@lunora/config 1.0.0-alpha.143 → 1.0.0-alpha.145

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.
@@ -644,7 +644,9 @@ interface WranglerConfig {
644
644
  containers?: ReadonlyArray<WranglerContainerEntry | null | undefined>;
645
645
  d1_databases?: ReadonlyArray<{
646
646
  binding?: string;
647
- }>;
647
+ database_id?: string;
648
+ database_name?: string;
649
+ } | null | undefined>;
648
650
  dispatch_namespaces?: ReadonlyArray<{
649
651
  binding?: string;
650
652
  namespace?: string;
@@ -679,8 +681,13 @@ interface WranglerConfig {
679
681
  logpush?: boolean;
680
682
  main?: string;
681
683
  migrations?: ReadonlyArray<{
684
+ deleted_classes?: ReadonlyArray<string>;
682
685
  new_classes?: ReadonlyArray<string>;
683
686
  new_sqlite_classes?: ReadonlyArray<string>;
687
+ renamed_classes?: ReadonlyArray<{
688
+ from?: string;
689
+ to?: string;
690
+ } | null | undefined>;
684
691
  } | null | undefined>;
685
692
  mtls_certificates?: ReadonlyArray<{
686
693
  binding?: string;
@@ -708,7 +715,8 @@ interface WranglerConfig {
708
715
  };
709
716
  r2_buckets?: ReadonlyArray<{
710
717
  binding?: string;
711
- }>;
718
+ bucket_name?: string;
719
+ } | null | undefined>;
712
720
  secrets_store_secrets?: ReadonlyArray<{
713
721
  binding?: string;
714
722
  secret_name?: string;
@@ -644,7 +644,9 @@ interface WranglerConfig {
644
644
  containers?: ReadonlyArray<WranglerContainerEntry | null | undefined>;
645
645
  d1_databases?: ReadonlyArray<{
646
646
  binding?: string;
647
- }>;
647
+ database_id?: string;
648
+ database_name?: string;
649
+ } | null | undefined>;
648
650
  dispatch_namespaces?: ReadonlyArray<{
649
651
  binding?: string;
650
652
  namespace?: string;
@@ -679,8 +681,13 @@ interface WranglerConfig {
679
681
  logpush?: boolean;
680
682
  main?: string;
681
683
  migrations?: ReadonlyArray<{
684
+ deleted_classes?: ReadonlyArray<string>;
682
685
  new_classes?: ReadonlyArray<string>;
683
686
  new_sqlite_classes?: ReadonlyArray<string>;
687
+ renamed_classes?: ReadonlyArray<{
688
+ from?: string;
689
+ to?: string;
690
+ } | null | undefined>;
684
691
  } | null | undefined>;
685
692
  mtls_certificates?: ReadonlyArray<{
686
693
  binding?: string;
@@ -708,7 +715,8 @@ interface WranglerConfig {
708
715
  };
709
716
  r2_buckets?: ReadonlyArray<{
710
717
  binding?: string;
711
- }>;
718
+ bucket_name?: string;
719
+ } | null | undefined>;
712
720
  secrets_store_secrets?: ReadonlyArray<{
713
721
  binding?: string;
714
722
  secret_name?: string;
@@ -1 +1 @@
1
- import{BINDING_MANIFEST_VERSION as o,buildBindingManifest as a}from"../packem_shared/BINDING_MANIFEST_VERSION-Cd00jVOf.mjs";import{C as n}from"../packem_shared/cloudflare-driver-CvMyH1Ih.mjs";import{collectExportGaps as i,reconcileWranglerBindings as E}from"../packem_shared/collectExportGaps-B5eIg8p8.mjs";import{reconcileWranglerCompatibilityDate as c}from"../packem_shared/reconcileWranglerCompatibilityDate-7OO_xaKR.mjs";import{reconcileWranglerCrons as R}from"../packem_shared/reconcileWranglerCrons-COMb6ICf.mjs";import{REMOTE_ELIGIBLE_KEYS as f,injectRemoteFlags as p,isRemoteEnvEnabled as I,materializeRemoteWranglerConfig as W,planRemoteBindings as d,resolveRemoteEnabled as x}from"../packem_shared/REMOTE_ELIGIBLE_KEYS-DKlqkz1w.mjs";import{WORKERS_CACHE_MIN_DATE as C,isCacheEnabled as A}from"../packem_shared/WORKERS_CACHE_MIN_DATE-0k9ABJtF.mjs";import{WRANGLER_FILES as L,findWranglerFile as T,readWranglerJsonc as b}from"../packem_shared/WRANGLER_FILES-UNW-xY5u.mjs";import{collectWranglerSecretVariables as S,scanWranglerVariablesForSecrets as B}from"../packem_shared/collectWranglerSecretVariables-Df_H6ytT.mjs";import{wranglerToAlchemy as v}from"../packem_shared/wranglerToAlchemy-CX9nCwtu.mjs";import{REQUIRED_COMPATIBILITY_DATE as M,REQUIRED_FLAG as O,validateWrangler as V,validateWranglerConfig as h,validateWranglerProject as U,withTailConsumer as j}from"../packem_shared/REQUIRED_COMPATIBILITY_DATE-Cx6D676Z.mjs";export{o as BINDING_MANIFEST_VERSION,n as CLOUDFLARE_DRIVER,f as REMOTE_ELIGIBLE_KEYS,M as REQUIRED_COMPATIBILITY_DATE,O as REQUIRED_FLAG,C as WORKERS_CACHE_MIN_DATE,L as WRANGLER_FILES,a as buildBindingManifest,i as collectExportGaps,S as collectWranglerSecretVariables,T as findWranglerFile,p as injectRemoteFlags,A as isCacheEnabled,I as isRemoteEnvEnabled,W as materializeRemoteWranglerConfig,d as planRemoteBindings,b as readWranglerJsonc,E as reconcileWranglerBindings,c as reconcileWranglerCompatibilityDate,R as reconcileWranglerCrons,x as resolveRemoteEnabled,B as scanWranglerVariablesForSecrets,V as validateWrangler,h as validateWranglerConfig,U as validateWranglerProject,j as withTailConsumer,v as wranglerToAlchemy};
1
+ import{BINDING_MANIFEST_VERSION as o,buildBindingManifest as a}from"../packem_shared/BINDING_MANIFEST_VERSION-Cd00jVOf.mjs";import{C as n}from"../packem_shared/cloudflare-driver-CvMyH1Ih.mjs";import{collectExportGaps as i,reconcileWranglerBindings as E}from"../packem_shared/collectExportGaps-B5eIg8p8.mjs";import{reconcileWranglerCompatibilityDate as c}from"../packem_shared/reconcileWranglerCompatibilityDate-7OO_xaKR.mjs";import{reconcileWranglerCrons as R}from"../packem_shared/reconcileWranglerCrons-COMb6ICf.mjs";import{REMOTE_ELIGIBLE_KEYS as f,injectRemoteFlags as p,isRemoteEnvEnabled as I,materializeRemoteWranglerConfig as W,planRemoteBindings as d,resolveRemoteEnabled as x}from"../packem_shared/REMOTE_ELIGIBLE_KEYS-DKlqkz1w.mjs";import{WORKERS_CACHE_MIN_DATE as C,isCacheEnabled as A}from"../packem_shared/WORKERS_CACHE_MIN_DATE-0k9ABJtF.mjs";import{WRANGLER_FILES as L,findWranglerFile as T,readWranglerJsonc as b}from"../packem_shared/WRANGLER_FILES-UNW-xY5u.mjs";import{collectWranglerSecretVariables as S,scanWranglerVariablesForSecrets as B}from"../packem_shared/collectWranglerSecretVariables-Df_H6ytT.mjs";import{wranglerToAlchemy as v}from"../packem_shared/wranglerToAlchemy-CX9nCwtu.mjs";import{REQUIRED_COMPATIBILITY_DATE as M,REQUIRED_FLAG as O,validateWrangler as V,validateWranglerConfig as h,validateWranglerProject as U,withTailConsumer as j}from"../packem_shared/REQUIRED_COMPATIBILITY_DATE-l78q5ZIV.mjs";export{o as BINDING_MANIFEST_VERSION,n as CLOUDFLARE_DRIVER,f as REMOTE_ELIGIBLE_KEYS,M as REQUIRED_COMPATIBILITY_DATE,O as REQUIRED_FLAG,C as WORKERS_CACHE_MIN_DATE,L as WRANGLER_FILES,a as buildBindingManifest,i as collectExportGaps,S as collectWranglerSecretVariables,T as findWranglerFile,p as injectRemoteFlags,A as isCacheEnabled,I as isRemoteEnvEnabled,W as materializeRemoteWranglerConfig,d as planRemoteBindings,b as readWranglerJsonc,E as reconcileWranglerBindings,c as reconcileWranglerCompatibilityDate,R as reconcileWranglerCrons,x as resolveRemoteEnabled,B as scanWranglerVariablesForSecrets,V as validateWrangler,h as validateWranglerConfig,U as validateWranglerProject,j as withTailConsumer,v as wranglerToAlchemy};
@@ -0,0 +1 @@
1
+ import{existsSync as f,readFileSync as M}from"node:fs";import{dirname as A,join as p}from"node:path";import{WORKER_ENTRY_FALLBACKS as O}from"./inferLunoraBindings-CEE39hXz.mjs";import{discoverSchemaInfo as D}from"./discoverSchemaInfo-Bg2CUZXG.mjs";import{isCacheEnabled as x,WORKERS_CACHE_MIN_DATE as _}from"./WORKERS_CACHE_MIN_DATE-0k9ABJtF.mjs";import{findWranglerFile as N,readWranglerJsonc as I}from"./WRANGLER_FILES-UNW-xY5u.mjs";const v="2026-04-07",Ie="web_socket_auto_reply_to_close",$=/^\d{4}-\d{2}-\d{2}$/,E=["d1_databases","durable_objects","kv_namespaces","queues","r2_buckets","secrets_store_secrets","services","tail_consumers","vars","vectorize","workflows"],S=["assets","compatibility_date","exports","logpush","main","migrations","observability","placement"],R=(e,s)=>{if(s===void 0)return{merged:e,unverifiedKeys:[]};const t=e.env?.[s];if(t===void 0){const c=Object.keys(e.env??{}).toSorted((r,l)=>r.localeCompare(l)),d=c.length>0?` (declared: ${c.join(", ")}).`:" (no environments are declared).";return{error:`--env "${s}" names no environment declared in wrangler.jsonc's "env" block${d}`,merged:e,unverifiedKeys:[]}}const n={...e},a=Object.keys(t).filter(c=>c!=="env");for(const c of a)S.includes(c)&&(n[c]=t[c]);for(const c of E)n[c]=t[c];const i=new Set([...E,...S]),o=a.filter(c=>!i.has(c)).map(String);return{merged:n,unverifiedKeys:o}},C=(e,s,t)=>{if(s.length===0)return;const n=e.vectorize??[],a=new Set(n.filter(Boolean).map(i=>i?.index_name));for(const i of s)a.has(i)||t.push(`schema declares vector index "${i}"; wrangler "vectorize" must include a binding with index_name "${i}"`)},L=new Set(["basic","dev","lite","standard","standard-1","standard-2","standard-3","standard-4"]),T={disk_mb:2e4,memory_mib:12288,vcpu:4},B=(e,s,t)=>{const n=e.instance_type;if(n===void 0)return;if(typeof n=="string"){L.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[c,d]of Object.entries(T)){const r=n[c];r!==void 0&&(typeof r!="number"||r<=0||r>d)&&t.push(`${s} custom instance_type ${c} must be a positive number ≤ ${String(d)} (got ${String(r)})`)}const{disk_mb:a,memory_mib:i,vcpu:o}=n;if(typeof o=="number"&&typeof i=="number"&&i<o*3072&&t.push(`${s} custom instance_type needs ≥ 3 GiB (3072 MiB) memory per vCPU (got ${String(i)} MiB for ${String(o)} vCPU)`),typeof i=="number"&&typeof a=="number"){const c=Math.floor(i/1024*2e3);a>c&&t.push(`${s} custom instance_type allows ≤ 2 GB disk per GiB memory (≤ ${String(c)} MB for ${String(i)} MiB memory; got ${String(a)} MB)`)}},W=(e,s,t)=>{const{boundClasses:n,errors:a,nonSqliteClasses:i,sqliteClasses:o,warnings:c}=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}(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 — run \`lunora dev\` to auto-reconcile wrangler.jsonc, or add { "name": "...", "class_name": "${e.class_name}" }`),o.has(e.class_name)||a.push(i.has(e.class_name)?`${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}"]`),B(e,`${s} ("${e.class_name}")`,a),e.max_instances===void 0&&c.push(`${s} ("${e.class_name}") declares no max_instances — set a cap so a traffic spike can't fan out unbounded container spend`)},m=e=>typeof e=="string"&&e.length>0,b=e=>Array.isArray(e)?e.filter(s=>s!==null&&typeof s=="object"):[],h=e=>Array.isArray(e)?e.filter(s=>m(s)):[],q=e=>{const s=new Set;for(const t of b(e)){for(const n of h(t.new_classes))s.add(n);for(const n of h(t.new_sqlite_classes))s.add(n);for(const n of b(t.renamed_classes))m(n.from)&&m(n.to)&&(s.delete(n.from),s.add(n.to));for(const n of h(t.deleted_classes))s.delete(n)}return s},U=(e,s)=>{const t=q(e.migrations);for(const n of b(e.durable_objects?.bindings))n.script_name===void 0&&m(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 run \`lunora dev\` to auto-reconcile wrangler.jsonc`)},F=(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 a=new Set(b(e.durable_objects?.bindings).map(d=>d.class_name)),i=e.migrations??[],o=new Set(i.flatMap(d=>[...d?.new_sqlite_classes??[]])),c=new Set(i.flatMap(d=>[...d?.new_classes??[]]));for(const[d,r]of n.entries())W(r,`containers[${String(d)}]`,{boundClasses:a,errors:s,nonSqliteClasses:c,sqliteClasses:o,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 } })')},y=e=>e,g=(e,s,t,n)=>{if(e!==void 0){if(!Array.isArray(e)){n.push(t.arrayMessage);return}for(const[a,i]of y(e).entries()){const o=`${s}[${String(a)}]`;if(!i||typeof i!="object"){n.push(t.objectMessage(o));continue}for(const c of t.fields)m(i[c.field])||n.push(c.message(o))}}},P={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. WORKFLOW_ORDER_PIPELINE)`},{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`},K={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`},G={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`},Y=(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}g(e.queues.producers,"queues.producers",K,s),g(e.queues.consumers,"queues.consumers",G,s)}},H={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`},Q=[{arrayMessage:"kv_namespaces must be an array of { binding, id } entries",bindingMessage:e=>`${e} must have a non-empty "binding" naming the KV namespace binding`,hintField:"id",hintMessage:(e,s)=>`${e} ("${s}") has no "id" — run \`wrangler kv namespace create\` and set the namespace id, or the binding can't resolve`,key:"kv_namespaces"},{arrayMessage:"flagship must be an array of { binding, app_id } entries",bindingMessage:e=>`${e} must have a non-empty "binding" naming the Flagship binding`,hintField:"app_id",hintMessage:(e,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"}],V=(e,s,t,n)=>{const a=e[s.key];if(a!==void 0){if(!Array.isArray(a)){t.push(s.arrayMessage);return}for(const[i,o]of y(a).entries()){const c=`${s.key}[${String(i)}]`;if(!o||typeof o!="object"||!m(o.binding)){t.push(s.bindingMessage(c));continue}(typeof s.hintField=="string"?[s.hintField]:s.hintField).some(r=>m(o[r]))||n.push(s.hintMessage(c,o.binding))}}},z=[{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" })'}],X=(e,s,t)=>{const n=e[s.key];n!==void 0&&(typeof n!="object"||Array.isArray(n)||!m(n.binding))&&t.push(s.message)},J=[{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`}],Z=(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,a]of y(t).entries()){const i=`d1_databases[${String(n)}]`;if(!a||typeof a!="object"){s.push(`${i} must be a { binding, database_id | database_name } object`);continue}m(a.binding)||s.push(`${i} must have a non-empty "binding" naming the D1 binding`),!m(a.database_id)&&!m(a.database_name)&&s.push(`${i} must have a "database_id" or a "database_name" — run \`wrangler d1 create\` and set one, or the binding can't resolve`)}}},ee=(e,s,t)=>{const n=e.send_email;if(n===void 0)return;if(!Array.isArray(n)){s.push("send_email must be an array of { name, destination_address? } entries");return}const a=n;for(const[i,o]of a.entries())(!o||typeof o!="object"||typeof o.name!="string"||o.name.length===0)&&t.push(`send_email[${String(i)}] has no non-empty "name" naming the send-email binding — set one before deploying`)},se=(e,s)=>{e.logpush!==void 0&&typeof e.logpush!="boolean"&&s.push('logpush must be a boolean (set "logpush": true to enable Cloudflare Logpush)')},ne=(e,s)=>{const{placement:t}=e;if(t!==void 0){if(typeof t!="object"||Array.isArray(t)){s.push('placement must be an object (e.g. { "mode": "smart" })');return}t.mode!==void 0&&t.mode!=="smart"&&s.push('placement.mode must be "smart" (the only supported Smart Placement mode)')}},te=(e,s)=>{const{observability:t}=e;if(t===void 0)return;if(typeof t!="object"||Array.isArray(t)){s.push('observability must be an object (e.g. { "enabled": true, "head_sampling_rate": 1 })');return}const n=(a,i)=>{a!==void 0&&(typeof a!="number"||Number.isNaN(a)||a<0||a>1)&&s.push(`${i} must be a number in [0, 1] (the fraction of requests sampled)`)};n(t.head_sampling_rate,"observability.head_sampling_rate"),t.logs!==void 0&&(typeof t.logs!="object"||Array.isArray(t.logs)?s.push("observability.logs must be an object"):n(t.logs.head_sampling_rate,"observability.logs.head_sampling_rate"))},ae=(e,s)=>{const{cache:t}=e;if(t!==void 0){if(typeof t!="object"||t===null||Array.isArray(t)){s.push('cache must be an object (e.g. { "enabled": true })');return}t.enabled!==void 0&&typeof t.enabled!="boolean"&&s.push("cache.enabled must be a boolean (true or false)")}},ie=(e,s)=>{const{exports:t}=e;if(t!==void 0){if(typeof t!="object"||t===null||Array.isArray(t)){s.push("exports must be an object keyed by entrypoint name");return}for(const[n,a]of Object.entries(t)){if(typeof a!="object"||a===null){s.push(`exports["${n}"] must be an object`);continue}a.type!==void 0&&typeof a.type!="string"&&s.push(`exports["${n}"].type must be a string`),a.cache!==void 0&&(typeof a.cache!="object"||a.cache===null||Array.isArray(a.cache)?s.push(`exports["${n}"].cache must be an object`):a.cache.enabled!==void 0&&typeof a.cache.enabled!="boolean"&&s.push(`exports["${n}"].cache.enabled must be a boolean`))}}},oe=(e,s)=>{const{assets:t}=e;if(t!==void 0){if(typeof t!="object"||Array.isArray(t)){s.push('assets must be an object (e.g. { "directory": "./dist/client", "binding": "ASSETS" })');return}(typeof t.directory!="string"||t.directory.length===0)&&s.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)&&s.push('assets.binding must be a non-empty string (e.g. "ASSETS")'),t.html_handling!==void 0&&typeof t.html_handling!="string"&&s.push("assets.html_handling must be a string"),t.not_found_handling!==void 0&&typeof t.not_found_handling!="string"&&s.push("assets.not_found_handling must be a string")}},re=(e,s)=>{const t=e.tail_consumers;if(t===void 0)return;if(!Array.isArray(t)){s.push("tail_consumers must be an array of { service, environment? } entries");return}const n=t;for(const[a,i]of n.entries())(!i||typeof i!="object"||typeof i.service!="string"||i.service.length===0)&&s.push(`tail_consumers[${String(a)}] must have a non-empty "service" naming the consumer Worker`)},Ce=(e,s)=>{const t=e.tail_consumers??[];return t.some(a=>!!a&&a?.service===s.service&&a?.environment===s.environment)?e:{...e,tail_consumers:[...t,s]}},ce=new Set(["1","enabled","on","true","yes"]),de=(e,s)=>{const{vars:t}=e;if(!t||typeof t!="object")return;const n=t.LUNORA_ALLOWED_ORIGINS,a=t.LUNORA_CORS_ALLOW_CREDENTIALS,i=typeof n=="string"&&n.split(",").some(c=>c.trim()==="*"),o=typeof a=="string"&&ce.has(a.trim().toLowerCase());i&&o&&s.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')},le=(e,s,t)=>{const{error:n,merged:a,unverifiedKeys:i}=R(e,s);return n!==void 0?{error:n,wrangler:a}:(i.length>0&&t.push(`env.${String(s)} overrides ${i.join(", ")}, which this validator doesn't have a verified inheritance rule for — validated against the TOP-LEVEL value only. Double-check ${i.length===1?"it":"them"} by hand for "${String(s)}".`),{wrangler:a})},k=(e,s,t)=>{const n=[],a=[];if(!e||typeof e!="object")return n.push("wrangler config is not a valid object"),{errors:n,valid:!1,warnings:a};const{error:i,wrangler:o}=le(e,t,a);if(i!==void 0)return n.push(i),{errors:n,valid:!1,warnings:a};b(o.durable_objects?.bindings).find(l=>l.name==="SHARD"&&l.class_name==="ShardDO")||n.push('durable_objects.bindings must include { "name": "SHARD", "class_name": "ShardDO" } — run `lunora dev` to auto-reconcile wrangler.jsonc, or add the binding manually'),U(o,n);const r=o.compatibility_date??"";r&&!$.test(r)?n.push(`compatibility_date must be in YYYY-MM-DD format (got "${r}")`):r<v&&n.push(`compatibility_date must be >= "${v}" (got "${r||"<missing>"}")`),x(o)&&$.test(r)&&r<_&&n.push(`cache.enabled requires compatibility_date >= "${_}" (got "${r||"<missing>"}")`),s?.hasGlobalTable&&(b(o.d1_databases).find(w=>w.binding==="DB")||n.push('schema declares .global() tables; d1_databases must include a binding named "DB" — run `lunora dev` to auto-reconcile wrangler.jsonc, or add the binding manually')),Z(o,n),C(o,s?.vectorIndexNames??[],n),re(o,n),F(o,n,a),g(o.workflows,"workflows",P,n),Y(o,n),g(o.secrets_store_secrets,"secrets_store_secrets",H,n);for(const l of Q)V(o,l,n,a);for(const l of J)g(o[l.key],l.key,l,n);for(const l of z)X(o,l,n);return ee(o,n,a),se(o,n),ne(o,n),te(o,n),oe(o,n),ae(o,n),ie(o,n),de(o,n),{errors:n,valid:n.length===0,warnings:a}},Le=k,me=(e,s,t)=>{const n=[];for(const a of e){const i=a?.image;typeof i!="string"||!(i.startsWith("./")||i.startsWith("../")||i.startsWith("/")||i.includes("Dockerfile"))||f(i.startsWith("/")?i:p(s,i))||n.push(`containers image "${i}" does not exist (resolved relative to ${t}); create the Dockerfile or point image at a registry reference`)}return n},ue=(e,s,t)=>{if(typeof e=="string"&&e.length>0){const n=p(A(t),e);return f(n)?n:void 0}return O.map(n=>p(s,n)).find(n=>f(n))},be=/\/\/[^\n]*|\/\*.*?\*\/|"[^"\n]*"|'[^'\n]*'|`[^`]*`/gsu,ge=e=>e.replaceAll(be,s=>s.replaceAll(/[^\n]/gu," ")),fe=/\bexport\s*\*\s*(?:as\s+\w+\s*)?from\b/u,pe=/\bexport\b/gu,he=/^\s*(?:(?:abstract|async|declare|default)\s+)*/u,ye=/^(?:class|const|function|let|var)\s+(?<name>[$A-Z_a-z][\w$]*)/u,_e=/^\s*(?:const|let|var)\s*\{/u,ve=/^[$A-Z_a-z][\w$]*/u,$e=/^type\b/u,Ee=/\s+/u,Se=e=>{const s=[];for(const t of e.split(",")){const n=t.trim().split(Ee).filter(Boolean),a=n.at(-1);a!==void 0&&n[0]!=="type"&&s.push(a)}return s},je=e=>{const s=[];for(const t of e.split(",")){const n=t.includes(":")?t.slice(t.indexOf(":")+1):t,a=ve.exec(n.trim());a&&s.push(a[0])}return s},j=e=>{const s=e.indexOf("{"),t=e.indexOf("}",s);return s===-1||t===-1?void 0:e.slice(s+1,t)},Ae=e=>{const s=e.trimStart();if($e.test(s))return[];if(s.startsWith("{")){const n=j(s);return n===void 0?[]:Se(n)}if(_e.test(e)){const n=j(e);return n===void 0?[]:je(n)}const t=ye.exec(e.replace(he,""));return t?.groups?.name===void 0?[]:[t.groups.name]},Re=e=>{const s=new Set;for(const t of e.matchAll(pe))for(const n of Ae(e.slice(t.index+6)))s.add(n);return s},ke=(e,s,t)=>{const n=ue(e.main,s,t);if(n===void 0)return[];let a;try{a=M(n,"utf8")}catch{return[]}const i=ge(a);if(fe.test(i))return[];const o=[];for(const r of b(e.durable_objects?.bindings))typeof r.class_name=="string"&&r.class_name.length>0&&r.script_name===void 0&&o.push({className:r.class_name,label:"durable_objects.bindings"});for(const r of e.workflows??[])typeof r?.class_name=="string"&&r.class_name.length>0&&r.script_name===void 0&&o.push({className:r.class_name,label:"workflows"});const c=Re(i);return o.filter(r=>!c.has(r.className)).map(r=>`${r.label} declares class "${r.className}" but the worker entry (${n}) does not export it — wrangler refuses to bundle a Worker whose Durable Object classes are not exported. Add \`export { ${r.className} } from "…";\` to the entry.`)},Te=e=>{const s=e.schemaDir??"lunora",t=N(e.projectRoot);if(!t){const u=`wrangler.jsonc not found in ${e.projectRoot}; create one declaring at least the SHARD durable object binding.`;return{problems:[u],report:{errors:[u],valid:!1,warnings:[]},wranglerPath:void 0}}const{parsed:n}=I(t);if(n===void 0){const u=`failed to parse ${t} as JSONC.`;return{problems:[u],report:{errors:[u],valid:!1,warnings:[]},wranglerPath:t}}const{error:a,merged:i}=R(n,e.environment);if(a!==void 0)return{problems:[a],report:{errors:[a],valid:!1,warnings:[]},wranglerPath:t};const{error:o,info:c}=D(e.projectRoot,s),d=k(n,c,e.environment);o!==void 0&&d.warnings.push(`schema parse failed in ${s}/schema.ts: ${o}`);const r=A(t);d.errors.push(...me(i.containers??[],r,t)),d.warnings.push(...ke(i,e.projectRoot,t));const l=i.assets?.directory;if(typeof l=="string"&&l.length>0){const u=l.startsWith("/")?l:p(r,l);f(u)||d.warnings.push(`assets.directory "${l}" does not exist yet — it is created by the client build; run the build before deploy`)}return d.valid=d.errors.length===0,{problems:d.errors,report:d,wranglerPath:t}};export{v as REQUIRED_COMPATIBILITY_DATE,Ie as REQUIRED_FLAG,Le as validateWrangler,k as validateWranglerConfig,Te as validateWranglerProject,Ce as withTailConsumer};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunora/config",
3
- "version": "1.0.0-alpha.143",
3
+ "version": "1.0.0-alpha.145",
4
4
  "description": "Internal shared CLI + Vite config layer for Lunora: wrangler.jsonc validation, binding inference, and .dev.vars scaffolding",
5
5
  "keywords": [
6
6
  "bindings",
@@ -54,10 +54,10 @@
54
54
  "access": "public"
55
55
  },
56
56
  "dependencies": {
57
- "@lunora/codegen": "1.0.0-alpha.113",
58
- "@lunora/container": "1.0.0-alpha.31",
57
+ "@lunora/codegen": "1.0.0-alpha.115",
58
+ "@lunora/container": "1.0.0-alpha.32",
59
59
  "@lunora/errors": "1.0.0-alpha.22",
60
- "@lunora/seed": "1.0.0-alpha.75",
60
+ "@lunora/seed": "1.0.0-alpha.77",
61
61
  "@visulima/colorize": "2.1.1",
62
62
  "@visulima/find-ai-runner": "1.0.1",
63
63
  "dockerode": "^5.0.1",
@@ -1 +0,0 @@
1
- import{existsSync as g,readFileSync as k}from"node:fs";import{dirname as S,join as f}from"node:path";import{WORKER_ENTRY_FALLBACKS as M}from"./inferLunoraBindings-CEE39hXz.mjs";import{discoverSchemaInfo as O}from"./discoverSchemaInfo-Bg2CUZXG.mjs";import{isCacheEnabled as N,WORKERS_CACHE_MIN_DATE as h}from"./WORKERS_CACHE_MIN_DATE-0k9ABJtF.mjs";import{findWranglerFile as x,readWranglerJsonc as I}from"./WRANGLER_FILES-UNW-xY5u.mjs";const y="2026-04-07",Oe="web_socket_auto_reply_to_close",_=/^\d{4}-\d{2}-\d{2}$/,v=["d1_databases","durable_objects","kv_namespaces","queues","r2_buckets","secrets_store_secrets","services","tail_consumers","vars","vectorize","workflows"],E=["assets","compatibility_date","exports","logpush","main","migrations","observability","placement"],R=(e,s)=>{if(s===void 0)return{merged:e,unverifiedKeys:[]};const n=e.env?.[s];if(n===void 0){const c=Object.keys(e.env??{}).toSorted((r,l)=>r.localeCompare(l)),d=c.length>0?` (declared: ${c.join(", ")}).`:" (no environments are declared).";return{error:`--env "${s}" names no environment declared in wrangler.jsonc's "env" block${d}`,merged:e,unverifiedKeys:[]}}const t={...e},i=Object.keys(n).filter(c=>c!=="env");for(const c of i)E.includes(c)&&(t[c]=n[c]);for(const c of v)t[c]=n[c];const a=new Set([...v,...E]),o=i.filter(c=>!a.has(c)).map(String);return{merged:t,unverifiedKeys:o}},D=(e,s,n)=>{if(s.length===0)return;const t=e.vectorize??[],i=new Set(t.filter(Boolean).map(a=>a?.index_name));for(const a of s)i.has(a)||n.push(`schema declares vector index "${a}"; wrangler "vectorize" must include a binding with index_name "${a}"`)},C=new Set(["basic","dev","lite","standard","standard-1","standard-2","standard-3","standard-4"]),L={disk_mb:2e4,memory_mib:12288,vcpu:4},T=(e,s,n)=>{const t=e.instance_type;if(t===void 0)return;if(typeof t=="string"){C.has(t)||n.push(`${s} has unknown instance_type "${t}" — expected lite, basic, standard-1..4, or a custom { vcpu, memory_mib, disk_mb } object`);return}for(const[c,d]of Object.entries(L)){const r=t[c];r!==void 0&&(typeof r!="number"||r<=0||r>d)&&n.push(`${s} custom instance_type ${c} must be a positive number ≤ ${String(d)} (got ${String(r)})`)}const{disk_mb:i,memory_mib:a,vcpu:o}=t;if(typeof o=="number"&&typeof a=="number"&&a<o*3072&&n.push(`${s} custom instance_type needs ≥ 3 GiB (3072 MiB) memory per vCPU (got ${String(a)} MiB for ${String(o)} vCPU)`),typeof a=="number"&&typeof i=="number"){const c=Math.floor(a/1024*2e3);i>c&&n.push(`${s} custom instance_type allows ≤ 2 GB disk per GiB memory (≤ ${String(c)} MB for ${String(a)} MiB memory; got ${String(i)} MB)`)}},B=(e,s,n)=>{const{boundClasses:t,errors:i,nonSqliteClasses:a,sqliteClasses:o,warnings:c}=n;if(!e||typeof e!="object"||typeof e.class_name!="string"||e.class_name.length===0){i.push(`${s} must have a non-empty "class_name" naming its container-enabled Durable Object class`);return}(typeof e.image!="string"||e.image.length===0)&&i.push(`${s} ("${e.class_name}") must have an "image" — a Dockerfile path or a registry reference`),t.has(e.class_name)||i.push(`${s} class "${e.class_name}" has no matching durable_objects binding — run \`lunora dev\` to auto-reconcile wrangler.jsonc, or add { "name": "...", "class_name": "${e.class_name}" }`),o.has(e.class_name)||i.push(a.has(e.class_name)?`${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}"]`),T(e,`${s} ("${e.class_name}")`,i),e.max_instances===void 0&&c.push(`${s} ("${e.class_name}") declares no max_instances — set a cap so a traffic spike can't fan out unbounded container spend`)},b=e=>Array.isArray(e)?e.filter(s=>s!==null&&typeof s=="object"):[],W=(e,s,n)=>{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 t=e.containers;if(t.length===0)return;const i=new Set(b(e.durable_objects?.bindings).map(d=>d.class_name)),a=e.migrations??[],o=new Set(a.flatMap(d=>[...d?.new_sqlite_classes??[]])),c=new Set(a.flatMap(d=>[...d?.new_classes??[]]));for(const[d,r]of t.entries())B(r,`containers[${String(d)}]`,{boundClasses:i,errors:s,nonSqliteClasses:c,sqliteClasses:o,warnings:n});e.observability?.enabled!==!0&&n.push('containers are configured but observability is not enabled — container logs will not be captured (add { "observability": { "enabled": true } })')},p=e=>typeof e=="string"&&e.length>0,j=e=>e,u=(e,s,n,t)=>{if(e!==void 0){if(!Array.isArray(e)){t.push(n.arrayMessage);return}for(const[i,a]of j(e).entries()){const o=`${s}[${String(i)}]`;if(!a||typeof a!="object"){t.push(n.objectMessage(o));continue}for(const c of n.fields)p(a[c.field])||t.push(c.message(o))}}},q={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. WORKFLOW_ORDER_PIPELINE)`},{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`},U={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`},F={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`},P=(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}u(e.queues.producers,"queues.producers",U,s),u(e.queues.consumers,"queues.consumers",F,s)}},K={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`},G=[{arrayMessage:"kv_namespaces must be an array of { binding, id } entries",bindingMessage:e=>`${e} must have a non-empty "binding" naming the KV namespace binding`,hintField:"id",hintMessage:(e,s)=>`${e} ("${s}") has no "id" — run \`wrangler kv namespace create\` and set the namespace id, or the binding can't resolve`,key:"kv_namespaces"},{arrayMessage:"flagship must be an array of { binding, app_id } entries",bindingMessage:e=>`${e} must have a non-empty "binding" naming the Flagship binding`,hintField:"app_id",hintMessage:(e,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"}],Y=(e,s,n,t)=>{const i=e[s.key];if(i!==void 0){if(!Array.isArray(i)){n.push(s.arrayMessage);return}for(const[a,o]of j(i).entries()){const c=`${s.key}[${String(a)}]`;if(!o||typeof o!="object"||!p(o.binding)){n.push(s.bindingMessage(c));continue}(typeof s.hintField=="string"?[s.hintField]:s.hintField).some(r=>p(o[r]))||t.push(s.hintMessage(c,o.binding))}}},H=[{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" })'}],Q=(e,s,n)=>{const t=e[s.key];t!==void 0&&(typeof t!="object"||Array.isArray(t)||!p(t.binding))&&n.push(s.message)},V=[{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`}],z=(e,s,n)=>{const t=e.send_email;if(t===void 0)return;if(!Array.isArray(t)){s.push("send_email must be an array of { name, destination_address? } entries");return}const i=t;for(const[a,o]of i.entries())(!o||typeof o!="object"||typeof o.name!="string"||o.name.length===0)&&n.push(`send_email[${String(a)}] has no non-empty "name" naming the send-email binding — set one before deploying`)},X=(e,s)=>{e.logpush!==void 0&&typeof e.logpush!="boolean"&&s.push('logpush must be a boolean (set "logpush": true to enable Cloudflare Logpush)')},J=(e,s)=>{const{placement:n}=e;if(n!==void 0){if(typeof n!="object"||Array.isArray(n)){s.push('placement must be an object (e.g. { "mode": "smart" })');return}n.mode!==void 0&&n.mode!=="smart"&&s.push('placement.mode must be "smart" (the only supported Smart Placement mode)')}},Z=(e,s)=>{const{observability:n}=e;if(n===void 0)return;if(typeof n!="object"||Array.isArray(n)){s.push('observability must be an object (e.g. { "enabled": true, "head_sampling_rate": 1 })');return}const t=(i,a)=>{i!==void 0&&(typeof i!="number"||Number.isNaN(i)||i<0||i>1)&&s.push(`${a} must be a number in [0, 1] (the fraction of requests sampled)`)};t(n.head_sampling_rate,"observability.head_sampling_rate"),n.logs!==void 0&&(typeof n.logs!="object"||Array.isArray(n.logs)?s.push("observability.logs must be an object"):t(n.logs.head_sampling_rate,"observability.logs.head_sampling_rate"))},ee=(e,s)=>{const{cache:n}=e;if(n!==void 0){if(typeof n!="object"||n===null||Array.isArray(n)){s.push('cache must be an object (e.g. { "enabled": true })');return}n.enabled!==void 0&&typeof n.enabled!="boolean"&&s.push("cache.enabled must be a boolean (true or false)")}},se=(e,s)=>{const{exports:n}=e;if(n!==void 0){if(typeof n!="object"||n===null||Array.isArray(n)){s.push("exports must be an object keyed by entrypoint name");return}for(const[t,i]of Object.entries(n)){if(typeof i!="object"||i===null){s.push(`exports["${t}"] must be an object`);continue}i.type!==void 0&&typeof i.type!="string"&&s.push(`exports["${t}"].type must be a string`),i.cache!==void 0&&(typeof i.cache!="object"||i.cache===null||Array.isArray(i.cache)?s.push(`exports["${t}"].cache must be an object`):i.cache.enabled!==void 0&&typeof i.cache.enabled!="boolean"&&s.push(`exports["${t}"].cache.enabled must be a boolean`))}}},ne=(e,s)=>{const{assets:n}=e;if(n!==void 0){if(typeof n!="object"||Array.isArray(n)){s.push('assets must be an object (e.g. { "directory": "./dist/client", "binding": "ASSETS" })');return}(typeof n.directory!="string"||n.directory.length===0)&&s.push('assets must declare a non-empty "directory" pointing at the built client output (e.g. "./dist/client")'),n.binding!==void 0&&(typeof n.binding!="string"||n.binding.length===0)&&s.push('assets.binding must be a non-empty string (e.g. "ASSETS")'),n.html_handling!==void 0&&typeof n.html_handling!="string"&&s.push("assets.html_handling must be a string"),n.not_found_handling!==void 0&&typeof n.not_found_handling!="string"&&s.push("assets.not_found_handling must be a string")}},te=(e,s)=>{const n=e.tail_consumers;if(n===void 0)return;if(!Array.isArray(n)){s.push("tail_consumers must be an array of { service, environment? } entries");return}const t=n;for(const[i,a]of t.entries())(!a||typeof a!="object"||typeof a.service!="string"||a.service.length===0)&&s.push(`tail_consumers[${String(i)}] must have a non-empty "service" naming the consumer Worker`)},Ne=(e,s)=>{const n=e.tail_consumers??[];return n.some(i=>!!i&&i?.service===s.service&&i?.environment===s.environment)?e:{...e,tail_consumers:[...n,s]}},ie=new Set(["1","enabled","on","true","yes"]),ae=(e,s)=>{const{vars:n}=e;if(!n||typeof n!="object")return;const t=n.LUNORA_ALLOWED_ORIGINS,i=n.LUNORA_CORS_ALLOW_CREDENTIALS,a=typeof t=="string"&&t.split(",").some(c=>c.trim()==="*"),o=typeof i=="string"&&ie.has(i.trim().toLowerCase());a&&o&&s.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')},oe=(e,s,n)=>{const{error:t,merged:i,unverifiedKeys:a}=R(e,s);return t!==void 0?{error:t,wrangler:i}:(a.length>0&&n.push(`env.${String(s)} overrides ${a.join(", ")}, which this validator doesn't have a verified inheritance rule for — validated against the TOP-LEVEL value only. Double-check ${a.length===1?"it":"them"} by hand for "${String(s)}".`),{wrangler:i})},A=(e,s,n)=>{const t=[],i=[];if(!e||typeof e!="object")return t.push("wrangler config is not a valid object"),{errors:t,valid:!1,warnings:i};const{error:a,wrangler:o}=oe(e,n,i);if(a!==void 0)return t.push(a),{errors:t,valid:!1,warnings:i};b(o.durable_objects?.bindings).find(l=>l.name==="SHARD"&&l.class_name==="ShardDO")||t.push('durable_objects.bindings must include { "name": "SHARD", "class_name": "ShardDO" } — run `lunora dev` to auto-reconcile wrangler.jsonc, or add the binding manually');const r=o.compatibility_date??"";r&&!_.test(r)?t.push(`compatibility_date must be in YYYY-MM-DD format (got "${r}")`):r<y&&t.push(`compatibility_date must be >= "${y}" (got "${r||"<missing>"}")`),N(o)&&_.test(r)&&r<h&&t.push(`cache.enabled requires compatibility_date >= "${h}" (got "${r||"<missing>"}")`),s?.hasGlobalTable&&(b(o.d1_databases).find(w=>w.binding==="DB")||t.push('schema declares .global() tables; d1_databases must include a binding named "DB" — run `lunora dev` to auto-reconcile wrangler.jsonc, or add the binding manually')),D(o,s?.vectorIndexNames??[],t),te(o,t),W(o,t,i),u(o.workflows,"workflows",q,t),P(o,t),u(o.secrets_store_secrets,"secrets_store_secrets",K,t);for(const l of G)Y(o,l,t,i);for(const l of V)u(o[l.key],l.key,l,t);for(const l of H)Q(o,l,t);return z(o,t,i),X(o,t),J(o,t),Z(o,t),ne(o,t),ee(o,t),se(o,t),ae(o,t),{errors:t,valid:t.length===0,warnings:i}},xe=A,re=(e,s,n)=>{const t=[];for(const i of e){const a=i?.image;typeof a!="string"||!(a.startsWith("./")||a.startsWith("../")||a.startsWith("/")||a.includes("Dockerfile"))||g(a.startsWith("/")?a:f(s,a))||t.push(`containers image "${a}" does not exist (resolved relative to ${n}); create the Dockerfile or point image at a registry reference`)}return t},ce=(e,s,n)=>{if(typeof e=="string"&&e.length>0){const t=f(S(n),e);return g(t)?t:void 0}return M.map(t=>f(s,t)).find(t=>g(t))},de=/\/\/[^\n]*|\/\*.*?\*\/|"[^"\n]*"|'[^'\n]*'|`[^`]*`/gsu,le=e=>e.replaceAll(de,s=>s.replaceAll(/[^\n]/gu," ")),me=/\bexport\s*\*\s*(?:as\s+\w+\s*)?from\b/u,ue=/\bexport\b/gu,ge=/^\s*(?:(?:abstract|async|declare|default)\s+)*/u,fe=/^(?:class|const|function|let|var)\s+(?<name>[$A-Z_a-z][\w$]*)/u,be=/^\s*(?:const|let|var)\s*\{/u,pe=/^[$A-Z_a-z][\w$]*/u,he=/^type\b/u,ye=/\s+/u,_e=e=>{const s=[];for(const n of e.split(",")){const t=n.trim().split(ye).filter(Boolean),i=t.at(-1);i!==void 0&&t[0]!=="type"&&s.push(i)}return s},ve=e=>{const s=[];for(const n of e.split(",")){const t=n.includes(":")?n.slice(n.indexOf(":")+1):n,i=pe.exec(t.trim());i&&s.push(i[0])}return s},$=e=>{const s=e.indexOf("{"),n=e.indexOf("}",s);return s===-1||n===-1?void 0:e.slice(s+1,n)},Ee=e=>{const s=e.trimStart();if(he.test(s))return[];if(s.startsWith("{")){const t=$(s);return t===void 0?[]:_e(t)}if(be.test(e)){const t=$(e);return t===void 0?[]:ve(t)}const n=fe.exec(e.replace(ge,""));return n?.groups?.name===void 0?[]:[n.groups.name]},$e=e=>{const s=new Set;for(const n of e.matchAll(ue))for(const t of Ee(e.slice(n.index+6)))s.add(t);return s},Se=(e,s,n)=>{const t=ce(e.main,s,n);if(t===void 0)return[];let i;try{i=k(t,"utf8")}catch{return[]}const a=le(i);if(me.test(a))return[];const o=[];for(const r of b(e.durable_objects?.bindings))typeof r.class_name=="string"&&r.class_name.length>0&&r.script_name===void 0&&o.push({className:r.class_name,label:"durable_objects.bindings"});for(const r of e.workflows??[])typeof r?.class_name=="string"&&r.class_name.length>0&&r.script_name===void 0&&o.push({className:r.class_name,label:"workflows"});const c=$e(a);return o.filter(r=>!c.has(r.className)).map(r=>`${r.label} declares class "${r.className}" but the worker entry (${t}) does not export it — wrangler refuses to bundle a Worker whose Durable Object classes are not exported. Add \`export { ${r.className} } from "…";\` to the entry.`)},Ie=e=>{const s=e.schemaDir??"lunora",n=x(e.projectRoot);if(!n){const m=`wrangler.jsonc not found in ${e.projectRoot}; create one declaring at least the SHARD durable object binding.`;return{problems:[m],report:{errors:[m],valid:!1,warnings:[]},wranglerPath:void 0}}const{parsed:t}=I(n);if(t===void 0){const m=`failed to parse ${n} as JSONC.`;return{problems:[m],report:{errors:[m],valid:!1,warnings:[]},wranglerPath:n}}const{error:i,merged:a}=R(t,e.environment);if(i!==void 0)return{problems:[i],report:{errors:[i],valid:!1,warnings:[]},wranglerPath:n};const{error:o,info:c}=O(e.projectRoot,s),d=A(t,c,e.environment);o!==void 0&&d.warnings.push(`schema parse failed in ${s}/schema.ts: ${o}`);const r=S(n);d.errors.push(...re(a.containers??[],r,n)),d.warnings.push(...Se(a,e.projectRoot,n));const l=a.assets?.directory;if(typeof l=="string"&&l.length>0){const m=l.startsWith("/")?l:f(r,l);g(m)||d.warnings.push(`assets.directory "${l}" does not exist yet — it is created by the client build; run the build before deploy`)}return d.valid=d.errors.length===0,{problems:d.errors,report:d,wranglerPath:n}};export{y as REQUIRED_COMPATIBILITY_DATE,Oe as REQUIRED_FLAG,xe as validateWrangler,A as validateWranglerConfig,Ie as validateWranglerProject,Ne as withTailConsumer};