@lunora/codegen 1.0.0-alpha.240 → 1.0.0-alpha.242

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.
Files changed (26) hide show
  1. package/dist/index.d.mts +93 -55
  2. package/dist/index.d.ts +93 -55
  3. package/dist/index.mjs +1 -1
  4. package/dist/packem_shared/AGENTS_FILENAME-Bb2jxbOa.mjs +1 -0
  5. package/dist/packem_shared/CONTAINERS_FILENAME-CGB4bqUr.mjs +1 -0
  6. package/dist/packem_shared/DEFAULT_TARGET-B1zgC6k6.mjs +1 -0
  7. package/dist/packem_shared/SCHEMA_SNAPSHOT_FILENAME-BHDnOBKJ.mjs +9 -0
  8. package/dist/packem_shared/WORKFLOWS_FILENAME-DNaUHGS8.mjs +1 -0
  9. package/dist/packem_shared/{discoverCrons-MfKw7IFf.mjs → discoverCrons-0lNudk0S.mjs} +1 -1
  10. package/dist/packem_shared/{emitAgents-Cy7QGO1t.mjs → emitAgents-Ddcr_r3B.mjs} +1 -1
  11. package/dist/packem_shared/{emitApi-CJ9ziZnP.mjs → emitApi-DdW9RyGG.mjs} +22 -22
  12. package/dist/packem_shared/{emitApp-BGhO5bhT.mjs → emitApp--W9G6MZd.mjs} +48 -56
  13. package/dist/packem_shared/{emitCrons-mkwWkn0R.mjs → emitCrons-Bop1FTEz.mjs} +28 -14
  14. package/dist/packem_shared/{emitFunctions-BqAz1ssY.mjs → emitFunctions-BgNeOZt_.mjs} +1 -1
  15. package/dist/packem_shared/{emitServer-BEo_fCY8.mjs → emitServer-B8t7Hzb1.mjs} +38 -40
  16. package/dist/packem_shared/emitShard-RnNua5aR.mjs +1 -0
  17. package/dist/packem_shared/ir-BgM8A3XV.mjs +1 -0
  18. package/dist/packem_shared/{shard-BBv6VBmX.mjs → shard-CCNl561P.mjs} +61 -61
  19. package/dist/packem_shared/{shard-runtime-CM5qthZc.mjs → shard-runtime-B7xvdFPc.mjs} +48 -39
  20. package/package.json +10 -10
  21. package/dist/packem_shared/AGENTS_FILENAME-DoPI92Wu.mjs +0 -1
  22. package/dist/packem_shared/CONTAINERS_FILENAME-B6TFs82W.mjs +0 -1
  23. package/dist/packem_shared/DEFAULT_TARGET-DCpDuuUM.mjs +0 -1
  24. package/dist/packem_shared/SCHEMA_SNAPSHOT_FILENAME-IOiezeVr.mjs +0 -9
  25. package/dist/packem_shared/WORKFLOWS_FILENAME-B_ZJxRSx.mjs +0 -1
  26. package/dist/packem_shared/emitShard-CsWK2K91.mjs +0 -1
package/dist/index.d.mts CHANGED
@@ -693,28 +693,37 @@ interface CronJobIR {
693
693
  name: string;
694
694
  /**
695
695
  * Set when the job targets a durable workflow (a `lunora/workflows.ts`
696
- * export) instead of a function: the workflow's `WORKFLOW_*` binding name
697
- * plus its export name. On each fire the worker starts a new workflow
696
+ * export) instead of a function: the workflow's class name (its
697
+ * `ctx.exports` key) plus its export name. On each fire the worker starts a new workflow
698
698
  * INSTANCE (the {@link CronJobIR.args} become its `params`) rather than
699
699
  * dispatching a one-shot function.
700
700
  */
701
701
  workflow?: {
702
- binding: string;
702
+ className: string;
703
703
  exportName: string;
704
704
  };
705
705
  }
706
- /**
707
- * A container lifted from a `defineContainer()` export in
708
- * `lunora/containers.ts`. Carries everything the emitters and the config layer
709
- * need to wire wrangler (`containers[]` + the Durable Object binding +
710
- * migration class) and the generated `_generated/containers.ts` DO class.
711
- * Names are derived via `@lunora/container`'s shared helpers so codegen and
712
- * the config layer can never disagree.
713
- */
714
- interface ContainerIR {
706
+ /** A normalized container image source, as written into `wrangler.jsonc`. */
707
+ type ContainerImageIR = {
708
+ buildContext: string;
709
+ dockerfilePath: string;
710
+ kind: "dockerfile";
711
+ } | {
712
+ buildDir: string;
713
+ kind: "build";
714
+ } | {
715
+ kind: "registry";
716
+ reference: string;
717
+ };
718
+ /** A `durable_object` container's named image — a Dockerfile or a registry digest, never a Railpack build. */
719
+ type ContainerNamedImageIR = Exclude<ContainerImageIR, {
720
+ kind: "build";
721
+ }>;
722
+ /** The fields every container carries, whichever scheduling policy it uses. */
723
+ interface ContainerIRBase {
715
724
  /** Durable Object binding name, e.g. `CONTAINER_TRANSCODER`. */
716
725
  bindingName: string;
717
- /** Static Dockerfile build args (wrangler `image_vars`), when declared as literals. */
726
+ /** Static Dockerfile build args (wrangler `image_vars` / named-image `build_vars`), when declared as literals. */
718
727
  buildArgs?: Record<string, string>;
719
728
  /** Generated DO class name, e.g. `TranscoderContainer`. */
720
729
  className: string;
@@ -726,43 +735,58 @@ interface ContainerIR {
726
735
  enableInternet?: boolean;
727
736
  /** The `lunora/containers.ts` export name, e.g. `transcoder`. */
728
737
  exportName: string;
729
- /**
730
- * Normalized image source: a local Dockerfile (`dockerfile`), a pre-built
731
- * registry reference (`registry`), or a Railpack source directory (`build`)
732
- * that the deploy step builds and pushes before wrangler runs.
733
- */
734
- image: {
735
- buildContext: string;
736
- dockerfilePath: string;
737
- kind: "dockerfile";
738
- } | {
739
- buildDir: string;
740
- kind: "build";
741
- } | {
742
- kind: "registry";
743
- reference: string;
744
- };
745
- /** Static `instanceType`, when declared. */
738
+ /** Static `instanceType`, when declared (the default size, under `durable_object`). */
746
739
  instanceType?: string | {
747
740
  diskMb?: number;
748
741
  memoryMib?: number;
749
742
  vcpu?: number;
750
743
  };
751
- /** Static `maxInstances`, when declared. */
752
- maxInstances?: number;
753
744
  /** Static wrangler `containers[].name` override, when declared. */
754
745
  name?: string;
755
- /** Static rolling-deploy tuning, when declared as literals. */
756
- rollout?: {
757
- gracePeriodSeconds?: number;
758
- stepPercentage?: number;
759
- };
760
746
  /**
761
747
  * The static `sleepAfter` value, when it was a literal. `undefined` means
762
748
  * omitted (platform default `"10m"`) or non-literal. Lifted for the advisor.
763
749
  */
764
750
  sleepAfter?: number | string;
765
751
  }
752
+ /** A container under the default scheduling policy: one application image, a cap, and a rollout. */
753
+ interface DefaultScheduledContainerIR extends ContainerIRBase {
754
+ /**
755
+ * Normalized image source: a local Dockerfile (`dockerfile`), a pre-built
756
+ * registry reference (`registry`), or a Railpack source directory (`build`)
757
+ * that the deploy step builds and pushes before wrangler runs.
758
+ */
759
+ image: ContainerImageIR;
760
+ /** Static `maxInstances`, when declared. */
761
+ maxInstances?: number;
762
+ /** Static rolling-deploy tuning, when declared as literals. */
763
+ rollout?: {
764
+ gracePeriodSeconds?: number;
765
+ stepPercentage?: number;
766
+ };
767
+ /** Absent under the default policy — the union's discriminant. */
768
+ schedulingPolicy?: never;
769
+ }
770
+ /**
771
+ * A container under the `durable_object` scheduling policy (wrangler
772
+ * `scheduling_policy`): each instance picks its image and size per start. Also
773
+ * the `containerRuntimeScheduling` platform signal.
774
+ */
775
+ interface DurableObjectScheduledContainerIR extends ContainerIRBase {
776
+ /** The named images an instance can start from (wrangler `containers[].images`). */
777
+ images?: Record<string, ContainerNamedImageIR>;
778
+ schedulingPolicy: "durable_object";
779
+ }
780
+ /**
781
+ * A container lifted from a `defineContainer()` export in
782
+ * `lunora/containers.ts`, discriminated on its scheduling policy. Carries
783
+ * everything the emitters and the config layer need to wire wrangler
784
+ * (`containers[]` + the Durable Object binding + migration class) and the
785
+ * generated `_generated/containers.ts` DO class. Names are derived via
786
+ * `@lunora/container`'s shared helpers so codegen and the config layer can
787
+ * never disagree.
788
+ */
789
+ type ContainerIR = DefaultScheduledContainerIR | DurableObjectScheduledContainerIR;
766
790
  /**
767
791
  * A workflow lifted from a `defineWorkflow()` export in `lunora/workflows.ts`.
768
792
  * Carries what the emitters and the config layer need to wire the wrangler
@@ -773,18 +797,31 @@ interface ContainerIR {
773
797
  * shared helpers so codegen and the config layer can never disagree.
774
798
  */
775
799
  interface WorkflowIR {
776
- /** The Cloudflare `Workflow` binding name, e.g. `WORKFLOW_ORDER_PIPELINE`. */
777
- bindingName: string;
778
- /** Generated `WorkflowEntrypoint` class name, e.g. `OrderPipelineWorkflow`. */
800
+ /** Generated `WorkflowEntrypoint` class name, e.g. `OrderPipelineWorkflow` — also its `exports` key and `ctx.exports` property. */
779
801
  className: string;
802
+ /** Static `defaultRetention` literal → `exports.<Class>.default_retention`. */
803
+ defaultRetention?: {
804
+ errorRetention?: string;
805
+ successRetention?: string;
806
+ };
780
807
  /** The `lunora/workflows.ts` export name, e.g. `orderPipeline`. */
781
808
  exportName: string;
809
+ /** Static `limits` literal → `exports.<Class>.limits`. */
810
+ limits?: {
811
+ steps?: number;
812
+ };
782
813
  /**
783
- * The stable wrangler `workflows[].name`. Defaults to the kebab-cased export
814
+ * The stable wrangler `exports.<Class>.name`. Defaults to the kebab-cased export
784
815
  * name (`orderPipeline` → `order-pipeline`); a static `name:` literal in the
785
816
  * definition overrides it.
786
817
  */
787
818
  name: string;
819
+ /**
820
+ * Static `schedules` cron literals → `exports.<Class>.schedules`. Each one
821
+ * starts an instance on Cloudflare; gated by the `workflowSchedules`
822
+ * capability, since a host that ignores them would never run the workflow.
823
+ */
824
+ schedules?: ReadonlyArray<string>;
788
825
  /**
789
826
  * Durable step labels lifted from the handler body — the first string-literal
790
827
  * argument of every `ctx.step.do` / `.sleep` / `.sleepUntil` / `.waitForEvent`
@@ -807,14 +844,12 @@ interface WorkflowIR {
807
844
  * the config layer can never disagree.
808
845
  */
809
846
  interface AgentIR {
810
- /** The Cloudflare `Workflow` binding name, e.g. `AGENT_SUPPORT`. */
811
- bindingName: string;
812
- /** Generated `WorkflowEntrypoint` class name, e.g. `SupportAgentWorkflow`. */
847
+ /** Generated `WorkflowEntrypoint` class name, e.g. `SupportAgentWorkflow` — also its `exports` key and `ctx.exports` property. */
813
848
  className: string;
814
849
  /** The `lunora/agents.ts` export name, e.g. `support`. */
815
850
  exportName: string;
816
851
  /**
817
- * The stable wrangler `workflows[].name`. Defaults to the kebab-cased export
852
+ * The stable wrangler `exports.<Class>.name`. Defaults to the kebab-cased export
818
853
  * name (`support` → `agent-support`); a static `name:` literal in the
819
854
  * definition overrides it.
820
855
  */
@@ -3067,8 +3102,9 @@ declare const WORKFLOWS_FILENAME = "workflows.ts";
3067
3102
  /**
3068
3103
  * Discover every workflow the project declares: exported `defineWorkflow()`
3069
3104
  * calls in `lunora/workflows.ts`. Returns `[]` when the file doesn't exist. The
3070
- * only wrangler-relevant literal is the optional `name` override; the workflow
3071
- * body is runtime-only, so codegen never evaluates it.
3105
+ * wrangler-relevant literals are the optional `name` override and the deploy
3106
+ * settings (`schedules`, `limits`, `defaultRetention`); the workflow body is
3107
+ * runtime-only, so codegen never evaluates it.
3072
3108
  */
3073
3109
  declare const discoverWorkflows: (project: Project, lunoraDirectory: string) => WorkflowIR[];
3074
3110
  /**
@@ -3382,7 +3418,7 @@ interface EmitAppOptions {
3382
3418
  * ⇒ no wiring, byte-identical output for email-free (and agent-free) projects.
3383
3419
  */
3384
3420
  emailAgents?: ReadonlyArray<{
3385
- bindingName: string;
3421
+ className: string;
3386
3422
  exportName: string;
3387
3423
  }>;
3388
3424
  /** App depends on `@lunora/cloudflare-access` → emit `.access()` (wire the Cloudflare Access `resolveIdentity`, composed ahead of `@lunora/auth` when both are present). */
@@ -3466,13 +3502,15 @@ interface EmitAppOptions {
3466
3502
  */
3467
3503
  jurisdictionPinsAuth?: boolean;
3468
3504
  /**
3469
- * Every table the schema declares. Emitted as a literal `listSchemaTables`
3470
- * so export can answer "every table" with a real list: shard discovery is
3471
- * driven by the table list, so an export naming no tables reaches no shards.
3472
- * A literal (rather than a read off the imported `schema`) keeps this working
3473
- * for apps with no `.global()` tables, which never import `schema` at all.
3505
+ * Every table the schema declares, with its shard mode. Emitted as a literal
3506
+ * table map backing `listSchemaTables` and `resolveTableSharding`: export
3507
+ * needs a real "every table" list (shard discovery is driven by it), and the
3508
+ * import bucketing plus the worker's default shard registry need to tell a
3509
+ * `.shardBy()` table from a root one. A literal (rather than a read off the
3510
+ * imported `schema`) keeps this working for apps with no `.global()` tables,
3511
+ * which never import `schema` at all.
3474
3512
  */
3475
- tableNames: ReadonlyArray<string>;
3513
+ tables: ReadonlyArray<Pick<TableIR, "name" | "shardMode">>;
3476
3514
  /** Project depends on the unscoped `lunorash` umbrella → import the runtime via `lunorash/runtime` instead of `@lunora/runtime`. */
3477
3515
  useUmbrella: boolean;
3478
3516
  /** Number of `.vectorize()` / `defineVectorIndex(...)` indexes the schema declares — the app-side half of {@link EmitAppOptions.hasVectors}. Defaults to `0`. */
@@ -4132,4 +4170,4 @@ declare const secretKindOf: (value: string) => string | undefined;
4132
4170
  /** A redacted preview of a secret value — first 4 chars plus its length, never the full value. */
4133
4171
  declare const redact: (value: string) => string;
4134
4172
  declare const VERSION = "0.0.0";
4135
- export { AGENTS_FILENAME, type AgentIR, type AuthApiCallIR, CONTAINERS_FILENAME, CodegenDiagnosticError, type CodegenOptions, type CodegenResult, type ContainerIR, type ContextPropertyCallIR, type CronJobIR, DEFAULT_TARGET, type DriftChange, type DriftRemediation, type DriftScope, type EmitAppOptions, FLAGS_FILENAME, type FieldSnapshot, type FlagsIR, type FunctionIR, GENERATED_HEADER, type HttpRouteIR, type IndexIR, type IndexSnapshot, type InsertWriteIR, LUNORA_ERROR_CODES, type LintSchemaOptions, type LoadedProjectConfig, type LunoraProjectConfig, MUTATORS_FILENAME, type MaskProcedureIR, type MigrationIR, type MutatorIR, NOTIFY_FILENAME, OPENRPC_VERSION, type OpenApiEmitInput, type OpenRpcDocument, type OpenRpcEmitInput, type OpenRpcMethod, PROJECT_CONFIG_FILENAMES, type PlatformDiagnostic, type ProjectConfigLiterals, type ProjectIR, QUEUES_FILENAME, type QueryReadIR, type QueueIR, type RelationSnapshot, type RlsMetadataIR, type RlsPolicyIR, type RlsProcedureIR, type RlsRoleIR, type RuntimeVerb, SCHEMA_SNAPSHOT_FILENAME, SCHEMA_SNAPSHOT_VERSION, SDK_LANGUAGES, SDK_TARGETS, SHAPES_FILENAME, type SandboxUsage, type SchemaDrift, type SchemaDriftDecision, type SchemaIR, type SchemaSnapshot, SchemaSnapshotParseError, type SdkFiles, type SdkMethod, type SdkNamespace, type SdkRenderInput, type SdkResult, type SdkTarget, type ShapeIR, type StorageRuleIR, type StorageRulesMetadataIR, type TableIR, type TableSnapshot, VERSION, type ValidatorIR, type VectorIndexIR, WORKFLOWS_FILENAME, type WorkflowIR, type WranglerVariableIR, buildOpenApiDocument, buildOpenRpcDocument, buildSchemaSnapshot, createCodegenProject, describeErrorLevelFindings, diagnosticAt, diffSchemaSnapshots, discoverAgents, discoverAuthApiCalls, discoverContainers, discoverCrons, discoverFlags, discoverFunctions, discoverHttpRoutes, discoverHyperdriveCalls, discoverInserts, discoverMaskProcedures, discoverMigrations, discoverMutators, discoverNondeterministicCalls, discoverNotifyCalls, discoverNotifyConfig, discoverQueries, discoverQueues, discoverR2sqlCalls, discoverRlsMetadata, discoverRlsProcedures, discoverSandboxUsage, discoverSchema, discoverShapes, discoverStorageRulesMetadata, discoverWorkflows, emitAgents, emitApi, emitApp, emitCollections, emitContainers, emitCrons, emitDataModel, emitDrizzleSchema, emitFunctions, emitOpenApi, emitOpenApiModule, emitOpenRpc, emitOpenRpcModule, emitScheduler, emitServer, emitShard, emitVectors, emitWorkflows, emitWranglerCronTriggers, errorAdvisoryNames, errorPlatformDiagnosticNames, evaluateSchemaDrift, findProjectConfigFile, findTsconfig, fingerprintSchemaSources, formatAdvisories, generateSdk, isD1GlobalTable, isHyperdriveGlobalTable, isTypedSchema, lintSchema, listLunoraSourceFiles, loadProjectConfig, parseSchemaSnapshot, platformMatrixIds, readPackageDependencies, readProjectConfigLiterals, readProjectTarget, redact, refreshCodegenProject, resolveCodegenTarget, runCodegen, schemaFromIr, secretKindOf, serializeSchemaSnapshot, sortedUniqueNames, toAdvisorContext, validatorIrToJsonSchema };
4173
+ export { AGENTS_FILENAME, type AgentIR, type AuthApiCallIR, CONTAINERS_FILENAME, CodegenDiagnosticError, type CodegenOptions, type CodegenResult, type ContainerIR, type ContainerImageIR, type ContainerNamedImageIR, type ContextPropertyCallIR, type CronJobIR, DEFAULT_TARGET, type DefaultScheduledContainerIR, type DriftChange, type DriftRemediation, type DriftScope, type DurableObjectScheduledContainerIR, type EmitAppOptions, FLAGS_FILENAME, type FieldSnapshot, type FlagsIR, type FunctionIR, GENERATED_HEADER, type HttpRouteIR, type IndexIR, type IndexSnapshot, type InsertWriteIR, LUNORA_ERROR_CODES, type LintSchemaOptions, type LoadedProjectConfig, type LunoraProjectConfig, MUTATORS_FILENAME, type MaskProcedureIR, type MigrationIR, type MutatorIR, NOTIFY_FILENAME, OPENRPC_VERSION, type OpenApiEmitInput, type OpenRpcDocument, type OpenRpcEmitInput, type OpenRpcMethod, PROJECT_CONFIG_FILENAMES, type PlatformDiagnostic, type ProjectConfigLiterals, type ProjectIR, QUEUES_FILENAME, type QueryReadIR, type QueueIR, type RelationSnapshot, type RlsMetadataIR, type RlsPolicyIR, type RlsProcedureIR, type RlsRoleIR, type RuntimeVerb, SCHEMA_SNAPSHOT_FILENAME, SCHEMA_SNAPSHOT_VERSION, SDK_LANGUAGES, SDK_TARGETS, SHAPES_FILENAME, type SandboxUsage, type SchemaDrift, type SchemaDriftDecision, type SchemaIR, type SchemaSnapshot, SchemaSnapshotParseError, type SdkFiles, type SdkMethod, type SdkNamespace, type SdkRenderInput, type SdkResult, type SdkTarget, type ShapeIR, type StorageRuleIR, type StorageRulesMetadataIR, type TableIR, type TableSnapshot, VERSION, type ValidatorIR, type VectorIndexIR, WORKFLOWS_FILENAME, type WorkflowIR, type WranglerVariableIR, buildOpenApiDocument, buildOpenRpcDocument, buildSchemaSnapshot, createCodegenProject, describeErrorLevelFindings, diagnosticAt, diffSchemaSnapshots, discoverAgents, discoverAuthApiCalls, discoverContainers, discoverCrons, discoverFlags, discoverFunctions, discoverHttpRoutes, discoverHyperdriveCalls, discoverInserts, discoverMaskProcedures, discoverMigrations, discoverMutators, discoverNondeterministicCalls, discoverNotifyCalls, discoverNotifyConfig, discoverQueries, discoverQueues, discoverR2sqlCalls, discoverRlsMetadata, discoverRlsProcedures, discoverSandboxUsage, discoverSchema, discoverShapes, discoverStorageRulesMetadata, discoverWorkflows, emitAgents, emitApi, emitApp, emitCollections, emitContainers, emitCrons, emitDataModel, emitDrizzleSchema, emitFunctions, emitOpenApi, emitOpenApiModule, emitOpenRpc, emitOpenRpcModule, emitScheduler, emitServer, emitShard, emitVectors, emitWorkflows, emitWranglerCronTriggers, errorAdvisoryNames, errorPlatformDiagnosticNames, evaluateSchemaDrift, findProjectConfigFile, findTsconfig, fingerprintSchemaSources, formatAdvisories, generateSdk, isD1GlobalTable, isHyperdriveGlobalTable, isTypedSchema, lintSchema, listLunoraSourceFiles, loadProjectConfig, parseSchemaSnapshot, platformMatrixIds, readPackageDependencies, readProjectConfigLiterals, readProjectTarget, redact, refreshCodegenProject, resolveCodegenTarget, runCodegen, schemaFromIr, secretKindOf, serializeSchemaSnapshot, sortedUniqueNames, toAdvisorContext, validatorIrToJsonSchema };
package/dist/index.d.ts CHANGED
@@ -693,28 +693,37 @@ interface CronJobIR {
693
693
  name: string;
694
694
  /**
695
695
  * Set when the job targets a durable workflow (a `lunora/workflows.ts`
696
- * export) instead of a function: the workflow's `WORKFLOW_*` binding name
697
- * plus its export name. On each fire the worker starts a new workflow
696
+ * export) instead of a function: the workflow's class name (its
697
+ * `ctx.exports` key) plus its export name. On each fire the worker starts a new workflow
698
698
  * INSTANCE (the {@link CronJobIR.args} become its `params`) rather than
699
699
  * dispatching a one-shot function.
700
700
  */
701
701
  workflow?: {
702
- binding: string;
702
+ className: string;
703
703
  exportName: string;
704
704
  };
705
705
  }
706
- /**
707
- * A container lifted from a `defineContainer()` export in
708
- * `lunora/containers.ts`. Carries everything the emitters and the config layer
709
- * need to wire wrangler (`containers[]` + the Durable Object binding +
710
- * migration class) and the generated `_generated/containers.ts` DO class.
711
- * Names are derived via `@lunora/container`'s shared helpers so codegen and
712
- * the config layer can never disagree.
713
- */
714
- interface ContainerIR {
706
+ /** A normalized container image source, as written into `wrangler.jsonc`. */
707
+ type ContainerImageIR = {
708
+ buildContext: string;
709
+ dockerfilePath: string;
710
+ kind: "dockerfile";
711
+ } | {
712
+ buildDir: string;
713
+ kind: "build";
714
+ } | {
715
+ kind: "registry";
716
+ reference: string;
717
+ };
718
+ /** A `durable_object` container's named image — a Dockerfile or a registry digest, never a Railpack build. */
719
+ type ContainerNamedImageIR = Exclude<ContainerImageIR, {
720
+ kind: "build";
721
+ }>;
722
+ /** The fields every container carries, whichever scheduling policy it uses. */
723
+ interface ContainerIRBase {
715
724
  /** Durable Object binding name, e.g. `CONTAINER_TRANSCODER`. */
716
725
  bindingName: string;
717
- /** Static Dockerfile build args (wrangler `image_vars`), when declared as literals. */
726
+ /** Static Dockerfile build args (wrangler `image_vars` / named-image `build_vars`), when declared as literals. */
718
727
  buildArgs?: Record<string, string>;
719
728
  /** Generated DO class name, e.g. `TranscoderContainer`. */
720
729
  className: string;
@@ -726,43 +735,58 @@ interface ContainerIR {
726
735
  enableInternet?: boolean;
727
736
  /** The `lunora/containers.ts` export name, e.g. `transcoder`. */
728
737
  exportName: string;
729
- /**
730
- * Normalized image source: a local Dockerfile (`dockerfile`), a pre-built
731
- * registry reference (`registry`), or a Railpack source directory (`build`)
732
- * that the deploy step builds and pushes before wrangler runs.
733
- */
734
- image: {
735
- buildContext: string;
736
- dockerfilePath: string;
737
- kind: "dockerfile";
738
- } | {
739
- buildDir: string;
740
- kind: "build";
741
- } | {
742
- kind: "registry";
743
- reference: string;
744
- };
745
- /** Static `instanceType`, when declared. */
738
+ /** Static `instanceType`, when declared (the default size, under `durable_object`). */
746
739
  instanceType?: string | {
747
740
  diskMb?: number;
748
741
  memoryMib?: number;
749
742
  vcpu?: number;
750
743
  };
751
- /** Static `maxInstances`, when declared. */
752
- maxInstances?: number;
753
744
  /** Static wrangler `containers[].name` override, when declared. */
754
745
  name?: string;
755
- /** Static rolling-deploy tuning, when declared as literals. */
756
- rollout?: {
757
- gracePeriodSeconds?: number;
758
- stepPercentage?: number;
759
- };
760
746
  /**
761
747
  * The static `sleepAfter` value, when it was a literal. `undefined` means
762
748
  * omitted (platform default `"10m"`) or non-literal. Lifted for the advisor.
763
749
  */
764
750
  sleepAfter?: number | string;
765
751
  }
752
+ /** A container under the default scheduling policy: one application image, a cap, and a rollout. */
753
+ interface DefaultScheduledContainerIR extends ContainerIRBase {
754
+ /**
755
+ * Normalized image source: a local Dockerfile (`dockerfile`), a pre-built
756
+ * registry reference (`registry`), or a Railpack source directory (`build`)
757
+ * that the deploy step builds and pushes before wrangler runs.
758
+ */
759
+ image: ContainerImageIR;
760
+ /** Static `maxInstances`, when declared. */
761
+ maxInstances?: number;
762
+ /** Static rolling-deploy tuning, when declared as literals. */
763
+ rollout?: {
764
+ gracePeriodSeconds?: number;
765
+ stepPercentage?: number;
766
+ };
767
+ /** Absent under the default policy — the union's discriminant. */
768
+ schedulingPolicy?: never;
769
+ }
770
+ /**
771
+ * A container under the `durable_object` scheduling policy (wrangler
772
+ * `scheduling_policy`): each instance picks its image and size per start. Also
773
+ * the `containerRuntimeScheduling` platform signal.
774
+ */
775
+ interface DurableObjectScheduledContainerIR extends ContainerIRBase {
776
+ /** The named images an instance can start from (wrangler `containers[].images`). */
777
+ images?: Record<string, ContainerNamedImageIR>;
778
+ schedulingPolicy: "durable_object";
779
+ }
780
+ /**
781
+ * A container lifted from a `defineContainer()` export in
782
+ * `lunora/containers.ts`, discriminated on its scheduling policy. Carries
783
+ * everything the emitters and the config layer need to wire wrangler
784
+ * (`containers[]` + the Durable Object binding + migration class) and the
785
+ * generated `_generated/containers.ts` DO class. Names are derived via
786
+ * `@lunora/container`'s shared helpers so codegen and the config layer can
787
+ * never disagree.
788
+ */
789
+ type ContainerIR = DefaultScheduledContainerIR | DurableObjectScheduledContainerIR;
766
790
  /**
767
791
  * A workflow lifted from a `defineWorkflow()` export in `lunora/workflows.ts`.
768
792
  * Carries what the emitters and the config layer need to wire the wrangler
@@ -773,18 +797,31 @@ interface ContainerIR {
773
797
  * shared helpers so codegen and the config layer can never disagree.
774
798
  */
775
799
  interface WorkflowIR {
776
- /** The Cloudflare `Workflow` binding name, e.g. `WORKFLOW_ORDER_PIPELINE`. */
777
- bindingName: string;
778
- /** Generated `WorkflowEntrypoint` class name, e.g. `OrderPipelineWorkflow`. */
800
+ /** Generated `WorkflowEntrypoint` class name, e.g. `OrderPipelineWorkflow` — also its `exports` key and `ctx.exports` property. */
779
801
  className: string;
802
+ /** Static `defaultRetention` literal → `exports.<Class>.default_retention`. */
803
+ defaultRetention?: {
804
+ errorRetention?: string;
805
+ successRetention?: string;
806
+ };
780
807
  /** The `lunora/workflows.ts` export name, e.g. `orderPipeline`. */
781
808
  exportName: string;
809
+ /** Static `limits` literal → `exports.<Class>.limits`. */
810
+ limits?: {
811
+ steps?: number;
812
+ };
782
813
  /**
783
- * The stable wrangler `workflows[].name`. Defaults to the kebab-cased export
814
+ * The stable wrangler `exports.<Class>.name`. Defaults to the kebab-cased export
784
815
  * name (`orderPipeline` → `order-pipeline`); a static `name:` literal in the
785
816
  * definition overrides it.
786
817
  */
787
818
  name: string;
819
+ /**
820
+ * Static `schedules` cron literals → `exports.<Class>.schedules`. Each one
821
+ * starts an instance on Cloudflare; gated by the `workflowSchedules`
822
+ * capability, since a host that ignores them would never run the workflow.
823
+ */
824
+ schedules?: ReadonlyArray<string>;
788
825
  /**
789
826
  * Durable step labels lifted from the handler body — the first string-literal
790
827
  * argument of every `ctx.step.do` / `.sleep` / `.sleepUntil` / `.waitForEvent`
@@ -807,14 +844,12 @@ interface WorkflowIR {
807
844
  * the config layer can never disagree.
808
845
  */
809
846
  interface AgentIR {
810
- /** The Cloudflare `Workflow` binding name, e.g. `AGENT_SUPPORT`. */
811
- bindingName: string;
812
- /** Generated `WorkflowEntrypoint` class name, e.g. `SupportAgentWorkflow`. */
847
+ /** Generated `WorkflowEntrypoint` class name, e.g. `SupportAgentWorkflow` — also its `exports` key and `ctx.exports` property. */
813
848
  className: string;
814
849
  /** The `lunora/agents.ts` export name, e.g. `support`. */
815
850
  exportName: string;
816
851
  /**
817
- * The stable wrangler `workflows[].name`. Defaults to the kebab-cased export
852
+ * The stable wrangler `exports.<Class>.name`. Defaults to the kebab-cased export
818
853
  * name (`support` → `agent-support`); a static `name:` literal in the
819
854
  * definition overrides it.
820
855
  */
@@ -3067,8 +3102,9 @@ declare const WORKFLOWS_FILENAME = "workflows.ts";
3067
3102
  /**
3068
3103
  * Discover every workflow the project declares: exported `defineWorkflow()`
3069
3104
  * calls in `lunora/workflows.ts`. Returns `[]` when the file doesn't exist. The
3070
- * only wrangler-relevant literal is the optional `name` override; the workflow
3071
- * body is runtime-only, so codegen never evaluates it.
3105
+ * wrangler-relevant literals are the optional `name` override and the deploy
3106
+ * settings (`schedules`, `limits`, `defaultRetention`); the workflow body is
3107
+ * runtime-only, so codegen never evaluates it.
3072
3108
  */
3073
3109
  declare const discoverWorkflows: (project: Project, lunoraDirectory: string) => WorkflowIR[];
3074
3110
  /**
@@ -3382,7 +3418,7 @@ interface EmitAppOptions {
3382
3418
  * ⇒ no wiring, byte-identical output for email-free (and agent-free) projects.
3383
3419
  */
3384
3420
  emailAgents?: ReadonlyArray<{
3385
- bindingName: string;
3421
+ className: string;
3386
3422
  exportName: string;
3387
3423
  }>;
3388
3424
  /** App depends on `@lunora/cloudflare-access` → emit `.access()` (wire the Cloudflare Access `resolveIdentity`, composed ahead of `@lunora/auth` when both are present). */
@@ -3466,13 +3502,15 @@ interface EmitAppOptions {
3466
3502
  */
3467
3503
  jurisdictionPinsAuth?: boolean;
3468
3504
  /**
3469
- * Every table the schema declares. Emitted as a literal `listSchemaTables`
3470
- * so export can answer "every table" with a real list: shard discovery is
3471
- * driven by the table list, so an export naming no tables reaches no shards.
3472
- * A literal (rather than a read off the imported `schema`) keeps this working
3473
- * for apps with no `.global()` tables, which never import `schema` at all.
3505
+ * Every table the schema declares, with its shard mode. Emitted as a literal
3506
+ * table map backing `listSchemaTables` and `resolveTableSharding`: export
3507
+ * needs a real "every table" list (shard discovery is driven by it), and the
3508
+ * import bucketing plus the worker's default shard registry need to tell a
3509
+ * `.shardBy()` table from a root one. A literal (rather than a read off the
3510
+ * imported `schema`) keeps this working for apps with no `.global()` tables,
3511
+ * which never import `schema` at all.
3474
3512
  */
3475
- tableNames: ReadonlyArray<string>;
3513
+ tables: ReadonlyArray<Pick<TableIR, "name" | "shardMode">>;
3476
3514
  /** Project depends on the unscoped `lunorash` umbrella → import the runtime via `lunorash/runtime` instead of `@lunora/runtime`. */
3477
3515
  useUmbrella: boolean;
3478
3516
  /** Number of `.vectorize()` / `defineVectorIndex(...)` indexes the schema declares — the app-side half of {@link EmitAppOptions.hasVectors}. Defaults to `0`. */
@@ -4132,4 +4170,4 @@ declare const secretKindOf: (value: string) => string | undefined;
4132
4170
  /** A redacted preview of a secret value — first 4 chars plus its length, never the full value. */
4133
4171
  declare const redact: (value: string) => string;
4134
4172
  declare const VERSION = "0.0.0";
4135
- export { AGENTS_FILENAME, type AgentIR, type AuthApiCallIR, CONTAINERS_FILENAME, CodegenDiagnosticError, type CodegenOptions, type CodegenResult, type ContainerIR, type ContextPropertyCallIR, type CronJobIR, DEFAULT_TARGET, type DriftChange, type DriftRemediation, type DriftScope, type EmitAppOptions, FLAGS_FILENAME, type FieldSnapshot, type FlagsIR, type FunctionIR, GENERATED_HEADER, type HttpRouteIR, type IndexIR, type IndexSnapshot, type InsertWriteIR, LUNORA_ERROR_CODES, type LintSchemaOptions, type LoadedProjectConfig, type LunoraProjectConfig, MUTATORS_FILENAME, type MaskProcedureIR, type MigrationIR, type MutatorIR, NOTIFY_FILENAME, OPENRPC_VERSION, type OpenApiEmitInput, type OpenRpcDocument, type OpenRpcEmitInput, type OpenRpcMethod, PROJECT_CONFIG_FILENAMES, type PlatformDiagnostic, type ProjectConfigLiterals, type ProjectIR, QUEUES_FILENAME, type QueryReadIR, type QueueIR, type RelationSnapshot, type RlsMetadataIR, type RlsPolicyIR, type RlsProcedureIR, type RlsRoleIR, type RuntimeVerb, SCHEMA_SNAPSHOT_FILENAME, SCHEMA_SNAPSHOT_VERSION, SDK_LANGUAGES, SDK_TARGETS, SHAPES_FILENAME, type SandboxUsage, type SchemaDrift, type SchemaDriftDecision, type SchemaIR, type SchemaSnapshot, SchemaSnapshotParseError, type SdkFiles, type SdkMethod, type SdkNamespace, type SdkRenderInput, type SdkResult, type SdkTarget, type ShapeIR, type StorageRuleIR, type StorageRulesMetadataIR, type TableIR, type TableSnapshot, VERSION, type ValidatorIR, type VectorIndexIR, WORKFLOWS_FILENAME, type WorkflowIR, type WranglerVariableIR, buildOpenApiDocument, buildOpenRpcDocument, buildSchemaSnapshot, createCodegenProject, describeErrorLevelFindings, diagnosticAt, diffSchemaSnapshots, discoverAgents, discoverAuthApiCalls, discoverContainers, discoverCrons, discoverFlags, discoverFunctions, discoverHttpRoutes, discoverHyperdriveCalls, discoverInserts, discoverMaskProcedures, discoverMigrations, discoverMutators, discoverNondeterministicCalls, discoverNotifyCalls, discoverNotifyConfig, discoverQueries, discoverQueues, discoverR2sqlCalls, discoverRlsMetadata, discoverRlsProcedures, discoverSandboxUsage, discoverSchema, discoverShapes, discoverStorageRulesMetadata, discoverWorkflows, emitAgents, emitApi, emitApp, emitCollections, emitContainers, emitCrons, emitDataModel, emitDrizzleSchema, emitFunctions, emitOpenApi, emitOpenApiModule, emitOpenRpc, emitOpenRpcModule, emitScheduler, emitServer, emitShard, emitVectors, emitWorkflows, emitWranglerCronTriggers, errorAdvisoryNames, errorPlatformDiagnosticNames, evaluateSchemaDrift, findProjectConfigFile, findTsconfig, fingerprintSchemaSources, formatAdvisories, generateSdk, isD1GlobalTable, isHyperdriveGlobalTable, isTypedSchema, lintSchema, listLunoraSourceFiles, loadProjectConfig, parseSchemaSnapshot, platformMatrixIds, readPackageDependencies, readProjectConfigLiterals, readProjectTarget, redact, refreshCodegenProject, resolveCodegenTarget, runCodegen, schemaFromIr, secretKindOf, serializeSchemaSnapshot, sortedUniqueNames, toAdvisorContext, validatorIrToJsonSchema };
4173
+ export { AGENTS_FILENAME, type AgentIR, type AuthApiCallIR, CONTAINERS_FILENAME, CodegenDiagnosticError, type CodegenOptions, type CodegenResult, type ContainerIR, type ContainerImageIR, type ContainerNamedImageIR, type ContextPropertyCallIR, type CronJobIR, DEFAULT_TARGET, type DefaultScheduledContainerIR, type DriftChange, type DriftRemediation, type DriftScope, type DurableObjectScheduledContainerIR, type EmitAppOptions, FLAGS_FILENAME, type FieldSnapshot, type FlagsIR, type FunctionIR, GENERATED_HEADER, type HttpRouteIR, type IndexIR, type IndexSnapshot, type InsertWriteIR, LUNORA_ERROR_CODES, type LintSchemaOptions, type LoadedProjectConfig, type LunoraProjectConfig, MUTATORS_FILENAME, type MaskProcedureIR, type MigrationIR, type MutatorIR, NOTIFY_FILENAME, OPENRPC_VERSION, type OpenApiEmitInput, type OpenRpcDocument, type OpenRpcEmitInput, type OpenRpcMethod, PROJECT_CONFIG_FILENAMES, type PlatformDiagnostic, type ProjectConfigLiterals, type ProjectIR, QUEUES_FILENAME, type QueryReadIR, type QueueIR, type RelationSnapshot, type RlsMetadataIR, type RlsPolicyIR, type RlsProcedureIR, type RlsRoleIR, type RuntimeVerb, SCHEMA_SNAPSHOT_FILENAME, SCHEMA_SNAPSHOT_VERSION, SDK_LANGUAGES, SDK_TARGETS, SHAPES_FILENAME, type SandboxUsage, type SchemaDrift, type SchemaDriftDecision, type SchemaIR, type SchemaSnapshot, SchemaSnapshotParseError, type SdkFiles, type SdkMethod, type SdkNamespace, type SdkRenderInput, type SdkResult, type SdkTarget, type ShapeIR, type StorageRuleIR, type StorageRulesMetadataIR, type TableIR, type TableSnapshot, VERSION, type ValidatorIR, type VectorIndexIR, WORKFLOWS_FILENAME, type WorkflowIR, type WranglerVariableIR, buildOpenApiDocument, buildOpenRpcDocument, buildSchemaSnapshot, createCodegenProject, describeErrorLevelFindings, diagnosticAt, diffSchemaSnapshots, discoverAgents, discoverAuthApiCalls, discoverContainers, discoverCrons, discoverFlags, discoverFunctions, discoverHttpRoutes, discoverHyperdriveCalls, discoverInserts, discoverMaskProcedures, discoverMigrations, discoverMutators, discoverNondeterministicCalls, discoverNotifyCalls, discoverNotifyConfig, discoverQueries, discoverQueues, discoverR2sqlCalls, discoverRlsMetadata, discoverRlsProcedures, discoverSandboxUsage, discoverSchema, discoverShapes, discoverStorageRulesMetadata, discoverWorkflows, emitAgents, emitApi, emitApp, emitCollections, emitContainers, emitCrons, emitDataModel, emitDrizzleSchema, emitFunctions, emitOpenApi, emitOpenApiModule, emitOpenRpc, emitOpenRpcModule, emitScheduler, emitServer, emitShard, emitVectors, emitWorkflows, emitWranglerCronTriggers, errorAdvisoryNames, errorPlatformDiagnosticNames, evaluateSchemaDrift, findProjectConfigFile, findTsconfig, fingerprintSchemaSources, formatAdvisories, generateSdk, isD1GlobalTable, isHyperdriveGlobalTable, isTypedSchema, lintSchema, listLunoraSourceFiles, loadProjectConfig, parseSchemaSnapshot, platformMatrixIds, readPackageDependencies, readProjectConfigLiterals, readProjectTarget, redact, refreshCodegenProject, resolveCodegenTarget, runCodegen, schemaFromIr, secretKindOf, serializeSchemaSnapshot, sortedUniqueNames, toAdvisorContext, validatorIrToJsonSchema };
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{SCHEMA_SNAPSHOT_VERSION as t,diffSchemaSnapshots as s,serializeSchemaSnapshot as a}from"./packem_shared/SCHEMA_SNAPSHOT_VERSION-C0oHwiJZ.mjs";import{formatAdvisories as m,lintSchema as f,toAdvisorContext as d}from"./packem_shared/formatAdvisories-DwmUKYuc.mjs";import{describeErrorLevelFindings as c,errorAdvisoryNames as n,errorPlatformDiagnosticNames as l,sortedUniqueNames as x}from"./packem_shared/describeErrorLevelFindings-vzaGS9KL.mjs";import{CodegenDiagnosticError as E,diagnosticAt as u}from"./packem_shared/CodegenDiagnosticError-BUXlG3P-.mjs";import{AGENTS_FILENAME as v,discoverAgents as N}from"./packem_shared/AGENTS_FILENAME-DoPI92Wu.mjs";import{listLunoraSourceFiles as C}from"./packem_shared/listLunoraSourceFiles-DP-5e-RE.mjs";import{default as R}from"./packem_shared/discoverAuthApiCalls-FxrdBeVt.mjs";import{CONTAINERS_FILENAME as T,discoverContainers as _}from"./packem_shared/CONTAINERS_FILENAME-B6TFs82W.mjs";import{default as L}from"./packem_shared/discoverCrons-MfKw7IFf.mjs";import{FLAGS_FILENAME as I,discoverFlags as P}from"./packem_shared/FLAGS_FILENAME-BedPDCsR.mjs";import{default as G}from"./packem_shared/discoverFunctions-BsmX-sEq.mjs";import{default as b}from"./packem_shared/discoverHttpRoutes-BcXI9CNt.mjs";import{default as y}from"./packem_shared/discoverHyperdriveCalls-D9qXqTq3.mjs";import{default as k}from"./packem_shared/discoverInserts-CFJ3IVeI.mjs";import{d as z}from"./packem_shared/index-BoaHhVtM.mjs";import{default as V}from"./packem_shared/discoverMigrations-DbrHwcGE.mjs";import{MUTATORS_FILENAME as q,discoverMutators as w}from"./packem_shared/MUTATORS_FILENAME-B6cKrN_m.mjs";import{default as B}from"./packem_shared/discoverNondeterministicCalls-CSQ_GDcA.mjs";import{NOTIFY_FILENAME as X,discoverNotifyCalls as Z,discoverNotifyConfig as $}from"./packem_shared/NOTIFY_FILENAME-Cri3NT5U.mjs";import{default as re}from"./packem_shared/readPackageDependencies-C6h6FZuP.mjs";import{d as te}from"./packem_shared/queries-B-f4jO-x.mjs";import{QUEUES_FILENAME as ae,discoverQueues as ie}from"./packem_shared/QUEUES_FILENAME-CxkPcMH1.mjs";import{default as fe}from"./packem_shared/discoverR2sqlCalls-fu7fC0i_.mjs";import{default as pe}from"./packem_shared/discoverRlsProcedures-BO4qC77y.mjs";import{default as ne}from"./packem_shared/discoverRlsMetadata-CPmAGL0W.mjs";import{discoverSandboxUsage as xe}from"./packem_shared/discoverSandboxUsage-CrjZ6yNg.mjs";import{default as Ee}from"./packem_shared/discoverSchema-D8DBDHEg.mjs";import{SHAPES_FILENAME as Ae,discoverShapes as ve}from"./packem_shared/SHAPES_FILENAME-zJgzynXR.mjs";import{default as ge}from"./packem_shared/discoverStorageRulesMetadata-D8VYflWt.mjs";import{WORKFLOWS_FILENAME as Oe,discoverWorkflows as Re}from"./packem_shared/WORKFLOWS_FILENAME-B_ZJxRSx.mjs";import{emitApp as Te}from"./packem_shared/emitApp-BGhO5bhT.mjs";import{isD1GlobalTable as he,isHyperdriveGlobalTable as Le}from"./packem_shared/isD1GlobalTable-udvHAAzD.mjs";import{buildOpenApiDocument as Ie,emitOpenApi as Pe,emitOpenApiModule as De}from"./packem_shared/buildOpenApiDocument-nYvBhjxu.mjs";import{OPENRPC_VERSION as Ue,buildOpenRpcDocument as be,emitOpenRpc as He,emitOpenRpcModule as ye}from"./packem_shared/OPENRPC_VERSION-Cl6P9WGv.mjs";import{DEFAULT_TARGET as ke,platformMatrixIds as We,readProjectTarget as ze,resolveCodegenTarget as Ke}from"./packem_shared/DEFAULT_TARGET-DCpDuuUM.mjs";import{loadProjectConfig as Qe,readProjectConfigLiterals as qe}from"./packem_shared/loadProjectConfig-CKsFNgn3.mjs";import{SCHEMA_SNAPSHOT_FILENAME as Je,createCodegenProject as Be,findTsconfig as Ye,refreshCodegenProject as Xe,runCodegen as Ze}from"./packem_shared/SCHEMA_SNAPSHOT_FILENAME-IOiezeVr.mjs";import{SchemaSnapshotParseError as er,buildSchemaSnapshot as rr,evaluateSchemaDrift as or,parseSchemaSnapshot as tr}from"./packem_shared/SchemaSnapshotParseError-CPOXlFhI.mjs";import{default as ar}from"./packem_shared/fingerprintSchemaSources-L3nGKDQt.mjs";import{schemaFromIr as mr}from"./packem_shared/schemaFromIr-BWFnvCVg.mjs";import{LUNORA_ERROR_CODES as dr,validatorIrToJsonSchema as pr}from"./packem_shared/LUNORA_ERROR_CODES-C2s0xWQD.mjs";import{SDK_LANGUAGES as nr,SDK_TARGETS as lr,generateSdk as xr}from"./packem_shared/SDK_LANGUAGES-Df_CnJx5.mjs";import{redact as Er,secretKindOf as ur}from"./packem_shared/redact-Cy14LEnc.mjs";import{default as vr}from"./packem_shared/emitDrizzleSchema-Cv0HtLR3.mjs";import{default as gr}from"./packem_shared/emitFunctions-BqAz1ssY.mjs";import{default as Or}from"./packem_shared/emitServer-BEo_fCY8.mjs";import{e as Mr}from"./packem_shared/shard-BBv6VBmX.mjs";import{G as _r}from"./packem_shared/shared-DjUziztz.mjs";import{MESSAGE_SOLUTIONS as Lr,findSolutionByMessage as Fr}from"@lunora/errors";import{PROJECT_CONFIG_FILENAMES as Pr,findProjectConfigFile as Dr}from"./packem_shared/PROJECT_CONFIG_FILENAMES-DzOu-lSc.mjs";import{y as Ur,z as br,A as Hr}from"./packem_shared/shard-runtime-CM5qthZc.mjs";import{emitApi as jr,emitCollections as kr}from"./packem_shared/emitApi-CJ9ziZnP.mjs";import{emitCrons as zr,emitScheduler as Kr,emitVectors as Vr,emitWranglerCronTriggers as Qr}from"./packem_shared/emitCrons-mkwWkn0R.mjs";import{emitDataModel as wr}from"./packem_shared/emitDataModel-D3WuEZ4b.mjs";import{isTypedSchema as Br}from"./packem_shared/isTypedSchema-CKzc3ioR.mjs";const e="0.0.0";export{v as AGENTS_FILENAME,T as CONTAINERS_FILENAME,E as CodegenDiagnosticError,ke as DEFAULT_TARGET,I as FLAGS_FILENAME,_r as GENERATED_HEADER,dr as LUNORA_ERROR_CODES,Lr as LUNORA_SOLUTION_RULES,q as MUTATORS_FILENAME,X as NOTIFY_FILENAME,Ue as OPENRPC_VERSION,Pr as PROJECT_CONFIG_FILENAMES,ae as QUEUES_FILENAME,Je as SCHEMA_SNAPSHOT_FILENAME,t as SCHEMA_SNAPSHOT_VERSION,nr as SDK_LANGUAGES,lr as SDK_TARGETS,Ae as SHAPES_FILENAME,er as SchemaSnapshotParseError,e as VERSION,Oe as WORKFLOWS_FILENAME,Ie as buildOpenApiDocument,be as buildOpenRpcDocument,rr as buildSchemaSnapshot,Be as createCodegenProject,c as describeErrorLevelFindings,u as diagnosticAt,s as diffSchemaSnapshots,N as discoverAgents,R as discoverAuthApiCalls,_ as discoverContainers,L as discoverCrons,P as discoverFlags,G as discoverFunctions,b as discoverHttpRoutes,y as discoverHyperdriveCalls,k as discoverInserts,z as discoverMaskProcedures,V as discoverMigrations,w as discoverMutators,B as discoverNondeterministicCalls,Z as discoverNotifyCalls,$ as discoverNotifyConfig,te as discoverQueries,ie as discoverQueues,fe as discoverR2sqlCalls,ne as discoverRlsMetadata,pe as discoverRlsProcedures,xe as discoverSandboxUsage,Ee as discoverSchema,ve as discoverShapes,ge as discoverStorageRulesMetadata,Re as discoverWorkflows,Ur as emitAgents,jr as emitApi,Te as emitApp,kr as emitCollections,br as emitContainers,zr as emitCrons,wr as emitDataModel,vr as emitDrizzleSchema,gr as emitFunctions,Pe as emitOpenApi,De as emitOpenApiModule,He as emitOpenRpc,ye as emitOpenRpcModule,Kr as emitScheduler,Or as emitServer,Mr as emitShard,Vr as emitVectors,Hr as emitWorkflows,Qr as emitWranglerCronTriggers,n as errorAdvisoryNames,l as errorPlatformDiagnosticNames,or as evaluateSchemaDrift,Fr as findLunoraSolution,Dr as findProjectConfigFile,Ye as findTsconfig,ar as fingerprintSchemaSources,m as formatAdvisories,xr as generateSdk,he as isD1GlobalTable,Le as isHyperdriveGlobalTable,Br as isTypedSchema,f as lintSchema,C as listLunoraSourceFiles,Qe as loadProjectConfig,tr as parseSchemaSnapshot,We as platformMatrixIds,re as readPackageDependencies,qe as readProjectConfigLiterals,ze as readProjectTarget,Er as redact,Xe as refreshCodegenProject,Ke as resolveCodegenTarget,Ze as runCodegen,mr as schemaFromIr,ur as secretKindOf,a as serializeSchemaSnapshot,x as sortedUniqueNames,d as toAdvisorContext,pr as validatorIrToJsonSchema};
1
+ import{SCHEMA_SNAPSHOT_VERSION as t,diffSchemaSnapshots as s,serializeSchemaSnapshot as a}from"./packem_shared/SCHEMA_SNAPSHOT_VERSION-C0oHwiJZ.mjs";import{formatAdvisories as m,lintSchema as f,toAdvisorContext as d}from"./packem_shared/formatAdvisories-DwmUKYuc.mjs";import{describeErrorLevelFindings as c,errorAdvisoryNames as n,errorPlatformDiagnosticNames as l,sortedUniqueNames as x}from"./packem_shared/describeErrorLevelFindings-vzaGS9KL.mjs";import{CodegenDiagnosticError as E,diagnosticAt as u}from"./packem_shared/CodegenDiagnosticError-BUXlG3P-.mjs";import{AGENTS_FILENAME as v,discoverAgents as N}from"./packem_shared/AGENTS_FILENAME-Bb2jxbOa.mjs";import{listLunoraSourceFiles as C}from"./packem_shared/listLunoraSourceFiles-DP-5e-RE.mjs";import{default as R}from"./packem_shared/discoverAuthApiCalls-FxrdBeVt.mjs";import{CONTAINERS_FILENAME as T,discoverContainers as _}from"./packem_shared/CONTAINERS_FILENAME-CGB4bqUr.mjs";import{default as L}from"./packem_shared/discoverCrons-0lNudk0S.mjs";import{FLAGS_FILENAME as I,discoverFlags as P}from"./packem_shared/FLAGS_FILENAME-BedPDCsR.mjs";import{default as G}from"./packem_shared/discoverFunctions-BsmX-sEq.mjs";import{default as b}from"./packem_shared/discoverHttpRoutes-BcXI9CNt.mjs";import{default as y}from"./packem_shared/discoverHyperdriveCalls-D9qXqTq3.mjs";import{default as k}from"./packem_shared/discoverInserts-CFJ3IVeI.mjs";import{d as z}from"./packem_shared/index-BoaHhVtM.mjs";import{default as V}from"./packem_shared/discoverMigrations-DbrHwcGE.mjs";import{MUTATORS_FILENAME as q,discoverMutators as w}from"./packem_shared/MUTATORS_FILENAME-B6cKrN_m.mjs";import{default as J}from"./packem_shared/discoverNondeterministicCalls-CSQ_GDcA.mjs";import{NOTIFY_FILENAME as X,discoverNotifyCalls as Z,discoverNotifyConfig as $}from"./packem_shared/NOTIFY_FILENAME-Cri3NT5U.mjs";import{default as re}from"./packem_shared/readPackageDependencies-C6h6FZuP.mjs";import{d as te}from"./packem_shared/queries-B-f4jO-x.mjs";import{QUEUES_FILENAME as ae,discoverQueues as ie}from"./packem_shared/QUEUES_FILENAME-CxkPcMH1.mjs";import{default as fe}from"./packem_shared/discoverR2sqlCalls-fu7fC0i_.mjs";import{default as pe}from"./packem_shared/discoverRlsProcedures-BO4qC77y.mjs";import{default as ne}from"./packem_shared/discoverRlsMetadata-CPmAGL0W.mjs";import{discoverSandboxUsage as xe}from"./packem_shared/discoverSandboxUsage-CrjZ6yNg.mjs";import{default as Ee}from"./packem_shared/discoverSchema-D8DBDHEg.mjs";import{SHAPES_FILENAME as Ae,discoverShapes as ve}from"./packem_shared/SHAPES_FILENAME-zJgzynXR.mjs";import{default as ge}from"./packem_shared/discoverStorageRulesMetadata-D8VYflWt.mjs";import{WORKFLOWS_FILENAME as Oe,discoverWorkflows as Re}from"./packem_shared/WORKFLOWS_FILENAME-DNaUHGS8.mjs";import{emitApp as Te}from"./packem_shared/emitApp--W9G6MZd.mjs";import{isD1GlobalTable as he,isHyperdriveGlobalTable as Le}from"./packem_shared/isD1GlobalTable-udvHAAzD.mjs";import{buildOpenApiDocument as Ie,emitOpenApi as Pe,emitOpenApiModule as De}from"./packem_shared/buildOpenApiDocument-nYvBhjxu.mjs";import{OPENRPC_VERSION as Ue,buildOpenRpcDocument as be,emitOpenRpc as He,emitOpenRpcModule as ye}from"./packem_shared/OPENRPC_VERSION-Cl6P9WGv.mjs";import{DEFAULT_TARGET as ke,platformMatrixIds as We,readProjectTarget as ze,resolveCodegenTarget as Ke}from"./packem_shared/DEFAULT_TARGET-B1zgC6k6.mjs";import{loadProjectConfig as Qe,readProjectConfigLiterals as qe}from"./packem_shared/loadProjectConfig-CKsFNgn3.mjs";import{SCHEMA_SNAPSHOT_FILENAME as Be,createCodegenProject as Je,findTsconfig as Ye,refreshCodegenProject as Xe,runCodegen as Ze}from"./packem_shared/SCHEMA_SNAPSHOT_FILENAME-BHDnOBKJ.mjs";import{SchemaSnapshotParseError as er,buildSchemaSnapshot as rr,evaluateSchemaDrift as or,parseSchemaSnapshot as tr}from"./packem_shared/SchemaSnapshotParseError-CPOXlFhI.mjs";import{default as ar}from"./packem_shared/fingerprintSchemaSources-L3nGKDQt.mjs";import{schemaFromIr as mr}from"./packem_shared/schemaFromIr-BWFnvCVg.mjs";import{LUNORA_ERROR_CODES as dr,validatorIrToJsonSchema as pr}from"./packem_shared/LUNORA_ERROR_CODES-C2s0xWQD.mjs";import{SDK_LANGUAGES as nr,SDK_TARGETS as lr,generateSdk as xr}from"./packem_shared/SDK_LANGUAGES-Df_CnJx5.mjs";import{redact as Er,secretKindOf as ur}from"./packem_shared/redact-Cy14LEnc.mjs";import{default as vr}from"./packem_shared/emitDrizzleSchema-Cv0HtLR3.mjs";import{default as gr}from"./packem_shared/emitFunctions-BgNeOZt_.mjs";import{default as Or}from"./packem_shared/emitServer-B8t7Hzb1.mjs";import{e as Mr}from"./packem_shared/shard-CCNl561P.mjs";import{G as _r}from"./packem_shared/shared-DjUziztz.mjs";import{MESSAGE_SOLUTIONS as Lr,findSolutionByMessage as Fr}from"@lunora/errors";import{PROJECT_CONFIG_FILENAMES as Pr,findProjectConfigFile as Dr}from"./packem_shared/PROJECT_CONFIG_FILENAMES-DzOu-lSc.mjs";import{z as Ur,A as br,B as Hr}from"./packem_shared/shard-runtime-B7xvdFPc.mjs";import{emitApi as jr,emitCollections as kr}from"./packem_shared/emitApi-DdW9RyGG.mjs";import{emitCrons as zr,emitScheduler as Kr,emitVectors as Vr,emitWranglerCronTriggers as Qr}from"./packem_shared/emitCrons-Bop1FTEz.mjs";import{emitDataModel as wr}from"./packem_shared/emitDataModel-D3WuEZ4b.mjs";import{isTypedSchema as Jr}from"./packem_shared/isTypedSchema-CKzc3ioR.mjs";const e="0.0.0";export{v as AGENTS_FILENAME,T as CONTAINERS_FILENAME,E as CodegenDiagnosticError,ke as DEFAULT_TARGET,I as FLAGS_FILENAME,_r as GENERATED_HEADER,dr as LUNORA_ERROR_CODES,Lr as LUNORA_SOLUTION_RULES,q as MUTATORS_FILENAME,X as NOTIFY_FILENAME,Ue as OPENRPC_VERSION,Pr as PROJECT_CONFIG_FILENAMES,ae as QUEUES_FILENAME,Be as SCHEMA_SNAPSHOT_FILENAME,t as SCHEMA_SNAPSHOT_VERSION,nr as SDK_LANGUAGES,lr as SDK_TARGETS,Ae as SHAPES_FILENAME,er as SchemaSnapshotParseError,e as VERSION,Oe as WORKFLOWS_FILENAME,Ie as buildOpenApiDocument,be as buildOpenRpcDocument,rr as buildSchemaSnapshot,Je as createCodegenProject,c as describeErrorLevelFindings,u as diagnosticAt,s as diffSchemaSnapshots,N as discoverAgents,R as discoverAuthApiCalls,_ as discoverContainers,L as discoverCrons,P as discoverFlags,G as discoverFunctions,b as discoverHttpRoutes,y as discoverHyperdriveCalls,k as discoverInserts,z as discoverMaskProcedures,V as discoverMigrations,w as discoverMutators,J as discoverNondeterministicCalls,Z as discoverNotifyCalls,$ as discoverNotifyConfig,te as discoverQueries,ie as discoverQueues,fe as discoverR2sqlCalls,ne as discoverRlsMetadata,pe as discoverRlsProcedures,xe as discoverSandboxUsage,Ee as discoverSchema,ve as discoverShapes,ge as discoverStorageRulesMetadata,Re as discoverWorkflows,Ur as emitAgents,jr as emitApi,Te as emitApp,kr as emitCollections,br as emitContainers,zr as emitCrons,wr as emitDataModel,vr as emitDrizzleSchema,gr as emitFunctions,Pe as emitOpenApi,De as emitOpenApiModule,He as emitOpenRpc,ye as emitOpenRpcModule,Kr as emitScheduler,Or as emitServer,Mr as emitShard,Vr as emitVectors,Hr as emitWorkflows,Qr as emitWranglerCronTriggers,n as errorAdvisoryNames,l as errorPlatformDiagnosticNames,or as evaluateSchemaDrift,Fr as findLunoraSolution,Dr as findProjectConfigFile,Ye as findTsconfig,ar as fingerprintSchemaSources,m as formatAdvisories,xr as generateSdk,he as isD1GlobalTable,Le as isHyperdriveGlobalTable,Jr as isTypedSchema,f as lintSchema,C as listLunoraSourceFiles,Qe as loadProjectConfig,tr as parseSchemaSnapshot,We as platformMatrixIds,re as readPackageDependencies,qe as readProjectConfigLiterals,ze as readProjectTarget,Er as redact,Xe as refreshCodegenProject,Ke as resolveCodegenTarget,Ze as runCodegen,mr as schemaFromIr,ur as secretKindOf,a as serializeSchemaSnapshot,x as sortedUniqueNames,d as toAdvisorContext,pr as validatorIrToJsonSchema};
@@ -0,0 +1 @@
1
+ import{existsSync as p}from"node:fs";import{join as f}from"node:path";import{agentDefaultName as d,agentClassName as b,voiceBindingName as N,voiceClassName as y}from"@lunora/agent/naming";import{LunoraError as m}from"@lunora/errors";import{Node as s,SyntaxKind as u}from"ts-morph";import{diagnosticAt as l}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{unwrapToCallExpression as A,findObjectProperty as c,stringPropertyFor as w}from"./listLunoraSourceFiles-DP-5e-RE.mjs";const h="agents.ts",E=o=>{const n=o.getSymbol();if(!n)return o.getText()==="defineAgent";for(const t of n.getDeclarations())if(s.isImportSpecifier(t))return t.getImportDeclaration().getModuleSpecifierValue()!=="@lunora/agent"?!1:t.getNameNode().getText()==="defineAgent";return!1},P=w("agent"),v=(o,n,t)=>{if(o.getKind()===u.TrueKeyword)return!0;if(o.getKind()===u.FalseKeyword)return!1;throw l(o,`agent "${n}": \`${t}\` must be a static boolean literal — it is deploy configuration codegen writes into the ctx.agents wiring spec`)},T=(o,n)=>{const t=o.getArguments()[0];if(!t||!s.isObjectLiteralExpression(t))throw l(o,`agent "${n}": defineAgent must be passed an inline object literal`);const e={className:b(n),exportName:n,name:d(n)},i=c(t,"name");i&&s.isPropertyAssignment(i)&&(e.name=P(i.getInitializerOrThrow(),n,"name"));const r=c(t,"publicRun");r&&s.isPropertyAssignment(r)&&v(r.getInitializerOrThrow(),n,"publicRun")&&(e.publicRun=!0);const a=c(t,"voice");if(a&&s.isPropertyAssignment(a)){const g=a.getInitializerOrThrow();if(!s.isObjectLiteralExpression(g))throw l(g,`agent "${n}": \`voice\` must be an inline object literal — its presence tells codegen to emit the voice-session Durable Object`);e.voice=!0,e.voiceBindingName=N(n),e.voiceClassName=y(n)}return c(t,"onEmail")&&(e.onEmail=!0),e},I=o=>{const n=[];for(const t of o.getVariableDeclarations()){if(!t.isExported())continue;const e=A(t.getInitializer());if(!e)continue;const i=e.getExpression();if(!s.isIdentifier(i)||!E(i))continue;const r=t.getNameNode();if(!s.isIdentifier(r))throw l(r,"defineAgent exports must be plain named exports (no destructuring)");n.push(T(e,r.getText()))}return n},x=o=>{const n=new Map,t=new Map;for(const e of o){const i=n.get(e.name);if(i!==void 0)throw new m("DUPLICATE_AGENT_NAME",`Duplicate agent name "${e.name}": produced by both "${i}" and "${e.exportName}". Deployed agent names must be unique across the project.`,{status:500});n.set(e.name,e.exportName);const r=t.get(e.className);if(r!==void 0)throw new m("DUPLICATE_AGENT_CLASS",`Duplicate agent class "${e.className}": produced by both "${r}" and "${e.exportName}". Agent export names must yield unique generated class names.`,{status:500});t.set(e.className,e.exportName)}},O=(o,n)=>{const t=f(n,h);if(!p(t))return[];const e=o.getSourceFile(t)??o.addSourceFileAtPath(t),i=I(e);return i.sort((r,a)=>r.exportName.localeCompare(a.exportName)),x(i),i};export{h as AGENTS_FILENAME,O as discoverAgents};
@@ -0,0 +1 @@
1
+ import{existsSync as $}from"node:fs";import{join as S}from"node:path";import{containerClassName as P,containerBindingName as T,DURABLE_OBJECT_POLICY_FORBIDDEN_KEYS as A,isManagedImage as j,isCloudflareRegistryDigest as O,normalizeContainerImage as b}from"@lunora/container";import{SyntaxKind as d,Node as o}from"ts-morph";import{diagnosticAt as a}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{propertyKeyName as y,stringPropertyFor as I,findObjectProperty as p,symbolConstInitializer as k}from"./listLunoraSourceFiles-DP-5e-RE.mjs";const C="containers.ts",D=t=>{const e=t.getSymbol();if(!e)return t.getText()==="defineContainer";for(const r of e.getDeclarations())if(o.isImportSpecifier(r))return r.getImportDeclaration().getModuleSpecifierValue()!=="@lunora/container"?!1:r.getNameNode().getText()==="defineContainer";return!1},f=I("container"),h=(t,e,r)=>{if(o.isNumericLiteral(t))return t.getLiteralValue();throw a(t,`container "${e}": \`${r}\` must be a static number literal — it is deploy configuration codegen writes into wrangler.jsonc`)},w=(t,e)=>{if(o.isStringLiteral(t)||o.isNoSubstitutionTemplateLiteral(t))return b(t.getLiteralValue());if(o.isObjectLiteralExpression(t)){const r=p(t,"registry");if(r&&o.isPropertyAssignment(r)){const i=r.getInitializerOrThrow();return b({registry:f(i,e,"image.registry")})}const n=p(t,"build");if(n&&o.isPropertyAssignment(n)){const i=n.getInitializerOrThrow();return b({build:f(i,e,"image.build")})}}throw a(t,`container "${e}": \`image\` must be a static string path, { registry: "…" }, or { build: "…" } literal`)},M=new Set(["buildArgs","image","images","instanceType","maxInstances","name","rollout","schedulingPolicy"]),_=new Set(["gracePeriodSeconds","stepPercentage"]),E=t=>{let e=t;for(;o.isAsExpression(e)||o.isSatisfiesExpression(e)||o.isTypeAssertion(e)||o.isParenthesizedExpression(e);)e=e.getExpression();return e},F=(t,e)=>{const r=i=>{let s=i;for(;o.isPropertyAccessExpression(s)||o.isElementAccessExpression(s)||o.isParenthesizedExpression(s);)s=s.getExpression();return s===i?void 0:s},n=i=>i!==void 0&&o.isIdentifier(i)&&i.getSymbol()===t;return e.getDescendants().some(i=>{if(o.isBinaryExpression(i)){const s=i.getOperatorToken().getKind();return s>=d.FirstAssignment&&s<=d.LastAssignment&&n(r(i.getLeft()))}if(o.isPrefixUnaryExpression(i)||o.isPostfixUnaryExpression(i)){const s=i.getOperatorToken();return(s===d.PlusPlusToken||s===d.MinusMinusToken)&&n(r(i.getOperand()))}return o.isDeleteExpression(i)?n(r(i.getExpression())):o.isCallExpression(i)&&i.getExpression().getText()==="Object.assign"&&n(i.getArguments()[0])})},B=16,v=(t,e,r,n)=>{let i={name:r,symbol:t},s;for(let l=0;l<B;l+=1){const c=k(i.symbol);if(c===void 0||!o.isExpression(c))return s;if(s=E(c),o.isObjectLiteralExpression(s)&&i.symbol!==void 0&&F(i.symbol,e.getSourceFile()))throw a(e,`${n}: \`${i.name}\` is a const object that is written to elsewhere in this file, so its initializer is not the value the container runs with. Declare the settings where they are final.`);if(!o.isIdentifier(s))return s;i={name:s.getText(),symbol:s.getSymbol()}}return s},L=(t,e)=>{const r=E(t);return o.isIdentifier(r)?v(r.getSymbol(),r,r.getText(),e)??r:r},R=t=>{const e=t.getNonNullableType();return(e.isUnion()?e.getUnionTypes():[e]).flatMap(n=>n.getApparentType().getProperties().map(i=>i.getName()))},V=(t,e,r)=>{const n=t.getExpression().getType(),i=e==="every"||n.isAny()||n.isUnknown()?["its keys"]:[...new Set(R(n))].filter(s=>e.has(s)).map(s=>`\`${s}\``);if(i.length>0)throw a(t,`${r}: this spread can set ${i.join(", ")}, which codegen writes into wrangler.jsonc and so must read statically. Spread a module-scope \`const\` object literal, or write the keys inline.`)},z=(t,e,r)=>{const n=y(t),i=o.isShorthandPropertyAssignment(t)?v(t.getValueSymbol(),t,n,r):void 0;if(i!==void 0)return[n,i];if(e==="every"||e.has(n))throw a(t,`${r}: \`${n}\` is deploy configuration codegen writes into wrangler.jsonc, so it must be a static literal — inline it, or name a module-scope \`const\` initialized with one.`)},m=(t,e,r,n=new Set)=>{const i=[],s=new Set(n).add(t);for(const l of t.getProperties())if(o.isPropertyAssignment(l))i.push([y(l),L(l.getInitializerOrThrow(),r)]);else if(o.isSpreadAssignment(l))i.push(...K(l,e,r,s));else{const c=z(l,e,r);c!==void 0&&i.push(c)}return i},K=(t,e,r,n)=>{const i=L(t.getExpression(),r);if(!o.isObjectLiteralExpression(i))return V(t,e,r),[];if(n.has(i))throw a(t,`${r}: this spread refers back to an object it is part of, so it has no static value.`);return m(i,e,r,n)},U=(t,e)=>{if(!o.isObjectLiteralExpression(t))throw a(t,`container "${e}": \`buildArgs\` must be a static object literal — it is deploy configuration codegen writes into wrangler.jsonc`);const r={};for(const[n,i]of m(t,"every",`container "${e}" buildArgs`))r[n]=f(i,e,`buildArgs.${n}`);return Object.keys(r).length>0?r:void 0},x=(t,e)=>{if(!o.isObjectLiteralExpression(t))throw a(t,`container "${e}": \`rollout\` must be a static object literal — it is deploy configuration codegen writes into wrangler.jsonc`);const r={};for(const[n,i]of m(t,_,`container "${e}" rollout`))(n==="gracePeriodSeconds"||n==="stepPercentage")&&(r[n]=h(i,e,`rollout.${n}`));return r.gracePeriodSeconds===void 0&&r.stepPercentage===void 0?void 0:r},N=t=>{if(o.isTrueLiteral(t))return!0;if(o.isFalseLiteral(t))return!1},Y=t=>{if(o.isStringLiteral(t)||o.isNoSubstitutionTemplateLiteral(t)||o.isNumericLiteral(t))return t.getLiteralValue()},q=(t,e)=>{if(o.isStringLiteral(t))return t.getLiteralValue();if(o.isObjectLiteralExpression(t)){const r={};for(const n of t.getProperties()){if(!o.isPropertyAssignment(n))throw a(n,`container "${e}": \`instanceType\` must be an object of static number literals`);const i=y(n);if(i!=="diskMb"&&i!=="memoryMib"&&i!=="vcpu")throw a(n,`container "${e}": unknown \`instanceType\` field "${i}" — expected vcpu, memoryMib, or diskMb`);r[i]=h(n.getInitializerOrThrow(),e,`instanceType.${i}`)}return r}throw a(t,`container "${e}": \`instanceType\` must be a static string or { vcpu, memoryMib, diskMb } literal`)},W=(t,e)=>{if(!o.isObjectLiteralExpression(t))throw a(t,`container "${e}": \`images\` must be a static object literal — codegen writes it into wrangler.jsonc`);const r={};for(const[n,i]of m(t,"every",`container "${e}" images`)){const s=w(i,e);if(s.kind==="build")throw a(i,`container "${e}": \`images["${n}"]\` cannot be a Railpack { build } source — use a Dockerfile path or a { registry } reference`);if(s.kind==="registry"&&!O(s.reference))throw a(i,`container "${e}": \`images["${n}"].registry\` must be a digest-pinned (@sha256) reference under registry.cloudflare.com — push other registries' images there first`);r[n]=s}return r},G=(t,e)=>{const r=t.findLast(([i])=>i==="schedulingPolicy");if(r===void 0)return;const n=f(r[1],e,"schedulingPolicy");if(n!=="default"&&n!=="durable_object")throw a(r[1],`container "${e}": unknown \`schedulingPolicy\` "${n}" — use "default" or "durable_object"`);return n==="durable_object"?n:void 0},H=(t,e,r,n)=>{if(r!==void 0&&A.includes(t))throw a(e,`container "${n}": \`${t}\` is not supported with schedulingPolicy "durable_object"`);if(r===void 0&&t==="images")throw a(e,`container "${n}": \`images\` needs schedulingPolicy "durable_object"`)},J=(t,e,r,n)=>{const{base:i,policy:s}=r;switch(t){case"buildArgs":{i.buildArgs=U(e,n);break}case"enableInternet":{i.enableInternet=N(e);break}case"image":{r.scheduled||(s.image=w(e,n));break}case"images":{s.images=W(e,n);break}case"instanceType":{i.instanceType=q(e,n);break}case"maxInstances":{s.maxInstances=h(e,n,"maxInstances");break}case"name":{i.name=f(e,n,"name");break}case"rollout":{s.rollout=x(e,n);break}case"sleepAfter":{i.sleepAfter=Y(e);break}}},X=(t,e,r)=>{const n=t.findLast(([s])=>s==="image")?.[1];if(n===void 0||!(o.isStringLiteral(n)||o.isNoSubstitutionTemplateLiteral(n)))return;const i=n.getLiteralValue();if(!Object.hasOwn(e??{},i)&&!j(i))throw a(n,`container "${r}": \`image\` "${i}" must name an entry of \`images\` or a Cloudflare-managed "cloudflare/…" image`)},Q=(t,e)=>{const r=t.getArguments()[0];if(!r||!o.isObjectLiteralExpression(r))throw a(t,`container "${e}": defineContainer must be passed an inline object literal`);const n=m(r,M,`container "${e}"`),i=G(n,e),s={base:{bindingName:T(e),className:P(e),exportName:e},policy:{},scheduled:i!==void 0};for(const[u,g]of n)H(u,g,i,e),J(u,g,s,e);const{base:l,policy:c}=s;if(i==="durable_object")return X(n,c.images,e),{...l,...c.images===void 0?{}:{images:c.images},schedulingPolicy:i};if(c.image===void 0)throw a(r,`container "${e}": defineContainer requires a static \`image\` property`);return{...l,image:c.image,...c.maxInstances===void 0?{}:{maxInstances:c.maxInstances},...c.rollout===void 0?{}:{rollout:c.rollout}}},Z=t=>{const e=[],r=new Map;for(const n of t.getVariableDeclarations()){if(!n.isExported())continue;const i=n.getInitializer();if(i?.getKind()!==d.CallExpression)continue;const s=i,l=s.getExpression();if(!o.isIdentifier(l)||!D(l))continue;const c=n.getNameNode();if(!o.isIdentifier(c))throw a(c,"defineContainer exports must be plain named exports (no destructuring)");const u=Q(s,c.getText()),g=r.get(u.bindingName);if(g!==void 0)throw a(c,`containers "${g}" and "${u.exportName}" both map to the binding ${u.bindingName} — rename one so each container gets its own Durable Object binding`);r.set(u.bindingName,u.exportName),e.push(u)}return e},oe=(t,e)=>{const r=S(e,C);if(!$(r))return[];const n=t.getSourceFile(r)??t.addSourceFileAtPath(r),i=Z(n);return i.sort((s,l)=>s.exportName.localeCompare(l.exportName)),i};export{C as CONTAINERS_FILENAME,oe as discoverContainers};
@@ -0,0 +1 @@
1
+ import{NODE_CAPABILITIES as f,CLOUDFLARE_CAPABILITIES as h,CELLD_CAPABILITIES as v}from"@lunora/platform";import{readProjectConfigLiterals as m}from"./loadProjectConfig-CKsFNgn3.mjs";const c="cloudflare",b=t=>{const{target:e}=m(t);return e!==void 0&&e.length>0?e:void 0},L=(t,e)=>e??b(t)??c,x=(t,e)=>{if(e!==void 0)return[];const{target:a,unreadable:r}=m(t);return r!==!0||a!==void 0?[]:[{level:"warn",message:`lunora.config declares a \`target\` that codegen cannot read without evaluating it, so the "${c}" surface was emitted. \`runCodegen\` resolves the target synchronously, which means it reads literals only.`,name:"platform_unreadable_target",remediation:`Write \`target\` as a string literal on the config's default export (\`export default { target: "${c}" }\`), or pass \`--target\`.`,target:c}]},u={celld:v,cloudflare:h,node:f},C=()=>Object.keys(u).toSorted((t,e)=>t.localeCompare(e)),w={access:null,ai:"ai",analytics:"analytics",browser:"browser",container:"containers",flags:null,hyperdrive:"hyperdrive",images:"images",kv:"keyValueStore",mail:"mail",notify:null,payments:null,pipelines:"pipelines",r2sql:null,scheduler:"scheduler",storage:"objectStorage",vectors:"vectorStore",workflows:"workflows",x402:null},y=["agents","commitOrderedTables","containerEgressPolicy","containerRuntimeScheduling","cronTriggers","crossShardFanout","durableStreams","globalTables","queues","relationGraph","secrets","vectorStore","workerLoaders","workflowRollback","workflowSchedules"],g={agents:"durable agents (`defineAgent`)",commitOrderedTables:"commit-ordered tables (`.commitOrdered()`)",containerEgressPolicy:"container egress policies (`defineContainer({ allowedHosts | deniedHosts | interceptHttps })`)",containerRuntimeScheduling:'per-instance container images and snapshots (`defineContainer({ schedulingPolicy: "durable_object" })`)',cronTriggers:"declared cron triggers (`cronJobs()`)",crossShardFanout:"cross-shard fan-out queries (a `.shardBy(...)` schema)",durableStreams:"durable streams (`.stream(handler, { durable: true })`)",globalTables:"global tables (`.global()`)",queues:"queues (`defineQueue`)",relationGraph:"relation-graph traversal (`ctx.db.related`, derived from `v.id(...)` columns)",secrets:"the secrets store (`ctx.secrets`)",vectorStore:"vector indexes (`.vectorize()`)",workerLoaders:"sandboxed agent scripts (`jsCodeTool`, on Worker Loaders)",workflowRollback:"workflow step rollback (`defineStep({ rollback })`)",workflowSchedules:"scheduled workflow instances (`defineWorkflow({ schedules })`)"},S=(t,e,a)=>({level:"error",message:`${e.name} does not support ${g[t]}, which this app declares.`,name:"platform_unsupported_feature",remediation:`Remove the declaration, or deploy to a target whose capability matrix marks "${t}" as native or emulated.`,target:a}),T=(t,e,a)=>({level:"error",message:`${e.name}'s capability matrix does not declare a support level for ${g[t]}, which this app declares. Treated as unsupported.`,name:"platform_undeclared_feature",remediation:`Rate "${t}" in the ${e.name} capability matrix as "native", "emulated", or "unsupported" — an undeclared feature fails closed rather than letting the app deploy onto a primitive the host may not provide.`,target:a}),k=t=>{const{diagnostics:e,gatedSignals:a,matrix:r,reported:n,signals:d,target:l}=t;for(const s of y){if(d[s]!==!0)continue;const o=r.features[s]?.level;o!=="unsupported"&&o!==void 0||(a[s]=!1,!n.has(s)&&e.push(o==="unsupported"?S(s,r,l):T(s,r,l)))}},_=(t,e,a,r={})=>{const n={...t},d={...r},l=[],s=new Set;for(const[o,i]of Object.entries(w)){if(i===null||!t[o])continue;const p=e.features[i]?.level;p==="unsupported"?(n[o]=!1,s.add(i),l.push({feature:o,level:"error",message:`${e.name} does not support "${o}" (ctx.${o}).`,name:"platform_unsupported_feature",remediation:`Remove the ctx.${o} usage, or deploy to a target whose capability matrix marks "${i}" as native or emulated.`,target:a})):p===void 0&&(n[o]=!1,s.add(i),l.push({feature:o,level:"error",message:`${e.name}'s capability matrix does not declare a support level for "${o}" (ctx.${o}). Treated as unsupported.`,name:"platform_undeclared_feature",remediation:`Rate "${i}" in the ${e.name} capability matrix as "native", "emulated", or "unsupported" — an undeclared feature fails closed rather than shipping a surface the host may not provide.`,target:a}))}return k({diagnostics:l,gatedSignals:d,matrix:e,reported:s,signals:r,target:a}),{diagnostics:l,signals:d,usage:n}},E=(t,e,a={})=>{const r=u[e];return r===void 0?{diagnostics:[{level:"error",message:`Unknown deploy target "${e}" — no capability matrix is registered for it. Codegen emitted the full Cloudflare surface un-gated.`,name:"platform_unknown_target",remediation:`Use a registered target (${Object.keys(u).join(", ")}) or install the target's @lunora/platform-${e} package.`,target:e}],signals:{...a},usage:{...t}}:_(t,r,e,a)},I=t=>{const e=u[t];if(e===void 0)return;const a=Object.entries(e.features).filter(([,r])=>r.level==="unsupported").map(([r])=>r).toSorted((r,n)=>r.localeCompare(n));return{id:e.id,name:e.name,unsupported:a}};export{w as CAPABILITY_TO_FEATURE,c as DEFAULT_TARGET,_ as gateAgainstMatrix,E as gatePlatformFeatures,C as platformMatrixIds,b as readProjectTarget,x as readTargetDiagnostics,L as resolveCodegenTarget,I as studioPlatformFor};