@lunora/config 1.0.0-alpha.334 → 1.0.0-alpha.336
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 +56 -38
- package/dist/cloudflare/index.d.ts +56 -38
- package/dist/cloudflare/index.mjs +1 -1
- package/dist/packem_shared/REMOTE_ELIGIBLE_KEYS-PLeh_74E.mjs +1 -0
- package/dist/packem_shared/{collectExportGaps-tpw0w4Oo.mjs → collectExportGaps-BVb5JlSY.mjs} +1 -1
- package/dist/packem_shared/describeWithheldWorkersAi-IIxe3TuI.mjs +1 -0
- package/dist/packem_shared/hasCloudflareCredentials-byvHpEiD.mjs +1 -0
- package/dist/packem_shared/materializeServiceDevConfigs-DLUHefD-.mjs +1 -0
- package/dist/packem_shared/reconcileBindingsSafely-Cj6LlUTQ.mjs +1 -0
- package/package.json +3 -3
- package/dist/packem_shared/REMOTE_ELIGIBLE_KEYS-BrOO_a0V.mjs +0 -1
- package/dist/packem_shared/materializeServiceDevConfigs-KfEZ8o__.mjs +0 -1
- package/dist/packem_shared/reconcileBindingsSafely-JHQWlbHM.mjs +0 -1
|
@@ -321,6 +321,25 @@ declare const CLOUDFLARE_DRIVER: DeployDriver;
|
|
|
321
321
|
* without it, and `lunora doctor` checks for it wherever that transport is imported.
|
|
322
322
|
*/
|
|
323
323
|
declare const GLOBAL_FETCH_STRICTLY_PUBLIC_FLAG = "global_fetch_strictly_public";
|
|
324
|
+
/** Inputs, injectable so tests never read the real home directory or env. */
|
|
325
|
+
interface CloudflareCredentialProbe {
|
|
326
|
+
env?: Record<string, string | undefined>;
|
|
327
|
+
home?: string;
|
|
328
|
+
/** Project whose `.env` files are read; omit to skip them. */
|
|
329
|
+
projectRoot?: string;
|
|
330
|
+
}
|
|
331
|
+
declare const hasCloudflareCredentials: (probe?: CloudflareCredentialProbe) => boolean;
|
|
332
|
+
/** Which kind of temp config a file is, in its name. */
|
|
333
|
+
type DevConfigKind = "dev" | "service";
|
|
334
|
+
/**
|
|
335
|
+
* The binding name to withhold from a logged-out dev session, or `undefined` to keep
|
|
336
|
+
* it. The credential probe runs only when an `ai` binding is declared at all.
|
|
337
|
+
*/
|
|
338
|
+
declare const withheldWorkersAi: (ai: {
|
|
339
|
+
binding?: string;
|
|
340
|
+
} | null | undefined, hasCredentials: () => boolean) => string | undefined;
|
|
341
|
+
/** The one dev warning for a withheld Workers AI binding, shared by `lunora dev` and `@lunora/vite`. */
|
|
342
|
+
declare const describeWithheldWorkersAi: (binding: string) => string;
|
|
324
343
|
/**
|
|
325
344
|
* A container/workflow that is declared (so codegen emits its class) but the
|
|
326
345
|
* worker entry never re-exports — the one wiring step the generators can't always
|
|
@@ -404,7 +423,10 @@ declare const collectExportGaps: (inferred: InferredBindings) => ExportGap[];
|
|
|
404
423
|
* attempt — `lunora deploy --env <name>` now VALIDATES the env-scoped view
|
|
405
424
|
* (closing the reported gap), it just doesn't yet auto-provision it.
|
|
406
425
|
*/
|
|
407
|
-
declare const reconcileWranglerBindings: (projectRoot: string, inferred: InferredBindings, environment
|
|
426
|
+
declare const reconcileWranglerBindings: (projectRoot: string, inferred: InferredBindings, { environment, target }?: {
|
|
427
|
+
environment?: string;
|
|
428
|
+
target?: string;
|
|
429
|
+
}) => ReconcileBindingsResult;
|
|
408
430
|
interface ReconcileCompatibilityDateResult {
|
|
409
431
|
/** `true` when `wrangler.jsonc` was rewritten. */
|
|
410
432
|
changed: boolean;
|
|
@@ -652,48 +674,37 @@ declare const planRemoteBindings: (parsed: RemoteWranglerShape) => RemoteBinding
|
|
|
652
674
|
* `queues.producers[i]` entry, or the single `ai` object as the plan demands.
|
|
653
675
|
*/
|
|
654
676
|
declare const injectRemoteFlags: (text: string, plans: ReadonlyArray<RemoteBindingPlan>) => string;
|
|
655
|
-
interface
|
|
656
|
-
/**
|
|
657
|
-
|
|
677
|
+
interface MaterializeDevOptions {
|
|
678
|
+
/** Whether wrangler can authenticate; defaults to a probe of `projectRoot`. */
|
|
679
|
+
hasCredentials?: () => boolean;
|
|
658
680
|
projectRoot: string;
|
|
681
|
+
/** Proxy the eligible bindings to the deployed resources (`--remote` / `LUNORA_REMOTE`). Off, only the logged-out `ai` withholding applies. */
|
|
682
|
+
remote: boolean;
|
|
659
683
|
}
|
|
660
|
-
interface
|
|
661
|
-
/**
|
|
662
|
-
* Removes the generated temp config file. Always present and always safe to
|
|
663
|
-
* call: it is idempotent, a no-op when nothing was written (disabled /
|
|
664
|
-
* fall-through cases), and never throws if the path is already gone. The dev
|
|
665
|
-
* command calls this on every exit path (normal, signal, error).
|
|
666
|
-
*/
|
|
684
|
+
interface MaterializeDevResult {
|
|
685
|
+
/** Removes the temp config. Always safe to call: idempotent, and a no-op when nothing was written. */
|
|
667
686
|
cleanup: () => void;
|
|
668
|
-
/**
|
|
669
|
-
* Absolute path to the generated temp config to pass to
|
|
670
|
-
* `wrangler dev --config`. `undefined` when remote mode is disabled, no
|
|
671
|
-
* wrangler config was found, it failed to parse, or it declared no eligible
|
|
672
|
-
* binding (nothing to remote — run plain local dev).
|
|
673
|
-
*/
|
|
687
|
+
/** The temp config to pass to `wrangler dev --config`, or `undefined` to run the user's file unchanged. */
|
|
674
688
|
configPath?: string;
|
|
675
|
-
/**
|
|
676
|
-
enabled: boolean;
|
|
677
|
-
/** Why no temp config was produced, for logging (only set when none was). */
|
|
689
|
+
/** Why remote mode produced no temp config, for the dev log. Only set when nothing was written. */
|
|
678
690
|
reason?: string;
|
|
679
691
|
/** The bindings flipped to remote, for the dev banner. */
|
|
680
692
|
remoteBindings: RemoteBindingPlan[];
|
|
693
|
+
/** The `ai` binding name left out for lack of Cloudflare credentials, for the dev warning. */
|
|
694
|
+
withheld: string[];
|
|
681
695
|
}
|
|
682
696
|
/**
|
|
683
|
-
*
|
|
684
|
-
*
|
|
685
|
-
*
|
|
697
|
+
* Write the temp wrangler config a dev session runs with: the user's file with any
|
|
698
|
+
* eligible bindings flipped to `"remote": true` (when `remote` is set), and the
|
|
699
|
+
* `ai` binding removed when the session has no Cloudflare login. See `dev-config.ts`
|
|
700
|
+
* for why the `ai` removal exists.
|
|
686
701
|
*
|
|
687
|
-
* The temp file
|
|
688
|
-
*
|
|
689
|
-
*
|
|
690
|
-
*
|
|
691
|
-
* `/tmp/src/server.ts` and fail to start the worker. Keeping it beside the real
|
|
692
|
-
* config preserves those relative paths. Returns `configPath: undefined` (with a
|
|
693
|
-
* `reason`) for every fall-through case so the caller degrades to plain local
|
|
694
|
-
* dev instead of failing.
|
|
702
|
+
* The temp file sits beside the source `wrangler.jsonc`, not in an OS temp dir,
|
|
703
|
+
* because wrangler resolves a config's relative `main`/`assets`/`migrations_dir`
|
|
704
|
+
* paths against the config file's own directory. Returns no `configPath` when there
|
|
705
|
+
* is nothing to change, so the caller runs the user's file unchanged.
|
|
695
706
|
*/
|
|
696
|
-
declare const
|
|
707
|
+
declare const materializeDevWranglerConfig: (options: MaterializeDevOptions) => MaterializeDevResult;
|
|
697
708
|
/**
|
|
698
709
|
* Parse a `LUNORA_REMOTE` env value into the on/off decision. Truthy when set to
|
|
699
710
|
* `"1"` or `"true"` (case-insensitive); anything else — unset, `"0"`, `"false"`,
|
|
@@ -726,18 +737,25 @@ interface RemoteEnableInputs {
|
|
|
726
737
|
* is still overridable per-run by `--remote` or `LUNORA_REMOTE=1`.
|
|
727
738
|
*/
|
|
728
739
|
declare const resolveRemoteEnabled: (inputs: RemoteEnableInputs) => boolean;
|
|
729
|
-
/** The configs to pass as `--config`, in input order, and
|
|
740
|
+
/** The configs to pass as `--config`, in input order, and what was done to them. */
|
|
730
741
|
interface ServiceDevConfigs {
|
|
731
742
|
/** Unlinks every copy written. Idempotent, never throws — a no-op when none was. */
|
|
732
743
|
cleanup: () => void;
|
|
733
744
|
configPaths: string[];
|
|
745
|
+
/** The `ai` binding names left out of a service copy for lack of Cloudflare credentials, for the dev warning. */
|
|
746
|
+
withheld: string[];
|
|
747
|
+
}
|
|
748
|
+
interface ServiceMaterializeOptions {
|
|
749
|
+
/** Whether wrangler can authenticate; defaults to a probe of `projectRoot`. */
|
|
750
|
+
hasCredentials?: () => boolean;
|
|
751
|
+
/** The app's folder, where `wrangler dev` runs and whose `.env` files it reads. */
|
|
752
|
+
projectRoot: string;
|
|
734
753
|
}
|
|
735
754
|
/**
|
|
736
755
|
* Resolve the `--config` path of each service the shared `wrangler dev` session
|
|
737
|
-
* runs, writing a copy only for a service
|
|
738
|
-
* in the app's folder (see the module doc).
|
|
756
|
+
* runs, writing a copy only for a service that needs one (see the module doc).
|
|
739
757
|
*/
|
|
740
|
-
declare const materializeServiceDevConfigs: (wranglerPaths: ReadonlyArray<string
|
|
758
|
+
declare const materializeServiceDevConfigs: (wranglerPaths: ReadonlyArray<string>, options: ServiceMaterializeOptions) => ServiceDevConfigs;
|
|
741
759
|
/**
|
|
742
760
|
* The Cloudflare toolchain ranges a scaffolded Lunora app declares — the one
|
|
743
761
|
* source for `lunora init`'s overlay. The `templates/*` starters are fetched at
|
|
@@ -1215,7 +1233,7 @@ declare const validateWranglerConfig: (wranglerInput: WranglerConfig | undefined
|
|
|
1215
1233
|
* `{ valid, errors, warnings }`.
|
|
1216
1234
|
*/
|
|
1217
1235
|
declare const validateWrangler: typeof validateWranglerConfig;
|
|
1218
|
-
export { type AlchemyTranslation, type AssertWranglerOptions, BINDING_MANIFEST_VERSION, type BindingManifest, type BindingRequirement, CLOUDFLARE_CLI_CONFIG_WARNING_ENV, CLOUDFLARE_DRIVER, CLOUDFLARE_TOOLCHAIN_VERSIONS, type CloudflareCliConfigFinding, DEFAULT_OBSERVABILITY, type ExportGap, GLOBAL_FETCH_STRICTLY_PUBLIC_FLAG, type ManifestConfigShape, type
|
|
1236
|
+
export { type AlchemyTranslation, type AssertWranglerOptions, BINDING_MANIFEST_VERSION, type BindingManifest, type BindingRequirement, CLOUDFLARE_CLI_CONFIG_WARNING_ENV, CLOUDFLARE_DRIVER, CLOUDFLARE_TOOLCHAIN_VERSIONS, type CloudflareCliConfigFinding, type CloudflareCredentialProbe, DEFAULT_OBSERVABILITY, type DevConfigKind, type ExportGap, GLOBAL_FETCH_STRICTLY_PUBLIC_FLAG, type ManifestConfigShape, type MaterializeDevOptions, type MaterializeDevResult, type ObservabilitySignalSampling, REMOTE_ELIGIBLE_KEYS, REQUIRED_COMPATIBILITY_DATE, REQUIRED_FLAG, type ReadWranglerResult, type ReconcileBindingsResult, type ReconcileCompatibilityDateResult, type ReconcileResult as ReconcileCronsResult, type ReconcileProject, type RemoteBindingPlan, type RemoteEnableInputs, type RemoteWranglerShape, type ServiceDevConfigs, type TailConsumer, UNEXPORTED_CLASS_MARKER, WORKERS_CACHE_MIN_DATE, WRANGLER_FILES, type WranglerCacheShape, type WranglerCodegenInputs, type WranglerConfig, type WranglerConfigShape, type WranglerContainerEntry, type WranglerEnvironmentMerge, type WranglerObservability, type WranglerObservabilityLogs, type WranglerObservabilityTraces, type WranglerProjectValidationOptions, type WranglerProjectValidationResult, type WranglerValidationReport, type WranglerWorkflowEntry,
|
|
1219
1237
|
/**
|
|
1220
1238
|
* `@lunora/config/cloudflare` — the wrangler layer.
|
|
1221
1239
|
*
|
|
@@ -1231,4 +1249,4 @@ export { type AlchemyTranslation, type AssertWranglerOptions, BINDING_MANIFEST_V
|
|
|
1231
1249
|
* Plan 114 §5.3 (D6): a package carrying real provider code isolates it behind a
|
|
1232
1250
|
* subpath rather than relocating wholesale.
|
|
1233
1251
|
*/
|
|
1234
|
-
applyModify, assertWranglerSatisfiesSchema, buildBindingManifest, collectExportGaps, describePreservedCrons, detectCloudflareCliConfig, findWranglerFile, injectRemoteFlags, isCacheEnabled, isRemoteEnvEnabled,
|
|
1252
|
+
applyModify, assertWranglerSatisfiesSchema, buildBindingManifest, collectExportGaps, describePreservedCrons, describeWithheldWorkersAi, detectCloudflareCliConfig, findWranglerFile, hasCloudflareCredentials, injectRemoteFlags, isCacheEnabled, isRemoteEnvEnabled, materializeDevWranglerConfig, materializeServiceDevConfigs, mergeWranglerEnvironment, planRemoteBindings, readWranglerJsonc, reconcileBindingsSafely, reconcileWranglerBindings, reconcileWranglerCompatibilityDate, reconcileWranglerCrons, reconcileWranglerExtras, resolveObservabilitySampling, resolveRemoteEnabled, scanWranglerVariablesForSecrets, validateWrangler, validateWranglerConfig, validateWranglerProject, warnCloudflareCliConfigOnce, withTailConsumer, withheldWorkersAi, wranglerCodegenInputs, wranglerToAlchemy };
|
|
@@ -321,6 +321,25 @@ declare const CLOUDFLARE_DRIVER: DeployDriver;
|
|
|
321
321
|
* without it, and `lunora doctor` checks for it wherever that transport is imported.
|
|
322
322
|
*/
|
|
323
323
|
declare const GLOBAL_FETCH_STRICTLY_PUBLIC_FLAG = "global_fetch_strictly_public";
|
|
324
|
+
/** Inputs, injectable so tests never read the real home directory or env. */
|
|
325
|
+
interface CloudflareCredentialProbe {
|
|
326
|
+
env?: Record<string, string | undefined>;
|
|
327
|
+
home?: string;
|
|
328
|
+
/** Project whose `.env` files are read; omit to skip them. */
|
|
329
|
+
projectRoot?: string;
|
|
330
|
+
}
|
|
331
|
+
declare const hasCloudflareCredentials: (probe?: CloudflareCredentialProbe) => boolean;
|
|
332
|
+
/** Which kind of temp config a file is, in its name. */
|
|
333
|
+
type DevConfigKind = "dev" | "service";
|
|
334
|
+
/**
|
|
335
|
+
* The binding name to withhold from a logged-out dev session, or `undefined` to keep
|
|
336
|
+
* it. The credential probe runs only when an `ai` binding is declared at all.
|
|
337
|
+
*/
|
|
338
|
+
declare const withheldWorkersAi: (ai: {
|
|
339
|
+
binding?: string;
|
|
340
|
+
} | null | undefined, hasCredentials: () => boolean) => string | undefined;
|
|
341
|
+
/** The one dev warning for a withheld Workers AI binding, shared by `lunora dev` and `@lunora/vite`. */
|
|
342
|
+
declare const describeWithheldWorkersAi: (binding: string) => string;
|
|
324
343
|
/**
|
|
325
344
|
* A container/workflow that is declared (so codegen emits its class) but the
|
|
326
345
|
* worker entry never re-exports — the one wiring step the generators can't always
|
|
@@ -404,7 +423,10 @@ declare const collectExportGaps: (inferred: InferredBindings) => ExportGap[];
|
|
|
404
423
|
* attempt — `lunora deploy --env <name>` now VALIDATES the env-scoped view
|
|
405
424
|
* (closing the reported gap), it just doesn't yet auto-provision it.
|
|
406
425
|
*/
|
|
407
|
-
declare const reconcileWranglerBindings: (projectRoot: string, inferred: InferredBindings, environment
|
|
426
|
+
declare const reconcileWranglerBindings: (projectRoot: string, inferred: InferredBindings, { environment, target }?: {
|
|
427
|
+
environment?: string;
|
|
428
|
+
target?: string;
|
|
429
|
+
}) => ReconcileBindingsResult;
|
|
408
430
|
interface ReconcileCompatibilityDateResult {
|
|
409
431
|
/** `true` when `wrangler.jsonc` was rewritten. */
|
|
410
432
|
changed: boolean;
|
|
@@ -652,48 +674,37 @@ declare const planRemoteBindings: (parsed: RemoteWranglerShape) => RemoteBinding
|
|
|
652
674
|
* `queues.producers[i]` entry, or the single `ai` object as the plan demands.
|
|
653
675
|
*/
|
|
654
676
|
declare const injectRemoteFlags: (text: string, plans: ReadonlyArray<RemoteBindingPlan>) => string;
|
|
655
|
-
interface
|
|
656
|
-
/**
|
|
657
|
-
|
|
677
|
+
interface MaterializeDevOptions {
|
|
678
|
+
/** Whether wrangler can authenticate; defaults to a probe of `projectRoot`. */
|
|
679
|
+
hasCredentials?: () => boolean;
|
|
658
680
|
projectRoot: string;
|
|
681
|
+
/** Proxy the eligible bindings to the deployed resources (`--remote` / `LUNORA_REMOTE`). Off, only the logged-out `ai` withholding applies. */
|
|
682
|
+
remote: boolean;
|
|
659
683
|
}
|
|
660
|
-
interface
|
|
661
|
-
/**
|
|
662
|
-
* Removes the generated temp config file. Always present and always safe to
|
|
663
|
-
* call: it is idempotent, a no-op when nothing was written (disabled /
|
|
664
|
-
* fall-through cases), and never throws if the path is already gone. The dev
|
|
665
|
-
* command calls this on every exit path (normal, signal, error).
|
|
666
|
-
*/
|
|
684
|
+
interface MaterializeDevResult {
|
|
685
|
+
/** Removes the temp config. Always safe to call: idempotent, and a no-op when nothing was written. */
|
|
667
686
|
cleanup: () => void;
|
|
668
|
-
/**
|
|
669
|
-
* Absolute path to the generated temp config to pass to
|
|
670
|
-
* `wrangler dev --config`. `undefined` when remote mode is disabled, no
|
|
671
|
-
* wrangler config was found, it failed to parse, or it declared no eligible
|
|
672
|
-
* binding (nothing to remote — run plain local dev).
|
|
673
|
-
*/
|
|
687
|
+
/** The temp config to pass to `wrangler dev --config`, or `undefined` to run the user's file unchanged. */
|
|
674
688
|
configPath?: string;
|
|
675
|
-
/**
|
|
676
|
-
enabled: boolean;
|
|
677
|
-
/** Why no temp config was produced, for logging (only set when none was). */
|
|
689
|
+
/** Why remote mode produced no temp config, for the dev log. Only set when nothing was written. */
|
|
678
690
|
reason?: string;
|
|
679
691
|
/** The bindings flipped to remote, for the dev banner. */
|
|
680
692
|
remoteBindings: RemoteBindingPlan[];
|
|
693
|
+
/** The `ai` binding name left out for lack of Cloudflare credentials, for the dev warning. */
|
|
694
|
+
withheld: string[];
|
|
681
695
|
}
|
|
682
696
|
/**
|
|
683
|
-
*
|
|
684
|
-
*
|
|
685
|
-
*
|
|
697
|
+
* Write the temp wrangler config a dev session runs with: the user's file with any
|
|
698
|
+
* eligible bindings flipped to `"remote": true` (when `remote` is set), and the
|
|
699
|
+
* `ai` binding removed when the session has no Cloudflare login. See `dev-config.ts`
|
|
700
|
+
* for why the `ai` removal exists.
|
|
686
701
|
*
|
|
687
|
-
* The temp file
|
|
688
|
-
*
|
|
689
|
-
*
|
|
690
|
-
*
|
|
691
|
-
* `/tmp/src/server.ts` and fail to start the worker. Keeping it beside the real
|
|
692
|
-
* config preserves those relative paths. Returns `configPath: undefined` (with a
|
|
693
|
-
* `reason`) for every fall-through case so the caller degrades to plain local
|
|
694
|
-
* dev instead of failing.
|
|
702
|
+
* The temp file sits beside the source `wrangler.jsonc`, not in an OS temp dir,
|
|
703
|
+
* because wrangler resolves a config's relative `main`/`assets`/`migrations_dir`
|
|
704
|
+
* paths against the config file's own directory. Returns no `configPath` when there
|
|
705
|
+
* is nothing to change, so the caller runs the user's file unchanged.
|
|
695
706
|
*/
|
|
696
|
-
declare const
|
|
707
|
+
declare const materializeDevWranglerConfig: (options: MaterializeDevOptions) => MaterializeDevResult;
|
|
697
708
|
/**
|
|
698
709
|
* Parse a `LUNORA_REMOTE` env value into the on/off decision. Truthy when set to
|
|
699
710
|
* `"1"` or `"true"` (case-insensitive); anything else — unset, `"0"`, `"false"`,
|
|
@@ -726,18 +737,25 @@ interface RemoteEnableInputs {
|
|
|
726
737
|
* is still overridable per-run by `--remote` or `LUNORA_REMOTE=1`.
|
|
727
738
|
*/
|
|
728
739
|
declare const resolveRemoteEnabled: (inputs: RemoteEnableInputs) => boolean;
|
|
729
|
-
/** The configs to pass as `--config`, in input order, and
|
|
740
|
+
/** The configs to pass as `--config`, in input order, and what was done to them. */
|
|
730
741
|
interface ServiceDevConfigs {
|
|
731
742
|
/** Unlinks every copy written. Idempotent, never throws — a no-op when none was. */
|
|
732
743
|
cleanup: () => void;
|
|
733
744
|
configPaths: string[];
|
|
745
|
+
/** The `ai` binding names left out of a service copy for lack of Cloudflare credentials, for the dev warning. */
|
|
746
|
+
withheld: string[];
|
|
747
|
+
}
|
|
748
|
+
interface ServiceMaterializeOptions {
|
|
749
|
+
/** Whether wrangler can authenticate; defaults to a probe of `projectRoot`. */
|
|
750
|
+
hasCredentials?: () => boolean;
|
|
751
|
+
/** The app's folder, where `wrangler dev` runs and whose `.env` files it reads. */
|
|
752
|
+
projectRoot: string;
|
|
734
753
|
}
|
|
735
754
|
/**
|
|
736
755
|
* Resolve the `--config` path of each service the shared `wrangler dev` session
|
|
737
|
-
* runs, writing a copy only for a service
|
|
738
|
-
* in the app's folder (see the module doc).
|
|
756
|
+
* runs, writing a copy only for a service that needs one (see the module doc).
|
|
739
757
|
*/
|
|
740
|
-
declare const materializeServiceDevConfigs: (wranglerPaths: ReadonlyArray<string
|
|
758
|
+
declare const materializeServiceDevConfigs: (wranglerPaths: ReadonlyArray<string>, options: ServiceMaterializeOptions) => ServiceDevConfigs;
|
|
741
759
|
/**
|
|
742
760
|
* The Cloudflare toolchain ranges a scaffolded Lunora app declares — the one
|
|
743
761
|
* source for `lunora init`'s overlay. The `templates/*` starters are fetched at
|
|
@@ -1215,7 +1233,7 @@ declare const validateWranglerConfig: (wranglerInput: WranglerConfig | undefined
|
|
|
1215
1233
|
* `{ valid, errors, warnings }`.
|
|
1216
1234
|
*/
|
|
1217
1235
|
declare const validateWrangler: typeof validateWranglerConfig;
|
|
1218
|
-
export { type AlchemyTranslation, type AssertWranglerOptions, BINDING_MANIFEST_VERSION, type BindingManifest, type BindingRequirement, CLOUDFLARE_CLI_CONFIG_WARNING_ENV, CLOUDFLARE_DRIVER, CLOUDFLARE_TOOLCHAIN_VERSIONS, type CloudflareCliConfigFinding, DEFAULT_OBSERVABILITY, type ExportGap, GLOBAL_FETCH_STRICTLY_PUBLIC_FLAG, type ManifestConfigShape, type
|
|
1236
|
+
export { type AlchemyTranslation, type AssertWranglerOptions, BINDING_MANIFEST_VERSION, type BindingManifest, type BindingRequirement, CLOUDFLARE_CLI_CONFIG_WARNING_ENV, CLOUDFLARE_DRIVER, CLOUDFLARE_TOOLCHAIN_VERSIONS, type CloudflareCliConfigFinding, type CloudflareCredentialProbe, DEFAULT_OBSERVABILITY, type DevConfigKind, type ExportGap, GLOBAL_FETCH_STRICTLY_PUBLIC_FLAG, type ManifestConfigShape, type MaterializeDevOptions, type MaterializeDevResult, type ObservabilitySignalSampling, REMOTE_ELIGIBLE_KEYS, REQUIRED_COMPATIBILITY_DATE, REQUIRED_FLAG, type ReadWranglerResult, type ReconcileBindingsResult, type ReconcileCompatibilityDateResult, type ReconcileResult as ReconcileCronsResult, type ReconcileProject, type RemoteBindingPlan, type RemoteEnableInputs, type RemoteWranglerShape, type ServiceDevConfigs, type TailConsumer, UNEXPORTED_CLASS_MARKER, WORKERS_CACHE_MIN_DATE, WRANGLER_FILES, type WranglerCacheShape, type WranglerCodegenInputs, type WranglerConfig, type WranglerConfigShape, type WranglerContainerEntry, type WranglerEnvironmentMerge, type WranglerObservability, type WranglerObservabilityLogs, type WranglerObservabilityTraces, type WranglerProjectValidationOptions, type WranglerProjectValidationResult, type WranglerValidationReport, type WranglerWorkflowEntry,
|
|
1219
1237
|
/**
|
|
1220
1238
|
* `@lunora/config/cloudflare` — the wrangler layer.
|
|
1221
1239
|
*
|
|
@@ -1231,4 +1249,4 @@ export { type AlchemyTranslation, type AssertWranglerOptions, BINDING_MANIFEST_V
|
|
|
1231
1249
|
* Plan 114 §5.3 (D6): a package carrying real provider code isolates it behind a
|
|
1232
1250
|
* subpath rather than relocating wholesale.
|
|
1233
1251
|
*/
|
|
1234
|
-
applyModify, assertWranglerSatisfiesSchema, buildBindingManifest, collectExportGaps, describePreservedCrons, detectCloudflareCliConfig, findWranglerFile, injectRemoteFlags, isCacheEnabled, isRemoteEnvEnabled,
|
|
1252
|
+
applyModify, assertWranglerSatisfiesSchema, buildBindingManifest, collectExportGaps, describePreservedCrons, describeWithheldWorkersAi, detectCloudflareCliConfig, findWranglerFile, hasCloudflareCredentials, injectRemoteFlags, isCacheEnabled, isRemoteEnvEnabled, materializeDevWranglerConfig, materializeServiceDevConfigs, mergeWranglerEnvironment, planRemoteBindings, readWranglerJsonc, reconcileBindingsSafely, reconcileWranglerBindings, reconcileWranglerCompatibilityDate, reconcileWranglerCrons, reconcileWranglerExtras, resolveObservabilitySampling, resolveRemoteEnabled, scanWranglerVariablesForSecrets, validateWrangler, validateWranglerConfig, validateWranglerProject, warnCloudflareCliConfigOnce, withTailConsumer, withheldWorkersAi, wranglerCodegenInputs, wranglerToAlchemy };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{applyModify as o}from"../packem_shared/applyModify-DKP2l6S9.mjs";import{assertWranglerSatisfiesSchema as
|
|
1
|
+
import{applyModify as o}from"../packem_shared/applyModify-DKP2l6S9.mjs";import{assertWranglerSatisfiesSchema as l}from"../packem_shared/assertWranglerSatisfiesSchema-Dy0WXvP8.mjs";import{BINDING_MANIFEST_VERSION as i,buildBindingManifest as n}from"../packem_shared/BINDING_MANIFEST_VERSION-CfXEYG8e.mjs";import{CLOUDFLARE_CLI_CONFIG_WARNING_ENV as m,detectCloudflareCliConfig as E,warnCloudflareCliConfigOnce as s}from"../packem_shared/CLOUDFLARE_CLI_CONFIG_WARNING_ENV-BKMrOuXV.mjs";import{default as C}from"../packem_shared/CLOUDFLARE_DRIVER-Ci3VIqnk.mjs";import{default as g}from"../packem_shared/GLOBAL_FETCH_STRICTLY_PUBLIC_FLAG-f8CnJha3.mjs";import{hasCloudflareCredentials as R}from"../packem_shared/hasCloudflareCredentials-byvHpEiD.mjs";import{describeWithheldWorkersAi as _,withheldWorkersAi as I}from"../packem_shared/describeWithheldWorkersAi-IIxe3TuI.mjs";import{collectExportGaps as A,reconcileWranglerBindings as W}from"../packem_shared/collectExportGaps-BVb5JlSY.mjs";import{reconcileWranglerCompatibilityDate as O}from"../packem_shared/reconcileWranglerCompatibilityDate-hocXEuRA.mjs";import{describePreservedCrons as D,reconcileWranglerCrons as F}from"../packem_shared/describePreservedCrons-C5KPuPy3.mjs";import{reconcileBindingsSafely as v,reconcileWranglerExtras as B}from"../packem_shared/reconcileBindingsSafely-Cj6LlUTQ.mjs";import{REMOTE_ELIGIBLE_KEYS as h,injectRemoteFlags as u,isRemoteEnvEnabled as G,materializeDevWranglerConfig as U,planRemoteBindings as M,resolveRemoteEnabled as y}from"../packem_shared/REMOTE_ELIGIBLE_KEYS-PLeh_74E.mjs";import{materializeServiceDevConfigs as w}from"../packem_shared/materializeServiceDevConfigs-DLUHefD-.mjs";import{default as Y}from"../packem_shared/CLOUDFLARE_TOOLCHAIN_VERSIONS-DV5E_f_q.mjs";import{withTailConsumer as K}from"../packem_shared/withTailConsumer-DngzpJMK.mjs";import{WORKERS_CACHE_MIN_DATE as k,isCacheEnabled as z}from"../packem_shared/WORKERS_CACHE_MIN_DATE-0k9ABJtF.mjs";import{wranglerCodegenInputs as J}from"../packem_shared/wranglerCodegenInputs-DBtq3faO.mjs";import{DEFAULT_OBSERVABILITY as q,resolveObservabilitySampling as Z}from"../packem_shared/DEFAULT_OBSERVABILITY-bN6UkTMx.mjs";import{mergeWranglerEnvironment as ee}from"../packem_shared/mergeWranglerEnvironment-DXiB-HcS.mjs";import{WRANGLER_FILES as oe,findWranglerFile as ae,readWranglerJsonc as le}from"../packem_shared/WRANGLER_FILES-UNW-xY5u.mjs";import{UNEXPORTED_CLASS_MARKER as ie,validateWranglerProject as ne}from"../packem_shared/UNEXPORTED_CLASS_MARKER-IAK9PiDz.mjs";import{scanWranglerVariablesForSecrets as me}from"../packem_shared/scanWranglerVariablesForSecrets-BF-791aw.mjs";import{wranglerToAlchemy as se}from"../packem_shared/wranglerToAlchemy-CBO2ucRm.mjs";import{REQUIRED_COMPATIBILITY_DATE as Ce,REQUIRED_FLAG as de,validateWrangler as ge,validateWranglerConfig as xe}from"../packem_shared/REQUIRED_COMPATIBILITY_DATE-OLQlG0oj.mjs";export{i as BINDING_MANIFEST_VERSION,m as CLOUDFLARE_CLI_CONFIG_WARNING_ENV,C as CLOUDFLARE_DRIVER,Y as CLOUDFLARE_TOOLCHAIN_VERSIONS,q as DEFAULT_OBSERVABILITY,g as GLOBAL_FETCH_STRICTLY_PUBLIC_FLAG,h as REMOTE_ELIGIBLE_KEYS,Ce as REQUIRED_COMPATIBILITY_DATE,de as REQUIRED_FLAG,ie as UNEXPORTED_CLASS_MARKER,k as WORKERS_CACHE_MIN_DATE,oe as WRANGLER_FILES,o as applyModify,l as assertWranglerSatisfiesSchema,n as buildBindingManifest,A as collectExportGaps,D as describePreservedCrons,_ as describeWithheldWorkersAi,E as detectCloudflareCliConfig,ae as findWranglerFile,R as hasCloudflareCredentials,u as injectRemoteFlags,z as isCacheEnabled,G as isRemoteEnvEnabled,U as materializeDevWranglerConfig,w as materializeServiceDevConfigs,ee as mergeWranglerEnvironment,M as planRemoteBindings,le as readWranglerJsonc,v as reconcileBindingsSafely,W as reconcileWranglerBindings,O as reconcileWranglerCompatibilityDate,F as reconcileWranglerCrons,B as reconcileWranglerExtras,Z as resolveObservabilitySampling,y as resolveRemoteEnabled,me as scanWranglerVariablesForSecrets,ge as validateWrangler,xe as validateWranglerConfig,ne as validateWranglerProject,s as warnCloudflareCliConfigOnce,K as withTailConsumer,I as withheldWorkersAi,J as wranglerCodegenInputs,se as wranglerToAlchemy};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{applyModify as m}from"./applyModify-DKP2l6S9.mjs";import{hasCloudflareCredentials as y}from"./hasCloudflareCredentials-byvHpEiD.mjs";import{withheldWorkersAi as E,writeDevConfig as R,noopCleanup as S}from"./describeWithheldWorkersAi-IIxe3TuI.mjs";import{r as j}from"./lunora-manifest-DuH_Cmyu.mjs";import{o as w}from"./reconcile-services-DFqH4eMQ.mjs";import{findWranglerFile as _,readWranglerJsonc as C}from"./WRANGLER_FILES-UNW-xY5u.mjs";const h={ai:{label:"AI",shape:"object"},ai_search:{label:"AI Search",shape:"array"},ai_search_namespaces:{label:"AI Search namespace",shape:"array"},analytics:{label:"Analytics SQL",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"}},I=Object.keys(h),b=(e,r)=>typeof e.binding=="string"?e.binding:r,f=(e,r,t,n)=>{const i=[];for(const[s,a]of r.entries())a!=null&&i.push({binding:b(a,`#${String(s)}`),kind:t,path:[...n,s],section:e});return i},g=(e,r)=>h[e].shape===r,A=(e,r)=>{const{label:t}=h[e];if(g(e,"array"))return f(e,r[e]??[],t,[]);if(g(e,"object")){const n=r[e];return n==null?[]:[{binding:b(n,e),kind:t,path:[],section:e}]}return f(e,r.queues?.producers??[],t,["producers"])},B=e=>I.flatMap(r=>A(r,e)),L=(e,r)=>{let t=e;for(const n of r)t=m(t,[n.section,...n.path,"remote"],!0);return t},D=e=>{const r=o=>({cleanup:S,reason:o,remoteBindings:[],withheld:[]}),t=_(e.projectRoot);if(!t)return r("wrangler.jsonc not found");const{parsed:n,text:i}=C(t);if(n===void 0)return r(`failed to parse ${t} as JSONC`);const s=w(j(e.projectRoot)),a=e.remote?B(n).filter(o=>o.section!=="services"||!s.has(o.binding)):[],c=E(n.ai,e.hasCredentials??(()=>y({projectRoot:e.projectRoot}))),d=c===void 0?[]:[c],l=c===void 0?a:a.filter(o=>o.section!=="ai");if(l.length===0&&d.length===0)return r(e.remote?"no remote-eligible bindings to proxy":void 0);const p=d.length>0?m(i,["ai"],void 0):i,v=l.length>0?L(p,l):p,u=R(e.projectRoot,"dev",v);return{cleanup:u.cleanup,configPath:u.configPath,remoteBindings:l,withheld:d}},k=e=>{if(e===void 0)return!1;const r=e.trim().toLowerCase();return r==="1"||r==="true"},K=e=>e.flag===!0||k(e.envValue)?!0:e.configPreference??!1;export{h as REMOTE_ELIGIBLE_KEYS,L as injectRemoteFlags,k as isRemoteEnvEnabled,D as materializeDevWranglerConfig,B as planRemoteBindings,K as resolveRemoteEnabled};
|
package/dist/packem_shared/{collectExportGaps-tpw0w4Oo.mjs → collectExportGaps-BVb5JlSY.mjs}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import{readFileSync as X,writeFileSync as z}from"node:fs";import{createRequire as Z}from"node:module";import{join as Q}from"node:path";import{containerBuildTag as ee}from"@lunora/container";import{readJsonSync as ne}from"@visulima/fs";import{applyModify as S}from"./applyModify-DKP2l6S9.mjs";import{a as se,r as K}from"./lunora-manifest-DuH_Cmyu.mjs";import{parseTree as te,findNodeAtLocation as oe}from"jsonc-parser";import{r as ie,a as re,b as ae,c as de}from"./reconcile-services-DFqH4eMQ.mjs";import{a as ce,s as le}from"./infer-bindings-BsgN5eCm.mjs";import{DEV_VARS_FILE as ue,parseDevVariableEntries as ge}from"./DEV_VARS_EXAMPLE_FILE-CqLorAxT.mjs";import{requiredSecrets as me}from"./buildPackageSecretsBlock-xaAqLu5K.mjs";import{w as pe,m as fe,s as Y,o as B,n as C,p as be}from"./validate-bindings-CvNBF3U4.mjs";import{s as he}from"./worker-entry-checks-AIASCYl7.mjs";import{DEFAULT_OBSERVABILITY as we}from"./DEFAULT_OBSERVABILITY-bN6UkTMx.mjs";import{findWranglerFile as ve,readWranglerJsonc as _e}from"./WRANGLER_FILES-UNW-xY5u.mjs";const ye=[["maxBatchSize","max_batch_size"],["maxBatchTimeout","max_batch_timeout"],["maxConcurrency","max_concurrency"],["maxRetries","max_retries"],["deadLetterQueue","dead_letter_queue"],["retryDelay","retry_delay"]],R=e=>Object.fromEntries(ye.filter(([n])=>e.tuning[n]!==void 0).map(([n,s])=>[s,e.tuning[n]])),P="queueTuning",Se=/^[\t ]*(?:,[\t ]*)?(?:\/\/[^\n\r]*)?\r?\n/u,xe=/^[\t ]*,/u,Ne=(e,n)=>{const s=te(e),t=s===void 0?void 0:oe(s,[...n])?.parent;if(t?.type==="property"){const o=t.offset+t.length,i=e.lastIndexOf(`
|
|
2
|
-
`,t.offset-1)+1,r=Se.exec(e.slice(o));if(r!==null&&e.slice(i,t.offset).trim()===""){const d=t.parent?.children??[],m=d.indexOf(t),c=m===d.length-1&&m>0?d[m-1]:void 0,l=c===void 0?void 0:xe.exec(e.slice(c.offset+c.length))??void 0;return(l===void 0||c===void 0?e.slice(0,i):e.slice(0,c.offset+c.length)+e.slice(c.offset+c.length+l[0].length,i))+e.slice(o+r[0].length)}}return S(e,n,void 0)},G=(e,n,s,t,o,i=new Set)=>{const r=s.join("."),d={},m=[],c=[];let l=e;return{entries:n.map((u,w)=>{const g=t(u);if(g===void 0||u.queue===void 0)return u;const b=Object.fromEntries(Object.entries(R(g)).filter(([f])=>!i.has(f))),h=Object.entries(o[u.queue]??{}).filter(([f])=>!Object.hasOwn(b,f)),v=Object.entries(b).filter(([f,_])=>u[f]!==_),x=h.filter(([f,_])=>u[f]===_).map(([f])=>f),E=Object.fromEntries(Object.entries({...u,...b}).filter(([f])=>!x.includes(f)));for(const[f,_]of v)l=S(l,[...s,w,f],_);for(const f of x)l=Ne(l,[...s,w,f]);for(const[f,_]of h){const O=u[f];O!==void 0&&O!==_&&c.push(`${r}/${u.queue}: ${f} is no longer declared by defineQueue, but it was changed by hand to ${JSON.stringify(O)} from the declared ${JSON.stringify(_)}, so it was kept. Delete it from wrangler.jsonc if it should go.`)}return(v.length>0||x.length>0)&&m.push(`${r}/${u.queue} (${[...v.map(([f])=>f),...x.map(f=>`removed ${f}`)].join(", ")})`),Object.keys(b).length>0&&(d[u.queue]=b),E}),owned:d,text:l,updated:m,warnings:c}},Oe=(e,n,s,t)=>{const o=n.queues??{},i=o.producers??[],r=o.consumers??[],d=new Set(i.map(g=>g?.binding)),m=new Set(r.map(g=>g.queue)),c=s.filter(g=>!d.has(g.bindingName)),l=s.filter(g=>!m.has(g.name)),p=G(e,r,["queues","consumers"],g=>s.find(b=>b.name===g.queue),t);let u=p.text;const w={...p.owned};if(c.length>0||l.length>0){const g=[...i,...c.map(h=>({binding:h.bindingName,queue:h.name}))],b=[...p.entries,...l.map(h=>({queue:h.name,...h.mode==="pull"?{type:"http_pull"}:{},...R(h)}))];for(const h of l){const v=R(h);Object.keys(v).length>0&&(w[h.name]=v)}u=S(u,["queues"],{consumers:b,producers:g})}return{added:[...c.map(g=>`queues.producers/${g.bindingName}`),...l.map(g=>`queues.consumers/${g.name}`)],owned:w,text:u,updated:p.updated,warnings:p.warnings}},Ee=(e,n,s,t,o)=>{const i=n.env?.[t],r=i?.queues?.consumers??[],d=i?.queues?.producers??[],m=u=>{const w=d.find(g=>g?.queue===u.queue)?.binding;return w!==void 0?s.find(g=>g.bindingName===w):s.find(g=>g.name===u.queue&&!d.some(b=>b?.binding===g.bindingName))},c=G(e,r,["env",t,"queues","consumers"],m,o,new Set(["dead_letter_queue"])),l=r.filter(u=>u.queue!==void 0&&m(u)===void 0).map(u=>`env.${t}.queues.consumers/${String(u.queue)}: no defineQueue export matches it — this block declares no producer mapping one of their bindings to "${String(u.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=r.flatMap(u=>{const w=m(u)?.tuning.deadLetterQueue;return w===void 0||u.dead_letter_queue!==void 0?[]:[`env.${t}.queues.consumers/${String(u.queue)}: defineQueue declares deadLetterQueue "${w}", 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:c.owned,text:c.text,updated:c.updated,warnings:[...c.warnings,...p,...l]}},ke=(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?.[P],t=o=>typeof o=="object"&&o!==null&&!Array.isArray(o);return s===void 0?{}:!t(s)||!Object.values(s).every(o=>t(o)&&Object.values(o).every(i=>t(i)))?(n.push(`${e?.path??"package.json"}: \`lunora.${P}\` 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},$e=(e,n,s)=>{const t=Object.fromEntries(Object.entries({...n,...s}).filter(([,o])=>Object.keys(o).length>0));se(e,P,Object.keys(t).length===0?void 0:t)},j="PIPELINES",I="ARTIFACTS",Ae=(e,n)=>{const s=e.flagshipBinding!==void 0&&!(n?.flagship??[]).some(d=>d.binding===e.flagshipBinding),t=e.usesPipelines&&!(n?.pipelines??[]).some(d=>d.binding===j),o=e.usesArtifacts?n?.artifacts??[]:[],i=o.some(d=>d.binding===I)?[]:o.flatMap(d=>d.binding===void 0?[]:[d.binding]);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 "${j}" pipelines binding exists; run 'wrangler pipelines create <name>' and add a 'pipelines' binding ({ binding: "${j}", stream }) — codegen resolves this one name, and the pipeline resource can't be auto-provisioned.`],[e.usesArtifacts&&o.length===0,ce(e.jurisdiction)],[i.length>0,`ctx.artifacts is used and ${i.map(d=>`"${d}"`).join(", ")} ${i.length===1?"is":"are"} bound, but none is named "${I}"; make sure \`.artifacts()\` on defineApp points ctx.artifacts at it — otherwise it reads env.${I} and throws.`],[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(([d])=>d).map(([,d])=>d)},qe=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.usesX402,"@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),D=(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.`),Ce=(e,n)=>{const s=new Set([...e.workflows,...e.agents].map(i=>i.className));if(s.size===0)return[];const t=Object.entries(n.exports??{}).flatMap(([i,r])=>r?.type==="workflow"?[i]:[]),o=(n.workflows??[]).flatMap(i=>i.class_name===void 0||i.script_name!==void 0?[]:[i.class_name]);return[...new Set([...t,...o])].filter(i=>!s.has(i)).map(i=>`wrangler.jsonc declares workflow "${i}" 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.`)},je=(e,n)=>{if(e.queues.length===0)return[];const s=new Set(e.queues.map(o=>o.name)),t=new Set(e.queues.map(o=>o.bindingName));return[...(n.queues?.consumers??[]).flatMap(o=>{const{queue:i}=o;return i===void 0||s.has(i)?[]:[`wrangler.jsonc subscribes queues.consumers[] to "${i}" 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(o=>{const i=o?.binding;return i===void 0||t.has(i)?[]:[`wrangler.jsonc declares queues.producers[] binding "${i}" but no defineQueue export declares it — a leftover from a rename. Remove it if it is not hand-wired.`]})]},Ie=(e,n)=>[...Ce(e,n),...je(e,n)],U=[{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"}],De=()=>U.map(({keys:e,label:n})=>`${e[0]} + ${e[1]} (${n})`).join(" or "),Te=e=>{let n;try{n=X(Q(e,ue),"utf8")}catch{return!1}const s=new Map(ge(n).map(t=>[t.key,t.value]));return U.some(({keys:t})=>t.every(o=>(s.get(o)??"")!==""))},Be=(e,n)=>{const s=n?.secrets?.required;if(!Array.isArray(s))return[];const t=new Set(s),o=me(le(e)).map(i=>i.key).filter(i=>!t.has(i));return o.length===0?[]:[`wrangler.jsonc declares secrets.required without ${o.join(", ")}, which this app needs — wrangler dev loads only the listed keys from .dev.vars, so add ${o.length===1?"it":"them"} to secrets.required.`]},T=(e,n,s)=>{const t=new Set(e.durableObjects.map(d=>d.className)),o=[],i=(s?.r2_buckets?.length??0)>0,r=(s?.d1_databases?.some(d=>d.binding==="DB")??!1)||e.needsD1;return e.usesStorage&&!i&&o.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")&&!r&&o.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")&&o.push("@lunora/scheduler is used but the worker entry exports no SchedulerDO; export it so the SCHEDULER binding can be provisioned."),o.push(...D("container","containers",e.containers),...D("workflow","workflows",e.workflows),...D("agent","agents",e.agents)),e.containers.length>0&&s?.observability?.enabled===!1&&o.push("containers are declared but observability is explicitly disabled in wrangler.jsonc — container logs will not be captured."),e.usesPayments&&!Te(n)&&o.push(`@lunora/payment is used; set one provider's secret pair in .dev.vars — ${De()}.`),o.push(...qe(e),...Ae(e,s),...Be(e,s)),s!==void 0&&o.push(...Ie(e,s)),o},H="<replace-with-d1-create-id>",Re=e=>[["container","containers",e.containers],["workflow","workflows",e.workflows],["agent","agents",e.agents]].flatMap(([s,t,o])=>o.filter(i=>!i.exported).map(({className:i,exportName:r})=>({className:i,exportName:r,kind:s,module:t}))),Pe=e=>{const n=new Set(B(e).map(t=>t.tag));let s=1;for(;n.has(`v${String(s)}`);)s+=1;return`v${String(s)}`},Le=e=>{const n=new Set;for(const s of B(e)){for(const t of C(s.deleted_classes))n.delete(t);for(const{from:t,to:o}of B(s.renamed_classes))t!==void 0&&n.delete(t),o!==void 0&&n.add(o);for(const t of[...C(s.new_classes),...C(s.new_sqlite_classes)])n.add(t)}return n},Me=(e,n,s)=>{const t=n.durable_objects?.bindings??[],o=new Set(t.map(l=>l.name)),i=s.filter(l=>!o.has(l.binding));let r=e;const d=[];if(i.length>0){const l=[...t,...i.map(p=>({class_name:p.className,name:p.binding}))];r=S(r,["durable_objects","bindings"],l),d.push(...i.map(p=>`${p.binding}/${p.className}`))}const m=n.migrations??[],c=s.map(l=>l.className).filter(l=>!Le(m).has(l));if(c.length>0){const l=[...m,{new_sqlite_classes:c,tag:Pe(m)}];r=S(r,["migrations"],l)}return{added:d,text:r}},We=(e,n)=>{const s=n.d1_databases??[];if(s.some(i=>i.binding==="DB"))return{added:[],text:e};const t=typeof n.name=="string"&&n.name.length>0?n.name:"lunora",o=[...s,{binding:"DB",database_id:H,database_name:t}];return{added:["DB (D1)"],text:S(e,["d1_databases"],o)}},Ke={ai:{binding:"AI",label:"AI (Workers AI)"},analytics:{binding:"ANALYTICS_SQL",label:"ANALYTICS_SQL (Analytics SQL)"},browser:{binding:"BROWSER",label:"BROWSER (Browser Rendering)"},images:{binding:"IMAGES",label:"IMAGES (Cloudflare Images)"}},$=(e,n,s)=>{const{binding:t,label:o}=Ke[s],i=n[s]?.binding;return typeof i=="string"&&i.length>0?{added:[],text:e}:{added:[o],text:S(e,[s],{binding:t})}},Fe=(e,n)=>e.usesAnalyticsSql&&he(n,new Set(["analyticsSql"]))?.chained.has("analyticsSql")!==!0,Qe=new Set(["ratelimits","send_email"]),Ye=["durable_objects","logfwdr","unsafe"],Ge=new Set(["data_blobs","text_blobs","vars","wasm_modules"]),M=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),L=(e,n,s)=>M(e)&&e[n]===s,Ue=(e,n,s)=>{if(Ge.has(e))return M(n)&&Object.hasOwn(n,s);const t=Qe.has(e)?"name":"binding";return Array.isArray(n)?n.some(o=>L(o,t,s)):L(n,"binding",s)},He=(e,n)=>{const s=e,t=Object.entries(s).find(([i,r])=>i!=="env"&&Ue(i,r,n));if(t!==void 0)return t[0];for(const i of Ye){const r=s[i];if(M(r)&&Array.isArray(r.bindings)&&r.bindings.some(d=>L(d,"name",n)))return`${i}.bindings`}if(e.queues?.producers?.some(i=>i?.binding===n)===!0)return"queues.producers";const o=e.secrets?.required;if(Array.isArray(o)&&o.includes(n))return"secrets.required"},F=(e,n,s,t,o)=>{if((n[s]?.length??0)>0)return{added:[],text:e};const i=He(n,t.binding);return i!==void 0?{added:[],text:e,warnings:[`${s}: not adding ${JSON.stringify(t)} — the name "${t.binding}" is already bound by \`${i}\` in wrangler.jsonc. Add a ${s} entry under another binding name and point the matching \`defineApp()\` override at it.`]}:{added:[o],text:S(e,[s],[t])}},Je=(e,n)=>{const s=n.worker_loaders??[];return s.some(t=>t.binding==="LOADER")?{added:[],text:e}:{added:["LOADER (Worker Loader)"],text:S(e,["worker_loaders"],[...s,{binding:"LOADER"}])}},Ve=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},Xe=e=>{const{image:n}=e;return n.kind==="dockerfile"?n.dockerfilePath:n.kind==="registry"?n.reference:ee(e.exportName)},J=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}}},ze=e=>{if(e.schedulingPolicy==="durable_object")return J(e);const{image:n}=e,s={class_name:e.className,image:Xe(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=Ve(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},Ze=(e,n,s)=>{const t=n.containers??[],o=new Set(t.map(c=>c.class_name)),i=s.filter(c=>!o.has(c.className));let r=i.length===0?e:S(e,["containers"],[...t,...i.map(c=>ze(c))]);const d=[],m=[];for(const[c,l]of t.entries()){const p=s.find(g=>g.className===l.class_name);if(p===void 0)continue;const u=p.schedulingPolicy??"default";if((l.scheduling_policy??"default")!==u){m.push(`containers/${p.className} has scheduling_policy "${l.scheduling_policy??"default"}" in wrangler.jsonc but defineContainer "${p.exportName}" declares "${u}" — the policy is immutable, so replace the entry (and its container application) by hand.`);continue}const w=p.schedulingPolicy==="durable_object"?J(p).images:void 0;w!==void 0&&JSON.stringify(l.images)!==JSON.stringify(w)&&(r=S(r,["containers",c,"images"],w),d.push(`containers/${p.className}.images`))}return{added:i.map(c=>`containers/${c.className}`),text:r,updated:d,warnings:m}},en=(e,n)=>{if(n.observability!==void 0)return{added:[],text:e};const s=S(e,["observability"],{...we});return{added:["observability"],text:s}},nn=(e,n)=>n.upload_source_maps!==void 0?{added:[],text:e}:{added:["upload_source_maps"],text:S(e,["upload_source_maps"],!0)},V=[{minimum:[4,142],name:"wrangler"},{minimum:[1,61],name:"@cloudflare/vite-plugin"}],sn=V.map(({minimum:e,name:n})=>`${n}@^${e.join(".")}.0`).join(" "),tn=(e,n)=>{try{const s=Z(Q(e,"package.json")).resolve(`${n}/package.json`),[t=0,o=0]=String(ne(s).version).split(".").map(Number);return[t,o]}catch{return}},on=e=>{const n=V.flatMap(({minimum:s,name:t})=>{const o=tn(e,t);return o!==void 0&&(o[0]<s[0]||o[0]===s[0]&&o[1]<s[1])?[`${t} ${o.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 ${sn}\`) and re-run.`},rn=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.`]:[]),an=(e,n,s)=>{let t=e;const o=[],i=[];for(const r of s){const d=n[r.className];if(d?.type==="workflow")for(const{of:m,path:c}of be){const l=m(r),p=Y(d,c),u=`exports/${r.className}.${c.join(".")}`;if(l===void 0){p!==void 0&&i.push(`${u} is set in wrangler.jsonc but defineWorkflow "${r.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(l)&&(t=S(t,["exports",r.className,...c],l),o.push(u))}}return{text:t,updated:o,warnings:i}},dn=(e,n,s,t,o)=>{if(o!==void 0)return{added:[],text:e,warnings:[o]};const i=[...s.map(b=>({settings:pe(b),workflow:b})),...t.map(b=>({settings:{},workflow:b}))],r=new Set(i.map(({workflow:b})=>b.className)),d=n.workflows??[],m=d.filter(b=>b.script_name===void 0&&b.class_name!==void 0&&r.has(b.class_name)),c=n.exports??{},l=[],p=[],u=[];let w=e;for(const{settings:b,workflow:h}of i){if(c[h.className]!==void 0&&c[h.className]!==null)continue;const v=m.find(f=>f.class_name===h.className),x=Object.fromEntries(fe.flatMap(f=>{const _=Y(v,[f]);return _===void 0?[]:[[f,_]]})),E=v?.name??h.name;v?.name!==void 0&&v.name!==h.name&&u.push(`workflows/${h.className} is deployed as "${v.name}" but declared as "${h.name}" — its export keeps "${v.name}" so running instances survive. Change the declaration to match, or rename deliberately (it starts a new, empty workflow).`),w=S(w,["exports",h.className],{type:"workflow",...x,...b,name:E}),(v===void 0?l:p).push(`exports/${h.className}`)}if(m.length>0){const b=d.filter(h=>!m.includes(h));w=S(w,["workflows"],b.length===0?void 0:b),p.push(...m.map(h=>`workflows/${String(h.class_name)} → exports`))}u.push(...rn(n));const g=an(w,c,s);return{added:l,text:g.text,updated:[...p,...g.updated],warnings:[...u,...g.warnings]}},On=(e,n,s,t)=>{const o=ve(e),i=Re(n);if(!o)return{added:[],changed:!1,exportGaps:i,reason:"wrangler.jsonc not found",updated:[],warnings:T(n,e)};const{parsed:r,text:d}=_e(o);if(r===void 0)return{added:[],changed:!1,exportGaps:i,reason:`failed to parse ${o} as JSONC`,updated:[],warnings:T(n,e),wranglerPath:o};const m=T(n,e,r);if(s!==void 0){const a=r.env?.[s]!==void 0;m.push(a?`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 c=n.containers.filter(a=>a.exported),l=n.agents.filter(a=>a.exported&&a.voice===!0&&a.voiceBindingName!==void 0&&a.voiceClassName!==void 0),p=[...n.durableObjects,...c.map(a=>({binding:a.bindingName,className:a.className})),...l.map(a=>({binding:a.voiceBindingName,className:a.voiceClassName}))],u=n.workflows.filter(a=>a.exported),w=n.agents.filter(a=>a.exported),g=K(e),b=ke(g,m),h={},v=ie(g);let x;const E=[{enabled:!0,run:a=>Me(a,r,p)},{enabled:n.needsD1,run:a=>We(a,r)},{enabled:n.usesAi,run:a=>$(a,r,"ai")},{enabled:n.usesAiSearch,run:a=>F(a,r,"ai_search_namespaces",{binding:"AI_SEARCH",namespace:"default"},"AI_SEARCH (AI Search namespace)")},{enabled:Fe(n,e),run:a=>$(a,r,"analytics")},{enabled:n.usesBrowser,run:a=>$(a,r,"browser")},{enabled:n.usesImages,run:a=>$(a,r,"images")},{enabled:n.usesAnalytics,run:a=>F(a,r,"analytics_engine_datasets",{binding:"ANALYTICS",dataset:"ANALYTICS"},"ANALYTICS (Analytics Engine)")},{enabled:n.usesWorkerLoader,run:a=>Je(a,r)},{enabled:!0,run:a=>en(a,r)},{enabled:t===void 0||t==="cloudflare",run:a=>nn(a,r)},{enabled:c.length>0,run:a=>Ze(a,r,c)},{enabled:u.length>0||w.length>0,run:a=>dn(a,r,u,w,on(e))},{enabled:n.queues.length>0,run:a=>{const y=Oe(a,r,n.queues,b.queues??{});return h.queues=y.owned,y}},{enabled:n.services!==void 0&&(n.services.length>0||Object.keys(v).length>0),run:a=>{const y=re(a,r,n.services??[],v);return x=y.owned,y}},...s===void 0||r.env?.[s]===void 0?[]:[{enabled:n.queues.length>0,run:a=>{const y=`env.${s}.queues`,k=Ee(a,r,n.queues,s,b[y]??{});return h[y]=k.owned,k}}]];let f=d;const _=[],O=[];for(const a of E){if(!a.enabled)continue;const y=a.run(f);f=y.text,_.push(...y.added),O.push(...y.updated??[]),m.push(...y.warnings??[])}const W=a=>{if(g===void 0)return;const y=x,k=[...Object.keys(h).length>0?[{consequence:"an option removed from defineQueue stays deployed",key:"queueTuning",label:"queue tuning",write:N=>{$e(N,b,h)}}]:[],...y===void 0?[]:[{consequence:"a service removed from lunora.config stays bound",key:"services",label:"service bindings",write:N=>{de(N,y)}}]];for(const N of k)try{N.write(K(e)??g)}catch(q){m.push(`${a?"wrangler.jsonc was updated, but ":""}recording the ${N.label} reconcile owns in ${g.path} (lunora.${N.key}) failed: ${q instanceof Error?q.message:String(q)}. Until it is recorded, ${N.consequence}.`)}};let A;if(n.services!==void 0){const a=ae(e,n.services,v);m.push(...a.warnings),x={...x,...a.owned},A=a.added.length>0||a.updated.length>0?{added:a.added,path:a.path,updated:a.updated}:void 0}return _.includes("DB (D1)")&&m.push(`wrote a DB binding with a placeholder database_id ("${H}") — run \`wrangler d1 create <name>\` and replace it before deploying.`),f===d?(W(!1),{added:_,changed:!1,devConfig:A,exportGaps:i,reason:"bindings already in sync",updated:O,warnings:m,wranglerPath:o}):(z(o,f,"utf8"),W(!0),{added:_,changed:!0,devConfig:A,exportGaps:i,updated:O,warnings:m,wranglerPath:o})};export{Re as collectExportGaps,On as reconcileWranglerBindings};
|
|
2
|
+
`,t.offset-1)+1,r=Se.exec(e.slice(o));if(r!==null&&e.slice(i,t.offset).trim()===""){const d=t.parent?.children??[],m=d.indexOf(t),c=m===d.length-1&&m>0?d[m-1]:void 0,l=c===void 0?void 0:xe.exec(e.slice(c.offset+c.length))??void 0;return(l===void 0||c===void 0?e.slice(0,i):e.slice(0,c.offset+c.length)+e.slice(c.offset+c.length+l[0].length,i))+e.slice(o+r[0].length)}}return S(e,n,void 0)},G=(e,n,s,t,o,i=new Set)=>{const r=s.join("."),d={},m=[],c=[];let l=e;return{entries:n.map((u,w)=>{const g=t(u);if(g===void 0||u.queue===void 0)return u;const b=Object.fromEntries(Object.entries(R(g)).filter(([f])=>!i.has(f))),h=Object.entries(o[u.queue]??{}).filter(([f])=>!Object.hasOwn(b,f)),v=Object.entries(b).filter(([f,_])=>u[f]!==_),x=h.filter(([f,_])=>u[f]===_).map(([f])=>f),E=Object.fromEntries(Object.entries({...u,...b}).filter(([f])=>!x.includes(f)));for(const[f,_]of v)l=S(l,[...s,w,f],_);for(const f of x)l=Ne(l,[...s,w,f]);for(const[f,_]of h){const O=u[f];O!==void 0&&O!==_&&c.push(`${r}/${u.queue}: ${f} is no longer declared by defineQueue, but it was changed by hand to ${JSON.stringify(O)} from the declared ${JSON.stringify(_)}, so it was kept. Delete it from wrangler.jsonc if it should go.`)}return(v.length>0||x.length>0)&&m.push(`${r}/${u.queue} (${[...v.map(([f])=>f),...x.map(f=>`removed ${f}`)].join(", ")})`),Object.keys(b).length>0&&(d[u.queue]=b),E}),owned:d,text:l,updated:m,warnings:c}},Oe=(e,n,s,t)=>{const o=n.queues??{},i=o.producers??[],r=o.consumers??[],d=new Set(i.map(g=>g?.binding)),m=new Set(r.map(g=>g.queue)),c=s.filter(g=>!d.has(g.bindingName)),l=s.filter(g=>!m.has(g.name)),p=G(e,r,["queues","consumers"],g=>s.find(b=>b.name===g.queue),t);let u=p.text;const w={...p.owned};if(c.length>0||l.length>0){const g=[...i,...c.map(h=>({binding:h.bindingName,queue:h.name}))],b=[...p.entries,...l.map(h=>({queue:h.name,...h.mode==="pull"?{type:"http_pull"}:{},...R(h)}))];for(const h of l){const v=R(h);Object.keys(v).length>0&&(w[h.name]=v)}u=S(u,["queues"],{consumers:b,producers:g})}return{added:[...c.map(g=>`queues.producers/${g.bindingName}`),...l.map(g=>`queues.consumers/${g.name}`)],owned:w,text:u,updated:p.updated,warnings:p.warnings}},Ee=(e,n,s,t,o)=>{const i=n.env?.[t],r=i?.queues?.consumers??[],d=i?.queues?.producers??[],m=u=>{const w=d.find(g=>g?.queue===u.queue)?.binding;return w!==void 0?s.find(g=>g.bindingName===w):s.find(g=>g.name===u.queue&&!d.some(b=>b?.binding===g.bindingName))},c=G(e,r,["env",t,"queues","consumers"],m,o,new Set(["dead_letter_queue"])),l=r.filter(u=>u.queue!==void 0&&m(u)===void 0).map(u=>`env.${t}.queues.consumers/${String(u.queue)}: no defineQueue export matches it — this block declares no producer mapping one of their bindings to "${String(u.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=r.flatMap(u=>{const w=m(u)?.tuning.deadLetterQueue;return w===void 0||u.dead_letter_queue!==void 0?[]:[`env.${t}.queues.consumers/${String(u.queue)}: defineQueue declares deadLetterQueue "${w}", 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:c.owned,text:c.text,updated:c.updated,warnings:[...c.warnings,...p,...l]}},ke=(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?.[P],t=o=>typeof o=="object"&&o!==null&&!Array.isArray(o);return s===void 0?{}:!t(s)||!Object.values(s).every(o=>t(o)&&Object.values(o).every(i=>t(i)))?(n.push(`${e?.path??"package.json"}: \`lunora.${P}\` 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},$e=(e,n,s)=>{const t=Object.fromEntries(Object.entries({...n,...s}).filter(([,o])=>Object.keys(o).length>0));se(e,P,Object.keys(t).length===0?void 0:t)},j="PIPELINES",I="ARTIFACTS",Ae=(e,n)=>{const s=e.flagshipBinding!==void 0&&!(n?.flagship??[]).some(d=>d.binding===e.flagshipBinding),t=e.usesPipelines&&!(n?.pipelines??[]).some(d=>d.binding===j),o=e.usesArtifacts?n?.artifacts??[]:[],i=o.some(d=>d.binding===I)?[]:o.flatMap(d=>d.binding===void 0?[]:[d.binding]);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 "${j}" pipelines binding exists; run 'wrangler pipelines create <name>' and add a 'pipelines' binding ({ binding: "${j}", stream }) — codegen resolves this one name, and the pipeline resource can't be auto-provisioned.`],[e.usesArtifacts&&o.length===0,ce(e.jurisdiction)],[i.length>0,`ctx.artifacts is used and ${i.map(d=>`"${d}"`).join(", ")} ${i.length===1?"is":"are"} bound, but none is named "${I}"; make sure \`.artifacts()\` on defineApp points ctx.artifacts at it — otherwise it reads env.${I} and throws.`],[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(([d])=>d).map(([,d])=>d)},qe=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.usesX402,"@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),D=(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.`),Ce=(e,n)=>{const s=new Set([...e.workflows,...e.agents].map(i=>i.className));if(s.size===0)return[];const t=Object.entries(n.exports??{}).flatMap(([i,r])=>r?.type==="workflow"?[i]:[]),o=(n.workflows??[]).flatMap(i=>i.class_name===void 0||i.script_name!==void 0?[]:[i.class_name]);return[...new Set([...t,...o])].filter(i=>!s.has(i)).map(i=>`wrangler.jsonc declares workflow "${i}" 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.`)},je=(e,n)=>{if(e.queues.length===0)return[];const s=new Set(e.queues.map(o=>o.name)),t=new Set(e.queues.map(o=>o.bindingName));return[...(n.queues?.consumers??[]).flatMap(o=>{const{queue:i}=o;return i===void 0||s.has(i)?[]:[`wrangler.jsonc subscribes queues.consumers[] to "${i}" 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(o=>{const i=o?.binding;return i===void 0||t.has(i)?[]:[`wrangler.jsonc declares queues.producers[] binding "${i}" but no defineQueue export declares it — a leftover from a rename. Remove it if it is not hand-wired.`]})]},Ie=(e,n)=>[...Ce(e,n),...je(e,n)],U=[{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"}],De=()=>U.map(({keys:e,label:n})=>`${e[0]} + ${e[1]} (${n})`).join(" or "),Te=e=>{let n;try{n=X(Q(e,ue),"utf8")}catch{return!1}const s=new Map(ge(n).map(t=>[t.key,t.value]));return U.some(({keys:t})=>t.every(o=>(s.get(o)??"")!==""))},Be=(e,n)=>{const s=n?.secrets?.required;if(!Array.isArray(s))return[];const t=new Set(s),o=me(le(e)).map(i=>i.key).filter(i=>!t.has(i));return o.length===0?[]:[`wrangler.jsonc declares secrets.required without ${o.join(", ")}, which this app needs — wrangler dev loads only the listed keys from .dev.vars, so add ${o.length===1?"it":"them"} to secrets.required.`]},T=(e,n,s)=>{const t=new Set(e.durableObjects.map(d=>d.className)),o=[],i=(s?.r2_buckets?.length??0)>0,r=(s?.d1_databases?.some(d=>d.binding==="DB")??!1)||e.needsD1;return e.usesStorage&&!i&&o.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")&&!r&&o.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")&&o.push("@lunora/scheduler is used but the worker entry exports no SchedulerDO; export it so the SCHEDULER binding can be provisioned."),o.push(...D("container","containers",e.containers),...D("workflow","workflows",e.workflows),...D("agent","agents",e.agents)),e.containers.length>0&&s?.observability?.enabled===!1&&o.push("containers are declared but observability is explicitly disabled in wrangler.jsonc — container logs will not be captured."),e.usesPayments&&!Te(n)&&o.push(`@lunora/payment is used; set one provider's secret pair in .dev.vars — ${De()}.`),o.push(...qe(e),...Ae(e,s),...Be(e,s)),s!==void 0&&o.push(...Ie(e,s)),o},H="<replace-with-d1-create-id>",Re=e=>[["container","containers",e.containers],["workflow","workflows",e.workflows],["agent","agents",e.agents]].flatMap(([s,t,o])=>o.filter(i=>!i.exported).map(({className:i,exportName:r})=>({className:i,exportName:r,kind:s,module:t}))),Pe=e=>{const n=new Set(B(e).map(t=>t.tag));let s=1;for(;n.has(`v${String(s)}`);)s+=1;return`v${String(s)}`},Le=e=>{const n=new Set;for(const s of B(e)){for(const t of C(s.deleted_classes))n.delete(t);for(const{from:t,to:o}of B(s.renamed_classes))t!==void 0&&n.delete(t),o!==void 0&&n.add(o);for(const t of[...C(s.new_classes),...C(s.new_sqlite_classes)])n.add(t)}return n},Me=(e,n,s)=>{const t=n.durable_objects?.bindings??[],o=new Set(t.map(l=>l.name)),i=s.filter(l=>!o.has(l.binding));let r=e;const d=[];if(i.length>0){const l=[...t,...i.map(p=>({class_name:p.className,name:p.binding}))];r=S(r,["durable_objects","bindings"],l),d.push(...i.map(p=>`${p.binding}/${p.className}`))}const m=n.migrations??[],c=s.map(l=>l.className).filter(l=>!Le(m).has(l));if(c.length>0){const l=[...m,{new_sqlite_classes:c,tag:Pe(m)}];r=S(r,["migrations"],l)}return{added:d,text:r}},We=(e,n)=>{const s=n.d1_databases??[];if(s.some(i=>i.binding==="DB"))return{added:[],text:e};const t=typeof n.name=="string"&&n.name.length>0?n.name:"lunora",o=[...s,{binding:"DB",database_id:H,database_name:t}];return{added:["DB (D1)"],text:S(e,["d1_databases"],o)}},Ke={ai:{binding:"AI",label:"AI (Workers AI)"},analytics:{binding:"ANALYTICS_SQL",label:"ANALYTICS_SQL (Analytics SQL)"},browser:{binding:"BROWSER",label:"BROWSER (Browser Rendering)"},images:{binding:"IMAGES",label:"IMAGES (Cloudflare Images)"}},$=(e,n,s)=>{const{binding:t,label:o}=Ke[s],i=n[s]?.binding;return typeof i=="string"&&i.length>0?{added:[],text:e}:{added:[o],text:S(e,[s],{binding:t})}},Fe=(e,n)=>e.usesAnalyticsSql&&he(n,new Set(["analyticsSql"]))?.chained.has("analyticsSql")!==!0,Qe=new Set(["ratelimits","send_email"]),Ye=["durable_objects","logfwdr","unsafe"],Ge=new Set(["data_blobs","text_blobs","vars","wasm_modules"]),M=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),L=(e,n,s)=>M(e)&&e[n]===s,Ue=(e,n,s)=>{if(Ge.has(e))return M(n)&&Object.hasOwn(n,s);const t=Qe.has(e)?"name":"binding";return Array.isArray(n)?n.some(o=>L(o,t,s)):L(n,"binding",s)},He=(e,n)=>{const s=e,t=Object.entries(s).find(([i,r])=>i!=="env"&&Ue(i,r,n));if(t!==void 0)return t[0];for(const i of Ye){const r=s[i];if(M(r)&&Array.isArray(r.bindings)&&r.bindings.some(d=>L(d,"name",n)))return`${i}.bindings`}if(e.queues?.producers?.some(i=>i?.binding===n)===!0)return"queues.producers";const o=e.secrets?.required;if(Array.isArray(o)&&o.includes(n))return"secrets.required"},F=(e,n,s,t,o)=>{if((n[s]?.length??0)>0)return{added:[],text:e};const i=He(n,t.binding);return i!==void 0?{added:[],text:e,warnings:[`${s}: not adding ${JSON.stringify(t)} — the name "${t.binding}" is already bound by \`${i}\` in wrangler.jsonc. Add a ${s} entry under another binding name and point the matching \`defineApp()\` override at it.`]}:{added:[o],text:S(e,[s],[t])}},Je=(e,n)=>{const s=n.worker_loaders??[];return s.some(t=>t.binding==="LOADER")?{added:[],text:e}:{added:["LOADER (Worker Loader)"],text:S(e,["worker_loaders"],[...s,{binding:"LOADER"}])}},Ve=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},Xe=e=>{const{image:n}=e;return n.kind==="dockerfile"?n.dockerfilePath:n.kind==="registry"?n.reference:ee(e.exportName)},J=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}}},ze=e=>{if(e.schedulingPolicy==="durable_object")return J(e);const{image:n}=e,s={class_name:e.className,image:Xe(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=Ve(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},Ze=(e,n,s)=>{const t=n.containers??[],o=new Set(t.map(c=>c.class_name)),i=s.filter(c=>!o.has(c.className));let r=i.length===0?e:S(e,["containers"],[...t,...i.map(c=>ze(c))]);const d=[],m=[];for(const[c,l]of t.entries()){const p=s.find(g=>g.className===l.class_name);if(p===void 0)continue;const u=p.schedulingPolicy??"default";if((l.scheduling_policy??"default")!==u){m.push(`containers/${p.className} has scheduling_policy "${l.scheduling_policy??"default"}" in wrangler.jsonc but defineContainer "${p.exportName}" declares "${u}" — the policy is immutable, so replace the entry (and its container application) by hand.`);continue}const w=p.schedulingPolicy==="durable_object"?J(p).images:void 0;w!==void 0&&JSON.stringify(l.images)!==JSON.stringify(w)&&(r=S(r,["containers",c,"images"],w),d.push(`containers/${p.className}.images`))}return{added:i.map(c=>`containers/${c.className}`),text:r,updated:d,warnings:m}},en=(e,n)=>{if(n.observability!==void 0)return{added:[],text:e};const s=S(e,["observability"],{...we});return{added:["observability"],text:s}},nn=(e,n)=>n.upload_source_maps!==void 0?{added:[],text:e}:{added:["upload_source_maps"],text:S(e,["upload_source_maps"],!0)},V=[{minimum:[4,142],name:"wrangler"},{minimum:[1,61],name:"@cloudflare/vite-plugin"}],sn=V.map(({minimum:e,name:n})=>`${n}@^${e.join(".")}.0`).join(" "),tn=(e,n)=>{try{const s=Z(Q(e,"package.json")).resolve(`${n}/package.json`),[t=0,o=0]=String(ne(s).version).split(".").map(Number);return[t,o]}catch{return}},on=e=>{const n=V.flatMap(({minimum:s,name:t})=>{const o=tn(e,t);return o!==void 0&&(o[0]<s[0]||o[0]===s[0]&&o[1]<s[1])?[`${t} ${o.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 ${sn}\`) and re-run.`},rn=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.`]:[]),an=(e,n,s)=>{let t=e;const o=[],i=[];for(const r of s){const d=n[r.className];if(d?.type==="workflow")for(const{of:m,path:c}of be){const l=m(r),p=Y(d,c),u=`exports/${r.className}.${c.join(".")}`;if(l===void 0){p!==void 0&&i.push(`${u} is set in wrangler.jsonc but defineWorkflow "${r.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(l)&&(t=S(t,["exports",r.className,...c],l),o.push(u))}}return{text:t,updated:o,warnings:i}},dn=(e,n,s,t,o)=>{if(o!==void 0)return{added:[],text:e,warnings:[o]};const i=[...s.map(b=>({settings:pe(b),workflow:b})),...t.map(b=>({settings:{},workflow:b}))],r=new Set(i.map(({workflow:b})=>b.className)),d=n.workflows??[],m=d.filter(b=>b.script_name===void 0&&b.class_name!==void 0&&r.has(b.class_name)),c=n.exports??{},l=[],p=[],u=[];let w=e;for(const{settings:b,workflow:h}of i){if(c[h.className]!==void 0&&c[h.className]!==null)continue;const v=m.find(f=>f.class_name===h.className),x=Object.fromEntries(fe.flatMap(f=>{const _=Y(v,[f]);return _===void 0?[]:[[f,_]]})),E=v?.name??h.name;v?.name!==void 0&&v.name!==h.name&&u.push(`workflows/${h.className} is deployed as "${v.name}" but declared as "${h.name}" — its export keeps "${v.name}" so running instances survive. Change the declaration to match, or rename deliberately (it starts a new, empty workflow).`),w=S(w,["exports",h.className],{type:"workflow",...x,...b,name:E}),(v===void 0?l:p).push(`exports/${h.className}`)}if(m.length>0){const b=d.filter(h=>!m.includes(h));w=S(w,["workflows"],b.length===0?void 0:b),p.push(...m.map(h=>`workflows/${String(h.class_name)} → exports`))}u.push(...rn(n));const g=an(w,c,s);return{added:l,text:g.text,updated:[...p,...g.updated],warnings:[...u,...g.warnings]}},On=(e,n,{environment:s,target:t}={})=>{const o=ve(e),i=Re(n);if(!o)return{added:[],changed:!1,exportGaps:i,reason:"wrangler.jsonc not found",updated:[],warnings:T(n,e)};const{parsed:r,text:d}=_e(o);if(r===void 0)return{added:[],changed:!1,exportGaps:i,reason:`failed to parse ${o} as JSONC`,updated:[],warnings:T(n,e),wranglerPath:o};const m=T(n,e,r);if(s!==void 0){const a=r.env?.[s]!==void 0;m.push(a?`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 c=n.containers.filter(a=>a.exported),l=n.agents.filter(a=>a.exported&&a.voice===!0&&a.voiceBindingName!==void 0&&a.voiceClassName!==void 0),p=[...n.durableObjects,...c.map(a=>({binding:a.bindingName,className:a.className})),...l.map(a=>({binding:a.voiceBindingName,className:a.voiceClassName}))],u=n.workflows.filter(a=>a.exported),w=n.agents.filter(a=>a.exported),g=K(e),b=ke(g,m),h={},v=ie(g);let x;const E=[{enabled:!0,run:a=>Me(a,r,p)},{enabled:n.needsD1,run:a=>We(a,r)},{enabled:n.usesAi,run:a=>$(a,r,"ai")},{enabled:n.usesAiSearch,run:a=>F(a,r,"ai_search_namespaces",{binding:"AI_SEARCH",namespace:"default"},"AI_SEARCH (AI Search namespace)")},{enabled:Fe(n,e),run:a=>$(a,r,"analytics")},{enabled:n.usesBrowser,run:a=>$(a,r,"browser")},{enabled:n.usesImages,run:a=>$(a,r,"images")},{enabled:n.usesAnalytics,run:a=>F(a,r,"analytics_engine_datasets",{binding:"ANALYTICS",dataset:"ANALYTICS"},"ANALYTICS (Analytics Engine)")},{enabled:n.usesWorkerLoader,run:a=>Je(a,r)},{enabled:!0,run:a=>en(a,r)},{enabled:t===void 0||t==="cloudflare",run:a=>nn(a,r)},{enabled:c.length>0,run:a=>Ze(a,r,c)},{enabled:u.length>0||w.length>0,run:a=>dn(a,r,u,w,on(e))},{enabled:n.queues.length>0,run:a=>{const y=Oe(a,r,n.queues,b.queues??{});return h.queues=y.owned,y}},{enabled:n.services!==void 0&&(n.services.length>0||Object.keys(v).length>0),run:a=>{const y=re(a,r,n.services??[],v);return x=y.owned,y}},...s===void 0||r.env?.[s]===void 0?[]:[{enabled:n.queues.length>0,run:a=>{const y=`env.${s}.queues`,k=Ee(a,r,n.queues,s,b[y]??{});return h[y]=k.owned,k}}]];let f=d;const _=[],O=[];for(const a of E){if(!a.enabled)continue;const y=a.run(f);f=y.text,_.push(...y.added),O.push(...y.updated??[]),m.push(...y.warnings??[])}const W=a=>{if(g===void 0)return;const y=x,k=[...Object.keys(h).length>0?[{consequence:"an option removed from defineQueue stays deployed",key:"queueTuning",label:"queue tuning",write:N=>{$e(N,b,h)}}]:[],...y===void 0?[]:[{consequence:"a service removed from lunora.config stays bound",key:"services",label:"service bindings",write:N=>{de(N,y)}}]];for(const N of k)try{N.write(K(e)??g)}catch(q){m.push(`${a?"wrangler.jsonc was updated, but ":""}recording the ${N.label} reconcile owns in ${g.path} (lunora.${N.key}) failed: ${q instanceof Error?q.message:String(q)}. Until it is recorded, ${N.consequence}.`)}};let A;if(n.services!==void 0){const a=ae(e,n.services,v);m.push(...a.warnings),x={...x,...a.owned},A=a.added.length>0||a.updated.length>0?{added:a.added,path:a.path,updated:a.updated}:void 0}return _.includes("DB (D1)")&&m.push(`wrote a DB binding with a placeholder database_id ("${H}") — run \`wrangler d1 create <name>\` and replace it before deploying.`),f===d?(W(!1),{added:_,changed:!1,devConfig:A,exportGaps:i,reason:"bindings already in sync",updated:O,warnings:m,wranglerPath:o}):(z(o,f,"utf8"),W(!0),{added:_,changed:!0,devConfig:A,exportGaps:i,updated:O,warnings:m,wranglerPath:o})};export{Re as collectExportGaps,On as reconcileWranglerBindings};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{rmSync as s,readdirSync as c,writeFileSync as l}from"node:fs";import{join as i}from"node:path";const u=/^\.wrangler\.lunora-(?:dev|service)\.(\d+)\.\d+\.jsonc$/;let t=0;const a=e=>(t+=1,`.wrangler.lunora-${e}.${String(process.pid)}.${String(t)}.jsonc`),d=e=>{try{return process.kill(e,0),!0}catch(r){return r.code==="EPERM"}},f=e=>{let r;try{r=c(e)}catch{return}for(const o of r){const n=u.exec(o);if(!(n===null||Number(n[1])===process.pid||d(Number(n[1]))))try{s(i(e,o),{force:!0})}catch{}}},h=()=>{},g=e=>{let r=!1;return()=>{if(!r){r=!0;try{s(e,{force:!0})}catch{}}}},A=(e,r,o)=>{f(e);const n=i(e,a(r));return l(n,o,"utf8"),{cleanup:g(n),configPath:n}},w=(e,r)=>{if(!(e==null||r()))return typeof e.binding=="string"?e.binding:"AI"},v=e=>`Workers AI is off in this dev session (${e} binding left out): no Cloudflare login found, and Workers AI only runs remotely. \`@cf/…\` models will throw; AI SDK models and \`LUNORA_AI_PROXY_URL\` slugs still work. Run \`wrangler login\` or set CLOUDFLARE_API_TOKEN to turn it on.`;export{u as STALE_DEV_CONFIG,g as createCleanup,v as describeWithheldWorkersAi,a as devConfigBasename,h as noopCleanup,f as sweepStaleDevConfigs,w as withheldWorkersAi,A as writeDevConfig};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{readFileSync as d,readdirSync as m}from"node:fs";import{homedir as L}from"node:os";import{join as r}from"node:path";const u=[".env",".env.local",".env.development",".env.development.local"],l=["CLOUDFLARE_API_TOKEN","CF_API_TOKEN"],f=["CLOUDFLARE_API_KEY","CF_API_KEY"],A=["CLOUDFLARE_EMAIL","CF_EMAIL"],v=new Set([...l,...f,...A]),O=/^export\s+/u,S=/\r?\n/u,p=/^(["'])(.*)\1$/u,E=t=>t!==void 0&&t.trim()!=="",C=(t,o)=>[o,t.XDG_CONFIG_HOME,r(o,"Library","Preferences"),r(o,".config"),t.APPDATA===void 0?void 0:r(t.APPDATA,"xdg.config"),r(o,"AppData","Roaming","xdg.config")].filter(s=>E(s)),I=t=>{try{return m(t).length>0}catch{return!1}},K=t=>{const o=new Set;for(const s of u){let n;try{n=d(r(t,s),"utf8")}catch{continue}for(const e of n.split(S)){const c=e.trim().replace(O,""),i=c.indexOf("=");if(c.startsWith("#")||i===-1)continue;const a=c.slice(0,i).trim(),_=c.slice(i+1).trim().replace(p,"$2");v.has(a)&&E(_)&&o.add(a)}}return o},F=(t={})=>{const o=t.env??process.env,s=t.projectRoot===void 0?new Set:K(t.projectRoot),n=e=>E(o[e])||s.has(e);return l.some(e=>n(e))||f.some(e=>n(e))&&A.some(e=>n(e))?!0:C(o,t.home??L()).some(e=>I(r(e,".wrangler","config")))};export{F as hasCloudflareCredentials};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{isAbsolute as f,dirname as p,resolve as m}from"node:path";import{applyModify as l}from"./applyModify-DKP2l6S9.mjs";import{hasCloudflareCredentials as h}from"./hasCloudflareCredentials-byvHpEiD.mjs";import{withheldWorkersAi as u,writeDevConfig as v}from"./describeWithheldWorkersAi-IIxe3TuI.mjs";import{readWranglerJsonc as w}from"./WRANGLER_FILES-UNW-xY5u.mjs";const g=(t,r)=>{const{parsed:e,text:n}=w(t),o=e?.build,c=u(e?.ai,r.hasCredentials??(()=>h({projectRoot:r.projectRoot}))),d=typeof o?.command=="string"&&o.command!==""&&!(typeof o.cwd=="string"&&f(o.cwd));if(!d&&c===void 0)return{configPath:t};const s=p(t);let i=n;c!==void 0&&(i=l(i,["ai"],void 0)),d&&(i=l(i,["build","cwd"],m(s,typeof o.cwd=="string"?o.cwd:".")));const a=v(s,"service",i);return{cleanup:a.cleanup,configPath:a.configPath,withheld:c}},j=(t,r)=>{const e=t.map(o=>g(o,r)),n=e.flatMap(o=>o.cleanup===void 0?[]:[o.cleanup]);return{cleanup:()=>{for(const o of n)o()},configPaths:e.map(o=>o.configPath),withheld:e.flatMap(o=>o.withheld===void 0?[]:[o.withheld])}};export{j as materializeServiceDevConfigs};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{i as g}from"./infer-bindings-BsgN5eCm.mjs";import{LUNORA_TAG as r}from"./LUNORA_TAG-CiQM3BkI.mjs";import{reconcileWranglerBindings as p}from"./collectExportGaps-BVb5JlSY.mjs";import{reconcileWranglerCompatibilityDate as $}from"./reconcileWranglerCompatibilityDate-hocXEuRA.mjs";import{reconcileWranglerCrons as m,describePreservedCrons as w}from"./describePreservedCrons-C5KPuPy3.mjs";const j=async(i,t,a)=>{try{const n=await g({projectRoot:i.projectRoot,schemaDir:i.schemaDir}),e=p(i.projectRoot,n,{target:i.target}),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=$(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};
|
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.336",
|
|
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.
|
|
57
|
+
"@lunora/codegen": "1.0.0-alpha.291",
|
|
58
58
|
"@lunora/container": "1.0.0-alpha.72",
|
|
59
59
|
"@lunora/errors": ">=1.0.0-alpha.51 <2.0.0-0",
|
|
60
|
-
"@lunora/seed": "1.0.0-alpha.
|
|
60
|
+
"@lunora/seed": "1.0.0-alpha.209",
|
|
61
61
|
"@visulima/colorize": "2.1.1",
|
|
62
62
|
"@visulima/find-ai-runner": "1.0.2",
|
|
63
63
|
"@visulima/fs": "6.0.29",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{writeFileSync as m,rmSync as b}from"node:fs";import{applyModify as g}from"./applyModify-DKP2l6S9.mjs";import{r as h}from"./lunora-manifest-DuH_Cmyu.mjs";import{o as y}from"./reconcile-services-DFqH4eMQ.mjs";import{findWranglerFile as S,readWranglerJsonc as v}from"./WRANGLER_FILES-UNW-xY5u.mjs";import{join as E}from"node:path";const l={ai:{label:"AI",shape:"object"},ai_search:{label:"AI Search",shape:"array"},ai_search_namespaces:{label:"AI Search namespace",shape:"array"},analytics:{label:"Analytics SQL",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"}},j=Object.keys(l),d=(e,r)=>typeof e.binding=="string"?e.binding:r,u=(e,r,n,a)=>{const s=[];for(const[o,t]of r.entries())t!=null&&s.push({binding:d(t,`#${String(o)}`),kind:n,path:[...a,o],section:e});return s},p=(e,r)=>l[e].shape===r,R=(e,r)=>{const{label:n}=l[e];if(p(e,"array"))return u(e,r[e]??[],n,[]);if(p(e,"object")){const a=r[e];return a==null?[]:[{binding:d(a,e),kind:n,path:[],section:e}]}return u(e,r.queues?.producers??[],n,["producers"])},_=e=>j.flatMap(r=>R(r,e)),B=(e,r)=>{let n=e;for(const a of r)n=g(n,[a.section,...a.path,"remote"],!0);return n},i=()=>{},I=e=>{let r=!1;return()=>{if(!r){r=!0;try{b(e,{force:!0,recursive:!0})}catch{}}}};let f=0;const C=()=>(f+=1,`.wrangler.lunora-remote.${String(process.pid)}.${String(f)}.jsonc`),O=e=>{if(!e.enabled)return{cleanup:i,enabled:!1,remoteBindings:[]};const r=S(e.projectRoot);if(!r)return{cleanup:i,enabled:!0,reason:"wrangler.jsonc not found",remoteBindings:[]};const{parsed:n,text:a}=v(r);if(n===void 0)return{cleanup:i,enabled:!0,reason:`failed to parse ${r} as JSONC`,remoteBindings:[]};const s=y(h(e.projectRoot)),o=_(n).filter(c=>c.section!=="services"||!s.has(c.binding));if(o.length===0)return{cleanup:i,enabled:!0,reason:"no remote-eligible bindings to proxy",remoteBindings:[]};const t=E(e.projectRoot,C());return m(t,B(a,o),"utf8"),{cleanup:I(t),configPath:t,enabled:!0,remoteBindings:o}},L=e=>{if(e===void 0)return!1;const r=e.trim().toLowerCase();return r==="1"||r==="true"},$=e=>e.flag===!0||L(e.envValue)?!0:e.configPreference??!1;export{l as REMOTE_ELIGIBLE_KEYS,I as createCleanup,B as injectRemoteFlags,L as isRemoteEnvEnabled,O as materializeRemoteWranglerConfig,_ as planRemoteBindings,$ as resolveRemoteEnabled};
|
|
@@ -1 +0,0 @@
|
|
|
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-BrOO_a0V.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};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as p}from"./infer-bindings-BsgN5eCm.mjs";import{LUNORA_TAG as r}from"./LUNORA_TAG-CiQM3BkI.mjs";import{reconcileWranglerBindings as $}from"./collectExportGaps-tpw0w4Oo.mjs";import{reconcileWranglerCompatibilityDate as g}from"./reconcileWranglerCompatibilityDate-hocXEuRA.mjs";import{reconcileWranglerCrons as m,describePreservedCrons as w}from"./describePreservedCrons-C5KPuPy3.mjs";const j=async(i,t,a)=>{try{const n=await p({projectRoot:i.projectRoot,schemaDir:i.schemaDir}),e=$(i.projectRoot,n,void 0,i.target),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};
|