@alienplatform/core 3.3.10 → 3.3.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -6283,7 +6283,7 @@ type EmailOutputs = z$2.infer<typeof EmailOutputsSchema>;
6283
6283
  //#endregion
6284
6284
  //#region src/generated/zod/email-schema.d.ts
6285
6285
  /**
6286
- * @description Email infrastructure for sending and receiving mail on customer-owned\ndomains. On AWS this is backed by SES: a shared configuration set, optional\ninbound/event wiring, and one email identity (Easy DKIM) per seed domain.\n\n# Infrastructure vs runtime data\n\nThis resource owns the email *infrastructure* and the capability to use it,\nnot the domain lifecycle. Deployment manages the configuration set, the\nevent topology, the inbound receipt topology, and any seed identities\nlisted in `domains`. Email identities created at runtime through the\n`email/manage-identities` grant are application data: they are not tracked\nby the deployment, are not removed when the stack is deleted, and their\nlifecycle — including deletion — belongs to the application.\n\nThe operator (or the application, for runtime-created identities) owns DNS:\nthe per-domain DKIM CNAME records surfaced in [`EmailOutputs`] must be\ncreated before SES verifies a domain and allows sending from it.\n\n# Inbound mail (AWS)\n\nWhen `inbound` is set, a SES receipt rule set is provisioned that writes\nraw incoming mail into the linked Storage bucket. The receipt rule is a\ncatch-all (no recipient filter), so mail for identities verified at runtime\nlands in the bucket without any infrastructure change.\n\nAlien activates the provisioned receipt rule set as part of setup. Because\nSES permits only one active receipt rule set per AWS account and region, an\nAWS stack may contain only one email resource with inbound delivery, and\ninstalling it makes its rule set the account\'s active rule set. SES email\nreceiving is available only in a subset of AWS regions; deploying `inbound`\nto an unsupported region fails during setup.\n\n# Update semantics\n\n`domains` is append-friendly: adding a domain provisions a new identity,\nremoving a domain deletes its identity (and its DKIM verification state).\nThe list may be empty. `inbound` and `events` may be added, removed, or\nrepointed; removing them tears down the corresponding receipt rule set /\nevent destination wiring.
6286
+ * @description Email infrastructure for sending and receiving mail on customer-owned\ndomains. On AWS this is backed by SES: a shared configuration set, optional\ninbound/event wiring, and one email identity (Easy DKIM) per seed domain.\n\n# Infrastructure vs runtime data\n\nThis resource owns the email *infrastructure* and the capability to use it,\nnot the domain lifecycle. Deployment manages the configuration set, the\nevent topology, the inbound receipt topology, and any seed identities\nlisted in `domains`. Email identities created at runtime through the\n`email/manage-identities` grant are application data: they are not tracked\nby the deployment, are not removed when the stack is deleted, and their\nlifecycle — including deletion — belongs to the application.\n\nThe operator (or the application, for runtime-created identities) owns DNS:\nthe per-domain DKIM CNAME records surfaced in [`EmailOutputs`] must be\ncreated before SES verifies a domain and allows sending from it.\n\n# Inbound mail (AWS)\n\nWhen `inbound` is set, a SES receipt rule set is provisioned that writes\nraw incoming mail into the linked Storage bucket. The receipt rule is a\ncatch-all (no recipient filter), so mail for identities verified at runtime\nlands in the bucket without any infrastructure change.\n\nAlien activates the provisioned receipt rule set as part of setup. Because\nSES permits only one active receipt rule set per AWS account and region, an\nAWS stack may contain only one email resource with inbound delivery. The\nresource requires exclusive ownership of SES receiving in its account and\nregion: setup refuses to replace an active rule set it does not own. Choose\nan unused region when the account already receives email through SES. SES email\nreceiving is available only in a subset of AWS regions; deploying `inbound`\nto an unsupported region fails during setup.\n\n# Update semantics\n\n`domains` is append-friendly: adding a domain provisions a new identity,\nremoving a domain deletes its identity (and its DKIM verification state).\nThe list may be empty. `inbound` and `events` may be added, removed, or\nrepointed; removing them tears down the corresponding receipt rule set /\nevent destination wiring.
6287
6287
  */
6288
6288
  declare const EmailSchema: z$2.ZodObject<{
6289
6289
  domains: z$2.ZodOptional<z$2.ZodArray<z$2.ZodString>>;
@@ -7930,10 +7930,10 @@ type HealthCheck = z$2.infer<typeof HealthCheckSchema>;
7930
7930
  //#endregion
7931
7931
  //#region src/generated/zod/heartbeat-backend-schema.d.ts
7932
7932
  declare const HeartbeatBackendSchema: z$2.ZodEnum<{
7933
+ external: "external";
7933
7934
  aws: "aws";
7934
7935
  azure: "azure";
7935
7936
  gcp: "gcp";
7936
- external: "external";
7937
7937
  kubernetes: "kubernetes";
7938
7938
  local: "local";
7939
7939
  test: "test";
@@ -10806,10 +10806,10 @@ type ObservedHealth = z$2.infer<typeof ObservedHealthSchema>;
10806
10806
  //#region src/generated/zod/observed-inventory-batch-schema.d.ts
10807
10807
  declare const ObservedInventoryBatchSchema: z$2.ZodObject<{
10808
10808
  backend: z$2.ZodEnum<{
10809
+ external: "external";
10809
10810
  aws: "aws";
10810
10811
  azure: "azure";
10811
10812
  gcp: "gcp";
10812
- external: "external";
10813
10813
  kubernetes: "kubernetes";
10814
10814
  local: "local";
10815
10815
  test: "test";
@@ -17336,10 +17336,10 @@ type ResourceHeartbeatData = z$2.infer<typeof ResourceHeartbeatDataSchema>;
17336
17336
  //#region src/generated/zod/resource-heartbeat-schema.d.ts
17337
17337
  declare const ResourceHeartbeatSchema: z$2.ZodObject<{
17338
17338
  backend: z$2.ZodEnum<{
17339
+ external: "external";
17339
17340
  aws: "aws";
17340
17341
  azure: "azure";
17341
17342
  gcp: "gcp";
17342
- external: "external";
17343
17343
  kubernetes: "kubernetes";
17344
17344
  local: "local";
17345
17345
  test: "test";
@@ -23352,8 +23352,8 @@ declare const StackInputDefinitionSchema: z$2.ZodObject<{
23352
23352
  number: "number";
23353
23353
  boolean: "boolean";
23354
23354
  enum: "enum";
23355
- stringList: "stringList";
23356
23355
  secret: "secret";
23356
+ stringList: "stringList";
23357
23357
  integer: "integer";
23358
23358
  }>;
23359
23359
  label: z$2.ZodString;
@@ -23419,8 +23419,8 @@ declare const StackInputKindSchema: z$2.ZodEnum<{
23419
23419
  number: "number";
23420
23420
  boolean: "boolean";
23421
23421
  enum: "enum";
23422
- stringList: "stringList";
23423
23422
  secret: "secret";
23423
+ stringList: "stringList";
23424
23424
  integer: "integer";
23425
23425
  }>;
23426
23426
  type StackInputKind = z$2.infer<typeof StackInputKindSchema>;
@@ -23559,8 +23559,8 @@ declare const StackSchema: z$2.ZodObject<{
23559
23559
  number: "number";
23560
23560
  boolean: "boolean";
23561
23561
  enum: "enum";
23562
- stringList: "stringList";
23563
23562
  secret: "secret";
23563
+ stringList: "stringList";
23564
23564
  integer: "integer";
23565
23565
  }>;
23566
23566
  label: z$2.ZodString;
@@ -25970,464 +25970,616 @@ declare abstract class ResourceBuilder {
25970
25970
  protected resource(config: BaseResource): Resource;
25971
25971
  }
25972
25972
  //#endregion
25973
- //#region src/storage.d.ts
25973
+ //#region src/ai.d.ts
25974
25974
  /**
25975
- * Represents an object storage bucket.
25975
+ * Represents an AI Gateway resource that provides a unified interface to
25976
+ * managed AI inference services across cloud providers.
25976
25977
  */
25977
- declare class Storage extends ResourceBuilder {
25978
+ declare class AI extends ResourceBuilder {
25978
25979
  private _config;
25979
25980
  /**
25980
- * Creates a new Storage builder.
25981
- * @param id ID of the storage bucket. For names with dots, each dot-separated label must be ≤ 63 characters.
25981
+ * Creates a new AI builder.
25982
+ * @param id Identifier for the AI resource. Must contain only alphanumeric characters, hyphens, and underscores ([A-Za-z0-9-_]). Maximum 64 characters.
25982
25983
  */
25983
25984
  constructor(id: string);
25984
25985
  /**
25985
- * Returns a ResourceType representing any storage resource.
25986
- * Used for creating permission targets that apply to all storage resources.
25987
- * @returns The "storage" resource type.
25986
+ * Returns a ResourceType representing any AI resource.
25987
+ * Used for creating permission targets that apply to all AI resources.
25988
+ * @returns The "ai" resource type.
25988
25989
  */
25989
25990
  static any(): ResourceType;
25990
25991
  /**
25991
- * Allows public read access to objects without authentication.
25992
- * Default: `false`.
25993
- * @param value Whether to allow public read access.
25994
- * @returns The Storage builder instance.
25995
- */
25996
- publicRead(value: boolean): this;
25997
- /**
25998
- * Enables object versioning.
25999
- * Default: `false`.
26000
- * @param value Whether to enable versioning.
26001
- * @returns The Storage builder instance.
26002
- */
26003
- versioning(value: boolean): this;
26004
- /**
26005
- * Defines lifecycle rules for automatic object management (e.g., expiration).
26006
- * @param rules An array of lifecycle rules.
26007
- * @returns The Storage builder instance.
26008
- */
26009
- lifecycleRules(rules: LifecycleRule[]): this;
26010
- /**
26011
- * Allows browser reads from the listed origins through signed URLs.
26012
- * Providers enable `GET` and `HEAD`; use `*` only when the signed URL itself
26013
- * is the credential and browser cookies are not involved.
26014
- * @param origins Allowed browser origins.
26015
- * @returns The Storage builder instance.
26016
- */
26017
- corsAllowedOrigins(origins: string[]): this;
26018
- /**
26019
- * Builds and validates the storage configuration.
26020
- * @returns An immutable Resource representing the configured storage bucket.
26021
- * @throws Error if the storage configuration is invalid.
25992
+ * Builds and validates the AI configuration.
25993
+ * @returns An immutable Resource representing the configured AI Gateway.
25994
+ * @throws Error if the AI configuration is invalid.
26022
25995
  */
26023
25996
  build(): Resource;
26024
25997
  }
26025
25998
  //#endregion
26026
- //#region src/worker.d.ts
26027
- interface WorkerPublicEndpointOptions {
26028
- hostLabel?: string;
26029
- wildcardSubdomains?: boolean;
26030
- }
25999
+ //#region src/artifact-registry.d.ts
26031
26000
  /**
26032
- * Represents a serverless worker that executes code in response to triggers or direct invocations.
26033
- * Workers are the primary compute resource in serverless applications, designed to be stateless and ephemeral.
26001
+ * Represents an artifact registry for storing container images and other build artifacts.
26002
+ * This is a high-level wrapper resource that provides a cloud-agnostic interface over
26003
+ * AWS ECR, GCP Artifact Registry, and Azure Container Registry.
26034
26004
  */
26035
- declare class Worker extends ResourceBuilder {
26005
+ declare class ArtifactRegistry {
26036
26006
  private _config;
26037
26007
  /**
26038
- * Creates a new Worker builder.
26039
- * @param id Identifier for the worker. Must contain only alphanumeric characters, hyphens, and underscores ([A-Za-z0-9-_]). Maximum 64 characters.
26008
+ * Creates a new ArtifactRegistry builder.
26009
+ * @param id Identifier for the artifact registry. Must contain only alphanumeric characters, hyphens, and underscores ([A-Za-z0-9-_]). Maximum 64 characters.
26040
26010
  */
26041
26011
  constructor(id: string);
26042
26012
  /**
26043
- * Returns a ResourceType representing any worker resource.
26044
- * Used for creating permission targets that apply to all worker resources.
26045
- * @returns The "worker" resource type.
26013
+ * Returns a ResourceType representing any artifact registry resource.
26014
+ * Used for creating permission targets that apply to all artifact registry resources.
26015
+ * @returns The "artifact-registry" resource type.
26046
26016
  */
26047
26017
  static any(): ResourceType;
26048
26018
  /**
26049
- * Sets the code for the worker, either a pre-built image or source code to be built.
26050
- * @param code The worker code configuration.
26051
- * @returns The Worker builder instance.
26019
+ * AWS-only: Configure ECR private image replication to additional regions.
26020
+ * Ensures images pushed in the registry's home region are automatically
26021
+ * available in these destination regions (required when Lambda or other
26022
+ * compute runs in a different region).
26023
+ * @param regions - AWS region codes to replicate to (e.g., ["us-east-2", "eu-west-1"])
26052
26024
  */
26053
- code(code: WorkerCode): this;
26025
+ replicationRegions(regions: string[]): this;
26054
26026
  /**
26055
- * Sets the memory allocated to the worker in megabytes (MB).
26056
- * Constraints: 128‑32768 MB (platform-specific limits may apply).
26057
- * Default: 512 MB.
26058
- * @param mb The memory in MB.
26059
- * @returns The Worker builder instance.
26027
+ * Builds and validates the artifact registry configuration.
26028
+ * @returns An immutable Resource representing the configured artifact registry.
26029
+ * @throws Error if the artifact registry configuration is invalid.
26060
26030
  */
26061
- memoryMb(mb: number): this;
26031
+ build(): Resource;
26032
+ }
26033
+ //#endregion
26034
+ //#region src/build.d.ts
26035
+ /**
26036
+ * Represents a build resource that executes bash scripts to build code.
26037
+ * Builds are designed to be stateless and can be triggered on-demand to compile,
26038
+ * test, or package application code.
26039
+ */
26040
+ declare class Build {
26041
+ private _config;
26062
26042
  /**
26063
- * Sets the maximum execution time for the worker in seconds.
26064
- * Constraints: 1‑3600 seconds (platform-specific limits may apply).
26065
- * Default: 30 seconds.
26066
- * @param sec The timeout in seconds.
26067
- * @returns The Worker builder instance.
26043
+ * Creates a new Build builder.
26044
+ * @param id Identifier for the build resource. Must contain only alphanumeric characters, hyphens, and underscores ([A-Za-z0-9-_]). Maximum 64 characters.
26068
26045
  */
26069
- timeoutSeconds(sec: number): this;
26046
+ constructor(id: string);
26070
26047
  /**
26071
- * Sets the maximum number of concurrent executions allowed for the worker.
26072
- * `null` means platform default applies.
26073
- * @param limit The concurrency limit, or `null` for platform default.
26074
- * @returns The Worker builder instance.
26048
+ * Returns a ResourceType representing any build resource.
26049
+ * Used for creating permission targets that apply to all build resources.
26050
+ * @returns The "build" resource type.
26075
26051
  */
26076
- concurrencyLimit(limit: number | undefined): this;
26052
+ static any(): ResourceType;
26077
26053
  /**
26078
- * Exposes a named public HTTP endpoint for the worker.
26079
- *
26080
- * If no public endpoint is declared, the worker is private and only reachable
26081
- * through triggers, commands, or provider invocation APIs.
26054
+ * Sets the compute type for the build.
26055
+ * @param type The compute type (small, medium, large, x-large).
26056
+ * @returns The Build builder instance.
26082
26057
  */
26083
- publicEndpoint(name: string, options?: WorkerPublicEndpointOptions): this;
26058
+ computeType(type: ComputeType): this;
26084
26059
  /**
26085
- * Sets key-value pairs as environment variables for the worker.
26060
+ * Sets key-value pairs as environment variables for the build.
26086
26061
  * @param env A map of environment variable names to their values.
26087
- * @returns The Worker builder instance.
26062
+ * @returns The Build builder instance.
26088
26063
  */
26089
26064
  environment(env: Record<string, string>): this;
26090
26065
  /**
26091
- * Links another resource (e.g., Storage, KV, Queue) to this worker.
26092
- * This makes the linked resource accessible to the worker, often by injecting
26066
+ * Links another resource (e.g., Storage, ArtifactRegistry, Role) to this build.
26067
+ * This makes the linked resource accessible to the build, often by injecting
26093
26068
  * environment variables or granting permissions.
26094
26069
  * @param resource The resource to link.
26095
- * @returns The Worker builder instance.
26070
+ * @returns The Build builder instance.
26096
26071
  */
26097
26072
  link(resource: Resource): this;
26098
26073
  /**
26099
- * Assigns a permission profile to this worker.
26100
- * The profile defines the permissions granted to this worker when interacting
26074
+ * Assigns a permission profile to this build.
26075
+ * The profile defines the permissions granted to this build when interacting
26101
26076
  * with other cloud resources.
26102
26077
  * @param permissions The permission profile name.
26103
- * @returns The Worker builder instance.
26078
+ * @returns The Build builder instance.
26104
26079
  */
26105
26080
  permissions(permissions: string): this;
26106
26081
  /**
26107
- * Configures a readiness probe for the worker.
26108
- * The probe will be executed after provisioning/update to verify the worker is ready.
26109
- * Only works with workers that declare a public endpoint.
26110
- *
26111
- * @example
26112
- * ```typescript
26113
- * const probe: ReadinessProbe = {
26114
- * method: "GET",
26115
- * path: "/health"
26116
- * };
26117
- *
26118
- * const func = new Worker("my-api")
26119
- * .code({ type: "image", image: "my-api:latest" })
26120
- * .publicEndpoint("api")
26121
- * .readinessProbe(probe)
26122
- * .build();
26123
- * ```
26124
- *
26125
- * @param probe The readiness probe configuration.
26126
- * @returns The Worker builder instance.
26127
- */
26128
- readinessProbe(probe: ReadinessProbe): this;
26129
- /**
26130
- * Enables or disables the Commands protocol for the worker.
26131
- * When enabled, the platform pushes commands into the Worker runtime, which executes registered handlers.
26132
- * Default: false.
26133
- * @param enabled Whether to enable commands for this worker.
26134
- * @returns The Worker builder instance.
26135
- */
26136
- commandsEnabled(enabled: boolean): this;
26137
- /**
26138
- * Adds a trigger to the worker. Workers can have multiple triggers.
26139
- * Each trigger will independently invoke the worker when its conditions are met.
26140
- *
26141
- * @example
26142
- * ```typescript
26143
- * // Queue trigger
26144
- * const queueTrigger: WorkerTrigger = {
26145
- * type: "queue",
26146
- * queue: myQueue.ref()
26147
- * };
26148
- *
26149
- * // Schedule trigger
26150
- * const scheduleTrigg: WorkerTrigger = {
26151
- * type: "schedule",
26152
- * cron: "0 * * * *"
26153
- * };
26154
- *
26155
- * const func = new Worker("my-func")
26156
- * .code({ type: "image", image: "my-image:latest" })
26157
- * .trigger(queueTrigger)
26158
- * .trigger(scheduleTrigger)
26159
- * .build();
26160
- * ```
26161
- *
26162
- * @param trigger The trigger configuration.
26163
- * @returns The Worker builder instance.
26164
- */
26165
- trigger(trigger: WorkerTrigger): this;
26166
- /**
26167
- * Builds and validates the worker configuration.
26168
- * @returns An immutable Resource representing the configured worker.
26169
- * @throws Error if the worker configuration is invalid (e.g., missing code).
26082
+ * Builds and validates the build configuration.
26083
+ * @returns An immutable Resource representing the configured build.
26084
+ * @throws Error if the build configuration is invalid.
26170
26085
  */
26171
26086
  build(): Resource;
26172
26087
  }
26173
26088
  //#endregion
26174
- //#region src/container.d.ts
26175
- type PublicEndpointOptions = "http" | "tcp" | {
26176
- protocol: "http" | "tcp";
26177
- hostLabel?: string;
26178
- wildcardSubdomains?: boolean;
26179
- };
26180
- interface PersistentStorageOptions {
26181
- /**
26182
- * Mount path inside the container.
26183
- *
26184
- * Defaults to `/data`.
26185
- */
26186
- mountPath?: string;
26187
- }
26089
+ //#region src/error.d.ts
26188
26090
  /**
26189
- * Represents a long-running container workload.
26091
+ * Base interface that all error type definitions must implement.
26190
26092
  *
26191
- * Containers run on compute instances (EC2, GCE, Azure VMs) and are orchestrated
26192
- * by the managed container backend. They're designed for always-on workloads
26193
- * like web services, APIs, databases, and background workers.
26093
+ * This provides the structure for creating type-safe error definitions
26094
+ * with Zod validation and contextual information.
26095
+ *
26096
+ * @template TContext - Zod schema type for the error context
26194
26097
  */
26195
- declare class Container extends ResourceBuilder {
26196
- private _config;
26197
- /**
26198
- * Creates a new Container builder.
26199
- * @param id Identifier for the container. Must be DNS-compatible: lowercase alphanumeric with hyphens.
26200
- */
26201
- constructor(id: string);
26098
+ interface AlienErrorMetadata<TContext extends z.ZodTypeAny> {
26099
+ /** Unique error code (e.g., "DATABASE_CONNECTION_FAILED") */
26100
+ code: string;
26101
+ /** Zod schema for type-safe context validation */
26102
+ context: TContext;
26103
+ /** Whether this error can be retried */
26104
+ retryable: boolean;
26105
+ /** Whether this error contains sensitive information */
26106
+ internal: boolean;
26107
+ /** HTTP status code for API responses */
26108
+ httpStatusCode?: number;
26109
+ /** Worker to generate human-readable error message from context */
26110
+ message: (context: z.infer<TContext>) => string;
26111
+ }
26112
+ /**
26113
+ * Helper function to create type-safe error definitions.
26114
+ *
26115
+ * This function provides a clean API for defining reusable error types
26116
+ * with full TypeScript type safety and Zod validation.
26117
+ *
26118
+ * @template TContext - Zod schema type for the error context
26119
+ * @param metadata - Error metadata including code, schema, and message generator
26120
+ * @returns Object with metadata and a create function for error instances
26121
+ *
26122
+ * @example
26123
+ * ```typescript
26124
+ * const UserNotFound = defineError({
26125
+ * code: "USER_NOT_FOUND",
26126
+ * context: z.object({
26127
+ * userId: z.string(),
26128
+ * searchMethod: z.string(),
26129
+ * }),
26130
+ * message: ({ userId, searchMethod }) =>
26131
+ * `User '${userId}' not found using method '${searchMethod}'`,
26132
+ * retryable: false,
26133
+ * internal: false,
26134
+ * httpStatusCode: 404,
26135
+ * })
26136
+ *
26137
+ * // Usage
26138
+ * const error = UserNotFound.create({
26139
+ * userId: "123",
26140
+ * searchMethod: "database_lookup"
26141
+ * })
26142
+ * ```
26143
+ */
26144
+ declare function defineError<TContext extends z.ZodTypeAny>(metadata: AlienErrorMetadata<TContext>): {
26145
+ metadata: AlienErrorMetadata<TContext>;
26146
+ contextSchema: TContext;
26147
+ create: (context: z.infer<TContext>) => AlienErrorDefinition<TContext>;
26148
+ };
26149
+ /**
26150
+ * Represents a specific error instance with its context.
26151
+ *
26152
+ * This is created by calling `.create()` on an error definition
26153
+ * and contains the actual context data for a specific error occurrence.
26154
+ *
26155
+ * @template TContext - Zod schema type for the error context
26156
+ */
26157
+ interface AlienErrorDefinition<TContext extends z.ZodTypeAny> {
26158
+ metadata: AlienErrorMetadata<TContext>;
26159
+ contextSchema: TContext;
26160
+ context: z.infer<TContext>;
26202
26161
  /**
26203
- * Returns a ResourceType representing any container resource.
26204
- * Used for creating permission targets that apply to all container resources.
26205
- * @returns The "container" resource type.
26162
+ * Convert this error definition directly to AlienErrorOptions.
26163
+ *
26164
+ * This allows you to get the wire format representation
26165
+ * without creating an AlienError instance first.
26166
+ *
26167
+ * @returns AlienErrorOptions object representing this error
26206
26168
  */
26207
- static any(): ResourceType;
26169
+ toOptions(): AlienError$1;
26170
+ }
26171
+ /**
26172
+ * Main AlienError class that provides structured error handling.
26173
+ *
26174
+ * This class extends the standard JavaScript Error with additional features:
26175
+ * - Type-safe context data
26176
+ * - Error chaining and source tracking
26177
+ * - Retryability and internal/external visibility flags
26178
+ * - HTTP status code mapping
26179
+ * - Sanitization for external APIs
26180
+ *
26181
+ * @template TContext - Zod schema type for the error context
26182
+ *
26183
+ * @example Basic Construction
26184
+ * ```typescript
26185
+ * const error = new AlienError(DatabaseError.create({
26186
+ * host: "localhost",
26187
+ * port: 5432,
26188
+ * reason: "Timeout"
26189
+ * }))
26190
+ * ```
26191
+ *
26192
+ * @example Converting JavaScript Errors
26193
+ * ```typescript
26194
+ * try {
26195
+ * JSON.parse("invalid json")
26196
+ * } catch (jsError) {
26197
+ * const alienError = AlienError.from(jsError)
26198
+ * console.log(alienError.code) // "GENERIC_ERROR"
26199
+ * }
26200
+ * ```
26201
+ *
26202
+ * @example Error Chaining
26203
+ * ```typescript
26204
+ * const contextualError = AlienError.from(new Error("Network timeout"))
26205
+ * .withContext(DatabaseError.create({
26206
+ * host: "localhost",
26207
+ * port: 5432,
26208
+ * reason: "Connection timeout"
26209
+ * }))
26210
+ *
26211
+ * // Check error chain
26212
+ * console.log(contextualError.hasErrorCode("DATABASE_CONNECTION_FAILED")) // true
26213
+ * console.log(contextualError.toString()) // Shows full error chain
26214
+ * ```
26215
+ */
26216
+ declare class AlienError<TContext extends z.ZodTypeAny = z.ZodAny> extends Error {
26217
+ /** Unique error code identifying the error type */
26218
+ readonly code: string;
26219
+ /** Whether this error can be safely retried */
26220
+ readonly retryable: boolean;
26221
+ /** Whether this error contains sensitive internal information */
26222
+ readonly internal: boolean;
26223
+ /** HTTP status code for API responses */
26224
+ readonly httpStatusCode: number;
26225
+ /** Type-safe context data specific to this error */
26226
+ readonly context?: z.infer<TContext>;
26227
+ /** Optional human-facing remediation hint */
26228
+ readonly hint?: string | null;
26229
+ /** Source error that caused this error (for chaining) */
26230
+ readonly source?: AlienError<any>;
26231
+ constructor(input: AlienErrorDefinition<TContext> | (AlienError$1 & {
26232
+ context?: any;
26233
+ }));
26208
26234
  /**
26209
- * Sets the container cluster this container runs on.
26210
- * @param clusterId The ComputeCluster resource ID.
26211
- * @returns The Container builder instance.
26235
+ * Create an AlienError from a type-safe error definition.
26236
+ *
26237
+ * @template TContext - Zod schema type for the error context
26238
+ * @param definition - Error definition with type-safe context
26239
+ * @returns New AlienError instance
26212
26240
  */
26213
- cluster(clusterId: string): this;
26241
+ static fromDefinition<TContext extends z.ZodTypeAny>(definition: AlienErrorDefinition<TContext>): AlienError<TContext>;
26214
26242
  /**
26215
- * Sets the code for the container, either a pre-built image or source code to be built.
26216
- * @param code The container code configuration.
26217
- * @returns The Container builder instance.
26243
+ * Create an AlienError from raw options (for compatibility).
26244
+ *
26245
+ * @param options - Raw error options conforming to AlienErrorOptions schema
26246
+ * @returns New AlienError instance
26218
26247
  */
26219
- code(code: ContainerCode): this;
26248
+ static fromOptions(options: AlienError$1): AlienError;
26220
26249
  /**
26221
- * Sets the CPU resources for the container.
26250
+ * Helper function to get a user-friendly type name for error context.
26222
26251
  *
26223
- * For simplified configuration, use a single number:
26224
- * - `.cpu(1)` sets both min and desired to 1 vCPU
26252
+ * @param error - Any value to get the type name for
26253
+ * @returns User-friendly type name
26254
+ */
26255
+ private static getErrorTypeName;
26256
+ /**
26257
+ * Convert a JavaScript Error or any object to a generic AlienError.
26225
26258
  *
26226
- * For advanced configuration, use ResourceSpec:
26227
- * - `.cpu({ min: "0.5", desired: "1" })`
26259
+ * This is equivalent to Rust's `.into_alien_error()` pattern and provides
26260
+ * a way to convert any JavaScript error into the structured AlienError format.
26228
26261
  *
26229
- * @param value CPU in vCPUs (number) or ResourceSpec with min/desired.
26230
- * @returns The Container builder instance.
26262
+ * @param error - Any JavaScript error or object to convert
26263
+ * @returns AlienError with GENERIC_ERROR code and preserved original error
26264
+ *
26265
+ * @example
26266
+ * ```typescript
26267
+ * try {
26268
+ * throw new TypeError("Invalid argument")
26269
+ * } catch (error) {
26270
+ * const alienError = AlienError.from(error)
26271
+ * console.log(alienError.code) // "GENERIC_ERROR"
26272
+ * console.log(alienError.context?.originalError) // Serialized TypeError
26273
+ * }
26274
+ * ```
26275
+ *
26276
+ * @example Chaining with context
26277
+ * ```typescript
26278
+ * try {
26279
+ * JSON.parse("invalid")
26280
+ * } catch (error) {
26281
+ * throw AlienError.from(error).withContext(
26282
+ * ValidationError.create({
26283
+ * input: "invalid",
26284
+ * expectedFormat: "JSON"
26285
+ * })
26286
+ * )
26287
+ * }
26288
+ * ```
26289
+ *
26290
+ * @example AxiosError conversion
26291
+ * ```typescript
26292
+ * try {
26293
+ * await axios.get('/api/resource')
26294
+ * } catch (error) {
26295
+ * // If error.response.data contains a valid AlienError structure, it will be parsed
26296
+ * const alienError = AlienError.from(error)
26297
+ * console.log(alienError.code) // Could be "REMOTE_RESOURCE_NOT_FOUND" if parsed from response
26298
+ * }
26299
+ * ```
26231
26300
  */
26232
- cpu(value: number | ResourceSpec): this;
26301
+ static from(error: any): Promise<AlienError>;
26233
26302
  /**
26234
- * Sets the memory resources for the container.
26303
+ * Add context to this error, creating a new error that wraps this one.
26235
26304
  *
26236
- * Format: "<number>Mi" or "<number>Gi"
26305
+ * This is equivalent to Rust's `.with_context()` pattern and allows
26306
+ * building error chains with increasing levels of context.
26237
26307
  *
26238
- * Example: "512Mi", "2Gi", "16Gi"
26308
+ * @template TNewContext - Zod schema type for the new context
26309
+ * @param definition - Error definition to wrap this error with
26310
+ * @returns New AlienError with this error as the source
26239
26311
  *
26240
- * @param size Memory size string.
26241
- * @returns The Container builder instance.
26312
+ * @example
26313
+ * ```typescript
26314
+ * // Clean fluent API
26315
+ * const authError = (await AlienError.from(new Error("ECONNREFUSED")))
26316
+ * .withContext(DatabaseError.create({
26317
+ * host: "localhost",
26318
+ * port: 5432,
26319
+ * reason: "Connection refused"
26320
+ * }))
26321
+ * .withContext(AuthError.create({
26322
+ * username: "john",
26323
+ * reason: "Database unavailable"
26324
+ * }))
26325
+ *
26326
+ * // Error chain: AuthError -> DatabaseError -> GENERIC_ERROR
26327
+ * console.log(authError.toString())
26328
+ * ```
26242
26329
  */
26243
- memory(size: string): this;
26330
+ withContext<TNewContext extends z.ZodTypeAny>(definition: AlienErrorDefinition<TNewContext>): AlienError<TNewContext>;
26244
26331
  /**
26245
- * Sets minimum and maximum replica counts with autoscaling configuration.
26332
+ * Convert this AlienError to the wire format (AlienErrorOptions).
26246
26333
  *
26247
- * @param min Minimum replicas (always running).
26248
- * @param max Maximum replicas under load.
26249
- * @returns The Container builder instance.
26334
+ * This method serializes the error into the standard format used
26335
+ * for transmitting errors over the network or storing them.
26336
+ *
26337
+ * @returns AlienErrorOptions object representing this error
26250
26338
  */
26251
- minReplicas(min: number): this;
26339
+ toOptions(): AlienError$1;
26252
26340
  /**
26253
- * Sets the maximum replica count for autoscaling.
26254
- * @param max Maximum replicas.
26255
- * @returns The Container builder instance.
26256
- */
26257
- maxReplicas(max: number): this;
26258
- /**
26259
- * Sets a fixed replica count (for stateful containers or stateless without autoscaling).
26260
- * Cannot be used with minReplicas/maxReplicas.
26261
- * @param count Fixed number of replicas.
26262
- * @returns The Container builder instance.
26263
- */
26264
- replicas(count: number): this;
26265
- /**
26266
- * Configures autoscaling behavior.
26267
- * @param config Autoscaling configuration.
26268
- * @returns The Container builder instance.
26269
- */
26270
- autoScale(config: ContainerAutoscaling): this;
26271
- /**
26272
- * Sets whether this container is stateful.
26273
- * Stateful containers get stable ordinals and support persistent storage.
26274
- * @param enabled Whether the container is stateful.
26275
- * @returns The Container builder instance.
26276
- */
26277
- stateful(enabled: boolean): this;
26278
- /**
26279
- * Adds an internal-only port to the container.
26280
- * Automatically creates DNS records for service discovery.
26281
- * @param port Port number (e.g., 3000, 8080, 5432).
26282
- * @returns The Container builder instance.
26283
- */
26284
- port(port: number): this;
26285
- /**
26286
- * Adds multiple internal-only ports to the container.
26287
- * @param ports Array of port numbers.
26288
- * @returns The Container builder instance.
26289
- */
26290
- ports(ports: number[]): this;
26291
- /**
26292
- * Exposes a named public endpoint for a container port.
26341
+ * Get a sanitized version for external APIs (hides internal errors).
26293
26342
  *
26294
- * Endpoint names are the stable contract for URLs, DNS, and runtime
26295
- * environment injection.
26343
+ * This method is crucial for security - it prevents sensitive internal
26344
+ * error details from being exposed to external users while preserving
26345
+ * the error chain structure for non-sensitive errors.
26296
26346
  *
26297
- * @param name Endpoint name, unique within this container.
26298
- * @param port Port number to expose.
26299
- * @param options "http"/"tcp" or endpoint options.
26300
- * @returns The Container builder instance.
26301
- */
26302
- publicEndpoint(name: string, port: number, options?: PublicEndpointOptions): this;
26303
- /**
26304
- * Sets environment variables for the container.
26305
- * @param vars Key-value pairs of environment variables.
26306
- * @returns The Container builder instance.
26307
- */
26308
- environment(vars: Record<string, string>): this;
26309
- /**
26310
- * Sets ephemeral storage size.
26311
- * Data is lost on container restart.
26312
- * @param size Storage size (e.g., "10Gi", "100Gi", "500Gi").
26313
- * @returns The Container builder instance.
26314
- */
26315
- ephemeralStorage(size: string): this;
26316
- /**
26317
- * Configures persistent storage and marks the container stateful.
26318
- * Data survives container restarts.
26319
- * @param size Storage size (e.g., "100Gi", "500Gi", "1Ti").
26320
- * @param options Optional mount path.
26321
- * @returns The Container builder instance.
26322
- */
26323
- persistentStorage(size: string, options?: PersistentStorageOptions): this;
26324
- /**
26325
- * Requests GPU resources.
26326
- * @param config GPU configuration with type and count.
26327
- * @returns The Container builder instance.
26328
- */
26329
- gpu(config: ContainerGpuSpec): this;
26330
- /**
26331
- * Configures health check for the container.
26332
- * @param config Health check configuration.
26333
- * @returns The Container builder instance.
26334
- */
26335
- healthCheck(config: HealthCheck): this;
26336
- /**
26337
- * Configures readiness probe (alias for healthCheck).
26338
- * @param config Readiness probe configuration with method and path.
26339
- * @returns The Container builder instance.
26340
- */
26341
- readinessProbe(config: {
26342
- method: string;
26343
- path: string;
26344
- }): this;
26345
- /**
26346
- * Sets the permission profile for this container.
26347
- * @param profile Permission profile name from stack permissions configuration.
26348
- * @returns The Container builder instance.
26349
- */
26350
- permissions(profile: string): this;
26351
- /**
26352
- * Assigns the container to a specific compute pool.
26353
- * @param poolName Compute pool name.
26354
- * @returns The Container builder instance.
26355
- */
26356
- pool(poolName: string): this;
26357
- /**
26358
- * Sets the command to override the image default.
26359
- * @param command Array of command arguments.
26360
- * @returns The Container builder instance.
26361
- */
26362
- command(command: string[]): this;
26363
- /**
26364
- * Sets the grace period used when stopping replicas during updates, drains, and deletes.
26347
+ * @returns Sanitized AlienErrorOptions safe for external consumption
26365
26348
  *
26366
- * The value is expressed in seconds. Valid values are 1 through 86400.
26349
+ * @example
26350
+ * ```typescript
26351
+ * const internalError = new AlienError(InternalApiError.create({
26352
+ * service: "payment-processor",
26353
+ * details: "Database password expired for user admin",
26354
+ * traceId: "trace-12345"
26355
+ * }))
26356
+ *
26357
+ * console.log(internalError.toOptions())
26358
+ * // Shows full details including sensitive information
26359
+ *
26360
+ * console.log(internalError.toExternal())
26361
+ * // { code: "GENERIC_ERROR", message: "Internal server error", ... }
26362
+ * ```
26367
26363
  */
26368
- stopGracePeriod(seconds: number): this;
26364
+ toExternal(): AlienError$1;
26369
26365
  /**
26370
- * Links this container to another resource (Storage, Queue, KV, etc.).
26371
- * @param resource The resource to link to.
26372
- * @returns The Container builder instance.
26366
+ * Check if this error chain contains an error with a specific code.
26367
+ *
26368
+ * This method traverses the entire error chain (this error and all
26369
+ * source errors) to find if any error has the specified code.
26370
+ *
26371
+ * @param code - Error code to search for
26372
+ * @returns True if the code is found anywhere in the error chain
26373
+ *
26374
+ * @example
26375
+ * ```typescript
26376
+ * const chainedError = authError.withContext(dbError.withContext(networkError))
26377
+ *
26378
+ * console.log(chainedError.hasErrorCode("AUTH_FAILED")) // true
26379
+ * console.log(chainedError.hasErrorCode("DATABASE_CONNECTION_FAILED")) // true
26380
+ * console.log(chainedError.hasErrorCode("NETWORK_TIMEOUT")) // true
26381
+ * console.log(chainedError.hasErrorCode("NONEXISTENT_ERROR")) // false
26382
+ * ```
26373
26383
  */
26374
- link(resource: Resource): this;
26384
+ hasErrorCode(code: string): boolean;
26375
26385
  /**
26376
- * Enables or disables the Commands protocol for the container.
26377
- * When enabled, an app-owned receiver can lease this Container's pending commands and execute registered handlers.
26378
- * Default: false.
26379
- * @param enabled Whether to enable commands for this container.
26380
- * @returns The Container builder instance.
26386
+ * Find the first error in the chain with a specific code.
26387
+ *
26388
+ * This method traverses the error chain and returns the first error
26389
+ * instance that matches the specified code, allowing access to its
26390
+ * specific context and details.
26391
+ *
26392
+ * @param code - Error code to search for
26393
+ * @returns AlienError instance with the specified code, or undefined if not found
26394
+ *
26395
+ * @example
26396
+ * ```typescript
26397
+ * const chainedError = authError.withContext(dbError)
26398
+ *
26399
+ * const dbError = chainedError.findErrorByCode("DATABASE_CONNECTION_FAILED")
26400
+ * if (dbError) {
26401
+ * console.log("Database error context:", dbError.context)
26402
+ * console.log("Host:", dbError.context?.host)
26403
+ * }
26404
+ * ```
26381
26405
  */
26382
- commandsEnabled(enabled: boolean): this;
26406
+ findErrorByCode(code: string): AlienError | undefined;
26383
26407
  /**
26384
- * Builds and validates the container configuration.
26385
- * @returns An immutable Resource representing the configured container.
26386
- * @throws Error if the container configuration is invalid.
26408
+ * Get a formatted string representation of the error chain.
26409
+ *
26410
+ * This method provides a human-readable representation of the entire
26411
+ * error chain, showing how errors are nested and providing context
26412
+ * for debugging and logging.
26413
+ *
26414
+ * @returns Formatted string showing the complete error chain
26415
+ *
26416
+ * @example
26417
+ * ```typescript
26418
+ * const chainedError = authError.withContext(dbError.withContext(networkError))
26419
+ * console.log(chainedError.toString())
26420
+ * // Output:
26421
+ * // AUTH_FAILED: User authentication failed for 'john'
26422
+ * // ├─▶ DATABASE_CONNECTION_FAILED: Failed to connect to database 'localhost:5432'
26423
+ * // ├─▶ GENERIC_ERROR: Connection timeout
26424
+ * ```
26387
26425
  */
26388
- build(): Resource;
26426
+ toString(): string;
26389
26427
  }
26428
+ type ExtractContext<T> = T extends AlienErrorDefinition<infer TContext> ? z.infer<TContext> : never;
26390
26429
  //#endregion
26391
- //#region src/compute-cluster.d.ts
26430
+ //#region src/common-errors.d.ts
26392
26431
  /**
26393
- * Hardware requirements for a compute pool.
26432
+ * Error thrown when a requested resource cannot be found in the stack state.
26433
+ * This matches the Rust alien-core error: RESOURCE_NOT_FOUND
26394
26434
  */
26395
- type ComputePoolRequirements = {
26396
- cpu: number | string;
26397
- memory: string;
26398
- ephemeralStorage?: string;
26399
- architecture?: "arm64" | "x86_64";
26400
- nestedVirtualization?: boolean;
26401
- accelerators?: Array<{
26402
- type: string;
26403
- count: number;
26404
- }>;
26405
- };
26406
- type ComputeChoiceRange = number | {
26407
- min: number;
26408
- max: number;
26409
- default: number;
26410
- };
26411
- type ComputePoolScale = {
26412
- type: "fixed";
26413
- machines: ComputeChoiceRange;
26414
- } | {
26415
- type: "autoscale";
26416
- min: ComputeChoiceRange;
26417
- max: ComputeChoiceRange;
26418
- };
26419
- type ComputePoolInput = {
26420
- requirements: ComputePoolRequirements;
26421
- scale: ComputePoolScale;
26435
+ declare const ResourceNotFoundError: {
26436
+ metadata: AlienErrorMetadata<z$1.ZodObject<{
26437
+ resourceId: z$1.ZodString;
26438
+ availableResources: z$1.ZodArray<z$1.ZodString>;
26439
+ }, z$1.core.$strip>>;
26440
+ contextSchema: z$1.ZodObject<{
26441
+ resourceId: z$1.ZodString;
26442
+ availableResources: z$1.ZodArray<z$1.ZodString>;
26443
+ }, z$1.core.$strip>;
26444
+ create: (context: {
26445
+ resourceId: string;
26446
+ availableResources: string[];
26447
+ }) => AlienErrorDefinition<z$1.ZodObject<{
26448
+ resourceId: z$1.ZodString;
26449
+ availableResources: z$1.ZodArray<z$1.ZodString>;
26450
+ }, z$1.core.$strip>>;
26422
26451
  };
26423
26452
  /**
26424
- * Declares a ComputeCluster — the setup-owned machine boundary for daemons and
26425
- * containers. Each capacity group inside the cluster becomes a separate
26426
- * Auto Scaling Group (AWS), Managed Instance Group (GCP), or VM Scale Set
26427
- * (Azure). Daemons reference a cluster via `daemon.cluster(...)` and (when
26428
- * the cluster has more than one capacity group) a specific group via
26429
- * `daemon.pool(...)`.
26430
- *
26453
+ * Error thrown when resource outputs cannot be parsed according to their expected schema.
26454
+ * This indicates an internal system error or data corruption.
26455
+ */
26456
+ declare const ResourceOutputsParseError: {
26457
+ metadata: AlienErrorMetadata<z$1.ZodObject<{
26458
+ resourceName: z$1.ZodString;
26459
+ resourceType: z$1.ZodString;
26460
+ validationErrors: z$1.ZodString;
26461
+ }, z$1.core.$strip>>;
26462
+ contextSchema: z$1.ZodObject<{
26463
+ resourceName: z$1.ZodString;
26464
+ resourceType: z$1.ZodString;
26465
+ validationErrors: z$1.ZodString;
26466
+ }, z$1.core.$strip>;
26467
+ create: (context: {
26468
+ resourceName: string;
26469
+ resourceType: string;
26470
+ validationErrors: string;
26471
+ }) => AlienErrorDefinition<z$1.ZodObject<{
26472
+ resourceName: z$1.ZodString;
26473
+ resourceType: z$1.ZodString;
26474
+ validationErrors: z$1.ZodString;
26475
+ }, z$1.core.$strip>>;
26476
+ };
26477
+ /**
26478
+ * Error thrown when there's a resource type mismatch during stack operations.
26479
+ * This matches the Rust alien-core error: UNEXPECTED_RESOURCE_TYPE
26480
+ */
26481
+ declare const UnexpectedResourceTypeError: {
26482
+ metadata: AlienErrorMetadata<z$1.ZodObject<{
26483
+ resourceId: z$1.ZodString;
26484
+ expected: z$1.ZodString;
26485
+ actual: z$1.ZodString;
26486
+ }, z$1.core.$strip>>;
26487
+ contextSchema: z$1.ZodObject<{
26488
+ resourceId: z$1.ZodString;
26489
+ expected: z$1.ZodString;
26490
+ actual: z$1.ZodString;
26491
+ }, z$1.core.$strip>;
26492
+ create: (context: {
26493
+ resourceId: string;
26494
+ expected: string;
26495
+ actual: string;
26496
+ }) => AlienErrorDefinition<z$1.ZodObject<{
26497
+ resourceId: z$1.ZodString;
26498
+ expected: z$1.ZodString;
26499
+ actual: z$1.ZodString;
26500
+ }, z$1.core.$strip>>;
26501
+ };
26502
+ /**
26503
+ * Error thrown when a binding's projected configuration is invalid.
26504
+ */
26505
+ declare const InvalidBindingConfigError: {
26506
+ metadata: AlienErrorMetadata<z$1.ZodObject<{
26507
+ message: z$1.ZodString;
26508
+ suggestion: z$1.ZodOptional<z$1.ZodString>;
26509
+ }, z$1.core.$strip>>;
26510
+ contextSchema: z$1.ZodObject<{
26511
+ message: z$1.ZodString;
26512
+ suggestion: z$1.ZodOptional<z$1.ZodString>;
26513
+ }, z$1.core.$strip>;
26514
+ create: (context: {
26515
+ message: string;
26516
+ suggestion?: string | undefined;
26517
+ }) => AlienErrorDefinition<z$1.ZodObject<{
26518
+ message: z$1.ZodString;
26519
+ suggestion: z$1.ZodOptional<z$1.ZodString>;
26520
+ }, z$1.core.$strip>>;
26521
+ };
26522
+ /**
26523
+ * Error thrown when a binding is not found.
26524
+ */
26525
+ declare const BindingNotFoundError: {
26526
+ metadata: AlienErrorMetadata<z$1.ZodObject<{
26527
+ bindingName: z$1.ZodString;
26528
+ bindingType: z$1.ZodString;
26529
+ }, z$1.core.$strip>>;
26530
+ contextSchema: z$1.ZodObject<{
26531
+ bindingName: z$1.ZodString;
26532
+ bindingType: z$1.ZodString;
26533
+ }, z$1.core.$strip>;
26534
+ create: (context: {
26535
+ bindingName: string;
26536
+ bindingType: string;
26537
+ }) => AlienErrorDefinition<z$1.ZodObject<{
26538
+ bindingName: z$1.ZodString;
26539
+ bindingType: z$1.ZodString;
26540
+ }, z$1.core.$strip>>;
26541
+ };
26542
+ //#endregion
26543
+ //#region src/compute-cluster.d.ts
26544
+ /**
26545
+ * Hardware requirements for a compute pool.
26546
+ */
26547
+ type ComputePoolRequirements = {
26548
+ cpu: number | string;
26549
+ memory: string;
26550
+ ephemeralStorage?: string;
26551
+ architecture?: "arm64" | "x86_64";
26552
+ nestedVirtualization?: boolean;
26553
+ accelerators?: Array<{
26554
+ type: string;
26555
+ count: number;
26556
+ }>;
26557
+ };
26558
+ type ComputeChoiceRange = number | {
26559
+ min: number;
26560
+ max: number;
26561
+ default: number;
26562
+ };
26563
+ type ComputePoolScale = {
26564
+ type: "fixed";
26565
+ machines: ComputeChoiceRange;
26566
+ } | {
26567
+ type: "autoscale";
26568
+ min: ComputeChoiceRange;
26569
+ max: ComputeChoiceRange;
26570
+ };
26571
+ type ComputePoolInput = {
26572
+ requirements: ComputePoolRequirements;
26573
+ scale: ComputePoolScale;
26574
+ };
26575
+ /**
26576
+ * Declares a ComputeCluster — the setup-owned machine boundary for daemons and
26577
+ * containers. Each capacity group inside the cluster becomes a separate
26578
+ * Auto Scaling Group (AWS), Managed Instance Group (GCP), or VM Scale Set
26579
+ * (Azure). Daemons reference a cluster via `daemon.cluster(...)` and (when
26580
+ * the cluster has more than one capacity group) a specific group via
26581
+ * `daemon.pool(...)`.
26582
+ *
26431
26583
  * Application source declares portable pool requirements. Provider machine
26432
26584
  * names are selected later through deployment settings.
26433
26585
  */
@@ -26452,620 +26604,472 @@ declare class ComputeCluster {
26452
26604
  build(): Resource;
26453
26605
  }
26454
26606
  //#endregion
26455
- //#region src/daemon.d.ts
26456
- type DaemonPublicEndpointOptions = ExposeProtocol | {
26457
- protocol: ExposeProtocol;
26607
+ //#region src/container.d.ts
26608
+ type PublicEndpointOptions = "http" | "tcp" | {
26609
+ protocol: "http" | "tcp";
26458
26610
  hostLabel?: string;
26459
26611
  wildcardSubdomains?: boolean;
26460
26612
  };
26613
+ interface PersistentStorageOptions {
26614
+ /**
26615
+ * Mount path inside the container.
26616
+ *
26617
+ * Defaults to `/data`.
26618
+ */
26619
+ mountPath?: string;
26620
+ }
26461
26621
  /**
26462
- * Represents a resident process that runs once per eligible machine or node.
26622
+ * Represents a long-running container workload.
26463
26623
  *
26464
- * Daemons are intended for long-lived background processes such as endpoint
26465
- * agents and local side services.
26624
+ * Containers run on compute instances (EC2, GCE, Azure VMs) and are orchestrated
26625
+ * by the managed container backend. They're designed for always-on workloads
26626
+ * like web services, APIs, databases, and background workers.
26466
26627
  */
26467
- declare class Daemon extends ResourceBuilder {
26628
+ declare class Container extends ResourceBuilder {
26468
26629
  private _config;
26469
26630
  /**
26470
- * Creates a new Daemon builder.
26471
- * @param id Identifier for the daemon. Must contain only alphanumeric characters, hyphens, and underscores ([A-Za-z0-9-_]). Maximum 64 characters.
26631
+ * Creates a new Container builder.
26632
+ * @param id Identifier for the container. Must be DNS-compatible: lowercase alphanumeric with hyphens.
26472
26633
  */
26473
26634
  constructor(id: string);
26474
26635
  /**
26475
- * Returns a ResourceType representing any daemon resource.
26476
- * Used for creating permission targets that apply to all daemon resources.
26477
- * @returns The "daemon" resource type.
26636
+ * Returns a ResourceType representing any container resource.
26637
+ * Used for creating permission targets that apply to all container resources.
26638
+ * @returns The "container" resource type.
26478
26639
  */
26479
26640
  static any(): ResourceType;
26480
26641
  /**
26481
- * Sets the code for the daemon, either a pre-built image or source code to be built.
26482
- * @param code The daemon code configuration.
26483
- * @returns The Daemon builder instance.
26642
+ * Sets the container cluster this container runs on.
26643
+ * @param clusterId The ComputeCluster resource ID.
26644
+ * @returns The Container builder instance.
26484
26645
  */
26485
- code(code: DaemonCode): this;
26646
+ cluster(clusterId: string): this;
26486
26647
  /**
26487
- * Sets the ComputeCluster this daemon runs on for AWS/GCP/Azure deployments.
26488
- * Kubernetes and Local deployments ignore this field.
26648
+ * Sets the code for the container, either a pre-built image or source code to be built.
26649
+ * @param code The container code configuration.
26650
+ * @returns The Container builder instance.
26489
26651
  */
26490
- cluster(clusterId: string): this;
26652
+ code(code: ContainerCode): this;
26491
26653
  /**
26492
- * Sets CPU resources for each daemon instance.
26654
+ * Sets the CPU resources for the container.
26655
+ *
26656
+ * For simplified configuration, use a single number:
26657
+ * - `.cpu(1)` sets both min and desired to 1 vCPU
26658
+ *
26659
+ * For advanced configuration, use ResourceSpec:
26660
+ * - `.cpu({ min: "0.5", desired: "1" })`
26661
+ *
26662
+ * @param value CPU in vCPUs (number) or ResourceSpec with min/desired.
26663
+ * @returns The Container builder instance.
26493
26664
  */
26494
26665
  cpu(value: number | ResourceSpec): this;
26495
26666
  /**
26496
- * Sets memory resources for each daemon instance.
26667
+ * Sets the memory resources for the container.
26668
+ *
26669
+ * Format: "<number>Mi" or "<number>Gi"
26670
+ *
26671
+ * Example: "512Mi", "2Gi", "16Gi"
26672
+ *
26673
+ * @param size Memory size string.
26674
+ * @returns The Container builder instance.
26497
26675
  */
26498
26676
  memory(size: string): this;
26499
26677
  /**
26500
- * Sets the backend pool/capacity group for daemon placement.
26678
+ * Sets minimum and maximum replica counts with autoscaling configuration.
26679
+ *
26680
+ * @param min Minimum replicas (always running).
26681
+ * @param max Maximum replicas under load.
26682
+ * @returns The Container builder instance.
26501
26683
  */
26502
- pool(pool: string): this;
26684
+ minReplicas(min: number): this;
26503
26685
  /**
26504
- * Overrides the image default command.
26686
+ * Sets the maximum replica count for autoscaling.
26687
+ * @param max Maximum replicas.
26688
+ * @returns The Container builder instance.
26505
26689
  */
26506
- command(command: string[]): this;
26690
+ maxReplicas(max: number): this;
26507
26691
  /**
26508
- * Sets the grace period used when stopping daemon instances during updates, drains, and deletes.
26509
- *
26510
- * The value is expressed in seconds. Valid values are 1 through 86400.
26692
+ * Sets a fixed replica count (for stateful containers or stateless without autoscaling).
26693
+ * Cannot be used with minReplicas/maxReplicas.
26694
+ * @param count Fixed number of replicas.
26695
+ * @returns The Container builder instance.
26511
26696
  */
26512
- stopGracePeriod(seconds: number): this;
26697
+ replicas(count: number): this;
26513
26698
  /**
26514
- * Sets backend runtime options for trusted daemon infrastructure.
26515
- *
26516
- * Use this only for daemons that intentionally need host-level access, such
26517
- * as a privileged loader that installs or supervises a native host process.
26699
+ * Configures autoscaling behavior.
26700
+ * @param config Autoscaling configuration.
26701
+ * @returns The Container builder instance.
26518
26702
  */
26519
- runtime(runtime: DaemonRuntime): this;
26703
+ autoScale(config: ContainerAutoscaling): this;
26520
26704
  /**
26521
- * Exposes a named public endpoint for a daemon port.
26705
+ * Sets whether this container is stateful.
26706
+ * Stateful containers get stable ordinals and support persistent storage.
26707
+ * @param enabled Whether the container is stateful.
26708
+ * @returns The Container builder instance.
26522
26709
  */
26523
- publicEndpoint(name: string, port: number, options?: DaemonPublicEndpointOptions): this;
26710
+ stateful(enabled: boolean): this;
26524
26711
  /**
26525
- * Configures the HTTP health check used by public daemon endpoint load balancers.
26712
+ * Adds an internal-only port to the container.
26713
+ * Automatically creates DNS records for service discovery.
26714
+ * @param port Port number (e.g., 3000, 8080, 5432).
26715
+ * @returns The Container builder instance.
26526
26716
  */
26527
- healthCheck(config: HealthCheck): this;
26717
+ port(port: number): this;
26528
26718
  /**
26529
- * Configures readiness probe (alias for healthCheck).
26719
+ * Adds multiple internal-only ports to the container.
26720
+ * @param ports Array of port numbers.
26721
+ * @returns The Container builder instance.
26530
26722
  */
26531
- readinessProbe(config: {
26532
- method: string;
26533
- path: string;
26534
- }): this;
26723
+ ports(ports: number[]): this;
26535
26724
  /**
26536
- * Sets key-value pairs as environment variables for the daemon.
26537
- * @param env A map of environment variable names to their values.
26538
- * @returns The Daemon builder instance.
26725
+ * Exposes a named public endpoint for a container port.
26726
+ *
26727
+ * Endpoint names are the stable contract for URLs, DNS, and runtime
26728
+ * environment injection.
26729
+ *
26730
+ * @param name Endpoint name, unique within this container.
26731
+ * @param port Port number to expose.
26732
+ * @param options "http"/"tcp" or endpoint options.
26733
+ * @returns The Container builder instance.
26539
26734
  */
26540
- environment(env: Record<string, string>): this;
26735
+ publicEndpoint(name: string, port: number, options?: PublicEndpointOptions): this;
26541
26736
  /**
26542
- * Links another resource to this daemon.
26543
- * This makes the linked resource accessible to the daemon, often by injecting
26544
- * environment variables or granting permissions.
26545
- * @param resource The resource to link.
26546
- * @returns The Daemon builder instance.
26737
+ * Sets environment variables for the container.
26738
+ * @param vars Key-value pairs of environment variables.
26739
+ * @returns The Container builder instance.
26547
26740
  */
26548
- link(resource: Resource): this;
26741
+ environment(vars: Record<string, string>): this;
26549
26742
  /**
26550
- * Assigns a permission profile to this daemon.
26551
- * The profile defines the permissions granted to this daemon when interacting
26552
- * with other cloud resources.
26553
- * @param permissions The permission profile name.
26554
- * @returns The Daemon builder instance.
26743
+ * Sets ephemeral storage size.
26744
+ * Data is lost on container restart.
26745
+ * @param size Storage size (e.g., "10Gi", "100Gi", "500Gi").
26746
+ * @returns The Container builder instance.
26555
26747
  */
26556
- permissions(permissions: string): this;
26748
+ ephemeralStorage(size: string): this;
26557
26749
  /**
26558
- * Enables or disables the Commands protocol for the daemon.
26559
- * When enabled, an app-owned receiver can lease this Daemon's pending commands and execute registered handlers.
26750
+ * Configures persistent storage and marks the container stateful.
26751
+ * Data survives container restarts.
26752
+ * @param size Storage size (e.g., "100Gi", "500Gi", "1Ti").
26753
+ * @param options Optional mount path.
26754
+ * @returns The Container builder instance.
26755
+ */
26756
+ persistentStorage(size: string, options?: PersistentStorageOptions): this;
26757
+ /**
26758
+ * Requests GPU resources.
26759
+ * @param config GPU configuration with type and count.
26760
+ * @returns The Container builder instance.
26761
+ */
26762
+ gpu(config: ContainerGpuSpec): this;
26763
+ /**
26764
+ * Configures health check for the container.
26765
+ * @param config Health check configuration.
26766
+ * @returns The Container builder instance.
26767
+ */
26768
+ healthCheck(config: HealthCheck): this;
26769
+ /**
26770
+ * Configures readiness probe (alias for healthCheck).
26771
+ * @param config Readiness probe configuration with method and path.
26772
+ * @returns The Container builder instance.
26773
+ */
26774
+ readinessProbe(config: {
26775
+ method: string;
26776
+ path: string;
26777
+ }): this;
26778
+ /**
26779
+ * Sets the permission profile for this container.
26780
+ * @param profile Permission profile name from stack permissions configuration.
26781
+ * @returns The Container builder instance.
26782
+ */
26783
+ permissions(profile: string): this;
26784
+ /**
26785
+ * Assigns the container to a specific compute pool.
26786
+ * @param poolName Compute pool name.
26787
+ * @returns The Container builder instance.
26788
+ */
26789
+ pool(poolName: string): this;
26790
+ /**
26791
+ * Sets the command to override the image default.
26792
+ * @param command Array of command arguments.
26793
+ * @returns The Container builder instance.
26794
+ */
26795
+ command(command: string[]): this;
26796
+ /**
26797
+ * Sets the grace period used when stopping replicas during updates, drains, and deletes.
26798
+ *
26799
+ * The value is expressed in seconds. Valid values are 1 through 86400.
26800
+ */
26801
+ stopGracePeriod(seconds: number): this;
26802
+ /**
26803
+ * Links this container to another resource (Storage, Queue, KV, etc.).
26804
+ * @param resource The resource to link to.
26805
+ * @returns The Container builder instance.
26806
+ */
26807
+ link(resource: Resource): this;
26808
+ /**
26809
+ * Enables or disables the Commands protocol for the container.
26810
+ * When enabled, an app-owned receiver can lease this Container's pending commands and execute registered handlers.
26560
26811
  * Default: false.
26561
- * @param enabled Whether to enable commands for this daemon.
26562
- * @returns The Daemon builder instance.
26812
+ * @param enabled Whether to enable commands for this container.
26813
+ * @returns The Container builder instance.
26563
26814
  */
26564
26815
  commandsEnabled(enabled: boolean): this;
26565
26816
  /**
26566
- * Builds and validates the daemon configuration.
26567
- * @returns An immutable Resource representing the configured daemon.
26568
- * @throws Error if the daemon configuration is invalid.
26817
+ * Builds and validates the container configuration.
26818
+ * @returns An immutable Resource representing the configured container.
26819
+ * @throws Error if the container configuration is invalid.
26569
26820
  */
26570
26821
  build(): Resource;
26571
26822
  }
26572
26823
  //#endregion
26573
- //#region src/build.d.ts
26824
+ //#region src/daemon.d.ts
26825
+ type DaemonPublicEndpointOptions = ExposeProtocol | {
26826
+ protocol: ExposeProtocol;
26827
+ hostLabel?: string;
26828
+ wildcardSubdomains?: boolean;
26829
+ };
26574
26830
  /**
26575
- * Represents a build resource that executes bash scripts to build code.
26576
- * Builds are designed to be stateless and can be triggered on-demand to compile,
26577
- * test, or package application code.
26831
+ * Represents a resident process that runs once per eligible machine or node.
26832
+ *
26833
+ * Daemons are intended for long-lived background processes such as endpoint
26834
+ * agents and local side services.
26578
26835
  */
26579
- declare class Build {
26836
+ declare class Daemon extends ResourceBuilder {
26580
26837
  private _config;
26581
26838
  /**
26582
- * Creates a new Build builder.
26583
- * @param id Identifier for the build resource. Must contain only alphanumeric characters, hyphens, and underscores ([A-Za-z0-9-_]). Maximum 64 characters.
26839
+ * Creates a new Daemon builder.
26840
+ * @param id Identifier for the daemon. Must contain only alphanumeric characters, hyphens, and underscores ([A-Za-z0-9-_]). Maximum 64 characters.
26584
26841
  */
26585
26842
  constructor(id: string);
26586
26843
  /**
26587
- * Returns a ResourceType representing any build resource.
26588
- * Used for creating permission targets that apply to all build resources.
26589
- * @returns The "build" resource type.
26844
+ * Returns a ResourceType representing any daemon resource.
26845
+ * Used for creating permission targets that apply to all daemon resources.
26846
+ * @returns The "daemon" resource type.
26590
26847
  */
26591
26848
  static any(): ResourceType;
26592
26849
  /**
26593
- * Sets the compute type for the build.
26594
- * @param type The compute type (small, medium, large, x-large).
26595
- * @returns The Build builder instance.
26850
+ * Sets the code for the daemon, either a pre-built image or source code to be built.
26851
+ * @param code The daemon code configuration.
26852
+ * @returns The Daemon builder instance.
26596
26853
  */
26597
- computeType(type: ComputeType): this;
26854
+ code(code: DaemonCode): this;
26598
26855
  /**
26599
- * Sets key-value pairs as environment variables for the build.
26856
+ * Sets the ComputeCluster this daemon runs on for AWS/GCP/Azure deployments.
26857
+ * Kubernetes and Local deployments ignore this field.
26858
+ */
26859
+ cluster(clusterId: string): this;
26860
+ /**
26861
+ * Sets CPU resources for each daemon instance.
26862
+ */
26863
+ cpu(value: number | ResourceSpec): this;
26864
+ /**
26865
+ * Sets memory resources for each daemon instance.
26866
+ */
26867
+ memory(size: string): this;
26868
+ /**
26869
+ * Sets the backend pool/capacity group for daemon placement.
26870
+ */
26871
+ pool(pool: string): this;
26872
+ /**
26873
+ * Overrides the image default command.
26874
+ */
26875
+ command(command: string[]): this;
26876
+ /**
26877
+ * Sets the grace period used when stopping daemon instances during updates, drains, and deletes.
26878
+ *
26879
+ * The value is expressed in seconds. Valid values are 1 through 86400.
26880
+ */
26881
+ stopGracePeriod(seconds: number): this;
26882
+ /**
26883
+ * Sets backend runtime options for trusted daemon infrastructure.
26884
+ *
26885
+ * Use this only for daemons that intentionally need host-level access, such
26886
+ * as a privileged loader that installs or supervises a native host process.
26887
+ */
26888
+ runtime(runtime: DaemonRuntime): this;
26889
+ /**
26890
+ * Exposes a named public endpoint for a daemon port.
26891
+ */
26892
+ publicEndpoint(name: string, port: number, options?: DaemonPublicEndpointOptions): this;
26893
+ /**
26894
+ * Configures the HTTP health check used by public daemon endpoint load balancers.
26895
+ */
26896
+ healthCheck(config: HealthCheck): this;
26897
+ /**
26898
+ * Configures readiness probe (alias for healthCheck).
26899
+ */
26900
+ readinessProbe(config: {
26901
+ method: string;
26902
+ path: string;
26903
+ }): this;
26904
+ /**
26905
+ * Sets key-value pairs as environment variables for the daemon.
26600
26906
  * @param env A map of environment variable names to their values.
26601
- * @returns The Build builder instance.
26907
+ * @returns The Daemon builder instance.
26602
26908
  */
26603
26909
  environment(env: Record<string, string>): this;
26604
26910
  /**
26605
- * Links another resource (e.g., Storage, ArtifactRegistry, Role) to this build.
26606
- * This makes the linked resource accessible to the build, often by injecting
26911
+ * Links another resource to this daemon.
26912
+ * This makes the linked resource accessible to the daemon, often by injecting
26607
26913
  * environment variables or granting permissions.
26608
26914
  * @param resource The resource to link.
26609
- * @returns The Build builder instance.
26915
+ * @returns The Daemon builder instance.
26610
26916
  */
26611
26917
  link(resource: Resource): this;
26612
26918
  /**
26613
- * Assigns a permission profile to this build.
26614
- * The profile defines the permissions granted to this build when interacting
26919
+ * Assigns a permission profile to this daemon.
26920
+ * The profile defines the permissions granted to this daemon when interacting
26615
26921
  * with other cloud resources.
26616
26922
  * @param permissions The permission profile name.
26617
- * @returns The Build builder instance.
26923
+ * @returns The Daemon builder instance.
26618
26924
  */
26619
26925
  permissions(permissions: string): this;
26620
26926
  /**
26621
- * Builds and validates the build configuration.
26622
- * @returns An immutable Resource representing the configured build.
26623
- * @throws Error if the build configuration is invalid.
26927
+ * Enables or disables the Commands protocol for the daemon.
26928
+ * When enabled, an app-owned receiver can lease this Daemon's pending commands and execute registered handlers.
26929
+ * Default: false.
26930
+ * @param enabled Whether to enable commands for this daemon.
26931
+ * @returns The Daemon builder instance.
26932
+ */
26933
+ commandsEnabled(enabled: boolean): this;
26934
+ /**
26935
+ * Builds and validates the daemon configuration.
26936
+ * @returns An immutable Resource representing the configured daemon.
26937
+ * @throws Error if the daemon configuration is invalid.
26624
26938
  */
26625
26939
  build(): Resource;
26626
26940
  }
26627
26941
  //#endregion
26628
- //#region src/artifact-registry.d.ts
26942
+ //#region src/email.d.ts
26629
26943
  /**
26630
- * Represents an artifact registry for storing container images and other build artifacts.
26631
- * This is a high-level wrapper resource that provides a cloud-agnostic interface over
26632
- * AWS ECR, GCP Artifact Registry, and Azure Container Registry.
26944
+ * Email infrastructure for sending and receiving mail on customer-owned
26945
+ * domains (AWS SES). Provisions a shared configuration set, optional inbound
26946
+ * and event wiring, and one email identity (Easy DKIM) per seed domain.
26947
+ *
26948
+ * The resource owns the email infrastructure, not the domain lifecycle. Seed
26949
+ * domains are optional: products that create and verify domains dynamically
26950
+ * should manage identities at runtime through the `email/manage-identities`
26951
+ * grant instead of listing them here. Runtime-created identities are
26952
+ * application data — they are not tracked by the deployment and survive stack
26953
+ * deletion.
26954
+ *
26955
+ * After deployment, create the per-domain DKIM CNAME records from the
26956
+ * resource outputs — SES verifies each domain once the records exist in DNS.
26957
+ *
26958
+ * When inbound mail is configured, the receipt rule is a catch-all (no
26959
+ * recipient filter), so mail for runtime-verified identities lands in the
26960
+ * bucket without redeployment. Setup activates the provisioned receipt rule
26961
+ * set automatically. SES permits one active receipt rule set per account and
26962
+ * region, so an AWS stack may contain only one Email with inbound delivery,
26963
+ * and installing it makes its rule set the account's active rule set.
26633
26964
  */
26634
- declare class ArtifactRegistry {
26965
+ declare class Email extends ResourceBuilder {
26635
26966
  private _config;
26636
26967
  /**
26637
- * Creates a new ArtifactRegistry builder.
26638
- * @param id Identifier for the artifact registry. Must contain only alphanumeric characters, hyphens, and underscores ([A-Za-z0-9-_]). Maximum 64 characters.
26968
+ * Creates a new Email builder.
26969
+ * @param id Identifier for the email resource. Must contain only alphanumeric characters, hyphens, and underscores ([A-Za-z0-9-_]). Maximum 64 characters.
26639
26970
  */
26640
26971
  constructor(id: string);
26641
26972
  /**
26642
- * Returns a ResourceType representing any artifact registry resource.
26643
- * Used for creating permission targets that apply to all artifact registry resources.
26644
- * @returns The "artifact-registry" resource type.
26973
+ * Returns a ResourceType representing any email resource.
26974
+ * Used for creating permission targets that apply to all email resources.
26975
+ * @returns The "email" resource type.
26645
26976
  */
26646
26977
  static any(): ResourceType;
26647
26978
  /**
26648
- * AWS-only: Configure ECR private image replication to additional regions.
26649
- * Ensures images pushed in the registry's home region are automatically
26650
- * available in these destination regions (required when Lambda or other
26651
- * compute runs in a different region).
26652
- * @param regions - AWS region codes to replicate to (e.g., ["us-east-2", "eu-west-1"])
26979
+ * Sets the seed mail domains provisioned at deploy time (one SES identity
26980
+ * each). Optional — omit for products that manage domains at runtime.
26981
+ * @param domains The mail domains (e.g. `["mail.example.com"]`).
26982
+ * @returns The Email builder instance.
26653
26983
  */
26654
- replicationRegions(regions: string[]): this;
26984
+ domains(domains: string[]): this;
26655
26985
  /**
26656
- * Builds and validates the artifact registry configuration.
26657
- * @returns An immutable Resource representing the configured artifact registry.
26658
- * @throws Error if the artifact registry configuration is invalid.
26986
+ * Adds a single seed mail domain.
26987
+ * @param domain The mail domain (e.g. `"mail.example.com"`).
26988
+ * @returns The Email builder instance.
26659
26989
  */
26660
- build(): Resource;
26661
- }
26662
- //#endregion
26663
- //#region src/vault.d.ts
26664
- /**
26665
- * Represents a secure vault for storing secrets.
26666
- * This resource provides a platform-agnostic interface over cloud-native secret management services:
26667
- * - AWS: AWS Secrets Manager with prefixed secret names
26668
- * - GCP: Secret Manager with prefixed secret names
26669
- * - Azure: Key Vault resource
26670
- *
26671
- * The vault acts as a namespace for secrets and controls access permissions for workers and services.
26672
- */
26673
- declare class Vault extends ResourceBuilder {
26674
- private _config;
26990
+ domain(domain: string): this;
26675
26991
  /**
26676
- * Creates a new Vault builder.
26677
- * @param id Identifier for the vault. Must contain only alphanumeric characters, hyphens, and underscores ([A-Za-z0-9-_]). Maximum 64 characters.
26992
+ * Configures inbound mail: raw incoming mail for the configured domains is
26993
+ * written to the linked Storage bucket. Note the post-deploy activation
26994
+ * step described in the class documentation.
26995
+ * @param storage The Storage resource that receives raw incoming mail.
26996
+ * @returns The Email builder instance.
26678
26997
  */
26679
- constructor(id: string);
26998
+ inbound(storage: Resource): this;
26680
26999
  /**
26681
- * Returns a ResourceType representing any vault resource.
26682
- * Used for creating permission targets that apply to all vault resources.
26683
- * @returns The "vault" resource type.
27000
+ * Configures sending events: send / delivery / bounce / complaint /
27001
+ * delivery-delay / reject events are delivered to the linked Queue.
27002
+ * @param queue The Queue resource that receives sending events.
27003
+ * @returns The Email builder instance.
26684
27004
  */
26685
- static any(): ResourceType;
27005
+ events(queue: Resource): this;
26686
27006
  /**
26687
- * Builds and validates the vault configuration.
26688
- * @returns An immutable Resource representing the configured vault.
26689
- * @throws Error if the vault configuration is invalid.
27007
+ * Builds and validates the email configuration.
27008
+ * @returns An immutable Resource representing the configured email infrastructure.
27009
+ * @throws Error if the email configuration is invalid.
26690
27010
  */
26691
27011
  build(): Resource;
26692
27012
  }
26693
27013
  //#endregion
26694
- //#region src/kv.d.ts
27014
+ //#region src/stack.d.ts
26695
27015
  /**
26696
- * Represents a key-value store for data storage.
26697
- * This resource provides a platform-agnostic interface over cloud-native KV services:
26698
- * - AWS: DynamoDB with hash bucketing for load distribution
26699
- * - GCP: Firestore with document-based storage and collection management
26700
- * - Azure: Table Storage with client-side TTL filtering and partition fan-out
26701
- *
26702
- * The KV store supports basic operations: get, put, delete, exists, and scan_prefix.
26703
- * All operations support TTL for automatic expiration and conditional operations.
26704
- *
26705
- * Key Features:
26706
- * - Universal size limits: 512-byte keys, 24 KiB values
26707
- * - TTL support with logical expiry across all platforms
26708
- * - Atomic absent and version preconditions for puts and deletes
26709
- * - Prefix-based scanning with pagination
26710
- * - Platform-specific optimizations while maintaining consistent API
26711
- *
26712
- * Size Constraints:
26713
- * - Keys: ≤ 512 bytes with portable ASCII charset (a-z, A-Z, 0-9, -, _, :, .)
26714
- * - Values: ≤ 24,576 bytes (24 KiB)
26715
- *
26716
- * TTL Behavior:
26717
- * - Expired items appear absent on reads even if physically present
26718
- * - TTL precision varies by platform but logical behavior is consistent
26719
- *
26720
- * Scan Operations:
26721
- * - Returns arbitrary, unordered subsets in backend-natural order
26722
- * - No ordering guarantees across platforms
26723
- * - May return ≤ limit items (not guaranteed to fill)
26724
- * - Clients must de-duplicate keys across pages
26725
- * - No completeness guarantee under concurrent writes
27016
+ * Options for adding a resource to a stack.
26726
27017
  */
26727
- declare class Kv extends ResourceBuilder {
26728
- private _config;
26729
- /**
26730
- * Creates a new KV builder.
26731
- * @param id Identifier for the KV store. Must contain only alphanumeric characters, hyphens, and underscores ([A-Za-z0-9-_]). Maximum 64 characters.
26732
- */
26733
- constructor(id: string);
26734
- /**
26735
- * Returns a ResourceType representing any KV resource.
26736
- * Used for creating permission targets that apply to all KV resources.
26737
- * @returns The "kv" resource type.
26738
- */
26739
- static any(): ResourceType;
27018
+ interface AddResourceOptions {
26740
27019
  /**
26741
- * Builds and validates the KV configuration.
26742
- * @returns An immutable Resource representing the configured KV store.
26743
- * @throws Error if the KV configuration is invalid.
27020
+ * Enable remote bindings for this resource (BYOB use case).
27021
+ * When true, binding params are synced to StackState for external access.
27022
+ * Default: false (prevents sensitive data in synced state).
26744
27023
  */
26745
- build(): Resource;
27024
+ remoteAccess?: boolean;
26746
27025
  }
26747
- //#endregion
26748
- //#region src/postgres.d.ts
26749
27026
  /**
26750
- * Represents a managed PostgreSQL database. The target platform decides the backend;
26751
- * the database is private and reachable only by same-stack workloads.
27027
+ * Represents a collection of cloud resources that are managed together.
27028
+ * Stacks are the top-level organizational unit in an Alien application.
26752
27029
  */
26753
- declare class Postgres extends ResourceBuilder {
27030
+ declare class Stack {
26754
27031
  private _config;
26755
27032
  /**
26756
- * Creates a new Postgres builder.
26757
- * @param id ID of the database. A database of this name is created on the server.
27033
+ * Creates a new Stack builder.
27034
+ * @param id Identifier for the stack. Must contain only alphanumeric characters, hyphens, and underscores ([A-Za-z0-9-_]). Maximum 128 characters.
26758
27035
  */
26759
27036
  constructor(id: string);
26760
27037
  /**
26761
- * Returns a ResourceType representing any postgres resource.
26762
- * Used for creating permission targets that apply to all postgres resources.
26763
- * @returns The "postgres" resource type.
26764
- */
26765
- static any(): ResourceType;
26766
- /**
26767
- * Sets the major engine version ("15" | "16" | "17"). Default `"17"`.
26768
- * The union narrows the generated schema's free-form string for authoring ergonomics;
26769
- * keep it in sync with the supported majors if the Rust `Postgres` resource adds one.
26770
- * @param value The major version.
26771
- * @returns The Postgres builder instance.
26772
- */
26773
- version(value: "15" | "16" | "17"): this;
26774
- /**
26775
- * Requests vCPUs (e.g. "0.5", "2"). On GCP and Azure, `cpu` and `memory` together pick the
26776
- * smallest tier that satisfies both. On AWS (Aurora Serverless v2) sizing comes from `memory`, so
26777
- * `cpu` is ignored.
26778
- * @param value The requested vCPUs.
26779
- * @returns The Postgres builder instance.
26780
- */
26781
- cpu(value: string): this;
26782
- /**
26783
- * Requests memory (e.g. "1Gi", "8Gi"). Drives the size on AWS (the ACU ceiling) and, together
26784
- * with `cpu`, the tier on GCP and Azure.
26785
- * @param value The requested memory.
26786
- * @returns The Postgres builder instance.
26787
- */
26788
- memory(value: string): this;
26789
- /**
26790
- * Sets allocated storage (e.g. "100Gi"). Default `"20Gi"`. Grow-only.
26791
- * @param value The storage size.
26792
- * @returns The Postgres builder instance.
26793
- */
26794
- storage(value: string): this;
26795
- /**
26796
- * Enables multi-AZ / regional / zone-redundant high availability. Default `false`.
26797
- * @param value Whether to enable HA.
26798
- * @returns The Postgres builder instance.
26799
- */
26800
- highAvailability(value?: boolean): this;
26801
- /**
26802
- * Builds and validates the postgres configuration.
26803
- * @returns An immutable Resource representing the configured database.
26804
- * @throws Error if the configuration is invalid.
26805
- */
26806
- build(): Resource;
26807
- }
26808
- //#endregion
26809
- //#region src/ai.d.ts
26810
- /**
26811
- * Represents an AI Gateway resource that provides a unified interface to
26812
- * managed AI inference services across cloud providers.
26813
- */
26814
- declare class AI extends ResourceBuilder {
26815
- private _config;
26816
- /**
26817
- * Creates a new AI builder.
26818
- * @param id Identifier for the AI resource. Must contain only alphanumeric characters, hyphens, and underscores ([A-Za-z0-9-_]). Maximum 64 characters.
27038
+ * Adds a resource to the stack with a specified lifecycle.
27039
+ * @param resource The resource to add (e.g., Worker, Storage).
27040
+ * @param lifecycle The lifecycle state of the resource (e.g., Frozen, Live).
27041
+ * @param options Optional configuration for the resource entry.
27042
+ * @returns The Stack builder instance.
26819
27043
  */
26820
- constructor(id: string);
27044
+ add(resource: Resource, lifecycle: ResourceLifecycle, options?: AddResourceOptions): this;
26821
27045
  /**
26822
- * Returns a ResourceType representing any AI resource.
26823
- * Used for creating permission targets that apply to all AI resources.
26824
- * @returns The "ai" resource type.
27046
+ * Declare which platforms this stack supports.
27047
+ * When omitted, the stack supports all platforms.
26825
27048
  */
26826
- static any(): ResourceType;
27049
+ platforms(platforms: Platform[]): this;
26827
27050
  /**
26828
- * Builds and validates the AI configuration.
26829
- * @returns An immutable Resource representing the configured AI Gateway.
26830
- * @throws Error if the AI configuration is invalid.
27051
+ * Configure permissions for this stack.
27052
+ * @param config Permission configuration
27053
+ * @returns The Stack builder instance.
26831
27054
  */
26832
- build(): Resource;
26833
- }
26834
- //#endregion
26835
- //#region src/queue.d.ts
26836
- /**
26837
- * Represents a message queue resource with minimal, portable semantics.
26838
- * Queue integrates with platform-native services (AWS SQS, GCP Pub/Sub, Azure Service Bus).
26839
- */
26840
- declare class Queue extends ResourceBuilder {
26841
- private _config;
27055
+ permissions(config: PermissionsConfig): this;
26842
27056
  /**
26843
- * Creates a new Queue builder.
26844
- * @param id Identifier for the queue. Must contain only alphanumeric characters, hyphens, and underscores ([A-Za-z0-9-_]). Maximum 64 characters.
27057
+ * Configure values that must be provided before setup or deployment can proceed.
27058
+ * @param inputs Stack input definitions created with alien.inputs({...}).
27059
+ * @returns The Stack builder instance.
26845
27060
  */
26846
- constructor(id: string);
27061
+ inputs(inputs: StackInputCollection | readonly StackInputDefinition[]): this;
26847
27062
  /**
26848
- * Returns a ResourceType representing any queue resource.
26849
- * Used for creating permission targets that apply to all queue resources.
26850
- * @returns The "queue" resource type.
27063
+ * Gets the stack ID without building/validating the stack.
27064
+ * @returns The stack ID.
26851
27065
  */
26852
- static any(): ResourceType;
27066
+ get id(): string;
26853
27067
  /**
26854
- * Builds and validates the queue configuration.
26855
- * @returns An immutable Resource representing the configured queue.
26856
- * @throws Error if the queue configuration is invalid.
27068
+ * Builds and validates the stack configuration.
27069
+ * @returns The complete and validated stack configuration.
27070
+ * @throws Error if the stack configuration is invalid.
26857
27071
  */
26858
- build(): Resource;
26859
- }
26860
- //#endregion
26861
- //#region src/email.d.ts
26862
- /**
26863
- * Email infrastructure for sending and receiving mail on customer-owned
26864
- * domains (AWS SES). Provisions a shared configuration set, optional inbound
26865
- * and event wiring, and one email identity (Easy DKIM) per seed domain.
26866
- *
26867
- * The resource owns the email infrastructure, not the domain lifecycle. Seed
26868
- * domains are optional: products that create and verify domains dynamically
26869
- * should manage identities at runtime through the `email/manage-identities`
26870
- * grant instead of listing them here. Runtime-created identities are
26871
- * application data — they are not tracked by the deployment and survive stack
26872
- * deletion.
26873
- *
26874
- * After deployment, create the per-domain DKIM CNAME records from the
26875
- * resource outputs — SES verifies each domain once the records exist in DNS.
26876
- *
26877
- * When inbound mail is configured, the receipt rule is a catch-all (no
26878
- * recipient filter), so mail for runtime-verified identities lands in the
26879
- * bucket without redeployment. Setup activates the provisioned receipt rule
26880
- * set automatically. SES permits one active receipt rule set per account and
26881
- * region, so an AWS stack may contain only one Email with inbound delivery,
26882
- * and installing it makes its rule set the account's active rule set.
26883
- */
26884
- declare class Email extends ResourceBuilder {
26885
- private _config;
26886
- /**
26887
- * Creates a new Email builder.
26888
- * @param id Identifier for the email resource. Must contain only alphanumeric characters, hyphens, and underscores ([A-Za-z0-9-_]). Maximum 64 characters.
26889
- */
26890
- constructor(id: string);
26891
- /**
26892
- * Returns a ResourceType representing any email resource.
26893
- * Used for creating permission targets that apply to all email resources.
26894
- * @returns The "email" resource type.
26895
- */
26896
- static any(): ResourceType;
26897
- /**
26898
- * Sets the seed mail domains provisioned at deploy time (one SES identity
26899
- * each). Optional — omit for products that manage domains at runtime.
26900
- * @param domains The mail domains (e.g. `["mail.example.com"]`).
26901
- * @returns The Email builder instance.
26902
- */
26903
- domains(domains: string[]): this;
26904
- /**
26905
- * Adds a single seed mail domain.
26906
- * @param domain The mail domain (e.g. `"mail.example.com"`).
26907
- * @returns The Email builder instance.
26908
- */
26909
- domain(domain: string): this;
26910
- /**
26911
- * Configures inbound mail: raw incoming mail for the configured domains is
26912
- * written to the linked Storage bucket. Note the post-deploy activation
26913
- * step described in the class documentation.
26914
- * @param storage The Storage resource that receives raw incoming mail.
26915
- * @returns The Email builder instance.
26916
- */
26917
- inbound(storage: Resource): this;
26918
- /**
26919
- * Configures sending events: send / delivery / bounce / complaint /
26920
- * delivery-delay / reject events are delivered to the linked Queue.
26921
- * @param queue The Queue resource that receives sending events.
26922
- * @returns The Email builder instance.
26923
- */
26924
- events(queue: Resource): this;
26925
- /**
26926
- * Builds and validates the email configuration.
26927
- * @returns An immutable Resource representing the configured email infrastructure.
26928
- * @throws Error if the email configuration is invalid.
26929
- */
26930
- build(): Resource;
26931
- }
26932
- //#endregion
26933
- //#region src/service-account.d.ts
26934
- /**
26935
- * Represents a non-human identity that can be assumed by compute services.
26936
- *
26937
- * Maps to:
26938
- * - AWS: IAM Role
26939
- * - GCP: Service Account
26940
- * - Azure: User-assigned Managed Identity
26941
- *
26942
- * ServiceAccounts can be used to grant specific permissions to compute resources
26943
- * and can be impersonated by other services for cross-account or cross-service access.
26944
- *
26945
- * @example
26946
- * ```typescript
26947
- * import { ServiceAccount, Worker } from "@alien/core"
26948
- *
26949
- * // Create a service account with stack-level permissions
26950
- * const dataProcessorAccount = new ServiceAccount("data-processor")
26951
- * .build()
26952
- *
26953
- * // Link it to a function to use its identity
26954
- * const processor = new Worker("processor")
26955
- * .code({ type: "image", image: "processor:latest" })
26956
- * .link(dataProcessorAccount)
26957
- * .build()
26958
- * ```
26959
- */
26960
- declare class ServiceAccount {
26961
- private _config;
26962
- /**
26963
- * Creates a new ServiceAccount builder.
26964
- * @param id Identifier for the service account. Must contain only alphanumeric characters, hyphens, and underscores ([A-Za-z0-9-_]). Maximum 64 characters.
26965
- */
26966
- constructor(id: string);
26967
- /**
26968
- * Returns a ResourceType representing any service account resource.
26969
- * Used for creating permission targets that apply to all service account resources.
26970
- * @returns The "service-account" resource type.
26971
- */
26972
- static any(): ResourceType;
26973
- /**
26974
- * Adds a stack-level permission set to the service account.
26975
- * Stack-level permissions apply to all resources in the stack.
26976
- *
26977
- * Note: Only inline permission set objects are supported. To use built-in permission sets,
26978
- * you need to resolve them first through the permission set registry or use permission profiles
26979
- * in your stack configuration.
26980
- *
26981
- * @example
26982
- * ```typescript
26983
- * import { ServiceAccount, type PermissionSet } from "@alien/core"
26984
- *
26985
- * const customPermissionSet: PermissionSet = {
26986
- * id: "custom/my-perms",
26987
- * description: "Custom permissions",
26988
- * platforms: {
26989
- * aws: [{ grant: { actions: ["s3:GetObject"] }, binding: { stack: { resources: ["*"] } } }]
26990
- * }
26991
- * }
26992
- *
26993
- * const account = new ServiceAccount("custom-processor")
26994
- * .stackPermissionSet(customPermissionSet)
26995
- * .build()
26996
- * ```
26997
- *
26998
- * @param permissionSet The permission set object with platform-specific permissions
26999
- * @returns The ServiceAccount builder instance.
27000
- */
27001
- stackPermissionSet(permissionSet: PermissionSet): this;
27002
- /**
27003
- * Builds and validates the service account configuration.
27004
- * @returns An immutable Resource representing the configured service account.
27005
- * @throws Error if the service account configuration is invalid.
27006
- */
27007
- build(): Resource;
27008
- }
27009
- //#endregion
27010
- //#region src/stack.d.ts
27011
- /**
27012
- * Options for adding a resource to a stack.
27013
- */
27014
- interface AddResourceOptions {
27015
- /**
27016
- * Enable remote bindings for this resource (BYOB use case).
27017
- * When true, binding params are synced to StackState for external access.
27018
- * Default: false (prevents sensitive data in synced state).
27019
- */
27020
- remoteAccess?: boolean;
27021
- }
27022
- /**
27023
- * Represents a collection of cloud resources that are managed together.
27024
- * Stacks are the top-level organizational unit in an Alien application.
27025
- */
27026
- declare class Stack {
27027
- private _config;
27028
- /**
27029
- * Creates a new Stack builder.
27030
- * @param id Identifier for the stack. Must contain only alphanumeric characters, hyphens, and underscores ([A-Za-z0-9-_]). Maximum 128 characters.
27031
- */
27032
- constructor(id: string);
27033
- /**
27034
- * Adds a resource to the stack with a specified lifecycle.
27035
- * @param resource The resource to add (e.g., Worker, Storage).
27036
- * @param lifecycle The lifecycle state of the resource (e.g., Frozen, Live).
27037
- * @param options Optional configuration for the resource entry.
27038
- * @returns The Stack builder instance.
27039
- */
27040
- add(resource: Resource, lifecycle: ResourceLifecycle, options?: AddResourceOptions): this;
27041
- /**
27042
- * Declare which platforms this stack supports.
27043
- * When omitted, the stack supports all platforms.
27044
- */
27045
- platforms(platforms: Platform[]): this;
27046
- /**
27047
- * Configure permissions for this stack.
27048
- * @param config Permission configuration
27049
- * @returns The Stack builder instance.
27050
- */
27051
- permissions(config: PermissionsConfig): this;
27052
- /**
27053
- * Configure values that must be provided before setup or deployment can proceed.
27054
- * @param inputs Stack input definitions created with alien.inputs({...}).
27055
- * @returns The Stack builder instance.
27056
- */
27057
- inputs(inputs: StackInputCollection | readonly StackInputDefinition[]): this;
27058
- /**
27059
- * Gets the stack ID without building/validating the stack.
27060
- * @returns The stack ID.
27061
- */
27062
- get id(): string;
27063
- /**
27064
- * Builds and validates the stack configuration.
27065
- * @returns The complete and validated stack configuration.
27066
- * @throws Error if the stack configuration is invalid.
27067
- */
27068
- build(): Stack$1;
27072
+ build(): Stack$1;
27069
27073
  }
27070
27074
  //#endregion
27071
27075
  //#region src/get-resource-outputs.d.ts
@@ -27477,459 +27481,455 @@ declare function getResourceOutputs<K extends keyof typeof ResourceSchemaMapping
27477
27481
  };
27478
27482
  }): z$1.infer<(typeof ResourceSchemaMapping)[K]["output"]>;
27479
27483
  //#endregion
27480
- //#region src/error.d.ts
27484
+ //#region src/kv.d.ts
27481
27485
  /**
27482
- * Base interface that all error type definitions must implement.
27486
+ * Represents a key-value store for data storage.
27487
+ * This resource provides a platform-agnostic interface over cloud-native KV services:
27488
+ * - AWS: DynamoDB with hash bucketing for load distribution
27489
+ * - GCP: Firestore with document-based storage and collection management
27490
+ * - Azure: Table Storage with client-side TTL filtering and partition fan-out
27483
27491
  *
27484
- * This provides the structure for creating type-safe error definitions
27485
- * with Zod validation and contextual information.
27492
+ * The KV store supports basic operations: get, put, delete, exists, and scan_prefix.
27493
+ * All operations support TTL for automatic expiration and conditional operations.
27486
27494
  *
27487
- * @template TContext - Zod schema type for the error context
27495
+ * Key Features:
27496
+ * - Universal size limits: 512-byte keys, 24 KiB values
27497
+ * - TTL support with logical expiry across all platforms
27498
+ * - Atomic absent and version preconditions for puts and deletes
27499
+ * - Prefix-based scanning with pagination
27500
+ * - Platform-specific optimizations while maintaining consistent API
27501
+ *
27502
+ * Size Constraints:
27503
+ * - Keys: ≤ 512 bytes with portable ASCII charset (a-z, A-Z, 0-9, -, _, :, .)
27504
+ * - Values: ≤ 24,576 bytes (24 KiB)
27505
+ *
27506
+ * TTL Behavior:
27507
+ * - Expired items appear absent on reads even if physically present
27508
+ * - TTL precision varies by platform but logical behavior is consistent
27509
+ *
27510
+ * Scan Operations:
27511
+ * - Returns arbitrary, unordered subsets in backend-natural order
27512
+ * - No ordering guarantees across platforms
27513
+ * - May return ≤ limit items (not guaranteed to fill)
27514
+ * - Clients must de-duplicate keys across pages
27515
+ * - No completeness guarantee under concurrent writes
27488
27516
  */
27489
- interface AlienErrorMetadata<TContext extends z.ZodTypeAny> {
27490
- /** Unique error code (e.g., "DATABASE_CONNECTION_FAILED") */
27491
- code: string;
27492
- /** Zod schema for type-safe context validation */
27493
- context: TContext;
27494
- /** Whether this error can be retried */
27495
- retryable: boolean;
27496
- /** Whether this error contains sensitive information */
27497
- internal: boolean;
27498
- /** HTTP status code for API responses */
27499
- httpStatusCode?: number;
27500
- /** Worker to generate human-readable error message from context */
27501
- message: (context: z.infer<TContext>) => string;
27517
+ declare class Kv extends ResourceBuilder {
27518
+ private _config;
27519
+ /**
27520
+ * Creates a new KV builder.
27521
+ * @param id Identifier for the KV store. Must contain only alphanumeric characters, hyphens, and underscores ([A-Za-z0-9-_]). Maximum 64 characters.
27522
+ */
27523
+ constructor(id: string);
27524
+ /**
27525
+ * Returns a ResourceType representing any KV resource.
27526
+ * Used for creating permission targets that apply to all KV resources.
27527
+ * @returns The "kv" resource type.
27528
+ */
27529
+ static any(): ResourceType;
27530
+ /**
27531
+ * Builds and validates the KV configuration.
27532
+ * @returns An immutable Resource representing the configured KV store.
27533
+ * @throws Error if the KV configuration is invalid.
27534
+ */
27535
+ build(): Resource;
27502
27536
  }
27537
+ //#endregion
27538
+ //#region src/postgres.d.ts
27503
27539
  /**
27504
- * Helper function to create type-safe error definitions.
27540
+ * Represents a managed PostgreSQL database. The target platform decides the backend;
27541
+ * the database is private and reachable only by same-stack workloads.
27542
+ */
27543
+ declare class Postgres extends ResourceBuilder {
27544
+ private _config;
27545
+ /**
27546
+ * Creates a new Postgres builder.
27547
+ * @param id ID of the database. A database of this name is created on the server.
27548
+ */
27549
+ constructor(id: string);
27550
+ /**
27551
+ * Returns a ResourceType representing any postgres resource.
27552
+ * Used for creating permission targets that apply to all postgres resources.
27553
+ * @returns The "postgres" resource type.
27554
+ */
27555
+ static any(): ResourceType;
27556
+ /**
27557
+ * Sets the major engine version ("15" | "16" | "17"). Default `"17"`.
27558
+ * The union narrows the generated schema's free-form string for authoring ergonomics;
27559
+ * keep it in sync with the supported majors if the Rust `Postgres` resource adds one.
27560
+ * @param value The major version.
27561
+ * @returns The Postgres builder instance.
27562
+ */
27563
+ version(value: "15" | "16" | "17"): this;
27564
+ /**
27565
+ * Requests vCPUs (e.g. "0.5", "2"). On GCP and Azure, `cpu` and `memory` together pick the
27566
+ * smallest tier that satisfies both. On AWS (Aurora Serverless v2) sizing comes from `memory`, so
27567
+ * `cpu` is ignored.
27568
+ * @param value The requested vCPUs.
27569
+ * @returns The Postgres builder instance.
27570
+ */
27571
+ cpu(value: string): this;
27572
+ /**
27573
+ * Requests memory (e.g. "1Gi", "8Gi"). Drives the size on AWS (the ACU ceiling) and, together
27574
+ * with `cpu`, the tier on GCP and Azure.
27575
+ * @param value The requested memory.
27576
+ * @returns The Postgres builder instance.
27577
+ */
27578
+ memory(value: string): this;
27579
+ /**
27580
+ * Sets allocated storage (e.g. "100Gi"). Default `"20Gi"`. Grow-only.
27581
+ * @param value The storage size.
27582
+ * @returns The Postgres builder instance.
27583
+ */
27584
+ storage(value: string): this;
27585
+ /**
27586
+ * Enables multi-AZ / regional / zone-redundant high availability. Default `false`.
27587
+ * @param value Whether to enable HA.
27588
+ * @returns The Postgres builder instance.
27589
+ */
27590
+ highAvailability(value?: boolean): this;
27591
+ /**
27592
+ * Builds and validates the postgres configuration.
27593
+ * @returns An immutable Resource representing the configured database.
27594
+ * @throws Error if the configuration is invalid.
27595
+ */
27596
+ build(): Resource;
27597
+ }
27598
+ //#endregion
27599
+ //#region src/queue.d.ts
27600
+ /**
27601
+ * Represents a message queue resource with minimal, portable semantics.
27602
+ * Queue integrates with platform-native services (AWS SQS, GCP Pub/Sub, Azure Service Bus).
27603
+ */
27604
+ declare class Queue extends ResourceBuilder {
27605
+ private _config;
27606
+ /**
27607
+ * Creates a new Queue builder.
27608
+ * @param id Identifier for the queue. Must contain only alphanumeric characters, hyphens, and underscores ([A-Za-z0-9-_]). Maximum 64 characters.
27609
+ */
27610
+ constructor(id: string);
27611
+ /**
27612
+ * Returns a ResourceType representing any queue resource.
27613
+ * Used for creating permission targets that apply to all queue resources.
27614
+ * @returns The "queue" resource type.
27615
+ */
27616
+ static any(): ResourceType;
27617
+ /**
27618
+ * Builds and validates the queue configuration.
27619
+ * @returns An immutable Resource representing the configured queue.
27620
+ * @throws Error if the queue configuration is invalid.
27621
+ */
27622
+ build(): Resource;
27623
+ }
27624
+ //#endregion
27625
+ //#region src/service-account.d.ts
27626
+ /**
27627
+ * Represents a non-human identity that can be assumed by compute services.
27505
27628
  *
27506
- * This function provides a clean API for defining reusable error types
27507
- * with full TypeScript type safety and Zod validation.
27629
+ * Maps to:
27630
+ * - AWS: IAM Role
27631
+ * - GCP: Service Account
27632
+ * - Azure: User-assigned Managed Identity
27508
27633
  *
27509
- * @template TContext - Zod schema type for the error context
27510
- * @param metadata - Error metadata including code, schema, and message generator
27511
- * @returns Object with metadata and a create function for error instances
27634
+ * ServiceAccounts can be used to grant specific permissions to compute resources
27635
+ * and can be impersonated by other services for cross-account or cross-service access.
27512
27636
  *
27513
27637
  * @example
27514
27638
  * ```typescript
27515
- * const UserNotFound = defineError({
27516
- * code: "USER_NOT_FOUND",
27517
- * context: z.object({
27518
- * userId: z.string(),
27519
- * searchMethod: z.string(),
27520
- * }),
27521
- * message: ({ userId, searchMethod }) =>
27522
- * `User '${userId}' not found using method '${searchMethod}'`,
27523
- * retryable: false,
27524
- * internal: false,
27525
- * httpStatusCode: 404,
27526
- * })
27639
+ * import { ServiceAccount, Worker } from "@alien/core"
27527
27640
  *
27528
- * // Usage
27529
- * const error = UserNotFound.create({
27530
- * userId: "123",
27531
- * searchMethod: "database_lookup"
27532
- * })
27641
+ * // Create a service account with stack-level permissions
27642
+ * const dataProcessorAccount = new ServiceAccount("data-processor")
27643
+ * .build()
27644
+ *
27645
+ * // Link it to a function to use its identity
27646
+ * const processor = new Worker("processor")
27647
+ * .code({ type: "image", image: "processor:latest" })
27648
+ * .link(dataProcessorAccount)
27649
+ * .build()
27533
27650
  * ```
27534
27651
  */
27535
- declare function defineError<TContext extends z.ZodTypeAny>(metadata: AlienErrorMetadata<TContext>): {
27536
- metadata: AlienErrorMetadata<TContext>;
27537
- contextSchema: TContext;
27538
- create: (context: z.infer<TContext>) => AlienErrorDefinition<TContext>;
27539
- };
27652
+ declare class ServiceAccount {
27653
+ private _config;
27654
+ /**
27655
+ * Creates a new ServiceAccount builder.
27656
+ * @param id Identifier for the service account. Must contain only alphanumeric characters, hyphens, and underscores ([A-Za-z0-9-_]). Maximum 64 characters.
27657
+ */
27658
+ constructor(id: string);
27659
+ /**
27660
+ * Returns a ResourceType representing any service account resource.
27661
+ * Used for creating permission targets that apply to all service account resources.
27662
+ * @returns The "service-account" resource type.
27663
+ */
27664
+ static any(): ResourceType;
27665
+ /**
27666
+ * Adds a stack-level permission set to the service account.
27667
+ * Stack-level permissions apply to all resources in the stack.
27668
+ *
27669
+ * Note: Only inline permission set objects are supported. To use built-in permission sets,
27670
+ * you need to resolve them first through the permission set registry or use permission profiles
27671
+ * in your stack configuration.
27672
+ *
27673
+ * @example
27674
+ * ```typescript
27675
+ * import { ServiceAccount, type PermissionSet } from "@alien/core"
27676
+ *
27677
+ * const customPermissionSet: PermissionSet = {
27678
+ * id: "custom/my-perms",
27679
+ * description: "Custom permissions",
27680
+ * platforms: {
27681
+ * aws: [{ grant: { actions: ["s3:GetObject"] }, binding: { stack: { resources: ["*"] } } }]
27682
+ * }
27683
+ * }
27684
+ *
27685
+ * const account = new ServiceAccount("custom-processor")
27686
+ * .stackPermissionSet(customPermissionSet)
27687
+ * .build()
27688
+ * ```
27689
+ *
27690
+ * @param permissionSet The permission set object with platform-specific permissions
27691
+ * @returns The ServiceAccount builder instance.
27692
+ */
27693
+ stackPermissionSet(permissionSet: PermissionSet): this;
27694
+ /**
27695
+ * Builds and validates the service account configuration.
27696
+ * @returns An immutable Resource representing the configured service account.
27697
+ * @throws Error if the service account configuration is invalid.
27698
+ */
27699
+ build(): Resource;
27700
+ }
27701
+ //#endregion
27702
+ //#region src/storage.d.ts
27703
+ /**
27704
+ * Represents an object storage bucket.
27705
+ */
27706
+ declare class Storage extends ResourceBuilder {
27707
+ private _config;
27708
+ /**
27709
+ * Creates a new Storage builder.
27710
+ * @param id ID of the storage bucket. For names with dots, each dot-separated label must be ≤ 63 characters.
27711
+ */
27712
+ constructor(id: string);
27713
+ /**
27714
+ * Returns a ResourceType representing any storage resource.
27715
+ * Used for creating permission targets that apply to all storage resources.
27716
+ * @returns The "storage" resource type.
27717
+ */
27718
+ static any(): ResourceType;
27719
+ /**
27720
+ * Allows public read access to objects without authentication.
27721
+ * Default: `false`.
27722
+ * @param value Whether to allow public read access.
27723
+ * @returns The Storage builder instance.
27724
+ */
27725
+ publicRead(value: boolean): this;
27726
+ /**
27727
+ * Enables object versioning.
27728
+ * Default: `false`.
27729
+ * @param value Whether to enable versioning.
27730
+ * @returns The Storage builder instance.
27731
+ */
27732
+ versioning(value: boolean): this;
27733
+ /**
27734
+ * Defines lifecycle rules for automatic object management (e.g., expiration).
27735
+ * @param rules An array of lifecycle rules.
27736
+ * @returns The Storage builder instance.
27737
+ */
27738
+ lifecycleRules(rules: LifecycleRule[]): this;
27739
+ /**
27740
+ * Allows browser reads from the listed origins through signed URLs.
27741
+ * Providers enable `GET` and `HEAD`; use `*` only when the signed URL itself
27742
+ * is the credential and browser cookies are not involved.
27743
+ * @param origins Allowed browser origins.
27744
+ * @returns The Storage builder instance.
27745
+ */
27746
+ corsAllowedOrigins(origins: string[]): this;
27747
+ /**
27748
+ * Builds and validates the storage configuration.
27749
+ * @returns An immutable Resource representing the configured storage bucket.
27750
+ * @throws Error if the storage configuration is invalid.
27751
+ */
27752
+ build(): Resource;
27753
+ }
27754
+ //#endregion
27755
+ //#region src/vault.d.ts
27540
27756
  /**
27541
- * Represents a specific error instance with its context.
27542
- *
27543
- * This is created by calling `.create()` on an error definition
27544
- * and contains the actual context data for a specific error occurrence.
27757
+ * Represents a secure vault for storing secrets.
27758
+ * This resource provides a platform-agnostic interface over cloud-native secret management services:
27759
+ * - AWS: AWS Secrets Manager with prefixed secret names
27760
+ * - GCP: Secret Manager with prefixed secret names
27761
+ * - Azure: Key Vault resource
27545
27762
  *
27546
- * @template TContext - Zod schema type for the error context
27763
+ * The vault acts as a namespace for secrets and controls access permissions for workers and services.
27547
27764
  */
27548
- interface AlienErrorDefinition<TContext extends z.ZodTypeAny> {
27549
- metadata: AlienErrorMetadata<TContext>;
27550
- contextSchema: TContext;
27551
- context: z.infer<TContext>;
27765
+ declare class Vault extends ResourceBuilder {
27766
+ private _config;
27552
27767
  /**
27553
- * Convert this error definition directly to AlienErrorOptions.
27554
- *
27555
- * This allows you to get the wire format representation
27556
- * without creating an AlienError instance first.
27557
- *
27558
- * @returns AlienErrorOptions object representing this error
27768
+ * Creates a new Vault builder.
27769
+ * @param id Identifier for the vault. Must contain only alphanumeric characters, hyphens, and underscores ([A-Za-z0-9-_]). Maximum 64 characters.
27559
27770
  */
27560
- toOptions(): AlienError$1;
27771
+ constructor(id: string);
27772
+ /**
27773
+ * Returns a ResourceType representing any vault resource.
27774
+ * Used for creating permission targets that apply to all vault resources.
27775
+ * @returns The "vault" resource type.
27776
+ */
27777
+ static any(): ResourceType;
27778
+ /**
27779
+ * Builds and validates the vault configuration.
27780
+ * @returns An immutable Resource representing the configured vault.
27781
+ * @throws Error if the vault configuration is invalid.
27782
+ */
27783
+ build(): Resource;
27784
+ }
27785
+ //#endregion
27786
+ //#region src/worker.d.ts
27787
+ interface WorkerPublicEndpointOptions {
27788
+ hostLabel?: string;
27789
+ wildcardSubdomains?: boolean;
27561
27790
  }
27562
27791
  /**
27563
- * Main AlienError class that provides structured error handling.
27564
- *
27565
- * This class extends the standard JavaScript Error with additional features:
27566
- * - Type-safe context data
27567
- * - Error chaining and source tracking
27568
- * - Retryability and internal/external visibility flags
27569
- * - HTTP status code mapping
27570
- * - Sanitization for external APIs
27571
- *
27572
- * @template TContext - Zod schema type for the error context
27573
- *
27574
- * @example Basic Construction
27575
- * ```typescript
27576
- * const error = new AlienError(DatabaseError.create({
27577
- * host: "localhost",
27578
- * port: 5432,
27579
- * reason: "Timeout"
27580
- * }))
27581
- * ```
27582
- *
27583
- * @example Converting JavaScript Errors
27584
- * ```typescript
27585
- * try {
27586
- * JSON.parse("invalid json")
27587
- * } catch (jsError) {
27588
- * const alienError = AlienError.from(jsError)
27589
- * console.log(alienError.code) // "GENERIC_ERROR"
27590
- * }
27591
- * ```
27592
- *
27593
- * @example Error Chaining
27594
- * ```typescript
27595
- * const contextualError = AlienError.from(new Error("Network timeout"))
27596
- * .withContext(DatabaseError.create({
27597
- * host: "localhost",
27598
- * port: 5432,
27599
- * reason: "Connection timeout"
27600
- * }))
27601
- *
27602
- * // Check error chain
27603
- * console.log(contextualError.hasErrorCode("DATABASE_CONNECTION_FAILED")) // true
27604
- * console.log(contextualError.toString()) // Shows full error chain
27605
- * ```
27792
+ * Represents a serverless worker that executes code in response to triggers or direct invocations.
27793
+ * Workers are the primary compute resource in serverless applications, designed to be stateless and ephemeral.
27606
27794
  */
27607
- declare class AlienError<TContext extends z.ZodTypeAny = z.ZodAny> extends Error {
27608
- /** Unique error code identifying the error type */
27609
- readonly code: string;
27610
- /** Whether this error can be safely retried */
27611
- readonly retryable: boolean;
27612
- /** Whether this error contains sensitive internal information */
27613
- readonly internal: boolean;
27614
- /** HTTP status code for API responses */
27615
- readonly httpStatusCode: number;
27616
- /** Type-safe context data specific to this error */
27617
- readonly context?: z.infer<TContext>;
27618
- /** Optional human-facing remediation hint */
27619
- readonly hint?: string | null;
27620
- /** Source error that caused this error (for chaining) */
27621
- readonly source?: AlienError<any>;
27622
- constructor(input: AlienErrorDefinition<TContext> | (AlienError$1 & {
27623
- context?: any;
27624
- }));
27795
+ declare class Worker extends ResourceBuilder {
27796
+ private _config;
27625
27797
  /**
27626
- * Create an AlienError from a type-safe error definition.
27627
- *
27628
- * @template TContext - Zod schema type for the error context
27629
- * @param definition - Error definition with type-safe context
27630
- * @returns New AlienError instance
27798
+ * Creates a new Worker builder.
27799
+ * @param id Identifier for the worker. Must contain only alphanumeric characters, hyphens, and underscores ([A-Za-z0-9-_]). Maximum 64 characters.
27631
27800
  */
27632
- static fromDefinition<TContext extends z.ZodTypeAny>(definition: AlienErrorDefinition<TContext>): AlienError<TContext>;
27801
+ constructor(id: string);
27633
27802
  /**
27634
- * Create an AlienError from raw options (for compatibility).
27635
- *
27636
- * @param options - Raw error options conforming to AlienErrorOptions schema
27637
- * @returns New AlienError instance
27803
+ * Returns a ResourceType representing any worker resource.
27804
+ * Used for creating permission targets that apply to all worker resources.
27805
+ * @returns The "worker" resource type.
27638
27806
  */
27639
- static fromOptions(options: AlienError$1): AlienError;
27807
+ static any(): ResourceType;
27640
27808
  /**
27641
- * Helper function to get a user-friendly type name for error context.
27642
- *
27643
- * @param error - Any value to get the type name for
27644
- * @returns User-friendly type name
27809
+ * Sets the code for the worker, either a pre-built image or source code to be built.
27810
+ * @param code The worker code configuration.
27811
+ * @returns The Worker builder instance.
27645
27812
  */
27646
- private static getErrorTypeName;
27813
+ code(code: WorkerCode): this;
27647
27814
  /**
27648
- * Convert a JavaScript Error or any object to a generic AlienError.
27649
- *
27650
- * This is equivalent to Rust's `.into_alien_error()` pattern and provides
27651
- * a way to convert any JavaScript error into the structured AlienError format.
27652
- *
27653
- * @param error - Any JavaScript error or object to convert
27654
- * @returns AlienError with GENERIC_ERROR code and preserved original error
27655
- *
27656
- * @example
27657
- * ```typescript
27658
- * try {
27659
- * throw new TypeError("Invalid argument")
27660
- * } catch (error) {
27661
- * const alienError = AlienError.from(error)
27662
- * console.log(alienError.code) // "GENERIC_ERROR"
27663
- * console.log(alienError.context?.originalError) // Serialized TypeError
27664
- * }
27665
- * ```
27666
- *
27667
- * @example Chaining with context
27668
- * ```typescript
27669
- * try {
27670
- * JSON.parse("invalid")
27671
- * } catch (error) {
27672
- * throw AlienError.from(error).withContext(
27673
- * ValidationError.create({
27674
- * input: "invalid",
27675
- * expectedFormat: "JSON"
27676
- * })
27677
- * )
27678
- * }
27679
- * ```
27680
- *
27681
- * @example AxiosError conversion
27682
- * ```typescript
27683
- * try {
27684
- * await axios.get('/api/resource')
27685
- * } catch (error) {
27686
- * // If error.response.data contains a valid AlienError structure, it will be parsed
27687
- * const alienError = AlienError.from(error)
27688
- * console.log(alienError.code) // Could be "REMOTE_RESOURCE_NOT_FOUND" if parsed from response
27689
- * }
27690
- * ```
27815
+ * Sets the memory allocated to the worker in megabytes (MB).
27816
+ * Constraints: 128‑32768 MB (platform-specific limits may apply).
27817
+ * Default: 512 MB.
27818
+ * @param mb The memory in MB.
27819
+ * @returns The Worker builder instance.
27691
27820
  */
27692
- static from(error: any): Promise<AlienError>;
27821
+ memoryMb(mb: number): this;
27693
27822
  /**
27694
- * Add context to this error, creating a new error that wraps this one.
27695
- *
27696
- * This is equivalent to Rust's `.with_context()` pattern and allows
27697
- * building error chains with increasing levels of context.
27698
- *
27699
- * @template TNewContext - Zod schema type for the new context
27700
- * @param definition - Error definition to wrap this error with
27701
- * @returns New AlienError with this error as the source
27702
- *
27703
- * @example
27704
- * ```typescript
27705
- * // Clean fluent API
27706
- * const authError = (await AlienError.from(new Error("ECONNREFUSED")))
27707
- * .withContext(DatabaseError.create({
27708
- * host: "localhost",
27709
- * port: 5432,
27710
- * reason: "Connection refused"
27711
- * }))
27712
- * .withContext(AuthError.create({
27713
- * username: "john",
27714
- * reason: "Database unavailable"
27715
- * }))
27823
+ * Sets the maximum execution time for the worker in seconds.
27824
+ * Constraints: 1‑3600 seconds (platform-specific limits may apply).
27825
+ * Default: 30 seconds.
27826
+ * @param sec The timeout in seconds.
27827
+ * @returns The Worker builder instance.
27828
+ */
27829
+ timeoutSeconds(sec: number): this;
27830
+ /**
27831
+ * Sets the maximum number of concurrent executions allowed for the worker.
27832
+ * `null` means platform default applies.
27833
+ * @param limit The concurrency limit, or `null` for platform default.
27834
+ * @returns The Worker builder instance.
27835
+ */
27836
+ concurrencyLimit(limit: number | undefined): this;
27837
+ /**
27838
+ * Exposes a named public HTTP endpoint for the worker.
27716
27839
  *
27717
- * // Error chain: AuthError -> DatabaseError -> GENERIC_ERROR
27718
- * console.log(authError.toString())
27719
- * ```
27840
+ * If no public endpoint is declared, the worker is private and only reachable
27841
+ * through triggers, commands, or provider invocation APIs.
27842
+ */
27843
+ publicEndpoint(name: string, options?: WorkerPublicEndpointOptions): this;
27844
+ /**
27845
+ * Sets key-value pairs as environment variables for the worker.
27846
+ * @param env A map of environment variable names to their values.
27847
+ * @returns The Worker builder instance.
27720
27848
  */
27721
- withContext<TNewContext extends z.ZodTypeAny>(definition: AlienErrorDefinition<TNewContext>): AlienError<TNewContext>;
27849
+ environment(env: Record<string, string>): this;
27722
27850
  /**
27723
- * Convert this AlienError to the wire format (AlienErrorOptions).
27724
- *
27725
- * This method serializes the error into the standard format used
27726
- * for transmitting errors over the network or storing them.
27727
- *
27728
- * @returns AlienErrorOptions object representing this error
27851
+ * Links another resource (e.g., Storage, KV, Queue) to this worker.
27852
+ * This makes the linked resource accessible to the worker, often by injecting
27853
+ * environment variables or granting permissions.
27854
+ * @param resource The resource to link.
27855
+ * @returns The Worker builder instance.
27729
27856
  */
27730
- toOptions(): AlienError$1;
27857
+ link(resource: Resource): this;
27731
27858
  /**
27732
- * Get a sanitized version for external APIs (hides internal errors).
27733
- *
27734
- * This method is crucial for security - it prevents sensitive internal
27735
- * error details from being exposed to external users while preserving
27736
- * the error chain structure for non-sensitive errors.
27737
- *
27738
- * @returns Sanitized AlienErrorOptions safe for external consumption
27739
- *
27740
- * @example
27741
- * ```typescript
27742
- * const internalError = new AlienError(InternalApiError.create({
27743
- * service: "payment-processor",
27744
- * details: "Database password expired for user admin",
27745
- * traceId: "trace-12345"
27746
- * }))
27747
- *
27748
- * console.log(internalError.toOptions())
27749
- * // Shows full details including sensitive information
27750
- *
27751
- * console.log(internalError.toExternal())
27752
- * // { code: "GENERIC_ERROR", message: "Internal server error", ... }
27753
- * ```
27859
+ * Assigns a permission profile to this worker.
27860
+ * The profile defines the permissions granted to this worker when interacting
27861
+ * with other cloud resources.
27862
+ * @param permissions The permission profile name.
27863
+ * @returns The Worker builder instance.
27754
27864
  */
27755
- toExternal(): AlienError$1;
27865
+ permissions(permissions: string): this;
27756
27866
  /**
27757
- * Check if this error chain contains an error with a specific code.
27758
- *
27759
- * This method traverses the entire error chain (this error and all
27760
- * source errors) to find if any error has the specified code.
27761
- *
27762
- * @param code - Error code to search for
27763
- * @returns True if the code is found anywhere in the error chain
27867
+ * Configures a readiness probe for the worker.
27868
+ * The probe will be executed after provisioning/update to verify the worker is ready.
27869
+ * Only works with workers that declare a public endpoint.
27764
27870
  *
27765
27871
  * @example
27766
27872
  * ```typescript
27767
- * const chainedError = authError.withContext(dbError.withContext(networkError))
27873
+ * const probe: ReadinessProbe = {
27874
+ * method: "GET",
27875
+ * path: "/health"
27876
+ * };
27768
27877
  *
27769
- * console.log(chainedError.hasErrorCode("AUTH_FAILED")) // true
27770
- * console.log(chainedError.hasErrorCode("DATABASE_CONNECTION_FAILED")) // true
27771
- * console.log(chainedError.hasErrorCode("NETWORK_TIMEOUT")) // true
27772
- * console.log(chainedError.hasErrorCode("NONEXISTENT_ERROR")) // false
27878
+ * const func = new Worker("my-api")
27879
+ * .code({ type: "image", image: "my-api:latest" })
27880
+ * .publicEndpoint("api")
27881
+ * .readinessProbe(probe)
27882
+ * .build();
27773
27883
  * ```
27884
+ *
27885
+ * @param probe The readiness probe configuration.
27886
+ * @returns The Worker builder instance.
27774
27887
  */
27775
- hasErrorCode(code: string): boolean;
27888
+ readinessProbe(probe: ReadinessProbe): this;
27776
27889
  /**
27777
- * Find the first error in the chain with a specific code.
27778
- *
27779
- * This method traverses the error chain and returns the first error
27780
- * instance that matches the specified code, allowing access to its
27781
- * specific context and details.
27782
- *
27783
- * @param code - Error code to search for
27784
- * @returns AlienError instance with the specified code, or undefined if not found
27890
+ * Enables or disables the Commands protocol for the worker.
27891
+ * When enabled, the platform pushes commands into the Worker runtime, which executes registered handlers.
27892
+ * Default: false.
27893
+ * @param enabled Whether to enable commands for this worker.
27894
+ * @returns The Worker builder instance.
27895
+ */
27896
+ commandsEnabled(enabled: boolean): this;
27897
+ /**
27898
+ * Adds a trigger to the worker. Workers can have multiple triggers.
27899
+ * Each trigger will independently invoke the worker when its conditions are met.
27785
27900
  *
27786
27901
  * @example
27787
27902
  * ```typescript
27788
- * const chainedError = authError.withContext(dbError)
27903
+ * // Queue trigger
27904
+ * const queueTrigger: WorkerTrigger = {
27905
+ * type: "queue",
27906
+ * queue: myQueue.ref()
27907
+ * };
27789
27908
  *
27790
- * const dbError = chainedError.findErrorByCode("DATABASE_CONNECTION_FAILED")
27791
- * if (dbError) {
27792
- * console.log("Database error context:", dbError.context)
27793
- * console.log("Host:", dbError.context?.host)
27794
- * }
27909
+ * // Schedule trigger
27910
+ * const scheduleTrigg: WorkerTrigger = {
27911
+ * type: "schedule",
27912
+ * cron: "0 * * * *"
27913
+ * };
27914
+ *
27915
+ * const func = new Worker("my-func")
27916
+ * .code({ type: "image", image: "my-image:latest" })
27917
+ * .trigger(queueTrigger)
27918
+ * .trigger(scheduleTrigger)
27919
+ * .build();
27795
27920
  * ```
27921
+ *
27922
+ * @param trigger The trigger configuration.
27923
+ * @returns The Worker builder instance.
27796
27924
  */
27797
- findErrorByCode(code: string): AlienError | undefined;
27925
+ trigger(trigger: WorkerTrigger): this;
27798
27926
  /**
27799
- * Get a formatted string representation of the error chain.
27800
- *
27801
- * This method provides a human-readable representation of the entire
27802
- * error chain, showing how errors are nested and providing context
27803
- * for debugging and logging.
27804
- *
27805
- * @returns Formatted string showing the complete error chain
27806
- *
27807
- * @example
27808
- * ```typescript
27809
- * const chainedError = authError.withContext(dbError.withContext(networkError))
27810
- * console.log(chainedError.toString())
27811
- * // Output:
27812
- * // AUTH_FAILED: User authentication failed for 'john'
27813
- * // ├─▶ DATABASE_CONNECTION_FAILED: Failed to connect to database 'localhost:5432'
27814
- * // ├─▶ GENERIC_ERROR: Connection timeout
27815
- * ```
27927
+ * Builds and validates the worker configuration.
27928
+ * @returns An immutable Resource representing the configured worker.
27929
+ * @throws Error if the worker configuration is invalid (e.g., missing code).
27816
27930
  */
27817
- toString(): string;
27931
+ build(): Resource;
27818
27932
  }
27819
- type ExtractContext<T> = T extends AlienErrorDefinition<infer TContext> ? z.infer<TContext> : never;
27820
- //#endregion
27821
- //#region src/common-errors.d.ts
27822
- /**
27823
- * Error thrown when a requested resource cannot be found in the stack state.
27824
- * This matches the Rust alien-core error: RESOURCE_NOT_FOUND
27825
- */
27826
- declare const ResourceNotFoundError: {
27827
- metadata: AlienErrorMetadata<z$1.ZodObject<{
27828
- resourceId: z$1.ZodString;
27829
- availableResources: z$1.ZodArray<z$1.ZodString>;
27830
- }, z$1.core.$strip>>;
27831
- contextSchema: z$1.ZodObject<{
27832
- resourceId: z$1.ZodString;
27833
- availableResources: z$1.ZodArray<z$1.ZodString>;
27834
- }, z$1.core.$strip>;
27835
- create: (context: {
27836
- resourceId: string;
27837
- availableResources: string[];
27838
- }) => AlienErrorDefinition<z$1.ZodObject<{
27839
- resourceId: z$1.ZodString;
27840
- availableResources: z$1.ZodArray<z$1.ZodString>;
27841
- }, z$1.core.$strip>>;
27842
- };
27843
- /**
27844
- * Error thrown when resource outputs cannot be parsed according to their expected schema.
27845
- * This indicates an internal system error or data corruption.
27846
- */
27847
- declare const ResourceOutputsParseError: {
27848
- metadata: AlienErrorMetadata<z$1.ZodObject<{
27849
- resourceName: z$1.ZodString;
27850
- resourceType: z$1.ZodString;
27851
- validationErrors: z$1.ZodString;
27852
- }, z$1.core.$strip>>;
27853
- contextSchema: z$1.ZodObject<{
27854
- resourceName: z$1.ZodString;
27855
- resourceType: z$1.ZodString;
27856
- validationErrors: z$1.ZodString;
27857
- }, z$1.core.$strip>;
27858
- create: (context: {
27859
- resourceName: string;
27860
- resourceType: string;
27861
- validationErrors: string;
27862
- }) => AlienErrorDefinition<z$1.ZodObject<{
27863
- resourceName: z$1.ZodString;
27864
- resourceType: z$1.ZodString;
27865
- validationErrors: z$1.ZodString;
27866
- }, z$1.core.$strip>>;
27867
- };
27868
- /**
27869
- * Error thrown when there's a resource type mismatch during stack operations.
27870
- * This matches the Rust alien-core error: UNEXPECTED_RESOURCE_TYPE
27871
- */
27872
- declare const UnexpectedResourceTypeError: {
27873
- metadata: AlienErrorMetadata<z$1.ZodObject<{
27874
- resourceId: z$1.ZodString;
27875
- expected: z$1.ZodString;
27876
- actual: z$1.ZodString;
27877
- }, z$1.core.$strip>>;
27878
- contextSchema: z$1.ZodObject<{
27879
- resourceId: z$1.ZodString;
27880
- expected: z$1.ZodString;
27881
- actual: z$1.ZodString;
27882
- }, z$1.core.$strip>;
27883
- create: (context: {
27884
- resourceId: string;
27885
- expected: string;
27886
- actual: string;
27887
- }) => AlienErrorDefinition<z$1.ZodObject<{
27888
- resourceId: z$1.ZodString;
27889
- expected: z$1.ZodString;
27890
- actual: z$1.ZodString;
27891
- }, z$1.core.$strip>>;
27892
- };
27893
- /**
27894
- * Error thrown when a binding's projected configuration is invalid.
27895
- */
27896
- declare const InvalidBindingConfigError: {
27897
- metadata: AlienErrorMetadata<z$1.ZodObject<{
27898
- message: z$1.ZodString;
27899
- suggestion: z$1.ZodOptional<z$1.ZodString>;
27900
- }, z$1.core.$strip>>;
27901
- contextSchema: z$1.ZodObject<{
27902
- message: z$1.ZodString;
27903
- suggestion: z$1.ZodOptional<z$1.ZodString>;
27904
- }, z$1.core.$strip>;
27905
- create: (context: {
27906
- message: string;
27907
- suggestion?: string | undefined;
27908
- }) => AlienErrorDefinition<z$1.ZodObject<{
27909
- message: z$1.ZodString;
27910
- suggestion: z$1.ZodOptional<z$1.ZodString>;
27911
- }, z$1.core.$strip>>;
27912
- };
27913
- /**
27914
- * Error thrown when a binding is not found.
27915
- */
27916
- declare const BindingNotFoundError: {
27917
- metadata: AlienErrorMetadata<z$1.ZodObject<{
27918
- bindingName: z$1.ZodString;
27919
- bindingType: z$1.ZodString;
27920
- }, z$1.core.$strip>>;
27921
- contextSchema: z$1.ZodObject<{
27922
- bindingName: z$1.ZodString;
27923
- bindingType: z$1.ZodString;
27924
- }, z$1.core.$strip>;
27925
- create: (context: {
27926
- bindingName: string;
27927
- bindingType: string;
27928
- }) => AlienErrorDefinition<z$1.ZodObject<{
27929
- bindingName: z$1.ZodString;
27930
- bindingType: z$1.ZodString;
27931
- }, z$1.core.$strip>>;
27932
- };
27933
27933
  //#endregion
27934
27934
  //#region src/experimental/aws-opensearch.d.ts
27935
27935
  /**