{"id":19437959,"url":"https://github.com/architect/inventory","last_synced_at":"2025-04-24T21:32:37.890Z","repository":{"id":40418828,"uuid":"288460241","full_name":"architect/inventory","owner":"architect","description":"Architect project resource enumeration utility","archived":false,"fork":false,"pushed_at":"2025-04-19T14:18:19.000Z","size":728,"stargazers_count":4,"open_issues_count":4,"forks_count":8,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-19T18:28:30.803Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/architect.png","metadata":{"files":{"readme":"readme.md","changelog":"changelog.md","contributing":".github/contributing.md","funding":null,"license":"LICENSE","code_of_conduct":".github/code_of_conduct.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-08-18T13:13:50.000Z","updated_at":"2025-04-05T14:20:11.000Z","dependencies_parsed_at":"2023-02-17T23:46:08.448Z","dependency_job_id":"96c543af-1193-4755-8702-4e6c3a69c839","html_url":"https://github.com/architect/inventory","commit_stats":{"total_commits":382,"total_committers":7,"mean_commits":54.57142857142857,"dds":0.0680628272251309,"last_synced_commit":"2e0ae2de5ba8b83ba3502092c86e8c9411434628"},"previous_names":[],"tags_count":139,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/architect%2Finventory","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/architect%2Finventory/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/architect%2Finventory/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/architect%2Finventory/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/architect","download_url":"https://codeload.github.com/architect/inventory/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250713158,"owners_count":21475138,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-10T15:16:22.986Z","updated_at":"2025-04-24T21:32:37.527Z","avatar_url":"https://github.com/architect.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[\u003cimg src=\"https://assets.arc.codes/architect-logo-500b@2x.png\" width=500\u003e](https://www.npmjs.com/package/@architect/inventory)\n\n## [`@architect/inventory`](https://www.npmjs.com/package/@architect/inventory)\n\n\u003e Architect project resource enumeration utility\n\n[![GitHub CI status](https://github.com/architect/inventory/workflows/Node%20CI/badge.svg)](https://github.com/architect/inventory/actions?query=workflow%3A%22Node+CI%22)\n\n\nInventory is responsible for interpreting the configuration and shape of a given Architect project, validating its settings, and representing it in a consistent intermediate format.\n\n\n## Install\n\n```\nnpm i @architect/inventory\n```\n\n\n## Usage\n\n### `inventory(options[, callback]) → [Promise]`\n\nRuns an inventory against your project. Must be passed an options object that may containing the following parameters:\n\n- `cwd` - **String** - Absolute file path of the project being inventoried\n- `env` - **Boolean** - Queries AWS infra to acquire environment variables for `testing`, `staging`, and `production` environments\n- `layerValidation` - **Boolean** (default `true`) - Opt into skipping Lambda layer validation\n- `rawArc` - **String** - Raw Architect project manifest string, intended for testing; providing this will ignore your local manifest\n- `region` - **String** - Sets default AWS region; overrides default, but is overridden by `AWS_REGION` env var\n\nReturns results via `callback`, or returns a `promise` if `callback` is falsy, and resolves with results.\n\n\n### Inventory object\n\nInventory returns an object containing two parameters: `inv` (the project inventory object) and `get` (a getter helper for querying resources).\n\n\n#### `inv`\n\nThe inventory object contains the entirety of a project's data, including Architect defaults, project defaults, inferred resources, userland settings layered from the project and function levels, local preferences, etc. **An inventory object should be considered the source of truth about the state of your project, and should not be directly mutated.**\n\nTop-level inventory parameters that start with an underscore (e.g. `_arc`, `_project`) denote project metadata or internal diagnostic data; all other parameters represent userland project resources.\n\nIn a project inventory, `null` values are used as placeholders for known values or options that were not user-defined. The existence of a non-`null` value can be inferred as a user having specifically defined a setting. For example: `arc.http: null` can be construed as the user having **not** defined an `@http` pragma. This rule has some exceptions:\n\n- A handful of settings that must be backfilled if not supplied\n  - Example: `inv.aws.region`, which is required by the `aws-sdk` to function, and will be backfilled if not defined\n- Pragmas that infer other pragmas\n  - Example: while `@static` can be defined on its own without any other pragmas, the existence of `@http` infers `@static`\n  - Thus, the act of adding `@http` will necessarily make `inv.static` non-`null`\n- Settings that generate related resources\n  - Example: DynamoDB streams can be defined in `@tables` with `stream true`; Inventory would interpret a table with `stream true` as a new `inv['tables-streams']` resource and thus make `inv['tables-streams']` non-`null`\n- Lambda `handlerFile` file path property is present even if the file is not\n  - This differs from Lambda `configFile` file path properties, which will be `null` if no file is present\n  - This exception is namely because some workflows may need the computed default handler path (example: when running `arc create`)\n\n\n#### `get`\n\nYou do not need to use the `get` helper to use a project's inventory, but `get` does make it much easier to check for the existence of resources, or find specific resources.\n\nThe `get` helper works as such: `get.{pragma or property}('parameter or name of resource')`. (Not including a parameter or resource name will fail in most cases.)\n\nExamples:\n\n```arc\n@app\nmy-app\n\n@http\nget /\n\n@events\nevent\n```\n\n```js\nget.app()             // Returns my-app; same as accessing `inv.app`\n\nget.http('get /')     // Returns `get /` resource data\nget.http('get /foo')  // Returns undefined\nget.http()            // Returns undefined\n\nget.static('folder')  // Returns 'public' (default inferred by existence of @http); same as accessing `inv.app.static`\n\nget.events('event')   // Returns `event` resource data\n\nget.tables('data')    // Returns undefined\n```\n\n\n### `aws-sdk` caveat\n\nInventory conditionally requires `aws-sdk` if being used with the `env` param (e.g. `await inventory({ env: true })`). Early versions of Inventory included `aws-sdk` in `peerDependencies`, which prior to npm 7 would not automatically install `aws-sdk`. This is because Architect assumes you already have `aws-sdk` installed via Architect, or that it's available at runtime if you're using Inventory in a Lambda.\n\nHowever, npm 7 (once again) changed the behavior of `peerDependencies`, now automatically installing all `peerDependencies` (instead of merely printing a reminder). This means any Lambdas that use Inventory would get a \u003e50MB dependency payload if deployed on a machine with npm 7.\n\nAs such, Inventory now errors if the `env` param is set, and  `aws-sdk` is not installed. We are sorry to make this a userland issue, but we feel this is preferable to unnecessarily and invisibly causing `aws-sdk` to be installed in Lambdas.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farchitect%2Finventory","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farchitect%2Finventory","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farchitect%2Finventory/lists"}