@lunora/config 1.0.0-alpha.106 → 1.0.0-alpha.107
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cloudflare/index.d.mts +5 -0
- package/dist/cloudflare/index.d.ts +5 -0
- package/dist/cloudflare/index.mjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/packem_shared/{CLOUDFLARE_DRIVER-DqnWynqM.mjs → CLOUDFLARE_DRIVER-BllWt7Xx.mjs} +1 -1
- package/dist/packem_shared/{DEFAULT_DEPLOY_TARGET-DDfyhjj8.mjs → DEFAULT_DEPLOY_TARGET-DMsFUSw7.mjs} +1 -1
- package/dist/packem_shared/{LUNORA_CONFIG_FILE-DVkEe5L6.mjs → LUNORA_CONFIG_FILE-4XwJQRl9.mjs} +1 -1
- package/dist/packem_shared/REQUIRED_COMPATIBILITY_DATE-BP_35C9u.mjs +1 -0
- package/dist/packem_shared/{inferLunoraBindings-BP-OTizO.mjs → inferLunoraBindings-DhfIOVhl.mjs} +1 -1
- package/package.json +3 -3
- package/dist/packem_shared/REQUIRED_COMPATIBILITY_DATE-XijSB4Zt.mjs +0 -1
|
@@ -427,6 +427,8 @@ declare const REQUIRED_FLAG: string;
|
|
|
427
427
|
interface WranglerDurableObjectBinding {
|
|
428
428
|
class_name?: string;
|
|
429
429
|
name?: string;
|
|
430
|
+
/** Present when the class lives in ANOTHER Worker — then it is that script's to export, not this entry's. */
|
|
431
|
+
script_name?: string;
|
|
430
432
|
}
|
|
431
433
|
/**
|
|
432
434
|
* A `tail_consumers` entry: a Worker that receives this Worker's tail events
|
|
@@ -459,6 +461,8 @@ interface WranglerWorkflowEntry {
|
|
|
459
461
|
binding?: string;
|
|
460
462
|
class_name?: string;
|
|
461
463
|
name?: string;
|
|
464
|
+
/** Present when the class lives in ANOTHER Worker — then it is that script's to export. */
|
|
465
|
+
script_name?: string;
|
|
462
466
|
}
|
|
463
467
|
/** A wrangler `queues.producers[]` entry — a `Queue` binding sending to `queue`. */
|
|
464
468
|
interface WranglerQueueProducer {
|
|
@@ -530,6 +534,7 @@ interface WranglerConfig {
|
|
|
530
534
|
id?: string;
|
|
531
535
|
} | null | undefined>;
|
|
532
536
|
logpush?: boolean;
|
|
537
|
+
main?: string;
|
|
533
538
|
migrations?: ReadonlyArray<{
|
|
534
539
|
new_classes?: ReadonlyArray<string>;
|
|
535
540
|
new_sqlite_classes?: ReadonlyArray<string>;
|
|
@@ -427,6 +427,8 @@ declare const REQUIRED_FLAG: string;
|
|
|
427
427
|
interface WranglerDurableObjectBinding {
|
|
428
428
|
class_name?: string;
|
|
429
429
|
name?: string;
|
|
430
|
+
/** Present when the class lives in ANOTHER Worker — then it is that script's to export, not this entry's. */
|
|
431
|
+
script_name?: string;
|
|
430
432
|
}
|
|
431
433
|
/**
|
|
432
434
|
* A `tail_consumers` entry: a Worker that receives this Worker's tail events
|
|
@@ -459,6 +461,8 @@ interface WranglerWorkflowEntry {
|
|
|
459
461
|
binding?: string;
|
|
460
462
|
class_name?: string;
|
|
461
463
|
name?: string;
|
|
464
|
+
/** Present when the class lives in ANOTHER Worker — then it is that script's to export. */
|
|
465
|
+
script_name?: string;
|
|
462
466
|
}
|
|
463
467
|
/** A wrangler `queues.producers[]` entry — a `Queue` binding sending to `queue`. */
|
|
464
468
|
interface WranglerQueueProducer {
|
|
@@ -530,6 +534,7 @@ interface WranglerConfig {
|
|
|
530
534
|
id?: string;
|
|
531
535
|
} | null | undefined>;
|
|
532
536
|
logpush?: boolean;
|
|
537
|
+
main?: string;
|
|
533
538
|
migrations?: ReadonlyArray<{
|
|
534
539
|
new_classes?: ReadonlyArray<string>;
|
|
535
540
|
new_sqlite_classes?: ReadonlyArray<string>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{default as o}from"../packem_shared/CLOUDFLARE_DRIVER-
|
|
1
|
+
import{default as o}from"../packem_shared/CLOUDFLARE_DRIVER-BllWt7Xx.mjs";import{reconcileWranglerBindings as l}from"../packem_shared/reconcileWranglerBindings-CHFT6zqp.mjs";import{reconcileWranglerCompatibilityDate as t}from"../packem_shared/reconcileWranglerCompatibilityDate-BXNiEQ7p.mjs";import{reconcileWranglerCrons as E}from"../packem_shared/reconcileWranglerCrons-BmQa_kGL.mjs";import{REMOTE_ELIGIBLE_KEYS as g,injectRemoteFlags as R,isRemoteEnvEnabled as c,materializeRemoteWranglerConfig as f,planRemoteBindings as s,resolveRemoteEnabled as W}from"../packem_shared/REMOTE_ELIGIBLE_KEYS-ws6iE0y-.mjs";import{WORKERS_CACHE_MIN_DATE as d,isCacheEnabled as x}from"../packem_shared/WORKERS_CACHE_MIN_DATE-B1h_wNDN.mjs";import{WRANGLER_FILES as I,findWranglerFile as _,readWranglerJsonc as A}from"../packem_shared/WRANGLER_FILES-Bi_18Pj6.mjs";import{collectWranglerSecretVariables as D,scanWranglerVariablesForSecrets as T}from"../packem_shared/collectWranglerSecretVariables-OacEwPmL.mjs";import{wranglerToAlchemy as F}from"../packem_shared/wranglerToAlchemy-Fh5KfTPB.mjs";import{REQUIRED_COMPATIBILITY_DATE as S,REQUIRED_FLAG as B,validateWrangler as O,validateWranglerConfig as h,validateWranglerProject as G,withTailConsumer as M}from"../packem_shared/REQUIRED_COMPATIBILITY_DATE-BP_35C9u.mjs";export{o as CLOUDFLARE_DRIVER,g as REMOTE_ELIGIBLE_KEYS,S as REQUIRED_COMPATIBILITY_DATE,B as REQUIRED_FLAG,d as WORKERS_CACHE_MIN_DATE,I as WRANGLER_FILES,D as collectWranglerSecretVariables,_ as findWranglerFile,R as injectRemoteFlags,x as isCacheEnabled,c as isRemoteEnvEnabled,f as materializeRemoteWranglerConfig,s as planRemoteBindings,A as readWranglerJsonc,l as reconcileWranglerBindings,t as reconcileWranglerCompatibilityDate,E as reconcileWranglerCrons,W as resolveRemoteEnabled,T as scanWranglerVariablesForSecrets,O as validateWrangler,h as validateWranglerConfig,G as validateWranglerProject,M as withTailConsumer,F as wranglerToAlchemy};
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{AGENT_MODE_ENV as t,detectAiAgent as o}from"./packem_shared/AGENT_MODE_ENV-B54hVQ_w.mjs";import{discoverAgentInfo as E}from"./packem_shared/discoverAgentInfo-BJm0QtoI.mjs";import{AGENT_RULES_DIR as _,AGENT_RULES_HINT as s,AGENT_RULES_HINT_ENV as p,LUNORA_SKILL_NAMES as c,ROOT_SKILL_NAME as l,claimAgentRulesHint as n,detectAgentRules as d}from"./packem_shared/AGENT_RULES_DIR-hP9TiDNx.mjs";import{discoverContainerInfo as A}from"./packem_shared/discoverContainerInfo-CYG9j2LY.mjs";import{streamContainerLogs as f}from"./packem_shared/streamContainerLogs-BPYBNrWS.mjs";import{detectFramework as L,readProjectDependencyNames as N}from"./packem_shared/detectFramework-VTQfCNXy.mjs";import{DEV_DAEMON_ENV as T,DEV_HANDOFF_ENV as R,DEV_LOG_FILE as I,DEV_LOG_FILE_ENV as x,DEV_STATE_DIR as V,DEV_STATE_FILE as P,claimDevServerState as g,clearDevServerState as F,isProcessAlive as O,isRecordedProcessCurrent as u,readDevServerState as G,readLiveDevServerState as U,updateDevServerState as C,writeDevServerState as M}from"./packem_shared/DEV_DAEMON_ENV-D9Z83rlU.mjs";import{DEV_VARS_EXAMPLE_FILE as B,DEV_VARS_FILE as b,DEV_VARS_KEY_PATTERN as k,parseDevVariableEntries as w}from"./packem_shared/DEV_VARS_EXAMPLE_FILE-DX6xGbpr.mjs";import{DEFAULT_DEPLOY_TARGET as j,deployTargetIds as h,resolveDeployDriver as H}from"./packem_shared/DEFAULT_DEPLOY_TARGET-
|
|
1
|
+
import{AGENT_MODE_ENV as t,detectAiAgent as o}from"./packem_shared/AGENT_MODE_ENV-B54hVQ_w.mjs";import{discoverAgentInfo as E}from"./packem_shared/discoverAgentInfo-BJm0QtoI.mjs";import{AGENT_RULES_DIR as _,AGENT_RULES_HINT as s,AGENT_RULES_HINT_ENV as p,LUNORA_SKILL_NAMES as c,ROOT_SKILL_NAME as l,claimAgentRulesHint as n,detectAgentRules as d}from"./packem_shared/AGENT_RULES_DIR-hP9TiDNx.mjs";import{discoverContainerInfo as A}from"./packem_shared/discoverContainerInfo-CYG9j2LY.mjs";import{streamContainerLogs as f}from"./packem_shared/streamContainerLogs-BPYBNrWS.mjs";import{detectFramework as L,readProjectDependencyNames as N}from"./packem_shared/detectFramework-VTQfCNXy.mjs";import{DEV_DAEMON_ENV as T,DEV_HANDOFF_ENV as R,DEV_LOG_FILE as I,DEV_LOG_FILE_ENV as x,DEV_STATE_DIR as V,DEV_STATE_FILE as P,claimDevServerState as g,clearDevServerState as F,isProcessAlive as O,isRecordedProcessCurrent as u,readDevServerState as G,readLiveDevServerState as U,updateDevServerState as C,writeDevServerState as M}from"./packem_shared/DEV_DAEMON_ENV-D9Z83rlU.mjs";import{DEV_VARS_EXAMPLE_FILE as B,DEV_VARS_FILE as b,DEV_VARS_KEY_PATTERN as k,parseDevVariableEntries as w}from"./packem_shared/DEV_VARS_EXAMPLE_FILE-DX6xGbpr.mjs";import{DEFAULT_DEPLOY_TARGET as j,deployTargetIds as h,resolveDeployDriver as H}from"./packem_shared/DEFAULT_DEPLOY_TARGET-DMsFUSw7.mjs";import{inferLunoraBindings as W,packageNamesFromBindings as J}from"./packem_shared/inferLunoraBindings-DhfIOVhl.mjs";import{LINKED_PROJECT_DIR as X,LINKED_PROJECT_FILE as z,readLinkedProject as Q,writeLinkedProject as Z}from"./packem_shared/LINKED_PROJECT_DIR-CMzUvj-1.mjs";import{LUNORA_EVENT_SOURCE as ee,formatLunoraEvent as re}from"./packem_shared/LUNORA_EVENT_SOURCE-ZclWASXS.mjs";import{default as oe}from"./packem_shared/LunoraReporter-BnXUqh8t.mjs";import{PACKAGE_SECRETS_REGISTRY as Ee,secretsForPackages as ie}from"./packem_shared/PACKAGE_SECRETS_REGISTRY-BgmvEPA-.mjs";import{LUNORA_CONFIG_FILE as se,interpretRemote as pe,readProjectRemotePreference as ce,readProjectTarget as le,resolveProjectTarget as ne,resolveTargetOrThrow as de}from"./packem_shared/LUNORA_CONFIG_FILE-4XwJQRl9.mjs";import{createConfirm as Ae,isInteractive as Se,promptMultiSelect as fe,promptSelect as De,promptText as Le,promptYesNo as Ne}from"./packem_shared/createConfirm-7IL0kZyE.mjs";import{buildPackageSecretsBlock as Te,ensureDevVariables as Re,ensureDevVarsExample as Ie,fillDevSecrets as xe,generateSecretValue as Ve,isMintableSecretKey as Pe,isPlaceholderValue as ge,planDevSecretsFill as Fe,planDevVariablesAugment as Oe,planDevVariablesScaffold as ue,requiredSecrets as Ge}from"./packem_shared/buildPackageSecretsBlock-BpvaZzQ8.mjs";import{applyAdditiveEdit as Ce,classifyEdit as Me}from"./packem_shared/applyAdditiveEdit-Cff30cSa.mjs";import{parseSchema as Be}from"./packem_shared/parseSchema-BQjgz6bk.mjs";import{classifyPolicyEdit as ke,scaffoldPolicyFile as we,wireRlsIntoProcedure as Ke}from"./packem_shared/classifyPolicyEdit-BzC_MfYK.mjs";import{discoverSchemaInfo as he}from"./packem_shared/discoverSchemaInfo-C8X9mo-i.mjs";import{ACCENT as Ye,BADGES as We,BADGE_COLUMN_WIDTH as Je,LUNA_ART as qe,LUNA_BUNNY as Xe,LUNA_NAME as ze,LUNA_SIGNOFF as Qe,STEP_BADGE_NAMES as Ze,badgeLead as $e,badgeWidth as er,padBadge as rr,paintAnswer as tr,paintBadge as or}from"./packem_shared/ACCENT-CLeV5v0K.mjs";import{discoverWorkflowInfo as Er}from"./packem_shared/discoverWorkflowInfo-Bbc0u2gE.mjs";export{Ye as ACCENT,t as AGENT_MODE_ENV,_ as AGENT_RULES_DIR,s as AGENT_RULES_HINT,p as AGENT_RULES_HINT_ENV,We as BADGES,Je as BADGE_COLUMN_WIDTH,j as DEFAULT_DEPLOY_TARGET,T as DEV_DAEMON_ENV,R as DEV_HANDOFF_ENV,I as DEV_LOG_FILE,x as DEV_LOG_FILE_ENV,V as DEV_STATE_DIR,P as DEV_STATE_FILE,B as DEV_VARS_EXAMPLE_FILE,b as DEV_VARS_FILE,k as DEV_VARS_KEY_PATTERN,X as LINKED_PROJECT_DIR,z as LINKED_PROJECT_FILE,qe as LUNA_ART,Xe as LUNA_BUNNY,ze as LUNA_NAME,Qe as LUNA_SIGNOFF,se as LUNORA_CONFIG_FILE,ee as LUNORA_EVENT_SOURCE,c as LUNORA_SKILL_NAMES,oe as LunoraReporter,Ee as PACKAGE_SECRETS_REGISTRY,l as ROOT_SKILL_NAME,Ze as STEP_BADGE_NAMES,Ce as applyAdditiveEdit,$e as badgeLead,er as badgeWidth,Te as buildPackageSecretsBlock,n as claimAgentRulesHint,g as claimDevServerState,Me as classifyEdit,ke as classifyPolicyEdit,F as clearDevServerState,Ae as createConfirm,h as deployTargetIds,d as detectAgentRules,o as detectAiAgent,L as detectFramework,E as discoverAgentInfo,A as discoverContainerInfo,he as discoverSchemaInfo,Er as discoverWorkflowInfo,Re as ensureDevVariables,Ie as ensureDevVarsExample,xe as fillDevSecrets,re as formatLunoraEvent,Ve as generateSecretValue,W as inferLunoraBindings,pe as interpretRemote,Se as isInteractive,Pe as isMintableSecretKey,ge as isPlaceholderValue,O as isProcessAlive,u as isRecordedProcessCurrent,J as packageNamesFromBindings,rr as padBadge,tr as paintAnswer,or as paintBadge,w as parseDevVariableEntries,Be as parseSchema,Fe as planDevSecretsFill,Oe as planDevVariablesAugment,ue as planDevVariablesScaffold,fe as promptMultiSelect,De as promptSelect,Le as promptText,Ne as promptYesNo,G as readDevServerState,Q as readLinkedProject,U as readLiveDevServerState,N as readProjectDependencyNames,ce as readProjectRemotePreference,le as readProjectTarget,Ge as requiredSecrets,H as resolveDeployDriver,ne as resolveProjectTarget,de as resolveTargetOrThrow,we as scaffoldPolicyFile,ie as secretsForPackages,f as streamContainerLogs,C as updateDevServerState,Ke as wireRlsIntoProcedure,M as writeDevServerState,Z as writeLinkedProject};
|
package/dist/packem_shared/{CLOUDFLARE_DRIVER-DqnWynqM.mjs → CLOUDFLARE_DRIVER-BllWt7Xx.mjs}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{inferLunoraBindings as c}from"./inferLunoraBindings-
|
|
1
|
+
import{inferLunoraBindings as c}from"./inferLunoraBindings-DhfIOVhl.mjs";import{reconcileWranglerBindings as p}from"./reconcileWranglerBindings-CHFT6zqp.mjs";import{reconcileWranglerCompatibilityDate as u}from"./reconcileWranglerCompatibilityDate-BXNiEQ7p.mjs";import{reconcileWranglerCrons as g}from"./reconcileWranglerCrons-BmQa_kGL.mjs";const m=(e,r)=>{const a=e.durableObjects.map(t=>({className:t.className,exported:!0,name:t.binding})),n=e.queues.map(t=>({name:t.name})),s=e.workflows.map(t=>({exported:t.exported,name:t.exportName}));return{containers:e.containers.map(t=>({exported:t.exported,name:t.exportName})),crons:[...r],globalDatabase:e.needsD1,keyValueStore:e.usesKv,objectStorage:e.usesStorage,queues:n,shardNamespaces:a,signals:[...e.signals],workflows:s}},i=(e,r)=>{try{const a=r();return{added:a.added??[],changed:a.changed,configPath:a.wranglerPath,warnings:a.warnings??[]}}catch(a){const n=a instanceof Error?a.message:String(a);return{added:[],changed:!1,warnings:[`${e} skipped: ${n}`]}}},l={deploy:e=>{const r=e.preview===!0?["versions","upload"]:["deploy"];return e.entry!==void 0&&r.push(e.entry),e.environment!==void 0&&r.push("--env",e.environment),e.temporary===!0&&r.push("--temporary"),e.dryRun===!0&&r.push("--dry-run"),e.outDir!==void 0&&r.push("--outdir",e.outDir,"--metafile"),{args:r,tool:"wrangler"}},dev:e=>{const r=["dev"];return e.configPath!==void 0&&r.push("--config",e.configPath),e.environment!==void 0&&r.push("--env",e.environment),r.push(...e.extraArgs??[]),{args:r,tool:"wrangler"}},secretList:e=>{const r=["secret","list","--format","json"];return e.environment!==void 0&&r.push("--env",e.environment),e.temporary===!0&&r.push("--temporary"),{args:r,tool:"wrangler"}},secretPut:e=>{const r=["secret","put",e.key??""];return e.environment!==void 0&&r.push("--env",e.environment),e.temporary===!0&&r.push("--temporary"),{args:r,tool:"wrangler"}},tail:e=>{const r=["tail"];return e.worker!==void 0&&r.push(e.worker),e.environment!==void 0&&r.push("--env",e.environment),e.format!==void 0&&r.push("--format",e.format),e.status!==void 0&&r.push("--status",e.status),e.search!==void 0&&r.push("--search",e.search),e.temporary===!0&&r.push("--temporary"),{args:r,tool:"wrangler"}}},w={id:"cloudflare",infer:async e=>{const r=await c({projectRoot:e.projectRoot});return m(r,e.crons??[])},name:"Cloudflare",provision:async e=>{const r=e.crons??[],a=await(async()=>{try{const o=await c({projectRoot:e.projectRoot});return i("binding inference",()=>p(e.projectRoot,o))}catch(o){const d=o instanceof Error?o.message:String(o);return{added:[],changed:!1,warnings:[`binding inference skipped: ${d}`]}}})(),n=i("compatibility date sync",()=>u(e.projectRoot)),s=i("cron trigger sync",()=>g(e.projectRoot,r)),t=[a,{...n,added:n.changed?["compatibility_date"]:[]},{...s,added:s.changed?[`${String(r.length)} cron trigger(s)`]:[]}];return{added:t.flatMap(o=>o.added),changed:t.some(o=>o.changed),configPath:t.find(o=>o.configPath!==void 0)?.configPath,warnings:t.flatMap(o=>o.warnings)}},toolchain:l};export{w as default};
|
package/dist/packem_shared/{DEFAULT_DEPLOY_TARGET-DDfyhjj8.mjs → DEFAULT_DEPLOY_TARGET-DMsFUSw7.mjs}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import t from"./CLOUDFLARE_DRIVER-
|
|
1
|
+
import t from"./CLOUDFLARE_DRIVER-BllWt7Xx.mjs";const a="cloudflare",r={cloudflare:t},l=()=>Object.keys(r).toSorted((e,o)=>e.localeCompare(o)),n=(e=a)=>{const o=r[e];if(o===void 0)throw new Error(`unknown deploy target "${e}" — available targets: ${l().join(", ")}`);return o};export{a as DEFAULT_DEPLOY_TARGET,l as deployTargetIds,n as resolveDeployDriver};
|
package/dist/packem_shared/{LUNORA_CONFIG_FILE-DVkEe5L6.mjs → LUNORA_CONFIG_FILE-4XwJQRl9.mjs}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{existsSync as n,readFileSync as s}from"node:fs";import{readProjectTarget as i}from"@lunora/codegen";import{parse as l}from"jsonc-parser";import{DEFAULT_DEPLOY_TARGET as c,resolveDeployDriver as f}from"./DEFAULT_DEPLOY_TARGET-
|
|
1
|
+
import{existsSync as n,readFileSync as s}from"node:fs";import{readProjectTarget as i}from"@lunora/codegen";import{parse as l}from"jsonc-parser";import{DEFAULT_DEPLOY_TARGET as c,resolveDeployDriver as f}from"./DEFAULT_DEPLOY_TARGET-DMsFUSw7.mjs";import{join as m}from"node:path";const p="lunora.json",u=r=>{if(typeof r=="boolean")return r;if(r!==null&&typeof r=="object")return!0},j=r=>{const e=m(r,p);if(!n(e))return;let t;try{t=s(e,"utf8")}catch{return}const a=[],o=l(t,a,{allowTrailingComma:!0});if(!(a.length>0||o===null||typeof o!="object"))return o},E=r=>u(j(r)?.remote),T=r=>i(r),y=(r,e)=>e??T(r)??c,F=(r,e)=>{const t=y(r,e);return f(t),t};export{p as LUNORA_CONFIG_FILE,u as interpretRemote,E as readProjectRemotePreference,T as readProjectTarget,y as resolveProjectTarget,F as resolveTargetOrThrow};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{existsSync as u,readFileSync as $}from"node:fs";import{dirname as y,join as l}from"node:path";import{WORKER_ENTRY_FALLBACKS as w}from"./inferLunoraBindings-DhfIOVhl.mjs";import{discoverSchemaInfo as j}from"./discoverSchemaInfo-C8X9mo-i.mjs";import{isCacheEnabled as A,WORKERS_CACHE_MIN_DATE as g}from"./WORKERS_CACHE_MIN_DATE-B1h_wNDN.mjs";import{findWranglerFile as S,readWranglerJsonc as k}from"./WRANGLER_FILES-Bi_18Pj6.mjs";const b="2026-04-07",je="web_socket_auto_reply_to_close",f=/^\d{4}-\d{2}-\d{2}$/,M=(e,n,s)=>{if(n.length===0)return;const t=e.vectorize??[],a=new Set(t.filter(Boolean).map(r=>r?.index_name));for(const r of n)a.has(r)||s.push(`schema declares vector index "${r}"; wrangler "vectorize" must include a binding with index_name "${r}"`)},q=new Set(["basic","dev","lite","standard","standard-1","standard-2","standard-3","standard-4"]),x={disk_mb:2e4,memory_mib:12288,vcpu:4},O=(e,n,s)=>{const t=e.instance_type;if(t===void 0)return;if(typeof t=="string"){q.has(t)||s.push(`${n} has unknown instance_type "${t}" — expected lite, basic, standard-1..4, or a custom { vcpu, memory_mib, disk_mb } object`);return}for(const[c,o]of Object.entries(x)){const d=t[c];d!==void 0&&(typeof d!="number"||d<=0||d>o)&&s.push(`${n} custom instance_type ${c} must be a positive number ≤ ${String(o)} (got ${String(d)})`)}const{disk_mb:a,memory_mib:r,vcpu:i}=t;if(typeof i=="number"&&typeof r=="number"&&r<i*3072&&s.push(`${n} custom instance_type needs ≥ 3 GiB (3072 MiB) memory per vCPU (got ${String(r)} MiB for ${String(i)} vCPU)`),typeof r=="number"&&typeof a=="number"){const c=Math.floor(r/1024*2e3);a>c&&s.push(`${n} custom instance_type allows ≤ 2 GB disk per GiB memory (≤ ${String(c)} MB for ${String(r)} MiB memory; got ${String(a)} MB)`)}},R=(e,n,s)=>{const{boundClasses:t,errors:a,nonSqliteClasses:r,sqliteClasses:i,warnings:c}=s;if(!e||typeof e!="object"||typeof e.class_name!="string"||e.class_name.length===0){a.push(`${n} must have a non-empty "class_name" naming its container-enabled Durable Object class`);return}(typeof e.image!="string"||e.image.length===0)&&a.push(`${n} ("${e.class_name}") must have an "image" — a Dockerfile path or a registry reference`),t.has(e.class_name)||a.push(`${n} class "${e.class_name}" has no matching durable_objects binding — run \`lunora dev\` to auto-reconcile wrangler.jsonc, or add { "name": "...", "class_name": "${e.class_name}" }`),i.has(e.class_name)||a.push(r.has(e.class_name)?`${n} class "${e.class_name}" is registered via "new_classes" but containers require SQLite-backed DOs — move it to "new_sqlite_classes"`:`${n} class "${e.class_name}" is missing from migrations — add a migration entry with "new_sqlite_classes": ["${e.class_name}"]`),O(e,`${n} ("${e.class_name}")`,a),e.max_instances===void 0&&c.push(`${n} ("${e.class_name}") declares no max_instances — set a cap so a traffic spike can't fan out unbounded container spend`)},m=e=>Array.isArray(e)?e.filter(n=>n!==null&&typeof n=="object"):[],E=(e,n,s)=>{if(e.containers===void 0)return;if(!Array.isArray(e.containers)){n.push("containers must be an array of { class_name, image, ... } entries");return}const t=e.containers;if(t.length===0)return;const a=new Set(m(e.durable_objects?.bindings).map(o=>o.class_name)),r=e.migrations??[],i=new Set(r.flatMap(o=>[...o?.new_sqlite_classes??[]])),c=new Set(r.flatMap(o=>[...o?.new_classes??[]]));for(const[o,d]of t.entries())R(d,`containers[${String(o)}]`,{boundClasses:a,errors:n,nonSqliteClasses:c,sqliteClasses:i,warnings:s});e.observability?.enabled!==!0&&s.push('containers are configured but observability is not enabled — container logs will not be captured (add { "observability": { "enabled": true } })')},D=(e,n)=>{if(e.workflows===void 0)return;if(!Array.isArray(e.workflows)){n.push("workflows must be an array of { name, binding, class_name } entries");return}const s=e.workflows;for(const[t,a]of s.entries()){const r=`workflows[${String(t)}]`;if(!a||typeof a!="object"){n.push(`${r} must be a { name, binding, class_name } object`);continue}(typeof a.binding!="string"||a.binding.length===0)&&n.push(`${r} must have a non-empty "binding" naming the Workflow binding (e.g. WORKFLOW_ORDER_PIPELINE)`),(typeof a.class_name!="string"||a.class_name.length===0)&&n.push(`${r} must have a non-empty "class_name" naming the exported WorkflowEntrypoint class`),(typeof a.name!="string"||a.name.length===0)&&n.push(`${r} must have a non-empty "name" naming the deployed workflow`)}},W=(e,n)=>{if(e===void 0)return;if(!Array.isArray(e)){n.push("queues.producers must be an array of { binding, queue } entries");return}const s=e;for(const[t,a]of s.entries()){const r=`queues.producers[${String(t)}]`;if(!a||typeof a!="object"){n.push(`${r} must be a { binding, queue } object`);continue}(typeof a.binding!="string"||a.binding.length===0)&&n.push(`${r} must have a non-empty "binding" naming the Queue producer (e.g. QUEUE_EMAIL)`),(typeof a.queue!="string"||a.queue.length===0)&&n.push(`${r} must have a non-empty "queue" naming the deployed queue`)}},L=(e,n)=>{if(e===void 0)return;if(!Array.isArray(e)){n.push("queues.consumers must be an array of { queue } entries");return}const s=e;for(const[t,a]of s.entries()){const r=`queues.consumers[${String(t)}]`;if(!a||typeof a!="object"){n.push(`${r} must be a { queue } object`);continue}(typeof a.queue!="string"||a.queue.length===0)&&n.push(`${r} must have a non-empty "queue" naming the consumed queue`)}},C=(e,n)=>{if(e.queues!==void 0){if(typeof e.queues!="object"||Array.isArray(e.queues)){n.push("queues must be a { producers, consumers } object");return}W(e.queues.producers,n),L(e.queues.consumers,n)}},N=(e,n)=>{if(e.secrets_store_secrets===void 0)return;if(!Array.isArray(e.secrets_store_secrets)){n.push("secrets_store_secrets must be an array of { binding, store_id, secret_name } entries");return}const s=e.secrets_store_secrets;for(const[t,a]of s.entries()){const r=`secrets_store_secrets[${String(t)}]`;if(!a||typeof a!="object"){n.push(`${r} must be a { binding, store_id, secret_name } object`);continue}for(const i of["binding","store_id","secret_name"])(typeof a[i]!="string"||a[i].length===0)&&n.push(`${r} must have a non-empty "${i}"`)}},p=e=>typeof e=="string"&&e.length>0,_=e=>e,I=[{arrayMessage:"kv_namespaces must be an array of { binding, id } entries",bindingMessage:e=>`${e} must have a non-empty "binding" naming the KV namespace binding`,hintField:"id",hintMessage:(e,n)=>`${e} ("${n}") has no "id" — run \`wrangler kv namespace create\` and set the namespace id, or the binding can't resolve`,key:"kv_namespaces"},{arrayMessage:"flagship must be an array of { binding, app_id } entries",bindingMessage:e=>`${e} must have a non-empty "binding" naming the Flagship binding`,hintField:"app_id",hintMessage:(e,n)=>`${e} ("${n}") 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,n)=>`${e} ("${n}") 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,n)=>`${e} ("${n}") 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,n)=>`${e} ("${n}") has no "dataset" — it defaults to the binding name; set it explicitly to avoid drift`,key:"analytics_engine_datasets"}],B=(e,n,s,t)=>{const a=e[n.key];if(a!==void 0){if(!Array.isArray(a)){s.push(n.arrayMessage);return}for(const[r,i]of _(a).entries()){const c=`${n.key}[${String(r)}]`;if(!i||typeof i!="object"||!p(i.binding)){s.push(n.bindingMessage(c));continue}(typeof n.hintField=="string"?[n.hintField]:n.hintField).some(o=>p(i[o]))||t.push(n.hintMessage(c,i.binding))}}},F=[{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" })'}],P=(e,n,s)=>{const t=e[n.key];t!==void 0&&(typeof t!="object"||Array.isArray(t)||!p(t.binding))&&s.push(n.message)},T=[{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`}],U=(e,n,s)=>{const t=e[n.key];if(t!==void 0){if(!Array.isArray(t)){s.push(n.arrayMessage);return}for(const[a,r]of _(t).entries()){const i=`${n.key}[${String(a)}]`;if(!r||typeof r!="object"){s.push(n.objectMessage(i));continue}for(const c of n.fields)p(r[c.field])||s.push(c.message(i))}}},G=(e,n,s)=>{const t=e.send_email;if(t===void 0)return;if(!Array.isArray(t)){n.push("send_email must be an array of { name, destination_address? } entries");return}const a=t;for(const[r,i]of a.entries())(!i||typeof i!="object"||typeof i.name!="string"||i.name.length===0)&&s.push(`send_email[${String(r)}] has no non-empty "name" naming the send-email binding — set one before deploying`)},Y=(e,n)=>{e.logpush!==void 0&&typeof e.logpush!="boolean"&&n.push('logpush must be a boolean (set "logpush": true to enable Cloudflare Logpush)')},H=(e,n)=>{const{placement:s}=e;if(s!==void 0){if(typeof s!="object"||Array.isArray(s)){n.push('placement must be an object (e.g. { "mode": "smart" })');return}s.mode!==void 0&&s.mode!=="smart"&&n.push('placement.mode must be "smart" (the only supported Smart Placement mode)')}},K=(e,n)=>{const{observability:s}=e;if(s===void 0)return;if(typeof s!="object"||Array.isArray(s)){n.push('observability must be an object (e.g. { "enabled": true, "head_sampling_rate": 1 })');return}const t=(a,r)=>{a!==void 0&&(typeof a!="number"||Number.isNaN(a)||a<0||a>1)&&n.push(`${r} must be a number in [0, 1] (the fraction of requests sampled)`)};t(s.head_sampling_rate,"observability.head_sampling_rate"),s.logs!==void 0&&(typeof s.logs!="object"||Array.isArray(s.logs)?n.push("observability.logs must be an object"):t(s.logs.head_sampling_rate,"observability.logs.head_sampling_rate"))},Q=(e,n)=>{const{cache:s}=e;if(s!==void 0){if(typeof s!="object"||s===null||Array.isArray(s)){n.push('cache must be an object (e.g. { "enabled": true })');return}s.enabled!==void 0&&typeof s.enabled!="boolean"&&n.push("cache.enabled must be a boolean (true or false)")}},z=(e,n)=>{const{exports:s}=e;if(s!==void 0){if(typeof s!="object"||s===null||Array.isArray(s)){n.push("exports must be an object keyed by entrypoint name");return}for(const[t,a]of Object.entries(s)){if(typeof a!="object"||a===null){n.push(`exports["${t}"] must be an object`);continue}a.type!==void 0&&typeof a.type!="string"&&n.push(`exports["${t}"].type must be a string`),a.cache!==void 0&&(typeof a.cache!="object"||a.cache===null||Array.isArray(a.cache)?n.push(`exports["${t}"].cache must be an object`):a.cache.enabled!==void 0&&typeof a.cache.enabled!="boolean"&&n.push(`exports["${t}"].cache.enabled must be a boolean`))}}},J=(e,n)=>{const{assets:s}=e;if(s!==void 0){if(typeof s!="object"||Array.isArray(s)){n.push('assets must be an object (e.g. { "directory": "./dist/client", "binding": "ASSETS" })');return}(typeof s.directory!="string"||s.directory.length===0)&&n.push('assets must declare a non-empty "directory" pointing at the built client output (e.g. "./dist/client")'),s.binding!==void 0&&(typeof s.binding!="string"||s.binding.length===0)&&n.push('assets.binding must be a non-empty string (e.g. "ASSETS")'),s.html_handling!==void 0&&typeof s.html_handling!="string"&&n.push("assets.html_handling must be a string"),s.not_found_handling!==void 0&&typeof s.not_found_handling!="string"&&n.push("assets.not_found_handling must be a string")}},Z=(e,n)=>{const s=e.tail_consumers;if(s===void 0)return;if(!Array.isArray(s)){n.push("tail_consumers must be an array of { service, environment? } entries");return}const t=s;for(const[a,r]of t.entries())(!r||typeof r!="object"||typeof r.service!="string"||r.service.length===0)&&n.push(`tail_consumers[${String(a)}] must have a non-empty "service" naming the consumer Worker`)},Ae=(e,n)=>{const s=e.tail_consumers??[];return s.some(t=>!!t&&t?.service===n.service&&t?.environment===n.environment)?e:{...e,tail_consumers:[...s,n]}},V=new Set(["1","enabled","on","true","yes"]),X=(e,n)=>{const{vars:s}=e;if(!s||typeof s!="object")return;const t=s.LUNORA_ALLOWED_ORIGINS,a=s.LUNORA_CORS_ALLOW_CREDENTIALS,r=typeof t=="string"&&t.split(",").some(c=>c.trim()==="*"),i=typeof a=="string"&&V.has(a.trim().toLowerCase());r&&i&&n.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')},v=(e,n)=>{const s=[],t=[];if(!e||typeof e!="object")return s.push("wrangler config is not a valid object"),{errors:s,valid:!1,warnings:t};m(e.durable_objects?.bindings).find(r=>r.name==="SHARD"&&r.class_name==="ShardDO")||s.push('durable_objects.bindings must include { "name": "SHARD", "class_name": "ShardDO" } — run `lunora dev` to auto-reconcile wrangler.jsonc, or add the binding manually');const a=e.compatibility_date??"";a&&!f.test(a)?s.push(`compatibility_date must be in YYYY-MM-DD format (got "${a}")`):a<b&&s.push(`compatibility_date must be >= "${b}" (got "${a||"<missing>"}")`),A(e)&&f.test(a)&&a<g&&s.push(`cache.enabled requires compatibility_date >= "${g}" (got "${a||"<missing>"}")`),n?.hasGlobalTable&&(m(e.d1_databases).find(r=>r.binding==="DB")||s.push('schema declares .global() tables; d1_databases must include a binding named "DB" — run `lunora dev` to auto-reconcile wrangler.jsonc, or add the binding manually')),M(e,n?.vectorIndexNames??[],s),Z(e,s),E(e,s,t),D(e,s),C(e,s),N(e,s);for(const r of I)B(e,r,s,t);for(const r of T)U(e,r,s);for(const r of F)P(e,r,s);return G(e,s,t),Y(e,s),H(e,s),K(e,s),J(e,s),Q(e,s),z(e,s),X(e,s),{errors:s,valid:s.length===0,warnings:t}},Se=v,ee=(e,n,s)=>{const t=[];for(const a of e){const r=a?.image;typeof r!="string"||!(r.startsWith("./")||r.startsWith("../")||r.startsWith("/")||r.includes("Dockerfile"))||u(r.startsWith("/")?r:l(n,r))||t.push(`containers image "${r}" does not exist (resolved relative to ${s}); create the Dockerfile or point image at a registry reference`)}return t},se=(e,n,s)=>{if(typeof e=="string"&&e.length>0){const t=l(y(s),e);return u(t)?t:void 0}return w.map(t=>l(n,t)).find(t=>u(t))},ne=/\/\/[^\n]*|\/\*.*?\*\/|"[^"\n]*"|'[^'\n]*'|`[^`]*`/gsu,te=e=>e.replaceAll(ne,n=>n.replaceAll(/[^\n]/gu," ")),ae=/\bexport\s*\*\s*(?:as\s+\w+\s*)?from\b/u,re=/\bexport\b/gu,ie=/^\s*(?:(?:abstract|async|declare|default)\s+)*/u,oe=/^(?:class|const|function|let|var)\s+(?<name>[$A-Z_a-z][\w$]*)/u,ce=/^\s*(?:const|let|var)\s*\{/u,de=/^[$A-Z_a-z][\w$]*/u,ue=/^type\b/u,le=/\s+/u,me=e=>{const n=[];for(const s of e.split(",")){const t=s.trim().split(le).filter(Boolean),a=t.at(-1);a!==void 0&&t[0]!=="type"&&n.push(a)}return n},pe=e=>{const n=[];for(const s of e.split(",")){const t=s.includes(":")?s.slice(s.indexOf(":")+1):s,a=de.exec(t.trim());a&&n.push(a[0])}return n},h=e=>{const n=e.indexOf("{"),s=e.indexOf("}",n);return n===-1||s===-1?void 0:e.slice(n+1,s)},ge=e=>{const n=e.trimStart();if(ue.test(n))return[];if(n.startsWith("{")){const t=h(n);return t===void 0?[]:me(t)}if(ce.test(e)){const t=h(e);return t===void 0?[]:pe(t)}const s=oe.exec(e.replace(ie,""));return s?.groups?.name===void 0?[]:[s.groups.name]},be=e=>{const n=new Set;for(const s of e.matchAll(re))for(const t of ge(e.slice(s.index+6)))n.add(t);return n},fe=(e,n,s)=>{const t=se(e.main,n,s);if(t===void 0)return[];let a;try{a=$(t,"utf8")}catch{return[]}const r=te(a);if(ae.test(r))return[];const i=[];for(const o of m(e.durable_objects?.bindings))typeof o.class_name=="string"&&o.class_name.length>0&&o.script_name===void 0&&i.push({className:o.class_name,label:"durable_objects.bindings"});for(const o of e.workflows??[])typeof o?.class_name=="string"&&o.class_name.length>0&&o.script_name===void 0&&i.push({className:o.class_name,label:"workflows"});const c=be(r);return i.filter(o=>!c.has(o.className)).map(o=>`${o.label} declares class "${o.className}" but the worker entry (${t}) does not export it — wrangler refuses to bundle a Worker whose Durable Object classes are not exported. Add \`export { ${o.className} } from "…";\` to the entry.`)},ke=e=>{const n=e.schemaDir??"lunora",s=S(e.projectRoot);if(!s){const d=`wrangler.jsonc not found in ${e.projectRoot}; create one declaring at least the SHARD durable object binding.`;return{problems:[d],report:{errors:[d],valid:!1,warnings:[]},wranglerPath:void 0}}const{parsed:t}=k(s);if(t===void 0){const d=`failed to parse ${s} as JSONC.`;return{problems:[d],report:{errors:[d],valid:!1,warnings:[]},wranglerPath:s}}const{error:a,info:r}=j(e.projectRoot,n),i=v(t,r);a!==void 0&&i.warnings.push(`schema parse failed in ${n}/schema.ts: ${a}`);const c=y(s);i.errors.push(...ee(t.containers??[],c,s)),i.warnings.push(...fe(t,e.projectRoot,s));const o=t.assets?.directory;if(typeof o=="string"&&o.length>0){const d=o.startsWith("/")?o:l(c,o);u(d)||i.warnings.push(`assets.directory "${o}" does not exist yet — it is created by the client build; run the build before deploy`)}return i.valid=i.errors.length===0,{problems:i.errors,report:i,wranglerPath:s}};export{b as REQUIRED_COMPATIBILITY_DATE,je as REQUIRED_FLAG,Se as validateWrangler,v as validateWranglerConfig,ke as validateWranglerProject,Ae as withTailConsumer};
|
package/dist/packem_shared/{inferLunoraBindings-BP-OTizO.mjs → inferLunoraBindings-DhfIOVhl.mjs}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{existsSync as d,statSync as O,readFileSync as b,readdirSync as C}from"node:fs";import{init as T,parse as f}from"es-module-lexer";import{discoverAgentInfo as B}from"./discoverAgentInfo-BJm0QtoI.mjs";import{WRANGLER_FILES as P,readWranglerJsonc as L}from"./WRANGLER_FILES-Bi_18Pj6.mjs";import{discoverContainerInfo as K}from"./discoverContainerInfo-CYG9j2LY.mjs";import{FLAGS_FILENAME as M,discoverFlags as H,QUEUES_FILENAME as q,discoverQueues as G}from"@lunora/codegen";import{Project as R}from"ts-morph";import{join as c}from"node:path";import{discoverSchemaInfo as W}from"./discoverSchemaInfo-C8X9mo-i.mjs";import{discoverWorkflowInfo as X}from"./discoverWorkflowInfo-Bbc0u2gE.mjs";const U=(e,r)=>{const t=c(e,r,M);if(!d(t))return{};try{const s=new R({skipAddingFilesFromTsConfig:!0,useInMemoryFileSystem:!1});return{flags:H(s,c(e,r))}}catch(s){return{error:s instanceof Error?s.message:String(s)}}},Q=(e,r)=>{const t=c(e,r,q);if(!d(t))return{queues:[]};try{const s=new R({skipAddingFilesFromTsConfig:!0,useInMemoryFileSystem:!1});return{queues:G(s,c(e,r))}}catch(s){return{error:s instanceof Error?s.message:String(s),queues:[]}}},Y=new Set([".cjs",".cts",".js",".jsx",".mjs",".mts",".ts",".tsx"]),z=new Set([".git",".lunora-cache",".wrangler","_generated","dist","node_modules"]),J=["lunora","src"],V=["src/server/index.ts","src/server/index.tsx","src/index.ts","src/worker.ts"],k={SchedulerDO:"SCHEDULER",SessionDO:"SESSION",ShardDO:"SHARD"},$=Object.keys(k),Z={SchedulerDO:/\btype\s+SchedulerDO\b/,SessionDO:/\btype\s+SessionDO\b/,ShardDO:/\btype\s+ShardDO\b/},ee=/\benv\s*\.\s*DB\b/,re=/\benv\s*\.\s*AI\b/,A=/\bctx\s*\.\s*pipelines\b/,_=/^\s*import\s+type\b/,se=new Set(["@lunora/agent","@lunora/agent/sandbox"]),te=e=>{const r=e.indexOf("{");if(r===-1)return"";const t=e.indexOf("}",r+1);return t===-1?e.slice(r+1):e.slice(r+1,t)},ne=/\btype\s+browserTool\b/,oe=/\bbrowserTool\b/,ae=/import\s+\{[^}]*\bbrowserTool\b[^}]*\}\s+from\s+["']@lunora\/agent(?:\/sandbox)?["']/,ie=e=>{if(_.test(e))return!1;const r=te(e);return oe.test(r)&&!ne.test(r)},ce=e=>{try{const[r]=f(e);return r.some(t=>t.n!==void 0&&se.has(t.n)&&ie(e.slice(t.ss,t.se)))}catch{return ae.test(e)}},g={usesAi:{pattern:/\bfrom\s+["']@lunora\/ai["']/,source:"@lunora/ai"},usesAnalytics:{pattern:/\bfrom\s+["']@lunora\/bindings\/analytics["']/,source:"@lunora/bindings/analytics"},usesAuth:{pattern:/\bfrom\s+["']@lunora\/auth["']/,source:"@lunora/auth"},usesBrowser:{pattern:/\bfrom\s+["']@lunora\/browser["']/,source:"@lunora/browser"},usesHyperdrive:{pattern:/\bfrom\s+["']@lunora\/hyperdrive["']/,source:"@lunora/hyperdrive"},usesImages:{pattern:/\bfrom\s+["']@lunora\/bindings\/images["']/,source:"@lunora/bindings/images"},usesKv:{pattern:/\bfrom\s+["']@lunora\/bindings\/kv["']/,source:"@lunora/bindings/kv"},usesMail:{pattern:/\bfrom\s+["']@lunora\/mail["']/,source:"@lunora/mail"},usesPayment:{pattern:/\bfrom\s+["']@lunora\/payment["']/,source:"@lunora/payment"},usesPipelines:{pattern:A,source:"@lunora/bindings/pipelines"},usesScheduler:{pattern:/\bfrom\s+["']@lunora\/scheduler["']/,source:"@lunora/scheduler"},usesStorage:{pattern:/\bfrom\s+["']@lunora\/storage["']/,source:"@lunora/storage"},usesX402Charge:{pattern:/\bfrom\s+["']@lunora\/x402\/charge["']/,source:"@lunora/x402/charge"},usesX402Pay:{pattern:/\bfrom\s+["']@lunora\/x402\/pay["']/,source:"@lunora/x402/pay"}},p=Object.keys(g),ue="STRIPE_SECRET_KEY + STRIPE_WEBHOOK_SECRET (Stripe) or POLAR_ACCESS_TOKEN + POLAR_WEBHOOK_SECRET (Polar)",I=[...p,"needsD1"],de=()=>{const e={};for(const r of I)e[r]=!1;return e},l=Object.freeze(de()),y=(e,r)=>{const t={};for(const s of I)t[s]=e[s]||r[s];return t},le=e=>{for(const r of p)if(g[r].source===e)return{...l,[r]:!0};return l},pe=e=>{const[r]=f(e);let t=l;for(const s of r){const n=s.n;!n||_.test(e.slice(s.ss,s.se))||(t=y(t,le(n)))}return t},me=e=>{const r={...l};for(const t of p)r[t]=g[t].pattern.test(e);return r},be=e=>{let r;try{r=pe(e)}catch{r=me(e)}return y(r,{...l,needsD1:ee.test(e),usesAi:re.test(e),usesPipelines:A.test(e)})},S=(e,r)=>{let t;try{t=C(e,{withFileTypes:!0})}catch{return}for(const s of t){if(s.isDirectory()){z.has(s.name)||S(c(e,s.name),r);continue}const n=s.name.lastIndexOf(".");n!==-1&&Y.has(s.name.slice(n))&&r.push(c(e,s.name))}},fe=e=>{for(const r of P){const t=c(e,r);if(!d(t))continue;const{parsed:s}=L(t),n=s?.main;if(typeof n=="string"&&d(c(e,n)))return c(e,n);break}for(const r of V){const t=c(e,r);if(d(t))return t}},ge=e=>{const r=b(e,"utf8");let t;try{const[,s]=f(r);t=new Set(s.map(n=>n.n))}catch{t=new Set($.filter(s=>new RegExp(String.raw`\bexport\b[^\n;]*\b${s}\b`).test(r)))}return $.filter(s=>t.has(s)&&!Z[s].test(r)).map(s=>({binding:k[s],className:s}))},j=e=>e.replaceAll(/[$()*+.?[\\\]^{|}]/gu,String.raw`\$&`),he=/(?:^|[\s,{])type$/u,ye=(e,r)=>{const t=r.ls>=0?r.ls:r.s;return he.test(e.slice(0,t).trimEnd())},Se=(e,r)=>{const t=j(r);return new RegExp(String.raw`\bexport\s+type\s+${t}\b`,"u").test(e)||new RegExp(String.raw`\bexport\s+type\s*\{[^}]*\b${t}\b`,"u").test(e)||new RegExp(String.raw`\bexport\s+\{[^}]*\btype\s+${t}\b`,"u").test(e)},w=(e,r,t)=>{if(r.length===0)return[];if(e===void 0)return r.map(o=>({...o,exported:!1}));const s=b(e,"utf8"),n=new RegExp(String.raw`\bexport\s*\*\s*from\s*["'][^"']*_generated\/${t}(?:\.js)?["']`).test(s);let a;try{const[,o]=f(s);a=new Set(o.filter(i=>!ye(s,i)).map(i=>i.n))}catch{a=new Set(r.map(o=>o.className).filter(o=>new RegExp(String.raw`\bexport\b[^\n;]*\b${j(o)}\b`,"u").test(s)&&!Se(s,o)))}return r.map(o=>{const i=n||a.has(o.className);return{...o,exported:i}})},we=(e,r)=>w(e,r,"containers"),xe=(e,r)=>w(e,r,"workflows"),ve=(e,r)=>w(e,r,"agents"),Ee=(e,r)=>W(e,r).info?.hasGlobalTable??!1,Ne=(e,r)=>{let t=l;for(const s of r){const n=c(e,s);if(!d(n)||!O(n).isDirectory())continue;const a=[];S(n,a);for(const o of a)t=y(t,be(b(o,"utf8")))}return t},De=(e,r)=>{const t=c(e,r);if(!d(t)||!O(t).isDirectory())return!1;const s=[];return S(t,s),s.some(n=>ce(b(n,"utf8")))},$e=(e,r,t)=>[...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"\``),...r.map(s=>s.exported?`${s.bindingName}/${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"\``),...t.map(s=>s.exported?`${s.bindingName}/${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"\``)],Oe=(e,r)=>[[e.usesAi,"AI (@lunora/ai imported or env.AI used)"],[e.usesAuth&&!r.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&&!r.has("SchedulerDO"),"hint: @lunora/scheduler is imported but no SchedulerDO is exported by the worker entry"],[e.usesStorage,"hint: @lunora/storage is imported; add an r2_buckets binding (bucket binding names are user-defined)"],[e.usesMail,"hint: @lunora/mail is imported; set RESEND_API_KEY in .dev.vars (obtain at https://resend.com/api-keys)"],[e.usesPayment,`hint: @lunora/payment is imported; set the provider secrets in .dev.vars — ${ue}`],[e.usesBrowser,"browser (@lunora/browser imported) — self-describing { binding: BROWSER }"],[e.usesImages,"images (@lunora/bindings/images imported) — self-describing { binding: IMAGES }"],[e.usesAnalytics,"analytics_engine_datasets (@lunora/bindings/analytics imported) — self-describing { binding: ANALYTICS, dataset }"],[e.usesKv,"hint: @lunora/bindings/kv is imported; add a kv_namespaces binding ({ binding, id }) and pass env.<BINDING> to createKv() — the namespace id can't be auto-provisioned"],[e.usesHyperdrive,"hint: @lunora/hyperdrive is imported; run 'wrangler hyperdrive create' and add a 'hyperdrive' binding ({ binding, id }) — the id can't be auto-provisioned"],[e.usesPipelines,"hint: ctx.pipelines is used; run 'wrangler pipelines create <name>' and add a 'pipelines' binding ({ binding, pipeline }) — the pipeline resource can't be auto-provisioned"],[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.usesX402Pay,"hint: @lunora/x402/pay is imported (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(([t])=>t).map(([,t])=>t),Re=(e,r,t,s=[],n=[],a=[])=>{const o=new Set(e.map(u=>u.className)),i=e.map(u=>`${u.binding}/${u.className} (exported by worker entry)`);return r&&i.push("DB (.global() table declared)"),i.push(...$e(s,n,a),...Oe(t,o)),i},Le=async e=>{await T;const r=e.schemaDir??"lunora",t=e.scanDirs??J,s=Ne(e.projectRoot,t),n={...s,usesBrowser:s.usesBrowser||De(e.projectRoot,r)},a=fe(e.projectRoot),o=a?ge(a):[],i=n.needsD1||Ee(e.projectRoot,r),u=we(a,K(e.projectRoot,r).containers),x=xe(a,X(e.projectRoot,r).workflows),v=ve(a,B(e.projectRoot,r).agents),F=[...Q(e.projectRoot,r).queues],{flags:m}=U(e.projectRoot,r),h=m?.provider==="flagship"&&m.mode==="binding"?m.bindingName:void 0,E={};for(const D of p)E[D]=n[D];const N=Re(o,i,n,u,x,v);return h!==void 0&&N.push(`hint: lunora/flags.ts uses Flagship in binding mode; add a flagship binding ({ binding: "${h}", app_id }) — the app_id can't be auto-provisioned`),{agents:v,containers:u,durableObjects:o,flagshipBinding:h,needsD1:i,queues:F,signals:N,usesFlags:m!==void 0,workflows:x,...E}},Ke=e=>{const r=[];for(const t of p)e[t]&&r.push(g[t].source);return r};export{Le as inferLunoraBindings,Ke as packageNamesFromBindings};
|
|
1
|
+
import{existsSync as d,statSync as k,readFileSync as b,readdirSync as C}from"node:fs";import{init as T,parse as f}from"es-module-lexer";import{discoverAgentInfo as B}from"./discoverAgentInfo-BJm0QtoI.mjs";import{WRANGLER_FILES as P,readWranglerJsonc as L}from"./WRANGLER_FILES-Bi_18Pj6.mjs";import{discoverContainerInfo as K}from"./discoverContainerInfo-CYG9j2LY.mjs";import{FLAGS_FILENAME as W,discoverFlags as H,QUEUES_FILENAME as M,discoverQueues as q}from"@lunora/codegen";import{Project as D}from"ts-morph";import{join as c}from"node:path";import{discoverSchemaInfo as G}from"./discoverSchemaInfo-C8X9mo-i.mjs";import{discoverWorkflowInfo as U}from"./discoverWorkflowInfo-Bbc0u2gE.mjs";const X=(e,r)=>{const t=c(e,r,W);if(!d(t))return{};try{const s=new D({skipAddingFilesFromTsConfig:!0,useInMemoryFileSystem:!1});return{flags:H(s,c(e,r))}}catch(s){return{error:s instanceof Error?s.message:String(s)}}},Y=(e,r)=>{const t=c(e,r,M);if(!d(t))return{queues:[]};try{const s=new D({skipAddingFilesFromTsConfig:!0,useInMemoryFileSystem:!1});return{queues:q(s,c(e,r))}}catch(s){return{error:s instanceof Error?s.message:String(s),queues:[]}}},Q=new Set([".cjs",".cts",".js",".jsx",".mjs",".mts",".ts",".tsx"]),z=new Set([".git",".lunora-cache",".wrangler","_generated","dist","node_modules"]),J=["lunora","src"],V=["src/server/index.ts","src/server/index.tsx","src/index.ts","src/worker.ts"],$={SchedulerDO:"SCHEDULER",SessionDO:"SESSION",ShardDO:"SHARD"},O=Object.keys($),Z={SchedulerDO:/\btype\s+SchedulerDO\b/,SessionDO:/\btype\s+SessionDO\b/,ShardDO:/\btype\s+ShardDO\b/},ee=/\benv\s*\.\s*DB\b/,re=/\benv\s*\.\s*AI\b/,A=/\bctx\s*\.\s*pipelines\b/,_=/^\s*import\s+type\b/,se=new Set(["@lunora/agent","@lunora/agent/sandbox"]),te=e=>{const r=e.indexOf("{");if(r===-1)return"";const t=e.indexOf("}",r+1);return t===-1?e.slice(r+1):e.slice(r+1,t)},ne=/\btype\s+browserTool\b/,oe=/\bbrowserTool\b/,ae=/import\s+\{[^}]*\bbrowserTool\b[^}]*\}\s+from\s+["']@lunora\/agent(?:\/sandbox)?["']/,ie=e=>{if(_.test(e))return!1;const r=te(e);return oe.test(r)&&!ne.test(r)},ce=e=>{try{const[r]=f(e);return r.some(t=>t.n!==void 0&&se.has(t.n)&&ie(e.slice(t.ss,t.se)))}catch{return ae.test(e)}},g={usesAi:{pattern:/\bfrom\s+["']@lunora\/ai["']/,source:"@lunora/ai"},usesAnalytics:{pattern:/\bfrom\s+["']@lunora\/bindings\/analytics["']/,source:"@lunora/bindings/analytics"},usesAuth:{pattern:/\bfrom\s+["']@lunora\/auth["']/,source:"@lunora/auth"},usesBrowser:{pattern:/\bfrom\s+["']@lunora\/browser["']/,source:"@lunora/browser"},usesHyperdrive:{pattern:/\bfrom\s+["']@lunora\/hyperdrive["']/,source:"@lunora/hyperdrive"},usesImages:{pattern:/\bfrom\s+["']@lunora\/bindings\/images["']/,source:"@lunora/bindings/images"},usesKv:{pattern:/\bfrom\s+["']@lunora\/bindings\/kv["']/,source:"@lunora/bindings/kv"},usesMail:{pattern:/\bfrom\s+["']@lunora\/mail["']/,source:"@lunora/mail"},usesPayment:{pattern:/\bfrom\s+["']@lunora\/payment["']/,source:"@lunora/payment"},usesPipelines:{pattern:A,source:"@lunora/bindings/pipelines"},usesScheduler:{pattern:/\bfrom\s+["']@lunora\/scheduler["']/,source:"@lunora/scheduler"},usesStorage:{pattern:/\bfrom\s+["']@lunora\/storage["']/,source:"@lunora/storage"},usesX402Charge:{pattern:/\bfrom\s+["']@lunora\/x402\/charge["']/,source:"@lunora/x402/charge"},usesX402Pay:{pattern:/\bfrom\s+["']@lunora\/x402\/pay["']/,source:"@lunora/x402/pay"}},p=Object.keys(g),ue="STRIPE_SECRET_KEY + STRIPE_WEBHOOK_SECRET (Stripe) or POLAR_ACCESS_TOKEN + POLAR_WEBHOOK_SECRET (Polar)",I=[...p,"needsD1"],de=()=>{const e={};for(const r of I)e[r]=!1;return e},l=Object.freeze(de()),y=(e,r)=>{const t={};for(const s of I)t[s]=e[s]||r[s];return t},le=e=>{for(const r of p)if(g[r].source===e)return{...l,[r]:!0};return l},pe=e=>{const[r]=f(e);let t=l;for(const s of r){const n=s.n;!n||_.test(e.slice(s.ss,s.se))||(t=y(t,le(n)))}return t},me=e=>{const r={...l};for(const t of p)r[t]=g[t].pattern.test(e);return r},be=e=>{let r;try{r=pe(e)}catch{r=me(e)}return y(r,{...l,needsD1:ee.test(e),usesAi:re.test(e),usesPipelines:A.test(e)})},S=(e,r)=>{let t;try{t=C(e,{withFileTypes:!0})}catch{return}for(const s of t){if(s.isDirectory()){z.has(s.name)||S(c(e,s.name),r);continue}const n=s.name.lastIndexOf(".");n!==-1&&Q.has(s.name.slice(n))&&r.push(c(e,s.name))}},fe=e=>{for(const r of P){const t=c(e,r);if(!d(t))continue;const{parsed:s}=L(t),n=s?.main;if(typeof n=="string"&&d(c(e,n)))return c(e,n);break}for(const r of V){const t=c(e,r);if(d(t))return t}},ge=e=>{const r=b(e,"utf8");let t;try{const[,s]=f(r);t=new Set(s.map(n=>n.n))}catch{t=new Set(O.filter(s=>new RegExp(String.raw`\bexport\b[^\n;]*\b${s}\b`).test(r)))}return O.filter(s=>t.has(s)&&!Z[s].test(r)).map(s=>({binding:$[s],className:s}))},j=e=>e.replaceAll(/[$()*+.?[\\\]^{|}]/gu,String.raw`\$&`),he=/(?:^|[\s,{])type$/u,ye=(e,r)=>{const t=r.ls>=0?r.ls:r.s;return he.test(e.slice(0,t).trimEnd())},Se=(e,r)=>{const t=j(r);return new RegExp(String.raw`\bexport\s+type\s+${t}\b`,"u").test(e)||new RegExp(String.raw`\bexport\s+type\s*\{[^}]*\b${t}\b`,"u").test(e)||new RegExp(String.raw`\bexport\s+\{[^}]*\btype\s+${t}\b`,"u").test(e)},w=(e,r,t)=>{if(r.length===0)return[];if(e===void 0)return r.map(o=>({...o,exported:!1}));const s=b(e,"utf8"),n=new RegExp(String.raw`\bexport\s*\*\s*from\s*["'][^"']*_generated\/${t}(?:\.js)?["']`).test(s);let a;try{const[,o]=f(s);a=new Set(o.filter(i=>!ye(s,i)).map(i=>i.n))}catch{a=new Set(r.map(o=>o.className).filter(o=>new RegExp(String.raw`\bexport\b[^\n;]*\b${j(o)}\b`,"u").test(s)&&!Se(s,o)))}return r.map(o=>{const i=n||a.has(o.className);return{...o,exported:i}})},we=(e,r)=>w(e,r,"containers"),xe=(e,r)=>w(e,r,"workflows"),ve=(e,r)=>w(e,r,"agents"),Ee=(e,r)=>G(e,r).info?.hasGlobalTable??!1,Ne=(e,r)=>{let t=l;for(const s of r){const n=c(e,s);if(!d(n)||!k(n).isDirectory())continue;const a=[];S(n,a);for(const o of a)t=y(t,be(b(o,"utf8")))}return t},Re=(e,r)=>{const t=c(e,r);if(!d(t)||!k(t).isDirectory())return!1;const s=[];return S(t,s),s.some(n=>ce(b(n,"utf8")))},Oe=(e,r,t)=>[...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"\``),...r.map(s=>s.exported?`${s.bindingName}/${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"\``),...t.map(s=>s.exported?`${s.bindingName}/${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"\``)],ke=(e,r)=>[[e.usesAi,"AI (@lunora/ai imported or env.AI used)"],[e.usesAuth&&!r.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&&!r.has("SchedulerDO"),"hint: @lunora/scheduler is imported but no SchedulerDO is exported by the worker entry"],[e.usesStorage,"hint: @lunora/storage is imported; add an r2_buckets binding (bucket binding names are user-defined)"],[e.usesMail,"hint: @lunora/mail is imported; set RESEND_API_KEY in .dev.vars (obtain at https://resend.com/api-keys)"],[e.usesPayment,`hint: @lunora/payment is imported; set the provider secrets in .dev.vars — ${ue}`],[e.usesBrowser,"browser (@lunora/browser imported) — self-describing { binding: BROWSER }"],[e.usesImages,"images (@lunora/bindings/images imported) — self-describing { binding: IMAGES }"],[e.usesAnalytics,"analytics_engine_datasets (@lunora/bindings/analytics imported) — self-describing { binding: ANALYTICS, dataset }"],[e.usesKv,"hint: @lunora/bindings/kv is imported; add a kv_namespaces binding ({ binding, id }) and pass env.<BINDING> to createKv() — the namespace id can't be auto-provisioned"],[e.usesHyperdrive,"hint: @lunora/hyperdrive is imported; run 'wrangler hyperdrive create' and add a 'hyperdrive' binding ({ binding, id }) — the id can't be auto-provisioned"],[e.usesPipelines,"hint: ctx.pipelines is used; run 'wrangler pipelines create <name>' and add a 'pipelines' binding ({ binding, pipeline }) — the pipeline resource can't be auto-provisioned"],[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.usesX402Pay,"hint: @lunora/x402/pay is imported (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(([t])=>t).map(([,t])=>t),De=(e,r,t,s=[],n=[],a=[])=>{const o=new Set(e.map(u=>u.className)),i=e.map(u=>`${u.binding}/${u.className} (exported by worker entry)`);return r&&i.push("DB (.global() table declared)"),i.push(...Oe(s,n,a),...ke(t,o)),i},Le=async e=>{await T;const r=e.schemaDir??"lunora",t=e.scanDirs??J,s=Ne(e.projectRoot,t),n={...s,usesBrowser:s.usesBrowser||Re(e.projectRoot,r)},a=fe(e.projectRoot),o=a?ge(a):[],i=n.needsD1||Ee(e.projectRoot,r),u=we(a,K(e.projectRoot,r).containers),x=xe(a,U(e.projectRoot,r).workflows),v=ve(a,B(e.projectRoot,r).agents),F=[...Y(e.projectRoot,r).queues],{flags:m}=X(e.projectRoot,r),h=m?.provider==="flagship"&&m.mode==="binding"?m.bindingName:void 0,E={};for(const R of p)E[R]=n[R];const N=De(o,i,n,u,x,v);return h!==void 0&&N.push(`hint: lunora/flags.ts uses Flagship in binding mode; add a flagship binding ({ binding: "${h}", app_id }) — the app_id can't be auto-provisioned`),{agents:v,containers:u,durableObjects:o,flagshipBinding:h,needsD1:i,queues:F,signals:N,usesFlags:m!==void 0,workflows:x,...E}},Ke=e=>{const r=[];for(const t of p)e[t]&&r.push(g[t].source);return r};export{V as WORKER_ENTRY_FALLBACKS,Le as inferLunoraBindings,ye as isTypeOnlyExportEntry,Ke as packageNamesFromBindings,fe as resolveWorkerEntry};
|
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.107",
|
|
4
4
|
"description": "Internal shared CLI + Vite config layer for Lunora: wrangler.jsonc validation, binding inference, and .dev.vars scaffolding",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bindings",
|
|
@@ -54,10 +54,10 @@
|
|
|
54
54
|
"access": "public"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@lunora/codegen": "1.0.0-alpha.
|
|
57
|
+
"@lunora/codegen": "1.0.0-alpha.82",
|
|
58
58
|
"@lunora/container": "1.0.0-alpha.18",
|
|
59
59
|
"@lunora/errors": "1.0.0-alpha.10",
|
|
60
|
-
"@lunora/seed": "1.0.0-alpha.
|
|
60
|
+
"@lunora/seed": "1.0.0-alpha.56",
|
|
61
61
|
"@visulima/colorize": "2.0.0",
|
|
62
62
|
"@visulima/find-ai-runner": "1.0.0",
|
|
63
63
|
"dockerode": "^5.0.1",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{existsSync as b}from"node:fs";import{dirname as _,join as h}from"node:path";import{discoverSchemaInfo as v}from"./discoverSchemaInfo-C8X9mo-i.mjs";import{isCacheEnabled as $,WORKERS_CACHE_MIN_DATE as m}from"./WORKERS_CACHE_MIN_DATE-B1h_wNDN.mjs";import{findWranglerFile as j,readWranglerJsonc as w}from"./WRANGLER_FILES-Bi_18Pj6.mjs";const g="2026-04-07",te="web_socket_auto_reply_to_close",p=/^\d{4}-\d{2}-\d{2}$/,A=(e,n,s)=>{if(n.length===0)return;const r=e.vectorize??[],t=new Set(r.filter(Boolean).map(a=>a?.index_name));for(const a of n)t.has(a)||s.push(`schema declares vector index "${a}"; wrangler "vectorize" must include a binding with index_name "${a}"`)},S=new Set(["basic","dev","lite","standard","standard-1","standard-2","standard-3","standard-4"]),k={disk_mb:2e4,memory_mib:12288,vcpu:4},M=(e,n,s)=>{const r=e.instance_type;if(r===void 0)return;if(typeof r=="string"){S.has(r)||s.push(`${n} has unknown instance_type "${r}" — expected lite, basic, standard-1..4, or a custom { vcpu, memory_mib, disk_mb } object`);return}for(const[o,c]of Object.entries(k)){const d=r[o];d!==void 0&&(typeof d!="number"||d<=0||d>c)&&s.push(`${n} custom instance_type ${o} must be a positive number ≤ ${String(c)} (got ${String(d)})`)}const{disk_mb:t,memory_mib:a,vcpu:i}=r;if(typeof i=="number"&&typeof a=="number"&&a<i*3072&&s.push(`${n} custom instance_type needs ≥ 3 GiB (3072 MiB) memory per vCPU (got ${String(a)} MiB for ${String(i)} vCPU)`),typeof a=="number"&&typeof t=="number"){const o=Math.floor(a/1024*2e3);t>o&&s.push(`${n} custom instance_type allows ≤ 2 GB disk per GiB memory (≤ ${String(o)} MB for ${String(a)} MiB memory; got ${String(t)} MB)`)}},q=(e,n,s)=>{const{boundClasses:r,errors:t,nonSqliteClasses:a,sqliteClasses:i,warnings:o}=s;if(!e||typeof e!="object"||typeof e.class_name!="string"||e.class_name.length===0){t.push(`${n} must have a non-empty "class_name" naming its container-enabled Durable Object class`);return}(typeof e.image!="string"||e.image.length===0)&&t.push(`${n} ("${e.class_name}") must have an "image" — a Dockerfile path or a registry reference`),r.has(e.class_name)||t.push(`${n} class "${e.class_name}" has no matching durable_objects binding — run \`lunora dev\` to auto-reconcile wrangler.jsonc, or add { "name": "...", "class_name": "${e.class_name}" }`),i.has(e.class_name)||t.push(a.has(e.class_name)?`${n} class "${e.class_name}" is registered via "new_classes" but containers require SQLite-backed DOs — move it to "new_sqlite_classes"`:`${n} class "${e.class_name}" is missing from migrations — add a migration entry with "new_sqlite_classes": ["${e.class_name}"]`),M(e,`${n} ("${e.class_name}")`,t),e.max_instances===void 0&&o.push(`${n} ("${e.class_name}") declares no max_instances — set a cap so a traffic spike can't fan out unbounded container spend`)},l=e=>Array.isArray(e)?e.filter(n=>n!==null&&typeof n=="object"):[],E=(e,n,s)=>{if(e.containers===void 0)return;if(!Array.isArray(e.containers)){n.push("containers must be an array of { class_name, image, ... } entries");return}const r=e.containers;if(r.length===0)return;const t=new Set(l(e.durable_objects?.bindings).map(c=>c.class_name)),a=e.migrations??[],i=new Set(a.flatMap(c=>[...c?.new_sqlite_classes??[]])),o=new Set(a.flatMap(c=>[...c?.new_classes??[]]));for(const[c,d]of r.entries())q(d,`containers[${String(c)}]`,{boundClasses:t,errors:n,nonSqliteClasses:o,sqliteClasses:i,warnings:s});e.observability?.enabled!==!0&&s.push('containers are configured but observability is not enabled — container logs will not be captured (add { "observability": { "enabled": true } })')},R=(e,n)=>{if(e.workflows===void 0)return;if(!Array.isArray(e.workflows)){n.push("workflows must be an array of { name, binding, class_name } entries");return}const s=e.workflows;for(const[r,t]of s.entries()){const a=`workflows[${String(r)}]`;if(!t||typeof t!="object"){n.push(`${a} must be a { name, binding, class_name } object`);continue}(typeof t.binding!="string"||t.binding.length===0)&&n.push(`${a} must have a non-empty "binding" naming the Workflow binding (e.g. WORKFLOW_ORDER_PIPELINE)`),(typeof t.class_name!="string"||t.class_name.length===0)&&n.push(`${a} must have a non-empty "class_name" naming the exported WorkflowEntrypoint class`),(typeof t.name!="string"||t.name.length===0)&&n.push(`${a} must have a non-empty "name" naming the deployed workflow`)}},O=(e,n)=>{if(e===void 0)return;if(!Array.isArray(e)){n.push("queues.producers must be an array of { binding, queue } entries");return}const s=e;for(const[r,t]of s.entries()){const a=`queues.producers[${String(r)}]`;if(!t||typeof t!="object"){n.push(`${a} must be a { binding, queue } object`);continue}(typeof t.binding!="string"||t.binding.length===0)&&n.push(`${a} must have a non-empty "binding" naming the Queue producer (e.g. QUEUE_EMAIL)`),(typeof t.queue!="string"||t.queue.length===0)&&n.push(`${a} must have a non-empty "queue" naming the deployed queue`)}},D=(e,n)=>{if(e===void 0)return;if(!Array.isArray(e)){n.push("queues.consumers must be an array of { queue } entries");return}const s=e;for(const[r,t]of s.entries()){const a=`queues.consumers[${String(r)}]`;if(!t||typeof t!="object"){n.push(`${a} must be a { queue } object`);continue}(typeof t.queue!="string"||t.queue.length===0)&&n.push(`${a} must have a non-empty "queue" naming the consumed queue`)}},L=(e,n)=>{if(e.queues!==void 0){if(typeof e.queues!="object"||Array.isArray(e.queues)){n.push("queues must be a { producers, consumers } object");return}O(e.queues.producers,n),D(e.queues.consumers,n)}},W=(e,n)=>{if(e.secrets_store_secrets===void 0)return;if(!Array.isArray(e.secrets_store_secrets)){n.push("secrets_store_secrets must be an array of { binding, store_id, secret_name } entries");return}const s=e.secrets_store_secrets;for(const[r,t]of s.entries()){const a=`secrets_store_secrets[${String(r)}]`;if(!t||typeof t!="object"){n.push(`${a} must be a { binding, store_id, secret_name } object`);continue}for(const i of["binding","store_id","secret_name"])(typeof t[i]!="string"||t[i].length===0)&&n.push(`${a} must have a non-empty "${i}"`)}},u=e=>typeof e=="string"&&e.length>0,f=e=>e,C=[{arrayMessage:"kv_namespaces must be an array of { binding, id } entries",bindingMessage:e=>`${e} must have a non-empty "binding" naming the KV namespace binding`,hintField:"id",hintMessage:(e,n)=>`${e} ("${n}") has no "id" — run \`wrangler kv namespace create\` and set the namespace id, or the binding can't resolve`,key:"kv_namespaces"},{arrayMessage:"flagship must be an array of { binding, app_id } entries",bindingMessage:e=>`${e} must have a non-empty "binding" naming the Flagship binding`,hintField:"app_id",hintMessage:(e,n)=>`${e} ("${n}") 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,n)=>`${e} ("${n}") 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,n)=>`${e} ("${n}") 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,n)=>`${e} ("${n}") has no "dataset" — it defaults to the binding name; set it explicitly to avoid drift`,key:"analytics_engine_datasets"}],x=(e,n,s,r)=>{const t=e[n.key];if(t!==void 0){if(!Array.isArray(t)){s.push(n.arrayMessage);return}for(const[a,i]of f(t).entries()){const o=`${n.key}[${String(a)}]`;if(!i||typeof i!="object"||!u(i.binding)){s.push(n.bindingMessage(o));continue}(typeof n.hintField=="string"?[n.hintField]:n.hintField).some(c=>u(i[c]))||r.push(n.hintMessage(o,i.binding))}}},I=[{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" })'}],N=(e,n,s)=>{const r=e[n.key];r!==void 0&&(typeof r!="object"||Array.isArray(r)||!u(r.binding))&&s.push(n.message)},B=[{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`}],F=(e,n,s)=>{const r=e[n.key];if(r!==void 0){if(!Array.isArray(r)){s.push(n.arrayMessage);return}for(const[t,a]of f(r).entries()){const i=`${n.key}[${String(t)}]`;if(!a||typeof a!="object"){s.push(n.objectMessage(i));continue}for(const o of n.fields)u(a[o.field])||s.push(o.message(i))}}},P=(e,n,s)=>{const r=e.send_email;if(r===void 0)return;if(!Array.isArray(r)){n.push("send_email must be an array of { name, destination_address? } entries");return}const t=r;for(const[a,i]of t.entries())(!i||typeof i!="object"||typeof i.name!="string"||i.name.length===0)&&s.push(`send_email[${String(a)}] has no non-empty "name" naming the send-email binding — set one before deploying`)},T=(e,n)=>{e.logpush!==void 0&&typeof e.logpush!="boolean"&&n.push('logpush must be a boolean (set "logpush": true to enable Cloudflare Logpush)')},U=(e,n)=>{const{placement:s}=e;if(s!==void 0){if(typeof s!="object"||Array.isArray(s)){n.push('placement must be an object (e.g. { "mode": "smart" })');return}s.mode!==void 0&&s.mode!=="smart"&&n.push('placement.mode must be "smart" (the only supported Smart Placement mode)')}},G=(e,n)=>{const{observability:s}=e;if(s===void 0)return;if(typeof s!="object"||Array.isArray(s)){n.push('observability must be an object (e.g. { "enabled": true, "head_sampling_rate": 1 })');return}const r=(t,a)=>{t!==void 0&&(typeof t!="number"||Number.isNaN(t)||t<0||t>1)&&n.push(`${a} must be a number in [0, 1] (the fraction of requests sampled)`)};r(s.head_sampling_rate,"observability.head_sampling_rate"),s.logs!==void 0&&(typeof s.logs!="object"||Array.isArray(s.logs)?n.push("observability.logs must be an object"):r(s.logs.head_sampling_rate,"observability.logs.head_sampling_rate"))},H=(e,n)=>{const{cache:s}=e;if(s!==void 0){if(typeof s!="object"||s===null||Array.isArray(s)){n.push('cache must be an object (e.g. { "enabled": true })');return}s.enabled!==void 0&&typeof s.enabled!="boolean"&&n.push("cache.enabled must be a boolean (true or false)")}},Q=(e,n)=>{const{exports:s}=e;if(s!==void 0){if(typeof s!="object"||s===null||Array.isArray(s)){n.push("exports must be an object keyed by entrypoint name");return}for(const[r,t]of Object.entries(s)){if(typeof t!="object"||t===null){n.push(`exports["${r}"] must be an object`);continue}t.type!==void 0&&typeof t.type!="string"&&n.push(`exports["${r}"].type must be a string`),t.cache!==void 0&&(typeof t.cache!="object"||t.cache===null||Array.isArray(t.cache)?n.push(`exports["${r}"].cache must be an object`):t.cache.enabled!==void 0&&typeof t.cache.enabled!="boolean"&&n.push(`exports["${r}"].cache.enabled must be a boolean`))}}},Y=(e,n)=>{const{assets:s}=e;if(s!==void 0){if(typeof s!="object"||Array.isArray(s)){n.push('assets must be an object (e.g. { "directory": "./dist/client", "binding": "ASSETS" })');return}(typeof s.directory!="string"||s.directory.length===0)&&n.push('assets must declare a non-empty "directory" pointing at the built client output (e.g. "./dist/client")'),s.binding!==void 0&&(typeof s.binding!="string"||s.binding.length===0)&&n.push('assets.binding must be a non-empty string (e.g. "ASSETS")'),s.html_handling!==void 0&&typeof s.html_handling!="string"&&n.push("assets.html_handling must be a string"),s.not_found_handling!==void 0&&typeof s.not_found_handling!="string"&&n.push("assets.not_found_handling must be a string")}},K=(e,n)=>{const s=e.tail_consumers;if(s===void 0)return;if(!Array.isArray(s)){n.push("tail_consumers must be an array of { service, environment? } entries");return}const r=s;for(const[t,a]of r.entries())(!a||typeof a!="object"||typeof a.service!="string"||a.service.length===0)&&n.push(`tail_consumers[${String(t)}] must have a non-empty "service" naming the consumer Worker`)},ae=(e,n)=>{const s=e.tail_consumers??[];return s.some(r=>!!r&&r?.service===n.service&&r?.environment===n.environment)?e:{...e,tail_consumers:[...s,n]}},z=new Set(["1","enabled","on","true","yes"]),J=(e,n)=>{const{vars:s}=e;if(!s||typeof s!="object")return;const r=s.LUNORA_ALLOWED_ORIGINS,t=s.LUNORA_CORS_ALLOW_CREDENTIALS,a=typeof r=="string"&&r.split(",").some(o=>o.trim()==="*"),i=typeof t=="string"&&z.has(t.trim().toLowerCase());a&&i&&n.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')},y=(e,n)=>{const s=[],r=[];if(!e||typeof e!="object")return s.push("wrangler config is not a valid object"),{errors:s,valid:!1,warnings:r};l(e.durable_objects?.bindings).find(a=>a.name==="SHARD"&&a.class_name==="ShardDO")||s.push('durable_objects.bindings must include { "name": "SHARD", "class_name": "ShardDO" } — run `lunora dev` to auto-reconcile wrangler.jsonc, or add the binding manually');const t=e.compatibility_date??"";t&&!p.test(t)?s.push(`compatibility_date must be in YYYY-MM-DD format (got "${t}")`):t<g&&s.push(`compatibility_date must be >= "${g}" (got "${t||"<missing>"}")`),$(e)&&p.test(t)&&t<m&&s.push(`cache.enabled requires compatibility_date >= "${m}" (got "${t||"<missing>"}")`),n?.hasGlobalTable&&(l(e.d1_databases).find(a=>a.binding==="DB")||s.push('schema declares .global() tables; d1_databases must include a binding named "DB" — run `lunora dev` to auto-reconcile wrangler.jsonc, or add the binding manually')),A(e,n?.vectorIndexNames??[],s),K(e,s),E(e,s,r),R(e,s),L(e,s),W(e,s);for(const a of C)x(e,a,s,r);for(const a of B)F(e,a,s);for(const a of I)N(e,a,s);return P(e,s,r),T(e,s),U(e,s),G(e,s),Y(e,s),H(e,s),Q(e,s),J(e,s),{errors:s,valid:s.length===0,warnings:r}},re=y,V=(e,n,s)=>{const r=[];for(const t of e){const a=t?.image;typeof a!="string"||!(a.startsWith("./")||a.startsWith("../")||a.startsWith("/")||a.includes("Dockerfile"))||b(a.startsWith("/")?a:h(n,a))||r.push(`containers image "${a}" does not exist (resolved relative to ${s}); create the Dockerfile or point image at a registry reference`)}return r},ie=e=>{const n=e.schemaDir??"lunora",s=j(e.projectRoot);if(!s){const d=`wrangler.jsonc not found in ${e.projectRoot}; create one declaring at least the SHARD durable object binding.`;return{problems:[d],report:{errors:[d],valid:!1,warnings:[]},wranglerPath:void 0}}const{parsed:r}=w(s);if(r===void 0){const d=`failed to parse ${s} as JSONC.`;return{problems:[d],report:{errors:[d],valid:!1,warnings:[]},wranglerPath:s}}const{error:t,info:a}=v(e.projectRoot,n),i=y(r,a);t!==void 0&&i.warnings.push(`schema parse failed in ${n}/schema.ts: ${t}`);const o=_(s);i.errors.push(...V(r.containers??[],o,s));const c=r.assets?.directory;if(typeof c=="string"&&c.length>0){const d=c.startsWith("/")?c:h(o,c);b(d)||i.warnings.push(`assets.directory "${c}" does not exist yet — it is created by the client build; run the build before deploy`)}return i.valid=i.errors.length===0,{problems:i.errors,report:i,wranglerPath:s}};export{g as REQUIRED_COMPATIBILITY_DATE,te as REQUIRED_FLAG,re as validateWrangler,y as validateWranglerConfig,ie as validateWranglerProject,ae as withTailConsumer};
|