@lunora/config 1.0.0-alpha.47 → 1.0.0-alpha.470

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 (169) hide show
  1. package/LICENSE.md +336 -104
  2. package/README.md +6 -6
  3. package/dist/celld/index.d.mts +77 -0
  4. package/dist/celld/index.d.ts +77 -0
  5. package/dist/celld/index.mjs +1 -0
  6. package/dist/celld-names/index.d.mts +57 -0
  7. package/dist/celld-names/index.d.ts +57 -0
  8. package/dist/celld-names/index.mjs +1 -0
  9. package/dist/cli/index.d.mts +2 -0
  10. package/dist/cli/index.d.ts +2 -0
  11. package/dist/cli/index.mjs +1 -0
  12. package/dist/cloudflare/index.d.mts +941 -0
  13. package/dist/cloudflare/index.d.ts +941 -0
  14. package/dist/cloudflare/index.mjs +1 -0
  15. package/dist/index.d.mts +1045 -1044
  16. package/dist/index.d.ts +1045 -1044
  17. package/dist/index.mjs +1 -25
  18. package/dist/packem_shared/ACCENT-CotPTfv7.mjs +7 -0
  19. package/dist/packem_shared/ADVISOR_PROCEDURES_ENDPOINT-BPnqzAgT.mjs +1 -0
  20. package/dist/packem_shared/AGENT_MODE_ENV-D8MvSwPE.mjs +1 -0
  21. package/dist/packem_shared/AGENT_RULES_DIR-Bd6JPtNa.mjs +1 -0
  22. package/dist/packem_shared/ALLOW_FORWARDED_ENV-BUndghJx.mjs +1 -0
  23. package/dist/packem_shared/BINDING_MANIFEST_VERSION-CR06-eW7.mjs +1 -0
  24. package/dist/packem_shared/BUILD_ROOT_ENV-Dg4MV3wY.mjs +1 -0
  25. package/dist/packem_shared/CELLD_RELEASE_ASSETS_DIRECTORY-YBhEotjs.mjs +1 -0
  26. package/dist/packem_shared/CLOUDFLARE_CLI_CONFIG_WARNING_ENV-75Y5zVF8.mjs +1 -0
  27. package/dist/packem_shared/CLOUDFLARE_DRIVER-DbmpoIcg.mjs +1 -0
  28. package/dist/packem_shared/CLOUDFLARE_TOOLCHAIN_VERSIONS-DWyZ_2QM.mjs +1 -0
  29. package/dist/packem_shared/COMPOSED_WORKER_ENTRY-LpLlp-aF.mjs +1 -0
  30. package/dist/packem_shared/D1_PLACEHOLDER_ID-ZnDjVymH.mjs +1 -0
  31. package/dist/packem_shared/DEFAULT_DEPLOY_TARGET-BlvZ242-.mjs +1 -0
  32. package/dist/packem_shared/DEFAULT_OBSERVABILITY-CPLADr5u.mjs +1 -0
  33. package/dist/packem_shared/DEV_BINDINGS_FILE-C0ZN_XlP.mjs +4 -0
  34. package/dist/packem_shared/DEV_VARS_EXAMPLE_FILE-hBT89IXh.mjs +6 -0
  35. package/dist/packem_shared/DEV_WORKER_ENV_VALUE-FoysLtF0.mjs +1 -0
  36. package/dist/packem_shared/GLOBAL_FETCH_STRICTLY_PUBLIC_FLAG-f8CnJha3.mjs +1 -0
  37. package/dist/packem_shared/LINKED_PROJECT_DIR-Ba5qPEwo.mjs +2 -0
  38. package/dist/packem_shared/LUNORA_EVENT_SOURCE-Cq0oj0_9.mjs +9 -0
  39. package/dist/packem_shared/LUNORA_IGNORED_PATHS-U93uPxrW.mjs +19 -0
  40. package/dist/packem_shared/LUNORA_TAG-DQTGPqcJ.mjs +1 -0
  41. package/dist/packem_shared/LunoraReporter-f277GLNT.mjs +6 -0
  42. package/dist/packem_shared/MissingBuildOutputError-BAyekzof.mjs +1 -0
  43. package/dist/packem_shared/PACKAGE_SECRETS_REGISTRY-CPWkw-qE.mjs +1 -0
  44. package/dist/packem_shared/POLICY_SCAFFOLD_ENDPOINT-BiQ1zNsR.mjs +1 -0
  45. package/dist/packem_shared/REMOTE_ELIGIBLE_KEYS-D66_hwjD.mjs +1 -0
  46. package/dist/packem_shared/REQUIRED_COMPATIBILITY_DATE-BqFeetpX.mjs +1 -0
  47. package/dist/packem_shared/SCHEMA_EDIT_ENDPOINT-D296PlpV.mjs +1 -0
  48. package/dist/packem_shared/SEED_ENDPOINT-C1fhrehH.mjs +1 -0
  49. package/dist/packem_shared/STUDIO_PATH-CvVcvTbQ.mjs +1 -0
  50. package/dist/packem_shared/STUDIO_WRITE_TEMP_SUFFIX-BTTELz3K.mjs +1 -0
  51. package/dist/packem_shared/UNEXPORTED_CLASS_MARKER-BZEXldUo.mjs +1 -0
  52. package/dist/packem_shared/WORKERS_CACHE_MIN_DATE-0k9ABJtF.mjs +1 -0
  53. package/dist/packem_shared/WRANGLER_FILES-BF8PUjuo.mjs +1 -0
  54. package/dist/packem_shared/acceptsConnection-DHhUYGjT.mjs +2 -0
  55. package/dist/packem_shared/addArgsFor-CYZKhNIo.mjs +1 -0
  56. package/dist/packem_shared/applyAdditiveEdit-DEwPKcJg.mjs +6 -0
  57. package/dist/packem_shared/applyModify-DKP2l6S9.mjs +1 -0
  58. package/dist/packem_shared/assertBuildTargetMatches-D11J7F38.mjs +1 -0
  59. package/dist/packem_shared/assertWranglerSatisfiesSchema-_70vhvqk.mjs +3 -0
  60. package/dist/packem_shared/asset-headers-CPuEX21i.mjs +4 -0
  61. package/dist/packem_shared/assetContentType-CUb5bpbI.mjs +1 -0
  62. package/dist/packem_shared/binding-manifest.d-BRdoMhGE.d.mts +593 -0
  63. package/dist/packem_shared/binding-manifest.d-BRdoMhGE.d.ts +593 -0
  64. package/dist/packem_shared/bindingsNeedingDatabase-3KyGflIq.mjs +3 -0
  65. package/dist/packem_shared/blockingFindingsMessage-BQ9z7cie.mjs +1 -0
  66. package/dist/packem_shared/buildPackageSecretsBlock-DrSD60vH.mjs +19 -0
  67. package/dist/packem_shared/canonicalPath-DrfMiT3U.mjs +1 -0
  68. package/dist/packem_shared/celld-binding-id-9MiUoteo.mjs +1 -0
  69. package/dist/packem_shared/celld-config-Ef1RZ02t.mjs +3 -0
  70. package/dist/packem_shared/checkDevEnv-BwZSVBbB.mjs +3 -0
  71. package/dist/packem_shared/classifyPolicyEdit-DJi9Fk8G.mjs +24 -0
  72. package/dist/packem_shared/clearApiSpecMarker-DMGpP41V.mjs +2 -0
  73. package/dist/packem_shared/collectExportGaps-DHUtghqe.mjs +2 -0
  74. package/dist/packem_shared/createConfirm-D5mKTMHj.mjs +7 -0
  75. package/dist/packem_shared/createDiscoveryCache-npJI4uej.mjs +1 -0
  76. package/dist/packem_shared/createStudioDocumentCache-XBG1aWbl.mjs +1 -0
  77. package/dist/packem_shared/deploy-driver.d-CHVNQFV2.d.mts +190 -0
  78. package/dist/packem_shared/deploy-driver.d-CHVNQFV2.d.ts +190 -0
  79. package/dist/packem_shared/describePreservedCrons-i5XT6rtl.mjs +1 -0
  80. package/dist/packem_shared/describeWithheld-CbyzZjZF.mjs +1 -0
  81. package/dist/packem_shared/detectFramework-Dfpvu6rD.mjs +1 -0
  82. package/dist/packem_shared/devTriggerHints-CN_RJxWW.mjs +1 -0
  83. package/dist/packem_shared/devVariablesStamp-BQkGEn9d.mjs +1 -0
  84. package/dist/packem_shared/discover-info-DC2MrAIM.mjs +1 -0
  85. package/dist/packem_shared/discoverAgentInfo-pqFMJBtJ.mjs +1 -0
  86. package/dist/packem_shared/discoverContainerInfo-DzXr7Vm3.mjs +1 -0
  87. package/dist/packem_shared/discoverSchemaInfo-DRPnqgif.mjs +1 -0
  88. package/dist/packem_shared/discoverWorkflowInfo-zW7Tt0Tn.mjs +1 -0
  89. package/dist/packem_shared/emitProjectAssetHeaders-BdqdTVN3.mjs +1 -0
  90. package/dist/packem_shared/ensureGitignoreEntries-Tsk8Qkw7.mjs +7 -0
  91. package/dist/packem_shared/env-flag-u4B05gLp.mjs +1 -0
  92. package/dist/packem_shared/hasCloudflareCredentials-ByCrwaLT.mjs +1 -0
  93. package/dist/packem_shared/index.d-BoUSSRrk.d.mts +270 -0
  94. package/dist/packem_shared/index.d-C1nVDcie.d.ts +270 -0
  95. package/dist/packem_shared/inferLunoraBindings-Biq1OW9V.mjs +1 -0
  96. package/dist/packem_shared/is-plain-object-CWxHeOY1.mjs +1 -0
  97. package/dist/packem_shared/isOwnedStudioAssets-CHII-uIX.mjs +1 -0
  98. package/dist/packem_shared/materializeServiceDevConfigs-CI1HXv7f.mjs +1 -0
  99. package/dist/packem_shared/mergeWranglerEnvironment-CxT2PV1N.mjs +1 -0
  100. package/dist/packem_shared/parseSchema-D1Wbr1qv.mjs +1 -0
  101. package/dist/packem_shared/pendingBindingChanges-DqP40pSQ.mjs +1 -0
  102. package/dist/packem_shared/placeholder-ids.d-DvGHP6bl.d.mts +338 -0
  103. package/dist/packem_shared/placeholder-ids.d-DvGHP6bl.d.ts +338 -0
  104. package/dist/packem_shared/policy-scaffold.d-D2H4_G01.d.mts +86 -0
  105. package/dist/packem_shared/policy-scaffold.d-D2H4_G01.d.ts +86 -0
  106. package/dist/packem_shared/probeCelldToolchain-DxDttfHy.mjs +1 -0
  107. package/dist/packem_shared/process-tree-once-Ou4SfxKM.mjs +1 -0
  108. package/dist/packem_shared/queue-info-D38n7YdX.mjs +1 -0
  109. package/dist/packem_shared/readManifest-Cighz3WC.mjs +6 -0
  110. package/dist/packem_shared/readProjectDependencies-l3uhUKjo.mjs +1 -0
  111. package/dist/packem_shared/reconcile-services-CjgIJKim.mjs +1 -0
  112. package/dist/packem_shared/reconcileWranglerBindings-DAdI2Z-R.mjs +1 -0
  113. package/dist/packem_shared/reconcileWranglerCompatibilityDate-Cj94osA-.mjs +1 -0
  114. package/dist/packem_shared/renderStudioHtml-CRDTNivi.mjs +15 -0
  115. package/dist/packem_shared/resolveLocalWorkerEnv-C1s-quRt.mjs +1 -0
  116. package/dist/packem_shared/resolveSchemaDirectory-Ca5P6KuP.mjs +1 -0
  117. package/dist/packem_shared/runPostCodegenHook-Dx3yTsYZ.mjs +1 -0
  118. package/dist/packem_shared/scanWranglerVariablesForSecrets-DmdOBmwn.mjs +1 -0
  119. package/dist/packem_shared/secret-key-xi4VK8Jw.mjs +1 -0
  120. package/dist/packem_shared/sendStudioAsset-B81Pex91.mjs +1 -0
  121. package/dist/packem_shared/serveJsonHandler-B8_GE6QC.mjs +1 -0
  122. package/dist/packem_shared/spa-assets-wX8rTPEQ.mjs +1 -0
  123. package/dist/packem_shared/startCelldDevSession-DfuDVsha.mjs +1 -0
  124. package/dist/packem_shared/streamContainerLogs-0nko1qpv.mjs +2 -0
  125. package/dist/packem_shared/studio-assets-BKWx838V.mjs +1 -0
  126. package/dist/packem_shared/validate-bindings-DSMH8bRQ.mjs +1 -0
  127. package/dist/packem_shared/withTailConsumer-BXOIqXxv.mjs +1 -0
  128. package/dist/packem_shared/wranglerCodegenInputs-B8iRZZZw.mjs +1 -0
  129. package/dist/packem_shared/wranglerToAlchemy-ClIdvJFu.mjs +5 -0
  130. package/dist/packem_shared/write-atomic-9sY2z8DB.mjs +3 -0
  131. package/dist/packem_shared/writeAssetHeaders-C5igmezc.mjs +1 -0
  132. package/dist/studio-host/index.d.mts +371 -136
  133. package/dist/studio-host/index.d.ts +371 -136
  134. package/dist/studio-host/index.mjs +1 -7
  135. package/package.json +43 -10
  136. package/dist/packem_shared/ACCENT-DW1XJn8i.mjs +0 -40
  137. package/dist/packem_shared/AGENT_MODE_ENV-DM1Siczo.mjs +0 -17
  138. package/dist/packem_shared/AGENT_RULES_DIR-lcgC08aE.mjs +0 -40
  139. package/dist/packem_shared/DEV_DAEMON_ENV-FIEtW7Fz.mjs +0 -163
  140. package/dist/packem_shared/DEV_VARS_EXAMPLE_FILE-dJPNTEnK.mjs +0 -37
  141. package/dist/packem_shared/LINKED_PROJECT_DIR-CXwXzV_C.mjs +0 -52
  142. package/dist/packem_shared/LUNORA_CONFIG_FILE-CtcIcB5-.mjs +0 -34
  143. package/dist/packem_shared/LUNORA_EVENT_SOURCE-D2fDeGB6.mjs +0 -86
  144. package/dist/packem_shared/LunoraReporter-Ci-bDCK9.mjs +0 -70
  145. package/dist/packem_shared/PACKAGE_SECRETS_REGISTRY-B8t_SdoZ.mjs +0 -70
  146. package/dist/packem_shared/POLICY_SCAFFOLD_ENDPOINT-8bNMHGiu.mjs +0 -104
  147. package/dist/packem_shared/REMOTE_ELIGIBLE_KEYS-BC7_e9Bz.mjs +0 -105
  148. package/dist/packem_shared/REQUIRED_COMPATIBILITY_DATE-2YYyWJUq.mjs +0 -561
  149. package/dist/packem_shared/SCHEMA_EDIT_ENDPOINT-Df-Wrix-.mjs +0 -99
  150. package/dist/packem_shared/SEED_ENDPOINT-DVCjaGO-.mjs +0 -61
  151. package/dist/packem_shared/WRANGLER_FILES-DwSuC-Kn.mjs +0 -25
  152. package/dist/packem_shared/applyAdditiveEdit-C-snTFEV.mjs +0 -228
  153. package/dist/packem_shared/assetContentType-ByZjeV3D.mjs +0 -72
  154. package/dist/packem_shared/buildPackageSecretsBlock-B8iSX1Zo.mjs +0 -281
  155. package/dist/packem_shared/classifyPolicyEdit-BHeAqF8P.mjs +0 -99
  156. package/dist/packem_shared/createConfirm-fvpdgJ9s.mjs +0 -100
  157. package/dist/packem_shared/detectFramework-U08038Yp.mjs +0 -41
  158. package/dist/packem_shared/discoverContainerInfo-BXFs6Wav.mjs +0 -19
  159. package/dist/packem_shared/discoverSchemaInfo-BB-CKlTK.mjs +0 -25
  160. package/dist/packem_shared/discoverWorkflowInfo-CedvR0mn.mjs +0 -19
  161. package/dist/packem_shared/inferLunoraBindings-ByMwG-gH.mjs +0 -352
  162. package/dist/packem_shared/parseDevVariable-CJiq2IwE.mjs +0 -30
  163. package/dist/packem_shared/parseSchema-DSeyktvG.mjs +0 -107
  164. package/dist/packem_shared/policy-scaffold.d-DCmwn7zQ.d.mts +0 -74
  165. package/dist/packem_shared/policy-scaffold.d-DCmwn7zQ.d.ts +0 -74
  166. package/dist/packem_shared/reconcileWranglerBindings-Cruwwx1M.mjs +0 -334
  167. package/dist/packem_shared/renderStudioHtml-449Ysn75.mjs +0 -37
  168. package/dist/packem_shared/serveJsonHandler-B4OLTGLS.mjs +0 -86
  169. package/dist/packem_shared/streamContainerLogs-BZ4cOZwH.mjs +0 -157
@@ -0,0 +1,593 @@
1
+ /** The `wrangler.jsonc` shape the validator reads, and the report it returns. */
2
+ interface WranglerDurableObjectBinding$1 {
3
+ class_name?: string;
4
+ name?: string;
5
+ /** Present when the class lives in ANOTHER Worker — then it is that script's to export, not this entry's. */
6
+ script_name?: string;
7
+ }
8
+ /**
9
+ * A `tail_consumers` entry: a Worker that receives this Worker's tail events
10
+ * (logs, exceptions, fetch metadata) for forwarding to an external sink. See
11
+ * `withTailConsumer` for the wiring helper.
12
+ */
13
+ interface TailConsumer {
14
+ /** Optional Cloudflare environment of the consumer Worker. */
15
+ environment?: string;
16
+ /** Name of the Worker that consumes tail events. */
17
+ service?: string;
18
+ }
19
+ /**
20
+ * `observability.traces` — Workers Traces. `destinations` names OpenTelemetry
21
+ * export destinations configured in the dashboard; `persist: false` exports
22
+ * without also storing in Cloudflare (default `true`).
23
+ * https://developers.cloudflare.com/workers/observability/opentelemetry-export/
24
+ */
25
+ interface WranglerObservabilityTraces {
26
+ destinations?: ReadonlyArray<string>;
27
+ enabled?: boolean;
28
+ /** Fraction of requests traced, 0–1. */
29
+ head_sampling_rate?: number;
30
+ persist?: boolean;
31
+ }
32
+ /**
33
+ * `observability.logs` — Workers Logs. Same export knobs as traces, plus
34
+ * `invocation_logs` (the per-invocation summary line; default `true`).
35
+ */
36
+ interface WranglerObservabilityLogs extends WranglerObservabilityTraces {
37
+ invocation_logs?: boolean;
38
+ }
39
+ /** The wrangler `observability` block (Workers Logs + Traces). */
40
+ interface WranglerObservability {
41
+ enabled?: boolean;
42
+ /** Fraction of requests logged, 0–1 (wrangler's default is 1: every request). */
43
+ head_sampling_rate?: number;
44
+ /** Workers Issues — detects and groups production failures. */
45
+ issues?: {
46
+ enabled?: boolean;
47
+ };
48
+ logs?: WranglerObservabilityLogs;
49
+ /** Strip query strings from request URLs in logs and traces (wrangler's default is `false`). */
50
+ redact_query_string?: boolean;
51
+ traces?: WranglerObservabilityTraces;
52
+ }
53
+ /**
54
+ * The `observability` block Lunora writes when a project has none — by
55
+ * `lunora dev`'s binding reconcile and by `lunora init`'s scaffold. Logs on,
56
+ * every request sampled: the right default while an app is small, and what
57
+ * `lunora doctor`'s `observability-full-sampling` advisory then flags once
58
+ * Workers Observability is billed. One constant so the writers and the doctor
59
+ * cannot drift apart.
60
+ */
61
+ declare const DEFAULT_OBSERVABILITY: Readonly<{
62
+ enabled: true;
63
+ head_sampling_rate: 1;
64
+ redact_query_string: true;
65
+ }>;
66
+ /** One signal's effective sampling, as {@link resolveObservabilitySampling} resolves it. */
67
+ interface ObservabilitySignalSampling {
68
+ enabled: boolean;
69
+ /** Fraction of requests sampled, 0–1. */
70
+ headSamplingRate: number;
71
+ }
72
+ /**
73
+ * The effective logs / traces sampling an `observability` block deploys with,
74
+ * defaults applied. An absent block is {@link DEFAULT_OBSERVABILITY}, which is
75
+ * what Lunora reconciles it to. Inside a present block, logs are on unless the
76
+ * block (or its `logs` sub-block) turns them off; traces are opt-in
77
+ * (`traces.enabled: true`); and an unset rate is wrangler's own default of 1.
78
+ * `logs.*` overrides the top-level switch and rate.
79
+ */
80
+ declare const resolveObservabilitySampling: (block: WranglerObservability | undefined) => {
81
+ logs: ObservabilitySignalSampling;
82
+ traces: ObservabilitySignalSampling;
83
+ };
84
+ /** A wrangler `containers[]` entry (parsed from untrusted JSONC). */
85
+ interface WranglerContainerEntry {
86
+ class_name?: string;
87
+ image?: string;
88
+ /** Named images under the `durable_object` scheduling policy. */
89
+ images?: Record<string, {
90
+ build_context?: string;
91
+ build_vars?: Record<string, string>;
92
+ dockerfile?: string;
93
+ image?: string;
94
+ } | null | undefined>;
95
+ instance_type?: string | {
96
+ disk_mb?: number;
97
+ memory_mib?: number;
98
+ vcpu?: number;
99
+ };
100
+ max_instances?: number;
101
+ scheduling_policy?: string;
102
+ }
103
+ /**
104
+ * A wrangler `workflows[]` entry (parsed from untrusted JSONC). Unlike
105
+ * containers, workflows are NOT Durable Objects — the entry stands alone (no
106
+ * `durable_objects` binding, no migration class).
107
+ */
108
+ interface WranglerWorkflowEntry {
109
+ binding?: string;
110
+ class_name?: string;
111
+ /** `{ success_retention?, error_retention? }` durations; shape-checked by `validateWorkflowSettings`. */
112
+ default_retention?: unknown;
113
+ /** `{ steps? }`; shape-checked by `validateWorkflowSettings`. */
114
+ limits?: unknown;
115
+ name?: string;
116
+ /** Cron strings that each start an instance; shape-checked by `validateWorkflowSettings`. */
117
+ schedules?: unknown;
118
+ /** Present when the class lives in ANOTHER Worker — then it is that script's to export. */
119
+ script_name?: string;
120
+ }
121
+ /** A wrangler `queues.producers[]` entry — a `Queue` binding sending to `queue`. */
122
+ interface WranglerQueueProducer {
123
+ binding?: string;
124
+ delivery_delay?: number;
125
+ queue?: string;
126
+ }
127
+ /** A wrangler `queues.consumers[]` entry — push (worker) or `type: "http_pull"`. */
128
+ interface WranglerQueueConsumer {
129
+ dead_letter_queue?: string;
130
+ max_batch_size?: number;
131
+ max_batch_timeout?: number;
132
+ max_concurrency?: number;
133
+ max_retries?: number;
134
+ queue?: string;
135
+ retry_delay?: number;
136
+ type?: string;
137
+ }
138
+ interface WranglerConfig {
139
+ account_id?: unknown;
140
+ ai?: {
141
+ binding?: unknown;
142
+ } | null;
143
+ ai_search?: ReadonlyArray<{
144
+ binding?: string;
145
+ instance_name?: string;
146
+ remote?: boolean;
147
+ } | null | undefined>;
148
+ ai_search_namespaces?: ReadonlyArray<{
149
+ binding?: string;
150
+ namespace?: string;
151
+ remote?: boolean;
152
+ } | null | undefined>;
153
+ analytics?: {
154
+ binding?: unknown;
155
+ remote?: boolean;
156
+ } | null;
157
+ analytics_engine_datasets?: ReadonlyArray<{
158
+ binding?: string;
159
+ dataset?: string;
160
+ } | null | undefined>;
161
+ artifacts?: ReadonlyArray<{
162
+ binding?: string;
163
+ namespace?: string;
164
+ remote?: boolean;
165
+ } | null | undefined>;
166
+ assets?: {
167
+ binding?: string;
168
+ directory?: string;
169
+ html_handling?: string;
170
+ not_found_handling?: string;
171
+ run_worker_first?: boolean | ReadonlyArray<string>;
172
+ };
173
+ browser?: {
174
+ binding?: string;
175
+ };
176
+ cache?: {
177
+ enabled?: boolean;
178
+ } | null;
179
+ compatibility_date?: string;
180
+ compatibility_flags?: ReadonlyArray<string>;
181
+ containers?: ReadonlyArray<WranglerContainerEntry | null | undefined>;
182
+ d1_databases?: ReadonlyArray<{
183
+ binding?: string;
184
+ database_id?: string;
185
+ database_name?: string;
186
+ migrations_dir?: string;
187
+ migrations_pattern?: string;
188
+ } | null | undefined>;
189
+ dispatch_namespaces?: ReadonlyArray<{
190
+ binding?: string;
191
+ namespace?: string;
192
+ outbound?: unknown;
193
+ } | null | undefined>;
194
+ durable_objects?: {
195
+ bindings?: ReadonlyArray<WranglerDurableObjectBinding$1>;
196
+ };
197
+ env?: Record<string, WranglerConfig>;
198
+ exports?: Record<string, {
199
+ cache?: {
200
+ enabled?: boolean;
201
+ } | null;
202
+ default_retention?: unknown;
203
+ limits?: unknown;
204
+ name?: unknown;
205
+ schedules?: unknown;
206
+ type?: string;
207
+ } | null> | null;
208
+ flagship?: ReadonlyArray<{
209
+ app_id?: string;
210
+ binding?: string;
211
+ } | null | undefined>;
212
+ hyperdrive?: ReadonlyArray<{
213
+ binding?: string;
214
+ id?: string;
215
+ localConnectionString?: string;
216
+ } | null | undefined>;
217
+ images?: {
218
+ binding?: string;
219
+ };
220
+ k2?: ReadonlyArray<unknown>;
221
+ kv_namespaces?: ReadonlyArray<{
222
+ binding?: string;
223
+ id?: string;
224
+ } | null | undefined>;
225
+ limits?: {
226
+ cpu_ms?: number;
227
+ };
228
+ logpush?: boolean;
229
+ main?: string;
230
+ media?: {
231
+ binding?: string;
232
+ };
233
+ migrations?: ReadonlyArray<{
234
+ deleted_classes?: ReadonlyArray<string>;
235
+ new_classes?: ReadonlyArray<string>;
236
+ new_sqlite_classes?: ReadonlyArray<string>;
237
+ renamed_classes?: ReadonlyArray<{
238
+ from?: string;
239
+ to?: string;
240
+ } | null | undefined>;
241
+ } | null | undefined>;
242
+ mtls_certificates?: ReadonlyArray<{
243
+ binding?: string;
244
+ certificate_id?: string;
245
+ } | null | undefined>;
246
+ observability?: WranglerObservability;
247
+ pipelines?: ReadonlyArray<{
248
+ binding?: string;
249
+ pipeline?: string;
250
+ stream?: string;
251
+ } | null | undefined>;
252
+ placement?: {
253
+ host?: string;
254
+ hostname?: string;
255
+ mode?: string;
256
+ region?: string;
257
+ };
258
+ queues?: {
259
+ consumers?: ReadonlyArray<WranglerQueueConsumer | null | undefined>;
260
+ producers?: ReadonlyArray<WranglerQueueProducer | null | undefined>;
261
+ };
262
+ r2_buckets?: ReadonlyArray<{
263
+ binding?: string;
264
+ bucket_name?: string;
265
+ jurisdiction?: string;
266
+ } | null | undefined>;
267
+ secrets?: {
268
+ required?: unknown;
269
+ } | null;
270
+ secrets_store_secrets?: ReadonlyArray<{
271
+ binding?: string;
272
+ secret_name?: string;
273
+ store_id?: string;
274
+ } | null | undefined>;
275
+ send_email?: ReadonlyArray<{
276
+ allowed_destination_addresses?: ReadonlyArray<string>;
277
+ destination_address?: string;
278
+ name?: string;
279
+ } | null | undefined>;
280
+ services?: ReadonlyArray<{
281
+ binding?: string;
282
+ entrypoint?: string;
283
+ environment?: string;
284
+ service?: string;
285
+ } | null | undefined>;
286
+ stream?: {
287
+ binding?: string;
288
+ };
289
+ tail_consumers?: ReadonlyArray<TailConsumer | null | undefined>;
290
+ vars?: Record<string, unknown>;
291
+ vectorize?: ReadonlyArray<{
292
+ binding?: string;
293
+ index_name?: string;
294
+ } | null | undefined>;
295
+ vpc_networks?: ReadonlyArray<{
296
+ binding?: string;
297
+ network_id?: string;
298
+ remote?: boolean;
299
+ tunnel_id?: string;
300
+ } | null | undefined>;
301
+ vpc_services?: ReadonlyArray<{
302
+ binding?: string;
303
+ remote?: boolean;
304
+ service_id?: string;
305
+ } | null | undefined>;
306
+ workflows?: ReadonlyArray<WranglerWorkflowEntry | null | undefined>;
307
+ }
308
+ interface WranglerValidationReport {
309
+ errors: string[];
310
+ valid: boolean;
311
+ warnings: string[];
312
+ }
313
+ /** A Durable Object binding as `wrangler.jsonc` spells it. */
314
+ interface WranglerDurableObjectBinding {
315
+ class_name?: string;
316
+ name?: string;
317
+ script_name?: string;
318
+ }
319
+ /** The slice of `wrangler.jsonc` that translates into Alchemy resources. */
320
+ interface WranglerConfigShape {
321
+ ai?: {
322
+ binding?: string;
323
+ };
324
+ analytics_engine_datasets?: ReadonlyArray<{
325
+ binding?: string;
326
+ dataset?: string;
327
+ }>;
328
+ /** Static assets. Alchemy 2 always binds them as `ASSETS`. */
329
+ assets?: {
330
+ binding?: string;
331
+ directory?: string;
332
+ html_handling?: string;
333
+ not_found_handling?: string;
334
+ run_worker_first?: boolean | ReadonlyArray<string>;
335
+ };
336
+ browser?: {
337
+ binding?: string;
338
+ };
339
+ compatibility_date?: string;
340
+ compatibility_flags?: ReadonlyArray<string>;
341
+ d1_databases?: ReadonlyArray<{
342
+ binding?: string;
343
+ database_id?: string;
344
+ database_name?: string;
345
+ }>;
346
+ durable_objects?: {
347
+ bindings?: ReadonlyArray<WranglerDurableObjectBinding>;
348
+ };
349
+ hyperdrive?: ReadonlyArray<{
350
+ binding?: string;
351
+ id?: string;
352
+ }>;
353
+ images?: {
354
+ binding?: string;
355
+ };
356
+ kv_namespaces?: ReadonlyArray<{
357
+ binding?: string;
358
+ id?: string;
359
+ }>;
360
+ main?: string;
361
+ /** `new_sqlite_classes` marks which DO classes get SQLite storage. */
362
+ migrations?: ReadonlyArray<{
363
+ new_classes?: ReadonlyArray<string>;
364
+ new_sqlite_classes?: ReadonlyArray<string>;
365
+ tag?: string;
366
+ }>;
367
+ name?: string;
368
+ observability?: WranglerObservability;
369
+ queues?: {
370
+ consumers?: ReadonlyArray<WranglerQueueConsumer>;
371
+ producers?: ReadonlyArray<{
372
+ binding?: string;
373
+ queue?: string;
374
+ }>;
375
+ };
376
+ r2_buckets?: ReadonlyArray<{
377
+ binding?: string;
378
+ bucket_name?: string;
379
+ }>;
380
+ tail_consumers?: ReadonlyArray<{
381
+ service?: string;
382
+ }>;
383
+ triggers?: {
384
+ crons?: ReadonlyArray<string>;
385
+ };
386
+ vars?: Readonly<Record<string, unknown>>;
387
+ vectorize?: ReadonlyArray<{
388
+ binding?: string;
389
+ index_name?: string;
390
+ }>;
391
+ workers_dev?: boolean;
392
+ workflows?: ReadonlyArray<{
393
+ binding?: string;
394
+ class_name?: string;
395
+ name?: string;
396
+ script_name?: string;
397
+ }>;
398
+ }
399
+ /** What the translation could not carry over, so the caller can say so out loud. */
400
+ interface AlchemyTranslation {
401
+ /** The emitted program source (`alchemy.run.ts`). */
402
+ source: string;
403
+ /**
404
+ * Sections present in `wrangler.jsonc` that this translation drops.
405
+ *
406
+ * Reported rather than silently omitted: a deploy that quietly loses a
407
+ * service binding produces a worker whose `env.AUTH` is undefined at
408
+ * runtime, and nothing in the build says why.
409
+ */
410
+ unsupported: ReadonlyArray<string>;
411
+ }
412
+ /**
413
+ * Translate a parsed `wrangler.jsonc` into an Alchemy 2 program.
414
+ *
415
+ * Pure: it reads nothing and writes nothing, so the caller decides where the
416
+ * source lands and the whole thing stays testable as a string comparison.
417
+ * @param config The parsed `wrangler.jsonc`.
418
+ * @returns the program source, plus whatever could not be carried over.
419
+ */
420
+ declare const wranglerToAlchemy: (config: WranglerConfigShape) => AlchemyTranslation;
421
+ /** Schema version of the emitted document, so a consumer can gate on shape changes. */
422
+ declare const BINDING_MANIFEST_VERSION = 1;
423
+ /**
424
+ * One resource the built Worker expects to be bound to. `binding` is the name the
425
+ * Worker reads off `env`; the remaining fields are whatever identifies the
426
+ * resource for that type, omitted when the config does not carry them (an id
427
+ * Lunora could not mint is absent here exactly as it is absent from the config).
428
+ */
429
+ interface BindingRequirement {
430
+ /** The `env` property name the Worker reads. */
431
+ binding: string;
432
+ /**
433
+ * Durable Object / Workflow / Container class the Worker must export. Present
434
+ * for the class-backed binding types, so a deployer can assert the bundle
435
+ * exports it before publishing.
436
+ */
437
+ className?: string;
438
+ /** Bucket name (`r2`), database name (`d1`), dataset (`analytics_engine`), queue name (`queue`), index (`vectorize`), stream (`pipeline`), namespace (`artifacts`, `ai_search_namespace`), instance (`ai_search`), Worker name (`service`). */
439
+ resource?: string;
440
+ /** Remote resource id, when the config declares one (`d1`, `kv`, `hyperdrive`, `vpc_service`, `vpc_network`). */
441
+ resourceId?: string;
442
+ /** For `durable_object`: whether the class uses SQLite storage (`new_sqlite_classes`). */
443
+ sqlite?: boolean;
444
+ /** The kind of resource, keyed to the wrangler section it came from. */
445
+ type: "ai" | "ai_search" | "ai_search_namespace" | "analytics_engine" | "analytics_sql" | "artifacts" | "assets" | "browser" | "container" | "d1" | "durable_object" | "hyperdrive" | "images" | "kv" | "media" | "pipeline" | "queue_consumer" | "queue_producer" | "r2" | "service" | "stream" | "vectorize" | "vpc_network" | "vpc_service" | "workflow";
446
+ }
447
+ /** The document the `lunora build --emit-bindings` flag writes. */
448
+ interface BindingManifest {
449
+ /** Every resource the Worker expects, sorted by `type` then `binding` so the file is diff-stable. */
450
+ bindings: ReadonlyArray<BindingRequirement>;
451
+ /** `compatibility_date`, when declared. */
452
+ compatibilityDate?: string;
453
+ /** `compatibility_flags`, when declared. */
454
+ compatibilityFlags?: ReadonlyArray<string>;
455
+ /** Cron expressions the Worker must be triggered on (`triggers.crons`). */
456
+ crons: ReadonlyArray<string>;
457
+ /**
458
+ * Config keys whose value is not the shape wrangler expects — `kv_namespaces`
459
+ * as an object, a `null` entry in `queues.producers` — sorted. Whatever they
460
+ * held is left out of `bindings`: the builder reads a hand-edited config
461
+ * during `lunora dev`, where throwing would abort the start, and wrangler
462
+ * reports the bad key itself when it loads the file.
463
+ */
464
+ malformed: ReadonlyArray<string>;
465
+ /** Worker name from `wrangler.jsonc`. */
466
+ name?: string;
467
+ /**
468
+ * Wrangler sections present in the config that this version does not model,
469
+ * by field name. Empty for a fully-understood config; non-empty is a prompt to
470
+ * extend the collector, and is surfaced to the user rather than silently
471
+ * dropped.
472
+ */
473
+ unknown: ReadonlyArray<string>;
474
+ /** Names of `vars` entries. Values are deliberately excluded — a manifest is committed and read by CI, and a `vars` entry can hold a value a project would rather not publish. */
475
+ vars: ReadonlyArray<string>;
476
+ /** Schema version — {@link BINDING_MANIFEST_VERSION}. */
477
+ version: number;
478
+ }
479
+ /**
480
+ * The wider config this reads. {@link WranglerConfigShape} covers what the
481
+ * Alchemy translation models; a manifest additionally lists the sections that
482
+ * translation reports as unsupported, so those it reads are declared here.
483
+ */
484
+ interface ManifestConfigShape extends WranglerConfigShape {
485
+ ai?: {
486
+ binding?: string;
487
+ };
488
+ ai_search?: ReadonlyArray<{
489
+ binding?: string;
490
+ instance_name?: string;
491
+ }>;
492
+ ai_search_namespaces?: ReadonlyArray<{
493
+ binding?: string;
494
+ namespace?: string;
495
+ }>;
496
+ /** The Analytics SQL binding — a parameterless `{ binding }`, distinct from `analytics_engine_datasets`. */
497
+ analytics?: {
498
+ binding?: string;
499
+ };
500
+ analytics_engine_datasets?: ReadonlyArray<{
501
+ binding?: string;
502
+ dataset?: string;
503
+ }>;
504
+ artifacts?: ReadonlyArray<{
505
+ binding?: string;
506
+ namespace?: string;
507
+ }>;
508
+ /** Static assets carry a real `binding` the Worker reads (`env.ASSETS`). */
509
+ assets?: {
510
+ binding?: string;
511
+ directory?: string;
512
+ };
513
+ browser?: {
514
+ binding?: string;
515
+ };
516
+ containers?: ReadonlyArray<{
517
+ class_name?: string;
518
+ image?: string;
519
+ max_instances?: number;
520
+ }>;
521
+ /** Top-level exports; only `type: "workflow"` entries map to a binding requirement (see {@link collectWorkflowExports}). */
522
+ exports?: Record<string, {
523
+ name?: string;
524
+ type?: string;
525
+ } | null | undefined>;
526
+ hyperdrive?: ReadonlyArray<{
527
+ binding?: string;
528
+ id?: string;
529
+ }>;
530
+ images?: {
531
+ binding?: string;
532
+ };
533
+ media?: {
534
+ binding?: string;
535
+ };
536
+ /** `pipeline` is wrangler's deprecated spelling of `stream`; both are read. */
537
+ pipelines?: ReadonlyArray<{
538
+ binding?: string;
539
+ pipeline?: string;
540
+ stream?: string;
541
+ }>;
542
+ /** Adds `consumers` — the Alchemy translation models producers only. */
543
+ queues?: {
544
+ consumers?: ReadonlyArray<{
545
+ queue?: string;
546
+ }>;
547
+ producers?: ReadonlyArray<{
548
+ binding?: string;
549
+ queue?: string;
550
+ }>;
551
+ };
552
+ /** Service bindings to sibling Workers; `service` is the Worker name. */
553
+ services?: ReadonlyArray<{
554
+ binding?: string;
555
+ entrypoint?: string;
556
+ service?: string;
557
+ }>;
558
+ stream?: {
559
+ binding?: string;
560
+ };
561
+ vectorize?: ReadonlyArray<{
562
+ binding?: string;
563
+ index_name?: string;
564
+ }>;
565
+ vpc_networks?: ReadonlyArray<{
566
+ binding?: string;
567
+ network_id?: string;
568
+ tunnel_id?: string;
569
+ }>;
570
+ vpc_services?: ReadonlyArray<{
571
+ binding?: string;
572
+ service_id?: string;
573
+ }>;
574
+ workflows?: ReadonlyArray<{
575
+ binding?: string;
576
+ class_name?: string;
577
+ name?: string;
578
+ }>;
579
+ }
580
+ /**
581
+ * Build the manifest for a parsed `wrangler.jsonc`.
582
+ *
583
+ * Pure: reads nothing and writes nothing, so the caller decides where the
584
+ * document lands and the mapping stays testable as a plain object comparison.
585
+ *
586
+ * Total over any parsed JSON: the config is user-edited and read on every
587
+ * `lunora dev` start, so a section of the wrong shape lands in
588
+ * {@link BindingManifest.malformed} instead of throwing.
589
+ * @param config The parsed, already-reconciled `wrangler.jsonc`.
590
+ * @returns the requirements document.
591
+ */
592
+ declare const buildBindingManifest: (config: ManifestConfigShape) => BindingManifest;
593
+ export { AlchemyTranslation as A, BindingRequirement as B, DEFAULT_OBSERVABILITY as D, ManifestConfigShape as M, ObservabilitySignalSampling as O, TailConsumer as T, WranglerConfig as W, WranglerValidationReport as a, BINDING_MANIFEST_VERSION as b, BindingManifest as c, WranglerConfigShape as d, WranglerContainerEntry as e, WranglerObservability as f, WranglerObservabilityLogs as g, WranglerObservabilityTraces as h, WranglerWorkflowEntry as i, buildBindingManifest as j, resolveObservabilitySampling as r, wranglerToAlchemy as w };
@@ -0,0 +1,3 @@
1
+ import{createHash as O,randomUUID as v}from"node:crypto";import{mkdirSync as _,rmSync as y,readFileSync as N,writeFileSync as I,linkSync as w,renameSync as R}from"node:fs";import{findWranglerFile as C,readWranglerJsonc as k}from"./WRANGLER_FILES-BF8PUjuo.mjs";import{join as $}from"node:path";const E=["CLOUDFLARE_HYPERDRIVE_LOCAL_CONNECTION_STRING_","WRANGLER_HYPERDRIVE_LOCAL_CONNECTION_STRING_"],p=e=>`${E[0]}${e}`,D="pnpm add -D @electric-sql/pglite @electric-sql/pglite-socket",m="postgres://postgres:postgres@127.0.0.1:1/postgres",A=(e,t,r)=>typeof t.localConnectionString=="string"&&t.localConnectionString!==""||E.some(o=>{const n=r[`${o}${e}`]??"";return n!==""&&n!==m}),H=(e,t,r=t.CLOUDFLARE_ENV,o)=>{const n=o??C(e),i=n===void 0?void 0:k(n).parsed,c=r===void 0||r===""?void 0:i?.env?.[r];return((c===void 0?i?.hyperdrive:c.hyperdrive)??[]).flatMap(a=>typeof a?.binding=="string"&&a.binding!==""&&!A(a.binding,a,t)?[a.binding]:[])},T=async({PGlite:e,PGLiteSocketServer:t,vector:r},o)=>{const n=await e.create({dataDir:o,...r===void 0?{}:{extensions:{vector:r}}});let i;try{i=new t({db:n,host:"127.0.0.1",maxConnections:16,port:0}),await i.start()}catch(a){throw await Promise.allSettled([i?.stop(),n.close()]),a}const[c="127.0.0.1",g="5432"]=i.getServerConn().split(":");return{connectionString:`postgres://postgres:postgres@${c}:${g}/postgres`,stop:async()=>{try{await i.stop()}finally{await n.close()}}}},P=/[^\w-]/gu,F=e=>{const t=e.replaceAll(P,"_");return t===e?e:`${t}-${O("sha256").update(e).digest("hex").slice(0,8)}`},q=e=>{try{return process.kill(e,0),!0}catch(t){return t.code==="EPERM"}},x=e=>{try{const t=JSON.parse(N($(e,"package.json"),"utf8")),r=new Set([...Object.keys(t.dependencies??{}),...Object.keys(t.devDependencies??{})]);return r.has("mysql2")&&!r.has("pg")&&!r.has("postgres")}catch{return!1}},f=new Set,G=()=>{for(const e of f)y(e,{force:!0});f.clear()};let h=!1;const U=()=>{h||(h=!0,process.once("exit",G))},S=e=>{try{const[t="",r=""]=N(e,"utf8").split(`
2
+ `),o=Number.parseInt(t,10);return Number.isInteger(o)?{kind:"pid",pid:o,token:r}:{kind:"garbage",pid:-1,token:""}}catch(t){return{kind:t.code==="ENOENT"?"gone":"unreadable",pid:-1,token:""}}},L=e=>e.kind==="pid"&&e.pid!==process.pid&&q(e.pid),j=(e,t)=>{try{w(e,t)}catch(r){if(r.code!=="EEXIST")throw r;return}return f.add(t),U(),{release:()=>{f.delete(t)&&y(t,{force:!0})}}},W=(e,t)=>{const r=`${e}.stale.${v()}`;try{R(e,r)}catch{return}const o=S(r);try{if(o.token!==t.token&&L(o)){try{w(r,e)}catch{}return{holder:o.pid}}return}finally{y(r,{force:!0})}},M=e=>{const t=`${e}.${String(process.pid)}.${v()}`;I(t,`${String(process.pid)}
3
+ ${v()}`,"utf8");try{for(let r=0;r<3;r+=1){const o=j(t,e);if(o!==void 0)return o;if(f.has(e))return{holder:process.pid};const n=S(e);if(n.kind==="unreadable"||L(n))return{holder:n.pid};const i=n.kind==="gone"?void 0:W(e,n);if(i!==void 0)return i}return{holder:S(e).pid}}finally{y(t,{force:!0})}},V=/@electric-sql\/pglite/u,B=async()=>{try{const[{PGlite:e},{PGLiteSocketServer:t}]=await Promise.all([import("@electric-sql/pglite"),import("@electric-sql/pglite-socket")]),r=await import("@electric-sql/pglite-pgvector").then(o=>o.vector,()=>{});return{createServer:async o=>T({PGlite:e,PGLiteSocketServer:t,vector:r},o)}}catch(e){const{code:t,message:r}=e;if((t==="ERR_MODULE_NOT_FOUND"||t==="MODULE_NOT_FOUND")&&V.test(r??""))return;throw e}},Q=async e=>{try{return{runtime:await e()}}catch(t){return{failure:t instanceof Error?t.message:String(t)}}},J=async(e,t,r)=>{try{const o=await e.createServer(t);return{connectionString:o.connectionString,stop:async()=>{try{await o.stop()}finally{r.release()}}}}catch(o){throw r.release(),o}},X=(e,t)=>`Hyperdrive binding ${e.map(r=>`"${r}"`).join(", ")}: the embedded Postgres is installed but failed to load (${t}), so \`ctx.sql\` will fail to connect in dev. Set ${p(e[0]??"<BINDING>")} to use a database of your own.`,Y=(e,t)=>{const r=e.map(n=>`"${n}"`).join(", "),o=p(e[0]??"<BINDING>");return t?`Hyperdrive binding ${r}: this project's SQL driver is mysql2, and the embedded database speaks PostgreSQL, so \`ctx.sql\` will fail to connect in dev. Set ${o} to a local MySQL connection string.`:`Hyperdrive binding ${r} has no local database, so \`ctx.sql\` will fail to connect in dev. Run \`${D}\` for an embedded Postgres, or set ${o}.`},te=async e=>{const t=e.env??process.env,r=H(e.projectRoot,t,void 0,e.wranglerConfigPath);if(r.length===0)return;const o=new Map,n=s=>{t[p(s)]=m,o.set(s,m)},i=[],c=async()=>{const s=i.splice(0),l=[...o];o.clear();for(const[d,u]of l)t[p(d)]===u&&Reflect.deleteProperty(t,p(d));await Promise.allSettled(s.map(async d=>d.stop()))},g=x(e.projectRoot),{failure:a,runtime:b}=g?{failure:void 0,runtime:void 0}:await Q(e.load??B);if(b===void 0){e.onWarning?.(a===void 0?Y(r,g):X(r,a));for(const s of r)n(s);return{bindings:[],stop:c}}try{for(const s of r){const l=$(e.projectRoot,".wrangler","state","lunora-pglite",F(s));_(l,{recursive:!0});const d=M(`${l}.lock`);if("holder"in d){e.onWarning?.(`Hyperdrive binding "${s}": another process (pid ${String(d.holder)}) has its embedded Postgres open, so \`ctx.sql\` will fail to connect here. Stop it, or set ${p(s)} to use a database of your own.`),n(s);continue}const u=await J(b,l,d);i.push({binding:s,stop:u.stop}),t[p(s)]=u.connectionString,o.set(s,u.connectionString)}}catch(s){e.onWarning?.(`Could not start the embedded Postgres for Hyperdrive: ${s instanceof Error?s.message:String(s)}`),await c();for(const l of r)n(l);return{bindings:[],stop:c}}return{bindings:i.map(({binding:s})=>s),stop:c}};export{H as bindingsNeedingDatabase,G as releaseHeldLocks,T as serveDatabase,te as startLocalHyperdrive};
@@ -0,0 +1 @@
1
+ import{describeErrorLevelFindings as a,sortedUniqueNames as d}from"@lunora/codegen";import{LUNORA_TAG as l,advisoryLine as n}from"./LUNORA_TAG-DQTGPqcJ.mjs";const f=(o,i)=>{for(const e of o.advisories){const s=n(e.level,e.name,e.detail,e.remediation);e.suppressed!==void 0?i.warn(`${s} (suppressed: ${e.suppressed.reason})`):e.level==="ERROR"?i.error(s):i.warn(s)}for(const e of o.platformDiagnostics){const s=n(e.level==="error"?"ERROR":"WARN",e.name,e.message,e.remediation);e.level==="error"?i.error(s):i.warn(s)}},v=(o,i={})=>{const{advisoryNames:e,platformDiagnosticNames:s}=a(o),r=d([...i.strictAdvisories===!1?[]:e,...s]);if(r.length===0)return;const t=r.length===1?"advisory/platform diagnostic":"advisories/platform diagnostics";return`${l} ${String(r.length)} ERROR-level ${t} (${r.join(", ")}) — see the log above for detail.`};export{v as blockingFindingsMessage,f as reportCodegenFindings};
@@ -0,0 +1,19 @@
1
+ import{randomBytes as V}from"node:crypto";import{existsSync as j,readFileSync as x,writeFileSync as h,linkSync as B,rmSync as m,renameSync as L,statSync as O}from"node:fs";import{join as g}from"node:path";import{LunoraError as z}from"@lunora/errors";import{DEV_VARS_FILE as u,DEV_VARS_EXAMPLE_FILE as f,parseDevVariableLine as K,parseDevVariableEntries as E,DEV_VARS_NEWLINE as b}from"./DEV_VARS_EXAMPLE_FILE-hBT89IXh.mjs";import{MINTABLE_SECRET_KEYS as W,SHARD_RELAY_SECRET_KEY as y,CORE_SECRETS as P,mintableSecretKeysFor as U,SHARD_RELAY_HOST_PLACEHOLDER as Y,secretsForPackages as X}from"./PACKAGE_SECRETS_REGISTRY-CPWkw-qE.mjs";const H=e=>[...P,...X(e)],k=32,G=["replace","openssl","changeme","change-me","change_me","change-this","change_this","your-","your_","example","placeholder","todo","fill-me","fill_me","fill-in","fill_in","xxx"],q=/[.*+?^${}()|[\]\\]/gu,J=/[a-z0-9]$/u,T=e=>{const t=e.trim().toLowerCase();return t===""||t.startsWith("<")&&t.endsWith(">")?!0:G.some(n=>{const r=n.replaceAll(q,String.raw`\$&`),s=J.test(n)?`(^|[^a-z0-9])${r}([^a-z0-9]|$)`:`(^|[^a-z0-9])${r}`;return new RegExp(s,"u").test(t)})},p=e=>V(e).toString("hex"),w=new Set([...W,y]),Q=(e,t,n=w)=>e===y?n.has(e)&&(t.trim()===""||t===Y):n.has(e),F=(e,t,n,r)=>Q(e,t,r)&&T(t)?n(k):void 0,me=(e=p)=>e(k),M=(e,t,n,r=w)=>e.split(b).map(o=>{const s=K(o),i=s?F(s.key,s.value,t,r):void 0;return!s||i===void 0?o:(n.push(s.key),`${s.key}="${i}"`)}),Z=e=>{if(e.devVarsExists)return{status:"exists"};if(e.exampleContent===void 0)return{status:"no-example"};const t=[];return{content:M(e.exampleContent,e.randomHex??p,t).join(`
2
+ `),generatedKeys:t,status:"generate"}},ee=e=>e.includes('"')||e.includes("\\")?"":e.replaceAll("\r",String.raw`\r`).replaceAll(`
3
+ `,String.raw`\n`),A=e=>{const t=e.randomHex??p,n=new Set(E(e.existingContent).map(i=>i.key)),r=[],o=[],s=[];for(const i of e.exampleContent.split(b)){const a=K(i);if(!a||n.has(a.key))continue;const l=F(a.key,a.value,t,w);s.push(a.key),l===void 0?r.push(`${a.key}="${ee(a.value)}"`):(o.push(a.key),r.push(`${a.key}="${l}"`))}return{additions:r,generatedKeys:o,missingKeys:s}},R=e=>e.length>0?` (generated ${e.join(", ")})`:"",I=e=>`${e}.tmp-${String(process.pid)}`,v=(e,t,n={})=>{const r=I(e);try{h(r,t,{encoding:"utf8",...n}),L(r,e)}catch(o){throw m(r,{force:!0}),o}},te=(e,t)=>{try{return h(e,t,{encoding:"utf8",flag:"wx",mode:384}),!0}catch(n){if(n.code==="EEXIST")return!1;throw n}},N=(e,t)=>{const n=I(e);try{h(n,t,{encoding:"utf8",flag:"wx",mode:384});try{return B(n,e),!0}catch(r){const{code:o}=r;if(o==="EEXIST")return!1;if(o==="EPERM"||o==="ENOTSUP")return te(e,t);throw r}}finally{m(n,{force:!0})}},ge=(e,t)=>{v(e,t,{mode:384})},D=5,C=e=>{try{const t=O(e);return{mtimeMs:t.mtimeMs,size:t.size}}catch{return}},ne=(e,t)=>e===void 0||t===void 0?!1:e.mtimeMs===t.mtimeMs&&e.size===t.size,re=(e,t)=>{for(let n=0;n<D;n+=1){const r=C(e),o=x(e,"utf8"),s=t(o);if(s.length===0)return[];const i=o.length>0&&!o.endsWith(`
4
+ `)?`
5
+ `:"",a=`${o}${i}${s.join(`
6
+ `)}
7
+ `,l=`${e}.tmp-${String(process.pid)}-${V(6).toString("hex")}`;try{h(l,a,{encoding:"utf8",mode:384});const c=C(e);if(!ne(r,c)){m(l,{force:!0});continue}return L(l,e),s}catch(c){throw m(l,{force:!0}),c}}throw new z("INTERNAL",`Failed to append to ${e} after ${String(D)} attempts — a concurrent writer kept winning the race.`)},se=new Set(["EACCES","EISDIR","EPERM"]),$=e=>{try{return{content:x(e,"utf8"),kind:"read"}}catch(t){const{code:n}=t;if(n==="ENOENT")return{kind:"missing"};if(n!==void 0&&se.has(n))return{code:n,kind:"unreadable"};throw t}},he=async e=>{const t=g(e.cwd,u),n=$(t),r=$(g(e.cwd,f));for(const[d,S]of[[u,n],[f,r]])if(S.kind==="unreadable")return(e.warn??e.info)(`skipped the ${u} scaffold: ${d} is not a readable file (${S.code})`),{addedKeys:[],generatedKeys:[],status:"unreadable"};if(r.kind!=="read")return{addedKeys:[],generatedKeys:[],status:"no-example"};const o=r.content;if(n.kind!=="read"){const d=Z({devVarsExists:!1,exampleContent:o,randomHex:e.randomHex});return d.status!=="generate"?{addedKeys:[],generatedKeys:[],status:"no-example"}:e.yes===!0||await e.confirm(`No ${u} found. Generate it from ${f} (secrets auto-filled)?`)?N(t,d.content)?(e.info(`Created ${u}${R(d.generatedKeys)}.`),{addedKeys:[],generatedKeys:d.generatedKeys,status:"generated"}):{addedKeys:[],generatedKeys:[],status:"skipped-exists"}:(e.info(`Skipped — copy ${f} to ${u} and fill it in when you're ready.`),{addedKeys:[],generatedKeys:[],status:"declined"})}const s=A({existingContent:n.content,exampleContent:o,randomHex:e.randomHex});if(s.missingKeys.length===0)return{addedKeys:[],generatedKeys:[],status:"exists"};const i=s.missingKeys.join(", ");if(!(e.yes===!0||await e.confirm(`${u} is missing ${String(s.missingKeys.length)} key(s) from ${f} (${i}). Add them?`)))return e.info(`Skipped — add ${i} to ${u} when you're ready.`),{addedKeys:[],generatedKeys:[],status:"declined"};const c=re(t,d=>A({existingContent:d,exampleContent:o,randomHex:e.randomHex}).additions).map(d=>K(d)?.key).filter(d=>d!==void 0);if(c.length===0)return{addedKeys:[],generatedKeys:[],status:"exists"};const _=s.generatedKeys.filter(d=>c.includes(d));return e.info(`Updated ${u} — added ${c.join(", ")}${R(_)}.`),{addedKeys:c,generatedKeys:_,status:"augmented"}},oe=e=>[`# ${e.description}`,`# Docs: ${e.docsUrl}`,`${e.key}="${e.placeholderValue}"`].join(`
8
+ `),ie=(e,t)=>{const n=H(e).filter(r=>!t.has(r.key));return n.length===0?"":n.map(r=>oe(r)).join(`
9
+
10
+ `)},Ee=(e,t)=>{const n=g(e,f),r=j(n)?x(n,"utf8"):"",o=new Set(E(r).map(a=>a.key)),s=ie(t,o);if(s==="")return[];const i=r.length>0&&!r.endsWith(`
11
+ `)?`
12
+ `:"";return v(n,`${r}${i}
13
+ ${s}
14
+ `),H(t).filter(a=>!o.has(a.key)).map(a=>a.key)},ae=e=>{const t=e.randomHex??p,n=[],r=M(e.existingContent,t,n,e.mintable),o=new Set(E(e.existingContent).map(c=>c.key)),s=[],i=[];for(const c of P)o.has(c.key)||(s.push(c.key),i.push(`# ${c.description}`,`${c.key}="${t(k)}"`));const a=r.join(`
15
+ `);if(i.length===0)return{addedKeys:s,content:a,filledKeys:n};const l=a===""||a.endsWith(`
16
+ `)?"":`
17
+ `;return{addedKeys:s,content:`${a}${l}${i.join(`
18
+ `)}
19
+ `,filledKeys:n}},pe=e=>{const t=g(e.cwd,u),n=$(t);if(n.kind==="unreadable")return{addedKeys:[],filledKeys:[],status:"unchanged"};const r=n.kind==="read",o=r?n.content:"",s=e.secretSources===void 0?void 0:U(e.secretSources),i=ae({existingContent:o,mintable:s,randomHex:e.randomHex}),a=E(i.content).find(c=>c.key===y)?.value;if(s!==void 0&&!s.has(y)&&a!==void 0&&T(a)&&e.info?.(`${y} is still a placeholder. This worker only calls an event log hosted elsewhere, so set it to the ${y} of the worker that hosts EventLogDO.`),i.filledKeys.length===0&&i.addedKeys.length===0)return{addedKeys:[],filledKeys:[],status:"unchanged"};if(r)v(t,i.content,{mode:384});else if(!N(t,i.content))return{addedKeys:[],filledKeys:[],status:"unchanged"};const l=[...i.filledKeys,...i.addedKeys];return e.info?.(`Generated ${String(l.length)} dev secret(s) in ${u}: ${l.join(", ")}`),{addedKeys:i.addedKeys,filledKeys:i.filledKeys,status:r?"filled":"created"}};export{ie as buildPackageSecretsBlock,he as ensureDevVariables,Ee as ensureDevVarsExample,pe as fillDevSecrets,me as generateSecretValue,Q as isMintableSecretKey,T as isPlaceholderValue,ae as planDevSecretsFill,A as planDevVariablesAugment,Z as planDevVariablesScaffold,H as requiredSecrets,ge as writeDevVariablesFileAtomically};
@@ -0,0 +1 @@
1
+ import{realpathSync as e}from"node:fs";import{resolve as n,dirname as o,join as c,basename as s}from"node:path";const i=r=>{const t=n(r);try{return e.native(t)}catch{const a=o(t);return a===t?t:c(i(a),s(t))}};export{i as default};
@@ -0,0 +1 @@
1
+ import{LunoraError as t}from"@lunora/errors";const i=(e,n)=>{if(typeof e!="string"||e.length===0)throw new t("BAD_REQUEST",`the celld projection needs the Worker's \`name\` to give the id-less binding "${n}" a fleet-wide id; set \`name\` in wrangler.jsonc`);return`${e}-${n}`};export{i as c};
@@ -0,0 +1,3 @@
1
+ import{writeFileSync as $,rmSync as W,existsSync as w,readFileSync as A}from"node:fs";import{dirname as E,resolve as h,join as v,sep as y,relative as _,isAbsolute as B}from"node:path";import{MissingBuildOutputError as x}from"./MissingBuildOutputError-BAyekzof.mjs";import{D1_PLACEHOLDER_ID as F}from"./D1_PLACEHOLDER_ID-ZnDjVymH.mjs";import{findWranglerFile as K,readWranglerJsonc as Y}from"./WRANGLER_FILES-BF8PUjuo.mjs";import{DEV_VARS_FILE as G,parseDevVariableEntries as J}from"./DEV_VARS_EXAMPLE_FILE-hBT89IXh.mjs";import D from"./ensureGitignoreEntries-Tsk8Qkw7.mjs";import{c as k}from"./celld-binding-id-9MiUoteo.mjs";const q=".celld.wrangler.json",C=[".celld/",".celld.wrangler.json",".celld.service.*.wrangler.json"],M=v(".wrangler","deploy","config.json"),U=new Set(["$schema","assets","compatibility_date","compatibility_flags","containers","d1_databases","define","durable_objects","kv_namespaces","main","migrations","name","no_bundle","queues","r2_buckets","rules","services","triggers","vars","worker_loaders","workflows"]),H=new Set(["class_name","image","instance_type","max_instances","name","runtime"]),X=new Set(["CompiledWasm","Data","Text"]),z=/\r?\n/u,Q=/[!*?[]/u,Z=/[.[]/u,ee=["deleted_classes","new_classes","renamed_classes","transferred_classes"],c=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),I=e=>Array.isArray(e)&&e.length===0||c(e)&&Object.values(e).every(s=>I(s)),re=e=>Array.isArray(e)?e.map(s=>{if(!c(s))return s;const r=ee.find(t=>s[t]!==void 0);if(r!==void 0)throw new Error(`migration "${String(s.tag)}" uses \`${r}\`, which celld refuses — celld accepts only \`new_sqlite_classes\` migrations`);return{new_sqlite_classes:s.new_sqlite_classes,tag:s.tag}}):e,se=(e,s)=>Array.isArray(e)?e.map((r,t)=>c(r)?Object.fromEntries(Object.entries(r).filter(([n])=>{const i=H.has(n);return i||s.push(`containers[${String(t)}].${n}`),i})):r):e,te=(e,s)=>Array.isArray(e)?e.filter((r,t)=>{const n=c(r)&&typeof r.type=="string"&&X.has(r.type);return n||s.push(`rules[${String(t)}]`),n}):e,ne=e=>{const s=[],r={};for(const[t,n]of Object.entries(c(e)?e:{}))c(n)&&n.type==="workflow"?s.push({binding:t,class_name:t,name:n.name}):r[t]=n;return{bindings:s,rest:r}},ie=(e,s)=>Array.isArray(e)?e.map(r=>!c(r)||r.database_id!==F?r:typeof r.database_name=="string"?{...r,database_id:r.database_name}:typeof r.binding=="string"?{...r,database_id:k(s,r.binding)}:r):e,oe=(e,s)=>Array.isArray(e)?e.map(r=>c(r)&&r.id===void 0&&typeof r.binding=="string"?{...r,id:k(s,r.binding)}:r):e,N=e=>{const s=[],r={},t=ne(e.exports),n={...e,exports:t.rest};for(const[i,o]of Object.entries(n)){if(!U.has(i)){I(o)||s.push(i);continue}switch(i){case"containers":{r[i]=se(o,s);break}case"d1_databases":{r[i]=ie(o,e.name);break}case"kv_namespaces":{r[i]=oe(o,e.name);break}case"migrations":{r[i]=re(o);break}case"rules":{r[i]=te(o,s);break}default:r[i]=o}}if(t.bindings.length>0){const i=Array.isArray(r.workflows)?r.workflows:[];r.workflows=[...i,...t.bindings]}return{config:r,dropped:s}},ae=e=>{const[s=[],...r]=e.map(n=>h(n).split(y));let t=0;for(;t<s.length&&r.every(n=>n[t]===s[t]);)t+=1;return s.slice(0,t).join(y)||y},P=(e,s,r)=>{const t=i=>_(r,h(s,i)).split(y).join("/"),n={...e};return typeof e.main=="string"&&(n.main=t(e.main)),c(e.assets)&&typeof e.assets.directory=="string"&&(n.assets={...e.assets,directory:t(e.assets.directory)}),n},ce=e=>{const s=v(e,".assetsignore");if(!w(s))return;const r=A(s,"utf8").split(z).map(t=>t.trim()).filter(t=>t!==""&&!t.startsWith("#")).filter(t=>Q.test(t)||w(v(e,t)));if(r.length>0)throw new Error(`${s} hides ${r.join(", ")} from the assets, and celld has no .assetsignore — remove those files from ${e} first`);return s},le=(e,s)=>{const r=v(e,M);if(!w(r))throw new x(`wrangler \`main\` is the Vite virtual module "${s}", so celld deploys the Vite build output — and there is none yet. Run the project's build (\`vite build\`) first`);const{configPath:t}=JSON.parse(A(r,"utf8"));if(typeof t!="string")throw new TypeError(`${r} names no configPath`);return h(E(r),t)},S=e=>{const{parsed:s}=Y(e);if(s===void 0)throw new Error(`${e} is not valid JSONC`);return s},T=(e,s,r,t)=>{const{d1_databases:n}=e;if(!Array.isArray(n)||t===r)return e;const i=Array.isArray(s.d1_databases)?s.d1_databases.filter(o=>c(o)):[];return{...e,d1_databases:n.map(o=>{if(!c(o))return o;const a=i.find(m=>m.binding===o.binding),l=a?.migrations_dir,p=h(r,typeof l=="string"?l:"migrations"),d=w(p)?{...o,migrations_dir:_(t,p).split(y).join("/")}:o,f=a?.migrations_pattern;return typeof f=="string"?{...d,migrations_pattern:_(t,h(r,f)).split(y).join("/")}:d})}},de=(e,s,r,t)=>{const{main:n}=r;if(typeof n!="string"||!n.startsWith("virtual:"))return{fromBuild:!1,source:r,sourcePath:s};if(t==="dev")throw new Error(`wrangler \`main\` is the Vite virtual module "${n}", which only a Vite build can resolve — \`celld dev\` rebuilds from a source file. Use \`vite dev\` for the dev loop and \`lunora deploy\` to ship the build to celld, or point \`main\` at a worker file`);const i=le(e,n);return{fromBuild:!0,source:S(i),sourcePath:i}},fe=(e,s,r,t,n)=>{const i=s.filter(l=>Object.hasOwn(r,l.split(Z)[0]??l));let o=e;e.no_bundle!==void 0&&(o=Object.fromEntries(Object.entries(e).filter(([l])=>l!=="no_bundle")),i.push("no_bundle (celld re-bundles the build output)"));const a=t===void 0?void 0:ce(t);return a!==void 0&&i.push(`${_(n,a)} (matched no files)`),{assetsIgnore:a,projected:o,reported:i}},R=(e,s={})=>{const r=c(e.vars)?e.vars:{};return{...e,vars:{...r,WORKER_ENV:"development",...s}}},_e=(e,s)=>{const r=K(e);if(r===void 0)throw new Error(`no wrangler.jsonc or wrangler.json in ${e} — celld deploys from the project's Wrangler config`);const t=S(r),{fromBuild:n,source:i,sourcePath:o}=de(e,r,t,s),a=E(o),{config:l,dropped:p}=N(i),{assets:d}=i,f=c(d)&&typeof d.directory=="string"?h(a,d.directory):void 0,m=typeof i.main=="string"?E(h(a,i.main)):void 0,u=ae([a,m,f].filter(L=>L!==void 0));if(!n&&u!==a)throw new Error(`wrangler \`main\` and \`assets.directory\` must sit inside ${a} — celld resolves everything against the config's directory`);const b=T(P(l,a,u),t,e,u),g=n?fe(b,p,t,f,u):{assetsIgnore:void 0,projected:b,reported:p},j=s==="dev"?R(g.projected):g.projected,O=v(u,q),V=`${JSON.stringify(j,void 0,4)}
2
+ `;return{configPath:O,dropped:g.reported,vars:c(j.vars)?j.vars:{},write:()=>{if(!n)try{D(u,C)}catch{}$(O,V),g.assetsIgnore!==void 0&&W(g.assetsIgnore)}}},be=(e,s)=>{const r=S(s),t=E(s),{config:n,dropped:i}=N(r),o=typeof r.name=="string"?r.name:"service",a=_(e,t);if(a===".."||a.startsWith(`..${y}`)||B(a))throw new Error(`service ${o} (${t}) must sit inside ${e} — celld dev runs it from a config beside the app's`);const l=v(t,G),p=w(l)?Object.fromEntries(J(A(l,"utf8")).map(({key:b,value:g})=>[b,g])):{},d=T(P(n,t,e),r,t,e),f=v(e,`.celld.service.${o.replaceAll(/[^\w.-]/gu,"-")}.wrangler.json`),m=R(d,p),u=`${JSON.stringify(m,void 0,4)}
3
+ `;return{configPath:f,dropped:i,vars:c(m.vars)?m.vars:{},write:()=>{D(e,C),$(f,u)}}};export{be as a,N as b,_e as p};