@lunora/codegen 1.0.0-alpha.273 → 1.0.0-alpha.275

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 (71) hide show
  1. package/dist/index.d.mts +79 -12
  2. package/dist/index.d.ts +79 -12
  3. package/dist/index.mjs +1 -1
  4. package/dist/packem_shared/{AGENTS_FILENAME-lBe4g_sU.mjs → AGENTS_FILENAME-NQIB6wh3.mjs} +1 -1
  5. package/dist/packem_shared/{CONTAINERS_FILENAME-CY43AXXN.mjs → CONTAINERS_FILENAME-CK3xJGwm.mjs} +1 -1
  6. package/dist/packem_shared/{FLAGS_FILENAME-DXltN9DD.mjs → FLAGS_FILENAME-DYMd1xqw.mjs} +1 -1
  7. package/dist/packem_shared/GENERATED_HEADER-D-P7ii4H.mjs +1 -0
  8. package/dist/packem_shared/{MUTATORS_FILENAME-BxRrG_s-.mjs → MUTATORS_FILENAME-BrEGrcPU.mjs} +1 -1
  9. package/dist/packem_shared/{NOTIFY_FILENAME-J5MGAkca.mjs → NOTIFY_FILENAME-B42rW2NJ.mjs} +1 -1
  10. package/dist/packem_shared/{OPENRPC_VERSION-B8RT1JYn.mjs → OPENRPC_VERSION-BaD2A2YR.mjs} +1 -1
  11. package/dist/packem_shared/{QUEUES_FILENAME-DeJw5eqU.mjs → QUEUES_FILENAME-Dj5yK34Z.mjs} +1 -1
  12. package/dist/packem_shared/SCHEMA_SNAPSHOT_FILENAME-DWriXOYw.mjs +11 -0
  13. package/dist/packem_shared/{SHAPES_FILENAME-CeBFuc8M.mjs → SHAPES_FILENAME-CVc2VCnS.mjs} +1 -1
  14. package/dist/packem_shared/{WORKFLOWS_FILENAME-B47AB5pc.mjs → WORKFLOWS_FILENAME-Ze98LsB3.mjs} +1 -1
  15. package/dist/packem_shared/{attribution-NRssTEkk.mjs → attribution-Dw35rOaJ.mjs} +1 -1
  16. package/dist/packem_shared/{buildOpenApiDocument-6VJGU6fU.mjs → buildOpenApiDocument-BjHdW7b2.mjs} +1 -1
  17. package/dist/packem_shared/{capabilitiesUsedBy-DARbl-4Z.mjs → capabilitiesUsedBy-FnnYmnSl.mjs} +1 -1
  18. package/dist/packem_shared/chain-nWiSr1yy.mjs +1 -0
  19. package/dist/packem_shared/{classify-procedure-call-BBKuBvKg.mjs → classify-procedure-call-DxuPQkJA.mjs} +1 -1
  20. package/dist/packem_shared/{context-property-calls-tlnXE-wv.mjs → context-property-calls-BLTVj9HH.mjs} +1 -1
  21. package/dist/packem_shared/{context-root-IuI71QkK.mjs → context-root-B04bYCE-.mjs} +1 -1
  22. package/dist/packem_shared/{database-calls-BFY_pIUf.mjs → database-calls-DWDtdDbS.mjs} +1 -1
  23. package/dist/packem_shared/{discoverAuthApiCalls-TA2a8bZI.mjs → discoverAuthApiCalls-XK_WCMDG.mjs} +1 -1
  24. package/dist/packem_shared/discoverCrons-B5bVCaNF.mjs +1 -0
  25. package/dist/packem_shared/{discoverFunctions-4sef11AC.mjs → discoverFunctions-Be-XuuSW.mjs} +1 -1
  26. package/dist/packem_shared/{discoverHttpRoutes-CLGXL19M.mjs → discoverHttpRoutes-CMOxt2Y9.mjs} +1 -1
  27. package/dist/packem_shared/discoverHyperdriveCalls-mrho5AnY.mjs +1 -0
  28. package/dist/packem_shared/{discoverInserts-CKEO1mZZ.mjs → discoverInserts-BhIpUWXN.mjs} +1 -1
  29. package/dist/packem_shared/discoverMaskProcedures-DCw165tP.mjs +1 -0
  30. package/dist/packem_shared/{discoverMigrations-DYQbnqow.mjs → discoverMigrations-dVVZtuJa.mjs} +1 -1
  31. package/dist/packem_shared/{discoverNondeterministicCalls-BfdM93-8.mjs → discoverNondeterministicCalls-Dtb1aoGV.mjs} +1 -1
  32. package/dist/packem_shared/{discoverQueries-DEkIMaBP.mjs → discoverQueries-BSOjEsk3.mjs} +1 -1
  33. package/dist/packem_shared/discoverR2sqlCalls-KONCqZr2.mjs +1 -0
  34. package/dist/packem_shared/{discoverRlsMetadata-rpiO4wSi.mjs → discoverRlsMetadata-9YDlDDoh.mjs} +1 -1
  35. package/dist/packem_shared/{discoverRlsProcedures-BtT8-r93.mjs → discoverRlsProcedures-c0DnIR4z.mjs} +1 -1
  36. package/dist/packem_shared/{discoverSandboxUsage-B8P9QjWZ.mjs → discoverSandboxUsage-CfEU2hM-.mjs} +1 -1
  37. package/dist/packem_shared/{discoverSchema-BdmC-kO2.mjs → discoverSchema-BTFFWy3i.mjs} +1 -1
  38. package/dist/packem_shared/{discoverStorageRulesMetadata-C2hYksmI.mjs → discoverStorageRulesMetadata-f89BWody.mjs} +1 -1
  39. package/dist/packem_shared/{emitAgents-CzxW-qj5.mjs → emitAgents-CG2R-Zz6.mjs} +1 -1
  40. package/dist/packem_shared/{emitApi-xDIHPRPH.mjs → emitApi-zY6egN77.mjs} +44 -63
  41. package/dist/packem_shared/{emitApp-BdVXkH7A.mjs → emitApp-DUGS6Ve2.mjs} +1 -1
  42. package/dist/packem_shared/{emitCrons-DKeoaeqU.mjs → emitCrons-B8TBAOZ4.mjs} +1 -1
  43. package/dist/packem_shared/{emitDataModel-DSk9AkJe.mjs → emitDataModel-B68T_eX6.mjs} +5 -5
  44. package/dist/packem_shared/{emitDrizzleSchema-DohtnI8c.mjs → emitDrizzleSchema-DLtfKTI4.mjs} +2 -2
  45. package/dist/packem_shared/{emitFunctions-evl8Mx1a.mjs → emitFunctions-DkkcTDqh.mjs} +39 -47
  46. package/dist/packem_shared/emitServer-BbjIwe2-.mjs +1 -0
  47. package/dist/packem_shared/{emitShard-tQej36w1.mjs → emitShard-CSLqD-Hr.mjs} +1 -1
  48. package/dist/packem_shared/{exported-procedure-chains-DqU-ZCbG.mjs → exported-procedure-chains-C5VKkd9T.mjs} +1 -1
  49. package/dist/packem_shared/{fingerprintSchemaSources-ChYfrghz.mjs → fingerprintSchemaSources-BJSIxwhY.mjs} +1 -1
  50. package/dist/packem_shared/{handler-reference-B3coD2YR.mjs → handler-reference-2Hs4WKnz.mjs} +1 -1
  51. package/dist/packem_shared/{index-CRO3TRxd.mjs → index-CefI-Sba.mjs} +1 -1
  52. package/dist/packem_shared/isTestPath-CgyyLk8U.mjs +1 -0
  53. package/dist/packem_shared/{modules-6EEBTEDo.mjs → modules-BIpFLz3Z.mjs} +1 -1
  54. package/dist/packem_shared/paths-DwTjD7BU.mjs +1 -0
  55. package/dist/packem_shared/{qualifiers-Cw8dEDbh.mjs → qualifiers-COHdrghK.mjs} +1 -1
  56. package/dist/packem_shared/{emitServer-BSMUAt0o.mjs → server-BmY5wwKY.mjs} +56 -56
  57. package/dist/packem_shared/{shard-C1ZGdOG1.mjs → shard-Dr5gMNyz.mjs} +1 -1
  58. package/dist/packem_shared/{shard-runtime-DGrBvQWg.mjs → shard-runtime-BI2SZ54Z.mjs} +1 -1
  59. package/dist/packem_shared/shared-Be3TGzxM.mjs +13 -0
  60. package/dist/packem_shared/{unwrap-handler-return-Dy8h5-I6.mjs → unwrap-handler-return-T5sJhEss.mjs} +1 -1
  61. package/package.json +4 -4
  62. package/dist/packem_shared/GENERATED_HEADER-dFyrHgQ0.mjs +0 -1
  63. package/dist/packem_shared/SCHEMA_SNAPSHOT_FILENAME-DHYzuzTc.mjs +0 -11
  64. package/dist/packem_shared/chain-6qc9c0JF.mjs +0 -1
  65. package/dist/packem_shared/discoverCrons-PQeDYVPc.mjs +0 -1
  66. package/dist/packem_shared/discoverHyperdriveCalls-imtma-ic.mjs +0 -1
  67. package/dist/packem_shared/discoverMaskProcedures-Cr6hDinL.mjs +0 -1
  68. package/dist/packem_shared/discoverR2sqlCalls-BRIyb8Cl.mjs +0 -1
  69. package/dist/packem_shared/isTestPath-DCyIyPa7.mjs +0 -1
  70. package/dist/packem_shared/paths-C-9fwEgQ.mjs +0 -1
  71. package/dist/packem_shared/shared-BXUKWh7t.mjs +0 -9
package/dist/index.d.mts CHANGED
@@ -7,6 +7,58 @@ import { Schema } from '@lunora/server';
7
7
  import { JsonSchema } from '@lunora/values';
8
8
  import { LanguageName } from 'quicktype-core';
9
9
  import { StudioFeaturesResult } from '@lunora/shard-engine';
10
+ /**
11
+ * The architecture manifest — `_generated/architecture.json` — shared by the
12
+ * codegen that builds it, the runtime that serves it at
13
+ * `GET /_lunora/admin/architecture`, the client that fetches it and the studio
14
+ * that draws it. Also the one place the module-membership rule lives.
15
+ *
16
+ * Bundler-inlined `shared/` source: zero dependencies, named exports only.
17
+ */
18
+ /** The resources a node can stand for. */
19
+ type ArchitectureNodeKind = "cron" | "function" | "http" | "queue" | "service" | "table" | "topic" | "workflow";
20
+ /** How two nodes relate. */
21
+ type ArchitectureEdgeKind = "call" | "enqueue" | "invoke" | "publish" | "read" | "schedule" | "start" | "subscribe" | "trigger" | "write";
22
+ interface ArchitectureNode {
23
+ /** Short qualifier: a function's kind (`query`, …), `subscription` for a topic's queue, a cron's schedule. */
24
+ detail?: string;
25
+ /** Stable id, `<kind>:<identity>` (`function:billing_invoices:create`, `table:invoices`). */
26
+ id: string;
27
+ kind: ArchitectureNodeKind;
28
+ /** Display name: the `api.*` path, the route, the table or export name. */
29
+ name: string;
30
+ /** The owning module; absent for a node outside every module. */
31
+ module?: string;
32
+ }
33
+ interface ArchitectureEdge {
34
+ from: string;
35
+ kind: ArchitectureEdgeKind;
36
+ to: string;
37
+ }
38
+ /** An edge codegen found but could not attach to the graph. */
39
+ interface UnresolvedEdge {
40
+ /** `lunora/`-relative file of the call site. */
41
+ file: string;
42
+ kind: ArchitectureEdgeKind;
43
+ line: number;
44
+ reason: string;
45
+ }
46
+ interface ArchitectureModule {
47
+ description?: string;
48
+ /** `true` for an installed component (a schema extension) shown as a module. */
49
+ installed?: true;
50
+ /** `false` for a package component: it owns its tables but no `lunora/<name>/` folder (see {@link moduleOf}). */
51
+ ownsFolder?: false;
52
+ name: string;
53
+ tables: string[];
54
+ }
55
+ interface ArchitectureManifest {
56
+ edges: ArchitectureEdge[];
57
+ nodes: ArchitectureNode[];
58
+ modules: ArchitectureModule[];
59
+ unresolved: UnresolvedEdge[];
60
+ version: 1;
61
+ }
10
62
  /** Current snapshot format version. Bumped if the structural shape below changes. */
11
63
  declare const SCHEMA_SNAPSHOT_VERSION: 1;
12
64
  /**
@@ -3076,6 +3128,12 @@ interface CodegenResult {
3076
3128
  * so this adds no binding or migration. Empty when the project declares none.
3077
3129
  */
3078
3130
  agents: ReadonlyArray<AgentIR>;
3131
+ /**
3132
+ * The architecture manifest written to `_generated/architecture.json` —
3133
+ * `lunora deploy` diffs it against the last deployed one. `undefined` when the
3134
+ * app declares no module.
3135
+ */
3136
+ architecture?: ArchitectureManifest;
3079
3137
  /**
3080
3138
  * Containers discovered from `defineContainer` exports in
3081
3139
  * `lunora/containers.ts` — the list the config layer reconciles into
@@ -3104,6 +3162,8 @@ interface CodegenResult {
3104
3162
  drizzleGlobal: string;
3105
3163
  drizzleShard: string;
3106
3164
  functions: string;
3165
+ /** `internal.*` references to the internal functions (`_generated/internal.ts`), kept out of `api.ts` so a client bundle never carries them. */
3166
+ internal: string;
3107
3167
  /** OpenAPI 3.1.0 document (`_generated/openapi.json`), pretty-printed JSON. */
3108
3168
  openApi: string;
3109
3169
  /**
@@ -3496,14 +3556,6 @@ declare const WORKFLOWS_FILENAME = "workflows.ts";
3496
3556
  * runtime-only, so codegen never evaluates it.
3497
3557
  */
3498
3558
  declare const discoverWorkflows: (project: Project, lunoraDirectory: string) => WorkflowIR[];
3499
- /**
3500
- * Emit `_generated/api.ts` — the typed `api.*` registry (public functions), the
3501
- * `internal.*` registry, and (when the project declares them) the typed
3502
- * `workflows.*` / `agents.*` scheduler-target reference objects. `api`/`internal` are the same `anyApi` proxy
3503
- * at runtime (the `__lunoraRef` is identical); visibility is enforced
3504
- * server-side at dispatch, not in the reference. Splitting the *types* keeps
3505
- * internal functions off the client-facing `api` surface.
3506
- */
3507
3559
  interface EmitApiOptions {
3508
3560
  agents?: ReadonlyArray<AgentIR>;
3509
3561
  functions: ReadonlyArray<FunctionIR>;
@@ -3514,7 +3566,24 @@ interface EmitApiOptions {
3514
3566
  useUmbrella?: boolean;
3515
3567
  workflows?: ReadonlyArray<WorkflowIR>;
3516
3568
  }
3569
+ /**
3570
+ * Emit `_generated/api.ts` — the `api.*` references to the public functions,
3571
+ * and (when the project declares them) the typed `workflows.*` / `agents.*`
3572
+ * scheduler-target reference objects and the `httpStreams.*` SSE routes.
3573
+ * Internal functions live in `_generated/internal.ts` ({@link emitInternalApi}),
3574
+ * so a client bundle that imports `api` never carries their names.
3575
+ */
3517
3576
  declare const emitApi: (options: EmitApiOptions) => string;
3577
+ /**
3578
+ * Emit `_generated/internal.ts` — the `internal.*` references, callable only
3579
+ * server-side via `ctx.run*` / the scheduler. Visibility is enforced at
3580
+ * dispatch; keeping them in their own module keeps their names out of any
3581
+ * client bundle that imports `api`.
3582
+ */
3583
+ declare const emitInternalApi: (options: {
3584
+ functions: ReadonlyArray<FunctionIR>;
3585
+ useUmbrella?: boolean;
3586
+ }) => string;
3518
3587
  /**
3519
3588
  * Emit `_generated/collections.ts` — a typed TanStack DB binding per `defineShape`
3520
3589
  * in `lunora/shapes.ts` (the local-first partial-replication surface).
@@ -3657,8 +3726,6 @@ interface EmitServerOptions {
3657
3726
  * the base optional binding record — byte-identical to today.
3658
3727
  */
3659
3728
  env?: EnvIR;
3660
- /** Absolute `_generated/` directory, so an RPC service's entry module is imported by a path relative to it. Required with `services`. */
3661
- generatedDirectory?: string;
3662
3729
  /** The project declares `lunora/flags.ts` — wires `ctx.flags` (OpenFeature) onto every ctx. */
3663
3730
  hasFlags?: boolean;
3664
3731
  /** The project declares `lunora/notify.ts` — wires `ctx.notify` + its `ctx.push` alias (`@lunora/notify`) onto every ctx. */
@@ -3686,7 +3753,7 @@ interface EmitServerOptions {
3686
3753
  useUmbrella?: boolean;
3687
3754
  workflows?: ReadonlyArray<WorkflowIR>;
3688
3755
  }
3689
- declare const emitServer: ({ agents, capabilities, containers, env, hasVectors, hasFlags, hasNotify, identity, queues, schema, generatedDirectory, services, storageRuleBuckets, topics, useUmbrella, workflows }?: EmitServerOptions) => string;
3756
+ declare const emitServer: ({ agents, capabilities, containers, env, hasVectors, hasFlags, hasNotify, identity, queues, schema, services, storageRuleBuckets, topics, useUmbrella, workflows }?: EmitServerOptions) => string;
3690
3757
  interface EmitShardOptions {
3691
3758
  advisories?: ReadonlyArray<Finding>;
3692
3759
  /** Every declared procedure — the health map's denominator, served via `getAdvisorProcedures`. */
@@ -4572,4 +4639,4 @@ declare const secretKindOf: (value: string) => string | undefined;
4572
4639
  /** A redacted preview of a secret value — first 4 chars plus its length, never the full value. */
4573
4640
  declare const redact: (value: string) => string;
4574
4641
  declare const VERSION = "0.0.0";
4575
- export { AGENTS_FILENAME, type AgentIR, type AuthApiCallIR, CAPABILITY_PROBES, 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 FieldSnapshot, type FlagsIR, type FunctionIR, GENERATED_HEADER, type HttpRouteIR, type IndexIR, type IndexSnapshot, type InsertWriteIR, LUNORA_ERROR_CODES, type LintSchemaOptions, type LoadedProjectConfig, type LunoraProjectConfig, MUTATORS_FILENAME, type MaskProcedureIR, type MigrationIR, type MutatorIR, NOTIFY_FILENAME, OPENRPC_VERSION, type OpenApiEmitInput, type OpenRpcDocument, type OpenRpcEmitInput, type OpenRpcMethod, PROJECT_CONFIG_FILENAMES, type PlatformDiagnostic, type ProjectConfigLiterals, type ProjectIR, QUEUES_FILENAME, type QueryReadIR, type QueueIR, type RelationSnapshot, type RlsMetadataIR, type RlsPolicyIR, type RlsProcedureIR, type RlsRoleIR, type RuntimeVerb, SCHEMA_SNAPSHOT_FILENAME, SCHEMA_SNAPSHOT_VERSION, SDK_LANGUAGES, SDK_TARGETS, SHAPES_FILENAME, type SandboxUsage, type SchemaDrift, type SchemaDriftDecision, type SchemaIR, type SchemaSnapshot, SchemaSnapshotParseError, type SdkFiles, type SdkMethod, type SdkNamespace, type SdkRenderInput, type SdkResult, type SdkTarget, type ServiceBindingIR, type ServiceLiteral, type ShapeIR, type SourceCapabilitySignals, type StorageRuleIR, type StorageRulesMetadataIR, type TableIR, type TableSnapshot, type TopicIR, VERSION, type ValidatorIR, type VectorIndexIR, WORKFLOWS_FILENAME, type WorkflowIR, type WranglerVariableIR, buildOpenApiDocument, buildOpenRpcDocument, buildSchemaSnapshot, capabilitiesUsedBy, createCodegenProject, describeErrorLevelFindings, diagnosticAt, diffSchemaSnapshots, discoverAgents, discoverAuthApiCalls, discoverContainers, discoverCrons, discoverFlags, discoverFunctions, discoverHttpRoutes, discoverHyperdriveCalls, discoverInserts, discoverMaskProcedures, discoverMigrations, discoverMutators, discoverNondeterministicCalls, discoverNotifyCalls, discoverNotifyConfig, discoverQueries, discoverQueues, discoverR2sqlCalls, discoverRlsMetadata, discoverRlsProcedures, discoverSandboxUsage, discoverSchema, discoverShapes, discoverStorageRulesMetadata, discoverWorkflows, emitAgents, emitApi, emitApp, emitCollections, emitContainers, emitCrons, emitDataModel, emitDrizzleSchema, emitFunctions, emitOpenApi, emitOpenApiModule, emitOpenRpc, emitOpenRpcModule, emitScheduler, emitServer, emitShard, emitVectors, emitWorkflows, emitWranglerCronTriggers, errorAdvisoryNames, errorPlatformDiagnosticNames, evaluateSchemaDrift, findProjectConfigFile, findTsconfig, fingerprintSchemaSources, foldCapabilitySignals, formatAdvisories, generateSdk, isD1GlobalTable, isHyperdriveGlobalTable, isTestPath, isTypedSchema, lintSchema, listLunoraSourceFiles, loadProjectConfig, mayReadCapabilityContext, parseSchemaSnapshot, platformMatrixIds, readPackageDependencies, readProjectConfigLiterals, readProjectTarget, readServiceBindings, redact, refreshCodegenProject, resolveCodegenTarget, resolveServiceBindings, runCodegen, schemaFromIr, secretKindOf, serializeSchemaSnapshot, sortedUniqueNames, sourceCapabilitySignals, toAdvisorContext, validatorIrToJsonSchema };
4642
+ export { AGENTS_FILENAME, type AgentIR, type ArchitectureManifest, type AuthApiCallIR, CAPABILITY_PROBES, 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 FieldSnapshot, type FlagsIR, type FunctionIR, GENERATED_HEADER, type HttpRouteIR, type IndexIR, type IndexSnapshot, type InsertWriteIR, LUNORA_ERROR_CODES, type LintSchemaOptions, type LoadedProjectConfig, type LunoraProjectConfig, MUTATORS_FILENAME, type MaskProcedureIR, type MigrationIR, type MutatorIR, NOTIFY_FILENAME, OPENRPC_VERSION, type OpenApiEmitInput, type OpenRpcDocument, type OpenRpcEmitInput, type OpenRpcMethod, PROJECT_CONFIG_FILENAMES, type PlatformDiagnostic, type ProjectConfigLiterals, type ProjectIR, QUEUES_FILENAME, type QueryReadIR, type QueueIR, type RelationSnapshot, type RlsMetadataIR, type RlsPolicyIR, type RlsProcedureIR, type RlsRoleIR, type RuntimeVerb, SCHEMA_SNAPSHOT_FILENAME, SCHEMA_SNAPSHOT_VERSION, SDK_LANGUAGES, SDK_TARGETS, SHAPES_FILENAME, type SandboxUsage, type SchemaDrift, type SchemaDriftDecision, type SchemaIR, type SchemaSnapshot, SchemaSnapshotParseError, type SdkFiles, type SdkMethod, type SdkNamespace, type SdkRenderInput, type SdkResult, type SdkTarget, type ServiceBindingIR, type ServiceLiteral, type ShapeIR, type SourceCapabilitySignals, type StorageRuleIR, type StorageRulesMetadataIR, type TableIR, type TableSnapshot, type TopicIR, VERSION, type ValidatorIR, type VectorIndexIR, WORKFLOWS_FILENAME, type WorkflowIR, type WranglerVariableIR, buildOpenApiDocument, buildOpenRpcDocument, buildSchemaSnapshot, capabilitiesUsedBy, createCodegenProject, describeErrorLevelFindings, diagnosticAt, diffSchemaSnapshots, discoverAgents, discoverAuthApiCalls, discoverContainers, discoverCrons, discoverFlags, discoverFunctions, discoverHttpRoutes, discoverHyperdriveCalls, discoverInserts, discoverMaskProcedures, discoverMigrations, discoverMutators, discoverNondeterministicCalls, discoverNotifyCalls, discoverNotifyConfig, discoverQueries, discoverQueues, discoverR2sqlCalls, discoverRlsMetadata, discoverRlsProcedures, discoverSandboxUsage, discoverSchema, discoverShapes, discoverStorageRulesMetadata, discoverWorkflows, emitAgents, emitApi, emitApp, emitCollections, emitContainers, emitCrons, emitDataModel, emitDrizzleSchema, emitFunctions, emitInternalApi, emitOpenApi, emitOpenApiModule, emitOpenRpc, emitOpenRpcModule, emitScheduler, emitServer, emitShard, emitVectors, emitWorkflows, emitWranglerCronTriggers, errorAdvisoryNames, errorPlatformDiagnosticNames, evaluateSchemaDrift, findProjectConfigFile, findTsconfig, fingerprintSchemaSources, foldCapabilitySignals, formatAdvisories, generateSdk, isD1GlobalTable, isHyperdriveGlobalTable, isTestPath, isTypedSchema, lintSchema, listLunoraSourceFiles, loadProjectConfig, mayReadCapabilityContext, parseSchemaSnapshot, platformMatrixIds, readPackageDependencies, readProjectConfigLiterals, readProjectTarget, readServiceBindings, redact, refreshCodegenProject, resolveCodegenTarget, resolveServiceBindings, runCodegen, schemaFromIr, secretKindOf, serializeSchemaSnapshot, sortedUniqueNames, sourceCapabilitySignals, toAdvisorContext, validatorIrToJsonSchema };
package/dist/index.d.ts CHANGED
@@ -7,6 +7,58 @@ import { Schema } from '@lunora/server';
7
7
  import { JsonSchema } from '@lunora/values';
8
8
  import { LanguageName } from 'quicktype-core';
9
9
  import { StudioFeaturesResult } from '@lunora/shard-engine';
10
+ /**
11
+ * The architecture manifest — `_generated/architecture.json` — shared by the
12
+ * codegen that builds it, the runtime that serves it at
13
+ * `GET /_lunora/admin/architecture`, the client that fetches it and the studio
14
+ * that draws it. Also the one place the module-membership rule lives.
15
+ *
16
+ * Bundler-inlined `shared/` source: zero dependencies, named exports only.
17
+ */
18
+ /** The resources a node can stand for. */
19
+ type ArchitectureNodeKind = "cron" | "function" | "http" | "queue" | "service" | "table" | "topic" | "workflow";
20
+ /** How two nodes relate. */
21
+ type ArchitectureEdgeKind = "call" | "enqueue" | "invoke" | "publish" | "read" | "schedule" | "start" | "subscribe" | "trigger" | "write";
22
+ interface ArchitectureNode {
23
+ /** Short qualifier: a function's kind (`query`, …), `subscription` for a topic's queue, a cron's schedule. */
24
+ detail?: string;
25
+ /** Stable id, `<kind>:<identity>` (`function:billing_invoices:create`, `table:invoices`). */
26
+ id: string;
27
+ kind: ArchitectureNodeKind;
28
+ /** Display name: the `api.*` path, the route, the table or export name. */
29
+ name: string;
30
+ /** The owning module; absent for a node outside every module. */
31
+ module?: string;
32
+ }
33
+ interface ArchitectureEdge {
34
+ from: string;
35
+ kind: ArchitectureEdgeKind;
36
+ to: string;
37
+ }
38
+ /** An edge codegen found but could not attach to the graph. */
39
+ interface UnresolvedEdge {
40
+ /** `lunora/`-relative file of the call site. */
41
+ file: string;
42
+ kind: ArchitectureEdgeKind;
43
+ line: number;
44
+ reason: string;
45
+ }
46
+ interface ArchitectureModule {
47
+ description?: string;
48
+ /** `true` for an installed component (a schema extension) shown as a module. */
49
+ installed?: true;
50
+ /** `false` for a package component: it owns its tables but no `lunora/<name>/` folder (see {@link moduleOf}). */
51
+ ownsFolder?: false;
52
+ name: string;
53
+ tables: string[];
54
+ }
55
+ interface ArchitectureManifest {
56
+ edges: ArchitectureEdge[];
57
+ nodes: ArchitectureNode[];
58
+ modules: ArchitectureModule[];
59
+ unresolved: UnresolvedEdge[];
60
+ version: 1;
61
+ }
10
62
  /** Current snapshot format version. Bumped if the structural shape below changes. */
11
63
  declare const SCHEMA_SNAPSHOT_VERSION: 1;
12
64
  /**
@@ -3076,6 +3128,12 @@ interface CodegenResult {
3076
3128
  * so this adds no binding or migration. Empty when the project declares none.
3077
3129
  */
3078
3130
  agents: ReadonlyArray<AgentIR>;
3131
+ /**
3132
+ * The architecture manifest written to `_generated/architecture.json` —
3133
+ * `lunora deploy` diffs it against the last deployed one. `undefined` when the
3134
+ * app declares no module.
3135
+ */
3136
+ architecture?: ArchitectureManifest;
3079
3137
  /**
3080
3138
  * Containers discovered from `defineContainer` exports in
3081
3139
  * `lunora/containers.ts` — the list the config layer reconciles into
@@ -3104,6 +3162,8 @@ interface CodegenResult {
3104
3162
  drizzleGlobal: string;
3105
3163
  drizzleShard: string;
3106
3164
  functions: string;
3165
+ /** `internal.*` references to the internal functions (`_generated/internal.ts`), kept out of `api.ts` so a client bundle never carries them. */
3166
+ internal: string;
3107
3167
  /** OpenAPI 3.1.0 document (`_generated/openapi.json`), pretty-printed JSON. */
3108
3168
  openApi: string;
3109
3169
  /**
@@ -3496,14 +3556,6 @@ declare const WORKFLOWS_FILENAME = "workflows.ts";
3496
3556
  * runtime-only, so codegen never evaluates it.
3497
3557
  */
3498
3558
  declare const discoverWorkflows: (project: Project, lunoraDirectory: string) => WorkflowIR[];
3499
- /**
3500
- * Emit `_generated/api.ts` — the typed `api.*` registry (public functions), the
3501
- * `internal.*` registry, and (when the project declares them) the typed
3502
- * `workflows.*` / `agents.*` scheduler-target reference objects. `api`/`internal` are the same `anyApi` proxy
3503
- * at runtime (the `__lunoraRef` is identical); visibility is enforced
3504
- * server-side at dispatch, not in the reference. Splitting the *types* keeps
3505
- * internal functions off the client-facing `api` surface.
3506
- */
3507
3559
  interface EmitApiOptions {
3508
3560
  agents?: ReadonlyArray<AgentIR>;
3509
3561
  functions: ReadonlyArray<FunctionIR>;
@@ -3514,7 +3566,24 @@ interface EmitApiOptions {
3514
3566
  useUmbrella?: boolean;
3515
3567
  workflows?: ReadonlyArray<WorkflowIR>;
3516
3568
  }
3569
+ /**
3570
+ * Emit `_generated/api.ts` — the `api.*` references to the public functions,
3571
+ * and (when the project declares them) the typed `workflows.*` / `agents.*`
3572
+ * scheduler-target reference objects and the `httpStreams.*` SSE routes.
3573
+ * Internal functions live in `_generated/internal.ts` ({@link emitInternalApi}),
3574
+ * so a client bundle that imports `api` never carries their names.
3575
+ */
3517
3576
  declare const emitApi: (options: EmitApiOptions) => string;
3577
+ /**
3578
+ * Emit `_generated/internal.ts` — the `internal.*` references, callable only
3579
+ * server-side via `ctx.run*` / the scheduler. Visibility is enforced at
3580
+ * dispatch; keeping them in their own module keeps their names out of any
3581
+ * client bundle that imports `api`.
3582
+ */
3583
+ declare const emitInternalApi: (options: {
3584
+ functions: ReadonlyArray<FunctionIR>;
3585
+ useUmbrella?: boolean;
3586
+ }) => string;
3518
3587
  /**
3519
3588
  * Emit `_generated/collections.ts` — a typed TanStack DB binding per `defineShape`
3520
3589
  * in `lunora/shapes.ts` (the local-first partial-replication surface).
@@ -3657,8 +3726,6 @@ interface EmitServerOptions {
3657
3726
  * the base optional binding record — byte-identical to today.
3658
3727
  */
3659
3728
  env?: EnvIR;
3660
- /** Absolute `_generated/` directory, so an RPC service's entry module is imported by a path relative to it. Required with `services`. */
3661
- generatedDirectory?: string;
3662
3729
  /** The project declares `lunora/flags.ts` — wires `ctx.flags` (OpenFeature) onto every ctx. */
3663
3730
  hasFlags?: boolean;
3664
3731
  /** The project declares `lunora/notify.ts` — wires `ctx.notify` + its `ctx.push` alias (`@lunora/notify`) onto every ctx. */
@@ -3686,7 +3753,7 @@ interface EmitServerOptions {
3686
3753
  useUmbrella?: boolean;
3687
3754
  workflows?: ReadonlyArray<WorkflowIR>;
3688
3755
  }
3689
- declare const emitServer: ({ agents, capabilities, containers, env, hasVectors, hasFlags, hasNotify, identity, queues, schema, generatedDirectory, services, storageRuleBuckets, topics, useUmbrella, workflows }?: EmitServerOptions) => string;
3756
+ declare const emitServer: ({ agents, capabilities, containers, env, hasVectors, hasFlags, hasNotify, identity, queues, schema, services, storageRuleBuckets, topics, useUmbrella, workflows }?: EmitServerOptions) => string;
3690
3757
  interface EmitShardOptions {
3691
3758
  advisories?: ReadonlyArray<Finding>;
3692
3759
  /** Every declared procedure — the health map's denominator, served via `getAdvisorProcedures`. */
@@ -4572,4 +4639,4 @@ declare const secretKindOf: (value: string) => string | undefined;
4572
4639
  /** A redacted preview of a secret value — first 4 chars plus its length, never the full value. */
4573
4640
  declare const redact: (value: string) => string;
4574
4641
  declare const VERSION = "0.0.0";
4575
- export { AGENTS_FILENAME, type AgentIR, type AuthApiCallIR, CAPABILITY_PROBES, 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 FieldSnapshot, type FlagsIR, type FunctionIR, GENERATED_HEADER, type HttpRouteIR, type IndexIR, type IndexSnapshot, type InsertWriteIR, LUNORA_ERROR_CODES, type LintSchemaOptions, type LoadedProjectConfig, type LunoraProjectConfig, MUTATORS_FILENAME, type MaskProcedureIR, type MigrationIR, type MutatorIR, NOTIFY_FILENAME, OPENRPC_VERSION, type OpenApiEmitInput, type OpenRpcDocument, type OpenRpcEmitInput, type OpenRpcMethod, PROJECT_CONFIG_FILENAMES, type PlatformDiagnostic, type ProjectConfigLiterals, type ProjectIR, QUEUES_FILENAME, type QueryReadIR, type QueueIR, type RelationSnapshot, type RlsMetadataIR, type RlsPolicyIR, type RlsProcedureIR, type RlsRoleIR, type RuntimeVerb, SCHEMA_SNAPSHOT_FILENAME, SCHEMA_SNAPSHOT_VERSION, SDK_LANGUAGES, SDK_TARGETS, SHAPES_FILENAME, type SandboxUsage, type SchemaDrift, type SchemaDriftDecision, type SchemaIR, type SchemaSnapshot, SchemaSnapshotParseError, type SdkFiles, type SdkMethod, type SdkNamespace, type SdkRenderInput, type SdkResult, type SdkTarget, type ServiceBindingIR, type ServiceLiteral, type ShapeIR, type SourceCapabilitySignals, type StorageRuleIR, type StorageRulesMetadataIR, type TableIR, type TableSnapshot, type TopicIR, VERSION, type ValidatorIR, type VectorIndexIR, WORKFLOWS_FILENAME, type WorkflowIR, type WranglerVariableIR, buildOpenApiDocument, buildOpenRpcDocument, buildSchemaSnapshot, capabilitiesUsedBy, createCodegenProject, describeErrorLevelFindings, diagnosticAt, diffSchemaSnapshots, discoverAgents, discoverAuthApiCalls, discoverContainers, discoverCrons, discoverFlags, discoverFunctions, discoverHttpRoutes, discoverHyperdriveCalls, discoverInserts, discoverMaskProcedures, discoverMigrations, discoverMutators, discoverNondeterministicCalls, discoverNotifyCalls, discoverNotifyConfig, discoverQueries, discoverQueues, discoverR2sqlCalls, discoverRlsMetadata, discoverRlsProcedures, discoverSandboxUsage, discoverSchema, discoverShapes, discoverStorageRulesMetadata, discoverWorkflows, emitAgents, emitApi, emitApp, emitCollections, emitContainers, emitCrons, emitDataModel, emitDrizzleSchema, emitFunctions, emitOpenApi, emitOpenApiModule, emitOpenRpc, emitOpenRpcModule, emitScheduler, emitServer, emitShard, emitVectors, emitWorkflows, emitWranglerCronTriggers, errorAdvisoryNames, errorPlatformDiagnosticNames, evaluateSchemaDrift, findProjectConfigFile, findTsconfig, fingerprintSchemaSources, foldCapabilitySignals, formatAdvisories, generateSdk, isD1GlobalTable, isHyperdriveGlobalTable, isTestPath, isTypedSchema, lintSchema, listLunoraSourceFiles, loadProjectConfig, mayReadCapabilityContext, parseSchemaSnapshot, platformMatrixIds, readPackageDependencies, readProjectConfigLiterals, readProjectTarget, readServiceBindings, redact, refreshCodegenProject, resolveCodegenTarget, resolveServiceBindings, runCodegen, schemaFromIr, secretKindOf, serializeSchemaSnapshot, sortedUniqueNames, sourceCapabilitySignals, toAdvisorContext, validatorIrToJsonSchema };
4642
+ export { AGENTS_FILENAME, type AgentIR, type ArchitectureManifest, type AuthApiCallIR, CAPABILITY_PROBES, 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 FieldSnapshot, type FlagsIR, type FunctionIR, GENERATED_HEADER, type HttpRouteIR, type IndexIR, type IndexSnapshot, type InsertWriteIR, LUNORA_ERROR_CODES, type LintSchemaOptions, type LoadedProjectConfig, type LunoraProjectConfig, MUTATORS_FILENAME, type MaskProcedureIR, type MigrationIR, type MutatorIR, NOTIFY_FILENAME, OPENRPC_VERSION, type OpenApiEmitInput, type OpenRpcDocument, type OpenRpcEmitInput, type OpenRpcMethod, PROJECT_CONFIG_FILENAMES, type PlatformDiagnostic, type ProjectConfigLiterals, type ProjectIR, QUEUES_FILENAME, type QueryReadIR, type QueueIR, type RelationSnapshot, type RlsMetadataIR, type RlsPolicyIR, type RlsProcedureIR, type RlsRoleIR, type RuntimeVerb, SCHEMA_SNAPSHOT_FILENAME, SCHEMA_SNAPSHOT_VERSION, SDK_LANGUAGES, SDK_TARGETS, SHAPES_FILENAME, type SandboxUsage, type SchemaDrift, type SchemaDriftDecision, type SchemaIR, type SchemaSnapshot, SchemaSnapshotParseError, type SdkFiles, type SdkMethod, type SdkNamespace, type SdkRenderInput, type SdkResult, type SdkTarget, type ServiceBindingIR, type ServiceLiteral, type ShapeIR, type SourceCapabilitySignals, type StorageRuleIR, type StorageRulesMetadataIR, type TableIR, type TableSnapshot, type TopicIR, VERSION, type ValidatorIR, type VectorIndexIR, WORKFLOWS_FILENAME, type WorkflowIR, type WranglerVariableIR, buildOpenApiDocument, buildOpenRpcDocument, buildSchemaSnapshot, capabilitiesUsedBy, createCodegenProject, describeErrorLevelFindings, diagnosticAt, diffSchemaSnapshots, discoverAgents, discoverAuthApiCalls, discoverContainers, discoverCrons, discoverFlags, discoverFunctions, discoverHttpRoutes, discoverHyperdriveCalls, discoverInserts, discoverMaskProcedures, discoverMigrations, discoverMutators, discoverNondeterministicCalls, discoverNotifyCalls, discoverNotifyConfig, discoverQueries, discoverQueues, discoverR2sqlCalls, discoverRlsMetadata, discoverRlsProcedures, discoverSandboxUsage, discoverSchema, discoverShapes, discoverStorageRulesMetadata, discoverWorkflows, emitAgents, emitApi, emitApp, emitCollections, emitContainers, emitCrons, emitDataModel, emitDrizzleSchema, emitFunctions, emitInternalApi, emitOpenApi, emitOpenApiModule, emitOpenRpc, emitOpenRpcModule, emitScheduler, emitServer, emitShard, emitVectors, emitWorkflows, emitWranglerCronTriggers, errorAdvisoryNames, errorPlatformDiagnosticNames, evaluateSchemaDrift, findProjectConfigFile, findTsconfig, fingerprintSchemaSources, foldCapabilitySignals, formatAdvisories, generateSdk, isD1GlobalTable, isHyperdriveGlobalTable, isTestPath, isTypedSchema, lintSchema, listLunoraSourceFiles, loadProjectConfig, mayReadCapabilityContext, parseSchemaSnapshot, platformMatrixIds, readPackageDependencies, readProjectConfigLiterals, readProjectTarget, readServiceBindings, redact, refreshCodegenProject, resolveCodegenTarget, resolveServiceBindings, runCodegen, schemaFromIr, secretKindOf, serializeSchemaSnapshot, sortedUniqueNames, sourceCapabilitySignals, toAdvisorContext, validatorIrToJsonSchema };
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{SCHEMA_SNAPSHOT_VERSION as t,diffSchemaSnapshots as a,serializeSchemaSnapshot as s}from"./packem_shared/SCHEMA_SNAPSHOT_VERSION-C0oHwiJZ.mjs";import{formatAdvisories as m,lintSchema as f,toAdvisorContext as d}from"./packem_shared/formatAdvisories-DwmUKYuc.mjs";import{describeErrorLevelFindings as l,errorAdvisoryNames as n,errorPlatformDiagnosticNames as c,sortedUniqueNames as x}from"./packem_shared/describeErrorLevelFindings-vzaGS9KL.mjs";import{CAPABILITY_PROBES as E}from"./packem_shared/CAPABILITY_PROBES-brcmKenl.mjs";import{CodegenDiagnosticError as A,diagnosticAt as v}from"./packem_shared/CodegenDiagnosticError-BUXlG3P-.mjs";import{AGENTS_FILENAME as C,discoverAgents as N}from"./packem_shared/AGENTS_FILENAME-lBe4g_sU.mjs";import{isTestPath as R,listLunoraSourceFiles as T}from"./packem_shared/isTestPath-DCyIyPa7.mjs";import{default as h}from"./packem_shared/discoverAuthApiCalls-TA2a8bZI.mjs";import{CONTAINERS_FILENAME as L,discoverContainers as M}from"./packem_shared/CONTAINERS_FILENAME-CY43AXXN.mjs";import{default as P}from"./packem_shared/discoverCrons-PQeDYVPc.mjs";import{capabilitiesUsedBy as b,foldCapabilitySignals as U,mayReadCapabilityContext as y,sourceCapabilitySignals as G}from"./packem_shared/capabilitiesUsedBy-DARbl-4Z.mjs";import{FLAGS_FILENAME as j,discoverFlags as B}from"./packem_shared/FLAGS_FILENAME-DXltN9DD.mjs";import{default as W}from"./packem_shared/discoverFunctions-4sef11AC.mjs";import{default as V}from"./packem_shared/discoverHttpRoutes-CLGXL19M.mjs";import{default as Q}from"./packem_shared/discoverHyperdriveCalls-imtma-ic.mjs";import{default as w}from"./packem_shared/discoverInserts-CKEO1mZZ.mjs";import{d as Y}from"./packem_shared/index-CRO3TRxd.mjs";import{default as Z}from"./packem_shared/discoverMigrations-DYQbnqow.mjs";import{MUTATORS_FILENAME as ee,discoverMutators as re}from"./packem_shared/MUTATORS_FILENAME-BxRrG_s-.mjs";import{default as te}from"./packem_shared/discoverNondeterministicCalls-BfdM93-8.mjs";import{NOTIFY_FILENAME as se,discoverNotifyCalls as ie,discoverNotifyConfig as me}from"./packem_shared/NOTIFY_FILENAME-J5MGAkca.mjs";import{default as de}from"./packem_shared/readPackageDependencies-RHhGiz0k.mjs";import{default as le}from"./packem_shared/discoverQueries-DEkIMaBP.mjs";import{QUEUES_FILENAME as ce,discoverQueues as xe}from"./packem_shared/QUEUES_FILENAME-DeJw5eqU.mjs";import{default as Ee}from"./packem_shared/discoverR2sqlCalls-BRIyb8Cl.mjs";import{default as Ae}from"./packem_shared/discoverRlsProcedures-BtT8-r93.mjs";import{default as ge}from"./packem_shared/discoverRlsMetadata-rpiO4wSi.mjs";import{discoverSandboxUsage as Ne}from"./packem_shared/discoverSandboxUsage-B8P9QjWZ.mjs";import{default as Re}from"./packem_shared/discoverSchema-BdmC-kO2.mjs";import{readServiceBindings as _e,resolveServiceBindings as he}from"./packem_shared/readServiceBindings-DuE9xlvV.mjs";import{SHAPES_FILENAME as Le,discoverShapes as Me}from"./packem_shared/SHAPES_FILENAME-CeBFuc8M.mjs";import{default as Pe}from"./packem_shared/discoverStorageRulesMetadata-C2hYksmI.mjs";import{WORKFLOWS_FILENAME as be,discoverWorkflows as Ue}from"./packem_shared/WORKFLOWS_FILENAME-B47AB5pc.mjs";import{emitApp as Ge}from"./packem_shared/emitApp-BdVXkH7A.mjs";import{isD1GlobalTable as je,isHyperdriveGlobalTable as Be}from"./packem_shared/isD1GlobalTable-udvHAAzD.mjs";import{buildOpenApiDocument as We,emitOpenApi as Ke,emitOpenApiModule as Ve}from"./packem_shared/buildOpenApiDocument-6VJGU6fU.mjs";import{OPENRPC_VERSION as Qe,buildOpenRpcDocument as qe,emitOpenRpc as we,emitOpenRpcModule as Je}from"./packem_shared/OPENRPC_VERSION-B8RT1JYn.mjs";import{DEFAULT_TARGET as Xe,platformMatrixIds as Ze,readProjectTarget as $e,resolveCodegenTarget as er}from"./packem_shared/DEFAULT_TARGET-rlz3WdHe.mjs";import{l as or,r as tr}from"./packem_shared/project-config-file-Bv2l-Kmm.mjs";import{SCHEMA_SNAPSHOT_FILENAME as sr,createCodegenProject as ir,findTsconfig as mr,refreshCodegenProject as fr,runCodegen as dr}from"./packem_shared/SCHEMA_SNAPSHOT_FILENAME-DHYzuzTc.mjs";import{SchemaSnapshotParseError as lr,buildSchemaSnapshot as nr,evaluateSchemaDrift as cr,parseSchemaSnapshot as xr}from"./packem_shared/SchemaSnapshotParseError-CPOXlFhI.mjs";import{default as Er}from"./packem_shared/fingerprintSchemaSources-ChYfrghz.mjs";import{schemaFromIr as Ar}from"./packem_shared/schemaFromIr-BWFnvCVg.mjs";import{LUNORA_ERROR_CODES as gr,validatorIrToJsonSchema as Cr}from"./packem_shared/LUNORA_ERROR_CODES-C2s0xWQD.mjs";import{SDK_LANGUAGES as Or,SDK_TARGETS as Rr,generateSdk as Tr}from"./packem_shared/SDK_LANGUAGES-Df_CnJx5.mjs";import{redact as hr,secretKindOf as Ir}from"./packem_shared/redact-Cy14LEnc.mjs";import{default as Mr}from"./packem_shared/emitDrizzleSchema-DohtnI8c.mjs";import{default as Pr}from"./packem_shared/emitFunctions-evl8Mx1a.mjs";import{default as br}from"./packem_shared/emitServer-BSMUAt0o.mjs";import{e as yr}from"./packem_shared/shard-C1ZGdOG1.mjs";import{G as Hr}from"./packem_shared/shared-BXUKWh7t.mjs";import{MESSAGE_SOLUTIONS as Br,findSolutionByMessage as kr}from"@lunora/errors";import{PROJECT_CONFIG_FILENAMES as Kr,findProjectConfigFile as Vr}from"./packem_shared/PROJECT_CONFIG_FILENAMES-DzOu-lSc.mjs";import{s as Qr,t as qr,u as wr}from"./packem_shared/shard-runtime-DGrBvQWg.mjs";import{emitApi as Yr,emitCollections as Xr}from"./packem_shared/emitApi-xDIHPRPH.mjs";import{emitCrons as $r,emitScheduler as eo,emitVectors as ro,emitWranglerCronTriggers as oo}from"./packem_shared/emitCrons-DKeoaeqU.mjs";import{emitDataModel as ao}from"./packem_shared/emitDataModel-DSk9AkJe.mjs";import{isTypedSchema as io}from"./packem_shared/isTypedSchema-CKzc3ioR.mjs";const e="0.0.0";export{C as AGENTS_FILENAME,E as CAPABILITY_PROBES,L as CONTAINERS_FILENAME,A as CodegenDiagnosticError,Xe as DEFAULT_TARGET,j as FLAGS_FILENAME,Hr as GENERATED_HEADER,gr as LUNORA_ERROR_CODES,Br as LUNORA_SOLUTION_RULES,ee as MUTATORS_FILENAME,se as NOTIFY_FILENAME,Qe as OPENRPC_VERSION,Kr as PROJECT_CONFIG_FILENAMES,ce as QUEUES_FILENAME,sr as SCHEMA_SNAPSHOT_FILENAME,t as SCHEMA_SNAPSHOT_VERSION,Or as SDK_LANGUAGES,Rr as SDK_TARGETS,Le as SHAPES_FILENAME,lr as SchemaSnapshotParseError,e as VERSION,be as WORKFLOWS_FILENAME,We as buildOpenApiDocument,qe as buildOpenRpcDocument,nr as buildSchemaSnapshot,b as capabilitiesUsedBy,ir as createCodegenProject,l as describeErrorLevelFindings,v as diagnosticAt,a as diffSchemaSnapshots,N as discoverAgents,h as discoverAuthApiCalls,M as discoverContainers,P as discoverCrons,B as discoverFlags,W as discoverFunctions,V as discoverHttpRoutes,Q as discoverHyperdriveCalls,w as discoverInserts,Y as discoverMaskProcedures,Z as discoverMigrations,re as discoverMutators,te as discoverNondeterministicCalls,ie as discoverNotifyCalls,me as discoverNotifyConfig,le as discoverQueries,xe as discoverQueues,Ee as discoverR2sqlCalls,ge as discoverRlsMetadata,Ae as discoverRlsProcedures,Ne as discoverSandboxUsage,Re as discoverSchema,Me as discoverShapes,Pe as discoverStorageRulesMetadata,Ue as discoverWorkflows,Qr as emitAgents,Yr as emitApi,Ge as emitApp,Xr as emitCollections,qr as emitContainers,$r as emitCrons,ao as emitDataModel,Mr as emitDrizzleSchema,Pr as emitFunctions,Ke as emitOpenApi,Ve as emitOpenApiModule,we as emitOpenRpc,Je as emitOpenRpcModule,eo as emitScheduler,br as emitServer,yr as emitShard,ro as emitVectors,wr as emitWorkflows,oo as emitWranglerCronTriggers,n as errorAdvisoryNames,c as errorPlatformDiagnosticNames,cr as evaluateSchemaDrift,kr as findLunoraSolution,Vr as findProjectConfigFile,mr as findTsconfig,Er as fingerprintSchemaSources,U as foldCapabilitySignals,m as formatAdvisories,Tr as generateSdk,je as isD1GlobalTable,Be as isHyperdriveGlobalTable,R as isTestPath,io as isTypedSchema,f as lintSchema,T as listLunoraSourceFiles,or as loadProjectConfig,y as mayReadCapabilityContext,xr as parseSchemaSnapshot,Ze as platformMatrixIds,de as readPackageDependencies,tr as readProjectConfigLiterals,$e as readProjectTarget,_e as readServiceBindings,hr as redact,fr as refreshCodegenProject,er as resolveCodegenTarget,he as resolveServiceBindings,dr as runCodegen,Ar as schemaFromIr,Ir as secretKindOf,s as serializeSchemaSnapshot,x as sortedUniqueNames,G as sourceCapabilitySignals,d as toAdvisorContext,Cr as validatorIrToJsonSchema};
1
+ import{SCHEMA_SNAPSHOT_VERSION as t,diffSchemaSnapshots as a,serializeSchemaSnapshot as s}from"./packem_shared/SCHEMA_SNAPSHOT_VERSION-C0oHwiJZ.mjs";import{formatAdvisories as m,lintSchema as f,toAdvisorContext as d}from"./packem_shared/formatAdvisories-DwmUKYuc.mjs";import{describeErrorLevelFindings as l,errorAdvisoryNames as n,errorPlatformDiagnosticNames as c,sortedUniqueNames as x}from"./packem_shared/describeErrorLevelFindings-vzaGS9KL.mjs";import{CAPABILITY_PROBES as E}from"./packem_shared/CAPABILITY_PROBES-brcmKenl.mjs";import{CodegenDiagnosticError as A,diagnosticAt as v}from"./packem_shared/CodegenDiagnosticError-BUXlG3P-.mjs";import{AGENTS_FILENAME as C,discoverAgents as N}from"./packem_shared/AGENTS_FILENAME-NQIB6wh3.mjs";import{isTestPath as R,listLunoraSourceFiles as T}from"./packem_shared/isTestPath-CgyyLk8U.mjs";import{default as _}from"./packem_shared/discoverAuthApiCalls-XK_WCMDG.mjs";import{CONTAINERS_FILENAME as L,discoverContainers as M}from"./packem_shared/CONTAINERS_FILENAME-CK3xJGwm.mjs";import{default as P}from"./packem_shared/discoverCrons-B5bVCaNF.mjs";import{capabilitiesUsedBy as b,foldCapabilitySignals as U,mayReadCapabilityContext as y,sourceCapabilitySignals as G}from"./packem_shared/capabilitiesUsedBy-FnnYmnSl.mjs";import{FLAGS_FILENAME as j,discoverFlags as B}from"./packem_shared/FLAGS_FILENAME-DYMd1xqw.mjs";import{default as W}from"./packem_shared/discoverFunctions-Be-XuuSW.mjs";import{default as V}from"./packem_shared/discoverHttpRoutes-CMOxt2Y9.mjs";import{default as Q}from"./packem_shared/discoverHyperdriveCalls-mrho5AnY.mjs";import{default as w}from"./packem_shared/discoverInserts-BhIpUWXN.mjs";import{d as Y}from"./packem_shared/index-CefI-Sba.mjs";import{default as Z}from"./packem_shared/discoverMigrations-dVVZtuJa.mjs";import{MUTATORS_FILENAME as ee,discoverMutators as re}from"./packem_shared/MUTATORS_FILENAME-BrEGrcPU.mjs";import{default as te}from"./packem_shared/discoverNondeterministicCalls-Dtb1aoGV.mjs";import{NOTIFY_FILENAME as se,discoverNotifyCalls as ie,discoverNotifyConfig as me}from"./packem_shared/NOTIFY_FILENAME-B42rW2NJ.mjs";import{default as de}from"./packem_shared/readPackageDependencies-RHhGiz0k.mjs";import{default as le}from"./packem_shared/discoverQueries-BSOjEsk3.mjs";import{QUEUES_FILENAME as ce,discoverQueues as xe}from"./packem_shared/QUEUES_FILENAME-Dj5yK34Z.mjs";import{default as Ee}from"./packem_shared/discoverR2sqlCalls-KONCqZr2.mjs";import{default as Ae}from"./packem_shared/discoverRlsProcedures-c0DnIR4z.mjs";import{default as ge}from"./packem_shared/discoverRlsMetadata-9YDlDDoh.mjs";import{discoverSandboxUsage as Ne}from"./packem_shared/discoverSandboxUsage-CfEU2hM-.mjs";import{default as Re}from"./packem_shared/discoverSchema-BTFFWy3i.mjs";import{readServiceBindings as Ie,resolveServiceBindings as _e}from"./packem_shared/readServiceBindings-DuE9xlvV.mjs";import{SHAPES_FILENAME as Le,discoverShapes as Me}from"./packem_shared/SHAPES_FILENAME-CVc2VCnS.mjs";import{default as Pe}from"./packem_shared/discoverStorageRulesMetadata-f89BWody.mjs";import{WORKFLOWS_FILENAME as be,discoverWorkflows as Ue}from"./packem_shared/WORKFLOWS_FILENAME-Ze98LsB3.mjs";import{emitApp as Ge}from"./packem_shared/emitApp-DUGS6Ve2.mjs";import{isD1GlobalTable as je,isHyperdriveGlobalTable as Be}from"./packem_shared/isD1GlobalTable-udvHAAzD.mjs";import{buildOpenApiDocument as We,emitOpenApi as Ke,emitOpenApiModule as Ve}from"./packem_shared/buildOpenApiDocument-BjHdW7b2.mjs";import{OPENRPC_VERSION as Qe,buildOpenRpcDocument as qe,emitOpenRpc as we,emitOpenRpcModule as Je}from"./packem_shared/OPENRPC_VERSION-BaD2A2YR.mjs";import{DEFAULT_TARGET as Xe,platformMatrixIds as Ze,readProjectTarget as $e,resolveCodegenTarget as er}from"./packem_shared/DEFAULT_TARGET-rlz3WdHe.mjs";import{l as or,r as tr}from"./packem_shared/project-config-file-Bv2l-Kmm.mjs";import{SCHEMA_SNAPSHOT_FILENAME as sr,createCodegenProject as ir,findTsconfig as mr,refreshCodegenProject as fr,runCodegen as dr}from"./packem_shared/SCHEMA_SNAPSHOT_FILENAME-DWriXOYw.mjs";import{SchemaSnapshotParseError as lr,buildSchemaSnapshot as nr,evaluateSchemaDrift as cr,parseSchemaSnapshot as xr}from"./packem_shared/SchemaSnapshotParseError-CPOXlFhI.mjs";import{default as Er}from"./packem_shared/fingerprintSchemaSources-BJSIxwhY.mjs";import{schemaFromIr as Ar}from"./packem_shared/schemaFromIr-BWFnvCVg.mjs";import{LUNORA_ERROR_CODES as gr,validatorIrToJsonSchema as Cr}from"./packem_shared/LUNORA_ERROR_CODES-C2s0xWQD.mjs";import{SDK_LANGUAGES as Or,SDK_TARGETS as Rr,generateSdk as Tr}from"./packem_shared/SDK_LANGUAGES-Df_CnJx5.mjs";import{redact as _r,secretKindOf as hr}from"./packem_shared/redact-Cy14LEnc.mjs";import{default as Mr}from"./packem_shared/emitDrizzleSchema-DLtfKTI4.mjs";import{default as Pr}from"./packem_shared/emitFunctions-DkkcTDqh.mjs";import{e as br}from"./packem_shared/server-BmY5wwKY.mjs";import{e as yr}from"./packem_shared/shard-Dr5gMNyz.mjs";import{G as Hr}from"./packem_shared/shared-Be3TGzxM.mjs";import{MESSAGE_SOLUTIONS as Br,findSolutionByMessage as kr}from"@lunora/errors";import{PROJECT_CONFIG_FILENAMES as Kr,findProjectConfigFile as Vr}from"./packem_shared/PROJECT_CONFIG_FILENAMES-DzOu-lSc.mjs";import{s as Qr,t as qr,u as wr}from"./packem_shared/shard-runtime-BI2SZ54Z.mjs";import{emitApi as Yr,emitCollections as Xr,emitInternalApi as Zr}from"./packem_shared/emitApi-zY6egN77.mjs";import{emitCrons as eo,emitScheduler as ro,emitVectors as oo,emitWranglerCronTriggers as to}from"./packem_shared/emitCrons-B8TBAOZ4.mjs";import{emitDataModel as so}from"./packem_shared/emitDataModel-B68T_eX6.mjs";import{isTypedSchema as mo}from"./packem_shared/isTypedSchema-CKzc3ioR.mjs";const e="0.0.0";export{C as AGENTS_FILENAME,E as CAPABILITY_PROBES,L as CONTAINERS_FILENAME,A as CodegenDiagnosticError,Xe as DEFAULT_TARGET,j as FLAGS_FILENAME,Hr as GENERATED_HEADER,gr as LUNORA_ERROR_CODES,Br as LUNORA_SOLUTION_RULES,ee as MUTATORS_FILENAME,se as NOTIFY_FILENAME,Qe as OPENRPC_VERSION,Kr as PROJECT_CONFIG_FILENAMES,ce as QUEUES_FILENAME,sr as SCHEMA_SNAPSHOT_FILENAME,t as SCHEMA_SNAPSHOT_VERSION,Or as SDK_LANGUAGES,Rr as SDK_TARGETS,Le as SHAPES_FILENAME,lr as SchemaSnapshotParseError,e as VERSION,be as WORKFLOWS_FILENAME,We as buildOpenApiDocument,qe as buildOpenRpcDocument,nr as buildSchemaSnapshot,b as capabilitiesUsedBy,ir as createCodegenProject,l as describeErrorLevelFindings,v as diagnosticAt,a as diffSchemaSnapshots,N as discoverAgents,_ as discoverAuthApiCalls,M as discoverContainers,P as discoverCrons,B as discoverFlags,W as discoverFunctions,V as discoverHttpRoutes,Q as discoverHyperdriveCalls,w as discoverInserts,Y as discoverMaskProcedures,Z as discoverMigrations,re as discoverMutators,te as discoverNondeterministicCalls,ie as discoverNotifyCalls,me as discoverNotifyConfig,le as discoverQueries,xe as discoverQueues,Ee as discoverR2sqlCalls,ge as discoverRlsMetadata,Ae as discoverRlsProcedures,Ne as discoverSandboxUsage,Re as discoverSchema,Me as discoverShapes,Pe as discoverStorageRulesMetadata,Ue as discoverWorkflows,Qr as emitAgents,Yr as emitApi,Ge as emitApp,Xr as emitCollections,qr as emitContainers,eo as emitCrons,so as emitDataModel,Mr as emitDrizzleSchema,Pr as emitFunctions,Zr as emitInternalApi,Ke as emitOpenApi,Ve as emitOpenApiModule,we as emitOpenRpc,Je as emitOpenRpcModule,ro as emitScheduler,br as emitServer,yr as emitShard,oo as emitVectors,wr as emitWorkflows,to as emitWranglerCronTriggers,n as errorAdvisoryNames,c as errorPlatformDiagnosticNames,cr as evaluateSchemaDrift,kr as findLunoraSolution,Vr as findProjectConfigFile,mr as findTsconfig,Er as fingerprintSchemaSources,U as foldCapabilitySignals,m as formatAdvisories,Tr as generateSdk,je as isD1GlobalTable,Be as isHyperdriveGlobalTable,R as isTestPath,mo as isTypedSchema,f as lintSchema,T as listLunoraSourceFiles,or as loadProjectConfig,y as mayReadCapabilityContext,xr as parseSchemaSnapshot,Ze as platformMatrixIds,de as readPackageDependencies,tr as readProjectConfigLiterals,$e as readProjectTarget,Ie as readServiceBindings,_r as redact,fr as refreshCodegenProject,er as resolveCodegenTarget,_e as resolveServiceBindings,dr as runCodegen,Ar as schemaFromIr,hr as secretKindOf,s as serializeSchemaSnapshot,x as sortedUniqueNames,G as sourceCapabilitySignals,d as toAdvisorContext,Cr 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 w}from"./isTestPath-DCyIyPa7.mjs";import{a as h}from"./attribution-NRssTEkk.mjs";const E="agents.ts",v=o=>{const n=o.getSymbol();if(!n)return o.getText()==="defineAgent";for(const e of n.getDeclarations())if(a.isImportSpecifier(e))return e.getImportDeclaration().getModuleSpecifierValue()!=="@lunora/agent"?!1:e.getNameNode().getText()==="defineAgent";return!1},P=w("agent"),x=(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)},i=c(e,"name");i&&a.isPropertyAssignment(i)&&(t.name=P(i.getInitializerOrThrow(),n,"name"));const r=c(e,"publicRun");r&&a.isPropertyAssignment(r)&&x(r.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},S=o=>{const n=[];for(const e of o.getVariableDeclarations()){const t=A(e.getInitializer());if(!t)continue;const i=t.getExpression();if(!a.isIdentifier(i)||!v(i))continue;const r=e.getNameNode();if(!a.isIdentifier(r)){if(e.getVariableStatement()?.hasExportKeyword()!==!0)continue;throw l(r,"defineAgent exports must be plain named exports (no destructuring)")}const s=h(e,"binding");s!==void 0&&n.push(I(t,s))}return n},T=o=>{const n=new Map,e=new Map;for(const t of o){const i=n.get(t.name);if(i!==void 0)throw new g("DUPLICATE_AGENT_NAME",`Duplicate agent name "${t.name}": produced by both "${i}" and "${t.exportName}". Deployed agent names must be unique across the project.`,{status:500});n.set(t.name,t.exportName);const r=e.get(t.className);if(r!==void 0)throw new g("DUPLICATE_AGENT_CLASS",`Duplicate agent class "${t.className}": produced by both "${r}" and "${t.exportName}". Agent export names must yield unique generated class names.`,{status:500});e.set(t.className,t.exportName)}},z=(o,n)=>{const e=f(n,E);if(!p(e))return[];const t=o.getSourceFile(e)??o.addSourceFileAtPath(e),i=S(t);return i.sort((r,s)=>r.exportName.localeCompare(s.exportName)),T(i),i};export{E as AGENTS_FILENAME,z 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 w}from"./isTestPath-CgyyLk8U.mjs";import{a as h}from"./attribution-Dw35rOaJ.mjs";const E="agents.ts",v=o=>{const n=o.getSymbol();if(!n)return o.getText()==="defineAgent";for(const e of n.getDeclarations())if(a.isImportSpecifier(e))return e.getImportDeclaration().getModuleSpecifierValue()!=="@lunora/agent"?!1:e.getNameNode().getText()==="defineAgent";return!1},P=w("agent"),x=(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)},i=c(e,"name");i&&a.isPropertyAssignment(i)&&(t.name=P(i.getInitializerOrThrow(),n,"name"));const r=c(e,"publicRun");r&&a.isPropertyAssignment(r)&&x(r.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},S=o=>{const n=[];for(const e of o.getVariableDeclarations()){const t=A(e.getInitializer());if(!t)continue;const i=t.getExpression();if(!a.isIdentifier(i)||!v(i))continue;const r=e.getNameNode();if(!a.isIdentifier(r)){if(e.getVariableStatement()?.hasExportKeyword()!==!0)continue;throw l(r,"defineAgent exports must be plain named exports (no destructuring)")}const s=h(e,"binding");s!==void 0&&n.push(I(t,s))}return n},T=o=>{const n=new Map,e=new Map;for(const t of o){const i=n.get(t.name);if(i!==void 0)throw new g("DUPLICATE_AGENT_NAME",`Duplicate agent name "${t.name}": produced by both "${i}" and "${t.exportName}". Deployed agent names must be unique across the project.`,{status:500});n.set(t.name,t.exportName);const r=e.get(t.className);if(r!==void 0)throw new g("DUPLICATE_AGENT_CLASS",`Duplicate agent class "${t.className}": produced by both "${r}" and "${t.exportName}". Agent export names must yield unique generated class names.`,{status:500});e.set(t.className,t.exportName)}},z=(o,n)=>{const e=f(n,E);if(!p(e))return[];const t=o.getSourceFile(e)??o.addSourceFileAtPath(e),i=S(t);return i.sort((r,s)=>r.exportName.localeCompare(s.exportName)),T(i),i};export{E as AGENTS_FILENAME,z as discoverAgents};
@@ -1 +1 @@
1
- import{existsSync as T}from"node:fs";import{join as j}from"node:path";import{containerClassName as I,containerBindingName as A,DURABLE_OBJECT_POLICY_FORBIDDEN_KEYS as O,isManagedImage as k,isCloudflareRegistryDigest as C,normalizeContainerImage as f}from"@lunora/container";import{SyntaxKind as S,Node as s}from"ts-morph";import{diagnosticAt as a}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{stringPropertyFor as _,findObjectProperty as p,symbolConstInitializer as D,outermostValueWrapper as w,isWriteTarget as M}from"./isTestPath-DCyIyPa7.mjs";import{a as F}from"./attribution-NRssTEkk.mjs";import{a as b}from"./project-config-file-Bv2l-Kmm.mjs";const V="containers.ts",K=t=>{const e=t.getSymbol();if(!e)return t.getText()==="defineContainer";for(const n of e.getDeclarations())if(s.isImportSpecifier(n))return n.getImportDeclaration().getModuleSpecifierValue()!=="@lunora/container"?!1:n.getNameNode().getText()==="defineContainer";return!1},d=_("container"),y=(t,e,n)=>{if(s.isNumericLiteral(t))return t.getLiteralValue();throw a(t,`container "${e}": \`${n}\` must be a static number literal — it is deploy configuration codegen writes into wrangler.jsonc`)},$=(t,e)=>{if(s.isStringLiteral(t)||s.isNoSubstitutionTemplateLiteral(t))return f(t.getLiteralValue());if(s.isObjectLiteralExpression(t)){const n=p(t,"registry");if(n&&s.isPropertyAssignment(n)){const r=n.getInitializerOrThrow();return f({registry:d(r,e,"image.registry")})}const i=p(t,"build");if(i&&s.isPropertyAssignment(i)){const r=i.getInitializerOrThrow();return f({build:d(r,e,"image.build")})}}throw a(t,`container "${e}": \`image\` must be a static string path, { registry: "…" }, or { build: "…" } literal`)},B=new Set(["buildArgs","image","images","instanceType","maxInstances","name","rollout","sandbox","schedulingPolicy"]),R=new Set(["gracePeriodSeconds","stepPercentage"]),E=t=>{let e=t;for(;s.isAsExpression(e)||s.isSatisfiesExpression(e)||s.isTypeAssertion(e)||s.isParenthesizedExpression(e);)e=e.getExpression();return e},U=(t,e)=>e.getDescendantsOfKind(S.Identifier).some(n=>{if(n.getSymbol()!==t)return!1;let i=w(n),r=i.getParent();if(s.isCallExpression(r)&&r.getExpression().getText()==="Object.assign")return r.getArguments()[0]===i;for(;(s.isPropertyAccessExpression(r)||s.isElementAccessExpression(r))&&r.getExpression()===i;){if(M(r))return!0;i=w(r),r=i.getParent()}return!1}),z=16,L=(t,e,n,i)=>{let r={name:n,symbol:t},o;for(let c=0;c<z;c+=1){const l=D(r.symbol);if(l===void 0||!s.isExpression(l))return o;if(o=E(l),s.isObjectLiteralExpression(o)&&r.symbol!==void 0&&U(r.symbol,e.getSourceFile()))throw a(e,`${i}: \`${r.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;r={name:o.getText(),symbol:o.getSymbol()}}return o},P=(t,e)=>{const n=E(t);return s.isIdentifier(n)?L(n.getSymbol(),n,n.getText(),e)??n:n},N=t=>{const e=t.getNonNullableType();return(e.isUnion()?e.getUnionTypes():[e]).flatMap(i=>i.getApparentType().getProperties().map(r=>r.getName()))},Y=(t,e,n)=>{const i=t.getExpression().getType(),r=e==="every"||i.isAny()||i.isUnknown()?["its keys"]:[...new Set(N(i))].filter(o=>e.has(o)).map(o=>`\`${o}\``);if(r.length>0)throw a(t,`${n}: this spread can set ${r.join(", ")}, which codegen writes into wrangler.jsonc and so must read statically. Spread a module-scope \`const\` object literal, or write the keys inline.`)},W=(t,e,n)=>{const i=b(t),r=s.isShorthandPropertyAssignment(t)?L(t.getValueSymbol(),t,i,n):void 0;if(r!==void 0)return[i,r];if(e==="every"||e.has(i))throw a(t,`${n}: \`${i}\` 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,n,i=new Set)=>{const r=[],o=new Set(i).add(t);for(const c of t.getProperties())if(s.isPropertyAssignment(c))r.push([b(c),P(c.getInitializerOrThrow(),n)]);else if(s.isSpreadAssignment(c))r.push(...q(c,e,n,o));else{const l=W(c,e,n);l!==void 0&&r.push(l)}return r},q=(t,e,n,i)=>{const r=P(t.getExpression(),n);if(!s.isObjectLiteralExpression(r))return Y(t,e,n),[];if(i.has(r))throw a(t,`${n}: this spread refers back to an object it is part of, so it has no static value.`);return m(r,e,n,i)},x=(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 n={};for(const[i,r]of m(t,"every",`container "${e}" buildArgs`))n[i]=d(r,e,`buildArgs.${i}`);return Object.keys(n).length>0?n:void 0},H=(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 n={};for(const[i,r]of m(t,R,`container "${e}" rollout`))(i==="gracePeriodSeconds"||i==="stepPercentage")&&(n[i]=y(r,e,`rollout.${i}`));return n.gracePeriodSeconds===void 0&&n.stepPercentage===void 0?void 0:n},v=t=>{if(s.isTrueLiteral(t))return!0;if(s.isFalseLiteral(t))return!1},J=t=>{if(s.isStringLiteral(t)||s.isNoSubstitutionTemplateLiteral(t)||s.isNumericLiteral(t))return t.getLiteralValue()},X=(t,e)=>{if(s.isStringLiteral(t))return t.getLiteralValue();if(s.isObjectLiteralExpression(t)){const n={};for(const i of t.getProperties()){if(!s.isPropertyAssignment(i))throw a(i,`container "${e}": \`instanceType\` must be an object of static number literals`);const r=b(i);if(r!=="diskMb"&&r!=="memoryMib"&&r!=="vcpu")throw a(i,`container "${e}": unknown \`instanceType\` field "${r}" — expected vcpu, memoryMib, or diskMb`);n[r]=y(i.getInitializerOrThrow(),e,`instanceType.${r}`)}return n}throw a(t,`container "${e}": \`instanceType\` must be a static string or { vcpu, memoryMib, diskMb } literal`)},G=(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 n={};for(const[i,r]of m(t,"every",`container "${e}" images`)){const o=$(r,e);if(o.kind==="build")throw a(r,`container "${e}": \`images["${i}"]\` cannot be a Railpack { build } source — use a Dockerfile path or a { registry } reference`);if(o.kind==="registry"&&!C(o.reference))throw a(r,`container "${e}": \`images["${i}"].registry\` must be a digest-pinned (@sha256) reference under registry.cloudflare.com — push other registries' images there first`);n[i]=o}return n},Q=(t,e)=>{const n=t.findLast(([r])=>r==="schedulingPolicy");if(n===void 0)return;const i=d(n[1],e,"schedulingPolicy");if(i!=="default"&&i!=="durable_object")throw a(n[1],`container "${e}": unknown \`schedulingPolicy\` "${i}" — use "default" or "durable_object"`);return i==="durable_object"?i:void 0},Z=(t,e,n,i)=>{if(n!==void 0&&O.includes(t))throw a(e,`container "${i}": \`${t}\` is not supported with schedulingPolicy "durable_object"`);if(n===void 0&&t==="images")throw a(e,`container "${i}": \`images\` needs schedulingPolicy "durable_object"`)},ee=(t,e,n,i)=>{const{base:r,policy:o}=n;switch(t){case"buildArgs":{r.buildArgs=x(e,i);break}case"enableInternet":{r.enableInternet=v(e);break}case"image":{n.scheduled||(o.image=$(e,i));break}case"images":{o.images=G(e,i);break}case"instanceType":{r.instanceType=X(e,i);break}case"maxInstances":{o.maxInstances=y(e,i,"maxInstances");break}case"name":{r.name=d(e,i,"name");break}case"rollout":{o.rollout=H(e,i);break}case"sandbox":{const c=v(e);if(c===void 0)throw a(e,`container "${i}": \`sandbox\` must be a static true/false literal`);r.sandbox=c;break}case"sleepAfter":{r.sleepAfter=J(e);break}}},te=(t,e,n)=>{const i=t.findLast(([o])=>o==="image")?.[1];if(i===void 0||!(s.isStringLiteral(i)||s.isNoSubstitutionTemplateLiteral(i)))return;const r=i.getLiteralValue();if(!Object.hasOwn(e??{},r)&&!k(r))throw a(i,`container "${n}": \`image\` "${r}" must name an entry of \`images\` or a Cloudflare-managed "cloudflare/…" image`)},ie=(t,e)=>{const n=t.getArguments()[0];if(!n||!s.isObjectLiteralExpression(n))throw a(t,`container "${e}": defineContainer must be passed an inline object literal`);const i=m(n,B,`container "${e}"`),r=Q(i,e),o={base:{bindingName:A(e),className:I(e),exportName:e},policy:{},scheduled:r!==void 0};for(const[g,u]of i)Z(g,u,r,e),ee(g,u,o,e);const{base:c,policy:l}=o;if(r==="durable_object")return te(i,l.images,e),{...c,...l.images===void 0?{}:{images:l.images},schedulingPolicy:r};if(l.image===void 0)throw a(n,`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}}},ne=t=>{const e=[],n=new Map;for(const i of t.getVariableDeclarations()){const r=i.getInitializer();if(r?.getKind()!==S.CallExpression)continue;const o=r,c=o.getExpression();if(!s.isIdentifier(c)||!K(c))continue;const l=i.getNameNode();if(!s.isIdentifier(l)){if(i.getVariableStatement()?.hasExportKeyword()!==!0)continue;throw a(l,"defineContainer exports must be plain named exports (no destructuring)")}const g=F(i,"binding");if(g===void 0)continue;const u=ie(o,g),h=n.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`);n.set(u.bindingName,u.exportName),e.push(u)}return e},de=(t,e)=>{const n=j(e,V);if(!T(n))return[];const i=t.getSourceFile(n)??t.addSourceFileAtPath(n),r=ne(i);return r.sort((o,c)=>o.exportName.localeCompare(c.exportName)),r};export{V as CONTAINERS_FILENAME,de as discoverContainers};
1
+ import{existsSync as T}from"node:fs";import{join as j}from"node:path";import{containerClassName as I,containerBindingName as A,DURABLE_OBJECT_POLICY_FORBIDDEN_KEYS as O,isManagedImage as k,isCloudflareRegistryDigest as C,normalizeContainerImage as f}from"@lunora/container";import{SyntaxKind as S,Node as s}from"ts-morph";import{diagnosticAt as a}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{stringPropertyFor as _,findObjectProperty as p,symbolConstInitializer as D,outermostValueWrapper as w,isWriteTarget as M}from"./isTestPath-CgyyLk8U.mjs";import{a as F}from"./attribution-Dw35rOaJ.mjs";import{a as b}from"./project-config-file-Bv2l-Kmm.mjs";const V="containers.ts",K=t=>{const e=t.getSymbol();if(!e)return t.getText()==="defineContainer";for(const n of e.getDeclarations())if(s.isImportSpecifier(n))return n.getImportDeclaration().getModuleSpecifierValue()!=="@lunora/container"?!1:n.getNameNode().getText()==="defineContainer";return!1},d=_("container"),y=(t,e,n)=>{if(s.isNumericLiteral(t))return t.getLiteralValue();throw a(t,`container "${e}": \`${n}\` must be a static number literal — it is deploy configuration codegen writes into wrangler.jsonc`)},$=(t,e)=>{if(s.isStringLiteral(t)||s.isNoSubstitutionTemplateLiteral(t))return f(t.getLiteralValue());if(s.isObjectLiteralExpression(t)){const n=p(t,"registry");if(n&&s.isPropertyAssignment(n)){const r=n.getInitializerOrThrow();return f({registry:d(r,e,"image.registry")})}const i=p(t,"build");if(i&&s.isPropertyAssignment(i)){const r=i.getInitializerOrThrow();return f({build:d(r,e,"image.build")})}}throw a(t,`container "${e}": \`image\` must be a static string path, { registry: "…" }, or { build: "…" } literal`)},B=new Set(["buildArgs","image","images","instanceType","maxInstances","name","rollout","sandbox","schedulingPolicy"]),R=new Set(["gracePeriodSeconds","stepPercentage"]),E=t=>{let e=t;for(;s.isAsExpression(e)||s.isSatisfiesExpression(e)||s.isTypeAssertion(e)||s.isParenthesizedExpression(e);)e=e.getExpression();return e},U=(t,e)=>e.getDescendantsOfKind(S.Identifier).some(n=>{if(n.getSymbol()!==t)return!1;let i=w(n),r=i.getParent();if(s.isCallExpression(r)&&r.getExpression().getText()==="Object.assign")return r.getArguments()[0]===i;for(;(s.isPropertyAccessExpression(r)||s.isElementAccessExpression(r))&&r.getExpression()===i;){if(M(r))return!0;i=w(r),r=i.getParent()}return!1}),z=16,L=(t,e,n,i)=>{let r={name:n,symbol:t},o;for(let c=0;c<z;c+=1){const l=D(r.symbol);if(l===void 0||!s.isExpression(l))return o;if(o=E(l),s.isObjectLiteralExpression(o)&&r.symbol!==void 0&&U(r.symbol,e.getSourceFile()))throw a(e,`${i}: \`${r.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;r={name:o.getText(),symbol:o.getSymbol()}}return o},P=(t,e)=>{const n=E(t);return s.isIdentifier(n)?L(n.getSymbol(),n,n.getText(),e)??n:n},N=t=>{const e=t.getNonNullableType();return(e.isUnion()?e.getUnionTypes():[e]).flatMap(i=>i.getApparentType().getProperties().map(r=>r.getName()))},Y=(t,e,n)=>{const i=t.getExpression().getType(),r=e==="every"||i.isAny()||i.isUnknown()?["its keys"]:[...new Set(N(i))].filter(o=>e.has(o)).map(o=>`\`${o}\``);if(r.length>0)throw a(t,`${n}: this spread can set ${r.join(", ")}, which codegen writes into wrangler.jsonc and so must read statically. Spread a module-scope \`const\` object literal, or write the keys inline.`)},W=(t,e,n)=>{const i=b(t),r=s.isShorthandPropertyAssignment(t)?L(t.getValueSymbol(),t,i,n):void 0;if(r!==void 0)return[i,r];if(e==="every"||e.has(i))throw a(t,`${n}: \`${i}\` 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,n,i=new Set)=>{const r=[],o=new Set(i).add(t);for(const c of t.getProperties())if(s.isPropertyAssignment(c))r.push([b(c),P(c.getInitializerOrThrow(),n)]);else if(s.isSpreadAssignment(c))r.push(...q(c,e,n,o));else{const l=W(c,e,n);l!==void 0&&r.push(l)}return r},q=(t,e,n,i)=>{const r=P(t.getExpression(),n);if(!s.isObjectLiteralExpression(r))return Y(t,e,n),[];if(i.has(r))throw a(t,`${n}: this spread refers back to an object it is part of, so it has no static value.`);return m(r,e,n,i)},x=(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 n={};for(const[i,r]of m(t,"every",`container "${e}" buildArgs`))n[i]=d(r,e,`buildArgs.${i}`);return Object.keys(n).length>0?n:void 0},H=(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 n={};for(const[i,r]of m(t,R,`container "${e}" rollout`))(i==="gracePeriodSeconds"||i==="stepPercentage")&&(n[i]=y(r,e,`rollout.${i}`));return n.gracePeriodSeconds===void 0&&n.stepPercentage===void 0?void 0:n},v=t=>{if(s.isTrueLiteral(t))return!0;if(s.isFalseLiteral(t))return!1},J=t=>{if(s.isStringLiteral(t)||s.isNoSubstitutionTemplateLiteral(t)||s.isNumericLiteral(t))return t.getLiteralValue()},X=(t,e)=>{if(s.isStringLiteral(t))return t.getLiteralValue();if(s.isObjectLiteralExpression(t)){const n={};for(const i of t.getProperties()){if(!s.isPropertyAssignment(i))throw a(i,`container "${e}": \`instanceType\` must be an object of static number literals`);const r=b(i);if(r!=="diskMb"&&r!=="memoryMib"&&r!=="vcpu")throw a(i,`container "${e}": unknown \`instanceType\` field "${r}" — expected vcpu, memoryMib, or diskMb`);n[r]=y(i.getInitializerOrThrow(),e,`instanceType.${r}`)}return n}throw a(t,`container "${e}": \`instanceType\` must be a static string or { vcpu, memoryMib, diskMb } literal`)},G=(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 n={};for(const[i,r]of m(t,"every",`container "${e}" images`)){const o=$(r,e);if(o.kind==="build")throw a(r,`container "${e}": \`images["${i}"]\` cannot be a Railpack { build } source — use a Dockerfile path or a { registry } reference`);if(o.kind==="registry"&&!C(o.reference))throw a(r,`container "${e}": \`images["${i}"].registry\` must be a digest-pinned (@sha256) reference under registry.cloudflare.com — push other registries' images there first`);n[i]=o}return n},Q=(t,e)=>{const n=t.findLast(([r])=>r==="schedulingPolicy");if(n===void 0)return;const i=d(n[1],e,"schedulingPolicy");if(i!=="default"&&i!=="durable_object")throw a(n[1],`container "${e}": unknown \`schedulingPolicy\` "${i}" — use "default" or "durable_object"`);return i==="durable_object"?i:void 0},Z=(t,e,n,i)=>{if(n!==void 0&&O.includes(t))throw a(e,`container "${i}": \`${t}\` is not supported with schedulingPolicy "durable_object"`);if(n===void 0&&t==="images")throw a(e,`container "${i}": \`images\` needs schedulingPolicy "durable_object"`)},ee=(t,e,n,i)=>{const{base:r,policy:o}=n;switch(t){case"buildArgs":{r.buildArgs=x(e,i);break}case"enableInternet":{r.enableInternet=v(e);break}case"image":{n.scheduled||(o.image=$(e,i));break}case"images":{o.images=G(e,i);break}case"instanceType":{r.instanceType=X(e,i);break}case"maxInstances":{o.maxInstances=y(e,i,"maxInstances");break}case"name":{r.name=d(e,i,"name");break}case"rollout":{o.rollout=H(e,i);break}case"sandbox":{const c=v(e);if(c===void 0)throw a(e,`container "${i}": \`sandbox\` must be a static true/false literal`);r.sandbox=c;break}case"sleepAfter":{r.sleepAfter=J(e);break}}},te=(t,e,n)=>{const i=t.findLast(([o])=>o==="image")?.[1];if(i===void 0||!(s.isStringLiteral(i)||s.isNoSubstitutionTemplateLiteral(i)))return;const r=i.getLiteralValue();if(!Object.hasOwn(e??{},r)&&!k(r))throw a(i,`container "${n}": \`image\` "${r}" must name an entry of \`images\` or a Cloudflare-managed "cloudflare/…" image`)},ie=(t,e)=>{const n=t.getArguments()[0];if(!n||!s.isObjectLiteralExpression(n))throw a(t,`container "${e}": defineContainer must be passed an inline object literal`);const i=m(n,B,`container "${e}"`),r=Q(i,e),o={base:{bindingName:A(e),className:I(e),exportName:e},policy:{},scheduled:r!==void 0};for(const[g,u]of i)Z(g,u,r,e),ee(g,u,o,e);const{base:c,policy:l}=o;if(r==="durable_object")return te(i,l.images,e),{...c,...l.images===void 0?{}:{images:l.images},schedulingPolicy:r};if(l.image===void 0)throw a(n,`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}}},ne=t=>{const e=[],n=new Map;for(const i of t.getVariableDeclarations()){const r=i.getInitializer();if(r?.getKind()!==S.CallExpression)continue;const o=r,c=o.getExpression();if(!s.isIdentifier(c)||!K(c))continue;const l=i.getNameNode();if(!s.isIdentifier(l)){if(i.getVariableStatement()?.hasExportKeyword()!==!0)continue;throw a(l,"defineContainer exports must be plain named exports (no destructuring)")}const g=F(i,"binding");if(g===void 0)continue;const u=ie(o,g),h=n.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`);n.set(u.bindingName,u.exportName),e.push(u)}return e},de=(t,e)=>{const n=j(e,V);if(!T(n))return[];const i=t.getSourceFile(n)??t.addSourceFileAtPath(n),r=ne(i);return r.sort((o,c)=>o.exportName.localeCompare(c.exportName)),r};export{V as CONTAINERS_FILENAME,de as discoverContainers};
@@ -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-DCyIyPa7.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-CgyyLk8U.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};
@@ -0,0 +1 @@
1
+ import{G as p,I as i,a as n,g as o,d,i as I,p as T,r as c,f,b as y,c as E,e as m,u as O,v as l}from"./shared-Be3TGzxM.mjs";import"./paths-DwTjD7BU.mjs";import"./reserved-words-CW1QFbTd.mjs";import"./LUNORA_ERROR_CODES-C2s0xWQD.mjs";export{p as GENERATED_HEADER,i as IMPORT_PATH_RE,n as assertIdentifier,o as assertPropertyIdentifier,d as baseSpecifiers,I as isOptionalOnInsert,T as pascalCase,c as renderArgsType,f as renderInsertInterface,y as renderNamespaceTree,E as renderObjectKey,m as renderPropertyKey,O as unwrapOptional,l as validatorToType};
@@ -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{a as M}from"./module-specifiers-WF8iAydP.mjs";import{p as A}from"./parse-validator-DYdT7Hyf.mjs";import{findObjectProperty as c,unwrapExpression as d,isConstDeclaration as P}from"./isTestPath-DCyIyPa7.mjs";import{j as D,i as b,f as g,d as O}from"./attribution-NRssTEkk.mjs";import{u as w}from"./unwrap-handler-return-Dy8h5-I6.mjs";const z="mutators.ts",x=M,h=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 h(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":w(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 D(t).filter(F=>b(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,z);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{z 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{a as M}from"./module-specifiers-WF8iAydP.mjs";import{p as A}from"./parse-validator-DYdT7Hyf.mjs";import{findObjectProperty as c,unwrapExpression as d,isConstDeclaration as P}from"./isTestPath-CgyyLk8U.mjs";import{j as D,i as b,f as g,d as O}from"./attribution-Dw35rOaJ.mjs";import{u as w}from"./unwrap-handler-return-T5sJhEss.mjs";const z="mutators.ts",x=M,h=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 h(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":w(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 D(t).filter(F=>b(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,z);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{z as MUTATORS_FILENAME,J as discoverMutators,N as isDefineMutatorCallee,S as mutatorLiteral,G as mutatorServerImplOf};
@@ -1 +1 @@
1
- import{existsSync as P}from"node:fs";import{join as S}from"node:path";import{SyntaxKind as l,Node as f}from"ts-morph";import{listLunoraSourceFiles as p,lunoraRelativePath as y,defaultExportExpression as E,findObjectProperty as d,handlerOf as g}from"./isTestPath-DCyIyPa7.mjs";import{b as N,d as v}from"./attribution-NRssTEkk.mjs";import{i as a}from"./context-root-IuI71QkK.mjs";import{c as F}from"./classify-procedure-call-BBKuBvKg.mjs";const O="notify.ts",A=new Set(["chat","inApp","send","webhook"]),h=new Set(["broadcast","send"]),b=e=>{const t=e.getInitializer();if(!t||!f.isCallExpression(t))return;const o=F(t);if(!o)return;const r=g(t,o.receiver);return r?{exportName:v(e)??e.getName(),handler:r,kind:o.kind}:void 0},m=e=>{const t=[];for(const o of N(e)){const r=b(o);r&&t.push(r)}return t},x=e=>a(e,["notify"])?"notify":a(e,["push"])||a(e,["notify","push"])?"push":void 0,k=e=>{if(!f.isPropertyAccessExpression(e))return;const t=e.getName(),o=x(e.getExpression());if(o==="notify"&&A.has(t))return`ctx.notify.${t}`;if(o==="push"&&h.has(t))return`ctx.push.${t}`},C=e=>f.isPropertyAccessExpression(e)?x(e.getExpression())==="push"&&h.has(e.getName()):!1,M=(e,t)=>{const o=[];for(const r of p(t)){const n=e.getSourceFile(r)??e.addSourceFileAtPath(r),c=y(t,r);for(const s of m(n))if(!(s.kind!=="query"&&s.kind!=="mutation"))for(const i of s.handler.getDescendantsOfKind(l.PropertyAccessExpression)){const u=k(i);u!==void 0&&o.push({callee:u,exportName:s.exportName,file:c,kind:s.kind,line:i.getStartLineNumber()})}}return o},D=(e,t)=>{for(const o of p(t)){const r=e.getSourceFile(o)??e.addSourceFileAtPath(o);for(const n of m(r))for(const c of n.handler.getDescendantsOfKind(l.PropertyAccessExpression))if(C(c))return!0}return!1},z=(e,t)=>{const o=S(t,O);if(!P(o))return;const r=e.getSourceFile(o)??e.addSourceFileAtPath(o),n=E(r);let c=!1,s=!1;if(n&&f.isCallExpression(n)){const i=n.getArguments()[0];i&&f.isObjectLiteralExpression(i)&&(c=d(i,"webPush")!==void 0,s=d(i,"fcm")!==void 0)}return{hasFcm:s,hasWebPush:c,usesPush:D(e,t)}};export{O as NOTIFY_FILENAME,M as discoverNotifyCalls,z as discoverNotifyConfig};
1
+ import{existsSync as P}from"node:fs";import{join as S}from"node:path";import{SyntaxKind as l,Node as f}from"ts-morph";import{listLunoraSourceFiles as p,lunoraRelativePath as y,defaultExportExpression as E,findObjectProperty as d,handlerOf as g}from"./isTestPath-CgyyLk8U.mjs";import{b as N,d as v}from"./attribution-Dw35rOaJ.mjs";import{i as a}from"./context-root-B04bYCE-.mjs";import{c as F}from"./classify-procedure-call-DxuPQkJA.mjs";const O="notify.ts",A=new Set(["chat","inApp","send","webhook"]),h=new Set(["broadcast","send"]),b=e=>{const t=e.getInitializer();if(!t||!f.isCallExpression(t))return;const o=F(t);if(!o)return;const r=g(t,o.receiver);return r?{exportName:v(e)??e.getName(),handler:r,kind:o.kind}:void 0},m=e=>{const t=[];for(const o of N(e)){const r=b(o);r&&t.push(r)}return t},x=e=>a(e,["notify"])?"notify":a(e,["push"])||a(e,["notify","push"])?"push":void 0,k=e=>{if(!f.isPropertyAccessExpression(e))return;const t=e.getName(),o=x(e.getExpression());if(o==="notify"&&A.has(t))return`ctx.notify.${t}`;if(o==="push"&&h.has(t))return`ctx.push.${t}`},C=e=>f.isPropertyAccessExpression(e)?x(e.getExpression())==="push"&&h.has(e.getName()):!1,M=(e,t)=>{const o=[];for(const r of p(t)){const n=e.getSourceFile(r)??e.addSourceFileAtPath(r),c=y(t,r);for(const s of m(n))if(!(s.kind!=="query"&&s.kind!=="mutation"))for(const i of s.handler.getDescendantsOfKind(l.PropertyAccessExpression)){const u=k(i);u!==void 0&&o.push({callee:u,exportName:s.exportName,file:c,kind:s.kind,line:i.getStartLineNumber()})}}return o},D=(e,t)=>{for(const o of p(t)){const r=e.getSourceFile(o)??e.addSourceFileAtPath(o);for(const n of m(r))for(const c of n.handler.getDescendantsOfKind(l.PropertyAccessExpression))if(C(c))return!0}return!1},z=(e,t)=>{const o=S(t,O);if(!P(o))return;const r=e.getSourceFile(o)??e.addSourceFileAtPath(o),n=E(r);let c=!1,s=!1;if(n&&f.isCallExpression(n)){const i=n.getArguments()[0];i&&f.isObjectLiteralExpression(i)&&(c=d(i,"webPush")!==void 0,s=d(i,"fcm")!==void 0)}return{hasFcm:s,hasWebPush:c,usesPush:D(e,t)}};export{O as NOTIFY_FILENAME,M as discoverNotifyCalls,z as discoverNotifyConfig};
@@ -1,3 +1,3 @@
1
- import{m}from"./modules-6EEBTEDo.mjs";import{r as u}from"./json-data-Chfs2Cz5.mjs";import{s as p}from"./paths-C-9fwEgQ.mjs";import{validatorIrToJsonSchema as l,objectSchema as d,LUNORA_ERROR_CODES as i}from"./LUNORA_ERROR_CODES-C2s0xWQD.mjs";import{G as R}from"./shared-BXUKWh7t.mjs";const h="1.3.2",g={description:"Result is TS-inferred from the function's return type (no `.output()` declared); best-effort — any JSON."},f=(e,n)=>{const t=`${p(e.filePath)}:${e.exportName}`;return{description:`Invoke the \`${e.kind}\` \`${t}\` over the Lunora RPC envelope (POST /_lunora/rpc, body \`{ "functionPath": "${t}", "args": { … } }\`).`,errors:i.map((r,a)=>({code:-32e3-a,data:{code:r},message:r})),name:t,params:[{description:"The function's argument object (the RPC envelope's `args`).",name:"args",required:Object.keys(e.args).length>0,schema:d(e.args)}],result:{name:"result",schema:e.output?l(e.output):g},summary:`${e.kind}: ${t}`,"x-lunora-function-kind":e.kind,"x-tags":[{name:n}]}},O=e=>{const n=e.version??"0.0.0",s=e.functions.filter(o=>o.visibility!=="internal"&&o.kind!=="stream"),t=e.modules??[],r=s.map(o=>f(o,m(t,o.filePath))).toSorted((o,c)=>o.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:n},methods:r,openrpc:h}},E=e=>`${JSON.stringify(O(e),void 0,2)}
1
+ import{m}from"./modules-BIpFLz3Z.mjs";import{r as u}from"./json-data-Chfs2Cz5.mjs";import{s as p}from"./paths-DwTjD7BU.mjs";import{validatorIrToJsonSchema as l,objectSchema as d,LUNORA_ERROR_CODES as i}from"./LUNORA_ERROR_CODES-C2s0xWQD.mjs";import{G as R}from"./shared-Be3TGzxM.mjs";const h="1.3.2",g={description:"Result is TS-inferred from the function's return type (no `.output()` declared); best-effort — any JSON."},f=(e,n)=>{const t=`${p(e.filePath)}:${e.exportName}`;return{description:`Invoke the \`${e.kind}\` \`${t}\` over the Lunora RPC envelope (POST /_lunora/rpc, body \`{ "functionPath": "${t}", "args": { … } }\`).`,errors:i.map((r,a)=>({code:-32e3-a,data:{code:r},message:r})),name:t,params:[{description:"The function's argument object (the RPC envelope's `args`).",name:"args",required:Object.keys(e.args).length>0,schema:d(e.args)}],result:{name:"result",schema:e.output?l(e.output):g},summary:`${e.kind}: ${t}`,"x-lunora-function-kind":e.kind,"x-tags":[{name:n}]}},O=e=>{const n=e.version??"0.0.0",s=e.functions.filter(o=>o.visibility!=="internal"&&o.kind!=="stream"),t=e.modules??[],r=s.map(o=>f(o,m(t,o.filePath))).toSorted((o,c)=>o.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:n},methods:r,openrpc:h}},E=e=>`${JSON.stringify(O(e),void 0,2)}
2
2
  `,b=e=>`${R}export const openRpcSpec = ${u(e,"Record<string, unknown>")};
3
3
  `;export{h as OPENRPC_VERSION,O as buildOpenRpcDocument,E as emitOpenRpc,b as emitOpenRpcModule};
@@ -1 +1 @@
1
- import{existsSync as y}from"node:fs";import{join as b}from"node:path";import{LunoraError as h}from"@lunora/errors";import{queueDefaultName as x,queueBindingName as w}from"@lunora/queue";import{SyntaxKind as v,Node as u}from"ts-morph";import{diagnosticAt as m}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{lunoraRelativePath as g,findObjectProperty as l,stringPropertyFor as S}from"./isTestPath-DCyIyPa7.mjs";import{a as F}from"./attribution-NRssTEkk.mjs";import{r as P}from"./handler-reference-B3coD2YR.mjs";import{d as E}from"./modules-6EEBTEDo.mjs";const N="queues.ts",$=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 s=t.getNameNode().getText();return e(s)?s:void 0}},p=S("queue"),A=(o,e,i)=>{if(u.isNumericLiteral(o))return o.getLiteralValue();throw m(o,`queue "${e}": \`${i}\` must be a static numeric literal — it is deploy configuration codegen writes into wrangler.jsonc`)},I=(o,e)=>{const i=l(o,"name");if(!i||!u.isPropertyAssignment(i))return;const t=p(i.getInitializerOrThrow(),e,"name");if(t.length===0)throw m(i,`queue "${e}": \`name\` must be a non-empty string when provided`);return t},q=(o,e,i,t)=>{const s=P(l(o,"handler"),t)?.site,r={bindingName:w(e),exportName:e,filePath:g(t,o.getSourceFile().getFilePath()),mode:"push",name:I(o,e)??x(e),...i===void 0?{}:{topic:i},...s===void 0?{}:{handlerSite:s},tuning:{}},a=l(o,"mode");if(a&&u.isPropertyAssignment(a)){if(i!==void 0)throw m(a,`subscription "${e}": \`mode\` is not allowed — a subscription is always a push consumer`);const c=p(a.getInitializerOrThrow(),e,"mode");if(c!=="push"&&c!=="pull")throw m(a,`queue "${e}": \`mode\` must be "push" or "pull" (got ${JSON.stringify(c)})`);r.mode=c}const n=l(o,"deadLetterQueue");n&&u.isPropertyAssignment(n)&&(r.tuning.deadLetterQueue=p(n.getInitializerOrThrow(),e,"deadLetterQueue"));for(const c of["maxBatchSize","maxBatchTimeout","maxRetries","retryDelay"]){const d=l(o,c);d&&u.isPropertyAssignment(d)&&(r.tuning[c]=A(d.getInitializerOrThrow(),e,c))}return r},T=(o,e,i)=>{const t=o.getArguments()[0];if(!t||!u.isObjectLiteralExpression(t))throw m(o,`queue "${e}": defineQueue must be passed an inline object literal`);return q(t,e,void 0,i)},f=(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)?f(i.getSourceFile().getFilePath(),i.getName()):f(o.getSourceFile().getFilePath(),o.getText())},O=(o,e,i,t)=>{const[s,r]=o.getArguments(),a=s!==void 0&&u.isIdentifier(s)?i.get(Q(s)):void 0;if(a===void 0)throw m(s??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 m(o,`subscription "${e}": defineSubscription must be passed an inline object literal`);return q(r,e,a,t)},L=o=>{const e=[];for(const i of o.getVariableDeclarations()){const t=i.getInitializer();if(t?.getKind()!==v.CallExpression)continue;const s=t,r=s.getExpression(),a=u.isIdentifier(r)?$(r):void 0;if(a===void 0)continue;const n=i.getNameNode();if(!u.isIdentifier(n)){if(i.getVariableStatement()?.hasExportKeyword()!==!0)continue;throw m(n,`${a} exports must be plain named exports (no destructuring)`)}const c=F(i,"binding");c!==void 0&&e.push({call:s,exportName:c,factory:a,localName:n.getText()})}return e},U=(o,e)=>{const i=new Map;for(const t of o){const s=g(e,t.call.getSourceFile().getFilePath()),r=i.get(t.exportName);if(r!==void 0)throw m(t.call,`"${t.exportName}" is exported by both lunora/${r}.ts and lunora/${s}.ts — queue and topic export names must be unique across the app`);i.set(t.exportName,s)}},M=(o,e)=>{const i=o.flatMap(n=>L(n));U(i,e);const t=i.filter(n=>n.factory==="defineTopic"),s=new Map(t.map(n=>[f(n.call.getSourceFile().getFilePath(),n.localName),n.exportName])),r=[];for(const n of i)n.factory==="defineQueue"?r.push(T(n.call,n.exportName,e)):n.factory==="defineSubscription"&&r.push(O(n.call,n.exportName,s,e));const a=t.map(n=>({exportName:n.exportName,filePath:g(e,n.call.getSourceFile().getFilePath())}));return{queues:r,topics:a}},C=(o,e)=>[b(e,N),...E(o,e).map(i=>b(e,i.name,N))].filter(i=>y(i)),z=o=>{const e=new Map,i=new Map;for(const t of o){const s=e.get(t.name);if(s!==void 0)throw new h("DUPLICATE_QUEUE_NAME",`Duplicate queue name "${t.name}": produced by both "${s}" 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 h("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=C(o,e).map(a=>o.getSourceFile(a)??o.addSourceFileAtPath(a)),{queues:t,topics:s}=M(i,e),r=t.toSorted((a,n)=>a.exportName.localeCompare(n.exportName));return z(r),{queues:r,topics:s.toSorted((a,n)=>a.exportName.localeCompare(n.exportName))}},W=(o,e)=>D(o,e).queues;export{N as QUEUES_FILENAME,D as discoverQueueDeclarations,W as discoverQueues};
1
+ import{existsSync as y}from"node:fs";import{join as b}from"node:path";import{LunoraError as h}from"@lunora/errors";import{queueDefaultName as x,queueBindingName as w}from"@lunora/queue";import{SyntaxKind as v,Node as u}from"ts-morph";import{diagnosticAt as m}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{lunoraRelativePath as g,findObjectProperty as l,stringPropertyFor as S}from"./isTestPath-CgyyLk8U.mjs";import{a as F}from"./attribution-Dw35rOaJ.mjs";import{r as P}from"./handler-reference-2Hs4WKnz.mjs";import{d as E}from"./modules-BIpFLz3Z.mjs";const N="queues.ts",$=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 s=t.getNameNode().getText();return e(s)?s:void 0}},p=S("queue"),A=(o,e,i)=>{if(u.isNumericLiteral(o))return o.getLiteralValue();throw m(o,`queue "${e}": \`${i}\` must be a static numeric literal — it is deploy configuration codegen writes into wrangler.jsonc`)},I=(o,e)=>{const i=l(o,"name");if(!i||!u.isPropertyAssignment(i))return;const t=p(i.getInitializerOrThrow(),e,"name");if(t.length===0)throw m(i,`queue "${e}": \`name\` must be a non-empty string when provided`);return t},q=(o,e,i,t)=>{const s=P(l(o,"handler"),t)?.site,r={bindingName:w(e),exportName:e,filePath:g(t,o.getSourceFile().getFilePath()),mode:"push",name:I(o,e)??x(e),...i===void 0?{}:{topic:i},...s===void 0?{}:{handlerSite:s},tuning:{}},a=l(o,"mode");if(a&&u.isPropertyAssignment(a)){if(i!==void 0)throw m(a,`subscription "${e}": \`mode\` is not allowed — a subscription is always a push consumer`);const c=p(a.getInitializerOrThrow(),e,"mode");if(c!=="push"&&c!=="pull")throw m(a,`queue "${e}": \`mode\` must be "push" or "pull" (got ${JSON.stringify(c)})`);r.mode=c}const n=l(o,"deadLetterQueue");n&&u.isPropertyAssignment(n)&&(r.tuning.deadLetterQueue=p(n.getInitializerOrThrow(),e,"deadLetterQueue"));for(const c of["maxBatchSize","maxBatchTimeout","maxRetries","retryDelay"]){const d=l(o,c);d&&u.isPropertyAssignment(d)&&(r.tuning[c]=A(d.getInitializerOrThrow(),e,c))}return r},T=(o,e,i)=>{const t=o.getArguments()[0];if(!t||!u.isObjectLiteralExpression(t))throw m(o,`queue "${e}": defineQueue must be passed an inline object literal`);return q(t,e,void 0,i)},f=(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)?f(i.getSourceFile().getFilePath(),i.getName()):f(o.getSourceFile().getFilePath(),o.getText())},O=(o,e,i,t)=>{const[s,r]=o.getArguments(),a=s!==void 0&&u.isIdentifier(s)?i.get(Q(s)):void 0;if(a===void 0)throw m(s??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 m(o,`subscription "${e}": defineSubscription must be passed an inline object literal`);return q(r,e,a,t)},L=o=>{const e=[];for(const i of o.getVariableDeclarations()){const t=i.getInitializer();if(t?.getKind()!==v.CallExpression)continue;const s=t,r=s.getExpression(),a=u.isIdentifier(r)?$(r):void 0;if(a===void 0)continue;const n=i.getNameNode();if(!u.isIdentifier(n)){if(i.getVariableStatement()?.hasExportKeyword()!==!0)continue;throw m(n,`${a} exports must be plain named exports (no destructuring)`)}const c=F(i,"binding");c!==void 0&&e.push({call:s,exportName:c,factory:a,localName:n.getText()})}return e},U=(o,e)=>{const i=new Map;for(const t of o){const s=g(e,t.call.getSourceFile().getFilePath()),r=i.get(t.exportName);if(r!==void 0)throw m(t.call,`"${t.exportName}" is exported by both lunora/${r}.ts and lunora/${s}.ts — queue and topic export names must be unique across the app`);i.set(t.exportName,s)}},M=(o,e)=>{const i=o.flatMap(n=>L(n));U(i,e);const t=i.filter(n=>n.factory==="defineTopic"),s=new Map(t.map(n=>[f(n.call.getSourceFile().getFilePath(),n.localName),n.exportName])),r=[];for(const n of i)n.factory==="defineQueue"?r.push(T(n.call,n.exportName,e)):n.factory==="defineSubscription"&&r.push(O(n.call,n.exportName,s,e));const a=t.map(n=>({exportName:n.exportName,filePath:g(e,n.call.getSourceFile().getFilePath())}));return{queues:r,topics:a}},C=(o,e)=>[b(e,N),...E(o,e).map(i=>b(e,i.name,N))].filter(i=>y(i)),z=o=>{const e=new Map,i=new Map;for(const t of o){const s=e.get(t.name);if(s!==void 0)throw new h("DUPLICATE_QUEUE_NAME",`Duplicate queue name "${t.name}": produced by both "${s}" 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 h("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=C(o,e).map(a=>o.getSourceFile(a)??o.addSourceFileAtPath(a)),{queues:t,topics:s}=M(i,e),r=t.toSorted((a,n)=>a.exportName.localeCompare(n.exportName));return z(r),{queues:r,topics:s.toSorted((a,n)=>a.exportName.localeCompare(n.exportName))}},W=(o,e)=>D(o,e).queues;export{N as QUEUES_FILENAME,D as discoverQueueDeclarations,W as discoverQueues};