@lunora/shard-engine 1.0.0-alpha.8 → 1.0.0-alpha.81
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 +595 -121
- package/dist/index.d.ts +595 -121
- package/dist/index.mjs +1 -1
- package/dist/packem_shared/ADMIN_FUNCTIONS-B5zFvu5K.mjs +1 -0
- package/dist/packem_shared/AGGREGATE_SQL_FUNCTION-DDEoMnJR.mjs +1 -0
- package/dist/packem_shared/AGG_COUNT-B7izQELK.mjs +1 -0
- package/dist/packem_shared/AUDIT_LOG_TABLE-CEdsC6vT.mjs +8 -0
- package/dist/packem_shared/BIGINT_KEY_DIGITS-Bnqj9CYQ.mjs +1 -0
- package/dist/packem_shared/CDC_LOG_TABLE-BFbP2eiJ.mjs +18 -0
- package/dist/packem_shared/CLIENT_WATERMARK_TABLE-BdKYbah0.mjs +7 -0
- package/dist/packem_shared/COMMIT_SEQ_FIELD-D6uMUaiR.mjs +4 -0
- package/dist/packem_shared/CURSOR_PREFIX-Bn8SFoGd.mjs +1 -0
- package/dist/packem_shared/CountRlsUnsupportedError-BvsDqfO2.mjs +1 -0
- package/dist/packem_shared/DATA_MIGRATION_STATE_TABLE-BbDr6pc7.mjs +31 -0
- package/dist/packem_shared/DEFAULT_MAX_RELATION_KEYS-BfAQvZT8.mjs +1 -0
- package/dist/packem_shared/DEFAULT_MAX_RELAYS-DG9iXjzF.mjs +8 -0
- package/dist/packem_shared/DEFAULT_PROMOTION_THRESHOLDS-Bfx7KakS.mjs +1 -0
- package/dist/packem_shared/DEFAULT_TRANSACTION_LIMITS-CTHQQgDC.mjs +1 -0
- package/dist/packem_shared/DurableStreamRunner-Cliu09-j.mjs +1 -0
- package/dist/packem_shared/GEO_DEFAULT_PRECISION-CqpQZ-J_.mjs +1 -0
- package/dist/packem_shared/GLOBAL_SHAPE_SNAPSHOT_TABLE-wWaEWj5f.mjs +7 -0
- package/dist/packem_shared/GlobalPollTick-BNK4o-XT.mjs +1 -0
- package/dist/packem_shared/IDEMPOTENCY_TABLE-DKrXVEUe.mjs +7 -0
- package/dist/packem_shared/MAIL_RETENTION-DXpGFjOt.mjs +18 -0
- package/dist/packem_shared/MAX_SQL_ROWS-Dh_Ty0Zo.mjs +4 -0
- package/dist/packem_shared/MAX_TOKEN_LENGTH-BakL9FUy-B3VwYY8C.mjs +1 -0
- package/dist/packem_shared/NotUniqueError-EnGaESbV.mjs +1 -0
- package/dist/packem_shared/QUEUE_TABLE-D-cL1NPj.mjs +17 -0
- package/dist/packem_shared/RANK_TIEBREAK-D5xNdzB3.mjs +1 -0
- package/dist/packem_shared/REACTOR_STATE_TABLE-CBHASjH9.mjs +28 -0
- package/dist/packem_shared/RELATED_DEFAULT_LIMIT-B9PH28Pn.mjs +1 -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-BwwTbz3Q.mjs +1 -0
- package/dist/packem_shared/ReactiveCache-CU_NoCMR.mjs +1 -0
- package/dist/packem_shared/SCAN_DEP-D7qE3iUe.mjs +1 -0
- package/dist/packem_shared/SCHEDULE_OUTBOX_TABLE-BHpxtEy4.mjs +11 -0
- package/dist/packem_shared/SCHEMA_HISTORY_MAX_VERSIONS-CXznJRUG.mjs +6 -0
- package/dist/packem_shared/SEARCH_STATE_TABLE-DvKmxQn0.mjs +1 -0
- package/dist/packem_shared/SHAPE_POKE_CURSOR_TABLE-Bbpou9XZ.mjs +8 -0
- package/dist/packem_shared/ShapeDiffCache-gdaILV5E.mjs +1 -0
- package/dist/packem_shared/ShardRunner-CrveaPId.mjs +1 -0
- package/dist/packem_shared/UNVOUCHABLE_DEP-C68htACn.mjs +1 -0
- package/dist/packem_shared/aggregateTableName-C7o-gpms.mjs +1 -0
- package/dist/packem_shared/appendStreamChunk-pPeR5nbF.mjs +19 -0
- package/dist/packem_shared/applyOnDelete-7JZ4vR9r.mjs +1 -0
- package/dist/packem_shared/archiveCdcSegment-C7taIEpg.mjs +4 -0
- package/dist/packem_shared/{armRestore-BNzdvQ_o.mjs → armRestore-Bu1_8SUa.mjs} +1 -1
- package/dist/packem_shared/awaitWsDrain-apizgmKY.mjs +1 -0
- package/dist/packem_shared/backfillAggregateIndexes-DOEO0SoZ.mjs +1 -0
- package/dist/packem_shared/base64-DfpzS4o_.mjs +1 -0
- package/dist/packem_shared/buildIndexRange-DvN8Qj8e.mjs +1 -0
- package/dist/packem_shared/buildPokeFrames-BBE6J91z.mjs +1 -0
- package/dist/packem_shared/buildReprojectionMigration-DDZhSO95.mjs +1 -0
- package/dist/packem_shared/buildSettings-DC3VeQ0H.mjs +1 -0
- package/dist/packem_shared/buildShapeDiff-Bd5nLaY8.mjs +1 -0
- package/dist/packem_shared/clearMemoryTables-C5Wivufe.mjs +1 -0
- package/dist/packem_shared/compileWhereSql-B8tS0_nD.mjs +1 -0
- package/dist/packem_shared/computeRankPage-CQewnemg.mjs +1 -0
- package/dist/packem_shared/createCompanionSync-BwWcSwvy.mjs +1 -0
- package/dist/packem_shared/createReplicaLink-CTyOjpjh.mjs +7 -0
- package/dist/packem_shared/createSystemReader-DcDLFfC-.mjs +1 -0
- package/dist/packem_shared/ctx-db-relay-shapes-BcgjOtG1.mjs +17 -0
- package/dist/packem_shared/ctx-db-search-state-DUo0LnTy.mjs +1 -0
- package/dist/packem_shared/defineEngineContractSuite-DfJUYVxZ.mjs +1 -0
- package/dist/packem_shared/diffExternalSource-DgDJhslq.mjs +1 -0
- package/dist/packem_shared/do-sql-BSoH-O04.mjs +1 -0
- package/dist/packem_shared/envOptionalPositiveInt-D2pY-c64.mjs +1 -0
- package/dist/packem_shared/estimate-bytes-DM1UZj_m.mjs +1 -0
- package/dist/packem_shared/exportShardRows-DmFKSzLZ.mjs +1 -0
- package/dist/packem_shared/fts-companion-B7jllLhZ.mjs +1 -0
- package/dist/packem_shared/ftsCompanionDdl-BKeIk9KQ.mjs +1 -0
- package/dist/packem_shared/hasTrigger-CjlwI4le.mjs +1 -0
- package/dist/packem_shared/isSoftDeleted-CCDHCtX3.mjs +9 -0
- package/dist/packem_shared/liftSourceId-CA3ENhXj.mjs +1 -0
- package/dist/packem_shared/materializeExternalRows-j_8glxcE.mjs +1 -0
- package/dist/packem_shared/mergeChangedKeys-BA3YxaLE.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-CfKnGpV2.mjs +1 -0
- package/dist/packem_shared/runShardMigrations-DPPZG_c2.mjs +5 -0
- package/dist/packem_shared/runSocketPool-CZJ2X9cF.mjs +1 -0
- package/dist/packem_shared/selectExpiredIds-Do1q2HQr.mjs +1 -0
- package/dist/packem_shared/selectShapeMembers-Cp98I-ot.mjs +1 -0
- package/dist/packem_shared/serializeSqlValue-BEMMYX1n.mjs +1 -0
- package/dist/packem_shared/sibling-channel-BkL5cTCc.mjs +1 -0
- package/dist/packem_shared/sql-projection-D3qdaItY.mjs +1 -0
- package/dist/packem_shared/stableStringify-DibjylKD.mjs +1 -0
- package/dist/packem_shared/stableWireKey-D2US4k_J.mjs +1 -0
- package/dist/packem_shared/where-sql-x1YKldcq.mjs +1 -0
- package/dist/packem_shared/wire-codec-C-FpWm52.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-D-wORk0b.mjs +0 -1
- package/dist/packem_shared/AUDIT_LOG_TABLE-CaA0jL0L.mjs +0 -8
- package/dist/packem_shared/CDC_LOG_TABLE-q7MSIAzR.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-D0oc40p6.mjs +0 -1
- package/dist/packem_shared/DEFAULT_PROMOTION_THRESHOLDS-Dteg0sZF.mjs +0 -1
- package/dist/packem_shared/DEFAULT_TRANSACTION_LIMITS-BH5q0Ror.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-CjdcqrlK.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-CBYPlYBb.mjs +0 -1
- package/dist/packem_shared/ReactiveCache-C6QAa7MG.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-CCZ-8wjm.mjs +0 -1
- package/dist/packem_shared/backfillAggregateIndexes-u6_SblD0.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-DCfEbb9_.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-C1e_JZp1.mjs +0 -1
- package/dist/packem_shared/diffExternalSource-DMpkJta1.mjs +0 -1
- package/dist/packem_shared/estimate-bytes-DwQON1Ky.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-CvcsqA59.mjs +0 -9
- package/dist/packem_shared/liftSourceId-DApAbu7Q.mjs +0 -1
- package/dist/packem_shared/materializeExternalRows-DmYwTW_A.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-MWWmpqzb.mjs +0 -5
- package/dist/packem_shared/runSocketPool-DPQLVyWF.mjs +0 -1
- package/dist/packem_shared/selectExpiredIds-BnHyOKtN.mjs +0 -1
- package/dist/packem_shared/selectShapeMemberIds-TPdvxh2A.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.ts
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;
|
|
@@ -86,6 +88,75 @@ interface WhereInput {
|
|
|
86
88
|
OR?: WhereInput[];
|
|
87
89
|
}
|
|
88
90
|
declare const RELATION_EXISTS_KEY = "__relationExists";
|
|
91
|
+
interface SubscriptionQuery {
|
|
92
|
+
args?: Record<string, unknown>;
|
|
93
|
+
functionPath?: string;
|
|
94
|
+
sinceEpoch?: string;
|
|
95
|
+
sinceSeq?: number;
|
|
96
|
+
table?: string;
|
|
97
|
+
}
|
|
98
|
+
interface ShapeSubscriptionQuery {
|
|
99
|
+
args?: Record<string, unknown>;
|
|
100
|
+
name: string;
|
|
101
|
+
sinceEpoch?: string;
|
|
102
|
+
sinceSeq?: number;
|
|
103
|
+
}
|
|
104
|
+
interface SubscriptionEnvelope {
|
|
105
|
+
caps?: string[];
|
|
106
|
+
clientId?: string;
|
|
107
|
+
context?: Record<string, unknown>;
|
|
108
|
+
data?: unknown;
|
|
109
|
+
generation?: number;
|
|
110
|
+
id: string;
|
|
111
|
+
query?: SubscriptionQuery;
|
|
112
|
+
shape?: {
|
|
113
|
+
args?: Record<string, unknown>;
|
|
114
|
+
name: string;
|
|
115
|
+
};
|
|
116
|
+
sinceCheckpoint?: number;
|
|
117
|
+
sinceChunk?: number;
|
|
118
|
+
sinceEpoch?: string;
|
|
119
|
+
topic?: string;
|
|
120
|
+
type: "ack" | "connect" | "shape_subscribe" | "shape_unsubscribe" | "stream" | "subscribe" | "unsubscribe" | "whisper" | "whisper_subscribe" | "whisper_unsubscribe";
|
|
121
|
+
}
|
|
122
|
+
interface RpcRequest {
|
|
123
|
+
args?: Record<string, unknown>;
|
|
124
|
+
functionPath: string;
|
|
125
|
+
}
|
|
126
|
+
interface SocketAttachment {
|
|
127
|
+
admin?: boolean;
|
|
128
|
+
adminBinding?: string;
|
|
129
|
+
clientId?: string;
|
|
130
|
+
connected?: boolean;
|
|
131
|
+
connectionId?: string;
|
|
132
|
+
context?: Record<string, unknown>;
|
|
133
|
+
expiresAt?: number;
|
|
134
|
+
identity?: Record<string, unknown>;
|
|
135
|
+
ip?: string;
|
|
136
|
+
pageDeltas?: boolean;
|
|
137
|
+
shapes?: Record<string, ShapeSubscriptionQuery>;
|
|
138
|
+
subs: Record<string, SubscriptionQuery>;
|
|
139
|
+
userId?: string;
|
|
140
|
+
whispers?: string[];
|
|
141
|
+
}
|
|
142
|
+
interface ResolvedShape {
|
|
143
|
+
columns?: ReadonlyArray<string>;
|
|
144
|
+
effectiveWhere?: WhereInput;
|
|
145
|
+
global?: boolean;
|
|
146
|
+
table: string;
|
|
147
|
+
}
|
|
148
|
+
interface SubscriptionIdentity {
|
|
149
|
+
identity?: Record<string, unknown>;
|
|
150
|
+
ip?: string;
|
|
151
|
+
userId?: string;
|
|
152
|
+
}
|
|
153
|
+
interface ShardSocketLike {
|
|
154
|
+
readonly bufferedAmount?: number;
|
|
155
|
+
close?: (code?: number, reason?: string) => void;
|
|
156
|
+
deserializeAttachment?: () => unknown;
|
|
157
|
+
send: (data: string) => void;
|
|
158
|
+
serializeAttachment?: (value: unknown) => void;
|
|
159
|
+
}
|
|
89
160
|
type AggregateOp = "avg" | "count" | "max" | "min" | "sum";
|
|
90
161
|
interface AggregateIndexDefinitionLike {
|
|
91
162
|
readonly by?: ReadonlyArray<string>;
|
|
@@ -137,6 +208,10 @@ interface ColumnMetaLike {
|
|
|
137
208
|
interface ValidatorLike {
|
|
138
209
|
readonly _meta?: {
|
|
139
210
|
readonly column?: ColumnMetaLike;
|
|
211
|
+
readonly inner?: ValidatorLike;
|
|
212
|
+
readonly members?: ReadonlyArray<ValidatorLike>;
|
|
213
|
+
readonly tableName?: string;
|
|
214
|
+
readonly value?: unknown;
|
|
140
215
|
};
|
|
141
216
|
readonly kind?: string;
|
|
142
217
|
readonly parse?: (value: unknown) => unknown;
|
|
@@ -180,9 +255,12 @@ interface SchemaLike {
|
|
|
180
255
|
}
|
|
181
256
|
interface TableDefinitionLike {
|
|
182
257
|
readonly aggregateIndexes?: ReadonlyArray<AggregateIndexDefinitionLike>;
|
|
258
|
+
readonly commitOrderedMode?: boolean;
|
|
259
|
+
readonly dropStalePatchesMode?: boolean;
|
|
183
260
|
readonly geoIndexes?: ReadonlyArray<GeoIndexDefinitionLike>;
|
|
184
261
|
readonly indexes: ReadonlyArray<IndexDefinitionLike>;
|
|
185
262
|
readonly isPublic?: boolean;
|
|
263
|
+
readonly memoryMode?: boolean;
|
|
186
264
|
readonly rankIndexes?: ReadonlyArray<RankIndexDefinitionLike>;
|
|
187
265
|
readonly relationMap?: Record<string, RelationDefinitionLike>;
|
|
188
266
|
readonly searchIndexes?: ReadonlyArray<SearchIndexDefinitionLike>;
|
|
@@ -225,11 +303,16 @@ interface ApplyOnDeleteOptions$1 {
|
|
|
225
303
|
row: Record<string, unknown>;
|
|
226
304
|
tableName: string;
|
|
227
305
|
}
|
|
306
|
+
interface FanOutBudget {
|
|
307
|
+
remaining: number;
|
|
308
|
+
}
|
|
228
309
|
interface ResolveWithOptions {
|
|
310
|
+
fanOutBudget?: FanOutBudget;
|
|
229
311
|
fetcher: (tableName: string, args: QueryArgs) => Promise<QueryPage>;
|
|
230
312
|
groupedCounter: (tableName: string, whereField: string, values: unknown[], policyWhere?: WhereInput) => Promise<Map<unknown, number>>;
|
|
231
313
|
parents: Record<string, unknown>[];
|
|
232
314
|
relationBaseWhere?: (table: string) => undefined | WhereInput;
|
|
315
|
+
relationMask?: RelationMask;
|
|
233
316
|
schema: {
|
|
234
317
|
readonly tables: Record<string, TableDefinitionLike>;
|
|
235
318
|
};
|
|
@@ -248,22 +331,69 @@ interface QueryArgs {
|
|
|
248
331
|
cursor?: null | string;
|
|
249
332
|
includeDeleted?: boolean;
|
|
250
333
|
limit?: number;
|
|
334
|
+
omitContinueCursor?: boolean;
|
|
251
335
|
orderBy?: OrderByInput[];
|
|
252
336
|
relationBaseWhere?: (table: string) => undefined | WhereInput;
|
|
337
|
+
relationMask?: RelationMask;
|
|
253
338
|
restrictsCounts?: boolean;
|
|
254
339
|
select?: ReadonlyArray<string>;
|
|
255
340
|
where?: WhereInput;
|
|
256
341
|
with?: WithInput;
|
|
257
342
|
}
|
|
343
|
+
interface CrossShardReadArgs {
|
|
344
|
+
orderBy?: OrderByInput[];
|
|
345
|
+
relationPolicies?: Record<string, WhereInput>;
|
|
346
|
+
where?: WhereInput;
|
|
347
|
+
with?: WithInput;
|
|
348
|
+
}
|
|
349
|
+
type RelationMask = (table: string, rows: Record<string, unknown>[]) => Record<string, unknown>[];
|
|
258
350
|
interface QueryPage {
|
|
259
351
|
continueCursor: null | string;
|
|
260
352
|
isDone: boolean;
|
|
261
353
|
page: Record<string, unknown>[];
|
|
262
354
|
splitCursor?: null | string;
|
|
263
355
|
}
|
|
356
|
+
interface RelationEdge {
|
|
357
|
+
readonly array: boolean;
|
|
358
|
+
readonly column: string;
|
|
359
|
+
readonly name: string;
|
|
360
|
+
readonly sourceTable: string;
|
|
361
|
+
readonly targetTable: string;
|
|
362
|
+
}
|
|
363
|
+
interface RelatedStartReference {
|
|
364
|
+
id: string;
|
|
365
|
+
table: string;
|
|
366
|
+
}
|
|
367
|
+
type RelatedStart = (Record<string, unknown> & {
|
|
368
|
+
_id: string;
|
|
369
|
+
}) | RelatedStartReference;
|
|
370
|
+
type RelatedDirection = "both" | "in" | "out";
|
|
371
|
+
interface RelatedOptions {
|
|
372
|
+
cursor?: null | string;
|
|
373
|
+
depth?: number;
|
|
374
|
+
direction?: RelatedDirection;
|
|
375
|
+
edges?: ReadonlyArray<string>;
|
|
376
|
+
limit?: number;
|
|
377
|
+
relationBaseWhere?: (table: string) => undefined | WhereInput;
|
|
378
|
+
relationMask?: RelationMask;
|
|
379
|
+
}
|
|
380
|
+
interface RelatedNode {
|
|
381
|
+
depth: number;
|
|
382
|
+
document: Record<string, unknown>;
|
|
383
|
+
path: ReadonlyArray<string>;
|
|
384
|
+
pathIds: ReadonlyArray<string>;
|
|
385
|
+
score: number;
|
|
386
|
+
table: string;
|
|
387
|
+
}
|
|
388
|
+
interface RelatedPage {
|
|
389
|
+
continueCursor: null | string;
|
|
390
|
+
isDone: boolean;
|
|
391
|
+
nodes: RelatedNode[];
|
|
392
|
+
}
|
|
264
393
|
interface OrderKey {
|
|
265
394
|
direction: SortDirection;
|
|
266
395
|
field: string;
|
|
396
|
+
nullable: boolean;
|
|
267
397
|
}
|
|
268
398
|
interface RestrictableQueryOptions {
|
|
269
399
|
baseWhere?: WhereInput;
|
|
@@ -399,10 +529,8 @@ interface LifecycleEvent {
|
|
|
399
529
|
shardKey: string;
|
|
400
530
|
userId: string | null;
|
|
401
531
|
}
|
|
402
|
-
interface LifecycleDispatchInfo {
|
|
532
|
+
interface LifecycleDispatchInfo extends SubscriptionIdentity {
|
|
403
533
|
event: LifecycleEvent;
|
|
404
|
-
identity: Record<string, unknown> | undefined;
|
|
405
|
-
userId: string | undefined;
|
|
406
534
|
}
|
|
407
535
|
interface MutationDelta {
|
|
408
536
|
indexKeys?: ReadonlyArray<IndexKeyEntry>;
|
|
@@ -414,6 +542,13 @@ interface MutationDelta {
|
|
|
414
542
|
interface DatabaseWriterLike {
|
|
415
543
|
aggregate: (tableName: string, options: AggregateOptions) => Promise<AggregateResult>;
|
|
416
544
|
asId?: (tableName: string, id: string) => string;
|
|
545
|
+
cdcChangedTables?: (sinceSeq: number, options?: {
|
|
546
|
+
cursorOnly?: boolean;
|
|
547
|
+
}) => Promise<{
|
|
548
|
+
cursor: number;
|
|
549
|
+
floor?: number;
|
|
550
|
+
tables: string[];
|
|
551
|
+
} | undefined>;
|
|
417
552
|
count: (tableName: string, where?: RestrictableQueryOptions | WhereInput) => Promise<number>;
|
|
418
553
|
delete: (id: string, expectedTable?: string, options?: {
|
|
419
554
|
hard?: boolean;
|
|
@@ -478,6 +613,8 @@ interface DatabaseWriterLike {
|
|
|
478
613
|
rankBefore?: (tableName: string, indexName: string, options: RankBeforeOptions) => Promise<RankBeforeResult>;
|
|
479
614
|
rankPage: (tableName: string, indexName: string, options?: RankPageOptions) => Promise<RankPage>;
|
|
480
615
|
rankPageRows?: (tableName: string, indexName: string, options?: RankPageOptions) => Promise<ShardRankPageResult>;
|
|
616
|
+
related?: (start: RelatedStart, options?: RelatedOptions) => Promise<RelatedPage>;
|
|
617
|
+
relationEdges?: ReadonlyArray<RelationEdge>;
|
|
481
618
|
replace: (id: string, document: Record<string, unknown>, expectedTable?: string, options?: {
|
|
482
619
|
allowExplicitId?: boolean;
|
|
483
620
|
}) => Promise<void>;
|
|
@@ -516,7 +653,6 @@ interface ImportShardResult {
|
|
|
516
653
|
inserted: Record<string, number>;
|
|
517
654
|
}
|
|
518
655
|
declare const selectExportTables: (schema: SchemaLike, requested?: ReadonlyArray<string>) => string[];
|
|
519
|
-
declare const exportShardTable: (writer: DatabaseWriterLike, table: string, batchSize?: number) => AsyncGenerator<ExportRow, void, undefined>;
|
|
520
656
|
declare const exportShardRows: (writer: DatabaseWriterLike, schema: SchemaLike, args: ExportShardArgs) => AsyncGenerator<ExportRow, void, undefined>;
|
|
521
657
|
declare const validateImportRow: (schema: SchemaLike, table: string, record: Record<string, unknown>) => string | undefined;
|
|
522
658
|
declare const importShardRows: (writer: DatabaseWriterLike, schema: SchemaLike, args: ImportShardArgs) => Promise<ImportShardResult>;
|
|
@@ -591,6 +727,7 @@ declare class ReactiveCache {
|
|
|
591
727
|
private readonly maxBytes;
|
|
592
728
|
private readonly now;
|
|
593
729
|
private monotonic;
|
|
730
|
+
private generation;
|
|
594
731
|
constructor(options?: ReactiveCacheOptions);
|
|
595
732
|
run<R>(key: string, deps: Set<string>, run: () => Promise<R>, ranges?: () => ReadonlyArray<KeyRange>): Promise<R>;
|
|
596
733
|
invalidate(table: string, id: string, indexKeys?: ReadonlyArray<IndexKeyEntry>): string[];
|
|
@@ -612,6 +749,7 @@ declare class ReactiveCache {
|
|
|
612
749
|
};
|
|
613
750
|
private dropRangeDeps;
|
|
614
751
|
private collectAndDrop;
|
|
752
|
+
private dropKeys;
|
|
615
753
|
private dropEntry;
|
|
616
754
|
private evict;
|
|
617
755
|
}
|
|
@@ -650,12 +788,18 @@ interface RunTriggersOptions {
|
|
|
650
788
|
}
|
|
651
789
|
declare const runTriggers: (options: RunTriggersOptions) => Promise<void>;
|
|
652
790
|
declare const hasTrigger: (schema: SchemaLike, tableName: string, op: TriggerOpLike) => boolean;
|
|
791
|
+
interface SearchBackfillProgress {
|
|
792
|
+
done: boolean;
|
|
793
|
+
pages: number;
|
|
794
|
+
}
|
|
653
795
|
declare const backfillAggregateIndexes: (sql: SqlExec, schema: SchemaLike) => void;
|
|
654
796
|
declare const backfillRankIndexes: (sql: SqlExec, schema: SchemaLike) => void;
|
|
655
797
|
declare const backfillSearchIndexesForTable: (sql: SqlExec, tableName: string, definition: {
|
|
656
798
|
searchIndexes?: ReadonlyArray<SearchIndexDefinitionLike>;
|
|
657
799
|
}) => void;
|
|
658
|
-
declare const backfillSearchIndexes: (sql: SqlExec, schema: SchemaLike
|
|
800
|
+
declare const backfillSearchIndexes: (sql: SqlExec, schema: SchemaLike, options?: {
|
|
801
|
+
maxPages?: number;
|
|
802
|
+
}) => SearchBackfillProgress;
|
|
659
803
|
declare const CDC_LOG_TABLE = "__cdc_log";
|
|
660
804
|
interface CdcChange {
|
|
661
805
|
doc?: Record<string, unknown>;
|
|
@@ -665,19 +809,35 @@ interface CdcChange {
|
|
|
665
809
|
table: string;
|
|
666
810
|
ts: number;
|
|
667
811
|
}
|
|
668
|
-
declare const
|
|
812
|
+
declare const CDC_LOG_TABLE_SEQ_INDEX = "__cdc_log_table_seq";
|
|
813
|
+
declare const migrateCdcLog: (sql: SqlExec, options?: {
|
|
814
|
+
rowHistoryIndex?: boolean;
|
|
815
|
+
}) => void;
|
|
669
816
|
declare const appendCdcChange: (sql: SqlExec, ts: number, table: string, id: string, op: CdcChange["op"], doc: Record<string, unknown> | undefined) => void;
|
|
670
817
|
declare const readCdcChanges: (sql: SqlExec, options?: {
|
|
671
818
|
limit?: number;
|
|
672
819
|
sinceSeq?: number;
|
|
673
|
-
tables?: ReadonlySet<string>;
|
|
674
820
|
}) => {
|
|
675
821
|
changes: CdcChange[];
|
|
676
822
|
cursor: number;
|
|
677
823
|
};
|
|
678
|
-
declare const
|
|
824
|
+
declare const cdcTouchesTables: (sql: SqlExec, sinceSeq: number, tables: ReadonlySet<string>) => boolean;
|
|
825
|
+
declare const cdcCanVouchFor: (sql: SqlExec, deps: ReadonlySet<string>) => boolean;
|
|
826
|
+
interface CdcChangeKey {
|
|
827
|
+
id: string;
|
|
828
|
+
op: CdcChange["op"];
|
|
829
|
+
seq: number;
|
|
830
|
+
}
|
|
831
|
+
declare const readCdcChangeKeys: (sql: SqlExec, table: string, sinceSeq: number, upTo: number) => CdcChangeKey[];
|
|
832
|
+
declare const trimCdcChanges: (sql: SqlExec, throughSeq: number, maxRows: number) => void;
|
|
833
|
+
declare const compactCdcDocs: (sql: SqlExec, throughSeq: number, maxRows: number) => void;
|
|
834
|
+
declare const cdcSeqLeavingRows: (sql: SqlExec, keep: number) => number | undefined;
|
|
679
835
|
declare const readCdcCursor: (sql: SqlExec) => number;
|
|
836
|
+
declare const cursorBelowRetainedFloor: (floor: number | undefined, sinceSeq: number) => boolean;
|
|
837
|
+
declare const cdcTrimmedError: (floor: number, sinceSeq: number, scope: "global" | "shard") => LunoraError;
|
|
838
|
+
declare const cdcForkedError: (cursor: number, sinceSeq: number, scope: "global" | "shard", epoch?: string) => LunoraError;
|
|
680
839
|
declare const minCdcSeq: (sql: SqlExec) => number | undefined;
|
|
840
|
+
declare const minCdcReplayableSeq: (sql: SqlExec) => number | undefined;
|
|
681
841
|
declare const CDC_META_TABLE = "__cdc_meta";
|
|
682
842
|
declare const migrateCdcMeta: (sql: SqlExec) => void;
|
|
683
843
|
declare const readCdcEpoch: (sql: SqlExec) => string;
|
|
@@ -689,7 +849,7 @@ declare const readClientWatermark: (sql: SqlExec, identity: string, clientId: st
|
|
|
689
849
|
declare const advanceClientWatermark: (sql: SqlExec, identity: string, clientId: string, mutationId: number) => void;
|
|
690
850
|
declare const GLOBAL_SHAPE_SNAPSHOT_TABLE = "__global_shape_snapshot";
|
|
691
851
|
declare const migrateGlobalShapeSnapshot: (sql: SqlExec) => void;
|
|
692
|
-
declare const readGlobalShapeSnapshot: (sql: SqlExec, connectionId: string, subId: string) => Map<string, string
|
|
852
|
+
declare const readGlobalShapeSnapshot: (sql: SqlExec, connectionId: string, subId: string) => Map<string, string> | undefined;
|
|
693
853
|
declare const writeGlobalShapeSnapshot: (sql: SqlExec, connectionId: string, subId: string, snapshot: Map<string, string>) => void;
|
|
694
854
|
declare const deleteGlobalShapeSnapshot: (sql: SqlExec, connectionId: string, subId: string) => void;
|
|
695
855
|
declare const deleteGlobalShapeSnapshotsForConnection: (sql: SqlExec, connectionId: string) => void;
|
|
@@ -709,21 +869,6 @@ declare const runShardMigrations: (sql: SqlExec, schema: SchemaLike, options?: {
|
|
|
709
869
|
json: string;
|
|
710
870
|
};
|
|
711
871
|
}) => void;
|
|
712
|
-
/**
|
|
713
|
-
* How far a search companion's backfill has progressed, and what the next pass
|
|
714
|
-
* should do about it.
|
|
715
|
-
*
|
|
716
|
-
* Neither stored analysis nor query policy, which is why it is its own module
|
|
717
|
-
* rather than a third responsibility bolted onto one of them: it is *progress*,
|
|
718
|
-
* the one piece of search state that is written as the index is built rather
|
|
719
|
-
* than decided when it is read.
|
|
720
|
-
*
|
|
721
|
-
* The policy below is shared because when each engine owned a copy they
|
|
722
|
-
* immediately disagreed about exactly the two cases that matter — whether a row
|
|
723
|
-
* with no recorded profile may be resumed (it may not; nothing says what
|
|
724
|
-
* analyzed it) and whether a never-started index is worth wiping (it is not;
|
|
725
|
-
* there is nothing in it).
|
|
726
|
-
*/
|
|
727
872
|
/**
|
|
728
873
|
* How far a companion's backfill has progressed, and under which analysis.
|
|
729
874
|
* Declared here rather than beside either engine's state table: both record the
|
|
@@ -747,12 +892,14 @@ interface ShapeRow {
|
|
|
747
892
|
id: string;
|
|
748
893
|
}
|
|
749
894
|
declare const selectShapeRows: (sql: SqlExec, table: string, effectiveWhere: WhereInput | undefined) => ShapeRow[];
|
|
750
|
-
declare const
|
|
895
|
+
declare const selectShapeMembers: (sql: SqlExec, table: string, effectiveWhere: WhereInput | undefined, ids: ReadonlyArray<string>) => Map<string, Record<string, unknown>>;
|
|
751
896
|
interface SqlExec {
|
|
752
897
|
exec: <Row = Record<string, unknown>>(sql: string, ...params: unknown[]) => SqlCursor<Row>;
|
|
753
898
|
}
|
|
754
899
|
interface SqlCursor<Row> extends Iterable<Row> {
|
|
900
|
+
readonly columnNames?: string[];
|
|
755
901
|
one: () => Row;
|
|
902
|
+
raw?: () => IterableIterator<unknown[]>;
|
|
756
903
|
toArray: () => Row[];
|
|
757
904
|
}
|
|
758
905
|
type IndexUseHook = (table: string, indexName: string, kind: "geo" | "index" | "rank" | "search") => void;
|
|
@@ -768,6 +915,7 @@ interface WriteEvent {
|
|
|
768
915
|
type WriteHook = (event: WriteEvent) => Promise<void> | void;
|
|
769
916
|
interface CtxDbOptions {
|
|
770
917
|
auth?: ServerDefaultContextLike["auth"];
|
|
918
|
+
baselineSeq?: () => number | undefined;
|
|
771
919
|
broadcast?: BroadcastDelta;
|
|
772
920
|
cache?: ReactiveCache;
|
|
773
921
|
cdc?: boolean;
|
|
@@ -776,10 +924,16 @@ interface CtxDbOptions {
|
|
|
776
924
|
globalDb?: DatabaseWriterLike;
|
|
777
925
|
headroom?: TransactionHeadroomTracker;
|
|
778
926
|
idGenerator?: IdGenerator;
|
|
927
|
+
inTransaction?: () => boolean;
|
|
779
928
|
maxRelationKeys?: number;
|
|
780
929
|
onIndexUse?: IndexUseHook;
|
|
781
930
|
onRead?: ReadHook;
|
|
782
931
|
onReadRange?: (range: KeyRange) => void;
|
|
932
|
+
onStalePatchDropped?: (event: {
|
|
933
|
+
fields: string[];
|
|
934
|
+
id: string;
|
|
935
|
+
table: string;
|
|
936
|
+
}) => void;
|
|
783
937
|
onWrite?: WriteHook;
|
|
784
938
|
relationExistsPushDown?: "always" | "auto" | "never";
|
|
785
939
|
scheduler?: SchedulerLike;
|
|
@@ -792,6 +946,8 @@ declare class NotUniqueError extends LunoraError {
|
|
|
792
946
|
constructor(message?: string);
|
|
793
947
|
}
|
|
794
948
|
declare const normalizeIdStructurally: (schema: SchemaLike, tableName: string, id: string) => null | string;
|
|
949
|
+
declare const assertNoExplicitUndefined: (op: "patch" | "replace", document: Record<string, unknown>) => void;
|
|
950
|
+
declare const stripReservedPatchFields: (patch: Record<string, unknown>) => Record<string, unknown>;
|
|
795
951
|
declare const createShardCtxDb: (options: CtxDbOptions) => DatabaseWriterLike;
|
|
796
952
|
declare const AUDIT_LOG_TABLE = "__lunora_audit__";
|
|
797
953
|
interface AuditEntry {
|
|
@@ -815,68 +971,23 @@ declare const readAuditLog: (sql: SqlExec, options?: {
|
|
|
815
971
|
limit?: number;
|
|
816
972
|
sinceSeq?: number;
|
|
817
973
|
}) => AuditEntry[];
|
|
818
|
-
interface
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
id: string;
|
|
836
|
-
query?: SubscriptionQuery;
|
|
837
|
-
shape?: {
|
|
838
|
-
args?: Record<string, unknown>;
|
|
839
|
-
name: string;
|
|
840
|
-
};
|
|
841
|
-
sinceCheckpoint?: number;
|
|
842
|
-
sinceEpoch?: string;
|
|
843
|
-
topic?: string;
|
|
844
|
-
type: "ack" | "connect" | "shape_subscribe" | "shape_unsubscribe" | "stream" | "subscribe" | "unsubscribe" | "whisper" | "whisper_subscribe" | "whisper_unsubscribe";
|
|
845
|
-
}
|
|
846
|
-
interface RpcRequest {
|
|
847
|
-
args?: Record<string, unknown>;
|
|
848
|
-
functionPath: string;
|
|
849
|
-
}
|
|
850
|
-
interface SocketAttachment {
|
|
851
|
-
admin?: boolean;
|
|
852
|
-
clientId?: string;
|
|
853
|
-
connected?: boolean;
|
|
854
|
-
connectionId?: string;
|
|
855
|
-
context?: Record<string, unknown>;
|
|
856
|
-
expiresAt?: number;
|
|
857
|
-
identity?: Record<string, unknown>;
|
|
858
|
-
shapes?: Record<string, ShapeSubscriptionQuery>;
|
|
859
|
-
subs: Record<string, SubscriptionQuery>;
|
|
860
|
-
userId?: string;
|
|
861
|
-
whispers?: string[];
|
|
862
|
-
}
|
|
863
|
-
interface ResolvedShape {
|
|
864
|
-
columns?: ReadonlyArray<string>;
|
|
865
|
-
effectiveWhere?: WhereInput;
|
|
866
|
-
global?: boolean;
|
|
867
|
-
table: string;
|
|
868
|
-
}
|
|
869
|
-
interface SubscriptionIdentity {
|
|
870
|
-
identity?: Record<string, unknown>;
|
|
871
|
-
userId?: string;
|
|
872
|
-
}
|
|
873
|
-
interface ShardSocketLike {
|
|
874
|
-
readonly bufferedAmount?: number;
|
|
875
|
-
close?: (code?: number, reason?: string) => void;
|
|
876
|
-
deserializeAttachment?: () => unknown;
|
|
877
|
-
send: (data: string) => void;
|
|
878
|
-
serializeAttachment?: (value: unknown) => void;
|
|
879
|
-
}
|
|
974
|
+
interface CdcArchiveScope {
|
|
975
|
+
epoch: string;
|
|
976
|
+
shard: string;
|
|
977
|
+
}
|
|
978
|
+
declare const readCdcArchivedThrough: (sql: SqlExec) => number;
|
|
979
|
+
declare const writeCdcArchivedThrough: (sql: SqlExec, seq: number) => void;
|
|
980
|
+
declare const archiveCdcSegment: (bucket: R2BucketLike, scope: CdcArchiveScope, changes: CdcChange[]) => Promise<void>;
|
|
981
|
+
declare const cdcArchiveRewound: (bucket: R2BucketLike, scope: CdcArchiveScope, archivedThrough: number) => Promise<boolean>;
|
|
982
|
+
declare const readArchivedCdcChanges: (bucket: R2BucketLike, scope: CdcArchiveScope, sinceSeq: number, limit: number | undefined) => Promise<{
|
|
983
|
+
changes: CdcChange[];
|
|
984
|
+
cursor: number;
|
|
985
|
+
} | undefined>;
|
|
986
|
+
declare const COMMIT_SEQ_TABLE = "__commit_seq";
|
|
987
|
+
declare const COMMIT_SEQ_FIELD = "_commitSeq";
|
|
988
|
+
declare const migrateCommitSeq: (sql: SqlExec) => void;
|
|
989
|
+
declare const readCommitSeq: (sql: SqlExec) => number;
|
|
990
|
+
declare const allocateCommitSeq: (sql: SqlExec) => number;
|
|
880
991
|
interface CompanionSyncDeps {
|
|
881
992
|
broadcast: (delta: MutationDelta) => void;
|
|
882
993
|
indexKeysFor: (table: string, document?: Record<string, unknown>) => ReadonlyArray<{
|
|
@@ -900,6 +1011,13 @@ interface CompanionSync {
|
|
|
900
1011
|
syncSearch: (tableName: string, id: string, document: Record<string, unknown> | undefined, previous?: Record<string, unknown>) => void;
|
|
901
1012
|
}
|
|
902
1013
|
declare const createCompanionSync: (deps: CompanionSyncDeps) => CompanionSync;
|
|
1014
|
+
declare const isMemoryTable: (definition: TableDefinitionLike | undefined) => boolean;
|
|
1015
|
+
declare const memoryTableNames: (schema: SchemaLike) => string[];
|
|
1016
|
+
declare const clearMemoryTables: (sql: SqlExec, schema: SchemaLike) => number;
|
|
1017
|
+
declare const resolveRankSeekTuple: (options: {
|
|
1018
|
+
after?: RankPageRowKey;
|
|
1019
|
+
cursor?: null | string;
|
|
1020
|
+
}) => unknown[] | undefined;
|
|
903
1021
|
interface RankPageDeps {
|
|
904
1022
|
assertRankPartitionLocal: (tableName: string, definition: TableDefinitionLike, index: RankIndexDefinitionLike) => void;
|
|
905
1023
|
ensureRankBackfilled: (tableName: string, index: RankIndexDefinitionLike) => void;
|
|
@@ -917,8 +1035,49 @@ interface RankPageComputation {
|
|
|
917
1035
|
key: RankPageRowKey;
|
|
918
1036
|
}[];
|
|
919
1037
|
}
|
|
920
|
-
declare const hydrateDocsById: (deps: RankPageDeps, tableName: string, ids: ReadonlyArray<string>) => Map<string, Record<string, unknown>>;
|
|
921
1038
|
declare const computeRankPage: (deps: RankPageDeps, tableName: string, indexName: string, rankPageOptions: RankPageOptions) => RankPageComputation;
|
|
1039
|
+
declare const SCHEDULE_OUTBOX_TABLE = "__schedule_outbox";
|
|
1040
|
+
interface ScheduleOutboxRow {
|
|
1041
|
+
attempts: number;
|
|
1042
|
+
envelopeJson: string;
|
|
1043
|
+
id: string;
|
|
1044
|
+
nextAttemptAt: number;
|
|
1045
|
+
}
|
|
1046
|
+
interface ScheduleOutboxEnvelope {
|
|
1047
|
+
args: unknown;
|
|
1048
|
+
options: Record<string, unknown> | undefined;
|
|
1049
|
+
target: unknown;
|
|
1050
|
+
when: number;
|
|
1051
|
+
}
|
|
1052
|
+
interface ScheduleOutbox {
|
|
1053
|
+
forget: (id: string) => void;
|
|
1054
|
+
record: (id: string, envelope: ScheduleOutboxEnvelope) => void;
|
|
1055
|
+
wake: () => void;
|
|
1056
|
+
}
|
|
1057
|
+
declare const migrateScheduleOutbox: (sql: SqlExec) => void;
|
|
1058
|
+
declare const recordScheduleOutbox: (sql: SqlExec, id: string, envelopeJson: string, now: number) => void;
|
|
1059
|
+
declare const forgetScheduleOutbox: (sql: SqlExec, id: string) => void;
|
|
1060
|
+
declare const readDueScheduleOutbox: (sql: SqlExec, nowMs: number, limit: number) => ScheduleOutboxRow[];
|
|
1061
|
+
declare const deferScheduleOutbox: (sql: SqlExec, id: string, attempts: number, nextAttemptAt: number) => void;
|
|
1062
|
+
declare const parkScheduleOutbox: (sql: SqlExec, id: string, attempts: number) => void;
|
|
1063
|
+
declare const probeScheduleOutbox: (sql: SqlExec) => {
|
|
1064
|
+
dueAt: number | undefined;
|
|
1065
|
+
populated: boolean;
|
|
1066
|
+
};
|
|
1067
|
+
declare const trimScheduleOutbox: (sql: SqlExec, olderThanTs: number) => void;
|
|
1068
|
+
declare const SHAPE_POKE_CURSOR_TABLE = "__shape_poke_cursor";
|
|
1069
|
+
declare const migrateShapePokeCursor: (sql: SqlExec) => void;
|
|
1070
|
+
declare const readShapePokeCursor: (sql: SqlExec, connectionId: string, subId: string) => number | undefined;
|
|
1071
|
+
declare const writeShapePokeCursor: (sql: SqlExec, connectionId: string, subId: string, cursor: number) => void;
|
|
1072
|
+
interface ShapePokeCursorRow {
|
|
1073
|
+
connectionId: string;
|
|
1074
|
+
cursor: number;
|
|
1075
|
+
subId: string;
|
|
1076
|
+
}
|
|
1077
|
+
declare const writeShapePokeCursors: (sql: SqlExec, rows: ReadonlyArray<ShapePokeCursorRow>) => void;
|
|
1078
|
+
declare const minShapePokeCursor: (sql: SqlExec) => number | undefined;
|
|
1079
|
+
declare const deleteShapePokeCursor: (sql: SqlExec, connectionId: string, subId: string) => void;
|
|
1080
|
+
declare const deleteShapePokeCursorsForConnection: (sql: SqlExec, connectionId: string) => void;
|
|
922
1081
|
declare const DATA_MIGRATION_STATE_TABLE = "__lunora_migrations";
|
|
923
1082
|
type MigrationDirection = "down" | "up";
|
|
924
1083
|
type MigrationStatus = "completed" | "failed" | "in_progress";
|
|
@@ -982,10 +1141,10 @@ interface DependencyTracker {
|
|
|
982
1141
|
declare const createDependencyTracker: () => DependencyTracker;
|
|
983
1142
|
declare const runSql: <Row = Record<string, unknown>>(sql: SqlExec, query: string, ...params: unknown[]) => SqlCursor<Row>;
|
|
984
1143
|
declare const runDrizzle: <Row = Record<string, unknown>>(exec: SqlExec, query: SQL) => SqlCursor<Row>;
|
|
1144
|
+
declare const quoteIdentifier: (name: string) => string;
|
|
985
1145
|
declare const serializeSqlValue: (value: unknown) => unknown;
|
|
986
1146
|
declare const DOC_COLUMN = "__doc__";
|
|
987
1147
|
declare const geoTableName: (table: string, indexName: string) => string;
|
|
988
|
-
declare const quoteIdentifier: (name: string) => string;
|
|
989
1148
|
declare const jsonPath: (field: string) => string;
|
|
990
1149
|
declare const jsonPathSql: (field: string) => SQL;
|
|
991
1150
|
declare const qualifiedJsonPath: (table: string, field: string) => string;
|
|
@@ -995,7 +1154,7 @@ declare const AGG_KEY: Name;
|
|
|
995
1154
|
declare const AGG_VALUE: Name;
|
|
996
1155
|
declare const AGG_COUNT: Name;
|
|
997
1156
|
declare const aggUpsertSql: (aggTable: string, key: unknown, value: unknown, count: unknown, set: SQL) => SQL;
|
|
998
|
-
declare const tableColumns: (definition: TableDefinitionLike) => [string, ColumnMetaLike]
|
|
1157
|
+
declare const tableColumns: (definition: TableDefinitionLike) => ReadonlyArray<readonly [string, ColumnMetaLike]>;
|
|
999
1158
|
declare const rowToDocument: (row: Record<string, unknown> | undefined) => Record<string, unknown> | undefined;
|
|
1000
1159
|
declare const tryRowToDocument: (row: Record<string, unknown> | undefined) => Record<string, unknown> | undefined;
|
|
1001
1160
|
declare const isFtsAvailable: (sql: SqlExec) => boolean;
|
|
@@ -1006,6 +1165,79 @@ interface RenderedSql {
|
|
|
1006
1165
|
}
|
|
1007
1166
|
declare const renderSql: (engine: SqlEngine, query: SQL) => RenderedSql;
|
|
1008
1167
|
declare const param: (value: unknown) => SQL;
|
|
1168
|
+
declare const unionAll: (branches: ReadonlyArray<SQL>) => SQL;
|
|
1169
|
+
declare const sqliteInList: (reference: SQL, items: ReadonlyArray<unknown>, negated: boolean, budget?: number) => SQL;
|
|
1170
|
+
type DurableStreamStatus = "complete" | "error" | "running";
|
|
1171
|
+
interface DurableStreamRun {
|
|
1172
|
+
error?: string;
|
|
1173
|
+
errorCode?: string;
|
|
1174
|
+
lastSeq: number;
|
|
1175
|
+
startedAt: number;
|
|
1176
|
+
status: DurableStreamStatus;
|
|
1177
|
+
}
|
|
1178
|
+
interface DurableStreamChunk {
|
|
1179
|
+
dataJson: string;
|
|
1180
|
+
seq: number;
|
|
1181
|
+
}
|
|
1182
|
+
declare const migrateDurableStreams: (sql: SqlExec) => void;
|
|
1183
|
+
declare const readStreamRun: (sql: SqlExec, runKey: string) => DurableStreamRun | undefined;
|
|
1184
|
+
declare const claimStreamRun: (sql: SqlExec, runKey: string, startedAt: number, ttlMs: number) => boolean;
|
|
1185
|
+
declare const deleteStreamRun: (sql: SqlExec, runKey: string) => void;
|
|
1186
|
+
declare const appendStreamChunk: (sql: SqlExec, runKey: string, seq: number, dataJson: string) => void;
|
|
1187
|
+
declare const readStreamChunks: (sql: SqlExec, runKey: string, sinceSeq: number) => DurableStreamChunk[];
|
|
1188
|
+
declare const finishStreamRun: (sql: SqlExec, runKey: string, status: "complete" | "error", lastSeq: number, failure?: {
|
|
1189
|
+
code: string;
|
|
1190
|
+
message: string;
|
|
1191
|
+
}) => void;
|
|
1192
|
+
declare const trimStreamRuns: (sql: SqlExec, now: number) => void;
|
|
1193
|
+
declare const MAX_DURABLE_STREAM_CHUNKS = 50000;
|
|
1194
|
+
declare const MAX_DURABLE_STREAM_BYTES: number;
|
|
1195
|
+
interface DurableStreamSink {
|
|
1196
|
+
readonly chunk: (chunk: {
|
|
1197
|
+
data: unknown;
|
|
1198
|
+
generation?: number;
|
|
1199
|
+
seq: number;
|
|
1200
|
+
}) => boolean;
|
|
1201
|
+
readonly complete: () => void;
|
|
1202
|
+
readonly fail: (failure: {
|
|
1203
|
+
code: string;
|
|
1204
|
+
message: string;
|
|
1205
|
+
}) => void;
|
|
1206
|
+
}
|
|
1207
|
+
type DurableAttachDecision = "attach" | "interrupted" | "reclaim" | "replay-terminal";
|
|
1208
|
+
declare const decideDurableAttach: (run: DurableStreamRun | undefined, context: {
|
|
1209
|
+
generation?: number;
|
|
1210
|
+
live?: {
|
|
1211
|
+
generation: number;
|
|
1212
|
+
};
|
|
1213
|
+
resuming: boolean;
|
|
1214
|
+
}) => DurableAttachDecision;
|
|
1215
|
+
interface DurableStreamAttach {
|
|
1216
|
+
readonly generation?: number;
|
|
1217
|
+
readonly iterator: (signal: AbortSignal) => AsyncIterable<unknown>;
|
|
1218
|
+
readonly runKey: string;
|
|
1219
|
+
readonly sinceChunk: number;
|
|
1220
|
+
readonly sink: DurableStreamSink;
|
|
1221
|
+
readonly ttlMs?: number;
|
|
1222
|
+
}
|
|
1223
|
+
declare class DurableStreamRunner {
|
|
1224
|
+
private lastTrimAt;
|
|
1225
|
+
private readonly runs;
|
|
1226
|
+
private readonly sql;
|
|
1227
|
+
private readonly waitUntil;
|
|
1228
|
+
constructor(dependencies: {
|
|
1229
|
+
sql: () => SqlExec;
|
|
1230
|
+
waitUntil?: (promise: Promise<unknown>) => void;
|
|
1231
|
+
});
|
|
1232
|
+
attach(request: DurableStreamAttach): Promise<void>;
|
|
1233
|
+
detach(runKey: string, sink: DurableStreamSink): void;
|
|
1234
|
+
isLive(runKey: string): boolean;
|
|
1235
|
+
private attachOrThrow;
|
|
1236
|
+
private produce;
|
|
1237
|
+
private trim;
|
|
1238
|
+
}
|
|
1239
|
+
declare const envPositiveInt: (env: unknown, key: string, fallback: number) => number;
|
|
1240
|
+
declare const envOptionalPositiveInt: (env: unknown, key: string) => number | undefined;
|
|
1009
1241
|
interface ExternalSourceDiffResult {
|
|
1010
1242
|
changes: CdcChange[];
|
|
1011
1243
|
nextBaseline: Map<string, string>;
|
|
@@ -1070,6 +1302,16 @@ declare const isSoftDeleted: (row: Record<string, unknown>, column: string) => b
|
|
|
1070
1302
|
declare const pullExternalSourceIncrementalTick: (sql: SqlExec, writer: DatabaseWriterLike, client: SourceClientLike, table: string, source: ExternalSourceLike, shardKey: string, nowMs: number) => Promise<{
|
|
1071
1303
|
applied: number;
|
|
1072
1304
|
}>;
|
|
1305
|
+
declare const ftsRowidMapName: (companion: string) => string;
|
|
1306
|
+
interface FtsWriteOptions {
|
|
1307
|
+
guard?: SQL;
|
|
1308
|
+
unmappedRowids?: ReadonlyArray<number>;
|
|
1309
|
+
}
|
|
1310
|
+
declare const ftsCompanionDdl: (companion: string) => SQL[];
|
|
1311
|
+
declare const ftsWriteDocument: (companion: string, id: string, text: string, options?: FtsWriteOptions) => SQL[];
|
|
1312
|
+
declare const ftsPurgeDocument: (companion: string, id: string, options?: FtsWriteOptions) => SQL[];
|
|
1313
|
+
declare const ftsUnmappedPage: (companion: string, limit: number, after?: number) => SQL;
|
|
1314
|
+
declare const groupUnmappedRows: (rows: ReadonlyArray<Record<string, unknown>>) => Map<string, number[]>;
|
|
1073
1315
|
declare const GEO_DEFAULT_PRECISION = 9;
|
|
1074
1316
|
interface GeoPoint {
|
|
1075
1317
|
lat: number;
|
|
@@ -1085,6 +1327,19 @@ declare const coveringGeohashes: (center: GeoPoint, radiusMeters: number) => str
|
|
|
1085
1327
|
declare const pointInBoundingBox: (point: GeoPoint, box: GeoBoundingBox) => boolean;
|
|
1086
1328
|
declare const boundingBoxCenter: (box: GeoBoundingBox) => GeoPoint;
|
|
1087
1329
|
declare const boundingBoxGeohashes: (box: GeoBoundingBox) => string[];
|
|
1330
|
+
declare class GlobalPollTick {
|
|
1331
|
+
private readonly changedTables;
|
|
1332
|
+
private readonly reads;
|
|
1333
|
+
private resync;
|
|
1334
|
+
private skippedCount;
|
|
1335
|
+
constructor(changedTables?: Set<string>);
|
|
1336
|
+
get readCount(): number;
|
|
1337
|
+
get resyncRequested(): boolean;
|
|
1338
|
+
get skipped(): number;
|
|
1339
|
+
requestResync(): void;
|
|
1340
|
+
rows(key: string | undefined, load: () => Promise<ShapeRow[]>): Promise<ShapeRow[]>;
|
|
1341
|
+
shouldRead(table: string): boolean;
|
|
1342
|
+
}
|
|
1088
1343
|
declare const ADMIN_FUNCTION_PREFIX = "__lunora_admin__:";
|
|
1089
1344
|
declare const RELATION_FUNCTION_PREFIX = "__lunora_relation__:";
|
|
1090
1345
|
declare const FLAGS_FUNCTION_PREFIX = "__lunora_flags__:";
|
|
@@ -1095,6 +1350,7 @@ declare const ADMIN_FUNCTIONS: {
|
|
|
1095
1350
|
readonly aiGenerateSql: "__lunora_admin__:aiGenerateSql";
|
|
1096
1351
|
readonly aiTableFilter: "__lunora_admin__:aiTableFilter";
|
|
1097
1352
|
readonly assignIssue: "__lunora_admin__:assignIssue";
|
|
1353
|
+
readonly backfillSearch: "__lunora_admin__:backfillSearch";
|
|
1098
1354
|
readonly backRelationCounts: "__lunora_admin__:backRelationCounts";
|
|
1099
1355
|
readonly cdcSync: "__lunora_admin__:cdcSync";
|
|
1100
1356
|
readonly clearCapturedMail: "__lunora_admin__:clearCapturedMail";
|
|
@@ -1107,6 +1363,7 @@ declare const ADMIN_FUNCTIONS: {
|
|
|
1107
1363
|
readonly explainIssue: "__lunora_admin__:explainIssue";
|
|
1108
1364
|
readonly exportShard: "__lunora_admin__:exportShard";
|
|
1109
1365
|
readonly facetColumn: "__lunora_admin__:facetColumn";
|
|
1366
|
+
readonly findRelated: "__lunora_admin__:findRelated";
|
|
1110
1367
|
readonly getAdvisories: "__lunora_admin__:getAdvisories";
|
|
1111
1368
|
readonly getAdvisorProcedures: "__lunora_admin__:getAdvisorProcedures";
|
|
1112
1369
|
readonly getAuditLog: "__lunora_admin__:getAuditLog";
|
|
@@ -1133,12 +1390,14 @@ declare const ADMIN_FUNCTIONS: {
|
|
|
1133
1390
|
readonly ignoreIssue: "__lunora_admin__:ignoreIssue";
|
|
1134
1391
|
readonly importShard: "__lunora_admin__:importShard";
|
|
1135
1392
|
readonly listFlags: "__lunora_admin__:listFlags";
|
|
1393
|
+
readonly listReactors: "__lunora_admin__:listReactors";
|
|
1136
1394
|
readonly listQueues: "__lunora_admin__:listQueues";
|
|
1137
1395
|
readonly lintSql: "__lunora_admin__:lintSql";
|
|
1138
1396
|
readonly listTables: "__lunora_admin__:listTables";
|
|
1139
1397
|
readonly listWorkflows: "__lunora_admin__:listWorkflows";
|
|
1140
1398
|
readonly maskPolicies: "__lunora_admin__:maskPolicies";
|
|
1141
1399
|
readonly migrationStatus: "__lunora_admin__:migrationStatus";
|
|
1400
|
+
readonly patchRows: "__lunora_admin__:patchRows";
|
|
1142
1401
|
readonly pitrRestore: "__lunora_admin__:pitrRestore";
|
|
1143
1402
|
readonly rankBefore: "__lunora_admin__:rankBefore";
|
|
1144
1403
|
readonly rankPage: "__lunora_admin__:rankPage";
|
|
@@ -1216,8 +1475,12 @@ interface TablesIndexesResult {
|
|
|
1216
1475
|
indexesByTable: Record<string, TableIndexInfo[]>;
|
|
1217
1476
|
}
|
|
1218
1477
|
interface ColumnMeta {
|
|
1478
|
+
bucket?: string;
|
|
1479
|
+
enumValues?: string[];
|
|
1219
1480
|
isStorage?: boolean;
|
|
1220
1481
|
name: string;
|
|
1482
|
+
nullable?: boolean;
|
|
1483
|
+
onDelete?: "cascade" | "restrict" | "set null";
|
|
1221
1484
|
optional: boolean;
|
|
1222
1485
|
pk?: boolean;
|
|
1223
1486
|
ref?: string;
|
|
@@ -1332,6 +1595,19 @@ interface FlagsResult {
|
|
|
1332
1595
|
configured: boolean;
|
|
1333
1596
|
flags: FlagEvaluation[];
|
|
1334
1597
|
}
|
|
1598
|
+
interface ReactorMetadata {
|
|
1599
|
+
errors: number;
|
|
1600
|
+
lastError?: string;
|
|
1601
|
+
lastRanAt?: number;
|
|
1602
|
+
path: string;
|
|
1603
|
+
runs: number;
|
|
1604
|
+
state: "active" | "failing" | "idle";
|
|
1605
|
+
suppressed: number;
|
|
1606
|
+
tables?: ReadonlyArray<string>;
|
|
1607
|
+
}
|
|
1608
|
+
interface ReactorsResult {
|
|
1609
|
+
reactors: ReactorMetadata[];
|
|
1610
|
+
}
|
|
1335
1611
|
interface WorkflowMetadata {
|
|
1336
1612
|
binding: string;
|
|
1337
1613
|
className: string;
|
|
@@ -1390,6 +1666,7 @@ interface TablePage {
|
|
|
1390
1666
|
columns: string[];
|
|
1391
1667
|
refs?: Record<string, string>;
|
|
1392
1668
|
rows: Record<string, unknown>[];
|
|
1669
|
+
sqlColumns: string[];
|
|
1393
1670
|
total?: number;
|
|
1394
1671
|
}
|
|
1395
1672
|
type FilterOperator = "contains" | "eq" | "gt" | "gte" | "lt" | "lte" | "ne";
|
|
@@ -1413,6 +1690,7 @@ interface ReadTablePageOptions {
|
|
|
1413
1690
|
table: string;
|
|
1414
1691
|
}
|
|
1415
1692
|
interface SelectMatchingIdsOptions {
|
|
1693
|
+
after?: string;
|
|
1416
1694
|
filters?: FilterClause[];
|
|
1417
1695
|
limit?: number;
|
|
1418
1696
|
search?: string;
|
|
@@ -1469,12 +1747,22 @@ interface FanoutPathCounters {
|
|
|
1469
1747
|
socketsIterated: number;
|
|
1470
1748
|
totalMs: number;
|
|
1471
1749
|
}
|
|
1750
|
+
interface ShapeProbeCounters {
|
|
1751
|
+
run: number;
|
|
1752
|
+
served: number;
|
|
1753
|
+
}
|
|
1754
|
+
interface GlobalPollCounters {
|
|
1755
|
+
drains: number;
|
|
1756
|
+
pairsSkipped: number;
|
|
1757
|
+
}
|
|
1472
1758
|
interface FanoutMetricsResult {
|
|
1759
|
+
globalPoll: GlobalPollCounters;
|
|
1473
1760
|
maxRelays: number;
|
|
1474
1761
|
peakSubscribers: number;
|
|
1475
1762
|
promoted: boolean;
|
|
1476
1763
|
relayCount: number;
|
|
1477
1764
|
shapePoke: FanoutPathCounters;
|
|
1765
|
+
shapeProbe: ShapeProbeCounters;
|
|
1478
1766
|
sinceMs: number;
|
|
1479
1767
|
topics: FanoutTopicStat[];
|
|
1480
1768
|
totalConnections: number;
|
|
@@ -1488,6 +1776,10 @@ interface FanoutAttachmentLike {
|
|
|
1488
1776
|
}
|
|
1489
1777
|
declare const DEFAULT_FANOUT_TOPIC_LIMIT = 20;
|
|
1490
1778
|
declare const createFanoutCounters: () => FanoutPathCounters;
|
|
1779
|
+
declare const createShapeProbeCounters: () => ShapeProbeCounters;
|
|
1780
|
+
declare const createGlobalPollCounters: () => GlobalPollCounters;
|
|
1781
|
+
declare const recordGlobalPollPass: (counters: GlobalPollCounters, drains: number, pairsSkipped: number) => GlobalPollCounters;
|
|
1782
|
+
declare const recordShapeProbePass: (counters: ShapeProbeCounters, run: number, served: number) => ShapeProbeCounters;
|
|
1491
1783
|
declare const recordFanoutPass: (counters: FanoutPathCounters, iterated: number, delivered: number, ms: number) => FanoutPathCounters;
|
|
1492
1784
|
declare const summarizeFanoutTopics: (attachments: FanoutAttachmentLike[], limit?: number) => {
|
|
1493
1785
|
peakSubscribers: number;
|
|
@@ -1556,7 +1848,20 @@ interface PitrRestoreArgs {
|
|
|
1556
1848
|
}
|
|
1557
1849
|
declare const readBookmark: (storage: PitrStorage, time?: number | string) => Promise<PitrBookmarkResult>;
|
|
1558
1850
|
declare const armRestore: (storage: PitrStorage, args: PitrRestoreArgs) => Promise<Omit<PitrRestoreResult, "restarted">>;
|
|
1559
|
-
declare const
|
|
1851
|
+
declare const tiebreakDirectionFor: (keys: ReadonlyArray<{
|
|
1852
|
+
direction?: string;
|
|
1853
|
+
}>) => SortDirection;
|
|
1854
|
+
declare const equalityPinnedFields: (where: undefined | WhereInput) => ReadonlySet<string>;
|
|
1855
|
+
declare const uniqueIndexFields: (indexes: ReadonlyArray<{
|
|
1856
|
+
fields: ReadonlyArray<string>;
|
|
1857
|
+
unique?: boolean;
|
|
1858
|
+
}> | undefined, shape: Record<string, ValidatorLike> | undefined) => ReadonlyArray<ReadonlyArray<string>>;
|
|
1859
|
+
interface OrderKeyConstraints {
|
|
1860
|
+
pinned?: ReadonlySet<string>;
|
|
1861
|
+
uniqueBy?: ReadonlyArray<ReadonlyArray<string>>;
|
|
1862
|
+
}
|
|
1863
|
+
declare const normalizeOrderKeys: (orderBy: OrderByInput[] | undefined, shape?: Record<string, ValidatorLike>, constraints?: OrderKeyConstraints) => OrderKey[];
|
|
1864
|
+
declare const CURSOR_PREFIX = "~4";
|
|
1560
1865
|
declare const encodeCursor: (record: Record<string, unknown>, keys: OrderKey[]) => string;
|
|
1561
1866
|
declare const decodeCursor: (cursor: string) => unknown[];
|
|
1562
1867
|
declare const buildSeekWhere: (keys: OrderKey[], cursorValues: unknown[]) => WhereInput;
|
|
@@ -1609,7 +1914,6 @@ declare const clearQueueMessages: (sql: SqlExec) => {
|
|
|
1609
1914
|
declare const encodePartitionKey: (partitionBy: ReadonlyArray<string>, source: Record<string, unknown>) => string;
|
|
1610
1915
|
declare const RANK_TIEBREAK = "__id__";
|
|
1611
1916
|
declare const sortColumnName: (i: number) => string;
|
|
1612
|
-
declare const matchesRankStaticWhere: (document: Record<string, unknown>, predicate: Record<string, unknown>) => boolean;
|
|
1613
1917
|
declare const resolveRankPartition: (index: RankIndexDefinitionLike, where: Record<string, unknown> | undefined) => Record<string, unknown> | undefined;
|
|
1614
1918
|
declare const rankTableName: (table: string, indexName: string) => string;
|
|
1615
1919
|
declare const rankKeyFromDocument: (index: RankIndexDefinitionLike, document_: Record<string, unknown>) => {
|
|
@@ -1617,6 +1921,36 @@ declare const rankKeyFromDocument: (index: RankIndexDefinitionLike, document_: R
|
|
|
1617
1921
|
rowId: string;
|
|
1618
1922
|
sortValues: unknown[];
|
|
1619
1923
|
};
|
|
1924
|
+
declare const rankPivotConditionSql: (column: string, value: unknown, direction: "asc" | "desc", wantLater: boolean) => SQL | undefined;
|
|
1925
|
+
declare const matchesRankStaticWhere: (document: Record<string, unknown>, predicate: Record<string, unknown>) => boolean;
|
|
1926
|
+
declare const REACTOR_STATE_TABLE = "__reactor_state";
|
|
1927
|
+
interface ReactorState {
|
|
1928
|
+
digest: string;
|
|
1929
|
+
lastError?: string;
|
|
1930
|
+
lastRanAt: number;
|
|
1931
|
+
stats: ReactorStats;
|
|
1932
|
+
tables?: ReadonlyArray<string>;
|
|
1933
|
+
}
|
|
1934
|
+
interface ReactorStats {
|
|
1935
|
+
errors: number;
|
|
1936
|
+
runs: number;
|
|
1937
|
+
suppressed: number;
|
|
1938
|
+
}
|
|
1939
|
+
declare const migrateReactorState: (sql: SqlExec) => void;
|
|
1940
|
+
declare const readReactorState: (sql: SqlExec, path: string) => ReactorState | undefined;
|
|
1941
|
+
declare const listReactorStates: (sql: SqlExec) => {
|
|
1942
|
+
path: string;
|
|
1943
|
+
state: ReactorState;
|
|
1944
|
+
}[];
|
|
1945
|
+
type ReactorDispatchResult = "error" | "ran" | "suppressed";
|
|
1946
|
+
declare const writeReactorState: (sql: SqlExec, path: string, outcome: {
|
|
1947
|
+
digest?: string;
|
|
1948
|
+
error?: string;
|
|
1949
|
+
now: number;
|
|
1950
|
+
result: ReactorDispatchResult;
|
|
1951
|
+
tables?: ReadonlyArray<string>;
|
|
1952
|
+
}) => void;
|
|
1953
|
+
declare const reactorNeedsRun: (state: Pick<ReactorState, "tables"> | undefined, changed: ReadonlySet<string>) => boolean;
|
|
1620
1954
|
interface ReadFootprint {
|
|
1621
1955
|
onRead: (table: string, idOrScan?: string) => void;
|
|
1622
1956
|
onReadRange: (range: KeyRange) => void;
|
|
@@ -1624,6 +1958,15 @@ interface ReadFootprint {
|
|
|
1624
1958
|
tables: Set<string>;
|
|
1625
1959
|
}
|
|
1626
1960
|
declare const createReadFootprint: () => ReadFootprint;
|
|
1961
|
+
declare const UNVOUCHABLE_DEP = "!unvouchable";
|
|
1962
|
+
declare const markUnvouchableReads: <T extends object>(facade: T, onRead: ReadFootprint["onRead"] | undefined, methods: ReadonlyArray<string>) => T;
|
|
1963
|
+
declare const RELATED_MAX_DEPTH = 4;
|
|
1964
|
+
declare const RELATED_DEFAULT_LIMIT = 50;
|
|
1965
|
+
declare const RELATED_MAX_LIMIT = 200;
|
|
1966
|
+
declare const RELATED_DEPTH_DECAY = 0.5;
|
|
1967
|
+
declare const deriveRelationEdges: (schema: SchemaLike) => RelationEdge[];
|
|
1968
|
+
type RelationGraphReader = Pick<DatabaseWriterLike, "findMany"> & Pick<Partial<DatabaseWriterLike>, "lookupById">;
|
|
1969
|
+
declare const findRelated: (reader: RelationGraphReader, edges: ReadonlyArray<RelationEdge>, start: RelatedStart, options?: RelatedOptions) => Promise<RelatedPage>;
|
|
1627
1970
|
declare const DEFAULT_MAX_RELATION_KEYS = 5000;
|
|
1628
1971
|
interface RelationExistsMarker {
|
|
1629
1972
|
childWhere: WhereInput;
|
|
@@ -1658,6 +2001,7 @@ declare const containsRelationPredicate: (where: WhereInput, schema: ResolveCont
|
|
|
1658
2001
|
declare const assertFlatPredicate: (where: WhereInput | undefined, schema: ResolveContext["schema"], tableName: string, op: string) => void;
|
|
1659
2002
|
declare const resolveRelationPredicates: (where: WhereInput | undefined, options: ResolveRelationPredicatesOptions) => Promise<WhereInput | undefined>;
|
|
1660
2003
|
declare const assertShapeShardable: (effectiveWhere: WhereInput | undefined, schema: ResolveContext["schema"], table: string) => void;
|
|
2004
|
+
declare const relationHooks: (args: Pick<QueryArgs, "relationBaseWhere" | "relationMask">) => Pick<QueryArgs, "relationBaseWhere" | "relationMask"> & Pick<ResolveWithOptions, "fanOutBudget">;
|
|
1661
2005
|
declare const fanOutScalarCounts: (counter: (tableName: string, where?: WhereInput) => Promise<number>, tableName: string, whereField: string, values: unknown[], policyWhere: WhereInput | undefined) => Promise<Map<unknown, number>>;
|
|
1662
2006
|
declare const distinctValues: (rows: Record<string, unknown>[], field: string) => unknown[];
|
|
1663
2007
|
declare const resolveWith: (options: ResolveWithOptions) => Promise<void>;
|
|
@@ -1682,6 +2026,8 @@ interface ShapeRowOp {
|
|
|
1682
2026
|
value?: Record<string, unknown>;
|
|
1683
2027
|
}
|
|
1684
2028
|
interface ShapePokePart {
|
|
2029
|
+
baseCheckpoint?: number;
|
|
2030
|
+
reset?: boolean;
|
|
1685
2031
|
rowsPatch: ShapeRowOp[];
|
|
1686
2032
|
shapeId: string;
|
|
1687
2033
|
}
|
|
@@ -1742,6 +2088,12 @@ interface RelayShapeSubscribe {
|
|
|
1742
2088
|
type: "relay_shape_subscribe";
|
|
1743
2089
|
userId?: string;
|
|
1744
2090
|
}
|
|
2091
|
+
interface RelayShapeUnsubscribe {
|
|
2092
|
+
connectionId: string;
|
|
2093
|
+
relayIndex: number;
|
|
2094
|
+
subId?: string;
|
|
2095
|
+
type: "relay_shape_unsubscribe";
|
|
2096
|
+
}
|
|
1745
2097
|
interface RelayShapeSeed {
|
|
1746
2098
|
cursor?: number;
|
|
1747
2099
|
epoch?: string;
|
|
@@ -1761,22 +2113,18 @@ interface RelayShapePoke {
|
|
|
1761
2113
|
targetConnectionId?: string;
|
|
1762
2114
|
type: "relay_shape_poke";
|
|
1763
2115
|
}
|
|
1764
|
-
type OwnerRelayFrame = RelayAttach | RelayDetach | RelayFrame | RelayShapePoke | RelayShapeSubscribe;
|
|
1765
|
-
|
|
1766
|
-
interface RelayStub {
|
|
2116
|
+
type OwnerRelayFrame = RelayAttach | RelayDetach | RelayFrame | RelayShapePoke | RelayShapeSubscribe | RelayShapeUnsubscribe;
|
|
2117
|
+
interface SiblingStub {
|
|
1767
2118
|
fetch: (url: string, init?: RequestInit) => Promise<Response>;
|
|
1768
2119
|
}
|
|
1769
|
-
|
|
1770
|
-
get: (id: unknown) => RelayStub;
|
|
1771
|
-
getByName?: (name: string) => RelayStub;
|
|
1772
|
-
idFromName: (name: string) => unknown;
|
|
1773
|
-
}
|
|
2120
|
+
declare const DEFAULT_MAX_RELAYS = 8;
|
|
1774
2121
|
interface RelayHost {
|
|
1775
2122
|
buildShapeDiff: (resolved: ResolvedShape, fromCursor: number, toCursor: number) => ShapeRowOp[];
|
|
1776
2123
|
computeOpLogShapeSeed: (shape: ShapeSubscriptionQuery, resolved: ResolvedShape) => {
|
|
1777
2124
|
baseCheckpoint: number | undefined;
|
|
1778
2125
|
cursor: number;
|
|
1779
2126
|
epoch: string | undefined;
|
|
2127
|
+
reset: boolean;
|
|
1780
2128
|
rowsPatch: ShapeRowOp[];
|
|
1781
2129
|
};
|
|
1782
2130
|
currentCdcEpoch: () => string | undefined;
|
|
@@ -1791,8 +2139,13 @@ interface RelayHost {
|
|
|
1791
2139
|
resolveShape: (name: string, args: Record<string, unknown>, identity?: SubscriptionIdentity) => ResolvedShape | undefined;
|
|
1792
2140
|
rlsMetadata: () => RlsPoliciesResult;
|
|
1793
2141
|
shardBinding: () => string | undefined;
|
|
2142
|
+
shardJurisdiction: () => string | undefined;
|
|
1794
2143
|
sql: () => SqlExec;
|
|
1795
2144
|
}
|
|
2145
|
+
interface RelayPokeDelivery {
|
|
2146
|
+
delivered: number;
|
|
2147
|
+
matched: number;
|
|
2148
|
+
}
|
|
1796
2149
|
declare abstract class RelayLink {
|
|
1797
2150
|
protected readonly host: RelayHost;
|
|
1798
2151
|
protected readonly roleId: {
|
|
@@ -1806,7 +2159,8 @@ declare abstract class RelayLink {
|
|
|
1806
2159
|
handleControl(request: Request): Promise<Response>;
|
|
1807
2160
|
maxRelays(): number;
|
|
1808
2161
|
protected canAddressSiblings(): boolean;
|
|
1809
|
-
protected
|
|
2162
|
+
protected siblingStub(targetName: string): SiblingStub | undefined;
|
|
2163
|
+
protected bindingName(): string | undefined;
|
|
1810
2164
|
protected postRelayMessage(targetName: string, message: OwnerRelayFrame): Promise<void>;
|
|
1811
2165
|
protected requestRelayMessage(targetName: string, message: OwnerRelayFrame): Promise<Response | undefined>;
|
|
1812
2166
|
abstract forwardWhisper(topic: string, frame: string): Promise<void>;
|
|
@@ -1817,19 +2171,22 @@ declare abstract class RelayLink {
|
|
|
1817
2171
|
}>;
|
|
1818
2172
|
abstract announce(): Promise<void>;
|
|
1819
2173
|
abstract announceDrain(closing: ShardSocketLike): Promise<void>;
|
|
2174
|
+
abstract releaseRelayShapes(ws: ShardSocketLike, subId?: string): Promise<void>;
|
|
1820
2175
|
abstract relayCount(): number;
|
|
1821
2176
|
abstract isShapeRelayUniform(name: string, args: Record<string, unknown>): boolean;
|
|
2177
|
+
abstract minShapeCursor(): number | undefined;
|
|
1822
2178
|
protected abstract onAttach(index: number): void;
|
|
1823
2179
|
protected abstract onDetach(index: number): void;
|
|
1824
2180
|
protected abstract onWhisperFrame(message: RelayFrame): Promise<void>;
|
|
1825
2181
|
protected abstract onShapeSubscribe(message: RelayShapeSubscribe): RelayShapeSeed;
|
|
1826
|
-
protected abstract
|
|
2182
|
+
protected abstract onShapeUnsubscribe(message: RelayShapeUnsubscribe): void;
|
|
2183
|
+
protected abstract onShapePoke(poke: RelayShapePoke): RelayPokeDelivery;
|
|
1827
2184
|
}
|
|
1828
2185
|
declare class OwnerRelay extends RelayLink {
|
|
1829
2186
|
private readonly shapeUniformCache;
|
|
1830
2187
|
private relaySetCache;
|
|
1831
|
-
private
|
|
1832
|
-
private
|
|
2188
|
+
private registryCache;
|
|
2189
|
+
private recordedBinding;
|
|
1833
2190
|
private promotionState;
|
|
1834
2191
|
constructor(host: RelayHost, ownerKey: string);
|
|
1835
2192
|
forwardWhisper(topic: string, frame: string): Promise<void>;
|
|
@@ -1840,17 +2197,26 @@ declare class OwnerRelay extends RelayLink {
|
|
|
1840
2197
|
}>;
|
|
1841
2198
|
announce(): Promise<void>;
|
|
1842
2199
|
announceDrain(): Promise<void>;
|
|
2200
|
+
releaseRelayShapes(): Promise<void>;
|
|
1843
2201
|
relayCount(): number;
|
|
2202
|
+
minShapeCursor(): number | undefined;
|
|
1844
2203
|
isShapeRelayUniform(name: string, args: Record<string, unknown>): boolean;
|
|
2204
|
+
protected onShapeUnsubscribe(message: RelayShapeUnsubscribe): void;
|
|
1845
2205
|
protected onAttach(index: number): void;
|
|
1846
2206
|
protected onDetach(index: number): void;
|
|
1847
2207
|
protected onWhisperFrame(message: RelayFrame): Promise<void>;
|
|
1848
2208
|
protected onShapeSubscribe(message: RelayShapeSubscribe): RelayShapeSeed;
|
|
1849
|
-
protected onShapePoke():
|
|
2209
|
+
protected onShapePoke(): RelayPokeDelivery;
|
|
2210
|
+
private buildShapePoke;
|
|
1850
2211
|
private multicastShapePokes;
|
|
2212
|
+
private multicastToRelays;
|
|
1851
2213
|
private proxyShapePokes;
|
|
2214
|
+
private proxyToRelay;
|
|
1852
2215
|
private buildShapeSeedFrames;
|
|
1853
|
-
private
|
|
2216
|
+
private ensureRelayTables;
|
|
2217
|
+
protected bindingName(): string | undefined;
|
|
2218
|
+
private relayShapes;
|
|
2219
|
+
private rewindShapeCursor;
|
|
1854
2220
|
private ownerRelaySet;
|
|
1855
2221
|
private addRelayToSet;
|
|
1856
2222
|
private removeRelayFromSet;
|
|
@@ -1859,7 +2225,8 @@ declare class OwnerRelay extends RelayLink {
|
|
|
1859
2225
|
}
|
|
1860
2226
|
declare class RelayMember extends RelayLink {
|
|
1861
2227
|
private relayAnnounced;
|
|
1862
|
-
private
|
|
2228
|
+
private relayMemoCache;
|
|
2229
|
+
private readonly shapeControl;
|
|
1863
2230
|
constructor(host: RelayHost, ownerKey: string, relayIndex: number);
|
|
1864
2231
|
forwardWhisper(topic: string, frame: string): Promise<void>;
|
|
1865
2232
|
onFlush(): Promise<void>;
|
|
@@ -1869,17 +2236,81 @@ declare class RelayMember extends RelayLink {
|
|
|
1869
2236
|
}>;
|
|
1870
2237
|
announce(): Promise<void>;
|
|
1871
2238
|
announceDrain(closing: ShardSocketLike): Promise<void>;
|
|
2239
|
+
releaseRelayShapes(ws: ShardSocketLike, subId?: string): Promise<void>;
|
|
1872
2240
|
relayCount(): number;
|
|
1873
2241
|
isShapeRelayUniform(): boolean;
|
|
2242
|
+
minShapeCursor(): number | undefined;
|
|
1874
2243
|
protected onAttach(): void;
|
|
1875
2244
|
protected onDetach(): void;
|
|
1876
2245
|
protected onWhisperFrame(): Promise<void>;
|
|
1877
2246
|
protected onShapeSubscribe(): RelayShapeSeed;
|
|
1878
|
-
protected
|
|
2247
|
+
protected onShapeUnsubscribe(): void;
|
|
2248
|
+
protected onShapePoke(poke: RelayShapePoke): RelayPokeDelivery;
|
|
2249
|
+
private queueShapeControl;
|
|
2250
|
+
private relayMemos;
|
|
2251
|
+
private connectionMemos;
|
|
1879
2252
|
private recordRelayShapeMemo;
|
|
2253
|
+
private forgetRelayShapeMemos;
|
|
1880
2254
|
private deliverShapePoke;
|
|
2255
|
+
private pokeSocketShapes;
|
|
1881
2256
|
}
|
|
1882
2257
|
declare const createRelayLink: (host: RelayHost) => OwnerRelay | RelayMember | undefined;
|
|
2258
|
+
declare const REGION_HINTS: readonly ["wnam", "enam", "sam", "weur", "eeur", "apac", "apac-ne", "apac-se", "oc", "afr", "me"];
|
|
2259
|
+
type RegionHint = (typeof REGION_HINTS)[number];
|
|
2260
|
+
type ReplicaReadiness = "fresh" | "stale" | "unavailable";
|
|
2261
|
+
interface ShardSiblingHost {
|
|
2262
|
+
doName: () => string | undefined;
|
|
2263
|
+
env: () => unknown;
|
|
2264
|
+
shardBinding: () => string | undefined;
|
|
2265
|
+
shardJurisdiction: () => string | undefined;
|
|
2266
|
+
sql: () => SqlExec;
|
|
2267
|
+
}
|
|
2268
|
+
interface ReplicaOwnerHost extends ShardSiblingHost {
|
|
2269
|
+
exportRows: () => Promise<ExportRow[]>;
|
|
2270
|
+
ownerCursor: () => number | undefined;
|
|
2271
|
+
ownerEpoch: () => string | undefined;
|
|
2272
|
+
ownerFloor: () => number | undefined;
|
|
2273
|
+
readChanges: (sinceSeq: number, limit: number) => {
|
|
2274
|
+
changes: CdcChange[];
|
|
2275
|
+
cursor: number;
|
|
2276
|
+
};
|
|
2277
|
+
rowCount: () => number;
|
|
2278
|
+
}
|
|
2279
|
+
interface ReplicaFollowerHost extends ShardSiblingHost {
|
|
2280
|
+
applyChanges: (changes: ReadonlyArray<CdcChange>) => Promise<number>;
|
|
2281
|
+
importRows: (rows: ReadonlyArray<ExportRow>) => Promise<{
|
|
2282
|
+
errors: ReadonlyArray<unknown>;
|
|
2283
|
+
}>;
|
|
2284
|
+
}
|
|
2285
|
+
declare const handleReplicaControl: (host: ReplicaOwnerHost, request: Request) => Promise<Response>;
|
|
2286
|
+
declare class ShardReplica {
|
|
2287
|
+
private readonly host;
|
|
2288
|
+
readonly ownerKey: string;
|
|
2289
|
+
readonly region: RegionHint;
|
|
2290
|
+
private divergent;
|
|
2291
|
+
private inFlight;
|
|
2292
|
+
constructor(host: ReplicaFollowerHost, ownerKey: string, region: RegionHint);
|
|
2293
|
+
ensureFresh(minSeq?: number): Promise<ReplicaReadiness>;
|
|
2294
|
+
appliedSeq(): number;
|
|
2295
|
+
isDivergent(): boolean;
|
|
2296
|
+
private advance;
|
|
2297
|
+
private isCaughtUp;
|
|
2298
|
+
private catchUp;
|
|
2299
|
+
private applyPage;
|
|
2300
|
+
private hasDiverged;
|
|
2301
|
+
private bootstrap;
|
|
2302
|
+
private isFreshEnough;
|
|
2303
|
+
private pull;
|
|
2304
|
+
private request;
|
|
2305
|
+
}
|
|
2306
|
+
declare const createReplicaLink: (host: ReplicaFollowerHost) => ShardReplica | undefined;
|
|
2307
|
+
declare const gateReplicaDispatch: (replica: ShardReplica, request: Request, functionPath: string) => Promise<Response | undefined>;
|
|
2308
|
+
declare const REPROJECTION_MIGRATION_PREFIX = "__lunora_reproject__";
|
|
2309
|
+
declare const reprojectionMigrationId: (table: string) => string;
|
|
2310
|
+
declare const reprojectableFields: (definition: TableDefinitionLike) => string[];
|
|
2311
|
+
declare const reprojectionTables: (schema: SchemaLike) => string[];
|
|
2312
|
+
declare const countLegacyRows: (sql: SqlExec, table: string, fields: ReadonlyArray<string>) => number;
|
|
2313
|
+
declare const buildReprojectionMigration: (id: string, schema: SchemaLike, sql: SqlExec) => DataMigrationLike | undefined;
|
|
1883
2314
|
declare const RLS_UNWRAP_SYMBOL: symbol;
|
|
1884
2315
|
declare class RlsRequiredError extends LunoraError {
|
|
1885
2316
|
readonly table: string;
|
|
@@ -1896,7 +2327,7 @@ interface GuardableSchema {
|
|
|
1896
2327
|
}
|
|
1897
2328
|
type TableOfId = (id: string, expectedTable?: string) => Promise<string | undefined> | string | undefined;
|
|
1898
2329
|
type TablesOfIds = (ids: ReadonlyArray<string>, expectedTable?: string) => Promise<ReadonlyMap<string, string>> | ReadonlyMap<string, string>;
|
|
1899
|
-
declare const guardWriter: <W>(raw: W, schema: GuardableSchema, tableOfId: TableOfId, tablesOfIds?: TablesOfIds) => W;
|
|
2330
|
+
declare const guardWriter: <W>(raw: W, schema: GuardableSchema, tableOfId: TableOfId, tablesOfIds?: TablesOfIds, relationEdges?: ReadonlyArray<RelationEdge>) => W;
|
|
1900
2331
|
declare const SCHEMA_HISTORY_MAX_VERSIONS = 50;
|
|
1901
2332
|
interface SchemaVersionRow {
|
|
1902
2333
|
appliedAt: number;
|
|
@@ -1907,8 +2338,24 @@ interface SchemaVersionRow {
|
|
|
1907
2338
|
declare const recordSchemaVersion: (sql: SqlExec, hash: string, snapshotJson: string, now?: number) => boolean;
|
|
1908
2339
|
declare const readSchemaHistory: (sql: SqlExec) => SchemaVersionRow[];
|
|
1909
2340
|
declare const readSchemaVersion: (sql: SqlExec, hash: string) => SchemaVersionRow | undefined;
|
|
2341
|
+
declare const readDeployInfo: (rawEnv: unknown) => DeployInfo;
|
|
1910
2342
|
declare const isDevEnvironment: (rawEnv: unknown) => boolean;
|
|
1911
2343
|
declare const buildSettings: (rawEnv: unknown) => SettingsResult;
|
|
2344
|
+
declare class ShapeDiffCache {
|
|
2345
|
+
private readonly keyScans;
|
|
2346
|
+
private readonly memberProbes;
|
|
2347
|
+
private run;
|
|
2348
|
+
private served;
|
|
2349
|
+
get probesRun(): number;
|
|
2350
|
+
get probesServed(): number;
|
|
2351
|
+
changedKeys(rangeKey: string, load: () => CdcChangeKey[]): ReadonlyArray<CdcChangeKey>;
|
|
2352
|
+
members(resolved: ResolvedShape, rangeKey: string, load: () => Map<string, Record<string, unknown>>): ReadonlyMap<string, Record<string, unknown>>;
|
|
2353
|
+
private getOrLoad;
|
|
2354
|
+
}
|
|
2355
|
+
declare const createShapeDiffCache: () => ShapeDiffCache;
|
|
2356
|
+
declare const globalShapeReadKey: (resolved: ResolvedShape, identity: SubscriptionIdentity) => string | undefined;
|
|
2357
|
+
type ReadShapeCdcKeys = (sql: SqlExec, table: string, sinceSeq: number, upTo: number) => CdcChangeKey[];
|
|
2358
|
+
declare const buildShapeDiff: (sql: SqlExec, resolved: ResolvedShape, sinceSeq: number, upTo: number, cache: ShapeDiffCache, readKeys?: ReadShapeCdcKeys) => ShapeRowOp[];
|
|
1912
2359
|
interface ShardRunnerOptions {
|
|
1913
2360
|
handlers?: {
|
|
1914
2361
|
handleAlarm?: () => Promise<void>;
|
|
@@ -1924,7 +2371,7 @@ declare class ShardRunner {
|
|
|
1924
2371
|
socketFor(raw: unknown): ShardSocketLike;
|
|
1925
2372
|
sockets(tag?: string): SocketHandle[];
|
|
1926
2373
|
background(work: Promise<unknown>): boolean;
|
|
1927
|
-
runInTransaction<T>(work: () => Promise<T
|
|
2374
|
+
runInTransaction<T>(work: () => Promise<T>, onCommitted?: () => void): Promise<T>;
|
|
1928
2375
|
handleFetch(request: Request): Promise<Response>;
|
|
1929
2376
|
handleAlarm(): Promise<void>;
|
|
1930
2377
|
}
|
|
@@ -1950,6 +2397,11 @@ interface SqlDiagnostic {
|
|
|
1950
2397
|
source: "gate" | "plan" | "syntax";
|
|
1951
2398
|
}
|
|
1952
2399
|
declare const lintReadonlySql: (sql: SqlExec, query: string) => SqlLintResult;
|
|
2400
|
+
declare const BIGINT_KEY_DIGITS = 39;
|
|
2401
|
+
declare const bigintSqlKey: (value: bigint) => string;
|
|
2402
|
+
declare const decodeBigintSqlKey: (raw: string) => bigint | undefined;
|
|
2403
|
+
declare const float64SqlKey: (value: number) => string;
|
|
2404
|
+
declare const decodeFloat64SqlKey: (raw: string) => number | undefined;
|
|
1953
2405
|
declare const subscriptionListDeltas: (previousJson: string, nextResult: unknown, table: string, frames?: string[]) => MutationDelta[] | undefined;
|
|
1954
2406
|
interface FrameSink {
|
|
1955
2407
|
send: (data: string) => void;
|
|
@@ -1958,7 +2410,17 @@ interface DrainableSink {
|
|
|
1958
2410
|
readonly bufferedAmount?: unknown;
|
|
1959
2411
|
}
|
|
1960
2412
|
declare const trySendFrame: (ws: FrameSink, frame: string) => boolean;
|
|
1961
|
-
|
|
2413
|
+
interface SubscriptionFrameInput {
|
|
2414
|
+
cursorSuffix: string;
|
|
2415
|
+
lastMutationId?: number;
|
|
2416
|
+
nextResult: unknown;
|
|
2417
|
+
pageDeltas?: boolean;
|
|
2418
|
+
previousJson?: string;
|
|
2419
|
+
snapshotJson: string;
|
|
2420
|
+
subId: string;
|
|
2421
|
+
table: string;
|
|
2422
|
+
}
|
|
2423
|
+
declare const subscriptionFrames: (input: SubscriptionFrameInput) => string[];
|
|
1962
2424
|
declare const awaitWsDrain: (ws: DrainableSink) => Promise<void>;
|
|
1963
2425
|
interface SubscriptionReadFootprint {
|
|
1964
2426
|
ranges?: Map<string, KeyRange[]>;
|
|
@@ -1986,13 +2448,25 @@ declare const selectExpiredIds: (sql: SqlExec, spec: TtlSweepSpec, now: number,
|
|
|
1986
2448
|
hasMore: boolean;
|
|
1987
2449
|
ids: string[];
|
|
1988
2450
|
};
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
2451
|
+
interface WhereFragments<T> {
|
|
2452
|
+
binary: (reference: T, comparator: string, value: unknown) => T;
|
|
2453
|
+
connect: (left: T, right: T, connector: "AND" | "OR") => T;
|
|
2454
|
+
constant: (value: boolean) => T;
|
|
2455
|
+
contains: (reference: T, term: T) => T;
|
|
2456
|
+
inList: (reference: T, items: ReadonlyArray<unknown>, negated: boolean, budget: number) => T;
|
|
2457
|
+
negate: (inner: T) => T;
|
|
2458
|
+
nullCheck: (reference: T, negated: boolean) => T;
|
|
2459
|
+
value: (value: unknown) => T;
|
|
2460
|
+
}
|
|
2461
|
+
type FieldRefSql<T> = (field: string) => T;
|
|
2462
|
+
type SerializeValue = (value: unknown, field: string) => unknown;
|
|
2463
|
+
interface WhereSqlStrategy<T = SQL> {
|
|
2464
|
+
containsExpr?: (reference: T, term: T) => T;
|
|
2465
|
+
fieldRef: FieldRefSql<T>;
|
|
2466
|
+
inList?: (reference: T, items: ReadonlyArray<unknown>, negated: boolean, budget?: number) => T;
|
|
2467
|
+
relationExists?: (request: unknown) => T;
|
|
1995
2468
|
serialize: SerializeValue;
|
|
1996
2469
|
}
|
|
1997
|
-
declare const
|
|
1998
|
-
|
|
2470
|
+
declare const literalInList: (reference: SQL, items: ReadonlyArray<unknown>, negated: boolean) => SQL;
|
|
2471
|
+
declare const compileWhereSql: <T = SQL>(where: WhereInput | undefined, strategy: WhereSqlStrategy<T>, fragments?: WhereFragments<T>) => T | undefined;
|
|
2472
|
+
export { ADMIN_FUNCTIONS, ADMIN_FUNCTION_PREFIX, AGGREGATE_SQL_FUNCTION, AGG_COUNT, AGG_KEY, AGG_VALUE, AUDIT_LOG_TABLE, type AdvisorProcedure, type AdvisorProceduresResult, type AdvisoriesResult, type AdvisoryFinding, type AggregateIndexDefinitionLike, type AggregateOp, type AggregateOptions, type AggregateResult, type AggregateTally, type AppendAuditEntry, type ApplyOnDeleteOptions$1 as ApplyOnDeleteOptions, type AuditEntry, type AuditLogResult, BIGINT_KEY_DIGITS, type BroadcastDelta, CDC_LOG_TABLE, CDC_LOG_TABLE_SEQ_INDEX, CDC_META_TABLE, CLIENT_WATERMARK_TABLE, COMMIT_SEQ_FIELD, COMMIT_SEQ_TABLE, CURSOR_PREFIX, type CacheEntry, type CapturedMailRow, type CdcArchiveScope, type CdcChange, type CdcChangeKey, type ChangedKeys, type Clock, type ColumnMeta, type ColumnMetaLike, type CompanionSync, type CompanionSyncDeps, ConflictError, type ConflictKind, type CountArgs, CountRlsUnsupportedError, type CreateWorkflowInstanceResult, type CrossShardReadArgs, type CtxDbOptions, DATA_MIGRATION_STATE_TABLE, DEFAULT_FANOUT_TOPIC_LIMIT, DEFAULT_MAX_RELATION_KEYS, DEFAULT_MAX_RELAYS, DEFAULT_PROMOTION_THRESHOLDS, DEFAULT_TRANSACTION_LIMITS, DOC_COLUMN, type DataMigrationDocument, type DataMigrationLike, type DataMigrationTransform, type DatabaseWriterLike, type DependencyTracker, type DeployInfo, type DurableAttachDecision, type DurableStreamAttach, type DurableStreamRun, DurableStreamRunner, type DurableStreamSink, type ExportRow, type ExportShardAdminArgs, type ExportShardArgs, type ExternalSourceDiffResult, type ExternalSourceLike, FLAGS_FUNCTION_PREFIX, type FacetColumnOptions, type FacetColumnResult, type FacetValue, type FanOutBudget, type FanoutMetricsResult, type FanoutPathCounters, type FanoutTopicStat, type FieldOperators, type FilterClause, type FilterOperator, type FlagEvaluation, type FlagsResult, type FtsWriteOptions, type FunctionCallStat, type FunctionScanAttribution, type FunctionStatsResult, GEO_DEFAULT_PRECISION, GLOBAL_SHAPE_SNAPSHOT_TABLE, type GeoBoundingBox, type GeoFilterBuilderLike, type GeoIndexDefinitionLike, type GeoPoint, type GeoScoredDocument, type GlobalPollCounters, GlobalPollTick, type GroupByEntry, type GroupByOptions, type GuardableSchema$1 as GuardableSchema, IDEMPOTENCY_TABLE, type IdGenerator, type IdempotentRecord, type ImportError, type ImportShardAdminArgs, type ImportShardArgs, type ImportShardResult, type IncrementalMaterializeResult, type IndexDefinitionLike, type IndexKeyEntry, type IndexRangeBuilderLike, type KeyRange, type LifecycleDispatchInfo, type LifecycleEvent, MAIL_RETENTION, MAIL_TABLE, MAX_DURABLE_STREAM_BYTES, MAX_DURABLE_STREAM_CHUNKS, MAX_PAGE_SIZE, MAX_SQL_ROWS, type MaskColumnMetadata, type MaskPoliciesResult, type MaterializeResult, type MigrationDirection, type MigrationRunResult, type MigrationStatus, type MigrationStatusRow, type MutationDelta, type NestedWith, NotFoundError, NotUniqueError, type OnDeleteActionLike, type OrderByClause, type OrderByInput, type OrderKey, type OrderKeyConstraints, OwnerRelay, type OwnerRelayFrame, type PaginationOptions, type PitrBookmarkResult, type PitrRestoreArgs, type PitrRestoreResult, type PitrStorage, type PokeFrameMeta, type PromotionState, type PromotionThresholds, QUEUE_TABLE, type QueryArgs, type QueryPage, type QueueMessageOutcome, type QueueMessageRow, type QueueMetadata, type QueuesResult, RANK_TIEBREAK, REACTOR_STATE_TABLE, RELATED_DEFAULT_LIMIT, RELATED_DEPTH_DECAY, RELATED_MAX_DEPTH, RELATED_MAX_LIMIT, RELATION_EXISTS_KEY, RELATION_FUNCTION_PREFIX, REPROJECTION_MIGRATION_PREFIX, RLS_UNWRAP_SYMBOL, type RankBeforeOptions, type RankBeforeResult, type RankDirection, type RankIndexDefinitionLike, type RankOptions, type RankPage, type RankPageComputation, type RankPageDeps, type RankPageOptions, type RankPageRow, type RankPageRowKey, type RankResult, type RankSortKeyLike, ReactiveCache, type ReactiveCacheOptions, type ReactorDispatchResult, type ReactorMetadata, type ReactorState, type ReactorStats, type ReactorsResult, type ReadFootprint, type ReadHook, type ReadTablePageOptions, type RecordMailInput, type RecordQueueMessageInput, type RelatedDirection, type RelatedNode, type RelatedOptions, type RelatedPage, type RelatedStart, type RelatedStartReference, type RelationDefinitionLike, type RelationEdge, type RelationExistsMarker, type RelationGraphReader, type RelayAttach, type RelayDetach, type RelayFrame, type RelayHost, RelayMember, type RelayPokeDelivery, type RelayShapePoke, type RelayShapeSeed, type RelayShapeSubscribe, type RelayShapeUnsubscribe, type RenderedSql, type ReplicaFollowerHost, type ReplicaOwnerHost, type ReplicaReadiness, type ResolveRelationPredicatesOptions, type ResolveWithOptions, type ResolveWithResult, type ResolvedShape, type RestrictableQueryOptions, type RlsPoliciesResult, type RlsPolicyMetadata, RlsRequiredError, type RlsRoleMetadata, type RpcRequest, type RunDataMigrationOptions, type RunTriggersOptions, SCAN_DEP, SCHEDULE_OUTBOX_TABLE, SCHEMA_HISTORY_MAX_VERSIONS, SEARCH_STATE_TABLE, SHAPE_POKE_CURSOR_TABLE, type SchedulableWorkflowReferenceLike, type ScheduleOutbox, type ScheduleOutboxEnvelope, type ScheduleOutboxRow, type ScheduledFunctionDoc, type SchedulerLike, type SchemaLike, type ScoredDocument, type SearchBackfillProgress, type SearchFilterBuilderLike, type SearchIndexDefinitionLike, type SearchScoredDocument, type SelectMatchingIdsOptions, type ServerDefaultContextLike, type SettingEntry, type SettingKind, type SettingsResult, ShapeDiffCache, type ShapePokeCursorRow, type ShapePokePart, type ShapeProbeCounters, type ShapeRow, type ShapeRowOp, type ShapeSubscriptionQuery, type ShardRankPageResult, ShardRunner, type ShardRunnerOptions, type ShardSiblingHost, type ShardSocketLike, type SocketAttachment, type SortDirection, type SourceClientLike, type SourceCursorLike, type SourceRefresh, type SqlConsoleResult, type SqlCursor, type SqlEngine, type SqlExec, type SqlLintResult, type StorageMetadata, type StorageReference, type StorageReferenceResult, type StorageRuleMetadata, type StorageRulesResult, type StudioFeaturesResult, type SubscriptionConnection, type SubscriptionEnvelope, type SubscriptionIdentity, type SubscriptionInfo, type SubscriptionQuery, type SubscriptionReadFootprint, type SubscriptionsResult, type SystemDatabaseReader, type SystemDoc, type SystemQuery, type SystemReaderOptions, type SystemReaderSchedulerLike, type SystemReaderStorageLike, type SystemTableName, type TableColumnsResult, type TableDefinitionLike, type TableIndexInfo, type TableIndexesResult, type TableInfo, type TablePage, type TableReaderLike, type TablesColumnsResult, type TablesIndexesResult, type TransactionHeadroom, TransactionHeadroomTracker, type TransactionLimits, type TransactionSqlLike, type TriggerContextLike, type TriggerDefinitionLike, type TriggerEventLike, type TriggerOpLike, type TriggerTimingLike, type TtlSweepSpec, UNVOUCHABLE_DEP, type ValidatorLike, type WhereInput, type WhereSqlStrategy, type WithInput, type WorkflowInstanceState, type WorkflowInstanceStatusResult, type WorkflowMetadata, type WorkflowsResult, type WriteEvent, type WriteHook, advanceClientWatermark, aggUpsertSql, aggregateSqlFunction, aggregateTableName, allocateCommitSeq, appendAuditEntry, appendCdcChange, appendStreamChunk, applyCdcChanges, applyOnDelete, applySelect, archiveCdcSegment, armRestore, assertFlatPredicate, assertNoExplicitUndefined, assertReadonly, assertShapeShardable, assertValidClientId, awaitWsDrain, backfillAggregateIndexes, backfillRankIndexes, backfillSearchIndexes, backfillSearchIndexesForTable, bigintSqlKey, boundingBoxCenter, boundingBoxGeohashes, buildIndexRange, buildPokeFrames, buildReprojectionMigration, buildSeekBeforeWhere, buildSeekWhere, buildSettings, buildShapeDiff, bumpCdcEpoch, cdcArchiveRewound, cdcCanVouchFor, cdcForkedError, cdcSeqLeavingRows, cdcTouchesTables, cdcTrimmedError, claimStreamRun, clampPromotionThresholds, clearCapturedMail, clearMemoryTables, clearQueueMessages, coerceAggregateNumber, compactCdcDocs, compileWhereSql, computeRankPage, containsRelationPredicate, countLegacyRows, coveringGeohashes, createCompanionSync, createDependencyTracker, createFanoutCounters, createGlobalPollCounters, createIndexSql, createReadFootprint, createRelayLink, createReplicaLink, createShapeDiffCache, createShapeProbeCounters, createShardCtxDb, createSystemReader, cursorBelowRetainedFloor, decideDurableAttach, decodeBigintSqlKey, decodeCursor, decodeFloat64SqlKey, deferScheduleOutbox, deleteGlobalShapeSnapshot, deleteGlobalShapeSnapshotsForConnection, deleteShapePokeCursor, deleteShapePokeCursorsForConnection, deleteStreamRun, depKey, deriveRelationEdges, diffExternalSource, diffGlobalMembership, distinctValues, encodeAggregateKey, encodeCursor, encodeGeohash, encodePartitionKey, encodeRowsPatch, ensureAuditTable, ensureMailTable, envOptionalPositiveInt, envPositiveInt, equalityPinnedFields, exportShardRows, facetColumn, fanOutScalarCounts, findRelated, findStorageReferences, finishStreamRun, float64SqlKey, foldAggregateTally, forgetScheduleOutbox, ftsCompanionDdl, ftsPurgeDocument, ftsRowidMapName, ftsUnmappedPage, ftsWriteDocument, gateReplicaDispatch, geoTableName, globalShapeReadKey, groupUnmappedRows, guardWriter, handleReplicaControl, hasTrigger, haversineMeters, importShardRows, indexKeysForRow, isDevEnvironment, isFtsAvailable, isLossyBody, isMemoryTable, isRelationPredicate, isSoftDeleted, isSourceDue, jsonPath, jsonPathSql, keysTouchRanges, liftSourceId, lintReadonlySql, listReactorStates, listTables, literalInList, markUnvouchableReads, matchesRankStaticWhere, matchesStaticWhere, materializeExternalRows, materializeExternalRowsIncremental, memoryTableNames, mergeChangedKeys, mergeWhere, migrateCdcLog, migrateCdcMeta, migrateClientWatermark, migrateCommitSeq, migrateDurableStreams, migrateGlobalShapeSnapshot, migrateIdempotency, migrateReactorState, migrateScheduleOutbox, migrateSearchState, migrateShapePokeCursor, minCdcReplayableSeq, minCdcSeq, minShapePokeCursor, nextPromotionState, normalizeCountArgument, normalizeIdStructurally, normalizeOrderKeys, normalizeSourceDocument, normalizeSourceValue, param, parkScheduleOutbox, parseExportShardArgs, parseImportShardArgs, planAggregateLookup, pointInBoundingBox, probeScheduleOutbox, projectColumns, pullExternalSourceIncrementalTick, pullExternalSourceTick, qualifiedJsonPath, qualifiedJsonPathSql, quoteIdentifier, rankKeyFromDocument as rankKeyFromDoc, rankPivotConditionSql, rankTableName, reactiveCacheKey, reactorNeedsRun, readAggregateValue, readArchivedCdcChanges, readAuditLog, readBookmark, readCapturedMail, readCdcArchivedThrough, readCdcChangeKeys, readCdcChanges, readCdcCursor, readCdcEpoch, readClientWatermark, readCommitSeq, readDeployInfo, readDueScheduleOutbox, readExternalSourceBaseline, readGlobalShapeSnapshot, readIdempotent, readMigrationStatus, readQueueMessageById, readQueueMessages, readReactorState, readSchemaHistory, readSchemaVersion, readSearchBackfillState, readShapePokeCursor, readStreamChunks, readStreamRun, readTablePage, recordCapturedMail, recordChangedKeys, recordFanoutPass, recordGlobalPollPass, recordQueueMessages, recordScheduleOutbox, recordSchemaVersion, recordShapeProbePass, relationHooks, relayCountFor, renderSql, reprojectableFields, reprojectionMigrationId, reprojectionTables, resolveRankPartition, resolveRankSeekTuple, resolveRelationPredicates, resolveWith, rowToDocument, runDataMigration, runDrizzle, runExternalSourceTick, runReadonlySql, runRowValidators, runShardMigrations, runSocketPool, runSql, runTriggers, selectExpiredIds, selectExportTables, selectIndexForAggregate, selectIndexForCount, selectIndexForGroupBy, selectMatchingIds, selectShapeMembers, selectShapeRows, serializeSqlValue, shapeRoutingKey, softDeleteScope, sortColumnName, sqliteInList, stableStringify, stableWireKey, stripReservedPatchFields, subscriptionFrames, subscriptionListDeltas, summarizeFanoutTopics, summarizeSubscriptions, tableColumns, tableFromDepKey, throwingScheduler, tiebreakDirectionFor, trimCdcChanges, trimIdempotent, trimScheduleOutbox, trimStreamRuns, tryRowToDocument, trySendFrame, unionAll, uniqueIndexFields, validateImportRow, writeCdcArchivedThrough, writeGlobalShapeSnapshot, writeIdempotent, writeReactorState, writeSearchBackfillState, writeShapePokeCursor, writeShapePokeCursors, writeTouchesMemo };
|