@lunora/codegen 1.0.0-alpha.431 → 1.0.0-alpha.432

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 i,serializeSchemaSnapshot as a}from"./packem_shared/SCHEMA_SNAPSHOT_VERSION-DTLoSaNn.mjs";import{formatAdvisories as d,lintSchema as f,toAdvisorContext as m}from"./packem_shared/formatAdvisories-Bue5tbp6.mjs";import{describeErrorLevelFindings as n,errorAdvisoryNames as c,errorPlatformDiagnosticNames as l,sortedUniqueNames as S}from"./packem_shared/describeErrorLevelFindings-DlkgCw8a.mjs";import{CAPABILITY_PROBES as E}from"./packem_shared/CAPABILITY_PROBES-DCzOjTN7.mjs";import{COMPANION_BINDING as u,COMPANION_SERVICE_NAME as N}from"./packem_shared/COMPANION_BINDING-Da_v9XpC.mjs";import{CodegenDiagnosticError as g,diagnosticAt as C}from"./packem_shared/CodegenDiagnosticError-BUXlG3P-.mjs";import{AGENTS_FILENAME as I,discoverAgents as _}from"./packem_shared/AGENTS_FILENAME-BSW65Q9R.mjs";import{isTestPath as L,listLunoraSourceFiles as M}from"./packem_shared/isTestPath-DJeZ18i9.mjs";import{default as F}from"./packem_shared/discoverAuthApiCalls-DcvsgL5u.mjs";import{CONTAINERS_FILENAME as P,discoverContainers as D}from"./packem_shared/CONTAINERS_FILENAME-Dy3qWGfI.mjs";import{default as b}from"./packem_shared/discoverCrons-MpIC14pg.mjs";import{ENV_FILENAME as U}from"./packem_shared/ENV_FILENAME-DFx_jlpa.mjs";import{capabilitiesUsedBy as H,createTargetScope as j,foldCapabilitySignals as V,mayReadCapabilityContext as k,sourceCapabilitySignals as W}from"./packem_shared/capabilitiesUsedBy-BcDkRoOu.mjs";import{FLAGS_FILENAME as K,discoverFlags as Q}from"./packem_shared/FLAGS_FILENAME-CDaIBL6L.mjs";import{d as q}from"./packem_shared/index-BwLaIVqA.mjs";import{default as J}from"./packem_shared/discoverHttpRoutes-BtMgsfzG.mjs";import{default as Z}from"./packem_shared/discoverHyperdriveCalls-B--Nvx36.mjs";import{default as ee}from"./packem_shared/discoverInserts-Dx7Lxey3.mjs";import{d as oe}from"./packem_shared/index-CQuAXbal.mjs";import{default as ie}from"./packem_shared/discoverMigrations-DaBdK1Bv.mjs";import{MUTATORS_FILENAME as se,discoverMutators as de}from"./packem_shared/MUTATORS_FILENAME-SLAN2VXq.mjs";import{default as me}from"./packem_shared/discoverNondeterministicCalls-MeKjo_UX.mjs";import{ALL_NOTIFY_CHANNELS as ne,NOTIFY_FILENAME as ce,discoverNotifyCalls as le,discoverNotifyChannels as Se,discoverNotifyConfig as xe}from"./packem_shared/ALL_NOTIFY_CHANNELS-DI0zmZGs.mjs";import{default as Ae}from"./packem_shared/readPackageDependencies-RHhGiz0k.mjs";import{default as Ne}from"./packem_shared/discoverQueries-BlhMsXuk.mjs";import{QUEUES_FILENAME as ge,discoverQueues as Ce}from"./packem_shared/QUEUES_FILENAME-CVkpGqoY.mjs";import{default as Ie}from"./packem_shared/discoverR2sqlCalls-DHvclvkv.mjs";import{default as Re}from"./packem_shared/discoverRlsProcedures-CUfhUqfY.mjs";import{default as Me}from"./packem_shared/discoverRlsMetadata-CO-pRHOx.mjs";import{discoverSandboxUsage as Fe}from"./packem_shared/discoverSandboxUsage-CdrJNRFd.mjs";import{default as Pe}from"./packem_shared/discoverSchema-CL9PLdOu.mjs";import{companionServiceBinding as ye,readBoundServiceBindings as be,readDevServiceBindings as Ge,readServiceBindings as Ue,resolveServiceBindings as Be}from"./packem_shared/companionServiceBinding-BZjm486n.mjs";import{SHAPES_FILENAME as je,discoverShapes as Ve}from"./packem_shared/SHAPES_FILENAME-Cf4sum4C.mjs";import{default as We}from"./packem_shared/discoverStorageRulesMetadata-D_pYyr1i.mjs";import{WORKFLOWS_FILENAME as Ke,discoverWorkflows as Qe}from"./packem_shared/WORKFLOWS_FILENAME-Dtxo_XBw.mjs";import{emitApp as qe}from"./packem_shared/emitApp-xbr1VKI7.mjs";import{isD1GlobalTable as Je,isHyperdriveGlobalTable as Xe}from"./packem_shared/isD1GlobalTable-udvHAAzD.mjs";import{buildOpenApiDocument as $e,emitOpenApi as er,emitOpenApiModule as rr}from"./packem_shared/buildOpenApiDocument-C3zlve6K.mjs";import{OPENRPC_VERSION as tr,buildOpenRpcDocument as ir,emitOpenRpc as ar,emitOpenRpcModule as sr}from"./packem_shared/OPENRPC_VERSION-DkWde9eh.mjs";import{DEFAULT_TARGET as fr,platformMatrixIds as mr,readProjectTarget as pr,resolveCodegenTarget as nr}from"./packem_shared/DEFAULT_TARGET-CnglMKg_.mjs";import{b as lr,r as Sr,c as xr,d as Er}from"./packem_shared/project-config-file-DR7xrrNB.mjs";import{PROJECT_CONFIG_FILENAMES as ur,findCodegenConfigFile as Nr,findProjectConfigFile as vr,projectConfigCandidatePaths as gr}from"./packem_shared/PROJECT_CONFIG_FILENAMES-CLfsyvjA.mjs";import{SCHEMA_SNAPSHOT_FILENAME as Or,runCodegen as Ir}from"./packem_shared/SCHEMA_SNAPSHOT_FILENAME-CGC3sVJb.mjs";import{SchemaSnapshotParseError as Rr,buildSchemaSnapshot as Lr,evaluateSchemaDrift as Mr,indexReferencesOf as Tr,parseSchemaSnapshot as Fr}from"./packem_shared/SchemaSnapshotParseError-CV7mmuPi.mjs";import{default as Pr}from"./packem_shared/fingerprintSchemaSources-BqPD3mw0.mjs";import{schemaFromIr as yr}from"./packem_shared/schemaFromIr-CByOxuZb.mjs";import{LUNORA_ERROR_CODES as Gr,validatorIrToJsonSchema as Ur}from"./packem_shared/LUNORA_ERROR_CODES-D7AVT7qF.mjs";import{SDK_LANGUAGES as Hr,SDK_TARGETS as jr,generateSdk as Vr}from"./sdk/index.mjs";import{redact as Wr,secretKindOf as zr}from"./packem_shared/redact-Cy14LEnc.mjs";import{default as Qr}from"./packem_shared/emitDrizzleSchema-lRoq3OJs.mjs";import{e as qr}from"./packem_shared/server-Dfxmm5Zw.mjs";import{e as Jr}from"./packem_shared/shard-WWiw5i1B.mjs";import{G as Zr}from"./packem_shared/shared-Cn7dMQ_u.mjs";import{MESSAGE_SOLUTIONS as eo,findSolutionByMessage as ro}from"@lunora/errors";import{createCodegenProject as to,findTsconfig as io,refreshCodegenProject as ao,tsconfigFingerprint as so}from"./packem_shared/createCodegenProject-C4XuJSap.mjs";import{t as mo,u as po,v as no}from"./packem_shared/shard-runtime-G5mZQjY0.mjs";import{emitApi as lo,emitCollections as So,emitInternalApi as xo}from"./packem_shared/emitApi-lwadq5G7.mjs";import{emitCrons as Ao,emitScheduler as uo,emitVectors as No,emitWranglerCronTriggers as vo}from"./packem_shared/emitCrons-CCRKs482.mjs";import{emitDataModel as Co}from"./packem_shared/emitDataModel-Cen7mAmM.mjs";import{emitFunctions as Io}from"./packem_shared/emitFunctions-ppMX7E3X.mjs";import{isTypedSchema as Ro}from"./packem_shared/isTypedSchema-CDv3pJB6.mjs";const e="0.0.0";export{I as AGENTS_FILENAME,ne as ALL_NOTIFY_CHANNELS,E as CAPABILITY_PROBES,u as COMPANION_BINDING,N as COMPANION_SERVICE_NAME,P as CONTAINERS_FILENAME,g as CodegenDiagnosticError,fr as DEFAULT_TARGET,U as ENV_FILENAME,K as FLAGS_FILENAME,Zr as GENERATED_HEADER,Gr as LUNORA_ERROR_CODES,eo as LUNORA_SOLUTION_RULES,se as MUTATORS_FILENAME,ce as NOTIFY_FILENAME,tr as OPENRPC_VERSION,ur as PROJECT_CONFIG_FILENAMES,ge as QUEUES_FILENAME,Or as SCHEMA_SNAPSHOT_FILENAME,t as SCHEMA_SNAPSHOT_VERSION,Hr as SDK_LANGUAGES,jr as SDK_TARGETS,je as SHAPES_FILENAME,Rr as SchemaSnapshotParseError,e as VERSION,Ke as WORKFLOWS_FILENAME,$e as buildOpenApiDocument,ir as buildOpenRpcDocument,Lr as buildSchemaSnapshot,H as capabilitiesUsedBy,ye as companionServiceBinding,to as createCodegenProject,j as createTargetScope,n as describeErrorLevelFindings,C as diagnosticAt,i as diffSchemaSnapshots,_ as discoverAgents,F as discoverAuthApiCalls,D as discoverContainers,b as discoverCrons,Q as discoverFlags,q as discoverFunctions,J as discoverHttpRoutes,Z as discoverHyperdriveCalls,ee as discoverInserts,oe as discoverMaskProcedures,ie as discoverMigrations,de as discoverMutators,me as discoverNondeterministicCalls,le as discoverNotifyCalls,Se as discoverNotifyChannels,xe as discoverNotifyConfig,Ne as discoverQueries,Ce as discoverQueues,Ie as discoverR2sqlCalls,Me as discoverRlsMetadata,Re as discoverRlsProcedures,Fe as discoverSandboxUsage,Pe as discoverSchema,Ve as discoverShapes,We as discoverStorageRulesMetadata,Qe as discoverWorkflows,mo as emitAgents,lo as emitApi,qe as emitApp,So as emitCollections,po as emitContainers,Ao as emitCrons,Co as emitDataModel,Qr as emitDrizzleSchema,Io as emitFunctions,xo as emitInternalApi,er as emitOpenApi,rr as emitOpenApiModule,ar as emitOpenRpc,sr as emitOpenRpcModule,uo as emitScheduler,qr as emitServer,Jr as emitShard,No as emitVectors,no as emitWorkflows,vo as emitWranglerCronTriggers,c as errorAdvisoryNames,l as errorPlatformDiagnosticNames,Mr as evaluateSchemaDrift,Nr as findCodegenConfigFile,ro as findLunoraSolution,vr as findProjectConfigFile,io as findTsconfig,Pr as fingerprintSchemaSources,V as foldCapabilitySignals,d as formatAdvisories,Vr as generateSdk,Tr as indexReferencesOf,Je as isD1GlobalTable,Xe as isHyperdriveGlobalTable,L as isTestPath,Ro as isTypedSchema,f as lintSchema,M as listLunoraSourceFiles,lr as loadProjectConfig,k as mayReadCapabilityContext,Fr as parseSchemaSnapshot,mr as platformMatrixIds,gr as projectConfigCandidatePaths,be as readBoundServiceBindings,Ge as readDevServiceBindings,Ae as readPackageDependencies,Sr as readProjectConfigLiterals,xr as readProjectLazyFunctions,Er as readProjectSecurityHeaders,pr as readProjectTarget,Ue as readServiceBindings,Wr as redact,ao as refreshCodegenProject,nr as resolveCodegenTarget,Be as resolveServiceBindings,Ir as runCodegen,yr as schemaFromIr,zr as secretKindOf,a as serializeSchemaSnapshot,S as sortedUniqueNames,W as sourceCapabilitySignals,m as toAdvisorContext,so as tsconfigFingerprint,Ur as validatorIrToJsonSchema};
1
+ import{SCHEMA_SNAPSHOT_VERSION as t,diffSchemaSnapshots as i,serializeSchemaSnapshot as a}from"./packem_shared/SCHEMA_SNAPSHOT_VERSION-DTLoSaNn.mjs";import{formatAdvisories as d,lintSchema as f,toAdvisorContext as m}from"./packem_shared/formatAdvisories-Bue5tbp6.mjs";import{describeErrorLevelFindings as n,errorAdvisoryNames as c,errorPlatformDiagnosticNames as l,sortedUniqueNames as S}from"./packem_shared/describeErrorLevelFindings-DlkgCw8a.mjs";import{CAPABILITY_PROBES as E}from"./packem_shared/CAPABILITY_PROBES-DCzOjTN7.mjs";import{COMPANION_BINDING as u,COMPANION_SERVICE_NAME as N}from"./packem_shared/COMPANION_BINDING-Da_v9XpC.mjs";import{CodegenDiagnosticError as g,diagnosticAt as C}from"./packem_shared/CodegenDiagnosticError-BUXlG3P-.mjs";import{AGENTS_FILENAME as I,discoverAgents as _}from"./packem_shared/AGENTS_FILENAME-BSW65Q9R.mjs";import{isTestPath as L,listLunoraSourceFiles as M}from"./packem_shared/isTestPath-DJeZ18i9.mjs";import{default as F}from"./packem_shared/discoverAuthApiCalls-DcvsgL5u.mjs";import{CONTAINERS_FILENAME as P,discoverContainers as D}from"./packem_shared/CONTAINERS_FILENAME-Dy3qWGfI.mjs";import{default as b}from"./packem_shared/discoverCrons-MpIC14pg.mjs";import{ENV_FILENAME as U}from"./packem_shared/ENV_FILENAME-DFx_jlpa.mjs";import{capabilitiesUsedBy as H,createTargetScope as j,foldCapabilitySignals as V,mayReadCapabilityContext as k,sourceCapabilitySignals as W}from"./packem_shared/capabilitiesUsedBy-BcDkRoOu.mjs";import{FLAGS_FILENAME as K,discoverFlags as Q}from"./packem_shared/FLAGS_FILENAME-CDaIBL6L.mjs";import{d as q}from"./packem_shared/index-BwLaIVqA.mjs";import{default as J}from"./packem_shared/discoverHttpRoutes-BtMgsfzG.mjs";import{default as Z}from"./packem_shared/discoverHyperdriveCalls-B--Nvx36.mjs";import{default as ee}from"./packem_shared/discoverInserts-Dx7Lxey3.mjs";import{d as oe}from"./packem_shared/index-CQuAXbal.mjs";import{default as ie}from"./packem_shared/discoverMigrations-DaBdK1Bv.mjs";import{MUTATORS_FILENAME as se,discoverMutators as de}from"./packem_shared/MUTATORS_FILENAME-SLAN2VXq.mjs";import{default as me}from"./packem_shared/discoverNondeterministicCalls-MeKjo_UX.mjs";import{ALL_NOTIFY_CHANNELS as ne,NOTIFY_FILENAME as ce,discoverNotifyCalls as le,discoverNotifyChannels as Se,discoverNotifyConfig as xe}from"./packem_shared/ALL_NOTIFY_CHANNELS-DI0zmZGs.mjs";import{default as Ae}from"./packem_shared/readPackageDependencies-RHhGiz0k.mjs";import{default as Ne}from"./packem_shared/discoverQueries-BlhMsXuk.mjs";import{QUEUES_FILENAME as ge,discoverQueues as Ce}from"./packem_shared/QUEUES_FILENAME-CVkpGqoY.mjs";import{default as Ie}from"./packem_shared/discoverR2sqlCalls-DHvclvkv.mjs";import{default as Re}from"./packem_shared/discoverRlsProcedures-CUfhUqfY.mjs";import{default as Me}from"./packem_shared/discoverRlsMetadata-CO-pRHOx.mjs";import{discoverSandboxUsage as Fe}from"./packem_shared/discoverSandboxUsage-CdrJNRFd.mjs";import{default as Pe}from"./packem_shared/discoverSchema-CL9PLdOu.mjs";import{companionServiceBinding as ye,readBoundServiceBindings as be,readDevServiceBindings as Ge,readServiceBindings as Ue,resolveServiceBindings as Be}from"./packem_shared/companionServiceBinding-BZjm486n.mjs";import{SHAPES_FILENAME as je,discoverShapes as Ve}from"./packem_shared/SHAPES_FILENAME-Cf4sum4C.mjs";import{default as We}from"./packem_shared/discoverStorageRulesMetadata-D_pYyr1i.mjs";import{WORKFLOWS_FILENAME as Ke,discoverWorkflows as Qe}from"./packem_shared/WORKFLOWS_FILENAME-Dtxo_XBw.mjs";import{emitApp as qe}from"./packem_shared/emitApp-a6xtVrpx.mjs";import{isD1GlobalTable as Je,isHyperdriveGlobalTable as Xe}from"./packem_shared/isD1GlobalTable-udvHAAzD.mjs";import{buildOpenApiDocument as $e,emitOpenApi as er,emitOpenApiModule as rr}from"./packem_shared/buildOpenApiDocument-C3zlve6K.mjs";import{OPENRPC_VERSION as tr,buildOpenRpcDocument as ir,emitOpenRpc as ar,emitOpenRpcModule as sr}from"./packem_shared/OPENRPC_VERSION-DkWde9eh.mjs";import{DEFAULT_TARGET as fr,platformMatrixIds as mr,readProjectTarget as pr,resolveCodegenTarget as nr}from"./packem_shared/DEFAULT_TARGET-CnglMKg_.mjs";import{b as lr,r as Sr,c as xr,d as Er}from"./packem_shared/project-config-file-DR7xrrNB.mjs";import{PROJECT_CONFIG_FILENAMES as ur,findCodegenConfigFile as Nr,findProjectConfigFile as vr,projectConfigCandidatePaths as gr}from"./packem_shared/PROJECT_CONFIG_FILENAMES-CLfsyvjA.mjs";import{SCHEMA_SNAPSHOT_FILENAME as Or,runCodegen as Ir}from"./packem_shared/SCHEMA_SNAPSHOT_FILENAME-DhUTli8c.mjs";import{SchemaSnapshotParseError as Rr,buildSchemaSnapshot as Lr,evaluateSchemaDrift as Mr,indexReferencesOf as Tr,parseSchemaSnapshot as Fr}from"./packem_shared/SchemaSnapshotParseError-CV7mmuPi.mjs";import{default as Pr}from"./packem_shared/fingerprintSchemaSources-BqPD3mw0.mjs";import{schemaFromIr as yr}from"./packem_shared/schemaFromIr-CByOxuZb.mjs";import{LUNORA_ERROR_CODES as Gr,validatorIrToJsonSchema as Ur}from"./packem_shared/LUNORA_ERROR_CODES-D7AVT7qF.mjs";import{SDK_LANGUAGES as Hr,SDK_TARGETS as jr,generateSdk as Vr}from"./sdk/index.mjs";import{redact as Wr,secretKindOf as zr}from"./packem_shared/redact-Cy14LEnc.mjs";import{default as Qr}from"./packem_shared/emitDrizzleSchema-lRoq3OJs.mjs";import{e as qr}from"./packem_shared/server-Dfxmm5Zw.mjs";import{e as Jr}from"./packem_shared/shard-DcWZeVPb.mjs";import{G as Zr}from"./packem_shared/shared-Cn7dMQ_u.mjs";import{MESSAGE_SOLUTIONS as eo,findSolutionByMessage as ro}from"@lunora/errors";import{createCodegenProject as to,findTsconfig as io,refreshCodegenProject as ao,tsconfigFingerprint as so}from"./packem_shared/createCodegenProject-C4XuJSap.mjs";import{t as mo,u as po,v as no}from"./packem_shared/shard-runtime-G5mZQjY0.mjs";import{emitApi as lo,emitCollections as So,emitInternalApi as xo}from"./packem_shared/emitApi-lwadq5G7.mjs";import{emitCrons as Ao,emitScheduler as uo,emitVectors as No,emitWranglerCronTriggers as vo}from"./packem_shared/emitCrons-CCRKs482.mjs";import{emitDataModel as Co}from"./packem_shared/emitDataModel-Cen7mAmM.mjs";import{emitFunctions as Io}from"./packem_shared/emitFunctions-ppMX7E3X.mjs";import{isTypedSchema as Ro}from"./packem_shared/isTypedSchema-CDv3pJB6.mjs";const e="0.0.0";export{I as AGENTS_FILENAME,ne as ALL_NOTIFY_CHANNELS,E as CAPABILITY_PROBES,u as COMPANION_BINDING,N as COMPANION_SERVICE_NAME,P as CONTAINERS_FILENAME,g as CodegenDiagnosticError,fr as DEFAULT_TARGET,U as ENV_FILENAME,K as FLAGS_FILENAME,Zr as GENERATED_HEADER,Gr as LUNORA_ERROR_CODES,eo as LUNORA_SOLUTION_RULES,se as MUTATORS_FILENAME,ce as NOTIFY_FILENAME,tr as OPENRPC_VERSION,ur as PROJECT_CONFIG_FILENAMES,ge as QUEUES_FILENAME,Or as SCHEMA_SNAPSHOT_FILENAME,t as SCHEMA_SNAPSHOT_VERSION,Hr as SDK_LANGUAGES,jr as SDK_TARGETS,je as SHAPES_FILENAME,Rr as SchemaSnapshotParseError,e as VERSION,Ke as WORKFLOWS_FILENAME,$e as buildOpenApiDocument,ir as buildOpenRpcDocument,Lr as buildSchemaSnapshot,H as capabilitiesUsedBy,ye as companionServiceBinding,to as createCodegenProject,j as createTargetScope,n as describeErrorLevelFindings,C as diagnosticAt,i as diffSchemaSnapshots,_ as discoverAgents,F as discoverAuthApiCalls,D as discoverContainers,b as discoverCrons,Q as discoverFlags,q as discoverFunctions,J as discoverHttpRoutes,Z as discoverHyperdriveCalls,ee as discoverInserts,oe as discoverMaskProcedures,ie as discoverMigrations,de as discoverMutators,me as discoverNondeterministicCalls,le as discoverNotifyCalls,Se as discoverNotifyChannels,xe as discoverNotifyConfig,Ne as discoverQueries,Ce as discoverQueues,Ie as discoverR2sqlCalls,Me as discoverRlsMetadata,Re as discoverRlsProcedures,Fe as discoverSandboxUsage,Pe as discoverSchema,Ve as discoverShapes,We as discoverStorageRulesMetadata,Qe as discoverWorkflows,mo as emitAgents,lo as emitApi,qe as emitApp,So as emitCollections,po as emitContainers,Ao as emitCrons,Co as emitDataModel,Qr as emitDrizzleSchema,Io as emitFunctions,xo as emitInternalApi,er as emitOpenApi,rr as emitOpenApiModule,ar as emitOpenRpc,sr as emitOpenRpcModule,uo as emitScheduler,qr as emitServer,Jr as emitShard,No as emitVectors,no as emitWorkflows,vo as emitWranglerCronTriggers,c as errorAdvisoryNames,l as errorPlatformDiagnosticNames,Mr as evaluateSchemaDrift,Nr as findCodegenConfigFile,ro as findLunoraSolution,vr as findProjectConfigFile,io as findTsconfig,Pr as fingerprintSchemaSources,V as foldCapabilitySignals,d as formatAdvisories,Vr as generateSdk,Tr as indexReferencesOf,Je as isD1GlobalTable,Xe as isHyperdriveGlobalTable,L as isTestPath,Ro as isTypedSchema,f as lintSchema,M as listLunoraSourceFiles,lr as loadProjectConfig,k as mayReadCapabilityContext,Fr as parseSchemaSnapshot,mr as platformMatrixIds,gr as projectConfigCandidatePaths,be as readBoundServiceBindings,Ge as readDevServiceBindings,Ae as readPackageDependencies,Sr as readProjectConfigLiterals,xr as readProjectLazyFunctions,Er as readProjectSecurityHeaders,pr as readProjectTarget,Ue as readServiceBindings,Wr as redact,ao as refreshCodegenProject,nr as resolveCodegenTarget,Be as resolveServiceBindings,Ir as runCodegen,yr as schemaFromIr,zr as secretKindOf,a as serializeSchemaSnapshot,S as sortedUniqueNames,W as sourceCapabilitySignals,m as toAdvisorContext,so as tsconfigFingerprint,Ur as validatorIrToJsonSchema};
@@ -1,4 +1,4 @@
1
- import{existsSync as K,readFileSync as Ie,statSync as fi,realpathSync as To,mkdirSync as vt,writeFileSync as Co,rmSync as Ee,readdirSync as vs}from"node:fs";import{dirname as Se,join as E,relative as xe,sep as Es,basename as Ss,resolve as pi}from"node:path";import{performance as Vt}from"node:perf_hooks";import{RUNTIME_LINTS as Oo,STATIC_LINTS as ko,runAdvisor as Ro}from"@lunora/advisor";import{LunoraError as F}from"@lunora/errors";import{serializeSchemaSnapshot as Lo}from"./SCHEMA_SNAPSHOT_VERSION-DTLoSaNn.mjs";import{toAdvisorContext as Fo}from"./formatAdvisories-Bue5tbp6.mjs";import{Node as r,SyntaxKind as u,Project as Et,VariableDeclarationKind as xs,ts as T}from"ts-morph";import{listLunoraSourceFiles as b,lunoraRelativePath as C,declarationLineOf as gi,collectCallRows as R,descendantsOfKind as S,bindingKeyName as fe,findObjectProperty as V,collectSecurityCallRows as Do,propertyInitializer as M,listSecurityScanFiles as Ue,objectLiteralFromCallbackBody as mi,limitNameOf as hi,optionsObjectLiteral as vi,handlerOf as _o,memberAccessOf as ys,chainRootOf as St,unwrapExpression as v,collectNodeRows as ce,isConstDeclaration as J,outermostValueWrapper as O,isWriteTarget as Te,isSameNode as P,returningFunctionOf as Xt,walkChain as Mo,staticNumberValue as Ei,RUN_METHODS as As,functionReferenceSegments as Ko,isTestPath as $o,isFunctionLike as pe,functionKeyOf as Si,withSourceListMemo as zo}from"./isTestPath-DJeZ18i9.mjs";import{j as se,h as ee,c as N,a as bs,w as Ns,k as Bo,d as $,l as Vo,b as xi,f as Wo,m as Uo,g as Jt,i as jo}from"./attribution-B8xa6AeK.mjs";import{i as Y,a as Ne,r as qo,b as Ho,c as yi,d as Go,s as je,e as Yo,f as Qo,g as Xo}from"./ip-reads-D8rPYtZ6.mjs";import{e as Z,f as Jo,m as Ai,b as xt,g as yt,E as bi,C as Ni,d as wi,h as Zo,j as ea,a as ta}from"./context-root-CO8PbZi5.mjs";import{a as k,i as Pi,c as le,d as Ii,e as Ti,f as sa,b as na,g as ia,h as ra}from"./classify-procedure-call-BK_MMoue.mjs";import{a as y,s as ws}from"./property-name-7cBlgK_O.mjs";import{b as oa,a as Ci}from"./module-specifiers-BctA0m_p.mjs";import{r as At,s as aa}from"./parse-validator-BisfC8bR.mjs";import ca from"./discoverAuthApiCalls-DcvsgL5u.mjs";import{i as z,r as Oi}from"./database-calls-Cug60vT9.mjs";import{i as Zt,p as ki,w as la,d as da}from"./index-BwLaIVqA.mjs";import ua from"./discoverHyperdriveCalls-B--Nvx36.mjs";import{PROJECT_CONFIG_FILENAMES as fa,findProjectConfigFile as Ri,findCodegenConfigFile as pa}from"./PROJECT_CONFIG_FILENAMES-CLfsyvjA.mjs";import{contextPropertiesRead as ga,createTargetScope as ma,fileWiresRequestSecretTool as ha,discoverFeatureUsage as va}from"./capabilitiesUsedBy-BcDkRoOu.mjs";import{diagnosticAt as Ce}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{m as Ps,a as lt,s as Li,d as Ea}from"./index-CQuAXbal.mjs";import{MUTATORS_FILENAME as Sa,isDefineMutatorCallee as xa,mutatorServerImplOf as ya,discoverMutators as Aa}from"./MUTATORS_FILENAME-SLAN2VXq.mjs";import ba from"./discoverNondeterministicCalls-MeKjo_UX.mjs";import{discoverNotifyConfig as Na,discoverNotifyCalls as wa}from"./ALL_NOTIFY_CHANNELS-DI0zmZGs.mjs";import Pa from"./discoverR2sqlCalls-DHvclvkv.mjs";import Ia from"./discoverRlsProcedures-CUfhUqfY.mjs";import{s as Is,n as Ta}from"./dispatch-namespace-DwTjD7BU.mjs";import{secretKindOf as Ca,redact as Oa,isHeuristicSecretKind as ka,isSecretishName as Ra}from"./redact-Cy14LEnc.mjs";import{r as Fi,p as La,c as Fa,a as Da,e as _a,d as Ma}from"./project-config-file-DR7xrrNB.mjs";import{a as tt,d as Ka,r as $a}from"./modules-isOWiSYI.mjs";import{WORKFLOWS_FILENAME as za,discoverWorkflows as Ba}from"./WORKFLOWS_FILENAME-Dtxo_XBw.mjs";import{r as Va}from"./json-data-Chfs2Cz5.mjs";import{a as Wa,I as Ua,g as ja,G as Di,d as qa,i as Ha}from"./shared-Cn7dMQ_u.mjs";import{createCodegenProject as Ga}from"./createCodegenProject-C4XuJSap.mjs";import{findTsconfig as p0,refreshCodegenProject as g0,tsconfigFingerprint as m0}from"./createCodegenProject-C4XuJSap.mjs";import{wranglerString as Ya,wranglerValue as Qa,companionName as Xa,COMPANION_FILES as Ja}from"./COMPANION_BINDING-Da_v9XpC.mjs";import{CAPABILITIES as Za,usedCapabilities as ec}from"./CAPABILITY_PROBES-DCzOjTN7.mjs";import{isD1GlobalTable as _i,isHyperdriveGlobalTable as Mi}from"./isD1GlobalTable-udvHAAzD.mjs";import{discoverAgents as tc}from"./AGENTS_FILENAME-BSW65Q9R.mjs";import{discoverContainers as sc}from"./CONTAINERS_FILENAME-Dy3qWGfI.mjs";import nc from"./discoverCrons-MpIC14pg.mjs";import{discoverEnv as ic}from"./ENV_FILENAME-DFx_jlpa.mjs";import Ki from"./readPackageDependencies-RHhGiz0k.mjs";import{discoverQueueDeclarations as rc}from"./QUEUES_FILENAME-CVkpGqoY.mjs";import{discoverSandboxUsage as oc}from"./discoverSandboxUsage-CdrJNRFd.mjs";import{resolveServiceBindings as ac}from"./companionServiceBinding-BZjm486n.mjs";import cc from"./discoverStorageRulesMetadata-D_pYyr1i.mjs";import{resolveCodegenTarget as Fe,gatePlatformFeatures as lc,needsCloudflareModuleWalk as dc,readTargetDiagnostics as uc,vectorizeDimensionDiagnostics as fc,liveStreamsDeliveryAuthorizationDiagnostic as pc,socketRoutesDeliveryAuthorizationDiagnostic as gc,studioPlatformFor as mc,platformFeatureAvailable as hc,gateAdminTokenRevocation as vc}from"./DEFAULT_TARGET-CnglMKg_.mjs";import{i as Ec}from"./schema-BgM8A3XV.mjs";import{b as $i,e as Sc}from"./shard-WWiw5i1B.mjs";import{e as xc,a as yc}from"./server-Dfxmm5Zw.mjs";import{emitDataModel as Ac}from"./emitDataModel-Cen7mAmM.mjs";import{i as bc,b as Nc,e as wc,d as Pc,f as Ic,c as Tc}from"./unwrap-handler-return-BnsKyz9W.mjs";import Cc from"./discoverHttpRoutes-BtMgsfzG.mjs";import Oc from"./discoverInserts-Dx7Lxey3.mjs";import{e as zi}from"./exported-procedure-chains-ej9ozyZB.mjs";import kc from"./discoverMigrations-DaBdK1Bv.mjs";import gn from"./discoverQueries-BlhMsXuk.mjs";import Rc from"./discoverRlsMetadata-CO-pRHOx.mjs";import Lc from"./discoverSchema-CL9PLdOu.mjs";import{discoverShapes as Fc}from"./SHAPES_FILENAME-Cf4sum4C.mjs";import{i as Dc}from"./reserved-words-CW1QFbTd.mjs";import{emitAuthModule as _c,emitApp as Mc}from"./emitApp-xbr1VKI7.mjs";import{readJsonSync as Kc}from"@visulima/fs";import{indexReferencesOf as $c,buildSchemaSnapshot as zc}from"./SchemaSnapshotParseError-CV7mmuPi.mjs";import{buildOpenApiDocument as Bc,emitOpenApiModule as Vc}from"./buildOpenApiDocument-C3zlve6K.mjs";import{buildOpenRpcDocument as Wc,emitOpenRpcModule as Uc}from"./OPENRPC_VERSION-DkWde9eh.mjs";import{w as jc,u as qc,v as Hc,t as Gc,x as Yc}from"./shard-runtime-G5mZQjY0.mjs";import{emitCollections as Qc,emitSeed as Xc,emitApi as Jc,emitInternalApi as Zc}from"./emitApi-lwadq5G7.mjs";import{emitCrons as el,emitScheduler as tl,emitAdminRevocations as sl,emitShardRegistry as nl,emitDurableObjects as il,emitVectors as rl,emitWranglerCronTriggers as ol}from"./emitCrons-CCRKs482.mjs";import al from"./emitDrizzleSchema-lRoq3OJs.mjs";import{LAZY_FUNCTION_DIRECTORY as Bi,emitFunctions as cl,emitLazyFunctionModules as ll}from"./emitFunctions-ppMX7E3X.mjs";const dl=(e,t=!1)=>{if(e.length===0)return"";const s=qa(t),n=e.map(c=>{if(Wa(c.exportName,"live stream export name"),!Ua.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(d=>{ja(d.name,"live topic name");const f=`(typeof ${c.exportName}Stream)["topics"]["${d.name}"]`,p=`LiveTopicRef<LiveTopicPayload<${f}>>`,g=JSON.stringify(c.id);if(d.fields.length===0)return` ${d.name}: (): ${p} => ({ __lunoraLive: ${g}, topic: ${JSON.stringify(d.name)} }),`;const h=d.fields.map(x=>`\${encodeURIComponent(key.${x})}`).join(":");return` ${d.name}: (key: LiveTopicKey<${f}>): ${p} => ({
1
+ import{existsSync as K,readFileSync as Ie,statSync as fi,realpathSync as To,mkdirSync as vt,writeFileSync as Co,rmSync as Ee,readdirSync as vs}from"node:fs";import{dirname as Se,join as E,relative as xe,sep as Es,basename as Ss,resolve as pi}from"node:path";import{performance as Vt}from"node:perf_hooks";import{RUNTIME_LINTS as Oo,STATIC_LINTS as ko,runAdvisor as Ro}from"@lunora/advisor";import{LunoraError as F}from"@lunora/errors";import{serializeSchemaSnapshot as Lo}from"./SCHEMA_SNAPSHOT_VERSION-DTLoSaNn.mjs";import{toAdvisorContext as Fo}from"./formatAdvisories-Bue5tbp6.mjs";import{Node as r,SyntaxKind as u,Project as Et,VariableDeclarationKind as xs,ts as T}from"ts-morph";import{listLunoraSourceFiles as b,lunoraRelativePath as C,declarationLineOf as gi,collectCallRows as R,descendantsOfKind as S,bindingKeyName as fe,findObjectProperty as V,collectSecurityCallRows as Do,propertyInitializer as M,listSecurityScanFiles as Ue,objectLiteralFromCallbackBody as mi,limitNameOf as hi,optionsObjectLiteral as vi,handlerOf as _o,memberAccessOf as ys,chainRootOf as St,unwrapExpression as v,collectNodeRows as ce,isConstDeclaration as J,outermostValueWrapper as O,isWriteTarget as Te,isSameNode as P,returningFunctionOf as Xt,walkChain as Mo,staticNumberValue as Ei,RUN_METHODS as As,functionReferenceSegments as Ko,isTestPath as $o,isFunctionLike as pe,functionKeyOf as Si,withSourceListMemo as zo}from"./isTestPath-DJeZ18i9.mjs";import{j as se,h as ee,c as N,a as bs,w as Ns,k as Bo,d as $,l as Vo,b as xi,f as Wo,m as Uo,g as Jt,i as jo}from"./attribution-B8xa6AeK.mjs";import{i as Y,a as Ne,r as qo,b as Ho,c as yi,d as Go,s as je,e as Yo,f as Qo,g as Xo}from"./ip-reads-D8rPYtZ6.mjs";import{e as Z,f as Jo,m as Ai,b as xt,g as yt,E as bi,C as Ni,d as wi,h as Zo,j as ea,a as ta}from"./context-root-CO8PbZi5.mjs";import{a as k,i as Pi,c as le,d as Ii,e as Ti,f as sa,b as na,g as ia,h as ra}from"./classify-procedure-call-BK_MMoue.mjs";import{a as y,s as ws}from"./property-name-7cBlgK_O.mjs";import{b as oa,a as Ci}from"./module-specifiers-BctA0m_p.mjs";import{r as At,s as aa}from"./parse-validator-BisfC8bR.mjs";import ca from"./discoverAuthApiCalls-DcvsgL5u.mjs";import{i as z,r as Oi}from"./database-calls-Cug60vT9.mjs";import{i as Zt,p as ki,w as la,d as da}from"./index-BwLaIVqA.mjs";import ua from"./discoverHyperdriveCalls-B--Nvx36.mjs";import{PROJECT_CONFIG_FILENAMES as fa,findProjectConfigFile as Ri,findCodegenConfigFile as pa}from"./PROJECT_CONFIG_FILENAMES-CLfsyvjA.mjs";import{contextPropertiesRead as ga,createTargetScope as ma,fileWiresRequestSecretTool as ha,discoverFeatureUsage as va}from"./capabilitiesUsedBy-BcDkRoOu.mjs";import{diagnosticAt as Ce}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{m as Ps,a as lt,s as Li,d as Ea}from"./index-CQuAXbal.mjs";import{MUTATORS_FILENAME as Sa,isDefineMutatorCallee as xa,mutatorServerImplOf as ya,discoverMutators as Aa}from"./MUTATORS_FILENAME-SLAN2VXq.mjs";import ba from"./discoverNondeterministicCalls-MeKjo_UX.mjs";import{discoverNotifyConfig as Na,discoverNotifyCalls as wa}from"./ALL_NOTIFY_CHANNELS-DI0zmZGs.mjs";import Pa from"./discoverR2sqlCalls-DHvclvkv.mjs";import Ia from"./discoverRlsProcedures-CUfhUqfY.mjs";import{s as Is,n as Ta}from"./dispatch-namespace-DwTjD7BU.mjs";import{secretKindOf as Ca,redact as Oa,isHeuristicSecretKind as ka,isSecretishName as Ra}from"./redact-Cy14LEnc.mjs";import{r as Fi,p as La,c as Fa,a as Da,e as _a,d as Ma}from"./project-config-file-DR7xrrNB.mjs";import{a as tt,d as Ka,r as $a}from"./modules-isOWiSYI.mjs";import{WORKFLOWS_FILENAME as za,discoverWorkflows as Ba}from"./WORKFLOWS_FILENAME-Dtxo_XBw.mjs";import{r as Va}from"./json-data-Chfs2Cz5.mjs";import{a as Wa,I as Ua,g as ja,G as Di,d as qa,i as Ha}from"./shared-Cn7dMQ_u.mjs";import{createCodegenProject as Ga}from"./createCodegenProject-C4XuJSap.mjs";import{findTsconfig as p0,refreshCodegenProject as g0,tsconfigFingerprint as m0}from"./createCodegenProject-C4XuJSap.mjs";import{wranglerString as Ya,wranglerValue as Qa,companionName as Xa,COMPANION_FILES as Ja}from"./COMPANION_BINDING-Da_v9XpC.mjs";import{CAPABILITIES as Za,usedCapabilities as ec}from"./CAPABILITY_PROBES-DCzOjTN7.mjs";import{isD1GlobalTable as _i,isHyperdriveGlobalTable as Mi}from"./isD1GlobalTable-udvHAAzD.mjs";import{discoverAgents as tc}from"./AGENTS_FILENAME-BSW65Q9R.mjs";import{discoverContainers as sc}from"./CONTAINERS_FILENAME-Dy3qWGfI.mjs";import nc from"./discoverCrons-MpIC14pg.mjs";import{discoverEnv as ic}from"./ENV_FILENAME-DFx_jlpa.mjs";import Ki from"./readPackageDependencies-RHhGiz0k.mjs";import{discoverQueueDeclarations as rc}from"./QUEUES_FILENAME-CVkpGqoY.mjs";import{discoverSandboxUsage as oc}from"./discoverSandboxUsage-CdrJNRFd.mjs";import{resolveServiceBindings as ac}from"./companionServiceBinding-BZjm486n.mjs";import cc from"./discoverStorageRulesMetadata-D_pYyr1i.mjs";import{resolveCodegenTarget as Fe,gatePlatformFeatures as lc,needsCloudflareModuleWalk as dc,readTargetDiagnostics as uc,vectorizeDimensionDiagnostics as fc,liveStreamsDeliveryAuthorizationDiagnostic as pc,socketRoutesDeliveryAuthorizationDiagnostic as gc,studioPlatformFor as mc,platformFeatureAvailable as hc,gateAdminTokenRevocation as vc}from"./DEFAULT_TARGET-CnglMKg_.mjs";import{i as Ec}from"./schema-BgM8A3XV.mjs";import{b as $i,e as Sc}from"./shard-DcWZeVPb.mjs";import{e as xc,a as yc}from"./server-Dfxmm5Zw.mjs";import{emitDataModel as Ac}from"./emitDataModel-Cen7mAmM.mjs";import{i as bc,b as Nc,e as wc,d as Pc,f as Ic,c as Tc}from"./unwrap-handler-return-BnsKyz9W.mjs";import Cc from"./discoverHttpRoutes-BtMgsfzG.mjs";import Oc from"./discoverInserts-Dx7Lxey3.mjs";import{e as zi}from"./exported-procedure-chains-ej9ozyZB.mjs";import kc from"./discoverMigrations-DaBdK1Bv.mjs";import gn from"./discoverQueries-BlhMsXuk.mjs";import Rc from"./discoverRlsMetadata-CO-pRHOx.mjs";import Lc from"./discoverSchema-CL9PLdOu.mjs";import{discoverShapes as Fc}from"./SHAPES_FILENAME-Cf4sum4C.mjs";import{i as Dc}from"./reserved-words-CW1QFbTd.mjs";import{emitAuthModule as _c,emitApp as Mc}from"./emitApp-a6xtVrpx.mjs";import{readJsonSync as Kc}from"@visulima/fs";import{indexReferencesOf as $c,buildSchemaSnapshot as zc}from"./SchemaSnapshotParseError-CV7mmuPi.mjs";import{buildOpenApiDocument as Bc,emitOpenApiModule as Vc}from"./buildOpenApiDocument-C3zlve6K.mjs";import{buildOpenRpcDocument as Wc,emitOpenRpcModule as Uc}from"./OPENRPC_VERSION-DkWde9eh.mjs";import{w as jc,u as qc,v as Hc,t as Gc,x as Yc}from"./shard-runtime-G5mZQjY0.mjs";import{emitCollections as Qc,emitSeed as Xc,emitApi as Jc,emitInternalApi as Zc}from"./emitApi-lwadq5G7.mjs";import{emitCrons as el,emitScheduler as tl,emitAdminRevocations as sl,emitShardRegistry as nl,emitDurableObjects as il,emitVectors as rl,emitWranglerCronTriggers as ol}from"./emitCrons-CCRKs482.mjs";import al from"./emitDrizzleSchema-lRoq3OJs.mjs";import{LAZY_FUNCTION_DIRECTORY as Bi,emitFunctions as cl,emitLazyFunctionModules as ll}from"./emitFunctions-ppMX7E3X.mjs";const dl=(e,t=!1)=>{if(e.length===0)return"";const s=qa(t),n=e.map(c=>{if(Wa(c.exportName,"live stream export name"),!Ua.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(d=>{ja(d.name,"live topic name");const f=`(typeof ${c.exportName}Stream)["topics"]["${d.name}"]`,p=`LiveTopicRef<LiveTopicPayload<${f}>>`,g=JSON.stringify(c.id);if(d.fields.length===0)return` ${d.name}: (): ${p} => ({ __lunoraLive: ${g}, topic: ${JSON.stringify(d.name)} }),`;const h=d.fields.map(x=>`\${encodeURIComponent(key.${x})}`).join(":");return` ${d.name}: (key: LiveTopicKey<${f}>): ${p} => ({
2
2
  __lunoraLive: ${g},
3
3
  topic: \`${d.name}:${h}\`,
4
4
  }),`});return` ${c.exportName}: {
@@ -486,7 +486,7 @@ const buildGlobalCdcApplier =
486
486
  }`]:[],...U(e)],Q=e=>{const t=a=>e.hasScheduler?`
487
487
  ...(this.schedulerDeclaration ? { scheduler: this.resolveScheduler(env) as unknown as ${a}["scheduler"] } : {}),`:"",r=[" 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
488
488
  ? {
489
- d1: (rawEnv: Record<string, unknown>, request?: { bookmark?: string; cdc?: boolean; cdcRetentionMs?: number; identity?: Record<string, unknown> | undefined; onBookmark?: (bookmark: string | undefined) => void; onWrite?: (table: string) => void; userId?: string | null | undefined }) => {
489
+ d1: (rawEnv: Record<string, unknown>, request?: { bookmark?: string; cdc?: boolean; cdcRetentionMs?: number; identity?: Record<string, unknown> | undefined; onBookmark?: (bookmark: string | undefined) => void; onWrite?: (table: string, settledLate?: boolean) => void; userId?: string | null | undefined }) => {
490
490
  const env = rawEnv as Env;
491
491
  const database = this.globalDeclaration?.d1(env);
492
492
 
@@ -540,7 +540,7 @@ const buildGlobalCdcApplier =
540
540
  }
541
541
  : {}),`]:[],...e.hasHyperdriveGlobal?[` ...(this.hyperdriveGlobalDeclaration
542
542
  ? {
543
- hyperdriveGlobal: (rawEnv: Record<string, unknown>, request?: { cdc?: boolean; cdcRetentionMs?: number; identity?: Record<string, unknown> | undefined; onWrite?: (table: string) => void; userId?: string | null | undefined }) => {
543
+ hyperdriveGlobal: (rawEnv: Record<string, unknown>, request?: { cdc?: boolean; cdcRetentionMs?: number; identity?: Record<string, unknown> | undefined; onWrite?: (table: string, settledLate?: boolean) => void; userId?: string | null | undefined }) => {
544
544
  const env = rawEnv as Env;
545
545
  const declaration = this.hyperdriveGlobalDeclaration;
546
546
  const exec = declaration?.exec(env) as SqlExec | undefined;
@@ -1 +1 @@
1
- import"./SCHEMA_SNAPSHOT_VERSION-DTLoSaNn.mjs";import"./isD1GlobalTable-udvHAAzD.mjs";import"./json-data-Chfs2Cz5.mjs";import{e as d}from"./shard-WWiw5i1B.mjs";import"./shard-runtime-G5mZQjY0.mjs";import"./shared-Cn7dMQ_u.mjs";import"./platform-8oj7iXQy.mjs";import"./schema-BgM8A3XV.mjs";export{d as default};
1
+ import"./SCHEMA_SNAPSHOT_VERSION-DTLoSaNn.mjs";import"./isD1GlobalTable-udvHAAzD.mjs";import"./json-data-Chfs2Cz5.mjs";import{e as d}from"./shard-DcWZeVPb.mjs";import"./shard-runtime-G5mZQjY0.mjs";import"./shared-Cn7dMQ_u.mjs";import"./platform-8oj7iXQy.mjs";import"./schema-BgM8A3XV.mjs";export{d as default};
@@ -236,7 +236,7 @@ ${y()}
236
236
  await applyCdcChanges(writer, args.changes);
237
237
 
238
238
  return { applied: args.changes.length };
239
- }`,Pr=({actionOnlyBuild:r,actionOnlyFields:t,agentsBuild:e,agentsContextField:o,agentsSchedulerSource:n,containersBuild:s,containersContextField:i,databaseOptions:g,everyContextBuild:c,everyContextField:f,facadeBlock:O,globalDatabaseLine:w,hasSensitiveArgs:u=!1,lazyFunctions:l=!1,notifyBuild:T,ormContextField:v,paymentsBuild:F,paymentsContextField:B,queuesBuild:R,queuesContextField:j,topicsBuild:d,topicsContextField:k,vectorsBuild:I,vectorsContextField:W,workflowsBuild:K,workflowsContextField:E})=>{const _=t.length>0,H=v===""?"{ db }":"{ db, orm: bindOrm(facade) }",V=v===""?"":`
239
+ }`,Pr=({actionOnlyBuild:r,actionOnlyFields:t,agentsBuild:e,agentsContextField:o,agentsSchedulerSource:n,containersBuild:s,containersContextField:i,databaseOptions:g,everyContextBuild:c,everyContextField:f,facadeBlock:O,globalDatabaseLine:w,hasSensitiveArgs:u=!1,lazyFunctions:l=!1,notifyBuild:T,ormContextField:v,paymentsBuild:F,paymentsContextField:B,queuesBuild:R,queuesContextField:W,topicsBuild:d,topicsContextField:k,vectorsBuild:I,vectorsContextField:j,workflowsBuild:K,workflowsContextField:E})=>{const _=t.length>0,H=v===""?"{ db }":"{ db, orm: bindOrm(facade) }",V=v===""?"":`
240
240
  orm: databaseContext.orm,`,C=v===""?"":`
241
241
  orm: { configurable: true, enumerable: true, value: mutationDatabase.orm, writable: true },`,x=_?`
242
242
  // ActionCtx-only helpers (external, non-deterministic I/O): constructed
@@ -511,7 +511,7 @@ ${T}
511
511
  scheduler,
512
512
  span,
513
513
  storage: contextStorage,
514
- trace,${W}${f}${B}${i}${E}${j}${k}${o}${u?`
514
+ trace,${j}${f}${B}${i}${E}${W}${k}${o}${u?`
515
515
  [Symbol.for("lunora.admitSensitiveArgs")]: (args: Record<string, unknown>, names: ReadonlySet<string>): void => this.admitSensitiveValues(options.sensitive, args, names),`:""}
516
516
  };
517
517
  ${_?` const isAction = contextKind === "action";
@@ -1022,7 +1022,7 @@ __SUBSCRIPTION_RUN__
1022
1022
  } finally {
1023
1023
  sensitive.clear();
1024
1024
  }
1025
- `,jr=r=>Mr.replace("__SUBSCRIPTION_RUN__",r?Br:Fr),Wr=r=>{const t={};for(const e of r.tables){const o={};for(const[n,s]of Object.entries(e.shape)){const i=U(s);i.kind==="id"&&i.tableName!==void 0&&(o[n]=i.tableName)}Object.keys(o).length>0&&(t[e.name]=o)}return t},Kr=r=>{const t={};for(const e of r.tables){const o=[];for(const[n,s]of Object.entries(e.shape))U(s).kind==="storage"&&o.push(n);o.length>0&&(t[e.name]=o)}return t},Hr=r=>{const t={};for(const e of r.tables){const o=[...e.indexes.map(n=>({fields:[...n.fields],name:n.name,type:"index",...n.unique===!0?{unique:!0}:{}})),...e.searchIndexes.map(n=>({fields:[n.field,...n.filterFields??[]],name:n.name,type:"search"})),...(e.geoIndexes??[]).map(n=>({fields:[n.field],name:n.name,type:"geo"})),...e.rankIndexes.map(n=>({fields:n.sortBy.map(s=>s.field),name:n.name,type:"rank"})),...e.vectorIndexes.map(n=>({fields:n.field===void 0?[]:[n.field],name:n.name,type:"vector"}))];o.length>0&&(t[e.name]=o)}return t},Vr=r=>{const t=[];for(const e of r.tables)!e.ttl||e.shardMode==="global"||t.push({...e.ttl.after===void 0?{}:{after:e.ttl.after},field:e.ttl.field,...e.softDelete?{softDeleteField:e.softDelete.field}:{},table:e.name});return t},Gr=r=>{if(r.kind!=="union"||r.members===void 0||r.members.length===0)return;const t=[];for(const e of r.members){if(e.kind!=="literal"||e.literalValue===void 0)return;try{const o=JSON.parse(e.literalValue);if(typeof o!="string")return;t.push(o)}catch{return}}return t},Qr=new Set(["bigint","boolean","date","number","timestamp"]),Jr=r=>{const[t,e]=r.kind==="union"?r.members??[]:[];if(t===void 0||e===void 0||r.members?.length!==2)return;const o=s=>s.kind==="null"||s.kind==="literal"&&s.literalValue==="null",n=U(o(e)?t:e);return o(t)!==o(e)&&Qr.has(n.kind)?n:void 0},zr=(r,t,e)=>{const o=U(t),n=Jr(o),s=n??o,i={name:r,optional:Sr(t),type:s.kind};if(s.kind==="id"&&s.tableName!==void 0){i.ref=s.tableName;const c=e.get(r);c!==void 0&&(i.onDelete=c)}s.kind==="storage"&&(i.isStorage=!0,s.bucket!==void 0&&(i.bucket=s.bucket));const g=Gr(s);return g!==void 0&&(i.enumValues=g),(s.column?.notNull===!1||n!==void 0)&&(i.nullable=!0),i},Yr=r=>{const t={};for(const e of r.tables){const o=[{name:"_id",optional:!1,pk:!0,type:"id"},{name:"_creationTime",optional:!1,type:"number"},...e.commitOrdered===!0?[{name:"_commitSeq",optional:!1,type:"number"}]:[]],n=new Map(e.relations.flatMap(s=>s.kind==="one"?[[s.field,s.onDelete]]:[]));for(const[s,i]of Object.entries(e.shape))o.push(zr(s,i,n));t[e.name]=o}return t},Xr=({hasMutators:r,hasSensitiveShapes:t,hasShapes:e,rlsData:o})=>{const n="{ columns?: readonly string[]; effectiveWhere?: WhereInput; global?: boolean; table: string } | undefined",s=t?` protected override resolveShape(name: string, args: Record<string, unknown>, identity?: SubscriptionIdentity): ${n} {
1025
+ `,Wr=r=>Mr.replace("__SUBSCRIPTION_RUN__",r?Br:Fr),jr=r=>{const t={};for(const e of r.tables){const o={};for(const[n,s]of Object.entries(e.shape)){const i=U(s);i.kind==="id"&&i.tableName!==void 0&&(o[n]=i.tableName)}Object.keys(o).length>0&&(t[e.name]=o)}return t},Kr=r=>{const t={};for(const e of r.tables){const o=[];for(const[n,s]of Object.entries(e.shape))U(s).kind==="storage"&&o.push(n);o.length>0&&(t[e.name]=o)}return t},Hr=r=>{const t={};for(const e of r.tables){const o=[...e.indexes.map(n=>({fields:[...n.fields],name:n.name,type:"index",...n.unique===!0?{unique:!0}:{}})),...e.searchIndexes.map(n=>({fields:[n.field,...n.filterFields??[]],name:n.name,type:"search"})),...(e.geoIndexes??[]).map(n=>({fields:[n.field],name:n.name,type:"geo"})),...e.rankIndexes.map(n=>({fields:n.sortBy.map(s=>s.field),name:n.name,type:"rank"})),...e.vectorIndexes.map(n=>({fields:n.field===void 0?[]:[n.field],name:n.name,type:"vector"}))];o.length>0&&(t[e.name]=o)}return t},Vr=r=>{const t=[];for(const e of r.tables)!e.ttl||e.shardMode==="global"||t.push({...e.ttl.after===void 0?{}:{after:e.ttl.after},field:e.ttl.field,...e.softDelete?{softDeleteField:e.softDelete.field}:{},table:e.name});return t},Gr=r=>{if(r.kind!=="union"||r.members===void 0||r.members.length===0)return;const t=[];for(const e of r.members){if(e.kind!=="literal"||e.literalValue===void 0)return;try{const o=JSON.parse(e.literalValue);if(typeof o!="string")return;t.push(o)}catch{return}}return t},Qr=new Set(["bigint","boolean","date","number","timestamp"]),Jr=r=>{const[t,e]=r.kind==="union"?r.members??[]:[];if(t===void 0||e===void 0||r.members?.length!==2)return;const o=s=>s.kind==="null"||s.kind==="literal"&&s.literalValue==="null",n=U(o(e)?t:e);return o(t)!==o(e)&&Qr.has(n.kind)?n:void 0},zr=(r,t,e)=>{const o=U(t),n=Jr(o),s=n??o,i={name:r,optional:Sr(t),type:s.kind};if(s.kind==="id"&&s.tableName!==void 0){i.ref=s.tableName;const c=e.get(r);c!==void 0&&(i.onDelete=c)}s.kind==="storage"&&(i.isStorage=!0,s.bucket!==void 0&&(i.bucket=s.bucket));const g=Gr(s);return g!==void 0&&(i.enumValues=g),(s.column?.notNull===!1||n!==void 0)&&(i.nullable=!0),i},Yr=r=>{const t={};for(const e of r.tables){const o=[{name:"_id",optional:!1,pk:!0,type:"id"},{name:"_creationTime",optional:!1,type:"number"},...e.commitOrdered===!0?[{name:"_commitSeq",optional:!1,type:"number"}]:[]],n=new Map(e.relations.flatMap(s=>s.kind==="one"?[[s.field,s.onDelete]]:[]));for(const[s,i]of Object.entries(e.shape))o.push(zr(s,i,n));t[e.name]=o}return t},Xr=({hasMutators:r,hasSensitiveShapes:t,hasShapes:e,rlsData:o})=>{const n="{ columns?: readonly string[]; effectiveWhere?: WhereInput; global?: boolean; table: string } | undefined",s=t?` protected override resolveShape(name: string, args: Record<string, unknown>, identity?: SubscriptionIdentity): ${n} {
1026
1026
  const sensitive = this.openSensitiveScope(\`__shape__:\${name}\`, args);
1027
1027
 
1028
1028
  try {
@@ -1152,13 +1152,19 @@ assertShapesDeclareReadPolicies(LUNORA_SHAPES, ${JSON.stringify(c)}, (schema as
1152
1152
  return rows;
1153
1153
  }
1154
1154
  `:"",en=(r,t)=>r.length===0?"":`
1155
+ private readonly globalTableSet: ReadonlySet<string> = new Set<string>(${JSON.stringify(r)});
1156
+
1155
1157
  // Without a changelog a tick cannot say which tables moved, so there is nothing to poll for.
1156
- private readonly polledGlobalTableSet: ReadonlySet<string> = new Set<string>(config.cdc === true ? ${JSON.stringify(r)} : []);
1158
+ private readonly polledGlobalTableSet: ReadonlySet<string> = config.cdc === true ? this.globalTableSet : new Set<string>();
1157
1159
 
1158
1160
  protected override polledGlobalTables(): ReadonlySet<string> {
1159
1161
  return this.polledGlobalTableSet;
1160
1162
  }
1161
1163
 
1164
+ protected override globalTables(): ReadonlySet<string> {
1165
+ return this.globalTableSet;
1166
+ }
1167
+
1162
1168
  protected override async readGlobalChangedTables(sinceSeq: number, cursorOnly?: boolean): Promise<{ bookmark?: string; cursor: number; floor?: number; tables: string[] } | undefined> {
1163
1169
  const env = this.env as Record<string, unknown>;
1164
1170
  // Metadata-only: this asks the global changelog which TABLES moved,
@@ -1388,10 +1394,10 @@ ${s} const vectors = createContextVectors(lunora${c});
1388
1394
  ordered: async (read, work) => this.runOrderedAfterWrites(read, work),
1389
1395
  });
1390
1396
  }
1391
- `:"",vectorsBuild:f,vectorsStub:n}},Sn=({advisories:r=[],agents:t=[],capabilities:e=new Set,containers:o=[],env:n,flagKeys:s=[],hasFlags:i=!1,hasNotify:g=!1,hasRooms:c=!1,hasSecretValues:f=!1,hasSensitiveArgs:O=!1,hasSockets:w=!1,lazyFunctions:u=!1,hasVectors:l=!0,liveStreamDeclarations:T=[],liveStreams:v=!1,maskMetadata:F,mutators:B=[],queues:R=[],rlsMetadata:j,schema:d,schemaSnapshot:k,shapes:I=[],storageRules:W,studioFeatures:K,hasIpReaders:E=!1,services:_=[],topics:H=[],useUmbrella:V=!1,workflowEvents:C=[],workflows:x=[]})=>{const h=_r(V),G=B.length>0,p=I.length>0,L=I.some(a=>Rr(a.args).length>0),P=O||L,fe=k===void 0?"":Zt(k),be=k===void 0?"":`
1397
+ `:"",vectorsBuild:f,vectorsStub:n}},Sn=({advisories:r=[],agents:t=[],capabilities:e=new Set,containers:o=[],env:n,flagKeys:s=[],hasFlags:i=!1,hasNotify:g=!1,hasRooms:c=!1,hasSecretValues:f=!1,hasSensitiveArgs:O=!1,hasSockets:w=!1,lazyFunctions:u=!1,hasVectors:l=!0,liveStreamDeclarations:T=[],liveStreams:v=!1,maskMetadata:F,mutators:B=[],queues:R=[],rlsMetadata:W,schema:d,schemaSnapshot:k,shapes:I=[],storageRules:j,studioFeatures:K,hasIpReaders:E=!1,services:_=[],topics:H=[],useUmbrella:V=!1,workflowEvents:C=[],workflows:x=[]})=>{const h=_r(V),G=B.length>0,p=I.length>0,L=I.some(a=>Rr(a.args).length>0),P=O||L,fe=k===void 0?"":Zt(k),be=k===void 0?"":`
1392
1398
  /** Structural schema snapshot + its content hash, recorded in the shard's \`__lunora_schema_history\` ledger on cold start so the studio can show a schema-version timeline and diff any two versions. */
1393
1399
  const LUNORA_SCHEMA_SNAPSHOT: { hash: string; json: string } = { hash: ${JSON.stringify(er(k))}, json: ${JSON.stringify(fe)} };
1394
- `,ye=k===void 0?"":", schemaSnapshot: LUNORA_SCHEMA_SNAPSHOT",S=ar(e),N=sr(i,h.flags),Q=or(s,i,h.flags),J=kr(g),z=ir(n),{build:we,contextField:ve,importLines:ke,specs:Se}=dr(Dr(R)),{build:Re,contextField:xe,importLines:Ae,specs:Oe}=cr(H,R),Y=lr(_,h.server),{build:Te,contextField:_e,importLines:De,specs:Ie}=ur(o,d.jurisdiction),{build:Ee,contextField:Ce,importLines:Le,specs:Pe}=hr(x),{build:Ne,contextField:$e,importLines:Me,schedulerSource:qe,specs:Ue,stampsOutbox:Fe}=pr(t,f&&t.length>0),{build:Be,configField:je,contextField:We,imports:Ke,stub:He}=mr(e.has("payments")),Ve=r,{advisoryRules:Ge,advisoryRows:Qe}=Er(Ve),ae=j??{policies:[],roles:[]},Je=F??{columns:[]},ze=W??{rules:[]},Ye=K??{analytics:!1,auth:!1,containers:!1,flags:!1,kv:!1,mail:!1,notifications:!1,payments:!1,privacy:!1,queues:!1,scheduler:!1,storage:!1,vectors:!1,workflows:!1},{constant:Xe,override:Ze}=gr(x,C),{constant:et,override:tt}=fr(x,C),{constant:rt,override:nt}=br(R),b=l&&d.vectorIndexes.length>0,X=new Set(d.tables.filter(a=>Ir(a)).map(a=>a.name)),se=b&&d.vectorIndexes.some(a=>X.has(a.table)),A=d.tables.some(a=>a.shardMode==="global"),Z=yr(X),ee=d.tables.some(a=>tr(a)),oe=d.tables.some(a=>rr(a)),$=d.tables.some(a=>a.externalSource!==void 0),ie=d.tables.some(a=>a.memory===!0),te=d.tables.some(a=>a.shardMode!=="global"&&a.searchIndexes.length>0);if(oe&&ee)throw new pe("INTERNAL",'lunora codegen: mixing `.global()` (D1) and `.global({ backend: "hyperdrive" })` tables in one app is not supported yet — use a single global backend.');const re=d.tables.length>0,at=Wr(d),st=Hr(d),ot=Yr(d),it=Kr(d),de=Vr(d),ce=wr(b,x.length>0,R.length>0,i,te);p&&ce.push("WhereInput");const le=vr(A),{customMutatorOverride:dt,shapeGuardImport:ct,shapeReadPolicyAssertion:lt,shapeReadPolicyImport:ut,shapeResolveOverride:ht}=Xr({hasMutators:G,hasSensitiveShapes:L,hasShapes:p,rlsData:ae}),D=v?T:[];for(const a of D)if(xr(a.exportName,"live stream export name"),!Ar.test(a.filePath))throw new pe("INTERNAL",`@lunora/codegen: refusing to emit import for unsafe live stream file path: ${JSON.stringify(a.filePath)}`);const pt=u?[]:D.map(a=>`import { ${a.exportName} as liveStream_${a.exportName} } from "../${a.filePath}.js";`),mt=` protected override liveStreams() {
1400
+ `,ye=k===void 0?"":", schemaSnapshot: LUNORA_SCHEMA_SNAPSHOT",S=ar(e),N=sr(i,h.flags),Q=or(s,i,h.flags),J=kr(g),z=ir(n),{build:we,contextField:ve,importLines:ke,specs:Se}=dr(Dr(R)),{build:Re,contextField:xe,importLines:Ae,specs:Oe}=cr(H,R),Y=lr(_,h.server),{build:Te,contextField:_e,importLines:De,specs:Ie}=ur(o,d.jurisdiction),{build:Ee,contextField:Ce,importLines:Le,specs:Pe}=hr(x),{build:Ne,contextField:$e,importLines:Me,schedulerSource:qe,specs:Ue,stampsOutbox:Fe}=pr(t,f&&t.length>0),{build:Be,configField:We,contextField:je,imports:Ke,stub:He}=mr(e.has("payments")),Ve=r,{advisoryRules:Ge,advisoryRows:Qe}=Er(Ve),ae=W??{policies:[],roles:[]},Je=F??{columns:[]},ze=j??{rules:[]},Ye=K??{analytics:!1,auth:!1,containers:!1,flags:!1,kv:!1,mail:!1,notifications:!1,payments:!1,privacy:!1,queues:!1,scheduler:!1,storage:!1,vectors:!1,workflows:!1},{constant:Xe,override:Ze}=gr(x,C),{constant:et,override:tt}=fr(x,C),{constant:rt,override:nt}=br(R),b=l&&d.vectorIndexes.length>0,X=new Set(d.tables.filter(a=>Ir(a)).map(a=>a.name)),se=b&&d.vectorIndexes.some(a=>X.has(a.table)),A=d.tables.some(a=>a.shardMode==="global"),Z=yr(X),ee=d.tables.some(a=>tr(a)),oe=d.tables.some(a=>rr(a)),$=d.tables.some(a=>a.externalSource!==void 0),ie=d.tables.some(a=>a.memory===!0),te=d.tables.some(a=>a.shardMode!=="global"&&a.searchIndexes.length>0);if(oe&&ee)throw new pe("INTERNAL",'lunora codegen: mixing `.global()` (D1) and `.global({ backend: "hyperdrive" })` tables in one app is not supported yet — use a single global backend.');const re=d.tables.length>0,at=jr(d),st=Hr(d),ot=Yr(d),it=Kr(d),de=Vr(d),ce=wr(b,x.length>0,R.length>0,i,te);p&&ce.push("WhereInput");const le=vr(A),{customMutatorOverride:dt,shapeGuardImport:ct,shapeReadPolicyAssertion:lt,shapeReadPolicyImport:ut,shapeResolveOverride:ht}=Xr({hasMutators:G,hasSensitiveShapes:L,hasShapes:p,rlsData:ae}),D=v?T:[];for(const a of D)if(xr(a.exportName,"live stream export name"),!Ar.test(a.filePath))throw new pe("INTERNAL",`@lunora/codegen: refusing to emit import for unsafe live stream file path: ${JSON.stringify(a.filePath)}`);const pt=u?[]:D.map(a=>`import { ${a.exportName} as liveStream_${a.exportName} } from "../${a.filePath}.js";`),mt=` protected override liveStreams() {
1395
1401
  return { ${D.map(a=>`${Or(a.id)}: liveStream_${a.exportName}`).join(", ")} };
1396
1402
  }
1397
1403
  `,gt=` private readonly liveStreamLoaders = new Map<string, () => Promise<{ validatePublish: (topic: string, payload: unknown) => unknown }>>([
@@ -1418,8 +1424,8 @@ ${D.map(a=>` [${JSON.stringify(a.id)}, () => import("../${a.filePath}
1418
1424
  }
1419
1425
  `;let ue="";D.length>0&&(ue=u?gt:mt);const M=[`import type { ${ce.join(", ")} } from "${h.do}";`,`import { applyCdcChanges, createStableIdFactory, createStableRandomFactory, ${te?"backfillSearchIndexes, ":""}${b?"backfillVectorIndexes, ":""}buildReprojectionMigration, ${ie?"clearMemoryTables, ":""}${ct}createReadFootprint, createShardCtxDb, exportShardRows, importShardRows, ${$?"isSourceDue, pullExternalSourceIncrementalTick, pullExternalSourceTick, ":""}markUnvouchableReads, ${se?"ROOT_SHARD_NAME, ":""}runDataMigration, runShardMigrations, ${le.importFragment}ShardDO as ShardDOBase } from "${h.do}";`,...$?[`import type { ExternalSourceLike, SourceClientLike, TraceRefLike } from "${h.do}";`]:[],p?`import { asBucketStorage, ${ut}beginDeferredDeletes, beginDeferredSchedules, composeShapeReadWhere, createSecrets, flushDeferredDeletes, LunoraError, withDeferredDeletes, withDeferredSchedules } from "${h.server}";`:`import { asBucketStorage, beginDeferredDeletes, beginDeferredSchedules, createSecrets, flushDeferredDeletes, LunoraError, withDeferredDeletes, withDeferredSchedules } from "${h.server}";`];re&&M.push(`import type { FacadeEntry } from "${h.server}";`,`import { bindOrm, defineLazyFacade } from "${h.server}";`),b&&M.push('import type { SchemaLike as VectorSchemaLike, VectorBackfillSync, VectorizeIndexLike, VectorSearchLike } from "@lunora/bindings/vectors";','import { createContextVectors, createVectorBackfillSync, createVectors, createVectorSyncHook, vectorBackfillTargets } from "@lunora/bindings/vectors";'),M.push(...S.importLines,...N.importLines,...J.importLines,...z.importLines,...De,...Le,...ke,...Ae,...Y.importLines,...Me,...Ke,...P?[`import { sensitiveArgumentNames } from "${h.values}";`]:[],"",'import schema from "../schema.js";',...pt,`import { ${["LUNORA_FUNCTIONS","LUNORA_LIFECYCLE_HOOKS","LUNORA_MIGRATIONS",...u?["getLoadedFunction","loadFunction"]:[],...G?["LUNORA_MUTATOR_PATHS"]:[],...E?["LUNORA_IP_READER_PATHS"]:[],...c?["LUNORA_ROOMS"]:[],...w?["LUNORA_SOCKETS"]:[],...p?["LUNORA_SHAPES"]:[]].join(", ")} } from "./functions.js";`);const ft=b?`
1420
1426
  vectors?: (env: Record<string, unknown>) => Record<string, VectorizeIndexLike>;`:"",bt=oe?`
1421
- d1?: (env: Record<string, unknown>, request?: { bookmark?: string; cdc?: boolean; cdcRetentionMs?: number; identity?: Record<string, unknown> | undefined; onBookmark?: (bookmark: string | undefined) => void; onWrite?: (table: string) => void; userId?: string | undefined }) => DatabaseWriterLike | undefined;`:"",yt=ee?`
1422
- hyperdriveGlobal?: (env: Record<string, unknown>, request?: { cdc?: boolean; cdcRetentionMs?: number; identity?: Record<string, unknown> | undefined; onWrite?: (table: string) => void; userId?: string | undefined }) => DatabaseWriterLike | undefined;`:"",wt=$?`
1427
+ d1?: (env: Record<string, unknown>, request?: { bookmark?: string; cdc?: boolean; cdcRetentionMs?: number; identity?: Record<string, unknown> | undefined; onBookmark?: (bookmark: string | undefined) => void; onWrite?: (table: string, settledLate?: boolean) => void; userId?: string | undefined }) => DatabaseWriterLike | undefined;`:"",yt=ee?`
1428
+ hyperdriveGlobal?: (env: Record<string, unknown>, request?: { cdc?: boolean; cdcRetentionMs?: number; identity?: Record<string, unknown> | undefined; onWrite?: (table: string, settledLate?: boolean) => void; userId?: string | undefined }) => DatabaseWriterLike | undefined;`:"",wt=$?`
1423
1429
  sourceClient?: (env: Record<string, unknown>, binding: string) => { query: <Row = Record<string, unknown>>(text: string, params?: readonly unknown[]) => Promise<Row[]> } | undefined;`:"",vt="ctx.db.<globalTable>: no global backend configured. Pass `d1` or `hyperdriveGlobal` to createShardDO().",kt="ctx.scheduler: no scheduler configured. Pass `scheduler` to createShardDO().",St="ctx.storage: no storage configured. Pass `storage` to createShardDO().",Rt=A?q("globalDbStub: DatabaseWriterLike",vt,["aggregate","count","delete","explain","findFirst","findFirstOrThrow","findMany","get","groupBy","insert","normalizeId","patch","query","rank","rankPage","replace"],{sync:["normalizeId","query"]}):"",{vectorSyncMethod:xt,vectorsBuild:At,vectorsStub:Ot}=rn(b,se?d.vectorIndexes.filter(a=>X.has(a.table)).map(a=>a.name):[]),Tt=`{
1424
1430
  ...this.ctxDbTuning(),
1425
1431
  auth: {
@@ -1432,7 +1438,7 @@ ${D.map(a=>` [${JSON.stringify(a.id)}, () => import("../${a.filePath}
1432
1438
  },
1433
1439
  broadcast: (delta) => {
1434
1440
  ${A?` if (writeBookmark !== undefined && (schema as unknown as SchemaLike).tables[delta.table]?.shardMode?.kind === "global") {
1435
- this.recordGlobalWrite(delta.table, writeBookmark);
1441
+ this.recordGlobalWrite(delta.table, writeBookmark, globalWriteSession);
1436
1442
  } else {
1437
1443
  this.recordChangedTable(delta.table, delta.indexKeys);
1438
1444
  }`:" this.recordChangedTable(delta.table, delta.indexKeys);"}
@@ -1489,6 +1495,7 @@ ${A?` if (writeBookmark !== undefined && (schema as unknown a
1489
1495
  vectors,`:"",Dt=re?`
1490
1496
  orm: bindOrm(facade),`:"",ne=ee?"config.hyperdriveGlobal":"config.d1",It=A?` const bookmark = options.readBookmark ?? this.getInboundBookmark();
1491
1497
  let writeBookmark: string | undefined;
1498
+ const globalWriteSession = {};
1492
1499
  const globalRequest = {
1493
1500
  ...this.globalCdcOptions(config.cdc ?? false),
1494
1501
  ...(bookmark === undefined ? {} : { bookmark }),
@@ -1496,7 +1503,7 @@ ${A?` if (writeBookmark !== undefined && (schema as unknown a
1496
1503
  return readIdentity();
1497
1504
  },
1498
1505
  onBookmark: (bookmarkValue: string | undefined) => { writeBookmark = bookmarkValue; if (options.bookmarks !== undefined) { options.bookmarks.value = bookmarkValue; } },
1499
- onWrite: (table: string) => { this.recordGlobalWrite(table, writeBookmark); },
1506
+ onWrite: (table: string, settledLate?: boolean) => { if (settledLate === true) { this.recordLateGlobalWrite(table); } else { this.recordGlobalWrite(table, writeBookmark, globalWriteSession); } },
1500
1507
  get userId(): string | undefined {
1501
1508
  return readUserId();
1502
1509
  },
@@ -1634,9 +1641,9 @@ ${E?` for (const path of LUNORA_IP_READER_PATHS) {
1634
1641
  return new Set([...registered.sensitiveArgs, ...fromValidators]);
1635
1642
  }
1636
1643
 
1637
- `:"",jt=Nr(u),Wt=u?` const preparation = this.prepareFunction(functionPath, "subscription");
1644
+ `:"",Wt=Nr(u),jt=u?` const preparation = this.prepareFunction(functionPath, "subscription");
1638
1645
  if (preparation !== undefined) await preparation;
1639
- `:"",Kt=jr(P).replace("__PREPARE_FUNCTION__",Wt),Ht=Ur(c,u,Fe),Vt=re?`
1646
+ `:"",Kt=Wr(P).replace("__PREPARE_FUNCTION__",jt),Ht=Ur(c,u,Fe),Vt=re?`
1640
1647
  const facade = db as unknown as Record<string, FacadeEntry>;
1641
1648
  ${d.tables.map(a=>` defineLazyFacade(db, ${JSON.stringify(a.name)});`).join(`
1642
1649
  `)}
@@ -1729,7 +1736,7 @@ export interface ShardDOConfig {
1729
1736
  /** \`unknown\` because \`@lunora/scheduler\`'s \`Scheduler\` is not assignable to \`SchedulerLike\`; the shard casts it. */
1730
1737
  scheduler?: (env: Record<string, unknown>) => unknown;
1731
1738
  /** \`origin\` is the origin the current \`/rpc\` request reached the worker on — the fallback base for signed object URLs when no \`publicBaseUrl\` is configured. \`undefined\` off the synchronous dispatch path. */
1732
- storage?: (env: Record<string, unknown>, origin?: string) => unknown;${ft}${S.configFields}${N.configField}${je}${bt}${yt}${wt}${Z.configField}
1739
+ storage?: (env: Record<string, unknown>, origin?: string) => unknown;${ft}${S.configFields}${N.configField}${We}${bt}${yt}${wt}${Z.configField}
1733
1740
  }
1734
1741
  ${q("schedulerStub",kt,["cancel","runAfter","runAt"])}${q("storageStub",St,["createMultipartUpload","delete","download","generateUploadUrl","getMetadata","getPresignedUrl","getSignedUrl","getUrl","head","list","resumeMultipartUpload","store","upload"],{sync:["getUrl","resumeMultipartUpload"]})}${Rt}${$t}${Ot}${S.stubs}${He}
1735
1742
  // \`ctx.fetch\` is action-only. A query is re-run by every live subscription and a
@@ -1743,7 +1750,7 @@ const refuseFetch = (): never => {
1743
1750
  throw new LunoraError("FORBIDDEN", "ctx.fetch is action-only: network I/O belongs in an action, not a query or mutation");
1744
1751
  };
1745
1752
 
1746
- ${jt}
1753
+ ${Wt}
1747
1754
 
1748
1755
  /**
1749
1756
  * Build the project's shard Durable Object. Export the result as \`ShardDO\`
@@ -1917,6 +1924,6 @@ ${te?`
1917
1924
  return backfillSearchIndexes(this.sql as SqlExec, schema as unknown as SchemaLike, options);
1918
1925
  }
1919
1926
  `:""}${xt}
1920
- ${Pr({hasSensitiveArgs:P,lazyFunctions:u,actionOnlyFields:Yt,agentsBuild:Ne,agentsContextField:$e,agentsSchedulerSource:qe,containersBuild:Te,containersContextField:_e,databaseOptions:Tt,everyContextBuild:Gt,everyContextField:Qt,facadeBlock:Vt,globalDatabaseLine:It,notifyBuild:Jt,ormContextField:Dt,paymentsBuild:Be,paymentsContextField:We,queuesBuild:we,queuesContextField:ve,topicsBuild:Re,topicsContextField:xe,vectorsBuild:At,vectorsContextField:_t,workflowsBuild:Ee,workflowsContextField:Ce,actionOnlyBuild:Xt})}
1927
+ ${Pr({hasSensitiveArgs:P,lazyFunctions:u,actionOnlyFields:Yt,agentsBuild:Ne,agentsContextField:$e,agentsSchedulerSource:qe,containersBuild:Te,containersContextField:_e,databaseOptions:Tt,everyContextBuild:Gt,everyContextField:Qt,facadeBlock:Vt,globalDatabaseLine:It,notifyBuild:Jt,ormContextField:Dt,paymentsBuild:Be,paymentsContextField:je,queuesBuild:we,queuesContextField:ve,topicsBuild:Re,topicsContextField:xe,vectorsBuild:At,vectorsContextField:_t,workflowsBuild:Ee,workflowsContextField:Ce,actionOnlyBuild:Xt})}
1921
1928
  };
1922
1929
  `};export{Kr as b,Sn as e};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunora/codegen",
3
- "version": "1.0.0-alpha.431",
3
+ "version": "1.0.0-alpha.432",
4
4
  "description": "Code generator for Lunora: emits _generated/{api,server,dataModel}.ts from your schema",
5
5
  "keywords": [
6
6
  "cloudflare",