@lunora/codegen 1.0.0-alpha.388 → 1.0.0-alpha.389
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 +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.mjs +1 -1
- package/dist/packem_shared/{DEFAULT_TARGET-3OLdJhTj.mjs → DEFAULT_TARGET-hkUrVddn.mjs} +1 -1
- package/dist/packem_shared/SCHEMA_SNAPSHOT_FILENAME-CtfWbIuc.mjs +31 -0
- package/dist/packem_shared/{emitApp-DI0NqdBD.mjs → emitApp-Blxf5Bvs.mjs} +38 -29
- package/dist/packem_shared/{emitCrons-BvqxeNRr.mjs → emitCrons-BQjDleCe.mjs} +37 -22
- package/dist/packem_shared/{emitFunctions-C4PzKb4H.mjs → emitFunctions-D6n4ENZO.mjs} +44 -33
- package/dist/packem_shared/{emitShard-9bkKBgXn.mjs → emitShard-g-4f3Zle.mjs} +1 -1
- package/dist/packem_shared/{shard-BCIxx9-G.mjs → shard-D_mnxT3r.mjs} +1 -1
- package/package.json +9 -9
- package/dist/packem_shared/SCHEMA_SNAPSHOT_FILENAME-DJ8KVD1z.mjs +0 -31
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{APP_METHOD_CAPABILITIES as
|
|
1
|
+
import{APP_METHOD_CAPABILITIES as N}from"./CAPABILITY_PROBES-BuNEmlCO.mjs";import{i as q}from"./schema-BgM8A3XV.mjs";import{a as I,I as L,G as y}from"./shared-DhqnD5R3.mjs";const j={configKey:"vectors",doc:"Wire the Vectorize index map backing `ctx.vectors`.",method:"vectors"},f=e=>[...N.filter(({key:r})=>e.capabilities.has(r)).map(({appMethod:r})=>r),...e.hasVectors?[j]:[]],w=e=>f(e).length>0,k=e=>(e.emailAgents?.length??0)>0,l=e=>e.tables.some(r=>q(r)),p=e=>e.liveStreams===!0&&(e.liveStreamDeclarations?.length??0)>0,$=e=>e.hasScheduler?`
|
|
2
2
|
/** Resolve the \`SchedulerDO\`-backed scheduler for this env; \`undefined\` until the namespace is wired. */
|
|
3
3
|
private resolveScheduler(env: Env): ReturnType<typeof createScheduler> | undefined {
|
|
4
4
|
const namespace = this.schedulerDeclaration?.namespace(env);
|
|
@@ -340,7 +340,7 @@ const buildGlobalCdcApplier =
|
|
|
340
340
|
|
|
341
341
|
return request.changes.length;
|
|
342
342
|
};
|
|
343
|
-
`:"",M=e=>[...e.hasStorage?["/** `.storage(...)` declaration — one bucket (required) plus optional extra named buckets and signed-URL config. Backs `ctx.storage` AND the studio file browser. */\ninterface StorageDeclaration<Env> {\n /** The default R2 bucket binding (the bare `ctx.storage`). */\n bucket: Selector<Env, R2BucketLike>;\n /** Extra named buckets, reached via `ctx.storage.bucket(\"name\")` and the studio's bucket picker. */\n buckets?: Record<string, Selector<Env, R2BucketLike>>;\n /** Public base URL signed/public object URLs resolve against. Omit it and `ctx.storage` in a mutation, action or HTTP handler (and the studio's copy-URL) signs against the origin the request reached the worker on — no per-environment value to ship. Queries get no such fallback (a live query re-runs with no request behind it), so a query that signs URLs needs this set. */\n publicBaseUrl?: Selector<Env, string>;\n /** R2 S3-API credentials (`{ accountId, accessKeyId, secretAccessKey, bucket, jurisdiction? }`) enabling `ctx.storage.getPresignedUrl` — native S3 presigned URLs that hit R2 directly, bypassing the worker. Omit to use only the worker-signed `getSignedUrl` path. */\n s3?: Selector<Env, R2S3Credentials>;\n /** HMAC secret for signed URLs. */\n signingSecret?: Selector<Env, string>;\n}"]:[],...e.hasScheduler?["/** `.scheduler(...)` declaration — the `SchedulerDO` namespace. Backs `ctx.scheduler` AND the studio's scheduled-jobs view. The origin its callbacks dispatch back to is not declared here: the DO reads `env.LUNORA_ORIGIN_URL` at fire time, because a caller-supplied dispatch target would be an SSRF vector. */\ninterface SchedulerDeclaration<Env> {\n /** The `SchedulerDO` namespace binding (typically `env.SCHEDULER`). */\n namespace: Selector<Env, DurableObjectNamespaceLike & ShardNamespaceLike>;\n}"]:[],...e.hasGlobal?["/** `.global(...)` declaration — the D1 binding backing `.global()` tables. Backs cross-tenant `ctx.db` reads/writes AND the studio's global data browser. */\ninterface GlobalDeclaration<Env> {\n /** The D1 binding (typically `env.DB`). */\n d1: Selector<Env, D1DatabaseLike>;\n /** The worker origin used to fan reverse cross-backend relations across shards. Without it, such a relation throws a clear error. */\n origin?: Selector<Env, string>;\n}"]:[],...e.hasHyperdriveGlobal?['/** `.hyperdriveGlobal(...)` declaration — backs `.global({ backend: "hyperdrive" })` tables on a Postgres/MySQL database via Hyperdrive. Stays reactive: the writer is injected as `globalDb` and the broadcast hook drives live queries. */\ninterface HyperdriveGlobalDeclaration<Env> {\n /** The Hyperdrive engine — selects the Postgres or MySQL dialect. */\n engine: HyperdriveEngine;\n /** Build the `SqlExec` from `env` — e.g. `buildPgExec(fromPostgresJs(async () => (await import("postgres")).default(env.HYPERDRIVE.connectionString, { fetch_types: false, max: 5 })))`. Called per request, by the shard and by the stateless worker\'s admin plane, so return an exec on a connection opened for that call: never cache a driver or socket at module scope, since Workers refuse I/O across requests. */\n exec: (env: Env) => SqlExec;\n /** The worker origin used to fan reverse cross-backend relations across shards. Without it, such a relation throws a clear error. */\n origin?: Selector<Env, string>;\n}']:[],...e.hasAuth?['/** `.auth(...)` declaration — better-auth options plus the storage the adapter reads. Give it `d1` (the default) or `namespace` (a Durable Object that hosts the auth tables), never both. The builder owns the lazy build + `ensureMigrated` dance and wires `authHandler` / `resolveIdentity` / `authAdmin`. */\ninterface AuthDeclaration<Env> {\n /** The D1 binding the auth SQL adapter is wired over (via `lunoraD1Adapter`). Omit only when using `namespace`. */\n d1?: Selector<Env, unknown>;\n /** Shared secret the worker presents on the object\'s internal session route. REQUIRED with `namespace`: the binding is reachable from any worker bound to it, so the secret — not the binding — is the authorization boundary. Without it identity resolution fails closed. */\n internalSecret?: Selector<Env, string>;\n /** Name of the Durable Object instance holding the auth tables. Defaults to `"auth"`. Set it to run separate auth objects (per deployment, per tenant) off one namespace. */\n objectName?: Selector<Env, string>;\n /** The auth Durable Object namespace — the DO-backed mode. Needed for `@better-auth/scim`, which requires native transactions that D1 has none of. The object owns the auth tables, so `/api/auth/*` and identity resolution both go through it. Typed as `AuthNamespaceLike` because `createDoAuthWiring` resolves through `idFromName` + `get` and has no `getByName` fallback — both members are load-bearing here, and `ShardNamespaceLike` leaves both optional. */\n namespace?: Selector<Env, AuthNamespaceLike>;\n /** Build the better-auth options from `env` (secret, plugins, email/password, …). */\n options: (env: Env) => LunoraAuthOptions;\n}']:[]],
|
|
343
|
+
`:"",M=e=>[...e.hasStorage?["/** `.storage(...)` declaration — one bucket (required) plus optional extra named buckets and signed-URL config. Backs `ctx.storage` AND the studio file browser. */\ninterface StorageDeclaration<Env> {\n /** The default R2 bucket binding (the bare `ctx.storage`). */\n bucket: Selector<Env, R2BucketLike>;\n /** Extra named buckets, reached via `ctx.storage.bucket(\"name\")` and the studio's bucket picker. */\n buckets?: Record<string, Selector<Env, R2BucketLike>>;\n /** Public base URL signed/public object URLs resolve against. Omit it and `ctx.storage` in a mutation, action or HTTP handler (and the studio's copy-URL) signs against the origin the request reached the worker on — no per-environment value to ship. Queries get no such fallback (a live query re-runs with no request behind it), so a query that signs URLs needs this set. */\n publicBaseUrl?: Selector<Env, string>;\n /** R2 S3-API credentials (`{ accountId, accessKeyId, secretAccessKey, bucket, jurisdiction? }`) enabling `ctx.storage.getPresignedUrl` — native S3 presigned URLs that hit R2 directly, bypassing the worker. Omit to use only the worker-signed `getSignedUrl` path. */\n s3?: Selector<Env, R2S3Credentials>;\n /** HMAC secret for signed URLs. */\n signingSecret?: Selector<Env, string>;\n}"]:[],...e.hasScheduler?["/** `.scheduler(...)` declaration — the `SchedulerDO` namespace. Backs `ctx.scheduler` AND the studio's scheduled-jobs view. The origin its callbacks dispatch back to is not declared here: the DO reads `env.LUNORA_ORIGIN_URL` at fire time, because a caller-supplied dispatch target would be an SSRF vector. */\ninterface SchedulerDeclaration<Env> {\n /** The `SchedulerDO` namespace binding (typically `env.SCHEDULER`). */\n namespace: Selector<Env, DurableObjectNamespaceLike & ShardNamespaceLike>;\n}"]:[],...e.hasGlobal?["/** `.global(...)` declaration — the D1 binding backing `.global()` tables. Backs cross-tenant `ctx.db` reads/writes AND the studio's global data browser. */\ninterface GlobalDeclaration<Env> {\n /** The D1 binding (typically `env.DB`). */\n d1: Selector<Env, D1DatabaseLike>;\n /** The worker origin used to fan reverse cross-backend relations across shards. Without it, such a relation throws a clear error. */\n origin?: Selector<Env, string>;\n}"]:[],...e.hasHyperdriveGlobal?['/** `.hyperdriveGlobal(...)` declaration — backs `.global({ backend: "hyperdrive" })` tables on a Postgres/MySQL database via Hyperdrive. Stays reactive: the writer is injected as `globalDb` and the broadcast hook drives live queries. */\ninterface HyperdriveGlobalDeclaration<Env> {\n /** The Hyperdrive engine — selects the Postgres or MySQL dialect. */\n engine: HyperdriveEngine;\n /** Build the `SqlExec` from `env` — e.g. `buildPgExec(fromPostgresJs(async () => (await import("postgres")).default(env.HYPERDRIVE.connectionString, { fetch_types: false, max: 5 })))`. Called per request, by the shard and by the stateless worker\'s admin plane, so return an exec on a connection opened for that call: never cache a driver or socket at module scope, since Workers refuse I/O across requests. */\n exec: (env: Env) => SqlExec;\n /** The worker origin used to fan reverse cross-backend relations across shards. Without it, such a relation throws a clear error. */\n origin?: Selector<Env, string>;\n}']:[],...e.hasAuth?['/** `.auth(...)` declaration — better-auth options plus the storage the adapter reads. Give it `d1` (the default) or `namespace` (a Durable Object that hosts the auth tables), never both. The builder owns the lazy build + `ensureMigrated` dance and wires `authHandler` / `resolveIdentity` / `authAdmin`. */\ninterface AuthDeclaration<Env> {\n /** The D1 binding the auth SQL adapter is wired over (via `lunoraD1Adapter`). Omit only when using `namespace`. */\n d1?: Selector<Env, unknown>;\n /** Shared secret the worker presents on the object\'s internal session route. REQUIRED with `namespace`: the binding is reachable from any worker bound to it, so the secret — not the binding — is the authorization boundary. Without it identity resolution fails closed. */\n internalSecret?: Selector<Env, string>;\n /** Name of the Durable Object instance holding the auth tables. Defaults to `"auth"`. Set it to run separate auth objects (per deployment, per tenant) off one namespace. */\n objectName?: Selector<Env, string>;\n /** The auth Durable Object namespace — the DO-backed mode. Needed for `@better-auth/scim`, which requires native transactions that D1 has none of. The object owns the auth tables, so `/api/auth/*` and identity resolution both go through it. Typed as `AuthNamespaceLike` because `createDoAuthWiring` resolves through `idFromName` + `get` and has no `getByName` fallback — both members are load-bearing here, and `ShardNamespaceLike` leaves both optional. */\n namespace?: Selector<Env, AuthNamespaceLike>;\n /** Build the better-auth options from `env` (secret, plugins, email/password, …). */\n options: (env: Env) => LunoraAuthOptions;\n}']:[]],_=e=>[...e.hasAccess?[" private accessSelector?: Selector<Env, CreateAccessResolverOptions | undefined>;"]:[],...e.hasAdminRevocations===!1?[]:[" private adminRevocationsSelector?: Selector<Env, ShardNamespaceLike>;"]," private adminToken?: Selector<Env, string>;",...e.hasAuth?[" private authDeclaration?: AuthDeclaration<Env>;"]:[]," private cdcEnabled = false;",...e.hasDeliveryAuthorization===!1?[]:[' private deliveryAuthorizationSelector?: ShardConfig["deliveryAuthorization"];']," private reactiveCacheConfig: boolean | { maxBytes?: number; maxEntries?: number } = false;",' private maxRelationKeysLimit?: ShardConfig["maxRelationKeys"];',' private observabilitySink?: ShardConfig["observability"];',' private relationExistsPushDownMode?: ShardConfig["relationExistsPushDown"];'," private readonly extendFns: ((env: Env, derived: Readonly<WorkerOptions>) => Partial<WorkerOptions>)[] = [];",...e.hasGlobal?[" private globalDeclaration?: GlobalDeclaration<Env>;"]:[],...e.hasHyperdriveGlobal?[" private hyperdriveGlobalDeclaration?: HyperdriveGlobalDeclaration<Env>;"]:[]," private httpRouterApp?: HttpRouterLike;"," private readonly routeMap: Record<string, Route> = {};",...e.hasScheduler?[" private schedulerDeclaration?: SchedulerDeclaration<Env>;"]:[],...w(e)?[" private readonly shardExtras: Partial<ShardConfig> = {};"]:[],...l(e)?[" private shardRegistrySelector?: Selector<Env, ShardNamespaceLike | ShardRegistryRpc>;"]:[]," private shardSelector?: Selector<Env, ShardNamespaceLike>;",...e.hasSourcedTables?[' private sourceClientFactory?: NonNullable<ShardConfig["sourceClient"]>;']:[],...e.hasStorage?[" private storageDeclaration?: StorageDeclaration<Env>;"]:[]],B=e=>f(e).map(({configKey:r,doc:t,method:a})=>` /** ${t} */
|
|
344
344
|
public ${a}(factory: (env: Env) => ReturnType<NonNullable<ShardConfig["${r}"]>>): this {
|
|
345
345
|
this.shardExtras.${r} = factory as NonNullable<ShardConfig["${r}"]>;
|
|
346
346
|
|
|
@@ -399,7 +399,12 @@ const buildGlobalCdcApplier =
|
|
|
399
399
|
this.shardSelector = selector;
|
|
400
400
|
|
|
401
401
|
return this;
|
|
402
|
-
}`,...
|
|
402
|
+
}`,...e.hasAdminRevocations===!1?[]:[` /** The \`AdminRevocationDO\` namespace (typically \`env.ADMIN_REVOCATIONS\`). Records revoked named admin tokens where a point-in-time restore of the default shard cannot rewind them. Without it no named admin token can be created and any that exist are refused. */
|
|
403
|
+
public adminRevocations(selector: Selector<Env, ShardNamespaceLike>): this {
|
|
404
|
+
this.adminRevocationsSelector = selector;
|
|
405
|
+
|
|
406
|
+
return this;
|
|
407
|
+
}`],...l(e)?[" /** The `ShardRegistryDO` namespace (typically `env.SHARD_REGISTRY`). Each shard registers itself for the `.shardBy()` tables it writes, and cross-shard export, CDC sync and migrations fan out to the shards it lists. Without it they refuse a `.shardBy()` table. */\n public shardRegistry(selector: Selector<Env, ShardNamespaceLike | ShardRegistryRpc>): this {\n this.shardRegistrySelector = selector;\n\n return this;\n }"]:[],...e.hasSourcedTables?[` /** Resolve the SQL client a \`.source(...)\` table's ingest poll reads from, given the wrangler Hyperdrive binding it named. Build it with \`@lunora/hyperdrive\`'s \`createHyperdrive\` plus your driver adapter. REQUIRED for a sourced table: without it every poll tick records "no sourceClient resolved for binding" and the table stays empty. */
|
|
403
408
|
public sourceClient(factory: (env: Env, binding: string) => ReturnType<NonNullable<ShardConfig["sourceClient"]>>): this {
|
|
404
409
|
this.sourceClientFactory = factory as NonNullable<ShardConfig["sourceClient"]>;
|
|
405
410
|
|
|
@@ -409,7 +414,7 @@ const buildGlobalCdcApplier =
|
|
|
409
414
|
this.storageDeclaration = declaration;
|
|
410
415
|
|
|
411
416
|
return this;
|
|
412
|
-
}`]:[],...
|
|
417
|
+
}`]:[],...B(e)],H=e=>{const r=a=>e.hasScheduler?`
|
|
413
418
|
...(this.schedulerDeclaration ? { scheduler: this.resolveScheduler(env) as unknown as ${a}["scheduler"] } : {}),`:"",t=[" cdc: this.cdcEnabled,"," reactiveCache: this.reactiveCacheConfig,"," ...(this.maxRelationKeysLimit === undefined ? {} : { maxRelationKeys: this.maxRelationKeysLimit }),"," ...(this.observabilitySink === undefined ? {} : { observability: this.observabilitySink }),",...e.hasDeliveryAuthorization===!1?[]:[" ...(this.deliveryAuthorizationSelector === undefined ? {} : { deliveryAuthorization: this.deliveryAuthorizationSelector }),"]," ...(this.relationExistsPushDownMode === undefined ? {} : { relationExistsPushDown: this.relationExistsPushDownMode }),",...e.hasGlobal?[` ...(this.globalDeclaration
|
|
414
419
|
? {
|
|
415
420
|
d1: (rawEnv: Record<string, unknown>, request?: { bookmark?: string; cdc?: boolean; cdcRetentionMs?: number; identity?: Record<string, unknown> | undefined; onBookmark?: (bookmark: string | undefined) => void; userId?: string | null | undefined }) => {
|
|
@@ -517,10 +522,10 @@ const buildGlobalCdcApplier =
|
|
|
517
522
|
? {
|
|
518
523
|
scheduler: (rawEnv: Record<string, unknown>) => this.resolveScheduler(rawEnv as Env),
|
|
519
524
|
}
|
|
520
|
-
: {}),`]:[],...
|
|
525
|
+
: {}),`]:[],...l(e)?[" ...(this.shardRegistrySelector ? { shardRegistry: (rawEnv: Record<string, unknown>) => this.shardRegistrySelector?.(rawEnv as Env) } : {}),"]:[],...e.hasSourcedTables?[" ...(this.sourceClientFactory === undefined ? {} : { sourceClient: this.sourceClientFactory }),"]:[],...e.hasStorage?[" ...(this.storageDeclaration ? { storage: (rawEnv: Record<string, unknown>, origin?: string) => this.resolveStorage(rawEnv as Env, origin) } : {}),"]:[],...w(e)?[" ...this.shardExtras,"]:[]];return t.length>0?`
|
|
521
526
|
${t.join(`
|
|
522
527
|
`)}
|
|
523
|
-
`:""},U=e=>e?['import * as lunoraIdentityContract from "../identity.js";']:[],F=(e,r)=>e?['import type { CreateAccessResolverOptions } from "@lunora/cloudflare-access";',`import { createAccessResolver${r?", composeResolvers":""} } from "@lunora/cloudflare-access";`]:[],Q=e=>e?['import { createKvIntrospectorFromEnv } from "@lunora/bindings/kv";']:[],z=e=>e?['import { createVectorAdminIntrospector } from "@lunora/bindings/vectors";']:[],J=e=>e?['import type { D1CtxDbOptions, D1DatabaseLike, D1Exec } from "@lunora/d1";','import { applyCdcChanges, createD1CtxDb, emitD1QueryCost, exportGlobalRows, facetGlobalColumn, importGlobalRows, listGlobalTables, readD1CdcChanges, readGlobalTablePage, retryingExec } from "@lunora/d1";']:[],K=e=>e?['import notifyConfig from "../notify.js";']:[],V=e=>k(e)?e.lazyFunctions===!0?['import type { dispatchAgentEmail } from "@lunora/agent/inbound";']:['import { dispatchAgentEmail } from "@lunora/agent/inbound";']:[],Y=e=>k(e)&&e.lazyFunctions!==!0?['import * as lunoraAgentDefinitions from "../agents.js";']:[],X=e=>{const{hasFramework:r,hasGlobal:t,hasHyperdriveGlobal:a,hasQueue:n,useUmbrella:s}=e,i=s?"lunorash/runtime":"@lunora/runtime",d=["ExecutionContextLike","HttpRouterLike","LunoraWorker","Route","ScheduledControllerLike","ShardNamespaceLike",...
|
|
528
|
+
`:""},U=e=>e?['import * as lunoraIdentityContract from "../identity.js";']:[],F=(e,r)=>e?['import type { CreateAccessResolverOptions } from "@lunora/cloudflare-access";',`import { createAccessResolver${r?", composeResolvers":""} } from "@lunora/cloudflare-access";`]:[],Q=e=>e?['import { createKvIntrospectorFromEnv } from "@lunora/bindings/kv";']:[],z=e=>e?['import { createVectorAdminIntrospector } from "@lunora/bindings/vectors";']:[],J=e=>e?['import type { D1CtxDbOptions, D1DatabaseLike, D1Exec } from "@lunora/d1";','import { applyCdcChanges, createD1CtxDb, emitD1QueryCost, exportGlobalRows, facetGlobalColumn, importGlobalRows, listGlobalTables, readD1CdcChanges, readGlobalTablePage, retryingExec } from "@lunora/d1";']:[],K=e=>e?['import notifyConfig from "../notify.js";']:[],V=e=>k(e)?e.lazyFunctions===!0?['import type { dispatchAgentEmail } from "@lunora/agent/inbound";']:['import { dispatchAgentEmail } from "@lunora/agent/inbound";']:[],Y=e=>k(e)&&e.lazyFunctions!==!0?['import * as lunoraAgentDefinitions from "../agents.js";']:[],X=e=>{const{hasFramework:r,hasGlobal:t,hasHyperdriveGlobal:a,hasQueue:n,useUmbrella:s}=e,i=s?"lunorash/runtime":"@lunora/runtime",d=["ExecutionContextLike","HttpRouterLike","LunoraWorker","Route","ScheduledControllerLike","ShardNamespaceLike",...l(e)?["ShardRegistryRpc"]:[],"WorkerOptions",...n?["TriggerTrace"]:[],...t?["GlobalIntrospector"]:[],...e.tables.length>0?["ShardingInfo"]:[],...r?["FrameworkHostHandler"]:[]],c=[...t||a?["createCrossShardRelationCapabilities"]:[],...l(e)?["createDynamicShardRegistry","createQueryCoordinator"]:[],"createWorker",...e.jurisdiction?["declareAppJurisdiction"]:[],"resolveLogArchiveFromEnv",...e.hasAuth?["memoizeIdentity"]:[],...r?["withFrameworkWorker"]:[]].join(", ");return[`import type { ${[...d].toSorted((o,u)=>o.localeCompare(u)).join(", ")} } from "${i}";`,`import { ${c} } from "${i}";`]},Z=e=>{const{hasAccess:r,hasAuth:t,hasGlobal:a,hasHyperdriveGlobal:n,hasKvIntrospector:s,hasQueue:i,hasScheduler:d,hasStorage:c,hasWorkflow:o}=e;return[...t?['import type { AuthNamespaceLike, LunoraAuth, LunoraAuthOptions } from "@lunora/auth";','import type * as LunoraAuthModule from "./authModule.js";']:[],...F(r,t),...J(a),...n?['import type { HyperdriveEngine } from "@lunora/hyperdrive/global";','import { applyHyperdriveGlobalCdc, createHyperdriveGlobalCtxDb, createHyperdriveGlobalIntrospector, exportHyperdriveGlobalRows, importHyperdriveGlobalRows, readHyperdriveGlobalCdc } from "@lunora/hyperdrive/global";','import type { SqlCtxDbOptions, SqlExec } from "@lunora/sql-store";']:[],...Q(s),...z(e.hasVectors),...d?['import type { DurableObjectNamespaceLike } from "@lunora/scheduler";','import { createScheduler } from "@lunora/scheduler";']:[],...c?['import type { R2BucketLike, R2S3Credentials, Storage } from "@lunora/storage";','import { createBucketStorage, createStorage } from "@lunora/storage";']:[],...o?['import { createWorkflowsRestClient } from "@lunora/workflow";']:[],...V(e),...X(e),"",...U(e.identity),...Y(e),...a||n?['import schema from "../schema.js";']:[],...K(e.hasNotify),'import { LUNORA_CRONS } from "./crons.js";','import { LUNORA_FUNCTIONS } from "./functions.js";',...i?['import { createQueueCaptureSink, dispatchQueueBatch, shouldCaptureQueue } from "@lunora/queue";',...e.lazyFunctions===!0?[]:['import { LUNORA_QUEUE_REGISTRY } from "./queues.js";']]:[],'import { createShardDO } from "./shard.js";',...p(e)?[`import { liveStreamRouter } from "${e.useUmbrella?"lunorash/server":"@lunora/server"}";`]:[],...e.hasVectors?['import { LUNORA_VECTOR_INDEXES } from "./vectors.js";']:[]]},ee=e=>e.jurisdiction&&e.jurisdictionPinsAuth===!0?`
|
|
524
529
|
// The schema's jurisdiction pins the auth object like every other DO.
|
|
525
530
|
jurisdiction: ${JSON.stringify(e.jurisdiction)},`:"",te=e=>typeof e=="string"?`{ mode: { kind: ${JSON.stringify(e)} } }`:`{ mode: { field: ${JSON.stringify(e.field)}, kind: "shardBy" } }`,re=e=>[...e.tables.length>0?[` const tableSharding = new Map<string, ShardingInfo>([
|
|
526
531
|
${e.tables.map(r=>` [${JSON.stringify(r.name)}, ${te(r.shardMode)}],`).join(`
|
|
@@ -528,14 +533,18 @@ ${e.tables.map(r=>` [${JSON.stringify(r.name)}, ${te(r.shardMode)}],`
|
|
|
528
533
|
]);
|
|
529
534
|
|
|
530
535
|
options.listSchemaTables = () => [...tableSharding.keys()];
|
|
531
|
-
options.resolveTableSharding = (table) => tableSharding.get(table);`]:[],...
|
|
536
|
+
options.resolveTableSharding = (table) => tableSharding.get(table);`]:[],...l(e)?[` const shardRegistry = this.shardRegistrySelector?.(env);
|
|
532
537
|
|
|
533
538
|
if (shardRegistry) {
|
|
534
539
|
options.queryCoordinator = createQueryCoordinator({ registry: createDynamicShardRegistry({ ${e.jurisdiction?`jurisdiction: ${JSON.stringify(e.jurisdiction)}, `:""}env, namespace: shardRegistry }) });
|
|
535
|
-
}`]:[]],
|
|
540
|
+
}`]:[]],ae=[` const adminRevocations = this.adminRevocationsSelector?.(env);
|
|
541
|
+
|
|
542
|
+
if (adminRevocations) {
|
|
543
|
+
options.adminRevocations = adminRevocations;
|
|
544
|
+
}`],S=e=>(e.liveStreamDeclarations??[]).map(r=>{if(I(r.exportName,"live stream export name"),!L.test(r.filePath))throw new Error(`@lunora/codegen: live stream file path is not safe to import: ${JSON.stringify(r.filePath)}`);return` { id: ${JSON.stringify(r.id)}, load: () => import("../${r.filePath}.js").then((m) => m.${r.exportName}) },`}),ne=e=>p(e)?[" httpRouter: liveStreamRouter([",...S(e)," ], this.httpRouterApp),"]:[" ...(this.httpRouterApp ? { httpRouter: this.httpRouterApp } : {}),"],se=e=>p(e)?[" liveStreamRoutes: [",...(e.liveStreamDeclarations??[]).flatMap(r=>[` ${JSON.stringify(`GET /live/${r.id}/connect`)},`,` ${JSON.stringify(`POST /live/${r.id}/control`)},`])," ],"]:[],oe=e=>p(e)?`liveStreamRouter([
|
|
536
545
|
${S(e).join(`
|
|
537
546
|
`)}
|
|
538
|
-
], host)`:"host",
|
|
547
|
+
], host)`:"host",ie=e=>[...re(e),...e.hasAdminRevocations===!1?[]:ae,...e.hasScheduler?[` if (this.schedulerDeclaration) {
|
|
539
548
|
options.schedulerDO = this.schedulerDeclaration.namespace(env);
|
|
540
549
|
}`]:[],...e.hasWorkflow?[` options.workflowsClient = (workflowEnv) => {
|
|
541
550
|
const source = workflowEnv as Record<string, unknown>;
|
|
@@ -804,10 +813,10 @@ ${S(e).join(`
|
|
|
804
813
|
}`]:[],...e.voiceAgents&&e.voiceAgents.length>0?[` options.voiceAgents = {
|
|
805
814
|
${e.voiceAgents.map(r=>` ${JSON.stringify(r.exportName)}: (env as Record<string, unknown>)[${JSON.stringify(r.bindingName)}] as ShardNamespaceLike,`).join(`
|
|
806
815
|
`)}
|
|
807
|
-
};`]:[]],
|
|
816
|
+
};`]:[]],ce=e=>e.hasQueue?[` queue: ${e.lazyFunctions===!0?"async ":""}(batch: unknown, queueEnv: unknown, _context: ExecutionContextLike, trigger: TriggerTrace, ${e.liveStreams?"queueLive":"_live"}: Parameters<typeof dispatchQueueBatch>[2]["live"], queueFetch: Parameters<typeof dispatchQueueBatch>[2]["fetchImpl"]): Promise<void> =>`,` dispatchQueueBatch(batch as Parameters<typeof dispatchQueueBatch>[0], ${e.lazyFunctions===!0?'(await import("./queues.js")).LUNORA_QUEUE_REGISTRY':"LUNORA_QUEUE_REGISTRY"}, {`," capture: shouldCaptureQueue(queueEnv as Record<string, unknown>)",` ? createQueueCaptureSink(queueEnv as Record<string, unknown>${e.jurisdiction?`, { jurisdiction: ${JSON.stringify(e.jurisdiction)} }`:""})`," : undefined,"," env: queueEnv as Record<string, unknown>,"," holdSeconds: trigger.holdSeconds,"," traceparent: trigger.traceparent,"," fetchImpl: queueFetch,",...e.liveStreams?[" live: queueLive,"]:[]," }),"]:[],le=e=>[' aiChatBinding: (env as Record<string, unknown>)["AI"] as WorkerOptions["aiChatBinding"],',' aiOptInLevel: (env as Record<string, unknown>)["LUNORA_AI_OPT_IN"] as WorkerOptions["aiOptInLevel"],'," cronJobs: LUNORA_CRONS,"," functions: LUNORA_FUNCTIONS,",...e.identity?[` identity: lunoraIdentityContract.${e.identity.exportName},`]:[],...e.jurisdiction?[` jurisdiction: ${JSON.stringify(e.jurisdiction)},`]:[],...e.wantsArchitecture?[" architecture: deferred.architecture,"]:[],...e.wantsOpenApi?[" openApiSpec: deferred.openApiSpec,"]:[],...e.wantsOpenRpc?[" openRpcSpec: deferred.openRpcSpec,"]:[],...ce(e),...ne(e),...se(e)," routes: this.routeMap,",...e.liveStreamsWithheld?[" liveStreams: false,"]:[]," shardDO: this.shardSelector?.(env) ?? (undefined as unknown as ShardNamespaceLike),"],de=e=>e?`
|
|
808
817
|
/** The identity memo per \`env\` object, owned by one assembled worker. */
|
|
809
818
|
type IdentityMemoStore = WeakMap<object, ReturnType<typeof memoizeIdentity>>;
|
|
810
|
-
`:"",E=e=>e.hasAuth||e.wantsArchitecture||e.wantsOpenApi||e.wantsOpenRpc,
|
|
819
|
+
`:"",E=e=>e.hasAuth||e.wantsArchitecture||e.wantsOpenApi||e.wantsOpenRpc,he=e=>{if(!E(e))return"";const t=[[e.wantsArchitecture,"architecture","unknown",'(await import("./architecture.js")).architecture'],[e.hasAuth,"auth","typeof LunoraAuthModule",'await import("./authModule.js")'],[e.wantsOpenApi,"openApiSpec","unknown",'(await import("./openapi.js")).openApiSpec'],[e.wantsOpenRpc,"openRpcSpec","unknown",'(await import("./openrpc.js")).openRpcSpec']].filter(([a])=>a).map(([,a,n,s])=>[a,n,s]);return`
|
|
811
820
|
/** What the worker reads only once a request arrives: loaded then, not at isolate startup (Cloudflare caps startup at 1 s of CPU). */
|
|
812
821
|
interface DeferredModules {
|
|
813
822
|
${t.map(([a,n])=>` ${a}: ${n};`).join(`
|
|
@@ -824,13 +833,13 @@ ${t.map(([a,,n])=>` ${a}: ${n},`).join(`
|
|
|
824
833
|
`)}
|
|
825
834
|
};
|
|
826
835
|
})());
|
|
827
|
-
`},
|
|
836
|
+
`},ue=(e,r)=>{const t=`buildWorker(rawEnv as Env${r})`,a=e?`
|
|
828
837
|
await ensureAuth(env);`:"",n=e?`
|
|
829
838
|
await ensureAuth(rawEnv as Env);`:"";return e?{ensureAuthCall:a,ensureRawAuthCall:n,eventWorker:"target",eventWorkerLine:`
|
|
830
839
|
const target = (await authReady(rawEnv as Env)) ? (worker ??= ${t}) : ${t};`}:{ensureAuthCall:a,ensureRawAuthCall:n,eventWorker:"worker",eventWorkerLine:`
|
|
831
|
-
worker ??= ${t};`}},
|
|
832
|
-
const deferred = await loadDeferredModules();`}:{asyncIfDeferred:"",deferredArgument:"",deferredParameter:"",loadDeferredLine:""},
|
|
833
|
-
`:"",
|
|
840
|
+
worker ??= ${t};`}},pe=e=>E(e)?{asyncIfDeferred:"async ",deferredArgument:", deferred",deferredParameter:", deferred: DeferredModules",loadDeferredLine:`
|
|
841
|
+
const deferred = await loadDeferredModules();`}:{asyncIfDeferred:"",deferredArgument:"",deferredParameter:"",loadDeferredLine:""},fe=e=>e?`${y}export { authDiscoveryPathsFor, createAuth, createAuthAdmin, createAuthAuditReader, createDoAuthWiring, d1Executor, handleAuthDiscoveryRequest, handleAuthRequest, lunoraD1Adapter, resolveSessionIdentity } from "@lunora/auth/worker";
|
|
842
|
+
`:"",me=e=>{const r=e.emailAgents??[];if(r.length===0)return"";const t=a=>r.map(n=>`${a}{ agent: lunoraAgentDefinitions.${n.exportName}, className: ${JSON.stringify(n.className)} },`).join(`
|
|
834
843
|
`);return e.lazyFunctions!==!0?` composed.email = dispatchAgentEmail([
|
|
835
844
|
${t(" ")}
|
|
836
845
|
]);
|
|
@@ -849,7 +858,7 @@ ${t(" ")}
|
|
|
849
858
|
return agentEmail(message, rawEnv, context);
|
|
850
859
|
};
|
|
851
860
|
|
|
852
|
-
`},be=e=>[...e.hasAuth?["AuthDeclaration"]:[],"ComposedApp",...e.hasGlobal?["GlobalDeclaration"]:[],"LunoraConfig",...e.hasScheduler?["SchedulerDeclaration"]:[],"Selector",...e.hasStorage?["StorageDeclaration"]:[]].toSorted((r,t)=>r.localeCompare(t)).join(", "),
|
|
861
|
+
`},be=e=>[...e.hasAuth?["AuthDeclaration"]:[],"ComposedApp",...e.hasGlobal?["GlobalDeclaration"]:[],"LunoraConfig",...e.hasScheduler?["SchedulerDeclaration"]:[],"Selector",...e.hasStorage?["StorageDeclaration"]:[]].toSorted((r,t)=>r.localeCompare(t)).join(", "),we=e=>{const r=(e.hasVectors??!0)&&(e.vectorIndexCount??0)>0,t={...e,hasVectors:r},{hasAuth:a}=t,n=M(t),s=ie(t),i=a?` let auth: LunoraAuth | null = null;
|
|
853
862
|
let authInit: Promise<void> | null = null;
|
|
854
863
|
// One memo per env for THIS assembled worker: every worker it builds reuses it, but a second
|
|
855
864
|
// \`assemble()\` has its own auth closure and must not share.
|
|
@@ -920,8 +929,8 @@ ${t(" ")}
|
|
|
920
929
|
return false;
|
|
921
930
|
},
|
|
922
931
|
);
|
|
923
|
-
`:"",{asyncIfDeferred:
|
|
924
|
-
host ? withFrameworkWorker(${
|
|
932
|
+
`:"",{asyncIfDeferred:c,deferredArgument:o,deferredParameter:u,loadDeferredLine:h}=pe(t),{ensureAuthCall:R,ensureRawAuthCall:D,eventWorker:m,eventWorkerLine:b}=ue(a,o),g=`${a?"() => auth, identityMemos":"() => null"}${o}`,A=`${a?"getAuth: () => LunoraAuth | null, identityMemos: IdentityMemoStore":"_getAuth: () => null"}${u}`,v=`env: Env${u}`,x=t.hasFramework?` const buildWorker = (${v}): LunoraWorker =>
|
|
933
|
+
host ? withFrameworkWorker(${oe(t)}, (hostEnv) => this.buildWorkerOptions(hostEnv as Env, ${g})) : createWorker(this.buildWorkerOptions(env, ${g}));`:` const buildWorker = (${v}): LunoraWorker => createWorker(this.buildWorkerOptions(env, ${g}));`,C=t.hasFramework?"host?: FrameworkHostHandler":"",O=me(t),T=` /** Materialise the standalone Cloudflare worker + \`ShardDO\` class. */
|
|
925
934
|
public build(): ComposedApp {
|
|
926
935
|
return this.assemble();
|
|
927
936
|
}${t.hasFramework?"\n\n /** Compose Lunora's realtime plane INTO a meta-framework's Cloudflare handler (SvelteKit/Astro/Nuxt). The framework `host` serves everything except the reserved `/_lunora/*` endpoints; pass the adapter-emitted worker (e.g. SvelteKit's `_worker.js`, Astro's `handle`). */\n public buildFrameworkWorker(host: FrameworkHostHandler): ComposedApp {\n return this.assemble(host);\n }":""}`;return`${y}${Z(t).join(`
|
|
@@ -932,7 +941,7 @@ type Selector<Env, T> = (env: Env) => T | undefined;
|
|
|
932
941
|
|
|
933
942
|
/** The generated \`createShardDO\` config — \`.observability()\`, \`.maxRelationKeys()\` and the long-tail \`.ai()\` / \`.kv()\` / … methods pass straight through to it. */
|
|
934
943
|
type ShardConfig = NonNullable<Parameters<typeof createShardDO>[0]>;
|
|
935
|
-
${
|
|
944
|
+
${de(a)}${he(t)}${t.jurisdiction?`
|
|
936
945
|
// Module scope, so every isolate loading this script (the worker and each Durable
|
|
937
946
|
// Object class it exports) knows the schema's jurisdiction before a request runs.
|
|
938
947
|
// \`@lunora/mail\` reads it to pin its shard RPC like every other DO path.
|
|
@@ -957,7 +966,7 @@ interface ComposedApp extends LunoraWorker {
|
|
|
957
966
|
* first request so per-isolate singletons are built once.
|
|
958
967
|
*/
|
|
959
968
|
class AppBuilder<Env extends object> {
|
|
960
|
-
${
|
|
969
|
+
${_(t).join(`
|
|
961
970
|
`)}
|
|
962
971
|
|
|
963
972
|
private emailHandler?: (env: Env) => (message: unknown, env: unknown, context: ExecutionContextLike) => Promise<void>;
|
|
@@ -982,23 +991,23 @@ ${x}
|
|
|
982
991
|
const composed: ComposedApp = {
|
|
983
992
|
ShardDO,
|
|
984
993
|
fetch: async (request: Request, rawEnv: unknown, context: ExecutionContextLike): Promise<Response> => {
|
|
985
|
-
const env = rawEnv as Env;${h}${
|
|
994
|
+
const env = rawEnv as Env;${h}${R}
|
|
986
995
|
worker ??= buildWorker(env${o});
|
|
987
996
|
|
|
988
997
|
return worker.fetch(request, rawEnv, context);
|
|
989
998
|
},
|
|
990
|
-
scheduled: async (controller: ScheduledControllerLike, rawEnv: unknown, context: ExecutionContextLike): Promise<void> => {${h}${
|
|
999
|
+
scheduled: async (controller: ScheduledControllerLike, rawEnv: unknown, context: ExecutionContextLike): Promise<void> => {${h}${b}
|
|
991
1000
|
|
|
992
|
-
return ${
|
|
1001
|
+
return ${m}.scheduled(controller, rawEnv, context);
|
|
993
1002
|
},
|
|
994
|
-
serverQuery: ${
|
|
1003
|
+
serverQuery: ${c}(request, rawEnv, reference, args, options) => {${h}${D}
|
|
995
1004
|
worker ??= buildWorker(rawEnv as Env${o});
|
|
996
1005
|
|
|
997
1006
|
return worker.serverQuery(request, rawEnv, reference, args, options);
|
|
998
1007
|
},${t.hasQueue||t.hasFramework?`
|
|
999
|
-
queue: async (batch: unknown, rawEnv: unknown, context: ExecutionContextLike): Promise<void> => {${h}${
|
|
1008
|
+
queue: async (batch: unknown, rawEnv: unknown, context: ExecutionContextLike): Promise<void> => {${h}${b}
|
|
1000
1009
|
|
|
1001
|
-
return ${
|
|
1010
|
+
return ${m}.queue?.(batch, rawEnv, context);
|
|
1002
1011
|
},`:""}
|
|
1003
1012
|
};
|
|
1004
1013
|
|
|
@@ -1013,9 +1022,9 @@ ${t.hasFramework?`
|
|
|
1013
1022
|
// of its own the host's is the only one there is — forward to it rather than
|
|
1014
1023
|
// dropping the entry.
|
|
1015
1024
|
if (!composed.email && host && typeof host === "object" && typeof host.email === "function") {
|
|
1016
|
-
composed.email = ${
|
|
1025
|
+
composed.email = ${c}(message, rawEnv, context) => {${h}${b}
|
|
1017
1026
|
|
|
1018
|
-
return ${
|
|
1027
|
+
return ${m}.email?.(message, rawEnv, context) ?? Promise.resolve();
|
|
1019
1028
|
};
|
|
1020
1029
|
}
|
|
1021
1030
|
`:""}
|
|
@@ -1086,4 +1095,4 @@ const defineApp = <Env extends object>(): AppBuilder<Env> => new AppBuilder<Env>
|
|
|
1086
1095
|
|
|
1087
1096
|
export { AppBuilder, defineApp };
|
|
1088
1097
|
export type { ${be(t)} };
|
|
1089
|
-
`};export{
|
|
1098
|
+
`};export{we as emitApp,fe as emitAuthModule};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{G as
|
|
1
|
+
import{G as i,d as c}from"./shared-DhqnD5R3.mjs";import{i as g}from"./schema-BgM8A3XV.mjs";const f=r=>r?`${i}/**
|
|
2
2
|
* The \`SchedulerDO\` Durable Object class, re-exported so a worker entry can
|
|
3
3
|
* forward it — wrangler binds only what the entry exports:
|
|
4
4
|
*
|
|
@@ -8,8 +8,8 @@ import{G as a,d as c}from"./shared-DhqnD5R3.mjs";import{i as y}from"./schema-BgM
|
|
|
8
8
|
* forwards this module for you whenever it exists.
|
|
9
9
|
*/
|
|
10
10
|
export { SchedulerDO } from "@lunora/scheduler";
|
|
11
|
-
`:"",u=(
|
|
12
|
-
import { hostedShardRegistry } from "${c(
|
|
11
|
+
`:"",u=(r,t,o)=>{if(!r.some(n=>g(n)))return"";const e=o?JSON.stringify(o):"undefined";return`${i}import { WorkerEntrypoint } from "cloudflare:workers";
|
|
12
|
+
import { hostedShardRegistry } from "${c(t).do}";
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* The \`ShardRegistryDO\` Durable Object class — the live set of shard keys per
|
|
@@ -24,7 +24,7 @@ import { hostedShardRegistry } from "${c(r).do}";
|
|
|
24
24
|
* \`export *\`. A Vite-first (class-A) app needs neither line — its generated
|
|
25
25
|
* worker entry does both whenever this module exists.
|
|
26
26
|
*/
|
|
27
|
-
export { ShardRegistryDO } from "${c(
|
|
27
|
+
export { ShardRegistryDO } from "${c(t).do}";
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
30
|
* The registry's RPC surface. A worker that calls a registry this worker hosts binds
|
|
@@ -49,29 +49,44 @@ export class ShardRegistryEntrypoint extends WorkerEntrypoint<{ SHARD_REGISTRY:
|
|
|
49
49
|
return hostedShardRegistry(this.env, ${e}).snapshot();
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
|
-
`},R=
|
|
53
|
-
*
|
|
54
|
-
*
|
|
52
|
+
`},R=r=>`${i}/**
|
|
53
|
+
* The \`AdminRevocationDO\` Durable Object class: remembers revoked named admin
|
|
54
|
+
* tokens where a point-in-time restore of the default shard cannot rewind them.
|
|
55
|
+
* Re-exported so a worker entry can forward it (wrangler binds only what the
|
|
56
|
+
* entry exports), next to \`.adminRevocations((env) => env.ADMIN_REVOCATIONS)\`:
|
|
57
|
+
*
|
|
58
|
+
* \`export { AdminRevocationDO } from "./lunora/_generated/adminRevocations.js";\`
|
|
59
|
+
*
|
|
60
|
+
* Name the class in a hand-written entry: binding inference provisions
|
|
61
|
+
* \`ADMIN_REVOCATIONS\` off the entry's named exports, and cannot see through an
|
|
62
|
+
* \`export *\`. A Vite-first (class-A) app needs neither line. Without the
|
|
63
|
+
* binding no named admin token can be created, and any that exist are refused.
|
|
64
|
+
*/
|
|
65
|
+
export { AdminRevocationDO } from "${c(r).do}";
|
|
66
|
+
`,b=r=>`${i}/**
|
|
67
|
+
* Host the shard, the scheduler, the shard registry and the admin revocation
|
|
68
|
+
* store in ONE Durable Object class, so the app spends one of the account's
|
|
69
|
+
* classes instead of four. A
|
|
55
70
|
* Vite-first (class-A) app needs nothing more: its generated worker entry builds
|
|
56
71
|
* \`LunoraDO\` from these. A hand-written entry does the same by hand:
|
|
57
72
|
*
|
|
58
|
-
* \`export const LunoraDO = mergeDurableObjects({ shard: app.ShardDO, scheduler: SchedulerDO, shardRegistry: ShardRegistryDO });\`
|
|
73
|
+
* \`export const LunoraDO = mergeDurableObjects({ shard: app.ShardDO, scheduler: SchedulerDO, shardRegistry: ShardRegistryDO, adminRevocations: AdminRevocationDO });\`
|
|
59
74
|
*
|
|
60
|
-
* and passes \`roleNamespace(env.SHARD, "scheduler")\` / \`roleNamespace(env.SHARD, "shardRegistry")\`
|
|
61
|
-
* to \`.scheduler()\` / \`.shardRegistry()\`. Merge before the first deploy only:
|
|
75
|
+
* and passes \`roleNamespace(env.SHARD, "scheduler")\` / \`roleNamespace(env.SHARD, "shardRegistry")\` /
|
|
76
|
+
* \`roleNamespace(env.SHARD, "adminRevocations")\` to \`.scheduler()\` / \`.shardRegistry()\` / \`.adminRevocations()\`. Merge before the first deploy only:
|
|
62
77
|
* data already in \`ShardDO\` does not move, and a deployed merge cannot be undone.
|
|
63
78
|
*/
|
|
64
|
-
export { mergeDurableObjects, roleNamespace } from "${c(
|
|
65
|
-
`,
|
|
79
|
+
export { mergeDurableObjects, roleNamespace } from "${c(r).do}";
|
|
80
|
+
`,w=r=>{const t=new Map;for(const s of r){const d=t.get(s.cron);d?d.push(s):t.set(s.cron,[s])}const o=[...t.keys()].map(s=>` ${JSON.stringify(s)},`).join(`
|
|
66
81
|
`),e=o.length>0?`
|
|
67
82
|
${o}
|
|
68
|
-
`:"",
|
|
69
|
-
`);return` ${JSON.stringify(
|
|
83
|
+
`:"",n=[...t.entries()].map(([s,d])=>{const l=d.map(a=>{const m=a.workflow?`workflow: ${JSON.stringify(a.workflow.className)}`:`functionPath: ${JSON.stringify(a.functionPath)}`;return` { name: ${JSON.stringify(a.name)}, ${m}, args: ${JSON.stringify(a.args)} },`}).join(`
|
|
84
|
+
`);return` ${JSON.stringify(s)}: [
|
|
70
85
|
${l}
|
|
71
86
|
],`}).join(`
|
|
72
|
-
`),h=
|
|
73
|
-
${
|
|
74
|
-
`:"";return`${
|
|
87
|
+
`),h=n.length>0?`
|
|
88
|
+
${n}
|
|
89
|
+
`:"";return`${i}/**
|
|
75
90
|
* One scheduled cron invocation. Exactly one target is set: \`functionPath\` is
|
|
76
91
|
* the \`namespace:fn\` dispatch ref (matches \`__lunoraRef\`), invoked on the
|
|
77
92
|
* shard; \`workflow\` is a workflow class name (its \`ctx.exports\` key) whose durable workflow is
|
|
@@ -96,10 +111,10 @@ export const LUNORA_CRON_TRIGGERS: ReadonlyArray<string> = [${e}];
|
|
|
96
111
|
* looks up \`event.cron\` here and dispatches every job in the list.
|
|
97
112
|
*/
|
|
98
113
|
export const LUNORA_CRONS: Record<string, ReadonlyArray<LunoraCronJob>> = {${h}};
|
|
99
|
-
`},
|
|
100
|
-
`),o=
|
|
101
|
-
${
|
|
102
|
-
`:"";return`${
|
|
114
|
+
`},S=r=>{const t=[...r].toSorted((e,n)=>e.name.localeCompare(n.name)).map(e=>{const n=[`name: ${JSON.stringify(e.name)}`,`table: ${JSON.stringify(e.table)}`];return e.field!==void 0&&n.push(`field: ${JSON.stringify(e.field)}`),e.dimensions!==void 0&&n.push(`dimensions: ${JSON.stringify(e.dimensions)}`),e.metric!==void 0&&n.push(`metric: ${JSON.stringify(e.metric)}`),e.metadata!==void 0&&n.push(`metadata: ${JSON.stringify(e.metadata)}`),` { ${n.join(", ")} },`}).join(`
|
|
115
|
+
`),o=t.length>0?`
|
|
116
|
+
${t}
|
|
117
|
+
`:"";return`${i}/**
|
|
103
118
|
* One vector index declared in \`schema.ts\` — an inline \`.vectorize()\` column
|
|
104
119
|
* or a standalone \`defineVectorIndex()\`. \`field\` is the source column (absent
|
|
105
120
|
* for a \`select\`-derived Shape B index); \`metadata\` lists the row fields
|
|
@@ -120,4 +135,4 @@ export interface LunoraVectorIndex {
|
|
|
120
135
|
* \`createWorker({ vectorIntrospector })\` to back the studio's vector browser.
|
|
121
136
|
*/
|
|
122
137
|
export const LUNORA_VECTOR_INDEXES: ReadonlyArray<LunoraVectorIndex> = [${o}];
|
|
123
|
-
`},
|
|
138
|
+
`},v=r=>[...new Set(r.map(t=>t.cron))];export{R as emitAdminRevocations,w as emitCrons,b as emitDurableObjects,f as emitScheduler,u as emitShardRegistry,S as emitVectors,v as emitWranglerCronTriggers};
|