@lunora/shard-engine 1.0.0-alpha.4 → 1.0.0-alpha.41

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 (147) hide show
  1. package/dist/conformance/index.mjs +1 -1
  2. package/dist/index.d.mts +367 -31
  3. package/dist/index.d.ts +367 -31
  4. package/dist/index.mjs +1 -1
  5. package/dist/packem_shared/ADMIN_FUNCTIONS-DKos6M_I.mjs +1 -0
  6. package/dist/packem_shared/AGGREGATE_SQL_FUNCTION-m1iUU1rv.mjs +1 -0
  7. package/dist/packem_shared/AGG_COUNT-DLoWGwBC.mjs +1 -0
  8. package/dist/packem_shared/AUDIT_LOG_TABLE-ONxmEAIz.mjs +8 -0
  9. package/dist/packem_shared/CDC_LOG_TABLE-BknLCi4r.mjs +15 -0
  10. package/dist/packem_shared/CLIENT_WATERMARK_TABLE-CRnrAnJ2.mjs +7 -0
  11. package/dist/packem_shared/COMMIT_SEQ_FIELD-BUdOMG5y.mjs +4 -0
  12. package/dist/packem_shared/CountRlsUnsupportedError-Bdfupt3g.mjs +1 -0
  13. package/dist/packem_shared/DATA_MIGRATION_STATE_TABLE-CKRGRMxV.mjs +31 -0
  14. package/dist/packem_shared/DEFAULT_MAX_RELATION_KEYS-Bbyb7_rO.mjs +1 -0
  15. package/dist/packem_shared/DEFAULT_MAX_RELAYS-4Lslx8Qu.mjs +1 -0
  16. package/dist/packem_shared/DEFAULT_PROMOTION_THRESHOLDS-BDnVpbQ9.mjs +1 -0
  17. package/dist/packem_shared/DEFAULT_TRANSACTION_LIMITS-Bcoi7Bvf.mjs +1 -0
  18. package/dist/packem_shared/DurableStreamRunner-cq7kMv9M.mjs +1 -0
  19. package/dist/packem_shared/GEO_DEFAULT_PRECISION-CqpQZ-J_.mjs +1 -0
  20. package/dist/packem_shared/GLOBAL_SHAPE_SNAPSHOT_TABLE-BicDuO0a.mjs +7 -0
  21. package/dist/packem_shared/GlobalPollTick-BNK4o-XT.mjs +1 -0
  22. package/dist/packem_shared/IDEMPOTENCY_TABLE-DOpm_oMF.mjs +7 -0
  23. package/dist/packem_shared/MAIL_RETENTION-DGAQTHHs.mjs +18 -0
  24. package/dist/packem_shared/MAX_SQL_ROWS-gsiUV0Eo.mjs +5 -0
  25. package/dist/packem_shared/NotUniqueError-D5URxcDG.mjs +1 -0
  26. package/dist/packem_shared/QUEUE_TABLE-s7QJZvBz.mjs +17 -0
  27. package/dist/packem_shared/RANK_TIEBREAK-DBzb8aDX.mjs +1 -0
  28. package/dist/packem_shared/REACTOR_STATE_TABLE-QPRFyxMS.mjs +28 -0
  29. package/dist/packem_shared/RELATION_EXISTS_KEY-CFUhnZSZ.mjs +1 -0
  30. package/dist/packem_shared/REPROJECTION_MIGRATION_PREFIX-Czcb6_mO.mjs +1 -0
  31. package/dist/packem_shared/RLS_UNWRAP_SYMBOL-BWloGsd3.mjs +1 -0
  32. package/dist/packem_shared/ReactiveCache-gcV_jBm2.mjs +1 -0
  33. package/dist/packem_shared/SCAN_DEP-D7qE3iUe.mjs +1 -0
  34. package/dist/packem_shared/SCHEMA_HISTORY_MAX_VERSIONS-BluIj2s-.mjs +6 -0
  35. package/dist/packem_shared/SEARCH_STATE_TABLE-BCqn5ksa.mjs +1 -0
  36. package/dist/packem_shared/SHAPE_POKE_CURSOR_TABLE-ByJVDHds.mjs +8 -0
  37. package/dist/packem_shared/ShapeDiffCache-DLBPMAaA.mjs +1 -0
  38. package/dist/packem_shared/ShardRunner-C9p5DVOx.mjs +1 -0
  39. package/dist/packem_shared/UNVOUCHABLE_DEP-C68htACn.mjs +1 -0
  40. package/dist/packem_shared/aggregateTableName-XtEbp1DE.mjs +1 -0
  41. package/dist/packem_shared/appendStreamChunk-8eH4HB1Q.mjs +19 -0
  42. package/dist/packem_shared/applyOnDelete-VGMOvm-o.mjs +1 -0
  43. package/dist/packem_shared/applySelect-gwCG8hQF.mjs +1 -0
  44. package/dist/packem_shared/{armRestore-BNzdvQ_o.mjs → armRestore-Bu1_8SUa.mjs} +1 -1
  45. package/dist/packem_shared/awaitWsDrain-BpfFOTSS.mjs +1 -0
  46. package/dist/packem_shared/backfillAggregateIndexes-wsjTZz7k.mjs +1 -0
  47. package/dist/packem_shared/base64-DfpzS4o_.mjs +1 -0
  48. package/dist/packem_shared/buildIndexRange-CBKQmHSS.mjs +1 -0
  49. package/dist/packem_shared/buildPokeFrames-BvgtmTHk.mjs +1 -0
  50. package/dist/packem_shared/buildReprojectionMigration-DcEoW2QQ.mjs +1 -0
  51. package/dist/packem_shared/buildSettings-B4igo4rJ.mjs +1 -0
  52. package/dist/packem_shared/buildShapeDiff-DEPp9Rbv.mjs +1 -0
  53. package/dist/packem_shared/clearMemoryTables-BGbmag2i.mjs +1 -0
  54. package/dist/packem_shared/compileWhereSql-DMH7Qtzd.mjs +1 -0
  55. package/dist/packem_shared/computeRankPage-CfDhzXMF.mjs +1 -0
  56. package/dist/packem_shared/createCompanionSync-29Gp1xI_.mjs +1 -0
  57. package/dist/packem_shared/createReplicaLink-GrknD9FY.mjs +7 -0
  58. package/dist/packem_shared/createSystemReader-BtYeSMDb.mjs +1 -0
  59. package/dist/packem_shared/ctx-db-companions-B4gOYjdz.mjs +1 -0
  60. package/dist/packem_shared/ctx-db-relay-shapes-C93UQ7LV.mjs +17 -0
  61. package/dist/packem_shared/defineEngineContractSuite-Dvd03W9-.mjs +1 -0
  62. package/dist/packem_shared/diffExternalSource-DbHrcoZK.mjs +1 -0
  63. package/dist/packem_shared/do-sql-DqQTxsj_.mjs +1 -0
  64. package/dist/packem_shared/envOptionalPositiveInt-D2pY-c64.mjs +1 -0
  65. package/dist/packem_shared/estimate-bytes-CzG5x1f8.mjs +1 -0
  66. package/dist/packem_shared/exportShardRows-Cgt3ITwH.mjs +1 -0
  67. package/dist/packem_shared/hasTrigger-CjlwI4le.mjs +1 -0
  68. package/dist/packem_shared/isSoftDeleted-DvUFsJE9.mjs +9 -0
  69. package/dist/packem_shared/liftSourceId-CA3ENhXj.mjs +1 -0
  70. package/dist/packem_shared/materializeExternalRows-DmSW2ujk.mjs +1 -0
  71. package/dist/packem_shared/mergeChangedKeys-D1T-TPUb.mjs +1 -0
  72. package/dist/packem_shared/param-DlozcSQu.mjs +1 -0
  73. package/dist/packem_shared/quoteIdentifier-CObIFRhb.mjs +1 -0
  74. package/dist/packem_shared/runDrizzle-2ULFQR_k.mjs +1 -0
  75. package/dist/packem_shared/runShardMigrations-C4bvso2W.mjs +5 -0
  76. package/dist/packem_shared/runSocketPool-CZJ2X9cF.mjs +1 -0
  77. package/dist/packem_shared/selectExpiredIds-rvmKjueQ.mjs +1 -0
  78. package/dist/packem_shared/selectShapeMembers-Ce5Jr6UH.mjs +1 -0
  79. package/dist/packem_shared/serializeSqlValue-DbI1VQYM.mjs +1 -0
  80. package/dist/packem_shared/sibling-channel-Cxvk0Zca.mjs +1 -0
  81. package/dist/packem_shared/sql-projection-BqmxFxQU.mjs +1 -0
  82. package/dist/packem_shared/stableStringify-G9OF5wcs.mjs +1 -0
  83. package/dist/packem_shared/stableWireKey-BC6DtQic.mjs +1 -0
  84. package/dist/packem_shared/where-sql-DxCbgqDJ.mjs +1 -0
  85. package/dist/packem_shared/wire-codec-CDds5uQW.mjs +1 -0
  86. package/package.json +3 -3
  87. package/dist/packem_shared/ADMIN_FUNCTIONS-B0xlQJ4w.mjs +0 -1
  88. package/dist/packem_shared/AGGREGATE_SQL_FUNCTION-QYaiuty4.mjs +0 -1
  89. package/dist/packem_shared/AGG_COUNT-BWXe3gtQ.mjs +0 -1
  90. package/dist/packem_shared/AUDIT_LOG_TABLE-CaA0jL0L.mjs +0 -8
  91. package/dist/packem_shared/CDC_LOG_TABLE-BnqlH2eZ.mjs +0 -8
  92. package/dist/packem_shared/CLIENT_WATERMARK_TABLE-CXsSLU8D.mjs +0 -7
  93. package/dist/packem_shared/CountRlsUnsupportedError-B2WKJD9v.mjs +0 -1
  94. package/dist/packem_shared/DATA_MIGRATION_STATE_TABLE-BZMVrLcy.mjs +0 -31
  95. package/dist/packem_shared/DEFAULT_MAX_RELATION_KEYS-bq00btqV.mjs +0 -1
  96. package/dist/packem_shared/DEFAULT_MAX_RELAYS-CnCyh6oX.mjs +0 -1
  97. package/dist/packem_shared/DEFAULT_PROMOTION_THRESHOLDS-Dteg0sZF.mjs +0 -1
  98. package/dist/packem_shared/DEFAULT_TRANSACTION_LIMITS--TtB8Gpo.mjs +0 -1
  99. package/dist/packem_shared/FTS_COUNT_COLUMN-D1gY3wwZ-CZHdaRrd.mjs +0 -1
  100. package/dist/packem_shared/GEO_DEFAULT_PRECISION-okRCkZ6r.mjs +0 -1
  101. package/dist/packem_shared/GLOBAL_SHAPE_SNAPSHOT_TABLE-DX-6-gBP.mjs +0 -7
  102. package/dist/packem_shared/IDEMPOTENCY_TABLE-DjkEMp6w.mjs +0 -7
  103. package/dist/packem_shared/MAIL_RETENTION-KmozO2NQ.mjs +0 -18
  104. package/dist/packem_shared/MAX_SQL_ROWS-nMwkxv5f.mjs +0 -2
  105. package/dist/packem_shared/NotUniqueError-iGKd9wRR.mjs +0 -1
  106. package/dist/packem_shared/QUEUE_TABLE-DYCDvzTG.mjs +0 -17
  107. package/dist/packem_shared/RANK_TIEBREAK-9NU5s_mi.mjs +0 -1
  108. package/dist/packem_shared/RELATION_EXISTS_KEY-BaqSIFU1.mjs +0 -1
  109. package/dist/packem_shared/RLS_UNWRAP_SYMBOL-C6_WX3dG.mjs +0 -1
  110. package/dist/packem_shared/ReactiveCache-CF21t8IB.mjs +0 -1
  111. package/dist/packem_shared/SCAN_DEP-D_yR9EeV.mjs +0 -1
  112. package/dist/packem_shared/SCHEMA_HISTORY_MAX_VERSIONS-CHXz6p_z.mjs +0 -6
  113. package/dist/packem_shared/SEARCH_STATE_TABLE-eLN8U5tz.mjs +0 -1
  114. package/dist/packem_shared/ShardRunner-DIqVdWtk.mjs +0 -1
  115. package/dist/packem_shared/aggregateTableName-G-eXyjcz.mjs +0 -1
  116. package/dist/packem_shared/applyOnDelete-uFRC5p1d.mjs +0 -1
  117. package/dist/packem_shared/applySelect-B0CF8T7y.mjs +0 -1
  118. package/dist/packem_shared/awaitWsDrain-Dk50ISgE.mjs +0 -1
  119. package/dist/packem_shared/backfillAggregateIndexes-BHiewuB-.mjs +0 -1
  120. package/dist/packem_shared/buildIndexRange-DIjFVgeO.mjs +0 -1
  121. package/dist/packem_shared/buildPokeFrames-DaPpm5Ss.mjs +0 -1
  122. package/dist/packem_shared/buildSettings-DT18_DkX.mjs +0 -1
  123. package/dist/packem_shared/compileWhereSql-BLcfs4QW.mjs +0 -1
  124. package/dist/packem_shared/computeRankPage-IUSS-zIB.mjs +0 -1
  125. package/dist/packem_shared/createCompanionSync-DWK0Vlg1.mjs +0 -1
  126. package/dist/packem_shared/createReadFootprint-DIrrxRTE.mjs +0 -1
  127. package/dist/packem_shared/createSystemReader-DcDcrtM3.mjs +0 -1
  128. package/dist/packem_shared/defineEngineContractSuite-BefTibvY.mjs +0 -1
  129. package/dist/packem_shared/diffExternalSource-DMpkJta1.mjs +0 -1
  130. package/dist/packem_shared/estimate-bytes-DzD3PdCc.mjs +0 -1
  131. package/dist/packem_shared/exportShardRows-kt42wijd.mjs +0 -1
  132. package/dist/packem_shared/hasTrigger-CbkOHExZ.mjs +0 -1
  133. package/dist/packem_shared/isSoftDeleted-B-SXkGUo.mjs +0 -9
  134. package/dist/packem_shared/liftSourceId-DApAbu7Q.mjs +0 -1
  135. package/dist/packem_shared/materializeExternalRows-DOQJV9p2.mjs +0 -1
  136. package/dist/packem_shared/mergeChangedKeys-CvSHlkv-.mjs +0 -1
  137. package/dist/packem_shared/param-B5lF5Jd9.mjs +0 -1
  138. package/dist/packem_shared/quote-identifier-CGiYFBvY.mjs +0 -1
  139. package/dist/packem_shared/runDrizzle-GKR3y97k.mjs +0 -1
  140. package/dist/packem_shared/runShardMigrations-CPxqCh3O.mjs +0 -5
  141. package/dist/packem_shared/runSocketPool-DPQLVyWF.mjs +0 -1
  142. package/dist/packem_shared/selectExpiredIds-FzhIEeG1.mjs +0 -1
  143. package/dist/packem_shared/selectShapeMemberIds-DvE7K6zG.mjs +0 -1
  144. package/dist/packem_shared/serializeSqlValue-DnpyaLcw.mjs +0 -1
  145. package/dist/packem_shared/stableStringify-BjLh4gvA.mjs +0 -1
  146. package/dist/packem_shared/stableWireKey-YEHLaX6X.mjs +0 -1
  147. package/dist/packem_shared/wire-codec-Ctnni0h6.mjs +0 -1
package/dist/index.d.mts CHANGED
@@ -180,9 +180,11 @@ interface SchemaLike {
180
180
  }
181
181
  interface TableDefinitionLike {
182
182
  readonly aggregateIndexes?: ReadonlyArray<AggregateIndexDefinitionLike>;
183
+ readonly commitOrderedMode?: boolean;
183
184
  readonly geoIndexes?: ReadonlyArray<GeoIndexDefinitionLike>;
184
185
  readonly indexes: ReadonlyArray<IndexDefinitionLike>;
185
186
  readonly isPublic?: boolean;
187
+ readonly memoryMode?: boolean;
186
188
  readonly rankIndexes?: ReadonlyArray<RankIndexDefinitionLike>;
187
189
  readonly relationMap?: Record<string, RelationDefinitionLike>;
188
190
  readonly searchIndexes?: ReadonlyArray<SearchIndexDefinitionLike>;
@@ -230,6 +232,7 @@ interface ResolveWithOptions {
230
232
  groupedCounter: (tableName: string, whereField: string, values: unknown[], policyWhere?: WhereInput) => Promise<Map<unknown, number>>;
231
233
  parents: Record<string, unknown>[];
232
234
  relationBaseWhere?: (table: string) => undefined | WhereInput;
235
+ relationMask?: RelationMask;
233
236
  schema: {
234
237
  readonly tables: Record<string, TableDefinitionLike>;
235
238
  };
@@ -248,13 +251,22 @@ interface QueryArgs {
248
251
  cursor?: null | string;
249
252
  includeDeleted?: boolean;
250
253
  limit?: number;
254
+ omitContinueCursor?: boolean;
251
255
  orderBy?: OrderByInput[];
252
256
  relationBaseWhere?: (table: string) => undefined | WhereInput;
257
+ relationMask?: RelationMask;
253
258
  restrictsCounts?: boolean;
254
259
  select?: ReadonlyArray<string>;
255
260
  where?: WhereInput;
256
261
  with?: WithInput;
257
262
  }
263
+ interface CrossShardReadArgs {
264
+ orderBy?: OrderByInput[];
265
+ relationPolicies?: Record<string, WhereInput>;
266
+ where?: WhereInput;
267
+ with?: WithInput;
268
+ }
269
+ type RelationMask = (table: string, rows: Record<string, unknown>[]) => Record<string, unknown>[];
258
270
  interface QueryPage {
259
271
  continueCursor: null | string;
260
272
  isDone: boolean;
@@ -359,9 +371,21 @@ interface GeoFilterBuilderLike {
359
371
  };
360
372
  }) => GeoFilterBuilderLike;
361
373
  }
374
+ type ScoredDocument = GeoScoredDocument | SearchScoredDocument;
375
+ interface GeoScoredDocument {
376
+ distanceMeters: null | number;
377
+ document: Record<string, unknown>;
378
+ score?: never;
379
+ }
380
+ interface SearchScoredDocument {
381
+ distanceMeters?: never;
382
+ document: Record<string, unknown>;
383
+ score: number;
384
+ }
362
385
  interface TableReaderLike {
363
386
  [Symbol.asyncIterator]: () => AsyncIterator<Record<string, unknown>>;
364
387
  collect: () => Promise<Record<string, unknown>[]>;
388
+ collectWithScores: () => Promise<ScoredDocument[]>;
365
389
  filter: (predicate: (document: Record<string, unknown>) => boolean) => TableReaderLike;
366
390
  first: () => Promise<Record<string, unknown> | null>;
367
391
  order: (direction: "asc" | "desc") => TableReaderLike;
@@ -402,6 +426,13 @@ interface MutationDelta {
402
426
  interface DatabaseWriterLike {
403
427
  aggregate: (tableName: string, options: AggregateOptions) => Promise<AggregateResult>;
404
428
  asId?: (tableName: string, id: string) => string;
429
+ cdcChangedTables?: (sinceSeq: number, options?: {
430
+ cursorOnly?: boolean;
431
+ }) => Promise<{
432
+ cursor: number;
433
+ floor?: number;
434
+ tables: string[];
435
+ } | undefined>;
405
436
  count: (tableName: string, where?: RestrictableQueryOptions | WhereInput) => Promise<number>;
406
437
  delete: (id: string, expectedTable?: string, options?: {
407
438
  hard?: boolean;
@@ -600,6 +631,7 @@ declare class ReactiveCache {
600
631
  };
601
632
  private dropRangeDeps;
602
633
  private collectAndDrop;
634
+ private dropKeys;
603
635
  private dropEntry;
604
636
  private evict;
605
637
  }
@@ -638,12 +670,18 @@ interface RunTriggersOptions {
638
670
  }
639
671
  declare const runTriggers: (options: RunTriggersOptions) => Promise<void>;
640
672
  declare const hasTrigger: (schema: SchemaLike, tableName: string, op: TriggerOpLike) => boolean;
673
+ interface SearchBackfillProgress {
674
+ done: boolean;
675
+ pages: number;
676
+ }
641
677
  declare const backfillAggregateIndexes: (sql: SqlExec, schema: SchemaLike) => void;
642
678
  declare const backfillRankIndexes: (sql: SqlExec, schema: SchemaLike) => void;
643
679
  declare const backfillSearchIndexesForTable: (sql: SqlExec, tableName: string, definition: {
644
680
  searchIndexes?: ReadonlyArray<SearchIndexDefinitionLike>;
645
681
  }) => void;
646
- declare const backfillSearchIndexes: (sql: SqlExec, schema: SchemaLike) => void;
682
+ declare const backfillSearchIndexes: (sql: SqlExec, schema: SchemaLike, options?: {
683
+ maxPages?: number;
684
+ }) => SearchBackfillProgress;
647
685
  declare const CDC_LOG_TABLE = "__cdc_log";
648
686
  interface CdcChange {
649
687
  doc?: Record<string, unknown>;
@@ -653,6 +691,7 @@ interface CdcChange {
653
691
  table: string;
654
692
  ts: number;
655
693
  }
694
+ declare const CDC_LOG_TABLE_SEQ_INDEX = "__cdc_log_table_seq";
656
695
  declare const migrateCdcLog: (sql: SqlExec) => void;
657
696
  declare const appendCdcChange: (sql: SqlExec, ts: number, table: string, id: string, op: CdcChange["op"], doc: Record<string, unknown> | undefined) => void;
658
697
  declare const readCdcChanges: (sql: SqlExec, options?: {
@@ -663,9 +702,22 @@ declare const readCdcChanges: (sql: SqlExec, options?: {
663
702
  changes: CdcChange[];
664
703
  cursor: number;
665
704
  };
666
- declare const trimCdcChanges: (sql: SqlExec, throughSeq: number) => void;
705
+ declare const cdcTouchesTables: (sql: SqlExec, sinceSeq: number, tables: ReadonlySet<string>) => boolean;
706
+ declare const cdcCanVouchFor: (sql: SqlExec, deps: ReadonlySet<string>) => boolean;
707
+ interface CdcChangeKey {
708
+ id: string;
709
+ op: CdcChange["op"];
710
+ seq: number;
711
+ }
712
+ declare const readCdcChangeKeys: (sql: SqlExec, table: string, sinceSeq: number, upTo: number) => CdcChangeKey[];
713
+ declare const trimCdcChanges: (sql: SqlExec, throughSeq: number, maxRows: number) => void;
714
+ declare const compactCdcDocs: (sql: SqlExec, throughSeq: number, maxRows: number) => void;
715
+ declare const cdcSeqLeavingRows: (sql: SqlExec, keep: number) => number | undefined;
667
716
  declare const readCdcCursor: (sql: SqlExec) => number;
717
+ declare const cursorBelowRetainedFloor: (floor: number | undefined, sinceSeq: number) => boolean;
718
+ declare const cdcTrimmedError: (floor: number, sinceSeq: number, scope: "global" | "shard") => LunoraError;
668
719
  declare const minCdcSeq: (sql: SqlExec) => number | undefined;
720
+ declare const minCdcReplayableSeq: (sql: SqlExec) => number | undefined;
669
721
  declare const CDC_META_TABLE = "__cdc_meta";
670
722
  declare const migrateCdcMeta: (sql: SqlExec) => void;
671
723
  declare const readCdcEpoch: (sql: SqlExec) => string;
@@ -735,7 +787,7 @@ interface ShapeRow {
735
787
  id: string;
736
788
  }
737
789
  declare const selectShapeRows: (sql: SqlExec, table: string, effectiveWhere: WhereInput | undefined) => ShapeRow[];
738
- declare const selectShapeMemberIds: (sql: SqlExec, table: string, effectiveWhere: WhereInput | undefined, ids: ReadonlyArray<string>) => Set<string>;
790
+ declare const selectShapeMembers: (sql: SqlExec, table: string, effectiveWhere: WhereInput | undefined, ids: ReadonlyArray<string>) => Map<string, Record<string, unknown>>;
739
791
  interface SqlExec {
740
792
  exec: <Row = Record<string, unknown>>(sql: string, ...params: unknown[]) => SqlCursor<Row>;
741
793
  }
@@ -764,6 +816,7 @@ interface CtxDbOptions {
764
816
  globalDb?: DatabaseWriterLike;
765
817
  headroom?: TransactionHeadroomTracker;
766
818
  idGenerator?: IdGenerator;
819
+ inTransaction?: () => boolean;
767
820
  maxRelationKeys?: number;
768
821
  onIndexUse?: IndexUseHook;
769
822
  onRead?: ReadHook;
@@ -803,6 +856,11 @@ declare const readAuditLog: (sql: SqlExec, options?: {
803
856
  limit?: number;
804
857
  sinceSeq?: number;
805
858
  }) => AuditEntry[];
859
+ declare const COMMIT_SEQ_TABLE = "__commit_seq";
860
+ declare const COMMIT_SEQ_FIELD = "_commitSeq";
861
+ declare const migrateCommitSeq: (sql: SqlExec) => void;
862
+ declare const readCommitSeq: (sql: SqlExec) => number;
863
+ declare const allocateCommitSeq: (sql: SqlExec) => number;
806
864
  interface SubscriptionQuery {
807
865
  args?: Record<string, unknown>;
808
866
  functionPath?: string;
@@ -817,9 +875,11 @@ interface ShapeSubscriptionQuery {
817
875
  sinceSeq?: number;
818
876
  }
819
877
  interface SubscriptionEnvelope {
878
+ caps?: string[];
820
879
  clientId?: string;
821
880
  context?: Record<string, unknown>;
822
881
  data?: unknown;
882
+ generation?: number;
823
883
  id: string;
824
884
  query?: SubscriptionQuery;
825
885
  shape?: {
@@ -827,6 +887,7 @@ interface SubscriptionEnvelope {
827
887
  name: string;
828
888
  };
829
889
  sinceCheckpoint?: number;
890
+ sinceChunk?: number;
830
891
  sinceEpoch?: string;
831
892
  topic?: string;
832
893
  type: "ack" | "connect" | "shape_subscribe" | "shape_unsubscribe" | "stream" | "subscribe" | "unsubscribe" | "whisper" | "whisper_subscribe" | "whisper_unsubscribe";
@@ -843,6 +904,7 @@ interface SocketAttachment {
843
904
  context?: Record<string, unknown>;
844
905
  expiresAt?: number;
845
906
  identity?: Record<string, unknown>;
907
+ pageDeltas?: boolean;
846
908
  shapes?: Record<string, ShapeSubscriptionQuery>;
847
909
  subs: Record<string, SubscriptionQuery>;
848
910
  userId?: string;
@@ -888,6 +950,9 @@ interface CompanionSync {
888
950
  syncSearch: (tableName: string, id: string, document: Record<string, unknown> | undefined, previous?: Record<string, unknown>) => void;
889
951
  }
890
952
  declare const createCompanionSync: (deps: CompanionSyncDeps) => CompanionSync;
953
+ declare const isMemoryTable: (definition: TableDefinitionLike | undefined) => boolean;
954
+ declare const memoryTableNames: (schema: SchemaLike) => string[];
955
+ declare const clearMemoryTables: (sql: SqlExec, schema: SchemaLike) => number;
891
956
  interface RankPageDeps {
892
957
  assertRankPartitionLocal: (tableName: string, definition: TableDefinitionLike, index: RankIndexDefinitionLike) => void;
893
958
  ensureRankBackfilled: (tableName: string, index: RankIndexDefinitionLike) => void;
@@ -907,6 +972,19 @@ interface RankPageComputation {
907
972
  }
908
973
  declare const hydrateDocsById: (deps: RankPageDeps, tableName: string, ids: ReadonlyArray<string>) => Map<string, Record<string, unknown>>;
909
974
  declare const computeRankPage: (deps: RankPageDeps, tableName: string, indexName: string, rankPageOptions: RankPageOptions) => RankPageComputation;
975
+ declare const SHAPE_POKE_CURSOR_TABLE = "__shape_poke_cursor";
976
+ declare const migrateShapePokeCursor: (sql: SqlExec) => void;
977
+ declare const readShapePokeCursor: (sql: SqlExec, connectionId: string, subId: string) => number | undefined;
978
+ declare const writeShapePokeCursor: (sql: SqlExec, connectionId: string, subId: string, cursor: number) => void;
979
+ interface ShapePokeCursorRow {
980
+ connectionId: string;
981
+ cursor: number;
982
+ subId: string;
983
+ }
984
+ declare const writeShapePokeCursors: (sql: SqlExec, rows: ReadonlyArray<ShapePokeCursorRow>) => void;
985
+ declare const minShapePokeCursor: (sql: SqlExec) => number | undefined;
986
+ declare const deleteShapePokeCursor: (sql: SqlExec, connectionId: string, subId: string) => void;
987
+ declare const deleteShapePokeCursorsForConnection: (sql: SqlExec, connectionId: string) => void;
910
988
  declare const DATA_MIGRATION_STATE_TABLE = "__lunora_migrations";
911
989
  type MigrationDirection = "down" | "up";
912
990
  type MigrationStatus = "completed" | "failed" | "in_progress";
@@ -970,10 +1048,10 @@ interface DependencyTracker {
970
1048
  declare const createDependencyTracker: () => DependencyTracker;
971
1049
  declare const runSql: <Row = Record<string, unknown>>(sql: SqlExec, query: string, ...params: unknown[]) => SqlCursor<Row>;
972
1050
  declare const runDrizzle: <Row = Record<string, unknown>>(exec: SqlExec, query: SQL) => SqlCursor<Row>;
1051
+ declare const quoteIdentifier: (name: string) => string;
973
1052
  declare const serializeSqlValue: (value: unknown) => unknown;
974
1053
  declare const DOC_COLUMN = "__doc__";
975
1054
  declare const geoTableName: (table: string, indexName: string) => string;
976
- declare const quoteIdentifier: (name: string) => string;
977
1055
  declare const jsonPath: (field: string) => string;
978
1056
  declare const jsonPathSql: (field: string) => SQL;
979
1057
  declare const qualifiedJsonPath: (table: string, field: string) => string;
@@ -983,7 +1061,7 @@ declare const AGG_KEY: Name;
983
1061
  declare const AGG_VALUE: Name;
984
1062
  declare const AGG_COUNT: Name;
985
1063
  declare const aggUpsertSql: (aggTable: string, key: unknown, value: unknown, count: unknown, set: SQL) => SQL;
986
- declare const tableColumns: (definition: TableDefinitionLike) => [string, ColumnMetaLike][];
1064
+ declare const tableColumns: (definition: TableDefinitionLike) => ReadonlyArray<readonly [string, ColumnMetaLike]>;
987
1065
  declare const rowToDocument: (row: Record<string, unknown> | undefined) => Record<string, unknown> | undefined;
988
1066
  declare const tryRowToDocument: (row: Record<string, unknown> | undefined) => Record<string, unknown> | undefined;
989
1067
  declare const isFtsAvailable: (sql: SqlExec) => boolean;
@@ -994,6 +1072,79 @@ interface RenderedSql {
994
1072
  }
995
1073
  declare const renderSql: (engine: SqlEngine, query: SQL) => RenderedSql;
996
1074
  declare const param: (value: unknown) => SQL;
1075
+ declare const unionAll: (branches: ReadonlyArray<SQL>) => SQL;
1076
+ declare const sqliteInList: (reference: SQL, items: ReadonlyArray<unknown>, negated: boolean, budget?: number) => SQL;
1077
+ type DurableStreamStatus = "complete" | "error" | "running";
1078
+ interface DurableStreamRun {
1079
+ error?: string;
1080
+ errorCode?: string;
1081
+ lastSeq: number;
1082
+ startedAt: number;
1083
+ status: DurableStreamStatus;
1084
+ }
1085
+ interface DurableStreamChunk {
1086
+ dataJson: string;
1087
+ seq: number;
1088
+ }
1089
+ declare const migrateDurableStreams: (sql: SqlExec) => void;
1090
+ declare const readStreamRun: (sql: SqlExec, runKey: string) => DurableStreamRun | undefined;
1091
+ declare const claimStreamRun: (sql: SqlExec, runKey: string, startedAt: number, ttlMs: number) => boolean;
1092
+ declare const deleteStreamRun: (sql: SqlExec, runKey: string) => void;
1093
+ declare const appendStreamChunk: (sql: SqlExec, runKey: string, seq: number, dataJson: string) => void;
1094
+ declare const readStreamChunks: (sql: SqlExec, runKey: string, sinceSeq: number) => DurableStreamChunk[];
1095
+ declare const finishStreamRun: (sql: SqlExec, runKey: string, status: "complete" | "error", lastSeq: number, failure?: {
1096
+ code: string;
1097
+ message: string;
1098
+ }) => void;
1099
+ declare const trimStreamRuns: (sql: SqlExec, now: number) => void;
1100
+ declare const MAX_DURABLE_STREAM_CHUNKS = 50000;
1101
+ declare const MAX_DURABLE_STREAM_BYTES: number;
1102
+ interface DurableStreamSink {
1103
+ readonly chunk: (chunk: {
1104
+ data: unknown;
1105
+ generation?: number;
1106
+ seq: number;
1107
+ }) => boolean;
1108
+ readonly complete: () => void;
1109
+ readonly fail: (failure: {
1110
+ code: string;
1111
+ message: string;
1112
+ }) => void;
1113
+ }
1114
+ type DurableAttachDecision = "attach" | "interrupted" | "reclaim" | "replay-terminal";
1115
+ declare const decideDurableAttach: (run: DurableStreamRun | undefined, context: {
1116
+ generation?: number;
1117
+ live?: {
1118
+ generation: number;
1119
+ };
1120
+ resuming: boolean;
1121
+ }) => DurableAttachDecision;
1122
+ interface DurableStreamAttach {
1123
+ readonly generation?: number;
1124
+ readonly iterator: (signal: AbortSignal) => AsyncIterable<unknown>;
1125
+ readonly runKey: string;
1126
+ readonly sinceChunk: number;
1127
+ readonly sink: DurableStreamSink;
1128
+ readonly ttlMs?: number;
1129
+ }
1130
+ declare class DurableStreamRunner {
1131
+ private lastTrimAt;
1132
+ private readonly runs;
1133
+ private readonly sql;
1134
+ private readonly waitUntil;
1135
+ constructor(dependencies: {
1136
+ sql: () => SqlExec;
1137
+ waitUntil?: (promise: Promise<unknown>) => void;
1138
+ });
1139
+ attach(request: DurableStreamAttach): Promise<void>;
1140
+ detach(runKey: string, sink: DurableStreamSink): void;
1141
+ isLive(runKey: string): boolean;
1142
+ private attachOrThrow;
1143
+ private produce;
1144
+ private trim;
1145
+ }
1146
+ declare const envPositiveInt: (env: unknown, key: string, fallback: number) => number;
1147
+ declare const envOptionalPositiveInt: (env: unknown, key: string) => number | undefined;
997
1148
  interface ExternalSourceDiffResult {
998
1149
  changes: CdcChange[];
999
1150
  nextBaseline: Map<string, string>;
@@ -1073,6 +1224,19 @@ declare const coveringGeohashes: (center: GeoPoint, radiusMeters: number) => str
1073
1224
  declare const pointInBoundingBox: (point: GeoPoint, box: GeoBoundingBox) => boolean;
1074
1225
  declare const boundingBoxCenter: (box: GeoBoundingBox) => GeoPoint;
1075
1226
  declare const boundingBoxGeohashes: (box: GeoBoundingBox) => string[];
1227
+ declare class GlobalPollTick {
1228
+ private readonly changedTables;
1229
+ private readonly reads;
1230
+ private resync;
1231
+ private skippedCount;
1232
+ constructor(changedTables?: Set<string>);
1233
+ get readCount(): number;
1234
+ get resyncRequested(): boolean;
1235
+ get skipped(): number;
1236
+ requestResync(): void;
1237
+ rows(key: string | undefined, load: () => Promise<ShapeRow[]>): Promise<ShapeRow[]>;
1238
+ shouldRead(table: string): boolean;
1239
+ }
1076
1240
  declare const ADMIN_FUNCTION_PREFIX = "__lunora_admin__:";
1077
1241
  declare const RELATION_FUNCTION_PREFIX = "__lunora_relation__:";
1078
1242
  declare const FLAGS_FUNCTION_PREFIX = "__lunora_flags__:";
@@ -1083,6 +1247,7 @@ declare const ADMIN_FUNCTIONS: {
1083
1247
  readonly aiGenerateSql: "__lunora_admin__:aiGenerateSql";
1084
1248
  readonly aiTableFilter: "__lunora_admin__:aiTableFilter";
1085
1249
  readonly assignIssue: "__lunora_admin__:assignIssue";
1250
+ readonly backfillSearch: "__lunora_admin__:backfillSearch";
1086
1251
  readonly backRelationCounts: "__lunora_admin__:backRelationCounts";
1087
1252
  readonly cdcSync: "__lunora_admin__:cdcSync";
1088
1253
  readonly clearCapturedMail: "__lunora_admin__:clearCapturedMail";
@@ -1107,6 +1272,7 @@ declare const ADMIN_FUNCTIONS: {
1107
1272
  readonly getMetricSeries: "__lunora_admin__:getMetricSeries";
1108
1273
  readonly listSubscriptions: "__lunora_admin__:listSubscriptions";
1109
1274
  readonly listTableIndexes: "__lunora_admin__:listTableIndexes";
1275
+ readonly listTablesIndexes: "__lunora_admin__:listTablesIndexes";
1110
1276
  readonly getLogs: "__lunora_admin__:getLogs";
1111
1277
  readonly getMetrics: "__lunora_admin__:getMetrics";
1112
1278
  readonly getPitrBookmark: "__lunora_admin__:getPitrBookmark";
@@ -1120,6 +1286,7 @@ declare const ADMIN_FUNCTIONS: {
1120
1286
  readonly ignoreIssue: "__lunora_admin__:ignoreIssue";
1121
1287
  readonly importShard: "__lunora_admin__:importShard";
1122
1288
  readonly listFlags: "__lunora_admin__:listFlags";
1289
+ readonly listReactors: "__lunora_admin__:listReactors";
1123
1290
  readonly listQueues: "__lunora_admin__:listQueues";
1124
1291
  readonly lintSql: "__lunora_admin__:lintSql";
1125
1292
  readonly listTables: "__lunora_admin__:listTables";
@@ -1199,9 +1366,15 @@ interface TableIndexInfo {
1199
1366
  interface TableIndexesResult {
1200
1367
  indexes: TableIndexInfo[];
1201
1368
  }
1369
+ interface TablesIndexesResult {
1370
+ indexesByTable: Record<string, TableIndexInfo[]>;
1371
+ }
1202
1372
  interface ColumnMeta {
1373
+ bucket?: string;
1374
+ enumValues?: string[];
1203
1375
  isStorage?: boolean;
1204
1376
  name: string;
1377
+ nullable?: boolean;
1205
1378
  optional: boolean;
1206
1379
  pk?: boolean;
1207
1380
  ref?: string;
@@ -1229,12 +1402,13 @@ interface AdvisoriesResult {
1229
1402
  advisories: AdvisoryFinding[];
1230
1403
  }
1231
1404
  interface AdvisorProcedure {
1232
- callsMail: boolean;
1405
+ analyzableBody?: boolean;
1406
+ callsMail?: boolean;
1233
1407
  emitsEvent?: boolean;
1234
1408
  exempt?: boolean;
1235
1409
  exemptReason?: string;
1236
1410
  exportName: string;
1237
- fanOut: boolean;
1411
+ fanOut?: boolean;
1238
1412
  file: string;
1239
1413
  handlesErrors?: boolean;
1240
1414
  hasEmailArg?: boolean;
@@ -1242,15 +1416,15 @@ interface AdvisorProcedure {
1242
1416
  reachesOutbound?: boolean;
1243
1417
  runsAiGeneration?: boolean;
1244
1418
  throwsBareError?: boolean;
1245
- unboundedAiGeneration: boolean;
1419
+ unboundedAiGeneration?: boolean;
1246
1420
  usesCaptcha: boolean;
1247
1421
  usesEmailGate: boolean;
1248
- usesInsertManyUnsafe: boolean;
1422
+ usesInsertManyUnsafe?: boolean;
1249
1423
  usesMask: boolean;
1250
1424
  usesRateLimit: boolean;
1251
1425
  usesRls: boolean;
1252
1426
  visibility: "internal" | "public";
1253
- writesUserTable: boolean;
1427
+ writesUserTable?: boolean;
1254
1428
  }
1255
1429
  interface AdvisorProceduresResult {
1256
1430
  procedures: AdvisorProcedure[];
@@ -1315,6 +1489,19 @@ interface FlagsResult {
1315
1489
  configured: boolean;
1316
1490
  flags: FlagEvaluation[];
1317
1491
  }
1492
+ interface ReactorMetadata {
1493
+ errors: number;
1494
+ lastError?: string;
1495
+ lastRanAt?: number;
1496
+ path: string;
1497
+ runs: number;
1498
+ state: "active" | "failing" | "idle";
1499
+ suppressed: number;
1500
+ tables?: ReadonlyArray<string>;
1501
+ }
1502
+ interface ReactorsResult {
1503
+ reactors: ReactorMetadata[];
1504
+ }
1318
1505
  interface WorkflowMetadata {
1319
1506
  binding: string;
1320
1507
  className: string;
@@ -1452,12 +1639,22 @@ interface FanoutPathCounters {
1452
1639
  socketsIterated: number;
1453
1640
  totalMs: number;
1454
1641
  }
1642
+ interface ShapeProbeCounters {
1643
+ run: number;
1644
+ served: number;
1645
+ }
1646
+ interface GlobalPollCounters {
1647
+ drains: number;
1648
+ pairsSkipped: number;
1649
+ }
1455
1650
  interface FanoutMetricsResult {
1651
+ globalPoll: GlobalPollCounters;
1456
1652
  maxRelays: number;
1457
1653
  peakSubscribers: number;
1458
1654
  promoted: boolean;
1459
1655
  relayCount: number;
1460
1656
  shapePoke: FanoutPathCounters;
1657
+ shapeProbe: ShapeProbeCounters;
1461
1658
  sinceMs: number;
1462
1659
  topics: FanoutTopicStat[];
1463
1660
  totalConnections: number;
@@ -1471,6 +1668,10 @@ interface FanoutAttachmentLike {
1471
1668
  }
1472
1669
  declare const DEFAULT_FANOUT_TOPIC_LIMIT = 20;
1473
1670
  declare const createFanoutCounters: () => FanoutPathCounters;
1671
+ declare const createShapeProbeCounters: () => ShapeProbeCounters;
1672
+ declare const createGlobalPollCounters: () => GlobalPollCounters;
1673
+ declare const recordGlobalPollPass: (counters: GlobalPollCounters, drains: number, pairsSkipped: number) => GlobalPollCounters;
1674
+ declare const recordShapeProbePass: (counters: ShapeProbeCounters, run: number, served: number) => ShapeProbeCounters;
1474
1675
  declare const recordFanoutPass: (counters: FanoutPathCounters, iterated: number, delivered: number, ms: number) => FanoutPathCounters;
1475
1676
  declare const summarizeFanoutTopics: (attachments: FanoutAttachmentLike[], limit?: number) => {
1476
1677
  peakSubscribers: number;
@@ -1592,7 +1793,6 @@ declare const clearQueueMessages: (sql: SqlExec) => {
1592
1793
  declare const encodePartitionKey: (partitionBy: ReadonlyArray<string>, source: Record<string, unknown>) => string;
1593
1794
  declare const RANK_TIEBREAK = "__id__";
1594
1795
  declare const sortColumnName: (i: number) => string;
1595
- declare const matchesRankStaticWhere: (document: Record<string, unknown>, predicate: Record<string, unknown>) => boolean;
1596
1796
  declare const resolveRankPartition: (index: RankIndexDefinitionLike, where: Record<string, unknown> | undefined) => Record<string, unknown> | undefined;
1597
1797
  declare const rankTableName: (table: string, indexName: string) => string;
1598
1798
  declare const rankKeyFromDocument: (index: RankIndexDefinitionLike, document_: Record<string, unknown>) => {
@@ -1600,6 +1800,35 @@ declare const rankKeyFromDocument: (index: RankIndexDefinitionLike, document_: R
1600
1800
  rowId: string;
1601
1801
  sortValues: unknown[];
1602
1802
  };
1803
+ declare const matchesRankStaticWhere: (document: Record<string, unknown>, predicate: Record<string, unknown>) => boolean;
1804
+ declare const REACTOR_STATE_TABLE = "__reactor_state";
1805
+ interface ReactorState {
1806
+ digest: string;
1807
+ lastError?: string;
1808
+ lastRanAt: number;
1809
+ stats: ReactorStats;
1810
+ tables?: ReadonlyArray<string>;
1811
+ }
1812
+ interface ReactorStats {
1813
+ errors: number;
1814
+ runs: number;
1815
+ suppressed: number;
1816
+ }
1817
+ declare const migrateReactorState: (sql: SqlExec) => void;
1818
+ declare const readReactorState: (sql: SqlExec, path: string) => ReactorState | undefined;
1819
+ declare const listReactorStates: (sql: SqlExec) => {
1820
+ path: string;
1821
+ state: ReactorState;
1822
+ }[];
1823
+ type ReactorDispatchResult = "error" | "ran" | "suppressed";
1824
+ declare const writeReactorState: (sql: SqlExec, path: string, outcome: {
1825
+ digest?: string;
1826
+ error?: string;
1827
+ now: number;
1828
+ result: ReactorDispatchResult;
1829
+ tables?: ReadonlyArray<string>;
1830
+ }) => void;
1831
+ declare const reactorNeedsRun: (state: Pick<ReactorState, "tables"> | undefined, changed: ReadonlySet<string>) => boolean;
1603
1832
  interface ReadFootprint {
1604
1833
  onRead: (table: string, idOrScan?: string) => void;
1605
1834
  onReadRange: (range: KeyRange) => void;
@@ -1607,6 +1836,8 @@ interface ReadFootprint {
1607
1836
  tables: Set<string>;
1608
1837
  }
1609
1838
  declare const createReadFootprint: () => ReadFootprint;
1839
+ declare const UNVOUCHABLE_DEP = "!unvouchable";
1840
+ declare const markUnvouchableReads: <T extends object>(facade: T, onRead: ReadFootprint["onRead"] | undefined, methods: ReadonlyArray<string>) => T;
1610
1841
  declare const DEFAULT_MAX_RELATION_KEYS = 5000;
1611
1842
  interface RelationExistsMarker {
1612
1843
  childWhere: WhereInput;
@@ -1641,6 +1872,7 @@ declare const containsRelationPredicate: (where: WhereInput, schema: ResolveCont
1641
1872
  declare const assertFlatPredicate: (where: WhereInput | undefined, schema: ResolveContext["schema"], tableName: string, op: string) => void;
1642
1873
  declare const resolveRelationPredicates: (where: WhereInput | undefined, options: ResolveRelationPredicatesOptions) => Promise<WhereInput | undefined>;
1643
1874
  declare const assertShapeShardable: (effectiveWhere: WhereInput | undefined, schema: ResolveContext["schema"], table: string) => void;
1875
+ declare const relationHooks: (args: Pick<QueryArgs, "relationBaseWhere" | "relationMask">) => Pick<QueryArgs, "relationBaseWhere" | "relationMask">;
1644
1876
  declare const fanOutScalarCounts: (counter: (tableName: string, where?: WhereInput) => Promise<number>, tableName: string, whereField: string, values: unknown[], policyWhere: WhereInput | undefined) => Promise<Map<unknown, number>>;
1645
1877
  declare const distinctValues: (rows: Record<string, unknown>[], field: string) => unknown[];
1646
1878
  declare const resolveWith: (options: ResolveWithOptions) => Promise<void>;
@@ -1665,6 +1897,8 @@ interface ShapeRowOp {
1665
1897
  value?: Record<string, unknown>;
1666
1898
  }
1667
1899
  interface ShapePokePart {
1900
+ baseCheckpoint?: number;
1901
+ reset?: boolean;
1668
1902
  rowsPatch: ShapeRowOp[];
1669
1903
  shapeId: string;
1670
1904
  }
@@ -1745,21 +1979,17 @@ interface RelayShapePoke {
1745
1979
  type: "relay_shape_poke";
1746
1980
  }
1747
1981
  type OwnerRelayFrame = RelayAttach | RelayDetach | RelayFrame | RelayShapePoke | RelayShapeSubscribe;
1748
- declare const DEFAULT_MAX_RELAYS = 8;
1749
- interface RelayStub {
1982
+ interface SiblingStub {
1750
1983
  fetch: (url: string, init?: RequestInit) => Promise<Response>;
1751
1984
  }
1752
- interface RelayNamespaceLike {
1753
- get: (id: unknown) => RelayStub;
1754
- getByName?: (name: string) => RelayStub;
1755
- idFromName: (name: string) => unknown;
1756
- }
1985
+ declare const DEFAULT_MAX_RELAYS = 8;
1757
1986
  interface RelayHost {
1758
1987
  buildShapeDiff: (resolved: ResolvedShape, fromCursor: number, toCursor: number) => ShapeRowOp[];
1759
1988
  computeOpLogShapeSeed: (shape: ShapeSubscriptionQuery, resolved: ResolvedShape) => {
1760
1989
  baseCheckpoint: number | undefined;
1761
1990
  cursor: number;
1762
1991
  epoch: string | undefined;
1992
+ reset: boolean;
1763
1993
  rowsPatch: ShapeRowOp[];
1764
1994
  };
1765
1995
  currentCdcEpoch: () => string | undefined;
@@ -1789,7 +2019,8 @@ declare abstract class RelayLink {
1789
2019
  handleControl(request: Request): Promise<Response>;
1790
2020
  maxRelays(): number;
1791
2021
  protected canAddressSiblings(): boolean;
1792
- protected relayNamespace(): RelayNamespaceLike | undefined;
2022
+ protected siblingStub(targetName: string): SiblingStub | undefined;
2023
+ protected bindingName(): string | undefined;
1793
2024
  protected postRelayMessage(targetName: string, message: OwnerRelayFrame): Promise<void>;
1794
2025
  protected requestRelayMessage(targetName: string, message: OwnerRelayFrame): Promise<Response | undefined>;
1795
2026
  abstract forwardWhisper(topic: string, frame: string): Promise<void>;
@@ -1802,6 +2033,7 @@ declare abstract class RelayLink {
1802
2033
  abstract announceDrain(closing: ShardSocketLike): Promise<void>;
1803
2034
  abstract relayCount(): number;
1804
2035
  abstract isShapeRelayUniform(name: string, args: Record<string, unknown>): boolean;
2036
+ abstract minShapeCursor(): number | undefined;
1805
2037
  protected abstract onAttach(index: number): void;
1806
2038
  protected abstract onDetach(index: number): void;
1807
2039
  protected abstract onWhisperFrame(message: RelayFrame): Promise<void>;
@@ -1811,8 +2043,8 @@ declare abstract class RelayLink {
1811
2043
  declare class OwnerRelay extends RelayLink {
1812
2044
  private readonly shapeUniformCache;
1813
2045
  private relaySetCache;
1814
- private readonly relayShapeRegistry;
1815
- private readonly relayShapeProxies;
2046
+ private registryCache;
2047
+ private recordedBinding;
1816
2048
  private promotionState;
1817
2049
  constructor(host: RelayHost, ownerKey: string);
1818
2050
  forwardWhisper(topic: string, frame: string): Promise<void>;
@@ -1824,16 +2056,23 @@ declare class OwnerRelay extends RelayLink {
1824
2056
  announce(): Promise<void>;
1825
2057
  announceDrain(): Promise<void>;
1826
2058
  relayCount(): number;
2059
+ minShapeCursor(): number | undefined;
1827
2060
  isShapeRelayUniform(name: string, args: Record<string, unknown>): boolean;
1828
2061
  protected onAttach(index: number): void;
1829
2062
  protected onDetach(index: number): void;
1830
2063
  protected onWhisperFrame(message: RelayFrame): Promise<void>;
1831
2064
  protected onShapeSubscribe(message: RelayShapeSubscribe): RelayShapeSeed;
1832
2065
  protected onShapePoke(): number;
2066
+ private buildShapePoke;
1833
2067
  private multicastShapePokes;
2068
+ private multicastToRelays;
1834
2069
  private proxyShapePokes;
2070
+ private proxyToRelay;
1835
2071
  private buildShapeSeedFrames;
1836
- private ensureRelayTable;
2072
+ private ensureRelayTables;
2073
+ protected bindingName(): string | undefined;
2074
+ private relayShapes;
2075
+ private rewindShapeCursor;
1837
2076
  private ownerRelaySet;
1838
2077
  private addRelayToSet;
1839
2078
  private removeRelayFromSet;
@@ -1854,6 +2093,7 @@ declare class RelayMember extends RelayLink {
1854
2093
  announceDrain(closing: ShardSocketLike): Promise<void>;
1855
2094
  relayCount(): number;
1856
2095
  isShapeRelayUniform(): boolean;
2096
+ minShapeCursor(): number | undefined;
1857
2097
  protected onAttach(): void;
1858
2098
  protected onDetach(): void;
1859
2099
  protected onWhisperFrame(): Promise<void>;
@@ -1863,6 +2103,61 @@ declare class RelayMember extends RelayLink {
1863
2103
  private deliverShapePoke;
1864
2104
  }
1865
2105
  declare const createRelayLink: (host: RelayHost) => OwnerRelay | RelayMember | undefined;
2106
+ declare const REGION_HINTS: readonly ["wnam", "enam", "sam", "weur", "eeur", "apac", "apac-ne", "apac-se", "oc", "afr", "me"];
2107
+ type RegionHint = (typeof REGION_HINTS)[number];
2108
+ type ReplicaReadiness = "fresh" | "stale" | "unavailable";
2109
+ interface ShardSiblingHost {
2110
+ doName: () => string | undefined;
2111
+ env: () => unknown;
2112
+ shardBinding: () => string | undefined;
2113
+ sql: () => SqlExec;
2114
+ }
2115
+ interface ReplicaOwnerHost extends ShardSiblingHost {
2116
+ exportRows: () => Promise<ExportRow[]>;
2117
+ ownerCursor: () => number | undefined;
2118
+ ownerEpoch: () => string | undefined;
2119
+ ownerFloor: () => number | undefined;
2120
+ readChanges: (sinceSeq: number, limit: number) => {
2121
+ changes: CdcChange[];
2122
+ cursor: number;
2123
+ };
2124
+ rowCount: () => number;
2125
+ }
2126
+ interface ReplicaFollowerHost extends ShardSiblingHost {
2127
+ applyChanges: (changes: ReadonlyArray<CdcChange>) => Promise<number>;
2128
+ importRows: (rows: ReadonlyArray<ExportRow>) => Promise<{
2129
+ errors: ReadonlyArray<unknown>;
2130
+ }>;
2131
+ }
2132
+ declare const handleReplicaControl: (host: ReplicaOwnerHost, request: Request) => Promise<Response>;
2133
+ declare class ShardReplica {
2134
+ private readonly host;
2135
+ readonly ownerKey: string;
2136
+ readonly region: RegionHint;
2137
+ private divergent;
2138
+ private inFlight;
2139
+ constructor(host: ReplicaFollowerHost, ownerKey: string, region: RegionHint);
2140
+ ensureFresh(minSeq?: number): Promise<ReplicaReadiness>;
2141
+ appliedSeq(): number;
2142
+ isDivergent(): boolean;
2143
+ private advance;
2144
+ private isCaughtUp;
2145
+ private catchUp;
2146
+ private applyPage;
2147
+ private hasDiverged;
2148
+ private bootstrap;
2149
+ private isFreshEnough;
2150
+ private pull;
2151
+ private request;
2152
+ }
2153
+ declare const createReplicaLink: (host: ReplicaFollowerHost) => ShardReplica | undefined;
2154
+ declare const gateReplicaDispatch: (replica: ShardReplica, request: Request, functionPath: string) => Promise<Response | undefined>;
2155
+ declare const REPROJECTION_MIGRATION_PREFIX = "__lunora_reproject__";
2156
+ declare const reprojectionMigrationId: (table: string) => string;
2157
+ declare const reprojectableFields: (definition: TableDefinitionLike) => string[];
2158
+ declare const reprojectionTables: (schema: SchemaLike) => string[];
2159
+ declare const countLegacyRows: (sql: SqlExec, table: string, fields: ReadonlyArray<string>) => number;
2160
+ declare const buildReprojectionMigration: (id: string, schema: SchemaLike, sql: SqlExec) => DataMigrationLike | undefined;
1866
2161
  declare const RLS_UNWRAP_SYMBOL: symbol;
1867
2162
  declare class RlsRequiredError extends LunoraError {
1868
2163
  readonly table: string;
@@ -1878,7 +2173,8 @@ interface GuardableSchema {
1878
2173
  }>;
1879
2174
  }
1880
2175
  type TableOfId = (id: string, expectedTable?: string) => Promise<string | undefined> | string | undefined;
1881
- declare const guardWriter: <W>(raw: W, schema: GuardableSchema, tableOfId: TableOfId) => W;
2176
+ type TablesOfIds = (ids: ReadonlyArray<string>, expectedTable?: string) => Promise<ReadonlyMap<string, string>> | ReadonlyMap<string, string>;
2177
+ declare const guardWriter: <W>(raw: W, schema: GuardableSchema, tableOfId: TableOfId, tablesOfIds?: TablesOfIds) => W;
1882
2178
  declare const SCHEMA_HISTORY_MAX_VERSIONS = 50;
1883
2179
  interface SchemaVersionRow {
1884
2180
  appliedAt: number;
@@ -1891,6 +2187,24 @@ declare const readSchemaHistory: (sql: SqlExec) => SchemaVersionRow[];
1891
2187
  declare const readSchemaVersion: (sql: SqlExec, hash: string) => SchemaVersionRow | undefined;
1892
2188
  declare const isDevEnvironment: (rawEnv: unknown) => boolean;
1893
2189
  declare const buildSettings: (rawEnv: unknown) => SettingsResult;
2190
+ declare class ShapeDiffCache {
2191
+ private readonly keyScans;
2192
+ private readonly memberProbes;
2193
+ private run;
2194
+ private served;
2195
+ get probesRun(): number;
2196
+ get probesServed(): number;
2197
+ changedKeys(rangeKey: string, load: () => CdcChangeKey[]): ReadonlyArray<CdcChangeKey>;
2198
+ members(resolved: ResolvedShape, rangeKey: string, load: () => Map<string, Record<string, unknown>>): ReadonlyMap<string, Record<string, unknown>>;
2199
+ private getOrLoad;
2200
+ }
2201
+ declare const createShapeDiffCache: () => ShapeDiffCache;
2202
+ declare const globalShapeReadKey: (resolved: ResolvedShape, identity: {
2203
+ identity?: Record<string, unknown>;
2204
+ userId?: string;
2205
+ }) => string | undefined;
2206
+ type ReadShapeCdcKeys = (sql: SqlExec, table: string, sinceSeq: number, upTo: number) => CdcChangeKey[];
2207
+ declare const buildShapeDiff: (sql: SqlExec, resolved: ResolvedShape, sinceSeq: number, upTo: number, cache: ShapeDiffCache, readKeys?: ReadShapeCdcKeys) => ShapeRowOp[];
1894
2208
  interface ShardRunnerOptions {
1895
2209
  handlers?: {
1896
2210
  handleAlarm?: () => Promise<void>;
@@ -1940,7 +2254,17 @@ interface DrainableSink {
1940
2254
  readonly bufferedAmount?: unknown;
1941
2255
  }
1942
2256
  declare const trySendFrame: (ws: FrameSink, frame: string) => boolean;
1943
- declare const sendDeltaFrames: (ws: FrameSink, subId: string, deltaFrames: ReadonlyArray<string>, cursorSuffix: string) => boolean;
2257
+ interface SubscriptionFrameInput {
2258
+ cursorSuffix: string;
2259
+ lastMutationId?: number;
2260
+ nextResult: unknown;
2261
+ pageDeltas?: boolean;
2262
+ previousJson?: string;
2263
+ snapshotJson: string;
2264
+ subId: string;
2265
+ table: string;
2266
+ }
2267
+ declare const subscriptionFrames: (input: SubscriptionFrameInput) => string[];
1944
2268
  declare const awaitWsDrain: (ws: DrainableSink) => Promise<void>;
1945
2269
  interface SubscriptionReadFootprint {
1946
2270
  ranges?: Map<string, KeyRange[]>;
@@ -1968,13 +2292,25 @@ declare const selectExpiredIds: (sql: SqlExec, spec: TtlSweepSpec, now: number,
1968
2292
  hasMore: boolean;
1969
2293
  ids: string[];
1970
2294
  };
1971
- type FieldRefSql = (field: string) => SQL;
2295
+ interface WhereFragments<T> {
2296
+ binary: (reference: T, comparator: string, value: unknown) => T;
2297
+ connect: (left: T, right: T, connector: "AND" | "OR") => T;
2298
+ constant: (value: boolean) => T;
2299
+ contains: (reference: T, term: T) => T;
2300
+ inList: (reference: T, items: ReadonlyArray<unknown>, negated: boolean, budget: number) => T;
2301
+ negate: (inner: T) => T;
2302
+ nullCheck: (reference: T, negated: boolean) => T;
2303
+ value: (value: unknown) => T;
2304
+ }
2305
+ type FieldRefSql<T> = (field: string) => T;
1972
2306
  type SerializeValue = (value: unknown) => unknown;
1973
- interface WhereSqlStrategy {
1974
- fieldRef: FieldRefSql;
1975
- likeContains?: (reference: SQL, term: SQL) => SQL;
1976
- relationExists?: (request: unknown) => SQL;
2307
+ interface WhereSqlStrategy<T = SQL> {
2308
+ containsExpr?: (reference: T, term: T) => T;
2309
+ fieldRef: FieldRefSql<T>;
2310
+ inList?: (reference: T, items: ReadonlyArray<unknown>, negated: boolean, budget?: number) => T;
2311
+ relationExists?: (request: unknown) => T;
1977
2312
  serialize: SerializeValue;
1978
2313
  }
1979
- declare const compileWhereSql: (where: WhereInput | undefined, strategy: WhereSqlStrategy) => SQL | undefined;
1980
- export { ADMIN_FUNCTIONS, ADMIN_FUNCTION_PREFIX, AGGREGATE_SQL_FUNCTION, AGG_COUNT, AGG_KEY, AGG_VALUE, AUDIT_LOG_TABLE, type AdvisorProcedure, type AdvisorProceduresResult, type AdvisoriesResult, type AdvisoryFinding, type AggregateIndexDefinitionLike, type AggregateOp, type AggregateOptions, type AggregateResult, type AggregateTally, type AppendAuditEntry, type ApplyOnDeleteOptions$1 as ApplyOnDeleteOptions, type AuditEntry, type AuditLogResult, type BroadcastDelta, CDC_LOG_TABLE, CDC_META_TABLE, CLIENT_WATERMARK_TABLE, type CacheEntry, type CapturedMailRow, type CdcChange, type ChangedKeys, type Clock, type ColumnMeta, type ColumnMetaLike, type CompanionSync, type CompanionSyncDeps, ConflictError, type ConflictKind, type CountArgs, CountRlsUnsupportedError, type CreateWorkflowInstanceResult, type CtxDbOptions, DATA_MIGRATION_STATE_TABLE, DEFAULT_FANOUT_TOPIC_LIMIT, DEFAULT_MAX_RELATION_KEYS, DEFAULT_MAX_RELAYS, DEFAULT_PROMOTION_THRESHOLDS, DEFAULT_TRANSACTION_LIMITS, DOC_COLUMN, type DataMigrationDocument, type DataMigrationLike, type DataMigrationTransform, type DatabaseWriterLike, type DependencyTracker, type DeployInfo, type ExportRow, type ExportShardAdminArgs, type ExportShardArgs, type ExternalSourceDiffResult, type ExternalSourceLike, FLAGS_FUNCTION_PREFIX, type FacetColumnOptions, type FacetColumnResult, type FacetValue, type FanoutMetricsResult, type FanoutPathCounters, type FanoutTopicStat, type FieldOperators, type FilterClause, type FilterOperator, type FlagEvaluation, type FlagsResult, type FunctionCallStat, type FunctionScanAttribution, type FunctionStatsResult, GEO_DEFAULT_PRECISION, GLOBAL_SHAPE_SNAPSHOT_TABLE, type GeoBoundingBox, type GeoFilterBuilderLike, type GeoIndexDefinitionLike, type GeoPoint, type GroupByEntry, type GroupByOptions, type GuardableSchema$1 as GuardableSchema, IDEMPOTENCY_TABLE, type IdGenerator, type IdempotentRecord, type ImportError, type ImportShardAdminArgs, type ImportShardArgs, type ImportShardResult, type IncrementalMaterializeResult, type IndexDefinitionLike, type IndexKeyEntry, type IndexRangeBuilderLike, type KeyRange, type LifecycleDispatchInfo, type LifecycleEvent, MAIL_RETENTION, MAIL_TABLE, MAX_PAGE_SIZE, MAX_SQL_ROWS, type MaskColumnMetadata, type MaskPoliciesResult, type MaterializeResult, type MigrationDirection, type MigrationRunResult, type MigrationStatus, type MigrationStatusRow, type MutationDelta, type NestedWith, NotFoundError, NotUniqueError, type OnDeleteActionLike, type OrderByClause, type OrderByInput, type OrderKey, OwnerRelay, type OwnerRelayFrame, type PaginationOptions, type PitrBookmarkResult, type PitrRestoreArgs, type PitrRestoreResult, type PitrStorage, type PokeFrameMeta, type PromotionState, type PromotionThresholds, QUEUE_TABLE, type QueryArgs, type QueryPage, type QueueMessageOutcome, type QueueMessageRow, type QueueMetadata, type QueuesResult, RANK_TIEBREAK, RELATION_EXISTS_KEY, RELATION_FUNCTION_PREFIX, RLS_UNWRAP_SYMBOL, type RankBeforeOptions, type RankBeforeResult, type RankDirection, type RankIndexDefinitionLike, type RankOptions, type RankPage, type RankPageComputation, type RankPageDeps, type RankPageOptions, type RankPageRow, type RankPageRowKey, type RankResult, type RankSortKeyLike, ReactiveCache, type ReactiveCacheOptions, type ReadFootprint, type ReadHook, type ReadTablePageOptions, type RecordMailInput, type RecordQueueMessageInput, type RelationDefinitionLike, type RelationExistsMarker, type RelayAttach, type RelayDetach, type RelayFrame, type RelayHost, RelayMember, type RelayShapePoke, type RelayShapeSeed, type RelayShapeSubscribe, type RenderedSql, type ResolveRelationPredicatesOptions, type ResolveWithOptions, type ResolveWithResult, type ResolvedShape, type RestrictableQueryOptions, type RlsPoliciesResult, type RlsPolicyMetadata, RlsRequiredError, type RlsRoleMetadata, type RpcRequest, type RunDataMigrationOptions, type RunTriggersOptions, SCAN_DEP, SCHEMA_HISTORY_MAX_VERSIONS, SEARCH_STATE_TABLE, type SchedulableWorkflowReferenceLike, type ScheduledFunctionDoc, type SchedulerLike, type SchemaLike, type 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 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 TransactionHeadroom, TransactionHeadroomTracker, type TransactionLimits, type TransactionSqlLike, type TriggerContextLike, type TriggerDefinitionLike, type TriggerEventLike, type TriggerOpLike, type TriggerTimingLike, type TtlSweepSpec, type ValidatorLike, type WhereInput, type WhereSqlStrategy, type WithInput, type WorkflowInstanceState, type WorkflowInstanceStatusResult, type WorkflowMetadata, type WorkflowsResult, type WriteEvent, type WriteHook, advanceClientWatermark, aggUpsertSql, aggregateSqlFunction, aggregateTableName, appendAuditEntry, appendCdcChange, applyCdcChanges, applyOnDelete, applySelect, armRestore, assertFlatPredicate, assertReadonly, assertShapeShardable, assertValidClientId, awaitWsDrain, backfillAggregateIndexes, backfillRankIndexes, backfillSearchIndexes, backfillSearchIndexesForTable, boundingBoxCenter, boundingBoxGeohashes, buildIndexRange, buildPokeFrames, buildSeekBeforeWhere, buildSeekWhere, buildSettings, bumpCdcEpoch, clampPromotionThresholds, clearCapturedMail, clearQueueMessages, coerceAggregateNumber, compileWhereSql, computeRankPage, containsRelationPredicate, coveringGeohashes, createCompanionSync, createDependencyTracker, createFanoutCounters, createIndexSql, createReadFootprint, createRelayLink, createShardCtxDb, createSystemReader, decodeCursor, deleteGlobalShapeSnapshot, deleteGlobalShapeSnapshotsForConnection, depKey, diffExternalSource, diffGlobalMembership, distinctValues, encodeAggregateKey, encodeCursor, encodeGeohash, encodePartitionKey, encodeRowsPatch, ensureAuditTable, ensureMailTable, exportShardRows, exportShardTable, facetColumn, fanOutScalarCounts, findStorageReferences, foldAggregateTally, geoTableName, guardWriter, hasTrigger, haversineMeters, hydrateDocsById, importShardRows, indexKeysForRow, isDevEnvironment, isFtsAvailable, isLossyBody, isRelationPredicate, isSoftDeleted, isSourceDue, jsonPath, jsonPathSql, keysTouchRanges, liftSourceId, lintReadonlySql, listTables, matchesRankStaticWhere, matchesStaticWhere, materializeExternalRows, materializeExternalRowsIncremental, mergeChangedKeys, mergeWhere, migrateCdcLog, migrateCdcMeta, migrateClientWatermark, migrateGlobalShapeSnapshot, migrateIdempotency, migrateSearchState, minCdcSeq, nextPromotionState, normalizeCountArgument, normalizeIdStructurally, normalizeOrderKeys, normalizeSourceDocument, normalizeSourceValue, param, parseExportShardArgs, parseImportShardArgs, planAggregateLookup, pointInBoundingBox, projectColumns, pullExternalSourceIncrementalTick, pullExternalSourceTick, qualifiedJsonPath, qualifiedJsonPathSql, quoteIdentifier, rankKeyFromDocument as rankKeyFromDoc, rankTableName, reactiveCacheKey, readAggregateValue, readAuditLog, readBookmark, readCapturedMail, readCdcChanges, readCdcCursor, readCdcEpoch, readClientWatermark, readExternalSourceBaseline, readGlobalShapeSnapshot, readIdempotent, readMigrationStatus, readQueueMessageById, readQueueMessages, readSchemaHistory, readSchemaVersion, readSearchBackfillState, readTablePage, recordCapturedMail, recordChangedKeys, recordFanoutPass, recordQueueMessages, recordSchemaVersion, relayCountFor, renderSql, resolveRankPartition, resolveRelationPredicates, resolveWith, rowToDocument, runDataMigration, runDrizzle, runExternalSourceTick, runReadonlySql, runRowValidators, runShardMigrations, runSocketPool, runSql, runTriggers, selectExpiredIds, selectExportTables, selectIndexForAggregate, selectIndexForCount, selectIndexForGroupBy, selectMatchingIds, selectShapeMemberIds, selectShapeRows, sendDeltaFrames, serializeSqlValue, shapeRoutingKey, softDeleteScope, sortColumnName, stableStringify, stableWireKey, subscriptionListDeltas, summarizeFanoutTopics, summarizeSubscriptions, tableColumns, tableFromDepKey, throwingScheduler, trimCdcChanges, trimIdempotent, tryRowToDocument, trySendFrame, validateImportRow, writeGlobalShapeSnapshot, writeIdempotent, writeSearchBackfillState, writeTouchesMemo };
2314
+ declare const literalInList: (reference: SQL, items: ReadonlyArray<unknown>, negated: boolean) => SQL;
2315
+ declare const compileWhereSql: <T = SQL>(where: WhereInput | undefined, strategy: WhereSqlStrategy<T>, fragments?: WhereFragments<T>) => T | undefined;
2316
+ 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_LOG_TABLE_SEQ_INDEX, CDC_META_TABLE, CLIENT_WATERMARK_TABLE, COMMIT_SEQ_FIELD, COMMIT_SEQ_TABLE, type CacheEntry, type CapturedMailRow, 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 FanoutMetricsResult, type FanoutPathCounters, type FanoutTopicStat, type FieldOperators, type FilterClause, type FilterOperator, type FlagEvaluation, type FlagsResult, type FunctionCallStat, type FunctionScanAttribution, type FunctionStatsResult, GEO_DEFAULT_PRECISION, GLOBAL_SHAPE_SNAPSHOT_TABLE, type GeoBoundingBox, type GeoFilterBuilderLike, type GeoIndexDefinitionLike, type GeoPoint, type GeoScoredDocument, type GlobalPollCounters, GlobalPollTick, type GroupByEntry, type GroupByOptions, type GuardableSchema$1 as GuardableSchema, IDEMPOTENCY_TABLE, type IdGenerator, type IdempotentRecord, type ImportError, type ImportShardAdminArgs, type ImportShardArgs, type ImportShardResult, type IncrementalMaterializeResult, type IndexDefinitionLike, type IndexKeyEntry, type IndexRangeBuilderLike, type KeyRange, type LifecycleDispatchInfo, type LifecycleEvent, MAIL_RETENTION, MAIL_TABLE, MAX_DURABLE_STREAM_BYTES, MAX_DURABLE_STREAM_CHUNKS, MAX_PAGE_SIZE, MAX_SQL_ROWS, type MaskColumnMetadata, type MaskPoliciesResult, type MaterializeResult, type MigrationDirection, type MigrationRunResult, type MigrationStatus, type MigrationStatusRow, type MutationDelta, type NestedWith, NotFoundError, NotUniqueError, type OnDeleteActionLike, type OrderByClause, type OrderByInput, type OrderKey, 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, 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 RelationDefinitionLike, type RelationExistsMarker, type RelayAttach, type RelayDetach, type RelayFrame, type RelayHost, RelayMember, type RelayShapePoke, type RelayShapeSeed, type RelayShapeSubscribe, 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, SCHEMA_HISTORY_MAX_VERSIONS, SEARCH_STATE_TABLE, SHAPE_POKE_CURSOR_TABLE, type SchedulableWorkflowReferenceLike, type ScheduledFunctionDoc, type SchedulerLike, type SchemaLike, type ScoredDocument, type SearchBackfillProgress, type SearchFilterBuilderLike, type SearchIndexDefinitionLike, type SearchScoredDocument, type SelectMatchingIdsOptions, type ServerDefaultContextLike, type SettingEntry, type SettingKind, type SettingsResult, ShapeDiffCache, type ShapePokeCursorRow, type ShapePokePart, type ShapeProbeCounters, type ShapeRow, type ShapeRowOp, type ShapeSubscriptionQuery, type ShardRankPageResult, ShardRunner, type ShardRunnerOptions, type ShardSiblingHost, type ShardSocketLike, type SocketAttachment, type SortDirection, type SourceClientLike, type SourceCursorLike, type SourceRefresh, type SqlConsoleResult, type SqlCursor, type SqlEngine, type SqlExec, type SqlLintResult, type StorageMetadata, type StorageReference, type StorageReferenceResult, type StorageRuleMetadata, type StorageRulesResult, type StudioFeaturesResult, type SubscriptionConnection, type SubscriptionEnvelope, type SubscriptionIdentity, type SubscriptionInfo, type SubscriptionQuery, type SubscriptionReadFootprint, type SubscriptionsResult, type SystemDatabaseReader, type SystemDoc, type SystemQuery, type SystemReaderOptions, type SystemReaderSchedulerLike, type SystemReaderStorageLike, type SystemTableName, type TableColumnsResult, type TableDefinitionLike, type TableIndexInfo, type TableIndexesResult, type TableInfo, type TablePage, type TableReaderLike, type TablesColumnsResult, type TablesIndexesResult, type TransactionHeadroom, TransactionHeadroomTracker, type TransactionLimits, type TransactionSqlLike, type TriggerContextLike, type TriggerDefinitionLike, type TriggerEventLike, type TriggerOpLike, type TriggerTimingLike, type TtlSweepSpec, UNVOUCHABLE_DEP, type ValidatorLike, type WhereInput, type WhereSqlStrategy, type WithInput, type WorkflowInstanceState, type WorkflowInstanceStatusResult, type WorkflowMetadata, type WorkflowsResult, type WriteEvent, type WriteHook, advanceClientWatermark, aggUpsertSql, aggregateSqlFunction, aggregateTableName, allocateCommitSeq, appendAuditEntry, appendCdcChange, appendStreamChunk, applyCdcChanges, applyOnDelete, applySelect, armRestore, assertFlatPredicate, assertReadonly, assertShapeShardable, assertValidClientId, awaitWsDrain, backfillAggregateIndexes, backfillRankIndexes, backfillSearchIndexes, backfillSearchIndexesForTable, boundingBoxCenter, boundingBoxGeohashes, buildIndexRange, buildPokeFrames, buildReprojectionMigration, buildSeekBeforeWhere, buildSeekWhere, buildSettings, buildShapeDiff, bumpCdcEpoch, cdcCanVouchFor, cdcSeqLeavingRows, cdcTouchesTables, cdcTrimmedError, claimStreamRun, clampPromotionThresholds, clearCapturedMail, clearMemoryTables, clearQueueMessages, coerceAggregateNumber, compactCdcDocs, compileWhereSql, computeRankPage, containsRelationPredicate, countLegacyRows, coveringGeohashes, createCompanionSync, createDependencyTracker, createFanoutCounters, createGlobalPollCounters, createIndexSql, createReadFootprint, createRelayLink, createReplicaLink, createShapeDiffCache, createShapeProbeCounters, createShardCtxDb, createSystemReader, cursorBelowRetainedFloor, decideDurableAttach, decodeCursor, deleteGlobalShapeSnapshot, deleteGlobalShapeSnapshotsForConnection, deleteShapePokeCursor, deleteShapePokeCursorsForConnection, deleteStreamRun, depKey, diffExternalSource, diffGlobalMembership, distinctValues, encodeAggregateKey, encodeCursor, encodeGeohash, encodePartitionKey, encodeRowsPatch, ensureAuditTable, ensureMailTable, envOptionalPositiveInt, envPositiveInt, exportShardRows, exportShardTable, facetColumn, fanOutScalarCounts, findStorageReferences, finishStreamRun, foldAggregateTally, gateReplicaDispatch, geoTableName, globalShapeReadKey, guardWriter, handleReplicaControl, hasTrigger, haversineMeters, hydrateDocsById, importShardRows, indexKeysForRow, isDevEnvironment, isFtsAvailable, isLossyBody, isMemoryTable, isRelationPredicate, isSoftDeleted, isSourceDue, jsonPath, jsonPathSql, keysTouchRanges, liftSourceId, lintReadonlySql, listReactorStates, listTables, literalInList, markUnvouchableReads, matchesRankStaticWhere, matchesStaticWhere, materializeExternalRows, materializeExternalRowsIncremental, memoryTableNames, mergeChangedKeys, mergeWhere, migrateCdcLog, migrateCdcMeta, migrateClientWatermark, migrateCommitSeq, migrateDurableStreams, migrateGlobalShapeSnapshot, migrateIdempotency, migrateReactorState, migrateSearchState, migrateShapePokeCursor, minCdcReplayableSeq, minCdcSeq, minShapePokeCursor, nextPromotionState, normalizeCountArgument, normalizeIdStructurally, normalizeOrderKeys, normalizeSourceDocument, normalizeSourceValue, param, parseExportShardArgs, parseImportShardArgs, planAggregateLookup, pointInBoundingBox, projectColumns, pullExternalSourceIncrementalTick, pullExternalSourceTick, qualifiedJsonPath, qualifiedJsonPathSql, quoteIdentifier, rankKeyFromDocument as rankKeyFromDoc, rankTableName, reactiveCacheKey, reactorNeedsRun, readAggregateValue, readAuditLog, readBookmark, readCapturedMail, readCdcChangeKeys, readCdcChanges, readCdcCursor, readCdcEpoch, readClientWatermark, readCommitSeq, readExternalSourceBaseline, readGlobalShapeSnapshot, readIdempotent, readMigrationStatus, readQueueMessageById, readQueueMessages, readReactorState, readSchemaHistory, readSchemaVersion, readSearchBackfillState, readShapePokeCursor, readStreamChunks, readStreamRun, readTablePage, recordCapturedMail, recordChangedKeys, recordFanoutPass, recordGlobalPollPass, recordQueueMessages, recordSchemaVersion, recordShapeProbePass, relationHooks, relayCountFor, renderSql, reprojectableFields, reprojectionMigrationId, reprojectionTables, resolveRankPartition, resolveRelationPredicates, resolveWith, rowToDocument, runDataMigration, runDrizzle, runExternalSourceTick, runReadonlySql, runRowValidators, runShardMigrations, runSocketPool, runSql, runTriggers, selectExpiredIds, selectExportTables, selectIndexForAggregate, selectIndexForCount, selectIndexForGroupBy, selectMatchingIds, selectShapeMembers, selectShapeRows, serializeSqlValue, shapeRoutingKey, softDeleteScope, sortColumnName, sqliteInList, stableStringify, stableWireKey, subscriptionFrames, subscriptionListDeltas, summarizeFanoutTopics, summarizeSubscriptions, tableColumns, tableFromDepKey, throwingScheduler, trimCdcChanges, trimIdempotent, trimStreamRuns, tryRowToDocument, trySendFrame, unionAll, validateImportRow, writeGlobalShapeSnapshot, writeIdempotent, writeReactorState, writeSearchBackfillState, writeShapePokeCursor, writeShapePokeCursors, writeTouchesMemo };