@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.
Files changed (42) hide show
  1. package/dist/cloudflare/index.d.mts +131 -4
  2. package/dist/cloudflare/index.d.ts +131 -4
  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/{DEV_WORKER_ENV_VALUE-Buh60zHI.mjs → DEV_WORKER_ENV_VALUE-DdPmCpf3.mjs} +1 -1
  8. package/dist/packem_shared/{PACKAGE_SECRETS_REGISTRY-C8tN4qgQ.mjs → PACKAGE_SECRETS_REGISTRY-CnY7jg9j.mjs} +1 -1
  9. package/dist/packem_shared/{POLICY_SCAFFOLD_ENDPOINT-xEHecns4.mjs → POLICY_SCAFFOLD_ENDPOINT-CXr3lZGF.mjs} +1 -1
  10. package/dist/packem_shared/REQUIRED_COMPATIBILITY_DATE-B8WSlhBx.mjs +1 -0
  11. package/dist/packem_shared/{SCHEMA_EDIT_ENDPOINT-qrJCQf0v.mjs → SCHEMA_EDIT_ENDPOINT-CUN4q8oi.mjs} +1 -1
  12. package/dist/packem_shared/{STUDIO_PATH-DDlZcH-q.mjs → STUDIO_PATH-BFXK7eku.mjs} +1 -1
  13. package/dist/packem_shared/UNEXPORTED_CLASS_MARKER-Cf3uQ2s0.mjs +1 -0
  14. package/dist/packem_shared/{assertWranglerSatisfiesSchema-DmkdB-OW.mjs → assertWranglerSatisfiesSchema-BSIX4ljM.mjs} +1 -1
  15. package/dist/packem_shared/asset-headers-CGvrhfGW.mjs +4 -0
  16. package/dist/packem_shared/{buildPackageSecretsBlock-DkAJ9DmX.mjs → buildPackageSecretsBlock-B4Odg5OF.mjs} +1 -1
  17. package/dist/packem_shared/collectExportGaps-CJPSXdEn.mjs +2 -0
  18. package/dist/packem_shared/emitProjectAssetHeaders-C0Ec7nsF.mjs +1 -0
  19. package/dist/packem_shared/env-flag-u4B05gLp.mjs +1 -0
  20. package/dist/packem_shared/{infer-bindings.d-DtKuba3D.d.mts → infer-bindings.d-Tkaosiub.d.mts} +15 -3
  21. package/dist/packem_shared/{infer-bindings.d-DtKuba3D.d.ts → infer-bindings.d-Tkaosiub.d.ts} +15 -3
  22. package/dist/packem_shared/inferLunoraBindings-D0QDcugr.mjs +1 -0
  23. package/dist/packem_shared/is-plain-object-CWxHeOY1.mjs +1 -0
  24. package/dist/packem_shared/{package-secrets-registry-B4MtZQYU.mjs → package-secrets-registry-TouCAMQN.mjs} +1 -1
  25. package/dist/packem_shared/reconcile-assets-DXQsm--3.mjs +1 -0
  26. package/dist/packem_shared/{reconcileBindingsSafely-CNLZojiQ.mjs → reconcileBindingsSafely-BKL4MGWX.mjs} +1 -1
  27. package/dist/packem_shared/{scanWranglerVariablesForSecrets-C0Yt1KAG.mjs → scanWranglerVariablesForSecrets-CkonQUdG.mjs} +1 -1
  28. package/dist/packem_shared/spa-assets-C591NPiX.mjs +1 -0
  29. package/dist/packem_shared/withTailConsumer-BUDKESwC.mjs +1 -0
  30. package/dist/packem_shared/wranglerCodegenInputs-BPoRg-2G.mjs +1 -0
  31. package/dist/packem_shared/{write-atomic-BK08pOLO.mjs → write-atomic-B8e7rVyT.mjs} +1 -1
  32. package/dist/packem_shared/writeAssetHeaders-BWSEaedL.mjs +1 -0
  33. package/dist/studio-host/index.mjs +1 -1
  34. package/package.json +2 -2
  35. package/dist/packem_shared/REQUIRED_COMPATIBILITY_DATE-C8qfwbaA.mjs +0 -1
  36. package/dist/packem_shared/UNEXPORTED_CLASS_MARKER-07SNQ0rP.mjs +0 -1
  37. package/dist/packem_shared/collectExportGaps-vVbPzutT.mjs +0 -2
  38. package/dist/packem_shared/guards-Buu_E7mP.mjs +0 -1
  39. package/dist/packem_shared/inferLunoraBindings-DeR_c0W0.mjs +0 -1
  40. package/dist/packem_shared/validate-bindings-PVHSAU6M.mjs +0 -1
  41. package/dist/packem_shared/withTailConsumer-CF3pk_Ov.mjs +0 -1
  42. package/dist/packem_shared/wranglerCodegenInputs-BG0xZlgU.mjs +0 -1
@@ -0,0 +1,4 @@
1
+ import{existsSync as k,readFileSync as x,rmSync as D,writeFileSync as L}from"node:fs";import{LunoraError as E}from"@lunora/errors";import{a as I}from"./env-flag-u4B05gLp.mjs";import{i as w}from"./is-plain-object-CWxHeOY1.mjs";import{join as C}from"node:path";const R="default-src 'none'; frame-ancestors 'none'; base-uri 'none'; form-action 'none'",j="accelerometer=(), autoplay=(), camera=(), display-capture=(), geolocation=(), gyroscope=(), magnetometer=(), microphone=(), payment=(), usb=()",H=31536e3,F={coop:void 0,csp:void 0,enabled:!1,frameOptions:void 0,hsts:void 0,permissionsPolicy:void 0,referrerPolicy:void 0},M=s=>{if(s===!1)return;const e=s===void 0||s===!0?{}:s,r=e.maxAge??H,t=e.includeSubDomains??!0;return`max-age=${String(r)}${t?"; includeSubDomains":""}${e.preload===!0?"; preload":""}`},T=(s,e)=>e!==void 0?["frame-ancestors 'self'",...e].join(" "):s==="DENY"?"frame-ancestors 'none'":s==="SAMEORIGIN"?"frame-ancestors 'self'":void 0,U=/^[a-z][\d+.a-z-]*:\/\/(?:\*\.)?[\d.a-z-]+(?::\d{1,5})?$/iu,$=s=>[...s].every(e=>e===" "||e>=" "&&e!==""&&e<="ÿ"),G=["same-origin","same-origin-allow-popups","unsafe-none"],W=["DENY","SAMEORIGIN"],S=["includeSubDomains","maxAge","preload"],P=["csp","permissionsPolicy","referrerPolicy"],b=[...P,"crossOriginOpenerPolicy","frameAncestors","frameOptions","hsts"],p=s=>s.map(e=>JSON.stringify(e)).join(", "),Y=(s,e)=>{if(typeof s=="boolean")return s;if(!w(s)){e.push("security.headers.hsts must be a boolean or an object { maxAge?, includeSubDomains?, preload? }");return}for(const n of Object.keys(s).filter(i=>!S.includes(i)))e.push(`security.headers.hsts.${n} is not an option (expected ${p(S)})`);const{includeSubDomains:r,maxAge:t,preload:o}=s;t!==void 0&&!(typeof t=="number"&&Number.isSafeInteger(t)&&t>=0)&&e.push(`security.headers.hsts.maxAge must be a whole number of seconds (got ${JSON.stringify(t)})`);for(const[n,i]of[["includeSubDomains",r],["preload",o]])i!==void 0&&typeof i!="boolean"&&e.push(`security.headers.hsts.${n} must be a boolean`);return{...r===void 0?{}:{includeSubDomains:r},...t===void 0?{}:{maxAge:t},...o===void 0?{}:{preload:o}}},v=(s,e,r,t)=>{if(e===void 0||e===!1||r.includes(e))return e;t.push(`security.headers.${s} must be one of ${p(r)} or false (got ${JSON.stringify(e)})`)},B=(s,e)=>{if(s!==void 0){if(!Array.isArray(s)){e.push('security.headers.frameAncestors must be an array of origins like ["https://partner.example"]');return}for(const r of s)(typeof r!="string"||!U.test(r)||!$(r))&&e.push(`security.headers.frameAncestors entry ${JSON.stringify(r)} is not an origin like "https://partner.example"`);return[...s]}},X=s=>{if(s===void 0||typeof s=="boolean")return{ok:!0,value:s};if(!w(s))return{ok:!1,problems:[`security.headers must be a boolean or an object (got ${Array.isArray(s)?"an array":JSON.stringify(s)})`]};const e=Object.keys(s).filter(t=>!b.includes(t)).map(t=>`security.headers.${t} is not an option (expected ${p(b)})`),r={};for(const t of P){const o=s[t];o===void 0||o===!1?r[t]=o:typeof o!="string"?e.push(`security.headers.${t} must be a string or false`):$(o)?r[t]=o:e.push(`security.headers.${t} contains a line break or control character`)}return r.crossOriginOpenerPolicy=v("crossOriginOpenerPolicy",s.crossOriginOpenerPolicy,G,e),r.frameOptions=v("frameOptions",s.frameOptions,W,e),r.frameAncestors=B(s.frameAncestors,e),r.hsts=s.hsts===void 0?void 0:Y(s.hsts,e),r.frameAncestors!==void 0&&typeof r.csp=="string"&&e.push("security.headers.frameAncestors cannot be combined with a csp string: put the frame-ancestors directive in the csp"),r.frameAncestors!==void 0&&r.frameOptions==="DENY"&&e.push('security.headers.frameAncestors cannot be combined with frameOptions: "DENY"'),r.frameAncestors!==void 0&&r.csp===!1&&e.push("security.headers.frameAncestors needs the Content-Security-Policy that carries it; it cannot be combined with csp: false"),e.length>0?{ok:!1,problems:e}:{ok:!0,value:Object.fromEntries(Object.entries(r).filter(([,t])=>t!==void 0))}},ge=(s,e)=>s??(I(e)?!1:void 0),V=s=>{if(s===!1)return F;const e=s===void 0||s===!0?{}:s,r=e.frameAncestors!==void 0||e.frameOptions===!1?void 0:e.frameOptions??"SAMEORIGIN",t=["base-uri 'none'","object-src 'none'",T(r,e.frameAncestors)].filter(n=>n!==void 0).join("; ");let o;return typeof e.csp=="string"?o={htmlValue:e.csp,value:e.csp}:e.csp!==!1&&(o={htmlValue:t,value:R}),{coop:e.crossOriginOpenerPolicy===!1?void 0:e.crossOriginOpenerPolicy??"same-origin-allow-popups",csp:o,enabled:!0,frameOptions:r,hsts:M(e.hsts),permissionsPolicy:e.permissionsPolicy===!1?void 0:e.permissionsPolicy??j,referrerPolicy:e.referrerPolicy===!1?void 0:e.referrerPolicy??"strict-origin-when-cross-origin"}},J="_headers",h="# BEGIN lunora-managed: rewritten on every build. Put your own rules outside this block.",m="# END lunora-managed",d=100,O=2e3,K=s=>{const e=X(s);if(!e.ok)throw new E("CONFIG_INVALID",`[lunora] cannot write _headers: ${e.problems.join("; ")}`);const r=V(e.value);return r.enabled?[["Strict-Transport-Security",r.hsts],["X-Content-Type-Options","nosniff"],["X-Frame-Options",r.frameOptions],["Referrer-Policy",r.referrerPolicy],["Permissions-Policy",r.permissionsPolicy],["Cross-Origin-Opener-Policy",r.coop],["Content-Security-Policy",r.csp?.htmlValue]].filter(o=>o[1]!==void 0):[]},z="public, max-age=31536000, immutable",q=s=>s.split(`
2
+ `).map(e=>e.endsWith("\r")?e.slice(0,-1):e),A=s=>{let e=0,r=s.length;for(;e<r&&s[e]?.trim()==="";)e+=1;for(;r>e&&s[r-1]?.trim()==="";)r-=1;return s.slice(e,r)},Q=s=>{const e=q(s),r=e.indexOf(h);if(r===-1)return A(e);const t=e.indexOf(m,r);return t===-1?void 0:A([...e.slice(0,r),...e.slice(t+1)])},_=s=>s.startsWith(" ")||s.startsWith(" "),Z=s=>s!==""&&!_(s)&&!s.startsWith("#"),ee=s=>{if(!s.startsWith("https://"))return s;const e=s.indexOf("/",8);return e===-1?"/":s.slice(e)},se=s=>{const e=[];let r=new Set;for(const t of s){if(Z(t)){e.push({rule:t.trim(),sets:[]}),r=new Set;continue}const o=e.at(-1),n=t.trim();if(o===void 0||!_(t)||n.startsWith("#"))continue;if(n.startsWith("!")){r.add(n.slice(1).trim().toLowerCase());continue}const i=n.indexOf(":");if(i>0){const a=n.slice(0,i).trim().toLowerCase();o.sets.push({detached:r.has(a),name:a})}}return e},re=s=>{const e=new Set,r=[];for(const{rule:t,sets:o}of s)for(const{detached:n,name:i}of o)t==="/*"?e.add(i):n||r.push({name:i,rule:t});return{stacked:r,taken:e}},te=(s,e)=>{const r=ee(s).split("/").slice(1),t=e.split("/");for(const[o,n]of r.entries()){const i=t[o];if(n.includes("*")||i===void 0)return!0;if(!n.startsWith(":")&&n!==i)return!1}return!1},oe=(s,e)=>s.some(({rule:r,sets:t})=>t.some(({name:o})=>o==="cache-control")&&te(r,e)),ne=s=>[h,...s.flatMap(e=>[e.path,...e.headers.map(([r,t])=>` ${r}: ${t}`)]),m],N=/^frame-ancestors(?:\s|$)/iu,ie=s=>s.split(";").map(e=>e.trim()).filter(e=>e!==""&&!N.test(e)).join("; "),ae=(s,e,r)=>e?ie(s):(s.split(";").some(t=>N.test(t.trim()))&&r.push("your _headers rule for /* sets X-Frame-Options, but the csp in lunora.config carries a frame-ancestors directive, which browsers apply instead of X-Frame-Options; make the two agree"),s),ce=(s,e)=>{const r=` ${s}: ${e}`;if(r.length>O)throw new E("INTERNAL",`[lunora] the _headers line for ${s} would be ${String(r.length)} characters; Cloudflare ignores a line longer than ${String(O)}, which would leave every static page without it. Shorten security.headers in lunora.config: list fewer frameAncestors origins (one *.example.com entry covers its subdomains), or a shorter csp.`)},le=(s,e,r)=>{const t=[],o=[],n=[];for(const[i,a]of s){for(const l of e.stacked.filter(f=>f.name===i.toLowerCase()))o.push(`_headers rule "${l.rule}" sets ${i} on top of Lunora's default, so both values are sent; add "! ${i}" above it in that rule to replace the default`);if(e.taken.has(i.toLowerCase())){t.push(i);continue}const c=i==="Content-Security-Policy"&&e.taken.has("x-frame-options")?ae(a,r,o):a;ce(i,c),n.push([i,c])}return{deferred:t,rule:n.length===0?void 0:{headers:n,path:"/*"},warnings:o}},fe=(s,e,r)=>{const t=Math.max(0,d-e),o=s.slice(0,t),n=s.slice(t);return n.length>0&&r.push(`_headers already has ${String(e)} of your rules, and Cloudflare applies at most ${String(d)}; Lunora left out its ${n.map(i=>i.path).join(", ")} rule so yours still apply. Merge some of your rules to make room`),e>d&&r.push(`_headers has ${String(e)} rules of your own; Cloudflare ignores every rule past the ${String(d)}th`),o},de=(s,e)=>{const r=Q(s??"");if(r===void 0)return{deferred:[],text:s,warnings:[`_headers has "${h}" but no "${m}" line, so Lunora cannot tell its rules from yours and left the file as it is; put the END line back after the managed rules, or delete the managed block`]};const t=se(r),o=[],n=[],i=[],a=typeof e.headers!="object"||typeof e.headers.csp!="string",c=le(K(e.headers),re(t),a);o.push(...c.deferred),n.push(...c.warnings),c.rule!==void 0&&i.push(c.rule);const l=e.immutableDirectory?.replaceAll("\\","/").split("/").filter(g=>g!==""&&g!==".").join("/");l!==void 0&&l!==""&&(oe(t,l)?o.push("Cache-Control"):i.push({headers:[["Cache-Control",z]],path:`/${l}/*`}));const f=fe(i,t.length,n),u=f.length===0?[]:ne(f),y=r.length>0&&u.length>0?[...u,"",...r]:[...u,...r];return{deferred:o,text:y.length===0?void 0:`${y.join(`
3
+ `)}
4
+ `,warnings:n}},Se=(s,e)=>{const r=C(s,J),t=k(r)?x(r,"utf8"):void 0,o=de(t,e);return o.text===void 0?(t!==void 0&&D(r,{force:!0}),{deferred:o.deferred,path:void 0,warnings:o.warnings}):(o.text!==t&&L(r,o.text,"utf8"),{deferred:o.deferred,path:r,warnings:o.warnings})};export{ge as e,de as m,Se as w};
@@ -1,4 +1,4 @@
1
- import{randomBytes as D}from"node:crypto";import{existsSync as g,readFileSync as m,writeFileSync as E,linkSync as j,rmSync as h,renameSync as V,statSync as I}from"node:fs";import{join as p}from"node:path";import{LunoraError as N}from"@lunora/errors";import{DEV_VARS_FILE as u,DEV_VARS_EXAMPLE_FILE as y,parseDevVariableLine as $,parseDevVariableEntries as S,DEV_VARS_NEWLINE as C}from"./DEV_VARS_EXAMPLE_FILE-CqLorAxT.mjs";import{M as z,S as f,C as P,m as B,b as O,s as W}from"./package-secrets-registry-B4MtZQYU.mjs";const H=e=>[...P,...W(e)],K=32,Y=["replace","openssl","changeme","change-me","change_me","change-this","change_this","your-","your_","example","placeholder","todo","fill-me","fill_me","fill-in","fill_in","xxx"],U=/[.*+?^${}()|[\]\\]/gu,X=/[a-z0-9]$/u,L=e=>{const t=e.trim().toLowerCase();return t===""||t.startsWith("<")&&t.endsWith(">")?!0:Y.some(n=>{const r=n.replaceAll(U,String.raw`\$&`),s=X.test(n)?`(^|[^a-z0-9])${r}([^a-z0-9]|$)`:`(^|[^a-z0-9])${r}`;return new RegExp(s,"u").test(t)})},x=e=>D(e).toString("hex"),w=new Set([...z,f]),G=(e,t,n=w)=>e===f?n.has(e)&&(t.trim()===""||t===O):n.has(e),T=(e,t,n,r)=>G(e,t,r)&&L(t)?n(K):void 0,ue=(e=x)=>e(K),b=(e,t,n,r=w)=>e.split(C).map(o=>{const s=$(o),a=s?T(s.key,s.value,t,r):void 0;return!s||a===void 0?o:(n.push(s.key),`${s.key}="${a}"`)}),q=e=>{if(e.devVarsExists)return{status:"exists"};if(e.exampleContent===void 0)return{status:"no-example"};const t=[];return{content:b(e.exampleContent,e.randomHex??x,t).join(`
1
+ import{randomBytes as D}from"node:crypto";import{existsSync as g,readFileSync as m,writeFileSync as E,linkSync as j,rmSync as h,renameSync as V,statSync as I}from"node:fs";import{join as p}from"node:path";import{LunoraError as N}from"@lunora/errors";import{DEV_VARS_FILE as u,DEV_VARS_EXAMPLE_FILE as y,parseDevVariableLine as $,parseDevVariableEntries as S,DEV_VARS_NEWLINE as C}from"./DEV_VARS_EXAMPLE_FILE-CqLorAxT.mjs";import{M as z,S as f,C as P,m as B,b as O,s as W}from"./package-secrets-registry-TouCAMQN.mjs";const H=e=>[...P,...W(e)],K=32,Y=["replace","openssl","changeme","change-me","change_me","change-this","change_this","your-","your_","example","placeholder","todo","fill-me","fill_me","fill-in","fill_in","xxx"],U=/[.*+?^${}()|[\]\\]/gu,X=/[a-z0-9]$/u,L=e=>{const t=e.trim().toLowerCase();return t===""||t.startsWith("<")&&t.endsWith(">")?!0:Y.some(n=>{const r=n.replaceAll(U,String.raw`\$&`),s=X.test(n)?`(^|[^a-z0-9])${r}([^a-z0-9]|$)`:`(^|[^a-z0-9])${r}`;return new RegExp(s,"u").test(t)})},x=e=>D(e).toString("hex"),w=new Set([...z,f]),G=(e,t,n=w)=>e===f?n.has(e)&&(t.trim()===""||t===O):n.has(e),T=(e,t,n,r)=>G(e,t,r)&&L(t)?n(K):void 0,ue=(e=x)=>e(K),b=(e,t,n,r=w)=>e.split(C).map(o=>{const s=$(o),a=s?T(s.key,s.value,t,r):void 0;return!s||a===void 0?o:(n.push(s.key),`${s.key}="${a}"`)}),q=e=>{if(e.devVarsExists)return{status:"exists"};if(e.exampleContent===void 0)return{status:"no-example"};const t=[];return{content:b(e.exampleContent,e.randomHex??x,t).join(`
2
2
  `),generatedKeys:t,status:"generate"}},J=e=>e.includes('"')||e.includes("\\")?"":e.replaceAll("\r",String.raw`\r`).replaceAll(`
3
3
  `,String.raw`\n`),_=e=>{const t=e.randomHex??x,n=new Set(S(e.existingContent).map(a=>a.key)),r=[],o=[],s=[];for(const a of e.exampleContent.split(C)){const i=$(a);if(!i||n.has(i.key))continue;const c=T(i.key,i.value,t,w);s.push(i.key),c===void 0?r.push(`${i.key}="${J(i.value)}"`):(o.push(i.key),r.push(`${i.key}="${c}"`))}return{additions:r,generatedKeys:o,missingKeys:s}},k=e=>e.length>0?` (generated ${e.join(", ")})`:"",F=e=>`${e}.tmp-${String(process.pid)}`,v=(e,t,n={})=>{const r=F(e);try{E(r,t,{encoding:"utf8",...n}),V(r,e)}catch(o){throw h(r,{force:!0}),o}},Q=(e,t)=>{try{return E(e,t,{encoding:"utf8",flag:"wx",mode:384}),!0}catch(n){if(n.code==="EEXIST")return!1;throw n}},M=(e,t)=>{const n=F(e);try{E(n,t,{encoding:"utf8",flag:"wx",mode:384});try{return j(n,e),!0}catch(r){const{code:o}=r;if(o==="EEXIST")return!1;if(o==="EPERM"||o==="ENOTSUP")return Q(e,t);throw r}}finally{h(n,{force:!0})}},fe=(e,t)=>{v(e,t,{mode:384})},A=5,R=e=>{try{const t=I(e);return{mtimeMs:t.mtimeMs,size:t.size}}catch{return}},Z=(e,t)=>e===void 0||t===void 0?!1:e.mtimeMs===t.mtimeMs&&e.size===t.size,ee=(e,t)=>{for(let n=0;n<A;n+=1){const r=R(e),o=m(e,"utf8"),s=t(o);if(s.length===0)return[];const a=o.length>0&&!o.endsWith(`
4
4
  `)?`
@@ -0,0 +1,2 @@
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 _}from"./applyModify-DKP2l6S9.mjs";import{recordManifestKey as re,readManifest as Y}from"./readManifest-Cighz3WC.mjs";import{D1_PLACEHOLDER_ID as U,HYPERDRIVE_PLACEHOLDER_ID as ae}from"./D1_PLACEHOLDER_ID-ZnDjVymH.mjs";import{m as de,w as ce,n as le,s as G,o as D,p as T,q as ue}from"./reconcile-assets-DXQsm--3.mjs";import{parseTree as ge,findNodeAtLocation as me}from"jsonc-parser";import{r as pe,a as fe,b as be,c as he}from"./reconcile-services-C4TwY8YH.mjs";import{DEV_VARS_FILE as ve,parseDevVariableEntries as we}from"./DEV_VARS_EXAMPLE_FILE-CqLorAxT.mjs";import{secretSourcesFromBindings as _e}from"./inferLunoraBindings-D0QDcugr.mjs";import{requiredSecrets as ye}from"./buildPackageSecretsBlock-B4Odg5OF.mjs";import{b as Se}from"./spa-assets-C591NPiX.mjs";import{s as Ee}from"./worker-entry-checks-CHrum2AN.mjs";import{DEFAULT_OBSERVABILITY as xe}from"./DEFAULT_OBSERVABILITY-CPLADr5u.mjs";import{findWranglerFile as Ae,readWranglerJsonc as Oe}from"./WRANGLER_FILES-UNW-xY5u.mjs";const $e=[["maxBatchSize","max_batch_size"],["maxBatchTimeout","max_batch_timeout"],["maxConcurrency","max_concurrency"],["maxRetries","max_retries"],["deadLetterQueue","dead_letter_queue"],["retryDelay","retry_delay"]],P=e=>Object.fromEntries($e.filter(([n])=>e.tuning[n]!==void 0).map(([n,s])=>[s,e.tuning[n]])),B="queueTuning",Ne=/^[\t ]*(?:,[\t ]*)?(?:\/\/[^\n\r]*)?\r?\n/u,ke=/^[\t ]*,/u,Ce=(e,n)=>{const s=ge(e),t=s===void 0?void 0:me(s,[...n])?.parent;if(t?.type==="property"){const o=t.offset+t.length,i=e.lastIndexOf(`
2
+ `,t.offset-1)+1,r=Ne.exec(e.slice(o));if(r!==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:ke.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+r[0].length)}}return _(e,n,void 0)},J=(e,n,s,t,o,i=new Set)=>{const r=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(P(g)).filter(([f])=>!i.has(f))),h=Object.entries(o[l.queue]??{}).filter(([f])=>!Object.hasOwn(b,f)),y=Object.entries(b).filter(([f,S])=>l[f]!==S),E=h.filter(([f,S])=>l[f]===S).map(([f])=>f),O=Object.fromEntries(Object.entries({...l,...b}).filter(([f])=>!E.includes(f)));for(const[f,S]of y)c=_(c,[...s,v,f],S);for(const f of E)c=Ce(c,[...s,v,f]);for(const[f,S]of h){const A=l[f];A!==void 0&&A!==S&&d.push(`${r}/${l.queue}: ${f} is no longer declared by defineQueue, but it was changed by hand to ${JSON.stringify(A)} from the declared ${JSON.stringify(S)}, so it was kept. Delete it from wrangler.jsonc if it should go.`)}return(y.length>0||E.length>0)&&u.push(`${r}/${l.queue} (${[...y.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}},Te=(e,n,s,t)=>{const o=n.queues??{},i=o.producers??[],r=o.consumers??[],m=new Set(i.map(g=>g?.binding)),u=new Set(r.map(g=>g.queue)),d=s.filter(g=>!m.has(g.bindingName)),c=s.filter(g=>!u.has(g.name)),p=J(e,r,["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"}:{},...P(h)}))];for(const h of c){const y=P(h);Object.keys(y).length>0&&(v[h.name]=y)}l=_(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}},Ie=(e,n,s,t,o)=>{const i=n.env?.[t],r=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,r,["env",t,"queues","consumers"],u,o,new Set(["dead_letter_queue"])),c=r.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=r.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]}},Re=(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=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.${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},je=(e,n,s)=>{const t=Object.fromEntries(Object.entries({...n,...s}).filter(([,o])=>Object.keys(o).length>0));re(e,B,Object.keys(t).length===0?void 0:t)},qe="https://api.cloudflare.com/client/v4/accounts/<ACCOUNT_ID>/artifacts/namespaces",De=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 ${qe} 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.`},I="PIPELINES",R="ARTIFACTS",Pe=(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===I),r=e.usesArtifacts?n?.artifacts??[]:[],m=r.some(d=>d.binding===R)?[]:r.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&&r.length===0&&(!t||e.jurisdiction!==void 0),De(e.jurisdiction)],[i,`ctx.pipelines is used but no "${I}" pipelines binding exists; run 'wrangler pipelines create <name>' and add a 'pipelines' binding ({ binding: "${I}", stream }) — codegen resolves this one name, and the pipeline resource can't be auto-provisioned.`],[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)},Be=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),j=(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.`),Le=(e,n)=>{const s=new Set([...e.workflows,...e.agents].map(i=>i.className));if(s.size===0)return[];const t=Object.entries(n.exports??{}).flatMap(([i,r])=>r?.type==="workflow"?[i]:[]),o=(n.workflows??[]).flatMap(i=>i.class_name===void 0||i.script_name!==void 0?[]:[i.class_name]);return[...new Set([...t,...o])].filter(i=>!s.has(i)).map(i=>`wrangler.jsonc declares workflow "${i}" but no defineWorkflow/defineAgent export generates that class — a leftover from a rename will fail the deploy (wrangler rejects a class the worker does not export). Remove it if it is not hand-wired.`)},We=(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.`]})]},Me=(e,n)=>[...Le(e,n),...We(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"}],Ke=()=>X.map(({keys:e,label:n})=>`${e[0]} + ${e[1]} (${n})`).join(" or "),Fe=e=>{let n;try{n=ee(Q(e,ve),"utf8")}catch{return!1}const s=new Map(we(n).map(t=>[t.key,t.value]));return X.some(({keys:t})=>t.every(o=>(s.get(o)??"")!==""))},He=(e,n)=>{const s=n?.secrets?.required;if(!Array.isArray(s))return[];const t=new Set(s),o=ye(_e(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.`]},q=(e,n,s,t)=>{const o=new Set(e.durableObjects.map(u=>u.className)),i=[],r=(s?.r2_buckets?.length??0)>0,m=(s?.d1_databases?.some(u=>u.binding==="DB")??!1)||e.needsD1;return e.usesStorage&&!r&&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(...j("container","containers",e.containers),...j("workflow","workflows",e.workflows),...j("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&&!Fe(n)&&i.push(`@lunora/payment is used; set one provider's secret pair in .dev.vars — ${Ke()}.`),i.push(...Be(e),...Pe(e,s,t),...He(e,s)),s!==void 0&&i.push(...Me(e,s)),i},Ye=e=>[["container","containers",e.containers],["workflow","workflows",e.workflows],["agent","agents",e.agents]].flatMap(([s,t,o])=>o.filter(i=>!i.exported).map(({className:i,exportName:r})=>({className:i,exportName:r,kind:s,module:t}))),Ve=e=>{const n=new Set(D(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 D(e)){for(const t of T(s.deleted_classes))n.delete(t);for(const{from:t,to:o}of D(s.renamed_classes))t!==void 0&&n.delete(t),o!==void 0&&n.add(o);for(const t of[...T(s.new_classes),...T(s.new_sqlite_classes)])n.add(t)}return n},Ue=(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 r=e;const m=[];if(i.length>0){const c=[...t,...i.map(p=>({class_name:p.className,name:p.binding}))];r=_(r,["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=>!Qe(u).has(c));if(d.length>0){const c=[...u,{new_sqlite_classes:d,tag:Ve(u)}];r=_(r,["migrations"],c)}return{added:m,text:r}},W=e=>e===void 0||e==="cloudflare",Ge=(e,n)=>e.includes("DB (D1)")&&W(n)?[`wrote a DB binding with a placeholder database_id ("${U}") — run \`wrangler d1 create <name>\` and replace it before deploying.`]:[],Je=(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:_(e,["d1_databases"],o)}},Xe={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)"}},ze=(e,n)=>e.usesAnalyticsSql&&Ee(n,new Set(["analyticsSql"]))?.chained.has("analyticsSql")!==!0,Ze=new Set(["ratelimits","send_email"]),en=["durable_objects","logfwdr","unsafe"],nn=new Set(["data_blobs","text_blobs","vars","wasm_modules"]),M=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),L=(e,n,s)=>M(e)&&e[n]===s,sn=(e,n,s)=>{if(nn.has(e))return M(n)&&Object.hasOwn(n,s);const t=Ze.has(e)?"name":"binding";return Array.isArray(n)?n.some(o=>L(o,t,s)):L(n,"binding",s)},$=(e,n)=>{const s=e,t=Object.entries(s).find(([i,r])=>i!=="env"&&sn(i,r,n));if(t!==void 0)return t[0];for(const i of en){const r=s[i];if(M(r)&&Array.isArray(r.bindings)&&r.bindings.some(m=>L(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"},N=(e,n,s)=>{const{binding:t,label:o}=Xe[s],i=n[s]?.binding;if(typeof i=="string"&&i.length>0)return{added:[],text:e};const r=$(n,t);return r!==void 0?{added:[],text:e,warnings:[`${s}: not adding the ${o} binding — the name "${t}" is already bound by \`${r}\` in wrangler.jsonc. Rename that binding, then set ${s}.binding by hand.`]}:{added:[o],text:_(e,[s],{binding:t})}},K=(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.`,tn=(e,n,s)=>{if(!W(s)||(n.hyperdrive?.length??0)>0)return{added:[],text:e};const t=$(n,"HYPERDRIVE");return t!==void 0?{added:[],text:e,warnings:[K("hyperdrive","HYPERDRIVE",t)]}:{added:["HYPERDRIVE (Hyperdrive, created on deploy)"],text:_(e,["hyperdrive"],[{binding:"HYPERDRIVE",id:ae}])}},on=new Set(["celld","cloudflare"]),rn=(e,n,s,t)=>{if(t!==void 0&&!on.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:[K("kv_namespaces","KV",o)]}:{added:[t==="celld"?`KV (Workers KV, celld namespace ${oe(n.name,"KV")})`:"KV (Workers KV, created on deploy)"],text:_(e,["kv_namespaces"],[{binding:"KV"}])}},an=(e,n,s,t)=>{if(!W(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:[K("artifacts","ARTIFACTS",o)]};const i=typeof n.name=="string"&&n.name.length>0?n.name:"lunora";return{added:["ARTIFACTS (Cloudflare Artifacts)"],text:_(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:_(e,[s],[t])}},dn=(e,n)=>{const s=n.worker_loaders??[];return s.some(t=>t.binding==="LOADER")?{added:[],text:e}:{added:["LOADER (Worker Loader)"],text:_(e,["worker_loaders"],[...s,{binding:"LOADER"}])}},cn=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},ln=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}}},un=e=>{if(e.schedulingPolicy==="durable_object")return z(e);const{image:n}=e,s={class_name:e.className,image:ln(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=cn(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},gn=(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 r=i.length===0?e:_(e,["containers"],[...t,...i.map(d=>un(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)&&(r=_(r,["containers",d,"images"],v),m.push(`containers/${p.className}.images`))}return{added:i.map(d=>`containers/${d.className}`),text:r,updated:m,warnings:u}},mn=(e,n)=>{if(n.observability!==void 0)return{added:[],text:e};const s=_(e,["observability"],{...xe});return{added:["observability"],text:s}},pn=(e,n)=>n.upload_source_maps!==void 0?{added:[],text:e}:{added:["upload_source_maps"],text:_(e,["upload_source_maps"],!0)},Z=[{minimum:[4,142],name:"wrangler"},{minimum:[1,61],name:"@cloudflare/vite-plugin"}],fn=Z.map(({minimum:e,name:n})=>`${n}@^${e.join(".")}.0`).join(" "),bn=(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}},hn=e=>{const n=Z.flatMap(({minimum:s,name:t})=>{const o=bn(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 ${fn}\`) and re-run.`},vn=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.`]:[]),wn=(e,n,s)=>{let t=e;const o=[],i=[];for(const r of s){const m=n[r.className];if(m?.type==="workflow")for(const{of:u,path:d}of ue){const c=u(r),p=G(m,d),l=`exports/${r.className}.${d.join(".")}`;if(c===void 0){p!==void 0&&i.push(`${l} is set in wrangler.jsonc but defineWorkflow "${r.exportName}" does not declare it — reconcile leaves it in place. Remove it by hand if it was dropped from the definition.`);continue}JSON.stringify(p)!==JSON.stringify(c)&&(t=_(t,["exports",r.className,...d],c),o.push(l))}}return{text:t,updated:o,warnings:i}},_n=(e,n,s,t,o)=>{if(o!==void 0)return{added:[],text:e,warnings:[o]};const i=[...s.map(b=>({settings:ce(b),workflow:b})),...t.map(b=>({settings:{},workflow:b}))],r=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&&r.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 y=u.find(f=>f.class_name===h.className),E=Object.fromEntries(le.flatMap(f=>{const S=G(y,[f]);return S===void 0?[]:[[f,S]]})),O=y?.name??h.name;y?.name!==void 0&&y.name!==h.name&&l.push(`workflows/${h.className} is deployed as "${y.name}" but declared as "${h.name}" — its export keeps "${y.name}" so running instances survive. Change the declaration to match, or rename deliberately (it starts a new, empty workflow).`),v=_(v,["exports",h.className],{type:"workflow",...E,...b,name:O}),(y===void 0?c:p).push(`exports/${h.className}`)}if(u.length>0){const b=m.filter(h=>!u.includes(h));v=_(v,["workflows"],b.length===0?void 0:b),p.push(...u.map(h=>`workflows/${String(h.class_name)} → exports`))}l.push(...vn(n));const g=wn(v,d,s);return{added:c,text:g.text,updated:[...p,...g.updated],warnings:[...l,...g.warnings]}},Wn=(e,n,{environment:s,target:t}={})=>{const o=Ae(e),i=Ye(n);if(!o)return{added:[],changed:!1,exportGaps:i,reason:"wrangler.jsonc not found",updated:[],warnings:q(n,e)};const{parsed:r,text:m}=Oe(o);if(r===void 0)return{added:[],changed:!1,exportGaps:i,reason:`failed to parse ${o} as JSONC`,updated:[],warnings:q(n,e),wranglerPath:o};const u=q(n,e,r,t);if(s!==void 0){const a=r.env?.[s]!==void 0;u.push(a?`auto-provisioned bindings are written to the top level of wrangler.jsonc only (queue consumers "env.${s}" already declares are retuned, nothing is added) — "env.${s}" has its own (non-inheritable) bindings and must be reconciled by hand; \`lunora deploy --env ${s}\` now validates them, so a gap here will be reported at deploy time.`:`--env "${s}" was requested but wrangler.jsonc declares no "env.${s}" block — auto-provisioned bindings are written to the top level only and will not apply to that environment.`)}const d=n.containers.filter(a=>a.exported),c=n.agents.filter(a=>a.exported&&a.voice===!0&&a.voiceBindingName!==void 0&&a.voiceClassName!==void 0),p=[...n.durableObjects,...d.map(a=>({binding:a.bindingName,className:a.className})),...c.map(a=>({binding:a.voiceBindingName,className:a.voiceClassName}))],l=n.workflows.filter(a=>a.exported),v=n.agents.filter(a=>a.exported),g=Y(e),b=Re(g,u),h={},y=pe(g);let E;const O=[{enabled:!0,run:a=>Ue(a,r,p)},{enabled:n.needsD1,run:a=>Je(a,r)},{enabled:n.usesKv,run:a=>rn(a,r,n.jurisdiction,t)},{enabled:n.usesHyperdrive,run:a=>tn(a,r,t)},{enabled:n.usesArtifacts,run:a=>an(a,r,n.jurisdiction,t)},{enabled:n.usesAi,run:a=>N(a,r,"ai")},{enabled:n.usesAiSearch,run:a=>V(a,r,"ai_search_namespaces",{binding:"AI_SEARCH",namespace:"default"},"AI_SEARCH (AI Search namespace)")},{enabled:ze(n,e),run:a=>N(a,r,"analytics")},{enabled:n.usesBrowser,run:a=>N(a,r,"browser")},{enabled:n.usesImages,run:a=>N(a,r,"images")},{enabled:n.usesAnalytics,run:a=>V(a,r,"analytics_engine_datasets",{binding:"ANALYTICS",dataset:"ANALYTICS"},"ANALYTICS (Analytics Engine)")},{enabled:n.usesWorkerLoader,run:a=>dn(a,r)},{enabled:!0,run:a=>mn(a,r)},{enabled:t===void 0||t==="cloudflare",run:a=>pn(a,r)},{enabled:(t===void 0||t==="cloudflare")&&n.workerRoutes!==void 0,run:a=>de(a,r,n.workerRoutes??[],g,Se(e))},{enabled:d.length>0,run:a=>gn(a,r,d)},{enabled:l.length>0||v.length>0,run:a=>_n(a,r,l,v,hn(e))},{enabled:n.queues.length>0,run:a=>{const w=Te(a,r,n.queues,b.queues??{});return h.queues=w.owned,{...w,record:{consequence:"an option removed from defineQueue stays deployed",key:"queueTuning",label:"queue tuning",write:C=>{je(C,b,h)}}}}},{enabled:n.services!==void 0&&(n.services.length>0||Object.keys(y).length>0),run:a=>{const w=fe(a,r,n.services??[],y);return E=w.owned,{...w,record:{consequence:"a service removed from lunora.config stays bound",key:"services",label:"service bindings",write:C=>{he(C,E??w.owned)}}}}},...s===void 0||r.env?.[s]===void 0?[]:[{enabled:n.queues.length>0,run:a=>{const w=`env.${s}.queues`,x=Ie(a,r,n.queues,s,b[w]??{});return h[w]=x.owned,x}}]];let f=m;const S=[],A=[],F=[];for(const a of O){if(!a.enabled)continue;const w=a.run(f);f=w.text,S.push(...w.added),A.push(...w.updated??[]),u.push(...w.warnings??[]),F.push(...[w.record].filter(x=>x!==void 0))}const H=a=>{if(g!==void 0)for(const w of F)try{w.write(Y(e)??g)}catch(x){u.push(`${a?"wrangler.jsonc was updated, but ":""}recording the ${w.label} reconcile owns in ${g.path} (lunora.${w.key}) failed: ${x instanceof Error?x.message:String(x)}. Until it is recorded, ${w.consequence}.`)}};let k;if(n.services!==void 0){const a=be(e,n.services,y);u.push(...a.warnings),E={...E,...a.owned},k=a.added.length>0||a.updated.length>0?{added:a.added,path:a.path,updated:a.updated}:void 0}return u.push(...Ge(S,t)),f===m?(H(!1),{added:S,changed:!1,devConfig:k,exportGaps:i,reason:"bindings already in sync",updated:A,warnings:u,wranglerPath:o}):(ne(o,f,"utf8"),H(!0),{added:S,changed:!0,devConfig:k,exportGaps:i,updated:A,warnings:u,wranglerPath:o})};export{Ye as collectExportGaps,Wn as reconcileWranglerBindings};
@@ -0,0 +1 @@
1
+ import{readdirSync as w,existsSync as g}from"node:fs";import{join as l,relative as p,sep as y,isAbsolute as _,resolve as f,dirname as A}from"node:path";import{readProjectSecurityHeaders as D}from"@lunora/codegen";import{i as d}from"./is-plain-object-CWxHeOY1.mjs";import{w as E,e as S}from"./asset-headers-CGvrhfGW.mjs";import u from"./canonicalPath-DrfMiT3U.mjs";import{resolveProjectTarget as j}from"./assertBuildTargetMatches-CqrrwiQ-.mjs";import{findWranglerFile as P,readWranglerJsonc as $}from"./WRANGLER_FILES-UNW-xY5u.mjs";const R=/\[(name|hash|extname|ext|format)(?::(\d+))?\]/gu,b=/[$()*+.?[\\\]^{|}]/gu,H=/\.map$/u,T=8,h=e=>e.replaceAll(b,String.raw`\$&`),x=e=>{let t="",r=0;for(const o of e.matchAll(R)){t+=h(e.slice(r,o.index));const[,s,n]=o;switch(s){case"extname":{t+=String.raw`(?:\.[^/]+)?`;break}case"hash":{t+=String.raw`[\w-]{${n??String(T)}}`;break}case"name":{t+=".*";break}default:t+="[^/]*"}r=o.index+o[0].length}return new RegExp(`^${t}${h(e.slice(r))}$`,"u")},L=(e,t)=>{try{return w(l(e,t),{recursive:!0,withFileTypes:!0}).filter(r=>r.isFile()).map(r=>p(e,l(r.parentPath,r.name)).split(y).join("/"))}catch{return[]}},U=(e,t,r)=>{const o=r.map(s=>x(s));return L(e,t).every(s=>o.some(n=>n.test(s.replace(H,""))))},F=()=>{const e=process.env.CLOUDFLARE_ENV;return e===void 0||e===""?void 0:e},m=(e,t,r,{inherit:o})=>{const s=d(e)?e:void 0,n=d(s?.[r])?s[r]:void 0;if(t===void 0)return n;const i=s?.env,c=d(i)?i[t]:void 0,a=d(c)?c[r]:void 0;return d(a)?a:o?n:void 0},N=(e,t,r)=>S(D(e),m(t,r,"vars",{inherit:!1})?.LUNORA_SECURITY_HEADERS),k=(e,t)=>{const{hashedDirectory:r,hashedNamePatterns:o,outputDirectory:s,publicDirectory:n}=e;if(!(r===void 0||r===""||t!==void 0&&t!=="none")&&!(o!==void 0&&!U(s,r,o)))return n!==void 0&&g(l(n,r))?void 0:r},C=e=>{const t=j(e.projectRoot,e.target);if(t!=="cloudflare")return{reason:`target "${t}" does not serve _headers`,written:!1};const r=e.wranglerPath??P(e.projectRoot),o=r===void 0?void 0:$(r).parsed,s=F(),n=m(o,s,"assets",{inherit:!0});if(e.requireAssetsDirectory){const a=n?.directory;if(typeof a!="string"||r===void 0)return{reason:"wrangler declares no assets.directory",written:!1};const v=_(a)?a:f(A(r),a);if(u(v)!==u(e.outputDirectory))return{reason:`the build output is not wrangler's assets.directory (${a})`,written:!1}}const i=o!==void 0,c=E(e.outputDirectory,{headers:N(f(e.projectRoot,e.schemaDir??"lunora"),o,s),immutableDirectory:i?k(e,n?.not_found_handling):void 0});return!i&&e.hashedDirectory!==void 0&&e.hashedDirectory!==""&&c.warnings.push(`_headers: no long-term caching for ${e.hashedDirectory}/, because ${r===void 0?"no wrangler.jsonc or wrangler.json was found":`${r} could not be read or parsed`} and assets.not_found_handling decides whether that is safe`),{result:c,written:!0}},K=(e,t)=>{const r=C(e);if(r.written){r.result.deferred.length>0&&t.info(`_headers: kept your own ${r.result.deferred.join(", ")} for static assets instead of Lunora's default`);for(const o of r.result.warnings)t.warn(o)}return r};export{K as emitProjectAssetHeaders};
@@ -0,0 +1 @@
1
+ const e=new Set(["0","disabled","false","no","off"]),t=new Set(["1","enabled","on","true","yes"]),n=s=>typeof s=="string"&&e.has(s.trim().toLowerCase()),o=s=>typeof s=="string"&&t.has(s.trim().toLowerCase());export{n as a,o as i};
@@ -257,10 +257,12 @@ interface InferredBindings {
257
257
  usesKv: boolean;
258
258
  /** `@lunora/mail` is imported (Resend API key must be set in `.dev.vars`; no binding). No `ctx.mail` helper exists, so only the import counts. */
259
259
  usesMail: boolean;
260
- /** `@lunora/notify` is imported or `ctx.notify` read (no binding; channel secrets ride `usesNotifyFcm` / `usesNotifyWebPush`). */
260
+ /** `@lunora/notify` is imported or `ctx.notify` read (no binding; channel secrets ride the `usesNotifyFcm*` / `usesNotifyWebPush` flags). */
261
261
  usesNotify: boolean;
262
- /** `lunora/notify.ts` configures the `fcm` channel → the `FCM_*` secrets in `.dev.vars`. */
262
+ /** `lunora/notify.ts` configures the `fcm` channel and leaves its token to `fcmFromEnv` → `FCM_SERVICE_ACCOUNT` in `.dev.vars`. */
263
263
  usesNotifyFcm: boolean;
264
+ /** The `fcm` channel passes its own `getAccessToken` but takes its project from env → `FCM_PROJECT_ID`. */
265
+ usesNotifyFcmTokenSource: boolean;
264
266
  /** `lunora/notify.ts` configures the `webPush` channel → the `VAPID_*` secrets in `.dev.vars`. */
265
267
  usesNotifyWebPush: boolean;
266
268
  /** `@lunora/payment/autumn` is imported → the Autumn secrets in `.dev.vars` (no binding). */
@@ -291,6 +293,16 @@ interface InferredBindings {
291
293
  usesX402: boolean;
292
294
  /** `@lunora/x402/charge` is imported — the charge rail settles USDC to a recipient address (a public `[vars]` entry, user-named; hint-only). */
293
295
  usesX402Charge: boolean;
296
+ /**
297
+ * Paths the Worker serves outside its reserved `/_lunora/*` plane, as written:
298
+ * each `httpRoute.<verb>(path)` route under `lunora/`, plus, when auth is
299
+ * imported, its base path (a literal `basePath` / `authBasePath` option, else
300
+ * `/api/auth`) and the two OAuth discovery prefixes under `/.well-known/`.
301
+ * Reconcile widens them into `assets.run_worker_first` rules. A computed
302
+ * `basePath` and routes added to a Hono `httpRouter` directly are not visible
303
+ * here. `undefined` when the files under `lunora/` could not be parsed.
304
+ */
305
+ workerRoutes: string[] | undefined;
294
306
  /** Workflows declared in `lunora/workflows.ts` (exported or not — see {@link InferredWorkflow.exported}). */
295
307
  workflows: InferredWorkflow[];
296
308
  }
@@ -323,4 +335,4 @@ declare const inferLunoraBindings: (options: InferOptions) => Promise<InferredBi
323
335
  * ({@link SECRET_SOURCE_FLAGS}), keeping only sources that carry secrets.
324
336
  */
325
337
  declare const secretSourcesFromBindings: (bindings: InferredBindings) => string[];
326
- export { COMPOSED_WORKER_ENTRY as C, DiscoveryCache as D, GeneratedClassModule as G, HYPERDRIVE_PLACEHOLDER_ID as H, InferredBindings as I, MERGED_DURABLE_OBJECTS_MODULE as M, SchemaInfo as S, D1_PLACEHOLDER_ID as a, DURABLE_OBJECT_BINDINGS as b, DiscoverSchemaInfoResult as c, GENERATED_CLASS_MODULES as d, GENERATED_MODULE_DURABLE_OBJECTS as e, InferOptions as f, InferredAgent as g, InferredContainer as h, InferredWorkflow as i, createDiscoveryCache as j, discoverSchemaInfo as k, inferLunoraBindings as l, isMergedProject as m, isMergedRoleModule as n, secretSourcesFromBindings as s };
338
+ export { COMPOSED_WORKER_ENTRY as C, DiscoveryCache as D, GENERATED_CLASS_MODULES as G, HYPERDRIVE_PLACEHOLDER_ID as H, InferOptions as I, MERGED_DURABLE_OBJECTS_MODULE as M, SchemaInfo as S, D1_PLACEHOLDER_ID as a, DURABLE_OBJECT_BINDINGS as b, DiscoverSchemaInfoResult as c, GENERATED_MODULE_DURABLE_OBJECTS as d, GeneratedClassModule as e, InferredAgent as f, InferredBindings as g, InferredContainer as h, InferredWorkflow as i, createDiscoveryCache as j, discoverSchemaInfo as k, inferLunoraBindings as l, isMergedProject as m, isMergedRoleModule as n, secretSourcesFromBindings as s };
@@ -257,10 +257,12 @@ interface InferredBindings {
257
257
  usesKv: boolean;
258
258
  /** `@lunora/mail` is imported (Resend API key must be set in `.dev.vars`; no binding). No `ctx.mail` helper exists, so only the import counts. */
259
259
  usesMail: boolean;
260
- /** `@lunora/notify` is imported or `ctx.notify` read (no binding; channel secrets ride `usesNotifyFcm` / `usesNotifyWebPush`). */
260
+ /** `@lunora/notify` is imported or `ctx.notify` read (no binding; channel secrets ride the `usesNotifyFcm*` / `usesNotifyWebPush` flags). */
261
261
  usesNotify: boolean;
262
- /** `lunora/notify.ts` configures the `fcm` channel → the `FCM_*` secrets in `.dev.vars`. */
262
+ /** `lunora/notify.ts` configures the `fcm` channel and leaves its token to `fcmFromEnv` → `FCM_SERVICE_ACCOUNT` in `.dev.vars`. */
263
263
  usesNotifyFcm: boolean;
264
+ /** The `fcm` channel passes its own `getAccessToken` but takes its project from env → `FCM_PROJECT_ID`. */
265
+ usesNotifyFcmTokenSource: boolean;
264
266
  /** `lunora/notify.ts` configures the `webPush` channel → the `VAPID_*` secrets in `.dev.vars`. */
265
267
  usesNotifyWebPush: boolean;
266
268
  /** `@lunora/payment/autumn` is imported → the Autumn secrets in `.dev.vars` (no binding). */
@@ -291,6 +293,16 @@ interface InferredBindings {
291
293
  usesX402: boolean;
292
294
  /** `@lunora/x402/charge` is imported — the charge rail settles USDC to a recipient address (a public `[vars]` entry, user-named; hint-only). */
293
295
  usesX402Charge: boolean;
296
+ /**
297
+ * Paths the Worker serves outside its reserved `/_lunora/*` plane, as written:
298
+ * each `httpRoute.<verb>(path)` route under `lunora/`, plus, when auth is
299
+ * imported, its base path (a literal `basePath` / `authBasePath` option, else
300
+ * `/api/auth`) and the two OAuth discovery prefixes under `/.well-known/`.
301
+ * Reconcile widens them into `assets.run_worker_first` rules. A computed
302
+ * `basePath` and routes added to a Hono `httpRouter` directly are not visible
303
+ * here. `undefined` when the files under `lunora/` could not be parsed.
304
+ */
305
+ workerRoutes: string[] | undefined;
294
306
  /** Workflows declared in `lunora/workflows.ts` (exported or not — see {@link InferredWorkflow.exported}). */
295
307
  workflows: InferredWorkflow[];
296
308
  }
@@ -323,4 +335,4 @@ declare const inferLunoraBindings: (options: InferOptions) => Promise<InferredBi
323
335
  * ({@link SECRET_SOURCE_FLAGS}), keeping only sources that carry secrets.
324
336
  */
325
337
  declare const secretSourcesFromBindings: (bindings: InferredBindings) => string[];
326
- export { COMPOSED_WORKER_ENTRY as C, DiscoveryCache as D, GeneratedClassModule as G, HYPERDRIVE_PLACEHOLDER_ID as H, InferredBindings as I, MERGED_DURABLE_OBJECTS_MODULE as M, SchemaInfo as S, D1_PLACEHOLDER_ID as a, DURABLE_OBJECT_BINDINGS as b, DiscoverSchemaInfoResult as c, GENERATED_CLASS_MODULES as d, GENERATED_MODULE_DURABLE_OBJECTS as e, InferOptions as f, InferredAgent as g, InferredContainer as h, InferredWorkflow as i, createDiscoveryCache as j, discoverSchemaInfo as k, inferLunoraBindings as l, isMergedProject as m, isMergedRoleModule as n, secretSourcesFromBindings as s };
338
+ export { COMPOSED_WORKER_ENTRY as C, DiscoveryCache as D, GENERATED_CLASS_MODULES as G, HYPERDRIVE_PLACEHOLDER_ID as H, InferOptions as I, MERGED_DURABLE_OBJECTS_MODULE as M, SchemaInfo as S, D1_PLACEHOLDER_ID as a, DURABLE_OBJECT_BINDINGS as b, DiscoverSchemaInfoResult as c, GENERATED_MODULE_DURABLE_OBJECTS as d, GeneratedClassModule as e, InferredAgent as f, InferredBindings as g, InferredContainer as h, InferredWorkflow as i, createDiscoveryCache as j, discoverSchemaInfo as k, inferLunoraBindings as l, isMergedProject as m, isMergedRoleModule as n, secretSourcesFromBindings as s };
@@ -0,0 +1 @@
1
+ import{statSync as k,readFileSync as B,existsSync as M,readdirSync as ue}from"node:fs";import{relative as pe,sep as me,isAbsolute as fe,join as E,dirname as F,resolve as ge}from"node:path";import{discoverFlags as he,FLAGS_FILENAME as Se,discoverQueues as Ee,CAPABILITY_PROBES as J,COMPANION_BINDING as z,ALL_NOTIFY_CHANNELS as xe,readBoundServiceBindings as ve,discoverHttpRoutes as ye,discoverNotifyChannels as Ne,NOTIFY_FILENAME as Te,createTargetScope as be,mayReadCapabilityContext as Ce,sourceCapabilitySignals as Ae,foldCapabilitySignals as V,capabilitiesUsedBy as Re}from"@lunora/codegen";import{init as Ie}from"es-module-lexer";import{ts as n,Node as m,Project as Z}from"ts-morph";import{discoverAgentInfo as Oe}from"./discoverAgentInfo-pqFMJBtJ.mjs";import{discoverContainerInfo as _e}from"./discoverContainerInfo-DzXr7Vm3.mjs";import{escapeRegExp as we}from"./DEV_VARS_EXAMPLE_FILE-CqLorAxT.mjs";import{d as D}from"./discover-info-DC2MrAIM.mjs";import{P as De}from"./package-secrets-registry-TouCAMQN.mjs";import{discoverSchemaInfo as Le}from"./discoverSchemaInfo-DRPnqgif.mjs";import{resolveWorkerEntry as Pe,composedEntryDurableObjects as $e,GENERATED_DIRECTORY as _,DURABLE_OBJECT_BINDINGS as Fe,detectExportedDurableObjects as je,detectClassExports as P,isMergedProject as ee}from"./COMPOSED_WORKER_ENTRY-BcFt6ts5.mjs";import{discoverWorkflowInfo as ke}from"./discoverWorkflowInfo-zW7Tt0Tn.mjs";const Be="/api/auth",Me="/.well-known/oauth-protected-resource",Ke="/.well-known/oauth-authorization-server",Ge=String.raw`\/\*[\s\S]*?\*\/`,Ue=String.raw`\/\/[^\n]*`,We=String.raw`"(?:[^"\\\n]|\\.)*"`,Ve=String.raw`'(?:[^'\\\n]|\\.)*'`,He=String.raw`\x60(?:[^\x60\\$]|\\.|\$(?!\{))*\x60`,Ye=new RegExp([Ge,Ue,We,Ve,He].join("|"),"gu"),qe=/[^\n]/gu,Xe=e=>e.replaceAll(qe," "),Qe=e=>e.replaceAll(Ye,t=>t.startsWith("//")||t.startsWith("/*")?Xe(t):t),Je=(e,t)=>{const{error:o,value:s}=D(e,t,Se,he);return o===void 0?{flags:s}:{error:o}},te=(e,t)=>{const o=pe(t,e);return o!==""&&o!==".."&&!o.startsWith(`..${me}`)&&!fe(o)},ze=(e,t)=>{const{error:o,value:s}=D(e,t,void 0,Ee);return o===void 0?{queues:s??[]}:{error:o,queues:[]}},b="@lunora/replica",h="EventLogDOClient",Ze=/\.[cm]?[jt]sx?$/u,H=[".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs"],Y=new Map,K=e=>{const{mtimeMs:t}=k(e),o=Y.get(e);if(o?.mtimeMs===t)return o.source;const s=n.createSourceFile(e,B(e,"utf8"),n.ScriptTarget.Latest);return Y.set(e,{mtimeMs:t,source:s}),s},q=new WeakMap,et=e=>{const t=q.get(e);if(t!==void 0&&t[0]?.wasForgotten()!==!0)return t;const o=e.getDescendantsOfKind(n.SyntaxKind.Identifier);return q.set(e,o),o},X=e=>n.sys.fileExists(e)?k(e).mtimeMs:-1,Q=new Map,tt=e=>{const t=n.findConfigFile(F(e),i=>n.sys.fileExists(i));if(t===void 0)return{};const o=Q.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,F(t)),a=new Map([t,...s.extendedSourceFiles??[]].map(i=>[i,X(i)]));return Q.set(t,{mtimes:a,options:r}),r},G=(e,t)=>{if(t===b)return;if(!t.startsWith("./")&&!t.startsWith("../")){const a={moduleResolution:n.ModuleResolutionKind.Bundler,...tt(e)},i=n.resolveModuleName(t,e,a,n.sys).resolvedModule;return i?.isExternalLibraryImport===!0?void 0:i?.resolvedFileName}const o=E(F(e),t.replace(Ze,"")),s=H.map(a=>`${o}${a}`),r=H.map(a=>E(o,`index${a}`));return[...s,...r].find(a=>M(a))},st=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},ot=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},w=e=>n.canHaveModifiers(e)&&(n.getModifiers(e)??[]).some(t=>t.kind===n.SyntaxKind.ExportKeyword),rt=e=>n.isVariableStatement(e)?w(e)?e.declarationList.declarations.flatMap(t=>n.isIdentifier(t.name)?[t.name.text]:[]):[]:(n.isClassDeclaration(e)||n.isFunctionDeclaration(e))&&w(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):[],nt=e=>new Set(e.statements.flatMap(t=>rt(t))),it=(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}}},at=(e,t,o)=>w(e)?e.declarationList.declarations.flatMap(s=>{if(!n.isIdentifier(s.name)||s.initializer===void 0)return[];const r=it(s.initializer,t,o);return r===void 0?[]:[{exported:s.name.text,module:r.module,name:r.name}]}):[],ct=(e,t)=>{const o=e.heritageClauses?.find(r=>r.token===n.SyntaxKind.ExtendsKeyword)?.types[0]?.expression;if(!w(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}]},dt=e=>{const t=st(e),o=ot(e);return e.statements.flatMap(s=>{if(n.isVariableStatement(s))return at(s,t,o);if(n.isClassDeclaration(s))return ct(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}]}):[]})},U=(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=dt(i),d=new Set([...r,...nt(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===b?t:void 0);if(g!==void 0&&d.has(g))return!1}const u=l.exported===void 0?o:l.name;if(l.module===b)return u===void 0||u===t;const y=G(e,l.module);return y!==void 0&&U(y,t,u,s,l.exported===void 0?d:r)})},j=(e,t)=>et(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()===h:m.isQualifiedName(s)?!m.isTypeReference(s.getParent())&&s.getRight().getText()===h:!0}),lt=e=>{const[t]=e.getArguments();return e.getExpression().getKind()===n.SyntaxKind.ImportKeyword&&t!==void 0&&(m.isStringLiteral(t)||m.isNoSubstitutionTemplateLiteral(t))&&t.getLiteralValue()===b},ut=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()},pt=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||ut(a)===h)}return m.isPropertyAccessExpression(s)&&s.getExpression()===t?s.getName()===h:!0},mt=(e,t)=>K(e).statements.some(o=>n.isExportDeclaration(o)&&o.moduleSpecifier!==void 0&&n.isStringLiteral(o.moduleSpecifier)&&o.moduleSpecifier.text===b&&o.exportClause!==void 0&&n.isNamespaceExport(o.exportClause)&&o.exportClause.name.text===t),ft=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()===h),a=s.filter(d=>j(e,(d.getAliasNode()??d.getNameNode()).getText())),i=o!==void 0&&j(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)&&U(c,h,h,new Set)||a.some(d=>mt(c,d.getNameNode().getText()))}),se=e=>{const t=e.getImportDeclarations().filter(o=>o.getModuleSpecifierValue()===b&&!o.isTypeOnly());return t.some(o=>o.getNamedImports().some(s=>!s.isTypeOnly()&&s.getNameNode().getText()===h))||t.some(o=>{const s=o.getNamespaceImport();return s!==void 0&&j(e,s.getText())})||e.getExportDeclarations().some(o=>o.getModuleSpecifierValue()===b&&!o.isTypeOnly()&&o.getNamedExports().some(s=>!s.isTypeOnly()&&s.getNameNode().getText()===h))||ft(e)||e.getDescendantsOfKind(n.SyntaxKind.CallExpression).some(o=>lt(o)&&pt(o))},gt=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},ht=new Set([".cjs",".cts",".js",".jsx",".mjs",".mts",".ts",".tsx"]),St=new Set([".git",".lunora-cache",".wrangler","dist",_,"node_modules"]),Et=["lunora","src"],xt=/\benv\s*\.\s*DB\b/,vt=/\benv\s*\.\s*AI\b/,oe=["ai","aiSearch","analytics","analyticsSql","artifacts","browser","hyperdrive","images","kv","mail","notify","payments","pipelines","r2sql","scheduler","storage","x402"],re=e=>`uses${e.charAt(0).toUpperCase()}${e.slice(1)}`,ne=[["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"]],ie=[...oe.map(e=>[re(e),J[e].moduleSpecifier]),...ne].toSorted(([e],[t])=>e.localeCompare(t)),yt=[["usesNotifyFcm","@lunora/notify:fcm"],["usesNotifyFcmTokenSource","@lunora/notify:fcmTokenSource"],["usesNotifyWebPush","@lunora/notify:webPush"],["hostsShardRegistry","@lunora/do:shardRegistry"],["hostsEventLog","@lunora/replica:eventLog"],["usesEventLogClient","@lunora/replica:eventLogClient"],["usesRequestSecretTool","@lunora/agent:requestSecretTool"]],Nt=["@lunora/agent","@lunora/agent/sandbox"],ae=new RegExp(String.raw`["'\x60](?:${[...ie.map(([,e])=>e),...Nt,b].map(e=>we(e)).join("|")})["'\x60]`,"u"),p=e=>{const{contextProperty:t,moduleSpecifier:o}=J[e];return t===void 0?`${o} is imported`:`${o} is imported or ctx.${t} is read`},Tt="STRIPE_SECRET_KEY + STRIPE_WEBHOOK_SECRET (Stripe) or POLAR_ACCESS_TOKEN + POLAR_WEBHOOK_SECRET (Polar)",bt=/\b(authBasePath|basePath):\s*(["'`])(\/[^"'`$\s]*)\2/gu,Ct=/["']@lunora\/auth(?:\/[^"']*)?["']/u,At=/[Bb]asePath/u,Rt=e=>{const t=new Set;for(const o of e){const s=B(o,"utf8");if(!At.test(s))continue;const r=Qe(s),a=Ct.test(r);for(const[,i,,c]of r.matchAll(bt)){const d=c?.endsWith("/")===!0?c.slice(0,-1):c??"";d!==""&&(i==="authBasePath"||a)&&t.add(d)}}return t.size===0?[Be]:[...t].toSorted((o,s)=>o.localeCompare(s))},It=(e,t,o,s)=>{const{error:r,value:a}=D(e,t,void 0,ye);if(r!==void 0)return;const i=o?[...Rt(s),Me,Ke].map(c=>`${c}/*`):[];return[...(a??[]).map(c=>c.path),...i]},Ot=/\bfrom\s+["']\.{1,2}\//u,ce=(e,t)=>{let o;try{o=ue(e,{withFileTypes:!0})}catch{return}for(const s of o){if(s.isDirectory()){St.has(s.name)||ce(E(e,s.name),t);continue}const r=s.name.lastIndexOf(".");r!==-1&&ht.has(s.name.slice(r))&&t.push(E(e,s.name))}},_t=(e,t,o)=>{const s=ve(e,t);return o?{...s,services:s.services.filter(r=>r.binding!==z)}:s},wt=(e,t,o)=>{const{info:s}=Le(e,t,o);return{jurisdiction:s?.jurisdiction,needsD1:s?.hasD1GlobalTable??!1}};let $;const Dt=e=>{const t=ge(e);return $?.root!==t&&($={project:new Z({compilerOptions:{allowJs:!0},skipAddingFilesFromTsConfig:!0}),root:t}),$.project},Lt=(e,t,o)=>{e.getSourceFile(t)?.getFullText()!==o&&e.createSourceFile(t,o,{overwrite:!0})},Pt=(e,t)=>{for(const o of e.getSourceFiles())t.has(o)||e.removeSourceFile(o)},$t=(e,t,o)=>{const s=E(e,o),r=Dt(e),a=[],i=new Set,c=[],d=[],l=be();let u=!1,y=!1;for(const f of t){const S=E(e,f);if(!M(S)||!k(S).isDirectory())continue;const O=[];ce(S,O);for(const A of O){i.add(A);const x=B(A,"utf8"),T=te(A,s);u||=vt.test(x),y||=xt.test(x),(ae.test(x)||x.includes(h)||T&&(Ce(x)||Ot.test(x)))&&(Lt(r,A,x),a.push({file:A,inLunora:T}))}}Pt(r,new Set(a.map(({file:f})=>r.getSourceFileOrThrow(f))));for(const{file:f,inLunora:S}of a)(S?c:d).push(Ae(r.getSourceFileOrThrow(f),l));const g=V(c),C=V([g,...d]),I=new Set([...C.valueImports,...C.dynamicImports]),N=Re({contextReads:g.contextReads,valueImports:I});return{...Object.fromEntries([...oe.map(f=>[re(f),N.has(f)]),...ne.map(([f,S])=>[f,I.has(S)])]),needsD1:y,usesEventLogClient:a.some(({file:f})=>se(r.getSourceFileOrThrow(f))),usesRequestSecretTool:g.requestSecretTool,usesAi:N.has("ai")||u,usesBrowser:N.has("browser")||g.sandboxTools.usesSandboxBrowser,usesWorkerLoader:g.sandboxTools.usesSandboxLoader,scannedFiles:i}},Ft=(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"\``)],jt=(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 — ${Tt}`],[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),kt=(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(...Ft(s,r,a),...jt(o,i,t)),c},Bt=(e,t)=>e.some(o=>o.binding==="SHARD_REGISTRY")||ee(t)&&M(E(t,"shardRegistry.ts")),Mt=(e,t,o)=>{const s=new Z({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((ae.test(d)||d.includes(h))&&se(s.createSourceFile(i,d,{overwrite:!0})))return!0;for(const l of gt(c)){const u=G(i,l);u!==void 0&&!t.has(u)&&!te(u,o)&&r.push(u)}}return!1},Kt=e=>!e.composed&&e.path!==void 0&&U(e.path,"EventLogDO",void 0,new Set),Gt=e=>({usesNotifyFcm:e?.fcm==="env",usesNotifyFcmTokenSource:e?.fcm==="ownToken",usesNotifyWebPush:e?.hasWebPush??!1}),ss=async e=>{await Ie;const t=e.schemaDir??"lunora",o=e.scanDirs??Et,s=()=>$t(e.projectRoot,o,t),{scannedFiles:r,...a}=e.cache===void 0?s():e.cache.memo(`capabilities:${e.projectRoot}:${t}:${o.join(",")}`,s),i=Pe(e.projectRoot);let c;i.composed?c=$e(E(e.projectRoot,t,_)).map(W=>({binding:Fe[W],className:W})):c=i.path===void 0?[]:je(i.path);const d=wt(e.projectRoot,t,e.cache),l={...d,needsD1:a.needsD1||d.needsD1},u=P(i,_e(e.projectRoot,t,e.cache).containers,"containers"),y=P(i,ke(e.projectRoot,t).workflows,"workflows"),g=P(i,Oe(e.projectRoot,t).agents,"agents"),C={...a,usesAi:a.usesAi||g.length>0},I=[...ze(e.projectRoot,t).queues],{flags:N}=Je(e.projectRoot,t),L=D(e.projectRoot,t,Te,Ne),f=N?.provider==="flagship"&&N.mode==="binding"?N.bindingName:void 0,S=E(e.projectRoot,t,_),O=Bt(c,S),A=Kt(i),x=!i.composed&&i.path!==void 0&&Mt(i.path,r,S),T=kt(c,l,C,u,y,g);!i.composed&&ee(E(e.projectRoot,t,_))&&!c.some(v=>v.className==="LunoraDO")&&T.push("hint: durableObjects.merge is set, but the worker entry exports no LunoraDO — export one built with mergeDurableObjects, or the classes stay separate"),f!==void 0&&T.push(`hint: lunora/flags.ts uses Flagship in binding mode; add a flagship binding ({ binding: "${f}", app_id }) — the app_id can't be auto-provisioned`);const R=_t(e.projectRoot,t,e.skipCompanion===!0),de=R.error===void 0?R.services:void 0;R.error!==void 0&&T.push(`hint: lunora.config \`services\` not reconciled — ${R.error}`),T.push(...R.services.map(v=>v.binding===z?`${v.binding} → ${v.worker} (studio.companion)`:`${v.binding} → ${v.worker} (lunora.config services.${v.name})`));const le=It(e.projectRoot,t,C.usesAuth,r);return{...C,usesEventLogClient:C.usesEventLogClient||x,agents:g,containers:u,durableObjects:c,flagshipBinding:f,...l.jurisdiction===void 0?{}:{jurisdiction:l.jurisdiction},needsD1:l.needsD1,queues:I,services:de,signals:T,usesFlags:N!==void 0,...Gt(L.error===void 0?L.value:xe),hostsEventLog:A,hostsShardRegistry:O,workerRoutes:le,workflows:y}},os=e=>[...ie,...yt].filter(([t,o])=>e[t]&&De[o]!==void 0).map(([,t])=>t);export{ss as inferLunoraBindings,os as secretSourcesFromBindings};
@@ -0,0 +1 @@
1
+ const e=t=>{if(t===null||typeof t!="object")return!1;const o=Object.getPrototypeOf(t);return o===null||o===Object.prototype};export{e as i};
@@ -1 +1 @@
1
- const r=e=>e.endsWith("S")?e.slice(0,-1):e,c=e=>e.replaceAll(/([a-z\d])([A-Z])/gu,"$1_$2").toUpperCase().split(/[_-]+/u).filter(s=>s.length>0),i=new Set(["CREDENTIAL","DSN","PASSPHRASE","PASSWD","PASSWORD","SECRET","TOKEN"]),p=["ACCESS_KEY","API_KEY","ENCRYPTION_KEY","PRIVATE_KEY","SIGNING_KEY"],u=new RegExp(`(?:${[...i,...p.map(e=>e.replaceAll("_",""))].join("|")})S?$`,"iu"),y=e=>c(e).some(s=>s==="PUBLIC"||s==="PUBLISHABLE"),E=e=>{if(y(e))return!1;const s=c(e);if(s.some(o=>i.has(r(o))))return!0;const t=r(s.join("_"));return p.some(o=>t===o||t.endsWith(`_${o}`))||u.test(e)},k=[{description:"Bearer token the local Lunora Studio uses to call the worker's admin endpoints (data browser, schema edits) in dev. Generate with: openssl rand -hex 32",docsUrl:"https://lunora.sh/docs/packages/studio",key:"LUNORA_ADMIN_TOKEN",placeholderValue:"replace-with-openssl-rand-hex-32"}],a="LUNORA_RELAY_SECRET",n="replace-with-openssl-rand-hex-32",m=new Set(["@lunora/do:shardRegistry","@lunora/replica:eventLog"]),_="@lunora/replica:eventLogClient",g=["BETTER_AUTH_SECRET","STORAGE_SIGNING_SECRET"],d={"@lunora/auth":[{description:"32-byte random secret used to sign sessions and tokens. Generate with: openssl rand -hex 32",docsUrl:"https://lunora.sh/docs/packages/auth#secrets",key:"AUTH_SECRET",placeholderValue:"replace-with-openssl-rand-hex-32"},{description:"Public base URL of your worker (used by better-auth for redirects and cookie domain). For local dev this is typically http://localhost:8787",docsUrl:"https://lunora.sh/docs/packages/auth#secrets",key:"AUTH_URL",placeholderValue:"http://localhost:8787"}],"@lunora/agent:requestSecretTool":[{description:"AES-256 key that seals secret values held for one agent step, base64 of 32 bytes. Generate with: openssl rand -base64 32. Rotate by moving the old value to LUNORA_SECRET_VALUE_KEY_PREVIOUS first.",docsUrl:"https://lunora.sh/docs/packages/agent#secret-values",key:"LUNORA_SECRET_VALUE_KEY",placeholderValue:"<your-base64-32-byte-key>"}],"@lunora/do:shardRegistry":[{description:"Signs every request to ShardRegistryDO, which refuses unsigned ones, and the shard-to-shard control channel. Set the same value on the worker and every Durable Object. Generate with: openssl rand -hex 32",docsUrl:"https://lunora.sh/docs/concepts/sharding#the-shard-registry",key:a,placeholderValue:n}],"@lunora/bindings/r2sql":[{description:"Cloudflare API token with R2 SQL read access, for `ctx.r2sql`. Create at https://dash.cloudflare.com/profile/api-tokens with the R2 SQL permission.",docsUrl:"https://lunora.sh/docs/packages/bindings#r2-sql",key:"R2_SQL_TOKEN",placeholderValue:"<your-r2-sql-api-token>"},{description:"Cloudflare account id the R2 SQL queries run against. Falls back to CLOUDFLARE_ACCOUNT_ID when unset.",docsUrl:"https://lunora.sh/docs/packages/bindings#r2-sql",key:"R2_SQL_ACCOUNT_ID",placeholderValue:"<your-cloudflare-account-id>"},{description:"Name of the R2 bucket holding the Iceberg tables `ctx.r2sql` queries.",docsUrl:"https://lunora.sh/docs/packages/bindings#r2-sql",key:"R2_SQL_BUCKET",placeholderValue:"<your-r2-sql-bucket>"}],"@lunora/mail":[{description:"Resend API key for sending transactional email via @lunora/mail. Obtain at https://resend.com/api-keys",docsUrl:"https://lunora.sh/docs/packages/mail#secrets",key:"RESEND_API_KEY",placeholderValue:"<your-resend-api-key>"}],"@lunora/replica:eventLog":[{description:"Signs every request to EventLogDO, which refuses unsigned ones, and the calls from the worker that reads or appends the log. Set the same value on the worker and every Durable Object. Generate with: openssl rand -hex 32",docsUrl:"https://lunora.sh/docs/packages/replica#eventlogdo",key:a,placeholderValue:n}],"@lunora/replica:eventLogClient":[{description:"The LUNORA_RELAY_SECRET of the worker that hosts EventLogDO. EventLogDOClient throws at construction without it, and the log refuses every request signed with another value.",docsUrl:"https://lunora.sh/docs/packages/replica#eventlogdo",key:a,placeholderValue:"<your-eventlogdo-host-relay-secret>"}],"@lunora/notify:fcm":[{description:"Google service-account key file for FCM HTTP v1, base64-encoded on one line for .dev.vars (.dev.vars cannot hold its JSON quotes); in production use: wrangler secret put FCM_SERVICE_ACCOUNT < key.json. fcmFromEnv mints access tokens from it and reads the project id from it. Download it from the Firebase console (Project settings → Service accounts).",docsUrl:"https://lunora.sh/docs/packages/notify#fcm",key:"FCM_SERVICE_ACCOUNT",placeholderValue:"<base64-of-your-service-account-key-json>"}],"@lunora/notify:webPush":[{description:"Public VAPID key (base64url) for Web Push. Generate a keypair once with: npx web-push generate-vapid-keys — the public key is also shipped to the browser to subscribe.",docsUrl:"https://lunora.sh/docs/packages/notify#web-push",key:"VAPID_PUBLIC_KEY",placeholderValue:"<your-vapid-public-key>"},{description:"Private VAPID key (base64url) for Web Push — the application-server signing key. Generate with: npx web-push generate-vapid-keys",docsUrl:"https://lunora.sh/docs/packages/notify#web-push",key:"VAPID_PRIVATE_KEY",placeholderValue:"<your-vapid-private-key>"},{description:"VAPID `sub` contact — a mailto: or https: URL identifying the application server (e.g. mailto:you@example.com).",docsUrl:"https://lunora.sh/docs/packages/notify#web-push",key:"VAPID_SUBJECT",placeholderValue:"mailto:you@example.com"}],"@lunora/payment/autumn":[{description:"Autumn secret key (am_sk_…) for the Autumn payment adapter. Obtain at https://app.useautumn.com/dev",docsUrl:"https://lunora.sh/docs/packages/payment#autumn",key:"AUTUMN_SECRET_KEY",placeholderValue:"<your-autumn-secret-key>"},{description:"Autumn webhook signing secret for verifying Standard Webhooks event payloads. Obtain from your Autumn dashboard webhook settings.",docsUrl:"https://lunora.sh/docs/packages/payment#autumn",key:"AUTUMN_WEBHOOK_SECRET",placeholderValue:"<your-autumn-webhook-secret>"}],"@lunora/payment/creem":[{description:"Creem API key for the Creem payment adapter. Obtain at https://www.creem.io/dashboard/developers",docsUrl:"https://lunora.sh/docs/packages/payment#creem",key:"CREEM_API_KEY",placeholderValue:"<your-creem-api-key>"},{description:"Creem webhook signing secret for verifying the creem-signature header. Obtain from your Creem dashboard webhook settings.",docsUrl:"https://lunora.sh/docs/packages/payment#creem",key:"CREEM_WEBHOOK_SECRET",placeholderValue:"<your-creem-webhook-secret>"}],"@lunora/payment/dodopayments":[{description:"Dodo Payments API key (bearer token) for the Dodo Payments adapter. Obtain at https://app.dodopayments.com/developer/api-keys",docsUrl:"https://lunora.sh/docs/packages/payment#dodo-payments",key:"DODO_PAYMENTS_API_KEY",placeholderValue:"<your-dodo-payments-api-key>"},{description:"Dodo Payments webhook signing secret (whsec_…) for verifying event payloads. Obtain at https://app.dodopayments.com/developer/webhooks",docsUrl:"https://lunora.sh/docs/packages/payment#dodo-payments",key:"DODO_PAYMENTS_WEBHOOK_KEY",placeholderValue:"<your-dodo-payments-webhook-secret>"}],"@lunora/payment/polar":[{description:"Polar access token for the Polar payment adapter. Obtain at https://polar.sh/settings/tokens",docsUrl:"https://lunora.sh/docs/packages/payment#polar",key:"POLAR_ACCESS_TOKEN",placeholderValue:"<your-polar-access-token>"},{description:"Polar webhook secret for verifying event payloads from Polar. Obtain at https://polar.sh/settings/webhooks",docsUrl:"https://lunora.sh/docs/packages/payment#polar",key:"POLAR_WEBHOOK_SECRET",placeholderValue:"<your-polar-webhook-secret>"}],"@lunora/payment/stripe":[{description:"Stripe secret key (sk_test_…). Required when using the Stripe adapter. Obtain at https://dashboard.stripe.com/apikeys",docsUrl:"https://lunora.sh/docs/packages/payment#stripe",key:"STRIPE_SECRET_KEY",placeholderValue:"<your-stripe-secret-key>"},{description:"Stripe webhook signing secret (whsec_…) for verifying event payloads. Obtain at https://dashboard.stripe.com/webhooks",docsUrl:"https://lunora.sh/docs/packages/payment#stripe",key:"STRIPE_WEBHOOK_SECRET",placeholderValue:"<your-stripe-webhook-secret>"}]},l=new Set([...g,...[...k,...Object.values(d).flat()].filter(e=>E(e.key)&&!e.placeholderValue.startsWith("<")&&e.key!==a).map(e=>e.key)]),S=e=>e.includes(_)&&!e.some(t=>m.has(t))?l:new Set([...l,a]),b=e=>{const s=[];for(const t of e)for(const o of d[t]??[])s.some(h=>h.key===o.key)||s.push(o);return s};export{k as C,l as M,d as P,a as S,E as a,n as b,y as i,S as m,b as s};
1
+ const r=e=>e.endsWith("S")?e.slice(0,-1):e,c=e=>e.replaceAll(/([a-z\d])([A-Z])/gu,"$1_$2").toUpperCase().split(/[_-]+/u).filter(s=>s.length>0),i=new Set(["CREDENTIAL","DSN","PASSPHRASE","PASSWD","PASSWORD","SECRET","TOKEN"]),p=["ACCESS_KEY","API_KEY","ENCRYPTION_KEY","PRIVATE_KEY","SIGNING_KEY"],u=new RegExp(`(?:${[...i,...p.map(e=>e.replaceAll("_",""))].join("|")})S?$`,"iu"),y=e=>c(e).some(s=>s==="PUBLIC"||s==="PUBLISHABLE"),E=e=>{if(y(e))return!1;const s=c(e);if(s.some(o=>i.has(r(o))))return!0;const t=r(s.join("_"));return p.some(o=>t===o||t.endsWith(`_${o}`))||u.test(e)},k=[{description:"Bearer token the local Lunora Studio uses to call the worker's admin endpoints (data browser, schema edits) in dev. Generate with: openssl rand -hex 32",docsUrl:"https://lunora.sh/docs/packages/studio",key:"LUNORA_ADMIN_TOKEN",placeholderValue:"replace-with-openssl-rand-hex-32"}],a="LUNORA_RELAY_SECRET",n="replace-with-openssl-rand-hex-32",m=new Set(["@lunora/do:shardRegistry","@lunora/replica:eventLog"]),_="@lunora/replica:eventLogClient",g=["BETTER_AUTH_SECRET","STORAGE_SIGNING_SECRET"],d={"@lunora/auth":[{description:"32-byte random secret used to sign sessions and tokens. Generate with: openssl rand -hex 32",docsUrl:"https://lunora.sh/docs/packages/auth#secrets",key:"AUTH_SECRET",placeholderValue:"replace-with-openssl-rand-hex-32"},{description:"Public base URL of your worker (used by better-auth for redirects and cookie domain). For local dev this is typically http://localhost:8787",docsUrl:"https://lunora.sh/docs/packages/auth#secrets",key:"AUTH_URL",placeholderValue:"http://localhost:8787"}],"@lunora/agent:requestSecretTool":[{description:"AES-256 key that seals secret values held for one agent step, base64 of 32 bytes. Generate with: openssl rand -base64 32. Rotate by moving the old value to LUNORA_SECRET_VALUE_KEY_PREVIOUS first.",docsUrl:"https://lunora.sh/docs/packages/agent#secret-values",key:"LUNORA_SECRET_VALUE_KEY",placeholderValue:"<your-base64-32-byte-key>"}],"@lunora/do:shardRegistry":[{description:"Signs every request to ShardRegistryDO, which refuses unsigned ones, and the shard-to-shard control channel. Set the same value on the worker and every Durable Object. Generate with: openssl rand -hex 32",docsUrl:"https://lunora.sh/docs/concepts/sharding#the-shard-registry",key:a,placeholderValue:n}],"@lunora/bindings/r2sql":[{description:"Cloudflare API token with R2 SQL read access, for `ctx.r2sql`. Create at https://dash.cloudflare.com/profile/api-tokens with the R2 SQL permission.",docsUrl:"https://lunora.sh/docs/packages/bindings#r2-sql",key:"R2_SQL_TOKEN",placeholderValue:"<your-r2-sql-api-token>"},{description:"Cloudflare account id the R2 SQL queries run against. Falls back to CLOUDFLARE_ACCOUNT_ID when unset.",docsUrl:"https://lunora.sh/docs/packages/bindings#r2-sql",key:"R2_SQL_ACCOUNT_ID",placeholderValue:"<your-cloudflare-account-id>"},{description:"Name of the R2 bucket holding the Iceberg tables `ctx.r2sql` queries.",docsUrl:"https://lunora.sh/docs/packages/bindings#r2-sql",key:"R2_SQL_BUCKET",placeholderValue:"<your-r2-sql-bucket>"}],"@lunora/mail":[{description:"Resend API key for sending transactional email via @lunora/mail. Obtain at https://resend.com/api-keys",docsUrl:"https://lunora.sh/docs/packages/mail#secrets",key:"RESEND_API_KEY",placeholderValue:"<your-resend-api-key>"}],"@lunora/replica:eventLog":[{description:"Signs every request to EventLogDO, which refuses unsigned ones, and the calls from the worker that reads or appends the log. Set the same value on the worker and every Durable Object. Generate with: openssl rand -hex 32",docsUrl:"https://lunora.sh/docs/packages/replica#eventlogdo",key:a,placeholderValue:n}],"@lunora/replica:eventLogClient":[{description:"The LUNORA_RELAY_SECRET of the worker that hosts EventLogDO. EventLogDOClient throws at construction without it, and the log refuses every request signed with another value.",docsUrl:"https://lunora.sh/docs/packages/replica#eventlogdo",key:a,placeholderValue:"<your-eventlogdo-host-relay-secret>"}],"@lunora/notify:fcm":[{description:"Google service-account key file for FCM HTTP v1, base64-encoded on one line for .dev.vars (.dev.vars cannot hold its JSON quotes); in production use: wrangler secret put FCM_SERVICE_ACCOUNT < key.json. fcmFromEnv mints access tokens from it and reads the project id from it. Download it from the Firebase console (Project settings → Service accounts).",docsUrl:"https://lunora.sh/docs/packages/notify#fcm",key:"FCM_SERVICE_ACCOUNT",placeholderValue:"<base64-of-your-service-account-key-json>"}],"@lunora/notify:fcmTokenSource":[{description:"Firebase project id for FCM HTTP v1. Your fcm channel supplies its own getAccessToken, so only the project id comes from env. Find it in the Firebase console (Project settings).",docsUrl:"https://lunora.sh/docs/packages/notify#fcm",key:"FCM_PROJECT_ID",placeholderValue:"<your-firebase-project-id>"}],"@lunora/notify:webPush":[{description:"Public VAPID key (base64url) for Web Push. Generate a keypair once with: npx web-push generate-vapid-keys — the public key is also shipped to the browser to subscribe.",docsUrl:"https://lunora.sh/docs/packages/notify#web-push",key:"VAPID_PUBLIC_KEY",placeholderValue:"<your-vapid-public-key>"},{description:"Private VAPID key (base64url) for Web Push — the application-server signing key. Generate with: npx web-push generate-vapid-keys",docsUrl:"https://lunora.sh/docs/packages/notify#web-push",key:"VAPID_PRIVATE_KEY",placeholderValue:"<your-vapid-private-key>"},{description:"VAPID `sub` contact — a mailto: or https: URL identifying the application server (e.g. mailto:you@example.com).",docsUrl:"https://lunora.sh/docs/packages/notify#web-push",key:"VAPID_SUBJECT",placeholderValue:"mailto:you@example.com"}],"@lunora/payment/autumn":[{description:"Autumn secret key (am_sk_…) for the Autumn payment adapter. Obtain at https://app.useautumn.com/dev",docsUrl:"https://lunora.sh/docs/packages/payment#autumn",key:"AUTUMN_SECRET_KEY",placeholderValue:"<your-autumn-secret-key>"},{description:"Autumn webhook signing secret for verifying Standard Webhooks event payloads. Obtain from your Autumn dashboard webhook settings.",docsUrl:"https://lunora.sh/docs/packages/payment#autumn",key:"AUTUMN_WEBHOOK_SECRET",placeholderValue:"<your-autumn-webhook-secret>"}],"@lunora/payment/creem":[{description:"Creem API key for the Creem payment adapter. Obtain at https://www.creem.io/dashboard/developers",docsUrl:"https://lunora.sh/docs/packages/payment#creem",key:"CREEM_API_KEY",placeholderValue:"<your-creem-api-key>"},{description:"Creem webhook signing secret for verifying the creem-signature header. Obtain from your Creem dashboard webhook settings.",docsUrl:"https://lunora.sh/docs/packages/payment#creem",key:"CREEM_WEBHOOK_SECRET",placeholderValue:"<your-creem-webhook-secret>"}],"@lunora/payment/dodopayments":[{description:"Dodo Payments API key (bearer token) for the Dodo Payments adapter. Obtain at https://app.dodopayments.com/developer/api-keys",docsUrl:"https://lunora.sh/docs/packages/payment#dodo-payments",key:"DODO_PAYMENTS_API_KEY",placeholderValue:"<your-dodo-payments-api-key>"},{description:"Dodo Payments webhook signing secret (whsec_…) for verifying event payloads. Obtain at https://app.dodopayments.com/developer/webhooks",docsUrl:"https://lunora.sh/docs/packages/payment#dodo-payments",key:"DODO_PAYMENTS_WEBHOOK_KEY",placeholderValue:"<your-dodo-payments-webhook-secret>"}],"@lunora/payment/polar":[{description:"Polar access token for the Polar payment adapter. Obtain at https://polar.sh/settings/tokens",docsUrl:"https://lunora.sh/docs/packages/payment#polar",key:"POLAR_ACCESS_TOKEN",placeholderValue:"<your-polar-access-token>"},{description:"Polar webhook secret for verifying event payloads from Polar. Obtain at https://polar.sh/settings/webhooks",docsUrl:"https://lunora.sh/docs/packages/payment#polar",key:"POLAR_WEBHOOK_SECRET",placeholderValue:"<your-polar-webhook-secret>"}],"@lunora/payment/stripe":[{description:"Stripe secret key (sk_test_…). Required when using the Stripe adapter. Obtain at https://dashboard.stripe.com/apikeys",docsUrl:"https://lunora.sh/docs/packages/payment#stripe",key:"STRIPE_SECRET_KEY",placeholderValue:"<your-stripe-secret-key>"},{description:"Stripe webhook signing secret (whsec_…) for verifying event payloads. Obtain at https://dashboard.stripe.com/webhooks",docsUrl:"https://lunora.sh/docs/packages/payment#stripe",key:"STRIPE_WEBHOOK_SECRET",placeholderValue:"<your-stripe-webhook-secret>"}]},l=new Set([...g,...[...k,...Object.values(d).flat()].filter(e=>E(e.key)&&!e.placeholderValue.startsWith("<")&&e.key!==a).map(e=>e.key)]),S=e=>e.includes(_)&&!e.some(t=>m.has(t))?l:new Set([...l,a]),b=e=>{const s=[];for(const t of e)for(const o of d[t]??[])s.some(h=>h.key===o.key)||s.push(o);return s};export{k as C,l as M,d as P,a as S,E as a,n as b,y as i,S as m,b as s};
@@ -0,0 +1 @@
1
+ import{CUSTOM_INSTANCE_TYPE_LIMITS as j,CUSTOM_INSTANCE_MIN_MEMORY_MIB_PER_VCPU as O}from"@lunora/container";import{i as f,a as d,s as I}from"./spa-assets-C591NPiX.mjs";import{i as w}from"./is-plain-object-CWxHeOY1.mjs";import{applyModify as F}from"./applyModify-DKP2l6S9.mjs";import{recordManifestKey as P}from"./readManifest-Cighz3WC.mjs";const A=[{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"]}],ye=[...new Set(A.map(({path:e})=>e[0]))],N=(e,s)=>{let t=e;for(const n of s)t=f(t)?t[n]:void 0;return t},ve=e=>{const s={};for(const{of:t,path:n}of A){const i=t(e);if(i===void 0)continue;const[a,o]=n;s[a]=o===void 0?i:{...s[a],[o]:i}}return s},$e=(e,s,t)=>{if(s.length===0)return;const n=e.vectorize??[],i=new Set(n.filter(Boolean).map(a=>a?.index_name));for(const a of s)i.has(a)||t.push(`schema declares vector index "${a}"; wrangler "vectorize" must include a binding with index_name "${a}"`)},B=new Set(["basic","dev","lite","standard","standard-1","standard-2","standard-3","standard-4"]),D={disk_mb:j.diskMb,memory_mib:j.memoryMib,vcpu:{...j.vcpu,hint:'use the named "lite" or "basic" instance type below 1 vCPU'}},K=(e,s,t)=>{const n=e.instance_type;if(n===void 0)return;if(typeof n=="string"){B.has(n)||t.push(`${s} has unknown instance_type "${n}" — expected lite, basic, standard-1..4, or a custom { vcpu, memory_mib, disk_mb } object`);return}for(const[o,{hint:r,max:c,min:m}]of Object.entries(D)){const u=n[o];if(u!==void 0&&(typeof u!="number"||Number.isNaN(u)||u<m||u>c)){const l=r!==void 0&&typeof u=="number"&&u<m?` — ${r}`:"";t.push(`${s} custom instance_type ${o} must be a number in ${String(m)}–${String(c)} (got ${String(u)})${l}`)}}const{memory_mib:i,vcpu:a}=n;typeof a=="number"&&typeof i=="number"&&i<a*O&&t.push(`${s} custom instance_type needs ≥ 3 GiB (${String(O)} MiB) memory per vCPU (got ${String(i)} MiB for ${String(a)} vCPU)`)},G=(e,s,t)=>{for(const n of["image","instance_type","max_instances"])e[n]!==void 0&&t.push(`${s} sets "${n}", which the durable_object scheduling policy does not take — the Durable Object picks image and size at start`);for(const[n,i]of Object.entries(e.images??{}))[i?.dockerfile,i?.image].filter(o=>typeof o=="string"&&o.length>0).length!==1&&t.push(`${s} images["${n}"] must set exactly one of "dockerfile" or "image"`)},H=(e,s,t)=>{const{boundClasses:n,classKinds:i,errors:a,warnings:o}=t;if(!e||typeof e!="object"||typeof e.class_name!="string"||e.class_name.length===0){a.push(`${s} 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&&a.push(`${s} ("${e.class_name}") has unknown scheduling_policy "${e.scheduling_policy}" — expected "default" or "durable_object"`),r?G(e,`${s} ("${e.class_name}")`,a):(typeof e.image!="string"||e.image.length===0)&&a.push(`${s} ("${e.class_name}") must have an "image" — a Dockerfile path or a registry reference`),n.has(e.class_name)||a.push(`${s} 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=i.get(e.class_name);c!=="sqlite"&&a.push(c==="classic"?`${s} class "${e.class_name}" is registered via "new_classes" but containers require SQLite-backed DOs — move it to "new_sqlite_classes"`:`${s} class "${e.class_name}" is missing from migrations — add a migration entry with "new_sqlite_classes": ["${e.class_name}"]`),K(e,`${s} ("${e.class_name}")`,a),e.max_instances===void 0&&!r&&o.push(`${s} ("${e.class_name}") declares no max_instances — set a cap so a traffic spike can't fan out unbounded container spend`)},h=e=>Array.isArray(e)?e.filter(s=>s!==null&&typeof s=="object"):[],M=e=>Array.isArray(e)?e.filter(s=>d(s)):[],L=e=>{const s=new Map;for(const t of h(e)){for(const n of M(t.new_classes))s.set(n,"classic");for(const n of M(t.new_sqlite_classes))s.set(n,"sqlite");for(const n of h(t.renamed_classes))if(d(n.from)&&d(n.to)){const i=s.get(n.from)??"sqlite";s.delete(n.from),s.set(n.to,i)}for(const n of M(t.deleted_classes))s.delete(n)}return s},Q=e=>new Set(L(e).keys()),we=(e,s)=>{const t=Q(e.migrations);for(const n of h(e.durable_objects?.bindings))n.script_name===void 0&&d(n.class_name)&&!t.has(n.class_name)&&s.push(`durable_objects.bindings declares class "${n.class_name}" but it is missing from migrations — add a migration entry with "new_sqlite_classes": ["${n.class_name}"] (or "new_classes" for a non-SQLite-backed class), or let the dev server auto-reconcile it on the next start`)},ke=(e,s,t)=>{if(e.containers===void 0)return;if(!Array.isArray(e.containers)){s.push("containers must be an array of { class_name, image, ... } entries");return}const n=e.containers;if(n.length===0)return;const i=new Set(h(e.durable_objects?.bindings).map(o=>o.class_name)),a=L(e.migrations);for(const[o,r]of n.entries())H(r,`containers[${String(o)}]`,{boundClasses:i,classKinds:a,errors:s,warnings:t});e.observability?.enabled!==!0&&t.push('containers are configured but observability is not enabled — container logs will not be captured (add { "observability": { "enabled": true } })')},$=e=>e,T=(e,s,t,n)=>{if(e!==void 0){if(!Array.isArray(e)){n.push(t.arrayMessage);return}for(const[i,a]of $(e).entries()){const o=`${s}[${String(i)}]`;if(!a||typeof a!="object"){n.push(t.objectMessage(o));continue}for(const r of t.fields)d(a[r.field])||n.push(r.message(o))}}},Se={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`},V=(e,s)=>e===void 0||s&&d(e)||Array.isArray(e)&&e.length>0&&e.every(n=>d(n))?void 0:"schedules must be a non-empty array of cron expression strings",Y=e=>{if(e!==void 0)return f(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"},z=e=>e===void 0?[]:f(e)?["success_retention","error_retention"].filter(s=>e[s]!==void 0&&!d(e[s])).map(s=>`default_retention.${s} must be a duration string (e.g. "7 days")`):["default_retention must be an object"],C=(e,s,t,n)=>{const i=[V(e.schedules,t),Y(e.limits),...z(e.default_retention)];for(const a of i)a!==void 0&&n.push(`${s}.${a}`)},J=(e,s)=>A.map(({path:t})=>t).filter(t=>{const n=N(e,t),i=N(s,t),a=typeof i=="string"&&t[0]==="schedules"?[i]:i;return n!==void 0&&i!==void 0&&JSON.stringify(n)!==JSON.stringify(a)}).map(t=>t.join(".")),X=(e,s,t,n)=>{const i=`exports["${e}"]`,a=String(s.name);for(const o of t){if(!f(o)||o.name!==s.name)continue;const r=`workflows entry "${String(o.binding)}"`;if(o.script_name!==void 0){n.push(`${r} binds workflow "${a}" in another Worker, but ${i} declares a workflow with that name here — workflow names are unique per account`);continue}o.class_name!==e&&n.push(`${r} and ${i} both declare workflow "${a}" but name different classes ("${String(o.class_name)}" vs "${e}")`);for(const c of J(o,s))n.push(`${r} and ${i} set ${c} to different values for workflow "${a}" — set it in one place`)}},je=(e,s)=>{const t=Array.isArray(e.workflows)?$(e.workflows):[];for(const[i,a]of t.entries())f(a)&&C(a,`workflows[${String(i)}]`,!1,s);const n=f(e.exports)?Object.entries(e.exports):[];for(const[i,a]of n)!f(a)||a.type!=="workflow"||(d(a.name)?(C(a,`exports["${i}"]`,!0,s),X(i,a,t,s)):s.push(`exports["${i}"] is a workflow export and must have a non-empty "name" naming the deployed workflow`))},Z={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`},ee={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`},Me=(e,s)=>{if(e.queues!==void 0){if(typeof e.queues!="object"||Array.isArray(e.queues)){s.push("queues must be a { producers, consumers } object");return}T(e.queues.producers,"queues.producers",Z,s),T(e.queues.consumers,"queues.consumers",ee,s)}},Ee={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:s=>`${s} must have a non-empty "${e}"`})),objectMessage:e=>`${e} must be a { binding, store_id, secret_name } object`},Re=[{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,s)=>`${e} ("${s}") 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,s)=>`${e} ("${s}") 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,s)=>`${e} ("${s}") 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,s)=>`${e} ("${s}") has no "dataset" — it defaults to the binding name; set it explicitly to avoid drift`,key:"analytics_engine_datasets"}],Ae=(e,s,t,n)=>{const i=e[s.key];if(i!==void 0){if(!Array.isArray(i)){t.push(s.arrayMessage);return}for(const[a,o]of $(i).entries()){const r=`${s.key}[${String(a)}]`;if(!o||typeof o!="object"||!d(o.binding)){t.push(s.bindingMessage(r));continue}if(!("hintField"in s))continue;(typeof s.hintField=="string"?[s.hintField]:s.hintField).some(m=>d(o[m]))||n.push(s.hintMessage(r,o.binding))}}},xe=[{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" })'}],We=(e,s,t)=>{const n=e[s.key];n!==void 0&&(typeof n!="object"||n===null||Array.isArray(n)||!d(n.binding))&&t.push(s.message)},Oe=[{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`}],Ie=(e,s,t)=>{s?.hasD1GlobalTable&&!h(e.d1_databases).some(n=>n.binding==="DB")&&t.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'),s?.hasHyperdriveGlobalTable&&h(e.hyperdrive).length===0&&t.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)')},Ne=(e,s)=>{const{d1_databases:t}=e;if(t!==void 0){if(!Array.isArray(t)){s.push("d1_databases must be an array of { binding, database_id | database_name } entries");return}for(const[n,i]of $(t).entries()){const a=`d1_databases[${String(n)}]`;if(!i||typeof i!="object"){s.push(`${a} must be a { binding, database_id | database_name } object`);continue}d(i.binding)||s.push(`${a} must have a non-empty "binding" naming the D1 binding`),!d(i.database_id)&&!d(i.database_name)&&s.push(`${a} must have a "database_id" or a "database_name" — run \`wrangler d1 create\` and set one, or the binding can't resolve`)}}},Te=(e,s)=>{const{vpc_networks:t}=e;if(t!==void 0){if(!Array.isArray(t)){s.push("vpc_networks must be an array of { binding, tunnel_id | network_id } entries");return}for(const[n,i]of $(t).entries()){const a=`vpc_networks[${String(n)}]`;if(!i||typeof i!="object"){s.push(`${a} must be a { binding, tunnel_id | network_id } object`);continue}d(i.binding)||s.push(`${a} must have a non-empty "binding" naming the VPC Network binding`),d(i.tunnel_id)===d(i.network_id)&&s.push(`${a} must set exactly one of "tunnel_id" (a Cloudflare Tunnel) or "network_id" ("cf1:network" for Cloudflare Mesh)`)}}},p=["/_lunora/*","/__lunora/*"],se=[p,["/_lunora/*"]],ne="/*",y=100,v=100,R="runWorkerFirst",te=/^[\w.~@%+-]+$/u,ie=e=>{const s=e.split("/").filter(r=>r!==""),t=s.map(r=>te.test(r));if(s.length===0||t[0]===!1)return;const n=s.map((r,c)=>t[c]?r:"*"),i=`/${n.join("/")}`,a=s.at(-1)??"";return a==="*"||t.at(-1)===!1&&a.endsWith("?")?[`/${n.slice(0,-1).join("/")}`,i]:[i]},_=(e,s)=>s!==e&&s.endsWith("*")&&e.startsWith(s.slice(0,-1)),q=e=>e.flatMap((s,t)=>{const n=e.find(i=>_(s,i));return[...s.length>v?[`assets.run_worker_first entry "${s}" is ${String(s.length)} characters; Cloudflare accepts at most ${String(v)}`]:[],...e.indexOf(s)===t?[]:[`assets.run_worker_first lists "${s}" twice`],...n===void 0?[]:[`assets.run_worker_first entry "${s}" is already covered by "${n}", which wrangler refuses`]]}),Ce=e=>{if(e.length===0)return["assets.run_worker_first is an empty list, which wrangler refuses; remove it, or name at least one path"];const s=[];e.length>y&&s.push(`assets.run_worker_first has ${String(e.length)} rules; Cloudflare accepts at most ${String(y)}, duplicates included`);const t=[],n=[];for(const i of e)typeof i=="string"&&i.startsWith("/")?t.push(i):typeof i=="string"&&i.startsWith("!/")?n.push(i):s.push(`assets.run_worker_first entry ${JSON.stringify(i)} must be a path rule starting with "/" (or "!/" to exempt a path)`);return t.length===0&&n.length>0&&s.push("assets.run_worker_first has only negative (!/…) rules; wrangler needs at least one path that runs the Worker first"),s.push(...q(t),...q(n)),s},ae=e=>e.split("/").every(s=>s==="")?`the route "${e}" is the site root; run_worker_first leaves it to the assets (index.html), so add "/" to run_worker_first yourself if the Worker should answer it`:`the route "${e}" starts with a parameter, so no run_worker_first rule names it without sending every path to the Worker; a matching file in the assets directory, or the not_found_handling fallback, answers instead`,oe=e=>{const s=[],t=new Set;for(const o of e){const r=ie(o);if(r===void 0){s.push(ae(o));continue}for(const c of r)c.length>v?s.push(`run_worker_first rule "${c}" is longer than Cloudflare's ${String(v)} characters and was left out`):t.add(c)}const n=[...p,...t],i=[...new Set(n)].filter(o=>!n.some(r=>_(o,r))&&!p.includes(o)).toSorted((o,r)=>o.localeCompare(r)),a=y-p.length;return i.length>a&&s.push(`the routes need ${String(i.length+p.length)} run_worker_first rules and Cloudflare accepts ${String(y)}; ${i.slice(a).join(", ")} were left out`),{rules:[...p,...i.slice(0,a)],warnings:s}},U=(e,s)=>e===s||_(e,s)||_(s,e),re=(e,s)=>{const t=new Map,n=[];if(e===!0)return{excluded:t,missing:n};const i=Array.isArray(e)?e.filter(r=>typeof r=="string"):[],a=i.filter(r=>r.startsWith("/")),o=i.filter(r=>r.startsWith("!/"));for(const r of s){if(!a.some(m=>m===r||_(r,m))){n.push(r);continue}const c=o.filter(m=>U(m.slice(1),r));c.length>0&&t.set(r,c)}return{excluded:t,missing:n}},ce=(e,s,t)=>{const{excluded:n,missing:i}=re(e,t),a=[];i.length>0&&a.push(`${s} does not send ${i.join(", ")} to the Worker first, so a matching file in the assets directory (or the SPA fallback) answers instead of Lunora — add ${i.map(o=>`"${o}"`).join(", ")} to it`);for(const[o,r]of n)a.push(`${s} sends ${o} to the Worker first, but ${r.map(c=>`"${c}"`).join(", ")} takes part of it back to the assets — remove ${r.length===1?"that rule":"those rules"} unless the Worker never serves the paths it names`);return a.length===0?void 0:a.join("; ")},E=(e,s)=>Array.isArray(e)&&e.length===s?.length&&e.every((t,n)=>t===s[n]),de=e=>{const s=e?.lunora?.[R];return w(s)?Object.fromEntries(Object.entries(s).filter(t=>Array.isArray(t[1])&&t[1].every(n=>typeof n=="string"))):{}},ue=(e,s)=>{const t=[...new Set(s)].filter(o=>o.length<v&&!e.some(r=>U(o,r))),n=t.filter(o=>!t.some(r=>_(o,r))).toSorted((o,r)=>o.localeCompare(r)).map(o=>`!${o}`),i=y-1,a=n.length>i?[`run_worker_first has room for ${String(i)} static exemptions; ${n.slice(i).join(", ")} run the Worker, which serves them from the assets binding`]:[];return{rules:[ne,...n.slice(0,i)],warnings:a}},me=e=>`${e} falls back to a single-page app but sets no "binding", so the Worker cannot serve the app shell or a static file; run_worker_first keeps naming only the routes Lunora can see, and a Worker path it misses (a route on a Hono httpRouter, a computed auth basePath) gets index.html. Add "binding": "ASSETS" to ${e}`,le=(e,s,t,n,i)=>e===void 0||E(e,i)||se.some(o=>E(e,o))?E(e,t)?{change:void 0,owned:!0,warning:void 0}:{change:e===void 0?"added":"updated",owned:!0,warning:void 0}:{change:void 0,owned:!1,warning:ce(e,s,n)},ge=e=>[{assets:e.assets,path:["assets"]},...Object.entries(e.env??{}).flatMap(([s,t])=>w(t)?[{assets:t.assets,path:["env",s,"assets"]}]:[])],qe=(e,s,t,n,i)=>{const a=ge(s),o=oe(t),r=ue(o.rules,i),c=de(n),m={},u={added:[],text:e,updated:[],warnings:[]};for(const{assets:l,path:x}of a.filter(g=>w(g.assets))){const g=x.join("."),k=l,W=I(k)!==void 0,S=W?r.rules:o.rules,b=le(k.run_worker_first,`${g}.run_worker_first`,S,o.rules,c[g]);b.owned&&(m[g]=S),b.owned&&!W&&k.not_found_handling==="single-page-application"&&u.warnings.push(me(g)),b.warning!==void 0&&u.warnings.push(b.warning),b.change!==void 0&&(u.text=F(u.text,[...x,"run_worker_first"],S),u[b.change].push(`${g}.run_worker_first`))}return a.some(l=>w(l.assets))&&u.warnings.unshift(...o.warnings,...a.some(l=>I(l.assets)!==void 0)?r.warnings:[]),{...u,record:{consequence:"the next route change leaves run_worker_first as it is",key:R,label:"run_worker_first rules",write:l=>{P(l,R,Object.keys(m).length===0?void 0:m)}}}};export{Re as H,Oe as R,xe as S,Se as W,Ie as a,Ne as b,$e as c,ke as d,T as e,Q as f,je as g,Me as h,Ae as i,We as j,Te as k,Ee as l,qe as m,ye as n,h as o,M as p,A as q,Ce as r,N as s,we as v,ve as w};
@@ -1 +1 @@
1
- import{inferLunoraBindings as g}from"./inferLunoraBindings-DeR_c0W0.mjs";import{LUNORA_TAG as r}from"./LUNORA_TAG-DQTGPqcJ.mjs";import{reconcileWranglerBindings as $}from"./collectExportGaps-vVbPzutT.mjs";import{reconcileWranglerCompatibilityDate as p}from"./reconcileWranglerCompatibilityDate-hocXEuRA.mjs";import{reconcileWranglerCrons as m,describePreservedCrons as w}from"./describePreservedCrons-Bt2rPPeY.mjs";const j=async(i,t,a)=>{try{const n=await g({cache:i.cache,projectRoot:i.projectRoot,schemaDir:i.schemaDir}),e=$(i.projectRoot,n,{target:i.target}),o=e.wranglerPath??"wrangler.jsonc";if(e.added.length>0&&t.info?.(`${r} inferred bindings → ${e.added.join(", ")} (written to ${o})`),e.updated.length>0&&t.info?.(`${r} updated bindings → ${e.updated.join(", ")} (written to ${o})`),e.devConfig!==void 0){const{added:c,path:d,updated:f}=e.devConfig;t.info?.(`${r} dev sidecar bindings → ${[...c,...f].join(", ")} (written to ${d})`)}for(const c of e.warnings)t.warn(`${r} ${c}`);e.exportGaps.length>0&&a?.(e.exportGaps)}catch(n){const e=n instanceof Error?n.message:String(n);t.warn(`${r} binding inference skipped: ${e}`)}},s=new Map,u=(i,t,a)=>{try{const n=m(i,t);n.changed&&a.info?.(`${r} synced ${t.length.toFixed(0)} cron trigger(s) into ${n.wranglerPath??"wrangler.jsonc"}`);for(const c of n.warnings)a.warn(`${r} ${c}`);const e=n.preserved.join("\0"),o=w(n.preserved);o!==void 0&&(n.changed||s.get(i)!==e)&&a.info?.(`${r} ${o}`),s.set(i,e)}catch(n){const e=n instanceof Error?n.message:String(n);a.warn(`${r} cron trigger sync skipped: ${e}`)}try{const n=p(i);n.changed&&a.info?.(`${r} bumped compatibility_date to ${n.date??"unknown"} (Workers Cache enabled) → ${n.wranglerPath??"wrangler.jsonc"}`)}catch(n){const e=n instanceof Error?n.message:String(n);a.warn(`${r} compatibility date sync skipped: ${e}`)}};export{j as reconcileBindingsSafely,u as reconcileWranglerExtras};
1
+ import{inferLunoraBindings as g}from"./inferLunoraBindings-D0QDcugr.mjs";import{LUNORA_TAG as r}from"./LUNORA_TAG-DQTGPqcJ.mjs";import{reconcileWranglerBindings as $}from"./collectExportGaps-CJPSXdEn.mjs";import{reconcileWranglerCompatibilityDate as p}from"./reconcileWranglerCompatibilityDate-hocXEuRA.mjs";import{reconcileWranglerCrons as m,describePreservedCrons as w}from"./describePreservedCrons-Bt2rPPeY.mjs";const j=async(i,t,a)=>{try{const n=await g({cache:i.cache,projectRoot:i.projectRoot,schemaDir:i.schemaDir}),e=$(i.projectRoot,n,{target:i.target}),o=e.wranglerPath??"wrangler.jsonc";if(e.added.length>0&&t.info?.(`${r} inferred bindings → ${e.added.join(", ")} (written to ${o})`),e.updated.length>0&&t.info?.(`${r} updated bindings → ${e.updated.join(", ")} (written to ${o})`),e.devConfig!==void 0){const{added:c,path:d,updated:f}=e.devConfig;t.info?.(`${r} dev sidecar bindings → ${[...c,...f].join(", ")} (written to ${d})`)}for(const c of e.warnings)t.warn(`${r} ${c}`);e.exportGaps.length>0&&a?.(e.exportGaps)}catch(n){const e=n instanceof Error?n.message:String(n);t.warn(`${r} binding inference skipped: ${e}`)}},s=new Map,u=(i,t,a)=>{try{const n=m(i,t);n.changed&&a.info?.(`${r} synced ${t.length.toFixed(0)} cron trigger(s) into ${n.wranglerPath??"wrangler.jsonc"}`);for(const c of n.warnings)a.warn(`${r} ${c}`);const e=n.preserved.join("\0"),o=w(n.preserved);o!==void 0&&(n.changed||s.get(i)!==e)&&a.info?.(`${r} ${o}`),s.set(i,e)}catch(n){const e=n instanceof Error?n.message:String(n);a.warn(`${r} cron trigger sync skipped: ${e}`)}try{const n=p(i);n.changed&&a.info?.(`${r} bumped compatibility_date to ${n.date??"unknown"} (Workers Cache enabled) → ${n.wranglerPath??"wrangler.jsonc"}`)}catch(n){const e=n instanceof Error?n.message:String(n);a.warn(`${r} compatibility date sync skipped: ${e}`)}};export{j as reconcileBindingsSafely,u as reconcileWranglerExtras};
@@ -1 +1 @@
1
- import{secretKindOf as s,redact as c}from"@lunora/codegen";import{i as a,a as f}from"./package-secrets-registry-B4MtZQYU.mjs";import{isPlaceholderValue as d}from"./buildPackageSecretsBlock-DkAJ9DmX.mjs";const u=8,h=(n,o)=>{if(n===void 0)return[];const r=[];for(const[i,e]of Object.entries(n)){if(typeof e!="string"||d(e)||a(i))continue;const t=s(e)??(f(i)&&e.length>=u?"secret_named_var":void 0);t!==void 0&&r.push({file:o,key:i,kind:t,preview:c(e)})}return r};export{h as scanWranglerVariablesForSecrets};
1
+ import{secretKindOf as s,redact as c}from"@lunora/codegen";import{i as a,a as f}from"./package-secrets-registry-TouCAMQN.mjs";import{isPlaceholderValue as d}from"./buildPackageSecretsBlock-B4Odg5OF.mjs";const u=8,h=(n,o)=>{if(n===void 0)return[];const r=[];for(const[i,e]of Object.entries(n)){if(typeof e!="string"||d(e)||a(i))continue;const t=s(e)??(f(i)&&e.length>=u?"secret_named_var":void 0);t!==void 0&&r.push({file:o,key:i,kind:t,preview:c(e)})}return r};export{h as scanWranglerVariablesForSecrets};
@@ -0,0 +1 @@
1
+ import{readdirSync as i}from"node:fs";import{i as n}from"./is-plain-object-CWxHeOY1.mjs";import{join as o}from"node:path";const _=t=>typeof t=="object"&&t!==null&&!Array.isArray(t),f=t=>typeof t=="string"&&t.length>0,r=["assets","static","_astro"],a=new Set(["_headers","_redirects","_routes.json"]),e=/^[\w.~@%+-]+$/u,g=t=>{if(!n(t)||t.not_found_handling!=="single-page-application")return;const{binding:s}=t;return typeof s=="string"&&s!==""?s:void 0},c=t=>{try{return i(o(t,"public"),{withFileTypes:!0}).filter(s=>e.test(s.name)&&!a.has(s.name)).map(s=>s.isDirectory()?`/${s.name}/*`:`/${s.name}`)}catch{return[]}},l=t=>[...r.map(s=>`/${s}/*`),...c(t)];export{f as a,l as b,_ as i,g as s};
@@ -0,0 +1 @@
1
+ import{i as _}from"./env-flag-u4B05gLp.mjs";import{i as u,a as h}from"./spa-assets-C591NPiX.mjs";import{r as A,o as O}from"./reconcile-assets-DXQsm--3.mjs";const p=(s,e,t,i)=>{s!==void 0&&typeof s!="boolean"&&t.push(`${e} must be a boolean${i===void 0?"":` (${i})`}`)},S=(s,e,t)=>{s!==void 0&&(typeof s!="number"||Number.isNaN(s)||s<0||s>1)&&t.push(`${e} must be a number in [0, 1] (the fraction of requests sampled)`)},D=(s,e,t)=>{const i=s.send_email;if(i===void 0)return;if(!Array.isArray(i)){e.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)&&t.push(`send_email[${String(o)}] has no non-empty "name" naming the send-email binding — set one before deploying`)},T=(s,e)=>{p(s.logpush,"logpush",e,'set "logpush": true to enable Cloudflare Logpush')},x=(s,e)=>{const t=s.secrets;if(t===void 0)return;const i=typeof t=="object"&&t!==null&&!Array.isArray(t)?t.required:void 0;(!Array.isArray(i)||i.some(n=>typeof n!="string"||n===""))&&e.push('secrets must be an object whose "required" is an array of secret names (e.g. { "required": ["API_KEY"] })')},b=3e5,U=(s,e)=>{const{limits:t}=s;if(t===void 0)return;if(typeof t!="object"||Array.isArray(t)){e.push('limits must be an object (e.g. { "cpu_ms": 30000 })');return}const i=t.cpu_ms;if(i!==void 0){if(typeof i!="number"||!Number.isFinite(i)||!Number.isInteger(i)||i<=0){e.push("limits.cpu_ms must be a positive integer number of milliseconds");return}i>b&&e.push(`limits.cpu_ms must be at most ${String(b)} (Cloudflare's per-invocation ceiling)`)}},m=new Set(["off","smart","targeted"]),B=(s,e)=>{const{placement:t}=s;if(t===void 0)return;if(typeof t!="object"||t===null||Array.isArray(t)){e.push('placement must be an object (e.g. { "mode": "smart" })');return}const{mode:i}=t;i!==void 0&&(typeof i!="string"||!m.has(i))&&e.push(`placement.mode must be one of ${[...m].map(n=>`"${n}"`).join(", ")}`)},c={kind:"boolean"},y={kind:"samplingRate"},g={destinations:{kind:"destinations"},enabled:c,head_sampling_rate:y,persist:c},L={...g,invocation_logs:{hint:'set "invocation_logs": true to keep per-invocation summaries',kind:"boolean"}},j={enabled:c,head_sampling_rate:y,issues:{kind:"level",level:{enabled:c}},logs:{kind:"level",level:L},redact_query_string:c,traces:{kind:"level",level:g}},$=(s,e,t,i)=>{switch(s.kind){case"boolean":{p(e,t,i,s.hint);break}case"destinations":{e!==void 0&&(!Array.isArray(e)||e.some(n=>!h(n)))&&i.push(`${t} must be an array of destination names configured in the Cloudflare dashboard`);break}case"samplingRate":{S(e,t,i);break}}},v=(s,e,t,i,n)=>{for(const[o,a]of Object.entries(s)){const r=Object.hasOwn(e,o)?e[o]:void 0,l=`${t}.${o}`;r===void 0?n.push(`${l} is not a documented wrangler key (expected one of ${Object.keys(e).join(", ")}) — a typo is silently ignored by wrangler`):r.kind!=="level"?$(r,a,l,i):u(a)?v(a,r.level,l,i,n):a!==void 0&&i.push(`${l} must be an object`)}},G=(s,e,t)=>{const{observability:i}=s;if(i!==void 0){if(!u(i)){e.push('observability must be an object (e.g. { "enabled": true, "head_sampling_rate": 1 })');return}v(i,j,"observability",e,t)}},W=(s,e)=>{const{cache:t}=s;if(t!==void 0){if(!u(t)){e.push('cache must be an object (e.g. { "enabled": true })');return}p(t.enabled,"cache.enabled",e)}},P=(s,e)=>{const{exports:t}=s;if(t!==void 0){if(typeof t!="object"||t===null||Array.isArray(t)){e.push("exports must be an object keyed by entrypoint name");return}for(const[i,n]of Object.entries(t)){if(typeof n!="object"||n===null){e.push(`exports["${i}"] must be an object`);continue}n.type!==void 0&&typeof n.type!="string"&&e.push(`exports["${i}"].type must be a string`),n.cache!==void 0&&(typeof n.cache!="object"||n.cache===null||Array.isArray(n.cache)?e.push(`exports["${i}"].cache must be an object`):n.cache.enabled!==void 0&&typeof n.cache.enabled!="boolean"&&e.push(`exports["${i}"].cache.enabled must be a boolean`))}}},E=["auto-trailing-slash","drop-trailing-slash","force-trailing-slash","none"],N=["404-page","none","single-page-application"],f=(s,e,t,i)=>{e!==void 0&&(typeof e!="string"||!t.includes(e))&&i.push(`assets.${s} must be one of ${t.map(n=>`"${n}"`).join(", ")} (got ${JSON.stringify(e)})`)},R=(s,e)=>{if(!(s===void 0||typeof s=="boolean")){if(!Array.isArray(s)){e.push('assets.run_worker_first must be a boolean or an array of path rules (e.g. ["/_lunora/*"])');return}e.push(...A(s))}},q=(s,e)=>{const{assets:t}=s;if(t!==void 0){if(typeof t!="object"||Array.isArray(t)){e.push('assets must be an object (e.g. { "directory": "./dist/client", "binding": "ASSETS" })');return}(typeof t.directory!="string"||t.directory.length===0)&&e.push('assets must declare a non-empty "directory" pointing at the built client output (e.g. "./dist/client")'),t.binding!==void 0&&(typeof t.binding!="string"||t.binding.length===0)&&e.push('assets.binding must be a non-empty string (e.g. "ASSETS")'),f("html_handling",t.html_handling,E,e),f("not_found_handling",t.not_found_handling,N,e),R(t.run_worker_first,e)}},F=(s,e)=>{const t=s.tail_consumers;if(t===void 0)return;if(!Array.isArray(t)){e.push("tail_consumers must be an array of { service, environment? } entries");return}const i=t;for(const[n,o]of i.entries())(!o||typeof o!="object"||typeof o.service!="string"||o.service.length===0)&&e.push(`tail_consumers[${String(n)}] must have a non-empty "service" naming the consumer Worker`)},M=(s,e)=>{const t=s.tail_consumers??[];return t.some(n=>!!n&&n?.service===e.service&&n?.environment===e.environment)?s:{...s,tail_consumers:[...t,e]}},V=(s,e)=>{const{vars:t}=s;if(!t||typeof t!="object")return;const i=t.LUNORA_ALLOWED_ORIGINS,n=t.LUNORA_CORS_ALLOW_CREDENTIALS,o=typeof i=="string"&&i.split(",").some(r=>r.trim()==="*"),a=_(n);o&&a&&e.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')},k=s=>O(s.durable_objects?.bindings).some(e=>e.class_name==="SchedulerDO"&&e.script_name===void 0),d="LUNORA_ORIGIN_URL",H=(s,e,t,i=k(s)?"durable_objects.bindings declares the SchedulerDO":void 0)=>{if(i===void 0||h(s.vars?.[d]))return;const n=e===void 0?"vars":`env.${e}.vars`,o=e===void 0?"":` --env ${e}`;t.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{q as validateAssets,W as validateCache,V as validateCorsVariables,P as validateExports,U as validateLimits,T as validateLogpush,G as validateObservability,B as validatePlacement,H as validateSchedulerOrigin,x as validateSecretsRequired,D as validateSendEmail,F as validateTailConsumers,M as withTailConsumer};
@@ -0,0 +1 @@
1
+ import{relative as u}from"node:path";import{s as d,i as t}from"./spa-assets-C591NPiX.mjs";import{findWranglerFile as l,readWranglerJsonc as g}from"./WRANGLER_FILES-UNW-xY5u.mjs";import{scanWranglerVariablesForSecrets as p}from"./scanWranglerVariablesForSecrets-CkonQUdG.mjs";const i=(a,s)=>{const r=a?.producers;return(Array.isArray(r)?r:[]).flatMap(e=>t(e)&&typeof e.binding=="string"&&typeof e.queue=="string"?[{binding:e.binding,queue:e.queue,...s===void 0?{}:{env:s}}]:[])},m=a=>{const s=l(a),r=s===void 0?void 0:g(s).parsed;if(s===void 0||r===void 0)return{wranglerQueueProducers:[],wranglerVariables:[]};const n=[...new Set([r.assets,...Object.values(r.env??{}).map(e=>e?.assets)].flatMap(e=>d(e)??[]))];return{...n.length===0?{}:{spaAssetsBindings:n},wranglerQueueProducers:[...i(r.queues),...Object.entries(r.env??{}).flatMap(([e,o])=>i(o?.queues,e))],wranglerVariables:p(t(r.vars)?r.vars:void 0,u(a,s))}};export{m as wranglerCodegenInputs};
@@ -1,3 +1,3 @@
1
- import{existsSync as s,statSync as a,writeFileSync as p,renameSync as d,rmSync as g}from"node:fs";import{join as m}from"node:path";import{runCodegen as f,CodegenDiagnosticError as j,refreshCodegenProject as u,createCodegenProject as y,findTsconfig as S,tsconfigFingerprint as C,projectConfigCandidatePaths as h}from"@lunora/codegen";import{wranglerCodegenInputs as l}from"./wranglerCodegenInputs-BG0xZlgU.mjs";import{isCodegenDisabled as w,CODEGEN_ENV as n}from"./BUILD_ROOT_ENV-Dg4MV3wY.mjs";import{recordStudioWrite as P,STUDIO_WRITE_TEMP_SUFFIX as $}from"./STUDIO_WRITE_TEMP_SUFFIX-BTTELz3K.mjs";const F=o=>({apiSpec:o.apiSpec,lazyFunctions:o.lazyFunctions,lunoraDirectory:o.schemaDirectory??"lunora",projectRoot:o.projectRoot,...l(o.projectRoot)});let r;const c=o=>{const t=a(o);return`${o}:${String(t.mtimeMs)}:${String(t.size)}`},E=o=>{const t=S(o);return[t===void 0?"":`${c(t)}
1
+ import{existsSync as s,statSync as a,writeFileSync as p,renameSync as d,rmSync as g}from"node:fs";import{join as m}from"node:path";import{runCodegen as f,CodegenDiagnosticError as j,refreshCodegenProject as u,createCodegenProject as y,findTsconfig as S,tsconfigFingerprint as C,projectConfigCandidatePaths as h}from"@lunora/codegen";import{wranglerCodegenInputs as l}from"./wranglerCodegenInputs-BPoRg-2G.mjs";import{isCodegenDisabled as w,CODEGEN_ENV as n}from"./BUILD_ROOT_ENV-Dg4MV3wY.mjs";import{recordStudioWrite as P,STUDIO_WRITE_TEMP_SUFFIX as $}from"./STUDIO_WRITE_TEMP_SUFFIX-BTTELz3K.mjs";const F=o=>({apiSpec:o.apiSpec,lazyFunctions:o.lazyFunctions,lunoraDirectory:o.schemaDirectory??"lunora",projectRoot:o.projectRoot,...l(o.projectRoot)});let r;const c=o=>{const t=a(o);return`${o}:${String(t.mtimeMs)}:${String(t.size)}`},E=o=>{const t=S(o);return[t===void 0?"":`${c(t)}
2
2
  ${C(t)}`,...h(o).filter(e=>s(e)).map(e=>c(e))].join(`
3
3
  `)},R=o=>{const t=E(o);return r?.lunoraDirectory===o&&r.key===t?(u(r.project,o),r.project):(r={key:t,lunoraDirectory:o,project:y(o)},r.project)},x=(o,t)=>{if(w(process.env[n]))return[`codegen is off (${n}=0 / \`lunora dev --no-codegen\`) — the source was written but \`_generated/\` was NOT regenerated`];try{const e=m(o.projectRoot,o.schemaDirectory??"lunora");f({...F(o),project:R(e)})}catch(e){if(r=void 0,e instanceof j)return[e.message];throw e}return P(t.path,t.text),[]},z=(o,t)=>{const e=`${o}${$}`;try{p(e,t,"utf8"),d(e,o)}catch(i){throw g(e,{force:!0}),i}};export{x as r,z as w};
@@ -0,0 +1 @@
1
+ import{m as r,w as a}from"./asset-headers-CGvrhfGW.mjs";export{r as mergeAssetHeaders,a as writeAssetHeaders};
@@ -1 +1 @@
1
- import{devVariablesStamp as t,parseDevVariable as r,resolveAdminToken as a}from"../packem_shared/devVariablesStamp-Cetr3qFz.mjs";import{ADVISOR_PROCEDURES_ENDPOINT as d,handleAdvisorProceduresRequest as n}from"../packem_shared/ADVISOR_PROCEDURES_ENDPOINT-BPnqzAgT.mjs";import{sendStudioAsset as u,sendStudioDocument as i}from"../packem_shared/sendStudioAsset-B81Pex91.mjs";import{assetContentType as l,isStandaloneModulePath as p,loadStudioAssets as D,readStandaloneAsset as T,resolveStandaloneDirectory as f,studioAssetsStamp as _}from"../packem_shared/assetContentType-CUb5bpbI.mjs";import{default as P}from"../packem_shared/createStudioDocumentCache-B3Sf1bIl.mjs";import{STUDIO_PATH as c,STUDIO_SCRIPT_PATH as I,STUDIO_STYLE_PATH as O,createStudioMiddleware as x,isNonLoopbackHost as R,requestPathname as h,studioMountPath as N}from"../packem_shared/STUDIO_PATH-DDlZcH-q.mjs";import{POLICY_SCAFFOLD_ENDPOINT as H,handlePolicyScaffoldRequest as L}from"../packem_shared/POLICY_SCAFFOLD_ENDPOINT-xEHecns4.mjs";import{default as U}from"../packem_shared/renderStudioHtml-CRDTNivi.mjs";import{SCHEMA_EDIT_ENDPOINT as F,handleSchemaEditRequest as M}from"../packem_shared/SCHEMA_EDIT_ENDPOINT-qrJCQf0v.mjs";import{SEED_ENDPOINT as b,handleSeedRequest as W}from"../packem_shared/SEED_ENDPOINT-C1fhrehH.mjs";import{serveJsonHandler as y}from"../packem_shared/serveJsonHandler-B8_GE6QC.mjs";import{STUDIO_WRITE_TEMP_SUFFIX as j,consumeStudioWrite as w}from"../packem_shared/STUDIO_WRITE_TEMP_SUFFIX-BTTELz3K.mjs";import{ALLOW_FORWARDED_ENV as X,headerValue as g,isLoopbackAddress as z,transportRejectionReason as B}from"../packem_shared/ALLOW_FORWARDED_ENV-BUndghJx.mjs";export{d as ADVISOR_PROCEDURES_ENDPOINT,X as ALLOW_FORWARDED_ENV,H as POLICY_SCAFFOLD_ENDPOINT,F as SCHEMA_EDIT_ENDPOINT,b as SEED_ENDPOINT,c as STUDIO_PATH,I as STUDIO_SCRIPT_PATH,O as STUDIO_STYLE_PATH,j as STUDIO_WRITE_TEMP_SUFFIX,l as assetContentType,w as consumeStudioWrite,P as createStudioDocumentCache,x as createStudioMiddleware,t as devVariablesStamp,n as handleAdvisorProceduresRequest,L as handlePolicyScaffoldRequest,M as handleSchemaEditRequest,W as handleSeedRequest,g as headerValue,z as isLoopbackAddress,R as isNonLoopbackHost,p as isStandaloneModulePath,D as loadStudioAssets,r as parseDevVariable,T as readStandaloneAsset,U as renderStudioHtml,h as requestPathname,a as resolveAdminToken,f as resolveStandaloneDirectory,u as sendStudioAsset,i as sendStudioDocument,y as serveJsonHandler,_ as studioAssetsStamp,N as studioMountPath,B as transportRejectionReason};
1
+ import{devVariablesStamp as t,parseDevVariable as r,resolveAdminToken as a}from"../packem_shared/devVariablesStamp-Cetr3qFz.mjs";import{ADVISOR_PROCEDURES_ENDPOINT as d,handleAdvisorProceduresRequest as n}from"../packem_shared/ADVISOR_PROCEDURES_ENDPOINT-BPnqzAgT.mjs";import{sendStudioAsset as u,sendStudioDocument as i}from"../packem_shared/sendStudioAsset-B81Pex91.mjs";import{assetContentType as l,isStandaloneModulePath as p,loadStudioAssets as D,readStandaloneAsset as T,resolveStandaloneDirectory as f,studioAssetsStamp as _}from"../packem_shared/assetContentType-CUb5bpbI.mjs";import{default as P}from"../packem_shared/createStudioDocumentCache-B3Sf1bIl.mjs";import{STUDIO_PATH as c,STUDIO_SCRIPT_PATH as I,STUDIO_STYLE_PATH as O,createStudioMiddleware as x,isNonLoopbackHost as R,requestPathname as h,studioMountPath as N}from"../packem_shared/STUDIO_PATH-BFXK7eku.mjs";import{POLICY_SCAFFOLD_ENDPOINT as H,handlePolicyScaffoldRequest as L}from"../packem_shared/POLICY_SCAFFOLD_ENDPOINT-CXr3lZGF.mjs";import{default as U}from"../packem_shared/renderStudioHtml-CRDTNivi.mjs";import{SCHEMA_EDIT_ENDPOINT as F,handleSchemaEditRequest as M}from"../packem_shared/SCHEMA_EDIT_ENDPOINT-CUN4q8oi.mjs";import{SEED_ENDPOINT as b,handleSeedRequest as W}from"../packem_shared/SEED_ENDPOINT-C1fhrehH.mjs";import{serveJsonHandler as y}from"../packem_shared/serveJsonHandler-B8_GE6QC.mjs";import{STUDIO_WRITE_TEMP_SUFFIX as j,consumeStudioWrite as w}from"../packem_shared/STUDIO_WRITE_TEMP_SUFFIX-BTTELz3K.mjs";import{ALLOW_FORWARDED_ENV as X,headerValue as g,isLoopbackAddress as z,transportRejectionReason as B}from"../packem_shared/ALLOW_FORWARDED_ENV-BUndghJx.mjs";export{d as ADVISOR_PROCEDURES_ENDPOINT,X as ALLOW_FORWARDED_ENV,H as POLICY_SCAFFOLD_ENDPOINT,F as SCHEMA_EDIT_ENDPOINT,b as SEED_ENDPOINT,c as STUDIO_PATH,I as STUDIO_SCRIPT_PATH,O as STUDIO_STYLE_PATH,j as STUDIO_WRITE_TEMP_SUFFIX,l as assetContentType,w as consumeStudioWrite,P as createStudioDocumentCache,x as createStudioMiddleware,t as devVariablesStamp,n as handleAdvisorProceduresRequest,L as handlePolicyScaffoldRequest,M as handleSchemaEditRequest,W as handleSeedRequest,g as headerValue,z as isLoopbackAddress,R as isNonLoopbackHost,p as isStandaloneModulePath,D as loadStudioAssets,r as parseDevVariable,T as readStandaloneAsset,U as renderStudioHtml,h as requestPathname,a as resolveAdminToken,f as resolveStandaloneDirectory,u as sendStudioAsset,i as sendStudioDocument,y as serveJsonHandler,_ as studioAssetsStamp,N as studioMountPath,B as transportRejectionReason};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunora/config",
3
- "version": "1.0.0-alpha.456",
3
+ "version": "1.0.0-alpha.458",
4
4
  "description": "Internal shared CLI + Vite config layer for Lunora: wrangler.jsonc validation, binding inference, and .dev.vars scaffolding",
5
5
  "keywords": [
6
6
  "bindings",
@@ -58,7 +58,7 @@
58
58
  "access": "public"
59
59
  },
60
60
  "dependencies": {
61
- "@lunora/codegen": "^1.0.0-alpha.399",
61
+ "@lunora/codegen": "^1.0.0-alpha.400",
62
62
  "@lunora/container": "1.0.0-alpha.108",
63
63
  "@lunora/errors": ">=1.0.0-alpha.51 <2.0.0-0",
64
64
  "@lunora/seed": "^1.0.0-alpha.282",
@@ -1 +0,0 @@
1
- import{MERGED_DURABLE_OBJECT as _}from"./COMPOSED_WORKER_ENTRY-BcFt6ts5.mjs";import{o as E,v as h,a as p,b as D,c as O,d as R,e as l,g as y,h as I,H as S,i as $,R as j,S as A,j as k,k as L,W as w,l as B}from"./validate-bindings-PVHSAU6M.mjs";import{validateTailConsumers as T,validateSendEmail as C,validateSecretsRequired as N,validateLogpush as U,validateLimits as G,validatePlacement as P,validateObservability as K,validateAssets as V,validateCache as W,validateExports as M,validateCorsVariables as x,validateSchedulerOrigin as F}from"./withTailConsumer-CF3pk_Ov.mjs";import{isCacheEnabled as H,WORKERS_CACHE_MIN_DATE as b}from"./WORKERS_CACHE_MIN_DATE-0k9ABJtF.mjs";import{mergeWranglerEnvironment as Y}from"./mergeWranglerEnvironment-D5ekKj5x.mjs";const q=i=>typeof i=="object"&&i!==null&&!Array.isArray(i),g=i=>Array.isArray(i)?i.flatMap((a,n)=>q(a)?[[n,a]]:[]):[],m=i=>typeof i.binding=="string"?i.binding:"",J=(i,a,n)=>{for(const[e,s]of g(i.kv_namespaces))typeof s.id=="string"&&s.id!==""||n.push(`kv_namespaces[${String(e)}] ("${m(s)}") is not created yet and the schema pins data to "${a}" — create it with \`wrangler kv namespace create <name> --jurisdiction=${a}\`; a namespace's jurisdiction cannot be changed afterwards`)},Q=(i,a,n)=>{for(const[e,s]of g(i.r2_buckets)){const o=s.jurisdiction;if(o===a)continue;const t=typeof o=="string"?`names the "${o}" jurisdiction`:"names no jurisdiction";n.push(`r2_buckets[${String(e)}] ("${m(s)}") ${t}, but the schema pins data to "${a}" — create the bucket with \`wrangler r2 bucket create <name> --jurisdiction=${a}\` and set "jurisdiction": "${a}" on the binding`)}},z=(i,a,n)=>{const e=a?.jurisdiction;e!==void 0&&(J(i,e,n),Q(i,e,n))},v="2026-04-07",le="web_socket_auto_reply_to_close",u="2026-10-01",f="durable_object_io_tasks_prevent_eviction",X="durable_object_io_tasks_do_not_prevent_eviction",Z=/^\d{4}-\d{2}-\d{2}$/,ee=(i,a,n)=>{i>=u||a.includes(f)||a.includes(X)||n.push(`compatibility_date "${i}" predates "${u}", so pending I/O (waitUntil, cross-Durable-Object RPC, service-binding calls, timers) does not keep a Durable Object alive once its last client disconnects — live-query refreshes and durable streams can be cut off mid-flight. Set compatibility_date >= "${u}" or add the "${f}" compatibility flag`)},te=(i,a,n)=>{const{error:e,merged:s,unverifiedKeys:o}=Y(i,a);return e!==void 0?{error:e,wrangler:s}:(o.length>0&&n.push(`env.${String(a)} overrides ${o.join(", ")}, which this validator doesn't have a verified inheritance rule for — validated against the TOP-LEVEL value only. Double-check ${o.length===1?"it":"them"} by hand for "${String(a)}".`),{wrangler:s})},ie=(i,a,n)=>{const e=[],s=[];if(!i||typeof i!="object")return e.push("wrangler config is not a valid object"),{errors:e,valid:!1,warnings:s};const{error:o,wrangler:t}=te(i,n,s);if(o!==void 0)return e.push(o),{errors:e,valid:!1,warnings:s};E(t.durable_objects?.bindings).find(r=>r.name==="SHARD"&&(r.class_name==="ShardDO"||r.class_name===_))||e.push(`durable_objects.bindings must include { "name": "SHARD", "class_name": "ShardDO" } (or "${_}" when the app merges its Durable Objects) — your dev server auto-reconciles this on startup, or add the binding manually`),h(t,e);const d=t.compatibility_date??"",c=Z.test(d);d&&!c?e.push(`compatibility_date must be in YYYY-MM-DD format (got "${d}")`):d<v&&e.push(`compatibility_date must be >= "${v}" (got "${d||"<missing>"}")`),H(t)&&c&&d<b&&e.push(`cache.enabled requires compatibility_date >= "${b}" (got "${d||"<missing>"}")`),c&&ee(d,t.compatibility_flags??[],s),p(t,a,e),z(t,a,s),D(t,e),O(t,a?.vectorIndexNames??[],e),T(t,e),R(t,e,s),l(t.workflows,"workflows",w,e),y(t,e),I(t,e),l(t.secrets_store_secrets,"secrets_store_secrets",B,e);for(const r of S)$(t,r,e,s);for(const r of j)l(t[r.key],r.key,r,e);for(const r of A)k(t,r,e);return L(t,e),C(t,e,s),N(t,e),U(t,e),G(t,e),P(t,e),K(t,e,s),V(t,e),W(t,e),M(t,e),x(t,e),F(t,n,s),{errors:e,valid:e.length===0,warnings:s}},ue=ie;export{v as REQUIRED_COMPATIBILITY_DATE,le as REQUIRED_FLAG,ue as validateWrangler,ie as validateWranglerConfig};
@@ -1 +0,0 @@
1
- import{existsSync as h}from"node:fs";import{dirname as y,join as p}from"node:path";import{discoverSchemaInfo as w}from"./discoverSchemaInfo-DRPnqgif.mjs";import{MERGED_DURABLE_OBJECT as i,GENERATED_DIRECTORY as E,MERGED_ROLE_DURABLE_OBJECTS as u,COMPOSED_ENTRY_DURABLE_OBJECTS as $,GENERATED_CLASS_MODULES as k,isFrameworkDurableObject as D}from"./COMPOSED_WORKER_ENTRY-BcFt6ts5.mjs";import{o as R,f as j}from"./validate-bindings-PVHSAU6M.mjs";import{validateSchedulerOrigin as x}from"./withTailConsumer-CF3pk_Ov.mjs";import{l as O,r as _,s as A}from"./worker-entry-checks-CHrum2AN.mjs";import{mergeWranglerEnvironment as S}from"./mergeWranglerEnvironment-D5ekKj5x.mjs";import{findWranglerFile as W,readWranglerJsonc as C}from"./WRANGLER_FILES-UNW-xY5u.mjs";import{validateWranglerConfig as T}from"./REQUIRED_COMPATIBILITY_DATE-C8qfwbaA.mjs";const v=r=>Array.isArray(r)?r:[],L=(r,t,o)=>Object.entries(r?.images??{}).flatMap(([s,n])=>{const e=n?.dockerfile;return typeof e!="string"||h(e.startsWith("/")?e:p(t,e))?[]:[`containers images["${s}"] dockerfile "${e}" does not exist (resolved relative to ${o}); create the Dockerfile`]}),I=(r,t,o)=>{const s=[];for(const n of v(r)){const e=n?.image;typeof e=="string"&&(e.startsWith("./")||e.startsWith("../")||e.startsWith("/")||e.includes("Dockerfile"))&&!h(e.startsWith("/")?e:p(t,e))&&s.push(`containers image "${e}" does not exist (resolved relative to ${o}); create the Dockerfile or point image at a registry reference`),s.push(...L(n,t,o))}return s},P=(r,t)=>{const o=r?.vectorIndexNames??[],s=[];if(o.length>0&&s.push({message:e=>`schema declares vector index(es) ${o.map(l=>`"${l}"`).join(", ")} but nothing chains .vectors(...) onto defineApp() (composed in: ${e}) — \`ctx.vectors\` is then a throwing stub and buildWorkerOptions rejects EVERY request, /_lunora/health included. Add \`.vectors((env) => ({ ${String(o[0])}: env.<BINDING> }))\` to the chain.`,method:"vectors"}),r?.hasD1GlobalTable&&s.push({message:e=>`schema declares .global() table(s) but nothing chains .global(...) onto defineApp() (composed in: ${e}) — the shard then has no global writer, so every read or write of a global table throws INTERNAL ("requires a globalDb writer"). Add \`.global({ d1: (env) => env.DB })\` to the chain.`,method:"global"}),r?.hasHyperdriveGlobalTable&&s.push({message:e=>`schema declares .global({ backend: "hyperdrive" }) table(s) but nothing chains .hyperdriveGlobal(...) onto defineApp() (composed in: ${e}) — the shard then has no global writer, so every read or write of those tables throws INTERNAL. Add \`.hyperdriveGlobal({ engine: "postgres", exec: (env) => buildPgExec(fromPostgresJs(async () => (await import("postgres")).default(env.HYPERDRIVE.connectionString, { fetch_types: false, max: 5 }))) })\` to the chain (\`buildPgExec\` from \`@lunora/hyperdrive/global\`, \`fromPostgresJs\` from \`@lunora/hyperdrive\`).`,method:"hyperdriveGlobal"}),s.length===0)return[];const n=A(t,new Set(s.map(e=>e.method)));return n===void 0?[]:s.filter(e=>!n.chained.has(e.method)).map(e=>e.message(n.site))},G="does not export it",B=(r,t)=>{if(t.exports?.has(i)===!0&&u.has(r))return`This app merges its Durable Objects (\`durableObjects.merge\` in lunora.config), so ${i} hosts ${r}: bind only \`SHARD\` to "${i}" and drop the SCHEDULER / SHARD_REGISTRY bindings. Do that only if this Worker has never been deployed — a deployed ${r} namespace keeps its data, which the merged class cannot reach; turn \`durableObjects.merge\` off to keep it.`;if(r===i)return`${i} is the merged class (\`durableObjects.merge\` in lunora.config), and merging cannot be undone once deployed: the shard data lives in ${i}. Turn \`durableObjects.merge\` back on. Only a Worker that has never been deployed may rebind SHARD to "ShardDO".`;if(t.kind!=="composed")return`Re-export it from the module that defines it (\`export { ${r} } from "./…";\`), or add it to the app builder's own export (\`export const { ${r} } = app;\`).`;const o=`it exports ${$.join(", ")}, SchedulerDO when its binding is declared, and every class codegen emits from your ${k.map(s=>`${s}.mjs`).join(" / ")} declarations`;return D(r)?`\`@lunora/vite\` generates that entry — ${o}, and ${r} is not among them. Class-A composition does not carry ${r}, so drop the binding; a project that needs it has to own its worker entry (add \`src/worker.ts\`, which \`lunora deploy\` bundles in place of \`main\`, and compose \`defineApp()\` there).`:`\`@lunora/vite\` generates that entry, so there is no file to add a re-export to: ${o}. Declare "${r}" in one of those and re-run \`lunora codegen\`, or drop the binding.`},M=(r,t)=>{const o=t.exports;if(o===void 0)return[];const s=[];for(const e of R(r.durable_objects?.bindings))typeof e.class_name=="string"&&e.class_name.length>0&&e.script_name===void 0&&s.push({className:e.class_name,label:"durable_objects.bindings"});for(const e of v(r.workflows))typeof e?.class_name=="string"&&e.class_name.length>0&&e.script_name===void 0&&s.push({className:e.class_name,label:"workflows"});for(const[e,l]of Object.entries(r.exports??{}))l?.type==="workflow"&&s.push({className:e,label:"workflows"});return s.filter(e=>!o.has(e.className)).map(e=>`${e.label} declares class "${e.className}" but the ${t.kind==="composed"?"composed class-A worker entry":"worker entry"} (${t.path}) ${G} — wrangler refuses to bundle a Worker whose ${e.label==="workflows"?"Workflow":"Durable Object"} classes are not exported. ${B(e.className,t)}`)},N=r=>[...j(r.migrations)].filter(t=>u.has(t)).map(t=>`migrations create class "${t}", which this app hosts in ${i} because it merges its Durable Objects (\`durableObjects.merge\`). Before the first deploy, replace "${t}" with "${i}" in new_sqlite_classes; a Worker already deployed with "${t}" keeps its data there and cannot merge — turn \`durableObjects.merge\` off.`),U=r=>r?.origin!=="absent"?[]:[`main is set but no readable file is there (looked in ${r.path}) — wrangler cannot resolve the worker entry, so a deploy will fail there. Point main at the entry that composes your app, or remove it to fall back to the conventional locations.`],Z=r=>{const t=r.schemaDir??"lunora",o=W(r.projectRoot);if(!o){const c=`wrangler.jsonc not found in ${r.projectRoot}; create one declaring at least the SHARD durable object binding.`;return{problems:[c],report:{errors:[c],valid:!1,warnings:[]},wranglerPath:void 0}}const{parsed:s}=C(o);if(s===void 0){const c=`failed to parse ${o} as JSONC.`;return{problems:[c],report:{errors:[c],valid:!1,warnings:[]},wranglerPath:o}}const{error:n,merged:e}=S(s,r.environment);if(n!==void 0)return{problems:[n],report:{errors:[n],valid:!1,warnings:[]},wranglerPath:o};const{error:l,info:f}=w(r.projectRoot,t,r.cache),a=T(s,f,r.environment);l!==void 0&&a.warnings.push(`schema parse failed in ${t}/schema.ts: ${l}`);const g=y(o),b=O(e.main,r.projectRoot,o),m=_(b,r.projectRoot,t);a.errors.push(...I(e.containers??[],g,o)),a.warnings.push(...U(b)),m!==void 0&&a.errors.push(...M(e,m)),m?.exports?.has(i)===!0&&(a.errors.push(...N(e)),h(p(r.projectRoot,t,E,"scheduler.ts"))&&x(e,r.environment,a.warnings,"the merged LunoraDO hosts the scheduler")),a.errors.push(...P(f,r.projectRoot));const d=e.assets?.directory;if(typeof d=="string"&&d.length>0){const c=d.startsWith("/")?d:p(g,d);h(c)||a.warnings.push(`assets.directory "${d}" does not exist yet — it is created by the client build; run the build before deploy`)}return a.valid=a.errors.length===0,{problems:a.errors,report:a,wranglerPath:o}};export{G as UNEXPORTED_CLASS_MARKER,Z as validateWranglerProject};