@lunora/codegen 1.0.0-alpha.401 → 1.0.0-alpha.402

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 (65) hide show
  1. package/dist/index.d.mts +86 -1
  2. package/dist/index.d.ts +86 -1
  3. package/dist/index.mjs +1 -1
  4. package/dist/packem_shared/{AGENTS_FILENAME-Cli3X44r.mjs → AGENTS_FILENAME-BiSJTXnu.mjs} +1 -1
  5. package/dist/packem_shared/{ALL_NOTIFY_CHANNELS-D1SaOfnm.mjs → ALL_NOTIFY_CHANNELS-_xAn-jI3.mjs} +1 -1
  6. package/dist/packem_shared/{CONTAINERS_FILENAME-BX1_ALLp.mjs → CONTAINERS_FILENAME-Bj3hFBa-.mjs} +1 -1
  7. package/dist/packem_shared/DEFAULT_TARGET-BfJ7upI0.mjs +1 -0
  8. package/dist/packem_shared/{FLAGS_FILENAME-DY3yo1u_.mjs → FLAGS_FILENAME-BW7MzS9C.mjs} +1 -1
  9. package/dist/packem_shared/{MUTATORS_FILENAME-Ck_l1lz7.mjs → MUTATORS_FILENAME-tPpN_a00.mjs} +1 -1
  10. package/dist/packem_shared/{OPENRPC_VERSION-CCp_wKFT.mjs → OPENRPC_VERSION-DI_G2H0Q.mjs} +1 -1
  11. package/dist/packem_shared/{QUEUES_FILENAME-C5xotY-M.mjs → QUEUES_FILENAME-Cpp-0QI9.mjs} +1 -1
  12. package/dist/packem_shared/{SCHEMA_SNAPSHOT_FILENAME-BIELlQsc.mjs → SCHEMA_SNAPSHOT_FILENAME-CoCuKo3b.mjs} +11 -11
  13. package/dist/packem_shared/{SHAPES_FILENAME-DCtGHMEm.mjs → SHAPES_FILENAME-cHL4n_Co.mjs} +1 -1
  14. package/dist/packem_shared/{WORKFLOWS_FILENAME-CyV1HQaP.mjs → WORKFLOWS_FILENAME-BXjKKAmj.mjs} +1 -1
  15. package/dist/packem_shared/{attribution-DjweYNgJ.mjs → attribution-C6VQNs-V.mjs} +1 -1
  16. package/dist/packem_shared/{buildOpenApiDocument-B1PEHSSc.mjs → buildOpenApiDocument-aAAsKnsY.mjs} +1 -1
  17. package/dist/packem_shared/{capabilitiesUsedBy-SSrieNZ1.mjs → capabilitiesUsedBy-t-UvdnZl.mjs} +1 -1
  18. package/dist/packem_shared/chain-BvRxehwv.mjs +1 -0
  19. package/dist/packem_shared/{classify-procedure-call-BuF5PNwV.mjs → classify-procedure-call-DwWrpCoX.mjs} +1 -1
  20. package/dist/packem_shared/companionServiceBinding-CnEUhH0Z.mjs +1 -0
  21. package/dist/packem_shared/{context-property-calls-BcUYQ6ph.mjs → context-property-calls-RsCkfFCU.mjs} +1 -1
  22. package/dist/packem_shared/{context-root-2wag3akK.mjs → context-root-CY5kkBER.mjs} +1 -1
  23. package/dist/packem_shared/{createCodegenProject-C8N4Zm8h.mjs → createCodegenProject-BC4GwdnG.mjs} +1 -1
  24. package/dist/packem_shared/{database-calls-B_85LJIk.mjs → database-calls-HP2mxQAR.mjs} +1 -1
  25. package/dist/packem_shared/{discoverAuthApiCalls-f8_WRQEA.mjs → discoverAuthApiCalls-CHytF_NH.mjs} +1 -1
  26. package/dist/packem_shared/{discoverCrons-DTqSuSDh.mjs → discoverCrons-C6Y1u_kI.mjs} +1 -1
  27. package/dist/packem_shared/discoverFunctions-B-051l15.mjs +1 -0
  28. package/dist/packem_shared/{discoverHttpRoutes-2gxHuLgt.mjs → discoverHttpRoutes-BccPlGZb.mjs} +1 -1
  29. package/dist/packem_shared/discoverHyperdriveCalls-DmUuhUoL.mjs +1 -0
  30. package/dist/packem_shared/{discoverInserts-CLh70kVu.mjs → discoverInserts-z7jg8LD3.mjs} +1 -1
  31. package/dist/packem_shared/discoverMaskProcedures-CrkT80jO.mjs +1 -0
  32. package/dist/packem_shared/{discoverMigrations-e5_NQdf-.mjs → discoverMigrations-B6u2Do9_.mjs} +1 -1
  33. package/dist/packem_shared/{discoverNondeterministicCalls-CrXAegUc.mjs → discoverNondeterministicCalls-Dei7EUFX.mjs} +1 -1
  34. package/dist/packem_shared/{discoverQueries-T8b_7ZZ-.mjs → discoverQueries-D4mihML_.mjs} +1 -1
  35. package/dist/packem_shared/discoverR2sqlCalls-Ej8oRuVk.mjs +1 -0
  36. package/dist/packem_shared/{discoverRlsMetadata-CnVvP2Ps.mjs → discoverRlsMetadata-CNn4cdfy.mjs} +1 -1
  37. package/dist/packem_shared/{discoverRlsProcedures-DttY0Jld.mjs → discoverRlsProcedures-CsczAow2.mjs} +1 -1
  38. package/dist/packem_shared/{discoverSandboxUsage-X0SECo-x.mjs → discoverSandboxUsage-EKZOCCPU.mjs} +1 -1
  39. package/dist/packem_shared/discoverSchema-BcyKCBIw.mjs +1 -0
  40. package/dist/packem_shared/{discoverStorageRulesMetadata-t_oMSn0L.mjs → discoverStorageRulesMetadata-yCB6MdrA.mjs} +1 -1
  41. package/dist/packem_shared/{emitApp-BrOgH7YU.mjs → emitApp-C3IUdkkt.mjs} +37 -28
  42. package/dist/packem_shared/{exported-procedure-chains-BaxQ8C-S.mjs → exported-procedure-chains-DiNvW1Wl.mjs} +1 -1
  43. package/dist/packem_shared/{fingerprintSchemaSources-PmhepCVj.mjs → fingerprintSchemaSources-Cpom_87X.mjs} +1 -1
  44. package/dist/packem_shared/{handler-reference-D2EE2q-4.mjs → handler-reference-BqSXtjJ6.mjs} +1 -1
  45. package/dist/packem_shared/index-BPg6e1oa.mjs +1 -0
  46. package/dist/packem_shared/{index-Dd6T5nSP.mjs → index-DgHhQfpm.mjs} +1 -1
  47. package/dist/packem_shared/{ip-reads-WFubgB1G.mjs → ip-reads-Bn9qvrMD.mjs} +1 -1
  48. package/dist/packem_shared/isTestPath-B357_sbh.mjs +1 -0
  49. package/dist/packem_shared/loadProjectConfig-D4_s2UFp.mjs +1 -0
  50. package/dist/packem_shared/{modules-DE0ksIeR.mjs → modules-BgublqiK.mjs} +1 -1
  51. package/dist/packem_shared/project-config-file-DBVmBpin.mjs +1 -0
  52. package/dist/packem_shared/{unwrap-handler-return-BpigsVD6.mjs → unwrap-handler-return-zNStZJ4K.mjs} +1 -1
  53. package/package.json +1 -1
  54. package/dist/packem_shared/DEFAULT_TARGET-C-gcdslJ.mjs +0 -1
  55. package/dist/packem_shared/chain-DWwd9wXd.mjs +0 -1
  56. package/dist/packem_shared/companionServiceBinding-ChINWo8k.mjs +0 -1
  57. package/dist/packem_shared/discoverFunctions-D4GIaVIP.mjs +0 -1
  58. package/dist/packem_shared/discoverHyperdriveCalls-DaJLewG0.mjs +0 -1
  59. package/dist/packem_shared/discoverMaskProcedures-C0VcUGpb.mjs +0 -1
  60. package/dist/packem_shared/discoverR2sqlCalls-CY0xmIWX.mjs +0 -1
  61. package/dist/packem_shared/discoverSchema-DDvMQheA.mjs +0 -1
  62. package/dist/packem_shared/index-fVYBrxkP.mjs +0 -1
  63. package/dist/packem_shared/isTestPath-ClgKgMYM.mjs +0 -1
  64. package/dist/packem_shared/loadProjectConfig-CtcJHHKS.mjs +0 -1
  65. package/dist/packem_shared/static-literal-BwDHHjEJ.mjs +0 -1
package/dist/index.d.mts CHANGED
@@ -3545,6 +3545,16 @@ interface CodegenOptions {
3545
3545
  project?: Project;
3546
3546
  /** Project root containing the `lunora/` directory. */
3547
3547
  projectRoot: string;
3548
+ /**
3549
+ * Wrangler's `assets.binding` of each `assets` block (top level and every
3550
+ * `env.<name>`) that falls back to a single-page app (`not_found_handling:
3551
+ * "single-page-application"`). `@lunora/config` then routes every path to the
3552
+ * Worker first, and the generated worker passes what no route serves to the
3553
+ * first of these bindings the deployment has (`spaAssets`). Produced by
3554
+ * `@lunora/config`, which reads `wrangler.jsonc`; absent or empty for any other
3555
+ * app, whose output is unchanged.
3556
+ */
3557
+ spaAssetsBindings?: ReadonlyArray<string>;
3548
3558
  /**
3549
3559
  * The deploy target codegen tailors the emitted `ctx.*` surface to.
3550
3560
  * Defaults to `"cloudflare"` — whose capability matrix marks every feature
@@ -4499,6 +4509,50 @@ declare const emitAgents: (agents: ReadonlyArray<AgentIR>, options?: {
4499
4509
  lazy?: boolean;
4500
4510
  }) => string;
4501
4511
  declare const GENERATED_HEADER = "// GENERATED by @lunora/codegen — do not edit.\n// Run `lunora codegen` to regenerate.\n\n";
4512
+ /** `Cross-Origin-Opener-Policy` values. `false` omits the header. */
4513
+ type CrossOriginOpenerPolicy = "same-origin" | "same-origin-allow-popups" | "unsafe-none";
4514
+ /** Per-header overrides for the baseline security headers. `false` omits the header. */
4515
+ interface SecurityHeadersOptions {
4516
+ /**
4517
+ * `Cross-Origin-Opener-Policy`. Defaults to `same-origin-allow-popups`: a
4518
+ * cross-origin page that opens yours gets no handle on it, while a popup your
4519
+ * page opens (an OAuth provider, a payment sheet) can still message back
4520
+ * through `window.opener`. `same-origin` severs that too; `false` omits the header.
4521
+ */
4522
+ crossOriginOpenerPolicy?: CrossOriginOpenerPolicy | false;
4523
+ /**
4524
+ * `Content-Security-Policy`. Omitted (`undefined`) applies a restrictive
4525
+ * `default-src 'none'` policy to **non-HTML** responses, and a conservative
4526
+ * hardening policy to **HTML** responses (`base-uri 'none'; object-src
4527
+ * 'none'; frame-ancestors …`) — this does NOT set `default-src`/`script-src`,
4528
+ * so it never blocks a page's own scripts/styles/images/fetches. Pass a string
4529
+ * to apply that exact policy to every response (HTML included); `false` to
4530
+ * never send one. Neither can be combined with {@link frameAncestors}: put the
4531
+ * `frame-ancestors` directive in the string.
4532
+ */
4533
+ csp?: string | false;
4534
+ /**
4535
+ * Origins allowed to embed your HTML pages in a frame, besides your own
4536
+ * (e.g. `["https://partner.example"]`). Sets the HTML policy's
4537
+ * `frame-ancestors 'self' <origins>` and drops `X-Frame-Options`, which
4538
+ * cannot express a list (browsers that understand `frame-ancestors` ignore
4539
+ * it anyway). Cannot be combined with `frameOptions: "DENY"`, a `csp` string,
4540
+ * or `csp: false` (which would leave no header restricting framing).
4541
+ */
4542
+ frameAncestors?: ReadonlyArray<string>;
4543
+ /** `X-Frame-Options` (clickjacking). Defaults to `SAMEORIGIN`. `false` omits it. */
4544
+ frameOptions?: "DENY" | "SAMEORIGIN" | false;
4545
+ /** `Strict-Transport-Security`. The Worker sends it only over HTTPS. `false` omits it. */
4546
+ hsts?: boolean | {
4547
+ includeSubDomains?: boolean;
4548
+ maxAge?: number;
4549
+ preload?: boolean;
4550
+ };
4551
+ /** `Permissions-Policy`. Defaults to a minimal deny list. `false` omits it. */
4552
+ permissionsPolicy?: string | false;
4553
+ /** `Referrer-Policy`. Defaults to `strict-origin-when-cross-origin`. `false` omits it. */
4554
+ referrerPolicy?: string | false;
4555
+ }
4502
4556
  /** Which capability methods the generated `defineApp` builder exposes — one flag per package-backed feature the app actually uses. */
4503
4557
  interface EmitAppOptions {
4504
4558
  /**
@@ -4622,6 +4676,15 @@ interface EmitAppOptions {
4622
4676
  * no `ctx.live`. Absent or `false` leaves the emitted options unchanged.
4623
4677
  */
4624
4678
  liveStreamsWithheld?: boolean;
4679
+ /**
4680
+ * `lunora.config`'s `security.headers`, already validated. Emitted as
4681
+ * `LUNORA_SECURITY_HEADERS` and applied by `buildWorkerOptions` when code
4682
+ * set no `security.headers` of its own; `undefined` emits `undefined`, so the
4683
+ * runtime keeps its defaults.
4684
+ */
4685
+ securityHeaders?: boolean | SecurityHeadersOptions;
4686
+ /** Wrangler's assets bindings for a single-page app → `spaAssets`; absent or empty emits nothing. See `RunCodegenOptions.spaAssetsBindings`. */
4687
+ spaAssetsBindings?: ReadonlyArray<string>;
4625
4688
  /**
4626
4689
  * Every table the schema declares, with its shard mode. Emitted as a literal
4627
4690
  * table map backing `listSchemaTables` and `resolveTableSharding`: export
@@ -4871,6 +4934,16 @@ interface ProjectConfigLiterals {
4871
4934
  unreadable?: boolean;
4872
4935
  };
4873
4936
  remote?: boolean;
4937
+ /**
4938
+ * `security.headers` as its literal value, not yet parsed (see
4939
+ * {@link readProjectSecurityHeaders}). `unreadable` when `security` is declared
4940
+ * but its `headers` is not built from literals; the caller then keeps the
4941
+ * defaults and says so, since an unreadable value must never read as "headers off".
4942
+ */
4943
+ security?: {
4944
+ headers?: unknown;
4945
+ unreadable?: true;
4946
+ };
4874
4947
  /**
4875
4948
  * `services`: binding key → `{ dir, entrypoint? }` (plan 457). `unreadable`
4876
4949
  * when declared but not an object of string literals, kept apart from the
@@ -4917,6 +4990,8 @@ interface LunoraProjectConfig {
4917
4990
  durableObjects?: unknown;
4918
4991
  /** Remote-binding dev preference. */
4919
4992
  remote?: unknown;
4993
+ /** Baseline security headers (`headers`), read through {@link readProjectConfigLiterals}. */
4994
+ security?: unknown;
4920
4995
  /** Deploy target id. */
4921
4996
  target?: unknown;
4922
4997
  }
@@ -4958,6 +5033,16 @@ declare const readProjectConfigLiterals: (projectRoot: string) => ProjectConfigL
4958
5033
  * out loud and treated as off, like `durableObjects.merge`.
4959
5034
  */
4960
5035
  declare const readProjectLazyFunctions: (lunoraDirectory: string) => boolean;
5036
+ /**
5037
+ * `lunora.config`'s `security.headers`, `undefined` when the config sets none,
5038
+ * or `true` (the defaults) when the value cannot be used. Unreadable or invalid,
5039
+ * a whole config codegen cannot read included, is said out loud and pins the
5040
+ * defaults: `undefined` would let `LUNORA_SECURITY_HEADERS` turn every header
5041
+ * off, and an invalid value would fail every request at runtime. The build's
5042
+ * `_headers` writer resolves the same way, so the Worker and the static assets
5043
+ * keep sending the same headers.
5044
+ */
5045
+ declare const readProjectSecurityHeaders: (lunoraDirectory: string) => boolean | SecurityHeadersOptions | undefined;
4961
5046
  /**
4962
5047
  * Content hash of the schema directory's TypeScript sources — everything codegen
4963
5048
  * reads, minus its own `_generated/` output.
@@ -5016,4 +5101,4 @@ declare const secretKindOf: (value: string) => string | undefined;
5016
5101
  /** A redacted preview of a secret value — first 4 chars plus its length, never the full value. */
5017
5102
  declare const redact: (value: string) => string;
5018
5103
  declare const VERSION = "0.0.0";
5019
- export { AGENTS_FILENAME, ALL_NOTIFY_CHANNELS, type AgentIR, type ArchitectureManifest, type AuthApiCallIR, CAPABILITY_PROBES, COMPANION_BINDING, COMPANION_SERVICE_NAME, CONTAINERS_FILENAME, type CapabilityKey, type CapabilityProbe, 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 FcmCredentials, type FieldSnapshot, type FlagsIR, type FunctionIR, GENERATED_HEADER, type HttpRouteIR, type IndexIR, type IndexReference, type IndexSnapshot, type InsertWriteIR, LUNORA_ERROR_CODES, type LintSchemaOptions, type LoadedProjectConfig, type LunoraProjectConfig, MUTATORS_FILENAME, type MaskProcedureIR, type MigrationIR, type MutatorIR, NOTIFY_FILENAME, type NotifyChannels, OPENRPC_VERSION, type OpenApiEmitInput, type OpenRpcEmitInput, 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, SCHEMA_SNAPSHOT_FILENAME, SCHEMA_SNAPSHOT_VERSION, SHAPES_FILENAME, type SandboxUsage, type SchemaDrift, type SchemaDriftDecision, type SchemaIR, type SchemaSnapshot, SchemaSnapshotParseError, type ServiceBindingIR, type ServiceLiteral, type ShapeIR, type SourceCapabilitySignals, type StorageRuleIR, type StorageRulesMetadataIR, type TableIR, type TableSnapshot, type TargetScope, type TopicIR, VERSION, type ValidatorIR, type VectorIndexIR, WORKFLOWS_FILENAME, type WorkflowIR, type WranglerQueueProducerIR, type WranglerVariableIR, buildOpenApiDocument, buildOpenRpcDocument, buildSchemaSnapshot, capabilitiesUsedBy, companionServiceBinding, createCodegenProject, createTargetScope, describeErrorLevelFindings, diagnosticAt, diffSchemaSnapshots, discoverAgents, discoverAuthApiCalls, discoverContainers, discoverCrons, discoverFlags, discoverFunctions, discoverHttpRoutes, discoverHyperdriveCalls, discoverInserts, discoverMaskProcedures, discoverMigrations, discoverMutators, discoverNondeterministicCalls, discoverNotifyCalls, discoverNotifyChannels, discoverNotifyConfig, discoverQueries, discoverQueues, discoverR2sqlCalls, discoverRlsMetadata, discoverRlsProcedures, discoverSandboxUsage, discoverSchema, discoverShapes, discoverStorageRulesMetadata, discoverWorkflows, emitAgents, emitApi, emitApp, emitCollections, emitContainers, emitCrons, emitDataModel, emitDrizzleSchema, emitFunctions, emitInternalApi, emitOpenApi, emitOpenApiModule, emitOpenRpc, emitOpenRpcModule, emitScheduler, emitServer, emitShard, emitVectors, emitWorkflows, emitWranglerCronTriggers, errorAdvisoryNames, errorPlatformDiagnosticNames, evaluateSchemaDrift, findCodegenConfigFile, findProjectConfigFile, findTsconfig, fingerprintSchemaSources, foldCapabilitySignals, formatAdvisories, indexReferencesOf, isD1GlobalTable, isHyperdriveGlobalTable, isTestPath, lintSchema, listLunoraSourceFiles, loadProjectConfig, mayReadCapabilityContext, parseSchemaSnapshot, platformMatrixIds, projectConfigCandidatePaths, readBoundServiceBindings, readDevServiceBindings, readPackageDependencies, readProjectConfigLiterals, readProjectLazyFunctions, readProjectTarget, readServiceBindings, redact, refreshCodegenProject, resolveCodegenTarget, resolveServiceBindings, runCodegen, schemaFromIr, secretKindOf, serializeSchemaSnapshot, sortedUniqueNames, sourceCapabilitySignals, toAdvisorContext, tsconfigFingerprint, validatorIrToJsonSchema };
5104
+ export { AGENTS_FILENAME, ALL_NOTIFY_CHANNELS, type AgentIR, type ArchitectureManifest, type AuthApiCallIR, CAPABILITY_PROBES, COMPANION_BINDING, COMPANION_SERVICE_NAME, CONTAINERS_FILENAME, type CapabilityKey, type CapabilityProbe, 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 FcmCredentials, type FieldSnapshot, type FlagsIR, type FunctionIR, GENERATED_HEADER, type HttpRouteIR, type IndexIR, type IndexReference, type IndexSnapshot, type InsertWriteIR, LUNORA_ERROR_CODES, type LintSchemaOptions, type LoadedProjectConfig, type LunoraProjectConfig, MUTATORS_FILENAME, type MaskProcedureIR, type MigrationIR, type MutatorIR, NOTIFY_FILENAME, type NotifyChannels, OPENRPC_VERSION, type OpenApiEmitInput, type OpenRpcEmitInput, 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, SCHEMA_SNAPSHOT_FILENAME, SCHEMA_SNAPSHOT_VERSION, SHAPES_FILENAME, type SandboxUsage, type SchemaDrift, type SchemaDriftDecision, type SchemaIR, type SchemaSnapshot, SchemaSnapshotParseError, type ServiceBindingIR, type ServiceLiteral, type ShapeIR, type SourceCapabilitySignals, type StorageRuleIR, type StorageRulesMetadataIR, type TableIR, type TableSnapshot, type TargetScope, type TopicIR, VERSION, type ValidatorIR, type VectorIndexIR, WORKFLOWS_FILENAME, type WorkflowIR, type WranglerQueueProducerIR, type WranglerVariableIR, buildOpenApiDocument, buildOpenRpcDocument, buildSchemaSnapshot, capabilitiesUsedBy, companionServiceBinding, createCodegenProject, createTargetScope, describeErrorLevelFindings, diagnosticAt, diffSchemaSnapshots, discoverAgents, discoverAuthApiCalls, discoverContainers, discoverCrons, discoverFlags, discoverFunctions, discoverHttpRoutes, discoverHyperdriveCalls, discoverInserts, discoverMaskProcedures, discoverMigrations, discoverMutators, discoverNondeterministicCalls, discoverNotifyCalls, discoverNotifyChannels, discoverNotifyConfig, discoverQueries, discoverQueues, discoverR2sqlCalls, discoverRlsMetadata, discoverRlsProcedures, discoverSandboxUsage, discoverSchema, discoverShapes, discoverStorageRulesMetadata, discoverWorkflows, emitAgents, emitApi, emitApp, emitCollections, emitContainers, emitCrons, emitDataModel, emitDrizzleSchema, emitFunctions, emitInternalApi, emitOpenApi, emitOpenApiModule, emitOpenRpc, emitOpenRpcModule, emitScheduler, emitServer, emitShard, emitVectors, emitWorkflows, emitWranglerCronTriggers, errorAdvisoryNames, errorPlatformDiagnosticNames, evaluateSchemaDrift, findCodegenConfigFile, findProjectConfigFile, findTsconfig, fingerprintSchemaSources, foldCapabilitySignals, formatAdvisories, indexReferencesOf, isD1GlobalTable, isHyperdriveGlobalTable, isTestPath, lintSchema, listLunoraSourceFiles, loadProjectConfig, mayReadCapabilityContext, parseSchemaSnapshot, platformMatrixIds, projectConfigCandidatePaths, readBoundServiceBindings, readDevServiceBindings, readPackageDependencies, readProjectConfigLiterals, readProjectLazyFunctions, readProjectSecurityHeaders, readProjectTarget, readServiceBindings, redact, refreshCodegenProject, resolveCodegenTarget, resolveServiceBindings, runCodegen, schemaFromIr, secretKindOf, serializeSchemaSnapshot, sortedUniqueNames, sourceCapabilitySignals, toAdvisorContext, tsconfigFingerprint, validatorIrToJsonSchema };
package/dist/index.d.ts CHANGED
@@ -3545,6 +3545,16 @@ interface CodegenOptions {
3545
3545
  project?: Project;
3546
3546
  /** Project root containing the `lunora/` directory. */
3547
3547
  projectRoot: string;
3548
+ /**
3549
+ * Wrangler's `assets.binding` of each `assets` block (top level and every
3550
+ * `env.<name>`) that falls back to a single-page app (`not_found_handling:
3551
+ * "single-page-application"`). `@lunora/config` then routes every path to the
3552
+ * Worker first, and the generated worker passes what no route serves to the
3553
+ * first of these bindings the deployment has (`spaAssets`). Produced by
3554
+ * `@lunora/config`, which reads `wrangler.jsonc`; absent or empty for any other
3555
+ * app, whose output is unchanged.
3556
+ */
3557
+ spaAssetsBindings?: ReadonlyArray<string>;
3548
3558
  /**
3549
3559
  * The deploy target codegen tailors the emitted `ctx.*` surface to.
3550
3560
  * Defaults to `"cloudflare"` — whose capability matrix marks every feature
@@ -4499,6 +4509,50 @@ declare const emitAgents: (agents: ReadonlyArray<AgentIR>, options?: {
4499
4509
  lazy?: boolean;
4500
4510
  }) => string;
4501
4511
  declare const GENERATED_HEADER = "// GENERATED by @lunora/codegen — do not edit.\n// Run `lunora codegen` to regenerate.\n\n";
4512
+ /** `Cross-Origin-Opener-Policy` values. `false` omits the header. */
4513
+ type CrossOriginOpenerPolicy = "same-origin" | "same-origin-allow-popups" | "unsafe-none";
4514
+ /** Per-header overrides for the baseline security headers. `false` omits the header. */
4515
+ interface SecurityHeadersOptions {
4516
+ /**
4517
+ * `Cross-Origin-Opener-Policy`. Defaults to `same-origin-allow-popups`: a
4518
+ * cross-origin page that opens yours gets no handle on it, while a popup your
4519
+ * page opens (an OAuth provider, a payment sheet) can still message back
4520
+ * through `window.opener`. `same-origin` severs that too; `false` omits the header.
4521
+ */
4522
+ crossOriginOpenerPolicy?: CrossOriginOpenerPolicy | false;
4523
+ /**
4524
+ * `Content-Security-Policy`. Omitted (`undefined`) applies a restrictive
4525
+ * `default-src 'none'` policy to **non-HTML** responses, and a conservative
4526
+ * hardening policy to **HTML** responses (`base-uri 'none'; object-src
4527
+ * 'none'; frame-ancestors …`) — this does NOT set `default-src`/`script-src`,
4528
+ * so it never blocks a page's own scripts/styles/images/fetches. Pass a string
4529
+ * to apply that exact policy to every response (HTML included); `false` to
4530
+ * never send one. Neither can be combined with {@link frameAncestors}: put the
4531
+ * `frame-ancestors` directive in the string.
4532
+ */
4533
+ csp?: string | false;
4534
+ /**
4535
+ * Origins allowed to embed your HTML pages in a frame, besides your own
4536
+ * (e.g. `["https://partner.example"]`). Sets the HTML policy's
4537
+ * `frame-ancestors 'self' <origins>` and drops `X-Frame-Options`, which
4538
+ * cannot express a list (browsers that understand `frame-ancestors` ignore
4539
+ * it anyway). Cannot be combined with `frameOptions: "DENY"`, a `csp` string,
4540
+ * or `csp: false` (which would leave no header restricting framing).
4541
+ */
4542
+ frameAncestors?: ReadonlyArray<string>;
4543
+ /** `X-Frame-Options` (clickjacking). Defaults to `SAMEORIGIN`. `false` omits it. */
4544
+ frameOptions?: "DENY" | "SAMEORIGIN" | false;
4545
+ /** `Strict-Transport-Security`. The Worker sends it only over HTTPS. `false` omits it. */
4546
+ hsts?: boolean | {
4547
+ includeSubDomains?: boolean;
4548
+ maxAge?: number;
4549
+ preload?: boolean;
4550
+ };
4551
+ /** `Permissions-Policy`. Defaults to a minimal deny list. `false` omits it. */
4552
+ permissionsPolicy?: string | false;
4553
+ /** `Referrer-Policy`. Defaults to `strict-origin-when-cross-origin`. `false` omits it. */
4554
+ referrerPolicy?: string | false;
4555
+ }
4502
4556
  /** Which capability methods the generated `defineApp` builder exposes — one flag per package-backed feature the app actually uses. */
4503
4557
  interface EmitAppOptions {
4504
4558
  /**
@@ -4622,6 +4676,15 @@ interface EmitAppOptions {
4622
4676
  * no `ctx.live`. Absent or `false` leaves the emitted options unchanged.
4623
4677
  */
4624
4678
  liveStreamsWithheld?: boolean;
4679
+ /**
4680
+ * `lunora.config`'s `security.headers`, already validated. Emitted as
4681
+ * `LUNORA_SECURITY_HEADERS` and applied by `buildWorkerOptions` when code
4682
+ * set no `security.headers` of its own; `undefined` emits `undefined`, so the
4683
+ * runtime keeps its defaults.
4684
+ */
4685
+ securityHeaders?: boolean | SecurityHeadersOptions;
4686
+ /** Wrangler's assets bindings for a single-page app → `spaAssets`; absent or empty emits nothing. See `RunCodegenOptions.spaAssetsBindings`. */
4687
+ spaAssetsBindings?: ReadonlyArray<string>;
4625
4688
  /**
4626
4689
  * Every table the schema declares, with its shard mode. Emitted as a literal
4627
4690
  * table map backing `listSchemaTables` and `resolveTableSharding`: export
@@ -4871,6 +4934,16 @@ interface ProjectConfigLiterals {
4871
4934
  unreadable?: boolean;
4872
4935
  };
4873
4936
  remote?: boolean;
4937
+ /**
4938
+ * `security.headers` as its literal value, not yet parsed (see
4939
+ * {@link readProjectSecurityHeaders}). `unreadable` when `security` is declared
4940
+ * but its `headers` is not built from literals; the caller then keeps the
4941
+ * defaults and says so, since an unreadable value must never read as "headers off".
4942
+ */
4943
+ security?: {
4944
+ headers?: unknown;
4945
+ unreadable?: true;
4946
+ };
4874
4947
  /**
4875
4948
  * `services`: binding key → `{ dir, entrypoint? }` (plan 457). `unreadable`
4876
4949
  * when declared but not an object of string literals, kept apart from the
@@ -4917,6 +4990,8 @@ interface LunoraProjectConfig {
4917
4990
  durableObjects?: unknown;
4918
4991
  /** Remote-binding dev preference. */
4919
4992
  remote?: unknown;
4993
+ /** Baseline security headers (`headers`), read through {@link readProjectConfigLiterals}. */
4994
+ security?: unknown;
4920
4995
  /** Deploy target id. */
4921
4996
  target?: unknown;
4922
4997
  }
@@ -4958,6 +5033,16 @@ declare const readProjectConfigLiterals: (projectRoot: string) => ProjectConfigL
4958
5033
  * out loud and treated as off, like `durableObjects.merge`.
4959
5034
  */
4960
5035
  declare const readProjectLazyFunctions: (lunoraDirectory: string) => boolean;
5036
+ /**
5037
+ * `lunora.config`'s `security.headers`, `undefined` when the config sets none,
5038
+ * or `true` (the defaults) when the value cannot be used. Unreadable or invalid,
5039
+ * a whole config codegen cannot read included, is said out loud and pins the
5040
+ * defaults: `undefined` would let `LUNORA_SECURITY_HEADERS` turn every header
5041
+ * off, and an invalid value would fail every request at runtime. The build's
5042
+ * `_headers` writer resolves the same way, so the Worker and the static assets
5043
+ * keep sending the same headers.
5044
+ */
5045
+ declare const readProjectSecurityHeaders: (lunoraDirectory: string) => boolean | SecurityHeadersOptions | undefined;
4961
5046
  /**
4962
5047
  * Content hash of the schema directory's TypeScript sources — everything codegen
4963
5048
  * reads, minus its own `_generated/` output.
@@ -5016,4 +5101,4 @@ declare const secretKindOf: (value: string) => string | undefined;
5016
5101
  /** A redacted preview of a secret value — first 4 chars plus its length, never the full value. */
5017
5102
  declare const redact: (value: string) => string;
5018
5103
  declare const VERSION = "0.0.0";
5019
- export { AGENTS_FILENAME, ALL_NOTIFY_CHANNELS, type AgentIR, type ArchitectureManifest, type AuthApiCallIR, CAPABILITY_PROBES, COMPANION_BINDING, COMPANION_SERVICE_NAME, CONTAINERS_FILENAME, type CapabilityKey, type CapabilityProbe, 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 FcmCredentials, type FieldSnapshot, type FlagsIR, type FunctionIR, GENERATED_HEADER, type HttpRouteIR, type IndexIR, type IndexReference, type IndexSnapshot, type InsertWriteIR, LUNORA_ERROR_CODES, type LintSchemaOptions, type LoadedProjectConfig, type LunoraProjectConfig, MUTATORS_FILENAME, type MaskProcedureIR, type MigrationIR, type MutatorIR, NOTIFY_FILENAME, type NotifyChannels, OPENRPC_VERSION, type OpenApiEmitInput, type OpenRpcEmitInput, 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, SCHEMA_SNAPSHOT_FILENAME, SCHEMA_SNAPSHOT_VERSION, SHAPES_FILENAME, type SandboxUsage, type SchemaDrift, type SchemaDriftDecision, type SchemaIR, type SchemaSnapshot, SchemaSnapshotParseError, type ServiceBindingIR, type ServiceLiteral, type ShapeIR, type SourceCapabilitySignals, type StorageRuleIR, type StorageRulesMetadataIR, type TableIR, type TableSnapshot, type TargetScope, type TopicIR, VERSION, type ValidatorIR, type VectorIndexIR, WORKFLOWS_FILENAME, type WorkflowIR, type WranglerQueueProducerIR, type WranglerVariableIR, buildOpenApiDocument, buildOpenRpcDocument, buildSchemaSnapshot, capabilitiesUsedBy, companionServiceBinding, createCodegenProject, createTargetScope, describeErrorLevelFindings, diagnosticAt, diffSchemaSnapshots, discoverAgents, discoverAuthApiCalls, discoverContainers, discoverCrons, discoverFlags, discoverFunctions, discoverHttpRoutes, discoverHyperdriveCalls, discoverInserts, discoverMaskProcedures, discoverMigrations, discoverMutators, discoverNondeterministicCalls, discoverNotifyCalls, discoverNotifyChannels, discoverNotifyConfig, discoverQueries, discoverQueues, discoverR2sqlCalls, discoverRlsMetadata, discoverRlsProcedures, discoverSandboxUsage, discoverSchema, discoverShapes, discoverStorageRulesMetadata, discoverWorkflows, emitAgents, emitApi, emitApp, emitCollections, emitContainers, emitCrons, emitDataModel, emitDrizzleSchema, emitFunctions, emitInternalApi, emitOpenApi, emitOpenApiModule, emitOpenRpc, emitOpenRpcModule, emitScheduler, emitServer, emitShard, emitVectors, emitWorkflows, emitWranglerCronTriggers, errorAdvisoryNames, errorPlatformDiagnosticNames, evaluateSchemaDrift, findCodegenConfigFile, findProjectConfigFile, findTsconfig, fingerprintSchemaSources, foldCapabilitySignals, formatAdvisories, indexReferencesOf, isD1GlobalTable, isHyperdriveGlobalTable, isTestPath, lintSchema, listLunoraSourceFiles, loadProjectConfig, mayReadCapabilityContext, parseSchemaSnapshot, platformMatrixIds, projectConfigCandidatePaths, readBoundServiceBindings, readDevServiceBindings, readPackageDependencies, readProjectConfigLiterals, readProjectLazyFunctions, readProjectTarget, readServiceBindings, redact, refreshCodegenProject, resolveCodegenTarget, resolveServiceBindings, runCodegen, schemaFromIr, secretKindOf, serializeSchemaSnapshot, sortedUniqueNames, sourceCapabilitySignals, toAdvisorContext, tsconfigFingerprint, validatorIrToJsonSchema };
5104
+ export { AGENTS_FILENAME, ALL_NOTIFY_CHANNELS, type AgentIR, type ArchitectureManifest, type AuthApiCallIR, CAPABILITY_PROBES, COMPANION_BINDING, COMPANION_SERVICE_NAME, CONTAINERS_FILENAME, type CapabilityKey, type CapabilityProbe, 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 FcmCredentials, type FieldSnapshot, type FlagsIR, type FunctionIR, GENERATED_HEADER, type HttpRouteIR, type IndexIR, type IndexReference, type IndexSnapshot, type InsertWriteIR, LUNORA_ERROR_CODES, type LintSchemaOptions, type LoadedProjectConfig, type LunoraProjectConfig, MUTATORS_FILENAME, type MaskProcedureIR, type MigrationIR, type MutatorIR, NOTIFY_FILENAME, type NotifyChannels, OPENRPC_VERSION, type OpenApiEmitInput, type OpenRpcEmitInput, 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, SCHEMA_SNAPSHOT_FILENAME, SCHEMA_SNAPSHOT_VERSION, SHAPES_FILENAME, type SandboxUsage, type SchemaDrift, type SchemaDriftDecision, type SchemaIR, type SchemaSnapshot, SchemaSnapshotParseError, type ServiceBindingIR, type ServiceLiteral, type ShapeIR, type SourceCapabilitySignals, type StorageRuleIR, type StorageRulesMetadataIR, type TableIR, type TableSnapshot, type TargetScope, type TopicIR, VERSION, type ValidatorIR, type VectorIndexIR, WORKFLOWS_FILENAME, type WorkflowIR, type WranglerQueueProducerIR, type WranglerVariableIR, buildOpenApiDocument, buildOpenRpcDocument, buildSchemaSnapshot, capabilitiesUsedBy, companionServiceBinding, createCodegenProject, createTargetScope, describeErrorLevelFindings, diagnosticAt, diffSchemaSnapshots, discoverAgents, discoverAuthApiCalls, discoverContainers, discoverCrons, discoverFlags, discoverFunctions, discoverHttpRoutes, discoverHyperdriveCalls, discoverInserts, discoverMaskProcedures, discoverMigrations, discoverMutators, discoverNondeterministicCalls, discoverNotifyCalls, discoverNotifyChannels, discoverNotifyConfig, discoverQueries, discoverQueues, discoverR2sqlCalls, discoverRlsMetadata, discoverRlsProcedures, discoverSandboxUsage, discoverSchema, discoverShapes, discoverStorageRulesMetadata, discoverWorkflows, emitAgents, emitApi, emitApp, emitCollections, emitContainers, emitCrons, emitDataModel, emitDrizzleSchema, emitFunctions, emitInternalApi, emitOpenApi, emitOpenApiModule, emitOpenRpc, emitOpenRpcModule, emitScheduler, emitServer, emitShard, emitVectors, emitWorkflows, emitWranglerCronTriggers, errorAdvisoryNames, errorPlatformDiagnosticNames, evaluateSchemaDrift, findCodegenConfigFile, findProjectConfigFile, findTsconfig, fingerprintSchemaSources, foldCapabilitySignals, formatAdvisories, indexReferencesOf, isD1GlobalTable, isHyperdriveGlobalTable, isTestPath, lintSchema, listLunoraSourceFiles, loadProjectConfig, mayReadCapabilityContext, parseSchemaSnapshot, platformMatrixIds, projectConfigCandidatePaths, readBoundServiceBindings, readDevServiceBindings, readPackageDependencies, readProjectConfigLiterals, readProjectLazyFunctions, readProjectSecurityHeaders, readProjectTarget, readServiceBindings, redact, refreshCodegenProject, resolveCodegenTarget, resolveServiceBindings, runCodegen, schemaFromIr, secretKindOf, serializeSchemaSnapshot, sortedUniqueNames, sourceCapabilitySignals, toAdvisorContext, tsconfigFingerprint, validatorIrToJsonSchema };
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{SCHEMA_SNAPSHOT_VERSION as t,diffSchemaSnapshots as i,serializeSchemaSnapshot as a}from"./packem_shared/SCHEMA_SNAPSHOT_VERSION-DTLoSaNn.mjs";import{formatAdvisories as d,lintSchema as f,toAdvisorContext as m}from"./packem_shared/formatAdvisories-BCVASH7N.mjs";import{describeErrorLevelFindings as p,errorAdvisoryNames as c,errorPlatformDiagnosticNames as l,sortedUniqueNames as S}from"./packem_shared/describeErrorLevelFindings-vzaGS9KL.mjs";import{CAPABILITY_PROBES as E}from"./packem_shared/CAPABILITY_PROBES-BuNEmlCO.mjs";import{COMPANION_BINDING as u,COMPANION_SERVICE_NAME as v}from"./packem_shared/COMPANION_BINDING-Da_v9XpC.mjs";import{CodegenDiagnosticError as g,diagnosticAt as C}from"./packem_shared/CodegenDiagnosticError-BUXlG3P-.mjs";import{AGENTS_FILENAME as I,discoverAgents as R}from"./packem_shared/AGENTS_FILENAME-Cli3X44r.mjs";import{isTestPath as L,listLunoraSourceFiles as T}from"./packem_shared/isTestPath-ClgKgMYM.mjs";import{default as h}from"./packem_shared/discoverAuthApiCalls-f8_WRQEA.mjs";import{CONTAINERS_FILENAME as P,discoverContainers as D}from"./packem_shared/CONTAINERS_FILENAME-BX1_ALLp.mjs";import{default as b}from"./packem_shared/discoverCrons-DTqSuSDh.mjs";import{capabilitiesUsedBy as U,createTargetScope as B,foldCapabilitySignals as H,mayReadCapabilityContext as j,sourceCapabilitySignals as k}from"./packem_shared/capabilitiesUsedBy-SSrieNZ1.mjs";import{FLAGS_FILENAME as W,discoverFlags as z}from"./packem_shared/FLAGS_FILENAME-DY3yo1u_.mjs";import{d as Q}from"./packem_shared/index-fVYBrxkP.mjs";import{default as q}from"./packem_shared/discoverHttpRoutes-2gxHuLgt.mjs";import{default as J}from"./packem_shared/discoverHyperdriveCalls-DaJLewG0.mjs";import{default as Z}from"./packem_shared/discoverInserts-CLh70kVu.mjs";import{d as ee}from"./packem_shared/index-Dd6T5nSP.mjs";import{default as oe}from"./packem_shared/discoverMigrations-e5_NQdf-.mjs";import{MUTATORS_FILENAME as ie,discoverMutators as ae}from"./packem_shared/MUTATORS_FILENAME-Ck_l1lz7.mjs";import{default as de}from"./packem_shared/discoverNondeterministicCalls-CrXAegUc.mjs";import{ALL_NOTIFY_CHANNELS as me,NOTIFY_FILENAME as ne,discoverNotifyCalls as pe,discoverNotifyChannels as ce,discoverNotifyConfig as le}from"./packem_shared/ALL_NOTIFY_CHANNELS-D1SaOfnm.mjs";import{default as xe}from"./packem_shared/readPackageDependencies-RHhGiz0k.mjs";import{default as Ae}from"./packem_shared/discoverQueries-T8b_7ZZ-.mjs";import{QUEUES_FILENAME as ve,discoverQueues as Ne}from"./packem_shared/QUEUES_FILENAME-C5xotY-M.mjs";import{default as Ce}from"./packem_shared/discoverR2sqlCalls-CY0xmIWX.mjs";import{default as Ie}from"./packem_shared/discoverRlsProcedures-DttY0Jld.mjs";import{default as _e}from"./packem_shared/discoverRlsMetadata-CnVvP2Ps.mjs";import{discoverSandboxUsage as Te}from"./packem_shared/discoverSandboxUsage-X0SECo-x.mjs";import{default as he}from"./packem_shared/discoverSchema-DDvMQheA.mjs";import{companionServiceBinding as Pe,readBoundServiceBindings as De,readDevServiceBindings as ye,readServiceBindings as be,resolveServiceBindings as Ge}from"./packem_shared/companionServiceBinding-ChINWo8k.mjs";import{SHAPES_FILENAME as Be,discoverShapes as He}from"./packem_shared/SHAPES_FILENAME-DCtGHMEm.mjs";import{default as ke}from"./packem_shared/discoverStorageRulesMetadata-t_oMSn0L.mjs";import{WORKFLOWS_FILENAME as We,discoverWorkflows as ze}from"./packem_shared/WORKFLOWS_FILENAME-CyV1HQaP.mjs";import{emitApp as Qe}from"./packem_shared/emitApp-BrOgH7YU.mjs";import{isD1GlobalTable as qe,isHyperdriveGlobalTable as we}from"./packem_shared/isD1GlobalTable-udvHAAzD.mjs";import{buildOpenApiDocument as Xe,emitOpenApi as Ze,emitOpenApiModule as $e}from"./packem_shared/buildOpenApiDocument-B1PEHSSc.mjs";import{OPENRPC_VERSION as rr,buildOpenRpcDocument as or,emitOpenRpc as tr,emitOpenRpcModule as ir}from"./packem_shared/OPENRPC_VERSION-CCp_wKFT.mjs";import{DEFAULT_TARGET as sr,platformMatrixIds as dr,readProjectTarget as fr,resolveCodegenTarget as mr}from"./packem_shared/DEFAULT_TARGET-C-gcdslJ.mjs";import{loadProjectConfig as pr,readProjectConfigLiterals as cr,readProjectLazyFunctions as lr}from"./packem_shared/loadProjectConfig-CtcJHHKS.mjs";import{PROJECT_CONFIG_FILENAMES as xr,findCodegenConfigFile as Er,findProjectConfigFile as Ar,projectConfigCandidatePaths as ur}from"./packem_shared/PROJECT_CONFIG_FILENAMES-CLfsyvjA.mjs";import{SCHEMA_SNAPSHOT_FILENAME as Nr,runCodegen as gr}from"./packem_shared/SCHEMA_SNAPSHOT_FILENAME-BIELlQsc.mjs";import{SchemaSnapshotParseError as Or,buildSchemaSnapshot as Ir,evaluateSchemaDrift as Rr,indexReferencesOf as _r,parseSchemaSnapshot as Lr}from"./packem_shared/SchemaSnapshotParseError-DnAuFdpl.mjs";import{default as Mr}from"./packem_shared/fingerprintSchemaSources-PmhepCVj.mjs";import{schemaFromIr as Fr}from"./packem_shared/schemaFromIr-CByOxuZb.mjs";import{LUNORA_ERROR_CODES as Dr,validatorIrToJsonSchema as yr}from"./packem_shared/LUNORA_ERROR_CODES-D7AVT7qF.mjs";import{SDK_LANGUAGES as Gr,SDK_TARGETS as Ur,generateSdk as Br}from"./sdk/index.mjs";import{redact as jr,secretKindOf as kr}from"./packem_shared/redact-Cy14LEnc.mjs";import{default as Wr}from"./packem_shared/emitDrizzleSchema-BzOChEYW.mjs";import{e as Kr}from"./packem_shared/server-CRFaUMKQ.mjs";import{e as Yr}from"./packem_shared/shard-Csztu3jG.mjs";import{G as wr}from"./packem_shared/shared-Cn7dMQ_u.mjs";import{MESSAGE_SOLUTIONS as Xr,findSolutionByMessage as Zr}from"@lunora/errors";import{createCodegenProject as eo,findTsconfig as ro,refreshCodegenProject as oo,tsconfigFingerprint as to}from"./packem_shared/createCodegenProject-C8N4Zm8h.mjs";import{t as ao,u as so,v as fo}from"./packem_shared/shard-runtime-D0xuE0pX.mjs";import{emitApi as no,emitCollections as po,emitInternalApi as co}from"./packem_shared/emitApi-lwadq5G7.mjs";import{emitCrons as So,emitScheduler as xo,emitVectors as Eo,emitWranglerCronTriggers as Ao}from"./packem_shared/emitCrons-CCRKs482.mjs";import{emitDataModel as vo}from"./packem_shared/emitDataModel-BvCZS4Yq.mjs";import{emitFunctions as go}from"./packem_shared/emitFunctions-ppMX7E3X.mjs";import{isTypedSchema as Oo}from"./packem_shared/isTypedSchema-CDv3pJB6.mjs";const e="0.0.0";export{I as AGENTS_FILENAME,me as ALL_NOTIFY_CHANNELS,E as CAPABILITY_PROBES,u as COMPANION_BINDING,v as COMPANION_SERVICE_NAME,P as CONTAINERS_FILENAME,g as CodegenDiagnosticError,sr as DEFAULT_TARGET,W as FLAGS_FILENAME,wr as GENERATED_HEADER,Dr as LUNORA_ERROR_CODES,Xr as LUNORA_SOLUTION_RULES,ie as MUTATORS_FILENAME,ne as NOTIFY_FILENAME,rr as OPENRPC_VERSION,xr as PROJECT_CONFIG_FILENAMES,ve as QUEUES_FILENAME,Nr as SCHEMA_SNAPSHOT_FILENAME,t as SCHEMA_SNAPSHOT_VERSION,Gr as SDK_LANGUAGES,Ur as SDK_TARGETS,Be as SHAPES_FILENAME,Or as SchemaSnapshotParseError,e as VERSION,We as WORKFLOWS_FILENAME,Xe as buildOpenApiDocument,or as buildOpenRpcDocument,Ir as buildSchemaSnapshot,U as capabilitiesUsedBy,Pe as companionServiceBinding,eo as createCodegenProject,B as createTargetScope,p as describeErrorLevelFindings,C as diagnosticAt,i as diffSchemaSnapshots,R as discoverAgents,h as discoverAuthApiCalls,D as discoverContainers,b as discoverCrons,z as discoverFlags,Q as discoverFunctions,q as discoverHttpRoutes,J as discoverHyperdriveCalls,Z as discoverInserts,ee as discoverMaskProcedures,oe as discoverMigrations,ae as discoverMutators,de as discoverNondeterministicCalls,pe as discoverNotifyCalls,ce as discoverNotifyChannels,le as discoverNotifyConfig,Ae as discoverQueries,Ne as discoverQueues,Ce as discoverR2sqlCalls,_e as discoverRlsMetadata,Ie as discoverRlsProcedures,Te as discoverSandboxUsage,he as discoverSchema,He as discoverShapes,ke as discoverStorageRulesMetadata,ze as discoverWorkflows,ao as emitAgents,no as emitApi,Qe as emitApp,po as emitCollections,so as emitContainers,So as emitCrons,vo as emitDataModel,Wr as emitDrizzleSchema,go as emitFunctions,co as emitInternalApi,Ze as emitOpenApi,$e as emitOpenApiModule,tr as emitOpenRpc,ir as emitOpenRpcModule,xo as emitScheduler,Kr as emitServer,Yr as emitShard,Eo as emitVectors,fo as emitWorkflows,Ao as emitWranglerCronTriggers,c as errorAdvisoryNames,l as errorPlatformDiagnosticNames,Rr as evaluateSchemaDrift,Er as findCodegenConfigFile,Zr as findLunoraSolution,Ar as findProjectConfigFile,ro as findTsconfig,Mr as fingerprintSchemaSources,H as foldCapabilitySignals,d as formatAdvisories,Br as generateSdk,_r as indexReferencesOf,qe as isD1GlobalTable,we as isHyperdriveGlobalTable,L as isTestPath,Oo as isTypedSchema,f as lintSchema,T as listLunoraSourceFiles,pr as loadProjectConfig,j as mayReadCapabilityContext,Lr as parseSchemaSnapshot,dr as platformMatrixIds,ur as projectConfigCandidatePaths,De as readBoundServiceBindings,ye as readDevServiceBindings,xe as readPackageDependencies,cr as readProjectConfigLiterals,lr as readProjectLazyFunctions,fr as readProjectTarget,be as readServiceBindings,jr as redact,oo as refreshCodegenProject,mr as resolveCodegenTarget,Ge as resolveServiceBindings,gr as runCodegen,Fr as schemaFromIr,kr as secretKindOf,a as serializeSchemaSnapshot,S as sortedUniqueNames,k as sourceCapabilitySignals,m as toAdvisorContext,to as tsconfigFingerprint,yr as validatorIrToJsonSchema};
1
+ import{SCHEMA_SNAPSHOT_VERSION as t,diffSchemaSnapshots as i,serializeSchemaSnapshot as a}from"./packem_shared/SCHEMA_SNAPSHOT_VERSION-DTLoSaNn.mjs";import{formatAdvisories as d,lintSchema as f,toAdvisorContext as m}from"./packem_shared/formatAdvisories-BCVASH7N.mjs";import{describeErrorLevelFindings as p,errorAdvisoryNames as c,errorPlatformDiagnosticNames as l,sortedUniqueNames as S}from"./packem_shared/describeErrorLevelFindings-vzaGS9KL.mjs";import{CAPABILITY_PROBES as E}from"./packem_shared/CAPABILITY_PROBES-BuNEmlCO.mjs";import{COMPANION_BINDING as u,COMPANION_SERVICE_NAME as v}from"./packem_shared/COMPANION_BINDING-Da_v9XpC.mjs";import{CodegenDiagnosticError as g,diagnosticAt as C}from"./packem_shared/CodegenDiagnosticError-BUXlG3P-.mjs";import{AGENTS_FILENAME as I,discoverAgents as R}from"./packem_shared/AGENTS_FILENAME-BiSJTXnu.mjs";import{isTestPath as L,listLunoraSourceFiles as T}from"./packem_shared/isTestPath-B357_sbh.mjs";import{default as h}from"./packem_shared/discoverAuthApiCalls-CHytF_NH.mjs";import{CONTAINERS_FILENAME as P,discoverContainers as D}from"./packem_shared/CONTAINERS_FILENAME-Bj3hFBa-.mjs";import{default as b}from"./packem_shared/discoverCrons-C6Y1u_kI.mjs";import{capabilitiesUsedBy as U,createTargetScope as B,foldCapabilitySignals as H,mayReadCapabilityContext as j,sourceCapabilitySignals as k}from"./packem_shared/capabilitiesUsedBy-t-UvdnZl.mjs";import{FLAGS_FILENAME as W,discoverFlags as z}from"./packem_shared/FLAGS_FILENAME-BW7MzS9C.mjs";import{d as Q}from"./packem_shared/index-BPg6e1oa.mjs";import{default as q}from"./packem_shared/discoverHttpRoutes-BccPlGZb.mjs";import{default as J}from"./packem_shared/discoverHyperdriveCalls-DmUuhUoL.mjs";import{default as Z}from"./packem_shared/discoverInserts-z7jg8LD3.mjs";import{d as ee}from"./packem_shared/index-DgHhQfpm.mjs";import{default as oe}from"./packem_shared/discoverMigrations-B6u2Do9_.mjs";import{MUTATORS_FILENAME as ie,discoverMutators as ae}from"./packem_shared/MUTATORS_FILENAME-tPpN_a00.mjs";import{default as de}from"./packem_shared/discoverNondeterministicCalls-Dei7EUFX.mjs";import{ALL_NOTIFY_CHANNELS as me,NOTIFY_FILENAME as ne,discoverNotifyCalls as pe,discoverNotifyChannels as ce,discoverNotifyConfig as le}from"./packem_shared/ALL_NOTIFY_CHANNELS-_xAn-jI3.mjs";import{default as xe}from"./packem_shared/readPackageDependencies-RHhGiz0k.mjs";import{default as Ae}from"./packem_shared/discoverQueries-D4mihML_.mjs";import{QUEUES_FILENAME as ve,discoverQueues as Ne}from"./packem_shared/QUEUES_FILENAME-Cpp-0QI9.mjs";import{default as Ce}from"./packem_shared/discoverR2sqlCalls-Ej8oRuVk.mjs";import{default as Ie}from"./packem_shared/discoverRlsProcedures-CsczAow2.mjs";import{default as _e}from"./packem_shared/discoverRlsMetadata-CNn4cdfy.mjs";import{discoverSandboxUsage as Te}from"./packem_shared/discoverSandboxUsage-EKZOCCPU.mjs";import{default as he}from"./packem_shared/discoverSchema-BcyKCBIw.mjs";import{companionServiceBinding as Pe,readBoundServiceBindings as De,readDevServiceBindings as ye,readServiceBindings as be,resolveServiceBindings as Ge}from"./packem_shared/companionServiceBinding-CnEUhH0Z.mjs";import{SHAPES_FILENAME as Be,discoverShapes as He}from"./packem_shared/SHAPES_FILENAME-cHL4n_Co.mjs";import{default as ke}from"./packem_shared/discoverStorageRulesMetadata-yCB6MdrA.mjs";import{WORKFLOWS_FILENAME as We,discoverWorkflows as ze}from"./packem_shared/WORKFLOWS_FILENAME-BXjKKAmj.mjs";import{emitApp as Qe}from"./packem_shared/emitApp-C3IUdkkt.mjs";import{isD1GlobalTable as qe,isHyperdriveGlobalTable as we}from"./packem_shared/isD1GlobalTable-udvHAAzD.mjs";import{buildOpenApiDocument as Xe,emitOpenApi as Ze,emitOpenApiModule as $e}from"./packem_shared/buildOpenApiDocument-aAAsKnsY.mjs";import{OPENRPC_VERSION as rr,buildOpenRpcDocument as or,emitOpenRpc as tr,emitOpenRpcModule as ir}from"./packem_shared/OPENRPC_VERSION-DI_G2H0Q.mjs";import{DEFAULT_TARGET as sr,platformMatrixIds as dr,readProjectTarget as fr,resolveCodegenTarget as mr}from"./packem_shared/DEFAULT_TARGET-BfJ7upI0.mjs";import{b as pr,r as cr,c as lr,d as Sr}from"./packem_shared/project-config-file-DBVmBpin.mjs";import{PROJECT_CONFIG_FILENAMES as Er,findCodegenConfigFile as Ar,findProjectConfigFile as ur,projectConfigCandidatePaths as vr}from"./packem_shared/PROJECT_CONFIG_FILENAMES-CLfsyvjA.mjs";import{SCHEMA_SNAPSHOT_FILENAME as gr,runCodegen as Cr}from"./packem_shared/SCHEMA_SNAPSHOT_FILENAME-CoCuKo3b.mjs";import{SchemaSnapshotParseError as Ir,buildSchemaSnapshot as Rr,evaluateSchemaDrift as _r,indexReferencesOf as Lr,parseSchemaSnapshot as Tr}from"./packem_shared/SchemaSnapshotParseError-DnAuFdpl.mjs";import{default as hr}from"./packem_shared/fingerprintSchemaSources-Cpom_87X.mjs";import{schemaFromIr as Pr}from"./packem_shared/schemaFromIr-CByOxuZb.mjs";import{LUNORA_ERROR_CODES as yr,validatorIrToJsonSchema as br}from"./packem_shared/LUNORA_ERROR_CODES-D7AVT7qF.mjs";import{SDK_LANGUAGES as Ur,SDK_TARGETS as Br,generateSdk as Hr}from"./sdk/index.mjs";import{redact as kr,secretKindOf as Vr}from"./packem_shared/redact-Cy14LEnc.mjs";import{default as zr}from"./packem_shared/emitDrizzleSchema-BzOChEYW.mjs";import{e as Qr}from"./packem_shared/server-CRFaUMKQ.mjs";import{e as qr}from"./packem_shared/shard-Csztu3jG.mjs";import{G as Jr}from"./packem_shared/shared-Cn7dMQ_u.mjs";import{MESSAGE_SOLUTIONS as Zr,findSolutionByMessage as $r}from"@lunora/errors";import{createCodegenProject as ro,findTsconfig as oo,refreshCodegenProject as to,tsconfigFingerprint as io}from"./packem_shared/createCodegenProject-BC4GwdnG.mjs";import{t as so,u as fo,v as mo}from"./packem_shared/shard-runtime-D0xuE0pX.mjs";import{emitApi as po,emitCollections as co,emitInternalApi as lo}from"./packem_shared/emitApi-lwadq5G7.mjs";import{emitCrons as xo,emitScheduler as Eo,emitVectors as Ao,emitWranglerCronTriggers as uo}from"./packem_shared/emitCrons-CCRKs482.mjs";import{emitDataModel as No}from"./packem_shared/emitDataModel-BvCZS4Yq.mjs";import{emitFunctions as Co}from"./packem_shared/emitFunctions-ppMX7E3X.mjs";import{isTypedSchema as Io}from"./packem_shared/isTypedSchema-CDv3pJB6.mjs";const e="0.0.0";export{I as AGENTS_FILENAME,me as ALL_NOTIFY_CHANNELS,E as CAPABILITY_PROBES,u as COMPANION_BINDING,v as COMPANION_SERVICE_NAME,P as CONTAINERS_FILENAME,g as CodegenDiagnosticError,sr as DEFAULT_TARGET,W as FLAGS_FILENAME,Jr as GENERATED_HEADER,yr as LUNORA_ERROR_CODES,Zr as LUNORA_SOLUTION_RULES,ie as MUTATORS_FILENAME,ne as NOTIFY_FILENAME,rr as OPENRPC_VERSION,Er as PROJECT_CONFIG_FILENAMES,ve as QUEUES_FILENAME,gr as SCHEMA_SNAPSHOT_FILENAME,t as SCHEMA_SNAPSHOT_VERSION,Ur as SDK_LANGUAGES,Br as SDK_TARGETS,Be as SHAPES_FILENAME,Ir as SchemaSnapshotParseError,e as VERSION,We as WORKFLOWS_FILENAME,Xe as buildOpenApiDocument,or as buildOpenRpcDocument,Rr as buildSchemaSnapshot,U as capabilitiesUsedBy,Pe as companionServiceBinding,ro as createCodegenProject,B as createTargetScope,p as describeErrorLevelFindings,C as diagnosticAt,i as diffSchemaSnapshots,R as discoverAgents,h as discoverAuthApiCalls,D as discoverContainers,b as discoverCrons,z as discoverFlags,Q as discoverFunctions,q as discoverHttpRoutes,J as discoverHyperdriveCalls,Z as discoverInserts,ee as discoverMaskProcedures,oe as discoverMigrations,ae as discoverMutators,de as discoverNondeterministicCalls,pe as discoverNotifyCalls,ce as discoverNotifyChannels,le as discoverNotifyConfig,Ae as discoverQueries,Ne as discoverQueues,Ce as discoverR2sqlCalls,_e as discoverRlsMetadata,Ie as discoverRlsProcedures,Te as discoverSandboxUsage,he as discoverSchema,He as discoverShapes,ke as discoverStorageRulesMetadata,ze as discoverWorkflows,so as emitAgents,po as emitApi,Qe as emitApp,co as emitCollections,fo as emitContainers,xo as emitCrons,No as emitDataModel,zr as emitDrizzleSchema,Co as emitFunctions,lo as emitInternalApi,Ze as emitOpenApi,$e as emitOpenApiModule,tr as emitOpenRpc,ir as emitOpenRpcModule,Eo as emitScheduler,Qr as emitServer,qr as emitShard,Ao as emitVectors,mo as emitWorkflows,uo as emitWranglerCronTriggers,c as errorAdvisoryNames,l as errorPlatformDiagnosticNames,_r as evaluateSchemaDrift,Ar as findCodegenConfigFile,$r as findLunoraSolution,ur as findProjectConfigFile,oo as findTsconfig,hr as fingerprintSchemaSources,H as foldCapabilitySignals,d as formatAdvisories,Hr as generateSdk,Lr as indexReferencesOf,qe as isD1GlobalTable,we as isHyperdriveGlobalTable,L as isTestPath,Io as isTypedSchema,f as lintSchema,T as listLunoraSourceFiles,pr as loadProjectConfig,j as mayReadCapabilityContext,Tr as parseSchemaSnapshot,dr as platformMatrixIds,vr as projectConfigCandidatePaths,De as readBoundServiceBindings,ye as readDevServiceBindings,xe as readPackageDependencies,cr as readProjectConfigLiterals,lr as readProjectLazyFunctions,Sr as readProjectSecurityHeaders,fr as readProjectTarget,be as readServiceBindings,kr as redact,to as refreshCodegenProject,mr as resolveCodegenTarget,Ge as resolveServiceBindings,Cr as runCodegen,Pr as schemaFromIr,Vr as secretKindOf,a as serializeSchemaSnapshot,S as sortedUniqueNames,k as sourceCapabilitySignals,m as toAdvisorContext,io as tsconfigFingerprint,br as validatorIrToJsonSchema};
@@ -1 +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 g}from"@lunora/errors";import{Node as a,SyntaxKind as u}from"ts-morph";import{diagnosticAt as l}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{unwrapToCallExpression as A,findObjectProperty as c,stringPropertyFor as E}from"./isTestPath-ClgKgMYM.mjs";import{a as w}from"./attribution-DjweYNgJ.mjs";const h=new Set(["@lunora/agent","@lunora/agent/core"]),v="agents.ts",P=o=>{const n=o.getSymbol();if(!n)return o.getText()==="defineAgent";for(const e of n.getDeclarations())if(a.isImportSpecifier(e))return h.has(e.getImportDeclaration().getModuleSpecifierValue())?e.getNameNode().getText()==="defineAgent":!1;return!1},S=E("agent"),D=(o,n,e)=>{if(o.getKind()===u.TrueKeyword)return!0;if(o.getKind()===u.FalseKeyword)return!1;throw l(o,`agent "${n}": \`${e}\` must be a static boolean literal — it is deploy configuration codegen writes into the ctx.agents wiring spec`)},I=(o,n)=>{const e=o.getArguments()[0];if(!e||!a.isObjectLiteralExpression(e))throw l(o,`agent "${n}": defineAgent must be passed an inline object literal`);const t={className:b(n),exportName:n,name:d(n)},r=c(e,"name");r&&a.isPropertyAssignment(r)&&(t.name=S(r.getInitializerOrThrow(),n,"name"));const i=c(e,"publicRun");i&&a.isPropertyAssignment(i)&&D(i.getInitializerOrThrow(),n,"publicRun")&&(t.publicRun=!0);const s=c(e,"voice");if(s&&a.isPropertyAssignment(s)){const m=s.getInitializerOrThrow();if(!a.isObjectLiteralExpression(m))throw l(m,`agent "${n}": \`voice\` must be an inline object literal — its presence tells codegen to emit the voice-session Durable Object`);t.voice=!0,t.voiceBindingName=N(n),t.voiceClassName=y(n)}return c(e,"onEmail")&&(t.onEmail=!0),t},T=o=>{const n=[];for(const e of o.getVariableDeclarations()){const t=A(e.getInitializer());if(!t)continue;const r=t.getExpression();if(!a.isIdentifier(r)||!P(r))continue;const i=e.getNameNode();if(!a.isIdentifier(i)){if(e.getVariableStatement()?.hasExportKeyword()!==!0)continue;throw l(i,"defineAgent exports must be plain named exports (no destructuring)")}const s=w(e,"binding");s!==void 0&&n.push(I(t,s))}return n},x=o=>{const n=new Map,e=new Map;for(const t of o){const r=n.get(t.name);if(r!==void 0)throw new g("DUPLICATE_AGENT_NAME",`Duplicate agent name "${t.name}": produced by both "${r}" and "${t.exportName}". Deployed agent names must be unique across the project.`,{status:500});n.set(t.name,t.exportName);const i=e.get(t.className);if(i!==void 0)throw new g("DUPLICATE_AGENT_CLASS",`Duplicate agent class "${t.className}": produced by both "${i}" and "${t.exportName}". Agent export names must yield unique generated class names.`,{status:500});e.set(t.className,t.exportName)}},M=(o,n)=>{const e=f(n,v);if(!p(e))return[];const t=o.getSourceFile(e)??o.addSourceFileAtPath(e),r=T(t);return r.sort((i,s)=>i.exportName.localeCompare(s.exportName)),x(r),r};export{v as AGENTS_FILENAME,M as discoverAgents};
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 g}from"@lunora/errors";import{Node as a,SyntaxKind as u}from"ts-morph";import{diagnosticAt as l}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{unwrapToCallExpression as A,findObjectProperty as c,stringPropertyFor as E}from"./isTestPath-B357_sbh.mjs";import{a as w}from"./attribution-C6VQNs-V.mjs";const h=new Set(["@lunora/agent","@lunora/agent/core"]),v="agents.ts",P=o=>{const n=o.getSymbol();if(!n)return o.getText()==="defineAgent";for(const e of n.getDeclarations())if(a.isImportSpecifier(e))return h.has(e.getImportDeclaration().getModuleSpecifierValue())?e.getNameNode().getText()==="defineAgent":!1;return!1},S=E("agent"),D=(o,n,e)=>{if(o.getKind()===u.TrueKeyword)return!0;if(o.getKind()===u.FalseKeyword)return!1;throw l(o,`agent "${n}": \`${e}\` must be a static boolean literal — it is deploy configuration codegen writes into the ctx.agents wiring spec`)},I=(o,n)=>{const e=o.getArguments()[0];if(!e||!a.isObjectLiteralExpression(e))throw l(o,`agent "${n}": defineAgent must be passed an inline object literal`);const t={className:b(n),exportName:n,name:d(n)},r=c(e,"name");r&&a.isPropertyAssignment(r)&&(t.name=S(r.getInitializerOrThrow(),n,"name"));const i=c(e,"publicRun");i&&a.isPropertyAssignment(i)&&D(i.getInitializerOrThrow(),n,"publicRun")&&(t.publicRun=!0);const s=c(e,"voice");if(s&&a.isPropertyAssignment(s)){const m=s.getInitializerOrThrow();if(!a.isObjectLiteralExpression(m))throw l(m,`agent "${n}": \`voice\` must be an inline object literal — its presence tells codegen to emit the voice-session Durable Object`);t.voice=!0,t.voiceBindingName=N(n),t.voiceClassName=y(n)}return c(e,"onEmail")&&(t.onEmail=!0),t},T=o=>{const n=[];for(const e of o.getVariableDeclarations()){const t=A(e.getInitializer());if(!t)continue;const r=t.getExpression();if(!a.isIdentifier(r)||!P(r))continue;const i=e.getNameNode();if(!a.isIdentifier(i)){if(e.getVariableStatement()?.hasExportKeyword()!==!0)continue;throw l(i,"defineAgent exports must be plain named exports (no destructuring)")}const s=w(e,"binding");s!==void 0&&n.push(I(t,s))}return n},x=o=>{const n=new Map,e=new Map;for(const t of o){const r=n.get(t.name);if(r!==void 0)throw new g("DUPLICATE_AGENT_NAME",`Duplicate agent name "${t.name}": produced by both "${r}" and "${t.exportName}". Deployed agent names must be unique across the project.`,{status:500});n.set(t.name,t.exportName);const i=e.get(t.className);if(i!==void 0)throw new g("DUPLICATE_AGENT_CLASS",`Duplicate agent class "${t.className}": produced by both "${i}" and "${t.exportName}". Agent export names must yield unique generated class names.`,{status:500});e.set(t.className,t.exportName)}},M=(o,n)=>{const e=f(n,v);if(!p(e))return[];const t=o.getSourceFile(e)??o.addSourceFileAtPath(e),r=T(t);return r.sort((i,s)=>i.exportName.localeCompare(s.exportName)),x(r),r};export{v as AGENTS_FILENAME,M as discoverAgents};
@@ -1 +1 @@
1
- import{existsSync as T}from"node:fs";import{join as D}from"node:path";import{SyntaxKind as l,Node as r,VariableDeclarationKind as L}from"ts-morph";import{listLunoraSourceFiles as E,lunoraRelativePath as k,descendantsOfKind as v,findObjectProperty as d,defaultExportExpression as C,propertyInitializer as m,handlerOf as w,unwrapExpression as u}from"./isTestPath-ClgKgMYM.mjs";import{j as M,h as j}from"./attribution-DjweYNgJ.mjs";import{a as p}from"./context-root-2wag3akK.mjs";import{c as _}from"./classify-procedure-call-BuF5PNwV.mjs";import{s as R}from"./property-name-7cBlgK_O.mjs";const W="notify.ts",z=new Set(["chat","inApp","send","webhook"]),S=new Set(["broadcast","send"]),H=e=>{const s=e.getInitializer();if(!s||!r.isCallExpression(s))return;const t=_(s);if(!t)return;const i=w(s,t.receiver);return i?{exportName:j(e)??e.getName(),handler:i,kind:t.kind}:void 0},P=e=>{const s=[];for(const t of M(e)){const i=H(t);i&&s.push(i)}return s},b=e=>p(e,["notify"])?"notify":p(e,["push"])||p(e,["notify","push"])?"push":void 0,U=e=>{if(!r.isPropertyAccessExpression(e))return;const s=e.getName(),t=b(e.getExpression());if(t==="notify"&&z.has(s))return`ctx.notify.${s}`;if(t==="push"&&S.has(s))return`ctx.push.${s}`},V=e=>r.isPropertyAccessExpression(e)?b(e.getExpression())==="push"&&S.has(e.getName()):!1,de=(e,s)=>{const t=[];for(const i of E(s)){const n=e.getSourceFile(i)??e.addSourceFileAtPath(i),o=k(s,i);for(const c of P(n))if(!(c.kind!=="query"&&c.kind!=="mutation"))for(const a of v(c.handler,l.PropertyAccessExpression)){const f=U(a);f!==void 0&&t.push({callee:f,exportName:c.exportName,file:o,kind:c.kind,line:a.getStartLineNumber()})}}return t},B=(e,s)=>{for(const t of E(s)){const i=e.getSourceFile(t)??e.addSourceFileAtPath(t);for(const n of P(i))for(const o of v(n.handler,l.PropertyAccessExpression))if(V(o))return!0}return!1},y={fcm:"env",hasWebPush:!0},K=new Set(["@lunora/notify"]),O=(e,s)=>{const t=e.getSymbol();if(!t)return e.getText()===s;for(const i of t.getDeclarations())if(r.isImportSpecifier(i))return K.has(i.getImportDeclaration().getModuleSpecifierValue())?i.getNameNode().getText()===s:!1;return!1},A=(e,s=new Set)=>{const t=C(e);if(!t)return;if(!r.isIdentifier(t))return t;const i=t.getSymbol();if(!i?.isAlias())return t;const n=i.getAliasedSymbol();if(!n)return t;const o=n.getDeclarations().find(a=>r.isExportAssignment(a));if(!o)return t;const c=o.getSourceFile();if(!s.has(c.getFilePath()))return A(c,s.add(c.getFilePath()))},Y=new Set(["%=","&&=","&=","**=","+=","-=","/=","<<=","=",">>=",">>>=","??=","^=","|=","||="]),x=e=>{const s=e.getSymbol();return s?.getAliasedSymbol()?.getDeclarations()[0]??s?.getDeclarations()[0]},N=e=>{if(r.isIdentifier(e))return e;if(r.isPropertyAccessExpression(e)||r.isElementAccessExpression(e))return N(e.getExpression())},g=(e,s)=>{const t=N(e);return t!==void 0&&x(t)===s},$=(e,s)=>{const t=e.getExpression();if(!r.isPropertyAccessExpression(t))return!1;const i=t.getName(),n=t.getExpression(),o=r.isIdentifier(n)?n.getText():"";if(!((i==="assign"||i==="defineProperty"||i==="defineProperties")&&o==="Object"||i==="set"&&o==="Reflect"))return!1;const a=e.getArguments()[0];return a!==void 0&&r.isIdentifier(a)&&x(a)===s},q=(e,s)=>{if(r.isBinaryExpression(e))return Y.has(e.getOperatorToken().getText())&&g(e.getLeft(),s);if(r.isDeleteExpression(e))return g(e.getExpression(),s);if(r.isPrefixUnaryExpression(e)||r.isPostfixUnaryExpression(e)){const t=e.getOperatorToken();return(t===l.PlusPlusToken||t===l.MinusMinusToken)&&g(e.getOperand(),s)}return r.isCallExpression(e)?$(e,s):!1},G=(e,s)=>{const t=x(e);return t===void 0?!0:s.some(i=>i.getDescendants().some(n=>q(n,t)))},J=e=>{if(r.isObjectLiteralExpression(e))return e;if(!r.isIdentifier(e))return;const s=e.getSymbol(),t=s?.getAliasedSymbol()?.getDeclarations()??s?.getDeclarations()??[];for(const i of t){if(!r.isVariableDeclaration(i))continue;const n=i.getInitializer();if(!n||!r.isObjectLiteralExpression(n))continue;const o=i.getParent();if(!r.isVariableDeclarationList(o)||o.getDeclarationKind()!==L.Const)continue;const c=[i.getSourceFile(),e.getSourceFile()].filter((a,f,F)=>F.findIndex(I=>I.getFilePath()===a.getFilePath())===f);if(!G(e,c))return n}},Q=e=>r.isArrowFunction(e)||r.isFunctionExpression(e)||r.isMethodDeclaration(e),X=e=>{const s=e.getBody();if(!r.isBlock(s))return s;const[t,...i]=s.getStatements();return i.length===0&&r.isReturnStatement(t)?t.getExpression():void 0},Z=e=>{const s=u(e),t=u(s!==void 0&&Q(s)?X(s):s);if(t!==void 0&&r.isCallExpression(t)){const i=t.getExpression(),n=u(t.getArguments()[1]);return r.isIdentifier(i)&&O(i,"fcmFromEnv")&&n!==void 0&&r.isObjectLiteralExpression(n)?n:void 0}return t!==void 0&&r.isObjectLiteralExpression(t)?t:void 0},h=(e,s)=>{const t=d(e,s),i=e.getProperties();return t!==void 0&&!i.slice(i.indexOf(t)+1).some(n=>{if(r.isSpreadAssignment(n))return!0;const o=R(n.getNameNode());return o===void 0||o===s})},ee=e=>{const s=d(e,"getAccessToken");if(s===void 0||!h(e,"getAccessToken"))return!1;if(r.isShorthandPropertyAssignment(s)||r.isMethodDeclaration(s))return!0;const t=u(m(e,"getAccessToken"));return t!==void 0&&(r.isArrowFunction(t)||r.isFunctionExpression(t)||r.isCallExpression(t)||r.isPropertyAccessExpression(t)||r.isIdentifier(t)&&t.getText()!=="undefined")},te=e=>{const s=u(m(e,"projectId"));return h(e,"projectId")&&s!==void 0&&(r.isStringLiteral(s)||r.isNoSubstitutionTemplateLiteral(s))&&s.getLiteralText()!==""},se=(e,s)=>{const t=d(e,"fcm");if(t===void 0)return"absent";if(!s||!h(e,"fcm"))return"env";const i=r.isMethodDeclaration(t)?t:m(e,"fcm"),n=i===void 0?void 0:Z(i);return n===void 0||!ee(n)?"env":te(n)?"ownCredentials":"ownToken"},re=(e,s)=>{const t=D(s,W);if(!T(t))return;const i=e.getSourceFile(t)??e.addSourceFileAtPath(t),n=A(i);if(!n||!r.isCallExpression(n))return y;const o=n.getExpression(),c=r.isIdentifier(o)&&O(o,"defineNotify")?n.getArguments()[0]:void 0,a=c===void 0?void 0:J(c);return!a||a.getProperties().some(f=>r.isSpreadAssignment(f))?y:{fcm:se(a,r.isObjectLiteralExpression(c)),hasWebPush:d(a,"webPush")!==void 0}},pe=(e,s)=>{const t=re(e,s);return t===void 0?void 0:{hasFcm:t.fcm!=="absent",hasWebPush:t.hasWebPush,usesPush:B(e,s)}};export{y as ALL_NOTIFY_CHANNELS,W as NOTIFY_FILENAME,de as discoverNotifyCalls,re as discoverNotifyChannels,pe as discoverNotifyConfig};
1
+ import{existsSync as T}from"node:fs";import{join as D}from"node:path";import{SyntaxKind as l,Node as r,VariableDeclarationKind as L}from"ts-morph";import{listLunoraSourceFiles as E,lunoraRelativePath as k,descendantsOfKind as v,findObjectProperty as d,defaultExportExpression as C,propertyInitializer as m,handlerOf as w,unwrapExpression as u}from"./isTestPath-B357_sbh.mjs";import{j as M,h as j}from"./attribution-C6VQNs-V.mjs";import{a as p}from"./context-root-CY5kkBER.mjs";import{c as _}from"./classify-procedure-call-DwWrpCoX.mjs";import{s as R}from"./property-name-7cBlgK_O.mjs";const W="notify.ts",z=new Set(["chat","inApp","send","webhook"]),S=new Set(["broadcast","send"]),H=e=>{const s=e.getInitializer();if(!s||!r.isCallExpression(s))return;const t=_(s);if(!t)return;const i=w(s,t.receiver);return i?{exportName:j(e)??e.getName(),handler:i,kind:t.kind}:void 0},P=e=>{const s=[];for(const t of M(e)){const i=H(t);i&&s.push(i)}return s},b=e=>p(e,["notify"])?"notify":p(e,["push"])||p(e,["notify","push"])?"push":void 0,U=e=>{if(!r.isPropertyAccessExpression(e))return;const s=e.getName(),t=b(e.getExpression());if(t==="notify"&&z.has(s))return`ctx.notify.${s}`;if(t==="push"&&S.has(s))return`ctx.push.${s}`},V=e=>r.isPropertyAccessExpression(e)?b(e.getExpression())==="push"&&S.has(e.getName()):!1,de=(e,s)=>{const t=[];for(const i of E(s)){const n=e.getSourceFile(i)??e.addSourceFileAtPath(i),o=k(s,i);for(const c of P(n))if(!(c.kind!=="query"&&c.kind!=="mutation"))for(const a of v(c.handler,l.PropertyAccessExpression)){const f=U(a);f!==void 0&&t.push({callee:f,exportName:c.exportName,file:o,kind:c.kind,line:a.getStartLineNumber()})}}return t},B=(e,s)=>{for(const t of E(s)){const i=e.getSourceFile(t)??e.addSourceFileAtPath(t);for(const n of P(i))for(const o of v(n.handler,l.PropertyAccessExpression))if(V(o))return!0}return!1},y={fcm:"env",hasWebPush:!0},K=new Set(["@lunora/notify"]),O=(e,s)=>{const t=e.getSymbol();if(!t)return e.getText()===s;for(const i of t.getDeclarations())if(r.isImportSpecifier(i))return K.has(i.getImportDeclaration().getModuleSpecifierValue())?i.getNameNode().getText()===s:!1;return!1},A=(e,s=new Set)=>{const t=C(e);if(!t)return;if(!r.isIdentifier(t))return t;const i=t.getSymbol();if(!i?.isAlias())return t;const n=i.getAliasedSymbol();if(!n)return t;const o=n.getDeclarations().find(a=>r.isExportAssignment(a));if(!o)return t;const c=o.getSourceFile();if(!s.has(c.getFilePath()))return A(c,s.add(c.getFilePath()))},Y=new Set(["%=","&&=","&=","**=","+=","-=","/=","<<=","=",">>=",">>>=","??=","^=","|=","||="]),x=e=>{const s=e.getSymbol();return s?.getAliasedSymbol()?.getDeclarations()[0]??s?.getDeclarations()[0]},N=e=>{if(r.isIdentifier(e))return e;if(r.isPropertyAccessExpression(e)||r.isElementAccessExpression(e))return N(e.getExpression())},g=(e,s)=>{const t=N(e);return t!==void 0&&x(t)===s},$=(e,s)=>{const t=e.getExpression();if(!r.isPropertyAccessExpression(t))return!1;const i=t.getName(),n=t.getExpression(),o=r.isIdentifier(n)?n.getText():"";if(!((i==="assign"||i==="defineProperty"||i==="defineProperties")&&o==="Object"||i==="set"&&o==="Reflect"))return!1;const a=e.getArguments()[0];return a!==void 0&&r.isIdentifier(a)&&x(a)===s},q=(e,s)=>{if(r.isBinaryExpression(e))return Y.has(e.getOperatorToken().getText())&&g(e.getLeft(),s);if(r.isDeleteExpression(e))return g(e.getExpression(),s);if(r.isPrefixUnaryExpression(e)||r.isPostfixUnaryExpression(e)){const t=e.getOperatorToken();return(t===l.PlusPlusToken||t===l.MinusMinusToken)&&g(e.getOperand(),s)}return r.isCallExpression(e)?$(e,s):!1},G=(e,s)=>{const t=x(e);return t===void 0?!0:s.some(i=>i.getDescendants().some(n=>q(n,t)))},J=e=>{if(r.isObjectLiteralExpression(e))return e;if(!r.isIdentifier(e))return;const s=e.getSymbol(),t=s?.getAliasedSymbol()?.getDeclarations()??s?.getDeclarations()??[];for(const i of t){if(!r.isVariableDeclaration(i))continue;const n=i.getInitializer();if(!n||!r.isObjectLiteralExpression(n))continue;const o=i.getParent();if(!r.isVariableDeclarationList(o)||o.getDeclarationKind()!==L.Const)continue;const c=[i.getSourceFile(),e.getSourceFile()].filter((a,f,F)=>F.findIndex(I=>I.getFilePath()===a.getFilePath())===f);if(!G(e,c))return n}},Q=e=>r.isArrowFunction(e)||r.isFunctionExpression(e)||r.isMethodDeclaration(e),X=e=>{const s=e.getBody();if(!r.isBlock(s))return s;const[t,...i]=s.getStatements();return i.length===0&&r.isReturnStatement(t)?t.getExpression():void 0},Z=e=>{const s=u(e),t=u(s!==void 0&&Q(s)?X(s):s);if(t!==void 0&&r.isCallExpression(t)){const i=t.getExpression(),n=u(t.getArguments()[1]);return r.isIdentifier(i)&&O(i,"fcmFromEnv")&&n!==void 0&&r.isObjectLiteralExpression(n)?n:void 0}return t!==void 0&&r.isObjectLiteralExpression(t)?t:void 0},h=(e,s)=>{const t=d(e,s),i=e.getProperties();return t!==void 0&&!i.slice(i.indexOf(t)+1).some(n=>{if(r.isSpreadAssignment(n))return!0;const o=R(n.getNameNode());return o===void 0||o===s})},ee=e=>{const s=d(e,"getAccessToken");if(s===void 0||!h(e,"getAccessToken"))return!1;if(r.isShorthandPropertyAssignment(s)||r.isMethodDeclaration(s))return!0;const t=u(m(e,"getAccessToken"));return t!==void 0&&(r.isArrowFunction(t)||r.isFunctionExpression(t)||r.isCallExpression(t)||r.isPropertyAccessExpression(t)||r.isIdentifier(t)&&t.getText()!=="undefined")},te=e=>{const s=u(m(e,"projectId"));return h(e,"projectId")&&s!==void 0&&(r.isStringLiteral(s)||r.isNoSubstitutionTemplateLiteral(s))&&s.getLiteralText()!==""},se=(e,s)=>{const t=d(e,"fcm");if(t===void 0)return"absent";if(!s||!h(e,"fcm"))return"env";const i=r.isMethodDeclaration(t)?t:m(e,"fcm"),n=i===void 0?void 0:Z(i);return n===void 0||!ee(n)?"env":te(n)?"ownCredentials":"ownToken"},re=(e,s)=>{const t=D(s,W);if(!T(t))return;const i=e.getSourceFile(t)??e.addSourceFileAtPath(t),n=A(i);if(!n||!r.isCallExpression(n))return y;const o=n.getExpression(),c=r.isIdentifier(o)&&O(o,"defineNotify")?n.getArguments()[0]:void 0,a=c===void 0?void 0:J(c);return!a||a.getProperties().some(f=>r.isSpreadAssignment(f))?y:{fcm:se(a,r.isObjectLiteralExpression(c)),hasWebPush:d(a,"webPush")!==void 0}},pe=(e,s)=>{const t=re(e,s);return t===void 0?void 0:{hasFcm:t.fcm!=="absent",hasWebPush:t.hasWebPush,usesPush:B(e,s)}};export{y as ALL_NOTIFY_CHANNELS,W as NOTIFY_FILENAME,de as discoverNotifyCalls,re as discoverNotifyChannels,pe as discoverNotifyConfig};
@@ -1 +1 @@
1
- import{existsSync as j}from"node:fs";import{join as I}from"node:path";import{containerClassName as A,containerBindingName as O,DURABLE_OBJECT_POLICY_FORBIDDEN_KEYS as k,isManagedImage as C,isCloudflareRegistryDigest as _,normalizeContainerImage as f}from"@lunora/container";import{SyntaxKind as $,Node as s}from"ts-morph";import{diagnosticAt as a}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{stringPropertyFor as D,findObjectProperty as p,symbolConstInitializer as M,descendantsOfKind as F,outermostValueWrapper as w,isWriteTarget as V}from"./isTestPath-ClgKgMYM.mjs";import{a as K}from"./attribution-DjweYNgJ.mjs";import{a as b}from"./property-name-7cBlgK_O.mjs";const B="containers.ts",R=t=>{const e=t.getSymbol();if(!e)return t.getText()==="defineContainer";for(const r of e.getDeclarations())if(s.isImportSpecifier(r))return r.getImportDeclaration().getModuleSpecifierValue()!=="@lunora/container"?!1:r.getNameNode().getText()==="defineContainer";return!1},d=D("container"),y=(t,e,r)=>{if(s.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`)},E=(t,e)=>{if(s.isStringLiteral(t)||s.isNoSubstitutionTemplateLiteral(t))return f(t.getLiteralValue());if(s.isObjectLiteralExpression(t)){const r=p(t,"registry");if(r&&s.isPropertyAssignment(r)){const i=r.getInitializerOrThrow();return f({registry:d(i,e,"image.registry")})}const n=p(t,"build");if(n&&s.isPropertyAssignment(n)){const i=n.getInitializerOrThrow();return f({build:d(i,e,"image.build")})}}throw a(t,`container "${e}": \`image\` must be a static string path, { registry: "…" }, or { build: "…" } literal`)},U=new Set(["buildArgs","image","images","instanceType","maxInstances","name","rollout","sandbox","schedulingPolicy"]),N=new Set(["gracePeriodSeconds","stepPercentage"]),L=t=>{let e=t;for(;s.isAsExpression(e)||s.isSatisfiesExpression(e)||s.isTypeAssertion(e)||s.isParenthesizedExpression(e);)e=e.getExpression();return e},Y=(t,e)=>F(e,$.Identifier).some(r=>{if(r.getSymbol()!==t)return!1;let n=w(r),i=n.getParent();if(s.isCallExpression(i)&&i.getExpression().getText()==="Object.assign")return i.getArguments()[0]===n;for(;(s.isPropertyAccessExpression(i)||s.isElementAccessExpression(i))&&i.getExpression()===n;){if(V(i))return!0;n=w(i),i=n.getParent()}return!1}),z=16,T=(t,e,r,n)=>{let i={name:r,symbol:t},o;for(let c=0;c<z;c+=1){const l=M(i.symbol);if(l===void 0||!s.isExpression(l))return o;if(o=L(l),s.isObjectLiteralExpression(o)&&i.symbol!==void 0&&Y(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(!s.isIdentifier(o))return o;i={name:o.getText(),symbol:o.getSymbol()}}return o},P=(t,e)=>{const r=L(t);return s.isIdentifier(r)?T(r.getSymbol(),r,r.getText(),e)??r:r},W=t=>{const e=t.getNonNullableType();return(e.isUnion()?e.getUnionTypes():[e]).flatMap(n=>n.getApparentType().getProperties().map(i=>i.getName()))},q=(t,e,r)=>{const n=t.getExpression().getType(),i=e==="every"||n.isAny()||n.isUnknown()?["its keys"]:[...new Set(W(n))].filter(o=>e.has(o)).map(o=>`\`${o}\``);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.`)},x=(t,e,r)=>{const n=b(t),i=s.isShorthandPropertyAssignment(t)?T(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=[],o=new Set(n).add(t);for(const c of t.getProperties())if(s.isPropertyAssignment(c))i.push([b(c),P(c.getInitializerOrThrow(),r)]);else if(s.isSpreadAssignment(c))i.push(...H(c,e,r,o));else{const l=x(c,e,r);l!==void 0&&i.push(l)}return i},H=(t,e,r,n)=>{const i=P(t.getExpression(),r);if(!s.isObjectLiteralExpression(i))return q(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)},J=(t,e)=>{if(!s.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]=d(i,e,`buildArgs.${n}`);return Object.keys(r).length>0?r:void 0},X=(t,e)=>{if(!s.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,N,`container "${e}" rollout`))(n==="gracePeriodSeconds"||n==="stepPercentage")&&(r[n]=y(i,e,`rollout.${n}`));return r.gracePeriodSeconds===void 0&&r.stepPercentage===void 0?void 0:r},v=t=>{if(s.isTrueLiteral(t))return!0;if(s.isFalseLiteral(t))return!1},S=t=>{if(s.isStringLiteral(t)||s.isNoSubstitutionTemplateLiteral(t)||s.isNumericLiteral(t))return t.getLiteralValue()},G=(t,e)=>{if(s.isStringLiteral(t))return t.getLiteralValue();if(s.isObjectLiteralExpression(t)){const r={};for(const n of t.getProperties()){if(!s.isPropertyAssignment(n))throw a(n,`container "${e}": \`instanceType\` must be an object of static number literals`);const i=b(n);if(i!=="diskMb"&&i!=="memoryMib"&&i!=="vcpu")throw a(n,`container "${e}": unknown \`instanceType\` field "${i}" — expected vcpu, memoryMib, or diskMb`);r[i]=y(n.getInitializerOrThrow(),e,`instanceType.${i}`)}return r}throw a(t,`container "${e}": \`instanceType\` must be a static string or { vcpu, memoryMib, diskMb } literal`)},Q=(t,e)=>{if(!s.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 o=E(i,e);if(o.kind==="build")throw a(i,`container "${e}": \`images["${n}"]\` cannot be a Railpack { build } source — use a Dockerfile path or a { registry } reference`);if(o.kind==="registry"&&!_(o.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]=o}return r},Z=(t,e)=>{const r=t.findLast(([i])=>i==="schedulingPolicy");if(r===void 0)return;const n=d(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},ee=(t,e,r,n)=>{if(r!==void 0&&k.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"`)},te=(t,e,r,n)=>{const{base:i,policy:o}=r;switch(t){case"buildArgs":{i.buildArgs=J(e,n);break}case"enableInternet":{i.enableInternet=v(e);break}case"hardTimeout":{i.hardTimeout=S(e);break}case"image":{r.scheduled||(o.image=E(e,n));break}case"images":{o.images=Q(e,n);break}case"instanceType":{i.instanceType=G(e,n);break}case"maxInstances":{o.maxInstances=y(e,n,"maxInstances");break}case"name":{i.name=d(e,n,"name");break}case"rollout":{o.rollout=X(e,n);break}case"sandbox":{const c=v(e);if(c===void 0)throw a(e,`container "${n}": \`sandbox\` must be a static true/false literal`);i.sandbox=c;break}case"sleepAfter":{i.sleepAfter=S(e);break}}},ne=(t,e,r)=>{const n=t.findLast(([o])=>o==="image")?.[1];if(n===void 0||!(s.isStringLiteral(n)||s.isNoSubstitutionTemplateLiteral(n)))return;const i=n.getLiteralValue();if(!Object.hasOwn(e??{},i)&&!C(i))throw a(n,`container "${r}": \`image\` "${i}" must name an entry of \`images\` or a Cloudflare-managed "cloudflare/…" image`)},ie=(t,e)=>{const r=t.getArguments()[0];if(!r||!s.isObjectLiteralExpression(r))throw a(t,`container "${e}": defineContainer must be passed an inline object literal`);const n=m(r,U,`container "${e}"`),i=Z(n,e),o={base:{bindingName:O(e),className:A(e),exportName:e},policy:{},scheduled:i!==void 0};for(const[g,u]of n)ee(g,u,i,e),te(g,u,o,e);const{base:c,policy:l}=o;if(i==="durable_object")return ne(n,l.images,e),{...c,...l.images===void 0?{}:{images:l.images},schedulingPolicy:i};if(l.image===void 0)throw a(r,`container "${e}": defineContainer requires a static \`image\` property`);return{...c,image:l.image,...l.maxInstances===void 0?{}:{maxInstances:l.maxInstances},...l.rollout===void 0?{}:{rollout:l.rollout}}},re=t=>{const e=[],r=new Map;for(const n of t.getVariableDeclarations()){const i=n.getInitializer();if(i?.getKind()!==$.CallExpression)continue;const o=i,c=o.getExpression();if(!s.isIdentifier(c)||!R(c))continue;const l=n.getNameNode();if(!s.isIdentifier(l)){if(n.getVariableStatement()?.hasExportKeyword()!==!0)continue;throw a(l,"defineContainer exports must be plain named exports (no destructuring)")}const g=K(n,"binding");if(g===void 0)continue;const u=ie(o,g),h=r.get(u.bindingName);if(h!==void 0)throw a(l,`containers "${h}" 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},me=(t,e)=>{const r=I(e,B);if(!j(r))return[];const n=t.getSourceFile(r)??t.addSourceFileAtPath(r),i=re(n);return i.sort((o,c)=>o.exportName.localeCompare(c.exportName)),i};export{B as CONTAINERS_FILENAME,me as discoverContainers};
1
+ import{existsSync as j}from"node:fs";import{join as I}from"node:path";import{containerClassName as A,containerBindingName as O,DURABLE_OBJECT_POLICY_FORBIDDEN_KEYS as k,isManagedImage as C,isCloudflareRegistryDigest as _,normalizeContainerImage as f}from"@lunora/container";import{SyntaxKind as $,Node as s}from"ts-morph";import{diagnosticAt as a}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{stringPropertyFor as D,findObjectProperty as p,symbolConstInitializer as M,descendantsOfKind as F,outermostValueWrapper as w,isWriteTarget as V}from"./isTestPath-B357_sbh.mjs";import{a as K}from"./attribution-C6VQNs-V.mjs";import{a as b}from"./property-name-7cBlgK_O.mjs";const B="containers.ts",R=t=>{const e=t.getSymbol();if(!e)return t.getText()==="defineContainer";for(const r of e.getDeclarations())if(s.isImportSpecifier(r))return r.getImportDeclaration().getModuleSpecifierValue()!=="@lunora/container"?!1:r.getNameNode().getText()==="defineContainer";return!1},d=D("container"),y=(t,e,r)=>{if(s.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`)},E=(t,e)=>{if(s.isStringLiteral(t)||s.isNoSubstitutionTemplateLiteral(t))return f(t.getLiteralValue());if(s.isObjectLiteralExpression(t)){const r=p(t,"registry");if(r&&s.isPropertyAssignment(r)){const i=r.getInitializerOrThrow();return f({registry:d(i,e,"image.registry")})}const n=p(t,"build");if(n&&s.isPropertyAssignment(n)){const i=n.getInitializerOrThrow();return f({build:d(i,e,"image.build")})}}throw a(t,`container "${e}": \`image\` must be a static string path, { registry: "…" }, or { build: "…" } literal`)},U=new Set(["buildArgs","image","images","instanceType","maxInstances","name","rollout","sandbox","schedulingPolicy"]),N=new Set(["gracePeriodSeconds","stepPercentage"]),L=t=>{let e=t;for(;s.isAsExpression(e)||s.isSatisfiesExpression(e)||s.isTypeAssertion(e)||s.isParenthesizedExpression(e);)e=e.getExpression();return e},Y=(t,e)=>F(e,$.Identifier).some(r=>{if(r.getSymbol()!==t)return!1;let n=w(r),i=n.getParent();if(s.isCallExpression(i)&&i.getExpression().getText()==="Object.assign")return i.getArguments()[0]===n;for(;(s.isPropertyAccessExpression(i)||s.isElementAccessExpression(i))&&i.getExpression()===n;){if(V(i))return!0;n=w(i),i=n.getParent()}return!1}),z=16,T=(t,e,r,n)=>{let i={name:r,symbol:t},o;for(let c=0;c<z;c+=1){const l=M(i.symbol);if(l===void 0||!s.isExpression(l))return o;if(o=L(l),s.isObjectLiteralExpression(o)&&i.symbol!==void 0&&Y(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(!s.isIdentifier(o))return o;i={name:o.getText(),symbol:o.getSymbol()}}return o},P=(t,e)=>{const r=L(t);return s.isIdentifier(r)?T(r.getSymbol(),r,r.getText(),e)??r:r},W=t=>{const e=t.getNonNullableType();return(e.isUnion()?e.getUnionTypes():[e]).flatMap(n=>n.getApparentType().getProperties().map(i=>i.getName()))},q=(t,e,r)=>{const n=t.getExpression().getType(),i=e==="every"||n.isAny()||n.isUnknown()?["its keys"]:[...new Set(W(n))].filter(o=>e.has(o)).map(o=>`\`${o}\``);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.`)},x=(t,e,r)=>{const n=b(t),i=s.isShorthandPropertyAssignment(t)?T(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=[],o=new Set(n).add(t);for(const c of t.getProperties())if(s.isPropertyAssignment(c))i.push([b(c),P(c.getInitializerOrThrow(),r)]);else if(s.isSpreadAssignment(c))i.push(...H(c,e,r,o));else{const l=x(c,e,r);l!==void 0&&i.push(l)}return i},H=(t,e,r,n)=>{const i=P(t.getExpression(),r);if(!s.isObjectLiteralExpression(i))return q(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)},J=(t,e)=>{if(!s.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]=d(i,e,`buildArgs.${n}`);return Object.keys(r).length>0?r:void 0},X=(t,e)=>{if(!s.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,N,`container "${e}" rollout`))(n==="gracePeriodSeconds"||n==="stepPercentage")&&(r[n]=y(i,e,`rollout.${n}`));return r.gracePeriodSeconds===void 0&&r.stepPercentage===void 0?void 0:r},v=t=>{if(s.isTrueLiteral(t))return!0;if(s.isFalseLiteral(t))return!1},S=t=>{if(s.isStringLiteral(t)||s.isNoSubstitutionTemplateLiteral(t)||s.isNumericLiteral(t))return t.getLiteralValue()},G=(t,e)=>{if(s.isStringLiteral(t))return t.getLiteralValue();if(s.isObjectLiteralExpression(t)){const r={};for(const n of t.getProperties()){if(!s.isPropertyAssignment(n))throw a(n,`container "${e}": \`instanceType\` must be an object of static number literals`);const i=b(n);if(i!=="diskMb"&&i!=="memoryMib"&&i!=="vcpu")throw a(n,`container "${e}": unknown \`instanceType\` field "${i}" — expected vcpu, memoryMib, or diskMb`);r[i]=y(n.getInitializerOrThrow(),e,`instanceType.${i}`)}return r}throw a(t,`container "${e}": \`instanceType\` must be a static string or { vcpu, memoryMib, diskMb } literal`)},Q=(t,e)=>{if(!s.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 o=E(i,e);if(o.kind==="build")throw a(i,`container "${e}": \`images["${n}"]\` cannot be a Railpack { build } source — use a Dockerfile path or a { registry } reference`);if(o.kind==="registry"&&!_(o.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]=o}return r},Z=(t,e)=>{const r=t.findLast(([i])=>i==="schedulingPolicy");if(r===void 0)return;const n=d(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},ee=(t,e,r,n)=>{if(r!==void 0&&k.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"`)},te=(t,e,r,n)=>{const{base:i,policy:o}=r;switch(t){case"buildArgs":{i.buildArgs=J(e,n);break}case"enableInternet":{i.enableInternet=v(e);break}case"hardTimeout":{i.hardTimeout=S(e);break}case"image":{r.scheduled||(o.image=E(e,n));break}case"images":{o.images=Q(e,n);break}case"instanceType":{i.instanceType=G(e,n);break}case"maxInstances":{o.maxInstances=y(e,n,"maxInstances");break}case"name":{i.name=d(e,n,"name");break}case"rollout":{o.rollout=X(e,n);break}case"sandbox":{const c=v(e);if(c===void 0)throw a(e,`container "${n}": \`sandbox\` must be a static true/false literal`);i.sandbox=c;break}case"sleepAfter":{i.sleepAfter=S(e);break}}},ne=(t,e,r)=>{const n=t.findLast(([o])=>o==="image")?.[1];if(n===void 0||!(s.isStringLiteral(n)||s.isNoSubstitutionTemplateLiteral(n)))return;const i=n.getLiteralValue();if(!Object.hasOwn(e??{},i)&&!C(i))throw a(n,`container "${r}": \`image\` "${i}" must name an entry of \`images\` or a Cloudflare-managed "cloudflare/…" image`)},ie=(t,e)=>{const r=t.getArguments()[0];if(!r||!s.isObjectLiteralExpression(r))throw a(t,`container "${e}": defineContainer must be passed an inline object literal`);const n=m(r,U,`container "${e}"`),i=Z(n,e),o={base:{bindingName:O(e),className:A(e),exportName:e},policy:{},scheduled:i!==void 0};for(const[g,u]of n)ee(g,u,i,e),te(g,u,o,e);const{base:c,policy:l}=o;if(i==="durable_object")return ne(n,l.images,e),{...c,...l.images===void 0?{}:{images:l.images},schedulingPolicy:i};if(l.image===void 0)throw a(r,`container "${e}": defineContainer requires a static \`image\` property`);return{...c,image:l.image,...l.maxInstances===void 0?{}:{maxInstances:l.maxInstances},...l.rollout===void 0?{}:{rollout:l.rollout}}},re=t=>{const e=[],r=new Map;for(const n of t.getVariableDeclarations()){const i=n.getInitializer();if(i?.getKind()!==$.CallExpression)continue;const o=i,c=o.getExpression();if(!s.isIdentifier(c)||!R(c))continue;const l=n.getNameNode();if(!s.isIdentifier(l)){if(n.getVariableStatement()?.hasExportKeyword()!==!0)continue;throw a(l,"defineContainer exports must be plain named exports (no destructuring)")}const g=K(n,"binding");if(g===void 0)continue;const u=ie(o,g),h=r.get(u.bindingName);if(h!==void 0)throw a(l,`containers "${h}" 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},me=(t,e)=>{const r=I(e,B);if(!j(r))return[];const n=t.getSourceFile(r)??t.addSourceFileAtPath(r),i=re(n);return i.sort((o,c)=>o.exportName.localeCompare(c.exportName)),i};export{B as CONTAINERS_FILENAME,me as discoverContainers};
@@ -0,0 +1 @@
1
+ import{NODE_CAPABILITIES as g,CLOUDFLARE_CAPABILITIES as b,CELLD_CAPABILITIES as y}from"@lunora/platform";import{r as f}from"./project-config-file-DBVmBpin.mjs";const m="cloudflare",S=t=>{const{target:e}=f(t);return e!==void 0&&e.length>0?e:void 0},I=(t,e)=>e??S(t)??m,z=(t,e)=>{if(e!==void 0)return[];const{target:r,unreadable:a}=f(t);return a!==!0||r!==void 0?[]:[{level:"warn",message:`lunora.config declares a \`target\` that codegen cannot read without evaluating it, so the "${m}" 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: "${m}" }\`), or pass \`--target\`.`,target:m}]},_={max:1536,min:32},E=(t,e)=>{if(t!=="cloudflare")return[];const{max:r,min:a}=_,i=`${String(a)}-${String(r)}`;return e.filter(({dimensions:o})=>o!==void 0&&(!Number.isInteger(o)||o<a||o>r)).map(({dimensions:o,name:s})=>({level:"warn",message:`Vector index "${s}" declares ${String(o)} dimensions; Cloudflare Vectorize accepts ${i}, so creating a Vectorize index for it fails at deploy.`,name:"platform_vector_dimensions_out_of_range",remediation:`If a Vectorize index backs "${s}", use ${i} dimensions (many embedding models can truncate output to fit). Ignore this if another store, such as pgvector, backs it.`,target:t}))},u={celld:y,cloudflare:b,node:g},O=(t,e)=>{const r=u[t];if(r===void 0)return!0;const a=r.features[e]?.level;return a==="native"||a==="emulated"},D=()=>Object.keys(u).toSorted((t,e)=>t.localeCompare(e)),k={access:null,ai:"ai",aiSearch:"aiSearch",analytics:"analytics",analyticsSql:"analyticsSql",artifacts:"artifacts",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:"secrets"},w=["agents","commitOrderedTables","containerEgressPolicy","containerRuntimeScheduling","containerSandboxTools","cronTriggers","crossShardFanout","deliveryAuthorization","durableStreams","globalTables","liveStreams","queues","relationGraph","secrets","secretValues","services","topics","typedWebSockets","vectorStore","workerLoaders","workflowRollback","workflowSchedules"],h={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" })`)',containerSandboxTools:"container sandbox helpers — files, directory backups, bucket mounts (`defineContainer({ sandbox: true })`)",deliveryAuthorization:"delivery authorization (`.deliveryAuthorization(...)` on the app builder)",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()`)",liveContext:"the live publisher (`ctx.live`)",liveStreams:"live topic streams (`defineLiveStream`)",queues:"queues (`defineQueue`)",relationGraph:"relation-graph traversal (`ctx.db.related`, derived from `v.id(...)` columns)",secrets:"the secrets store (`ctx.secrets`)",secretValues:"human-supplied secret values (`requestSecretTool`, held for one agent step)",services:"service bindings to sibling Workers (`lunora.config` `services`)",topics:"pub/sub topics (`defineTopic` / `defineSubscription`)",typedWebSockets:"typed WebSocket routes and rooms (`defineWebSocket` / `defineRoom`)",vectorStore:"vector indexes (`.vectorize()`)",workerLoaders:"sandboxed agent scripts (`jsCodeTool`, on Worker Loaders)",workflowRollback:"workflow step rollback (`defineStep({ rollback })`)",workflowSchedules:"scheduled workflow instances (`defineWorkflow({ schedules })`)"},T=(t,e,r)=>({level:"error",message:`${e.name} does not support ${h[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:r}),x=(t,e)=>({level:"error",message:`${t.name} withholds live streams, so ctx.live is not available on the "${e}" target, but this app reads ctx.live.`,name:"platform_unsupported_feature",remediation:'Remove the ctx.live usage, or deploy to a target whose capability matrix marks "liveStreams" as native or emulated.',target:e}),P=t=>({level:"error",message:"This app declares defineLiveStream topics and enables delivery authorization. With delivery authorization on, the shard answers every /_lunora/live/* request with 501, so the live streams cannot be served.",name:"platform_live_stream_delivery_authorization",remediation:"Remove the defineLiveStream declarations, or remove the .deliveryAuthorization(...) call. Live streams and delivery authorization cannot be combined.",target:t}),W=t=>({level:"error",message:"This app declares defineWebSocket routes and enables delivery authorization. With delivery authorization on, the shard answers every route upgrade with 501, so the routes cannot be served.",name:"platform_socket_delivery_authorization",remediation:"Remove the defineWebSocket declarations, or remove the .deliveryAuthorization(...) call. Socket routes and delivery authorization cannot be combined.",target:t}),A=(t,e,r)=>({level:"error",message:`${e.name}'s capability matrix does not declare a support level for ${h[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:r}),$=t=>{const{diagnostics:e,gatedSignals:r,matrix:a,reported:i,signals:o,target:s}=t;for(const n of w){if(o[n]!==!0)continue;const d=a.features[n]?.level;d!=="unsupported"&&d!==void 0||(r[n]=!1,!i.has(n)&&e.push(d==="unsupported"?T(n,a,s):A(n,a,s)))}},R=(t,e,r,a={})=>{const i={...t},o={...a},s=[],n=new Set;for(const[l,c]of Object.entries(k)){if(c===null||!t[l])continue;const v=e.features[c]?.level;v==="unsupported"?(i[l]=!1,n.add(c),s.push({feature:l,level:"error",message:`${e.name} does not support "${l}" (ctx.${l}).`,name:"platform_unsupported_feature",remediation:`Remove the ctx.${l} usage, or deploy to a target whose capability matrix marks "${c}" as native or emulated.`,target:r})):v===void 0&&(i[l]=!1,n.add(c),s.push({feature:l,level:"error",message:`${e.name}'s capability matrix does not declare a support level for "${l}" (ctx.${l}). Treated as unsupported.`,name:"platform_undeclared_feature",remediation:`Rate "${c}" 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:r}))}$({diagnostics:s,gatedSignals:o,matrix:e,reported:n,signals:a,target:r});const d=e.features.liveStreams?.level,p=d===void 0||d==="unsupported";return a.liveContext===!0&&p&&s.push(x(e,r)),{diagnostics:s,liveStreamsWithheld:p,signals:o,usage:i}},F=(t,e,r={})=>{const a=u[e];return a===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}],liveStreamsWithheld:!1,signals:{...r},usage:{...t}}:R(t,a,e,r)},j=t=>{const e=u[t];if(e===void 0)return{supported:!0};const r=e.features.adminTokenRevocation?.level;return r!==void 0&&r!=="unsupported"?{supported:!0}:{diagnostic:{level:"warn",message:`${e.name} ${r===void 0?"does not declare a support level for":"does not support"} named admin tokens, so codegen omits the admin revocation store (\`_generated/adminRevocations.ts\` and the builder's \`.adminRevocations()\`). The root LUNORA_ADMIN_TOKEN is the only admin credential here.`,name:r===void 0?"platform_undeclared_feature":"platform_unsupported_feature",remediation:'Use the root admin token, or deploy to a target whose capability matrix marks "adminTokenRevocation" as native or emulated.',target:t},supported:!1}},N=t=>{const e=u[t];if(e===void 0)return;const r=Object.entries(e.features).filter(([,a])=>a.level==="unsupported").map(([a])=>a).toSorted((a,i)=>a.localeCompare(i));return{id:e.id,name:e.name,unsupported:r}};export{k as CAPABILITY_TO_FEATURE,m as DEFAULT_TARGET,j as gateAdminTokenRevocation,R as gateAgainstMatrix,F as gatePlatformFeatures,P as liveStreamsDeliveryAuthorizationDiagnostic,O as platformFeatureAvailable,D as platformMatrixIds,S as readProjectTarget,z as readTargetDiagnostics,I as resolveCodegenTarget,W as socketRoutesDeliveryAuthorizationDiagnostic,N as studioPlatformFor,E as vectorizeDimensionDiagnostics};
@@ -1 +1 @@
1
- import{existsSync as l}from"node:fs";import{join as p}from"node:path";import{Node as t}from"ts-morph";import{defaultExportExpression as g,propertyInitializer as f,findObjectProperty as c}from"./isTestPath-ClgKgMYM.mjs";const d="flags.ts",u=new Set(["@lunora/flags/providers/flagship","lunorash/flags/flagship"]),m=e=>{const i=e.getSymbol();if(!i)return e.getText()==="flagshipProvider";for(const r of i.getDeclarations())if(t.isImportSpecifier(r))return u.has(r.getImportDeclaration().getModuleSpecifierValue())?r.getNameNode().getText()==="flagshipProvider":!1;return!1},v=(e,i)=>{const r=c(e,i);if(!r||!t.isPropertyAssignment(r))return;const o=r.getInitializerOrThrow();if(t.isStringLiteral(o)||t.isNoSubstitutionTemplateLiteral(o))return o.getLiteralValue()},h=e=>{const i=e.getArguments()[0];if(i&&t.isObjectLiteralExpression(i)){const r=v(i,"binding");if(r!==void 0&&r.length>0)return{bindingName:r,mode:"binding",provider:"flagship"}}return{mode:"http",provider:"flagship"}},S=e=>f(e.getArguments()[0],"provider"),b=(e,i)=>{const r=p(i,d);if(!l(r))return;const o=e.getSourceFile(r)??e.addSourceFileAtPath(r),n=g(o);if(!n||!t.isCallExpression(n))return{provider:"custom"};const s=S(n);if(s&&t.isCallExpression(s)){const a=s.getExpression();if(t.isIdentifier(a)&&m(a))return h(s)}return{provider:"custom"}};export{d as FLAGS_FILENAME,b as discoverFlags};
1
+ import{existsSync as l}from"node:fs";import{join as p}from"node:path";import{Node as t}from"ts-morph";import{defaultExportExpression as g,propertyInitializer as f,findObjectProperty as c}from"./isTestPath-B357_sbh.mjs";const d="flags.ts",u=new Set(["@lunora/flags/providers/flagship","lunorash/flags/flagship"]),m=e=>{const i=e.getSymbol();if(!i)return e.getText()==="flagshipProvider";for(const r of i.getDeclarations())if(t.isImportSpecifier(r))return u.has(r.getImportDeclaration().getModuleSpecifierValue())?r.getNameNode().getText()==="flagshipProvider":!1;return!1},v=(e,i)=>{const r=c(e,i);if(!r||!t.isPropertyAssignment(r))return;const o=r.getInitializerOrThrow();if(t.isStringLiteral(o)||t.isNoSubstitutionTemplateLiteral(o))return o.getLiteralValue()},h=e=>{const i=e.getArguments()[0];if(i&&t.isObjectLiteralExpression(i)){const r=v(i,"binding");if(r!==void 0&&r.length>0)return{bindingName:r,mode:"binding",provider:"flagship"}}return{mode:"http",provider:"flagship"}},S=e=>f(e.getArguments()[0],"provider"),b=(e,i)=>{const r=p(i,d);if(!l(r))return;const o=e.getSourceFile(r)??e.addSourceFileAtPath(r),n=g(o);if(!n||!t.isCallExpression(n))return{provider:"custom"};const s=S(n);if(s&&t.isCallExpression(s)){const a=s.getExpression();if(t.isIdentifier(a)&&m(a))return h(s)}return{provider:"custom"}};export{d as FLAGS_FILENAME,b as discoverFlags};
@@ -1 +1 @@
1
- import{existsSync as E}from"node:fs";import{join as y}from"node:path";import{Node as o,SyntaxKind as l}from"ts-morph";import{diagnosticAt as I}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{b as M}from"./module-specifiers-BctA0m_p.mjs";import{p as A}from"./parse-validator-BisfC8bR.mjs";import{findObjectProperty as c,unwrapExpression as d,isConstDeclaration as P}from"./isTestPath-ClgKgMYM.mjs";import{g as b,i as D,d as g,h as O}from"./attribution-DjweYNgJ.mjs";import{u as h}from"./unwrap-handler-return-BpigsVD6.mjs";const w="mutators.ts",x=M,z=r=>{const e=r.getSymbol();if(!e)return r.getText()==="defineMutator";for(const t of e.getDeclarations())if(o.isImportSpecifier(t))return x(t.getImportDeclaration().getModuleSpecifierValue())?t.getNameNode().getText()==="defineMutator":!1;return!1},C=r=>{const e=r.getSymbol();if(!e)return!1;for(const t of e.getDeclarations()){if(!o.isNamespaceImport(t))continue;const i=t.getFirstAncestorByKind(l.ImportDeclaration);return i!==void 0&&x(i.getModuleSpecifierValue())}return!1},N=r=>{if(o.isIdentifier(r))return z(r);if(o.isPropertyAccessExpression(r)){const e=r.getExpression();return r.getName()==="defineMutator"&&o.isIdentifier(e)&&C(e)}return!1},S=r=>{const e=r.getArguments()[0];return e&&o.isObjectLiteralExpression(e)?e:void 0},m=new WeakMap,p=r=>{let e=m.get(r.compilerNode);if(e===void 0){const t=r.getNameNode(),i=t?.getText();e=r.getSourceFile().getDescendantsOfKind(l.Identifier).filter(s=>s!==t&&s.getText()===i&&g(s)?.compilerNode===r.compilerNode).length===1&&O(r)===void 0,m.set(r.compilerNode,e)}return e},f=r=>{const e=o.isIdentifier(r)?g(r):void 0,t=o.isSourceFile(e?.getParent())||o.isSourceFile(e?.getParent()?.getParent()?.getParent());if(e===void 0||e.getSourceFile()!==r?.getSourceFile()||!t)return;if(o.isFunctionDeclaration(e))return e.hasBody()&&p(e)?e:void 0;const i=P(e)?d(e.getInitializer()):void 0;return(o.isArrowFunction(i)||o.isFunctionExpression(i))&&o.isVariableDeclaration(e)&&p(e)?i:void 0},G=r=>{const e=r.getInitializer();if(!o.isCallExpression(e)||!N(e.getExpression()))return;const t=c(S(e),"server");if(o.isMethodDeclaration(t))return t;if(o.isShorthandPropertyAssignment(t))return f(t.getNameNode());const i=o.isPropertyAssignment(t)?d(t.getInitializer()):void 0;return o.isArrowFunction(i)||o.isFunctionExpression(i)?i:f(i)},T=r=>{const e=c(r,"args");if(!e||!o.isPropertyAssignment(e))return{};const t=e.getInitializer();return t&&o.isObjectLiteralExpression(t)?A(t):{}},L=r=>{const e=c(r,"server");if(!e||!o.isPropertyAssignment(e))return"unknown";const t=e.getInitializer();return!t||!(o.isArrowFunction(t)||o.isFunctionExpression(t))?"unknown":h(t)},j=r=>{const e=c(r,"owner");if(!e||!o.isPropertyAssignment(e))return;const t=e.getInitializer();return t&&o.isStringLiteral(t)?t.getLiteralValue():void 0},R=r=>{const e=[];for(const t of r.getVariableDeclarations()){if(!t.isExported())continue;const i=t.getInitializer();if(i?.getKind()!==l.CallExpression)continue;const n=i,s=n.getExpression();if(!N(s))continue;const a=t.getNameNode();if(!o.isIdentifier(a))throw I(a,"defineMutator exports must be plain named exports (no destructuring)");const u=S(n);for(const v of b(t).filter(F=>D(F)))e.push({args:T(u),exportName:v,filePath:"mutators",line:n.getStartLineNumber(),owner:j(u),returnType:L(u)})}return e},J=(r,e)=>{const t=y(e,w);if(!E(t))return[];const i=r.getSourceFile(t)??r.addSourceFileAtPath(t),n=R(i);return n.sort((s,a)=>s.exportName.localeCompare(a.exportName)),n};export{w as MUTATORS_FILENAME,J as discoverMutators,N as isDefineMutatorCallee,S as mutatorLiteral,G as mutatorServerImplOf};
1
+ import{existsSync as E}from"node:fs";import{join as y}from"node:path";import{Node as o,SyntaxKind as l}from"ts-morph";import{diagnosticAt as I}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{b as M}from"./module-specifiers-BctA0m_p.mjs";import{p as A}from"./parse-validator-BisfC8bR.mjs";import{findObjectProperty as c,unwrapExpression as d,isConstDeclaration as P}from"./isTestPath-B357_sbh.mjs";import{g as b,i as D,d as g,h as O}from"./attribution-C6VQNs-V.mjs";import{u as h}from"./unwrap-handler-return-zNStZJ4K.mjs";const w="mutators.ts",x=M,z=r=>{const e=r.getSymbol();if(!e)return r.getText()==="defineMutator";for(const t of e.getDeclarations())if(o.isImportSpecifier(t))return x(t.getImportDeclaration().getModuleSpecifierValue())?t.getNameNode().getText()==="defineMutator":!1;return!1},C=r=>{const e=r.getSymbol();if(!e)return!1;for(const t of e.getDeclarations()){if(!o.isNamespaceImport(t))continue;const i=t.getFirstAncestorByKind(l.ImportDeclaration);return i!==void 0&&x(i.getModuleSpecifierValue())}return!1},N=r=>{if(o.isIdentifier(r))return z(r);if(o.isPropertyAccessExpression(r)){const e=r.getExpression();return r.getName()==="defineMutator"&&o.isIdentifier(e)&&C(e)}return!1},S=r=>{const e=r.getArguments()[0];return e&&o.isObjectLiteralExpression(e)?e:void 0},m=new WeakMap,p=r=>{let e=m.get(r.compilerNode);if(e===void 0){const t=r.getNameNode(),i=t?.getText();e=r.getSourceFile().getDescendantsOfKind(l.Identifier).filter(s=>s!==t&&s.getText()===i&&g(s)?.compilerNode===r.compilerNode).length===1&&O(r)===void 0,m.set(r.compilerNode,e)}return e},f=r=>{const e=o.isIdentifier(r)?g(r):void 0,t=o.isSourceFile(e?.getParent())||o.isSourceFile(e?.getParent()?.getParent()?.getParent());if(e===void 0||e.getSourceFile()!==r?.getSourceFile()||!t)return;if(o.isFunctionDeclaration(e))return e.hasBody()&&p(e)?e:void 0;const i=P(e)?d(e.getInitializer()):void 0;return(o.isArrowFunction(i)||o.isFunctionExpression(i))&&o.isVariableDeclaration(e)&&p(e)?i:void 0},G=r=>{const e=r.getInitializer();if(!o.isCallExpression(e)||!N(e.getExpression()))return;const t=c(S(e),"server");if(o.isMethodDeclaration(t))return t;if(o.isShorthandPropertyAssignment(t))return f(t.getNameNode());const i=o.isPropertyAssignment(t)?d(t.getInitializer()):void 0;return o.isArrowFunction(i)||o.isFunctionExpression(i)?i:f(i)},T=r=>{const e=c(r,"args");if(!e||!o.isPropertyAssignment(e))return{};const t=e.getInitializer();return t&&o.isObjectLiteralExpression(t)?A(t):{}},L=r=>{const e=c(r,"server");if(!e||!o.isPropertyAssignment(e))return"unknown";const t=e.getInitializer();return!t||!(o.isArrowFunction(t)||o.isFunctionExpression(t))?"unknown":h(t)},j=r=>{const e=c(r,"owner");if(!e||!o.isPropertyAssignment(e))return;const t=e.getInitializer();return t&&o.isStringLiteral(t)?t.getLiteralValue():void 0},R=r=>{const e=[];for(const t of r.getVariableDeclarations()){if(!t.isExported())continue;const i=t.getInitializer();if(i?.getKind()!==l.CallExpression)continue;const n=i,s=n.getExpression();if(!N(s))continue;const a=t.getNameNode();if(!o.isIdentifier(a))throw I(a,"defineMutator exports must be plain named exports (no destructuring)");const u=S(n);for(const v of b(t).filter(F=>D(F)))e.push({args:T(u),exportName:v,filePath:"mutators",line:n.getStartLineNumber(),owner:j(u),returnType:L(u)})}return e},J=(r,e)=>{const t=y(e,w);if(!E(t))return[];const i=r.getSourceFile(t)??r.addSourceFileAtPath(t),n=R(i);return n.sort((s,a)=>s.exportName.localeCompare(a.exportName)),n};export{w as MUTATORS_FILENAME,J as discoverMutators,N as isDefineMutatorCallee,S as mutatorLiteral,G as mutatorServerImplOf};
@@ -1,3 +1,3 @@
1
- import{m}from"./modules-DE0ksIeR.mjs";import{r as u}from"./json-data-Chfs2Cz5.mjs";import{validatorIrToJsonSchema as p,objectSchema as l,LUNORA_ERROR_CODES as d}from"./LUNORA_ERROR_CODES-D7AVT7qF.mjs";import{G as h}from"./shared-Cn7dMQ_u.mjs";import{s as i}from"./dispatch-namespace-DwTjD7BU.mjs";const R="1.3.2",g={description:"Result is TS-inferred from the function's return type (no `.output()` declared); best-effort — any JSON."},O=(e,r)=>e==="stream"?`Open the \`stream\` \`${r}\` over the Lunora WebSocket. It yields chunks rather than one result, so its \`result\` schema is a placeholder.`:`Invoke the \`${e}\` \`${r}\` over the Lunora RPC envelope (POST /_lunora/rpc, body \`{ "functionPath": "${r}", "args": { … } }\`).`,S=(e,r)=>{const o=`${i(e.filePath)}:${e.exportName}`;return{description:O(e.kind,o),errors:d.map((s,a)=>({code:-32e3-a,data:{code:s},message:s})),name:o,params:[{description:"The function's argument object (the RPC envelope's `args`).",name:"args",required:Object.keys(e.args).length>0,schema:l(e.args)}],result:{name:"result",schema:e.output&&e.kind!=="stream"?p(e.output):g},summary:`${e.kind}: ${o}`,"x-lunora-function-kind":e.kind,...e.description?{"x-lunora-description":e.description}:{},"x-tags":[{name:r}]}},v=e=>{const r=e.version??"0.0.0",n=e.functions.filter(t=>t.visibility!=="internal"),o=e.modules??[],s=n.map(t=>S(t,m(o,t.filePath))).toSorted((t,c)=>t.name.localeCompare(c.name));return{info:{description:"Auto-generated from @lunora/values-typed functions by @lunora/codegen. Do not edit — run `lunora codegen` to regenerate.",title:"Lunora RPC",version:r},methods:s,openrpc:R}},E=e=>`${JSON.stringify(v(e),void 0,2)}
1
+ import{m}from"./modules-BgublqiK.mjs";import{r as u}from"./json-data-Chfs2Cz5.mjs";import{validatorIrToJsonSchema as p,objectSchema as l,LUNORA_ERROR_CODES as d}from"./LUNORA_ERROR_CODES-D7AVT7qF.mjs";import{G as h}from"./shared-Cn7dMQ_u.mjs";import{s as i}from"./dispatch-namespace-DwTjD7BU.mjs";const R="1.3.2",g={description:"Result is TS-inferred from the function's return type (no `.output()` declared); best-effort — any JSON."},O=(e,r)=>e==="stream"?`Open the \`stream\` \`${r}\` over the Lunora WebSocket. It yields chunks rather than one result, so its \`result\` schema is a placeholder.`:`Invoke the \`${e}\` \`${r}\` over the Lunora RPC envelope (POST /_lunora/rpc, body \`{ "functionPath": "${r}", "args": { … } }\`).`,S=(e,r)=>{const o=`${i(e.filePath)}:${e.exportName}`;return{description:O(e.kind,o),errors:d.map((s,a)=>({code:-32e3-a,data:{code:s},message:s})),name:o,params:[{description:"The function's argument object (the RPC envelope's `args`).",name:"args",required:Object.keys(e.args).length>0,schema:l(e.args)}],result:{name:"result",schema:e.output&&e.kind!=="stream"?p(e.output):g},summary:`${e.kind}: ${o}`,"x-lunora-function-kind":e.kind,...e.description?{"x-lunora-description":e.description}:{},"x-tags":[{name:r}]}},v=e=>{const r=e.version??"0.0.0",n=e.functions.filter(t=>t.visibility!=="internal"),o=e.modules??[],s=n.map(t=>S(t,m(o,t.filePath))).toSorted((t,c)=>t.name.localeCompare(c.name));return{info:{description:"Auto-generated from @lunora/values-typed functions by @lunora/codegen. Do not edit — run `lunora codegen` to regenerate.",title:"Lunora RPC",version:r},methods:s,openrpc:R}},E=e=>`${JSON.stringify(v(e),void 0,2)}
2
2
  `,N=e=>`${h}export const openRpcSpec = ${u(e,"Record<string, unknown>")};
3
3
  `;export{R as OPENRPC_VERSION,v as buildOpenRpcDocument,E as emitOpenRpc,N as emitOpenRpcModule};
@@ -1 +1 @@
1
- import{existsSync as x}from"node:fs";import{join as f}from"node:path";import{LunoraError as b}from"@lunora/errors";import{queueDefaultName as q,queueBindingName as y}from"@lunora/queue";import{SyntaxKind as S,Node as u}from"ts-morph";import{diagnosticAt as c}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{lunoraRelativePath as g,findObjectProperty as l,stringPropertyFor as w}from"./isTestPath-ClgKgMYM.mjs";import{a as v}from"./attribution-DjweYNgJ.mjs";import{r as $}from"./handler-reference-D2EE2q-4.mjs";import{d as F}from"./modules-DE0ksIeR.mjs";const h="queues.ts",P=o=>{const e=t=>t==="defineQueue"||t==="defineSubscription"||t==="defineTopic",i=o.getSymbol();if(!i){const t=o.getText();return e(t)?t:void 0}for(const t of i.getDeclarations()){if(!u.isImportSpecifier(t))continue;if(t.getImportDeclaration().getModuleSpecifierValue()!=="@lunora/queue")return;const n=t.getNameNode().getText();return e(n)?n:void 0}},d=w("queue"),E=(o,e,i)=>{if(u.isNumericLiteral(o))return o.getLiteralValue();throw c(o,`queue "${e}": \`${i}\` must be a static numeric literal — it is deploy configuration codegen writes into wrangler.jsonc`)},I={maxBatchSize:{integer:!0,max:100,min:1},maxBatchTimeout:{integer:!1,max:60,min:0},maxConcurrency:{integer:!0,max:250,min:1},maxRetries:{integer:!0,max:100,min:0},retryDelay:{integer:!0,max:86400,min:0}},A=(o,e)=>{const i={};for(const[t,n]of Object.entries(I)){const r=l(o,t);if(r&&u.isPropertyAssignment(r)){const a=E(r.getInitializerOrThrow(),e,t);if(a<n.min||a>n.max||n.integer&&!Number.isInteger(a))throw c(r,`queue "${e}": \`${t}\` must be ${n.integer?"an integer":"a number"} from ${n.min.toString()} to ${n.max.toString()} (got ${a.toString()})`);i[t]=a}}return i},T=(o,e)=>{const i=l(o,"name");if(!i||!u.isPropertyAssignment(i))return;const t=d(i.getInitializerOrThrow(),e,"name");if(t.length===0)throw c(i,`queue "${e}": \`name\` must be a non-empty string when provided`);return t},N=(o,e,i,t)=>{const n=$(l(o,"handler"),t)?.site,r={bindingName:y(e),exportName:e,filePath:g(t,o.getSourceFile().getFilePath()),mode:"push",name:T(o,e)??q(e),...i===void 0?{}:{topic:i},...n===void 0?{}:{handlerSite:n},tuning:{}},a=l(o,"mode");if(a&&u.isPropertyAssignment(a)){if(i!==void 0)throw c(a,`subscription "${e}": \`mode\` is not allowed — a subscription is always a push consumer`);const m=d(a.getInitializerOrThrow(),e,"mode");if(m!=="push"&&m!=="pull")throw c(a,`queue "${e}": \`mode\` must be "push" or "pull" (got ${JSON.stringify(m)})`);r.mode=m}const s=l(o,"deadLetterQueue");return s&&u.isPropertyAssignment(s)&&(r.tuning.deadLetterQueue=d(s.getInitializerOrThrow(),e,"deadLetterQueue")),Object.assign(r.tuning,A(o,e)),r},O=(o,e,i)=>{const t=o.getArguments()[0];if(!t||!u.isObjectLiteralExpression(t))throw c(o,`queue "${e}": defineQueue must be passed an inline object literal`);return N(t,e,void 0,i)},p=(o,e)=>`${o}:${e}`,Q=o=>{const e=o.getSymbol(),i=(e?.isAlias()===!0?e.getAliasedSymbol():e)?.getDeclarations()[0];return i!==void 0&&u.isVariableDeclaration(i)?p(i.getSourceFile().getFilePath(),i.getName()):p(o.getSourceFile().getFilePath(),o.getText())},L=(o,e,i,t)=>{const[n,r]=o.getArguments(),a=n!==void 0&&u.isIdentifier(n)?i.get(Q(n)):void 0;if(a===void 0)throw c(n??o,`subscription "${e}": the first argument must name a \`defineTopic()\` export of lunora/queues.ts or a module's queues.ts`);if(!r||!u.isObjectLiteralExpression(r))throw c(o,`subscription "${e}": defineSubscription must be passed an inline object literal`);return N(r,e,a,t)},U=o=>{const e=[];for(const i of o.getVariableDeclarations()){const t=i.getInitializer();if(t?.getKind()!==S.CallExpression)continue;const n=t,r=n.getExpression(),a=u.isIdentifier(r)?P(r):void 0;if(a===void 0)continue;const s=i.getNameNode();if(!u.isIdentifier(s)){if(i.getVariableStatement()?.hasExportKeyword()!==!0)continue;throw c(s,`${a} exports must be plain named exports (no destructuring)`)}const m=v(i,"binding");m!==void 0&&e.push({call:n,exportName:m,factory:a,localName:s.getText()})}return e},C=(o,e)=>{const i=new Map;for(const t of o){const n=g(e,t.call.getSourceFile().getFilePath()),r=i.get(t.exportName);if(r!==void 0)throw c(t.call,`"${t.exportName}" is exported by both lunora/${r}.ts and lunora/${n}.ts — queue and topic export names must be unique across the app`);i.set(t.exportName,n)}},M=(o,e)=>{const i=o.flatMap(s=>U(s));C(i,e);const t=i.filter(s=>s.factory==="defineTopic"),n=new Map(t.map(s=>[p(s.call.getSourceFile().getFilePath(),s.localName),s.exportName])),r=[];for(const s of i)s.factory==="defineQueue"?r.push(O(s.call,s.exportName,e)):s.factory==="defineSubscription"&&r.push(L(s.call,s.exportName,n,e));const a=t.map(s=>({exportName:s.exportName,filePath:g(e,s.call.getSourceFile().getFilePath())}));return{queues:r,topics:a}},j=(o,e)=>[f(e,h),...F(o,e).map(i=>f(e,i.name,h))].filter(i=>x(i)),z=o=>{const e=new Map,i=new Map;for(const t of o){const n=e.get(t.name);if(n!==void 0)throw new b("DUPLICATE_QUEUE_NAME",`Duplicate queue name "${t.name}": produced by both "${n}" and "${t.exportName}". Deployed queue names must be unique across the project.`,{status:500});e.set(t.name,t.exportName);const r=i.get(t.bindingName);if(r!==void 0)throw new b("DUPLICATE_QUEUE_BINDING",`Duplicate queue binding "${t.bindingName}": produced by both "${r}" and "${t.exportName}". Queue export names must yield unique binding names.`,{status:500});i.set(t.bindingName,t.exportName)}},D=(o,e)=>{const i=j(o,e).map(a=>o.getSourceFile(a)??o.addSourceFileAtPath(a)),{queues:t,topics:n}=M(i,e),r=t.toSorted((a,s)=>a.exportName.localeCompare(s.exportName));return z(r),{queues:r,topics:n.toSorted((a,s)=>a.exportName.localeCompare(s.exportName))}},X=(o,e)=>D(o,e).queues;export{h as QUEUES_FILENAME,D as discoverQueueDeclarations,X as discoverQueues};
1
+ import{existsSync as x}from"node:fs";import{join as f}from"node:path";import{LunoraError as b}from"@lunora/errors";import{queueDefaultName as q,queueBindingName as y}from"@lunora/queue";import{SyntaxKind as S,Node as u}from"ts-morph";import{diagnosticAt as c}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{lunoraRelativePath as g,findObjectProperty as l,stringPropertyFor as w}from"./isTestPath-B357_sbh.mjs";import{a as v}from"./attribution-C6VQNs-V.mjs";import{r as $}from"./handler-reference-BqSXtjJ6.mjs";import{d as F}from"./modules-BgublqiK.mjs";const h="queues.ts",P=o=>{const e=t=>t==="defineQueue"||t==="defineSubscription"||t==="defineTopic",i=o.getSymbol();if(!i){const t=o.getText();return e(t)?t:void 0}for(const t of i.getDeclarations()){if(!u.isImportSpecifier(t))continue;if(t.getImportDeclaration().getModuleSpecifierValue()!=="@lunora/queue")return;const n=t.getNameNode().getText();return e(n)?n:void 0}},d=w("queue"),E=(o,e,i)=>{if(u.isNumericLiteral(o))return o.getLiteralValue();throw c(o,`queue "${e}": \`${i}\` must be a static numeric literal — it is deploy configuration codegen writes into wrangler.jsonc`)},I={maxBatchSize:{integer:!0,max:100,min:1},maxBatchTimeout:{integer:!1,max:60,min:0},maxConcurrency:{integer:!0,max:250,min:1},maxRetries:{integer:!0,max:100,min:0},retryDelay:{integer:!0,max:86400,min:0}},A=(o,e)=>{const i={};for(const[t,n]of Object.entries(I)){const r=l(o,t);if(r&&u.isPropertyAssignment(r)){const a=E(r.getInitializerOrThrow(),e,t);if(a<n.min||a>n.max||n.integer&&!Number.isInteger(a))throw c(r,`queue "${e}": \`${t}\` must be ${n.integer?"an integer":"a number"} from ${n.min.toString()} to ${n.max.toString()} (got ${a.toString()})`);i[t]=a}}return i},T=(o,e)=>{const i=l(o,"name");if(!i||!u.isPropertyAssignment(i))return;const t=d(i.getInitializerOrThrow(),e,"name");if(t.length===0)throw c(i,`queue "${e}": \`name\` must be a non-empty string when provided`);return t},N=(o,e,i,t)=>{const n=$(l(o,"handler"),t)?.site,r={bindingName:y(e),exportName:e,filePath:g(t,o.getSourceFile().getFilePath()),mode:"push",name:T(o,e)??q(e),...i===void 0?{}:{topic:i},...n===void 0?{}:{handlerSite:n},tuning:{}},a=l(o,"mode");if(a&&u.isPropertyAssignment(a)){if(i!==void 0)throw c(a,`subscription "${e}": \`mode\` is not allowed — a subscription is always a push consumer`);const m=d(a.getInitializerOrThrow(),e,"mode");if(m!=="push"&&m!=="pull")throw c(a,`queue "${e}": \`mode\` must be "push" or "pull" (got ${JSON.stringify(m)})`);r.mode=m}const s=l(o,"deadLetterQueue");return s&&u.isPropertyAssignment(s)&&(r.tuning.deadLetterQueue=d(s.getInitializerOrThrow(),e,"deadLetterQueue")),Object.assign(r.tuning,A(o,e)),r},O=(o,e,i)=>{const t=o.getArguments()[0];if(!t||!u.isObjectLiteralExpression(t))throw c(o,`queue "${e}": defineQueue must be passed an inline object literal`);return N(t,e,void 0,i)},p=(o,e)=>`${o}:${e}`,Q=o=>{const e=o.getSymbol(),i=(e?.isAlias()===!0?e.getAliasedSymbol():e)?.getDeclarations()[0];return i!==void 0&&u.isVariableDeclaration(i)?p(i.getSourceFile().getFilePath(),i.getName()):p(o.getSourceFile().getFilePath(),o.getText())},L=(o,e,i,t)=>{const[n,r]=o.getArguments(),a=n!==void 0&&u.isIdentifier(n)?i.get(Q(n)):void 0;if(a===void 0)throw c(n??o,`subscription "${e}": the first argument must name a \`defineTopic()\` export of lunora/queues.ts or a module's queues.ts`);if(!r||!u.isObjectLiteralExpression(r))throw c(o,`subscription "${e}": defineSubscription must be passed an inline object literal`);return N(r,e,a,t)},U=o=>{const e=[];for(const i of o.getVariableDeclarations()){const t=i.getInitializer();if(t?.getKind()!==S.CallExpression)continue;const n=t,r=n.getExpression(),a=u.isIdentifier(r)?P(r):void 0;if(a===void 0)continue;const s=i.getNameNode();if(!u.isIdentifier(s)){if(i.getVariableStatement()?.hasExportKeyword()!==!0)continue;throw c(s,`${a} exports must be plain named exports (no destructuring)`)}const m=v(i,"binding");m!==void 0&&e.push({call:n,exportName:m,factory:a,localName:s.getText()})}return e},C=(o,e)=>{const i=new Map;for(const t of o){const n=g(e,t.call.getSourceFile().getFilePath()),r=i.get(t.exportName);if(r!==void 0)throw c(t.call,`"${t.exportName}" is exported by both lunora/${r}.ts and lunora/${n}.ts — queue and topic export names must be unique across the app`);i.set(t.exportName,n)}},M=(o,e)=>{const i=o.flatMap(s=>U(s));C(i,e);const t=i.filter(s=>s.factory==="defineTopic"),n=new Map(t.map(s=>[p(s.call.getSourceFile().getFilePath(),s.localName),s.exportName])),r=[];for(const s of i)s.factory==="defineQueue"?r.push(O(s.call,s.exportName,e)):s.factory==="defineSubscription"&&r.push(L(s.call,s.exportName,n,e));const a=t.map(s=>({exportName:s.exportName,filePath:g(e,s.call.getSourceFile().getFilePath())}));return{queues:r,topics:a}},j=(o,e)=>[f(e,h),...F(o,e).map(i=>f(e,i.name,h))].filter(i=>x(i)),z=o=>{const e=new Map,i=new Map;for(const t of o){const n=e.get(t.name);if(n!==void 0)throw new b("DUPLICATE_QUEUE_NAME",`Duplicate queue name "${t.name}": produced by both "${n}" and "${t.exportName}". Deployed queue names must be unique across the project.`,{status:500});e.set(t.name,t.exportName);const r=i.get(t.bindingName);if(r!==void 0)throw new b("DUPLICATE_QUEUE_BINDING",`Duplicate queue binding "${t.bindingName}": produced by both "${r}" and "${t.exportName}". Queue export names must yield unique binding names.`,{status:500});i.set(t.bindingName,t.exportName)}},D=(o,e)=>{const i=j(o,e).map(a=>o.getSourceFile(a)??o.addSourceFileAtPath(a)),{queues:t,topics:n}=M(i,e),r=t.toSorted((a,s)=>a.exportName.localeCompare(s.exportName));return z(r),{queues:r,topics:n.toSorted((a,s)=>a.exportName.localeCompare(s.exportName))}},X=(o,e)=>D(o,e).queues;export{h as QUEUES_FILENAME,D as discoverQueueDeclarations,X as discoverQueues};