@lunora/shard-engine 1.0.0-alpha.13 → 1.0.0-alpha.131
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 +763 -158
- package/dist/index.d.ts +763 -158
- package/dist/index.mjs +1 -1
- package/dist/packem_shared/ADMIN_FUNCTIONS-B0QCN3HM.mjs +1 -0
- package/dist/packem_shared/AGGREGATE_SQL_FUNCTION-C_ZipS9R.mjs +1 -0
- package/dist/packem_shared/AGG_COUNT-CBe5drFS.mjs +1 -0
- package/dist/packem_shared/AUDIT_LOG_TABLE-CuIP7PJ0.mjs +8 -0
- package/dist/packem_shared/BIGINT_KEY_DIGITS-DE6yshOt.mjs +1 -0
- package/dist/packem_shared/CDC_LOG_TABLE-DsCz-DAV.mjs +18 -0
- package/dist/packem_shared/CLIENT_WATERMARK_TABLE-_CkdMnT2.mjs +7 -0
- package/dist/packem_shared/COMMIT_SEQ_FIELD-BcUO15fR.mjs +4 -0
- package/dist/packem_shared/CURSOR_PREFIX-6offuG6M.mjs +1 -0
- package/dist/packem_shared/CountRlsUnsupportedError-BvsDqfO2.mjs +1 -0
- package/dist/packem_shared/DATA_MIGRATION_STATE_TABLE-CmsAKy5V.mjs +31 -0
- package/dist/packem_shared/DEFAULT_MAX_RELATION_KEYS-BYfAkNAH.mjs +1 -0
- package/dist/packem_shared/DEFAULT_MAX_RELAYS-ZRhh4qpX.mjs +8 -0
- package/dist/packem_shared/DEFAULT_PROMOTION_THRESHOLDS-B3pRMuqb.mjs +1 -0
- package/dist/packem_shared/DEFAULT_TRANSACTION_LIMITS-Dmj5VBrV.mjs +1 -0
- package/dist/packem_shared/DurableStreamRunner-Dzge_ywD.mjs +1 -0
- package/dist/packem_shared/GEO_DEFAULT_PRECISION-CqpQZ-J_.mjs +1 -0
- package/dist/packem_shared/GLOBAL_SHAPE_SNAPSHOT_TABLE-Du0PbPdS.mjs +7 -0
- package/dist/packem_shared/GlobalPollTick-BNK4o-XT.mjs +1 -0
- package/dist/packem_shared/IDEMPOTENCY_TABLE-CymJf4r0.mjs +7 -0
- package/dist/packem_shared/MAIL_RETENTION-BP1GSXQ0.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-CNXsYOSU.mjs +1 -0
- package/dist/packem_shared/QUEUE_TABLE-jEc6-2wm.mjs +17 -0
- package/dist/packem_shared/RANK_TIEBREAK-D3ye2GsL.mjs +1 -0
- package/dist/packem_shared/REACTOR_STATE_TABLE-DHaBP_vb.mjs +28 -0
- package/dist/packem_shared/RELATED_DEFAULT_LIMIT-CVqN4JEu.mjs +1 -0
- package/dist/packem_shared/RELATION_EXISTS_KEY-wxgj6rSL.mjs +1 -0
- package/dist/packem_shared/REPROJECTION_MIGRATION_PREFIX-Czcb6_mO.mjs +1 -0
- package/dist/packem_shared/RLS_UNWRAP_SYMBOL-J1tiBtRj.mjs +1 -0
- package/dist/packem_shared/ReactiveCache-DHhhLJtN.mjs +1 -0
- package/dist/packem_shared/SCAN_DEP-D7qE3iUe.mjs +1 -0
- package/dist/packem_shared/SCHEDULE_OUTBOX_TABLE-C_Me442c.mjs +11 -0
- package/dist/packem_shared/SCHEMA_HISTORY_MAX_VERSIONS-SQVxBlum.mjs +6 -0
- package/dist/packem_shared/SEARCH_STATE_TABLE-BThmEiED.mjs +1 -0
- package/dist/packem_shared/SHAPE_POKE_CURSOR_TABLE-B6MXBH-p.mjs +8 -0
- package/dist/packem_shared/ShapeDiffCache-iNO-hUiy.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/VECTOR_BACKFILL_MAX_PAGES-DY_3FYts.mjs +1 -0
- package/dist/packem_shared/WORKERD_SQLITE_LIMITS-BdNnnMj0.mjs +1 -0
- package/dist/packem_shared/accepts-null-D1zmJbyR.mjs +1 -0
- package/dist/packem_shared/aggregateTableName-B_CtIQCS.mjs +1 -0
- package/dist/packem_shared/appendStreamChunk-DF_Jrgpy.mjs +17 -0
- package/dist/packem_shared/applyOnDelete-BwxDC4lU.mjs +1 -0
- package/dist/packem_shared/archiveCdcSegment-CIiYU1FU.mjs +4 -0
- package/dist/packem_shared/{armRestore-BNzdvQ_o.mjs → armRestore-Bu1_8SUa.mjs} +1 -1
- package/dist/packem_shared/assertPatchAllowed-CA_H466g.mjs +1 -0
- package/dist/packem_shared/awaitWsDrain-N-oR29RI.mjs +1 -0
- package/dist/packem_shared/backfillAggregateIndexes-Dw4Azd33.mjs +1 -0
- package/dist/packem_shared/buildIndexRange-DQ3eWAGd.mjs +1 -0
- package/dist/packem_shared/buildPokeFrames-WR-hp0mX.mjs +1 -0
- package/dist/packem_shared/buildReprojectionMigration-DQV0q3w9.mjs +1 -0
- package/dist/packem_shared/buildSettings-BRkZd6_E.mjs +1 -0
- package/dist/packem_shared/buildShapeDiff-BHr3i1m6.mjs +1 -0
- package/dist/packem_shared/clearCompanionSignatures-8uVX84aT.mjs +1 -0
- package/dist/packem_shared/clearMemoryTables-Lu0S2GOb.mjs +1 -0
- package/dist/packem_shared/compileWhereSql-CKoO19by.mjs +1 -0
- package/dist/packem_shared/computeRankPage-DLSi_oBt.mjs +1 -0
- package/dist/packem_shared/createCompanionSync-DhYLePyV.mjs +1 -0
- package/dist/packem_shared/createReplicaLink-Bd7jCjDt.mjs +7 -0
- package/dist/packem_shared/createSystemReader-DcDLFfC-.mjs +1 -0
- package/dist/packem_shared/ctx-db-relay-shapes-CPwELrMf.mjs +17 -0
- package/dist/packem_shared/ctx-db-search-state-CrTLPmFN.mjs +1 -0
- package/dist/packem_shared/defineEngineContractSuite-DdD3QXbx.mjs +1 -0
- package/dist/packem_shared/describeRelationWrites-omar6-u9.mjs +1 -0
- package/dist/packem_shared/diffExternalSource-B0FZlDoL.mjs +1 -0
- package/dist/packem_shared/do-sql-DqU-17Fs.mjs +1 -0
- package/dist/packem_shared/effective-kind-BmG_zCAy.mjs +1 -0
- package/dist/packem_shared/envOptionalPositiveInt-D2pY-c64.mjs +1 -0
- package/dist/packem_shared/estimate-bytes-_k74s6LZ.mjs +1 -0
- package/dist/packem_shared/exportShardRows-yxw7vFf9.mjs +1 -0
- package/dist/packem_shared/fts-companion-DzfEHonU.mjs +1 -0
- package/dist/packem_shared/ftsCompanionDdl-Cka6_-Fm.mjs +1 -0
- package/dist/packem_shared/hasTrigger-CjlwI4le.mjs +1 -0
- package/dist/packem_shared/isInternalTableName-BoljO2tP.mjs +1 -0
- package/dist/packem_shared/isPushableWhere-BeYAOjUb.mjs +1 -0
- package/dist/packem_shared/isSoftDeleted-D5MeQSk0.mjs +9 -0
- package/dist/packem_shared/json-field-path-DeJW4U9z.mjs +1 -0
- package/dist/packem_shared/liftSourceId-CA3ENhXj.mjs +1 -0
- package/dist/packem_shared/materializeExternalRows-D2zEvCAa.mjs +1 -0
- package/dist/packem_shared/mergeChangedKeys-CF2mjYuy.mjs +1 -0
- package/dist/packem_shared/relation-operators-BEg-CvCH.mjs +1 -0
- package/dist/packem_shared/runDrizzle-B2GG3IJa.mjs +1 -0
- package/dist/packem_shared/runShardMigrations-BeqUbznb.mjs +5 -0
- package/dist/packem_shared/runSocketPool-CZJ2X9cF.mjs +1 -0
- package/dist/packem_shared/selectExpiredIds-B8PxwbIr.mjs +1 -0
- package/dist/packem_shared/selectShapeMembers-B1MIaRkE.mjs +1 -0
- package/dist/packem_shared/serializeSqlValue-DeoBMpZ2.mjs +1 -0
- package/dist/packem_shared/stubByName-C_P73AOx.mjs +1 -0
- package/dist/packem_shared/where-sql-DO1vOrhc.mjs +1 -0
- package/package.json +5 -4
- package/dist/packem_shared/ADMIN_FUNCTIONS-xKxYOiRC.mjs +0 -1
- package/dist/packem_shared/AGGREGATE_SQL_FUNCTION-CTo0-9iZ.mjs +0 -1
- package/dist/packem_shared/AGG_COUNT-B0Pb1nQZ.mjs +0 -1
- package/dist/packem_shared/AUDIT_LOG_TABLE-C6nwXFPd.mjs +0 -8
- package/dist/packem_shared/CDC_LOG_TABLE-D__2M4gX.mjs +0 -8
- package/dist/packem_shared/CLIENT_WATERMARK_TABLE-CzApRlyv.mjs +0 -7
- package/dist/packem_shared/CountRlsUnsupportedError-8BqPYQoP.mjs +0 -1
- package/dist/packem_shared/DATA_MIGRATION_STATE_TABLE-BrpAGtXf.mjs +0 -31
- package/dist/packem_shared/DEFAULT_MAX_RELATION_KEYS-C7Iky4H5.mjs +0 -1
- package/dist/packem_shared/DEFAULT_MAX_RELAYS-AcHLNxha.mjs +0 -1
- package/dist/packem_shared/DEFAULT_PROMOTION_THRESHOLDS-BdmnUGLO.mjs +0 -1
- package/dist/packem_shared/DEFAULT_TRANSACTION_LIMITS-BH5q0Ror.mjs +0 -1
- package/dist/packem_shared/GEO_DEFAULT_PRECISION-DyI5zggj.mjs +0 -1
- package/dist/packem_shared/GLOBAL_SHAPE_SNAPSHOT_TABLE-soMJDSBs.mjs +0 -7
- package/dist/packem_shared/IDEMPOTENCY_TABLE-Bvu9JkiL.mjs +0 -7
- package/dist/packem_shared/MAIL_RETENTION-BefR9Sei.mjs +0 -18
- package/dist/packem_shared/MAX_SQL_ROWS-nMwkxv5f.mjs +0 -2
- package/dist/packem_shared/NotUniqueError-GHJiYnzm.mjs +0 -1
- package/dist/packem_shared/QUEUE_TABLE-DgBqWrXX.mjs +0 -17
- package/dist/packem_shared/RANK_TIEBREAK-D541BOFR.mjs +0 -1
- package/dist/packem_shared/RELATION_EXISTS_KEY-BaqSIFU1.mjs +0 -1
- package/dist/packem_shared/RLS_UNWRAP_SYMBOL-DcqORh2s.mjs +0 -1
- package/dist/packem_shared/ReactiveCache-iWA9VRqk.mjs +0 -1
- package/dist/packem_shared/SCAN_DEP-D_yR9EeV.mjs +0 -1
- package/dist/packem_shared/SCHEMA_HISTORY_MAX_VERSIONS-BEU0CuW5.mjs +0 -6
- package/dist/packem_shared/SEARCH_STATE_TABLE-BZ_fxI5l.mjs +0 -1
- package/dist/packem_shared/ShardRunner-DIqVdWtk.mjs +0 -1
- package/dist/packem_shared/aggregateTableName-DKo6dwBP.mjs +0 -1
- package/dist/packem_shared/applyOnDelete-CxpItW0j.mjs +0 -1
- package/dist/packem_shared/applySelect-BjgwvZmI.mjs +0 -1
- package/dist/packem_shared/awaitWsDrain-DKycCSBS.mjs +0 -1
- package/dist/packem_shared/backfillAggregateIndexes-BVNrfFcI.mjs +0 -1
- package/dist/packem_shared/buildIndexRange-DFsdtPjD.mjs +0 -1
- package/dist/packem_shared/buildPokeFrames-CCxYXd2V.mjs +0 -1
- package/dist/packem_shared/buildSettings-COIJsw7a.mjs +0 -1
- package/dist/packem_shared/compileWhereSql-B4rPariq.mjs +0 -1
- package/dist/packem_shared/computeRankPage-B7U6t1fW.mjs +0 -1
- package/dist/packem_shared/createCompanionSync-Dym8huD9.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/ctx-db-companions-7fIu-E2H.mjs +0 -1
- package/dist/packem_shared/defineEngineContractSuite-Zg5xN9h4.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-Bbi_JGfn.mjs +0 -1
- package/dist/packem_shared/hasTrigger-CbkOHExZ.mjs +0 -1
- package/dist/packem_shared/isSoftDeleted-doD_8AwX.mjs +0 -9
- package/dist/packem_shared/liftSourceId-DApAbu7Q.mjs +0 -1
- package/dist/packem_shared/materializeExternalRows-BR8MvZTz.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/runDrizzle-B6rnz3so.mjs +0 -1
- package/dist/packem_shared/runShardMigrations-DhZLG0bn.mjs +0 -5
- package/dist/packem_shared/runSocketPool-DPQLVyWF.mjs +0 -1
- package/dist/packem_shared/selectExpiredIds-DxFEwNlT.mjs +0 -1
- package/dist/packem_shared/selectShapeMemberIds-BD3JiZn-.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-C4JfdJ_e.mjs +0 -1
- package/dist/packem_shared/wire-codec-D_fiax9d.mjs +0 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
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
|
-
|
|
4
|
+
export { stableStringify, stableWireKey } from '@lunora/wire';
|
|
4
5
|
interface KeyRange {
|
|
5
6
|
hi: string;
|
|
6
7
|
index: string;
|
|
@@ -22,15 +23,43 @@ declare const indexKeysForRow: (indexes: ReadonlyArray<{
|
|
|
22
23
|
name: string;
|
|
23
24
|
}>, row: Record<string, unknown>, serialize: (value: unknown) => unknown) => IndexKeyEntry[];
|
|
24
25
|
declare const keysTouchRanges: (ranges: ReadonlyArray<KeyRange> | undefined, keys: ReadonlyArray<IndexKeyEntry> | undefined) => boolean;
|
|
26
|
+
interface RelationWriteBase {
|
|
27
|
+
readonly colocated: boolean;
|
|
28
|
+
readonly refusal?: string;
|
|
29
|
+
readonly table: string;
|
|
30
|
+
}
|
|
31
|
+
interface KeyedRelationWriteInfo extends RelationWriteBase {
|
|
32
|
+
readonly field: string;
|
|
33
|
+
readonly kind: "many" | "one";
|
|
34
|
+
readonly nullable: boolean;
|
|
35
|
+
readonly references: string;
|
|
36
|
+
readonly refusalNow?: never;
|
|
37
|
+
readonly through?: never;
|
|
38
|
+
}
|
|
39
|
+
interface ThroughRelationWriteInfo extends RelationWriteBase {
|
|
40
|
+
readonly kind: "many";
|
|
41
|
+
readonly pairIsOnlyUnique: boolean;
|
|
42
|
+
readonly refusalNow: () => string | undefined;
|
|
43
|
+
readonly through: {
|
|
44
|
+
readonly from: string;
|
|
45
|
+
readonly table: string;
|
|
46
|
+
readonly to: string;
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
type RelationWriteInfo = KeyedRelationWriteInfo | ThroughRelationWriteInfo;
|
|
50
|
+
type RelationWriteMap = Readonly<Record<string, Readonly<Record<string, RelationWriteInfo>>>>;
|
|
51
|
+
declare const describeRelationWrites: (schema: SchemaLike, inTransaction?: () => boolean) => RelationWriteMap;
|
|
25
52
|
type SystemTableName = "_scheduled_functions" | "_storage";
|
|
26
53
|
interface ScheduledFunctionDoc {
|
|
27
54
|
args: Record<string, unknown>;
|
|
28
55
|
attempts?: number;
|
|
29
56
|
enqueuedAt: number;
|
|
30
|
-
functionPath
|
|
57
|
+
functionPath?: string;
|
|
31
58
|
id: string;
|
|
59
|
+
pool?: string;
|
|
32
60
|
scheduledFor: number;
|
|
33
61
|
shardKey?: string;
|
|
62
|
+
workflow?: string;
|
|
34
63
|
}
|
|
35
64
|
interface StorageMetadata {
|
|
36
65
|
contentType?: string;
|
|
@@ -86,6 +115,75 @@ interface WhereInput {
|
|
|
86
115
|
OR?: WhereInput[];
|
|
87
116
|
}
|
|
88
117
|
declare const RELATION_EXISTS_KEY = "__relationExists";
|
|
118
|
+
interface SubscriptionQuery {
|
|
119
|
+
args?: Record<string, unknown>;
|
|
120
|
+
functionPath?: string;
|
|
121
|
+
sinceEpoch?: string;
|
|
122
|
+
sinceSeq?: number;
|
|
123
|
+
table?: string;
|
|
124
|
+
}
|
|
125
|
+
interface ShapeSubscriptionQuery {
|
|
126
|
+
args?: Record<string, unknown>;
|
|
127
|
+
name: string;
|
|
128
|
+
sinceEpoch?: string;
|
|
129
|
+
sinceSeq?: number;
|
|
130
|
+
}
|
|
131
|
+
interface SubscriptionEnvelope {
|
|
132
|
+
caps?: string[];
|
|
133
|
+
clientId?: string;
|
|
134
|
+
context?: Record<string, unknown>;
|
|
135
|
+
data?: unknown;
|
|
136
|
+
generation?: number;
|
|
137
|
+
id: string;
|
|
138
|
+
query?: SubscriptionQuery;
|
|
139
|
+
shape?: {
|
|
140
|
+
args?: Record<string, unknown>;
|
|
141
|
+
name: string;
|
|
142
|
+
};
|
|
143
|
+
sinceCheckpoint?: number;
|
|
144
|
+
sinceChunk?: number;
|
|
145
|
+
sinceEpoch?: string;
|
|
146
|
+
topic?: string;
|
|
147
|
+
type: "ack" | "connect" | "shape_subscribe" | "shape_unsubscribe" | "stream" | "subscribe" | "unsubscribe" | "whisper" | "whisper_subscribe" | "whisper_unsubscribe";
|
|
148
|
+
}
|
|
149
|
+
interface RpcRequest {
|
|
150
|
+
args?: Record<string, unknown>;
|
|
151
|
+
functionPath: string;
|
|
152
|
+
}
|
|
153
|
+
interface SocketAttachment {
|
|
154
|
+
admin?: boolean;
|
|
155
|
+
adminBinding?: string;
|
|
156
|
+
clientId?: string;
|
|
157
|
+
connected?: boolean;
|
|
158
|
+
connectionId?: string;
|
|
159
|
+
context?: Record<string, unknown>;
|
|
160
|
+
expiresAt?: number;
|
|
161
|
+
identity?: Record<string, unknown>;
|
|
162
|
+
ip?: string;
|
|
163
|
+
pageDeltas?: boolean;
|
|
164
|
+
shapes?: Record<string, ShapeSubscriptionQuery>;
|
|
165
|
+
subs: Record<string, SubscriptionQuery>;
|
|
166
|
+
userId?: string;
|
|
167
|
+
whispers?: string[];
|
|
168
|
+
}
|
|
169
|
+
interface ResolvedShape {
|
|
170
|
+
columns?: ReadonlyArray<string>;
|
|
171
|
+
effectiveWhere?: WhereInput;
|
|
172
|
+
global?: boolean;
|
|
173
|
+
table: string;
|
|
174
|
+
}
|
|
175
|
+
interface SubscriptionIdentity {
|
|
176
|
+
identity?: Record<string, unknown>;
|
|
177
|
+
ip?: string;
|
|
178
|
+
userId?: string;
|
|
179
|
+
}
|
|
180
|
+
interface ShardSocketLike {
|
|
181
|
+
readonly bufferedAmount?: number;
|
|
182
|
+
close?: (code?: number, reason?: string) => void;
|
|
183
|
+
deserializeAttachment?: () => unknown;
|
|
184
|
+
send: (data: string) => void;
|
|
185
|
+
serializeAttachment?: (value: unknown) => void;
|
|
186
|
+
}
|
|
89
187
|
type AggregateOp = "avg" | "count" | "max" | "min" | "sum";
|
|
90
188
|
interface AggregateIndexDefinitionLike {
|
|
91
189
|
readonly by?: ReadonlyArray<string>;
|
|
@@ -137,6 +235,11 @@ interface ColumnMetaLike {
|
|
|
137
235
|
interface ValidatorLike {
|
|
138
236
|
readonly _meta?: {
|
|
139
237
|
readonly column?: ColumnMetaLike;
|
|
238
|
+
readonly inner?: ValidatorLike;
|
|
239
|
+
readonly members?: ReadonlyArray<ValidatorLike>;
|
|
240
|
+
readonly shape?: Readonly<Record<string, ValidatorLike>>;
|
|
241
|
+
readonly tableName?: string;
|
|
242
|
+
readonly value?: unknown;
|
|
140
243
|
};
|
|
141
244
|
readonly kind?: string;
|
|
142
245
|
readonly parse?: (value: unknown) => unknown;
|
|
@@ -144,7 +247,7 @@ interface ValidatorLike {
|
|
|
144
247
|
type TriggerTimingLike = "after" | "before";
|
|
145
248
|
type TriggerOpLike = "delete" | "insert" | "update";
|
|
146
249
|
interface SchedulableWorkflowReferenceLike {
|
|
147
|
-
readonly
|
|
250
|
+
readonly className?: string;
|
|
148
251
|
readonly isLunoraWorkflow: true;
|
|
149
252
|
readonly name?: string;
|
|
150
253
|
}
|
|
@@ -178,11 +281,18 @@ interface SchemaLike {
|
|
|
178
281
|
readonly rlsMode?: "required";
|
|
179
282
|
readonly tables: Record<string, TableDefinitionLike>;
|
|
180
283
|
}
|
|
284
|
+
type PatchVerifier = (previous: Record<string, unknown>, next: Record<string, unknown>) => boolean;
|
|
285
|
+
interface PatchWriteOptions {
|
|
286
|
+
verify?: PatchVerifier;
|
|
287
|
+
}
|
|
181
288
|
interface TableDefinitionLike {
|
|
182
289
|
readonly aggregateIndexes?: ReadonlyArray<AggregateIndexDefinitionLike>;
|
|
290
|
+
readonly commitOrderedMode?: boolean;
|
|
291
|
+
readonly dropStalePatchesMode?: boolean;
|
|
183
292
|
readonly geoIndexes?: ReadonlyArray<GeoIndexDefinitionLike>;
|
|
184
293
|
readonly indexes: ReadonlyArray<IndexDefinitionLike>;
|
|
185
294
|
readonly isPublic?: boolean;
|
|
295
|
+
readonly memoryMode?: boolean;
|
|
186
296
|
readonly rankIndexes?: ReadonlyArray<RankIndexDefinitionLike>;
|
|
187
297
|
readonly relationMap?: Record<string, RelationDefinitionLike>;
|
|
188
298
|
readonly searchIndexes?: ReadonlyArray<SearchIndexDefinitionLike>;
|
|
@@ -200,13 +310,25 @@ interface TableDefinitionLike {
|
|
|
200
310
|
field: string;
|
|
201
311
|
};
|
|
202
312
|
}
|
|
203
|
-
interface
|
|
313
|
+
interface KeyedRelationDefinitionLike {
|
|
204
314
|
readonly field: string;
|
|
205
315
|
readonly kind: "many" | "one";
|
|
206
316
|
readonly onDelete?: OnDeleteActionLike;
|
|
207
317
|
readonly references: string;
|
|
208
318
|
readonly table: string;
|
|
319
|
+
readonly through?: never;
|
|
320
|
+
}
|
|
321
|
+
interface RelationThroughLike {
|
|
322
|
+
readonly from: string;
|
|
323
|
+
readonly table: string;
|
|
324
|
+
readonly to: string;
|
|
325
|
+
}
|
|
326
|
+
interface ThroughRelationDefinitionLike {
|
|
327
|
+
readonly kind: "many";
|
|
328
|
+
readonly table: string;
|
|
329
|
+
readonly through: RelationThroughLike;
|
|
209
330
|
}
|
|
331
|
+
type RelationDefinitionLike = KeyedRelationDefinitionLike | ThroughRelationDefinitionLike;
|
|
210
332
|
type OnDeleteActionLike = "cascade" | "restrict" | "set null";
|
|
211
333
|
interface NestedWith {
|
|
212
334
|
limit?: number;
|
|
@@ -219,17 +341,16 @@ interface WithInput {
|
|
|
219
341
|
[relationName: string]: NestedWith | Record<string, true> | boolean | undefined;
|
|
220
342
|
_count?: Record<string, true>;
|
|
221
343
|
}
|
|
222
|
-
interface
|
|
223
|
-
|
|
224
|
-
relation: RelationDefinitionLike;
|
|
225
|
-
row: Record<string, unknown>;
|
|
226
|
-
tableName: string;
|
|
344
|
+
interface FanOutBudget {
|
|
345
|
+
remaining: number;
|
|
227
346
|
}
|
|
228
347
|
interface ResolveWithOptions {
|
|
348
|
+
fanOutBudget?: FanOutBudget;
|
|
229
349
|
fetcher: (tableName: string, args: QueryArgs) => Promise<QueryPage>;
|
|
230
350
|
groupedCounter: (tableName: string, whereField: string, values: unknown[], policyWhere?: WhereInput) => Promise<Map<unknown, number>>;
|
|
231
351
|
parents: Record<string, unknown>[];
|
|
232
352
|
relationBaseWhere?: (table: string) => undefined | WhereInput;
|
|
353
|
+
relationMask?: RelationMask;
|
|
233
354
|
schema: {
|
|
234
355
|
readonly tables: Record<string, TableDefinitionLike>;
|
|
235
356
|
};
|
|
@@ -242,28 +363,85 @@ interface ResolveWithResult {
|
|
|
242
363
|
rows: Record<string, unknown>[];
|
|
243
364
|
}
|
|
244
365
|
type SortDirection = "asc" | "desc";
|
|
245
|
-
type
|
|
366
|
+
type NullPlacement = "first" | "last";
|
|
367
|
+
type OrderByInput = Record<string, SortDirection | {
|
|
368
|
+
nulls: NullPlacement;
|
|
369
|
+
sort: SortDirection;
|
|
370
|
+
}>;
|
|
246
371
|
interface QueryArgs {
|
|
247
372
|
baseWhere?: WhereInput;
|
|
248
373
|
cursor?: null | string;
|
|
249
374
|
includeDeleted?: boolean;
|
|
250
375
|
limit?: number;
|
|
376
|
+
omitContinueCursor?: boolean;
|
|
251
377
|
orderBy?: OrderByInput[];
|
|
252
378
|
relationBaseWhere?: (table: string) => undefined | WhereInput;
|
|
379
|
+
relationMask?: RelationMask;
|
|
253
380
|
restrictsCounts?: boolean;
|
|
254
381
|
select?: ReadonlyArray<string>;
|
|
255
382
|
where?: WhereInput;
|
|
256
383
|
with?: WithInput;
|
|
257
384
|
}
|
|
385
|
+
interface CrossShardReadArgs {
|
|
386
|
+
orderBy?: OrderByInput[];
|
|
387
|
+
relationPolicies?: Record<string, WhereInput>;
|
|
388
|
+
where?: WhereInput;
|
|
389
|
+
with?: WithInput;
|
|
390
|
+
}
|
|
391
|
+
type RelationMask = (table: string, rows: Record<string, unknown>[]) => Record<string, unknown>[];
|
|
392
|
+
interface QueryPlan {
|
|
393
|
+
params: unknown[];
|
|
394
|
+
plan: string[];
|
|
395
|
+
sql: string;
|
|
396
|
+
}
|
|
258
397
|
interface QueryPage {
|
|
259
398
|
continueCursor: null | string;
|
|
260
399
|
isDone: boolean;
|
|
261
400
|
page: Record<string, unknown>[];
|
|
262
401
|
splitCursor?: null | string;
|
|
263
402
|
}
|
|
403
|
+
interface RelationEdge {
|
|
404
|
+
readonly array: boolean;
|
|
405
|
+
readonly column: string;
|
|
406
|
+
readonly name: string;
|
|
407
|
+
readonly sourceTable: string;
|
|
408
|
+
readonly targetTable: string;
|
|
409
|
+
}
|
|
410
|
+
interface RelatedStartReference {
|
|
411
|
+
id: string;
|
|
412
|
+
table: string;
|
|
413
|
+
}
|
|
414
|
+
type RelatedStart = (Record<string, unknown> & {
|
|
415
|
+
_id: string;
|
|
416
|
+
}) | RelatedStartReference;
|
|
417
|
+
type RelatedDirection = "both" | "in" | "out";
|
|
418
|
+
interface RelatedOptions {
|
|
419
|
+
cursor?: null | string;
|
|
420
|
+
depth?: number;
|
|
421
|
+
direction?: RelatedDirection;
|
|
422
|
+
edges?: ReadonlyArray<string>;
|
|
423
|
+
limit?: number;
|
|
424
|
+
relationBaseWhere?: (table: string) => undefined | WhereInput;
|
|
425
|
+
relationMask?: RelationMask;
|
|
426
|
+
}
|
|
427
|
+
interface RelatedNode {
|
|
428
|
+
depth: number;
|
|
429
|
+
document: Record<string, unknown>;
|
|
430
|
+
path: ReadonlyArray<string>;
|
|
431
|
+
pathIds: ReadonlyArray<string>;
|
|
432
|
+
score: number;
|
|
433
|
+
table: string;
|
|
434
|
+
}
|
|
435
|
+
interface RelatedPage {
|
|
436
|
+
continueCursor: null | string;
|
|
437
|
+
isDone: boolean;
|
|
438
|
+
nodes: RelatedNode[];
|
|
439
|
+
}
|
|
264
440
|
interface OrderKey {
|
|
265
441
|
direction: SortDirection;
|
|
266
442
|
field: string;
|
|
443
|
+
nullable: boolean;
|
|
444
|
+
nulls?: NullPlacement;
|
|
267
445
|
}
|
|
268
446
|
interface RestrictableQueryOptions {
|
|
269
447
|
baseWhere?: WhereInput;
|
|
@@ -399,10 +577,8 @@ interface LifecycleEvent {
|
|
|
399
577
|
shardKey: string;
|
|
400
578
|
userId: string | null;
|
|
401
579
|
}
|
|
402
|
-
interface LifecycleDispatchInfo {
|
|
580
|
+
interface LifecycleDispatchInfo extends SubscriptionIdentity {
|
|
403
581
|
event: LifecycleEvent;
|
|
404
|
-
identity: Record<string, unknown> | undefined;
|
|
405
|
-
userId: string | undefined;
|
|
406
582
|
}
|
|
407
583
|
interface MutationDelta {
|
|
408
584
|
indexKeys?: ReadonlyArray<IndexKeyEntry>;
|
|
@@ -414,6 +590,14 @@ interface MutationDelta {
|
|
|
414
590
|
interface DatabaseWriterLike {
|
|
415
591
|
aggregate: (tableName: string, options: AggregateOptions) => Promise<AggregateResult>;
|
|
416
592
|
asId?: (tableName: string, id: string) => string;
|
|
593
|
+
assertPatchAllowed?: (id: string, expectedTable?: string) => Promise<void>;
|
|
594
|
+
cdcChangedTables?: (sinceSeq: number, options?: {
|
|
595
|
+
cursorOnly?: boolean;
|
|
596
|
+
}) => Promise<{
|
|
597
|
+
cursor: number;
|
|
598
|
+
floor?: number;
|
|
599
|
+
tables: string[];
|
|
600
|
+
} | undefined>;
|
|
417
601
|
count: (tableName: string, where?: RestrictableQueryOptions | WhereInput) => Promise<number>;
|
|
418
602
|
delete: (id: string, expectedTable?: string, options?: {
|
|
419
603
|
hard?: boolean;
|
|
@@ -429,11 +613,13 @@ interface DatabaseWriterLike {
|
|
|
429
613
|
}, expectedTable?: string) => Promise<{
|
|
430
614
|
deleted: number;
|
|
431
615
|
}>;
|
|
616
|
+
deleteRereadTables?: ReadonlySet<string>;
|
|
432
617
|
deleteWhere?: (tableName: string, where: WhereInput, options?: {
|
|
433
618
|
limit?: number;
|
|
434
619
|
}) => Promise<{
|
|
435
620
|
deleted: number;
|
|
436
621
|
}>;
|
|
622
|
+
explain: (tableName: string, args?: QueryArgs) => Promise<QueryPlan>;
|
|
437
623
|
findFirst: (tableName: string, args?: QueryArgs) => Promise<Record<string, unknown> | null>;
|
|
438
624
|
findFirstOrThrow: (tableName: string, args?: QueryArgs) => Promise<Record<string, unknown>>;
|
|
439
625
|
findMany: (tableName: string, args?: QueryArgs) => Promise<QueryPage>;
|
|
@@ -451,12 +637,21 @@ interface DatabaseWriterLike {
|
|
|
451
637
|
allowExplicitId?: boolean;
|
|
452
638
|
limit?: number;
|
|
453
639
|
}) => Promise<string[]>;
|
|
640
|
+
inTransaction?: () => boolean;
|
|
454
641
|
lookupById?: (id: string, expectedTable?: string) => Promise<null | {
|
|
455
642
|
row: Record<string, unknown>;
|
|
456
643
|
tableName: string;
|
|
457
644
|
}>;
|
|
458
645
|
normalizeId: (tableName: string, id: string) => null | string;
|
|
459
|
-
patch: (id: string, patch: Record<string, unknown>, expectedTable?: string) => Promise<void>;
|
|
646
|
+
patch: (id: string, patch: Record<string, unknown>, expectedTable?: string, options?: PatchWriteOptions) => Promise<void>;
|
|
647
|
+
patchIf?: (tableName: string, id: string, args: {
|
|
648
|
+
patch: Record<string, unknown>;
|
|
649
|
+
verify?: PatchVerifier;
|
|
650
|
+
where: WhereInput;
|
|
651
|
+
}) => Promise<{
|
|
652
|
+
applied: boolean;
|
|
653
|
+
doc: Record<string, unknown> | null;
|
|
654
|
+
}>;
|
|
460
655
|
patchMany?: (patches: ReadonlyArray<{
|
|
461
656
|
id: string;
|
|
462
657
|
patch: Record<string, unknown>;
|
|
@@ -478,10 +673,14 @@ interface DatabaseWriterLike {
|
|
|
478
673
|
rankBefore?: (tableName: string, indexName: string, options: RankBeforeOptions) => Promise<RankBeforeResult>;
|
|
479
674
|
rankPage: (tableName: string, indexName: string, options?: RankPageOptions) => Promise<RankPage>;
|
|
480
675
|
rankPageRows?: (tableName: string, indexName: string, options?: RankPageOptions) => Promise<ShardRankPageResult>;
|
|
676
|
+
related?: (start: RelatedStart, options?: RelatedOptions) => Promise<RelatedPage>;
|
|
677
|
+
relationEdges?: ReadonlyArray<RelationEdge>;
|
|
678
|
+
relationWrites?: RelationWriteMap;
|
|
481
679
|
replace: (id: string, document: Record<string, unknown>, expectedTable?: string, options?: {
|
|
482
680
|
allowExplicitId?: boolean;
|
|
483
681
|
}) => Promise<void>;
|
|
484
682
|
restore?: (id: string, expectedTable?: string) => Promise<void>;
|
|
683
|
+
softDeleteFields?: ReadonlyMap<string, string>;
|
|
485
684
|
system?: SystemDatabaseReader;
|
|
486
685
|
wipeShard?: (options?: {
|
|
487
686
|
chunkSize?: number;
|
|
@@ -516,7 +715,6 @@ interface ImportShardResult {
|
|
|
516
715
|
inserted: Record<string, number>;
|
|
517
716
|
}
|
|
518
717
|
declare const selectExportTables: (schema: SchemaLike, requested?: ReadonlyArray<string>) => string[];
|
|
519
|
-
declare const exportShardTable: (writer: DatabaseWriterLike, table: string, batchSize?: number) => AsyncGenerator<ExportRow, void, undefined>;
|
|
520
718
|
declare const exportShardRows: (writer: DatabaseWriterLike, schema: SchemaLike, args: ExportShardArgs) => AsyncGenerator<ExportRow, void, undefined>;
|
|
521
719
|
declare const validateImportRow: (schema: SchemaLike, table: string, record: Record<string, unknown>) => string | undefined;
|
|
522
720
|
declare const importShardRows: (writer: DatabaseWriterLike, schema: SchemaLike, args: ImportShardArgs) => Promise<ImportShardResult>;
|
|
@@ -564,8 +762,6 @@ declare const selectIndexForGroupBy: (indexes: ReadonlyArray<AggregateIndexDefin
|
|
|
564
762
|
index: AggregateIndexDefinitionLike;
|
|
565
763
|
partial: Record<string, unknown>;
|
|
566
764
|
};
|
|
567
|
-
declare const stableStringify: (value: unknown) => string;
|
|
568
|
-
declare const stableWireKey: (value: unknown) => string;
|
|
569
765
|
interface CacheEntry {
|
|
570
766
|
bytes: number;
|
|
571
767
|
deps: Set<string>;
|
|
@@ -591,6 +787,7 @@ declare class ReactiveCache {
|
|
|
591
787
|
private readonly maxBytes;
|
|
592
788
|
private readonly now;
|
|
593
789
|
private monotonic;
|
|
790
|
+
private generation;
|
|
594
791
|
constructor(options?: ReactiveCacheOptions);
|
|
595
792
|
run<R>(key: string, deps: Set<string>, run: () => Promise<R>, ranges?: () => ReadonlyArray<KeyRange>): Promise<R>;
|
|
596
793
|
invalidate(table: string, id: string, indexKeys?: ReadonlyArray<IndexKeyEntry>): string[];
|
|
@@ -651,12 +848,18 @@ interface RunTriggersOptions {
|
|
|
651
848
|
}
|
|
652
849
|
declare const runTriggers: (options: RunTriggersOptions) => Promise<void>;
|
|
653
850
|
declare const hasTrigger: (schema: SchemaLike, tableName: string, op: TriggerOpLike) => boolean;
|
|
851
|
+
interface SearchBackfillProgress {
|
|
852
|
+
done: boolean;
|
|
853
|
+
pages: number;
|
|
854
|
+
}
|
|
654
855
|
declare const backfillAggregateIndexes: (sql: SqlExec, schema: SchemaLike) => void;
|
|
655
856
|
declare const backfillRankIndexes: (sql: SqlExec, schema: SchemaLike) => void;
|
|
656
857
|
declare const backfillSearchIndexesForTable: (sql: SqlExec, tableName: string, definition: {
|
|
657
858
|
searchIndexes?: ReadonlyArray<SearchIndexDefinitionLike>;
|
|
658
859
|
}) => void;
|
|
659
|
-
declare const backfillSearchIndexes: (sql: SqlExec, schema: SchemaLike
|
|
860
|
+
declare const backfillSearchIndexes: (sql: SqlExec, schema: SchemaLike, options?: {
|
|
861
|
+
maxPages?: number;
|
|
862
|
+
}) => SearchBackfillProgress;
|
|
660
863
|
declare const CDC_LOG_TABLE = "__cdc_log";
|
|
661
864
|
interface CdcChange {
|
|
662
865
|
doc?: Record<string, unknown>;
|
|
@@ -666,19 +869,35 @@ interface CdcChange {
|
|
|
666
869
|
table: string;
|
|
667
870
|
ts: number;
|
|
668
871
|
}
|
|
669
|
-
declare const
|
|
872
|
+
declare const CDC_LOG_TABLE_SEQ_INDEX = "__cdc_log_table_seq";
|
|
873
|
+
declare const migrateCdcLog: (sql: SqlExec, options?: {
|
|
874
|
+
rowHistoryIndex?: boolean;
|
|
875
|
+
}) => void;
|
|
670
876
|
declare const appendCdcChange: (sql: SqlExec, ts: number, table: string, id: string, op: CdcChange["op"], doc: Record<string, unknown> | undefined) => void;
|
|
671
877
|
declare const readCdcChanges: (sql: SqlExec, options?: {
|
|
672
878
|
limit?: number;
|
|
673
879
|
sinceSeq?: number;
|
|
674
|
-
tables?: ReadonlySet<string>;
|
|
675
880
|
}) => {
|
|
676
881
|
changes: CdcChange[];
|
|
677
882
|
cursor: number;
|
|
678
883
|
};
|
|
679
|
-
declare const
|
|
884
|
+
declare const cdcTouchesTables: (sql: SqlExec, sinceSeq: number, tables: ReadonlySet<string>) => boolean;
|
|
885
|
+
declare const cdcCanVouchFor: (sql: SqlExec, deps: ReadonlySet<string>) => boolean;
|
|
886
|
+
interface CdcChangeKey {
|
|
887
|
+
id: string;
|
|
888
|
+
op: CdcChange["op"];
|
|
889
|
+
seq: number;
|
|
890
|
+
}
|
|
891
|
+
declare const readCdcChangeKeys: (sql: SqlExec, table: string, sinceSeq: number, upTo: number) => CdcChangeKey[];
|
|
892
|
+
declare const trimCdcChanges: (sql: SqlExec, throughSeq: number, maxRows: number) => void;
|
|
893
|
+
declare const compactCdcDocs: (sql: SqlExec, throughSeq: number, maxRows: number) => void;
|
|
894
|
+
declare const cdcSeqLeavingRows: (sql: SqlExec, keep: number) => number | undefined;
|
|
680
895
|
declare const readCdcCursor: (sql: SqlExec) => number;
|
|
896
|
+
declare const cursorBelowRetainedFloor: (floor: number | undefined, sinceSeq: number) => boolean;
|
|
897
|
+
declare const cdcTrimmedError: (floor: number, sinceSeq: number, scope: "global" | "shard") => LunoraError;
|
|
898
|
+
declare const cdcForkedError: (cursor: number, sinceSeq: number, scope: "global" | "shard", epoch?: string) => LunoraError;
|
|
681
899
|
declare const minCdcSeq: (sql: SqlExec) => number | undefined;
|
|
900
|
+
declare const minCdcReplayableSeq: (sql: SqlExec) => number | undefined;
|
|
682
901
|
declare const CDC_META_TABLE = "__cdc_meta";
|
|
683
902
|
declare const migrateCdcMeta: (sql: SqlExec) => void;
|
|
684
903
|
declare const readCdcEpoch: (sql: SqlExec) => string;
|
|
@@ -688,12 +907,6 @@ declare const CLIENT_WATERMARK_TABLE = "__client_watermark";
|
|
|
688
907
|
declare const migrateClientWatermark: (sql: SqlExec) => void;
|
|
689
908
|
declare const readClientWatermark: (sql: SqlExec, identity: string, clientId: string) => number;
|
|
690
909
|
declare const advanceClientWatermark: (sql: SqlExec, identity: string, clientId: string, mutationId: number) => void;
|
|
691
|
-
declare const GLOBAL_SHAPE_SNAPSHOT_TABLE = "__global_shape_snapshot";
|
|
692
|
-
declare const migrateGlobalShapeSnapshot: (sql: SqlExec) => void;
|
|
693
|
-
declare const readGlobalShapeSnapshot: (sql: SqlExec, connectionId: string, subId: string) => Map<string, string>;
|
|
694
|
-
declare const writeGlobalShapeSnapshot: (sql: SqlExec, connectionId: string, subId: string, snapshot: Map<string, string>) => void;
|
|
695
|
-
declare const deleteGlobalShapeSnapshot: (sql: SqlExec, connectionId: string, subId: string) => void;
|
|
696
|
-
declare const deleteGlobalShapeSnapshotsForConnection: (sql: SqlExec, connectionId: string) => void;
|
|
697
910
|
declare const IDEMPOTENCY_TABLE = "__idempotency";
|
|
698
911
|
interface IdempotentRecord {
|
|
699
912
|
resultJson: string;
|
|
@@ -710,50 +923,19 @@ declare const runShardMigrations: (sql: SqlExec, schema: SchemaLike, options?: {
|
|
|
710
923
|
json: string;
|
|
711
924
|
};
|
|
712
925
|
}) => void;
|
|
713
|
-
/**
|
|
714
|
-
* How far a search companion's backfill has progressed, and what the next pass
|
|
715
|
-
* should do about it.
|
|
716
|
-
*
|
|
717
|
-
* Neither stored analysis nor query policy, which is why it is its own module
|
|
718
|
-
* rather than a third responsibility bolted onto one of them: it is *progress*,
|
|
719
|
-
* the one piece of search state that is written as the index is built rather
|
|
720
|
-
* than decided when it is read.
|
|
721
|
-
*
|
|
722
|
-
* The policy below is shared because when each engine owned a copy they
|
|
723
|
-
* immediately disagreed about exactly the two cases that matter — whether a row
|
|
724
|
-
* with no recorded profile may be resumed (it may not; nothing says what
|
|
725
|
-
* analyzed it) and whether a never-started index is worth wiping (it is not;
|
|
726
|
-
* there is nothing in it).
|
|
727
|
-
*/
|
|
728
|
-
/**
|
|
729
|
-
* How far a companion's backfill has progressed, and under which analysis.
|
|
730
|
-
* Declared here rather than beside either engine's state table: both record the
|
|
731
|
-
* same three facts, and the decisions made from them are the shared policy
|
|
732
|
-
* below.
|
|
733
|
-
*/
|
|
734
|
-
interface SearchBackfillState {
|
|
735
|
-
/** Last `id` indexed, or `undefined` when no page has run yet. */
|
|
736
|
-
cursor: string | undefined;
|
|
737
|
-
/** True once a page came back short — the table is fully indexed. */
|
|
738
|
-
done: boolean;
|
|
739
|
-
/** Analyzer profile the stored rows were built with; `undefined` predates profile tracking. */
|
|
740
|
-
profile: string | undefined;
|
|
741
|
-
}
|
|
742
|
-
declare const SEARCH_STATE_TABLE = "__lunora_search_state";
|
|
743
|
-
declare const migrateSearchState: (sql: SqlExec) => void;
|
|
744
|
-
declare const readSearchBackfillState: (sql: SqlExec, companion: string) => SearchBackfillState;
|
|
745
|
-
declare const writeSearchBackfillState: (sql: SqlExec, companion: string, cursor: string | undefined, done: boolean, profile: string) => void;
|
|
746
926
|
interface ShapeRow {
|
|
747
927
|
doc: Record<string, unknown>;
|
|
748
928
|
id: string;
|
|
749
929
|
}
|
|
750
930
|
declare const selectShapeRows: (sql: SqlExec, table: string, effectiveWhere: WhereInput | undefined) => ShapeRow[];
|
|
751
|
-
declare const
|
|
931
|
+
declare const selectShapeMembers: (sql: SqlExec, table: string, effectiveWhere: WhereInput | undefined, ids: ReadonlyArray<string>) => Map<string, Record<string, unknown>>;
|
|
752
932
|
interface SqlExec {
|
|
753
933
|
exec: <Row = Record<string, unknown>>(sql: string, ...params: unknown[]) => SqlCursor<Row>;
|
|
754
934
|
}
|
|
755
935
|
interface SqlCursor<Row> extends Iterable<Row> {
|
|
936
|
+
readonly columnNames?: string[];
|
|
756
937
|
one: () => Row;
|
|
938
|
+
raw?: () => IterableIterator<unknown[]>;
|
|
757
939
|
toArray: () => Row[];
|
|
758
940
|
}
|
|
759
941
|
type IndexUseHook = (table: string, indexName: string, kind: "geo" | "index" | "rank" | "search") => void;
|
|
@@ -769,6 +951,7 @@ interface WriteEvent {
|
|
|
769
951
|
type WriteHook = (event: WriteEvent) => Promise<void> | void;
|
|
770
952
|
interface CtxDbOptions {
|
|
771
953
|
auth?: ServerDefaultContextLike["auth"];
|
|
954
|
+
baselineSeq?: () => number | undefined;
|
|
772
955
|
broadcast?: BroadcastDelta;
|
|
773
956
|
cache?: ReactiveCache;
|
|
774
957
|
cdc?: boolean;
|
|
@@ -777,10 +960,16 @@ interface CtxDbOptions {
|
|
|
777
960
|
globalDb?: DatabaseWriterLike;
|
|
778
961
|
headroom?: TransactionHeadroomTracker;
|
|
779
962
|
idGenerator?: IdGenerator;
|
|
963
|
+
inTransaction?: () => boolean;
|
|
780
964
|
maxRelationKeys?: number;
|
|
781
965
|
onIndexUse?: IndexUseHook;
|
|
782
966
|
onRead?: ReadHook;
|
|
783
967
|
onReadRange?: (range: KeyRange) => void;
|
|
968
|
+
onStalePatchDropped?: (event: {
|
|
969
|
+
fields: string[];
|
|
970
|
+
id: string;
|
|
971
|
+
table: string;
|
|
972
|
+
}) => void;
|
|
784
973
|
onWrite?: WriteHook;
|
|
785
974
|
relationExistsPushDown?: "always" | "auto" | "never";
|
|
786
975
|
scheduler?: SchedulerLike;
|
|
@@ -793,6 +982,8 @@ declare class NotUniqueError extends LunoraError {
|
|
|
793
982
|
constructor(message?: string);
|
|
794
983
|
}
|
|
795
984
|
declare const normalizeIdStructurally: (schema: SchemaLike, tableName: string, id: string) => null | string;
|
|
985
|
+
declare const assertNoExplicitUndefined: (op: "patch" | "patchIf" | "replace", document: Record<string, unknown>) => void;
|
|
986
|
+
declare const stripReservedPatchFields: (patch: Record<string, unknown>) => Record<string, unknown>;
|
|
796
987
|
declare const createShardCtxDb: (options: CtxDbOptions) => DatabaseWriterLike;
|
|
797
988
|
declare const AUDIT_LOG_TABLE = "__lunora_audit__";
|
|
798
989
|
interface AuditEntry {
|
|
@@ -816,68 +1007,24 @@ declare const readAuditLog: (sql: SqlExec, options?: {
|
|
|
816
1007
|
limit?: number;
|
|
817
1008
|
sinceSeq?: number;
|
|
818
1009
|
}) => AuditEntry[];
|
|
819
|
-
interface
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
query?: SubscriptionQuery;
|
|
838
|
-
shape?: {
|
|
839
|
-
args?: Record<string, unknown>;
|
|
840
|
-
name: string;
|
|
841
|
-
};
|
|
842
|
-
sinceCheckpoint?: number;
|
|
843
|
-
sinceEpoch?: string;
|
|
844
|
-
topic?: string;
|
|
845
|
-
type: "ack" | "connect" | "shape_subscribe" | "shape_unsubscribe" | "stream" | "subscribe" | "unsubscribe" | "whisper" | "whisper_subscribe" | "whisper_unsubscribe";
|
|
846
|
-
}
|
|
847
|
-
interface RpcRequest {
|
|
848
|
-
args?: Record<string, unknown>;
|
|
849
|
-
functionPath: string;
|
|
850
|
-
}
|
|
851
|
-
interface SocketAttachment {
|
|
852
|
-
admin?: boolean;
|
|
853
|
-
clientId?: string;
|
|
854
|
-
connected?: boolean;
|
|
855
|
-
connectionId?: string;
|
|
856
|
-
context?: Record<string, unknown>;
|
|
857
|
-
expiresAt?: number;
|
|
858
|
-
identity?: Record<string, unknown>;
|
|
859
|
-
shapes?: Record<string, ShapeSubscriptionQuery>;
|
|
860
|
-
subs: Record<string, SubscriptionQuery>;
|
|
861
|
-
userId?: string;
|
|
862
|
-
whispers?: string[];
|
|
863
|
-
}
|
|
864
|
-
interface ResolvedShape {
|
|
865
|
-
columns?: ReadonlyArray<string>;
|
|
866
|
-
effectiveWhere?: WhereInput;
|
|
867
|
-
global?: boolean;
|
|
868
|
-
table: string;
|
|
869
|
-
}
|
|
870
|
-
interface SubscriptionIdentity {
|
|
871
|
-
identity?: Record<string, unknown>;
|
|
872
|
-
userId?: string;
|
|
873
|
-
}
|
|
874
|
-
interface ShardSocketLike {
|
|
875
|
-
readonly bufferedAmount?: number;
|
|
876
|
-
close?: (code?: number, reason?: string) => void;
|
|
877
|
-
deserializeAttachment?: () => unknown;
|
|
878
|
-
send: (data: string) => void;
|
|
879
|
-
serializeAttachment?: (value: unknown) => void;
|
|
880
|
-
}
|
|
1010
|
+
interface CdcArchiveScope {
|
|
1011
|
+
epoch: string;
|
|
1012
|
+
shard: string;
|
|
1013
|
+
}
|
|
1014
|
+
declare const readCdcArchivedThrough: (sql: SqlExec) => number;
|
|
1015
|
+
declare const writeCdcArchivedThrough: (sql: SqlExec, seq: number) => void;
|
|
1016
|
+
declare const archiveCdcSegment: (bucket: R2BucketLike, scope: CdcArchiveScope, changes: CdcChange[]) => Promise<void>;
|
|
1017
|
+
declare const cdcArchiveRewound: (bucket: R2BucketLike, scope: CdcArchiveScope, archivedThrough: number) => Promise<boolean>;
|
|
1018
|
+
declare const readArchivedCdcChanges: (bucket: R2BucketLike, scope: CdcArchiveScope, sinceSeq: number, limit: number | undefined) => Promise<{
|
|
1019
|
+
changes: CdcChange[];
|
|
1020
|
+
cursor: number;
|
|
1021
|
+
} | undefined>;
|
|
1022
|
+
declare const COMMIT_SEQ_TABLE = "__commit_seq";
|
|
1023
|
+
declare const COMMIT_SEQ_FIELD = "_commitSeq";
|
|
1024
|
+
declare const migrateCommitSeq: (sql: SqlExec) => void;
|
|
1025
|
+
declare const readCommitSeq: (sql: SqlExec) => number;
|
|
1026
|
+
declare const allocateCommitSeq: (sql: SqlExec) => number;
|
|
1027
|
+
declare const clearCompanionSignatures: (sql: SqlExec) => void;
|
|
881
1028
|
interface CompanionSyncDeps {
|
|
882
1029
|
broadcast: (delta: MutationDelta) => void;
|
|
883
1030
|
indexKeysFor: (table: string, document?: Record<string, unknown>) => ReadonlyArray<{
|
|
@@ -901,6 +1048,19 @@ interface CompanionSync {
|
|
|
901
1048
|
syncSearch: (tableName: string, id: string, document: Record<string, unknown> | undefined, previous?: Record<string, unknown>) => void;
|
|
902
1049
|
}
|
|
903
1050
|
declare const createCompanionSync: (deps: CompanionSyncDeps) => CompanionSync;
|
|
1051
|
+
declare const GLOBAL_SHAPE_SNAPSHOT_TABLE = "__global_shape_snapshot";
|
|
1052
|
+
declare const migrateGlobalShapeSnapshot: (sql: SqlExec) => void;
|
|
1053
|
+
declare const readGlobalShapeSnapshot: (sql: SqlExec, connectionId: string, subId: string) => Map<string, string> | undefined;
|
|
1054
|
+
declare const writeGlobalShapeSnapshot: (sql: SqlExec, connectionId: string, subId: string, snapshot: Map<string, string>) => void;
|
|
1055
|
+
declare const deleteGlobalShapeSnapshot: (sql: SqlExec, connectionId: string, subId: string) => void;
|
|
1056
|
+
declare const deleteGlobalShapeSnapshotsForConnection: (sql: SqlExec, connectionId: string) => void;
|
|
1057
|
+
declare const isMemoryTable: (definition: TableDefinitionLike | undefined) => boolean;
|
|
1058
|
+
declare const memoryTableNames: (schema: SchemaLike) => string[];
|
|
1059
|
+
declare const clearMemoryTables: (sql: SqlExec, schema: SchemaLike) => number;
|
|
1060
|
+
declare const resolveRankSeekTuple: (options: {
|
|
1061
|
+
after?: RankPageRowKey;
|
|
1062
|
+
cursor?: null | string;
|
|
1063
|
+
}) => unknown[] | undefined;
|
|
904
1064
|
interface RankPageDeps {
|
|
905
1065
|
assertRankPartitionLocal: (tableName: string, definition: TableDefinitionLike, index: RankIndexDefinitionLike) => void;
|
|
906
1066
|
ensureRankBackfilled: (tableName: string, index: RankIndexDefinitionLike) => void;
|
|
@@ -918,8 +1078,68 @@ interface RankPageComputation {
|
|
|
918
1078
|
key: RankPageRowKey;
|
|
919
1079
|
}[];
|
|
920
1080
|
}
|
|
921
|
-
declare const hydrateDocsById: (deps: RankPageDeps, tableName: string, ids: ReadonlyArray<string>) => Map<string, Record<string, unknown>>;
|
|
922
1081
|
declare const computeRankPage: (deps: RankPageDeps, tableName: string, indexName: string, rankPageOptions: RankPageOptions) => RankPageComputation;
|
|
1082
|
+
declare const SCHEDULE_OUTBOX_TABLE = "__schedule_outbox";
|
|
1083
|
+
interface ScheduleOutboxRow {
|
|
1084
|
+
attempts: number;
|
|
1085
|
+
envelopeJson: string;
|
|
1086
|
+
id: string;
|
|
1087
|
+
nextAttemptAt: number;
|
|
1088
|
+
}
|
|
1089
|
+
interface ScheduleOutboxEnvelope {
|
|
1090
|
+
args: unknown;
|
|
1091
|
+
options: Record<string, unknown> | undefined;
|
|
1092
|
+
target: unknown;
|
|
1093
|
+
when: number;
|
|
1094
|
+
}
|
|
1095
|
+
interface ScheduleOutbox {
|
|
1096
|
+
admit: (target: string) => number | undefined;
|
|
1097
|
+
forget: (id: string) => void;
|
|
1098
|
+
record: (id: string, envelope: ScheduleOutboxEnvelope) => void;
|
|
1099
|
+
wake: () => void;
|
|
1100
|
+
}
|
|
1101
|
+
declare const migrateScheduleOutbox: (sql: SqlExec) => void;
|
|
1102
|
+
declare const recordScheduleOutbox: (sql: SqlExec, id: string, envelopeJson: string, now: number) => void;
|
|
1103
|
+
declare const forgetScheduleOutbox: (sql: SqlExec, id: string) => void;
|
|
1104
|
+
declare const readDueScheduleOutbox: (sql: SqlExec, nowMs: number, limit: number) => ScheduleOutboxRow[];
|
|
1105
|
+
declare const deferScheduleOutbox: (sql: SqlExec, id: string, attempts: number, nextAttemptAt: number) => void;
|
|
1106
|
+
declare const parkScheduleOutbox: (sql: SqlExec, id: string, attempts: number) => void;
|
|
1107
|
+
declare const probeScheduleOutbox: (sql: SqlExec) => {
|
|
1108
|
+
dueAt: number | undefined;
|
|
1109
|
+
populated: boolean;
|
|
1110
|
+
};
|
|
1111
|
+
declare const trimScheduleOutbox: (sql: SqlExec, olderThanTs: number) => void;
|
|
1112
|
+
/**
|
|
1113
|
+
* How far a companion's backfill has progressed, and under which analysis.
|
|
1114
|
+
* Declared here rather than beside either engine's state table: both record the
|
|
1115
|
+
* same three facts, and the decisions made from them are the shared policy
|
|
1116
|
+
* below.
|
|
1117
|
+
*/
|
|
1118
|
+
interface BackfillState {
|
|
1119
|
+
/** Last `id` indexed, or `undefined` when no page has run yet. */
|
|
1120
|
+
cursor: string | undefined;
|
|
1121
|
+
/** True once a page came back short — the table is fully indexed. */
|
|
1122
|
+
done: boolean;
|
|
1123
|
+
/** Analyzer profile the stored rows were built with; `undefined` predates profile tracking. */
|
|
1124
|
+
profile: string | undefined;
|
|
1125
|
+
}
|
|
1126
|
+
declare const SEARCH_STATE_TABLE = "__lunora_search_state";
|
|
1127
|
+
declare const migrateSearchState: (sql: SqlExec) => void;
|
|
1128
|
+
declare const readSearchBackfillState: (sql: SqlExec, companion: string) => BackfillState;
|
|
1129
|
+
declare const writeSearchBackfillState: (sql: SqlExec, companion: string, cursor: string | undefined, done: boolean, profile: string) => void;
|
|
1130
|
+
declare const SHAPE_POKE_CURSOR_TABLE = "__shape_poke_cursor";
|
|
1131
|
+
declare const migrateShapePokeCursor: (sql: SqlExec) => void;
|
|
1132
|
+
declare const readShapePokeCursor: (sql: SqlExec, connectionId: string, subId: string) => number | undefined;
|
|
1133
|
+
declare const writeShapePokeCursor: (sql: SqlExec, connectionId: string, subId: string, cursor: number) => void;
|
|
1134
|
+
interface ShapePokeCursorRow {
|
|
1135
|
+
connectionId: string;
|
|
1136
|
+
cursor: number;
|
|
1137
|
+
subId: string;
|
|
1138
|
+
}
|
|
1139
|
+
declare const writeShapePokeCursors: (sql: SqlExec, rows: ReadonlyArray<ShapePokeCursorRow>) => void;
|
|
1140
|
+
declare const minShapePokeCursor: (sql: SqlExec) => number | undefined;
|
|
1141
|
+
declare const deleteShapePokeCursor: (sql: SqlExec, connectionId: string, subId: string) => void;
|
|
1142
|
+
declare const deleteShapePokeCursorsForConnection: (sql: SqlExec, connectionId: string) => void;
|
|
923
1143
|
declare const DATA_MIGRATION_STATE_TABLE = "__lunora_migrations";
|
|
924
1144
|
type MigrationDirection = "down" | "up";
|
|
925
1145
|
type MigrationStatus = "completed" | "failed" | "in_progress";
|
|
@@ -983,6 +1203,29 @@ interface DependencyTracker {
|
|
|
983
1203
|
declare const createDependencyTracker: () => DependencyTracker;
|
|
984
1204
|
declare const runSql: <Row = Record<string, unknown>>(sql: SqlExec, query: string, ...params: unknown[]) => SqlCursor<Row>;
|
|
985
1205
|
declare const runDrizzle: <Row = Record<string, unknown>>(exec: SqlExec, query: SQL) => SqlCursor<Row>;
|
|
1206
|
+
type RangeOperandType = "boolean" | "number" | "string";
|
|
1207
|
+
interface WhereFragments<T> {
|
|
1208
|
+
binary: (reference: T, comparator: string, value: unknown) => T;
|
|
1209
|
+
connect: (left: T, right: T, connector: "AND" | "OR") => T;
|
|
1210
|
+
constant: (value: boolean) => T;
|
|
1211
|
+
contains: (reference: T, term: T) => T;
|
|
1212
|
+
inList: (reference: T, items: ReadonlyArray<unknown>, negated: boolean, budget: number) => T;
|
|
1213
|
+
negate: (inner: T) => T;
|
|
1214
|
+
nullCheck: (reference: T, negated: boolean) => T;
|
|
1215
|
+
value: (value: unknown) => T;
|
|
1216
|
+
}
|
|
1217
|
+
type FieldRefSql<T> = (field: string) => T;
|
|
1218
|
+
type SerializeValue = (value: unknown, field: string) => unknown;
|
|
1219
|
+
interface WhereSqlStrategy<T = SQL> {
|
|
1220
|
+
containsExpr?: (reference: T, term: T) => T;
|
|
1221
|
+
fieldRef: FieldRefSql<T>;
|
|
1222
|
+
inList?: (reference: T, items: ReadonlyArray<unknown>, negated: boolean, budget?: number) => T;
|
|
1223
|
+
rangeTypeGuard: (field: string, type: RangeOperandType) => T;
|
|
1224
|
+
relationExists?: (request: unknown) => T;
|
|
1225
|
+
serialize: SerializeValue;
|
|
1226
|
+
}
|
|
1227
|
+
declare const serverInList: (engine: "mysql" | "postgres") => (reference: SQL, items: ReadonlyArray<unknown>, negated: boolean, budget?: number) => SQL;
|
|
1228
|
+
declare const compileWhereSql: <T = SQL>(where: WhereInput | undefined, strategy: WhereSqlStrategy<T>, fragments?: WhereFragments<T>, reservedParams?: number) => T | undefined;
|
|
986
1229
|
declare const quoteIdentifier: (name: string) => string;
|
|
987
1230
|
declare const serializeSqlValue: (value: unknown) => unknown;
|
|
988
1231
|
declare const DOC_COLUMN = "__doc__";
|
|
@@ -996,10 +1239,16 @@ declare const AGG_KEY: Name;
|
|
|
996
1239
|
declare const AGG_VALUE: Name;
|
|
997
1240
|
declare const AGG_COUNT: Name;
|
|
998
1241
|
declare const aggUpsertSql: (aggTable: string, key: unknown, value: unknown, count: unknown, set: SQL) => SQL;
|
|
999
|
-
declare const tableColumns: (definition: TableDefinitionLike) => [string, ColumnMetaLike]
|
|
1242
|
+
declare const tableColumns: (definition: TableDefinitionLike) => ReadonlyArray<readonly [string, ColumnMetaLike]>;
|
|
1000
1243
|
declare const rowToDocument: (row: Record<string, unknown> | undefined) => Record<string, unknown> | undefined;
|
|
1001
1244
|
declare const tryRowToDocument: (row: Record<string, unknown> | undefined) => Record<string, unknown> | undefined;
|
|
1002
1245
|
declare const isFtsAvailable: (sql: SqlExec) => boolean;
|
|
1246
|
+
declare const WORKERD_SQLITE_LIMITS: {
|
|
1247
|
+
readonly boundParams: 100;
|
|
1248
|
+
readonly compoundSelect: 5;
|
|
1249
|
+
readonly likePattern: 50;
|
|
1250
|
+
readonly sqlTextLength: 100000;
|
|
1251
|
+
};
|
|
1003
1252
|
type SqlEngine = "mysql" | "postgres" | "sqlite";
|
|
1004
1253
|
interface RenderedSql {
|
|
1005
1254
|
params: unknown[];
|
|
@@ -1007,6 +1256,79 @@ interface RenderedSql {
|
|
|
1007
1256
|
}
|
|
1008
1257
|
declare const renderSql: (engine: SqlEngine, query: SQL) => RenderedSql;
|
|
1009
1258
|
declare const param: (value: unknown) => SQL;
|
|
1259
|
+
declare const unionAll: (branches: ReadonlyArray<SQL>) => SQL;
|
|
1260
|
+
declare const sqliteInList: (reference: SQL, items: ReadonlyArray<unknown>, negated: boolean, budget?: number) => SQL;
|
|
1261
|
+
type DurableStreamStatus = "complete" | "error" | "running";
|
|
1262
|
+
interface DurableStreamRun {
|
|
1263
|
+
error?: string;
|
|
1264
|
+
errorCode?: string;
|
|
1265
|
+
lastSeq: number;
|
|
1266
|
+
startedAt: number;
|
|
1267
|
+
status: DurableStreamStatus;
|
|
1268
|
+
}
|
|
1269
|
+
interface DurableStreamChunk {
|
|
1270
|
+
dataJson: string;
|
|
1271
|
+
seq: number;
|
|
1272
|
+
}
|
|
1273
|
+
declare const migrateDurableStreams: (sql: SqlExec) => void;
|
|
1274
|
+
declare const readStreamRun: (sql: SqlExec, runKey: string) => DurableStreamRun | undefined;
|
|
1275
|
+
declare const claimStreamRun: (sql: SqlExec, runKey: string, startedAt: number, ttlMs: number) => boolean;
|
|
1276
|
+
declare const deleteStreamRun: (sql: SqlExec, runKey: string) => void;
|
|
1277
|
+
declare const appendStreamChunk: (sql: SqlExec, runKey: string, seq: number, dataJson: string) => void;
|
|
1278
|
+
declare const readStreamChunks: (sql: SqlExec, runKey: string, sinceSeq: number) => DurableStreamChunk[];
|
|
1279
|
+
declare const finishStreamRun: (sql: SqlExec, runKey: string, status: "complete" | "error", lastSeq: number, failure?: {
|
|
1280
|
+
code: string;
|
|
1281
|
+
message: string;
|
|
1282
|
+
}) => void;
|
|
1283
|
+
declare const trimStreamRuns: (sql: SqlExec, now: number, live: ReadonlySet<string>) => void;
|
|
1284
|
+
declare const MAX_DURABLE_STREAM_CHUNKS = 50000;
|
|
1285
|
+
declare const MAX_DURABLE_STREAM_BYTES: number;
|
|
1286
|
+
interface DurableStreamSink {
|
|
1287
|
+
readonly chunk: (chunk: {
|
|
1288
|
+
data: unknown;
|
|
1289
|
+
generation?: number;
|
|
1290
|
+
seq: number;
|
|
1291
|
+
}) => boolean;
|
|
1292
|
+
readonly complete: () => void;
|
|
1293
|
+
readonly fail: (failure: {
|
|
1294
|
+
code: string;
|
|
1295
|
+
message: string;
|
|
1296
|
+
}) => void;
|
|
1297
|
+
}
|
|
1298
|
+
type DurableAttachDecision = "attach" | "interrupted" | "reclaim" | "replay-terminal";
|
|
1299
|
+
declare const decideDurableAttach: (run: DurableStreamRun | undefined, context: {
|
|
1300
|
+
generation?: number;
|
|
1301
|
+
live?: {
|
|
1302
|
+
generation: number;
|
|
1303
|
+
};
|
|
1304
|
+
resuming: boolean;
|
|
1305
|
+
}) => DurableAttachDecision;
|
|
1306
|
+
interface DurableStreamAttach {
|
|
1307
|
+
readonly generation?: number;
|
|
1308
|
+
readonly iterator: (signal: AbortSignal) => AsyncIterable<unknown>;
|
|
1309
|
+
readonly runKey: string;
|
|
1310
|
+
readonly sinceChunk: number;
|
|
1311
|
+
readonly sink: DurableStreamSink;
|
|
1312
|
+
readonly ttlMs?: number;
|
|
1313
|
+
}
|
|
1314
|
+
declare class DurableStreamRunner {
|
|
1315
|
+
private lastTrimAt;
|
|
1316
|
+
private readonly runs;
|
|
1317
|
+
private readonly sql;
|
|
1318
|
+
private readonly waitUntil;
|
|
1319
|
+
constructor(dependencies: {
|
|
1320
|
+
sql: () => SqlExec;
|
|
1321
|
+
waitUntil?: (promise: Promise<unknown>) => void;
|
|
1322
|
+
});
|
|
1323
|
+
attach(request: DurableStreamAttach): Promise<void>;
|
|
1324
|
+
detach(runKey: string, sink: DurableStreamSink): void;
|
|
1325
|
+
isLive(runKey: string): boolean;
|
|
1326
|
+
private attachOrThrow;
|
|
1327
|
+
private produce;
|
|
1328
|
+
private trim;
|
|
1329
|
+
}
|
|
1330
|
+
declare const envPositiveInt: (env: unknown, key: string, fallback: number) => number;
|
|
1331
|
+
declare const envOptionalPositiveInt: (env: unknown, key: string) => number | undefined;
|
|
1010
1332
|
interface ExternalSourceDiffResult {
|
|
1011
1333
|
changes: CdcChange[];
|
|
1012
1334
|
nextBaseline: Map<string, string>;
|
|
@@ -1071,6 +1393,16 @@ declare const isSoftDeleted: (row: Record<string, unknown>, column: string) => b
|
|
|
1071
1393
|
declare const pullExternalSourceIncrementalTick: (sql: SqlExec, writer: DatabaseWriterLike, client: SourceClientLike, table: string, source: ExternalSourceLike, shardKey: string, nowMs: number) => Promise<{
|
|
1072
1394
|
applied: number;
|
|
1073
1395
|
}>;
|
|
1396
|
+
declare const ftsRowidMapName: (companion: string) => string;
|
|
1397
|
+
interface FtsWriteOptions {
|
|
1398
|
+
guard?: SQL;
|
|
1399
|
+
unmappedRowids?: ReadonlyArray<number>;
|
|
1400
|
+
}
|
|
1401
|
+
declare const ftsCompanionDdl: (companion: string) => SQL[];
|
|
1402
|
+
declare const ftsWriteDocument: (companion: string, id: string, text: string, options?: FtsWriteOptions) => SQL[];
|
|
1403
|
+
declare const ftsPurgeDocument: (companion: string, id: string, options?: FtsWriteOptions) => SQL[];
|
|
1404
|
+
declare const ftsUnmappedPage: (companion: string, limit: number, after?: number) => SQL;
|
|
1405
|
+
declare const groupUnmappedRows: (rows: ReadonlyArray<Record<string, unknown>>) => Map<string, number[]>;
|
|
1074
1406
|
declare const GEO_DEFAULT_PRECISION = 9;
|
|
1075
1407
|
interface GeoPoint {
|
|
1076
1408
|
lat: number;
|
|
@@ -1086,6 +1418,20 @@ declare const coveringGeohashes: (center: GeoPoint, radiusMeters: number) => str
|
|
|
1086
1418
|
declare const pointInBoundingBox: (point: GeoPoint, box: GeoBoundingBox) => boolean;
|
|
1087
1419
|
declare const boundingBoxCenter: (box: GeoBoundingBox) => GeoPoint;
|
|
1088
1420
|
declare const boundingBoxGeohashes: (box: GeoBoundingBox) => string[];
|
|
1421
|
+
declare class GlobalPollTick {
|
|
1422
|
+
private readonly changedTables;
|
|
1423
|
+
private readonly reads;
|
|
1424
|
+
private resync;
|
|
1425
|
+
private skippedCount;
|
|
1426
|
+
constructor(changedTables?: Set<string>);
|
|
1427
|
+
get readCount(): number;
|
|
1428
|
+
get resyncRequested(): boolean;
|
|
1429
|
+
get skipped(): number;
|
|
1430
|
+
requestResync(): void;
|
|
1431
|
+
rows(key: string | undefined, load: () => Promise<ShapeRow[]>): Promise<ShapeRow[]>;
|
|
1432
|
+
shouldRead(table: string): boolean;
|
|
1433
|
+
}
|
|
1434
|
+
declare const isInternalTableName: (name: string) => boolean;
|
|
1089
1435
|
declare const ADMIN_FUNCTION_PREFIX = "__lunora_admin__:";
|
|
1090
1436
|
declare const RELATION_FUNCTION_PREFIX = "__lunora_relation__:";
|
|
1091
1437
|
declare const FLAGS_FUNCTION_PREFIX = "__lunora_flags__:";
|
|
@@ -1096,6 +1442,8 @@ declare const ADMIN_FUNCTIONS: {
|
|
|
1096
1442
|
readonly aiGenerateSql: "__lunora_admin__:aiGenerateSql";
|
|
1097
1443
|
readonly aiTableFilter: "__lunora_admin__:aiTableFilter";
|
|
1098
1444
|
readonly assignIssue: "__lunora_admin__:assignIssue";
|
|
1445
|
+
readonly backfillSearch: "__lunora_admin__:backfillSearch";
|
|
1446
|
+
readonly backfillVectors: "__lunora_admin__:backfillVectors";
|
|
1099
1447
|
readonly backRelationCounts: "__lunora_admin__:backRelationCounts";
|
|
1100
1448
|
readonly cdcSync: "__lunora_admin__:cdcSync";
|
|
1101
1449
|
readonly clearCapturedMail: "__lunora_admin__:clearCapturedMail";
|
|
@@ -1108,6 +1456,7 @@ declare const ADMIN_FUNCTIONS: {
|
|
|
1108
1456
|
readonly explainIssue: "__lunora_admin__:explainIssue";
|
|
1109
1457
|
readonly exportShard: "__lunora_admin__:exportShard";
|
|
1110
1458
|
readonly facetColumn: "__lunora_admin__:facetColumn";
|
|
1459
|
+
readonly findRelated: "__lunora_admin__:findRelated";
|
|
1111
1460
|
readonly getAdvisories: "__lunora_admin__:getAdvisories";
|
|
1112
1461
|
readonly getAdvisorProcedures: "__lunora_admin__:getAdvisorProcedures";
|
|
1113
1462
|
readonly getAuditLog: "__lunora_admin__:getAuditLog";
|
|
@@ -1134,20 +1483,24 @@ declare const ADMIN_FUNCTIONS: {
|
|
|
1134
1483
|
readonly ignoreIssue: "__lunora_admin__:ignoreIssue";
|
|
1135
1484
|
readonly importShard: "__lunora_admin__:importShard";
|
|
1136
1485
|
readonly listFlags: "__lunora_admin__:listFlags";
|
|
1486
|
+
readonly listReactors: "__lunora_admin__:listReactors";
|
|
1137
1487
|
readonly listQueues: "__lunora_admin__:listQueues";
|
|
1138
1488
|
readonly lintSql: "__lunora_admin__:lintSql";
|
|
1139
1489
|
readonly listTables: "__lunora_admin__:listTables";
|
|
1140
1490
|
readonly listWorkflows: "__lunora_admin__:listWorkflows";
|
|
1141
1491
|
readonly maskPolicies: "__lunora_admin__:maskPolicies";
|
|
1142
1492
|
readonly migrationStatus: "__lunora_admin__:migrationStatus";
|
|
1493
|
+
readonly patchRows: "__lunora_admin__:patchRows";
|
|
1143
1494
|
readonly pitrRestore: "__lunora_admin__:pitrRestore";
|
|
1144
1495
|
readonly rankBefore: "__lunora_admin__:rankBefore";
|
|
1145
1496
|
readonly rankPage: "__lunora_admin__:rankPage";
|
|
1146
1497
|
readonly readTablePage: "__lunora_admin__:readTablePage";
|
|
1498
|
+
readonly rebuildCompanions: "__lunora_admin__:rebuildCompanions";
|
|
1147
1499
|
readonly recordAuthEvent: "__lunora_admin__:recordAuthEvent";
|
|
1148
1500
|
readonly recordContainerEvent: "__lunora_admin__:recordContainerEvent";
|
|
1149
1501
|
readonly recordMail: "__lunora_admin__:recordMail";
|
|
1150
1502
|
readonly recordQueueMessage: "__lunora_admin__:recordQueueMessage";
|
|
1503
|
+
readonly releaseShardRegistration: "__lunora_admin__:releaseShardRegistration";
|
|
1151
1504
|
readonly replayQueueMessage: "__lunora_admin__:replayQueueMessage";
|
|
1152
1505
|
readonly resolveIssue: "__lunora_admin__:resolveIssue";
|
|
1153
1506
|
readonly rlsPolicies: "__lunora_admin__:rlsPolicies";
|
|
@@ -1217,8 +1570,12 @@ interface TablesIndexesResult {
|
|
|
1217
1570
|
indexesByTable: Record<string, TableIndexInfo[]>;
|
|
1218
1571
|
}
|
|
1219
1572
|
interface ColumnMeta {
|
|
1573
|
+
bucket?: string;
|
|
1574
|
+
enumValues?: string[];
|
|
1220
1575
|
isStorage?: boolean;
|
|
1221
1576
|
name: string;
|
|
1577
|
+
nullable?: boolean;
|
|
1578
|
+
onDelete?: "cascade" | "restrict" | "set null";
|
|
1222
1579
|
optional: boolean;
|
|
1223
1580
|
pk?: boolean;
|
|
1224
1581
|
ref?: string;
|
|
@@ -1315,6 +1672,12 @@ interface StudioFeaturesResult {
|
|
|
1315
1672
|
mail: boolean;
|
|
1316
1673
|
notifications: boolean;
|
|
1317
1674
|
payments: boolean;
|
|
1675
|
+
platform?: {
|
|
1676
|
+
id: string;
|
|
1677
|
+
name: string;
|
|
1678
|
+
unsupported: string[];
|
|
1679
|
+
};
|
|
1680
|
+
privacy: boolean;
|
|
1318
1681
|
queues: boolean;
|
|
1319
1682
|
scheduler: boolean;
|
|
1320
1683
|
storage: boolean;
|
|
@@ -1333,8 +1696,20 @@ interface FlagsResult {
|
|
|
1333
1696
|
configured: boolean;
|
|
1334
1697
|
flags: FlagEvaluation[];
|
|
1335
1698
|
}
|
|
1699
|
+
interface ReactorMetadata {
|
|
1700
|
+
errors: number;
|
|
1701
|
+
lastError?: string;
|
|
1702
|
+
lastRanAt?: number;
|
|
1703
|
+
path: string;
|
|
1704
|
+
runs: number;
|
|
1705
|
+
state: "active" | "failing" | "idle";
|
|
1706
|
+
suppressed: number;
|
|
1707
|
+
tables?: ReadonlyArray<string>;
|
|
1708
|
+
}
|
|
1709
|
+
interface ReactorsResult {
|
|
1710
|
+
reactors: ReactorMetadata[];
|
|
1711
|
+
}
|
|
1336
1712
|
interface WorkflowMetadata {
|
|
1337
|
-
binding: string;
|
|
1338
1713
|
className: string;
|
|
1339
1714
|
exportName: string;
|
|
1340
1715
|
name: string;
|
|
@@ -1348,6 +1723,7 @@ interface QueueMetadata {
|
|
|
1348
1723
|
exportName: string;
|
|
1349
1724
|
mode: "pull" | "push";
|
|
1350
1725
|
name: string;
|
|
1726
|
+
topic?: string;
|
|
1351
1727
|
}
|
|
1352
1728
|
interface QueuesResult {
|
|
1353
1729
|
queues: QueueMetadata[];
|
|
@@ -1391,8 +1767,10 @@ interface TablePage {
|
|
|
1391
1767
|
columns: string[];
|
|
1392
1768
|
refs?: Record<string, string>;
|
|
1393
1769
|
rows: Record<string, unknown>[];
|
|
1770
|
+
sqlColumns: string[];
|
|
1394
1771
|
total?: number;
|
|
1395
1772
|
}
|
|
1773
|
+
type ColumnKinds = Readonly<Record<string, string>>;
|
|
1396
1774
|
type FilterOperator = "contains" | "eq" | "gt" | "gte" | "lt" | "lte" | "ne";
|
|
1397
1775
|
interface FilterClause {
|
|
1398
1776
|
column: string;
|
|
@@ -1404,6 +1782,7 @@ interface OrderByClause {
|
|
|
1404
1782
|
direction: SortDirection;
|
|
1405
1783
|
}
|
|
1406
1784
|
interface ReadTablePageOptions {
|
|
1785
|
+
columnKinds?: ColumnKinds;
|
|
1407
1786
|
filters?: FilterClause[];
|
|
1408
1787
|
limit?: number;
|
|
1409
1788
|
offset?: number;
|
|
@@ -1414,6 +1793,8 @@ interface ReadTablePageOptions {
|
|
|
1414
1793
|
table: string;
|
|
1415
1794
|
}
|
|
1416
1795
|
interface SelectMatchingIdsOptions {
|
|
1796
|
+
after?: string;
|
|
1797
|
+
columnKinds?: ColumnKinds;
|
|
1417
1798
|
filters?: FilterClause[];
|
|
1418
1799
|
limit?: number;
|
|
1419
1800
|
search?: string;
|
|
@@ -1421,6 +1802,7 @@ interface SelectMatchingIdsOptions {
|
|
|
1421
1802
|
}
|
|
1422
1803
|
interface FacetColumnOptions {
|
|
1423
1804
|
column: string;
|
|
1805
|
+
columnKinds?: ColumnKinds;
|
|
1424
1806
|
filters?: FilterClause[];
|
|
1425
1807
|
limit?: number;
|
|
1426
1808
|
search?: string;
|
|
@@ -1436,6 +1818,7 @@ interface FacetColumnResult {
|
|
|
1436
1818
|
}
|
|
1437
1819
|
declare const MAX_PAGE_SIZE = 500;
|
|
1438
1820
|
declare const listTables: (sql: SqlExec) => TableInfo[];
|
|
1821
|
+
declare const isVacuousFilterClause: (clause: FilterClause) => boolean;
|
|
1439
1822
|
declare const readTablePage: (sql: SqlExec, options: ReadTablePageOptions) => TablePage;
|
|
1440
1823
|
declare const selectMatchingIds: (sql: SqlExec, options: SelectMatchingIdsOptions) => {
|
|
1441
1824
|
hasMore: boolean;
|
|
@@ -1470,12 +1853,22 @@ interface FanoutPathCounters {
|
|
|
1470
1853
|
socketsIterated: number;
|
|
1471
1854
|
totalMs: number;
|
|
1472
1855
|
}
|
|
1856
|
+
interface ShapeProbeCounters {
|
|
1857
|
+
run: number;
|
|
1858
|
+
served: number;
|
|
1859
|
+
}
|
|
1860
|
+
interface GlobalPollCounters {
|
|
1861
|
+
drains: number;
|
|
1862
|
+
pairsSkipped: number;
|
|
1863
|
+
}
|
|
1473
1864
|
interface FanoutMetricsResult {
|
|
1865
|
+
globalPoll: GlobalPollCounters;
|
|
1474
1866
|
maxRelays: number;
|
|
1475
1867
|
peakSubscribers: number;
|
|
1476
1868
|
promoted: boolean;
|
|
1477
1869
|
relayCount: number;
|
|
1478
1870
|
shapePoke: FanoutPathCounters;
|
|
1871
|
+
shapeProbe: ShapeProbeCounters;
|
|
1479
1872
|
sinceMs: number;
|
|
1480
1873
|
topics: FanoutTopicStat[];
|
|
1481
1874
|
totalConnections: number;
|
|
@@ -1489,6 +1882,10 @@ interface FanoutAttachmentLike {
|
|
|
1489
1882
|
}
|
|
1490
1883
|
declare const DEFAULT_FANOUT_TOPIC_LIMIT = 20;
|
|
1491
1884
|
declare const createFanoutCounters: () => FanoutPathCounters;
|
|
1885
|
+
declare const createShapeProbeCounters: () => ShapeProbeCounters;
|
|
1886
|
+
declare const createGlobalPollCounters: () => GlobalPollCounters;
|
|
1887
|
+
declare const recordGlobalPollPass: (counters: GlobalPollCounters, drains: number, pairsSkipped: number) => GlobalPollCounters;
|
|
1888
|
+
declare const recordShapeProbePass: (counters: ShapeProbeCounters, run: number, served: number) => ShapeProbeCounters;
|
|
1492
1889
|
declare const recordFanoutPass: (counters: FanoutPathCounters, iterated: number, delivered: number, ms: number) => FanoutPathCounters;
|
|
1493
1890
|
declare const summarizeFanoutTopics: (attachments: FanoutAttachmentLike[], limit?: number) => {
|
|
1494
1891
|
peakSubscribers: number;
|
|
@@ -1536,6 +1933,11 @@ declare const clearCapturedMail: (sql: SqlExec) => {
|
|
|
1536
1933
|
declare class NotFoundError extends LunoraError {
|
|
1537
1934
|
constructor(message?: string);
|
|
1538
1935
|
}
|
|
1936
|
+
declare const operatorFields: (definition: TableDefinitionLike, patch: Record<string, unknown>) => ReadonlySet<string>;
|
|
1937
|
+
declare const resolvePatch: (definition: TableDefinitionLike, patch: Record<string, unknown>, current: Record<string, unknown>) => Record<string, unknown>;
|
|
1938
|
+
declare const patchDependsOnRow: (definition: TableDefinitionLike, patch: Record<string, unknown>) => boolean;
|
|
1939
|
+
declare const assertPatchAllowed: (options: PatchWriteOptions | undefined, previous: Record<string, unknown>, next: Record<string, unknown>) => void;
|
|
1940
|
+
declare const readPatchField: (document: Record<string, unknown>, field: string) => unknown;
|
|
1539
1941
|
interface PitrStorage {
|
|
1540
1942
|
getBookmarkForTime?: (time: Date | number) => Promise<string>;
|
|
1541
1943
|
getCurrentBookmark?: () => Promise<string>;
|
|
@@ -1557,7 +1959,22 @@ interface PitrRestoreArgs {
|
|
|
1557
1959
|
}
|
|
1558
1960
|
declare const readBookmark: (storage: PitrStorage, time?: number | string) => Promise<PitrBookmarkResult>;
|
|
1559
1961
|
declare const armRestore: (storage: PitrStorage, args: PitrRestoreArgs) => Promise<Omit<PitrRestoreResult, "restarted">>;
|
|
1560
|
-
declare const
|
|
1962
|
+
declare const tiebreakDirectionFor: (keys: ReadonlyArray<{
|
|
1963
|
+
direction?: string;
|
|
1964
|
+
}>) => SortDirection;
|
|
1965
|
+
declare const equalityPinnedFields: (where: undefined | WhereInput) => ReadonlySet<string>;
|
|
1966
|
+
declare const uniqueIndexFields: (indexes: ReadonlyArray<{
|
|
1967
|
+
fields: ReadonlyArray<string>;
|
|
1968
|
+
unique?: boolean;
|
|
1969
|
+
}> | undefined, shape: Record<string, ValidatorLike> | undefined) => ReadonlyArray<ReadonlyArray<string>>;
|
|
1970
|
+
interface OrderKeyConstraints {
|
|
1971
|
+
pinned?: ReadonlySet<string>;
|
|
1972
|
+
uniqueBy?: ReadonlyArray<ReadonlyArray<string>>;
|
|
1973
|
+
}
|
|
1974
|
+
declare const nullsFirstOf: (key: Pick<OrderKey, "direction" | "nulls">) => boolean;
|
|
1975
|
+
declare const nullsOrderSuffix: (nullsFirst: boolean) => string;
|
|
1976
|
+
declare const normalizeOrderKeys: (orderBy: OrderByInput[] | undefined, shape?: Record<string, ValidatorLike>, constraints?: OrderKeyConstraints) => OrderKey[];
|
|
1977
|
+
declare const CURSOR_PREFIX = "~4";
|
|
1561
1978
|
declare const encodeCursor: (record: Record<string, unknown>, keys: OrderKey[]) => string;
|
|
1562
1979
|
declare const decodeCursor: (cursor: string) => unknown[];
|
|
1563
1980
|
declare const buildSeekWhere: (keys: OrderKey[], cursorValues: unknown[]) => WhereInput;
|
|
@@ -1617,7 +2034,36 @@ declare const rankKeyFromDocument: (index: RankIndexDefinitionLike, document_: R
|
|
|
1617
2034
|
rowId: string;
|
|
1618
2035
|
sortValues: unknown[];
|
|
1619
2036
|
};
|
|
2037
|
+
declare const rankPivotConditionSql: (column: string, value: unknown, direction: "asc" | "desc", wantLater: boolean) => SQL | undefined;
|
|
1620
2038
|
declare const matchesRankStaticWhere: (document: Record<string, unknown>, predicate: Record<string, unknown>) => boolean;
|
|
2039
|
+
declare const REACTOR_STATE_TABLE = "__reactor_state";
|
|
2040
|
+
interface ReactorState {
|
|
2041
|
+
digest: string;
|
|
2042
|
+
lastError?: string;
|
|
2043
|
+
lastRanAt: number;
|
|
2044
|
+
stats: ReactorStats;
|
|
2045
|
+
tables?: ReadonlyArray<string>;
|
|
2046
|
+
}
|
|
2047
|
+
interface ReactorStats {
|
|
2048
|
+
errors: number;
|
|
2049
|
+
runs: number;
|
|
2050
|
+
suppressed: number;
|
|
2051
|
+
}
|
|
2052
|
+
declare const migrateReactorState: (sql: SqlExec) => void;
|
|
2053
|
+
declare const readReactorState: (sql: SqlExec, path: string) => ReactorState | undefined;
|
|
2054
|
+
declare const listReactorStates: (sql: SqlExec) => {
|
|
2055
|
+
path: string;
|
|
2056
|
+
state: ReactorState;
|
|
2057
|
+
}[];
|
|
2058
|
+
type ReactorDispatchResult = "error" | "ran" | "suppressed";
|
|
2059
|
+
declare const writeReactorState: (sql: SqlExec, path: string, outcome: {
|
|
2060
|
+
digest?: string;
|
|
2061
|
+
error?: string;
|
|
2062
|
+
now: number;
|
|
2063
|
+
result: ReactorDispatchResult;
|
|
2064
|
+
tables?: ReadonlyArray<string>;
|
|
2065
|
+
}) => void;
|
|
2066
|
+
declare const reactorNeedsRun: (state: Pick<ReactorState, "tables"> | undefined, changed: ReadonlySet<string>) => boolean;
|
|
1621
2067
|
interface ReadFootprint {
|
|
1622
2068
|
onRead: (table: string, idOrScan?: string) => void;
|
|
1623
2069
|
onReadRange: (range: KeyRange) => void;
|
|
@@ -1625,16 +2071,33 @@ interface ReadFootprint {
|
|
|
1625
2071
|
tables: Set<string>;
|
|
1626
2072
|
}
|
|
1627
2073
|
declare const createReadFootprint: () => ReadFootprint;
|
|
2074
|
+
declare const UNVOUCHABLE_DEP = "!unvouchable";
|
|
2075
|
+
declare const markUnvouchableReads: <T extends object>(facade: T, onRead: ReadFootprint["onRead"] | undefined, methods: ReadonlyArray<string>) => T;
|
|
2076
|
+
declare const WHERE_FILTER: unique symbol;
|
|
2077
|
+
type RowPredicate = (document: Record<string, unknown>) => boolean;
|
|
2078
|
+
type WhereFilter = RowPredicate & {
|
|
2079
|
+
readonly [WHERE_FILTER]: WhereInput;
|
|
2080
|
+
};
|
|
2081
|
+
declare const whereFilter: (where: WhereInput, predicate: RowPredicate) => WhereFilter;
|
|
2082
|
+
declare const whereOfFilter: (predicate: RowPredicate) => undefined | WhereInput;
|
|
2083
|
+
declare const isPushableWhere: (where: WhereInput, shape: Readonly<Record<string, ValidatorLike>>, exactText?: boolean) => boolean;
|
|
2084
|
+
declare const RELATED_MAX_DEPTH = 4;
|
|
2085
|
+
declare const RELATED_DEFAULT_LIMIT = 50;
|
|
2086
|
+
declare const RELATED_MAX_LIMIT = 200;
|
|
2087
|
+
declare const RELATED_DEPTH_DECAY = 0.5;
|
|
2088
|
+
declare const deriveRelationEdges: (schema: SchemaLike) => RelationEdge[];
|
|
2089
|
+
type RelationGraphReader = Pick<DatabaseWriterLike, "findMany"> & Pick<Partial<DatabaseWriterLike>, "lookupById">;
|
|
2090
|
+
declare const findRelated: (reader: RelationGraphReader, edges: ReadonlyArray<RelationEdge>, start: RelatedStart, options?: RelatedOptions) => Promise<RelatedPage>;
|
|
1628
2091
|
declare const DEFAULT_MAX_RELATION_KEYS = 5000;
|
|
1629
2092
|
interface RelationExistsMarker {
|
|
1630
2093
|
childWhere: WhereInput;
|
|
1631
2094
|
negated: boolean;
|
|
1632
2095
|
parentTable: string;
|
|
1633
|
-
relation:
|
|
2096
|
+
relation: KeyedRelationDefinitionLike;
|
|
1634
2097
|
}
|
|
1635
2098
|
type ExistsPushMode = "always" | "auto";
|
|
1636
2099
|
interface ResolveRelationPredicatesOptions {
|
|
1637
|
-
canPushExists?: (relation:
|
|
2100
|
+
canPushExists?: (relation: KeyedRelationDefinitionLike) => boolean;
|
|
1638
2101
|
existsPushMode?: ExistsPushMode;
|
|
1639
2102
|
fetcher: (tableName: string, args: QueryArgs) => Promise<QueryPage>;
|
|
1640
2103
|
maxRelationKeys?: number;
|
|
@@ -1645,7 +2108,7 @@ interface ResolveRelationPredicatesOptions {
|
|
|
1645
2108
|
tableName: string;
|
|
1646
2109
|
}
|
|
1647
2110
|
interface ResolveContext {
|
|
1648
|
-
canPushExists?: (relation:
|
|
2111
|
+
canPushExists?: (relation: KeyedRelationDefinitionLike) => boolean;
|
|
1649
2112
|
existsPushMode: ExistsPushMode;
|
|
1650
2113
|
fetcher: (tableName: string, args: QueryArgs) => Promise<QueryPage>;
|
|
1651
2114
|
maxRelationKeys: number;
|
|
@@ -1658,7 +2121,14 @@ declare const isRelationPredicate: (value: unknown) => value is Record<string, W
|
|
|
1658
2121
|
declare const containsRelationPredicate: (where: WhereInput, schema: ResolveContext["schema"], tableName: string) => boolean;
|
|
1659
2122
|
declare const assertFlatPredicate: (where: WhereInput | undefined, schema: ResolveContext["schema"], tableName: string, op: string) => void;
|
|
1660
2123
|
declare const resolveRelationPredicates: (where: WhereInput | undefined, options: ResolveRelationPredicatesOptions) => Promise<WhereInput | undefined>;
|
|
2124
|
+
declare const composeReadPredicate: (definition: TableDefinitionLike, args: QueryArgs, relation: Omit<ResolveRelationPredicatesOptions, "relationBaseWhere">) => Promise<{
|
|
2125
|
+
fetchLimit: number | undefined;
|
|
2126
|
+
limit: number | undefined;
|
|
2127
|
+
orderKeys: OrderKey[];
|
|
2128
|
+
predicate: WhereInput | undefined;
|
|
2129
|
+
}>;
|
|
1661
2130
|
declare const assertShapeShardable: (effectiveWhere: WhereInput | undefined, schema: ResolveContext["schema"], table: string) => void;
|
|
2131
|
+
declare const relationHooks: (args: Pick<QueryArgs, "relationBaseWhere" | "relationMask">) => Pick<QueryArgs, "relationBaseWhere" | "relationMask"> & Pick<ResolveWithOptions, "fanOutBudget">;
|
|
1662
2132
|
declare const fanOutScalarCounts: (counter: (tableName: string, where?: WhereInput) => Promise<number>, tableName: string, whereField: string, values: unknown[], policyWhere: WhereInput | undefined) => Promise<Map<unknown, number>>;
|
|
1663
2133
|
declare const distinctValues: (rows: Record<string, unknown>[], field: string) => unknown[];
|
|
1664
2134
|
declare const resolveWith: (options: ResolveWithOptions) => Promise<void>;
|
|
@@ -1683,6 +2153,8 @@ interface ShapeRowOp {
|
|
|
1683
2153
|
value?: Record<string, unknown>;
|
|
1684
2154
|
}
|
|
1685
2155
|
interface ShapePokePart {
|
|
2156
|
+
baseCheckpoint?: number;
|
|
2157
|
+
reset?: boolean;
|
|
1686
2158
|
rowsPatch: ShapeRowOp[];
|
|
1687
2159
|
shapeId: string;
|
|
1688
2160
|
}
|
|
@@ -1743,6 +2215,12 @@ interface RelayShapeSubscribe {
|
|
|
1743
2215
|
type: "relay_shape_subscribe";
|
|
1744
2216
|
userId?: string;
|
|
1745
2217
|
}
|
|
2218
|
+
interface RelayShapeUnsubscribe {
|
|
2219
|
+
connectionId: string;
|
|
2220
|
+
relayIndex: number;
|
|
2221
|
+
subId?: string;
|
|
2222
|
+
type: "relay_shape_unsubscribe";
|
|
2223
|
+
}
|
|
1746
2224
|
interface RelayShapeSeed {
|
|
1747
2225
|
cursor?: number;
|
|
1748
2226
|
epoch?: string;
|
|
@@ -1762,22 +2240,19 @@ interface RelayShapePoke {
|
|
|
1762
2240
|
targetConnectionId?: string;
|
|
1763
2241
|
type: "relay_shape_poke";
|
|
1764
2242
|
}
|
|
1765
|
-
type OwnerRelayFrame = RelayAttach | RelayDetach | RelayFrame | RelayShapePoke | RelayShapeSubscribe;
|
|
1766
|
-
|
|
1767
|
-
interface RelayStub {
|
|
2243
|
+
type OwnerRelayFrame = RelayAttach | RelayDetach | RelayFrame | RelayShapePoke | RelayShapeSubscribe | RelayShapeUnsubscribe;
|
|
2244
|
+
interface SiblingStub {
|
|
1768
2245
|
fetch: (url: string, init?: RequestInit) => Promise<Response>;
|
|
1769
2246
|
}
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
getByName?: (name: string) => RelayStub;
|
|
1773
|
-
idFromName: (name: string) => unknown;
|
|
1774
|
-
}
|
|
2247
|
+
declare const stubByName: (value: unknown, name: string, jurisdiction?: string) => SiblingStub | undefined;
|
|
2248
|
+
declare const DEFAULT_MAX_RELAYS = 8;
|
|
1775
2249
|
interface RelayHost {
|
|
1776
2250
|
buildShapeDiff: (resolved: ResolvedShape, fromCursor: number, toCursor: number) => ShapeRowOp[];
|
|
1777
2251
|
computeOpLogShapeSeed: (shape: ShapeSubscriptionQuery, resolved: ResolvedShape) => {
|
|
1778
2252
|
baseCheckpoint: number | undefined;
|
|
1779
2253
|
cursor: number;
|
|
1780
2254
|
epoch: string | undefined;
|
|
2255
|
+
reset: boolean;
|
|
1781
2256
|
rowsPatch: ShapeRowOp[];
|
|
1782
2257
|
};
|
|
1783
2258
|
currentCdcEpoch: () => string | undefined;
|
|
@@ -1792,8 +2267,13 @@ interface RelayHost {
|
|
|
1792
2267
|
resolveShape: (name: string, args: Record<string, unknown>, identity?: SubscriptionIdentity) => ResolvedShape | undefined;
|
|
1793
2268
|
rlsMetadata: () => RlsPoliciesResult;
|
|
1794
2269
|
shardBinding: () => string | undefined;
|
|
2270
|
+
shardJurisdiction: () => string | undefined;
|
|
1795
2271
|
sql: () => SqlExec;
|
|
1796
2272
|
}
|
|
2273
|
+
interface RelayPokeDelivery {
|
|
2274
|
+
delivered: number;
|
|
2275
|
+
matched: number;
|
|
2276
|
+
}
|
|
1797
2277
|
declare abstract class RelayLink {
|
|
1798
2278
|
protected readonly host: RelayHost;
|
|
1799
2279
|
protected readonly roleId: {
|
|
@@ -1807,7 +2287,8 @@ declare abstract class RelayLink {
|
|
|
1807
2287
|
handleControl(request: Request): Promise<Response>;
|
|
1808
2288
|
maxRelays(): number;
|
|
1809
2289
|
protected canAddressSiblings(): boolean;
|
|
1810
|
-
protected
|
|
2290
|
+
protected siblingStub(targetName: string): SiblingStub | undefined;
|
|
2291
|
+
protected bindingName(): string | undefined;
|
|
1811
2292
|
protected postRelayMessage(targetName: string, message: OwnerRelayFrame): Promise<void>;
|
|
1812
2293
|
protected requestRelayMessage(targetName: string, message: OwnerRelayFrame): Promise<Response | undefined>;
|
|
1813
2294
|
abstract forwardWhisper(topic: string, frame: string): Promise<void>;
|
|
@@ -1818,19 +2299,22 @@ declare abstract class RelayLink {
|
|
|
1818
2299
|
}>;
|
|
1819
2300
|
abstract announce(): Promise<void>;
|
|
1820
2301
|
abstract announceDrain(closing: ShardSocketLike): Promise<void>;
|
|
2302
|
+
abstract releaseRelayShapes(ws: ShardSocketLike, subId?: string): Promise<void>;
|
|
1821
2303
|
abstract relayCount(): number;
|
|
1822
2304
|
abstract isShapeRelayUniform(name: string, args: Record<string, unknown>): boolean;
|
|
2305
|
+
abstract minShapeCursor(): number | undefined;
|
|
1823
2306
|
protected abstract onAttach(index: number): void;
|
|
1824
2307
|
protected abstract onDetach(index: number): void;
|
|
1825
2308
|
protected abstract onWhisperFrame(message: RelayFrame): Promise<void>;
|
|
1826
2309
|
protected abstract onShapeSubscribe(message: RelayShapeSubscribe): RelayShapeSeed;
|
|
1827
|
-
protected abstract
|
|
2310
|
+
protected abstract onShapeUnsubscribe(message: RelayShapeUnsubscribe): void;
|
|
2311
|
+
protected abstract onShapePoke(poke: RelayShapePoke): RelayPokeDelivery;
|
|
1828
2312
|
}
|
|
1829
2313
|
declare class OwnerRelay extends RelayLink {
|
|
1830
2314
|
private readonly shapeUniformCache;
|
|
1831
2315
|
private relaySetCache;
|
|
1832
|
-
private
|
|
1833
|
-
private
|
|
2316
|
+
private registryCache;
|
|
2317
|
+
private recordedBinding;
|
|
1834
2318
|
private promotionState;
|
|
1835
2319
|
constructor(host: RelayHost, ownerKey: string);
|
|
1836
2320
|
forwardWhisper(topic: string, frame: string): Promise<void>;
|
|
@@ -1841,18 +2325,26 @@ declare class OwnerRelay extends RelayLink {
|
|
|
1841
2325
|
}>;
|
|
1842
2326
|
announce(): Promise<void>;
|
|
1843
2327
|
announceDrain(): Promise<void>;
|
|
2328
|
+
releaseRelayShapes(): Promise<void>;
|
|
1844
2329
|
relayCount(): number;
|
|
2330
|
+
minShapeCursor(): number | undefined;
|
|
1845
2331
|
isShapeRelayUniform(name: string, args: Record<string, unknown>): boolean;
|
|
2332
|
+
protected onShapeUnsubscribe(message: RelayShapeUnsubscribe): void;
|
|
1846
2333
|
protected onAttach(index: number): void;
|
|
1847
2334
|
protected onDetach(index: number): void;
|
|
1848
2335
|
protected onWhisperFrame(message: RelayFrame): Promise<void>;
|
|
1849
2336
|
protected onShapeSubscribe(message: RelayShapeSubscribe): RelayShapeSeed;
|
|
1850
|
-
protected onShapePoke():
|
|
2337
|
+
protected onShapePoke(): RelayPokeDelivery;
|
|
1851
2338
|
private buildShapePoke;
|
|
1852
2339
|
private multicastShapePokes;
|
|
2340
|
+
private multicastToRelays;
|
|
1853
2341
|
private proxyShapePokes;
|
|
2342
|
+
private proxyToRelay;
|
|
1854
2343
|
private buildShapeSeedFrames;
|
|
1855
|
-
private
|
|
2344
|
+
private ensureRelayTables;
|
|
2345
|
+
protected bindingName(): string | undefined;
|
|
2346
|
+
private relayShapes;
|
|
2347
|
+
private rewindShapeCursor;
|
|
1856
2348
|
private ownerRelaySet;
|
|
1857
2349
|
private addRelayToSet;
|
|
1858
2350
|
private removeRelayFromSet;
|
|
@@ -1861,7 +2353,8 @@ declare class OwnerRelay extends RelayLink {
|
|
|
1861
2353
|
}
|
|
1862
2354
|
declare class RelayMember extends RelayLink {
|
|
1863
2355
|
private relayAnnounced;
|
|
1864
|
-
private
|
|
2356
|
+
private relayMemoCache;
|
|
2357
|
+
private readonly shapeControl;
|
|
1865
2358
|
constructor(host: RelayHost, ownerKey: string, relayIndex: number);
|
|
1866
2359
|
forwardWhisper(topic: string, frame: string): Promise<void>;
|
|
1867
2360
|
onFlush(): Promise<void>;
|
|
@@ -1871,17 +2364,81 @@ declare class RelayMember extends RelayLink {
|
|
|
1871
2364
|
}>;
|
|
1872
2365
|
announce(): Promise<void>;
|
|
1873
2366
|
announceDrain(closing: ShardSocketLike): Promise<void>;
|
|
2367
|
+
releaseRelayShapes(ws: ShardSocketLike, subId?: string): Promise<void>;
|
|
1874
2368
|
relayCount(): number;
|
|
1875
2369
|
isShapeRelayUniform(): boolean;
|
|
2370
|
+
minShapeCursor(): number | undefined;
|
|
1876
2371
|
protected onAttach(): void;
|
|
1877
2372
|
protected onDetach(): void;
|
|
1878
2373
|
protected onWhisperFrame(): Promise<void>;
|
|
1879
2374
|
protected onShapeSubscribe(): RelayShapeSeed;
|
|
1880
|
-
protected
|
|
2375
|
+
protected onShapeUnsubscribe(): void;
|
|
2376
|
+
protected onShapePoke(poke: RelayShapePoke): RelayPokeDelivery;
|
|
2377
|
+
private queueShapeControl;
|
|
2378
|
+
private relayMemos;
|
|
2379
|
+
private connectionMemos;
|
|
1881
2380
|
private recordRelayShapeMemo;
|
|
2381
|
+
private forgetRelayShapeMemos;
|
|
1882
2382
|
private deliverShapePoke;
|
|
2383
|
+
private pokeSocketShapes;
|
|
1883
2384
|
}
|
|
1884
2385
|
declare const createRelayLink: (host: RelayHost) => OwnerRelay | RelayMember | undefined;
|
|
2386
|
+
declare const REGION_HINTS: readonly ["wnam", "enam", "sam", "weur", "eeur", "apac", "apac-ne", "apac-se", "oc", "afr", "me"];
|
|
2387
|
+
type RegionHint = (typeof REGION_HINTS)[number];
|
|
2388
|
+
type ReplicaReadiness = "fresh" | "stale" | "unavailable";
|
|
2389
|
+
interface ShardSiblingHost {
|
|
2390
|
+
doName: () => string | undefined;
|
|
2391
|
+
env: () => unknown;
|
|
2392
|
+
shardBinding: () => string | undefined;
|
|
2393
|
+
shardJurisdiction: () => string | undefined;
|
|
2394
|
+
sql: () => SqlExec;
|
|
2395
|
+
}
|
|
2396
|
+
interface ReplicaOwnerHost extends ShardSiblingHost {
|
|
2397
|
+
exportRows: () => Promise<ExportRow[]>;
|
|
2398
|
+
ownerCursor: () => number | undefined;
|
|
2399
|
+
ownerEpoch: () => string | undefined;
|
|
2400
|
+
ownerFloor: () => number | undefined;
|
|
2401
|
+
readChanges: (sinceSeq: number, limit: number) => {
|
|
2402
|
+
changes: CdcChange[];
|
|
2403
|
+
cursor: number;
|
|
2404
|
+
};
|
|
2405
|
+
rowCount: () => number;
|
|
2406
|
+
}
|
|
2407
|
+
interface ReplicaFollowerHost extends ShardSiblingHost {
|
|
2408
|
+
applyChanges: (changes: ReadonlyArray<CdcChange>) => Promise<number>;
|
|
2409
|
+
importRows: (rows: ReadonlyArray<ExportRow>) => Promise<{
|
|
2410
|
+
errors: ReadonlyArray<unknown>;
|
|
2411
|
+
}>;
|
|
2412
|
+
}
|
|
2413
|
+
declare const handleReplicaControl: (host: ReplicaOwnerHost, request: Request) => Promise<Response>;
|
|
2414
|
+
declare class ShardReplica {
|
|
2415
|
+
private readonly host;
|
|
2416
|
+
readonly ownerKey: string;
|
|
2417
|
+
readonly region: RegionHint;
|
|
2418
|
+
private divergent;
|
|
2419
|
+
private inFlight;
|
|
2420
|
+
constructor(host: ReplicaFollowerHost, ownerKey: string, region: RegionHint);
|
|
2421
|
+
ensureFresh(minSeq?: number): Promise<ReplicaReadiness>;
|
|
2422
|
+
appliedSeq(): number;
|
|
2423
|
+
isDivergent(): boolean;
|
|
2424
|
+
private advance;
|
|
2425
|
+
private isCaughtUp;
|
|
2426
|
+
private catchUp;
|
|
2427
|
+
private applyPage;
|
|
2428
|
+
private hasDiverged;
|
|
2429
|
+
private bootstrap;
|
|
2430
|
+
private isFreshEnough;
|
|
2431
|
+
private pull;
|
|
2432
|
+
private request;
|
|
2433
|
+
}
|
|
2434
|
+
declare const createReplicaLink: (host: ReplicaFollowerHost) => ShardReplica | undefined;
|
|
2435
|
+
declare const gateReplicaDispatch: (replica: ShardReplica, request: Request, functionPath: string) => Promise<Response | undefined>;
|
|
2436
|
+
declare const REPROJECTION_MIGRATION_PREFIX = "__lunora_reproject__";
|
|
2437
|
+
declare const reprojectionMigrationId: (table: string) => string;
|
|
2438
|
+
declare const reprojectableFields: (definition: TableDefinitionLike) => string[];
|
|
2439
|
+
declare const reprojectionTables: (schema: SchemaLike) => string[];
|
|
2440
|
+
declare const countLegacyRows: (sql: SqlExec, table: string, fields: ReadonlyArray<string>) => number;
|
|
2441
|
+
declare const buildReprojectionMigration: (id: string, schema: SchemaLike, sql: SqlExec) => DataMigrationLike | undefined;
|
|
1885
2442
|
declare const RLS_UNWRAP_SYMBOL: symbol;
|
|
1886
2443
|
declare class RlsRequiredError extends LunoraError {
|
|
1887
2444
|
readonly table: string;
|
|
@@ -1898,7 +2455,7 @@ interface GuardableSchema {
|
|
|
1898
2455
|
}
|
|
1899
2456
|
type TableOfId = (id: string, expectedTable?: string) => Promise<string | undefined> | string | undefined;
|
|
1900
2457
|
type TablesOfIds = (ids: ReadonlyArray<string>, expectedTable?: string) => Promise<ReadonlyMap<string, string>> | ReadonlyMap<string, string>;
|
|
1901
|
-
declare const guardWriter: <W>(raw: W, schema: GuardableSchema, tableOfId: TableOfId, tablesOfIds?: TablesOfIds) => W;
|
|
2458
|
+
declare const guardWriter: <W>(raw: W, schema: GuardableSchema, tableOfId: TableOfId, tablesOfIds?: TablesOfIds, relationEdges?: ReadonlyArray<RelationEdge>) => W;
|
|
1902
2459
|
declare const SCHEMA_HISTORY_MAX_VERSIONS = 50;
|
|
1903
2460
|
interface SchemaVersionRow {
|
|
1904
2461
|
appliedAt: number;
|
|
@@ -1909,8 +2466,24 @@ interface SchemaVersionRow {
|
|
|
1909
2466
|
declare const recordSchemaVersion: (sql: SqlExec, hash: string, snapshotJson: string, now?: number) => boolean;
|
|
1910
2467
|
declare const readSchemaHistory: (sql: SqlExec) => SchemaVersionRow[];
|
|
1911
2468
|
declare const readSchemaVersion: (sql: SqlExec, hash: string) => SchemaVersionRow | undefined;
|
|
2469
|
+
declare const readDeployInfo: (rawEnv: unknown) => DeployInfo;
|
|
1912
2470
|
declare const isDevEnvironment: (rawEnv: unknown) => boolean;
|
|
1913
2471
|
declare const buildSettings: (rawEnv: unknown) => SettingsResult;
|
|
2472
|
+
declare class ShapeDiffCache {
|
|
2473
|
+
private readonly keyScans;
|
|
2474
|
+
private readonly memberProbes;
|
|
2475
|
+
private run;
|
|
2476
|
+
private served;
|
|
2477
|
+
get probesRun(): number;
|
|
2478
|
+
get probesServed(): number;
|
|
2479
|
+
changedKeys(rangeKey: string, load: () => CdcChangeKey[]): ReadonlyArray<CdcChangeKey>;
|
|
2480
|
+
members(resolved: ResolvedShape, rangeKey: string, load: () => Map<string, Record<string, unknown>>): ReadonlyMap<string, Record<string, unknown>>;
|
|
2481
|
+
private getOrLoad;
|
|
2482
|
+
}
|
|
2483
|
+
declare const createShapeDiffCache: () => ShapeDiffCache;
|
|
2484
|
+
declare const globalShapeReadKey: (resolved: ResolvedShape, identity: SubscriptionIdentity) => string | undefined;
|
|
2485
|
+
type ReadShapeCdcKeys = (sql: SqlExec, table: string, sinceSeq: number, upTo: number) => CdcChangeKey[];
|
|
2486
|
+
declare const buildShapeDiff: (sql: SqlExec, resolved: ResolvedShape, sinceSeq: number, upTo: number, cache: ShapeDiffCache, readKeys?: ReadShapeCdcKeys) => ShapeRowOp[];
|
|
1914
2487
|
interface ShardRunnerOptions {
|
|
1915
2488
|
handlers?: {
|
|
1916
2489
|
handleAlarm?: () => Promise<void>;
|
|
@@ -1926,7 +2499,7 @@ declare class ShardRunner {
|
|
|
1926
2499
|
socketFor(raw: unknown): ShardSocketLike;
|
|
1927
2500
|
sockets(tag?: string): SocketHandle[];
|
|
1928
2501
|
background(work: Promise<unknown>): boolean;
|
|
1929
|
-
runInTransaction<T>(work: () => Promise<T
|
|
2502
|
+
runInTransaction<T>(work: () => Promise<T>, onCommitted?: () => void): Promise<T>;
|
|
1930
2503
|
handleFetch(request: Request): Promise<Response>;
|
|
1931
2504
|
handleAlarm(): Promise<void>;
|
|
1932
2505
|
}
|
|
@@ -1952,6 +2525,11 @@ interface SqlDiagnostic {
|
|
|
1952
2525
|
source: "gate" | "plan" | "syntax";
|
|
1953
2526
|
}
|
|
1954
2527
|
declare const lintReadonlySql: (sql: SqlExec, query: string) => SqlLintResult;
|
|
2528
|
+
declare const BIGINT_KEY_DIGITS = 39;
|
|
2529
|
+
declare const bigintSqlKey: (value: bigint) => string;
|
|
2530
|
+
declare const decodeBigintSqlKey: (raw: string) => bigint | undefined;
|
|
2531
|
+
declare const float64SqlKey: (value: number) => string;
|
|
2532
|
+
declare const decodeFloat64SqlKey: (raw: string) => number | undefined;
|
|
1955
2533
|
declare const subscriptionListDeltas: (previousJson: string, nextResult: unknown, table: string, frames?: string[]) => MutationDelta[] | undefined;
|
|
1956
2534
|
interface FrameSink {
|
|
1957
2535
|
send: (data: string) => void;
|
|
@@ -1960,7 +2538,17 @@ interface DrainableSink {
|
|
|
1960
2538
|
readonly bufferedAmount?: unknown;
|
|
1961
2539
|
}
|
|
1962
2540
|
declare const trySendFrame: (ws: FrameSink, frame: string) => boolean;
|
|
1963
|
-
|
|
2541
|
+
interface SubscriptionFrameInput {
|
|
2542
|
+
cursorSuffix: string;
|
|
2543
|
+
lastMutationId?: number;
|
|
2544
|
+
nextResult: unknown;
|
|
2545
|
+
pageDeltas?: boolean;
|
|
2546
|
+
previousJson?: string;
|
|
2547
|
+
snapshotJson: string;
|
|
2548
|
+
subId: string;
|
|
2549
|
+
table: string;
|
|
2550
|
+
}
|
|
2551
|
+
declare const subscriptionFrames: (input: SubscriptionFrameInput) => string[];
|
|
1964
2552
|
declare const awaitWsDrain: (ws: DrainableSink) => Promise<void>;
|
|
1965
2553
|
interface SubscriptionReadFootprint {
|
|
1966
2554
|
ranges?: Map<string, KeyRange[]>;
|
|
@@ -1988,13 +2576,30 @@ declare const selectExpiredIds: (sql: SqlExec, spec: TtlSweepSpec, now: number,
|
|
|
1988
2576
|
hasMore: boolean;
|
|
1989
2577
|
ids: string[];
|
|
1990
2578
|
};
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
2579
|
+
declare const VECTOR_BACKFILL_MAX_PAGES = 20;
|
|
2580
|
+
interface VectorBackfillTarget {
|
|
2581
|
+
profile: string;
|
|
2582
|
+
table: string;
|
|
2583
|
+
}
|
|
2584
|
+
interface VectorBackfillProgress {
|
|
2585
|
+
done: boolean;
|
|
2586
|
+
error?: string;
|
|
2587
|
+
failed: number;
|
|
2588
|
+
failedIds: string[];
|
|
2589
|
+
pages: number;
|
|
2590
|
+
rows: number;
|
|
1998
2591
|
}
|
|
1999
|
-
|
|
2000
|
-
|
|
2592
|
+
type VectorPageSync = (table: string, rows: ReadonlyArray<{
|
|
2593
|
+
doc: Record<string, unknown>;
|
|
2594
|
+
id: string;
|
|
2595
|
+
}>) => Promise<ReadonlyArray<{
|
|
2596
|
+
error: unknown;
|
|
2597
|
+
id: string;
|
|
2598
|
+
}>>;
|
|
2599
|
+
type OrderedAfterWrites = <T, U>(read: () => T, work: (value: T) => Promise<U>) => Promise<U>;
|
|
2600
|
+
declare const backfillVectorIndexes: (sql: SqlExec, targets: ReadonlyArray<VectorBackfillTarget>, sync: VectorPageSync, options: {
|
|
2601
|
+
maxPages?: number;
|
|
2602
|
+
ordered: OrderedAfterWrites;
|
|
2603
|
+
restart?: boolean;
|
|
2604
|
+
}) => Promise<VectorBackfillProgress>;
|
|
2605
|
+
export { ADMIN_FUNCTIONS, ADMIN_FUNCTION_PREFIX, AGGREGATE_SQL_FUNCTION, AGG_COUNT, AGG_KEY, AGG_VALUE, AUDIT_LOG_TABLE, type AdvisorProcedure, type AdvisorProceduresResult, type AdvisoriesResult, type AdvisoryFinding, type AggregateIndexDefinitionLike, type AggregateOp, type AggregateOptions, type AggregateResult, type AggregateTally, type AppendAuditEntry, type ApplyOnDeleteOptions, type AuditEntry, type AuditLogResult, BIGINT_KEY_DIGITS, type BroadcastDelta, CDC_LOG_TABLE, CDC_LOG_TABLE_SEQ_INDEX, CDC_META_TABLE, CLIENT_WATERMARK_TABLE, COMMIT_SEQ_FIELD, COMMIT_SEQ_TABLE, CURSOR_PREFIX, type CacheEntry, type CapturedMailRow, type CdcArchiveScope, type CdcChange, type CdcChangeKey, type ChangedKeys, type Clock, type ColumnMeta, type ColumnMetaLike, type CompanionSync, type CompanionSyncDeps, ConflictError, type ConflictKind, type CountArgs, CountRlsUnsupportedError, type CreateWorkflowInstanceResult, type CrossShardReadArgs, type CtxDbOptions, DATA_MIGRATION_STATE_TABLE, DEFAULT_FANOUT_TOPIC_LIMIT, DEFAULT_MAX_RELATION_KEYS, DEFAULT_MAX_RELAYS, DEFAULT_PROMOTION_THRESHOLDS, DEFAULT_TRANSACTION_LIMITS, DOC_COLUMN, type DataMigrationDocument, type DataMigrationLike, type DataMigrationTransform, type DatabaseWriterLike, type DependencyTracker, type DeployInfo, type DurableAttachDecision, type DurableStreamAttach, type DurableStreamRun, DurableStreamRunner, type DurableStreamSink, type ExportRow, type ExportShardAdminArgs, type ExportShardArgs, type ExternalSourceDiffResult, type ExternalSourceLike, FLAGS_FUNCTION_PREFIX, type FacetColumnOptions, type FacetColumnResult, type FacetValue, type FanOutBudget, type FanoutMetricsResult, type FanoutPathCounters, type FanoutTopicStat, type FieldOperators, type FilterClause, type FilterOperator, type FlagEvaluation, type FlagsResult, type FtsWriteOptions, type FunctionCallStat, type FunctionScanAttribution, type FunctionStatsResult, GEO_DEFAULT_PRECISION, GLOBAL_SHAPE_SNAPSHOT_TABLE, type GeoBoundingBox, type GeoFilterBuilderLike, type GeoIndexDefinitionLike, type GeoPoint, type GeoScoredDocument, type GlobalPollCounters, GlobalPollTick, type GroupByEntry, type GroupByOptions, type GuardableSchema$1 as GuardableSchema, IDEMPOTENCY_TABLE, type IdGenerator, type IdempotentRecord, type ImportError, type ImportShardAdminArgs, type ImportShardArgs, type ImportShardResult, type IncrementalMaterializeResult, type IndexDefinitionLike, type IndexKeyEntry, type IndexRangeBuilderLike, type KeyRange, type KeyedRelationWriteInfo, 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 NullPlacement, type OnDeleteActionLike, type OrderByClause, type OrderByInput, type OrderKey, type OrderKeyConstraints, OwnerRelay, type OwnerRelayFrame, type PaginationOptions, type PatchVerifier, type PatchWriteOptions, type PitrBookmarkResult, type PitrRestoreArgs, type PitrRestoreResult, type PitrStorage, type PokeFrameMeta, type PromotionState, type PromotionThresholds, QUEUE_TABLE, type QueryArgs, type QueryPage, type QueryPlan, 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 RangeOperandType, 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 RelationWriteInfo, type RelationWriteMap, 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 ThroughRelationWriteInfo, type TransactionHeadroom, TransactionHeadroomTracker, type TransactionLimits, type TransactionSqlLike, type TriggerContextLike, type TriggerDefinitionLike, type TriggerEventLike, type TriggerOpLike, type TriggerTimingLike, type TtlSweepSpec, UNVOUCHABLE_DEP, VECTOR_BACKFILL_MAX_PAGES, type ValidatorLike, type VectorBackfillProgress, WORKERD_SQLITE_LIMITS, type WhereFilter, type WhereInput, type WhereSqlStrategy, type WithInput, type WorkflowInstanceState, type WorkflowInstanceStatusResult, type WorkflowMetadata, type WorkflowsResult, type WriteEvent, type WriteHook, advanceClientWatermark, aggUpsertSql, aggregateSqlFunction, aggregateTableName, allocateCommitSeq, appendAuditEntry, appendCdcChange, appendStreamChunk, applyCdcChanges, applyOnDelete, applySelect, archiveCdcSegment, armRestore, assertFlatPredicate, assertNoExplicitUndefined, assertPatchAllowed, assertReadonly, assertShapeShardable, assertValidClientId, awaitWsDrain, backfillAggregateIndexes, backfillRankIndexes, backfillSearchIndexes, backfillSearchIndexesForTable, backfillVectorIndexes, bigintSqlKey, boundingBoxCenter, boundingBoxGeohashes, buildIndexRange, buildPokeFrames, buildReprojectionMigration, buildSeekBeforeWhere, buildSeekWhere, buildSettings, buildShapeDiff, bumpCdcEpoch, cdcArchiveRewound, cdcCanVouchFor, cdcForkedError, cdcSeqLeavingRows, cdcTouchesTables, cdcTrimmedError, claimStreamRun, clampPromotionThresholds, clearCapturedMail, clearCompanionSignatures, clearMemoryTables, clearQueueMessages, coerceAggregateNumber, compactCdcDocs, compileWhereSql, composeReadPredicate, 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, describeRelationWrites, diffExternalSource, diffGlobalMembership, distinctValues, encodeAggregateKey, encodeCursor, encodeGeohash, encodePartitionKey, encodeRowsPatch, ensureAuditTable, ensureMailTable, envOptionalPositiveInt, envPositiveInt, equalityPinnedFields, exportShardRows, facetColumn, fanOutScalarCounts, findRelated, findStorageReferences, finishStreamRun, float64SqlKey, foldAggregateTally, forgetScheduleOutbox, ftsCompanionDdl, ftsPurgeDocument, ftsRowidMapName, ftsUnmappedPage, ftsWriteDocument, gateReplicaDispatch, geoTableName, globalShapeReadKey, groupUnmappedRows, guardWriter, handleReplicaControl, hasTrigger, haversineMeters, importShardRows, indexKeysForRow, isDevEnvironment, isFtsAvailable, isInternalTableName, isLossyBody, isMemoryTable, isPushableWhere, isRelationPredicate, isSoftDeleted, isSourceDue, isVacuousFilterClause, jsonPath, jsonPathSql, keysTouchRanges, liftSourceId, lintReadonlySql, listReactorStates, listTables, markUnvouchableReads, matchesRankStaticWhere, matchesStaticWhere, materializeExternalRows, materializeExternalRowsIncremental, memoryTableNames, mergeChangedKeys, mergeWhere, migrateCdcLog, migrateCdcMeta, migrateClientWatermark, migrateCommitSeq, migrateDurableStreams, migrateGlobalShapeSnapshot, migrateIdempotency, migrateReactorState, migrateScheduleOutbox, migrateSearchState, migrateShapePokeCursor, minCdcReplayableSeq, minCdcSeq, minShapePokeCursor, nextPromotionState, normalizeCountArgument, normalizeIdStructurally, normalizeOrderKeys, normalizeSourceDocument, normalizeSourceValue, nullsFirstOf, nullsOrderSuffix, operatorFields, param, parkScheduleOutbox, parseExportShardArgs, parseImportShardArgs, patchDependsOnRow, 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, readPatchField, readQueueMessageById, readQueueMessages, readReactorState, readSchemaHistory, readSchemaVersion, readSearchBackfillState, readShapePokeCursor, readStreamChunks, readStreamRun, readTablePage, recordCapturedMail, recordChangedKeys, recordFanoutPass, recordGlobalPollPass, recordQueueMessages, recordScheduleOutbox, recordSchemaVersion, recordShapeProbePass, relationHooks, relayCountFor, renderSql, reprojectableFields, reprojectionMigrationId, reprojectionTables, resolvePatch, resolveRankPartition, resolveRankSeekTuple, resolveRelationPredicates, resolveWith, rowToDocument, runDataMigration, runDrizzle, runExternalSourceTick, runReadonlySql, runRowValidators, runShardMigrations, runSocketPool, runSql, runTriggers, selectExpiredIds, selectExportTables, selectIndexForAggregate, selectIndexForCount, selectIndexForGroupBy, selectMatchingIds, selectShapeMembers, selectShapeRows, serializeSqlValue, serverInList, shapeRoutingKey, softDeleteScope, sortColumnName, sqliteInList, stripReservedPatchFields, stubByName, subscriptionFrames, subscriptionListDeltas, summarizeFanoutTopics, summarizeSubscriptions, tableColumns, tableFromDepKey, throwingScheduler, tiebreakDirectionFor, trimCdcChanges, trimIdempotent, trimScheduleOutbox, trimStreamRuns, tryRowToDocument, trySendFrame, unionAll, uniqueIndexFields, validateImportRow, whereFilter, whereOfFilter, writeCdcArchivedThrough, writeGlobalShapeSnapshot, writeIdempotent, writeReactorState, writeSearchBackfillState, writeShapePokeCursor, writeShapePokeCursors, writeTouchesMemo };
|