@lunora/config 1.0.0-alpha.422 → 1.0.0-alpha.423

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.
@@ -1 +1 @@
1
- import{applyModify as o}from"../packem_shared/applyModify-DKP2l6S9.mjs";import{assertWranglerSatisfiesSchema as t}from"../packem_shared/assertWranglerSatisfiesSchema-A2WCMIRa.mjs";import{BINDING_MANIFEST_VERSION as i,buildBindingManifest as l}from"../packem_shared/BINDING_MANIFEST_VERSION-CfXEYG8e.mjs";import{CLOUDFLARE_CLI_CONFIG_WARNING_ENV as m,detectCloudflareCliConfig as E,warnCloudflareCliConfigOnce as s}from"../packem_shared/CLOUDFLARE_CLI_CONFIG_WARNING_ENV-BKMrOuXV.mjs";import{default as d}from"../packem_shared/CLOUDFLARE_DRIVER-CULavrYO.mjs";import{default as C}from"../packem_shared/GLOBAL_FETCH_STRICTLY_PUBLIC_FLAG-f8CnJha3.mjs";import{hasCloudflareCredentials as R}from"../packem_shared/hasCloudflareCredentials-Bak5w1_6.mjs";import{describeWithheld as c,withheldBindings as I}from"../packem_shared/describeWithheld-CbyzZjZF.mjs";import{bindingsNeedingDatabase as A,startLocalHyperdrive as D}from"../packem_shared/bindingsNeedingDatabase-6eD6Qtqf.mjs";import{HYPERDRIVE_PLACEHOLDER_ID as S}from"../packem_shared/D1_PLACEHOLDER_ID-ZnDjVymH.mjs";import{collectExportGaps as T,reconcileWranglerBindings as N}from"../packem_shared/collectExportGaps-zmra4uTS.mjs";import{reconcileWranglerCompatibilityDate as F}from"../packem_shared/reconcileWranglerCompatibilityDate-hocXEuRA.mjs";import{describePreservedCrons as B,reconcileWranglerCrons as h}from"../packem_shared/describePreservedCrons-C5KPuPy3.mjs";import{reconcileBindingsSafely as G,reconcileWranglerExtras as U}from"../packem_shared/reconcileBindingsSafely-Dh2MIIWG.mjs";import{REMOTE_ELIGIBLE_KEYS as M,injectRemoteFlags as P,isRemoteEnvEnabled as V,materializeDevWranglerConfig as H,planRemoteBindings as w,resolveRemoteEnabled as Y}from"../packem_shared/REMOTE_ELIGIBLE_KEYS-CuhB99R2.mjs";import{materializeServiceDevConfigs as j}from"../packem_shared/materializeServiceDevConfigs-qUY4_iu1.mjs";import{default as Q}from"../packem_shared/CLOUDFLARE_TOOLCHAIN_VERSIONS-DV5E_f_q.mjs";import{withTailConsumer as X}from"../packem_shared/withTailConsumer-CF3pk_Ov.mjs";import{WORKERS_CACHE_MIN_DATE as q,isCacheEnabled as Z}from"../packem_shared/WORKERS_CACHE_MIN_DATE-0k9ABJtF.mjs";import{wranglerCodegenInputs as ee}from"../packem_shared/wranglerCodegenInputs-BZamZrPz.mjs";import{DEFAULT_OBSERVABILITY as oe,resolveObservabilitySampling as ae}from"../packem_shared/DEFAULT_OBSERVABILITY-bN6UkTMx.mjs";import{mergeWranglerEnvironment as ne}from"../packem_shared/mergeWranglerEnvironment-D5ekKj5x.mjs";import{WRANGLER_FILES as le,findWranglerFile as fe,readWranglerJsonc as me}from"../packem_shared/WRANGLER_FILES-UNW-xY5u.mjs";import{UNEXPORTED_CLASS_MARKER as se,validateWranglerProject as pe}from"../packem_shared/UNEXPORTED_CLASS_MARKER-BV29zhUp.mjs";import{scanWranglerVariablesForSecrets as ge}from"../packem_shared/scanWranglerVariablesForSecrets-DRBYlMYb.mjs";import{wranglerToAlchemy as xe}from"../packem_shared/wranglerToAlchemy-CBO2ucRm.mjs";import{REQUIRED_COMPATIBILITY_DATE as _e,REQUIRED_FLAG as ce,validateWrangler as Ie,validateWranglerConfig as Le}from"../packem_shared/REQUIRED_COMPATIBILITY_DATE-D4UcOP_t.mjs";export{i as BINDING_MANIFEST_VERSION,m as CLOUDFLARE_CLI_CONFIG_WARNING_ENV,d as CLOUDFLARE_DRIVER,Q as CLOUDFLARE_TOOLCHAIN_VERSIONS,oe as DEFAULT_OBSERVABILITY,C as GLOBAL_FETCH_STRICTLY_PUBLIC_FLAG,S as HYPERDRIVE_PLACEHOLDER_ID,M as REMOTE_ELIGIBLE_KEYS,_e as REQUIRED_COMPATIBILITY_DATE,ce as REQUIRED_FLAG,se as UNEXPORTED_CLASS_MARKER,q as WORKERS_CACHE_MIN_DATE,le as WRANGLER_FILES,o as applyModify,t as assertWranglerSatisfiesSchema,A as bindingsNeedingDatabase,l as buildBindingManifest,T as collectExportGaps,B as describePreservedCrons,c as describeWithheld,E as detectCloudflareCliConfig,fe as findWranglerFile,R as hasCloudflareCredentials,P as injectRemoteFlags,Z as isCacheEnabled,V as isRemoteEnvEnabled,H as materializeDevWranglerConfig,j as materializeServiceDevConfigs,ne as mergeWranglerEnvironment,w as planRemoteBindings,me as readWranglerJsonc,G as reconcileBindingsSafely,N as reconcileWranglerBindings,F as reconcileWranglerCompatibilityDate,h as reconcileWranglerCrons,U as reconcileWranglerExtras,ae as resolveObservabilitySampling,Y as resolveRemoteEnabled,ge as scanWranglerVariablesForSecrets,D as startLocalHyperdrive,Ie as validateWrangler,Le as validateWranglerConfig,pe as validateWranglerProject,s as warnCloudflareCliConfigOnce,X as withTailConsumer,I as withheldBindings,ee as wranglerCodegenInputs,xe as wranglerToAlchemy};
1
+ import{applyModify as o}from"../packem_shared/applyModify-DKP2l6S9.mjs";import{assertWranglerSatisfiesSchema as t}from"../packem_shared/assertWranglerSatisfiesSchema-CNwRRCbB.mjs";import{BINDING_MANIFEST_VERSION as i,buildBindingManifest as l}from"../packem_shared/BINDING_MANIFEST_VERSION-CfXEYG8e.mjs";import{CLOUDFLARE_CLI_CONFIG_WARNING_ENV as m,detectCloudflareCliConfig as E,warnCloudflareCliConfigOnce as s}from"../packem_shared/CLOUDFLARE_CLI_CONFIG_WARNING_ENV-BKMrOuXV.mjs";import{default as d}from"../packem_shared/CLOUDFLARE_DRIVER-CULavrYO.mjs";import{default as C}from"../packem_shared/GLOBAL_FETCH_STRICTLY_PUBLIC_FLAG-f8CnJha3.mjs";import{hasCloudflareCredentials as R}from"../packem_shared/hasCloudflareCredentials-Bak5w1_6.mjs";import{describeWithheld as c,withheldBindings as I}from"../packem_shared/describeWithheld-CbyzZjZF.mjs";import{bindingsNeedingDatabase as A,startLocalHyperdrive as D}from"../packem_shared/bindingsNeedingDatabase-6eD6Qtqf.mjs";import{HYPERDRIVE_PLACEHOLDER_ID as S}from"../packem_shared/D1_PLACEHOLDER_ID-ZnDjVymH.mjs";import{collectExportGaps as T,reconcileWranglerBindings as N}from"../packem_shared/collectExportGaps-zmra4uTS.mjs";import{reconcileWranglerCompatibilityDate as F}from"../packem_shared/reconcileWranglerCompatibilityDate-hocXEuRA.mjs";import{describePreservedCrons as B,reconcileWranglerCrons as h}from"../packem_shared/describePreservedCrons-C5KPuPy3.mjs";import{reconcileBindingsSafely as G,reconcileWranglerExtras as U}from"../packem_shared/reconcileBindingsSafely-Dh2MIIWG.mjs";import{REMOTE_ELIGIBLE_KEYS as M,injectRemoteFlags as P,isRemoteEnvEnabled as V,materializeDevWranglerConfig as H,planRemoteBindings as w,resolveRemoteEnabled as Y}from"../packem_shared/REMOTE_ELIGIBLE_KEYS-CuhB99R2.mjs";import{materializeServiceDevConfigs as j}from"../packem_shared/materializeServiceDevConfigs-qUY4_iu1.mjs";import{default as Q}from"../packem_shared/CLOUDFLARE_TOOLCHAIN_VERSIONS-DV5E_f_q.mjs";import{withTailConsumer as X}from"../packem_shared/withTailConsumer-CF3pk_Ov.mjs";import{WORKERS_CACHE_MIN_DATE as q,isCacheEnabled as Z}from"../packem_shared/WORKERS_CACHE_MIN_DATE-0k9ABJtF.mjs";import{wranglerCodegenInputs as ee}from"../packem_shared/wranglerCodegenInputs-BZamZrPz.mjs";import{DEFAULT_OBSERVABILITY as oe,resolveObservabilitySampling as ae}from"../packem_shared/DEFAULT_OBSERVABILITY-bN6UkTMx.mjs";import{mergeWranglerEnvironment as ne}from"../packem_shared/mergeWranglerEnvironment-D5ekKj5x.mjs";import{WRANGLER_FILES as le,findWranglerFile as fe,readWranglerJsonc as me}from"../packem_shared/WRANGLER_FILES-UNW-xY5u.mjs";import{UNEXPORTED_CLASS_MARKER as se,validateWranglerProject as pe}from"../packem_shared/UNEXPORTED_CLASS_MARKER-B06-1J8H.mjs";import{scanWranglerVariablesForSecrets as ge}from"../packem_shared/scanWranglerVariablesForSecrets-DRBYlMYb.mjs";import{wranglerToAlchemy as xe}from"../packem_shared/wranglerToAlchemy-CBO2ucRm.mjs";import{REQUIRED_COMPATIBILITY_DATE as _e,REQUIRED_FLAG as ce,validateWrangler as Ie,validateWranglerConfig as Le}from"../packem_shared/REQUIRED_COMPATIBILITY_DATE-D4UcOP_t.mjs";export{i as BINDING_MANIFEST_VERSION,m as CLOUDFLARE_CLI_CONFIG_WARNING_ENV,d as CLOUDFLARE_DRIVER,Q as CLOUDFLARE_TOOLCHAIN_VERSIONS,oe as DEFAULT_OBSERVABILITY,C as GLOBAL_FETCH_STRICTLY_PUBLIC_FLAG,S as HYPERDRIVE_PLACEHOLDER_ID,M as REMOTE_ELIGIBLE_KEYS,_e as REQUIRED_COMPATIBILITY_DATE,ce as REQUIRED_FLAG,se as UNEXPORTED_CLASS_MARKER,q as WORKERS_CACHE_MIN_DATE,le as WRANGLER_FILES,o as applyModify,t as assertWranglerSatisfiesSchema,A as bindingsNeedingDatabase,l as buildBindingManifest,T as collectExportGaps,B as describePreservedCrons,c as describeWithheld,E as detectCloudflareCliConfig,fe as findWranglerFile,R as hasCloudflareCredentials,P as injectRemoteFlags,Z as isCacheEnabled,V as isRemoteEnvEnabled,H as materializeDevWranglerConfig,j as materializeServiceDevConfigs,ne as mergeWranglerEnvironment,w as planRemoteBindings,me as readWranglerJsonc,G as reconcileBindingsSafely,N as reconcileWranglerBindings,F as reconcileWranglerCompatibilityDate,h as reconcileWranglerCrons,U as reconcileWranglerExtras,ae as resolveObservabilitySampling,Y as resolveRemoteEnabled,ge as scanWranglerVariablesForSecrets,D as startLocalHyperdrive,Ie as validateWrangler,Le as validateWranglerConfig,pe as validateWranglerProject,s as warnCloudflareCliConfigOnce,X as withTailConsumer,I as withheldBindings,ee as wranglerCodegenInputs,xe as wranglerToAlchemy};
@@ -0,0 +1 @@
1
+ import{existsSync as h}from"node:fs";import{dirname as y,join as p}from"node:path";import{discoverSchemaInfo as E}from"./discoverSchemaInfo-DRPnqgif.mjs";import{MERGED_DURABLE_OBJECT as i,GENERATED_DIRECTORY as w,MERGED_ROLE_DURABLE_OBJECTS as u,COMPOSED_ENTRY_DURABLE_OBJECTS as $,GENERATED_CLASS_MODULES as k,isFrameworkDurableObject as D}from"./COMPOSED_WORKER_ENTRY-Ciiba5g_.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-AIASCYl7.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-D4UcOP_t.mjs";const v=r=>Array.isArray(r)?r:[],L=(r,o,t)=>Object.entries(r?.images??{}).flatMap(([s,n])=>{const e=n?.dockerfile;return typeof e!="string"||h(e.startsWith("/")?e:p(o,e))?[]:[`containers images["${s}"] dockerfile "${e}" does not exist (resolved relative to ${t}); create the Dockerfile`]}),I=(r,o,t)=>{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(o,e))&&s.push(`containers image "${e}" does not exist (resolved relative to ${t}); create the Dockerfile or point image at a registry reference`),s.push(...L(n,o,t))}return s},P=(r,o)=>{const t=r?.vectorIndexNames??[],s=[];if(t.length>0&&s.push({message:e=>`schema declares vector index(es) ${t.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(t[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(postgres(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(o,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,o)=>{if(o.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(o.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 t=`it exports ${$.join(", ")}, SchedulerDO when its binding is declared, and every class codegen emits from your ${k.map(s=>`${s}.ts`).join(" / ")} declarations`;return D(r)?`\`@lunora/vite\` generates that entry — ${t}, 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: ${t}. Declare "${r}" in one of those and re-run \`lunora codegen\`, or drop the binding.`},M=(r,o)=>{const t=o.exports;if(t===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=>!t.has(e.className)).map(e=>`${e.label} declares class "${e.className}" but the ${o.kind==="composed"?"composed class-A worker entry":"worker entry"} (${o.path}) ${G} — wrangler refuses to bundle a Worker whose ${e.label==="workflows"?"Workflow":"Durable Object"} classes are not exported. ${B(e.className,o)}`)},N=r=>[...j(r.migrations)].filter(o=>u.has(o)).map(o=>`migrations create class "${o}", which this app hosts in ${i} because it merges its Durable Objects (\`durableObjects.merge\`). Before the first deploy, replace "${o}" with "${i}" in new_sqlite_classes; a Worker already deployed with "${o}" 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 o=r.schemaDir??"lunora",t=W(r.projectRoot);if(!t){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(t);if(s===void 0){const c=`failed to parse ${t} as JSONC.`;return{problems:[c],report:{errors:[c],valid:!1,warnings:[]},wranglerPath:t}}const{error:n,merged:e}=S(s,r.environment);if(n!==void 0)return{problems:[n],report:{errors:[n],valid:!1,warnings:[]},wranglerPath:t};const{error:l,info:f}=E(r.projectRoot,o,r.cache),a=T(s,f,r.environment);l!==void 0&&a.warnings.push(`schema parse failed in ${o}/schema.ts: ${l}`);const g=y(t),b=O(e.main,r.projectRoot,t),m=_(b,r.projectRoot,o);a.errors.push(...I(e.containers??[],g,t)),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,o,w,"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:t}};export{G as UNEXPORTED_CLASS_MARKER,Z as validateWranglerProject};
@@ -1,3 +1,3 @@
1
- import{LunoraError as n}from"@lunora/errors";import{lunoraLine as i}from"./LUNORA_TAG-DQTGPqcJ.mjs";import{validateWranglerProject as c}from"./UNEXPORTED_CLASS_MARKER-BV29zhUp.mjs";const m=(e,o,t)=>{const r=c({cache:e.cache,projectRoot:e.projectRoot,schemaDir:e.schemaDir});if(!r.wranglerPath)throw new n("INTERNAL",["[lunora] wrangler.jsonc not found.",` searched in: ${e.projectRoot}`," create a wrangler.jsonc declaring at least the SHARD durable object binding."].join(`
1
+ import{LunoraError as n}from"@lunora/errors";import{lunoraLine as i}from"./LUNORA_TAG-DQTGPqcJ.mjs";import{validateWranglerProject as c}from"./UNEXPORTED_CLASS_MARKER-B06-1J8H.mjs";const m=(e,o,t)=>{const r=c({cache:e.cache,projectRoot:e.projectRoot,schemaDir:e.schemaDir});if(!r.wranglerPath)throw new n("INTERNAL",["[lunora] wrangler.jsonc not found.",` searched in: ${e.projectRoot}`," create a wrangler.jsonc declaring at least the SHARD durable object binding."].join(`
2
2
  `));for(const a of r.report.warnings)o(i(`wrangler validator: ${a}`));if(r.problems.length>0)throw new n("INTERNAL",["[lunora] wrangler configuration is missing bindings required by your schema.",` file: ${r.wranglerPath}`,"",...r.problems.map(a=>` - ${a}`),"",` ${t}`].join(`
3
3
  `))};export{m as assertWranglerSatisfiesSchema};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunora/config",
3
- "version": "1.0.0-alpha.422",
3
+ "version": "1.0.0-alpha.423",
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.367",
61
+ "@lunora/codegen": "1.0.0-alpha.368",
62
62
  "@lunora/container": "1.0.0-alpha.96",
63
63
  "@lunora/errors": ">=1.0.0-alpha.51 <2.0.0-0",
64
64
  "@lunora/seed": "1.0.0-alpha.264",
@@ -1 +0,0 @@
1
- import{existsSync as h}from"node:fs";import{dirname as y,join as p}from"node:path";import{discoverSchemaInfo as E}from"./discoverSchemaInfo-DRPnqgif.mjs";import{MERGED_DURABLE_OBJECT as i,GENERATED_DIRECTORY as w,MERGED_ROLE_DURABLE_OBJECTS as u,COMPOSED_ENTRY_DURABLE_OBJECTS as $,GENERATED_CLASS_MODULES as k,isFrameworkDurableObject as D}from"./COMPOSED_WORKER_ENTRY-Ciiba5g_.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-AIASCYl7.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-D4UcOP_t.mjs";const v=r=>Array.isArray(r)?r:[],L=(r,o,t)=>Object.entries(r?.images??{}).flatMap(([s,n])=>{const e=n?.dockerfile;return typeof e!="string"||h(e.startsWith("/")?e:p(o,e))?[]:[`containers images["${s}"] dockerfile "${e}" does not exist (resolved relative to ${t}); create the Dockerfile`]}),I=(r,o,t)=>{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(o,e))&&s.push(`containers image "${e}" does not exist (resolved relative to ${t}); create the Dockerfile or point image at a registry reference`),s.push(...L(n,o,t))}return s},P=(r,o)=>{const t=r?.vectorIndexNames??[],s=[];if(t.length>0&&s.push({message:e=>`schema declares vector index(es) ${t.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(t[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(postgres(env.HYPERDRIVE.connectionString))) })\` to the chain (\`buildPgExec\` from \`@lunora/hyperdrive/global\`, \`fromPostgresJs\` from \`@lunora/hyperdrive\`).`,method:"hyperdriveGlobal"}),s.length===0)return[];const n=A(o,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,o)=>{if(o.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(o.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 t=`it exports ${$.join(", ")}, SchedulerDO when its binding is declared, and every class codegen emits from your ${k.map(s=>`${s}.ts`).join(" / ")} declarations`;return D(r)?`\`@lunora/vite\` generates that entry — ${t}, 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: ${t}. Declare "${r}" in one of those and re-run \`lunora codegen\`, or drop the binding.`},M=(r,o)=>{const t=o.exports;if(t===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=>!t.has(e.className)).map(e=>`${e.label} declares class "${e.className}" but the ${o.kind==="composed"?"composed class-A worker entry":"worker entry"} (${o.path}) ${G} — wrangler refuses to bundle a Worker whose ${e.label==="workflows"?"Workflow":"Durable Object"} classes are not exported. ${B(e.className,o)}`)},N=r=>[...j(r.migrations)].filter(o=>u.has(o)).map(o=>`migrations create class "${o}", which this app hosts in ${i} because it merges its Durable Objects (\`durableObjects.merge\`). Before the first deploy, replace "${o}" with "${i}" in new_sqlite_classes; a Worker already deployed with "${o}" 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 o=r.schemaDir??"lunora",t=W(r.projectRoot);if(!t){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(t);if(s===void 0){const c=`failed to parse ${t} as JSONC.`;return{problems:[c],report:{errors:[c],valid:!1,warnings:[]},wranglerPath:t}}const{error:n,merged:e}=S(s,r.environment);if(n!==void 0)return{problems:[n],report:{errors:[n],valid:!1,warnings:[]},wranglerPath:t};const{error:l,info:f}=E(r.projectRoot,o,r.cache),a=T(s,f,r.environment);l!==void 0&&a.warnings.push(`schema parse failed in ${o}/schema.ts: ${l}`);const g=y(t),b=O(e.main,r.projectRoot,t),m=_(b,r.projectRoot,o);a.errors.push(...I(e.containers??[],g,t)),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,o,w,"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:t}};export{G as UNEXPORTED_CLASS_MARKER,Z as validateWranglerProject};