@lunora/codegen 1.0.0-alpha.394 → 1.0.0-alpha.396
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/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{SCHEMA_SNAPSHOT_VERSION as t,diffSchemaSnapshots as a,serializeSchemaSnapshot as i}from"./packem_shared/SCHEMA_SNAPSHOT_VERSION-DTLoSaNn.mjs";import{formatAdvisories as f,lintSchema as m,toAdvisorContext as d}from"./packem_shared/formatAdvisories-BCVASH7N.mjs";import{describeErrorLevelFindings as n,errorAdvisoryNames as c,errorPlatformDiagnosticNames as l,sortedUniqueNames as x}from"./packem_shared/describeErrorLevelFindings-vzaGS9KL.mjs";import{CAPABILITY_PROBES as E}from"./packem_shared/CAPABILITY_PROBES-BuNEmlCO.mjs";import{CodegenDiagnosticError as A,diagnosticAt as v}from"./packem_shared/CodegenDiagnosticError-BUXlG3P-.mjs";import{AGENTS_FILENAME as C,discoverAgents as N}from"./packem_shared/AGENTS_FILENAME-BxpEvZgW.mjs";import{isTestPath as R,listLunoraSourceFiles as T}from"./packem_shared/isTestPath-DrszPMtU.mjs";import{default as F}from"./packem_shared/discoverAuthApiCalls-D-ZsZKvv.mjs";import{CONTAINERS_FILENAME as L,discoverContainers as _}from"./packem_shared/CONTAINERS_FILENAME-CvPP3wR-.mjs";import{default as P}from"./packem_shared/discoverCrons-BT_qyOt8.mjs";import{capabilitiesUsedBy as y,createTargetScope as b,foldCapabilitySignals as U,mayReadCapabilityContext as G,sourceCapabilitySignals as H}from"./packem_shared/capabilitiesUsedBy-B8KULfAq.mjs";import{FLAGS_FILENAME as B,discoverFlags as k}from"./packem_shared/FLAGS_FILENAME-Ce1G6kZd.mjs";import{d as z}from"./packem_shared/index-DzO8JT7M.mjs";import{default as V}from"./packem_shared/discoverHttpRoutes-DOkHmHzy.mjs";import{default as q}from"./packem_shared/discoverHyperdriveCalls-BGhSZp00.mjs";import{default as J}from"./packem_shared/discoverInserts-d_zAWqc4.mjs";import{d as X}from"./packem_shared/index-VKPwR6Cj.mjs";import{default as $}from"./packem_shared/discoverMigrations-Dq-7Od3H.mjs";import{MUTATORS_FILENAME as re,discoverMutators as oe}from"./packem_shared/MUTATORS_FILENAME-JBFlT9aD.mjs";import{default as ae}from"./packem_shared/discoverNondeterministicCalls-CWLdAwUM.mjs";import{NOTIFY_FILENAME as se,discoverNotifyCalls as fe,discoverNotifyChannels as me,discoverNotifyConfig as de}from"./packem_shared/NOTIFY_FILENAME-DLGxunzB.mjs";import{default as ne}from"./packem_shared/readPackageDependencies-RHhGiz0k.mjs";import{default as le}from"./packem_shared/discoverQueries-Bvh__ZjJ.mjs";import{QUEUES_FILENAME as Se,discoverQueues as Ee}from"./packem_shared/QUEUES_FILENAME-2K8DSvbt.mjs";import{default as Ae}from"./packem_shared/discoverR2sqlCalls-CexxhDRt.mjs";import{default as ge}from"./packem_shared/discoverRlsProcedures-CDbsnndn.mjs";import{default as Ne}from"./packem_shared/discoverRlsMetadata-CugyqoLu.mjs";import{discoverSandboxUsage as Re}from"./packem_shared/discoverSandboxUsage-CSt29RbS.mjs";import{default as he}from"./packem_shared/discoverSchema-DTgg8rAu.mjs";import{readServiceBindings as Ie,resolveServiceBindings as Le}from"./packem_shared/readServiceBindings-rDIqDBSW.mjs";import{SHAPES_FILENAME as Me,discoverShapes as Pe}from"./packem_shared/SHAPES_FILENAME-DCqsIdQQ.mjs";import{default as ye}from"./packem_shared/discoverStorageRulesMetadata-DTXC-pY3.mjs";import{WORKFLOWS_FILENAME as Ue,discoverWorkflows as Ge}from"./packem_shared/WORKFLOWS_FILENAME-Cpx5Mg0z.mjs";import{emitApp as je}from"./packem_shared/emitApp-
|
|
1
|
+
import{SCHEMA_SNAPSHOT_VERSION as t,diffSchemaSnapshots as a,serializeSchemaSnapshot as i}from"./packem_shared/SCHEMA_SNAPSHOT_VERSION-DTLoSaNn.mjs";import{formatAdvisories as f,lintSchema as m,toAdvisorContext as d}from"./packem_shared/formatAdvisories-BCVASH7N.mjs";import{describeErrorLevelFindings as n,errorAdvisoryNames as c,errorPlatformDiagnosticNames as l,sortedUniqueNames as x}from"./packem_shared/describeErrorLevelFindings-vzaGS9KL.mjs";import{CAPABILITY_PROBES as E}from"./packem_shared/CAPABILITY_PROBES-BuNEmlCO.mjs";import{CodegenDiagnosticError as A,diagnosticAt as v}from"./packem_shared/CodegenDiagnosticError-BUXlG3P-.mjs";import{AGENTS_FILENAME as C,discoverAgents as N}from"./packem_shared/AGENTS_FILENAME-BxpEvZgW.mjs";import{isTestPath as R,listLunoraSourceFiles as T}from"./packem_shared/isTestPath-DrszPMtU.mjs";import{default as F}from"./packem_shared/discoverAuthApiCalls-D-ZsZKvv.mjs";import{CONTAINERS_FILENAME as L,discoverContainers as _}from"./packem_shared/CONTAINERS_FILENAME-CvPP3wR-.mjs";import{default as P}from"./packem_shared/discoverCrons-BT_qyOt8.mjs";import{capabilitiesUsedBy as y,createTargetScope as b,foldCapabilitySignals as U,mayReadCapabilityContext as G,sourceCapabilitySignals as H}from"./packem_shared/capabilitiesUsedBy-B8KULfAq.mjs";import{FLAGS_FILENAME as B,discoverFlags as k}from"./packem_shared/FLAGS_FILENAME-Ce1G6kZd.mjs";import{d as z}from"./packem_shared/index-DzO8JT7M.mjs";import{default as V}from"./packem_shared/discoverHttpRoutes-DOkHmHzy.mjs";import{default as q}from"./packem_shared/discoverHyperdriveCalls-BGhSZp00.mjs";import{default as J}from"./packem_shared/discoverInserts-d_zAWqc4.mjs";import{d as X}from"./packem_shared/index-VKPwR6Cj.mjs";import{default as $}from"./packem_shared/discoverMigrations-Dq-7Od3H.mjs";import{MUTATORS_FILENAME as re,discoverMutators as oe}from"./packem_shared/MUTATORS_FILENAME-JBFlT9aD.mjs";import{default as ae}from"./packem_shared/discoverNondeterministicCalls-CWLdAwUM.mjs";import{NOTIFY_FILENAME as se,discoverNotifyCalls as fe,discoverNotifyChannels as me,discoverNotifyConfig as de}from"./packem_shared/NOTIFY_FILENAME-DLGxunzB.mjs";import{default as ne}from"./packem_shared/readPackageDependencies-RHhGiz0k.mjs";import{default as le}from"./packem_shared/discoverQueries-Bvh__ZjJ.mjs";import{QUEUES_FILENAME as Se,discoverQueues as Ee}from"./packem_shared/QUEUES_FILENAME-2K8DSvbt.mjs";import{default as Ae}from"./packem_shared/discoverR2sqlCalls-CexxhDRt.mjs";import{default as ge}from"./packem_shared/discoverRlsProcedures-CDbsnndn.mjs";import{default as Ne}from"./packem_shared/discoverRlsMetadata-CugyqoLu.mjs";import{discoverSandboxUsage as Re}from"./packem_shared/discoverSandboxUsage-CSt29RbS.mjs";import{default as he}from"./packem_shared/discoverSchema-DTgg8rAu.mjs";import{readServiceBindings as Ie,resolveServiceBindings as Le}from"./packem_shared/readServiceBindings-rDIqDBSW.mjs";import{SHAPES_FILENAME as Me,discoverShapes as Pe}from"./packem_shared/SHAPES_FILENAME-DCqsIdQQ.mjs";import{default as ye}from"./packem_shared/discoverStorageRulesMetadata-DTXC-pY3.mjs";import{WORKFLOWS_FILENAME as Ue,discoverWorkflows as Ge}from"./packem_shared/WORKFLOWS_FILENAME-Cpx5Mg0z.mjs";import{emitApp as je}from"./packem_shared/emitApp-D-fxbE34.mjs";import{isD1GlobalTable as ke,isHyperdriveGlobalTable as We}from"./packem_shared/isD1GlobalTable-udvHAAzD.mjs";import{buildOpenApiDocument as Ke,emitOpenApi as Ve,emitOpenApiModule as Qe}from"./packem_shared/buildOpenApiDocument-KKQFkA_W.mjs";import{OPENRPC_VERSION as we,buildOpenRpcDocument as Je,emitOpenRpc as Ye,emitOpenRpcModule as Xe}from"./packem_shared/OPENRPC_VERSION-CLZ5Em9J.mjs";import{DEFAULT_TARGET as $e,platformMatrixIds as er,readProjectTarget as rr,resolveCodegenTarget as or}from"./packem_shared/DEFAULT_TARGET-C0xI7Xqd.mjs";import{loadProjectConfig as ar,readProjectConfigLiterals as ir,readProjectLazyFunctions as sr}from"./packem_shared/loadProjectConfig-Dbux4jI3.mjs";import{PROJECT_CONFIG_FILENAMES as mr,findCodegenConfigFile as dr,findProjectConfigFile as pr,projectConfigCandidatePaths as nr}from"./packem_shared/PROJECT_CONFIG_FILENAMES-CLfsyvjA.mjs";import{SCHEMA_SNAPSHOT_FILENAME as lr,runCodegen as xr}from"./packem_shared/SCHEMA_SNAPSHOT_FILENAME-BRRkfu5-.mjs";import{SchemaSnapshotParseError as Er,buildSchemaSnapshot as ur,evaluateSchemaDrift as Ar,indexReferencesOf as vr,parseSchemaSnapshot as gr}from"./packem_shared/SchemaSnapshotParseError-DnAuFdpl.mjs";import{default as Nr}from"./packem_shared/fingerprintSchemaSources-Pmxw808S.mjs";import{schemaFromIr as Rr}from"./packem_shared/schemaFromIr-CByOxuZb.mjs";import{LUNORA_ERROR_CODES as hr,validatorIrToJsonSchema as Fr}from"./packem_shared/LUNORA_ERROR_CODES-CjACC-MQ.mjs";import{SDK_LANGUAGES as Lr,SDK_TARGETS as _r,generateSdk as Mr}from"./sdk/index.mjs";import{redact as Dr,secretKindOf as yr}from"./packem_shared/redact-Cy14LEnc.mjs";import{default as Ur}from"./packem_shared/emitDrizzleSchema-Dszoyymv.mjs";import{e as Hr}from"./packem_shared/server-Box8pDwi.mjs";import{e as Br}from"./packem_shared/shard-DXVp_Iht.mjs";import{G as Wr}from"./packem_shared/shared-DhqnD5R3.mjs";import{MESSAGE_SOLUTIONS as Kr,findSolutionByMessage as Vr}from"@lunora/errors";import{createCodegenProject as qr,findTsconfig as wr,refreshCodegenProject as Jr,tsconfigFingerprint as Yr}from"./packem_shared/createCodegenProject-khHqIXPY.mjs";import{t as Zr,u as $r,v as eo}from"./packem_shared/shard-runtime-BHljpfS5.mjs";import{emitApi as oo,emitCollections as to,emitInternalApi as ao}from"./packem_shared/emitApi-Cdc8MeNK.mjs";import{emitCrons as so,emitScheduler as fo,emitVectors as mo,emitWranglerCronTriggers as po}from"./packem_shared/emitCrons-BQjDleCe.mjs";import{emitDataModel as co}from"./packem_shared/emitDataModel-MjAOi3KM.mjs";import{emitFunctions as xo}from"./packem_shared/emitFunctions-BIMKBLQ8.mjs";import{isTypedSchema as Eo}from"./packem_shared/isTypedSchema-CDv3pJB6.mjs";const e="0.0.0";export{C as AGENTS_FILENAME,E as CAPABILITY_PROBES,L as CONTAINERS_FILENAME,A as CodegenDiagnosticError,$e as DEFAULT_TARGET,B as FLAGS_FILENAME,Wr as GENERATED_HEADER,hr as LUNORA_ERROR_CODES,Kr as LUNORA_SOLUTION_RULES,re as MUTATORS_FILENAME,se as NOTIFY_FILENAME,we as OPENRPC_VERSION,mr as PROJECT_CONFIG_FILENAMES,Se as QUEUES_FILENAME,lr as SCHEMA_SNAPSHOT_FILENAME,t as SCHEMA_SNAPSHOT_VERSION,Lr as SDK_LANGUAGES,_r as SDK_TARGETS,Me as SHAPES_FILENAME,Er as SchemaSnapshotParseError,e as VERSION,Ue as WORKFLOWS_FILENAME,Ke as buildOpenApiDocument,Je as buildOpenRpcDocument,ur as buildSchemaSnapshot,y as capabilitiesUsedBy,qr as createCodegenProject,b as createTargetScope,n as describeErrorLevelFindings,v as diagnosticAt,a as diffSchemaSnapshots,N as discoverAgents,F as discoverAuthApiCalls,_ as discoverContainers,P as discoverCrons,k as discoverFlags,z as discoverFunctions,V as discoverHttpRoutes,q as discoverHyperdriveCalls,J as discoverInserts,X as discoverMaskProcedures,$ as discoverMigrations,oe as discoverMutators,ae as discoverNondeterministicCalls,fe as discoverNotifyCalls,me as discoverNotifyChannels,de as discoverNotifyConfig,le as discoverQueries,Ee as discoverQueues,Ae as discoverR2sqlCalls,Ne as discoverRlsMetadata,ge as discoverRlsProcedures,Re as discoverSandboxUsage,he as discoverSchema,Pe as discoverShapes,ye as discoverStorageRulesMetadata,Ge as discoverWorkflows,Zr as emitAgents,oo as emitApi,je as emitApp,to as emitCollections,$r as emitContainers,so as emitCrons,co as emitDataModel,Ur as emitDrizzleSchema,xo as emitFunctions,ao as emitInternalApi,Ve as emitOpenApi,Qe as emitOpenApiModule,Ye as emitOpenRpc,Xe as emitOpenRpcModule,fo as emitScheduler,Hr as emitServer,Br as emitShard,mo as emitVectors,eo as emitWorkflows,po as emitWranglerCronTriggers,c as errorAdvisoryNames,l as errorPlatformDiagnosticNames,Ar as evaluateSchemaDrift,dr as findCodegenConfigFile,Vr as findLunoraSolution,pr as findProjectConfigFile,wr as findTsconfig,Nr as fingerprintSchemaSources,U as foldCapabilitySignals,f as formatAdvisories,Mr as generateSdk,vr as indexReferencesOf,ke as isD1GlobalTable,We as isHyperdriveGlobalTable,R as isTestPath,Eo as isTypedSchema,m as lintSchema,T as listLunoraSourceFiles,ar as loadProjectConfig,G as mayReadCapabilityContext,gr as parseSchemaSnapshot,er as platformMatrixIds,nr as projectConfigCandidatePaths,ne as readPackageDependencies,ir as readProjectConfigLiterals,sr as readProjectLazyFunctions,rr as readProjectTarget,Ie as readServiceBindings,Dr as redact,Jr as refreshCodegenProject,or as resolveCodegenTarget,Le as resolveServiceBindings,xr as runCodegen,Rr as schemaFromIr,yr as secretKindOf,i as serializeSchemaSnapshot,x as sortedUniqueNames,H as sourceCapabilitySignals,d as toAdvisorContext,Yr as tsconfigFingerprint,Fr as validatorIrToJsonSchema};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{existsSync as K,readFileSync as Je,mkdirSync as jt,writeFileSync as Pr,rmSync as we,readdirSync as Dn}from"node:fs";import{dirname as Ht,join as v,relative as Gt}from"node:path";import{performance as St}from"node:perf_hooks";import{runAdvisor as wr}from"@lunora/advisor";import{LunoraError as M}from"@lunora/errors";import{serializeSchemaSnapshot as Ir}from"./SCHEMA_SNAPSHOT_VERSION-DTLoSaNn.mjs";import{toAdvisorContext as Tr}from"./formatAdvisories-BCVASH7N.mjs";import{Node as r,SyntaxKind as d,Project as Yt,ts as Cr,VariableDeclarationKind as Qt}from"ts-morph";import{listLunoraSourceFiles as y,lunoraRelativePath as T,descendantsOfKind as E,bindingKeyName as fe,collectCallRows as k,findObjectProperty as U,collectSecurityCallRows as Or,propertyInitializer as D,listSecurityScanFiles as Ze,objectLiteralFromCallbackBody as Mn,limitNameOf as _n,optionsObjectLiteral as zn,handlerOf as kr,collectNodeRows as re,chainRootOf as et,outermostValueWrapper as O,isWriteTarget as tt,isSameNode as b,unwrapExpression as h,isConstDeclaration as oe,memberAccessOf as Xt,returningFunctionOf as kt,walkChain as Rr,RUN_METHODS as Kn,functionReferenceSegments as Fr,isTestPath as Lr,isFunctionLike as ae,functionKeyOf as $n,withSourceListMemo as Dr}from"./isTestPath-DrszPMtU.mjs";import{j as J,h as G,d as _,b as Jt,c as S,a as st,w as Zt,k as Mr,l as _r,f as zr,m as Kr,g as Rt,i as $r}from"./attribution-7Qs8xFmy.mjs";import{b as $s,r as At,a as Q,e as Br,m as Bn,c as nt,f as es,E as Vn,C as Un,d as Vr,g as Ur,i as Wr}from"./context-root-DHXNIvVA.mjs";import{a as C,i as Wn,c as se,d as qn,e as qr,f as jr,g as jn}from"./classify-procedure-call-D7XTLd8w.mjs";import{a as A,s as Hr}from"./property-name-7cBlgK_O.mjs";import{b as Gr,a as it}from"./module-specifiers-BctA0m_p.mjs";import{r as rt,s as Yr}from"./parse-validator-BisfC8bR.mjs";import Qr from"./discoverAuthApiCalls-D-ZsZKvv.mjs";import{i as $,r as Hn}from"./database-calls-CxJgjC_X.mjs";import{i as Ft,p as Gn,w as Xr,d as Jr}from"./index-DzO8JT7M.mjs";import Zr from"./discoverHyperdriveCalls-BGhSZp00.mjs";import{diagnosticAt as ce}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{m as ts,a as qe,s as Yn,d as eo}from"./index-VKPwR6Cj.mjs";import{MUTATORS_FILENAME as to,isDefineMutatorCallee as so,mutatorServerImplOf as no,discoverMutators as io}from"./MUTATORS_FILENAME-JBFlT9aD.mjs";import ro from"./discoverNondeterministicCalls-CWLdAwUM.mjs";import{discoverNotifyConfig as oo,discoverNotifyCalls as ao}from"./NOTIFY_FILENAME-DLGxunzB.mjs";import co from"./discoverR2sqlCalls-CexxhDRt.mjs";import lo from"./discoverRlsProcedures-CDbsnndn.mjs";import{s as ss,n as uo}from"./dispatch-namespace-DwTjD7BU.mjs";import{secretKindOf as fo,redact as go,isHeuristicSecretKind as po,isSecretishName as mo}from"./redact-Cy14LEnc.mjs";import{readProjectConfigLiterals as Qn,readProjectLazyFunctions as ho,readMergeDurableObjects as vo}from"./loadProjectConfig-Dbux4jI3.mjs";import{a as Me,d as Eo,r as xo}from"./modules-CYf6V2w7.mjs";import{WORKFLOWS_FILENAME as So,discoverWorkflows as Ao}from"./WORKFLOWS_FILENAME-Cpx5Mg0z.mjs";import{r as yo}from"./json-data-Chfs2Cz5.mjs";import{a as bo,I as No,g as Po,G as Xn,d as wo,i as Io}from"./shared-DhqnD5R3.mjs";import{createCodegenProject as To}from"./createCodegenProject-khHqIXPY.mjs";import{findTsconfig as HE,refreshCodegenProject as GE,tsconfigFingerprint as YE}from"./createCodegenProject-khHqIXPY.mjs";import{CAPABILITIES as Co,usedCapabilities as Oo}from"./CAPABILITY_PROBES-BuNEmlCO.mjs";import{isD1GlobalTable as Jn,isHyperdriveGlobalTable as Zn}from"./isD1GlobalTable-udvHAAzD.mjs";import{discoverAgents as ko}from"./AGENTS_FILENAME-BxpEvZgW.mjs";import{discoverContainers as Ro}from"./CONTAINERS_FILENAME-CvPP3wR-.mjs";import Fo from"./discoverCrons-BT_qyOt8.mjs";import{contextPropertiesRead as Lo,fileWiresRequestSecretTool as Do,createTargetScope as Mo,discoverFeatureUsage as _o}from"./capabilitiesUsedBy-B8KULfAq.mjs";import ei from"./readPackageDependencies-RHhGiz0k.mjs";import{PROJECT_CONFIG_FILENAMES as zo,findProjectConfigFile as Ko}from"./PROJECT_CONFIG_FILENAMES-CLfsyvjA.mjs";import{discoverQueueDeclarations as $o}from"./QUEUES_FILENAME-2K8DSvbt.mjs";import{discoverSandboxUsage as Bo}from"./discoverSandboxUsage-CSt29RbS.mjs";import{resolveServiceBindings as Vo}from"./readServiceBindings-rDIqDBSW.mjs";import Uo from"./discoverStorageRulesMetadata-DTXC-pY3.mjs";import{resolveCodegenTarget as _e,gatePlatformFeatures as Wo,readTargetDiagnostics as qo,vectorizeDimensionDiagnostics as jo,liveStreamsDeliveryAuthorizationDiagnostic as Ho,socketRoutesDeliveryAuthorizationDiagnostic as Go,studioPlatformFor as Yo,platformFeatureAvailable as Qo,gateAdminTokenRevocation as Xo}from"./DEFAULT_TARGET-C0xI7Xqd.mjs";import{i as Jo}from"./schema-BgM8A3XV.mjs";import{b as ti,e as Zo}from"./shard-DXVp_Iht.mjs";import{e as ea,a as ta}from"./server-Box8pDwi.mjs";import{emitDataModel as sa}from"./emitDataModel-MjAOi3KM.mjs";import{i as na,b as ia,e as ra,d as oa,f as aa,c as ca}from"./unwrap-handler-return-X7HuBhd5.mjs";import la from"./discoverHttpRoutes-DOkHmHzy.mjs";import da from"./discoverInserts-d_zAWqc4.mjs";import{e as si}from"./exported-procedure-chains-D1wkgxKb.mjs";import ua from"./discoverMigrations-Dq-7Od3H.mjs";import Bs from"./discoverQueries-Bvh__ZjJ.mjs";import fa from"./discoverRlsMetadata-CugyqoLu.mjs";import ga from"./discoverSchema-DTgg8rAu.mjs";import{discoverShapes as pa}from"./SHAPES_FILENAME-DCqsIdQQ.mjs";import{i as ma}from"./reserved-words-CW1QFbTd.mjs";import{emitAuthModule as ha,emitApp as va}from"./emitApp-
|
|
1
|
+
import{existsSync as K,readFileSync as Je,mkdirSync as jt,writeFileSync as Pr,rmSync as we,readdirSync as Dn}from"node:fs";import{dirname as Ht,join as v,relative as Gt}from"node:path";import{performance as St}from"node:perf_hooks";import{runAdvisor as wr}from"@lunora/advisor";import{LunoraError as M}from"@lunora/errors";import{serializeSchemaSnapshot as Ir}from"./SCHEMA_SNAPSHOT_VERSION-DTLoSaNn.mjs";import{toAdvisorContext as Tr}from"./formatAdvisories-BCVASH7N.mjs";import{Node as r,SyntaxKind as d,Project as Yt,ts as Cr,VariableDeclarationKind as Qt}from"ts-morph";import{listLunoraSourceFiles as y,lunoraRelativePath as T,descendantsOfKind as E,bindingKeyName as fe,collectCallRows as k,findObjectProperty as U,collectSecurityCallRows as Or,propertyInitializer as D,listSecurityScanFiles as Ze,objectLiteralFromCallbackBody as Mn,limitNameOf as _n,optionsObjectLiteral as zn,handlerOf as kr,collectNodeRows as re,chainRootOf as et,outermostValueWrapper as O,isWriteTarget as tt,isSameNode as b,unwrapExpression as h,isConstDeclaration as oe,memberAccessOf as Xt,returningFunctionOf as kt,walkChain as Rr,RUN_METHODS as Kn,functionReferenceSegments as Fr,isTestPath as Lr,isFunctionLike as ae,functionKeyOf as $n,withSourceListMemo as Dr}from"./isTestPath-DrszPMtU.mjs";import{j as J,h as G,d as _,b as Jt,c as S,a as st,w as Zt,k as Mr,l as _r,f as zr,m as Kr,g as Rt,i as $r}from"./attribution-7Qs8xFmy.mjs";import{b as $s,r as At,a as Q,e as Br,m as Bn,c as nt,f as es,E as Vn,C as Un,d as Vr,g as Ur,i as Wr}from"./context-root-DHXNIvVA.mjs";import{a as C,i as Wn,c as se,d as qn,e as qr,f as jr,g as jn}from"./classify-procedure-call-D7XTLd8w.mjs";import{a as A,s as Hr}from"./property-name-7cBlgK_O.mjs";import{b as Gr,a as it}from"./module-specifiers-BctA0m_p.mjs";import{r as rt,s as Yr}from"./parse-validator-BisfC8bR.mjs";import Qr from"./discoverAuthApiCalls-D-ZsZKvv.mjs";import{i as $,r as Hn}from"./database-calls-CxJgjC_X.mjs";import{i as Ft,p as Gn,w as Xr,d as Jr}from"./index-DzO8JT7M.mjs";import Zr from"./discoverHyperdriveCalls-BGhSZp00.mjs";import{diagnosticAt as ce}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{m as ts,a as qe,s as Yn,d as eo}from"./index-VKPwR6Cj.mjs";import{MUTATORS_FILENAME as to,isDefineMutatorCallee as so,mutatorServerImplOf as no,discoverMutators as io}from"./MUTATORS_FILENAME-JBFlT9aD.mjs";import ro from"./discoverNondeterministicCalls-CWLdAwUM.mjs";import{discoverNotifyConfig as oo,discoverNotifyCalls as ao}from"./NOTIFY_FILENAME-DLGxunzB.mjs";import co from"./discoverR2sqlCalls-CexxhDRt.mjs";import lo from"./discoverRlsProcedures-CDbsnndn.mjs";import{s as ss,n as uo}from"./dispatch-namespace-DwTjD7BU.mjs";import{secretKindOf as fo,redact as go,isHeuristicSecretKind as po,isSecretishName as mo}from"./redact-Cy14LEnc.mjs";import{readProjectConfigLiterals as Qn,readProjectLazyFunctions as ho,readMergeDurableObjects as vo}from"./loadProjectConfig-Dbux4jI3.mjs";import{a as Me,d as Eo,r as xo}from"./modules-CYf6V2w7.mjs";import{WORKFLOWS_FILENAME as So,discoverWorkflows as Ao}from"./WORKFLOWS_FILENAME-Cpx5Mg0z.mjs";import{r as yo}from"./json-data-Chfs2Cz5.mjs";import{a as bo,I as No,g as Po,G as Xn,d as wo,i as Io}from"./shared-DhqnD5R3.mjs";import{createCodegenProject as To}from"./createCodegenProject-khHqIXPY.mjs";import{findTsconfig as HE,refreshCodegenProject as GE,tsconfigFingerprint as YE}from"./createCodegenProject-khHqIXPY.mjs";import{CAPABILITIES as Co,usedCapabilities as Oo}from"./CAPABILITY_PROBES-BuNEmlCO.mjs";import{isD1GlobalTable as Jn,isHyperdriveGlobalTable as Zn}from"./isD1GlobalTable-udvHAAzD.mjs";import{discoverAgents as ko}from"./AGENTS_FILENAME-BxpEvZgW.mjs";import{discoverContainers as Ro}from"./CONTAINERS_FILENAME-CvPP3wR-.mjs";import Fo from"./discoverCrons-BT_qyOt8.mjs";import{contextPropertiesRead as Lo,fileWiresRequestSecretTool as Do,createTargetScope as Mo,discoverFeatureUsage as _o}from"./capabilitiesUsedBy-B8KULfAq.mjs";import ei from"./readPackageDependencies-RHhGiz0k.mjs";import{PROJECT_CONFIG_FILENAMES as zo,findProjectConfigFile as Ko}from"./PROJECT_CONFIG_FILENAMES-CLfsyvjA.mjs";import{discoverQueueDeclarations as $o}from"./QUEUES_FILENAME-2K8DSvbt.mjs";import{discoverSandboxUsage as Bo}from"./discoverSandboxUsage-CSt29RbS.mjs";import{resolveServiceBindings as Vo}from"./readServiceBindings-rDIqDBSW.mjs";import Uo from"./discoverStorageRulesMetadata-DTXC-pY3.mjs";import{resolveCodegenTarget as _e,gatePlatformFeatures as Wo,readTargetDiagnostics as qo,vectorizeDimensionDiagnostics as jo,liveStreamsDeliveryAuthorizationDiagnostic as Ho,socketRoutesDeliveryAuthorizationDiagnostic as Go,studioPlatformFor as Yo,platformFeatureAvailable as Qo,gateAdminTokenRevocation as Xo}from"./DEFAULT_TARGET-C0xI7Xqd.mjs";import{i as Jo}from"./schema-BgM8A3XV.mjs";import{b as ti,e as Zo}from"./shard-DXVp_Iht.mjs";import{e as ea,a as ta}from"./server-Box8pDwi.mjs";import{emitDataModel as sa}from"./emitDataModel-MjAOi3KM.mjs";import{i as na,b as ia,e as ra,d as oa,f as aa,c as ca}from"./unwrap-handler-return-X7HuBhd5.mjs";import la from"./discoverHttpRoutes-DOkHmHzy.mjs";import da from"./discoverInserts-d_zAWqc4.mjs";import{e as si}from"./exported-procedure-chains-D1wkgxKb.mjs";import ua from"./discoverMigrations-Dq-7Od3H.mjs";import Bs from"./discoverQueries-Bvh__ZjJ.mjs";import fa from"./discoverRlsMetadata-CugyqoLu.mjs";import ga from"./discoverSchema-DTgg8rAu.mjs";import{discoverShapes as pa}from"./SHAPES_FILENAME-DCqsIdQQ.mjs";import{i as ma}from"./reserved-words-CW1QFbTd.mjs";import{emitAuthModule as ha,emitApp as va}from"./emitApp-D-fxbE34.mjs";import{readJsonSync as Ea}from"@visulima/fs";import{indexReferencesOf as xa,buildSchemaSnapshot as Sa}from"./SchemaSnapshotParseError-DnAuFdpl.mjs";import{buildOpenApiDocument as Aa,emitOpenApiModule as ya}from"./buildOpenApiDocument-KKQFkA_W.mjs";import{buildOpenRpcDocument as ba,emitOpenRpcModule as Na}from"./OPENRPC_VERSION-CLZ5Em9J.mjs";import{w as Pa,u as wa,v as Ia,t as Ta,x as Ca}from"./shard-runtime-BHljpfS5.mjs";import{emitCollections as Oa,emitSeed as ka,emitApi as Ra,emitInternalApi as Fa}from"./emitApi-Cdc8MeNK.mjs";import{emitCrons as La,emitScheduler as Da,emitAdminRevocations as Ma,emitShardRegistry as _a,emitDurableObjects as za,emitVectors as Ka,emitWranglerCronTriggers as $a}from"./emitCrons-BQjDleCe.mjs";import Ba from"./emitDrizzleSchema-Dszoyymv.mjs";import{LAZY_FUNCTION_DIRECTORY as ni,emitFunctions as Va,emitLazyFunctionModules as Ua}from"./emitFunctions-BIMKBLQ8.mjs";const Wa=(e,t=!1)=>{if(e.length===0)return"";const s=wo(t),n=e.map(c=>{if(bo(c.exportName,"live stream export name"),!No.test(c.filePath))throw new Error(`@lunora/codegen: live stream file path is not safe to import: ${JSON.stringify(c.filePath)}`);return`import type { ${c.exportName} as ${c.exportName}Stream } from "../${c.filePath}.js";`}),i=e.map(c=>{const l=c.topics.map(u=>{Po(u.name,"live topic name");const f=`(typeof ${c.exportName}Stream)["topics"]["${u.name}"]`,g=`LiveTopicRef<LiveTopicPayload<${f}>>`,m=JSON.stringify(c.id);if(u.fields.length===0)return` ${u.name}: (): ${g} => ({ __lunoraLive: ${m}, topic: ${JSON.stringify(u.name)} }),`;const x=u.fields.map(N=>`\${encodeURIComponent(key.${N})}`).join(":");return` ${u.name}: (key: LiveTopicKey<${f}>): ${g} => ({
|
|
2
2
|
__lunoraLive: ${m},
|
|
3
3
|
topic: \`${u.name}:${x}\`,
|
|
4
4
|
}),`});return` ${c.exportName}: {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{APP_METHOD_CAPABILITIES as
|
|
1
|
+
import{APP_METHOD_CAPABILITIES as q}from"./CAPABILITY_PROBES-BuNEmlCO.mjs";import{i as N}from"./schema-BgM8A3XV.mjs";import{a as I,I as L,G as y}from"./shared-DhqnD5R3.mjs";const j={configKey:"vectors",doc:"Wire the Vectorize index map backing `ctx.vectors`.",method:"vectors"},f=e=>[...q.filter(({key:r})=>e.capabilities.has(r)).map(({appMethod:r})=>r),...e.hasVectors?[j]:[]],w=e=>f(e).length>0,k=e=>(e.emailAgents?.length??0)>0,l=e=>e.tables.some(r=>N(r)),p=e=>e.liveStreams===!0&&(e.liveStreamDeclarations?.length??0)>0,$=e=>e.hasScheduler?`
|
|
2
2
|
/** Resolve the \`SchedulerDO\`-backed scheduler for this env; \`undefined\` until the namespace is wired. */
|
|
3
3
|
private resolveScheduler(env: Env): ReturnType<typeof createScheduler> | undefined {
|
|
4
4
|
const namespace = this.schedulerDeclaration?.namespace(env);
|
|
@@ -138,22 +138,14 @@ import{APP_METHOD_CAPABILITIES as N}from"./CAPABILITY_PROBES-BuNEmlCO.mjs";impor
|
|
|
138
138
|
* deployed; the dashboard's own metric is per-database and can't name the query.
|
|
139
139
|
* The emit is best-effort — instrumentation must never fail a served query.
|
|
140
140
|
*/
|
|
141
|
-
const
|
|
141
|
+
const buildSessionExec = (database: D1DatabaseLike, constraint: string, onBookmark?: (bookmark: string | undefined) => void): D1Exec => {
|
|
142
142
|
// Real D1 always exposes \`withSession\`; guarded the same way as \`batch\`
|
|
143
143
|
// below so a hand-rolled test double that omits it keeps working via
|
|
144
|
-
// \`prepare()\` straight on the raw binding — today's behaviour.
|
|
145
|
-
//
|
|
146
|
-
|
|
147
|
-
const session = typeof database.withSession === "function" ? database.withSession(bookmark ?? "first-unconstrained") : undefined;
|
|
144
|
+
// \`prepare()\` straight on the raw binding — today's behaviour. \`constraint\`
|
|
145
|
+
// is the Sessions API constraint the session opens with (see \`buildExec\`).
|
|
146
|
+
const session = typeof database.withSession === "function" ? database.withSession(constraint) : undefined;
|
|
148
147
|
const target = session ?? database;
|
|
149
148
|
const batchFn = target.batch;
|
|
150
|
-
const meter = (sql: string, meta: Record<string, unknown> | undefined): void => {
|
|
151
|
-
try {
|
|
152
|
-
emitD1QueryCost(sql, meta);
|
|
153
|
-
} catch {
|
|
154
|
-
// Best-effort: never let cost accounting fail the query it measures.
|
|
155
|
-
}
|
|
156
|
-
};
|
|
157
149
|
|
|
158
150
|
return retryingExec({
|
|
159
151
|
all: async (sql, parameters) => {
|
|
@@ -225,6 +217,56 @@ const buildExec = (database: D1DatabaseLike, bookmark?: string, onBookmark?: (bo
|
|
|
225
217
|
});
|
|
226
218
|
};
|
|
227
219
|
|
|
220
|
+
const meter = (sql: string, meta: Record<string, unknown> | undefined): void => {
|
|
221
|
+
try {
|
|
222
|
+
emitD1QueryCost(sql, meta);
|
|
223
|
+
} catch {
|
|
224
|
+
// Best-effort: never let cost accounting fail the query it measures.
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* The primary exec, for a read that must see every committed write (a policy check on a write
|
|
230
|
+
* path). Every statement opens its own \`"first-primary"\` session, and so does every retry:
|
|
231
|
+
* that constraint covers only a session's first read, so one session shared by two reads, or by
|
|
232
|
+
* a retry, can serve the later read from a replica that has not caught up. It reports no
|
|
233
|
+
* bookmark: the sink keeps the last value it is given, and a later replica read reports an older
|
|
234
|
+
* one, which would move the client's bookmark backwards.
|
|
235
|
+
*/
|
|
236
|
+
const buildPrimaryExec = (database: D1DatabaseLike): D1Exec => {
|
|
237
|
+
const statement = (sql: string, parameters: ReadonlyArray<unknown>) =>
|
|
238
|
+
(typeof database.withSession === "function" ? database.withSession("first-primary") : database).prepare(sql).bind(...parameters);
|
|
239
|
+
|
|
240
|
+
return retryingExec({
|
|
241
|
+
all: async (sql, parameters) => {
|
|
242
|
+
const result = await statement(sql, parameters).all<Record<string, unknown>>();
|
|
243
|
+
|
|
244
|
+
meter(sql, result.meta);
|
|
245
|
+
|
|
246
|
+
return result.results;
|
|
247
|
+
},
|
|
248
|
+
run: async (sql, parameters) => {
|
|
249
|
+
const result = await statement(sql, parameters).run();
|
|
250
|
+
|
|
251
|
+
meter(sql, result.meta);
|
|
252
|
+
},
|
|
253
|
+
});
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* The replica exec reads at the caller's bookmark, or \`"first-unconstrained"\` (lowest latency,
|
|
258
|
+
* any replica) without one. \`primary\` is the per-statement primary exec (see \`buildPrimaryExec\`).
|
|
259
|
+
*/
|
|
260
|
+
const buildExec = (database: D1DatabaseLike, bookmark?: string, onBookmark?: (bookmark: string | undefined) => void): D1Exec => {
|
|
261
|
+
const replica = buildSessionExec(database, bookmark ?? "first-unconstrained", onBookmark);
|
|
262
|
+
|
|
263
|
+
if (typeof database.withSession !== "function") {
|
|
264
|
+
return replica;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
return { ...replica, primary: buildPrimaryExec(database) };
|
|
268
|
+
};
|
|
269
|
+
|
|
228
270
|
/** Introspect \`.global()\` (D1-backed) tables for the studio's global data browser. */
|
|
229
271
|
const buildGlobalIntrospector = (database: D1DatabaseLike): GlobalIntrospector => {
|
|
230
272
|
const exec = buildExec(database);
|
|
@@ -340,12 +382,12 @@ const buildGlobalCdcApplier =
|
|
|
340
382
|
|
|
341
383
|
return request.changes.length;
|
|
342
384
|
};
|
|
343
|
-
`:"",M=e=>[...e.hasStorage?["/** `.storage(...)` declaration — one bucket (required) plus optional extra named buckets and signed-URL config. Backs `ctx.storage` AND the studio file browser. */\ninterface StorageDeclaration<Env> {\n /** The default R2 bucket binding (the bare `ctx.storage`). */\n bucket: Selector<Env, R2BucketLike>;\n /** Extra named buckets, reached via `ctx.storage.bucket(\"name\")` and the studio's bucket picker. */\n buckets?: Record<string, Selector<Env, R2BucketLike>>;\n /** Public base URL signed/public object URLs resolve against. Omit it and `ctx.storage` in a mutation, action or HTTP handler (and the studio's copy-URL) signs against the origin the request reached the worker on — no per-environment value to ship. Queries get no such fallback (a live query re-runs with no request behind it), so a query that signs URLs needs this set. */\n publicBaseUrl?: Selector<Env, string>;\n /** R2 S3-API credentials (`{ accountId, accessKeyId, secretAccessKey, bucket, jurisdiction? }`) enabling `ctx.storage.getPresignedUrl` — native S3 presigned URLs that hit R2 directly, bypassing the worker. Omit to use only the worker-signed `getSignedUrl` path. */\n s3?: Selector<Env, R2S3Credentials>;\n /** HMAC secret for signed URLs. */\n signingSecret?: Selector<Env, string>;\n}"]:[],...e.hasScheduler?["/** `.scheduler(...)` declaration — the `SchedulerDO` namespace. Backs `ctx.scheduler` AND the studio's scheduled-jobs view. The origin its callbacks dispatch back to is not declared here: the DO reads `env.LUNORA_ORIGIN_URL` at fire time, because a caller-supplied dispatch target would be an SSRF vector. */\ninterface SchedulerDeclaration<Env> {\n /** The `SchedulerDO` namespace binding (typically `env.SCHEDULER`). */\n namespace: Selector<Env, DurableObjectNamespaceLike & ShardNamespaceLike>;\n}"]:[],...e.hasGlobal?["/** `.global(...)` declaration — the D1 binding backing `.global()` tables. Backs cross-tenant `ctx.db` reads/writes AND the studio's global data browser. */\ninterface GlobalDeclaration<Env> {\n /** The D1 binding (typically `env.DB`). */\n d1: Selector<Env, D1DatabaseLike>;\n /** The worker origin used to fan reverse cross-backend relations across shards. Without it, such a relation throws a clear error. */\n origin?: Selector<Env, string>;\n}"]:[],...e.hasHyperdriveGlobal?['/** `.hyperdriveGlobal(...)` declaration — backs `.global({ backend: "hyperdrive" })` tables on a Postgres/MySQL database via Hyperdrive. Stays reactive: the writer is injected as `globalDb` and the broadcast hook drives live queries. */\ninterface HyperdriveGlobalDeclaration<Env> {\n /** The Hyperdrive engine — selects the Postgres or MySQL dialect. */\n engine: HyperdriveEngine;\n /** Build the `SqlExec` from `env` — e.g. `buildPgExec(fromPostgresJs(async () => (await import("postgres")).default(env.HYPERDRIVE.connectionString, { fetch_types: false, max: 5 })))`. Called per request, by the shard and by the stateless worker\'s admin plane, so return an exec on a connection opened for that call: never cache a driver or socket at module scope, since Workers refuse I/O across requests. */\n exec: (env: Env) => SqlExec;\n /** The worker origin used to fan reverse cross-backend relations across shards. Without it, such a relation throws a clear error. */\n origin?: Selector<Env, string>;\n}']:[],...e.hasAuth?['/** `.auth(...)` declaration — better-auth options plus the storage the adapter reads. Give it `d1` (the default) or `namespace` (a Durable Object that hosts the auth tables), never both. The builder owns the lazy build + `ensureMigrated` dance and wires `authHandler` / `resolveIdentity` / `authAdmin`. */\ninterface AuthDeclaration<Env> {\n /** The D1 binding the auth SQL adapter is wired over (via `lunoraD1Adapter`). Omit only when using `namespace`. */\n d1?: Selector<Env, unknown>;\n /** Shared secret the worker presents on the object\'s internal session route. REQUIRED with `namespace`: the binding is reachable from any worker bound to it, so the secret — not the binding — is the authorization boundary. Without it identity resolution fails closed. */\n internalSecret?: Selector<Env, string>;\n /** Name of the Durable Object instance holding the auth tables. Defaults to `"auth"`. Set it to run separate auth objects (per deployment, per tenant) off one namespace. */\n objectName?: Selector<Env, string>;\n /** The auth Durable Object namespace — the DO-backed mode. Needed for `@better-auth/scim`, which requires native transactions that D1 has none of. The object owns the auth tables, so `/api/auth/*` and identity resolution both go through it. Typed as `AuthNamespaceLike` because `createDoAuthWiring` resolves through `idFromName` + `get` and has no `getByName` fallback — both members are load-bearing here, and `ShardNamespaceLike` leaves both optional. */\n namespace?: Selector<Env, AuthNamespaceLike>;\n /** Build the better-auth options from `env` (secret, plugins, email/password, …). */\n options: (env: Env) => LunoraAuthOptions;\n}']:[]],_=e=>[...e.hasAccess?[" private accessSelector?: Selector<Env, CreateAccessResolverOptions | undefined>;"]:[],...e.hasAdminRevocations===!1?[]:[" private adminRevocationsSelector?: Selector<Env, ShardNamespaceLike>;"]," private adminToken?: Selector<Env, string>;",...e.hasAuth?[" private authDeclaration?: AuthDeclaration<Env>;"]:[]," private cdcEnabled = false;",...e.hasDeliveryAuthorization===!1?[]:[' private deliveryAuthorizationSelector?: ShardConfig["deliveryAuthorization"];']," private reactiveCacheConfig: boolean | { maxBytes?: number; maxEntries?: number } = false;",' private maxRelationKeysLimit?: ShardConfig["maxRelationKeys"];',' private observabilitySink?: ShardConfig["observability"];',' private relationExistsPushDownMode?: ShardConfig["relationExistsPushDown"];'," private readonly extendFns: ((env: Env, derived: Readonly<WorkerOptions>) => Partial<WorkerOptions>)[] = [];",...e.hasGlobal?[" private globalDeclaration?: GlobalDeclaration<Env>;"]:[],...e.hasHyperdriveGlobal?[" private hyperdriveGlobalDeclaration?: HyperdriveGlobalDeclaration<Env>;"]:[]," private httpRouterApp?: HttpRouterLike;"," private readonly routeMap: Record<string, Route> = {};",...e.hasScheduler?[" private schedulerDeclaration?: SchedulerDeclaration<Env>;"]:[],...w(e)?[" private readonly shardExtras: Partial<ShardConfig> = {};"]:[],...
|
|
385
|
+
`:"",M=e=>[...e.hasStorage?["/** `.storage(...)` declaration — one bucket (required) plus optional extra named buckets and signed-URL config. Backs `ctx.storage` AND the studio file browser. */\ninterface StorageDeclaration<Env> {\n /** The default R2 bucket binding (the bare `ctx.storage`). */\n bucket: Selector<Env, R2BucketLike>;\n /** Extra named buckets, reached via `ctx.storage.bucket(\"name\")` and the studio's bucket picker. */\n buckets?: Record<string, Selector<Env, R2BucketLike>>;\n /** Public base URL signed/public object URLs resolve against. Omit it and `ctx.storage` in a mutation, action or HTTP handler (and the studio's copy-URL) signs against the origin the request reached the worker on — no per-environment value to ship. Queries get no such fallback (a live query re-runs with no request behind it), so a query that signs URLs needs this set. */\n publicBaseUrl?: Selector<Env, string>;\n /** R2 S3-API credentials (`{ accountId, accessKeyId, secretAccessKey, bucket, jurisdiction? }`) enabling `ctx.storage.getPresignedUrl` — native S3 presigned URLs that hit R2 directly, bypassing the worker. Omit to use only the worker-signed `getSignedUrl` path. */\n s3?: Selector<Env, R2S3Credentials>;\n /** HMAC secret for signed URLs. */\n signingSecret?: Selector<Env, string>;\n}"]:[],...e.hasScheduler?["/** `.scheduler(...)` declaration — the `SchedulerDO` namespace. Backs `ctx.scheduler` AND the studio's scheduled-jobs view. The origin its callbacks dispatch back to is not declared here: the DO reads `env.LUNORA_ORIGIN_URL` at fire time, because a caller-supplied dispatch target would be an SSRF vector. */\ninterface SchedulerDeclaration<Env> {\n /** The `SchedulerDO` namespace binding (typically `env.SCHEDULER`). */\n namespace: Selector<Env, DurableObjectNamespaceLike & ShardNamespaceLike>;\n}"]:[],...e.hasGlobal?["/** `.global(...)` declaration — the D1 binding backing `.global()` tables. Backs cross-tenant `ctx.db` reads/writes AND the studio's global data browser. */\ninterface GlobalDeclaration<Env> {\n /** The D1 binding (typically `env.DB`). */\n d1: Selector<Env, D1DatabaseLike>;\n /** The worker origin used to fan reverse cross-backend relations across shards. Without it, such a relation throws a clear error. */\n origin?: Selector<Env, string>;\n}"]:[],...e.hasHyperdriveGlobal?['/** `.hyperdriveGlobal(...)` declaration — backs `.global({ backend: "hyperdrive" })` tables on a Postgres/MySQL database via Hyperdrive. Stays reactive: the writer is injected as `globalDb` and the broadcast hook drives live queries. */\ninterface HyperdriveGlobalDeclaration<Env> {\n /** The Hyperdrive engine — selects the Postgres or MySQL dialect. */\n engine: HyperdriveEngine;\n /** Build the `SqlExec` from `env` — e.g. `buildPgExec(fromPostgresJs(async () => (await import("postgres")).default(env.HYPERDRIVE.connectionString, { fetch_types: false, max: 5 })))`. Called per request, by the shard and by the stateless worker\'s admin plane, so return an exec on a connection opened for that call: never cache a driver or socket at module scope, since Workers refuse I/O across requests. */\n exec: (env: Env) => SqlExec;\n /** The worker origin used to fan reverse cross-backend relations across shards. Without it, such a relation throws a clear error. */\n origin?: Selector<Env, string>;\n}']:[],...e.hasAuth?['/** `.auth(...)` declaration — better-auth options plus the storage the adapter reads. Give it `d1` (the default) or `namespace` (a Durable Object that hosts the auth tables), never both. The builder owns the lazy build + `ensureMigrated` dance and wires `authHandler` / `resolveIdentity` / `authAdmin`. */\ninterface AuthDeclaration<Env> {\n /** The D1 binding the auth SQL adapter is wired over (via `lunoraD1Adapter`). Omit only when using `namespace`. */\n d1?: Selector<Env, unknown>;\n /** Shared secret the worker presents on the object\'s internal session route. REQUIRED with `namespace`: the binding is reachable from any worker bound to it, so the secret — not the binding — is the authorization boundary. Without it identity resolution fails closed. */\n internalSecret?: Selector<Env, string>;\n /** Name of the Durable Object instance holding the auth tables. Defaults to `"auth"`. Set it to run separate auth objects (per deployment, per tenant) off one namespace. */\n objectName?: Selector<Env, string>;\n /** The auth Durable Object namespace — the DO-backed mode. Needed for `@better-auth/scim`, which requires native transactions that D1 has none of. The object owns the auth tables, so `/api/auth/*` and identity resolution both go through it. Typed as `AuthNamespaceLike` because `createDoAuthWiring` resolves through `idFromName` + `get` and has no `getByName` fallback — both members are load-bearing here, and `ShardNamespaceLike` leaves both optional. */\n namespace?: Selector<Env, AuthNamespaceLike>;\n /** Build the better-auth options from `env` (secret, plugins, email/password, …). */\n options: (env: Env) => LunoraAuthOptions;\n}']:[]],_=e=>[...e.hasAccess?[" private accessSelector?: Selector<Env, CreateAccessResolverOptions | undefined>;"]:[],...e.hasAdminRevocations===!1?[]:[" private adminRevocationsSelector?: Selector<Env, ShardNamespaceLike>;"]," private adminToken?: Selector<Env, string>;",...e.hasAuth?[" private authDeclaration?: AuthDeclaration<Env>;"]:[]," private cdcEnabled = false;",...e.hasDeliveryAuthorization===!1?[]:[' private deliveryAuthorizationSelector?: ShardConfig["deliveryAuthorization"];']," private reactiveCacheConfig: boolean | { maxBytes?: number; maxEntries?: number } = false;",' private maxRelationKeysLimit?: ShardConfig["maxRelationKeys"];',' private observabilitySink?: ShardConfig["observability"];',' private relationExistsPushDownMode?: ShardConfig["relationExistsPushDown"];'," private readonly extendFns: ((env: Env, derived: Readonly<WorkerOptions>) => Partial<WorkerOptions>)[] = [];",...e.hasGlobal?[" private globalDeclaration?: GlobalDeclaration<Env>;"]:[],...e.hasHyperdriveGlobal?[" private hyperdriveGlobalDeclaration?: HyperdriveGlobalDeclaration<Env>;"]:[]," private httpRouterApp?: HttpRouterLike;"," private readonly routeMap: Record<string, Route> = {};",...e.hasScheduler?[" private schedulerDeclaration?: SchedulerDeclaration<Env>;"]:[],...w(e)?[" private readonly shardExtras: Partial<ShardConfig> = {};"]:[],...l(e)?[" private shardRegistrySelector?: Selector<Env, ShardNamespaceLike | ShardRegistryRpc>;"]:[]," private shardSelector?: Selector<Env, ShardNamespaceLike>;",...e.hasSourcedTables?[' private sourceClientFactory?: NonNullable<ShardConfig["sourceClient"]>;']:[],...e.hasStorage?[" private storageDeclaration?: StorageDeclaration<Env>;"]:[]],B=e=>f(e).map(({configKey:r,doc:t,method:a})=>` /** ${t} */
|
|
344
386
|
public ${a}(factory: (env: Env) => ReturnType<NonNullable<ShardConfig["${r}"]>>): this {
|
|
345
387
|
this.shardExtras.${r} = factory as NonNullable<ShardConfig["${r}"]>;
|
|
346
388
|
|
|
347
389
|
return this;
|
|
348
|
-
}`),
|
|
390
|
+
}`),W=e=>[...e.hasAccess?[" /** Wire Cloudflare Access (Zero Trust) — feeds the verified Access identity into `ctx.auth` / RLS via `resolveIdentity`. Call it with no argument when the Access policy is attached to the Worker (the identity arrives on the execution context; nothing to configure); pass `teamDomain` + `aud` for a hostname-scoped Access application, whose `Cf-Access-Jwt-Assertion` JWT is verified against your team JWKS. When `.auth(...)` is also configured, Access is composed ahead of it (Access wins when it authenticated the caller; everyone else falls through to the app session). */\n public access(selector?: Selector<Env, CreateAccessResolverOptions>): this {\n this.accessSelector = selector ?? (() => undefined);\n\n return this;\n }"]:[],` /** Bearer token gating the \`/_lunora/admin/*\` endpoints the studio calls. */
|
|
349
391
|
public admin(selector: Selector<Env, string>): this {
|
|
350
392
|
this.adminToken = selector;
|
|
351
393
|
|
|
@@ -404,7 +446,7 @@ const buildGlobalCdcApplier =
|
|
|
404
446
|
this.adminRevocationsSelector = selector;
|
|
405
447
|
|
|
406
448
|
return this;
|
|
407
|
-
}`],...
|
|
449
|
+
}`],...l(e)?[" /** The `ShardRegistryDO` namespace (typically `env.SHARD_REGISTRY`). Each shard registers itself for the `.shardBy()` tables it writes, and cross-shard export, CDC sync and migrations fan out to the shards it lists. Without it they refuse a `.shardBy()` table. */\n public shardRegistry(selector: Selector<Env, ShardNamespaceLike | ShardRegistryRpc>): this {\n this.shardRegistrySelector = selector;\n\n return this;\n }"]:[],...e.hasSourcedTables?[` /** Resolve the SQL client a \`.source(...)\` table's ingest poll reads from, given the wrangler Hyperdrive binding it named. Build it with \`@lunora/hyperdrive\`'s \`createHyperdrive\` plus your driver adapter. REQUIRED for a sourced table: without it every poll tick records "no sourceClient resolved for binding" and the table stays empty. */
|
|
408
450
|
public sourceClient(factory: (env: Env, binding: string) => ReturnType<NonNullable<ShardConfig["sourceClient"]>>): this {
|
|
409
451
|
this.sourceClientFactory = factory as NonNullable<ShardConfig["sourceClient"]>;
|
|
410
452
|
|
|
@@ -414,7 +456,7 @@ const buildGlobalCdcApplier =
|
|
|
414
456
|
this.storageDeclaration = declaration;
|
|
415
457
|
|
|
416
458
|
return this;
|
|
417
|
-
}`]:[],...
|
|
459
|
+
}`]:[],...B(e)],H=e=>{const r=a=>e.hasScheduler?`
|
|
418
460
|
...(this.schedulerDeclaration ? { scheduler: this.resolveScheduler(env) as unknown as ${a}["scheduler"] } : {}),`:"",t=[" cdc: this.cdcEnabled,"," reactiveCache: this.reactiveCacheConfig,"," ...(this.maxRelationKeysLimit === undefined ? {} : { maxRelationKeys: this.maxRelationKeysLimit }),"," ...(this.observabilitySink === undefined ? {} : { observability: this.observabilitySink }),",...e.hasDeliveryAuthorization===!1?[]:[" ...(this.deliveryAuthorizationSelector === undefined ? {} : { deliveryAuthorization: this.deliveryAuthorizationSelector }),"]," ...(this.relationExistsPushDownMode === undefined ? {} : { relationExistsPushDown: this.relationExistsPushDownMode }),",...e.hasGlobal?[` ...(this.globalDeclaration
|
|
419
461
|
? {
|
|
420
462
|
d1: (rawEnv: Record<string, unknown>, request?: { bookmark?: string; cdc?: boolean; cdcRetentionMs?: number; identity?: Record<string, unknown> | undefined; onBookmark?: (bookmark: string | undefined) => void; userId?: string | null | undefined }) => {
|
|
@@ -522,10 +564,10 @@ const buildGlobalCdcApplier =
|
|
|
522
564
|
? {
|
|
523
565
|
scheduler: (rawEnv: Record<string, unknown>) => this.resolveScheduler(rawEnv as Env),
|
|
524
566
|
}
|
|
525
|
-
: {}),`]:[],...
|
|
567
|
+
: {}),`]:[],...l(e)?[" ...(this.shardRegistrySelector ? { shardRegistry: (rawEnv: Record<string, unknown>) => this.shardRegistrySelector?.(rawEnv as Env) } : {}),"]:[],...e.hasSourcedTables?[" ...(this.sourceClientFactory === undefined ? {} : { sourceClient: this.sourceClientFactory }),"]:[],...e.hasStorage?[" ...(this.storageDeclaration ? { storage: (rawEnv: Record<string, unknown>, origin?: string) => this.resolveStorage(rawEnv as Env, origin) } : {}),"]:[],...w(e)?[" ...this.shardExtras,"]:[]];return t.length>0?`
|
|
526
568
|
${t.join(`
|
|
527
569
|
`)}
|
|
528
|
-
`:""},F=e=>e?['import * as lunoraIdentityContract from "../identity.js";']:[],U=(e,r)=>e?['import type { CreateAccessResolverOptions } from "@lunora/cloudflare-access";',`import { createAccessResolver${r?", composeResolvers":""} } from "@lunora/cloudflare-access";`]:[],z=e=>e?['import { createKvIntrospectorFromEnv } from "@lunora/bindings/kv";']:[],Q=e=>e?['import { createVectorAdminIntrospector } from "@lunora/bindings/vectors";']:[],J=e=>e?['import type { D1CtxDbOptions, D1DatabaseLike, D1Exec } from "@lunora/d1";','import { applyCdcChanges, createD1CtxDb, emitD1QueryCost, exportGlobalRows, facetGlobalColumn, importGlobalRows, listGlobalTables, readD1CdcChanges, readGlobalTablePage, retryingExec } from "@lunora/d1";']:[],K=e=>e?['import notifyConfig from "../notify.js";']:[],V=e=>k(e)?e.lazyFunctions===!0?['import type { dispatchAgentEmail } from "@lunora/agent/inbound";']:['import { dispatchAgentEmail } from "@lunora/agent/inbound";']:[],Y=e=>k(e)&&e.lazyFunctions!==!0?['import * as lunoraAgentDefinitions from "../agents.js";']:[],X=e=>{const{hasFramework:r,hasGlobal:t,hasHyperdriveGlobal:a,hasQueue:n,useUmbrella:s}=e,i=s?"lunorash/runtime":"@lunora/runtime",d=["ExecutionContextLike","HttpRouterLike","LunoraWorker","Route","ScheduledControllerLike","ShardNamespaceLike",...
|
|
570
|
+
`:""},F=e=>e?['import * as lunoraIdentityContract from "../identity.js";']:[],U=(e,r)=>e?['import type { CreateAccessResolverOptions } from "@lunora/cloudflare-access";',`import { createAccessResolver${r?", composeResolvers":""} } from "@lunora/cloudflare-access";`]:[],z=e=>e?['import { createKvIntrospectorFromEnv } from "@lunora/bindings/kv";']:[],Q=e=>e?['import { createVectorAdminIntrospector } from "@lunora/bindings/vectors";']:[],J=e=>e?['import type { D1CtxDbOptions, D1DatabaseLike, D1Exec } from "@lunora/d1";','import { applyCdcChanges, createD1CtxDb, emitD1QueryCost, exportGlobalRows, facetGlobalColumn, importGlobalRows, listGlobalTables, readD1CdcChanges, readGlobalTablePage, retryingExec } from "@lunora/d1";']:[],K=e=>e?['import notifyConfig from "../notify.js";']:[],V=e=>k(e)?e.lazyFunctions===!0?['import type { dispatchAgentEmail } from "@lunora/agent/inbound";']:['import { dispatchAgentEmail } from "@lunora/agent/inbound";']:[],Y=e=>k(e)&&e.lazyFunctions!==!0?['import * as lunoraAgentDefinitions from "../agents.js";']:[],X=e=>{const{hasFramework:r,hasGlobal:t,hasHyperdriveGlobal:a,hasQueue:n,useUmbrella:s}=e,i=s?"lunorash/runtime":"@lunora/runtime",d=["ExecutionContextLike","HttpRouterLike","LunoraWorker","Route","ScheduledControllerLike","ShardNamespaceLike",...l(e)?["ShardRegistryRpc"]:[],"WorkerOptions",...n?["TriggerTrace"]:[],...t?["GlobalIntrospector"]:[],...e.tables.length>0?["ShardingInfo"]:[],...r?["FrameworkHostHandler"]:[]],c=[...t||a?["createCrossShardRelationCapabilities"]:[],...l(e)?["createDynamicShardRegistry","createQueryCoordinator"]:[],"createWorker",...e.jurisdiction?["declareAppJurisdiction"]:[],"resolveLogArchiveFromEnv",...e.hasAuth?["memoizeIdentity"]:[],...r?["withFrameworkWorker"]:[]].join(", ");return[`import type { ${[...d].toSorted((o,u)=>o.localeCompare(u)).join(", ")} } from "${i}";`,`import { ${c} } from "${i}";`]},Z=e=>{const{hasAccess:r,hasAuth:t,hasGlobal:a,hasHyperdriveGlobal:n,hasKvIntrospector:s,hasQueue:i,hasScheduler:d,hasStorage:c,hasWorkflow:o}=e;return[...t?['import type { AuthNamespaceLike, LunoraAuth, LunoraAuthOptions } from "@lunora/auth";','import type * as LunoraAuthModule from "./authModule.js";']:[],...U(r,t),...J(a),...n?['import type { HyperdriveEngine } from "@lunora/hyperdrive/global";','import { applyHyperdriveGlobalCdc, createHyperdriveGlobalCtxDb, createHyperdriveGlobalIntrospector, exportHyperdriveGlobalRows, importHyperdriveGlobalRows, readHyperdriveGlobalCdc } from "@lunora/hyperdrive/global";','import type { SqlCtxDbOptions, SqlExec } from "@lunora/sql-store";']:[],...z(s),...Q(e.hasVectors),...d?['import type { DurableObjectNamespaceLike } from "@lunora/scheduler";','import { createScheduler } from "@lunora/scheduler";']:[],...c?['import type { R2BucketLike, R2S3Credentials, Storage } from "@lunora/storage";','import { createBucketStorage, createStorage } from "@lunora/storage";']:[],...o?['import { createWorkflowsRestClient } from "@lunora/workflow";']:[],...V(e),...X(e),"",...F(e.identity),...Y(e),...a||n?['import schema from "../schema.js";']:[],...K(e.hasNotify),'import { LUNORA_CRONS } from "./crons.js";','import { LUNORA_FUNCTIONS } from "./functions.js";',...i?['import { createQueueCaptureSink, dispatchQueueBatch, shouldCaptureQueue } from "@lunora/queue";',...e.lazyFunctions===!0?[]:['import { LUNORA_QUEUE_REGISTRY } from "./queues.js";']]:[],'import { createShardDO } from "./shard.js";',...p(e)?[`import { liveStreamRouter } from "${e.useUmbrella?"lunorash/server":"@lunora/server"}";`]:[],...e.hasVectors?['import { LUNORA_VECTOR_INDEXES } from "./vectors.js";']:[]]},ee=e=>e.jurisdiction&&e.jurisdictionPinsAuth===!0?`
|
|
529
571
|
// The schema's jurisdiction pins the auth object like every other DO.
|
|
530
572
|
jurisdiction: ${JSON.stringify(e.jurisdiction)},`:"",te=e=>typeof e=="string"?`{ mode: { kind: ${JSON.stringify(e)} } }`:`{ mode: { field: ${JSON.stringify(e.field)}, kind: "shardBy" } }`,re=e=>[...e.tables.length>0?[` const tableSharding = new Map<string, ShardingInfo>([
|
|
531
573
|
${e.tables.map(r=>` [${JSON.stringify(r.name)}, ${te(r.shardMode)}],`).join(`
|
|
@@ -533,7 +575,7 @@ ${e.tables.map(r=>` [${JSON.stringify(r.name)}, ${te(r.shardMode)}],`
|
|
|
533
575
|
]);
|
|
534
576
|
|
|
535
577
|
options.listSchemaTables = () => [...tableSharding.keys()];
|
|
536
|
-
options.resolveTableSharding = (table) => tableSharding.get(table);`]:[],...
|
|
578
|
+
options.resolveTableSharding = (table) => tableSharding.get(table);`]:[],...l(e)?[` const shardRegistry = this.shardRegistrySelector?.(env);
|
|
537
579
|
|
|
538
580
|
if (shardRegistry) {
|
|
539
581
|
options.queryCoordinator = createQueryCoordinator({ registry: createDynamicShardRegistry({ ${e.jurisdiction?`jurisdiction: ${JSON.stringify(e.jurisdiction)}, `:""}env, namespace: shardRegistry }) });
|
|
@@ -544,7 +586,7 @@ ${e.tables.map(r=>` [${JSON.stringify(r.name)}, ${te(r.shardMode)}],`
|
|
|
544
586
|
}`],S=e=>(e.liveStreamDeclarations??[]).map(r=>{if(I(r.exportName,"live stream export name"),!L.test(r.filePath))throw new Error(`@lunora/codegen: live stream file path is not safe to import: ${JSON.stringify(r.filePath)}`);return` { id: ${JSON.stringify(r.id)}, load: () => import("../${r.filePath}.js").then((m) => m.${r.exportName}) },`}),ne=e=>p(e)?[" httpRouter: liveStreamRouter([",...S(e)," ], this.httpRouterApp),"]:[" ...(this.httpRouterApp ? { httpRouter: this.httpRouterApp } : {}),"],se=e=>p(e)?[" liveStreamRoutes: [",...(e.liveStreamDeclarations??[]).flatMap(r=>[` ${JSON.stringify(`GET /live/${r.id}/connect`)},`,` ${JSON.stringify(`POST /live/${r.id}/control`)},`])," ],"]:[],oe=e=>p(e)?`liveStreamRouter([
|
|
545
587
|
${S(e).join(`
|
|
546
588
|
`)}
|
|
547
|
-
], host)`:"host",ie=e=>e.agentWorkflows===void 0?[]:[` options.agentWorkflows = ${JSON.stringify(e.agentWorkflows)};`],
|
|
589
|
+
], host)`:"host",ie=e=>e.agentWorkflows===void 0?[]:[` options.agentWorkflows = ${JSON.stringify(e.agentWorkflows)};`],ce=e=>[...re(e),...e.hasAdminRevocations===!1?[]:ae,...e.hasScheduler?[` if (this.schedulerDeclaration) {
|
|
548
590
|
options.schedulerDO = this.schedulerDeclaration.namespace(env);
|
|
549
591
|
}`]:[],...e.hasWorkflow?[` options.workflowsClient = (workflowEnv) => {
|
|
550
592
|
const source = workflowEnv as Record<string, unknown>;
|
|
@@ -813,7 +855,7 @@ ${S(e).join(`
|
|
|
813
855
|
}`]:[],...ie(e),...e.voiceAgents&&e.voiceAgents.length>0?[` options.voiceAgents = {
|
|
814
856
|
${e.voiceAgents.map(r=>` ${JSON.stringify(r.exportName)}: (env as Record<string, unknown>)[${JSON.stringify(r.bindingName)}] as ShardNamespaceLike,`).join(`
|
|
815
857
|
`)}
|
|
816
|
-
};`]:[]],
|
|
858
|
+
};`]:[]],le=e=>e.hasQueue?[` queue: ${e.lazyFunctions===!0?"async ":""}(batch: unknown, queueEnv: unknown, _context: ExecutionContextLike, trigger: TriggerTrace, ${e.liveStreams?"queueLive":"_live"}: Parameters<typeof dispatchQueueBatch>[2]["live"], queueFetch: Parameters<typeof dispatchQueueBatch>[2]["fetchImpl"]): Promise<void> =>`,` dispatchQueueBatch(batch as Parameters<typeof dispatchQueueBatch>[0], ${e.lazyFunctions===!0?'(await import("./queues.js")).LUNORA_QUEUE_REGISTRY':"LUNORA_QUEUE_REGISTRY"}, {`," capture: shouldCaptureQueue(queueEnv as Record<string, unknown>)",` ? createQueueCaptureSink(queueEnv as Record<string, unknown>${e.jurisdiction?`, { jurisdiction: ${JSON.stringify(e.jurisdiction)} }`:""})`," : undefined,"," env: queueEnv as Record<string, unknown>,"," holdSeconds: trigger.holdSeconds,"," traceparent: trigger.traceparent,"," fetchImpl: queueFetch,",...e.liveStreams?[" live: queueLive,"]:[]," }),"]:[],de=e=>[' aiChatBinding: (env as Record<string, unknown>)["AI"] as WorkerOptions["aiChatBinding"],',' aiOptInLevel: (env as Record<string, unknown>)["LUNORA_AI_OPT_IN"] as WorkerOptions["aiOptInLevel"],'," cronJobs: LUNORA_CRONS,"," functions: LUNORA_FUNCTIONS,",...e.identity?[` identity: lunoraIdentityContract.${e.identity.exportName},`]:[],...e.jurisdiction?[` jurisdiction: ${JSON.stringify(e.jurisdiction)},`]:[],...e.wantsArchitecture?[" architecture: deferred.architecture,"]:[],...e.wantsOpenApi?[" openApiSpec: deferred.openApiSpec,"]:[],...e.wantsOpenRpc?[" openRpcSpec: deferred.openRpcSpec,"]:[],...le(e),...ne(e),...se(e)," routes: this.routeMap,",...e.liveStreamsWithheld?[" liveStreams: false,"]:[]," shardDO: this.shardSelector?.(env) ?? (undefined as unknown as ShardNamespaceLike),"],he=e=>e?`
|
|
817
859
|
/** The identity memo per \`env\` object, owned by one assembled worker. */
|
|
818
860
|
type IdentityMemoStore = WeakMap<object, ReturnType<typeof memoizeIdentity>>;
|
|
819
861
|
`:"",E=e=>e.hasAuth||e.wantsArchitecture||e.wantsOpenApi||e.wantsOpenRpc,ue=e=>{if(!E(e))return"";const t=[[e.wantsArchitecture,"architecture","unknown",'(await import("./architecture.js")).architecture'],[e.hasAuth,"auth","typeof LunoraAuthModule",'await import("./authModule.js")'],[e.wantsOpenApi,"openApiSpec","unknown",'(await import("./openapi.js")).openApiSpec'],[e.wantsOpenRpc,"openRpcSpec","unknown",'(await import("./openrpc.js")).openRpcSpec']].filter(([a])=>a).map(([,a,n,s])=>[a,n,s]);return`
|
|
@@ -858,7 +900,7 @@ ${t(" ")}
|
|
|
858
900
|
return agentEmail(message, rawEnv, context);
|
|
859
901
|
};
|
|
860
902
|
|
|
861
|
-
`},ge=e=>[...e.hasAuth?["AuthDeclaration"]:[],"ComposedApp",...e.hasGlobal?["GlobalDeclaration"]:[],"LunoraConfig",...e.hasScheduler?["SchedulerDeclaration"]:[],"Selector",...e.hasStorage?["StorageDeclaration"]:[]].toSorted((r,t)=>r.localeCompare(t)).join(", "),ke=e=>{const r=(e.hasVectors??!0)&&(e.vectorIndexCount??0)>0,t={...e,hasVectors:r},{hasAuth:a}=t,n=M(t),s=
|
|
903
|
+
`},ge=e=>[...e.hasAuth?["AuthDeclaration"]:[],"ComposedApp",...e.hasGlobal?["GlobalDeclaration"]:[],"LunoraConfig",...e.hasScheduler?["SchedulerDeclaration"]:[],"Selector",...e.hasStorage?["StorageDeclaration"]:[]].toSorted((r,t)=>r.localeCompare(t)).join(", "),ke=e=>{const r=(e.hasVectors??!0)&&(e.vectorIndexCount??0)>0,t={...e,hasVectors:r},{hasAuth:a}=t,n=M(t),s=ce(t),i=a?` let auth: LunoraAuth | null = null;
|
|
862
904
|
let authInit: Promise<void> | null = null;
|
|
863
905
|
// One memo per env for THIS assembled worker: every worker it builds reuses it, but a second
|
|
864
906
|
// \`assemble()\` has its own auth closure and must not share.
|
|
@@ -929,7 +971,7 @@ ${t(" ")}
|
|
|
929
971
|
return false;
|
|
930
972
|
},
|
|
931
973
|
);
|
|
932
|
-
`:"",{asyncIfDeferred:
|
|
974
|
+
`:"",{asyncIfDeferred:c,deferredArgument:o,deferredParameter:u,loadDeferredLine:h}=me(t),{ensureAuthCall:R,ensureRawAuthCall:D,eventWorker:m,eventWorkerLine:b}=pe(a,o),g=`${a?"() => auth, identityMemos":"() => null"}${o}`,A=`${a?"getAuth: () => LunoraAuth | null, identityMemos: IdentityMemoStore":"_getAuth: () => null"}${u}`,v=`env: Env${u}`,x=t.hasFramework?` const buildWorker = (${v}): LunoraWorker =>
|
|
933
975
|
host ? withFrameworkWorker(${oe(t)}, (hostEnv) => this.buildWorkerOptions(hostEnv as Env, ${g})) : createWorker(this.buildWorkerOptions(env, ${g}));`:` const buildWorker = (${v}): LunoraWorker => createWorker(this.buildWorkerOptions(env, ${g}));`,C=t.hasFramework?"host?: FrameworkHostHandler":"",O=be(t),T=` /** Materialise the standalone Cloudflare worker + \`ShardDO\` class. */
|
|
934
976
|
public build(): ComposedApp {
|
|
935
977
|
return this.assemble();
|
|
@@ -971,7 +1013,7 @@ ${_(t).join(`
|
|
|
971
1013
|
|
|
972
1014
|
private emailHandler?: (env: Env) => (message: unknown, env: unknown, context: ExecutionContextLike) => Promise<void>;
|
|
973
1015
|
|
|
974
|
-
${
|
|
1016
|
+
${W(t).join(`
|
|
975
1017
|
|
|
976
1018
|
`)}
|
|
977
1019
|
|
|
@@ -1000,7 +1042,7 @@ ${x}
|
|
|
1000
1042
|
|
|
1001
1043
|
return ${m}.scheduled(controller, rawEnv, context);
|
|
1002
1044
|
},
|
|
1003
|
-
serverQuery: ${
|
|
1045
|
+
serverQuery: ${c}(request, rawEnv, reference, args, options) => {${h}${D}
|
|
1004
1046
|
worker ??= buildWorker(rawEnv as Env${o});
|
|
1005
1047
|
|
|
1006
1048
|
return worker.serverQuery(request, rawEnv, reference, args, options);
|
|
@@ -1022,7 +1064,7 @@ ${t.hasFramework?`
|
|
|
1022
1064
|
// of its own the host's is the only one there is — forward to it rather than
|
|
1023
1065
|
// dropping the entry.
|
|
1024
1066
|
if (!composed.email && host && typeof host === "object" && typeof host.email === "function") {
|
|
1025
|
-
composed.email = ${
|
|
1067
|
+
composed.email = ${c}(message, rawEnv, context) => {${h}${b}
|
|
1026
1068
|
|
|
1027
1069
|
return ${m}.email?.(message, rawEnv, context) ?? Promise.resolve();
|
|
1028
1070
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lunora/codegen",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.396",
|
|
4
4
|
"description": "Code generator for Lunora: emits _generated/{api,server,dataModel}.ts from your schema",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|
|
@@ -50,13 +50,13 @@
|
|
|
50
50
|
"access": "public"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@lunora/advisor": "1.0.0-alpha.
|
|
54
|
-
"@lunora/agent": "1.0.0-alpha.
|
|
53
|
+
"@lunora/advisor": "1.0.0-alpha.286",
|
|
54
|
+
"@lunora/agent": "1.0.0-alpha.280",
|
|
55
55
|
"@lunora/container": "1.0.0-alpha.108",
|
|
56
56
|
"@lunora/errors": ">=1.0.0-alpha.51 <2.0.0-0",
|
|
57
|
-
"@lunora/platform": "1.0.0-alpha.
|
|
58
|
-
"@lunora/queue": "1.0.0-alpha.
|
|
59
|
-
"@lunora/scheduler": "1.0.0-alpha.
|
|
57
|
+
"@lunora/platform": "1.0.0-alpha.80",
|
|
58
|
+
"@lunora/queue": "1.0.0-alpha.143",
|
|
59
|
+
"@lunora/scheduler": "1.0.0-alpha.168",
|
|
60
60
|
"@lunora/values": "1.0.0-alpha.94",
|
|
61
61
|
"@lunora/workflow": "1.0.0-alpha.110",
|
|
62
62
|
"@visulima/fs": "7.0.0",
|