@lunora/config 1.0.0-alpha.293 → 1.0.0-alpha.295
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cloudflare/index.d.mts +86 -13
- package/dist/cloudflare/index.d.ts +86 -13
- package/dist/cloudflare/index.mjs +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.mjs +1 -1
- package/dist/packem_shared/BINDING_MANIFEST_VERSION-CPGD7sr_.mjs +1 -0
- package/dist/packem_shared/GLOBAL_FETCH_STRICTLY_PUBLIC_FLAG-f8CnJha3.mjs +1 -0
- package/dist/packem_shared/REMOTE_ELIGIBLE_KEYS-DioKi8jL.mjs +1 -0
- package/dist/packem_shared/REQUIRED_COMPATIBILITY_DATE-DFsH8i4Z.mjs +1 -0
- package/dist/packem_shared/UNEXPORTED_CLASS_MARKER-BMNpympM.mjs +1 -0
- package/dist/packem_shared/{assertWranglerSatisfiesSchema-BiABHeMv.mjs → assertWranglerSatisfiesSchema-DBsJ8xZA.mjs} +1 -1
- package/dist/packem_shared/collectExportGaps-BOeuCzWm.mjs +2 -0
- package/dist/packem_shared/discoverSchemaInfo-BguahM6z.mjs +1 -0
- package/dist/packem_shared/infer-bindings-D5S20KYQ.mjs +1 -0
- package/dist/packem_shared/{schema-info.d-fEhxTb9k.d.mts → infer-bindings.d-Duw2Bq4_.d.mts} +78 -54
- package/dist/packem_shared/{schema-info.d-fEhxTb9k.d.ts → infer-bindings.d-Duw2Bq4_.d.ts} +78 -54
- package/dist/packem_shared/inferLunoraBindings-DLCakLqW.mjs +1 -0
- package/dist/packem_shared/{materializeServiceDevConfigs-Cjk9uh9u.mjs → materializeServiceDevConfigs-VcqRp-kv.mjs} +1 -1
- package/dist/packem_shared/mergeWranglerEnvironment-KtP_NGVx.mjs +1 -0
- package/dist/packem_shared/reconcileBindingsSafely-BDZqwxAJ.mjs +1 -0
- package/dist/packem_shared/validate-bindings-Djec3UWf.mjs +1 -0
- package/dist/packem_shared/withTailConsumer-Dz7FDSBy.mjs +1 -0
- package/dist/packem_shared/worker-entry-checks-9Vdz4d2f.mjs +1 -0
- package/dist/packem_shared/wranglerToAlchemy-Bpfy1abZ.mjs +6 -0
- package/package.json +5 -5
- package/dist/packem_shared/BINDING_MANIFEST_VERSION-BHfXhS_-.mjs +0 -1
- package/dist/packem_shared/REMOTE_ELIGIBLE_KEYS-CBKtw0E-.mjs +0 -1
- package/dist/packem_shared/REQUIRED_COMPATIBILITY_DATE-jTnj2MPJ.mjs +0 -1
- package/dist/packem_shared/UNEXPORTED_CLASS_MARKER-CugcZbPf.mjs +0 -1
- package/dist/packem_shared/collectExportGaps-CIYe_DRY.mjs +0 -2
- package/dist/packem_shared/discoverSchemaInfo-DJvevsCm.mjs +0 -1
- package/dist/packem_shared/inferLunoraBindings-DXLEJY9w.mjs +0 -1
- package/dist/packem_shared/mergeWranglerEnvironment-DOKJUNH8.mjs +0 -1
- package/dist/packem_shared/reconcileBindingsSafely-VBbLYoAx.mjs +0 -1
- package/dist/packem_shared/validate-bindings-Dnf1t0SY.mjs +0 -1
- package/dist/packem_shared/withTailConsumer-B1NoKIsj.mjs +0 -1
- package/dist/packem_shared/wranglerToAlchemy-BMOQYRyw.mjs +0 -6
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AgentIR, ContainerIR, QueueIR, ServiceBindingIR, WorkflowIR } from '@lunora/codegen';
|
|
1
|
+
import { SchemaIR, AgentIR, ContainerIR, QueueIR, ServiceBindingIR, WorkflowIR } from '@lunora/codegen';
|
|
2
2
|
/**
|
|
3
3
|
* `DeployDriver` — the provider-neutral seam between a Lunora command and the
|
|
4
4
|
* host CLI that carries it out (plan 114, §5.3).
|
|
@@ -180,6 +180,57 @@ interface DeployDriver {
|
|
|
180
180
|
*/
|
|
181
181
|
readonly toolchain?: DriverToolchain;
|
|
182
182
|
}
|
|
183
|
+
/** One filterable Vectorize metadata property a schema declares. */
|
|
184
|
+
interface VectorMetadataDeclaration {
|
|
185
|
+
/** The vector index the property belongs to. */
|
|
186
|
+
index: string;
|
|
187
|
+
/**
|
|
188
|
+
* The validator kind behind the column, or `undefined` when the column
|
|
189
|
+
* isn't in the owning table's shape. Callers map it to the Vectorize
|
|
190
|
+
* metadata type; a kind that can't be filtered on is reported, not indexed.
|
|
191
|
+
*/
|
|
192
|
+
kind: string | undefined;
|
|
193
|
+
/** Column mirrored into vector metadata. */
|
|
194
|
+
property: string;
|
|
195
|
+
}
|
|
196
|
+
interface SchemaInfo {
|
|
197
|
+
/**
|
|
198
|
+
* Whether the schema declares a **D1-backed** `.global()` table — the only
|
|
199
|
+
* flavour that needs the `DB` binding and the app's `.global({ d1 })` chain.
|
|
200
|
+
* A `.global({ backend: "hyperdrive" })` table needs neither, and counting it
|
|
201
|
+
* here demanded a D1 database of a project that has none.
|
|
202
|
+
*/
|
|
203
|
+
hasD1GlobalTable: boolean;
|
|
204
|
+
/** Whether the schema declares a `.global({ backend: "hyperdrive" })` table — needs the app's `.hyperdriveGlobal(...)` chain instead. Required, not optional: the only producer always knows the answer, and `?` made every consumer read a two-valued fact as three-valued. */
|
|
205
|
+
hasHyperdriveGlobalTable: boolean;
|
|
206
|
+
/**
|
|
207
|
+
* Data-residency jurisdiction declared via `defineSchema(...).jurisdiction("…")`.
|
|
208
|
+
* It pins the app's Durable Objects only; KV namespaces and R2 buckets carry
|
|
209
|
+
* their own jurisdiction, set when they are created.
|
|
210
|
+
*/
|
|
211
|
+
jurisdiction?: SchemaIR["jurisdiction"];
|
|
212
|
+
/** Names of vector indexes declared via `.vectorize()` / `defineVectorIndex()`. */
|
|
213
|
+
vectorIndexNames?: ReadonlyArray<string>;
|
|
214
|
+
/**
|
|
215
|
+
* Metadata properties declared filterable on a vector index. Cloudflare
|
|
216
|
+
* needs an explicit metadata index per property before a `filter` can match
|
|
217
|
+
* anything, so deploy provisions these and doctor reports them.
|
|
218
|
+
*/
|
|
219
|
+
vectorMetadata?: ReadonlyArray<VectorMetadataDeclaration>;
|
|
220
|
+
}
|
|
221
|
+
interface DiscoverSchemaInfoResult {
|
|
222
|
+
/** Parse error message, when the schema exists but could not be analyzed. */
|
|
223
|
+
error?: string;
|
|
224
|
+
/** Schema facts, or `undefined` when no `schema.ts` exists or parsing failed. */
|
|
225
|
+
info: SchemaInfo | undefined;
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Discover {@link SchemaInfo} for a project. Returns `{ info: undefined }` when
|
|
229
|
+
* the project declares no `schema.ts` (not an error), or `{ info: undefined,
|
|
230
|
+
* error }` when a present schema could not be parsed — callers decide whether a
|
|
231
|
+
* parse failure is a warning (validator) or simply ignorable (inference).
|
|
232
|
+
*/
|
|
233
|
+
declare const discoverSchemaInfo: (projectRoot: string, schemaDirectory: string) => DiscoverSchemaInfoResult;
|
|
183
234
|
interface DurableObjectSpec {
|
|
184
235
|
binding: string;
|
|
185
236
|
className: string;
|
|
@@ -273,6 +324,12 @@ interface InferredBindings {
|
|
|
273
324
|
* un-mintable `app_id`, so it is reconciled as a hint, not auto-written.
|
|
274
325
|
*/
|
|
275
326
|
flagshipBinding?: string;
|
|
327
|
+
/**
|
|
328
|
+
* The schema's `.jurisdiction("…")`, when it declares one. Read by the binding
|
|
329
|
+
* hints whose resource takes its residency at creation (Artifacts), so the
|
|
330
|
+
* hint can name the jurisdiction to create it in.
|
|
331
|
+
*/
|
|
332
|
+
jurisdiction?: SchemaInfo["jurisdiction"];
|
|
276
333
|
/** Schema declares a `.global()` table → needs the `DB` D1 binding. */
|
|
277
334
|
needsD1: boolean;
|
|
278
335
|
/** Queues declared in `lunora/queues.ts` → reconciled into `queues.producers[]` / `queues.consumers[]`. */
|
|
@@ -285,21 +342,34 @@ interface InferredBindings {
|
|
|
285
342
|
services: ServiceBindingIR[] | undefined;
|
|
286
343
|
/** Human-readable provenance for each inferred binding / hint, for logging. */
|
|
287
344
|
signals: string[];
|
|
288
|
-
/** `@lunora/ai` is imported or `env.AI`
|
|
345
|
+
/** `@lunora/ai` is imported, `ctx.ai` read, or `env.AI` used → needs the `ai` Workers AI binding. */
|
|
289
346
|
usesAi: boolean;
|
|
290
|
-
/**
|
|
347
|
+
/** `ctx.aiSearch` is used → self-describing `ai_search_namespaces` binding (`AI_SEARCH` on namespace `default`; auto-writeable). */
|
|
348
|
+
usesAiSearch: boolean;
|
|
349
|
+
/** `@lunora/bindings/analytics` is imported or `ctx.analytics` read → self-describing `analytics_engine_datasets` binding (auto-writeable). */
|
|
291
350
|
usesAnalytics: boolean;
|
|
351
|
+
/** `ctx.analyticsSql` is used → self-describing `analytics` binding (`{ binding: ANALYTICS_SQL }`; auto-writeable, wrangler >= 4.145.0). */
|
|
352
|
+
usesAnalyticsSql: boolean;
|
|
353
|
+
/**
|
|
354
|
+
* `ctx.artifacts` is read or `@lunora/bindings/artifacts` value-imported.
|
|
355
|
+
* Hint-only: the first repo `create()` against a missing namespace creates it
|
|
356
|
+
* UNRESTRICTED, and a namespace's jurisdiction can never change after that,
|
|
357
|
+
* so Lunora never writes the binding for you.
|
|
358
|
+
*/
|
|
359
|
+
usesArtifacts: boolean;
|
|
292
360
|
/** `@lunora/auth` is imported (sessions may be D1- or `SessionDO`-backed). */
|
|
293
361
|
usesAuth: boolean;
|
|
294
|
-
/** `@lunora/browser` is imported → self-describing `browser` binding (auto-writeable). */
|
|
362
|
+
/** `@lunora/browser` is imported or `ctx.browser` read → self-describing `browser` binding (auto-writeable). */
|
|
295
363
|
usesBrowser: boolean;
|
|
364
|
+
/** `@lunora/auth/cimd/workers` is imported → needs the `global_fetch_strictly_public` compatibility flag (no binding; `lunora doctor` checks it). */
|
|
365
|
+
usesCimdWorkers: boolean;
|
|
296
366
|
/** `lunora/flags.ts` declares a feature-flag provider (any OpenFeature provider — Flagship or custom). */
|
|
297
367
|
usesFlags: boolean;
|
|
298
|
-
/** `@lunora/hyperdrive` is imported (binding needs an un-mintable remote `id`; hint-only). */
|
|
368
|
+
/** `@lunora/hyperdrive` is imported or `ctx.sql` read (binding needs an un-mintable remote `id`; hint-only). */
|
|
299
369
|
usesHyperdrive: boolean;
|
|
300
|
-
/** `@lunora/bindings/images` is imported → self-describing `images` binding (auto-writeable). */
|
|
370
|
+
/** `@lunora/bindings/images` is imported or `ctx.images` read → self-describing `images` binding (auto-writeable). */
|
|
301
371
|
usesImages: boolean;
|
|
302
|
-
/** `@lunora/bindings/kv` is imported (namespace binding name + id are user-defined; hint-only). */
|
|
372
|
+
/** `@lunora/bindings/kv` is imported or `ctx.kv` read (namespace binding name + id are user-defined; hint-only). */
|
|
303
373
|
usesKv: boolean;
|
|
304
374
|
/** `@lunora/mail` is imported (Resend API key must be set in `.dev.vars`; no binding). */
|
|
305
375
|
usesMail: boolean;
|
|
@@ -345,53 +415,7 @@ declare const inferLunoraBindings: (options: InferOptions) => Promise<InferredBi
|
|
|
345
415
|
* This is the canonical bridge between binding inference and the package-aware
|
|
346
416
|
* `.dev.vars.example` scaffolding in `scaffold-dev-variables.ts`. The result is
|
|
347
417
|
* a stable, predictable slice of {@link CAPABILITY_SOURCES} source values,
|
|
348
|
-
* filtered to the flags that are `true` in `bindings` — in
|
|
349
|
-
* declaration order.
|
|
418
|
+
* filtered to the flags that are `true` in `bindings` — in flag-name order.
|
|
350
419
|
*/
|
|
351
420
|
declare const packageNamesFromBindings: (bindings: InferredBindings) => string[];
|
|
352
|
-
/** One filterable Vectorize metadata property a schema declares. */
|
|
353
|
-
interface VectorMetadataDeclaration {
|
|
354
|
-
/** The vector index the property belongs to. */
|
|
355
|
-
index: string;
|
|
356
|
-
/**
|
|
357
|
-
* The validator kind behind the column, or `undefined` when the column
|
|
358
|
-
* isn't in the owning table's shape. Callers map it to the Vectorize
|
|
359
|
-
* metadata type; a kind that can't be filtered on is reported, not indexed.
|
|
360
|
-
*/
|
|
361
|
-
kind: string | undefined;
|
|
362
|
-
/** Column mirrored into vector metadata. */
|
|
363
|
-
property: string;
|
|
364
|
-
}
|
|
365
|
-
interface SchemaInfo {
|
|
366
|
-
/**
|
|
367
|
-
* Whether the schema declares a **D1-backed** `.global()` table — the only
|
|
368
|
-
* flavour that needs the `DB` binding and the app's `.global({ d1 })` chain.
|
|
369
|
-
* A `.global({ backend: "hyperdrive" })` table needs neither, and counting it
|
|
370
|
-
* here demanded a D1 database of a project that has none.
|
|
371
|
-
*/
|
|
372
|
-
hasD1GlobalTable: boolean;
|
|
373
|
-
/** Whether the schema declares a `.global({ backend: "hyperdrive" })` table — needs the app's `.hyperdriveGlobal(...)` chain instead. Required, not optional: the only producer always knows the answer, and `?` made every consumer read a two-valued fact as three-valued. */
|
|
374
|
-
hasHyperdriveGlobalTable: boolean;
|
|
375
|
-
/** Names of vector indexes declared via `.vectorize()` / `defineVectorIndex()`. */
|
|
376
|
-
vectorIndexNames?: ReadonlyArray<string>;
|
|
377
|
-
/**
|
|
378
|
-
* Metadata properties declared filterable on a vector index. Cloudflare
|
|
379
|
-
* needs an explicit metadata index per property before a `filter` can match
|
|
380
|
-
* anything, so deploy provisions these and doctor reports them.
|
|
381
|
-
*/
|
|
382
|
-
vectorMetadata?: ReadonlyArray<VectorMetadataDeclaration>;
|
|
383
|
-
}
|
|
384
|
-
interface DiscoverSchemaInfoResult {
|
|
385
|
-
/** Parse error message, when the schema exists but could not be analyzed. */
|
|
386
|
-
error?: string;
|
|
387
|
-
/** Schema facts, or `undefined` when no `schema.ts` exists or parsing failed. */
|
|
388
|
-
info: SchemaInfo | undefined;
|
|
389
|
-
}
|
|
390
|
-
/**
|
|
391
|
-
* Discover {@link SchemaInfo} for a project. Returns `{ info: undefined }` when
|
|
392
|
-
* the project declares no `schema.ts` (not an error), or `{ info: undefined,
|
|
393
|
-
* error }` when a present schema could not be parsed — callers decide whether a
|
|
394
|
-
* parse failure is a warning (validator) or simply ignorable (inference).
|
|
395
|
-
*/
|
|
396
|
-
declare const discoverSchemaInfo: (projectRoot: string, schemaDirectory: string) => DiscoverSchemaInfoResult;
|
|
397
421
|
export { COMPOSED_WORKER_ENTRY as C, DeployDriver as D, GeneratedClassModule as G, InferredBindings as I, ProjectionPurpose as P, SchemaInfo as S, ToolchainCommand as T, DeployRequest as a, DevRequest as b, DiscoverSchemaInfoResult as c, DriverToolchain as d, GENERATED_CLASS_MODULES as e, InferOptions as f, InferredAgent as g, InferredContainer as h, InferredWorkflow as i, ProjectedConfig as j, SecretRequest as k, TailRequest as l, discoverSchemaInfo as m, inferLunoraBindings as n, packageNamesFromBindings as p };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AgentIR, ContainerIR, QueueIR, ServiceBindingIR, WorkflowIR } from '@lunora/codegen';
|
|
1
|
+
import { SchemaIR, AgentIR, ContainerIR, QueueIR, ServiceBindingIR, WorkflowIR } from '@lunora/codegen';
|
|
2
2
|
/**
|
|
3
3
|
* `DeployDriver` — the provider-neutral seam between a Lunora command and the
|
|
4
4
|
* host CLI that carries it out (plan 114, §5.3).
|
|
@@ -180,6 +180,57 @@ interface DeployDriver {
|
|
|
180
180
|
*/
|
|
181
181
|
readonly toolchain?: DriverToolchain;
|
|
182
182
|
}
|
|
183
|
+
/** One filterable Vectorize metadata property a schema declares. */
|
|
184
|
+
interface VectorMetadataDeclaration {
|
|
185
|
+
/** The vector index the property belongs to. */
|
|
186
|
+
index: string;
|
|
187
|
+
/**
|
|
188
|
+
* The validator kind behind the column, or `undefined` when the column
|
|
189
|
+
* isn't in the owning table's shape. Callers map it to the Vectorize
|
|
190
|
+
* metadata type; a kind that can't be filtered on is reported, not indexed.
|
|
191
|
+
*/
|
|
192
|
+
kind: string | undefined;
|
|
193
|
+
/** Column mirrored into vector metadata. */
|
|
194
|
+
property: string;
|
|
195
|
+
}
|
|
196
|
+
interface SchemaInfo {
|
|
197
|
+
/**
|
|
198
|
+
* Whether the schema declares a **D1-backed** `.global()` table — the only
|
|
199
|
+
* flavour that needs the `DB` binding and the app's `.global({ d1 })` chain.
|
|
200
|
+
* A `.global({ backend: "hyperdrive" })` table needs neither, and counting it
|
|
201
|
+
* here demanded a D1 database of a project that has none.
|
|
202
|
+
*/
|
|
203
|
+
hasD1GlobalTable: boolean;
|
|
204
|
+
/** Whether the schema declares a `.global({ backend: "hyperdrive" })` table — needs the app's `.hyperdriveGlobal(...)` chain instead. Required, not optional: the only producer always knows the answer, and `?` made every consumer read a two-valued fact as three-valued. */
|
|
205
|
+
hasHyperdriveGlobalTable: boolean;
|
|
206
|
+
/**
|
|
207
|
+
* Data-residency jurisdiction declared via `defineSchema(...).jurisdiction("…")`.
|
|
208
|
+
* It pins the app's Durable Objects only; KV namespaces and R2 buckets carry
|
|
209
|
+
* their own jurisdiction, set when they are created.
|
|
210
|
+
*/
|
|
211
|
+
jurisdiction?: SchemaIR["jurisdiction"];
|
|
212
|
+
/** Names of vector indexes declared via `.vectorize()` / `defineVectorIndex()`. */
|
|
213
|
+
vectorIndexNames?: ReadonlyArray<string>;
|
|
214
|
+
/**
|
|
215
|
+
* Metadata properties declared filterable on a vector index. Cloudflare
|
|
216
|
+
* needs an explicit metadata index per property before a `filter` can match
|
|
217
|
+
* anything, so deploy provisions these and doctor reports them.
|
|
218
|
+
*/
|
|
219
|
+
vectorMetadata?: ReadonlyArray<VectorMetadataDeclaration>;
|
|
220
|
+
}
|
|
221
|
+
interface DiscoverSchemaInfoResult {
|
|
222
|
+
/** Parse error message, when the schema exists but could not be analyzed. */
|
|
223
|
+
error?: string;
|
|
224
|
+
/** Schema facts, or `undefined` when no `schema.ts` exists or parsing failed. */
|
|
225
|
+
info: SchemaInfo | undefined;
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Discover {@link SchemaInfo} for a project. Returns `{ info: undefined }` when
|
|
229
|
+
* the project declares no `schema.ts` (not an error), or `{ info: undefined,
|
|
230
|
+
* error }` when a present schema could not be parsed — callers decide whether a
|
|
231
|
+
* parse failure is a warning (validator) or simply ignorable (inference).
|
|
232
|
+
*/
|
|
233
|
+
declare const discoverSchemaInfo: (projectRoot: string, schemaDirectory: string) => DiscoverSchemaInfoResult;
|
|
183
234
|
interface DurableObjectSpec {
|
|
184
235
|
binding: string;
|
|
185
236
|
className: string;
|
|
@@ -273,6 +324,12 @@ interface InferredBindings {
|
|
|
273
324
|
* un-mintable `app_id`, so it is reconciled as a hint, not auto-written.
|
|
274
325
|
*/
|
|
275
326
|
flagshipBinding?: string;
|
|
327
|
+
/**
|
|
328
|
+
* The schema's `.jurisdiction("…")`, when it declares one. Read by the binding
|
|
329
|
+
* hints whose resource takes its residency at creation (Artifacts), so the
|
|
330
|
+
* hint can name the jurisdiction to create it in.
|
|
331
|
+
*/
|
|
332
|
+
jurisdiction?: SchemaInfo["jurisdiction"];
|
|
276
333
|
/** Schema declares a `.global()` table → needs the `DB` D1 binding. */
|
|
277
334
|
needsD1: boolean;
|
|
278
335
|
/** Queues declared in `lunora/queues.ts` → reconciled into `queues.producers[]` / `queues.consumers[]`. */
|
|
@@ -285,21 +342,34 @@ interface InferredBindings {
|
|
|
285
342
|
services: ServiceBindingIR[] | undefined;
|
|
286
343
|
/** Human-readable provenance for each inferred binding / hint, for logging. */
|
|
287
344
|
signals: string[];
|
|
288
|
-
/** `@lunora/ai` is imported or `env.AI`
|
|
345
|
+
/** `@lunora/ai` is imported, `ctx.ai` read, or `env.AI` used → needs the `ai` Workers AI binding. */
|
|
289
346
|
usesAi: boolean;
|
|
290
|
-
/**
|
|
347
|
+
/** `ctx.aiSearch` is used → self-describing `ai_search_namespaces` binding (`AI_SEARCH` on namespace `default`; auto-writeable). */
|
|
348
|
+
usesAiSearch: boolean;
|
|
349
|
+
/** `@lunora/bindings/analytics` is imported or `ctx.analytics` read → self-describing `analytics_engine_datasets` binding (auto-writeable). */
|
|
291
350
|
usesAnalytics: boolean;
|
|
351
|
+
/** `ctx.analyticsSql` is used → self-describing `analytics` binding (`{ binding: ANALYTICS_SQL }`; auto-writeable, wrangler >= 4.145.0). */
|
|
352
|
+
usesAnalyticsSql: boolean;
|
|
353
|
+
/**
|
|
354
|
+
* `ctx.artifacts` is read or `@lunora/bindings/artifacts` value-imported.
|
|
355
|
+
* Hint-only: the first repo `create()` against a missing namespace creates it
|
|
356
|
+
* UNRESTRICTED, and a namespace's jurisdiction can never change after that,
|
|
357
|
+
* so Lunora never writes the binding for you.
|
|
358
|
+
*/
|
|
359
|
+
usesArtifacts: boolean;
|
|
292
360
|
/** `@lunora/auth` is imported (sessions may be D1- or `SessionDO`-backed). */
|
|
293
361
|
usesAuth: boolean;
|
|
294
|
-
/** `@lunora/browser` is imported → self-describing `browser` binding (auto-writeable). */
|
|
362
|
+
/** `@lunora/browser` is imported or `ctx.browser` read → self-describing `browser` binding (auto-writeable). */
|
|
295
363
|
usesBrowser: boolean;
|
|
364
|
+
/** `@lunora/auth/cimd/workers` is imported → needs the `global_fetch_strictly_public` compatibility flag (no binding; `lunora doctor` checks it). */
|
|
365
|
+
usesCimdWorkers: boolean;
|
|
296
366
|
/** `lunora/flags.ts` declares a feature-flag provider (any OpenFeature provider — Flagship or custom). */
|
|
297
367
|
usesFlags: boolean;
|
|
298
|
-
/** `@lunora/hyperdrive` is imported (binding needs an un-mintable remote `id`; hint-only). */
|
|
368
|
+
/** `@lunora/hyperdrive` is imported or `ctx.sql` read (binding needs an un-mintable remote `id`; hint-only). */
|
|
299
369
|
usesHyperdrive: boolean;
|
|
300
|
-
/** `@lunora/bindings/images` is imported → self-describing `images` binding (auto-writeable). */
|
|
370
|
+
/** `@lunora/bindings/images` is imported or `ctx.images` read → self-describing `images` binding (auto-writeable). */
|
|
301
371
|
usesImages: boolean;
|
|
302
|
-
/** `@lunora/bindings/kv` is imported (namespace binding name + id are user-defined; hint-only). */
|
|
372
|
+
/** `@lunora/bindings/kv` is imported or `ctx.kv` read (namespace binding name + id are user-defined; hint-only). */
|
|
303
373
|
usesKv: boolean;
|
|
304
374
|
/** `@lunora/mail` is imported (Resend API key must be set in `.dev.vars`; no binding). */
|
|
305
375
|
usesMail: boolean;
|
|
@@ -345,53 +415,7 @@ declare const inferLunoraBindings: (options: InferOptions) => Promise<InferredBi
|
|
|
345
415
|
* This is the canonical bridge between binding inference and the package-aware
|
|
346
416
|
* `.dev.vars.example` scaffolding in `scaffold-dev-variables.ts`. The result is
|
|
347
417
|
* a stable, predictable slice of {@link CAPABILITY_SOURCES} source values,
|
|
348
|
-
* filtered to the flags that are `true` in `bindings` — in
|
|
349
|
-
* declaration order.
|
|
418
|
+
* filtered to the flags that are `true` in `bindings` — in flag-name order.
|
|
350
419
|
*/
|
|
351
420
|
declare const packageNamesFromBindings: (bindings: InferredBindings) => string[];
|
|
352
|
-
/** One filterable Vectorize metadata property a schema declares. */
|
|
353
|
-
interface VectorMetadataDeclaration {
|
|
354
|
-
/** The vector index the property belongs to. */
|
|
355
|
-
index: string;
|
|
356
|
-
/**
|
|
357
|
-
* The validator kind behind the column, or `undefined` when the column
|
|
358
|
-
* isn't in the owning table's shape. Callers map it to the Vectorize
|
|
359
|
-
* metadata type; a kind that can't be filtered on is reported, not indexed.
|
|
360
|
-
*/
|
|
361
|
-
kind: string | undefined;
|
|
362
|
-
/** Column mirrored into vector metadata. */
|
|
363
|
-
property: string;
|
|
364
|
-
}
|
|
365
|
-
interface SchemaInfo {
|
|
366
|
-
/**
|
|
367
|
-
* Whether the schema declares a **D1-backed** `.global()` table — the only
|
|
368
|
-
* flavour that needs the `DB` binding and the app's `.global({ d1 })` chain.
|
|
369
|
-
* A `.global({ backend: "hyperdrive" })` table needs neither, and counting it
|
|
370
|
-
* here demanded a D1 database of a project that has none.
|
|
371
|
-
*/
|
|
372
|
-
hasD1GlobalTable: boolean;
|
|
373
|
-
/** Whether the schema declares a `.global({ backend: "hyperdrive" })` table — needs the app's `.hyperdriveGlobal(...)` chain instead. Required, not optional: the only producer always knows the answer, and `?` made every consumer read a two-valued fact as three-valued. */
|
|
374
|
-
hasHyperdriveGlobalTable: boolean;
|
|
375
|
-
/** Names of vector indexes declared via `.vectorize()` / `defineVectorIndex()`. */
|
|
376
|
-
vectorIndexNames?: ReadonlyArray<string>;
|
|
377
|
-
/**
|
|
378
|
-
* Metadata properties declared filterable on a vector index. Cloudflare
|
|
379
|
-
* needs an explicit metadata index per property before a `filter` can match
|
|
380
|
-
* anything, so deploy provisions these and doctor reports them.
|
|
381
|
-
*/
|
|
382
|
-
vectorMetadata?: ReadonlyArray<VectorMetadataDeclaration>;
|
|
383
|
-
}
|
|
384
|
-
interface DiscoverSchemaInfoResult {
|
|
385
|
-
/** Parse error message, when the schema exists but could not be analyzed. */
|
|
386
|
-
error?: string;
|
|
387
|
-
/** Schema facts, or `undefined` when no `schema.ts` exists or parsing failed. */
|
|
388
|
-
info: SchemaInfo | undefined;
|
|
389
|
-
}
|
|
390
|
-
/**
|
|
391
|
-
* Discover {@link SchemaInfo} for a project. Returns `{ info: undefined }` when
|
|
392
|
-
* the project declares no `schema.ts` (not an error), or `{ info: undefined,
|
|
393
|
-
* error }` when a present schema could not be parsed — callers decide whether a
|
|
394
|
-
* parse failure is a warning (validator) or simply ignorable (inference).
|
|
395
|
-
*/
|
|
396
|
-
declare const discoverSchemaInfo: (projectRoot: string, schemaDirectory: string) => DiscoverSchemaInfoResult;
|
|
397
421
|
export { COMPOSED_WORKER_ENTRY as C, DeployDriver as D, GeneratedClassModule as G, InferredBindings as I, ProjectionPurpose as P, SchemaInfo as S, ToolchainCommand as T, DeployRequest as a, DevRequest as b, DiscoverSchemaInfoResult as c, DriverToolchain as d, GENERATED_CLASS_MODULES as e, InferOptions as f, InferredAgent as g, InferredContainer as h, InferredWorkflow as i, ProjectedConfig as j, SecretRequest as k, TailRequest as l, discoverSchemaInfo as m, inferLunoraBindings as n, packageNamesFromBindings as p };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./discoverAgentInfo-CTdCSfYM.mjs";import{i as t,p as s}from"./infer-bindings-D5S20KYQ.mjs";import"./discoverContainerInfo-EhZtEBQs.mjs";import"./discoverSchemaInfo-BguahM6z.mjs";import"./COMPOSED_WORKER_ENTRY-C69wqbSP.mjs";import"./discoverWorkflowInfo-BsPvlo6O.mjs";export{t as inferLunoraBindings,s as packageNamesFromBindings};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{writeFileSync as a}from"node:fs";import{isAbsolute as p,dirname as d,resolve as f,join as m}from"node:path";import{applyModify as l}from"./applyModify-DKP2l6S9.mjs";import{createCleanup as u}from"./REMOTE_ELIGIBLE_KEYS-
|
|
1
|
+
import{writeFileSync as a}from"node:fs";import{isAbsolute as p,dirname as d,resolve as f,join as m}from"node:path";import{applyModify as l}from"./applyModify-DKP2l6S9.mjs";import{createCleanup as u}from"./REMOTE_ELIGIBLE_KEYS-DioKi8jL.mjs";import{readWranglerJsonc as g}from"./WRANGLER_FILES-UNW-xY5u.mjs";let c=0;const v=e=>{const{parsed:t,text:r}=g(e),o=t?.build;if(typeof o?.command!="string"||o.command===""||typeof o.cwd=="string"&&p(o.cwd))return{configPath:e};const i=d(e),s=f(i,typeof o.cwd=="string"?o.cwd:".");c+=1;const n=m(i,`.wrangler.lunora-service.${String(process.pid)}.${String(c)}.jsonc`);return a(n,l(r,["build","cwd"],s),"utf8"),{cleanup:u(n),configPath:n}},j=e=>{const t=e.map(o=>v(o)),r=t.flatMap(o=>o.cleanup===void 0?[]:[o.cleanup]);return{cleanup:()=>{for(const o of r)o()},configPaths:t.map(o=>o.configPath)}};export{j as materializeServiceDevConfigs};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const c=["ai_search","ai_search_namespaces","analytics","artifacts","containers","d1_databases","durable_objects","kv_namespaces","queues","r2_buckets","secrets","secrets_store_secrets","services","tail_consumers","vars","vectorize","workflows"],i=["assets","compatibility_date","compatibility_flags","exports","logpush","main","migrations","observability","placement"],m=(s,n)=>{if(n===void 0)return{merged:s,unverifiedKeys:[]};const t=s.env?.[n];if(t===void 0){const e=Object.keys(s.env??{}).toSorted((v,f)=>v.localeCompare(f)),l=e.length>0?` (declared: ${e.join(", ")}).`:" (no environments are declared).";return{error:`--env "${n}" names no environment declared in wrangler.jsonc's "env" block${l}`,merged:s,unverifiedKeys:[]}}const o={...s},r=Object.keys(t).filter(e=>e!=="env");for(const e of r)i.includes(e)&&(o[e]=t[e]);for(const e of c)o[e]=t[e];const a=new Set([...c,...i]),d=r.filter(e=>!a.has(e)).map(String);return{merged:o,unverifiedKeys:d}};export{m as mergeWranglerEnvironment};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{i as p}from"./infer-bindings-D5S20KYQ.mjs";import{LUNORA_TAG as r}from"./LUNORA_TAG-CiQM3BkI.mjs";import{reconcileWranglerBindings as $}from"./collectExportGaps-BOeuCzWm.mjs";import{reconcileWranglerCompatibilityDate as g}from"./reconcileWranglerCompatibilityDate-hocXEuRA.mjs";import{reconcileWranglerCrons as m,describePreservedCrons as w}from"./describePreservedCrons-7gaDLxWx.mjs";const j=async(i,t,a)=>{try{const n=await p({projectRoot:i.projectRoot,schemaDir:i.schemaDir}),e=$(i.projectRoot,n),o=e.wranglerPath??"wrangler.jsonc";if(e.added.length>0&&t.info?.(`${r} inferred bindings → ${e.added.join(", ")} (written to ${o})`),e.updated.length>0&&t.info?.(`${r} updated bindings → ${e.updated.join(", ")} (written to ${o})`),e.devConfig!==void 0){const{added:s,path:d,updated:f}=e.devConfig;t.info?.(`${r} dev sidecar bindings → ${[...s,...f].join(", ")} (written to ${d})`)}for(const s of e.warnings)t.warn(`${r} ${s}`);e.exportGaps.length>0&&a?.(e.exportGaps)}catch(n){const e=n instanceof Error?n.message:String(n);t.warn(`${r} binding inference skipped: ${e}`)}},c=new Map,u=(i,t,a)=>{try{const n=m(i,t);n.changed&&a.info?.(`${r} synced ${t.length.toFixed(0)} cron trigger(s) into ${n.wranglerPath??"wrangler.jsonc"}`);for(const s of n.warnings)a.warn(`${r} ${s}`);const e=n.preserved.join("\0"),o=w(n.preserved);o!==void 0&&(n.changed||c.get(i)!==e)&&a.info?.(`${r} ${o}`),c.set(i,e)}catch(n){const e=n instanceof Error?n.message:String(n);a.warn(`${r} cron trigger sync skipped: ${e}`)}try{const n=g(i);n.changed&&a.info?.(`${r} bumped compatibility_date to ${n.date??"unknown"} (Workers Cache enabled) → ${n.wranglerPath??"wrangler.jsonc"}`)}catch(n){const e=n instanceof Error?n.message:String(n);a.warn(`${r} compatibility date sync skipped: ${e}`)}};export{j as reconcileBindingsSafely,u as reconcileWranglerExtras};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const l=[{of:e=>e.schedules===void 0?void 0:[...e.schedules],path:["schedules"]},{of:e=>e.limits?.steps,path:["limits","steps"]},{of:e=>e.defaultRetention?.successRetention,path:["default_retention","success_retention"]},{of:e=>e.defaultRetention?.errorRetention,path:["default_retention","error_retention"]}],N=[...new Set(l.map(({path:e})=>e[0]))],m=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),f=(e,n)=>{let a=e;for(const s of n)a=m(a)?a[s]:void 0;return a},O=e=>{const n={};for(const{of:a,path:s}of l){const t=a(e);if(t===void 0)continue;const[i,o]=s;n[i]=o===void 0?t:{...n[i],[o]:t}}return n},D=(e,n,a)=>{if(n.length===0)return;const s=e.vectorize??[],t=new Set(s.filter(Boolean).map(i=>i?.index_name));for(const i of n)t.has(i)||a.push(`schema declares vector index "${i}"; wrangler "vectorize" must include a binding with index_name "${i}"`)},$=new Set(["basic","dev","lite","standard","standard-1","standard-2","standard-3","standard-4"]),k={disk_mb:2e4,memory_mib:12288,vcpu:4},p=1,w=(e,n,a)=>{const s=e.instance_type;if(s===void 0)return;if(typeof s=="string"){$.has(s)||a.push(`${n} has unknown instance_type "${s}" — expected lite, basic, standard-1..4, or a custom { vcpu, memory_mib, disk_mb } object`);return}for(const[o,r]of Object.entries(k)){const d=s[o];d!==void 0&&(typeof d!="number"||d<=0||d>r)&&a.push(`${n} custom instance_type ${o} must be a positive number ≤ ${String(r)} (got ${String(d)})`)}const{memory_mib:t,vcpu:i}=s;typeof i=="number"&&i>0&&i<p&&a.push(`${n} custom instance_type needs ≥ ${String(p)} vCPU (got ${String(i)}) — use the named "lite" or "basic" instance type below 1 vCPU`),typeof i=="number"&&typeof t=="number"&&t<i*3072&&a.push(`${n} custom instance_type needs ≥ 3 GiB (3072 MiB) memory per vCPU (got ${String(t)} MiB for ${String(i)} vCPU)`)},S=(e,n,a)=>{for(const s of["image","instance_type","max_instances"])e[s]!==void 0&&a.push(`${n} sets "${s}", which the durable_object scheduling policy does not take — the Durable Object picks image and size at start`);for(const[s,t]of Object.entries(e.images??{}))[t?.dockerfile,t?.image].filter(o=>typeof o=="string"&&o.length>0).length!==1&&a.push(`${n} images["${s}"] must set exactly one of "dockerfile" or "image"`)},j=(e,n,a)=>{const{boundClasses:s,classKinds:t,errors:i,warnings:o}=a;if(!e||typeof e!="object"||typeof e.class_name!="string"||e.class_name.length===0){i.push(`${n} must have a non-empty "class_name" naming its container-enabled Durable Object class`);return}const r=e.scheduling_policy==="durable_object";e.scheduling_policy!==void 0&&e.scheduling_policy!=="default"&&!r&&i.push(`${n} ("${e.class_name}") has unknown scheduling_policy "${e.scheduling_policy}" — expected "default" or "durable_object"`),r?S(e,`${n} ("${e.class_name}")`,i):(typeof e.image!="string"||e.image.length===0)&&i.push(`${n} ("${e.class_name}") must have an "image" — a Dockerfile path or a registry reference`),s.has(e.class_name)||i.push(`${n} class "${e.class_name}" has no matching durable_objects binding — your dev server auto-reconciles this on startup; add { "name": "...", "class_name": "${e.class_name}" } to fix it by hand`);const d=t.get(e.class_name);d!=="sqlite"&&i.push(d==="classic"?`${n} class "${e.class_name}" is registered via "new_classes" but containers require SQLite-backed DOs — move it to "new_sqlite_classes"`:`${n} class "${e.class_name}" is missing from migrations — add a migration entry with "new_sqlite_classes": ["${e.class_name}"]`),w(e,`${n} ("${e.class_name}")`,i),e.max_instances===void 0&&!r&&o.push(`${n} ("${e.class_name}") declares no max_instances — set a cap so a traffic spike can't fan out unbounded container spend`)},c=e=>typeof e=="string"&&e.length>0,g=e=>Array.isArray(e)?e.filter(n=>n!==null&&typeof n=="object"):[],b=e=>Array.isArray(e)?e.filter(n=>c(n)):[],_=e=>{const n=new Map;for(const a of g(e)){for(const s of b(a.new_classes))n.set(s,"classic");for(const s of b(a.new_sqlite_classes))n.set(s,"sqlite");for(const s of g(a.renamed_classes))if(c(s.from)&&c(s.to)){const t=n.get(s.from)??"sqlite";n.delete(s.from),n.set(s.to,t)}for(const s of b(a.deleted_classes))n.delete(s)}return n},M=e=>new Set(_(e).keys()),U=(e,n)=>{const a=M(e.migrations);for(const s of g(e.durable_objects?.bindings))s.script_name===void 0&&c(s.class_name)&&!a.has(s.class_name)&&n.push(`durable_objects.bindings declares class "${s.class_name}" but it is missing from migrations — add a migration entry with "new_sqlite_classes": ["${s.class_name}"] (or "new_classes" for a non-SQLite-backed class), or let the dev server auto-reconcile it on the next start`)},B=(e,n,a)=>{if(e.containers===void 0)return;if(!Array.isArray(e.containers)){n.push("containers must be an array of { class_name, image, ... } entries");return}const s=e.containers;if(s.length===0)return;const t=new Set(g(e.durable_objects?.bindings).map(o=>o.class_name)),i=_(e.migrations);for(const[o,r]of s.entries())j(r,`containers[${String(o)}]`,{boundClasses:t,classKinds:i,errors:n,warnings:a});e.observability?.enabled!==!0&&a.push('containers are configured but observability is not enabled — container logs will not be captured (add { "observability": { "enabled": true } })')},u=e=>e,h=(e,n,a,s)=>{if(e!==void 0){if(!Array.isArray(e)){s.push(a.arrayMessage);return}for(const[t,i]of u(e).entries()){const o=`${n}[${String(t)}]`;if(!i||typeof i!="object"){s.push(a.objectMessage(o));continue}for(const r of a.fields)c(i[r.field])||s.push(r.message(o))}}},L={arrayMessage:"workflows must be an array of { name, binding, class_name } entries",fields:[{field:"binding",message:e=>`${e} must have a non-empty "binding" naming the Workflow binding (e.g. MY_WORKFLOW)`},{field:"class_name",message:e=>`${e} must have a non-empty "class_name" naming the exported WorkflowEntrypoint class`},{field:"name",message:e=>`${e} must have a non-empty "name" naming the deployed workflow`}],objectMessage:e=>`${e} must be a { name, binding, class_name } object`},E=(e,n)=>e===void 0||n&&c(e)||Array.isArray(e)&&e.length>0&&e.every(s=>c(s))?void 0:"schedules must be a non-empty array of cron expression strings",A=e=>{if(e!==void 0)return m(e)?e.steps===void 0||Number.isInteger(e.steps)&&e.steps>0?void 0:"limits.steps must be a positive integer":"limits must be an object"},x=e=>e===void 0?[]:m(e)?["success_retention","error_retention"].filter(n=>e[n]!==void 0&&!c(e[n])).map(n=>`default_retention.${n} must be a duration string (e.g. "7 days")`):["default_retention must be an object"],y=(e,n,a,s)=>{const t=[E(e.schedules,a),A(e.limits),...x(e.default_retention)];for(const i of t)i!==void 0&&s.push(`${n}.${i}`)},q=(e,n)=>l.map(({path:a})=>a).filter(a=>{const s=f(e,a),t=f(n,a),i=typeof t=="string"&&a[0]==="schedules"?[t]:t;return s!==void 0&&t!==void 0&&JSON.stringify(s)!==JSON.stringify(i)}).map(a=>a.join(".")),R=(e,n,a,s)=>{const t=`exports["${e}"]`,i=String(n.name);for(const o of a){if(!m(o)||o.name!==n.name)continue;const r=`workflows entry "${String(o.binding)}"`;if(o.script_name!==void 0){s.push(`${r} binds workflow "${i}" in another Worker, but ${t} declares a workflow with that name here — workflow names are unique per account`);continue}o.class_name!==e&&s.push(`${r} and ${t} both declare workflow "${i}" but name different classes ("${String(o.class_name)}" vs "${e}")`);for(const d of q(o,n))s.push(`${r} and ${t} set ${d} to different values for workflow "${i}" — set it in one place`)}},T=(e,n)=>{const a=Array.isArray(e.workflows)?u(e.workflows):[];for(const[t,i]of a.entries())m(i)&&y(i,`workflows[${String(t)}]`,!1,n);const s=m(e.exports)?Object.entries(e.exports):[];for(const[t,i]of s)!m(i)||i.type!=="workflow"||(c(i.name)?(y(i,`exports["${t}"]`,!0,n),R(t,i,a,n)):n.push(`exports["${t}"] is a workflow export and must have a non-empty "name" naming the deployed workflow`))},I={arrayMessage:"queues.producers must be an array of { binding, queue } entries",fields:[{field:"binding",message:e=>`${e} must have a non-empty "binding" naming the Queue producer (e.g. QUEUE_EMAIL)`},{field:"queue",message:e=>`${e} must have a non-empty "queue" naming the deployed queue`}],objectMessage:e=>`${e} must be a { binding, queue } object`},C={arrayMessage:"queues.consumers must be an array of { queue } entries",fields:[{field:"queue",message:e=>`${e} must have a non-empty "queue" naming the consumed queue`}],objectMessage:e=>`${e} must be a { queue } object`},F=(e,n)=>{if(e.queues!==void 0){if(typeof e.queues!="object"||Array.isArray(e.queues)){n.push("queues must be a { producers, consumers } object");return}h(e.queues.producers,"queues.producers",I,n),h(e.queues.consumers,"queues.consumers",C,n)}},W={arrayMessage:"secrets_store_secrets must be an array of { binding, store_id, secret_name } entries",fields:["binding","store_id","secret_name"].map(e=>({field:e,message:n=>`${n} must have a non-empty "${e}"`})),objectMessage:e=>`${e} must be a { binding, store_id, secret_name } object`},P=[{arrayMessage:"kv_namespaces must be an array of { binding, id } entries",bindingMessage:e=>`${e} must have a non-empty "binding" naming the KV namespace binding`,hintField:"id",hintMessage:(e,n)=>`${e} ("${n}") has no "id" — run \`wrangler kv namespace create\` and set the namespace id, or the binding can't resolve`,key:"kv_namespaces"},{arrayMessage:"flagship must be an array of { binding, app_id } entries",bindingMessage:e=>`${e} must have a non-empty "binding" naming the Flagship binding`,hintField:"app_id",hintMessage:(e,n)=>`${e} ("${n}") has no "app_id" — create a Flagship app and set its id, or the binding can't resolve`,key:"flagship"},{arrayMessage:"hyperdrive must be an array of { binding, id } entries",bindingMessage:e=>`${e} must have a non-empty "binding" naming the Hyperdrive binding`,hintField:"id",hintMessage:(e,n)=>`${e} ("${n}") has no "id" — run \`wrangler hyperdrive create\` and set the id, or the binding can't connect`,key:"hyperdrive"},{arrayMessage:"pipelines must be an array of { binding, stream } entries",bindingMessage:e=>`${e} must have a non-empty "binding" naming the Pipelines binding`,hintField:["stream","pipeline"],hintMessage:(e,n)=>`${e} ("${n}") has no "stream" — run \`wrangler pipelines create <name>\` and set the stream name, or the binding can't resolve`,key:"pipelines"},{arrayMessage:"analytics_engine_datasets must be an array of { binding, dataset } entries",bindingMessage:e=>`${e} must have a non-empty "binding" naming the Analytics Engine binding`,hintField:"dataset",hintMessage:(e,n)=>`${e} ("${n}") has no "dataset" — it defaults to the binding name; set it explicitly to avoid drift`,key:"analytics_engine_datasets"}],G=(e,n,a,s)=>{const t=e[n.key];if(t!==void 0){if(!Array.isArray(t)){a.push(n.arrayMessage);return}for(const[i,o]of u(t).entries()){const r=`${n.key}[${String(i)}]`;if(!o||typeof o!="object"||!c(o.binding)){a.push(n.bindingMessage(r));continue}(typeof n.hintField=="string"?[n.hintField]:n.hintField).some(v=>c(o[v]))||s.push(n.hintMessage(r,o.binding))}}},K=[{key:"analytics",message:'analytics must be an object with a non-empty "binding" (e.g. { "binding": "ANALYTICS_SQL" })'},{key:"browser",message:'browser must be an object with a non-empty "binding" (e.g. { "binding": "BROWSER" })'},{key:"images",message:'images must be an object with a non-empty "binding" (e.g. { "binding": "IMAGES" })'},{key:"media",message:'media must be an object with a non-empty "binding" (e.g. { "binding": "MEDIA" })'},{key:"stream",message:'stream must be an object with a non-empty "binding" (e.g. { "binding": "STREAM" })'}],Q=(e,n,a)=>{const s=e[n.key];s!==void 0&&(typeof s!="object"||s===null||Array.isArray(s)||!c(s.binding))&&a.push(n.message)},V=[{arrayMessage:"ai_search_namespaces must be an array of { binding, namespace } entries",fields:[{field:"binding",message:e=>`${e} must have a non-empty "binding" naming the AI Search binding`},{field:"namespace",message:e=>`${e} must have a non-empty "namespace" naming the AI Search namespace (every account has "default")`}],key:"ai_search_namespaces",objectMessage:e=>`${e} must be a { binding, namespace } object`},{arrayMessage:"ai_search must be an array of { binding, instance_name } entries",fields:[{field:"binding",message:e=>`${e} must have a non-empty "binding" naming the AI Search binding`},{field:"instance_name",message:e=>`${e} must have a non-empty "instance_name" naming an existing AI Search instance`}],key:"ai_search",objectMessage:e=>`${e} must be a { binding, instance_name } object`},{arrayMessage:"services must be an array of { binding, service, entrypoint? } entries",fields:[{field:"binding",message:e=>`${e} must have a non-empty "binding" naming the service binding`},{field:"service",message:e=>`${e} must have a non-empty "service" naming the target Worker`}],key:"services",objectMessage:e=>`${e} must be a { binding, service, entrypoint? } object`},{arrayMessage:"dispatch_namespaces must be an array of { binding, namespace } entries",fields:[{field:"binding",message:e=>`${e} must have a non-empty "binding"`},{field:"namespace",message:e=>`${e} must have a non-empty "namespace" naming the dispatch namespace`}],key:"dispatch_namespaces",objectMessage:e=>`${e} must be a { binding, namespace } object`},{arrayMessage:"mtls_certificates must be an array of { binding, certificate_id } entries",fields:[{field:"binding",message:e=>`${e} must have a non-empty "binding"`},{field:"certificate_id",message:e=>`${e} must have a non-empty "certificate_id" (upload via \`wrangler mtls-certificate upload\`)`}],key:"mtls_certificates",objectMessage:e=>`${e} must be a { binding, certificate_id } object`},{arrayMessage:"r2_buckets must be an array of { binding, bucket_name } entries",fields:[{field:"binding",message:e=>`${e} must have a non-empty "binding" naming the R2 bucket binding`},{field:"bucket_name",message:e=>`${e} must have a non-empty "bucket_name" naming the deployed bucket`}],key:"r2_buckets",objectMessage:e=>`${e} must be a { binding, bucket_name } object`},{arrayMessage:"vpc_services must be an array of { binding, service_id } entries",fields:[{field:"binding",message:e=>`${e} must have a non-empty "binding" naming the VPC Service binding`},{field:"service_id",message:e=>`${e} must have a non-empty "service_id" (create one with \`wrangler vpc service create\`)`}],key:"vpc_services",objectMessage:e=>`${e} must be a { binding, service_id } object`},{arrayMessage:"artifacts must be an array of { binding, namespace } entries",fields:[{field:"binding",message:e=>`${e} must have a non-empty "binding" naming the Artifacts binding`},{field:"namespace",message:e=>`${e} must have a non-empty "namespace" naming the Artifacts namespace`}],key:"artifacts",objectMessage:e=>`${e} must be a { binding, namespace } object`}],z=(e,n,a)=>{n?.hasD1GlobalTable&&!g(e.d1_databases).some(s=>s.binding==="DB")&&a.push('schema declares .global() tables; d1_databases must include a binding named "DB" — your dev server auto-reconciles this on startup, or add the binding manually'),n?.hasHyperdriveGlobalTable&&g(e.hyperdrive).length===0&&a.push('schema declares .global({ backend: "hyperdrive" }) tables; wrangler must declare a hyperdrive binding for `.hyperdriveGlobal({ exec })` to read — run `wrangler hyperdrive create <name> --connection-string=...` and add `"hyperdrive": [{ "binding": "HYPERDRIVE", "id": "<id>" }]` (any binding name works; your `exec` selector picks it)')},H=(e,n)=>{const{d1_databases:a}=e;if(a!==void 0){if(!Array.isArray(a)){n.push("d1_databases must be an array of { binding, database_id | database_name } entries");return}for(const[s,t]of u(a).entries()){const i=`d1_databases[${String(s)}]`;if(!t||typeof t!="object"){n.push(`${i} must be a { binding, database_id | database_name } object`);continue}c(t.binding)||n.push(`${i} must have a non-empty "binding" naming the D1 binding`),!c(t.database_id)&&!c(t.database_name)&&n.push(`${i} must have a "database_id" or a "database_name" — run \`wrangler d1 create\` and set one, or the binding can't resolve`)}}},Y=(e,n)=>{const{vpc_networks:a}=e;if(a!==void 0){if(!Array.isArray(a)){n.push("vpc_networks must be an array of { binding, tunnel_id | network_id } entries");return}for(const[s,t]of u(a).entries()){const i=`vpc_networks[${String(s)}]`;if(!t||typeof t!="object"){n.push(`${i} must be a { binding, tunnel_id | network_id } object`);continue}c(t.binding)||n.push(`${i} must have a non-empty "binding" naming the VPC Network binding`),c(t.tunnel_id)===c(t.network_id)&&n.push(`${i} must set exactly one of "tunnel_id" (a Cloudflare Tunnel) or "network_id" ("cf1:network" for Cloudflare Mesh)`)}}};export{P as H,V as R,K as S,L as W,z as a,H as b,D as c,B as d,h as e,T as f,F as g,G as h,Q as i,Y as j,W as k,m as l,c as m,N as n,g as o,b as p,l as q,f as s,U as v,O as w};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{l,m as y,o as g}from"./validate-bindings-Djec3UWf.mjs";const v=new Set(["1","enabled","on","true","yes"]),_=s=>typeof s=="string"&&v.has(s.trim().toLowerCase()),L=(s,t,e)=>{const i=s.send_email;if(i===void 0)return;if(!Array.isArray(i)){t.push("send_email must be an array of { name, destination_address? } entries");return}const n=i;for(const[o,a]of n.entries())(!a||typeof a!="object"||typeof a.name!="string"||a.name.length===0)&&e.push(`send_email[${String(o)}] has no non-empty "name" naming the send-email binding — set one before deploying`)},$=(s,t)=>{s.logpush!==void 0&&typeof s.logpush!="boolean"&&t.push('logpush must be a boolean (set "logpush": true to enable Cloudflare Logpush)')},R=(s,t)=>{const e=s.secrets;if(e===void 0)return;const i=typeof e=="object"&&e!==null&&!Array.isArray(e)?e.required:void 0;(!Array.isArray(i)||i.some(n=>typeof n!="string"||n===""))&&t.push('secrets must be an object whose "required" is an array of secret names (e.g. { "required": ["API_KEY"] })')},d=3e5,I=(s,t)=>{const{limits:e}=s;if(e===void 0)return;if(typeof e!="object"||Array.isArray(e)){t.push('limits must be an object (e.g. { "cpu_ms": 30000 })');return}const i=e.cpu_ms;if(i!==void 0){if(typeof i!="number"||!Number.isFinite(i)||!Number.isInteger(i)||i<=0){t.push("limits.cpu_ms must be a positive integer number of milliseconds");return}i>d&&t.push(`limits.cpu_ms must be at most ${String(d)} (Cloudflare's per-invocation ceiling)`)}},b=new Set(["off","smart","targeted"]),N=(s,t)=>{const{placement:e}=s;if(e===void 0)return;if(typeof e!="object"||e===null||Array.isArray(e)){t.push('placement must be an object (e.g. { "mode": "smart" })');return}const{mode:i}=e;i!==void 0&&(typeof i!="string"||!b.has(i))&&t.push(`placement.mode must be one of ${[...b].map(n=>`"${n}"`).join(", ")}`)},A=new Set(["enabled","head_sampling_rate","issues","logs","traces"]),m=new Set(["destinations","enabled","head_sampling_rate","persist"]),S=new Set([...m,"invocation_logs"]),E=new Set(["enabled"]),u=(s,t,e,{warnings:i})=>{for(const n of Object.keys(s))t.has(n)||i.push(`${e}.${n} is not a documented wrangler key (expected one of ${[...t].join(", ")}) — a typo is silently ignored by wrangler`)},c=(s,t,{errors:e})=>{s!==void 0&&typeof s!="boolean"&&e.push(`${t} must be a boolean`)},f=(s,t,{errors:e})=>{s!==void 0&&(typeof s!="number"||Number.isNaN(s)||s<0||s>1)&&e.push(`${t} must be a number in [0, 1] (the fraction of requests sampled)`)},p=(s,t,e,i)=>{if(s===void 0)return;if(!l(s)){i.errors.push(`${t} must be an object`);return}u(s,e,t,i),c(s.enabled,`${t}.enabled`,i),c(s.persist,`${t}.persist`,i),f(s.head_sampling_rate,`${t}.head_sampling_rate`,i);const{destinations:n}=s;return n!==void 0&&(!Array.isArray(n)||n.some(o=>typeof o!="string"||o.length===0))&&i.errors.push(`${t}.destinations must be an array of destination names configured in the Cloudflare dashboard`),s},w=(s,t,e)=>{const{observability:i}=s;if(i===void 0)return;if(!l(i)){t.push('observability must be an object (e.g. { "enabled": true, "head_sampling_rate": 1 })');return}const n={errors:t,warnings:e};u(i,A,"observability",n),c(i.enabled,"observability.enabled",n),f(i.head_sampling_rate,"observability.head_sampling_rate",n);const o=p(i.logs,"observability.logs",S,n);o?.invocation_logs!==void 0&&typeof o.invocation_logs!="boolean"&&t.push('observability.logs.invocation_logs must be a boolean (set "invocation_logs": true to keep per-invocation summaries)'),p(i.traces,"observability.traces",m,n);const{issues:a}=i;a!==void 0&&(l(a)?(u(a,E,"observability.issues",n),c(a.enabled,"observability.issues.enabled",n)):t.push("observability.issues must be an object"))},C=(s,t)=>{const{cache:e}=s;if(e!==void 0){if(typeof e!="object"||e===null||Array.isArray(e)){t.push('cache must be an object (e.g. { "enabled": true })');return}e.enabled!==void 0&&typeof e.enabled!="boolean"&&t.push("cache.enabled must be a boolean (true or false)")}},x=(s,t)=>{const{exports:e}=s;if(e!==void 0){if(typeof e!="object"||e===null||Array.isArray(e)){t.push("exports must be an object keyed by entrypoint name");return}for(const[i,n]of Object.entries(e)){if(typeof n!="object"||n===null){t.push(`exports["${i}"] must be an object`);continue}n.type!==void 0&&typeof n.type!="string"&&t.push(`exports["${i}"].type must be a string`),n.cache!==void 0&&(typeof n.cache!="object"||n.cache===null||Array.isArray(n.cache)?t.push(`exports["${i}"].cache must be an object`):n.cache.enabled!==void 0&&typeof n.cache.enabled!="boolean"&&t.push(`exports["${i}"].cache.enabled must be a boolean`))}}},T=(s,t)=>{const{assets:e}=s;if(e!==void 0){if(typeof e!="object"||Array.isArray(e)){t.push('assets must be an object (e.g. { "directory": "./dist/client", "binding": "ASSETS" })');return}(typeof e.directory!="string"||e.directory.length===0)&&t.push('assets must declare a non-empty "directory" pointing at the built client output (e.g. "./dist/client")'),e.binding!==void 0&&(typeof e.binding!="string"||e.binding.length===0)&&t.push('assets.binding must be a non-empty string (e.g. "ASSETS")'),e.html_handling!==void 0&&typeof e.html_handling!="string"&&t.push("assets.html_handling must be a string"),e.not_found_handling!==void 0&&typeof e.not_found_handling!="string"&&t.push("assets.not_found_handling must be a string")}},U=(s,t)=>{const e=s.tail_consumers;if(e===void 0)return;if(!Array.isArray(e)){t.push("tail_consumers must be an array of { service, environment? } entries");return}const i=e;for(const[n,o]of i.entries())(!o||typeof o!="object"||typeof o.service!="string"||o.service.length===0)&&t.push(`tail_consumers[${String(n)}] must have a non-empty "service" naming the consumer Worker`)},B=(s,t)=>{const e=s.tail_consumers??[];return e.some(n=>!!n&&n?.service===t.service&&n?.environment===t.environment)?s:{...s,tail_consumers:[...e,t]}},D=(s,t)=>{const{vars:e}=s;if(!e||typeof e!="object")return;const i=e.LUNORA_ALLOWED_ORIGINS,n=e.LUNORA_CORS_ALLOW_CREDENTIALS,o=typeof i=="string"&&i.split(",").some(h=>h.trim()==="*"),a=_(n);o&&a&&t.push('vars.LUNORA_ALLOWED_ORIGINS includes a "*" wildcard while vars.LUNORA_CORS_ALLOW_CREDENTIALS is on — browsers reject this combination and it defeats the allowlist; name explicit origins or drop credentials')},O=s=>g(s.durable_objects?.bindings).some(t=>t.class_name==="SchedulerDO"&&t.script_name===void 0),r="LUNORA_ORIGIN_URL",Y=(s,t,e)=>{if(!O(s)||y(s.vars?.[r]))return;const i=t===void 0?"vars":`env.${t}.vars`,n=t===void 0?"":` --env ${t}`;e.push(`durable_objects.bindings declares the SchedulerDO but ${i}.${r} is unset — the DO reads its dispatch origin from its own env and refuses to schedule without it, so every ctx.scheduler.runAfter/runAt fails with ORIGIN_NOT_CONFIGURED. Set ${i}.${r} to the worker's public URL, or \`wrangler secret put ${r}${n}\` (ignore this if it is already set as a secret or in the dashboard).`)};export{T as validateAssets,C as validateCache,D as validateCorsVariables,x as validateExports,I as validateLimits,$ as validateLogpush,w as validateObservability,N as validatePlacement,Y as validateSchedulerOrigin,R as validateSecretsRequired,L as validateSendEmail,U as validateTailConsumers,B as withTailConsumer};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{existsSync as f,readFileSync as N,readdirSync as I}from"node:fs";import{join as l,dirname as v,extname as h,basename as x}from"node:path";import{Project as b,Node as d}from"ts-morph";import{COMPOSED_WORKER_ENTRY as w,LUNORA_WORKER_VIRTUAL_ID as u,isGeneratedOutput as F,WORKER_ENTRY_FALLBACKS as L,GENERATED_DIRECTORY as j,COMPOSED_ENTRY_DURABLE_OBJECTS as M,GENERATED_CLASS_MODULES as P,SOURCE_DOT_DIRECTORIES as k,NON_SOURCE_DIRECTORIES as U}from"./COMPOSED_WORKER_ENTRY-C69wqbSP.mjs";const E=[".ts",".tsx",".mts",".cts"],m=new Set(E),W=new Set([".cjs",".js",".mjs"]),g="default",S={".cjs":[".cts"],".js":[".ts",".tsx"],".mjs":[".mts"]},B=250,re=(e,o,t)=>{const s=l(o,w);if(f(s))return{origin:"declared",path:s};if(e===u)return{origin:"composed"};const n=()=>{const i=L.map(a=>l(o,a)).find(a=>f(a));return i===void 0?void 0:{origin:"probed",path:i}};if(typeof e!="string"||e.length===0||F(e))return n();const r=l(v(t),e),c=h(r);if(!(!m.has(c)&&!W.has(c)))return f(r)?{origin:"declared",path:r}:{origin:"absent",path:r}},y=(e,o)=>{if(d.isIdentifier(e)){o.add(e.getText());return}if(d.isObjectBindingPattern(e)||d.isArrayBindingPattern(e))for(const t of e.getElements())d.isBindingElement(t)&&y(t.getNameNode(),o)},K=(e,o)=>{const t=[];for(const s of e.getExportDeclarations())if(!s.isTypeOnly()){if(s.isNamespaceExport()){const n=s.getNamespaceExport();n===void 0?t.push(s.getModuleSpecifierValue()??""):o.add(n.getName());continue}for(const n of s.getNamedExports())n.isTypeOnly()||o.add(n.getAliasNode()?.getText()??n.getName())}return t},X=(e,o)=>{for(const t of e.getVariableStatements().filter(s=>s.getExportKeyword()!==void 0))for(const s of t.getDeclarations())y(s.getNameNode(),o);for(const t of[...e.getClasses(),...e.getFunctions(),...e.getEnums()]){if(t.getExportKeyword()===void 0)continue;const s=t.isDefaultExport()?g:t.getName();s!==void 0&&o.add(s)}e.getExportAssignments().length>0&&o.add(g)},_=(e,o)=>{const t=new b({compilerOptions:{allowJs:!0},skipFileDependencyResolution:!0,skipLoadingLibFiles:!0,useInMemoryFileSystem:!0}),s=t.createSourceFile(e,o,{overwrite:!0});return t.getProgram().compilerObject.getSyntacticDiagnostics(s.compilerNode).length>0?void 0:s},Y=(e,o)=>{if(!o.startsWith("./")&&!o.startsWith("../"))return;const t=l(v(e),o),s=h(t),n=m.has(s)||S[s]!==void 0,r=n?t.slice(0,-s.length):t;return[...m.has(s)?[t]:[],...(S[s]??[]).map(i=>`${r}${i}`),...n?[]:E.map(i=>`${t}${i}`),...n||s.length===0?E.map(i=>l(r,`index${i}`)):[]].find(i=>f(i))},T=e=>{const o=new Set,t=new Set([e]),s=[e];for(;s.length>0;){if(t.size-1>B)return;const n=s.pop();let r;try{r=N(n,"utf8")}catch{return}const c=_(x(n),r);if(c===void 0)return;const i=K(c,o);X(c,o);for(const a of i){const p=Y(n,a);if(p===void 0)return;t.has(p)||(t.add(p),s.push(p))}}return o},$=(e,o)=>{const t={exports:void 0,kind:"composed",path:u},s=l(e,o,j);if(!f(s))return t;const n=new Set(M);for(const r of P){const c=l(s,`${r}.ts`);if(!f(c))continue;const i=T(c);if(i===void 0)return t;for(const a of i)n.add(a)}return{exports:n,kind:"composed",path:u}},ie=(e,o,t)=>{if(e===void 0||e.origin==="absent")return;if(e.origin==="composed")return $(o,t);const s=T(e.path);if(!(e.origin==="probed"&&s!==void 0&&!s.has(g)))return{exports:s,kind:"authored",path:e.path}},G=new Set([".cjs",".cts",".js",".jsx",".mjs",".mts",".ts",".tsx"]),z=2e3,O="defineTable",R="defineApp",J=e=>{const o=[],t=[];let s;try{s=I(e,{withFileTypes:!0})}catch{return{files:o,subdirectories:t}}for(const n of s)n.isDirectory()?n.name.startsWith(".")&&!k.has(n.name)||U.has(n.name)||t.push(l(e,n.name)):G.has(h(n.name))&&o.push(l(e,n.name));return{files:o,subdirectories:t}},D=(e,o)=>{const t=new Set;for(const s of e.getImportDeclarations())for(const n of s.getNamedImports())!n.isTypeOnly()&&n.getName()===o&&t.add(n.getAliasNode()?.getText()??n.getName());return t},q=(e,o)=>{let t=!1;return e.forEachDescendant((s,n)=>{if(!d.isCallExpression(s))return;const r=s.getExpression();d.isIdentifier(r)&&o.has(r.getText())&&(t=!0,n.stop())}),t},V=e=>{let o=e;for(;d.isCallExpression(o)||d.isPropertyAccessExpression(o);)o=o.getExpression();return o},H=(e,o)=>{const t=V(e);return d.isIdentifier(t)&&o.has(t.getText())},A={analyticsSql:/\.\s*analyticsSql\s*\(/u,global:/\.\s*global\s*\(/u,hyperdriveGlobal:/\.\s*hyperdriveGlobal\s*\(/u,vectors:/\.\s*vectors\s*\(/u},Q=e=>Object.hasOwn(A,e),Z=(e,o)=>{const t=new Set,s=new Set([O,...D(e,O)]);return e.forEachDescendant(n=>{if(!d.isCallExpression(n))return;const r=n.getExpression();if(!d.isPropertyAccessExpression(r)||H(r,s))return;const c=r.getName();Q(c)&&o.has(c)&&t.add(c)}),t},ee=(e,o)=>{let t;try{t=N(e,"utf8")}catch{return}const s=new Set([...o].filter(r=>A[r].test(t)));if(s.size===0&&!t.includes(R))return;const n=_(x(e),t);return n===void 0?{chained:s,composes:!1}:{chained:Z(n,s),composes:q(n,D(n,R))}},ce=(e,o)=>{const t=[e],s=new Set;let n=0,r;const c=i=>{if(n+=1,n>z)return!1;const a=ee(i,o);for(const p of a?.chained??[])s.add(p);return a?.composes&&(r??=i),!0};for(;t.length>0;){const i=t.pop(),{files:a,subdirectories:p}=J(i);t.push(...p);for(const C of a){if(!c(C))return;if(r!==void 0&&s.size===o.size)return{chained:s,site:r}}}return r===void 0?void 0:{chained:s,site:r}};export{re as l,ie as r,ce as s};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
const o=e=>JSON.stringify(e),$=/^[A-Z_a-z][\w$]*$/u,d=e=>$.test(e),u=e=>d(e)?e:`binding_${e.replaceAll(/\W/gu,"_")}`,m=(e,t=u(e))=>{const n=d(e);return n&&t===e?`${e},`:`${n?e:o(e)}: ${t},`},h=e=>{const t=new Set;for(const n of e.migrations??[])for(const r of n.new_sqlite_classes??[])t.add(r);return t},g=(e,t,n,r,c)=>{for(const a of e.durable_objects?.bindings??[])if(!(a.name===void 0||a.class_name===void 0)){if(a.script_name!==void 0){c.push(`durable_objects.${a.name} (external script_name "${a.script_name}")`);continue}n.add("DurableObjectNamespace"),r.push(m(a.name,`DurableObjectNamespace(${o(a.name)}, { className: ${o(a.class_name)}, sqlite: ${String(t.has(a.class_name))} })`))}},v=(e,t)=>{for(const[n,r]of Object.entries(e.vars??{}))t.push(m(n,o(r)))},f=["ai","ai_search","ai_search_namespaces","analytics","analytics_engine_datasets","artifacts","assets","browser","containers","flagship","hyperdrive","images","pipelines","secrets_store_secrets","send_email","services","tail_consumers","vectorize","worker_loaders","workflows","exports"],w=(e,t)=>{for(const n of f){const r=e[n];r!==void 0&&(!Array.isArray(r)||r.length>0)&&t.push(n)}(e.queues?.consumers?.length??0)>0&&t.push("queues.consumers")},k=e=>{const t=e.name??"worker",n=[],r=new Set(["Worker"]),c=[],a=[],p=h(e),b=[{construct:"D1Database",entries:(e.d1_databases??[]).map(s=>({binding:s.binding,name:s.database_name})),nameKey:"name"},{construct:"R2Bucket",entries:(e.r2_buckets??[]).map(s=>({binding:s.binding,name:s.bucket_name})),nameKey:"name"},{construct:"KVNamespace",entries:(e.kv_namespaces??[]).map(s=>({binding:s.binding,name:s.binding})),nameKey:"title"},{construct:"Queue",entries:(e.queues?.producers??[]).map(s=>({binding:s.binding,name:s.queue})),nameKey:"name"}];for(const{construct:s,entries:l,nameKey:y}of b)for(const i of l)i.binding!==void 0&&(r.add(s),c.push(`const ${u(i.binding)} = await ${s}(${o(i.binding)}, { adopt: true, ${y}: ${o(i.name??i.binding)} });`),a.push(m(i.binding)));g(e,p,r,a,n),v(e,a),w(e,n);const _=["adopt: true,",a.length===0?void 0:`bindings: {
|
|
2
|
+
${a.join(`
|
|
3
|
+
`)}
|
|
4
|
+
},`,e.compatibility_date===void 0?void 0:`compatibilityDate: ${o(e.compatibility_date)},`,e.compatibility_flags===void 0||e.compatibility_flags.length===0?void 0:`compatibilityFlags: ${o([...e.compatibility_flags])},`,e.triggers?.crons===void 0||e.triggers.crons.length===0?void 0:`crons: ${o([...e.triggers.crons])},`,e.main===void 0?void 0:`entrypoint: ${o(e.main)},`,`name: ${o(t)},`].filter(s=>s!==void 0);return{source:["// GENERATED by @lunora/config from wrangler.jsonc — do not edit.","// Re-generated on every `lunora deploy`; edit wrangler.jsonc instead.","",'import alchemy from "alchemy";',`import { ${[...r].toSorted((s,l)=>s.localeCompare(l)).join(", ")} } from "alchemy/cloudflare";`,"",`const app = await alchemy(${o(t)});`,"",...c.length===0?[]:[...c,""],`export const worker = await Worker(${o(t)}, {`,` ${_.join(`
|
|
5
|
+
`)}`,"});","","await app.finalize();",""].join(`
|
|
6
|
+
`),unsupported:n}};export{h as sqliteClasses,k as wranglerToAlchemy};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lunora/config",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.295",
|
|
4
4
|
"description": "Internal shared CLI + Vite config layer for Lunora: wrangler.jsonc validation, binding inference, and .dev.vars scaffolding",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bindings",
|
|
@@ -54,10 +54,10 @@
|
|
|
54
54
|
"access": "public"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@lunora/codegen": "1.0.0-alpha.
|
|
58
|
-
"@lunora/container": "1.0.0-alpha.
|
|
59
|
-
"@lunora/errors": "1.0.0-alpha.
|
|
60
|
-
"@lunora/seed": "1.0.0-alpha.
|
|
57
|
+
"@lunora/codegen": "1.0.0-alpha.252",
|
|
58
|
+
"@lunora/container": "1.0.0-alpha.68",
|
|
59
|
+
"@lunora/errors": "1.0.0-alpha.50",
|
|
60
|
+
"@lunora/seed": "1.0.0-alpha.180",
|
|
61
61
|
"@visulima/colorize": "2.1.1",
|
|
62
62
|
"@visulima/find-ai-runner": "1.0.2",
|
|
63
63
|
"@visulima/package": "5.0.20",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{sqliteClasses as u}from"./wranglerToAlchemy-BMOQYRyw.mjs";const l=1,p=new Set(["$schema","account_id","compatibility_date","compatibility_flags","keep_vars","main","migrations","minify","name","observability","placement","routes","rules","secrets","triggers","upload_source_maps","vars","workers_dev"]),y=e=>Object.fromEntries(Object.entries(e).filter(([,n])=>n!==void 0)),a=[{bindingKey:"binding",field:"analytics_engine_datasets",resourceKey:"dataset",type:"analytics_engine"},{bindingKey:"binding",field:"artifacts",resourceKey:"namespace",type:"artifacts"},{bindingKey:"class_name",field:"containers",resourceKey:"image",type:"container"},{bindingKey:"binding",field:"d1_databases",resourceIdKey:"database_id",resourceKey:"database_name",type:"d1"},{bindingKey:"binding",field:"hyperdrive",resourceIdKey:"id",type:"hyperdrive"},{bindingKey:"binding",field:"kv_namespaces",resourceIdKey:"id",type:"kv"},{bindingKey:"binding",field:"pipelines",resourceKey:["stream","pipeline"],type:"pipeline"},{bindingKey:"binding",field:"r2_buckets",resourceKey:"bucket_name",type:"r2"},{bindingKey:"binding",field:"services",resourceKey:"service",type:"service"},{bindingKey:"binding",field:"vectorize",resourceKey:"index_name",type:"vectorize"},{bindingKey:"binding",field:"vpc_networks",resourceIdKey:["tunnel_id","network_id"],type:"vpc_network"},{bindingKey:"binding",field:"vpc_services",resourceIdKey:"service_id",type:"vpc_service"},{bindingKey:"binding",field:"workflows",resourceKey:"name",type:"workflow"}],c=[{field:"ai",type:"ai"},{field:"assets",type:"assets"},{field:"browser",type:"browser"},{field:"images",type:"images"},{field:"media",type:"media"},{field:"stream",type:"stream"}],b=new Set([...a.map(e=>e.field),...c.map(e=>e.field),"durable_objects","exports","queues"]),d=(e,n)=>(typeof n=="string"?[n]:n??[]).map(i=>e[i]).find(i=>typeof i=="string"&&i!==""),m=(e,n)=>{const t=[];for(const i of a)for(const r of e[i.field]??[]){const s=d(r,i.bindingKey);if(s===void 0){n.push(i.field);continue}t.push({binding:s,className:d(r,"class_name"),resource:d(r,i.resourceKey),resourceId:d(r,i.resourceIdKey),type:i.type})}return t},g=(e,n)=>{const t=u(e),i=[];for(const r of e.durable_objects?.bindings??[]){if(r.name===void 0||r.name===""){n.push("durable_objects");continue}i.push({binding:r.name,className:r.class_name,sqlite:r.script_name===void 0&&r.class_name!==void 0?t.has(r.class_name):void 0,type:"durable_object"})}return i},_=(e,n)=>{const t=[];for(const i of e.queues?.producers??[]){if(i.binding===void 0||i.binding===""){n.push("queues.producers");continue}t.push({binding:i.binding,resource:i.queue,type:"queue_producer"})}for(const i of e.queues?.consumers??[]){if(i.queue===void 0||i.queue===""){n.push("queues.consumers");continue}t.push({binding:i.queue,resource:i.queue,type:"queue_consumer"})}return t},f=(e,n)=>Object.entries(e.exports??{}).flatMap(([t,i])=>i?.type!=="workflow"?(n.push(`exports.${t}`),[]):[{binding:t,className:t,resource:i.name,type:"workflow"}]),v=(e,n,t)=>[...f(e,t),...m(e,n),...g(e,n),..._(e,n),...c.filter(i=>e[i.field]?.binding!==void 0).map(i=>({binding:e[i.field]?.binding,type:i.type}))],w=e=>{const n=[],t=[],i=v(e,n,t).map(s=>y(s)).toSorted((s,o)=>s.type.localeCompare(o.type)||s.binding.localeCompare(o.binding)),r=[...Object.keys(e).filter(s=>!p.has(s)&&!b.has(s)),...n.map(s=>`${s} (entry with no binding name)`),...t].toSorted((s,o)=>s.localeCompare(o));return{bindings:i,...e.compatibility_date===void 0?{}:{compatibilityDate:e.compatibility_date},...e.compatibility_flags===void 0?{}:{compatibilityFlags:e.compatibility_flags},crons:e.triggers?.crons??[],...e.name===void 0?{}:{name:e.name},unknown:r,vars:Object.keys(e.vars??{}).toSorted((s,o)=>s.localeCompare(o)),version:l}};export{l as BINDING_MANIFEST_VERSION,w as buildBindingManifest};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{writeFileSync as p,rmSync as m}from"node:fs";import{applyModify as g}from"./applyModify-DKP2l6S9.mjs";import{r as b}from"./lunora-manifest-v90ZUbVp.mjs";import{o as h}from"./reconcile-services-3dn35zgy.mjs";import{findWranglerFile as y,readWranglerJsonc as v}from"./WRANGLER_FILES-UNW-xY5u.mjs";import{join as E}from"node:path";const d={ai:{label:"AI",shape:"object"},d1_databases:{label:"D1",shape:"array"},kv_namespaces:{label:"KV",shape:"array"},queues:{label:"Queue",shape:"producers"},r2_buckets:{label:"R2",shape:"array"},services:{label:"Service",shape:"array"},vectorize:{label:"Vectorize",shape:"array"}},S=Object.keys(d),f=(e,r)=>typeof e.binding=="string"?e.binding:r,c=(e,r,n,t)=>{const o=[];for(const[a,i]of r.entries())i!=null&&o.push({binding:f(i,`#${String(a)}`),kind:n,path:[...t,a],section:e});return o},R=(e,r)=>{const{label:n,shape:t}=d[e];if(t==="array"){const a=r[e]??[];return c(e,a,n,[])}if(t==="producers")return c(e,r.queues?.producers??[],n,["producers"]);const o=r.ai;return o==null?[]:[{binding:f(o,e),kind:n,path:[],section:e}]},B=e=>S.flatMap(r=>R(r,e)),j=(e,r)=>{let n=e;for(const t of r)n=g(n,[t.section,...t.path,"remote"],!0);return n},s=()=>{},_=e=>{let r=!1;return()=>{if(!r){r=!0;try{m(e,{force:!0,recursive:!0})}catch{}}}};let u=0;const C=()=>(u+=1,`.wrangler.lunora-remote.${String(process.pid)}.${String(u)}.jsonc`),O=e=>{if(!e.enabled)return{cleanup:s,enabled:!1,remoteBindings:[]};const r=y(e.projectRoot);if(!r)return{cleanup:s,enabled:!0,reason:"wrangler.jsonc not found",remoteBindings:[]};const{parsed:n,text:t}=v(r);if(n===void 0)return{cleanup:s,enabled:!0,reason:`failed to parse ${r} as JSONC`,remoteBindings:[]};const o=h(b(e.projectRoot)),a=B(n).filter(l=>l.section!=="services"||!o.has(l.binding));if(a.length===0)return{cleanup:s,enabled:!0,reason:"no remote-eligible bindings to proxy",remoteBindings:[]};const i=E(e.projectRoot,C());return p(i,j(t,a),"utf8"),{cleanup:_(i),configPath:i,enabled:!0,remoteBindings:a}},w=e=>{if(e===void 0)return!1;const r=e.trim().toLowerCase();return r==="1"||r==="true"},$=e=>e.flag===!0||w(e.envValue)?!0:e.configPreference??!1;export{d as REMOTE_ELIGIBLE_KEYS,_ as createCleanup,j as injectRemoteFlags,w as isRemoteEnvEnabled,O as materializeRemoteWranglerConfig,B as planRemoteBindings,$ as resolveRemoteEnabled};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as g,v as _,a as b,b as f,c as E,d as m,e as d,f as h,g as D,H as R,h as S,R as p,S as I,i as y,j as B,W as L,k as O}from"./validate-bindings-Dnf1t0SY.mjs";import{validateTailConsumers as w,validateSendEmail as N,validateSecretsRequired as T,validateLogpush as C,validateLimits as j,validatePlacement as k,validateObservability as A,validateAssets as $,validateCache as U,validateExports as W,validateCorsVariables as G,validateSchedulerOrigin as H}from"./withTailConsumer-B1NoKIsj.mjs";import{isCacheEnabled as F,WORKERS_CACHE_MIN_DATE as c}from"./WORKERS_CACHE_MIN_DATE-0k9ABJtF.mjs";import{mergeWranglerEnvironment as M}from"./mergeWranglerEnvironment-DOKJUNH8.mjs";const v="2026-04-07",J="web_socket_auto_reply_to_close",u=/^\d{4}-\d{2}-\d{2}$/,V=(o,r,l)=>{const{error:e,merged:i,unverifiedKeys:n}=M(o,r);return e!==void 0?{error:e,wrangler:i}:(n.length>0&&l.push(`env.${String(r)} overrides ${n.join(", ")}, which this validator doesn't have a verified inheritance rule for — validated against the TOP-LEVEL value only. Double-check ${n.length===1?"it":"them"} by hand for "${String(r)}".`),{wrangler:i})},Y=(o,r,l)=>{const e=[],i=[];if(!o||typeof o!="object")return e.push("wrangler config is not a valid object"),{errors:e,valid:!1,warnings:i};const{error:n,wrangler:a}=V(o,l,i);if(n!==void 0)return e.push(n),{errors:e,valid:!1,warnings:i};g(a.durable_objects?.bindings).find(t=>t.name==="SHARD"&&t.class_name==="ShardDO")||e.push('durable_objects.bindings must include { "name": "SHARD", "class_name": "ShardDO" } — your dev server auto-reconciles this on startup, or add the binding manually'),_(a,e);const s=a.compatibility_date??"";s&&!u.test(s)?e.push(`compatibility_date must be in YYYY-MM-DD format (got "${s}")`):s<v&&e.push(`compatibility_date must be >= "${v}" (got "${s||"<missing>"}")`),F(a)&&u.test(s)&&s<c&&e.push(`cache.enabled requires compatibility_date >= "${c}" (got "${s||"<missing>"}")`),b(a,r,e),f(a,e),E(a,r?.vectorIndexNames??[],e),w(a,e),m(a,e,i),d(a.workflows,"workflows",L,e),h(a,e),D(a,e),d(a.secrets_store_secrets,"secrets_store_secrets",O,e);for(const t of R)S(a,t,e,i);for(const t of p)d(a[t.key],t.key,t,e);for(const t of I)y(a,t,e);return B(a,e),N(a,e,i),T(a,e),C(a,e),j(a,e),k(a,e),A(a,e),$(a,e),U(a,e),W(a,e),G(a,e),H(a,l,i),{errors:e,valid:e.length===0,warnings:i}},X=Y;export{v as REQUIRED_COMPATIBILITY_DATE,J as REQUIRED_FLAG,X as validateWrangler,Y as validateWranglerConfig};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{existsSync as f,readFileSync as N,readdirSync as W}from"node:fs";import{join as l,dirname as y,extname as w,basename as _}from"node:path";import{discoverSchemaInfo as P}from"./discoverSchemaInfo-DJvevsCm.mjs";import{COMPOSED_WORKER_ENTRY as L,LUNORA_WORKER_VIRTUAL_ID as g,isGeneratedOutput as F,WORKER_ENTRY_FALLBACKS as M,GENERATED_DIRECTORY as U,COMPOSED_ENTRY_DURABLE_OBJECTS as D,GENERATED_CLASS_MODULES as A,SOURCE_DOT_DIRECTORIES as B,NON_SOURCE_DIRECTORIES as G,isFrameworkDurableObject as Y}from"./COMPOSED_WORKER_ENTRY-C69wqbSP.mjs";import{o as K}from"./validate-bindings-Dnf1t0SY.mjs";import{Project as X,Node as p}from"ts-morph";import{mergeWranglerEnvironment as J}from"./mergeWranglerEnvironment-DOKJUNH8.mjs";import{findWranglerFile as V,readWranglerJsonc as q}from"./WRANGLER_FILES-UNW-xY5u.mjs";import{validateWranglerConfig as z}from"./REQUIRED_COMPATIBILITY_DATE-jTnj2MPJ.mjs";const E=[".ts",".tsx",".mts",".cts"],b=new Set(E),H=new Set([".cjs",".js",".mjs"]),v="default",S={".cjs":[".cts"],".js":[".ts",".tsx"],".mjs":[".mts"]},Q=250,Z=(e,s,t)=>{const o=l(s,L);if(f(o))return{origin:"declared",path:o};if(e===g)return{origin:"composed"};const n=()=>{const a=M.map(c=>l(s,c)).find(c=>f(c));return a===void 0?void 0:{origin:"probed",path:a}};if(typeof e!="string"||e.length===0||F(e))return n();const r=l(y(t),e),i=w(r);if(!(!b.has(i)&&!H.has(i)))return f(r)?{origin:"declared",path:r}:{origin:"absent",path:r}},T=(e,s)=>{if(p.isIdentifier(e)){s.add(e.getText());return}if(p.isObjectBindingPattern(e)||p.isArrayBindingPattern(e))for(const t of e.getElements())p.isBindingElement(t)&&T(t.getNameNode(),s)},ee=(e,s)=>{const t=[];for(const o of e.getExportDeclarations())if(!o.isTypeOnly()){if(o.isNamespaceExport()){const n=o.getNamespaceExport();n===void 0?t.push(o.getModuleSpecifierValue()??""):s.add(n.getName());continue}for(const n of o.getNamedExports())n.isTypeOnly()||s.add(n.getAliasNode()?.getText()??n.getName())}return t},te=(e,s)=>{for(const t of e.getVariableStatements().filter(o=>o.getExportKeyword()!==void 0))for(const o of t.getDeclarations())T(o.getNameNode(),s);for(const t of[...e.getClasses(),...e.getFunctions(),...e.getEnums()]){if(t.getExportKeyword()===void 0)continue;const o=t.isDefaultExport()?v:t.getName();o!==void 0&&s.add(o)}e.getExportAssignments().length>0&&s.add(v)},$=(e,s)=>{const t=new X({compilerOptions:{allowJs:!0},skipFileDependencyResolution:!0,skipLoadingLibFiles:!0,useInMemoryFileSystem:!0}),o=t.createSourceFile(e,s,{overwrite:!0});return t.getProgram().compilerObject.getSyntacticDiagnostics(o.compilerNode).length>0?void 0:o},re=(e,s)=>{if(!s.startsWith("./")&&!s.startsWith("../"))return;const t=l(y(e),s),o=w(t),n=b.has(o)||S[o]!==void 0,r=n?t.slice(0,-o.length):t;return[...b.has(o)?[t]:[],...(S[o]??[]).map(a=>`${r}${a}`),...n?[]:E.map(a=>`${t}${a}`),...n||o.length===0?E.map(a=>l(r,`index${a}`)):[]].find(a=>f(a))},k=e=>{const s=new Set,t=new Set([e]),o=[e];for(;o.length>0;){if(t.size-1>Q)return;const n=o.pop();let r;try{r=N(n,"utf8")}catch{return}const i=$(_(n),r);if(i===void 0)return;const a=ee(i,s);te(i,s);for(const c of a){const d=re(n,c);if(d===void 0)return;t.has(d)||(t.add(d),o.push(d))}}return s},oe=(e,s)=>{const t={exports:void 0,kind:"composed",path:g},o=l(e,s,U);if(!f(o))return t;const n=new Set(D);for(const r of A){const i=l(o,`${r}.ts`);if(!f(i))continue;const a=k(i);if(a===void 0)return t;for(const c of a)n.add(c)}return{exports:n,kind:"composed",path:g}},se=(e,s,t)=>{if(e===void 0||e.origin==="absent")return;if(e.origin==="composed")return oe(s,t);const o=k(e.path);if(!(e.origin==="probed"&&o!==void 0&&!o.has(v)))return{exports:o,kind:"authored",path:e.path}},ne=new Set([".cjs",".cts",".js",".jsx",".mjs",".mts",".ts",".tsx"]),ie=2e3,R="defineTable",O="defineApp",ae=e=>{const s=[],t=[];let o;try{o=W(e,{withFileTypes:!0})}catch{return{files:s,subdirectories:t}}for(const n of o)n.isDirectory()?n.name.startsWith(".")&&!B.has(n.name)||G.has(n.name)||t.push(l(e,n.name)):ne.has(w(n.name))&&s.push(l(e,n.name));return{files:s,subdirectories:t}},j=(e,s)=>{const t=new Set;for(const o of e.getImportDeclarations())for(const n of o.getNamedImports())!n.isTypeOnly()&&n.getName()===s&&t.add(n.getAliasNode()?.getText()??n.getName());return t},ce=(e,s)=>{let t=!1;return e.forEachDescendant((o,n)=>{if(!p.isCallExpression(o))return;const r=o.getExpression();p.isIdentifier(r)&&s.has(r.getText())&&(t=!0,n.stop())}),t},le=e=>{let s=e;for(;p.isCallExpression(s)||p.isPropertyAccessExpression(s);)s=s.getExpression();return s},de=(e,s)=>{const t=le(e);return p.isIdentifier(t)&&s.has(t.getText())},I={global:/\.\s*global\s*\(/u,hyperdriveGlobal:/\.\s*hyperdriveGlobal\s*\(/u,vectors:/\.\s*vectors\s*\(/u},pe=e=>Object.hasOwn(I,e),fe=(e,s)=>{const t=new Set,o=new Set([R,...j(e,R)]);return e.forEachDescendant(n=>{if(!p.isCallExpression(n))return;const r=n.getExpression();if(!p.isPropertyAccessExpression(r)||de(r,o))return;const i=r.getName();pe(i)&&s.has(i)&&t.add(i)}),t},he=(e,s)=>{let t;try{t=N(e,"utf8")}catch{return}const o=new Set([...s].filter(r=>I[r].test(t)));if(o.size===0&&!t.includes(O))return;const n=$(_(e),t);return n===void 0?{chained:o,composes:!1}:{chained:fe(n,o),composes:ce(n,j(n,O))}},ue=(e,s)=>{const t=[e],o=new Set;let n=0,r;const i=a=>{if(n+=1,n>ie)return!1;const c=he(a,s);for(const d of c?.chained??[])o.add(d);return c?.composes&&(r??=a),!0};for(;t.length>0;){const a=t.pop(),{files:c,subdirectories:d}=ae(a);t.push(...d);for(const m of c){if(!i(m))return;if(r!==void 0&&o.size===s.size)return{chained:o,site:r}}}return r===void 0?void 0:{chained:o,site:r}},C=e=>Array.isArray(e)?e:[],me=(e,s,t)=>Object.entries(e?.images??{}).flatMap(([o,n])=>{const r=n?.dockerfile;return typeof r!="string"||f(r.startsWith("/")?r:l(s,r))?[]:[`containers images["${o}"] dockerfile "${r}" does not exist (resolved relative to ${t}); create the Dockerfile`]}),ge=(e,s,t)=>{const o=[];for(const n of C(e)){const r=n?.image;typeof r=="string"&&(r.startsWith("./")||r.startsWith("../")||r.startsWith("/")||r.includes("Dockerfile"))&&!f(r.startsWith("/")?r:l(s,r))&&o.push(`containers image "${r}" does not exist (resolved relative to ${t}); create the Dockerfile or point image at a registry reference`),o.push(...me(n,s,t))}return o},Ee=(e,s)=>{const t=e?.vectorIndexNames??[],o=[];if(t.length>0&&o.push({message:r=>`schema declares vector index(es) ${t.map(i=>`"${i}"`).join(", ")} but nothing chains .vectors(...) onto defineApp() (composed in: ${r}) — \`ctx.vectors\` is then a throwing stub and buildWorkerOptions rejects EVERY request, /_lunora/health included. Add \`.vectors((env) => ({ ${String(t[0])}: env.<BINDING> }))\` to the chain.`,method:"vectors"}),e?.hasD1GlobalTable&&o.push({message:r=>`schema declares .global() table(s) but nothing chains .global(...) onto defineApp() (composed in: ${r}) — the shard then has no global writer, so every read or write of a global table throws INTERNAL ("requires a globalDb writer"). Add \`.global({ d1: (env) => env.DB })\` to the chain.`,method:"global"}),e?.hasHyperdriveGlobalTable&&o.push({message:r=>`schema declares .global({ backend: "hyperdrive" }) table(s) but nothing chains .hyperdriveGlobal(...) onto defineApp() (composed in: ${r}) — the shard then has no global writer, so every read or write of those tables throws INTERNAL. Add \`.hyperdriveGlobal({ engine: "postgres", exec: (env) => buildPgExec(fromPostgresJs(postgres(env.HYPERDRIVE.connectionString))) })\` to the chain (\`buildPgExec\` from \`@lunora/hyperdrive/global\`, \`fromPostgresJs\` from \`@lunora/hyperdrive\`).`,method:"hyperdriveGlobal"}),o.length===0)return[];const n=ue(s,new Set(o.map(r=>r.method)));return n===void 0?[]:o.filter(r=>!n.chained.has(r.method)).map(r=>r.message(n.site))},be="does not export it",ve=(e,s)=>{if(s!=="composed")return`Re-export it from the module that defines it (\`export { ${e} } from "./…";\`), or add it to the app builder's own export (\`export const { ${e} } = app;\`).`;const t=`it exports ${D.join(", ")}, SchedulerDO when its binding is declared, and every class codegen emits from your ${A.map(o=>`${o}.ts`).join(" / ")} declarations`;return Y(e)?`\`@lunora/vite\` generates that entry — ${t}, and ${e} is not among them. Class-A composition does not carry ${e}, so drop the binding; a project that needs it has to own its worker entry (add \`src/worker.ts\`, which \`lunora deploy\` bundles in place of \`main\`, and compose \`defineApp()\` there).`:`\`@lunora/vite\` generates that entry, so there is no file to add a re-export to: ${t}. Declare "${e}" in one of those and re-run \`lunora codegen\`, or drop the binding.`},ye=(e,s)=>{const t=s.exports;if(t===void 0)return[];const o=[];for(const r of K(e.durable_objects?.bindings))typeof r.class_name=="string"&&r.class_name.length>0&&r.script_name===void 0&&o.push({className:r.class_name,label:"durable_objects.bindings"});for(const r of C(e.workflows))typeof r?.class_name=="string"&&r.class_name.length>0&&r.script_name===void 0&&o.push({className:r.class_name,label:"workflows"});for(const[r,i]of Object.entries(e.exports??{}))i?.type==="workflow"&&o.push({className:r,label:"workflows"});return o.filter(r=>!t.has(r.className)).map(r=>`${r.label} declares class "${r.className}" but the ${s.kind==="composed"?"composed class-A worker entry":"worker entry"} (${s.path}) ${be} — wrangler refuses to bundle a Worker whose ${r.label==="workflows"?"Workflow":"Durable Object"} classes are not exported. ${ve(r.className,s.kind)}`)},we=e=>e?.origin!=="absent"?[]:[`main is set but no readable file is there (looked in ${e.path}) — wrangler cannot resolve the worker entry, so a deploy will fail there. Point main at the entry that composes your app, or remove it to fall back to the conventional locations.`],$e=e=>{const s=e.schemaDir??"lunora",t=V(e.projectRoot);if(!t){const h=`wrangler.jsonc not found in ${e.projectRoot}; create one declaring at least the SHARD durable object binding.`;return{problems:[h],report:{errors:[h],valid:!1,warnings:[]},wranglerPath:void 0}}const{parsed:o}=q(t);if(o===void 0){const h=`failed to parse ${t} as JSONC.`;return{problems:[h],report:{errors:[h],valid:!1,warnings:[]},wranglerPath:t}}const{error:n,merged:r}=J(o,e.environment);if(n!==void 0)return{problems:[n],report:{errors:[n],valid:!1,warnings:[]},wranglerPath:t};const{error:i,info:a}=P(e.projectRoot,s),c=z(o,a,e.environment);i!==void 0&&c.warnings.push(`schema parse failed in ${s}/schema.ts: ${i}`);const d=y(t),m=Z(r.main,e.projectRoot,t),x=se(m,e.projectRoot,s);c.errors.push(...ge(r.containers??[],d,t)),c.warnings.push(...we(m)),x!==void 0&&c.errors.push(...ye(r,x)),c.errors.push(...Ee(a,e.projectRoot));const u=r.assets?.directory;if(typeof u=="string"&&u.length>0){const h=u.startsWith("/")?u:l(d,u);f(h)||c.warnings.push(`assets.directory "${u}" does not exist yet — it is created by the client build; run the build before deploy`)}return c.valid=c.errors.length===0,{problems:c.errors,report:c,wranglerPath:t}};export{be as UNEXPORTED_CLASS_MARKER,$e as validateWranglerProject};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{readFileSync as W,writeFileSync as Y}from"node:fs";import{createRequire as G}from"node:module";import{join as M}from"node:path";import{containerBuildTag as H}from"@lunora/container";import{applyModify as x}from"./applyModify-DKP2l6S9.mjs";import{a as J,r as R}from"./lunora-manifest-v90ZUbVp.mjs";import{parseTree as V,findNodeAtLocation as X}from"jsonc-parser";import{r as z,a as Z,b as ee,c as ne}from"./reconcile-services-3dn35zgy.mjs";import{DEV_VARS_FILE as se,parseDevVariableEntries as te}from"./DEV_VARS_EXAMPLE_FILE-CqLorAxT.mjs";import{packageNamesFromBindings as oe}from"./inferLunoraBindings-DXLEJY9w.mjs";import{requiredSecrets as re}from"./buildPackageSecretsBlock-yv9mjKEW.mjs";import{w as ie,m as ae,s as L,o as I,n as j,p as de}from"./validate-bindings-Dnf1t0SY.mjs";import{findWranglerFile as ce,readWranglerJsonc as le}from"./WRANGLER_FILES-UNW-xY5u.mjs";const ue=[["maxBatchSize","max_batch_size"],["maxBatchTimeout","max_batch_timeout"],["maxRetries","max_retries"],["deadLetterQueue","dead_letter_queue"],["retryDelay","retry_delay"]],P=e=>Object.fromEntries(ue.filter(([n])=>e.tuning[n]!==void 0).map(([n,s])=>[s,e.tuning[n]])),B="queueTuning",ge=/^[\t ]*(?:,[\t ]*)?(?:\/\/[^\n\r]*)?\r?\n/u,pe=/^[\t ]*,/u,me=(e,n)=>{const s=V(e),t=s===void 0?void 0:X(s,[...n])?.parent;if(t?.type==="property"){const r=t.offset+t.length,o=e.lastIndexOf(`
|
|
2
|
-
`,t.offset-1)+1,l=ge.exec(e.slice(r));if(l!==null&&e.slice(o,t.offset).trim()===""){const u=t.parent?.children??[],h=u.indexOf(t),a=h===u.length-1&&h>0?u[h-1]:void 0,d=a===void 0?void 0:pe.exec(e.slice(a.offset+a.length))??void 0;return(d===void 0||a===void 0?e.slice(0,o):e.slice(0,a.offset+a.length)+e.slice(a.offset+a.length+d[0].length,o))+e.slice(r+l[0].length)}}return x(e,n,void 0)},K=(e,n,s,t,r,o=new Set)=>{const l=s.join("."),u={},h=[],a=[];let d=e;return{entries:n.map((c,v)=>{const g=t(c);if(g===void 0||c.queue===void 0)return c;const m=Object.fromEntries(Object.entries(P(g)).filter(([f])=>!o.has(f))),b=Object.entries(r[c.queue]??{}).filter(([f])=>!Object.hasOwn(m,f)),w=Object.entries(m).filter(([f,_])=>c[f]!==_),k=b.filter(([f,_])=>c[f]===_).map(([f])=>f),S=Object.fromEntries(Object.entries({...c,...m}).filter(([f])=>!k.includes(f)));for(const[f,_]of w)d=x(d,[...s,v,f],_);for(const f of k)d=me(d,[...s,v,f]);for(const[f,_]of b){const N=c[f];N!==void 0&&N!==_&&a.push(`${l}/${c.queue}: ${f} is no longer declared by defineQueue, but it was changed by hand to ${JSON.stringify(N)} from the declared ${JSON.stringify(_)}, so it was kept. Delete it from wrangler.jsonc if it should go.`)}return(w.length>0||k.length>0)&&h.push(`${l}/${c.queue} (${[...w.map(([f])=>f),...k.map(f=>`removed ${f}`)].join(", ")})`),Object.keys(m).length>0&&(u[c.queue]=m),S}),owned:u,text:d,updated:h,warnings:a}},fe=(e,n,s,t)=>{const r=n.queues??{},o=r.producers??[],l=r.consumers??[],u=new Set(o.map(g=>g.binding)),h=new Set(l.map(g=>g.queue)),a=s.filter(g=>!u.has(g.bindingName)),d=s.filter(g=>!h.has(g.name)),p=K(e,l,["queues","consumers"],g=>s.find(m=>m.name===g.queue),t);let c=p.text;const v={...p.owned};if(a.length>0||d.length>0){const g=[...o,...a.map(b=>({binding:b.bindingName,queue:b.name}))],m=[...p.entries,...d.map(b=>({queue:b.name,...b.mode==="pull"?{type:"http_pull"}:{},...P(b)}))];for(const b of d){const w=P(b);Object.keys(w).length>0&&(v[b.name]=w)}c=x(c,["queues"],{consumers:m,producers:g})}return{added:[...a.map(g=>`queues.producers/${g.bindingName}`),...d.map(g=>`queues.consumers/${g.name}`)],owned:v,text:c,updated:p.updated,warnings:p.warnings}},he=(e,n,s,t,r)=>{const o=n.env?.[t],l=o?.queues?.consumers??[],u=o?.queues?.producers??[],h=c=>{const v=u.find(g=>g.queue===c.queue)?.binding;return v!==void 0?s.find(g=>g.bindingName===v):s.find(g=>g.name===c.queue&&!u.some(m=>m.binding===g.bindingName))},a=K(e,l,["env",t,"queues","consumers"],h,r,new Set(["dead_letter_queue"])),d=l.filter(c=>c.queue!==void 0&&h(c)===void 0).map(c=>`env.${t}.queues.consumers/${String(c.queue)}: no defineQueue export matches it — this block declares no producer mapping one of their bindings to "${String(c.queue)}", and no export is named that — so it was not retuned. A consumer for a queue another worker produces is skipped the same way.`),p=l.flatMap(c=>{const v=h(c)?.tuning.deadLetterQueue;return v===void 0||c.dead_letter_queue!==void 0?[]:[`env.${t}.queues.consumers/${String(c.queue)}: defineQueue declares deadLetterQueue "${v}", but this consumer has no dead_letter_queue, so its exhausted messages are dropped. Queue names differ per environment, so reconcile does not write it here; add it by hand.`]});return{added:[],owned:a.owned,text:a.text,updated:a.updated,warnings:[...a.warnings,...p,...d]}},be=(e,n)=>{if(e?.lunoraIsForeign===!0)return n.push(`${e.path}: \`lunora\` is not an object, so the queue tuning ownership record cannot be read or written — an option removed from defineQueue stays deployed.`),{};const s=e?.lunora?.[B],t=r=>typeof r=="object"&&r!==null&&!Array.isArray(r);return s===void 0?{}:!t(s)||!Object.values(s).every(r=>t(r)&&Object.values(r).every(o=>t(o)))?(n.push(`${e?.path??"package.json"}: \`lunora.${B}\` is not a map of scope → queue → fields, so it is ignored — an option removed from defineQueue stays deployed until the next pass records it again.`),{}):s},ve=(e,n,s)=>{const t=Object.fromEntries(Object.entries({...n,...s}).filter(([,r])=>Object.keys(r).length>0));J(e,B,Object.keys(t).length===0?void 0:t)},A="PIPELINES",we=(e,n)=>{const s=e.flagshipBinding!==void 0&&!(n?.flagship??[]).some(o=>o.binding===e.flagshipBinding),t=e.usesPipelines&&!(n?.pipelines??[]).some(o=>o.binding===A);return[[e.usesKv&&(n?.kv_namespaces?.length??0)===0,"@lunora/bindings/kv is used but no kv_namespaces binding exists; add a kv_namespaces entry ({ binding, id }) and pass env.<BINDING> to createKv() — the namespace id can't be auto-provisioned."],[e.usesHyperdrive&&(n?.hyperdrive?.length??0)===0,"@lunora/hyperdrive is used but no hyperdrive binding exists; run 'wrangler hyperdrive create' and add a 'hyperdrive' binding ({ binding, id }) — the id can't be auto-provisioned."],[t,`ctx.pipelines is used but no "${A}" pipelines binding exists; run 'wrangler pipelines create <name>' and add a 'pipelines' binding ({ binding: "${A}", stream }) — codegen resolves this one name, and the pipeline resource can't be auto-provisioned.`],[s,`lunora/flags.ts uses Flagship in binding mode but no flagship binding "${e.flagshipBinding??""}" exists; add a flagship entry ({ binding: "${e.flagshipBinding??""}", app_id }) — the app_id can't be auto-provisioned.`]].filter(([o])=>o).map(([,o])=>o)},ye=e=>[[e.usesX402Charge,"@lunora/x402/charge is used; set the recipient wallet address as a [vars] entry (the var name is your choice) and pass it to the charge config — the x402 facilitator settles USDC to that address."],[e.usesX402Pay,"@lunora/x402/pay is used (ActionCtx-only, spends real funds); add a secrets_store_secrets[] binding holding the agent wallet key (binding name == signer.secretName) and pair the pay rail with a spend policy — ctx.secrets reads a Secrets Store binding, not .dev.vars."]].filter(([s])=>s).map(([,s])=>s),C=(e,n,s)=>s.filter(t=>!t.exported).map(t=>`${e} "${t.exportName}" is declared but ${t.className} is not exported by the worker entry; add \`export * from "./lunora/_generated/${n}"\` so its binding can be provisioned.`),_e=(e,n)=>{const s=new Set([...e.workflows,...e.agents].map(o=>o.className));if(s.size===0)return[];const t=Object.entries(n.exports??{}).flatMap(([o,l])=>l?.type==="workflow"?[o]:[]),r=(n.workflows??[]).flatMap(o=>o.class_name===void 0||o.script_name!==void 0?[]:[o.class_name]);return[...new Set([...t,...r])].filter(o=>!s.has(o)).map(o=>`wrangler.jsonc declares workflow "${o}" but no defineWorkflow/defineAgent export generates that class — a leftover from a rename will fail the deploy (wrangler rejects a class the worker does not export). Remove it if it is not hand-wired.`)},xe=(e,n)=>{if(e.queues.length===0)return[];const s=new Set(e.queues.map(r=>r.name)),t=new Set(e.queues.map(r=>r.bindingName));return[...(n.queues?.consumers??[]).flatMap(r=>{const{queue:o}=r;return o===void 0||s.has(o)?[]:[`wrangler.jsonc subscribes queues.consumers[] to "${o}" but no defineQueue export declares that queue — a leftover from a rename keeps delivering batches this worker has no handler for (they retry to exhaustion, then drop or dead-letter). Remove it if it is not hand-wired.`]}),...(n.queues?.producers??[]).flatMap(r=>{const{binding:o}=r;return o===void 0||t.has(o)?[]:[`wrangler.jsonc declares queues.producers[] binding "${o}" but no defineQueue export declares it — a leftover from a rename. Remove it if it is not hand-wired.`]})]},ke=(e,n)=>[..._e(e,n),...xe(e,n)],Q=[{keys:["STRIPE_SECRET_KEY","STRIPE_WEBHOOK_SECRET"],label:"Stripe"},{keys:["POLAR_ACCESS_TOKEN","POLAR_WEBHOOK_SECRET"],label:"Polar"},{keys:["CREEM_API_KEY","CREEM_WEBHOOK_SECRET"],label:"Creem"},{keys:["AUTUMN_SECRET_KEY","AUTUMN_WEBHOOK_SECRET"],label:"Autumn"},{keys:["DODO_PAYMENTS_API_KEY","DODO_PAYMENTS_WEBHOOK_KEY"],label:"Dodo Payments"}],Se=()=>Q.map(({keys:e,label:n})=>`${e[0]} + ${e[1]} (${n})`).join(" or "),Oe=e=>{let n;try{n=W(M(e,se),"utf8")}catch{return!1}const s=new Map(te(n).map(t=>[t.key,t.value]));return Q.some(({keys:t})=>t.every(r=>(s.get(r)??"")!==""))},Ne=(e,n)=>{const s=n?.secrets?.required;if(!Array.isArray(s))return[];const t=new Set(s),r=re(oe(e)).map(o=>o.key).filter(o=>!t.has(o));return r.length===0?[]:[`wrangler.jsonc declares secrets.required without ${r.join(", ")}, which this app needs — wrangler dev loads only the listed keys from .dev.vars, so add ${r.length===1?"it":"them"} to secrets.required.`]},D=(e,n,s)=>{const t=new Set(e.durableObjects.map(u=>u.className)),r=[],o=(s?.r2_buckets?.length??0)>0,l=(s?.d1_databases?.some(u=>u.binding==="DB")??!1)||e.needsD1;return e.usesStorage&&!o&&r.push("@lunora/storage is used but R2 bucket bindings have user-defined names; add an r2_buckets entry and pass env.<BINDING> to createStorage()."),e.usesAuth&&!t.has("SessionDO")&&!l&&r.push("@lunora/auth is used but the worker entry exports no SessionDO; sessions are D1-backed, or export SessionDO to enable DO-backed sessions."),e.usesScheduler&&!t.has("SchedulerDO")&&r.push("@lunora/scheduler is used but the worker entry exports no SchedulerDO; export it so the SCHEDULER binding can be provisioned."),r.push(...C("container","containers",e.containers),...C("workflow","workflows",e.workflows),...C("agent","agents",e.agents)),e.containers.length>0&&s?.observability?.enabled===!1&&r.push("containers are declared but observability is explicitly disabled in wrangler.jsonc — container logs will not be captured."),e.usesPayment&&!Oe(n)&&r.push(`@lunora/payment is used; set one provider's secret pair in .dev.vars — ${Se()}.`),r.push(...ye(e),...we(e,s),...Ne(e,s)),s!==void 0&&r.push(...ke(e,s)),r},F="<replace-with-d1-create-id>",Ee=e=>[["container","containers",e.containers],["workflow","workflows",e.workflows],["agent","agents",e.agents]].flatMap(([s,t,r])=>r.filter(o=>!o.exported).map(({className:o,exportName:l})=>({className:o,exportName:l,kind:s,module:t}))),$e=e=>{const n=new Set(I(e).map(t=>t.tag));let s=1;for(;n.has(`v${String(s)}`);)s+=1;return`v${String(s)}`},qe=e=>{const n=new Set;for(const s of I(e)){for(const t of j(s.deleted_classes))n.delete(t);for(const{from:t,to:r}of I(s.renamed_classes))t!==void 0&&n.delete(t),r!==void 0&&n.add(r);for(const t of[...j(s.new_classes),...j(s.new_sqlite_classes)])n.add(t)}return n},je=(e,n,s)=>{const t=n.durable_objects?.bindings??[],r=new Set(t.map(d=>d.name)),o=s.filter(d=>!r.has(d.binding));let l=e;const u=[];if(o.length>0){const d=[...t,...o.map(p=>({class_name:p.className,name:p.binding}))];l=x(l,["durable_objects","bindings"],d),u.push(...o.map(p=>`${p.binding}/${p.className}`))}const h=n.migrations??[],a=s.map(d=>d.className).filter(d=>!qe(h).has(d));if(a.length>0){const d=[...h,{new_sqlite_classes:a,tag:$e(h)}];l=x(l,["migrations"],d)}return{added:u,text:l}},Ae=(e,n)=>{const s=n.d1_databases??[];if(s.some(o=>o.binding==="DB"))return{added:[],text:e};const t=typeof n.name=="string"&&n.name.length>0?n.name:"lunora",r=[...s,{binding:"DB",database_id:F,database_name:t}];return{added:["DB (D1)"],text:x(e,["d1_databases"],r)}},T=(e,n,s,t,r)=>{const o=n[s]?.binding;return typeof o=="string"&&o.length>0?{added:[],text:e}:{added:[r],text:x(e,[s],{binding:t})}},Ce=(e,n)=>(n.analytics_engine_datasets?.length??0)>0?{added:[],text:e}:{added:["ANALYTICS (Analytics Engine)"],text:x(e,["analytics_engine_datasets"],[{binding:"ANALYTICS",dataset:"ANALYTICS"}])},De=(e,n)=>{const s=n.worker_loaders??[];return s.some(t=>t.binding==="LOADER")?{added:[],text:e}:{added:["LOADER (Worker Loader)"],text:x(e,["worker_loaders"],[...s,{binding:"LOADER"}])}},Te=e=>{if(typeof e=="string")return e;const n={};return e.diskMb!==void 0&&(n.disk_mb=e.diskMb),e.memoryMib!==void 0&&(n.memory_mib=e.memoryMib),e.vcpu!==void 0&&(n.vcpu=e.vcpu),n},Ie=e=>{const{image:n}=e;return n.kind==="dockerfile"?n.dockerfilePath:n.kind==="registry"?n.reference:H(e.exportName)},U=e=>{const n={};for(const[s,t]of Object.entries(e.images??{}))n[s]=t.kind==="registry"?{image:t.reference}:{build_context:t.buildContext,dockerfile:t.dockerfilePath,...e.buildArgs===void 0?{}:{build_vars:e.buildArgs}};return{class_name:e.className,scheduling_policy:"durable_object",...Object.keys(n).length>0?{images:n}:{},...e.name===void 0?{}:{name:e.name}}},Pe=e=>{if(e.schedulingPolicy==="durable_object")return U(e);const{image:n}=e,s={class_name:e.className,image:Ie(e)};return n.kind==="dockerfile"&&(s.image_build_context=n.buildContext),e.buildArgs!==void 0&&n.kind!=="registry"&&(s.image_vars=e.buildArgs),e.instanceType!==void 0&&(s.instance_type=Te(e.instanceType)),e.maxInstances!==void 0&&(s.max_instances=e.maxInstances),e.name!==void 0&&(s.name=e.name),e.rollout?.stepPercentage!==void 0&&(s.rollout_step_percentage=e.rollout.stepPercentage),e.rollout?.gracePeriodSeconds!==void 0&&(s.rollout_active_grace_period=e.rollout.gracePeriodSeconds),s},Be=(e,n,s)=>{const t=n.containers??[],r=new Set(t.map(a=>a.class_name)),o=s.filter(a=>!r.has(a.className));let l=o.length===0?e:x(e,["containers"],[...t,...o.map(a=>Pe(a))]);const u=[],h=[];for(const[a,d]of t.entries()){const p=s.find(g=>g.className===d.class_name);if(p===void 0)continue;const c=p.schedulingPolicy??"default";if((d.scheduling_policy??"default")!==c){h.push(`containers/${p.className} has scheduling_policy "${d.scheduling_policy??"default"}" in wrangler.jsonc but defineContainer "${p.exportName}" declares "${c}" — the policy is immutable, so replace the entry (and its container application) by hand.`);continue}const v=p.schedulingPolicy==="durable_object"?U(p).images:void 0;v!==void 0&&JSON.stringify(d.images)!==JSON.stringify(v)&&(l=x(l,["containers",a,"images"],v),u.push(`containers/${p.className}.images`))}return{added:o.map(a=>`containers/${a.className}`),text:l,updated:u,warnings:h}},Re=(e,n)=>{if(n.observability!==void 0)return{added:[],text:e};const s=x(e,["observability"],{enabled:!0,head_sampling_rate:1});return{added:["observability"],text:s}},We=[{minimum:[4,142],name:"wrangler"},{minimum:[1,61],name:"@cloudflare/vite-plugin"}],Me=(e,n)=>{try{const s=G(M(e,"package.json")).resolve(`${n}/package.json`),[t=0,r=0]=String(JSON.parse(W(s,"utf8")).version).split(".").map(Number);return[t,r]}catch{return}},Le=e=>{const n=We.flatMap(({minimum:s,name:t})=>{const r=Me(e,t);return r!==void 0&&(r[0]<s[0]||r[0]===s[0]&&r[1]<s[1])?[`${t} ${r.join(".")} (needs >= ${s.join(".")})`]:[]});return n.length===0?void 0:`workflows are declared in wrangler \`exports\`, which ${n.join(" and ")} cannot run — reconcile left workflows[] untouched. Upgrade (\`pnpm add -D wrangler@^4.143.1 @cloudflare/vite-plugin@^1.62.1\`) and re-run.`},Ke=e=>Object.entries(e.env??{}).flatMap(([n,s])=>Array.isArray(s?.workflows)?[`env.${n}.workflows declares workflow bindings, but Lunora now declares workflows in \`exports\` and resolves them on ctx.exports — move them to that environment's own \`exports\` by hand.`]:[]),Qe=(e,n,s)=>{let t=e;const r=[],o=[];for(const l of s){const u=n[l.className];if(u?.type==="workflow")for(const{of:h,path:a}of de){const d=h(l),p=L(u,a),c=`exports/${l.className}.${a.join(".")}`;if(d===void 0){p!==void 0&&o.push(`${c} is set in wrangler.jsonc but defineWorkflow "${l.exportName}" does not declare it — reconcile leaves it in place. Remove it by hand if it was dropped from the definition.`);continue}JSON.stringify(p)!==JSON.stringify(d)&&(t=x(t,["exports",l.className,...a],d),r.push(c))}}return{text:t,updated:r,warnings:o}},Fe=(e,n,s,t,r)=>{if(r!==void 0)return{added:[],text:e,warnings:[r]};const o=[...s.map(m=>({settings:ie(m),workflow:m})),...t.map(m=>({settings:{},workflow:m}))],l=new Set(o.map(({workflow:m})=>m.className)),u=n.workflows??[],h=u.filter(m=>m.script_name===void 0&&m.class_name!==void 0&&l.has(m.class_name)),a=n.exports??{},d=[],p=[],c=[];let v=e;for(const{settings:m,workflow:b}of o){if(a[b.className]!==void 0&&a[b.className]!==null)continue;const w=h.find(f=>f.class_name===b.className),k=Object.fromEntries(ae.flatMap(f=>{const _=L(w,[f]);return _===void 0?[]:[[f,_]]})),S=w?.name??b.name;w?.name!==void 0&&w.name!==b.name&&c.push(`workflows/${b.className} is deployed as "${w.name}" but declared as "${b.name}" — its export keeps "${w.name}" so running instances survive. Change the declaration to match, or rename deliberately (it starts a new, empty workflow).`),v=x(v,["exports",b.className],{type:"workflow",...k,...m,name:S}),(w===void 0?d:p).push(`exports/${b.className}`)}if(h.length>0){const m=u.filter(b=>!h.includes(b));v=x(v,["workflows"],m.length===0?void 0:m),p.push(...h.map(b=>`workflows/${String(b.class_name)} → exports`))}c.push(...Ke(n));const g=Qe(v,a,s);return{added:d,text:g.text,updated:[...p,...g.updated],warnings:[...c,...g.warnings]}},on=(e,n,s)=>{const t=ce(e),r=Ee(n);if(!t)return{added:[],changed:!1,exportGaps:r,reason:"wrangler.jsonc not found",updated:[],warnings:D(n,e)};const{parsed:o,text:l}=le(t);if(o===void 0)return{added:[],changed:!1,exportGaps:r,reason:`failed to parse ${t} as JSONC`,updated:[],warnings:D(n,e),wranglerPath:t};const u=D(n,e,o);if(s!==void 0){const i=o.env?.[s]!==void 0;u.push(i?`auto-provisioned bindings are written to the top level of wrangler.jsonc only (queue consumers "env.${s}" already declares are retuned, nothing is added) — "env.${s}" has its own (non-inheritable) bindings and must be reconciled by hand; \`lunora deploy --env ${s}\` now validates them, so a gap here will be reported at deploy time.`:`--env "${s}" was requested but wrangler.jsonc declares no "env.${s}" block — auto-provisioned bindings are written to the top level only and will not apply to that environment.`)}const h=n.containers.filter(i=>i.exported),a=n.agents.filter(i=>i.exported&&i.voice===!0&&i.voiceBindingName!==void 0&&i.voiceClassName!==void 0),d=[...n.durableObjects,...h.map(i=>({binding:i.bindingName,className:i.className})),...a.map(i=>({binding:i.voiceBindingName,className:i.voiceClassName}))],p=n.workflows.filter(i=>i.exported),c=n.agents.filter(i=>i.exported),v=R(e),g=be(v,u),m={},b=z(v);let w;const k=[{enabled:!0,run:i=>je(i,o,d)},{enabled:n.needsD1,run:i=>Ae(i,o)},{enabled:n.usesAi,run:i=>T(i,o,"ai","AI","AI (Workers AI)")},{enabled:n.usesBrowser,run:i=>T(i,o,"browser","BROWSER","BROWSER (Browser Rendering)")},{enabled:n.usesImages,run:i=>T(i,o,"images","IMAGES","IMAGES (Cloudflare Images)")},{enabled:n.usesAnalytics,run:i=>Ce(i,o)},{enabled:n.usesWorkerLoader,run:i=>De(i,o)},{enabled:!0,run:i=>Re(i,o)},{enabled:h.length>0,run:i=>Be(i,o,h)},{enabled:p.length>0||c.length>0,run:i=>Fe(i,o,p,c,Le(e))},{enabled:n.queues.length>0,run:i=>{const y=fe(i,o,n.queues,g.queues??{});return m.queues=y.owned,y}},{enabled:n.services!==void 0&&(n.services.length>0||Object.keys(b).length>0),run:i=>{const y=Z(i,o,n.services??[],b);return w=y.owned,y}},...s===void 0||o.env?.[s]===void 0?[]:[{enabled:n.queues.length>0,run:i=>{const y=`env.${s}.queues`,E=he(i,o,n.queues,s,g[y]??{});return m[y]=E.owned,E}}]];let S=l;const f=[],_=[];for(const i of k){if(!i.enabled)continue;const y=i.run(S);S=y.text,f.push(...y.added),_.push(...y.updated??[]),u.push(...y.warnings??[])}const N=i=>{if(v===void 0)return;const y=w,E=[...Object.keys(m).length>0?[{consequence:"an option removed from defineQueue stays deployed",key:"queueTuning",label:"queue tuning",write:O=>{ve(O,g,m)}}]:[],...y===void 0?[]:[{consequence:"a service removed from lunora.config stays bound",key:"services",label:"service bindings",write:O=>{ne(O,y)}}]];for(const O of E)try{O.write(R(e)??v)}catch(q){u.push(`${i?"wrangler.jsonc was updated, but ":""}recording the ${O.label} reconcile owns in ${v.path} (lunora.${O.key}) failed: ${q instanceof Error?q.message:String(q)}. Until it is recorded, ${O.consequence}.`)}};let $;if(n.services!==void 0){const i=ee(e,n.services,b);u.push(...i.warnings),w={...w,...i.owned},$=i.added.length>0||i.updated.length>0?{added:i.added,path:i.path,updated:i.updated}:void 0}return f.includes("DB (D1)")&&u.push(`wrote a DB binding with a placeholder database_id ("${F}") — run \`wrangler d1 create <name>\` and replace it before deploying.`),S===l?(N(!1),{added:f,changed:!1,devConfig:$,exportGaps:r,reason:"bindings already in sync",updated:_,warnings:u,wranglerPath:t}):(Y(t,S,"utf8"),N(!0),{added:f,changed:!0,devConfig:$,exportGaps:r,updated:_,warnings:u,wranglerPath:t})};export{Ee as collectExportGaps,on as reconcileWranglerBindings};
|