@lunora/config 1.0.0-alpha.297 → 1.0.0-alpha.299
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 +18 -1
- package/dist/cloudflare/index.d.ts +18 -1
- package/dist/cloudflare/index.mjs +1 -1
- package/dist/packem_shared/{BINDING_MANIFEST_VERSION-CPGD7sr_.mjs → BINDING_MANIFEST_VERSION-CfXEYG8e.mjs} +1 -1
- package/dist/packem_shared/CLOUDFLARE_TOOLCHAIN_VERSIONS-Grzfm5p1.mjs +1 -0
- package/dist/packem_shared/{REQUIRED_COMPATIBILITY_DATE-Cosq9TDj.mjs → REQUIRED_COMPATIBILITY_DATE-Bv07Q3v8.mjs} +1 -1
- package/dist/packem_shared/{UNEXPORTED_CLASS_MARKER-C8AFIY8C.mjs → UNEXPORTED_CLASS_MARKER-s6wTR8W1.mjs} +1 -1
- package/dist/packem_shared/{assertWranglerSatisfiesSchema-CfrY1Lal.mjs → assertWranglerSatisfiesSchema-BBQ2zkZy.mjs} +1 -1
- package/dist/packem_shared/collectExportGaps-qqrrR5x_.mjs +2 -0
- package/dist/packem_shared/mergeWranglerEnvironment-DXiB-HcS.mjs +1 -0
- package/dist/packem_shared/{reconcileBindingsSafely-BU5PpS1F.mjs → reconcileBindingsSafely-BRyb_65W.mjs} +1 -1
- package/dist/packem_shared/{wranglerToAlchemy-Bpfy1abZ.mjs → wranglerToAlchemy-CBO2ucRm.mjs} +1 -1
- package/package.json +3 -3
- package/dist/packem_shared/collectExportGaps-BEkTtsyv.mjs +0 -2
- package/dist/packem_shared/mergeWranglerEnvironment-KtP_NGVx.mjs +0 -1
|
@@ -711,6 +711,22 @@ interface ServiceDevConfigs {
|
|
|
711
711
|
* in the app's folder (see the module doc).
|
|
712
712
|
*/
|
|
713
713
|
declare const materializeServiceDevConfigs: (wranglerPaths: ReadonlyArray<string>) => ServiceDevConfigs;
|
|
714
|
+
/**
|
|
715
|
+
* The Cloudflare toolchain ranges a scaffolded Lunora app declares — the one
|
|
716
|
+
* source for `lunora init`'s overlay. The `templates/*` starters are fetched at
|
|
717
|
+
* runtime and cannot import this, so `tests/vis-templates` asserts that every
|
|
718
|
+
* template declaring one of these packages declares exactly this range.
|
|
719
|
+
*
|
|
720
|
+
* `@cloudflare/workers-types` is on the v5 line: v4 ended at 4.20260702.1, and
|
|
721
|
+
* v5's root entrypoint is the latest runtime (AI Search, Artifacts, Analytics
|
|
722
|
+
* SQL, tracing `setStatus`). `wrangler` >= 4.145.0 accepts the Analytics SQL
|
|
723
|
+
* `analytics` binding that `ctx.analyticsSql` makes `lunora dev` write, and
|
|
724
|
+
* >= 4.142.0 declares and runs Workflows in `exports`, which codegen writes.
|
|
725
|
+
* `@cloudflare/vite-plugin` matches the wrangler it embeds.
|
|
726
|
+
*
|
|
727
|
+
* Bump it together with the `cloudflare` / `vite` catalogs in `pnpm-workspace.yaml`.
|
|
728
|
+
*/
|
|
729
|
+
declare const CLOUDFLARE_TOOLCHAIN_VERSIONS: Readonly<Record<"@cloudflare/vite-plugin" | "@cloudflare/workers-types" | "wrangler", string>>;
|
|
714
730
|
/** The `wrangler.jsonc` shape the validator reads, and the report it returns. */
|
|
715
731
|
interface WranglerDurableObjectBinding {
|
|
716
732
|
class_name?: string;
|
|
@@ -926,6 +942,7 @@ interface WranglerConfig {
|
|
|
926
942
|
images?: {
|
|
927
943
|
binding?: string;
|
|
928
944
|
};
|
|
945
|
+
k2?: ReadonlyArray<unknown>;
|
|
929
946
|
kv_namespaces?: ReadonlyArray<{
|
|
930
947
|
binding?: string;
|
|
931
948
|
id?: string;
|
|
@@ -1169,7 +1186,7 @@ declare const validateWranglerConfig: (wranglerInput: WranglerConfig | undefined
|
|
|
1169
1186
|
* `{ valid, errors, warnings }`.
|
|
1170
1187
|
*/
|
|
1171
1188
|
declare const validateWrangler: typeof validateWranglerConfig;
|
|
1172
|
-
export { type AlchemyTranslation, type AssertWranglerOptions, BINDING_MANIFEST_VERSION, type BindingManifest, type BindingRequirement, CLOUDFLARE_DRIVER, DEFAULT_OBSERVABILITY, type ExportGap, GLOBAL_FETCH_STRICTLY_PUBLIC_FLAG, type ManifestConfigShape, type MaterializeOptions, type MaterializeResult, 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 WranglerConfig, type WranglerConfigShape, type WranglerContainerEntry, type WranglerEnvironmentMerge, type WranglerObservability, type WranglerObservabilityLogs, type WranglerObservabilityTraces, type WranglerProjectValidationOptions, type WranglerProjectValidationResult, type WranglerValidationReport, type WranglerWorkflowEntry,
|
|
1189
|
+
export { type AlchemyTranslation, type AssertWranglerOptions, BINDING_MANIFEST_VERSION, type BindingManifest, type BindingRequirement, CLOUDFLARE_DRIVER, CLOUDFLARE_TOOLCHAIN_VERSIONS, DEFAULT_OBSERVABILITY, type ExportGap, GLOBAL_FETCH_STRICTLY_PUBLIC_FLAG, type ManifestConfigShape, type MaterializeOptions, type MaterializeResult, 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 WranglerConfig, type WranglerConfigShape, type WranglerContainerEntry, type WranglerEnvironmentMerge, type WranglerObservability, type WranglerObservabilityLogs, type WranglerObservabilityTraces, type WranglerProjectValidationOptions, type WranglerProjectValidationResult, type WranglerValidationReport, type WranglerWorkflowEntry,
|
|
1173
1190
|
/**
|
|
1174
1191
|
* `@lunora/config/cloudflare` — the wrangler layer.
|
|
1175
1192
|
*
|
|
@@ -711,6 +711,22 @@ interface ServiceDevConfigs {
|
|
|
711
711
|
* in the app's folder (see the module doc).
|
|
712
712
|
*/
|
|
713
713
|
declare const materializeServiceDevConfigs: (wranglerPaths: ReadonlyArray<string>) => ServiceDevConfigs;
|
|
714
|
+
/**
|
|
715
|
+
* The Cloudflare toolchain ranges a scaffolded Lunora app declares — the one
|
|
716
|
+
* source for `lunora init`'s overlay. The `templates/*` starters are fetched at
|
|
717
|
+
* runtime and cannot import this, so `tests/vis-templates` asserts that every
|
|
718
|
+
* template declaring one of these packages declares exactly this range.
|
|
719
|
+
*
|
|
720
|
+
* `@cloudflare/workers-types` is on the v5 line: v4 ended at 4.20260702.1, and
|
|
721
|
+
* v5's root entrypoint is the latest runtime (AI Search, Artifacts, Analytics
|
|
722
|
+
* SQL, tracing `setStatus`). `wrangler` >= 4.145.0 accepts the Analytics SQL
|
|
723
|
+
* `analytics` binding that `ctx.analyticsSql` makes `lunora dev` write, and
|
|
724
|
+
* >= 4.142.0 declares and runs Workflows in `exports`, which codegen writes.
|
|
725
|
+
* `@cloudflare/vite-plugin` matches the wrangler it embeds.
|
|
726
|
+
*
|
|
727
|
+
* Bump it together with the `cloudflare` / `vite` catalogs in `pnpm-workspace.yaml`.
|
|
728
|
+
*/
|
|
729
|
+
declare const CLOUDFLARE_TOOLCHAIN_VERSIONS: Readonly<Record<"@cloudflare/vite-plugin" | "@cloudflare/workers-types" | "wrangler", string>>;
|
|
714
730
|
/** The `wrangler.jsonc` shape the validator reads, and the report it returns. */
|
|
715
731
|
interface WranglerDurableObjectBinding {
|
|
716
732
|
class_name?: string;
|
|
@@ -926,6 +942,7 @@ interface WranglerConfig {
|
|
|
926
942
|
images?: {
|
|
927
943
|
binding?: string;
|
|
928
944
|
};
|
|
945
|
+
k2?: ReadonlyArray<unknown>;
|
|
929
946
|
kv_namespaces?: ReadonlyArray<{
|
|
930
947
|
binding?: string;
|
|
931
948
|
id?: string;
|
|
@@ -1169,7 +1186,7 @@ declare const validateWranglerConfig: (wranglerInput: WranglerConfig | undefined
|
|
|
1169
1186
|
* `{ valid, errors, warnings }`.
|
|
1170
1187
|
*/
|
|
1171
1188
|
declare const validateWrangler: typeof validateWranglerConfig;
|
|
1172
|
-
export { type AlchemyTranslation, type AssertWranglerOptions, BINDING_MANIFEST_VERSION, type BindingManifest, type BindingRequirement, CLOUDFLARE_DRIVER, DEFAULT_OBSERVABILITY, type ExportGap, GLOBAL_FETCH_STRICTLY_PUBLIC_FLAG, type ManifestConfigShape, type MaterializeOptions, type MaterializeResult, 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 WranglerConfig, type WranglerConfigShape, type WranglerContainerEntry, type WranglerEnvironmentMerge, type WranglerObservability, type WranglerObservabilityLogs, type WranglerObservabilityTraces, type WranglerProjectValidationOptions, type WranglerProjectValidationResult, type WranglerValidationReport, type WranglerWorkflowEntry,
|
|
1189
|
+
export { type AlchemyTranslation, type AssertWranglerOptions, BINDING_MANIFEST_VERSION, type BindingManifest, type BindingRequirement, CLOUDFLARE_DRIVER, CLOUDFLARE_TOOLCHAIN_VERSIONS, DEFAULT_OBSERVABILITY, type ExportGap, GLOBAL_FETCH_STRICTLY_PUBLIC_FLAG, type ManifestConfigShape, type MaterializeOptions, type MaterializeResult, 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 WranglerConfig, type WranglerConfigShape, type WranglerContainerEntry, type WranglerEnvironmentMerge, type WranglerObservability, type WranglerObservabilityLogs, type WranglerObservabilityTraces, type WranglerProjectValidationOptions, type WranglerProjectValidationResult, type WranglerValidationReport, type WranglerWorkflowEntry,
|
|
1173
1190
|
/**
|
|
1174
1191
|
* `@lunora/config/cloudflare` — the wrangler layer.
|
|
1175
1192
|
*
|
|
@@ -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 t}from"../packem_shared/assertWranglerSatisfiesSchema-BBQ2zkZy.mjs";import{BINDING_MANIFEST_VERSION as n,buildBindingManifest as i}from"../packem_shared/BINDING_MANIFEST_VERSION-CfXEYG8e.mjs";import{default as E}from"../packem_shared/CLOUDFLARE_DRIVER-Ci3VIqnk.mjs";import{default as s}from"../packem_shared/GLOBAL_FETCH_STRICTLY_PUBLIC_FLAG-f8CnJha3.mjs";import{collectExportGaps as c,reconcileWranglerBindings as g}from"../packem_shared/collectExportGaps-qqrrR5x_.mjs";import{reconcileWranglerCompatibilityDate as x}from"../packem_shared/reconcileWranglerCompatibilityDate-hocXEuRA.mjs";import{describePreservedCrons as I,reconcileWranglerCrons as d}from"../packem_shared/describePreservedCrons-7gaDLxWx.mjs";import{reconcileBindingsSafely as C,reconcileWranglerExtras as S}from"../packem_shared/reconcileBindingsSafely-BRyb_65W.mjs";import{REMOTE_ELIGIBLE_KEYS as W,injectRemoteFlags as T,isRemoteEnvEnabled as O,materializeRemoteWranglerConfig as D,planRemoteBindings as v,resolveRemoteEnabled as B}from"../packem_shared/REMOTE_ELIGIBLE_KEYS-DioKi8jL.mjs";import{materializeServiceDevConfigs as b}from"../packem_shared/materializeServiceDevConfigs-VcqRp-kv.mjs";import{default as G}from"../packem_shared/CLOUDFLARE_TOOLCHAIN_VERSIONS-Grzfm5p1.mjs";import{withTailConsumer as U}from"../packem_shared/withTailConsumer-BZqzeKYh.mjs";import{WORKERS_CACHE_MIN_DATE as V,isCacheEnabled as u}from"../packem_shared/WORKERS_CACHE_MIN_DATE-0k9ABJtF.mjs";import{DEFAULT_OBSERVABILITY as h,resolveObservabilitySampling as Y}from"../packem_shared/DEFAULT_OBSERVABILITY-bN6UkTMx.mjs";import{mergeWranglerEnvironment as K}from"../packem_shared/mergeWranglerEnvironment-DXiB-HcS.mjs";import{WRANGLER_FILES as w,findWranglerFile as z,readWranglerJsonc as Q}from"../packem_shared/WRANGLER_FILES-UNW-xY5u.mjs";import{UNEXPORTED_CLASS_MARKER as X,validateWranglerProject as k}from"../packem_shared/UNEXPORTED_CLASS_MARKER-s6wTR8W1.mjs";import{collectWranglerSecretVariables as Z,scanWranglerVariablesForSecrets as $}from"../packem_shared/collectWranglerSecretVariables-D-usPfT8.mjs";import{wranglerToAlchemy as re}from"../packem_shared/wranglerToAlchemy-CBO2ucRm.mjs";import{REQUIRED_COMPATIBILITY_DATE as ae,REQUIRED_FLAG as te,validateWrangler as le,validateWranglerConfig as ne}from"../packem_shared/REQUIRED_COMPATIBILITY_DATE-Bv07Q3v8.mjs";export{n as BINDING_MANIFEST_VERSION,E as CLOUDFLARE_DRIVER,G as CLOUDFLARE_TOOLCHAIN_VERSIONS,h as DEFAULT_OBSERVABILITY,s as GLOBAL_FETCH_STRICTLY_PUBLIC_FLAG,W as REMOTE_ELIGIBLE_KEYS,ae as REQUIRED_COMPATIBILITY_DATE,te as REQUIRED_FLAG,X as UNEXPORTED_CLASS_MARKER,V as WORKERS_CACHE_MIN_DATE,w as WRANGLER_FILES,o as applyModify,t as assertWranglerSatisfiesSchema,i as buildBindingManifest,c as collectExportGaps,Z as collectWranglerSecretVariables,I as describePreservedCrons,z as findWranglerFile,T as injectRemoteFlags,u as isCacheEnabled,O as isRemoteEnvEnabled,D as materializeRemoteWranglerConfig,b as materializeServiceDevConfigs,K as mergeWranglerEnvironment,v as planRemoteBindings,Q as readWranglerJsonc,C as reconcileBindingsSafely,g as reconcileWranglerBindings,x as reconcileWranglerCompatibilityDate,d as reconcileWranglerCrons,S as reconcileWranglerExtras,Y as resolveObservabilitySampling,B as resolveRemoteEnabled,$ as scanWranglerVariablesForSecrets,le as validateWrangler,ne as validateWranglerConfig,k as validateWranglerProject,U as withTailConsumer,re as wranglerToAlchemy};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{sqliteClasses as l}from"./wranglerToAlchemy-
|
|
1
|
+
import{sqliteClasses as l}from"./wranglerToAlchemy-CBO2ucRm.mjs";const p=1,u=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)),d=[{bindingKey:"binding",field:"ai_search",resourceKey:"instance_name",type:"ai_search"},{bindingKey:"binding",field:"ai_search_namespaces",resourceKey:"namespace",type:"ai_search_namespace"},{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:"analytics",type:"analytics_sql"},{field:"assets",type:"assets"},{field:"browser",type:"browser"},{field:"images",type:"images"},{field:"media",type:"media"},{field:"stream",type:"stream"}],b=new Set([...d.map(e=>e.field),...c.map(e=>e.field),"durable_objects","exports","queues"]),a=(e,n)=>(typeof n=="string"?[n]:n??[]).map(i=>e[i]).find(i=>typeof i=="string"&&i!==""),m=(e,n)=>{const s=[];for(const i of d)for(const r of e[i.field]??[]){const t=a(r,i.bindingKey);if(t===void 0){n.push(i.field);continue}s.push({binding:t,className:a(r,"class_name"),resource:a(r,i.resourceKey),resourceId:a(r,i.resourceIdKey),type:i.type})}return s},_=(e,n)=>{const s=l(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?s.has(r.class_name):void 0,type:"durable_object"})}return i},g=(e,n)=>{const s=[];for(const i of e.queues?.producers??[]){if(i.binding===void 0||i.binding===""){n.push("queues.producers");continue}s.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}s.push({binding:i.queue,resource:i.queue,type:"queue_consumer"})}return s},f=(e,n)=>Object.entries(e.exports??{}).flatMap(([s,i])=>i?.type!=="workflow"?(n.push(`exports.${s}`),[]):[{binding:s,className:s,resource:i.name,type:"workflow"}]),v=(e,n,s)=>[...f(e,s),...m(e,n),..._(e,n),...g(e,n),...c.filter(i=>e[i.field]?.binding!==void 0).map(i=>({binding:e[i.field]?.binding,type:i.type}))],h=e=>{const n=[],s=[],i=v(e,n,s).map(t=>y(t)).toSorted((t,o)=>t.type.localeCompare(o.type)||t.binding.localeCompare(o.binding)),r=[...Object.keys(e).filter(t=>!u.has(t)&&!b.has(t)),...n.map(t=>`${t} (entry with no binding name)`),...s].toSorted((t,o)=>t.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((t,o)=>t.localeCompare(o)),version:p}};export{p as BINDING_MANIFEST_VERSION,h as buildBindingManifest};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e={"@cloudflare/vite-plugin":"^1.62.4","@cloudflare/workers-types":"^5.20261002.1",wrangler:"^4.146.0"};export{e as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as m,v as h,a as E,b as p,c as D,d as y,e as l,f as I,g as O,H as R,h as S,R as $,S as j,i as A,j as k,W as L,k as w}from"./validate-bindings-DFAcr5wA.mjs";import{validateTailConsumers as B,validateSendEmail as T,validateSecretsRequired as N,validateLogpush as C,validateLimits as U,validatePlacement as P,validateObservability as G,validateAssets as K,validateCache as V,validateExports as W,validateCorsVariables as x,validateSchedulerOrigin as F}from"./withTailConsumer-BZqzeKYh.mjs";import{isCacheEnabled as H,WORKERS_CACHE_MIN_DATE as _}from"./WORKERS_CACHE_MIN_DATE-0k9ABJtF.mjs";import{mergeWranglerEnvironment as M}from"./mergeWranglerEnvironment-
|
|
1
|
+
import{o as m,v as h,a as E,b as p,c as D,d as y,e as l,f as I,g as O,H as R,h as S,R as $,S as j,i as A,j as k,W as L,k as w}from"./validate-bindings-DFAcr5wA.mjs";import{validateTailConsumers as B,validateSendEmail as T,validateSecretsRequired as N,validateLogpush as C,validateLimits as U,validatePlacement as P,validateObservability as G,validateAssets as K,validateCache as V,validateExports as W,validateCorsVariables as x,validateSchedulerOrigin as F}from"./withTailConsumer-BZqzeKYh.mjs";import{isCacheEnabled as H,WORKERS_CACHE_MIN_DATE as _}from"./WORKERS_CACHE_MIN_DATE-0k9ABJtF.mjs";import{mergeWranglerEnvironment as M}from"./mergeWranglerEnvironment-DXiB-HcS.mjs";const Y=i=>typeof i=="object"&&i!==null&&!Array.isArray(i),f=i=>Array.isArray(i)?i.flatMap((a,n)=>Y(a)?[[n,a]]:[]):[],g=i=>typeof i.binding=="string"?i.binding:"",q=(i,a,n)=>{for(const[e,s]of f(i.kv_namespaces))typeof s.id=="string"&&s.id!==""||n.push(`kv_namespaces[${String(e)}] ("${g(s)}") is not created yet and the schema pins data to "${a}" — create it with \`wrangler kv namespace create <name> --jurisdiction=${a}\`; a namespace's jurisdiction cannot be changed afterwards`)},Q=(i,a,n)=>{for(const[e,s]of f(i.r2_buckets)){const r=s.jurisdiction;if(r===a)continue;const t=typeof r=="string"?`names the "${r}" jurisdiction`:"names no jurisdiction";n.push(`r2_buckets[${String(e)}] ("${g(s)}") ${t}, but the schema pins data to "${a}" — create the bucket with \`wrangler r2 bucket create <name> --jurisdiction=${a}\` and set "jurisdiction": "${a}" on the binding`)}},J=(i,a,n)=>{const e=a?.jurisdiction;e!==void 0&&(q(i,e,n),Q(i,e,n))},b="2026-04-07",de="web_socket_auto_reply_to_close",u="2026-10-01",v="durable_object_io_tasks_prevent_eviction",z="durable_object_io_tasks_do_not_prevent_eviction",X=/^\d{4}-\d{2}-\d{2}$/,Z=(i,a,n)=>{i>=u||a.includes(v)||a.includes(z)||n.push(`compatibility_date "${i}" predates "${u}", so pending I/O (waitUntil, cross-Durable-Object RPC, service-binding calls, timers) does not keep a Durable Object alive once its last client disconnects — live-query refreshes and durable streams can be cut off mid-flight. Set compatibility_date >= "${u}" or add the "${v}" compatibility flag`)},ee=(i,a,n)=>{const{error:e,merged:s,unverifiedKeys:r}=M(i,a);return e!==void 0?{error:e,wrangler:s}:(r.length>0&&n.push(`env.${String(a)} overrides ${r.join(", ")}, which this validator doesn't have a verified inheritance rule for — validated against the TOP-LEVEL value only. Double-check ${r.length===1?"it":"them"} by hand for "${String(a)}".`),{wrangler:s})},te=(i,a,n)=>{const e=[],s=[];if(!i||typeof i!="object")return e.push("wrangler config is not a valid object"),{errors:e,valid:!1,warnings:s};const{error:r,wrangler:t}=ee(i,n,s);if(r!==void 0)return e.push(r),{errors:e,valid:!1,warnings:s};m(t.durable_objects?.bindings).find(o=>o.name==="SHARD"&&o.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'),h(t,e);const d=t.compatibility_date??"",c=X.test(d);d&&!c?e.push(`compatibility_date must be in YYYY-MM-DD format (got "${d}")`):d<b&&e.push(`compatibility_date must be >= "${b}" (got "${d||"<missing>"}")`),H(t)&&c&&d<_&&e.push(`cache.enabled requires compatibility_date >= "${_}" (got "${d||"<missing>"}")`),c&&Z(d,t.compatibility_flags??[],s),E(t,a,e),J(t,a,s),p(t,e),D(t,a?.vectorIndexNames??[],e),B(t,e),y(t,e,s),l(t.workflows,"workflows",L,e),I(t,e),O(t,e),l(t.secrets_store_secrets,"secrets_store_secrets",w,e);for(const o of R)S(t,o,e,s);for(const o of $)l(t[o.key],o.key,o,e);for(const o of j)A(t,o,e);return k(t,e),T(t,e,s),N(t,e),C(t,e),U(t,e),P(t,e),G(t,e,s),K(t,e),V(t,e),W(t,e),x(t,e),F(t,n,s),{errors:e,valid:e.length===0,warnings:s}},ce=te;export{b as REQUIRED_COMPATIBILITY_DATE,de as REQUIRED_FLAG,ce as validateWrangler,te as validateWranglerConfig};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{existsSync as d}from"node:fs";import{dirname as u,join as h}from"node:path";import{discoverSchemaInfo as v}from"./discoverSchemaInfo-BguahM6z.mjs";import{COMPOSED_ENTRY_DURABLE_OBJECTS as y,GENERATED_CLASS_MODULES as w,isFrameworkDurableObject as E}from"./COMPOSED_WORKER_ENTRY-C69wqbSP.mjs";import{o as $}from"./validate-bindings-DFAcr5wA.mjs";import{l as k,r as x,s as j}from"./worker-entry-checks-9Vdz4d2f.mjs";import{mergeWranglerEnvironment as D}from"./mergeWranglerEnvironment-
|
|
1
|
+
import{existsSync as d}from"node:fs";import{dirname as u,join as h}from"node:path";import{discoverSchemaInfo as v}from"./discoverSchemaInfo-BguahM6z.mjs";import{COMPOSED_ENTRY_DURABLE_OBJECTS as y,GENERATED_CLASS_MODULES as w,isFrameworkDurableObject as E}from"./COMPOSED_WORKER_ENTRY-C69wqbSP.mjs";import{o as $}from"./validate-bindings-DFAcr5wA.mjs";import{l as k,r as x,s as j}from"./worker-entry-checks-9Vdz4d2f.mjs";import{mergeWranglerEnvironment as D}from"./mergeWranglerEnvironment-DXiB-HcS.mjs";import{findWranglerFile as A,readWranglerJsonc as R}from"./WRANGLER_FILES-UNW-xY5u.mjs";import{validateWranglerConfig as W}from"./REQUIRED_COMPATIBILITY_DATE-Bv07Q3v8.mjs";const b=r=>Array.isArray(r)?r:[],_=(r,s,o)=>Object.entries(r?.images??{}).flatMap(([t,n])=>{const e=n?.dockerfile;return typeof e!="string"||d(e.startsWith("/")?e:h(s,e))?[]:[`containers images["${t}"] dockerfile "${e}" does not exist (resolved relative to ${o}); create the Dockerfile`]}),S=(r,s,o)=>{const t=[];for(const n of b(r)){const e=n?.image;typeof e=="string"&&(e.startsWith("./")||e.startsWith("../")||e.startsWith("/")||e.includes("Dockerfile"))&&!d(e.startsWith("/")?e:h(s,e))&&t.push(`containers image "${e}" does not exist (resolved relative to ${o}); create the Dockerfile or point image at a registry reference`),t.push(..._(n,s,o))}return t},N=(r,s)=>{const o=r?.vectorIndexNames??[],t=[];if(o.length>0&&t.push({message:e=>`schema declares vector index(es) ${o.map(i=>`"${i}"`).join(", ")} but nothing chains .vectors(...) onto defineApp() (composed in: ${e}) — \`ctx.vectors\` is then a throwing stub and buildWorkerOptions rejects EVERY request, /_lunora/health included. Add \`.vectors((env) => ({ ${String(o[0])}: env.<BINDING> }))\` to the chain.`,method:"vectors"}),r?.hasD1GlobalTable&&t.push({message:e=>`schema declares .global() table(s) but nothing chains .global(...) onto defineApp() (composed in: ${e}) — 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"}),r?.hasHyperdriveGlobalTable&&t.push({message:e=>`schema declares .global({ backend: "hyperdrive" }) table(s) but nothing chains .hyperdriveGlobal(...) onto defineApp() (composed in: ${e}) — 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"}),t.length===0)return[];const n=j(s,new Set(t.map(e=>e.method)));return n===void 0?[]:t.filter(e=>!n.chained.has(e.method)).map(e=>e.message(n.site))},O="does not export it",P=(r,s)=>{if(s!=="composed")return`Re-export it from the module that defines it (\`export { ${r} } from "./…";\`), or add it to the app builder's own export (\`export const { ${r} } = app;\`).`;const o=`it exports ${y.join(", ")}, SchedulerDO when its binding is declared, and every class codegen emits from your ${w.map(t=>`${t}.ts`).join(" / ")} declarations`;return E(r)?`\`@lunora/vite\` generates that entry — ${o}, and ${r} is not among them. Class-A composition does not carry ${r}, 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: ${o}. Declare "${r}" in one of those and re-run \`lunora codegen\`, or drop the binding.`},C=(r,s)=>{const o=s.exports;if(o===void 0)return[];const t=[];for(const e of $(r.durable_objects?.bindings))typeof e.class_name=="string"&&e.class_name.length>0&&e.script_name===void 0&&t.push({className:e.class_name,label:"durable_objects.bindings"});for(const e of b(r.workflows))typeof e?.class_name=="string"&&e.class_name.length>0&&e.script_name===void 0&&t.push({className:e.class_name,label:"workflows"});for(const[e,i]of Object.entries(r.exports??{}))i?.type==="workflow"&&t.push({className:e,label:"workflows"});return t.filter(e=>!o.has(e.className)).map(e=>`${e.label} declares class "${e.className}" but the ${s.kind==="composed"?"composed class-A worker entry":"worker entry"} (${s.path}) ${O} — wrangler refuses to bundle a Worker whose ${e.label==="workflows"?"Workflow":"Durable Object"} classes are not exported. ${P(e.className,s.kind)}`)},I=r=>r?.origin!=="absent"?[]:[`main is set but no readable file is there (looked in ${r.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.`],H=r=>{const s=r.schemaDir??"lunora",o=A(r.projectRoot);if(!o){const l=`wrangler.jsonc not found in ${r.projectRoot}; create one declaring at least the SHARD durable object binding.`;return{problems:[l],report:{errors:[l],valid:!1,warnings:[]},wranglerPath:void 0}}const{parsed:t}=R(o);if(t===void 0){const l=`failed to parse ${o} as JSONC.`;return{problems:[l],report:{errors:[l],valid:!1,warnings:[]},wranglerPath:o}}const{error:n,merged:e}=D(t,r.environment);if(n!==void 0)return{problems:[n],report:{errors:[n],valid:!1,warnings:[]},wranglerPath:o};const{error:i,info:p}=v(r.projectRoot,s),a=W(t,p,r.environment);i!==void 0&&a.warnings.push(`schema parse failed in ${s}/schema.ts: ${i}`);const m=u(o),f=k(e.main,r.projectRoot,o),g=x(f,r.projectRoot,s);a.errors.push(...S(e.containers??[],m,o)),a.warnings.push(...I(f)),g!==void 0&&a.errors.push(...C(e,g)),a.errors.push(...N(p,r.projectRoot));const c=e.assets?.directory;if(typeof c=="string"&&c.length>0){const l=c.startsWith("/")?c:h(m,c);d(l)||a.warnings.push(`assets.directory "${c}" does not exist yet — it is created by the client build; run the build before deploy`)}return a.valid=a.errors.length===0,{problems:a.errors,report:a,wranglerPath:o}};export{O as UNEXPORTED_CLASS_MARKER,H as validateWranglerProject};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{LunoraError as n}from"@lunora/errors";import{lunoraLine as i}from"./LUNORA_TAG-CiQM3BkI.mjs";import{validateWranglerProject as l}from"./UNEXPORTED_CLASS_MARKER-
|
|
1
|
+
import{LunoraError as n}from"@lunora/errors";import{lunoraLine as i}from"./LUNORA_TAG-CiQM3BkI.mjs";import{validateWranglerProject as l}from"./UNEXPORTED_CLASS_MARKER-s6wTR8W1.mjs";const m=(e,a,t)=>{const r=l({projectRoot:e.projectRoot,schemaDir:e.schemaDir});if(!r.wranglerPath)throw new n("INTERNAL",["[lunora] wrangler.jsonc not found.",` searched in: ${e.projectRoot}`," create a wrangler.jsonc declaring at least the SHARD durable object binding."].join(`
|
|
2
2
|
`));for(const o of r.report.warnings)a(i(`wrangler validator: ${o}`));if(r.problems.length>0)throw new n("INTERNAL",["[lunora] wrangler configuration is missing bindings required by your schema.",` file: ${r.wranglerPath}`,"",...r.problems.map(o=>` - ${o}`),"",` ${t}`].join(`
|
|
3
3
|
`))};export{m as assertWranglerSatisfiesSchema};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{readFileSync as F,writeFileSync as X}from"node:fs";import{createRequire as z}from"node:module";import{join as Q}from"node:path";import{containerBuildTag as Z}from"@lunora/container";import{applyModify as S}from"./applyModify-DKP2l6S9.mjs";import{a as ee,r as M}from"./lunora-manifest-v90ZUbVp.mjs";import{parseTree as ne,findNodeAtLocation as se}from"jsonc-parser";import{r as te,a as oe,b as ie,c as re}from"./reconcile-services-3dn35zgy.mjs";import{a as ae,p as de}from"./infer-bindings-B-BFynp2.mjs";import{DEV_VARS_FILE as ce,parseDevVariableEntries as le}from"./DEV_VARS_EXAMPLE_FILE-CqLorAxT.mjs";import{requiredSecrets as ue}from"./buildPackageSecretsBlock-yv9mjKEW.mjs";import{w as ge,n as me,s as Y,o as B,p as j,q as pe}from"./validate-bindings-DFAcr5wA.mjs";import{s as fe}from"./worker-entry-checks-9Vdz4d2f.mjs";import{DEFAULT_OBSERVABILITY as be}from"./DEFAULT_OBSERVABILITY-bN6UkTMx.mjs";import{findWranglerFile as he,readWranglerJsonc as we}from"./WRANGLER_FILES-UNW-xY5u.mjs";const ve=[["maxBatchSize","max_batch_size"],["maxBatchTimeout","max_batch_timeout"],["maxRetries","max_retries"],["deadLetterQueue","dead_letter_queue"],["retryDelay","retry_delay"]],R=e=>Object.fromEntries(ve.filter(([n])=>e.tuning[n]!==void 0).map(([n,s])=>[s,e.tuning[n]])),P="queueTuning",_e=/^[\t ]*(?:,[\t ]*)?(?:\/\/[^\n\r]*)?\r?\n/u,ye=/^[\t ]*,/u,Se=(e,n)=>{const s=ne(e),t=s===void 0?void 0:se(s,[...n])?.parent;if(t?.type==="property"){const i=t.offset+t.length,o=e.lastIndexOf(`
|
|
2
|
+
`,t.offset-1)+1,d=_e.exec(e.slice(i));if(d!==null&&e.slice(o,t.offset).trim()===""){const a=t.parent?.children??[],b=a.indexOf(t),c=b===a.length-1&&b>0?a[b-1]:void 0,l=c===void 0?void 0:ye.exec(e.slice(c.offset+c.length))??void 0;return(l===void 0||c===void 0?e.slice(0,o):e.slice(0,c.offset+c.length)+e.slice(c.offset+c.length+l[0].length,o))+e.slice(i+d[0].length)}}return S(e,n,void 0)},G=(e,n,s,t,i,o=new Set)=>{const d=s.join("."),a={},b=[],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 p=Object.fromEntries(Object.entries(R(g)).filter(([f])=>!o.has(f))),h=Object.entries(i[u.queue]??{}).filter(([f])=>!Object.hasOwn(p,f)),v=Object.entries(p).filter(([f,y])=>u[f]!==y),x=h.filter(([f,y])=>u[f]===y).map(([f])=>f),N=Object.fromEntries(Object.entries({...u,...p}).filter(([f])=>!x.includes(f)));for(const[f,y]of v)l=S(l,[...s,w,f],y);for(const f of x)l=Se(l,[...s,w,f]);for(const[f,y]of h){const E=u[f];E!==void 0&&E!==y&&c.push(`${d}/${u.queue}: ${f} is no longer declared by defineQueue, but it was changed by hand to ${JSON.stringify(E)} from the declared ${JSON.stringify(y)}, so it was kept. Delete it from wrangler.jsonc if it should go.`)}return(v.length>0||x.length>0)&&b.push(`${d}/${u.queue} (${[...v.map(([f])=>f),...x.map(f=>`removed ${f}`)].join(", ")})`),Object.keys(p).length>0&&(a[u.queue]=p),N}),owned:a,text:l,updated:b,warnings:c}},xe=(e,n,s,t)=>{const i=n.queues??{},o=i.producers??[],d=i.consumers??[],a=new Set(o.map(g=>g.binding)),b=new Set(d.map(g=>g.queue)),c=s.filter(g=>!a.has(g.bindingName)),l=s.filter(g=>!b.has(g.name)),m=G(e,d,["queues","consumers"],g=>s.find(p=>p.name===g.queue),t);let u=m.text;const w={...m.owned};if(c.length>0||l.length>0){const g=[...o,...c.map(h=>({binding:h.bindingName,queue:h.name}))],p=[...m.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:p,producers:g})}return{added:[...c.map(g=>`queues.producers/${g.bindingName}`),...l.map(g=>`queues.consumers/${g.name}`)],owned:w,text:u,updated:m.updated,warnings:m.warnings}},Ne=(e,n,s,t,i)=>{const o=n.env?.[t],d=o?.queues?.consumers??[],a=o?.queues?.producers??[],b=u=>{const w=a.find(g=>g.queue===u.queue)?.binding;return w!==void 0?s.find(g=>g.bindingName===w):s.find(g=>g.name===u.queue&&!a.some(p=>p.binding===g.bindingName))},c=G(e,d,["env",t,"queues","consumers"],b,i,new Set(["dead_letter_queue"])),l=d.filter(u=>u.queue!==void 0&&b(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.`),m=d.flatMap(u=>{const w=b(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,...m,...l]}},Oe=(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=i=>typeof i=="object"&&i!==null&&!Array.isArray(i);return s===void 0?{}:!t(s)||!Object.values(s).every(i=>t(i)&&Object.values(i).every(o=>t(o)))?(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},Ee=(e,n,s)=>{const t=Object.fromEntries(Object.entries({...n,...s}).filter(([,i])=>Object.keys(i).length>0));ee(e,P,Object.keys(t).length===0?void 0:t)},C="PIPELINES",I="ARTIFACTS",ke=(e,n)=>{const s=e.flagshipBinding!==void 0&&!(n?.flagship??[]).some(a=>a.binding===e.flagshipBinding),t=e.usesPipelines&&!(n?.pipelines??[]).some(a=>a.binding===C),i=e.usesArtifacts?n?.artifacts??[]:[],o=i.some(a=>a.binding===I)?[]:i.flatMap(a=>a.binding===void 0?[]:[a.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 "${C}" pipelines binding exists; run 'wrangler pipelines create <name>' and add a 'pipelines' binding ({ binding: "${C}", stream }) — codegen resolves this one name, and the pipeline resource can't be auto-provisioned.`],[e.usesArtifacts&&i.length===0,ae(e.jurisdiction)],[o.length>0,`ctx.artifacts is used and ${o.map(a=>`"${a}"`).join(", ")} ${o.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(([a])=>a).map(([,a])=>a)},$e=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.`),Ae=(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,d])=>d?.type==="workflow"?[o]:[]),i=(n.workflows??[]).flatMap(o=>o.class_name===void 0||o.script_name!==void 0?[]:[o.class_name]);return[...new Set([...t,...i])].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.`)},qe=(e,n)=>{if(e.queues.length===0)return[];const s=new Set(e.queues.map(i=>i.name)),t=new Set(e.queues.map(i=>i.bindingName));return[...(n.queues?.consumers??[]).flatMap(i=>{const{queue:o}=i;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(i=>{const{binding:o}=i;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.`]})]},je=(e,n)=>[...Ae(e,n),...qe(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"}],Ce=()=>U.map(({keys:e,label:n})=>`${e[0]} + ${e[1]} (${n})`).join(" or "),Ie=e=>{let n;try{n=F(Q(e,ce),"utf8")}catch{return!1}const s=new Map(le(n).map(t=>[t.key,t.value]));return U.some(({keys:t})=>t.every(i=>(s.get(i)??"")!==""))},De=(e,n)=>{const s=n?.secrets?.required;if(!Array.isArray(s))return[];const t=new Set(s),i=ue(de(e)).map(o=>o.key).filter(o=>!t.has(o));return i.length===0?[]:[`wrangler.jsonc declares secrets.required without ${i.join(", ")}, which this app needs — wrangler dev loads only the listed keys from .dev.vars, so add ${i.length===1?"it":"them"} to secrets.required.`]},T=(e,n,s)=>{const t=new Set(e.durableObjects.map(a=>a.className)),i=[],o=(s?.r2_buckets?.length??0)>0,d=(s?.d1_databases?.some(a=>a.binding==="DB")??!1)||e.needsD1;return e.usesStorage&&!o&&i.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")&&!d&&i.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")&&i.push("@lunora/scheduler is used but the worker entry exports no SchedulerDO; export it so the SCHEDULER binding can be provisioned."),i.push(...D("container","containers",e.containers),...D("workflow","workflows",e.workflows),...D("agent","agents",e.agents)),e.containers.length>0&&s?.observability?.enabled===!1&&i.push("containers are declared but observability is explicitly disabled in wrangler.jsonc — container logs will not be captured."),e.usesPayments&&!Ie(n)&&i.push(`@lunora/payment is used; set one provider's secret pair in .dev.vars — ${Ce()}.`),i.push(...$e(e),...ke(e,s),...De(e,s)),s!==void 0&&i.push(...je(e,s)),i},H="<replace-with-d1-create-id>",Te=e=>[["container","containers",e.containers],["workflow","workflows",e.workflows],["agent","agents",e.agents]].flatMap(([s,t,i])=>i.filter(o=>!o.exported).map(({className:o,exportName:d})=>({className:o,exportName:d,kind:s,module:t}))),Be=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)}`},Re=e=>{const n=new Set;for(const s of B(e)){for(const t of j(s.deleted_classes))n.delete(t);for(const{from:t,to:i}of B(s.renamed_classes))t!==void 0&&n.delete(t),i!==void 0&&n.add(i);for(const t of[...j(s.new_classes),...j(s.new_sqlite_classes)])n.add(t)}return n},Pe=(e,n,s)=>{const t=n.durable_objects?.bindings??[],i=new Set(t.map(l=>l.name)),o=s.filter(l=>!i.has(l.binding));let d=e;const a=[];if(o.length>0){const l=[...t,...o.map(m=>({class_name:m.className,name:m.binding}))];d=S(d,["durable_objects","bindings"],l),a.push(...o.map(m=>`${m.binding}/${m.className}`))}const b=n.migrations??[],c=s.map(l=>l.className).filter(l=>!Re(b).has(l));if(c.length>0){const l=[...b,{new_sqlite_classes:c,tag:Be(b)}];d=S(d,["migrations"],l)}return{added:a,text:d}},Le=(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",i=[...s,{binding:"DB",database_id:H,database_name:t}];return{added:["DB (D1)"],text:S(e,["d1_databases"],i)}},We={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:i}=We[s],o=n[s]?.binding;return typeof o=="string"&&o.length>0?{added:[],text:e}:{added:[i],text:S(e,[s],{binding:t})}},Me=(e,n)=>e.usesAnalyticsSql&&fe(n,new Set(["analyticsSql"]))?.chained.has("analyticsSql")!==!0,Ke=new Set(["ratelimits","send_email"]),Fe=["durable_objects","logfwdr","unsafe"],Qe=new Set(["data_blobs","text_blobs","vars","wasm_modules"]),W=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),L=(e,n,s)=>W(e)&&e[n]===s,Ye=(e,n,s)=>{if(Qe.has(e))return W(n)&&Object.hasOwn(n,s);const t=Ke.has(e)?"name":"binding";return Array.isArray(n)?n.some(i=>L(i,t,s)):L(n,"binding",s)},Ge=(e,n)=>{const s=e,t=Object.entries(s).find(([o,d])=>o!=="env"&&Ye(o,d,n));if(t!==void 0)return t[0];for(const o of Fe){const d=s[o];if(W(d)&&Array.isArray(d.bindings)&&d.bindings.some(a=>L(a,"name",n)))return`${o}.bindings`}if(e.queues?.producers?.some(o=>o.binding===n)===!0)return"queues.producers";const i=e.secrets?.required;if(Array.isArray(i)&&i.includes(n))return"secrets.required"},K=(e,n,s,t,i)=>{if((n[s]?.length??0)>0)return{added:[],text:e};const o=Ge(n,t.binding);return o!==void 0?{added:[],text:e,warnings:[`${s}: not adding ${JSON.stringify(t)} — the name "${t.binding}" is already bound by \`${o}\` in wrangler.jsonc. Add a ${s} entry under another binding name and point the matching \`defineApp()\` override at it.`]}:{added:[i],text:S(e,[s],[t])}},Ue=(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"}])}},He=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},Je=e=>{const{image:n}=e;return n.kind==="dockerfile"?n.dockerfilePath:n.kind==="registry"?n.reference:Z(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}}},Ve=e=>{if(e.schedulingPolicy==="durable_object")return J(e);const{image:n}=e,s={class_name:e.className,image:Je(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=He(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},Xe=(e,n,s)=>{const t=n.containers??[],i=new Set(t.map(c=>c.class_name)),o=s.filter(c=>!i.has(c.className));let d=o.length===0?e:S(e,["containers"],[...t,...o.map(c=>Ve(c))]);const a=[],b=[];for(const[c,l]of t.entries()){const m=s.find(g=>g.className===l.class_name);if(m===void 0)continue;const u=m.schedulingPolicy??"default";if((l.scheduling_policy??"default")!==u){b.push(`containers/${m.className} has scheduling_policy "${l.scheduling_policy??"default"}" in wrangler.jsonc but defineContainer "${m.exportName}" declares "${u}" — the policy is immutable, so replace the entry (and its container application) by hand.`);continue}const w=m.schedulingPolicy==="durable_object"?J(m).images:void 0;w!==void 0&&JSON.stringify(l.images)!==JSON.stringify(w)&&(d=S(d,["containers",c,"images"],w),a.push(`containers/${m.className}.images`))}return{added:o.map(c=>`containers/${c.className}`),text:d,updated:a,warnings:b}},ze=(e,n)=>{if(n.observability!==void 0)return{added:[],text:e};const s=S(e,["observability"],{...be});return{added:["observability"],text:s}},V=[{minimum:[4,142],name:"wrangler"},{minimum:[1,61],name:"@cloudflare/vite-plugin"}],Ze=V.map(({minimum:e,name:n})=>`${n}@^${e.join(".")}.0`).join(" "),en=(e,n)=>{try{const s=z(Q(e,"package.json")).resolve(`${n}/package.json`),[t=0,i=0]=String(JSON.parse(F(s,"utf8")).version).split(".").map(Number);return[t,i]}catch{return}},nn=e=>{const n=V.flatMap(({minimum:s,name:t})=>{const i=en(e,t);return i!==void 0&&(i[0]<s[0]||i[0]===s[0]&&i[1]<s[1])?[`${t} ${i.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 ${Ze}\`) and re-run.`},sn=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.`]:[]),tn=(e,n,s)=>{let t=e;const i=[],o=[];for(const d of s){const a=n[d.className];if(a?.type==="workflow")for(const{of:b,path:c}of pe){const l=b(d),m=Y(a,c),u=`exports/${d.className}.${c.join(".")}`;if(l===void 0){m!==void 0&&o.push(`${u} is set in wrangler.jsonc but defineWorkflow "${d.exportName}" does not declare it — reconcile leaves it in place. Remove it by hand if it was dropped from the definition.`);continue}JSON.stringify(m)!==JSON.stringify(l)&&(t=S(t,["exports",d.className,...c],l),i.push(u))}}return{text:t,updated:i,warnings:o}},on=(e,n,s,t,i)=>{if(i!==void 0)return{added:[],text:e,warnings:[i]};const o=[...s.map(p=>({settings:ge(p),workflow:p})),...t.map(p=>({settings:{},workflow:p}))],d=new Set(o.map(({workflow:p})=>p.className)),a=n.workflows??[],b=a.filter(p=>p.script_name===void 0&&p.class_name!==void 0&&d.has(p.class_name)),c=n.exports??{},l=[],m=[],u=[];let w=e;for(const{settings:p,workflow:h}of o){if(c[h.className]!==void 0&&c[h.className]!==null)continue;const v=b.find(f=>f.class_name===h.className),x=Object.fromEntries(me.flatMap(f=>{const y=Y(v,[f]);return y===void 0?[]:[[f,y]]})),N=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,...p,name:N}),(v===void 0?l:m).push(`exports/${h.className}`)}if(b.length>0){const p=a.filter(h=>!b.includes(h));w=S(w,["workflows"],p.length===0?void 0:p),m.push(...b.map(h=>`workflows/${String(h.class_name)} → exports`))}u.push(...sn(n));const g=tn(w,c,s);return{added:l,text:g.text,updated:[...m,...g.updated],warnings:[...u,...g.warnings]}},yn=(e,n,s)=>{const t=he(e),i=Te(n);if(!t)return{added:[],changed:!1,exportGaps:i,reason:"wrangler.jsonc not found",updated:[],warnings:T(n,e)};const{parsed:o,text:d}=we(t);if(o===void 0)return{added:[],changed:!1,exportGaps:i,reason:`failed to parse ${t} as JSONC`,updated:[],warnings:T(n,e),wranglerPath:t};const a=T(n,e,o);if(s!==void 0){const r=o.env?.[s]!==void 0;a.push(r?`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 b=n.containers.filter(r=>r.exported),c=n.agents.filter(r=>r.exported&&r.voice===!0&&r.voiceBindingName!==void 0&&r.voiceClassName!==void 0),l=[...n.durableObjects,...b.map(r=>({binding:r.bindingName,className:r.className})),...c.map(r=>({binding:r.voiceBindingName,className:r.voiceClassName}))],m=n.workflows.filter(r=>r.exported),u=n.agents.filter(r=>r.exported),w=M(e),g=Oe(w,a),p={},h=te(w);let v;const x=[{enabled:!0,run:r=>Pe(r,o,l)},{enabled:n.needsD1,run:r=>Le(r,o)},{enabled:n.usesAi,run:r=>$(r,o,"ai")},{enabled:n.usesAiSearch,run:r=>K(r,o,"ai_search_namespaces",{binding:"AI_SEARCH",namespace:"default"},"AI_SEARCH (AI Search namespace)")},{enabled:Me(n,e),run:r=>$(r,o,"analytics")},{enabled:n.usesBrowser,run:r=>$(r,o,"browser")},{enabled:n.usesImages,run:r=>$(r,o,"images")},{enabled:n.usesAnalytics,run:r=>K(r,o,"analytics_engine_datasets",{binding:"ANALYTICS",dataset:"ANALYTICS"},"ANALYTICS (Analytics Engine)")},{enabled:n.usesWorkerLoader,run:r=>Ue(r,o)},{enabled:!0,run:r=>ze(r,o)},{enabled:b.length>0,run:r=>Xe(r,o,b)},{enabled:m.length>0||u.length>0,run:r=>on(r,o,m,u,nn(e))},{enabled:n.queues.length>0,run:r=>{const _=xe(r,o,n.queues,g.queues??{});return p.queues=_.owned,_}},{enabled:n.services!==void 0&&(n.services.length>0||Object.keys(h).length>0),run:r=>{const _=oe(r,o,n.services??[],h);return v=_.owned,_}},...s===void 0||o.env?.[s]===void 0?[]:[{enabled:n.queues.length>0,run:r=>{const _=`env.${s}.queues`,k=Ne(r,o,n.queues,s,g[_]??{});return p[_]=k.owned,k}}]];let N=d;const f=[],y=[];for(const r of x){if(!r.enabled)continue;const _=r.run(N);N=_.text,f.push(..._.added),y.push(..._.updated??[]),a.push(..._.warnings??[])}const E=r=>{if(w===void 0)return;const _=v,k=[...Object.keys(p).length>0?[{consequence:"an option removed from defineQueue stays deployed",key:"queueTuning",label:"queue tuning",write:O=>{Ee(O,g,p)}}]:[],..._===void 0?[]:[{consequence:"a service removed from lunora.config stays bound",key:"services",label:"service bindings",write:O=>{re(O,_)}}]];for(const O of k)try{O.write(M(e)??w)}catch(q){a.push(`${r?"wrangler.jsonc was updated, but ":""}recording the ${O.label} reconcile owns in ${w.path} (lunora.${O.key}) failed: ${q instanceof Error?q.message:String(q)}. Until it is recorded, ${O.consequence}.`)}};let A;if(n.services!==void 0){const r=ie(e,n.services,h);a.push(...r.warnings),v={...v,...r.owned},A=r.added.length>0||r.updated.length>0?{added:r.added,path:r.path,updated:r.updated}:void 0}return f.includes("DB (D1)")&&a.push(`wrote a DB binding with a placeholder database_id ("${H}") — run \`wrangler d1 create <name>\` and replace it before deploying.`),N===d?(E(!1),{added:f,changed:!1,devConfig:A,exportGaps:i,reason:"bindings already in sync",updated:y,warnings:a,wranglerPath:t}):(X(t,N,"utf8"),E(!0),{added:f,changed:!0,devConfig:A,exportGaps:i,updated:y,warnings:a,wranglerPath:t})};export{Te as collectExportGaps,yn as reconcileWranglerBindings};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const c=["ai_search","ai_search_namespaces","analytics","artifacts","containers","d1_databases","durable_objects","k2","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{c as NON_INHERITABLE_KEYS,m as mergeWranglerEnvironment};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as p}from"./infer-bindings-B-BFynp2.mjs";import{LUNORA_TAG as r}from"./LUNORA_TAG-CiQM3BkI.mjs";import{reconcileWranglerBindings as $}from"./collectExportGaps-
|
|
1
|
+
import{i as p}from"./infer-bindings-B-BFynp2.mjs";import{LUNORA_TAG as r}from"./LUNORA_TAG-CiQM3BkI.mjs";import{reconcileWranglerBindings as $}from"./collectExportGaps-qqrrR5x_.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};
|
package/dist/packem_shared/{wranglerToAlchemy-Bpfy1abZ.mjs → wranglerToAlchemy-CBO2ucRm.mjs}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
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: {
|
|
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","k2","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
2
|
${a.join(`
|
|
3
3
|
`)}
|
|
4
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(`
|
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.299",
|
|
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.256",
|
|
58
58
|
"@lunora/container": "1.0.0-alpha.69",
|
|
59
59
|
"@lunora/errors": "1.0.0-alpha.50",
|
|
60
|
-
"@lunora/seed": "1.0.0-alpha.
|
|
60
|
+
"@lunora/seed": "1.0.0-alpha.184",
|
|
61
61
|
"@visulima/colorize": "2.1.1",
|
|
62
62
|
"@visulima/find-ai-runner": "1.0.2",
|
|
63
63
|
"@visulima/package": "5.0.20",
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{readFileSync as F,writeFileSync as V}from"node:fs";import{createRequire as X}from"node:module";import{join as Q}from"node:path";import{containerBuildTag as z}from"@lunora/container";import{applyModify as S}from"./applyModify-DKP2l6S9.mjs";import{a as Z,r as W}from"./lunora-manifest-v90ZUbVp.mjs";import{parseTree as ee,findNodeAtLocation as ne}from"jsonc-parser";import{r as se,a as te,b as oe,c as ie}from"./reconcile-services-3dn35zgy.mjs";import{a as re,p as ae}from"./infer-bindings-B-BFynp2.mjs";import{DEV_VARS_FILE as de,parseDevVariableEntries as ce}from"./DEV_VARS_EXAMPLE_FILE-CqLorAxT.mjs";import{requiredSecrets as le}from"./buildPackageSecretsBlock-yv9mjKEW.mjs";import{w as ue,n as ge,s as Y,o as B,p as C,q as me}from"./validate-bindings-DFAcr5wA.mjs";import{s as pe}from"./worker-entry-checks-9Vdz4d2f.mjs";import{DEFAULT_OBSERVABILITY as fe}from"./DEFAULT_OBSERVABILITY-bN6UkTMx.mjs";import{findWranglerFile as be,readWranglerJsonc as he}from"./WRANGLER_FILES-UNW-xY5u.mjs";const we=[["maxBatchSize","max_batch_size"],["maxBatchTimeout","max_batch_timeout"],["maxRetries","max_retries"],["deadLetterQueue","dead_letter_queue"],["retryDelay","retry_delay"]],R=e=>Object.fromEntries(we.filter(([n])=>e.tuning[n]!==void 0).map(([n,s])=>[s,e.tuning[n]])),P="queueTuning",ve=/^[\t ]*(?:,[\t ]*)?(?:\/\/[^\n\r]*)?\r?\n/u,_e=/^[\t ]*,/u,ye=(e,n)=>{const s=ee(e),t=s===void 0?void 0:ne(s,[...n])?.parent;if(t?.type==="property"){const i=t.offset+t.length,o=e.lastIndexOf(`
|
|
2
|
-
`,t.offset-1)+1,d=ve.exec(e.slice(i));if(d!==null&&e.slice(o,t.offset).trim()===""){const a=t.parent?.children??[],b=a.indexOf(t),c=b===a.length-1&&b>0?a[b-1]:void 0,l=c===void 0?void 0:_e.exec(e.slice(c.offset+c.length))??void 0;return(l===void 0||c===void 0?e.slice(0,o):e.slice(0,c.offset+c.length)+e.slice(c.offset+c.length+l[0].length,o))+e.slice(i+d[0].length)}}return S(e,n,void 0)},G=(e,n,s,t,i,o=new Set)=>{const d=s.join("."),a={},b=[],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 p=Object.fromEntries(Object.entries(R(g)).filter(([f])=>!o.has(f))),h=Object.entries(i[u.queue]??{}).filter(([f])=>!Object.hasOwn(p,f)),v=Object.entries(p).filter(([f,y])=>u[f]!==y),x=h.filter(([f,y])=>u[f]===y).map(([f])=>f),N=Object.fromEntries(Object.entries({...u,...p}).filter(([f])=>!x.includes(f)));for(const[f,y]of v)l=S(l,[...s,w,f],y);for(const f of x)l=ye(l,[...s,w,f]);for(const[f,y]of h){const k=u[f];k!==void 0&&k!==y&&c.push(`${d}/${u.queue}: ${f} is no longer declared by defineQueue, but it was changed by hand to ${JSON.stringify(k)} from the declared ${JSON.stringify(y)}, so it was kept. Delete it from wrangler.jsonc if it should go.`)}return(v.length>0||x.length>0)&&b.push(`${d}/${u.queue} (${[...v.map(([f])=>f),...x.map(f=>`removed ${f}`)].join(", ")})`),Object.keys(p).length>0&&(a[u.queue]=p),N}),owned:a,text:l,updated:b,warnings:c}},Se=(e,n,s,t)=>{const i=n.queues??{},o=i.producers??[],d=i.consumers??[],a=new Set(o.map(g=>g.binding)),b=new Set(d.map(g=>g.queue)),c=s.filter(g=>!a.has(g.bindingName)),l=s.filter(g=>!b.has(g.name)),m=G(e,d,["queues","consumers"],g=>s.find(p=>p.name===g.queue),t);let u=m.text;const w={...m.owned};if(c.length>0||l.length>0){const g=[...o,...c.map(h=>({binding:h.bindingName,queue:h.name}))],p=[...m.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:p,producers:g})}return{added:[...c.map(g=>`queues.producers/${g.bindingName}`),...l.map(g=>`queues.consumers/${g.name}`)],owned:w,text:u,updated:m.updated,warnings:m.warnings}},xe=(e,n,s,t,i)=>{const o=n.env?.[t],d=o?.queues?.consumers??[],a=o?.queues?.producers??[],b=u=>{const w=a.find(g=>g.queue===u.queue)?.binding;return w!==void 0?s.find(g=>g.bindingName===w):s.find(g=>g.name===u.queue&&!a.some(p=>p.binding===g.bindingName))},c=G(e,d,["env",t,"queues","consumers"],b,i,new Set(["dead_letter_queue"])),l=d.filter(u=>u.queue!==void 0&&b(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.`),m=d.flatMap(u=>{const w=b(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,...m,...l]}},Ne=(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=i=>typeof i=="object"&&i!==null&&!Array.isArray(i);return s===void 0?{}:!t(s)||!Object.values(s).every(i=>t(i)&&Object.values(i).every(o=>t(o)))?(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},Oe=(e,n,s)=>{const t=Object.fromEntries(Object.entries({...n,...s}).filter(([,i])=>Object.keys(i).length>0));Z(e,P,Object.keys(t).length===0?void 0:t)},I="PIPELINES",j="ARTIFACTS",ke=(e,n)=>{const s=e.flagshipBinding!==void 0&&!(n?.flagship??[]).some(a=>a.binding===e.flagshipBinding),t=e.usesPipelines&&!(n?.pipelines??[]).some(a=>a.binding===I),i=e.usesArtifacts?n?.artifacts??[]:[],o=i.some(a=>a.binding===j)?[]:i.flatMap(a=>a.binding===void 0?[]:[a.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 "${I}" pipelines binding exists; run 'wrangler pipelines create <name>' and add a 'pipelines' binding ({ binding: "${I}", stream }) — codegen resolves this one name, and the pipeline resource can't be auto-provisioned.`],[e.usesArtifacts&&i.length===0,re(e.jurisdiction)],[o.length>0,`ctx.artifacts is used and ${o.map(a=>`"${a}"`).join(", ")} ${o.length===1?"is":"are"} bound, but none is named "${j}"; make sure \`.artifacts()\` on defineApp points ctx.artifacts at it — otherwise it reads env.${j} 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(([a])=>a).map(([,a])=>a)},Ee=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.`),$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,d])=>d?.type==="workflow"?[o]:[]),i=(n.workflows??[]).flatMap(o=>o.class_name===void 0||o.script_name!==void 0?[]:[o.class_name]);return[...new Set([...t,...i])].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.`)},Ae=(e,n)=>{if(e.queues.length===0)return[];const s=new Set(e.queues.map(i=>i.name)),t=new Set(e.queues.map(i=>i.bindingName));return[...(n.queues?.consumers??[]).flatMap(i=>{const{queue:o}=i;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(i=>{const{binding:o}=i;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.`]})]},qe=(e,n)=>[...$e(e,n),...Ae(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"}],Ce=()=>U.map(({keys:e,label:n})=>`${e[0]} + ${e[1]} (${n})`).join(" or "),Ie=e=>{let n;try{n=F(Q(e,de),"utf8")}catch{return!1}const s=new Map(ce(n).map(t=>[t.key,t.value]));return U.some(({keys:t})=>t.every(i=>(s.get(i)??"")!==""))},je=(e,n)=>{const s=n?.secrets?.required;if(!Array.isArray(s))return[];const t=new Set(s),i=le(ae(e)).map(o=>o.key).filter(o=>!t.has(o));return i.length===0?[]:[`wrangler.jsonc declares secrets.required without ${i.join(", ")}, which this app needs — wrangler dev loads only the listed keys from .dev.vars, so add ${i.length===1?"it":"them"} to secrets.required.`]},T=(e,n,s)=>{const t=new Set(e.durableObjects.map(a=>a.className)),i=[],o=(s?.r2_buckets?.length??0)>0,d=(s?.d1_databases?.some(a=>a.binding==="DB")??!1)||e.needsD1;return e.usesStorage&&!o&&i.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")&&!d&&i.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")&&i.push("@lunora/scheduler is used but the worker entry exports no SchedulerDO; export it so the SCHEDULER binding can be provisioned."),i.push(...D("container","containers",e.containers),...D("workflow","workflows",e.workflows),...D("agent","agents",e.agents)),e.containers.length>0&&s?.observability?.enabled===!1&&i.push("containers are declared but observability is explicitly disabled in wrangler.jsonc — container logs will not be captured."),e.usesPayments&&!Ie(n)&&i.push(`@lunora/payment is used; set one provider's secret pair in .dev.vars — ${Ce()}.`),i.push(...Ee(e),...ke(e,s),...je(e,s)),s!==void 0&&i.push(...qe(e,s)),i},H="<replace-with-d1-create-id>",De=e=>[["container","containers",e.containers],["workflow","workflows",e.workflows],["agent","agents",e.agents]].flatMap(([s,t,i])=>i.filter(o=>!o.exported).map(({className:o,exportName:d})=>({className:o,exportName:d,kind:s,module:t}))),Te=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)}`},Be=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:i}of B(s.renamed_classes))t!==void 0&&n.delete(t),i!==void 0&&n.add(i);for(const t of[...C(s.new_classes),...C(s.new_sqlite_classes)])n.add(t)}return n},Re=(e,n,s)=>{const t=n.durable_objects?.bindings??[],i=new Set(t.map(l=>l.name)),o=s.filter(l=>!i.has(l.binding));let d=e;const a=[];if(o.length>0){const l=[...t,...o.map(m=>({class_name:m.className,name:m.binding}))];d=S(d,["durable_objects","bindings"],l),a.push(...o.map(m=>`${m.binding}/${m.className}`))}const b=n.migrations??[],c=s.map(l=>l.className).filter(l=>!Be(b).has(l));if(c.length>0){const l=[...b,{new_sqlite_classes:c,tag:Te(b)}];d=S(d,["migrations"],l)}return{added:a,text:d}},Pe=(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",i=[...s,{binding:"DB",database_id:H,database_name:t}];return{added:["DB (D1)"],text:S(e,["d1_databases"],i)}},Le={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:i}=Le[s],o=n[s]?.binding;return typeof o=="string"&&o.length>0?{added:[],text:e}:{added:[i],text:S(e,[s],{binding:t})}},Me=(e,n)=>e.usesAnalyticsSql&&pe(n,new Set(["analyticsSql"]))?.chained.has("analyticsSql")!==!0,We=new Set(["ratelimits","send_email"]),Ke=["durable_objects","logfwdr","unsafe"],Fe=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,Qe=(e,n,s)=>{if(Fe.has(e))return M(n)&&Object.hasOwn(n,s);const t=We.has(e)?"name":"binding";return Array.isArray(n)?n.some(i=>L(i,t,s)):L(n,"binding",s)},Ye=(e,n)=>{const s=e,t=Object.entries(s).find(([o,d])=>o!=="env"&&Qe(o,d,n));if(t!==void 0)return t[0];for(const o of Ke){const d=s[o];if(M(d)&&Array.isArray(d.bindings)&&d.bindings.some(a=>L(a,"name",n)))return`${o}.bindings`}if(e.queues?.producers?.some(o=>o.binding===n)===!0)return"queues.producers";const i=e.secrets?.required;if(Array.isArray(i)&&i.includes(n))return"secrets.required"},K=(e,n,s,t,i)=>{if((n[s]?.length??0)>0)return{added:[],text:e};const o=Ye(n,t.binding);return o!==void 0?{added:[],text:e,warnings:[`${s}: not adding ${JSON.stringify(t)} — the name "${t.binding}" is already bound by \`${o}\` in wrangler.jsonc. Add a ${s} entry under another binding name and point the matching \`defineApp()\` override at it.`]}:{added:[i],text:S(e,[s],[t])}},Ge=(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"}])}},Ue=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},He=e=>{const{image:n}=e;return n.kind==="dockerfile"?n.dockerfilePath:n.kind==="registry"?n.reference:z(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}}},Je=e=>{if(e.schedulingPolicy==="durable_object")return J(e);const{image:n}=e,s={class_name:e.className,image:He(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=Ue(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},Ve=(e,n,s)=>{const t=n.containers??[],i=new Set(t.map(c=>c.class_name)),o=s.filter(c=>!i.has(c.className));let d=o.length===0?e:S(e,["containers"],[...t,...o.map(c=>Je(c))]);const a=[],b=[];for(const[c,l]of t.entries()){const m=s.find(g=>g.className===l.class_name);if(m===void 0)continue;const u=m.schedulingPolicy??"default";if((l.scheduling_policy??"default")!==u){b.push(`containers/${m.className} has scheduling_policy "${l.scheduling_policy??"default"}" in wrangler.jsonc but defineContainer "${m.exportName}" declares "${u}" — the policy is immutable, so replace the entry (and its container application) by hand.`);continue}const w=m.schedulingPolicy==="durable_object"?J(m).images:void 0;w!==void 0&&JSON.stringify(l.images)!==JSON.stringify(w)&&(d=S(d,["containers",c,"images"],w),a.push(`containers/${m.className}.images`))}return{added:o.map(c=>`containers/${c.className}`),text:d,updated:a,warnings:b}},Xe=(e,n)=>{if(n.observability!==void 0)return{added:[],text:e};const s=S(e,["observability"],{...fe});return{added:["observability"],text:s}},ze=[{minimum:[4,142],name:"wrangler"},{minimum:[1,61],name:"@cloudflare/vite-plugin"}],Ze=(e,n)=>{try{const s=X(Q(e,"package.json")).resolve(`${n}/package.json`),[t=0,i=0]=String(JSON.parse(F(s,"utf8")).version).split(".").map(Number);return[t,i]}catch{return}},en=e=>{const n=ze.flatMap(({minimum:s,name:t})=>{const i=Ze(e,t);return i!==void 0&&(i[0]<s[0]||i[0]===s[0]&&i[1]<s[1])?[`${t} ${i.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.`},nn=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.`]:[]),sn=(e,n,s)=>{let t=e;const i=[],o=[];for(const d of s){const a=n[d.className];if(a?.type==="workflow")for(const{of:b,path:c}of me){const l=b(d),m=Y(a,c),u=`exports/${d.className}.${c.join(".")}`;if(l===void 0){m!==void 0&&o.push(`${u} is set in wrangler.jsonc but defineWorkflow "${d.exportName}" does not declare it — reconcile leaves it in place. Remove it by hand if it was dropped from the definition.`);continue}JSON.stringify(m)!==JSON.stringify(l)&&(t=S(t,["exports",d.className,...c],l),i.push(u))}}return{text:t,updated:i,warnings:o}},tn=(e,n,s,t,i)=>{if(i!==void 0)return{added:[],text:e,warnings:[i]};const o=[...s.map(p=>({settings:ue(p),workflow:p})),...t.map(p=>({settings:{},workflow:p}))],d=new Set(o.map(({workflow:p})=>p.className)),a=n.workflows??[],b=a.filter(p=>p.script_name===void 0&&p.class_name!==void 0&&d.has(p.class_name)),c=n.exports??{},l=[],m=[],u=[];let w=e;for(const{settings:p,workflow:h}of o){if(c[h.className]!==void 0&&c[h.className]!==null)continue;const v=b.find(f=>f.class_name===h.className),x=Object.fromEntries(ge.flatMap(f=>{const y=Y(v,[f]);return y===void 0?[]:[[f,y]]})),N=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,...p,name:N}),(v===void 0?l:m).push(`exports/${h.className}`)}if(b.length>0){const p=a.filter(h=>!b.includes(h));w=S(w,["workflows"],p.length===0?void 0:p),m.push(...b.map(h=>`workflows/${String(h.class_name)} → exports`))}u.push(...nn(n));const g=sn(w,c,s);return{added:l,text:g.text,updated:[...m,...g.updated],warnings:[...u,...g.warnings]}},_n=(e,n,s)=>{const t=be(e),i=De(n);if(!t)return{added:[],changed:!1,exportGaps:i,reason:"wrangler.jsonc not found",updated:[],warnings:T(n,e)};const{parsed:o,text:d}=he(t);if(o===void 0)return{added:[],changed:!1,exportGaps:i,reason:`failed to parse ${t} as JSONC`,updated:[],warnings:T(n,e),wranglerPath:t};const a=T(n,e,o);if(s!==void 0){const r=o.env?.[s]!==void 0;a.push(r?`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 b=n.containers.filter(r=>r.exported),c=n.agents.filter(r=>r.exported&&r.voice===!0&&r.voiceBindingName!==void 0&&r.voiceClassName!==void 0),l=[...n.durableObjects,...b.map(r=>({binding:r.bindingName,className:r.className})),...c.map(r=>({binding:r.voiceBindingName,className:r.voiceClassName}))],m=n.workflows.filter(r=>r.exported),u=n.agents.filter(r=>r.exported),w=W(e),g=Ne(w,a),p={},h=se(w);let v;const x=[{enabled:!0,run:r=>Re(r,o,l)},{enabled:n.needsD1,run:r=>Pe(r,o)},{enabled:n.usesAi,run:r=>$(r,o,"ai")},{enabled:n.usesAiSearch,run:r=>K(r,o,"ai_search_namespaces",{binding:"AI_SEARCH",namespace:"default"},"AI_SEARCH (AI Search namespace)")},{enabled:Me(n,e),run:r=>$(r,o,"analytics")},{enabled:n.usesBrowser,run:r=>$(r,o,"browser")},{enabled:n.usesImages,run:r=>$(r,o,"images")},{enabled:n.usesAnalytics,run:r=>K(r,o,"analytics_engine_datasets",{binding:"ANALYTICS",dataset:"ANALYTICS"},"ANALYTICS (Analytics Engine)")},{enabled:n.usesWorkerLoader,run:r=>Ge(r,o)},{enabled:!0,run:r=>Xe(r,o)},{enabled:b.length>0,run:r=>Ve(r,o,b)},{enabled:m.length>0||u.length>0,run:r=>tn(r,o,m,u,en(e))},{enabled:n.queues.length>0,run:r=>{const _=Se(r,o,n.queues,g.queues??{});return p.queues=_.owned,_}},{enabled:n.services!==void 0&&(n.services.length>0||Object.keys(h).length>0),run:r=>{const _=te(r,o,n.services??[],h);return v=_.owned,_}},...s===void 0||o.env?.[s]===void 0?[]:[{enabled:n.queues.length>0,run:r=>{const _=`env.${s}.queues`,E=xe(r,o,n.queues,s,g[_]??{});return p[_]=E.owned,E}}]];let N=d;const f=[],y=[];for(const r of x){if(!r.enabled)continue;const _=r.run(N);N=_.text,f.push(..._.added),y.push(..._.updated??[]),a.push(..._.warnings??[])}const k=r=>{if(w===void 0)return;const _=v,E=[...Object.keys(p).length>0?[{consequence:"an option removed from defineQueue stays deployed",key:"queueTuning",label:"queue tuning",write:O=>{Oe(O,g,p)}}]:[],..._===void 0?[]:[{consequence:"a service removed from lunora.config stays bound",key:"services",label:"service bindings",write:O=>{ie(O,_)}}]];for(const O of E)try{O.write(W(e)??w)}catch(q){a.push(`${r?"wrangler.jsonc was updated, but ":""}recording the ${O.label} reconcile owns in ${w.path} (lunora.${O.key}) failed: ${q instanceof Error?q.message:String(q)}. Until it is recorded, ${O.consequence}.`)}};let A;if(n.services!==void 0){const r=oe(e,n.services,h);a.push(...r.warnings),v={...v,...r.owned},A=r.added.length>0||r.updated.length>0?{added:r.added,path:r.path,updated:r.updated}:void 0}return f.includes("DB (D1)")&&a.push(`wrote a DB binding with a placeholder database_id ("${H}") — run \`wrangler d1 create <name>\` and replace it before deploying.`),N===d?(k(!1),{added:f,changed:!1,devConfig:A,exportGaps:i,reason:"bindings already in sync",updated:y,warnings:a,wranglerPath:t}):(V(t,N,"utf8"),k(!0),{added:f,changed:!0,devConfig:A,exportGaps:i,updated:y,warnings:a,wranglerPath:t})};export{De as collectExportGaps,_n as reconcileWranglerBindings};
|
|
@@ -1 +0,0 @@
|
|
|
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};
|