@lunora/config 1.0.0-alpha.459 → 1.0.0-alpha.460
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/cli/index.mjs +1 -1
- package/dist/cloudflare/index.d.mts +1097 -1068
- package/dist/cloudflare/index.d.ts +1097 -1068
- package/dist/cloudflare/index.mjs +1 -1
- package/dist/index.d.mts +119 -6
- package/dist/index.d.ts +119 -6
- package/dist/index.mjs +1 -1
- package/dist/packem_shared/BINDING_MANIFEST_VERSION-CR06-eW7.mjs +1 -0
- package/dist/packem_shared/{CLOUDFLARE_CLI_CONFIG_WARNING_ENV-BKMrOuXV.mjs → CLOUDFLARE_CLI_CONFIG_WARNING_ENV-75Y5zVF8.mjs} +1 -1
- package/dist/packem_shared/{COMPOSED_WORKER_ENTRY-BcFt6ts5.mjs → COMPOSED_WORKER_ENTRY-LpLlp-aF.mjs} +1 -1
- package/dist/packem_shared/{DEFAULT_DEPLOY_TARGET-DllYb7Tj.mjs → DEFAULT_DEPLOY_TARGET-CAJl2nEI.mjs} +1 -1
- package/dist/packem_shared/DEV_VARS_EXAMPLE_FILE-hBT89IXh.mjs +6 -0
- package/dist/packem_shared/{DEV_WORKER_ENV_VALUE-DdPmCpf3.mjs → DEV_WORKER_ENV_VALUE-FoysLtF0.mjs} +1 -1
- package/dist/packem_shared/LUNORA_EVENT_SOURCE-Cq0oj0_9.mjs +9 -0
- package/dist/packem_shared/PACKAGE_SECRETS_REGISTRY-CPWkw-qE.mjs +1 -0
- package/dist/packem_shared/{POLICY_SCAFFOLD_ENDPOINT-uJ8CZJh-.mjs → POLICY_SCAFFOLD_ENDPOINT-UcPFeEyM.mjs} +1 -1
- package/dist/packem_shared/REMOTE_ELIGIBLE_KEYS-D66_hwjD.mjs +1 -0
- package/dist/packem_shared/REQUIRED_COMPATIBILITY_DATE-BPxR2Ht_.mjs +1 -0
- package/dist/packem_shared/{SCHEMA_EDIT_ENDPOINT-C4h_C4TI.mjs → SCHEMA_EDIT_ENDPOINT-C-ic_pvD.mjs} +1 -1
- package/dist/packem_shared/{STUDIO_PATH-C6kNFiHy.mjs → STUDIO_PATH-CDf-EtPs.mjs} +1 -1
- package/dist/packem_shared/UNEXPORTED_CLASS_MARKER-Zw1oiigQ.mjs +1 -0
- package/dist/packem_shared/WRANGLER_FILES-BF8PUjuo.mjs +1 -0
- package/dist/packem_shared/{assertBuildTargetMatches-CqrrwiQ-.mjs → assertBuildTargetMatches-tkKAa5zl.mjs} +1 -1
- package/dist/packem_shared/{assertWranglerSatisfiesSchema-071lEemx.mjs → assertWranglerSatisfiesSchema-CZWQnfly.mjs} +1 -1
- package/dist/packem_shared/{bindingsNeedingDatabase-6eD6Qtqf.mjs → bindingsNeedingDatabase-3KyGflIq.mjs} +1 -1
- package/dist/packem_shared/buildPackageSecretsBlock-DrSD60vH.mjs +19 -0
- package/dist/packem_shared/{celld-config-DoBVipuN.mjs → celld-config-CpvLkAEg.mjs} +1 -1
- package/dist/packem_shared/checkDevEnv-egiW2lSF.mjs +3 -0
- package/dist/packem_shared/{collectExportGaps-C5OYqfkE.mjs → collectExportGaps-BYo3bcXi.mjs} +2 -2
- package/dist/packem_shared/{createStudioDocumentCache-B3Sf1bIl.mjs → createStudioDocumentCache-XBG1aWbl.mjs} +1 -1
- package/dist/packem_shared/{describePreservedCrons-Bt2rPPeY.mjs → describePreservedCrons-i5XT6rtl.mjs} +1 -1
- package/dist/packem_shared/devTriggerHints-CN_RJxWW.mjs +1 -0
- package/dist/packem_shared/{devVariablesStamp-Cetr3qFz.mjs → devVariablesStamp-BQkGEn9d.mjs} +1 -1
- package/dist/packem_shared/{emitProjectAssetHeaders-2FtExZPG.mjs → emitProjectAssetHeaders-6iinmRWE.mjs} +1 -1
- package/dist/packem_shared/guards-CoCtgpeR.mjs +1 -0
- package/dist/packem_shared/hasCloudflareCredentials-ByCrwaLT.mjs +1 -0
- package/dist/packem_shared/inferLunoraBindings-Biq1OW9V.mjs +1 -0
- package/dist/packem_shared/{materializeServiceDevConfigs-qUY4_iu1.mjs → materializeServiceDevConfigs-CI1HXv7f.mjs} +1 -1
- package/dist/packem_shared/pendingBindingChanges-5fPhwxMt.mjs +1 -0
- package/dist/packem_shared/{infer-bindings.d-Tkaosiub.d.mts → placeholder-ids.d-DvGHP6bl.d.mts} +18 -18
- package/dist/packem_shared/{infer-bindings.d-Tkaosiub.d.ts → placeholder-ids.d-DvGHP6bl.d.ts} +18 -18
- package/dist/packem_shared/queue-info-D38n7YdX.mjs +1 -0
- package/dist/packem_shared/reconcile-services-CjgIJKim.mjs +1 -0
- package/dist/packem_shared/reconcileWranglerBindings-D7mXDfAe.mjs +1 -0
- package/dist/packem_shared/{reconcileWranglerCompatibilityDate-hocXEuRA.mjs → reconcileWranglerCompatibilityDate-Cj94osA-.mjs} +1 -1
- package/dist/packem_shared/scanWranglerVariablesForSecrets-DojbojUo.mjs +1 -0
- package/dist/packem_shared/secret-key-xi4VK8Jw.mjs +1 -0
- package/dist/packem_shared/{startCelldDevSession-Bg_RN5uf.mjs → startCelldDevSession-DQ7YylR_.mjs} +1 -1
- package/dist/packem_shared/validate-bindings-CQbR23li.mjs +1 -0
- package/dist/packem_shared/withTailConsumer-CKXL6P6s.mjs +1 -0
- package/dist/packem_shared/{worker-entry-checks-CHrum2AN.mjs → worker-entry-checks-DH-ApvvX.mjs} +1 -1
- package/dist/packem_shared/wranglerCodegenInputs-Cz9ByxSo.mjs +1 -0
- package/dist/packem_shared/{write-atomic-NN-EjI8U.mjs → write-atomic-CcNMkFsX.mjs} +1 -1
- package/dist/studio-host/index.mjs +1 -1
- package/package.json +4 -2
- package/dist/packem_shared/BINDING_MANIFEST_VERSION-CfXEYG8e.mjs +0 -1
- package/dist/packem_shared/DEV_VARS_EXAMPLE_FILE-CqLorAxT.mjs +0 -6
- package/dist/packem_shared/LUNORA_EVENT_SOURCE-D_VGT1JJ.mjs +0 -9
- package/dist/packem_shared/PACKAGE_SECRETS_REGISTRY-CnY7jg9j.mjs +0 -1
- package/dist/packem_shared/REMOTE_ELIGIBLE_KEYS-DooK0pzs.mjs +0 -1
- package/dist/packem_shared/REQUIRED_COMPATIBILITY_DATE-CKjEIFrf.mjs +0 -1
- package/dist/packem_shared/UNEXPORTED_CLASS_MARKER-YnIX5BDi.mjs +0 -1
- package/dist/packem_shared/WRANGLER_FILES-UNW-xY5u.mjs +0 -1
- package/dist/packem_shared/buildPackageSecretsBlock-B4Odg5OF.mjs +0 -19
- package/dist/packem_shared/hasCloudflareCredentials-Bak5w1_6.mjs +0 -1
- package/dist/packem_shared/inferLunoraBindings-D0QDcugr.mjs +0 -1
- package/dist/packem_shared/package-secrets-registry-TouCAMQN.mjs +0 -1
- package/dist/packem_shared/reconcile-assets-h8q3F4Sy.mjs +0 -1
- package/dist/packem_shared/reconcile-services-C4TwY8YH.mjs +0 -1
- package/dist/packem_shared/reconcileBindingsSafely-BI6znzGg.mjs +0 -1
- package/dist/packem_shared/scanWranglerVariablesForSecrets-CkonQUdG.mjs +0 -1
- package/dist/packem_shared/spa-assets-BwJFTBeO.mjs +0 -1
- package/dist/packem_shared/withTailConsumer-_EZ9WqMc.mjs +0 -1
- package/dist/packem_shared/wranglerCodegenInputs-BZUWdHzz.mjs +0 -1
package/dist/packem_shared/{infer-bindings.d-Tkaosiub.d.ts → placeholder-ids.d-DvGHP6bl.d.ts}
RENAMED
|
@@ -13,23 +13,6 @@ interface DiscoveryCache {
|
|
|
13
13
|
memo: <T>(key: string, compute: () => T) => T;
|
|
14
14
|
}
|
|
15
15
|
declare const createDiscoveryCache: () => DiscoveryCache;
|
|
16
|
-
/**
|
|
17
|
-
* Placeholder `database_id` written for an auto-provisioned `DB` binding. It is
|
|
18
|
-
* intentionally not a valid id so a deploy can't silently target the wrong
|
|
19
|
-
* database; reconciliation warns the user to replace it (see the D1 warning in
|
|
20
|
-
* `reconcileWranglerBindings`).
|
|
21
|
-
*
|
|
22
|
-
* Kept apart from `reconcile-bindings` so a module that only needs the string
|
|
23
|
-
* (`celld-config`, reached from `@lunora/config/cli` through the driver
|
|
24
|
-
* registry) does not pull codegen and ts-morph into every CLI start.
|
|
25
|
-
*/
|
|
26
|
-
declare const D1_PLACEHOLDER_ID = "<replace-with-d1-create-id>";
|
|
27
|
-
/**
|
|
28
|
-
* The `id` reconcile writes on a Hyperdrive binding it adds, and the one the `hyperdrive`
|
|
29
|
-
* registry item ships: wrangler requires a string, and `lunora dev` serves the binding from an
|
|
30
|
-
* embedded Postgres whatever it is. `lunora deploy` swaps in a real id.
|
|
31
|
-
*/
|
|
32
|
-
declare const HYPERDRIVE_PLACEHOLDER_ID = "<replace-with-hyperdrive-create-id>";
|
|
33
16
|
/** One filterable Vectorize metadata property a schema declares. */
|
|
34
17
|
interface VectorMetadataDeclaration {
|
|
35
18
|
/** The vector index the property belongs to. */
|
|
@@ -335,4 +318,21 @@ declare const inferLunoraBindings: (options: InferOptions) => Promise<InferredBi
|
|
|
335
318
|
* ({@link SECRET_SOURCE_FLAGS}), keeping only sources that carry secrets.
|
|
336
319
|
*/
|
|
337
320
|
declare const secretSourcesFromBindings: (bindings: InferredBindings) => string[];
|
|
338
|
-
|
|
321
|
+
/**
|
|
322
|
+
* Placeholder `database_id` written for an auto-provisioned `DB` binding. It is
|
|
323
|
+
* intentionally not a valid id so a deploy can't silently target the wrong
|
|
324
|
+
* database; reconciliation warns the user to replace it (see the D1 warning in
|
|
325
|
+
* `reconcileWranglerBindings`).
|
|
326
|
+
*
|
|
327
|
+
* Kept apart from `reconcile-bindings` so a module that only needs the string
|
|
328
|
+
* (`celld-config`, reached from `@lunora/config/cli` through the driver
|
|
329
|
+
* registry) does not pull codegen and ts-morph into every CLI start.
|
|
330
|
+
*/
|
|
331
|
+
declare const D1_PLACEHOLDER_ID = "<replace-with-d1-create-id>";
|
|
332
|
+
/**
|
|
333
|
+
* The `id` reconcile writes on a Hyperdrive binding it adds, and the one the `hyperdrive`
|
|
334
|
+
* registry item ships: wrangler requires a string, and `lunora dev` serves the binding from an
|
|
335
|
+
* embedded Postgres whatever it is. `lunora deploy` swaps in a real id.
|
|
336
|
+
*/
|
|
337
|
+
declare const HYPERDRIVE_PLACEHOLDER_ID = "<replace-with-hyperdrive-create-id>";
|
|
338
|
+
export { COMPOSED_WORKER_ENTRY as C, DiscoveryCache as D, GeneratedClassModule as G, HYPERDRIVE_PLACEHOLDER_ID as H, InferredBindings as I, MERGED_DURABLE_OBJECTS_MODULE as M, SchemaInfo as S, D1_PLACEHOLDER_ID as a, DURABLE_OBJECT_BINDINGS as b, DiscoverSchemaInfoResult as c, GENERATED_CLASS_MODULES as d, GENERATED_MODULE_DURABLE_OBJECTS as e, InferOptions as f, InferredAgent as g, InferredContainer as h, InferredWorkflow as i, createDiscoveryCache as j, discoverSchemaInfo as k, inferLunoraBindings as l, isMergedProject as m, isMergedRoleModule as n, secretSourcesFromBindings as s };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{discoverQueues as u}from"@lunora/codegen";import{d}from"./discover-info-DC2MrAIM.mjs";const v=(o,r)=>{const{error:e,value:s}=d(o,r,void 0,u);return e===void 0?{queues:s??[]}:{error:e,queues:[]}};export{v as d};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{existsSync as k}from"node:fs";import{applyModify as M}from"./applyModify-DKP2l6S9.mjs";import{canonical as h,recordManifestKey as _}from"./readManifest-Cighz3WC.mjs";import{readWranglerJsonc as A}from"./WRANGLER_FILES-BF8PUjuo.mjs";import{join as D}from"node:path";const $="services",m="services",O="wrangler.dev.jsonc",u="dev:services",L=(t,n,r)=>{const i=n===void 0?t.worker:t.envWorkers[n]??`${t.worker}-${n}`,a=t.entrypoint??(n===void 0?void 0:r);return{binding:t.binding,...a===void 0?{}:{entrypoint:a},service:i}},l=t=>typeof t?.binding=="string"?t.binding:"",x=(t,n,r,i,a,d,w)=>{const p=n.join("."),o=new Map(i.map(e=>[e.binding,L(e,d,w.get(e.binding))])),s=r.filter(e=>!a.has(l(e))),f=new Set(s.map(e=>l(e))),g=new Map(r.filter(e=>a.has(l(e))).map(e=>[l(e),e])),c=[...o].filter(([e])=>!f.has(e)),y=[...s,...c.map(([,e])=>e)],S=c.filter(([e])=>!g.has(e)).map(([e,v])=>`${p}/${e} → ${v.service??""}`),b=[...c.filter(([e,v])=>g.has(e)&&h(g.get(e))!==h(v)).map(([e])=>`${p}/${e}`),...[...g.keys()].filter(e=>!o.has(e)).map(e=>`${p}/${e} (removed)`)],E=s.filter(e=>o.has(l(e))&&h(e)!==h(o.get(l(e)))).map(e=>`${p}: the hand-written "${l(e)}" entry is left as is — remove it to let lunora.config \`services\` manage that binding.`),j=S.length>0||b.length>0,C=y.length===0?void 0:y;return{added:S,owned:c.map(([e])=>e).toSorted((e,v)=>e.localeCompare(v)),text:j?M(t,n,C):t,updated:b,warnings:E}},V=t=>{const n=t?.lunora?.[$];return typeof n!="object"||n===null||Array.isArray(n)?{}:Object.fromEntries(Object.entries(n).filter(r=>Array.isArray(r[1])&&r[1].every(i=>typeof i=="string")))},B=t=>new Set(V(t)[m]),G=(t,n,r,i)=>{const a=[{current:n.services??[],path:[m]},...Object.entries(n.env??{}).map(([o,s])=>({current:s?.services??[],environment:o,path:["env",o,"services"]}))],d={added:[],owned:{},text:t,updated:[],warnings:[]},w=new Set(i[m]),p=new Map;for(const o of n.services??[])typeof o?.binding=="string"&&typeof o.entrypoint=="string"&&!w.has(o.binding)&&p.set(o.binding,o.entrypoint);for(const{current:o,environment:s,path:f}of a){const g=f.join("."),c=x(d.text,f,o,r,new Set(i[g]),s,p);d.text=c.text,d.added.push(...c.added),d.updated?.push(...c.updated??[]),d.warnings?.push(...c.warnings??[]),c.owned.length>0&&(d.owned[g]=c.owned)}return d},N=(t,n,r)=>{const i=D(t,O),a=r[u],d=a===void 0||a.length===0?{}:{[u]:a},w={added:[],original:"",path:i,previouslyOwned:d,text:"",updated:[],warnings:[]};if(n.length===0&&r[u]===void 0)return{...w,owned:{}};const{parsed:p,text:o}=k(i)?A(i):{parsed:void 0,text:""};if(p===void 0)return{...w,owned:d};const s=x(o,["services"],p.services??[],n,new Set(r[u]),void 0,new Map);return{added:s.added,original:o,owned:s.owned.length>0?{[u]:s.owned}:{},path:i,previouslyOwned:d,text:s.text,updated:s.updated??[],warnings:(s.warnings??[]).map(f=>`${O} ${f}`)}},T=(t,n)=>{_(t,$,Object.keys(n).length===0?void 0:n)};export{G as a,T as b,B as o,N as p,V as r};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{writeFileSync as c}from"node:fs";import{readManifest as g}from"./readManifest-Cighz3WC.mjs";import{planWranglerBindings as u}from"./collectExportGaps-BYo3bcXi.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},l=(r,e,{devConfigWritten:n,wranglerChanged:s})=>{const{manifest:o}=e;if(o===void 0)return[];const i=[];for(const t of e.records)try{t.write(g(r)??o,{devConfigWritten:n})}catch(a){i.push(`${s?"wrangler.jsonc was updated, but ":""}recording the ${t.label} reconcile owns in ${o.path} (lunora.${t.key}) failed: ${a instanceof Error?a.message:String(a)}. Until it is recorded, ${t.consequence}.`)}return i},h=(r,e)=>{if(!(r===void 0||r.text===r.original))try{c(r.path,r.text,"utf8");return}catch(n){return`${e?"wrangler.jsonc was updated, but ":""}writing ${r.path} failed: ${n instanceof Error?n.message:String(n)}. The dev sidecar keeps its previous service bindings until the next reconcile writes it.`}},f=(r,e)=>{const{edit:n,...s}=e;if(n===void 0||e.wranglerPath===void 0)return{...s,changed:!1,devConfig:d(e.devConfig)};const o=[...e.warnings],i=n.text!==n.original;i&&c(e.wranglerPath,n.text,"utf8");const t=h(e.devConfig,i);return t!==void 0&&o.push(t),o.push(...l(r,n,{devConfigWritten:t===void 0,wranglerChanged:i})),{...s,changed:i,devConfig:t===void 0?d(e.devConfig):void 0,...i?{}:{reason:"bindings already in sync"},warnings:o}},m=(r,e,n={})=>f(r,u(r,e,n));export{f as applyWranglerBindings,m as reconcileWranglerBindings};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{writeFileSync as d}from"node:fs";import{modify as c,applyEdits as l}from"jsonc-parser";import{FORMATTING as s}from"./applyModify-DKP2l6S9.mjs";import{isCacheEnabled as f,WORKERS_CACHE_MIN_DATE as a}from"./WORKERS_CACHE_MIN_DATE-0k9ABJtF.mjs";import{findWranglerFile as m,readWranglerJsonc as p}from"./WRANGLER_FILES-
|
|
1
|
+
import{writeFileSync as d}from"node:fs";import{modify as c,applyEdits as l}from"jsonc-parser";import{FORMATTING as s}from"./applyModify-DKP2l6S9.mjs";import{isCacheEnabled as f,WORKERS_CACHE_MIN_DATE as a}from"./WORKERS_CACHE_MIN_DATE-0k9ABJtF.mjs";import{findWranglerFile as m,readWranglerJsonc as p}from"./WRANGLER_FILES-BF8PUjuo.mjs";const _=i=>{const e=m(i);if(!e)return{changed:!1,date:void 0,reason:"wrangler.jsonc not found"};const{parsed:r,text:n}=p(e);if(r===void 0)return{changed:!1,date:void 0,reason:`failed to parse ${e} as JSONC`,wranglerPath:e};const t=r.compatibility_date??"";if(!f(r))return{changed:!1,date:t||void 0,reason:"cache not enabled",wranglerPath:e};if(t>=a)return{changed:!1,date:t,reason:`compatibility_date already >= ${a}`,wranglerPath:e};const o=c(n,["compatibility_date"],a,s);return o.length===0?{changed:!1,date:t||void 0,reason:"no structural edit produced",wranglerPath:e}:(d(e,l(n,o),"utf8"),{changed:!0,date:a,wranglerPath:e})};export{_ as reconcileWranglerCompatibilityDate};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{secretKindOf as s,redact as c}from"@lunora/codegen";import{a,i as f}from"./secret-key-xi4VK8Jw.mjs";import{isPlaceholderValue as d}from"./buildPackageSecretsBlock-DrSD60vH.mjs";const u=8,h=(n,o)=>{if(n===void 0)return[];const r=[];for(const[i,e]of Object.entries(n)){if(typeof e!="string"||d(e)||a(i))continue;const t=s(e)??(f(i)&&e.length>=u?"secret_named_var":void 0);t!==void 0&&r.push({file:o,key:i,kind:t,preview:c(e)})}return r};export{h as scanWranglerVariablesForSecrets};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const S=e=>e.endsWith("S")?e.slice(0,-1):e,n=e=>e.replaceAll(/([a-z\d])([A-Z])/gu,"$1_$2").toUpperCase().split(/[_-]+/u).filter(s=>s.length>0),o=new Set(["CREDENTIAL","DSN","PASSPHRASE","PASSWD","PASSWORD","SECRET","TOKEN"]),i=["ACCESS_KEY","API_KEY","ENCRYPTION_KEY","PRIVATE_KEY","SIGNING_KEY"],_=new RegExp(`(?:${[...o,...i.map(e=>e.replaceAll("_",""))].join("|")})S?$`,"iu"),a=e=>n(e).some(s=>s==="PUBLIC"||s==="PUBLISHABLE"),c=e=>{if(a(e))return!1;const s=n(e);if(s.some(E=>o.has(S(E))))return!0;const t=S(s.join("_"));return i.some(E=>t===E||t.endsWith(`_${E}`))||_.test(e)};export{a,c as i};
|
package/dist/packem_shared/{startCelldDevSession-Bg_RN5uf.mjs → startCelldDevSession-DQ7YylR_.mjs}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{watch as R}from"node:fs";import{createServer as _}from"node:net";import{dirname as C}from"node:path";import{readDevServiceBindings as j}from"@lunora/codegen";import{acceptsConnection as M,startDevProcess as x}from"./acceptsConnection-DHhUYGjT.mjs";import N from"./resolveSchemaDirectory-Ca5P6KuP.mjs";import{p as b,a as O}from"./celld-config-
|
|
1
|
+
import{watch as R}from"node:fs";import{createServer as _}from"node:net";import{dirname as C}from"node:path";import{readDevServiceBindings as j}from"@lunora/codegen";import{acceptsConnection as M,startDevProcess as x}from"./acceptsConnection-DHhUYGjT.mjs";import N from"./resolveSchemaDirectory-Ca5P6KuP.mjs";import{p as b,a as O}from"./celld-config-CpvLkAEg.mjs";import{probeCelldToolchain as F}from"./probeCelldToolchain-DxDttfHy.mjs";const I=6e4,B=200,G=new Set([".celld",".wrangler","node_modules"]),H=/[/\\]/u,U=async()=>new Promise((e,o)=>{const s=_();s.once("error",o),s.listen(0,"127.0.0.1",()=>{const n=s.address();s.close(()=>{e(typeof n=="object"&&n!==null?n.port:0)})})}),q=e=>e?.split(H).some(o=>G.has(o))===!0,L=(e,o,s)=>{let n;const c=R(e,{recursive:!0},(l,d)=>{q(d)||(clearTimeout(n),n=setTimeout(o,B))}),i=()=>{clearTimeout(n),c.close()};return c.once("error",l=>{i(),s(l)}),{close:i}},W=e=>e instanceof Error?e.message:String(e),D=async()=>F({env:process.env,purpose:"dev"}),rr=async e=>{const o=await(e.probe??D)();if(o.errors.length>0)throw new Error(o.errors.join("; "));return b(e.projectRoot,"dev").write(),o.warnings},er=async e=>{const{log:o,port:s,projectRoot:n}=e,c=(r,t="stdout")=>{o(r,{stream:t,tag:"celld"})},i=await(e.probe??D)();for(const r of i.warnings)c(r,"stderr");if(i.errors.length>0)throw new Error(i.errors.join("; "));if(await M(s))throw new Error(`port ${String(s)} is already in use — stop whatever is serving there (another dev server?), or pick another worker port`);const l=j(n,N(n));if(l.error!==void 0)throw new Error(`could not read the lunora.config services: ${l.error}`);const d=b(n,"dev");d.write();const $=C(d.configPath),m=[...new Map(l.services.map(r=>[r.wranglerPath,r])).values()],p=new AbortController,h=()=>p.signal.aborted,u=async(r,t,a)=>x({args:["dev",r,"--port",String(a)],command:"celld",cwd:n,label:"celld dev",notFound:"`celld` was not found on PATH — install it (https://celld.dev) to run the celld target",onLine:T=>{T.trim()!==""&&o(T,{stream:"stdout",tag:t})},port:a,readyTimeoutMs:I,signal:p.signal,spawn:e.spawn}),y=async r=>{const t=O($,r.wranglerPath);t.write(),c(`registering service ${r.worker} in the local dev state`),await(await u(t.configPath,`celld:${r.worker}`,await U())).stop()};for(const r of m)await y(r);let g=()=>{};const E=new Promise(r=>{g=r}),S=async()=>{const r=await u(d.configPath,"celld",s);return r.crashed.then(g).catch(()=>{}),r};let w=await S();const k=async r=>{await w.stop();let t;try{await y(r)}catch(a){t=a instanceof Error?a:new Error(String(a))}if(!h()){try{w=await S()}catch(a){throw h()||g(1),a}if(t!==void 0)throw t}};let f=Promise.resolve();const A=r=>{c(`service ${r.worker} changed — restarting`),f=f.then(async()=>k(r)).catch(t=>{h()||c(`service ${r.worker} failed to restart: ${W(t)}`,"stderr")})},P=[],v=()=>{for(const r of P)r.close()};try{for(const r of m)P.push(L(C(r.wranglerPath),()=>{A(r)},t=>{c(`stopped watching service ${r.worker}: ${t.message} — restart the dev server to pick up its edits`,"stderr")}))}catch(r){throw v(),await w.stop(),r}return E.then(v).catch(()=>{}),{exited:E,stop:async()=>{p.abort(),v(),await f,await w.stop()}}};export{er as startCelldDevSession,rr as writeCelldDevProjection};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{i as w}from"./is-plain-object-CWxHeOY1.mjs";import{applyModify as F}from"./applyModify-DKP2l6S9.mjs";import{recordManifestKey as P}from"./readManifest-Cighz3WC.mjs";import{s as O,i as f,a as d}from"./guards-CoCtgpeR.mjs";import{CUSTOM_INSTANCE_TYPE_LIMITS as j,CUSTOM_INSTANCE_MIN_MEMORY_MIB_PER_VCPU as I}from"@lunora/container";const p=["/_lunora/*","/__lunora/*"],B=[p,["/_lunora/*"]],D="/*",y=100,v=100,R="runWorkerFirst",K=/^[\w.~@%+-]+$/u,G=e=>{const s=e.split("/").filter(r=>r!==""),t=s.map(r=>K.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]},h=(e,s)=>s!==e&&s.endsWith("*")&&e.startsWith(s.slice(0,-1)),N=e=>e.flatMap((s,t)=>{const n=e.find(i=>h(s,i));return[...s.length>v?[`assets.run_worker_first entry "${s}" is ${String(s.length)} characters; Cloudflare accepts at most ${String(v)}`]:[],...e.indexOf(s)===t?[]:[`assets.run_worker_first lists "${s}" twice`],...n===void 0?[]:[`assets.run_worker_first entry "${s}" is already covered by "${n}", which wrangler refuses`]]}),ye=e=>{if(e.length===0)return["assets.run_worker_first is an empty list, which wrangler refuses; remove it, or name at least one path"];const s=[];e.length>y&&s.push(`assets.run_worker_first has ${String(e.length)} rules; Cloudflare accepts at most ${String(y)}, duplicates included`);const t=[],n=[];for(const i of e)typeof i=="string"&&i.startsWith("/")?t.push(i):typeof i=="string"&&i.startsWith("!/")?n.push(i):s.push(`assets.run_worker_first entry ${JSON.stringify(i)} must be a path rule starting with "/" (or "!/" to exempt a path)`);return t.length===0&&n.length>0&&s.push("assets.run_worker_first has only negative (!/…) rules; wrangler needs at least one path that runs the Worker first"),s.push(...N(t),...N(n)),s},H=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`,Q=e=>{const s=[],t=new Set;for(const o of e){const r=G(o);if(r===void 0){s.push(H(o));continue}for(const c of r)c.length>v?s.push(`run_worker_first rule "${c}" is longer than Cloudflare's ${String(v)} characters and was left out`):t.add(c)}const n=[...p,...t],i=[...new Set(n)].filter(o=>!n.some(r=>h(o,r))&&!p.includes(o)).toSorted((o,r)=>o.localeCompare(r)),a=y-p.length;return i.length>a&&s.push(`the routes need ${String(i.length+p.length)} run_worker_first rules and Cloudflare accepts ${String(y)}; ${i.slice(a).join(", ")} were left out`),{rules:[...p,...i.slice(0,a)],warnings:s}},L=(e,s)=>e===s||h(e,s)||h(s,e),V=(e,s)=>{const t=new Map,n=[];if(e===!0)return{excluded:t,missing:n};const i=Array.isArray(e)?e.filter(r=>typeof r=="string"):[],a=i.filter(r=>r.startsWith("/")),o=i.filter(r=>r.startsWith("!/"));for(const r of s){if(!a.some(m=>m===r||h(r,m))){n.push(r);continue}const c=o.filter(m=>L(m.slice(1),r));c.length>0&&t.set(r,c)}return{excluded:t,missing:n}},Y=(e,s,t)=>{const{excluded:n,missing:i}=V(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("; ")},M=(e,s)=>Array.isArray(e)&&e.length===s?.length&&e.every((t,n)=>t===s[n]),z=e=>{const s=e?.lunora?.[R];return w(s)?Object.fromEntries(Object.entries(s).filter(t=>Array.isArray(t[1])&&t[1].every(n=>typeof n=="string"))):{}},J=(e,s)=>{const t=[...new Set(s)].filter(o=>o.length<v&&!e.some(r=>L(o,r))),n=t.filter(o=>!t.some(r=>h(o,r))).toSorted((o,r)=>o.localeCompare(r)).map(o=>`!${o}`),i=y-1,a=n.length>i?[`run_worker_first has room for ${String(i)} static exemptions; ${n.slice(i).join(", ")} run the Worker, which serves them from the assets binding`]:[];return{rules:[D,...n.slice(0,i)],warnings:a}},X=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}`,Z=(e,s,t,n,i)=>e===void 0||M(e,i)||B.some(o=>M(e,o))?M(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:Y(e,s,n)},ee=e=>[{assets:e.assets,path:["assets"]},...Object.entries(e.env??{}).flatMap(([s,t])=>w(t)?[{assets:t.assets,path:["env",s,"assets"]}]:[])],ve=(e,s,t,n,i)=>{const a=ee(s),o=Q(t),r=J(o.rules,i),c=z(n),m={},u={added:[],text:e,updated:[],warnings:[]};for(const{assets:l,path:x}of a.filter(g=>w(g.assets))){const g=x.join("."),k=l,W=O(k)!==void 0,S=W?r.rules:o.rules,b=Z(k.run_worker_first,`${g}.run_worker_first`,S,o.rules,c[g]);b.owned&&(m[g]=S),b.owned&&!W&&k.not_found_handling==="single-page-application"&&u.warnings.push(X(g)),b.warning!==void 0&&u.warnings.push(b.warning),b.change!==void 0&&(u.text=F(u.text,[...x,"run_worker_first"],S),u[b.change].push(`${g}.run_worker_first`))}return a.some(l=>w(l.assets))&&u.warnings.unshift(...o.warnings,...a.some(l=>O(l.assets)!==void 0)?r.warnings:[]),{...u,record:{consequence:"the next route change leaves run_worker_first as it is",key:R,label:"run_worker_first rules",write:l=>{P(l,R,Object.keys(m).length===0?void 0:m)}}}},A=[{of:e=>e.schedules===void 0?void 0:[...e.schedules],path:["schedules"]},{of:e=>e.limits?.steps,path:["limits","steps"]},{of:e=>e.defaultRetention?.successRetention,path:["default_retention","success_retention"]},{of:e=>e.defaultRetention?.errorRetention,path:["default_retention","error_retention"]}],$e=[...new Set(A.map(({path:e})=>e[0]))],T=(e,s)=>{let t=e;for(const n of s)t=f(t)?t[n]:void 0;return t},we=e=>{const s={};for(const{of:t,path:n}of A){const i=t(e);if(i===void 0)continue;const[a,o]=n;s[a]=o===void 0?i:{...s[a],[o]:i}}return s},ke=(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}"`)},se=new Set(["basic","dev","lite","standard","standard-1","standard-2","standard-3","standard-4"]),ne={disk_mb:j.diskMb,memory_mib:j.memoryMib,vcpu:{...j.vcpu,hint:'use the named "lite" or "basic" instance type below 1 vCPU'}},te=(e,s,t)=>{const n=e.instance_type;if(n===void 0)return;if(typeof n=="string"){se.has(n)||t.push(`${s} has unknown instance_type "${n}" — expected lite, basic, standard-1..4, or a custom { vcpu, memory_mib, disk_mb } object`);return}for(const[o,{hint:r,max:c,min:m}]of Object.entries(ne)){const u=n[o];if(u!==void 0&&(typeof u!="number"||Number.isNaN(u)||u<m||u>c)){const l=r!==void 0&&typeof u=="number"&&u<m?` — ${r}`:"";t.push(`${s} custom instance_type ${o} must be a number in ${String(m)}–${String(c)} (got ${String(u)})${l}`)}}const{memory_mib:i,vcpu:a}=n;typeof a=="number"&&typeof i=="number"&&i<a*I&&t.push(`${s} custom instance_type needs ≥ 3 GiB (${String(I)} MiB) memory per vCPU (got ${String(i)} MiB for ${String(a)} vCPU)`)},ie=(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"`)},ae=(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?ie(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}"]`),te(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`)},_=e=>Array.isArray(e)?e.filter(s=>s!==null&&typeof s=="object"):[],E=e=>Array.isArray(e)?e.filter(s=>d(s)):[],U=e=>{const s=new Map;for(const t of _(e)){for(const n of E(t.new_classes))s.set(n,"classic");for(const n of E(t.new_sqlite_classes))s.set(n,"sqlite");for(const n of _(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 E(t.deleted_classes))s.delete(n)}return s},oe=e=>new Set(U(e).keys()),Se=(e,s)=>{const t=oe(e.migrations);for(const n of _(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`)},je=(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(_(e.durable_objects?.bindings).map(o=>o.class_name)),a=U(e.migrations);for(const[o,r]of n.entries())ae(r,`containers[${String(o)}]`,{boundClasses:i,classKinds:a,errors:s,warnings:t});e.observability?.enabled!==!0&&t.push('containers are configured but observability is not enabled — container logs will not be captured (add { "observability": { "enabled": true } })')},$=e=>e,C=(e,s,t,n)=>{if(e!==void 0){if(!Array.isArray(e)){n.push(t.arrayMessage);return}for(const[i,a]of $(e).entries()){const o=`${s}[${String(i)}]`;if(!a||typeof a!="object"){n.push(t.objectMessage(o));continue}for(const r of t.fields)d(a[r.field])||n.push(r.message(o))}}},Me={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`},re=(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",ce=e=>{if(e!==void 0)return f(e)?e.steps===void 0||Number.isInteger(e.steps)&&e.steps>0?void 0:"limits.steps must be a positive integer":"limits must be an object"},de=e=>e===void 0?[]:f(e)?["success_retention","error_retention"].filter(s=>e[s]!==void 0&&!d(e[s])).map(s=>`default_retention.${s} must be a duration string (e.g. "7 days")`):["default_retention must be an object"],q=(e,s,t,n)=>{const i=[re(e.schedules,t),ce(e.limits),...de(e.default_retention)];for(const a of i)a!==void 0&&n.push(`${s}.${a}`)},ue=(e,s)=>A.map(({path:t})=>t).filter(t=>{const n=T(e,t),i=T(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(".")),me=(e,s,t,n)=>{const i=`exports["${e}"]`,a=String(s.name);for(const o of t){if(!f(o)||o.name!==s.name)continue;const r=`workflows entry "${String(o.binding)}"`;if(o.script_name!==void 0){n.push(`${r} binds workflow "${a}" in another Worker, but ${i} declares a workflow with that name here — workflow names are unique per account`);continue}o.class_name!==e&&n.push(`${r} and ${i} both declare workflow "${a}" but name different classes ("${String(o.class_name)}" vs "${e}")`);for(const c of ue(o,s))n.push(`${r} and ${i} set ${c} to different values for workflow "${a}" — set it in one place`)}},Ee=(e,s)=>{const t=Array.isArray(e.workflows)?$(e.workflows):[];for(const[i,a]of t.entries())f(a)&&q(a,`workflows[${String(i)}]`,!1,s);const n=f(e.exports)?Object.entries(e.exports):[];for(const[i,a]of n)!f(a)||a.type!=="workflow"||(d(a.name)?(q(a,`exports["${i}"]`,!0,s),me(i,a,t,s)):s.push(`exports["${i}"] is a workflow export and must have a non-empty "name" naming the deployed workflow`))},le={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`},ge={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`},Re=(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}C(e.queues.producers,"queues.producers",le,s),C(e.queues.consumers,"queues.consumers",ge,s)}},Ae={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`},xe=[{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"}],We=(e,s,t,n)=>{const i=e[s.key];if(i!==void 0){if(!Array.isArray(i)){t.push(s.arrayMessage);return}for(const[a,o]of $(i).entries()){const r=`${s.key}[${String(a)}]`;if(!o||typeof o!="object"||!d(o.binding)){t.push(s.bindingMessage(r));continue}if(!("hintField"in s))continue;(typeof s.hintField=="string"?[s.hintField]:s.hintField).some(m=>d(o[m]))||n.push(s.hintMessage(r,o.binding))}}},Oe=[{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" })'}],Ie=(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)},Ne=[{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`}],Te=(e,s,t)=>{s?.hasD1GlobalTable&&!_(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&&_(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)')},Ce=(e,s)=>{const{d1_databases:t}=e;if(t!==void 0){if(!Array.isArray(t)){s.push("d1_databases must be an array of { binding, database_id | database_name } entries");return}for(const[n,i]of $(t).entries()){const a=`d1_databases[${String(n)}]`;if(!i||typeof i!="object"){s.push(`${a} must be a { binding, database_id | database_name } object`);continue}d(i.binding)||s.push(`${a} must have a non-empty "binding" naming the D1 binding`),!d(i.database_id)&&!d(i.database_name)&&s.push(`${a} must have a "database_id" or a "database_name" — run \`wrangler d1 create\` and set one, or the binding can't resolve`)}}},qe=(e,s)=>{const{vpc_networks:t}=e;if(t!==void 0){if(!Array.isArray(t)){s.push("vpc_networks must be an array of { binding, tunnel_id | network_id } entries");return}for(const[n,i]of $(t).entries()){const a=`vpc_networks[${String(n)}]`;if(!i||typeof i!="object"){s.push(`${a} must be a { binding, tunnel_id | network_id } object`);continue}d(i.binding)||s.push(`${a} must have a non-empty "binding" naming the VPC Network binding`),d(i.tunnel_id)===d(i.network_id)&&s.push(`${a} must set exactly one of "tunnel_id" (a Cloudflare Tunnel) or "network_id" ("cf1:network" for Cloudflare Mesh)`)}}};export{xe as H,Ne as R,Oe as S,Me as W,Te as a,Ce as b,ke as c,je as d,C as e,oe as f,Ee as g,Re as h,We as i,Ie as j,qe as k,Ae as l,ve as m,$e as n,_ as o,E as p,A as q,ye as r,T as s,Se as v,we as w};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{i as _}from"./env-flag-u4B05gLp.mjs";import{i as u,a as h}from"./guards-CoCtgpeR.mjs";import{r as A,o as O}from"./validate-bindings-CQbR23li.mjs";const p=(s,e,t,i)=>{s!==void 0&&typeof s!="boolean"&&t.push(`${e} must be a boolean${i===void 0?"":` (${i})`}`)},S=(s,e,t)=>{s!==void 0&&(typeof s!="number"||Number.isNaN(s)||s<0||s>1)&&t.push(`${e} must be a number in [0, 1] (the fraction of requests sampled)`)},D=(s,e,t)=>{const i=s.send_email;if(i===void 0)return;if(!Array.isArray(i)){e.push("send_email must be an array of { name, destination_address? } entries");return}const n=i;for(const[o,a]of n.entries())(!a||typeof a!="object"||typeof a.name!="string"||a.name.length===0)&&t.push(`send_email[${String(o)}] has no non-empty "name" naming the send-email binding — set one before deploying`)},T=(s,e)=>{p(s.logpush,"logpush",e,'set "logpush": true to enable Cloudflare Logpush')},x=(s,e)=>{const t=s.secrets;if(t===void 0)return;const i=typeof t=="object"&&t!==null&&!Array.isArray(t)?t.required:void 0;(!Array.isArray(i)||i.some(n=>typeof n!="string"||n===""))&&e.push('secrets must be an object whose "required" is an array of secret names (e.g. { "required": ["API_KEY"] })')},b=3e5,U=(s,e)=>{const{limits:t}=s;if(t===void 0)return;if(typeof t!="object"||Array.isArray(t)){e.push('limits must be an object (e.g. { "cpu_ms": 30000 })');return}const i=t.cpu_ms;if(i!==void 0){if(typeof i!="number"||!Number.isFinite(i)||!Number.isInteger(i)||i<=0){e.push("limits.cpu_ms must be a positive integer number of milliseconds");return}i>b&&e.push(`limits.cpu_ms must be at most ${String(b)} (Cloudflare's per-invocation ceiling)`)}},m=new Set(["off","smart","targeted"]),B=(s,e)=>{const{placement:t}=s;if(t===void 0)return;if(typeof t!="object"||t===null||Array.isArray(t)){e.push('placement must be an object (e.g. { "mode": "smart" })');return}const{mode:i}=t;i!==void 0&&(typeof i!="string"||!m.has(i))&&e.push(`placement.mode must be one of ${[...m].map(n=>`"${n}"`).join(", ")}`)},c={kind:"boolean"},y={kind:"samplingRate"},g={destinations:{kind:"destinations"},enabled:c,head_sampling_rate:y,persist:c},L={...g,invocation_logs:{hint:'set "invocation_logs": true to keep per-invocation summaries',kind:"boolean"}},j={enabled:c,head_sampling_rate:y,issues:{kind:"level",level:{enabled:c}},logs:{kind:"level",level:L},redact_query_string:c,traces:{kind:"level",level:g}},$=(s,e,t,i)=>{switch(s.kind){case"boolean":{p(e,t,i,s.hint);break}case"destinations":{e!==void 0&&(!Array.isArray(e)||e.some(n=>!h(n)))&&i.push(`${t} must be an array of destination names configured in the Cloudflare dashboard`);break}case"samplingRate":{S(e,t,i);break}}},v=(s,e,t,i,n)=>{for(const[o,a]of Object.entries(s)){const r=Object.hasOwn(e,o)?e[o]:void 0,l=`${t}.${o}`;r===void 0?n.push(`${l} is not a documented wrangler key (expected one of ${Object.keys(e).join(", ")}) — a typo is silently ignored by wrangler`):r.kind!=="level"?$(r,a,l,i):u(a)?v(a,r.level,l,i,n):a!==void 0&&i.push(`${l} must be an object`)}},G=(s,e,t)=>{const{observability:i}=s;if(i!==void 0){if(!u(i)){e.push('observability must be an object (e.g. { "enabled": true, "head_sampling_rate": 1 })');return}v(i,j,"observability",e,t)}},W=(s,e)=>{const{cache:t}=s;if(t!==void 0){if(!u(t)){e.push('cache must be an object (e.g. { "enabled": true })');return}p(t.enabled,"cache.enabled",e)}},P=(s,e)=>{const{exports:t}=s;if(t!==void 0){if(typeof t!="object"||t===null||Array.isArray(t)){e.push("exports must be an object keyed by entrypoint name");return}for(const[i,n]of Object.entries(t)){if(typeof n!="object"||n===null){e.push(`exports["${i}"] must be an object`);continue}n.type!==void 0&&typeof n.type!="string"&&e.push(`exports["${i}"].type must be a string`),n.cache!==void 0&&(typeof n.cache!="object"||n.cache===null||Array.isArray(n.cache)?e.push(`exports["${i}"].cache must be an object`):n.cache.enabled!==void 0&&typeof n.cache.enabled!="boolean"&&e.push(`exports["${i}"].cache.enabled must be a boolean`))}}},E=["auto-trailing-slash","drop-trailing-slash","force-trailing-slash","none"],N=["404-page","none","single-page-application"],f=(s,e,t,i)=>{e!==void 0&&(typeof e!="string"||!t.includes(e))&&i.push(`assets.${s} must be one of ${t.map(n=>`"${n}"`).join(", ")} (got ${JSON.stringify(e)})`)},R=(s,e)=>{if(!(s===void 0||typeof s=="boolean")){if(!Array.isArray(s)){e.push('assets.run_worker_first must be a boolean or an array of path rules (e.g. ["/_lunora/*"])');return}e.push(...A(s))}},q=(s,e)=>{const{assets:t}=s;if(t!==void 0){if(typeof t!="object"||Array.isArray(t)){e.push('assets must be an object (e.g. { "directory": "./dist/client", "binding": "ASSETS" })');return}(typeof t.directory!="string"||t.directory.length===0)&&e.push('assets must declare a non-empty "directory" pointing at the built client output (e.g. "./dist/client")'),t.binding!==void 0&&(typeof t.binding!="string"||t.binding.length===0)&&e.push('assets.binding must be a non-empty string (e.g. "ASSETS")'),f("html_handling",t.html_handling,E,e),f("not_found_handling",t.not_found_handling,N,e),R(t.run_worker_first,e)}},F=(s,e)=>{const t=s.tail_consumers;if(t===void 0)return;if(!Array.isArray(t)){e.push("tail_consumers must be an array of { service, environment? } entries");return}const i=t;for(const[n,o]of i.entries())(!o||typeof o!="object"||typeof o.service!="string"||o.service.length===0)&&e.push(`tail_consumers[${String(n)}] must have a non-empty "service" naming the consumer Worker`)},M=(s,e)=>{const t=s.tail_consumers??[];return t.some(n=>!!n&&n?.service===e.service&&n?.environment===e.environment)?s:{...s,tail_consumers:[...t,e]}},V=(s,e)=>{const{vars:t}=s;if(!t||typeof t!="object")return;const i=t.LUNORA_ALLOWED_ORIGINS,n=t.LUNORA_CORS_ALLOW_CREDENTIALS,o=typeof i=="string"&&i.split(",").some(r=>r.trim()==="*"),a=_(n);o&&a&&e.push('vars.LUNORA_ALLOWED_ORIGINS includes a "*" wildcard while vars.LUNORA_CORS_ALLOW_CREDENTIALS is on — browsers reject this combination and it defeats the allowlist; name explicit origins or drop credentials')},k=s=>O(s.durable_objects?.bindings).some(e=>e.class_name==="SchedulerDO"&&e.script_name===void 0),d="LUNORA_ORIGIN_URL",H=(s,e,t,i=k(s)?"durable_objects.bindings declares the SchedulerDO":void 0)=>{if(i===void 0||h(s.vars?.[d]))return;const n=e===void 0?"vars":`env.${e}.vars`,o=e===void 0?"":` --env ${e}`;t.push(`${i} but ${n}.${d} is unset — the DO reads its dispatch origin from its own env and refuses to schedule without it, so every ctx.scheduler.runAfter/runAt fails with ORIGIN_NOT_CONFIGURED. Set ${n}.${d} to the worker's public URL, or \`wrangler secret put ${d}${o}\` (ignore this if it is already set as a secret or in the dashboard).`)};export{q as validateAssets,W as validateCache,V as validateCorsVariables,P as validateExports,U as validateLimits,T as validateLogpush,G as validateObservability,B as validatePlacement,H as validateSchedulerOrigin,x as validateSecretsRequired,D as validateSendEmail,F as validateTailConsumers,M as withTailConsumer};
|
package/dist/packem_shared/{worker-entry-checks-CHrum2AN.mjs → worker-entry-checks-DH-ApvvX.mjs}
RENAMED
|
@@ -1 +1 @@
|
|
|
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-
|
|
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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{relative as u}from"node:path";import{s as d,i as t}from"./guards-CoCtgpeR.mjs";import{findWranglerFile as l,readWranglerJsonc as g}from"./WRANGLER_FILES-BF8PUjuo.mjs";import{scanWranglerVariablesForSecrets as p}from"./scanWranglerVariablesForSecrets-DojbojUo.mjs";const i=(a,s)=>{const r=a?.producers;return(Array.isArray(r)?r:[]).flatMap(e=>t(e)&&typeof e.binding=="string"&&typeof e.queue=="string"?[{binding:e.binding,queue:e.queue,...s===void 0?{}:{env:s}}]:[])},m=a=>{const s=l(a),r=s===void 0?void 0:g(s).parsed;if(s===void 0||r===void 0)return{wranglerQueueProducers:[],wranglerVariables:[]};const n=[...new Set([r.assets,...Object.values(r.env??{}).map(e=>e?.assets)].flatMap(e=>d(e)??[]))];return{...n.length===0?{}:{spaAssetsBindings:n},wranglerQueueProducers:[...i(r.queues),...Object.entries(r.env??{}).flatMap(([e,o])=>i(o?.queues,e))],wranglerVariables:p(t(r.vars)?r.vars:void 0,u(a,s))}};export{m as wranglerCodegenInputs};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{existsSync as s,statSync as a,writeFileSync as p,renameSync as d,rmSync as g}from"node:fs";import{join as m}from"node:path";import{runCodegen as f,CodegenDiagnosticError as j,refreshCodegenProject as u,createCodegenProject as y,findTsconfig as S,tsconfigFingerprint as C,projectConfigCandidatePaths as h}from"@lunora/codegen";import{wranglerCodegenInputs as l}from"./wranglerCodegenInputs-
|
|
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-Cz9ByxSo.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-
|
|
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-CDf-EtPs.mjs";import{POLICY_SCAFFOLD_ENDPOINT as H,handlePolicyScaffoldRequest as L}from"../packem_shared/POLICY_SCAFFOLD_ENDPOINT-UcPFeEyM.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-C-ic_pvD.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.460",
|
|
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.403",
|
|
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",
|
|
@@ -68,7 +68,9 @@
|
|
|
68
68
|
"@visulima/package": "6.0.0",
|
|
69
69
|
"dockerode": "^5.0.1",
|
|
70
70
|
"dotenv": "18.0.5",
|
|
71
|
+
"dotenv-expand": "12.0.2",
|
|
71
72
|
"es-module-lexer": "^2.3.2",
|
|
73
|
+
"jiti": "^2.7.0",
|
|
72
74
|
"jsonc-parser": "^3.3.1",
|
|
73
75
|
"ts-morph": "^28.0.0"
|
|
74
76
|
},
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{sqliteClasses as l}from"./wranglerToAlchemy-CBO2ucRm.mjs";const p=1,u=new Set(["$schema","account_id","compatibility_date","compatibility_flags","keep_vars","main","migrations","minify","name","observability","placement","routes","rules","secrets","triggers","upload_source_maps","vars","workers_dev"]),y=e=>Object.fromEntries(Object.entries(e).filter(([,n])=>n!==void 0)),d=[{bindingKey:"binding",field:"ai_search",resourceKey:"instance_name",type:"ai_search"},{bindingKey:"binding",field:"ai_search_namespaces",resourceKey:"namespace",type:"ai_search_namespace"},{bindingKey:"binding",field:"analytics_engine_datasets",resourceKey:"dataset",type:"analytics_engine"},{bindingKey:"binding",field:"artifacts",resourceKey:"namespace",type:"artifacts"},{bindingKey:"class_name",field:"containers",resourceKey:"image",type:"container"},{bindingKey:"binding",field:"d1_databases",resourceIdKey:"database_id",resourceKey:"database_name",type:"d1"},{bindingKey:"binding",field:"hyperdrive",resourceIdKey:"id",type:"hyperdrive"},{bindingKey:"binding",field:"kv_namespaces",resourceIdKey:"id",type:"kv"},{bindingKey:"binding",field:"pipelines",resourceKey:["stream","pipeline"],type:"pipeline"},{bindingKey:"binding",field:"r2_buckets",resourceKey:"bucket_name",type:"r2"},{bindingKey:"binding",field:"services",resourceKey:"service",type:"service"},{bindingKey:"binding",field:"vectorize",resourceKey:"index_name",type:"vectorize"},{bindingKey:"binding",field:"vpc_networks",resourceIdKey:["tunnel_id","network_id"],type:"vpc_network"},{bindingKey:"binding",field:"vpc_services",resourceIdKey:"service_id",type:"vpc_service"},{bindingKey:"binding",field:"workflows",resourceKey:"name",type:"workflow"}],c=[{field:"ai",type:"ai"},{field:"analytics",type:"analytics_sql"},{field:"assets",type:"assets"},{field:"browser",type:"browser"},{field:"images",type:"images"},{field:"media",type:"media"},{field:"stream",type:"stream"}],b=new Set([...d.map(e=>e.field),...c.map(e=>e.field),"durable_objects","exports","queues"]),a=(e,n)=>(typeof n=="string"?[n]:n??[]).map(i=>e[i]).find(i=>typeof i=="string"&&i!==""),m=(e,n)=>{const s=[];for(const i of d)for(const r of e[i.field]??[]){const t=a(r,i.bindingKey);if(t===void 0){n.push(i.field);continue}s.push({binding:t,className:a(r,"class_name"),resource:a(r,i.resourceKey),resourceId:a(r,i.resourceIdKey),type:i.type})}return s},_=(e,n)=>{const s=l(e),i=[];for(const r of e.durable_objects?.bindings??[]){if(r.name===void 0||r.name===""){n.push("durable_objects");continue}i.push({binding:r.name,className:r.class_name,sqlite:r.script_name===void 0&&r.class_name!==void 0?s.has(r.class_name):void 0,type:"durable_object"})}return i},g=(e,n)=>{const s=[];for(const i of e.queues?.producers??[]){if(i.binding===void 0||i.binding===""){n.push("queues.producers");continue}s.push({binding:i.binding,resource:i.queue,type:"queue_producer"})}for(const i of e.queues?.consumers??[]){if(i.queue===void 0||i.queue===""){n.push("queues.consumers");continue}s.push({binding:i.queue,resource:i.queue,type:"queue_consumer"})}return s},f=(e,n)=>Object.entries(e.exports??{}).flatMap(([s,i])=>i?.type!=="workflow"?(n.push(`exports.${s}`),[]):[{binding:s,className:s,resource:i.name,type:"workflow"}]),v=(e,n,s)=>[...f(e,s),...m(e,n),..._(e,n),...g(e,n),...c.filter(i=>e[i.field]?.binding!==void 0).map(i=>({binding:e[i.field]?.binding,type:i.type}))],h=e=>{const n=[],s=[],i=v(e,n,s).map(t=>y(t)).toSorted((t,o)=>t.type.localeCompare(o.type)||t.binding.localeCompare(o.binding)),r=[...Object.keys(e).filter(t=>!u.has(t)&&!b.has(t)),...n.map(t=>`${t} (entry with no binding name)`),...s].toSorted((t,o)=>t.localeCompare(o));return{bindings:i,...e.compatibility_date===void 0?{}:{compatibilityDate:e.compatibility_date},...e.compatibility_flags===void 0?{}:{compatibilityFlags:e.compatibility_flags},crons:e.triggers?.crons??[],...e.name===void 0?{}:{name:e.name},unknown:r,vars:Object.keys(e.vars??{}).toSorted((t,o)=>t.localeCompare(o)),version:p}};export{p as BINDING_MANIFEST_VERSION,h as buildBindingManifest};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import{parse as p}from"dotenv";const A=".dev.vars",D=".dev.vars.example",$=/^[A-Za-z_]\w*$/u,d=/\r?\n/u,u=e=>Object.entries(p(e)).map(([t,n])=>({key:t,value:n})),V=e=>u(e)[0],L=e=>e.replaceAll(/[.*+?^${}()|[\]\\]/gu,String.raw`\$&`),_=/(\r?\n)/u,E=(e,t,n)=>{const r=e.split(_),s=[];let a=!1;for(let i=0;i<r.length;i+=2){const o=r[i]??"",c=r[i+1]??"";if(V(o)?.key!==t){s.push(o,c);continue}const l=!a;a=!0,n!==void 0&&l&&s.push(n,c)}return{content:s.join(""),matched:a}},m=(e,t,n)=>{const r=`${t}="${n}"`,s=E(e,t,r);return s.matched?s.content:e===""?`${r}
|
|
2
|
-
`:e.endsWith(`
|
|
3
|
-
`)?`${e}${r}
|
|
4
|
-
`:`${e}
|
|
5
|
-
${r}
|
|
6
|
-
`},R=(e,t)=>E(e,t,void 0).content;export{D as DEV_VARS_EXAMPLE_FILE,A as DEV_VARS_FILE,$ as DEV_VARS_KEY_PATTERN,d as DEV_VARS_NEWLINE,L as escapeRegExp,u as parseDevVariableEntries,V as parseDevVariableLine,R as removeDevVariableLine,m as upsertDevVariableLine};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
const u=t=>{if(typeof t=="string")return t;if(t instanceof Error)return String(t);try{return JSON.stringify(t)??String(t)}catch{return String(t)}};const E=t=>typeof t=="object"&&t!==null&&!Array.isArray(t),h=t=>E(t)&&typeof t.name=="string"&&typeof t.message=="string"?t:void 0,$=t=>{let r=t;if(typeof t=="string"){if(!t.startsWith("{")||!t.endsWith("}"))return;try{r=JSON.parse(t)}catch{return}}const s=h(r);return s!==void 0&&(typeof s.stack=="string"||s.cause!==void 0||Array.isArray(s.errors))?s:void 0},d=t=>t.message===""?t.name:`${t.name}: ${t.message}`,R=/^[\w$.]+$/u,A=t=>{if(typeof t.stack!="string")return[];let r=t.stack;const s=t.message===""?-1:r.indexOf(t.message),n=s===-1?"":r.slice(0,s);return s>0&&n.endsWith(": ")&&!n.includes(`
|
|
2
|
-
`)?r=r.slice(s+t.message.length):t.message===""&&R.test(r.split(`
|
|
3
|
-
`,1)[0]??"")&&(r=r.slice((r.split(`
|
|
4
|
-
`,1)[0]??"").length)),r.split(`
|
|
5
|
-
`).map(e=>e.trim()).filter(e=>e!=="")},m=(t,r,s=0)=>{const n=`${r} `,e=[d(t),...A(t).map(o=>`${n}${o}`)],i=(o,a)=>{const f=h(a);return f===void 0?`${r}${o}: ${u(a)}`:`${r}${o}: ${s>=4?d(f):m(f,n,s+1).join(`
|
|
6
|
-
`)}`};return Array.isArray(t.errors)&&t.errors.slice(0,10).forEach((o,a)=>{e.push(i(`errors[${String(a)}]`,o))}),t.cause!==void 0&&e.push(i("caused by",t.cause)),e},_=(t,r="")=>t.map(([s,n])=>`${r}${s}: ${m(n,`${r} `).join(`
|
|
7
|
-
`)}`).join(`
|
|
8
|
-
`);const l=t=>{if(typeof t!="string")return t;if(!(!(t.startsWith("{")&&t.endsWith("}"))&&!(t.startsWith("[")&&t.endsWith("]"))))try{return JSON.parse(t)}catch{return}},p=(t,r,s,n)=>{if(n.length>=10||s>=8||typeof t!="object"||t===null)return;const e=$(t);if(e!==void 0){n.push([r,e]);return}if(Array.isArray(t)){t.forEach((i,o)=>{p(i,`${r}[${String(o)}]`,s+1,n)});return}for(const[i,o]of Object.entries(t))p(o,`${r}.${i}`,s+1,n)},S=t=>{if(!E(t))return{errors:[],text:""};const r=[],s=[];for(const[n,e]of Object.entries(t)){const i=$(e);if(i===void 0){s.push(`${n}=${u(e)}`);const o=[];p(l(e),n,0,o),r.push(...o)}else r.push([n,i]),s.push(`${n}=${d(i)}`)}return{errors:r,text:s.join(" ")}},O="lunora",j="__root__",c=t=>typeof t=="string"?t:"",g=t=>Array.isArray(t)?t.filter(r=>typeof r=="string"):[],N=t=>typeof t=="number"&&Number.isFinite(t)?`${String(Math.round(t))}ms`:"?ms",k=t=>t==="error"||t==="fatal"?"error":t==="warn"?"warn":"info",M=t=>{const r=t.trim();if(!r.startsWith("{")||!r.endsWith("}"))return;let s;try{s=JSON.parse(r)}catch{return}if(typeof s!="object"||s===null)return;const n=s;return n.source===O?n:void 0},y=(t,r)=>{const s=c(r.shard);return s===""||s===j?t:`${t}@${s}`},b=(t,r)=>{const s=t.outcome==="error",n=[y(r,t),s?"error":"ok",N(t.durationMs)],e=g(t.tablesRead),i=g(t.tablesWritten);e.length>0&&n.push(`read[${e.join(",")}]`),i.length>0&&n.push(`write[${i.join(",")}]`),t.cacheHit===!0&&n.push("cached");const o=c(t.error);return s&&o!==""&&n.push(o),{kind:"rpc",level:s?"error":"info",text:n.join(" ")}},D=t=>{const r=c(t.container)||"<unknown>",s=c(t.instance),n=c(t.event)||"event",e=s===""||s==="unknown"?"":`#${s.slice(0,8)}`,i=c(t.message),o=[`container:${r}${e}`,n];return i!==""&&o.push(i),{kind:"log",level:t.event==="error"?"error":"info",text:o.join(" ")}},G=t=>{const r=M(t);if(!r)return;const s=c(r.function)||"<unknown>";if(r.type==="log"){const n=[`${y(s,r)} ${c(r.message)}`.trimEnd()],e=S(r.fields);e.text!==""&&n.push(e.text);const i=c(r.traceId);i!==""&&n.push(`trace=${i.slice(0,8)}`);const o=e.errors.length===0?"":`
|
|
9
|
-
${_(e.errors," ")}`;return{kind:"log",level:k(c(r.level)),text:n.join(" ")+o}}if(r.type==="request")return b(r,s);if(r.type==="container")return D(r)};export{O as LUNORA_EVENT_SOURCE,G as formatLunoraEvent};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{C as s,M as R,P as _,b as a,S as e,m as A,s as C}from"./package-secrets-registry-TouCAMQN.mjs";export{s as CORE_SECRETS,R as MINTABLE_SECRET_KEYS,_ as PACKAGE_SECRETS_REGISTRY,a as SHARD_RELAY_HOST_PLACEHOLDER,e as SHARD_RELAY_SECRET_KEY,A as mintableSecretKeysFor,C as secretsForPackages};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{applyModify as g}from"./applyModify-DKP2l6S9.mjs";import{hasCloudflareCredentials as v}from"./hasCloudflareCredentials-Bak5w1_6.mjs";import{withheldBindings as y,writeDevConfig as E,noopCleanup as R}from"./describeWithheld-CbyzZjZF.mjs";import{readManifest as S}from"./readManifest-Cighz3WC.mjs";import{o as _}from"./reconcile-services-C4TwY8YH.mjs";import{findWranglerFile as j,readWranglerJsonc as w}from"./WRANGLER_FILES-UNW-xY5u.mjs";const p={ai:{label:"AI",shape:"object"},ai_search:{label:"AI Search",shape:"array"},ai_search_namespaces:{label:"AI Search namespace",shape:"array"},analytics:{label:"Analytics SQL",shape:"object"},d1_databases:{label:"D1",shape:"array"},kv_namespaces:{label:"KV",shape:"array"},queues:{label:"Queue",shape:"producers"},r2_buckets:{label:"R2",shape:"array"},services:{label:"Service",shape:"array"},vectorize:{label:"Vectorize",shape:"array"}},C=Object.keys(p),m=(e,r)=>typeof e.binding=="string"?e.binding:r,u=(e,r,t,n)=>{const i=[];for(const[s,o]of r.entries())o!=null&&(e==="kv_namespaces"&&(typeof o.id!="string"||o.id==="")||i.push({binding:m(o,`#${String(s)}`),kind:t,path:[...n,s],section:e}));return i},h=(e,r)=>p[e].shape===r,I=(e,r)=>{const{label:t}=p[e];if(h(e,"array"))return u(e,r[e]??[],t,[]);if(h(e,"object")){const n=r[e];return n==null?[]:[{binding:m(n,e),kind:t,path:[],section:e}]}return u(e,r.queues?.producers??[],t,["producers"])},B=e=>C.flatMap(r=>I(r,e)),L=(e,r)=>{let t=e;for(const n of r)t=g(t,[n.section,...n.path,"remote"],!0);return t},W=e=>{const r=a=>({cleanup:R,reason:a,remoteBindings:[],withheld:[]}),t=j(e.projectRoot);if(!t)return r("wrangler.jsonc not found");const{parsed:n,text:i}=w(t);if(n===void 0)return r(`failed to parse ${t} as JSONC`);const s=_(S(e.projectRoot)),o=e.remote?B(n).filter(a=>a.section!=="services"||!s.has(a.binding)):[],l=y(n,e.hasCredentials??(()=>v({projectRoot:e.projectRoot}))),c=l.some(({kind:a})=>a==="ai")?o.filter(a=>a.section!=="ai"):o;if(c.length===0&&l.length===0)return r(e.remote?"no remote-eligible bindings to proxy":void 0);let d=i;for(const{kind:a}of l)d=g(d,[a],void 0);const b=c.length>0?L(d,c):d,f=E(e.projectRoot,"dev",b);return{cleanup:f.cleanup,configPath:f.configPath,remoteBindings:c,withheld:l}},k=e=>{if(e===void 0)return!1;const r=e.trim().toLowerCase();return r==="1"||r==="true"},D=e=>e.flag===!0||k(e.envValue)?!0:e.configPreference??!1;export{p as REMOTE_ELIGIBLE_KEYS,L as injectRemoteFlags,k as isRemoteEnvEnabled,W as materializeDevWranglerConfig,B as planRemoteBindings,D as resolveRemoteEnabled};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{MERGED_DURABLE_OBJECT as m}from"./COMPOSED_WORKER_ENTRY-BcFt6ts5.mjs";import{o as R,v as S,a as I,b as j,c as A,d as L,e as f,g as k,h as B,H as C,i as N,R as T,S as w,j as q,k as U,W as G,l as P}from"./reconcile-assets-h8q3F4Sy.mjs";import{i as u,p as g,a as _}from"./spa-assets-BwJFTBeO.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-_EZ9WqMc.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 s=t.env[i],r=v(u(s)?s.queues:void 0);if(r.size===0)return;const a=b(s,t,e),p=[{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=>a===void 0||c.account===void 0||c.account===a);for(const c of r){const o=p.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:"",ae=(t,i,n)=>{for(const[e,s]of O(t.kv_namespaces))typeof s.id=="string"&&s.id!==""||n.push(`kv_namespaces[${String(e)}] ("${y(s)}") 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`)},se=(t,i,n)=>{for(const[e,s]of O(t.r2_buckets)){const r=s.jurisdiction;if(r===i)continue;const a=typeof r=="string"?`names the "${r}" jurisdiction`:"names no jurisdiction";n.push(`r2_buckets[${String(e)}] ("${y(s)}") ${a}, 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&&(ae(t,e,n),se(t,e,n))},D="2026-04-07",pe="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:s,unverifiedKeys:r}=ee(t,i);return e!==void 0?{error:e,wrangler:s}:(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:s})},le=(t,i,n)=>{const e=[],s=[];if(!t||typeof t!="object")return e.push("wrangler config is not a valid object"),{errors:e,valid:!1,warnings:s};const{error:r,wrangler:a}=de(t,n,s);if(r!==void 0)return e.push(r),{errors:e,valid:!1,warnings:s};R(a.durable_objects?.bindings).find(d=>d.name==="SHARD"&&(d.class_name==="ShardDO"||d.class_name===m))||e.push(`durable_objects.bindings must include { "name": "SHARD", "class_name": "ShardDO" } (or "${m}" when the app merges its Durable Objects) — your dev server auto-reconciles this on startup, or add the binding manually`),S(a,e);const o=a.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(a)&&l&&o<E&&e.push(`cache.enabled requires compatibility_date >= "${E}" (got "${o||"<missing>"}")`),l&&ce(o,a.compatibility_flags??[],s),I(a,i,e),ne(a,i,s),j(a,e),A(a,i?.vectorIndexNames??[],e),W(a,e),L(a,e,s),f(a.workflows,"workflows",G,e),k(a,e),B(a,e),te(t,n,s),f(a.secrets_store_secrets,"secrets_store_secrets",P,e);for(const d of C)N(a,d,e,s);for(const d of T)f(a[d.key],d.key,d,e);for(const d of w)q(a,d,e);return U(a,e),K(a,e,s),M(a,e),V(a,e),x(a,e),H(a,e),Q(a,e,s),F(a,e),Y(a,e),J(a,e),z(a,e),X(a,n,s),{errors:e,valid:e.length===0,warnings:s}},me=le;export{D as REQUIRED_COMPATIBILITY_DATE,pe as REQUIRED_FLAG,me as validateWrangler,le as validateWranglerConfig};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{existsSync as h}from"node:fs";import{dirname as y,join as p}from"node:path";import{discoverSchemaInfo as w}from"./discoverSchemaInfo-DRPnqgif.mjs";import{MERGED_DURABLE_OBJECT as i,GENERATED_DIRECTORY as E,MERGED_ROLE_DURABLE_OBJECTS as u,COMPOSED_ENTRY_DURABLE_OBJECTS as $,GENERATED_CLASS_MODULES as k,isFrameworkDurableObject as D}from"./COMPOSED_WORKER_ENTRY-BcFt6ts5.mjs";import{o as R,f as j}from"./reconcile-assets-h8q3F4Sy.mjs";import{validateSchedulerOrigin as x}from"./withTailConsumer-_EZ9WqMc.mjs";import{l as O,r as _,s as A}from"./worker-entry-checks-CHrum2AN.mjs";import{mergeWranglerEnvironment as S}from"./mergeWranglerEnvironment-D5ekKj5x.mjs";import{findWranglerFile as W,readWranglerJsonc as C}from"./WRANGLER_FILES-UNW-xY5u.mjs";import{validateWranglerConfig as T}from"./REQUIRED_COMPATIBILITY_DATE-CKjEIFrf.mjs";const v=r=>Array.isArray(r)?r:[],L=(r,t,o)=>Object.entries(r?.images??{}).flatMap(([s,n])=>{const e=n?.dockerfile;return typeof e!="string"||h(e.startsWith("/")?e:p(t,e))?[]:[`containers images["${s}"] dockerfile "${e}" does not exist (resolved relative to ${o}); create the Dockerfile`]}),I=(r,t,o)=>{const s=[];for(const n of v(r)){const e=n?.image;typeof e=="string"&&(e.startsWith("./")||e.startsWith("../")||e.startsWith("/")||e.includes("Dockerfile"))&&!h(e.startsWith("/")?e:p(t,e))&&s.push(`containers image "${e}" does not exist (resolved relative to ${o}); create the Dockerfile or point image at a registry reference`),s.push(...L(n,t,o))}return s},P=(r,t)=>{const o=r?.vectorIndexNames??[],s=[];if(o.length>0&&s.push({message:e=>`schema declares vector index(es) ${o.map(l=>`"${l}"`).join(", ")} but nothing chains .vectors(...) onto defineApp() (composed in: ${e}) — \`ctx.vectors\` is then a throwing stub and buildWorkerOptions rejects EVERY request, /_lunora/health included. Add \`.vectors((env) => ({ ${String(o[0])}: env.<BINDING> }))\` to the chain.`,method:"vectors"}),r?.hasD1GlobalTable&&s.push({message:e=>`schema declares .global() table(s) but nothing chains .global(...) onto defineApp() (composed in: ${e}) — the shard then has no global writer, so every read or write of a global table throws INTERNAL ("requires a globalDb writer"). Add \`.global({ d1: (env) => env.DB })\` to the chain.`,method:"global"}),r?.hasHyperdriveGlobalTable&&s.push({message:e=>`schema declares .global({ backend: "hyperdrive" }) table(s) but nothing chains .hyperdriveGlobal(...) onto defineApp() (composed in: ${e}) — the shard then has no global writer, so every read or write of those tables throws INTERNAL. Add \`.hyperdriveGlobal({ engine: "postgres", exec: (env) => buildPgExec(fromPostgresJs(async () => (await import("postgres")).default(env.HYPERDRIVE.connectionString, { fetch_types: false, max: 5 }))) })\` to the chain (\`buildPgExec\` from \`@lunora/hyperdrive/global\`, \`fromPostgresJs\` from \`@lunora/hyperdrive\`).`,method:"hyperdriveGlobal"}),s.length===0)return[];const n=A(t,new Set(s.map(e=>e.method)));return n===void 0?[]:s.filter(e=>!n.chained.has(e.method)).map(e=>e.message(n.site))},G="does not export it",B=(r,t)=>{if(t.exports?.has(i)===!0&&u.has(r))return`This app merges its Durable Objects (\`durableObjects.merge\` in lunora.config), so ${i} hosts ${r}: bind only \`SHARD\` to "${i}" and drop the SCHEDULER / SHARD_REGISTRY bindings. Do that only if this Worker has never been deployed — a deployed ${r} namespace keeps its data, which the merged class cannot reach; turn \`durableObjects.merge\` off to keep it.`;if(r===i)return`${i} is the merged class (\`durableObjects.merge\` in lunora.config), and merging cannot be undone once deployed: the shard data lives in ${i}. Turn \`durableObjects.merge\` back on. Only a Worker that has never been deployed may rebind SHARD to "ShardDO".`;if(t.kind!=="composed")return`Re-export it from the module that defines it (\`export { ${r} } from "./…";\`), or add it to the app builder's own export (\`export const { ${r} } = app;\`).`;const o=`it exports ${$.join(", ")}, SchedulerDO when its binding is declared, and every class codegen emits from your ${k.map(s=>`${s}.ts`).join(" / ")} declarations`;return D(r)?`\`@lunora/vite\` generates that entry — ${o}, and ${r} is not among them. Class-A composition does not carry ${r}, so drop the binding; a project that needs it has to own its worker entry (add \`src/worker.ts\`, which \`lunora deploy\` bundles in place of \`main\`, and compose \`defineApp()\` there).`:`\`@lunora/vite\` generates that entry, so there is no file to add a re-export to: ${o}. Declare "${r}" in one of those and re-run \`lunora codegen\`, or drop the binding.`},M=(r,t)=>{const o=t.exports;if(o===void 0)return[];const s=[];for(const e of R(r.durable_objects?.bindings))typeof e.class_name=="string"&&e.class_name.length>0&&e.script_name===void 0&&s.push({className:e.class_name,label:"durable_objects.bindings"});for(const e of v(r.workflows))typeof e?.class_name=="string"&&e.class_name.length>0&&e.script_name===void 0&&s.push({className:e.class_name,label:"workflows"});for(const[e,l]of Object.entries(r.exports??{}))l?.type==="workflow"&&s.push({className:e,label:"workflows"});return s.filter(e=>!o.has(e.className)).map(e=>`${e.label} declares class "${e.className}" but the ${t.kind==="composed"?"composed class-A worker entry":"worker entry"} (${t.path}) ${G} — wrangler refuses to bundle a Worker whose ${e.label==="workflows"?"Workflow":"Durable Object"} classes are not exported. ${B(e.className,t)}`)},N=r=>[...j(r.migrations)].filter(t=>u.has(t)).map(t=>`migrations create class "${t}", which this app hosts in ${i} because it merges its Durable Objects (\`durableObjects.merge\`). Before the first deploy, replace "${t}" with "${i}" in new_sqlite_classes; a Worker already deployed with "${t}" keeps its data there and cannot merge — turn \`durableObjects.merge\` off.`),U=r=>r?.origin!=="absent"?[]:[`main is set but no readable file is there (looked in ${r.path}) — wrangler cannot resolve the worker entry, so a deploy will fail there. Point main at the entry that composes your app, or remove it to fall back to the conventional locations.`],Z=r=>{const t=r.schemaDir??"lunora",o=W(r.projectRoot);if(!o){const c=`wrangler.jsonc not found in ${r.projectRoot}; create one declaring at least the SHARD durable object binding.`;return{problems:[c],report:{errors:[c],valid:!1,warnings:[]},wranglerPath:void 0}}const{parsed:s}=C(o);if(s===void 0){const c=`failed to parse ${o} as JSONC.`;return{problems:[c],report:{errors:[c],valid:!1,warnings:[]},wranglerPath:o}}const{error:n,merged:e}=S(s,r.environment);if(n!==void 0)return{problems:[n],report:{errors:[n],valid:!1,warnings:[]},wranglerPath:o};const{error:l,info:f}=w(r.projectRoot,t,r.cache),a=T(s,f,r.environment);l!==void 0&&a.warnings.push(`schema parse failed in ${t}/schema.ts: ${l}`);const g=y(o),b=O(e.main,r.projectRoot,o),m=_(b,r.projectRoot,t);a.errors.push(...I(e.containers??[],g,o)),a.warnings.push(...U(b)),m!==void 0&&a.errors.push(...M(e,m)),m?.exports?.has(i)===!0&&(a.errors.push(...N(e)),h(p(r.projectRoot,t,E,"scheduler.ts"))&&x(e,r.environment,a.warnings,"the merged LunoraDO hosts the scheduler")),a.errors.push(...P(f,r.projectRoot));const d=e.assets?.directory;if(typeof d=="string"&&d.length>0){const c=d.startsWith("/")?d:p(g,d);h(c)||a.warnings.push(`assets.directory "${d}" does not exist yet — it is created by the client build; run the build before deploy`)}return a.valid=a.errors.length===0,{problems:a.errors,report:a,wranglerPath:o}};export{G as UNEXPORTED_CLASS_MARKER,Z as validateWranglerProject};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{existsSync as e,readFileSync as s}from"node:fs";import{parse as a}from"jsonc-parser";import{join as i}from"node:path";const l=["wrangler.jsonc","wrangler.json"],p=n=>{for(const r of l){const o=i(n,r);if(e(o))return o}},u=n=>{const r=s(n,"utf8"),o=[],t=a(r,o,{allowTrailingComma:!0});return o.length>0||t===null||typeof t!="object"?{parsed:void 0,text:r}:{parsed:t,text:r}};export{l as WRANGLER_FILES,p as findWranglerFile,u as readWranglerJsonc};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import{randomBytes as D}from"node:crypto";import{existsSync as g,readFileSync as m,writeFileSync as E,linkSync as j,rmSync as h,renameSync as V,statSync as I}from"node:fs";import{join as p}from"node:path";import{LunoraError as N}from"@lunora/errors";import{DEV_VARS_FILE as u,DEV_VARS_EXAMPLE_FILE as y,parseDevVariableLine as $,parseDevVariableEntries as S,DEV_VARS_NEWLINE as C}from"./DEV_VARS_EXAMPLE_FILE-CqLorAxT.mjs";import{M as z,S as f,C as P,m as B,b as O,s as W}from"./package-secrets-registry-TouCAMQN.mjs";const H=e=>[...P,...W(e)],K=32,Y=["replace","openssl","changeme","change-me","change_me","change-this","change_this","your-","your_","example","placeholder","todo","fill-me","fill_me","fill-in","fill_in","xxx"],U=/[.*+?^${}()|[\]\\]/gu,X=/[a-z0-9]$/u,L=e=>{const t=e.trim().toLowerCase();return t===""||t.startsWith("<")&&t.endsWith(">")?!0:Y.some(n=>{const r=n.replaceAll(U,String.raw`\$&`),s=X.test(n)?`(^|[^a-z0-9])${r}([^a-z0-9]|$)`:`(^|[^a-z0-9])${r}`;return new RegExp(s,"u").test(t)})},x=e=>D(e).toString("hex"),w=new Set([...z,f]),G=(e,t,n=w)=>e===f?n.has(e)&&(t.trim()===""||t===O):n.has(e),T=(e,t,n,r)=>G(e,t,r)&&L(t)?n(K):void 0,ue=(e=x)=>e(K),b=(e,t,n,r=w)=>e.split(C).map(o=>{const s=$(o),a=s?T(s.key,s.value,t,r):void 0;return!s||a===void 0?o:(n.push(s.key),`${s.key}="${a}"`)}),q=e=>{if(e.devVarsExists)return{status:"exists"};if(e.exampleContent===void 0)return{status:"no-example"};const t=[];return{content:b(e.exampleContent,e.randomHex??x,t).join(`
|
|
2
|
-
`),generatedKeys:t,status:"generate"}},J=e=>e.includes('"')||e.includes("\\")?"":e.replaceAll("\r",String.raw`\r`).replaceAll(`
|
|
3
|
-
`,String.raw`\n`),_=e=>{const t=e.randomHex??x,n=new Set(S(e.existingContent).map(a=>a.key)),r=[],o=[],s=[];for(const a of e.exampleContent.split(C)){const i=$(a);if(!i||n.has(i.key))continue;const c=T(i.key,i.value,t,w);s.push(i.key),c===void 0?r.push(`${i.key}="${J(i.value)}"`):(o.push(i.key),r.push(`${i.key}="${c}"`))}return{additions:r,generatedKeys:o,missingKeys:s}},k=e=>e.length>0?` (generated ${e.join(", ")})`:"",F=e=>`${e}.tmp-${String(process.pid)}`,v=(e,t,n={})=>{const r=F(e);try{E(r,t,{encoding:"utf8",...n}),V(r,e)}catch(o){throw h(r,{force:!0}),o}},Q=(e,t)=>{try{return E(e,t,{encoding:"utf8",flag:"wx",mode:384}),!0}catch(n){if(n.code==="EEXIST")return!1;throw n}},M=(e,t)=>{const n=F(e);try{E(n,t,{encoding:"utf8",flag:"wx",mode:384});try{return j(n,e),!0}catch(r){const{code:o}=r;if(o==="EEXIST")return!1;if(o==="EPERM"||o==="ENOTSUP")return Q(e,t);throw r}}finally{h(n,{force:!0})}},fe=(e,t)=>{v(e,t,{mode:384})},A=5,R=e=>{try{const t=I(e);return{mtimeMs:t.mtimeMs,size:t.size}}catch{return}},Z=(e,t)=>e===void 0||t===void 0?!1:e.mtimeMs===t.mtimeMs&&e.size===t.size,ee=(e,t)=>{for(let n=0;n<A;n+=1){const r=R(e),o=m(e,"utf8"),s=t(o);if(s.length===0)return[];const a=o.length>0&&!o.endsWith(`
|
|
4
|
-
`)?`
|
|
5
|
-
`:"",i=`${o}${a}${s.join(`
|
|
6
|
-
`)}
|
|
7
|
-
`,c=`${e}.tmp-${String(process.pid)}-${D(6).toString("hex")}`;try{E(c,i,{encoding:"utf8",mode:384});const d=R(e);if(!Z(r,d)){h(c,{force:!0});continue}return V(c,e),s}catch(d){throw h(c,{force:!0}),d}}throw new N("INTERNAL",`Failed to append to ${e} after ${String(A)} attempts — a concurrent writer kept winning the race.`)},ye=async e=>{const t=p(e.cwd,u),n=p(e.cwd,y);if(!g(n))return{addedKeys:[],generatedKeys:[],status:"no-example"};const r=m(n,"utf8");if(!g(t)){const l=q({devVarsExists:!1,exampleContent:r,randomHex:e.randomHex});return l.status!=="generate"?{addedKeys:[],generatedKeys:[],status:"no-example"}:e.yes===!0||await e.confirm(`No ${u} found. Generate it from ${y} (secrets auto-filled)?`)?M(t,l.content)?(e.info(`Created ${u}${k(l.generatedKeys)}.`),{addedKeys:[],generatedKeys:l.generatedKeys,status:"generated"}):{addedKeys:[],generatedKeys:[],status:"skipped-exists"}:(e.info(`Skipped — copy ${y} to ${u} and fill it in when you're ready.`),{addedKeys:[],generatedKeys:[],status:"declined"})}const o=_({existingContent:m(t,"utf8"),exampleContent:r,randomHex:e.randomHex});if(o.missingKeys.length===0)return{addedKeys:[],generatedKeys:[],status:"exists"};const s=o.missingKeys.join(", ");if(!(e.yes===!0||await e.confirm(`${u} is missing ${String(o.missingKeys.length)} key(s) from ${y} (${s}). Add them?`)))return e.info(`Skipped — add ${s} to ${u} when you're ready.`),{addedKeys:[],generatedKeys:[],status:"declined"};const c=ee(t,l=>_({existingContent:l,exampleContent:r,randomHex:e.randomHex}).additions).map(l=>$(l)?.key).filter(l=>l!==void 0);if(c.length===0)return{addedKeys:[],generatedKeys:[],status:"exists"};const d=o.generatedKeys.filter(l=>c.includes(l));return e.info(`Updated ${u} — added ${c.join(", ")}${k(d)}.`),{addedKeys:c,generatedKeys:d,status:"augmented"}},te=e=>[`# ${e.description}`,`# Docs: ${e.docsUrl}`,`${e.key}="${e.placeholderValue}"`].join(`
|
|
8
|
-
`),ne=(e,t)=>{const n=H(e).filter(r=>!t.has(r.key));return n.length===0?"":n.map(r=>te(r)).join(`
|
|
9
|
-
|
|
10
|
-
`)},me=(e,t)=>{const n=p(e,y),r=g(n)?m(n,"utf8"):"",o=new Set(S(r).map(i=>i.key)),s=ne(t,o);if(s==="")return[];const a=r.length>0&&!r.endsWith(`
|
|
11
|
-
`)?`
|
|
12
|
-
`:"";return v(n,`${r}${a}
|
|
13
|
-
${s}
|
|
14
|
-
`),H(t).filter(i=>!o.has(i.key)).map(i=>i.key)},re=e=>{const t=e.randomHex??x,n=[],r=b(e.existingContent,t,n,e.mintable),o=new Set(S(e.existingContent).map(d=>d.key)),s=[],a=[];for(const d of P)o.has(d.key)||(s.push(d.key),a.push(`# ${d.description}`,`${d.key}="${t(K)}"`));const i=r.join(`
|
|
15
|
-
`);if(a.length===0)return{addedKeys:s,content:i,filledKeys:n};const c=i===""||i.endsWith(`
|
|
16
|
-
`)?"":`
|
|
17
|
-
`;return{addedKeys:s,content:`${i}${c}${a.join(`
|
|
18
|
-
`)}
|
|
19
|
-
`,filledKeys:n}},ge=e=>{const t=p(e.cwd,u),n=g(t),r=n?m(t,"utf8"):"",o=e.secretSources===void 0?void 0:B(e.secretSources),s=re({existingContent:r,mintable:o,randomHex:e.randomHex}),a=S(s.content).find(c=>c.key===f)?.value;if(o!==void 0&&!o.has(f)&&a!==void 0&&L(a)&&e.info?.(`${f} is still a placeholder. This worker only calls an event log hosted elsewhere, so set it to the ${f} of the worker that hosts EventLogDO.`),s.filledKeys.length===0&&s.addedKeys.length===0)return{addedKeys:[],filledKeys:[],status:"unchanged"};if(n)v(t,s.content,{mode:384});else if(!M(t,s.content))return{addedKeys:[],filledKeys:[],status:"unchanged"};const i=[...s.filledKeys,...s.addedKeys];return e.info?.(`Generated ${String(i.length)} dev secret(s) in ${u}: ${i.join(", ")}`),{addedKeys:s.addedKeys,filledKeys:s.filledKeys,status:n?"filled":"created"}};export{ne as buildPackageSecretsBlock,ye as ensureDevVariables,me as ensureDevVarsExample,ge as fillDevSecrets,ue as generateSecretValue,G as isMintableSecretKey,L as isPlaceholderValue,re as planDevSecretsFill,_ as planDevVariablesAugment,q as planDevVariablesScaffold,H as requiredSecrets,fe as writeDevVariablesFileAtomically};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{spawnSync as m}from"node:child_process";import{readFileSync as L,readdirSync as A,existsSync as O}from"node:fs";import{homedir as S}from"node:os";import{join as r,dirname as d}from"node:path";const v=[".env",".env.local",".env.development",".env.development.local"],E=["CLOUDFLARE_API_TOKEN","CF_API_TOKEN"],g=["CLOUDFLARE_API_KEY","CF_API_KEY"],_=["CLOUDFLARE_EMAIL","CF_EMAIL"],w=new Set([...E,...g,..._]),p=/^export\s+/u,D=/\r?\n/u,I=/"loggedIn"\s*:\s*false/u,T=1e4,f=new Map,C=/^(["'])(.*)\1$/u,a=e=>e!==void 0&&e.trim()!=="",h=(e,t)=>[t,e.XDG_CONFIG_HOME,r(t,"Library","Preferences"),r(t,".config"),e.APPDATA===void 0?void 0:r(e.APPDATA,"xdg.config"),r(t,"AppData","Roaming","xdg.config")].filter(o=>a(o)),F=e=>{try{return A(e).length>0}catch{return!1}},K=e=>{for(let t=e;;t=d(t)){const o=r(t,"node_modules","wrangler","bin","wrangler.js");if(O(o))return o;if(d(t)===t)return}},P=(e,t)=>{const o=f.get(e);if(o!==void 0&&Date.now()-o.at<T)return o.loggedOut;const s=K(e);if(s===void 0)return!1;const{stdout:i}=m(process.execPath,[s,"whoami","--json"],{cwd:e,encoding:"utf8",env:{...t,WRANGLER_SEND_METRICS:"false"},stdio:["ignore","pipe","ignore"],timeout:3e3}),n=I.test(i);return f.set(e,{at:Date.now(),loggedOut:n}),n},R=e=>{const t=new Set;for(const o of v){let s;try{s=L(r(e,o),"utf8")}catch{continue}for(const i of s.split(D)){const n=i.trim().replace(p,""),c=n.indexOf("=");if(n.startsWith("#")||c===-1)continue;const l=n.slice(0,c).trim(),u=n.slice(c+1).trim().replace(C,"$2");w.has(l)&&a(u)&&t.add(l)}}return t},M=(e={})=>{const t=e.env??process.env,o=e.projectRoot===void 0?new Set:R(e.projectRoot),s=n=>a(t[n])||o.has(n);return E.some(n=>s(n))||g.some(n=>s(n))&&_.some(n=>s(n))?!0:h(t,e.home??S()).some(n=>F(r(n,".wrangler","config")))&&(e.projectRoot===void 0||!P(e.projectRoot,t))};export{M as hasCloudflareCredentials};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{statSync as k,readFileSync as B,existsSync as M,readdirSync as ue}from"node:fs";import{relative as pe,sep as me,isAbsolute as fe,join as E,dirname as F,resolve as ge}from"node:path";import{discoverFlags as he,FLAGS_FILENAME as Se,discoverQueues as Ee,CAPABILITY_PROBES as J,COMPANION_BINDING as z,ALL_NOTIFY_CHANNELS as xe,readBoundServiceBindings as ve,discoverHttpRoutes as ye,discoverNotifyChannels as Ne,NOTIFY_FILENAME as Te,createTargetScope as be,mayReadCapabilityContext as Ce,sourceCapabilitySignals as Ae,foldCapabilitySignals as V,capabilitiesUsedBy as Re}from"@lunora/codegen";import{init as Ie}from"es-module-lexer";import{ts as n,Node as m,Project as Z}from"ts-morph";import{discoverAgentInfo as Oe}from"./discoverAgentInfo-pqFMJBtJ.mjs";import{discoverContainerInfo as _e}from"./discoverContainerInfo-DzXr7Vm3.mjs";import{escapeRegExp as we}from"./DEV_VARS_EXAMPLE_FILE-CqLorAxT.mjs";import{d as D}from"./discover-info-DC2MrAIM.mjs";import{P as De}from"./package-secrets-registry-TouCAMQN.mjs";import{discoverSchemaInfo as Le}from"./discoverSchemaInfo-DRPnqgif.mjs";import{resolveWorkerEntry as Pe,composedEntryDurableObjects as $e,GENERATED_DIRECTORY as _,DURABLE_OBJECT_BINDINGS as Fe,detectExportedDurableObjects as je,detectClassExports as P,isMergedProject as ee}from"./COMPOSED_WORKER_ENTRY-BcFt6ts5.mjs";import{discoverWorkflowInfo as ke}from"./discoverWorkflowInfo-zW7Tt0Tn.mjs";const Be="/api/auth",Me="/.well-known/oauth-protected-resource",Ke="/.well-known/oauth-authorization-server",Ge=String.raw`\/\*[\s\S]*?\*\/`,Ue=String.raw`\/\/[^\n]*`,We=String.raw`"(?:[^"\\\n]|\\.)*"`,Ve=String.raw`'(?:[^'\\\n]|\\.)*'`,He=String.raw`\x60(?:[^\x60\\$]|\\.|\$(?!\{))*\x60`,Ye=new RegExp([Ge,Ue,We,Ve,He].join("|"),"gu"),qe=/[^\n]/gu,Xe=e=>e.replaceAll(qe," "),Qe=e=>e.replaceAll(Ye,t=>t.startsWith("//")||t.startsWith("/*")?Xe(t):t),Je=(e,t)=>{const{error:o,value:s}=D(e,t,Se,he);return o===void 0?{flags:s}:{error:o}},te=(e,t)=>{const o=pe(t,e);return o!==""&&o!==".."&&!o.startsWith(`..${me}`)&&!fe(o)},ze=(e,t)=>{const{error:o,value:s}=D(e,t,void 0,Ee);return o===void 0?{queues:s??[]}:{error:o,queues:[]}},b="@lunora/replica",h="EventLogDOClient",Ze=/\.[cm]?[jt]sx?$/u,H=[".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs"],Y=new Map,K=e=>{const{mtimeMs:t}=k(e),o=Y.get(e);if(o?.mtimeMs===t)return o.source;const s=n.createSourceFile(e,B(e,"utf8"),n.ScriptTarget.Latest);return Y.set(e,{mtimeMs:t,source:s}),s},q=new WeakMap,et=e=>{const t=q.get(e);if(t!==void 0&&t[0]?.wasForgotten()!==!0)return t;const o=e.getDescendantsOfKind(n.SyntaxKind.Identifier);return q.set(e,o),o},X=e=>n.sys.fileExists(e)?k(e).mtimeMs:-1,Q=new Map,tt=e=>{const t=n.findConfigFile(F(e),i=>n.sys.fileExists(i));if(t===void 0)return{};const o=Q.get(t);if(o!==void 0&&[...o.mtimes].every(([i,c])=>X(i)===c))return o.options;const s=n.readJsonConfigFile(t,i=>n.sys.readFile(i)),{options:r}=n.parseJsonSourceFileConfigFileContent(s,n.sys,F(t)),a=new Map([t,...s.extendedSourceFiles??[]].map(i=>[i,X(i)]));return Q.set(t,{mtimes:a,options:r}),r},G=(e,t)=>{if(t===b)return;if(!t.startsWith("./")&&!t.startsWith("../")){const a={moduleResolution:n.ModuleResolutionKind.Bundler,...tt(e)},i=n.resolveModuleName(t,e,a,n.sys).resolvedModule;return i?.isExternalLibraryImport===!0?void 0:i?.resolvedFileName}const o=E(F(e),t.replace(Ze,"")),s=H.map(a=>`${o}${a}`),r=H.map(a=>E(o,`index${a}`));return[...s,...r].find(a=>M(a))},st=e=>{const t=new Map;for(const o of e.statements){if(!n.isImportDeclaration(o)||o.importClause?.phaseModifier===n.SyntaxKind.TypeKeyword||!n.isStringLiteral(o.moduleSpecifier))continue;const s=o.importClause?.namedBindings,r=s!==void 0&&n.isNamedImports(s)?s.elements:[];for(const a of r)a.isTypeOnly||t.set(a.name.text,{module:o.moduleSpecifier.text,name:(a.propertyName??a.name).text})}return t},ot=e=>{const t=new Map;for(const o of e.statements){if(!n.isImportDeclaration(o)||o.importClause?.phaseModifier===n.SyntaxKind.TypeKeyword||!n.isStringLiteral(o.moduleSpecifier))continue;const s=o.importClause?.namedBindings;s!==void 0&&n.isNamespaceImport(s)&&t.set(s.name.text,o.moduleSpecifier.text)}return t},w=e=>n.canHaveModifiers(e)&&(n.getModifiers(e)??[]).some(t=>t.kind===n.SyntaxKind.ExportKeyword),rt=e=>n.isVariableStatement(e)?w(e)?e.declarationList.declarations.flatMap(t=>n.isIdentifier(t.name)?[t.name.text]:[]):[]:(n.isClassDeclaration(e)||n.isFunctionDeclaration(e))&&w(e)?e.name===void 0?[]:[e.name.text]:n.isExportDeclaration(e)&&e.moduleSpecifier===void 0&&!e.isTypeOnly&&e.exportClause!==void 0&&n.isNamedExports(e.exportClause)?e.exportClause.elements.map(t=>t.name.text):[],nt=e=>new Set(e.statements.flatMap(t=>rt(t))),it=(e,t,o)=>{if(n.isIdentifier(e))return t.get(e.text);if(n.isPropertyAccessExpression(e)&&n.isIdentifier(e.expression)){const s=o.get(e.expression.text);return s===void 0?void 0:{module:s,name:e.name.text}}},at=(e,t,o)=>w(e)?e.declarationList.declarations.flatMap(s=>{if(!n.isIdentifier(s.name)||s.initializer===void 0)return[];const r=it(s.initializer,t,o);return r===void 0?[]:[{exported:s.name.text,module:r.module,name:r.name}]}):[],ct=(e,t)=>{const o=e.heritageClauses?.find(r=>r.token===n.SyntaxKind.ExtendsKeyword)?.types[0]?.expression;if(!w(e)||e.name===void 0||o===void 0||!n.isIdentifier(o))return[];const s=t.get(o.text);return s===void 0?[]:[{exported:e.name.text,module:s.module,name:s.name}]},dt=e=>{const t=st(e),o=ot(e);return e.statements.flatMap(s=>{if(n.isVariableStatement(s))return at(s,t,o);if(n.isClassDeclaration(s))return ct(s,t);if(!n.isExportDeclaration(s)||s.isTypeOnly)return[];const{exportClause:r,moduleSpecifier:a}=s,i=a!==void 0&&n.isStringLiteral(a)?a.text:void 0;return r===void 0?i===void 0?[]:[{exported:void 0,module:i,name:void 0}]:n.isNamedExports(r)?r.elements.flatMap(c=>{if(c.isTypeOnly)return[];const d=c.name.text,l=(c.propertyName??c.name).text;if(i!==void 0)return[{exported:d,module:i,name:l}];const u=t.get(l);return u===void 0?[]:[{exported:d,module:u.module,name:u.name}]}):[]})},U=(e,t,o,s,r=new Set)=>{const a=JSON.stringify([e,o,[...r]]);if(s.has(a))return!1;s.add(a);const i=K(e),c=dt(i),d=new Set([...r,...nt(i),...c.flatMap(l=>l.exported===void 0?[]:[l.exported])]);return c.some(l=>{if(o!==void 0&&l.exported!==void 0&&l.exported!==o||l.exported!==void 0&&r.has(l.exported))return!1;if(l.exported===void 0){const g=o??(l.module===b?t:void 0);if(g!==void 0&&d.has(g))return!1}const u=l.exported===void 0?o:l.name;if(l.module===b)return u===void 0||u===t;const y=G(e,l.module);return y!==void 0&&U(y,t,u,s,l.exported===void 0?d:r)})},j=(e,t)=>et(e).some(o=>{const s=o.getParent();return o.getText()!==t||m.isNamespaceImport(s)||m.isPropertyAccessExpression(s)&&s.getNameNode()===o||m.isQualifiedName(s)&&s.getRight()===o?!1:m.isPropertyAccessExpression(s)?s.getName()===h:m.isQualifiedName(s)?!m.isTypeReference(s.getParent())&&s.getRight().getText()===h:!0}),lt=e=>{const[t]=e.getArguments();return e.getExpression().getKind()===n.SyntaxKind.ImportKeyword&&t!==void 0&&(m.isStringLiteral(t)||m.isNoSubstitutionTemplateLiteral(t))&&t.getLiteralValue()===b},ut=e=>{const t=e.getPropertyNameNode();if(t===void 0)return e.getNameNode().getText();const o=m.isComputedPropertyName(t)?t.getExpression():t;return m.isStringLiteral(o)||m.isNoSubstitutionTemplateLiteral(o)?o.getLiteralValue():t.getText()},pt=e=>{let t=e,o=!1;for(let r=e.getParent();m.isParenthesizedExpression(r)||m.isAwaitExpression(r);r=t.getParent())o||=m.isAwaitExpression(r),t=r;if(!o)return!0;const s=t.getParent();if(m.isVariableDeclaration(s)){const r=s.getNameNode();return!m.isObjectBindingPattern(r)||r.getElements().some(a=>a.getDotDotDotToken()!==void 0||ut(a)===h)}return m.isPropertyAccessExpression(s)&&s.getExpression()===t?s.getName()===h:!0},mt=(e,t)=>K(e).statements.some(o=>n.isExportDeclaration(o)&&o.moduleSpecifier!==void 0&&n.isStringLiteral(o.moduleSpecifier)&&o.moduleSpecifier.text===b&&o.exportClause!==void 0&&n.isNamespaceExport(o.exportClause)&&o.exportClause.name.text===t),ft=e=>e.getImportDeclarations().some(t=>{const o=t.getNamespaceImport(),s=t.isTypeOnly()?[]:t.getNamedImports().filter(d=>!d.isTypeOnly()),r=s.some(d=>d.getNameNode().getText()===h),a=s.filter(d=>j(e,(d.getAliasNode()??d.getNameNode()).getText())),i=o!==void 0&&j(e,o.getText());if(!r&&!i&&a.length===0)return!1;const c=G(e.getFilePath(),t.getModuleSpecifierValue());return c===void 0?!1:(r||i)&&U(c,h,h,new Set)||a.some(d=>mt(c,d.getNameNode().getText()))}),se=e=>{const t=e.getImportDeclarations().filter(o=>o.getModuleSpecifierValue()===b&&!o.isTypeOnly());return t.some(o=>o.getNamedImports().some(s=>!s.isTypeOnly()&&s.getNameNode().getText()===h))||t.some(o=>{const s=o.getNamespaceImport();return s!==void 0&&j(e,s.getText())})||e.getExportDeclarations().some(o=>o.getModuleSpecifierValue()===b&&!o.isTypeOnly()&&o.getNamedExports().some(s=>!s.isTypeOnly()&&s.getNameNode().getText()===h))||ft(e)||e.getDescendantsOfKind(n.SyntaxKind.CallExpression).some(o=>lt(o)&&pt(o))},gt=e=>{const t=[],o=s=>{if(n.isImportDeclaration(s)&&s.importClause?.phaseModifier!==n.SyntaxKind.TypeKeyword&&n.isStringLiteral(s.moduleSpecifier))t.push(s.moduleSpecifier.text);else if(n.isExportDeclaration(s)&&!s.isTypeOnly&&s.moduleSpecifier!==void 0&&n.isStringLiteral(s.moduleSpecifier))t.push(s.moduleSpecifier.text);else if(n.isCallExpression(s)&&s.expression.kind===n.SyntaxKind.ImportKeyword){const[r]=s.arguments;r!==void 0&&(n.isStringLiteral(r)||n.isNoSubstitutionTemplateLiteral(r))&&t.push(r.text)}n.forEachChild(s,o)};return o(e),t},ht=new Set([".cjs",".cts",".js",".jsx",".mjs",".mts",".ts",".tsx"]),St=new Set([".git",".lunora-cache",".wrangler","dist",_,"node_modules"]),Et=["lunora","src"],xt=/\benv\s*\.\s*DB\b/,vt=/\benv\s*\.\s*AI\b/,oe=["ai","aiSearch","analytics","analyticsSql","artifacts","browser","hyperdrive","images","kv","mail","notify","payments","pipelines","r2sql","scheduler","storage","x402"],re=e=>`uses${e.charAt(0).toUpperCase()}${e.slice(1)}`,ne=[["usesAuth","@lunora/auth"],["usesCimdWorkers","@lunora/auth/cimd/workers"],["usesX402Charge","@lunora/x402/charge"],["usesPaymentAutumn","@lunora/payment/autumn"],["usesPaymentCreem","@lunora/payment/creem"],["usesPaymentDodopayments","@lunora/payment/dodopayments"],["usesPaymentPolar","@lunora/payment/polar"],["usesPaymentStripe","@lunora/payment/stripe"]],ie=[...oe.map(e=>[re(e),J[e].moduleSpecifier]),...ne].toSorted(([e],[t])=>e.localeCompare(t)),yt=[["usesNotifyFcm","@lunora/notify:fcm"],["usesNotifyFcmTokenSource","@lunora/notify:fcmTokenSource"],["usesNotifyWebPush","@lunora/notify:webPush"],["hostsShardRegistry","@lunora/do:shardRegistry"],["hostsEventLog","@lunora/replica:eventLog"],["usesEventLogClient","@lunora/replica:eventLogClient"],["usesRequestSecretTool","@lunora/agent:requestSecretTool"]],Nt=["@lunora/agent","@lunora/agent/sandbox"],ae=new RegExp(String.raw`["'\x60](?:${[...ie.map(([,e])=>e),...Nt,b].map(e=>we(e)).join("|")})["'\x60]`,"u"),p=e=>{const{contextProperty:t,moduleSpecifier:o}=J[e];return t===void 0?`${o} is imported`:`${o} is imported or ctx.${t} is read`},Tt="STRIPE_SECRET_KEY + STRIPE_WEBHOOK_SECRET (Stripe) or POLAR_ACCESS_TOKEN + POLAR_WEBHOOK_SECRET (Polar)",bt=/\b(authBasePath|basePath):\s*(["'`])(\/[^"'`$\s]*)\2/gu,Ct=/["']@lunora\/auth(?:\/[^"']*)?["']/u,At=/[Bb]asePath/u,Rt=e=>{const t=new Set;for(const o of e){const s=B(o,"utf8");if(!At.test(s))continue;const r=Qe(s),a=Ct.test(r);for(const[,i,,c]of r.matchAll(bt)){const d=c?.endsWith("/")===!0?c.slice(0,-1):c??"";d!==""&&(i==="authBasePath"||a)&&t.add(d)}}return t.size===0?[Be]:[...t].toSorted((o,s)=>o.localeCompare(s))},It=(e,t,o,s)=>{const{error:r,value:a}=D(e,t,void 0,ye);if(r!==void 0)return;const i=o?[...Rt(s),Me,Ke].map(c=>`${c}/*`):[];return[...(a??[]).map(c=>c.path),...i]},Ot=/\bfrom\s+["']\.{1,2}\//u,ce=(e,t)=>{let o;try{o=ue(e,{withFileTypes:!0})}catch{return}for(const s of o){if(s.isDirectory()){St.has(s.name)||ce(E(e,s.name),t);continue}const r=s.name.lastIndexOf(".");r!==-1&&ht.has(s.name.slice(r))&&t.push(E(e,s.name))}},_t=(e,t,o)=>{const s=ve(e,t);return o?{...s,services:s.services.filter(r=>r.binding!==z)}:s},wt=(e,t,o)=>{const{info:s}=Le(e,t,o);return{jurisdiction:s?.jurisdiction,needsD1:s?.hasD1GlobalTable??!1}};let $;const Dt=e=>{const t=ge(e);return $?.root!==t&&($={project:new Z({compilerOptions:{allowJs:!0},skipAddingFilesFromTsConfig:!0}),root:t}),$.project},Lt=(e,t,o)=>{e.getSourceFile(t)?.getFullText()!==o&&e.createSourceFile(t,o,{overwrite:!0})},Pt=(e,t)=>{for(const o of e.getSourceFiles())t.has(o)||e.removeSourceFile(o)},$t=(e,t,o)=>{const s=E(e,o),r=Dt(e),a=[],i=new Set,c=[],d=[],l=be();let u=!1,y=!1;for(const f of t){const S=E(e,f);if(!M(S)||!k(S).isDirectory())continue;const O=[];ce(S,O);for(const A of O){i.add(A);const x=B(A,"utf8"),T=te(A,s);u||=vt.test(x),y||=xt.test(x),(ae.test(x)||x.includes(h)||T&&(Ce(x)||Ot.test(x)))&&(Lt(r,A,x),a.push({file:A,inLunora:T}))}}Pt(r,new Set(a.map(({file:f})=>r.getSourceFileOrThrow(f))));for(const{file:f,inLunora:S}of a)(S?c:d).push(Ae(r.getSourceFileOrThrow(f),l));const g=V(c),C=V([g,...d]),I=new Set([...C.valueImports,...C.dynamicImports]),N=Re({contextReads:g.contextReads,valueImports:I});return{...Object.fromEntries([...oe.map(f=>[re(f),N.has(f)]),...ne.map(([f,S])=>[f,I.has(S)])]),needsD1:y,usesEventLogClient:a.some(({file:f})=>se(r.getSourceFileOrThrow(f))),usesRequestSecretTool:g.requestSecretTool,usesAi:N.has("ai")||u,usesBrowser:N.has("browser")||g.sandboxTools.usesSandboxBrowser,usesWorkerLoader:g.sandboxTools.usesSandboxLoader,scannedFiles:i}},Ft=(e,t,o)=>[...e.map(s=>s.exported?`${s.bindingName}/${s.className} (container "${s.exportName}" declared and exported)`:`hint: container "${s.exportName}" is declared but ${s.className} is not exported by the worker entry — add \`export * from "./lunora/_generated/containers"\``),...t.map(s=>s.exported?`exports.${s.className} (workflow "${s.exportName}" declared and exported)`:`hint: workflow "${s.exportName}" is declared but ${s.className} is not exported by the worker entry — add \`export * from "./lunora/_generated/workflows"\``),...o.map(s=>s.exported?`exports.${s.className} (agent "${s.exportName}" declared and exported)`:`hint: agent "${s.exportName}" is declared but ${s.className} is not exported by the worker entry — add \`export * from "./lunora/_generated/agents"\``)],jt=(e,t,o)=>[[e.usesAi,`AI (${p("ai")}, env.AI is used, or an agent is declared)`],[e.usesAuth&&!t.has("SessionDO"),"hint: @lunora/auth is imported; its tables are D1-backed by default. For DO-backed auth (what @better-auth/scim needs), pass `namespace` to .auth() and export the generated auth DO class"],[e.usesScheduler&&!t.has("SchedulerDO"),`hint: ${p("scheduler")}, but no SchedulerDO is exported by the worker entry`],[e.usesStorage,`hint: ${p("storage")}; add an r2_buckets binding (bucket binding names are user-defined)`],[e.usesMail,`hint: ${p("mail")}; set RESEND_API_KEY in .dev.vars (obtain at https://resend.com/api-keys)`],[e.usesPayments,`hint: ${p("payments")}; set the provider secrets in .dev.vars — ${Tt}`],[e.usesBrowser,`browser (${p("browser")}, or a sandbox browserTool imported in lunora/) — self-describing { binding: BROWSER }`],[e.usesImages,`images (${p("images")}) — self-describing { binding: IMAGES }`],[e.usesAnalytics,`analytics_engine_datasets (${p("analytics")}) — self-describing { binding: ANALYTICS, dataset }`],[e.usesWorkerLoader,"worker_loaders (jsCodeTool imported in lunora/) — self-describing { binding: LOADER }"],[e.usesAiSearch,`ai_search_namespaces (${p("aiSearch")}) — self-describing { binding: AI_SEARCH, namespace: "default" }; remote-only, so \`lunora dev\` reaches the deployed AI Search service`],[e.usesAnalyticsSql,`analytics (${p("analyticsSql")}) — self-describing { binding: ANALYTICS_SQL }; needs wrangler >= 4.145.0, and is remote-only, so \`lunora dev\` queries the account's live analytics`],[e.usesKv,o.jurisdiction===void 0?`kv_namespaces (${p("kv")}) — { binding: KV } with no id; wrangler creates the namespace on the first deploy`:`hint: ${p("kv")} and the schema pins "${o.jurisdiction}"; create the namespace with --jurisdiction ${o.jurisdiction} and add a kv_namespaces binding ({ binding, id })`],[e.usesHyperdrive,`hyperdrive (${p("hyperdrive")}) — { binding: HYPERDRIVE } with a placeholder id; dev uses an embedded Postgres and \`lunora deploy\` creates the config`],[e.usesPipelines,`hint: ${p("pipelines")}; run 'wrangler pipelines create <name>' and add a 'pipelines' binding ({ binding, stream }) — the pipeline resource can't be auto-provisioned`],[e.usesArtifacts,o.jurisdiction===void 0?`artifacts (${p("artifacts")}) — { binding: ARTIFACTS, namespace }`:`hint: ${p("artifacts")}; the schema pins data to "${o.jurisdiction}", so create the namespace in that jurisdiction first and add { binding: ARTIFACTS, namespace } yourself — \`lunora deploy\` then checks it (a first create() in dev would make it unrestricted)`],[e.usesX402Charge,"hint: @lunora/x402/charge is imported; set the recipient wallet address as a [vars] entry (the var name is yours to choose) and pass it to the charge config — the x402 facilitator settles USDC to that address"],[e.usesX402,`hint: ${p("x402")} (ActionCtx-only, spends real funds); add a secrets_store_secrets[] binding for the agent wallet key (name it to match signer.secretName) and pair the pay rail with a spend policy — ctx.secrets reads a Secrets Store binding, not .dev.vars, so the key can't be auto-provisioned`]].filter(([r])=>r).map(([,r])=>r),kt=(e,t,o,s=[],r=[],a=[])=>{const i=new Set(e.map(d=>d.className)),c=e.map(d=>`${d.binding}/${d.className} (exported by worker entry)`);return t.needsD1&&c.push("DB (.global() table declared)"),c.push(...Ft(s,r,a),...jt(o,i,t)),c},Bt=(e,t)=>e.some(o=>o.binding==="SHARD_REGISTRY")||ee(t)&&M(E(t,"shardRegistry.ts")),Mt=(e,t,o)=>{const s=new Z({compilerOptions:{allowJs:!0},skipAddingFilesFromTsConfig:!0}),r=[e],a=new Set;for(let i=r.pop();i!==void 0;i=r.pop()){if(a.has(i))continue;a.add(i);const c=K(i),d=c.text;if((ae.test(d)||d.includes(h))&&se(s.createSourceFile(i,d,{overwrite:!0})))return!0;for(const l of gt(c)){const u=G(i,l);u!==void 0&&!t.has(u)&&!te(u,o)&&r.push(u)}}return!1},Kt=e=>!e.composed&&e.path!==void 0&&U(e.path,"EventLogDO",void 0,new Set),Gt=e=>({usesNotifyFcm:e?.fcm==="env",usesNotifyFcmTokenSource:e?.fcm==="ownToken",usesNotifyWebPush:e?.hasWebPush??!1}),ss=async e=>{await Ie;const t=e.schemaDir??"lunora",o=e.scanDirs??Et,s=()=>$t(e.projectRoot,o,t),{scannedFiles:r,...a}=e.cache===void 0?s():e.cache.memo(`capabilities:${e.projectRoot}:${t}:${o.join(",")}`,s),i=Pe(e.projectRoot);let c;i.composed?c=$e(E(e.projectRoot,t,_)).map(W=>({binding:Fe[W],className:W})):c=i.path===void 0?[]:je(i.path);const d=wt(e.projectRoot,t,e.cache),l={...d,needsD1:a.needsD1||d.needsD1},u=P(i,_e(e.projectRoot,t,e.cache).containers,"containers"),y=P(i,ke(e.projectRoot,t).workflows,"workflows"),g=P(i,Oe(e.projectRoot,t).agents,"agents"),C={...a,usesAi:a.usesAi||g.length>0},I=[...ze(e.projectRoot,t).queues],{flags:N}=Je(e.projectRoot,t),L=D(e.projectRoot,t,Te,Ne),f=N?.provider==="flagship"&&N.mode==="binding"?N.bindingName:void 0,S=E(e.projectRoot,t,_),O=Bt(c,S),A=Kt(i),x=!i.composed&&i.path!==void 0&&Mt(i.path,r,S),T=kt(c,l,C,u,y,g);!i.composed&&ee(E(e.projectRoot,t,_))&&!c.some(v=>v.className==="LunoraDO")&&T.push("hint: durableObjects.merge is set, but the worker entry exports no LunoraDO — export one built with mergeDurableObjects, or the classes stay separate"),f!==void 0&&T.push(`hint: lunora/flags.ts uses Flagship in binding mode; add a flagship binding ({ binding: "${f}", app_id }) — the app_id can't be auto-provisioned`);const R=_t(e.projectRoot,t,e.skipCompanion===!0),de=R.error===void 0?R.services:void 0;R.error!==void 0&&T.push(`hint: lunora.config \`services\` not reconciled — ${R.error}`),T.push(...R.services.map(v=>v.binding===z?`${v.binding} → ${v.worker} (studio.companion)`:`${v.binding} → ${v.worker} (lunora.config services.${v.name})`));const le=It(e.projectRoot,t,C.usesAuth,r);return{...C,usesEventLogClient:C.usesEventLogClient||x,agents:g,containers:u,durableObjects:c,flagshipBinding:f,...l.jurisdiction===void 0?{}:{jurisdiction:l.jurisdiction},needsD1:l.needsD1,queues:I,services:de,signals:T,usesFlags:N!==void 0,...Gt(L.error===void 0?L.value:xe),hostsEventLog:A,hostsShardRegistry:O,workerRoutes:le,workflows:y}},os=e=>[...ie,...yt].filter(([t,o])=>e[t]&&De[o]!==void 0).map(([,t])=>t);export{ss as inferLunoraBindings,os as secretSourcesFromBindings};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const r=e=>e.endsWith("S")?e.slice(0,-1):e,c=e=>e.replaceAll(/([a-z\d])([A-Z])/gu,"$1_$2").toUpperCase().split(/[_-]+/u).filter(s=>s.length>0),i=new Set(["CREDENTIAL","DSN","PASSPHRASE","PASSWD","PASSWORD","SECRET","TOKEN"]),p=["ACCESS_KEY","API_KEY","ENCRYPTION_KEY","PRIVATE_KEY","SIGNING_KEY"],u=new RegExp(`(?:${[...i,...p.map(e=>e.replaceAll("_",""))].join("|")})S?$`,"iu"),y=e=>c(e).some(s=>s==="PUBLIC"||s==="PUBLISHABLE"),E=e=>{if(y(e))return!1;const s=c(e);if(s.some(o=>i.has(r(o))))return!0;const t=r(s.join("_"));return p.some(o=>t===o||t.endsWith(`_${o}`))||u.test(e)},k=[{description:"Bearer token the local Lunora Studio uses to call the worker's admin endpoints (data browser, schema edits) in dev. Generate with: openssl rand -hex 32",docsUrl:"https://lunora.sh/docs/packages/studio",key:"LUNORA_ADMIN_TOKEN",placeholderValue:"replace-with-openssl-rand-hex-32"}],a="LUNORA_RELAY_SECRET",n="replace-with-openssl-rand-hex-32",m=new Set(["@lunora/do:shardRegistry","@lunora/replica:eventLog"]),_="@lunora/replica:eventLogClient",g=["BETTER_AUTH_SECRET","STORAGE_SIGNING_SECRET"],d={"@lunora/auth":[{description:"32-byte random secret used to sign sessions and tokens. Generate with: openssl rand -hex 32",docsUrl:"https://lunora.sh/docs/packages/auth#secrets",key:"AUTH_SECRET",placeholderValue:"replace-with-openssl-rand-hex-32"},{description:"Public base URL of your worker (used by better-auth for redirects and cookie domain). For local dev this is typically http://localhost:8787",docsUrl:"https://lunora.sh/docs/packages/auth#secrets",key:"AUTH_URL",placeholderValue:"http://localhost:8787"}],"@lunora/agent:requestSecretTool":[{description:"AES-256 key that seals secret values held for one agent step, base64 of 32 bytes. Generate with: openssl rand -base64 32. Rotate by moving the old value to LUNORA_SECRET_VALUE_KEY_PREVIOUS first.",docsUrl:"https://lunora.sh/docs/packages/agent#secret-values",key:"LUNORA_SECRET_VALUE_KEY",placeholderValue:"<your-base64-32-byte-key>"}],"@lunora/do:shardRegistry":[{description:"Signs every request to ShardRegistryDO, which refuses unsigned ones, and the shard-to-shard control channel. Set the same value on the worker and every Durable Object. Generate with: openssl rand -hex 32",docsUrl:"https://lunora.sh/docs/concepts/sharding#the-shard-registry",key:a,placeholderValue:n}],"@lunora/bindings/r2sql":[{description:"Cloudflare API token with R2 SQL read access, for `ctx.r2sql`. Create at https://dash.cloudflare.com/profile/api-tokens with the R2 SQL permission.",docsUrl:"https://lunora.sh/docs/packages/bindings#r2-sql",key:"R2_SQL_TOKEN",placeholderValue:"<your-r2-sql-api-token>"},{description:"Cloudflare account id the R2 SQL queries run against. Falls back to CLOUDFLARE_ACCOUNT_ID when unset.",docsUrl:"https://lunora.sh/docs/packages/bindings#r2-sql",key:"R2_SQL_ACCOUNT_ID",placeholderValue:"<your-cloudflare-account-id>"},{description:"Name of the R2 bucket holding the Iceberg tables `ctx.r2sql` queries.",docsUrl:"https://lunora.sh/docs/packages/bindings#r2-sql",key:"R2_SQL_BUCKET",placeholderValue:"<your-r2-sql-bucket>"}],"@lunora/mail":[{description:"Resend API key for sending transactional email via @lunora/mail. Obtain at https://resend.com/api-keys",docsUrl:"https://lunora.sh/docs/packages/mail#secrets",key:"RESEND_API_KEY",placeholderValue:"<your-resend-api-key>"}],"@lunora/replica:eventLog":[{description:"Signs every request to EventLogDO, which refuses unsigned ones, and the calls from the worker that reads or appends the log. Set the same value on the worker and every Durable Object. Generate with: openssl rand -hex 32",docsUrl:"https://lunora.sh/docs/packages/replica#eventlogdo",key:a,placeholderValue:n}],"@lunora/replica:eventLogClient":[{description:"The LUNORA_RELAY_SECRET of the worker that hosts EventLogDO. EventLogDOClient throws at construction without it, and the log refuses every request signed with another value.",docsUrl:"https://lunora.sh/docs/packages/replica#eventlogdo",key:a,placeholderValue:"<your-eventlogdo-host-relay-secret>"}],"@lunora/notify:fcm":[{description:"Google service-account key file for FCM HTTP v1, base64-encoded on one line for .dev.vars (.dev.vars cannot hold its JSON quotes); in production use: wrangler secret put FCM_SERVICE_ACCOUNT < key.json. fcmFromEnv mints access tokens from it and reads the project id from it. Download it from the Firebase console (Project settings → Service accounts).",docsUrl:"https://lunora.sh/docs/packages/notify#fcm",key:"FCM_SERVICE_ACCOUNT",placeholderValue:"<base64-of-your-service-account-key-json>"}],"@lunora/notify:fcmTokenSource":[{description:"Firebase project id for FCM HTTP v1. Your fcm channel supplies its own getAccessToken, so only the project id comes from env. Find it in the Firebase console (Project settings).",docsUrl:"https://lunora.sh/docs/packages/notify#fcm",key:"FCM_PROJECT_ID",placeholderValue:"<your-firebase-project-id>"}],"@lunora/notify:webPush":[{description:"Public VAPID key (base64url) for Web Push. Generate a keypair once with: npx web-push generate-vapid-keys — the public key is also shipped to the browser to subscribe.",docsUrl:"https://lunora.sh/docs/packages/notify#web-push",key:"VAPID_PUBLIC_KEY",placeholderValue:"<your-vapid-public-key>"},{description:"Private VAPID key (base64url) for Web Push — the application-server signing key. Generate with: npx web-push generate-vapid-keys",docsUrl:"https://lunora.sh/docs/packages/notify#web-push",key:"VAPID_PRIVATE_KEY",placeholderValue:"<your-vapid-private-key>"},{description:"VAPID `sub` contact — a mailto: or https: URL identifying the application server (e.g. mailto:you@example.com).",docsUrl:"https://lunora.sh/docs/packages/notify#web-push",key:"VAPID_SUBJECT",placeholderValue:"mailto:you@example.com"}],"@lunora/payment/autumn":[{description:"Autumn secret key (am_sk_…) for the Autumn payment adapter. Obtain at https://app.useautumn.com/dev",docsUrl:"https://lunora.sh/docs/packages/payment#autumn",key:"AUTUMN_SECRET_KEY",placeholderValue:"<your-autumn-secret-key>"},{description:"Autumn webhook signing secret for verifying Standard Webhooks event payloads. Obtain from your Autumn dashboard webhook settings.",docsUrl:"https://lunora.sh/docs/packages/payment#autumn",key:"AUTUMN_WEBHOOK_SECRET",placeholderValue:"<your-autumn-webhook-secret>"}],"@lunora/payment/creem":[{description:"Creem API key for the Creem payment adapter. Obtain at https://www.creem.io/dashboard/developers",docsUrl:"https://lunora.sh/docs/packages/payment#creem",key:"CREEM_API_KEY",placeholderValue:"<your-creem-api-key>"},{description:"Creem webhook signing secret for verifying the creem-signature header. Obtain from your Creem dashboard webhook settings.",docsUrl:"https://lunora.sh/docs/packages/payment#creem",key:"CREEM_WEBHOOK_SECRET",placeholderValue:"<your-creem-webhook-secret>"}],"@lunora/payment/dodopayments":[{description:"Dodo Payments API key (bearer token) for the Dodo Payments adapter. Obtain at https://app.dodopayments.com/developer/api-keys",docsUrl:"https://lunora.sh/docs/packages/payment#dodo-payments",key:"DODO_PAYMENTS_API_KEY",placeholderValue:"<your-dodo-payments-api-key>"},{description:"Dodo Payments webhook signing secret (whsec_…) for verifying event payloads. Obtain at https://app.dodopayments.com/developer/webhooks",docsUrl:"https://lunora.sh/docs/packages/payment#dodo-payments",key:"DODO_PAYMENTS_WEBHOOK_KEY",placeholderValue:"<your-dodo-payments-webhook-secret>"}],"@lunora/payment/polar":[{description:"Polar access token for the Polar payment adapter. Obtain at https://polar.sh/settings/tokens",docsUrl:"https://lunora.sh/docs/packages/payment#polar",key:"POLAR_ACCESS_TOKEN",placeholderValue:"<your-polar-access-token>"},{description:"Polar webhook secret for verifying event payloads from Polar. Obtain at https://polar.sh/settings/webhooks",docsUrl:"https://lunora.sh/docs/packages/payment#polar",key:"POLAR_WEBHOOK_SECRET",placeholderValue:"<your-polar-webhook-secret>"}],"@lunora/payment/stripe":[{description:"Stripe secret key (sk_test_…). Required when using the Stripe adapter. Obtain at https://dashboard.stripe.com/apikeys",docsUrl:"https://lunora.sh/docs/packages/payment#stripe",key:"STRIPE_SECRET_KEY",placeholderValue:"<your-stripe-secret-key>"},{description:"Stripe webhook signing secret (whsec_…) for verifying event payloads. Obtain at https://dashboard.stripe.com/webhooks",docsUrl:"https://lunora.sh/docs/packages/payment#stripe",key:"STRIPE_WEBHOOK_SECRET",placeholderValue:"<your-stripe-webhook-secret>"}]},l=new Set([...g,...[...k,...Object.values(d).flat()].filter(e=>E(e.key)&&!e.placeholderValue.startsWith("<")&&e.key!==a).map(e=>e.key)]),S=e=>e.includes(_)&&!e.some(t=>m.has(t))?l:new Set([...l,a]),b=e=>{const s=[];for(const t of e)for(const o of d[t]??[])s.some(h=>h.key===o.key)||s.push(o);return s};export{k as C,l as M,d as P,a as S,E as a,n as b,y as i,S as m,b as s};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{CUSTOM_INSTANCE_TYPE_LIMITS as j,CUSTOM_INSTANCE_MIN_MEMORY_MIB_PER_VCPU as O}from"@lunora/container";import{i as f,a as d,s as I}from"./spa-assets-BwJFTBeO.mjs";import{i as w}from"./is-plain-object-CWxHeOY1.mjs";import{applyModify as F}from"./applyModify-DKP2l6S9.mjs";import{recordManifestKey as P}from"./readManifest-Cighz3WC.mjs";const A=[{of:e=>e.schedules===void 0?void 0:[...e.schedules],path:["schedules"]},{of:e=>e.limits?.steps,path:["limits","steps"]},{of:e=>e.defaultRetention?.successRetention,path:["default_retention","success_retention"]},{of:e=>e.defaultRetention?.errorRetention,path:["default_retention","error_retention"]}],ye=[...new Set(A.map(({path:e})=>e[0]))],N=(e,s)=>{let t=e;for(const n of s)t=f(t)?t[n]:void 0;return t},ve=e=>{const s={};for(const{of:t,path:n}of A){const i=t(e);if(i===void 0)continue;const[a,o]=n;s[a]=o===void 0?i:{...s[a],[o]:i}}return s},$e=(e,s,t)=>{if(s.length===0)return;const n=e.vectorize??[],i=new Set(n.filter(Boolean).map(a=>a?.index_name));for(const a of s)i.has(a)||t.push(`schema declares vector index "${a}"; wrangler "vectorize" must include a binding with index_name "${a}"`)},B=new Set(["basic","dev","lite","standard","standard-1","standard-2","standard-3","standard-4"]),D={disk_mb:j.diskMb,memory_mib:j.memoryMib,vcpu:{...j.vcpu,hint:'use the named "lite" or "basic" instance type below 1 vCPU'}},K=(e,s,t)=>{const n=e.instance_type;if(n===void 0)return;if(typeof n=="string"){B.has(n)||t.push(`${s} has unknown instance_type "${n}" — expected lite, basic, standard-1..4, or a custom { vcpu, memory_mib, disk_mb } object`);return}for(const[o,{hint:r,max:c,min:m}]of Object.entries(D)){const u=n[o];if(u!==void 0&&(typeof u!="number"||Number.isNaN(u)||u<m||u>c)){const l=r!==void 0&&typeof u=="number"&&u<m?` — ${r}`:"";t.push(`${s} custom instance_type ${o} must be a number in ${String(m)}–${String(c)} (got ${String(u)})${l}`)}}const{memory_mib:i,vcpu:a}=n;typeof a=="number"&&typeof i=="number"&&i<a*O&&t.push(`${s} custom instance_type needs ≥ 3 GiB (${String(O)} MiB) memory per vCPU (got ${String(i)} MiB for ${String(a)} vCPU)`)},G=(e,s,t)=>{for(const n of["image","instance_type","max_instances"])e[n]!==void 0&&t.push(`${s} sets "${n}", which the durable_object scheduling policy does not take — the Durable Object picks image and size at start`);for(const[n,i]of Object.entries(e.images??{}))[i?.dockerfile,i?.image].filter(o=>typeof o=="string"&&o.length>0).length!==1&&t.push(`${s} images["${n}"] must set exactly one of "dockerfile" or "image"`)},H=(e,s,t)=>{const{boundClasses:n,classKinds:i,errors:a,warnings:o}=t;if(!e||typeof e!="object"||typeof e.class_name!="string"||e.class_name.length===0){a.push(`${s} must have a non-empty "class_name" naming its container-enabled Durable Object class`);return}const r=e.scheduling_policy==="durable_object";e.scheduling_policy!==void 0&&e.scheduling_policy!=="default"&&!r&&a.push(`${s} ("${e.class_name}") has unknown scheduling_policy "${e.scheduling_policy}" — expected "default" or "durable_object"`),r?G(e,`${s} ("${e.class_name}")`,a):(typeof e.image!="string"||e.image.length===0)&&a.push(`${s} ("${e.class_name}") must have an "image" — a Dockerfile path or a registry reference`),n.has(e.class_name)||a.push(`${s} class "${e.class_name}" has no matching durable_objects binding — your dev server auto-reconciles this on startup; add { "name": "...", "class_name": "${e.class_name}" } to fix it by hand`);const c=i.get(e.class_name);c!=="sqlite"&&a.push(c==="classic"?`${s} class "${e.class_name}" is registered via "new_classes" but containers require SQLite-backed DOs — move it to "new_sqlite_classes"`:`${s} class "${e.class_name}" is missing from migrations — add a migration entry with "new_sqlite_classes": ["${e.class_name}"]`),K(e,`${s} ("${e.class_name}")`,a),e.max_instances===void 0&&!r&&o.push(`${s} ("${e.class_name}") declares no max_instances — set a cap so a traffic spike can't fan out unbounded container spend`)},h=e=>Array.isArray(e)?e.filter(s=>s!==null&&typeof s=="object"):[],M=e=>Array.isArray(e)?e.filter(s=>d(s)):[],L=e=>{const s=new Map;for(const t of h(e)){for(const n of M(t.new_classes))s.set(n,"classic");for(const n of M(t.new_sqlite_classes))s.set(n,"sqlite");for(const n of h(t.renamed_classes))if(d(n.from)&&d(n.to)){const i=s.get(n.from)??"sqlite";s.delete(n.from),s.set(n.to,i)}for(const n of M(t.deleted_classes))s.delete(n)}return s},Q=e=>new Set(L(e).keys()),we=(e,s)=>{const t=Q(e.migrations);for(const n of h(e.durable_objects?.bindings))n.script_name===void 0&&d(n.class_name)&&!t.has(n.class_name)&&s.push(`durable_objects.bindings declares class "${n.class_name}" but it is missing from migrations — add a migration entry with "new_sqlite_classes": ["${n.class_name}"] (or "new_classes" for a non-SQLite-backed class), or let the dev server auto-reconcile it on the next start`)},ke=(e,s,t)=>{if(e.containers===void 0)return;if(!Array.isArray(e.containers)){s.push("containers must be an array of { class_name, image, ... } entries");return}const n=e.containers;if(n.length===0)return;const i=new Set(h(e.durable_objects?.bindings).map(o=>o.class_name)),a=L(e.migrations);for(const[o,r]of n.entries())H(r,`containers[${String(o)}]`,{boundClasses:i,classKinds:a,errors:s,warnings:t});e.observability?.enabled!==!0&&t.push('containers are configured but observability is not enabled — container logs will not be captured (add { "observability": { "enabled": true } })')},$=e=>e,T=(e,s,t,n)=>{if(e!==void 0){if(!Array.isArray(e)){n.push(t.arrayMessage);return}for(const[i,a]of $(e).entries()){const o=`${s}[${String(i)}]`;if(!a||typeof a!="object"){n.push(t.objectMessage(o));continue}for(const r of t.fields)d(a[r.field])||n.push(r.message(o))}}},Se={arrayMessage:"workflows must be an array of { name, binding, class_name } entries",fields:[{field:"binding",message:e=>`${e} must have a non-empty "binding" naming the Workflow binding (e.g. MY_WORKFLOW)`},{field:"class_name",message:e=>`${e} must have a non-empty "class_name" naming the exported WorkflowEntrypoint class`},{field:"name",message:e=>`${e} must have a non-empty "name" naming the deployed workflow`}],objectMessage:e=>`${e} must be a { name, binding, class_name } object`},V=(e,s)=>e===void 0||s&&d(e)||Array.isArray(e)&&e.length>0&&e.every(n=>d(n))?void 0:"schedules must be a non-empty array of cron expression strings",Y=e=>{if(e!==void 0)return f(e)?e.steps===void 0||Number.isInteger(e.steps)&&e.steps>0?void 0:"limits.steps must be a positive integer":"limits must be an object"},z=e=>e===void 0?[]:f(e)?["success_retention","error_retention"].filter(s=>e[s]!==void 0&&!d(e[s])).map(s=>`default_retention.${s} must be a duration string (e.g. "7 days")`):["default_retention must be an object"],C=(e,s,t,n)=>{const i=[V(e.schedules,t),Y(e.limits),...z(e.default_retention)];for(const a of i)a!==void 0&&n.push(`${s}.${a}`)},J=(e,s)=>A.map(({path:t})=>t).filter(t=>{const n=N(e,t),i=N(s,t),a=typeof i=="string"&&t[0]==="schedules"?[i]:i;return n!==void 0&&i!==void 0&&JSON.stringify(n)!==JSON.stringify(a)}).map(t=>t.join(".")),X=(e,s,t,n)=>{const i=`exports["${e}"]`,a=String(s.name);for(const o of t){if(!f(o)||o.name!==s.name)continue;const r=`workflows entry "${String(o.binding)}"`;if(o.script_name!==void 0){n.push(`${r} binds workflow "${a}" in another Worker, but ${i} declares a workflow with that name here — workflow names are unique per account`);continue}o.class_name!==e&&n.push(`${r} and ${i} both declare workflow "${a}" but name different classes ("${String(o.class_name)}" vs "${e}")`);for(const c of J(o,s))n.push(`${r} and ${i} set ${c} to different values for workflow "${a}" — set it in one place`)}},je=(e,s)=>{const t=Array.isArray(e.workflows)?$(e.workflows):[];for(const[i,a]of t.entries())f(a)&&C(a,`workflows[${String(i)}]`,!1,s);const n=f(e.exports)?Object.entries(e.exports):[];for(const[i,a]of n)!f(a)||a.type!=="workflow"||(d(a.name)?(C(a,`exports["${i}"]`,!0,s),X(i,a,t,s)):s.push(`exports["${i}"] is a workflow export and must have a non-empty "name" naming the deployed workflow`))},Z={arrayMessage:"queues.producers must be an array of { binding, queue } entries",fields:[{field:"binding",message:e=>`${e} must have a non-empty "binding" naming the Queue producer (e.g. QUEUE_EMAIL)`},{field:"queue",message:e=>`${e} must have a non-empty "queue" naming the deployed queue`}],objectMessage:e=>`${e} must be a { binding, queue } object`},ee={arrayMessage:"queues.consumers must be an array of { queue } entries",fields:[{field:"queue",message:e=>`${e} must have a non-empty "queue" naming the consumed queue`}],objectMessage:e=>`${e} must be a { queue } object`},Me=(e,s)=>{if(e.queues!==void 0){if(typeof e.queues!="object"||Array.isArray(e.queues)){s.push("queues must be a { producers, consumers } object");return}T(e.queues.producers,"queues.producers",Z,s),T(e.queues.consumers,"queues.consumers",ee,s)}},Ee={arrayMessage:"secrets_store_secrets must be an array of { binding, store_id, secret_name } entries",fields:["binding","store_id","secret_name"].map(e=>({field:e,message:s=>`${s} must have a non-empty "${e}"`})),objectMessage:e=>`${e} must be a { binding, store_id, secret_name } object`},Re=[{arrayMessage:"kv_namespaces must be an array of { binding, id } entries",bindingMessage:e=>`${e} must have a non-empty "binding" naming the KV namespace binding`,key:"kv_namespaces"},{arrayMessage:"flagship must be an array of { binding, app_id } entries",bindingMessage:e=>`${e} must have a non-empty "binding" naming the Flagship binding`,hintField:"app_id",hintMessage:(e,s)=>`${e} ("${s}") has no "app_id" — create a Flagship app and set its id, or the binding can't resolve`,key:"flagship"},{arrayMessage:"hyperdrive must be an array of { binding, id } entries",bindingMessage:e=>`${e} must have a non-empty "binding" naming the Hyperdrive binding`,hintField:"id",hintMessage:(e,s)=>`${e} ("${s}") has no "id" — run \`wrangler hyperdrive create\` and set the id, or the binding can't connect`,key:"hyperdrive"},{arrayMessage:"pipelines must be an array of { binding, stream } entries",bindingMessage:e=>`${e} must have a non-empty "binding" naming the Pipelines binding`,hintField:["stream","pipeline"],hintMessage:(e,s)=>`${e} ("${s}") has no "stream" — run \`wrangler pipelines create <name>\` and set the stream name, or the binding can't resolve`,key:"pipelines"},{arrayMessage:"analytics_engine_datasets must be an array of { binding, dataset } entries",bindingMessage:e=>`${e} must have a non-empty "binding" naming the Analytics Engine binding`,hintField:"dataset",hintMessage:(e,s)=>`${e} ("${s}") has no "dataset" — it defaults to the binding name; set it explicitly to avoid drift`,key:"analytics_engine_datasets"}],Ae=(e,s,t,n)=>{const i=e[s.key];if(i!==void 0){if(!Array.isArray(i)){t.push(s.arrayMessage);return}for(const[a,o]of $(i).entries()){const r=`${s.key}[${String(a)}]`;if(!o||typeof o!="object"||!d(o.binding)){t.push(s.bindingMessage(r));continue}if(!("hintField"in s))continue;(typeof s.hintField=="string"?[s.hintField]:s.hintField).some(m=>d(o[m]))||n.push(s.hintMessage(r,o.binding))}}},xe=[{key:"analytics",message:'analytics must be an object with a non-empty "binding" (e.g. { "binding": "ANALYTICS_SQL" })'},{key:"browser",message:'browser must be an object with a non-empty "binding" (e.g. { "binding": "BROWSER" })'},{key:"images",message:'images must be an object with a non-empty "binding" (e.g. { "binding": "IMAGES" })'},{key:"media",message:'media must be an object with a non-empty "binding" (e.g. { "binding": "MEDIA" })'},{key:"stream",message:'stream must be an object with a non-empty "binding" (e.g. { "binding": "STREAM" })'}],We=(e,s,t)=>{const n=e[s.key];n!==void 0&&(typeof n!="object"||n===null||Array.isArray(n)||!d(n.binding))&&t.push(s.message)},Oe=[{arrayMessage:"ai_search_namespaces must be an array of { binding, namespace } entries",fields:[{field:"binding",message:e=>`${e} must have a non-empty "binding" naming the AI Search binding`},{field:"namespace",message:e=>`${e} must have a non-empty "namespace" naming the AI Search namespace (every account has "default")`}],key:"ai_search_namespaces",objectMessage:e=>`${e} must be a { binding, namespace } object`},{arrayMessage:"ai_search must be an array of { binding, instance_name } entries",fields:[{field:"binding",message:e=>`${e} must have a non-empty "binding" naming the AI Search binding`},{field:"instance_name",message:e=>`${e} must have a non-empty "instance_name" naming an existing AI Search instance`}],key:"ai_search",objectMessage:e=>`${e} must be a { binding, instance_name } object`},{arrayMessage:"services must be an array of { binding, service, entrypoint? } entries",fields:[{field:"binding",message:e=>`${e} must have a non-empty "binding" naming the service binding`},{field:"service",message:e=>`${e} must have a non-empty "service" naming the target Worker`}],key:"services",objectMessage:e=>`${e} must be a { binding, service, entrypoint? } object`},{arrayMessage:"dispatch_namespaces must be an array of { binding, namespace } entries",fields:[{field:"binding",message:e=>`${e} must have a non-empty "binding"`},{field:"namespace",message:e=>`${e} must have a non-empty "namespace" naming the dispatch namespace`}],key:"dispatch_namespaces",objectMessage:e=>`${e} must be a { binding, namespace } object`},{arrayMessage:"mtls_certificates must be an array of { binding, certificate_id } entries",fields:[{field:"binding",message:e=>`${e} must have a non-empty "binding"`},{field:"certificate_id",message:e=>`${e} must have a non-empty "certificate_id" (upload via \`wrangler mtls-certificate upload\`)`}],key:"mtls_certificates",objectMessage:e=>`${e} must be a { binding, certificate_id } object`},{arrayMessage:"r2_buckets must be an array of { binding, bucket_name } entries",fields:[{field:"binding",message:e=>`${e} must have a non-empty "binding" naming the R2 bucket binding`},{field:"bucket_name",message:e=>`${e} must have a non-empty "bucket_name" naming the deployed bucket`}],key:"r2_buckets",objectMessage:e=>`${e} must be a { binding, bucket_name } object`},{arrayMessage:"vpc_services must be an array of { binding, service_id } entries",fields:[{field:"binding",message:e=>`${e} must have a non-empty "binding" naming the VPC Service binding`},{field:"service_id",message:e=>`${e} must have a non-empty "service_id" (create one with \`wrangler vpc service create\`)`}],key:"vpc_services",objectMessage:e=>`${e} must be a { binding, service_id } object`},{arrayMessage:"artifacts must be an array of { binding, namespace } entries",fields:[{field:"binding",message:e=>`${e} must have a non-empty "binding" naming the Artifacts binding`},{field:"namespace",message:e=>`${e} must have a non-empty "namespace" naming the Artifacts namespace`}],key:"artifacts",objectMessage:e=>`${e} must be a { binding, namespace } object`}],Ie=(e,s,t)=>{s?.hasD1GlobalTable&&!h(e.d1_databases).some(n=>n.binding==="DB")&&t.push('schema declares .global() tables; d1_databases must include a binding named "DB" — your dev server auto-reconciles this on startup, or add the binding manually'),s?.hasHyperdriveGlobalTable&&h(e.hyperdrive).length===0&&t.push('schema declares .global({ backend: "hyperdrive" }) tables; wrangler must declare a hyperdrive binding for `.hyperdriveGlobal({ exec })` to read — run `wrangler hyperdrive create <name> --connection-string=...` and add `"hyperdrive": [{ "binding": "HYPERDRIVE", "id": "<id>" }]` (any binding name works; your `exec` selector picks it)')},Ne=(e,s)=>{const{d1_databases:t}=e;if(t!==void 0){if(!Array.isArray(t)){s.push("d1_databases must be an array of { binding, database_id | database_name } entries");return}for(const[n,i]of $(t).entries()){const a=`d1_databases[${String(n)}]`;if(!i||typeof i!="object"){s.push(`${a} must be a { binding, database_id | database_name } object`);continue}d(i.binding)||s.push(`${a} must have a non-empty "binding" naming the D1 binding`),!d(i.database_id)&&!d(i.database_name)&&s.push(`${a} must have a "database_id" or a "database_name" — run \`wrangler d1 create\` and set one, or the binding can't resolve`)}}},Te=(e,s)=>{const{vpc_networks:t}=e;if(t!==void 0){if(!Array.isArray(t)){s.push("vpc_networks must be an array of { binding, tunnel_id | network_id } entries");return}for(const[n,i]of $(t).entries()){const a=`vpc_networks[${String(n)}]`;if(!i||typeof i!="object"){s.push(`${a} must be a { binding, tunnel_id | network_id } object`);continue}d(i.binding)||s.push(`${a} must have a non-empty "binding" naming the VPC Network binding`),d(i.tunnel_id)===d(i.network_id)&&s.push(`${a} must set exactly one of "tunnel_id" (a Cloudflare Tunnel) or "network_id" ("cf1:network" for Cloudflare Mesh)`)}}},p=["/_lunora/*","/__lunora/*"],se=[p,["/_lunora/*"]],ne="/*",y=100,v=100,R="runWorkerFirst",te=/^[\w.~@%+-]+$/u,ie=e=>{const s=e.split("/").filter(r=>r!==""),t=s.map(r=>te.test(r));if(s.length===0||t[0]===!1)return;const n=s.map((r,c)=>t[c]?r:"*"),i=`/${n.join("/")}`,a=s.at(-1)??"";return a==="*"||t.at(-1)===!1&&a.endsWith("?")?[`/${n.slice(0,-1).join("/")}`,i]:[i]},_=(e,s)=>s!==e&&s.endsWith("*")&&e.startsWith(s.slice(0,-1)),q=e=>e.flatMap((s,t)=>{const n=e.find(i=>_(s,i));return[...s.length>v?[`assets.run_worker_first entry "${s}" is ${String(s.length)} characters; Cloudflare accepts at most ${String(v)}`]:[],...e.indexOf(s)===t?[]:[`assets.run_worker_first lists "${s}" twice`],...n===void 0?[]:[`assets.run_worker_first entry "${s}" is already covered by "${n}", which wrangler refuses`]]}),Ce=e=>{if(e.length===0)return["assets.run_worker_first is an empty list, which wrangler refuses; remove it, or name at least one path"];const s=[];e.length>y&&s.push(`assets.run_worker_first has ${String(e.length)} rules; Cloudflare accepts at most ${String(y)}, duplicates included`);const t=[],n=[];for(const i of e)typeof i=="string"&&i.startsWith("/")?t.push(i):typeof i=="string"&&i.startsWith("!/")?n.push(i):s.push(`assets.run_worker_first entry ${JSON.stringify(i)} must be a path rule starting with "/" (or "!/" to exempt a path)`);return t.length===0&&n.length>0&&s.push("assets.run_worker_first has only negative (!/…) rules; wrangler needs at least one path that runs the Worker first"),s.push(...q(t),...q(n)),s},ae=e=>e.split("/").every(s=>s==="")?`the route "${e}" is the site root; run_worker_first leaves it to the assets (index.html), so add "/" to run_worker_first yourself if the Worker should answer it`:`the route "${e}" starts with a parameter, so no run_worker_first rule names it without sending every path to the Worker; a matching file in the assets directory, or the not_found_handling fallback, answers instead`,oe=e=>{const s=[],t=new Set;for(const o of e){const r=ie(o);if(r===void 0){s.push(ae(o));continue}for(const c of r)c.length>v?s.push(`run_worker_first rule "${c}" is longer than Cloudflare's ${String(v)} characters and was left out`):t.add(c)}const n=[...p,...t],i=[...new Set(n)].filter(o=>!n.some(r=>_(o,r))&&!p.includes(o)).toSorted((o,r)=>o.localeCompare(r)),a=y-p.length;return i.length>a&&s.push(`the routes need ${String(i.length+p.length)} run_worker_first rules and Cloudflare accepts ${String(y)}; ${i.slice(a).join(", ")} were left out`),{rules:[...p,...i.slice(0,a)],warnings:s}},U=(e,s)=>e===s||_(e,s)||_(s,e),re=(e,s)=>{const t=new Map,n=[];if(e===!0)return{excluded:t,missing:n};const i=Array.isArray(e)?e.filter(r=>typeof r=="string"):[],a=i.filter(r=>r.startsWith("/")),o=i.filter(r=>r.startsWith("!/"));for(const r of s){if(!a.some(m=>m===r||_(r,m))){n.push(r);continue}const c=o.filter(m=>U(m.slice(1),r));c.length>0&&t.set(r,c)}return{excluded:t,missing:n}},ce=(e,s,t)=>{const{excluded:n,missing:i}=re(e,t),a=[];i.length>0&&a.push(`${s} does not send ${i.join(", ")} to the Worker first, so a matching file in the assets directory (or the SPA fallback) answers instead of Lunora — add ${i.map(o=>`"${o}"`).join(", ")} to it`);for(const[o,r]of n)a.push(`${s} sends ${o} to the Worker first, but ${r.map(c=>`"${c}"`).join(", ")} takes part of it back to the assets — remove ${r.length===1?"that rule":"those rules"} unless the Worker never serves the paths it names`);return a.length===0?void 0:a.join("; ")},E=(e,s)=>Array.isArray(e)&&e.length===s?.length&&e.every((t,n)=>t===s[n]),de=e=>{const s=e?.lunora?.[R];return w(s)?Object.fromEntries(Object.entries(s).filter(t=>Array.isArray(t[1])&&t[1].every(n=>typeof n=="string"))):{}},ue=(e,s)=>{const t=[...new Set(s)].filter(o=>o.length<v&&!e.some(r=>U(o,r))),n=t.filter(o=>!t.some(r=>_(o,r))).toSorted((o,r)=>o.localeCompare(r)).map(o=>`!${o}`),i=y-1,a=n.length>i?[`run_worker_first has room for ${String(i)} static exemptions; ${n.slice(i).join(", ")} run the Worker, which serves them from the assets binding`]:[];return{rules:[ne,...n.slice(0,i)],warnings:a}},me=e=>`${e} falls back to a single-page app but sets no "binding", so the Worker cannot serve the app shell or a static file; run_worker_first keeps naming only the routes Lunora can see, and a Worker path it misses (a route on a Hono httpRouter, a computed auth basePath) gets index.html. Add "binding": "ASSETS" to ${e}`,le=(e,s,t,n,i)=>e===void 0||E(e,i)||se.some(o=>E(e,o))?E(e,t)?{change:void 0,owned:!0,warning:void 0}:{change:e===void 0?"added":"updated",owned:!0,warning:void 0}:{change:void 0,owned:!1,warning:ce(e,s,n)},ge=e=>[{assets:e.assets,path:["assets"]},...Object.entries(e.env??{}).flatMap(([s,t])=>w(t)?[{assets:t.assets,path:["env",s,"assets"]}]:[])],qe=(e,s,t,n,i)=>{const a=ge(s),o=oe(t),r=ue(o.rules,i),c=de(n),m={},u={added:[],text:e,updated:[],warnings:[]};for(const{assets:l,path:x}of a.filter(g=>w(g.assets))){const g=x.join("."),k=l,W=I(k)!==void 0,S=W?r.rules:o.rules,b=le(k.run_worker_first,`${g}.run_worker_first`,S,o.rules,c[g]);b.owned&&(m[g]=S),b.owned&&!W&&k.not_found_handling==="single-page-application"&&u.warnings.push(me(g)),b.warning!==void 0&&u.warnings.push(b.warning),b.change!==void 0&&(u.text=F(u.text,[...x,"run_worker_first"],S),u[b.change].push(`${g}.run_worker_first`))}return a.some(l=>w(l.assets))&&u.warnings.unshift(...o.warnings,...a.some(l=>I(l.assets)!==void 0)?r.warnings:[]),{...u,record:{consequence:"the next route change leaves run_worker_first as it is",key:R,label:"run_worker_first rules",write:l=>{P(l,R,Object.keys(m).length===0?void 0:m)}}}};export{Re as H,Oe as R,xe as S,Se as W,Ie as a,Ne as b,$e as c,ke as d,T as e,Q as f,je as g,Me as h,Ae as i,We as j,Te as k,Ee as l,qe as m,ye as n,h as o,M as p,A as q,Ce as r,N as s,we as v,ve as w};
|