@lunora/config 1.0.0-alpha.463 → 1.0.0-alpha.465
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cloudflare/index.mjs +1 -1
- package/dist/packem_shared/{POLICY_SCAFFOLD_ENDPOINT-VLHOdIr8.mjs → POLICY_SCAFFOLD_ENDPOINT-uPZXZrU7.mjs} +1 -1
- package/dist/packem_shared/{REQUIRED_COMPATIBILITY_DATE-Dccl2OBo.mjs → REQUIRED_COMPATIBILITY_DATE-GjaJU_-D.mjs} +1 -1
- package/dist/packem_shared/{SCHEMA_EDIT_ENDPOINT-065ZVpOZ.mjs → SCHEMA_EDIT_ENDPOINT-Dbdgz4G6.mjs} +1 -1
- package/dist/packem_shared/{STUDIO_PATH-DAPdXJb_.mjs → STUDIO_PATH-DXNMnzuM.mjs} +1 -1
- package/dist/packem_shared/UNEXPORTED_CLASS_MARKER-Cfi7PRg1.mjs +1 -0
- package/dist/packem_shared/{assertWranglerSatisfiesSchema-MeuwpRUx.mjs → assertWranglerSatisfiesSchema-UYsmhXNk.mjs} +1 -1
- package/dist/packem_shared/{collectExportGaps-C9awPQMw.mjs → collectExportGaps-DHUtghqe.mjs} +2 -2
- package/dist/packem_shared/isOwnedStudioAssets-CHII-uIX.mjs +1 -0
- package/dist/packem_shared/{pendingBindingChanges-B85u-ZNK.mjs → pendingBindingChanges-DqP40pSQ.mjs} +1 -1
- package/dist/packem_shared/{reconcileWranglerBindings-D2xxchNc.mjs → reconcileWranglerBindings-DAdI2Z-R.mjs} +1 -1
- package/dist/packem_shared/studio-assets-BKWx838V.mjs +1 -0
- package/dist/packem_shared/validate-bindings-DSMH8bRQ.mjs +1 -0
- package/dist/packem_shared/{withTailConsumer-B__tj5s-.mjs → withTailConsumer-BXOIqXxv.mjs} +1 -1
- package/dist/packem_shared/{wranglerCodegenInputs-BM7W0Aqh.mjs → wranglerCodegenInputs-Bfe3cN0G.mjs} +1 -1
- package/dist/packem_shared/{write-atomic-CNq1MBss.mjs → write-atomic-BD9yan7c.mjs} +1 -1
- package/dist/studio-host/index.mjs +1 -1
- package/package.json +2 -2
- package/dist/packem_shared/UNEXPORTED_CLASS_MARKER-Dr92nrbm.mjs +0 -1
- package/dist/packem_shared/isOwnedStudioAssets-CEaEGSRF.mjs +0 -1
- package/dist/packem_shared/studio-assets-B-xhoszR.mjs +0 -1
- package/dist/packem_shared/validate-bindings-wzOGNEFw.mjs +0 -1
- package/dist/packem_shared/worker-entry-checks-DH-ApvvX.mjs +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{applyModify as o}from"../packem_shared/applyModify-DKP2l6S9.mjs";import{reconcileWranglerBindings as a}from"../packem_shared/reconcileWranglerBindings-
|
|
1
|
+
import{applyModify as o}from"../packem_shared/applyModify-DKP2l6S9.mjs";import{reconcileWranglerBindings as a}from"../packem_shared/reconcileWranglerBindings-DAdI2Z-R.mjs";import{assertWranglerSatisfiesSchema as n}from"../packem_shared/assertWranglerSatisfiesSchema-UYsmhXNk.mjs";import{w as s}from"../packem_shared/asset-headers-CPuEX21i.mjs";import{BINDING_MANIFEST_VERSION as m,buildBindingManifest as p}from"../packem_shared/BINDING_MANIFEST_VERSION-CR06-eW7.mjs";import{CLOUDFLARE_CLI_CONFIG_WARNING_ENV as E,detectCloudflareCliConfig as g,warnCloudflareCliConfigOnce as x}from"../packem_shared/CLOUDFLARE_CLI_CONFIG_WARNING_ENV-75Y5zVF8.mjs";import{default as c}from"../packem_shared/CLOUDFLARE_DRIVER-DbmpoIcg.mjs";import{default as _}from"../packem_shared/GLOBAL_FETCH_STRICTLY_PUBLIC_FLAG-f8CnJha3.mjs";import{hasCloudflareCredentials as L}from"../packem_shared/hasCloudflareCredentials-ByCrwaLT.mjs";import{describeWithheld as S,withheldBindings as D}from"../packem_shared/describeWithheld-CbyzZjZF.mjs";import{bindingsNeedingDatabase as W,startLocalHyperdrive as T}from"../packem_shared/bindingsNeedingDatabase-3KyGflIq.mjs";import{readManifest as v,recordManifestKey as B}from"../packem_shared/readManifest-Cighz3WC.mjs";import{HYPERDRIVE_PLACEHOLDER_ID as b}from"../packem_shared/D1_PLACEHOLDER_ID-ZnDjVymH.mjs";import{emitProjectAssetHeaders as h}from"../packem_shared/emitProjectAssetHeaders-6iinmRWE.mjs";import{collectExportGaps as M}from"../packem_shared/collectExportGaps-DHUtghqe.mjs";import{reconcileWranglerCompatibilityDate as w}from"../packem_shared/reconcileWranglerCompatibilityDate-Cj94osA-.mjs";import{describePreservedCrons as H,reconcileWranglerCrons as U}from"../packem_shared/describePreservedCrons-i5XT6rtl.mjs";import{pendingBindingChanges as Y,reconcileBindingsSafely as K,reconcileStudioAssets as j,reconcileWranglerExtras as z}from"../packem_shared/pendingBindingChanges-DqP40pSQ.mjs";import{REMOTE_ELIGIBLE_KEYS as J,injectRemoteFlags as X,isRemoteEnvEnabled as k,materializeDevWranglerConfig as q,planRemoteBindings as Z,resolveRemoteEnabled as $,toRemotePlan as ee}from"../packem_shared/REMOTE_ELIGIBLE_KEYS-D66_hwjD.mjs";import{materializeServiceDevConfigs as oe}from"../packem_shared/materializeServiceDevConfigs-CI1HXv7f.mjs";import{i as ae}from"../packem_shared/studio-assets-BKWx838V.mjs";import{default as ne}from"../packem_shared/CLOUDFLARE_TOOLCHAIN_VERSIONS-DWyZ_2QM.mjs";import{withTailConsumer as se}from"../packem_shared/withTailConsumer-BXOIqXxv.mjs";import{WORKERS_CACHE_MIN_DATE as me,isCacheEnabled as pe}from"../packem_shared/WORKERS_CACHE_MIN_DATE-0k9ABJtF.mjs";import{wranglerCodegenInputs as Ee}from"../packem_shared/wranglerCodegenInputs-Bfe3cN0G.mjs";import{DEFAULT_OBSERVABILITY as xe,resolveObservabilitySampling as Ce}from"../packem_shared/DEFAULT_OBSERVABILITY-CPLADr5u.mjs";import{mergeWranglerEnvironment as Re}from"../packem_shared/mergeWranglerEnvironment-D5ekKj5x.mjs";import{WRANGLER_FILES as Ie,findWranglerFile as Le,readWranglerJsonc as Ae}from"../packem_shared/WRANGLER_FILES-BF8PUjuo.mjs";import{UNEXPORTED_CLASS_MARKER as De,validateWranglerProject as Oe}from"../packem_shared/UNEXPORTED_CLASS_MARKER-Cfi7PRg1.mjs";import{scanWranglerVariablesForSecrets as Te}from"../packem_shared/scanWranglerVariablesForSecrets-BQIPpHpH.mjs";import{wranglerToAlchemy as ve}from"../packem_shared/wranglerToAlchemy-CBO2ucRm.mjs";import{REQUIRED_COMPATIBILITY_DATE as Fe,REQUIRED_FLAG as be,validateWrangler as ue,validateWranglerConfig as he}from"../packem_shared/REQUIRED_COMPATIBILITY_DATE-GjaJU_-D.mjs";export{m as BINDING_MANIFEST_VERSION,E as CLOUDFLARE_CLI_CONFIG_WARNING_ENV,c as CLOUDFLARE_DRIVER,ne as CLOUDFLARE_TOOLCHAIN_VERSIONS,xe as DEFAULT_OBSERVABILITY,_ as GLOBAL_FETCH_STRICTLY_PUBLIC_FLAG,b as HYPERDRIVE_PLACEHOLDER_ID,J as REMOTE_ELIGIBLE_KEYS,Fe as REQUIRED_COMPATIBILITY_DATE,be as REQUIRED_FLAG,De as UNEXPORTED_CLASS_MARKER,me as WORKERS_CACHE_MIN_DATE,Ie as WRANGLER_FILES,o as applyModify,n as assertWranglerSatisfiesSchema,W as bindingsNeedingDatabase,p as buildBindingManifest,M as collectExportGaps,H as describePreservedCrons,S as describeWithheld,g as detectCloudflareCliConfig,h as emitProjectAssetHeaders,Le as findWranglerFile,L as hasCloudflareCredentials,X as injectRemoteFlags,pe as isCacheEnabled,ae as isOwnedStudioAssets,k as isRemoteEnvEnabled,q as materializeDevWranglerConfig,oe as materializeServiceDevConfigs,Re as mergeWranglerEnvironment,Y as pendingBindingChanges,Z as planRemoteBindings,v as readManifest,Ae as readWranglerJsonc,K as reconcileBindingsSafely,j as reconcileStudioAssets,a as reconcileWranglerBindings,w as reconcileWranglerCompatibilityDate,U as reconcileWranglerCrons,z as reconcileWranglerExtras,B as recordManifestKey,Ce as resolveObservabilitySampling,$ as resolveRemoteEnabled,Te as scanWranglerVariablesForSecrets,T as startLocalHyperdrive,ee as toRemotePlan,ue as validateWrangler,he as validateWranglerConfig,Oe as validateWranglerProject,x as warnCloudflareCliConfigOnce,se as withTailConsumer,D as withheldBindings,Ee as wranglerCodegenInputs,ve as wranglerToAlchemy,s as writeAssetHeaders};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{existsSync as d,readFileSync as y}from"node:fs";import{join as s,isAbsolute as a,relative as m}from"node:path";import{LunoraError as p}from"@lunora/errors";import{classifyPolicyEdit as k,scaffoldPolicyFile as h,resolveServerModule as l,wireRlsIntoProcedure as v}from"./classifyPolicyEdit-DJi9Fk8G.mjs";import{w as c,r as b}from"./write-atomic-
|
|
1
|
+
import{existsSync as d,readFileSync as y}from"node:fs";import{join as s,isAbsolute as a,relative as m}from"node:path";import{LunoraError as p}from"@lunora/errors";import{classifyPolicyEdit as k,scaffoldPolicyFile as h,resolveServerModule as l,wireRlsIntoProcedure as v}from"./classifyPolicyEdit-DJi9Fk8G.mjs";import{w as c,r as b}from"./write-atomic-BD9yan7c.mjs";const D="/__lunora/policy-scaffold",u=r=>r==="unknown-procedure"?404:r==="already-wired"||r==="destructive"?409:422,f=(r,o,e)=>{let t;try{t=b(r,o)}catch(n){return{body:{error:n instanceof Error?n.message:String(n),ok:!1},status:500}}return{body:{...e,diagnostics:t,ok:!0},status:200}},g=r=>({body:{edit:r,message:"Rewriting an existing policy predicate changes evaluation semantics and must be done by hand. The scaffolder only adds new, deny-by-default rules.",needsManualEdit:!0,ok:!1},status:409}),w=(r,o)=>{const e=h(o,l(r.projectRoot));if(!e.ok)return{body:{error:e.reason,ok:!1},status:u(e.reason)};const t=r.schemaDirectory??"lunora",n=s(r.projectRoot,t,e.fileName);return d(n)?{body:{error:"file-exists",fileName:e.fileName,ok:!1},status:409}:(c(n,e.source),f(r,{path:n,text:e.source},{fileName:e.fileName}))},R=(r,o,e)=>{if(typeof e!="string"||e.length===0||a(e)||e.includes("\\"))return;const t=s(r,o),n=s(t,`${e}.ts`),i=m(t,n);if(!(i.startsWith("..")||a(i)))return n},N=(r,o)=>{const e=R(r.projectRoot,r.schemaDirectory??"lunora",o.filePath);if(e===void 0||!d(e))return{body:{error:"unknown-procedure",ok:!1},status:404};const t=v(y(e,"utf8"),o,l(r.projectRoot));return t.ok?(c(e,t.text),f(r,{path:e,text:t.text},{exportName:o.exportName})):{body:{error:t.reason,ok:!1},status:u(t.reason)}},E=r=>{if(r.method!=="POST")return{body:{error:"method-not-allowed",ok:!1},status:405};const{body:o}=r;if(o==null||typeof o!="object"||typeof o.kind!="string")return{body:{error:"invalid-edit",ok:!1},status:400};const e=o;if(k(e)==="destructive")return g(e);if(e.kind==="scaffoldPolicy")return w(r,e);if(e.kind==="wireRls")return N(r,e);throw new p("INTERNAL",`unhandled additive policy edit kind: ${String(e.kind)}`)};export{D as POLICY_SCAFFOLD_ENDPOINT,E as handlePolicyScaffoldRequest};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{MERGED_DURABLE_OBJECT as p}from"./COMPOSED_WORKER_ENTRY-LpLlp-aF.mjs";import{o as R,v as S,b as I,c as j,d as A,e as L,g as f,h as k,i as B,H as C,j as N,R as T,S as w,k as q,l as U,W as G,m as P}from"./validate-bindings-
|
|
1
|
+
import{MERGED_DURABLE_OBJECT as p}from"./COMPOSED_WORKER_ENTRY-LpLlp-aF.mjs";import{o as R,v as S,b as I,c as j,d as A,e as L,g as f,h as k,i as B,H as C,j as N,R as T,S as w,k as q,l as U,W as G,m as P}from"./validate-bindings-DSMH8bRQ.mjs";import{b as u,p as g,c as _}from"./studio-assets-BKWx838V.mjs";import{validateTailConsumers as W,validateSendEmail as K,validateSecretsRequired as M,validateLogpush as V,validateLimits as x,validatePlacement as H,validateObservability as Q,validateAssets as F,validateCache as Y,validateExports as J,validateCorsVariables as z,validateSchedulerOrigin as X}from"./withTailConsumer-BXOIqXxv.mjs";import{isCacheEnabled as Z,WORKERS_CACHE_MIN_DATE as E}from"./WORKERS_CACHE_MIN_DATE-0k9ABJtF.mjs";import{mergeWranglerEnvironment as ee}from"./mergeWranglerEnvironment-D5ekKj5x.mjs";const v=t=>u(t)?new Set([...g(t.producers).map(i=>i.queue),...g(t.consumers).flatMap(i=>[i.queue,i.dead_letter_queue])].filter(i=>_(i))):new Set,b=(t,i,n)=>{const e=u(t)?t.account_id:void 0;return _(e)?e:_(i.account_id)?i.account_id:_(n)?n:void 0},te=(t,i,n,e=process.env.CLOUDFLARE_ACCOUNT_ID)=>{if(i===void 0||!u(t.env))return;const a=t.env[i],r=v(u(a)?a.queues:void 0);if(r.size===0)return;const s=b(a,t,e),m=[{account:b(void 0,t,e),names:v(t.queues),scope:"the top level"},...Object.entries(t.env).filter(([c])=>c!==i).map(([c,o])=>({account:b(o,t,e),names:v(u(o)?o.queues:void 0),scope:`env.${c}`}))].filter(c=>s===void 0||c.account===void 0||c.account===s);for(const c of r){const o=m.filter(({names:l})=>l.has(c)).map(({scope:l})=>l);o.length>0&&n.push(`env.${i}.queues names queue "${c}", which ${o.join(" and ")} also ${o.length===1?"names":"name"}. Queue names are unique per Cloudflare account, so deployed to one account the environments share that queue: messages produced in one are consumed by the other. Give env.${i} its own name (e.g. "${c}-${i}") unless the sharing is intended — the renamed queue starts empty, and messages already in "${c}" stay there.`)}},ie=t=>typeof t=="object"&&t!==null&&!Array.isArray(t),O=t=>Array.isArray(t)?t.flatMap((i,n)=>ie(i)?[[n,i]]:[]):[],y=t=>typeof t.binding=="string"?t.binding:"",se=(t,i,n)=>{for(const[e,a]of O(t.kv_namespaces))typeof a.id=="string"&&a.id!==""||n.push(`kv_namespaces[${String(e)}] ("${y(a)}") is not created yet and the schema pins data to "${i}" — create it with \`wrangler kv namespace create <name> --jurisdiction=${i}\`; a namespace's jurisdiction cannot be changed afterwards`)},ae=(t,i,n)=>{for(const[e,a]of O(t.r2_buckets)){const r=a.jurisdiction;if(r===i)continue;const s=typeof r=="string"?`names the "${r}" jurisdiction`:"names no jurisdiction";n.push(`r2_buckets[${String(e)}] ("${y(a)}") ${s}, but the schema pins data to "${i}" — create the bucket with \`wrangler r2 bucket create <name> --jurisdiction=${i}\` and set "jurisdiction": "${i}" on the binding`)}},ne=(t,i,n)=>{const e=i?.jurisdiction;e!==void 0&&(se(t,e,n),ae(t,e,n))},D="2026-04-07",me="web_socket_auto_reply_to_close",h="2026-10-01",$="durable_object_io_tasks_prevent_eviction",oe="durable_object_io_tasks_do_not_prevent_eviction",re=/^\d{4}-\d{2}-\d{2}$/,ce=(t,i,n)=>{t>=h||i.includes($)||i.includes(oe)||n.push(`compatibility_date "${t}" predates "${h}", 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 >= "${h}" or add the "${$}" compatibility flag`)},de=(t,i,n)=>{const{error:e,merged:a,unverifiedKeys:r}=ee(t,i);return e!==void 0?{error:e,wrangler:a}:(r.length>0&&n.push(`env.${String(i)} overrides ${r.join(", ")}, which this validator doesn't have a verified inheritance rule for — validated against the TOP-LEVEL value only. Double-check ${r.length===1?"it":"them"} by hand for "${String(i)}".`),{wrangler:a})},le=(t,i,n)=>{const e=[],a=[];if(!t||typeof t!="object")return e.push("wrangler config is not a valid object"),{errors:e,valid:!1,warnings:a};const{error:r,wrangler:s}=de(t,n,a);if(r!==void 0)return e.push(r),{errors:e,valid:!1,warnings:a};R(s.durable_objects?.bindings).find(d=>d.name==="SHARD"&&(d.class_name==="ShardDO"||d.class_name===p))||e.push(`durable_objects.bindings must include { "name": "SHARD", "class_name": "ShardDO" } (or "${p}" when the app merges its Durable Objects) — your dev server auto-reconciles this on startup, or add the binding manually`),S(s,e);const o=s.compatibility_date??"",l=re.test(o);o&&!l?e.push(`compatibility_date must be in YYYY-MM-DD format (got "${o}")`):o<D&&e.push(`compatibility_date must be >= "${D}" (got "${o||"<missing>"}")`),Z(s)&&l&&o<E&&e.push(`cache.enabled requires compatibility_date >= "${E}" (got "${o||"<missing>"}")`),l&&ce(o,s.compatibility_flags??[],a),I(s,i,e),ne(s,i,a),j(s,e),A(s,i?.vectorIndexNames??[],e),W(s,e),L(s,e,a),f(s.workflows,"workflows",G,e),k(s,e),B(s,e),te(t,n,a),f(s.secrets_store_secrets,"secrets_store_secrets",P,e);for(const d of C)N(s,d,e,a);for(const d of T)f(s[d.key],d.key,d,e);for(const d of w)q(s,d,e);return U(s,e),K(s,e,a),M(s,e),V(s,e),x(s,e),H(s,e),Q(s,e,a),F(s,e),Y(s,e),J(s,e),z(s,e),X(s,n,a),{errors:e,valid:e.length===0,warnings:a}},pe=le;export{D as REQUIRED_COMPATIBILITY_DATE,me as REQUIRED_FLAG,pe as validateWrangler,le as validateWranglerConfig};
|
package/dist/packem_shared/{SCHEMA_EDIT_ENDPOINT-065ZVpOZ.mjs → SCHEMA_EDIT_ENDPOINT-Dbdgz4G6.mjs}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{existsSync as a,readFileSync as d}from"node:fs";import{classifyEdit as l,applyAdditiveEdit as c}from"./applyAdditiveEdit-DEwPKcJg.mjs";import{parseSchema as u}from"./parseSchema-D1Wbr1qv.mjs";import{w as f,r as p}from"./write-atomic-
|
|
1
|
+
import{existsSync as a,readFileSync as d}from"node:fs";import{classifyEdit as l,applyAdditiveEdit as c}from"./applyAdditiveEdit-DEwPKcJg.mjs";import{parseSchema as u}from"./parseSchema-D1Wbr1qv.mjs";import{w as f,r as p}from"./write-atomic-BD9yan7c.mjs";import{join as m}from"node:path";const F="/__lunora/schema-edit",b=t=>t==="destructive"||t==="duplicate-table"||t==="duplicate-column"||t==="duplicate-index"?409:t==="unknown-table"?404:t==="invalid-identifier"||t==="invalid-validator"?400:422,y=t=>({body:{error:t.reason,ok:!1},status:422}),k=t=>{if(!a(t))return{response:{body:{error:"no-schema-file",ok:!1},status:404}};const e=u(d(t,"utf8"));return e.ok?{tables:e.tables}:{response:y(e)}},g=t=>({body:{edit:t,message:"This edit changes stored data and must go through a migration. Review the migration before applying.",needsMigration:!0,ok:!1},status:409}),h=(t,e)=>{const r=t.body;if(r==null||typeof r!="object"||typeof r.kind!="string")return{body:{error:"invalid-edit",ok:!1},status:400};if(l(r)==="destructive")return g(r);if(!a(e))return{body:{error:"no-schema-file",ok:!1},status:404};const o=c(d(e,"utf8"),r);if(!o.ok)return{body:{error:o.reason,ok:!1},status:b(o.reason)};f(e,o.text);let i;try{i=p(t,{path:e,text:o.text})}catch(s){return{body:{error:s instanceof Error?s.message:String(s),ok:!1},status:500}}const n=u(o.text);return{body:{diagnostics:i,ok:!0,tables:n.ok?n.tables:[]},status:200}},R=t=>{const e=m(t.projectRoot,t.schemaDirectory??"lunora","schema.ts");if(t.method==="GET"){const r=k(e);return"response"in r?r.response:{body:{ok:!0,tables:r.tables},status:200}}return t.method==="POST"?h(t,e):{body:{error:"method-not-allowed",ok:!1},status:405}};export{F as SCHEMA_EDIT_ENDPOINT,R as handleSchemaEditRequest};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{resolveAdminToken as A}from"./devVariablesStamp-BQkGEn9d.mjs";import{handleAdvisorProceduresRequest as I,ADVISOR_PROCEDURES_ENDPOINT as O}from"./ADVISOR_PROCEDURES_ENDPOINT-BPnqzAgT.mjs";import{sendStudioDocument as _,sendStudioAsset as h}from"./sendStudioAsset-B81Pex91.mjs";import{isStandaloneModulePath as y,studioAssetsStamp as N,loadStudioAssets as E,readStandaloneAsset as H,assetContentType as R}from"./assetContentType-CUb5bpbI.mjs";import v from"./createStudioDocumentCache-XBG1aWbl.mjs";import{detectAgentRules as C}from"./AGENT_RULES_DIR-Bd6JPtNa.mjs";import{handlePolicyScaffoldRequest as L,POLICY_SCAFFOLD_ENDPOINT as b}from"./POLICY_SCAFFOLD_ENDPOINT-
|
|
1
|
+
import{resolveAdminToken as A}from"./devVariablesStamp-BQkGEn9d.mjs";import{handleAdvisorProceduresRequest as I,ADVISOR_PROCEDURES_ENDPOINT as O}from"./ADVISOR_PROCEDURES_ENDPOINT-BPnqzAgT.mjs";import{sendStudioDocument as _,sendStudioAsset as h}from"./sendStudioAsset-B81Pex91.mjs";import{isStandaloneModulePath as y,studioAssetsStamp as N,loadStudioAssets as E,readStandaloneAsset as H,assetContentType as R}from"./assetContentType-CUb5bpbI.mjs";import v from"./createStudioDocumentCache-XBG1aWbl.mjs";import{detectAgentRules as C}from"./AGENT_RULES_DIR-Bd6JPtNa.mjs";import{handlePolicyScaffoldRequest as L,POLICY_SCAFFOLD_ENDPOINT as b}from"./POLICY_SCAFFOLD_ENDPOINT-uPZXZrU7.mjs";import x from"./renderStudioHtml-CRDTNivi.mjs";import{handleSchemaEditRequest as $,SCHEMA_EDIT_ENDPOINT as k}from"./SCHEMA_EDIT_ENDPOINT-Dbdgz4G6.mjs";import{handleSeedRequest as U,SEED_ENDPOINT as g}from"./SEED_ENDPOINT-C1fhrehH.mjs";import{serveJsonHandler as j}from"./serveJsonHandler-B8_GE6QC.mjs";import{transportRejectionReason as F}from"./ALLOW_FORWARDED_ENV-BUndghJx.mjs";import"./STUDIO_WRITE_TEMP_SUFFIX-BTTELz3K.mjs";const i="/__lunora",M=`${i}/studio.js`,m=`${i}/styles.css`,P=/\/$/,q={[b]:L,[k]:$,[g]:U,[O]:I},w=new Set(["127.0.0.1","::1","localhost"]),st=t=>t!==void 0&&t!==!1&&!w.has(t),T=t=>t===void 0||t==="/"?"":t.replace(P,""),nt=t=>`${T(t)}${i}`,B=t=>{try{return new URL(t,"http://localhost").pathname}catch{const d=t.indexOf("?");return d===-1?t:t.slice(0,d)}},at=t=>{const{logger:d,projectRoot:c}=t,u=T(t.base);let l,S;const p=v(c,()=>x({adminToken:A(c),advisorProcedures:!0,basePath:i,dataEditable:!0,rulesInstalled:C(c).installed,runAsIdentity:!0,schemaEditable:!0,scriptSrc:M,styleHref:m})),D=(s,o,e)=>{const n=N();if((l===void 0||n!==S)&&(l=E(d),S=n),l===void 0){e.statusCode=501,e.setHeader("Content-Type","text/plain"),e.end("Lunora studio assets not found — install and build @lunora/studio.");return}const a=s===m,r=s.slice(s.lastIndexOf("/")+1);if(a){h(o,e,l.styles,"text/css; charset=utf-8",r,n);return}const f=H(r);if(f===void 0){e.statusCode=404,e.setHeader("Content-Type","text/plain"),e.end("Not found");return}h(o,e,f,R(r),r,n)};return(s,o,e)=>{const n=B(s.url??"").replace(P,""),a=u!==""&&n.startsWith(u)?n.slice(u.length):n;if(a!==i&&!a.startsWith(`${i}/`)){e();return}if(t.isNonLoopbackBind||F(s,d)!==void 0){o.statusCode=403,o.setHeader("Content-Type","text/plain"),o.end("Lunora studio is only available on loopback hosts in dev.");return}const r=q[a];if(r!==void 0){j(s,o,r,c,{apiSpec:t.apiSpec,lazyFunctions:t.lazyFunctions,schemaDirectory:t.schemaDirectory});return}if(a===m||y(a)){D(a,s,o);return}_(o,p())}};export{i as STUDIO_PATH,M as STUDIO_SCRIPT_PATH,m as STUDIO_STYLE_PATH,at as createStudioMiddleware,st as isNonLoopbackHost,B as requestPathname,nt as studioMountPath};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{existsSync as d}from"node:fs";import{dirname as y,join as h}from"node:path";import{discoverSchemaInfo as v}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 E,GENERATED_CLASS_MODULES as $,isFrameworkDurableObject as k}from"./COMPOSED_WORKER_ENTRY-LpLlp-aF.mjs";import{l as D,r as R,a as j,i as x}from"./studio-assets-BKWx838V.mjs";import{o as O,f as A}from"./validate-bindings-DSMH8bRQ.mjs";import{validateSchedulerOrigin as _}from"./withTailConsumer-BXOIqXxv.mjs";import{mergeWranglerEnvironment as S}from"./mergeWranglerEnvironment-D5ekKj5x.mjs";import{findWranglerFile as W,readWranglerJsonc as C}from"./WRANGLER_FILES-BF8PUjuo.mjs";import{validateWranglerConfig as T}from"./REQUIRED_COMPATIBILITY_DATE-GjaJU_-D.mjs";const b=r=>Array.isArray(r)?r:[],L=(r,o,t)=>Object.entries(r?.images??{}).flatMap(([s,n])=>{const e=n?.dockerfile;return typeof e!="string"||d(e.startsWith("/")?e:h(o,e))?[]:[`containers images["${s}"] dockerfile "${e}" does not exist (resolved relative to ${t}); create the Dockerfile`]}),I=(r,o)=>{const t=r?.directory;if(typeof t!="string"||t.length===0||d(t.startsWith("/")?t:h(o,t)))return[];const s=x(r)?"it holds the Studio documents `lunora codegen` writes; run codegen before deploy":"it is created by the client build; run the build before deploy";return[`assets.directory "${t}" does not exist yet — ${s}`]},P=(r,o,t)=>{const s=[];for(const n of b(r)){const e=n?.image;typeof e=="string"&&(e.startsWith("./")||e.startsWith("../")||e.startsWith("/")||e.includes("Dockerfile"))&&!d(e.startsWith("/")?e:h(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},B=(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(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=j(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",M=(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 ${E.join(", ")}, SchedulerDO when its binding is declared, and every class codegen emits from your ${$.map(s=>`${s}.ts`).join(" / ")} declarations`;return k(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.`},N=(r,o)=>{const t=o.exports;if(t===void 0)return[];const s=[];for(const e of O(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 b(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. ${M(e.className,o)}`)},U=r=>[...A(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.`),H=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.`],ee=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:m}=v(r.projectRoot,o,r.cache),a=T(s,m,r.environment);l!==void 0&&a.warnings.push(`schema parse failed in ${o}/schema.ts: ${l}`);const g=y(t),f=D(e.main,r.projectRoot,t),p=R(f,r.projectRoot,o);return a.errors.push(...P(e.containers??[],g,t)),a.warnings.push(...H(f)),p!==void 0&&a.errors.push(...N(e,p)),p?.exports?.has(i)===!0&&(a.errors.push(...U(e)),d(h(r.projectRoot,o,w,"scheduler.ts"))&&_(e,r.environment,a.warnings,"the merged LunoraDO hosts the scheduler")),a.errors.push(...B(m,r.projectRoot)),a.warnings.push(...I(e.assets,g)),a.valid=a.errors.length===0,{problems:a.errors,report:a,wranglerPath:t}};export{G as UNEXPORTED_CLASS_MARKER,ee 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-
|
|
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-Cfi7PRg1.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/dist/packem_shared/{collectExportGaps-C9awPQMw.mjs → collectExportGaps-DHUtghqe.mjs}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createRequire as ee}from"node:module";import{join as V}from"node:path";import{containerBuildTag as ne}from"@lunora/container";import{readJsonSync as se}from"@visulima/fs";import{c as te}from"./celld-binding-id-9MiUoteo.mjs";import{applyModify as w}from"./applyModify-DKP2l6S9.mjs";import{s as F,
|
|
2
|
-
`,t.offset-1)+1,a=$e.exec(e.slice(o));if(a!==null&&e.slice(i,t.offset).trim()===""){const m=t.parent?.children??[],u=m.indexOf(t),d=u===m.length-1&&u>0?m[u-1]:void 0,c=d===void 0?void 0:Ne.exec(e.slice(d.offset+d.length))??void 0;return(c===void 0||d===void 0?e.slice(0,i):e.slice(0,d.offset+d.length)+e.slice(d.offset+d.length+c[0].length,i))+e.slice(o+a[0].length)}}return w(e,n,void 0)},U=(e,n,s,t,o,i=new Set)=>{const a=s.join("."),m={},u=[],d=[];let c=e;return{entries:n.map((l,v)=>{const g=t(l);if(g===void 0||l.queue===void 0)return l;const f=Object.fromEntries(Object.entries(q(g)).filter(([h])=>!i.has(h))),b=Object.entries(o[l.queue]??{}).filter(([h])=>!Object.hasOwn(f,h)),_=Object.entries(f).filter(([h,y])=>l[h]!==y),x=b.filter(([h,y])=>l[h]===y).map(([h])=>h),E=Object.fromEntries(Object.entries({...l,...f}).filter(([h])=>!x.includes(h)));for(const[h,y]of _)c=w(c,[...s,v,h],y);for(const h of x)c=Ce(c,[...s,v,h]);for(const[h,y]of b){const A=l[h];A!==void 0&&A!==y&&d.push(`${a}/${l.queue}: ${h} is no longer declared by defineQueue, but it was changed by hand to ${JSON.stringify(A)} from the declared ${JSON.stringify(y)}, so it was kept. Delete it from wrangler.jsonc if it should go.`)}return(_.length>0||x.length>0)&&u.push(`${a}/${l.queue} (${[..._.map(([h])=>h),...x.map(h=>`removed ${h}`)].join(", ")})`),Object.keys(f).length>0&&(m[l.queue]=f),E}),owned:m,text:c,updated:u,warnings:d}},Re=(e,n,s,t)=>{const o=n.queues??{},i=o.producers??[],a=o.consumers??[],m=new Set(i.map(g=>g?.binding)),u=new Set(a.map(g=>g.queue)),d=s.filter(g=>!m.has(g.bindingName)),c=s.filter(g=>!u.has(g.name)),p=U(e,a,["queues","consumers"],g=>s.find(f=>f.name===g.queue),t);let l=p.text;const v={...p.owned};if(d.length>0||c.length>0){const g=[...i,...d.map(b=>({binding:b.bindingName,queue:b.name}))],f=[...p.entries,...c.map(b=>({queue:b.name,...b.mode==="pull"?{type:"http_pull"}:{},...q(b)}))];for(const b of c){const _=q(b);Object.keys(_).length>0&&(v[b.name]=_)}l=w(l,["queues"],{consumers:f,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}},Te=(e,n,s,t,o)=>{const i=n.env?.[t],a=i?.queues?.consumers??[],m=i?.queues?.producers??[],u=l=>{const v=m.find(g=>g?.queue===l.queue)?.binding;return v!==void 0?s.find(g=>g.bindingName===v):s.find(g=>g.name===l.queue&&!m.some(f=>f?.binding===g.bindingName))},d=U(e,a,["env",t,"queues","consumers"],u,o,new Set(["dead_letter_queue"])),c=a.filter(l=>l.queue!==void 0&&u(l)===void 0).map(l=>`env.${t}.queues.consumers/${String(l.queue)}: no defineQueue export matches it — this block declares no producer mapping one of their bindings to "${String(l.queue)}", and no export is named that — so it was not retuned. A consumer for a queue another worker produces is skipped the same way.`),p=a.flatMap(l=>{const v=u(l)?.tuning.deadLetterQueue;return v===void 0||l.dead_letter_queue!==void 0?[]:[`env.${t}.queues.consumers/${String(l.queue)}: defineQueue declares deadLetterQueue "${v}", but this consumer has no dead_letter_queue, so its exhausted messages are dropped. Queue names differ per environment, so reconcile does not write it here; add it by hand.`]});return{added:[],owned:d.owned,text:d.text,updated:d.updated,warnings:[...d.warnings,...p,...c]}},Ie=(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?.[P],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.${P}\` 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));ie(e,P,Object.keys(t).length===0?void 0:t)},De="https://api.cloudflare.com/client/v4/accounts/<ACCOUNT_ID>/artifacts/namespaces",qe=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 ${De} 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.`},R="PIPELINES",T="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===R),a=e.usesArtifacts?n?.artifacts??[]:[],m=a.some(d=>d.binding===T)?[]:a.flatMap(d=>d.binding===void 0?[]:[d.binding]);return[[e.usesKv&&(n?.kv_namespaces?.length??0)===0&&(!t||e.jurisdiction!==void 0),e.jurisdiction===void 0?'ctx.kv is used but no kv_namespaces binding exists; add one ({ binding: "KV" }) — wrangler creates the namespace on the first deploy.':`ctx.kv is used and the schema pins data to "${e.jurisdiction}"; run \`wrangler kv namespace create <name> --jurisdiction ${e.jurisdiction}\` and add a kv_namespaces entry ({ binding: "KV", id }) — a namespace wrangler creates on deploy is unrestricted.`],[e.usesHyperdrive&&(n?.hyperdrive?.length??0)===0&&!t,'@lunora/hyperdrive is used but no hyperdrive binding exists; add one ({ binding: "HYPERDRIVE", id }) — on a Cloudflare target `lunora deploy` creates the Hyperdrive config from a connection string.'],[e.usesArtifacts&&a.length===0&&(!t||e.jurisdiction!==void 0),qe(e.jurisdiction)],[i,`ctx.pipelines is used but no "${R}" pipelines binding exists; run 'wrangler pipelines create <name>' and add a 'pipelines' binding ({ binding: "${R}", 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 "${T}"; make sure \`.artifacts()\` on defineApp points ctx.artifacts at it — otherwise it reads env.${T} 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),I=(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,a])=>a?.type==="workflow"?[i]:[]),o=(n.workflows??[]).flatMap(i=>i.class_name===void 0||i.script_name!==void 0?[]:[i.class_name]);return[...new Set([...t,...o])].filter(i=>!s.has(i)).map(i=>`wrangler.jsonc declares workflow "${i}" but no defineWorkflow/defineAgent export generates that class — a leftover from a rename will fail the deploy (wrangler rejects a class the worker does not export). Remove it if it is not hand-wired.`)},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)],G=[{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=()=>G.map(({keys:e,label:n})=>`${e[0]} + ${e[1]} (${n})`).join(" or "),Fe=e=>{let n;try{n=he(V(e,ve),"utf8")}catch{return!1}const s=new Map(we(n).map(t=>[t.key,t.value]));return G.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.`]},j=(e,n,s,t)=>{const o=new Set(e.durableObjects.map(u=>u.className)),i=[],a=(s?.r2_buckets?.length??0)>0,m=(s?.d1_databases?.some(u=>u.binding==="DB")??!1)||e.needsD1;return e.usesStorage&&!a&&i.push("@lunora/storage is used but R2 bucket bindings have user-defined names; add an r2_buckets entry and pass env.<BINDING> to createStorage()."),e.usesAuth&&!o.has("SessionDO")&&!m&&i.push("@lunora/auth is used but the worker entry exports no SessionDO; sessions are D1-backed, or export SessionDO to enable DO-backed sessions."),e.usesScheduler&&!o.has("SchedulerDO")&&i.push("@lunora/scheduler is used but the worker entry exports no SchedulerDO; export it so the SCHEDULER binding can be provisioned."),i.push(...I("container","containers",e.containers),...I("workflow","workflows",e.workflows),...I("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},Ve=e=>[["container","containers",e.containers],["workflow","workflows",e.workflows],["agent","agents",e.agents]].flatMap(([s,t,o])=>o.filter(i=>!i.exported).map(({className:i,exportName:a})=>({className:i,exportName:a,kind:s,module:t}))),Ye=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 C(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[...C(s.new_classes),...C(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 a=e;const m=[];if(i.length>0){const c=[...t,...i.map(p=>({class_name:p.className,name:p.binding}))];a=w(a,["durable_objects","bindings"],c),m.push(...i.map(p=>`${p.binding}/${p.className}`))}const u=n.migrations??[],d=s.map(c=>c.className).filter(c=>!Qe(u).has(c));if(d.length>0){const c=[...u,{new_sqlite_classes:d,tag:Ye(u)}];a=w(a,["migrations"],c)}return{added:m,text:a}},B=e=>e===void 0||e==="cloudflare",Ge=(e,n)=>e.includes("DB (D1)")&&B(n)?[`wrote a DB binding with a placeholder database_id ("${Y}") — 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:Y,database_name:t}];return{added:["DB (D1)"],text:w(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&&xe(n,new Set(["analyticsSql"]))?.chained.has("analyticsSql")!==!0,$=(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 a=k(n,t);return a!==void 0?{added:[],text:e,warnings:[`${s}: not adding the ${o} binding — the name "${t}" is already bound by \`${a}\` in wrangler.jsonc. Rename that binding, then set ${s}.binding by hand.`]}:{added:[o],text:w(e,[s],{binding:t})}},L=(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.`,Ze=(e,n,s)=>{if(!B(s)||(n.hyperdrive?.length??0)>0)return{added:[],text:e};const t=k(n,"HYPERDRIVE");return t!==void 0?{added:[],text:e,warnings:[L("hyperdrive","HYPERDRIVE",t)]}:{added:["HYPERDRIVE (Hyperdrive, created on deploy)"],text:w(e,["hyperdrive"],[{binding:"HYPERDRIVE",id:ae}])}},en=new Set(["celld","cloudflare"]),nn=(e,n,s,t)=>{if(t!==void 0&&!en.has(t)||s!==void 0||(n.kv_namespaces?.length??0)>0)return{added:[],text:e};const o=k(n,"KV");return o!==void 0?{added:[],text:e,warnings:[L("kv_namespaces","KV",o)]}:{added:[t==="celld"?`KV (Workers KV, celld namespace ${te(n.name,"KV")})`:"KV (Workers KV, created on deploy)"],text:w(e,["kv_namespaces"],[{binding:"KV"}])}},sn=(e,n,s,t)=>{if(!B(t)||s!==void 0||(n.artifacts?.length??0)>0)return{added:[],text:e};const o=k(n,"ARTIFACTS");if(o!==void 0)return{added:[],text:e,warnings:[L("artifacts","ARTIFACTS",o)]};const i=typeof n.name=="string"&&n.name.length>0?n.name:"lunora";return{added:["ARTIFACTS (Cloudflare Artifacts)"],text:w(e,["artifacts"],[{binding:"ARTIFACTS",namespace:i}])}},H=(e,n,s,t,o)=>{if((n[s]?.length??0)>0)return{added:[],text:e};const i=k(n,t.binding);return i!==void 0?{added:[],text:e,warnings:[`${s}: not adding ${JSON.stringify(t)} — the name "${t.binding}" is already bound by \`${i}\` in wrangler.jsonc. Add a ${s} entry under another binding name and point the matching \`defineApp()\` override at it.`]}:{added:[o],text:w(e,[s],[t])}},tn=(e,n)=>{const s=n.worker_loaders??[];return s.some(t=>t.binding==="LOADER")?{added:[],text:e}:{added:["LOADER (Worker Loader)"],text:w(e,["worker_loaders"],[...s,{binding:"LOADER"}])}},on=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},an=e=>{const{image:n}=e;return n.kind==="dockerfile"?n.dockerfilePath:n.kind==="registry"?n.reference:ne(e.exportName)},J=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}}},rn=e=>{if(e.schedulingPolicy==="durable_object")return J(e);const{image:n}=e,s={class_name:e.className,image:an(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=on(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},dn=(e,n,s)=>{const t=n.containers??[],o=new Set(t.map(d=>d.class_name)),i=s.filter(d=>!o.has(d.className));let a=i.length===0?e:w(e,["containers"],[...t,...i.map(d=>rn(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"?J(p).images:void 0;v!==void 0&&JSON.stringify(c.images)!==JSON.stringify(v)&&(a=w(a,["containers",d,"images"],v),m.push(`containers/${p.className}.images`))}return{added:i.map(d=>`containers/${d.className}`),text:a,updated:m,warnings:u}},cn=(e,n)=>{if(n.observability!==void 0)return{added:[],text:e};const s=w(e,["observability"],{...Ee});return{added:["observability"],text:s}},ln=(e,n)=>n.upload_source_maps!==void 0?{added:[],text:e}:{added:["upload_source_maps"],text:w(e,["upload_source_maps"],!0)},X=[{minimum:[4,142],name:"wrangler"},{minimum:[1,61],name:"@cloudflare/vite-plugin"}],un=X.map(({minimum:e,name:n})=>`${n}@^${e.join(".")}.0`).join(" "),gn=(e,n)=>{try{const s=ee(V(e,"package.json")).resolve(`${n}/package.json`),[t=0,o=0]=String(se(s).version).split(".").map(Number);return[t,o]}catch{return}},mn=e=>{const n=X.flatMap(({minimum:s,name:t})=>{const o=gn(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 ${un}\`) and re-run.`},pn=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.`]:[]),fn=(e,n,s)=>{let t=e;const o=[],i=[];for(const a of s){const m=n[a.className];if(m?.type==="workflow")for(const{of:u,path:d}of le){const c=u(a),p=Q(m,d),l=`exports/${a.className}.${d.join(".")}`;if(c===void 0){p!==void 0&&i.push(`${l} is set in wrangler.jsonc but defineWorkflow "${a.exportName}" does not declare it — reconcile leaves it in place. Remove it by hand if it was dropped from the definition.`);continue}JSON.stringify(p)!==JSON.stringify(c)&&(t=w(t,["exports",a.className,...d],c),o.push(l))}}return{text:t,updated:o,warnings:i}},bn=(e,n,s,t,o)=>{if(o!==void 0)return{added:[],text:e,warnings:[o]};const i=[...s.map(f=>({settings:de(f),workflow:f})),...t.map(f=>({settings:{},workflow:f}))],a=new Set(i.map(({workflow:f})=>f.className)),m=n.workflows??[],u=m.filter(f=>f.script_name===void 0&&f.class_name!==void 0&&a.has(f.class_name)),d=n.exports??{},c=[],p=[],l=[];let v=e;for(const{settings:f,workflow:b}of i){if(d[b.className]!==void 0&&d[b.className]!==null)continue;const _=u.find(h=>h.class_name===b.className),x=Object.fromEntries(ce.flatMap(h=>{const y=Q(_,[h]);return y===void 0?[]:[[h,y]]})),E=_?.name??b.name;_?.name!==void 0&&_.name!==b.name&&l.push(`workflows/${b.className} is deployed as "${_.name}" but declared as "${b.name}" — its export keeps "${_.name}" so running instances survive. Change the declaration to match, or rename deliberately (it starts a new, empty workflow).`),v=w(v,["exports",b.className],{type:"workflow",...x,...f,name:E}),(_===void 0?c:p).push(`exports/${b.className}`)}if(u.length>0){const f=m.filter(b=>!u.includes(b));v=w(v,["workflows"],f.length===0?void 0:f),p.push(...u.map(b=>`workflows/${String(b.class_name)} → exports`))}l.push(...pn(n));const g=fn(v,d,s);return{added:c,text:g.text,updated:[...p,...g.updated],warnings:[...l,...g.warnings]}},Pn=(e,n,{environment:s,target:t}={})=>{const o=Ae(e),i=Ve(n);if(!o)return{added:[],exportGaps:i,reason:"wrangler.jsonc not found",updated:[],warnings:j(n,e)};const{parsed:a,text:m}=Oe(o);if(a===void 0)return{added:[],exportGaps:i,reason:`failed to parse ${o} as JSONC`,updated:[],warnings:j(n,e),wranglerPath:o};const u=j(n,e,a,t);if(s!==void 0){const r=a.env?.[s]!==void 0;u.push(r?`auto-provisioned bindings are written to the top level of wrangler.jsonc only (queue consumers "env.${s}" already declares are retuned, nothing is added) — "env.${s}" has its own (non-inheritable) bindings and must be reconciled by hand; \`lunora deploy --env ${s}\` now validates them, so a gap here will be reported at deploy time.`:`--env "${s}" was requested but wrangler.jsonc declares no "env.${s}" block — auto-provisioned bindings are written to the top level only and will not apply to that environment.`)}const d=n.containers.filter(r=>r.exported),c=n.agents.filter(r=>r.exported&&r.voice===!0&&r.voiceBindingName!==void 0&&r.voiceClassName!==void 0),p=[...n.durableObjects,...d.map(r=>({binding:r.bindingName,className:r.className})),...c.map(r=>({binding:r.voiceBindingName,className:r.voiceClassName}))],l=n.workflows.filter(r=>r.exported),v=n.agents.filter(r=>r.exported),g=oe(e),f=Ie(g,u),b={},_=me(g);let x,E={unwritten:{},written:{}};const h=[{enabled:!0,run:r=>Ue(r,a,p)},{enabled:n.needsD1,run:r=>Je(r,a)},{enabled:n.usesKv,run:r=>nn(r,a,n.jurisdiction,t)},{enabled:n.usesHyperdrive,run:r=>Ze(r,a,t)},{enabled:n.usesArtifacts,run:r=>sn(r,a,n.jurisdiction,t)},{enabled:n.usesAi,run:r=>$(r,a,"ai")},{enabled:n.usesAiSearch,run:r=>H(r,a,"ai_search_namespaces",{binding:"AI_SEARCH",namespace:"default"},"AI_SEARCH (AI Search namespace)")},{enabled:ze(n,e),run:r=>$(r,a,"analytics")},{enabled:n.usesBrowser,run:r=>$(r,a,"browser")},{enabled:n.usesImages,run:r=>$(r,a,"images")},{enabled:n.usesAnalytics,run:r=>H(r,a,"analytics_engine_datasets",{binding:"ANALYTICS",dataset:"ANALYTICS"},"ANALYTICS (Analytics Engine)")},{enabled:n.usesWorkerLoader,run:r=>tn(r,a)},{enabled:!0,run:r=>cn(r,a)},{enabled:t===void 0||t==="cloudflare",run:r=>ln(r,a)},{enabled:(t===void 0||t==="cloudflare")&&n.workerRoutes!==void 0,run:r=>re(r,a,n.workerRoutes??[],g,Se(e),F(e,a,t))},{enabled:d.length>0,run:r=>dn(r,a,d)},{enabled:l.length>0||v.length>0,run:r=>bn(r,a,l,v,mn(e))},{enabled:n.queues.length>0,run:r=>{const S=Re(r,a,n.queues,f.queues??{});return b.queues=S.owned,{...S,record:{consequence:"an option removed from defineQueue stays deployed",key:"queueTuning",label:"queue tuning",write:N=>{je(N,f,b)}}}}},{enabled:n.services!==void 0&&(n.services.length>0||Object.keys(_).length>0),run:r=>{const S=pe(r,a,n.services??[],_);return x=S.owned,{...S,record:{consequence:"a service removed from lunora.config stays bound",key:"services",label:"service bindings",write:(N,{devConfigWritten:Z})=>{be(N,{...x,...Z?E.written:E.unwritten})}}}}},...s===void 0||a.env?.[s]===void 0?[]:[{enabled:n.queues.length>0,run:r=>{const S=`env.${s}.queues`,O=Te(r,a,n.queues,s,f[S]??{});return b[S]=O.owned,O}}]];let y=m;const A=[],W=[],M=[];for(const r of h){if(!r.enabled)continue;const S=r.run(y);y=S.text,A.push(...S.added),W.push(...S.updated??[]),u.push(...S.warnings??[]),M.push(...[S.record].filter(O=>O!==void 0))}let K;if(n.services!==void 0){const r=fe(e,n.services,_);u.push(...r.warnings),E={unwritten:r.previouslyOwned,written:r.owned},K=r}u.push(...Ge(A,t));const z=F(e,a,t)?.directory;return{added:A,devConfig:K,edit:{assetsDirectory:z,manifest:g,original:m,records:M,text:y},exportGaps:i,updated:W,warnings:u,wranglerPath:o}};export{Ve as collectExportGaps,Pn as planWranglerBindings};
|
|
1
|
+
import{createRequire as ee}from"node:module";import{join as V}from"node:path";import{containerBuildTag as ne}from"@lunora/container";import{readJsonSync as se}from"@visulima/fs";import{c as te}from"./celld-binding-id-9MiUoteo.mjs";import{applyModify as w}from"./applyModify-DKP2l6S9.mjs";import{s as F,d as k,a as ie}from"./studio-assets-BKWx838V.mjs";import{recordManifestKey as oe,readManifest as ae}from"./readManifest-Cighz3WC.mjs";import{D1_PLACEHOLDER_ID as Y,HYPERDRIVE_PLACEHOLDER_ID as re}from"./D1_PLACEHOLDER_ID-ZnDjVymH.mjs";import{n as de,w as ce,p as le,s as Q,o as D,q as C,t as ue}from"./validate-bindings-DSMH8bRQ.mjs";import{parseTree as ge,findNodeAtLocation as me}from"jsonc-parser";import{r as pe,a as fe,p as be,b as he}from"./reconcile-services-CjgIJKim.mjs";import{readFileSync as ve}from"node:fs";import{DEV_VARS_FILE as we,parseDevVariableEntries as _e}from"./DEV_VARS_EXAMPLE_FILE-hBT89IXh.mjs";import{secretSourcesFromBindings as ye}from"./inferLunoraBindings-Biq1OW9V.mjs";import{requiredSecrets as Se}from"./buildPackageSecretsBlock-DrSD60vH.mjs";import{a as xe}from"./spa-assets-wX8rTPEQ.mjs";import{DEFAULT_OBSERVABILITY as Ee}from"./DEFAULT_OBSERVABILITY-CPLADr5u.mjs";import{findWranglerFile as Ae,readWranglerJsonc as Oe}from"./WRANGLER_FILES-BF8PUjuo.mjs";const ke=[["maxBatchSize","max_batch_size"],["maxBatchTimeout","max_batch_timeout"],["maxConcurrency","max_concurrency"],["maxRetries","max_retries"],["deadLetterQueue","dead_letter_queue"],["retryDelay","retry_delay"]],q=e=>Object.fromEntries(ke.filter(([n])=>e.tuning[n]!==void 0).map(([n,s])=>[s,e.tuning[n]])),P="queueTuning",$e=/^[\t ]*(?:,[\t ]*)?(?:\/\/[^\n\r]*)?\r?\n/u,Ne=/^[\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,a=$e.exec(e.slice(o));if(a!==null&&e.slice(i,t.offset).trim()===""){const m=t.parent?.children??[],u=m.indexOf(t),d=u===m.length-1&&u>0?m[u-1]:void 0,c=d===void 0?void 0:Ne.exec(e.slice(d.offset+d.length))??void 0;return(c===void 0||d===void 0?e.slice(0,i):e.slice(0,d.offset+d.length)+e.slice(d.offset+d.length+c[0].length,i))+e.slice(o+a[0].length)}}return w(e,n,void 0)},U=(e,n,s,t,o,i=new Set)=>{const a=s.join("."),m={},u=[],d=[];let c=e;return{entries:n.map((l,v)=>{const g=t(l);if(g===void 0||l.queue===void 0)return l;const f=Object.fromEntries(Object.entries(q(g)).filter(([h])=>!i.has(h))),b=Object.entries(o[l.queue]??{}).filter(([h])=>!Object.hasOwn(f,h)),_=Object.entries(f).filter(([h,y])=>l[h]!==y),x=b.filter(([h,y])=>l[h]===y).map(([h])=>h),E=Object.fromEntries(Object.entries({...l,...f}).filter(([h])=>!x.includes(h)));for(const[h,y]of _)c=w(c,[...s,v,h],y);for(const h of x)c=Ce(c,[...s,v,h]);for(const[h,y]of b){const A=l[h];A!==void 0&&A!==y&&d.push(`${a}/${l.queue}: ${h} is no longer declared by defineQueue, but it was changed by hand to ${JSON.stringify(A)} from the declared ${JSON.stringify(y)}, so it was kept. Delete it from wrangler.jsonc if it should go.`)}return(_.length>0||x.length>0)&&u.push(`${a}/${l.queue} (${[..._.map(([h])=>h),...x.map(h=>`removed ${h}`)].join(", ")})`),Object.keys(f).length>0&&(m[l.queue]=f),E}),owned:m,text:c,updated:u,warnings:d}},Re=(e,n,s,t)=>{const o=n.queues??{},i=o.producers??[],a=o.consumers??[],m=new Set(i.map(g=>g?.binding)),u=new Set(a.map(g=>g.queue)),d=s.filter(g=>!m.has(g.bindingName)),c=s.filter(g=>!u.has(g.name)),p=U(e,a,["queues","consumers"],g=>s.find(f=>f.name===g.queue),t);let l=p.text;const v={...p.owned};if(d.length>0||c.length>0){const g=[...i,...d.map(b=>({binding:b.bindingName,queue:b.name}))],f=[...p.entries,...c.map(b=>({queue:b.name,...b.mode==="pull"?{type:"http_pull"}:{},...q(b)}))];for(const b of c){const _=q(b);Object.keys(_).length>0&&(v[b.name]=_)}l=w(l,["queues"],{consumers:f,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}},Te=(e,n,s,t,o)=>{const i=n.env?.[t],a=i?.queues?.consumers??[],m=i?.queues?.producers??[],u=l=>{const v=m.find(g=>g?.queue===l.queue)?.binding;return v!==void 0?s.find(g=>g.bindingName===v):s.find(g=>g.name===l.queue&&!m.some(f=>f?.binding===g.bindingName))},d=U(e,a,["env",t,"queues","consumers"],u,o,new Set(["dead_letter_queue"])),c=a.filter(l=>l.queue!==void 0&&u(l)===void 0).map(l=>`env.${t}.queues.consumers/${String(l.queue)}: no defineQueue export matches it — this block declares no producer mapping one of their bindings to "${String(l.queue)}", and no export is named that — so it was not retuned. A consumer for a queue another worker produces is skipped the same way.`),p=a.flatMap(l=>{const v=u(l)?.tuning.deadLetterQueue;return v===void 0||l.dead_letter_queue!==void 0?[]:[`env.${t}.queues.consumers/${String(l.queue)}: defineQueue declares deadLetterQueue "${v}", but this consumer has no dead_letter_queue, so its exhausted messages are dropped. Queue names differ per environment, so reconcile does not write it here; add it by hand.`]});return{added:[],owned:d.owned,text:d.text,updated:d.updated,warnings:[...d.warnings,...p,...c]}},Ie=(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?.[P],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.${P}\` 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));oe(e,P,Object.keys(t).length===0?void 0:t)},De="https://api.cloudflare.com/client/v4/accounts/<ACCOUNT_ID>/artifacts/namespaces",qe=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 ${De} 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.`},R="PIPELINES",T="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===R),a=e.usesArtifacts?n?.artifacts??[]:[],m=a.some(d=>d.binding===T)?[]:a.flatMap(d=>d.binding===void 0?[]:[d.binding]);return[[e.usesKv&&(n?.kv_namespaces?.length??0)===0&&(!t||e.jurisdiction!==void 0),e.jurisdiction===void 0?'ctx.kv is used but no kv_namespaces binding exists; add one ({ binding: "KV" }) — wrangler creates the namespace on the first deploy.':`ctx.kv is used and the schema pins data to "${e.jurisdiction}"; run \`wrangler kv namespace create <name> --jurisdiction ${e.jurisdiction}\` and add a kv_namespaces entry ({ binding: "KV", id }) — a namespace wrangler creates on deploy is unrestricted.`],[e.usesHyperdrive&&(n?.hyperdrive?.length??0)===0&&!t,'@lunora/hyperdrive is used but no hyperdrive binding exists; add one ({ binding: "HYPERDRIVE", id }) — on a Cloudflare target `lunora deploy` creates the Hyperdrive config from a connection string.'],[e.usesArtifacts&&a.length===0&&(!t||e.jurisdiction!==void 0),qe(e.jurisdiction)],[i,`ctx.pipelines is used but no "${R}" pipelines binding exists; run 'wrangler pipelines create <name>' and add a 'pipelines' binding ({ binding: "${R}", 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 "${T}"; make sure \`.artifacts()\` on defineApp points ctx.artifacts at it — otherwise it reads env.${T} 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),I=(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,a])=>a?.type==="workflow"?[i]:[]),o=(n.workflows??[]).flatMap(i=>i.class_name===void 0||i.script_name!==void 0?[]:[i.class_name]);return[...new Set([...t,...o])].filter(i=>!s.has(i)).map(i=>`wrangler.jsonc declares workflow "${i}" but no defineWorkflow/defineAgent export generates that class — a leftover from a rename will fail the deploy (wrangler rejects a class the worker does not export). Remove it if it is not hand-wired.`)},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)],G=[{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=()=>G.map(({keys:e,label:n})=>`${e[0]} + ${e[1]} (${n})`).join(" or "),Fe=e=>{let n;try{n=ve(V(e,we),"utf8")}catch{return!1}const s=new Map(_e(n).map(t=>[t.key,t.value]));return G.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=Se(ye(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.`]},j=(e,n,s,t)=>{const o=new Set(e.durableObjects.map(u=>u.className)),i=[],a=(s?.r2_buckets?.length??0)>0,m=(s?.d1_databases?.some(u=>u.binding==="DB")??!1)||e.needsD1;return e.usesStorage&&!a&&i.push("@lunora/storage is used but R2 bucket bindings have user-defined names; add an r2_buckets entry and pass env.<BINDING> to createStorage()."),e.usesAuth&&!o.has("SessionDO")&&!m&&i.push("@lunora/auth is used but the worker entry exports no SessionDO; sessions are D1-backed, or export SessionDO to enable DO-backed sessions."),e.usesScheduler&&!o.has("SchedulerDO")&&i.push("@lunora/scheduler is used but the worker entry exports no SchedulerDO; export it so the SCHEDULER binding can be provisioned."),i.push(...I("container","containers",e.containers),...I("workflow","workflows",e.workflows),...I("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},Ve=e=>[["container","containers",e.containers],["workflow","workflows",e.workflows],["agent","agents",e.agents]].flatMap(([s,t,o])=>o.filter(i=>!i.exported).map(({className:i,exportName:a})=>({className:i,exportName:a,kind:s,module:t}))),Ye=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 C(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[...C(s.new_classes),...C(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 a=e;const m=[];if(i.length>0){const c=[...t,...i.map(p=>({class_name:p.className,name:p.binding}))];a=w(a,["durable_objects","bindings"],c),m.push(...i.map(p=>`${p.binding}/${p.className}`))}const u=n.migrations??[],d=s.map(c=>c.className).filter(c=>!Qe(u).has(c));if(d.length>0){const c=[...u,{new_sqlite_classes:d,tag:Ye(u)}];a=w(a,["migrations"],c)}return{added:m,text:a}},B=e=>e===void 0||e==="cloudflare",Ge=(e,n)=>e.includes("DB (D1)")&&B(n)?[`wrote a DB binding with a placeholder database_id ("${Y}") — 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:Y,database_name:t}];return{added:["DB (D1)"],text:w(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&&ie(n,new Set(["analyticsSql"]))?.chained.has("analyticsSql")!==!0,$=(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 a=k(n,t);return a!==void 0?{added:[],text:e,warnings:[`${s}: not adding the ${o} binding — the name "${t}" is already bound by \`${a}\` in wrangler.jsonc. Rename that binding, then set ${s}.binding by hand.`]}:{added:[o],text:w(e,[s],{binding:t})}},L=(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.`,Ze=(e,n,s)=>{if(!B(s)||(n.hyperdrive?.length??0)>0)return{added:[],text:e};const t=k(n,"HYPERDRIVE");return t!==void 0?{added:[],text:e,warnings:[L("hyperdrive","HYPERDRIVE",t)]}:{added:["HYPERDRIVE (Hyperdrive, created on deploy)"],text:w(e,["hyperdrive"],[{binding:"HYPERDRIVE",id:re}])}},en=new Set(["celld","cloudflare"]),nn=(e,n,s,t)=>{if(t!==void 0&&!en.has(t)||s!==void 0||(n.kv_namespaces?.length??0)>0)return{added:[],text:e};const o=k(n,"KV");return o!==void 0?{added:[],text:e,warnings:[L("kv_namespaces","KV",o)]}:{added:[t==="celld"?`KV (Workers KV, celld namespace ${te(n.name,"KV")})`:"KV (Workers KV, created on deploy)"],text:w(e,["kv_namespaces"],[{binding:"KV"}])}},sn=(e,n,s,t)=>{if(!B(t)||s!==void 0||(n.artifacts?.length??0)>0)return{added:[],text:e};const o=k(n,"ARTIFACTS");if(o!==void 0)return{added:[],text:e,warnings:[L("artifacts","ARTIFACTS",o)]};const i=typeof n.name=="string"&&n.name.length>0?n.name:"lunora";return{added:["ARTIFACTS (Cloudflare Artifacts)"],text:w(e,["artifacts"],[{binding:"ARTIFACTS",namespace:i}])}},H=(e,n,s,t,o)=>{if((n[s]?.length??0)>0)return{added:[],text:e};const i=k(n,t.binding);return i!==void 0?{added:[],text:e,warnings:[`${s}: not adding ${JSON.stringify(t)} — the name "${t.binding}" is already bound by \`${i}\` in wrangler.jsonc. Add a ${s} entry under another binding name and point the matching \`defineApp()\` override at it.`]}:{added:[o],text:w(e,[s],[t])}},tn=(e,n)=>{const s=n.worker_loaders??[];return s.some(t=>t.binding==="LOADER")?{added:[],text:e}:{added:["LOADER (Worker Loader)"],text:w(e,["worker_loaders"],[...s,{binding:"LOADER"}])}},on=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},an=e=>{const{image:n}=e;return n.kind==="dockerfile"?n.dockerfilePath:n.kind==="registry"?n.reference:ne(e.exportName)},J=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}}},rn=e=>{if(e.schedulingPolicy==="durable_object")return J(e);const{image:n}=e,s={class_name:e.className,image:an(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=on(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},dn=(e,n,s)=>{const t=n.containers??[],o=new Set(t.map(d=>d.class_name)),i=s.filter(d=>!o.has(d.className));let a=i.length===0?e:w(e,["containers"],[...t,...i.map(d=>rn(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"?J(p).images:void 0;v!==void 0&&JSON.stringify(c.images)!==JSON.stringify(v)&&(a=w(a,["containers",d,"images"],v),m.push(`containers/${p.className}.images`))}return{added:i.map(d=>`containers/${d.className}`),text:a,updated:m,warnings:u}},cn=(e,n)=>{if(n.observability!==void 0)return{added:[],text:e};const s=w(e,["observability"],{...Ee});return{added:["observability"],text:s}},ln=(e,n)=>n.upload_source_maps!==void 0?{added:[],text:e}:{added:["upload_source_maps"],text:w(e,["upload_source_maps"],!0)},X=[{minimum:[4,142],name:"wrangler"},{minimum:[1,61],name:"@cloudflare/vite-plugin"}],un=X.map(({minimum:e,name:n})=>`${n}@^${e.join(".")}.0`).join(" "),gn=(e,n)=>{try{const s=ee(V(e,"package.json")).resolve(`${n}/package.json`),[t=0,o=0]=String(se(s).version).split(".").map(Number);return[t,o]}catch{return}},mn=e=>{const n=X.flatMap(({minimum:s,name:t})=>{const o=gn(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 ${un}\`) and re-run.`},pn=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.`]:[]),fn=(e,n,s)=>{let t=e;const o=[],i=[];for(const a of s){const m=n[a.className];if(m?.type==="workflow")for(const{of:u,path:d}of ue){const c=u(a),p=Q(m,d),l=`exports/${a.className}.${d.join(".")}`;if(c===void 0){p!==void 0&&i.push(`${l} is set in wrangler.jsonc but defineWorkflow "${a.exportName}" does not declare it — reconcile leaves it in place. Remove it by hand if it was dropped from the definition.`);continue}JSON.stringify(p)!==JSON.stringify(c)&&(t=w(t,["exports",a.className,...d],c),o.push(l))}}return{text:t,updated:o,warnings:i}},bn=(e,n,s,t,o)=>{if(o!==void 0)return{added:[],text:e,warnings:[o]};const i=[...s.map(f=>({settings:ce(f),workflow:f})),...t.map(f=>({settings:{},workflow:f}))],a=new Set(i.map(({workflow:f})=>f.className)),m=n.workflows??[],u=m.filter(f=>f.script_name===void 0&&f.class_name!==void 0&&a.has(f.class_name)),d=n.exports??{},c=[],p=[],l=[];let v=e;for(const{settings:f,workflow:b}of i){if(d[b.className]!==void 0&&d[b.className]!==null)continue;const _=u.find(h=>h.class_name===b.className),x=Object.fromEntries(le.flatMap(h=>{const y=Q(_,[h]);return y===void 0?[]:[[h,y]]})),E=_?.name??b.name;_?.name!==void 0&&_.name!==b.name&&l.push(`workflows/${b.className} is deployed as "${_.name}" but declared as "${b.name}" — its export keeps "${_.name}" so running instances survive. Change the declaration to match, or rename deliberately (it starts a new, empty workflow).`),v=w(v,["exports",b.className],{type:"workflow",...x,...f,name:E}),(_===void 0?c:p).push(`exports/${b.className}`)}if(u.length>0){const f=m.filter(b=>!u.includes(b));v=w(v,["workflows"],f.length===0?void 0:f),p.push(...u.map(b=>`workflows/${String(b.class_name)} → exports`))}l.push(...pn(n));const g=fn(v,d,s);return{added:c,text:g.text,updated:[...p,...g.updated],warnings:[...l,...g.warnings]}},qn=(e,n,{environment:s,target:t}={})=>{const o=Ae(e),i=Ve(n);if(!o)return{added:[],exportGaps:i,reason:"wrangler.jsonc not found",updated:[],warnings:j(n,e)};const{parsed:a,text:m}=Oe(o);if(a===void 0)return{added:[],exportGaps:i,reason:`failed to parse ${o} as JSONC`,updated:[],warnings:j(n,e),wranglerPath:o};const u=j(n,e,a,t);if(s!==void 0){const r=a.env?.[s]!==void 0;u.push(r?`auto-provisioned bindings are written to the top level of wrangler.jsonc only (queue consumers "env.${s}" already declares are retuned, nothing is added) — "env.${s}" has its own (non-inheritable) bindings and must be reconciled by hand; \`lunora deploy --env ${s}\` now validates them, so a gap here will be reported at deploy time.`:`--env "${s}" was requested but wrangler.jsonc declares no "env.${s}" block — auto-provisioned bindings are written to the top level only and will not apply to that environment.`)}const d=n.containers.filter(r=>r.exported),c=n.agents.filter(r=>r.exported&&r.voice===!0&&r.voiceBindingName!==void 0&&r.voiceClassName!==void 0),p=[...n.durableObjects,...d.map(r=>({binding:r.bindingName,className:r.className})),...c.map(r=>({binding:r.voiceBindingName,className:r.voiceClassName}))],l=n.workflows.filter(r=>r.exported),v=n.agents.filter(r=>r.exported),g=ae(e),f=Ie(g,u),b={},_=pe(g);let x,E={unwritten:{},written:{}};const h=[{enabled:!0,run:r=>Ue(r,a,p)},{enabled:n.needsD1,run:r=>Je(r,a)},{enabled:n.usesKv,run:r=>nn(r,a,n.jurisdiction,t)},{enabled:n.usesHyperdrive,run:r=>Ze(r,a,t)},{enabled:n.usesArtifacts,run:r=>sn(r,a,n.jurisdiction,t)},{enabled:n.usesAi,run:r=>$(r,a,"ai")},{enabled:n.usesAiSearch,run:r=>H(r,a,"ai_search_namespaces",{binding:"AI_SEARCH",namespace:"default"},"AI_SEARCH (AI Search namespace)")},{enabled:ze(n,e),run:r=>$(r,a,"analytics")},{enabled:n.usesBrowser,run:r=>$(r,a,"browser")},{enabled:n.usesImages,run:r=>$(r,a,"images")},{enabled:n.usesAnalytics,run:r=>H(r,a,"analytics_engine_datasets",{binding:"ANALYTICS",dataset:"ANALYTICS"},"ANALYTICS (Analytics Engine)")},{enabled:n.usesWorkerLoader,run:r=>tn(r,a)},{enabled:!0,run:r=>cn(r,a)},{enabled:t===void 0||t==="cloudflare",run:r=>ln(r,a)},{enabled:(t===void 0||t==="cloudflare")&&n.workerRoutes!==void 0,run:r=>de(r,a,n.workerRoutes??[],g,xe(e),F(e,a,t))},{enabled:d.length>0,run:r=>dn(r,a,d)},{enabled:l.length>0||v.length>0,run:r=>bn(r,a,l,v,mn(e))},{enabled:n.queues.length>0,run:r=>{const S=Re(r,a,n.queues,f.queues??{});return b.queues=S.owned,{...S,record:{consequence:"an option removed from defineQueue stays deployed",key:"queueTuning",label:"queue tuning",write:N=>{je(N,f,b)}}}}},{enabled:n.services!==void 0&&(n.services.length>0||Object.keys(_).length>0),run:r=>{const S=fe(r,a,n.services??[],_);return x=S.owned,{...S,record:{consequence:"a service removed from lunora.config stays bound",key:"services",label:"service bindings",write:(N,{devConfigWritten:Z})=>{he(N,{...x,...Z?E.written:E.unwritten})}}}}},...s===void 0||a.env?.[s]===void 0?[]:[{enabled:n.queues.length>0,run:r=>{const S=`env.${s}.queues`,O=Te(r,a,n.queues,s,f[S]??{});return b[S]=O.owned,O}}]];let y=m;const A=[],W=[],M=[];for(const r of h){if(!r.enabled)continue;const S=r.run(y);y=S.text,A.push(...S.added),W.push(...S.updated??[]),u.push(...S.warnings??[]),M.push(...[S.record].filter(O=>O!==void 0))}let K;if(n.services!==void 0){const r=be(e,n.services,_);u.push(...r.warnings),E={unwritten:r.previouslyOwned,written:r.owned},K=r}u.push(...Ge(A,t));const z=F(e,a,t)?.directory;return{added:A,devConfig:K,edit:{assetsDirectory:z,manifest:g,original:m,records:M,text:y},exportGaps:i,updated:W,warnings:u,wranglerPath:o}};export{Ve as collectExportGaps,qn as planWranglerBindings};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./detectFramework-Dfpvu6rD.mjs";import"./readProjectDependencies-l3uhUKjo.mjs";import{S as e,i as a,o as d,s as r}from"./studio-assets-BKWx838V.mjs";import"./WRANGLER_FILES-BF8PUjuo.mjs";export{e as STUDIO_ASSETS_DIRECTORY,a as isOwnedStudioAssets,d as ownedStudioAssetsBlock,r as studioAssetsPlan};
|
package/dist/packem_shared/{pendingBindingChanges-B85u-ZNK.mjs → pendingBindingChanges-DqP40pSQ.mjs}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{mkdirSync as l,writeFileSync as $,rmSync as w}from"node:fs";import{basename as h,join as d,dirname as p}from"node:path";import{inferLunoraBindings as u}from"./inferLunoraBindings-Biq1OW9V.mjs";import{LUNORA_TAG as a}from"./LUNORA_TAG-DQTGPqcJ.mjs";import{applyWranglerBindings as v}from"./reconcileWranglerBindings-
|
|
1
|
+
import{mkdirSync as l,writeFileSync as $,rmSync as w}from"node:fs";import{basename as h,join as d,dirname as p}from"node:path";import{inferLunoraBindings as u}from"./inferLunoraBindings-Biq1OW9V.mjs";import{LUNORA_TAG as a}from"./LUNORA_TAG-DQTGPqcJ.mjs";import{applyWranglerBindings as v}from"./reconcileWranglerBindings-DAdI2Z-R.mjs";import{r as y}from"./validate-bindings-DSMH8bRQ.mjs";import{planWranglerBindings as S}from"./collectExportGaps-DHUtghqe.mjs";import{reconcileWranglerCompatibilityDate as j}from"./reconcileWranglerCompatibilityDate-Cj94osA-.mjs";import{reconcileWranglerCrons as b,describePreservedCrons as C}from"./describePreservedCrons-i5XT6rtl.mjs";import{s as x,S as E}from"./studio-assets-BKWx838V.mjs";import{findWranglerFile as k,readWranglerJsonc as P}from"./WRANGLER_FILES-BF8PUjuo.mjs";const m=async r=>S(r.projectRoot,await u({cache:r.cache,projectRoot:r.projectRoot,schemaDir:r.schemaDir}),{target:r.target}),L=async(r,o,t)=>{try{const n=v(r.projectRoot,await m(r)),e=n.wranglerPath??"wrangler.jsonc";if(n.added.length>0&&o.info?.(`${a} inferred bindings → ${n.added.join(", ")} (written to ${e})`),n.updated.length>0&&o.info?.(`${a} updated bindings → ${n.updated.join(", ")} (written to ${e})`),n.devConfig!==void 0){const{added:i,path:s,updated:c}=n.devConfig;o.info?.(`${a} dev sidecar bindings → ${[...i,...c].join(", ")} (written to ${s})`)}for(const i of n.warnings)o.warn(`${a} ${i}`);n.exportGaps.length>0&&t?.(n.exportGaps)}catch(n){const e=n instanceof Error?n.message:String(n);o.warn(`${a} binding inference skipped: ${e}`)}},M=async r=>{try{const{added:o,devConfig:t,updated:n}=await m(r),e=t===void 0?[]:[...t.added,...t.updated].map(i=>`${h(t.path)} ${i}`);return[...new Set([...o,...n,...e])]}catch{return[]}},f=new Map,N=(r,o,t)=>{try{const n=b(r,o);n.changed&&t.info?.(`${a} synced ${o.length.toFixed(0)} cron trigger(s) into ${n.wranglerPath??"wrangler.jsonc"}`);for(const s of n.warnings)t.warn(`${a} ${s}`);const e=n.preserved.join("\0"),i=C(n.preserved);i!==void 0&&(n.changed||f.get(r)!==e)&&t.info?.(`${a} ${i}`),f.set(r,e)}catch(n){const e=n instanceof Error?n.message:String(n);t.warn(`${a} cron trigger sync skipped: ${e}`)}try{const n=j(r);n.changed&&t.info?.(`${a} 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);t.warn(`${a} compatibility date sync skipped: ${e}`)}},W=["architecture.json","openapi.json","openrpc.json"],J=(r,o,t)=>{const n=k(r),e=n===void 0?void 0:P(n);if(n===void 0||e?.parsed===void 0)return;const i=x(r,e.parsed,o),s=y(e.text,e.parsed,i);if(i!==void 0&&l(d(p(n),i.directory),{recursive:!0}),s.text!==e.text&&($(n,s.text,"utf8"),t.info?.(`${a} ${[...s.added,...s.updated].join(", ")} → ${n}`)),i===void 0){const c=d(p(n),E,"_lunora","studio");for(const g of W)w(d(c,g),{force:!0})}};export{M as pendingBindingChanges,L as reconcileBindingsSafely,J as reconcileStudioAssets,N as reconcileWranglerExtras};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{mkdirSync as g,writeFileSync as c}from"node:fs";import{join as u,dirname as l}from"node:path";import{readManifest as h}from"./readManifest-Cighz3WC.mjs";import{planWranglerBindings as f}from"./collectExportGaps-
|
|
1
|
+
import{mkdirSync as g,writeFileSync as c}from"node:fs";import{join as u,dirname as l}from"node:path";import{readManifest as h}from"./readManifest-Cighz3WC.mjs";import{planWranglerBindings as f}from"./collectExportGaps-DHUtghqe.mjs";const d=r=>r===void 0||r.added.length===0&&r.updated.length===0?void 0:{added:r.added,path:r.path,updated:r.updated},w=(r,e,{devConfigWritten:t,wranglerChanged:s})=>{const{manifest:o}=e;if(o===void 0)return[];const n=[];for(const i of e.records)try{i.write(h(r)??o,{devConfigWritten:t})}catch(a){n.push(`${s?"wrangler.jsonc was updated, but ":""}recording the ${i.label} reconcile owns in ${o.path} (lunora.${i.key}) failed: ${a instanceof Error?a.message:String(a)}. Until it is recorded, ${i.consequence}.`)}return n},p=(r,e)=>{if(!(r===void 0||r.text===r.original))try{c(r.path,r.text,"utf8");return}catch(t){return`${e?"wrangler.jsonc was updated, but ":""}writing ${r.path} failed: ${t instanceof Error?t.message:String(t)}. The dev sidecar keeps its previous service bindings until the next reconcile writes it.`}},v=(r,e)=>{const{edit:t,...s}=e;if(t===void 0||e.wranglerPath===void 0)return{...s,changed:!1,devConfig:d(e.devConfig)};const o=[...e.warnings],n=t.text!==t.original;t.assetsDirectory!==void 0&&g(u(l(e.wranglerPath),t.assetsDirectory),{recursive:!0}),n&&c(e.wranglerPath,t.text,"utf8");const i=p(e.devConfig,n);return i!==void 0&&o.push(i),o.push(...w(r,t,{devConfigWritten:i===void 0,wranglerChanged:n})),{...s,changed:n,devConfig:i===void 0?d(e.devConfig):void 0,...n?{}:{reason:"bindings already in sync"},warnings:o}},x=(r,e,t={})=>v(r,f(r,e,t));export{v as applyWranglerBindings,x as reconcileWranglerBindings};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{resolveCodegenTarget as B}from"@lunora/codegen";import{detectFramework as U}from"./detectFramework-Dfpvu6rD.mjs";import{readProjectManifest as W,readProjectDependencyNames as G}from"./readProjectDependencies-l3uhUKjo.mjs";import{existsSync as f,readFileSync as _,readdirSync as K}from"node:fs";import{join as u,dirname as x,extname as N,basename as v}from"node:path";import{Project as Y,Node as d}from"ts-morph";import{COMPOSED_WORKER_ENTRY as q,LUNORA_WORKER_VIRTUAL_ID as g,isGeneratedOutput as X,WORKER_ENTRY_FALLBACKS as $,GENERATED_DIRECTORY as w,isMergedProject as z,MERGED_DURABLE_OBJECT as J,COMPOSED_ENTRY_DURABLE_OBJECTS as V,GENERATED_CLASS_MODULES as H,isMergedRoleModule as Q,SOURCE_DOT_DIRECTORIES as Z,NON_SOURCE_DIRECTORIES as ee}from"./COMPOSED_WORKER_ENTRY-LpLlp-aF.mjs";import{findWranglerFile as te}from"./WRANGLER_FILES-BF8PUjuo.mjs";const se=new Set(["ratelimits","send_email"]),ne=["durable_objects","logfwdr","unsafe"],oe=new Set(["data_blobs","text_blobs","vars","wasm_modules"]),A=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),E=(e,t,n)=>A(e)&&e[t]===n,re=(e,t,n)=>{if(oe.has(e))return A(t)&&Object.hasOwn(t,n);const s=se.has(e)?"name":"binding";return Array.isArray(t)?t.some(o=>E(o,s,n)):E(t,"binding",n)},ie=(e,t)=>{const n=e,s=Object.entries(n).find(([c,i])=>c!=="env"&&re(c,i,t));if(s!==void 0)return s[0];for(const c of ne){const i=n[c];if(A(i)&&Array.isArray(i.bindings)&&i.bindings.some(a=>E(a,"name",t)))return`${c}.bindings`}const o=e.queues?.producers;if(Array.isArray(o)&&o.some(c=>E(c,"binding",t)))return"queues.producers";const r=e.secrets?.required;if(Array.isArray(r)&&r.includes(t))return"secrets.required"},p=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),Fe=e=>typeof e=="string"&&e.length>0,Le=e=>Array.isArray(e)?e.filter(t=>p(t)):[],S=[".ts",".tsx",".mts",".cts"],h=new Set(S),ce=new Set([".cjs",".js",".mjs"]),y="default",I={".cjs":[".cts"],".js":[".ts",".tsx"],".mjs":[".mts"]},C=250,ae=(e,t,n)=>{const s=u(t,q);if(f(s))return{origin:"declared",path:s};if(e===g)return{origin:"composed"};const o=()=>{const i=$.map(a=>u(t,a)).find(a=>f(a));return i===void 0?void 0:{origin:"probed",path:i}};if(typeof e!="string"||e.length===0||X(e))return o();const r=u(x(n),e),c=N(r);if(!(!h.has(c)&&!ce.has(c)))return f(r)?{origin:"declared",path:r}:{origin:"absent",path:r}},M=(e,t)=>{if(d.isIdentifier(e)){t.add(e.getText());return}if(d.isObjectBindingPattern(e)||d.isArrayBindingPattern(e))for(const n of e.getElements())d.isBindingElement(n)&&M(n.getNameNode(),t)},de=(e,t)=>{const n=[];for(const s of e.getExportDeclarations())if(!s.isTypeOnly()){if(s.isNamespaceExport()){const o=s.getNamespaceExport();o===void 0?n.push(s.getModuleSpecifierValue()??""):t.add(o.getName());continue}for(const o of s.getNamedExports())o.isTypeOnly()||t.add(o.getAliasNode()?.getText()??o.getName())}return n},le=(e,t)=>{for(const n of e.getVariableStatements().filter(s=>s.getExportKeyword()!==void 0))for(const s of n.getDeclarations())M(s.getNameNode(),t);for(const n of[...e.getClasses(),...e.getFunctions(),...e.getEnums()]){if(n.getExportKeyword()===void 0)continue;const s=n.isDefaultExport()?y:n.getName();s!==void 0&&t.add(s)}e.getExportAssignments().length>0&&t.add(y)},T=(e,t)=>{const n=new Y({compilerOptions:{allowJs:!0},skipFileDependencyResolution:!0,skipLoadingLibFiles:!0,useInMemoryFileSystem:!0}),s=n.createSourceFile(e,t,{overwrite:!0});return n.getProgram().compilerObject.getSyntacticDiagnostics(s.compilerNode).length>0?void 0:s},P=(e,t)=>{if(!t.startsWith("./")&&!t.startsWith("../"))return;const n=u(x(e),t),s=N(n),o=h.has(s)||I[s]!==void 0,r=o?n.slice(0,-s.length):n;return[...h.has(s)?[n]:[],...(I[s]??[]).map(i=>`${r}${i}`),...o?[]:S.map(i=>`${n}${i}`),...o||s.length===0?S.map(i=>u(r,`index${i}`)):[]].find(i=>f(i))},j=e=>{const t=new Set,n=new Set([e]),s=[e];for(;s.length>0;){if(n.size-1>C)return;const o=s.pop();let r;try{r=_(o,"utf8")}catch{return}const c=T(v(o),r);if(c===void 0)return;const i=de(c,t);le(c,t);for(const a of i){const l=P(o,a);if(l===void 0)return;n.has(l)||(n.add(l),s.push(l))}}return t},ue=(e,t)=>{const n={exports:void 0,kind:"composed",path:g},s=u(e,t,w);if(!f(s))return n;const o=z(s),r=new Set(o?[J]:V);for(const c of H){const i=u(s,`${c}.ts`);if(!f(i)||o&&Q(c))continue;const a=j(i);if(a===void 0)return n;for(const l of a)r.add(l)}return{exports:r,kind:"composed",path:g}},ke=(e,t,n)=>{if(e===void 0||e.origin==="absent")return;if(e.origin==="composed")return ue(t,n);const s=j(e.path);if(!(e.origin==="probed"&&s!==void 0&&!s.has(y)))return{exports:s,kind:"authored",path:e.path}},fe=new Set([".cjs",".cts",".js",".jsx",".mjs",".mts",".ts",".tsx"]),pe=2e3,D="defineTable",O="defineApp",Ee=e=>{const t=[],n=[];let s;try{s=K(e,{withFileTypes:!0})}catch{return{files:t,subdirectories:n}}for(const o of s)o.isDirectory()?o.name.startsWith(".")&&!Z.has(o.name)||ee.has(o.name)||n.push(u(e,o.name)):fe.has(N(o.name))&&t.push(u(e,o.name));return{files:t,subdirectories:n}},b=(e,t,n)=>{const s=new Set;for(const o of e.getImportDeclarations())if(!(o.isTypeOnly()||n!==void 0&&!n(o.getModuleSpecifierValue())))for(const r of o.getNamedImports())!r.isTypeOnly()&&r.getName()===t&&s.add(r.getAliasNode()?.getText()??r.getName());return s},F=(e,t)=>{let n=!1;return e.forEachDescendant((s,o)=>{if(!d.isCallExpression(s))return;const r=s.getExpression();d.isIdentifier(r)&&t.has(r.getText())&&(n=!0,o.stop())}),n},me=e=>{let t=e;for(;d.isCallExpression(t)||d.isPropertyAccessExpression(t);)t=t.getExpression();return t},ge=(e,t)=>{const n=me(e);return d.isIdentifier(n)&&t.has(n.getText())},L={analyticsSql:/\.\s*analyticsSql\s*\(/u,global:/\.\s*global\s*\(/u,hyperdriveGlobal:/\.\s*hyperdriveGlobal\s*\(/u,vectors:/\.\s*vectors\s*\(/u},Se=e=>Object.hasOwn(L,e),he=(e,t)=>{const n=new Set,s=new Set([D,...b(e,D)]);return e.forEachDescendant(o=>{if(!d.isCallExpression(o))return;const r=o.getExpression();if(!d.isPropertyAccessExpression(r)||ge(r,s))return;const c=r.getName();Se(c)&&t.has(c)&&n.add(c)}),n},ye=(e,t)=>{let n;try{n=_(e,"utf8")}catch{return}const s=new Set([...t].filter(r=>L[r].test(n)));if(s.size===0&&!n.includes(O))return;const o=T(v(e),n);return o===void 0?{chained:s,composes:!1}:{chained:he(o,s),composes:F(o,b(o,O))}},Be=(e,t)=>{const n=[e],s=new Set;let o=0,r;const c=i=>{if(o+=1,o>pe)return!1;const a=ye(i,t);for(const l of a?.chained??[])s.add(l);return a?.composes&&(r??=i),!0};for(;n.length>0;){const i=n.pop(),{files:a,subdirectories:l}=Ee(i);n.push(...l);for(const k of a){if(!c(k))return;if(r!==void 0&&s.size===t.size)return{chained:s,site:r}}}return r===void 0?void 0:{chained:s,site:r}},Oe=/(?:^|\/)_generated\/app(?:\.[cm]?[jt]sx?)?$/u,_e=/[\\/]/u,Ne=e=>{const t=new Set([e]),n=[e];for(;n.length>0;){if(t.size-1>C)return!1;const s=n.pop();let o;try{o=_(s,"utf8")}catch{return!1}const r=T(v(s),o);if(r===void 0)return!1;if(F(r,b(r,O,i=>Oe.test(i))))return!0;const c=[...r.getImportDeclarations().filter(i=>!i.isTypeOnly()&&(i.getImportClause()===void 0||i.getDefaultImport()!==void 0||i.getNamespaceImport()!==void 0||i.getNamedImports().length===0||i.getNamedImports().some(a=>!a.isTypeOnly()))),...r.getExportDeclarations().filter(i=>!i.isTypeOnly()&&(i.getNamedExports().length===0||i.getNamedExports().some(a=>!a.isTypeOnly())))].flatMap(i=>i.getModuleSpecifierValue()??[]);for(const i of c){const a=P(s,i);a!==void 0&&!t.has(a)&&!a.split(_e).includes(w)&&(t.add(a),n.push(a))}}return!1},R=".lunora/studio-assets",m="ASSETS",ve="virtual:lunora/worker",Ae=["@lunora/vite","@lunora/rspack","@cloudflare/vite-plugin"],Ue=()=>({binding:m,directory:R,run_worker_first:!0}),Te=e=>p(e)&&Object.keys(e).length===3&&e.binding===m&&e.directory===R&&e.run_worker_first===!0,be=(e,t)=>{if(W(e)===void 0||t.main===ve||U(e).class!=="C")return!1;const n=G(e);return!Ae.some(s=>n.has(s))},Re=(e,t)=>{const n=typeof t.main=="string"?t.main:void 0,s=ae(n,e,te(e)??u(e,"wrangler.jsonc"));return s?.origin==="composed"?!0:s!==void 0&&s.origin!=="absent"&&Ne(s.path)},We=(e,t,n)=>{if(t===void 0||B(e,n)!=="cloudflare")return;const s=p(t.env)?Object.values(t.env):[],o=t.assets!==void 0&&!Te(t.assets)||t.site!==void 0||s.some(c=>p(c)&&(c.assets!==void 0||c.site!==void 0)),r=[{...t,assets:void 0},...s].some(c=>p(c)&&ie(c,m)!==void 0);if(!(o||r||!be(e,t)||!Re(e,t)))return{binding:m,directory:R}};export{R as S,Be as a,p as b,Fe as c,ie as d,Te as i,ae as l,Ue as o,Le as p,ke as r,We as s};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{i as k}from"./is-plain-object-CWxHeOY1.mjs";import{applyModify as A}from"./applyModify-DKP2l6S9.mjs";import{recordManifestKey as D}from"./readManifest-Cighz3WC.mjs";import{s as N}from"./spa-assets-wX8rTPEQ.mjs";import{o as K,i as F,b,c as d}from"./studio-assets-BKWx838V.mjs";import{CUSTOM_INSTANCE_TYPE_LIMITS as M,CUSTOM_INSTANCE_MIN_MEMORY_MIB_PER_VCPU as T}from"@lunora/container";const h=["/_lunora/*","/__lunora/*"],G=[h,["/_lunora/*"]],H="/*",v=100,$=100,x="runWorkerFirst",Q=/^[\w.~@%+-]+$/u,V=e=>{const s=e.split("/").filter(r=>r!==""),t=s.map(r=>Q.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)),C=e=>e.flatMap((s,t)=>{const n=e.find(i=>_(s,i));return[...s.length>$?[`assets.run_worker_first entry "${s}" is ${String(s.length)} characters; Cloudflare accepts at most ${String($)}`]:[],...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`]]}),Se=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>v&&s.push(`assets.run_worker_first has ${String(e.length)} rules; Cloudflare accepts at most ${String(v)}, 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(...C(t),...C(n)),s},Y=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`,z=e=>{const s=[],t=new Set;for(const o of e){const r=V(o);if(r===void 0){s.push(Y(o));continue}for(const c of r)c.length>$?s.push(`run_worker_first rule "${c}" is longer than Cloudflare's ${String($)} characters and was left out`):t.add(c)}const n=[...h,...t],i=[...new Set(n)].filter(o=>!n.some(r=>_(o,r))&&!h.includes(o)).toSorted((o,r)=>o.localeCompare(r)),a=v-h.length;return i.length>a&&s.push(`the routes need ${String(i.length+h.length)} run_worker_first rules and Cloudflare accepts ${String(v)}; ${i.slice(a).join(", ")} were left out`),{rules:[...h,...i.slice(0,a)],warnings:s}},B=(e,s)=>e===s||_(e,s)||_(s,e),J=(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(u=>u===r||_(r,u))){n.push(r);continue}const c=o.filter(u=>B(u.slice(1),r));c.length>0&&t.set(r,c)}return{excluded:t,missing:n}},X=(e,s,t)=>{const{excluded:n,missing:i}=J(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]),Z=e=>{const s=e?.lunora?.[x];return k(s)?Object.fromEntries(Object.entries(s).filter(t=>Array.isArray(t[1])&&t[1].every(n=>typeof n=="string"))):{}},ee=(e,s)=>{const t=[...new Set(s)].filter(o=>o.length<$&&!e.some(r=>B(o,r))),n=t.filter(o=>!t.some(r=>_(o,r))).toSorted((o,r)=>o.localeCompare(r)).map(o=>`!${o}`),i=v-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:[H,...n.slice(0,i)],warnings:a}},se=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}`,ne=(e,s,t,n,i)=>e===void 0||E(e,i)||G.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:X(e,s,n)},te=e=>[{assets:e.assets,path:["assets"]},...Object.entries(e.env??{}).flatMap(([s,t])=>k(t)?[{assets:t.assets,path:["env",s,"assets"]}]:[])],ie=(e,s,t)=>t!==void 0&&s.assets===void 0?{added:["assets (Studio documents, run_worker_first: true)"],text:A(e,["assets"],K()),updated:[]}:t===void 0&&F(s.assets)?{added:[],text:A(e,["assets"],void 0),updated:["assets (Studio documents block removed)"]}:{added:[],text:e,updated:[]},je=(e,s,t,n,i,a)=>{const o=te(s).filter(g=>!F(g.assets)),r=z(t),c=ee(r.rules,i),u=Z(n),m={},l={...ie(e,s,a),warnings:[]};for(const{assets:g,path:O}of o.filter(f=>k(f.assets))){const f=O.join("."),S=g,I=N(S)!==void 0,j=I?c.rules:r.rules,p=ne(S.run_worker_first,`${f}.run_worker_first`,j,r.rules,u[f]);p.owned&&(m[f]=j),p.owned&&!I&&S.not_found_handling==="single-page-application"&&l.warnings.push(se(f)),p.warning!==void 0&&l.warnings.push(p.warning),p.change!==void 0&&(l.text=A(l.text,[...O,"run_worker_first"],j),l[p.change].push(`${f}.run_worker_first`))}return o.some(g=>k(g.assets))&&l.warnings.unshift(...r.warnings,...o.some(g=>N(g.assets)!==void 0)?c.warnings:[]),{...l,record:{consequence:"the next route change leaves run_worker_first as it is",key:x,label:"run_worker_first rules",write:g=>{D(g,x,Object.keys(m).length===0?void 0:m)}}}},W=[{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"]}],Me=[...new Set(W.map(({path:e})=>e[0]))],q=(e,s)=>{let t=e;for(const n of s)t=b(t)?t[n]:void 0;return t},Ee=e=>{const s={};for(const{of:t,path:n}of W){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},Re=(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}"`)},ae=new Set(["basic","dev","lite","standard","standard-1","standard-2","standard-3","standard-4"]),oe={disk_mb:M.diskMb,memory_mib:M.memoryMib,vcpu:{...M.vcpu,hint:'use the named "lite" or "basic" instance type below 1 vCPU'}},re=(e,s,t)=>{const n=e.instance_type;if(n===void 0)return;if(typeof n=="string"){ae.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:u}]of Object.entries(oe)){const m=n[o];if(m!==void 0&&(typeof m!="number"||Number.isNaN(m)||m<u||m>c)){const l=r!==void 0&&typeof m=="number"&&m<u?` — ${r}`:"";t.push(`${s} custom instance_type ${o} must be a number in ${String(u)}–${String(c)} (got ${String(m)})${l}`)}}const{memory_mib:i,vcpu:a}=n;typeof a=="number"&&typeof i=="number"&&i<a*T&&t.push(`${s} custom instance_type needs ≥ 3 GiB (${String(T)} MiB) memory per vCPU (got ${String(i)} MiB for ${String(a)} vCPU)`)},ce=(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"`)},de=(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?ce(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}"]`),re(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`)},y=e=>Array.isArray(e)?e.filter(s=>s!==null&&typeof s=="object"):[],R=e=>Array.isArray(e)?e.filter(s=>d(s)):[],P=e=>{const s=new Map;for(const t of y(e)){for(const n of R(t.new_classes))s.set(n,"classic");for(const n of R(t.new_sqlite_classes))s.set(n,"sqlite");for(const n of y(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 R(t.deleted_classes))s.delete(n)}return s},ue=e=>new Set(P(e).keys()),Ae=(e,s)=>{const t=ue(e.migrations);for(const n of y(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`)},xe=(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(y(e.durable_objects?.bindings).map(o=>o.class_name)),a=P(e.migrations);for(const[o,r]of n.entries())de(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 } })')},w=e=>e,L=(e,s,t,n)=>{if(e!==void 0){if(!Array.isArray(e)){n.push(t.arrayMessage);return}for(const[i,a]of w(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))}}},We={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`},me=(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",le=e=>{if(e!==void 0)return b(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"},ge=e=>e===void 0?[]:b(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"],U=(e,s,t,n)=>{const i=[me(e.schedules,t),le(e.limits),...ge(e.default_retention)];for(const a of i)a!==void 0&&n.push(`${s}.${a}`)},fe=(e,s)=>W.map(({path:t})=>t).filter(t=>{const n=q(e,t),i=q(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(".")),be=(e,s,t,n)=>{const i=`exports["${e}"]`,a=String(s.name);for(const o of t){if(!b(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 fe(o,s))n.push(`${r} and ${i} set ${c} to different values for workflow "${a}" — set it in one place`)}},Oe=(e,s)=>{const t=Array.isArray(e.workflows)?w(e.workflows):[];for(const[i,a]of t.entries())b(a)&&U(a,`workflows[${String(i)}]`,!1,s);const n=b(e.exports)?Object.entries(e.exports):[];for(const[i,a]of n)!b(a)||a.type!=="workflow"||(d(a.name)?(U(a,`exports["${i}"]`,!0,s),be(i,a,t,s)):s.push(`exports["${i}"] is a workflow export and must have a non-empty "name" naming the deployed workflow`))},pe={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`},he={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`},Ie=(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}L(e.queues.producers,"queues.producers",pe,s),L(e.queues.consumers,"queues.consumers",he,s)}},Ne={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`},Te=[{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"}],Ce=(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 w(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(u=>d(o[u]))||n.push(s.hintMessage(r,o.binding))}}},qe=[{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" })'}],Le=(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)},Ue=[{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`}],Fe=(e,s,t)=>{s?.hasD1GlobalTable&&!y(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&&y(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)')},Be=(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 w(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`)}}},Pe=(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 w(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)`)}}};export{Te as H,Ue as R,qe as S,We as W,Se as a,Fe as b,Be as c,Re as d,xe as e,ue as f,L as g,Oe as h,Ie as i,Ce as j,Le as k,Pe as l,Ne as m,je as n,y as o,Me as p,R as q,ie as r,q as s,W as t,Ae as v,Ee as w};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as _}from"./env-flag-u4B05gLp.mjs";import{
|
|
1
|
+
import{i as _}from"./env-flag-u4B05gLp.mjs";import{b as u,c as h}from"./studio-assets-BKWx838V.mjs";import{a as A,o as O}from"./validate-bindings-DSMH8bRQ.mjs";const b=(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)=>{b(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"] })')},p=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>p&&e.push(`limits.cpu_ms must be at most ${String(p)} (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":{b(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}b(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};
|
package/dist/packem_shared/{wranglerCodegenInputs-BM7W0Aqh.mjs → wranglerCodegenInputs-Bfe3cN0G.mjs}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{relative as d,resolve as p,dirname as v}from"node:path";import{s as
|
|
1
|
+
import{relative as d,resolve as p,dirname as v}from"node:path";import{s as b,b as l}from"./studio-assets-BKWx838V.mjs";import{s as f}from"./spa-assets-wX8rTPEQ.mjs";import{findWranglerFile as m,readWranglerJsonc as w}from"./WRANGLER_FILES-BF8PUjuo.mjs";import{variableKeyLines as A,scanWranglerVariablesForSecrets as q}from"./scanWranglerVariablesForSecrets-BQIPpHpH.mjs";const u=(i,n)=>{const s=i?.producers;return(Array.isArray(s)?s:[]).flatMap(e=>l(e)&&typeof e.binding=="string"&&typeof e.queue=="string"?[{binding:e.binding,queue:e.queue,...n===void 0?{}:{env:n}}]:[])},V=(i,n)=>{const s=m(i),a=s===void 0?void 0:w(s),e=a?.parsed;if(s===void 0||a?.text===void 0||e===void 0)return{wranglerQueueProducers:[],wranglerVariables:[]};const g=A(a.text),o=[...new Set([e.assets,...Object.values(e.env??{}).map(r=>r?.assets)].flatMap(r=>f(r)??[]))],t=b(i,e,n);return{...o.length===0?{}:{spaAssetsBindings:o},...t===void 0?{}:{studioAssets:{binding:t.binding,directory:d(i,p(v(s),t.directory))}},wranglerQueueProducers:[...u(e.queues),...Object.entries(e.env??{}).flatMap(([r,c])=>u(c?.queues,r))],wranglerVariables:q(l(e.vars)?e.vars:void 0,d(i,s),r=>g.get(r))}};export{V 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-
|
|
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-Bfe3cN0G.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};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{devVariablesStamp as t,parseDevVariable as r,resolveAdminToken as a}from"../packem_shared/devVariablesStamp-BQkGEn9d.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-XBG1aWbl.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-
|
|
1
|
+
import{devVariablesStamp as t,parseDevVariable as r,resolveAdminToken as a}from"../packem_shared/devVariablesStamp-BQkGEn9d.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-XBG1aWbl.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-DXNMnzuM.mjs";import{POLICY_SCAFFOLD_ENDPOINT as H,handlePolicyScaffoldRequest as L}from"../packem_shared/POLICY_SCAFFOLD_ENDPOINT-uPZXZrU7.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-Dbdgz4G6.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.
|
|
3
|
+
"version": "1.0.0-alpha.465",
|
|
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.
|
|
61
|
+
"@lunora/codegen": "^1.0.0-alpha.420",
|
|
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{existsSync as d}from"node:fs";import{dirname as y,join as h}from"node:path";import{discoverSchemaInfo as v}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 E,GENERATED_CLASS_MODULES as $,isFrameworkDurableObject as k}from"./COMPOSED_WORKER_ENTRY-LpLlp-aF.mjs";import{i as D}from"./studio-assets-B-xhoszR.mjs";import{o as R,f as j}from"./validate-bindings-wzOGNEFw.mjs";import{validateSchedulerOrigin as x}from"./withTailConsumer-B__tj5s-.mjs";import{l as O,r as A,s as _}from"./worker-entry-checks-DH-ApvvX.mjs";import{mergeWranglerEnvironment as S}from"./mergeWranglerEnvironment-D5ekKj5x.mjs";import{findWranglerFile as W,readWranglerJsonc as C}from"./WRANGLER_FILES-BF8PUjuo.mjs";import{validateWranglerConfig as T}from"./REQUIRED_COMPATIBILITY_DATE-Dccl2OBo.mjs";const b=r=>Array.isArray(r)?r:[],L=(r,o,t)=>Object.entries(r?.images??{}).flatMap(([s,n])=>{const e=n?.dockerfile;return typeof e!="string"||d(e.startsWith("/")?e:h(o,e))?[]:[`containers images["${s}"] dockerfile "${e}" does not exist (resolved relative to ${t}); create the Dockerfile`]}),I=(r,o)=>{const t=r?.directory;if(typeof t!="string"||t.length===0||d(t.startsWith("/")?t:h(o,t)))return[];const s=D(r)?"it holds the Studio documents `lunora codegen` writes; run codegen before deploy":"it is created by the client build; run the build before deploy";return[`assets.directory "${t}" does not exist yet — ${s}`]},P=(r,o,t)=>{const s=[];for(const n of b(r)){const e=n?.image;typeof e=="string"&&(e.startsWith("./")||e.startsWith("../")||e.startsWith("/")||e.includes("Dockerfile"))&&!d(e.startsWith("/")?e:h(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},B=(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(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=_(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",M=(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 ${E.join(", ")}, SchedulerDO when its binding is declared, and every class codegen emits from your ${$.map(s=>`${s}.ts`).join(" / ")} declarations`;return k(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.`},N=(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 b(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. ${M(e.className,o)}`)},U=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.`),H=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.`],re=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:m}=v(r.projectRoot,o,r.cache),a=T(s,m,r.environment);l!==void 0&&a.warnings.push(`schema parse failed in ${o}/schema.ts: ${l}`);const f=y(t),g=O(e.main,r.projectRoot,t),p=A(g,r.projectRoot,o);return a.errors.push(...P(e.containers??[],f,t)),a.warnings.push(...H(g)),p!==void 0&&a.errors.push(...N(e,p)),p?.exports?.has(i)===!0&&(a.errors.push(...U(e)),d(h(r.projectRoot,o,w,"scheduler.ts"))&&x(e,r.environment,a.warnings,"the merged LunoraDO hosts the scheduler")),a.errors.push(...B(m,r.projectRoot)),a.warnings.push(...I(e.assets,f)),a.valid=a.errors.length===0,{problems:a.errors,report:a,wranglerPath:t}};export{G as UNEXPORTED_CLASS_MARKER,re as validateWranglerProject};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./detectFramework-Dfpvu6rD.mjs";import"./readProjectDependencies-l3uhUKjo.mjs";import{S,i as e,o as a,s as d}from"./studio-assets-B-xhoszR.mjs";export{S as STUDIO_ASSETS_DIRECTORY,e as isOwnedStudioAssets,a as ownedStudioAssetsBlock,d as studioAssetsPlan};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{resolveCodegenTarget as A}from"@lunora/codegen";import{detectFramework as l}from"./detectFramework-Dfpvu6rD.mjs";import{readProjectManifest as _,readProjectDependencyNames as y}from"./readProjectDependencies-l3uhUKjo.mjs";const m=new Set(["ratelimits","send_email"]),g=["durable_objects","logfwdr","unsafe"],E=new Set(["data_blobs","text_blobs","vars","wasm_modules"]),f=r=>typeof r=="object"&&r!==null&&!Array.isArray(r),a=(r,n,e)=>f(r)&&r[n]===e,N=(r,n,e)=>{if(E.has(r))return f(n)&&Object.hasOwn(n,e);const t=m.has(r)?"name":"binding";return Array.isArray(n)?n.some(i=>a(i,t,e)):a(n,"binding",e)},O=(r,n)=>{const e=r,t=Object.entries(e).find(([s,o])=>s!=="env"&&N(s,o,n));if(t!==void 0)return t[0];for(const s of g){const o=e[s];if(f(o)&&Array.isArray(o.bindings)&&o.bindings.some(b=>a(b,"name",n)))return`${s}.bindings`}const i=r.queues?.producers;if(Array.isArray(i)&&i.some(s=>a(s,"binding",n)))return"queues.producers";const d=r.secrets?.required;if(Array.isArray(d)&&d.includes(n))return"secrets.required"},c=r=>typeof r=="object"&&r!==null&&!Array.isArray(r),P=r=>typeof r=="string"&&r.length>0,h=r=>Array.isArray(r)?r.filter(n=>c(n)):[],S=".lunora/studio-assets",u="ASSETS",I="virtual:lunora/worker",w=["@lunora/vite","@lunora/rspack","@cloudflare/vite-plugin"],k=()=>({binding:u,directory:S,run_worker_first:!0}),v=r=>c(r)&&Object.keys(r).length===3&&r.binding===u&&r.directory===S&&r.run_worker_first===!0,T=(r,n)=>{if(_(r)===void 0||n.main===I||l(r).class!=="C")return!1;const e=y(r);return!w.some(t=>e.has(t))},B=(r,n,e)=>{if(n===void 0||A(r,e)!=="cloudflare")return;const t=c(n.env)?Object.values(n.env):[],i=n.assets!==void 0&&!v(n.assets)||n.site!==void 0||t.some(s=>c(s)&&(s.assets!==void 0||s.site!==void 0)),d=[{...n,assets:void 0},...t].some(s=>c(s)&&O(s,u)!==void 0);if(!(i||d||!T(r,n)))return{binding:u,directory:S}};export{S,c as a,P as b,O as c,v as i,k as o,h as p,B as s};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as k}from"./is-plain-object-CWxHeOY1.mjs";import{applyModify as A}from"./applyModify-DKP2l6S9.mjs";import{recordManifestKey as D}from"./readManifest-Cighz3WC.mjs";import{s as N}from"./spa-assets-wX8rTPEQ.mjs";import{o as K,i as F,a as b,b as d}from"./studio-assets-B-xhoszR.mjs";import{CUSTOM_INSTANCE_TYPE_LIMITS as M,CUSTOM_INSTANCE_MIN_MEMORY_MIB_PER_VCPU as T}from"@lunora/container";const h=["/_lunora/*","/__lunora/*"],G=[h,["/_lunora/*"]],H="/*",v=100,$=100,x="runWorkerFirst",Q=/^[\w.~@%+-]+$/u,V=e=>{const s=e.split("/").filter(r=>r!==""),t=s.map(r=>Q.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)),C=e=>e.flatMap((s,t)=>{const n=e.find(i=>_(s,i));return[...s.length>$?[`assets.run_worker_first entry "${s}" is ${String(s.length)} characters; Cloudflare accepts at most ${String($)}`]:[],...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`]]}),Se=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>v&&s.push(`assets.run_worker_first has ${String(e.length)} rules; Cloudflare accepts at most ${String(v)}, 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(...C(t),...C(n)),s},Y=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`,z=e=>{const s=[],t=new Set;for(const o of e){const r=V(o);if(r===void 0){s.push(Y(o));continue}for(const c of r)c.length>$?s.push(`run_worker_first rule "${c}" is longer than Cloudflare's ${String($)} characters and was left out`):t.add(c)}const n=[...h,...t],i=[...new Set(n)].filter(o=>!n.some(r=>_(o,r))&&!h.includes(o)).toSorted((o,r)=>o.localeCompare(r)),a=v-h.length;return i.length>a&&s.push(`the routes need ${String(i.length+h.length)} run_worker_first rules and Cloudflare accepts ${String(v)}; ${i.slice(a).join(", ")} were left out`),{rules:[...h,...i.slice(0,a)],warnings:s}},B=(e,s)=>e===s||_(e,s)||_(s,e),J=(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(u=>u===r||_(r,u))){n.push(r);continue}const c=o.filter(u=>B(u.slice(1),r));c.length>0&&t.set(r,c)}return{excluded:t,missing:n}},X=(e,s,t)=>{const{excluded:n,missing:i}=J(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]),Z=e=>{const s=e?.lunora?.[x];return k(s)?Object.fromEntries(Object.entries(s).filter(t=>Array.isArray(t[1])&&t[1].every(n=>typeof n=="string"))):{}},ee=(e,s)=>{const t=[...new Set(s)].filter(o=>o.length<$&&!e.some(r=>B(o,r))),n=t.filter(o=>!t.some(r=>_(o,r))).toSorted((o,r)=>o.localeCompare(r)).map(o=>`!${o}`),i=v-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:[H,...n.slice(0,i)],warnings:a}},se=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}`,ne=(e,s,t,n,i)=>e===void 0||E(e,i)||G.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:X(e,s,n)},te=e=>[{assets:e.assets,path:["assets"]},...Object.entries(e.env??{}).flatMap(([s,t])=>k(t)?[{assets:t.assets,path:["env",s,"assets"]}]:[])],ie=(e,s,t)=>t!==void 0&&s.assets===void 0?{added:["assets (Studio documents, run_worker_first: true)"],text:A(e,["assets"],K()),updated:[]}:t===void 0&&F(s.assets)?{added:[],text:A(e,["assets"],void 0),updated:["assets (Studio documents block removed)"]}:{added:[],text:e,updated:[]},je=(e,s,t,n,i,a)=>{const o=te(s).filter(g=>!F(g.assets)),r=z(t),c=ee(r.rules,i),u=Z(n),m={},l={...ie(e,s,a),warnings:[]};for(const{assets:g,path:O}of o.filter(f=>k(f.assets))){const f=O.join("."),S=g,I=N(S)!==void 0,j=I?c.rules:r.rules,p=ne(S.run_worker_first,`${f}.run_worker_first`,j,r.rules,u[f]);p.owned&&(m[f]=j),p.owned&&!I&&S.not_found_handling==="single-page-application"&&l.warnings.push(se(f)),p.warning!==void 0&&l.warnings.push(p.warning),p.change!==void 0&&(l.text=A(l.text,[...O,"run_worker_first"],j),l[p.change].push(`${f}.run_worker_first`))}return o.some(g=>k(g.assets))&&l.warnings.unshift(...r.warnings,...o.some(g=>N(g.assets)!==void 0)?c.warnings:[]),{...l,record:{consequence:"the next route change leaves run_worker_first as it is",key:x,label:"run_worker_first rules",write:g=>{D(g,x,Object.keys(m).length===0?void 0:m)}}}},W=[{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"]}],Me=[...new Set(W.map(({path:e})=>e[0]))],q=(e,s)=>{let t=e;for(const n of s)t=b(t)?t[n]:void 0;return t},Ee=e=>{const s={};for(const{of:t,path:n}of W){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},Re=(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}"`)},ae=new Set(["basic","dev","lite","standard","standard-1","standard-2","standard-3","standard-4"]),oe={disk_mb:M.diskMb,memory_mib:M.memoryMib,vcpu:{...M.vcpu,hint:'use the named "lite" or "basic" instance type below 1 vCPU'}},re=(e,s,t)=>{const n=e.instance_type;if(n===void 0)return;if(typeof n=="string"){ae.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:u}]of Object.entries(oe)){const m=n[o];if(m!==void 0&&(typeof m!="number"||Number.isNaN(m)||m<u||m>c)){const l=r!==void 0&&typeof m=="number"&&m<u?` — ${r}`:"";t.push(`${s} custom instance_type ${o} must be a number in ${String(u)}–${String(c)} (got ${String(m)})${l}`)}}const{memory_mib:i,vcpu:a}=n;typeof a=="number"&&typeof i=="number"&&i<a*T&&t.push(`${s} custom instance_type needs ≥ 3 GiB (${String(T)} MiB) memory per vCPU (got ${String(i)} MiB for ${String(a)} vCPU)`)},ce=(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"`)},de=(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?ce(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}"]`),re(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`)},y=e=>Array.isArray(e)?e.filter(s=>s!==null&&typeof s=="object"):[],R=e=>Array.isArray(e)?e.filter(s=>d(s)):[],P=e=>{const s=new Map;for(const t of y(e)){for(const n of R(t.new_classes))s.set(n,"classic");for(const n of R(t.new_sqlite_classes))s.set(n,"sqlite");for(const n of y(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 R(t.deleted_classes))s.delete(n)}return s},ue=e=>new Set(P(e).keys()),Ae=(e,s)=>{const t=ue(e.migrations);for(const n of y(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`)},xe=(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(y(e.durable_objects?.bindings).map(o=>o.class_name)),a=P(e.migrations);for(const[o,r]of n.entries())de(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 } })')},w=e=>e,L=(e,s,t,n)=>{if(e!==void 0){if(!Array.isArray(e)){n.push(t.arrayMessage);return}for(const[i,a]of w(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))}}},We={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`},me=(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",le=e=>{if(e!==void 0)return b(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"},ge=e=>e===void 0?[]:b(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"],U=(e,s,t,n)=>{const i=[me(e.schedules,t),le(e.limits),...ge(e.default_retention)];for(const a of i)a!==void 0&&n.push(`${s}.${a}`)},fe=(e,s)=>W.map(({path:t})=>t).filter(t=>{const n=q(e,t),i=q(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(".")),be=(e,s,t,n)=>{const i=`exports["${e}"]`,a=String(s.name);for(const o of t){if(!b(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 fe(o,s))n.push(`${r} and ${i} set ${c} to different values for workflow "${a}" — set it in one place`)}},Oe=(e,s)=>{const t=Array.isArray(e.workflows)?w(e.workflows):[];for(const[i,a]of t.entries())b(a)&&U(a,`workflows[${String(i)}]`,!1,s);const n=b(e.exports)?Object.entries(e.exports):[];for(const[i,a]of n)!b(a)||a.type!=="workflow"||(d(a.name)?(U(a,`exports["${i}"]`,!0,s),be(i,a,t,s)):s.push(`exports["${i}"] is a workflow export and must have a non-empty "name" naming the deployed workflow`))},pe={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`},he={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`},Ie=(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}L(e.queues.producers,"queues.producers",pe,s),L(e.queues.consumers,"queues.consumers",he,s)}},Ne={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`},Te=[{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"}],Ce=(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 w(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(u=>d(o[u]))||n.push(s.hintMessage(r,o.binding))}}},qe=[{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" })'}],Le=(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)},Ue=[{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`}],Fe=(e,s,t)=>{s?.hasD1GlobalTable&&!y(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&&y(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)')},Be=(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 w(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`)}}},Pe=(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 w(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)`)}}};export{Te as H,Ue as R,qe as S,We as W,Se as a,Fe as b,Be as c,Re as d,xe as e,ue as f,L as g,Oe as h,Ie as i,Ce as j,Le as k,Pe as l,Ne as m,je as n,y as o,Me as p,R as q,ie as r,q as s,W as t,Ae as v,Ee as w};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{existsSync as f,readFileSync as N,readdirSync as I}from"node:fs";import{join as p,dirname as v,extname as h,basename as x}from"node:path";import{Project as b,Node as d}from"ts-morph";import{COMPOSED_WORKER_ENTRY as w,LUNORA_WORKER_VIRTUAL_ID as u,isGeneratedOutput as L,WORKER_ENTRY_FALLBACKS as M,GENERATED_DIRECTORY as j,isMergedProject as F,MERGED_DURABLE_OBJECT as P,COMPOSED_ENTRY_DURABLE_OBJECTS as k,GENERATED_CLASS_MODULES as U,isMergedRoleModule as W,SOURCE_DOT_DIRECTORIES as B,NON_SOURCE_DIRECTORIES as K}from"./COMPOSED_WORKER_ENTRY-LpLlp-aF.mjs";const E=[".ts",".tsx",".mts",".cts"],g=new Set(E),X=new Set([".cjs",".js",".mjs"]),m="default",S={".cjs":[".cts"],".js":[".ts",".tsx"],".mjs":[".mts"]},Y=250,ae=(e,o,t)=>{const s=p(o,w);if(f(s))return{origin:"declared",path:s};if(e===u)return{origin:"composed"};const n=()=>{const i=M.map(a=>p(o,a)).find(a=>f(a));return i===void 0?void 0:{origin:"probed",path:i}};if(typeof e!="string"||e.length===0||L(e))return n();const r=p(v(t),e),c=h(r);if(!(!g.has(c)&&!X.has(c)))return f(r)?{origin:"declared",path:r}:{origin:"absent",path:r}},_=(e,o)=>{if(d.isIdentifier(e)){o.add(e.getText());return}if(d.isObjectBindingPattern(e)||d.isArrayBindingPattern(e))for(const t of e.getElements())d.isBindingElement(t)&&_(t.getNameNode(),o)},G=(e,o)=>{const t=[];for(const s of e.getExportDeclarations())if(!s.isTypeOnly()){if(s.isNamespaceExport()){const n=s.getNamespaceExport();n===void 0?t.push(s.getModuleSpecifierValue()??""):o.add(n.getName());continue}for(const n of s.getNamedExports())n.isTypeOnly()||o.add(n.getAliasNode()?.getText()??n.getName())}return t},$=(e,o)=>{for(const t of e.getVariableStatements().filter(s=>s.getExportKeyword()!==void 0))for(const s of t.getDeclarations())_(s.getNameNode(),o);for(const t of[...e.getClasses(),...e.getFunctions(),...e.getEnums()]){if(t.getExportKeyword()===void 0)continue;const s=t.isDefaultExport()?m:t.getName();s!==void 0&&o.add(s)}e.getExportAssignments().length>0&&o.add(m)},y=(e,o)=>{const t=new b({compilerOptions:{allowJs:!0},skipFileDependencyResolution:!0,skipLoadingLibFiles:!0,useInMemoryFileSystem:!0}),s=t.createSourceFile(e,o,{overwrite:!0});return t.getProgram().compilerObject.getSyntacticDiagnostics(s.compilerNode).length>0?void 0:s},J=(e,o)=>{if(!o.startsWith("./")&&!o.startsWith("../"))return;const t=p(v(e),o),s=h(t),n=g.has(s)||S[s]!==void 0,r=n?t.slice(0,-s.length):t;return[...g.has(s)?[t]:[],...(S[s]??[]).map(i=>`${r}${i}`),...n?[]:E.map(i=>`${t}${i}`),...n||s.length===0?E.map(i=>p(r,`index${i}`)):[]].find(i=>f(i))},T=e=>{const o=new Set,t=new Set([e]),s=[e];for(;s.length>0;){if(t.size-1>Y)return;const n=s.pop();let r;try{r=N(n,"utf8")}catch{return}const c=y(x(n),r);if(c===void 0)return;const i=G(c,o);$(c,o);for(const a of i){const l=J(n,a);if(l===void 0)return;t.has(l)||(t.add(l),s.push(l))}}return o},z=(e,o)=>{const t={exports:void 0,kind:"composed",path:u},s=p(e,o,j);if(!f(s))return t;const n=F(s),r=new Set(n?[P]:k);for(const c of U){const i=p(s,`${c}.ts`);if(!f(i)||n&&W(c))continue;const a=T(i);if(a===void 0)return t;for(const l of a)r.add(l)}return{exports:r,kind:"composed",path:u}},de=(e,o,t)=>{if(e===void 0||e.origin==="absent")return;if(e.origin==="composed")return z(o,t);const s=T(e.path);if(!(e.origin==="probed"&&s!==void 0&&!s.has(m)))return{exports:s,kind:"authored",path:e.path}},q=new Set([".cjs",".cts",".js",".jsx",".mjs",".mts",".ts",".tsx"]),V=2e3,O="defineTable",R="defineApp",H=e=>{const o=[],t=[];let s;try{s=I(e,{withFileTypes:!0})}catch{return{files:o,subdirectories:t}}for(const n of s)n.isDirectory()?n.name.startsWith(".")&&!B.has(n.name)||K.has(n.name)||t.push(p(e,n.name)):q.has(h(n.name))&&o.push(p(e,n.name));return{files:o,subdirectories:t}},D=(e,o)=>{const t=new Set;for(const s of e.getImportDeclarations())for(const n of s.getNamedImports())!n.isTypeOnly()&&n.getName()===o&&t.add(n.getAliasNode()?.getText()??n.getName());return t},Q=(e,o)=>{let t=!1;return e.forEachDescendant((s,n)=>{if(!d.isCallExpression(s))return;const r=s.getExpression();d.isIdentifier(r)&&o.has(r.getText())&&(t=!0,n.stop())}),t},Z=e=>{let o=e;for(;d.isCallExpression(o)||d.isPropertyAccessExpression(o);)o=o.getExpression();return o},ee=(e,o)=>{const t=Z(e);return d.isIdentifier(t)&&o.has(t.getText())},A={analyticsSql:/\.\s*analyticsSql\s*\(/u,global:/\.\s*global\s*\(/u,hyperdriveGlobal:/\.\s*hyperdriveGlobal\s*\(/u,vectors:/\.\s*vectors\s*\(/u},te=e=>Object.hasOwn(A,e),se=(e,o)=>{const t=new Set,s=new Set([O,...D(e,O)]);return e.forEachDescendant(n=>{if(!d.isCallExpression(n))return;const r=n.getExpression();if(!d.isPropertyAccessExpression(r)||ee(r,s))return;const c=r.getName();te(c)&&o.has(c)&&t.add(c)}),t},oe=(e,o)=>{let t;try{t=N(e,"utf8")}catch{return}const s=new Set([...o].filter(r=>A[r].test(t)));if(s.size===0&&!t.includes(R))return;const n=y(x(e),t);return n===void 0?{chained:s,composes:!1}:{chained:se(n,s),composes:Q(n,D(n,R))}},le=(e,o)=>{const t=[e],s=new Set;let n=0,r;const c=i=>{if(n+=1,n>V)return!1;const a=oe(i,o);for(const l of a?.chained??[])s.add(l);return a?.composes&&(r??=i),!0};for(;t.length>0;){const i=t.pop(),{files:a,subdirectories:l}=H(i);t.push(...l);for(const C of a){if(!c(C))return;if(r!==void 0&&s.size===o.size)return{chained:s,site:r}}}return r===void 0?void 0:{chained:s,site:r}};export{ae as l,de as r,le as s};
|