@lunora/shard-engine 1.0.0-alpha.5 → 1.0.0-alpha.51
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.
- package/README.md +1 -1
- package/dist/conformance/index.mjs +1 -1
- package/dist/index.d.mts +392 -33
- package/dist/index.d.ts +392 -33
- package/dist/index.mjs +1 -1
- package/dist/packem_shared/ADMIN_FUNCTIONS-oJ7IyZP6.mjs +1 -0
- package/dist/packem_shared/AGGREGATE_SQL_FUNCTION-m1iUU1rv.mjs +1 -0
- package/dist/packem_shared/AGG_COUNT-JTc_jUaL.mjs +1 -0
- package/dist/packem_shared/AUDIT_LOG_TABLE-ONxmEAIz.mjs +8 -0
- package/dist/packem_shared/CDC_LOG_TABLE-gl0FuepJ.mjs +15 -0
- package/dist/packem_shared/CLIENT_WATERMARK_TABLE-CRnrAnJ2.mjs +7 -0
- package/dist/packem_shared/COMMIT_SEQ_FIELD-BUdOMG5y.mjs +4 -0
- package/dist/packem_shared/CURSOR_PREFIX-CoJUQfCI.mjs +1 -0
- package/dist/packem_shared/CountRlsUnsupportedError-Bdfupt3g.mjs +1 -0
- package/dist/packem_shared/DATA_MIGRATION_STATE_TABLE-BHzhEE-y.mjs +31 -0
- package/dist/packem_shared/DEFAULT_MAX_RELATION_KEYS-Fb5vfB-T.mjs +1 -0
- package/dist/packem_shared/DEFAULT_MAX_RELAYS-CH446J5m.mjs +1 -0
- package/dist/packem_shared/DEFAULT_PROMOTION_THRESHOLDS-DcJw42RT.mjs +1 -0
- package/dist/packem_shared/DEFAULT_TRANSACTION_LIMITS-Bcoi7Bvf.mjs +1 -0
- package/dist/packem_shared/DurableStreamRunner-C3NUyv3s.mjs +1 -0
- package/dist/packem_shared/GEO_DEFAULT_PRECISION-CqpQZ-J_.mjs +1 -0
- package/dist/packem_shared/GLOBAL_SHAPE_SNAPSHOT_TABLE-DSA6mzyx.mjs +7 -0
- package/dist/packem_shared/GlobalPollTick-BNK4o-XT.mjs +1 -0
- package/dist/packem_shared/IDEMPOTENCY_TABLE-DOpm_oMF.mjs +7 -0
- package/dist/packem_shared/MAIL_RETENTION-DGAQTHHs.mjs +18 -0
- package/dist/packem_shared/MAX_SQL_ROWS-gsiUV0Eo.mjs +5 -0
- package/dist/packem_shared/NotUniqueError-DucaxGnP.mjs +1 -0
- package/dist/packem_shared/QUEUE_TABLE-s7QJZvBz.mjs +17 -0
- package/dist/packem_shared/RANK_TIEBREAK-D157XEqw.mjs +1 -0
- package/dist/packem_shared/REACTOR_STATE_TABLE-QPRFyxMS.mjs +28 -0
- package/dist/packem_shared/RELATION_EXISTS_KEY-CFUhnZSZ.mjs +1 -0
- package/dist/packem_shared/REPROJECTION_MIGRATION_PREFIX-Czcb6_mO.mjs +1 -0
- package/dist/packem_shared/RLS_UNWRAP_SYMBOL-BWloGsd3.mjs +1 -0
- package/dist/packem_shared/ReactiveCache-BngdZxr9.mjs +1 -0
- package/dist/packem_shared/SCAN_DEP-D7qE3iUe.mjs +1 -0
- package/dist/packem_shared/SCHEMA_HISTORY_MAX_VERSIONS-BluIj2s-.mjs +6 -0
- package/dist/packem_shared/SEARCH_STATE_TABLE-xmYM_nOd.mjs +1 -0
- package/dist/packem_shared/SHAPE_POKE_CURSOR_TABLE-ByJVDHds.mjs +8 -0
- package/dist/packem_shared/ShapeDiffCache-CLm5XXd1.mjs +1 -0
- package/dist/packem_shared/ShardRunner-C9p5DVOx.mjs +1 -0
- package/dist/packem_shared/UNVOUCHABLE_DEP-C68htACn.mjs +1 -0
- package/dist/packem_shared/aggregateTableName-CGi8gxeK.mjs +1 -0
- package/dist/packem_shared/appendStreamChunk-8eH4HB1Q.mjs +19 -0
- package/dist/packem_shared/applyOnDelete-BOOJzpbw.mjs +1 -0
- package/dist/packem_shared/archiveCdcSegment-DU4uzDFQ.mjs +4 -0
- package/dist/packem_shared/{armRestore-BNzdvQ_o.mjs → armRestore-Bu1_8SUa.mjs} +1 -1
- package/dist/packem_shared/awaitWsDrain-CjWMVZOG.mjs +1 -0
- package/dist/packem_shared/backfillAggregateIndexes-CTPj9dAd.mjs +1 -0
- package/dist/packem_shared/base64-DfpzS4o_.mjs +1 -0
- package/dist/packem_shared/buildIndexRange-CBKQmHSS.mjs +1 -0
- package/dist/packem_shared/buildPokeFrames-C8km3IhJ.mjs +1 -0
- package/dist/packem_shared/buildReprojectionMigration-CR2RSgJd.mjs +1 -0
- package/dist/packem_shared/buildSettings-B4igo4rJ.mjs +1 -0
- package/dist/packem_shared/buildShapeDiff-BW5lKBzQ.mjs +1 -0
- package/dist/packem_shared/clearMemoryTables-BGbmag2i.mjs +1 -0
- package/dist/packem_shared/compileWhereSql-BB1JlUhC.mjs +1 -0
- package/dist/packem_shared/computeRankPage-BH2rv2mc.mjs +1 -0
- package/dist/packem_shared/createCompanionSync-Bo-oIkyU.mjs +1 -0
- package/dist/packem_shared/createReplicaLink-DujqFlHs.mjs +7 -0
- package/dist/packem_shared/createSystemReader-DcDLFfC-.mjs +1 -0
- package/dist/packem_shared/ctx-db-companions-BFBIVIOd.mjs +1 -0
- package/dist/packem_shared/ctx-db-relay-shapes-CnOeftkH.mjs +17 -0
- package/dist/packem_shared/defineEngineContractSuite-B-fWLvpW.mjs +1 -0
- package/dist/packem_shared/diffExternalSource-DgDJhslq.mjs +1 -0
- package/dist/packem_shared/do-sql-bkXQEBl8.mjs +1 -0
- package/dist/packem_shared/envOptionalPositiveInt-D2pY-c64.mjs +1 -0
- package/dist/packem_shared/estimate-bytes-CzG5x1f8.mjs +1 -0
- package/dist/packem_shared/exportShardRows-4Xezo8F6.mjs +1 -0
- package/dist/packem_shared/hasTrigger-CjlwI4le.mjs +1 -0
- package/dist/packem_shared/isSoftDeleted-B6TNznFv.mjs +9 -0
- package/dist/packem_shared/liftSourceId-CA3ENhXj.mjs +1 -0
- package/dist/packem_shared/materializeExternalRows-DZPYRDXu.mjs +1 -0
- package/dist/packem_shared/mergeChangedKeys-D1T-TPUb.mjs +1 -0
- package/dist/packem_shared/param-DlozcSQu.mjs +1 -0
- package/dist/packem_shared/quoteIdentifier-CObIFRhb.mjs +1 -0
- package/dist/packem_shared/runDrizzle-2ULFQR_k.mjs +1 -0
- package/dist/packem_shared/runShardMigrations-BqH93Q8t.mjs +5 -0
- package/dist/packem_shared/runSocketPool-CZJ2X9cF.mjs +1 -0
- package/dist/packem_shared/selectExpiredIds-D784Mqvh.mjs +1 -0
- package/dist/packem_shared/selectShapeMembers-CLK9q18N.mjs +1 -0
- package/dist/packem_shared/serializeSqlValue-DbI1VQYM.mjs +1 -0
- package/dist/packem_shared/sibling-channel-Cxvk0Zca.mjs +1 -0
- package/dist/packem_shared/sql-projection-BqmxFxQU.mjs +1 -0
- package/dist/packem_shared/stableStringify-DibjylKD.mjs +1 -0
- package/dist/packem_shared/stableWireKey-9bjKL5Gy.mjs +1 -0
- package/dist/packem_shared/where-sql-4RHk2frP.mjs +1 -0
- package/dist/packem_shared/wire-codec-COhOSEe4.mjs +1 -0
- package/package.json +3 -3
- package/dist/packem_shared/ADMIN_FUNCTIONS-vj2G8OR6.mjs +0 -1
- package/dist/packem_shared/AGGREGATE_SQL_FUNCTION-QYaiuty4.mjs +0 -1
- package/dist/packem_shared/AGG_COUNT-BWXe3gtQ.mjs +0 -1
- package/dist/packem_shared/AUDIT_LOG_TABLE-CaA0jL0L.mjs +0 -8
- package/dist/packem_shared/CDC_LOG_TABLE-BnqlH2eZ.mjs +0 -8
- package/dist/packem_shared/CLIENT_WATERMARK_TABLE-CXsSLU8D.mjs +0 -7
- package/dist/packem_shared/CountRlsUnsupportedError-B2WKJD9v.mjs +0 -1
- package/dist/packem_shared/DATA_MIGRATION_STATE_TABLE-BZMVrLcy.mjs +0 -31
- package/dist/packem_shared/DEFAULT_MAX_RELATION_KEYS-bq00btqV.mjs +0 -1
- package/dist/packem_shared/DEFAULT_MAX_RELAYS-CnCyh6oX.mjs +0 -1
- package/dist/packem_shared/DEFAULT_PROMOTION_THRESHOLDS-Dteg0sZF.mjs +0 -1
- package/dist/packem_shared/DEFAULT_TRANSACTION_LIMITS--TtB8Gpo.mjs +0 -1
- package/dist/packem_shared/FTS_COUNT_COLUMN-D1gY3wwZ-CZHdaRrd.mjs +0 -1
- package/dist/packem_shared/GEO_DEFAULT_PRECISION-okRCkZ6r.mjs +0 -1
- package/dist/packem_shared/GLOBAL_SHAPE_SNAPSHOT_TABLE-DX-6-gBP.mjs +0 -7
- package/dist/packem_shared/IDEMPOTENCY_TABLE-DjkEMp6w.mjs +0 -7
- package/dist/packem_shared/MAIL_RETENTION-KmozO2NQ.mjs +0 -18
- package/dist/packem_shared/MAX_SQL_ROWS-nMwkxv5f.mjs +0 -2
- package/dist/packem_shared/NotUniqueError-C8DLoXSK.mjs +0 -1
- package/dist/packem_shared/QUEUE_TABLE-DYCDvzTG.mjs +0 -17
- package/dist/packem_shared/RANK_TIEBREAK-9NU5s_mi.mjs +0 -1
- package/dist/packem_shared/RELATION_EXISTS_KEY-BaqSIFU1.mjs +0 -1
- package/dist/packem_shared/RLS_UNWRAP_SYMBOL-C6_WX3dG.mjs +0 -1
- package/dist/packem_shared/ReactiveCache-DSGtSVGZ.mjs +0 -1
- package/dist/packem_shared/SCAN_DEP-D_yR9EeV.mjs +0 -1
- package/dist/packem_shared/SCHEMA_HISTORY_MAX_VERSIONS-CHXz6p_z.mjs +0 -6
- package/dist/packem_shared/SEARCH_STATE_TABLE-eLN8U5tz.mjs +0 -1
- package/dist/packem_shared/ShardRunner-DIqVdWtk.mjs +0 -1
- package/dist/packem_shared/aggregateTableName-G-eXyjcz.mjs +0 -1
- package/dist/packem_shared/applyOnDelete-uFRC5p1d.mjs +0 -1
- package/dist/packem_shared/applySelect-B0CF8T7y.mjs +0 -1
- package/dist/packem_shared/awaitWsDrain-Dk50ISgE.mjs +0 -1
- package/dist/packem_shared/backfillAggregateIndexes-BHiewuB-.mjs +0 -1
- package/dist/packem_shared/buildIndexRange-DFsdtPjD.mjs +0 -1
- package/dist/packem_shared/buildPokeFrames-DaPpm5Ss.mjs +0 -1
- package/dist/packem_shared/buildSettings-DT18_DkX.mjs +0 -1
- package/dist/packem_shared/compileWhereSql-BLcfs4QW.mjs +0 -1
- package/dist/packem_shared/computeRankPage-IUSS-zIB.mjs +0 -1
- package/dist/packem_shared/createCompanionSync-DWK0Vlg1.mjs +0 -1
- package/dist/packem_shared/createReadFootprint-DIrrxRTE.mjs +0 -1
- package/dist/packem_shared/createSystemReader-DcDcrtM3.mjs +0 -1
- package/dist/packem_shared/defineEngineContractSuite--yaJW9mT.mjs +0 -1
- package/dist/packem_shared/diffExternalSource-DMpkJta1.mjs +0 -1
- package/dist/packem_shared/estimate-bytes-DzD3PdCc.mjs +0 -1
- package/dist/packem_shared/exportShardRows-kt42wijd.mjs +0 -1
- package/dist/packem_shared/hasTrigger-CbkOHExZ.mjs +0 -1
- package/dist/packem_shared/isSoftDeleted-B-SXkGUo.mjs +0 -9
- package/dist/packem_shared/liftSourceId-DApAbu7Q.mjs +0 -1
- package/dist/packem_shared/materializeExternalRows-DOQJV9p2.mjs +0 -1
- package/dist/packem_shared/mergeChangedKeys-BXtUgIPW.mjs +0 -1
- package/dist/packem_shared/param-B5lF5Jd9.mjs +0 -1
- package/dist/packem_shared/quote-identifier-CGiYFBvY.mjs +0 -1
- package/dist/packem_shared/runDrizzle-GKR3y97k.mjs +0 -1
- package/dist/packem_shared/runShardMigrations-CPxqCh3O.mjs +0 -5
- package/dist/packem_shared/runSocketPool-DPQLVyWF.mjs +0 -1
- package/dist/packem_shared/selectExpiredIds-FzhIEeG1.mjs +0 -1
- package/dist/packem_shared/selectShapeMemberIds-DvE7K6zG.mjs +0 -1
- package/dist/packem_shared/serializeSqlValue-DnpyaLcw.mjs +0 -1
- package/dist/packem_shared/stableStringify-BjLh4gvA.mjs +0 -1
- package/dist/packem_shared/stableWireKey-YEHLaX6X.mjs +0 -1
- package/dist/packem_shared/wire-codec-Ctnni0h6.mjs +0 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { LunoraError } from '@lunora/errors';
|
|
2
|
+
import { R2BucketLike, ShardHost, SocketHost, SocketHandle } from '@lunora/platform';
|
|
2
3
|
import { SQL, Name } from 'drizzle-orm';
|
|
3
|
-
import { ShardHost, SocketHost, SocketHandle } from '@lunora/platform';
|
|
4
4
|
interface KeyRange {
|
|
5
5
|
hi: string;
|
|
6
6
|
index: string;
|
|
@@ -27,10 +27,12 @@ interface ScheduledFunctionDoc {
|
|
|
27
27
|
args: Record<string, unknown>;
|
|
28
28
|
attempts?: number;
|
|
29
29
|
enqueuedAt: number;
|
|
30
|
-
functionPath
|
|
30
|
+
functionPath?: string;
|
|
31
31
|
id: string;
|
|
32
|
+
pool?: string;
|
|
32
33
|
scheduledFor: number;
|
|
33
34
|
shardKey?: string;
|
|
35
|
+
workflow?: string;
|
|
34
36
|
}
|
|
35
37
|
interface StorageMetadata {
|
|
36
38
|
contentType?: string;
|
|
@@ -180,9 +182,11 @@ interface SchemaLike {
|
|
|
180
182
|
}
|
|
181
183
|
interface TableDefinitionLike {
|
|
182
184
|
readonly aggregateIndexes?: ReadonlyArray<AggregateIndexDefinitionLike>;
|
|
185
|
+
readonly commitOrderedMode?: boolean;
|
|
183
186
|
readonly geoIndexes?: ReadonlyArray<GeoIndexDefinitionLike>;
|
|
184
187
|
readonly indexes: ReadonlyArray<IndexDefinitionLike>;
|
|
185
188
|
readonly isPublic?: boolean;
|
|
189
|
+
readonly memoryMode?: boolean;
|
|
186
190
|
readonly rankIndexes?: ReadonlyArray<RankIndexDefinitionLike>;
|
|
187
191
|
readonly relationMap?: Record<string, RelationDefinitionLike>;
|
|
188
192
|
readonly searchIndexes?: ReadonlyArray<SearchIndexDefinitionLike>;
|
|
@@ -225,11 +229,16 @@ interface ApplyOnDeleteOptions$1 {
|
|
|
225
229
|
row: Record<string, unknown>;
|
|
226
230
|
tableName: string;
|
|
227
231
|
}
|
|
232
|
+
interface FanOutBudget {
|
|
233
|
+
remaining: number;
|
|
234
|
+
}
|
|
228
235
|
interface ResolveWithOptions {
|
|
236
|
+
fanOutBudget?: FanOutBudget;
|
|
229
237
|
fetcher: (tableName: string, args: QueryArgs) => Promise<QueryPage>;
|
|
230
238
|
groupedCounter: (tableName: string, whereField: string, values: unknown[], policyWhere?: WhereInput) => Promise<Map<unknown, number>>;
|
|
231
239
|
parents: Record<string, unknown>[];
|
|
232
240
|
relationBaseWhere?: (table: string) => undefined | WhereInput;
|
|
241
|
+
relationMask?: RelationMask;
|
|
233
242
|
schema: {
|
|
234
243
|
readonly tables: Record<string, TableDefinitionLike>;
|
|
235
244
|
};
|
|
@@ -248,13 +257,22 @@ interface QueryArgs {
|
|
|
248
257
|
cursor?: null | string;
|
|
249
258
|
includeDeleted?: boolean;
|
|
250
259
|
limit?: number;
|
|
260
|
+
omitContinueCursor?: boolean;
|
|
251
261
|
orderBy?: OrderByInput[];
|
|
252
262
|
relationBaseWhere?: (table: string) => undefined | WhereInput;
|
|
263
|
+
relationMask?: RelationMask;
|
|
253
264
|
restrictsCounts?: boolean;
|
|
254
265
|
select?: ReadonlyArray<string>;
|
|
255
266
|
where?: WhereInput;
|
|
256
267
|
with?: WithInput;
|
|
257
268
|
}
|
|
269
|
+
interface CrossShardReadArgs {
|
|
270
|
+
orderBy?: OrderByInput[];
|
|
271
|
+
relationPolicies?: Record<string, WhereInput>;
|
|
272
|
+
where?: WhereInput;
|
|
273
|
+
with?: WithInput;
|
|
274
|
+
}
|
|
275
|
+
type RelationMask = (table: string, rows: Record<string, unknown>[]) => Record<string, unknown>[];
|
|
258
276
|
interface QueryPage {
|
|
259
277
|
continueCursor: null | string;
|
|
260
278
|
isDone: boolean;
|
|
@@ -264,6 +282,7 @@ interface QueryPage {
|
|
|
264
282
|
interface OrderKey {
|
|
265
283
|
direction: SortDirection;
|
|
266
284
|
field: string;
|
|
285
|
+
nullable: boolean;
|
|
267
286
|
}
|
|
268
287
|
interface RestrictableQueryOptions {
|
|
269
288
|
baseWhere?: WhereInput;
|
|
@@ -414,6 +433,13 @@ interface MutationDelta {
|
|
|
414
433
|
interface DatabaseWriterLike {
|
|
415
434
|
aggregate: (tableName: string, options: AggregateOptions) => Promise<AggregateResult>;
|
|
416
435
|
asId?: (tableName: string, id: string) => string;
|
|
436
|
+
cdcChangedTables?: (sinceSeq: number, options?: {
|
|
437
|
+
cursorOnly?: boolean;
|
|
438
|
+
}) => Promise<{
|
|
439
|
+
cursor: number;
|
|
440
|
+
floor?: number;
|
|
441
|
+
tables: string[];
|
|
442
|
+
} | undefined>;
|
|
417
443
|
count: (tableName: string, where?: RestrictableQueryOptions | WhereInput) => Promise<number>;
|
|
418
444
|
delete: (id: string, expectedTable?: string, options?: {
|
|
419
445
|
hard?: boolean;
|
|
@@ -516,7 +542,6 @@ interface ImportShardResult {
|
|
|
516
542
|
inserted: Record<string, number>;
|
|
517
543
|
}
|
|
518
544
|
declare const selectExportTables: (schema: SchemaLike, requested?: ReadonlyArray<string>) => string[];
|
|
519
|
-
declare const exportShardTable: (writer: DatabaseWriterLike, table: string, batchSize?: number) => AsyncGenerator<ExportRow, void, undefined>;
|
|
520
545
|
declare const exportShardRows: (writer: DatabaseWriterLike, schema: SchemaLike, args: ExportShardArgs) => AsyncGenerator<ExportRow, void, undefined>;
|
|
521
546
|
declare const validateImportRow: (schema: SchemaLike, table: string, record: Record<string, unknown>) => string | undefined;
|
|
522
547
|
declare const importShardRows: (writer: DatabaseWriterLike, schema: SchemaLike, args: ImportShardArgs) => Promise<ImportShardResult>;
|
|
@@ -591,6 +616,7 @@ declare class ReactiveCache {
|
|
|
591
616
|
private readonly maxBytes;
|
|
592
617
|
private readonly now;
|
|
593
618
|
private monotonic;
|
|
619
|
+
private generation;
|
|
594
620
|
constructor(options?: ReactiveCacheOptions);
|
|
595
621
|
run<R>(key: string, deps: Set<string>, run: () => Promise<R>, ranges?: () => ReadonlyArray<KeyRange>): Promise<R>;
|
|
596
622
|
invalidate(table: string, id: string, indexKeys?: ReadonlyArray<IndexKeyEntry>): string[];
|
|
@@ -612,6 +638,7 @@ declare class ReactiveCache {
|
|
|
612
638
|
};
|
|
613
639
|
private dropRangeDeps;
|
|
614
640
|
private collectAndDrop;
|
|
641
|
+
private dropKeys;
|
|
615
642
|
private dropEntry;
|
|
616
643
|
private evict;
|
|
617
644
|
}
|
|
@@ -650,12 +677,18 @@ interface RunTriggersOptions {
|
|
|
650
677
|
}
|
|
651
678
|
declare const runTriggers: (options: RunTriggersOptions) => Promise<void>;
|
|
652
679
|
declare const hasTrigger: (schema: SchemaLike, tableName: string, op: TriggerOpLike) => boolean;
|
|
680
|
+
interface SearchBackfillProgress {
|
|
681
|
+
done: boolean;
|
|
682
|
+
pages: number;
|
|
683
|
+
}
|
|
653
684
|
declare const backfillAggregateIndexes: (sql: SqlExec, schema: SchemaLike) => void;
|
|
654
685
|
declare const backfillRankIndexes: (sql: SqlExec, schema: SchemaLike) => void;
|
|
655
686
|
declare const backfillSearchIndexesForTable: (sql: SqlExec, tableName: string, definition: {
|
|
656
687
|
searchIndexes?: ReadonlyArray<SearchIndexDefinitionLike>;
|
|
657
688
|
}) => void;
|
|
658
|
-
declare const backfillSearchIndexes: (sql: SqlExec, schema: SchemaLike
|
|
689
|
+
declare const backfillSearchIndexes: (sql: SqlExec, schema: SchemaLike, options?: {
|
|
690
|
+
maxPages?: number;
|
|
691
|
+
}) => SearchBackfillProgress;
|
|
659
692
|
declare const CDC_LOG_TABLE = "__cdc_log";
|
|
660
693
|
interface CdcChange {
|
|
661
694
|
doc?: Record<string, unknown>;
|
|
@@ -665,6 +698,7 @@ interface CdcChange {
|
|
|
665
698
|
table: string;
|
|
666
699
|
ts: number;
|
|
667
700
|
}
|
|
701
|
+
declare const CDC_LOG_TABLE_SEQ_INDEX = "__cdc_log_table_seq";
|
|
668
702
|
declare const migrateCdcLog: (sql: SqlExec) => void;
|
|
669
703
|
declare const appendCdcChange: (sql: SqlExec, ts: number, table: string, id: string, op: CdcChange["op"], doc: Record<string, unknown> | undefined) => void;
|
|
670
704
|
declare const readCdcChanges: (sql: SqlExec, options?: {
|
|
@@ -675,9 +709,22 @@ declare const readCdcChanges: (sql: SqlExec, options?: {
|
|
|
675
709
|
changes: CdcChange[];
|
|
676
710
|
cursor: number;
|
|
677
711
|
};
|
|
678
|
-
declare const
|
|
712
|
+
declare const cdcTouchesTables: (sql: SqlExec, sinceSeq: number, tables: ReadonlySet<string>) => boolean;
|
|
713
|
+
declare const cdcCanVouchFor: (sql: SqlExec, deps: ReadonlySet<string>) => boolean;
|
|
714
|
+
interface CdcChangeKey {
|
|
715
|
+
id: string;
|
|
716
|
+
op: CdcChange["op"];
|
|
717
|
+
seq: number;
|
|
718
|
+
}
|
|
719
|
+
declare const readCdcChangeKeys: (sql: SqlExec, table: string, sinceSeq: number, upTo: number) => CdcChangeKey[];
|
|
720
|
+
declare const trimCdcChanges: (sql: SqlExec, throughSeq: number, maxRows: number) => void;
|
|
721
|
+
declare const compactCdcDocs: (sql: SqlExec, throughSeq: number, maxRows: number) => void;
|
|
722
|
+
declare const cdcSeqLeavingRows: (sql: SqlExec, keep: number) => number | undefined;
|
|
679
723
|
declare const readCdcCursor: (sql: SqlExec) => number;
|
|
724
|
+
declare const cursorBelowRetainedFloor: (floor: number | undefined, sinceSeq: number) => boolean;
|
|
725
|
+
declare const cdcTrimmedError: (floor: number, sinceSeq: number, scope: "global" | "shard") => LunoraError;
|
|
680
726
|
declare const minCdcSeq: (sql: SqlExec) => number | undefined;
|
|
727
|
+
declare const minCdcReplayableSeq: (sql: SqlExec) => number | undefined;
|
|
681
728
|
declare const CDC_META_TABLE = "__cdc_meta";
|
|
682
729
|
declare const migrateCdcMeta: (sql: SqlExec) => void;
|
|
683
730
|
declare const readCdcEpoch: (sql: SqlExec) => string;
|
|
@@ -689,7 +736,7 @@ declare const readClientWatermark: (sql: SqlExec, identity: string, clientId: st
|
|
|
689
736
|
declare const advanceClientWatermark: (sql: SqlExec, identity: string, clientId: string, mutationId: number) => void;
|
|
690
737
|
declare const GLOBAL_SHAPE_SNAPSHOT_TABLE = "__global_shape_snapshot";
|
|
691
738
|
declare const migrateGlobalShapeSnapshot: (sql: SqlExec) => void;
|
|
692
|
-
declare const readGlobalShapeSnapshot: (sql: SqlExec, connectionId: string, subId: string) => Map<string, string
|
|
739
|
+
declare const readGlobalShapeSnapshot: (sql: SqlExec, connectionId: string, subId: string) => Map<string, string> | undefined;
|
|
693
740
|
declare const writeGlobalShapeSnapshot: (sql: SqlExec, connectionId: string, subId: string, snapshot: Map<string, string>) => void;
|
|
694
741
|
declare const deleteGlobalShapeSnapshot: (sql: SqlExec, connectionId: string, subId: string) => void;
|
|
695
742
|
declare const deleteGlobalShapeSnapshotsForConnection: (sql: SqlExec, connectionId: string) => void;
|
|
@@ -747,7 +794,7 @@ interface ShapeRow {
|
|
|
747
794
|
id: string;
|
|
748
795
|
}
|
|
749
796
|
declare const selectShapeRows: (sql: SqlExec, table: string, effectiveWhere: WhereInput | undefined) => ShapeRow[];
|
|
750
|
-
declare const
|
|
797
|
+
declare const selectShapeMembers: (sql: SqlExec, table: string, effectiveWhere: WhereInput | undefined, ids: ReadonlyArray<string>) => Map<string, Record<string, unknown>>;
|
|
751
798
|
interface SqlExec {
|
|
752
799
|
exec: <Row = Record<string, unknown>>(sql: string, ...params: unknown[]) => SqlCursor<Row>;
|
|
753
800
|
}
|
|
@@ -776,6 +823,7 @@ interface CtxDbOptions {
|
|
|
776
823
|
globalDb?: DatabaseWriterLike;
|
|
777
824
|
headroom?: TransactionHeadroomTracker;
|
|
778
825
|
idGenerator?: IdGenerator;
|
|
826
|
+
inTransaction?: () => boolean;
|
|
779
827
|
maxRelationKeys?: number;
|
|
780
828
|
onIndexUse?: IndexUseHook;
|
|
781
829
|
onRead?: ReadHook;
|
|
@@ -792,6 +840,7 @@ declare class NotUniqueError extends LunoraError {
|
|
|
792
840
|
constructor(message?: string);
|
|
793
841
|
}
|
|
794
842
|
declare const normalizeIdStructurally: (schema: SchemaLike, tableName: string, id: string) => null | string;
|
|
843
|
+
declare const assertNoExplicitUndefined: (op: "patch" | "replace", document: Record<string, unknown>) => void;
|
|
795
844
|
declare const createShardCtxDb: (options: CtxDbOptions) => DatabaseWriterLike;
|
|
796
845
|
declare const AUDIT_LOG_TABLE = "__lunora_audit__";
|
|
797
846
|
interface AuditEntry {
|
|
@@ -815,6 +864,22 @@ declare const readAuditLog: (sql: SqlExec, options?: {
|
|
|
815
864
|
limit?: number;
|
|
816
865
|
sinceSeq?: number;
|
|
817
866
|
}) => AuditEntry[];
|
|
867
|
+
interface CdcArchiveScope {
|
|
868
|
+
epoch: string;
|
|
869
|
+
shard: string;
|
|
870
|
+
}
|
|
871
|
+
declare const readCdcArchivedThrough: (sql: SqlExec) => number;
|
|
872
|
+
declare const writeCdcArchivedThrough: (sql: SqlExec, seq: number) => void;
|
|
873
|
+
declare const archiveCdcSegment: (bucket: R2BucketLike, scope: CdcArchiveScope, changes: CdcChange[]) => Promise<void>;
|
|
874
|
+
declare const readArchivedCdcChanges: (bucket: R2BucketLike, scope: CdcArchiveScope, sinceSeq: number, limit: number | undefined) => Promise<{
|
|
875
|
+
changes: CdcChange[];
|
|
876
|
+
cursor: number;
|
|
877
|
+
} | undefined>;
|
|
878
|
+
declare const COMMIT_SEQ_TABLE = "__commit_seq";
|
|
879
|
+
declare const COMMIT_SEQ_FIELD = "_commitSeq";
|
|
880
|
+
declare const migrateCommitSeq: (sql: SqlExec) => void;
|
|
881
|
+
declare const readCommitSeq: (sql: SqlExec) => number;
|
|
882
|
+
declare const allocateCommitSeq: (sql: SqlExec) => number;
|
|
818
883
|
interface SubscriptionQuery {
|
|
819
884
|
args?: Record<string, unknown>;
|
|
820
885
|
functionPath?: string;
|
|
@@ -829,9 +894,11 @@ interface ShapeSubscriptionQuery {
|
|
|
829
894
|
sinceSeq?: number;
|
|
830
895
|
}
|
|
831
896
|
interface SubscriptionEnvelope {
|
|
897
|
+
caps?: string[];
|
|
832
898
|
clientId?: string;
|
|
833
899
|
context?: Record<string, unknown>;
|
|
834
900
|
data?: unknown;
|
|
901
|
+
generation?: number;
|
|
835
902
|
id: string;
|
|
836
903
|
query?: SubscriptionQuery;
|
|
837
904
|
shape?: {
|
|
@@ -839,6 +906,7 @@ interface SubscriptionEnvelope {
|
|
|
839
906
|
name: string;
|
|
840
907
|
};
|
|
841
908
|
sinceCheckpoint?: number;
|
|
909
|
+
sinceChunk?: number;
|
|
842
910
|
sinceEpoch?: string;
|
|
843
911
|
topic?: string;
|
|
844
912
|
type: "ack" | "connect" | "shape_subscribe" | "shape_unsubscribe" | "stream" | "subscribe" | "unsubscribe" | "whisper" | "whisper_subscribe" | "whisper_unsubscribe";
|
|
@@ -855,6 +923,7 @@ interface SocketAttachment {
|
|
|
855
923
|
context?: Record<string, unknown>;
|
|
856
924
|
expiresAt?: number;
|
|
857
925
|
identity?: Record<string, unknown>;
|
|
926
|
+
pageDeltas?: boolean;
|
|
858
927
|
shapes?: Record<string, ShapeSubscriptionQuery>;
|
|
859
928
|
subs: Record<string, SubscriptionQuery>;
|
|
860
929
|
userId?: string;
|
|
@@ -900,6 +969,13 @@ interface CompanionSync {
|
|
|
900
969
|
syncSearch: (tableName: string, id: string, document: Record<string, unknown> | undefined, previous?: Record<string, unknown>) => void;
|
|
901
970
|
}
|
|
902
971
|
declare const createCompanionSync: (deps: CompanionSyncDeps) => CompanionSync;
|
|
972
|
+
declare const isMemoryTable: (definition: TableDefinitionLike | undefined) => boolean;
|
|
973
|
+
declare const memoryTableNames: (schema: SchemaLike) => string[];
|
|
974
|
+
declare const clearMemoryTables: (sql: SqlExec, schema: SchemaLike) => number;
|
|
975
|
+
declare const resolveRankSeekTuple: (options: {
|
|
976
|
+
after?: RankPageRowKey;
|
|
977
|
+
cursor?: null | string;
|
|
978
|
+
}) => unknown[] | undefined;
|
|
903
979
|
interface RankPageDeps {
|
|
904
980
|
assertRankPartitionLocal: (tableName: string, definition: TableDefinitionLike, index: RankIndexDefinitionLike) => void;
|
|
905
981
|
ensureRankBackfilled: (tableName: string, index: RankIndexDefinitionLike) => void;
|
|
@@ -917,8 +993,20 @@ interface RankPageComputation {
|
|
|
917
993
|
key: RankPageRowKey;
|
|
918
994
|
}[];
|
|
919
995
|
}
|
|
920
|
-
declare const hydrateDocsById: (deps: RankPageDeps, tableName: string, ids: ReadonlyArray<string>) => Map<string, Record<string, unknown>>;
|
|
921
996
|
declare const computeRankPage: (deps: RankPageDeps, tableName: string, indexName: string, rankPageOptions: RankPageOptions) => RankPageComputation;
|
|
997
|
+
declare const SHAPE_POKE_CURSOR_TABLE = "__shape_poke_cursor";
|
|
998
|
+
declare const migrateShapePokeCursor: (sql: SqlExec) => void;
|
|
999
|
+
declare const readShapePokeCursor: (sql: SqlExec, connectionId: string, subId: string) => number | undefined;
|
|
1000
|
+
declare const writeShapePokeCursor: (sql: SqlExec, connectionId: string, subId: string, cursor: number) => void;
|
|
1001
|
+
interface ShapePokeCursorRow {
|
|
1002
|
+
connectionId: string;
|
|
1003
|
+
cursor: number;
|
|
1004
|
+
subId: string;
|
|
1005
|
+
}
|
|
1006
|
+
declare const writeShapePokeCursors: (sql: SqlExec, rows: ReadonlyArray<ShapePokeCursorRow>) => void;
|
|
1007
|
+
declare const minShapePokeCursor: (sql: SqlExec) => number | undefined;
|
|
1008
|
+
declare const deleteShapePokeCursor: (sql: SqlExec, connectionId: string, subId: string) => void;
|
|
1009
|
+
declare const deleteShapePokeCursorsForConnection: (sql: SqlExec, connectionId: string) => void;
|
|
922
1010
|
declare const DATA_MIGRATION_STATE_TABLE = "__lunora_migrations";
|
|
923
1011
|
type MigrationDirection = "down" | "up";
|
|
924
1012
|
type MigrationStatus = "completed" | "failed" | "in_progress";
|
|
@@ -982,10 +1070,10 @@ interface DependencyTracker {
|
|
|
982
1070
|
declare const createDependencyTracker: () => DependencyTracker;
|
|
983
1071
|
declare const runSql: <Row = Record<string, unknown>>(sql: SqlExec, query: string, ...params: unknown[]) => SqlCursor<Row>;
|
|
984
1072
|
declare const runDrizzle: <Row = Record<string, unknown>>(exec: SqlExec, query: SQL) => SqlCursor<Row>;
|
|
1073
|
+
declare const quoteIdentifier: (name: string) => string;
|
|
985
1074
|
declare const serializeSqlValue: (value: unknown) => unknown;
|
|
986
1075
|
declare const DOC_COLUMN = "__doc__";
|
|
987
1076
|
declare const geoTableName: (table: string, indexName: string) => string;
|
|
988
|
-
declare const quoteIdentifier: (name: string) => string;
|
|
989
1077
|
declare const jsonPath: (field: string) => string;
|
|
990
1078
|
declare const jsonPathSql: (field: string) => SQL;
|
|
991
1079
|
declare const qualifiedJsonPath: (table: string, field: string) => string;
|
|
@@ -995,7 +1083,7 @@ declare const AGG_KEY: Name;
|
|
|
995
1083
|
declare const AGG_VALUE: Name;
|
|
996
1084
|
declare const AGG_COUNT: Name;
|
|
997
1085
|
declare const aggUpsertSql: (aggTable: string, key: unknown, value: unknown, count: unknown, set: SQL) => SQL;
|
|
998
|
-
declare const tableColumns: (definition: TableDefinitionLike) => [string, ColumnMetaLike]
|
|
1086
|
+
declare const tableColumns: (definition: TableDefinitionLike) => ReadonlyArray<readonly [string, ColumnMetaLike]>;
|
|
999
1087
|
declare const rowToDocument: (row: Record<string, unknown> | undefined) => Record<string, unknown> | undefined;
|
|
1000
1088
|
declare const tryRowToDocument: (row: Record<string, unknown> | undefined) => Record<string, unknown> | undefined;
|
|
1001
1089
|
declare const isFtsAvailable: (sql: SqlExec) => boolean;
|
|
@@ -1006,6 +1094,79 @@ interface RenderedSql {
|
|
|
1006
1094
|
}
|
|
1007
1095
|
declare const renderSql: (engine: SqlEngine, query: SQL) => RenderedSql;
|
|
1008
1096
|
declare const param: (value: unknown) => SQL;
|
|
1097
|
+
declare const unionAll: (branches: ReadonlyArray<SQL>) => SQL;
|
|
1098
|
+
declare const sqliteInList: (reference: SQL, items: ReadonlyArray<unknown>, negated: boolean, budget?: number) => SQL;
|
|
1099
|
+
type DurableStreamStatus = "complete" | "error" | "running";
|
|
1100
|
+
interface DurableStreamRun {
|
|
1101
|
+
error?: string;
|
|
1102
|
+
errorCode?: string;
|
|
1103
|
+
lastSeq: number;
|
|
1104
|
+
startedAt: number;
|
|
1105
|
+
status: DurableStreamStatus;
|
|
1106
|
+
}
|
|
1107
|
+
interface DurableStreamChunk {
|
|
1108
|
+
dataJson: string;
|
|
1109
|
+
seq: number;
|
|
1110
|
+
}
|
|
1111
|
+
declare const migrateDurableStreams: (sql: SqlExec) => void;
|
|
1112
|
+
declare const readStreamRun: (sql: SqlExec, runKey: string) => DurableStreamRun | undefined;
|
|
1113
|
+
declare const claimStreamRun: (sql: SqlExec, runKey: string, startedAt: number, ttlMs: number) => boolean;
|
|
1114
|
+
declare const deleteStreamRun: (sql: SqlExec, runKey: string) => void;
|
|
1115
|
+
declare const appendStreamChunk: (sql: SqlExec, runKey: string, seq: number, dataJson: string) => void;
|
|
1116
|
+
declare const readStreamChunks: (sql: SqlExec, runKey: string, sinceSeq: number) => DurableStreamChunk[];
|
|
1117
|
+
declare const finishStreamRun: (sql: SqlExec, runKey: string, status: "complete" | "error", lastSeq: number, failure?: {
|
|
1118
|
+
code: string;
|
|
1119
|
+
message: string;
|
|
1120
|
+
}) => void;
|
|
1121
|
+
declare const trimStreamRuns: (sql: SqlExec, now: number) => void;
|
|
1122
|
+
declare const MAX_DURABLE_STREAM_CHUNKS = 50000;
|
|
1123
|
+
declare const MAX_DURABLE_STREAM_BYTES: number;
|
|
1124
|
+
interface DurableStreamSink {
|
|
1125
|
+
readonly chunk: (chunk: {
|
|
1126
|
+
data: unknown;
|
|
1127
|
+
generation?: number;
|
|
1128
|
+
seq: number;
|
|
1129
|
+
}) => boolean;
|
|
1130
|
+
readonly complete: () => void;
|
|
1131
|
+
readonly fail: (failure: {
|
|
1132
|
+
code: string;
|
|
1133
|
+
message: string;
|
|
1134
|
+
}) => void;
|
|
1135
|
+
}
|
|
1136
|
+
type DurableAttachDecision = "attach" | "interrupted" | "reclaim" | "replay-terminal";
|
|
1137
|
+
declare const decideDurableAttach: (run: DurableStreamRun | undefined, context: {
|
|
1138
|
+
generation?: number;
|
|
1139
|
+
live?: {
|
|
1140
|
+
generation: number;
|
|
1141
|
+
};
|
|
1142
|
+
resuming: boolean;
|
|
1143
|
+
}) => DurableAttachDecision;
|
|
1144
|
+
interface DurableStreamAttach {
|
|
1145
|
+
readonly generation?: number;
|
|
1146
|
+
readonly iterator: (signal: AbortSignal) => AsyncIterable<unknown>;
|
|
1147
|
+
readonly runKey: string;
|
|
1148
|
+
readonly sinceChunk: number;
|
|
1149
|
+
readonly sink: DurableStreamSink;
|
|
1150
|
+
readonly ttlMs?: number;
|
|
1151
|
+
}
|
|
1152
|
+
declare class DurableStreamRunner {
|
|
1153
|
+
private lastTrimAt;
|
|
1154
|
+
private readonly runs;
|
|
1155
|
+
private readonly sql;
|
|
1156
|
+
private readonly waitUntil;
|
|
1157
|
+
constructor(dependencies: {
|
|
1158
|
+
sql: () => SqlExec;
|
|
1159
|
+
waitUntil?: (promise: Promise<unknown>) => void;
|
|
1160
|
+
});
|
|
1161
|
+
attach(request: DurableStreamAttach): Promise<void>;
|
|
1162
|
+
detach(runKey: string, sink: DurableStreamSink): void;
|
|
1163
|
+
isLive(runKey: string): boolean;
|
|
1164
|
+
private attachOrThrow;
|
|
1165
|
+
private produce;
|
|
1166
|
+
private trim;
|
|
1167
|
+
}
|
|
1168
|
+
declare const envPositiveInt: (env: unknown, key: string, fallback: number) => number;
|
|
1169
|
+
declare const envOptionalPositiveInt: (env: unknown, key: string) => number | undefined;
|
|
1009
1170
|
interface ExternalSourceDiffResult {
|
|
1010
1171
|
changes: CdcChange[];
|
|
1011
1172
|
nextBaseline: Map<string, string>;
|
|
@@ -1085,6 +1246,19 @@ declare const coveringGeohashes: (center: GeoPoint, radiusMeters: number) => str
|
|
|
1085
1246
|
declare const pointInBoundingBox: (point: GeoPoint, box: GeoBoundingBox) => boolean;
|
|
1086
1247
|
declare const boundingBoxCenter: (box: GeoBoundingBox) => GeoPoint;
|
|
1087
1248
|
declare const boundingBoxGeohashes: (box: GeoBoundingBox) => string[];
|
|
1249
|
+
declare class GlobalPollTick {
|
|
1250
|
+
private readonly changedTables;
|
|
1251
|
+
private readonly reads;
|
|
1252
|
+
private resync;
|
|
1253
|
+
private skippedCount;
|
|
1254
|
+
constructor(changedTables?: Set<string>);
|
|
1255
|
+
get readCount(): number;
|
|
1256
|
+
get resyncRequested(): boolean;
|
|
1257
|
+
get skipped(): number;
|
|
1258
|
+
requestResync(): void;
|
|
1259
|
+
rows(key: string | undefined, load: () => Promise<ShapeRow[]>): Promise<ShapeRow[]>;
|
|
1260
|
+
shouldRead(table: string): boolean;
|
|
1261
|
+
}
|
|
1088
1262
|
declare const ADMIN_FUNCTION_PREFIX = "__lunora_admin__:";
|
|
1089
1263
|
declare const RELATION_FUNCTION_PREFIX = "__lunora_relation__:";
|
|
1090
1264
|
declare const FLAGS_FUNCTION_PREFIX = "__lunora_flags__:";
|
|
@@ -1095,6 +1269,7 @@ declare const ADMIN_FUNCTIONS: {
|
|
|
1095
1269
|
readonly aiGenerateSql: "__lunora_admin__:aiGenerateSql";
|
|
1096
1270
|
readonly aiTableFilter: "__lunora_admin__:aiTableFilter";
|
|
1097
1271
|
readonly assignIssue: "__lunora_admin__:assignIssue";
|
|
1272
|
+
readonly backfillSearch: "__lunora_admin__:backfillSearch";
|
|
1098
1273
|
readonly backRelationCounts: "__lunora_admin__:backRelationCounts";
|
|
1099
1274
|
readonly cdcSync: "__lunora_admin__:cdcSync";
|
|
1100
1275
|
readonly clearCapturedMail: "__lunora_admin__:clearCapturedMail";
|
|
@@ -1133,12 +1308,14 @@ declare const ADMIN_FUNCTIONS: {
|
|
|
1133
1308
|
readonly ignoreIssue: "__lunora_admin__:ignoreIssue";
|
|
1134
1309
|
readonly importShard: "__lunora_admin__:importShard";
|
|
1135
1310
|
readonly listFlags: "__lunora_admin__:listFlags";
|
|
1311
|
+
readonly listReactors: "__lunora_admin__:listReactors";
|
|
1136
1312
|
readonly listQueues: "__lunora_admin__:listQueues";
|
|
1137
1313
|
readonly lintSql: "__lunora_admin__:lintSql";
|
|
1138
1314
|
readonly listTables: "__lunora_admin__:listTables";
|
|
1139
1315
|
readonly listWorkflows: "__lunora_admin__:listWorkflows";
|
|
1140
1316
|
readonly maskPolicies: "__lunora_admin__:maskPolicies";
|
|
1141
1317
|
readonly migrationStatus: "__lunora_admin__:migrationStatus";
|
|
1318
|
+
readonly patchRows: "__lunora_admin__:patchRows";
|
|
1142
1319
|
readonly pitrRestore: "__lunora_admin__:pitrRestore";
|
|
1143
1320
|
readonly rankBefore: "__lunora_admin__:rankBefore";
|
|
1144
1321
|
readonly rankPage: "__lunora_admin__:rankPage";
|
|
@@ -1216,8 +1393,11 @@ interface TablesIndexesResult {
|
|
|
1216
1393
|
indexesByTable: Record<string, TableIndexInfo[]>;
|
|
1217
1394
|
}
|
|
1218
1395
|
interface ColumnMeta {
|
|
1396
|
+
bucket?: string;
|
|
1397
|
+
enumValues?: string[];
|
|
1219
1398
|
isStorage?: boolean;
|
|
1220
1399
|
name: string;
|
|
1400
|
+
nullable?: boolean;
|
|
1221
1401
|
optional: boolean;
|
|
1222
1402
|
pk?: boolean;
|
|
1223
1403
|
ref?: string;
|
|
@@ -1332,6 +1512,19 @@ interface FlagsResult {
|
|
|
1332
1512
|
configured: boolean;
|
|
1333
1513
|
flags: FlagEvaluation[];
|
|
1334
1514
|
}
|
|
1515
|
+
interface ReactorMetadata {
|
|
1516
|
+
errors: number;
|
|
1517
|
+
lastError?: string;
|
|
1518
|
+
lastRanAt?: number;
|
|
1519
|
+
path: string;
|
|
1520
|
+
runs: number;
|
|
1521
|
+
state: "active" | "failing" | "idle";
|
|
1522
|
+
suppressed: number;
|
|
1523
|
+
tables?: ReadonlyArray<string>;
|
|
1524
|
+
}
|
|
1525
|
+
interface ReactorsResult {
|
|
1526
|
+
reactors: ReactorMetadata[];
|
|
1527
|
+
}
|
|
1335
1528
|
interface WorkflowMetadata {
|
|
1336
1529
|
binding: string;
|
|
1337
1530
|
className: string;
|
|
@@ -1413,6 +1606,7 @@ interface ReadTablePageOptions {
|
|
|
1413
1606
|
table: string;
|
|
1414
1607
|
}
|
|
1415
1608
|
interface SelectMatchingIdsOptions {
|
|
1609
|
+
after?: string;
|
|
1416
1610
|
filters?: FilterClause[];
|
|
1417
1611
|
limit?: number;
|
|
1418
1612
|
search?: string;
|
|
@@ -1469,12 +1663,22 @@ interface FanoutPathCounters {
|
|
|
1469
1663
|
socketsIterated: number;
|
|
1470
1664
|
totalMs: number;
|
|
1471
1665
|
}
|
|
1666
|
+
interface ShapeProbeCounters {
|
|
1667
|
+
run: number;
|
|
1668
|
+
served: number;
|
|
1669
|
+
}
|
|
1670
|
+
interface GlobalPollCounters {
|
|
1671
|
+
drains: number;
|
|
1672
|
+
pairsSkipped: number;
|
|
1673
|
+
}
|
|
1472
1674
|
interface FanoutMetricsResult {
|
|
1675
|
+
globalPoll: GlobalPollCounters;
|
|
1473
1676
|
maxRelays: number;
|
|
1474
1677
|
peakSubscribers: number;
|
|
1475
1678
|
promoted: boolean;
|
|
1476
1679
|
relayCount: number;
|
|
1477
1680
|
shapePoke: FanoutPathCounters;
|
|
1681
|
+
shapeProbe: ShapeProbeCounters;
|
|
1478
1682
|
sinceMs: number;
|
|
1479
1683
|
topics: FanoutTopicStat[];
|
|
1480
1684
|
totalConnections: number;
|
|
@@ -1488,6 +1692,10 @@ interface FanoutAttachmentLike {
|
|
|
1488
1692
|
}
|
|
1489
1693
|
declare const DEFAULT_FANOUT_TOPIC_LIMIT = 20;
|
|
1490
1694
|
declare const createFanoutCounters: () => FanoutPathCounters;
|
|
1695
|
+
declare const createShapeProbeCounters: () => ShapeProbeCounters;
|
|
1696
|
+
declare const createGlobalPollCounters: () => GlobalPollCounters;
|
|
1697
|
+
declare const recordGlobalPollPass: (counters: GlobalPollCounters, drains: number, pairsSkipped: number) => GlobalPollCounters;
|
|
1698
|
+
declare const recordShapeProbePass: (counters: ShapeProbeCounters, run: number, served: number) => ShapeProbeCounters;
|
|
1491
1699
|
declare const recordFanoutPass: (counters: FanoutPathCounters, iterated: number, delivered: number, ms: number) => FanoutPathCounters;
|
|
1492
1700
|
declare const summarizeFanoutTopics: (attachments: FanoutAttachmentLike[], limit?: number) => {
|
|
1493
1701
|
peakSubscribers: number;
|
|
@@ -1556,7 +1764,11 @@ interface PitrRestoreArgs {
|
|
|
1556
1764
|
}
|
|
1557
1765
|
declare const readBookmark: (storage: PitrStorage, time?: number | string) => Promise<PitrBookmarkResult>;
|
|
1558
1766
|
declare const armRestore: (storage: PitrStorage, args: PitrRestoreArgs) => Promise<Omit<PitrRestoreResult, "restarted">>;
|
|
1559
|
-
declare const
|
|
1767
|
+
declare const tiebreakDirectionFor: (keys: ReadonlyArray<{
|
|
1768
|
+
direction?: string;
|
|
1769
|
+
}>) => SortDirection;
|
|
1770
|
+
declare const normalizeOrderKeys: (orderBy: OrderByInput[] | undefined, shape?: Record<string, ValidatorLike>) => OrderKey[];
|
|
1771
|
+
declare const CURSOR_PREFIX = "~3";
|
|
1560
1772
|
declare const encodeCursor: (record: Record<string, unknown>, keys: OrderKey[]) => string;
|
|
1561
1773
|
declare const decodeCursor: (cursor: string) => unknown[];
|
|
1562
1774
|
declare const buildSeekWhere: (keys: OrderKey[], cursorValues: unknown[]) => WhereInput;
|
|
@@ -1609,7 +1821,6 @@ declare const clearQueueMessages: (sql: SqlExec) => {
|
|
|
1609
1821
|
declare const encodePartitionKey: (partitionBy: ReadonlyArray<string>, source: Record<string, unknown>) => string;
|
|
1610
1822
|
declare const RANK_TIEBREAK = "__id__";
|
|
1611
1823
|
declare const sortColumnName: (i: number) => string;
|
|
1612
|
-
declare const matchesRankStaticWhere: (document: Record<string, unknown>, predicate: Record<string, unknown>) => boolean;
|
|
1613
1824
|
declare const resolveRankPartition: (index: RankIndexDefinitionLike, where: Record<string, unknown> | undefined) => Record<string, unknown> | undefined;
|
|
1614
1825
|
declare const rankTableName: (table: string, indexName: string) => string;
|
|
1615
1826
|
declare const rankKeyFromDocument: (index: RankIndexDefinitionLike, document_: Record<string, unknown>) => {
|
|
@@ -1617,6 +1828,35 @@ declare const rankKeyFromDocument: (index: RankIndexDefinitionLike, document_: R
|
|
|
1617
1828
|
rowId: string;
|
|
1618
1829
|
sortValues: unknown[];
|
|
1619
1830
|
};
|
|
1831
|
+
declare const matchesRankStaticWhere: (document: Record<string, unknown>, predicate: Record<string, unknown>) => boolean;
|
|
1832
|
+
declare const REACTOR_STATE_TABLE = "__reactor_state";
|
|
1833
|
+
interface ReactorState {
|
|
1834
|
+
digest: string;
|
|
1835
|
+
lastError?: string;
|
|
1836
|
+
lastRanAt: number;
|
|
1837
|
+
stats: ReactorStats;
|
|
1838
|
+
tables?: ReadonlyArray<string>;
|
|
1839
|
+
}
|
|
1840
|
+
interface ReactorStats {
|
|
1841
|
+
errors: number;
|
|
1842
|
+
runs: number;
|
|
1843
|
+
suppressed: number;
|
|
1844
|
+
}
|
|
1845
|
+
declare const migrateReactorState: (sql: SqlExec) => void;
|
|
1846
|
+
declare const readReactorState: (sql: SqlExec, path: string) => ReactorState | undefined;
|
|
1847
|
+
declare const listReactorStates: (sql: SqlExec) => {
|
|
1848
|
+
path: string;
|
|
1849
|
+
state: ReactorState;
|
|
1850
|
+
}[];
|
|
1851
|
+
type ReactorDispatchResult = "error" | "ran" | "suppressed";
|
|
1852
|
+
declare const writeReactorState: (sql: SqlExec, path: string, outcome: {
|
|
1853
|
+
digest?: string;
|
|
1854
|
+
error?: string;
|
|
1855
|
+
now: number;
|
|
1856
|
+
result: ReactorDispatchResult;
|
|
1857
|
+
tables?: ReadonlyArray<string>;
|
|
1858
|
+
}) => void;
|
|
1859
|
+
declare const reactorNeedsRun: (state: Pick<ReactorState, "tables"> | undefined, changed: ReadonlySet<string>) => boolean;
|
|
1620
1860
|
interface ReadFootprint {
|
|
1621
1861
|
onRead: (table: string, idOrScan?: string) => void;
|
|
1622
1862
|
onReadRange: (range: KeyRange) => void;
|
|
@@ -1624,6 +1864,8 @@ interface ReadFootprint {
|
|
|
1624
1864
|
tables: Set<string>;
|
|
1625
1865
|
}
|
|
1626
1866
|
declare const createReadFootprint: () => ReadFootprint;
|
|
1867
|
+
declare const UNVOUCHABLE_DEP = "!unvouchable";
|
|
1868
|
+
declare const markUnvouchableReads: <T extends object>(facade: T, onRead: ReadFootprint["onRead"] | undefined, methods: ReadonlyArray<string>) => T;
|
|
1627
1869
|
declare const DEFAULT_MAX_RELATION_KEYS = 5000;
|
|
1628
1870
|
interface RelationExistsMarker {
|
|
1629
1871
|
childWhere: WhereInput;
|
|
@@ -1658,6 +1900,7 @@ declare const containsRelationPredicate: (where: WhereInput, schema: ResolveCont
|
|
|
1658
1900
|
declare const assertFlatPredicate: (where: WhereInput | undefined, schema: ResolveContext["schema"], tableName: string, op: string) => void;
|
|
1659
1901
|
declare const resolveRelationPredicates: (where: WhereInput | undefined, options: ResolveRelationPredicatesOptions) => Promise<WhereInput | undefined>;
|
|
1660
1902
|
declare const assertShapeShardable: (effectiveWhere: WhereInput | undefined, schema: ResolveContext["schema"], table: string) => void;
|
|
1903
|
+
declare const relationHooks: (args: Pick<QueryArgs, "relationBaseWhere" | "relationMask">) => Pick<QueryArgs, "relationBaseWhere" | "relationMask"> & Pick<ResolveWithOptions, "fanOutBudget">;
|
|
1661
1904
|
declare const fanOutScalarCounts: (counter: (tableName: string, where?: WhereInput) => Promise<number>, tableName: string, whereField: string, values: unknown[], policyWhere: WhereInput | undefined) => Promise<Map<unknown, number>>;
|
|
1662
1905
|
declare const distinctValues: (rows: Record<string, unknown>[], field: string) => unknown[];
|
|
1663
1906
|
declare const resolveWith: (options: ResolveWithOptions) => Promise<void>;
|
|
@@ -1682,6 +1925,8 @@ interface ShapeRowOp {
|
|
|
1682
1925
|
value?: Record<string, unknown>;
|
|
1683
1926
|
}
|
|
1684
1927
|
interface ShapePokePart {
|
|
1928
|
+
baseCheckpoint?: number;
|
|
1929
|
+
reset?: boolean;
|
|
1685
1930
|
rowsPatch: ShapeRowOp[];
|
|
1686
1931
|
shapeId: string;
|
|
1687
1932
|
}
|
|
@@ -1742,6 +1987,12 @@ interface RelayShapeSubscribe {
|
|
|
1742
1987
|
type: "relay_shape_subscribe";
|
|
1743
1988
|
userId?: string;
|
|
1744
1989
|
}
|
|
1990
|
+
interface RelayShapeUnsubscribe {
|
|
1991
|
+
connectionId: string;
|
|
1992
|
+
relayIndex: number;
|
|
1993
|
+
subId?: string;
|
|
1994
|
+
type: "relay_shape_unsubscribe";
|
|
1995
|
+
}
|
|
1745
1996
|
interface RelayShapeSeed {
|
|
1746
1997
|
cursor?: number;
|
|
1747
1998
|
epoch?: string;
|
|
@@ -1761,22 +2012,18 @@ interface RelayShapePoke {
|
|
|
1761
2012
|
targetConnectionId?: string;
|
|
1762
2013
|
type: "relay_shape_poke";
|
|
1763
2014
|
}
|
|
1764
|
-
type OwnerRelayFrame = RelayAttach | RelayDetach | RelayFrame | RelayShapePoke | RelayShapeSubscribe;
|
|
1765
|
-
|
|
1766
|
-
interface RelayStub {
|
|
2015
|
+
type OwnerRelayFrame = RelayAttach | RelayDetach | RelayFrame | RelayShapePoke | RelayShapeSubscribe | RelayShapeUnsubscribe;
|
|
2016
|
+
interface SiblingStub {
|
|
1767
2017
|
fetch: (url: string, init?: RequestInit) => Promise<Response>;
|
|
1768
2018
|
}
|
|
1769
|
-
|
|
1770
|
-
get: (id: unknown) => RelayStub;
|
|
1771
|
-
getByName?: (name: string) => RelayStub;
|
|
1772
|
-
idFromName: (name: string) => unknown;
|
|
1773
|
-
}
|
|
2019
|
+
declare const DEFAULT_MAX_RELAYS = 8;
|
|
1774
2020
|
interface RelayHost {
|
|
1775
2021
|
buildShapeDiff: (resolved: ResolvedShape, fromCursor: number, toCursor: number) => ShapeRowOp[];
|
|
1776
2022
|
computeOpLogShapeSeed: (shape: ShapeSubscriptionQuery, resolved: ResolvedShape) => {
|
|
1777
2023
|
baseCheckpoint: number | undefined;
|
|
1778
2024
|
cursor: number;
|
|
1779
2025
|
epoch: string | undefined;
|
|
2026
|
+
reset: boolean;
|
|
1780
2027
|
rowsPatch: ShapeRowOp[];
|
|
1781
2028
|
};
|
|
1782
2029
|
currentCdcEpoch: () => string | undefined;
|
|
@@ -1806,7 +2053,8 @@ declare abstract class RelayLink {
|
|
|
1806
2053
|
handleControl(request: Request): Promise<Response>;
|
|
1807
2054
|
maxRelays(): number;
|
|
1808
2055
|
protected canAddressSiblings(): boolean;
|
|
1809
|
-
protected
|
|
2056
|
+
protected siblingStub(targetName: string): SiblingStub | undefined;
|
|
2057
|
+
protected bindingName(): string | undefined;
|
|
1810
2058
|
protected postRelayMessage(targetName: string, message: OwnerRelayFrame): Promise<void>;
|
|
1811
2059
|
protected requestRelayMessage(targetName: string, message: OwnerRelayFrame): Promise<Response | undefined>;
|
|
1812
2060
|
abstract forwardWhisper(topic: string, frame: string): Promise<void>;
|
|
@@ -1817,19 +2065,22 @@ declare abstract class RelayLink {
|
|
|
1817
2065
|
}>;
|
|
1818
2066
|
abstract announce(): Promise<void>;
|
|
1819
2067
|
abstract announceDrain(closing: ShardSocketLike): Promise<void>;
|
|
2068
|
+
abstract releaseRelayShapes(ws: ShardSocketLike, subId?: string): Promise<void>;
|
|
1820
2069
|
abstract relayCount(): number;
|
|
1821
2070
|
abstract isShapeRelayUniform(name: string, args: Record<string, unknown>): boolean;
|
|
2071
|
+
abstract minShapeCursor(): number | undefined;
|
|
1822
2072
|
protected abstract onAttach(index: number): void;
|
|
1823
2073
|
protected abstract onDetach(index: number): void;
|
|
1824
2074
|
protected abstract onWhisperFrame(message: RelayFrame): Promise<void>;
|
|
1825
2075
|
protected abstract onShapeSubscribe(message: RelayShapeSubscribe): RelayShapeSeed;
|
|
2076
|
+
protected abstract onShapeUnsubscribe(message: RelayShapeUnsubscribe): void;
|
|
1826
2077
|
protected abstract onShapePoke(poke: RelayShapePoke): number;
|
|
1827
2078
|
}
|
|
1828
2079
|
declare class OwnerRelay extends RelayLink {
|
|
1829
2080
|
private readonly shapeUniformCache;
|
|
1830
2081
|
private relaySetCache;
|
|
1831
|
-
private
|
|
1832
|
-
private
|
|
2082
|
+
private registryCache;
|
|
2083
|
+
private recordedBinding;
|
|
1833
2084
|
private promotionState;
|
|
1834
2085
|
constructor(host: RelayHost, ownerKey: string);
|
|
1835
2086
|
forwardWhisper(topic: string, frame: string): Promise<void>;
|
|
@@ -1840,17 +2091,26 @@ declare class OwnerRelay extends RelayLink {
|
|
|
1840
2091
|
}>;
|
|
1841
2092
|
announce(): Promise<void>;
|
|
1842
2093
|
announceDrain(): Promise<void>;
|
|
2094
|
+
releaseRelayShapes(): Promise<void>;
|
|
1843
2095
|
relayCount(): number;
|
|
2096
|
+
minShapeCursor(): number | undefined;
|
|
1844
2097
|
isShapeRelayUniform(name: string, args: Record<string, unknown>): boolean;
|
|
2098
|
+
protected onShapeUnsubscribe(message: RelayShapeUnsubscribe): void;
|
|
1845
2099
|
protected onAttach(index: number): void;
|
|
1846
2100
|
protected onDetach(index: number): void;
|
|
1847
2101
|
protected onWhisperFrame(message: RelayFrame): Promise<void>;
|
|
1848
2102
|
protected onShapeSubscribe(message: RelayShapeSubscribe): RelayShapeSeed;
|
|
1849
2103
|
protected onShapePoke(): number;
|
|
2104
|
+
private buildShapePoke;
|
|
1850
2105
|
private multicastShapePokes;
|
|
2106
|
+
private multicastToRelays;
|
|
1851
2107
|
private proxyShapePokes;
|
|
2108
|
+
private proxyToRelay;
|
|
1852
2109
|
private buildShapeSeedFrames;
|
|
1853
|
-
private
|
|
2110
|
+
private ensureRelayTables;
|
|
2111
|
+
protected bindingName(): string | undefined;
|
|
2112
|
+
private relayShapes;
|
|
2113
|
+
private rewindShapeCursor;
|
|
1854
2114
|
private ownerRelaySet;
|
|
1855
2115
|
private addRelayToSet;
|
|
1856
2116
|
private removeRelayFromSet;
|
|
@@ -1869,17 +2129,75 @@ declare class RelayMember extends RelayLink {
|
|
|
1869
2129
|
}>;
|
|
1870
2130
|
announce(): Promise<void>;
|
|
1871
2131
|
announceDrain(closing: ShardSocketLike): Promise<void>;
|
|
2132
|
+
releaseRelayShapes(ws: ShardSocketLike, subId?: string): Promise<void>;
|
|
1872
2133
|
relayCount(): number;
|
|
1873
2134
|
isShapeRelayUniform(): boolean;
|
|
2135
|
+
minShapeCursor(): number | undefined;
|
|
1874
2136
|
protected onAttach(): void;
|
|
1875
2137
|
protected onDetach(): void;
|
|
1876
2138
|
protected onWhisperFrame(): Promise<void>;
|
|
1877
2139
|
protected onShapeSubscribe(): RelayShapeSeed;
|
|
2140
|
+
protected onShapeUnsubscribe(): void;
|
|
1878
2141
|
protected onShapePoke(poke: RelayShapePoke): number;
|
|
1879
2142
|
private recordRelayShapeMemo;
|
|
1880
2143
|
private deliverShapePoke;
|
|
1881
2144
|
}
|
|
1882
2145
|
declare const createRelayLink: (host: RelayHost) => OwnerRelay | RelayMember | undefined;
|
|
2146
|
+
declare const REGION_HINTS: readonly ["wnam", "enam", "sam", "weur", "eeur", "apac", "apac-ne", "apac-se", "oc", "afr", "me"];
|
|
2147
|
+
type RegionHint = (typeof REGION_HINTS)[number];
|
|
2148
|
+
type ReplicaReadiness = "fresh" | "stale" | "unavailable";
|
|
2149
|
+
interface ShardSiblingHost {
|
|
2150
|
+
doName: () => string | undefined;
|
|
2151
|
+
env: () => unknown;
|
|
2152
|
+
shardBinding: () => string | undefined;
|
|
2153
|
+
sql: () => SqlExec;
|
|
2154
|
+
}
|
|
2155
|
+
interface ReplicaOwnerHost extends ShardSiblingHost {
|
|
2156
|
+
exportRows: () => Promise<ExportRow[]>;
|
|
2157
|
+
ownerCursor: () => number | undefined;
|
|
2158
|
+
ownerEpoch: () => string | undefined;
|
|
2159
|
+
ownerFloor: () => number | undefined;
|
|
2160
|
+
readChanges: (sinceSeq: number, limit: number) => {
|
|
2161
|
+
changes: CdcChange[];
|
|
2162
|
+
cursor: number;
|
|
2163
|
+
};
|
|
2164
|
+
rowCount: () => number;
|
|
2165
|
+
}
|
|
2166
|
+
interface ReplicaFollowerHost extends ShardSiblingHost {
|
|
2167
|
+
applyChanges: (changes: ReadonlyArray<CdcChange>) => Promise<number>;
|
|
2168
|
+
importRows: (rows: ReadonlyArray<ExportRow>) => Promise<{
|
|
2169
|
+
errors: ReadonlyArray<unknown>;
|
|
2170
|
+
}>;
|
|
2171
|
+
}
|
|
2172
|
+
declare const handleReplicaControl: (host: ReplicaOwnerHost, request: Request) => Promise<Response>;
|
|
2173
|
+
declare class ShardReplica {
|
|
2174
|
+
private readonly host;
|
|
2175
|
+
readonly ownerKey: string;
|
|
2176
|
+
readonly region: RegionHint;
|
|
2177
|
+
private divergent;
|
|
2178
|
+
private inFlight;
|
|
2179
|
+
constructor(host: ReplicaFollowerHost, ownerKey: string, region: RegionHint);
|
|
2180
|
+
ensureFresh(minSeq?: number): Promise<ReplicaReadiness>;
|
|
2181
|
+
appliedSeq(): number;
|
|
2182
|
+
isDivergent(): boolean;
|
|
2183
|
+
private advance;
|
|
2184
|
+
private isCaughtUp;
|
|
2185
|
+
private catchUp;
|
|
2186
|
+
private applyPage;
|
|
2187
|
+
private hasDiverged;
|
|
2188
|
+
private bootstrap;
|
|
2189
|
+
private isFreshEnough;
|
|
2190
|
+
private pull;
|
|
2191
|
+
private request;
|
|
2192
|
+
}
|
|
2193
|
+
declare const createReplicaLink: (host: ReplicaFollowerHost) => ShardReplica | undefined;
|
|
2194
|
+
declare const gateReplicaDispatch: (replica: ShardReplica, request: Request, functionPath: string) => Promise<Response | undefined>;
|
|
2195
|
+
declare const REPROJECTION_MIGRATION_PREFIX = "__lunora_reproject__";
|
|
2196
|
+
declare const reprojectionMigrationId: (table: string) => string;
|
|
2197
|
+
declare const reprojectableFields: (definition: TableDefinitionLike) => string[];
|
|
2198
|
+
declare const reprojectionTables: (schema: SchemaLike) => string[];
|
|
2199
|
+
declare const countLegacyRows: (sql: SqlExec, table: string, fields: ReadonlyArray<string>) => number;
|
|
2200
|
+
declare const buildReprojectionMigration: (id: string, schema: SchemaLike, sql: SqlExec) => DataMigrationLike | undefined;
|
|
1883
2201
|
declare const RLS_UNWRAP_SYMBOL: symbol;
|
|
1884
2202
|
declare class RlsRequiredError extends LunoraError {
|
|
1885
2203
|
readonly table: string;
|
|
@@ -1895,7 +2213,8 @@ interface GuardableSchema {
|
|
|
1895
2213
|
}>;
|
|
1896
2214
|
}
|
|
1897
2215
|
type TableOfId = (id: string, expectedTable?: string) => Promise<string | undefined> | string | undefined;
|
|
1898
|
-
|
|
2216
|
+
type TablesOfIds = (ids: ReadonlyArray<string>, expectedTable?: string) => Promise<ReadonlyMap<string, string>> | ReadonlyMap<string, string>;
|
|
2217
|
+
declare const guardWriter: <W>(raw: W, schema: GuardableSchema, tableOfId: TableOfId, tablesOfIds?: TablesOfIds) => W;
|
|
1899
2218
|
declare const SCHEMA_HISTORY_MAX_VERSIONS = 50;
|
|
1900
2219
|
interface SchemaVersionRow {
|
|
1901
2220
|
appliedAt: number;
|
|
@@ -1908,6 +2227,24 @@ declare const readSchemaHistory: (sql: SqlExec) => SchemaVersionRow[];
|
|
|
1908
2227
|
declare const readSchemaVersion: (sql: SqlExec, hash: string) => SchemaVersionRow | undefined;
|
|
1909
2228
|
declare const isDevEnvironment: (rawEnv: unknown) => boolean;
|
|
1910
2229
|
declare const buildSettings: (rawEnv: unknown) => SettingsResult;
|
|
2230
|
+
declare class ShapeDiffCache {
|
|
2231
|
+
private readonly keyScans;
|
|
2232
|
+
private readonly memberProbes;
|
|
2233
|
+
private run;
|
|
2234
|
+
private served;
|
|
2235
|
+
get probesRun(): number;
|
|
2236
|
+
get probesServed(): number;
|
|
2237
|
+
changedKeys(rangeKey: string, load: () => CdcChangeKey[]): ReadonlyArray<CdcChangeKey>;
|
|
2238
|
+
members(resolved: ResolvedShape, rangeKey: string, load: () => Map<string, Record<string, unknown>>): ReadonlyMap<string, Record<string, unknown>>;
|
|
2239
|
+
private getOrLoad;
|
|
2240
|
+
}
|
|
2241
|
+
declare const createShapeDiffCache: () => ShapeDiffCache;
|
|
2242
|
+
declare const globalShapeReadKey: (resolved: ResolvedShape, identity: {
|
|
2243
|
+
identity?: Record<string, unknown>;
|
|
2244
|
+
userId?: string;
|
|
2245
|
+
}) => string | undefined;
|
|
2246
|
+
type ReadShapeCdcKeys = (sql: SqlExec, table: string, sinceSeq: number, upTo: number) => CdcChangeKey[];
|
|
2247
|
+
declare const buildShapeDiff: (sql: SqlExec, resolved: ResolvedShape, sinceSeq: number, upTo: number, cache: ShapeDiffCache, readKeys?: ReadShapeCdcKeys) => ShapeRowOp[];
|
|
1911
2248
|
interface ShardRunnerOptions {
|
|
1912
2249
|
handlers?: {
|
|
1913
2250
|
handleAlarm?: () => Promise<void>;
|
|
@@ -1957,7 +2294,17 @@ interface DrainableSink {
|
|
|
1957
2294
|
readonly bufferedAmount?: unknown;
|
|
1958
2295
|
}
|
|
1959
2296
|
declare const trySendFrame: (ws: FrameSink, frame: string) => boolean;
|
|
1960
|
-
|
|
2297
|
+
interface SubscriptionFrameInput {
|
|
2298
|
+
cursorSuffix: string;
|
|
2299
|
+
lastMutationId?: number;
|
|
2300
|
+
nextResult: unknown;
|
|
2301
|
+
pageDeltas?: boolean;
|
|
2302
|
+
previousJson?: string;
|
|
2303
|
+
snapshotJson: string;
|
|
2304
|
+
subId: string;
|
|
2305
|
+
table: string;
|
|
2306
|
+
}
|
|
2307
|
+
declare const subscriptionFrames: (input: SubscriptionFrameInput) => string[];
|
|
1961
2308
|
declare const awaitWsDrain: (ws: DrainableSink) => Promise<void>;
|
|
1962
2309
|
interface SubscriptionReadFootprint {
|
|
1963
2310
|
ranges?: Map<string, KeyRange[]>;
|
|
@@ -1985,13 +2332,25 @@ declare const selectExpiredIds: (sql: SqlExec, spec: TtlSweepSpec, now: number,
|
|
|
1985
2332
|
hasMore: boolean;
|
|
1986
2333
|
ids: string[];
|
|
1987
2334
|
};
|
|
1988
|
-
|
|
2335
|
+
interface WhereFragments<T> {
|
|
2336
|
+
binary: (reference: T, comparator: string, value: unknown) => T;
|
|
2337
|
+
connect: (left: T, right: T, connector: "AND" | "OR") => T;
|
|
2338
|
+
constant: (value: boolean) => T;
|
|
2339
|
+
contains: (reference: T, term: T) => T;
|
|
2340
|
+
inList: (reference: T, items: ReadonlyArray<unknown>, negated: boolean, budget: number) => T;
|
|
2341
|
+
negate: (inner: T) => T;
|
|
2342
|
+
nullCheck: (reference: T, negated: boolean) => T;
|
|
2343
|
+
value: (value: unknown) => T;
|
|
2344
|
+
}
|
|
2345
|
+
type FieldRefSql<T> = (field: string) => T;
|
|
1989
2346
|
type SerializeValue = (value: unknown) => unknown;
|
|
1990
|
-
interface WhereSqlStrategy {
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
2347
|
+
interface WhereSqlStrategy<T = SQL> {
|
|
2348
|
+
containsExpr?: (reference: T, term: T) => T;
|
|
2349
|
+
fieldRef: FieldRefSql<T>;
|
|
2350
|
+
inList?: (reference: T, items: ReadonlyArray<unknown>, negated: boolean, budget?: number) => T;
|
|
2351
|
+
relationExists?: (request: unknown) => T;
|
|
1994
2352
|
serialize: SerializeValue;
|
|
1995
2353
|
}
|
|
1996
|
-
declare const
|
|
1997
|
-
|
|
2354
|
+
declare const literalInList: (reference: SQL, items: ReadonlyArray<unknown>, negated: boolean) => SQL;
|
|
2355
|
+
declare const compileWhereSql: <T = SQL>(where: WhereInput | undefined, strategy: WhereSqlStrategy<T>, fragments?: WhereFragments<T>) => T | undefined;
|
|
2356
|
+
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, CURSOR_PREFIX, type CacheEntry, type CapturedMailRow, type CdcArchiveScope, type CdcChange, type CdcChangeKey, type ChangedKeys, type Clock, type ColumnMeta, type ColumnMetaLike, type CompanionSync, type CompanionSyncDeps, ConflictError, type ConflictKind, type CountArgs, CountRlsUnsupportedError, type CreateWorkflowInstanceResult, type CrossShardReadArgs, type CtxDbOptions, DATA_MIGRATION_STATE_TABLE, DEFAULT_FANOUT_TOPIC_LIMIT, DEFAULT_MAX_RELATION_KEYS, DEFAULT_MAX_RELAYS, DEFAULT_PROMOTION_THRESHOLDS, DEFAULT_TRANSACTION_LIMITS, DOC_COLUMN, type DataMigrationDocument, type DataMigrationLike, type DataMigrationTransform, type DatabaseWriterLike, type DependencyTracker, type DeployInfo, type DurableAttachDecision, type DurableStreamAttach, type DurableStreamRun, DurableStreamRunner, type DurableStreamSink, type ExportRow, type ExportShardAdminArgs, type ExportShardArgs, type ExternalSourceDiffResult, type ExternalSourceLike, FLAGS_FUNCTION_PREFIX, type FacetColumnOptions, type FacetColumnResult, type FacetValue, type FanOutBudget, type FanoutMetricsResult, type FanoutPathCounters, type FanoutTopicStat, type FieldOperators, type FilterClause, type FilterOperator, type FlagEvaluation, type FlagsResult, type FunctionCallStat, type FunctionScanAttribution, type FunctionStatsResult, GEO_DEFAULT_PRECISION, GLOBAL_SHAPE_SNAPSHOT_TABLE, type GeoBoundingBox, type GeoFilterBuilderLike, type GeoIndexDefinitionLike, type GeoPoint, type GeoScoredDocument, type GlobalPollCounters, GlobalPollTick, type GroupByEntry, type GroupByOptions, type GuardableSchema$1 as GuardableSchema, IDEMPOTENCY_TABLE, type IdGenerator, type IdempotentRecord, type ImportError, type ImportShardAdminArgs, type ImportShardArgs, type ImportShardResult, type IncrementalMaterializeResult, type IndexDefinitionLike, type IndexKeyEntry, type IndexRangeBuilderLike, type KeyRange, type LifecycleDispatchInfo, type LifecycleEvent, MAIL_RETENTION, MAIL_TABLE, MAX_DURABLE_STREAM_BYTES, MAX_DURABLE_STREAM_CHUNKS, MAX_PAGE_SIZE, MAX_SQL_ROWS, type MaskColumnMetadata, type MaskPoliciesResult, type MaterializeResult, type MigrationDirection, type MigrationRunResult, type MigrationStatus, type MigrationStatusRow, type MutationDelta, type NestedWith, NotFoundError, NotUniqueError, type OnDeleteActionLike, type OrderByClause, type OrderByInput, type OrderKey, 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 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, 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, archiveCdcSegment, armRestore, assertFlatPredicate, assertNoExplicitUndefined, 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, facetColumn, fanOutScalarCounts, findStorageReferences, finishStreamRun, foldAggregateTally, gateReplicaDispatch, geoTableName, globalShapeReadKey, guardWriter, handleReplicaControl, hasTrigger, haversineMeters, importShardRows, indexKeysForRow, isDevEnvironment, isFtsAvailable, isLossyBody, isMemoryTable, isRelationPredicate, isSoftDeleted, isSourceDue, jsonPath, jsonPathSql, keysTouchRanges, liftSourceId, lintReadonlySql, listReactorStates, listTables, literalInList, markUnvouchableReads, matchesRankStaticWhere, matchesStaticWhere, materializeExternalRows, materializeExternalRowsIncremental, memoryTableNames, mergeChangedKeys, mergeWhere, migrateCdcLog, migrateCdcMeta, migrateClientWatermark, migrateCommitSeq, migrateDurableStreams, migrateGlobalShapeSnapshot, migrateIdempotency, migrateReactorState, 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, readArchivedCdcChanges, readAuditLog, readBookmark, readCapturedMail, readCdcArchivedThrough, 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, resolveRankSeekTuple, resolveRelationPredicates, resolveWith, rowToDocument, runDataMigration, runDrizzle, runExternalSourceTick, runReadonlySql, runRowValidators, runShardMigrations, runSocketPool, runSql, runTriggers, selectExpiredIds, selectExportTables, selectIndexForAggregate, selectIndexForCount, selectIndexForGroupBy, selectMatchingIds, selectShapeMembers, selectShapeRows, serializeSqlValue, shapeRoutingKey, softDeleteScope, sortColumnName, sqliteInList, stableStringify, stableWireKey, subscriptionFrames, subscriptionListDeltas, summarizeFanoutTopics, summarizeSubscriptions, tableColumns, tableFromDepKey, throwingScheduler, tiebreakDirectionFor, trimCdcChanges, trimIdempotent, trimStreamRuns, tryRowToDocument, trySendFrame, unionAll, validateImportRow, writeCdcArchivedThrough, writeGlobalShapeSnapshot, writeIdempotent, writeReactorState, writeSearchBackfillState, writeShapePokeCursor, writeShapePokeCursors, writeTouchesMemo };
|