@lunora/config 1.0.0-alpha.292 → 1.0.0-alpha.294

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/dist/cloudflare/index.d.mts +92 -14
  2. package/dist/cloudflare/index.d.ts +92 -14
  3. package/dist/cloudflare/index.mjs +1 -1
  4. package/dist/index.d.mts +2 -2
  5. package/dist/index.d.ts +2 -2
  6. package/dist/index.mjs +1 -1
  7. package/dist/packem_shared/BINDING_MANIFEST_VERSION-CFVuo3vP.mjs +1 -0
  8. package/dist/packem_shared/GLOBAL_FETCH_STRICTLY_PUBLIC_FLAG-f8CnJha3.mjs +1 -0
  9. package/dist/packem_shared/REMOTE_ELIGIBLE_KEYS-BYnYe4el.mjs +1 -0
  10. package/dist/packem_shared/REQUIRED_COMPATIBILITY_DATE-lONKS1B6.mjs +1 -0
  11. package/dist/packem_shared/{UNEXPORTED_CLASS_MARKER-CugcZbPf.mjs → UNEXPORTED_CLASS_MARKER-D9ZP8mPA.mjs} +1 -1
  12. package/dist/packem_shared/{assertWranglerSatisfiesSchema-BiABHeMv.mjs → assertWranglerSatisfiesSchema-B-hQPnhP.mjs} +1 -1
  13. package/dist/packem_shared/collectExportGaps-BRITqV5h.mjs +2 -0
  14. package/dist/packem_shared/discoverSchemaInfo-BguahM6z.mjs +1 -0
  15. package/dist/packem_shared/infer-bindings-B3rsAmY_.mjs +1 -0
  16. package/dist/packem_shared/{schema-info.d-fEhxTb9k.d.mts → infer-bindings.d-Bay0cm0d.d.mts} +76 -54
  17. package/dist/packem_shared/{schema-info.d-fEhxTb9k.d.ts → infer-bindings.d-Bay0cm0d.d.ts} +76 -54
  18. package/dist/packem_shared/inferLunoraBindings-QvG5WKjF.mjs +1 -0
  19. package/dist/packem_shared/materializeServiceDevConfigs-BYuEQ5X3.mjs +1 -0
  20. package/dist/packem_shared/mergeWranglerEnvironment-CTh4zkEL.mjs +1 -0
  21. package/dist/packem_shared/reconcileBindingsSafely-DJgj_7Pl.mjs +1 -0
  22. package/dist/packem_shared/validate-bindings-TA4ZqC4j.mjs +1 -0
  23. package/dist/packem_shared/withTailConsumer-BK5uzf1W.mjs +1 -0
  24. package/dist/packem_shared/wranglerToAlchemy-D8bWeHhd.mjs +6 -0
  25. package/package.json +5 -5
  26. package/dist/packem_shared/BINDING_MANIFEST_VERSION-vItUTnHk.mjs +0 -1
  27. package/dist/packem_shared/REMOTE_ELIGIBLE_KEYS-ikHvqvS5.mjs +0 -1
  28. package/dist/packem_shared/REQUIRED_COMPATIBILITY_DATE-jTnj2MPJ.mjs +0 -1
  29. package/dist/packem_shared/collectExportGaps-CIYe_DRY.mjs +0 -2
  30. package/dist/packem_shared/discoverSchemaInfo-DJvevsCm.mjs +0 -1
  31. package/dist/packem_shared/inferLunoraBindings-DXLEJY9w.mjs +0 -1
  32. package/dist/packem_shared/mergeWranglerEnvironment-DOKJUNH8.mjs +0 -1
  33. package/dist/packem_shared/reconcileBindingsSafely-VBbLYoAx.mjs +0 -1
  34. package/dist/packem_shared/validate-bindings-Dnf1t0SY.mjs +0 -1
  35. package/dist/packem_shared/withTailConsumer-B1NoKIsj.mjs +0 -1
  36. package/dist/packem_shared/wranglerToAlchemy-BMOQYRyw.mjs +0 -6
@@ -1,2 +0,0 @@
1
- import{readFileSync as W,writeFileSync as Y}from"node:fs";import{createRequire as G}from"node:module";import{join as M}from"node:path";import{containerBuildTag as H}from"@lunora/container";import{applyModify as x}from"./applyModify-DKP2l6S9.mjs";import{a as J,r as R}from"./lunora-manifest-v90ZUbVp.mjs";import{parseTree as V,findNodeAtLocation as X}from"jsonc-parser";import{r as z,a as Z,b as ee,c as ne}from"./reconcile-services-3dn35zgy.mjs";import{DEV_VARS_FILE as se,parseDevVariableEntries as te}from"./DEV_VARS_EXAMPLE_FILE-CqLorAxT.mjs";import{packageNamesFromBindings as oe}from"./inferLunoraBindings-DXLEJY9w.mjs";import{requiredSecrets as re}from"./buildPackageSecretsBlock-yv9mjKEW.mjs";import{w as ie,m as ae,s as L,o as I,n as j,p as de}from"./validate-bindings-Dnf1t0SY.mjs";import{findWranglerFile as ce,readWranglerJsonc as le}from"./WRANGLER_FILES-UNW-xY5u.mjs";const ue=[["maxBatchSize","max_batch_size"],["maxBatchTimeout","max_batch_timeout"],["maxRetries","max_retries"],["deadLetterQueue","dead_letter_queue"],["retryDelay","retry_delay"]],P=e=>Object.fromEntries(ue.filter(([n])=>e.tuning[n]!==void 0).map(([n,s])=>[s,e.tuning[n]])),B="queueTuning",ge=/^[\t ]*(?:,[\t ]*)?(?:\/\/[^\n\r]*)?\r?\n/u,pe=/^[\t ]*,/u,me=(e,n)=>{const s=V(e),t=s===void 0?void 0:X(s,[...n])?.parent;if(t?.type==="property"){const r=t.offset+t.length,o=e.lastIndexOf(`
2
- `,t.offset-1)+1,l=ge.exec(e.slice(r));if(l!==null&&e.slice(o,t.offset).trim()===""){const u=t.parent?.children??[],h=u.indexOf(t),a=h===u.length-1&&h>0?u[h-1]:void 0,d=a===void 0?void 0:pe.exec(e.slice(a.offset+a.length))??void 0;return(d===void 0||a===void 0?e.slice(0,o):e.slice(0,a.offset+a.length)+e.slice(a.offset+a.length+d[0].length,o))+e.slice(r+l[0].length)}}return x(e,n,void 0)},K=(e,n,s,t,r,o=new Set)=>{const l=s.join("."),u={},h=[],a=[];let d=e;return{entries:n.map((c,v)=>{const g=t(c);if(g===void 0||c.queue===void 0)return c;const m=Object.fromEntries(Object.entries(P(g)).filter(([f])=>!o.has(f))),b=Object.entries(r[c.queue]??{}).filter(([f])=>!Object.hasOwn(m,f)),w=Object.entries(m).filter(([f,_])=>c[f]!==_),k=b.filter(([f,_])=>c[f]===_).map(([f])=>f),S=Object.fromEntries(Object.entries({...c,...m}).filter(([f])=>!k.includes(f)));for(const[f,_]of w)d=x(d,[...s,v,f],_);for(const f of k)d=me(d,[...s,v,f]);for(const[f,_]of b){const N=c[f];N!==void 0&&N!==_&&a.push(`${l}/${c.queue}: ${f} is no longer declared by defineQueue, but it was changed by hand to ${JSON.stringify(N)} from the declared ${JSON.stringify(_)}, so it was kept. Delete it from wrangler.jsonc if it should go.`)}return(w.length>0||k.length>0)&&h.push(`${l}/${c.queue} (${[...w.map(([f])=>f),...k.map(f=>`removed ${f}`)].join(", ")})`),Object.keys(m).length>0&&(u[c.queue]=m),S}),owned:u,text:d,updated:h,warnings:a}},fe=(e,n,s,t)=>{const r=n.queues??{},o=r.producers??[],l=r.consumers??[],u=new Set(o.map(g=>g.binding)),h=new Set(l.map(g=>g.queue)),a=s.filter(g=>!u.has(g.bindingName)),d=s.filter(g=>!h.has(g.name)),p=K(e,l,["queues","consumers"],g=>s.find(m=>m.name===g.queue),t);let c=p.text;const v={...p.owned};if(a.length>0||d.length>0){const g=[...o,...a.map(b=>({binding:b.bindingName,queue:b.name}))],m=[...p.entries,...d.map(b=>({queue:b.name,...b.mode==="pull"?{type:"http_pull"}:{},...P(b)}))];for(const b of d){const w=P(b);Object.keys(w).length>0&&(v[b.name]=w)}c=x(c,["queues"],{consumers:m,producers:g})}return{added:[...a.map(g=>`queues.producers/${g.bindingName}`),...d.map(g=>`queues.consumers/${g.name}`)],owned:v,text:c,updated:p.updated,warnings:p.warnings}},he=(e,n,s,t,r)=>{const o=n.env?.[t],l=o?.queues?.consumers??[],u=o?.queues?.producers??[],h=c=>{const v=u.find(g=>g.queue===c.queue)?.binding;return v!==void 0?s.find(g=>g.bindingName===v):s.find(g=>g.name===c.queue&&!u.some(m=>m.binding===g.bindingName))},a=K(e,l,["env",t,"queues","consumers"],h,r,new Set(["dead_letter_queue"])),d=l.filter(c=>c.queue!==void 0&&h(c)===void 0).map(c=>`env.${t}.queues.consumers/${String(c.queue)}: no defineQueue export matches it — this block declares no producer mapping one of their bindings to "${String(c.queue)}", and no export is named that — so it was not retuned. A consumer for a queue another worker produces is skipped the same way.`),p=l.flatMap(c=>{const v=h(c)?.tuning.deadLetterQueue;return v===void 0||c.dead_letter_queue!==void 0?[]:[`env.${t}.queues.consumers/${String(c.queue)}: defineQueue declares deadLetterQueue "${v}", but this consumer has no dead_letter_queue, so its exhausted messages are dropped. Queue names differ per environment, so reconcile does not write it here; add it by hand.`]});return{added:[],owned:a.owned,text:a.text,updated:a.updated,warnings:[...a.warnings,...p,...d]}},be=(e,n)=>{if(e?.lunoraIsForeign===!0)return n.push(`${e.path}: \`lunora\` is not an object, so the queue tuning ownership record cannot be read or written — an option removed from defineQueue stays deployed.`),{};const s=e?.lunora?.[B],t=r=>typeof r=="object"&&r!==null&&!Array.isArray(r);return s===void 0?{}:!t(s)||!Object.values(s).every(r=>t(r)&&Object.values(r).every(o=>t(o)))?(n.push(`${e?.path??"package.json"}: \`lunora.${B}\` is not a map of scope → queue → fields, so it is ignored — an option removed from defineQueue stays deployed until the next pass records it again.`),{}):s},ve=(e,n,s)=>{const t=Object.fromEntries(Object.entries({...n,...s}).filter(([,r])=>Object.keys(r).length>0));J(e,B,Object.keys(t).length===0?void 0:t)},A="PIPELINES",we=(e,n)=>{const s=e.flagshipBinding!==void 0&&!(n?.flagship??[]).some(o=>o.binding===e.flagshipBinding),t=e.usesPipelines&&!(n?.pipelines??[]).some(o=>o.binding===A);return[[e.usesKv&&(n?.kv_namespaces?.length??0)===0,"@lunora/bindings/kv is used but no kv_namespaces binding exists; add a kv_namespaces entry ({ binding, id }) and pass env.<BINDING> to createKv() — the namespace id can't be auto-provisioned."],[e.usesHyperdrive&&(n?.hyperdrive?.length??0)===0,"@lunora/hyperdrive is used but no hyperdrive binding exists; run 'wrangler hyperdrive create' and add a 'hyperdrive' binding ({ binding, id }) — the id can't be auto-provisioned."],[t,`ctx.pipelines is used but no "${A}" pipelines binding exists; run 'wrangler pipelines create <name>' and add a 'pipelines' binding ({ binding: "${A}", stream }) — codegen resolves this one name, and the pipeline resource can't be auto-provisioned.`],[s,`lunora/flags.ts uses Flagship in binding mode but no flagship binding "${e.flagshipBinding??""}" exists; add a flagship entry ({ binding: "${e.flagshipBinding??""}", app_id }) — the app_id can't be auto-provisioned.`]].filter(([o])=>o).map(([,o])=>o)},ye=e=>[[e.usesX402Charge,"@lunora/x402/charge is used; set the recipient wallet address as a [vars] entry (the var name is your choice) and pass it to the charge config — the x402 facilitator settles USDC to that address."],[e.usesX402Pay,"@lunora/x402/pay is used (ActionCtx-only, spends real funds); add a secrets_store_secrets[] binding holding the agent wallet key (binding name == signer.secretName) and pair the pay rail with a spend policy — ctx.secrets reads a Secrets Store binding, not .dev.vars."]].filter(([s])=>s).map(([,s])=>s),C=(e,n,s)=>s.filter(t=>!t.exported).map(t=>`${e} "${t.exportName}" is declared but ${t.className} is not exported by the worker entry; add \`export * from "./lunora/_generated/${n}"\` so its binding can be provisioned.`),_e=(e,n)=>{const s=new Set([...e.workflows,...e.agents].map(o=>o.className));if(s.size===0)return[];const t=Object.entries(n.exports??{}).flatMap(([o,l])=>l?.type==="workflow"?[o]:[]),r=(n.workflows??[]).flatMap(o=>o.class_name===void 0||o.script_name!==void 0?[]:[o.class_name]);return[...new Set([...t,...r])].filter(o=>!s.has(o)).map(o=>`wrangler.jsonc declares workflow "${o}" but no defineWorkflow/defineAgent export generates that class — a leftover from a rename will fail the deploy (wrangler rejects a class the worker does not export). Remove it if it is not hand-wired.`)},xe=(e,n)=>{if(e.queues.length===0)return[];const s=new Set(e.queues.map(r=>r.name)),t=new Set(e.queues.map(r=>r.bindingName));return[...(n.queues?.consumers??[]).flatMap(r=>{const{queue:o}=r;return o===void 0||s.has(o)?[]:[`wrangler.jsonc subscribes queues.consumers[] to "${o}" but no defineQueue export declares that queue — a leftover from a rename keeps delivering batches this worker has no handler for (they retry to exhaustion, then drop or dead-letter). Remove it if it is not hand-wired.`]}),...(n.queues?.producers??[]).flatMap(r=>{const{binding:o}=r;return o===void 0||t.has(o)?[]:[`wrangler.jsonc declares queues.producers[] binding "${o}" but no defineQueue export declares it — a leftover from a rename. Remove it if it is not hand-wired.`]})]},ke=(e,n)=>[..._e(e,n),...xe(e,n)],Q=[{keys:["STRIPE_SECRET_KEY","STRIPE_WEBHOOK_SECRET"],label:"Stripe"},{keys:["POLAR_ACCESS_TOKEN","POLAR_WEBHOOK_SECRET"],label:"Polar"},{keys:["CREEM_API_KEY","CREEM_WEBHOOK_SECRET"],label:"Creem"},{keys:["AUTUMN_SECRET_KEY","AUTUMN_WEBHOOK_SECRET"],label:"Autumn"},{keys:["DODO_PAYMENTS_API_KEY","DODO_PAYMENTS_WEBHOOK_KEY"],label:"Dodo Payments"}],Se=()=>Q.map(({keys:e,label:n})=>`${e[0]} + ${e[1]} (${n})`).join(" or "),Oe=e=>{let n;try{n=W(M(e,se),"utf8")}catch{return!1}const s=new Map(te(n).map(t=>[t.key,t.value]));return Q.some(({keys:t})=>t.every(r=>(s.get(r)??"")!==""))},Ne=(e,n)=>{const s=n?.secrets?.required;if(!Array.isArray(s))return[];const t=new Set(s),r=re(oe(e)).map(o=>o.key).filter(o=>!t.has(o));return r.length===0?[]:[`wrangler.jsonc declares secrets.required without ${r.join(", ")}, which this app needs — wrangler dev loads only the listed keys from .dev.vars, so add ${r.length===1?"it":"them"} to secrets.required.`]},D=(e,n,s)=>{const t=new Set(e.durableObjects.map(u=>u.className)),r=[],o=(s?.r2_buckets?.length??0)>0,l=(s?.d1_databases?.some(u=>u.binding==="DB")??!1)||e.needsD1;return e.usesStorage&&!o&&r.push("@lunora/storage is used but R2 bucket bindings have user-defined names; add an r2_buckets entry and pass env.<BINDING> to createStorage()."),e.usesAuth&&!t.has("SessionDO")&&!l&&r.push("@lunora/auth is used but the worker entry exports no SessionDO; sessions are D1-backed, or export SessionDO to enable DO-backed sessions."),e.usesScheduler&&!t.has("SchedulerDO")&&r.push("@lunora/scheduler is used but the worker entry exports no SchedulerDO; export it so the SCHEDULER binding can be provisioned."),r.push(...C("container","containers",e.containers),...C("workflow","workflows",e.workflows),...C("agent","agents",e.agents)),e.containers.length>0&&s?.observability?.enabled===!1&&r.push("containers are declared but observability is explicitly disabled in wrangler.jsonc — container logs will not be captured."),e.usesPayment&&!Oe(n)&&r.push(`@lunora/payment is used; set one provider's secret pair in .dev.vars — ${Se()}.`),r.push(...ye(e),...we(e,s),...Ne(e,s)),s!==void 0&&r.push(...ke(e,s)),r},F="<replace-with-d1-create-id>",Ee=e=>[["container","containers",e.containers],["workflow","workflows",e.workflows],["agent","agents",e.agents]].flatMap(([s,t,r])=>r.filter(o=>!o.exported).map(({className:o,exportName:l})=>({className:o,exportName:l,kind:s,module:t}))),$e=e=>{const n=new Set(I(e).map(t=>t.tag));let s=1;for(;n.has(`v${String(s)}`);)s+=1;return`v${String(s)}`},qe=e=>{const n=new Set;for(const s of I(e)){for(const t of j(s.deleted_classes))n.delete(t);for(const{from:t,to:r}of I(s.renamed_classes))t!==void 0&&n.delete(t),r!==void 0&&n.add(r);for(const t of[...j(s.new_classes),...j(s.new_sqlite_classes)])n.add(t)}return n},je=(e,n,s)=>{const t=n.durable_objects?.bindings??[],r=new Set(t.map(d=>d.name)),o=s.filter(d=>!r.has(d.binding));let l=e;const u=[];if(o.length>0){const d=[...t,...o.map(p=>({class_name:p.className,name:p.binding}))];l=x(l,["durable_objects","bindings"],d),u.push(...o.map(p=>`${p.binding}/${p.className}`))}const h=n.migrations??[],a=s.map(d=>d.className).filter(d=>!qe(h).has(d));if(a.length>0){const d=[...h,{new_sqlite_classes:a,tag:$e(h)}];l=x(l,["migrations"],d)}return{added:u,text:l}},Ae=(e,n)=>{const s=n.d1_databases??[];if(s.some(o=>o.binding==="DB"))return{added:[],text:e};const t=typeof n.name=="string"&&n.name.length>0?n.name:"lunora",r=[...s,{binding:"DB",database_id:F,database_name:t}];return{added:["DB (D1)"],text:x(e,["d1_databases"],r)}},T=(e,n,s,t,r)=>{const o=n[s]?.binding;return typeof o=="string"&&o.length>0?{added:[],text:e}:{added:[r],text:x(e,[s],{binding:t})}},Ce=(e,n)=>(n.analytics_engine_datasets?.length??0)>0?{added:[],text:e}:{added:["ANALYTICS (Analytics Engine)"],text:x(e,["analytics_engine_datasets"],[{binding:"ANALYTICS",dataset:"ANALYTICS"}])},De=(e,n)=>{const s=n.worker_loaders??[];return s.some(t=>t.binding==="LOADER")?{added:[],text:e}:{added:["LOADER (Worker Loader)"],text:x(e,["worker_loaders"],[...s,{binding:"LOADER"}])}},Te=e=>{if(typeof e=="string")return e;const n={};return e.diskMb!==void 0&&(n.disk_mb=e.diskMb),e.memoryMib!==void 0&&(n.memory_mib=e.memoryMib),e.vcpu!==void 0&&(n.vcpu=e.vcpu),n},Ie=e=>{const{image:n}=e;return n.kind==="dockerfile"?n.dockerfilePath:n.kind==="registry"?n.reference:H(e.exportName)},U=e=>{const n={};for(const[s,t]of Object.entries(e.images??{}))n[s]=t.kind==="registry"?{image:t.reference}:{build_context:t.buildContext,dockerfile:t.dockerfilePath,...e.buildArgs===void 0?{}:{build_vars:e.buildArgs}};return{class_name:e.className,scheduling_policy:"durable_object",...Object.keys(n).length>0?{images:n}:{},...e.name===void 0?{}:{name:e.name}}},Pe=e=>{if(e.schedulingPolicy==="durable_object")return U(e);const{image:n}=e,s={class_name:e.className,image:Ie(e)};return n.kind==="dockerfile"&&(s.image_build_context=n.buildContext),e.buildArgs!==void 0&&n.kind!=="registry"&&(s.image_vars=e.buildArgs),e.instanceType!==void 0&&(s.instance_type=Te(e.instanceType)),e.maxInstances!==void 0&&(s.max_instances=e.maxInstances),e.name!==void 0&&(s.name=e.name),e.rollout?.stepPercentage!==void 0&&(s.rollout_step_percentage=e.rollout.stepPercentage),e.rollout?.gracePeriodSeconds!==void 0&&(s.rollout_active_grace_period=e.rollout.gracePeriodSeconds),s},Be=(e,n,s)=>{const t=n.containers??[],r=new Set(t.map(a=>a.class_name)),o=s.filter(a=>!r.has(a.className));let l=o.length===0?e:x(e,["containers"],[...t,...o.map(a=>Pe(a))]);const u=[],h=[];for(const[a,d]of t.entries()){const p=s.find(g=>g.className===d.class_name);if(p===void 0)continue;const c=p.schedulingPolicy??"default";if((d.scheduling_policy??"default")!==c){h.push(`containers/${p.className} has scheduling_policy "${d.scheduling_policy??"default"}" in wrangler.jsonc but defineContainer "${p.exportName}" declares "${c}" — the policy is immutable, so replace the entry (and its container application) by hand.`);continue}const v=p.schedulingPolicy==="durable_object"?U(p).images:void 0;v!==void 0&&JSON.stringify(d.images)!==JSON.stringify(v)&&(l=x(l,["containers",a,"images"],v),u.push(`containers/${p.className}.images`))}return{added:o.map(a=>`containers/${a.className}`),text:l,updated:u,warnings:h}},Re=(e,n)=>{if(n.observability!==void 0)return{added:[],text:e};const s=x(e,["observability"],{enabled:!0,head_sampling_rate:1});return{added:["observability"],text:s}},We=[{minimum:[4,142],name:"wrangler"},{minimum:[1,61],name:"@cloudflare/vite-plugin"}],Me=(e,n)=>{try{const s=G(M(e,"package.json")).resolve(`${n}/package.json`),[t=0,r=0]=String(JSON.parse(W(s,"utf8")).version).split(".").map(Number);return[t,r]}catch{return}},Le=e=>{const n=We.flatMap(({minimum:s,name:t})=>{const r=Me(e,t);return r!==void 0&&(r[0]<s[0]||r[0]===s[0]&&r[1]<s[1])?[`${t} ${r.join(".")} (needs >= ${s.join(".")})`]:[]});return n.length===0?void 0:`workflows are declared in wrangler \`exports\`, which ${n.join(" and ")} cannot run — reconcile left workflows[] untouched. Upgrade (\`pnpm add -D wrangler@^4.143.1 @cloudflare/vite-plugin@^1.62.1\`) and re-run.`},Ke=e=>Object.entries(e.env??{}).flatMap(([n,s])=>Array.isArray(s?.workflows)?[`env.${n}.workflows declares workflow bindings, but Lunora now declares workflows in \`exports\` and resolves them on ctx.exports — move them to that environment's own \`exports\` by hand.`]:[]),Qe=(e,n,s)=>{let t=e;const r=[],o=[];for(const l of s){const u=n[l.className];if(u?.type==="workflow")for(const{of:h,path:a}of de){const d=h(l),p=L(u,a),c=`exports/${l.className}.${a.join(".")}`;if(d===void 0){p!==void 0&&o.push(`${c} is set in wrangler.jsonc but defineWorkflow "${l.exportName}" does not declare it — reconcile leaves it in place. Remove it by hand if it was dropped from the definition.`);continue}JSON.stringify(p)!==JSON.stringify(d)&&(t=x(t,["exports",l.className,...a],d),r.push(c))}}return{text:t,updated:r,warnings:o}},Fe=(e,n,s,t,r)=>{if(r!==void 0)return{added:[],text:e,warnings:[r]};const o=[...s.map(m=>({settings:ie(m),workflow:m})),...t.map(m=>({settings:{},workflow:m}))],l=new Set(o.map(({workflow:m})=>m.className)),u=n.workflows??[],h=u.filter(m=>m.script_name===void 0&&m.class_name!==void 0&&l.has(m.class_name)),a=n.exports??{},d=[],p=[],c=[];let v=e;for(const{settings:m,workflow:b}of o){if(a[b.className]!==void 0&&a[b.className]!==null)continue;const w=h.find(f=>f.class_name===b.className),k=Object.fromEntries(ae.flatMap(f=>{const _=L(w,[f]);return _===void 0?[]:[[f,_]]})),S=w?.name??b.name;w?.name!==void 0&&w.name!==b.name&&c.push(`workflows/${b.className} is deployed as "${w.name}" but declared as "${b.name}" — its export keeps "${w.name}" so running instances survive. Change the declaration to match, or rename deliberately (it starts a new, empty workflow).`),v=x(v,["exports",b.className],{type:"workflow",...k,...m,name:S}),(w===void 0?d:p).push(`exports/${b.className}`)}if(h.length>0){const m=u.filter(b=>!h.includes(b));v=x(v,["workflows"],m.length===0?void 0:m),p.push(...h.map(b=>`workflows/${String(b.class_name)} → exports`))}c.push(...Ke(n));const g=Qe(v,a,s);return{added:d,text:g.text,updated:[...p,...g.updated],warnings:[...c,...g.warnings]}},on=(e,n,s)=>{const t=ce(e),r=Ee(n);if(!t)return{added:[],changed:!1,exportGaps:r,reason:"wrangler.jsonc not found",updated:[],warnings:D(n,e)};const{parsed:o,text:l}=le(t);if(o===void 0)return{added:[],changed:!1,exportGaps:r,reason:`failed to parse ${t} as JSONC`,updated:[],warnings:D(n,e),wranglerPath:t};const u=D(n,e,o);if(s!==void 0){const i=o.env?.[s]!==void 0;u.push(i?`auto-provisioned bindings are written to the top level of wrangler.jsonc only (queue consumers "env.${s}" already declares are retuned, nothing is added) — "env.${s}" has its own (non-inheritable) bindings and must be reconciled by hand; \`lunora deploy --env ${s}\` now validates them, so a gap here will be reported at deploy time.`:`--env "${s}" was requested but wrangler.jsonc declares no "env.${s}" block — auto-provisioned bindings are written to the top level only and will not apply to that environment.`)}const h=n.containers.filter(i=>i.exported),a=n.agents.filter(i=>i.exported&&i.voice===!0&&i.voiceBindingName!==void 0&&i.voiceClassName!==void 0),d=[...n.durableObjects,...h.map(i=>({binding:i.bindingName,className:i.className})),...a.map(i=>({binding:i.voiceBindingName,className:i.voiceClassName}))],p=n.workflows.filter(i=>i.exported),c=n.agents.filter(i=>i.exported),v=R(e),g=be(v,u),m={},b=z(v);let w;const k=[{enabled:!0,run:i=>je(i,o,d)},{enabled:n.needsD1,run:i=>Ae(i,o)},{enabled:n.usesAi,run:i=>T(i,o,"ai","AI","AI (Workers AI)")},{enabled:n.usesBrowser,run:i=>T(i,o,"browser","BROWSER","BROWSER (Browser Rendering)")},{enabled:n.usesImages,run:i=>T(i,o,"images","IMAGES","IMAGES (Cloudflare Images)")},{enabled:n.usesAnalytics,run:i=>Ce(i,o)},{enabled:n.usesWorkerLoader,run:i=>De(i,o)},{enabled:!0,run:i=>Re(i,o)},{enabled:h.length>0,run:i=>Be(i,o,h)},{enabled:p.length>0||c.length>0,run:i=>Fe(i,o,p,c,Le(e))},{enabled:n.queues.length>0,run:i=>{const y=fe(i,o,n.queues,g.queues??{});return m.queues=y.owned,y}},{enabled:n.services!==void 0&&(n.services.length>0||Object.keys(b).length>0),run:i=>{const y=Z(i,o,n.services??[],b);return w=y.owned,y}},...s===void 0||o.env?.[s]===void 0?[]:[{enabled:n.queues.length>0,run:i=>{const y=`env.${s}.queues`,E=he(i,o,n.queues,s,g[y]??{});return m[y]=E.owned,E}}]];let S=l;const f=[],_=[];for(const i of k){if(!i.enabled)continue;const y=i.run(S);S=y.text,f.push(...y.added),_.push(...y.updated??[]),u.push(...y.warnings??[])}const N=i=>{if(v===void 0)return;const y=w,E=[...Object.keys(m).length>0?[{consequence:"an option removed from defineQueue stays deployed",key:"queueTuning",label:"queue tuning",write:O=>{ve(O,g,m)}}]:[],...y===void 0?[]:[{consequence:"a service removed from lunora.config stays bound",key:"services",label:"service bindings",write:O=>{ne(O,y)}}]];for(const O of E)try{O.write(R(e)??v)}catch(q){u.push(`${i?"wrangler.jsonc was updated, but ":""}recording the ${O.label} reconcile owns in ${v.path} (lunora.${O.key}) failed: ${q instanceof Error?q.message:String(q)}. Until it is recorded, ${O.consequence}.`)}};let $;if(n.services!==void 0){const i=ee(e,n.services,b);u.push(...i.warnings),w={...w,...i.owned},$=i.added.length>0||i.updated.length>0?{added:i.added,path:i.path,updated:i.updated}:void 0}return f.includes("DB (D1)")&&u.push(`wrote a DB binding with a placeholder database_id ("${F}") — run \`wrangler d1 create <name>\` and replace it before deploying.`),S===l?(N(!1),{added:f,changed:!1,devConfig:$,exportGaps:r,reason:"bindings already in sync",updated:_,warnings:u,wranglerPath:t}):(Y(t,S,"utf8"),N(!0),{added:f,changed:!0,devConfig:$,exportGaps:r,updated:_,warnings:u,wranglerPath:t})};export{Ee as collectExportGaps,on as reconcileWranglerBindings};
@@ -1 +0,0 @@
1
- import{existsSync as m}from"node:fs";import{discoverSchema as c,isHyperdriveGlobalTable as l,isD1GlobalTable as d}from"@lunora/codegen";import{Project as f}from"ts-morph";import{join as b}from"node:path";const y=(s,n)=>{const t=b(s,n,"schema.ts");if(!m(t))return{info:void 0};try{const a=new f({skipAddingFilesFromTsConfig:!0,useInMemoryFileSystem:!1}),r=c(a,t,s),i=e=>r.tables.find(o=>o.name===e)?.shape??{};return{info:{hasD1GlobalTable:r.tables.some(e=>d(e)),hasHyperdriveGlobalTable:r.tables.some(e=>l(e)),vectorIndexNames:r.vectorIndexes.map(e=>e.name),vectorMetadata:r.vectorIndexes.flatMap(e=>(e.metadata??[]).map(o=>({index:e.name,kind:i(e.table)[o]?.kind,property:o})))}}}catch(a){return{error:a instanceof Error?a.message:String(a),info:void 0}}};export{y as discoverSchemaInfo};
@@ -1 +0,0 @@
1
- import{existsSync as _,statSync as O,readFileSync as D,readdirSync as U}from"node:fs";import{discoverFlags as Y,FLAGS_FILENAME as M,discoverQueues as W,QUEUES_FILENAME as G,readServiceBindings as K}from"@lunora/codegen";import{parse as C,init as X}from"es-module-lexer";import{discoverAgentInfo as q}from"./discoverAgentInfo-CTdCSfYM.mjs";import{discoverContainerInfo as H}from"./discoverContainerInfo-EhZtEBQs.mjs";import{d as w}from"./discover-info-Vj9d4qYt.mjs";import{escapeRegExp as Q}from"./DEV_VARS_EXAMPLE_FILE-CqLorAxT.mjs";import{discoverSchemaInfo as V}from"./discoverSchemaInfo-DJvevsCm.mjs";import{resolveWorkerEntry as J,COMPOSED_ENTRY_DURABLE_OBJECTS as z,GENERATED_MODULE_DURABLE_OBJECTS as Z,GENERATED_DIRECTORY as k,DURABLE_OBJECT_BINDINGS as ee,detectExportedDurableObjects as se,detectClassExports as y}from"./COMPOSED_WORKER_ENTRY-C69wqbSP.mjs";import{discoverWorkflowInfo as re}from"./discoverWorkflowInfo-BsPvlo6O.mjs";import{join as m}from"node:path";const oe=(e,s)=>{const{error:o,value:r}=w(e,s,M,Y);return o===void 0?{flags:r}:{error:o}},L=/^\s*import\s+type\b/,te=new Set(["@lunora/agent","@lunora/agent/sandbox"]),h=["browserTool","jsCodeTool"],v=Object.fromEntries(h.map(e=>{const s=Q(e);return[e,{fallback:new RegExp(String.raw`import\s+\{[^}]*\b${s}\b[^}]*\}\s+from\s+["']@lunora\/agent(?:\/sandbox)?["']`,"u"),name:new RegExp(String.raw`\b${s}\b`,"u"),typeSpecifier:new RegExp(String.raw`\btype\s+${s}\b`,"u")}]})),ne=e=>{const s=e.indexOf("{");if(s===-1)return"";const o=e.indexOf("}",s+1);return o===-1?e.slice(s+1):e.slice(s+1,o)},ae=(e,s)=>{if(L.test(e))return!1;const o=ne(e);return v[s].name.test(o)&&!v[s].typeSpecifier.test(o)},ie=e=>{let s;try{const[o]=C(e);s=o.filter(r=>r.n!==void 0&&te.has(r.n)).map(r=>e.slice(r.ss,r.se))}catch{s=void 0}return Object.fromEntries(h.map(o=>[o,s===void 0?v[o].fallback.test(e):s.some(r=>ae(r,o))]))},ce=(e,s)=>{const{error:o,value:r}=w(e,s,G,W);return o===void 0?{queues:r??[]}:{error:o,queues:[]}},de=new Set([".cjs",".cts",".js",".jsx",".mjs",".mts",".ts",".tsx"]),ue=new Set([".git",".lunora-cache",".wrangler","dist",k,"node_modules"]),le=["lunora","src"],pe=/\benv\s*\.\s*DB\b/,me=/\benv\s*\.\s*AI\b/,P=/\bctx\s*\.\s*pipelines\b/,B=/\bctx\s*\.\s*r2sql\b/,E={usesAi:{pattern:/\bfrom\s+["']@lunora\/ai["']/,source:"@lunora/ai"},usesAnalytics:{pattern:/\bfrom\s+["']@lunora\/bindings\/analytics["']/,source:"@lunora/bindings/analytics"},usesAuth:{pattern:/\bfrom\s+["']@lunora\/auth["']/,source:"@lunora/auth"},usesBrowser:{pattern:/\bfrom\s+["']@lunora\/browser["']/,source:"@lunora/browser"},usesHyperdrive:{pattern:/\bfrom\s+["']@lunora\/hyperdrive["']/,source:"@lunora/hyperdrive"},usesImages:{pattern:/\bfrom\s+["']@lunora\/bindings\/images["']/,source:"@lunora/bindings/images"},usesKv:{pattern:/\bfrom\s+["']@lunora\/bindings\/kv["']/,source:"@lunora/bindings/kv"},usesMail:{pattern:/\bfrom\s+["']@lunora\/mail["']/,source:"@lunora/mail"},usesNotify:{pattern:/\bfrom\s+["']@lunora\/notify["']/,source:"@lunora/notify"},usesPayment:{pattern:/\bfrom\s+["']@lunora\/payment["']/,source:"@lunora/payment"},usesPipelines:{pattern:P,source:"@lunora/bindings/pipelines"},usesR2sql:{pattern:B,source:"@lunora/bindings/r2sql"},usesScheduler:{pattern:/\bfrom\s+["']@lunora\/scheduler["']/,source:"@lunora/scheduler"},usesStorage:{pattern:/\bfrom\s+["']@lunora\/storage["']/,source:"@lunora/storage"},usesX402Charge:{pattern:/\bfrom\s+["']@lunora\/x402\/charge["']/,source:"@lunora/x402/charge"},usesX402Pay:{pattern:/\bfrom\s+["']@lunora\/x402\/pay["']/,source:"@lunora/x402/pay"}},f=Object.keys(E),fe="STRIPE_SECRET_KEY + STRIPE_WEBHOOK_SECRET (Stripe) or POLAR_ACCESS_TOKEN + POLAR_WEBHOOK_SECRET (Polar)",j=[...f,"needsD1","usesWorkerLoader"],be=()=>{const e={};for(const s of j)e[s]=!1;return e},l=Object.freeze(be()),x=(e,s)=>{const o={};for(const r of j)o[r]=e[r]||s[r];return o},ge=e=>{for(const s of f)if(E[s].source===e)return{...l,[s]:!0};return l},he=e=>{const[s]=C(e);let o=l;for(const r of s){const t=r.n;!t||L.test(e.slice(r.ss,r.se))||(o=x(o,ge(t)))}return o},Ee=e=>{const s={...l};for(const o of f)s[o]=E[o].pattern.test(e);return s},Se=e=>{let s;try{s=he(e)}catch{s=Ee(e)}return x(s,{...l,needsD1:pe.test(e),usesAi:me.test(e),usesPipelines:P.test(e),usesR2sql:B.test(e)})},R=(e,s)=>{let o;try{o=U(e,{withFileTypes:!0})}catch{return}for(const r of o){if(r.isDirectory()){ue.has(r.name)||R(m(e,r.name),s);continue}const t=r.name.lastIndexOf(".");t!==-1&&de.has(r.name.slice(t))&&s.push(m(e,r.name))}},ye=(e,s)=>V(e,s).info?.hasD1GlobalTable??!1,ve=(e,s)=>{let o=l;for(const r of s){const t=m(e,r);if(!_(t)||!O(t).isDirectory())continue;const n=[];R(t,n);for(const a of n)o=x(o,Se(D(a,"utf8")))}return o},_e=(e,s)=>{const o=m(e,s),r=Object.fromEntries(h.map(n=>[n,!1]));if(!_(o)||!O(o).isDirectory())return r;const t=[];R(o,t);for(const n of t){const a=ie(D(n,"utf8"));for(const i of h)r[i]||=a[i]}return r},xe=(e,s,o)=>[...e.map(r=>r.exported?`${r.bindingName}/${r.className} (container "${r.exportName}" declared and exported)`:`hint: container "${r.exportName}" is declared but ${r.className} is not exported by the worker entry — add \`export * from "./lunora/_generated/containers"\``),...s.map(r=>r.exported?`exports.${r.className} (workflow "${r.exportName}" declared and exported)`:`hint: workflow "${r.exportName}" is declared but ${r.className} is not exported by the worker entry — add \`export * from "./lunora/_generated/workflows"\``),...o.map(r=>r.exported?`exports.${r.className} (agent "${r.exportName}" declared and exported)`:`hint: agent "${r.exportName}" is declared but ${r.className} is not exported by the worker entry — add \`export * from "./lunora/_generated/agents"\``)],Re=(e,s)=>[[e.usesAi,"AI (@lunora/ai imported or env.AI used)"],[e.usesAuth&&!s.has("SessionDO"),"hint: @lunora/auth is imported; its tables are D1-backed by default. For DO-backed auth (what @better-auth/scim needs), pass `namespace` to .auth() and export the generated auth DO class"],[e.usesScheduler&&!s.has("SchedulerDO"),"hint: @lunora/scheduler is imported but no SchedulerDO is exported by the worker entry"],[e.usesStorage,"hint: @lunora/storage is imported; add an r2_buckets binding (bucket binding names are user-defined)"],[e.usesMail,"hint: @lunora/mail is imported; set RESEND_API_KEY in .dev.vars (obtain at https://resend.com/api-keys)"],[e.usesPayment,`hint: @lunora/payment is imported; set the provider secrets in .dev.vars — ${fe}`],[e.usesBrowser,"browser (@lunora/browser imported) — self-describing { binding: BROWSER }"],[e.usesImages,"images (@lunora/bindings/images imported) — self-describing { binding: IMAGES }"],[e.usesAnalytics,"analytics_engine_datasets (@lunora/bindings/analytics imported) — self-describing { binding: ANALYTICS, dataset }"],[e.usesWorkerLoader,"worker_loaders (jsCodeTool imported in lunora/) — self-describing { binding: LOADER }"],[e.usesKv,"hint: @lunora/bindings/kv is imported; add a kv_namespaces binding ({ binding, id }) and pass env.<BINDING> to createKv() — the namespace id can't be auto-provisioned"],[e.usesHyperdrive,"hint: @lunora/hyperdrive is imported; run 'wrangler hyperdrive create' and add a 'hyperdrive' binding ({ binding, id }) — the id can't be auto-provisioned"],[e.usesPipelines,"hint: ctx.pipelines is used; run 'wrangler pipelines create <name>' and add a 'pipelines' binding ({ binding, stream }) — the pipeline resource can't be auto-provisioned"],[e.usesX402Charge,"hint: @lunora/x402/charge is imported; set the recipient wallet address as a [vars] entry (the var name is yours to choose) and pass it to the charge config — the x402 facilitator settles USDC to that address"],[e.usesX402Pay,"hint: @lunora/x402/pay is imported (ActionCtx-only, spends real funds); add a secrets_store_secrets[] binding for the agent wallet key (name it to match signer.secretName) and pair the pay rail with a spend policy — ctx.secrets reads a Secrets Store binding, not .dev.vars, so the key can't be auto-provisioned"]].filter(([r])=>r).map(([,r])=>r),Ie=(e,s,o,r=[],t=[],n=[])=>{const a=new Set(e.map(c=>c.className)),i=e.map(c=>`${c.binding}/${c.className} (exported by worker entry)`);return s&&i.push("DB (.global() table declared)"),i.push(...xe(r,t,n),...Re(o,a)),i},je=async e=>{await X;const s=e.schemaDir??"lunora",o=e.scanDirs??le,r=ve(e.projectRoot,o),t=_e(e.projectRoot,s),n={...r,usesBrowser:r.usesBrowser||t.browserTool,usesWorkerLoader:t.jsCodeTool},a=J(e.projectRoot);let i;a.composed?i=[...z,...Object.entries(Z).filter(([u])=>_(m(e.projectRoot,s,k,`${u}.ts`))).map(([,u])=>u)].map(u=>({binding:ee[u],className:u})):i=a.path===void 0?[]:se(a.path);const c=n.needsD1||ye(e.projectRoot,s),I=y(a,H(e.projectRoot,s).containers,"containers"),A=y(a,re(e.projectRoot,s).workflows,"workflows"),N=y(a,q(e.projectRoot,s).agents,"agents"),$=[...ce(e.projectRoot,s).queues],{flags:b}=oe(e.projectRoot,s),S=b?.provider==="flagship"&&b.mode==="binding"?b.bindingName:void 0,T={};for(const d of f)T[d]=n[d];const g=Ie(i,c,n,I,A,N);S!==void 0&&g.push(`hint: lunora/flags.ts uses Flagship in binding mode; add a flagship binding ({ binding: "${S}", app_id }) — the app_id can't be auto-provisioned`);const p=K(e.projectRoot),F=p.error===void 0?p.services:void 0;return p.error!==void 0&&g.push(`hint: lunora.config \`services\` not reconciled — ${p.error}`),g.push(...p.services.map(d=>`${d.binding} → ${d.worker} (lunora.config services.${d.name})`)),{agents:N,containers:I,durableObjects:i,flagshipBinding:S,needsD1:c,queues:$,services:F,signals:g,usesFlags:b!==void 0,usesWorkerLoader:n.usesWorkerLoader,workflows:A,...T}},$e=e=>{const s=[];for(const o of f)e[o]&&s.push(E[o].source);return s};export{je as inferLunoraBindings,$e as packageNamesFromBindings};
@@ -1 +0,0 @@
1
- const c=["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","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};
@@ -1 +0,0 @@
1
- import{inferLunoraBindings as p}from"./inferLunoraBindings-DXLEJY9w.mjs";import{LUNORA_TAG as r}from"./LUNORA_TAG-CiQM3BkI.mjs";import{reconcileWranglerBindings as $}from"./collectExportGaps-CIYe_DRY.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,o)=>{try{const n=await p({projectRoot:i.projectRoot,schemaDir:i.schemaDir}),e=$(i.projectRoot,n),a=e.wranglerPath??"wrangler.jsonc";if(e.added.length>0&&t.info?.(`${r} inferred bindings → ${e.added.join(", ")} (written to ${a})`),e.updated.length>0&&t.info?.(`${r} updated bindings → ${e.updated.join(", ")} (written to ${a})`),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&&o?.(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,o)=>{try{const n=m(i,t);n.changed&&o.info?.(`${r} synced ${t.length.toFixed(0)} cron trigger(s) into ${n.wranglerPath??"wrangler.jsonc"}`);for(const s of n.warnings)o.warn(`${r} ${s}`);const e=n.preserved.join("\0"),a=w(n.preserved);a!==void 0&&(n.changed||c.get(i)!==e)&&o.info?.(`${r} ${a}`),c.set(i,e)}catch(n){const e=n instanceof Error?n.message:String(n);o.warn(`${r} cron trigger sync skipped: ${e}`)}try{const n=g(i);n.changed&&o.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);o.warn(`${r} compatibility date sync skipped: ${e}`)}};export{j as reconcileBindingsSafely,u as reconcileWranglerExtras};
@@ -1 +0,0 @@
1
- const f=[{of:e=>e.schedules===void 0?void 0:[...e.schedules],path:["schedules"]},{of:e=>e.limits?.steps,path:["limits","steps"]},{of:e=>e.defaultRetention?.successRetention,path:["default_retention","success_retention"]},{of:e=>e.defaultRetention?.errorRetention,path:["default_retention","error_retention"]}],D=[...new Set(f.map(({path:e})=>e[0]))],u=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),p=(e,n)=>{let i=e;for(const s of n)i=u(i)?i[s]:void 0;return i},O=e=>{const n={};for(const{of:i,path:s}of f){const a=i(e);if(a===void 0)continue;const[t,o]=s;n[t]=o===void 0?a:{...n[t],[o]:a}}return n},I=(e,n,i)=>{if(n.length===0)return;const s=e.vectorize??[],a=new Set(s.filter(Boolean).map(t=>t?.index_name));for(const t of n)a.has(t)||i.push(`schema declares vector index "${t}"; wrangler "vectorize" must include a binding with index_name "${t}"`)},v=new Set(["basic","dev","lite","standard","standard-1","standard-2","standard-3","standard-4"]),$={disk_mb:2e4,memory_mib:12288,vcpu:4},k=(e,n,i)=>{const s=e.instance_type;if(s===void 0)return;if(typeof s=="string"){v.has(s)||i.push(`${n} has unknown instance_type "${s}" — expected lite, basic, standard-1..4, or a custom { vcpu, memory_mib, disk_mb } object`);return}for(const[r,c]of Object.entries($)){const m=s[r];m!==void 0&&(typeof m!="number"||m<=0||m>c)&&i.push(`${n} custom instance_type ${r} must be a positive number ≤ ${String(c)} (got ${String(m)})`)}const{disk_mb:a,memory_mib:t,vcpu:o}=s;if(typeof o=="number"&&typeof t=="number"&&t<o*3072&&i.push(`${n} custom instance_type needs ≥ 3 GiB (3072 MiB) memory per vCPU (got ${String(t)} MiB for ${String(o)} vCPU)`),typeof t=="number"&&typeof a=="number"){const r=Math.floor(t/1024*2e3);a>r&&i.push(`${n} custom instance_type allows ≤ 2 GB disk per GiB memory (≤ ${String(r)} MB for ${String(t)} MiB memory; got ${String(a)} MB)`)}},w=(e,n,i)=>{for(const s of["image","instance_type","max_instances"])e[s]!==void 0&&i.push(`${n} sets "${s}", which the durable_object scheduling policy does not take — the Durable Object picks image and size at start`);for(const[s,a]of Object.entries(e.images??{}))[a?.dockerfile,a?.image].filter(o=>typeof o=="string"&&o.length>0).length!==1&&i.push(`${n} images["${s}"] must set exactly one of "dockerfile" or "image"`)},M=(e,n,i)=>{const{boundClasses:s,classKinds:a,errors:t,warnings:o}=i;if(!e||typeof e!="object"||typeof e.class_name!="string"||e.class_name.length===0){t.push(`${n} must have a non-empty "class_name" naming its container-enabled Durable Object class`);return}const r=e.scheduling_policy==="durable_object";e.scheduling_policy!==void 0&&e.scheduling_policy!=="default"&&!r&&t.push(`${n} ("${e.class_name}") has unknown scheduling_policy "${e.scheduling_policy}" — expected "default" or "durable_object"`),r?w(e,`${n} ("${e.class_name}")`,t):(typeof e.image!="string"||e.image.length===0)&&t.push(`${n} ("${e.class_name}") must have an "image" — a Dockerfile path or a registry reference`),s.has(e.class_name)||t.push(`${n} class "${e.class_name}" has no matching durable_objects binding — your dev server auto-reconciles this on startup; add { "name": "...", "class_name": "${e.class_name}" } to fix it by hand`);const c=a.get(e.class_name);c!=="sqlite"&&t.push(c==="classic"?`${n} class "${e.class_name}" is registered via "new_classes" but containers require SQLite-backed DOs — move it to "new_sqlite_classes"`:`${n} class "${e.class_name}" is missing from migrations — add a migration entry with "new_sqlite_classes": ["${e.class_name}"]`),k(e,`${n} ("${e.class_name}")`,t),e.max_instances===void 0&&!r&&o.push(`${n} ("${e.class_name}") declares no max_instances — set a cap so a traffic spike can't fan out unbounded container spend`)},d=e=>typeof e=="string"&&e.length>0,g=e=>Array.isArray(e)?e.filter(n=>n!==null&&typeof n=="object"):[],l=e=>Array.isArray(e)?e.filter(n=>d(n)):[],_=e=>{const n=new Map;for(const i of g(e)){for(const s of l(i.new_classes))n.set(s,"classic");for(const s of l(i.new_sqlite_classes))n.set(s,"sqlite");for(const s of g(i.renamed_classes))if(d(s.from)&&d(s.to)){const a=n.get(s.from)??"sqlite";n.delete(s.from),n.set(s.to,a)}for(const s of l(i.deleted_classes))n.delete(s)}return n},S=e=>new Set(_(e).keys()),N=(e,n)=>{const i=S(e.migrations);for(const s of g(e.durable_objects?.bindings))s.script_name===void 0&&d(s.class_name)&&!i.has(s.class_name)&&n.push(`durable_objects.bindings declares class "${s.class_name}" but it is missing from migrations — add a migration entry with "new_sqlite_classes": ["${s.class_name}"] (or "new_classes" for a non-SQLite-backed class), or let the dev server auto-reconcile it on the next start`)},C=(e,n,i)=>{if(e.containers===void 0)return;if(!Array.isArray(e.containers)){n.push("containers must be an array of { class_name, image, ... } entries");return}const s=e.containers;if(s.length===0)return;const a=new Set(g(e.durable_objects?.bindings).map(o=>o.class_name)),t=_(e.migrations);for(const[o,r]of s.entries())M(r,`containers[${String(o)}]`,{boundClasses:a,classKinds:t,errors:n,warnings:i});e.observability?.enabled!==!0&&i.push('containers are configured but observability is not enabled — container logs will not be captured (add { "observability": { "enabled": true } })')},b=e=>e,h=(e,n,i,s)=>{if(e!==void 0){if(!Array.isArray(e)){s.push(i.arrayMessage);return}for(const[a,t]of b(e).entries()){const o=`${n}[${String(a)}]`;if(!t||typeof t!="object"){s.push(i.objectMessage(o));continue}for(const r of i.fields)d(t[r.field])||s.push(r.message(o))}}},F={arrayMessage:"workflows must be an array of { name, binding, class_name } entries",fields:[{field:"binding",message:e=>`${e} must have a non-empty "binding" naming the Workflow binding (e.g. MY_WORKFLOW)`},{field:"class_name",message:e=>`${e} must have a non-empty "class_name" naming the exported WorkflowEntrypoint class`},{field:"name",message:e=>`${e} must have a non-empty "name" naming the deployed workflow`}],objectMessage:e=>`${e} must be a { name, binding, class_name } object`},j=(e,n)=>e===void 0||n&&d(e)||Array.isArray(e)&&e.length>0&&e.every(s=>d(s))?void 0:"schedules must be a non-empty array of cron expression strings",E=e=>{if(e!==void 0)return u(e)?e.steps===void 0||Number.isInteger(e.steps)&&e.steps>0?void 0:"limits.steps must be a positive integer":"limits must be an object"},x=e=>e===void 0?[]:u(e)?["success_retention","error_retention"].filter(n=>e[n]!==void 0&&!d(e[n])).map(n=>`default_retention.${n} must be a duration string (e.g. "7 days")`):["default_retention must be an object"],y=(e,n,i,s)=>{const a=[j(e.schedules,i),E(e.limits),...x(e.default_retention)];for(const t of a)t!==void 0&&s.push(`${n}.${t}`)},A=(e,n)=>f.map(({path:i})=>i).filter(i=>{const s=p(e,i),a=p(n,i),t=typeof a=="string"&&i[0]==="schedules"?[a]:a;return s!==void 0&&a!==void 0&&JSON.stringify(s)!==JSON.stringify(t)}).map(i=>i.join(".")),R=(e,n,i,s)=>{const a=`exports["${e}"]`,t=String(n.name);for(const o of i){if(!u(o)||o.name!==n.name)continue;const r=`workflows entry "${String(o.binding)}"`;if(o.script_name!==void 0){s.push(`${r} binds workflow "${t}" in another Worker, but ${a} declares a workflow with that name here — workflow names are unique per account`);continue}o.class_name!==e&&s.push(`${r} and ${a} both declare workflow "${t}" but name different classes ("${String(o.class_name)}" vs "${e}")`);for(const c of A(o,n))s.push(`${r} and ${a} set ${c} to different values for workflow "${t}" — set it in one place`)}},L=(e,n)=>{const i=Array.isArray(e.workflows)?b(e.workflows):[];for(const[a,t]of i.entries())u(t)&&y(t,`workflows[${String(a)}]`,!1,n);const s=u(e.exports)?Object.entries(e.exports):[];for(const[a,t]of s)!u(t)||t.type!=="workflow"||(d(t.name)?(y(t,`exports["${a}"]`,!0,n),R(a,t,i,n)):n.push(`exports["${a}"] is a workflow export and must have a non-empty "name" naming the deployed workflow`))},q={arrayMessage:"queues.producers must be an array of { binding, queue } entries",fields:[{field:"binding",message:e=>`${e} must have a non-empty "binding" naming the Queue producer (e.g. QUEUE_EMAIL)`},{field:"queue",message:e=>`${e} must have a non-empty "queue" naming the deployed queue`}],objectMessage:e=>`${e} must be a { binding, queue } object`},B={arrayMessage:"queues.consumers must be an array of { queue } entries",fields:[{field:"queue",message:e=>`${e} must have a non-empty "queue" naming the consumed queue`}],objectMessage:e=>`${e} must be a { queue } object`},U=(e,n)=>{if(e.queues!==void 0){if(typeof e.queues!="object"||Array.isArray(e.queues)){n.push("queues must be a { producers, consumers } object");return}h(e.queues.producers,"queues.producers",q,n),h(e.queues.consumers,"queues.consumers",B,n)}},T={arrayMessage:"secrets_store_secrets must be an array of { binding, store_id, secret_name } entries",fields:["binding","store_id","secret_name"].map(e=>({field:e,message:n=>`${n} must have a non-empty "${e}"`})),objectMessage:e=>`${e} must be a { binding, store_id, secret_name } object`},W=[{arrayMessage:"kv_namespaces must be an array of { binding, id } entries",bindingMessage:e=>`${e} must have a non-empty "binding" naming the KV namespace binding`,hintField:"id",hintMessage:(e,n)=>`${e} ("${n}") has no "id" — run \`wrangler kv namespace create\` and set the namespace id, or the binding can't resolve`,key:"kv_namespaces"},{arrayMessage:"flagship must be an array of { binding, app_id } entries",bindingMessage:e=>`${e} must have a non-empty "binding" naming the Flagship binding`,hintField:"app_id",hintMessage:(e,n)=>`${e} ("${n}") has no "app_id" — create a Flagship app and set its id, or the binding can't resolve`,key:"flagship"},{arrayMessage:"hyperdrive must be an array of { binding, id } entries",bindingMessage:e=>`${e} must have a non-empty "binding" naming the Hyperdrive binding`,hintField:"id",hintMessage:(e,n)=>`${e} ("${n}") has no "id" — run \`wrangler hyperdrive create\` and set the id, or the binding can't connect`,key:"hyperdrive"},{arrayMessage:"pipelines must be an array of { binding, stream } entries",bindingMessage:e=>`${e} must have a non-empty "binding" naming the Pipelines binding`,hintField:["stream","pipeline"],hintMessage:(e,n)=>`${e} ("${n}") has no "stream" — run \`wrangler pipelines create <name>\` and set the stream name, or the binding can't resolve`,key:"pipelines"},{arrayMessage:"analytics_engine_datasets must be an array of { binding, dataset } entries",bindingMessage:e=>`${e} must have a non-empty "binding" naming the Analytics Engine binding`,hintField:"dataset",hintMessage:(e,n)=>`${e} ("${n}") has no "dataset" — it defaults to the binding name; set it explicitly to avoid drift`,key:"analytics_engine_datasets"}],G=(e,n,i,s)=>{const a=e[n.key];if(a!==void 0){if(!Array.isArray(a)){i.push(n.arrayMessage);return}for(const[t,o]of b(a).entries()){const r=`${n.key}[${String(t)}]`;if(!o||typeof o!="object"||!d(o.binding)){i.push(n.bindingMessage(r));continue}(typeof n.hintField=="string"?[n.hintField]:n.hintField).some(m=>d(o[m]))||s.push(n.hintMessage(r,o.binding))}}},P=[{key:"browser",message:'browser must be an object with a non-empty "binding" (e.g. { "binding": "BROWSER" })'},{key:"images",message:'images must be an object with a non-empty "binding" (e.g. { "binding": "IMAGES" })'},{key:"media",message:'media must be an object with a non-empty "binding" (e.g. { "binding": "MEDIA" })'},{key:"stream",message:'stream must be an object with a non-empty "binding" (e.g. { "binding": "STREAM" })'}],K=(e,n,i)=>{const s=e[n.key];s!==void 0&&(typeof s!="object"||s===null||Array.isArray(s)||!d(s.binding))&&i.push(n.message)},Q=[{arrayMessage:"services must be an array of { binding, service, entrypoint? } entries",fields:[{field:"binding",message:e=>`${e} must have a non-empty "binding" naming the service binding`},{field:"service",message:e=>`${e} must have a non-empty "service" naming the target Worker`}],key:"services",objectMessage:e=>`${e} must be a { binding, service, entrypoint? } object`},{arrayMessage:"dispatch_namespaces must be an array of { binding, namespace } entries",fields:[{field:"binding",message:e=>`${e} must have a non-empty "binding"`},{field:"namespace",message:e=>`${e} must have a non-empty "namespace" naming the dispatch namespace`}],key:"dispatch_namespaces",objectMessage:e=>`${e} must be a { binding, namespace } object`},{arrayMessage:"mtls_certificates must be an array of { binding, certificate_id } entries",fields:[{field:"binding",message:e=>`${e} must have a non-empty "binding"`},{field:"certificate_id",message:e=>`${e} must have a non-empty "certificate_id" (upload via \`wrangler mtls-certificate upload\`)`}],key:"mtls_certificates",objectMessage:e=>`${e} must be a { binding, certificate_id } object`},{arrayMessage:"r2_buckets must be an array of { binding, bucket_name } entries",fields:[{field:"binding",message:e=>`${e} must have a non-empty "binding" naming the R2 bucket binding`},{field:"bucket_name",message:e=>`${e} must have a non-empty "bucket_name" naming the deployed bucket`}],key:"r2_buckets",objectMessage:e=>`${e} must be a { binding, bucket_name } object`},{arrayMessage:"vpc_services must be an array of { binding, service_id } entries",fields:[{field:"binding",message:e=>`${e} must have a non-empty "binding" naming the VPC Service binding`},{field:"service_id",message:e=>`${e} must have a non-empty "service_id" (create one with \`wrangler vpc service create\`)`}],key:"vpc_services",objectMessage:e=>`${e} must be a { binding, service_id } object`},{arrayMessage:"artifacts must be an array of { binding, namespace } entries",fields:[{field:"binding",message:e=>`${e} must have a non-empty "binding" naming the Artifacts binding`},{field:"namespace",message:e=>`${e} must have a non-empty "namespace" naming the Artifacts namespace`}],key:"artifacts",objectMessage:e=>`${e} must be a { binding, namespace } object`}],z=(e,n,i)=>{n?.hasD1GlobalTable&&!g(e.d1_databases).some(s=>s.binding==="DB")&&i.push('schema declares .global() tables; d1_databases must include a binding named "DB" — your dev server auto-reconciles this on startup, or add the binding manually'),n?.hasHyperdriveGlobalTable&&g(e.hyperdrive).length===0&&i.push('schema declares .global({ backend: "hyperdrive" }) tables; wrangler must declare a hyperdrive binding for `.hyperdriveGlobal({ exec })` to read — run `wrangler hyperdrive create <name> --connection-string=...` and add `"hyperdrive": [{ "binding": "HYPERDRIVE", "id": "<id>" }]` (any binding name works; your `exec` selector picks it)')},H=(e,n)=>{const{d1_databases:i}=e;if(i!==void 0){if(!Array.isArray(i)){n.push("d1_databases must be an array of { binding, database_id | database_name } entries");return}for(const[s,a]of b(i).entries()){const t=`d1_databases[${String(s)}]`;if(!a||typeof a!="object"){n.push(`${t} must be a { binding, database_id | database_name } object`);continue}d(a.binding)||n.push(`${t} must have a non-empty "binding" naming the D1 binding`),!d(a.database_id)&&!d(a.database_name)&&n.push(`${t} must have a "database_id" or a "database_name" — run \`wrangler d1 create\` and set one, or the binding can't resolve`)}}},V=(e,n)=>{const{vpc_networks:i}=e;if(i!==void 0){if(!Array.isArray(i)){n.push("vpc_networks must be an array of { binding, tunnel_id | network_id } entries");return}for(const[s,a]of b(i).entries()){const t=`vpc_networks[${String(s)}]`;if(!a||typeof a!="object"){n.push(`${t} must be a { binding, tunnel_id | network_id } object`);continue}d(a.binding)||n.push(`${t} must have a non-empty "binding" naming the VPC Network binding`),d(a.tunnel_id)===d(a.network_id)&&n.push(`${t} must set exactly one of "tunnel_id" (a Cloudflare Tunnel) or "network_id" ("cf1:network" for Cloudflare Mesh)`)}}};export{W as H,Q as R,P as S,F as W,z as a,H as b,I as c,C as d,h as e,L as f,U as g,G as h,K as i,V as j,T as k,d as l,D as m,l as n,g as o,f as p,p as s,N as v,O as w};
@@ -1 +0,0 @@
1
- import{l as d,o as p}from"./validate-bindings-Dnf1t0SY.mjs";const b=new Set(["1","enabled","on","true","yes"]),m=s=>typeof s=="string"&&b.has(s.trim().toLowerCase()),y=(s,t,e)=>{const i=s.send_email;if(i===void 0)return;if(!Array.isArray(i)){t.push("send_email must be an array of { name, destination_address? } entries");return}const n=i;for(const[o,a]of n.entries())(!a||typeof a!="object"||typeof a.name!="string"||a.name.length===0)&&e.push(`send_email[${String(o)}] has no non-empty "name" naming the send-email binding — set one before deploying`)},g=(s,t)=>{s.logpush!==void 0&&typeof s.logpush!="boolean"&&t.push('logpush must be a boolean (set "logpush": true to enable Cloudflare Logpush)')},v=(s,t)=>{const e=s.secrets;if(e===void 0)return;const i=typeof e=="object"&&e!==null&&!Array.isArray(e)?e.required:void 0;(!Array.isArray(i)||i.some(n=>typeof n!="string"||n===""))&&t.push('secrets must be an object whose "required" is an array of secret names (e.g. { "required": ["API_KEY"] })')},c=3e5,_=(s,t)=>{const{limits:e}=s;if(e===void 0)return;if(typeof e!="object"||Array.isArray(e)){t.push('limits must be an object (e.g. { "cpu_ms": 30000 })');return}const i=e.cpu_ms;if(i!==void 0){if(typeof i!="number"||!Number.isFinite(i)||!Number.isInteger(i)||i<=0){t.push("limits.cpu_ms must be a positive integer number of milliseconds");return}i>c&&t.push(`limits.cpu_ms must be at most ${String(c)} (Cloudflare's per-invocation ceiling)`)}},l=new Set(["off","smart","targeted"]),A=(s,t)=>{const{placement:e}=s;if(e===void 0)return;if(typeof e!="object"||e===null||Array.isArray(e)){t.push('placement must be an object (e.g. { "mode": "smart" })');return}const{mode:i}=e;i!==void 0&&(typeof i!="string"||!l.has(i))&&t.push(`placement.mode must be one of ${[...l].map(n=>`"${n}"`).join(", ")}`)},j=(s,t)=>{const{observability:e}=s;if(e===void 0)return;if(typeof e!="object"||Array.isArray(e)){t.push('observability must be an object (e.g. { "enabled": true, "head_sampling_rate": 1 })');return}const i=(n,o)=>{n!==void 0&&(typeof n!="number"||Number.isNaN(n)||n<0||n>1)&&t.push(`${o} must be a number in [0, 1] (the fraction of requests sampled)`)};i(e.head_sampling_rate,"observability.head_sampling_rate"),e.logs!==void 0&&(typeof e.logs!="object"||Array.isArray(e.logs)?t.push("observability.logs must be an object"):(i(e.logs.head_sampling_rate,"observability.logs.head_sampling_rate"),e.logs.invocation_logs!==void 0&&typeof e.logs.invocation_logs!="boolean"&&t.push('observability.logs.invocation_logs must be a boolean (set "invocation_logs": true to keep per-invocation summaries)')))},S=(s,t)=>{const{cache:e}=s;if(e!==void 0){if(typeof e!="object"||e===null||Array.isArray(e)){t.push('cache must be an object (e.g. { "enabled": true })');return}e.enabled!==void 0&&typeof e.enabled!="boolean"&&t.push("cache.enabled must be a boolean (true or false)")}},O=(s,t)=>{const{exports:e}=s;if(e!==void 0){if(typeof e!="object"||e===null||Array.isArray(e)){t.push("exports must be an object keyed by entrypoint name");return}for(const[i,n]of Object.entries(e)){if(typeof n!="object"||n===null){t.push(`exports["${i}"] must be an object`);continue}n.type!==void 0&&typeof n.type!="string"&&t.push(`exports["${i}"].type must be a string`),n.cache!==void 0&&(typeof n.cache!="object"||n.cache===null||Array.isArray(n.cache)?t.push(`exports["${i}"].cache must be an object`):n.cache.enabled!==void 0&&typeof n.cache.enabled!="boolean"&&t.push(`exports["${i}"].cache.enabled must be a boolean`))}}},E=(s,t)=>{const{assets:e}=s;if(e!==void 0){if(typeof e!="object"||Array.isArray(e)){t.push('assets must be an object (e.g. { "directory": "./dist/client", "binding": "ASSETS" })');return}(typeof e.directory!="string"||e.directory.length===0)&&t.push('assets must declare a non-empty "directory" pointing at the built client output (e.g. "./dist/client")'),e.binding!==void 0&&(typeof e.binding!="string"||e.binding.length===0)&&t.push('assets.binding must be a non-empty string (e.g. "ASSETS")'),e.html_handling!==void 0&&typeof e.html_handling!="string"&&t.push("assets.html_handling must be a string"),e.not_found_handling!==void 0&&typeof e.not_found_handling!="string"&&t.push("assets.not_found_handling must be a string")}},L=(s,t)=>{const e=s.tail_consumers;if(e===void 0)return;if(!Array.isArray(e)){t.push("tail_consumers must be an array of { service, environment? } entries");return}const i=e;for(const[n,o]of i.entries())(!o||typeof o!="object"||typeof o.service!="string"||o.service.length===0)&&t.push(`tail_consumers[${String(n)}] must have a non-empty "service" naming the consumer Worker`)},N=(s,t)=>{const e=s.tail_consumers??[];return e.some(n=>!!n&&n?.service===t.service&&n?.environment===t.environment)?s:{...s,tail_consumers:[...e,t]}},R=(s,t)=>{const{vars:e}=s;if(!e||typeof e!="object")return;const i=e.LUNORA_ALLOWED_ORIGINS,n=e.LUNORA_CORS_ALLOW_CREDENTIALS,o=typeof i=="string"&&i.split(",").some(u=>u.trim()==="*"),a=m(n);o&&a&&t.push('vars.LUNORA_ALLOWED_ORIGINS includes a "*" wildcard while vars.LUNORA_CORS_ALLOW_CREDENTIALS is on — browsers reject this combination and it defeats the allowlist; name explicit origins or drop credentials')},f=s=>p(s.durable_objects?.bindings).some(t=>t.class_name==="SchedulerDO"&&t.script_name===void 0),r="LUNORA_ORIGIN_URL",$=(s,t,e)=>{if(!f(s)||d(s.vars?.[r]))return;const i=t===void 0?"vars":`env.${t}.vars`,n=t===void 0?"":` --env ${t}`;e.push(`durable_objects.bindings declares the SchedulerDO but ${i}.${r} is unset — the DO reads its dispatch origin from its own env and refuses to schedule without it, so every ctx.scheduler.runAfter/runAt fails with ORIGIN_NOT_CONFIGURED. Set ${i}.${r} to the worker's public URL, or \`wrangler secret put ${r}${n}\` (ignore this if it is already set as a secret or in the dashboard).`)};export{E as validateAssets,S as validateCache,R as validateCorsVariables,O as validateExports,_ as validateLimits,g as validateLogpush,j as validateObservability,A as validatePlacement,$ as validateSchedulerOrigin,v as validateSecretsRequired,y as validateSendEmail,L as validateTailConsumers,N as withTailConsumer};
@@ -1,6 +0,0 @@
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,s=u(e))=>{const n=d(e);return n&&s===e?`${e},`:`${n?e:o(e)}: ${s},`},g=e=>{const s=new Set;for(const n of e.migrations??[])for(const r of n.new_sqlite_classes??[])s.add(r);return s},v=(e,s,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(s.has(a.class_name))} })`))}},h=(e,s)=>{for(const[n,r]of Object.entries(e.vars??{}))s.push(m(n,o(r)))},w=["ai","analytics_engine_datasets","assets","browser","containers","flagship","hyperdrive","images","pipelines","secrets_store_secrets","send_email","services","tail_consumers","vectorize","worker_loaders","workflows","exports"],f=(e,s)=>{for(const n of w){const r=e[n];r!==void 0&&(!Array.isArray(r)||r.length>0)&&s.push(n)}(e.queues?.consumers?.length??0)>0&&s.push("queues.consumers")},k=e=>{const s=e.name??"worker",n=[],r=new Set(["Worker"]),c=[],a=[],p=g(e),b=[{construct:"D1Database",entries:(e.d1_databases??[]).map(t=>({binding:t.binding,name:t.database_name})),nameKey:"name"},{construct:"R2Bucket",entries:(e.r2_buckets??[]).map(t=>({binding:t.binding,name:t.bucket_name})),nameKey:"name"},{construct:"KVNamespace",entries:(e.kv_namespaces??[]).map(t=>({binding:t.binding,name:t.binding})),nameKey:"title"},{construct:"Queue",entries:(e.queues?.producers??[]).map(t=>({binding:t.binding,name:t.queue})),nameKey:"name"}];for(const{construct:t,entries:l,nameKey:y}of b)for(const i of l)i.binding!==void 0&&(r.add(t),c.push(`const ${u(i.binding)} = await ${t}(${o(i.binding)}, { adopt: true, ${y}: ${o(i.name??i.binding)} });`),a.push(m(i.binding)));v(e,p,r,a,n),h(e,a),f(e,n);const _=["adopt: true,",a.length===0?void 0:`bindings: {
2
- ${a.join(`
3
- `)}
4
- },`,e.compatibility_date===void 0?void 0:`compatibilityDate: ${o(e.compatibility_date)},`,e.compatibility_flags===void 0||e.compatibility_flags.length===0?void 0:`compatibilityFlags: ${o([...e.compatibility_flags])},`,e.triggers?.crons===void 0||e.triggers.crons.length===0?void 0:`crons: ${o([...e.triggers.crons])},`,e.main===void 0?void 0:`entrypoint: ${o(e.main)},`,`name: ${o(s)},`].filter(t=>t!==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((t,l)=>t.localeCompare(l)).join(", ")} } from "alchemy/cloudflare";`,"",`const app = await alchemy(${o(s)});`,"",...c.length===0?[]:[...c,""],`export const worker = await Worker(${o(s)}, {`,` ${_.join(`
5
- `)}`,"});","","await app.finalize();",""].join(`
6
- `),unsupported:n}};export{g as sqliteClasses,k as wranglerToAlchemy};