@architect/inventory

中文文档
6.1.0发布于 2026/01/16Apache-2.0CommonJS构建来源已验证近 30 天下载 623.7万

Architect project resource enumeration utility

原始使用文档
文档目录6 节
  1. @architect/inventory
  2. Install
  3. Usage
  4. inventory(options[, callback]) → [Promise]
  5. Inventory object
  6. aws-sdk caveat

@architect/inventory

Architect project resource enumeration utility

GitHub CI status

Inventory is responsible for interpreting the configuration and shape of a given Architect project, validating its settings, and representing it in a consistent intermediate format.

Install

npm i @architect/inventory

Usage

inventory(options[, callback]) → [Promise]

Runs an inventory against your project. Must be passed an options object that may containing the following parameters:

  • cwd - String - Absolute file path of the project being inventoried
  • env - Boolean - Queries AWS infra to acquire environment variables for testing, staging, and production environments
  • layerValidation - Boolean (default true) - Opt into skipping Lambda layer validation
  • rawArc - String - Raw Architect project manifest string, intended for testing; providing this will ignore your local manifest
  • region - String - Sets default AWS region; overrides default, but is overridden by AWS_REGION env var

Returns results via callback, or returns a promise if callback is falsy, and resolves with results.

Inventory object

Inventory returns an object containing two parameters: inv (the project inventory object) and get (a getter helper for querying resources).

inv

The 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.

Top-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.

In 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:

  • A handful of settings that must be backfilled if not supplied
    • Example: inv.aws.region, which is required by the aws-sdk to function, and will be backfilled if not defined
  • Pragmas that infer other pragmas
    • Example: while @static can be defined on its own without any other pragmas, the existence of @http infers @static
    • Thus, the act of adding @http will necessarily make inv.static non-null
  • Settings that generate related resources
    • 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
  • Lambda handlerFile file path property is present even if the file is not
    • This differs from Lambda configFile file path properties, which will be null if no file is present
    • This exception is namely because some workflows may need the computed default handler path (example: when running arc create)

get

You 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.

The 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.)

Examples:

@app
my-app

@http
get /

@events
event
get.app()             // Returns my-app; same as accessing `inv.app`

get.http('get /')     // Returns `get /` resource data
get.http('get /foo')  // Returns undefined
get.http()            // Returns undefined

get.static('folder')  // Returns 'public' (default inferred by existence of @http); same as accessing `inv.app.static`

get.events('event')   // Returns `event` resource data

get.tables('data')    // Returns undefined

aws-sdk caveat

Inventory 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.

However, 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 >50MB dependency payload if deployed on a machine with npm 7.

As 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.

版本与发布记录

@architect/inventory 共发布 150 个版本,首次发布于 2020/08/21;过去 12 个月发布了 5 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
6.1.0latest2026/01/169 个月前
6.1.0-RC.1RC2026/01/099 个月前
6.1.0-RC.02026/01/099 个月前
6.0.02025/11/2811 个月前
6.0.0-RC.02025/11/2611 个月前
5.0.02025/09/251.1 年前

关于 @architect/inventory 的常见问题

@architect/inventory 是什么?

Architect project resource enumeration utility

如何安装 @architect/inventory?

在项目目录运行 npm install @architect/inventory,或使用 pnpm add / yarn add / bun add。

@architect/inventory 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/architect__inventory 是否存在。

@architect/inventory 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@architect/inventory 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@architect/inventory 可以商用吗?

@architect/inventory 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@architect/inventory 的下载量有多少?

根据 npm 官方下载统计,@architect/inventory 在 2026/10/07 – 2026/11/05 这 30 天内被下载 6,236,518 次,日均约 207,884 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@architect/inventory 还在维护吗?

最新版本 6.1.0 发布于 2026/01/16(9 个月前);至今共发布 150 个版本,其中过去 12 个月发布了 5 个;首次发布于 2020/08/21。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。