@lunora/config 1.0.0-alpha.245 → 1.0.0-alpha.246
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.
|
@@ -256,6 +256,12 @@ interface ReconcileBindingsResult {
|
|
|
256
256
|
exportGaps: ExportGap[];
|
|
257
257
|
/** Reason reconciliation was skipped, for logging. */
|
|
258
258
|
reason?: string;
|
|
259
|
+
/**
|
|
260
|
+
* Short labels for each EXISTING entry whose settings were brought in line
|
|
261
|
+
* with its declaration (e.g. `"queues.consumers/receipt-queue (max_retries)"`).
|
|
262
|
+
* Kept apart from `added` so a retune is not logged as a new binding.
|
|
263
|
+
*/
|
|
264
|
+
updated: string[];
|
|
259
265
|
/** Non-fatal hints for capabilities that cannot be auto-provisioned. */
|
|
260
266
|
warnings: string[];
|
|
261
267
|
/** Resolved wrangler path, or `undefined` when none was found. */
|
|
@@ -256,6 +256,12 @@ interface ReconcileBindingsResult {
|
|
|
256
256
|
exportGaps: ExportGap[];
|
|
257
257
|
/** Reason reconciliation was skipped, for logging. */
|
|
258
258
|
reason?: string;
|
|
259
|
+
/**
|
|
260
|
+
* Short labels for each EXISTING entry whose settings were brought in line
|
|
261
|
+
* with its declaration (e.g. `"queues.consumers/receipt-queue (max_retries)"`).
|
|
262
|
+
* Kept apart from `added` so a retune is not logged as a new binding.
|
|
263
|
+
*/
|
|
264
|
+
updated: string[];
|
|
259
265
|
/** Non-fatal hints for capabilities that cannot be auto-provisioned. */
|
|
260
266
|
warnings: string[];
|
|
261
267
|
/** Resolved wrangler path, or `undefined` when none was found. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{BINDING_MANIFEST_VERSION as o,buildBindingManifest as a}from"../packem_shared/BINDING_MANIFEST_VERSION-B8dwEKLn.mjs";import{default as l}from"../packem_shared/CLOUDFLARE_DRIVER-Ci9oJMYb.mjs";import{collectExportGaps as i,reconcileWranglerBindings as E}from"../packem_shared/collectExportGaps-
|
|
1
|
+
import{BINDING_MANIFEST_VERSION as o,buildBindingManifest as a}from"../packem_shared/BINDING_MANIFEST_VERSION-B8dwEKLn.mjs";import{default as l}from"../packem_shared/CLOUDFLARE_DRIVER-Ci9oJMYb.mjs";import{collectExportGaps as i,reconcileWranglerBindings as E}from"../packem_shared/collectExportGaps-k35UGfxu.mjs";import{reconcileWranglerCompatibilityDate as R}from"../packem_shared/reconcileWranglerCompatibilityDate-7OO_xaKR.mjs";import{describePreservedCrons as c,reconcileWranglerCrons as s}from"../packem_shared/describePreservedCrons-Bp5s5u0M.mjs";import{REMOTE_ELIGIBLE_KEYS as d,injectRemoteFlags as p,isRemoteEnvEnabled as I,materializeRemoteWranglerConfig as W,planRemoteBindings as _,resolveRemoteEnabled as x}from"../packem_shared/REMOTE_ELIGIBLE_KEYS-D-edJjVY.mjs";import{WORKERS_CACHE_MIN_DATE as A,isCacheEnabled as D}from"../packem_shared/WORKERS_CACHE_MIN_DATE-0k9ABJtF.mjs";import{WRANGLER_FILES as S,findWranglerFile as T,readWranglerJsonc as b}from"../packem_shared/WRANGLER_FILES-UNW-xY5u.mjs";import{collectWranglerSecretVariables as F,scanWranglerVariablesForSecrets as N}from"../packem_shared/collectWranglerSecretVariables-D-usPfT8.mjs";import{wranglerToAlchemy as M}from"../packem_shared/wranglerToAlchemy-SDoS_XY0.mjs";import{REQUIRED_COMPATIBILITY_DATE as G,REQUIRED_FLAG as P,UNEXPORTED_CLASS_MARKER as U,mergeWranglerEnvironment as V,validateWrangler as h,validateWranglerConfig as u,validateWranglerProject as K,withTailConsumer as j}from"../packem_shared/REQUIRED_COMPATIBILITY_DATE-SdRHaUwh.mjs";export{o as BINDING_MANIFEST_VERSION,l as CLOUDFLARE_DRIVER,d as REMOTE_ELIGIBLE_KEYS,G as REQUIRED_COMPATIBILITY_DATE,P as REQUIRED_FLAG,U as UNEXPORTED_CLASS_MARKER,A as WORKERS_CACHE_MIN_DATE,S as WRANGLER_FILES,a as buildBindingManifest,i as collectExportGaps,F as collectWranglerSecretVariables,c as describePreservedCrons,T as findWranglerFile,p as injectRemoteFlags,D as isCacheEnabled,I as isRemoteEnvEnabled,W as materializeRemoteWranglerConfig,V as mergeWranglerEnvironment,_ as planRemoteBindings,b as readWranglerJsonc,E as reconcileWranglerBindings,R as reconcileWranglerCompatibilityDate,s as reconcileWranglerCrons,x as resolveRemoteEnabled,N as scanWranglerVariablesForSecrets,h as validateWrangler,u as validateWranglerConfig,K as validateWranglerProject,j as withTailConsumer,M as wranglerToAlchemy};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{writeFileSync as A,readFileSync as O}from"node:fs";import{join as P}from"node:path";import{containerBuildTag as $}from"@lunora/container";import{DEV_VARS_FILE as I,parseDevVariableEntries as R}from"./DEV_VARS_EXAMPLE_FILE-CqLorAxT.mjs";import{a as f}from"./jsonc-edit-BZgQIdAH.mjs";import{findWranglerFile as M,readWranglerJsonc as T}from"./WRANGLER_FILES-UNW-xY5u.mjs";import{objectBindingEntries as k,stringEntries as _}from"./REQUIRED_COMPATIBILITY_DATE-SdRHaUwh.mjs";const C="<replace-with-d1-create-id>",W=e=>[["container","containers",e.containers],["workflow","workflows",e.workflows],["agent","agents",e.agents]].flatMap(([n,a,i])=>i.filter(t=>!t.exported).map(({className:t,exportName:l})=>({className:t,exportName:l,kind:n,module:a}))),x="PIPELINES",q=(e,s)=>{const n=e.flagshipBinding!==void 0&&!(s?.flagship??[]).some(t=>t.binding===e.flagshipBinding),a=e.usesPipelines&&!(s?.pipelines??[]).some(t=>t.binding===x);return[[e.usesKv&&(s?.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&&(s?.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."],[a,`ctx.pipelines is used but no "${x}" pipelines binding exists; run 'wrangler pipelines create <name>' and add a 'pipelines' binding ({ binding: "${x}", pipeline }) — codegen resolves this one name, and the pipeline resource can't be auto-provisioned.`],[n,`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(([t])=>t).map(([,t])=>t)},j=e=>[[e.usesX402Charge,"@lunora/x402/charge is used; set the recipient wallet address as a [vars] entry (the var name is your choice) and pass it to the charge config — the x402 facilitator settles USDC to that address."],[e.usesX402Pay,"@lunora/x402/pay is used (ActionCtx-only, spends real funds); add a secrets_store_secrets[] binding holding the agent wallet key (binding name == signer.secretName) and pair the pay rail with a spend policy — ctx.secrets reads a Secrets Store binding, not .dev.vars."]].filter(([n])=>n).map(([,n])=>n),y=(e,s,n)=>n.filter(a=>!a.exported).map(a=>`${e} "${a.exportName}" is declared but ${a.className} is not exported by the worker entry; add \`export * from "./lunora/_generated/${s}"\` so its binding can be provisioned.`),K=(e,s)=>{const n=new Set([...e.workflows,...e.agents].map(a=>a.className));return n.size===0?[]:(s.workflows??[]).flatMap(a=>{const i=a.class_name;return i===void 0||n.has(i)?[]:[`wrangler.jsonc declares workflows[] entry "${i}" but no defineWorkflow/defineAgent export generates that class — a leftover from a rename will fail the deploy (wrangler rejects a class_name the worker does not export). Remove it if it is not hand-wired.`]})},L=(e,s)=>{if(e.queues.length===0)return[];const n=new Set(e.queues.map(i=>i.name)),a=new Set(e.queues.map(i=>i.bindingName));return[...(s.queues?.consumers??[]).flatMap(i=>{const{queue:t}=i;return t===void 0||n.has(t)?[]:[`wrangler.jsonc subscribes queues.consumers[] to "${t}" 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.`]}),...(s.queues?.producers??[]).flatMap(i=>{const{binding:t}=i;return t===void 0||a.has(t)?[]:[`wrangler.jsonc declares queues.producers[] binding "${t}" but no defineQueue export declares it — a leftover from a rename. Remove it if it is not hand-wired.`]})]},Y=(e,s)=>[...K(e,s),...L(e,s)],B=[{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"}],H=()=>B.map(({keys:e,label:s})=>`${e[0]} + ${e[1]} (${s})`).join(" or "),F=e=>{let s;try{s=O(P(e,I),"utf8")}catch{return!1}const n=new Map(R(s).map(a=>[a.key,a.value]));return B.some(({keys:a})=>a.every(i=>(n.get(i)??"")!==""))},E=(e,s,n)=>{const a=new Set(e.durableObjects.map(r=>r.className)),i=[],t=(n?.r2_buckets?.length??0)>0,l=(n?.d1_databases?.some(r=>r.binding==="DB")??!1)||e.needsD1;return e.usesStorage&&!t&&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&&!a.has("SessionDO")&&!l&&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&&!a.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(...y("container","containers",e.containers),...y("workflow","workflows",e.workflows),...y("agent","agents",e.agents)),e.containers.length>0&&n?.observability?.enabled===!1&&i.push("containers are declared but observability is explicitly disabled in wrangler.jsonc — container logs will not be captured."),e.usesPayment&&!F(s)&&i.push(`@lunora/payment is used; set one provider's secret pair in .dev.vars — ${H()}.`),i.push(...j(e),...q(e,n)),n!==void 0&&i.push(...Y(e,n)),i},G=e=>{const s=new Set(k(e).map(a=>a.tag));let n=1;for(;s.has(`v${String(n)}`);)n+=1;return`v${String(n)}`},U=e=>{const s=new Set;for(const n of k(e)){for(const a of _(n.deleted_classes))s.delete(a);for(const{from:a,to:i}of k(n.renamed_classes))a!==void 0&&s.delete(a),i!==void 0&&s.add(i);for(const a of[..._(n.new_classes),..._(n.new_sqlite_classes)])s.add(a)}return s},Q=(e,s,n)=>{const a=s.durable_objects?.bindings??[],i=new Set(a.map(c=>c.name)),t=n.filter(c=>!i.has(c.binding));let l=e;const r=[];if(t.length>0){const c=[...a,...t.map(b=>({class_name:b.className,name:b.binding}))];l=f(l,["durable_objects","bindings"],c),r.push(...t.map(b=>`${b.binding}/${b.className}`))}const m=s.migrations??[],d=n.map(c=>c.className).filter(c=>!U(m).has(c));if(d.length>0){const c=[...m,{new_sqlite_classes:d,tag:G(m)}];l=f(l,["migrations"],c)}return{added:r,text:l}},V=(e,s)=>{const n=s.d1_databases??[];if(n.some(t=>t.binding==="DB"))return{added:[],text:e};const a=typeof s.name=="string"&&s.name.length>0?s.name:"lunora",i=[...n,{binding:"DB",database_id:C,database_name:a}];return{added:["DB (D1)"],text:f(e,["d1_databases"],i)}},S=(e,s,n,a,i)=>{const t=s[n]?.binding;return typeof t=="string"&&t.length>0?{added:[],text:e}:{added:[i],text:f(e,[n],{binding:a})}},z=(e,s)=>(s.analytics_engine_datasets?.length??0)>0?{added:[],text:e}:{added:["ANALYTICS (Analytics Engine)"],text:f(e,["analytics_engine_datasets"],[{binding:"ANALYTICS",dataset:"ANALYTICS"}])},X=e=>{if(typeof e=="string")return e;const s={};return e.diskMb!==void 0&&(s.disk_mb=e.diskMb),e.memoryMib!==void 0&&(s.memory_mib=e.memoryMib),e.vcpu!==void 0&&(s.vcpu=e.vcpu),s},J=e=>e.image.kind==="dockerfile"?e.image.dockerfilePath:e.image.kind==="registry"?e.image.reference:$(e.exportName),Z=e=>{const s={class_name:e.className,image:J(e)};return e.image.kind==="dockerfile"&&(s.image_build_context=e.image.buildContext),e.buildArgs!==void 0&&e.image.kind!=="registry"&&(s.image_vars=e.buildArgs),e.instanceType!==void 0&&(s.instance_type=X(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},ee=(e,s,n)=>{const a=s.containers??[],i=new Set(a.map(r=>r.class_name)),t=n.filter(r=>!i.has(r.className));if(t.length===0)return{added:[],text:e};const l=f(e,["containers"],[...a,...t.map(r=>Z(r))]);return{added:t.map(r=>`containers/${r.className}`),text:l}},se=(e,s)=>{if(s.observability!==void 0)return{added:[],text:e};const n=f(e,["observability"],{enabled:!0,head_sampling_rate:1});return{added:["observability"],text:n}},D=e=>({binding:e.bindingName,class_name:e.className,name:e.name}),ne=(e,s,n,a=[])=>{const i=s.workflows??[],t=new Set(i.map(d=>d.class_name)),l=n.filter(d=>!t.has(d.className)),r=a.filter(d=>!t.has(d.className));if(l.length===0&&r.length===0)return{added:[],text:e};const m=f(e,["workflows"],[...i,...l.map(d=>D(d)),...r.map(d=>D(d))]);return{added:[...l.map(d=>`workflows/${d.className}`),...r.map(d=>`workflows/${d.className}`)],text:m}},te=[["maxBatchSize","max_batch_size"],["maxBatchTimeout","max_batch_timeout"],["maxRetries","max_retries"],["deadLetterQueue","dead_letter_queue"],["retryDelay","retry_delay"]],N=e=>Object.fromEntries(te.filter(([s])=>e.tuning[s]!==void 0).map(([s,n])=>[n,e.tuning[s]])),ae=(e,s,n)=>{const a=s.queues??{},i=a.producers??[],t=a.consumers??[],l=new Set(i.map(g=>g.binding)),r=new Set(t.map(g=>g.queue)),m=n.filter(g=>!l.has(g.bindingName)),d=n.filter(g=>!r.has(g.name));let c=e;const b=[];for(const[g,v]of t.entries()){const u=n.find(p=>p.name===v.queue);if(u===void 0)continue;const h=Object.entries(N(u)).filter(([p,o])=>v[p]!==o);for(const[p,o]of h)c=f(c,["queues","consumers",g,p],o);h.length>0&&b.push(`queues.consumers/${u.name} (${h.map(([p])=>p).join(", ")})`)}if(m.length>0||d.length>0){const g=[...i,...m.map(u=>({binding:u.bindingName,queue:u.name}))],v=[...t.map(u=>{const h=n.find(p=>p.name===u.queue);return h===void 0?u:{...u,...N(h)}}),...d.map(u=>({queue:u.name,...u.mode==="pull"?{type:"http_pull"}:{},...N(u)}))];c=f(c,["queues"],{consumers:v,producers:g})}return{added:[...m.map(g=>`queues.producers/${g.bindingName}`),...d.map(g=>`queues.consumers/${g.name}`)],text:c,updated:b}},ge=(e,s,n)=>{const a=M(e),i=W(s);if(!a)return{added:[],changed:!1,exportGaps:i,reason:"wrangler.jsonc not found",updated:[],warnings:E(s,e)};const{parsed:t,text:l}=T(a);if(t===void 0)return{added:[],changed:!1,exportGaps:i,reason:`failed to parse ${a} as JSONC`,updated:[],warnings:E(s,e),wranglerPath:a};const r=E(s,e,t);if(n!==void 0){const o=t.env?.[n]!==void 0;r.push(o?`auto-provisioned bindings are written to the top level of wrangler.jsonc only — "env.${n}" has its own (non-inheritable) bindings and must be reconciled by hand; \`lunora deploy --env ${n}\` now validates them, so a gap here will be reported at deploy time.`:`--env "${n}" was requested but wrangler.jsonc declares no "env.${n}" block — auto-provisioned bindings are written to the top level only and will not apply to that environment.`)}const m=s.containers.filter(o=>o.exported),d=s.agents.filter(o=>o.exported&&o.voice===!0&&o.voiceBindingName!==void 0&&o.voiceClassName!==void 0),c=[...s.durableObjects,...m.map(o=>({binding:o.bindingName,className:o.className})),...d.map(o=>({binding:o.voiceBindingName,className:o.voiceClassName}))],b=s.workflows.filter(o=>o.exported),g=s.agents.filter(o=>o.exported),v=[{enabled:!0,run:o=>Q(o,t,c)},{enabled:s.needsD1,run:o=>V(o,t)},{enabled:s.usesAi,run:o=>S(o,t,"ai","AI","AI (Workers AI)")},{enabled:s.usesBrowser,run:o=>S(o,t,"browser","BROWSER","BROWSER (Browser Rendering)")},{enabled:s.usesImages,run:o=>S(o,t,"images","IMAGES","IMAGES (Cloudflare Images)")},{enabled:s.usesAnalytics,run:o=>z(o,t)},{enabled:!0,run:o=>se(o,t)},{enabled:m.length>0,run:o=>ee(o,t,m)},{enabled:b.length>0||g.length>0,run:o=>ne(o,t,b,g)},{enabled:s.queues.length>0,run:o=>ae(o,t,s.queues)}];let u=l;const h=[],p=[];for(const o of v){if(!o.enabled)continue;const w=o.run(u);u=w.text,h.push(...w.added),p.push(...w.updated??[])}return h.includes("DB (D1)")&&r.push(`wrote a DB binding with a placeholder database_id ("${C}") — run \`wrangler d1 create <name>\` and replace it before deploying.`),u===l?{added:[],changed:!1,exportGaps:i,reason:"bindings already in sync",updated:[],warnings:r,wranglerPath:a}:(A(a,u,"utf8"),{added:h,changed:!0,exportGaps:i,updated:p,warnings:r,wranglerPath:a})};export{W as collectExportGaps,ge as reconcileWranglerBindings};
|
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.246",
|
|
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.209",
|
|
58
58
|
"@lunora/container": "1.0.0-alpha.56",
|
|
59
59
|
"@lunora/errors": "1.0.0-alpha.41",
|
|
60
|
-
"@lunora/seed": "1.0.0-alpha.
|
|
60
|
+
"@lunora/seed": "1.0.0-alpha.149",
|
|
61
61
|
"@visulima/colorize": "2.1.1",
|
|
62
62
|
"@visulima/find-ai-runner": "1.0.2",
|
|
63
63
|
"@visulima/package": "5.0.20",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{writeFileSync as B,readFileSync as C}from"node:fs";import{join as A}from"node:path";import{containerBuildTag as P}from"@lunora/container";import{DEV_VARS_FILE as O,parseDevVariableEntries as I}from"./DEV_VARS_EXAMPLE_FILE-CqLorAxT.mjs";import{a as b}from"./jsonc-edit-BZgQIdAH.mjs";import{findWranglerFile as $,readWranglerJsonc as R}from"./WRANGLER_FILES-UNW-xY5u.mjs";import{objectBindingEntries as S,stringEntries as v}from"./REQUIRED_COMPATIBILITY_DATE-SdRHaUwh.mjs";const k="<replace-with-d1-create-id>",M=e=>[["container","containers",e.containers],["workflow","workflows",e.workflows],["agent","agents",e.agents]].flatMap(([s,t,i])=>i.filter(a=>!a.exported).map(({className:a,exportName:c})=>({className:a,exportName:c,kind:s,module:t}))),w="PIPELINES",T=(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===w);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 "${w}" pipelines binding exists; run 'wrangler pipelines create <name>' and add a 'pipelines' binding ({ binding: "${w}", pipeline }) — codegen resolves this one name, and the pipeline resource can't be auto-provisioned.`],[s,`lunora/flags.ts uses Flagship in binding mode but no flagship binding "${e.flagshipBinding??""}" exists; add a flagship entry ({ binding: "${e.flagshipBinding??""}", app_id }) — the app_id can't be auto-provisioned.`]].filter(([a])=>a).map(([,a])=>a)},W=e=>[[e.usesX402Charge,"@lunora/x402/charge is used; set the recipient wallet address as a [vars] entry (the var name is your choice) and pass it to the charge config — the x402 facilitator settles USDC to that address."],[e.usesX402Pay,"@lunora/x402/pay is used (ActionCtx-only, spends real funds); add a secrets_store_secrets[] binding holding the agent wallet key (binding name == signer.secretName) and pair the pay rail with a spend policy — ctx.secrets reads a Secrets Store binding, not .dev.vars."]].filter(([s])=>s).map(([,s])=>s),_=(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.`),K=(e,n)=>{const s=new Set([...e.workflows,...e.agents].map(t=>t.className));return s.size===0?[]:(n.workflows??[]).flatMap(t=>{const i=t.class_name;return i===void 0||s.has(i)?[]:[`wrangler.jsonc declares workflows[] entry "${i}" but no defineWorkflow/defineAgent export generates that class — a leftover from a rename will fail the deploy (wrangler rejects a class_name the worker does not export). Remove it if it is not hand-wired.`]})},L=(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:a}=i;return a===void 0||s.has(a)?[]:[`wrangler.jsonc subscribes queues.consumers[] to "${a}" 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:a}=i;return a===void 0||t.has(a)?[]:[`wrangler.jsonc declares queues.producers[] binding "${a}" but no defineQueue export declares it — a leftover from a rename. Remove it if it is not hand-wired.`]})]},j=(e,n)=>[...K(e,n),...L(e,n)],D=[{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"}],Y=()=>D.map(({keys:e,label:n})=>`${e[0]} + ${e[1]} (${n})`).join(" or "),q=e=>{let n;try{n=C(A(e,O),"utf8")}catch{return!1}const s=new Map(I(n).map(t=>[t.key,t.value]));return D.some(({keys:t})=>t.every(i=>(s.get(i)??"")!==""))},x=(e,n,s)=>{const t=new Set(e.durableObjects.map(d=>d.className)),i=[],a=(s?.r2_buckets?.length??0)>0,c=(s?.d1_databases?.some(d=>d.binding==="DB")??!1)||e.needsD1;return e.usesStorage&&!a&&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")&&!c&&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(..._("container","containers",e.containers),..._("workflow","workflows",e.workflows),..._("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.usesPayment&&!q(n)&&i.push(`@lunora/payment is used; set one provider's secret pair in .dev.vars — ${Y()}.`),i.push(...W(e),...T(e,s)),s!==void 0&&i.push(...j(e,s)),i},H=e=>{const n=new Set(S(e).map(t=>t.tag));let s=1;for(;n.has(`v${String(s)}`);)s+=1;return`v${String(s)}`},F=e=>{const n=new Set;for(const s of S(e)){for(const t of v(s.deleted_classes))n.delete(t);for(const{from:t,to:i}of S(s.renamed_classes))t!==void 0&&n.delete(t),i!==void 0&&n.add(i);for(const t of[...v(s.new_classes),...v(s.new_sqlite_classes)])n.add(t)}return n},G=(e,n,s)=>{const t=n.durable_objects?.bindings??[],i=new Set(t.map(u=>u.name)),a=s.filter(u=>!i.has(u.binding));let c=e;const d=[];if(a.length>0){const u=[...t,...a.map(p=>({class_name:p.className,name:p.binding}))];c=b(c,["durable_objects","bindings"],u),d.push(...a.map(p=>`${p.binding}/${p.className}`))}const g=n.migrations??[],l=s.map(u=>u.className).filter(u=>!F(g).has(u));if(l.length>0){const u=[...g,{new_sqlite_classes:l,tag:H(g)}];c=b(c,["migrations"],u)}return{added:d,text:c}},Q=(e,n)=>{const s=n.d1_databases??[];if(s.some(a=>a.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:k,database_name:t}];return{added:["DB (D1)"],text:b(e,["d1_databases"],i)}},y=(e,n,s,t,i)=>{const a=n[s]?.binding;return typeof a=="string"&&a.length>0?{added:[],text:e}:{added:[i],text:b(e,[s],{binding:t})}},U=(e,n)=>(n.analytics_engine_datasets?.length??0)>0?{added:[],text:e}:{added:["ANALYTICS (Analytics Engine)"],text:b(e,["analytics_engine_datasets"],[{binding:"ANALYTICS",dataset:"ANALYTICS"}])},z=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},V=e=>e.image.kind==="dockerfile"?e.image.dockerfilePath:e.image.kind==="registry"?e.image.reference:P(e.exportName),X=e=>{const n={class_name:e.className,image:V(e)};return e.image.kind==="dockerfile"&&(n.image_build_context=e.image.buildContext),e.buildArgs!==void 0&&e.image.kind!=="registry"&&(n.image_vars=e.buildArgs),e.instanceType!==void 0&&(n.instance_type=z(e.instanceType)),e.maxInstances!==void 0&&(n.max_instances=e.maxInstances),e.name!==void 0&&(n.name=e.name),e.rollout?.stepPercentage!==void 0&&(n.rollout_step_percentage=e.rollout.stepPercentage),e.rollout?.gracePeriodSeconds!==void 0&&(n.rollout_active_grace_period=e.rollout.gracePeriodSeconds),n},J=(e,n,s)=>{const t=n.containers??[],i=new Set(t.map(d=>d.class_name)),a=s.filter(d=>!i.has(d.className));if(a.length===0)return{added:[],text:e};const c=b(e,["containers"],[...t,...a.map(d=>X(d))]);return{added:a.map(d=>`containers/${d.className}`),text:c}},Z=(e,n)=>{if(n.observability!==void 0)return{added:[],text:e};const s=b(e,["observability"],{enabled:!0,head_sampling_rate:1});return{added:["observability"],text:s}},N=e=>({binding:e.bindingName,class_name:e.className,name:e.name}),ee=(e,n,s,t=[])=>{const i=n.workflows??[],a=new Set(i.map(l=>l.class_name)),c=s.filter(l=>!a.has(l.className)),d=t.filter(l=>!a.has(l.className));if(c.length===0&&d.length===0)return{added:[],text:e};const g=b(e,["workflows"],[...i,...c.map(l=>N(l)),...d.map(l=>N(l))]);return{added:[...c.map(l=>`workflows/${l.className}`),...d.map(l=>`workflows/${l.className}`)],text:g}},ne=(e,n,s)=>{const t=n.queues??{},i=t.producers??[],a=t.consumers??[],c=new Set(i.map(r=>r.binding)),d=new Set(a.map(r=>r.queue)),g=s.filter(r=>!c.has(r.bindingName)),l=s.filter(r=>!d.has(r.name));if(g.length===0&&l.length===0)return{added:[],text:e};const u=[...i,...g.map(r=>({binding:r.bindingName,queue:r.name}))],p=[...a,...l.map(r=>{const m={queue:r.name};return r.mode==="pull"&&(m.type="http_pull"),r.tuning.maxBatchSize!==void 0&&(m.max_batch_size=r.tuning.maxBatchSize),r.tuning.maxBatchTimeout!==void 0&&(m.max_batch_timeout=r.tuning.maxBatchTimeout),r.tuning.maxRetries!==void 0&&(m.max_retries=r.tuning.maxRetries),r.tuning.deadLetterQueue!==void 0&&(m.dead_letter_queue=r.tuning.deadLetterQueue),r.tuning.retryDelay!==void 0&&(m.retry_delay=r.tuning.retryDelay),m})],h=b(e,["queues"],{consumers:p,producers:u});return{added:[...g.map(r=>`queues.producers/${r.bindingName}`),...l.map(r=>`queues.consumers/${r.name}`)],text:h}},le=(e,n,s)=>{const t=$(e),i=M(n);if(!t)return{added:[],changed:!1,exportGaps:i,reason:"wrangler.jsonc not found",warnings:x(n,e)};const{parsed:a,text:c}=R(t);if(a===void 0)return{added:[],changed:!1,exportGaps:i,reason:`failed to parse ${t} as JSONC`,warnings:x(n,e),wranglerPath:t};const d=x(n,e,a);if(s!==void 0){const o=a.env?.[s]!==void 0;d.push(o?`auto-provisioned bindings are written to the top level of wrangler.jsonc only — "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 g=n.containers.filter(o=>o.exported),l=n.agents.filter(o=>o.exported&&o.voice===!0&&o.voiceBindingName!==void 0&&o.voiceClassName!==void 0),u=[...n.durableObjects,...g.map(o=>({binding:o.bindingName,className:o.className})),...l.map(o=>({binding:o.voiceBindingName,className:o.voiceClassName}))],p=n.workflows.filter(o=>o.exported),h=n.agents.filter(o=>o.exported),r=[{enabled:!0,run:o=>G(o,a,u)},{enabled:n.needsD1,run:o=>Q(o,a)},{enabled:n.usesAi,run:o=>y(o,a,"ai","AI","AI (Workers AI)")},{enabled:n.usesBrowser,run:o=>y(o,a,"browser","BROWSER","BROWSER (Browser Rendering)")},{enabled:n.usesImages,run:o=>y(o,a,"images","IMAGES","IMAGES (Cloudflare Images)")},{enabled:n.usesAnalytics,run:o=>U(o,a)},{enabled:!0,run:o=>Z(o,a)},{enabled:g.length>0,run:o=>J(o,a,g)},{enabled:p.length>0||h.length>0,run:o=>ee(o,a,p,h)},{enabled:n.queues.length>0,run:o=>ne(o,a,n.queues)}];let m=c;const f=[];for(const o of r){if(!o.enabled)continue;const E=o.run(m);m=E.text,f.push(...E.added)}return f.includes("DB (D1)")&&d.push(`wrote a DB binding with a placeholder database_id ("${k}") — run \`wrangler d1 create <name>\` and replace it before deploying.`),m===c?{added:[],changed:!1,exportGaps:i,reason:"bindings already in sync",warnings:d,wranglerPath:t}:(B(t,m,"utf8"),{added:f,changed:!0,exportGaps:i,warnings:d,wranglerPath:t})};export{M as collectExportGaps,le as reconcileWranglerBindings};
|