@lunora/config 1.0.0-alpha.456 → 1.0.0-alpha.458
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cloudflare/index.d.mts +131 -4
- package/dist/cloudflare/index.d.ts +131 -4
- package/dist/cloudflare/index.mjs +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.mjs +1 -1
- package/dist/packem_shared/{DEV_WORKER_ENV_VALUE-Buh60zHI.mjs → DEV_WORKER_ENV_VALUE-DdPmCpf3.mjs} +1 -1
- package/dist/packem_shared/{PACKAGE_SECRETS_REGISTRY-C8tN4qgQ.mjs → PACKAGE_SECRETS_REGISTRY-CnY7jg9j.mjs} +1 -1
- package/dist/packem_shared/{POLICY_SCAFFOLD_ENDPOINT-xEHecns4.mjs → POLICY_SCAFFOLD_ENDPOINT-CXr3lZGF.mjs} +1 -1
- package/dist/packem_shared/REQUIRED_COMPATIBILITY_DATE-B8WSlhBx.mjs +1 -0
- package/dist/packem_shared/{SCHEMA_EDIT_ENDPOINT-qrJCQf0v.mjs → SCHEMA_EDIT_ENDPOINT-CUN4q8oi.mjs} +1 -1
- package/dist/packem_shared/{STUDIO_PATH-DDlZcH-q.mjs → STUDIO_PATH-BFXK7eku.mjs} +1 -1
- package/dist/packem_shared/UNEXPORTED_CLASS_MARKER-Cf3uQ2s0.mjs +1 -0
- package/dist/packem_shared/{assertWranglerSatisfiesSchema-DmkdB-OW.mjs → assertWranglerSatisfiesSchema-BSIX4ljM.mjs} +1 -1
- package/dist/packem_shared/asset-headers-CGvrhfGW.mjs +4 -0
- package/dist/packem_shared/{buildPackageSecretsBlock-DkAJ9DmX.mjs → buildPackageSecretsBlock-B4Odg5OF.mjs} +1 -1
- package/dist/packem_shared/collectExportGaps-CJPSXdEn.mjs +2 -0
- package/dist/packem_shared/emitProjectAssetHeaders-C0Ec7nsF.mjs +1 -0
- package/dist/packem_shared/env-flag-u4B05gLp.mjs +1 -0
- package/dist/packem_shared/{infer-bindings.d-DtKuba3D.d.mts → infer-bindings.d-Tkaosiub.d.mts} +15 -3
- package/dist/packem_shared/{infer-bindings.d-DtKuba3D.d.ts → infer-bindings.d-Tkaosiub.d.ts} +15 -3
- package/dist/packem_shared/inferLunoraBindings-D0QDcugr.mjs +1 -0
- package/dist/packem_shared/is-plain-object-CWxHeOY1.mjs +1 -0
- package/dist/packem_shared/{package-secrets-registry-B4MtZQYU.mjs → package-secrets-registry-TouCAMQN.mjs} +1 -1
- package/dist/packem_shared/reconcile-assets-DXQsm--3.mjs +1 -0
- package/dist/packem_shared/{reconcileBindingsSafely-CNLZojiQ.mjs → reconcileBindingsSafely-BKL4MGWX.mjs} +1 -1
- package/dist/packem_shared/{scanWranglerVariablesForSecrets-C0Yt1KAG.mjs → scanWranglerVariablesForSecrets-CkonQUdG.mjs} +1 -1
- package/dist/packem_shared/spa-assets-C591NPiX.mjs +1 -0
- package/dist/packem_shared/withTailConsumer-BUDKESwC.mjs +1 -0
- package/dist/packem_shared/wranglerCodegenInputs-BPoRg-2G.mjs +1 -0
- package/dist/packem_shared/{write-atomic-BK08pOLO.mjs → write-atomic-B8e7rVyT.mjs} +1 -1
- package/dist/packem_shared/writeAssetHeaders-BWSEaedL.mjs +1 -0
- package/dist/studio-host/index.mjs +1 -1
- package/package.json +2 -2
- package/dist/packem_shared/REQUIRED_COMPATIBILITY_DATE-C8qfwbaA.mjs +0 -1
- package/dist/packem_shared/UNEXPORTED_CLASS_MARKER-07SNQ0rP.mjs +0 -1
- package/dist/packem_shared/collectExportGaps-vVbPzutT.mjs +0 -2
- package/dist/packem_shared/guards-Buu_E7mP.mjs +0 -1
- package/dist/packem_shared/inferLunoraBindings-DeR_c0W0.mjs +0 -1
- package/dist/packem_shared/validate-bindings-PVHSAU6M.mjs +0 -1
- package/dist/packem_shared/withTailConsumer-CF3pk_Ov.mjs +0 -1
- package/dist/packem_shared/wranglerCodegenInputs-BG0xZlgU.mjs +0 -1
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{readFileSync as ee,writeFileSync as ne}from"node:fs";import{createRequire as se}from"node:module";import{join as Q}from"node:path";import{containerBuildTag as te}from"@lunora/container";import{readJsonSync as ie}from"@visulima/fs";import{c as oe}from"./celld-binding-id-9MiUoteo.mjs";import{applyModify as w}from"./applyModify-DKP2l6S9.mjs";import{recordManifestKey as ae,readManifest as Y}from"./readManifest-Cighz3WC.mjs";import{D1_PLACEHOLDER_ID as U,HYPERDRIVE_PLACEHOLDER_ID as re}from"./D1_PLACEHOLDER_ID-ZnDjVymH.mjs";import{parseTree as de,findNodeAtLocation as ce}from"jsonc-parser";import{r as le,a as ue,b as ge,c as me}from"./reconcile-services-C4TwY8YH.mjs";import{DEV_VARS_FILE as pe,parseDevVariableEntries as fe}from"./DEV_VARS_EXAMPLE_FILE-CqLorAxT.mjs";import{secretSourcesFromBindings as be}from"./inferLunoraBindings-DeR_c0W0.mjs";import{requiredSecrets as he}from"./buildPackageSecretsBlock-DkAJ9DmX.mjs";import{w as ve,m as we,s as G,o as P,n as I,p as _e}from"./validate-bindings-PVHSAU6M.mjs";import{s as ye}from"./worker-entry-checks-CHrum2AN.mjs";import{DEFAULT_OBSERVABILITY as Se}from"./DEFAULT_OBSERVABILITY-CPLADr5u.mjs";import{findWranglerFile as Ee,readWranglerJsonc as xe}from"./WRANGLER_FILES-UNW-xY5u.mjs";const Ae=[["maxBatchSize","max_batch_size"],["maxBatchTimeout","max_batch_timeout"],["maxConcurrency","max_concurrency"],["maxRetries","max_retries"],["deadLetterQueue","dead_letter_queue"],["retryDelay","retry_delay"]],B=e=>Object.fromEntries(Ae.filter(([n])=>e.tuning[n]!==void 0).map(([n,s])=>[s,e.tuning[n]])),L="queueTuning",Oe=/^[\t ]*(?:,[\t ]*)?(?:\/\/[^\n\r]*)?\r?\n/u,$e=/^[\t ]*,/u,Ne=(e,n)=>{const s=de(e),t=s===void 0?void 0:ce(s,[...n])?.parent;if(t?.type==="property"){const o=t.offset+t.length,i=e.lastIndexOf(`
|
|
2
|
-
`,t.offset-1)+1,a=Oe.exec(e.slice(o));if(a!==null&&e.slice(i,t.offset).trim()===""){const m=t.parent?.children??[],u=m.indexOf(t),d=u===m.length-1&&u>0?m[u-1]:void 0,c=d===void 0?void 0:$e.exec(e.slice(d.offset+d.length))??void 0;return(c===void 0||d===void 0?e.slice(0,i):e.slice(0,d.offset+d.length)+e.slice(d.offset+d.length+c[0].length,i))+e.slice(o+a[0].length)}}return w(e,n,void 0)},J=(e,n,s,t,o,i=new Set)=>{const a=s.join("."),m={},u=[],d=[];let c=e;return{entries:n.map((l,v)=>{const g=t(l);if(g===void 0||l.queue===void 0)return l;const b=Object.fromEntries(Object.entries(B(g)).filter(([f])=>!i.has(f))),h=Object.entries(o[l.queue]??{}).filter(([f])=>!Object.hasOwn(b,f)),_=Object.entries(b).filter(([f,y])=>l[f]!==y),E=h.filter(([f,y])=>l[f]===y).map(([f])=>f),O=Object.fromEntries(Object.entries({...l,...b}).filter(([f])=>!E.includes(f)));for(const[f,y]of _)c=w(c,[...s,v,f],y);for(const f of E)c=Ne(c,[...s,v,f]);for(const[f,y]of h){const A=l[f];A!==void 0&&A!==y&&d.push(`${a}/${l.queue}: ${f} is no longer declared by defineQueue, but it was changed by hand to ${JSON.stringify(A)} from the declared ${JSON.stringify(y)}, so it was kept. Delete it from wrangler.jsonc if it should go.`)}return(_.length>0||E.length>0)&&u.push(`${a}/${l.queue} (${[..._.map(([f])=>f),...E.map(f=>`removed ${f}`)].join(", ")})`),Object.keys(b).length>0&&(m[l.queue]=b),O}),owned:m,text:c,updated:u,warnings:d}},ke=(e,n,s,t)=>{const o=n.queues??{},i=o.producers??[],a=o.consumers??[],m=new Set(i.map(g=>g?.binding)),u=new Set(a.map(g=>g.queue)),d=s.filter(g=>!m.has(g.bindingName)),c=s.filter(g=>!u.has(g.name)),p=J(e,a,["queues","consumers"],g=>s.find(b=>b.name===g.queue),t);let l=p.text;const v={...p.owned};if(d.length>0||c.length>0){const g=[...i,...d.map(h=>({binding:h.bindingName,queue:h.name}))],b=[...p.entries,...c.map(h=>({queue:h.name,...h.mode==="pull"?{type:"http_pull"}:{},...B(h)}))];for(const h of c){const _=B(h);Object.keys(_).length>0&&(v[h.name]=_)}l=w(l,["queues"],{consumers:b,producers:g})}return{added:[...d.map(g=>`queues.producers/${g.bindingName}`),...c.map(g=>`queues.consumers/${g.name}`)],owned:v,text:l,updated:p.updated,warnings:p.warnings}},Ce=(e,n,s,t,o)=>{const i=n.env?.[t],a=i?.queues?.consumers??[],m=i?.queues?.producers??[],u=l=>{const v=m.find(g=>g?.queue===l.queue)?.binding;return v!==void 0?s.find(g=>g.bindingName===v):s.find(g=>g.name===l.queue&&!m.some(b=>b?.binding===g.bindingName))},d=J(e,a,["env",t,"queues","consumers"],u,o,new Set(["dead_letter_queue"])),c=a.filter(l=>l.queue!==void 0&&u(l)===void 0).map(l=>`env.${t}.queues.consumers/${String(l.queue)}: no defineQueue export matches it — this block declares no producer mapping one of their bindings to "${String(l.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=a.flatMap(l=>{const v=u(l)?.tuning.deadLetterQueue;return v===void 0||l.dead_letter_queue!==void 0?[]:[`env.${t}.queues.consumers/${String(l.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:d.owned,text:d.text,updated:d.updated,warnings:[...d.warnings,...p,...c]}},Te=(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?.[L],t=o=>typeof o=="object"&&o!==null&&!Array.isArray(o);return s===void 0?{}:!t(s)||!Object.values(s).every(o=>t(o)&&Object.values(o).every(i=>t(i)))?(n.push(`${e?.path??"package.json"}: \`lunora.${L}\` 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},Ie=(e,n,s)=>{const t=Object.fromEntries(Object.entries({...n,...s}).filter(([,o])=>Object.keys(o).length>0));ae(e,L,Object.keys(t).length===0?void 0:t)},je="https://api.cloudflare.com/client/v4/accounts/<ACCOUNT_ID>/artifacts/namespaces",Re=e=>{const n='add an "artifacts" binding ({ binding: "ARTIFACTS", namespace }) — codegen reads env.ARTIFACTS unless `.artifacts()` on defineApp points ctx.artifacts at another binding';return e===void 0?`ctx.artifacts is used; ${n}. The namespace is created by the first repo create() if it does not exist yet.`:`ctx.artifacts is used and the schema pins data to "${e}"; create the namespace in that jurisdiction BEFORE the first repo, with POST ${je} and body { "namespace": "<name>", "jurisdiction": "${e}" }, then ${n}. A namespace's jurisdiction cannot be changed, and one created implicitly by the first repo create() is unrestricted. With CLOUDFLARE_API_TOKEN set, \`lunora deploy\` creates a missing namespace in that jurisdiction for a binding you have added.`},j="PIPELINES",R="ARTIFACTS",qe=(e,n,s)=>{const t=n!==void 0&&(s===void 0||s==="cloudflare"),o=e.flagshipBinding!==void 0&&!(n?.flagship??[]).some(d=>d.binding===e.flagshipBinding),i=e.usesPipelines&&!(n?.pipelines??[]).some(d=>d.binding===j),a=e.usesArtifacts?n?.artifacts??[]:[],m=a.some(d=>d.binding===R)?[]:a.flatMap(d=>d.binding===void 0?[]:[d.binding]);return[[e.usesKv&&(n?.kv_namespaces?.length??0)===0&&(!t||e.jurisdiction!==void 0),e.jurisdiction===void 0?'ctx.kv is used but no kv_namespaces binding exists; add one ({ binding: "KV" }) — wrangler creates the namespace on the first deploy.':`ctx.kv is used and the schema pins data to "${e.jurisdiction}"; run \`wrangler kv namespace create <name> --jurisdiction ${e.jurisdiction}\` and add a kv_namespaces entry ({ binding: "KV", id }) — a namespace wrangler creates on deploy is unrestricted.`],[e.usesHyperdrive&&(n?.hyperdrive?.length??0)===0&&!t,'@lunora/hyperdrive is used but no hyperdrive binding exists; add one ({ binding: "HYPERDRIVE", id }) — on a Cloudflare target `lunora deploy` creates the Hyperdrive config from a connection string.'],[e.usesArtifacts&&a.length===0&&(!t||e.jurisdiction!==void 0),Re(e.jurisdiction)],[i,`ctx.pipelines is used but no "${j}" pipelines binding exists; run 'wrangler pipelines create <name>' and add a 'pipelines' binding ({ binding: "${j}", stream }) — codegen resolves this one name, and the pipeline resource can't be auto-provisioned.`],[m.length>0,`ctx.artifacts is used and ${m.map(d=>`"${d}"`).join(", ")} ${m.length===1?"is":"are"} bound, but none is named "${R}"; make sure \`.artifacts()\` on defineApp points ctx.artifacts at it — otherwise it reads env.${R} and throws.`],[o,`lunora/flags.ts uses Flagship in binding mode but no flagship binding "${e.flagshipBinding??""}" exists; add a flagship entry ({ binding: "${e.flagshipBinding??""}", app_id }) — the app_id can't be auto-provisioned.`]].filter(([d])=>d).map(([,d])=>d)},De=e=>[[e.usesX402Charge,"@lunora/x402/charge is used; set the recipient wallet address as a [vars] entry (the var name is your choice) and pass it to the charge config — the x402 facilitator settles USDC to that address."],[e.usesX402,"@lunora/x402/pay is used (ActionCtx-only, spends real funds); add a secrets_store_secrets[] binding holding the agent wallet key (binding name == signer.secretName) and pair the pay rail with a spend policy — ctx.secrets reads a Secrets Store binding, not .dev.vars."]].filter(([s])=>s).map(([,s])=>s),q=(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.`),Pe=(e,n)=>{const s=new Set([...e.workflows,...e.agents].map(i=>i.className));if(s.size===0)return[];const t=Object.entries(n.exports??{}).flatMap(([i,a])=>a?.type==="workflow"?[i]:[]),o=(n.workflows??[]).flatMap(i=>i.class_name===void 0||i.script_name!==void 0?[]:[i.class_name]);return[...new Set([...t,...o])].filter(i=>!s.has(i)).map(i=>`wrangler.jsonc declares workflow "${i}" but no defineWorkflow/defineAgent export generates that class — a leftover from a rename will fail the deploy (wrangler rejects a class the worker does not export). Remove it if it is not hand-wired.`)},Be=(e,n)=>{if(e.queues.length===0)return[];const s=new Set(e.queues.map(o=>o.name)),t=new Set(e.queues.map(o=>o.bindingName));return[...(n.queues?.consumers??[]).flatMap(o=>{const{queue:i}=o;return i===void 0||s.has(i)?[]:[`wrangler.jsonc subscribes queues.consumers[] to "${i}" but no defineQueue export declares that queue — a leftover from a rename keeps delivering batches this worker has no handler for (they retry to exhaustion, then drop or dead-letter). Remove it if it is not hand-wired.`]}),...(n.queues?.producers??[]).flatMap(o=>{const i=o?.binding;return i===void 0||t.has(i)?[]:[`wrangler.jsonc declares queues.producers[] binding "${i}" but no defineQueue export declares it — a leftover from a rename. Remove it if it is not hand-wired.`]})]},Le=(e,n)=>[...Pe(e,n),...Be(e,n)],X=[{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"}],We=()=>X.map(({keys:e,label:n})=>`${e[0]} + ${e[1]} (${n})`).join(" or "),Me=e=>{let n;try{n=ee(Q(e,pe),"utf8")}catch{return!1}const s=new Map(fe(n).map(t=>[t.key,t.value]));return X.some(({keys:t})=>t.every(o=>(s.get(o)??"")!==""))},Ke=(e,n)=>{const s=n?.secrets?.required;if(!Array.isArray(s))return[];const t=new Set(s),o=he(be(e)).map(i=>i.key).filter(i=>!t.has(i));return o.length===0?[]:[`wrangler.jsonc declares secrets.required without ${o.join(", ")}, which this app needs — wrangler dev loads only the listed keys from .dev.vars, so add ${o.length===1?"it":"them"} to secrets.required.`]},D=(e,n,s,t)=>{const o=new Set(e.durableObjects.map(u=>u.className)),i=[],a=(s?.r2_buckets?.length??0)>0,m=(s?.d1_databases?.some(u=>u.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&&!o.has("SessionDO")&&!m&&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&&!o.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(...q("container","containers",e.containers),...q("workflow","workflows",e.workflows),...q("agent","agents",e.agents)),e.containers.length>0&&s?.observability?.enabled===!1&&i.push("containers are declared but observability is explicitly disabled in wrangler.jsonc — container logs will not be captured."),e.usesPayments&&!Me(n)&&i.push(`@lunora/payment is used; set one provider's secret pair in .dev.vars — ${We()}.`),i.push(...De(e),...qe(e,s,t),...Ke(e,s)),s!==void 0&&i.push(...Le(e,s)),i},Fe=e=>[["container","containers",e.containers],["workflow","workflows",e.workflows],["agent","agents",e.agents]].flatMap(([s,t,o])=>o.filter(i=>!i.exported).map(({className:i,exportName:a})=>({className:i,exportName:a,kind:s,module:t}))),He=e=>{const n=new Set(P(e).map(t=>t.tag));let s=1;for(;n.has(`v${String(s)}`);)s+=1;return`v${String(s)}`},Ye=e=>{const n=new Set;for(const s of P(e)){for(const t of I(s.deleted_classes))n.delete(t);for(const{from:t,to:o}of P(s.renamed_classes))t!==void 0&&n.delete(t),o!==void 0&&n.add(o);for(const t of[...I(s.new_classes),...I(s.new_sqlite_classes)])n.add(t)}return n},Ve=(e,n,s)=>{const t=n.durable_objects?.bindings??[],o=new Set(t.map(c=>c.name)),i=s.filter(c=>!o.has(c.binding));let a=e;const m=[];if(i.length>0){const c=[...t,...i.map(p=>({class_name:p.className,name:p.binding}))];a=w(a,["durable_objects","bindings"],c),m.push(...i.map(p=>`${p.binding}/${p.className}`))}const u=n.migrations??[],d=s.map(c=>c.className).filter(c=>!Ye(u).has(c));if(d.length>0){const c=[...u,{new_sqlite_classes:d,tag:He(u)}];a=w(a,["migrations"],c)}return{added:m,text:a}},M=e=>e===void 0||e==="cloudflare",Qe=(e,n)=>e.includes("DB (D1)")&&M(n)?[`wrote a DB binding with a placeholder database_id ("${U}") — run \`wrangler d1 create <name>\` and replace it before deploying.`]:[],Ue=(e,n)=>{const s=n.d1_databases??[];if(s.some(i=>i.binding==="DB"))return{added:[],text:e};const t=typeof n.name=="string"&&n.name.length>0?n.name:"lunora",o=[...s,{binding:"DB",database_id:U,database_name:t}];return{added:["DB (D1)"],text:w(e,["d1_databases"],o)}},Ge={ai:{binding:"AI",label:"AI (Workers AI)"},analytics:{binding:"ANALYTICS_SQL",label:"ANALYTICS_SQL (Analytics SQL)"},browser:{binding:"BROWSER",label:"BROWSER (Browser Rendering)"},images:{binding:"IMAGES",label:"IMAGES (Cloudflare Images)"}},Je=(e,n)=>e.usesAnalyticsSql&&ye(n,new Set(["analyticsSql"]))?.chained.has("analyticsSql")!==!0,Xe=new Set(["ratelimits","send_email"]),ze=["durable_objects","logfwdr","unsafe"],Ze=new Set(["data_blobs","text_blobs","vars","wasm_modules"]),K=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),W=(e,n,s)=>K(e)&&e[n]===s,en=(e,n,s)=>{if(Ze.has(e))return K(n)&&Object.hasOwn(n,s);const t=Xe.has(e)?"name":"binding";return Array.isArray(n)?n.some(o=>W(o,t,s)):W(n,"binding",s)},$=(e,n)=>{const s=e,t=Object.entries(s).find(([i,a])=>i!=="env"&&en(i,a,n));if(t!==void 0)return t[0];for(const i of ze){const a=s[i];if(K(a)&&Array.isArray(a.bindings)&&a.bindings.some(m=>W(m,"name",n)))return`${i}.bindings`}if(e.queues?.producers?.some(i=>i?.binding===n)===!0)return"queues.producers";const o=e.secrets?.required;if(Array.isArray(o)&&o.includes(n))return"secrets.required"},k=(e,n,s)=>{const{binding:t,label:o}=Ge[s],i=n[s]?.binding;if(typeof i=="string"&&i.length>0)return{added:[],text:e};const a=$(n,t);return a!==void 0?{added:[],text:e,warnings:[`${s}: not adding the ${o} binding — the name "${t}" is already bound by \`${a}\` in wrangler.jsonc. Rename that binding, then set ${s}.binding by hand.`]}:{added:[o],text:w(e,[s],{binding:t})}},F=(e,n,s)=>`${e}: not adding "${n}" — the name is already bound by \`${s}\` in wrangler.jsonc. Add a ${e} entry under another binding name and point the matching \`defineApp()\` override at it.`,nn=(e,n,s)=>{if(!M(s)||(n.hyperdrive?.length??0)>0)return{added:[],text:e};const t=$(n,"HYPERDRIVE");return t!==void 0?{added:[],text:e,warnings:[F("hyperdrive","HYPERDRIVE",t)]}:{added:["HYPERDRIVE (Hyperdrive, created on deploy)"],text:w(e,["hyperdrive"],[{binding:"HYPERDRIVE",id:re}])}},sn=new Set(["celld","cloudflare"]),tn=(e,n,s,t)=>{if(t!==void 0&&!sn.has(t)||s!==void 0||(n.kv_namespaces?.length??0)>0)return{added:[],text:e};const o=$(n,"KV");return o!==void 0?{added:[],text:e,warnings:[F("kv_namespaces","KV",o)]}:{added:[t==="celld"?`KV (Workers KV, celld namespace ${oe(n.name,"KV")})`:"KV (Workers KV, created on deploy)"],text:w(e,["kv_namespaces"],[{binding:"KV"}])}},on=(e,n,s,t)=>{if(!M(t)||s!==void 0||(n.artifacts?.length??0)>0)return{added:[],text:e};const o=$(n,"ARTIFACTS");if(o!==void 0)return{added:[],text:e,warnings:[F("artifacts","ARTIFACTS",o)]};const i=typeof n.name=="string"&&n.name.length>0?n.name:"lunora";return{added:["ARTIFACTS (Cloudflare Artifacts)"],text:w(e,["artifacts"],[{binding:"ARTIFACTS",namespace:i}])}},V=(e,n,s,t,o)=>{if((n[s]?.length??0)>0)return{added:[],text:e};const i=$(n,t.binding);return i!==void 0?{added:[],text:e,warnings:[`${s}: not adding ${JSON.stringify(t)} — the name "${t.binding}" is already bound by \`${i}\` in wrangler.jsonc. Add a ${s} entry under another binding name and point the matching \`defineApp()\` override at it.`]}:{added:[o],text:w(e,[s],[t])}},an=(e,n)=>{const s=n.worker_loaders??[];return s.some(t=>t.binding==="LOADER")?{added:[],text:e}:{added:["LOADER (Worker Loader)"],text:w(e,["worker_loaders"],[...s,{binding:"LOADER"}])}},rn=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},dn=e=>{const{image:n}=e;return n.kind==="dockerfile"?n.dockerfilePath:n.kind==="registry"?n.reference:te(e.exportName)},z=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}}},cn=e=>{if(e.schedulingPolicy==="durable_object")return z(e);const{image:n}=e,s={class_name:e.className,image:dn(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=rn(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},ln=(e,n,s)=>{const t=n.containers??[],o=new Set(t.map(d=>d.class_name)),i=s.filter(d=>!o.has(d.className));let a=i.length===0?e:w(e,["containers"],[...t,...i.map(d=>cn(d))]);const m=[],u=[];for(const[d,c]of t.entries()){const p=s.find(g=>g.className===c.class_name);if(p===void 0)continue;const l=p.schedulingPolicy??"default";if((c.scheduling_policy??"default")!==l){u.push(`containers/${p.className} has scheduling_policy "${c.scheduling_policy??"default"}" in wrangler.jsonc but defineContainer "${p.exportName}" declares "${l}" — the policy is immutable, so replace the entry (and its container application) by hand.`);continue}const v=p.schedulingPolicy==="durable_object"?z(p).images:void 0;v!==void 0&&JSON.stringify(c.images)!==JSON.stringify(v)&&(a=w(a,["containers",d,"images"],v),m.push(`containers/${p.className}.images`))}return{added:i.map(d=>`containers/${d.className}`),text:a,updated:m,warnings:u}},un=(e,n)=>{if(n.observability!==void 0)return{added:[],text:e};const s=w(e,["observability"],{...Se});return{added:["observability"],text:s}},gn=(e,n)=>n.upload_source_maps!==void 0?{added:[],text:e}:{added:["upload_source_maps"],text:w(e,["upload_source_maps"],!0)},Z=[{minimum:[4,142],name:"wrangler"},{minimum:[1,61],name:"@cloudflare/vite-plugin"}],mn=Z.map(({minimum:e,name:n})=>`${n}@^${e.join(".")}.0`).join(" "),pn=(e,n)=>{try{const s=se(Q(e,"package.json")).resolve(`${n}/package.json`),[t=0,o=0]=String(ie(s).version).split(".").map(Number);return[t,o]}catch{return}},fn=e=>{const n=Z.flatMap(({minimum:s,name:t})=>{const o=pn(e,t);return o!==void 0&&(o[0]<s[0]||o[0]===s[0]&&o[1]<s[1])?[`${t} ${o.join(".")} (needs >= ${s.join(".")})`]:[]});return n.length===0?void 0:`workflows are declared in wrangler \`exports\`, which ${n.join(" and ")} cannot run — reconcile left workflows[] untouched. Upgrade (\`pnpm add -D ${mn}\`) and re-run.`},bn=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.`]:[]),hn=(e,n,s)=>{let t=e;const o=[],i=[];for(const a of s){const m=n[a.className];if(m?.type==="workflow")for(const{of:u,path:d}of _e){const c=u(a),p=G(m,d),l=`exports/${a.className}.${d.join(".")}`;if(c===void 0){p!==void 0&&i.push(`${l} is set in wrangler.jsonc but defineWorkflow "${a.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(c)&&(t=w(t,["exports",a.className,...d],c),o.push(l))}}return{text:t,updated:o,warnings:i}},vn=(e,n,s,t,o)=>{if(o!==void 0)return{added:[],text:e,warnings:[o]};const i=[...s.map(b=>({settings:ve(b),workflow:b})),...t.map(b=>({settings:{},workflow:b}))],a=new Set(i.map(({workflow:b})=>b.className)),m=n.workflows??[],u=m.filter(b=>b.script_name===void 0&&b.class_name!==void 0&&a.has(b.class_name)),d=n.exports??{},c=[],p=[],l=[];let v=e;for(const{settings:b,workflow:h}of i){if(d[h.className]!==void 0&&d[h.className]!==null)continue;const _=u.find(f=>f.class_name===h.className),E=Object.fromEntries(we.flatMap(f=>{const y=G(_,[f]);return y===void 0?[]:[[f,y]]})),O=_?.name??h.name;_?.name!==void 0&&_.name!==h.name&&l.push(`workflows/${h.className} is deployed as "${_.name}" but declared as "${h.name}" — its export keeps "${_.name}" so running instances survive. Change the declaration to match, or rename deliberately (it starts a new, empty workflow).`),v=w(v,["exports",h.className],{type:"workflow",...E,...b,name:O}),(_===void 0?c:p).push(`exports/${h.className}`)}if(u.length>0){const b=m.filter(h=>!u.includes(h));v=w(v,["workflows"],b.length===0?void 0:b),p.push(...u.map(h=>`workflows/${String(h.class_name)} → exports`))}l.push(...bn(n));const g=hn(v,d,s);return{added:c,text:g.text,updated:[...p,...g.updated],warnings:[...l,...g.warnings]}},Pn=(e,n,{environment:s,target:t}={})=>{const o=Ee(e),i=Fe(n);if(!o)return{added:[],changed:!1,exportGaps:i,reason:"wrangler.jsonc not found",updated:[],warnings:D(n,e)};const{parsed:a,text:m}=xe(o);if(a===void 0)return{added:[],changed:!1,exportGaps:i,reason:`failed to parse ${o} as JSONC`,updated:[],warnings:D(n,e),wranglerPath:o};const u=D(n,e,a,t);if(s!==void 0){const r=a.env?.[s]!==void 0;u.push(r?`auto-provisioned bindings are written to the top level of wrangler.jsonc only (queue consumers "env.${s}" already declares are retuned, nothing is added) — "env.${s}" has its own (non-inheritable) bindings and must be reconciled by hand; \`lunora deploy --env ${s}\` now validates them, so a gap here will be reported at deploy time.`:`--env "${s}" was requested but wrangler.jsonc declares no "env.${s}" block — auto-provisioned bindings are written to the top level only and will not apply to that environment.`)}const d=n.containers.filter(r=>r.exported),c=n.agents.filter(r=>r.exported&&r.voice===!0&&r.voiceBindingName!==void 0&&r.voiceClassName!==void 0),p=[...n.durableObjects,...d.map(r=>({binding:r.bindingName,className:r.className})),...c.map(r=>({binding:r.voiceBindingName,className:r.voiceClassName}))],l=n.workflows.filter(r=>r.exported),v=n.agents.filter(r=>r.exported),g=Y(e),b=Te(g,u),h={},_=le(g);let E;const O=[{enabled:!0,run:r=>Ve(r,a,p)},{enabled:n.needsD1,run:r=>Ue(r,a)},{enabled:n.usesKv,run:r=>tn(r,a,n.jurisdiction,t)},{enabled:n.usesHyperdrive,run:r=>nn(r,a,t)},{enabled:n.usesArtifacts,run:r=>on(r,a,n.jurisdiction,t)},{enabled:n.usesAi,run:r=>k(r,a,"ai")},{enabled:n.usesAiSearch,run:r=>V(r,a,"ai_search_namespaces",{binding:"AI_SEARCH",namespace:"default"},"AI_SEARCH (AI Search namespace)")},{enabled:Je(n,e),run:r=>k(r,a,"analytics")},{enabled:n.usesBrowser,run:r=>k(r,a,"browser")},{enabled:n.usesImages,run:r=>k(r,a,"images")},{enabled:n.usesAnalytics,run:r=>V(r,a,"analytics_engine_datasets",{binding:"ANALYTICS",dataset:"ANALYTICS"},"ANALYTICS (Analytics Engine)")},{enabled:n.usesWorkerLoader,run:r=>an(r,a)},{enabled:!0,run:r=>un(r,a)},{enabled:t===void 0||t==="cloudflare",run:r=>gn(r,a)},{enabled:d.length>0,run:r=>ln(r,a,d)},{enabled:l.length>0||v.length>0,run:r=>vn(r,a,l,v,fn(e))},{enabled:n.queues.length>0,run:r=>{const S=ke(r,a,n.queues,b.queues??{});return h.queues=S.owned,S}},{enabled:n.services!==void 0&&(n.services.length>0||Object.keys(_).length>0),run:r=>{const S=ue(r,a,n.services??[],_);return E=S.owned,S}},...s===void 0||a.env?.[s]===void 0?[]:[{enabled:n.queues.length>0,run:r=>{const S=`env.${s}.queues`,N=Ce(r,a,n.queues,s,b[S]??{});return h[S]=N.owned,N}}]];let f=m;const y=[],A=[];for(const r of O){if(!r.enabled)continue;const S=r.run(f);f=S.text,y.push(...S.added),A.push(...S.updated??[]),u.push(...S.warnings??[])}const H=r=>{if(g===void 0)return;const S=E,N=[...Object.keys(h).length>0?[{consequence:"an option removed from defineQueue stays deployed",key:"queueTuning",label:"queue tuning",write:x=>{Ie(x,b,h)}}]:[],...S===void 0?[]:[{consequence:"a service removed from lunora.config stays bound",key:"services",label:"service bindings",write:x=>{me(x,S)}}]];for(const x of N)try{x.write(Y(e)??g)}catch(T){u.push(`${r?"wrangler.jsonc was updated, but ":""}recording the ${x.label} reconcile owns in ${g.path} (lunora.${x.key}) failed: ${T instanceof Error?T.message:String(T)}. Until it is recorded, ${x.consequence}.`)}};let C;if(n.services!==void 0){const r=ge(e,n.services,_);u.push(...r.warnings),E={...E,...r.owned},C=r.added.length>0||r.updated.length>0?{added:r.added,path:r.path,updated:r.updated}:void 0}return u.push(...Qe(y,t)),f===m?(H(!1),{added:y,changed:!1,devConfig:C,exportGaps:i,reason:"bindings already in sync",updated:A,warnings:u,wranglerPath:o}):(ne(o,f,"utf8"),H(!0),{added:y,changed:!0,devConfig:C,exportGaps:i,updated:A,warnings:u,wranglerPath:o})};export{Fe as collectExportGaps,Pn as reconcileWranglerBindings};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const n=t=>typeof t=="object"&&t!==null&&!Array.isArray(t),s=t=>typeof t=="string"&&t.length>0;export{s as a,n as i};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{statSync as k,readFileSync as Q,existsSync as M,readdirSync as ue}from"node:fs";import{relative as pe,sep as me,isAbsolute as fe,join as x,dirname as j,resolve as ge}from"node:path";import{discoverFlags as he,FLAGS_FILENAME as Se,discoverQueues as xe,CAPABILITY_PROBES as z,COMPANION_BINDING as Z,discoverNotifyChannels as ye,NOTIFY_FILENAME as ve,readBoundServiceBindings as Ee,createTargetScope as be,mayReadCapabilityContext as Ne,sourceCapabilitySignals as Ce,foldCapabilitySignals as Y,capabilitiesUsedBy as Te}from"@lunora/codegen";import{init as Ie}from"es-module-lexer";import{ts as n,Node as m,Project as ee}from"ts-morph";import{discoverAgentInfo as Re}from"./discoverAgentInfo-pqFMJBtJ.mjs";import{discoverContainerInfo as Ae}from"./discoverContainerInfo-DzXr7Vm3.mjs";import{escapeRegExp as Oe}from"./DEV_VARS_EXAMPLE_FILE-CqLorAxT.mjs";import{d as B}from"./discover-info-DC2MrAIM.mjs";import{P as we}from"./package-secrets-registry-B4MtZQYU.mjs";import{discoverSchemaInfo as De}from"./discoverSchemaInfo-DRPnqgif.mjs";import{resolveWorkerEntry as _e,composedEntryDurableObjects as Le,GENERATED_DIRECTORY as D,DURABLE_OBJECT_BINDINGS as $e,detectExportedDurableObjects as Pe,detectClassExports as $,isMergedProject as te}from"./COMPOSED_WORKER_ENTRY-BcFt6ts5.mjs";import{discoverWorkflowInfo as je}from"./discoverWorkflowInfo-zW7Tt0Tn.mjs";const Fe=(e,t)=>{const{error:o,value:s}=B(e,t,Se,he);return o===void 0?{flags:s}:{error:o}},se=(e,t)=>{const o=pe(t,e);return o!==""&&o!==".."&&!o.startsWith(`..${me}`)&&!fe(o)},ke=(e,t)=>{const{error:o,value:s}=B(e,t,void 0,xe);return o===void 0?{queues:s??[]}:{error:o,queues:[]}},N="@lunora/replica",S="EventLogDOClient",Me=/\.[cm]?[jt]sx?$/u,U=[".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs"],q=new Map,K=e=>{const{mtimeMs:t}=k(e),o=q.get(e);if(o?.mtimeMs===t)return o.source;const s=n.createSourceFile(e,Q(e,"utf8"),n.ScriptTarget.Latest);return q.set(e,{mtimeMs:t,source:s}),s},H=new WeakMap,Be=e=>{const t=H.get(e);if(t!==void 0&&t[0]?.wasForgotten()!==!0)return t;const o=e.getDescendantsOfKind(n.SyntaxKind.Identifier);return H.set(e,o),o},X=e=>n.sys.fileExists(e)?k(e).mtimeMs:-1,J=new Map,Ke=e=>{const t=n.findConfigFile(j(e),i=>n.sys.fileExists(i));if(t===void 0)return{};const o=J.get(t);if(o!==void 0&&[...o.mtimes].every(([i,c])=>X(i)===c))return o.options;const s=n.readJsonConfigFile(t,i=>n.sys.readFile(i)),{options:r}=n.parseJsonSourceFileConfigFileContent(s,n.sys,j(t)),a=new Map([t,...s.extendedSourceFiles??[]].map(i=>[i,X(i)]));return J.set(t,{mtimes:a,options:r}),r},G=(e,t)=>{if(t===N)return;if(!t.startsWith("./")&&!t.startsWith("../")){const a={moduleResolution:n.ModuleResolutionKind.Bundler,...Ke(e)},i=n.resolveModuleName(t,e,a,n.sys).resolvedModule;return i?.isExternalLibraryImport===!0?void 0:i?.resolvedFileName}const o=x(j(e),t.replace(Me,"")),s=U.map(a=>`${o}${a}`),r=U.map(a=>x(o,`index${a}`));return[...s,...r].find(a=>M(a))},Ge=e=>{const t=new Map;for(const o of e.statements){if(!n.isImportDeclaration(o)||o.importClause?.phaseModifier===n.SyntaxKind.TypeKeyword||!n.isStringLiteral(o.moduleSpecifier))continue;const s=o.importClause?.namedBindings,r=s!==void 0&&n.isNamedImports(s)?s.elements:[];for(const a of r)a.isTypeOnly||t.set(a.name.text,{module:o.moduleSpecifier.text,name:(a.propertyName??a.name).text})}return t},We=e=>{const t=new Map;for(const o of e.statements){if(!n.isImportDeclaration(o)||o.importClause?.phaseModifier===n.SyntaxKind.TypeKeyword||!n.isStringLiteral(o.moduleSpecifier))continue;const s=o.importClause?.namedBindings;s!==void 0&&n.isNamespaceImport(s)&&t.set(s.name.text,o.moduleSpecifier.text)}return t},_=e=>n.canHaveModifiers(e)&&(n.getModifiers(e)??[]).some(t=>t.kind===n.SyntaxKind.ExportKeyword),Ve=e=>n.isVariableStatement(e)?_(e)?e.declarationList.declarations.flatMap(t=>n.isIdentifier(t.name)?[t.name.text]:[]):[]:(n.isClassDeclaration(e)||n.isFunctionDeclaration(e))&&_(e)?e.name===void 0?[]:[e.name.text]:n.isExportDeclaration(e)&&e.moduleSpecifier===void 0&&!e.isTypeOnly&&e.exportClause!==void 0&&n.isNamedExports(e.exportClause)?e.exportClause.elements.map(t=>t.name.text):[],Ye=e=>new Set(e.statements.flatMap(t=>Ve(t))),Ue=(e,t,o)=>{if(n.isIdentifier(e))return t.get(e.text);if(n.isPropertyAccessExpression(e)&&n.isIdentifier(e.expression)){const s=o.get(e.expression.text);return s===void 0?void 0:{module:s,name:e.name.text}}},qe=(e,t,o)=>_(e)?e.declarationList.declarations.flatMap(s=>{if(!n.isIdentifier(s.name)||s.initializer===void 0)return[];const r=Ue(s.initializer,t,o);return r===void 0?[]:[{exported:s.name.text,module:r.module,name:r.name}]}):[],He=(e,t)=>{const o=e.heritageClauses?.find(r=>r.token===n.SyntaxKind.ExtendsKeyword)?.types[0]?.expression;if(!_(e)||e.name===void 0||o===void 0||!n.isIdentifier(o))return[];const s=t.get(o.text);return s===void 0?[]:[{exported:e.name.text,module:s.module,name:s.name}]},Xe=e=>{const t=Ge(e),o=We(e);return e.statements.flatMap(s=>{if(n.isVariableStatement(s))return qe(s,t,o);if(n.isClassDeclaration(s))return He(s,t);if(!n.isExportDeclaration(s)||s.isTypeOnly)return[];const{exportClause:r,moduleSpecifier:a}=s,i=a!==void 0&&n.isStringLiteral(a)?a.text:void 0;return r===void 0?i===void 0?[]:[{exported:void 0,module:i,name:void 0}]:n.isNamedExports(r)?r.elements.flatMap(c=>{if(c.isTypeOnly)return[];const d=c.name.text,l=(c.propertyName??c.name).text;if(i!==void 0)return[{exported:d,module:i,name:l}];const u=t.get(l);return u===void 0?[]:[{exported:d,module:u.module,name:u.name}]}):[]})},W=(e,t,o,s,r=new Set)=>{const a=JSON.stringify([e,o,[...r]]);if(s.has(a))return!1;s.add(a);const i=K(e),c=Xe(i),d=new Set([...r,...Ye(i),...c.flatMap(l=>l.exported===void 0?[]:[l.exported])]);return c.some(l=>{if(o!==void 0&&l.exported!==void 0&&l.exported!==o||l.exported!==void 0&&r.has(l.exported))return!1;if(l.exported===void 0){const g=o??(l.module===N?t:void 0);if(g!==void 0&&d.has(g))return!1}const u=l.exported===void 0?o:l.name;if(l.module===N)return u===void 0||u===t;const E=G(e,l.module);return E!==void 0&&W(E,t,u,s,l.exported===void 0?d:r)})},F=(e,t)=>Be(e).some(o=>{const s=o.getParent();return o.getText()!==t||m.isNamespaceImport(s)||m.isPropertyAccessExpression(s)&&s.getNameNode()===o||m.isQualifiedName(s)&&s.getRight()===o?!1:m.isPropertyAccessExpression(s)?s.getName()===S:m.isQualifiedName(s)?!m.isTypeReference(s.getParent())&&s.getRight().getText()===S:!0}),Je=e=>{const[t]=e.getArguments();return e.getExpression().getKind()===n.SyntaxKind.ImportKeyword&&t!==void 0&&(m.isStringLiteral(t)||m.isNoSubstitutionTemplateLiteral(t))&&t.getLiteralValue()===N},Qe=e=>{const t=e.getPropertyNameNode();if(t===void 0)return e.getNameNode().getText();const o=m.isComputedPropertyName(t)?t.getExpression():t;return m.isStringLiteral(o)||m.isNoSubstitutionTemplateLiteral(o)?o.getLiteralValue():t.getText()},ze=e=>{let t=e,o=!1;for(let r=e.getParent();m.isParenthesizedExpression(r)||m.isAwaitExpression(r);r=t.getParent())o||=m.isAwaitExpression(r),t=r;if(!o)return!0;const s=t.getParent();if(m.isVariableDeclaration(s)){const r=s.getNameNode();return!m.isObjectBindingPattern(r)||r.getElements().some(a=>a.getDotDotDotToken()!==void 0||Qe(a)===S)}return m.isPropertyAccessExpression(s)&&s.getExpression()===t?s.getName()===S:!0},Ze=(e,t)=>K(e).statements.some(o=>n.isExportDeclaration(o)&&o.moduleSpecifier!==void 0&&n.isStringLiteral(o.moduleSpecifier)&&o.moduleSpecifier.text===N&&o.exportClause!==void 0&&n.isNamespaceExport(o.exportClause)&&o.exportClause.name.text===t),et=e=>e.getImportDeclarations().some(t=>{const o=t.getNamespaceImport(),s=t.isTypeOnly()?[]:t.getNamedImports().filter(d=>!d.isTypeOnly()),r=s.some(d=>d.getNameNode().getText()===S),a=s.filter(d=>F(e,(d.getAliasNode()??d.getNameNode()).getText())),i=o!==void 0&&F(e,o.getText());if(!r&&!i&&a.length===0)return!1;const c=G(e.getFilePath(),t.getModuleSpecifierValue());return c===void 0?!1:(r||i)&&W(c,S,S,new Set)||a.some(d=>Ze(c,d.getNameNode().getText()))}),oe=e=>{const t=e.getImportDeclarations().filter(o=>o.getModuleSpecifierValue()===N&&!o.isTypeOnly());return t.some(o=>o.getNamedImports().some(s=>!s.isTypeOnly()&&s.getNameNode().getText()===S))||t.some(o=>{const s=o.getNamespaceImport();return s!==void 0&&F(e,s.getText())})||e.getExportDeclarations().some(o=>o.getModuleSpecifierValue()===N&&!o.isTypeOnly()&&o.getNamedExports().some(s=>!s.isTypeOnly()&&s.getNameNode().getText()===S))||et(e)||e.getDescendantsOfKind(n.SyntaxKind.CallExpression).some(o=>Je(o)&&ze(o))},tt=e=>{const t=[],o=s=>{if(n.isImportDeclaration(s)&&s.importClause?.phaseModifier!==n.SyntaxKind.TypeKeyword&&n.isStringLiteral(s.moduleSpecifier))t.push(s.moduleSpecifier.text);else if(n.isExportDeclaration(s)&&!s.isTypeOnly&&s.moduleSpecifier!==void 0&&n.isStringLiteral(s.moduleSpecifier))t.push(s.moduleSpecifier.text);else if(n.isCallExpression(s)&&s.expression.kind===n.SyntaxKind.ImportKeyword){const[r]=s.arguments;r!==void 0&&(n.isStringLiteral(r)||n.isNoSubstitutionTemplateLiteral(r))&&t.push(r.text)}n.forEachChild(s,o)};return o(e),t},st=new Set([".cjs",".cts",".js",".jsx",".mjs",".mts",".ts",".tsx"]),ot=new Set([".git",".lunora-cache",".wrangler","dist",D,"node_modules"]),rt=["lunora","src"],nt=/\benv\s*\.\s*DB\b/,it=/\benv\s*\.\s*AI\b/,re=["ai","aiSearch","analytics","analyticsSql","artifacts","browser","hyperdrive","images","kv","mail","notify","payments","pipelines","r2sql","scheduler","storage","x402"],ne=e=>`uses${e.charAt(0).toUpperCase()}${e.slice(1)}`,ie=[["usesAuth","@lunora/auth"],["usesCimdWorkers","@lunora/auth/cimd/workers"],["usesX402Charge","@lunora/x402/charge"],["usesPaymentAutumn","@lunora/payment/autumn"],["usesPaymentCreem","@lunora/payment/creem"],["usesPaymentDodopayments","@lunora/payment/dodopayments"],["usesPaymentPolar","@lunora/payment/polar"],["usesPaymentStripe","@lunora/payment/stripe"]],ae=[...re.map(e=>[ne(e),z[e].moduleSpecifier]),...ie].toSorted(([e],[t])=>e.localeCompare(t)),at=[["usesNotifyFcm","@lunora/notify:fcm"],["usesNotifyWebPush","@lunora/notify:webPush"],["hostsShardRegistry","@lunora/do:shardRegistry"],["hostsEventLog","@lunora/replica:eventLog"],["usesEventLogClient","@lunora/replica:eventLogClient"],["usesRequestSecretTool","@lunora/agent:requestSecretTool"]],ct=["@lunora/agent","@lunora/agent/sandbox"],ce=new RegExp(String.raw`["'\x60](?:${[...ae.map(([,e])=>e),...ct,N].map(e=>Oe(e)).join("|")})["'\x60]`,"u"),p=e=>{const{contextProperty:t,moduleSpecifier:o}=z[e];return t===void 0?`${o} is imported`:`${o} is imported or ctx.${t} is read`},dt="STRIPE_SECRET_KEY + STRIPE_WEBHOOK_SECRET (Stripe) or POLAR_ACCESS_TOKEN + POLAR_WEBHOOK_SECRET (Polar)",lt=/\bfrom\s+["']\.{1,2}\//u,de=(e,t)=>{let o;try{o=ue(e,{withFileTypes:!0})}catch{return}for(const s of o){if(s.isDirectory()){ot.has(s.name)||de(x(e,s.name),t);continue}const r=s.name.lastIndexOf(".");r!==-1&&st.has(s.name.slice(r))&&t.push(x(e,s.name))}},ut=(e,t,o)=>{const s=Ee(e,t);return o?{...s,services:s.services.filter(r=>r.binding!==Z)}:s},pt=(e,t,o)=>{const{info:s}=De(e,t,o);return{jurisdiction:s?.jurisdiction,needsD1:s?.hasD1GlobalTable??!1}};let P;const mt=e=>{const t=ge(e);return P?.root!==t&&(P={project:new ee({compilerOptions:{allowJs:!0},skipAddingFilesFromTsConfig:!0}),root:t}),P.project},ft=(e,t,o)=>{e.getSourceFile(t)?.getFullText()!==o&&e.createSourceFile(t,o,{overwrite:!0})},gt=(e,t)=>{for(const o of e.getSourceFiles())t.has(o)||e.removeSourceFile(o)},ht=(e,t,o)=>{const s=x(e,o),r=mt(e),a=[],i=new Set,c=[],d=[],l=be();let u=!1,E=!1;for(const f of t){const h=x(e,f);if(!M(h)||!k(h).isDirectory())continue;const I=[];de(h,I);for(const C of I){i.add(C);const y=Q(C,"utf8"),w=se(C,s);u||=it.test(y),E||=nt.test(y),(ce.test(y)||y.includes(S)||w&&(Ne(y)||lt.test(y)))&&(ft(r,C,y),a.push({file:C,inLunora:w}))}}gt(r,new Set(a.map(({file:f})=>r.getSourceFileOrThrow(f))));for(const{file:f,inLunora:h}of a)(h?c:d).push(Ce(r.getSourceFileOrThrow(f),l));const g=Y(c),T=Y([g,...d]),O=new Set([...T.valueImports,...T.dynamicImports]),b=Te({contextReads:g.contextReads,valueImports:O});return{...Object.fromEntries([...re.map(f=>[ne(f),b.has(f)]),...ie.map(([f,h])=>[f,O.has(h)])]),needsD1:E,usesEventLogClient:a.some(({file:f})=>oe(r.getSourceFileOrThrow(f))),usesRequestSecretTool:g.requestSecretTool,usesAi:b.has("ai")||u,usesBrowser:b.has("browser")||g.sandboxTools.usesSandboxBrowser,usesWorkerLoader:g.sandboxTools.usesSandboxLoader,scannedFiles:i}},St=(e,t,o)=>[...e.map(s=>s.exported?`${s.bindingName}/${s.className} (container "${s.exportName}" declared and exported)`:`hint: container "${s.exportName}" is declared but ${s.className} is not exported by the worker entry — add \`export * from "./lunora/_generated/containers"\``),...t.map(s=>s.exported?`exports.${s.className} (workflow "${s.exportName}" declared and exported)`:`hint: workflow "${s.exportName}" is declared but ${s.className} is not exported by the worker entry — add \`export * from "./lunora/_generated/workflows"\``),...o.map(s=>s.exported?`exports.${s.className} (agent "${s.exportName}" declared and exported)`:`hint: agent "${s.exportName}" is declared but ${s.className} is not exported by the worker entry — add \`export * from "./lunora/_generated/agents"\``)],xt=(e,t,o)=>[[e.usesAi,`AI (${p("ai")}, env.AI is used, or an agent is declared)`],[e.usesAuth&&!t.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&&!t.has("SchedulerDO"),`hint: ${p("scheduler")}, but no SchedulerDO is exported by the worker entry`],[e.usesStorage,`hint: ${p("storage")}; add an r2_buckets binding (bucket binding names are user-defined)`],[e.usesMail,`hint: ${p("mail")}; set RESEND_API_KEY in .dev.vars (obtain at https://resend.com/api-keys)`],[e.usesPayments,`hint: ${p("payments")}; set the provider secrets in .dev.vars — ${dt}`],[e.usesBrowser,`browser (${p("browser")}, or a sandbox browserTool imported in lunora/) — self-describing { binding: BROWSER }`],[e.usesImages,`images (${p("images")}) — self-describing { binding: IMAGES }`],[e.usesAnalytics,`analytics_engine_datasets (${p("analytics")}) — self-describing { binding: ANALYTICS, dataset }`],[e.usesWorkerLoader,"worker_loaders (jsCodeTool imported in lunora/) — self-describing { binding: LOADER }"],[e.usesAiSearch,`ai_search_namespaces (${p("aiSearch")}) — self-describing { binding: AI_SEARCH, namespace: "default" }; remote-only, so \`lunora dev\` reaches the deployed AI Search service`],[e.usesAnalyticsSql,`analytics (${p("analyticsSql")}) — self-describing { binding: ANALYTICS_SQL }; needs wrangler >= 4.145.0, and is remote-only, so \`lunora dev\` queries the account's live analytics`],[e.usesKv,o.jurisdiction===void 0?`kv_namespaces (${p("kv")}) — { binding: KV } with no id; wrangler creates the namespace on the first deploy`:`hint: ${p("kv")} and the schema pins "${o.jurisdiction}"; create the namespace with --jurisdiction ${o.jurisdiction} and add a kv_namespaces binding ({ binding, id })`],[e.usesHyperdrive,`hyperdrive (${p("hyperdrive")}) — { binding: HYPERDRIVE } with a placeholder id; dev uses an embedded Postgres and \`lunora deploy\` creates the config`],[e.usesPipelines,`hint: ${p("pipelines")}; run 'wrangler pipelines create <name>' and add a 'pipelines' binding ({ binding, stream }) — the pipeline resource can't be auto-provisioned`],[e.usesArtifacts,o.jurisdiction===void 0?`artifacts (${p("artifacts")}) — { binding: ARTIFACTS, namespace }`:`hint: ${p("artifacts")}; the schema pins data to "${o.jurisdiction}", so create the namespace in that jurisdiction first and add { binding: ARTIFACTS, namespace } yourself — \`lunora deploy\` then checks it (a first create() in dev would make it unrestricted)`],[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.usesX402,`hint: ${p("x402")} (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),yt=(e,t,o,s=[],r=[],a=[])=>{const i=new Set(e.map(d=>d.className)),c=e.map(d=>`${d.binding}/${d.className} (exported by worker entry)`);return t.needsD1&&c.push("DB (.global() table declared)"),c.push(...St(s,r,a),...xt(o,i,t)),c},vt=(e,t)=>e.some(o=>o.binding==="SHARD_REGISTRY")||te(t)&&M(x(t,"shardRegistry.ts")),Et=(e,t,o)=>{const s=new ee({compilerOptions:{allowJs:!0},skipAddingFilesFromTsConfig:!0}),r=[e],a=new Set;for(let i=r.pop();i!==void 0;i=r.pop()){if(a.has(i))continue;a.add(i);const c=K(i),d=c.text;if((ce.test(d)||d.includes(S))&&oe(s.createSourceFile(i,d,{overwrite:!0})))return!0;for(const l of tt(c)){const u=G(i,l);u!==void 0&&!t.has(u)&&!se(u,o)&&r.push(u)}}return!1},bt=e=>!e.composed&&e.path!==void 0&&W(e.path,"EventLogDO",void 0,new Set),jt=async e=>{await Ie;const t=e.schemaDir??"lunora",o=e.scanDirs??rt,s=()=>ht(e.projectRoot,o,t),{scannedFiles:r,...a}=e.cache===void 0?s():e.cache.memo(`capabilities:${e.projectRoot}:${t}:${o.join(",")}`,s),i=_e(e.projectRoot);let c;i.composed?c=Le(x(e.projectRoot,t,D)).map(V=>({binding:$e[V],className:V})):c=i.path===void 0?[]:Pe(i.path);const d=pt(e.projectRoot,t,e.cache),l={...d,needsD1:a.needsD1||d.needsD1},u=$(i,Ae(e.projectRoot,t,e.cache).containers,"containers"),E=$(i,je(e.projectRoot,t).workflows,"workflows"),g=$(i,Re(e.projectRoot,t).agents,"agents"),T={...a,usesAi:a.usesAi||g.length>0},O=[...ke(e.projectRoot,t).queues],{flags:b}=Fe(e.projectRoot,t),L=B(e.projectRoot,t,ve,ye),f=L.error===void 0?L.value:{hasFcm:!0,hasWebPush:!0},h=b?.provider==="flagship"&&b.mode==="binding"?b.bindingName:void 0,I=x(e.projectRoot,t,D),C=vt(c,I),y=bt(i),w=!i.composed&&i.path!==void 0&&Et(i.path,r,I),R=yt(c,l,T,u,E,g);!i.composed&&te(x(e.projectRoot,t,D))&&!c.some(v=>v.className==="LunoraDO")&&R.push("hint: durableObjects.merge is set, but the worker entry exports no LunoraDO — export one built with mergeDurableObjects, or the classes stay separate"),h!==void 0&&R.push(`hint: lunora/flags.ts uses Flagship in binding mode; add a flagship binding ({ binding: "${h}", app_id }) — the app_id can't be auto-provisioned`);const A=ut(e.projectRoot,t,e.skipCompanion===!0),le=A.error===void 0?A.services:void 0;return A.error!==void 0&&R.push(`hint: lunora.config \`services\` not reconciled — ${A.error}`),R.push(...A.services.map(v=>v.binding===Z?`${v.binding} → ${v.worker} (studio.companion)`:`${v.binding} → ${v.worker} (lunora.config services.${v.name})`)),{...T,usesEventLogClient:T.usesEventLogClient||w,agents:g,containers:u,durableObjects:c,flagshipBinding:h,...l.jurisdiction===void 0?{}:{jurisdiction:l.jurisdiction},needsD1:l.needsD1,queues:O,services:le,signals:R,usesFlags:b!==void 0,usesNotifyFcm:f?.hasFcm??!1,usesNotifyWebPush:f?.hasWebPush??!1,hostsEventLog:y,hostsShardRegistry:C,workflows:E}},Ft=e=>[...ae,...at].filter(([t,o])=>e[t]&&we[o]!==void 0).map(([,t])=>t);export{jt as inferLunoraBindings,Ft as secretSourcesFromBindings};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{CUSTOM_INSTANCE_TYPE_LIMITS as f,CUSTOM_INSTANCE_MIN_MEMORY_MIB_PER_VCPU as y}from"@lunora/container";import{i as g,a as d}from"./guards-Buu_E7mP.mjs";const h=[{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"]}],B=[...new Set(h.map(({path:e})=>e[0]))],_=(e,n)=>{let a=e;for(const s of n)a=g(a)?a[s]:void 0;return a},L=e=>{const n={};for(const{of:a,path:s}of h){const t=a(e);if(t===void 0)continue;const[i,o]=s;n[i]=o===void 0?t:{...n[i],[o]:t}}return n},F=(e,n,a)=>{if(n.length===0)return;const s=e.vectorize??[],t=new Set(s.filter(Boolean).map(i=>i?.index_name));for(const i of n)t.has(i)||a.push(`schema declares vector index "${i}"; wrangler "vectorize" must include a binding with index_name "${i}"`)},w=new Set(["basic","dev","lite","standard","standard-1","standard-2","standard-3","standard-4"]),M={disk_mb:f.diskMb,memory_mib:f.memoryMib,vcpu:{...f.vcpu,hint:'use the named "lite" or "basic" instance type below 1 vCPU'}},j=(e,n,a)=>{const s=e.instance_type;if(s===void 0)return;if(typeof s=="string"){w.has(s)||a.push(`${n} has unknown instance_type "${s}" — expected lite, basic, standard-1..4, or a custom { vcpu, memory_mib, disk_mb } object`);return}for(const[o,{hint:r,max:c,min:b}]of Object.entries(M)){const m=s[o];if(m!==void 0&&(typeof m!="number"||Number.isNaN(m)||m<b||m>c)){const S=r!==void 0&&typeof m=="number"&&m<b?` — ${r}`:"";a.push(`${n} custom instance_type ${o} must be a number in ${String(b)}–${String(c)} (got ${String(m)})${S}`)}}const{memory_mib:t,vcpu:i}=s;typeof i=="number"&&typeof t=="number"&&t<i*y&&a.push(`${n} custom instance_type needs ≥ 3 GiB (${String(y)} MiB) memory per vCPU (got ${String(t)} MiB for ${String(i)} vCPU)`)},E=(e,n,a)=>{for(const s of["image","instance_type","max_instances"])e[s]!==void 0&&a.push(`${n} sets "${s}", which the durable_object scheduling policy does not take — the Durable Object picks image and size at start`);for(const[s,t]of Object.entries(e.images??{}))[t?.dockerfile,t?.image].filter(o=>typeof o=="string"&&o.length>0).length!==1&&a.push(`${n} images["${s}"] must set exactly one of "dockerfile" or "image"`)},A=(e,n,a)=>{const{boundClasses:s,classKinds:t,errors:i,warnings:o}=a;if(!e||typeof e!="object"||typeof e.class_name!="string"||e.class_name.length===0){i.push(`${n} must have a non-empty "class_name" naming its container-enabled Durable Object class`);return}const r=e.scheduling_policy==="durable_object";e.scheduling_policy!==void 0&&e.scheduling_policy!=="default"&&!r&&i.push(`${n} ("${e.class_name}") has unknown scheduling_policy "${e.scheduling_policy}" — expected "default" or "durable_object"`),r?E(e,`${n} ("${e.class_name}")`,i):(typeof e.image!="string"||e.image.length===0)&&i.push(`${n} ("${e.class_name}") must have an "image" — a Dockerfile path or a registry reference`),s.has(e.class_name)||i.push(`${n} class "${e.class_name}" has no matching durable_objects binding — your dev server auto-reconciles this on startup; add { "name": "...", "class_name": "${e.class_name}" } to fix it by hand`);const c=t.get(e.class_name);c!=="sqlite"&&i.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}"]`),j(e,`${n} ("${e.class_name}")`,i),e.max_instances===void 0&&!r&&o.push(`${n} ("${e.class_name}") declares no max_instances — set a cap so a traffic spike can't fan out unbounded container spend`)},u=e=>Array.isArray(e)?e.filter(n=>n!==null&&typeof n=="object"):[],p=e=>Array.isArray(e)?e.filter(n=>d(n)):[],k=e=>{const n=new Map;for(const a of u(e)){for(const s of p(a.new_classes))n.set(s,"classic");for(const s of p(a.new_sqlite_classes))n.set(s,"sqlite");for(const s of u(a.renamed_classes))if(d(s.from)&&d(s.to)){const t=n.get(s.from)??"sqlite";n.delete(s.from),n.set(s.to,t)}for(const s of p(a.deleted_classes))n.delete(s)}return n},x=e=>new Set(k(e).keys()),P=(e,n)=>{const a=x(e.migrations);for(const s of u(e.durable_objects?.bindings))s.script_name===void 0&&d(s.class_name)&&!a.has(s.class_name)&&n.push(`durable_objects.bindings declares class "${s.class_name}" but it is missing from migrations — add a migration entry with "new_sqlite_classes": ["${s.class_name}"] (or "new_classes" for a non-SQLite-backed class), or let the dev server auto-reconcile it on the next start`)},W=(e,n,a)=>{if(e.containers===void 0)return;if(!Array.isArray(e.containers)){n.push("containers must be an array of { class_name, image, ... } entries");return}const s=e.containers;if(s.length===0)return;const t=new Set(u(e.durable_objects?.bindings).map(o=>o.class_name)),i=k(e.migrations);for(const[o,r]of s.entries())A(r,`containers[${String(o)}]`,{boundClasses:t,classKinds:i,errors:n,warnings:a});e.observability?.enabled!==!0&&a.push('containers are configured but observability is not enabled — container logs will not be captured (add { "observability": { "enabled": true } })')},l=e=>e,v=(e,n,a,s)=>{if(e!==void 0){if(!Array.isArray(e)){s.push(a.arrayMessage);return}for(const[t,i]of l(e).entries()){const o=`${n}[${String(t)}]`;if(!i||typeof i!="object"){s.push(a.objectMessage(o));continue}for(const r of a.fields)d(i[r.field])||s.push(r.message(o))}}},G={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`},I=(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",R=e=>{if(e!==void 0)return g(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"},N=e=>e===void 0?[]:g(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"],$=(e,n,a,s)=>{const t=[I(e.schedules,a),R(e.limits),...N(e.default_retention)];for(const i of t)i!==void 0&&s.push(`${n}.${i}`)},q=(e,n)=>h.map(({path:a})=>a).filter(a=>{const s=_(e,a),t=_(n,a),i=typeof t=="string"&&a[0]==="schedules"?[t]:t;return s!==void 0&&t!==void 0&&JSON.stringify(s)!==JSON.stringify(i)}).map(a=>a.join(".")),O=(e,n,a,s)=>{const t=`exports["${e}"]`,i=String(n.name);for(const o of a){if(!g(o)||o.name!==n.name)continue;const r=`workflows entry "${String(o.binding)}"`;if(o.script_name!==void 0){s.push(`${r} binds workflow "${i}" in another Worker, but ${t} declares a workflow with that name here — workflow names are unique per account`);continue}o.class_name!==e&&s.push(`${r} and ${t} both declare workflow "${i}" but name different classes ("${String(o.class_name)}" vs "${e}")`);for(const c of q(o,n))s.push(`${r} and ${t} set ${c} to different values for workflow "${i}" — set it in one place`)}},K=(e,n)=>{const a=Array.isArray(e.workflows)?l(e.workflows):[];for(const[t,i]of a.entries())g(i)&&$(i,`workflows[${String(t)}]`,!1,n);const s=g(e.exports)?Object.entries(e.exports):[];for(const[t,i]of s)!g(i)||i.type!=="workflow"||(d(i.name)?($(i,`exports["${t}"]`,!0,n),O(t,i,a,n)):n.push(`exports["${t}"] is a workflow export and must have a non-empty "name" naming the deployed workflow`))},C={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`},T={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`},Q=(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}v(e.queues.producers,"queues.producers",C,n),v(e.queues.consumers,"queues.consumers",T,n)}},V={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`},Y=[{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`,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"}],z=(e,n,a,s)=>{const t=e[n.key];if(t!==void 0){if(!Array.isArray(t)){a.push(n.arrayMessage);return}for(const[i,o]of l(t).entries()){const r=`${n.key}[${String(i)}]`;if(!o||typeof o!="object"||!d(o.binding)){a.push(n.bindingMessage(r));continue}if(!("hintField"in n))continue;(typeof n.hintField=="string"?[n.hintField]:n.hintField).some(b=>d(o[b]))||s.push(n.hintMessage(r,o.binding))}}},H=[{key:"analytics",message:'analytics must be an object with a non-empty "binding" (e.g. { "binding": "ANALYTICS_SQL" })'},{key:"browser",message:'browser must be an object with a non-empty "binding" (e.g. { "binding": "BROWSER" })'},{key:"images",message:'images must be an object with a non-empty "binding" (e.g. { "binding": "IMAGES" })'},{key:"media",message:'media must be an object with a non-empty "binding" (e.g. { "binding": "MEDIA" })'},{key:"stream",message:'stream must be an object with a non-empty "binding" (e.g. { "binding": "STREAM" })'}],J=(e,n,a)=>{const s=e[n.key];s!==void 0&&(typeof s!="object"||s===null||Array.isArray(s)||!d(s.binding))&&a.push(n.message)},X=[{arrayMessage:"ai_search_namespaces must be an array of { binding, namespace } entries",fields:[{field:"binding",message:e=>`${e} must have a non-empty "binding" naming the AI Search binding`},{field:"namespace",message:e=>`${e} must have a non-empty "namespace" naming the AI Search namespace (every account has "default")`}],key:"ai_search_namespaces",objectMessage:e=>`${e} must be a { binding, namespace } object`},{arrayMessage:"ai_search must be an array of { binding, instance_name } entries",fields:[{field:"binding",message:e=>`${e} must have a non-empty "binding" naming the AI Search binding`},{field:"instance_name",message:e=>`${e} must have a non-empty "instance_name" naming an existing AI Search instance`}],key:"ai_search",objectMessage:e=>`${e} must be a { binding, instance_name } object`},{arrayMessage:"services must be an array of { binding, service, entrypoint? } entries",fields:[{field:"binding",message:e=>`${e} must have a non-empty "binding" naming the service binding`},{field:"service",message:e=>`${e} must have a non-empty "service" naming the target Worker`}],key:"services",objectMessage:e=>`${e} must be a { binding, service, entrypoint? } object`},{arrayMessage:"dispatch_namespaces must be an array of { binding, namespace } entries",fields:[{field:"binding",message:e=>`${e} must have a non-empty "binding"`},{field:"namespace",message:e=>`${e} must have a non-empty "namespace" naming the dispatch namespace`}],key:"dispatch_namespaces",objectMessage:e=>`${e} must be a { binding, namespace } object`},{arrayMessage:"mtls_certificates must be an array of { binding, certificate_id } entries",fields:[{field:"binding",message:e=>`${e} must have a non-empty "binding"`},{field:"certificate_id",message:e=>`${e} must have a non-empty "certificate_id" (upload via \`wrangler mtls-certificate upload\`)`}],key:"mtls_certificates",objectMessage:e=>`${e} must be a { binding, certificate_id } object`},{arrayMessage:"r2_buckets must be an array of { binding, bucket_name } entries",fields:[{field:"binding",message:e=>`${e} must have a non-empty "binding" naming the R2 bucket binding`},{field:"bucket_name",message:e=>`${e} must have a non-empty "bucket_name" naming the deployed bucket`}],key:"r2_buckets",objectMessage:e=>`${e} must be a { binding, bucket_name } object`},{arrayMessage:"vpc_services must be an array of { binding, service_id } entries",fields:[{field:"binding",message:e=>`${e} must have a non-empty "binding" naming the VPC Service binding`},{field:"service_id",message:e=>`${e} must have a non-empty "service_id" (create one with \`wrangler vpc service create\`)`}],key:"vpc_services",objectMessage:e=>`${e} must be a { binding, service_id } object`},{arrayMessage:"artifacts must be an array of { binding, namespace } entries",fields:[{field:"binding",message:e=>`${e} must have a non-empty "binding" naming the Artifacts binding`},{field:"namespace",message:e=>`${e} must have a non-empty "namespace" naming the Artifacts namespace`}],key:"artifacts",objectMessage:e=>`${e} must be a { binding, namespace } object`}],Z=(e,n,a)=>{n?.hasD1GlobalTable&&!u(e.d1_databases).some(s=>s.binding==="DB")&&a.push('schema declares .global() tables; d1_databases must include a binding named "DB" — your dev server auto-reconciles this on startup, or add the binding manually'),n?.hasHyperdriveGlobalTable&&u(e.hyperdrive).length===0&&a.push('schema declares .global({ backend: "hyperdrive" }) tables; wrangler must declare a hyperdrive binding for `.hyperdriveGlobal({ exec })` to read — run `wrangler hyperdrive create <name> --connection-string=...` and add `"hyperdrive": [{ "binding": "HYPERDRIVE", "id": "<id>" }]` (any binding name works; your `exec` selector picks it)')},ee=(e,n)=>{const{d1_databases:a}=e;if(a!==void 0){if(!Array.isArray(a)){n.push("d1_databases must be an array of { binding, database_id | database_name } entries");return}for(const[s,t]of l(a).entries()){const i=`d1_databases[${String(s)}]`;if(!t||typeof t!="object"){n.push(`${i} must be a { binding, database_id | database_name } object`);continue}d(t.binding)||n.push(`${i} must have a non-empty "binding" naming the D1 binding`),!d(t.database_id)&&!d(t.database_name)&&n.push(`${i} must have a "database_id" or a "database_name" — run \`wrangler d1 create\` and set one, or the binding can't resolve`)}}},ne=(e,n)=>{const{vpc_networks:a}=e;if(a!==void 0){if(!Array.isArray(a)){n.push("vpc_networks must be an array of { binding, tunnel_id | network_id } entries");return}for(const[s,t]of l(a).entries()){const i=`vpc_networks[${String(s)}]`;if(!t||typeof t!="object"){n.push(`${i} must be a { binding, tunnel_id | network_id } object`);continue}d(t.binding)||n.push(`${i} must have a non-empty "binding" naming the VPC Network binding`),d(t.tunnel_id)===d(t.network_id)&&n.push(`${i} must set exactly one of "tunnel_id" (a Cloudflare Tunnel) or "network_id" ("cf1:network" for Cloudflare Mesh)`)}}};export{Y as H,X as R,H as S,G as W,Z as a,ee as b,F as c,W as d,v as e,x as f,K as g,Q as h,z as i,J as j,ne as k,V as l,B as m,p as n,u as o,h as p,_ as s,P as v,L as w};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as u,a as f}from"./guards-Buu_E7mP.mjs";import{o as v}from"./validate-bindings-PVHSAU6M.mjs";const _=new Set(["1","enabled","on","true","yes"]),A=s=>typeof s=="string"&&_.has(s.trim().toLowerCase()),b=(s,t,e,i)=>{s!==void 0&&typeof s!="boolean"&&e.push(`${t} must be a boolean${i===void 0?"":` (${i})`}`)},O=(s,t,e)=>{s!==void 0&&(typeof s!="number"||Number.isNaN(s)||s<0||s>1)&&e.push(`${t} must be a number in [0, 1] (the fraction of requests sampled)`)},N=(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`)},k=(s,t)=>{b(s.logpush,"logpush",t,'set "logpush": true to enable Cloudflare Logpush')},I=(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"] })')},m=3e5,C=(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>m&&t.push(`limits.cpu_ms must be at most ${String(m)} (Cloudflare's per-invocation ceiling)`)}},p=new Set(["off","smart","targeted"]),w=(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"||!p.has(i))&&t.push(`placement.mode must be one of ${[...p].map(n=>`"${n}"`).join(", ")}`)},c={kind:"boolean"},h={kind:"samplingRate"},y={destinations:{kind:"destinations"},enabled:c,head_sampling_rate:h,persist:c},S={...y,invocation_logs:{hint:'set "invocation_logs": true to keep per-invocation summaries',kind:"boolean"}},L={enabled:c,head_sampling_rate:h,issues:{kind:"level",level:{enabled:c}},logs:{kind:"level",level:S},redact_query_string:c,traces:{kind:"level",level:y}},E=(s,t,e,i)=>{switch(s.kind){case"boolean":{b(t,e,i,s.hint);break}case"destinations":{t!==void 0&&(!Array.isArray(t)||t.some(n=>!f(n)))&&i.push(`${e} must be an array of destination names configured in the Cloudflare dashboard`);break}case"samplingRate":{O(t,e,i);break}}},g=(s,t,e,i,n)=>{for(const[o,a]of Object.entries(s)){const r=Object.hasOwn(t,o)?t[o]:void 0,l=`${e}.${o}`;r===void 0?n.push(`${l} is not a documented wrangler key (expected one of ${Object.keys(t).join(", ")}) — a typo is silently ignored by wrangler`):r.kind!=="level"?E(r,a,l,i):u(a)?g(a,r.level,l,i,n):a!==void 0&&i.push(`${l} must be an object`)}},x=(s,t,e)=>{const{observability:i}=s;if(i!==void 0){if(!u(i)){t.push('observability must be an object (e.g. { "enabled": true, "head_sampling_rate": 1 })');return}g(i,L,"observability",t,e)}},D=(s,t)=>{const{cache:e}=s;if(e!==void 0){if(!u(e)){t.push('cache must be an object (e.g. { "enabled": true })');return}b(e.enabled,"cache.enabled",t)}},T=(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`))}}},B=(s,t)=>{const{assets:e}=s;if(e!==void 0){if(typeof e!="object"||Array.isArray(e)){t.push('assets must be an object (e.g. { "directory": "./dist/client", "binding": "ASSETS" })');return}(typeof e.directory!="string"||e.directory.length===0)&&t.push('assets must declare a non-empty "directory" pointing at the built client output (e.g. "./dist/client")'),e.binding!==void 0&&(typeof e.binding!="string"||e.binding.length===0)&&t.push('assets.binding must be a non-empty string (e.g. "ASSETS")'),e.html_handling!==void 0&&typeof e.html_handling!="string"&&t.push("assets.html_handling must be a string"),e.not_found_handling!==void 0&&typeof e.not_found_handling!="string"&&t.push("assets.not_found_handling must be a string")}},U=(s,t)=>{const e=s.tail_consumers;if(e===void 0)return;if(!Array.isArray(e)){t.push("tail_consumers must be an array of { service, environment? } entries");return}const i=e;for(const[n,o]of i.entries())(!o||typeof o!="object"||typeof o.service!="string"||o.service.length===0)&&t.push(`tail_consumers[${String(n)}] must have a non-empty "service" naming the consumer Worker`)},G=(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]}},P=(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(r=>r.trim()==="*"),a=A(n);o&&a&&t.push('vars.LUNORA_ALLOWED_ORIGINS includes a "*" wildcard while vars.LUNORA_CORS_ALLOW_CREDENTIALS is on — browsers reject this combination and it defeats the allowlist; name explicit origins or drop credentials')},j=s=>v(s.durable_objects?.bindings).some(t=>t.class_name==="SchedulerDO"&&t.script_name===void 0),d="LUNORA_ORIGIN_URL",W=(s,t,e,i=j(s)?"durable_objects.bindings declares the SchedulerDO":void 0)=>{if(i===void 0||f(s.vars?.[d]))return;const n=t===void 0?"vars":`env.${t}.vars`,o=t===void 0?"":` --env ${t}`;e.push(`${i} but ${n}.${d} 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 ${n}.${d} to the worker's public URL, or \`wrangler secret put ${d}${o}\` (ignore this if it is already set as a secret or in the dashboard).`)};export{B as validateAssets,D as validateCache,P as validateCorsVariables,T as validateExports,C as validateLimits,k as validateLogpush,x as validateObservability,w as validatePlacement,W as validateSchedulerOrigin,I as validateSecretsRequired,N as validateSendEmail,U as validateTailConsumers,G as withTailConsumer};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{relative as t}from"node:path";import{i as o}from"./guards-Buu_E7mP.mjs";import{findWranglerFile as u,readWranglerJsonc as d}from"./WRANGLER_FILES-UNW-xY5u.mjs";import{scanWranglerVariablesForSecrets as l}from"./scanWranglerVariablesForSecrets-C0Yt1KAG.mjs";const n=(s,e)=>{const r=s?.producers;return(Array.isArray(r)?r:[]).flatMap(i=>o(i)&&typeof i.binding=="string"&&typeof i.queue=="string"?[{binding:i.binding,queue:i.queue,...e===void 0?{}:{env:e}}]:[])},v=s=>{const e=u(s),r=e===void 0?void 0:d(e).parsed;return e===void 0||r===void 0?{wranglerQueueProducers:[],wranglerVariables:[]}:{wranglerQueueProducers:[...n(r.queues),...Object.entries(r.env??{}).flatMap(([a,i])=>n(i?.queues,a))],wranglerVariables:l(o(r.vars)?r.vars:void 0,t(s,e))}};export{v as wranglerCodegenInputs};
|