@lunora/codegen 1.0.0-alpha.367 → 1.0.0-alpha.369
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.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/packem_shared/{CAPABILITY_PROBES-brcmKenl.mjs → CAPABILITY_PROBES-DKYJ2K4t.mjs} +1 -1
- package/dist/packem_shared/{SCHEMA_SNAPSHOT_FILENAME-CVAC4R90.mjs → SCHEMA_SNAPSHOT_FILENAME-DDRbBN-I.mjs} +1 -1
- package/dist/packem_shared/{capabilitiesUsedBy-Xncj__oq.mjs → capabilitiesUsedBy-CN8HACEL.mjs} +1 -1
- package/dist/packem_shared/{emitAgents-BIvfaobb.mjs → emitAgents-B6IWt2Gq.mjs} +1 -1
- package/dist/packem_shared/{emitApp-CFkLyCIO.mjs → emitApp-CzDMr_iP.mjs} +19 -19
- package/dist/packem_shared/emitServer-DEkbCE0n.mjs +1 -0
- package/dist/packem_shared/{emitShard-tyWbUrjj.mjs → emitShard-N6sEBh_g.mjs} +1 -1
- package/dist/packem_shared/{server-8wMiVU6J.mjs → server-DC4PW_2M.mjs} +1 -1
- package/dist/packem_shared/{shard-DOqocTdL.mjs → shard-D9_wgrV7.mjs} +1 -1
- package/dist/packem_shared/{shard-runtime-Dad_kcaX.mjs → shard-runtime-B9K29SyO.mjs} +1 -1
- package/package.json +3 -3
- package/dist/packem_shared/emitServer-OThMbq3y.mjs +0 -1
package/dist/index.d.mts
CHANGED
|
@@ -2976,7 +2976,7 @@ declare const CAPABILITY_ROWS: readonly [{
|
|
|
2976
2976
|
readonly shardBinding: {
|
|
2977
2977
|
readonly clientType: "SqlClient";
|
|
2978
2978
|
readonly instrument: "instrumentSql";
|
|
2979
|
-
readonly missingMessage: "ctx.sql: provide a `sql` config thunk that builds a SqlClient from your driver, e.g. `sql: (env) => fromPostgresJs(postgres(env.HYPERDRIVE.connectionString))`.";
|
|
2979
|
+
readonly missingMessage: "ctx.sql: provide a `sql` config thunk that builds a SqlClient from your driver, e.g. `sql: (env) => fromPostgresJs(postgres(env.HYPERDRIVE.connectionString, { fetch_types: false, max: 5 }))`.";
|
|
2980
2980
|
readonly stubMethods: readonly ["query"];
|
|
2981
2981
|
};
|
|
2982
2982
|
readonly tier: "action";
|
package/dist/index.d.ts
CHANGED
|
@@ -2976,7 +2976,7 @@ declare const CAPABILITY_ROWS: readonly [{
|
|
|
2976
2976
|
readonly shardBinding: {
|
|
2977
2977
|
readonly clientType: "SqlClient";
|
|
2978
2978
|
readonly instrument: "instrumentSql";
|
|
2979
|
-
readonly missingMessage: "ctx.sql: provide a `sql` config thunk that builds a SqlClient from your driver, e.g. `sql: (env) => fromPostgresJs(postgres(env.HYPERDRIVE.connectionString))`.";
|
|
2979
|
+
readonly missingMessage: "ctx.sql: provide a `sql` config thunk that builds a SqlClient from your driver, e.g. `sql: (env) => fromPostgresJs(postgres(env.HYPERDRIVE.connectionString, { fetch_types: false, max: 5 }))`.";
|
|
2980
2980
|
readonly stubMethods: readonly ["query"];
|
|
2981
2981
|
};
|
|
2982
2982
|
readonly tier: "action";
|
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-SplX7j_9.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-
|
|
1
|
+
import{SCHEMA_SNAPSHOT_VERSION as t,diffSchemaSnapshots as a,serializeSchemaSnapshot as i}from"./packem_shared/SCHEMA_SNAPSHOT_VERSION-SplX7j_9.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-DKYJ2K4t.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-BedyJsOT.mjs";import{isTestPath as R,listLunoraSourceFiles as T}from"./packem_shared/isTestPath-JdN4KXhV.mjs";import{default as I}from"./packem_shared/discoverAuthApiCalls-Ce3BdKQr.mjs";import{CONTAINERS_FILENAME as F,discoverContainers as L}from"./packem_shared/CONTAINERS_FILENAME-T1v8pyHN.mjs";import{default as P}from"./packem_shared/discoverCrons-D-vJXsgx.mjs";import{capabilitiesUsedBy as b,createTargetScope as y,foldCapabilitySignals as U,mayReadCapabilityContext as G,sourceCapabilitySignals as H}from"./packem_shared/capabilitiesUsedBy-CN8HACEL.mjs";import{FLAGS_FILENAME as B,discoverFlags as k}from"./packem_shared/FLAGS_FILENAME-BEMyglH0.mjs";import{default as K}from"./packem_shared/discoverFunctions-BdEY3nbv.mjs";import{default as z}from"./packem_shared/discoverHttpRoutes-Hy2UrcrN.mjs";import{default as q}from"./packem_shared/discoverHyperdriveCalls-Cn3087D8.mjs";import{default as J}from"./packem_shared/discoverInserts-DIzIGlyG.mjs";import{d as X}from"./packem_shared/index-Cm7HdvL5.mjs";import{default as $}from"./packem_shared/discoverMigrations-Bv8kNIgy.mjs";import{MUTATORS_FILENAME as re,discoverMutators as oe}from"./packem_shared/MUTATORS_FILENAME-PNPCtUl2.mjs";import{default as ae}from"./packem_shared/discoverNondeterministicCalls-DZ_kIie5.mjs";import{NOTIFY_FILENAME as se,discoverNotifyCalls as fe,discoverNotifyChannels as me,discoverNotifyConfig as de}from"./packem_shared/NOTIFY_FILENAME-HXIKioYv.mjs";import{default as ne}from"./packem_shared/readPackageDependencies-RHhGiz0k.mjs";import{default as le}from"./packem_shared/discoverQueries-KjOdhrk6.mjs";import{QUEUES_FILENAME as Se,discoverQueues as Ee}from"./packem_shared/QUEUES_FILENAME-Dt5RG_P0.mjs";import{default as Ae}from"./packem_shared/discoverR2sqlCalls-B4N8iXlU.mjs";import{default as ge}from"./packem_shared/discoverRlsProcedures-DhOEyJLg.mjs";import{default as Ne}from"./packem_shared/discoverRlsMetadata-Dq6iSXnC.mjs";import{discoverSandboxUsage as Re}from"./packem_shared/discoverSandboxUsage-CdGRnVU2.mjs";import{default as he}from"./packem_shared/discoverSchema-DmkjooXZ.mjs";import{readServiceBindings as _e,resolveServiceBindings as Fe}from"./packem_shared/readServiceBindings-BA49C6aN.mjs";import{SHAPES_FILENAME as Me,discoverShapes as Pe}from"./packem_shared/SHAPES_FILENAME-mgEi072Z.mjs";import{default as be}from"./packem_shared/discoverStorageRulesMetadata-CJ7h6SPK.mjs";import{WORKFLOWS_FILENAME as Ue,discoverWorkflows as Ge}from"./packem_shared/WORKFLOWS_FILENAME-VAXgqqP-.mjs";import{emitApp as je}from"./packem_shared/emitApp-CzDMr_iP.mjs";import{isD1GlobalTable as ke,isHyperdriveGlobalTable as We}from"./packem_shared/isD1GlobalTable-udvHAAzD.mjs";import{buildOpenApiDocument as Ve,emitOpenApi as ze,emitOpenApiModule as Qe}from"./packem_shared/buildOpenApiDocument-Cju685VK.mjs";import{OPENRPC_VERSION as we,buildOpenRpcDocument as Je,emitOpenRpc as Ye,emitOpenRpcModule as Xe}from"./packem_shared/OPENRPC_VERSION-CTR_g_IE.mjs";import{DEFAULT_TARGET as $e,platformMatrixIds as er,readProjectTarget as rr,resolveCodegenTarget as or}from"./packem_shared/DEFAULT_TARGET-3OLdJhTj.mjs";import{loadProjectConfig as ar,readProjectConfigLiterals as ir}from"./packem_shared/loadProjectConfig-B7RmxIeD.mjs";import{PROJECT_CONFIG_FILENAMES as fr,findCodegenConfigFile as mr,findProjectConfigFile as dr,projectConfigCandidatePaths as pr}from"./packem_shared/PROJECT_CONFIG_FILENAMES-CLfsyvjA.mjs";import{SCHEMA_SNAPSHOT_FILENAME as cr,runCodegen as lr}from"./packem_shared/SCHEMA_SNAPSHOT_FILENAME-DDRbBN-I.mjs";import{SchemaSnapshotParseError as Sr,buildSchemaSnapshot as Er,evaluateSchemaDrift as ur,parseSchemaSnapshot as Ar}from"./packem_shared/SchemaSnapshotParseError-CjKSMuex.mjs";import{default as gr}from"./packem_shared/fingerprintSchemaSources-DIYx5eO0.mjs";import{schemaFromIr as Nr}from"./packem_shared/schemaFromIr-CByOxuZb.mjs";import{LUNORA_ERROR_CODES as Rr,validatorIrToJsonSchema as Tr}from"./packem_shared/LUNORA_ERROR_CODES-CIAJQeKB.mjs";import{SDK_LANGUAGES as Ir,SDK_TARGETS as _r,generateSdk as Fr}from"./sdk/index.mjs";import{redact as Mr,secretKindOf as Pr}from"./packem_shared/redact-Cy14LEnc.mjs";import{default as br}from"./packem_shared/emitDrizzleSchema-CD4hPtUP.mjs";import{e as Ur}from"./packem_shared/server-DC4PW_2M.mjs";import{e as Hr}from"./packem_shared/shard-D9_wgrV7.mjs";import{G as Br}from"./packem_shared/shared-Br_OnErI.mjs";import{MESSAGE_SOLUTIONS as Wr,findSolutionByMessage as Kr}from"@lunora/errors";import{createCodegenProject as zr,findTsconfig as Qr,refreshCodegenProject as qr,tsconfigFingerprint as wr}from"./packem_shared/createCodegenProject-DmXl8m_P.mjs";import{t as Yr,u as Xr,v as Zr}from"./packem_shared/shard-runtime-B9K29SyO.mjs";import{emitApi as eo,emitCollections as ro,emitInternalApi as oo}from"./packem_shared/emitApi-CCjh0ICg.mjs";import{emitCrons as ao,emitScheduler as io,emitVectors as so,emitWranglerCronTriggers as fo}from"./packem_shared/emitCrons-CY8IQfAI.mjs";import{emitDataModel as po}from"./packem_shared/emitDataModel-Bba2y2yt.mjs";import{emitFunctions as co}from"./packem_shared/emitFunctions-C3WOlVN0.mjs";import{isTypedSchema as xo}from"./packem_shared/isTypedSchema-CDv3pJB6.mjs";const e="0.0.0";export{C as AGENTS_FILENAME,E as CAPABILITY_PROBES,F as CONTAINERS_FILENAME,A as CodegenDiagnosticError,$e as DEFAULT_TARGET,B as FLAGS_FILENAME,Br as GENERATED_HEADER,Rr as LUNORA_ERROR_CODES,Wr as LUNORA_SOLUTION_RULES,re as MUTATORS_FILENAME,se as NOTIFY_FILENAME,we as OPENRPC_VERSION,fr as PROJECT_CONFIG_FILENAMES,Se as QUEUES_FILENAME,cr as SCHEMA_SNAPSHOT_FILENAME,t as SCHEMA_SNAPSHOT_VERSION,Ir as SDK_LANGUAGES,_r as SDK_TARGETS,Me as SHAPES_FILENAME,Sr as SchemaSnapshotParseError,e as VERSION,Ue as WORKFLOWS_FILENAME,Ve as buildOpenApiDocument,Je as buildOpenRpcDocument,Er as buildSchemaSnapshot,b as capabilitiesUsedBy,zr as createCodegenProject,y as createTargetScope,n as describeErrorLevelFindings,v as diagnosticAt,a as diffSchemaSnapshots,N as discoverAgents,I as discoverAuthApiCalls,L as discoverContainers,P as discoverCrons,k as discoverFlags,K as discoverFunctions,z 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,be as discoverStorageRulesMetadata,Ge as discoverWorkflows,Yr as emitAgents,eo as emitApi,je as emitApp,ro as emitCollections,Xr as emitContainers,ao as emitCrons,po as emitDataModel,br as emitDrizzleSchema,co as emitFunctions,oo as emitInternalApi,ze as emitOpenApi,Qe as emitOpenApiModule,Ye as emitOpenRpc,Xe as emitOpenRpcModule,io as emitScheduler,Ur as emitServer,Hr as emitShard,so as emitVectors,Zr as emitWorkflows,fo as emitWranglerCronTriggers,c as errorAdvisoryNames,l as errorPlatformDiagnosticNames,ur as evaluateSchemaDrift,mr as findCodegenConfigFile,Kr as findLunoraSolution,dr as findProjectConfigFile,Qr as findTsconfig,gr as fingerprintSchemaSources,U as foldCapabilitySignals,f as formatAdvisories,Fr as generateSdk,ke as isD1GlobalTable,We as isHyperdriveGlobalTable,R as isTestPath,xo as isTypedSchema,m as lintSchema,T as listLunoraSourceFiles,ar as loadProjectConfig,G as mayReadCapabilityContext,Ar as parseSchemaSnapshot,er as platformMatrixIds,pr as projectConfigCandidatePaths,ne as readPackageDependencies,ir as readProjectConfigLiterals,rr as readProjectTarget,_e as readServiceBindings,Mr as redact,qr as refreshCodegenProject,or as resolveCodegenTarget,Fe as resolveServiceBindings,lr as runCodegen,Nr as schemaFromIr,Pr as secretKindOf,i as serializeSchemaSnapshot,x as sortedUniqueNames,H as sourceCapabilitySignals,d as toAdvisorContext,wr as tsconfigFingerprint,Tr as validatorIrToJsonSchema};
|
package/dist/packem_shared/{CAPABILITY_PROBES-brcmKenl.mjs → CAPABILITY_PROBES-DKYJ2K4t.mjs}
RENAMED
|
@@ -11,7 +11,7 @@ const n=[{contextProperty:"access",key:"access",moduleSpecifier:"@lunora/cloudfl
|
|
|
11
11
|
/**
|
|
12
12
|
* External database access via Hyperdrive. Non-deterministic — available only in actions. Writes here are NOT tracked by Lunora live queries; subscriptions will not re-run on external DB changes.
|
|
13
13
|
*/
|
|
14
|
-
readonly sql: import("@lunora/hyperdrive").SqlClient;`,shardBinding:{clientType:"SqlClient",instrument:"instrumentSql",missingMessage:"ctx.sql: provide a `sql` config thunk that builds a SqlClient from your driver, e.g. `sql: (env) => fromPostgresJs(postgres(env.HYPERDRIVE.connectionString))`.",stubMethods:["query"]},tier:"action"},{appMethod:{configKey:"images",doc:"Override the Images binding backing `ctx.images` (defaults to `env.IMAGES`).",method:"images"},bindingFreeExports:["buildImageDeliveryUrl","buildSignedImageUrl","parseSignedTransform","verifySignedImageUrl"],contextProperty:"images",key:"images",moduleSpecifier:"@lunora/bindings/images",requiredPackage:"@lunora/bindings",serverCtxField:`
|
|
14
|
+
readonly sql: import("@lunora/hyperdrive").SqlClient;`,shardBinding:{clientType:"SqlClient",instrument:"instrumentSql",missingMessage:"ctx.sql: provide a `sql` config thunk that builds a SqlClient from your driver, e.g. `sql: (env) => fromPostgresJs(postgres(env.HYPERDRIVE.connectionString, { fetch_types: false, max: 5 }))`.",stubMethods:["query"]},tier:"action"},{appMethod:{configKey:"images",doc:"Override the Images binding backing `ctx.images` (defaults to `env.IMAGES`).",method:"images"},bindingFreeExports:["buildImageDeliveryUrl","buildSignedImageUrl","parseSignedTransform","verifySignedImageUrl"],contextProperty:"images",key:"images",moduleSpecifier:"@lunora/bindings/images",requiredPackage:"@lunora/bindings",serverCtxField:`
|
|
15
15
|
/** Cloudflare Images transforms (resize/format/optimize). Non-deterministic — available only in actions. */
|
|
16
16
|
readonly images: import("@lunora/bindings/images").Images;`,shardBinding:{binding:{bindingType:"ImagesBindingLike",envName:"IMAGES",factory:{name:"createImages",option:"binding"}},clientType:"Images",missingMessage:"ctx.images: no Images binding found. Add an `images` binding (env.IMAGES) to wrangler.jsonc, or pass `images` to createShardDO().",stubMethods:["info","transform"]},tier:"action"},{appMethod:{configKey:"kv",doc:"Override the Workers KV binding backing `ctx.kv` (defaults to `env.KV`).",method:"kv"},bindingFreeExports:["scopeKey"],contextProperty:"kv",key:"kv",moduleSpecifier:"@lunora/bindings/kv",requiredPackage:"@lunora/bindings",serverCtxField:`
|
|
17
17
|
readonly kv: import("@lunora/bindings/kv").Kv;`,shardBinding:{binding:{bindingType:"KVNamespaceLike",envName:"KV",factory:{name:"createKv",option:"namespace"},unvouchableReads:["get","getRaw","getWithMetadata","list"]},clientType:"Kv",missingMessage:"ctx.kv: no KV binding found. Add a `kv_namespaces` binding (env.KV) to wrangler.jsonc, or pass `kv` to createShardDO().",stubMethods:["delete","get","getRaw","getWithMetadata","list","put"]},tier:"every"},{key:"mail",moduleSpecifier:"@lunora/mail"},{contextProperty:"notify",key:"notify",moduleSpecifier:"@lunora/notify"},{appMethod:{configKey:"payment",doc:"Wire the payment options backing `ctx.payments`.",method:"payment"},contextProperty:"payments",key:"payments",moduleSpecifier:"@lunora/payment",requiredPackage:"@lunora/payment",serverCtxField:`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{existsSync as z,readFileSync as Xe,mkdirSync as qt,writeFileSync as Sr,rmSync as Ne,readdirSync as Rn}from"node:fs";import{dirname as jt,join as E,relative as Fn}from"node:path";import{performance as xt}from"node:perf_hooks";import{runAdvisor as Ar}from"@lunora/advisor";import{LunoraError as L}from"@lunora/errors";import{serializeSchemaSnapshot as yr}from"./SCHEMA_SNAPSHOT_VERSION-SplX7j_9.mjs";import{toAdvisorContext as br}from"./formatAdvisories-BCVASH7N.mjs";import{Node as r,SyntaxKind as d,Project as Ht,ts as Nr,VariableDeclarationKind as Gt}from"ts-morph";import{listLunoraSourceFiles as y,lunoraRelativePath as w,descendantsOfKind as x,bindingKeyName as de,collectCallRows as C,findObjectProperty as U,collectSecurityCallRows as Pr,propertyInitializer as F,listSecurityScanFiles as Je,objectLiteralFromCallbackBody as Ln,limitNameOf as Dn,optionsObjectLiteral as Mn,handlerOf as wr,collectNodeRows as ie,chainRootOf as Ze,outermostValueWrapper as T,isWriteTarget as et,isSameNode as b,unwrapExpression as h,isConstDeclaration as re,memberAccessOf as Yt,returningFunctionOf as Ot,walkChain as Ir,RUN_METHODS as _n,functionReferenceSegments as Tr,isTestPath as Cr,isFunctionLike as oe,functionKeyOf as zn,withSourceListMemo as Or}from"./isTestPath-JdN4KXhV.mjs";import{b as X,d as H,f as M,g as Qt,c as S,a as tt,w as Xt,k as kr,l as Rr,h as Fr,m as Lr,j as kt,i as Dr}from"./attribution-DUbGYT4N.mjs";import{a as zs,r as St,i as Y,b as Mr,m as Kn,c as st,e as Jt,E as $n,C as Bn,d as _r,f as zr,g as Kr}from"./context-root-Bd08qiVR.mjs";import{a as I,i as Vn,c as te,d as Un,e as $r,f as Br,g as Wn}from"./classify-procedure-call-DtqiTjPg.mjs";import{a as A,s as Vr}from"./property-name-7cBlgK_O.mjs";import{b as Ur,a as nt}from"./module-specifiers-BctA0m_p.mjs";import{r as it,s as Wr}from"./parse-validator-CP5CL6Q7.mjs";import qr from"./discoverAuthApiCalls-Ce3BdKQr.mjs";import{i as K,r as qn}from"./database-calls-BSyvN1No.mjs";import jr from"./discoverHyperdriveCalls-Cn3087D8.mjs";import{diagnosticAt as ae}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{m as Zt,a as We,s as jn,d as Hr}from"./index-Cm7HdvL5.mjs";import{MUTATORS_FILENAME as Gr,isDefineMutatorCallee as Yr,mutatorServerImplOf as Qr,discoverMutators as Xr}from"./MUTATORS_FILENAME-PNPCtUl2.mjs";import Jr from"./discoverNondeterministicCalls-DZ_kIie5.mjs";import{discoverNotifyConfig as Zr,discoverNotifyCalls as eo}from"./NOTIFY_FILENAME-HXIKioYv.mjs";import to from"./discoverR2sqlCalls-B4N8iXlU.mjs";import so from"./discoverRlsProcedures-DhOEyJLg.mjs";import{s as es,n as no}from"./dispatch-namespace-DwTjD7BU.mjs";import{secretKindOf as io,redact as ro,isHeuristicSecretKind as oo,isSecretishName as ao}from"./redact-Cy14LEnc.mjs";import{readProjectConfigLiterals as Hn,readMergeDurableObjects as co}from"./loadProjectConfig-B7RmxIeD.mjs";import{a as Me,d as lo,r as uo}from"./modules-DEBCI7Gm.mjs";import{WORKFLOWS_FILENAME as fo,discoverWorkflows as go}from"./WORKFLOWS_FILENAME-VAXgqqP-.mjs";import{r as po}from"./json-data-Chfs2Cz5.mjs";import{a as mo,I as ho,g as vo,G as Gn,d as Eo,i as xo}from"./shared-Br_OnErI.mjs";import{createCodegenProject as So}from"./createCodegenProject-DmXl8m_P.mjs";import{findTsconfig as zE,refreshCodegenProject as KE,tsconfigFingerprint as $E}from"./createCodegenProject-DmXl8m_P.mjs";import{CAPABILITIES as Ao,usedCapabilities as yo}from"./CAPABILITY_PROBES-
|
|
1
|
+
import{existsSync as z,readFileSync as Xe,mkdirSync as qt,writeFileSync as Sr,rmSync as Ne,readdirSync as Rn}from"node:fs";import{dirname as jt,join as E,relative as Fn}from"node:path";import{performance as xt}from"node:perf_hooks";import{runAdvisor as Ar}from"@lunora/advisor";import{LunoraError as L}from"@lunora/errors";import{serializeSchemaSnapshot as yr}from"./SCHEMA_SNAPSHOT_VERSION-SplX7j_9.mjs";import{toAdvisorContext as br}from"./formatAdvisories-BCVASH7N.mjs";import{Node as r,SyntaxKind as d,Project as Ht,ts as Nr,VariableDeclarationKind as Gt}from"ts-morph";import{listLunoraSourceFiles as y,lunoraRelativePath as w,descendantsOfKind as x,bindingKeyName as de,collectCallRows as C,findObjectProperty as U,collectSecurityCallRows as Pr,propertyInitializer as F,listSecurityScanFiles as Je,objectLiteralFromCallbackBody as Ln,limitNameOf as Dn,optionsObjectLiteral as Mn,handlerOf as wr,collectNodeRows as ie,chainRootOf as Ze,outermostValueWrapper as T,isWriteTarget as et,isSameNode as b,unwrapExpression as h,isConstDeclaration as re,memberAccessOf as Yt,returningFunctionOf as Ot,walkChain as Ir,RUN_METHODS as _n,functionReferenceSegments as Tr,isTestPath as Cr,isFunctionLike as oe,functionKeyOf as zn,withSourceListMemo as Or}from"./isTestPath-JdN4KXhV.mjs";import{b as X,d as H,f as M,g as Qt,c as S,a as tt,w as Xt,k as kr,l as Rr,h as Fr,m as Lr,j as kt,i as Dr}from"./attribution-DUbGYT4N.mjs";import{a as zs,r as St,i as Y,b as Mr,m as Kn,c as st,e as Jt,E as $n,C as Bn,d as _r,f as zr,g as Kr}from"./context-root-Bd08qiVR.mjs";import{a as I,i as Vn,c as te,d as Un,e as $r,f as Br,g as Wn}from"./classify-procedure-call-DtqiTjPg.mjs";import{a as A,s as Vr}from"./property-name-7cBlgK_O.mjs";import{b as Ur,a as nt}from"./module-specifiers-BctA0m_p.mjs";import{r as it,s as Wr}from"./parse-validator-CP5CL6Q7.mjs";import qr from"./discoverAuthApiCalls-Ce3BdKQr.mjs";import{i as K,r as qn}from"./database-calls-BSyvN1No.mjs";import jr from"./discoverHyperdriveCalls-Cn3087D8.mjs";import{diagnosticAt as ae}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{m as Zt,a as We,s as jn,d as Hr}from"./index-Cm7HdvL5.mjs";import{MUTATORS_FILENAME as Gr,isDefineMutatorCallee as Yr,mutatorServerImplOf as Qr,discoverMutators as Xr}from"./MUTATORS_FILENAME-PNPCtUl2.mjs";import Jr from"./discoverNondeterministicCalls-DZ_kIie5.mjs";import{discoverNotifyConfig as Zr,discoverNotifyCalls as eo}from"./NOTIFY_FILENAME-HXIKioYv.mjs";import to from"./discoverR2sqlCalls-B4N8iXlU.mjs";import so from"./discoverRlsProcedures-DhOEyJLg.mjs";import{s as es,n as no}from"./dispatch-namespace-DwTjD7BU.mjs";import{secretKindOf as io,redact as ro,isHeuristicSecretKind as oo,isSecretishName as ao}from"./redact-Cy14LEnc.mjs";import{readProjectConfigLiterals as Hn,readMergeDurableObjects as co}from"./loadProjectConfig-B7RmxIeD.mjs";import{a as Me,d as lo,r as uo}from"./modules-DEBCI7Gm.mjs";import{WORKFLOWS_FILENAME as fo,discoverWorkflows as go}from"./WORKFLOWS_FILENAME-VAXgqqP-.mjs";import{r as po}from"./json-data-Chfs2Cz5.mjs";import{a as mo,I as ho,g as vo,G as Gn,d as Eo,i as xo}from"./shared-Br_OnErI.mjs";import{createCodegenProject as So}from"./createCodegenProject-DmXl8m_P.mjs";import{findTsconfig as zE,refreshCodegenProject as KE,tsconfigFingerprint as $E}from"./createCodegenProject-DmXl8m_P.mjs";import{CAPABILITIES as Ao,usedCapabilities as yo}from"./CAPABILITY_PROBES-DKYJ2K4t.mjs";import{isD1GlobalTable as Yn,isHyperdriveGlobalTable as Qn}from"./isD1GlobalTable-udvHAAzD.mjs";import{discoverAgents as bo}from"./AGENTS_FILENAME-BedyJsOT.mjs";import{discoverContainers as No}from"./CONTAINERS_FILENAME-T1v8pyHN.mjs";import Po from"./discoverCrons-D-vJXsgx.mjs";import{contextPropertiesRead as wo,fileWiresRequestSecretTool as Io,createTargetScope as To,discoverFeatureUsage as Co}from"./capabilitiesUsedBy-CN8HACEL.mjs";import Xn from"./readPackageDependencies-RHhGiz0k.mjs";import{PROJECT_CONFIG_FILENAMES as Oo,findProjectConfigFile as ko}from"./PROJECT_CONFIG_FILENAMES-CLfsyvjA.mjs";import{discoverQueueDeclarations as Ro}from"./QUEUES_FILENAME-Dt5RG_P0.mjs";import{discoverSandboxUsage as Fo}from"./discoverSandboxUsage-CdGRnVU2.mjs";import{resolveServiceBindings as Lo}from"./readServiceBindings-BA49C6aN.mjs";import Do from"./discoverStorageRulesMetadata-CJ7h6SPK.mjs";import{resolveCodegenTarget as Rt,gatePlatformFeatures as Mo,readTargetDiagnostics as _o,vectorizeDimensionDiagnostics as zo,liveStreamsDeliveryAuthorizationDiagnostic as Ko,socketRoutesDeliveryAuthorizationDiagnostic as $o,studioPlatformFor as Bo,platformFeatureAvailable as Vo}from"./DEFAULT_TARGET-3OLdJhTj.mjs";import{i as Uo}from"./schema-BgM8A3XV.mjs";import{b as Jn,e as Wo}from"./shard-D9_wgrV7.mjs";import{e as qo,a as jo}from"./server-DC4PW_2M.mjs";import{emitDataModel as Ho}from"./emitDataModel-Bba2y2yt.mjs";import{i as Go,a as Yo,e as Qo,b as Xo,d as Jo,c as Zo}from"./unwrap-handler-return-DTcee6Ng.mjs";import ea from"./discoverFunctions-BdEY3nbv.mjs";import ta from"./discoverHttpRoutes-Hy2UrcrN.mjs";import sa from"./discoverInserts-DIzIGlyG.mjs";import{e as Zn}from"./exported-procedure-chains-BaCIhnJ7.mjs";import na from"./discoverMigrations-Bv8kNIgy.mjs";import ia from"./discoverQueries-KjOdhrk6.mjs";import ra from"./discoverRlsMetadata-Dq6iSXnC.mjs";import oa from"./discoverSchema-DmkjooXZ.mjs";import{discoverShapes as aa}from"./SHAPES_FILENAME-mgEi072Z.mjs";import{i as ca}from"./reserved-words-CW1QFbTd.mjs";import{emitAuthModule as la,emitApp as da}from"./emitApp-CzDMr_iP.mjs";import{readJsonSync as ua}from"@visulima/fs";import{buildSchemaSnapshot as fa}from"./SchemaSnapshotParseError-CjKSMuex.mjs";import{buildOpenApiDocument as ga,emitOpenApiModule as pa}from"./buildOpenApiDocument-Cju685VK.mjs";import{buildOpenRpcDocument as ma,emitOpenRpcModule as ha}from"./OPENRPC_VERSION-CTR_g_IE.mjs";import{w as va,u as Ea,v as xa,t as Sa,x as Aa}from"./shard-runtime-B9K29SyO.mjs";import{emitCollections as ya,emitSeed as ba,emitApi as Na,emitInternalApi as Pa}from"./emitApi-CCjh0ICg.mjs";import{emitCrons as wa,emitScheduler as Ia,emitShardRegistry as Ta,emitDurableObjects as Ca,emitVectors as Oa,emitWranglerCronTriggers as ka}from"./emitCrons-CY8IQfAI.mjs";import Ra from"./emitDrizzleSchema-CD4hPtUP.mjs";import{LAZY_FUNCTION_DIRECTORY as ei,emitFunctions as Fa,emitLazyFunctionModules as La}from"./emitFunctions-C3WOlVN0.mjs";const Da=(e,t=!1)=>{if(e.length===0)return"";const s=Eo(t),n=e.map(c=>{if(mo(c.exportName,"live stream export name"),!ho.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=>{vo(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 v=u.fields.map(B=>`\${encodeURIComponent(key.${B})}`).join(":");return` ${u.name}: (key: LiveTopicKey<${f}>): ${g} => ({
|
|
2
2
|
__lunoraLive: ${m},
|
|
3
3
|
topic: \`${u.name}:${v}\`,
|
|
4
4
|
}),`});return` ${c.exportName}: {
|
package/dist/packem_shared/{capabilitiesUsedBy-Xncj__oq.mjs → capabilitiesUsedBy-CN8HACEL.mjs}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{SyntaxKind as g,Node as m,ts as w,Project as R}from"ts-morph";import{CAPABILITIES as u}from"./CAPABILITY_PROBES-
|
|
1
|
+
import{SyntaxKind as g,Node as m,ts as w,Project as R}from"ts-morph";import{CAPABILITIES as u}from"./CAPABILITY_PROBES-DKYJ2K4t.mjs";import{descendantsOfKind as l,bindingKeyName as y,listLunoraSourceFiles as D}from"./isTestPath-JdN4KXhV.mjs";import{scanImportDeclaration as P,noSandboxUsage as v}from"./discoverSandboxUsage-CdGRnVU2.mjs";const f="ctx",A=(e,t,s)=>{for(const n of l(e,g.ElementAccessExpression)){const r=n.getArgumentExpression();t(n.getExpression())&&r!==void 0&&(m.isStringLiteral(r)||m.isNoSubstitutionTemplateLiteral(r))&&s.add(r.getLiteralValue())}},L=e=>{const t=new Set,s=new Set,n=new Set(l(e,g.Parameter).map(o=>o.getName())),r=l(e,g.VariableDeclaration).some(o=>{const c=o.getInitializer();return o.getName()===f&&m.isIdentifier(c)&&n.has(c.getText())});(n.has(f)||r)&&s.add(f);const i=o=>{if(m.isObjectBindingPattern(o))for(const c of o.getElements()){const d=y(c);d&&t.add(d)}};for(const o of l(e,g.BindingElement)){if(y(o)!==f)continue;const c=o.getNameNode();m.isIdentifier(c)?s.add(c.getText()):i(c)}const a=o=>m.isIdentifier(o)&&s.has(o.getText());for(const o of l(e,g.PropertyAccessExpression))a(o.getExpression())&&t.add(o.getName());A(e,a,t);for(const o of l(e,g.VariableDeclaration)){const c=o.getInitializer();c!==void 0&&a(c)&&i(o.getNameNode())}return t},M=e=>{if(e.isTypeOnly())return!0;if(m.isExportDeclaration(e)){const s=e.getNamedExports();return!e.isNamespaceExport()&&s.length>0&&s.every(n=>n.isTypeOnly())}const t=e.getNamedImports();return e.getDefaultImport()===void 0&&e.getNamespaceImport()===void 0&&t.length>0&&t.every(s=>s.isTypeOnly())},C=new Map(u.flatMap(({bindingFreeExports:e,moduleSpecifier:t})=>e===void 0?[]:[[t,new Set(e)]])),V=(e,t)=>{const s=C.get(t);if(s===void 0||m.isImportDeclaration(e)&&(e.getDefaultImport()!==void 0||e.getNamespaceImport()!==void 0))return!1;const n=m.isExportDeclaration(e)?e.getNamedExports():e.getNamedImports();return n.length>0&&n.every(r=>r.isTypeOnly()||s.has(r.getName()))},F=e=>{const t=new Set;for(const s of l(e,g.CallExpression)){const[n]=s.getArguments();s.getExpression().getKind()===g.ImportKeyword&&(m.isStringLiteral(n)||m.isNoSubstitutionTemplateLiteral(n))&&t.add(n.getLiteralValue())}return t},N="@lunora/agent",E="requestSecretTool",I=e=>e.startsWith("./")||e.startsWith("../"),S=e=>e.getAliasNode()?.getText()??e.getNameNode().getText(),z=(e,t)=>{const s=e!==void 0&&m.isCallExpression(e)?e.getExpression():e;return s!==void 0&&m.isIdentifier(s)&&t.has(s.getText())},_=e=>{const t=new Set;for(const s of e.getImportDeclarations())if(!(s.getModuleSpecifierValue()!==N||s.isTypeOnly()))for(const n of s.getNamedImports())!n.isTypeOnly()&&n.getNameNode().getText()===E&&t.add(S(n));return t},p=e=>({names:new Set(e),namespaces:new Map}),x=()=>({projects:new Map,origins:new Map}),k=(e,t)=>{if(e.origins.has(t))return t;let s=e.projects.get(t);return s===void 0&&(s=new R({compilerOptions:{...t.getCompilerOptions(),allowJs:!0},fileSystem:t.getFileSystem(),skipAddingFilesFromTsConfig:!0,skipFileDependencyResolution:!0,skipLoadingLibFiles:!0}),e.projects.set(t,s),e.origins.set(s,t)),s},b=(e,t,s)=>{const n=t.getSourceFile(),r=n.getProject(),i=e.origins.get(r)??r,{resolvedModule:a}=w.resolveModuleName(s,n.getFilePath(),i.getCompilerOptions(),i.getModuleResolutionHost()),o=a?.resolvedFileName;if(o===void 0)return;const c=i.getSourceFile(o)??r.getSourceFile(o);if(c!==void 0)return c;const d=k(e,r);return d.getSourceFile(o)??d.addSourceFileAtPath(o)},B=(e,t,s)=>{const n=e.getNamespaceExport();if(n!==void 0){const r=new Set(t.names);t.namespaces.forEach((i,a)=>{i.forEach(o=>{r.add(`${a}.${o}`)})}),r.size>0&&s.namespaces.set(n.getName(),r);return}if(!e.hasNamedExports()){t.names.forEach(r=>s.names.add(r)),t.namespaces.forEach((r,i)=>s.namespaces.set(i,r));return}for(const r of e.getNamedExports()){if(r.isTypeOnly())continue;const i=r.getNameNode().getText(),a=S(r);t.names.has(i)&&s.names.add(a);const o=t.namespaces.get(i);o!==void 0&&s.namespaces.set(a,o)}},K=(e,t,s,n)=>{const r=t.getModuleSpecifierValue();if(r===void 0)return p(s);if(r===N)return p([E]);const i=I(r)?b(e,t,r):void 0;return i===void 0?p([]):n(i)},h=(e,t,s)=>{const n=p([]),r=e.getFilePath();if(t.has(r))return n;t.add(r);const i=_(e);for(const a of e.getExportDeclarations())a.isTypeOnly()||B(a,K(s,a,i,o=>h(o,t,s)),n);for(const a of e.getVariableStatements())if(a.hasExportKeyword())for(const o of a.getDeclarations())z(o.getInitializer(),i)&&n.names.add(o.getName());return t.delete(r),n},W=(e,t,s)=>{const n=e.getModuleSpecifierValue();if(n===N)return p([E]);const r=I(n)?b(s,e,n):void 0;return r===void 0?p([]):h(r,new Set([t.getFilePath()]),s)},$=e=>{const t=e.getPropertyNameNode();return t===void 0?e.getName():m.isStringLiteral(t)?t.getLiteralValue():t.getText()},T=(e,t,s)=>{const n=(o,c)=>o===t?s.has(c):o.startsWith(`${t}.`)&&s.has(`${o.slice(t.length+1)}.${c}`),r=e.getDescendantsOfKind(g.PropertyAccessExpression).some(o=>n(o.getExpression().getText(),o.getName())),i=l(e,g.ElementAccessExpression).some(o=>{const c=o.getArgumentExpression();return m.isStringLiteral(c)&&n(o.getExpression().getText(),c.getLiteralValue())}),a=l(e,g.VariableDeclaration).some(o=>{const c=o.getInitializer(),d=o.getNameNode();return c!==void 0&&m.isObjectBindingPattern(d)&&d.getElements().some(O=>n(c.getText(),$(O)))});return r||i||a},j=(e,t,s)=>{if(s.names.has(t.getNameNode().getText()))return!0;const n=s.namespaces.get(t.getNameNode().getText());return n!==void 0&&T(e,S(t),n)},q=(e,t=x())=>e.getImportDeclarations().some(s=>{if(s.isTypeOnly())return!1;const n=W(s,e,t);if(n.names.size===0&&n.namespaces.size===0)return!1;const r=s.getDefaultImport(),i=s.getNamespaceImport();return r!==void 0&&(n.names.has("default")||T(e,r.getText(),n.namespaces.get("default")??new Set))||s.getNamedImports().some(o=>!o.isTypeOnly()&&j(e,o,n))||i!==void 0&&T(e,i.getText(),n.names)}),U=(e,t=x())=>{const s=e.getImportDeclarations(),n=v();for(const r of s){const i=P(r);for(const a of Object.keys(n))n[a]||=i[a]}return{contextReads:L(e),dynamicImports:F(e),requestSecretTool:q(e,t),sandboxTools:n,valueImports:new Set([...s,...e.getExportDeclarations()].flatMap(r=>{const i=r.getModuleSpecifierValue();return i===void 0||M(r)||V(r,i)?[]:[i]}))}},X=e=>{const t=new Set,s=new Set,n=v(),r=new Set;let i=!1;for(const a of e){i||=a.requestSecretTool;for(const o of a.contextReads)t.add(o);for(const o of a.dynamicImports)s.add(o);for(const o of a.valueImports)r.add(o);for(const o of Object.keys(n))n[o]||=a.sandboxTools[o]}return{contextReads:t,dynamicImports:s,requestSecretTool:i,sandboxTools:n,valueImports:r}},G=e=>new Set(u.filter(({contextProperty:t,moduleSpecifier:s})=>e.valueImports.has(s)||t!==void 0&&e.contextReads.has(t)).map(({key:t})=>t)),H=new RegExp(String.raw`\b${f}\b`,"u"),J=new RegExp(String.raw`\b(?:${u.flatMap(({contextProperty:e})=>e===void 0?[]:[e]).join("|")})\b`,"u"),te=e=>H.test(e)&&J.test(e),se=(e,t)=>{const s=x(),n=X(D(t).map(i=>U(e.getSourceFile(i)??e.addSourceFileAtPath(i),s))),r=G(n);return Object.fromEntries(u.map(({key:i})=>[i,r.has(i)]))};export{G as capabilitiesUsedBy,L as contextPropertiesRead,x as createTargetScope,se as discoverFeatureUsage,q as fileWiresRequestSecretTool,X as foldCapabilitySignals,te as mayReadCapabilityContext,U as sourceCapabilitySignals};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./json-data-Chfs2Cz5.mjs";import{p as i,j as r,t as n,h as o,u as g,k as F,d as u,x as p,n as l,g as f,f as d,m as k,i as w,v as W,l as v,w as A}from"./shard-runtime-
|
|
1
|
+
import"./json-data-Chfs2Cz5.mjs";import{p as i,j as r,t as n,h as o,u as g,k as F,d as u,x as p,n as l,g as f,f as d,m as k,i as w,v as W,l as v,w as A}from"./shard-runtime-B9K29SyO.mjs";import"./shared-Br_OnErI.mjs";import"./platform-8oj7iXQy.mjs";export{i as buildDoTypeImports,r as emitAgentFragments,n as emitAgents,o as emitContainerFragments,g as emitContainers,F as emitPaymentFragments,u as emitQueueFragments,p as emitQueues,l as emitQueuesMetadataFragments,f as emitServiceFragments,d as emitTopicFragments,k as emitWorkflowEventFragments,w as emitWorkflowFragments,W as emitWorkflows,v as emitWorkflowsMetadataFragments,A as queueAliasFindings};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{APP_METHOD_CAPABILITIES as T}from"./CAPABILITY_PROBES-
|
|
1
|
+
import{APP_METHOD_CAPABILITIES as T}from"./CAPABILITY_PROBES-DKYJ2K4t.mjs";import{i as q}from"./schema-BgM8A3XV.mjs";import{a as N,I,G as y}from"./shared-Br_OnErI.mjs";const L={configKey:"vectors",doc:"Wire the Vectorize index map backing `ctx.vectors`.",method:"vectors"},f=e=>[...T.filter(({key:t})=>e.capabilities.has(t)).map(({appMethod:t})=>t),...e.hasVectors?[L]:[]],w=e=>f(e).length>0,k=e=>(e.emailAgents?.length??0)>0,c=e=>e.tables.some(t=>q(t)),p=e=>e.liveStreams===!0&&(e.liveStreamDeclarations?.length??0)>0,j=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);
|
|
@@ -339,7 +339,7 @@ const buildGlobalCdcApplier =
|
|
|
339
339
|
|
|
340
340
|
return request.changes.length;
|
|
341
341
|
};
|
|
342
|
-
`:"",$=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(postgres(env.HYPERDRIVE.connectionString)))`. 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}']:[]],M=e=>[...e.hasAccess?[" private accessSelector?: Selector<Env, CreateAccessResolverOptions | undefined>;"]:[]," 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> = {};"]:[],...c(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:t,doc:r,method:a})=>` /** ${r} */
|
|
342
|
+
`:"",$=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(postgres(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}']:[]],M=e=>[...e.hasAccess?[" private accessSelector?: Selector<Env, CreateAccessResolverOptions | undefined>;"]:[]," 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> = {};"]:[],...c(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:t,doc:r,method:a})=>` /** ${r} */
|
|
343
343
|
public ${a}(factory: (env: Env) => ReturnType<NonNullable<ShardConfig["${t}"]>>): this {
|
|
344
344
|
this.shardExtras.${t} = factory as NonNullable<ShardConfig["${t}"]>;
|
|
345
345
|
|
|
@@ -491,7 +491,7 @@ const buildGlobalCdcApplier =
|
|
|
491
491
|
: {}),`]:[],...c(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 r.length>0?`
|
|
492
492
|
${r.join(`
|
|
493
493
|
`)}
|
|
494
|
-
`:""},H=e=>e?['import * as lunoraIdentityContract from "../identity.js";']:[],U=(e,t)=>e?['import type { CreateAccessResolverOptions } from "@lunora/cloudflare-access";',`import { createAccessResolver${t?", composeResolvers":""} } from "@lunora/cloudflare-access";`]:[],F=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";']:[],z=e=>e?['import notifyConfig from "../notify.js";']:[],K=e=>k(e)?['import { dispatchAgentEmail } from "@lunora/agent/inbound";']:[],V=e=>k(e)?['import * as lunoraAgentDefinitions from "../agents.js";']:[],Y=e=>{const{hasFramework:t,hasGlobal:r,hasHyperdriveGlobal:a,hasQueue:
|
|
494
|
+
`:""},H=e=>e?['import * as lunoraIdentityContract from "../identity.js";']:[],U=(e,t)=>e?['import type { CreateAccessResolverOptions } from "@lunora/cloudflare-access";',`import { createAccessResolver${t?", composeResolvers":""} } from "@lunora/cloudflare-access";`]:[],F=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";']:[],z=e=>e?['import notifyConfig from "../notify.js";']:[],K=e=>k(e)?['import { dispatchAgentEmail } from "@lunora/agent/inbound";']:[],V=e=>k(e)?['import * as lunoraAgentDefinitions from "../agents.js";']:[],Y=e=>{const{hasFramework:t,hasGlobal:r,hasHyperdriveGlobal:a,hasQueue:s,useUmbrella:o}=e,i=o?"lunorash/runtime":"@lunora/runtime",d=["ExecutionContextLike","HttpRouterLike","LunoraWorker","Route","ScheduledControllerLike","ShardNamespaceLike",...c(e)?["ShardRegistryRpc"]:[],"WorkerOptions",...s?["TriggerTrace"]:[],...r?["GlobalIntrospector"]:[],...e.tables.length>0?["ShardingInfo"]:[],...t?["FrameworkHostHandler"]:[]],l=[...r||a?["createCrossShardRelationCapabilities"]:[],...c(e)?["createDynamicShardRegistry","createQueryCoordinator"]:[],"createWorker",...e.jurisdiction?["declareAppJurisdiction"]:[],"resolveLogArchiveFromEnv",...e.hasAuth?["memoizeIdentity"]:[],...t?["withFrameworkWorker"]:[]].join(", ");return[`import type { ${[...d].toSorted((n,u)=>n.localeCompare(u)).join(", ")} } from "${i}";`,`import { ${l} } from "${i}";`]},X=e=>{const{hasAccess:t,hasAuth:r,hasGlobal:a,hasHyperdriveGlobal:s,hasKvIntrospector:o,hasQueue:i,hasScheduler:d,hasStorage:l,hasWorkflow:n}=e;return[...r?['import type { AuthNamespaceLike, LunoraAuth, LunoraAuthOptions } from "@lunora/auth";','import type * as LunoraAuthModule from "./authModule.js";']:[],...U(t,r),...J(a),...s?['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";']:[],...F(o),...Q(e.hasVectors),...d?['import type { DurableObjectNamespaceLike } from "@lunora/scheduler";','import { createScheduler } from "@lunora/scheduler";']:[],...l?['import type { R2BucketLike, R2S3Credentials, Storage } from "@lunora/storage";','import { createBucketStorage, createStorage } from "@lunora/storage";']:[],...n?['import { createWorkflowsRestClient } from "@lunora/workflow";']:[],...K(e),...Y(e),"",...H(e.identity),...V(e),...a||s?['import schema from "../schema.js";']:[],...z(e.hasNotify),'import { LUNORA_CRONS } from "./crons.js";','import { LUNORA_FUNCTIONS } from "./functions.js";',...i?['import { createQueueCaptureSink, dispatchQueueBatch, shouldCaptureQueue } from "@lunora/queue";','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";']:[]]},Z=e=>e.jurisdiction&&e.jurisdictionPinsAuth===!0?`
|
|
495
495
|
// The schema's jurisdiction pins the auth object like every other DO.
|
|
496
496
|
jurisdiction: ${JSON.stringify(e.jurisdiction)},`:"",ee=e=>typeof e=="string"?`{ mode: { kind: ${JSON.stringify(e)} } }`:`{ mode: { field: ${JSON.stringify(e.field)}, kind: "shardBy" } }`,te=e=>[...e.tables.length>0?[` const tableSharding = new Map<string, ShardingInfo>([
|
|
497
497
|
${e.tables.map(t=>` [${JSON.stringify(t.name)}, ${ee(t.shardMode)}],`).join(`
|
|
@@ -503,10 +503,10 @@ ${e.tables.map(t=>` [${JSON.stringify(t.name)}, ${ee(t.shardMode)}],`
|
|
|
503
503
|
|
|
504
504
|
if (shardRegistry) {
|
|
505
505
|
options.queryCoordinator = createQueryCoordinator({ registry: createDynamicShardRegistry({ ${e.jurisdiction?`jurisdiction: ${JSON.stringify(e.jurisdiction)}, `:""}env, namespace: shardRegistry }) });
|
|
506
|
-
}`]:[]],S=e=>(e.liveStreamDeclarations??[]).map(t=>{if(N(t.exportName,"live stream export name"),!I.test(t.filePath))throw new Error(`@lunora/codegen: live stream file path is not safe to import: ${JSON.stringify(t.filePath)}`);return` { id: ${JSON.stringify(t.id)}, load: () => import("../${t.filePath}.js").then((m) => m.${t.exportName}) },`}),re=e=>p(e)?[" httpRouter: liveStreamRouter([",...S(e)," ], this.httpRouterApp),"]:[" ...(this.httpRouterApp ? { httpRouter: this.httpRouterApp } : {}),"],ae=e=>p(e)?[" liveStreamRoutes: [",...(e.liveStreamDeclarations??[]).flatMap(t=>[` ${JSON.stringify(`GET /live/${t.id}/connect`)},`,` ${JSON.stringify(`POST /live/${t.id}/control`)},`])," ],"]:[],
|
|
506
|
+
}`]:[]],S=e=>(e.liveStreamDeclarations??[]).map(t=>{if(N(t.exportName,"live stream export name"),!I.test(t.filePath))throw new Error(`@lunora/codegen: live stream file path is not safe to import: ${JSON.stringify(t.filePath)}`);return` { id: ${JSON.stringify(t.id)}, load: () => import("../${t.filePath}.js").then((m) => m.${t.exportName}) },`}),re=e=>p(e)?[" httpRouter: liveStreamRouter([",...S(e)," ], this.httpRouterApp),"]:[" ...(this.httpRouterApp ? { httpRouter: this.httpRouterApp } : {}),"],ae=e=>p(e)?[" liveStreamRoutes: [",...(e.liveStreamDeclarations??[]).flatMap(t=>[` ${JSON.stringify(`GET /live/${t.id}/connect`)},`,` ${JSON.stringify(`POST /live/${t.id}/control`)},`])," ],"]:[],se=e=>p(e)?`liveStreamRouter([
|
|
507
507
|
${S(e).join(`
|
|
508
508
|
`)}
|
|
509
|
-
], host)`:"host",
|
|
509
|
+
], host)`:"host",ne=e=>[...te(e),...e.hasScheduler?[` if (this.schedulerDeclaration) {
|
|
510
510
|
options.schedulerDO = this.schedulerDeclaration.namespace(env);
|
|
511
511
|
}`]:[],...e.hasWorkflow?[` options.workflowsClient = (workflowEnv) => {
|
|
512
512
|
const source = workflowEnv as Record<string, unknown>;
|
|
@@ -803,10 +803,10 @@ ${e.voiceAgents.map(t=>` ${JSON.stringify(t.exportName)}: (env as Rec
|
|
|
803
803
|
};`]:[]],oe=e=>[" 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,"]:[],...e.hasQueue?[` queue: (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], 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>,"," traceparent: trigger.traceparent,"," fetchImpl: queueFetch,",...e.liveStreams?[" live: queueLive,"]:[]," }),"]:[],...re(e),...ae(e)," routes: this.routeMap,",...e.liveStreamsWithheld?[" liveStreams: false,"]:[]," shardDO: this.shardSelector?.(env) ?? (undefined as unknown as ShardNamespaceLike),"],ie=e=>e?`
|
|
804
804
|
/** The identity memo per \`env\` object, owned by one assembled worker. */
|
|
805
805
|
type IdentityMemoStore = WeakMap<object, ReturnType<typeof memoizeIdentity>>;
|
|
806
|
-
`:"",E=e=>e.hasAuth||e.wantsArchitecture||e.wantsOpenApi||e.wantsOpenRpc,le=e=>{if(!E(e))return"";const r=[[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,
|
|
806
|
+
`:"",E=e=>e.hasAuth||e.wantsArchitecture||e.wantsOpenApi||e.wantsOpenRpc,le=e=>{if(!E(e))return"";const r=[[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,s,o])=>[a,s,o]);return`
|
|
807
807
|
/** What the worker reads only once a request arrives: loaded then, not at isolate startup (Cloudflare caps startup at 1 s of CPU). */
|
|
808
808
|
interface DeferredModules {
|
|
809
|
-
${r.map(([a,
|
|
809
|
+
${r.map(([a,s])=>` ${a}: ${s};`).join(`
|
|
810
810
|
`)}
|
|
811
811
|
}
|
|
812
812
|
|
|
@@ -816,13 +816,13 @@ let deferredModules: Promise<DeferredModules> | undefined;
|
|
|
816
816
|
const loadDeferredModules = (): Promise<DeferredModules> =>
|
|
817
817
|
(deferredModules ??= (async (): Promise<DeferredModules> => {
|
|
818
818
|
return {
|
|
819
|
-
${r.map(([a,,
|
|
819
|
+
${r.map(([a,,s])=>` ${a}: ${s},`).join(`
|
|
820
820
|
`)}
|
|
821
821
|
};
|
|
822
822
|
})());
|
|
823
823
|
`},ce=e=>E(e)?{asyncIfDeferred:"async ",deferredArgument:", deferred",deferredParameter:", deferred: DeferredModules",loadDeferredLine:`
|
|
824
824
|
const deferred = await loadDeferredModules();`}:{asyncIfDeferred:"",deferredArgument:"",deferredParameter:"",loadDeferredLine:""},be=e=>e?`${y}export { authDiscoveryPathsFor, createAuth, createAuthAdmin, createAuthAuditReader, createDoAuthWiring, d1Executor, handleAuthDiscoveryRequest, handleAuthRequest, lunoraD1Adapter } from "@lunora/auth/worker";
|
|
825
|
-
`:"",de=e=>[...e.hasAuth?["AuthDeclaration"]:[],"ComposedApp",...e.hasGlobal?["GlobalDeclaration"]:[],"LunoraConfig",...e.hasScheduler?["SchedulerDeclaration"]:[],"Selector",...e.hasStorage?["StorageDeclaration"]:[]].toSorted((t,r)=>t.localeCompare(r)).join(", "),me=e=>{const t=(e.hasVectors??!0)&&(e.vectorIndexCount??0)>0,r={...e,hasVectors:t},{hasAuth:a}=r,
|
|
825
|
+
`:"",de=e=>[...e.hasAuth?["AuthDeclaration"]:[],"ComposedApp",...e.hasGlobal?["GlobalDeclaration"]:[],"LunoraConfig",...e.hasScheduler?["SchedulerDeclaration"]:[],"Selector",...e.hasStorage?["StorageDeclaration"]:[]].toSorted((t,r)=>t.localeCompare(r)).join(", "),me=e=>{const t=(e.hasVectors??!0)&&(e.vectorIndexCount??0)>0,r={...e,hasVectors:t},{hasAuth:a}=r,s=$(r),o=ne(r),i=a?` let auth: LunoraAuth | null = null;
|
|
826
826
|
let authInit: Promise<void> | null = null;
|
|
827
827
|
// One memo per env for THIS assembled worker: a framework-hosted worker rebuilds its options per
|
|
828
828
|
// request and must reuse it, but a second \`assemble()\` has its own auth closure and must not share.
|
|
@@ -880,9 +880,9 @@ ${r.map(([a,,n])=>` ${a}: ${n},`).join(`
|
|
|
880
880
|
authInit = null;
|
|
881
881
|
throw error;
|
|
882
882
|
}));
|
|
883
|
-
`:"",{asyncIfDeferred:l,deferredArgument:
|
|
884
|
-
await ensureAuth(env);`:"",b=`${a?"() => auth, identityMemos":"() => null"}${
|
|
885
|
-
host ? withFrameworkWorker(${
|
|
883
|
+
`:"",{asyncIfDeferred:l,deferredArgument:n,deferredParameter:u,loadDeferredLine:h}=ce(r),D=a?`
|
|
884
|
+
await ensureAuth(env);`:"",b=`${a?"() => auth, identityMemos":"() => null"}${n}`,R=`${a?"getAuth: () => LunoraAuth | null, identityMemos: IdentityMemoStore":"_getAuth: () => null"}${u}`,m=`env: Env${u}`,A=r.hasFramework?` const buildWorker = (${m}): LunoraWorker =>
|
|
885
|
+
host ? withFrameworkWorker(${se(r)}, (hostEnv) => this.buildWorkerOptions(hostEnv as Env, ${b})) : createWorker(this.buildWorkerOptions(env, ${b}));`:` const buildWorker = (${m}): LunoraWorker => createWorker(this.buildWorkerOptions(env, ${b}));`,x=r.hasFramework?"host?: FrameworkHostHandler":"",g=r.emailAgents??[],C=g.length>0?` composed.email = dispatchAgentEmail([
|
|
886
886
|
${g.map(v=>` { agent: lunoraAgentDefinitions.${v.exportName}, className: ${JSON.stringify(v.className)} },`).join(`
|
|
887
887
|
`)}
|
|
888
888
|
]);
|
|
@@ -904,9 +904,9 @@ ${ie(a)}${le(r)}${r.jurisdiction?`
|
|
|
904
904
|
// \`@lunora/mail\` reads it to pin its shard RPC like every other DO path.
|
|
905
905
|
declareAppJurisdiction(${JSON.stringify(r.jurisdiction)});
|
|
906
906
|
`:""}
|
|
907
|
-
${
|
|
907
|
+
${s.join(`
|
|
908
908
|
|
|
909
|
-
`)}${
|
|
909
|
+
`)}${s.length>0?`
|
|
910
910
|
|
|
911
911
|
`:""}/** The composed app: a Cloudflare module worker (\`fetch\` / \`scheduled\` / optional \`email\`) plus the \`ShardDO\` class binding. */
|
|
912
912
|
interface ComposedApp extends LunoraWorker {
|
|
@@ -949,22 +949,22 @@ ${A}
|
|
|
949
949
|
ShardDO,
|
|
950
950
|
fetch: async (request: Request, rawEnv: unknown, context: ExecutionContextLike): Promise<Response> => {
|
|
951
951
|
const env = rawEnv as Env;${h}${D}
|
|
952
|
-
worker ??= buildWorker(env${
|
|
952
|
+
worker ??= buildWorker(env${n});
|
|
953
953
|
|
|
954
954
|
return worker.fetch(request, rawEnv, context);
|
|
955
955
|
},
|
|
956
956
|
scheduled: async (controller: ScheduledControllerLike, rawEnv: unknown, context: ExecutionContextLike): Promise<void> => {${h}
|
|
957
|
-
worker ??= buildWorker(rawEnv as Env${
|
|
957
|
+
worker ??= buildWorker(rawEnv as Env${n});
|
|
958
958
|
|
|
959
959
|
return worker.scheduled(controller, rawEnv, context);
|
|
960
960
|
},
|
|
961
961
|
serverQuery: ${l}(request, rawEnv, reference, args, options) => {${h}
|
|
962
|
-
worker ??= buildWorker(rawEnv as Env${
|
|
962
|
+
worker ??= buildWorker(rawEnv as Env${n});
|
|
963
963
|
|
|
964
964
|
return worker.serverQuery(request, rawEnv, reference, args, options);
|
|
965
965
|
},${r.hasQueue||r.hasFramework?`
|
|
966
966
|
queue: async (batch: unknown, rawEnv: unknown, context: ExecutionContextLike): Promise<void> => {${h}
|
|
967
|
-
worker ??= buildWorker(rawEnv as Env${
|
|
967
|
+
worker ??= buildWorker(rawEnv as Env${n});
|
|
968
968
|
|
|
969
969
|
return worker.queue?.(batch, rawEnv, context);
|
|
970
970
|
},`:""}
|
|
@@ -982,7 +982,7 @@ ${r.hasFramework?`
|
|
|
982
982
|
// dropping the entry.
|
|
983
983
|
if (!composed.email && host && typeof host === "object" && typeof host.email === "function") {
|
|
984
984
|
composed.email = ${l}(message, rawEnv, context) => {${h}
|
|
985
|
-
worker ??= buildWorker(rawEnv as Env${
|
|
985
|
+
worker ??= buildWorker(rawEnv as Env${n});
|
|
986
986
|
|
|
987
987
|
return worker.email?.(message, rawEnv, context) ?? Promise.resolve();
|
|
988
988
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./CAPABILITY_PROBES-DKYJ2K4t.mjs";import{e}from"./server-DC4PW_2M.mjs";import"./shared-Br_OnErI.mjs";import"./platform-8oj7iXQy.mjs";export{e as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./SCHEMA_SNAPSHOT_VERSION-SplX7j_9.mjs";import"./isD1GlobalTable-udvHAAzD.mjs";import"./json-data-Chfs2Cz5.mjs";import{e as d}from"./shard-
|
|
1
|
+
import"./SCHEMA_SNAPSHOT_VERSION-SplX7j_9.mjs";import"./isD1GlobalTable-udvHAAzD.mjs";import"./json-data-Chfs2Cz5.mjs";import{e as d}from"./shard-D9_wgrV7.mjs";import"./shard-runtime-B9K29SyO.mjs";import"./shared-Br_OnErI.mjs";import"./platform-8oj7iXQy.mjs";import"./schema-BgM8A3XV.mjs";export{d as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{CAPABILITIES as Qe}from"./CAPABILITY_PROBES-
|
|
1
|
+
import{CAPABILITIES as Qe}from"./CAPABILITY_PROBES-DKYJ2K4t.mjs";import{existsSync as D,readdirSync as de,readlinkSync as ce,lstatSync as qe,statSync as Le}from"node:fs";import{join as h,relative as y,dirname as d,sep as ue,isAbsolute as _e,resolve as Ve,basename as Ge}from"node:path";import{ts as c,Project as He}from"ts-morph";import{G as pe,a as N,u as Ke,d as Ue}from"./shared-Br_OnErI.mjs";import{p as Je}from"./platform-8oj7iXQy.mjs";const me=/(?:\.d)?\.([cm]?)tsx?$/u,ze=t=>t.replace(me,".d.$1ts"),ye=(t,o)=>{const a=y(t,o).split(ue).join("/").replace(me,".$1js");return a.startsWith(".")?a:`./${a}`},he=t=>t.replaceAll("\\","/"),Y=(t,o,a)=>he(h(t,ze(y(o,a)))),Ye=t=>ye(".",h("services",t.name,y(d(t.wranglerPath),t.main))),Xe=t=>{const o=[],a=e=>{(c.isImportDeclaration(e)||c.isExportDeclaration(e))&&e.moduleSpecifier!==void 0&&c.isStringLiteral(e.moduleSpecifier)?o.push(e.moduleSpecifier):c.isImportTypeNode(e)&&c.isLiteralTypeNode(e.argument)&&c.isStringLiteral(e.argument.literal)&&o.push(e.argument.literal),c.forEachChild(e,a)};return a(t),o},T=t=>{const{mtimeMs:o,size:a}=Le(t);return`${String(o)}:${String(a)}`},Ze=new Set([".git",".wrangler","dist","node_modules","target"]),fe=t=>de(t,{withFileTypes:!0}).flatMap(o=>{const a=h(t,o.name);return o.isSymbolicLink()?[`${a}->${ce(a)}`]:o.isDirectory()&&o.name.startsWith("@")?[`${a}:${T(a)}`,...fe(a)]:[]}),be=t=>[`${t}:${T(t)}`,...fe(t)],ge=t=>{const o=h(t,"node_modules"),a=D(o)?be(o):[],e=d(t);return e===t?a:[...a,...ge(e)]},et=(t,o)=>{const a=[];try{const e=s=>{for(const n of de(s,{withFileTypes:!0})){const l=h(s,n.name);if(l!==o)if(n.isSymbolicLink())a.push(`${l}->${ce(l)}`);else if(n.isDirectory()){if(n.name==="node_modules")a.push(...be(l));else if(!Ze.has(n.name)){if(!qe(l).isDirectory())throw new Error(`${l} changed during the scan`);e(l)}}else a.push(`${l}:${T(l)}`)}};e(t),a.push(...ge(t))}catch{return}return[...new Set(a)].toSorted((e,s)=>e.localeCompare(s)).join(`
|
|
2
2
|
`)},tt=t=>Ge(d(t)).startsWith("@")?d(d(t)):d(t),se=(t,o)=>!y(o,t).startsWith("..")&&!t.split(ue).includes("node_modules"),ie=(t,o)=>{const a=[];let e=t;for(;e!==d(e)&&!D(h(e,"package.json"));)a.push(e),e=d(e);if(D(h(e,"package.json"))){for(const s of[...a,e,h(e,"package.json")])o.add(s);return e}},at=(t,o,a)=>{let e=t;for(;y(e,o).startsWith("..")&&e!==d(e);)a.add(e),e=d(e);a.add(e)},rt=(t,o)=>{const a=new Set;t.some(e=>se(e,o))&&ie(o,a);for(const e of t){if(se(e,o)){for(let n=d(e);n!==o&&n!==d(n);n=d(n))a.add(n);continue}const s=ie(d(e),a);s===void 0?at(d(e),o,a):a.add(tt(s))}return[...a].map(e=>[e,T(e)])},xe=new Map,le=([t,o])=>{try{return T(t)===o}catch{return!1}},ot=(t,o,a)=>{const e=xe.get(t);return e?.optionsKey===o&&e.stamps.every(n=>le(n))&&e.directories.every(n=>le(n))&&a!==void 0&&e.tree===a?e.files:void 0},nt=(t,o,a)=>{const e=[...o.stamps,...o.directories].every(([,s])=>Math.floor(Number.parseFloat(s))<=a);o.tree!==void 0&&e&&xe.set(t,{...o,tree:o.tree})},st=(t,o)=>({directories:rt(o,t),stamps:o.map(a=>[a,T(a)])}),ht=(t,o)=>{const a=d(t.wranglerPath),e=y(a,t.main);if(e.startsWith("..")||_e(e))throw new Error(`@lunora/codegen: service "${t.name}": its entry module (${t.main}) must be inside ${a} to be typed as RPC`);const s=h(o,"services",t.name),n=c.findConfigFile(a,i=>c.sys.fileExists(i)),l=new He({compilerOptions:{composite:!1,declaration:!0,declarationMap:!1,emitDeclarationOnly:!0,incremental:!1,noEmit:!1,noEmitOnError:!1,outDir:s,rootDir:a},skipAddingFilesFromTsConfig:!0,...n===void 0?{}:{tsConfigFilePath:n}}),m=JSON.stringify([t.name,t.main,t.wranglerPath,o]),v=JSON.stringify(l.getCompilerOptions()),w=et(a,Ve(o)),g=ot(m,v,w);if(g!==void 0)return g;const A=Date.now();l.addSourceFileAtPath(t.main),l.resolveSourceFileDependencies();const $=l.getProgram().compilerObject.getSourceFiles().map(i=>i.fileName).filter(i=>D(i)),{directories:F,stamps:S}=st(a,$),u={...l.getCompilerOptions(),preserveSymlinks:!0},O=new Map(l.getSourceFiles().map(i=>i.getFilePath()).filter(i=>!i.endsWith(".d.ts")&&!y(a,i).startsWith("..")).map(i=>[Y(s,a,i),i])),f={};for(const i of l.emitToMemory({emitOnlyDtsFiles:!0}).getFiles()){const B=O.get(he(i.filePath));if(B===void 0)continue;const R=c.createSourceFile(i.filePath,i.text,c.ScriptTarget.Latest,!1);let{text:b}=i;for(const k of Xe(R).toReversed()){const x=c.resolveModuleName(k.text,B,u,c.sys).resolvedModule?.resolvedFileName;if(x===void 0)continue;const I=Y(s,a,x),W=O.has(I)?I:x;b=`${b.slice(0,k.getStart(R))}${JSON.stringify(ye(d(i.filePath),W))}${b.slice(k.getEnd())}`}f[y(o,i.filePath)]=`${pe}${b}`}if(f[y(o,Y(s,a,t.main))]===void 0)throw new Error(`@lunora/codegen: service "${t.name}": TypeScript emitted no declaration for its entry module ${t.main}`);return nt(m,{files:f,optionsKey:v,directories:F,stamps:S,tree:w},A),f},it=(t,o=[])=>{const a=new Set;for(const e of t.tables)for(const s of Object.values(e.shape)){const n=Ke(s);n.kind==="storage"&&typeof n.bucket=="string"&&n.bucket!==""&&a.add(n.bucket)}for(const e of o)e!==""&&e!=="default"&&a.add(e);return["default",...[...a].toSorted((e,s)=>e.localeCompare(s))]},ft=({agents:t=[],capabilities:o=new Set,containers:a=[],env:e,hasVectors:s=!0,hasFlags:n=!1,hasNotify:l=!1,identity:m,queues:v=[],schema:w,services:g=[],storageRuleBuckets:A=[],topics:$=[],useUmbrella:F=!1,workflows:S=[]}={})=>{const u=Ue(F),O=it(w??{tables:[]},A).map(r=>JSON.stringify(r)).join(" | "),f=r=>r.sandbox===!0?"SandboxContainerAccessor":"ContainerAccessor",i=[...new Set(a.map(r=>f(r)))].toSorted((r,p)=>r.localeCompare(p)),B=a.length>0?`import type { ${i.join(", ")} } from "@lunora/container";
|
|
3
3
|
`:"",R=a.length>0?`
|
|
4
4
|
readonly containers: {${a.map(r=>`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{LunoraError as pe}from"@lunora/errors";import{serializeSchemaSnapshot as Xt,hashSchemaSnapshot as Zt}from"./SCHEMA_SNAPSHOT_VERSION-SplX7j_9.mjs";import{isHyperdriveGlobalTable as er,isD1GlobalTable as tr}from"./isD1GlobalTable-udvHAAzD.mjs";import{r as rr}from"./json-data-Chfs2Cz5.mjs";import{r as q,e as nr,a as ar,b as sr,c as or,d as ir,f as dr,g as cr,h as lr,i as ur,j as hr,k as pr,l as mr,m as fr,n as gr,o as br,p as yr,q as wr,s as vr}from"./shard-runtime-
|
|
1
|
+
import{LunoraError as pe}from"@lunora/errors";import{serializeSchemaSnapshot as Xt,hashSchemaSnapshot as Zt}from"./SCHEMA_SNAPSHOT_VERSION-SplX7j_9.mjs";import{isHyperdriveGlobalTable as er,isD1GlobalTable as tr}from"./isD1GlobalTable-udvHAAzD.mjs";import{r as rr}from"./json-data-Chfs2Cz5.mjs";import{r as q,e as nr,a as ar,b as sr,c as or,d as ir,f as dr,g as cr,h as lr,i as ur,j as hr,k as pr,l as mr,m as fr,n as gr,o as br,p as yr,q as wr,s as vr}from"./shard-runtime-B9K29SyO.mjs";import{u as F,h as kr,s as Sr,a as Rr,I as xr,c as Ar,G as Or,d as Dr}from"./shared-Br_OnErI.mjs";import{p as Tr}from"./platform-8oj7iXQy.mjs";import{i as _r}from"./schema-BgM8A3XV.mjs";const p=(r,t)=>`((): (() => ${t}) => { let cached: ${t} | undefined; return () => (cached ??= JSON.parse(${JSON.stringify(JSON.stringify(r))}) as ${t}); })()`,me=["categories","description","facing","level","remediation","title"],Er=r=>{const t={};return{advisoryRows:r.map(o=>{let n=t[o.name];return n||(n=Object.fromEntries(me.filter(a=>a in o).map(a=>[a,o[a]])),t[o.name]=n),Object.fromEntries(Object.entries(o).filter(([a,i])=>!me.includes(a)||JSON.stringify(i)!==JSON.stringify(n[a])))}),advisoryRules:t}},Ir=` /**
|
|
2
2
|
* The bare writer every admin/maintenance entry point writes through.
|
|
3
3
|
*
|
|
4
4
|
* Admin and maintenance writes go through the SAME reactive-cache hooks as a
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{LunoraError as N}from"@lunora/errors";import{r as b}from"./json-data-Chfs2Cz5.mjs";import{CAPABILITIES as k}from"./CAPABILITY_PROBES-
|
|
1
|
+
import{LunoraError as N}from"@lunora/errors";import{r as b}from"./json-data-Chfs2Cz5.mjs";import{CAPABILITIES as k}from"./CAPABILITY_PROBES-DKYJ2K4t.mjs";import{a as l,G as g,I as R}from"./shared-Br_OnErI.mjs";import{s as w}from"./platform-8oj7iXQy.mjs";const U=e=>e?{importFragment:"serveRelationFanout, ",override:`
|
|
2
2
|
protected override async runRelationFanoutRead(functionPath: string, args: Record<string, unknown>): Promise<unknown> {
|
|
3
3
|
this.ensureServable();
|
|
4
4
|
|
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.369",
|
|
4
4
|
"description": "Code generator for Lunora: emits _generated/{api,server,dataModel}.ts from your schema",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|
|
@@ -50,8 +50,8 @@
|
|
|
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.268",
|
|
54
|
+
"@lunora/agent": "1.0.0-alpha.259",
|
|
55
55
|
"@lunora/container": "1.0.0-alpha.96",
|
|
56
56
|
"@lunora/errors": ">=1.0.0-alpha.51 <2.0.0-0",
|
|
57
57
|
"@lunora/platform": "1.0.0-alpha.75",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./CAPABILITY_PROBES-brcmKenl.mjs";import{e}from"./server-8wMiVU6J.mjs";import"./shared-Br_OnErI.mjs";import"./platform-8oj7iXQy.mjs";export{e as default};
|