@lunora/codegen 1.0.0-alpha.112 → 1.0.0-alpha.114
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 s,serializeSchemaSnapshot as a}from"./packem_shared/SCHEMA_SNAPSHOT_VERSION-DIqnj_32.mjs";import{formatAdvisories as m,lintSchema as d,toAdvisorContext as f}from"./packem_shared/formatAdvisories-BjTV22uR.mjs";import{describeErrorLevelFindings as c,errorAdvisoryNames as n,errorPlatformDiagnosticNames as S}from"./packem_shared/describeErrorLevelFindings-D23VSkFP.mjs";import{CodegenDiagnosticError as E,diagnosticAt as x}from"./packem_shared/CodegenDiagnosticError-BUXlG3P-.mjs";import{AGENTS_FILENAME as u,discoverAgents as v}from"./packem_shared/AGENTS_FILENAME-CPHo8Se5.mjs";import{default as g}from"./packem_shared/discoverAuthApiCalls-DUjcl0SB.mjs";import{CONTAINERS_FILENAME as R,discoverContainers as M}from"./packem_shared/CONTAINERS_FILENAME-Bvn6LZP6.mjs";import{default as C}from"./packem_shared/discoverCrons-BUJO2ipU.mjs";import{FLAGS_FILENAME as T,discoverFlags as I}from"./packem_shared/FLAGS_FILENAME-DtBWyUKq.mjs";import{discoverFunctions as F}from"./packem_shared/discoverFunctions-h8i51Mec.mjs";import{default as P}from"./packem_shared/discoverHttpRoutes-MX6y-iVE.mjs";import{default as G}from"./packem_shared/discoverInserts-YX8AmrzL.mjs";import{default as b}from"./packem_shared/discoverMaskProcedures-DhcK-YMG.mjs";import{default as y}from"./packem_shared/discoverMigrations-4Jjf5DJE.mjs";import{MUTATORS_FILENAME as j,discoverMutators as K}from"./packem_shared/MUTATORS_FILENAME-CRmTpN4y.mjs";import{default as z}from"./packem_shared/discoverNondeterministicCalls-CjS2Mznw.mjs";import{NOTIFY_FILENAME as w,discoverNotifyCalls as q,discoverNotifyConfig as B}from"./packem_shared/NOTIFY_FILENAME-BybR3Xbd.mjs";import{default as Y}from"./packem_shared/readPackageDependencies-C6h6FZuP.mjs";import{d as Z}from"./packem_shared/discover-queries-Dfj_0WJG.mjs";import{QUEUES_FILENAME as ee,discoverQueues as re}from"./packem_shared/QUEUES_FILENAME-BnGLtAIu.mjs";import{default as te}from"./packem_shared/discoverR2sqlCalls-DuTuaSMM.mjs";import{discoverRlsMetadata as ae,default as ie}from"./packem_shared/discoverRlsMetadata-BYVq6cVp.mjs";import{discoverSandboxUsage as de}from"./packem_shared/discoverSandboxUsage-L0lV17de.mjs";import{default as pe}from"./packem_shared/discoverSchema-BtlNz9b_.mjs";import{SHAPES_FILENAME as ne,discoverShapes as Se}from"./packem_shared/SHAPES_FILENAME-DxoIrQhA.mjs";import{default as Ee}from"./packem_shared/discoverStorageRulesMetadata-CKPFWHT5.mjs";import{WORKFLOWS_FILENAME as Ae,discoverWorkflows as ue}from"./packem_shared/WORKFLOWS_FILENAME-B8y51Frf.mjs";import{G as Ne,e as ge,a as Oe,b as Re,c as Me,d as he,f as Ce,g as _e,h as Te,i as Ie,j as Le,k as Fe,l as De,m as Pe}from"./packem_shared/emit-Ba3NiOwK.mjs";import{emitApp as Ge}from"./packem_shared/emitApp-
|
|
1
|
+
import{SCHEMA_SNAPSHOT_VERSION as t,diffSchemaSnapshots as s,serializeSchemaSnapshot as a}from"./packem_shared/SCHEMA_SNAPSHOT_VERSION-DIqnj_32.mjs";import{formatAdvisories as m,lintSchema as d,toAdvisorContext as f}from"./packem_shared/formatAdvisories-BjTV22uR.mjs";import{describeErrorLevelFindings as c,errorAdvisoryNames as n,errorPlatformDiagnosticNames as S}from"./packem_shared/describeErrorLevelFindings-D23VSkFP.mjs";import{CodegenDiagnosticError as E,diagnosticAt as x}from"./packem_shared/CodegenDiagnosticError-BUXlG3P-.mjs";import{AGENTS_FILENAME as u,discoverAgents as v}from"./packem_shared/AGENTS_FILENAME-CPHo8Se5.mjs";import{default as g}from"./packem_shared/discoverAuthApiCalls-DUjcl0SB.mjs";import{CONTAINERS_FILENAME as R,discoverContainers as M}from"./packem_shared/CONTAINERS_FILENAME-Bvn6LZP6.mjs";import{default as C}from"./packem_shared/discoverCrons-BUJO2ipU.mjs";import{FLAGS_FILENAME as T,discoverFlags as I}from"./packem_shared/FLAGS_FILENAME-DtBWyUKq.mjs";import{discoverFunctions as F}from"./packem_shared/discoverFunctions-h8i51Mec.mjs";import{default as P}from"./packem_shared/discoverHttpRoutes-MX6y-iVE.mjs";import{default as G}from"./packem_shared/discoverInserts-YX8AmrzL.mjs";import{default as b}from"./packem_shared/discoverMaskProcedures-DhcK-YMG.mjs";import{default as y}from"./packem_shared/discoverMigrations-4Jjf5DJE.mjs";import{MUTATORS_FILENAME as j,discoverMutators as K}from"./packem_shared/MUTATORS_FILENAME-CRmTpN4y.mjs";import{default as z}from"./packem_shared/discoverNondeterministicCalls-CjS2Mznw.mjs";import{NOTIFY_FILENAME as w,discoverNotifyCalls as q,discoverNotifyConfig as B}from"./packem_shared/NOTIFY_FILENAME-BybR3Xbd.mjs";import{default as Y}from"./packem_shared/readPackageDependencies-C6h6FZuP.mjs";import{d as Z}from"./packem_shared/discover-queries-Dfj_0WJG.mjs";import{QUEUES_FILENAME as ee,discoverQueues as re}from"./packem_shared/QUEUES_FILENAME-BnGLtAIu.mjs";import{default as te}from"./packem_shared/discoverR2sqlCalls-DuTuaSMM.mjs";import{discoverRlsMetadata as ae,default as ie}from"./packem_shared/discoverRlsMetadata-BYVq6cVp.mjs";import{discoverSandboxUsage as de}from"./packem_shared/discoverSandboxUsage-L0lV17de.mjs";import{default as pe}from"./packem_shared/discoverSchema-BtlNz9b_.mjs";import{SHAPES_FILENAME as ne,discoverShapes as Se}from"./packem_shared/SHAPES_FILENAME-DxoIrQhA.mjs";import{default as Ee}from"./packem_shared/discoverStorageRulesMetadata-CKPFWHT5.mjs";import{WORKFLOWS_FILENAME as Ae,discoverWorkflows as ue}from"./packem_shared/WORKFLOWS_FILENAME-B8y51Frf.mjs";import{G as Ne,e as ge,a as Oe,b as Re,c as Me,d as he,f as Ce,g as _e,h as Te,i as Ie,j as Le,k as Fe,l as De,m as Pe}from"./packem_shared/emit-Ba3NiOwK.mjs";import{emitApp as Ge}from"./packem_shared/emitApp-CXeJ0y98.mjs";import{buildOpenApiDocument as be,emitOpenApi as ke,emitOpenApiModule as ye}from"./packem_shared/buildOpenApiDocument-B2mW3f5a.mjs";import{OPENRPC_VERSION as je,buildOpenRpcDocument as Ke,emitOpenRpc as Ve,emitOpenRpcModule as ze}from"./packem_shared/OPENRPC_VERSION-DB1PSt8W.mjs";import{DEFAULT_TARGET as we,platformMatrixIds as qe,readProjectTarget as Be,resolveCodegenTarget as Je}from"./packem_shared/DEFAULT_TARGET-CIH5PRk1.mjs";import{SCHEMA_SNAPSHOT_FILENAME as Xe,createCodegenProject as Ze,findTsconfig as $e,refreshCodegenProject as er,runCodegen as rr}from"./packem_shared/SCHEMA_SNAPSHOT_FILENAME-DgAbfC_h.mjs";import{SchemaSnapshotParseError as tr,buildSchemaSnapshot as sr,evaluateSchemaDrift as ar,parseSchemaSnapshot as ir}from"./packem_shared/SchemaSnapshotParseError-Dc1aZAph.mjs";import{schemaFromIr as dr}from"./packem_shared/schemaFromIr-BWFnvCVg.mjs";import{LUNORA_ERROR_CODES as pr,validatorIrToJsonSchema as cr}from"./packem_shared/LUNORA_ERROR_CODES-BYg8Lpgb.mjs";import{SDK_LANGUAGES as Sr,SDK_TARGETS as lr,generateSdk as Er}from"./packem_shared/SDK_LANGUAGES-DcXlLVZ1.mjs";import{redact as Ar,secretKindOf as ur}from"./packem_shared/redact-Cy14LEnc.mjs";import{MESSAGE_SOLUTIONS as Nr,findSolutionByMessage as gr}from"@lunora/errors";import{isTypedSchema as Rr}from"./packem_shared/isTypedSchema-BBIBMZTg.mjs";const e="0.0.0";export{u as AGENTS_FILENAME,R as CONTAINERS_FILENAME,E as CodegenDiagnosticError,we as DEFAULT_TARGET,T as FLAGS_FILENAME,Ne as GENERATED_HEADER,pr as LUNORA_ERROR_CODES,Nr as LUNORA_SOLUTION_RULES,j as MUTATORS_FILENAME,w as NOTIFY_FILENAME,je as OPENRPC_VERSION,ee as QUEUES_FILENAME,Xe as SCHEMA_SNAPSHOT_FILENAME,t as SCHEMA_SNAPSHOT_VERSION,Sr as SDK_LANGUAGES,lr as SDK_TARGETS,ne as SHAPES_FILENAME,tr as SchemaSnapshotParseError,e as VERSION,Ae as WORKFLOWS_FILENAME,be as buildOpenApiDocument,Ke as buildOpenRpcDocument,sr as buildSchemaSnapshot,Ze as createCodegenProject,c as describeErrorLevelFindings,x as diagnosticAt,s as diffSchemaSnapshots,v as discoverAgents,g as discoverAuthApiCalls,M as discoverContainers,C as discoverCrons,I as discoverFlags,F as discoverFunctions,P as discoverHttpRoutes,G as discoverInserts,b as discoverMaskProcedures,y as discoverMigrations,K as discoverMutators,z as discoverNondeterministicCalls,q as discoverNotifyCalls,B as discoverNotifyConfig,Z as discoverQueries,re as discoverQueues,te as discoverR2sqlCalls,ae as discoverRlsMetadata,ie as discoverRlsProcedures,de as discoverSandboxUsage,pe as discoverSchema,Se as discoverShapes,Ee as discoverStorageRulesMetadata,ue as discoverWorkflows,ge as emitAgents,Oe as emitApi,Ge as emitApp,Re as emitCollections,Me as emitContainers,he as emitCrons,Ce as emitDataModel,_e as emitDrizzleSchema,Te as emitFunctions,ke as emitOpenApi,ye as emitOpenApiModule,Ve as emitOpenRpc,ze as emitOpenRpcModule,Ie as emitServer,Le as emitShard,Fe as emitVectors,De as emitWorkflows,Pe as emitWranglerCronTriggers,n as errorAdvisoryNames,S as errorPlatformDiagnosticNames,ar as evaluateSchemaDrift,gr as findLunoraSolution,$e as findTsconfig,m as formatAdvisories,Er as generateSdk,Rr as isTypedSchema,d as lintSchema,ir as parseSchemaSnapshot,qe as platformMatrixIds,Y as readPackageDependencies,Be as readProjectTarget,Ar as redact,er as refreshCodegenProject,Je as resolveCodegenTarget,rr as runCodegen,dr as schemaFromIr,ur as secretKindOf,a as serializeSchemaSnapshot,f as toAdvisorContext,cr as validatorIrToJsonSchema};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{existsSync as N,mkdirSync as Bt,readFileSync as dt,writeFileSync as $t,rmSync as qt}from"node:fs";import{join as f,dirname as le}from"node:path";import{performance as ue}from"node:perf_hooks";import{runAdvisor as jt}from"@lunora/advisor";import{LunoraError as R}from"@lunora/errors";import{SyntaxKind as l,Node as i,Project as He}from"ts-morph";import{serializeSchemaSnapshot as Wt}from"./SCHEMA_SNAPSHOT_VERSION-DIqnj_32.mjs";import{toAdvisorContext as Vt}from"./formatAdvisories-BjTV22uR.mjs";import{discoverAgents as Ht}from"./AGENTS_FILENAME-CPHo8Se5.mjs";import{discoverContainers as Gt}from"./CONTAINERS_FILENAME-Bvn6LZP6.mjs";import{diagnosticAt as Z}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{b as J}from"./module-specifiers-WF8iAydP.mjs";import{C as de,i as Yt,f as Xt,n as Qt,a as Zt,h as Jt,j as es,b as ts,c as ss,l as ns,e as rs,o as is,d as os,k as as,g as cs,p as ls,m as us}from"./emit-Ba3NiOwK.mjs";import{l as h,a as E,c as y,p as S,f as ft,i as ds,r as pt,e as fs}from"./discover-ast-D33zP-NZ.mjs";import ps from"./readPackageDependencies-C6h6FZuP.mjs";import{discoverQueues as gs}from"./QUEUES_FILENAME-BnGLtAIu.mjs";import{discoverSandboxUsage as ms}from"./discoverSandboxUsage-L0lV17de.mjs";import hs from"./discoverStorageRulesMetadata-CKPFWHT5.mjs";import{discoverWorkflows as xs}from"./WORKFLOWS_FILENAME-B8y51Frf.mjs";import{gatePlatformFeatures as Es,resolveCodegenTarget as vs}from"./DEFAULT_TARGET-CIH5PRk1.mjs";import{i as T,a as F,e as x,c as I,r as Ss,b as As,s as ee,f as Ns,g as ys,d as bs}from"./discover-queries-Dfj_0WJG.mjs";import{classifyProcedureCall as _,inlineHandler as Is,procedureHandler as gt,chainUsesWrappedCall as mt,isDatabaseAccessor as K,chainHasStep as Ps,discoverFunctions as ws,resolveStandardSchemaType as Ts}from"./discoverFunctions-h8i51Mec.mjs";import Cs from"./discoverAuthApiCalls-DUjcl0SB.mjs";import Os from"./discoverCrons-BUJO2ipU.mjs";import{discoverFlagKeys as Rs}from"./FLAGS_FILENAME-DtBWyUKq.mjs";import Fs from"./discoverHttpRoutes-MX6y-iVE.mjs";import Ls from"./discoverInserts-YX8AmrzL.mjs";import Ds,{discoverMaskStrategies as ks,discoverMaskMetadata as Ms,discoverMaskHasNonLiteralPolicy as Ks}from"./discoverMaskProcedures-DhcK-YMG.mjs";import _s from"./discoverMigrations-4Jjf5DJE.mjs";import{MUTATORS_FILENAME as zs,isDefineMutatorCallee as Us,discoverMutators as Bs}from"./MUTATORS_FILENAME-CRmTpN4y.mjs";import $s from"./discoverNondeterministicCalls-CjS2Mznw.mjs";import{discoverNotifyConfig as qs,discoverNotifyCalls as js}from"./NOTIFY_FILENAME-BybR3Xbd.mjs";import Ws from"./discoverR2sqlCalls-DuTuaSMM.mjs";import Vs,{discoverRlsMetadata as Hs}from"./discoverRlsMetadata-BYVq6cVp.mjs";import Gs from"./discoverSchema-BtlNz9b_.mjs";import{secretKindOf as Ys,redact as Xs,isHeuristicSecretKind as Qs,isSecretishName as Zs}from"./redact-Cy14LEnc.mjs";import{discoverShapes as Js}from"./SHAPES_FILENAME-DxoIrQhA.mjs";import{emitApp as en}from"./emitApp-
|
|
1
|
+
import{existsSync as N,mkdirSync as Bt,readFileSync as dt,writeFileSync as $t,rmSync as qt}from"node:fs";import{join as f,dirname as le}from"node:path";import{performance as ue}from"node:perf_hooks";import{runAdvisor as jt}from"@lunora/advisor";import{LunoraError as R}from"@lunora/errors";import{SyntaxKind as l,Node as i,Project as He}from"ts-morph";import{serializeSchemaSnapshot as Wt}from"./SCHEMA_SNAPSHOT_VERSION-DIqnj_32.mjs";import{toAdvisorContext as Vt}from"./formatAdvisories-BjTV22uR.mjs";import{discoverAgents as Ht}from"./AGENTS_FILENAME-CPHo8Se5.mjs";import{discoverContainers as Gt}from"./CONTAINERS_FILENAME-Bvn6LZP6.mjs";import{diagnosticAt as Z}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{b as J}from"./module-specifiers-WF8iAydP.mjs";import{C as de,i as Yt,f as Xt,n as Qt,a as Zt,h as Jt,j as es,b as ts,c as ss,l as ns,e as rs,o as is,d as os,k as as,g as cs,p as ls,m as us}from"./emit-Ba3NiOwK.mjs";import{l as h,a as E,c as y,p as S,f as ft,i as ds,r as pt,e as fs}from"./discover-ast-D33zP-NZ.mjs";import ps from"./readPackageDependencies-C6h6FZuP.mjs";import{discoverQueues as gs}from"./QUEUES_FILENAME-BnGLtAIu.mjs";import{discoverSandboxUsage as ms}from"./discoverSandboxUsage-L0lV17de.mjs";import hs from"./discoverStorageRulesMetadata-CKPFWHT5.mjs";import{discoverWorkflows as xs}from"./WORKFLOWS_FILENAME-B8y51Frf.mjs";import{gatePlatformFeatures as Es,resolveCodegenTarget as vs}from"./DEFAULT_TARGET-CIH5PRk1.mjs";import{i as T,a as F,e as x,c as I,r as Ss,b as As,s as ee,f as Ns,g as ys,d as bs}from"./discover-queries-Dfj_0WJG.mjs";import{classifyProcedureCall as _,inlineHandler as Is,procedureHandler as gt,chainUsesWrappedCall as mt,isDatabaseAccessor as K,chainHasStep as Ps,discoverFunctions as ws,resolveStandardSchemaType as Ts}from"./discoverFunctions-h8i51Mec.mjs";import Cs from"./discoverAuthApiCalls-DUjcl0SB.mjs";import Os from"./discoverCrons-BUJO2ipU.mjs";import{discoverFlagKeys as Rs}from"./FLAGS_FILENAME-DtBWyUKq.mjs";import Fs from"./discoverHttpRoutes-MX6y-iVE.mjs";import Ls from"./discoverInserts-YX8AmrzL.mjs";import Ds,{discoverMaskStrategies as ks,discoverMaskMetadata as Ms,discoverMaskHasNonLiteralPolicy as Ks}from"./discoverMaskProcedures-DhcK-YMG.mjs";import _s from"./discoverMigrations-4Jjf5DJE.mjs";import{MUTATORS_FILENAME as zs,isDefineMutatorCallee as Us,discoverMutators as Bs}from"./MUTATORS_FILENAME-CRmTpN4y.mjs";import $s from"./discoverNondeterministicCalls-CjS2Mznw.mjs";import{discoverNotifyConfig as qs,discoverNotifyCalls as js}from"./NOTIFY_FILENAME-BybR3Xbd.mjs";import Ws from"./discoverR2sqlCalls-DuTuaSMM.mjs";import Vs,{discoverRlsMetadata as Hs}from"./discoverRlsMetadata-BYVq6cVp.mjs";import Gs from"./discoverSchema-BtlNz9b_.mjs";import{secretKindOf as Ys,redact as Xs,isHeuristicSecretKind as Qs,isSecretishName as Zs}from"./redact-Cy14LEnc.mjs";import{discoverShapes as Js}from"./SHAPES_FILENAME-DxoIrQhA.mjs";import{emitApp as en}from"./emitApp-CXeJ0y98.mjs";import{buildOpenApiDocument as tn,emitOpenApiModule as sn}from"./buildOpenApiDocument-B2mW3f5a.mjs";import{buildOpenRpcDocument as nn,emitOpenRpcModule as rn}from"./OPENRPC_VERSION-DB1PSt8W.mjs";import{s as on}from"./parse-validator-DtALyvid.mjs";import{buildSchemaSnapshot as an}from"./SchemaSnapshotParseError-Dc1aZAph.mjs";const cn=e=>{const t=[],s=e.tables.filter(n=>n.shardMode==="global");return s.some(n=>n.globalBackend!=="hyperdrive")&&t.push({name:"@lunora/d1",reason:"`.global()` tables are D1-backed, so `_generated/app.ts` imports the D1 `ctx.db` adapter"}),s.some(n=>n.globalBackend==="hyperdrive")&&t.push({name:"@lunora/hyperdrive",reason:'`.global({ backend: "hyperdrive" })` tables route through `@lunora/hyperdrive/global`'}),e.vectorIndexes.length>0&&t.push({name:"@lunora/bindings",reason:"`.vectorize()` indexes make `_generated/vectors.ts` import `@lunora/bindings/vectors`"}),t},ln=(e,t)=>{if(t===void 0)return;const s=cn(e).filter(o=>!t.has(o.name));if(s.length===0)return;const n=s.map(o=>` - ${o.name} — ${o.reason}`).join(`
|
|
2
2
|
`);throw new R("INTERNAL",`@lunora/codegen: this schema's generated code imports packages the project does not declare:
|
|
3
3
|
${n}
|
|
4
4
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{A as S,G as D}from"./emit-Ba3NiOwK.mjs";const E=e=>`has${e.charAt(0).toUpperCase()}${e.slice(1)}`,v=S.map(({appMethod:e,key:t})=>[E(t),e.method,e.configKey,e.doc]),
|
|
1
|
+
import{A as S,G as D}from"./emit-Ba3NiOwK.mjs";const E=e=>`has${e.charAt(0).toUpperCase()}${e.slice(1)}`,v=S.map(({appMethod:e,key:t})=>[E(t),e.method,e.configKey,e.doc]),m=e=>v.some(([t])=>e[t]),A=e=>e?['import * as lunoraIdentityContract from "../identity.js";']:[],R=(e,t)=>e?['import type { CreateAccessResolverOptions } from "@lunora/cloudflare-access";',`import { createAccessResolver${t?", composeResolvers":""} } from "@lunora/cloudflare-access";`]:[],x=e=>e?['import { createKvIntrospectorFromEnv } from "@lunora/bindings/kv";']:[],O=e=>e?['import notifyConfig from "../notify.js";']:[],k=e=>(e.emailAgents?.length??0)>0,C=e=>k(e)?['import { dispatchAgentEmail } from "@lunora/agent/inbound";']:[],L=e=>k(e)?['import * as lunoraAgentDefinitions from "../agents.js";']:[],T=e=>{const{hasAccess:t,hasAuth:r,hasFramework:a,hasGlobal:n,hasHyperdriveGlobal:o,hasKv:l,hasQueue:s,hasScheduler:d,hasStorage:u,hasWorkflow:h,useUmbrella:c,wantsOpenApi:p,wantsOpenRpc:b}=e,i=c?"lunorash/runtime":"@lunora/runtime",g=["ExecutionContextLike","HttpRouterLike","LunoraWorker","Route","ScheduledControllerLike","ShardNamespaceLike","WorkerOptions"];n&&g.push("GlobalIntrospector","AdminTableResolver"),a&&g.push("FrameworkHostHandler");const f=[...n||o?["createCrossShardRelationCapabilities"]:[],"createWorker","resolveLogArchiveFromEnv",...a?["withFrameworkWorker"]:[]].join(", ");return[...r?['import type { AuthNamespaceLike, LunoraAuth, LunoraAuthOptions } from "@lunora/auth";','import { createAuth, createAuthAdmin, createAuthAuditReader, createDoAuthWiring, d1Executor, ensureMigrated, handleAuthRequest, lunoraD1Adapter } from "@lunora/auth";']:[],...R(t,r),...n?['import type { D1CtxDbOptions, D1DatabaseLike, D1Exec } from "@lunora/d1";','import { createD1CtxDb, facetGlobalColumn, importGlobalRows, listGlobalTables, readGlobalTablePage, retryingExec } from "@lunora/d1";']:[],...o?['import type { HyperdriveEngine } from "@lunora/hyperdrive/global";','import { createHyperdriveGlobalCtxDb } from "@lunora/hyperdrive/global";','import type { SqlCtxDbOptions, SqlExec } from "@lunora/sql-store";']:[],...x(l),...d?['import type { DurableObjectNamespaceLike } from "@lunora/scheduler";','import { createScheduler } from "@lunora/scheduler";']:[],...u?['import type { R2BucketLike, Storage } from "@lunora/storage";','import { createBucketStorage, createStorage } from "@lunora/storage";']:[],...h?['import { createWorkflowsRestClient } from "@lunora/workflow";']:[],...C(e),`import type { ${[...g].toSorted((w,y)=>w.localeCompare(y)).join(", ")} } from "${i}";`,`import { ${f} } from "${i}";`,"",...A(e.identity),...L(e),...n||o?['import schema from "../schema.js";']:[],...O(e.hasNotify),'import { LUNORA_CRONS } from "./crons.js";','import { LUNORA_FUNCTIONS } from "./functions.js";',...s?['import { createQueueCaptureSink, dispatchQueueBatch, shouldCaptureQueue } from "@lunora/queue";','import { LUNORA_QUEUE_REGISTRY } from "./queues.js";']:[],...p?['import { openApiSpec } from "./openapi.js";']:[],...b?['import { openRpcSpec } from "./openrpc.js";']:[],'import { createShardDO } from "./shard.js";']},I=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. */
|
|
2
2
|
interface StorageDeclaration<Env> {
|
|
3
3
|
/** The default R2 bucket binding (the bare \`ctx.storage\`). */
|
|
4
4
|
bucket: Selector<Env, R2BucketLike>;
|
|
@@ -8,7 +8,7 @@ interface StorageDeclaration<Env> {
|
|
|
8
8
|
publicBaseUrl?: Selector<Env, string>;
|
|
9
9
|
/** HMAC secret for signed URLs. */
|
|
10
10
|
signingSecret?: Selector<Env, string>;
|
|
11
|
-
}`]:[],...e.hasScheduler?["/** `.scheduler(...)` declaration — the `SchedulerDO` namespace plus the worker origin its callbacks dispatch back to. Backs `ctx.scheduler` AND the studio's scheduled-jobs view. */\ninterface SchedulerDeclaration<Env> {\n /** The `SchedulerDO` namespace binding (typically `env.SCHEDULER`). */\n namespace: Selector<Env, DurableObjectNamespaceLike & ShardNamespaceLike>;\n /** The worker origin the `SchedulerDO` dispatches HTTP job callbacks back to. */\n origin?: Selector<Env, string>;\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)))`. Cache the driver on the DO instance; rebuild lazily after hibernation. */\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}']:[]],j=e=>[...e.hasAccess?[" private accessSelector?: Selector<Env, CreateAccessResolverOptions | undefined>;"]:[]," private adminToken?: Selector<Env, string>;",...e.hasAuth?[" private authDeclaration?: AuthDeclaration<Env>;"]:[]," 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>;"]:[],...
|
|
11
|
+
}`]:[],...e.hasScheduler?["/** `.scheduler(...)` declaration — the `SchedulerDO` namespace plus the worker origin its callbacks dispatch back to. Backs `ctx.scheduler` AND the studio's scheduled-jobs view. */\ninterface SchedulerDeclaration<Env> {\n /** The `SchedulerDO` namespace binding (typically `env.SCHEDULER`). */\n namespace: Selector<Env, DurableObjectNamespaceLike & ShardNamespaceLike>;\n /** The worker origin the `SchedulerDO` dispatches HTTP job callbacks back to. */\n origin?: Selector<Env, string>;\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)))`. Cache the driver on the DO instance; rebuild lazily after hibernation. */\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}']:[]],j=e=>[...e.hasAccess?[" private accessSelector?: Selector<Env, CreateAccessResolverOptions | undefined>;"]:[]," private adminToken?: Selector<Env, string>;",...e.hasAuth?[" private authDeclaration?: AuthDeclaration<Env>;"]:[]," 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>;"]:[],...m(e)?[" private readonly shardExtras: Partial<ShardConfig> = {};"]:[]," private shardSelector?: Selector<Env, ShardNamespaceLike>;",...e.hasStorage?[" private storageDeclaration?: StorageDeclaration<Env>;"]:[]],N=e=>v.filter(([t])=>e[t]).map(([,t,r,a])=>` /** ${a} */
|
|
12
12
|
public ${t}(factory: NonNullable<ShardConfig["${r}"]>): this {
|
|
13
13
|
this.shardExtras.${r} = factory;
|
|
14
14
|
|
|
@@ -110,7 +110,7 @@ interface StorageDeclaration<Env> {
|
|
|
110
110
|
return namespace && origin ? createScheduler({${e.jurisdiction?` jurisdiction: ${JSON.stringify(e.jurisdiction)},`:""} namespace, originUrl: origin }) : undefined;
|
|
111
111
|
},
|
|
112
112
|
}
|
|
113
|
-
: {}),`]:[],...e.hasStorage?[" ...(this.storageDeclaration ? { storage: (rawEnv: Record<string, unknown>) => this.resolveStorage(rawEnv as Env) } : {}),"]:[],...
|
|
113
|
+
: {}),`]:[],...e.hasStorage?[" ...(this.storageDeclaration ? { storage: (rawEnv: Record<string, unknown>) => this.resolveStorage(rawEnv as Env) } : {}),"]:[],...m(e)?[" ...this.shardExtras,"]:[]];return t.length>0?`
|
|
114
114
|
${t.join(`
|
|
115
115
|
`)}
|
|
116
116
|
`:""},W=e=>[...e.hasScheduler?[` if (this.schedulerDeclaration) {
|
|
@@ -281,11 +281,20 @@ ${e.voiceAgents.map(t=>` ${JSON.stringify(t.exportName)}: (env as Rec
|
|
|
281
281
|
};
|
|
282
282
|
}
|
|
283
283
|
`:"",H=e=>e?`
|
|
284
|
-
/**
|
|
284
|
+
/**
|
|
285
|
+
* Adapt the raw D1 binding to \`@lunora/d1\`'s \`D1Exec\` (reads via \`all\`, writes via \`run\`, and — when the binding exposes it — several writes in one round trip via \`batch\`).
|
|
286
|
+
*
|
|
287
|
+
* Wrapped in \`retryingExec\` so D1's documented baseline of transient failures
|
|
288
|
+
* (storage-object resets, isolate memory evictions, dropped connections) does
|
|
289
|
+
* not surface on every \`.global()\` read. Only statements that are provably
|
|
290
|
+
* read-only retry; writes — including the \`UPDATE … RETURNING\` the store's
|
|
291
|
+
* optimistic-concurrency check issues through \`all\` — pass straight through,
|
|
292
|
+
* because a transient error never says whether the write applied.
|
|
293
|
+
*/
|
|
285
294
|
const buildExec = (database: D1DatabaseLike): D1Exec => {
|
|
286
295
|
const batchFn = database.batch;
|
|
287
296
|
|
|
288
|
-
return {
|
|
297
|
+
return retryingExec({
|
|
289
298
|
all: async (sql, parameters) => {
|
|
290
299
|
const result = await database
|
|
291
300
|
.prepare(sql)
|
|
@@ -320,7 +329,7 @@ const buildExec = (database: D1DatabaseLike): D1Exec => {
|
|
|
320
329
|
.bind(...parameters)
|
|
321
330
|
.run();
|
|
322
331
|
},
|
|
323
|
-
};
|
|
332
|
+
});
|
|
324
333
|
};
|
|
325
334
|
|
|
326
335
|
/** Introspect \`.global()\` (D1-backed) tables for the studio's global data browser. */
|
|
@@ -395,10 +404,10 @@ const buildGlobalImporter =
|
|
|
395
404
|
// migrator). For production run the migrate command ahead of deploy.
|
|
396
405
|
await ensureMigrated(createAuth({ ...this.authDeclaration.options(env), database: d1(env) as never }));
|
|
397
406
|
};
|
|
398
|
-
`:"",
|
|
407
|
+
`:"",l=t?`
|
|
399
408
|
await ensureAuth(env);`:"",s=t?"() => auth":"() => null",d=t?"getAuth: () => LunoraAuth | null":"_getAuth: () => null",u=e.hasFramework?` const buildWorker = (env: Env): LunoraWorker =>
|
|
400
|
-
host ? withFrameworkWorker(host, (hostEnv) => this.buildWorkerOptions(hostEnv as Env, ${s})) : createWorker(this.buildWorkerOptions(env, ${s}));`:` const buildWorker = (env: Env): LunoraWorker => createWorker(this.buildWorkerOptions(env, ${s}));`,h=e.hasFramework?"host?: FrameworkHostHandler":"",
|
|
401
|
-
${
|
|
409
|
+
host ? withFrameworkWorker(host, (hostEnv) => this.buildWorkerOptions(hostEnv as Env, ${s})) : createWorker(this.buildWorkerOptions(env, ${s}));`:` const buildWorker = (env: Env): LunoraWorker => createWorker(this.buildWorkerOptions(env, ${s}));`,h=e.hasFramework?"host?: FrameworkHostHandler":"",c=e.emailAgents??[],p=c.length>0?` composed.email = dispatchAgentEmail([
|
|
410
|
+
${c.map(i=>` { agent: lunoraAgentDefinitions.${i.exportName}, binding: ${JSON.stringify(i.bindingName)} },`).join(`
|
|
402
411
|
`)}
|
|
403
412
|
]);
|
|
404
413
|
|
|
@@ -410,7 +419,7 @@ ${l.map(i=>` { agent: lunoraAgentDefinitions.${i.exportName}, binding
|
|
|
410
419
|
|
|
411
420
|
/** Read a value off the per-request \`env\`. Returns \`undefined\` to leave the capability unconfigured (its \`ctx.*\`/admin surface stays a clear-error stub). */
|
|
412
421
|
type Selector<Env, T> = (env: Env) => T | undefined;
|
|
413
|
-
${
|
|
422
|
+
${m(e)?"\n/** The generated `createShardDO` config — the long-tail `.ai()` / `.kv()` / … methods pass straight through to it. */\ntype ShardConfig = NonNullable<Parameters<typeof createShardDO>[0]>;\n":""}
|
|
414
423
|
${r.join(`
|
|
415
424
|
|
|
416
425
|
`)}${r.length>0?`
|
|
@@ -455,7 +464,7 @@ ${u}
|
|
|
455
464
|
const composed: ComposedApp = {
|
|
456
465
|
ShardDO,
|
|
457
466
|
fetch: async (request: Request, rawEnv: unknown, context: ExecutionContextLike): Promise<Response> => {
|
|
458
|
-
const env = rawEnv as Env;${
|
|
467
|
+
const env = rawEnv as Env;${l}
|
|
459
468
|
worker ??= buildWorker(env);
|
|
460
469
|
|
|
461
470
|
return worker.fetch(request, rawEnv, context);
|
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.114",
|
|
4
4
|
"description": "Code generator for Lunora: emits _generated/{api,server,dataModel}.ts from your schema",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|
|
@@ -46,15 +46,15 @@
|
|
|
46
46
|
"access": "public"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@lunora/advisor": "1.0.0-alpha.
|
|
50
|
-
"@lunora/agent": "1.0.0-alpha.
|
|
51
|
-
"@lunora/container": "1.0.0-alpha.
|
|
49
|
+
"@lunora/advisor": "1.0.0-alpha.83",
|
|
50
|
+
"@lunora/agent": "1.0.0-alpha.58",
|
|
51
|
+
"@lunora/container": "1.0.0-alpha.32",
|
|
52
52
|
"@lunora/errors": "1.0.0-alpha.22",
|
|
53
|
-
"@lunora/platform": "1.0.0-alpha.
|
|
54
|
-
"@lunora/queue": "1.0.0-alpha.
|
|
55
|
-
"@lunora/scheduler": "1.0.0-alpha.
|
|
53
|
+
"@lunora/platform": "1.0.0-alpha.13",
|
|
54
|
+
"@lunora/queue": "1.0.0-alpha.29",
|
|
55
|
+
"@lunora/scheduler": "1.0.0-alpha.33",
|
|
56
56
|
"@lunora/values": "1.0.0-alpha.27",
|
|
57
|
-
"@lunora/workflow": "1.0.0-alpha.
|
|
57
|
+
"@lunora/workflow": "1.0.0-alpha.30",
|
|
58
58
|
"jsonc-parser": "^3.3.1",
|
|
59
59
|
"quicktype-core": "^26.0.0",
|
|
60
60
|
"ts-morph": "^28.0.0"
|