@lunora/shard-engine 1.0.0-alpha.1 → 1.0.0-alpha.100

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 +771 -158
  4. package/dist/index.d.ts +771 -158
  5. package/dist/index.mjs +1 -1
  6. package/dist/packem_shared/ADMIN_FUNCTIONS-D5mzmLFo.mjs +1 -0
  7. package/dist/packem_shared/AGGREGATE_SQL_FUNCTION-DDEoMnJR.mjs +1 -0
  8. package/dist/packem_shared/AGG_COUNT-DNnEXtyM.mjs +1 -0
  9. package/dist/packem_shared/AUDIT_LOG_TABLE-CZNxCRLv.mjs +8 -0
  10. package/dist/packem_shared/BIGINT_KEY_DIGITS-C9a7Ix7k.mjs +1 -0
  11. package/dist/packem_shared/CDC_LOG_TABLE-QaBxSIZM.mjs +18 -0
  12. package/dist/packem_shared/CLIENT_WATERMARK_TABLE-vLjfNhBR.mjs +7 -0
  13. package/dist/packem_shared/COMMIT_SEQ_FIELD-BY_vc9bw.mjs +4 -0
  14. package/dist/packem_shared/CURSOR_PREFIX-BX8jkMJa.mjs +1 -0
  15. package/dist/packem_shared/CountRlsUnsupportedError-BvsDqfO2.mjs +1 -0
  16. package/dist/packem_shared/DATA_MIGRATION_STATE_TABLE-BMbxLEaN.mjs +31 -0
  17. package/dist/packem_shared/DEFAULT_MAX_RELATION_KEYS-CYPZfQH9.mjs +1 -0
  18. package/dist/packem_shared/DEFAULT_MAX_RELAYS-hdowkC2x.mjs +8 -0
  19. package/dist/packem_shared/DEFAULT_PROMOTION_THRESHOLDS-91RH_llq.mjs +1 -0
  20. package/dist/packem_shared/DEFAULT_TRANSACTION_LIMITS-DiR5z5EX.mjs +1 -0
  21. package/dist/packem_shared/DurableStreamRunner-Dk9Pn-B8.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-pMxZ-obU.mjs +7 -0
  24. package/dist/packem_shared/GlobalPollTick-BNK4o-XT.mjs +1 -0
  25. package/dist/packem_shared/IDEMPOTENCY_TABLE-AOJCuq5U.mjs +7 -0
  26. package/dist/packem_shared/MAIL_RETENTION-BxAGL3hK.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-D4EV8EzO.mjs +1 -0
  30. package/dist/packem_shared/QUEUE_TABLE-DKANxmEZ.mjs +17 -0
  31. package/dist/packem_shared/RANK_TIEBREAK-B0_x8iev.mjs +1 -0
  32. package/dist/packem_shared/REACTOR_STATE_TABLE-B8IehLv8.mjs +28 -0
  33. package/dist/packem_shared/RELATED_DEFAULT_LIMIT-CBYQQIrZ.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-rSxYzw-G.mjs +1 -0
  37. package/dist/packem_shared/ReactiveCache-D8ccaO6f.mjs +1 -0
  38. package/dist/packem_shared/SCAN_DEP-D7qE3iUe.mjs +1 -0
  39. package/dist/packem_shared/SCHEDULE_OUTBOX_TABLE-CgLvGxpY.mjs +11 -0
  40. package/dist/packem_shared/SCHEMA_HISTORY_MAX_VERSIONS-BMcUIqBY.mjs +6 -0
  41. package/dist/packem_shared/SEARCH_STATE_TABLE-wgl-SePe.mjs +1 -0
  42. package/dist/packem_shared/SHAPE_POKE_CURSOR_TABLE-cn0stGAL.mjs +8 -0
  43. package/dist/packem_shared/ShapeDiffCache-gdaILV5E.mjs +1 -0
  44. package/dist/packem_shared/ShardRunner-CrveaPId.mjs +1 -0
  45. package/dist/packem_shared/UNVOUCHABLE_DEP-C68htACn.mjs +1 -0
  46. package/dist/packem_shared/VECTOR_BACKFILL_MAX_PAGES-B2ZWxshy.mjs +1 -0
  47. package/dist/packem_shared/WORKERD_SQLITE_LIMITS-DBH23L_S.mjs +1 -0
  48. package/dist/packem_shared/aggregateTableName-C7o-gpms.mjs +1 -0
  49. package/dist/packem_shared/appendStreamChunk-7ZyAZGg_.mjs +17 -0
  50. package/dist/packem_shared/applyOnDelete-DJsOG8tz.mjs +1 -0
  51. package/dist/packem_shared/archiveCdcSegment-BON69Nug.mjs +4 -0
  52. package/dist/packem_shared/{armRestore-BNzdvQ_o.mjs → armRestore-Bu1_8SUa.mjs} +1 -1
  53. package/dist/packem_shared/awaitWsDrain-apizgmKY.mjs +1 -0
  54. package/dist/packem_shared/backfillAggregateIndexes-B_3xdOgV.mjs +1 -0
  55. package/dist/packem_shared/base64-DfpzS4o_.mjs +1 -0
  56. package/dist/packem_shared/buildIndexRange-6nIZDf4m.mjs +1 -0
  57. package/dist/packem_shared/buildPokeFrames-BBE6J91z.mjs +1 -0
  58. package/dist/packem_shared/buildReprojectionMigration-IMrfRdvU.mjs +1 -0
  59. package/dist/packem_shared/buildSettings-BRkZd6_E.mjs +1 -0
  60. package/dist/packem_shared/buildShapeDiff-D-J_GmC1.mjs +1 -0
  61. package/dist/packem_shared/clearMemoryTables-CogAvVHR.mjs +1 -0
  62. package/dist/packem_shared/compileWhereSql-DLfUbHc-.mjs +1 -0
  63. package/dist/packem_shared/computeRankPage-3AiKfT8q.mjs +1 -0
  64. package/dist/packem_shared/createCompanionSync-Rjn0lsT6.mjs +1 -0
  65. package/dist/packem_shared/createReplicaLink-Z82FMxvY.mjs +7 -0
  66. package/dist/packem_shared/createSystemReader-DcDLFfC-.mjs +1 -0
  67. package/dist/packem_shared/ctx-db-relay-shapes-DuqhDLw8.mjs +17 -0
  68. package/dist/packem_shared/ctx-db-search-state-DVCp4JQf.mjs +1 -0
  69. package/dist/packem_shared/defineEngineContractSuite-BkVGn8QW.mjs +1 -0
  70. package/dist/packem_shared/diffExternalSource-DgDJhslq.mjs +1 -0
  71. package/dist/packem_shared/do-sql-BEFrJUds.mjs +1 -0
  72. package/dist/packem_shared/effective-kind-BmG_zCAy.mjs +1 -0
  73. package/dist/packem_shared/envOptionalPositiveInt-D2pY-c64.mjs +1 -0
  74. package/dist/packem_shared/estimate-bytes-CTuiPWMD.mjs +1 -0
  75. package/dist/packem_shared/exportShardRows-CTDgQEF8.mjs +1 -0
  76. package/dist/packem_shared/fts-companion-pUdD6kF-.mjs +1 -0
  77. package/dist/packem_shared/ftsCompanionDdl-Co6WSyCB.mjs +1 -0
  78. package/dist/packem_shared/hasTrigger-CjlwI4le.mjs +1 -0
  79. package/dist/packem_shared/isInternalTableName-BoljO2tP.mjs +1 -0
  80. package/dist/packem_shared/isPushableWhere-BeYAOjUb.mjs +1 -0
  81. package/dist/packem_shared/isSoftDeleted-sGRSPPQq.mjs +9 -0
  82. package/dist/packem_shared/liftSourceId-CA3ENhXj.mjs +1 -0
  83. package/dist/packem_shared/materializeExternalRows-DhINQHwd.mjs +1 -0
  84. package/dist/packem_shared/mergeChangedKeys-DH9RAARR.mjs +1 -0
  85. package/dist/packem_shared/quoteIdentifier-CObIFRhb.mjs +1 -0
  86. package/dist/packem_shared/relation-operators-BEg-CvCH.mjs +1 -0
  87. package/dist/packem_shared/runDrizzle-Du5HLitO.mjs +1 -0
  88. package/dist/packem_shared/runShardMigrations-MXioI81k.mjs +5 -0
  89. package/dist/packem_shared/runSocketPool-CZJ2X9cF.mjs +1 -0
  90. package/dist/packem_shared/selectExpiredIds-DQg6v5Uf.mjs +1 -0
  91. package/dist/packem_shared/selectShapeMembers-BXhvEt4X.mjs +1 -0
  92. package/dist/packem_shared/serializeSqlValue-BbZ5hKM7.mjs +1 -0
  93. package/dist/packem_shared/sibling-channel-BkL5cTCc.mjs +1 -0
  94. package/dist/packem_shared/stableStringify-DibjylKD.mjs +1 -0
  95. package/dist/packem_shared/stableWireKey-D2US4k_J.mjs +1 -0
  96. package/dist/packem_shared/where-sql-DFs8Zw7-.mjs +1 -0
  97. package/dist/packem_shared/wire-codec-C-FpWm52.mjs +1 -0
  98. package/package.json +3 -3
  99. package/dist/packem_shared/ADMIN_FUNCTIONS-B0xlQJ4w.mjs +0 -1
  100. package/dist/packem_shared/AGGREGATE_SQL_FUNCTION-QYaiuty4.mjs +0 -1
  101. package/dist/packem_shared/AGG_COUNT-BWXe3gtQ.mjs +0 -1
  102. package/dist/packem_shared/AUDIT_LOG_TABLE-CaA0jL0L.mjs +0 -8
  103. package/dist/packem_shared/CDC_LOG_TABLE-BnqlH2eZ.mjs +0 -8
  104. package/dist/packem_shared/CLIENT_WATERMARK_TABLE-CXsSLU8D.mjs +0 -7
  105. package/dist/packem_shared/CountRlsUnsupportedError-B2WKJD9v.mjs +0 -1
  106. package/dist/packem_shared/DATA_MIGRATION_STATE_TABLE-CaO6L0Ee.mjs +0 -31
  107. package/dist/packem_shared/DEFAULT_MAX_RELATION_KEYS-bq00btqV.mjs +0 -1
  108. package/dist/packem_shared/DEFAULT_MAX_RELAYS-CnCyh6oX.mjs +0 -1
  109. package/dist/packem_shared/DEFAULT_PROMOTION_THRESHOLDS-Dteg0sZF.mjs +0 -1
  110. package/dist/packem_shared/FTS_COUNT_COLUMN-D1gY3wwZ-CZHdaRrd.mjs +0 -1
  111. package/dist/packem_shared/GEO_DEFAULT_PRECISION-okRCkZ6r.mjs +0 -1
  112. package/dist/packem_shared/GLOBAL_SHAPE_SNAPSHOT_TABLE-DX-6-gBP.mjs +0 -7
  113. package/dist/packem_shared/IDEMPOTENCY_TABLE-DjkEMp6w.mjs +0 -7
  114. package/dist/packem_shared/MAIL_RETENTION-KmozO2NQ.mjs +0 -18
  115. package/dist/packem_shared/MAX_SQL_ROWS-nMwkxv5f.mjs +0 -2
  116. package/dist/packem_shared/NotUniqueError-B4piAtjk.mjs +0 -1
  117. package/dist/packem_shared/QUEUE_TABLE-DYCDvzTG.mjs +0 -17
  118. package/dist/packem_shared/RANK_TIEBREAK-9NU5s_mi.mjs +0 -1
  119. package/dist/packem_shared/RELATION_EXISTS_KEY-BaqSIFU1.mjs +0 -1
  120. package/dist/packem_shared/RLS_UNWRAP_SYMBOL-C6_WX3dG.mjs +0 -1
  121. package/dist/packem_shared/ReactiveCache-1_9Rs7J_.mjs +0 -1
  122. package/dist/packem_shared/SCAN_DEP-D_yR9EeV.mjs +0 -1
  123. package/dist/packem_shared/SCHEMA_HISTORY_MAX_VERSIONS-CHXz6p_z.mjs +0 -6
  124. package/dist/packem_shared/SEARCH_STATE_TABLE-eLN8U5tz.mjs +0 -1
  125. package/dist/packem_shared/ShardRunner-DIqVdWtk.mjs +0 -1
  126. package/dist/packem_shared/aggregateTableName-G-eXyjcz.mjs +0 -1
  127. package/dist/packem_shared/applyOnDelete-uFRC5p1d.mjs +0 -1
  128. package/dist/packem_shared/applySelect-B0CF8T7y.mjs +0 -1
  129. package/dist/packem_shared/awaitWsDrain-Dk50ISgE.mjs +0 -1
  130. package/dist/packem_shared/backfillAggregateIndexes-BHiewuB-.mjs +0 -1
  131. package/dist/packem_shared/buildPokeFrames-DaPpm5Ss.mjs +0 -1
  132. package/dist/packem_shared/buildSettings-DT18_DkX.mjs +0 -1
  133. package/dist/packem_shared/compileWhereSql-BLcfs4QW.mjs +0 -1
  134. package/dist/packem_shared/computeRankPage-IUSS-zIB.mjs +0 -1
  135. package/dist/packem_shared/createCompanionSync-BCBUOnMk.mjs +0 -1
  136. package/dist/packem_shared/createSystemReader-DcDcrtM3.mjs +0 -1
  137. package/dist/packem_shared/defineEngineContractSuite-CVwNQvzx.mjs +0 -1
  138. package/dist/packem_shared/diffExternalSource-DMpkJta1.mjs +0 -1
  139. package/dist/packem_shared/exportShardRows-kt42wijd.mjs +0 -1
  140. package/dist/packem_shared/hasTrigger-CbkOHExZ.mjs +0 -1
  141. package/dist/packem_shared/isSoftDeleted-B-SXkGUo.mjs +0 -9
  142. package/dist/packem_shared/liftSourceId-DApAbu7Q.mjs +0 -1
  143. package/dist/packem_shared/materializeExternalRows-DOQJV9p2.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.ts CHANGED
@@ -1,15 +1,38 @@
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
+ interface KeyRange {
5
+ hi: string;
6
+ index: string;
7
+ lo: string;
8
+ table: string;
9
+ }
10
+ interface IndexKeyEntry {
11
+ index: string;
12
+ key: string;
13
+ }
14
+ interface StagedCondition {
15
+ comparator: string;
16
+ field: string;
17
+ value: unknown;
18
+ }
19
+ declare const buildIndexRange: (table: string, index: string, fields: ReadonlyArray<string>, conditions: ReadonlyArray<StagedCondition>, serialize: (value: unknown) => unknown) => KeyRange | undefined;
20
+ declare const indexKeysForRow: (indexes: ReadonlyArray<{
21
+ fields: ReadonlyArray<string>;
22
+ name: string;
23
+ }>, row: Record<string, unknown>, serialize: (value: unknown) => unknown) => IndexKeyEntry[];
24
+ declare const keysTouchRanges: (ranges: ReadonlyArray<KeyRange> | undefined, keys: ReadonlyArray<IndexKeyEntry> | undefined) => boolean;
4
25
  type SystemTableName = "_scheduled_functions" | "_storage";
5
26
  interface ScheduledFunctionDoc {
6
27
  args: Record<string, unknown>;
7
28
  attempts?: number;
8
29
  enqueuedAt: number;
9
- functionPath: string;
30
+ functionPath?: string;
10
31
  id: string;
32
+ pool?: string;
11
33
  scheduledFor: number;
12
34
  shardKey?: string;
35
+ workflow?: string;
13
36
  }
14
37
  interface StorageMetadata {
15
38
  contentType?: string;
@@ -65,6 +88,75 @@ interface WhereInput {
65
88
  OR?: WhereInput[];
66
89
  }
67
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
+ }
68
160
  type AggregateOp = "avg" | "count" | "max" | "min" | "sum";
69
161
  interface AggregateIndexDefinitionLike {
70
162
  readonly by?: ReadonlyArray<string>;
@@ -116,6 +208,10 @@ interface ColumnMetaLike {
116
208
  interface ValidatorLike {
117
209
  readonly _meta?: {
118
210
  readonly column?: ColumnMetaLike;
211
+ readonly inner?: ValidatorLike;
212
+ readonly members?: ReadonlyArray<ValidatorLike>;
213
+ readonly tableName?: string;
214
+ readonly value?: unknown;
119
215
  };
120
216
  readonly kind?: string;
121
217
  readonly parse?: (value: unknown) => unknown;
@@ -159,9 +255,12 @@ interface SchemaLike {
159
255
  }
160
256
  interface TableDefinitionLike {
161
257
  readonly aggregateIndexes?: ReadonlyArray<AggregateIndexDefinitionLike>;
258
+ readonly commitOrderedMode?: boolean;
259
+ readonly dropStalePatchesMode?: boolean;
162
260
  readonly geoIndexes?: ReadonlyArray<GeoIndexDefinitionLike>;
163
261
  readonly indexes: ReadonlyArray<IndexDefinitionLike>;
164
262
  readonly isPublic?: boolean;
263
+ readonly memoryMode?: boolean;
165
264
  readonly rankIndexes?: ReadonlyArray<RankIndexDefinitionLike>;
166
265
  readonly relationMap?: Record<string, RelationDefinitionLike>;
167
266
  readonly searchIndexes?: ReadonlyArray<SearchIndexDefinitionLike>;
@@ -198,17 +297,16 @@ interface WithInput {
198
297
  [relationName: string]: NestedWith | Record<string, true> | boolean | undefined;
199
298
  _count?: Record<string, true>;
200
299
  }
201
- interface ApplyOnDeleteOptions$1 {
202
- database: DatabaseWriterLike;
203
- relation: RelationDefinitionLike;
204
- row: Record<string, unknown>;
205
- tableName: string;
300
+ interface FanOutBudget {
301
+ remaining: number;
206
302
  }
207
303
  interface ResolveWithOptions {
304
+ fanOutBudget?: FanOutBudget;
208
305
  fetcher: (tableName: string, args: QueryArgs) => Promise<QueryPage>;
209
306
  groupedCounter: (tableName: string, whereField: string, values: unknown[], policyWhere?: WhereInput) => Promise<Map<unknown, number>>;
210
307
  parents: Record<string, unknown>[];
211
308
  relationBaseWhere?: (table: string) => undefined | WhereInput;
309
+ relationMask?: RelationMask;
212
310
  schema: {
213
311
  readonly tables: Record<string, TableDefinitionLike>;
214
312
  };
@@ -227,22 +325,69 @@ interface QueryArgs {
227
325
  cursor?: null | string;
228
326
  includeDeleted?: boolean;
229
327
  limit?: number;
328
+ omitContinueCursor?: boolean;
230
329
  orderBy?: OrderByInput[];
231
330
  relationBaseWhere?: (table: string) => undefined | WhereInput;
331
+ relationMask?: RelationMask;
232
332
  restrictsCounts?: boolean;
233
333
  select?: ReadonlyArray<string>;
234
334
  where?: WhereInput;
235
335
  with?: WithInput;
236
336
  }
337
+ interface CrossShardReadArgs {
338
+ orderBy?: OrderByInput[];
339
+ relationPolicies?: Record<string, WhereInput>;
340
+ where?: WhereInput;
341
+ with?: WithInput;
342
+ }
343
+ type RelationMask = (table: string, rows: Record<string, unknown>[]) => Record<string, unknown>[];
237
344
  interface QueryPage {
238
345
  continueCursor: null | string;
239
346
  isDone: boolean;
240
347
  page: Record<string, unknown>[];
241
348
  splitCursor?: null | string;
242
349
  }
350
+ interface RelationEdge {
351
+ readonly array: boolean;
352
+ readonly column: string;
353
+ readonly name: string;
354
+ readonly sourceTable: string;
355
+ readonly targetTable: string;
356
+ }
357
+ interface RelatedStartReference {
358
+ id: string;
359
+ table: string;
360
+ }
361
+ type RelatedStart = (Record<string, unknown> & {
362
+ _id: string;
363
+ }) | RelatedStartReference;
364
+ type RelatedDirection = "both" | "in" | "out";
365
+ interface RelatedOptions {
366
+ cursor?: null | string;
367
+ depth?: number;
368
+ direction?: RelatedDirection;
369
+ edges?: ReadonlyArray<string>;
370
+ limit?: number;
371
+ relationBaseWhere?: (table: string) => undefined | WhereInput;
372
+ relationMask?: RelationMask;
373
+ }
374
+ interface RelatedNode {
375
+ depth: number;
376
+ document: Record<string, unknown>;
377
+ path: ReadonlyArray<string>;
378
+ pathIds: ReadonlyArray<string>;
379
+ score: number;
380
+ table: string;
381
+ }
382
+ interface RelatedPage {
383
+ continueCursor: null | string;
384
+ isDone: boolean;
385
+ nodes: RelatedNode[];
386
+ }
243
387
  interface OrderKey {
244
388
  direction: SortDirection;
245
389
  field: string;
390
+ nullable: boolean;
246
391
  }
247
392
  interface RestrictableQueryOptions {
248
393
  baseWhere?: WhereInput;
@@ -338,8 +483,21 @@ interface GeoFilterBuilderLike {
338
483
  };
339
484
  }) => GeoFilterBuilderLike;
340
485
  }
486
+ type ScoredDocument = GeoScoredDocument | SearchScoredDocument;
487
+ interface GeoScoredDocument {
488
+ distanceMeters: null | number;
489
+ document: Record<string, unknown>;
490
+ score?: never;
491
+ }
492
+ interface SearchScoredDocument {
493
+ distanceMeters?: never;
494
+ document: Record<string, unknown>;
495
+ score: number;
496
+ }
341
497
  interface TableReaderLike {
498
+ [Symbol.asyncIterator]: () => AsyncIterator<Record<string, unknown>>;
342
499
  collect: () => Promise<Record<string, unknown>[]>;
500
+ collectWithScores: () => Promise<ScoredDocument[]>;
343
501
  filter: (predicate: (document: Record<string, unknown>) => boolean) => TableReaderLike;
344
502
  first: () => Promise<Record<string, unknown> | null>;
345
503
  order: (direction: "asc" | "desc") => TableReaderLike;
@@ -365,12 +523,11 @@ interface LifecycleEvent {
365
523
  shardKey: string;
366
524
  userId: string | null;
367
525
  }
368
- interface LifecycleDispatchInfo {
526
+ interface LifecycleDispatchInfo extends SubscriptionIdentity {
369
527
  event: LifecycleEvent;
370
- identity: Record<string, unknown> | undefined;
371
- userId: string | undefined;
372
528
  }
373
529
  interface MutationDelta {
530
+ indexKeys?: ReadonlyArray<IndexKeyEntry>;
374
531
  key: string;
375
532
  op: "insert" | "update" | "delete";
376
533
  row?: Record<string, unknown>;
@@ -379,6 +536,13 @@ interface MutationDelta {
379
536
  interface DatabaseWriterLike {
380
537
  aggregate: (tableName: string, options: AggregateOptions) => Promise<AggregateResult>;
381
538
  asId?: (tableName: string, id: string) => string;
539
+ cdcChangedTables?: (sinceSeq: number, options?: {
540
+ cursorOnly?: boolean;
541
+ }) => Promise<{
542
+ cursor: number;
543
+ floor?: number;
544
+ tables: string[];
545
+ } | undefined>;
382
546
  count: (tableName: string, where?: RestrictableQueryOptions | WhereInput) => Promise<number>;
383
547
  delete: (id: string, expectedTable?: string, options?: {
384
548
  hard?: boolean;
@@ -443,6 +607,8 @@ interface DatabaseWriterLike {
443
607
  rankBefore?: (tableName: string, indexName: string, options: RankBeforeOptions) => Promise<RankBeforeResult>;
444
608
  rankPage: (tableName: string, indexName: string, options?: RankPageOptions) => Promise<RankPage>;
445
609
  rankPageRows?: (tableName: string, indexName: string, options?: RankPageOptions) => Promise<ShardRankPageResult>;
610
+ related?: (start: RelatedStart, options?: RelatedOptions) => Promise<RelatedPage>;
611
+ relationEdges?: ReadonlyArray<RelationEdge>;
446
612
  replace: (id: string, document: Record<string, unknown>, expectedTable?: string, options?: {
447
613
  allowExplicitId?: boolean;
448
614
  }) => Promise<void>;
@@ -481,7 +647,6 @@ interface ImportShardResult {
481
647
  inserted: Record<string, number>;
482
648
  }
483
649
  declare const selectExportTables: (schema: SchemaLike, requested?: ReadonlyArray<string>) => string[];
484
- declare const exportShardTable: (writer: DatabaseWriterLike, table: string, batchSize?: number) => AsyncGenerator<ExportRow, void, undefined>;
485
650
  declare const exportShardRows: (writer: DatabaseWriterLike, schema: SchemaLike, args: ExportShardArgs) => AsyncGenerator<ExportRow, void, undefined>;
486
651
  declare const validateImportRow: (schema: SchemaLike, table: string, record: Record<string, unknown>) => string | undefined;
487
652
  declare const importShardRows: (writer: DatabaseWriterLike, schema: SchemaLike, args: ImportShardArgs) => Promise<ImportShardResult>;
@@ -535,6 +700,7 @@ interface CacheEntry {
535
700
  bytes: number;
536
701
  deps: Set<string>;
537
702
  lastUsed: number;
703
+ ranges: ReadonlyArray<KeyRange>;
538
704
  result: unknown;
539
705
  subscribers: Set<string>;
540
706
  }
@@ -546,6 +712,7 @@ interface ReactiveCacheOptions {
546
712
  declare class ReactiveCache {
547
713
  private readonly entries;
548
714
  private readonly tableIndex;
715
+ private readonly rangeIndex;
549
716
  private totalBytes;
550
717
  private hits;
551
718
  private misses;
@@ -554,9 +721,10 @@ declare class ReactiveCache {
554
721
  private readonly maxBytes;
555
722
  private readonly now;
556
723
  private monotonic;
724
+ private generation;
557
725
  constructor(options?: ReactiveCacheOptions);
558
- run<R>(key: string, deps: Set<string>, run: () => Promise<R>): Promise<R>;
559
- invalidate(table: string, id: string): string[];
726
+ run<R>(key: string, deps: Set<string>, run: () => Promise<R>, ranges?: () => ReadonlyArray<KeyRange>): Promise<R>;
727
+ invalidate(table: string, id: string, indexKeys?: ReadonlyArray<IndexKeyEntry>): string[];
560
728
  invalidateTable(table: string): string[];
561
729
  subscribe(key: string, subscriberId: string): void;
562
730
  unsubscribe(key: string, subscriberId: string): void;
@@ -573,11 +741,37 @@ declare class ReactiveCache {
573
741
  hits: number;
574
742
  misses: number;
575
743
  };
744
+ private dropRangeDeps;
576
745
  private collectAndDrop;
746
+ private dropKeys;
577
747
  private dropEntry;
578
748
  private evict;
579
749
  }
580
750
  declare const reactiveCacheKey: (functionPath: string, args: Record<string, unknown>, identity: null | string) => string;
751
+ interface TransactionLimits {
752
+ maxReadRows: number;
753
+ maxWrittenBytes: number;
754
+ maxWrittenRows: number;
755
+ }
756
+ interface TransactionHeadroom {
757
+ readRows: number;
758
+ remainingReadRows: number;
759
+ remainingWrittenBytes: number;
760
+ remainingWrittenRows: number;
761
+ writtenBytes: number;
762
+ writtenRows: number;
763
+ }
764
+ declare const DEFAULT_TRANSACTION_LIMITS: TransactionLimits;
765
+ declare class TransactionHeadroomTracker {
766
+ private readRows;
767
+ private writtenRows;
768
+ private writtenBytes;
769
+ private readonly limits;
770
+ constructor(limits?: Partial<TransactionLimits>);
771
+ recordRead(count: number): void;
772
+ recordWrite(row: unknown): void;
773
+ headroom(): TransactionHeadroom;
774
+ }
581
775
  interface RunTriggersOptions {
582
776
  ctx: TriggerContextLike;
583
777
  event: TriggerEventLike;
@@ -588,12 +782,18 @@ interface RunTriggersOptions {
588
782
  }
589
783
  declare const runTriggers: (options: RunTriggersOptions) => Promise<void>;
590
784
  declare const hasTrigger: (schema: SchemaLike, tableName: string, op: TriggerOpLike) => boolean;
785
+ interface SearchBackfillProgress {
786
+ done: boolean;
787
+ pages: number;
788
+ }
591
789
  declare const backfillAggregateIndexes: (sql: SqlExec, schema: SchemaLike) => void;
592
790
  declare const backfillRankIndexes: (sql: SqlExec, schema: SchemaLike) => void;
593
791
  declare const backfillSearchIndexesForTable: (sql: SqlExec, tableName: string, definition: {
594
792
  searchIndexes?: ReadonlyArray<SearchIndexDefinitionLike>;
595
793
  }) => void;
596
- declare const backfillSearchIndexes: (sql: SqlExec, schema: SchemaLike) => void;
794
+ declare const backfillSearchIndexes: (sql: SqlExec, schema: SchemaLike, options?: {
795
+ maxPages?: number;
796
+ }) => SearchBackfillProgress;
597
797
  declare const CDC_LOG_TABLE = "__cdc_log";
598
798
  interface CdcChange {
599
799
  doc?: Record<string, unknown>;
@@ -603,19 +803,35 @@ interface CdcChange {
603
803
  table: string;
604
804
  ts: number;
605
805
  }
606
- declare const migrateCdcLog: (sql: SqlExec) => void;
806
+ declare const CDC_LOG_TABLE_SEQ_INDEX = "__cdc_log_table_seq";
807
+ declare const migrateCdcLog: (sql: SqlExec, options?: {
808
+ rowHistoryIndex?: boolean;
809
+ }) => void;
607
810
  declare const appendCdcChange: (sql: SqlExec, ts: number, table: string, id: string, op: CdcChange["op"], doc: Record<string, unknown> | undefined) => void;
608
811
  declare const readCdcChanges: (sql: SqlExec, options?: {
609
812
  limit?: number;
610
813
  sinceSeq?: number;
611
- tables?: ReadonlySet<string>;
612
814
  }) => {
613
815
  changes: CdcChange[];
614
816
  cursor: number;
615
817
  };
616
- declare const trimCdcChanges: (sql: SqlExec, throughSeq: number) => void;
818
+ declare const cdcTouchesTables: (sql: SqlExec, sinceSeq: number, tables: ReadonlySet<string>) => boolean;
819
+ declare const cdcCanVouchFor: (sql: SqlExec, deps: ReadonlySet<string>) => boolean;
820
+ interface CdcChangeKey {
821
+ id: string;
822
+ op: CdcChange["op"];
823
+ seq: number;
824
+ }
825
+ declare const readCdcChangeKeys: (sql: SqlExec, table: string, sinceSeq: number, upTo: number) => CdcChangeKey[];
826
+ declare const trimCdcChanges: (sql: SqlExec, throughSeq: number, maxRows: number) => void;
827
+ declare const compactCdcDocs: (sql: SqlExec, throughSeq: number, maxRows: number) => void;
828
+ declare const cdcSeqLeavingRows: (sql: SqlExec, keep: number) => number | undefined;
617
829
  declare const readCdcCursor: (sql: SqlExec) => number;
830
+ declare const cursorBelowRetainedFloor: (floor: number | undefined, sinceSeq: number) => boolean;
831
+ declare const cdcTrimmedError: (floor: number, sinceSeq: number, scope: "global" | "shard") => LunoraError;
832
+ declare const cdcForkedError: (cursor: number, sinceSeq: number, scope: "global" | "shard", epoch?: string) => LunoraError;
618
833
  declare const minCdcSeq: (sql: SqlExec) => number | undefined;
834
+ declare const minCdcReplayableSeq: (sql: SqlExec) => number | undefined;
619
835
  declare const CDC_META_TABLE = "__cdc_meta";
620
836
  declare const migrateCdcMeta: (sql: SqlExec) => void;
621
837
  declare const readCdcEpoch: (sql: SqlExec) => string;
@@ -625,12 +841,6 @@ declare const CLIENT_WATERMARK_TABLE = "__client_watermark";
625
841
  declare const migrateClientWatermark: (sql: SqlExec) => void;
626
842
  declare const readClientWatermark: (sql: SqlExec, identity: string, clientId: string) => number;
627
843
  declare const advanceClientWatermark: (sql: SqlExec, identity: string, clientId: string, mutationId: number) => void;
628
- declare const GLOBAL_SHAPE_SNAPSHOT_TABLE = "__global_shape_snapshot";
629
- declare const migrateGlobalShapeSnapshot: (sql: SqlExec) => void;
630
- declare const readGlobalShapeSnapshot: (sql: SqlExec, connectionId: string, subId: string) => Map<string, string>;
631
- declare const writeGlobalShapeSnapshot: (sql: SqlExec, connectionId: string, subId: string, snapshot: Map<string, string>) => void;
632
- declare const deleteGlobalShapeSnapshot: (sql: SqlExec, connectionId: string, subId: string) => void;
633
- declare const deleteGlobalShapeSnapshotsForConnection: (sql: SqlExec, connectionId: string) => void;
634
844
  declare const IDEMPOTENCY_TABLE = "__idempotency";
635
845
  interface IdempotentRecord {
636
846
  resultJson: string;
@@ -647,50 +857,19 @@ declare const runShardMigrations: (sql: SqlExec, schema: SchemaLike, options?: {
647
857
  json: string;
648
858
  };
649
859
  }) => void;
650
- /**
651
- * How far a search companion's backfill has progressed, and what the next pass
652
- * should do about it.
653
- *
654
- * Neither stored analysis nor query policy, which is why it is its own module
655
- * rather than a third responsibility bolted onto one of them: it is *progress*,
656
- * the one piece of search state that is written as the index is built rather
657
- * than decided when it is read.
658
- *
659
- * The policy below is shared because when each engine owned a copy they
660
- * immediately disagreed about exactly the two cases that matter — whether a row
661
- * with no recorded profile may be resumed (it may not; nothing says what
662
- * analyzed it) and whether a never-started index is worth wiping (it is not;
663
- * there is nothing in it).
664
- */
665
- /**
666
- * How far a companion's backfill has progressed, and under which analysis.
667
- * Declared here rather than beside either engine's state table: both record the
668
- * same three facts, and the decisions made from them are the shared policy
669
- * below.
670
- */
671
- interface SearchBackfillState {
672
- /** Last `id` indexed, or `undefined` when no page has run yet. */
673
- cursor: string | undefined;
674
- /** True once a page came back short — the table is fully indexed. */
675
- done: boolean;
676
- /** Analyzer profile the stored rows were built with; `undefined` predates profile tracking. */
677
- profile: string | undefined;
678
- }
679
- declare const SEARCH_STATE_TABLE = "__lunora_search_state";
680
- declare const migrateSearchState: (sql: SqlExec) => void;
681
- declare const readSearchBackfillState: (sql: SqlExec, companion: string) => SearchBackfillState;
682
- declare const writeSearchBackfillState: (sql: SqlExec, companion: string, cursor: string | undefined, done: boolean, profile: string) => void;
683
860
  interface ShapeRow {
684
861
  doc: Record<string, unknown>;
685
862
  id: string;
686
863
  }
687
864
  declare const selectShapeRows: (sql: SqlExec, table: string, effectiveWhere: WhereInput | undefined) => ShapeRow[];
688
- declare const selectShapeMemberIds: (sql: SqlExec, table: string, effectiveWhere: WhereInput | undefined, ids: ReadonlyArray<string>) => Set<string>;
865
+ declare const selectShapeMembers: (sql: SqlExec, table: string, effectiveWhere: WhereInput | undefined, ids: ReadonlyArray<string>) => Map<string, Record<string, unknown>>;
689
866
  interface SqlExec {
690
867
  exec: <Row = Record<string, unknown>>(sql: string, ...params: unknown[]) => SqlCursor<Row>;
691
868
  }
692
869
  interface SqlCursor<Row> extends Iterable<Row> {
870
+ readonly columnNames?: string[];
693
871
  one: () => Row;
872
+ raw?: () => IterableIterator<unknown[]>;
694
873
  toArray: () => Row[];
695
874
  }
696
875
  type IndexUseHook = (table: string, indexName: string, kind: "geo" | "index" | "rank" | "search") => void;
@@ -706,16 +885,25 @@ interface WriteEvent {
706
885
  type WriteHook = (event: WriteEvent) => Promise<void> | void;
707
886
  interface CtxDbOptions {
708
887
  auth?: ServerDefaultContextLike["auth"];
888
+ baselineSeq?: () => number | undefined;
709
889
  broadcast?: BroadcastDelta;
710
890
  cache?: ReactiveCache;
711
891
  cdc?: boolean;
712
892
  clock?: Clock;
713
893
  enforceRls?: boolean;
714
894
  globalDb?: DatabaseWriterLike;
895
+ headroom?: TransactionHeadroomTracker;
715
896
  idGenerator?: IdGenerator;
897
+ inTransaction?: () => boolean;
716
898
  maxRelationKeys?: number;
717
899
  onIndexUse?: IndexUseHook;
718
900
  onRead?: ReadHook;
901
+ onReadRange?: (range: KeyRange) => void;
902
+ onStalePatchDropped?: (event: {
903
+ fields: string[];
904
+ id: string;
905
+ table: string;
906
+ }) => void;
719
907
  onWrite?: WriteHook;
720
908
  relationExistsPushDown?: "always" | "auto" | "never";
721
909
  scheduler?: SchedulerLike;
@@ -728,6 +916,8 @@ declare class NotUniqueError extends LunoraError {
728
916
  constructor(message?: string);
729
917
  }
730
918
  declare const normalizeIdStructurally: (schema: SchemaLike, tableName: string, id: string) => null | string;
919
+ declare const assertNoExplicitUndefined: (op: "patch" | "replace", document: Record<string, unknown>) => void;
920
+ declare const stripReservedPatchFields: (patch: Record<string, unknown>) => Record<string, unknown>;
731
921
  declare const createShardCtxDb: (options: CtxDbOptions) => DatabaseWriterLike;
732
922
  declare const AUDIT_LOG_TABLE = "__lunora_audit__";
733
923
  interface AuditEntry {
@@ -751,71 +941,30 @@ declare const readAuditLog: (sql: SqlExec, options?: {
751
941
  limit?: number;
752
942
  sinceSeq?: number;
753
943
  }) => AuditEntry[];
754
- interface SubscriptionQuery {
755
- args?: Record<string, unknown>;
756
- functionPath?: string;
757
- sinceEpoch?: string;
758
- sinceSeq?: number;
759
- table?: string;
760
- }
761
- interface ShapeSubscriptionQuery {
762
- args?: Record<string, unknown>;
763
- name: string;
764
- sinceEpoch?: string;
765
- sinceSeq?: number;
766
- }
767
- interface SubscriptionEnvelope {
768
- clientId?: string;
769
- context?: Record<string, unknown>;
770
- data?: unknown;
771
- id: string;
772
- query?: SubscriptionQuery;
773
- shape?: {
774
- args?: Record<string, unknown>;
775
- name: string;
776
- };
777
- sinceCheckpoint?: number;
778
- sinceEpoch?: string;
779
- topic?: string;
780
- type: "ack" | "connect" | "shape_subscribe" | "shape_unsubscribe" | "stream" | "subscribe" | "unsubscribe" | "whisper" | "whisper_subscribe" | "whisper_unsubscribe";
781
- }
782
- interface RpcRequest {
783
- args?: Record<string, unknown>;
784
- functionPath: string;
785
- }
786
- interface SocketAttachment {
787
- admin?: boolean;
788
- clientId?: string;
789
- connected?: boolean;
790
- connectionId?: string;
791
- context?: Record<string, unknown>;
792
- expiresAt?: number;
793
- identity?: Record<string, unknown>;
794
- shapes?: Record<string, ShapeSubscriptionQuery>;
795
- subs: Record<string, SubscriptionQuery>;
796
- userId?: string;
797
- whispers?: string[];
798
- }
799
- interface ResolvedShape {
800
- columns?: ReadonlyArray<string>;
801
- effectiveWhere?: WhereInput;
802
- global?: boolean;
803
- table: string;
804
- }
805
- interface SubscriptionIdentity {
806
- identity?: Record<string, unknown>;
807
- userId?: string;
808
- }
809
- interface ShardSocketLike {
810
- readonly bufferedAmount?: number;
811
- close?: (code?: number, reason?: string) => void;
812
- deserializeAttachment?: () => unknown;
813
- send: (data: string) => void;
814
- serializeAttachment?: (value: unknown) => void;
815
- }
944
+ interface CdcArchiveScope {
945
+ epoch: string;
946
+ shard: string;
947
+ }
948
+ declare const readCdcArchivedThrough: (sql: SqlExec) => number;
949
+ declare const writeCdcArchivedThrough: (sql: SqlExec, seq: number) => void;
950
+ declare const archiveCdcSegment: (bucket: R2BucketLike, scope: CdcArchiveScope, changes: CdcChange[]) => Promise<void>;
951
+ declare const cdcArchiveRewound: (bucket: R2BucketLike, scope: CdcArchiveScope, archivedThrough: number) => Promise<boolean>;
952
+ declare const readArchivedCdcChanges: (bucket: R2BucketLike, scope: CdcArchiveScope, sinceSeq: number, limit: number | undefined) => Promise<{
953
+ changes: CdcChange[];
954
+ cursor: number;
955
+ } | undefined>;
956
+ declare const COMMIT_SEQ_TABLE = "__commit_seq";
957
+ declare const COMMIT_SEQ_FIELD = "_commitSeq";
958
+ declare const migrateCommitSeq: (sql: SqlExec) => void;
959
+ declare const readCommitSeq: (sql: SqlExec) => number;
960
+ declare const allocateCommitSeq: (sql: SqlExec) => number;
816
961
  interface CompanionSyncDeps {
817
962
  broadcast: (delta: MutationDelta) => void;
818
- invalidateCache: (table: string, id: string) => void;
963
+ indexKeysFor: (table: string, document?: Record<string, unknown>) => ReadonlyArray<{
964
+ index: string;
965
+ key: string;
966
+ }> | undefined;
967
+ invalidateCache: (table: string, id: string, document?: Record<string, unknown>) => void;
819
968
  recordCdc: (table: string, id: string, op: "delete" | "insert" | "update", doc?: Record<string, unknown>) => void;
820
969
  schema: SchemaLike;
821
970
  sql: SqlExec;
@@ -832,6 +981,19 @@ interface CompanionSync {
832
981
  syncSearch: (tableName: string, id: string, document: Record<string, unknown> | undefined, previous?: Record<string, unknown>) => void;
833
982
  }
834
983
  declare const createCompanionSync: (deps: CompanionSyncDeps) => CompanionSync;
984
+ declare const GLOBAL_SHAPE_SNAPSHOT_TABLE = "__global_shape_snapshot";
985
+ declare const migrateGlobalShapeSnapshot: (sql: SqlExec) => void;
986
+ declare const readGlobalShapeSnapshot: (sql: SqlExec, connectionId: string, subId: string) => Map<string, string> | undefined;
987
+ declare const writeGlobalShapeSnapshot: (sql: SqlExec, connectionId: string, subId: string, snapshot: Map<string, string>) => void;
988
+ declare const deleteGlobalShapeSnapshot: (sql: SqlExec, connectionId: string, subId: string) => void;
989
+ declare const deleteGlobalShapeSnapshotsForConnection: (sql: SqlExec, connectionId: string) => void;
990
+ declare const isMemoryTable: (definition: TableDefinitionLike | undefined) => boolean;
991
+ declare const memoryTableNames: (schema: SchemaLike) => string[];
992
+ declare const clearMemoryTables: (sql: SqlExec, schema: SchemaLike) => number;
993
+ declare const resolveRankSeekTuple: (options: {
994
+ after?: RankPageRowKey;
995
+ cursor?: null | string;
996
+ }) => unknown[] | undefined;
835
997
  interface RankPageDeps {
836
998
  assertRankPartitionLocal: (tableName: string, definition: TableDefinitionLike, index: RankIndexDefinitionLike) => void;
837
999
  ensureRankBackfilled: (tableName: string, index: RankIndexDefinitionLike) => void;
@@ -849,13 +1011,76 @@ interface RankPageComputation {
849
1011
  key: RankPageRowKey;
850
1012
  }[];
851
1013
  }
852
- declare const hydrateDocsById: (deps: RankPageDeps, tableName: string, ids: ReadonlyArray<string>) => Map<string, Record<string, unknown>>;
853
1014
  declare const computeRankPage: (deps: RankPageDeps, tableName: string, indexName: string, rankPageOptions: RankPageOptions) => RankPageComputation;
1015
+ declare const SCHEDULE_OUTBOX_TABLE = "__schedule_outbox";
1016
+ interface ScheduleOutboxRow {
1017
+ attempts: number;
1018
+ envelopeJson: string;
1019
+ id: string;
1020
+ nextAttemptAt: number;
1021
+ }
1022
+ interface ScheduleOutboxEnvelope {
1023
+ args: unknown;
1024
+ options: Record<string, unknown> | undefined;
1025
+ target: unknown;
1026
+ when: number;
1027
+ }
1028
+ interface ScheduleOutbox {
1029
+ forget: (id: string) => void;
1030
+ record: (id: string, envelope: ScheduleOutboxEnvelope) => void;
1031
+ wake: () => void;
1032
+ }
1033
+ declare const migrateScheduleOutbox: (sql: SqlExec) => void;
1034
+ declare const recordScheduleOutbox: (sql: SqlExec, id: string, envelopeJson: string, now: number) => void;
1035
+ declare const forgetScheduleOutbox: (sql: SqlExec, id: string) => void;
1036
+ declare const readDueScheduleOutbox: (sql: SqlExec, nowMs: number, limit: number) => ScheduleOutboxRow[];
1037
+ declare const deferScheduleOutbox: (sql: SqlExec, id: string, attempts: number, nextAttemptAt: number) => void;
1038
+ declare const parkScheduleOutbox: (sql: SqlExec, id: string, attempts: number) => void;
1039
+ declare const probeScheduleOutbox: (sql: SqlExec) => {
1040
+ dueAt: number | undefined;
1041
+ populated: boolean;
1042
+ };
1043
+ declare const trimScheduleOutbox: (sql: SqlExec, olderThanTs: number) => void;
1044
+ /**
1045
+ * How far a companion's backfill has progressed, and under which analysis.
1046
+ * Declared here rather than beside either engine's state table: both record the
1047
+ * same three facts, and the decisions made from them are the shared policy
1048
+ * below.
1049
+ */
1050
+ interface BackfillState {
1051
+ /** Last `id` indexed, or `undefined` when no page has run yet. */
1052
+ cursor: string | undefined;
1053
+ /** True once a page came back short — the table is fully indexed. */
1054
+ done: boolean;
1055
+ /** Analyzer profile the stored rows were built with; `undefined` predates profile tracking. */
1056
+ profile: string | undefined;
1057
+ }
1058
+ declare const SEARCH_STATE_TABLE = "__lunora_search_state";
1059
+ declare const migrateSearchState: (sql: SqlExec) => void;
1060
+ declare const readSearchBackfillState: (sql: SqlExec, companion: string) => BackfillState;
1061
+ declare const writeSearchBackfillState: (sql: SqlExec, companion: string, cursor: string | undefined, done: boolean, profile: string) => void;
1062
+ declare const SHAPE_POKE_CURSOR_TABLE = "__shape_poke_cursor";
1063
+ declare const migrateShapePokeCursor: (sql: SqlExec) => void;
1064
+ declare const readShapePokeCursor: (sql: SqlExec, connectionId: string, subId: string) => number | undefined;
1065
+ declare const writeShapePokeCursor: (sql: SqlExec, connectionId: string, subId: string, cursor: number) => void;
1066
+ interface ShapePokeCursorRow {
1067
+ connectionId: string;
1068
+ cursor: number;
1069
+ subId: string;
1070
+ }
1071
+ declare const writeShapePokeCursors: (sql: SqlExec, rows: ReadonlyArray<ShapePokeCursorRow>) => void;
1072
+ declare const minShapePokeCursor: (sql: SqlExec) => number | undefined;
1073
+ declare const deleteShapePokeCursor: (sql: SqlExec, connectionId: string, subId: string) => void;
1074
+ declare const deleteShapePokeCursorsForConnection: (sql: SqlExec, connectionId: string) => void;
854
1075
  declare const DATA_MIGRATION_STATE_TABLE = "__lunora_migrations";
855
1076
  type MigrationDirection = "down" | "up";
856
1077
  type MigrationStatus = "completed" | "failed" | "in_progress";
857
1078
  type DataMigrationDocument = Record<string, unknown>;
858
- type DataMigrationTransform = (document: DataMigrationDocument) => DataMigrationDocument | undefined;
1079
+ type DataMigrationReader = Pick<DatabaseWriterLike, "count" | "findFirst" | "findMany" | "get">;
1080
+ interface DataMigrationContext {
1081
+ db: DataMigrationReader;
1082
+ }
1083
+ type DataMigrationTransform = (document: DataMigrationDocument, context: DataMigrationContext) => DataMigrationDocument | Promise<DataMigrationDocument | undefined> | undefined;
859
1084
  interface DataMigrationLike {
860
1085
  readonly batchSize?: number;
861
1086
  readonly down?: DataMigrationTransform;
@@ -910,10 +1135,10 @@ interface DependencyTracker {
910
1135
  declare const createDependencyTracker: () => DependencyTracker;
911
1136
  declare const runSql: <Row = Record<string, unknown>>(sql: SqlExec, query: string, ...params: unknown[]) => SqlCursor<Row>;
912
1137
  declare const runDrizzle: <Row = Record<string, unknown>>(exec: SqlExec, query: SQL) => SqlCursor<Row>;
1138
+ declare const quoteIdentifier: (name: string) => string;
913
1139
  declare const serializeSqlValue: (value: unknown) => unknown;
914
1140
  declare const DOC_COLUMN = "__doc__";
915
1141
  declare const geoTableName: (table: string, indexName: string) => string;
916
- declare const quoteIdentifier: (name: string) => string;
917
1142
  declare const jsonPath: (field: string) => string;
918
1143
  declare const jsonPathSql: (field: string) => SQL;
919
1144
  declare const qualifiedJsonPath: (table: string, field: string) => string;
@@ -923,10 +1148,16 @@ declare const AGG_KEY: Name;
923
1148
  declare const AGG_VALUE: Name;
924
1149
  declare const AGG_COUNT: Name;
925
1150
  declare const aggUpsertSql: (aggTable: string, key: unknown, value: unknown, count: unknown, set: SQL) => SQL;
926
- declare const tableColumns: (definition: TableDefinitionLike) => [string, ColumnMetaLike][];
1151
+ declare const tableColumns: (definition: TableDefinitionLike) => ReadonlyArray<readonly [string, ColumnMetaLike]>;
927
1152
  declare const rowToDocument: (row: Record<string, unknown> | undefined) => Record<string, unknown> | undefined;
928
1153
  declare const tryRowToDocument: (row: Record<string, unknown> | undefined) => Record<string, unknown> | undefined;
929
1154
  declare const isFtsAvailable: (sql: SqlExec) => boolean;
1155
+ declare const WORKERD_SQLITE_LIMITS: {
1156
+ readonly boundParams: 100;
1157
+ readonly compoundSelect: 5;
1158
+ readonly likePattern: 50;
1159
+ readonly sqlTextLength: 100000;
1160
+ };
930
1161
  type SqlEngine = "mysql" | "postgres" | "sqlite";
931
1162
  interface RenderedSql {
932
1163
  params: unknown[];
@@ -934,6 +1165,79 @@ interface RenderedSql {
934
1165
  }
935
1166
  declare const renderSql: (engine: SqlEngine, query: SQL) => RenderedSql;
936
1167
  declare const param: (value: unknown) => SQL;
1168
+ declare const unionAll: (branches: ReadonlyArray<SQL>) => SQL;
1169
+ declare const sqliteInList: (reference: SQL, items: ReadonlyArray<unknown>, negated: boolean, budget?: number) => SQL;
1170
+ type DurableStreamStatus = "complete" | "error" | "running";
1171
+ interface DurableStreamRun {
1172
+ error?: string;
1173
+ errorCode?: string;
1174
+ lastSeq: number;
1175
+ startedAt: number;
1176
+ status: DurableStreamStatus;
1177
+ }
1178
+ interface DurableStreamChunk {
1179
+ dataJson: string;
1180
+ seq: number;
1181
+ }
1182
+ declare const migrateDurableStreams: (sql: SqlExec) => void;
1183
+ declare const readStreamRun: (sql: SqlExec, runKey: string) => DurableStreamRun | undefined;
1184
+ declare const claimStreamRun: (sql: SqlExec, runKey: string, startedAt: number, ttlMs: number) => boolean;
1185
+ declare const deleteStreamRun: (sql: SqlExec, runKey: string) => void;
1186
+ declare const appendStreamChunk: (sql: SqlExec, runKey: string, seq: number, dataJson: string) => void;
1187
+ declare const readStreamChunks: (sql: SqlExec, runKey: string, sinceSeq: number) => DurableStreamChunk[];
1188
+ declare const finishStreamRun: (sql: SqlExec, runKey: string, status: "complete" | "error", lastSeq: number, failure?: {
1189
+ code: string;
1190
+ message: string;
1191
+ }) => void;
1192
+ declare const trimStreamRuns: (sql: SqlExec, now: number, live: ReadonlySet<string>) => void;
1193
+ declare const MAX_DURABLE_STREAM_CHUNKS = 50000;
1194
+ declare const MAX_DURABLE_STREAM_BYTES: number;
1195
+ interface DurableStreamSink {
1196
+ readonly chunk: (chunk: {
1197
+ data: unknown;
1198
+ generation?: number;
1199
+ seq: number;
1200
+ }) => boolean;
1201
+ readonly complete: () => void;
1202
+ readonly fail: (failure: {
1203
+ code: string;
1204
+ message: string;
1205
+ }) => void;
1206
+ }
1207
+ type DurableAttachDecision = "attach" | "interrupted" | "reclaim" | "replay-terminal";
1208
+ declare const decideDurableAttach: (run: DurableStreamRun | undefined, context: {
1209
+ generation?: number;
1210
+ live?: {
1211
+ generation: number;
1212
+ };
1213
+ resuming: boolean;
1214
+ }) => DurableAttachDecision;
1215
+ interface DurableStreamAttach {
1216
+ readonly generation?: number;
1217
+ readonly iterator: (signal: AbortSignal) => AsyncIterable<unknown>;
1218
+ readonly runKey: string;
1219
+ readonly sinceChunk: number;
1220
+ readonly sink: DurableStreamSink;
1221
+ readonly ttlMs?: number;
1222
+ }
1223
+ declare class DurableStreamRunner {
1224
+ private lastTrimAt;
1225
+ private readonly runs;
1226
+ private readonly sql;
1227
+ private readonly waitUntil;
1228
+ constructor(dependencies: {
1229
+ sql: () => SqlExec;
1230
+ waitUntil?: (promise: Promise<unknown>) => void;
1231
+ });
1232
+ attach(request: DurableStreamAttach): Promise<void>;
1233
+ detach(runKey: string, sink: DurableStreamSink): void;
1234
+ isLive(runKey: string): boolean;
1235
+ private attachOrThrow;
1236
+ private produce;
1237
+ private trim;
1238
+ }
1239
+ declare const envPositiveInt: (env: unknown, key: string, fallback: number) => number;
1240
+ declare const envOptionalPositiveInt: (env: unknown, key: string) => number | undefined;
937
1241
  interface ExternalSourceDiffResult {
938
1242
  changes: CdcChange[];
939
1243
  nextBaseline: Map<string, string>;
@@ -998,6 +1302,16 @@ declare const isSoftDeleted: (row: Record<string, unknown>, column: string) => b
998
1302
  declare const pullExternalSourceIncrementalTick: (sql: SqlExec, writer: DatabaseWriterLike, client: SourceClientLike, table: string, source: ExternalSourceLike, shardKey: string, nowMs: number) => Promise<{
999
1303
  applied: number;
1000
1304
  }>;
1305
+ declare const ftsRowidMapName: (companion: string) => string;
1306
+ interface FtsWriteOptions {
1307
+ guard?: SQL;
1308
+ unmappedRowids?: ReadonlyArray<number>;
1309
+ }
1310
+ declare const ftsCompanionDdl: (companion: string) => SQL[];
1311
+ declare const ftsWriteDocument: (companion: string, id: string, text: string, options?: FtsWriteOptions) => SQL[];
1312
+ declare const ftsPurgeDocument: (companion: string, id: string, options?: FtsWriteOptions) => SQL[];
1313
+ declare const ftsUnmappedPage: (companion: string, limit: number, after?: number) => SQL;
1314
+ declare const groupUnmappedRows: (rows: ReadonlyArray<Record<string, unknown>>) => Map<string, number[]>;
1001
1315
  declare const GEO_DEFAULT_PRECISION = 9;
1002
1316
  interface GeoPoint {
1003
1317
  lat: number;
@@ -1013,6 +1327,20 @@ declare const coveringGeohashes: (center: GeoPoint, radiusMeters: number) => str
1013
1327
  declare const pointInBoundingBox: (point: GeoPoint, box: GeoBoundingBox) => boolean;
1014
1328
  declare const boundingBoxCenter: (box: GeoBoundingBox) => GeoPoint;
1015
1329
  declare const boundingBoxGeohashes: (box: GeoBoundingBox) => string[];
1330
+ declare class GlobalPollTick {
1331
+ private readonly changedTables;
1332
+ private readonly reads;
1333
+ private resync;
1334
+ private skippedCount;
1335
+ constructor(changedTables?: Set<string>);
1336
+ get readCount(): number;
1337
+ get resyncRequested(): boolean;
1338
+ get skipped(): number;
1339
+ requestResync(): void;
1340
+ rows(key: string | undefined, load: () => Promise<ShapeRow[]>): Promise<ShapeRow[]>;
1341
+ shouldRead(table: string): boolean;
1342
+ }
1343
+ declare const isInternalTableName: (name: string) => boolean;
1016
1344
  declare const ADMIN_FUNCTION_PREFIX = "__lunora_admin__:";
1017
1345
  declare const RELATION_FUNCTION_PREFIX = "__lunora_relation__:";
1018
1346
  declare const FLAGS_FUNCTION_PREFIX = "__lunora_flags__:";
@@ -1023,6 +1351,8 @@ declare const ADMIN_FUNCTIONS: {
1023
1351
  readonly aiGenerateSql: "__lunora_admin__:aiGenerateSql";
1024
1352
  readonly aiTableFilter: "__lunora_admin__:aiTableFilter";
1025
1353
  readonly assignIssue: "__lunora_admin__:assignIssue";
1354
+ readonly backfillSearch: "__lunora_admin__:backfillSearch";
1355
+ readonly backfillVectors: "__lunora_admin__:backfillVectors";
1026
1356
  readonly backRelationCounts: "__lunora_admin__:backRelationCounts";
1027
1357
  readonly cdcSync: "__lunora_admin__:cdcSync";
1028
1358
  readonly clearCapturedMail: "__lunora_admin__:clearCapturedMail";
@@ -1035,6 +1365,7 @@ declare const ADMIN_FUNCTIONS: {
1035
1365
  readonly explainIssue: "__lunora_admin__:explainIssue";
1036
1366
  readonly exportShard: "__lunora_admin__:exportShard";
1037
1367
  readonly facetColumn: "__lunora_admin__:facetColumn";
1368
+ readonly findRelated: "__lunora_admin__:findRelated";
1038
1369
  readonly getAdvisories: "__lunora_admin__:getAdvisories";
1039
1370
  readonly getAdvisorProcedures: "__lunora_admin__:getAdvisorProcedures";
1040
1371
  readonly getAuditLog: "__lunora_admin__:getAuditLog";
@@ -1047,6 +1378,7 @@ declare const ADMIN_FUNCTIONS: {
1047
1378
  readonly getMetricSeries: "__lunora_admin__:getMetricSeries";
1048
1379
  readonly listSubscriptions: "__lunora_admin__:listSubscriptions";
1049
1380
  readonly listTableIndexes: "__lunora_admin__:listTableIndexes";
1381
+ readonly listTablesIndexes: "__lunora_admin__:listTablesIndexes";
1050
1382
  readonly getLogs: "__lunora_admin__:getLogs";
1051
1383
  readonly getMetrics: "__lunora_admin__:getMetrics";
1052
1384
  readonly getPitrBookmark: "__lunora_admin__:getPitrBookmark";
@@ -1060,12 +1392,14 @@ declare const ADMIN_FUNCTIONS: {
1060
1392
  readonly ignoreIssue: "__lunora_admin__:ignoreIssue";
1061
1393
  readonly importShard: "__lunora_admin__:importShard";
1062
1394
  readonly listFlags: "__lunora_admin__:listFlags";
1395
+ readonly listReactors: "__lunora_admin__:listReactors";
1063
1396
  readonly listQueues: "__lunora_admin__:listQueues";
1064
1397
  readonly lintSql: "__lunora_admin__:lintSql";
1065
1398
  readonly listTables: "__lunora_admin__:listTables";
1066
1399
  readonly listWorkflows: "__lunora_admin__:listWorkflows";
1067
1400
  readonly maskPolicies: "__lunora_admin__:maskPolicies";
1068
1401
  readonly migrationStatus: "__lunora_admin__:migrationStatus";
1402
+ readonly patchRows: "__lunora_admin__:patchRows";
1069
1403
  readonly pitrRestore: "__lunora_admin__:pitrRestore";
1070
1404
  readonly rankBefore: "__lunora_admin__:rankBefore";
1071
1405
  readonly rankPage: "__lunora_admin__:rankPage";
@@ -1139,9 +1473,16 @@ interface TableIndexInfo {
1139
1473
  interface TableIndexesResult {
1140
1474
  indexes: TableIndexInfo[];
1141
1475
  }
1476
+ interface TablesIndexesResult {
1477
+ indexesByTable: Record<string, TableIndexInfo[]>;
1478
+ }
1142
1479
  interface ColumnMeta {
1480
+ bucket?: string;
1481
+ enumValues?: string[];
1143
1482
  isStorage?: boolean;
1144
1483
  name: string;
1484
+ nullable?: boolean;
1485
+ onDelete?: "cascade" | "restrict" | "set null";
1145
1486
  optional: boolean;
1146
1487
  pk?: boolean;
1147
1488
  ref?: string;
@@ -1169,12 +1510,13 @@ interface AdvisoriesResult {
1169
1510
  advisories: AdvisoryFinding[];
1170
1511
  }
1171
1512
  interface AdvisorProcedure {
1172
- callsMail: boolean;
1513
+ analyzableBody?: boolean;
1514
+ callsMail?: boolean;
1173
1515
  emitsEvent?: boolean;
1174
1516
  exempt?: boolean;
1175
1517
  exemptReason?: string;
1176
1518
  exportName: string;
1177
- fanOut: boolean;
1519
+ fanOut?: boolean;
1178
1520
  file: string;
1179
1521
  handlesErrors?: boolean;
1180
1522
  hasEmailArg?: boolean;
@@ -1182,15 +1524,15 @@ interface AdvisorProcedure {
1182
1524
  reachesOutbound?: boolean;
1183
1525
  runsAiGeneration?: boolean;
1184
1526
  throwsBareError?: boolean;
1185
- unboundedAiGeneration: boolean;
1527
+ unboundedAiGeneration?: boolean;
1186
1528
  usesCaptcha: boolean;
1187
1529
  usesEmailGate: boolean;
1188
- usesInsertManyUnsafe: boolean;
1530
+ usesInsertManyUnsafe?: boolean;
1189
1531
  usesMask: boolean;
1190
1532
  usesRateLimit: boolean;
1191
1533
  usesRls: boolean;
1192
1534
  visibility: "internal" | "public";
1193
- writesUserTable: boolean;
1535
+ writesUserTable?: boolean;
1194
1536
  }
1195
1537
  interface AdvisorProceduresResult {
1196
1538
  procedures: AdvisorProcedure[];
@@ -1237,6 +1579,11 @@ interface StudioFeaturesResult {
1237
1579
  mail: boolean;
1238
1580
  notifications: boolean;
1239
1581
  payments: boolean;
1582
+ platform?: {
1583
+ id: string;
1584
+ name: string;
1585
+ unsupported: string[];
1586
+ };
1240
1587
  queues: boolean;
1241
1588
  scheduler: boolean;
1242
1589
  storage: boolean;
@@ -1255,6 +1602,19 @@ interface FlagsResult {
1255
1602
  configured: boolean;
1256
1603
  flags: FlagEvaluation[];
1257
1604
  }
1605
+ interface ReactorMetadata {
1606
+ errors: number;
1607
+ lastError?: string;
1608
+ lastRanAt?: number;
1609
+ path: string;
1610
+ runs: number;
1611
+ state: "active" | "failing" | "idle";
1612
+ suppressed: number;
1613
+ tables?: ReadonlyArray<string>;
1614
+ }
1615
+ interface ReactorsResult {
1616
+ reactors: ReactorMetadata[];
1617
+ }
1258
1618
  interface WorkflowMetadata {
1259
1619
  binding: string;
1260
1620
  className: string;
@@ -1313,8 +1673,10 @@ interface TablePage {
1313
1673
  columns: string[];
1314
1674
  refs?: Record<string, string>;
1315
1675
  rows: Record<string, unknown>[];
1676
+ sqlColumns: string[];
1316
1677
  total?: number;
1317
1678
  }
1679
+ type ColumnKinds = Readonly<Record<string, string>>;
1318
1680
  type FilterOperator = "contains" | "eq" | "gt" | "gte" | "lt" | "lte" | "ne";
1319
1681
  interface FilterClause {
1320
1682
  column: string;
@@ -1326,6 +1688,7 @@ interface OrderByClause {
1326
1688
  direction: SortDirection;
1327
1689
  }
1328
1690
  interface ReadTablePageOptions {
1691
+ columnKinds?: ColumnKinds;
1329
1692
  filters?: FilterClause[];
1330
1693
  limit?: number;
1331
1694
  offset?: number;
@@ -1336,6 +1699,8 @@ interface ReadTablePageOptions {
1336
1699
  table: string;
1337
1700
  }
1338
1701
  interface SelectMatchingIdsOptions {
1702
+ after?: string;
1703
+ columnKinds?: ColumnKinds;
1339
1704
  filters?: FilterClause[];
1340
1705
  limit?: number;
1341
1706
  search?: string;
@@ -1343,6 +1708,7 @@ interface SelectMatchingIdsOptions {
1343
1708
  }
1344
1709
  interface FacetColumnOptions {
1345
1710
  column: string;
1711
+ columnKinds?: ColumnKinds;
1346
1712
  filters?: FilterClause[];
1347
1713
  limit?: number;
1348
1714
  search?: string;
@@ -1358,6 +1724,7 @@ interface FacetColumnResult {
1358
1724
  }
1359
1725
  declare const MAX_PAGE_SIZE = 500;
1360
1726
  declare const listTables: (sql: SqlExec) => TableInfo[];
1727
+ declare const isVacuousFilterClause: (clause: FilterClause) => boolean;
1361
1728
  declare const readTablePage: (sql: SqlExec, options: ReadTablePageOptions) => TablePage;
1362
1729
  declare const selectMatchingIds: (sql: SqlExec, options: SelectMatchingIdsOptions) => {
1363
1730
  hasMore: boolean;
@@ -1392,12 +1759,22 @@ interface FanoutPathCounters {
1392
1759
  socketsIterated: number;
1393
1760
  totalMs: number;
1394
1761
  }
1762
+ interface ShapeProbeCounters {
1763
+ run: number;
1764
+ served: number;
1765
+ }
1766
+ interface GlobalPollCounters {
1767
+ drains: number;
1768
+ pairsSkipped: number;
1769
+ }
1395
1770
  interface FanoutMetricsResult {
1771
+ globalPoll: GlobalPollCounters;
1396
1772
  maxRelays: number;
1397
1773
  peakSubscribers: number;
1398
1774
  promoted: boolean;
1399
1775
  relayCount: number;
1400
1776
  shapePoke: FanoutPathCounters;
1777
+ shapeProbe: ShapeProbeCounters;
1401
1778
  sinceMs: number;
1402
1779
  topics: FanoutTopicStat[];
1403
1780
  totalConnections: number;
@@ -1411,6 +1788,10 @@ interface FanoutAttachmentLike {
1411
1788
  }
1412
1789
  declare const DEFAULT_FANOUT_TOPIC_LIMIT = 20;
1413
1790
  declare const createFanoutCounters: () => FanoutPathCounters;
1791
+ declare const createShapeProbeCounters: () => ShapeProbeCounters;
1792
+ declare const createGlobalPollCounters: () => GlobalPollCounters;
1793
+ declare const recordGlobalPollPass: (counters: GlobalPollCounters, drains: number, pairsSkipped: number) => GlobalPollCounters;
1794
+ declare const recordShapeProbePass: (counters: ShapeProbeCounters, run: number, served: number) => ShapeProbeCounters;
1414
1795
  declare const recordFanoutPass: (counters: FanoutPathCounters, iterated: number, delivered: number, ms: number) => FanoutPathCounters;
1415
1796
  declare const summarizeFanoutTopics: (attachments: FanoutAttachmentLike[], limit?: number) => {
1416
1797
  peakSubscribers: number;
@@ -1479,7 +1860,20 @@ interface PitrRestoreArgs {
1479
1860
  }
1480
1861
  declare const readBookmark: (storage: PitrStorage, time?: number | string) => Promise<PitrBookmarkResult>;
1481
1862
  declare const armRestore: (storage: PitrStorage, args: PitrRestoreArgs) => Promise<Omit<PitrRestoreResult, "restarted">>;
1482
- declare const normalizeOrderKeys: (orderBy: OrderByInput[] | undefined) => OrderKey[];
1863
+ declare const tiebreakDirectionFor: (keys: ReadonlyArray<{
1864
+ direction?: string;
1865
+ }>) => SortDirection;
1866
+ declare const equalityPinnedFields: (where: undefined | WhereInput) => ReadonlySet<string>;
1867
+ declare const uniqueIndexFields: (indexes: ReadonlyArray<{
1868
+ fields: ReadonlyArray<string>;
1869
+ unique?: boolean;
1870
+ }> | undefined, shape: Record<string, ValidatorLike> | undefined) => ReadonlyArray<ReadonlyArray<string>>;
1871
+ interface OrderKeyConstraints {
1872
+ pinned?: ReadonlySet<string>;
1873
+ uniqueBy?: ReadonlyArray<ReadonlyArray<string>>;
1874
+ }
1875
+ declare const normalizeOrderKeys: (orderBy: OrderByInput[] | undefined, shape?: Record<string, ValidatorLike>, constraints?: OrderKeyConstraints) => OrderKey[];
1876
+ declare const CURSOR_PREFIX = "~4";
1483
1877
  declare const encodeCursor: (record: Record<string, unknown>, keys: OrderKey[]) => string;
1484
1878
  declare const decodeCursor: (cursor: string) => unknown[];
1485
1879
  declare const buildSeekWhere: (keys: OrderKey[], cursorValues: unknown[]) => WhereInput;
@@ -1532,7 +1926,6 @@ declare const clearQueueMessages: (sql: SqlExec) => {
1532
1926
  declare const encodePartitionKey: (partitionBy: ReadonlyArray<string>, source: Record<string, unknown>) => string;
1533
1927
  declare const RANK_TIEBREAK = "__id__";
1534
1928
  declare const sortColumnName: (i: number) => string;
1535
- declare const matchesRankStaticWhere: (document: Record<string, unknown>, predicate: Record<string, unknown>) => boolean;
1536
1929
  declare const resolveRankPartition: (index: RankIndexDefinitionLike, where: Record<string, unknown> | undefined) => Record<string, unknown> | undefined;
1537
1930
  declare const rankTableName: (table: string, indexName: string) => string;
1538
1931
  declare const rankKeyFromDocument: (index: RankIndexDefinitionLike, document_: Record<string, unknown>) => {
@@ -1540,6 +1933,60 @@ declare const rankKeyFromDocument: (index: RankIndexDefinitionLike, document_: R
1540
1933
  rowId: string;
1541
1934
  sortValues: unknown[];
1542
1935
  };
1936
+ declare const rankPivotConditionSql: (column: string, value: unknown, direction: "asc" | "desc", wantLater: boolean) => SQL | undefined;
1937
+ declare const matchesRankStaticWhere: (document: Record<string, unknown>, predicate: Record<string, unknown>) => boolean;
1938
+ declare const REACTOR_STATE_TABLE = "__reactor_state";
1939
+ interface ReactorState {
1940
+ digest: string;
1941
+ lastError?: string;
1942
+ lastRanAt: number;
1943
+ stats: ReactorStats;
1944
+ tables?: ReadonlyArray<string>;
1945
+ }
1946
+ interface ReactorStats {
1947
+ errors: number;
1948
+ runs: number;
1949
+ suppressed: number;
1950
+ }
1951
+ declare const migrateReactorState: (sql: SqlExec) => void;
1952
+ declare const readReactorState: (sql: SqlExec, path: string) => ReactorState | undefined;
1953
+ declare const listReactorStates: (sql: SqlExec) => {
1954
+ path: string;
1955
+ state: ReactorState;
1956
+ }[];
1957
+ type ReactorDispatchResult = "error" | "ran" | "suppressed";
1958
+ declare const writeReactorState: (sql: SqlExec, path: string, outcome: {
1959
+ digest?: string;
1960
+ error?: string;
1961
+ now: number;
1962
+ result: ReactorDispatchResult;
1963
+ tables?: ReadonlyArray<string>;
1964
+ }) => void;
1965
+ declare const reactorNeedsRun: (state: Pick<ReactorState, "tables"> | undefined, changed: ReadonlySet<string>) => boolean;
1966
+ interface ReadFootprint {
1967
+ onRead: (table: string, idOrScan?: string) => void;
1968
+ onReadRange: (range: KeyRange) => void;
1969
+ ranges: () => Map<string, KeyRange[]> | undefined;
1970
+ tables: Set<string>;
1971
+ }
1972
+ declare const createReadFootprint: () => ReadFootprint;
1973
+ declare const UNVOUCHABLE_DEP = "!unvouchable";
1974
+ declare const markUnvouchableReads: <T extends object>(facade: T, onRead: ReadFootprint["onRead"] | undefined, methods: ReadonlyArray<string>) => T;
1975
+ declare const WHERE_FILTER: unique symbol;
1976
+ type RowPredicate = (document: Record<string, unknown>) => boolean;
1977
+ type WhereFilter = RowPredicate & {
1978
+ readonly [WHERE_FILTER]: WhereInput;
1979
+ };
1980
+ declare const whereFilter: (where: WhereInput, predicate: RowPredicate) => WhereFilter;
1981
+ declare const whereOfFilter: (predicate: RowPredicate) => undefined | WhereInput;
1982
+ declare const isPushableWhere: (where: WhereInput, shape: Readonly<Record<string, ValidatorLike>>, exactText?: boolean) => boolean;
1983
+ declare const RELATED_MAX_DEPTH = 4;
1984
+ declare const RELATED_DEFAULT_LIMIT = 50;
1985
+ declare const RELATED_MAX_LIMIT = 200;
1986
+ declare const RELATED_DEPTH_DECAY = 0.5;
1987
+ declare const deriveRelationEdges: (schema: SchemaLike) => RelationEdge[];
1988
+ type RelationGraphReader = Pick<DatabaseWriterLike, "findMany"> & Pick<Partial<DatabaseWriterLike>, "lookupById">;
1989
+ declare const findRelated: (reader: RelationGraphReader, edges: ReadonlyArray<RelationEdge>, start: RelatedStart, options?: RelatedOptions) => Promise<RelatedPage>;
1543
1990
  declare const DEFAULT_MAX_RELATION_KEYS = 5000;
1544
1991
  interface RelationExistsMarker {
1545
1992
  childWhere: WhereInput;
@@ -1574,6 +2021,7 @@ declare const containsRelationPredicate: (where: WhereInput, schema: ResolveCont
1574
2021
  declare const assertFlatPredicate: (where: WhereInput | undefined, schema: ResolveContext["schema"], tableName: string, op: string) => void;
1575
2022
  declare const resolveRelationPredicates: (where: WhereInput | undefined, options: ResolveRelationPredicatesOptions) => Promise<WhereInput | undefined>;
1576
2023
  declare const assertShapeShardable: (effectiveWhere: WhereInput | undefined, schema: ResolveContext["schema"], table: string) => void;
2024
+ declare const relationHooks: (args: Pick<QueryArgs, "relationBaseWhere" | "relationMask">) => Pick<QueryArgs, "relationBaseWhere" | "relationMask"> & Pick<ResolveWithOptions, "fanOutBudget">;
1577
2025
  declare const fanOutScalarCounts: (counter: (tableName: string, where?: WhereInput) => Promise<number>, tableName: string, whereField: string, values: unknown[], policyWhere: WhereInput | undefined) => Promise<Map<unknown, number>>;
1578
2026
  declare const distinctValues: (rows: Record<string, unknown>[], field: string) => unknown[];
1579
2027
  declare const resolveWith: (options: ResolveWithOptions) => Promise<void>;
@@ -1598,6 +2046,8 @@ interface ShapeRowOp {
1598
2046
  value?: Record<string, unknown>;
1599
2047
  }
1600
2048
  interface ShapePokePart {
2049
+ baseCheckpoint?: number;
2050
+ reset?: boolean;
1601
2051
  rowsPatch: ShapeRowOp[];
1602
2052
  shapeId: string;
1603
2053
  }
@@ -1658,6 +2108,12 @@ interface RelayShapeSubscribe {
1658
2108
  type: "relay_shape_subscribe";
1659
2109
  userId?: string;
1660
2110
  }
2111
+ interface RelayShapeUnsubscribe {
2112
+ connectionId: string;
2113
+ relayIndex: number;
2114
+ subId?: string;
2115
+ type: "relay_shape_unsubscribe";
2116
+ }
1661
2117
  interface RelayShapeSeed {
1662
2118
  cursor?: number;
1663
2119
  epoch?: string;
@@ -1677,22 +2133,18 @@ interface RelayShapePoke {
1677
2133
  targetConnectionId?: string;
1678
2134
  type: "relay_shape_poke";
1679
2135
  }
1680
- type OwnerRelayFrame = RelayAttach | RelayDetach | RelayFrame | RelayShapePoke | RelayShapeSubscribe;
1681
- declare const DEFAULT_MAX_RELAYS = 8;
1682
- interface RelayStub {
2136
+ type OwnerRelayFrame = RelayAttach | RelayDetach | RelayFrame | RelayShapePoke | RelayShapeSubscribe | RelayShapeUnsubscribe;
2137
+ interface SiblingStub {
1683
2138
  fetch: (url: string, init?: RequestInit) => Promise<Response>;
1684
2139
  }
1685
- interface RelayNamespaceLike {
1686
- get: (id: unknown) => RelayStub;
1687
- getByName?: (name: string) => RelayStub;
1688
- idFromName: (name: string) => unknown;
1689
- }
2140
+ declare const DEFAULT_MAX_RELAYS = 8;
1690
2141
  interface RelayHost {
1691
2142
  buildShapeDiff: (resolved: ResolvedShape, fromCursor: number, toCursor: number) => ShapeRowOp[];
1692
2143
  computeOpLogShapeSeed: (shape: ShapeSubscriptionQuery, resolved: ResolvedShape) => {
1693
2144
  baseCheckpoint: number | undefined;
1694
2145
  cursor: number;
1695
2146
  epoch: string | undefined;
2147
+ reset: boolean;
1696
2148
  rowsPatch: ShapeRowOp[];
1697
2149
  };
1698
2150
  currentCdcEpoch: () => string | undefined;
@@ -1707,8 +2159,13 @@ interface RelayHost {
1707
2159
  resolveShape: (name: string, args: Record<string, unknown>, identity?: SubscriptionIdentity) => ResolvedShape | undefined;
1708
2160
  rlsMetadata: () => RlsPoliciesResult;
1709
2161
  shardBinding: () => string | undefined;
2162
+ shardJurisdiction: () => string | undefined;
1710
2163
  sql: () => SqlExec;
1711
2164
  }
2165
+ interface RelayPokeDelivery {
2166
+ delivered: number;
2167
+ matched: number;
2168
+ }
1712
2169
  declare abstract class RelayLink {
1713
2170
  protected readonly host: RelayHost;
1714
2171
  protected readonly roleId: {
@@ -1722,7 +2179,8 @@ declare abstract class RelayLink {
1722
2179
  handleControl(request: Request): Promise<Response>;
1723
2180
  maxRelays(): number;
1724
2181
  protected canAddressSiblings(): boolean;
1725
- protected relayNamespace(): RelayNamespaceLike | undefined;
2182
+ protected siblingStub(targetName: string): SiblingStub | undefined;
2183
+ protected bindingName(): string | undefined;
1726
2184
  protected postRelayMessage(targetName: string, message: OwnerRelayFrame): Promise<void>;
1727
2185
  protected requestRelayMessage(targetName: string, message: OwnerRelayFrame): Promise<Response | undefined>;
1728
2186
  abstract forwardWhisper(topic: string, frame: string): Promise<void>;
@@ -1733,19 +2191,22 @@ declare abstract class RelayLink {
1733
2191
  }>;
1734
2192
  abstract announce(): Promise<void>;
1735
2193
  abstract announceDrain(closing: ShardSocketLike): Promise<void>;
2194
+ abstract releaseRelayShapes(ws: ShardSocketLike, subId?: string): Promise<void>;
1736
2195
  abstract relayCount(): number;
1737
2196
  abstract isShapeRelayUniform(name: string, args: Record<string, unknown>): boolean;
2197
+ abstract minShapeCursor(): number | undefined;
1738
2198
  protected abstract onAttach(index: number): void;
1739
2199
  protected abstract onDetach(index: number): void;
1740
2200
  protected abstract onWhisperFrame(message: RelayFrame): Promise<void>;
1741
2201
  protected abstract onShapeSubscribe(message: RelayShapeSubscribe): RelayShapeSeed;
1742
- protected abstract onShapePoke(poke: RelayShapePoke): number;
2202
+ protected abstract onShapeUnsubscribe(message: RelayShapeUnsubscribe): void;
2203
+ protected abstract onShapePoke(poke: RelayShapePoke): RelayPokeDelivery;
1743
2204
  }
1744
2205
  declare class OwnerRelay extends RelayLink {
1745
2206
  private readonly shapeUniformCache;
1746
2207
  private relaySetCache;
1747
- private readonly relayShapeRegistry;
1748
- private readonly relayShapeProxies;
2208
+ private registryCache;
2209
+ private recordedBinding;
1749
2210
  private promotionState;
1750
2211
  constructor(host: RelayHost, ownerKey: string);
1751
2212
  forwardWhisper(topic: string, frame: string): Promise<void>;
@@ -1756,17 +2217,26 @@ declare class OwnerRelay extends RelayLink {
1756
2217
  }>;
1757
2218
  announce(): Promise<void>;
1758
2219
  announceDrain(): Promise<void>;
2220
+ releaseRelayShapes(): Promise<void>;
1759
2221
  relayCount(): number;
2222
+ minShapeCursor(): number | undefined;
1760
2223
  isShapeRelayUniform(name: string, args: Record<string, unknown>): boolean;
2224
+ protected onShapeUnsubscribe(message: RelayShapeUnsubscribe): void;
1761
2225
  protected onAttach(index: number): void;
1762
2226
  protected onDetach(index: number): void;
1763
2227
  protected onWhisperFrame(message: RelayFrame): Promise<void>;
1764
2228
  protected onShapeSubscribe(message: RelayShapeSubscribe): RelayShapeSeed;
1765
- protected onShapePoke(): number;
2229
+ protected onShapePoke(): RelayPokeDelivery;
2230
+ private buildShapePoke;
1766
2231
  private multicastShapePokes;
2232
+ private multicastToRelays;
1767
2233
  private proxyShapePokes;
2234
+ private proxyToRelay;
1768
2235
  private buildShapeSeedFrames;
1769
- private ensureRelayTable;
2236
+ private ensureRelayTables;
2237
+ protected bindingName(): string | undefined;
2238
+ private relayShapes;
2239
+ private rewindShapeCursor;
1770
2240
  private ownerRelaySet;
1771
2241
  private addRelayToSet;
1772
2242
  private removeRelayFromSet;
@@ -1775,7 +2245,8 @@ declare class OwnerRelay extends RelayLink {
1775
2245
  }
1776
2246
  declare class RelayMember extends RelayLink {
1777
2247
  private relayAnnounced;
1778
- private readonly shapeRelayMemos;
2248
+ private relayMemoCache;
2249
+ private readonly shapeControl;
1779
2250
  constructor(host: RelayHost, ownerKey: string, relayIndex: number);
1780
2251
  forwardWhisper(topic: string, frame: string): Promise<void>;
1781
2252
  onFlush(): Promise<void>;
@@ -1785,17 +2256,81 @@ declare class RelayMember extends RelayLink {
1785
2256
  }>;
1786
2257
  announce(): Promise<void>;
1787
2258
  announceDrain(closing: ShardSocketLike): Promise<void>;
2259
+ releaseRelayShapes(ws: ShardSocketLike, subId?: string): Promise<void>;
1788
2260
  relayCount(): number;
1789
2261
  isShapeRelayUniform(): boolean;
2262
+ minShapeCursor(): number | undefined;
1790
2263
  protected onAttach(): void;
1791
2264
  protected onDetach(): void;
1792
2265
  protected onWhisperFrame(): Promise<void>;
1793
2266
  protected onShapeSubscribe(): RelayShapeSeed;
1794
- protected onShapePoke(poke: RelayShapePoke): number;
2267
+ protected onShapeUnsubscribe(): void;
2268
+ protected onShapePoke(poke: RelayShapePoke): RelayPokeDelivery;
2269
+ private queueShapeControl;
2270
+ private relayMemos;
2271
+ private connectionMemos;
1795
2272
  private recordRelayShapeMemo;
2273
+ private forgetRelayShapeMemos;
1796
2274
  private deliverShapePoke;
2275
+ private pokeSocketShapes;
1797
2276
  }
1798
2277
  declare const createRelayLink: (host: RelayHost) => OwnerRelay | RelayMember | undefined;
2278
+ declare const REGION_HINTS: readonly ["wnam", "enam", "sam", "weur", "eeur", "apac", "apac-ne", "apac-se", "oc", "afr", "me"];
2279
+ type RegionHint = (typeof REGION_HINTS)[number];
2280
+ type ReplicaReadiness = "fresh" | "stale" | "unavailable";
2281
+ interface ShardSiblingHost {
2282
+ doName: () => string | undefined;
2283
+ env: () => unknown;
2284
+ shardBinding: () => string | undefined;
2285
+ shardJurisdiction: () => string | undefined;
2286
+ sql: () => SqlExec;
2287
+ }
2288
+ interface ReplicaOwnerHost extends ShardSiblingHost {
2289
+ exportRows: () => Promise<ExportRow[]>;
2290
+ ownerCursor: () => number | undefined;
2291
+ ownerEpoch: () => string | undefined;
2292
+ ownerFloor: () => number | undefined;
2293
+ readChanges: (sinceSeq: number, limit: number) => {
2294
+ changes: CdcChange[];
2295
+ cursor: number;
2296
+ };
2297
+ rowCount: () => number;
2298
+ }
2299
+ interface ReplicaFollowerHost extends ShardSiblingHost {
2300
+ applyChanges: (changes: ReadonlyArray<CdcChange>) => Promise<number>;
2301
+ importRows: (rows: ReadonlyArray<ExportRow>) => Promise<{
2302
+ errors: ReadonlyArray<unknown>;
2303
+ }>;
2304
+ }
2305
+ declare const handleReplicaControl: (host: ReplicaOwnerHost, request: Request) => Promise<Response>;
2306
+ declare class ShardReplica {
2307
+ private readonly host;
2308
+ readonly ownerKey: string;
2309
+ readonly region: RegionHint;
2310
+ private divergent;
2311
+ private inFlight;
2312
+ constructor(host: ReplicaFollowerHost, ownerKey: string, region: RegionHint);
2313
+ ensureFresh(minSeq?: number): Promise<ReplicaReadiness>;
2314
+ appliedSeq(): number;
2315
+ isDivergent(): boolean;
2316
+ private advance;
2317
+ private isCaughtUp;
2318
+ private catchUp;
2319
+ private applyPage;
2320
+ private hasDiverged;
2321
+ private bootstrap;
2322
+ private isFreshEnough;
2323
+ private pull;
2324
+ private request;
2325
+ }
2326
+ declare const createReplicaLink: (host: ReplicaFollowerHost) => ShardReplica | undefined;
2327
+ declare const gateReplicaDispatch: (replica: ShardReplica, request: Request, functionPath: string) => Promise<Response | undefined>;
2328
+ declare const REPROJECTION_MIGRATION_PREFIX = "__lunora_reproject__";
2329
+ declare const reprojectionMigrationId: (table: string) => string;
2330
+ declare const reprojectableFields: (definition: TableDefinitionLike) => string[];
2331
+ declare const reprojectionTables: (schema: SchemaLike) => string[];
2332
+ declare const countLegacyRows: (sql: SqlExec, table: string, fields: ReadonlyArray<string>) => number;
2333
+ declare const buildReprojectionMigration: (id: string, schema: SchemaLike, sql: SqlExec) => DataMigrationLike | undefined;
1799
2334
  declare const RLS_UNWRAP_SYMBOL: symbol;
1800
2335
  declare class RlsRequiredError extends LunoraError {
1801
2336
  readonly table: string;
@@ -1811,7 +2346,8 @@ interface GuardableSchema {
1811
2346
  }>;
1812
2347
  }
1813
2348
  type TableOfId = (id: string, expectedTable?: string) => Promise<string | undefined> | string | undefined;
1814
- declare const guardWriter: <W>(raw: W, schema: GuardableSchema, tableOfId: TableOfId) => W;
2349
+ type TablesOfIds = (ids: ReadonlyArray<string>, expectedTable?: string) => Promise<ReadonlyMap<string, string>> | ReadonlyMap<string, string>;
2350
+ declare const guardWriter: <W>(raw: W, schema: GuardableSchema, tableOfId: TableOfId, tablesOfIds?: TablesOfIds, relationEdges?: ReadonlyArray<RelationEdge>) => W;
1815
2351
  declare const SCHEMA_HISTORY_MAX_VERSIONS = 50;
1816
2352
  interface SchemaVersionRow {
1817
2353
  appliedAt: number;
@@ -1822,8 +2358,24 @@ interface SchemaVersionRow {
1822
2358
  declare const recordSchemaVersion: (sql: SqlExec, hash: string, snapshotJson: string, now?: number) => boolean;
1823
2359
  declare const readSchemaHistory: (sql: SqlExec) => SchemaVersionRow[];
1824
2360
  declare const readSchemaVersion: (sql: SqlExec, hash: string) => SchemaVersionRow | undefined;
2361
+ declare const readDeployInfo: (rawEnv: unknown) => DeployInfo;
1825
2362
  declare const isDevEnvironment: (rawEnv: unknown) => boolean;
1826
2363
  declare const buildSettings: (rawEnv: unknown) => SettingsResult;
2364
+ declare class ShapeDiffCache {
2365
+ private readonly keyScans;
2366
+ private readonly memberProbes;
2367
+ private run;
2368
+ private served;
2369
+ get probesRun(): number;
2370
+ get probesServed(): number;
2371
+ changedKeys(rangeKey: string, load: () => CdcChangeKey[]): ReadonlyArray<CdcChangeKey>;
2372
+ members(resolved: ResolvedShape, rangeKey: string, load: () => Map<string, Record<string, unknown>>): ReadonlyMap<string, Record<string, unknown>>;
2373
+ private getOrLoad;
2374
+ }
2375
+ declare const createShapeDiffCache: () => ShapeDiffCache;
2376
+ declare const globalShapeReadKey: (resolved: ResolvedShape, identity: SubscriptionIdentity) => string | undefined;
2377
+ type ReadShapeCdcKeys = (sql: SqlExec, table: string, sinceSeq: number, upTo: number) => CdcChangeKey[];
2378
+ declare const buildShapeDiff: (sql: SqlExec, resolved: ResolvedShape, sinceSeq: number, upTo: number, cache: ShapeDiffCache, readKeys?: ReadShapeCdcKeys) => ShapeRowOp[];
1827
2379
  interface ShardRunnerOptions {
1828
2380
  handlers?: {
1829
2381
  handleAlarm?: () => Promise<void>;
@@ -1839,7 +2391,7 @@ declare class ShardRunner {
1839
2391
  socketFor(raw: unknown): ShardSocketLike;
1840
2392
  sockets(tag?: string): SocketHandle[];
1841
2393
  background(work: Promise<unknown>): boolean;
1842
- runInTransaction<T>(work: () => Promise<T>): Promise<T>;
2394
+ runInTransaction<T>(work: () => Promise<T>, onCommitted?: () => void): Promise<T>;
1843
2395
  handleFetch(request: Request): Promise<Response>;
1844
2396
  handleAlarm(): Promise<void>;
1845
2397
  }
@@ -1865,6 +2417,11 @@ interface SqlDiagnostic {
1865
2417
  source: "gate" | "plan" | "syntax";
1866
2418
  }
1867
2419
  declare const lintReadonlySql: (sql: SqlExec, query: string) => SqlLintResult;
2420
+ declare const BIGINT_KEY_DIGITS = 39;
2421
+ declare const bigintSqlKey: (value: bigint) => string;
2422
+ declare const decodeBigintSqlKey: (raw: string) => bigint | undefined;
2423
+ declare const float64SqlKey: (value: number) => string;
2424
+ declare const decodeFloat64SqlKey: (raw: string) => number | undefined;
1868
2425
  declare const subscriptionListDeltas: (previousJson: string, nextResult: unknown, table: string, frames?: string[]) => MutationDelta[] | undefined;
1869
2426
  interface FrameSink {
1870
2427
  send: (data: string) => void;
@@ -1873,8 +2430,26 @@ interface DrainableSink {
1873
2430
  readonly bufferedAmount?: unknown;
1874
2431
  }
1875
2432
  declare const trySendFrame: (ws: FrameSink, frame: string) => boolean;
1876
- declare const sendDeltaFrames: (ws: FrameSink, subId: string, deltaFrames: ReadonlyArray<string>, cursorSuffix: string) => boolean;
2433
+ interface SubscriptionFrameInput {
2434
+ cursorSuffix: string;
2435
+ lastMutationId?: number;
2436
+ nextResult: unknown;
2437
+ pageDeltas?: boolean;
2438
+ previousJson?: string;
2439
+ snapshotJson: string;
2440
+ subId: string;
2441
+ table: string;
2442
+ }
2443
+ declare const subscriptionFrames: (input: SubscriptionFrameInput) => string[];
1877
2444
  declare const awaitWsDrain: (ws: DrainableSink) => Promise<void>;
2445
+ interface SubscriptionReadFootprint {
2446
+ ranges?: Map<string, KeyRange[]>;
2447
+ tables: Set<string>;
2448
+ }
2449
+ type ChangedKeys = Map<string, IndexKeyEntry[] | undefined>;
2450
+ declare const mergeChangedKeys: (pending: ChangedKeys | undefined, incoming: ChangedKeys | undefined, changed: Set<string>) => ChangedKeys;
2451
+ declare const recordChangedKeys: (pending: ChangedKeys | undefined, table: string, indexKeys: ReadonlyArray<IndexKeyEntry> | undefined) => ChangedKeys;
2452
+ declare const writeTouchesMemo: (memo: SubscriptionReadFootprint, changed: Set<string>, changedKeys: ChangedKeys | undefined) => boolean;
1878
2453
  type ConflictKind = "conflict" | "occ" | "restrict" | "trigger" | "unique";
1879
2454
  declare class ConflictError extends LunoraError {
1880
2455
  readonly kind: ConflictKind;
@@ -1893,13 +2468,51 @@ declare const selectExpiredIds: (sql: SqlExec, spec: TtlSweepSpec, now: number,
1893
2468
  hasMore: boolean;
1894
2469
  ids: string[];
1895
2470
  };
1896
- type FieldRefSql = (field: string) => SQL;
1897
- type SerializeValue = (value: unknown) => unknown;
1898
- interface WhereSqlStrategy {
1899
- fieldRef: FieldRefSql;
1900
- likeContains?: (reference: SQL, term: SQL) => SQL;
1901
- relationExists?: (request: unknown) => SQL;
2471
+ declare const VECTOR_BACKFILL_MAX_PAGES = 20;
2472
+ interface VectorBackfillTarget {
2473
+ profile: string;
2474
+ table: string;
2475
+ }
2476
+ interface VectorBackfillProgress {
2477
+ done: boolean;
2478
+ error?: string;
2479
+ failed: number;
2480
+ failedIds: string[];
2481
+ pages: number;
2482
+ rows: number;
2483
+ }
2484
+ type VectorPageSync = (table: string, rows: ReadonlyArray<{
2485
+ doc: Record<string, unknown>;
2486
+ id: string;
2487
+ }>) => Promise<ReadonlyArray<{
2488
+ error: unknown;
2489
+ id: string;
2490
+ }>>;
2491
+ type OrderedAfterWrites = <T, U>(read: () => T, work: (value: T) => Promise<U>) => Promise<U>;
2492
+ declare const backfillVectorIndexes: (sql: SqlExec, targets: ReadonlyArray<VectorBackfillTarget>, sync: VectorPageSync, options: {
2493
+ maxPages?: number;
2494
+ ordered: OrderedAfterWrites;
2495
+ restart?: boolean;
2496
+ }) => Promise<VectorBackfillProgress>;
2497
+ interface WhereFragments<T> {
2498
+ binary: (reference: T, comparator: string, value: unknown) => T;
2499
+ connect: (left: T, right: T, connector: "AND" | "OR") => T;
2500
+ constant: (value: boolean) => T;
2501
+ contains: (reference: T, term: T) => T;
2502
+ inList: (reference: T, items: ReadonlyArray<unknown>, negated: boolean, budget: number) => T;
2503
+ negate: (inner: T) => T;
2504
+ nullCheck: (reference: T, negated: boolean) => T;
2505
+ value: (value: unknown) => T;
2506
+ }
2507
+ type FieldRefSql<T> = (field: string) => T;
2508
+ type SerializeValue = (value: unknown, field: string) => unknown;
2509
+ interface WhereSqlStrategy<T = SQL> {
2510
+ containsExpr?: (reference: T, term: T) => T;
2511
+ fieldRef: FieldRefSql<T>;
2512
+ inList?: (reference: T, items: ReadonlyArray<unknown>, negated: boolean, budget?: number) => T;
2513
+ relationExists?: (request: unknown) => T;
1902
2514
  serialize: SerializeValue;
1903
2515
  }
1904
- declare const compileWhereSql: (where: WhereInput | undefined, strategy: WhereSqlStrategy) => SQL | undefined;
1905
- 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 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, 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 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 IndexRangeBuilderLike, 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 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 SearchFilterBuilderLike, type SearchIndexDefinitionLike, 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 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 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, buildPokeFrames, buildSeekBeforeWhere, buildSeekWhere, buildSettings, bumpCdcEpoch, clampPromotionThresholds, clearCapturedMail, clearQueueMessages, coerceAggregateNumber, compileWhereSql, computeRankPage, containsRelationPredicate, coveringGeohashes, createCompanionSync, createDependencyTracker, createFanoutCounters, createIndexSql, 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, isDevEnvironment, isFtsAvailable, isLossyBody, isRelationPredicate, isSoftDeleted, isSourceDue, jsonPath, jsonPathSql, liftSourceId, lintReadonlySql, listTables, matchesRankStaticWhere, matchesStaticWhere, materializeExternalRows, materializeExternalRowsIncremental, 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, 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 };
2516
+ declare const serverInList: (engine: "mysql" | "postgres") => (reference: SQL, items: ReadonlyArray<unknown>, negated: boolean, budget?: number) => SQL;
2517
+ declare const compileWhereSql: <T = SQL>(where: WhereInput | undefined, strategy: WhereSqlStrategy<T>, fragments?: WhereFragments<T>, reservedParams?: number) => T | undefined;
2518
+ 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, 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 FtsWriteOptions, 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, VECTOR_BACKFILL_MAX_PAGES, type ValidatorLike, type VectorBackfillProgress, WORKERD_SQLITE_LIMITS, type WhereFilter, 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, backfillVectorIndexes, bigintSqlKey, boundingBoxCenter, boundingBoxGeohashes, buildIndexRange, buildPokeFrames, buildReprojectionMigration, buildSeekBeforeWhere, buildSeekWhere, buildSettings, buildShapeDiff, bumpCdcEpoch, cdcArchiveRewound, cdcCanVouchFor, cdcForkedError, 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, ftsCompanionDdl, ftsPurgeDocument, ftsRowidMapName, ftsUnmappedPage, ftsWriteDocument, gateReplicaDispatch, geoTableName, globalShapeReadKey, groupUnmappedRows, guardWriter, handleReplicaControl, hasTrigger, haversineMeters, importShardRows, indexKeysForRow, isDevEnvironment, isFtsAvailable, isInternalTableName, isLossyBody, isMemoryTable, isPushableWhere, isRelationPredicate, isSoftDeleted, isSourceDue, isVacuousFilterClause, jsonPath, jsonPathSql, keysTouchRanges, liftSourceId, lintReadonlySql, listReactorStates, listTables, 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, serverInList, shapeRoutingKey, softDeleteScope, sortColumnName, sqliteInList, stableStringify, stableWireKey, stripReservedPatchFields, subscriptionFrames, subscriptionListDeltas, summarizeFanoutTopics, summarizeSubscriptions, tableColumns, tableFromDepKey, throwingScheduler, tiebreakDirectionFor, trimCdcChanges, trimIdempotent, trimScheduleOutbox, trimStreamRuns, tryRowToDocument, trySendFrame, unionAll, uniqueIndexFields, validateImportRow, whereFilter, whereOfFilter, writeCdcArchivedThrough, writeGlobalShapeSnapshot, writeIdempotent, writeReactorState, writeSearchBackfillState, writeShapePokeCursor, writeShapePokeCursors, writeTouchesMemo };