@lunora/shard-engine 1.0.0-alpha.7 → 1.0.0-alpha.70

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 (154) hide show
  1. package/README.md +1 -1
  2. package/dist/conformance/index.mjs +1 -1
  3. package/dist/index.d.mts +570 -119
  4. package/dist/index.d.ts +570 -119
  5. package/dist/index.mjs +1 -1
  6. package/dist/packem_shared/ADMIN_FUNCTIONS-INdhzK8S.mjs +1 -0
  7. package/dist/packem_shared/AGGREGATE_SQL_FUNCTION-DDEoMnJR.mjs +1 -0
  8. package/dist/packem_shared/AGG_COUNT-D2FdUJOa.mjs +1 -0
  9. package/dist/packem_shared/AUDIT_LOG_TABLE-ONxmEAIz.mjs +8 -0
  10. package/dist/packem_shared/BIGINT_KEY_DIGITS-Dp0GtURc.mjs +1 -0
  11. package/dist/packem_shared/CDC_LOG_TABLE-vVheEulD.mjs +15 -0
  12. package/dist/packem_shared/CLIENT_WATERMARK_TABLE-CRnrAnJ2.mjs +7 -0
  13. package/dist/packem_shared/COMMIT_SEQ_FIELD-BUdOMG5y.mjs +4 -0
  14. package/dist/packem_shared/CURSOR_PREFIX-Bn8SFoGd.mjs +1 -0
  15. package/dist/packem_shared/CountRlsUnsupportedError-BvsDqfO2.mjs +1 -0
  16. package/dist/packem_shared/DATA_MIGRATION_STATE_TABLE-BwFz6NTT.mjs +31 -0
  17. package/dist/packem_shared/DEFAULT_MAX_RELATION_KEYS-XESc7TiB.mjs +1 -0
  18. package/dist/packem_shared/DEFAULT_MAX_RELAYS-Ng4SyJ7k.mjs +8 -0
  19. package/dist/packem_shared/DEFAULT_PROMOTION_THRESHOLDS-Bfx7KakS.mjs +1 -0
  20. package/dist/packem_shared/DEFAULT_TRANSACTION_LIMITS-DDGk9ebh.mjs +1 -0
  21. package/dist/packem_shared/DurableStreamRunner-rTYp4v03.mjs +1 -0
  22. package/dist/packem_shared/GEO_DEFAULT_PRECISION-CqpQZ-J_.mjs +1 -0
  23. package/dist/packem_shared/GLOBAL_SHAPE_SNAPSHOT_TABLE-DSA6mzyx.mjs +7 -0
  24. package/dist/packem_shared/GlobalPollTick-BNK4o-XT.mjs +1 -0
  25. package/dist/packem_shared/IDEMPOTENCY_TABLE-DOpm_oMF.mjs +7 -0
  26. package/dist/packem_shared/MAIL_RETENTION-DGAQTHHs.mjs +18 -0
  27. package/dist/packem_shared/MAX_SQL_ROWS-Dh_Ty0Zo.mjs +4 -0
  28. package/dist/packem_shared/MAX_TOKEN_LENGTH-BakL9FUy-B3VwYY8C.mjs +1 -0
  29. package/dist/packem_shared/NotUniqueError-CzcG-VF9.mjs +1 -0
  30. package/dist/packem_shared/QUEUE_TABLE-s7QJZvBz.mjs +17 -0
  31. package/dist/packem_shared/RANK_TIEBREAK-BXDiMmkH.mjs +1 -0
  32. package/dist/packem_shared/REACTOR_STATE_TABLE-QPRFyxMS.mjs +28 -0
  33. package/dist/packem_shared/RELATED_DEFAULT_LIMIT-B9PH28Pn.mjs +1 -0
  34. package/dist/packem_shared/RELATION_EXISTS_KEY-CFUhnZSZ.mjs +1 -0
  35. package/dist/packem_shared/REPROJECTION_MIGRATION_PREFIX-Czcb6_mO.mjs +1 -0
  36. package/dist/packem_shared/RLS_UNWRAP_SYMBOL-BwwTbz3Q.mjs +1 -0
  37. package/dist/packem_shared/ReactiveCache-CzeUmTTN.mjs +1 -0
  38. package/dist/packem_shared/SCAN_DEP-D7qE3iUe.mjs +1 -0
  39. package/dist/packem_shared/SCHEDULE_OUTBOX_TABLE-CD_UjYVx.mjs +11 -0
  40. package/dist/packem_shared/SCHEMA_HISTORY_MAX_VERSIONS-BluIj2s-.mjs +6 -0
  41. package/dist/packem_shared/SEARCH_STATE_TABLE-D5mnK5kX.mjs +1 -0
  42. package/dist/packem_shared/SHAPE_POKE_CURSOR_TABLE-ByJVDHds.mjs +8 -0
  43. package/dist/packem_shared/ShapeDiffCache-gdaILV5E.mjs +1 -0
  44. package/dist/packem_shared/ShardRunner-C9p5DVOx.mjs +1 -0
  45. package/dist/packem_shared/UNVOUCHABLE_DEP-C68htACn.mjs +1 -0
  46. package/dist/packem_shared/aggregateTableName-C7o-gpms.mjs +1 -0
  47. package/dist/packem_shared/appendStreamChunk-C1Ok4b6J.mjs +19 -0
  48. package/dist/packem_shared/applyOnDelete-7JZ4vR9r.mjs +1 -0
  49. package/dist/packem_shared/archiveCdcSegment-DU4uzDFQ.mjs +4 -0
  50. package/dist/packem_shared/{armRestore-BNzdvQ_o.mjs → armRestore-Bu1_8SUa.mjs} +1 -1
  51. package/dist/packem_shared/awaitWsDrain-apizgmKY.mjs +1 -0
  52. package/dist/packem_shared/backfillAggregateIndexes-BG5-SC1q.mjs +1 -0
  53. package/dist/packem_shared/base64-DfpzS4o_.mjs +1 -0
  54. package/dist/packem_shared/buildIndexRange-NtciKq3M.mjs +1 -0
  55. package/dist/packem_shared/buildPokeFrames-BBE6J91z.mjs +1 -0
  56. package/dist/packem_shared/buildReprojectionMigration-Coeg-J0M.mjs +1 -0
  57. package/dist/packem_shared/buildSettings-DC3VeQ0H.mjs +1 -0
  58. package/dist/packem_shared/buildShapeDiff-WSoMs1_h.mjs +1 -0
  59. package/dist/packem_shared/clearMemoryTables-BGbmag2i.mjs +1 -0
  60. package/dist/packem_shared/compileWhereSql-B8tS0_nD.mjs +1 -0
  61. package/dist/packem_shared/computeRankPage-DsQ16o1z.mjs +1 -0
  62. package/dist/packem_shared/createCompanionSync-C6fV10Dq.mjs +1 -0
  63. package/dist/packem_shared/createReplicaLink-Bo4IWADY.mjs +7 -0
  64. package/dist/packem_shared/createSystemReader-DcDLFfC-.mjs +1 -0
  65. package/dist/packem_shared/ctx-db-companions-w-CfeOda.mjs +1 -0
  66. package/dist/packem_shared/ctx-db-relay-shapes-Bg5YYnmN.mjs +17 -0
  67. package/dist/packem_shared/ctx-db-search-state-ruTuCsxa.mjs +1 -0
  68. package/dist/packem_shared/defineEngineContractSuite-BSa7TDql.mjs +1 -0
  69. package/dist/packem_shared/diffExternalSource-DgDJhslq.mjs +1 -0
  70. package/dist/packem_shared/do-sql-Dvj8Yl5N.mjs +1 -0
  71. package/dist/packem_shared/envOptionalPositiveInt-D2pY-c64.mjs +1 -0
  72. package/dist/packem_shared/estimate-bytes-BuXtnbW2.mjs +1 -0
  73. package/dist/packem_shared/exportShardRows-1TkeNJI6.mjs +1 -0
  74. package/dist/packem_shared/hasTrigger-CjlwI4le.mjs +1 -0
  75. package/dist/packem_shared/isSoftDeleted-CYf6ijO3.mjs +9 -0
  76. package/dist/packem_shared/liftSourceId-CA3ENhXj.mjs +1 -0
  77. package/dist/packem_shared/materializeExternalRows-iEVQKOKT.mjs +1 -0
  78. package/dist/packem_shared/mergeChangedKeys-CPw4EamV.mjs +1 -0
  79. package/dist/packem_shared/param-DlozcSQu.mjs +1 -0
  80. package/dist/packem_shared/quoteIdentifier-CObIFRhb.mjs +1 -0
  81. package/dist/packem_shared/runDrizzle-2ULFQR_k.mjs +1 -0
  82. package/dist/packem_shared/runShardMigrations-DbQJdY1X.mjs +5 -0
  83. package/dist/packem_shared/runSocketPool-CZJ2X9cF.mjs +1 -0
  84. package/dist/packem_shared/selectExpiredIds-CKOUTIHn.mjs +1 -0
  85. package/dist/packem_shared/selectShapeMembers-CCZyZggM.mjs +1 -0
  86. package/dist/packem_shared/serializeSqlValue-CjbhIHjJ.mjs +1 -0
  87. package/dist/packem_shared/sibling-channel-BkL5cTCc.mjs +1 -0
  88. package/dist/packem_shared/sql-projection-BB2lCbYV.mjs +1 -0
  89. package/dist/packem_shared/stableStringify-DibjylKD.mjs +1 -0
  90. package/dist/packem_shared/stableWireKey-D2US4k_J.mjs +1 -0
  91. package/dist/packem_shared/where-sql-x1YKldcq.mjs +1 -0
  92. package/dist/packem_shared/wire-codec-C-FpWm52.mjs +1 -0
  93. package/package.json +3 -3
  94. package/dist/packem_shared/ADMIN_FUNCTIONS-vj2G8OR6.mjs +0 -1
  95. package/dist/packem_shared/AGGREGATE_SQL_FUNCTION-QYaiuty4.mjs +0 -1
  96. package/dist/packem_shared/AGG_COUNT-BWXe3gtQ.mjs +0 -1
  97. package/dist/packem_shared/AUDIT_LOG_TABLE-CaA0jL0L.mjs +0 -8
  98. package/dist/packem_shared/CDC_LOG_TABLE-BnqlH2eZ.mjs +0 -8
  99. package/dist/packem_shared/CLIENT_WATERMARK_TABLE-CXsSLU8D.mjs +0 -7
  100. package/dist/packem_shared/CountRlsUnsupportedError-B2WKJD9v.mjs +0 -1
  101. package/dist/packem_shared/DATA_MIGRATION_STATE_TABLE-BZMVrLcy.mjs +0 -31
  102. package/dist/packem_shared/DEFAULT_MAX_RELATION_KEYS-bq00btqV.mjs +0 -1
  103. package/dist/packem_shared/DEFAULT_MAX_RELAYS-D0oc40p6.mjs +0 -1
  104. package/dist/packem_shared/DEFAULT_PROMOTION_THRESHOLDS-Dteg0sZF.mjs +0 -1
  105. package/dist/packem_shared/DEFAULT_TRANSACTION_LIMITS-BH5q0Ror.mjs +0 -1
  106. package/dist/packem_shared/FTS_COUNT_COLUMN-D1gY3wwZ-CZHdaRrd.mjs +0 -1
  107. package/dist/packem_shared/GEO_DEFAULT_PRECISION-okRCkZ6r.mjs +0 -1
  108. package/dist/packem_shared/GLOBAL_SHAPE_SNAPSHOT_TABLE-DX-6-gBP.mjs +0 -7
  109. package/dist/packem_shared/IDEMPOTENCY_TABLE-DjkEMp6w.mjs +0 -7
  110. package/dist/packem_shared/MAIL_RETENTION-KmozO2NQ.mjs +0 -18
  111. package/dist/packem_shared/MAX_SQL_ROWS-nMwkxv5f.mjs +0 -2
  112. package/dist/packem_shared/NotUniqueError-Qrtwm7S6.mjs +0 -1
  113. package/dist/packem_shared/QUEUE_TABLE-DYCDvzTG.mjs +0 -17
  114. package/dist/packem_shared/RANK_TIEBREAK-9NU5s_mi.mjs +0 -1
  115. package/dist/packem_shared/RELATION_EXISTS_KEY-BaqSIFU1.mjs +0 -1
  116. package/dist/packem_shared/RLS_UNWRAP_SYMBOL-CBYPlYBb.mjs +0 -1
  117. package/dist/packem_shared/ReactiveCache-C6QAa7MG.mjs +0 -1
  118. package/dist/packem_shared/SCAN_DEP-D_yR9EeV.mjs +0 -1
  119. package/dist/packem_shared/SCHEMA_HISTORY_MAX_VERSIONS-CHXz6p_z.mjs +0 -6
  120. package/dist/packem_shared/SEARCH_STATE_TABLE-eLN8U5tz.mjs +0 -1
  121. package/dist/packem_shared/ShardRunner-DIqVdWtk.mjs +0 -1
  122. package/dist/packem_shared/aggregateTableName-G-eXyjcz.mjs +0 -1
  123. package/dist/packem_shared/applyOnDelete-uFRC5p1d.mjs +0 -1
  124. package/dist/packem_shared/applySelect-B0CF8T7y.mjs +0 -1
  125. package/dist/packem_shared/awaitWsDrain-CCZ-8wjm.mjs +0 -1
  126. package/dist/packem_shared/backfillAggregateIndexes-BHiewuB-.mjs +0 -1
  127. package/dist/packem_shared/buildIndexRange-DFsdtPjD.mjs +0 -1
  128. package/dist/packem_shared/buildPokeFrames-DaPpm5Ss.mjs +0 -1
  129. package/dist/packem_shared/buildSettings-DT18_DkX.mjs +0 -1
  130. package/dist/packem_shared/compileWhereSql-BLcfs4QW.mjs +0 -1
  131. package/dist/packem_shared/computeRankPage-IUSS-zIB.mjs +0 -1
  132. package/dist/packem_shared/createCompanionSync-DWK0Vlg1.mjs +0 -1
  133. package/dist/packem_shared/createReadFootprint-DIrrxRTE.mjs +0 -1
  134. package/dist/packem_shared/createSystemReader-DcDcrtM3.mjs +0 -1
  135. package/dist/packem_shared/defineEngineContractSuite-1f7OcQND.mjs +0 -1
  136. package/dist/packem_shared/diffExternalSource-DMpkJta1.mjs +0 -1
  137. package/dist/packem_shared/estimate-bytes-DwQON1Ky.mjs +0 -1
  138. package/dist/packem_shared/exportShardRows-kt42wijd.mjs +0 -1
  139. package/dist/packem_shared/hasTrigger-CbkOHExZ.mjs +0 -1
  140. package/dist/packem_shared/isSoftDeleted-B-SXkGUo.mjs +0 -9
  141. package/dist/packem_shared/liftSourceId-DApAbu7Q.mjs +0 -1
  142. package/dist/packem_shared/materializeExternalRows-DOQJV9p2.mjs +0 -1
  143. package/dist/packem_shared/mergeChangedKeys-BXtUgIPW.mjs +0 -1
  144. package/dist/packem_shared/param-B5lF5Jd9.mjs +0 -1
  145. package/dist/packem_shared/quote-identifier-CGiYFBvY.mjs +0 -1
  146. package/dist/packem_shared/runDrizzle-GKR3y97k.mjs +0 -1
  147. package/dist/packem_shared/runShardMigrations-CPxqCh3O.mjs +0 -5
  148. package/dist/packem_shared/runSocketPool-DPQLVyWF.mjs +0 -1
  149. package/dist/packem_shared/selectExpiredIds-FzhIEeG1.mjs +0 -1
  150. package/dist/packem_shared/selectShapeMemberIds-DvE7K6zG.mjs +0 -1
  151. package/dist/packem_shared/serializeSqlValue-DnpyaLcw.mjs +0 -1
  152. package/dist/packem_shared/stableStringify-BjLh4gvA.mjs +0 -1
  153. package/dist/packem_shared/stableWireKey-YEHLaX6X.mjs +0 -1
  154. package/dist/packem_shared/wire-codec-Ctnni0h6.mjs +0 -1
package/dist/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { LunoraError } from '@lunora/errors';
2
+ import { R2BucketLike, ShardHost, SocketHost, SocketHandle } from '@lunora/platform';
2
3
  import { SQL, Name } from 'drizzle-orm';
3
- import { ShardHost, SocketHost, SocketHandle } from '@lunora/platform';
4
4
  interface KeyRange {
5
5
  hi: string;
6
6
  index: string;
@@ -27,10 +27,12 @@ interface ScheduledFunctionDoc {
27
27
  args: Record<string, unknown>;
28
28
  attempts?: number;
29
29
  enqueuedAt: number;
30
- functionPath: string;
30
+ functionPath?: string;
31
31
  id: string;
32
+ pool?: string;
32
33
  scheduledFor: number;
33
34
  shardKey?: string;
35
+ workflow?: string;
34
36
  }
35
37
  interface StorageMetadata {
36
38
  contentType?: string;
@@ -86,6 +88,75 @@ interface WhereInput {
86
88
  OR?: WhereInput[];
87
89
  }
88
90
  declare const RELATION_EXISTS_KEY = "__relationExists";
91
+ interface SubscriptionQuery {
92
+ args?: Record<string, unknown>;
93
+ functionPath?: string;
94
+ sinceEpoch?: string;
95
+ sinceSeq?: number;
96
+ table?: string;
97
+ }
98
+ interface ShapeSubscriptionQuery {
99
+ args?: Record<string, unknown>;
100
+ name: string;
101
+ sinceEpoch?: string;
102
+ sinceSeq?: number;
103
+ }
104
+ interface SubscriptionEnvelope {
105
+ caps?: string[];
106
+ clientId?: string;
107
+ context?: Record<string, unknown>;
108
+ data?: unknown;
109
+ generation?: number;
110
+ id: string;
111
+ query?: SubscriptionQuery;
112
+ shape?: {
113
+ args?: Record<string, unknown>;
114
+ name: string;
115
+ };
116
+ sinceCheckpoint?: number;
117
+ sinceChunk?: number;
118
+ sinceEpoch?: string;
119
+ topic?: string;
120
+ type: "ack" | "connect" | "shape_subscribe" | "shape_unsubscribe" | "stream" | "subscribe" | "unsubscribe" | "whisper" | "whisper_subscribe" | "whisper_unsubscribe";
121
+ }
122
+ interface RpcRequest {
123
+ args?: Record<string, unknown>;
124
+ functionPath: string;
125
+ }
126
+ interface SocketAttachment {
127
+ admin?: boolean;
128
+ adminBinding?: string;
129
+ clientId?: string;
130
+ connected?: boolean;
131
+ connectionId?: string;
132
+ context?: Record<string, unknown>;
133
+ expiresAt?: number;
134
+ identity?: Record<string, unknown>;
135
+ ip?: string;
136
+ pageDeltas?: boolean;
137
+ shapes?: Record<string, ShapeSubscriptionQuery>;
138
+ subs: Record<string, SubscriptionQuery>;
139
+ userId?: string;
140
+ whispers?: string[];
141
+ }
142
+ interface ResolvedShape {
143
+ columns?: ReadonlyArray<string>;
144
+ effectiveWhere?: WhereInput;
145
+ global?: boolean;
146
+ table: string;
147
+ }
148
+ interface SubscriptionIdentity {
149
+ identity?: Record<string, unknown>;
150
+ ip?: string;
151
+ userId?: string;
152
+ }
153
+ interface ShardSocketLike {
154
+ readonly bufferedAmount?: number;
155
+ close?: (code?: number, reason?: string) => void;
156
+ deserializeAttachment?: () => unknown;
157
+ send: (data: string) => void;
158
+ serializeAttachment?: (value: unknown) => void;
159
+ }
89
160
  type AggregateOp = "avg" | "count" | "max" | "min" | "sum";
90
161
  interface AggregateIndexDefinitionLike {
91
162
  readonly by?: ReadonlyArray<string>;
@@ -137,6 +208,8 @@ interface ColumnMetaLike {
137
208
  interface ValidatorLike {
138
209
  readonly _meta?: {
139
210
  readonly column?: ColumnMetaLike;
211
+ readonly inner?: ValidatorLike;
212
+ readonly tableName?: string;
140
213
  };
141
214
  readonly kind?: string;
142
215
  readonly parse?: (value: unknown) => unknown;
@@ -180,9 +253,11 @@ interface SchemaLike {
180
253
  }
181
254
  interface TableDefinitionLike {
182
255
  readonly aggregateIndexes?: ReadonlyArray<AggregateIndexDefinitionLike>;
256
+ readonly commitOrderedMode?: boolean;
183
257
  readonly geoIndexes?: ReadonlyArray<GeoIndexDefinitionLike>;
184
258
  readonly indexes: ReadonlyArray<IndexDefinitionLike>;
185
259
  readonly isPublic?: boolean;
260
+ readonly memoryMode?: boolean;
186
261
  readonly rankIndexes?: ReadonlyArray<RankIndexDefinitionLike>;
187
262
  readonly relationMap?: Record<string, RelationDefinitionLike>;
188
263
  readonly searchIndexes?: ReadonlyArray<SearchIndexDefinitionLike>;
@@ -225,11 +300,16 @@ interface ApplyOnDeleteOptions$1 {
225
300
  row: Record<string, unknown>;
226
301
  tableName: string;
227
302
  }
303
+ interface FanOutBudget {
304
+ remaining: number;
305
+ }
228
306
  interface ResolveWithOptions {
307
+ fanOutBudget?: FanOutBudget;
229
308
  fetcher: (tableName: string, args: QueryArgs) => Promise<QueryPage>;
230
309
  groupedCounter: (tableName: string, whereField: string, values: unknown[], policyWhere?: WhereInput) => Promise<Map<unknown, number>>;
231
310
  parents: Record<string, unknown>[];
232
311
  relationBaseWhere?: (table: string) => undefined | WhereInput;
312
+ relationMask?: RelationMask;
233
313
  schema: {
234
314
  readonly tables: Record<string, TableDefinitionLike>;
235
315
  };
@@ -248,22 +328,69 @@ interface QueryArgs {
248
328
  cursor?: null | string;
249
329
  includeDeleted?: boolean;
250
330
  limit?: number;
331
+ omitContinueCursor?: boolean;
251
332
  orderBy?: OrderByInput[];
252
333
  relationBaseWhere?: (table: string) => undefined | WhereInput;
334
+ relationMask?: RelationMask;
253
335
  restrictsCounts?: boolean;
254
336
  select?: ReadonlyArray<string>;
255
337
  where?: WhereInput;
256
338
  with?: WithInput;
257
339
  }
340
+ interface CrossShardReadArgs {
341
+ orderBy?: OrderByInput[];
342
+ relationPolicies?: Record<string, WhereInput>;
343
+ where?: WhereInput;
344
+ with?: WithInput;
345
+ }
346
+ type RelationMask = (table: string, rows: Record<string, unknown>[]) => Record<string, unknown>[];
258
347
  interface QueryPage {
259
348
  continueCursor: null | string;
260
349
  isDone: boolean;
261
350
  page: Record<string, unknown>[];
262
351
  splitCursor?: null | string;
263
352
  }
353
+ interface RelationEdge {
354
+ readonly array: boolean;
355
+ readonly column: string;
356
+ readonly name: string;
357
+ readonly sourceTable: string;
358
+ readonly targetTable: string;
359
+ }
360
+ interface RelatedStartReference {
361
+ id: string;
362
+ table: string;
363
+ }
364
+ type RelatedStart = (Record<string, unknown> & {
365
+ _id: string;
366
+ }) | RelatedStartReference;
367
+ type RelatedDirection = "both" | "in" | "out";
368
+ interface RelatedOptions {
369
+ cursor?: null | string;
370
+ depth?: number;
371
+ direction?: RelatedDirection;
372
+ edges?: ReadonlyArray<string>;
373
+ limit?: number;
374
+ relationBaseWhere?: (table: string) => undefined | WhereInput;
375
+ relationMask?: RelationMask;
376
+ }
377
+ interface RelatedNode {
378
+ depth: number;
379
+ document: Record<string, unknown>;
380
+ path: ReadonlyArray<string>;
381
+ pathIds: ReadonlyArray<string>;
382
+ score: number;
383
+ table: string;
384
+ }
385
+ interface RelatedPage {
386
+ continueCursor: null | string;
387
+ isDone: boolean;
388
+ nodes: RelatedNode[];
389
+ }
264
390
  interface OrderKey {
265
391
  direction: SortDirection;
266
392
  field: string;
393
+ nullable: boolean;
267
394
  }
268
395
  interface RestrictableQueryOptions {
269
396
  baseWhere?: WhereInput;
@@ -399,10 +526,8 @@ interface LifecycleEvent {
399
526
  shardKey: string;
400
527
  userId: string | null;
401
528
  }
402
- interface LifecycleDispatchInfo {
529
+ interface LifecycleDispatchInfo extends SubscriptionIdentity {
403
530
  event: LifecycleEvent;
404
- identity: Record<string, unknown> | undefined;
405
- userId: string | undefined;
406
531
  }
407
532
  interface MutationDelta {
408
533
  indexKeys?: ReadonlyArray<IndexKeyEntry>;
@@ -414,6 +539,13 @@ interface MutationDelta {
414
539
  interface DatabaseWriterLike {
415
540
  aggregate: (tableName: string, options: AggregateOptions) => Promise<AggregateResult>;
416
541
  asId?: (tableName: string, id: string) => string;
542
+ cdcChangedTables?: (sinceSeq: number, options?: {
543
+ cursorOnly?: boolean;
544
+ }) => Promise<{
545
+ cursor: number;
546
+ floor?: number;
547
+ tables: string[];
548
+ } | undefined>;
417
549
  count: (tableName: string, where?: RestrictableQueryOptions | WhereInput) => Promise<number>;
418
550
  delete: (id: string, expectedTable?: string, options?: {
419
551
  hard?: boolean;
@@ -478,6 +610,8 @@ interface DatabaseWriterLike {
478
610
  rankBefore?: (tableName: string, indexName: string, options: RankBeforeOptions) => Promise<RankBeforeResult>;
479
611
  rankPage: (tableName: string, indexName: string, options?: RankPageOptions) => Promise<RankPage>;
480
612
  rankPageRows?: (tableName: string, indexName: string, options?: RankPageOptions) => Promise<ShardRankPageResult>;
613
+ related?: (start: RelatedStart, options?: RelatedOptions) => Promise<RelatedPage>;
614
+ relationEdges?: ReadonlyArray<RelationEdge>;
481
615
  replace: (id: string, document: Record<string, unknown>, expectedTable?: string, options?: {
482
616
  allowExplicitId?: boolean;
483
617
  }) => Promise<void>;
@@ -516,7 +650,6 @@ interface ImportShardResult {
516
650
  inserted: Record<string, number>;
517
651
  }
518
652
  declare const selectExportTables: (schema: SchemaLike, requested?: ReadonlyArray<string>) => string[];
519
- declare const exportShardTable: (writer: DatabaseWriterLike, table: string, batchSize?: number) => AsyncGenerator<ExportRow, void, undefined>;
520
653
  declare const exportShardRows: (writer: DatabaseWriterLike, schema: SchemaLike, args: ExportShardArgs) => AsyncGenerator<ExportRow, void, undefined>;
521
654
  declare const validateImportRow: (schema: SchemaLike, table: string, record: Record<string, unknown>) => string | undefined;
522
655
  declare const importShardRows: (writer: DatabaseWriterLike, schema: SchemaLike, args: ImportShardArgs) => Promise<ImportShardResult>;
@@ -591,6 +724,7 @@ declare class ReactiveCache {
591
724
  private readonly maxBytes;
592
725
  private readonly now;
593
726
  private monotonic;
727
+ private generation;
594
728
  constructor(options?: ReactiveCacheOptions);
595
729
  run<R>(key: string, deps: Set<string>, run: () => Promise<R>, ranges?: () => ReadonlyArray<KeyRange>): Promise<R>;
596
730
  invalidate(table: string, id: string, indexKeys?: ReadonlyArray<IndexKeyEntry>): string[];
@@ -612,6 +746,7 @@ declare class ReactiveCache {
612
746
  };
613
747
  private dropRangeDeps;
614
748
  private collectAndDrop;
749
+ private dropKeys;
615
750
  private dropEntry;
616
751
  private evict;
617
752
  }
@@ -650,12 +785,18 @@ interface RunTriggersOptions {
650
785
  }
651
786
  declare const runTriggers: (options: RunTriggersOptions) => Promise<void>;
652
787
  declare const hasTrigger: (schema: SchemaLike, tableName: string, op: TriggerOpLike) => boolean;
788
+ interface SearchBackfillProgress {
789
+ done: boolean;
790
+ pages: number;
791
+ }
653
792
  declare const backfillAggregateIndexes: (sql: SqlExec, schema: SchemaLike) => void;
654
793
  declare const backfillRankIndexes: (sql: SqlExec, schema: SchemaLike) => void;
655
794
  declare const backfillSearchIndexesForTable: (sql: SqlExec, tableName: string, definition: {
656
795
  searchIndexes?: ReadonlyArray<SearchIndexDefinitionLike>;
657
796
  }) => void;
658
- declare const backfillSearchIndexes: (sql: SqlExec, schema: SchemaLike) => void;
797
+ declare const backfillSearchIndexes: (sql: SqlExec, schema: SchemaLike, options?: {
798
+ maxPages?: number;
799
+ }) => SearchBackfillProgress;
659
800
  declare const CDC_LOG_TABLE = "__cdc_log";
660
801
  interface CdcChange {
661
802
  doc?: Record<string, unknown>;
@@ -665,19 +806,32 @@ interface CdcChange {
665
806
  table: string;
666
807
  ts: number;
667
808
  }
809
+ declare const CDC_LOG_TABLE_SEQ_INDEX = "__cdc_log_table_seq";
668
810
  declare const migrateCdcLog: (sql: SqlExec) => void;
669
811
  declare const appendCdcChange: (sql: SqlExec, ts: number, table: string, id: string, op: CdcChange["op"], doc: Record<string, unknown> | undefined) => void;
670
812
  declare const readCdcChanges: (sql: SqlExec, options?: {
671
813
  limit?: number;
672
814
  sinceSeq?: number;
673
- tables?: ReadonlySet<string>;
674
815
  }) => {
675
816
  changes: CdcChange[];
676
817
  cursor: number;
677
818
  };
678
- declare const trimCdcChanges: (sql: SqlExec, throughSeq: number) => void;
819
+ declare const cdcTouchesTables: (sql: SqlExec, sinceSeq: number, tables: ReadonlySet<string>) => boolean;
820
+ declare const cdcCanVouchFor: (sql: SqlExec, deps: ReadonlySet<string>) => boolean;
821
+ interface CdcChangeKey {
822
+ id: string;
823
+ op: CdcChange["op"];
824
+ seq: number;
825
+ }
826
+ declare const readCdcChangeKeys: (sql: SqlExec, table: string, sinceSeq: number, upTo: number) => CdcChangeKey[];
827
+ declare const trimCdcChanges: (sql: SqlExec, throughSeq: number, maxRows: number) => void;
828
+ declare const compactCdcDocs: (sql: SqlExec, throughSeq: number, maxRows: number) => void;
829
+ declare const cdcSeqLeavingRows: (sql: SqlExec, keep: number) => number | undefined;
679
830
  declare const readCdcCursor: (sql: SqlExec) => number;
831
+ declare const cursorBelowRetainedFloor: (floor: number | undefined, sinceSeq: number) => boolean;
832
+ declare const cdcTrimmedError: (floor: number, sinceSeq: number, scope: "global" | "shard") => LunoraError;
680
833
  declare const minCdcSeq: (sql: SqlExec) => number | undefined;
834
+ declare const minCdcReplayableSeq: (sql: SqlExec) => number | undefined;
681
835
  declare const CDC_META_TABLE = "__cdc_meta";
682
836
  declare const migrateCdcMeta: (sql: SqlExec) => void;
683
837
  declare const readCdcEpoch: (sql: SqlExec) => string;
@@ -689,7 +843,7 @@ declare const readClientWatermark: (sql: SqlExec, identity: string, clientId: st
689
843
  declare const advanceClientWatermark: (sql: SqlExec, identity: string, clientId: string, mutationId: number) => void;
690
844
  declare const GLOBAL_SHAPE_SNAPSHOT_TABLE = "__global_shape_snapshot";
691
845
  declare const migrateGlobalShapeSnapshot: (sql: SqlExec) => void;
692
- declare const readGlobalShapeSnapshot: (sql: SqlExec, connectionId: string, subId: string) => Map<string, string>;
846
+ declare const readGlobalShapeSnapshot: (sql: SqlExec, connectionId: string, subId: string) => Map<string, string> | undefined;
693
847
  declare const writeGlobalShapeSnapshot: (sql: SqlExec, connectionId: string, subId: string, snapshot: Map<string, string>) => void;
694
848
  declare const deleteGlobalShapeSnapshot: (sql: SqlExec, connectionId: string, subId: string) => void;
695
849
  declare const deleteGlobalShapeSnapshotsForConnection: (sql: SqlExec, connectionId: string) => void;
@@ -709,21 +863,6 @@ declare const runShardMigrations: (sql: SqlExec, schema: SchemaLike, options?: {
709
863
  json: string;
710
864
  };
711
865
  }) => void;
712
- /**
713
- * How far a search companion's backfill has progressed, and what the next pass
714
- * should do about it.
715
- *
716
- * Neither stored analysis nor query policy, which is why it is its own module
717
- * rather than a third responsibility bolted onto one of them: it is *progress*,
718
- * the one piece of search state that is written as the index is built rather
719
- * than decided when it is read.
720
- *
721
- * The policy below is shared because when each engine owned a copy they
722
- * immediately disagreed about exactly the two cases that matter — whether a row
723
- * with no recorded profile may be resumed (it may not; nothing says what
724
- * analyzed it) and whether a never-started index is worth wiping (it is not;
725
- * there is nothing in it).
726
- */
727
866
  /**
728
867
  * How far a companion's backfill has progressed, and under which analysis.
729
868
  * Declared here rather than beside either engine's state table: both record the
@@ -747,12 +886,14 @@ interface ShapeRow {
747
886
  id: string;
748
887
  }
749
888
  declare const selectShapeRows: (sql: SqlExec, table: string, effectiveWhere: WhereInput | undefined) => ShapeRow[];
750
- declare const selectShapeMemberIds: (sql: SqlExec, table: string, effectiveWhere: WhereInput | undefined, ids: ReadonlyArray<string>) => Set<string>;
889
+ declare const selectShapeMembers: (sql: SqlExec, table: string, effectiveWhere: WhereInput | undefined, ids: ReadonlyArray<string>) => Map<string, Record<string, unknown>>;
751
890
  interface SqlExec {
752
891
  exec: <Row = Record<string, unknown>>(sql: string, ...params: unknown[]) => SqlCursor<Row>;
753
892
  }
754
893
  interface SqlCursor<Row> extends Iterable<Row> {
894
+ readonly columnNames?: string[];
755
895
  one: () => Row;
896
+ raw?: () => IterableIterator<unknown[]>;
756
897
  toArray: () => Row[];
757
898
  }
758
899
  type IndexUseHook = (table: string, indexName: string, kind: "geo" | "index" | "rank" | "search") => void;
@@ -776,6 +917,7 @@ interface CtxDbOptions {
776
917
  globalDb?: DatabaseWriterLike;
777
918
  headroom?: TransactionHeadroomTracker;
778
919
  idGenerator?: IdGenerator;
920
+ inTransaction?: () => boolean;
779
921
  maxRelationKeys?: number;
780
922
  onIndexUse?: IndexUseHook;
781
923
  onRead?: ReadHook;
@@ -792,6 +934,8 @@ declare class NotUniqueError extends LunoraError {
792
934
  constructor(message?: string);
793
935
  }
794
936
  declare const normalizeIdStructurally: (schema: SchemaLike, tableName: string, id: string) => null | string;
937
+ declare const assertNoExplicitUndefined: (op: "patch" | "replace", document: Record<string, unknown>) => void;
938
+ declare const stripReservedPatchFields: (patch: Record<string, unknown>) => Record<string, unknown>;
795
939
  declare const createShardCtxDb: (options: CtxDbOptions) => DatabaseWriterLike;
796
940
  declare const AUDIT_LOG_TABLE = "__lunora_audit__";
797
941
  interface AuditEntry {
@@ -815,68 +959,22 @@ declare const readAuditLog: (sql: SqlExec, options?: {
815
959
  limit?: number;
816
960
  sinceSeq?: number;
817
961
  }) => AuditEntry[];
818
- interface SubscriptionQuery {
819
- args?: Record<string, unknown>;
820
- functionPath?: string;
821
- sinceEpoch?: string;
822
- sinceSeq?: number;
823
- table?: string;
824
- }
825
- interface ShapeSubscriptionQuery {
826
- args?: Record<string, unknown>;
827
- name: string;
828
- sinceEpoch?: string;
829
- sinceSeq?: number;
830
- }
831
- interface SubscriptionEnvelope {
832
- clientId?: string;
833
- context?: Record<string, unknown>;
834
- data?: unknown;
835
- id: string;
836
- query?: SubscriptionQuery;
837
- shape?: {
838
- args?: Record<string, unknown>;
839
- name: string;
840
- };
841
- sinceCheckpoint?: number;
842
- sinceEpoch?: string;
843
- topic?: string;
844
- type: "ack" | "connect" | "shape_subscribe" | "shape_unsubscribe" | "stream" | "subscribe" | "unsubscribe" | "whisper" | "whisper_subscribe" | "whisper_unsubscribe";
845
- }
846
- interface RpcRequest {
847
- args?: Record<string, unknown>;
848
- functionPath: string;
849
- }
850
- interface SocketAttachment {
851
- admin?: boolean;
852
- clientId?: string;
853
- connected?: boolean;
854
- connectionId?: string;
855
- context?: Record<string, unknown>;
856
- expiresAt?: number;
857
- identity?: Record<string, unknown>;
858
- shapes?: Record<string, ShapeSubscriptionQuery>;
859
- subs: Record<string, SubscriptionQuery>;
860
- userId?: string;
861
- whispers?: string[];
862
- }
863
- interface ResolvedShape {
864
- columns?: ReadonlyArray<string>;
865
- effectiveWhere?: WhereInput;
866
- global?: boolean;
867
- table: string;
868
- }
869
- interface SubscriptionIdentity {
870
- identity?: Record<string, unknown>;
871
- userId?: string;
872
- }
873
- interface ShardSocketLike {
874
- readonly bufferedAmount?: number;
875
- close?: (code?: number, reason?: string) => void;
876
- deserializeAttachment?: () => unknown;
877
- send: (data: string) => void;
878
- serializeAttachment?: (value: unknown) => void;
879
- }
962
+ interface CdcArchiveScope {
963
+ epoch: string;
964
+ shard: string;
965
+ }
966
+ declare const readCdcArchivedThrough: (sql: SqlExec) => number;
967
+ declare const writeCdcArchivedThrough: (sql: SqlExec, seq: number) => void;
968
+ declare const archiveCdcSegment: (bucket: R2BucketLike, scope: CdcArchiveScope, changes: CdcChange[]) => Promise<void>;
969
+ declare const readArchivedCdcChanges: (bucket: R2BucketLike, scope: CdcArchiveScope, sinceSeq: number, limit: number | undefined) => Promise<{
970
+ changes: CdcChange[];
971
+ cursor: number;
972
+ } | undefined>;
973
+ declare const COMMIT_SEQ_TABLE = "__commit_seq";
974
+ declare const COMMIT_SEQ_FIELD = "_commitSeq";
975
+ declare const migrateCommitSeq: (sql: SqlExec) => void;
976
+ declare const readCommitSeq: (sql: SqlExec) => number;
977
+ declare const allocateCommitSeq: (sql: SqlExec) => number;
880
978
  interface CompanionSyncDeps {
881
979
  broadcast: (delta: MutationDelta) => void;
882
980
  indexKeysFor: (table: string, document?: Record<string, unknown>) => ReadonlyArray<{
@@ -900,6 +998,13 @@ interface CompanionSync {
900
998
  syncSearch: (tableName: string, id: string, document: Record<string, unknown> | undefined, previous?: Record<string, unknown>) => void;
901
999
  }
902
1000
  declare const createCompanionSync: (deps: CompanionSyncDeps) => CompanionSync;
1001
+ declare const isMemoryTable: (definition: TableDefinitionLike | undefined) => boolean;
1002
+ declare const memoryTableNames: (schema: SchemaLike) => string[];
1003
+ declare const clearMemoryTables: (sql: SqlExec, schema: SchemaLike) => number;
1004
+ declare const resolveRankSeekTuple: (options: {
1005
+ after?: RankPageRowKey;
1006
+ cursor?: null | string;
1007
+ }) => unknown[] | undefined;
903
1008
  interface RankPageDeps {
904
1009
  assertRankPartitionLocal: (tableName: string, definition: TableDefinitionLike, index: RankIndexDefinitionLike) => void;
905
1010
  ensureRankBackfilled: (tableName: string, index: RankIndexDefinitionLike) => void;
@@ -917,8 +1022,49 @@ interface RankPageComputation {
917
1022
  key: RankPageRowKey;
918
1023
  }[];
919
1024
  }
920
- declare const hydrateDocsById: (deps: RankPageDeps, tableName: string, ids: ReadonlyArray<string>) => Map<string, Record<string, unknown>>;
921
1025
  declare const computeRankPage: (deps: RankPageDeps, tableName: string, indexName: string, rankPageOptions: RankPageOptions) => RankPageComputation;
1026
+ declare const SCHEDULE_OUTBOX_TABLE = "__schedule_outbox";
1027
+ interface ScheduleOutboxRow {
1028
+ attempts: number;
1029
+ envelopeJson: string;
1030
+ id: string;
1031
+ nextAttemptAt: number;
1032
+ }
1033
+ interface ScheduleOutboxEnvelope {
1034
+ args: unknown;
1035
+ options: Record<string, unknown> | undefined;
1036
+ target: unknown;
1037
+ when: number;
1038
+ }
1039
+ interface ScheduleOutbox {
1040
+ forget: (id: string) => void;
1041
+ record: (id: string, envelope: ScheduleOutboxEnvelope) => void;
1042
+ wake: () => void;
1043
+ }
1044
+ declare const migrateScheduleOutbox: (sql: SqlExec) => void;
1045
+ declare const recordScheduleOutbox: (sql: SqlExec, id: string, envelopeJson: string, now: number) => void;
1046
+ declare const forgetScheduleOutbox: (sql: SqlExec, id: string) => void;
1047
+ declare const readDueScheduleOutbox: (sql: SqlExec, nowMs: number, limit: number) => ScheduleOutboxRow[];
1048
+ declare const deferScheduleOutbox: (sql: SqlExec, id: string, attempts: number, nextAttemptAt: number) => void;
1049
+ declare const parkScheduleOutbox: (sql: SqlExec, id: string, attempts: number) => void;
1050
+ declare const probeScheduleOutbox: (sql: SqlExec) => {
1051
+ dueAt: number | undefined;
1052
+ populated: boolean;
1053
+ };
1054
+ declare const trimScheduleOutbox: (sql: SqlExec, olderThanTs: number) => void;
1055
+ declare const SHAPE_POKE_CURSOR_TABLE = "__shape_poke_cursor";
1056
+ declare const migrateShapePokeCursor: (sql: SqlExec) => void;
1057
+ declare const readShapePokeCursor: (sql: SqlExec, connectionId: string, subId: string) => number | undefined;
1058
+ declare const writeShapePokeCursor: (sql: SqlExec, connectionId: string, subId: string, cursor: number) => void;
1059
+ interface ShapePokeCursorRow {
1060
+ connectionId: string;
1061
+ cursor: number;
1062
+ subId: string;
1063
+ }
1064
+ declare const writeShapePokeCursors: (sql: SqlExec, rows: ReadonlyArray<ShapePokeCursorRow>) => void;
1065
+ declare const minShapePokeCursor: (sql: SqlExec) => number | undefined;
1066
+ declare const deleteShapePokeCursor: (sql: SqlExec, connectionId: string, subId: string) => void;
1067
+ declare const deleteShapePokeCursorsForConnection: (sql: SqlExec, connectionId: string) => void;
922
1068
  declare const DATA_MIGRATION_STATE_TABLE = "__lunora_migrations";
923
1069
  type MigrationDirection = "down" | "up";
924
1070
  type MigrationStatus = "completed" | "failed" | "in_progress";
@@ -982,10 +1128,10 @@ interface DependencyTracker {
982
1128
  declare const createDependencyTracker: () => DependencyTracker;
983
1129
  declare const runSql: <Row = Record<string, unknown>>(sql: SqlExec, query: string, ...params: unknown[]) => SqlCursor<Row>;
984
1130
  declare const runDrizzle: <Row = Record<string, unknown>>(exec: SqlExec, query: SQL) => SqlCursor<Row>;
1131
+ declare const quoteIdentifier: (name: string) => string;
985
1132
  declare const serializeSqlValue: (value: unknown) => unknown;
986
1133
  declare const DOC_COLUMN = "__doc__";
987
1134
  declare const geoTableName: (table: string, indexName: string) => string;
988
- declare const quoteIdentifier: (name: string) => string;
989
1135
  declare const jsonPath: (field: string) => string;
990
1136
  declare const jsonPathSql: (field: string) => SQL;
991
1137
  declare const qualifiedJsonPath: (table: string, field: string) => string;
@@ -995,7 +1141,7 @@ declare const AGG_KEY: Name;
995
1141
  declare const AGG_VALUE: Name;
996
1142
  declare const AGG_COUNT: Name;
997
1143
  declare const aggUpsertSql: (aggTable: string, key: unknown, value: unknown, count: unknown, set: SQL) => SQL;
998
- declare const tableColumns: (definition: TableDefinitionLike) => [string, ColumnMetaLike][];
1144
+ declare const tableColumns: (definition: TableDefinitionLike) => ReadonlyArray<readonly [string, ColumnMetaLike]>;
999
1145
  declare const rowToDocument: (row: Record<string, unknown> | undefined) => Record<string, unknown> | undefined;
1000
1146
  declare const tryRowToDocument: (row: Record<string, unknown> | undefined) => Record<string, unknown> | undefined;
1001
1147
  declare const isFtsAvailable: (sql: SqlExec) => boolean;
@@ -1006,6 +1152,79 @@ interface RenderedSql {
1006
1152
  }
1007
1153
  declare const renderSql: (engine: SqlEngine, query: SQL) => RenderedSql;
1008
1154
  declare const param: (value: unknown) => SQL;
1155
+ declare const unionAll: (branches: ReadonlyArray<SQL>) => SQL;
1156
+ declare const sqliteInList: (reference: SQL, items: ReadonlyArray<unknown>, negated: boolean, budget?: number) => SQL;
1157
+ type DurableStreamStatus = "complete" | "error" | "running";
1158
+ interface DurableStreamRun {
1159
+ error?: string;
1160
+ errorCode?: string;
1161
+ lastSeq: number;
1162
+ startedAt: number;
1163
+ status: DurableStreamStatus;
1164
+ }
1165
+ interface DurableStreamChunk {
1166
+ dataJson: string;
1167
+ seq: number;
1168
+ }
1169
+ declare const migrateDurableStreams: (sql: SqlExec) => void;
1170
+ declare const readStreamRun: (sql: SqlExec, runKey: string) => DurableStreamRun | undefined;
1171
+ declare const claimStreamRun: (sql: SqlExec, runKey: string, startedAt: number, ttlMs: number) => boolean;
1172
+ declare const deleteStreamRun: (sql: SqlExec, runKey: string) => void;
1173
+ declare const appendStreamChunk: (sql: SqlExec, runKey: string, seq: number, dataJson: string) => void;
1174
+ declare const readStreamChunks: (sql: SqlExec, runKey: string, sinceSeq: number) => DurableStreamChunk[];
1175
+ declare const finishStreamRun: (sql: SqlExec, runKey: string, status: "complete" | "error", lastSeq: number, failure?: {
1176
+ code: string;
1177
+ message: string;
1178
+ }) => void;
1179
+ declare const trimStreamRuns: (sql: SqlExec, now: number) => void;
1180
+ declare const MAX_DURABLE_STREAM_CHUNKS = 50000;
1181
+ declare const MAX_DURABLE_STREAM_BYTES: number;
1182
+ interface DurableStreamSink {
1183
+ readonly chunk: (chunk: {
1184
+ data: unknown;
1185
+ generation?: number;
1186
+ seq: number;
1187
+ }) => boolean;
1188
+ readonly complete: () => void;
1189
+ readonly fail: (failure: {
1190
+ code: string;
1191
+ message: string;
1192
+ }) => void;
1193
+ }
1194
+ type DurableAttachDecision = "attach" | "interrupted" | "reclaim" | "replay-terminal";
1195
+ declare const decideDurableAttach: (run: DurableStreamRun | undefined, context: {
1196
+ generation?: number;
1197
+ live?: {
1198
+ generation: number;
1199
+ };
1200
+ resuming: boolean;
1201
+ }) => DurableAttachDecision;
1202
+ interface DurableStreamAttach {
1203
+ readonly generation?: number;
1204
+ readonly iterator: (signal: AbortSignal) => AsyncIterable<unknown>;
1205
+ readonly runKey: string;
1206
+ readonly sinceChunk: number;
1207
+ readonly sink: DurableStreamSink;
1208
+ readonly ttlMs?: number;
1209
+ }
1210
+ declare class DurableStreamRunner {
1211
+ private lastTrimAt;
1212
+ private readonly runs;
1213
+ private readonly sql;
1214
+ private readonly waitUntil;
1215
+ constructor(dependencies: {
1216
+ sql: () => SqlExec;
1217
+ waitUntil?: (promise: Promise<unknown>) => void;
1218
+ });
1219
+ attach(request: DurableStreamAttach): Promise<void>;
1220
+ detach(runKey: string, sink: DurableStreamSink): void;
1221
+ isLive(runKey: string): boolean;
1222
+ private attachOrThrow;
1223
+ private produce;
1224
+ private trim;
1225
+ }
1226
+ declare const envPositiveInt: (env: unknown, key: string, fallback: number) => number;
1227
+ declare const envOptionalPositiveInt: (env: unknown, key: string) => number | undefined;
1009
1228
  interface ExternalSourceDiffResult {
1010
1229
  changes: CdcChange[];
1011
1230
  nextBaseline: Map<string, string>;
@@ -1085,6 +1304,19 @@ declare const coveringGeohashes: (center: GeoPoint, radiusMeters: number) => str
1085
1304
  declare const pointInBoundingBox: (point: GeoPoint, box: GeoBoundingBox) => boolean;
1086
1305
  declare const boundingBoxCenter: (box: GeoBoundingBox) => GeoPoint;
1087
1306
  declare const boundingBoxGeohashes: (box: GeoBoundingBox) => string[];
1307
+ declare class GlobalPollTick {
1308
+ private readonly changedTables;
1309
+ private readonly reads;
1310
+ private resync;
1311
+ private skippedCount;
1312
+ constructor(changedTables?: Set<string>);
1313
+ get readCount(): number;
1314
+ get resyncRequested(): boolean;
1315
+ get skipped(): number;
1316
+ requestResync(): void;
1317
+ rows(key: string | undefined, load: () => Promise<ShapeRow[]>): Promise<ShapeRow[]>;
1318
+ shouldRead(table: string): boolean;
1319
+ }
1088
1320
  declare const ADMIN_FUNCTION_PREFIX = "__lunora_admin__:";
1089
1321
  declare const RELATION_FUNCTION_PREFIX = "__lunora_relation__:";
1090
1322
  declare const FLAGS_FUNCTION_PREFIX = "__lunora_flags__:";
@@ -1095,6 +1327,7 @@ declare const ADMIN_FUNCTIONS: {
1095
1327
  readonly aiGenerateSql: "__lunora_admin__:aiGenerateSql";
1096
1328
  readonly aiTableFilter: "__lunora_admin__:aiTableFilter";
1097
1329
  readonly assignIssue: "__lunora_admin__:assignIssue";
1330
+ readonly backfillSearch: "__lunora_admin__:backfillSearch";
1098
1331
  readonly backRelationCounts: "__lunora_admin__:backRelationCounts";
1099
1332
  readonly cdcSync: "__lunora_admin__:cdcSync";
1100
1333
  readonly clearCapturedMail: "__lunora_admin__:clearCapturedMail";
@@ -1107,6 +1340,7 @@ declare const ADMIN_FUNCTIONS: {
1107
1340
  readonly explainIssue: "__lunora_admin__:explainIssue";
1108
1341
  readonly exportShard: "__lunora_admin__:exportShard";
1109
1342
  readonly facetColumn: "__lunora_admin__:facetColumn";
1343
+ readonly findRelated: "__lunora_admin__:findRelated";
1110
1344
  readonly getAdvisories: "__lunora_admin__:getAdvisories";
1111
1345
  readonly getAdvisorProcedures: "__lunora_admin__:getAdvisorProcedures";
1112
1346
  readonly getAuditLog: "__lunora_admin__:getAuditLog";
@@ -1133,12 +1367,14 @@ declare const ADMIN_FUNCTIONS: {
1133
1367
  readonly ignoreIssue: "__lunora_admin__:ignoreIssue";
1134
1368
  readonly importShard: "__lunora_admin__:importShard";
1135
1369
  readonly listFlags: "__lunora_admin__:listFlags";
1370
+ readonly listReactors: "__lunora_admin__:listReactors";
1136
1371
  readonly listQueues: "__lunora_admin__:listQueues";
1137
1372
  readonly lintSql: "__lunora_admin__:lintSql";
1138
1373
  readonly listTables: "__lunora_admin__:listTables";
1139
1374
  readonly listWorkflows: "__lunora_admin__:listWorkflows";
1140
1375
  readonly maskPolicies: "__lunora_admin__:maskPolicies";
1141
1376
  readonly migrationStatus: "__lunora_admin__:migrationStatus";
1377
+ readonly patchRows: "__lunora_admin__:patchRows";
1142
1378
  readonly pitrRestore: "__lunora_admin__:pitrRestore";
1143
1379
  readonly rankBefore: "__lunora_admin__:rankBefore";
1144
1380
  readonly rankPage: "__lunora_admin__:rankPage";
@@ -1216,8 +1452,12 @@ interface TablesIndexesResult {
1216
1452
  indexesByTable: Record<string, TableIndexInfo[]>;
1217
1453
  }
1218
1454
  interface ColumnMeta {
1455
+ bucket?: string;
1456
+ enumValues?: string[];
1219
1457
  isStorage?: boolean;
1220
1458
  name: string;
1459
+ nullable?: boolean;
1460
+ onDelete?: "cascade" | "restrict" | "set null";
1221
1461
  optional: boolean;
1222
1462
  pk?: boolean;
1223
1463
  ref?: string;
@@ -1332,6 +1572,19 @@ interface FlagsResult {
1332
1572
  configured: boolean;
1333
1573
  flags: FlagEvaluation[];
1334
1574
  }
1575
+ interface ReactorMetadata {
1576
+ errors: number;
1577
+ lastError?: string;
1578
+ lastRanAt?: number;
1579
+ path: string;
1580
+ runs: number;
1581
+ state: "active" | "failing" | "idle";
1582
+ suppressed: number;
1583
+ tables?: ReadonlyArray<string>;
1584
+ }
1585
+ interface ReactorsResult {
1586
+ reactors: ReactorMetadata[];
1587
+ }
1335
1588
  interface WorkflowMetadata {
1336
1589
  binding: string;
1337
1590
  className: string;
@@ -1390,6 +1643,7 @@ interface TablePage {
1390
1643
  columns: string[];
1391
1644
  refs?: Record<string, string>;
1392
1645
  rows: Record<string, unknown>[];
1646
+ sqlColumns: string[];
1393
1647
  total?: number;
1394
1648
  }
1395
1649
  type FilterOperator = "contains" | "eq" | "gt" | "gte" | "lt" | "lte" | "ne";
@@ -1413,6 +1667,7 @@ interface ReadTablePageOptions {
1413
1667
  table: string;
1414
1668
  }
1415
1669
  interface SelectMatchingIdsOptions {
1670
+ after?: string;
1416
1671
  filters?: FilterClause[];
1417
1672
  limit?: number;
1418
1673
  search?: string;
@@ -1469,12 +1724,22 @@ interface FanoutPathCounters {
1469
1724
  socketsIterated: number;
1470
1725
  totalMs: number;
1471
1726
  }
1727
+ interface ShapeProbeCounters {
1728
+ run: number;
1729
+ served: number;
1730
+ }
1731
+ interface GlobalPollCounters {
1732
+ drains: number;
1733
+ pairsSkipped: number;
1734
+ }
1472
1735
  interface FanoutMetricsResult {
1736
+ globalPoll: GlobalPollCounters;
1473
1737
  maxRelays: number;
1474
1738
  peakSubscribers: number;
1475
1739
  promoted: boolean;
1476
1740
  relayCount: number;
1477
1741
  shapePoke: FanoutPathCounters;
1742
+ shapeProbe: ShapeProbeCounters;
1478
1743
  sinceMs: number;
1479
1744
  topics: FanoutTopicStat[];
1480
1745
  totalConnections: number;
@@ -1488,6 +1753,10 @@ interface FanoutAttachmentLike {
1488
1753
  }
1489
1754
  declare const DEFAULT_FANOUT_TOPIC_LIMIT = 20;
1490
1755
  declare const createFanoutCounters: () => FanoutPathCounters;
1756
+ declare const createShapeProbeCounters: () => ShapeProbeCounters;
1757
+ declare const createGlobalPollCounters: () => GlobalPollCounters;
1758
+ declare const recordGlobalPollPass: (counters: GlobalPollCounters, drains: number, pairsSkipped: number) => GlobalPollCounters;
1759
+ declare const recordShapeProbePass: (counters: ShapeProbeCounters, run: number, served: number) => ShapeProbeCounters;
1491
1760
  declare const recordFanoutPass: (counters: FanoutPathCounters, iterated: number, delivered: number, ms: number) => FanoutPathCounters;
1492
1761
  declare const summarizeFanoutTopics: (attachments: FanoutAttachmentLike[], limit?: number) => {
1493
1762
  peakSubscribers: number;
@@ -1556,7 +1825,20 @@ interface PitrRestoreArgs {
1556
1825
  }
1557
1826
  declare const readBookmark: (storage: PitrStorage, time?: number | string) => Promise<PitrBookmarkResult>;
1558
1827
  declare const armRestore: (storage: PitrStorage, args: PitrRestoreArgs) => Promise<Omit<PitrRestoreResult, "restarted">>;
1559
- declare const normalizeOrderKeys: (orderBy: OrderByInput[] | undefined) => OrderKey[];
1828
+ declare const tiebreakDirectionFor: (keys: ReadonlyArray<{
1829
+ direction?: string;
1830
+ }>) => SortDirection;
1831
+ declare const equalityPinnedFields: (where: undefined | WhereInput) => ReadonlySet<string>;
1832
+ declare const uniqueIndexFields: (indexes: ReadonlyArray<{
1833
+ fields: ReadonlyArray<string>;
1834
+ unique?: boolean;
1835
+ }> | undefined, shape: Record<string, ValidatorLike> | undefined) => ReadonlyArray<ReadonlyArray<string>>;
1836
+ interface OrderKeyConstraints {
1837
+ pinned?: ReadonlySet<string>;
1838
+ uniqueBy?: ReadonlyArray<ReadonlyArray<string>>;
1839
+ }
1840
+ declare const normalizeOrderKeys: (orderBy: OrderByInput[] | undefined, shape?: Record<string, ValidatorLike>, constraints?: OrderKeyConstraints) => OrderKey[];
1841
+ declare const CURSOR_PREFIX = "~4";
1560
1842
  declare const encodeCursor: (record: Record<string, unknown>, keys: OrderKey[]) => string;
1561
1843
  declare const decodeCursor: (cursor: string) => unknown[];
1562
1844
  declare const buildSeekWhere: (keys: OrderKey[], cursorValues: unknown[]) => WhereInput;
@@ -1609,7 +1891,6 @@ declare const clearQueueMessages: (sql: SqlExec) => {
1609
1891
  declare const encodePartitionKey: (partitionBy: ReadonlyArray<string>, source: Record<string, unknown>) => string;
1610
1892
  declare const RANK_TIEBREAK = "__id__";
1611
1893
  declare const sortColumnName: (i: number) => string;
1612
- declare const matchesRankStaticWhere: (document: Record<string, unknown>, predicate: Record<string, unknown>) => boolean;
1613
1894
  declare const resolveRankPartition: (index: RankIndexDefinitionLike, where: Record<string, unknown> | undefined) => Record<string, unknown> | undefined;
1614
1895
  declare const rankTableName: (table: string, indexName: string) => string;
1615
1896
  declare const rankKeyFromDocument: (index: RankIndexDefinitionLike, document_: Record<string, unknown>) => {
@@ -1617,6 +1898,36 @@ declare const rankKeyFromDocument: (index: RankIndexDefinitionLike, document_: R
1617
1898
  rowId: string;
1618
1899
  sortValues: unknown[];
1619
1900
  };
1901
+ declare const rankPivotConditionSql: (column: string, value: unknown, direction: "asc" | "desc", wantLater: boolean) => SQL | undefined;
1902
+ declare const matchesRankStaticWhere: (document: Record<string, unknown>, predicate: Record<string, unknown>) => boolean;
1903
+ declare const REACTOR_STATE_TABLE = "__reactor_state";
1904
+ interface ReactorState {
1905
+ digest: string;
1906
+ lastError?: string;
1907
+ lastRanAt: number;
1908
+ stats: ReactorStats;
1909
+ tables?: ReadonlyArray<string>;
1910
+ }
1911
+ interface ReactorStats {
1912
+ errors: number;
1913
+ runs: number;
1914
+ suppressed: number;
1915
+ }
1916
+ declare const migrateReactorState: (sql: SqlExec) => void;
1917
+ declare const readReactorState: (sql: SqlExec, path: string) => ReactorState | undefined;
1918
+ declare const listReactorStates: (sql: SqlExec) => {
1919
+ path: string;
1920
+ state: ReactorState;
1921
+ }[];
1922
+ type ReactorDispatchResult = "error" | "ran" | "suppressed";
1923
+ declare const writeReactorState: (sql: SqlExec, path: string, outcome: {
1924
+ digest?: string;
1925
+ error?: string;
1926
+ now: number;
1927
+ result: ReactorDispatchResult;
1928
+ tables?: ReadonlyArray<string>;
1929
+ }) => void;
1930
+ declare const reactorNeedsRun: (state: Pick<ReactorState, "tables"> | undefined, changed: ReadonlySet<string>) => boolean;
1620
1931
  interface ReadFootprint {
1621
1932
  onRead: (table: string, idOrScan?: string) => void;
1622
1933
  onReadRange: (range: KeyRange) => void;
@@ -1624,6 +1935,15 @@ interface ReadFootprint {
1624
1935
  tables: Set<string>;
1625
1936
  }
1626
1937
  declare const createReadFootprint: () => ReadFootprint;
1938
+ declare const UNVOUCHABLE_DEP = "!unvouchable";
1939
+ declare const markUnvouchableReads: <T extends object>(facade: T, onRead: ReadFootprint["onRead"] | undefined, methods: ReadonlyArray<string>) => T;
1940
+ declare const RELATED_MAX_DEPTH = 4;
1941
+ declare const RELATED_DEFAULT_LIMIT = 50;
1942
+ declare const RELATED_MAX_LIMIT = 200;
1943
+ declare const RELATED_DEPTH_DECAY = 0.5;
1944
+ declare const deriveRelationEdges: (schema: SchemaLike) => RelationEdge[];
1945
+ type RelationGraphReader = Pick<DatabaseWriterLike, "findMany"> & Pick<Partial<DatabaseWriterLike>, "lookupById">;
1946
+ declare const findRelated: (reader: RelationGraphReader, edges: ReadonlyArray<RelationEdge>, start: RelatedStart, options?: RelatedOptions) => Promise<RelatedPage>;
1627
1947
  declare const DEFAULT_MAX_RELATION_KEYS = 5000;
1628
1948
  interface RelationExistsMarker {
1629
1949
  childWhere: WhereInput;
@@ -1658,6 +1978,7 @@ declare const containsRelationPredicate: (where: WhereInput, schema: ResolveCont
1658
1978
  declare const assertFlatPredicate: (where: WhereInput | undefined, schema: ResolveContext["schema"], tableName: string, op: string) => void;
1659
1979
  declare const resolveRelationPredicates: (where: WhereInput | undefined, options: ResolveRelationPredicatesOptions) => Promise<WhereInput | undefined>;
1660
1980
  declare const assertShapeShardable: (effectiveWhere: WhereInput | undefined, schema: ResolveContext["schema"], table: string) => void;
1981
+ declare const relationHooks: (args: Pick<QueryArgs, "relationBaseWhere" | "relationMask">) => Pick<QueryArgs, "relationBaseWhere" | "relationMask"> & Pick<ResolveWithOptions, "fanOutBudget">;
1661
1982
  declare const fanOutScalarCounts: (counter: (tableName: string, where?: WhereInput) => Promise<number>, tableName: string, whereField: string, values: unknown[], policyWhere: WhereInput | undefined) => Promise<Map<unknown, number>>;
1662
1983
  declare const distinctValues: (rows: Record<string, unknown>[], field: string) => unknown[];
1663
1984
  declare const resolveWith: (options: ResolveWithOptions) => Promise<void>;
@@ -1682,6 +2003,8 @@ interface ShapeRowOp {
1682
2003
  value?: Record<string, unknown>;
1683
2004
  }
1684
2005
  interface ShapePokePart {
2006
+ baseCheckpoint?: number;
2007
+ reset?: boolean;
1685
2008
  rowsPatch: ShapeRowOp[];
1686
2009
  shapeId: string;
1687
2010
  }
@@ -1742,6 +2065,12 @@ interface RelayShapeSubscribe {
1742
2065
  type: "relay_shape_subscribe";
1743
2066
  userId?: string;
1744
2067
  }
2068
+ interface RelayShapeUnsubscribe {
2069
+ connectionId: string;
2070
+ relayIndex: number;
2071
+ subId?: string;
2072
+ type: "relay_shape_unsubscribe";
2073
+ }
1745
2074
  interface RelayShapeSeed {
1746
2075
  cursor?: number;
1747
2076
  epoch?: string;
@@ -1761,22 +2090,18 @@ interface RelayShapePoke {
1761
2090
  targetConnectionId?: string;
1762
2091
  type: "relay_shape_poke";
1763
2092
  }
1764
- type OwnerRelayFrame = RelayAttach | RelayDetach | RelayFrame | RelayShapePoke | RelayShapeSubscribe;
1765
- declare const DEFAULT_MAX_RELAYS = 8;
1766
- interface RelayStub {
2093
+ type OwnerRelayFrame = RelayAttach | RelayDetach | RelayFrame | RelayShapePoke | RelayShapeSubscribe | RelayShapeUnsubscribe;
2094
+ interface SiblingStub {
1767
2095
  fetch: (url: string, init?: RequestInit) => Promise<Response>;
1768
2096
  }
1769
- interface RelayNamespaceLike {
1770
- get: (id: unknown) => RelayStub;
1771
- getByName?: (name: string) => RelayStub;
1772
- idFromName: (name: string) => unknown;
1773
- }
2097
+ declare const DEFAULT_MAX_RELAYS = 8;
1774
2098
  interface RelayHost {
1775
2099
  buildShapeDiff: (resolved: ResolvedShape, fromCursor: number, toCursor: number) => ShapeRowOp[];
1776
2100
  computeOpLogShapeSeed: (shape: ShapeSubscriptionQuery, resolved: ResolvedShape) => {
1777
2101
  baseCheckpoint: number | undefined;
1778
2102
  cursor: number;
1779
2103
  epoch: string | undefined;
2104
+ reset: boolean;
1780
2105
  rowsPatch: ShapeRowOp[];
1781
2106
  };
1782
2107
  currentCdcEpoch: () => string | undefined;
@@ -1791,8 +2116,13 @@ interface RelayHost {
1791
2116
  resolveShape: (name: string, args: Record<string, unknown>, identity?: SubscriptionIdentity) => ResolvedShape | undefined;
1792
2117
  rlsMetadata: () => RlsPoliciesResult;
1793
2118
  shardBinding: () => string | undefined;
2119
+ shardJurisdiction: () => string | undefined;
1794
2120
  sql: () => SqlExec;
1795
2121
  }
2122
+ interface RelayPokeDelivery {
2123
+ delivered: number;
2124
+ matched: number;
2125
+ }
1796
2126
  declare abstract class RelayLink {
1797
2127
  protected readonly host: RelayHost;
1798
2128
  protected readonly roleId: {
@@ -1806,7 +2136,8 @@ declare abstract class RelayLink {
1806
2136
  handleControl(request: Request): Promise<Response>;
1807
2137
  maxRelays(): number;
1808
2138
  protected canAddressSiblings(): boolean;
1809
- protected relayNamespace(): RelayNamespaceLike | undefined;
2139
+ protected siblingStub(targetName: string): SiblingStub | undefined;
2140
+ protected bindingName(): string | undefined;
1810
2141
  protected postRelayMessage(targetName: string, message: OwnerRelayFrame): Promise<void>;
1811
2142
  protected requestRelayMessage(targetName: string, message: OwnerRelayFrame): Promise<Response | undefined>;
1812
2143
  abstract forwardWhisper(topic: string, frame: string): Promise<void>;
@@ -1817,19 +2148,22 @@ declare abstract class RelayLink {
1817
2148
  }>;
1818
2149
  abstract announce(): Promise<void>;
1819
2150
  abstract announceDrain(closing: ShardSocketLike): Promise<void>;
2151
+ abstract releaseRelayShapes(ws: ShardSocketLike, subId?: string): Promise<void>;
1820
2152
  abstract relayCount(): number;
1821
2153
  abstract isShapeRelayUniform(name: string, args: Record<string, unknown>): boolean;
2154
+ abstract minShapeCursor(): number | undefined;
1822
2155
  protected abstract onAttach(index: number): void;
1823
2156
  protected abstract onDetach(index: number): void;
1824
2157
  protected abstract onWhisperFrame(message: RelayFrame): Promise<void>;
1825
2158
  protected abstract onShapeSubscribe(message: RelayShapeSubscribe): RelayShapeSeed;
1826
- protected abstract onShapePoke(poke: RelayShapePoke): number;
2159
+ protected abstract onShapeUnsubscribe(message: RelayShapeUnsubscribe): void;
2160
+ protected abstract onShapePoke(poke: RelayShapePoke): RelayPokeDelivery;
1827
2161
  }
1828
2162
  declare class OwnerRelay extends RelayLink {
1829
2163
  private readonly shapeUniformCache;
1830
2164
  private relaySetCache;
1831
- private readonly relayShapeRegistry;
1832
- private readonly relayShapeProxies;
2165
+ private registryCache;
2166
+ private recordedBinding;
1833
2167
  private promotionState;
1834
2168
  constructor(host: RelayHost, ownerKey: string);
1835
2169
  forwardWhisper(topic: string, frame: string): Promise<void>;
@@ -1840,17 +2174,26 @@ declare class OwnerRelay extends RelayLink {
1840
2174
  }>;
1841
2175
  announce(): Promise<void>;
1842
2176
  announceDrain(): Promise<void>;
2177
+ releaseRelayShapes(): Promise<void>;
1843
2178
  relayCount(): number;
2179
+ minShapeCursor(): number | undefined;
1844
2180
  isShapeRelayUniform(name: string, args: Record<string, unknown>): boolean;
2181
+ protected onShapeUnsubscribe(message: RelayShapeUnsubscribe): void;
1845
2182
  protected onAttach(index: number): void;
1846
2183
  protected onDetach(index: number): void;
1847
2184
  protected onWhisperFrame(message: RelayFrame): Promise<void>;
1848
2185
  protected onShapeSubscribe(message: RelayShapeSubscribe): RelayShapeSeed;
1849
- protected onShapePoke(): number;
2186
+ protected onShapePoke(): RelayPokeDelivery;
2187
+ private buildShapePoke;
1850
2188
  private multicastShapePokes;
2189
+ private multicastToRelays;
1851
2190
  private proxyShapePokes;
2191
+ private proxyToRelay;
1852
2192
  private buildShapeSeedFrames;
1853
- private ensureRelayTable;
2193
+ private ensureRelayTables;
2194
+ protected bindingName(): string | undefined;
2195
+ private relayShapes;
2196
+ private rewindShapeCursor;
1854
2197
  private ownerRelaySet;
1855
2198
  private addRelayToSet;
1856
2199
  private removeRelayFromSet;
@@ -1859,7 +2202,8 @@ declare class OwnerRelay extends RelayLink {
1859
2202
  }
1860
2203
  declare class RelayMember extends RelayLink {
1861
2204
  private relayAnnounced;
1862
- private readonly shapeRelayMemos;
2205
+ private relayMemoCache;
2206
+ private readonly shapeControl;
1863
2207
  constructor(host: RelayHost, ownerKey: string, relayIndex: number);
1864
2208
  forwardWhisper(topic: string, frame: string): Promise<void>;
1865
2209
  onFlush(): Promise<void>;
@@ -1869,17 +2213,81 @@ declare class RelayMember extends RelayLink {
1869
2213
  }>;
1870
2214
  announce(): Promise<void>;
1871
2215
  announceDrain(closing: ShardSocketLike): Promise<void>;
2216
+ releaseRelayShapes(ws: ShardSocketLike, subId?: string): Promise<void>;
1872
2217
  relayCount(): number;
1873
2218
  isShapeRelayUniform(): boolean;
2219
+ minShapeCursor(): number | undefined;
1874
2220
  protected onAttach(): void;
1875
2221
  protected onDetach(): void;
1876
2222
  protected onWhisperFrame(): Promise<void>;
1877
2223
  protected onShapeSubscribe(): RelayShapeSeed;
1878
- protected onShapePoke(poke: RelayShapePoke): number;
2224
+ protected onShapeUnsubscribe(): void;
2225
+ protected onShapePoke(poke: RelayShapePoke): RelayPokeDelivery;
2226
+ private queueShapeControl;
2227
+ private relayMemos;
2228
+ private connectionMemos;
1879
2229
  private recordRelayShapeMemo;
2230
+ private forgetRelayShapeMemos;
1880
2231
  private deliverShapePoke;
2232
+ private pokeSocketShapes;
1881
2233
  }
1882
2234
  declare const createRelayLink: (host: RelayHost) => OwnerRelay | RelayMember | undefined;
2235
+ declare const REGION_HINTS: readonly ["wnam", "enam", "sam", "weur", "eeur", "apac", "apac-ne", "apac-se", "oc", "afr", "me"];
2236
+ type RegionHint = (typeof REGION_HINTS)[number];
2237
+ type ReplicaReadiness = "fresh" | "stale" | "unavailable";
2238
+ interface ShardSiblingHost {
2239
+ doName: () => string | undefined;
2240
+ env: () => unknown;
2241
+ shardBinding: () => string | undefined;
2242
+ shardJurisdiction: () => string | undefined;
2243
+ sql: () => SqlExec;
2244
+ }
2245
+ interface ReplicaOwnerHost extends ShardSiblingHost {
2246
+ exportRows: () => Promise<ExportRow[]>;
2247
+ ownerCursor: () => number | undefined;
2248
+ ownerEpoch: () => string | undefined;
2249
+ ownerFloor: () => number | undefined;
2250
+ readChanges: (sinceSeq: number, limit: number) => {
2251
+ changes: CdcChange[];
2252
+ cursor: number;
2253
+ };
2254
+ rowCount: () => number;
2255
+ }
2256
+ interface ReplicaFollowerHost extends ShardSiblingHost {
2257
+ applyChanges: (changes: ReadonlyArray<CdcChange>) => Promise<number>;
2258
+ importRows: (rows: ReadonlyArray<ExportRow>) => Promise<{
2259
+ errors: ReadonlyArray<unknown>;
2260
+ }>;
2261
+ }
2262
+ declare const handleReplicaControl: (host: ReplicaOwnerHost, request: Request) => Promise<Response>;
2263
+ declare class ShardReplica {
2264
+ private readonly host;
2265
+ readonly ownerKey: string;
2266
+ readonly region: RegionHint;
2267
+ private divergent;
2268
+ private inFlight;
2269
+ constructor(host: ReplicaFollowerHost, ownerKey: string, region: RegionHint);
2270
+ ensureFresh(minSeq?: number): Promise<ReplicaReadiness>;
2271
+ appliedSeq(): number;
2272
+ isDivergent(): boolean;
2273
+ private advance;
2274
+ private isCaughtUp;
2275
+ private catchUp;
2276
+ private applyPage;
2277
+ private hasDiverged;
2278
+ private bootstrap;
2279
+ private isFreshEnough;
2280
+ private pull;
2281
+ private request;
2282
+ }
2283
+ declare const createReplicaLink: (host: ReplicaFollowerHost) => ShardReplica | undefined;
2284
+ declare const gateReplicaDispatch: (replica: ShardReplica, request: Request, functionPath: string) => Promise<Response | undefined>;
2285
+ declare const REPROJECTION_MIGRATION_PREFIX = "__lunora_reproject__";
2286
+ declare const reprojectionMigrationId: (table: string) => string;
2287
+ declare const reprojectableFields: (definition: TableDefinitionLike) => string[];
2288
+ declare const reprojectionTables: (schema: SchemaLike) => string[];
2289
+ declare const countLegacyRows: (sql: SqlExec, table: string, fields: ReadonlyArray<string>) => number;
2290
+ declare const buildReprojectionMigration: (id: string, schema: SchemaLike, sql: SqlExec) => DataMigrationLike | undefined;
1883
2291
  declare const RLS_UNWRAP_SYMBOL: symbol;
1884
2292
  declare class RlsRequiredError extends LunoraError {
1885
2293
  readonly table: string;
@@ -1896,7 +2304,7 @@ interface GuardableSchema {
1896
2304
  }
1897
2305
  type TableOfId = (id: string, expectedTable?: string) => Promise<string | undefined> | string | undefined;
1898
2306
  type TablesOfIds = (ids: ReadonlyArray<string>, expectedTable?: string) => Promise<ReadonlyMap<string, string>> | ReadonlyMap<string, string>;
1899
- declare const guardWriter: <W>(raw: W, schema: GuardableSchema, tableOfId: TableOfId, tablesOfIds?: TablesOfIds) => W;
2307
+ declare const guardWriter: <W>(raw: W, schema: GuardableSchema, tableOfId: TableOfId, tablesOfIds?: TablesOfIds, relationEdges?: ReadonlyArray<RelationEdge>) => W;
1900
2308
  declare const SCHEMA_HISTORY_MAX_VERSIONS = 50;
1901
2309
  interface SchemaVersionRow {
1902
2310
  appliedAt: number;
@@ -1907,8 +2315,24 @@ interface SchemaVersionRow {
1907
2315
  declare const recordSchemaVersion: (sql: SqlExec, hash: string, snapshotJson: string, now?: number) => boolean;
1908
2316
  declare const readSchemaHistory: (sql: SqlExec) => SchemaVersionRow[];
1909
2317
  declare const readSchemaVersion: (sql: SqlExec, hash: string) => SchemaVersionRow | undefined;
2318
+ declare const readDeployInfo: (rawEnv: unknown) => DeployInfo;
1910
2319
  declare const isDevEnvironment: (rawEnv: unknown) => boolean;
1911
2320
  declare const buildSettings: (rawEnv: unknown) => SettingsResult;
2321
+ declare class ShapeDiffCache {
2322
+ private readonly keyScans;
2323
+ private readonly memberProbes;
2324
+ private run;
2325
+ private served;
2326
+ get probesRun(): number;
2327
+ get probesServed(): number;
2328
+ changedKeys(rangeKey: string, load: () => CdcChangeKey[]): ReadonlyArray<CdcChangeKey>;
2329
+ members(resolved: ResolvedShape, rangeKey: string, load: () => Map<string, Record<string, unknown>>): ReadonlyMap<string, Record<string, unknown>>;
2330
+ private getOrLoad;
2331
+ }
2332
+ declare const createShapeDiffCache: () => ShapeDiffCache;
2333
+ declare const globalShapeReadKey: (resolved: ResolvedShape, identity: SubscriptionIdentity) => string | undefined;
2334
+ type ReadShapeCdcKeys = (sql: SqlExec, table: string, sinceSeq: number, upTo: number) => CdcChangeKey[];
2335
+ declare const buildShapeDiff: (sql: SqlExec, resolved: ResolvedShape, sinceSeq: number, upTo: number, cache: ShapeDiffCache, readKeys?: ReadShapeCdcKeys) => ShapeRowOp[];
1912
2336
  interface ShardRunnerOptions {
1913
2337
  handlers?: {
1914
2338
  handleAlarm?: () => Promise<void>;
@@ -1950,6 +2374,11 @@ interface SqlDiagnostic {
1950
2374
  source: "gate" | "plan" | "syntax";
1951
2375
  }
1952
2376
  declare const lintReadonlySql: (sql: SqlExec, query: string) => SqlLintResult;
2377
+ declare const BIGINT_KEY_DIGITS = 39;
2378
+ declare const bigintSqlKey: (value: bigint) => string;
2379
+ declare const decodeBigintSqlKey: (raw: string) => bigint | undefined;
2380
+ declare const float64SqlKey: (value: number) => string;
2381
+ declare const decodeFloat64SqlKey: (raw: string) => number | undefined;
1953
2382
  declare const subscriptionListDeltas: (previousJson: string, nextResult: unknown, table: string, frames?: string[]) => MutationDelta[] | undefined;
1954
2383
  interface FrameSink {
1955
2384
  send: (data: string) => void;
@@ -1958,7 +2387,17 @@ interface DrainableSink {
1958
2387
  readonly bufferedAmount?: unknown;
1959
2388
  }
1960
2389
  declare const trySendFrame: (ws: FrameSink, frame: string) => boolean;
1961
- declare const sendDeltaFrames: (ws: FrameSink, subId: string, deltaFrames: ReadonlyArray<string>, cursorSuffix: string, lastMutationId?: number) => boolean;
2390
+ interface SubscriptionFrameInput {
2391
+ cursorSuffix: string;
2392
+ lastMutationId?: number;
2393
+ nextResult: unknown;
2394
+ pageDeltas?: boolean;
2395
+ previousJson?: string;
2396
+ snapshotJson: string;
2397
+ subId: string;
2398
+ table: string;
2399
+ }
2400
+ declare const subscriptionFrames: (input: SubscriptionFrameInput) => string[];
1962
2401
  declare const awaitWsDrain: (ws: DrainableSink) => Promise<void>;
1963
2402
  interface SubscriptionReadFootprint {
1964
2403
  ranges?: Map<string, KeyRange[]>;
@@ -1986,13 +2425,25 @@ declare const selectExpiredIds: (sql: SqlExec, spec: TtlSweepSpec, now: number,
1986
2425
  hasMore: boolean;
1987
2426
  ids: string[];
1988
2427
  };
1989
- type FieldRefSql = (field: string) => SQL;
1990
- type SerializeValue = (value: unknown) => unknown;
1991
- interface WhereSqlStrategy {
1992
- fieldRef: FieldRefSql;
1993
- likeContains?: (reference: SQL, term: SQL) => SQL;
1994
- relationExists?: (request: unknown) => SQL;
2428
+ interface WhereFragments<T> {
2429
+ binary: (reference: T, comparator: string, value: unknown) => T;
2430
+ connect: (left: T, right: T, connector: "AND" | "OR") => T;
2431
+ constant: (value: boolean) => T;
2432
+ contains: (reference: T, term: T) => T;
2433
+ inList: (reference: T, items: ReadonlyArray<unknown>, negated: boolean, budget: number) => T;
2434
+ negate: (inner: T) => T;
2435
+ nullCheck: (reference: T, negated: boolean) => T;
2436
+ value: (value: unknown) => T;
2437
+ }
2438
+ type FieldRefSql<T> = (field: string) => T;
2439
+ type SerializeValue = (value: unknown, field: string) => unknown;
2440
+ interface WhereSqlStrategy<T = SQL> {
2441
+ containsExpr?: (reference: T, term: T) => T;
2442
+ fieldRef: FieldRefSql<T>;
2443
+ inList?: (reference: T, items: ReadonlyArray<unknown>, negated: boolean, budget?: number) => T;
2444
+ relationExists?: (request: unknown) => T;
1995
2445
  serialize: SerializeValue;
1996
2446
  }
1997
- declare const compileWhereSql: (where: WhereInput | undefined, strategy: WhereSqlStrategy) => SQL | undefined;
1998
- export { ADMIN_FUNCTIONS, ADMIN_FUNCTION_PREFIX, AGGREGATE_SQL_FUNCTION, AGG_COUNT, AGG_KEY, AGG_VALUE, AUDIT_LOG_TABLE, type AdvisorProcedure, type AdvisorProceduresResult, type AdvisoriesResult, type AdvisoryFinding, type AggregateIndexDefinitionLike, type AggregateOp, type AggregateOptions, type AggregateResult, type AggregateTally, type AppendAuditEntry, type ApplyOnDeleteOptions$1 as ApplyOnDeleteOptions, type AuditEntry, type AuditLogResult, type BroadcastDelta, CDC_LOG_TABLE, CDC_META_TABLE, CLIENT_WATERMARK_TABLE, type CacheEntry, type CapturedMailRow, type CdcChange, type ChangedKeys, type Clock, type ColumnMeta, type ColumnMetaLike, type CompanionSync, type CompanionSyncDeps, ConflictError, type ConflictKind, type CountArgs, CountRlsUnsupportedError, type CreateWorkflowInstanceResult, type CtxDbOptions, DATA_MIGRATION_STATE_TABLE, DEFAULT_FANOUT_TOPIC_LIMIT, DEFAULT_MAX_RELATION_KEYS, DEFAULT_MAX_RELAYS, DEFAULT_PROMOTION_THRESHOLDS, DEFAULT_TRANSACTION_LIMITS, DOC_COLUMN, type DataMigrationDocument, type DataMigrationLike, type DataMigrationTransform, type DatabaseWriterLike, type DependencyTracker, type DeployInfo, type ExportRow, type ExportShardAdminArgs, type ExportShardArgs, type ExternalSourceDiffResult, type ExternalSourceLike, FLAGS_FUNCTION_PREFIX, type FacetColumnOptions, type FacetColumnResult, type FacetValue, type FanoutMetricsResult, type FanoutPathCounters, type FanoutTopicStat, type FieldOperators, type FilterClause, type FilterOperator, type FlagEvaluation, type FlagsResult, type FunctionCallStat, type FunctionScanAttribution, type FunctionStatsResult, GEO_DEFAULT_PRECISION, GLOBAL_SHAPE_SNAPSHOT_TABLE, type GeoBoundingBox, type GeoFilterBuilderLike, type GeoIndexDefinitionLike, type GeoPoint, type GeoScoredDocument, type GroupByEntry, type GroupByOptions, type GuardableSchema$1 as GuardableSchema, IDEMPOTENCY_TABLE, type IdGenerator, type IdempotentRecord, type ImportError, type ImportShardAdminArgs, type ImportShardArgs, type ImportShardResult, type IncrementalMaterializeResult, type IndexDefinitionLike, type IndexKeyEntry, type IndexRangeBuilderLike, type KeyRange, type LifecycleDispatchInfo, type LifecycleEvent, MAIL_RETENTION, MAIL_TABLE, MAX_PAGE_SIZE, MAX_SQL_ROWS, type MaskColumnMetadata, type MaskPoliciesResult, type MaterializeResult, type MigrationDirection, type MigrationRunResult, type MigrationStatus, type MigrationStatusRow, type MutationDelta, type NestedWith, NotFoundError, NotUniqueError, type OnDeleteActionLike, type OrderByClause, type OrderByInput, type OrderKey, OwnerRelay, type OwnerRelayFrame, type PaginationOptions, type PitrBookmarkResult, type PitrRestoreArgs, type PitrRestoreResult, type PitrStorage, type PokeFrameMeta, type PromotionState, type PromotionThresholds, QUEUE_TABLE, type QueryArgs, type QueryPage, type QueueMessageOutcome, type QueueMessageRow, type QueueMetadata, type QueuesResult, RANK_TIEBREAK, RELATION_EXISTS_KEY, RELATION_FUNCTION_PREFIX, RLS_UNWRAP_SYMBOL, type RankBeforeOptions, type RankBeforeResult, type RankDirection, type RankIndexDefinitionLike, type RankOptions, type RankPage, type RankPageComputation, type RankPageDeps, type RankPageOptions, type RankPageRow, type RankPageRowKey, type RankResult, type RankSortKeyLike, ReactiveCache, type ReactiveCacheOptions, type ReadFootprint, type ReadHook, type ReadTablePageOptions, type RecordMailInput, type RecordQueueMessageInput, type RelationDefinitionLike, type RelationExistsMarker, type RelayAttach, type RelayDetach, type RelayFrame, type RelayHost, RelayMember, type RelayShapePoke, type RelayShapeSeed, type RelayShapeSubscribe, type RenderedSql, type ResolveRelationPredicatesOptions, type ResolveWithOptions, type ResolveWithResult, type ResolvedShape, type RestrictableQueryOptions, type RlsPoliciesResult, type RlsPolicyMetadata, RlsRequiredError, type RlsRoleMetadata, type RpcRequest, type RunDataMigrationOptions, type RunTriggersOptions, SCAN_DEP, SCHEMA_HISTORY_MAX_VERSIONS, SEARCH_STATE_TABLE, type SchedulableWorkflowReferenceLike, type ScheduledFunctionDoc, type SchedulerLike, type SchemaLike, type ScoredDocument, type SearchFilterBuilderLike, type SearchIndexDefinitionLike, type SearchScoredDocument, type SelectMatchingIdsOptions, type ServerDefaultContextLike, type SettingEntry, type SettingKind, type SettingsResult, type ShapePokePart, type ShapeRow, type ShapeRowOp, type ShapeSubscriptionQuery, type ShardRankPageResult, ShardRunner, type ShardRunnerOptions, type ShardSocketLike, type SocketAttachment, type SortDirection, type SourceClientLike, type SourceCursorLike, type SourceRefresh, type SqlConsoleResult, type SqlCursor, type SqlEngine, type SqlExec, type SqlLintResult, type StorageMetadata, type StorageReference, type StorageReferenceResult, type StorageRuleMetadata, type StorageRulesResult, type StudioFeaturesResult, type SubscriptionConnection, type SubscriptionEnvelope, type SubscriptionIdentity, type SubscriptionInfo, type SubscriptionQuery, type SubscriptionReadFootprint, type SubscriptionsResult, type SystemDatabaseReader, type SystemDoc, type SystemQuery, type SystemReaderOptions, type SystemReaderSchedulerLike, type SystemReaderStorageLike, type SystemTableName, type TableColumnsResult, type TableDefinitionLike, type TableIndexInfo, type TableIndexesResult, type TableInfo, type TablePage, type TableReaderLike, type TablesColumnsResult, type TablesIndexesResult, type TransactionHeadroom, TransactionHeadroomTracker, type TransactionLimits, type TransactionSqlLike, type TriggerContextLike, type TriggerDefinitionLike, type TriggerEventLike, type TriggerOpLike, type TriggerTimingLike, type TtlSweepSpec, type ValidatorLike, type WhereInput, type WhereSqlStrategy, type WithInput, type WorkflowInstanceState, type WorkflowInstanceStatusResult, type WorkflowMetadata, type WorkflowsResult, type WriteEvent, type WriteHook, advanceClientWatermark, aggUpsertSql, aggregateSqlFunction, aggregateTableName, appendAuditEntry, appendCdcChange, applyCdcChanges, applyOnDelete, applySelect, armRestore, assertFlatPredicate, assertReadonly, assertShapeShardable, assertValidClientId, awaitWsDrain, backfillAggregateIndexes, backfillRankIndexes, backfillSearchIndexes, backfillSearchIndexesForTable, boundingBoxCenter, boundingBoxGeohashes, buildIndexRange, buildPokeFrames, buildSeekBeforeWhere, buildSeekWhere, buildSettings, bumpCdcEpoch, clampPromotionThresholds, clearCapturedMail, clearQueueMessages, coerceAggregateNumber, compileWhereSql, computeRankPage, containsRelationPredicate, coveringGeohashes, createCompanionSync, createDependencyTracker, createFanoutCounters, createIndexSql, createReadFootprint, createRelayLink, createShardCtxDb, createSystemReader, decodeCursor, deleteGlobalShapeSnapshot, deleteGlobalShapeSnapshotsForConnection, depKey, diffExternalSource, diffGlobalMembership, distinctValues, encodeAggregateKey, encodeCursor, encodeGeohash, encodePartitionKey, encodeRowsPatch, ensureAuditTable, ensureMailTable, exportShardRows, exportShardTable, facetColumn, fanOutScalarCounts, findStorageReferences, foldAggregateTally, geoTableName, guardWriter, hasTrigger, haversineMeters, hydrateDocsById, importShardRows, indexKeysForRow, isDevEnvironment, isFtsAvailable, isLossyBody, isRelationPredicate, isSoftDeleted, isSourceDue, jsonPath, jsonPathSql, keysTouchRanges, liftSourceId, lintReadonlySql, listTables, matchesRankStaticWhere, matchesStaticWhere, materializeExternalRows, materializeExternalRowsIncremental, mergeChangedKeys, mergeWhere, migrateCdcLog, migrateCdcMeta, migrateClientWatermark, migrateGlobalShapeSnapshot, migrateIdempotency, migrateSearchState, minCdcSeq, nextPromotionState, normalizeCountArgument, normalizeIdStructurally, normalizeOrderKeys, normalizeSourceDocument, normalizeSourceValue, param, parseExportShardArgs, parseImportShardArgs, planAggregateLookup, pointInBoundingBox, projectColumns, pullExternalSourceIncrementalTick, pullExternalSourceTick, qualifiedJsonPath, qualifiedJsonPathSql, quoteIdentifier, rankKeyFromDocument as rankKeyFromDoc, rankTableName, reactiveCacheKey, readAggregateValue, readAuditLog, readBookmark, readCapturedMail, readCdcChanges, readCdcCursor, readCdcEpoch, readClientWatermark, readExternalSourceBaseline, readGlobalShapeSnapshot, readIdempotent, readMigrationStatus, readQueueMessageById, readQueueMessages, readSchemaHistory, readSchemaVersion, readSearchBackfillState, readTablePage, recordCapturedMail, recordChangedKeys, recordFanoutPass, recordQueueMessages, recordSchemaVersion, relayCountFor, renderSql, resolveRankPartition, resolveRelationPredicates, resolveWith, rowToDocument, runDataMigration, runDrizzle, runExternalSourceTick, runReadonlySql, runRowValidators, runShardMigrations, runSocketPool, runSql, runTriggers, selectExpiredIds, selectExportTables, selectIndexForAggregate, selectIndexForCount, selectIndexForGroupBy, selectMatchingIds, selectShapeMemberIds, selectShapeRows, sendDeltaFrames, serializeSqlValue, shapeRoutingKey, softDeleteScope, sortColumnName, stableStringify, stableWireKey, subscriptionListDeltas, summarizeFanoutTopics, summarizeSubscriptions, tableColumns, tableFromDepKey, throwingScheduler, trimCdcChanges, trimIdempotent, tryRowToDocument, trySendFrame, validateImportRow, writeGlobalShapeSnapshot, writeIdempotent, writeSearchBackfillState, writeTouchesMemo };
2447
+ declare const literalInList: (reference: SQL, items: ReadonlyArray<unknown>, negated: boolean) => SQL;
2448
+ declare const compileWhereSql: <T = SQL>(where: WhereInput | undefined, strategy: WhereSqlStrategy<T>, fragments?: WhereFragments<T>) => T | undefined;
2449
+ export { ADMIN_FUNCTIONS, ADMIN_FUNCTION_PREFIX, AGGREGATE_SQL_FUNCTION, AGG_COUNT, AGG_KEY, AGG_VALUE, AUDIT_LOG_TABLE, type AdvisorProcedure, type AdvisorProceduresResult, type AdvisoriesResult, type AdvisoryFinding, type AggregateIndexDefinitionLike, type AggregateOp, type AggregateOptions, type AggregateResult, type AggregateTally, type AppendAuditEntry, type ApplyOnDeleteOptions$1 as ApplyOnDeleteOptions, type AuditEntry, type AuditLogResult, BIGINT_KEY_DIGITS, type BroadcastDelta, CDC_LOG_TABLE, CDC_LOG_TABLE_SEQ_INDEX, CDC_META_TABLE, CLIENT_WATERMARK_TABLE, COMMIT_SEQ_FIELD, COMMIT_SEQ_TABLE, CURSOR_PREFIX, type CacheEntry, type CapturedMailRow, type CdcArchiveScope, type CdcChange, type CdcChangeKey, type ChangedKeys, type Clock, type ColumnMeta, type ColumnMetaLike, type CompanionSync, type CompanionSyncDeps, ConflictError, type ConflictKind, type CountArgs, CountRlsUnsupportedError, type CreateWorkflowInstanceResult, type CrossShardReadArgs, type CtxDbOptions, DATA_MIGRATION_STATE_TABLE, DEFAULT_FANOUT_TOPIC_LIMIT, DEFAULT_MAX_RELATION_KEYS, DEFAULT_MAX_RELAYS, DEFAULT_PROMOTION_THRESHOLDS, DEFAULT_TRANSACTION_LIMITS, DOC_COLUMN, type DataMigrationDocument, type DataMigrationLike, type DataMigrationTransform, type DatabaseWriterLike, type DependencyTracker, type DeployInfo, type DurableAttachDecision, type DurableStreamAttach, type DurableStreamRun, DurableStreamRunner, type DurableStreamSink, type ExportRow, type ExportShardAdminArgs, type ExportShardArgs, type ExternalSourceDiffResult, type ExternalSourceLike, FLAGS_FUNCTION_PREFIX, type FacetColumnOptions, type FacetColumnResult, type FacetValue, type FanOutBudget, type FanoutMetricsResult, type FanoutPathCounters, type FanoutTopicStat, type FieldOperators, type FilterClause, type FilterOperator, type FlagEvaluation, type FlagsResult, type FunctionCallStat, type FunctionScanAttribution, type FunctionStatsResult, GEO_DEFAULT_PRECISION, GLOBAL_SHAPE_SNAPSHOT_TABLE, type GeoBoundingBox, type GeoFilterBuilderLike, type GeoIndexDefinitionLike, type GeoPoint, type GeoScoredDocument, type GlobalPollCounters, GlobalPollTick, type GroupByEntry, type GroupByOptions, type GuardableSchema$1 as GuardableSchema, IDEMPOTENCY_TABLE, type IdGenerator, type IdempotentRecord, type ImportError, type ImportShardAdminArgs, type ImportShardArgs, type ImportShardResult, type IncrementalMaterializeResult, type IndexDefinitionLike, type IndexKeyEntry, type IndexRangeBuilderLike, type KeyRange, type LifecycleDispatchInfo, type LifecycleEvent, MAIL_RETENTION, MAIL_TABLE, MAX_DURABLE_STREAM_BYTES, MAX_DURABLE_STREAM_CHUNKS, MAX_PAGE_SIZE, MAX_SQL_ROWS, type MaskColumnMetadata, type MaskPoliciesResult, type MaterializeResult, type MigrationDirection, type MigrationRunResult, type MigrationStatus, type MigrationStatusRow, type MutationDelta, type NestedWith, NotFoundError, NotUniqueError, type OnDeleteActionLike, type OrderByClause, type OrderByInput, type OrderKey, type OrderKeyConstraints, OwnerRelay, type OwnerRelayFrame, type PaginationOptions, type PitrBookmarkResult, type PitrRestoreArgs, type PitrRestoreResult, type PitrStorage, type PokeFrameMeta, type PromotionState, type PromotionThresholds, QUEUE_TABLE, type QueryArgs, type QueryPage, type QueueMessageOutcome, type QueueMessageRow, type QueueMetadata, type QueuesResult, RANK_TIEBREAK, REACTOR_STATE_TABLE, RELATED_DEFAULT_LIMIT, RELATED_DEPTH_DECAY, RELATED_MAX_DEPTH, RELATED_MAX_LIMIT, RELATION_EXISTS_KEY, RELATION_FUNCTION_PREFIX, REPROJECTION_MIGRATION_PREFIX, RLS_UNWRAP_SYMBOL, type RankBeforeOptions, type RankBeforeResult, type RankDirection, type RankIndexDefinitionLike, type RankOptions, type RankPage, type RankPageComputation, type RankPageDeps, type RankPageOptions, type RankPageRow, type RankPageRowKey, type RankResult, type RankSortKeyLike, ReactiveCache, type ReactiveCacheOptions, type ReactorDispatchResult, type ReactorMetadata, type ReactorState, type ReactorStats, type ReactorsResult, type ReadFootprint, type ReadHook, type ReadTablePageOptions, type RecordMailInput, type RecordQueueMessageInput, type RelatedDirection, type RelatedNode, type RelatedOptions, type RelatedPage, type RelatedStart, type RelatedStartReference, type RelationDefinitionLike, type RelationEdge, type RelationExistsMarker, type RelationGraphReader, type RelayAttach, type RelayDetach, type RelayFrame, type RelayHost, RelayMember, type RelayPokeDelivery, type RelayShapePoke, type RelayShapeSeed, type RelayShapeSubscribe, type RelayShapeUnsubscribe, type RenderedSql, type ReplicaFollowerHost, type ReplicaOwnerHost, type ReplicaReadiness, type ResolveRelationPredicatesOptions, type ResolveWithOptions, type ResolveWithResult, type ResolvedShape, type RestrictableQueryOptions, type RlsPoliciesResult, type RlsPolicyMetadata, RlsRequiredError, type RlsRoleMetadata, type RpcRequest, type RunDataMigrationOptions, type RunTriggersOptions, SCAN_DEP, SCHEDULE_OUTBOX_TABLE, SCHEMA_HISTORY_MAX_VERSIONS, SEARCH_STATE_TABLE, SHAPE_POKE_CURSOR_TABLE, type SchedulableWorkflowReferenceLike, type ScheduleOutbox, type ScheduleOutboxEnvelope, type ScheduleOutboxRow, type ScheduledFunctionDoc, type SchedulerLike, type SchemaLike, type ScoredDocument, type SearchBackfillProgress, type SearchFilterBuilderLike, type SearchIndexDefinitionLike, type SearchScoredDocument, type SelectMatchingIdsOptions, type ServerDefaultContextLike, type SettingEntry, type SettingKind, type SettingsResult, ShapeDiffCache, type ShapePokeCursorRow, type ShapePokePart, type ShapeProbeCounters, type ShapeRow, type ShapeRowOp, type ShapeSubscriptionQuery, type ShardRankPageResult, ShardRunner, type ShardRunnerOptions, type ShardSiblingHost, type ShardSocketLike, type SocketAttachment, type SortDirection, type SourceClientLike, type SourceCursorLike, type SourceRefresh, type SqlConsoleResult, type SqlCursor, type SqlEngine, type SqlExec, type SqlLintResult, type StorageMetadata, type StorageReference, type StorageReferenceResult, type StorageRuleMetadata, type StorageRulesResult, type StudioFeaturesResult, type SubscriptionConnection, type SubscriptionEnvelope, type SubscriptionIdentity, type SubscriptionInfo, type SubscriptionQuery, type SubscriptionReadFootprint, type SubscriptionsResult, type SystemDatabaseReader, type SystemDoc, type SystemQuery, type SystemReaderOptions, type SystemReaderSchedulerLike, type SystemReaderStorageLike, type SystemTableName, type TableColumnsResult, type TableDefinitionLike, type TableIndexInfo, type TableIndexesResult, type TableInfo, type TablePage, type TableReaderLike, type TablesColumnsResult, type TablesIndexesResult, type TransactionHeadroom, TransactionHeadroomTracker, type TransactionLimits, type TransactionSqlLike, type TriggerContextLike, type TriggerDefinitionLike, type TriggerEventLike, type TriggerOpLike, type TriggerTimingLike, type TtlSweepSpec, UNVOUCHABLE_DEP, type ValidatorLike, type WhereInput, type WhereSqlStrategy, type WithInput, type WorkflowInstanceState, type WorkflowInstanceStatusResult, type WorkflowMetadata, type WorkflowsResult, type WriteEvent, type WriteHook, advanceClientWatermark, aggUpsertSql, aggregateSqlFunction, aggregateTableName, allocateCommitSeq, appendAuditEntry, appendCdcChange, appendStreamChunk, applyCdcChanges, applyOnDelete, applySelect, archiveCdcSegment, armRestore, assertFlatPredicate, assertNoExplicitUndefined, assertReadonly, assertShapeShardable, assertValidClientId, awaitWsDrain, backfillAggregateIndexes, backfillRankIndexes, backfillSearchIndexes, backfillSearchIndexesForTable, bigintSqlKey, boundingBoxCenter, boundingBoxGeohashes, buildIndexRange, buildPokeFrames, buildReprojectionMigration, buildSeekBeforeWhere, buildSeekWhere, buildSettings, buildShapeDiff, bumpCdcEpoch, cdcCanVouchFor, cdcSeqLeavingRows, cdcTouchesTables, cdcTrimmedError, claimStreamRun, clampPromotionThresholds, clearCapturedMail, clearMemoryTables, clearQueueMessages, coerceAggregateNumber, compactCdcDocs, compileWhereSql, computeRankPage, containsRelationPredicate, countLegacyRows, coveringGeohashes, createCompanionSync, createDependencyTracker, createFanoutCounters, createGlobalPollCounters, createIndexSql, createReadFootprint, createRelayLink, createReplicaLink, createShapeDiffCache, createShapeProbeCounters, createShardCtxDb, createSystemReader, cursorBelowRetainedFloor, decideDurableAttach, decodeBigintSqlKey, decodeCursor, decodeFloat64SqlKey, deferScheduleOutbox, deleteGlobalShapeSnapshot, deleteGlobalShapeSnapshotsForConnection, deleteShapePokeCursor, deleteShapePokeCursorsForConnection, deleteStreamRun, depKey, deriveRelationEdges, diffExternalSource, diffGlobalMembership, distinctValues, encodeAggregateKey, encodeCursor, encodeGeohash, encodePartitionKey, encodeRowsPatch, ensureAuditTable, ensureMailTable, envOptionalPositiveInt, envPositiveInt, equalityPinnedFields, exportShardRows, facetColumn, fanOutScalarCounts, findRelated, findStorageReferences, finishStreamRun, float64SqlKey, foldAggregateTally, forgetScheduleOutbox, gateReplicaDispatch, geoTableName, globalShapeReadKey, guardWriter, handleReplicaControl, hasTrigger, haversineMeters, importShardRows, indexKeysForRow, isDevEnvironment, isFtsAvailable, isLossyBody, isMemoryTable, isRelationPredicate, isSoftDeleted, isSourceDue, jsonPath, jsonPathSql, keysTouchRanges, liftSourceId, lintReadonlySql, listReactorStates, listTables, literalInList, markUnvouchableReads, matchesRankStaticWhere, matchesStaticWhere, materializeExternalRows, materializeExternalRowsIncremental, memoryTableNames, mergeChangedKeys, mergeWhere, migrateCdcLog, migrateCdcMeta, migrateClientWatermark, migrateCommitSeq, migrateDurableStreams, migrateGlobalShapeSnapshot, migrateIdempotency, migrateReactorState, migrateScheduleOutbox, migrateSearchState, migrateShapePokeCursor, minCdcReplayableSeq, minCdcSeq, minShapePokeCursor, nextPromotionState, normalizeCountArgument, normalizeIdStructurally, normalizeOrderKeys, normalizeSourceDocument, normalizeSourceValue, param, parkScheduleOutbox, parseExportShardArgs, parseImportShardArgs, planAggregateLookup, pointInBoundingBox, probeScheduleOutbox, projectColumns, pullExternalSourceIncrementalTick, pullExternalSourceTick, qualifiedJsonPath, qualifiedJsonPathSql, quoteIdentifier, rankKeyFromDocument as rankKeyFromDoc, rankPivotConditionSql, rankTableName, reactiveCacheKey, reactorNeedsRun, readAggregateValue, readArchivedCdcChanges, readAuditLog, readBookmark, readCapturedMail, readCdcArchivedThrough, readCdcChangeKeys, readCdcChanges, readCdcCursor, readCdcEpoch, readClientWatermark, readCommitSeq, readDeployInfo, readDueScheduleOutbox, readExternalSourceBaseline, readGlobalShapeSnapshot, readIdempotent, readMigrationStatus, readQueueMessageById, readQueueMessages, readReactorState, readSchemaHistory, readSchemaVersion, readSearchBackfillState, readShapePokeCursor, readStreamChunks, readStreamRun, readTablePage, recordCapturedMail, recordChangedKeys, recordFanoutPass, recordGlobalPollPass, recordQueueMessages, recordScheduleOutbox, recordSchemaVersion, recordShapeProbePass, relationHooks, relayCountFor, renderSql, reprojectableFields, reprojectionMigrationId, reprojectionTables, resolveRankPartition, resolveRankSeekTuple, resolveRelationPredicates, resolveWith, rowToDocument, runDataMigration, runDrizzle, runExternalSourceTick, runReadonlySql, runRowValidators, runShardMigrations, runSocketPool, runSql, runTriggers, selectExpiredIds, selectExportTables, selectIndexForAggregate, selectIndexForCount, selectIndexForGroupBy, selectMatchingIds, selectShapeMembers, selectShapeRows, serializeSqlValue, shapeRoutingKey, softDeleteScope, sortColumnName, sqliteInList, stableStringify, stableWireKey, stripReservedPatchFields, subscriptionFrames, subscriptionListDeltas, summarizeFanoutTopics, summarizeSubscriptions, tableColumns, tableFromDepKey, throwingScheduler, tiebreakDirectionFor, trimCdcChanges, trimIdempotent, trimScheduleOutbox, trimStreamRuns, tryRowToDocument, trySendFrame, unionAll, uniqueIndexFields, validateImportRow, writeCdcArchivedThrough, writeGlobalShapeSnapshot, writeIdempotent, writeReactorState, writeSearchBackfillState, writeShapePokeCursor, writeShapePokeCursors, writeTouchesMemo };