@lunora/config 1.0.0-alpha.121 → 1.0.0-alpha.122
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cloudflare/index.mjs +1 -1
- package/dist/index.d.mts +7 -12
- package/dist/index.d.ts +7 -12
- package/dist/index.mjs +1 -1
- package/dist/packem_shared/BINDING_MANIFEST_VERSION-DOlqQgYt.mjs +1 -0
- package/dist/packem_shared/{CLOUDFLARE_DRIVER-4eMO4O3x.mjs → CLOUDFLARE_DRIVER-CpWo25m7.mjs} +1 -1
- package/dist/packem_shared/{DEFAULT_DEPLOY_TARGET-DftkW2Zb.mjs → DEFAULT_DEPLOY_TARGET-CHuOXUoQ.mjs} +1 -1
- package/dist/packem_shared/{LUNORA_CONFIG_FILE-BrZLPIqF.mjs → LUNORA_CONFIG_FILE-DGWB86AX.mjs} +1 -1
- package/dist/packem_shared/REQUIRED_COMPATIBILITY_DATE-BN97lRmC.mjs +1 -0
- package/dist/packem_shared/buildPackageSecretsBlock-D2oDEMcf.mjs +18 -0
- package/dist/packem_shared/collectExportGaps-ajyIOfom.mjs +1 -0
- package/dist/packem_shared/{collectWranglerSecretVariables-jPUxMC9j.mjs → collectWranglerSecretVariables-DZE0RIsW.mjs} +1 -1
- package/dist/packem_shared/createConfirm-C5G4-dT6.mjs +7 -0
- package/dist/packem_shared/discover-info-DRQ0Ote0.mjs +1 -0
- package/dist/packem_shared/discoverAgentInfo-C8LTinx8.mjs +1 -0
- package/dist/packem_shared/discoverContainerInfo-C1zY2O8F.mjs +1 -0
- package/dist/packem_shared/discoverWorkflowInfo-DHzCyLRj.mjs +1 -0
- package/dist/packem_shared/inferLunoraBindings-_ESCdL9P.mjs +1 -0
- package/dist/packem_shared/wranglerToAlchemy-BXagFk92.mjs +6 -0
- package/package.json +5 -5
- package/dist/packem_shared/BINDING_MANIFEST_VERSION-BNab7wQ-.mjs +0 -1
- package/dist/packem_shared/REQUIRED_COMPATIBILITY_DATE-BwmyesjD.mjs +0 -1
- package/dist/packem_shared/buildPackageSecretsBlock-DlAPMSwt.mjs +0 -18
- package/dist/packem_shared/collectExportGaps-B7gjEClt.mjs +0 -1
- package/dist/packem_shared/createConfirm-7IL0kZyE.mjs +0 -7
- package/dist/packem_shared/discoverAgentInfo-BJm0QtoI.mjs +0 -1
- package/dist/packem_shared/discoverContainerInfo-CYG9j2LY.mjs +0 -1
- package/dist/packem_shared/discoverWorkflowInfo-Bbc0u2gE.mjs +0 -1
- package/dist/packem_shared/inferLunoraBindings-tf2nExl_.mjs +0 -1
- package/dist/packem_shared/wranglerToAlchemy-Fh5KfTPB.mjs +0 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
import{BINDING_MANIFEST_VERSION as o,buildBindingManifest as a}from"../packem_shared/BINDING_MANIFEST_VERSION-
|
|
1
|
+
import{BINDING_MANIFEST_VERSION as o,buildBindingManifest as a}from"../packem_shared/BINDING_MANIFEST_VERSION-DOlqQgYt.mjs";import{default as n}from"../packem_shared/CLOUDFLARE_DRIVER-CpWo25m7.mjs";import{collectExportGaps as i,reconcileWranglerBindings as E}from"../packem_shared/collectExportGaps-ajyIOfom.mjs";import{reconcileWranglerCompatibilityDate as c}from"../packem_shared/reconcileWranglerCompatibilityDate-BXNiEQ7p.mjs";import{reconcileWranglerCrons as R}from"../packem_shared/reconcileWranglerCrons-BmQa_kGL.mjs";import{REMOTE_ELIGIBLE_KEYS as s,injectRemoteFlags as p,isRemoteEnvEnabled as I,materializeRemoteWranglerConfig as d,planRemoteBindings as W,resolveRemoteEnabled as x}from"../packem_shared/REMOTE_ELIGIBLE_KEYS-ws6iE0y-.mjs";import{WORKERS_CACHE_MIN_DATE as C,isCacheEnabled as A}from"../packem_shared/WORKERS_CACHE_MIN_DATE-B1h_wNDN.mjs";import{WRANGLER_FILES as L,findWranglerFile as T,readWranglerJsonc as b}from"../packem_shared/WRANGLER_FILES-Bi_18Pj6.mjs";import{collectWranglerSecretVariables as S,scanWranglerVariablesForSecrets as B}from"../packem_shared/collectWranglerSecretVariables-DZE0RIsW.mjs";import{wranglerToAlchemy as v}from"../packem_shared/wranglerToAlchemy-BXagFk92.mjs";import{REQUIRED_COMPATIBILITY_DATE as M,REQUIRED_FLAG as O,validateWrangler as V,validateWranglerConfig as h,validateWranglerProject as u,withTailConsumer as U}from"../packem_shared/REQUIRED_COMPATIBILITY_DATE-BN97lRmC.mjs";export{o as BINDING_MANIFEST_VERSION,n as CLOUDFLARE_DRIVER,s as REMOTE_ELIGIBLE_KEYS,M as REQUIRED_COMPATIBILITY_DATE,O as REQUIRED_FLAG,C as WORKERS_CACHE_MIN_DATE,L as WRANGLER_FILES,a as buildBindingManifest,i as collectExportGaps,S as collectWranglerSecretVariables,T as findWranglerFile,p as injectRemoteFlags,A as isCacheEnabled,I as isRemoteEnvEnabled,d as materializeRemoteWranglerConfig,W as planRemoteBindings,b as readWranglerJsonc,E as reconcileWranglerBindings,c as reconcileWranglerCompatibilityDate,R as reconcileWranglerCrons,x as resolveRemoteEnabled,B as scanWranglerVariablesForSecrets,V as validateWrangler,h as validateWranglerConfig,u as validateWranglerProject,U as withTailConsumer,v as wranglerToAlchemy};
|
package/dist/index.d.mts
CHANGED
|
@@ -785,18 +785,13 @@ interface EnsureDevVariablesResult {
|
|
|
785
785
|
status: EnsureDevVariablesStatus;
|
|
786
786
|
}
|
|
787
787
|
/**
|
|
788
|
-
* Atomically (over)write a `.dev.vars`-shaped file
|
|
789
|
-
*
|
|
790
|
-
*
|
|
791
|
-
*
|
|
792
|
-
*
|
|
793
|
-
*
|
|
794
|
-
*
|
|
795
|
-
* anywhere else (Cloudflare secrets are write-only). On any failure the temp
|
|
796
|
-
* file is removed before the error propagates; never logs or throws the
|
|
797
|
-
* content. Exported so a caller writing to a `.dev.vars`-shaped path outside
|
|
798
|
-
* this module (`lunora deploy`'s minted-secret disclosure) reuses this
|
|
799
|
-
* instead of hand-rolling another copy of the pattern below.
|
|
788
|
+
* Atomically (over)write a `.dev.vars`-shaped file, owner-only. For a file
|
|
789
|
+
* holding secrets a torn write would destroy every other local value alongside
|
|
790
|
+
* the new one, and the new value itself has no other recoverable copy if it
|
|
791
|
+
* was never disclosed anywhere else (Cloudflare secrets are write-only).
|
|
792
|
+
* Exported so a caller writing to a `.dev.vars`-shaped path outside this
|
|
793
|
+
* module (`lunora deploy`'s minted-secret disclosure) reuses this instead of
|
|
794
|
+
* hand-rolling another copy of the pattern.
|
|
800
795
|
*/
|
|
801
796
|
declare const writeDevVariablesFileAtomically: (path: string, content: string) => void;
|
|
802
797
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -785,18 +785,13 @@ interface EnsureDevVariablesResult {
|
|
|
785
785
|
status: EnsureDevVariablesStatus;
|
|
786
786
|
}
|
|
787
787
|
/**
|
|
788
|
-
* Atomically (over)write a `.dev.vars`-shaped file
|
|
789
|
-
*
|
|
790
|
-
*
|
|
791
|
-
*
|
|
792
|
-
*
|
|
793
|
-
*
|
|
794
|
-
*
|
|
795
|
-
* anywhere else (Cloudflare secrets are write-only). On any failure the temp
|
|
796
|
-
* file is removed before the error propagates; never logs or throws the
|
|
797
|
-
* content. Exported so a caller writing to a `.dev.vars`-shaped path outside
|
|
798
|
-
* this module (`lunora deploy`'s minted-secret disclosure) reuses this
|
|
799
|
-
* instead of hand-rolling another copy of the pattern below.
|
|
788
|
+
* Atomically (over)write a `.dev.vars`-shaped file, owner-only. For a file
|
|
789
|
+
* holding secrets a torn write would destroy every other local value alongside
|
|
790
|
+
* the new one, and the new value itself has no other recoverable copy if it
|
|
791
|
+
* was never disclosed anywhere else (Cloudflare secrets are write-only).
|
|
792
|
+
* Exported so a caller writing to a `.dev.vars`-shaped path outside this
|
|
793
|
+
* module (`lunora deploy`'s minted-secret disclosure) reuses this instead of
|
|
794
|
+
* hand-rolling another copy of the pattern.
|
|
800
795
|
*/
|
|
801
796
|
declare const writeDevVariablesFileAtomically: (path: string, content: string) => void;
|
|
802
797
|
/**
|
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-
|
|
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-C8LTinx8.mjs";import{AGENT_RULES_DIR as _,AGENT_RULES_HINT as p,AGENT_RULES_HINT_ENV as s,LUNORA_SKILL_NAMES as l,ROOT_SKILL_NAME as c,claimAgentRulesHint as n,detectAgentRules as A}from"./packem_shared/AGENT_RULES_DIR-hP9TiDNx.mjs";import{discoverContainerInfo as d}from"./packem_shared/discoverContainerInfo-C1zY2O8F.mjs";import{streamContainerLogs as D}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 O,isProcessAlive as F,isRecordedProcessCurrent as u,readDevServerState as G,readLiveDevServerState as U,updateDevServerState as C,writeDevServerState as y}from"./packem_shared/DEV_DAEMON_ENV-D9Z83rlU.mjs";import{DEV_VARS_EXAMPLE_FILE as M,DEV_VARS_FILE as B,DEV_VARS_KEY_PATTERN as k,escapeRegExp as w,parseDevVariableEntries as K,upsertDevVariableLine as j}from"./packem_shared/DEV_VARS_EXAMPLE_FILE-BL0hrPx3.mjs";import{DEFAULT_DEPLOY_TARGET as h,deployTargetIds as Y,resolveDeployDriver as W}from"./packem_shared/DEFAULT_DEPLOY_TARGET-CHuOXUoQ.mjs";import{inferLunoraBindings as q,packageNamesFromBindings as X}from"./packem_shared/inferLunoraBindings-_ESCdL9P.mjs";import{LINKED_PROJECT_DIR as Q,LINKED_PROJECT_FILE as Z,readLinkedProject as $,writeLinkedProject as ee}from"./packem_shared/LINKED_PROJECT_DIR-CMzUvj-1.mjs";import{LUNORA_IGNORED_PATHS as te,applyLintIgnores as oe,detectLintTools as ae}from"./packem_shared/LUNORA_IGNORED_PATHS-DIdyP0js.mjs";import{LUNORA_EVENT_SOURCE as ie,formatLunoraEvent as _e}from"./packem_shared/LUNORA_EVENT_SOURCE-ZclWASXS.mjs";import{default as se}from"./packem_shared/LunoraReporter-BnXUqh8t.mjs";import{PACKAGE_SECRETS_REGISTRY as ce,secretsForPackages as ne}from"./packem_shared/PACKAGE_SECRETS_REGISTRY-BgmvEPA-.mjs";import{LUNORA_CONFIG_FILE as me,interpretRemote as de,readProjectRemotePreference as Se,readProjectTarget as De,resolveProjectTarget as fe,resolveTargetOrThrow as Le}from"./packem_shared/LUNORA_CONFIG_FILE-DGWB86AX.mjs";import{createConfirm as ve,isInteractive as Te,promptMultiSelect as Re,promptSelect as Ie,promptText as xe,promptYesNo as Ve}from"./packem_shared/createConfirm-C5G4-dT6.mjs";import{buildPackageSecretsBlock as ge,ensureDevVariables as Oe,ensureDevVarsExample as Fe,fillDevSecrets as ue,generateSecretValue as Ge,isMintableSecretKey as Ue,isPlaceholderValue as Ce,planDevSecretsFill as ye,planDevVariablesAugment as be,planDevVariablesScaffold as Me,requiredSecrets as Be,writeDevVariablesFileAtomically as ke}from"./packem_shared/buildPackageSecretsBlock-D2oDEMcf.mjs";import{applyAdditiveEdit as Ke,classifyEdit as je}from"./packem_shared/applyAdditiveEdit-Cff30cSa.mjs";import{parseSchema as he}from"./packem_shared/parseSchema-BQjgz6bk.mjs";import{classifyPolicyEdit as We,scaffoldPolicyFile as Je,wireRlsIntoProcedure as qe}from"./packem_shared/classifyPolicyEdit-BzC_MfYK.mjs";import{discoverSchemaInfo as ze}from"./packem_shared/discoverSchemaInfo-C8X9mo-i.mjs";import{ACCENT as Ze,BADGES as $e,BADGE_COLUMN_WIDTH as er,LUNA_ART as rr,LUNA_BUNNY as tr,LUNA_NAME as or,LUNA_SIGNOFF as ar,STEP_BADGE_NAMES as Er,badgeLead as ir,badgeWidth as _r,padBadge as pr,paintAnswer as sr,paintBadge as lr}from"./packem_shared/ACCENT-CLeV5v0K.mjs";import{discoverWorkflowInfo as nr}from"./packem_shared/discoverWorkflowInfo-DHzCyLRj.mjs";export{Ze as ACCENT,t as AGENT_MODE_ENV,_ as AGENT_RULES_DIR,p as AGENT_RULES_HINT,s as AGENT_RULES_HINT_ENV,$e as BADGES,er as BADGE_COLUMN_WIDTH,h 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,M as DEV_VARS_EXAMPLE_FILE,B as DEV_VARS_FILE,k as DEV_VARS_KEY_PATTERN,Q as LINKED_PROJECT_DIR,Z as LINKED_PROJECT_FILE,rr as LUNA_ART,tr as LUNA_BUNNY,or as LUNA_NAME,ar as LUNA_SIGNOFF,me as LUNORA_CONFIG_FILE,ie as LUNORA_EVENT_SOURCE,te as LUNORA_IGNORED_PATHS,l as LUNORA_SKILL_NAMES,se as LunoraReporter,ce as PACKAGE_SECRETS_REGISTRY,c as ROOT_SKILL_NAME,Er as STEP_BADGE_NAMES,Ke as applyAdditiveEdit,oe as applyLintIgnores,ir as badgeLead,_r as badgeWidth,ge as buildPackageSecretsBlock,n as claimAgentRulesHint,g as claimDevServerState,je as classifyEdit,We as classifyPolicyEdit,O as clearDevServerState,ve as createConfirm,Y as deployTargetIds,A as detectAgentRules,o as detectAiAgent,L as detectFramework,ae as detectLintTools,E as discoverAgentInfo,d as discoverContainerInfo,ze as discoverSchemaInfo,nr as discoverWorkflowInfo,Oe as ensureDevVariables,Fe as ensureDevVarsExample,w as escapeRegExp,ue as fillDevSecrets,_e as formatLunoraEvent,Ge as generateSecretValue,q as inferLunoraBindings,de as interpretRemote,Te as isInteractive,Ue as isMintableSecretKey,Ce as isPlaceholderValue,F as isProcessAlive,u as isRecordedProcessCurrent,X as packageNamesFromBindings,pr as padBadge,sr as paintAnswer,lr as paintBadge,K as parseDevVariableEntries,he as parseSchema,ye as planDevSecretsFill,be as planDevVariablesAugment,Me as planDevVariablesScaffold,Re as promptMultiSelect,Ie as promptSelect,xe as promptText,Ve as promptYesNo,G as readDevServerState,$ as readLinkedProject,U as readLiveDevServerState,N as readProjectDependencyNames,Se as readProjectRemotePreference,De as readProjectTarget,Be as requiredSecrets,W as resolveDeployDriver,fe as resolveProjectTarget,Le as resolveTargetOrThrow,Je as scaffoldPolicyFile,ne as secretsForPackages,D as streamContainerLogs,C as updateDevServerState,j as upsertDevVariableLine,qe as wireRlsIntoProcedure,y as writeDevServerState,ke as writeDevVariablesFileAtomically,ee as writeLinkedProject};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{sqliteClasses as c}from"./wranglerToAlchemy-BXagFk92.mjs";const u=1,l=new Set(["$schema","account_id","compatibility_date","compatibility_flags","keep_vars","main","migrations","minify","name","observability","placement","routes","rules","triggers","upload_source_maps","vars","workers_dev"]),p=e=>Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0)),a=[{bindingKey:"binding",field:"analytics_engine_datasets",resourceKey:"dataset",type:"analytics_engine"},{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:"pipeline",type:"pipeline"},{bindingKey:"binding",field:"r2_buckets",resourceKey:"bucket_name",type:"r2"},{bindingKey:"binding",field:"vectorize",resourceKey:"index_name",type:"vectorize"},{bindingKey:"binding",field:"workflows",resourceKey:"name",type:"workflow"}],d=[{field:"ai",type:"ai"},{field:"assets",type:"assets"},{field:"browser",type:"browser"},{field:"images",type:"images"}],b=new Set([...a.map(e=>e.field),...d.map(e=>e.field),"durable_objects","queues"]),r=(e,t)=>{const s=t===void 0?void 0:e[t];return typeof s=="string"&&s!==""?s:void 0},y=(e,t)=>{const s=[];for(const n of a)for(const i of e[n.field]??[]){const o=r(i,n.bindingKey);if(o===void 0){t.push(n.field);continue}s.push({binding:o,className:r(i,"class_name"),resource:r(i,n.resourceKey),resourceId:r(i,n.resourceIdKey),type:n.type})}return s},m=(e,t)=>{const s=c(e),n=[];for(const i of e.durable_objects?.bindings??[]){if(i.name===void 0||i.name===""){t.push("durable_objects");continue}n.push({binding:i.name,className:i.class_name,sqlite:i.script_name===void 0&&i.class_name!==void 0?s.has(i.class_name):void 0,type:"durable_object"})}return n},g=(e,t)=>{const s=[];for(const n of e.queues?.producers??[]){if(n.binding===void 0||n.binding===""){t.push("queues.producers");continue}s.push({binding:n.binding,resource:n.queue,type:"queue_producer"})}for(const n of e.queues?.consumers??[]){if(n.queue===void 0||n.queue===""){t.push("queues.consumers");continue}s.push({binding:n.queue,resource:n.queue,type:"queue_consumer"})}return s},f=(e,t)=>[...y(e,t),...m(e,t),...g(e,t),...d.filter(s=>e[s.field]?.binding!==void 0).map(s=>({binding:e[s.field]?.binding,type:s.type}))],v=e=>{const t=[],s=f(e,t).map(i=>p(i)).toSorted((i,o)=>i.type.localeCompare(o.type)||i.binding.localeCompare(o.binding)),n=[...Object.keys(e).filter(i=>!l.has(i)&&!b.has(i)),...t.map(i=>`${i} (entry with no binding name)`)].toSorted((i,o)=>i.localeCompare(o));return{bindings:s,...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:n,vars:Object.keys(e.vars??{}).toSorted((i,o)=>i.localeCompare(o)),version:u}};export{u as BINDING_MANIFEST_VERSION,v as buildBindingManifest};
|
package/dist/packem_shared/{CLOUDFLARE_DRIVER-4eMO4O3x.mjs → CLOUDFLARE_DRIVER-CpWo25m7.mjs}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{inferLunoraBindings as c}from"./inferLunoraBindings-
|
|
1
|
+
import{inferLunoraBindings as c}from"./inferLunoraBindings-_ESCdL9P.mjs";import{reconcileWranglerBindings as p}from"./collectExportGaps-ajyIOfom.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-DftkW2Zb.mjs → DEFAULT_DEPLOY_TARGET-CHuOXUoQ.mjs}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import t from"./CLOUDFLARE_DRIVER-
|
|
1
|
+
import t from"./CLOUDFLARE_DRIVER-CpWo25m7.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-BrZLPIqF.mjs → LUNORA_CONFIG_FILE-DGWB86AX.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-CHuOXUoQ.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 g,readFileSync as M}from"node:fs";import{dirname as j,join as b}from"node:path";import{WORKER_ENTRY_FALLBACKS as x}from"./inferLunoraBindings-_ESCdL9P.mjs";import{discoverSchemaInfo as E}from"./discoverSchemaInfo-C8X9mo-i.mjs";import{isCacheEnabled as O,WORKERS_CACHE_MIN_DATE as h}from"./WORKERS_CACHE_MIN_DATE-B1h_wNDN.mjs";import{findWranglerFile as R,readWranglerJsonc as q}from"./WRANGLER_FILES-Bi_18Pj6.mjs";const y="2026-04-07",Ee="web_socket_auto_reply_to_close",v=/^\d{4}-\d{2}-\d{2}$/,_=["d1_databases","durable_objects","kv_namespaces","queues","r2_buckets","secrets_store_secrets","services","tail_consumers","vars","vectorize","workflows"],$=["assets","compatibility_date","exports","logpush","main","migrations","observability","placement"],A=(e,s)=>{if(s===void 0)return{merged:e,unverifiedKeys:[]};const t=e.env?.[s];if(t===void 0){const c=Object.keys(e.env??{}).toSorted((d,l)=>d.localeCompare(l)),o=c.length>0?` (declared: ${c.join(", ")}).`:" (no environments are declared).";return{error:`--env "${s}" names no environment declared in wrangler.jsonc's "env" block${o}`,merged:e,unverifiedKeys:[]}}const n={...e},a=Object.keys(t).filter(c=>c!=="env");for(const c of a)$.includes(c)&&(n[c]=t[c]);for(const c of _)n[c]=t[c];const r=new Set([..._,...$]),i=a.filter(c=>!r.has(c)).map(String);return{merged:n,unverifiedKeys:i}},D=(e,s,t)=>{if(s.length===0)return;const n=e.vectorize??[],a=new Set(n.filter(Boolean).map(r=>r?.index_name));for(const r of s)a.has(r)||t.push(`schema declares vector index "${r}"; wrangler "vectorize" must include a binding with index_name "${r}"`)},L=new Set(["basic","dev","lite","standard","standard-1","standard-2","standard-3","standard-4"]),W={disk_mb:2e4,memory_mib:12288,vcpu:4},C=(e,s,t)=>{const n=e.instance_type;if(n===void 0)return;if(typeof n=="string"){L.has(n)||t.push(`${s} has unknown instance_type "${n}" — expected lite, basic, standard-1..4, or a custom { vcpu, memory_mib, disk_mb } object`);return}for(const[c,o]of Object.entries(W)){const d=n[c];d!==void 0&&(typeof d!="number"||d<=0||d>o)&&t.push(`${s} custom instance_type ${c} must be a positive number ≤ ${String(o)} (got ${String(d)})`)}const{disk_mb:a,memory_mib:r,vcpu:i}=n;if(typeof i=="number"&&typeof r=="number"&&r<i*3072&&t.push(`${s} 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&&t.push(`${s} custom instance_type allows ≤ 2 GB disk per GiB memory (≤ ${String(c)} MB for ${String(r)} MiB memory; got ${String(a)} MB)`)}},N=(e,s,t)=>{const{boundClasses:n,errors:a,nonSqliteClasses:r,sqliteClasses:i,warnings:c}=t;if(!e||typeof e!="object"||typeof e.class_name!="string"||e.class_name.length===0){a.push(`${s} must have a non-empty "class_name" naming its container-enabled Durable Object class`);return}(typeof e.image!="string"||e.image.length===0)&&a.push(`${s} ("${e.class_name}") must have an "image" — a Dockerfile path or a registry reference`),n.has(e.class_name)||a.push(`${s} class "${e.class_name}" has no matching durable_objects binding — run \`lunora dev\` to auto-reconcile wrangler.jsonc, or add { "name": "...", "class_name": "${e.class_name}" }`),i.has(e.class_name)||a.push(r.has(e.class_name)?`${s} class "${e.class_name}" is registered via "new_classes" but containers require SQLite-backed DOs — move it to "new_sqlite_classes"`:`${s} class "${e.class_name}" is missing from migrations — add a migration entry with "new_sqlite_classes": ["${e.class_name}"]`),C(e,`${s} ("${e.class_name}")`,a),e.max_instances===void 0&&c.push(`${s} ("${e.class_name}") declares no max_instances — set a cap so a traffic spike can't fan out unbounded container spend`)},p=e=>Array.isArray(e)?e.filter(s=>s!==null&&typeof s=="object"):[],I=(e,s,t)=>{if(e.containers===void 0)return;if(!Array.isArray(e.containers)){s.push("containers must be an array of { class_name, image, ... } entries");return}const n=e.containers;if(n.length===0)return;const a=new Set(p(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 n.entries())N(d,`containers[${String(o)}]`,{boundClasses:a,errors:s,nonSqliteClasses:c,sqliteClasses:i,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 } })')},f=e=>typeof e=="string"&&e.length>0,S=e=>e,u=(e,s,t,n)=>{if(e!==void 0){if(!Array.isArray(e)){n.push(t.arrayMessage);return}for(const[a,r]of S(e).entries()){const i=`${s}[${String(a)}]`;if(!r||typeof r!="object"){n.push(t.objectMessage(i));continue}for(const c of t.fields)f(r[c.field])||n.push(c.message(i))}}},B={arrayMessage:"workflows must be an array of { name, binding, class_name } entries",fields:[{field:"binding",message:e=>`${e} must have a non-empty "binding" naming the Workflow binding (e.g. WORKFLOW_ORDER_PIPELINE)`},{field:"class_name",message:e=>`${e} must have a non-empty "class_name" naming the exported WorkflowEntrypoint class`},{field:"name",message:e=>`${e} must have a non-empty "name" naming the deployed workflow`}],objectMessage:e=>`${e} must be a { name, binding, class_name } object`},F={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`},P={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`},T=(e,s)=>{if(e.queues!==void 0){if(typeof e.queues!="object"||Array.isArray(e.queues)){s.push("queues must be a { producers, consumers } object");return}u(e.queues.producers,"queues.producers",F,s),u(e.queues.consumers,"queues.consumers",P,s)}},U={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`},K=[{arrayMessage:"kv_namespaces must be an array of { binding, id } entries",bindingMessage:e=>`${e} must have a non-empty "binding" naming the KV namespace binding`,hintField:"id",hintMessage:(e,s)=>`${e} ("${s}") has no "id" — run \`wrangler kv namespace create\` and set the namespace id, or the binding can't resolve`,key:"kv_namespaces"},{arrayMessage:"flagship must be an array of { binding, app_id } entries",bindingMessage:e=>`${e} must have a non-empty "binding" naming the Flagship binding`,hintField:"app_id",hintMessage:(e,s)=>`${e} ("${s}") has no "app_id" — create a Flagship app and set its id, or the binding can't resolve`,key:"flagship"},{arrayMessage:"hyperdrive must be an array of { binding, id } entries",bindingMessage:e=>`${e} must have a non-empty "binding" naming the Hyperdrive binding`,hintField:"id",hintMessage:(e,s)=>`${e} ("${s}") has no "id" — run \`wrangler hyperdrive create\` and set the id, or the binding can't connect`,key:"hyperdrive"},{arrayMessage:"pipelines must be an array of { binding, stream } entries",bindingMessage:e=>`${e} must have a non-empty "binding" naming the Pipelines binding`,hintField:["stream","pipeline"],hintMessage:(e,s)=>`${e} ("${s}") has no "stream" — run \`wrangler pipelines create <name>\` and set the stream name, or the binding can't resolve`,key:"pipelines"},{arrayMessage:"analytics_engine_datasets must be an array of { binding, dataset } entries",bindingMessage:e=>`${e} must have a non-empty "binding" naming the Analytics Engine binding`,hintField:"dataset",hintMessage:(e,s)=>`${e} ("${s}") has no "dataset" — it defaults to the binding name; set it explicitly to avoid drift`,key:"analytics_engine_datasets"}],G=(e,s,t,n)=>{const a=e[s.key];if(a!==void 0){if(!Array.isArray(a)){t.push(s.arrayMessage);return}for(const[r,i]of S(a).entries()){const c=`${s.key}[${String(r)}]`;if(!i||typeof i!="object"||!f(i.binding)){t.push(s.bindingMessage(c));continue}(typeof s.hintField=="string"?[s.hintField]:s.hintField).some(o=>f(i[o]))||n.push(s.hintMessage(c,i.binding))}}},Y=[{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" })'}],z=(e,s,t)=>{const n=e[s.key];n!==void 0&&(typeof n!="object"||Array.isArray(n)||!f(n.binding))&&t.push(s.message)},H=[{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`}],Q=(e,s,t)=>{const n=e.send_email;if(n===void 0)return;if(!Array.isArray(n)){s.push("send_email must be an array of { name, destination_address? } entries");return}const a=n;for(const[r,i]of a.entries())(!i||typeof i!="object"||typeof i.name!="string"||i.name.length===0)&&t.push(`send_email[${String(r)}] has no non-empty "name" naming the send-email binding — set one before deploying`)},J=(e,s)=>{e.logpush!==void 0&&typeof e.logpush!="boolean"&&s.push('logpush must be a boolean (set "logpush": true to enable Cloudflare Logpush)')},V=(e,s)=>{const{placement:t}=e;if(t!==void 0){if(typeof t!="object"||Array.isArray(t)){s.push('placement must be an object (e.g. { "mode": "smart" })');return}t.mode!==void 0&&t.mode!=="smart"&&s.push('placement.mode must be "smart" (the only supported Smart Placement mode)')}},Z=(e,s)=>{const{observability:t}=e;if(t===void 0)return;if(typeof t!="object"||Array.isArray(t)){s.push('observability must be an object (e.g. { "enabled": true, "head_sampling_rate": 1 })');return}const n=(a,r)=>{a!==void 0&&(typeof a!="number"||Number.isNaN(a)||a<0||a>1)&&s.push(`${r} must be a number in [0, 1] (the fraction of requests sampled)`)};n(t.head_sampling_rate,"observability.head_sampling_rate"),t.logs!==void 0&&(typeof t.logs!="object"||Array.isArray(t.logs)?s.push("observability.logs must be an object"):n(t.logs.head_sampling_rate,"observability.logs.head_sampling_rate"))},X=(e,s)=>{const{cache:t}=e;if(t!==void 0){if(typeof t!="object"||t===null||Array.isArray(t)){s.push('cache must be an object (e.g. { "enabled": true })');return}t.enabled!==void 0&&typeof t.enabled!="boolean"&&s.push("cache.enabled must be a boolean (true or false)")}},ee=(e,s)=>{const{exports:t}=e;if(t!==void 0){if(typeof t!="object"||t===null||Array.isArray(t)){s.push("exports must be an object keyed by entrypoint name");return}for(const[n,a]of Object.entries(t)){if(typeof a!="object"||a===null){s.push(`exports["${n}"] must be an object`);continue}a.type!==void 0&&typeof a.type!="string"&&s.push(`exports["${n}"].type must be a string`),a.cache!==void 0&&(typeof a.cache!="object"||a.cache===null||Array.isArray(a.cache)?s.push(`exports["${n}"].cache must be an object`):a.cache.enabled!==void 0&&typeof a.cache.enabled!="boolean"&&s.push(`exports["${n}"].cache.enabled must be a boolean`))}}},se=(e,s)=>{const{assets:t}=e;if(t!==void 0){if(typeof t!="object"||Array.isArray(t)){s.push('assets must be an object (e.g. { "directory": "./dist/client", "binding": "ASSETS" })');return}(typeof t.directory!="string"||t.directory.length===0)&&s.push('assets must declare a non-empty "directory" pointing at the built client output (e.g. "./dist/client")'),t.binding!==void 0&&(typeof t.binding!="string"||t.binding.length===0)&&s.push('assets.binding must be a non-empty string (e.g. "ASSETS")'),t.html_handling!==void 0&&typeof t.html_handling!="string"&&s.push("assets.html_handling must be a string"),t.not_found_handling!==void 0&&typeof t.not_found_handling!="string"&&s.push("assets.not_found_handling must be a string")}},te=(e,s)=>{const t=e.tail_consumers;if(t===void 0)return;if(!Array.isArray(t)){s.push("tail_consumers must be an array of { service, environment? } entries");return}const n=t;for(const[a,r]of n.entries())(!r||typeof r!="object"||typeof r.service!="string"||r.service.length===0)&&s.push(`tail_consumers[${String(a)}] must have a non-empty "service" naming the consumer Worker`)},Oe=(e,s)=>{const t=e.tail_consumers??[];return t.some(n=>!!n&&n?.service===s.service&&n?.environment===s.environment)?e:{...e,tail_consumers:[...t,s]}},ne=new Set(["1","enabled","on","true","yes"]),ae=(e,s)=>{const{vars:t}=e;if(!t||typeof t!="object")return;const n=t.LUNORA_ALLOWED_ORIGINS,a=t.LUNORA_CORS_ALLOW_CREDENTIALS,r=typeof n=="string"&&n.split(",").some(c=>c.trim()==="*"),i=typeof a=="string"&&ne.has(a.trim().toLowerCase());r&&i&&s.push('vars.LUNORA_ALLOWED_ORIGINS includes a "*" wildcard while vars.LUNORA_CORS_ALLOW_CREDENTIALS is on — browsers reject this combination and it defeats the allowlist; name explicit origins or drop credentials')},re=(e,s,t)=>{const{error:n,merged:a,unverifiedKeys:r}=A(e,s);return n!==void 0?{error:n,wrangler:a}:(r.length>0&&t.push(`env.${String(s)} 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(s)}".`),{wrangler:a})},k=(e,s,t)=>{const n=[],a=[];if(!e||typeof e!="object")return n.push("wrangler config is not a valid object"),{errors:n,valid:!1,warnings:a};const{error:r,wrangler:i}=re(e,t,a);if(r!==void 0)return n.push(r),{errors:n,valid:!1,warnings:a};p(i.durable_objects?.bindings).find(o=>o.name==="SHARD"&&o.class_name==="ShardDO")||n.push('durable_objects.bindings must include { "name": "SHARD", "class_name": "ShardDO" } — run `lunora dev` to auto-reconcile wrangler.jsonc, or add the binding manually');const c=i.compatibility_date??"";c&&!v.test(c)?n.push(`compatibility_date must be in YYYY-MM-DD format (got "${c}")`):c<y&&n.push(`compatibility_date must be >= "${y}" (got "${c||"<missing>"}")`),O(i)&&v.test(c)&&c<h&&n.push(`cache.enabled requires compatibility_date >= "${h}" (got "${c||"<missing>"}")`),s?.hasGlobalTable&&(p(i.d1_databases).find(o=>o.binding==="DB")||n.push('schema declares .global() tables; d1_databases must include a binding named "DB" — run `lunora dev` to auto-reconcile wrangler.jsonc, or add the binding manually')),D(i,s?.vectorIndexNames??[],n),te(i,n),I(i,n,a),u(i.workflows,"workflows",B,n),T(i,n),u(i.secrets_store_secrets,"secrets_store_secrets",U,n);for(const o of K)G(i,o,n,a);for(const o of H)u(i[o.key],o.key,o,n);for(const o of Y)z(i,o,n);return Q(i,n,a),J(i,n),V(i,n),Z(i,n),se(i,n),X(i,n),ee(i,n),ae(i,n),{errors:n,valid:n.length===0,warnings:a}},Re=k,ie=(e,s,t)=>{const n=[];for(const a of e){const r=a?.image;typeof r!="string"||!(r.startsWith("./")||r.startsWith("../")||r.startsWith("/")||r.includes("Dockerfile"))||g(r.startsWith("/")?r:b(s,r))||n.push(`containers image "${r}" does not exist (resolved relative to ${t}); create the Dockerfile or point image at a registry reference`)}return n},oe=(e,s,t)=>{if(typeof e=="string"&&e.length>0){const n=b(j(t),e);return g(n)?n:void 0}return x.map(n=>b(s,n)).find(n=>g(n))},ce=/\/\/[^\n]*|\/\*.*?\*\/|"[^"\n]*"|'[^'\n]*'|`[^`]*`/gsu,de=e=>e.replaceAll(ce,s=>s.replaceAll(/[^\n]/gu," ")),le=/\bexport\s*\*\s*(?:as\s+\w+\s*)?from\b/u,me=/\bexport\b/gu,ue=/^\s*(?:(?:abstract|async|declare|default)\s+)*/u,ge=/^(?:class|const|function|let|var)\s+(?<name>[$A-Z_a-z][\w$]*)/u,be=/^\s*(?:const|let|var)\s*\{/u,pe=/^[$A-Z_a-z][\w$]*/u,fe=/^type\b/u,he=/\s+/u,ye=e=>{const s=[];for(const t of e.split(",")){const n=t.trim().split(he).filter(Boolean),a=n.at(-1);a!==void 0&&n[0]!=="type"&&s.push(a)}return s},ve=e=>{const s=[];for(const t of e.split(",")){const n=t.includes(":")?t.slice(t.indexOf(":")+1):t,a=pe.exec(n.trim());a&&s.push(a[0])}return s},w=e=>{const s=e.indexOf("{"),t=e.indexOf("}",s);return s===-1||t===-1?void 0:e.slice(s+1,t)},_e=e=>{const s=e.trimStart();if(fe.test(s))return[];if(s.startsWith("{")){const n=w(s);return n===void 0?[]:ye(n)}if(be.test(e)){const n=w(e);return n===void 0?[]:ve(n)}const t=ge.exec(e.replace(ue,""));return t?.groups?.name===void 0?[]:[t.groups.name]},$e=e=>{const s=new Set;for(const t of e.matchAll(me))for(const n of _e(e.slice(t.index+6)))s.add(n);return s},we=(e,s,t)=>{const n=oe(e.main,s,t);if(n===void 0)return[];let a;try{a=M(n,"utf8")}catch{return[]}const r=de(a);if(le.test(r))return[];const i=[];for(const o of p(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=$e(r);return i.filter(o=>!c.has(o.className)).map(o=>`${o.label} declares class "${o.className}" but the worker entry (${n}) does not export it — wrangler refuses to bundle a Worker whose Durable Object classes are not exported. Add \`export { ${o.className} } from "…";\` to the entry.`)},qe=e=>{const s=e.schemaDir??"lunora",t=R(e.projectRoot);if(!t){const m=`wrangler.jsonc not found in ${e.projectRoot}; create one declaring at least the SHARD durable object binding.`;return{problems:[m],report:{errors:[m],valid:!1,warnings:[]},wranglerPath:void 0}}const{parsed:n}=q(t);if(n===void 0){const m=`failed to parse ${t} as JSONC.`;return{problems:[m],report:{errors:[m],valid:!1,warnings:[]},wranglerPath:t}}const{error:a,merged:r}=A(n,e.environment);if(a!==void 0)return{problems:[a],report:{errors:[a],valid:!1,warnings:[]},wranglerPath:t};const{error:i,info:c}=E(e.projectRoot,s),o=k(n,c,e.environment);i!==void 0&&o.warnings.push(`schema parse failed in ${s}/schema.ts: ${i}`);const d=j(t);o.errors.push(...ie(r.containers??[],d,t)),o.warnings.push(...we(r,e.projectRoot,t));const l=r.assets?.directory;if(typeof l=="string"&&l.length>0){const m=l.startsWith("/")?l:b(d,l);g(m)||o.warnings.push(`assets.directory "${l}" does not exist yet — it is created by the client build; run the build before deploy`)}return o.valid=o.errors.length===0,{problems:o.errors,report:o,wranglerPath:t}};export{y as REQUIRED_COMPATIBILITY_DATE,Ee as REQUIRED_FLAG,Re as validateWrangler,k as validateWranglerConfig,qe as validateWranglerProject,Oe as withTailConsumer};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import{randomBytes as V}from"node:crypto";import{existsSync as y,readFileSync as m,writeFileSync as C,renameSync as D,rmSync as $,statSync as z}from"node:fs";import{join as f}from"node:path";import{LunoraError as F}from"@lunora/errors";import{DEV_VARS_FILE as c,DEV_VARS_EXAMPLE_FILE as u,splitDevVariableLine as h,parseDevVariableEntries as K,DEV_VARS_NEWLINE as _,unquoteDevVariable as j}from"./DEV_VARS_EXAMPLE_FILE-BL0hrPx3.mjs";import{CORE_SECRETS as x,PACKAGE_SECRETS_REGISTRY as L,secretsForPackages as W}from"./PACKAGE_SECRETS_REGISTRY-BgmvEPA-.mjs";const R=e=>[...x,...W(e)],S=32,A=/(?:KEY|PASSWORD|SECRET|TOKEN)$/u,M=["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"],T=/[.*+?^${}()|[\]\\]/gu,N=/[a-z0-9]$/u,P=e=>{const t=e.trim().toLowerCase();return t===""||t.startsWith("<")&&t.endsWith(">")?!0:M.some(a=>{const s=a.replaceAll(T,String.raw`\$&`),n=N.test(a)?`(^|[^a-z0-9])${s}([^a-z0-9]|$)`:`(^|[^a-z0-9])${s}`;return new RegExp(n,"u").test(t)})},G=e=>P(j(e.trim())),p=e=>V(e).toString("hex"),I=new Set([...x,...Object.values(L).flat()].filter(e=>A.test(e.key)&&e.placeholderValue.startsWith("<")).map(e=>e.key)),O=e=>A.test(e)&&!I.has(e),H=(e,t,a)=>O(e)&&G(t)?a(S):void 0,ae=(e=p)=>e(S),b=(e,t,a)=>e.split(_).map(s=>{const n=h(s),i=n?H(n.key,n.value,t):void 0;return!n||i===void 0?s:(a.push(n.key),`${n.key}="${i}"`)}),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??p,t).join(`
|
|
2
|
+
`),generatedKeys:t,status:"generate"}},k=e=>{const t=e.randomHex??p,a=new Set(K(e.existingContent).map(d=>d.key)),s=[],n=[],i=[];for(const d of e.exampleContent.split(_)){const r=h(d);if(!r||a.has(r.key))continue;const o=H(r.key,r.value,t);i.push(r.key),o===void 0?s.push(`${r.key}="${j(r.value)}"`):(n.push(r.key),s.push(`${r.key}="${o}"`))}return{additions:s,generatedKeys:n,missingKeys:i}},E=e=>e.length>0?` (generated ${e.join(", ")})`:"",g=(e,t,a={})=>{const s=`${e}.tmp-${String(process.pid)}`;try{C(s,t,{encoding:"utf8",...a}),D(s,e)}catch(n){throw $(s,{force:!0}),n}},re=(e,t)=>{g(e,t,{mode:384})},v=5,w=e=>{try{const t=z(e);return{mtimeMs:t.mtimeMs,size:t.size}}catch{return}},B=(e,t)=>e===void 0||t===void 0?!1:e.mtimeMs===t.mtimeMs&&e.size===t.size,U=(e,t)=>{for(let a=0;a<v;a+=1){const s=w(e),n=m(e,"utf8"),i=t(n);if(i.length===0)return[];const d=n.length>0&&!n.endsWith(`
|
|
3
|
+
`)?`
|
|
4
|
+
`:"",r=`${n}${d}${i.join(`
|
|
5
|
+
`)}
|
|
6
|
+
`,o=`${e}.tmp-${String(process.pid)}-${V(6).toString("hex")}`;try{C(o,r,{encoding:"utf8",mode:384});const l=w(e);if(!B(s,l)){$(o,{force:!0});continue}return D(o,e),i}catch(l){throw $(o,{force:!0}),l}}throw new F("INTERNAL",`Failed to append to ${e} after ${String(v)} attempts — a concurrent writer kept winning the race.`)},ie=async e=>{const t=f(e.cwd,c),a=f(e.cwd,u);if(!y(a))return{addedKeys:[],generatedKeys:[],status:"no-example"};const s=m(a,"utf8");if(!y(t)){const o=q({devVarsExists:!1,exampleContent:s,randomHex:e.randomHex});return o.status!=="generate"?{addedKeys:[],generatedKeys:[],status:"no-example"}:e.yes===!0||await e.confirm(`No ${c} found. Generate it from ${u} (secrets auto-filled)?`)?y(t)?{addedKeys:[],generatedKeys:[],status:"skipped-exists"}:(g(t,o.content,{flag:"wx",mode:384}),e.info(`Created ${c}${E(o.generatedKeys)}.`),{addedKeys:[],generatedKeys:o.generatedKeys,status:"generated"}):(e.info(`Skipped — copy ${u} to ${c} and fill it in when you're ready.`),{addedKeys:[],generatedKeys:[],status:"declined"})}const n=k({existingContent:m(t,"utf8"),exampleContent:s,randomHex:e.randomHex});if(n.missingKeys.length===0)return{addedKeys:[],generatedKeys:[],status:"exists"};const i=n.missingKeys.join(", ");if(!(e.yes===!0||await e.confirm(`${c} is missing ${String(n.missingKeys.length)} key(s) from ${u} (${i}). Add them?`)))return e.info(`Skipped — add ${i} to ${c} when you're ready.`),{addedKeys:[],generatedKeys:[],status:"declined"};const d=U(t,o=>k({existingContent:o,exampleContent:s,randomHex:e.randomHex}).additions).map(o=>h(o)?.key).filter(o=>o!==void 0);if(d.length===0)return{addedKeys:[],generatedKeys:[],status:"exists"};const r=n.generatedKeys.filter(o=>d.includes(o));return e.info(`Updated ${c} — added ${d.join(", ")}${E(r)}.`),{addedKeys:d,generatedKeys:r,status:"augmented"}},Y=e=>[`# ${e.description}`,`# Docs: ${e.docsUrl}`,`${e.key}="${e.placeholderValue}"`].join(`
|
|
7
|
+
`),X=(e,t)=>{const a=R(e).filter(s=>!t.has(s.key));return a.length===0?"":a.map(s=>Y(s)).join(`
|
|
8
|
+
|
|
9
|
+
`)},oe=(e,t)=>{const a=f(e,u),s=y(a)?m(a,"utf8"):"",n=new Set(K(s).map(r=>r.key)),i=X(t,n);if(i==="")return[];const d=s.length>0&&!s.endsWith(`
|
|
10
|
+
`)?`
|
|
11
|
+
`:"";return g(a,`${s}${d}
|
|
12
|
+
${i}
|
|
13
|
+
`),R(t).filter(r=>!n.has(r.key)).map(r=>r.key)},J=e=>{const t=e.randomHex??p,a=[],s=b(e.existingContent,t,a),n=new Set(K(e.existingContent).map(l=>l.key)),i=[],d=[];for(const l of x)n.has(l.key)||(i.push(l.key),d.push(`# ${l.description}`,`${l.key}="${t(S)}"`));const r=s.join(`
|
|
14
|
+
`);if(d.length===0)return{addedKeys:i,content:r,filledKeys:a};const o=r===""||r.endsWith(`
|
|
15
|
+
`)?"":`
|
|
16
|
+
`;return{addedKeys:i,content:`${r}${o}${d.join(`
|
|
17
|
+
`)}
|
|
18
|
+
`,filledKeys:a}},de=e=>{const t=f(e.cwd,c),a=y(t),s=a?m(t,"utf8"):"",n=J({existingContent:s,randomHex:e.randomHex});if(n.filledKeys.length===0&&n.addedKeys.length===0)return{addedKeys:[],filledKeys:[],status:"unchanged"};g(t,n.content,{mode:384});const i=[...n.filledKeys,...n.addedKeys];return e.info?.(`Generated ${String(i.length)} dev secret(s) in ${c}: ${i.join(", ")}`),{addedKeys:n.addedKeys,filledKeys:n.filledKeys,status:a?"filled":"created"}};export{X as buildPackageSecretsBlock,ie as ensureDevVariables,oe as ensureDevVarsExample,de as fillDevSecrets,ae as generateSecretValue,O as isMintableSecretKey,P as isPlaceholderValue,J as planDevSecretsFill,k as planDevVariablesAugment,q as planDevVariablesScaffold,R as requiredSecrets,re as writeDevVariablesFileAtomically};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{writeFileSync as N,readFileSync as E}from"node:fs";import{join as D}from"node:path";import{containerBuildTag as A}from"@lunora/container";import{DEV_VARS_FILE as B,parseDevVariableEntries as O}from"./DEV_VARS_EXAMPLE_FILE-BL0hrPx3.mjs";import{e as b}from"./jsonc-edit-BZVpxVA0.mjs";import{findWranglerFile as C,readWranglerJsonc as R}from"./WRANGLER_FILES-Bi_18Pj6.mjs";const S="<replace-with-d1-create-id>",P=e=>[["container","containers",e.containers],["workflow","workflows",e.workflows],["agent","agents",e.agents]].flatMap(([a,t,n])=>n.filter(r=>!r.exported).map(({className:r,exportName:i})=>({className:r,exportName:i,kind:a,module:t}))),T=(e,a)=>{const t=e.flagshipBinding!==void 0&&!(a?.flagship??[]).some(n=>n.binding===e.flagshipBinding);return[[e.usesKv&&(a?.kv_namespaces?.length??0)===0,"@lunora/bindings/kv is used but no kv_namespaces binding exists; add a kv_namespaces entry ({ binding, id }) and pass env.<BINDING> to createKv() — the namespace id can't be auto-provisioned."],[e.usesHyperdrive&&(a?.hyperdrive?.length??0)===0,"@lunora/hyperdrive is used but no hyperdrive binding exists; run 'wrangler hyperdrive create' and add a 'hyperdrive' binding ({ binding, id }) — the id can't be auto-provisioned."],[e.usesPipelines&&(a?.pipelines?.length??0)===0,"ctx.pipelines is used but no pipelines binding exists; run 'wrangler pipelines create <name>' and add a 'pipelines' binding ({ binding, pipeline }) — the pipeline resource can't be auto-provisioned."],[t,`lunora/flags.ts uses Flagship in binding mode but no flagship binding "${e.flagshipBinding??""}" exists; add a flagship entry ({ binding: "${e.flagshipBinding??""}", app_id }) — the app_id can't be auto-provisioned.`]].filter(([n])=>n).map(([,n])=>n)},I=e=>[[e.usesX402Charge,"@lunora/x402/charge is used; set the recipient wallet address as a [vars] entry (the var name is your choice) and pass it to the charge config — the x402 facilitator settles USDC to that address."],[e.usesX402Pay,"@lunora/x402/pay is used (ActionCtx-only, spends real funds); add a secrets_store_secrets[] binding holding the agent wallet key (binding name == signer.secretName) and pair the pay rail with a spend policy — ctx.secrets reads a Secrets Store binding, not .dev.vars."]].filter(([a])=>a).map(([,a])=>a),v=(e,a,t)=>t.filter(n=>!n.exported).map(n=>`${e} "${n.exportName}" is declared but ${n.className} is not exported by the worker entry; add \`export * from "./lunora/_generated/${a}"\` so its binding can be provisioned.`),k=[{keys:["STRIPE_SECRET_KEY","STRIPE_WEBHOOK_SECRET"],label:"Stripe"},{keys:["POLAR_ACCESS_TOKEN","POLAR_WEBHOOK_SECRET"],label:"Polar"},{keys:["CREEM_API_KEY","CREEM_WEBHOOK_SECRET"],label:"Creem"},{keys:["AUTUMN_SECRET_KEY","AUTUMN_WEBHOOK_SECRET"],label:"Autumn"},{keys:["DODO_PAYMENTS_API_KEY","DODO_PAYMENTS_WEBHOOK_KEY"],label:"Dodo Payments"}],$=()=>k.map(({keys:e,label:a})=>`${e[0]} + ${e[1]} (${a})`).join(" or "),M=e=>{let a;try{a=E(D(e,B),"utf8")}catch{return!1}const t=new Map(O(a).map(n=>[n.key,n.value]));return k.some(({keys:n})=>n.every(r=>(t.get(r)??"")!==""))},_=(e,a,t)=>{const n=new Set(e.durableObjects.map(o=>o.className)),r=[],i=(t?.r2_buckets?.length??0)>0,c=(t?.d1_databases?.some(o=>o.binding==="DB")??!1)||e.needsD1;return e.usesStorage&&!i&&r.push("@lunora/storage is used but R2 bucket bindings have user-defined names; add an r2_buckets entry and pass env.<BINDING> to createStorage()."),e.usesAuth&&!n.has("SessionDO")&&!c&&r.push("@lunora/auth is used but the worker entry exports no SessionDO; sessions are D1-backed, or export SessionDO to enable DO-backed sessions."),e.usesScheduler&&!n.has("SchedulerDO")&&r.push("@lunora/scheduler is used but the worker entry exports no SchedulerDO; export it so the SCHEDULER binding can be provisioned."),r.push(...v("container","containers",e.containers),...v("workflow","workflows",e.workflows),...v("agent","agents",e.agents)),e.containers.length>0&&t?.observability?.enabled===!1&&r.push("containers are declared but observability is explicitly disabled in wrangler.jsonc — container logs will not be captured."),e.usesPayment&&!M(a)&&r.push(`@lunora/payment is used; set one provider's secret pair in .dev.vars — ${$()}.`),r.push(...I(e),...T(e,t)),r},q=e=>{const a=new Set(e.map(n=>n.tag));let t=1;for(;a.has(`v${String(t)}`);)t+=1;return`v${String(t)}`},K=(e,a,t)=>{const n=a.durable_objects?.bindings??[],r=new Set(n.map(u=>u.name)),i=t.filter(u=>!r.has(u.binding));let c=e;const o=[];if(i.length>0){const u=[...n,...i.map(m=>({class_name:m.className,name:m.binding}))];c=b(c,["durable_objects","bindings"],u),o.push(...i.map(m=>`${m.binding}/${m.className}`))}const g=a.migrations??[],l=new Set(g.flatMap(u=>[...u.new_sqlite_classes??[],...u.new_classes??[]])),h=t.map(u=>u.className).filter(u=>!l.has(u));if(h.length>0){const u=[...g,{new_sqlite_classes:h,tag:q(g)}];c=b(c,["migrations"],u)}return{added:o,text:c}},W=(e,a)=>{const t=a.d1_databases??[];if(t.some(i=>i.binding==="DB"))return{added:[],text:e};const n=typeof a.name=="string"&&a.name.length>0?a.name:"lunora",r=[...t,{binding:"DB",database_id:S,database_name:n}];return{added:["DB (D1)"],text:b(e,["d1_databases"],r)}},y=(e,a,t,n,r)=>{const i=a[t]?.binding;return typeof i=="string"&&i.length>0?{added:[],text:e}:{added:[r],text:b(e,[t],{binding:n})}},j=(e,a)=>(a.analytics_engine_datasets?.length??0)>0?{added:[],text:e}:{added:["ANALYTICS (Analytics Engine)"],text:b(e,["analytics_engine_datasets"],[{binding:"ANALYTICS",dataset:"ANALYTICS"}])},Y=e=>{if(typeof e=="string")return e;const a={};return e.diskMb!==void 0&&(a.disk_mb=e.diskMb),e.memoryMib!==void 0&&(a.memory_mib=e.memoryMib),e.vcpu!==void 0&&(a.vcpu=e.vcpu),a},G=e=>e.image.kind==="dockerfile"?e.image.dockerfilePath:e.image.kind==="registry"?e.image.reference:A(e.exportName),L=e=>{const a={class_name:e.className,image:G(e)};return e.image.kind==="dockerfile"&&(a.image_build_context=e.image.buildContext),e.buildArgs!==void 0&&e.image.kind!=="registry"&&(a.image_vars=e.buildArgs),e.instanceType!==void 0&&(a.instance_type=Y(e.instanceType)),e.maxInstances!==void 0&&(a.max_instances=e.maxInstances),e.name!==void 0&&(a.name=e.name),e.rollout?.stepPercentage!==void 0&&(a.rollout_step_percentage=e.rollout.stepPercentage),e.rollout?.gracePeriodSeconds!==void 0&&(a.rollout_active_grace_period=e.rollout.gracePeriodSeconds),a},H=(e,a,t)=>{const n=a.containers??[],r=new Set(n.map(o=>o.class_name)),i=t.filter(o=>!r.has(o.className));if(i.length===0)return{added:[],text:e};const c=b(e,["containers"],[...n,...i.map(o=>L(o))]);return{added:i.map(o=>`containers/${o.className}`),text:c}},U=(e,a)=>{if(a.observability!==void 0)return{added:[],text:e};const t=b(e,["observability"],{enabled:!0,head_sampling_rate:1});return{added:["observability"],text:t}},x=e=>({binding:e.bindingName,class_name:e.className,name:e.name}),F=(e,a,t,n=[])=>{const r=a.workflows??[],i=new Set(r.map(l=>l.class_name)),c=t.filter(l=>!i.has(l.className)),o=n.filter(l=>!i.has(l.className));if(c.length===0&&o.length===0)return{added:[],text:e};const g=b(e,["workflows"],[...r,...c.map(l=>x(l)),...o.map(l=>x(l))]);return{added:[...c.map(l=>`workflows/${l.className}`),...o.map(l=>`workflows/${l.className}`)],text:g}},V=(e,a,t)=>{const n=a.queues??{},r=n.producers??[],i=n.consumers??[],c=new Set(r.map(d=>d.binding)),o=new Set(i.map(d=>d.queue)),g=t.filter(d=>!c.has(d.bindingName)),l=t.filter(d=>!o.has(d.name));if(g.length===0&&l.length===0)return{added:[],text:e};const h=[...r,...g.map(d=>({binding:d.bindingName,queue:d.name}))],u=[...i,...l.map(d=>{const p={queue:d.name};return d.mode==="pull"&&(p.type="http_pull"),d.tuning.maxBatchSize!==void 0&&(p.max_batch_size=d.tuning.maxBatchSize),d.tuning.maxBatchTimeout!==void 0&&(p.max_batch_timeout=d.tuning.maxBatchTimeout),d.tuning.maxRetries!==void 0&&(p.max_retries=d.tuning.maxRetries),d.tuning.deadLetterQueue!==void 0&&(p.dead_letter_queue=d.tuning.deadLetterQueue),d.tuning.retryDelay!==void 0&&(p.retry_delay=d.tuning.retryDelay),p})],m=b(e,["queues"],{consumers:u,producers:h});return{added:[...g.map(d=>`queues.producers/${d.bindingName}`),...l.map(d=>`queues.consumers/${d.name}`)],text:m}},ae=(e,a,t)=>{const n=C(e),r=P(a);if(!n)return{added:[],changed:!1,exportGaps:r,reason:"wrangler.jsonc not found",warnings:_(a,e)};const{parsed:i,text:c}=R(n);if(i===void 0)return{added:[],changed:!1,exportGaps:r,reason:`failed to parse ${n} as JSONC`,warnings:_(a,e),wranglerPath:n};const o=_(a,e,i);if(t!==void 0){const s=i.env?.[t]!==void 0;o.push(s?`auto-provisioned bindings are written to the top level of wrangler.jsonc only — "env.${t}" has its own (non-inheritable) bindings and must be reconciled by hand; \`lunora deploy --env ${t}\` now validates them, so a gap here will be reported at deploy time.`:`--env "${t}" was requested but wrangler.jsonc declares no "env.${t}" block — auto-provisioned bindings are written to the top level only and will not apply to that environment.`)}const g=a.containers.filter(s=>s.exported),l=a.agents.filter(s=>s.exported&&s.voice===!0&&s.voiceBindingName!==void 0&&s.voiceClassName!==void 0),h=[...a.durableObjects,...g.map(s=>({binding:s.bindingName,className:s.className})),...l.map(s=>({binding:s.voiceBindingName,className:s.voiceClassName}))],u=a.workflows.filter(s=>s.exported),m=a.agents.filter(s=>s.exported),d=[{enabled:!0,run:s=>K(s,i,h)},{enabled:a.needsD1,run:s=>W(s,i)},{enabled:a.usesAi,run:s=>y(s,i,"ai","AI","AI (Workers AI)")},{enabled:a.usesBrowser,run:s=>y(s,i,"browser","BROWSER","BROWSER (Browser Rendering)")},{enabled:a.usesImages,run:s=>y(s,i,"images","IMAGES","IMAGES (Cloudflare Images)")},{enabled:a.usesAnalytics,run:s=>j(s,i)},{enabled:!0,run:s=>U(s,i)},{enabled:g.length>0,run:s=>H(s,i,g)},{enabled:u.length>0||m.length>0,run:s=>F(s,i,u,m)},{enabled:a.queues.length>0,run:s=>V(s,i,a.queues)}];let p=c;const f=[];for(const s of d){if(!s.enabled)continue;const w=s.run(p);p=w.text,f.push(...w.added)}return f.includes("DB (D1)")&&o.push(`wrote a DB binding with a placeholder database_id ("${S}") — run \`wrangler d1 create <name>\` and replace it before deploying.`),p===c?{added:[],changed:!1,exportGaps:r,reason:"bindings already in sync",warnings:o,wranglerPath:n}:(N(n,p,"utf8"),{added:f,changed:!0,exportGaps:r,warnings:o,wranglerPath:n})};export{P as collectExportGaps,ae as reconcileWranglerBindings};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{relative as i}from"node:path";import{secretKindOf as c,redact as l}from"@lunora/codegen";import{isPlaceholderValue as S}from"./buildPackageSecretsBlock-
|
|
1
|
+
import{relative as i}from"node:path";import{secretKindOf as c,redact as l}from"@lunora/codegen";import{isPlaceholderValue as S}from"./buildPackageSecretsBlock-D2oDEMcf.mjs";import{findWranglerFile as E,readWranglerJsonc as p}from"./WRANGLER_FILES-Bi_18Pj6.mjs";const d=8,f=new Set(["CREDENTIAL","CREDENTIALS","DSN","PASSPHRASE","PASSWD","PASSWORD","SECRET","TOKEN"]),m=["ACCESS_KEY","API_KEY","ENCRYPTION_KEY","PRIVATE_KEY","SIGNING_KEY"],_=new Set(["PUBLIC","PUBLISHABLE"]),A=/[_-]/u,a=e=>e.toUpperCase().split(A),u=e=>{const r=e.toUpperCase().replaceAll("-","_");return a(e).some(t=>f.has(t))?!0:m.some(t=>r===t||r.endsWith(`_${t}`))},I=e=>a(e).some(r=>_.has(r)),P=(e,r)=>{if(e===void 0)return[];const t=[];for(const[s,o]of Object.entries(e)){if(typeof o!="string"||S(o)||I(s))continue;const n=c(o)??(u(s)&&o.length>=d?"secret_named_var":void 0);n!==void 0&&t.push({file:r,key:s,kind:n,preview:l(o)})}return t},R=e=>{const r=E(e);if(r===void 0)return[];const{parsed:t}=p(r);return t===void 0?[]:P(t.vars,i(e,r))};export{R as collectWranglerSecretVariables,P as scanWranglerVariablesForSecrets};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import{createInterface as v}from"node:readline";const g=/[\s,]+/u,d=()=>process.stdin.isTTY,f=async n=>{const t=v({input:process.stdin,output:process.stdout});try{return await new Promise(e=>{t.question(n,s=>{e(s)})})}finally{t.close()}},w=async(n,t)=>{const e=(await f(n)).trim().toLowerCase();return e===""?t?.defaultYes===!0:e==="y"||e==="yes"},b=(n="")=>d()?t=>w(`${n}${t} [Y/n] `,{defaultYes:!0}):()=>Promise.resolve(!1),S=async(n,t,e)=>{if(!d()||t.length===0)return e?.default;const s=e?.default===void 0?-1:t.findIndex(a=>a.value===e.default),p=t.map((a,u)=>` ${String(u+1)}) ${a.label}${a.description===void 0?"":` — ${a.description}`}`),m=`${n}
|
|
2
|
+
${p.join(`
|
|
3
|
+
`)}
|
|
4
|
+
> ${s>=0?`[${String(s+1)}] `:""}`,l=(await f(m)).trim();if(l==="")return e?.default;const i=Number.parseInt(l,10);return Number.isInteger(i)&&i>=1&&i<=t.length?t[i-1]?.value:t.find(a=>a.value===l||a.label.toLowerCase()===l.toLowerCase())?.value??e?.default},I=async(n,t)=>{if(!d())return t?.default;const e=(await f(n)).trim();return e===""?t?.default:e},h=async(n,t,e)=>{const s=e?.defaults??[];if(!d()||t.length===0)return[...s];const p=t.map((r,o)=>` ${String(o+1)}) ${r.label}${r.description===void 0?"":` — ${r.description}`}`),m=s.length===0?"":`[${s.join(", ")}] `,l=`${n} (comma-separated; Enter for default)
|
|
5
|
+
${p.join(`
|
|
6
|
+
`)}
|
|
7
|
+
> ${m}`,i=(await f(l)).trim();if(i==="")return[...s];const a=i.split(g).map(r=>r.trim()).filter(r=>r!==""),u=new Set;for(const r of a){const o=Number.parseInt(r,10);if(Number.isInteger(o)&&o>=1&&o<=t.length&&String(o)===r){const c=t[o-1]?.value;c!==void 0&&u.add(c);continue}const $=t.find(c=>c.value===r||c.label.toLowerCase()===r.toLowerCase());$!==void 0&&u.add($.value)}return t.filter(r=>u.has(r.value)).map(r=>r.value)};export{b as createConfirm,d as isInteractive,h as promptMultiSelect,S as promptSelect,I as promptText,w as promptYesNo};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{existsSync as m}from"node:fs";import{Project as c}from"ts-morph";import{join as t}from"node:path";const p=(e,o,n,i,s={})=>{if(!m(t(e,o,n)))return{};try{const r=new c({skipAddingFilesFromTsConfig:!0,useInMemoryFileSystem:!1,...s});return{value:i(r,t(e,o))}}catch(r){return{error:r instanceof Error?r.message:String(r)}}};export{p as m};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{discoverAgents as n,AGENTS_FILENAME as s}from"@lunora/codegen";import{m as i}from"./discover-info-DRQ0Ote0.mjs";const c=(o,e)=>{const{error:r,value:t}=i(o,e,s,n);return r===void 0?{agents:t??[]}:{agents:[],error:r}};export{c as discoverAgentInfo};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{discoverContainers as i,CONTAINERS_FILENAME as t}from"@lunora/codegen";import{m as s}from"./discover-info-DRQ0Ote0.mjs";const m=(o,e)=>{const{error:r,value:n}=s(o,e,t,i,{skipFileDependencyResolution:!0});return r===void 0?{containers:n??[]}:{containers:[],error:r}};export{m as discoverContainerInfo};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{discoverWorkflows as e,WORKFLOWS_FILENAME as t}from"@lunora/codegen";import{m as w}from"./discover-info-DRQ0Ote0.mjs";const m=(r,f)=>{const{error:o,value:s}=w(r,f,t,e);return o===void 0?{workflows:s??[]}:{error:o,workflows:[]}};export{m as discoverWorkflowInfo};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{existsSync as p,statSync as $,readFileSync as b,readdirSync as T}from"node:fs";import{init as C,parse as f}from"es-module-lexer";import{discoverAgentInfo as P}from"./discoverAgentInfo-C8LTinx8.mjs";import{WRANGLER_FILES as L,readWranglerJsonc as F}from"./WRANGLER_FILES-Bi_18Pj6.mjs";import{discoverContainerInfo as K}from"./discoverContainerInfo-C1zY2O8F.mjs";import{escapeRegExp as D}from"./DEV_VARS_EXAMPLE_FILE-BL0hrPx3.mjs";import{discoverFlags as W,FLAGS_FILENAME as H,discoverQueues as q,QUEUES_FILENAME as G}from"@lunora/codegen";import{m as k}from"./discover-info-DRQ0Ote0.mjs";import{discoverSchemaInfo as M}from"./discoverSchemaInfo-C8X9mo-i.mjs";import{discoverWorkflowInfo as U}from"./discoverWorkflowInfo-DHzCyLRj.mjs";import{join as c}from"node:path";const X=(e,r)=>{const{error:t,value:s}=k(e,r,H,W);return t===void 0?{flags:s}:{error:t}},Y=(e,r)=>{const{error:t,value:s}=k(e,r,G,q);return t===void 0?{queues:s??[]}:{error:t,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/,I=/^\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(I.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"}},l=Object.keys(g),de="STRIPE_SECRET_KEY + STRIPE_WEBHOOK_SECRET (Stripe) or POLAR_ACCESS_TOKEN + POLAR_WEBHOOK_SECRET (Polar)",j=[...l,"needsD1"],ue=()=>{const e={};for(const r of j)e[r]=!1;return e},u=Object.freeze(ue()),x=(e,r)=>{const t={};for(const s of j)t[s]=e[s]||r[s];return t},pe=e=>{for(const r of l)if(g[r].source===e)return{...u,[r]:!0};return u},le=e=>{const[r]=f(e);let t=u;for(const s of r){const n=s.n;!n||I.test(e.slice(s.ss,s.se))||(t=x(t,pe(n)))}return t},me=e=>{const r={...u};for(const t of l)r[t]=g[t].pattern.test(e);return r},be=e=>{let r;try{r=le(e)}catch{r=me(e)}return x(r,{...u,needsD1:ee.test(e),usesAi:re.test(e),usesPipelines:A.test(e)})},S=(e,r)=>{let t;try{t=T(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 L){const t=c(e,r);if(!p(t))continue;const{parsed:s}=F(t),n=s?.main;if(typeof n=="string"&&p(c(e,n)))return c(e,n);break}for(const r of V){const t=c(e,r);if(p(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}))},he=/(?:^|[\s,{])type$/u,ye=(e,r)=>{const t=r.ls>=0?r.ls:r.s;return he.test(e.slice(0,t).trimEnd())},xe=(e,r)=>{const t=D(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)},y=(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${D(o)}\b`,"u").test(s)&&!xe(s,o)))}return r.map(o=>{const i=n||a.has(o.className);return{...o,exported:i}})},Se=(e,r)=>M(e,r).info?.hasGlobalTable??!1,we=(e,r)=>{let t=u;for(const s of r){const n=c(e,s);if(!p(n)||!$(n).isDirectory())continue;const a=[];S(n,a);for(const o of a)t=x(t,be(b(o,"utf8")))}return t},ve=(e,r)=>{const t=c(e,r);if(!p(t)||!$(t).isDirectory())return!1;const s=[];return S(t,s),s.some(n=>ce(b(n,"utf8")))},Ee=(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"\``)],Re=(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 — ${de}`],[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),Ne=(e,r,t,s=[],n=[],a=[])=>{const o=new Set(e.map(d=>d.className)),i=e.map(d=>`${d.binding}/${d.className} (exported by worker entry)`);return r&&i.push("DB (.global() table declared)"),i.push(...Ee(s,n,a),...Re(t,o)),i},Pe=async e=>{await C;const r=e.schemaDir??"lunora",t=e.scanDirs??J,s=we(e.projectRoot,t),n={...s,usesBrowser:s.usesBrowser||ve(e.projectRoot,r)},a=fe(e.projectRoot),o=a?ge(a):[],i=n.needsD1||Se(e.projectRoot,r),d=y(a,K(e.projectRoot,r).containers,"containers"),w=y(a,U(e.projectRoot,r).workflows,"workflows"),v=y(a,P(e.projectRoot,r).agents,"agents"),B=[...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 N of l)E[N]=n[N];const R=Ne(o,i,n,d,w,v);return h!==void 0&&R.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:d,durableObjects:o,flagshipBinding:h,needsD1:i,queues:B,signals:R,usesFlags:m!==void 0,workflows:w,...E}},Le=e=>{const r=[];for(const t of l)e[t]&&r.push(g[t].source);return r};export{V as WORKER_ENTRY_FALLBACKS,Pe as inferLunoraBindings,ye as isTypeOnlyExportEntry,Le as packageNamesFromBindings,fe as resolveWorkerEntry};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
const o=n=>JSON.stringify(n),y=/^[A-Z_a-z][\w$]*$/u,l=n=>y.test(n),p=n=>l(n)?n:`binding_${n.replaceAll(/\W/gu,"_")}`,m=(n,i=p(n))=>{const t=l(n);return t&&i===n?`${n},`:`${t?n:o(n)}: ${i},`},_=n=>{const i=new Set;for(const t of n.migrations??[])for(const s of t.new_sqlite_classes??[])i.add(s);return i},$=(n,i,t,s,r)=>{for(const a of n.durable_objects?.bindings??[])if(!(a.name===void 0||a.class_name===void 0)){if(a.script_name!==void 0){r.push(`durable_objects.${a.name} (external script_name "${a.script_name}")`);continue}t.add("DurableObjectNamespace"),s.push(m(a.name,`DurableObjectNamespace(${o(a.name)}, { className: ${o(a.class_name)}, sqlite: ${String(i.has(a.class_name))} })`))}},v=(n,i)=>{for(const[t,s]of Object.entries(n.vars??{}))i.push(m(t,o(String(s))))},h=(n,i)=>{for(const[t,s]of[["ai","ai"],["analytics_engine_datasets","analytics_engine_datasets"],["browser","browser"],["containers","containers"],["hyperdrive","hyperdrive"],["images","images"],["pipelines","pipelines"],["vectorize","vectorize"],["workflows","workflows"]]){const r=n[t];r!==void 0&&(!Array.isArray(r)||r.length>0)&&i.push(s)}},w=n=>{const i=n.name??"worker",t=[],s=new Set(["Worker"]),r=[],a=[],g=_(n),b=[{construct:"D1Database",entries:(n.d1_databases??[]).map(e=>({binding:e.binding,name:e.database_name})),nameKey:"name"},{construct:"R2Bucket",entries:(n.r2_buckets??[]).map(e=>({binding:e.binding,name:e.bucket_name})),nameKey:"name"},{construct:"KVNamespace",entries:(n.kv_namespaces??[]).map(e=>({binding:e.binding,name:e.binding})),nameKey:"title"},{construct:"Queue",entries:(n.queues?.producers??[]).map(e=>({binding:e.binding,name:e.queue})),nameKey:"name"}];for(const{construct:e,entries:d,nameKey:f}of b)for(const c of d)c.binding!==void 0&&(s.add(e),r.push(`const ${p(c.binding)} = await ${e}(${o(c.binding)}, { adopt: true, ${f}: ${o(c.name??c.binding)} });`),a.push(m(c.binding)));$(n,g,s,a,t),v(n,a),h(n,t);const u=["adopt: true,",a.length===0?void 0:`bindings: {
|
|
2
|
+
${a.join(`
|
|
3
|
+
`)}
|
|
4
|
+
},`,n.compatibility_date===void 0?void 0:`compatibilityDate: ${o(n.compatibility_date)},`,n.compatibility_flags===void 0||n.compatibility_flags.length===0?void 0:`compatibilityFlags: ${o([...n.compatibility_flags])},`,n.triggers?.crons===void 0||n.triggers.crons.length===0?void 0:`crons: ${o([...n.triggers.crons])},`,n.main===void 0?void 0:`entrypoint: ${o(n.main)},`,`name: ${o(i)},`].filter(e=>e!==void 0);return{source:["// GENERATED by @lunora/config from wrangler.jsonc — do not edit.","// Re-generated on every `lunora deploy`; edit wrangler.jsonc instead.","",'import alchemy from "alchemy";',`import { ${[...s].toSorted((e,d)=>e.localeCompare(d)).join(", ")} } from "alchemy/cloudflare";`,"",`const app = await alchemy(${o(i)});`,"",...r.length===0?[]:[...r,""],`export const worker = await Worker(${o(i)}, {`,` ${u.join(`
|
|
5
|
+
`)}`,"});","","await app.finalize();",""].join(`
|
|
6
|
+
`),unsupported:t}};export{_ as sqliteClasses,w as wranglerToAlchemy};
|
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.122",
|
|
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.
|
|
58
|
-
"@lunora/container": "1.0.0-alpha.
|
|
59
|
-
"@lunora/errors": "1.0.0-alpha.
|
|
60
|
-
"@lunora/seed": "1.0.0-alpha.
|
|
57
|
+
"@lunora/codegen": "1.0.0-alpha.93",
|
|
58
|
+
"@lunora/container": "1.0.0-alpha.24",
|
|
59
|
+
"@lunora/errors": "1.0.0-alpha.15",
|
|
60
|
+
"@lunora/seed": "1.0.0-alpha.63",
|
|
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
|
-
const f=1,c=new Set(["$schema","account_id","compatibility_date","compatibility_flags","keep_vars","main","migrations","minify","name","observability","placement","routes","rules","triggers","upload_source_maps","vars","workers_dev"]),u=e=>{const s=new Set;for(const o of e.migrations??[])for(const n of o.new_sqlite_classes??[])s.add(n);return s},l=e=>Object.fromEntries(Object.entries(e).filter(([,s])=>s!==void 0)),a=[{bindingKey:"binding",field:"analytics_engine_datasets",resourceKey:"dataset",type:"analytics_engine"},{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:"pipeline",type:"pipeline"},{bindingKey:"binding",field:"r2_buckets",resourceKey:"bucket_name",type:"r2"},{bindingKey:"binding",field:"vectorize",resourceKey:"index_name",type:"vectorize"},{bindingKey:"binding",field:"workflows",resourceKey:"name",type:"workflow"}],d=[{field:"ai",type:"ai"},{field:"assets",type:"assets"},{field:"browser",type:"browser"},{field:"images",type:"images"}],p=new Set([...a.map(e=>e.field),...d.map(e=>e.field),"durable_objects","queues"]),r=(e,s)=>{const o=s===void 0?void 0:e[s];return typeof o=="string"&&o!==""?o:void 0},b=(e,s)=>{const o=[];for(const n of a)for(const i of e[n.field]??[]){const t=r(i,n.bindingKey);if(t===void 0){s.push(n.field);continue}o.push({binding:t,className:r(i,"class_name"),resource:r(i,n.resourceKey),resourceId:r(i,n.resourceIdKey),type:n.type})}return o},y=(e,s)=>{const o=u(e),n=[];for(const i of e.durable_objects?.bindings??[]){if(i.name===void 0||i.name===""){s.push("durable_objects");continue}n.push({binding:i.name,className:i.class_name,sqlite:i.script_name===void 0&&i.class_name!==void 0?o.has(i.class_name):void 0,type:"durable_object"})}return n},m=(e,s)=>{const o=[];for(const n of e.queues?.producers??[]){if(n.binding===void 0||n.binding===""){s.push("queues.producers");continue}o.push({binding:n.binding,resource:n.queue,type:"queue_producer"})}for(const n of e.queues?.consumers??[]){if(n.queue===void 0||n.queue===""){s.push("queues.consumers");continue}o.push({binding:n.queue,resource:n.queue,type:"queue_consumer"})}return o},g=(e,s)=>[...b(e,s),...y(e,s),...m(e,s),...d.filter(o=>e[o.field]?.binding!==void 0).map(o=>({binding:e[o.field]?.binding,type:o.type}))],_=e=>{const s=[],o=g(e,s).map(i=>l(i)).toSorted((i,t)=>i.type.localeCompare(t.type)||i.binding.localeCompare(t.binding)),n=[...Object.keys(e).filter(i=>!c.has(i)&&!p.has(i)),...s.map(i=>`${i} (entry with no binding name)`)].toSorted((i,t)=>i.localeCompare(t));return{bindings:o,...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:n,vars:Object.keys(e.vars??{}).toSorted((i,t)=>i.localeCompare(t)),version:1}};export{f as BINDING_MANIFEST_VERSION,_ as buildBindingManifest};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{existsSync as m,readFileSync as k}from"node:fs";import{dirname as w,join as g}from"node:path";import{WORKER_ENTRY_FALLBACKS as M}from"./inferLunoraBindings-tf2nExl_.mjs";import{discoverSchemaInfo as q}from"./discoverSchemaInfo-C8X9mo-i.mjs";import{isCacheEnabled as O,WORKERS_CACHE_MIN_DATE as f}from"./WORKERS_CACHE_MIN_DATE-B1h_wNDN.mjs";import{findWranglerFile as R,readWranglerJsonc as x}from"./WRANGLER_FILES-Bi_18Pj6.mjs";const h="2026-04-07",Oe="web_socket_auto_reply_to_close",y=/^\d{4}-\d{2}-\d{2}$/,v=["d1_databases","durable_objects","kv_namespaces","queues","r2_buckets","secrets_store_secrets","services","tail_consumers","vars","vectorize","workflows"],_=["assets","compatibility_date","exports","logpush","main","migrations","observability","placement"],j=(e,s)=>{if(s===void 0)return{merged:e,unverifiedKeys:[]};const t=e.env?.[s];if(t===void 0){const c=Object.keys(e.env??{}).toSorted((d,l)=>d.localeCompare(l)),o=c.length>0?` (declared: ${c.join(", ")}).`:" (no environments are declared).";return{error:`--env "${s}" names no environment declared in wrangler.jsonc's "env" block${o}`,merged:e,unverifiedKeys:[]}}const n={...e},r=Object.keys(t).filter(c=>c!=="env");for(const c of r)_.includes(c)&&(n[c]=t[c]);for(const c of v)n[c]=t[c];const a=new Set([...v,..._]),i=r.filter(c=>!a.has(c)).map(String);return{merged:n,unverifiedKeys:i}},E=(e,s,t)=>{if(s.length===0)return;const n=e.vectorize??[],r=new Set(n.filter(Boolean).map(a=>a?.index_name));for(const a of s)r.has(a)||t.push(`schema declares vector index "${a}"; wrangler "vectorize" must include a binding with index_name "${a}"`)},D=new Set(["basic","dev","lite","standard","standard-1","standard-2","standard-3","standard-4"]),L={disk_mb:2e4,memory_mib:12288,vcpu:4},W=(e,s,t)=>{const n=e.instance_type;if(n===void 0)return;if(typeof n=="string"){D.has(n)||t.push(`${s} has unknown instance_type "${n}" — expected lite, basic, standard-1..4, or a custom { vcpu, memory_mib, disk_mb } object`);return}for(const[c,o]of Object.entries(L)){const d=n[c];d!==void 0&&(typeof d!="number"||d<=0||d>o)&&t.push(`${s} custom instance_type ${c} must be a positive number ≤ ${String(o)} (got ${String(d)})`)}const{disk_mb:r,memory_mib:a,vcpu:i}=n;if(typeof i=="number"&&typeof a=="number"&&a<i*3072&&t.push(`${s} custom instance_type needs ≥ 3 GiB (3072 MiB) memory per vCPU (got ${String(a)} MiB for ${String(i)} vCPU)`),typeof a=="number"&&typeof r=="number"){const c=Math.floor(a/1024*2e3);r>c&&t.push(`${s} custom instance_type allows ≤ 2 GB disk per GiB memory (≤ ${String(c)} MB for ${String(a)} MiB memory; got ${String(r)} MB)`)}},C=(e,s,t)=>{const{boundClasses:n,errors:r,nonSqliteClasses:a,sqliteClasses:i,warnings:c}=t;if(!e||typeof e!="object"||typeof e.class_name!="string"||e.class_name.length===0){r.push(`${s} must have a non-empty "class_name" naming its container-enabled Durable Object class`);return}(typeof e.image!="string"||e.image.length===0)&&r.push(`${s} ("${e.class_name}") must have an "image" — a Dockerfile path or a registry reference`),n.has(e.class_name)||r.push(`${s} class "${e.class_name}" has no matching durable_objects binding — run \`lunora dev\` to auto-reconcile wrangler.jsonc, or add { "name": "...", "class_name": "${e.class_name}" }`),i.has(e.class_name)||r.push(a.has(e.class_name)?`${s} class "${e.class_name}" is registered via "new_classes" but containers require SQLite-backed DOs — move it to "new_sqlite_classes"`:`${s} class "${e.class_name}" is missing from migrations — add a migration entry with "new_sqlite_classes": ["${e.class_name}"]`),W(e,`${s} ("${e.class_name}")`,r),e.max_instances===void 0&&c.push(`${s} ("${e.class_name}") declares no max_instances — set a cap so a traffic spike can't fan out unbounded container spend`)},p=e=>Array.isArray(e)?e.filter(s=>s!==null&&typeof s=="object"):[],N=(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 r=new Set(p(e.durable_objects?.bindings).map(o=>o.class_name)),a=e.migrations??[],i=new Set(a.flatMap(o=>[...o?.new_sqlite_classes??[]])),c=new Set(a.flatMap(o=>[...o?.new_classes??[]]));for(const[o,d]of n.entries())C(d,`containers[${String(o)}]`,{boundClasses:r,errors:s,nonSqliteClasses:c,sqliteClasses:i,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 } })')},I=(e,s)=>{if(e.workflows===void 0)return;if(!Array.isArray(e.workflows)){s.push("workflows must be an array of { name, binding, class_name } entries");return}const t=e.workflows;for(const[n,r]of t.entries()){const a=`workflows[${String(n)}]`;if(!r||typeof r!="object"){s.push(`${a} must be a { name, binding, class_name } object`);continue}(typeof r.binding!="string"||r.binding.length===0)&&s.push(`${a} must have a non-empty "binding" naming the Workflow binding (e.g. WORKFLOW_ORDER_PIPELINE)`),(typeof r.class_name!="string"||r.class_name.length===0)&&s.push(`${a} must have a non-empty "class_name" naming the exported WorkflowEntrypoint class`),(typeof r.name!="string"||r.name.length===0)&&s.push(`${a} must have a non-empty "name" naming the deployed workflow`)}},B=(e,s)=>{if(e===void 0)return;if(!Array.isArray(e)){s.push("queues.producers must be an array of { binding, queue } entries");return}const t=e;for(const[n,r]of t.entries()){const a=`queues.producers[${String(n)}]`;if(!r||typeof r!="object"){s.push(`${a} must be a { binding, queue } object`);continue}(typeof r.binding!="string"||r.binding.length===0)&&s.push(`${a} must have a non-empty "binding" naming the Queue producer (e.g. QUEUE_EMAIL)`),(typeof r.queue!="string"||r.queue.length===0)&&s.push(`${a} must have a non-empty "queue" naming the deployed queue`)}},F=(e,s)=>{if(e===void 0)return;if(!Array.isArray(e)){s.push("queues.consumers must be an array of { queue } entries");return}const t=e;for(const[n,r]of t.entries()){const a=`queues.consumers[${String(n)}]`;if(!r||typeof r!="object"){s.push(`${a} must be a { queue } object`);continue}(typeof r.queue!="string"||r.queue.length===0)&&s.push(`${a} must have a non-empty "queue" naming the consumed queue`)}},P=(e,s)=>{if(e.queues!==void 0){if(typeof e.queues!="object"||Array.isArray(e.queues)){s.push("queues must be a { producers, consumers } object");return}B(e.queues.producers,s),F(e.queues.consumers,s)}},T=(e,s)=>{if(e.secrets_store_secrets===void 0)return;if(!Array.isArray(e.secrets_store_secrets)){s.push("secrets_store_secrets must be an array of { binding, store_id, secret_name } entries");return}const t=e.secrets_store_secrets;for(const[n,r]of t.entries()){const a=`secrets_store_secrets[${String(n)}]`;if(!r||typeof r!="object"){s.push(`${a} must be a { binding, store_id, secret_name } object`);continue}for(const i of["binding","store_id","secret_name"])(typeof r[i]!="string"||r[i].length===0)&&s.push(`${a} must have a non-empty "${i}"`)}},b=e=>typeof e=="string"&&e.length>0,A=e=>e,U=[{arrayMessage:"kv_namespaces must be an array of { binding, id } entries",bindingMessage:e=>`${e} must have a non-empty "binding" naming the KV namespace binding`,hintField:"id",hintMessage:(e,s)=>`${e} ("${s}") has no "id" — run \`wrangler kv namespace create\` and set the namespace id, or the binding can't resolve`,key:"kv_namespaces"},{arrayMessage:"flagship must be an array of { binding, app_id } entries",bindingMessage:e=>`${e} must have a non-empty "binding" naming the Flagship binding`,hintField:"app_id",hintMessage:(e,s)=>`${e} ("${s}") has no "app_id" — create a Flagship app and set its id, or the binding can't resolve`,key:"flagship"},{arrayMessage:"hyperdrive must be an array of { binding, id } entries",bindingMessage:e=>`${e} must have a non-empty "binding" naming the Hyperdrive binding`,hintField:"id",hintMessage:(e,s)=>`${e} ("${s}") has no "id" — run \`wrangler hyperdrive create\` and set the id, or the binding can't connect`,key:"hyperdrive"},{arrayMessage:"pipelines must be an array of { binding, stream } entries",bindingMessage:e=>`${e} must have a non-empty "binding" naming the Pipelines binding`,hintField:["stream","pipeline"],hintMessage:(e,s)=>`${e} ("${s}") has no "stream" — run \`wrangler pipelines create <name>\` and set the stream name, or the binding can't resolve`,key:"pipelines"},{arrayMessage:"analytics_engine_datasets must be an array of { binding, dataset } entries",bindingMessage:e=>`${e} must have a non-empty "binding" naming the Analytics Engine binding`,hintField:"dataset",hintMessage:(e,s)=>`${e} ("${s}") has no "dataset" — it defaults to the binding name; set it explicitly to avoid drift`,key:"analytics_engine_datasets"}],K=(e,s,t,n)=>{const r=e[s.key];if(r!==void 0){if(!Array.isArray(r)){t.push(s.arrayMessage);return}for(const[a,i]of A(r).entries()){const c=`${s.key}[${String(a)}]`;if(!i||typeof i!="object"||!b(i.binding)){t.push(s.bindingMessage(c));continue}(typeof s.hintField=="string"?[s.hintField]:s.hintField).some(o=>b(i[o]))||n.push(s.hintMessage(c,i.binding))}}},G=[{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" })'}],Y=(e,s,t)=>{const n=e[s.key];n!==void 0&&(typeof n!="object"||Array.isArray(n)||!b(n.binding))&&t.push(s.message)},z=[{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`}],H=(e,s,t)=>{const n=e[s.key];if(n!==void 0){if(!Array.isArray(n)){t.push(s.arrayMessage);return}for(const[r,a]of A(n).entries()){const i=`${s.key}[${String(r)}]`;if(!a||typeof a!="object"){t.push(s.objectMessage(i));continue}for(const c of s.fields)b(a[c.field])||t.push(c.message(i))}}},Q=(e,s,t)=>{const n=e.send_email;if(n===void 0)return;if(!Array.isArray(n)){s.push("send_email must be an array of { name, destination_address? } entries");return}const r=n;for(const[a,i]of r.entries())(!i||typeof i!="object"||typeof i.name!="string"||i.name.length===0)&&t.push(`send_email[${String(a)}] has no non-empty "name" naming the send-email binding — set one before deploying`)},J=(e,s)=>{e.logpush!==void 0&&typeof e.logpush!="boolean"&&s.push('logpush must be a boolean (set "logpush": true to enable Cloudflare Logpush)')},V=(e,s)=>{const{placement:t}=e;if(t!==void 0){if(typeof t!="object"||Array.isArray(t)){s.push('placement must be an object (e.g. { "mode": "smart" })');return}t.mode!==void 0&&t.mode!=="smart"&&s.push('placement.mode must be "smart" (the only supported Smart Placement mode)')}},Z=(e,s)=>{const{observability:t}=e;if(t===void 0)return;if(typeof t!="object"||Array.isArray(t)){s.push('observability must be an object (e.g. { "enabled": true, "head_sampling_rate": 1 })');return}const n=(r,a)=>{r!==void 0&&(typeof r!="number"||Number.isNaN(r)||r<0||r>1)&&s.push(`${a} must be a number in [0, 1] (the fraction of requests sampled)`)};n(t.head_sampling_rate,"observability.head_sampling_rate"),t.logs!==void 0&&(typeof t.logs!="object"||Array.isArray(t.logs)?s.push("observability.logs must be an object"):n(t.logs.head_sampling_rate,"observability.logs.head_sampling_rate"))},X=(e,s)=>{const{cache:t}=e;if(t!==void 0){if(typeof t!="object"||t===null||Array.isArray(t)){s.push('cache must be an object (e.g. { "enabled": true })');return}t.enabled!==void 0&&typeof t.enabled!="boolean"&&s.push("cache.enabled must be a boolean (true or false)")}},ee=(e,s)=>{const{exports:t}=e;if(t!==void 0){if(typeof t!="object"||t===null||Array.isArray(t)){s.push("exports must be an object keyed by entrypoint name");return}for(const[n,r]of Object.entries(t)){if(typeof r!="object"||r===null){s.push(`exports["${n}"] must be an object`);continue}r.type!==void 0&&typeof r.type!="string"&&s.push(`exports["${n}"].type must be a string`),r.cache!==void 0&&(typeof r.cache!="object"||r.cache===null||Array.isArray(r.cache)?s.push(`exports["${n}"].cache must be an object`):r.cache.enabled!==void 0&&typeof r.cache.enabled!="boolean"&&s.push(`exports["${n}"].cache.enabled must be a boolean`))}}},se=(e,s)=>{const{assets:t}=e;if(t!==void 0){if(typeof t!="object"||Array.isArray(t)){s.push('assets must be an object (e.g. { "directory": "./dist/client", "binding": "ASSETS" })');return}(typeof t.directory!="string"||t.directory.length===0)&&s.push('assets must declare a non-empty "directory" pointing at the built client output (e.g. "./dist/client")'),t.binding!==void 0&&(typeof t.binding!="string"||t.binding.length===0)&&s.push('assets.binding must be a non-empty string (e.g. "ASSETS")'),t.html_handling!==void 0&&typeof t.html_handling!="string"&&s.push("assets.html_handling must be a string"),t.not_found_handling!==void 0&&typeof t.not_found_handling!="string"&&s.push("assets.not_found_handling must be a string")}},te=(e,s)=>{const t=e.tail_consumers;if(t===void 0)return;if(!Array.isArray(t)){s.push("tail_consumers must be an array of { service, environment? } entries");return}const n=t;for(const[r,a]of n.entries())(!a||typeof a!="object"||typeof a.service!="string"||a.service.length===0)&&s.push(`tail_consumers[${String(r)}] must have a non-empty "service" naming the consumer Worker`)},Re=(e,s)=>{const t=e.tail_consumers??[];return t.some(n=>!!n&&n?.service===s.service&&n?.environment===s.environment)?e:{...e,tail_consumers:[...t,s]}},ne=new Set(["1","enabled","on","true","yes"]),re=(e,s)=>{const{vars:t}=e;if(!t||typeof t!="object")return;const n=t.LUNORA_ALLOWED_ORIGINS,r=t.LUNORA_CORS_ALLOW_CREDENTIALS,a=typeof n=="string"&&n.split(",").some(c=>c.trim()==="*"),i=typeof r=="string"&&ne.has(r.trim().toLowerCase());a&&i&&s.push('vars.LUNORA_ALLOWED_ORIGINS includes a "*" wildcard while vars.LUNORA_CORS_ALLOW_CREDENTIALS is on — browsers reject this combination and it defeats the allowlist; name explicit origins or drop credentials')},ae=(e,s,t)=>{const{error:n,merged:r,unverifiedKeys:a}=j(e,s);return n!==void 0?{error:n,wrangler:r}:(a.length>0&&t.push(`env.${String(s)} overrides ${a.join(", ")}, which this validator doesn't have a verified inheritance rule for — validated against the TOP-LEVEL value only. Double-check ${a.length===1?"it":"them"} by hand for "${String(s)}".`),{wrangler:r})},S=(e,s,t)=>{const n=[],r=[];if(!e||typeof e!="object")return n.push("wrangler config is not a valid object"),{errors:n,valid:!1,warnings:r};const{error:a,wrangler:i}=ae(e,t,r);if(a!==void 0)return n.push(a),{errors:n,valid:!1,warnings:r};p(i.durable_objects?.bindings).find(o=>o.name==="SHARD"&&o.class_name==="ShardDO")||n.push('durable_objects.bindings must include { "name": "SHARD", "class_name": "ShardDO" } — run `lunora dev` to auto-reconcile wrangler.jsonc, or add the binding manually');const c=i.compatibility_date??"";c&&!y.test(c)?n.push(`compatibility_date must be in YYYY-MM-DD format (got "${c}")`):c<h&&n.push(`compatibility_date must be >= "${h}" (got "${c||"<missing>"}")`),O(i)&&y.test(c)&&c<f&&n.push(`cache.enabled requires compatibility_date >= "${f}" (got "${c||"<missing>"}")`),s?.hasGlobalTable&&(p(i.d1_databases).find(o=>o.binding==="DB")||n.push('schema declares .global() tables; d1_databases must include a binding named "DB" — run `lunora dev` to auto-reconcile wrangler.jsonc, or add the binding manually')),E(i,s?.vectorIndexNames??[],n),te(i,n),N(i,n,r),I(i,n),P(i,n),T(i,n);for(const o of U)K(i,o,n,r);for(const o of z)H(i,o,n);for(const o of G)Y(i,o,n);return Q(i,n,r),J(i,n),V(i,n),Z(i,n),se(i,n),X(i,n),ee(i,n),re(i,n),{errors:n,valid:n.length===0,warnings:r}},xe=S,ie=(e,s,t)=>{const n=[];for(const r of e){const a=r?.image;typeof a!="string"||!(a.startsWith("./")||a.startsWith("../")||a.startsWith("/")||a.includes("Dockerfile"))||m(a.startsWith("/")?a:g(s,a))||n.push(`containers image "${a}" does not exist (resolved relative to ${t}); create the Dockerfile or point image at a registry reference`)}return n},oe=(e,s,t)=>{if(typeof e=="string"&&e.length>0){const n=g(w(t),e);return m(n)?n:void 0}return M.map(n=>g(s,n)).find(n=>m(n))},ce=/\/\/[^\n]*|\/\*.*?\*\/|"[^"\n]*"|'[^'\n]*'|`[^`]*`/gsu,de=e=>e.replaceAll(ce,s=>s.replaceAll(/[^\n]/gu," ")),le=/\bexport\s*\*\s*(?:as\s+\w+\s*)?from\b/u,ue=/\bexport\b/gu,me=/^\s*(?:(?:abstract|async|declare|default)\s+)*/u,ge=/^(?:class|const|function|let|var)\s+(?<name>[$A-Z_a-z][\w$]*)/u,pe=/^\s*(?:const|let|var)\s*\{/u,be=/^[$A-Z_a-z][\w$]*/u,fe=/^type\b/u,he=/\s+/u,ye=e=>{const s=[];for(const t of e.split(",")){const n=t.trim().split(he).filter(Boolean),r=n.at(-1);r!==void 0&&n[0]!=="type"&&s.push(r)}return s},ve=e=>{const s=[];for(const t of e.split(",")){const n=t.includes(":")?t.slice(t.indexOf(":")+1):t,r=be.exec(n.trim());r&&s.push(r[0])}return s},$=e=>{const s=e.indexOf("{"),t=e.indexOf("}",s);return s===-1||t===-1?void 0:e.slice(s+1,t)},_e=e=>{const s=e.trimStart();if(fe.test(s))return[];if(s.startsWith("{")){const n=$(s);return n===void 0?[]:ye(n)}if(pe.test(e)){const n=$(e);return n===void 0?[]:ve(n)}const t=ge.exec(e.replace(me,""));return t?.groups?.name===void 0?[]:[t.groups.name]},$e=e=>{const s=new Set;for(const t of e.matchAll(ue))for(const n of _e(e.slice(t.index+6)))s.add(n);return s},we=(e,s,t)=>{const n=oe(e.main,s,t);if(n===void 0)return[];let r;try{r=k(n,"utf8")}catch{return[]}const a=de(r);if(le.test(a))return[];const i=[];for(const o of p(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=$e(a);return i.filter(o=>!c.has(o.className)).map(o=>`${o.label} declares class "${o.className}" but the worker entry (${n}) does not export it — wrangler refuses to bundle a Worker whose Durable Object classes are not exported. Add \`export { ${o.className} } from "…";\` to the entry.`)},Ee=e=>{const s=e.schemaDir??"lunora",t=R(e.projectRoot);if(!t){const u=`wrangler.jsonc not found in ${e.projectRoot}; create one declaring at least the SHARD durable object binding.`;return{problems:[u],report:{errors:[u],valid:!1,warnings:[]},wranglerPath:void 0}}const{parsed:n}=x(t);if(n===void 0){const u=`failed to parse ${t} as JSONC.`;return{problems:[u],report:{errors:[u],valid:!1,warnings:[]},wranglerPath:t}}const{error:r,merged:a}=j(n,e.environment);if(r!==void 0)return{problems:[r],report:{errors:[r],valid:!1,warnings:[]},wranglerPath:t};const{error:i,info:c}=q(e.projectRoot,s),o=S(n,c,e.environment);i!==void 0&&o.warnings.push(`schema parse failed in ${s}/schema.ts: ${i}`);const d=w(t);o.errors.push(...ie(a.containers??[],d,t)),o.warnings.push(...we(a,e.projectRoot,t));const l=a.assets?.directory;if(typeof l=="string"&&l.length>0){const u=l.startsWith("/")?l:g(d,l);m(u)||o.warnings.push(`assets.directory "${l}" does not exist yet — it is created by the client build; run the build before deploy`)}return o.valid=o.errors.length===0,{problems:o.errors,report:o,wranglerPath:t}};export{h as REQUIRED_COMPATIBILITY_DATE,Oe as REQUIRED_FLAG,xe as validateWrangler,S as validateWranglerConfig,Ee as validateWranglerProject,Re as withTailConsumer};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import{randomBytes as R}from"node:crypto";import{existsSync as p,readFileSync as f,writeFileSync as g,renameSync as $,rmSync as y,statSync as L}from"node:fs";import{join as h}from"node:path";import{LunoraError as z}from"@lunora/errors";import{DEV_VARS_FILE as l,DEV_VARS_EXAMPLE_FILE as m,splitDevVariableLine as K,parseDevVariableEntries as S,DEV_VARS_NEWLINE as k,unquoteDevVariable as A}from"./DEV_VARS_EXAMPLE_FILE-BL0hrPx3.mjs";import{CORE_SECRETS as E,PACKAGE_SECRETS_REGISTRY as F,secretsForPackages as W}from"./PACKAGE_SECRETS_REGISTRY-BgmvEPA-.mjs";const H=e=>[...E,...W(e)],v=32,b=/(?:KEY|PASSWORD|SECRET|TOKEN)$/u,M=["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"],P=/[.*+?^${}()|[\]\\]/gu,T=/[a-z0-9]$/u,N=e=>{const t=e.trim().toLowerCase();return t===""||t.startsWith("<")&&t.endsWith(">")?!0:M.some(n=>{const r=n.replaceAll(P,String.raw`\$&`),s=T.test(n)?`(^|[^a-z0-9])${r}([^a-z0-9]|$)`:`(^|[^a-z0-9])${r}`;return new RegExp(s,"u").test(t)})},G=e=>N(A(e.trim())),x=e=>R(e).toString("hex"),I=new Set([...E,...Object.values(F).flat()].filter(e=>b.test(e.key)&&e.placeholderValue.startsWith("<")).map(e=>e.key)),O=e=>b.test(e)&&!I.has(e),w=(e,t,n)=>O(e)&&G(t)?n(v):void 0,ae=(e=x)=>e(v),q=e=>{if(e.devVarsExists)return{status:"exists"};if(e.exampleContent===void 0)return{status:"no-example"};const t=e.randomHex??x,n=[];return{content:e.exampleContent.split(k).map(r=>{const s=K(r),i=s?w(s.key,s.value,t):void 0;return!s||i===void 0?r:(n.push(s.key),`${s.key}="${i}"`)}).join(`
|
|
2
|
-
`),generatedKeys:n,status:"generate"}},C=e=>{const t=e.randomHex??x,n=new Set(S(e.existingContent).map(c=>c.key)),r=[],s=[],i=[];for(const c of e.exampleContent.split(k)){const o=K(c);if(!o||n.has(o.key))continue;const a=w(o.key,o.value,t);i.push(o.key),a===void 0?r.push(`${o.key}="${A(o.value)}"`):(s.push(o.key),r.push(`${o.key}="${a}"`))}return{additions:r,generatedKeys:s,missingKeys:i}},_=e=>e.length>0?` (generated ${e.join(", ")})`:"",ie=(e,t)=>{const n=`${e}.tmp-${String(process.pid)}`;try{g(n,t,{encoding:"utf8",mode:384}),$(n,e)}catch(r){throw y(n,{force:!0}),r}},B=(e,t)=>{const n=`${e}.tmp-${String(process.pid)}`;try{g(n,t,{encoding:"utf8",flag:"wx",mode:384}),$(n,e)}catch(r){throw y(n,{force:!0}),r}},D=5,j=e=>{try{const t=L(e);return{mtimeMs:t.mtimeMs,size:t.size}}catch{return}},U=(e,t)=>e===void 0||t===void 0?!1:e.mtimeMs===t.mtimeMs&&e.size===t.size,Y=(e,t)=>{for(let n=0;n<D;n+=1){const r=j(e),s=f(e,"utf8"),i=t(s);if(i.length===0)return[];const c=s.length>0&&!s.endsWith(`
|
|
3
|
-
`)?`
|
|
4
|
-
`:"",o=`${s}${c}${i.join(`
|
|
5
|
-
`)}
|
|
6
|
-
`,a=`${e}.tmp-${String(process.pid)}-${R(6).toString("hex")}`;try{g(a,o,{encoding:"utf8",mode:384});const d=j(e);if(!U(r,d)){y(a,{force:!0});continue}return $(a,e),i}catch(d){throw y(a,{force:!0}),d}}throw new z("INTERNAL",`Failed to append to ${e} after ${String(D)} attempts — a concurrent writer kept winning the race.`)},oe=async e=>{const t=h(e.cwd,l),n=h(e.cwd,m);if(!p(n))return{addedKeys:[],generatedKeys:[],status:"no-example"};const r=f(n,"utf8");if(!p(t)){const a=q({devVarsExists:!1,exampleContent:r,randomHex:e.randomHex});return a.status!=="generate"?{addedKeys:[],generatedKeys:[],status:"no-example"}:e.yes===!0||await e.confirm(`No ${l} found. Generate it from ${m} (secrets auto-filled)?`)?p(t)?{addedKeys:[],generatedKeys:[],status:"skipped-exists"}:(B(t,a.content),e.info(`Created ${l}${_(a.generatedKeys)}.`),{addedKeys:[],generatedKeys:a.generatedKeys,status:"generated"}):(e.info(`Skipped — copy ${m} to ${l} and fill it in when you're ready.`),{addedKeys:[],generatedKeys:[],status:"declined"})}const s=C({existingContent:f(t,"utf8"),exampleContent:r,randomHex:e.randomHex});if(s.missingKeys.length===0)return{addedKeys:[],generatedKeys:[],status:"exists"};const i=s.missingKeys.join(", ");if(!(e.yes===!0||await e.confirm(`${l} is missing ${String(s.missingKeys.length)} key(s) from ${m} (${i}). Add them?`)))return e.info(`Skipped — add ${i} to ${l} when you're ready.`),{addedKeys:[],generatedKeys:[],status:"declined"};const c=Y(t,a=>C({existingContent:a,exampleContent:r,randomHex:e.randomHex}).additions).map(a=>K(a)?.key).filter(a=>a!==void 0);if(c.length===0)return{addedKeys:[],generatedKeys:[],status:"exists"};const o=s.generatedKeys.filter(a=>c.includes(a));return e.info(`Updated ${l} — added ${c.join(", ")}${_(o)}.`),{addedKeys:c,generatedKeys:o,status:"augmented"}},X=e=>[`# ${e.description}`,`# Docs: ${e.docsUrl}`,`${e.key}="${e.placeholderValue}"`].join(`
|
|
7
|
-
`),J=(e,t)=>{const n=H(e).filter(r=>!t.has(r.key));return n.length===0?"":n.map(r=>X(r)).join(`
|
|
8
|
-
|
|
9
|
-
`)},de=(e,t)=>{const n=h(e,m),r=p(n)?f(n,"utf8"):"",s=new Set(S(r).map(d=>d.key)),i=J(t,s);if(i==="")return[];const c=r.length>0&&!r.endsWith(`
|
|
10
|
-
`)?`
|
|
11
|
-
`:"",o=`${r}${c}
|
|
12
|
-
${i}
|
|
13
|
-
`,a=`${n}.tmp-${String(process.pid)}`;try{g(a,o,{encoding:"utf8"}),$(a,n)}catch(d){throw y(a,{force:!0}),d}return H(t).filter(d=>!s.has(d.key)).map(d=>d.key)},Q=e=>{const t=e.randomHex??x,n=[],r=e.existingContent.split(k).map(d=>{const u=K(d),V=u?w(u.key,u.value,t):void 0;return!u||V===void 0?d:(n.push(u.key),`${u.key}="${V}"`)}),s=new Set(S(e.existingContent).map(d=>d.key)),i=[],c=[];for(const d of E)s.has(d.key)||(i.push(d.key),c.push(`# ${d.description}`,`${d.key}="${t(v)}"`));const o=r.join(`
|
|
14
|
-
`);if(c.length===0)return{addedKeys:i,content:o,filledKeys:n};const a=o===""||o.endsWith(`
|
|
15
|
-
`)?"":`
|
|
16
|
-
`;return{addedKeys:i,content:`${o}${a}${c.join(`
|
|
17
|
-
`)}
|
|
18
|
-
`,filledKeys:n}},ce=e=>{const t=h(e.cwd,l),n=p(t),r=n?f(t,"utf8"):"",s=Q({existingContent:r,randomHex:e.randomHex});if(s.filledKeys.length===0&&s.addedKeys.length===0)return{addedKeys:[],filledKeys:[],status:"unchanged"};const i=`${t}.tmp-${String(process.pid)}`;try{g(i,s.content,{encoding:"utf8",mode:384}),$(i,t)}catch(o){throw y(i,{force:!0}),o}const c=[...s.filledKeys,...s.addedKeys];return e.info?.(`Generated ${String(c.length)} dev secret(s) in ${l}: ${c.join(", ")}`),{addedKeys:s.addedKeys,filledKeys:s.filledKeys,status:n?"filled":"created"}};export{J as buildPackageSecretsBlock,oe as ensureDevVariables,de as ensureDevVarsExample,ce as fillDevSecrets,ae as generateSecretValue,O as isMintableSecretKey,N as isPlaceholderValue,Q as planDevSecretsFill,C as planDevVariablesAugment,q as planDevVariablesScaffold,H as requiredSecrets,ie as writeDevVariablesFileAtomically};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{writeFileSync as S,readFileSync as k}from"node:fs";import{join as E}from"node:path";import{containerBuildTag as D}from"@lunora/container";import{DEV_VARS_FILE as A,parseDevVariableEntries as B}from"./DEV_VARS_EXAMPLE_FILE-BL0hrPx3.mjs";import{e as b}from"./jsonc-edit-BZVpxVA0.mjs";import{findWranglerFile as O,readWranglerJsonc as C}from"./WRANGLER_FILES-Bi_18Pj6.mjs";const w="<replace-with-d1-create-id>",R=e=>{const a=[];for(const n of e.containers)n.exported||a.push({className:n.className,exportName:n.exportName,kind:"container",module:"containers"});for(const n of e.workflows)n.exported||a.push({className:n.className,exportName:n.exportName,kind:"workflow",module:"workflows"});for(const n of e.agents)n.exported||a.push({className:n.className,exportName:n.exportName,kind:"agent",module:"agents"});return a},P=(e,a)=>{const n=e.flagshipBinding!==void 0&&!(a?.flagship??[]).some(s=>s.binding===e.flagshipBinding);return[[e.usesKv&&(a?.kv_namespaces?.length??0)===0,"@lunora/bindings/kv is used but no kv_namespaces binding exists; add a kv_namespaces entry ({ binding, id }) and pass env.<BINDING> to createKv() — the namespace id can't be auto-provisioned."],[e.usesHyperdrive&&(a?.hyperdrive?.length??0)===0,"@lunora/hyperdrive is used but no hyperdrive binding exists; run 'wrangler hyperdrive create' and add a 'hyperdrive' binding ({ binding, id }) — the id can't be auto-provisioned."],[e.usesPipelines&&(a?.pipelines?.length??0)===0,"ctx.pipelines is used but no pipelines binding exists; run 'wrangler pipelines create <name>' and add a 'pipelines' binding ({ binding, pipeline }) — the pipeline resource can't be auto-provisioned."],[n,`lunora/flags.ts uses Flagship in binding mode but no flagship binding "${e.flagshipBinding??""}" exists; add a flagship entry ({ binding: "${e.flagshipBinding??""}", app_id }) — the app_id can't be auto-provisioned.`]].filter(([s])=>s).map(([,s])=>s)},T=e=>[[e.usesX402Charge,"@lunora/x402/charge is used; set the recipient wallet address as a [vars] entry (the var name is your choice) and pass it to the charge config — the x402 facilitator settles USDC to that address."],[e.usesX402Pay,"@lunora/x402/pay is used (ActionCtx-only, spends real funds); add a secrets_store_secrets[] binding holding the agent wallet key (binding name == signer.secretName) and pair the pay rail with a spend policy — ctx.secrets reads a Secrets Store binding, not .dev.vars."]].filter(([a])=>a).map(([,a])=>a),_=(e,a,n)=>n.filter(s=>!s.exported).map(s=>`${e} "${s.exportName}" is declared but ${s.className} is not exported by the worker entry; add \`export * from "./lunora/_generated/${a}"\` so its binding can be provisioned.`),N=[{keys:["STRIPE_SECRET_KEY","STRIPE_WEBHOOK_SECRET"],label:"Stripe"},{keys:["POLAR_ACCESS_TOKEN","POLAR_WEBHOOK_SECRET"],label:"Polar"},{keys:["CREEM_API_KEY","CREEM_WEBHOOK_SECRET"],label:"Creem"},{keys:["AUTUMN_SECRET_KEY","AUTUMN_WEBHOOK_SECRET"],label:"Autumn"},{keys:["DODO_PAYMENTS_API_KEY","DODO_PAYMENTS_WEBHOOK_KEY"],label:"Dodo Payments"}],I=()=>N.map(({keys:e,label:a})=>`${e[0]} + ${e[1]} (${a})`).join(" or "),$=e=>{let a;try{a=k(E(e,A),"utf8")}catch{return!1}const n=new Map(B(a).map(s=>[s.key,s.value]));return N.some(({keys:s})=>s.every(r=>(n.get(r)??"")!==""))},v=(e,a,n)=>{const s=new Set(e.durableObjects.map(o=>o.className)),r=[],i=(n?.r2_buckets?.length??0)>0,u=(n?.d1_databases?.some(o=>o.binding==="DB")??!1)||e.needsD1;return e.usesStorage&&!i&&r.push("@lunora/storage is used but R2 bucket bindings have user-defined names; add an r2_buckets entry and pass env.<BINDING> to createStorage()."),e.usesAuth&&!s.has("SessionDO")&&!u&&r.push("@lunora/auth is used but the worker entry exports no SessionDO; sessions are D1-backed, or export SessionDO to enable DO-backed sessions."),e.usesScheduler&&!s.has("SchedulerDO")&&r.push("@lunora/scheduler is used but the worker entry exports no SchedulerDO; export it so the SCHEDULER binding can be provisioned."),r.push(..._("container","containers",e.containers),..._("workflow","workflows",e.workflows),..._("agent","agents",e.agents)),e.containers.length>0&&n?.observability?.enabled===!1&&r.push("containers are declared but observability is explicitly disabled in wrangler.jsonc — container logs will not be captured."),e.usesPayment&&!$(a)&&r.push(`@lunora/payment is used; set one provider's secret pair in .dev.vars — ${I()}.`),r.push(...T(e),...P(e,n)),r},M=e=>{const a=new Set(e.map(s=>s.tag));let n=1;for(;a.has(`v${String(n)}`);)n+=1;return`v${String(n)}`},q=(e,a,n)=>{const s=a.durable_objects?.bindings??[],r=new Set(s.map(c=>c.name)),i=n.filter(c=>!r.has(c.binding));let u=e;const o=[];if(i.length>0){const c=[...s,...i.map(m=>({class_name:m.className,name:m.binding}))];u=b(u,["durable_objects","bindings"],c),o.push(...i.map(m=>`${m.binding}/${m.className}`))}const p=a.migrations??[],l=new Set(p.flatMap(c=>[...c.new_sqlite_classes??[],...c.new_classes??[]])),h=n.map(c=>c.className).filter(c=>!l.has(c));if(h.length>0){const c=[...p,{new_sqlite_classes:h,tag:M(p)}];u=b(u,["migrations"],c)}return{added:o,text:u}},K=(e,a)=>{const n=a.d1_databases??[];if(n.some(i=>i.binding==="DB"))return{added:[],text:e};const s=typeof a.name=="string"&&a.name.length>0?a.name:"lunora",r=[...n,{binding:"DB",database_id:w,database_name:s}];return{added:["DB (D1)"],text:b(e,["d1_databases"],r)}},y=(e,a,n,s,r)=>{const i=a[n]?.binding;return typeof i=="string"&&i.length>0?{added:[],text:e}:{added:[r],text:b(e,[n],{binding:s})}},W=(e,a)=>(a.analytics_engine_datasets?.length??0)>0?{added:[],text:e}:{added:["ANALYTICS (Analytics Engine)"],text:b(e,["analytics_engine_datasets"],[{binding:"ANALYTICS",dataset:"ANALYTICS"}])},j=e=>{if(typeof e=="string")return e;const a={};return e.diskMb!==void 0&&(a.disk_mb=e.diskMb),e.memoryMib!==void 0&&(a.memory_mib=e.memoryMib),e.vcpu!==void 0&&(a.vcpu=e.vcpu),a},Y=e=>e.image.kind==="dockerfile"?e.image.dockerfilePath:e.image.kind==="registry"?e.image.reference:D(e.exportName),G=e=>{const a={class_name:e.className,image:Y(e)};return e.image.kind==="dockerfile"&&(a.image_build_context=e.image.buildContext),e.buildArgs!==void 0&&e.image.kind!=="registry"&&(a.image_vars=e.buildArgs),e.instanceType!==void 0&&(a.instance_type=j(e.instanceType)),e.maxInstances!==void 0&&(a.max_instances=e.maxInstances),e.name!==void 0&&(a.name=e.name),e.rollout?.stepPercentage!==void 0&&(a.rollout_step_percentage=e.rollout.stepPercentage),e.rollout?.gracePeriodSeconds!==void 0&&(a.rollout_active_grace_period=e.rollout.gracePeriodSeconds),a},L=(e,a,n)=>{const s=a.containers??[],r=new Set(s.map(o=>o.class_name)),i=n.filter(o=>!r.has(o.className));if(i.length===0)return{added:[],text:e};const u=b(e,["containers"],[...s,...i.map(o=>G(o))]);return{added:i.map(o=>`containers/${o.className}`),text:u}},H=(e,a)=>{if(a.observability!==void 0)return{added:[],text:e};const n=b(e,["observability"],{enabled:!0,head_sampling_rate:1});return{added:["observability"],text:n}},U=e=>({binding:e.bindingName,class_name:e.className,name:e.name}),F=e=>({binding:e.bindingName,class_name:e.className,name:e.name}),z=(e,a,n,s=[])=>{const r=a.workflows??[],i=new Set(r.map(l=>l.class_name)),u=n.filter(l=>!i.has(l.className)),o=s.filter(l=>!i.has(l.className));if(u.length===0&&o.length===0)return{added:[],text:e};const p=b(e,["workflows"],[...r,...u.map(l=>U(l)),...o.map(l=>F(l))]);return{added:[...u.map(l=>`workflows/${l.className}`),...o.map(l=>`workflows/${l.className}`)],text:p}},V=(e,a,n)=>{const s=a.queues??{},r=s.producers??[],i=s.consumers??[],u=new Set(r.map(d=>d.binding)),o=new Set(i.map(d=>d.queue)),p=n.filter(d=>!u.has(d.bindingName)),l=n.filter(d=>!o.has(d.name));if(p.length===0&&l.length===0)return{added:[],text:e};const h=[...r,...p.map(d=>({binding:d.bindingName,queue:d.name}))],c=[...i,...l.map(d=>{const g={queue:d.name};return d.mode==="pull"&&(g.type="http_pull"),d.tuning.maxBatchSize!==void 0&&(g.max_batch_size=d.tuning.maxBatchSize),d.tuning.maxBatchTimeout!==void 0&&(g.max_batch_timeout=d.tuning.maxBatchTimeout),d.tuning.maxRetries!==void 0&&(g.max_retries=d.tuning.maxRetries),d.tuning.deadLetterQueue!==void 0&&(g.dead_letter_queue=d.tuning.deadLetterQueue),d.tuning.retryDelay!==void 0&&(g.retry_delay=d.tuning.retryDelay),g})],m=b(e,["queues"],{consumers:c,producers:h});return{added:[...p.map(d=>`queues.producers/${d.bindingName}`),...l.map(d=>`queues.consumers/${d.name}`)],text:m}},ne=(e,a,n)=>{const s=O(e),r=R(a);if(!s)return{added:[],changed:!1,exportGaps:r,reason:"wrangler.jsonc not found",warnings:v(a,e)};const{parsed:i,text:u}=C(s);if(i===void 0)return{added:[],changed:!1,exportGaps:r,reason:`failed to parse ${s} as JSONC`,warnings:v(a,e),wranglerPath:s};const o=v(a,e,i);if(n!==void 0){const t=i.env?.[n]!==void 0;o.push(t?`auto-provisioned bindings are written to the top level of wrangler.jsonc only — "env.${n}" has its own (non-inheritable) bindings and must be reconciled by hand; \`lunora deploy --env ${n}\` now validates them, so a gap here will be reported at deploy time.`:`--env "${n}" was requested but wrangler.jsonc declares no "env.${n}" block — auto-provisioned bindings are written to the top level only and will not apply to that environment.`)}const p=a.containers.filter(t=>t.exported),l=a.agents.filter(t=>t.exported&&t.voice===!0&&t.voiceBindingName!==void 0&&t.voiceClassName!==void 0),h=[...a.durableObjects,...p.map(t=>({binding:t.bindingName,className:t.className})),...l.map(t=>({binding:t.voiceBindingName,className:t.voiceClassName}))],c=a.workflows.filter(t=>t.exported),m=a.agents.filter(t=>t.exported),d=[{enabled:!0,run:t=>q(t,i,h)},{enabled:a.needsD1,run:t=>K(t,i)},{enabled:a.usesAi,run:t=>y(t,i,"ai","AI","AI (Workers AI)")},{enabled:a.usesBrowser,run:t=>y(t,i,"browser","BROWSER","BROWSER (Browser Rendering)")},{enabled:a.usesImages,run:t=>y(t,i,"images","IMAGES","IMAGES (Cloudflare Images)")},{enabled:a.usesAnalytics,run:t=>W(t,i)},{enabled:!0,run:t=>H(t,i)},{enabled:p.length>0,run:t=>L(t,i,p)},{enabled:c.length>0||m.length>0,run:t=>z(t,i,c,m)},{enabled:a.queues.length>0,run:t=>V(t,i,a.queues)}];let g=u;const f=[];for(const t of d){if(!t.enabled)continue;const x=t.run(g);g=x.text,f.push(...x.added)}return f.includes("DB (D1)")&&o.push(`wrote a DB binding with a placeholder database_id ("${w}") — run \`wrangler d1 create <name>\` and replace it before deploying.`),g===u?{added:[],changed:!1,exportGaps:r,reason:"bindings already in sync",warnings:o,wranglerPath:s}:(S(s,g,"utf8"),{added:f,changed:!0,exportGaps:r,warnings:o,wranglerPath:s})};export{R as collectExportGaps,ne as reconcileWranglerBindings};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import{createInterface as m}from"node:readline";const w=/[\s,]+/u,$=()=>process.stdin.isTTY,y=async(i,t)=>{const o=m({input:process.stdin,output:process.stdout});try{const e=(await new Promise(u=>{o.question(i,l=>{u(l)})})).trim().toLowerCase();return e===""?t?.defaultYes===!0:e==="y"||e==="yes"}finally{o.close()}},b=(i="")=>$()?t=>y(`${i}${t} [Y/n] `,{defaultYes:!0}):()=>Promise.resolve(!1),S=async(i,t,o)=>{if(!$()||t.length===0)return o?.default;const e=o?.default===void 0?-1:t.findIndex(r=>r.value===o.default),u=t.map((r,n)=>` ${String(n+1)}) ${r.label}${r.description===void 0?"":` — ${r.description}`}`),l=`${i}
|
|
2
|
-
${u.join(`
|
|
3
|
-
`)}
|
|
4
|
-
> ${e>=0?`[${String(e+1)}] `:""}`,f=m({input:process.stdin,output:process.stdout});try{const r=(await new Promise(a=>{f.question(l,d=>{a(d)})})).trim();if(r==="")return o?.default;const n=Number.parseInt(r,10);return Number.isInteger(n)&&n>=1&&n<=t.length?t[n-1]?.value:t.find(a=>a.value===r||a.label.toLowerCase()===r.toLowerCase())?.value??o?.default}finally{f.close()}},I=async(i,t)=>{if(!$())return t?.default;const o=m({input:process.stdin,output:process.stdout});try{const e=(await new Promise(u=>{o.question(i,l=>{u(l)})})).trim();return e===""?t?.default:e}finally{o.close()}},h=async(i,t,o)=>{const e=o?.defaults??[];if(!$()||t.length===0)return[...e];const u=t.map((n,a)=>` ${String(a+1)}) ${n.label}${n.description===void 0?"":` — ${n.description}`}`),l=e.length===0?"":`[${e.join(", ")}] `,f=`${i} (comma-separated; Enter for default)
|
|
5
|
-
${u.join(`
|
|
6
|
-
`)}
|
|
7
|
-
> ${l}`,r=m({input:process.stdin,output:process.stdout});try{const n=(await new Promise(s=>{r.question(f,c=>{s(c)})})).trim();if(n==="")return[...e];const a=n.split(w).map(s=>s.trim()).filter(s=>s!==""),d=new Set;for(const s of a){const c=Number.parseInt(s,10);if(Number.isInteger(c)&&c>=1&&c<=t.length&&String(c)===s){const p=t[c-1]?.value;p!==void 0&&d.add(p);continue}const v=t.find(p=>p.value===s||p.label.toLowerCase()===s.toLowerCase());v!==void 0&&d.add(v.value)}return t.filter(s=>d.has(s.value)).map(s=>s.value)}finally{r.close()}};export{b as createConfirm,$ as isInteractive,h as promptMultiSelect,S as promptSelect,I as promptText,y as promptYesNo};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{existsSync as s}from"node:fs";import{AGENTS_FILENAME as i,discoverAgents as m}from"@lunora/codegen";import{Project as c}from"ts-morph";import{join as t}from"node:path";const u=(e,o)=>{const n=t(e,o,i);if(!s(n))return{agents:[]};try{const r=new c({skipAddingFilesFromTsConfig:!0,useInMemoryFileSystem:!1});return{agents:m(r,t(e,o))}}catch(r){return{agents:[],error:r instanceof Error?r.message:String(r)}}};export{u as discoverAgentInfo};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{existsSync as i}from"node:fs";import{CONTAINERS_FILENAME as s,discoverContainers as c}from"@lunora/codegen";import{Project as m}from"ts-morph";import{join as n}from"node:path";const d=(e,o)=>{const t=n(e,o,s);if(!i(t))return{containers:[]};try{const r=new m({skipAddingFilesFromTsConfig:!0,skipFileDependencyResolution:!0,useInMemoryFileSystem:!1});return{containers:c(r,n(e,o))}}catch(r){return{containers:[],error:r instanceof Error?r.message:String(r)}}};export{d as discoverContainerInfo};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{existsSync as i}from"node:fs";import{WORKFLOWS_FILENAME as n,discoverWorkflows as f}from"@lunora/codegen";import{Project as m}from"ts-morph";import{join as e}from"node:path";const p=(r,s)=>{const t=e(r,s,n);if(!i(t))return{workflows:[]};try{const o=new m({skipAddingFilesFromTsConfig:!0,useInMemoryFileSystem:!1});return{workflows:f(o,e(r,s))}}catch(o){return{error:o instanceof Error?o.message:String(o),workflows:[]}}};export{p as discoverWorkflowInfo};
|
|
@@ -1 +0,0 @@
|
|
|
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{escapeRegExp as D}from"./DEV_VARS_EXAMPLE_FILE-BL0hrPx3.mjs";import{FLAGS_FILENAME as W,discoverFlags as H,QUEUES_FILENAME as M,discoverQueues as q}from"@lunora/codegen";import{Project as $}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 $({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 $({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"],A={SchedulerDO:"SCHEDULER",SessionDO:"SESSION",ShardDO:"SHARD"},O=Object.keys(A),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/,_=/\bctx\s*\.\s*pipelines\b/,I=/^\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(I.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:_,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)",j=[...p,"needsD1"],de=()=>{const e={};for(const r of j)e[r]=!1;return e},l=Object.freeze(de()),y=(e,r)=>{const t={};for(const s of j)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||I.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:_.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:A[s],className:s}))},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=D(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${D(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,Re=(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},Ne=(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},Ke=async e=>{await T;const r=e.schemaDir??"lunora",t=e.scanDirs??J,s=Re(e.projectRoot,t),n={...s,usesBrowser:s.usesBrowser||Ne(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 N of p)E[N]=n[N];const R=De(o,i,n,u,x,v);return h!==void 0&&R.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:R,usesFlags:m!==void 0,workflows:x,...E}},We=e=>{const r=[];for(const t of p)e[t]&&r.push(g[t].source);return r};export{V as WORKER_ENTRY_FALLBACKS,Ke as inferLunoraBindings,ye as isTypeOnlyExportEntry,We as packageNamesFromBindings,fe as resolveWorkerEntry};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
const o=n=>JSON.stringify(n),y=/^[A-Z_a-z][\w$]*$/u,p=n=>y.test(n),g=n=>p(n)?n:`binding_${n.replaceAll(/\W/gu,"_")}`,d=(n,a=g(n))=>{const t=p(n);return t&&a===n?`${n},`:`${t?n:o(n)}: ${a},`},_=n=>{const a=new Set;for(const t of n.migrations??[])for(const r of t.new_sqlite_classes??[])a.add(r);return a},$=(n,a,t,r,s)=>{for(const i of n.durable_objects?.bindings??[])if(!(i.name===void 0||i.class_name===void 0)){if(i.script_name!==void 0){s.push(`durable_objects.${i.name} (external script_name "${i.script_name}")`);continue}t.add("DurableObjectNamespace"),r.push(d(i.name,`DurableObjectNamespace(${o(i.name)}, { className: ${o(i.class_name)}, sqlite: ${String(a.has(i.class_name))} })`))}for(const[i,m]of Object.entries(n.vars??{}))r.push(d(i,o(String(m))))},v=(n,a)=>{for(const[t,r]of Object.entries(n.vars??{}))a.push(d(t,o(String(r))))},h=(n,a)=>{for(const[t,r]of[["ai","ai"],["analytics_engine_datasets","analytics_engine_datasets"],["browser","browser"],["containers","containers"],["hyperdrive","hyperdrive"],["images","images"],["pipelines","pipelines"],["vectorize","vectorize"],["workflows","workflows"]]){const s=n[t];s!==void 0&&(!Array.isArray(s)||s.length>0)&&a.push(r)}},w=n=>{const a=n.name??"worker",t=[],r=new Set(["Worker"]),s=[],i=[],m=_(n),b=[{construct:"D1Database",entries:(n.d1_databases??[]).map(e=>({binding:e.binding,name:e.database_name})),nameKey:"name"},{construct:"R2Bucket",entries:(n.r2_buckets??[]).map(e=>({binding:e.binding,name:e.bucket_name})),nameKey:"name"},{construct:"KVNamespace",entries:(n.kv_namespaces??[]).map(e=>({binding:e.binding,name:e.binding})),nameKey:"title"},{construct:"Queue",entries:(n.queues?.producers??[]).map(e=>({binding:e.binding,name:e.queue})),nameKey:"name"}];for(const{construct:e,entries:l,nameKey:f}of b)for(const c of l)c.binding!==void 0&&(r.add(e),s.push(`const ${g(c.binding)} = await ${e}(${o(c.binding)}, { adopt: true, ${f}: ${o(c.name??c.binding)} });`),i.push(d(c.binding)));$(n,m,r,i,t),v(n,i),h(n,t);const u=["adopt: true,",i.length===0?void 0:`bindings: {
|
|
2
|
-
${i.join(`
|
|
3
|
-
`)}
|
|
4
|
-
},`,n.compatibility_date===void 0?void 0:`compatibilityDate: ${o(n.compatibility_date)},`,n.compatibility_flags===void 0||n.compatibility_flags.length===0?void 0:`compatibilityFlags: ${o([...n.compatibility_flags])},`,n.triggers?.crons===void 0||n.triggers.crons.length===0?void 0:`crons: ${o([...n.triggers.crons])},`,n.main===void 0?void 0:`entrypoint: ${o(n.main)},`,`name: ${o(a)},`].filter(e=>e!==void 0);return{source:["// GENERATED by @lunora/config from wrangler.jsonc — do not edit.","// Re-generated on every `lunora deploy`; edit wrangler.jsonc instead.","",'import alchemy from "alchemy";',`import { ${[...r].toSorted((e,l)=>e.localeCompare(l)).join(", ")} } from "alchemy/cloudflare";`,"",`const app = await alchemy(${o(a)});`,"",...s.length===0?[]:[...s,""],`export const worker = await Worker(${o(a)}, {`,` ${u.join(`
|
|
5
|
-
`)}`,"});","","await app.finalize();",""].join(`
|
|
6
|
-
`),unsupported:t}};export{w as wranglerToAlchemy};
|