@lunora/shard-engine 0.0.0 → 1.0.0-alpha.1
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/LICENSE.md +122 -0
- package/README.md +10 -38
- package/dist/conformance/index.d.mts +24 -0
- package/dist/conformance/index.d.ts +24 -0
- package/dist/conformance/index.mjs +1 -0
- package/dist/index.d.mts +1905 -0
- package/dist/index.d.ts +1905 -0
- package/dist/index.mjs +1 -0
- package/dist/packem_shared/ADMIN_FUNCTIONS-B0xlQJ4w.mjs +1 -0
- package/dist/packem_shared/AGGREGATE_SQL_FUNCTION-QYaiuty4.mjs +1 -0
- package/dist/packem_shared/AGG_COUNT-BWXe3gtQ.mjs +1 -0
- package/dist/packem_shared/AUDIT_LOG_TABLE-CaA0jL0L.mjs +8 -0
- package/dist/packem_shared/CDC_LOG_TABLE-BnqlH2eZ.mjs +8 -0
- package/dist/packem_shared/CLIENT_WATERMARK_TABLE-CXsSLU8D.mjs +7 -0
- package/dist/packem_shared/ConflictError-C8GtJmjS.mjs +1 -0
- package/dist/packem_shared/CountRlsUnsupportedError-B2WKJD9v.mjs +1 -0
- package/dist/packem_shared/DATA_MIGRATION_STATE_TABLE-CaO6L0Ee.mjs +31 -0
- package/dist/packem_shared/DEFAULT_MAX_RELATION_KEYS-bq00btqV.mjs +1 -0
- package/dist/packem_shared/DEFAULT_MAX_RELAYS-CnCyh6oX.mjs +1 -0
- package/dist/packem_shared/DEFAULT_PROMOTION_THRESHOLDS-Dteg0sZF.mjs +1 -0
- package/dist/packem_shared/FTS_COUNT_COLUMN-D1gY3wwZ-CZHdaRrd.mjs +1 -0
- package/dist/packem_shared/GEO_DEFAULT_PRECISION-okRCkZ6r.mjs +1 -0
- package/dist/packem_shared/GLOBAL_SHAPE_SNAPSHOT_TABLE-DX-6-gBP.mjs +7 -0
- package/dist/packem_shared/IDEMPOTENCY_TABLE-DjkEMp6w.mjs +7 -0
- package/dist/packem_shared/MAIL_RETENTION-KmozO2NQ.mjs +18 -0
- package/dist/packem_shared/MAX_SQL_ROWS-nMwkxv5f.mjs +2 -0
- package/dist/packem_shared/NotFoundError-BhF7FeFr.mjs +1 -0
- package/dist/packem_shared/NotUniqueError-B4piAtjk.mjs +1 -0
- package/dist/packem_shared/QUEUE_TABLE-DYCDvzTG.mjs +17 -0
- package/dist/packem_shared/RANK_TIEBREAK-9NU5s_mi.mjs +1 -0
- package/dist/packem_shared/RELATION_EXISTS_KEY-BaqSIFU1.mjs +1 -0
- package/dist/packem_shared/RLS_UNWRAP_SYMBOL-C6_WX3dG.mjs +1 -0
- package/dist/packem_shared/ReactiveCache-1_9Rs7J_.mjs +1 -0
- package/dist/packem_shared/SCAN_DEP-D_yR9EeV.mjs +1 -0
- package/dist/packem_shared/SCHEMA_HISTORY_MAX_VERSIONS-CHXz6p_z.mjs +6 -0
- package/dist/packem_shared/SEARCH_STATE_TABLE-eLN8U5tz.mjs +1 -0
- package/dist/packem_shared/ShardRunner-DIqVdWtk.mjs +1 -0
- package/dist/packem_shared/aggregateTableName-G-eXyjcz.mjs +1 -0
- package/dist/packem_shared/applyOnDelete-uFRC5p1d.mjs +1 -0
- package/dist/packem_shared/applySelect-B0CF8T7y.mjs +1 -0
- package/dist/packem_shared/armRestore-BNzdvQ_o.mjs +1 -0
- package/dist/packem_shared/awaitWsDrain-Dk50ISgE.mjs +1 -0
- package/dist/packem_shared/backfillAggregateIndexes-BHiewuB-.mjs +1 -0
- package/dist/packem_shared/buildPokeFrames-DaPpm5Ss.mjs +1 -0
- package/dist/packem_shared/buildSettings-DT18_DkX.mjs +1 -0
- package/dist/packem_shared/compileWhereSql-BLcfs4QW.mjs +1 -0
- package/dist/packem_shared/computeRankPage-IUSS-zIB.mjs +1 -0
- package/dist/packem_shared/createCompanionSync-BCBUOnMk.mjs +1 -0
- package/dist/packem_shared/createSystemReader-DcDcrtM3.mjs +1 -0
- package/dist/packem_shared/defineEngineContractSuite-CVwNQvzx.mjs +1 -0
- package/dist/packem_shared/diffExternalSource-DMpkJta1.mjs +1 -0
- package/dist/packem_shared/exportShardRows-kt42wijd.mjs +1 -0
- package/dist/packem_shared/hasTrigger-CbkOHExZ.mjs +1 -0
- package/dist/packem_shared/isSoftDeleted-B-SXkGUo.mjs +9 -0
- package/dist/packem_shared/liftSourceId-DApAbu7Q.mjs +1 -0
- package/dist/packem_shared/materializeExternalRows-DOQJV9p2.mjs +1 -0
- package/dist/packem_shared/param-B5lF5Jd9.mjs +1 -0
- package/dist/packem_shared/quote-identifier-CGiYFBvY.mjs +1 -0
- package/dist/packem_shared/runDrizzle-GKR3y97k.mjs +1 -0
- package/dist/packem_shared/runShardMigrations-CPxqCh3O.mjs +5 -0
- package/dist/packem_shared/runSocketPool-DPQLVyWF.mjs +1 -0
- package/dist/packem_shared/selectExpiredIds-FzhIEeG1.mjs +1 -0
- package/dist/packem_shared/selectShapeMemberIds-DvE7K6zG.mjs +1 -0
- package/dist/packem_shared/serializeSqlValue-DnpyaLcw.mjs +1 -0
- package/dist/packem_shared/stableStringify-BjLh4gvA.mjs +1 -0
- package/dist/packem_shared/stableWireKey-YEHLaX6X.mjs +1 -0
- package/dist/packem_shared/wire-codec-Ctnni0h6.mjs +1 -0
- package/package.json +55 -7
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,1905 @@
|
|
|
1
|
+
import { LunoraError } from '@lunora/errors';
|
|
2
|
+
import { SQL, Name } from 'drizzle-orm';
|
|
3
|
+
import { ShardHost, SocketHost, SocketHandle } from '@lunora/platform';
|
|
4
|
+
type SystemTableName = "_scheduled_functions" | "_storage";
|
|
5
|
+
interface ScheduledFunctionDoc {
|
|
6
|
+
args: Record<string, unknown>;
|
|
7
|
+
attempts?: number;
|
|
8
|
+
enqueuedAt: number;
|
|
9
|
+
functionPath: string;
|
|
10
|
+
id: string;
|
|
11
|
+
scheduledFor: number;
|
|
12
|
+
shardKey?: string;
|
|
13
|
+
}
|
|
14
|
+
interface StorageMetadata {
|
|
15
|
+
contentType?: string;
|
|
16
|
+
customMetadata?: Record<string, string>;
|
|
17
|
+
key: string;
|
|
18
|
+
sha256?: string;
|
|
19
|
+
size: number;
|
|
20
|
+
uploaded?: number;
|
|
21
|
+
}
|
|
22
|
+
interface SystemDocMap {
|
|
23
|
+
_scheduled_functions: ScheduledFunctionDoc;
|
|
24
|
+
_storage: StorageMetadata;
|
|
25
|
+
}
|
|
26
|
+
type SystemDoc<T extends SystemTableName> = SystemDocMap[T];
|
|
27
|
+
interface SystemQuery<T extends SystemTableName> {
|
|
28
|
+
collect: () => Promise<SystemDoc<T>[]>;
|
|
29
|
+
}
|
|
30
|
+
interface SystemDatabaseReader {
|
|
31
|
+
get: <T extends SystemTableName>(table: T, id: string) => Promise<SystemDoc<T> | null>;
|
|
32
|
+
query: <T extends SystemTableName>(table: T) => SystemQuery<T>;
|
|
33
|
+
}
|
|
34
|
+
interface SystemReaderSchedulerLike {
|
|
35
|
+
get: (id: string) => Promise<Record<string, unknown> | null>;
|
|
36
|
+
list: () => Promise<ReadonlyArray<Record<string, unknown>>>;
|
|
37
|
+
}
|
|
38
|
+
interface SystemReaderStorageLike {
|
|
39
|
+
getMetadata: (key: string) => Promise<StorageMetadata | null>;
|
|
40
|
+
list: (prefix?: string, options?: Record<string, unknown>) => Promise<{
|
|
41
|
+
objects: ReadonlyArray<Record<string, unknown>>;
|
|
42
|
+
}>;
|
|
43
|
+
}
|
|
44
|
+
interface SystemReaderOptions {
|
|
45
|
+
scheduler?: SystemReaderSchedulerLike;
|
|
46
|
+
storage?: SystemReaderStorageLike;
|
|
47
|
+
}
|
|
48
|
+
declare const createSystemReader: (options?: SystemReaderOptions) => SystemDatabaseReader;
|
|
49
|
+
interface FieldOperators {
|
|
50
|
+
contains?: string;
|
|
51
|
+
eq?: unknown;
|
|
52
|
+
gt?: unknown;
|
|
53
|
+
gte?: unknown;
|
|
54
|
+
in?: unknown[];
|
|
55
|
+
isNull?: boolean;
|
|
56
|
+
lt?: unknown;
|
|
57
|
+
lte?: unknown;
|
|
58
|
+
ne?: unknown;
|
|
59
|
+
notIn?: unknown[];
|
|
60
|
+
}
|
|
61
|
+
interface WhereInput {
|
|
62
|
+
[field: string]: unknown;
|
|
63
|
+
AND?: WhereInput[];
|
|
64
|
+
NOT?: WhereInput;
|
|
65
|
+
OR?: WhereInput[];
|
|
66
|
+
}
|
|
67
|
+
declare const RELATION_EXISTS_KEY = "__relationExists";
|
|
68
|
+
type AggregateOp = "avg" | "count" | "max" | "min" | "sum";
|
|
69
|
+
interface AggregateIndexDefinitionLike {
|
|
70
|
+
readonly by?: ReadonlyArray<string>;
|
|
71
|
+
readonly field?: string;
|
|
72
|
+
readonly name: string;
|
|
73
|
+
readonly on: string;
|
|
74
|
+
readonly op: AggregateOp;
|
|
75
|
+
readonly where?: Record<string, unknown>;
|
|
76
|
+
}
|
|
77
|
+
interface GeoIndexDefinitionLike {
|
|
78
|
+
readonly field: string;
|
|
79
|
+
readonly name: string;
|
|
80
|
+
readonly precision?: number;
|
|
81
|
+
}
|
|
82
|
+
interface IndexDefinitionLike {
|
|
83
|
+
readonly fields: ReadonlyArray<string>;
|
|
84
|
+
readonly name: string;
|
|
85
|
+
readonly unique?: boolean;
|
|
86
|
+
}
|
|
87
|
+
interface RankIndexDefinitionLike {
|
|
88
|
+
readonly name: string;
|
|
89
|
+
readonly on: string;
|
|
90
|
+
readonly partitionBy?: ReadonlyArray<string>;
|
|
91
|
+
readonly sortBy: ReadonlyArray<RankSortKeyLike>;
|
|
92
|
+
readonly where?: Record<string, unknown>;
|
|
93
|
+
}
|
|
94
|
+
interface SearchIndexDefinitionLike {
|
|
95
|
+
readonly field: string;
|
|
96
|
+
readonly filterFields?: ReadonlyArray<string>;
|
|
97
|
+
readonly language?: string;
|
|
98
|
+
readonly name: string;
|
|
99
|
+
readonly staged?: boolean;
|
|
100
|
+
readonly strategy?: string;
|
|
101
|
+
}
|
|
102
|
+
interface ServerDefaultContextLike {
|
|
103
|
+
readonly auth: {
|
|
104
|
+
readonly identity: Record<string, unknown> | null;
|
|
105
|
+
readonly userId: null | string;
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
interface ColumnMetaLike {
|
|
109
|
+
readonly defaultFn?: () => unknown;
|
|
110
|
+
readonly defaultValue?: unknown;
|
|
111
|
+
readonly notNull?: boolean;
|
|
112
|
+
readonly onUpdateFn?: () => unknown;
|
|
113
|
+
readonly serverDefault?: (context: ServerDefaultContextLike) => unknown;
|
|
114
|
+
readonly unique?: boolean;
|
|
115
|
+
}
|
|
116
|
+
interface ValidatorLike {
|
|
117
|
+
readonly _meta?: {
|
|
118
|
+
readonly column?: ColumnMetaLike;
|
|
119
|
+
};
|
|
120
|
+
readonly kind?: string;
|
|
121
|
+
readonly parse?: (value: unknown) => unknown;
|
|
122
|
+
}
|
|
123
|
+
type TriggerTimingLike = "after" | "before";
|
|
124
|
+
type TriggerOpLike = "delete" | "insert" | "update";
|
|
125
|
+
interface SchedulableWorkflowReferenceLike {
|
|
126
|
+
readonly binding?: string;
|
|
127
|
+
readonly isLunoraWorkflow: true;
|
|
128
|
+
readonly name?: string;
|
|
129
|
+
}
|
|
130
|
+
interface SchedulerLike {
|
|
131
|
+
runAfter: (delayMs: number, target: SchedulableWorkflowReferenceLike | string, args?: Record<string, unknown>) => Promise<string>;
|
|
132
|
+
runAt: (timestampMs: number, target: SchedulableWorkflowReferenceLike | string, args?: Record<string, unknown>) => Promise<string>;
|
|
133
|
+
}
|
|
134
|
+
interface TriggerEventLike {
|
|
135
|
+
doc?: Record<string, unknown>;
|
|
136
|
+
id: string;
|
|
137
|
+
op: TriggerOpLike;
|
|
138
|
+
previous?: Record<string, unknown>;
|
|
139
|
+
table: string;
|
|
140
|
+
}
|
|
141
|
+
interface TriggerContextLike {
|
|
142
|
+
db: DatabaseWriterLike;
|
|
143
|
+
scheduler: SchedulerLike;
|
|
144
|
+
}
|
|
145
|
+
interface TriggerDefinitionLike {
|
|
146
|
+
readonly handler: (context: TriggerContextLike, event: TriggerEventLike) => Promise<void> | void;
|
|
147
|
+
readonly op: TriggerOpLike;
|
|
148
|
+
readonly timing: TriggerTimingLike;
|
|
149
|
+
}
|
|
150
|
+
interface GuardableSchema$1 {
|
|
151
|
+
readonly rlsMode?: "required";
|
|
152
|
+
readonly tables: Record<string, {
|
|
153
|
+
readonly isPublic?: boolean;
|
|
154
|
+
}>;
|
|
155
|
+
}
|
|
156
|
+
interface SchemaLike {
|
|
157
|
+
readonly rlsMode?: "required";
|
|
158
|
+
readonly tables: Record<string, TableDefinitionLike>;
|
|
159
|
+
}
|
|
160
|
+
interface TableDefinitionLike {
|
|
161
|
+
readonly aggregateIndexes?: ReadonlyArray<AggregateIndexDefinitionLike>;
|
|
162
|
+
readonly geoIndexes?: ReadonlyArray<GeoIndexDefinitionLike>;
|
|
163
|
+
readonly indexes: ReadonlyArray<IndexDefinitionLike>;
|
|
164
|
+
readonly isPublic?: boolean;
|
|
165
|
+
readonly rankIndexes?: ReadonlyArray<RankIndexDefinitionLike>;
|
|
166
|
+
readonly relationMap?: Record<string, RelationDefinitionLike>;
|
|
167
|
+
readonly searchIndexes?: ReadonlyArray<SearchIndexDefinitionLike>;
|
|
168
|
+
readonly shape: Record<string, ValidatorLike>;
|
|
169
|
+
readonly shardMode?: {
|
|
170
|
+
field?: string;
|
|
171
|
+
kind: "global" | "root" | "shardBy";
|
|
172
|
+
};
|
|
173
|
+
readonly softDeleteMode?: {
|
|
174
|
+
field: string;
|
|
175
|
+
};
|
|
176
|
+
readonly triggerMap?: Record<string, TriggerDefinitionLike>;
|
|
177
|
+
readonly ttlPolicy?: {
|
|
178
|
+
after?: number;
|
|
179
|
+
field: string;
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
interface RelationDefinitionLike {
|
|
183
|
+
readonly field: string;
|
|
184
|
+
readonly kind: "many" | "one";
|
|
185
|
+
readonly onDelete?: OnDeleteActionLike;
|
|
186
|
+
readonly references: string;
|
|
187
|
+
readonly table: string;
|
|
188
|
+
}
|
|
189
|
+
type OnDeleteActionLike = "cascade" | "restrict" | "set null";
|
|
190
|
+
interface NestedWith {
|
|
191
|
+
limit?: number;
|
|
192
|
+
orderBy?: OrderByInput[];
|
|
193
|
+
select?: ReadonlyArray<string>;
|
|
194
|
+
where?: WhereInput;
|
|
195
|
+
with?: WithInput;
|
|
196
|
+
}
|
|
197
|
+
interface WithInput {
|
|
198
|
+
[relationName: string]: NestedWith | Record<string, true> | boolean | undefined;
|
|
199
|
+
_count?: Record<string, true>;
|
|
200
|
+
}
|
|
201
|
+
interface ApplyOnDeleteOptions$1 {
|
|
202
|
+
database: DatabaseWriterLike;
|
|
203
|
+
relation: RelationDefinitionLike;
|
|
204
|
+
row: Record<string, unknown>;
|
|
205
|
+
tableName: string;
|
|
206
|
+
}
|
|
207
|
+
interface ResolveWithOptions {
|
|
208
|
+
fetcher: (tableName: string, args: QueryArgs) => Promise<QueryPage>;
|
|
209
|
+
groupedCounter: (tableName: string, whereField: string, values: unknown[], policyWhere?: WhereInput) => Promise<Map<unknown, number>>;
|
|
210
|
+
parents: Record<string, unknown>[];
|
|
211
|
+
relationBaseWhere?: (table: string) => undefined | WhereInput;
|
|
212
|
+
schema: {
|
|
213
|
+
readonly tables: Record<string, TableDefinitionLike>;
|
|
214
|
+
};
|
|
215
|
+
tableName: string;
|
|
216
|
+
with: WithInput;
|
|
217
|
+
}
|
|
218
|
+
interface ResolveWithResult {
|
|
219
|
+
parent: Record<string, unknown>;
|
|
220
|
+
relationName: string;
|
|
221
|
+
rows: Record<string, unknown>[];
|
|
222
|
+
}
|
|
223
|
+
type SortDirection = "asc" | "desc";
|
|
224
|
+
type OrderByInput = Record<string, SortDirection>;
|
|
225
|
+
interface QueryArgs {
|
|
226
|
+
baseWhere?: WhereInput;
|
|
227
|
+
cursor?: null | string;
|
|
228
|
+
includeDeleted?: boolean;
|
|
229
|
+
limit?: number;
|
|
230
|
+
orderBy?: OrderByInput[];
|
|
231
|
+
relationBaseWhere?: (table: string) => undefined | WhereInput;
|
|
232
|
+
restrictsCounts?: boolean;
|
|
233
|
+
select?: ReadonlyArray<string>;
|
|
234
|
+
where?: WhereInput;
|
|
235
|
+
with?: WithInput;
|
|
236
|
+
}
|
|
237
|
+
interface QueryPage {
|
|
238
|
+
continueCursor: null | string;
|
|
239
|
+
isDone: boolean;
|
|
240
|
+
page: Record<string, unknown>[];
|
|
241
|
+
splitCursor?: null | string;
|
|
242
|
+
}
|
|
243
|
+
interface OrderKey {
|
|
244
|
+
direction: SortDirection;
|
|
245
|
+
field: string;
|
|
246
|
+
}
|
|
247
|
+
interface RestrictableQueryOptions {
|
|
248
|
+
baseWhere?: WhereInput;
|
|
249
|
+
relationBaseWhere?: (table: string) => undefined | WhereInput;
|
|
250
|
+
restrictsCounts?: boolean;
|
|
251
|
+
where?: WhereInput;
|
|
252
|
+
}
|
|
253
|
+
interface AggregateOptions extends RestrictableQueryOptions {
|
|
254
|
+
field?: string;
|
|
255
|
+
op: AggregateOp;
|
|
256
|
+
}
|
|
257
|
+
type AggregateResult = null | number;
|
|
258
|
+
interface GroupByOptions extends RestrictableQueryOptions {
|
|
259
|
+
agg?: {
|
|
260
|
+
field?: string;
|
|
261
|
+
op: AggregateOp;
|
|
262
|
+
};
|
|
263
|
+
by: ReadonlyArray<string>;
|
|
264
|
+
}
|
|
265
|
+
interface GroupByEntry {
|
|
266
|
+
key: Record<string, unknown>;
|
|
267
|
+
value: AggregateResult;
|
|
268
|
+
}
|
|
269
|
+
type RankDirection = "asc" | "desc";
|
|
270
|
+
interface RankSortKeyLike {
|
|
271
|
+
readonly direction: RankDirection;
|
|
272
|
+
readonly field: string;
|
|
273
|
+
}
|
|
274
|
+
interface RankResult {
|
|
275
|
+
position: number;
|
|
276
|
+
total: number;
|
|
277
|
+
}
|
|
278
|
+
interface RankOptions extends RestrictableQueryOptions {
|
|
279
|
+
row: Record<string, unknown> | string;
|
|
280
|
+
}
|
|
281
|
+
interface RankBeforeOptions {
|
|
282
|
+
partitionKey: string;
|
|
283
|
+
restrictsCounts?: boolean;
|
|
284
|
+
rowId: string;
|
|
285
|
+
sortValues: ReadonlyArray<unknown>;
|
|
286
|
+
}
|
|
287
|
+
interface RankBeforeResult {
|
|
288
|
+
before: number;
|
|
289
|
+
total: number;
|
|
290
|
+
}
|
|
291
|
+
interface RankPageOptions extends RestrictableQueryOptions {
|
|
292
|
+
after?: RankPageRowKey;
|
|
293
|
+
cursor?: null | string;
|
|
294
|
+
partitionKey?: string;
|
|
295
|
+
take?: number;
|
|
296
|
+
}
|
|
297
|
+
interface RankPage {
|
|
298
|
+
continueCursor: null | string;
|
|
299
|
+
isDone: boolean;
|
|
300
|
+
page: Record<string, unknown>[];
|
|
301
|
+
}
|
|
302
|
+
interface RankPageRowKey {
|
|
303
|
+
partitionKey: string;
|
|
304
|
+
rowId: string;
|
|
305
|
+
sortValues: ReadonlyArray<unknown>;
|
|
306
|
+
}
|
|
307
|
+
interface RankPageRow {
|
|
308
|
+
doc: Record<string, unknown>;
|
|
309
|
+
key: RankPageRowKey;
|
|
310
|
+
}
|
|
311
|
+
interface ShardRankPageResult {
|
|
312
|
+
directions: ReadonlyArray<RankDirection>;
|
|
313
|
+
hasMore: boolean;
|
|
314
|
+
rows: ReadonlyArray<RankPageRow>;
|
|
315
|
+
}
|
|
316
|
+
interface PaginationOptions {
|
|
317
|
+
cursor?: null | string;
|
|
318
|
+
endCursor?: null | string;
|
|
319
|
+
numItems: number;
|
|
320
|
+
}
|
|
321
|
+
interface SearchFilterBuilderLike {
|
|
322
|
+
eq: (field: string, value: unknown) => SearchFilterBuilderLike;
|
|
323
|
+
search: (field: string, query: string) => SearchFilterBuilderLike;
|
|
324
|
+
}
|
|
325
|
+
interface GeoFilterBuilderLike {
|
|
326
|
+
near: (point: {
|
|
327
|
+
lat: number;
|
|
328
|
+
lng: number;
|
|
329
|
+
}, radiusMeters: number) => GeoFilterBuilderLike;
|
|
330
|
+
within: (box: {
|
|
331
|
+
ne: {
|
|
332
|
+
lat: number;
|
|
333
|
+
lng: number;
|
|
334
|
+
};
|
|
335
|
+
sw: {
|
|
336
|
+
lat: number;
|
|
337
|
+
lng: number;
|
|
338
|
+
};
|
|
339
|
+
}) => GeoFilterBuilderLike;
|
|
340
|
+
}
|
|
341
|
+
interface TableReaderLike {
|
|
342
|
+
collect: () => Promise<Record<string, unknown>[]>;
|
|
343
|
+
filter: (predicate: (document: Record<string, unknown>) => boolean) => TableReaderLike;
|
|
344
|
+
first: () => Promise<Record<string, unknown> | null>;
|
|
345
|
+
order: (direction: "asc" | "desc") => TableReaderLike;
|
|
346
|
+
paginate: (options: PaginationOptions) => Promise<QueryPage>;
|
|
347
|
+
take: (limit: number) => Promise<Record<string, unknown>[]>;
|
|
348
|
+
unique: () => Promise<Record<string, unknown> | null>;
|
|
349
|
+
withGeoIndex: (indexName: string, build: (q: GeoFilterBuilderLike) => GeoFilterBuilderLike) => TableReaderLike;
|
|
350
|
+
withIndex: (indexName: string, range?: (q: IndexRangeBuilderLike) => IndexRangeBuilderLike) => TableReaderLike;
|
|
351
|
+
withSearchIndex: (indexName: string, search: (q: SearchFilterBuilderLike) => SearchFilterBuilderLike) => TableReaderLike;
|
|
352
|
+
}
|
|
353
|
+
interface IndexRangeBuilderLike {
|
|
354
|
+
eq: (field: string, value: unknown) => IndexRangeBuilderLike;
|
|
355
|
+
gt: (field: string, value: unknown) => IndexRangeBuilderLike;
|
|
356
|
+
gte: (field: string, value: unknown) => IndexRangeBuilderLike;
|
|
357
|
+
lt: (field: string, value: unknown) => IndexRangeBuilderLike;
|
|
358
|
+
lte: (field: string, value: unknown) => IndexRangeBuilderLike;
|
|
359
|
+
}
|
|
360
|
+
type BroadcastDelta = (delta: MutationDelta) => void;
|
|
361
|
+
type ReadHook = (table: string, idOrScan?: string) => void;
|
|
362
|
+
interface LifecycleEvent {
|
|
363
|
+
connectionId: string;
|
|
364
|
+
context?: Record<string, unknown>;
|
|
365
|
+
shardKey: string;
|
|
366
|
+
userId: string | null;
|
|
367
|
+
}
|
|
368
|
+
interface LifecycleDispatchInfo {
|
|
369
|
+
event: LifecycleEvent;
|
|
370
|
+
identity: Record<string, unknown> | undefined;
|
|
371
|
+
userId: string | undefined;
|
|
372
|
+
}
|
|
373
|
+
interface MutationDelta {
|
|
374
|
+
key: string;
|
|
375
|
+
op: "insert" | "update" | "delete";
|
|
376
|
+
row?: Record<string, unknown>;
|
|
377
|
+
table: string;
|
|
378
|
+
}
|
|
379
|
+
interface DatabaseWriterLike {
|
|
380
|
+
aggregate: (tableName: string, options: AggregateOptions) => Promise<AggregateResult>;
|
|
381
|
+
asId?: (tableName: string, id: string) => string;
|
|
382
|
+
count: (tableName: string, where?: RestrictableQueryOptions | WhereInput) => Promise<number>;
|
|
383
|
+
delete: (id: string, expectedTable?: string, options?: {
|
|
384
|
+
hard?: boolean;
|
|
385
|
+
}) => Promise<void>;
|
|
386
|
+
deleteAll?: (tableName: string, options?: {
|
|
387
|
+
chunkSize?: number;
|
|
388
|
+
hard?: boolean;
|
|
389
|
+
}) => Promise<{
|
|
390
|
+
deleted: number;
|
|
391
|
+
}>;
|
|
392
|
+
deleteMany?: (ids: ReadonlyArray<string>, options?: {
|
|
393
|
+
limit?: number;
|
|
394
|
+
}, expectedTable?: string) => Promise<{
|
|
395
|
+
deleted: number;
|
|
396
|
+
}>;
|
|
397
|
+
deleteWhere?: (tableName: string, where: WhereInput, options?: {
|
|
398
|
+
limit?: number;
|
|
399
|
+
}) => Promise<{
|
|
400
|
+
deleted: number;
|
|
401
|
+
}>;
|
|
402
|
+
findFirst: (tableName: string, args?: QueryArgs) => Promise<Record<string, unknown> | null>;
|
|
403
|
+
findFirstOrThrow: (tableName: string, args?: QueryArgs) => Promise<Record<string, unknown>>;
|
|
404
|
+
findMany: (tableName: string, args?: QueryArgs) => Promise<QueryPage>;
|
|
405
|
+
get: (id: string, expectedTable?: string) => Promise<Record<string, unknown> | null>;
|
|
406
|
+
groupBy: (tableName: string, options: GroupByOptions) => Promise<ReadonlyArray<GroupByEntry>>;
|
|
407
|
+
insert: (tableName: string, document: Record<string, unknown>, options?: {
|
|
408
|
+
allowExplicitId?: boolean;
|
|
409
|
+
clientId?: string;
|
|
410
|
+
}) => Promise<string>;
|
|
411
|
+
insertMany?: (tableName: string, documents: ReadonlyArray<Record<string, unknown>>, options?: {
|
|
412
|
+
limit?: number;
|
|
413
|
+
skipDuplicates?: boolean;
|
|
414
|
+
}) => Promise<(string | null)[]>;
|
|
415
|
+
insertManyUnsafe?: (tableName: string, documents: ReadonlyArray<Record<string, unknown>>, options?: {
|
|
416
|
+
allowExplicitId?: boolean;
|
|
417
|
+
limit?: number;
|
|
418
|
+
}) => Promise<string[]>;
|
|
419
|
+
lookupById?: (id: string, expectedTable?: string) => Promise<null | {
|
|
420
|
+
row: Record<string, unknown>;
|
|
421
|
+
tableName: string;
|
|
422
|
+
}>;
|
|
423
|
+
normalizeId: (tableName: string, id: string) => null | string;
|
|
424
|
+
patch: (id: string, patch: Record<string, unknown>, expectedTable?: string) => Promise<void>;
|
|
425
|
+
patchMany?: (patches: ReadonlyArray<{
|
|
426
|
+
id: string;
|
|
427
|
+
patch: Record<string, unknown>;
|
|
428
|
+
}>, options?: {
|
|
429
|
+
limit?: number;
|
|
430
|
+
}, expectedTable?: string) => Promise<{
|
|
431
|
+
patched: number;
|
|
432
|
+
}>;
|
|
433
|
+
patchWhere?: (tableName: string, args: {
|
|
434
|
+
patch: Record<string, unknown>;
|
|
435
|
+
where: WhereInput;
|
|
436
|
+
}, options?: {
|
|
437
|
+
limit?: number;
|
|
438
|
+
}) => Promise<{
|
|
439
|
+
patched: number;
|
|
440
|
+
}>;
|
|
441
|
+
query: (tableName: string) => TableReaderLike;
|
|
442
|
+
rank: (tableName: string, indexName: string, options: RankOptions) => Promise<null | RankResult>;
|
|
443
|
+
rankBefore?: (tableName: string, indexName: string, options: RankBeforeOptions) => Promise<RankBeforeResult>;
|
|
444
|
+
rankPage: (tableName: string, indexName: string, options?: RankPageOptions) => Promise<RankPage>;
|
|
445
|
+
rankPageRows?: (tableName: string, indexName: string, options?: RankPageOptions) => Promise<ShardRankPageResult>;
|
|
446
|
+
replace: (id: string, document: Record<string, unknown>, expectedTable?: string, options?: {
|
|
447
|
+
allowExplicitId?: boolean;
|
|
448
|
+
}) => Promise<void>;
|
|
449
|
+
restore?: (id: string, expectedTable?: string) => Promise<void>;
|
|
450
|
+
system?: SystemDatabaseReader;
|
|
451
|
+
wipeShard?: (options?: {
|
|
452
|
+
chunkSize?: number;
|
|
453
|
+
exclude?: ReadonlyArray<string>;
|
|
454
|
+
tables?: ReadonlyArray<string>;
|
|
455
|
+
}) => Promise<{
|
|
456
|
+
deleted: number;
|
|
457
|
+
tables: Record<string, number>;
|
|
458
|
+
}>;
|
|
459
|
+
}
|
|
460
|
+
interface ExportRow {
|
|
461
|
+
doc: Record<string, unknown>;
|
|
462
|
+
table: string;
|
|
463
|
+
}
|
|
464
|
+
interface ImportError {
|
|
465
|
+
code: string;
|
|
466
|
+
line: number;
|
|
467
|
+
message: string;
|
|
468
|
+
table: string;
|
|
469
|
+
}
|
|
470
|
+
interface ExportShardArgs {
|
|
471
|
+
batchSize?: number;
|
|
472
|
+
tables?: ReadonlyArray<string>;
|
|
473
|
+
}
|
|
474
|
+
interface ImportShardArgs {
|
|
475
|
+
rows: ReadonlyArray<ExportRow>;
|
|
476
|
+
startLine?: number;
|
|
477
|
+
}
|
|
478
|
+
interface ImportShardResult {
|
|
479
|
+
conflicts: number;
|
|
480
|
+
errors: ImportError[];
|
|
481
|
+
inserted: Record<string, number>;
|
|
482
|
+
}
|
|
483
|
+
declare const selectExportTables: (schema: SchemaLike, requested?: ReadonlyArray<string>) => string[];
|
|
484
|
+
declare const exportShardTable: (writer: DatabaseWriterLike, table: string, batchSize?: number) => AsyncGenerator<ExportRow, void, undefined>;
|
|
485
|
+
declare const exportShardRows: (writer: DatabaseWriterLike, schema: SchemaLike, args: ExportShardArgs) => AsyncGenerator<ExportRow, void, undefined>;
|
|
486
|
+
declare const validateImportRow: (schema: SchemaLike, table: string, record: Record<string, unknown>) => string | undefined;
|
|
487
|
+
declare const importShardRows: (writer: DatabaseWriterLike, schema: SchemaLike, args: ImportShardArgs) => Promise<ImportShardResult>;
|
|
488
|
+
interface ExportShardAdminArgs {
|
|
489
|
+
batchSize?: number;
|
|
490
|
+
tables?: ReadonlyArray<string>;
|
|
491
|
+
}
|
|
492
|
+
interface ImportShardAdminArgs {
|
|
493
|
+
rows: ReadonlyArray<ExportRow>;
|
|
494
|
+
startLine?: number;
|
|
495
|
+
}
|
|
496
|
+
declare const parseExportShardArgs: (args: Record<string, unknown>) => ExportShardAdminArgs;
|
|
497
|
+
declare const parseImportShardArgs: (args: Record<string, unknown>) => ImportShardAdminArgs;
|
|
498
|
+
declare const matchesStaticWhere: (document: Record<string, unknown>, predicate: Record<string, unknown>) => boolean;
|
|
499
|
+
declare const normalizeCountArgument: (argument: RestrictableQueryOptions | undefined | WhereInput) => RestrictableQueryOptions;
|
|
500
|
+
declare const AGGREGATE_SQL_FUNCTION: Record<string, string>;
|
|
501
|
+
declare const aggregateSqlFunction: (op: string) => string;
|
|
502
|
+
declare const throwingScheduler: SchedulerLike;
|
|
503
|
+
declare const aggregateTableName: (table: string, indexName: string) => string;
|
|
504
|
+
declare const coerceAggregateNumber: (value: unknown) => number | undefined;
|
|
505
|
+
interface AggregateTally {
|
|
506
|
+
count: number;
|
|
507
|
+
value: null | number;
|
|
508
|
+
}
|
|
509
|
+
declare const foldAggregateTally: (tallies: Map<string, AggregateTally>, encoded: string, index: AggregateIndexDefinitionLike, record: Record<string, unknown>) => void;
|
|
510
|
+
declare const readAggregateValue: (op: string, row: {
|
|
511
|
+
count: number;
|
|
512
|
+
value: null | number;
|
|
513
|
+
} | undefined) => null | number;
|
|
514
|
+
declare const encodeAggregateKey: (by: ReadonlyArray<string>, source: Record<string, unknown>) => string;
|
|
515
|
+
declare class CountRlsUnsupportedError extends LunoraError {
|
|
516
|
+
constructor(table?: string);
|
|
517
|
+
}
|
|
518
|
+
declare const mergeWhere: (left: undefined | WhereInput, right: undefined | WhereInput) => undefined | WhereInput;
|
|
519
|
+
declare const planAggregateLookup: (index: AggregateIndexDefinitionLike, requestedWhere: Record<string, unknown> | undefined) => Record<string, unknown> | undefined;
|
|
520
|
+
declare const selectIndexForCount: (indexes: ReadonlyArray<AggregateIndexDefinitionLike>, requestedWhere: Record<string, unknown> | undefined) => undefined | {
|
|
521
|
+
index: AggregateIndexDefinitionLike;
|
|
522
|
+
key: Record<string, unknown>;
|
|
523
|
+
};
|
|
524
|
+
declare const selectIndexForAggregate: (indexes: ReadonlyArray<AggregateIndexDefinitionLike>, op: AggregateOp, field: string, requestedWhere: Record<string, unknown> | undefined) => undefined | {
|
|
525
|
+
index: AggregateIndexDefinitionLike;
|
|
526
|
+
key: Record<string, unknown>;
|
|
527
|
+
};
|
|
528
|
+
declare const selectIndexForGroupBy: (indexes: ReadonlyArray<AggregateIndexDefinitionLike>, op: AggregateOp, field: string | undefined, by: ReadonlyArray<string>, requestedWhere: Record<string, unknown> | undefined) => undefined | {
|
|
529
|
+
index: AggregateIndexDefinitionLike;
|
|
530
|
+
partial: Record<string, unknown>;
|
|
531
|
+
};
|
|
532
|
+
declare const stableStringify: (value: unknown) => string;
|
|
533
|
+
declare const stableWireKey: (value: unknown) => string;
|
|
534
|
+
interface CacheEntry {
|
|
535
|
+
bytes: number;
|
|
536
|
+
deps: Set<string>;
|
|
537
|
+
lastUsed: number;
|
|
538
|
+
result: unknown;
|
|
539
|
+
subscribers: Set<string>;
|
|
540
|
+
}
|
|
541
|
+
interface ReactiveCacheOptions {
|
|
542
|
+
maxBytes?: number;
|
|
543
|
+
maxEntries?: number;
|
|
544
|
+
now?: () => number;
|
|
545
|
+
}
|
|
546
|
+
declare class ReactiveCache {
|
|
547
|
+
private readonly entries;
|
|
548
|
+
private readonly tableIndex;
|
|
549
|
+
private totalBytes;
|
|
550
|
+
private hits;
|
|
551
|
+
private misses;
|
|
552
|
+
private evictions;
|
|
553
|
+
private readonly maxEntries;
|
|
554
|
+
private readonly maxBytes;
|
|
555
|
+
private readonly now;
|
|
556
|
+
private monotonic;
|
|
557
|
+
constructor(options?: ReactiveCacheOptions);
|
|
558
|
+
run<R>(key: string, deps: Set<string>, run: () => Promise<R>): Promise<R>;
|
|
559
|
+
invalidate(table: string, id: string): string[];
|
|
560
|
+
invalidateTable(table: string): string[];
|
|
561
|
+
subscribe(key: string, subscriberId: string): void;
|
|
562
|
+
unsubscribe(key: string, subscriberId: string): void;
|
|
563
|
+
size(): {
|
|
564
|
+
bytes: number;
|
|
565
|
+
entries: number;
|
|
566
|
+
};
|
|
567
|
+
clear(): void;
|
|
568
|
+
subscribers(key: string): string[];
|
|
569
|
+
stats(): {
|
|
570
|
+
bytes: number;
|
|
571
|
+
entries: number;
|
|
572
|
+
evictions: number;
|
|
573
|
+
hits: number;
|
|
574
|
+
misses: number;
|
|
575
|
+
};
|
|
576
|
+
private collectAndDrop;
|
|
577
|
+
private dropEntry;
|
|
578
|
+
private evict;
|
|
579
|
+
}
|
|
580
|
+
declare const reactiveCacheKey: (functionPath: string, args: Record<string, unknown>, identity: null | string) => string;
|
|
581
|
+
interface RunTriggersOptions {
|
|
582
|
+
ctx: TriggerContextLike;
|
|
583
|
+
event: TriggerEventLike;
|
|
584
|
+
op: TriggerOpLike;
|
|
585
|
+
schema: SchemaLike;
|
|
586
|
+
tableName: string;
|
|
587
|
+
timing: TriggerTimingLike;
|
|
588
|
+
}
|
|
589
|
+
declare const runTriggers: (options: RunTriggersOptions) => Promise<void>;
|
|
590
|
+
declare const hasTrigger: (schema: SchemaLike, tableName: string, op: TriggerOpLike) => boolean;
|
|
591
|
+
declare const backfillAggregateIndexes: (sql: SqlExec, schema: SchemaLike) => void;
|
|
592
|
+
declare const backfillRankIndexes: (sql: SqlExec, schema: SchemaLike) => void;
|
|
593
|
+
declare const backfillSearchIndexesForTable: (sql: SqlExec, tableName: string, definition: {
|
|
594
|
+
searchIndexes?: ReadonlyArray<SearchIndexDefinitionLike>;
|
|
595
|
+
}) => void;
|
|
596
|
+
declare const backfillSearchIndexes: (sql: SqlExec, schema: SchemaLike) => void;
|
|
597
|
+
declare const CDC_LOG_TABLE = "__cdc_log";
|
|
598
|
+
interface CdcChange {
|
|
599
|
+
doc?: Record<string, unknown>;
|
|
600
|
+
id: string;
|
|
601
|
+
op: "delete" | "insert" | "update";
|
|
602
|
+
seq: number;
|
|
603
|
+
table: string;
|
|
604
|
+
ts: number;
|
|
605
|
+
}
|
|
606
|
+
declare const migrateCdcLog: (sql: SqlExec) => void;
|
|
607
|
+
declare const appendCdcChange: (sql: SqlExec, ts: number, table: string, id: string, op: CdcChange["op"], doc: Record<string, unknown> | undefined) => void;
|
|
608
|
+
declare const readCdcChanges: (sql: SqlExec, options?: {
|
|
609
|
+
limit?: number;
|
|
610
|
+
sinceSeq?: number;
|
|
611
|
+
tables?: ReadonlySet<string>;
|
|
612
|
+
}) => {
|
|
613
|
+
changes: CdcChange[];
|
|
614
|
+
cursor: number;
|
|
615
|
+
};
|
|
616
|
+
declare const trimCdcChanges: (sql: SqlExec, throughSeq: number) => void;
|
|
617
|
+
declare const readCdcCursor: (sql: SqlExec) => number;
|
|
618
|
+
declare const minCdcSeq: (sql: SqlExec) => number | undefined;
|
|
619
|
+
declare const CDC_META_TABLE = "__cdc_meta";
|
|
620
|
+
declare const migrateCdcMeta: (sql: SqlExec) => void;
|
|
621
|
+
declare const readCdcEpoch: (sql: SqlExec) => string;
|
|
622
|
+
declare const bumpCdcEpoch: (sql: SqlExec) => string;
|
|
623
|
+
declare const applyCdcChanges: (writer: DatabaseWriterLike, changes: ReadonlyArray<CdcChange>) => Promise<void>;
|
|
624
|
+
declare const CLIENT_WATERMARK_TABLE = "__client_watermark";
|
|
625
|
+
declare const migrateClientWatermark: (sql: SqlExec) => void;
|
|
626
|
+
declare const readClientWatermark: (sql: SqlExec, identity: string, clientId: string) => number;
|
|
627
|
+
declare const advanceClientWatermark: (sql: SqlExec, identity: string, clientId: string, mutationId: number) => void;
|
|
628
|
+
declare const GLOBAL_SHAPE_SNAPSHOT_TABLE = "__global_shape_snapshot";
|
|
629
|
+
declare const migrateGlobalShapeSnapshot: (sql: SqlExec) => void;
|
|
630
|
+
declare const readGlobalShapeSnapshot: (sql: SqlExec, connectionId: string, subId: string) => Map<string, string>;
|
|
631
|
+
declare const writeGlobalShapeSnapshot: (sql: SqlExec, connectionId: string, subId: string, snapshot: Map<string, string>) => void;
|
|
632
|
+
declare const deleteGlobalShapeSnapshot: (sql: SqlExec, connectionId: string, subId: string) => void;
|
|
633
|
+
declare const deleteGlobalShapeSnapshotsForConnection: (sql: SqlExec, connectionId: string) => void;
|
|
634
|
+
declare const IDEMPOTENCY_TABLE = "__idempotency";
|
|
635
|
+
interface IdempotentRecord {
|
|
636
|
+
resultJson: string;
|
|
637
|
+
ts: number;
|
|
638
|
+
}
|
|
639
|
+
declare const migrateIdempotency: (sql: SqlExec) => void;
|
|
640
|
+
declare const readIdempotent: (sql: SqlExec, identity: string, mutationId: string) => IdempotentRecord | undefined;
|
|
641
|
+
declare const writeIdempotent: (sql: SqlExec, identity: string, mutationId: string, resultJson: string, ts: number) => void;
|
|
642
|
+
declare const trimIdempotent: (sql: SqlExec, olderThanTs: number) => void;
|
|
643
|
+
declare const runShardMigrations: (sql: SqlExec, schema: SchemaLike, options?: {
|
|
644
|
+
cdc?: boolean;
|
|
645
|
+
schemaSnapshot?: {
|
|
646
|
+
hash: string;
|
|
647
|
+
json: string;
|
|
648
|
+
};
|
|
649
|
+
}) => void;
|
|
650
|
+
/**
|
|
651
|
+
* How far a search companion's backfill has progressed, and what the next pass
|
|
652
|
+
* should do about it.
|
|
653
|
+
*
|
|
654
|
+
* Neither stored analysis nor query policy, which is why it is its own module
|
|
655
|
+
* rather than a third responsibility bolted onto one of them: it is *progress*,
|
|
656
|
+
* the one piece of search state that is written as the index is built rather
|
|
657
|
+
* than decided when it is read.
|
|
658
|
+
*
|
|
659
|
+
* The policy below is shared because when each engine owned a copy they
|
|
660
|
+
* immediately disagreed about exactly the two cases that matter — whether a row
|
|
661
|
+
* with no recorded profile may be resumed (it may not; nothing says what
|
|
662
|
+
* analyzed it) and whether a never-started index is worth wiping (it is not;
|
|
663
|
+
* there is nothing in it).
|
|
664
|
+
*/
|
|
665
|
+
/**
|
|
666
|
+
* How far a companion's backfill has progressed, and under which analysis.
|
|
667
|
+
* Declared here rather than beside either engine's state table: both record the
|
|
668
|
+
* same three facts, and the decisions made from them are the shared policy
|
|
669
|
+
* below.
|
|
670
|
+
*/
|
|
671
|
+
interface SearchBackfillState {
|
|
672
|
+
/** Last `id` indexed, or `undefined` when no page has run yet. */
|
|
673
|
+
cursor: string | undefined;
|
|
674
|
+
/** True once a page came back short — the table is fully indexed. */
|
|
675
|
+
done: boolean;
|
|
676
|
+
/** Analyzer profile the stored rows were built with; `undefined` predates profile tracking. */
|
|
677
|
+
profile: string | undefined;
|
|
678
|
+
}
|
|
679
|
+
declare const SEARCH_STATE_TABLE = "__lunora_search_state";
|
|
680
|
+
declare const migrateSearchState: (sql: SqlExec) => void;
|
|
681
|
+
declare const readSearchBackfillState: (sql: SqlExec, companion: string) => SearchBackfillState;
|
|
682
|
+
declare const writeSearchBackfillState: (sql: SqlExec, companion: string, cursor: string | undefined, done: boolean, profile: string) => void;
|
|
683
|
+
interface ShapeRow {
|
|
684
|
+
doc: Record<string, unknown>;
|
|
685
|
+
id: string;
|
|
686
|
+
}
|
|
687
|
+
declare const selectShapeRows: (sql: SqlExec, table: string, effectiveWhere: WhereInput | undefined) => ShapeRow[];
|
|
688
|
+
declare const selectShapeMemberIds: (sql: SqlExec, table: string, effectiveWhere: WhereInput | undefined, ids: ReadonlyArray<string>) => Set<string>;
|
|
689
|
+
interface SqlExec {
|
|
690
|
+
exec: <Row = Record<string, unknown>>(sql: string, ...params: unknown[]) => SqlCursor<Row>;
|
|
691
|
+
}
|
|
692
|
+
interface SqlCursor<Row> extends Iterable<Row> {
|
|
693
|
+
one: () => Row;
|
|
694
|
+
toArray: () => Row[];
|
|
695
|
+
}
|
|
696
|
+
type IndexUseHook = (table: string, indexName: string, kind: "geo" | "index" | "rank" | "search") => void;
|
|
697
|
+
type Clock = () => number;
|
|
698
|
+
type IdGenerator = () => string;
|
|
699
|
+
declare const assertValidClientId: (clientId: string) => void;
|
|
700
|
+
interface WriteEvent {
|
|
701
|
+
doc?: Record<string, unknown>;
|
|
702
|
+
id: string;
|
|
703
|
+
op: "delete" | "insert" | "update";
|
|
704
|
+
table: string;
|
|
705
|
+
}
|
|
706
|
+
type WriteHook = (event: WriteEvent) => Promise<void> | void;
|
|
707
|
+
interface CtxDbOptions {
|
|
708
|
+
auth?: ServerDefaultContextLike["auth"];
|
|
709
|
+
broadcast?: BroadcastDelta;
|
|
710
|
+
cache?: ReactiveCache;
|
|
711
|
+
cdc?: boolean;
|
|
712
|
+
clock?: Clock;
|
|
713
|
+
enforceRls?: boolean;
|
|
714
|
+
globalDb?: DatabaseWriterLike;
|
|
715
|
+
idGenerator?: IdGenerator;
|
|
716
|
+
maxRelationKeys?: number;
|
|
717
|
+
onIndexUse?: IndexUseHook;
|
|
718
|
+
onRead?: ReadHook;
|
|
719
|
+
onWrite?: WriteHook;
|
|
720
|
+
relationExistsPushDown?: "always" | "auto" | "never";
|
|
721
|
+
scheduler?: SchedulerLike;
|
|
722
|
+
schema: SchemaLike;
|
|
723
|
+
sql: SqlExec;
|
|
724
|
+
storage?: SystemReaderStorageLike;
|
|
725
|
+
}
|
|
726
|
+
type CountArgs = RestrictableQueryOptions;
|
|
727
|
+
declare class NotUniqueError extends LunoraError {
|
|
728
|
+
constructor(message?: string);
|
|
729
|
+
}
|
|
730
|
+
declare const normalizeIdStructurally: (schema: SchemaLike, tableName: string, id: string) => null | string;
|
|
731
|
+
declare const createShardCtxDb: (options: CtxDbOptions) => DatabaseWriterLike;
|
|
732
|
+
declare const AUDIT_LOG_TABLE = "__lunora_audit__";
|
|
733
|
+
interface AuditEntry {
|
|
734
|
+
detail?: Record<string, unknown>;
|
|
735
|
+
id?: string;
|
|
736
|
+
op: string;
|
|
737
|
+
seq: number;
|
|
738
|
+
table?: string;
|
|
739
|
+
ts: number;
|
|
740
|
+
}
|
|
741
|
+
interface AppendAuditEntry {
|
|
742
|
+
detail?: Record<string, unknown>;
|
|
743
|
+
id?: string;
|
|
744
|
+
op: string;
|
|
745
|
+
table?: string;
|
|
746
|
+
ts: number;
|
|
747
|
+
}
|
|
748
|
+
declare const ensureAuditTable: (sql: SqlExec) => void;
|
|
749
|
+
declare const appendAuditEntry: (sql: SqlExec, entry: AppendAuditEntry) => void;
|
|
750
|
+
declare const readAuditLog: (sql: SqlExec, options?: {
|
|
751
|
+
limit?: number;
|
|
752
|
+
sinceSeq?: number;
|
|
753
|
+
}) => AuditEntry[];
|
|
754
|
+
interface SubscriptionQuery {
|
|
755
|
+
args?: Record<string, unknown>;
|
|
756
|
+
functionPath?: string;
|
|
757
|
+
sinceEpoch?: string;
|
|
758
|
+
sinceSeq?: number;
|
|
759
|
+
table?: string;
|
|
760
|
+
}
|
|
761
|
+
interface ShapeSubscriptionQuery {
|
|
762
|
+
args?: Record<string, unknown>;
|
|
763
|
+
name: string;
|
|
764
|
+
sinceEpoch?: string;
|
|
765
|
+
sinceSeq?: number;
|
|
766
|
+
}
|
|
767
|
+
interface SubscriptionEnvelope {
|
|
768
|
+
clientId?: string;
|
|
769
|
+
context?: Record<string, unknown>;
|
|
770
|
+
data?: unknown;
|
|
771
|
+
id: string;
|
|
772
|
+
query?: SubscriptionQuery;
|
|
773
|
+
shape?: {
|
|
774
|
+
args?: Record<string, unknown>;
|
|
775
|
+
name: string;
|
|
776
|
+
};
|
|
777
|
+
sinceCheckpoint?: number;
|
|
778
|
+
sinceEpoch?: string;
|
|
779
|
+
topic?: string;
|
|
780
|
+
type: "ack" | "connect" | "shape_subscribe" | "shape_unsubscribe" | "stream" | "subscribe" | "unsubscribe" | "whisper" | "whisper_subscribe" | "whisper_unsubscribe";
|
|
781
|
+
}
|
|
782
|
+
interface RpcRequest {
|
|
783
|
+
args?: Record<string, unknown>;
|
|
784
|
+
functionPath: string;
|
|
785
|
+
}
|
|
786
|
+
interface SocketAttachment {
|
|
787
|
+
admin?: boolean;
|
|
788
|
+
clientId?: string;
|
|
789
|
+
connected?: boolean;
|
|
790
|
+
connectionId?: string;
|
|
791
|
+
context?: Record<string, unknown>;
|
|
792
|
+
expiresAt?: number;
|
|
793
|
+
identity?: Record<string, unknown>;
|
|
794
|
+
shapes?: Record<string, ShapeSubscriptionQuery>;
|
|
795
|
+
subs: Record<string, SubscriptionQuery>;
|
|
796
|
+
userId?: string;
|
|
797
|
+
whispers?: string[];
|
|
798
|
+
}
|
|
799
|
+
interface ResolvedShape {
|
|
800
|
+
columns?: ReadonlyArray<string>;
|
|
801
|
+
effectiveWhere?: WhereInput;
|
|
802
|
+
global?: boolean;
|
|
803
|
+
table: string;
|
|
804
|
+
}
|
|
805
|
+
interface SubscriptionIdentity {
|
|
806
|
+
identity?: Record<string, unknown>;
|
|
807
|
+
userId?: string;
|
|
808
|
+
}
|
|
809
|
+
interface ShardSocketLike {
|
|
810
|
+
readonly bufferedAmount?: number;
|
|
811
|
+
close?: (code?: number, reason?: string) => void;
|
|
812
|
+
deserializeAttachment?: () => unknown;
|
|
813
|
+
send: (data: string) => void;
|
|
814
|
+
serializeAttachment?: (value: unknown) => void;
|
|
815
|
+
}
|
|
816
|
+
interface CompanionSyncDeps {
|
|
817
|
+
broadcast: (delta: MutationDelta) => void;
|
|
818
|
+
invalidateCache: (table: string, id: string) => void;
|
|
819
|
+
recordCdc: (table: string, id: string, op: "delete" | "insert" | "update", doc?: Record<string, unknown>) => void;
|
|
820
|
+
schema: SchemaLike;
|
|
821
|
+
sql: SqlExec;
|
|
822
|
+
}
|
|
823
|
+
interface CompanionSync {
|
|
824
|
+
ensureBackfilledForTable: (tableName: string) => void;
|
|
825
|
+
ensureBackfilledIndex: (tableName: string, index: AggregateIndexDefinitionLike) => void;
|
|
826
|
+
ensureRankBackfilled: (tableName: string, index: RankIndexDefinitionLike) => void;
|
|
827
|
+
ensureRankBackfilledForTable: (tableName: string) => void;
|
|
828
|
+
syncAggregates: (tableName: string, previous: Record<string, unknown> | undefined, next: Record<string, unknown> | undefined) => void;
|
|
829
|
+
syncCompanionsForInsert: (tableName: string, id: string, document: Record<string, unknown>) => void;
|
|
830
|
+
syncGeo: (tableName: string, id: string, document: Record<string, unknown> | undefined) => void;
|
|
831
|
+
syncRanks: (tableName: string, id: string, previous: Record<string, unknown> | undefined, next: Record<string, unknown> | undefined) => void;
|
|
832
|
+
syncSearch: (tableName: string, id: string, document: Record<string, unknown> | undefined, previous?: Record<string, unknown>) => void;
|
|
833
|
+
}
|
|
834
|
+
declare const createCompanionSync: (deps: CompanionSyncDeps) => CompanionSync;
|
|
835
|
+
interface RankPageDeps {
|
|
836
|
+
assertRankPartitionLocal: (tableName: string, definition: TableDefinitionLike, index: RankIndexDefinitionLike) => void;
|
|
837
|
+
ensureRankBackfilled: (tableName: string, index: RankIndexDefinitionLike) => void;
|
|
838
|
+
onRead: (table: string, idOrScan?: string) => void;
|
|
839
|
+
rowToDocument: (row: Record<string, unknown> | undefined) => Record<string, unknown> | undefined;
|
|
840
|
+
schema: SchemaLike;
|
|
841
|
+
sql: SqlExec;
|
|
842
|
+
}
|
|
843
|
+
interface RankPageComputation {
|
|
844
|
+
continueCursor: null | string;
|
|
845
|
+
directions: ReadonlyArray<RankDirection>;
|
|
846
|
+
hasMore: boolean;
|
|
847
|
+
rows: {
|
|
848
|
+
doc: Record<string, unknown>;
|
|
849
|
+
key: RankPageRowKey;
|
|
850
|
+
}[];
|
|
851
|
+
}
|
|
852
|
+
declare const hydrateDocsById: (deps: RankPageDeps, tableName: string, ids: ReadonlyArray<string>) => Map<string, Record<string, unknown>>;
|
|
853
|
+
declare const computeRankPage: (deps: RankPageDeps, tableName: string, indexName: string, rankPageOptions: RankPageOptions) => RankPageComputation;
|
|
854
|
+
declare const DATA_MIGRATION_STATE_TABLE = "__lunora_migrations";
|
|
855
|
+
type MigrationDirection = "down" | "up";
|
|
856
|
+
type MigrationStatus = "completed" | "failed" | "in_progress";
|
|
857
|
+
type DataMigrationDocument = Record<string, unknown>;
|
|
858
|
+
type DataMigrationTransform = (document: DataMigrationDocument) => DataMigrationDocument | undefined;
|
|
859
|
+
interface DataMigrationLike {
|
|
860
|
+
readonly batchSize?: number;
|
|
861
|
+
readonly down?: DataMigrationTransform;
|
|
862
|
+
readonly id: string;
|
|
863
|
+
readonly table: string;
|
|
864
|
+
readonly up: DataMigrationTransform;
|
|
865
|
+
}
|
|
866
|
+
interface RunDataMigrationOptions {
|
|
867
|
+
batchSize?: number;
|
|
868
|
+
clock?: () => number;
|
|
869
|
+
direction?: MigrationDirection;
|
|
870
|
+
dryRun?: boolean;
|
|
871
|
+
maxBatches?: number;
|
|
872
|
+
migration: DataMigrationLike;
|
|
873
|
+
onBatch?: (progress: {
|
|
874
|
+
batches: number;
|
|
875
|
+
changed: number;
|
|
876
|
+
processed: number;
|
|
877
|
+
}) => Promise<void> | void;
|
|
878
|
+
sql: SqlExec;
|
|
879
|
+
writer: DatabaseWriterLike;
|
|
880
|
+
}
|
|
881
|
+
interface MigrationRunResult {
|
|
882
|
+
changed: number;
|
|
883
|
+
cursor: null | string;
|
|
884
|
+
direction: MigrationDirection;
|
|
885
|
+
dryRun: boolean;
|
|
886
|
+
id: string;
|
|
887
|
+
processed: number;
|
|
888
|
+
status: MigrationStatus;
|
|
889
|
+
}
|
|
890
|
+
interface MigrationStatusRow {
|
|
891
|
+
changed: number;
|
|
892
|
+
cursor: null | string;
|
|
893
|
+
direction: MigrationDirection;
|
|
894
|
+
error: null | string;
|
|
895
|
+
id: string;
|
|
896
|
+
processed: number;
|
|
897
|
+
startedAt: null | number;
|
|
898
|
+
status: MigrationStatus;
|
|
899
|
+
updatedAt: null | number;
|
|
900
|
+
}
|
|
901
|
+
declare const readMigrationStatus: (sql: SqlExec, id?: string) => MigrationStatusRow[];
|
|
902
|
+
declare const runDataMigration: (options: RunDataMigrationOptions) => Promise<MigrationRunResult>;
|
|
903
|
+
declare const SCAN_DEP = "*scan";
|
|
904
|
+
declare const depKey: (table: string, idOrScan: string) => string;
|
|
905
|
+
declare const tableFromDepKey: (dep: string) => string;
|
|
906
|
+
interface DependencyTracker {
|
|
907
|
+
collect: () => Set<string>;
|
|
908
|
+
recordRead: (table: string, idOrScan: string) => void;
|
|
909
|
+
}
|
|
910
|
+
declare const createDependencyTracker: () => DependencyTracker;
|
|
911
|
+
declare const runSql: <Row = Record<string, unknown>>(sql: SqlExec, query: string, ...params: unknown[]) => SqlCursor<Row>;
|
|
912
|
+
declare const runDrizzle: <Row = Record<string, unknown>>(exec: SqlExec, query: SQL) => SqlCursor<Row>;
|
|
913
|
+
declare const serializeSqlValue: (value: unknown) => unknown;
|
|
914
|
+
declare const DOC_COLUMN = "__doc__";
|
|
915
|
+
declare const geoTableName: (table: string, indexName: string) => string;
|
|
916
|
+
declare const quoteIdentifier: (name: string) => string;
|
|
917
|
+
declare const jsonPath: (field: string) => string;
|
|
918
|
+
declare const jsonPathSql: (field: string) => SQL;
|
|
919
|
+
declare const qualifiedJsonPath: (table: string, field: string) => string;
|
|
920
|
+
declare const qualifiedJsonPathSql: (table: string, field: string) => SQL;
|
|
921
|
+
declare const createIndexSql: (name: string, table: string, columns: SQL, unique: boolean) => SQL;
|
|
922
|
+
declare const AGG_KEY: Name;
|
|
923
|
+
declare const AGG_VALUE: Name;
|
|
924
|
+
declare const AGG_COUNT: Name;
|
|
925
|
+
declare const aggUpsertSql: (aggTable: string, key: unknown, value: unknown, count: unknown, set: SQL) => SQL;
|
|
926
|
+
declare const tableColumns: (definition: TableDefinitionLike) => [string, ColumnMetaLike][];
|
|
927
|
+
declare const rowToDocument: (row: Record<string, unknown> | undefined) => Record<string, unknown> | undefined;
|
|
928
|
+
declare const tryRowToDocument: (row: Record<string, unknown> | undefined) => Record<string, unknown> | undefined;
|
|
929
|
+
declare const isFtsAvailable: (sql: SqlExec) => boolean;
|
|
930
|
+
type SqlEngine = "mysql" | "postgres" | "sqlite";
|
|
931
|
+
interface RenderedSql {
|
|
932
|
+
params: unknown[];
|
|
933
|
+
sql: string;
|
|
934
|
+
}
|
|
935
|
+
declare const renderSql: (engine: SqlEngine, query: SQL) => RenderedSql;
|
|
936
|
+
declare const param: (value: unknown) => SQL;
|
|
937
|
+
interface ExternalSourceDiffResult {
|
|
938
|
+
changes: CdcChange[];
|
|
939
|
+
nextBaseline: Map<string, string>;
|
|
940
|
+
}
|
|
941
|
+
declare const diffExternalSource: (pulled: ReadonlyArray<Record<string, unknown>>, baseline: ReadonlyMap<string, string>, options: {
|
|
942
|
+
columns?: ReadonlyArray<string>;
|
|
943
|
+
table: string;
|
|
944
|
+
}) => ExternalSourceDiffResult;
|
|
945
|
+
declare const normalizeSourceValue: (value: unknown) => unknown;
|
|
946
|
+
declare const normalizeSourceDocument: (document: Record<string, unknown>) => Record<string, unknown>;
|
|
947
|
+
declare const liftSourceId: (row: Record<string, unknown>, options?: {
|
|
948
|
+
idColumn?: string;
|
|
949
|
+
map?: (row: Record<string, unknown>) => Record<string, unknown>;
|
|
950
|
+
}) => Record<string, unknown>;
|
|
951
|
+
interface MaterializeResult {
|
|
952
|
+
applied: number;
|
|
953
|
+
nextBaseline: Map<string, string>;
|
|
954
|
+
}
|
|
955
|
+
interface IncrementalMaterializeResult {
|
|
956
|
+
applied: number;
|
|
957
|
+
}
|
|
958
|
+
declare const materializeExternalRows: (writer: DatabaseWriterLike, pulled: ReadonlyArray<Record<string, unknown>>, baseline: ReadonlyMap<string, string>, options: {
|
|
959
|
+
columns?: ReadonlyArray<string>;
|
|
960
|
+
table: string;
|
|
961
|
+
}) => Promise<MaterializeResult>;
|
|
962
|
+
declare const materializeExternalRowsIncremental: (writer: DatabaseWriterLike, pulled: ReadonlyArray<Record<string, unknown>>, options: {
|
|
963
|
+
columns?: ReadonlyArray<string>;
|
|
964
|
+
deletedIds?: ReadonlySet<string>;
|
|
965
|
+
table: string;
|
|
966
|
+
}) => Promise<IncrementalMaterializeResult>;
|
|
967
|
+
declare const readExternalSourceBaseline: (sql: SqlExec, table: string, columns?: ReadonlyArray<string>) => Map<string, string>;
|
|
968
|
+
declare const runExternalSourceTick: (sql: SqlExec, writer: DatabaseWriterLike, pulled: ReadonlyArray<Record<string, unknown>>, options: {
|
|
969
|
+
columns?: ReadonlyArray<string>;
|
|
970
|
+
table: string;
|
|
971
|
+
}) => Promise<MaterializeResult>;
|
|
972
|
+
interface SourceClientLike {
|
|
973
|
+
query: <Row = Record<string, unknown>>(text: string, parameters?: ReadonlyArray<unknown>) => Promise<Row[]>;
|
|
974
|
+
}
|
|
975
|
+
type SourceRefresh = "manual" | {
|
|
976
|
+
everyMs: number;
|
|
977
|
+
};
|
|
978
|
+
interface SourceCursorLike {
|
|
979
|
+
column: string;
|
|
980
|
+
query: string;
|
|
981
|
+
}
|
|
982
|
+
interface ExternalSourceLike {
|
|
983
|
+
binding: string;
|
|
984
|
+
columns?: ReadonlyArray<string>;
|
|
985
|
+
cursor?: SourceCursorLike;
|
|
986
|
+
idColumn?: string;
|
|
987
|
+
map?: (row: Record<string, unknown>) => Record<string, unknown>;
|
|
988
|
+
mode?: string;
|
|
989
|
+
query: string;
|
|
990
|
+
reconcileEveryMs?: number;
|
|
991
|
+
refresh?: SourceRefresh;
|
|
992
|
+
softDeleteColumn?: string;
|
|
993
|
+
tenantBy?: (shardKey: string) => ReadonlyArray<unknown>;
|
|
994
|
+
}
|
|
995
|
+
declare const isSourceDue: (refresh: SourceRefresh | undefined, lastPolledMs: number | undefined, nowMs: number) => boolean;
|
|
996
|
+
declare const pullExternalSourceTick: (sql: SqlExec, writer: DatabaseWriterLike, client: SourceClientLike, table: string, source: ExternalSourceLike, shardKey: string) => Promise<MaterializeResult>;
|
|
997
|
+
declare const isSoftDeleted: (row: Record<string, unknown>, column: string) => boolean;
|
|
998
|
+
declare const pullExternalSourceIncrementalTick: (sql: SqlExec, writer: DatabaseWriterLike, client: SourceClientLike, table: string, source: ExternalSourceLike, shardKey: string, nowMs: number) => Promise<{
|
|
999
|
+
applied: number;
|
|
1000
|
+
}>;
|
|
1001
|
+
declare const GEO_DEFAULT_PRECISION = 9;
|
|
1002
|
+
interface GeoPoint {
|
|
1003
|
+
lat: number;
|
|
1004
|
+
lng: number;
|
|
1005
|
+
}
|
|
1006
|
+
interface GeoBoundingBox {
|
|
1007
|
+
ne: GeoPoint;
|
|
1008
|
+
sw: GeoPoint;
|
|
1009
|
+
}
|
|
1010
|
+
declare const encodeGeohash: (point: GeoPoint, precision: number) => string;
|
|
1011
|
+
declare const haversineMeters: (a: GeoPoint, b: GeoPoint) => number;
|
|
1012
|
+
declare const coveringGeohashes: (center: GeoPoint, radiusMeters: number) => string[];
|
|
1013
|
+
declare const pointInBoundingBox: (point: GeoPoint, box: GeoBoundingBox) => boolean;
|
|
1014
|
+
declare const boundingBoxCenter: (box: GeoBoundingBox) => GeoPoint;
|
|
1015
|
+
declare const boundingBoxGeohashes: (box: GeoBoundingBox) => string[];
|
|
1016
|
+
declare const ADMIN_FUNCTION_PREFIX = "__lunora_admin__:";
|
|
1017
|
+
declare const RELATION_FUNCTION_PREFIX = "__lunora_relation__:";
|
|
1018
|
+
declare const FLAGS_FUNCTION_PREFIX = "__lunora_flags__:";
|
|
1019
|
+
declare const ADMIN_FUNCTIONS: {
|
|
1020
|
+
readonly applyCdc: "__lunora_admin__:applyCdc";
|
|
1021
|
+
readonly aiAvailable: "__lunora_admin__:aiAvailable";
|
|
1022
|
+
readonly aiChartConfig: "__lunora_admin__:aiChartConfig";
|
|
1023
|
+
readonly aiGenerateSql: "__lunora_admin__:aiGenerateSql";
|
|
1024
|
+
readonly aiTableFilter: "__lunora_admin__:aiTableFilter";
|
|
1025
|
+
readonly assignIssue: "__lunora_admin__:assignIssue";
|
|
1026
|
+
readonly backRelationCounts: "__lunora_admin__:backRelationCounts";
|
|
1027
|
+
readonly cdcSync: "__lunora_admin__:cdcSync";
|
|
1028
|
+
readonly clearCapturedMail: "__lunora_admin__:clearCapturedMail";
|
|
1029
|
+
readonly clearQueueMessages: "__lunora_admin__:clearQueueMessages";
|
|
1030
|
+
readonly clearTable: "__lunora_admin__:clearTable";
|
|
1031
|
+
readonly createWorkflowInstance: "__lunora_admin__:createWorkflowInstance";
|
|
1032
|
+
readonly deleteRows: "__lunora_admin__:deleteRows";
|
|
1033
|
+
readonly describeTable: "__lunora_admin__:describeTable";
|
|
1034
|
+
readonly describeTables: "__lunora_admin__:describeTables";
|
|
1035
|
+
readonly explainIssue: "__lunora_admin__:explainIssue";
|
|
1036
|
+
readonly exportShard: "__lunora_admin__:exportShard";
|
|
1037
|
+
readonly facetColumn: "__lunora_admin__:facetColumn";
|
|
1038
|
+
readonly getAdvisories: "__lunora_admin__:getAdvisories";
|
|
1039
|
+
readonly getAdvisorProcedures: "__lunora_admin__:getAdvisorProcedures";
|
|
1040
|
+
readonly getAuditLog: "__lunora_admin__:getAuditLog";
|
|
1041
|
+
readonly getAuthMetrics: "__lunora_admin__:getAuthMetrics";
|
|
1042
|
+
readonly getCapturedMail: "__lunora_admin__:getCapturedMail";
|
|
1043
|
+
readonly getFanoutMetrics: "__lunora_admin__:getFanoutMetrics";
|
|
1044
|
+
readonly getFunctionStats: "__lunora_admin__:getFunctionStats";
|
|
1045
|
+
readonly getIssues: "__lunora_admin__:getIssues";
|
|
1046
|
+
readonly getMetricHistory: "__lunora_admin__:getMetricHistory";
|
|
1047
|
+
readonly getMetricSeries: "__lunora_admin__:getMetricSeries";
|
|
1048
|
+
readonly listSubscriptions: "__lunora_admin__:listSubscriptions";
|
|
1049
|
+
readonly listTableIndexes: "__lunora_admin__:listTableIndexes";
|
|
1050
|
+
readonly getLogs: "__lunora_admin__:getLogs";
|
|
1051
|
+
readonly getMetrics: "__lunora_admin__:getMetrics";
|
|
1052
|
+
readonly getPitrBookmark: "__lunora_admin__:getPitrBookmark";
|
|
1053
|
+
readonly getQueryInsights: "__lunora_admin__:getQueryInsights";
|
|
1054
|
+
readonly getQueueMessages: "__lunora_admin__:getQueueMessages";
|
|
1055
|
+
readonly getRequestLog: "__lunora_admin__:getRequestLog";
|
|
1056
|
+
readonly getSecurityAudit: "__lunora_admin__:getSecurityAudit";
|
|
1057
|
+
readonly getSettings: "__lunora_admin__:getSettings";
|
|
1058
|
+
readonly getTraces: "__lunora_admin__:getTraces";
|
|
1059
|
+
readonly getWorkflowInstanceStatus: "__lunora_admin__:getWorkflowInstanceStatus";
|
|
1060
|
+
readonly ignoreIssue: "__lunora_admin__:ignoreIssue";
|
|
1061
|
+
readonly importShard: "__lunora_admin__:importShard";
|
|
1062
|
+
readonly listFlags: "__lunora_admin__:listFlags";
|
|
1063
|
+
readonly listQueues: "__lunora_admin__:listQueues";
|
|
1064
|
+
readonly lintSql: "__lunora_admin__:lintSql";
|
|
1065
|
+
readonly listTables: "__lunora_admin__:listTables";
|
|
1066
|
+
readonly listWorkflows: "__lunora_admin__:listWorkflows";
|
|
1067
|
+
readonly maskPolicies: "__lunora_admin__:maskPolicies";
|
|
1068
|
+
readonly migrationStatus: "__lunora_admin__:migrationStatus";
|
|
1069
|
+
readonly pitrRestore: "__lunora_admin__:pitrRestore";
|
|
1070
|
+
readonly rankBefore: "__lunora_admin__:rankBefore";
|
|
1071
|
+
readonly rankPage: "__lunora_admin__:rankPage";
|
|
1072
|
+
readonly readTablePage: "__lunora_admin__:readTablePage";
|
|
1073
|
+
readonly recordAuthEvent: "__lunora_admin__:recordAuthEvent";
|
|
1074
|
+
readonly recordContainerEvent: "__lunora_admin__:recordContainerEvent";
|
|
1075
|
+
readonly recordMail: "__lunora_admin__:recordMail";
|
|
1076
|
+
readonly recordQueueMessage: "__lunora_admin__:recordQueueMessage";
|
|
1077
|
+
readonly replayQueueMessage: "__lunora_admin__:replayQueueMessage";
|
|
1078
|
+
readonly resolveIssue: "__lunora_admin__:resolveIssue";
|
|
1079
|
+
readonly rlsPolicies: "__lunora_admin__:rlsPolicies";
|
|
1080
|
+
readonly schemaHistory: "__lunora_admin__:schemaHistory";
|
|
1081
|
+
readonly schemaVersion: "__lunora_admin__:schemaVersion";
|
|
1082
|
+
readonly runAs: "__lunora_admin__:runAs";
|
|
1083
|
+
readonly runMigration: "__lunora_admin__:runMigration";
|
|
1084
|
+
readonly runSql: "__lunora_admin__:runSql";
|
|
1085
|
+
readonly sendQueueMessage: "__lunora_admin__:sendQueueMessage";
|
|
1086
|
+
readonly sendTestMail: "__lunora_admin__:sendTestMail";
|
|
1087
|
+
readonly setIssueSeverity: "__lunora_admin__:setIssueSeverity";
|
|
1088
|
+
readonly storageOrphans: "__lunora_admin__:storageOrphans";
|
|
1089
|
+
readonly storageReferences: "__lunora_admin__:storageReferences";
|
|
1090
|
+
readonly storageRules: "__lunora_admin__:storageRules";
|
|
1091
|
+
readonly studioFeatures: "__lunora_admin__:studioFeatures";
|
|
1092
|
+
readonly writeRow: "__lunora_admin__:writeRow";
|
|
1093
|
+
};
|
|
1094
|
+
interface TableInfo {
|
|
1095
|
+
name: string;
|
|
1096
|
+
rowCount: number;
|
|
1097
|
+
}
|
|
1098
|
+
interface AuditLogResult {
|
|
1099
|
+
entries: AuditEntry[];
|
|
1100
|
+
}
|
|
1101
|
+
interface SubscriptionInfo {
|
|
1102
|
+
args?: Record<string, unknown>;
|
|
1103
|
+
functionPath?: string;
|
|
1104
|
+
table?: string;
|
|
1105
|
+
}
|
|
1106
|
+
interface SubscriptionConnection {
|
|
1107
|
+
admin: boolean;
|
|
1108
|
+
id: number;
|
|
1109
|
+
subscriptions: SubscriptionInfo[];
|
|
1110
|
+
}
|
|
1111
|
+
interface SubscriptionsResult {
|
|
1112
|
+
connections: SubscriptionConnection[];
|
|
1113
|
+
totalConnections: number;
|
|
1114
|
+
totalSubscriptions: number;
|
|
1115
|
+
}
|
|
1116
|
+
interface FunctionScanAttribution {
|
|
1117
|
+
scans: number;
|
|
1118
|
+
table: string;
|
|
1119
|
+
}
|
|
1120
|
+
interface FunctionCallStat {
|
|
1121
|
+
calls: number;
|
|
1122
|
+
conflicts: number;
|
|
1123
|
+
errors: number;
|
|
1124
|
+
lastCalledAt: number;
|
|
1125
|
+
lastErrorAt: null | number;
|
|
1126
|
+
lastErrorMessage: null | string;
|
|
1127
|
+
maxDurationMs: number;
|
|
1128
|
+
path: string;
|
|
1129
|
+
scannedTables: FunctionScanAttribution[];
|
|
1130
|
+
scans: number;
|
|
1131
|
+
totalDurationMs: number;
|
|
1132
|
+
}
|
|
1133
|
+
interface TableIndexInfo {
|
|
1134
|
+
fields: string[];
|
|
1135
|
+
name: string;
|
|
1136
|
+
type: "geo" | "index" | "rank" | "search" | "vector";
|
|
1137
|
+
unique?: boolean;
|
|
1138
|
+
}
|
|
1139
|
+
interface TableIndexesResult {
|
|
1140
|
+
indexes: TableIndexInfo[];
|
|
1141
|
+
}
|
|
1142
|
+
interface ColumnMeta {
|
|
1143
|
+
isStorage?: boolean;
|
|
1144
|
+
name: string;
|
|
1145
|
+
optional: boolean;
|
|
1146
|
+
pk?: boolean;
|
|
1147
|
+
ref?: string;
|
|
1148
|
+
type: string;
|
|
1149
|
+
}
|
|
1150
|
+
interface TableColumnsResult {
|
|
1151
|
+
columns: ColumnMeta[];
|
|
1152
|
+
}
|
|
1153
|
+
interface TablesColumnsResult {
|
|
1154
|
+
columnsByTable: Record<string, ColumnMeta[]>;
|
|
1155
|
+
}
|
|
1156
|
+
interface AdvisoryFinding {
|
|
1157
|
+
cacheKey: string;
|
|
1158
|
+
categories: string[];
|
|
1159
|
+
description: string;
|
|
1160
|
+
detail: string;
|
|
1161
|
+
facing: "EXTERNAL" | "INTERNAL";
|
|
1162
|
+
level: "ERROR" | "INFO" | "WARN";
|
|
1163
|
+
metadata: Record<string, unknown>;
|
|
1164
|
+
name: string;
|
|
1165
|
+
remediation: string;
|
|
1166
|
+
title: string;
|
|
1167
|
+
}
|
|
1168
|
+
interface AdvisoriesResult {
|
|
1169
|
+
advisories: AdvisoryFinding[];
|
|
1170
|
+
}
|
|
1171
|
+
interface AdvisorProcedure {
|
|
1172
|
+
callsMail: boolean;
|
|
1173
|
+
emitsEvent?: boolean;
|
|
1174
|
+
exempt?: boolean;
|
|
1175
|
+
exemptReason?: string;
|
|
1176
|
+
exportName: string;
|
|
1177
|
+
fanOut: boolean;
|
|
1178
|
+
file: string;
|
|
1179
|
+
handlesErrors?: boolean;
|
|
1180
|
+
hasEmailArg?: boolean;
|
|
1181
|
+
kind: "action" | "mutation" | "query";
|
|
1182
|
+
reachesOutbound?: boolean;
|
|
1183
|
+
runsAiGeneration?: boolean;
|
|
1184
|
+
throwsBareError?: boolean;
|
|
1185
|
+
unboundedAiGeneration: boolean;
|
|
1186
|
+
usesCaptcha: boolean;
|
|
1187
|
+
usesEmailGate: boolean;
|
|
1188
|
+
usesInsertManyUnsafe: boolean;
|
|
1189
|
+
usesMask: boolean;
|
|
1190
|
+
usesRateLimit: boolean;
|
|
1191
|
+
usesRls: boolean;
|
|
1192
|
+
visibility: "internal" | "public";
|
|
1193
|
+
writesUserTable: boolean;
|
|
1194
|
+
}
|
|
1195
|
+
interface AdvisorProceduresResult {
|
|
1196
|
+
procedures: AdvisorProcedure[];
|
|
1197
|
+
}
|
|
1198
|
+
interface RlsPolicyMetadata {
|
|
1199
|
+
file: string;
|
|
1200
|
+
on: "delete" | "insert" | "read" | "update";
|
|
1201
|
+
procedure: string;
|
|
1202
|
+
table: string;
|
|
1203
|
+
}
|
|
1204
|
+
interface RlsRoleMetadata {
|
|
1205
|
+
description?: string;
|
|
1206
|
+
name: string;
|
|
1207
|
+
permissions: string[];
|
|
1208
|
+
}
|
|
1209
|
+
interface RlsPoliciesResult {
|
|
1210
|
+
policies: RlsPolicyMetadata[];
|
|
1211
|
+
roles: RlsRoleMetadata[];
|
|
1212
|
+
}
|
|
1213
|
+
interface MaskColumnMetadata {
|
|
1214
|
+
column: string;
|
|
1215
|
+
strategy: "custom" | "hash" | "redact";
|
|
1216
|
+
table: string;
|
|
1217
|
+
}
|
|
1218
|
+
interface MaskPoliciesResult {
|
|
1219
|
+
columns: MaskColumnMetadata[];
|
|
1220
|
+
}
|
|
1221
|
+
interface StorageRuleMetadata {
|
|
1222
|
+
bucket: string;
|
|
1223
|
+
file: string;
|
|
1224
|
+
on: "delete" | "list" | "read" | "write";
|
|
1225
|
+
prefix?: string;
|
|
1226
|
+
procedure: string;
|
|
1227
|
+
}
|
|
1228
|
+
interface StorageRulesResult {
|
|
1229
|
+
rules: StorageRuleMetadata[];
|
|
1230
|
+
}
|
|
1231
|
+
interface StudioFeaturesResult {
|
|
1232
|
+
analytics: boolean;
|
|
1233
|
+
auth: boolean;
|
|
1234
|
+
containers: boolean;
|
|
1235
|
+
flags: boolean;
|
|
1236
|
+
kv: boolean;
|
|
1237
|
+
mail: boolean;
|
|
1238
|
+
notifications: boolean;
|
|
1239
|
+
payments: boolean;
|
|
1240
|
+
queues: boolean;
|
|
1241
|
+
scheduler: boolean;
|
|
1242
|
+
storage: boolean;
|
|
1243
|
+
vectors: boolean;
|
|
1244
|
+
workflows: boolean;
|
|
1245
|
+
}
|
|
1246
|
+
interface FlagEvaluation {
|
|
1247
|
+
errorCode?: string;
|
|
1248
|
+
key: string;
|
|
1249
|
+
reason?: string;
|
|
1250
|
+
type: "boolean" | "number" | "object" | "string";
|
|
1251
|
+
value: unknown;
|
|
1252
|
+
variant?: string;
|
|
1253
|
+
}
|
|
1254
|
+
interface FlagsResult {
|
|
1255
|
+
configured: boolean;
|
|
1256
|
+
flags: FlagEvaluation[];
|
|
1257
|
+
}
|
|
1258
|
+
interface WorkflowMetadata {
|
|
1259
|
+
binding: string;
|
|
1260
|
+
className: string;
|
|
1261
|
+
exportName: string;
|
|
1262
|
+
name: string;
|
|
1263
|
+
}
|
|
1264
|
+
interface WorkflowsResult {
|
|
1265
|
+
workflows: WorkflowMetadata[];
|
|
1266
|
+
}
|
|
1267
|
+
interface QueueMetadata {
|
|
1268
|
+
binding: string;
|
|
1269
|
+
deadLetterQueue?: string;
|
|
1270
|
+
exportName: string;
|
|
1271
|
+
mode: "pull" | "push";
|
|
1272
|
+
name: string;
|
|
1273
|
+
}
|
|
1274
|
+
interface QueuesResult {
|
|
1275
|
+
queues: QueueMetadata[];
|
|
1276
|
+
}
|
|
1277
|
+
type WorkflowInstanceState = "complete" | "errored" | "paused" | "queued" | "running" | "terminated" | "unknown" | "waiting" | "waitingForPause";
|
|
1278
|
+
interface CreateWorkflowInstanceResult {
|
|
1279
|
+
id: string;
|
|
1280
|
+
status: WorkflowInstanceState;
|
|
1281
|
+
}
|
|
1282
|
+
interface WorkflowInstanceStatusResult {
|
|
1283
|
+
error?: {
|
|
1284
|
+
message: string;
|
|
1285
|
+
name: string;
|
|
1286
|
+
};
|
|
1287
|
+
id: string;
|
|
1288
|
+
output?: unknown;
|
|
1289
|
+
status: WorkflowInstanceState;
|
|
1290
|
+
}
|
|
1291
|
+
interface FunctionStatsResult {
|
|
1292
|
+
functions: FunctionCallStat[];
|
|
1293
|
+
sinceMs: number;
|
|
1294
|
+
}
|
|
1295
|
+
type SettingKind = "binding" | "secret" | "var";
|
|
1296
|
+
interface SettingEntry {
|
|
1297
|
+
bindingType?: string;
|
|
1298
|
+
kind: SettingKind;
|
|
1299
|
+
name: string;
|
|
1300
|
+
value: null | string;
|
|
1301
|
+
}
|
|
1302
|
+
interface DeployInfo {
|
|
1303
|
+
deploymentId?: string;
|
|
1304
|
+
environment?: string;
|
|
1305
|
+
versionTag?: string;
|
|
1306
|
+
workerUrl?: string;
|
|
1307
|
+
}
|
|
1308
|
+
interface SettingsResult {
|
|
1309
|
+
deploy: DeployInfo;
|
|
1310
|
+
settings: SettingEntry[];
|
|
1311
|
+
}
|
|
1312
|
+
interface TablePage {
|
|
1313
|
+
columns: string[];
|
|
1314
|
+
refs?: Record<string, string>;
|
|
1315
|
+
rows: Record<string, unknown>[];
|
|
1316
|
+
total?: number;
|
|
1317
|
+
}
|
|
1318
|
+
type FilterOperator = "contains" | "eq" | "gt" | "gte" | "lt" | "lte" | "ne";
|
|
1319
|
+
interface FilterClause {
|
|
1320
|
+
column: string;
|
|
1321
|
+
operator: FilterOperator;
|
|
1322
|
+
value?: unknown;
|
|
1323
|
+
}
|
|
1324
|
+
interface OrderByClause {
|
|
1325
|
+
column: string;
|
|
1326
|
+
direction: SortDirection;
|
|
1327
|
+
}
|
|
1328
|
+
interface ReadTablePageOptions {
|
|
1329
|
+
filters?: FilterClause[];
|
|
1330
|
+
limit?: number;
|
|
1331
|
+
offset?: number;
|
|
1332
|
+
orderBy?: OrderByClause;
|
|
1333
|
+
refs?: Record<string, string>;
|
|
1334
|
+
search?: string;
|
|
1335
|
+
skipCount?: boolean;
|
|
1336
|
+
table: string;
|
|
1337
|
+
}
|
|
1338
|
+
interface SelectMatchingIdsOptions {
|
|
1339
|
+
filters?: FilterClause[];
|
|
1340
|
+
limit?: number;
|
|
1341
|
+
search?: string;
|
|
1342
|
+
table: string;
|
|
1343
|
+
}
|
|
1344
|
+
interface FacetColumnOptions {
|
|
1345
|
+
column: string;
|
|
1346
|
+
filters?: FilterClause[];
|
|
1347
|
+
limit?: number;
|
|
1348
|
+
search?: string;
|
|
1349
|
+
table: string;
|
|
1350
|
+
}
|
|
1351
|
+
interface FacetValue {
|
|
1352
|
+
count: number;
|
|
1353
|
+
value: unknown;
|
|
1354
|
+
}
|
|
1355
|
+
interface FacetColumnResult {
|
|
1356
|
+
truncated: boolean;
|
|
1357
|
+
values: FacetValue[];
|
|
1358
|
+
}
|
|
1359
|
+
declare const MAX_PAGE_SIZE = 500;
|
|
1360
|
+
declare const listTables: (sql: SqlExec) => TableInfo[];
|
|
1361
|
+
declare const readTablePage: (sql: SqlExec, options: ReadTablePageOptions) => TablePage;
|
|
1362
|
+
declare const selectMatchingIds: (sql: SqlExec, options: SelectMatchingIdsOptions) => {
|
|
1363
|
+
hasMore: boolean;
|
|
1364
|
+
ids: string[];
|
|
1365
|
+
};
|
|
1366
|
+
declare const facetColumn: (sql: SqlExec, options: FacetColumnOptions) => FacetColumnResult;
|
|
1367
|
+
interface StorageReference {
|
|
1368
|
+
column: string;
|
|
1369
|
+
id: string;
|
|
1370
|
+
table: string;
|
|
1371
|
+
}
|
|
1372
|
+
interface StorageReferenceResult {
|
|
1373
|
+
references: Record<string, StorageReference[]>;
|
|
1374
|
+
storageColumns: Record<string, string[]>;
|
|
1375
|
+
}
|
|
1376
|
+
declare const findStorageReferences: (sql: SqlExec, storageColumns: Record<string, string[]>, keys: string[]) => StorageReferenceResult;
|
|
1377
|
+
interface SocketAttachmentLike {
|
|
1378
|
+
admin?: boolean;
|
|
1379
|
+
subs?: Record<string, SubscriptionInfo>;
|
|
1380
|
+
}
|
|
1381
|
+
declare const summarizeSubscriptions: (attachments: SocketAttachmentLike[]) => SubscriptionsResult;
|
|
1382
|
+
interface FanoutTopicStat {
|
|
1383
|
+
kind: "shape" | "whisper";
|
|
1384
|
+
subscribers: number;
|
|
1385
|
+
topic: string;
|
|
1386
|
+
}
|
|
1387
|
+
interface FanoutPathCounters {
|
|
1388
|
+
maxMs: number;
|
|
1389
|
+
passes: number;
|
|
1390
|
+
peakSocketsIterated: number;
|
|
1391
|
+
socketsDelivered: number;
|
|
1392
|
+
socketsIterated: number;
|
|
1393
|
+
totalMs: number;
|
|
1394
|
+
}
|
|
1395
|
+
interface FanoutMetricsResult {
|
|
1396
|
+
maxRelays: number;
|
|
1397
|
+
peakSubscribers: number;
|
|
1398
|
+
promoted: boolean;
|
|
1399
|
+
relayCount: number;
|
|
1400
|
+
shapePoke: FanoutPathCounters;
|
|
1401
|
+
sinceMs: number;
|
|
1402
|
+
topics: FanoutTopicStat[];
|
|
1403
|
+
totalConnections: number;
|
|
1404
|
+
whisper: FanoutPathCounters;
|
|
1405
|
+
}
|
|
1406
|
+
interface FanoutAttachmentLike {
|
|
1407
|
+
shapes?: Record<string, {
|
|
1408
|
+
name?: string;
|
|
1409
|
+
}>;
|
|
1410
|
+
whispers?: string[];
|
|
1411
|
+
}
|
|
1412
|
+
declare const DEFAULT_FANOUT_TOPIC_LIMIT = 20;
|
|
1413
|
+
declare const createFanoutCounters: () => FanoutPathCounters;
|
|
1414
|
+
declare const recordFanoutPass: (counters: FanoutPathCounters, iterated: number, delivered: number, ms: number) => FanoutPathCounters;
|
|
1415
|
+
declare const summarizeFanoutTopics: (attachments: FanoutAttachmentLike[], limit?: number) => {
|
|
1416
|
+
peakSubscribers: number;
|
|
1417
|
+
topics: FanoutTopicStat[];
|
|
1418
|
+
totalConnections: number;
|
|
1419
|
+
};
|
|
1420
|
+
declare const MAIL_TABLE = "__lunora_mail";
|
|
1421
|
+
declare const MAIL_RETENTION = 500;
|
|
1422
|
+
interface RecordMailInput {
|
|
1423
|
+
bcc?: string[];
|
|
1424
|
+
cc?: string[];
|
|
1425
|
+
from?: string;
|
|
1426
|
+
headers?: Record<string, string>;
|
|
1427
|
+
html?: string;
|
|
1428
|
+
replyTo?: string;
|
|
1429
|
+
subject: string;
|
|
1430
|
+
text?: string;
|
|
1431
|
+
to: string | string[];
|
|
1432
|
+
}
|
|
1433
|
+
interface CapturedMailRow {
|
|
1434
|
+
bcc?: string[];
|
|
1435
|
+
capturedAt: number;
|
|
1436
|
+
cc?: string[];
|
|
1437
|
+
from?: string;
|
|
1438
|
+
headers?: Record<string, string>;
|
|
1439
|
+
html?: string;
|
|
1440
|
+
id: string;
|
|
1441
|
+
replyTo?: string;
|
|
1442
|
+
subject: string;
|
|
1443
|
+
text?: string;
|
|
1444
|
+
to: string | string[];
|
|
1445
|
+
}
|
|
1446
|
+
declare const ensureMailTable: (sql: SqlExec) => void;
|
|
1447
|
+
declare const recordCapturedMail: (sql: SqlExec, input: RecordMailInput, capturedAt: number) => {
|
|
1448
|
+
id: string;
|
|
1449
|
+
};
|
|
1450
|
+
declare const readCapturedMail: (sql: SqlExec, options?: {
|
|
1451
|
+
limit?: number;
|
|
1452
|
+
}) => {
|
|
1453
|
+
entries: CapturedMailRow[];
|
|
1454
|
+
};
|
|
1455
|
+
declare const clearCapturedMail: (sql: SqlExec) => {
|
|
1456
|
+
cleared: true;
|
|
1457
|
+
};
|
|
1458
|
+
declare class NotFoundError extends LunoraError {
|
|
1459
|
+
constructor(message?: string);
|
|
1460
|
+
}
|
|
1461
|
+
interface PitrStorage {
|
|
1462
|
+
getBookmarkForTime?: (time: Date | number) => Promise<string>;
|
|
1463
|
+
getCurrentBookmark?: () => Promise<string>;
|
|
1464
|
+
onNextSessionRestoreBookmark?: (bookmark: string) => Promise<string>;
|
|
1465
|
+
}
|
|
1466
|
+
interface PitrBookmarkResult {
|
|
1467
|
+
current: string;
|
|
1468
|
+
forTime?: string;
|
|
1469
|
+
}
|
|
1470
|
+
interface PitrRestoreResult {
|
|
1471
|
+
restarted: boolean;
|
|
1472
|
+
restoredTo: string;
|
|
1473
|
+
undoBookmark: string;
|
|
1474
|
+
}
|
|
1475
|
+
interface PitrRestoreArgs {
|
|
1476
|
+
bookmark?: string;
|
|
1477
|
+
restart?: boolean;
|
|
1478
|
+
time?: number | string;
|
|
1479
|
+
}
|
|
1480
|
+
declare const readBookmark: (storage: PitrStorage, time?: number | string) => Promise<PitrBookmarkResult>;
|
|
1481
|
+
declare const armRestore: (storage: PitrStorage, args: PitrRestoreArgs) => Promise<Omit<PitrRestoreResult, "restarted">>;
|
|
1482
|
+
declare const normalizeOrderKeys: (orderBy: OrderByInput[] | undefined) => OrderKey[];
|
|
1483
|
+
declare const encodeCursor: (record: Record<string, unknown>, keys: OrderKey[]) => string;
|
|
1484
|
+
declare const decodeCursor: (cursor: string) => unknown[];
|
|
1485
|
+
declare const buildSeekWhere: (keys: OrderKey[], cursorValues: unknown[]) => WhereInput;
|
|
1486
|
+
declare const buildSeekBeforeWhere: (keys: OrderKey[], cursorValues: unknown[]) => WhereInput;
|
|
1487
|
+
declare const applySelect: (page: Record<string, unknown>[], select: ReadonlyArray<string> | undefined, withInput?: Record<string, unknown>) => Record<string, unknown>[];
|
|
1488
|
+
declare const softDeleteScope: (softDeleteMode: {
|
|
1489
|
+
field: string;
|
|
1490
|
+
} | undefined, includeDeleted: boolean | undefined) => undefined | WhereInput;
|
|
1491
|
+
declare const QUEUE_TABLE = "__lunora_queue_messages";
|
|
1492
|
+
type QueueMessageOutcome = "ack" | "error" | "retry";
|
|
1493
|
+
interface RecordQueueMessageInput {
|
|
1494
|
+
attempts: number;
|
|
1495
|
+
body: unknown;
|
|
1496
|
+
deadLettered?: boolean;
|
|
1497
|
+
error?: string;
|
|
1498
|
+
exportName?: string;
|
|
1499
|
+
messageId: string;
|
|
1500
|
+
outcome: QueueMessageOutcome;
|
|
1501
|
+
queue: string;
|
|
1502
|
+
timestamp: number;
|
|
1503
|
+
}
|
|
1504
|
+
interface QueueMessageRow {
|
|
1505
|
+
attempts: number;
|
|
1506
|
+
body: unknown;
|
|
1507
|
+
capturedAt: number;
|
|
1508
|
+
deadLettered: boolean;
|
|
1509
|
+
error?: string;
|
|
1510
|
+
exportName?: string;
|
|
1511
|
+
id: string;
|
|
1512
|
+
messageId: string;
|
|
1513
|
+
outcome: QueueMessageOutcome;
|
|
1514
|
+
queue: string;
|
|
1515
|
+
timestamp: number;
|
|
1516
|
+
}
|
|
1517
|
+
declare const isLossyBody: (body: unknown) => boolean;
|
|
1518
|
+
declare const recordQueueMessages: (sql: SqlExec, inputs: ReadonlyArray<RecordQueueMessageInput>, capturedAt: number) => {
|
|
1519
|
+
recorded: number;
|
|
1520
|
+
};
|
|
1521
|
+
interface ReadQueueMessagesOptions {
|
|
1522
|
+
limit?: number;
|
|
1523
|
+
queue?: string;
|
|
1524
|
+
}
|
|
1525
|
+
declare const readQueueMessages: (sql: SqlExec, options?: ReadQueueMessagesOptions) => {
|
|
1526
|
+
entries: QueueMessageRow[];
|
|
1527
|
+
};
|
|
1528
|
+
declare const readQueueMessageById: (sql: SqlExec, id: string) => QueueMessageRow | undefined;
|
|
1529
|
+
declare const clearQueueMessages: (sql: SqlExec) => {
|
|
1530
|
+
cleared: true;
|
|
1531
|
+
};
|
|
1532
|
+
declare const encodePartitionKey: (partitionBy: ReadonlyArray<string>, source: Record<string, unknown>) => string;
|
|
1533
|
+
declare const RANK_TIEBREAK = "__id__";
|
|
1534
|
+
declare const sortColumnName: (i: number) => string;
|
|
1535
|
+
declare const matchesRankStaticWhere: (document: Record<string, unknown>, predicate: Record<string, unknown>) => boolean;
|
|
1536
|
+
declare const resolveRankPartition: (index: RankIndexDefinitionLike, where: Record<string, unknown> | undefined) => Record<string, unknown> | undefined;
|
|
1537
|
+
declare const rankTableName: (table: string, indexName: string) => string;
|
|
1538
|
+
declare const rankKeyFromDocument: (index: RankIndexDefinitionLike, document_: Record<string, unknown>) => {
|
|
1539
|
+
partitionKey: string;
|
|
1540
|
+
rowId: string;
|
|
1541
|
+
sortValues: unknown[];
|
|
1542
|
+
};
|
|
1543
|
+
declare const DEFAULT_MAX_RELATION_KEYS = 5000;
|
|
1544
|
+
interface RelationExistsMarker {
|
|
1545
|
+
childWhere: WhereInput;
|
|
1546
|
+
negated: boolean;
|
|
1547
|
+
parentTable: string;
|
|
1548
|
+
relation: RelationDefinitionLike;
|
|
1549
|
+
}
|
|
1550
|
+
type ExistsPushMode = "always" | "auto";
|
|
1551
|
+
interface ResolveRelationPredicatesOptions {
|
|
1552
|
+
canPushExists?: (relation: RelationDefinitionLike) => boolean;
|
|
1553
|
+
existsPushMode?: ExistsPushMode;
|
|
1554
|
+
fetcher: (tableName: string, args: QueryArgs) => Promise<QueryPage>;
|
|
1555
|
+
maxRelationKeys?: number;
|
|
1556
|
+
relationBaseWhere?: (table: string) => undefined | WhereInput;
|
|
1557
|
+
schema: {
|
|
1558
|
+
readonly tables: Record<string, TableDefinitionLike>;
|
|
1559
|
+
};
|
|
1560
|
+
tableName: string;
|
|
1561
|
+
}
|
|
1562
|
+
interface ResolveContext {
|
|
1563
|
+
canPushExists?: (relation: RelationDefinitionLike) => boolean;
|
|
1564
|
+
existsPushMode: ExistsPushMode;
|
|
1565
|
+
fetcher: (tableName: string, args: QueryArgs) => Promise<QueryPage>;
|
|
1566
|
+
maxRelationKeys: number;
|
|
1567
|
+
relationBaseWhere?: (table: string) => undefined | WhereInput;
|
|
1568
|
+
schema: {
|
|
1569
|
+
readonly tables: Record<string, TableDefinitionLike>;
|
|
1570
|
+
};
|
|
1571
|
+
}
|
|
1572
|
+
declare const isRelationPredicate: (value: unknown) => value is Record<string, WhereInput>;
|
|
1573
|
+
declare const containsRelationPredicate: (where: WhereInput, schema: ResolveContext["schema"], tableName: string) => boolean;
|
|
1574
|
+
declare const assertFlatPredicate: (where: WhereInput | undefined, schema: ResolveContext["schema"], tableName: string, op: string) => void;
|
|
1575
|
+
declare const resolveRelationPredicates: (where: WhereInput | undefined, options: ResolveRelationPredicatesOptions) => Promise<WhereInput | undefined>;
|
|
1576
|
+
declare const assertShapeShardable: (effectiveWhere: WhereInput | undefined, schema: ResolveContext["schema"], table: string) => void;
|
|
1577
|
+
declare const fanOutScalarCounts: (counter: (tableName: string, where?: WhereInput) => Promise<number>, tableName: string, whereField: string, values: unknown[], policyWhere: WhereInput | undefined) => Promise<Map<unknown, number>>;
|
|
1578
|
+
declare const distinctValues: (rows: Record<string, unknown>[], field: string) => unknown[];
|
|
1579
|
+
declare const resolveWith: (options: ResolveWithOptions) => Promise<void>;
|
|
1580
|
+
interface ApplyOnDeleteOptions {
|
|
1581
|
+
deletedId: string;
|
|
1582
|
+
deletedReference: (references: string) => unknown;
|
|
1583
|
+
findHolders: (holderTable: string, field: string, value: unknown) => Promise<Record<string, unknown>[]>;
|
|
1584
|
+
onCascade: (holderTable: string, id: string) => Promise<void>;
|
|
1585
|
+
onRestrict: (message: string) => never;
|
|
1586
|
+
onSetNull: (holderTable: string, id: string, field: string) => Promise<void>;
|
|
1587
|
+
schema: {
|
|
1588
|
+
readonly tables: Record<string, TableDefinitionLike>;
|
|
1589
|
+
};
|
|
1590
|
+
tableName: string;
|
|
1591
|
+
}
|
|
1592
|
+
declare const applyOnDelete: (options: ApplyOnDeleteOptions) => Promise<void>;
|
|
1593
|
+
declare const runRowValidators: (definition: TableDefinitionLike, document: Record<string, unknown>, tolerateStoredNull?: boolean) => void;
|
|
1594
|
+
interface ShapeRowOp {
|
|
1595
|
+
key: string;
|
|
1596
|
+
op: "delete" | "insert" | "update";
|
|
1597
|
+
table: string;
|
|
1598
|
+
value?: Record<string, unknown>;
|
|
1599
|
+
}
|
|
1600
|
+
interface ShapePokePart {
|
|
1601
|
+
rowsPatch: ShapeRowOp[];
|
|
1602
|
+
shapeId: string;
|
|
1603
|
+
}
|
|
1604
|
+
interface PokeFrameMeta {
|
|
1605
|
+
baseCheckpoint: number | undefined;
|
|
1606
|
+
checkpoint: number;
|
|
1607
|
+
epoch: string | undefined;
|
|
1608
|
+
lastMutationId: number | undefined;
|
|
1609
|
+
pokeId: string;
|
|
1610
|
+
}
|
|
1611
|
+
declare const projectColumns: (document_: Record<string, unknown>, columns: ReadonlyArray<string> | undefined) => Record<string, unknown>;
|
|
1612
|
+
declare const diffGlobalMembership: (rows: ReadonlyArray<ShapeRow>, previous: ReadonlyMap<string, string>, options: {
|
|
1613
|
+
columns?: ReadonlyArray<string>;
|
|
1614
|
+
table: string;
|
|
1615
|
+
}) => {
|
|
1616
|
+
next: Map<string, string>;
|
|
1617
|
+
rowsPatch: ShapeRowOp[];
|
|
1618
|
+
};
|
|
1619
|
+
declare const encodeRowsPatch: (rowsPatch: ReadonlyArray<ShapeRowOp>) => ShapeRowOp[];
|
|
1620
|
+
declare const buildPokeFrames: (parts: ReadonlyArray<ShapePokePart>, meta: PokeFrameMeta, options?: {
|
|
1621
|
+
preEncoded?: boolean;
|
|
1622
|
+
}) => string[];
|
|
1623
|
+
declare const shapeRoutingKey: (name: string, args?: Record<string, unknown>) => string;
|
|
1624
|
+
type PromotionState = "owned" | "promoted";
|
|
1625
|
+
interface PromotionThresholds {
|
|
1626
|
+
tDown: number;
|
|
1627
|
+
tUp: number;
|
|
1628
|
+
}
|
|
1629
|
+
declare const DEFAULT_PROMOTION_THRESHOLDS: PromotionThresholds;
|
|
1630
|
+
declare const nextPromotionState: (current: PromotionState, subscribers: number, thresholds?: PromotionThresholds) => PromotionState;
|
|
1631
|
+
declare const clampPromotionThresholds: (tUp: number, tDownRaw: number) => PromotionThresholds;
|
|
1632
|
+
declare const relayCountFor: (subscribers: number, perRelayCapacity: number, maxRelays: number) => number;
|
|
1633
|
+
interface RelayAttach {
|
|
1634
|
+
relayIndex: number;
|
|
1635
|
+
type: "relay_attach";
|
|
1636
|
+
}
|
|
1637
|
+
interface RelayDetach {
|
|
1638
|
+
relayIndex: number;
|
|
1639
|
+
type: "relay_detach";
|
|
1640
|
+
}
|
|
1641
|
+
interface RelayFrame {
|
|
1642
|
+
cursor?: number;
|
|
1643
|
+
epoch?: string;
|
|
1644
|
+
frame: string;
|
|
1645
|
+
originRelay?: number;
|
|
1646
|
+
topic: string;
|
|
1647
|
+
type: "relay_frame";
|
|
1648
|
+
}
|
|
1649
|
+
interface RelayShapeSubscribe {
|
|
1650
|
+
args: Record<string, unknown>;
|
|
1651
|
+
connectionId?: string;
|
|
1652
|
+
identity?: Record<string, unknown>;
|
|
1653
|
+
name: string;
|
|
1654
|
+
relayIndex?: number;
|
|
1655
|
+
sinceEpoch?: string;
|
|
1656
|
+
sinceSeq?: number;
|
|
1657
|
+
subId: string;
|
|
1658
|
+
type: "relay_shape_subscribe";
|
|
1659
|
+
userId?: string;
|
|
1660
|
+
}
|
|
1661
|
+
interface RelayShapeSeed {
|
|
1662
|
+
cursor?: number;
|
|
1663
|
+
epoch?: string;
|
|
1664
|
+
error?: {
|
|
1665
|
+
code: string;
|
|
1666
|
+
message: string;
|
|
1667
|
+
};
|
|
1668
|
+
frames?: string[];
|
|
1669
|
+
}
|
|
1670
|
+
interface RelayShapePoke {
|
|
1671
|
+
args: Record<string, unknown>;
|
|
1672
|
+
checkpoint: number;
|
|
1673
|
+
epoch?: string;
|
|
1674
|
+
fromCursor: number;
|
|
1675
|
+
name: string;
|
|
1676
|
+
rowsPatch: ShapeRowOp[];
|
|
1677
|
+
targetConnectionId?: string;
|
|
1678
|
+
type: "relay_shape_poke";
|
|
1679
|
+
}
|
|
1680
|
+
type OwnerRelayFrame = RelayAttach | RelayDetach | RelayFrame | RelayShapePoke | RelayShapeSubscribe;
|
|
1681
|
+
declare const DEFAULT_MAX_RELAYS = 8;
|
|
1682
|
+
interface RelayStub {
|
|
1683
|
+
fetch: (url: string, init?: RequestInit) => Promise<Response>;
|
|
1684
|
+
}
|
|
1685
|
+
interface RelayNamespaceLike {
|
|
1686
|
+
get: (id: unknown) => RelayStub;
|
|
1687
|
+
getByName?: (name: string) => RelayStub;
|
|
1688
|
+
idFromName: (name: string) => unknown;
|
|
1689
|
+
}
|
|
1690
|
+
interface RelayHost {
|
|
1691
|
+
buildShapeDiff: (resolved: ResolvedShape, fromCursor: number, toCursor: number) => ShapeRowOp[];
|
|
1692
|
+
computeOpLogShapeSeed: (shape: ShapeSubscriptionQuery, resolved: ResolvedShape) => {
|
|
1693
|
+
baseCheckpoint: number | undefined;
|
|
1694
|
+
cursor: number;
|
|
1695
|
+
epoch: string | undefined;
|
|
1696
|
+
rowsPatch: ShapeRowOp[];
|
|
1697
|
+
};
|
|
1698
|
+
currentCdcEpoch: () => string | undefined;
|
|
1699
|
+
deliverWhisperLocal: (topic: string, frame: string, exclude: undefined | ShardSocketLike) => number;
|
|
1700
|
+
doName: () => string | undefined;
|
|
1701
|
+
env: () => unknown;
|
|
1702
|
+
getWebSockets: () => ShardSocketLike[];
|
|
1703
|
+
maskMetadata: () => MaskPoliciesResult;
|
|
1704
|
+
nextPokeId: () => string;
|
|
1705
|
+
readAttachment: (ws: ShardSocketLike) => SocketAttachment;
|
|
1706
|
+
recordShapePokeFanout: (iterated: number, delivered: number, elapsedMs: number) => void;
|
|
1707
|
+
resolveShape: (name: string, args: Record<string, unknown>, identity?: SubscriptionIdentity) => ResolvedShape | undefined;
|
|
1708
|
+
rlsMetadata: () => RlsPoliciesResult;
|
|
1709
|
+
shardBinding: () => string | undefined;
|
|
1710
|
+
sql: () => SqlExec;
|
|
1711
|
+
}
|
|
1712
|
+
declare abstract class RelayLink {
|
|
1713
|
+
protected readonly host: RelayHost;
|
|
1714
|
+
protected readonly roleId: {
|
|
1715
|
+
ownerKey: string;
|
|
1716
|
+
relayIndex?: number;
|
|
1717
|
+
};
|
|
1718
|
+
protected constructor(host: RelayHost, roleId: {
|
|
1719
|
+
ownerKey: string;
|
|
1720
|
+
relayIndex?: number;
|
|
1721
|
+
});
|
|
1722
|
+
handleControl(request: Request): Promise<Response>;
|
|
1723
|
+
maxRelays(): number;
|
|
1724
|
+
protected canAddressSiblings(): boolean;
|
|
1725
|
+
protected relayNamespace(): RelayNamespaceLike | undefined;
|
|
1726
|
+
protected postRelayMessage(targetName: string, message: OwnerRelayFrame): Promise<void>;
|
|
1727
|
+
protected requestRelayMessage(targetName: string, message: OwnerRelayFrame): Promise<Response | undefined>;
|
|
1728
|
+
abstract forwardWhisper(topic: string, frame: string): Promise<void>;
|
|
1729
|
+
abstract onFlush(changed: Set<string>, frameCursor: number): Promise<void>;
|
|
1730
|
+
abstract seedRelayShape(ws: ShardSocketLike, subId: string, shape: ShapeSubscriptionQuery, identity: SubscriptionIdentity): Promise<"ok" | undefined | {
|
|
1731
|
+
code: string;
|
|
1732
|
+
message: string;
|
|
1733
|
+
}>;
|
|
1734
|
+
abstract announce(): Promise<void>;
|
|
1735
|
+
abstract announceDrain(closing: ShardSocketLike): Promise<void>;
|
|
1736
|
+
abstract relayCount(): number;
|
|
1737
|
+
abstract isShapeRelayUniform(name: string, args: Record<string, unknown>): boolean;
|
|
1738
|
+
protected abstract onAttach(index: number): void;
|
|
1739
|
+
protected abstract onDetach(index: number): void;
|
|
1740
|
+
protected abstract onWhisperFrame(message: RelayFrame): Promise<void>;
|
|
1741
|
+
protected abstract onShapeSubscribe(message: RelayShapeSubscribe): RelayShapeSeed;
|
|
1742
|
+
protected abstract onShapePoke(poke: RelayShapePoke): number;
|
|
1743
|
+
}
|
|
1744
|
+
declare class OwnerRelay extends RelayLink {
|
|
1745
|
+
private readonly shapeUniformCache;
|
|
1746
|
+
private relaySetCache;
|
|
1747
|
+
private readonly relayShapeRegistry;
|
|
1748
|
+
private readonly relayShapeProxies;
|
|
1749
|
+
private promotionState;
|
|
1750
|
+
constructor(host: RelayHost, ownerKey: string);
|
|
1751
|
+
forwardWhisper(topic: string, frame: string): Promise<void>;
|
|
1752
|
+
onFlush(changed: Set<string>, frameCursor: number): Promise<void>;
|
|
1753
|
+
seedRelayShape(): Promise<"ok" | undefined | {
|
|
1754
|
+
code: string;
|
|
1755
|
+
message: string;
|
|
1756
|
+
}>;
|
|
1757
|
+
announce(): Promise<void>;
|
|
1758
|
+
announceDrain(): Promise<void>;
|
|
1759
|
+
relayCount(): number;
|
|
1760
|
+
isShapeRelayUniform(name: string, args: Record<string, unknown>): boolean;
|
|
1761
|
+
protected onAttach(index: number): void;
|
|
1762
|
+
protected onDetach(index: number): void;
|
|
1763
|
+
protected onWhisperFrame(message: RelayFrame): Promise<void>;
|
|
1764
|
+
protected onShapeSubscribe(message: RelayShapeSubscribe): RelayShapeSeed;
|
|
1765
|
+
protected onShapePoke(): number;
|
|
1766
|
+
private multicastShapePokes;
|
|
1767
|
+
private proxyShapePokes;
|
|
1768
|
+
private buildShapeSeedFrames;
|
|
1769
|
+
private ensureRelayTable;
|
|
1770
|
+
private ownerRelaySet;
|
|
1771
|
+
private addRelayToSet;
|
|
1772
|
+
private removeRelayFromSet;
|
|
1773
|
+
private probeShapeRelayUniform;
|
|
1774
|
+
private tableHasAnyMask;
|
|
1775
|
+
}
|
|
1776
|
+
declare class RelayMember extends RelayLink {
|
|
1777
|
+
private relayAnnounced;
|
|
1778
|
+
private readonly shapeRelayMemos;
|
|
1779
|
+
constructor(host: RelayHost, ownerKey: string, relayIndex: number);
|
|
1780
|
+
forwardWhisper(topic: string, frame: string): Promise<void>;
|
|
1781
|
+
onFlush(): Promise<void>;
|
|
1782
|
+
seedRelayShape(ws: ShardSocketLike, subId: string, shape: ShapeSubscriptionQuery, identity: SubscriptionIdentity): Promise<"ok" | {
|
|
1783
|
+
code: string;
|
|
1784
|
+
message: string;
|
|
1785
|
+
}>;
|
|
1786
|
+
announce(): Promise<void>;
|
|
1787
|
+
announceDrain(closing: ShardSocketLike): Promise<void>;
|
|
1788
|
+
relayCount(): number;
|
|
1789
|
+
isShapeRelayUniform(): boolean;
|
|
1790
|
+
protected onAttach(): void;
|
|
1791
|
+
protected onDetach(): void;
|
|
1792
|
+
protected onWhisperFrame(): Promise<void>;
|
|
1793
|
+
protected onShapeSubscribe(): RelayShapeSeed;
|
|
1794
|
+
protected onShapePoke(poke: RelayShapePoke): number;
|
|
1795
|
+
private recordRelayShapeMemo;
|
|
1796
|
+
private deliverShapePoke;
|
|
1797
|
+
}
|
|
1798
|
+
declare const createRelayLink: (host: RelayHost) => OwnerRelay | RelayMember | undefined;
|
|
1799
|
+
declare const RLS_UNWRAP_SYMBOL: symbol;
|
|
1800
|
+
declare class RlsRequiredError extends LunoraError {
|
|
1801
|
+
readonly table: string;
|
|
1802
|
+
constructor(table: string);
|
|
1803
|
+
}
|
|
1804
|
+
interface GuardableSchema {
|
|
1805
|
+
readonly rlsMode?: "required";
|
|
1806
|
+
readonly tables: Record<string, {
|
|
1807
|
+
readonly isPublic?: boolean;
|
|
1808
|
+
readonly shardMode?: {
|
|
1809
|
+
readonly kind?: string;
|
|
1810
|
+
};
|
|
1811
|
+
}>;
|
|
1812
|
+
}
|
|
1813
|
+
type TableOfId = (id: string, expectedTable?: string) => Promise<string | undefined> | string | undefined;
|
|
1814
|
+
declare const guardWriter: <W>(raw: W, schema: GuardableSchema, tableOfId: TableOfId) => W;
|
|
1815
|
+
declare const SCHEMA_HISTORY_MAX_VERSIONS = 50;
|
|
1816
|
+
interface SchemaVersionRow {
|
|
1817
|
+
appliedAt: number;
|
|
1818
|
+
hash: string;
|
|
1819
|
+
seq: number;
|
|
1820
|
+
snapshotJson?: string;
|
|
1821
|
+
}
|
|
1822
|
+
declare const recordSchemaVersion: (sql: SqlExec, hash: string, snapshotJson: string, now?: number) => boolean;
|
|
1823
|
+
declare const readSchemaHistory: (sql: SqlExec) => SchemaVersionRow[];
|
|
1824
|
+
declare const readSchemaVersion: (sql: SqlExec, hash: string) => SchemaVersionRow | undefined;
|
|
1825
|
+
declare const isDevEnvironment: (rawEnv: unknown) => boolean;
|
|
1826
|
+
declare const buildSettings: (rawEnv: unknown) => SettingsResult;
|
|
1827
|
+
interface ShardRunnerOptions {
|
|
1828
|
+
handlers?: {
|
|
1829
|
+
handleAlarm?: () => Promise<void>;
|
|
1830
|
+
handleFetch?: (request: Request) => Promise<Response>;
|
|
1831
|
+
};
|
|
1832
|
+
}
|
|
1833
|
+
declare class ShardRunner {
|
|
1834
|
+
readonly shardHost: ShardHost;
|
|
1835
|
+
readonly socketHost: SocketHost;
|
|
1836
|
+
readonly options: ShardRunnerOptions;
|
|
1837
|
+
constructor(shardHost: ShardHost, socketHost: SocketHost, options?: ShardRunnerOptions);
|
|
1838
|
+
get shardKey(): string | undefined;
|
|
1839
|
+
socketFor(raw: unknown): ShardSocketLike;
|
|
1840
|
+
sockets(tag?: string): SocketHandle[];
|
|
1841
|
+
background(work: Promise<unknown>): boolean;
|
|
1842
|
+
runInTransaction<T>(work: () => Promise<T>): Promise<T>;
|
|
1843
|
+
handleFetch(request: Request): Promise<Response>;
|
|
1844
|
+
handleAlarm(): Promise<void>;
|
|
1845
|
+
}
|
|
1846
|
+
declare const runSocketPool: <T>(items: ReadonlyArray<T>, processOne: (item: T) => Promise<void>, concurrency?: number) => Promise<void>;
|
|
1847
|
+
interface SqlConsoleResult {
|
|
1848
|
+
columns: string[];
|
|
1849
|
+
rowCount: number;
|
|
1850
|
+
rows: Record<string, unknown>[];
|
|
1851
|
+
truncated: boolean;
|
|
1852
|
+
}
|
|
1853
|
+
declare const MAX_SQL_ROWS = 1000;
|
|
1854
|
+
declare const assertReadonly: (query: string) => void;
|
|
1855
|
+
declare const runReadonlySql: (sql: SqlExec, query: string) => SqlConsoleResult;
|
|
1856
|
+
interface SqlLintResult {
|
|
1857
|
+
diagnostics: SqlDiagnostic[];
|
|
1858
|
+
plan: string[];
|
|
1859
|
+
}
|
|
1860
|
+
interface SqlDiagnostic {
|
|
1861
|
+
length?: number;
|
|
1862
|
+
message: string;
|
|
1863
|
+
offset?: number;
|
|
1864
|
+
severity: "error" | "warning";
|
|
1865
|
+
source: "gate" | "plan" | "syntax";
|
|
1866
|
+
}
|
|
1867
|
+
declare const lintReadonlySql: (sql: SqlExec, query: string) => SqlLintResult;
|
|
1868
|
+
declare const subscriptionListDeltas: (previousJson: string, nextResult: unknown, table: string, frames?: string[]) => MutationDelta[] | undefined;
|
|
1869
|
+
interface FrameSink {
|
|
1870
|
+
send: (data: string) => void;
|
|
1871
|
+
}
|
|
1872
|
+
interface DrainableSink {
|
|
1873
|
+
readonly bufferedAmount?: unknown;
|
|
1874
|
+
}
|
|
1875
|
+
declare const trySendFrame: (ws: FrameSink, frame: string) => boolean;
|
|
1876
|
+
declare const sendDeltaFrames: (ws: FrameSink, subId: string, deltaFrames: ReadonlyArray<string>, cursorSuffix: string) => boolean;
|
|
1877
|
+
declare const awaitWsDrain: (ws: DrainableSink) => Promise<void>;
|
|
1878
|
+
type ConflictKind = "conflict" | "occ" | "restrict" | "trigger" | "unique";
|
|
1879
|
+
declare class ConflictError extends LunoraError {
|
|
1880
|
+
readonly kind: ConflictKind;
|
|
1881
|
+
constructor(message?: string, kind?: ConflictKind);
|
|
1882
|
+
}
|
|
1883
|
+
interface TransactionSqlLike {
|
|
1884
|
+
exec: (query: string) => unknown;
|
|
1885
|
+
}
|
|
1886
|
+
interface TtlSweepSpec {
|
|
1887
|
+
after?: number;
|
|
1888
|
+
field: string;
|
|
1889
|
+
softDeleteField?: string;
|
|
1890
|
+
table: string;
|
|
1891
|
+
}
|
|
1892
|
+
declare const selectExpiredIds: (sql: SqlExec, spec: TtlSweepSpec, now: number, limit: number) => {
|
|
1893
|
+
hasMore: boolean;
|
|
1894
|
+
ids: string[];
|
|
1895
|
+
};
|
|
1896
|
+
type FieldRefSql = (field: string) => SQL;
|
|
1897
|
+
type SerializeValue = (value: unknown) => unknown;
|
|
1898
|
+
interface WhereSqlStrategy {
|
|
1899
|
+
fieldRef: FieldRefSql;
|
|
1900
|
+
likeContains?: (reference: SQL, term: SQL) => SQL;
|
|
1901
|
+
relationExists?: (request: unknown) => SQL;
|
|
1902
|
+
serialize: SerializeValue;
|
|
1903
|
+
}
|
|
1904
|
+
declare const compileWhereSql: (where: WhereInput | undefined, strategy: WhereSqlStrategy) => SQL | undefined;
|
|
1905
|
+
export { ADMIN_FUNCTIONS, ADMIN_FUNCTION_PREFIX, AGGREGATE_SQL_FUNCTION, AGG_COUNT, AGG_KEY, AGG_VALUE, AUDIT_LOG_TABLE, type AdvisorProcedure, type AdvisorProceduresResult, type AdvisoriesResult, type AdvisoryFinding, type AggregateIndexDefinitionLike, type AggregateOp, type AggregateOptions, type AggregateResult, type AggregateTally, type AppendAuditEntry, type ApplyOnDeleteOptions$1 as ApplyOnDeleteOptions, type AuditEntry, type AuditLogResult, type BroadcastDelta, CDC_LOG_TABLE, CDC_META_TABLE, CLIENT_WATERMARK_TABLE, type CacheEntry, type CapturedMailRow, type CdcChange, type Clock, type ColumnMeta, type ColumnMetaLike, type CompanionSync, type CompanionSyncDeps, ConflictError, type ConflictKind, type CountArgs, CountRlsUnsupportedError, type CreateWorkflowInstanceResult, type CtxDbOptions, DATA_MIGRATION_STATE_TABLE, DEFAULT_FANOUT_TOPIC_LIMIT, DEFAULT_MAX_RELATION_KEYS, DEFAULT_MAX_RELAYS, DEFAULT_PROMOTION_THRESHOLDS, DOC_COLUMN, type DataMigrationDocument, type DataMigrationLike, type DataMigrationTransform, type DatabaseWriterLike, type DependencyTracker, type DeployInfo, type ExportRow, type ExportShardAdminArgs, type ExportShardArgs, type ExternalSourceDiffResult, type ExternalSourceLike, FLAGS_FUNCTION_PREFIX, type FacetColumnOptions, type FacetColumnResult, type FacetValue, type FanoutMetricsResult, type FanoutPathCounters, type FanoutTopicStat, type FieldOperators, type FilterClause, type FilterOperator, type FlagEvaluation, type FlagsResult, type FunctionCallStat, type FunctionScanAttribution, type FunctionStatsResult, GEO_DEFAULT_PRECISION, GLOBAL_SHAPE_SNAPSHOT_TABLE, type GeoBoundingBox, type GeoFilterBuilderLike, type GeoIndexDefinitionLike, type GeoPoint, type GroupByEntry, type GroupByOptions, type GuardableSchema$1 as GuardableSchema, IDEMPOTENCY_TABLE, type IdGenerator, type IdempotentRecord, type ImportError, type ImportShardAdminArgs, type ImportShardArgs, type ImportShardResult, type IncrementalMaterializeResult, type IndexDefinitionLike, type IndexRangeBuilderLike, type LifecycleDispatchInfo, type LifecycleEvent, MAIL_RETENTION, MAIL_TABLE, MAX_PAGE_SIZE, MAX_SQL_ROWS, type MaskColumnMetadata, type MaskPoliciesResult, type MaterializeResult, type MigrationDirection, type MigrationRunResult, type MigrationStatus, type MigrationStatusRow, type MutationDelta, type NestedWith, NotFoundError, NotUniqueError, type OnDeleteActionLike, type OrderByClause, type OrderByInput, type OrderKey, OwnerRelay, type OwnerRelayFrame, type PaginationOptions, type PitrBookmarkResult, type PitrRestoreArgs, type PitrRestoreResult, type PitrStorage, type PokeFrameMeta, type PromotionState, type PromotionThresholds, QUEUE_TABLE, type QueryArgs, type QueryPage, type QueueMessageOutcome, type QueueMessageRow, type QueueMetadata, type QueuesResult, RANK_TIEBREAK, RELATION_EXISTS_KEY, RELATION_FUNCTION_PREFIX, RLS_UNWRAP_SYMBOL, type RankBeforeOptions, type RankBeforeResult, type RankDirection, type RankIndexDefinitionLike, type RankOptions, type RankPage, type RankPageComputation, type RankPageDeps, type RankPageOptions, type RankPageRow, type RankPageRowKey, type RankResult, type RankSortKeyLike, ReactiveCache, type ReactiveCacheOptions, type ReadHook, type ReadTablePageOptions, type RecordMailInput, type RecordQueueMessageInput, type RelationDefinitionLike, type RelationExistsMarker, type RelayAttach, type RelayDetach, type RelayFrame, type RelayHost, RelayMember, type RelayShapePoke, type RelayShapeSeed, type RelayShapeSubscribe, type RenderedSql, type ResolveRelationPredicatesOptions, type ResolveWithOptions, type ResolveWithResult, type ResolvedShape, type RestrictableQueryOptions, type RlsPoliciesResult, type RlsPolicyMetadata, RlsRequiredError, type RlsRoleMetadata, type RpcRequest, type RunDataMigrationOptions, type RunTriggersOptions, SCAN_DEP, SCHEMA_HISTORY_MAX_VERSIONS, SEARCH_STATE_TABLE, type SchedulableWorkflowReferenceLike, type ScheduledFunctionDoc, type SchedulerLike, type SchemaLike, type SearchFilterBuilderLike, type SearchIndexDefinitionLike, type SelectMatchingIdsOptions, type ServerDefaultContextLike, type SettingEntry, type SettingKind, type SettingsResult, type ShapePokePart, type ShapeRow, type ShapeRowOp, type ShapeSubscriptionQuery, type ShardRankPageResult, ShardRunner, type ShardRunnerOptions, type ShardSocketLike, type SocketAttachment, type SortDirection, type SourceClientLike, type SourceCursorLike, type SourceRefresh, type SqlConsoleResult, type SqlCursor, type SqlEngine, type SqlExec, type SqlLintResult, type StorageMetadata, type StorageReference, type StorageReferenceResult, type StorageRuleMetadata, type StorageRulesResult, type StudioFeaturesResult, type SubscriptionConnection, type SubscriptionEnvelope, type SubscriptionIdentity, type SubscriptionInfo, type SubscriptionQuery, type SubscriptionsResult, type SystemDatabaseReader, type SystemDoc, type SystemQuery, type SystemReaderOptions, type SystemReaderSchedulerLike, type SystemReaderStorageLike, type SystemTableName, type TableColumnsResult, type TableDefinitionLike, type TableIndexInfo, type TableIndexesResult, type TableInfo, type TablePage, type TableReaderLike, type TablesColumnsResult, type TransactionSqlLike, type TriggerContextLike, type TriggerDefinitionLike, type TriggerEventLike, type TriggerOpLike, type TriggerTimingLike, type TtlSweepSpec, type ValidatorLike, type WhereInput, type WhereSqlStrategy, type WithInput, type WorkflowInstanceState, type WorkflowInstanceStatusResult, type WorkflowMetadata, type WorkflowsResult, type WriteEvent, type WriteHook, advanceClientWatermark, aggUpsertSql, aggregateSqlFunction, aggregateTableName, appendAuditEntry, appendCdcChange, applyCdcChanges, applyOnDelete, applySelect, armRestore, assertFlatPredicate, assertReadonly, assertShapeShardable, assertValidClientId, awaitWsDrain, backfillAggregateIndexes, backfillRankIndexes, backfillSearchIndexes, backfillSearchIndexesForTable, boundingBoxCenter, boundingBoxGeohashes, buildPokeFrames, buildSeekBeforeWhere, buildSeekWhere, buildSettings, bumpCdcEpoch, clampPromotionThresholds, clearCapturedMail, clearQueueMessages, coerceAggregateNumber, compileWhereSql, computeRankPage, containsRelationPredicate, coveringGeohashes, createCompanionSync, createDependencyTracker, createFanoutCounters, createIndexSql, createRelayLink, createShardCtxDb, createSystemReader, decodeCursor, deleteGlobalShapeSnapshot, deleteGlobalShapeSnapshotsForConnection, depKey, diffExternalSource, diffGlobalMembership, distinctValues, encodeAggregateKey, encodeCursor, encodeGeohash, encodePartitionKey, encodeRowsPatch, ensureAuditTable, ensureMailTable, exportShardRows, exportShardTable, facetColumn, fanOutScalarCounts, findStorageReferences, foldAggregateTally, geoTableName, guardWriter, hasTrigger, haversineMeters, hydrateDocsById, importShardRows, isDevEnvironment, isFtsAvailable, isLossyBody, isRelationPredicate, isSoftDeleted, isSourceDue, jsonPath, jsonPathSql, liftSourceId, lintReadonlySql, listTables, matchesRankStaticWhere, matchesStaticWhere, materializeExternalRows, materializeExternalRowsIncremental, mergeWhere, migrateCdcLog, migrateCdcMeta, migrateClientWatermark, migrateGlobalShapeSnapshot, migrateIdempotency, migrateSearchState, minCdcSeq, nextPromotionState, normalizeCountArgument, normalizeIdStructurally, normalizeOrderKeys, normalizeSourceDocument, normalizeSourceValue, param, parseExportShardArgs, parseImportShardArgs, planAggregateLookup, pointInBoundingBox, projectColumns, pullExternalSourceIncrementalTick, pullExternalSourceTick, qualifiedJsonPath, qualifiedJsonPathSql, quoteIdentifier, rankKeyFromDocument as rankKeyFromDoc, rankTableName, reactiveCacheKey, readAggregateValue, readAuditLog, readBookmark, readCapturedMail, readCdcChanges, readCdcCursor, readCdcEpoch, readClientWatermark, readExternalSourceBaseline, readGlobalShapeSnapshot, readIdempotent, readMigrationStatus, readQueueMessageById, readQueueMessages, readSchemaHistory, readSchemaVersion, readSearchBackfillState, readTablePage, recordCapturedMail, recordFanoutPass, recordQueueMessages, recordSchemaVersion, relayCountFor, renderSql, resolveRankPartition, resolveRelationPredicates, resolveWith, rowToDocument, runDataMigration, runDrizzle, runExternalSourceTick, runReadonlySql, runRowValidators, runShardMigrations, runSocketPool, runSql, runTriggers, selectExpiredIds, selectExportTables, selectIndexForAggregate, selectIndexForCount, selectIndexForGroupBy, selectMatchingIds, selectShapeMemberIds, selectShapeRows, sendDeltaFrames, serializeSqlValue, shapeRoutingKey, softDeleteScope, sortColumnName, stableStringify, stableWireKey, subscriptionListDeltas, summarizeFanoutTopics, summarizeSubscriptions, tableColumns, tableFromDepKey, throwingScheduler, trimCdcChanges, trimIdempotent, tryRowToDocument, trySendFrame, validateImportRow, writeGlobalShapeSnapshot, writeIdempotent, writeSearchBackfillState };
|