@lunora/server 1.0.0-alpha.261 → 1.0.0-alpha.262

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.
Files changed (28) hide show
  1. package/dist/in-process.d.mts +1 -1
  2. package/dist/in-process.d.ts +1 -1
  3. package/dist/index.d.mts +97 -35
  4. package/dist/index.d.ts +97 -35
  5. package/dist/index.mjs +1 -1
  6. package/dist/otel.d.mts +1 -1
  7. package/dist/otel.d.ts +1 -1
  8. package/dist/packem_shared/{ACTION_CACHE_DEFAULT_TTL_MS-DU87Okaj.mjs → ACTION_CACHE_DEFAULT_TTL_MS-DMYtb827.mjs} +1 -1
  9. package/dist/packem_shared/{DOCUMENT_HISTORY_REDACTED_FIELDS-DHn50G0w.mjs → DOCUMENT_HISTORY_REDACTED_FIELDS-MUPXbAHR.mjs} +1 -1
  10. package/dist/packem_shared/PRESENCE_DEFAULT_TTL_MS-CKPKoWy_.mjs +1 -0
  11. package/dist/packem_shared/PROCEDURE_META-DVzrXpfa.mjs +1 -0
  12. package/dist/packem_shared/{assertShapesDeclareReadPolicies-CHqQ2eDy.mjs → assertShapesDeclareReadPolicies-BfxqaO3Z.mjs} +1 -1
  13. package/dist/packem_shared/{defineShape-CjBBjn-S.mjs → defineShape-JcqUI9iZ.mjs} +1 -1
  14. package/dist/packem_shared/initLunora-DcvCGLL_.mjs +1 -0
  15. package/dist/packem_shared/mask-Wqcb6WNS.mjs +1 -0
  16. package/dist/packem_shared/middleware-D4Z_QWhU.mjs +1 -0
  17. package/dist/packem_shared/{rls-CJ-lKTG6.mjs → rls-BoRrGSvO.mjs} +1 -1
  18. package/dist/packem_shared/{storageRules-5NQpFz_N.mjs → storageRules-DmYr_Gi9.mjs} +1 -1
  19. package/dist/packem_shared/{types.d-BOnXpMCp.d.mts → types.d-CuZXI4PC.d.mts} +39 -13
  20. package/dist/packem_shared/{types.d-BOnXpMCp.d.ts → types.d-CuZXI4PC.d.ts} +39 -13
  21. package/dist/rls/testing.mjs +1 -1
  22. package/dist/types.d.mts +1 -1
  23. package/dist/types.d.ts +1 -1
  24. package/package.json +4 -4
  25. package/dist/packem_shared/PRESENCE_DEFAULT_TTL_MS-BtGG52OZ.mjs +0 -1
  26. package/dist/packem_shared/initLunora-DH7k24N0.mjs +0 -1
  27. package/dist/packem_shared/mask-BFPGwDqW.mjs +0 -1
  28. package/dist/packem_shared/middleware-mzWrOTEE.mjs +0 -1
@@ -1,5 +1,5 @@
1
1
  import { SqlExec } from '@lunora/shard-engine';
2
- import { D as DatabaseWriter, S as Schema } from "./packem_shared/types.d-BOnXpMCp.mjs";
2
+ import { D as DatabaseWriter, S as Schema } from "./packem_shared/types.d-CuZXI4PC.mjs";
3
3
  import '@lunora/values';
4
4
  /** The kind of a registered Lunora function. */
5
5
  type FunctionKind = "action" | "mutation" | "query";
@@ -1,5 +1,5 @@
1
1
  import { SqlExec } from '@lunora/shard-engine';
2
- import { D as DatabaseWriter, S as Schema } from "./packem_shared/types.d-BOnXpMCp.js";
2
+ import { D as DatabaseWriter, S as Schema } from "./packem_shared/types.d-CuZXI4PC.js";
3
3
  import '@lunora/values';
4
4
  /** The kind of a registered Lunora function. */
5
5
  type FunctionKind = "action" | "mutation" | "query";
package/dist/index.d.mts CHANGED
@@ -1,7 +1,7 @@
1
- import { Validator, Infer, ColumnValidator, v, Id, ValidatorMap, InferValidatorMap } from '@lunora/values';
1
+ import { Validator, Infer, ColumnValidator, Id, StringColumnValidator, ValidatorMap, InferValidatorMap } from '@lunora/values';
2
2
  export { type ColumnValidator, type GeoPoint, type Id, type Infer, ValidationError, type Validator, type ValidatorKind, v } from '@lunora/values';
3
- import { A as ArgsValidator, I as InferArgs, R as RegisteredAction, E as ExposeConfig, X as X402ProcedureConfig, b as ActionCtx, M as MutationCtx, c as RegisteredMutation, Q as QueryCtx, d as RegisteredQuery, e as DurableStreamOptions, f as RegisteredStream, F as FunctionKind, T as TableDefinition, g as RegisteredFunction, V as VectorIndexDefinition, S as Schema, h as AggregateOp, G as GlobalBackend, K as KeyedRelationDefinition, i as RelationThrough, j as ThroughRelationDefinition, O as OnDeleteAction, k as RelationDefinition, l as SearchLanguage, m as SearchStrategy, n as ExternalSourceDefinition, o as TriggerBuilder, p as TriggerDefinition, q as VectorEmbedder, r as VectorMetric, s as DurableObjectJurisdiction, t as AggregateIndexDefinition, u as RankIndexDefinition, v as Secrets, w as LiveTopicRef, x as LifecycleEvent, y as ShardInitEvent, z as RegisteredLifecycleHook, W as WhisperEvent } from "./packem_shared/types.d-BOnXpMCp.mjs";
4
- export type { B as AuthState, C as CachePurge, H as DatabaseReader, D as DatabaseWriter, J as FunctionVisibility, N as GeoBoundingBox, P as GeoFilterBuilder, U as GeoIndexDefinition, Y as GeoPointInput, Z as IndexDefinition, _ as IndexRangeBuilder, $ as LifecycleEventKind, a0 as LogFields, a1 as LunoraLogMethod, a2 as LunoraLogger, a3 as LunoraMetrics, L as LunoraTracer, a4 as LunoraWideEvent, a5 as MutationStorage, a6 as PaginationOptions, a7 as PaginationResult, a8 as PatchIfResult, a9 as RankSortKey, aa as ReadOnlyStorage, ab as RelatedDirection, ac as RelatedNode, ad as RelatedOptions, ae as RelatedPage, af as RelatedStart, ag as RelatedStartReference, ah as RestCacheConfig, ai as RetryPolicy, aj as RunQueryOptions, ak as ScheduledFunctionDoc, al as ScheduledJob, am as ScheduledJobState, an as ScheduledJobView, ao as Scheduler, ap as SearchFilterBuilder, aq as SearchIndexDefinition, ar as ShardMode, as as SpanContextIds, at as SpanEvaluation, a as SpanHandle, au as SpanIdentity, av as SpanKind, aw as SpanLink, ax as SpanOptions, ay as Storage, az as StorageListOptions, aA as StorageListResult, aB as StorageMetadata, aC as StorageMultipartUpload, aD as StorageMultipartUploadOptions, aE as StorageObjectBody, aF as StorageObjectHead, aG as StorageRange, aH as StorageUploadBody, aI as StorageUploadOptions, aJ as StorageUploadResult, aK as StorageUploadedPart, aL as SystemDatabaseReader, aM as SystemDoc, aN as SystemQuery, aO as SystemTableName, aP as TableReader, aQ as TableVectorIndex, aR as TriggerAggregateOptions, aS as TriggerCtx, aT as TriggerDatabase, aU as TriggerDeleteEvent, aV as TriggerEvent, aW as TriggerGroupByEntry, aX as TriggerGroupByOptions, aY as TriggerHandler, aZ as TriggerInsertEvent, a_ as TriggerOp, a$ as TriggerQueryArgs, b0 as TriggerQueryPage, b1 as TriggerRankOptions, b2 as TriggerRankPageOptions, b3 as TriggerRankResult, b4 as TriggerRow, b5 as TriggerTiming, b6 as TriggerUpdateEvent, b7 as TtlDefinition, b8 as VectorMatch, b9 as VectorMatches, ba as VectorQueryInput, bb as VectorRecord, bc as VectorSearch, bd as VectorSearchReader, be as VectorUpsertInput, bf as WorkflowCreateOptions, bg as WorkflowEventDefinition, bh as WorkflowHandle, bi as WorkflowInstance, bj as WorkflowInstanceEvent, bk as WorkflowInstanceStatus, bl as WorkflowStatusResult, bm as Workflows } from "./packem_shared/types.d-BOnXpMCp.mjs";
3
+ import { A as ArgsValidator, I as InferArgs, R as RegisteredAction, E as ExposeConfig, X as X402ProcedureConfig, b as ActionCtx, c as RegisteredInternalAction, M as MutationCtx, d as RegisteredInternalMutation, Q as QueryCtx, e as RegisteredInternalQuery, f as DurableStreamOptions, g as RegisteredInternalStream, h as RegisteredMutation, i as RegisteredQuery, j as RegisteredStream, F as FunctionKind, T as TableDefinition, k as RegisteredFunction, V as VectorIndexDefinition, S as Schema, l as AggregateOp, G as GlobalBackend, K as KeyedRelationDefinition, m as RelationThrough, n as ThroughRelationDefinition, O as OnDeleteAction, o as RelationDefinition, p as SearchLanguage, q as SearchStrategy, r as ExternalSourceDefinition, s as TriggerBuilder, t as TriggerDefinition, u as VectorEmbedder, v as VectorMetric, w as DurableObjectJurisdiction, x as AggregateIndexDefinition, y as RankIndexDefinition, z as Secrets, B as LiveTopicRef, C as LifecycleEvent, H as ShardInitEvent, J as RegisteredLifecycleHook, W as WhisperEvent } from "./packem_shared/types.d-CuZXI4PC.mjs";
4
+ export type { N as AuthState, P as CachePurge, U as DatabaseReader, D as DatabaseWriter, Y as FunctionVisibility, Z as GeoBoundingBox, _ as GeoFilterBuilder, $ as GeoIndexDefinition, a0 as GeoPointInput, a1 as IndexDefinition, a2 as IndexRangeBuilder, a3 as LifecycleEventKind, a4 as LogFields, a5 as LunoraLogMethod, a6 as LunoraLogger, a7 as LunoraMetrics, L as LunoraTracer, a8 as LunoraWideEvent, a9 as MutationStorage, aa as PaginationOptions, ab as PaginationResult, ac as PatchIfResult, ad as RankSortKey, ae as ReadOnlyStorage, af as RelatedDirection, ag as RelatedNode, ah as RelatedOptions, ai as RelatedPage, aj as RelatedStart, ak as RelatedStartReference, al as RestCacheConfig, am as RetryPolicy, an as RunQueryOptions, ao as ScheduledFunctionDoc, ap as ScheduledJob, aq as ScheduledJobState, ar as ScheduledJobView, as as Scheduler, at as SearchFilterBuilder, au as SearchIndexDefinition, av as ShardMode, aw as SpanContextIds, ax as SpanEvaluation, a as SpanHandle, ay as SpanIdentity, az as SpanKind, aA as SpanLink, aB as SpanOptions, aC as Storage, aD as StorageListOptions, aE as StorageListResult, aF as StorageMetadata, aG as StorageMultipartUpload, aH as StorageMultipartUploadOptions, aI as StorageObjectBody, aJ as StorageObjectHead, aK as StorageRange, aL as StorageUploadBody, aM as StorageUploadOptions, aN as StorageUploadResult, aO as StorageUploadedPart, aP as SystemDatabaseReader, aQ as SystemDoc, aR as SystemQuery, aS as SystemTableName, aT as TableReader, aU as TableVectorIndex, aV as TriggerAggregateOptions, aW as TriggerCtx, aX as TriggerDatabase, aY as TriggerDeleteEvent, aZ as TriggerEvent, a_ as TriggerGroupByEntry, a$ as TriggerGroupByOptions, b0 as TriggerHandler, b1 as TriggerInsertEvent, b2 as TriggerOp, b3 as TriggerQueryArgs, b4 as TriggerQueryPage, b5 as TriggerRankOptions, b6 as TriggerRankPageOptions, b7 as TriggerRankResult, b8 as TriggerRow, b9 as TriggerTiming, ba as TriggerUpdateEvent, bb as TtlDefinition, bc as VectorMatch, bd as VectorMatches, be as VectorQueryInput, bf as VectorRecord, bg as VectorSearch, bh as VectorSearchReader, bi as VectorUpsertInput, bj as WorkflowCreateOptions, bk as WorkflowEventDefinition, bl as WorkflowHandle, bm as WorkflowInstance, bn as WorkflowInstanceEvent, bo as WorkflowInstanceStatus, bp as WorkflowStatusResult, bq as Workflows } from "./packem_shared/types.d-CuZXI4PC.mjs";
5
5
  import { LunoraError } from '@lunora/errors';
6
6
  export { LunoraError, type LunoraErrorCode } from '@lunora/errors';
7
7
  import { Context, Hono, ExecutionContext } from 'hono';
@@ -40,6 +40,24 @@ type Middleware<ContextIn, ContextOut> = (options: {
40
40
  ctx: ContextIn;
41
41
  next: MiddlewareNext<ContextIn>;
42
42
  }) => ContextOut | Promise<ContextOut>;
43
+ /**
44
+ * What a policy middleware (`rls()`, `mask()`) returns: a middleware generic over
45
+ * the procedure context it is attached to, handing that same context on.
46
+ *
47
+ * Generic so `.use()` instantiates it with the builder's own context: a generated
48
+ * `QueryCtx` / `MutationCtx` carries a typed `db` facade that is not assignable to
49
+ * the untyped writer shape a policy module projects. Keeping the caller's type is
50
+ * sound because the runtime only swaps `db` (and `orm`) for wrappers of the same
51
+ * facade. `Required` is everything else the policies read (`auth`, a `tenantId`
52
+ * an earlier middleware adds), so attaching them where it is missing is still a
53
+ * type error rather than an `undefined` at request time.
54
+ */
55
+ type PolicyMiddleware<Required = unknown> = <Context extends Required & {
56
+ db: object;
57
+ }>(options: {
58
+ ctx: Context;
59
+ next: MiddlewareNext<Context>;
60
+ }) => Promise<Context>;
43
61
  /**
44
62
  * The context a `.use(...)` step actually receives: the procedure context plus
45
63
  * `args`, the call's arguments as declared by `.input(...)` up to this point in
@@ -247,16 +265,16 @@ interface InternalQueryBuilder<Context, Args extends ArgsValidator, Output = und
247
265
  query: [Output] extends [undefined] ? <R>(handler: (options: {
248
266
  args: InferArgs<Args>;
249
267
  ctx: Context;
250
- }) => Promise<R> | R) => RegisteredQuery<Args, Awaited<R>> : (handler: (options: {
268
+ }) => Promise<R> | R) => RegisteredInternalQuery<Args, Awaited<R>> : (handler: (options: {
251
269
  args: InferArgs<Args>;
252
270
  ctx: Context;
253
- }) => Output | Promise<Output>) => RegisteredQuery<Args, Output>;
271
+ }) => Output | Promise<Output>) => RegisteredInternalQuery<Args, Output>;
254
272
  /** See {@link QueryBuilder.stream}; the internal variant routes the registration into `internal` instead of `api`. */
255
273
  stream: <R>(handler: (options: {
256
274
  args: InferArgs<Args>;
257
275
  ctx: Context;
258
276
  signal: AbortSignal;
259
- }) => AsyncGenerator<R, void, void> | AsyncIterable<R>, options?: StreamOptions) => RegisteredStream<Args, R>;
277
+ }) => AsyncGenerator<R, void, void> | AsyncIterable<R>, options?: StreamOptions) => RegisteredInternalStream<Args, R>;
260
278
  use: <ContextOut>(middleware: Middleware<MiddlewareContext<Context, Args>, ContextOut>) => InternalQueryBuilder<ContextOut, Args, Output>;
261
279
  }
262
280
  interface InternalMutationBuilder<Context, Args extends ArgsValidator, Output = undefined> {
@@ -280,10 +298,10 @@ interface InternalMutationBuilder<Context, Args extends ArgsValidator, Output =
280
298
  mutation: [Output] extends [undefined] ? <R>(handler: (options: {
281
299
  args: InferArgs<Args>;
282
300
  ctx: Context;
283
- }) => Promise<R> | R) => RegisteredMutation<Args, Awaited<R>> : (handler: (options: {
301
+ }) => Promise<R> | R) => RegisteredInternalMutation<Args, Awaited<R>> : (handler: (options: {
284
302
  args: InferArgs<Args>;
285
303
  ctx: Context;
286
- }) => Output | Promise<Output>) => RegisteredMutation<Args, Output>;
304
+ }) => Output | Promise<Output>) => RegisteredInternalMutation<Args, Output>;
287
305
  output: <V extends Validator>(validator: V) => InternalMutationBuilder<Context, Args, Infer<V>>;
288
306
  use: <ContextOut>(middleware: Middleware<MiddlewareContext<Context, Args>, ContextOut>) => InternalMutationBuilder<ContextOut, Args, Output>;
289
307
  }
@@ -293,10 +311,10 @@ interface InternalActionBuilder<Context, Args extends ArgsValidator, Output = un
293
311
  action: [Output] extends [undefined] ? <R>(handler: (options: {
294
312
  args: InferArgs<Args>;
295
313
  ctx: Context;
296
- }) => Promise<R> | R) => RegisteredAction<Args, Awaited<R>> : (handler: (options: {
314
+ }) => Promise<R> | R) => RegisteredInternalAction<Args, Awaited<R>> : (handler: (options: {
297
315
  args: InferArgs<Args>;
298
316
  ctx: Context;
299
- }) => Output | Promise<Output>) => RegisteredAction<Args, Output>;
317
+ }) => Output | Promise<Output>) => RegisteredInternalAction<Args, Output>;
300
318
  input: <A extends ArgsValidator>(validators: A) => InternalActionBuilder<Context, A & Args, Output>;
301
319
  /**
302
320
  * Attach static, per-procedure metadata. Merges across calls and is readable
@@ -451,7 +469,12 @@ declare const definePlugin: DefinePluginFunction;
451
469
  *
452
470
  * Codegen follows the re-export back to the bundled `query/mutation/action`
453
471
  * call (property access or destructuring both work), so the functions land in
454
- * the generated `api` under the re-exporting file's namespace.
472
+ * the generated `api` under the re-exporting file's namespace. A component
473
+ * installed from npm has no call to follow — only its `.d.ts` — so codegen reads
474
+ * each function off its declared type instead: declare public functions as
475
+ * `RegisteredQuery` / `RegisteredMutation` / `RegisteredAction` and server-only
476
+ * ones as their `RegisteredInternal*` counterparts. A bare `RegisteredFunction`
477
+ * leaves visibility open, and codegen refuses to guess it.
455
478
  */
456
479
  type ComponentFunctions = Readonly<Record<string, RegisteredFunction<any, any, FunctionKind>>>;
457
480
  /**
@@ -1145,8 +1168,8 @@ interface ActionCacheFunctions {
1145
1168
  * again rather than assuming one pass drained the table. A caller-supplied
1146
1169
  * `limit` is clamped — `take()` has no ceiling of its own.
1147
1170
  */
1148
- purgeExpired: RegisteredMutation<{
1149
- limit: ReturnType<typeof v.optional>;
1171
+ purgeExpired: RegisteredInternalMutation<{
1172
+ limit: ColumnValidator<number | undefined, number | undefined>;
1150
1173
  }, {
1151
1174
  deleted: number;
1152
1175
  }>;
@@ -1492,10 +1515,10 @@ interface DocumentHistoryFunctions {
1492
1515
  * the last version at or before it, which is what a point-in-time
1493
1516
  * reconstruction needs.
1494
1517
  */
1495
- listForDocument: RegisteredQuery<{
1496
- before: ReturnType<typeof v.optional>;
1497
- documentId: ReturnType<typeof v.string>;
1498
- limit: ReturnType<typeof v.optional>;
1518
+ listForDocument: RegisteredInternalQuery<{
1519
+ before: ColumnValidator<number | undefined, number | undefined>;
1520
+ documentId: StringColumnValidator;
1521
+ limit: ColumnValidator<number | undefined, number | undefined>;
1499
1522
  }, DocumentHistoryEntry[]>;
1500
1523
  /**
1501
1524
  * Internal mutation that deletes entries older than the retention window,
@@ -1504,8 +1527,8 @@ interface DocumentHistoryFunctions {
1504
1527
  * Compare `deleted` against `limit` to decide whether to run again rather
1505
1528
  * than assuming one pass drained the backlog.
1506
1529
  */
1507
- vacuum: RegisteredMutation<{
1508
- limit: ReturnType<typeof v.optional>;
1530
+ vacuum: RegisteredInternalMutation<{
1531
+ limit: ColumnValidator<number | undefined, number | undefined>;
1509
1532
  }, {
1510
1533
  deleted: number;
1511
1534
  }>;
@@ -2400,9 +2423,9 @@ type LifecycleHandler = (context: MutationCtx, event: LifecycleEvent) => Promise
2400
2423
  /** Handler for a shard-init hook. */
2401
2424
  type ShardInitHandler = (context: MutationCtx, event: ShardInitEvent) => Promise<void> | void;
2402
2425
  /** Register a hook that fires once when a client's WebSocket connects. */
2403
- declare const onConnect: (handler: LifecycleHandler) => RegisteredLifecycleHook;
2426
+ declare const onConnect: (handler: LifecycleHandler) => RegisteredLifecycleHook<"connect">;
2404
2427
  /** Register a hook that fires once when a client's WebSocket disconnects. */
2405
- declare const onDisconnect: (handler: LifecycleHandler) => RegisteredLifecycleHook;
2428
+ declare const onDisconnect: (handler: LifecycleHandler) => RegisteredLifecycleHook<"disconnect">;
2406
2429
  /**
2407
2430
  * Register a hook that fires ONCE per Durable Object instance, before any
2408
2431
  * handler on that instance can run — the re-init half of `.memory()` tables.
@@ -2453,7 +2476,7 @@ declare const onDisconnect: (handler: LifecycleHandler) => RegisteredLifecycleHo
2453
2476
  * instance's rows in place: a memory table's rows live in SQLite until they are
2454
2477
  * deleted, so an eviction on its own does not remove them.
2455
2478
  */
2456
- declare const onShardInit: (handler: ShardInitHandler) => RegisteredLifecycleHook;
2479
+ declare const onShardInit: (handler: ShardInitHandler) => RegisteredLifecycleHook<"init">;
2457
2480
  /** Default `limit` when the caller doesn't ask for one. */
2458
2481
  declare const DEFAULT_LIMIT = 25;
2459
2482
  /** Default ceiling on `limit`, so one request can't ask for an unbounded page. */
@@ -3075,7 +3098,7 @@ interface RlsContextIn {
3075
3098
  auth?: AuthLike;
3076
3099
  db: RlsDatabase;
3077
3100
  }
3078
- declare const rls: <Context extends RlsContextIn = RlsContextIn>(policies: ReadonlyArray<Policy<Context>>, options?: RlsOptions) => Middleware<Context, Context>;
3101
+ declare const rls: <Context extends RlsContextIn = RlsContextIn>(policies: ReadonlyArray<Policy<Context>>, options?: RlsOptions) => PolicyMiddleware<Omit<Context, "db">>;
3079
3102
  /**
3080
3103
  * Context handed to a {@link MaskFn} (and to {@link MaskOptions.bypass}). The
3081
3104
  * `auth` shape mirrors RLS's `PolicyContext.auth` one-for-one — same identity
@@ -3336,7 +3359,7 @@ interface MaskContextIn {
3336
3359
  * IMPORTANT: a mask is in scope only for procedures whose builder chain
3337
3360
  * includes this middleware — opt-in, never global (the same invariant as RLS).
3338
3361
  */
3339
- declare const mask: <Context extends MaskContextIn = MaskContextIn>(policies: MaskPolicies<Context>, options?: MaskOptions<Context>) => Middleware<Context, Context>;
3362
+ declare const mask: <Context extends MaskContextIn = MaskContextIn>(policies: MaskPolicies<Context>, options?: MaskOptions<Context>) => PolicyMiddleware<Omit<Context, "db">>;
3340
3363
  /** Project-wide masked-column registry: every table any registered function masks, unioned. */
3341
3364
  type MaskRegistry = ReadonlyMap<string, ReadonlySet<string>>;
3342
3365
  /**
@@ -3641,7 +3664,15 @@ interface DefinePresenceOptions {
3641
3664
  */
3642
3665
  ttlMs?: number;
3643
3666
  }
3644
- /** The registered functions a presence component ships. */
3667
+ /**
3668
+ * The registered functions a presence component ships.
3669
+ *
3670
+ * Installed from npm, this declaration is all codegen can see of them — there is
3671
+ * no `mutation(...)` call to read — so it is what the generated `api` is built
3672
+ * from. Each entry therefore states its argument validators precisely, uses the
3673
+ * internal alias for a server-only function, and narrows a hook's `lifecycle`; a
3674
+ * loose type here becomes a loose client type, or a codegen error.
3675
+ */
3645
3676
  interface PresenceFunctions {
3646
3677
  /**
3647
3678
  * Connection-lifecycle hook: the instant a client's WebSocket drops, hard-
@@ -3653,7 +3684,7 @@ interface PresenceFunctions {
3653
3684
  * member). The TTL filter + `sweep` remain the fallback for ungraceful drops
3654
3685
  * where no `context` was recorded.
3655
3686
  */
3656
- disconnect: RegisteredLifecycleHook;
3687
+ disconnect: RegisteredLifecycleHook<"disconnect">;
3657
3688
  /**
3658
3689
  * Upsert the caller's presence row for `roomId` in their tenant and stamp
3659
3690
  * `lastSeen = now`. Keyed by `(tenantId, roomId, sessionId)` — re-heartbeats
@@ -3664,9 +3695,9 @@ interface PresenceFunctions {
3664
3695
  * data via a guessed `sessionId`.
3665
3696
  */
3666
3697
  heartbeat: RegisteredMutation<{
3667
- data: ReturnType<typeof v.optional>;
3668
- roomId: ReturnType<typeof v.string>;
3669
- sessionId: ReturnType<typeof v.string>;
3698
+ data: ColumnValidator<Record<string, unknown> | undefined, Record<string, unknown> | undefined>;
3699
+ roomId: StringColumnValidator;
3700
+ sessionId: StringColumnValidator;
3670
3701
  }, {
3671
3702
  lastSeen: number;
3672
3703
  }>;
@@ -3676,7 +3707,7 @@ interface PresenceFunctions {
3676
3707
  * here" list.
3677
3708
  */
3678
3709
  listPresent: RegisteredQuery<{
3679
- roomId: ReturnType<typeof v.string>;
3710
+ roomId: StringColumnValidator;
3680
3711
  }, PresenceMember[]>;
3681
3712
  /**
3682
3713
  * Internal mutation that hard-deletes every expired row for `roomId` in
@@ -3687,9 +3718,9 @@ interface PresenceFunctions {
3687
3718
  * that went quiet with stale rows left behind (schedule it on a cron /
3688
3719
  * `runAfter` if you care).
3689
3720
  */
3690
- sweep: RegisteredMutation<{
3691
- roomId: ReturnType<typeof v.string>;
3692
- tenantId: ReturnType<typeof v.string>;
3721
+ sweep: RegisteredInternalMutation<{
3722
+ roomId: StringColumnValidator;
3723
+ tenantId: StringColumnValidator;
3693
3724
  }, {
3694
3725
  deleted: number;
3695
3726
  }>;
@@ -3698,6 +3729,10 @@ interface PresenceFunctions {
3698
3729
  type PresenceComponent = Component<{
3699
3730
  [PRESENCE_BARE_TABLE]: ReturnType<typeof defineTable>;
3700
3731
  }> & {
3732
+ /** Always present (unlike a bare {@link Component}'s), so `.extend(presence.extension)` typechecks. */
3733
+ readonly extension: SchemaExtension<{
3734
+ [PRESENCE_BARE_TABLE]: ReturnType<typeof defineTable>;
3735
+ }, typeof PRESENCE_KEY>;
3701
3736
  functions: PresenceFunctions;
3702
3737
  };
3703
3738
  /**
@@ -3723,6 +3758,33 @@ declare const presenceExtension: SchemaExtension<{
3723
3758
  * @returns a component bundling the extension and the presence functions.
3724
3759
  */
3725
3760
  declare const definePresence: (options?: DefinePresenceOptions) => PresenceComponent;
3761
+ /**
3762
+ * Where a registered function carries its `.meta(...)` declaration.
3763
+ *
3764
+ * A symbol so it cannot collide with a field of the dispatch shape, and
3765
+ * `Symbol.for` so two bundled copies of `@lunora/server` agree on it. ENUMERABLE
3766
+ * on purpose: object spread copies enumerable own symbols, so a wrapper that
3767
+ * re-tags a function (`{ ...fn, visibility }`) keeps its meta — a non-enumerable
3768
+ * stamp would vanish there without a word. `JSON.stringify` still skips it.
3769
+ */
3770
+ declare const PROCEDURE_META: unique symbol;
3771
+ /**
3772
+ * The value a lazily registered stub carries when its function declares a
3773
+ * `.meta(...)` codegen could not copy as a literal. Only loading the module
3774
+ * produces it, so {@link procedureMeta} refuses to answer rather than report
3775
+ * "no meta" for a function that has some.
3776
+ */
3777
+ declare const UNLOADED_META: "unloaded";
3778
+ /**
3779
+ * The `.meta(...)` declaration of a registered function — the same frozen object
3780
+ * its middleware reads as `ctx.meta` — or `undefined` when it declares none.
3781
+ *
3782
+ * The supported way for tooling (an authorization audit, a docs generator) to
3783
+ * read a procedure's metadata: iterate the generated `LUNORA_FUNCTIONS` table, or
3784
+ * pass an imported function, and ask this. Throws for a lazily registered
3785
+ * function whose meta exists but is only available once its module loads.
3786
+ */
3787
+ declare const procedureMeta: (registered: unknown) => Readonly<Record<string, unknown>> | undefined;
3726
3788
  /**
3727
3789
  * The middlewares `protectPublic` chains, in the order they run. Every field is
3728
3790
  * optional, so a bundle can be just a rate limit, just a captcha, or any mix —
@@ -4399,7 +4461,7 @@ type RegisteredWhisperAuthorizer = RegisteredFunction<Record<string, never>, boo
4399
4461
  */
4400
4462
  declare const onWhisper: (handler: WhisperAuthorizeHandler) => RegisteredWhisperAuthorizer;
4401
4463
  declare const VERSION = "0.0.0";
4402
- export { DEFAULT_ACTION_CACHE_TTL_MS as ACTION_CACHE_DEFAULT_TTL_MS, ACTION_CACHE_TABLE, type ActionBuilder, type ActionCacheComponent, type ActionCacheContext, type ActionCacheDatabase, type ActionCacheFunctions, type ActionCtx, type AggregateIndexDefinition, type AggregateIndexOptions, type AggregateOp, type ArgsValidator, type Component, type ComponentFunctions, type CreateOptions, DEFAULT_LIMIT, DEFAULT_MAX_LIMIT, DEFAULT_REDACTED_FIELDS as DOCUMENT_HISTORY_REDACTED_FIELDS, DOCUMENT_HISTORY_TABLE, type DataModelInit, type DeferredDeleteFlushResult, type DefineActionCacheOptions, type DefineComponentOptions, type DefineDocumentHistoryOptions, type DefineIdentityOptions, type DefineListArgsConfig, type DefinePluginOptions, type DefinePolicyInput, type DefinePresenceOptions, type DefineRoomOptions, type DefineStorageRuleInput, type DefineWebSocketOptions, type DocumentHistoryComponent, type DocumentHistoryEntry, type DocumentHistoryFunctions, type DurableObjectJurisdiction, type DurableStreamOptions, type EmptyArgs, type EnvAccessor, type EnvKeyFailure, type EnvShape, type ExposeConfig, type ExtendableSchema, type FacadeEntry, type FacadeWriterLike, type FunctionKind, type HttpActionCtx, type HttpActionHandler, type HttpMethod, type HttpRoute, type HttpRouteBuilder, type HttpRouteFactory, type HttpRouteHandlerOptions, type HttpRunners, type HttpStreamHandlerOptions, type IdentityContract, type IdentityRejectMode, type IdentityValidation, type IndexFieldsByTable, type InferArgs, type InferEnv, type InferIdentity, type InlineAggregateIndexOptions, type InlineRankIndexOptions, type InternalActionBuilder, type InternalMutationBuilder, type InternalQueryBuilder, type LifecycleEvent, type LifecycleHandler, type ListArgsSpec, type ListArgsValidators, type ListArgsValue, type ListFilterOperators, type ListOrderByEntry, type ListWhere, type LivePublishOptions, type LivePublisher, type LiveRouterApp, type LiveRouterFallback, type LiveStream, type LiveStreamConfig, type LiveStreamMount, type LiveSubscribeHandler, type LiveSubscribeOptions, type LiveTopicDeclaration, type LiveTopicKey, type LiveTopicPayload, type LiveTopicRef, type LiveTopics, type LunoraBuilders, LunoraEnvError, type LunoraHttpApp, type LunoraHttpEnv, type LunoraRouteHandler, type ManyRelation, type MaskColumns, type MaskContext, type MaskFn, type MaskOptions, type MaskPolicies, type MaskRegistry, type MaskStrategy, type Middleware, type MiddlewareContext, type MiddlewareNext, type MigrationCovers, type MigrationCtx, type MigrationDefinition, type MigrationDocument, type MigrationReader, type MigrationTransform, type ModuleConfig, type ModuleDefinition, type MutationBuilder, type MutationCtx, type MutatorDefinition, type OnDeleteAction, type OneRelation, type OrmLike, DEFAULT_TTL_MS as PRESENCE_DEFAULT_TTL_MS, PRESENCE_TABLE, type Permission, type PlatformAdminCheck, type Plugin, type Policy, type PrefixedTables, type PresenceComponent, type PresenceFunctions, type PresenceMember, type ProtectPublicOptions, type QueryBuilder, type QueryCtx, type RankIndexDefinition, type RankIndexOptions, type ReactorHandler, type ReactorOutcome, type ReactorSelect, type RegisteredAction, type RegisteredFunction, type RegisteredLifecycleHook, type RegisteredMigration, type RegisteredMutation, type RegisteredMutator, type RegisteredQuery, type RegisteredReactor, type RegisteredRoom, type RegisteredShape, type RegisteredStream, type RegisteredWebSocket, type RegisteredWhisperAuthorizer, type RelationBuilder, type RelationDefinition, type RelationThrough, type RlsOptions, type RlsReadRegistry, type Role, type RoomJoinHandler, type RoomLeaveHandler, type RoomMessageHandler, type RoomMessageOf, type RoomSocket, type Schema, type SchemaExtension, type ServiceBindingSpec, type ServiceFetcher, type ServiceRpc, type ShapeDefinition, type ShapeGuardDeclaration, type ShapeReadWhereRequest, type ShardFetch, type ShardFetchInit, type ShardInitEvent, type ShardInitHandler, type SseEvent, type StorageOperation, type StorageRule, type StorageRuleContext, type StorageRuleDecision, type StorageRulesOptions, type StorageServeAuthorizer, type StorageServeAuthzContext, type TableBuilder, type TableDefinition, type TerminalKind, type TriggerBuilder, type TriggerDefinition, type TypedDefinePolicyInput, VERSION, type VectorEmbedder, type VectorIndexDefinition, type VectorIndexOptions, type VectorMetric, type VectorizeOptions, type WebSocketCloseHandler, type WebSocketHandle, type WebSocketMessageHandler, type WebSocketOpenHandler, type WhereInput, type WhisperAuthorizeHandler, type WhisperEvent, actionCacheExtension, allowAll, asBucketStorage, assertShapesDeclareReadPolicies, beginDeferredDeletes, beginDeferredSchedules, bindOrm, bindTableFacade, buildMaskRegistry, buildRlsReadRegistry, cacheKeyFor, clampLimit, composePluginMiddleware, composeShapeReadWhere, createPolicyDsl, createSecrets, createServices, defineActionCache, defineAggregateIndex, defineComponent, defineDocumentHistory, defineEnv, defineIdentity, defineIdentityGuard, defineLazyFacade, defineListArgs, defineLiveStream, defineMigration, defineModule, defineMutator, definePermission, definePlugin, definePolicies, definePolicy, definePresence, defineRankIndex, defineRole, defineRoom, defineSchema, defineSchemaExtension, defineShape, defineStorageRule, defineStorageRules, defineTable, defineVectorIndex, defineWebSocket, deny, documentHistoryExtension, flushDeferredDeletes,
4464
+ export { DEFAULT_ACTION_CACHE_TTL_MS as ACTION_CACHE_DEFAULT_TTL_MS, ACTION_CACHE_TABLE, type ActionBuilder, type ActionCacheComponent, type ActionCacheContext, type ActionCacheDatabase, type ActionCacheFunctions, type ActionCtx, type AggregateIndexDefinition, type AggregateIndexOptions, type AggregateOp, type ArgsValidator, type Component, type ComponentFunctions, type CreateOptions, DEFAULT_LIMIT, DEFAULT_MAX_LIMIT, DEFAULT_REDACTED_FIELDS as DOCUMENT_HISTORY_REDACTED_FIELDS, DOCUMENT_HISTORY_TABLE, type DataModelInit, type DeferredDeleteFlushResult, type DefineActionCacheOptions, type DefineComponentOptions, type DefineDocumentHistoryOptions, type DefineIdentityOptions, type DefineListArgsConfig, type DefinePluginOptions, type DefinePolicyInput, type DefinePresenceOptions, type DefineRoomOptions, type DefineStorageRuleInput, type DefineWebSocketOptions, type DocumentHistoryComponent, type DocumentHistoryEntry, type DocumentHistoryFunctions, type DurableObjectJurisdiction, type DurableStreamOptions, type EmptyArgs, type EnvAccessor, type EnvKeyFailure, type EnvShape, type ExposeConfig, type ExtendableSchema, type FacadeEntry, type FacadeWriterLike, type FunctionKind, type HttpActionCtx, type HttpActionHandler, type HttpMethod, type HttpRoute, type HttpRouteBuilder, type HttpRouteFactory, type HttpRouteHandlerOptions, type HttpRunners, type HttpStreamHandlerOptions, type IdentityContract, type IdentityRejectMode, type IdentityValidation, type IndexFieldsByTable, type InferArgs, type InferEnv, type InferIdentity, type InlineAggregateIndexOptions, type InlineRankIndexOptions, type InternalActionBuilder, type InternalMutationBuilder, type InternalQueryBuilder, type LifecycleEvent, type LifecycleHandler, type ListArgsSpec, type ListArgsValidators, type ListArgsValue, type ListFilterOperators, type ListOrderByEntry, type ListWhere, type LivePublishOptions, type LivePublisher, type LiveRouterApp, type LiveRouterFallback, type LiveStream, type LiveStreamConfig, type LiveStreamMount, type LiveSubscribeHandler, type LiveSubscribeOptions, type LiveTopicDeclaration, type LiveTopicKey, type LiveTopicPayload, type LiveTopicRef, type LiveTopics, type LunoraBuilders, LunoraEnvError, type LunoraHttpApp, type LunoraHttpEnv, type LunoraRouteHandler, type ManyRelation, type MaskColumns, type MaskContext, type MaskFn, type MaskOptions, type MaskPolicies, type MaskRegistry, type MaskStrategy, type Middleware, type MiddlewareContext, type MiddlewareNext, type MigrationCovers, type MigrationCtx, type MigrationDefinition, type MigrationDocument, type MigrationReader, type MigrationTransform, type ModuleConfig, type ModuleDefinition, type MutationBuilder, type MutationCtx, type MutatorDefinition, type OnDeleteAction, type OneRelation, type OrmLike, DEFAULT_TTL_MS as PRESENCE_DEFAULT_TTL_MS, PRESENCE_TABLE, PROCEDURE_META, type Permission, type PlatformAdminCheck, type Plugin, type Policy, type PolicyMiddleware, type PrefixedTables, type PresenceComponent, type PresenceFunctions, type PresenceMember, type ProtectPublicOptions, type QueryBuilder, type QueryCtx, type RankIndexDefinition, type RankIndexOptions, type ReactorHandler, type ReactorOutcome, type ReactorSelect, type RegisteredAction, type RegisteredFunction, type RegisteredInternalAction, type RegisteredInternalMutation, type RegisteredInternalQuery, type RegisteredInternalStream, type RegisteredLifecycleHook, type RegisteredMigration, type RegisteredMutation, type RegisteredMutator, type RegisteredQuery, type RegisteredReactor, type RegisteredRoom, type RegisteredShape, type RegisteredStream, type RegisteredWebSocket, type RegisteredWhisperAuthorizer, type RelationBuilder, type RelationDefinition, type RelationThrough, type RlsContextIn, type RlsOptions, type RlsReadRegistry, type Role, type RoomJoinHandler, type RoomLeaveHandler, type RoomMessageHandler, type RoomMessageOf, type RoomSocket, type Schema, type SchemaExtension, type ServiceBindingSpec, type ServiceFetcher, type ServiceRpc, type ShapeDefinition, type ShapeGuardDeclaration, type ShapeReadWhereRequest, type ShardFetch, type ShardFetchInit, type ShardInitEvent, type ShardInitHandler, type SseEvent, type StorageOperation, type StorageRule, type StorageRuleContext, type StorageRuleDecision, type StorageRulesOptions, type StorageServeAuthorizer, type StorageServeAuthzContext, type TableBuilder, type TableDefinition, type TerminalKind, type TriggerBuilder, type TriggerDefinition, type TypedDefinePolicyInput, UNLOADED_META, VERSION, type VectorEmbedder, type VectorIndexDefinition, type VectorIndexOptions, type VectorMetric, type VectorizeOptions, type WebSocketCloseHandler, type WebSocketHandle, type WebSocketMessageHandler, type WebSocketOpenHandler, type WhereInput, type WhisperAuthorizeHandler, type WhisperEvent, actionCacheExtension, allowAll, asBucketStorage, assertShapesDeclareReadPolicies, beginDeferredDeletes, beginDeferredSchedules, bindOrm, bindTableFacade, buildMaskRegistry, buildRlsReadRegistry, cacheKeyFor, clampLimit, composePluginMiddleware, composeShapeReadWhere, createPolicyDsl, createSecrets, createServices, defineActionCache, defineAggregateIndex, defineComponent, defineDocumentHistory, defineEnv, defineIdentity, defineIdentityGuard, defineLazyFacade, defineListArgs, defineLiveStream, defineMigration, defineModule, defineMutator, definePermission, definePlugin, definePolicies, definePolicy, definePresence, defineRankIndex, defineRole, defineRoom, defineSchema, defineSchemaExtension, defineShape, defineStorageRule, defineStorageRules, defineTable, defineVectorIndex, defineWebSocket, deny, documentHistoryExtension, flushDeferredDeletes,
4403
4465
  /**
4404
4466
  * True when `value` is safe to use as an HTTP header field-value: no CR, LF, or
4405
4467
  * NUL. Guards against response-header injection / `Headers`-construction throws
@@ -4435,7 +4497,7 @@ httpRouter, indexFieldsFromSchema, initLunora, installPlugins, isDeny, isPerDisp
4435
4497
  * handler can guard a request-derived header value before writing it — the fix the
4436
4498
  * `http_action_response_header_injection` advisor lint points to.
4437
4499
  */
4438
- lastEventId, liveStreamRouter, mask, mergeSchemaExtension, onConnect, onDisconnect, onQueryChange, onShardInit, onWhisper, platformAdmin, presenceExtension, protectPublic, redactSecrets, rls, serveStorageObject,
4500
+ lastEventId, liveStreamRouter, mask, mergeSchemaExtension, onConnect, onDisconnect, onQueryChange, onShardInit, onWhisper, platformAdmin, presenceExtension, procedureMeta, protectPublic, redactSecrets, rls, serveStorageObject,
4439
4501
  /**
4440
4502
  * True when `value` is safe to use as an HTTP header field-value: no CR, LF, or
4441
4503
  * NUL. Guards against response-header injection / `Headers`-construction throws