@alienplatform/core

中文文档
3.3.54发布于 2026/11/05FSL-1.1-Apache-2.0TypeScriptES Module近 30 天下载 7.8万

Core types and schemas for the Alien platform

原始使用文档

Deployment-time container resources

Use fixed CPU and memory allocations when every deployment has the same workload. Use ranges when an installer should choose resources without publishing another release:

const api = new Container("api")
  .cpu({ min: 0.5, max: 4, default: 1 })
  .memory({ min: "512Mi", max: "8Gi", default: "2Gi" })

Select allocations when creating or preparing a deployment:

const settings = {
  compute: {
    containers: {
      api: { cpu: 2, memory: "4Gi" },
    },
    pools: {
      general: {
        mode: "autoscale",
        min: 1,
        max: 5,
      },
    },
  },
}

CPU is in vCPUs; memory uses binary units (Ki, Mi, Gi, Ti). Omitted selections use the release's defaults. Fixed .cpu(1) and .memory("2Gi") declarations remain fixed. Unknown containers and allocations outside the declared ranges are rejected before provisioning workloads.

Container allocations are portable across AWS, GCP, Azure, and Kubernetes. Pool machine names are provider-specific: use an EC2 instance type, a GCE machine type, or an Azure VM SKU. Compute planning uses the selected container allocations to recommend suitable machines and validate fleet capacity.

Omit machine to let Alien choose it from the selected resources on setup and later updates. Set machine to a provider machine name to override that choice; remove the override to return to automatic sizing. A resource update can replace the machine while keeping the pool's count policy and persistent volumes. Single-replica stateful workloads may restart during replacement. An explicit machine that cannot fit the allocation is rejected before cloud changes.

These are deployment choices, not vertical autoscaling. Each replica receives the selected allocation. An autoscaling machine pool adds capacity when replicas need it, within the pool's minimum and maximum. A fixed pool cannot add machines, and adding machines cannot make a single replica fit on an undersized machine.

The same resource choices work for stateful containers. Choosing CPU and memory does not change persistent disk size or enable horizontal autoscaling of stateful replicas.

CloudFormation exposes declared choices as parameters such as ContainerApiCpu and ContainerApiMemory. Terraform and API deployments carry selections in deployment settings. The deployment portal exposes the declared ranges and replans machine choices when allocations change.

Conditional inputs

Use when for inputs that only apply while another boolean input has a given value:

const io = alien.inputs({
  snapshotsEnabled: alien.boolean({
    providedBy: "deployer", required: true, default: true,
    label: "Snapshots enabled", description: "Keep periodic snapshots.",
  }),
  snapshotBucket: alien.string({
    providedBy: "deployer", required: true,
    label: "Snapshot bucket", description: "Bucket for snapshots.",
    when: { input: "snapshotsEnabled", equals: true },
    env: "SNAPSHOT_BUCKET",
  }),
})

The condition reads the provided boolean, otherwise its default. Inactive inputs are not asked for, required, validated or mapped into environment variables. Provided values for inactive inputs are ignored, so callers can submit full forms. When active, the input's normal requiredness and validation apply.

The referenced input must be a boolean in the same stack and must not have its own when. Self-references, chains and cycles are rejected. A conditional boolean cannot gate a resource with .enabled(). A deployer-provided input requires a controller that can also be provided by the deployer; developer-only controllers may control developer-only inputs. when cannot be combined with generate. An input excluded from the deployment platform does not apply. An off-platform controller resolves to false, so equals: false matches and equals: true does not. An unanswered on-platform reference matches neither value.

Both the CLI and manager must include conditional-input support before releasing or installing a stack that uses when. Version 3.3.43 predates that support; until a supporting release is tagged, build both from the revision introducing this feature or newer. Older CLIs and managers can require inactive inputs. Hosted management must also have conditional-input support deployed before any stack using when is released.

Terraform modules using conditional inputs require Terraform 1.9 or newer. CloudFormation uses Rules for conditional requiredness; other constraints are validated during registration because CloudFormation parameter constraints apply even when an input is inactive.

CloudFormation does not evaluate Rules when creating a CREATE change set. It checks them during stack creation: a failed assertion rolls the stack back before creating resources. Validate both condition states with CreateStack, not only CreateChangeSet.

Storage notification declarations

See storage notifications into queues for the .notify(queue, options) API, filter limits, lifecycle ownership and delivery semantics.

版本与发布记录

@alienplatform/core 共发布 100 个版本,首次发布于 2026/03/14;过去 12 个月发布了 100 个版本。

版本发布日期距今
3.3.54latest2026/11/05今天
3.3.532026/11/041 天前
3.3.522026/11/042 天前
3.3.512026/11/042 天前
3.3.502026/11/032 天前
3.3.492026/11/024 天前

其他发布通道:dev → 3.3.42-dev.6e3a661b219b3886d55014b3cef8af0ecdcc65fe。

关于 @alienplatform/core 的常见问题

@alienplatform/core 是什么?

Core types and schemas for the Alien platform

如何安装 @alienplatform/core?

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

@alienplatform/core 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@alienplatform/core 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@alienplatform/core 可以商用吗?

@alienplatform/core 使用 FSL-1.1-Apache-2.0 许可。声明的许可为 FSL-1.1-Apache-2.0,请阅读许可原文确认使用条件。以上为概括,不构成法律意见,请以许可原文为准。

@alienplatform/core 的下载量有多少?

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

@alienplatform/core 还在维护吗?

最新版本 3.3.54 发布于 2026/11/05(今天);至今共发布 100 个版本,其中过去 12 个月发布了 100 个;首次发布于 2026/03/14。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。