@lunora/codegen 1.0.0-alpha.240 → 1.0.0-alpha.241

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.
@@ -1,9 +1,9 @@
1
- import{A as w}from"./capabilities-DJJWVEtk.mjs";import{G as y}from"./shared-DjUziztz.mjs";const k=e=>`has${e.charAt(0).toUpperCase()}${e.slice(1)}`,b=w.map(({appMethod:e,key:t})=>[k(t),e.method,e.configKey,e.doc]),g=e=>b.some(([t])=>e[t]),S=e=>e?['import * as lunoraIdentityContract from "../identity.js";']:[],E=(e,t)=>e?['import type { CreateAccessResolverOptions } from "@lunora/cloudflare-access";',`import { createAccessResolver${t?", composeResolvers":""} } from "@lunora/cloudflare-access";`]:[],D=e=>e?['import { createKvIntrospectorFromEnv } from "@lunora/bindings/kv";']:[],x=e=>e?['import { createVectorAdminIntrospector } from "@lunora/bindings/vectors";']:[],R=e=>e?['import type { D1CtxDbOptions, D1DatabaseLike, D1Exec } from "@lunora/d1";','import { applyCdcChanges, createD1CtxDb, emitD1QueryCost, exportGlobalRows, facetGlobalColumn, importGlobalRows, listGlobalTables, readD1CdcChanges, readGlobalTablePage, retryingExec } from "@lunora/d1";']:[],A=e=>e?['import notifyConfig from "../notify.js";']:[],m=e=>(e.emailAgents?.length??0)>0,C=e=>m(e)?['import { dispatchAgentEmail } from "@lunora/agent/inbound";']:[],O=e=>m(e)?['import * as lunoraAgentDefinitions from "../agents.js";']:[],T=e=>{const{hasFramework:t,hasGlobal:a,hasHyperdriveGlobal:r,hasQueue:n,useUmbrella:i}=e,o=i?"lunorash/runtime":"@lunora/runtime",l=["ExecutionContextLike","HttpRouterLike","LunoraWorker","Route","ScheduledControllerLike","ShardNamespaceLike","WorkerOptions",...n?["TriggerTrace"]:[],...a?["GlobalIntrospector","AdminTableResolver"]:[],...t?["FrameworkHostHandler"]:[]],s=[...a||r?["createCrossShardRelationCapabilities"]:[],"createWorker",...e.jurisdiction?["declareAppJurisdiction"]:[],"resolveLogArchiveFromEnv",...t?["withFrameworkWorker"]:[]].join(", ");return[`import type { ${[...l].toSorted((c,d)=>c.localeCompare(d)).join(", ")} } from "${o}";`,`import { ${s} } from "${o}";`]},N=e=>{const{hasAccess:t,hasAuth:a,hasGlobal:r,hasHyperdriveGlobal:n,hasKvIntrospector:i,hasQueue:o,hasScheduler:l,hasStorage:s,hasWorkflow:c,wantsOpenApi:d,wantsOpenRpc:h}=e;return[...a?['import type { AuthNamespaceLike, LunoraAuth, LunoraAuthOptions } from "@lunora/auth";','import { createAuth, createAuthAdmin, createAuthAuditReader, createDoAuthWiring, d1Executor, ensureMigrated, handleAuthRequest, lunoraD1Adapter } from "@lunora/auth";']:[],...E(t,a),...R(r),...n?['import type { HyperdriveEngine } from "@lunora/hyperdrive/global";','import { createHyperdriveGlobalCtxDb } from "@lunora/hyperdrive/global";','import type { SqlCtxDbOptions, SqlExec } from "@lunora/sql-store";']:[],...D(i),...x(e.hasVectors===!0),...l?['import type { DurableObjectNamespaceLike } from "@lunora/scheduler";','import { createScheduler } from "@lunora/scheduler";']:[],...s?['import type { R2BucketLike, R2S3Credentials, Storage } from "@lunora/storage";','import { createBucketStorage, createStorage } from "@lunora/storage";']:[],...c?['import { createWorkflowsRestClient } from "@lunora/workflow";']:[],...C(e),...T(e),"",...S(e.identity),...O(e),...r||n?['import schema from "../schema.js";']:[],...A(e.hasNotify),'import { LUNORA_CRONS } from "./crons.js";','import { LUNORA_FUNCTIONS } from "./functions.js";',...o?['import { createQueueCaptureSink, dispatchQueueBatch, shouldCaptureQueue } from "@lunora/queue";','import { LUNORA_QUEUE_REGISTRY } from "./queues.js";']:[],...d?['import { openApiSpec } from "./openapi.js";']:[],...h?['import { openRpcSpec } from "./openrpc.js";']:[],'import { createShardDO } from "./shard.js";',...e.hasVectors===!0?['import { LUNORA_VECTOR_INDEXES } from "./vectors.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. */\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)))`. 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}']:[]],L=e=>[...e.hasAccess?[" private accessSelector?: Selector<Env, CreateAccessResolverOptions | undefined>;"]:[]," private adminToken?: Selector<Env, string>;",...e.hasAuth?[" private authDeclaration?: AuthDeclaration<Env>;"]:[]," private cdcEnabled = false;"," 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>;"]:[],...g(e)?[" private readonly shardExtras: Partial<ShardConfig> = {};"]:[]," private shardSelector?: Selector<Env, ShardNamespaceLike>;",...e.hasSourcedTables?[' private sourceClientFactory?: NonNullable<ShardConfig["sourceClient"]>;']:[],...e.hasStorage?[" private storageDeclaration?: StorageDeclaration<Env>;"]:[]],q=e=>b.filter(([t])=>e[t]).map(([,t,a,r])=>` /** ${r} */
2
- public ${t}(factory: (env: Env) => ReturnType<NonNullable<ShardConfig["${a}"]>>): this {
3
- this.shardExtras.${a} = factory as NonNullable<ShardConfig["${a}"]>;
1
+ import{A as w}from"./capabilities-DJJWVEtk.mjs";import{i as k}from"./ir-BgM8A3XV.mjs";import{G as S}from"./shared-DjUziztz.mjs";const E=e=>`has${e.charAt(0).toUpperCase()}${e.slice(1)}`,g=w.map(({appMethod:e,key:t})=>[E(t),e.method,e.configKey,e.doc]),m=e=>g.some(([t])=>e[t]),D=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";']:[],A=e=>e?['import { createVectorAdminIntrospector } from "@lunora/bindings/vectors";']:[],C=e=>e?['import type { D1CtxDbOptions, D1DatabaseLike, D1Exec } from "@lunora/d1";','import { applyCdcChanges, createD1CtxDb, emitD1QueryCost, exportGlobalRows, facetGlobalColumn, importGlobalRows, listGlobalTables, readD1CdcChanges, readGlobalTablePage, retryingExec } from "@lunora/d1";']:[],O=e=>e?['import notifyConfig from "../notify.js";']:[],v=e=>(e.emailAgents?.length??0)>0,T=e=>v(e)?['import { dispatchAgentEmail } from "@lunora/agent/inbound";']:[],N=e=>v(e)?['import * as lunoraAgentDefinitions from "../agents.js";']:[],d=e=>e.tables.some(t=>k(t)),I=e=>{const{hasFramework:t,hasGlobal:r,hasHyperdriveGlobal:a,hasQueue:n,useUmbrella:i}=e,o=i?"lunorash/runtime":"@lunora/runtime",l=["ExecutionContextLike","HttpRouterLike","LunoraWorker","Route","ScheduledControllerLike","ShardNamespaceLike","WorkerOptions",...n?["TriggerTrace"]:[],...r?["GlobalIntrospector"]:[],...e.tables.length>0?["ShardingInfo"]:[],...t?["FrameworkHostHandler"]:[]],s=[...r||a?["createCrossShardRelationCapabilities"]:[],...d(e)?["createDynamicShardRegistry","createQueryCoordinator"]:[],"createWorker",...e.jurisdiction?["declareAppJurisdiction"]:[],"resolveLogArchiveFromEnv",...t?["withFrameworkWorker"]:[]].join(", ");return[`import type { ${[...l].toSorted((c,h)=>c.localeCompare(h)).join(", ")} } from "${o}";`,`import { ${s} } from "${o}";`]},L=e=>{const{hasAccess:t,hasAuth:r,hasGlobal:a,hasHyperdriveGlobal:n,hasKvIntrospector:i,hasQueue:o,hasScheduler:l,hasStorage:s,hasWorkflow:c,wantsOpenApi:h,wantsOpenRpc:u}=e;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),...C(a),...n?['import type { HyperdriveEngine } from "@lunora/hyperdrive/global";','import { createHyperdriveGlobalCtxDb } from "@lunora/hyperdrive/global";','import type { SqlCtxDbOptions, SqlExec } from "@lunora/sql-store";']:[],...x(i),...A(e.hasVectors===!0),...l?['import type { DurableObjectNamespaceLike } from "@lunora/scheduler";','import { createScheduler } from "@lunora/scheduler";']:[],...s?['import type { R2BucketLike, R2S3Credentials, Storage } from "@lunora/storage";','import { createBucketStorage, createStorage } from "@lunora/storage";']:[],...c?['import { createWorkflowsRestClient } from "@lunora/workflow";']:[],...T(e),...I(e),"",...D(e.identity),...N(e),...a||n?['import schema from "../schema.js";']:[],...O(e.hasNotify),'import { LUNORA_CRONS } from "./crons.js";','import { LUNORA_FUNCTIONS } from "./functions.js";',...o?['import { createQueueCaptureSink, dispatchQueueBatch, shouldCaptureQueue } from "@lunora/queue";','import { LUNORA_QUEUE_REGISTRY } from "./queues.js";']:[],...h?['import { openApiSpec } from "./openapi.js";']:[],...u?['import { openRpcSpec } from "./openrpc.js";']:[],'import { createShardDO } from "./shard.js";',...e.hasVectors===!0?['import { LUNORA_VECTOR_INDEXES } from "./vectors.js";']:[]]},q=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)))`. 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 cdcEnabled = false;"," 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>;"]:[],...m(e)?[" private readonly shardExtras: Partial<ShardConfig> = {};"]:[],...d(e)?[" private shardRegistrySelector?: Selector<Env, ShardNamespaceLike>;"]:[]," private shardSelector?: Selector<Env, ShardNamespaceLike>;",...e.hasSourcedTables?[' private sourceClientFactory?: NonNullable<ShardConfig["sourceClient"]>;']:[],...e.hasStorage?[" private storageDeclaration?: StorageDeclaration<Env>;"]:[]],G=e=>g.filter(([t])=>e[t]).map(([,t,r,a])=>` /** ${a} */
2
+ public ${t}(factory: (env: Env) => ReturnType<NonNullable<ShardConfig["${r}"]>>): this {
3
+ this.shardExtras.${r} = factory as NonNullable<ShardConfig["${r}"]>;
4
4
 
5
5
  return this;
6
- }`),j=e=>[...e.hasAccess?[" /** Wire Cloudflare Access (Zero Trust) — feeds the verified Access identity into `ctx.auth` / RLS via `resolveIdentity`. Call it with no argument when the Access policy is attached to the Worker (the identity arrives on the execution context; nothing to configure); pass `teamDomain` + `aud` for a hostname-scoped Access application, whose `Cf-Access-Jwt-Assertion` JWT is verified against your team JWKS. When `.auth(...)` is also configured, Access is composed ahead of it (Access wins when it authenticated the caller; everyone else falls through to the app session). */\n public access(selector?: Selector<Env, CreateAccessResolverOptions>): this {\n this.accessSelector = selector ?? (() => undefined);\n\n return this;\n }"]:[],` /** Bearer token gating the \`/_lunora/admin/*\` endpoints the studio calls. */
6
+ }`),B=e=>[...e.hasAccess?[" /** Wire Cloudflare Access (Zero Trust) — feeds the verified Access identity into `ctx.auth` / RLS via `resolveIdentity`. Call it with no argument when the Access policy is attached to the Worker (the identity arrives on the execution context; nothing to configure); pass `teamDomain` + `aud` for a hostname-scoped Access application, whose `Cf-Access-Jwt-Assertion` JWT is verified against your team JWKS. When `.auth(...)` is also configured, Access is composed ahead of it (Access wins when it authenticated the caller; everyone else falls through to the app session). */\n public access(selector?: Selector<Env, CreateAccessResolverOptions>): this {\n this.accessSelector = selector ?? (() => undefined);\n\n return this;\n }"]:[],` /** Bearer token gating the \`/_lunora/admin/*\` endpoints the studio calls. */
7
7
  public admin(selector: Selector<Env, string>): this {
8
8
  this.adminToken = selector;
9
9
 
@@ -52,7 +52,7 @@ import{A as w}from"./capabilities-DJJWVEtk.mjs";import{G as y}from"./shared-DjUz
52
52
  this.shardSelector = selector;
53
53
 
54
54
  return this;
55
- }`,...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. */
55
+ }`,...d(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>): 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. */
56
56
  public sourceClient(factory: (env: Env, binding: string) => ReturnType<NonNullable<ShardConfig["sourceClient"]>>): this {
57
57
  this.sourceClientFactory = factory as NonNullable<ShardConfig["sourceClient"]>;
58
58
 
@@ -62,8 +62,8 @@ import{A as w}from"./capabilities-DJJWVEtk.mjs";import{G as y}from"./shared-DjUz
62
62
  this.storageDeclaration = declaration;
63
63
 
64
64
  return this;
65
- }`]:[],...q(e)],G=e=>{const t=r=>e.hasScheduler?`
66
- ...(this.schedulerDeclaration ? { scheduler: this.resolveScheduler(env) as unknown as ${r}["scheduler"] } : {}),`:"",a=[" cdc: this.cdcEnabled,"," reactiveCache: this.reactiveCacheConfig,"," ...(this.maxRelationKeysLimit === undefined ? {} : { maxRelationKeys: this.maxRelationKeysLimit }),"," ...(this.observabilitySink === undefined ? {} : { observability: this.observabilitySink }),"," ...(this.relationExistsPushDownMode === undefined ? {} : { relationExistsPushDown: this.relationExistsPushDownMode }),",...e.hasGlobal?[` ...(this.globalDeclaration
65
+ }`]:[],...G(e)],P=e=>{const t=a=>e.hasScheduler?`
66
+ ...(this.schedulerDeclaration ? { scheduler: this.resolveScheduler(env) as unknown as ${a}["scheduler"] } : {}),`:"",r=[" cdc: this.cdcEnabled,"," reactiveCache: this.reactiveCacheConfig,"," ...(this.maxRelationKeysLimit === undefined ? {} : { maxRelationKeys: this.maxRelationKeysLimit }),"," ...(this.observabilitySink === undefined ? {} : { observability: this.observabilitySink }),"," ...(this.relationExistsPushDownMode === undefined ? {} : { relationExistsPushDown: this.relationExistsPushDownMode }),",...e.hasGlobal?[` ...(this.globalDeclaration
67
67
  ? {
68
68
  d1: (rawEnv: Record<string, unknown>, request?: { bookmark?: string; cdc?: boolean; cdcRetentionMs?: number; identity?: Record<string, unknown>; onBookmark?: (bookmark: string | undefined) => void; userId?: string | null }) => {
69
69
  const env = rawEnv as Env;
@@ -134,12 +134,22 @@ import{A as w}from"./capabilities-DJJWVEtk.mjs";import{G as y}from"./shared-DjUz
134
134
  ? {
135
135
  scheduler: (rawEnv: Record<string, unknown>) => this.resolveScheduler(rawEnv as Env),
136
136
  }
137
- : {}),`]:[],...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) } : {}),"]:[],...g(e)?[" ...this.shardExtras,"]:[]];return a.length>0?`
138
- ${a.join(`
137
+ : {}),`]:[],...d(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) } : {}),"]:[],...m(e)?[" ...this.shardExtras,"]:[]];return r.length>0?`
138
+ ${r.join(`
139
139
  `)}
140
- `:""},B=e=>e.jurisdiction&&e.jurisdictionPinsAuth===!0?`
140
+ `:""},W=e=>e.jurisdiction&&e.jurisdictionPinsAuth===!0?`
141
141
  // The schema's jurisdiction pins the auth object like every other DO.
142
- jurisdiction: ${JSON.stringify(e.jurisdiction)},`:"",P=e=>[...e.tableNames.length>0?[` options.listSchemaTables = () => [${e.tableNames.map(t=>JSON.stringify(t)).join(", ")}];`]:[],...e.hasScheduler?[` if (this.schedulerDeclaration) {
142
+ jurisdiction: ${JSON.stringify(e.jurisdiction)},`:"",_=e=>typeof e=="string"?`{ mode: { kind: ${JSON.stringify(e)} } }`:`{ mode: { field: ${JSON.stringify(e.field)}, kind: "shardBy" } }`,$=e=>[...e.tables.length>0?[` const tableSharding = new Map<string, ShardingInfo>([
143
+ ${e.tables.map(t=>` [${JSON.stringify(t.name)}, ${_(t.shardMode)}],`).join(`
144
+ `)}
145
+ ]);
146
+
147
+ options.listSchemaTables = () => [...tableSharding.keys()];
148
+ options.resolveTableSharding = (table) => tableSharding.get(table);`]:[],...d(e)?[` const shardRegistry = this.shardRegistrySelector?.(env);
149
+
150
+ if (shardRegistry) {
151
+ options.queryCoordinator = createQueryCoordinator({ registry: createDynamicShardRegistry({ ${e.jurisdiction?`jurisdiction: ${JSON.stringify(e.jurisdiction)}, `:""}namespace: shardRegistry }) });
152
+ }`]:[]],H=e=>[...$(e),...e.hasScheduler?[` if (this.schedulerDeclaration) {
143
153
  options.schedulerDO = this.schedulerDeclaration.namespace(env);
144
154
  }`]:[],...e.hasWorkflow?[` options.workflowsClient = (workflowEnv) => {
145
155
  const source = workflowEnv as Record<string, unknown>;
@@ -154,14 +164,9 @@ ${a.join(`
154
164
 
155
165
  if (database) {
156
166
  options.globalIntrospector = buildGlobalIntrospector(database);
157
- // \`resolveTableSharding\`/\`importGlobals\` wire the admin bulk-import
158
- // endpoint: without the former, EVERY row (including a \`.global()\`
159
- // table's) routes to the default shard, so a global table is never
160
- // recognised as global and the latter is never reached — the
161
- // endpoint answers 200 with \`inserted: {}\` for a write that never
162
- // happened. Both are mechanical over the schema this file already
163
- // imports, so there is nothing project-specific to configure.
164
- options.resolveTableSharding = buildTableShardingResolver();
167
+ // \`importGlobals\` wires the admin bulk-import endpoint's global
168
+ // plane: the rows \`resolveTableSharding\` classifies as \`.global()\`
169
+ // land here, and without it they are reported, not written.
165
170
  options.importGlobals = buildGlobalImporter(database, this.cdcEnabled);
166
171
  // The read/replay half of the same admin plane. Each one is the
167
172
  // only reason its endpoint can see the global storage plane at
@@ -206,7 +211,7 @@ ${a.join(`
206
211
  // than more emitted code: request-path logic in generated output can only be
207
212
  // typechecked, never unit-tested.
208
213
  const authWiring = createDoAuthWiring({
209
- internalSecret: authDeclaration.internalSecret?.(env),${B(e)}
214
+ internalSecret: authDeclaration.internalSecret?.(env),${W(e)}
210
215
  namespace: authNamespace(env),
211
216
  objectName: authDeclaration.objectName?.(env),
212
217
  });
@@ -284,14 +289,14 @@ ${a.join(`
284
289
  }`]:[],...e.voiceAgents&&e.voiceAgents.length>0?[` options.voiceAgents = {
285
290
  ${e.voiceAgents.map(t=>` ${JSON.stringify(t.exportName)}: (env as Record<string, unknown>)[${JSON.stringify(t.bindingName)}] as ShardNamespaceLike,`).join(`
286
291
  `)}
287
- };`]:[]],W=e=>[" cronJobs: LUNORA_CRONS,"," functions: LUNORA_FUNCTIONS,",...e.identity?[` identity: lunoraIdentityContract.${e.identity.exportName},`]:[],...e.jurisdiction?[` jurisdiction: ${JSON.stringify(e.jurisdiction)},`]:[],...e.wantsOpenApi?[" openApiSpec,"]:[],...e.wantsOpenRpc?[" openRpcSpec,"]:[],...e.hasQueue?[" queue: (batch: unknown, queueEnv: unknown, _context: ExecutionContextLike, trigger: TriggerTrace): 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,"," }),"]:[]," ...(this.httpRouterApp ? { httpRouter: this.httpRouterApp } : {}),"," routes: this.routeMap,"," shardDO: this.shardSelector?.(env) ?? (undefined as unknown as ShardNamespaceLike),"],_=e=>e.hasScheduler?`
292
+ };`]:[]],U=e=>[" cronJobs: LUNORA_CRONS,"," functions: LUNORA_FUNCTIONS,",...e.identity?[` identity: lunoraIdentityContract.${e.identity.exportName},`]:[],...e.jurisdiction?[` jurisdiction: ${JSON.stringify(e.jurisdiction)},`]:[],...e.wantsOpenApi?[" openApiSpec,"]:[],...e.wantsOpenRpc?[" openRpcSpec,"]:[],...e.hasQueue?[" queue: (batch: unknown, queueEnv: unknown, _context: ExecutionContextLike, trigger: TriggerTrace): 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,"," }),"]:[]," ...(this.httpRouterApp ? { httpRouter: this.httpRouterApp } : {}),"," routes: this.routeMap,"," shardDO: this.shardSelector?.(env) ?? (undefined as unknown as ShardNamespaceLike),"],F=e=>e.hasScheduler?`
288
293
  /** Resolve the \`SchedulerDO\`-backed scheduler for this env; \`undefined\` until the namespace is wired. */
289
294
  private resolveScheduler(env: Env): ReturnType<typeof createScheduler> | undefined {
290
295
  const namespace = this.schedulerDeclaration?.namespace(env);
291
296
 
292
297
  return namespace ? createScheduler({${e.jurisdiction?` jurisdiction: ${JSON.stringify(e.jurisdiction)},`:""} namespace }) : undefined;
293
298
  }
294
- `:"",$=e=>e?`
299
+ `:"",M=e=>e?`
295
300
  /**
296
301
  * One bucket's \`Storage\`, signing under the name it is registered as.
297
302
  *
@@ -396,7 +401,7 @@ ${e.voiceAgents.map(t=>` ${JSON.stringify(t.exportName)}: (env as Rec
396
401
  storageUpload: (key: string, body: ArrayBuffer, opts?: { bucket?: string; contentType?: string; sha256?: string }) => pick(opts?.bucket).upload(key, body, opts),
397
402
  };
398
403
  }
399
- `:"",H=e=>e?`
404
+ `:"",Q=e=>e?`
400
405
  /**
401
406
  * 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\`).
402
407
  *
@@ -518,19 +523,6 @@ const buildGlobalIntrospector = (database: D1DatabaseLike): GlobalIntrospector =
518
523
  };
519
524
  };
520
525
 
521
- /**
522
- * \`resolveTableSharding\` for the admin bulk-import endpoint: a lookup over each
523
- * table's declared \`shardMode\` (\`defineTable(...).global()\` / \`.shardBy(field)\`
524
- * already record exactly this shape on the table) — mechanical, nothing to
525
- * configure per project. \`undefined\` for a table the schema doesn't declare, so
526
- * the import endpoint's own unknown-table handling still applies.
527
- */
528
- const buildTableShardingResolver = (): AdminTableResolver => (table) => {
529
- const declared = (schema as unknown as D1CtxDbOptions["schema"]).tables[table];
530
-
531
- return declared?.shardMode ? { mode: declared.shardMode } : undefined;
532
- };
533
-
534
526
  /**
535
527
  * \`importGlobals\` for the admin bulk-import endpoint: routes \`.global()\` rows
536
528
  * through the same D1 writer \`.global()\` reads/writes already use, via
@@ -631,9 +623,9 @@ const buildGlobalCdcApplier =
631
623
 
632
624
  return request.changes.length;
633
625
  };
634
- `:"",U=e=>[...e.hasAuth?["AuthDeclaration"]:[],"ComposedApp",...e.hasGlobal?["GlobalDeclaration"]:[],"LunoraConfig",...e.hasScheduler?["SchedulerDeclaration"]:[],"Selector",...e.hasStorage?["StorageDeclaration"]:[]].toSorted((t,a)=>t.localeCompare(a)).join(", "),Q=e=>{const t={...e,hasVectors:(e.hasVectors??!0)&&(e.vectorIndexCount??0)>0},{hasAuth:a}=t,r=I(t),n=P(t),i=a?` let auth: LunoraAuth | null = null;
626
+ `:"",K=e=>[...e.hasAuth?["AuthDeclaration"]:[],"ComposedApp",...e.hasGlobal?["GlobalDeclaration"]:[],"LunoraConfig",...e.hasScheduler?["SchedulerDeclaration"]:[],"Selector",...e.hasStorage?["StorageDeclaration"]:[]].toSorted((t,r)=>t.localeCompare(r)).join(", "),Y=e=>{const t={...e,hasVectors:(e.hasVectors??!0)&&(e.vectorIndexCount??0)>0},{hasAuth:r}=t,a=q(t),n=H(t),i=r?` let auth: LunoraAuth | null = null;
635
627
  let authInit: Promise<void> | null = null;
636
- `:"",o=a?`
628
+ `:"",o=r?`
637
629
  const initAuth = async (env: Env): Promise<void> => {
638
630
  if (!this.authDeclaration) {
639
631
  return;
@@ -682,17 +674,17 @@ const buildGlobalCdcApplier =
682
674
  authInit = null;
683
675
  throw error;
684
676
  }));
685
- `:"",l=a?`
686
- await ensureAuth(env);`:"",s=a?"() => auth":"() => null",c=a?"getAuth: () => LunoraAuth | null":"_getAuth: () => null",d=t.hasFramework?` const buildWorker = (env: Env): LunoraWorker =>
687
- 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=t.hasFramework?"host?: FrameworkHostHandler":"",u=t.emailAgents??[],v=u.length>0?` composed.email = dispatchAgentEmail([
688
- ${u.map(p=>` { agent: lunoraAgentDefinitions.${p.exportName}, binding: ${JSON.stringify(p.bindingName)} },`).join(`
677
+ `:"",l=r?`
678
+ await ensureAuth(env);`:"",s=r?"() => auth":"() => null",c=r?"getAuth: () => LunoraAuth | null":"_getAuth: () => null",h=t.hasFramework?` const buildWorker = (env: Env): LunoraWorker =>
679
+ 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}));`,u=t.hasFramework?"host?: FrameworkHostHandler":"",p=t.emailAgents??[],y=p.length>0?` composed.email = dispatchAgentEmail([
680
+ ${p.map(b=>` { agent: lunoraAgentDefinitions.${b.exportName}, binding: ${JSON.stringify(b.bindingName)} },`).join(`
689
681
  `)}
690
682
  ]);
691
683
 
692
684
  `:"",f=` /** Materialise the standalone Cloudflare worker + \`ShardDO\` class. */
693
685
  public build(): ComposedApp {
694
686
  return this.assemble();
695
- }${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}${N(t).join(`
687
+ }${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`${S}${L(t).join(`
696
688
  `)}
697
689
 
698
690
  /** Read a value off the per-request \`env\`. Returns \`undefined\` to leave the capability unconfigured (its \`ctx.*\`/admin surface stays a clear-error stub). */
@@ -706,9 +698,9 @@ ${t.jurisdiction?`
706
698
  // \`@lunora/mail\` reads it to pin its shard RPC like every other DO path.
707
699
  declareAppJurisdiction(${JSON.stringify(t.jurisdiction)});
708
700
  `:""}
709
- ${r.join(`
701
+ ${a.join(`
710
702
 
711
- `)}${r.length>0?`
703
+ `)}${a.length>0?`
712
704
 
713
705
  `:""}/** The composed app: a Cloudflare module worker (\`fetch\` / \`scheduled\` / optional \`email\`) plus the \`ShardDO\` class binding. */
714
706
  interface ComposedApp extends LunoraWorker {
@@ -725,27 +717,27 @@ interface ComposedApp extends LunoraWorker {
725
717
  * first request so per-isolate singletons are built once.
726
718
  */
727
719
  class AppBuilder<Env extends object> {
728
- ${L(t).join(`
720
+ ${j(t).join(`
729
721
  `)}
730
722
 
731
723
  private emailHandler?: (env: Env) => (message: unknown, env: unknown, context: ExecutionContextLike) => Promise<void>;
732
724
 
733
- ${j(t).join(`
725
+ ${B(t).join(`
734
726
 
735
727
  `)}
736
728
 
737
729
  ${f}
738
730
 
739
731
  /** Build the shard DO + compose the worker (standalone or framework-hosted), wrapping the lazy per-isolate singletons + auth init. */
740
- private assemble(${h}): ComposedApp {
741
- const ShardDO = createShardDO({${G(t)}});
732
+ private assemble(${u}): ComposedApp {
733
+ const ShardDO = createShardDO({${P(t)}});
742
734
 
743
735
  // Per-isolate singletons: the worker (and auth instance) are expensive to
744
736
  // build, so the first request constructs them and every later request on
745
737
  // the same isolate reuses them.
746
738
  let worker: LunoraWorker | null = null;
747
739
  ${i}${o}
748
- ${d}
740
+ ${h}
749
741
 
750
742
  const composed: ComposedApp = {
751
743
  ShardDO,
@@ -772,7 +764,7 @@ ${d}
772
764
  },`:""}
773
765
  };
774
766
 
775
- ${v} if (this.emailHandler) {
767
+ ${y} if (this.emailHandler) {
776
768
  const handler = this.emailHandler;
777
769
 
778
770
  composed.email = (message, rawEnv, context) => handler(rawEnv as Env)(message, rawEnv, context);
@@ -792,11 +784,11 @@ ${t.hasFramework?`
792
784
  `:""}
793
785
  return composed;
794
786
  }
795
- ${_(t)}${$(t.hasStorage)}
787
+ ${F(t)}${M(t.hasStorage)}
796
788
  /** Fan the recorded declarations into the worker-side \`createWorker\` options. */
797
789
  private buildWorkerOptions(env: Env, ${c}): WorkerOptions {
798
790
  const options: WorkerOptions = {
799
- ${W(t).join(`
791
+ ${U(t).join(`
800
792
  `)}
801
793
  };
802
794
 
@@ -815,7 +807,7 @@ ${n.join(`
815
807
  return options;
816
808
  }
817
809
  }
818
- ${H(t.hasGlobal)}
810
+ ${Q(t.hasGlobal)}
819
811
  /**
820
812
  * Shape of the project's root \`lunora.config.*\`.
821
813
  *
@@ -848,5 +840,5 @@ interface LunoraConfig<Env extends object = object> {
848
840
  const defineApp = <Env extends object>(): AppBuilder<Env> => new AppBuilder<Env>();
849
841
 
850
842
  export { AppBuilder, defineApp };
851
- export type { ${U(t)} };
852
- `};export{Q as emitApp};
843
+ export type { ${K(t)} };
844
+ `};export{Y as emitApp};
@@ -1,4 +1,4 @@
1
- import{G as c}from"./shared-DjUziztz.mjs";const g=o=>o?`${c}/**
1
+ import{i as f}from"./ir-BgM8A3XV.mjs";import{G as c,d as m}from"./shared-DjUziztz.mjs";const u=n=>n?`${c}/**
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,15 +8,29 @@ import{G as c}from"./shared-DjUziztz.mjs";const g=o=>o?`${c}/**
8
8
  * forwards this module for you whenever it exists.
9
9
  */
10
10
  export { SchedulerDO } from "@lunora/scheduler";
11
- `:"",h=o=>{const t=new Map;for(const n of o){const a=t.get(n.cron);a?a.push(n):t.set(n.cron,[n])}const i=[...t.keys()].map(n=>` ${JSON.stringify(n)},`).join(`
12
- `),e=i.length>0?`
13
- ${i}
14
- `:"",r=[...t.entries()].map(([n,a])=>{const l=a.map(s=>{const f=s.workflow?`workflow: ${JSON.stringify(s.workflow.binding)}`:`functionPath: ${JSON.stringify(s.functionPath)}`;return` { name: ${JSON.stringify(s.name)}, ${f}, args: ${JSON.stringify(s.args)} },`}).join(`
15
- `);return` ${JSON.stringify(n)}: [
16
- ${l}
11
+ `:"",y=(n,r)=>n.some(s=>f(s))?`${c}/**
12
+ * The \`ShardRegistryDO\` Durable Object class — the live set of shard keys per
13
+ * \`.shardBy()\` table, which cross-shard export, CDC sync and migrations fan out
14
+ * to. Re-exported so a worker entry can forward it (wrangler binds only what the
15
+ * entry exports), next to \`.shardRegistry((env) => env.SHARD_REGISTRY)\`:
16
+ *
17
+ * \`export { ShardRegistryDO } from "./lunora/_generated/shardRegistry.js";\`
18
+ *
19
+ * Name the class in a hand-written entry: binding inference provisions
20
+ * \`SHARD_REGISTRY\` off the entry's named exports, and cannot see through an
21
+ * \`export *\`. A Vite-first (class-A) app needs neither line — its generated
22
+ * worker entry does both whenever this module exists.
23
+ */
24
+ export { ShardRegistryDO } from "${m(r).do}";
25
+ `:"",w=n=>{const r=new Map;for(const o of n){const a=r.get(o.cron);a?a.push(o):r.set(o.cron,[o])}const s=[...r.keys()].map(o=>` ${JSON.stringify(o)},`).join(`
26
+ `),e=s.length>0?`
27
+ ${s}
28
+ `:"",t=[...r.entries()].map(([o,a])=>{const h=a.map(i=>{const l=i.workflow?`workflow: ${JSON.stringify(i.workflow.binding)}`:`functionPath: ${JSON.stringify(i.functionPath)}`;return` { name: ${JSON.stringify(i.name)}, ${l}, args: ${JSON.stringify(i.args)} },`}).join(`
29
+ `);return` ${JSON.stringify(o)}: [
30
+ ${h}
17
31
  ],`}).join(`
18
- `),d=r.length>0?`
19
- ${r}
32
+ `),d=t.length>0?`
33
+ ${t}
20
34
  `:"";return`${c}/**
21
35
  * One scheduled cron invocation. Exactly one target is set: \`functionPath\` is
22
36
  * the \`namespace:fn\` dispatch ref (matches \`__lunoraRef\`), invoked on the
@@ -42,9 +56,9 @@ export const LUNORA_CRON_TRIGGERS: ReadonlyArray<string> = [${e}];
42
56
  * looks up \`event.cron\` here and dispatches every job in the list.
43
57
  */
44
58
  export const LUNORA_CRONS: Record<string, ReadonlyArray<LunoraCronJob>> = {${d}};
45
- `},u=o=>{const t=[...o].toSorted((e,r)=>e.name.localeCompare(r.name)).map(e=>{const r=[`name: ${JSON.stringify(e.name)}`,`table: ${JSON.stringify(e.table)}`];return e.field!==void 0&&r.push(`field: ${JSON.stringify(e.field)}`),e.dimensions!==void 0&&r.push(`dimensions: ${JSON.stringify(e.dimensions)}`),e.metric!==void 0&&r.push(`metric: ${JSON.stringify(e.metric)}`),e.metadata!==void 0&&r.push(`metadata: ${JSON.stringify(e.metadata)}`),` { ${r.join(", ")} },`}).join(`
46
- `),i=t.length>0?`
47
- ${t}
59
+ `},S=n=>{const r=[...n].toSorted((e,t)=>e.name.localeCompare(t.name)).map(e=>{const t=[`name: ${JSON.stringify(e.name)}`,`table: ${JSON.stringify(e.table)}`];return e.field!==void 0&&t.push(`field: ${JSON.stringify(e.field)}`),e.dimensions!==void 0&&t.push(`dimensions: ${JSON.stringify(e.dimensions)}`),e.metric!==void 0&&t.push(`metric: ${JSON.stringify(e.metric)}`),e.metadata!==void 0&&t.push(`metadata: ${JSON.stringify(e.metadata)}`),` { ${t.join(", ")} },`}).join(`
60
+ `),s=r.length>0?`
61
+ ${r}
48
62
  `:"";return`${c}/**
49
63
  * One vector index declared in \`schema.ts\` — an inline \`.vectorize()\` column
50
64
  * or a standalone \`defineVectorIndex()\`. \`field\` is the source column (absent
@@ -65,5 +79,5 @@ export interface LunoraVectorIndex {
65
79
  * Vectorize cannot enumerate indexes at runtime, so the worker passes this to
66
80
  * \`createWorker({ vectorIntrospector })\` to back the studio's vector browser.
67
81
  */
68
- export const LUNORA_VECTOR_INDEXES: ReadonlyArray<LunoraVectorIndex> = [${i}];
69
- `},p=o=>[...new Set(o.map(t=>t.cron))];export{h as emitCrons,g as emitScheduler,u as emitVectors,p as emitWranglerCronTriggers};
82
+ export const LUNORA_VECTOR_INDEXES: ReadonlyArray<LunoraVectorIndex> = [${s}];
83
+ `},R=n=>[...new Set(n.map(r=>r.cron))];export{w as emitCrons,u as emitScheduler,y as emitShardRegistry,S as emitVectors,R as emitWranglerCronTriggers};
@@ -0,0 +1 @@
1
+ import"./SCHEMA_SNAPSHOT_VERSION-C0oHwiJZ.mjs";import"./isD1GlobalTable-udvHAAzD.mjs";import"./ir-BgM8A3XV.mjs";import"./json-data-Chfs2Cz5.mjs";import{e as f}from"./shard-BaHiawkc.mjs";import"./shard-runtime-B5SUfdZB.mjs";import"./shared-DjUziztz.mjs";export{f as default};
@@ -0,0 +1 @@
1
+ const o=d=>typeof d.shardMode=="object"&&d.shardMode.kind==="shardBy";export{o as i};