@lunora/config 1.0.0-alpha.447 → 1.0.0-alpha.449
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.mjs +1 -1
- package/dist/packem_shared/{collectExportGaps-CLrCQp09.mjs → collectExportGaps-CO1Se31Y.mjs} +2 -2
- package/dist/packem_shared/inferLunoraBindings-CGy-uHu6.mjs +1 -0
- package/dist/packem_shared/{reconcileBindingsSafely-CSov1jsv.mjs → reconcileBindingsSafely-BodqgI8_.mjs} +1 -1
- package/package.json +3 -3
- package/dist/packem_shared/inferLunoraBindings-BiRE_Jh9.mjs +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{applyModify as o}from"../packem_shared/applyModify-DKP2l6S9.mjs";import{assertWranglerSatisfiesSchema as t}from"../packem_shared/assertWranglerSatisfiesSchema-DmkdB-OW.mjs";import{BINDING_MANIFEST_VERSION as i,buildBindingManifest as l}from"../packem_shared/BINDING_MANIFEST_VERSION-CfXEYG8e.mjs";import{CLOUDFLARE_CLI_CONFIG_WARNING_ENV as m,detectCloudflareCliConfig as E,warnCloudflareCliConfigOnce as s}from"../packem_shared/CLOUDFLARE_CLI_CONFIG_WARNING_ENV-BKMrOuXV.mjs";import{default as d}from"../packem_shared/CLOUDFLARE_DRIVER-DbmpoIcg.mjs";import{default as C}from"../packem_shared/GLOBAL_FETCH_STRICTLY_PUBLIC_FLAG-f8CnJha3.mjs";import{hasCloudflareCredentials as R}from"../packem_shared/hasCloudflareCredentials-Bak5w1_6.mjs";import{describeWithheld as _,withheldBindings as I}from"../packem_shared/describeWithheld-CbyzZjZF.mjs";import{bindingsNeedingDatabase as A,startLocalHyperdrive as D}from"../packem_shared/bindingsNeedingDatabase-6eD6Qtqf.mjs";import{readManifest as S,recordManifestKey as W}from"../packem_shared/readManifest-Cighz3WC.mjs";import{HYPERDRIVE_PLACEHOLDER_ID as N}from"../packem_shared/D1_PLACEHOLDER_ID-ZnDjVymH.mjs";import{collectExportGaps as F,reconcileWranglerBindings as b}from"../packem_shared/collectExportGaps-
|
|
1
|
+
import{applyModify as o}from"../packem_shared/applyModify-DKP2l6S9.mjs";import{assertWranglerSatisfiesSchema as t}from"../packem_shared/assertWranglerSatisfiesSchema-DmkdB-OW.mjs";import{BINDING_MANIFEST_VERSION as i,buildBindingManifest as l}from"../packem_shared/BINDING_MANIFEST_VERSION-CfXEYG8e.mjs";import{CLOUDFLARE_CLI_CONFIG_WARNING_ENV as m,detectCloudflareCliConfig as E,warnCloudflareCliConfigOnce as s}from"../packem_shared/CLOUDFLARE_CLI_CONFIG_WARNING_ENV-BKMrOuXV.mjs";import{default as d}from"../packem_shared/CLOUDFLARE_DRIVER-DbmpoIcg.mjs";import{default as C}from"../packem_shared/GLOBAL_FETCH_STRICTLY_PUBLIC_FLAG-f8CnJha3.mjs";import{hasCloudflareCredentials as R}from"../packem_shared/hasCloudflareCredentials-Bak5w1_6.mjs";import{describeWithheld as _,withheldBindings as I}from"../packem_shared/describeWithheld-CbyzZjZF.mjs";import{bindingsNeedingDatabase as A,startLocalHyperdrive as D}from"../packem_shared/bindingsNeedingDatabase-6eD6Qtqf.mjs";import{readManifest as S,recordManifestKey as W}from"../packem_shared/readManifest-Cighz3WC.mjs";import{HYPERDRIVE_PLACEHOLDER_ID as N}from"../packem_shared/D1_PLACEHOLDER_ID-ZnDjVymH.mjs";import{collectExportGaps as F,reconcileWranglerBindings as b}from"../packem_shared/collectExportGaps-CO1Se31Y.mjs";import{reconcileWranglerCompatibilityDate as h}from"../packem_shared/reconcileWranglerCompatibilityDate-hocXEuRA.mjs";import{describePreservedCrons as G,reconcileWranglerCrons as M}from"../packem_shared/describePreservedCrons-Bt2rPPeY.mjs";import{reconcileBindingsSafely as U,reconcileWranglerExtras as P}from"../packem_shared/reconcileBindingsSafely-BodqgI8_.mjs";import{REMOTE_ELIGIBLE_KEYS as H,injectRemoteFlags as w,isRemoteEnvEnabled as Y,materializeDevWranglerConfig as K,planRemoteBindings as j,resolveRemoteEnabled as z}from"../packem_shared/REMOTE_ELIGIBLE_KEYS-DooK0pzs.mjs";import{materializeServiceDevConfigs as J}from"../packem_shared/materializeServiceDevConfigs-qUY4_iu1.mjs";import{default as k}from"../packem_shared/CLOUDFLARE_TOOLCHAIN_VERSIONS-DV5E_f_q.mjs";import{withTailConsumer as Z}from"../packem_shared/withTailConsumer-CF3pk_Ov.mjs";import{WORKERS_CACHE_MIN_DATE as ee,isCacheEnabled as re}from"../packem_shared/WORKERS_CACHE_MIN_DATE-0k9ABJtF.mjs";import{wranglerCodegenInputs as ae}from"../packem_shared/wranglerCodegenInputs-BZamZrPz.mjs";import{DEFAULT_OBSERVABILITY as ne,resolveObservabilitySampling as ie}from"../packem_shared/DEFAULT_OBSERVABILITY-CPLADr5u.mjs";import{mergeWranglerEnvironment as fe}from"../packem_shared/mergeWranglerEnvironment-D5ekKj5x.mjs";import{WRANGLER_FILES as Ee,findWranglerFile as se,readWranglerJsonc as pe}from"../packem_shared/WRANGLER_FILES-UNW-xY5u.mjs";import{UNEXPORTED_CLASS_MARKER as ge,validateWranglerProject as Ce}from"../packem_shared/UNEXPORTED_CLASS_MARKER-07SNQ0rP.mjs";import{scanWranglerVariablesForSecrets as Re}from"../packem_shared/scanWranglerVariablesForSecrets-DRBYlMYb.mjs";import{wranglerToAlchemy as _e}from"../packem_shared/wranglerToAlchemy-CBO2ucRm.mjs";import{REQUIRED_COMPATIBILITY_DATE as Le,REQUIRED_FLAG as Ae,validateWrangler as De,validateWranglerConfig as Oe}from"../packem_shared/REQUIRED_COMPATIBILITY_DATE-C8qfwbaA.mjs";export{i as BINDING_MANIFEST_VERSION,m as CLOUDFLARE_CLI_CONFIG_WARNING_ENV,d as CLOUDFLARE_DRIVER,k as CLOUDFLARE_TOOLCHAIN_VERSIONS,ne as DEFAULT_OBSERVABILITY,C as GLOBAL_FETCH_STRICTLY_PUBLIC_FLAG,N as HYPERDRIVE_PLACEHOLDER_ID,H as REMOTE_ELIGIBLE_KEYS,Le as REQUIRED_COMPATIBILITY_DATE,Ae as REQUIRED_FLAG,ge as UNEXPORTED_CLASS_MARKER,ee as WORKERS_CACHE_MIN_DATE,Ee as WRANGLER_FILES,o as applyModify,t as assertWranglerSatisfiesSchema,A as bindingsNeedingDatabase,l as buildBindingManifest,F as collectExportGaps,G as describePreservedCrons,_ as describeWithheld,E as detectCloudflareCliConfig,se as findWranglerFile,R as hasCloudflareCredentials,w as injectRemoteFlags,re as isCacheEnabled,Y as isRemoteEnvEnabled,K as materializeDevWranglerConfig,J as materializeServiceDevConfigs,fe as mergeWranglerEnvironment,j as planRemoteBindings,S as readManifest,pe as readWranglerJsonc,U as reconcileBindingsSafely,b as reconcileWranglerBindings,h as reconcileWranglerCompatibilityDate,M as reconcileWranglerCrons,P as reconcileWranglerExtras,W as recordManifestKey,ie as resolveObservabilitySampling,z as resolveRemoteEnabled,Re as scanWranglerVariablesForSecrets,D as startLocalHyperdrive,De as validateWrangler,Oe as validateWranglerConfig,Ce as validateWranglerProject,s as warnCloudflareCliConfigOnce,Z as withTailConsumer,I as withheldBindings,ae as wranglerCodegenInputs,_e as wranglerToAlchemy};
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{AGENT_MODE_ENV as o,detectAiAgent as t}from"./packem_shared/AGENT_MODE_ENV-D8MvSwPE.mjs";import{discoverAgentInfo as E}from"./packem_shared/discoverAgentInfo-pqFMJBtJ.mjs";import{AGENT_RULES_DIR as i,AGENT_RULES_HINT as n,AGENT_RULES_HINT_ENV as _,LUNORA_SKILL_NAMES as l,ROOT_SKILL_NAME as c,claimAgentRulesHint as p,detectAgentRules as D}from"./packem_shared/AGENT_RULES_DIR-Bd6JPtNa.mjs";import{clearApiSpecMarker as A,readApiSpecMarker as m,writeApiSpecMarker as S}from"./packem_shared/clearApiSpecMarker-DMGpP41V.mjs";import{MissingBuildOutputError as L}from"./packem_shared/MissingBuildOutputError-BAyekzof.mjs";import{default as T}from"./packem_shared/canonicalPath-DrfMiT3U.mjs";import{probeCelldToolchain as v}from"./packem_shared/probeCelldToolchain-DxDttfHy.mjs";import{startCelldDevSession as g,writeCelldDevProjection as I}from"./packem_shared/startCelldDevSession-BKRiLvt-.mjs";import{D1_PLACEHOLDER_ID as u}from"./packem_shared/D1_PLACEHOLDER_ID-ZnDjVymH.mjs";import{BUILD_ROOT_ENV as P,BUILD_TARGET_ENV as C,BUNDLE_META_PATH_ENV as M,CODEGEN_ENV as U,DEFAULT_BUNDLE_META_PATH as F,LAZY_FUNCTIONS_ENV as B,STRICT_ADVISORIES_ENV as G,isCodegenDisabled as b,isLazyFunctionsEnabled as y,resolveLazyFunctions as k}from"./packem_shared/BUILD_ROOT_ENV-Dg4MV3wY.mjs";import{discoverContainerInfo as j}from"./packem_shared/discoverContainerInfo-DzXr7Vm3.mjs";import{streamContainerLogs as K}from"./packem_shared/streamContainerLogs-0nko1qpv.mjs";import{detectFramework as W,projectUsesUmbrella as Y}from"./packem_shared/detectFramework-Dfpvu6rD.mjs";import{acceptsConnection as z,startDevProcess as q}from"./packem_shared/acceptsConnection-DHhUYGjT.mjs";import{DEV_BINDINGS_FILE as Z,DEV_DAEMON_ENV as Q,DEV_HANDOFF_ENV as $,DEV_LOG_FILE as ee,DEV_LOG_FILE_ENV as re,DEV_STATE_DIR as oe,DEV_STATE_FILE as te,claimDevServerState as ae,clearDevServerState as Ee,isDevServerReady as se,isProcessAlive as ie,isRecordedProcessCurrent as ne,readDevServerState as _e,readLiveDevServerState as le,updateDevServerState as ce,writeDevServerState as pe}from"./packem_shared/DEV_BINDINGS_FILE-C0ZN_XlP.mjs";import{DEV_VARS_EXAMPLE_FILE as de,DEV_VARS_FILE as Ae,DEV_VARS_KEY_PATTERN as me,escapeRegExp as Se,parseDevVariableEntries as fe,removeDevVariableLine as Le,upsertDevVariableLine as Ne}from"./packem_shared/DEV_VARS_EXAMPLE_FILE-CqLorAxT.mjs";import{DEV_WORKER_ENV_VALUE as Re,DEV_WORKER_ENV_VAR as ve,ensureDevWorkerEnv as xe}from"./packem_shared/DEV_WORKER_ENV_VALUE-CgozgOxh.mjs";import{createDiscoveryCache as Ie}from"./packem_shared/createDiscoveryCache-npJI4uej.mjs";import{DEFAULT_DEPLOY_TARGET as ue,deployTargetIds as Oe,isRunnableTarget as Pe,planToolchainInvocation as Ce,resolveDeployDriver as Me,runnableTargetIds as Ue,targetRunsOwnDevServer as Fe}from"./packem_shared/DEFAULT_DEPLOY_TARGET-DllYb7Tj.mjs";import{default as Ge}from"./packem_shared/ensureGitignoreEntries-Tsk8Qkw7.mjs";import{inferLunoraBindings as ye,secretSourcesFromBindings as ke}from"./packem_shared/inferLunoraBindings-BiRE_Jh9.mjs";import{LINKED_PROJECT_DIR as je,LINKED_PROJECT_FILE as we,readLinkedProject as Ke,writeLinkedProject as He}from"./packem_shared/LINKED_PROJECT_DIR-Ba5qPEwo.mjs";import{LUNORA_IGNORED_PATHS as Ye,applyLintIgnores as Je,detectLintTools as ze}from"./packem_shared/LUNORA_IGNORED_PATHS-U93uPxrW.mjs";import{blockingFindingsMessage as Xe,reportCodegenFindings as Ze}from"./packem_shared/blockingFindingsMessage-CRbg1sla.mjs";import{LUNORA_EVENT_SOURCE as $e,formatLunoraEvent as er}from"./packem_shared/LUNORA_EVENT_SOURCE-B9ZVohjO.mjs";import{LUNORA_TAG as or,advisoryLine as tr,lunoraLine as ar}from"./packem_shared/LUNORA_TAG-DQTGPqcJ.mjs";import{default as sr}from"./packem_shared/LunoraReporter-f277GLNT.mjs";import{addArgsFor as nr,detectInstalledManagers as _r,detectPackageManager as lr,execArgsFor as cr,installArgsFor as pr,runScriptArgsFor as Dr,runScriptCommand as dr,toolchainExecArgs as Ar}from"./packem_shared/addArgsFor-CYZKhNIo.mjs";import{P as Sr,m as fr,s as Lr}from"./packem_shared/package-secrets-registry-UQ_uEAB_.mjs";import{runPostCodegenHook as Tr}from"./packem_shared/runPostCodegenHook-Dx3yTsYZ.mjs";import{assertBuildTargetMatches as vr,interpretRemote as xr,readProjectRemotePreference as gr,readProjectTarget as Ir,resolveProjectTarget as Vr,resolveTargetOrThrow as ur}from"./packem_shared/assertBuildTargetMatches-CqrrwiQ-.mjs";import{readProjectDependencies as Pr,readProjectDependencyNames as Cr,readProjectManifest as Mr}from"./packem_shared/readProjectDependencies-l3uhUKjo.mjs";import{createConfirm as Fr,isInteractive as Br,promptMultiSelect as Gr,promptSelect as br,promptText as yr,promptYesNo as kr}from"./packem_shared/createConfirm-D5mKTMHj.mjs";import{default as jr}from"./packem_shared/resolveSchemaDirectory-Ca5P6KuP.mjs";import{buildPackageSecretsBlock as Kr,ensureDevVariables as Hr,ensureDevVarsExample as Wr,fillDevSecrets as Yr,generateSecretValue as Jr,isMintableSecretKey as zr,isPlaceholderValue as qr,planDevSecretsFill as Xr,planDevVariablesAugment as Zr,planDevVariablesScaffold as Qr,requiredSecrets as $r,writeDevVariablesFileAtomically as eo}from"./packem_shared/buildPackageSecretsBlock-GvaLgvFN.mjs";import{applyAdditiveEdit as oo,classifyEdit as to}from"./packem_shared/applyAdditiveEdit-DEwPKcJg.mjs";import{parseSchema as Eo}from"./packem_shared/parseSchema-D1Wbr1qv.mjs";import{classifyPolicyEdit as io,resolveServerModule as no,scaffoldPolicyFile as _o,wireRlsIntoProcedure as lo}from"./packem_shared/classifyPolicyEdit-DJi9Fk8G.mjs";import{discoverSchemaInfo as po}from"./packem_shared/discoverSchemaInfo-DRPnqgif.mjs";import{ACCENT as Ao,BADGES as mo,BADGE_COLUMN_WIDTH as So,LUNA_ART as fo,LUNA_BUNNY as Lo,LUNA_NAME as No,LUNA_SIGNOFF as To,STEP_BADGE_NAMES as Ro,badgeLead as vo,badgeWidth as xo,padBadge as go,paintAnswer as Io,paintBadge as Vo}from"./packem_shared/ACCENT-CotPTfv7.mjs";import{COMPOSED_WORKER_ENTRY as Oo,DURABLE_OBJECT_BINDINGS as Po,GENERATED_CLASS_MODULES as Co,GENERATED_MODULE_DURABLE_OBJECTS as Mo,MERGED_DURABLE_OBJECTS_MODULE as Uo,isMergedProject as Fo,isMergedRoleModule as Bo}from"./packem_shared/COMPOSED_WORKER_ENTRY-BcFt6ts5.mjs";import{discoverWorkflowInfo as bo}from"./packem_shared/discoverWorkflowInfo-zW7Tt0Tn.mjs";export{Ao as ACCENT,o as AGENT_MODE_ENV,i as AGENT_RULES_DIR,n as AGENT_RULES_HINT,_ as AGENT_RULES_HINT_ENV,mo as BADGES,So as BADGE_COLUMN_WIDTH,P as BUILD_ROOT_ENV,C as BUILD_TARGET_ENV,M as BUNDLE_META_PATH_ENV,U as CODEGEN_ENV,Oo as COMPOSED_WORKER_ENTRY,u as D1_PLACEHOLDER_ID,F as DEFAULT_BUNDLE_META_PATH,ue as DEFAULT_DEPLOY_TARGET,Z as DEV_BINDINGS_FILE,Q as DEV_DAEMON_ENV,$ as DEV_HANDOFF_ENV,ee as DEV_LOG_FILE,re as DEV_LOG_FILE_ENV,oe as DEV_STATE_DIR,te as DEV_STATE_FILE,de as DEV_VARS_EXAMPLE_FILE,Ae as DEV_VARS_FILE,me as DEV_VARS_KEY_PATTERN,Re as DEV_WORKER_ENV_VALUE,ve as DEV_WORKER_ENV_VAR,Po as DURABLE_OBJECT_BINDINGS,Co as GENERATED_CLASS_MODULES,Mo as GENERATED_MODULE_DURABLE_OBJECTS,B as LAZY_FUNCTIONS_ENV,je as LINKED_PROJECT_DIR,we as LINKED_PROJECT_FILE,fo as LUNA_ART,Lo as LUNA_BUNNY,No as LUNA_NAME,To as LUNA_SIGNOFF,$e as LUNORA_EVENT_SOURCE,Ye as LUNORA_IGNORED_PATHS,l as LUNORA_SKILL_NAMES,or as LUNORA_TAG,sr as LunoraReporter,Uo as MERGED_DURABLE_OBJECTS_MODULE,L as MissingBuildOutputError,Sr as PACKAGE_SECRETS_REGISTRY,c as ROOT_SKILL_NAME,Ro as STEP_BADGE_NAMES,G as STRICT_ADVISORIES_ENV,z as acceptsConnection,nr as addArgsFor,tr as advisoryLine,oo as applyAdditiveEdit,Je as applyLintIgnores,vr as assertBuildTargetMatches,vo as badgeLead,xo as badgeWidth,Xe as blockingFindingsMessage,Kr as buildPackageSecretsBlock,T as canonicalPath,p as claimAgentRulesHint,ae as claimDevServerState,to as classifyEdit,io as classifyPolicyEdit,A as clearApiSpecMarker,Ee as clearDevServerState,Fr as createConfirm,Ie as createDiscoveryCache,Oe as deployTargetIds,D as detectAgentRules,t as detectAiAgent,W as detectFramework,_r as detectInstalledManagers,ze as detectLintTools,lr as detectPackageManager,E as discoverAgentInfo,j as discoverContainerInfo,po as discoverSchemaInfo,bo as discoverWorkflowInfo,Hr as ensureDevVariables,Wr as ensureDevVarsExample,xe as ensureDevWorkerEnv,Ge as ensureGitignoreEntries,Se as escapeRegExp,cr as execArgsFor,Yr as fillDevSecrets,er as formatLunoraEvent,Jr as generateSecretValue,ye as inferLunoraBindings,pr as installArgsFor,xr as interpretRemote,b as isCodegenDisabled,se as isDevServerReady,Br as isInteractive,y as isLazyFunctionsEnabled,Fo as isMergedProject,Bo as isMergedRoleModule,zr as isMintableSecretKey,qr as isPlaceholderValue,ie as isProcessAlive,ne as isRecordedProcessCurrent,Pe as isRunnableTarget,ar as lunoraLine,fr as mintableSecretKeysFor,go as padBadge,Io as paintAnswer,Vo as paintBadge,fe as parseDevVariableEntries,Eo as parseSchema,Xr as planDevSecretsFill,Zr as planDevVariablesAugment,Qr as planDevVariablesScaffold,Ce as planToolchainInvocation,v as probeCelldToolchain,Y as projectUsesUmbrella,Gr as promptMultiSelect,br as promptSelect,yr as promptText,kr as promptYesNo,m as readApiSpecMarker,_e as readDevServerState,Ke as readLinkedProject,le as readLiveDevServerState,Pr as readProjectDependencies,Cr as readProjectDependencyNames,Mr as readProjectManifest,gr as readProjectRemotePreference,Ir as readProjectTarget,Le as removeDevVariableLine,Ze as reportCodegenFindings,$r as requiredSecrets,Me as resolveDeployDriver,k as resolveLazyFunctions,Vr as resolveProjectTarget,jr as resolveSchemaDirectory,no as resolveServerModule,ur as resolveTargetOrThrow,Tr as runPostCodegenHook,Dr as runScriptArgsFor,dr as runScriptCommand,Ue as runnableTargetIds,_o as scaffoldPolicyFile,ke as secretSourcesFromBindings,Lr as secretsForPackages,g as startCelldDevSession,q as startDevProcess,K as streamContainerLogs,Fe as targetRunsOwnDevServer,Ar as toolchainExecArgs,ce as updateDevServerState,Ne as upsertDevVariableLine,lo as wireRlsIntoProcedure,S as writeApiSpecMarker,I as writeCelldDevProjection,pe as writeDevServerState,eo as writeDevVariablesFileAtomically,He as writeLinkedProject};
|
|
1
|
+
import{AGENT_MODE_ENV as o,detectAiAgent as t}from"./packem_shared/AGENT_MODE_ENV-D8MvSwPE.mjs";import{discoverAgentInfo as E}from"./packem_shared/discoverAgentInfo-pqFMJBtJ.mjs";import{AGENT_RULES_DIR as i,AGENT_RULES_HINT as n,AGENT_RULES_HINT_ENV as _,LUNORA_SKILL_NAMES as l,ROOT_SKILL_NAME as c,claimAgentRulesHint as p,detectAgentRules as D}from"./packem_shared/AGENT_RULES_DIR-Bd6JPtNa.mjs";import{clearApiSpecMarker as A,readApiSpecMarker as m,writeApiSpecMarker as S}from"./packem_shared/clearApiSpecMarker-DMGpP41V.mjs";import{MissingBuildOutputError as L}from"./packem_shared/MissingBuildOutputError-BAyekzof.mjs";import{default as T}from"./packem_shared/canonicalPath-DrfMiT3U.mjs";import{probeCelldToolchain as v}from"./packem_shared/probeCelldToolchain-DxDttfHy.mjs";import{startCelldDevSession as g,writeCelldDevProjection as I}from"./packem_shared/startCelldDevSession-BKRiLvt-.mjs";import{D1_PLACEHOLDER_ID as u}from"./packem_shared/D1_PLACEHOLDER_ID-ZnDjVymH.mjs";import{BUILD_ROOT_ENV as P,BUILD_TARGET_ENV as C,BUNDLE_META_PATH_ENV as M,CODEGEN_ENV as U,DEFAULT_BUNDLE_META_PATH as F,LAZY_FUNCTIONS_ENV as B,STRICT_ADVISORIES_ENV as G,isCodegenDisabled as b,isLazyFunctionsEnabled as y,resolveLazyFunctions as k}from"./packem_shared/BUILD_ROOT_ENV-Dg4MV3wY.mjs";import{discoverContainerInfo as j}from"./packem_shared/discoverContainerInfo-DzXr7Vm3.mjs";import{streamContainerLogs as K}from"./packem_shared/streamContainerLogs-0nko1qpv.mjs";import{detectFramework as W,projectUsesUmbrella as Y}from"./packem_shared/detectFramework-Dfpvu6rD.mjs";import{acceptsConnection as z,startDevProcess as q}from"./packem_shared/acceptsConnection-DHhUYGjT.mjs";import{DEV_BINDINGS_FILE as Z,DEV_DAEMON_ENV as Q,DEV_HANDOFF_ENV as $,DEV_LOG_FILE as ee,DEV_LOG_FILE_ENV as re,DEV_STATE_DIR as oe,DEV_STATE_FILE as te,claimDevServerState as ae,clearDevServerState as Ee,isDevServerReady as se,isProcessAlive as ie,isRecordedProcessCurrent as ne,readDevServerState as _e,readLiveDevServerState as le,updateDevServerState as ce,writeDevServerState as pe}from"./packem_shared/DEV_BINDINGS_FILE-C0ZN_XlP.mjs";import{DEV_VARS_EXAMPLE_FILE as de,DEV_VARS_FILE as Ae,DEV_VARS_KEY_PATTERN as me,escapeRegExp as Se,parseDevVariableEntries as fe,removeDevVariableLine as Le,upsertDevVariableLine as Ne}from"./packem_shared/DEV_VARS_EXAMPLE_FILE-CqLorAxT.mjs";import{DEV_WORKER_ENV_VALUE as Re,DEV_WORKER_ENV_VAR as ve,ensureDevWorkerEnv as xe}from"./packem_shared/DEV_WORKER_ENV_VALUE-CgozgOxh.mjs";import{createDiscoveryCache as Ie}from"./packem_shared/createDiscoveryCache-npJI4uej.mjs";import{DEFAULT_DEPLOY_TARGET as ue,deployTargetIds as Oe,isRunnableTarget as Pe,planToolchainInvocation as Ce,resolveDeployDriver as Me,runnableTargetIds as Ue,targetRunsOwnDevServer as Fe}from"./packem_shared/DEFAULT_DEPLOY_TARGET-DllYb7Tj.mjs";import{default as Ge}from"./packem_shared/ensureGitignoreEntries-Tsk8Qkw7.mjs";import{inferLunoraBindings as ye,secretSourcesFromBindings as ke}from"./packem_shared/inferLunoraBindings-CGy-uHu6.mjs";import{LINKED_PROJECT_DIR as je,LINKED_PROJECT_FILE as we,readLinkedProject as Ke,writeLinkedProject as He}from"./packem_shared/LINKED_PROJECT_DIR-Ba5qPEwo.mjs";import{LUNORA_IGNORED_PATHS as Ye,applyLintIgnores as Je,detectLintTools as ze}from"./packem_shared/LUNORA_IGNORED_PATHS-U93uPxrW.mjs";import{blockingFindingsMessage as Xe,reportCodegenFindings as Ze}from"./packem_shared/blockingFindingsMessage-CRbg1sla.mjs";import{LUNORA_EVENT_SOURCE as $e,formatLunoraEvent as er}from"./packem_shared/LUNORA_EVENT_SOURCE-B9ZVohjO.mjs";import{LUNORA_TAG as or,advisoryLine as tr,lunoraLine as ar}from"./packem_shared/LUNORA_TAG-DQTGPqcJ.mjs";import{default as sr}from"./packem_shared/LunoraReporter-f277GLNT.mjs";import{addArgsFor as nr,detectInstalledManagers as _r,detectPackageManager as lr,execArgsFor as cr,installArgsFor as pr,runScriptArgsFor as Dr,runScriptCommand as dr,toolchainExecArgs as Ar}from"./packem_shared/addArgsFor-CYZKhNIo.mjs";import{P as Sr,m as fr,s as Lr}from"./packem_shared/package-secrets-registry-UQ_uEAB_.mjs";import{runPostCodegenHook as Tr}from"./packem_shared/runPostCodegenHook-Dx3yTsYZ.mjs";import{assertBuildTargetMatches as vr,interpretRemote as xr,readProjectRemotePreference as gr,readProjectTarget as Ir,resolveProjectTarget as Vr,resolveTargetOrThrow as ur}from"./packem_shared/assertBuildTargetMatches-CqrrwiQ-.mjs";import{readProjectDependencies as Pr,readProjectDependencyNames as Cr,readProjectManifest as Mr}from"./packem_shared/readProjectDependencies-l3uhUKjo.mjs";import{createConfirm as Fr,isInteractive as Br,promptMultiSelect as Gr,promptSelect as br,promptText as yr,promptYesNo as kr}from"./packem_shared/createConfirm-D5mKTMHj.mjs";import{default as jr}from"./packem_shared/resolveSchemaDirectory-Ca5P6KuP.mjs";import{buildPackageSecretsBlock as Kr,ensureDevVariables as Hr,ensureDevVarsExample as Wr,fillDevSecrets as Yr,generateSecretValue as Jr,isMintableSecretKey as zr,isPlaceholderValue as qr,planDevSecretsFill as Xr,planDevVariablesAugment as Zr,planDevVariablesScaffold as Qr,requiredSecrets as $r,writeDevVariablesFileAtomically as eo}from"./packem_shared/buildPackageSecretsBlock-GvaLgvFN.mjs";import{applyAdditiveEdit as oo,classifyEdit as to}from"./packem_shared/applyAdditiveEdit-DEwPKcJg.mjs";import{parseSchema as Eo}from"./packem_shared/parseSchema-D1Wbr1qv.mjs";import{classifyPolicyEdit as io,resolveServerModule as no,scaffoldPolicyFile as _o,wireRlsIntoProcedure as lo}from"./packem_shared/classifyPolicyEdit-DJi9Fk8G.mjs";import{discoverSchemaInfo as po}from"./packem_shared/discoverSchemaInfo-DRPnqgif.mjs";import{ACCENT as Ao,BADGES as mo,BADGE_COLUMN_WIDTH as So,LUNA_ART as fo,LUNA_BUNNY as Lo,LUNA_NAME as No,LUNA_SIGNOFF as To,STEP_BADGE_NAMES as Ro,badgeLead as vo,badgeWidth as xo,padBadge as go,paintAnswer as Io,paintBadge as Vo}from"./packem_shared/ACCENT-CotPTfv7.mjs";import{COMPOSED_WORKER_ENTRY as Oo,DURABLE_OBJECT_BINDINGS as Po,GENERATED_CLASS_MODULES as Co,GENERATED_MODULE_DURABLE_OBJECTS as Mo,MERGED_DURABLE_OBJECTS_MODULE as Uo,isMergedProject as Fo,isMergedRoleModule as Bo}from"./packem_shared/COMPOSED_WORKER_ENTRY-BcFt6ts5.mjs";import{discoverWorkflowInfo as bo}from"./packem_shared/discoverWorkflowInfo-zW7Tt0Tn.mjs";export{Ao as ACCENT,o as AGENT_MODE_ENV,i as AGENT_RULES_DIR,n as AGENT_RULES_HINT,_ as AGENT_RULES_HINT_ENV,mo as BADGES,So as BADGE_COLUMN_WIDTH,P as BUILD_ROOT_ENV,C as BUILD_TARGET_ENV,M as BUNDLE_META_PATH_ENV,U as CODEGEN_ENV,Oo as COMPOSED_WORKER_ENTRY,u as D1_PLACEHOLDER_ID,F as DEFAULT_BUNDLE_META_PATH,ue as DEFAULT_DEPLOY_TARGET,Z as DEV_BINDINGS_FILE,Q as DEV_DAEMON_ENV,$ as DEV_HANDOFF_ENV,ee as DEV_LOG_FILE,re as DEV_LOG_FILE_ENV,oe as DEV_STATE_DIR,te as DEV_STATE_FILE,de as DEV_VARS_EXAMPLE_FILE,Ae as DEV_VARS_FILE,me as DEV_VARS_KEY_PATTERN,Re as DEV_WORKER_ENV_VALUE,ve as DEV_WORKER_ENV_VAR,Po as DURABLE_OBJECT_BINDINGS,Co as GENERATED_CLASS_MODULES,Mo as GENERATED_MODULE_DURABLE_OBJECTS,B as LAZY_FUNCTIONS_ENV,je as LINKED_PROJECT_DIR,we as LINKED_PROJECT_FILE,fo as LUNA_ART,Lo as LUNA_BUNNY,No as LUNA_NAME,To as LUNA_SIGNOFF,$e as LUNORA_EVENT_SOURCE,Ye as LUNORA_IGNORED_PATHS,l as LUNORA_SKILL_NAMES,or as LUNORA_TAG,sr as LunoraReporter,Uo as MERGED_DURABLE_OBJECTS_MODULE,L as MissingBuildOutputError,Sr as PACKAGE_SECRETS_REGISTRY,c as ROOT_SKILL_NAME,Ro as STEP_BADGE_NAMES,G as STRICT_ADVISORIES_ENV,z as acceptsConnection,nr as addArgsFor,tr as advisoryLine,oo as applyAdditiveEdit,Je as applyLintIgnores,vr as assertBuildTargetMatches,vo as badgeLead,xo as badgeWidth,Xe as blockingFindingsMessage,Kr as buildPackageSecretsBlock,T as canonicalPath,p as claimAgentRulesHint,ae as claimDevServerState,to as classifyEdit,io as classifyPolicyEdit,A as clearApiSpecMarker,Ee as clearDevServerState,Fr as createConfirm,Ie as createDiscoveryCache,Oe as deployTargetIds,D as detectAgentRules,t as detectAiAgent,W as detectFramework,_r as detectInstalledManagers,ze as detectLintTools,lr as detectPackageManager,E as discoverAgentInfo,j as discoverContainerInfo,po as discoverSchemaInfo,bo as discoverWorkflowInfo,Hr as ensureDevVariables,Wr as ensureDevVarsExample,xe as ensureDevWorkerEnv,Ge as ensureGitignoreEntries,Se as escapeRegExp,cr as execArgsFor,Yr as fillDevSecrets,er as formatLunoraEvent,Jr as generateSecretValue,ye as inferLunoraBindings,pr as installArgsFor,xr as interpretRemote,b as isCodegenDisabled,se as isDevServerReady,Br as isInteractive,y as isLazyFunctionsEnabled,Fo as isMergedProject,Bo as isMergedRoleModule,zr as isMintableSecretKey,qr as isPlaceholderValue,ie as isProcessAlive,ne as isRecordedProcessCurrent,Pe as isRunnableTarget,ar as lunoraLine,fr as mintableSecretKeysFor,go as padBadge,Io as paintAnswer,Vo as paintBadge,fe as parseDevVariableEntries,Eo as parseSchema,Xr as planDevSecretsFill,Zr as planDevVariablesAugment,Qr as planDevVariablesScaffold,Ce as planToolchainInvocation,v as probeCelldToolchain,Y as projectUsesUmbrella,Gr as promptMultiSelect,br as promptSelect,yr as promptText,kr as promptYesNo,m as readApiSpecMarker,_e as readDevServerState,Ke as readLinkedProject,le as readLiveDevServerState,Pr as readProjectDependencies,Cr as readProjectDependencyNames,Mr as readProjectManifest,gr as readProjectRemotePreference,Ir as readProjectTarget,Le as removeDevVariableLine,Ze as reportCodegenFindings,$r as requiredSecrets,Me as resolveDeployDriver,k as resolveLazyFunctions,Vr as resolveProjectTarget,jr as resolveSchemaDirectory,no as resolveServerModule,ur as resolveTargetOrThrow,Tr as runPostCodegenHook,Dr as runScriptArgsFor,dr as runScriptCommand,Ue as runnableTargetIds,_o as scaffoldPolicyFile,ke as secretSourcesFromBindings,Lr as secretsForPackages,g as startCelldDevSession,q as startDevProcess,K as streamContainerLogs,Fe as targetRunsOwnDevServer,Ar as toolchainExecArgs,ce as updateDevServerState,Ne as upsertDevVariableLine,lo as wireRlsIntoProcedure,S as writeApiSpecMarker,I as writeCelldDevProjection,pe as writeDevServerState,eo as writeDevVariablesFileAtomically,He as writeLinkedProject};
|
package/dist/packem_shared/{collectExportGaps-CLrCQp09.mjs → collectExportGaps-CO1Se31Y.mjs}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{readFileSync as ee,writeFileSync as ne}from"node:fs";import{createRequire as se}from"node:module";import{join as Q}from"node:path";import{containerBuildTag as te}from"@lunora/container";import{readJsonSync as ie}from"@visulima/fs";import{c as oe}from"./celld-binding-id-9MiUoteo.mjs";import{applyModify as w}from"./applyModify-DKP2l6S9.mjs";import{recordManifestKey as ae,readManifest as Y}from"./readManifest-Cighz3WC.mjs";import{D1_PLACEHOLDER_ID as U,HYPERDRIVE_PLACEHOLDER_ID as re}from"./D1_PLACEHOLDER_ID-ZnDjVymH.mjs";import{parseTree as de,findNodeAtLocation as ce}from"jsonc-parser";import{r as le,a as ue,b as ge,c as me}from"./reconcile-services-C4TwY8YH.mjs";import{DEV_VARS_FILE as pe,parseDevVariableEntries as fe}from"./DEV_VARS_EXAMPLE_FILE-CqLorAxT.mjs";import{secretSourcesFromBindings as be}from"./inferLunoraBindings-
|
|
2
|
-
`,t.offset-1)+1,a=Oe.exec(e.slice(o));if(a!==null&&e.slice(i,t.offset).trim()===""){const m=t.parent?.children??[],u=m.indexOf(t),d=u===m.length-1&&u>0?m[u-1]:void 0,c=d===void 0?void 0:Ne.exec(e.slice(d.offset+d.length))??void 0;return(c===void 0||d===void 0?e.slice(0,i):e.slice(0,d.offset+d.length)+e.slice(d.offset+d.length+c[0].length,i))+e.slice(o+a[0].length)}}return w(e,n,void 0)},J=(e,n,s,t,o,i=new Set)=>{const a=s.join("."),m={},u=[],d=[];let c=e;return{entries:n.map((l,v)=>{const g=t(l);if(g===void 0||l.queue===void 0)return l;const b=Object.fromEntries(Object.entries(B(g)).filter(([f])=>!i.has(f))),h=Object.entries(o[l.queue]??{}).filter(([f])=>!Object.hasOwn(b,f)),_=Object.entries(b).filter(([f,y])=>l[f]!==y),E=h.filter(([f,y])=>l[f]===y).map(([f])=>f),O=Object.fromEntries(Object.entries({...l,...b}).filter(([f])=>!E.includes(f)));for(const[f,y]of _)c=w(c,[...s,v,f],y);for(const f of E)c=ke(c,[...s,v,f]);for(const[f,y]of h){const A=l[f];A!==void 0&&A!==y&&d.push(`${a}/${l.queue}: ${f} is no longer declared by defineQueue, but it was changed by hand to ${JSON.stringify(A)} from the declared ${JSON.stringify(y)}, so it was kept. Delete it from wrangler.jsonc if it should go.`)}return(_.length>0||E.length>0)&&u.push(`${a}/${l.queue} (${[..._.map(([f])=>f),...E.map(f=>`removed ${f}`)].join(", ")})`),Object.keys(b).length>0&&(m[l.queue]=b),O}),owned:m,text:c,updated:u,warnings:d}},$e=(e,n,s,t)=>{const o=n.queues??{},i=o.producers??[],a=o.consumers??[],m=new Set(i.map(g=>g?.binding)),u=new Set(a.map(g=>g.queue)),d=s.filter(g=>!m.has(g.bindingName)),c=s.filter(g=>!u.has(g.name)),p=J(e,a,["queues","consumers"],g=>s.find(b=>b.name===g.queue),t);let l=p.text;const v={...p.owned};if(d.length>0||c.length>0){const g=[...i,...d.map(h=>({binding:h.bindingName,queue:h.name}))],b=[...p.entries,...c.map(h=>({queue:h.name,...h.mode==="pull"?{type:"http_pull"}:{},...B(h)}))];for(const h of c){const _=B(h);Object.keys(_).length>0&&(v[h.name]=_)}l=w(l,["queues"],{consumers:b,producers:g})}return{added:[...d.map(g=>`queues.producers/${g.bindingName}`),...c.map(g=>`queues.consumers/${g.name}`)],owned:v,text:l,updated:p.updated,warnings:p.warnings}},Ce=(e,n,s,t,o)=>{const i=n.env?.[t],a=i?.queues?.consumers??[],m=i?.queues?.producers??[],u=l=>{const v=m.find(g=>g?.queue===l.queue)?.binding;return v!==void 0?s.find(g=>g.bindingName===v):s.find(g=>g.name===l.queue&&!m.some(b=>b?.binding===g.bindingName))},d=J(e,a,["env",t,"queues","consumers"],u,o,new Set(["dead_letter_queue"])),c=a.filter(l=>l.queue!==void 0&&u(l)===void 0).map(l=>`env.${t}.queues.consumers/${String(l.queue)}: no defineQueue export matches it — this block declares no producer mapping one of their bindings to "${String(l.queue)}", and no export is named that — so it was not retuned. A consumer for a queue another worker produces is skipped the same way.`),p=a.flatMap(l=>{const v=u(l)?.tuning.deadLetterQueue;return v===void 0||l.dead_letter_queue!==void 0?[]:[`env.${t}.queues.consumers/${String(l.queue)}: defineQueue declares deadLetterQueue "${v}", but this consumer has no dead_letter_queue, so its exhausted messages are dropped. Queue names differ per environment, so reconcile does not write it here; add it by hand.`]});return{added:[],owned:d.owned,text:d.text,updated:d.updated,warnings:[...d.warnings,...p,...c]}},Te=(e,n)=>{if(e?.lunoraIsForeign===!0)return n.push(`${e.path}: \`lunora\` is not an object, so the queue tuning ownership record cannot be read or written — an option removed from defineQueue stays deployed.`),{};const s=e?.lunora?.[L],t=o=>typeof o=="object"&&o!==null&&!Array.isArray(o);return s===void 0?{}:!t(s)||!Object.values(s).every(o=>t(o)&&Object.values(o).every(i=>t(i)))?(n.push(`${e?.path??"package.json"}: \`lunora.${L}\` is not a map of scope → queue → fields, so it is ignored — an option removed from defineQueue stays deployed until the next pass records it again.`),{}):s},Ie=(e,n,s)=>{const t=Object.fromEntries(Object.entries({...n,...s}).filter(([,o])=>Object.keys(o).length>0));ae(e,L,Object.keys(t).length===0?void 0:t)},je="https://api.cloudflare.com/client/v4/accounts/<ACCOUNT_ID>/artifacts/namespaces",Re=e=>{const n='add an "artifacts" binding ({ binding: "ARTIFACTS", namespace }) — codegen reads env.ARTIFACTS unless `.artifacts()` on defineApp points ctx.artifacts at another binding';return e===void 0?`ctx.artifacts is used; ${n}. The namespace is created by the first repo create() if it does not exist yet.`:`ctx.artifacts is used and the schema pins data to "${e}"; create the namespace in that jurisdiction BEFORE the first repo, with POST ${je} and body { "namespace": "<name>", "jurisdiction": "${e}" }, then ${n}. A namespace's jurisdiction cannot be changed, and one created implicitly by the first repo create() is unrestricted. With CLOUDFLARE_API_TOKEN set, \`lunora deploy\` creates a missing namespace in that jurisdiction for a binding you have added.`},j="PIPELINES",R="ARTIFACTS",qe=(e,n,s)=>{const t=n!==void 0&&(s===void 0||s==="cloudflare"),o=e.flagshipBinding!==void 0&&!(n?.flagship??[]).some(d=>d.binding===e.flagshipBinding),i=e.usesPipelines&&!(n?.pipelines??[]).some(d=>d.binding===j),a=e.usesArtifacts?n?.artifacts??[]:[],m=a.some(d=>d.binding===R)?[]:a.flatMap(d=>d.binding===void 0?[]:[d.binding]);return[[e.usesKv&&(n?.kv_namespaces?.length??0)===0&&(!t||e.jurisdiction!==void 0),e.jurisdiction===void 0?'ctx.kv is used but no kv_namespaces binding exists; add one ({ binding: "KV" }) — wrangler creates the namespace on the first deploy.':`ctx.kv is used and the schema pins data to "${e.jurisdiction}"; run \`wrangler kv namespace create <name> --jurisdiction ${e.jurisdiction}\` and add a kv_namespaces entry ({ binding: "KV", id }) — a namespace wrangler creates on deploy is unrestricted.`],[e.usesHyperdrive&&(n?.hyperdrive?.length??0)===0&&!t,'@lunora/hyperdrive is used but no hyperdrive binding exists; add one ({ binding: "HYPERDRIVE", id }) — on a Cloudflare target `lunora deploy` creates the Hyperdrive config from a connection string.'],[e.usesArtifacts&&a.length===0&&(!t||e.jurisdiction!==void 0),Re(e.jurisdiction)],[i,`ctx.pipelines is used but no "${j}" pipelines binding exists; run 'wrangler pipelines create <name>' and add a 'pipelines' binding ({ binding: "${j}", stream }) — codegen resolves this one name, and the pipeline resource can't be auto-provisioned.`],[m.length>0,`ctx.artifacts is used and ${m.map(d=>`"${d}"`).join(", ")} ${m.length===1?"is":"are"} bound, but none is named "${R}"; make sure \`.artifacts()\` on defineApp points ctx.artifacts at it — otherwise it reads env.${R} and throws.`],[o,`lunora/flags.ts uses Flagship in binding mode but no flagship binding "${e.flagshipBinding??""}" exists; add a flagship entry ({ binding: "${e.flagshipBinding??""}", app_id }) — the app_id can't be auto-provisioned.`]].filter(([d])=>d).map(([,d])=>d)},De=e=>[[e.usesX402Charge,"@lunora/x402/charge is used; set the recipient wallet address as a [vars] entry (the var name is your choice) and pass it to the charge config — the x402 facilitator settles USDC to that address."],[e.usesX402,"@lunora/x402/pay is used (ActionCtx-only, spends real funds); add a secrets_store_secrets[] binding holding the agent wallet key (binding name == signer.secretName) and pair the pay rail with a spend policy — ctx.secrets reads a Secrets Store binding, not .dev.vars."]].filter(([s])=>s).map(([,s])=>s),q=(e,n,s)=>s.filter(t=>!t.exported).map(t=>`${e} "${t.exportName}" is declared but ${t.className} is not exported by the worker entry; add \`export * from "./lunora/_generated/${n}"\` so its binding can be provisioned.`),Pe=(e,n)=>{const s=new Set([...e.workflows,...e.agents].map(i=>i.className));if(s.size===0)return[];const t=Object.entries(n.exports??{}).flatMap(([i,a])=>a?.type==="workflow"?[i]:[]),o=(n.workflows??[]).flatMap(i=>i.class_name===void 0||i.script_name!==void 0?[]:[i.class_name]);return[...new Set([...t,...o])].filter(i=>!s.has(i)).map(i=>`wrangler.jsonc declares workflow "${i}" but no defineWorkflow/defineAgent export generates that class — a leftover from a rename will fail the deploy (wrangler rejects a class the worker does not export). Remove it if it is not hand-wired.`)},Be=(e,n)=>{if(e.queues.length===0)return[];const s=new Set(e.queues.map(o=>o.name)),t=new Set(e.queues.map(o=>o.bindingName));return[...(n.queues?.consumers??[]).flatMap(o=>{const{queue:i}=o;return i===void 0||s.has(i)?[]:[`wrangler.jsonc subscribes queues.consumers[] to "${i}" but no defineQueue export declares that queue — a leftover from a rename keeps delivering batches this worker has no handler for (they retry to exhaustion, then drop or dead-letter). Remove it if it is not hand-wired.`]}),...(n.queues?.producers??[]).flatMap(o=>{const i=o?.binding;return i===void 0||t.has(i)?[]:[`wrangler.jsonc declares queues.producers[] binding "${i}" but no defineQueue export declares it — a leftover from a rename. Remove it if it is not hand-wired.`]})]},Le=(e,n)=>[...Pe(e,n),...Be(e,n)],X=[{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"}],We=()=>X.map(({keys:e,label:n})=>`${e[0]} + ${e[1]} (${n})`).join(" or "),Me=e=>{let n;try{n=ee(Q(e,pe),"utf8")}catch{return!1}const s=new Map(fe(n).map(t=>[t.key,t.value]));return X.some(({keys:t})=>t.every(o=>(s.get(o)??"")!==""))},Ke=(e,n)=>{const s=n?.secrets?.required;if(!Array.isArray(s))return[];const t=new Set(s),o=he(be(e)).map(i=>i.key).filter(i=>!t.has(i));return o.length===0?[]:[`wrangler.jsonc declares secrets.required without ${o.join(", ")}, which this app needs — wrangler dev loads only the listed keys from .dev.vars, so add ${o.length===1?"it":"them"} to secrets.required.`]},D=(e,n,s,t)=>{const o=new Set(e.durableObjects.map(u=>u.className)),i=[],a=(s?.r2_buckets?.length??0)>0,m=(s?.d1_databases?.some(u=>u.binding==="DB")??!1)||e.needsD1;return e.usesStorage&&!a&&i.push("@lunora/storage is used but R2 bucket bindings have user-defined names; add an r2_buckets entry and pass env.<BINDING> to createStorage()."),e.usesAuth&&!o.has("SessionDO")&&!m&&i.push("@lunora/auth is used but the worker entry exports no SessionDO; sessions are D1-backed, or export SessionDO to enable DO-backed sessions."),e.usesScheduler&&!o.has("SchedulerDO")&&i.push("@lunora/scheduler is used but the worker entry exports no SchedulerDO; export it so the SCHEDULER binding can be provisioned."),i.push(...q("container","containers",e.containers),...q("workflow","workflows",e.workflows),...q("agent","agents",e.agents)),e.containers.length>0&&s?.observability?.enabled===!1&&i.push("containers are declared but observability is explicitly disabled in wrangler.jsonc — container logs will not be captured."),e.usesPayments&&!Me(n)&&i.push(`@lunora/payment is used; set one provider's secret pair in .dev.vars — ${We()}.`),i.push(...De(e),...qe(e,s,t),...Ke(e,s)),s!==void 0&&i.push(...Le(e,s)),i},Fe=e=>[["container","containers",e.containers],["workflow","workflows",e.workflows],["agent","agents",e.agents]].flatMap(([s,t,o])=>o.filter(i=>!i.exported).map(({className:i,exportName:a})=>({className:i,exportName:a,kind:s,module:t}))),He=e=>{const n=new Set(P(e).map(t=>t.tag));let s=1;for(;n.has(`v${String(s)}`);)s+=1;return`v${String(s)}`},Ye=e=>{const n=new Set;for(const s of P(e)){for(const t of I(s.deleted_classes))n.delete(t);for(const{from:t,to:o}of P(s.renamed_classes))t!==void 0&&n.delete(t),o!==void 0&&n.add(o);for(const t of[...I(s.new_classes),...I(s.new_sqlite_classes)])n.add(t)}return n},Ve=(e,n,s)=>{const t=n.durable_objects?.bindings??[],o=new Set(t.map(c=>c.name)),i=s.filter(c=>!o.has(c.binding));let a=e;const m=[];if(i.length>0){const c=[...t,...i.map(p=>({class_name:p.className,name:p.binding}))];a=w(a,["durable_objects","bindings"],c),m.push(...i.map(p=>`${p.binding}/${p.className}`))}const u=n.migrations??[],d=s.map(c=>c.className).filter(c=>!Ye(u).has(c));if(d.length>0){const c=[...u,{new_sqlite_classes:d,tag:He(u)}];a=w(a,["migrations"],c)}return{added:m,text:a}},M=e=>e===void 0||e==="cloudflare",Qe=(e,n)=>e.includes("DB (D1)")&&M(n)?[`wrote a DB binding with a placeholder database_id ("${U}") — run \`wrangler d1 create <name>\` and replace it before deploying.`]:[],Ue=(e,n)=>{const s=n.d1_databases??[];if(s.some(i=>i.binding==="DB"))return{added:[],text:e};const t=typeof n.name=="string"&&n.name.length>0?n.name:"lunora",o=[...s,{binding:"DB",database_id:U,database_name:t}];return{added:["DB (D1)"],text:w(e,["d1_databases"],o)}},Ge={ai:{binding:"AI",label:"AI (Workers AI)"},analytics:{binding:"ANALYTICS_SQL",label:"ANALYTICS_SQL (Analytics SQL)"},browser:{binding:"BROWSER",label:"BROWSER (Browser Rendering)"},images:{binding:"IMAGES",label:"IMAGES (Cloudflare Images)"}},k=(e,n,s)=>{const{binding:t,label:o}=Ge[s],i=n[s]?.binding;return typeof i=="string"&&i.length>0?{added:[],text:e}:{added:[o],text:w(e,[s],{binding:t})}},Je=(e,n)=>e.usesAnalyticsSql&&ye(n,new Set(["analyticsSql"]))?.chained.has("analyticsSql")!==!0,Xe=new Set(["ratelimits","send_email"]),ze=["durable_objects","logfwdr","unsafe"],Ze=new Set(["data_blobs","text_blobs","vars","wasm_modules"]),K=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),W=(e,n,s)=>K(e)&&e[n]===s,en=(e,n,s)=>{if(Ze.has(e))return K(n)&&Object.hasOwn(n,s);const t=Xe.has(e)?"name":"binding";return Array.isArray(n)?n.some(o=>W(o,t,s)):W(n,"binding",s)},$=(e,n)=>{const s=e,t=Object.entries(s).find(([i,a])=>i!=="env"&&en(i,a,n));if(t!==void 0)return t[0];for(const i of ze){const a=s[i];if(K(a)&&Array.isArray(a.bindings)&&a.bindings.some(m=>W(m,"name",n)))return`${i}.bindings`}if(e.queues?.producers?.some(i=>i?.binding===n)===!0)return"queues.producers";const o=e.secrets?.required;if(Array.isArray(o)&&o.includes(n))return"secrets.required"},F=(e,n,s)=>`${e}: not adding "${n}" — the name is already bound by \`${s}\` in wrangler.jsonc. Add a ${e} entry under another binding name and point the matching \`defineApp()\` override at it.`,nn=(e,n,s)=>{if(!M(s)||(n.hyperdrive?.length??0)>0)return{added:[],text:e};const t=$(n,"HYPERDRIVE");return t!==void 0?{added:[],text:e,warnings:[F("hyperdrive","HYPERDRIVE",t)]}:{added:["HYPERDRIVE (Hyperdrive, created on deploy)"],text:w(e,["hyperdrive"],[{binding:"HYPERDRIVE",id:re}])}},sn=new Set(["celld","cloudflare"]),tn=(e,n,s,t)=>{if(t!==void 0&&!sn.has(t)||s!==void 0||(n.kv_namespaces?.length??0)>0)return{added:[],text:e};const o=$(n,"KV");return o!==void 0?{added:[],text:e,warnings:[F("kv_namespaces","KV",o)]}:{added:[t==="celld"?`KV (Workers KV, celld namespace ${oe(n.name,"KV")})`:"KV (Workers KV, created on deploy)"],text:w(e,["kv_namespaces"],[{binding:"KV"}])}},on=(e,n,s,t)=>{if(!M(t)||s!==void 0||(n.artifacts?.length??0)>0)return{added:[],text:e};const o=$(n,"ARTIFACTS");if(o!==void 0)return{added:[],text:e,warnings:[F("artifacts","ARTIFACTS",o)]};const i=typeof n.name=="string"&&n.name.length>0?n.name:"lunora";return{added:["ARTIFACTS (Cloudflare Artifacts)"],text:w(e,["artifacts"],[{binding:"ARTIFACTS",namespace:i}])}},V=(e,n,s,t,o)=>{if((n[s]?.length??0)>0)return{added:[],text:e};const i=$(n,t.binding);return i!==void 0?{added:[],text:e,warnings:[`${s}: not adding ${JSON.stringify(t)} — the name "${t.binding}" is already bound by \`${i}\` in wrangler.jsonc. Add a ${s} entry under another binding name and point the matching \`defineApp()\` override at it.`]}:{added:[o],text:w(e,[s],[t])}},an=(e,n)=>{const s=n.worker_loaders??[];return s.some(t=>t.binding==="LOADER")?{added:[],text:e}:{added:["LOADER (Worker Loader)"],text:w(e,["worker_loaders"],[...s,{binding:"LOADER"}])}},rn=e=>{if(typeof e=="string")return e;const n={};return e.diskMb!==void 0&&(n.disk_mb=e.diskMb),e.memoryMib!==void 0&&(n.memory_mib=e.memoryMib),e.vcpu!==void 0&&(n.vcpu=e.vcpu),n},dn=e=>{const{image:n}=e;return n.kind==="dockerfile"?n.dockerfilePath:n.kind==="registry"?n.reference:te(e.exportName)},z=e=>{const n={};for(const[s,t]of Object.entries(e.images??{}))n[s]=t.kind==="registry"?{image:t.reference}:{build_context:t.buildContext,dockerfile:t.dockerfilePath,...e.buildArgs===void 0?{}:{build_vars:e.buildArgs}};return{class_name:e.className,scheduling_policy:"durable_object",...Object.keys(n).length>0?{images:n}:{},...e.name===void 0?{}:{name:e.name}}},cn=e=>{if(e.schedulingPolicy==="durable_object")return z(e);const{image:n}=e,s={class_name:e.className,image:dn(e)};return n.kind==="dockerfile"&&(s.image_build_context=n.buildContext),e.buildArgs!==void 0&&n.kind!=="registry"&&(s.image_vars=e.buildArgs),e.instanceType!==void 0&&(s.instance_type=rn(e.instanceType)),e.maxInstances!==void 0&&(s.max_instances=e.maxInstances),e.name!==void 0&&(s.name=e.name),e.rollout?.stepPercentage!==void 0&&(s.rollout_step_percentage=e.rollout.stepPercentage),e.rollout?.gracePeriodSeconds!==void 0&&(s.rollout_active_grace_period=e.rollout.gracePeriodSeconds),s},ln=(e,n,s)=>{const t=n.containers??[],o=new Set(t.map(d=>d.class_name)),i=s.filter(d=>!o.has(d.className));let a=i.length===0?e:w(e,["containers"],[...t,...i.map(d=>cn(d))]);const m=[],u=[];for(const[d,c]of t.entries()){const p=s.find(g=>g.className===c.class_name);if(p===void 0)continue;const l=p.schedulingPolicy??"default";if((c.scheduling_policy??"default")!==l){u.push(`containers/${p.className} has scheduling_policy "${c.scheduling_policy??"default"}" in wrangler.jsonc but defineContainer "${p.exportName}" declares "${l}" — the policy is immutable, so replace the entry (and its container application) by hand.`);continue}const v=p.schedulingPolicy==="durable_object"?z(p).images:void 0;v!==void 0&&JSON.stringify(c.images)!==JSON.stringify(v)&&(a=w(a,["containers",d,"images"],v),m.push(`containers/${p.className}.images`))}return{added:i.map(d=>`containers/${d.className}`),text:a,updated:m,warnings:u}},un=(e,n)=>{if(n.observability!==void 0)return{added:[],text:e};const s=w(e,["observability"],{...Se});return{added:["observability"],text:s}},gn=(e,n)=>n.upload_source_maps!==void 0?{added:[],text:e}:{added:["upload_source_maps"],text:w(e,["upload_source_maps"],!0)},Z=[{minimum:[4,142],name:"wrangler"},{minimum:[1,61],name:"@cloudflare/vite-plugin"}],mn=Z.map(({minimum:e,name:n})=>`${n}@^${e.join(".")}.0`).join(" "),pn=(e,n)=>{try{const s=se(Q(e,"package.json")).resolve(`${n}/package.json`),[t=0,o=0]=String(ie(s).version).split(".").map(Number);return[t,o]}catch{return}},fn=e=>{const n=Z.flatMap(({minimum:s,name:t})=>{const o=pn(e,t);return o!==void 0&&(o[0]<s[0]||o[0]===s[0]&&o[1]<s[1])?[`${t} ${o.join(".")} (needs >= ${s.join(".")})`]:[]});return n.length===0?void 0:`workflows are declared in wrangler \`exports\`, which ${n.join(" and ")} cannot run — reconcile left workflows[] untouched. Upgrade (\`pnpm add -D ${mn}\`) and re-run.`},bn=e=>Object.entries(e.env??{}).flatMap(([n,s])=>Array.isArray(s?.workflows)?[`env.${n}.workflows declares workflow bindings, but Lunora now declares workflows in \`exports\` and resolves them on ctx.exports — move them to that environment's own \`exports\` by hand.`]:[]),hn=(e,n,s)=>{let t=e;const o=[],i=[];for(const a of s){const m=n[a.className];if(m?.type==="workflow")for(const{of:u,path:d}of _e){const c=u(a),p=G(m,d),l=`exports/${a.className}.${d.join(".")}`;if(c===void 0){p!==void 0&&i.push(`${l} is set in wrangler.jsonc but defineWorkflow "${a.exportName}" does not declare it — reconcile leaves it in place. Remove it by hand if it was dropped from the definition.`);continue}JSON.stringify(p)!==JSON.stringify(c)&&(t=w(t,["exports",a.className,...d],c),o.push(l))}}return{text:t,updated:o,warnings:i}},vn=(e,n,s,t,o)=>{if(o!==void 0)return{added:[],text:e,warnings:[o]};const i=[...s.map(b=>({settings:ve(b),workflow:b})),...t.map(b=>({settings:{},workflow:b}))],a=new Set(i.map(({workflow:b})=>b.className)),m=n.workflows??[],u=m.filter(b=>b.script_name===void 0&&b.class_name!==void 0&&a.has(b.class_name)),d=n.exports??{},c=[],p=[],l=[];let v=e;for(const{settings:b,workflow:h}of i){if(d[h.className]!==void 0&&d[h.className]!==null)continue;const _=u.find(f=>f.class_name===h.className),E=Object.fromEntries(we.flatMap(f=>{const y=G(_,[f]);return y===void 0?[]:[[f,y]]})),O=_?.name??h.name;_?.name!==void 0&&_.name!==h.name&&l.push(`workflows/${h.className} is deployed as "${_.name}" but declared as "${h.name}" — its export keeps "${_.name}" so running instances survive. Change the declaration to match, or rename deliberately (it starts a new, empty workflow).`),v=w(v,["exports",h.className],{type:"workflow",...E,...b,name:O}),(_===void 0?c:p).push(`exports/${h.className}`)}if(u.length>0){const b=m.filter(h=>!u.includes(h));v=w(v,["workflows"],b.length===0?void 0:b),p.push(...u.map(h=>`workflows/${String(h.class_name)} → exports`))}l.push(...bn(n));const g=hn(v,d,s);return{added:c,text:g.text,updated:[...p,...g.updated],warnings:[...l,...g.warnings]}},Pn=(e,n,{environment:s,target:t}={})=>{const o=Ee(e),i=Fe(n);if(!o)return{added:[],changed:!1,exportGaps:i,reason:"wrangler.jsonc not found",updated:[],warnings:D(n,e)};const{parsed:a,text:m}=xe(o);if(a===void 0)return{added:[],changed:!1,exportGaps:i,reason:`failed to parse ${o} as JSONC`,updated:[],warnings:D(n,e),wranglerPath:o};const u=D(n,e,a,t);if(s!==void 0){const r=a.env?.[s]!==void 0;u.push(r?`auto-provisioned bindings are written to the top level of wrangler.jsonc only (queue consumers "env.${s}" already declares are retuned, nothing is added) — "env.${s}" has its own (non-inheritable) bindings and must be reconciled by hand; \`lunora deploy --env ${s}\` now validates them, so a gap here will be reported at deploy time.`:`--env "${s}" was requested but wrangler.jsonc declares no "env.${s}" block — auto-provisioned bindings are written to the top level only and will not apply to that environment.`)}const d=n.containers.filter(r=>r.exported),c=n.agents.filter(r=>r.exported&&r.voice===!0&&r.voiceBindingName!==void 0&&r.voiceClassName!==void 0),p=[...n.durableObjects,...d.map(r=>({binding:r.bindingName,className:r.className})),...c.map(r=>({binding:r.voiceBindingName,className:r.voiceClassName}))],l=n.workflows.filter(r=>r.exported),v=n.agents.filter(r=>r.exported),g=Y(e),b=Te(g,u),h={},_=le(g);let E;const O=[{enabled:!0,run:r=>Ve(r,a,p)},{enabled:n.needsD1,run:r=>Ue(r,a)},{enabled:n.usesKv,run:r=>tn(r,a,n.jurisdiction,t)},{enabled:n.usesHyperdrive,run:r=>nn(r,a,t)},{enabled:n.usesArtifacts,run:r=>on(r,a,n.jurisdiction,t)},{enabled:n.usesAi,run:r=>k(r,a,"ai")},{enabled:n.usesAiSearch,run:r=>V(r,a,"ai_search_namespaces",{binding:"AI_SEARCH",namespace:"default"},"AI_SEARCH (AI Search namespace)")},{enabled:Je(n,e),run:r=>k(r,a,"analytics")},{enabled:n.usesBrowser,run:r=>k(r,a,"browser")},{enabled:n.usesImages,run:r=>k(r,a,"images")},{enabled:n.usesAnalytics,run:r=>V(r,a,"analytics_engine_datasets",{binding:"ANALYTICS",dataset:"ANALYTICS"},"ANALYTICS (Analytics Engine)")},{enabled:n.usesWorkerLoader,run:r=>an(r,a)},{enabled:!0,run:r=>un(r,a)},{enabled:t===void 0||t==="cloudflare",run:r=>gn(r,a)},{enabled:d.length>0,run:r=>ln(r,a,d)},{enabled:l.length>0||v.length>0,run:r=>vn(r,a,l,v,fn(e))},{enabled:n.queues.length>0,run:r=>{const S=$e(r,a,n.queues,b.queues??{});return h.queues=S.owned,S}},{enabled:n.services!==void 0&&(n.services.length>0||Object.keys(_).length>0),run:r=>{const S=ue(r,a,n.services??[],_);return E=S.owned,S}},...s===void 0||a.env?.[s]===void 0?[]:[{enabled:n.queues.length>0,run:r=>{const S=`env.${s}.queues`,N=Ce(r,a,n.queues,s,b[S]??{});return h[S]=N.owned,N}}]];let f=m;const y=[],A=[];for(const r of O){if(!r.enabled)continue;const S=r.run(f);f=S.text,y.push(...S.added),A.push(...S.updated??[]),u.push(...S.warnings??[])}const H=r=>{if(g===void 0)return;const S=E,N=[...Object.keys(h).length>0?[{consequence:"an option removed from defineQueue stays deployed",key:"queueTuning",label:"queue tuning",write:x=>{Ie(x,b,h)}}]:[],...S===void 0?[]:[{consequence:"a service removed from lunora.config stays bound",key:"services",label:"service bindings",write:x=>{me(x,S)}}]];for(const x of N)try{x.write(Y(e)??g)}catch(T){u.push(`${r?"wrangler.jsonc was updated, but ":""}recording the ${x.label} reconcile owns in ${g.path} (lunora.${x.key}) failed: ${T instanceof Error?T.message:String(T)}. Until it is recorded, ${x.consequence}.`)}};let C;if(n.services!==void 0){const r=ge(e,n.services,_);u.push(...r.warnings),E={...E,...r.owned},C=r.added.length>0||r.updated.length>0?{added:r.added,path:r.path,updated:r.updated}:void 0}return u.push(...Qe(y,t)),f===m?(H(!1),{added:y,changed:!1,devConfig:C,exportGaps:i,reason:"bindings already in sync",updated:A,warnings:u,wranglerPath:o}):(ne(o,f,"utf8"),H(!0),{added:y,changed:!0,devConfig:C,exportGaps:i,updated:A,warnings:u,wranglerPath:o})};export{Fe as collectExportGaps,Pn as reconcileWranglerBindings};
|
|
1
|
+
import{readFileSync as ee,writeFileSync as ne}from"node:fs";import{createRequire as se}from"node:module";import{join as Q}from"node:path";import{containerBuildTag as te}from"@lunora/container";import{readJsonSync as ie}from"@visulima/fs";import{c as oe}from"./celld-binding-id-9MiUoteo.mjs";import{applyModify as w}from"./applyModify-DKP2l6S9.mjs";import{recordManifestKey as ae,readManifest as Y}from"./readManifest-Cighz3WC.mjs";import{D1_PLACEHOLDER_ID as U,HYPERDRIVE_PLACEHOLDER_ID as re}from"./D1_PLACEHOLDER_ID-ZnDjVymH.mjs";import{parseTree as de,findNodeAtLocation as ce}from"jsonc-parser";import{r as le,a as ue,b as ge,c as me}from"./reconcile-services-C4TwY8YH.mjs";import{DEV_VARS_FILE as pe,parseDevVariableEntries as fe}from"./DEV_VARS_EXAMPLE_FILE-CqLorAxT.mjs";import{secretSourcesFromBindings as be}from"./inferLunoraBindings-CGy-uHu6.mjs";import{requiredSecrets as he}from"./buildPackageSecretsBlock-GvaLgvFN.mjs";import{w as ve,m as we,s as G,o as P,n as I,p as _e}from"./validate-bindings-PVHSAU6M.mjs";import{s as ye}from"./worker-entry-checks-CHrum2AN.mjs";import{DEFAULT_OBSERVABILITY as Se}from"./DEFAULT_OBSERVABILITY-CPLADr5u.mjs";import{findWranglerFile as Ee,readWranglerJsonc as xe}from"./WRANGLER_FILES-UNW-xY5u.mjs";const Ae=[["maxBatchSize","max_batch_size"],["maxBatchTimeout","max_batch_timeout"],["maxConcurrency","max_concurrency"],["maxRetries","max_retries"],["deadLetterQueue","dead_letter_queue"],["retryDelay","retry_delay"]],B=e=>Object.fromEntries(Ae.filter(([n])=>e.tuning[n]!==void 0).map(([n,s])=>[s,e.tuning[n]])),L="queueTuning",Oe=/^[\t ]*(?:,[\t ]*)?(?:\/\/[^\n\r]*)?\r?\n/u,$e=/^[\t ]*,/u,Ne=(e,n)=>{const s=de(e),t=s===void 0?void 0:ce(s,[...n])?.parent;if(t?.type==="property"){const o=t.offset+t.length,i=e.lastIndexOf(`
|
|
2
|
+
`,t.offset-1)+1,a=Oe.exec(e.slice(o));if(a!==null&&e.slice(i,t.offset).trim()===""){const m=t.parent?.children??[],u=m.indexOf(t),d=u===m.length-1&&u>0?m[u-1]:void 0,c=d===void 0?void 0:$e.exec(e.slice(d.offset+d.length))??void 0;return(c===void 0||d===void 0?e.slice(0,i):e.slice(0,d.offset+d.length)+e.slice(d.offset+d.length+c[0].length,i))+e.slice(o+a[0].length)}}return w(e,n,void 0)},J=(e,n,s,t,o,i=new Set)=>{const a=s.join("."),m={},u=[],d=[];let c=e;return{entries:n.map((l,v)=>{const g=t(l);if(g===void 0||l.queue===void 0)return l;const b=Object.fromEntries(Object.entries(B(g)).filter(([f])=>!i.has(f))),h=Object.entries(o[l.queue]??{}).filter(([f])=>!Object.hasOwn(b,f)),_=Object.entries(b).filter(([f,y])=>l[f]!==y),E=h.filter(([f,y])=>l[f]===y).map(([f])=>f),O=Object.fromEntries(Object.entries({...l,...b}).filter(([f])=>!E.includes(f)));for(const[f,y]of _)c=w(c,[...s,v,f],y);for(const f of E)c=Ne(c,[...s,v,f]);for(const[f,y]of h){const A=l[f];A!==void 0&&A!==y&&d.push(`${a}/${l.queue}: ${f} is no longer declared by defineQueue, but it was changed by hand to ${JSON.stringify(A)} from the declared ${JSON.stringify(y)}, so it was kept. Delete it from wrangler.jsonc if it should go.`)}return(_.length>0||E.length>0)&&u.push(`${a}/${l.queue} (${[..._.map(([f])=>f),...E.map(f=>`removed ${f}`)].join(", ")})`),Object.keys(b).length>0&&(m[l.queue]=b),O}),owned:m,text:c,updated:u,warnings:d}},ke=(e,n,s,t)=>{const o=n.queues??{},i=o.producers??[],a=o.consumers??[],m=new Set(i.map(g=>g?.binding)),u=new Set(a.map(g=>g.queue)),d=s.filter(g=>!m.has(g.bindingName)),c=s.filter(g=>!u.has(g.name)),p=J(e,a,["queues","consumers"],g=>s.find(b=>b.name===g.queue),t);let l=p.text;const v={...p.owned};if(d.length>0||c.length>0){const g=[...i,...d.map(h=>({binding:h.bindingName,queue:h.name}))],b=[...p.entries,...c.map(h=>({queue:h.name,...h.mode==="pull"?{type:"http_pull"}:{},...B(h)}))];for(const h of c){const _=B(h);Object.keys(_).length>0&&(v[h.name]=_)}l=w(l,["queues"],{consumers:b,producers:g})}return{added:[...d.map(g=>`queues.producers/${g.bindingName}`),...c.map(g=>`queues.consumers/${g.name}`)],owned:v,text:l,updated:p.updated,warnings:p.warnings}},Ce=(e,n,s,t,o)=>{const i=n.env?.[t],a=i?.queues?.consumers??[],m=i?.queues?.producers??[],u=l=>{const v=m.find(g=>g?.queue===l.queue)?.binding;return v!==void 0?s.find(g=>g.bindingName===v):s.find(g=>g.name===l.queue&&!m.some(b=>b?.binding===g.bindingName))},d=J(e,a,["env",t,"queues","consumers"],u,o,new Set(["dead_letter_queue"])),c=a.filter(l=>l.queue!==void 0&&u(l)===void 0).map(l=>`env.${t}.queues.consumers/${String(l.queue)}: no defineQueue export matches it — this block declares no producer mapping one of their bindings to "${String(l.queue)}", and no export is named that — so it was not retuned. A consumer for a queue another worker produces is skipped the same way.`),p=a.flatMap(l=>{const v=u(l)?.tuning.deadLetterQueue;return v===void 0||l.dead_letter_queue!==void 0?[]:[`env.${t}.queues.consumers/${String(l.queue)}: defineQueue declares deadLetterQueue "${v}", but this consumer has no dead_letter_queue, so its exhausted messages are dropped. Queue names differ per environment, so reconcile does not write it here; add it by hand.`]});return{added:[],owned:d.owned,text:d.text,updated:d.updated,warnings:[...d.warnings,...p,...c]}},Te=(e,n)=>{if(e?.lunoraIsForeign===!0)return n.push(`${e.path}: \`lunora\` is not an object, so the queue tuning ownership record cannot be read or written — an option removed from defineQueue stays deployed.`),{};const s=e?.lunora?.[L],t=o=>typeof o=="object"&&o!==null&&!Array.isArray(o);return s===void 0?{}:!t(s)||!Object.values(s).every(o=>t(o)&&Object.values(o).every(i=>t(i)))?(n.push(`${e?.path??"package.json"}: \`lunora.${L}\` is not a map of scope → queue → fields, so it is ignored — an option removed from defineQueue stays deployed until the next pass records it again.`),{}):s},Ie=(e,n,s)=>{const t=Object.fromEntries(Object.entries({...n,...s}).filter(([,o])=>Object.keys(o).length>0));ae(e,L,Object.keys(t).length===0?void 0:t)},je="https://api.cloudflare.com/client/v4/accounts/<ACCOUNT_ID>/artifacts/namespaces",Re=e=>{const n='add an "artifacts" binding ({ binding: "ARTIFACTS", namespace }) — codegen reads env.ARTIFACTS unless `.artifacts()` on defineApp points ctx.artifacts at another binding';return e===void 0?`ctx.artifacts is used; ${n}. The namespace is created by the first repo create() if it does not exist yet.`:`ctx.artifacts is used and the schema pins data to "${e}"; create the namespace in that jurisdiction BEFORE the first repo, with POST ${je} and body { "namespace": "<name>", "jurisdiction": "${e}" }, then ${n}. A namespace's jurisdiction cannot be changed, and one created implicitly by the first repo create() is unrestricted. With CLOUDFLARE_API_TOKEN set, \`lunora deploy\` creates a missing namespace in that jurisdiction for a binding you have added.`},j="PIPELINES",R="ARTIFACTS",qe=(e,n,s)=>{const t=n!==void 0&&(s===void 0||s==="cloudflare"),o=e.flagshipBinding!==void 0&&!(n?.flagship??[]).some(d=>d.binding===e.flagshipBinding),i=e.usesPipelines&&!(n?.pipelines??[]).some(d=>d.binding===j),a=e.usesArtifacts?n?.artifacts??[]:[],m=a.some(d=>d.binding===R)?[]:a.flatMap(d=>d.binding===void 0?[]:[d.binding]);return[[e.usesKv&&(n?.kv_namespaces?.length??0)===0&&(!t||e.jurisdiction!==void 0),e.jurisdiction===void 0?'ctx.kv is used but no kv_namespaces binding exists; add one ({ binding: "KV" }) — wrangler creates the namespace on the first deploy.':`ctx.kv is used and the schema pins data to "${e.jurisdiction}"; run \`wrangler kv namespace create <name> --jurisdiction ${e.jurisdiction}\` and add a kv_namespaces entry ({ binding: "KV", id }) — a namespace wrangler creates on deploy is unrestricted.`],[e.usesHyperdrive&&(n?.hyperdrive?.length??0)===0&&!t,'@lunora/hyperdrive is used but no hyperdrive binding exists; add one ({ binding: "HYPERDRIVE", id }) — on a Cloudflare target `lunora deploy` creates the Hyperdrive config from a connection string.'],[e.usesArtifacts&&a.length===0&&(!t||e.jurisdiction!==void 0),Re(e.jurisdiction)],[i,`ctx.pipelines is used but no "${j}" pipelines binding exists; run 'wrangler pipelines create <name>' and add a 'pipelines' binding ({ binding: "${j}", stream }) — codegen resolves this one name, and the pipeline resource can't be auto-provisioned.`],[m.length>0,`ctx.artifacts is used and ${m.map(d=>`"${d}"`).join(", ")} ${m.length===1?"is":"are"} bound, but none is named "${R}"; make sure \`.artifacts()\` on defineApp points ctx.artifacts at it — otherwise it reads env.${R} and throws.`],[o,`lunora/flags.ts uses Flagship in binding mode but no flagship binding "${e.flagshipBinding??""}" exists; add a flagship entry ({ binding: "${e.flagshipBinding??""}", app_id }) — the app_id can't be auto-provisioned.`]].filter(([d])=>d).map(([,d])=>d)},De=e=>[[e.usesX402Charge,"@lunora/x402/charge is used; set the recipient wallet address as a [vars] entry (the var name is your choice) and pass it to the charge config — the x402 facilitator settles USDC to that address."],[e.usesX402,"@lunora/x402/pay is used (ActionCtx-only, spends real funds); add a secrets_store_secrets[] binding holding the agent wallet key (binding name == signer.secretName) and pair the pay rail with a spend policy — ctx.secrets reads a Secrets Store binding, not .dev.vars."]].filter(([s])=>s).map(([,s])=>s),q=(e,n,s)=>s.filter(t=>!t.exported).map(t=>`${e} "${t.exportName}" is declared but ${t.className} is not exported by the worker entry; add \`export * from "./lunora/_generated/${n}"\` so its binding can be provisioned.`),Pe=(e,n)=>{const s=new Set([...e.workflows,...e.agents].map(i=>i.className));if(s.size===0)return[];const t=Object.entries(n.exports??{}).flatMap(([i,a])=>a?.type==="workflow"?[i]:[]),o=(n.workflows??[]).flatMap(i=>i.class_name===void 0||i.script_name!==void 0?[]:[i.class_name]);return[...new Set([...t,...o])].filter(i=>!s.has(i)).map(i=>`wrangler.jsonc declares workflow "${i}" but no defineWorkflow/defineAgent export generates that class — a leftover from a rename will fail the deploy (wrangler rejects a class the worker does not export). Remove it if it is not hand-wired.`)},Be=(e,n)=>{if(e.queues.length===0)return[];const s=new Set(e.queues.map(o=>o.name)),t=new Set(e.queues.map(o=>o.bindingName));return[...(n.queues?.consumers??[]).flatMap(o=>{const{queue:i}=o;return i===void 0||s.has(i)?[]:[`wrangler.jsonc subscribes queues.consumers[] to "${i}" but no defineQueue export declares that queue — a leftover from a rename keeps delivering batches this worker has no handler for (they retry to exhaustion, then drop or dead-letter). Remove it if it is not hand-wired.`]}),...(n.queues?.producers??[]).flatMap(o=>{const i=o?.binding;return i===void 0||t.has(i)?[]:[`wrangler.jsonc declares queues.producers[] binding "${i}" but no defineQueue export declares it — a leftover from a rename. Remove it if it is not hand-wired.`]})]},Le=(e,n)=>[...Pe(e,n),...Be(e,n)],X=[{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"}],We=()=>X.map(({keys:e,label:n})=>`${e[0]} + ${e[1]} (${n})`).join(" or "),Me=e=>{let n;try{n=ee(Q(e,pe),"utf8")}catch{return!1}const s=new Map(fe(n).map(t=>[t.key,t.value]));return X.some(({keys:t})=>t.every(o=>(s.get(o)??"")!==""))},Ke=(e,n)=>{const s=n?.secrets?.required;if(!Array.isArray(s))return[];const t=new Set(s),o=he(be(e)).map(i=>i.key).filter(i=>!t.has(i));return o.length===0?[]:[`wrangler.jsonc declares secrets.required without ${o.join(", ")}, which this app needs — wrangler dev loads only the listed keys from .dev.vars, so add ${o.length===1?"it":"them"} to secrets.required.`]},D=(e,n,s,t)=>{const o=new Set(e.durableObjects.map(u=>u.className)),i=[],a=(s?.r2_buckets?.length??0)>0,m=(s?.d1_databases?.some(u=>u.binding==="DB")??!1)||e.needsD1;return e.usesStorage&&!a&&i.push("@lunora/storage is used but R2 bucket bindings have user-defined names; add an r2_buckets entry and pass env.<BINDING> to createStorage()."),e.usesAuth&&!o.has("SessionDO")&&!m&&i.push("@lunora/auth is used but the worker entry exports no SessionDO; sessions are D1-backed, or export SessionDO to enable DO-backed sessions."),e.usesScheduler&&!o.has("SchedulerDO")&&i.push("@lunora/scheduler is used but the worker entry exports no SchedulerDO; export it so the SCHEDULER binding can be provisioned."),i.push(...q("container","containers",e.containers),...q("workflow","workflows",e.workflows),...q("agent","agents",e.agents)),e.containers.length>0&&s?.observability?.enabled===!1&&i.push("containers are declared but observability is explicitly disabled in wrangler.jsonc — container logs will not be captured."),e.usesPayments&&!Me(n)&&i.push(`@lunora/payment is used; set one provider's secret pair in .dev.vars — ${We()}.`),i.push(...De(e),...qe(e,s,t),...Ke(e,s)),s!==void 0&&i.push(...Le(e,s)),i},Fe=e=>[["container","containers",e.containers],["workflow","workflows",e.workflows],["agent","agents",e.agents]].flatMap(([s,t,o])=>o.filter(i=>!i.exported).map(({className:i,exportName:a})=>({className:i,exportName:a,kind:s,module:t}))),He=e=>{const n=new Set(P(e).map(t=>t.tag));let s=1;for(;n.has(`v${String(s)}`);)s+=1;return`v${String(s)}`},Ye=e=>{const n=new Set;for(const s of P(e)){for(const t of I(s.deleted_classes))n.delete(t);for(const{from:t,to:o}of P(s.renamed_classes))t!==void 0&&n.delete(t),o!==void 0&&n.add(o);for(const t of[...I(s.new_classes),...I(s.new_sqlite_classes)])n.add(t)}return n},Ve=(e,n,s)=>{const t=n.durable_objects?.bindings??[],o=new Set(t.map(c=>c.name)),i=s.filter(c=>!o.has(c.binding));let a=e;const m=[];if(i.length>0){const c=[...t,...i.map(p=>({class_name:p.className,name:p.binding}))];a=w(a,["durable_objects","bindings"],c),m.push(...i.map(p=>`${p.binding}/${p.className}`))}const u=n.migrations??[],d=s.map(c=>c.className).filter(c=>!Ye(u).has(c));if(d.length>0){const c=[...u,{new_sqlite_classes:d,tag:He(u)}];a=w(a,["migrations"],c)}return{added:m,text:a}},M=e=>e===void 0||e==="cloudflare",Qe=(e,n)=>e.includes("DB (D1)")&&M(n)?[`wrote a DB binding with a placeholder database_id ("${U}") — run \`wrangler d1 create <name>\` and replace it before deploying.`]:[],Ue=(e,n)=>{const s=n.d1_databases??[];if(s.some(i=>i.binding==="DB"))return{added:[],text:e};const t=typeof n.name=="string"&&n.name.length>0?n.name:"lunora",o=[...s,{binding:"DB",database_id:U,database_name:t}];return{added:["DB (D1)"],text:w(e,["d1_databases"],o)}},Ge={ai:{binding:"AI",label:"AI (Workers AI)"},analytics:{binding:"ANALYTICS_SQL",label:"ANALYTICS_SQL (Analytics SQL)"},browser:{binding:"BROWSER",label:"BROWSER (Browser Rendering)"},images:{binding:"IMAGES",label:"IMAGES (Cloudflare Images)"}},Je=(e,n)=>e.usesAnalyticsSql&&ye(n,new Set(["analyticsSql"]))?.chained.has("analyticsSql")!==!0,Xe=new Set(["ratelimits","send_email"]),ze=["durable_objects","logfwdr","unsafe"],Ze=new Set(["data_blobs","text_blobs","vars","wasm_modules"]),K=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),W=(e,n,s)=>K(e)&&e[n]===s,en=(e,n,s)=>{if(Ze.has(e))return K(n)&&Object.hasOwn(n,s);const t=Xe.has(e)?"name":"binding";return Array.isArray(n)?n.some(o=>W(o,t,s)):W(n,"binding",s)},$=(e,n)=>{const s=e,t=Object.entries(s).find(([i,a])=>i!=="env"&&en(i,a,n));if(t!==void 0)return t[0];for(const i of ze){const a=s[i];if(K(a)&&Array.isArray(a.bindings)&&a.bindings.some(m=>W(m,"name",n)))return`${i}.bindings`}if(e.queues?.producers?.some(i=>i?.binding===n)===!0)return"queues.producers";const o=e.secrets?.required;if(Array.isArray(o)&&o.includes(n))return"secrets.required"},k=(e,n,s)=>{const{binding:t,label:o}=Ge[s],i=n[s]?.binding;if(typeof i=="string"&&i.length>0)return{added:[],text:e};const a=$(n,t);return a!==void 0?{added:[],text:e,warnings:[`${s}: not adding the ${o} binding — the name "${t}" is already bound by \`${a}\` in wrangler.jsonc. Rename that binding, then set ${s}.binding by hand.`]}:{added:[o],text:w(e,[s],{binding:t})}},F=(e,n,s)=>`${e}: not adding "${n}" — the name is already bound by \`${s}\` in wrangler.jsonc. Add a ${e} entry under another binding name and point the matching \`defineApp()\` override at it.`,nn=(e,n,s)=>{if(!M(s)||(n.hyperdrive?.length??0)>0)return{added:[],text:e};const t=$(n,"HYPERDRIVE");return t!==void 0?{added:[],text:e,warnings:[F("hyperdrive","HYPERDRIVE",t)]}:{added:["HYPERDRIVE (Hyperdrive, created on deploy)"],text:w(e,["hyperdrive"],[{binding:"HYPERDRIVE",id:re}])}},sn=new Set(["celld","cloudflare"]),tn=(e,n,s,t)=>{if(t!==void 0&&!sn.has(t)||s!==void 0||(n.kv_namespaces?.length??0)>0)return{added:[],text:e};const o=$(n,"KV");return o!==void 0?{added:[],text:e,warnings:[F("kv_namespaces","KV",o)]}:{added:[t==="celld"?`KV (Workers KV, celld namespace ${oe(n.name,"KV")})`:"KV (Workers KV, created on deploy)"],text:w(e,["kv_namespaces"],[{binding:"KV"}])}},on=(e,n,s,t)=>{if(!M(t)||s!==void 0||(n.artifacts?.length??0)>0)return{added:[],text:e};const o=$(n,"ARTIFACTS");if(o!==void 0)return{added:[],text:e,warnings:[F("artifacts","ARTIFACTS",o)]};const i=typeof n.name=="string"&&n.name.length>0?n.name:"lunora";return{added:["ARTIFACTS (Cloudflare Artifacts)"],text:w(e,["artifacts"],[{binding:"ARTIFACTS",namespace:i}])}},V=(e,n,s,t,o)=>{if((n[s]?.length??0)>0)return{added:[],text:e};const i=$(n,t.binding);return i!==void 0?{added:[],text:e,warnings:[`${s}: not adding ${JSON.stringify(t)} — the name "${t.binding}" is already bound by \`${i}\` in wrangler.jsonc. Add a ${s} entry under another binding name and point the matching \`defineApp()\` override at it.`]}:{added:[o],text:w(e,[s],[t])}},an=(e,n)=>{const s=n.worker_loaders??[];return s.some(t=>t.binding==="LOADER")?{added:[],text:e}:{added:["LOADER (Worker Loader)"],text:w(e,["worker_loaders"],[...s,{binding:"LOADER"}])}},rn=e=>{if(typeof e=="string")return e;const n={};return e.diskMb!==void 0&&(n.disk_mb=e.diskMb),e.memoryMib!==void 0&&(n.memory_mib=e.memoryMib),e.vcpu!==void 0&&(n.vcpu=e.vcpu),n},dn=e=>{const{image:n}=e;return n.kind==="dockerfile"?n.dockerfilePath:n.kind==="registry"?n.reference:te(e.exportName)},z=e=>{const n={};for(const[s,t]of Object.entries(e.images??{}))n[s]=t.kind==="registry"?{image:t.reference}:{build_context:t.buildContext,dockerfile:t.dockerfilePath,...e.buildArgs===void 0?{}:{build_vars:e.buildArgs}};return{class_name:e.className,scheduling_policy:"durable_object",...Object.keys(n).length>0?{images:n}:{},...e.name===void 0?{}:{name:e.name}}},cn=e=>{if(e.schedulingPolicy==="durable_object")return z(e);const{image:n}=e,s={class_name:e.className,image:dn(e)};return n.kind==="dockerfile"&&(s.image_build_context=n.buildContext),e.buildArgs!==void 0&&n.kind!=="registry"&&(s.image_vars=e.buildArgs),e.instanceType!==void 0&&(s.instance_type=rn(e.instanceType)),e.maxInstances!==void 0&&(s.max_instances=e.maxInstances),e.name!==void 0&&(s.name=e.name),e.rollout?.stepPercentage!==void 0&&(s.rollout_step_percentage=e.rollout.stepPercentage),e.rollout?.gracePeriodSeconds!==void 0&&(s.rollout_active_grace_period=e.rollout.gracePeriodSeconds),s},ln=(e,n,s)=>{const t=n.containers??[],o=new Set(t.map(d=>d.class_name)),i=s.filter(d=>!o.has(d.className));let a=i.length===0?e:w(e,["containers"],[...t,...i.map(d=>cn(d))]);const m=[],u=[];for(const[d,c]of t.entries()){const p=s.find(g=>g.className===c.class_name);if(p===void 0)continue;const l=p.schedulingPolicy??"default";if((c.scheduling_policy??"default")!==l){u.push(`containers/${p.className} has scheduling_policy "${c.scheduling_policy??"default"}" in wrangler.jsonc but defineContainer "${p.exportName}" declares "${l}" — the policy is immutable, so replace the entry (and its container application) by hand.`);continue}const v=p.schedulingPolicy==="durable_object"?z(p).images:void 0;v!==void 0&&JSON.stringify(c.images)!==JSON.stringify(v)&&(a=w(a,["containers",d,"images"],v),m.push(`containers/${p.className}.images`))}return{added:i.map(d=>`containers/${d.className}`),text:a,updated:m,warnings:u}},un=(e,n)=>{if(n.observability!==void 0)return{added:[],text:e};const s=w(e,["observability"],{...Se});return{added:["observability"],text:s}},gn=(e,n)=>n.upload_source_maps!==void 0?{added:[],text:e}:{added:["upload_source_maps"],text:w(e,["upload_source_maps"],!0)},Z=[{minimum:[4,142],name:"wrangler"},{minimum:[1,61],name:"@cloudflare/vite-plugin"}],mn=Z.map(({minimum:e,name:n})=>`${n}@^${e.join(".")}.0`).join(" "),pn=(e,n)=>{try{const s=se(Q(e,"package.json")).resolve(`${n}/package.json`),[t=0,o=0]=String(ie(s).version).split(".").map(Number);return[t,o]}catch{return}},fn=e=>{const n=Z.flatMap(({minimum:s,name:t})=>{const o=pn(e,t);return o!==void 0&&(o[0]<s[0]||o[0]===s[0]&&o[1]<s[1])?[`${t} ${o.join(".")} (needs >= ${s.join(".")})`]:[]});return n.length===0?void 0:`workflows are declared in wrangler \`exports\`, which ${n.join(" and ")} cannot run — reconcile left workflows[] untouched. Upgrade (\`pnpm add -D ${mn}\`) and re-run.`},bn=e=>Object.entries(e.env??{}).flatMap(([n,s])=>Array.isArray(s?.workflows)?[`env.${n}.workflows declares workflow bindings, but Lunora now declares workflows in \`exports\` and resolves them on ctx.exports — move them to that environment's own \`exports\` by hand.`]:[]),hn=(e,n,s)=>{let t=e;const o=[],i=[];for(const a of s){const m=n[a.className];if(m?.type==="workflow")for(const{of:u,path:d}of _e){const c=u(a),p=G(m,d),l=`exports/${a.className}.${d.join(".")}`;if(c===void 0){p!==void 0&&i.push(`${l} is set in wrangler.jsonc but defineWorkflow "${a.exportName}" does not declare it — reconcile leaves it in place. Remove it by hand if it was dropped from the definition.`);continue}JSON.stringify(p)!==JSON.stringify(c)&&(t=w(t,["exports",a.className,...d],c),o.push(l))}}return{text:t,updated:o,warnings:i}},vn=(e,n,s,t,o)=>{if(o!==void 0)return{added:[],text:e,warnings:[o]};const i=[...s.map(b=>({settings:ve(b),workflow:b})),...t.map(b=>({settings:{},workflow:b}))],a=new Set(i.map(({workflow:b})=>b.className)),m=n.workflows??[],u=m.filter(b=>b.script_name===void 0&&b.class_name!==void 0&&a.has(b.class_name)),d=n.exports??{},c=[],p=[],l=[];let v=e;for(const{settings:b,workflow:h}of i){if(d[h.className]!==void 0&&d[h.className]!==null)continue;const _=u.find(f=>f.class_name===h.className),E=Object.fromEntries(we.flatMap(f=>{const y=G(_,[f]);return y===void 0?[]:[[f,y]]})),O=_?.name??h.name;_?.name!==void 0&&_.name!==h.name&&l.push(`workflows/${h.className} is deployed as "${_.name}" but declared as "${h.name}" — its export keeps "${_.name}" so running instances survive. Change the declaration to match, or rename deliberately (it starts a new, empty workflow).`),v=w(v,["exports",h.className],{type:"workflow",...E,...b,name:O}),(_===void 0?c:p).push(`exports/${h.className}`)}if(u.length>0){const b=m.filter(h=>!u.includes(h));v=w(v,["workflows"],b.length===0?void 0:b),p.push(...u.map(h=>`workflows/${String(h.class_name)} → exports`))}l.push(...bn(n));const g=hn(v,d,s);return{added:c,text:g.text,updated:[...p,...g.updated],warnings:[...l,...g.warnings]}},Pn=(e,n,{environment:s,target:t}={})=>{const o=Ee(e),i=Fe(n);if(!o)return{added:[],changed:!1,exportGaps:i,reason:"wrangler.jsonc not found",updated:[],warnings:D(n,e)};const{parsed:a,text:m}=xe(o);if(a===void 0)return{added:[],changed:!1,exportGaps:i,reason:`failed to parse ${o} as JSONC`,updated:[],warnings:D(n,e),wranglerPath:o};const u=D(n,e,a,t);if(s!==void 0){const r=a.env?.[s]!==void 0;u.push(r?`auto-provisioned bindings are written to the top level of wrangler.jsonc only (queue consumers "env.${s}" already declares are retuned, nothing is added) — "env.${s}" has its own (non-inheritable) bindings and must be reconciled by hand; \`lunora deploy --env ${s}\` now validates them, so a gap here will be reported at deploy time.`:`--env "${s}" was requested but wrangler.jsonc declares no "env.${s}" block — auto-provisioned bindings are written to the top level only and will not apply to that environment.`)}const d=n.containers.filter(r=>r.exported),c=n.agents.filter(r=>r.exported&&r.voice===!0&&r.voiceBindingName!==void 0&&r.voiceClassName!==void 0),p=[...n.durableObjects,...d.map(r=>({binding:r.bindingName,className:r.className})),...c.map(r=>({binding:r.voiceBindingName,className:r.voiceClassName}))],l=n.workflows.filter(r=>r.exported),v=n.agents.filter(r=>r.exported),g=Y(e),b=Te(g,u),h={},_=le(g);let E;const O=[{enabled:!0,run:r=>Ve(r,a,p)},{enabled:n.needsD1,run:r=>Ue(r,a)},{enabled:n.usesKv,run:r=>tn(r,a,n.jurisdiction,t)},{enabled:n.usesHyperdrive,run:r=>nn(r,a,t)},{enabled:n.usesArtifacts,run:r=>on(r,a,n.jurisdiction,t)},{enabled:n.usesAi,run:r=>k(r,a,"ai")},{enabled:n.usesAiSearch,run:r=>V(r,a,"ai_search_namespaces",{binding:"AI_SEARCH",namespace:"default"},"AI_SEARCH (AI Search namespace)")},{enabled:Je(n,e),run:r=>k(r,a,"analytics")},{enabled:n.usesBrowser,run:r=>k(r,a,"browser")},{enabled:n.usesImages,run:r=>k(r,a,"images")},{enabled:n.usesAnalytics,run:r=>V(r,a,"analytics_engine_datasets",{binding:"ANALYTICS",dataset:"ANALYTICS"},"ANALYTICS (Analytics Engine)")},{enabled:n.usesWorkerLoader,run:r=>an(r,a)},{enabled:!0,run:r=>un(r,a)},{enabled:t===void 0||t==="cloudflare",run:r=>gn(r,a)},{enabled:d.length>0,run:r=>ln(r,a,d)},{enabled:l.length>0||v.length>0,run:r=>vn(r,a,l,v,fn(e))},{enabled:n.queues.length>0,run:r=>{const S=ke(r,a,n.queues,b.queues??{});return h.queues=S.owned,S}},{enabled:n.services!==void 0&&(n.services.length>0||Object.keys(_).length>0),run:r=>{const S=ue(r,a,n.services??[],_);return E=S.owned,S}},...s===void 0||a.env?.[s]===void 0?[]:[{enabled:n.queues.length>0,run:r=>{const S=`env.${s}.queues`,N=Ce(r,a,n.queues,s,b[S]??{});return h[S]=N.owned,N}}]];let f=m;const y=[],A=[];for(const r of O){if(!r.enabled)continue;const S=r.run(f);f=S.text,y.push(...S.added),A.push(...S.updated??[]),u.push(...S.warnings??[])}const H=r=>{if(g===void 0)return;const S=E,N=[...Object.keys(h).length>0?[{consequence:"an option removed from defineQueue stays deployed",key:"queueTuning",label:"queue tuning",write:x=>{Ie(x,b,h)}}]:[],...S===void 0?[]:[{consequence:"a service removed from lunora.config stays bound",key:"services",label:"service bindings",write:x=>{me(x,S)}}]];for(const x of N)try{x.write(Y(e)??g)}catch(T){u.push(`${r?"wrangler.jsonc was updated, but ":""}recording the ${x.label} reconcile owns in ${g.path} (lunora.${x.key}) failed: ${T instanceof Error?T.message:String(T)}. Until it is recorded, ${x.consequence}.`)}};let C;if(n.services!==void 0){const r=ge(e,n.services,_);u.push(...r.warnings),E={...E,...r.owned},C=r.added.length>0||r.updated.length>0?{added:r.added,path:r.path,updated:r.updated}:void 0}return u.push(...Qe(y,t)),f===m?(H(!1),{added:y,changed:!1,devConfig:C,exportGaps:i,reason:"bindings already in sync",updated:A,warnings:u,wranglerPath:o}):(ne(o,f,"utf8"),H(!0),{added:y,changed:!0,devConfig:C,exportGaps:i,updated:A,warnings:u,wranglerPath:o})};export{Fe as collectExportGaps,Pn as reconcileWranglerBindings};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{statSync as k,readFileSync as Q,existsSync as M,readdirSync as le}from"node:fs";import{relative as ue,sep as pe,isAbsolute as me,join as S,dirname as j,resolve as fe}from"node:path";import{discoverFlags as ge,FLAGS_FILENAME as he,discoverQueues as xe,CAPABILITY_PROBES as z,readServiceBindings as Se,discoverNotifyChannels as ye,NOTIFY_FILENAME as ve,createTargetScope as Ee,mayReadCapabilityContext as be,sourceCapabilitySignals as Ne,foldCapabilitySignals as Y,capabilitiesUsedBy as Ce}from"@lunora/codegen";import{init as Te}from"es-module-lexer";import{ts as n,Node as m,Project as Z}from"ts-morph";import{discoverAgentInfo as Ie}from"./discoverAgentInfo-pqFMJBtJ.mjs";import{discoverContainerInfo as Re}from"./discoverContainerInfo-DzXr7Vm3.mjs";import{escapeRegExp as Ae}from"./DEV_VARS_EXAMPLE_FILE-CqLorAxT.mjs";import{d as K}from"./discover-info-DC2MrAIM.mjs";import{P as Oe}from"./package-secrets-registry-UQ_uEAB_.mjs";import{discoverSchemaInfo as we}from"./discoverSchemaInfo-DRPnqgif.mjs";import{resolveWorkerEntry as De,composedEntryDurableObjects as _e,GENERATED_DIRECTORY as D,DURABLE_OBJECT_BINDINGS as Le,detectExportedDurableObjects as $e,detectClassExports as $,isMergedProject as ee}from"./COMPOSED_WORKER_ENTRY-BcFt6ts5.mjs";import{discoverWorkflowInfo as Pe}from"./discoverWorkflowInfo-zW7Tt0Tn.mjs";const je=(e,t)=>{const{error:s,value:o}=K(e,t,he,ge);return s===void 0?{flags:o}:{error:s}},te=(e,t)=>{const s=ue(t,e);return s!==""&&s!==".."&&!s.startsWith(`..${pe}`)&&!me(s)},Fe=(e,t)=>{const{error:s,value:o}=K(e,t,void 0,xe);return s===void 0?{queues:o??[]}:{error:s,queues:[]}},b="@lunora/replica",x="EventLogDOClient",ke=/\.[cm]?[jt]sx?$/u,U=[".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs"],q=new Map,B=e=>{const{mtimeMs:t}=k(e),s=q.get(e);if(s?.mtimeMs===t)return s.source;const o=n.createSourceFile(e,Q(e,"utf8"),n.ScriptTarget.Latest);return q.set(e,{mtimeMs:t,source:o}),o},H=new WeakMap,Me=e=>{const t=H.get(e);if(t!==void 0&&t[0]?.wasForgotten()!==!0)return t;const s=e.getDescendantsOfKind(n.SyntaxKind.Identifier);return H.set(e,s),s},X=e=>n.sys.fileExists(e)?k(e).mtimeMs:-1,J=new Map,Ke=e=>{const t=n.findConfigFile(j(e),i=>n.sys.fileExists(i));if(t===void 0)return{};const s=J.get(t);if(s!==void 0&&[...s.mtimes].every(([i,c])=>X(i)===c))return s.options;const o=n.readJsonConfigFile(t,i=>n.sys.readFile(i)),{options:r}=n.parseJsonSourceFileConfigFileContent(o,n.sys,j(t)),a=new Map([t,...o.extendedSourceFiles??[]].map(i=>[i,X(i)]));return J.set(t,{mtimes:a,options:r}),r},G=(e,t)=>{if(t===b)return;if(!t.startsWith("./")&&!t.startsWith("../")){const a={moduleResolution:n.ModuleResolutionKind.Bundler,...Ke(e)},i=n.resolveModuleName(t,e,a,n.sys).resolvedModule;return i?.isExternalLibraryImport===!0?void 0:i?.resolvedFileName}const s=S(j(e),t.replace(ke,"")),o=U.map(a=>`${s}${a}`),r=U.map(a=>S(s,`index${a}`));return[...o,...r].find(a=>M(a))},Be=e=>{const t=new Map;for(const s of e.statements){if(!n.isImportDeclaration(s)||s.importClause?.phaseModifier===n.SyntaxKind.TypeKeyword||!n.isStringLiteral(s.moduleSpecifier))continue;const o=s.importClause?.namedBindings,r=o!==void 0&&n.isNamedImports(o)?o.elements:[];for(const a of r)a.isTypeOnly||t.set(a.name.text,{module:s.moduleSpecifier.text,name:(a.propertyName??a.name).text})}return t},Ge=e=>{const t=new Map;for(const s of e.statements){if(!n.isImportDeclaration(s)||s.importClause?.phaseModifier===n.SyntaxKind.TypeKeyword||!n.isStringLiteral(s.moduleSpecifier))continue;const o=s.importClause?.namedBindings;o!==void 0&&n.isNamespaceImport(o)&&t.set(o.name.text,s.moduleSpecifier.text)}return t},_=e=>n.canHaveModifiers(e)&&(n.getModifiers(e)??[]).some(t=>t.kind===n.SyntaxKind.ExportKeyword),We=e=>n.isVariableStatement(e)?_(e)?e.declarationList.declarations.flatMap(t=>n.isIdentifier(t.name)?[t.name.text]:[]):[]:(n.isClassDeclaration(e)||n.isFunctionDeclaration(e))&&_(e)?e.name===void 0?[]:[e.name.text]:n.isExportDeclaration(e)&&e.moduleSpecifier===void 0&&!e.isTypeOnly&&e.exportClause!==void 0&&n.isNamedExports(e.exportClause)?e.exportClause.elements.map(t=>t.name.text):[],Ve=e=>new Set(e.statements.flatMap(t=>We(t))),Ye=(e,t,s)=>{if(n.isIdentifier(e))return t.get(e.text);if(n.isPropertyAccessExpression(e)&&n.isIdentifier(e.expression)){const o=s.get(e.expression.text);return o===void 0?void 0:{module:o,name:e.name.text}}},Ue=(e,t,s)=>_(e)?e.declarationList.declarations.flatMap(o=>{if(!n.isIdentifier(o.name)||o.initializer===void 0)return[];const r=Ye(o.initializer,t,s);return r===void 0?[]:[{exported:o.name.text,module:r.module,name:r.name}]}):[],qe=(e,t)=>{const s=e.heritageClauses?.find(r=>r.token===n.SyntaxKind.ExtendsKeyword)?.types[0]?.expression;if(!_(e)||e.name===void 0||s===void 0||!n.isIdentifier(s))return[];const o=t.get(s.text);return o===void 0?[]:[{exported:e.name.text,module:o.module,name:o.name}]},He=e=>{const t=Be(e),s=Ge(e);return e.statements.flatMap(o=>{if(n.isVariableStatement(o))return Ue(o,t,s);if(n.isClassDeclaration(o))return qe(o,t);if(!n.isExportDeclaration(o)||o.isTypeOnly)return[];const{exportClause:r,moduleSpecifier:a}=o,i=a!==void 0&&n.isStringLiteral(a)?a.text:void 0;return r===void 0?i===void 0?[]:[{exported:void 0,module:i,name:void 0}]:n.isNamedExports(r)?r.elements.flatMap(c=>{if(c.isTypeOnly)return[];const d=c.name.text,l=(c.propertyName??c.name).text;if(i!==void 0)return[{exported:d,module:i,name:l}];const u=t.get(l);return u===void 0?[]:[{exported:d,module:u.module,name:u.name}]}):[]})},W=(e,t,s,o,r=new Set)=>{const a=JSON.stringify([e,s,[...r]]);if(o.has(a))return!1;o.add(a);const i=B(e),c=He(i),d=new Set([...r,...Ve(i),...c.flatMap(l=>l.exported===void 0?[]:[l.exported])]);return c.some(l=>{if(s!==void 0&&l.exported!==void 0&&l.exported!==s||l.exported!==void 0&&r.has(l.exported))return!1;if(l.exported===void 0){const g=s??(l.module===b?t:void 0);if(g!==void 0&&d.has(g))return!1}const u=l.exported===void 0?s:l.name;if(l.module===b)return u===void 0||u===t;const v=G(e,l.module);return v!==void 0&&W(v,t,u,o,l.exported===void 0?d:r)})},F=(e,t)=>Me(e).some(s=>{const o=s.getParent();return s.getText()!==t||m.isNamespaceImport(o)||m.isPropertyAccessExpression(o)&&o.getNameNode()===s||m.isQualifiedName(o)&&o.getRight()===s?!1:m.isPropertyAccessExpression(o)?o.getName()===x:m.isQualifiedName(o)?!m.isTypeReference(o.getParent())&&o.getRight().getText()===x:!0}),Xe=e=>{const[t]=e.getArguments();return e.getExpression().getKind()===n.SyntaxKind.ImportKeyword&&t!==void 0&&(m.isStringLiteral(t)||m.isNoSubstitutionTemplateLiteral(t))&&t.getLiteralValue()===b},Je=e=>{const t=e.getPropertyNameNode();if(t===void 0)return e.getNameNode().getText();const s=m.isComputedPropertyName(t)?t.getExpression():t;return m.isStringLiteral(s)||m.isNoSubstitutionTemplateLiteral(s)?s.getLiteralValue():t.getText()},Qe=e=>{let t=e,s=!1;for(let r=e.getParent();m.isParenthesizedExpression(r)||m.isAwaitExpression(r);r=t.getParent())s||=m.isAwaitExpression(r),t=r;if(!s)return!0;const o=t.getParent();if(m.isVariableDeclaration(o)){const r=o.getNameNode();return!m.isObjectBindingPattern(r)||r.getElements().some(a=>a.getDotDotDotToken()!==void 0||Je(a)===x)}return m.isPropertyAccessExpression(o)&&o.getExpression()===t?o.getName()===x:!0},ze=(e,t)=>B(e).statements.some(s=>n.isExportDeclaration(s)&&s.moduleSpecifier!==void 0&&n.isStringLiteral(s.moduleSpecifier)&&s.moduleSpecifier.text===b&&s.exportClause!==void 0&&n.isNamespaceExport(s.exportClause)&&s.exportClause.name.text===t),Ze=e=>e.getImportDeclarations().some(t=>{const s=t.getNamespaceImport(),o=t.isTypeOnly()?[]:t.getNamedImports().filter(d=>!d.isTypeOnly()),r=o.some(d=>d.getNameNode().getText()===x),a=o.filter(d=>F(e,(d.getAliasNode()??d.getNameNode()).getText())),i=s!==void 0&&F(e,s.getText());if(!r&&!i&&a.length===0)return!1;const c=G(e.getFilePath(),t.getModuleSpecifierValue());return c===void 0?!1:(r||i)&&W(c,x,x,new Set)||a.some(d=>ze(c,d.getNameNode().getText()))}),se=e=>{const t=e.getImportDeclarations().filter(s=>s.getModuleSpecifierValue()===b&&!s.isTypeOnly());return t.some(s=>s.getNamedImports().some(o=>!o.isTypeOnly()&&o.getNameNode().getText()===x))||t.some(s=>{const o=s.getNamespaceImport();return o!==void 0&&F(e,o.getText())})||e.getExportDeclarations().some(s=>s.getModuleSpecifierValue()===b&&!s.isTypeOnly()&&s.getNamedExports().some(o=>!o.isTypeOnly()&&o.getNameNode().getText()===x))||Ze(e)||e.getDescendantsOfKind(n.SyntaxKind.CallExpression).some(s=>Xe(s)&&Qe(s))},et=e=>{const t=[],s=o=>{if(n.isImportDeclaration(o)&&o.importClause?.phaseModifier!==n.SyntaxKind.TypeKeyword&&n.isStringLiteral(o.moduleSpecifier))t.push(o.moduleSpecifier.text);else if(n.isExportDeclaration(o)&&!o.isTypeOnly&&o.moduleSpecifier!==void 0&&n.isStringLiteral(o.moduleSpecifier))t.push(o.moduleSpecifier.text);else if(n.isCallExpression(o)&&o.expression.kind===n.SyntaxKind.ImportKeyword){const[r]=o.arguments;r!==void 0&&(n.isStringLiteral(r)||n.isNoSubstitutionTemplateLiteral(r))&&t.push(r.text)}n.forEachChild(o,s)};return s(e),t},tt=new Set([".cjs",".cts",".js",".jsx",".mjs",".mts",".ts",".tsx"]),st=new Set([".git",".lunora-cache",".wrangler","dist",D,"node_modules"]),ot=["lunora","src"],rt=/\benv\s*\.\s*DB\b/,nt=/\benv\s*\.\s*AI\b/,oe=["ai","aiSearch","analytics","analyticsSql","artifacts","browser","hyperdrive","images","kv","mail","notify","payments","pipelines","r2sql","scheduler","storage","x402"],re=e=>`uses${e.charAt(0).toUpperCase()}${e.slice(1)}`,ne=[["usesAuth","@lunora/auth"],["usesCimdWorkers","@lunora/auth/cimd/workers"],["usesX402Charge","@lunora/x402/charge"],["usesPaymentAutumn","@lunora/payment/autumn"],["usesPaymentCreem","@lunora/payment/creem"],["usesPaymentDodopayments","@lunora/payment/dodopayments"],["usesPaymentPolar","@lunora/payment/polar"],["usesPaymentStripe","@lunora/payment/stripe"]],ie=[...oe.map(e=>[re(e),z[e].moduleSpecifier]),...ne].toSorted(([e],[t])=>e.localeCompare(t)),it=[["usesNotifyFcm","@lunora/notify:fcm"],["usesNotifyWebPush","@lunora/notify:webPush"],["hostsShardRegistry","@lunora/do:shardRegistry"],["hostsEventLog","@lunora/replica:eventLog"],["usesEventLogClient","@lunora/replica:eventLogClient"],["usesRequestSecretTool","@lunora/agent:requestSecretTool"]],at=["@lunora/agent","@lunora/agent/sandbox"],ae=new RegExp(String.raw`["'\x60](?:${[...ie.map(([,e])=>e),...at,b].map(e=>Ae(e)).join("|")})["'\x60]`,"u"),p=e=>{const{contextProperty:t,moduleSpecifier:s}=z[e];return t===void 0?`${s} is imported`:`${s} is imported or ctx.${t} is read`},ct="STRIPE_SECRET_KEY + STRIPE_WEBHOOK_SECRET (Stripe) or POLAR_ACCESS_TOKEN + POLAR_WEBHOOK_SECRET (Polar)",dt=/\bfrom\s+["']\.{1,2}\//u,ce=(e,t)=>{let s;try{s=le(e,{withFileTypes:!0})}catch{return}for(const o of s){if(o.isDirectory()){st.has(o.name)||ce(S(e,o.name),t);continue}const r=o.name.lastIndexOf(".");r!==-1&&tt.has(o.name.slice(r))&&t.push(S(e,o.name))}},lt=(e,t,s)=>{const{info:o}=we(e,t,s);return{jurisdiction:o?.jurisdiction,needsD1:o?.hasD1GlobalTable??!1}};let P;const ut=e=>{const t=fe(e);return P?.root!==t&&(P={project:new Z({compilerOptions:{allowJs:!0},skipAddingFilesFromTsConfig:!0}),root:t}),P.project},pt=(e,t,s)=>{e.getSourceFile(t)?.getFullText()!==s&&e.createSourceFile(t,s,{overwrite:!0})},mt=(e,t)=>{for(const s of e.getSourceFiles())t.has(s)||e.removeSourceFile(s)},ft=(e,t,s)=>{const o=S(e,s),r=ut(e),a=[],i=new Set,c=[],d=[],l=Ee();let u=!1,v=!1;for(const f of t){const h=S(e,f);if(!M(h)||!k(h).isDirectory())continue;const I=[];ce(h,I);for(const N of I){i.add(N);const y=Q(N,"utf8"),w=te(N,o);u||=nt.test(y),v||=rt.test(y),(ae.test(y)||y.includes(x)||w&&(be(y)||dt.test(y)))&&(pt(r,N,y),a.push({file:N,inLunora:w}))}}mt(r,new Set(a.map(({file:f})=>r.getSourceFileOrThrow(f))));for(const{file:f,inLunora:h}of a)(h?c:d).push(Ne(r.getSourceFileOrThrow(f),l));const g=Y(c),C=Y([g,...d]),O=new Set([...C.valueImports,...C.dynamicImports]),E=Ce({contextReads:g.contextReads,valueImports:O});return{...Object.fromEntries([...oe.map(f=>[re(f),E.has(f)]),...ne.map(([f,h])=>[f,O.has(h)])]),needsD1:v,usesEventLogClient:a.some(({file:f})=>se(r.getSourceFileOrThrow(f))),usesRequestSecretTool:g.requestSecretTool,usesAi:E.has("ai")||u,usesBrowser:E.has("browser")||g.sandboxTools.usesSandboxBrowser,usesWorkerLoader:g.sandboxTools.usesSandboxLoader,scannedFiles:i}},gt=(e,t,s)=>[...e.map(o=>o.exported?`${o.bindingName}/${o.className} (container "${o.exportName}" declared and exported)`:`hint: container "${o.exportName}" is declared but ${o.className} is not exported by the worker entry — add \`export * from "./lunora/_generated/containers"\``),...t.map(o=>o.exported?`exports.${o.className} (workflow "${o.exportName}" declared and exported)`:`hint: workflow "${o.exportName}" is declared but ${o.className} is not exported by the worker entry — add \`export * from "./lunora/_generated/workflows"\``),...s.map(o=>o.exported?`exports.${o.className} (agent "${o.exportName}" declared and exported)`:`hint: agent "${o.exportName}" is declared but ${o.className} is not exported by the worker entry — add \`export * from "./lunora/_generated/agents"\``)],ht=(e,t,s)=>[[e.usesAi,`AI (${p("ai")}, env.AI is used, or an agent is declared)`],[e.usesAuth&&!t.has("SessionDO"),"hint: @lunora/auth is imported; its tables are D1-backed by default. For DO-backed auth (what @better-auth/scim needs), pass `namespace` to .auth() and export the generated auth DO class"],[e.usesScheduler&&!t.has("SchedulerDO"),`hint: ${p("scheduler")}, but no SchedulerDO is exported by the worker entry`],[e.usesStorage,`hint: ${p("storage")}; add an r2_buckets binding (bucket binding names are user-defined)`],[e.usesMail,`hint: ${p("mail")}; set RESEND_API_KEY in .dev.vars (obtain at https://resend.com/api-keys)`],[e.usesPayments,`hint: ${p("payments")}; set the provider secrets in .dev.vars — ${ct}`],[e.usesBrowser,`browser (${p("browser")}, or a sandbox browserTool imported in lunora/) — self-describing { binding: BROWSER }`],[e.usesImages,`images (${p("images")}) — self-describing { binding: IMAGES }`],[e.usesAnalytics,`analytics_engine_datasets (${p("analytics")}) — self-describing { binding: ANALYTICS, dataset }`],[e.usesWorkerLoader,"worker_loaders (jsCodeTool imported in lunora/) — self-describing { binding: LOADER }"],[e.usesAiSearch,`ai_search_namespaces (${p("aiSearch")}) — self-describing { binding: AI_SEARCH, namespace: "default" }; remote-only, so \`lunora dev\` reaches the deployed AI Search service`],[e.usesAnalyticsSql,`analytics (${p("analyticsSql")}) — self-describing { binding: ANALYTICS_SQL }; needs wrangler >= 4.145.0, and is remote-only, so \`lunora dev\` queries the account's live analytics`],[e.usesKv,s.jurisdiction===void 0?`kv_namespaces (${p("kv")}) — { binding: KV } with no id; wrangler creates the namespace on the first deploy`:`hint: ${p("kv")} and the schema pins "${s.jurisdiction}"; create the namespace with --jurisdiction ${s.jurisdiction} and add a kv_namespaces binding ({ binding, id })`],[e.usesHyperdrive,`hyperdrive (${p("hyperdrive")}) — { binding: HYPERDRIVE } with a placeholder id; dev uses an embedded Postgres and \`lunora deploy\` creates the config`],[e.usesPipelines,`hint: ${p("pipelines")}; run 'wrangler pipelines create <name>' and add a 'pipelines' binding ({ binding, stream }) — the pipeline resource can't be auto-provisioned`],[e.usesArtifacts,s.jurisdiction===void 0?`artifacts (${p("artifacts")}) — { binding: ARTIFACTS, namespace }`:`hint: ${p("artifacts")}; the schema pins data to "${s.jurisdiction}", so create the namespace in that jurisdiction first and add { binding: ARTIFACTS, namespace } yourself — \`lunora deploy\` then checks it (a first create() in dev would make it unrestricted)`],[e.usesX402Charge,"hint: @lunora/x402/charge is imported; set the recipient wallet address as a [vars] entry (the var name is yours to choose) and pass it to the charge config — the x402 facilitator settles USDC to that address"],[e.usesX402,`hint: ${p("x402")} (ActionCtx-only, spends real funds); add a secrets_store_secrets[] binding for the agent wallet key (name it to match signer.secretName) and pair the pay rail with a spend policy — ctx.secrets reads a Secrets Store binding, not .dev.vars, so the key can't be auto-provisioned`]].filter(([r])=>r).map(([,r])=>r),xt=(e,t,s,o=[],r=[],a=[])=>{const i=new Set(e.map(d=>d.className)),c=e.map(d=>`${d.binding}/${d.className} (exported by worker entry)`);return t.needsD1&&c.push("DB (.global() table declared)"),c.push(...gt(o,r,a),...ht(s,i,t)),c},St=(e,t)=>e.some(s=>s.binding==="SHARD_REGISTRY")||ee(t)&&M(S(t,"shardRegistry.ts")),yt=(e,t,s)=>{const o=new Z({compilerOptions:{allowJs:!0},skipAddingFilesFromTsConfig:!0}),r=[e],a=new Set;for(let i=r.pop();i!==void 0;i=r.pop()){if(a.has(i))continue;a.add(i);const c=B(i),d=c.text;if((ae.test(d)||d.includes(x))&&se(o.createSourceFile(i,d,{overwrite:!0})))return!0;for(const l of et(c)){const u=G(i,l);u!==void 0&&!t.has(u)&&!te(u,s)&&r.push(u)}}return!1},vt=e=>!e.composed&&e.path!==void 0&&W(e.path,"EventLogDO",void 0,new Set),$t=async e=>{await Te;const t=e.schemaDir??"lunora",s=e.scanDirs??ot,o=()=>ft(e.projectRoot,s,t),{scannedFiles:r,...a}=e.cache===void 0?o():e.cache.memo(`capabilities:${e.projectRoot}:${t}:${s.join(",")}`,o),i=De(e.projectRoot);let c;i.composed?c=_e(S(e.projectRoot,t,D)).map(V=>({binding:Le[V],className:V})):c=i.path===void 0?[]:$e(i.path);const d=lt(e.projectRoot,t,e.cache),l={...d,needsD1:a.needsD1||d.needsD1},u=$(i,Re(e.projectRoot,t,e.cache).containers,"containers"),v=$(i,Pe(e.projectRoot,t).workflows,"workflows"),g=$(i,Ie(e.projectRoot,t).agents,"agents"),C={...a,usesAi:a.usesAi||g.length>0},O=[...Fe(e.projectRoot,t).queues],{flags:E}=je(e.projectRoot,t),L=K(e.projectRoot,t,ve,ye),f=L.error===void 0?L.value:{hasFcm:!0,hasWebPush:!0},h=E?.provider==="flagship"&&E.mode==="binding"?E.bindingName:void 0,I=S(e.projectRoot,t,D),N=St(c,I),y=vt(i),w=!i.composed&&i.path!==void 0&&yt(i.path,r,I),R=xt(c,l,C,u,v,g);!i.composed&&ee(S(e.projectRoot,t,D))&&!c.some(T=>T.className==="LunoraDO")&&R.push("hint: durableObjects.merge is set, but the worker entry exports no LunoraDO — export one built with mergeDurableObjects, or the classes stay separate"),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`);const A=Se(e.projectRoot),de=A.error===void 0?A.services:void 0;return A.error!==void 0&&R.push(`hint: lunora.config \`services\` not reconciled — ${A.error}`),R.push(...A.services.map(T=>`${T.binding} → ${T.worker} (lunora.config services.${T.name})`)),{...C,usesEventLogClient:C.usesEventLogClient||w,agents:g,containers:u,durableObjects:c,flagshipBinding:h,...l.jurisdiction===void 0?{}:{jurisdiction:l.jurisdiction},needsD1:l.needsD1,queues:O,services:de,signals:R,usesFlags:E!==void 0,usesNotifyFcm:f?.hasFcm??!1,usesNotifyWebPush:f?.hasWebPush??!1,hostsEventLog:y,hostsShardRegistry:N,workflows:v}},Pt=e=>[...ie,...it].filter(([t,s])=>e[t]&&Oe[s]!==void 0).map(([,t])=>t);export{$t as inferLunoraBindings,Pt as secretSourcesFromBindings};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{inferLunoraBindings as g}from"./inferLunoraBindings-
|
|
1
|
+
import{inferLunoraBindings as g}from"./inferLunoraBindings-CGy-uHu6.mjs";import{LUNORA_TAG as r}from"./LUNORA_TAG-DQTGPqcJ.mjs";import{reconcileWranglerBindings as $}from"./collectExportGaps-CO1Se31Y.mjs";import{reconcileWranglerCompatibilityDate as p}from"./reconcileWranglerCompatibilityDate-hocXEuRA.mjs";import{reconcileWranglerCrons as m,describePreservedCrons as w}from"./describePreservedCrons-Bt2rPPeY.mjs";const j=async(i,t,a)=>{try{const n=await g({cache:i.cache,projectRoot:i.projectRoot,schemaDir:i.schemaDir}),e=$(i.projectRoot,n,{target:i.target}),o=e.wranglerPath??"wrangler.jsonc";if(e.added.length>0&&t.info?.(`${r} inferred bindings → ${e.added.join(", ")} (written to ${o})`),e.updated.length>0&&t.info?.(`${r} updated bindings → ${e.updated.join(", ")} (written to ${o})`),e.devConfig!==void 0){const{added:c,path:d,updated:f}=e.devConfig;t.info?.(`${r} dev sidecar bindings → ${[...c,...f].join(", ")} (written to ${d})`)}for(const c of e.warnings)t.warn(`${r} ${c}`);e.exportGaps.length>0&&a?.(e.exportGaps)}catch(n){const e=n instanceof Error?n.message:String(n);t.warn(`${r} binding inference skipped: ${e}`)}},s=new Map,u=(i,t,a)=>{try{const n=m(i,t);n.changed&&a.info?.(`${r} synced ${t.length.toFixed(0)} cron trigger(s) into ${n.wranglerPath??"wrangler.jsonc"}`);for(const c of n.warnings)a.warn(`${r} ${c}`);const e=n.preserved.join("\0"),o=w(n.preserved);o!==void 0&&(n.changed||s.get(i)!==e)&&a.info?.(`${r} ${o}`),s.set(i,e)}catch(n){const e=n instanceof Error?n.message:String(n);a.warn(`${r} cron trigger sync skipped: ${e}`)}try{const n=p(i);n.changed&&a.info?.(`${r} bumped compatibility_date to ${n.date??"unknown"} (Workers Cache enabled) → ${n.wranglerPath??"wrangler.jsonc"}`)}catch(n){const e=n instanceof Error?n.message:String(n);a.warn(`${r} compatibility date sync skipped: ${e}`)}};export{j as reconcileBindingsSafely,u as reconcileWranglerExtras};
|
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.449",
|
|
4
4
|
"description": "Internal shared CLI + Vite config layer for Lunora: wrangler.jsonc validation, binding inference, and .dev.vars scaffolding",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bindings",
|
|
@@ -58,10 +58,10 @@
|
|
|
58
58
|
"access": "public"
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@lunora/codegen": "1.0.0-alpha.
|
|
61
|
+
"@lunora/codegen": "1.0.0-alpha.392",
|
|
62
62
|
"@lunora/container": "1.0.0-alpha.108",
|
|
63
63
|
"@lunora/errors": ">=1.0.0-alpha.51 <2.0.0-0",
|
|
64
|
-
"@lunora/seed": "1.0.0-alpha.
|
|
64
|
+
"@lunora/seed": "1.0.0-alpha.279",
|
|
65
65
|
"@visulima/colorize": "3.0.0",
|
|
66
66
|
"@visulima/find-ai-runner": "1.0.2",
|
|
67
67
|
"@visulima/fs": "7.0.0",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{statSync as F,readFileSync as J,existsSync as k,readdirSync as de}from"node:fs";import{relative as le,sep as ue,isAbsolute as pe,join as S,dirname as P,resolve as me}from"node:path";import{discoverFlags as fe,FLAGS_FILENAME as ge,discoverQueues as he,CAPABILITY_PROBES as Q,readServiceBindings as xe,discoverNotifyChannels as Se,NOTIFY_FILENAME as ye,createTargetScope as ve,mayReadCapabilityContext as Ee,sourceCapabilitySignals as be,foldCapabilitySignals as V,capabilitiesUsedBy as Ne}from"@lunora/codegen";import{init as Ce}from"es-module-lexer";import{ts as n,Node as m,Project as z}from"ts-morph";import{discoverAgentInfo as Te}from"./discoverAgentInfo-pqFMJBtJ.mjs";import{discoverContainerInfo as Ie}from"./discoverContainerInfo-DzXr7Vm3.mjs";import{escapeRegExp as Re}from"./DEV_VARS_EXAMPLE_FILE-CqLorAxT.mjs";import{d as M}from"./discover-info-DC2MrAIM.mjs";import{P as Ae}from"./package-secrets-registry-UQ_uEAB_.mjs";import{discoverSchemaInfo as Oe}from"./discoverSchemaInfo-DRPnqgif.mjs";import{resolveWorkerEntry as we,composedEntryDurableObjects as De,GENERATED_DIRECTORY as w,DURABLE_OBJECT_BINDINGS as _e,detectExportedDurableObjects as Le,detectClassExports as L,isMergedProject as Z}from"./COMPOSED_WORKER_ENTRY-BcFt6ts5.mjs";import{discoverWorkflowInfo as $e}from"./discoverWorkflowInfo-zW7Tt0Tn.mjs";const Pe=(e,t)=>{const{error:s,value:o}=M(e,t,ge,fe);return s===void 0?{flags:o}:{error:s}},ee=(e,t)=>{const s=le(t,e);return s!==""&&s!==".."&&!s.startsWith(`..${ue}`)&&!pe(s)},je=(e,t)=>{const{error:s,value:o}=M(e,t,void 0,he);return s===void 0?{queues:o??[]}:{error:s,queues:[]}},b="@lunora/replica",h="EventLogDOClient",Fe=/\.[cm]?[jt]sx?$/u,Y=[".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs"],U=new Map,K=e=>{const{mtimeMs:t}=F(e),s=U.get(e);if(s?.mtimeMs===t)return s.source;const o=n.createSourceFile(e,J(e,"utf8"),n.ScriptTarget.Latest);return U.set(e,{mtimeMs:t,source:o}),o},q=new WeakMap,ke=e=>{const t=q.get(e);if(t!==void 0&&t[0]?.wasForgotten()!==!0)return t;const s=e.getDescendantsOfKind(n.SyntaxKind.Identifier);return q.set(e,s),s},H=e=>n.sys.fileExists(e)?F(e).mtimeMs:-1,X=new Map,Me=e=>{const t=n.findConfigFile(P(e),i=>n.sys.fileExists(i));if(t===void 0)return{};const s=X.get(t);if(s!==void 0&&[...s.mtimes].every(([i,c])=>H(i)===c))return s.options;const o=n.readJsonConfigFile(t,i=>n.sys.readFile(i)),{options:r}=n.parseJsonSourceFileConfigFileContent(o,n.sys,P(t)),a=new Map([t,...o.extendedSourceFiles??[]].map(i=>[i,H(i)]));return X.set(t,{mtimes:a,options:r}),r},B=(e,t)=>{if(t===b)return;if(!t.startsWith("./")&&!t.startsWith("../")){const a={moduleResolution:n.ModuleResolutionKind.Bundler,...Me(e)},i=n.resolveModuleName(t,e,a,n.sys).resolvedModule;return i?.isExternalLibraryImport===!0?void 0:i?.resolvedFileName}const s=S(P(e),t.replace(Fe,"")),o=Y.map(a=>`${s}${a}`),r=Y.map(a=>S(s,`index${a}`));return[...o,...r].find(a=>k(a))},Ke=e=>{const t=new Map;for(const s of e.statements){if(!n.isImportDeclaration(s)||s.importClause?.phaseModifier===n.SyntaxKind.TypeKeyword||!n.isStringLiteral(s.moduleSpecifier))continue;const o=s.importClause?.namedBindings,r=o!==void 0&&n.isNamedImports(o)?o.elements:[];for(const a of r)a.isTypeOnly||t.set(a.name.text,{module:s.moduleSpecifier.text,name:(a.propertyName??a.name).text})}return t},Be=e=>{const t=new Map;for(const s of e.statements){if(!n.isImportDeclaration(s)||s.importClause?.phaseModifier===n.SyntaxKind.TypeKeyword||!n.isStringLiteral(s.moduleSpecifier))continue;const o=s.importClause?.namedBindings;o!==void 0&&n.isNamespaceImport(o)&&t.set(o.name.text,s.moduleSpecifier.text)}return t},D=e=>n.canHaveModifiers(e)&&(n.getModifiers(e)??[]).some(t=>t.kind===n.SyntaxKind.ExportKeyword),Ge=e=>n.isVariableStatement(e)?D(e)?e.declarationList.declarations.flatMap(t=>n.isIdentifier(t.name)?[t.name.text]:[]):[]:(n.isClassDeclaration(e)||n.isFunctionDeclaration(e))&&D(e)?e.name===void 0?[]:[e.name.text]:n.isExportDeclaration(e)&&e.moduleSpecifier===void 0&&!e.isTypeOnly&&e.exportClause!==void 0&&n.isNamedExports(e.exportClause)?e.exportClause.elements.map(t=>t.name.text):[],We=e=>new Set(e.statements.flatMap(t=>Ge(t))),Ve=(e,t,s)=>{if(n.isIdentifier(e))return t.get(e.text);if(n.isPropertyAccessExpression(e)&&n.isIdentifier(e.expression)){const o=s.get(e.expression.text);return o===void 0?void 0:{module:o,name:e.name.text}}},Ye=(e,t,s)=>D(e)?e.declarationList.declarations.flatMap(o=>{if(!n.isIdentifier(o.name)||o.initializer===void 0)return[];const r=Ve(o.initializer,t,s);return r===void 0?[]:[{exported:o.name.text,module:r.module,name:r.name}]}):[],Ue=(e,t)=>{const s=e.heritageClauses?.find(r=>r.token===n.SyntaxKind.ExtendsKeyword)?.types[0]?.expression;if(!D(e)||e.name===void 0||s===void 0||!n.isIdentifier(s))return[];const o=t.get(s.text);return o===void 0?[]:[{exported:e.name.text,module:o.module,name:o.name}]},qe=e=>{const t=Ke(e),s=Be(e);return e.statements.flatMap(o=>{if(n.isVariableStatement(o))return Ye(o,t,s);if(n.isClassDeclaration(o))return Ue(o,t);if(!n.isExportDeclaration(o)||o.isTypeOnly)return[];const{exportClause:r,moduleSpecifier:a}=o,i=a!==void 0&&n.isStringLiteral(a)?a.text:void 0;return r===void 0?i===void 0?[]:[{exported:void 0,module:i,name:void 0}]:n.isNamedExports(r)?r.elements.flatMap(c=>{if(c.isTypeOnly)return[];const d=c.name.text,l=(c.propertyName??c.name).text;if(i!==void 0)return[{exported:d,module:i,name:l}];const u=t.get(l);return u===void 0?[]:[{exported:d,module:u.module,name:u.name}]}):[]})},G=(e,t,s,o,r=new Set)=>{const a=JSON.stringify([e,s,[...r]]);if(o.has(a))return!1;o.add(a);const i=K(e),c=qe(i),d=new Set([...r,...We(i),...c.flatMap(l=>l.exported===void 0?[]:[l.exported])]);return c.some(l=>{if(s!==void 0&&l.exported!==void 0&&l.exported!==s||l.exported!==void 0&&r.has(l.exported))return!1;if(l.exported===void 0){const g=s??(l.module===b?t:void 0);if(g!==void 0&&d.has(g))return!1}const u=l.exported===void 0?s:l.name;if(l.module===b)return u===void 0||u===t;const v=B(e,l.module);return v!==void 0&&G(v,t,u,o,l.exported===void 0?d:r)})},j=(e,t)=>ke(e).some(s=>{const o=s.getParent();return s.getText()!==t||m.isNamespaceImport(o)||m.isPropertyAccessExpression(o)&&o.getNameNode()===s||m.isQualifiedName(o)&&o.getRight()===s?!1:m.isPropertyAccessExpression(o)?o.getName()===h:m.isQualifiedName(o)?!m.isTypeReference(o.getParent())&&o.getRight().getText()===h:!0}),He=e=>{const[t]=e.getArguments();return e.getExpression().getKind()===n.SyntaxKind.ImportKeyword&&t!==void 0&&(m.isStringLiteral(t)||m.isNoSubstitutionTemplateLiteral(t))&&t.getLiteralValue()===b},Xe=e=>{const t=e.getPropertyNameNode();if(t===void 0)return e.getNameNode().getText();const s=m.isComputedPropertyName(t)?t.getExpression():t;return m.isStringLiteral(s)||m.isNoSubstitutionTemplateLiteral(s)?s.getLiteralValue():t.getText()},Je=e=>{let t=e,s=!1;for(let r=e.getParent();m.isParenthesizedExpression(r)||m.isAwaitExpression(r);r=t.getParent())s||=m.isAwaitExpression(r),t=r;if(!s)return!0;const o=t.getParent();if(m.isVariableDeclaration(o)){const r=o.getNameNode();return!m.isObjectBindingPattern(r)||r.getElements().some(a=>a.getDotDotDotToken()!==void 0||Xe(a)===h)}return m.isPropertyAccessExpression(o)&&o.getExpression()===t?o.getName()===h:!0},Qe=(e,t)=>K(e).statements.some(s=>n.isExportDeclaration(s)&&s.moduleSpecifier!==void 0&&n.isStringLiteral(s.moduleSpecifier)&&s.moduleSpecifier.text===b&&s.exportClause!==void 0&&n.isNamespaceExport(s.exportClause)&&s.exportClause.name.text===t),ze=e=>e.getImportDeclarations().some(t=>{const s=t.getNamespaceImport(),o=t.isTypeOnly()?[]:t.getNamedImports().filter(d=>!d.isTypeOnly()),r=o.some(d=>d.getNameNode().getText()===h),a=o.filter(d=>j(e,(d.getAliasNode()??d.getNameNode()).getText())),i=s!==void 0&&j(e,s.getText());if(!r&&!i&&a.length===0)return!1;const c=B(e.getFilePath(),t.getModuleSpecifierValue());return c===void 0?!1:(r||i)&&G(c,h,h,new Set)||a.some(d=>Qe(c,d.getNameNode().getText()))}),te=e=>{const t=e.getImportDeclarations().filter(s=>s.getModuleSpecifierValue()===b&&!s.isTypeOnly());return t.some(s=>s.getNamedImports().some(o=>!o.isTypeOnly()&&o.getNameNode().getText()===h))||t.some(s=>{const o=s.getNamespaceImport();return o!==void 0&&j(e,o.getText())})||e.getExportDeclarations().some(s=>s.getModuleSpecifierValue()===b&&!s.isTypeOnly()&&s.getNamedExports().some(o=>!o.isTypeOnly()&&o.getNameNode().getText()===h))||ze(e)||e.getDescendantsOfKind(n.SyntaxKind.CallExpression).some(s=>He(s)&&Je(s))},Ze=e=>{const t=[],s=o=>{if(n.isImportDeclaration(o)&&o.importClause?.phaseModifier!==n.SyntaxKind.TypeKeyword&&n.isStringLiteral(o.moduleSpecifier))t.push(o.moduleSpecifier.text);else if(n.isExportDeclaration(o)&&!o.isTypeOnly&&o.moduleSpecifier!==void 0&&n.isStringLiteral(o.moduleSpecifier))t.push(o.moduleSpecifier.text);else if(n.isCallExpression(o)&&o.expression.kind===n.SyntaxKind.ImportKeyword){const[r]=o.arguments;r!==void 0&&(n.isStringLiteral(r)||n.isNoSubstitutionTemplateLiteral(r))&&t.push(r.text)}n.forEachChild(o,s)};return s(e),t},et=new Set([".cjs",".cts",".js",".jsx",".mjs",".mts",".ts",".tsx"]),tt=new Set([".git",".lunora-cache",".wrangler","dist",w,"node_modules"]),st=["lunora","src"],ot=/\benv\s*\.\s*DB\b/,rt=/\benv\s*\.\s*AI\b/,se=["ai","aiSearch","analytics","analyticsSql","artifacts","browser","hyperdrive","images","kv","mail","notify","payments","pipelines","r2sql","scheduler","storage","x402"],oe=e=>`uses${e.charAt(0).toUpperCase()}${e.slice(1)}`,re=[["usesAuth","@lunora/auth"],["usesCimdWorkers","@lunora/auth/cimd/workers"],["usesX402Charge","@lunora/x402/charge"],["usesPaymentAutumn","@lunora/payment/autumn"],["usesPaymentCreem","@lunora/payment/creem"],["usesPaymentDodopayments","@lunora/payment/dodopayments"],["usesPaymentPolar","@lunora/payment/polar"],["usesPaymentStripe","@lunora/payment/stripe"]],ne=[...se.map(e=>[oe(e),Q[e].moduleSpecifier]),...re].toSorted(([e],[t])=>e.localeCompare(t)),nt=[["usesNotifyFcm","@lunora/notify:fcm"],["usesNotifyWebPush","@lunora/notify:webPush"],["hostsShardRegistry","@lunora/do:shardRegistry"],["hostsEventLog","@lunora/replica:eventLog"],["usesEventLogClient","@lunora/replica:eventLogClient"],["usesRequestSecretTool","@lunora/agent:requestSecretTool"]],it=["@lunora/agent","@lunora/agent/sandbox"],ie=new RegExp(String.raw`["'\x60](?:${[...ne.map(([,e])=>e),...it,b].map(e=>Re(e)).join("|")})["'\x60]`,"u"),p=e=>{const{contextProperty:t,moduleSpecifier:s}=Q[e];return t===void 0?`${s} is imported`:`${s} is imported or ctx.${t} is read`},at="STRIPE_SECRET_KEY + STRIPE_WEBHOOK_SECRET (Stripe) or POLAR_ACCESS_TOKEN + POLAR_WEBHOOK_SECRET (Polar)",ct=/\bfrom\s+["']\.{1,2}\//u,ae=(e,t)=>{let s;try{s=de(e,{withFileTypes:!0})}catch{return}for(const o of s){if(o.isDirectory()){tt.has(o.name)||ae(S(e,o.name),t);continue}const r=o.name.lastIndexOf(".");r!==-1&&et.has(o.name.slice(r))&&t.push(S(e,o.name))}},dt=(e,t,s)=>{const{info:o}=Oe(e,t,s);return{jurisdiction:o?.jurisdiction,needsD1:o?.hasD1GlobalTable??!1}};let $;const lt=e=>{const t=me(e);return $?.root!==t&&($={project:new z({compilerOptions:{allowJs:!0},skipAddingFilesFromTsConfig:!0}),root:t}),$.project},ut=(e,t,s)=>{e.getSourceFile(t)?.getFullText()!==s&&e.createSourceFile(t,s,{overwrite:!0})},pt=(e,t)=>{for(const s of e.getSourceFiles())t.has(s)||e.removeSourceFile(s)},mt=(e,t,s)=>{const o=S(e,s),r=lt(e),a=[],i=new Set,c=[],d=[],l=ve();let u=!1,v=!1;for(const f of t){const x=S(e,f);if(!k(x)||!F(x).isDirectory())continue;const O=[];ae(x,O);for(const C of O){i.add(C);const y=J(C,"utf8"),E=ee(C,o);u||=rt.test(y),v||=ot.test(y),(ie.test(y)||y.includes(h)||E&&(Ee(y)||ct.test(y)))&&(ut(r,C,y),a.push({file:C,inLunora:E}))}}pt(r,new Set(a.map(({file:f})=>r.getSourceFileOrThrow(f))));for(const{file:f,inLunora:x}of a)(x?c:d).push(be(r.getSourceFileOrThrow(f),l));const g=V(c),A=V([g,...d]),N=new Set([...A.valueImports,...A.dynamicImports]),T=Ne({contextReads:g.contextReads,valueImports:N});return{...Object.fromEntries([...se.map(f=>[oe(f),T.has(f)]),...re.map(([f,x])=>[f,N.has(x)])]),needsD1:v,usesEventLogClient:a.some(({file:f})=>te(r.getSourceFileOrThrow(f))),usesRequestSecretTool:g.requestSecretTool,usesAi:T.has("ai")||u,usesBrowser:T.has("browser")||g.sandboxTools.usesSandboxBrowser,usesWorkerLoader:g.sandboxTools.usesSandboxLoader,scannedFiles:i}},ft=(e,t,s)=>[...e.map(o=>o.exported?`${o.bindingName}/${o.className} (container "${o.exportName}" declared and exported)`:`hint: container "${o.exportName}" is declared but ${o.className} is not exported by the worker entry — add \`export * from "./lunora/_generated/containers"\``),...t.map(o=>o.exported?`exports.${o.className} (workflow "${o.exportName}" declared and exported)`:`hint: workflow "${o.exportName}" is declared but ${o.className} is not exported by the worker entry — add \`export * from "./lunora/_generated/workflows"\``),...s.map(o=>o.exported?`exports.${o.className} (agent "${o.exportName}" declared and exported)`:`hint: agent "${o.exportName}" is declared but ${o.className} is not exported by the worker entry — add \`export * from "./lunora/_generated/agents"\``)],gt=(e,t,s)=>[[e.usesAi,`AI (${p("ai")}, or env.AI is used)`],[e.usesAuth&&!t.has("SessionDO"),"hint: @lunora/auth is imported; its tables are D1-backed by default. For DO-backed auth (what @better-auth/scim needs), pass `namespace` to .auth() and export the generated auth DO class"],[e.usesScheduler&&!t.has("SchedulerDO"),`hint: ${p("scheduler")}, but no SchedulerDO is exported by the worker entry`],[e.usesStorage,`hint: ${p("storage")}; add an r2_buckets binding (bucket binding names are user-defined)`],[e.usesMail,`hint: ${p("mail")}; set RESEND_API_KEY in .dev.vars (obtain at https://resend.com/api-keys)`],[e.usesPayments,`hint: ${p("payments")}; set the provider secrets in .dev.vars — ${at}`],[e.usesBrowser,`browser (${p("browser")}, or a sandbox browserTool imported in lunora/) — self-describing { binding: BROWSER }`],[e.usesImages,`images (${p("images")}) — self-describing { binding: IMAGES }`],[e.usesAnalytics,`analytics_engine_datasets (${p("analytics")}) — self-describing { binding: ANALYTICS, dataset }`],[e.usesWorkerLoader,"worker_loaders (jsCodeTool imported in lunora/) — self-describing { binding: LOADER }"],[e.usesAiSearch,`ai_search_namespaces (${p("aiSearch")}) — self-describing { binding: AI_SEARCH, namespace: "default" }; remote-only, so \`lunora dev\` reaches the deployed AI Search service`],[e.usesAnalyticsSql,`analytics (${p("analyticsSql")}) — self-describing { binding: ANALYTICS_SQL }; needs wrangler >= 4.145.0, and is remote-only, so \`lunora dev\` queries the account's live analytics`],[e.usesKv,s.jurisdiction===void 0?`kv_namespaces (${p("kv")}) — { binding: KV } with no id; wrangler creates the namespace on the first deploy`:`hint: ${p("kv")} and the schema pins "${s.jurisdiction}"; create the namespace with --jurisdiction ${s.jurisdiction} and add a kv_namespaces binding ({ binding, id })`],[e.usesHyperdrive,`hyperdrive (${p("hyperdrive")}) — { binding: HYPERDRIVE } with a placeholder id; dev uses an embedded Postgres and \`lunora deploy\` creates the config`],[e.usesPipelines,`hint: ${p("pipelines")}; run 'wrangler pipelines create <name>' and add a 'pipelines' binding ({ binding, stream }) — the pipeline resource can't be auto-provisioned`],[e.usesArtifacts,s.jurisdiction===void 0?`artifacts (${p("artifacts")}) — { binding: ARTIFACTS, namespace }`:`hint: ${p("artifacts")}; the schema pins data to "${s.jurisdiction}", so create the namespace in that jurisdiction first and add { binding: ARTIFACTS, namespace } yourself — \`lunora deploy\` then checks it (a first create() in dev would make it unrestricted)`],[e.usesX402Charge,"hint: @lunora/x402/charge is imported; set the recipient wallet address as a [vars] entry (the var name is yours to choose) and pass it to the charge config — the x402 facilitator settles USDC to that address"],[e.usesX402,`hint: ${p("x402")} (ActionCtx-only, spends real funds); add a secrets_store_secrets[] binding for the agent wallet key (name it to match signer.secretName) and pair the pay rail with a spend policy — ctx.secrets reads a Secrets Store binding, not .dev.vars, so the key can't be auto-provisioned`]].filter(([r])=>r).map(([,r])=>r),ht=(e,t,s,o=[],r=[],a=[])=>{const i=new Set(e.map(d=>d.className)),c=e.map(d=>`${d.binding}/${d.className} (exported by worker entry)`);return t.needsD1&&c.push("DB (.global() table declared)"),c.push(...ft(o,r,a),...gt(s,i,t)),c},xt=(e,t)=>e.some(s=>s.binding==="SHARD_REGISTRY")||Z(t)&&k(S(t,"shardRegistry.ts")),St=(e,t,s)=>{const o=new z({compilerOptions:{allowJs:!0},skipAddingFilesFromTsConfig:!0}),r=[e],a=new Set;for(let i=r.pop();i!==void 0;i=r.pop()){if(a.has(i))continue;a.add(i);const c=K(i),d=c.text;if((ie.test(d)||d.includes(h))&&te(o.createSourceFile(i,d,{overwrite:!0})))return!0;for(const l of Ze(c)){const u=B(i,l);u!==void 0&&!t.has(u)&&!ee(u,s)&&r.push(u)}}return!1},yt=e=>!e.composed&&e.path!==void 0&&G(e.path,"EventLogDO",void 0,new Set),Lt=async e=>{await Ce;const t=e.schemaDir??"lunora",s=e.scanDirs??st,o=()=>mt(e.projectRoot,s,t),{scannedFiles:r,...a}=e.cache===void 0?o():e.cache.memo(`capabilities:${e.projectRoot}:${t}:${s.join(",")}`,o),i=we(e.projectRoot);let c;i.composed?c=De(S(e.projectRoot,t,w)).map(W=>({binding:_e[W],className:W})):c=i.path===void 0?[]:Le(i.path);const d=dt(e.projectRoot,t,e.cache),l={...d,needsD1:a.needsD1||d.needsD1},u=L(i,Ie(e.projectRoot,t,e.cache).containers,"containers"),v=L(i,$e(e.projectRoot,t).workflows,"workflows"),g=L(i,Te(e.projectRoot,t).agents,"agents"),A=[...je(e.projectRoot,t).queues],{flags:N}=Pe(e.projectRoot,t),T=M(e.projectRoot,t,ye,Se),_=T.error===void 0?T.value:{hasFcm:!0,hasWebPush:!0},f=N?.provider==="flagship"&&N.mode==="binding"?N.bindingName:void 0,x=S(e.projectRoot,t,w),O=xt(c,x),C=yt(i),y=!i.composed&&i.path!==void 0&&St(i.path,r,x),E=ht(c,l,a,u,v,g);!i.composed&&Z(S(e.projectRoot,t,w))&&!c.some(I=>I.className==="LunoraDO")&&E.push("hint: durableObjects.merge is set, but the worker entry exports no LunoraDO — export one built with mergeDurableObjects, or the classes stay separate"),f!==void 0&&E.push(`hint: lunora/flags.ts uses Flagship in binding mode; add a flagship binding ({ binding: "${f}", app_id }) — the app_id can't be auto-provisioned`);const R=xe(e.projectRoot),ce=R.error===void 0?R.services:void 0;return R.error!==void 0&&E.push(`hint: lunora.config \`services\` not reconciled — ${R.error}`),E.push(...R.services.map(I=>`${I.binding} → ${I.worker} (lunora.config services.${I.name})`)),{...a,usesEventLogClient:a.usesEventLogClient||y,agents:g,containers:u,durableObjects:c,flagshipBinding:f,...l.jurisdiction===void 0?{}:{jurisdiction:l.jurisdiction},needsD1:l.needsD1,queues:A,services:ce,signals:E,usesFlags:N!==void 0,usesNotifyFcm:_?.hasFcm??!1,usesNotifyWebPush:_?.hasWebPush??!1,hostsEventLog:C,hostsShardRegistry:O,workflows:v}},$t=e=>[...ne,...nt].filter(([t,s])=>e[t]&&Ae[s]!==void 0).map(([,t])=>t);export{Lt as inferLunoraBindings,$t as secretSourcesFromBindings};
|