@lunora/shard-engine 1.0.0-alpha.2 → 1.0.0-alpha.21
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/dist/conformance/index.mjs +1 -1
- package/dist/index.d.mts +176 -22
- package/dist/index.d.ts +176 -22
- package/dist/index.mjs +1 -1
- package/dist/packem_shared/ADMIN_FUNCTIONS-OnYxyTXW.mjs +1 -0
- package/dist/packem_shared/AGGREGATE_SQL_FUNCTION-CTo0-9iZ.mjs +1 -0
- package/dist/packem_shared/AGG_COUNT-CqQLWpb4.mjs +1 -0
- package/dist/packem_shared/AUDIT_LOG_TABLE-C6nwXFPd.mjs +8 -0
- package/dist/packem_shared/CDC_LOG_TABLE-ZqcflEen.mjs +8 -0
- package/dist/packem_shared/{CLIENT_WATERMARK_TABLE-CXsSLU8D.mjs → CLIENT_WATERMARK_TABLE-CzApRlyv.mjs} +1 -1
- package/dist/packem_shared/CountRlsUnsupportedError-8BqPYQoP.mjs +1 -0
- package/dist/packem_shared/DATA_MIGRATION_STATE_TABLE-BrpAGtXf.mjs +31 -0
- package/dist/packem_shared/DEFAULT_MAX_RELATION_KEYS-DjKka36Z.mjs +1 -0
- package/dist/packem_shared/DEFAULT_MAX_RELAYS-B19vrJxP.mjs +1 -0
- package/dist/packem_shared/{DEFAULT_PROMOTION_THRESHOLDS-Dteg0sZF.mjs → DEFAULT_PROMOTION_THRESHOLDS-B2rUe1bg.mjs} +1 -1
- package/dist/packem_shared/DEFAULT_TRANSACTION_LIMITS-q7ouI3i0.mjs +1 -0
- package/dist/packem_shared/GEO_DEFAULT_PRECISION-DyI5zggj.mjs +1 -0
- package/dist/packem_shared/{GLOBAL_SHAPE_SNAPSHOT_TABLE-DX-6-gBP.mjs → GLOBAL_SHAPE_SNAPSHOT_TABLE-soMJDSBs.mjs} +1 -1
- package/dist/packem_shared/{IDEMPOTENCY_TABLE-DjkEMp6w.mjs → IDEMPOTENCY_TABLE-Bvu9JkiL.mjs} +1 -1
- package/dist/packem_shared/MAIL_RETENTION-BefR9Sei.mjs +18 -0
- package/dist/packem_shared/NotUniqueError-CVHdtVw6.mjs +1 -0
- package/dist/packem_shared/QUEUE_TABLE-DgBqWrXX.mjs +17 -0
- package/dist/packem_shared/RANK_TIEBREAK-DDtST3gN.mjs +1 -0
- package/dist/packem_shared/REPROJECTION_MIGRATION_PREFIX-D2dltRFC.mjs +1 -0
- package/dist/packem_shared/RLS_UNWRAP_SYMBOL-DcqORh2s.mjs +1 -0
- package/dist/packem_shared/ReactiveCache-Cu8IfE1M.mjs +1 -0
- package/dist/packem_shared/SCHEMA_HISTORY_MAX_VERSIONS-BEU0CuW5.mjs +6 -0
- package/dist/packem_shared/SEARCH_STATE_TABLE-BZ_fxI5l.mjs +1 -0
- package/dist/packem_shared/aggregateTableName-DgYMC5tr.mjs +1 -0
- package/dist/packem_shared/applyOnDelete-By23GK-k.mjs +1 -0
- package/dist/packem_shared/applySelect-UY-o13Ia.mjs +1 -0
- package/dist/packem_shared/awaitWsDrain-Bp2jKzIb.mjs +1 -0
- package/dist/packem_shared/backfillAggregateIndexes-DmqOHg0U.mjs +1 -0
- package/dist/packem_shared/base64-fKomMf5D.mjs +1 -0
- package/dist/packem_shared/buildIndexRange-DFsdtPjD.mjs +1 -0
- package/dist/packem_shared/{buildPokeFrames-DaPpm5Ss.mjs → buildPokeFrames-CqxaN8_H.mjs} +1 -1
- package/dist/packem_shared/buildReprojectionMigration-Ctl4r84d.mjs +1 -0
- package/dist/packem_shared/buildSettings-COIJsw7a.mjs +1 -0
- package/dist/packem_shared/compileWhereSql-B4rPariq.mjs +1 -0
- package/dist/packem_shared/computeRankPage-QK8SeTZ-.mjs +1 -0
- package/dist/packem_shared/createCompanionSync-COw1Uy6a.mjs +1 -0
- package/dist/packem_shared/createReadFootprint-DIrrxRTE.mjs +1 -0
- package/dist/packem_shared/createReplicaLink-BMNW0SX6.mjs +7 -0
- package/dist/packem_shared/ctx-db-companions-BTi8DLUl.mjs +1 -0
- package/dist/packem_shared/{defineEngineContractSuite-ii3_DS_I.mjs → defineEngineContractSuite-B6nrsKSE.mjs} +1 -1
- package/dist/packem_shared/do-sql-1Yi1_Yq0.mjs +1 -0
- package/dist/packem_shared/estimate-bytes-Drp8rhPs.mjs +1 -0
- package/dist/packem_shared/exportShardRows-Bbi_JGfn.mjs +1 -0
- package/dist/packem_shared/{isSoftDeleted-B-SXkGUo.mjs → isSoftDeleted-Bo-y3DOe.mjs} +1 -1
- package/dist/packem_shared/{materializeExternalRows-DOQJV9p2.mjs → materializeExternalRows-DcCENzpV.mjs} +1 -1
- package/dist/packem_shared/mergeChangedKeys-BXtUgIPW.mjs +1 -0
- package/dist/packem_shared/quoteIdentifier-CObIFRhb.mjs +1 -0
- package/dist/packem_shared/runDrizzle-B6rnz3so.mjs +1 -0
- package/dist/packem_shared/runShardMigrations-BqO6HPtX.mjs +5 -0
- package/dist/packem_shared/selectExpiredIds-C6nQK7E2.mjs +1 -0
- package/dist/packem_shared/selectShapeMemberIds-BdBcbrUP.mjs +1 -0
- package/dist/packem_shared/serializeSqlValue-BR4UOWoP.mjs +1 -0
- package/dist/packem_shared/sibling-channel-bg9FBL5s.mjs +1 -0
- package/dist/packem_shared/sql-projection-jfoe331H.mjs +1 -0
- package/dist/packem_shared/stableWireKey-l3cjIt-9.mjs +1 -0
- package/dist/packem_shared/wire-codec-Dsy70M3Q.mjs +1 -0
- package/package.json +3 -3
- package/dist/packem_shared/ADMIN_FUNCTIONS-B0xlQJ4w.mjs +0 -1
- package/dist/packem_shared/AGGREGATE_SQL_FUNCTION-QYaiuty4.mjs +0 -1
- package/dist/packem_shared/AGG_COUNT-BWXe3gtQ.mjs +0 -1
- package/dist/packem_shared/AUDIT_LOG_TABLE-CaA0jL0L.mjs +0 -8
- package/dist/packem_shared/CDC_LOG_TABLE-BnqlH2eZ.mjs +0 -8
- package/dist/packem_shared/CountRlsUnsupportedError-B2WKJD9v.mjs +0 -1
- package/dist/packem_shared/DATA_MIGRATION_STATE_TABLE-CaO6L0Ee.mjs +0 -31
- package/dist/packem_shared/DEFAULT_MAX_RELATION_KEYS-bq00btqV.mjs +0 -1
- package/dist/packem_shared/DEFAULT_MAX_RELAYS-CnCyh6oX.mjs +0 -1
- package/dist/packem_shared/FTS_COUNT_COLUMN-D1gY3wwZ-CZHdaRrd.mjs +0 -1
- package/dist/packem_shared/GEO_DEFAULT_PRECISION-okRCkZ6r.mjs +0 -1
- package/dist/packem_shared/MAIL_RETENTION-KmozO2NQ.mjs +0 -18
- package/dist/packem_shared/NotUniqueError-Bw1Oh2FL.mjs +0 -1
- package/dist/packem_shared/QUEUE_TABLE-DYCDvzTG.mjs +0 -17
- package/dist/packem_shared/RANK_TIEBREAK-9NU5s_mi.mjs +0 -1
- package/dist/packem_shared/RLS_UNWRAP_SYMBOL-C6_WX3dG.mjs +0 -1
- package/dist/packem_shared/ReactiveCache-1_9Rs7J_.mjs +0 -1
- package/dist/packem_shared/SCHEMA_HISTORY_MAX_VERSIONS-CHXz6p_z.mjs +0 -6
- package/dist/packem_shared/SEARCH_STATE_TABLE-eLN8U5tz.mjs +0 -1
- package/dist/packem_shared/aggregateTableName-G-eXyjcz.mjs +0 -1
- package/dist/packem_shared/applyOnDelete-uFRC5p1d.mjs +0 -1
- package/dist/packem_shared/applySelect-B0CF8T7y.mjs +0 -1
- package/dist/packem_shared/awaitWsDrain-Dk50ISgE.mjs +0 -1
- package/dist/packem_shared/backfillAggregateIndexes-BHiewuB-.mjs +0 -1
- package/dist/packem_shared/buildSettings-DT18_DkX.mjs +0 -1
- package/dist/packem_shared/compileWhereSql-BLcfs4QW.mjs +0 -1
- package/dist/packem_shared/computeRankPage-IUSS-zIB.mjs +0 -1
- package/dist/packem_shared/createCompanionSync-BCBUOnMk.mjs +0 -1
- package/dist/packem_shared/exportShardRows-kt42wijd.mjs +0 -1
- package/dist/packem_shared/quote-identifier-CGiYFBvY.mjs +0 -1
- package/dist/packem_shared/runDrizzle-GKR3y97k.mjs +0 -1
- package/dist/packem_shared/runShardMigrations-CPxqCh3O.mjs +0 -5
- package/dist/packem_shared/selectExpiredIds-FzhIEeG1.mjs +0 -1
- package/dist/packem_shared/selectShapeMemberIds-DvE7K6zG.mjs +0 -1
- package/dist/packem_shared/serializeSqlValue-DnpyaLcw.mjs +0 -1
- package/dist/packem_shared/stableWireKey-YEHLaX6X.mjs +0 -1
- package/dist/packem_shared/wire-codec-Ctnni0h6.mjs +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,27 @@
|
|
|
1
1
|
import { LunoraError } from '@lunora/errors';
|
|
2
2
|
import { SQL, Name } from 'drizzle-orm';
|
|
3
3
|
import { ShardHost, SocketHost, SocketHandle } from '@lunora/platform';
|
|
4
|
+
interface KeyRange {
|
|
5
|
+
hi: string;
|
|
6
|
+
index: string;
|
|
7
|
+
lo: string;
|
|
8
|
+
table: string;
|
|
9
|
+
}
|
|
10
|
+
interface IndexKeyEntry {
|
|
11
|
+
index: string;
|
|
12
|
+
key: string;
|
|
13
|
+
}
|
|
14
|
+
interface StagedCondition {
|
|
15
|
+
comparator: string;
|
|
16
|
+
field: string;
|
|
17
|
+
value: unknown;
|
|
18
|
+
}
|
|
19
|
+
declare const buildIndexRange: (table: string, index: string, fields: ReadonlyArray<string>, conditions: ReadonlyArray<StagedCondition>, serialize: (value: unknown) => unknown) => KeyRange | undefined;
|
|
20
|
+
declare const indexKeysForRow: (indexes: ReadonlyArray<{
|
|
21
|
+
fields: ReadonlyArray<string>;
|
|
22
|
+
name: string;
|
|
23
|
+
}>, row: Record<string, unknown>, serialize: (value: unknown) => unknown) => IndexKeyEntry[];
|
|
24
|
+
declare const keysTouchRanges: (ranges: ReadonlyArray<KeyRange> | undefined, keys: ReadonlyArray<IndexKeyEntry> | undefined) => boolean;
|
|
4
25
|
type SystemTableName = "_scheduled_functions" | "_storage";
|
|
5
26
|
interface ScheduledFunctionDoc {
|
|
6
27
|
args: Record<string, unknown>;
|
|
@@ -209,6 +230,7 @@ interface ResolveWithOptions {
|
|
|
209
230
|
groupedCounter: (tableName: string, whereField: string, values: unknown[], policyWhere?: WhereInput) => Promise<Map<unknown, number>>;
|
|
210
231
|
parents: Record<string, unknown>[];
|
|
211
232
|
relationBaseWhere?: (table: string) => undefined | WhereInput;
|
|
233
|
+
relationMask?: RelationMask;
|
|
212
234
|
schema: {
|
|
213
235
|
readonly tables: Record<string, TableDefinitionLike>;
|
|
214
236
|
};
|
|
@@ -229,11 +251,19 @@ interface QueryArgs {
|
|
|
229
251
|
limit?: number;
|
|
230
252
|
orderBy?: OrderByInput[];
|
|
231
253
|
relationBaseWhere?: (table: string) => undefined | WhereInput;
|
|
254
|
+
relationMask?: RelationMask;
|
|
232
255
|
restrictsCounts?: boolean;
|
|
233
256
|
select?: ReadonlyArray<string>;
|
|
234
257
|
where?: WhereInput;
|
|
235
258
|
with?: WithInput;
|
|
236
259
|
}
|
|
260
|
+
interface CrossShardReadArgs {
|
|
261
|
+
orderBy?: OrderByInput[];
|
|
262
|
+
relationPolicies?: Record<string, WhereInput>;
|
|
263
|
+
where?: WhereInput;
|
|
264
|
+
with?: WithInput;
|
|
265
|
+
}
|
|
266
|
+
type RelationMask = (table: string, rows: Record<string, unknown>[]) => Record<string, unknown>[];
|
|
237
267
|
interface QueryPage {
|
|
238
268
|
continueCursor: null | string;
|
|
239
269
|
isDone: boolean;
|
|
@@ -338,9 +368,21 @@ interface GeoFilterBuilderLike {
|
|
|
338
368
|
};
|
|
339
369
|
}) => GeoFilterBuilderLike;
|
|
340
370
|
}
|
|
371
|
+
type ScoredDocument = GeoScoredDocument | SearchScoredDocument;
|
|
372
|
+
interface GeoScoredDocument {
|
|
373
|
+
distanceMeters: null | number;
|
|
374
|
+
document: Record<string, unknown>;
|
|
375
|
+
score?: never;
|
|
376
|
+
}
|
|
377
|
+
interface SearchScoredDocument {
|
|
378
|
+
distanceMeters?: never;
|
|
379
|
+
document: Record<string, unknown>;
|
|
380
|
+
score: number;
|
|
381
|
+
}
|
|
341
382
|
interface TableReaderLike {
|
|
342
383
|
[Symbol.asyncIterator]: () => AsyncIterator<Record<string, unknown>>;
|
|
343
384
|
collect: () => Promise<Record<string, unknown>[]>;
|
|
385
|
+
collectWithScores: () => Promise<ScoredDocument[]>;
|
|
344
386
|
filter: (predicate: (document: Record<string, unknown>) => boolean) => TableReaderLike;
|
|
345
387
|
first: () => Promise<Record<string, unknown> | null>;
|
|
346
388
|
order: (direction: "asc" | "desc") => TableReaderLike;
|
|
@@ -372,6 +414,7 @@ interface LifecycleDispatchInfo {
|
|
|
372
414
|
userId: string | undefined;
|
|
373
415
|
}
|
|
374
416
|
interface MutationDelta {
|
|
417
|
+
indexKeys?: ReadonlyArray<IndexKeyEntry>;
|
|
375
418
|
key: string;
|
|
376
419
|
op: "insert" | "update" | "delete";
|
|
377
420
|
row?: Record<string, unknown>;
|
|
@@ -536,6 +579,7 @@ interface CacheEntry {
|
|
|
536
579
|
bytes: number;
|
|
537
580
|
deps: Set<string>;
|
|
538
581
|
lastUsed: number;
|
|
582
|
+
ranges: ReadonlyArray<KeyRange>;
|
|
539
583
|
result: unknown;
|
|
540
584
|
subscribers: Set<string>;
|
|
541
585
|
}
|
|
@@ -547,6 +591,7 @@ interface ReactiveCacheOptions {
|
|
|
547
591
|
declare class ReactiveCache {
|
|
548
592
|
private readonly entries;
|
|
549
593
|
private readonly tableIndex;
|
|
594
|
+
private readonly rangeIndex;
|
|
550
595
|
private totalBytes;
|
|
551
596
|
private hits;
|
|
552
597
|
private misses;
|
|
@@ -556,8 +601,8 @@ declare class ReactiveCache {
|
|
|
556
601
|
private readonly now;
|
|
557
602
|
private monotonic;
|
|
558
603
|
constructor(options?: ReactiveCacheOptions);
|
|
559
|
-
run<R>(key: string, deps: Set<string>, run: () => Promise<R>): Promise<R>;
|
|
560
|
-
invalidate(table: string, id: string): string[];
|
|
604
|
+
run<R>(key: string, deps: Set<string>, run: () => Promise<R>, ranges?: () => ReadonlyArray<KeyRange>): Promise<R>;
|
|
605
|
+
invalidate(table: string, id: string, indexKeys?: ReadonlyArray<IndexKeyEntry>): string[];
|
|
561
606
|
invalidateTable(table: string): string[];
|
|
562
607
|
subscribe(key: string, subscriberId: string): void;
|
|
563
608
|
unsubscribe(key: string, subscriberId: string): void;
|
|
@@ -574,11 +619,37 @@ declare class ReactiveCache {
|
|
|
574
619
|
hits: number;
|
|
575
620
|
misses: number;
|
|
576
621
|
};
|
|
622
|
+
private dropRangeDeps;
|
|
577
623
|
private collectAndDrop;
|
|
624
|
+
private dropKeys;
|
|
578
625
|
private dropEntry;
|
|
579
626
|
private evict;
|
|
580
627
|
}
|
|
581
628
|
declare const reactiveCacheKey: (functionPath: string, args: Record<string, unknown>, identity: null | string) => string;
|
|
629
|
+
interface TransactionLimits {
|
|
630
|
+
maxReadRows: number;
|
|
631
|
+
maxWrittenBytes: number;
|
|
632
|
+
maxWrittenRows: number;
|
|
633
|
+
}
|
|
634
|
+
interface TransactionHeadroom {
|
|
635
|
+
readRows: number;
|
|
636
|
+
remainingReadRows: number;
|
|
637
|
+
remainingWrittenBytes: number;
|
|
638
|
+
remainingWrittenRows: number;
|
|
639
|
+
writtenBytes: number;
|
|
640
|
+
writtenRows: number;
|
|
641
|
+
}
|
|
642
|
+
declare const DEFAULT_TRANSACTION_LIMITS: TransactionLimits;
|
|
643
|
+
declare class TransactionHeadroomTracker {
|
|
644
|
+
private readRows;
|
|
645
|
+
private writtenRows;
|
|
646
|
+
private writtenBytes;
|
|
647
|
+
private readonly limits;
|
|
648
|
+
constructor(limits?: Partial<TransactionLimits>);
|
|
649
|
+
recordRead(count: number): void;
|
|
650
|
+
recordWrite(row: unknown): void;
|
|
651
|
+
headroom(): TransactionHeadroom;
|
|
652
|
+
}
|
|
582
653
|
interface RunTriggersOptions {
|
|
583
654
|
ctx: TriggerContextLike;
|
|
584
655
|
event: TriggerEventLike;
|
|
@@ -713,10 +784,12 @@ interface CtxDbOptions {
|
|
|
713
784
|
clock?: Clock;
|
|
714
785
|
enforceRls?: boolean;
|
|
715
786
|
globalDb?: DatabaseWriterLike;
|
|
787
|
+
headroom?: TransactionHeadroomTracker;
|
|
716
788
|
idGenerator?: IdGenerator;
|
|
717
789
|
maxRelationKeys?: number;
|
|
718
790
|
onIndexUse?: IndexUseHook;
|
|
719
791
|
onRead?: ReadHook;
|
|
792
|
+
onReadRange?: (range: KeyRange) => void;
|
|
720
793
|
onWrite?: WriteHook;
|
|
721
794
|
relationExistsPushDown?: "always" | "auto" | "never";
|
|
722
795
|
scheduler?: SchedulerLike;
|
|
@@ -816,7 +889,11 @@ interface ShardSocketLike {
|
|
|
816
889
|
}
|
|
817
890
|
interface CompanionSyncDeps {
|
|
818
891
|
broadcast: (delta: MutationDelta) => void;
|
|
819
|
-
|
|
892
|
+
indexKeysFor: (table: string, document?: Record<string, unknown>) => ReadonlyArray<{
|
|
893
|
+
index: string;
|
|
894
|
+
key: string;
|
|
895
|
+
}> | undefined;
|
|
896
|
+
invalidateCache: (table: string, id: string, document?: Record<string, unknown>) => void;
|
|
820
897
|
recordCdc: (table: string, id: string, op: "delete" | "insert" | "update", doc?: Record<string, unknown>) => void;
|
|
821
898
|
schema: SchemaLike;
|
|
822
899
|
sql: SqlExec;
|
|
@@ -856,7 +933,11 @@ declare const DATA_MIGRATION_STATE_TABLE = "__lunora_migrations";
|
|
|
856
933
|
type MigrationDirection = "down" | "up";
|
|
857
934
|
type MigrationStatus = "completed" | "failed" | "in_progress";
|
|
858
935
|
type DataMigrationDocument = Record<string, unknown>;
|
|
859
|
-
type
|
|
936
|
+
type DataMigrationReader = Pick<DatabaseWriterLike, "count" | "findFirst" | "findMany" | "get">;
|
|
937
|
+
interface DataMigrationContext {
|
|
938
|
+
db: DataMigrationReader;
|
|
939
|
+
}
|
|
940
|
+
type DataMigrationTransform = (document: DataMigrationDocument, context: DataMigrationContext) => DataMigrationDocument | Promise<DataMigrationDocument | undefined> | undefined;
|
|
860
941
|
interface DataMigrationLike {
|
|
861
942
|
readonly batchSize?: number;
|
|
862
943
|
readonly down?: DataMigrationTransform;
|
|
@@ -911,10 +992,10 @@ interface DependencyTracker {
|
|
|
911
992
|
declare const createDependencyTracker: () => DependencyTracker;
|
|
912
993
|
declare const runSql: <Row = Record<string, unknown>>(sql: SqlExec, query: string, ...params: unknown[]) => SqlCursor<Row>;
|
|
913
994
|
declare const runDrizzle: <Row = Record<string, unknown>>(exec: SqlExec, query: SQL) => SqlCursor<Row>;
|
|
995
|
+
declare const quoteIdentifier: (name: string) => string;
|
|
914
996
|
declare const serializeSqlValue: (value: unknown) => unknown;
|
|
915
997
|
declare const DOC_COLUMN = "__doc__";
|
|
916
998
|
declare const geoTableName: (table: string, indexName: string) => string;
|
|
917
|
-
declare const quoteIdentifier: (name: string) => string;
|
|
918
999
|
declare const jsonPath: (field: string) => string;
|
|
919
1000
|
declare const jsonPathSql: (field: string) => SQL;
|
|
920
1001
|
declare const qualifiedJsonPath: (table: string, field: string) => string;
|
|
@@ -1048,6 +1129,7 @@ declare const ADMIN_FUNCTIONS: {
|
|
|
1048
1129
|
readonly getMetricSeries: "__lunora_admin__:getMetricSeries";
|
|
1049
1130
|
readonly listSubscriptions: "__lunora_admin__:listSubscriptions";
|
|
1050
1131
|
readonly listTableIndexes: "__lunora_admin__:listTableIndexes";
|
|
1132
|
+
readonly listTablesIndexes: "__lunora_admin__:listTablesIndexes";
|
|
1051
1133
|
readonly getLogs: "__lunora_admin__:getLogs";
|
|
1052
1134
|
readonly getMetrics: "__lunora_admin__:getMetrics";
|
|
1053
1135
|
readonly getPitrBookmark: "__lunora_admin__:getPitrBookmark";
|
|
@@ -1140,6 +1222,9 @@ interface TableIndexInfo {
|
|
|
1140
1222
|
interface TableIndexesResult {
|
|
1141
1223
|
indexes: TableIndexInfo[];
|
|
1142
1224
|
}
|
|
1225
|
+
interface TablesIndexesResult {
|
|
1226
|
+
indexesByTable: Record<string, TableIndexInfo[]>;
|
|
1227
|
+
}
|
|
1143
1228
|
interface ColumnMeta {
|
|
1144
1229
|
isStorage?: boolean;
|
|
1145
1230
|
name: string;
|
|
@@ -1170,12 +1255,13 @@ interface AdvisoriesResult {
|
|
|
1170
1255
|
advisories: AdvisoryFinding[];
|
|
1171
1256
|
}
|
|
1172
1257
|
interface AdvisorProcedure {
|
|
1173
|
-
|
|
1258
|
+
analyzableBody?: boolean;
|
|
1259
|
+
callsMail?: boolean;
|
|
1174
1260
|
emitsEvent?: boolean;
|
|
1175
1261
|
exempt?: boolean;
|
|
1176
1262
|
exemptReason?: string;
|
|
1177
1263
|
exportName: string;
|
|
1178
|
-
fanOut
|
|
1264
|
+
fanOut?: boolean;
|
|
1179
1265
|
file: string;
|
|
1180
1266
|
handlesErrors?: boolean;
|
|
1181
1267
|
hasEmailArg?: boolean;
|
|
@@ -1183,15 +1269,15 @@ interface AdvisorProcedure {
|
|
|
1183
1269
|
reachesOutbound?: boolean;
|
|
1184
1270
|
runsAiGeneration?: boolean;
|
|
1185
1271
|
throwsBareError?: boolean;
|
|
1186
|
-
unboundedAiGeneration
|
|
1272
|
+
unboundedAiGeneration?: boolean;
|
|
1187
1273
|
usesCaptcha: boolean;
|
|
1188
1274
|
usesEmailGate: boolean;
|
|
1189
|
-
usesInsertManyUnsafe
|
|
1275
|
+
usesInsertManyUnsafe?: boolean;
|
|
1190
1276
|
usesMask: boolean;
|
|
1191
1277
|
usesRateLimit: boolean;
|
|
1192
1278
|
usesRls: boolean;
|
|
1193
1279
|
visibility: "internal" | "public";
|
|
1194
|
-
writesUserTable
|
|
1280
|
+
writesUserTable?: boolean;
|
|
1195
1281
|
}
|
|
1196
1282
|
interface AdvisorProceduresResult {
|
|
1197
1283
|
procedures: AdvisorProcedure[];
|
|
@@ -1533,7 +1619,6 @@ declare const clearQueueMessages: (sql: SqlExec) => {
|
|
|
1533
1619
|
declare const encodePartitionKey: (partitionBy: ReadonlyArray<string>, source: Record<string, unknown>) => string;
|
|
1534
1620
|
declare const RANK_TIEBREAK = "__id__";
|
|
1535
1621
|
declare const sortColumnName: (i: number) => string;
|
|
1536
|
-
declare const matchesRankStaticWhere: (document: Record<string, unknown>, predicate: Record<string, unknown>) => boolean;
|
|
1537
1622
|
declare const resolveRankPartition: (index: RankIndexDefinitionLike, where: Record<string, unknown> | undefined) => Record<string, unknown> | undefined;
|
|
1538
1623
|
declare const rankTableName: (table: string, indexName: string) => string;
|
|
1539
1624
|
declare const rankKeyFromDocument: (index: RankIndexDefinitionLike, document_: Record<string, unknown>) => {
|
|
@@ -1541,6 +1626,14 @@ declare const rankKeyFromDocument: (index: RankIndexDefinitionLike, document_: R
|
|
|
1541
1626
|
rowId: string;
|
|
1542
1627
|
sortValues: unknown[];
|
|
1543
1628
|
};
|
|
1629
|
+
declare const matchesRankStaticWhere: (document: Record<string, unknown>, predicate: Record<string, unknown>) => boolean;
|
|
1630
|
+
interface ReadFootprint {
|
|
1631
|
+
onRead: (table: string, idOrScan?: string) => void;
|
|
1632
|
+
onReadRange: (range: KeyRange) => void;
|
|
1633
|
+
ranges: () => Map<string, KeyRange[]> | undefined;
|
|
1634
|
+
tables: Set<string>;
|
|
1635
|
+
}
|
|
1636
|
+
declare const createReadFootprint: () => ReadFootprint;
|
|
1544
1637
|
declare const DEFAULT_MAX_RELATION_KEYS = 5000;
|
|
1545
1638
|
interface RelationExistsMarker {
|
|
1546
1639
|
childWhere: WhereInput;
|
|
@@ -1575,6 +1668,7 @@ declare const containsRelationPredicate: (where: WhereInput, schema: ResolveCont
|
|
|
1575
1668
|
declare const assertFlatPredicate: (where: WhereInput | undefined, schema: ResolveContext["schema"], tableName: string, op: string) => void;
|
|
1576
1669
|
declare const resolveRelationPredicates: (where: WhereInput | undefined, options: ResolveRelationPredicatesOptions) => Promise<WhereInput | undefined>;
|
|
1577
1670
|
declare const assertShapeShardable: (effectiveWhere: WhereInput | undefined, schema: ResolveContext["schema"], table: string) => void;
|
|
1671
|
+
declare const relationHooks: (args: Pick<QueryArgs, "relationBaseWhere" | "relationMask">) => Pick<QueryArgs, "relationBaseWhere" | "relationMask">;
|
|
1578
1672
|
declare const fanOutScalarCounts: (counter: (tableName: string, where?: WhereInput) => Promise<number>, tableName: string, whereField: string, values: unknown[], policyWhere: WhereInput | undefined) => Promise<Map<unknown, number>>;
|
|
1579
1673
|
declare const distinctValues: (rows: Record<string, unknown>[], field: string) => unknown[];
|
|
1580
1674
|
declare const resolveWith: (options: ResolveWithOptions) => Promise<void>;
|
|
@@ -1679,15 +1773,10 @@ interface RelayShapePoke {
|
|
|
1679
1773
|
type: "relay_shape_poke";
|
|
1680
1774
|
}
|
|
1681
1775
|
type OwnerRelayFrame = RelayAttach | RelayDetach | RelayFrame | RelayShapePoke | RelayShapeSubscribe;
|
|
1682
|
-
|
|
1683
|
-
interface RelayStub {
|
|
1776
|
+
interface SiblingStub {
|
|
1684
1777
|
fetch: (url: string, init?: RequestInit) => Promise<Response>;
|
|
1685
1778
|
}
|
|
1686
|
-
|
|
1687
|
-
get: (id: unknown) => RelayStub;
|
|
1688
|
-
getByName?: (name: string) => RelayStub;
|
|
1689
|
-
idFromName: (name: string) => unknown;
|
|
1690
|
-
}
|
|
1779
|
+
declare const DEFAULT_MAX_RELAYS = 8;
|
|
1691
1780
|
interface RelayHost {
|
|
1692
1781
|
buildShapeDiff: (resolved: ResolvedShape, fromCursor: number, toCursor: number) => ShapeRowOp[];
|
|
1693
1782
|
computeOpLogShapeSeed: (shape: ShapeSubscriptionQuery, resolved: ResolvedShape) => {
|
|
@@ -1723,7 +1812,7 @@ declare abstract class RelayLink {
|
|
|
1723
1812
|
handleControl(request: Request): Promise<Response>;
|
|
1724
1813
|
maxRelays(): number;
|
|
1725
1814
|
protected canAddressSiblings(): boolean;
|
|
1726
|
-
protected
|
|
1815
|
+
protected siblingStub(targetName: string): SiblingStub | undefined;
|
|
1727
1816
|
protected postRelayMessage(targetName: string, message: OwnerRelayFrame): Promise<void>;
|
|
1728
1817
|
protected requestRelayMessage(targetName: string, message: OwnerRelayFrame): Promise<Response | undefined>;
|
|
1729
1818
|
abstract forwardWhisper(topic: string, frame: string): Promise<void>;
|
|
@@ -1764,6 +1853,7 @@ declare class OwnerRelay extends RelayLink {
|
|
|
1764
1853
|
protected onWhisperFrame(message: RelayFrame): Promise<void>;
|
|
1765
1854
|
protected onShapeSubscribe(message: RelayShapeSubscribe): RelayShapeSeed;
|
|
1766
1855
|
protected onShapePoke(): number;
|
|
1856
|
+
private buildShapePoke;
|
|
1767
1857
|
private multicastShapePokes;
|
|
1768
1858
|
private proxyShapePokes;
|
|
1769
1859
|
private buildShapeSeedFrames;
|
|
@@ -1797,6 +1887,61 @@ declare class RelayMember extends RelayLink {
|
|
|
1797
1887
|
private deliverShapePoke;
|
|
1798
1888
|
}
|
|
1799
1889
|
declare const createRelayLink: (host: RelayHost) => OwnerRelay | RelayMember | undefined;
|
|
1890
|
+
declare const REGION_HINTS: readonly ["wnam", "enam", "sam", "weur", "eeur", "apac", "apac-ne", "apac-se", "oc", "afr", "me"];
|
|
1891
|
+
type RegionHint = (typeof REGION_HINTS)[number];
|
|
1892
|
+
type ReplicaReadiness = "fresh" | "stale" | "unavailable";
|
|
1893
|
+
interface ShardSiblingHost {
|
|
1894
|
+
doName: () => string | undefined;
|
|
1895
|
+
env: () => unknown;
|
|
1896
|
+
shardBinding: () => string | undefined;
|
|
1897
|
+
sql: () => SqlExec;
|
|
1898
|
+
}
|
|
1899
|
+
interface ReplicaOwnerHost extends ShardSiblingHost {
|
|
1900
|
+
exportRows: () => Promise<ExportRow[]>;
|
|
1901
|
+
ownerCursor: () => number | undefined;
|
|
1902
|
+
ownerEpoch: () => string | undefined;
|
|
1903
|
+
ownerFloor: () => number | undefined;
|
|
1904
|
+
readChanges: (sinceSeq: number, limit: number) => {
|
|
1905
|
+
changes: CdcChange[];
|
|
1906
|
+
cursor: number;
|
|
1907
|
+
};
|
|
1908
|
+
rowCount: () => number;
|
|
1909
|
+
}
|
|
1910
|
+
interface ReplicaFollowerHost extends ShardSiblingHost {
|
|
1911
|
+
applyChanges: (changes: ReadonlyArray<CdcChange>) => Promise<number>;
|
|
1912
|
+
importRows: (rows: ReadonlyArray<ExportRow>) => Promise<{
|
|
1913
|
+
errors: ReadonlyArray<unknown>;
|
|
1914
|
+
}>;
|
|
1915
|
+
}
|
|
1916
|
+
declare const handleReplicaControl: (host: ReplicaOwnerHost, request: Request) => Promise<Response>;
|
|
1917
|
+
declare class ShardReplica {
|
|
1918
|
+
private readonly host;
|
|
1919
|
+
readonly ownerKey: string;
|
|
1920
|
+
readonly region: RegionHint;
|
|
1921
|
+
private divergent;
|
|
1922
|
+
private inFlight;
|
|
1923
|
+
constructor(host: ReplicaFollowerHost, ownerKey: string, region: RegionHint);
|
|
1924
|
+
ensureFresh(minSeq?: number): Promise<ReplicaReadiness>;
|
|
1925
|
+
appliedSeq(): number;
|
|
1926
|
+
isDivergent(): boolean;
|
|
1927
|
+
private advance;
|
|
1928
|
+
private isCaughtUp;
|
|
1929
|
+
private catchUp;
|
|
1930
|
+
private applyPage;
|
|
1931
|
+
private hasDiverged;
|
|
1932
|
+
private bootstrap;
|
|
1933
|
+
private isFreshEnough;
|
|
1934
|
+
private pull;
|
|
1935
|
+
private request;
|
|
1936
|
+
}
|
|
1937
|
+
declare const createReplicaLink: (host: ReplicaFollowerHost) => ShardReplica | undefined;
|
|
1938
|
+
declare const gateReplicaDispatch: (replica: ShardReplica, request: Request, functionPath: string) => Promise<Response | undefined>;
|
|
1939
|
+
declare const REPROJECTION_MIGRATION_PREFIX = "__lunora_reproject__";
|
|
1940
|
+
declare const reprojectionMigrationId: (table: string) => string;
|
|
1941
|
+
declare const reprojectableFields: (definition: TableDefinitionLike) => string[];
|
|
1942
|
+
declare const reprojectionTables: (schema: SchemaLike) => string[];
|
|
1943
|
+
declare const countLegacyRows: (sql: SqlExec, table: string, fields: ReadonlyArray<string>) => number;
|
|
1944
|
+
declare const buildReprojectionMigration: (id: string, schema: SchemaLike, sql: SqlExec) => DataMigrationLike | undefined;
|
|
1800
1945
|
declare const RLS_UNWRAP_SYMBOL: symbol;
|
|
1801
1946
|
declare class RlsRequiredError extends LunoraError {
|
|
1802
1947
|
readonly table: string;
|
|
@@ -1812,7 +1957,8 @@ interface GuardableSchema {
|
|
|
1812
1957
|
}>;
|
|
1813
1958
|
}
|
|
1814
1959
|
type TableOfId = (id: string, expectedTable?: string) => Promise<string | undefined> | string | undefined;
|
|
1815
|
-
|
|
1960
|
+
type TablesOfIds = (ids: ReadonlyArray<string>, expectedTable?: string) => Promise<ReadonlyMap<string, string>> | ReadonlyMap<string, string>;
|
|
1961
|
+
declare const guardWriter: <W>(raw: W, schema: GuardableSchema, tableOfId: TableOfId, tablesOfIds?: TablesOfIds) => W;
|
|
1816
1962
|
declare const SCHEMA_HISTORY_MAX_VERSIONS = 50;
|
|
1817
1963
|
interface SchemaVersionRow {
|
|
1818
1964
|
appliedAt: number;
|
|
@@ -1874,8 +2020,16 @@ interface DrainableSink {
|
|
|
1874
2020
|
readonly bufferedAmount?: unknown;
|
|
1875
2021
|
}
|
|
1876
2022
|
declare const trySendFrame: (ws: FrameSink, frame: string) => boolean;
|
|
1877
|
-
declare const sendDeltaFrames: (ws: FrameSink, subId: string, deltaFrames: ReadonlyArray<string>, cursorSuffix: string) => boolean;
|
|
2023
|
+
declare const sendDeltaFrames: (ws: FrameSink, subId: string, deltaFrames: ReadonlyArray<string>, cursorSuffix: string, lastMutationId?: number) => boolean;
|
|
1878
2024
|
declare const awaitWsDrain: (ws: DrainableSink) => Promise<void>;
|
|
2025
|
+
interface SubscriptionReadFootprint {
|
|
2026
|
+
ranges?: Map<string, KeyRange[]>;
|
|
2027
|
+
tables: Set<string>;
|
|
2028
|
+
}
|
|
2029
|
+
type ChangedKeys = Map<string, IndexKeyEntry[] | undefined>;
|
|
2030
|
+
declare const mergeChangedKeys: (pending: ChangedKeys | undefined, incoming: ChangedKeys | undefined, changed: Set<string>) => ChangedKeys;
|
|
2031
|
+
declare const recordChangedKeys: (pending: ChangedKeys | undefined, table: string, indexKeys: ReadonlyArray<IndexKeyEntry> | undefined) => ChangedKeys;
|
|
2032
|
+
declare const writeTouchesMemo: (memo: SubscriptionReadFootprint, changed: Set<string>, changedKeys: ChangedKeys | undefined) => boolean;
|
|
1879
2033
|
type ConflictKind = "conflict" | "occ" | "restrict" | "trigger" | "unique";
|
|
1880
2034
|
declare class ConflictError extends LunoraError {
|
|
1881
2035
|
readonly kind: ConflictKind;
|
|
@@ -1903,4 +2057,4 @@ interface WhereSqlStrategy {
|
|
|
1903
2057
|
serialize: SerializeValue;
|
|
1904
2058
|
}
|
|
1905
2059
|
declare const compileWhereSql: (where: WhereInput | undefined, strategy: WhereSqlStrategy) => SQL | undefined;
|
|
1906
|
-
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 };
|
|
2060
|
+
export { ADMIN_FUNCTIONS, ADMIN_FUNCTION_PREFIX, AGGREGATE_SQL_FUNCTION, AGG_COUNT, AGG_KEY, AGG_VALUE, AUDIT_LOG_TABLE, type AdvisorProcedure, type AdvisorProceduresResult, type AdvisoriesResult, type AdvisoryFinding, type AggregateIndexDefinitionLike, type AggregateOp, type AggregateOptions, type AggregateResult, type AggregateTally, type AppendAuditEntry, type ApplyOnDeleteOptions$1 as ApplyOnDeleteOptions, type AuditEntry, type AuditLogResult, type BroadcastDelta, CDC_LOG_TABLE, CDC_META_TABLE, CLIENT_WATERMARK_TABLE, type CacheEntry, type CapturedMailRow, type CdcChange, type ChangedKeys, type Clock, type ColumnMeta, type ColumnMetaLike, type CompanionSync, type CompanionSyncDeps, ConflictError, type ConflictKind, type CountArgs, CountRlsUnsupportedError, type CreateWorkflowInstanceResult, type CrossShardReadArgs, type CtxDbOptions, DATA_MIGRATION_STATE_TABLE, DEFAULT_FANOUT_TOPIC_LIMIT, DEFAULT_MAX_RELATION_KEYS, DEFAULT_MAX_RELAYS, DEFAULT_PROMOTION_THRESHOLDS, DEFAULT_TRANSACTION_LIMITS, DOC_COLUMN, type DataMigrationDocument, type DataMigrationLike, type DataMigrationTransform, type DatabaseWriterLike, type DependencyTracker, type DeployInfo, type ExportRow, type ExportShardAdminArgs, type ExportShardArgs, type ExternalSourceDiffResult, type ExternalSourceLike, FLAGS_FUNCTION_PREFIX, type FacetColumnOptions, type FacetColumnResult, type FacetValue, type FanoutMetricsResult, type FanoutPathCounters, type FanoutTopicStat, type FieldOperators, type FilterClause, type FilterOperator, type FlagEvaluation, type FlagsResult, type FunctionCallStat, type FunctionScanAttribution, type FunctionStatsResult, GEO_DEFAULT_PRECISION, GLOBAL_SHAPE_SNAPSHOT_TABLE, type GeoBoundingBox, type GeoFilterBuilderLike, type GeoIndexDefinitionLike, type GeoPoint, type GeoScoredDocument, type GroupByEntry, type GroupByOptions, type GuardableSchema$1 as GuardableSchema, IDEMPOTENCY_TABLE, type IdGenerator, type IdempotentRecord, type ImportError, type ImportShardAdminArgs, type ImportShardArgs, type ImportShardResult, type IncrementalMaterializeResult, type IndexDefinitionLike, type IndexKeyEntry, type IndexRangeBuilderLike, type KeyRange, type LifecycleDispatchInfo, type LifecycleEvent, MAIL_RETENTION, MAIL_TABLE, MAX_PAGE_SIZE, MAX_SQL_ROWS, type MaskColumnMetadata, type MaskPoliciesResult, type MaterializeResult, type MigrationDirection, type MigrationRunResult, type MigrationStatus, type MigrationStatusRow, type MutationDelta, type NestedWith, NotFoundError, NotUniqueError, type OnDeleteActionLike, type OrderByClause, type OrderByInput, type OrderKey, OwnerRelay, type OwnerRelayFrame, type PaginationOptions, type PitrBookmarkResult, type PitrRestoreArgs, type PitrRestoreResult, type PitrStorage, type PokeFrameMeta, type PromotionState, type PromotionThresholds, QUEUE_TABLE, type QueryArgs, type QueryPage, type QueueMessageOutcome, type QueueMessageRow, type QueueMetadata, type QueuesResult, RANK_TIEBREAK, RELATION_EXISTS_KEY, RELATION_FUNCTION_PREFIX, REPROJECTION_MIGRATION_PREFIX, RLS_UNWRAP_SYMBOL, type RankBeforeOptions, type RankBeforeResult, type RankDirection, type RankIndexDefinitionLike, type RankOptions, type RankPage, type RankPageComputation, type RankPageDeps, type RankPageOptions, type RankPageRow, type RankPageRowKey, type RankResult, type RankSortKeyLike, ReactiveCache, type ReactiveCacheOptions, type ReadFootprint, type ReadHook, type ReadTablePageOptions, type RecordMailInput, type RecordQueueMessageInput, type RelationDefinitionLike, type RelationExistsMarker, type RelayAttach, type RelayDetach, type RelayFrame, type RelayHost, RelayMember, type RelayShapePoke, type RelayShapeSeed, type RelayShapeSubscribe, type RenderedSql, type ReplicaFollowerHost, type ReplicaOwnerHost, type ReplicaReadiness, type ResolveRelationPredicatesOptions, type ResolveWithOptions, type ResolveWithResult, type ResolvedShape, type RestrictableQueryOptions, type RlsPoliciesResult, type RlsPolicyMetadata, RlsRequiredError, type RlsRoleMetadata, type RpcRequest, type RunDataMigrationOptions, type RunTriggersOptions, SCAN_DEP, SCHEMA_HISTORY_MAX_VERSIONS, SEARCH_STATE_TABLE, type SchedulableWorkflowReferenceLike, type ScheduledFunctionDoc, type SchedulerLike, type SchemaLike, type ScoredDocument, type SearchFilterBuilderLike, type SearchIndexDefinitionLike, type SearchScoredDocument, type SelectMatchingIdsOptions, type ServerDefaultContextLike, type SettingEntry, type SettingKind, type SettingsResult, type ShapePokePart, type ShapeRow, type ShapeRowOp, type ShapeSubscriptionQuery, type ShardRankPageResult, ShardRunner, type ShardRunnerOptions, type ShardSiblingHost, type ShardSocketLike, type SocketAttachment, type SortDirection, type SourceClientLike, type SourceCursorLike, type SourceRefresh, type SqlConsoleResult, type SqlCursor, type SqlEngine, type SqlExec, type SqlLintResult, type StorageMetadata, type StorageReference, type StorageReferenceResult, type StorageRuleMetadata, type StorageRulesResult, type StudioFeaturesResult, type SubscriptionConnection, type SubscriptionEnvelope, type SubscriptionIdentity, type SubscriptionInfo, type SubscriptionQuery, type SubscriptionReadFootprint, type SubscriptionsResult, type SystemDatabaseReader, type SystemDoc, type SystemQuery, type SystemReaderOptions, type SystemReaderSchedulerLike, type SystemReaderStorageLike, type SystemTableName, type TableColumnsResult, type TableDefinitionLike, type TableIndexInfo, type TableIndexesResult, type TableInfo, type TablePage, type TableReaderLike, type TablesColumnsResult, type TablesIndexesResult, type TransactionHeadroom, TransactionHeadroomTracker, type TransactionLimits, type TransactionSqlLike, type TriggerContextLike, type TriggerDefinitionLike, type TriggerEventLike, type TriggerOpLike, type TriggerTimingLike, type TtlSweepSpec, type ValidatorLike, type WhereInput, type WhereSqlStrategy, type WithInput, type WorkflowInstanceState, type WorkflowInstanceStatusResult, type WorkflowMetadata, type WorkflowsResult, type WriteEvent, type WriteHook, advanceClientWatermark, aggUpsertSql, aggregateSqlFunction, aggregateTableName, appendAuditEntry, appendCdcChange, applyCdcChanges, applyOnDelete, applySelect, armRestore, assertFlatPredicate, assertReadonly, assertShapeShardable, assertValidClientId, awaitWsDrain, backfillAggregateIndexes, backfillRankIndexes, backfillSearchIndexes, backfillSearchIndexesForTable, boundingBoxCenter, boundingBoxGeohashes, buildIndexRange, buildPokeFrames, buildReprojectionMigration, buildSeekBeforeWhere, buildSeekWhere, buildSettings, bumpCdcEpoch, clampPromotionThresholds, clearCapturedMail, clearQueueMessages, coerceAggregateNumber, compileWhereSql, computeRankPage, containsRelationPredicate, countLegacyRows, coveringGeohashes, createCompanionSync, createDependencyTracker, createFanoutCounters, createIndexSql, createReadFootprint, createRelayLink, createReplicaLink, createShardCtxDb, createSystemReader, decodeCursor, deleteGlobalShapeSnapshot, deleteGlobalShapeSnapshotsForConnection, depKey, diffExternalSource, diffGlobalMembership, distinctValues, encodeAggregateKey, encodeCursor, encodeGeohash, encodePartitionKey, encodeRowsPatch, ensureAuditTable, ensureMailTable, exportShardRows, exportShardTable, facetColumn, fanOutScalarCounts, findStorageReferences, foldAggregateTally, gateReplicaDispatch, geoTableName, guardWriter, handleReplicaControl, hasTrigger, haversineMeters, hydrateDocsById, importShardRows, indexKeysForRow, isDevEnvironment, isFtsAvailable, isLossyBody, isRelationPredicate, isSoftDeleted, isSourceDue, jsonPath, jsonPathSql, keysTouchRanges, liftSourceId, lintReadonlySql, listTables, matchesRankStaticWhere, matchesStaticWhere, materializeExternalRows, materializeExternalRowsIncremental, mergeChangedKeys, mergeWhere, migrateCdcLog, migrateCdcMeta, migrateClientWatermark, migrateGlobalShapeSnapshot, migrateIdempotency, migrateSearchState, minCdcSeq, nextPromotionState, normalizeCountArgument, normalizeIdStructurally, normalizeOrderKeys, normalizeSourceDocument, normalizeSourceValue, param, parseExportShardArgs, parseImportShardArgs, planAggregateLookup, pointInBoundingBox, projectColumns, pullExternalSourceIncrementalTick, pullExternalSourceTick, qualifiedJsonPath, qualifiedJsonPathSql, quoteIdentifier, rankKeyFromDocument as rankKeyFromDoc, rankTableName, reactiveCacheKey, readAggregateValue, readAuditLog, readBookmark, readCapturedMail, readCdcChanges, readCdcCursor, readCdcEpoch, readClientWatermark, readExternalSourceBaseline, readGlobalShapeSnapshot, readIdempotent, readMigrationStatus, readQueueMessageById, readQueueMessages, readSchemaHistory, readSchemaVersion, readSearchBackfillState, readTablePage, recordCapturedMail, recordChangedKeys, recordFanoutPass, recordQueueMessages, recordSchemaVersion, relationHooks, relayCountFor, renderSql, reprojectableFields, reprojectionMigrationId, reprojectionTables, resolveRankPartition, resolveRelationPredicates, resolveWith, rowToDocument, runDataMigration, runDrizzle, runExternalSourceTick, runReadonlySql, runRowValidators, runShardMigrations, runSocketPool, runSql, runTriggers, selectExpiredIds, selectExportTables, selectIndexForAggregate, selectIndexForCount, selectIndexForGroupBy, selectMatchingIds, selectShapeMemberIds, selectShapeRows, sendDeltaFrames, serializeSqlValue, shapeRoutingKey, softDeleteScope, sortColumnName, stableStringify, stableWireKey, subscriptionListDeltas, summarizeFanoutTopics, summarizeSubscriptions, tableColumns, tableFromDepKey, throwingScheduler, trimCdcChanges, trimIdempotent, tryRowToDocument, trySendFrame, validateImportRow, writeGlobalShapeSnapshot, writeIdempotent, writeSearchBackfillState, writeTouchesMemo };
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{exportShardRows as o,exportShardTable as a,importShardRows as t,parseExportShardArgs as n,parseImportShardArgs as l,selectExportTables as i,validateImportRow as s}from"./packem_shared/exportShardRows-kt42wijd.mjs";import{AGGREGATE_SQL_FUNCTION as p,aggregateSqlFunction as d,matchesStaticWhere as c,normalizeCountArgument as S,throwingScheduler as u}from"./packem_shared/AGGREGATE_SQL_FUNCTION-QYaiuty4.mjs";import{aggregateTableName as f,coerceAggregateNumber as E,encodeAggregateKey as g,foldAggregateTally as A,readAggregateValue as h}from"./packem_shared/aggregateTableName-G-eXyjcz.mjs";import{CountRlsUnsupportedError as C,mergeWhere as I,planAggregateLookup as _,selectIndexForAggregate as R,selectIndexForCount as L,selectIndexForGroupBy as b}from"./packem_shared/CountRlsUnsupportedError-B2WKJD9v.mjs";import{AUDIT_LOG_TABLE as y,appendAuditEntry as M,ensureAuditTable as O,readAuditLog as D}from"./packem_shared/AUDIT_LOG_TABLE-CaA0jL0L.mjs";import{NotUniqueError as P,assertValidClientId as k,createShardCtxDb as B,normalizeIdStructurally as G}from"./packem_shared/NotUniqueError-Bw1Oh2FL.mjs";import{backfillAggregateIndexes as q,backfillRankIndexes as w,backfillSearchIndexes as W,backfillSearchIndexesForTable as K}from"./packem_shared/backfillAggregateIndexes-BHiewuB-.mjs";import{CDC_LOG_TABLE as z,CDC_META_TABLE as V,appendCdcChange as X,applyCdcChanges as H,bumpCdcEpoch as Q,migrateCdcLog as Y,migrateCdcMeta as j,minCdcSeq as J,readCdcChanges as Z,readCdcCursor as $,readCdcEpoch as ee,trimCdcChanges as re}from"./packem_shared/CDC_LOG_TABLE-BnqlH2eZ.mjs";import{CLIENT_WATERMARK_TABLE as ae,advanceClientWatermark as te,migrateClientWatermark as ne,readClientWatermark as le}from"./packem_shared/CLIENT_WATERMARK_TABLE-CXsSLU8D.mjs";import{createCompanionSync as se}from"./packem_shared/createCompanionSync-BCBUOnMk.mjs";import{GLOBAL_SHAPE_SNAPSHOT_TABLE as pe,deleteGlobalShapeSnapshot as de,deleteGlobalShapeSnapshotsForConnection as ce,migrateGlobalShapeSnapshot as Se,readGlobalShapeSnapshot as ue,writeGlobalShapeSnapshot as xe}from"./packem_shared/GLOBAL_SHAPE_SNAPSHOT_TABLE-DX-6-gBP.mjs";import{IDEMPOTENCY_TABLE as Ee,migrateIdempotency as ge,readIdempotent as Ae,trimIdempotent as he,writeIdempotent as Te}from"./packem_shared/IDEMPOTENCY_TABLE-DjkEMp6w.mjs";import{computeRankPage as Ie,hydrateDocsById as _e}from"./packem_shared/computeRankPage-IUSS-zIB.mjs";import{SEARCH_STATE_TABLE as Le,migrateSearchState as be,readSearchBackfillState as Ne,writeSearchBackfillState as ye}from"./packem_shared/SEARCH_STATE_TABLE-eLN8U5tz.mjs";import{selectShapeMemberIds as Oe,selectShapeRows as De}from"./packem_shared/selectShapeMemberIds-DvE7K6zG.mjs";import{DATA_MIGRATION_STATE_TABLE as Pe,readMigrationStatus as ke,runDataMigration as Be}from"./packem_shared/DATA_MIGRATION_STATE_TABLE-CaO6L0Ee.mjs";import{SCAN_DEP as Ue,createDependencyTracker as qe,depKey as we,tableFromDepKey as We}from"./packem_shared/SCAN_DEP-D_yR9EeV.mjs";import{runDrizzle as ve,runSql as ze}from"./packem_shared/runDrizzle-GKR3y97k.mjs";import{AGG_COUNT as Xe,AGG_KEY as He,AGG_VALUE as Qe,DOC_COLUMN as Ye,aggUpsertSql as je,createIndexSql as Je,geoTableName as Ze,isFtsAvailable as $e,jsonPath as er,jsonPathSql as rr,qualifiedJsonPath as or,qualifiedJsonPathSql as ar,quoteIdentifier as tr,rowToDocument as nr,tableColumns as lr,tryRowToDocument as ir}from"./packem_shared/AGG_COUNT-BWXe3gtQ.mjs";import{param as mr,renderSql as pr}from"./packem_shared/param-B5lF5Jd9.mjs";import{diffExternalSource as cr}from"./packem_shared/diffExternalSource-DMpkJta1.mjs";import{liftSourceId as ur,normalizeSourceDocument as xr,normalizeSourceValue as fr}from"./packem_shared/liftSourceId-DApAbu7Q.mjs";import{materializeExternalRows as gr,materializeExternalRowsIncremental as Ar,readExternalSourceBaseline as hr,runExternalSourceTick as Tr}from"./packem_shared/materializeExternalRows-DOQJV9p2.mjs";import{isSoftDeleted as Ir,isSourceDue as _r,pullExternalSourceIncrementalTick as Rr,pullExternalSourceTick as Lr}from"./packem_shared/isSoftDeleted-B-SXkGUo.mjs";import{GEO_DEFAULT_PRECISION as Nr,boundingBoxCenter as yr,boundingBoxGeohashes as Mr,coveringGeohashes as Or,encodeGeohash as Dr,haversineMeters as Fr,pointInBoundingBox as Pr}from"./packem_shared/GEO_DEFAULT_PRECISION-okRCkZ6r.mjs";import{ADMIN_FUNCTIONS as Br,ADMIN_FUNCTION_PREFIX as Gr,DEFAULT_FANOUT_TOPIC_LIMIT as Ur,FLAGS_FUNCTION_PREFIX as qr,MAX_PAGE_SIZE as wr,RELATION_FUNCTION_PREFIX as Wr,createFanoutCounters as Kr,facetColumn as vr,findStorageReferences as zr,listTables as Vr,readTablePage as Xr,recordFanoutPass as Hr,selectMatchingIds as Qr,summarizeFanoutTopics as Yr,summarizeSubscriptions as jr}from"./packem_shared/ADMIN_FUNCTIONS-B0xlQJ4w.mjs";import{MAIL_RETENTION as Zr,MAIL_TABLE as $r,clearCapturedMail as eo,ensureMailTable as ro,readCapturedMail as oo,recordCapturedMail as ao}from"./packem_shared/MAIL_RETENTION-KmozO2NQ.mjs";import{NotFoundError as no}from"./packem_shared/NotFoundError-BhF7FeFr.mjs";import{armRestore as io,readBookmark as so}from"./packem_shared/armRestore-BNzdvQ_o.mjs";import{applySelect as po,buildSeekBeforeWhere as co,buildSeekWhere as So,decodeCursor as uo,encodeCursor as xo,normalizeOrderKeys as fo,softDeleteScope as Eo}from"./packem_shared/applySelect-B0CF8T7y.mjs";import{QUEUE_TABLE as Ao,clearQueueMessages as ho,isLossyBody as To,readQueueMessageById as Co,readQueueMessages as Io,recordQueueMessages as _o}from"./packem_shared/QUEUE_TABLE-DYCDvzTG.mjs";import{RANK_TIEBREAK as Lo,encodePartitionKey as bo,matchesRankStaticWhere as No,rankKeyFromDoc as yo,rankTableName as Mo,resolveRankPartition as Oo,sortColumnName as Do}from"./packem_shared/RANK_TIEBREAK-9NU5s_mi.mjs";import{ReactiveCache as Po,reactiveCacheKey as ko}from"./packem_shared/ReactiveCache-1_9Rs7J_.mjs";import{DEFAULT_MAX_RELATION_KEYS as Go,assertFlatPredicate as Uo,assertShapeShardable as qo,containsRelationPredicate as wo,isRelationPredicate as Wo,resolveRelationPredicates as Ko}from"./packem_shared/DEFAULT_MAX_RELATION_KEYS-bq00btqV.mjs";import{applyOnDelete as zo,distinctValues as Vo,fanOutScalarCounts as Xo,resolveWith as Ho,runRowValidators as Qo}from"./packem_shared/applyOnDelete-uFRC5p1d.mjs";import{DEFAULT_PROMOTION_THRESHOLDS as jo,clampPromotionThresholds as Jo,nextPromotionState as Zo,relayCountFor as $o,shapeRoutingKey as ea}from"./packem_shared/DEFAULT_PROMOTION_THRESHOLDS-Dteg0sZF.mjs";import{DEFAULT_MAX_RELAYS as oa,OwnerRelay as aa,RelayMember as ta,createRelayLink as na}from"./packem_shared/DEFAULT_MAX_RELAYS-CnCyh6oX.mjs";import{RLS_UNWRAP_SYMBOL as ia,RlsRequiredError as sa,guardWriter as ma}from"./packem_shared/RLS_UNWRAP_SYMBOL-C6_WX3dG.mjs";import{SCHEMA_HISTORY_MAX_VERSIONS as da,readSchemaHistory as ca,readSchemaVersion as Sa,recordSchemaVersion as ua}from"./packem_shared/SCHEMA_HISTORY_MAX_VERSIONS-CHXz6p_z.mjs";import{serializeSqlValue as fa}from"./packem_shared/serializeSqlValue-DnpyaLcw.mjs";import{buildSettings as ga,isDevEnvironment as Aa}from"./packem_shared/buildSettings-DT18_DkX.mjs";import{buildPokeFrames as Ta,diffGlobalMembership as Ca,encodeRowsPatch as Ia,projectColumns as _a}from"./packem_shared/buildPokeFrames-DaPpm5Ss.mjs";import{ShardRunner as La}from"./packem_shared/ShardRunner-DIqVdWtk.mjs";import{runSocketPool as Na}from"./packem_shared/runSocketPool-DPQLVyWF.mjs";import{MAX_SQL_ROWS as Ma,assertReadonly as Oa,lintReadonlySql as Da,runReadonlySql as Fa}from"./packem_shared/MAX_SQL_ROWS-nMwkxv5f.mjs";import{awaitWsDrain as ka,sendDeltaFrames as Ba,subscriptionListDeltas as Ga,trySendFrame as Ua}from"./packem_shared/awaitWsDrain-Dk50ISgE.mjs";import{createSystemReader as wa}from"./packem_shared/createSystemReader-DcDcrtM3.mjs";import{ConflictError as Ka}from"./packem_shared/ConflictError-C8GtJmjS.mjs";import{hasTrigger as za,runTriggers as Va}from"./packem_shared/hasTrigger-CbkOHExZ.mjs";import{selectExpiredIds as Ha}from"./packem_shared/selectExpiredIds-FzhIEeG1.mjs";import{compileWhereSql as Ya}from"./packem_shared/compileWhereSql-BLcfs4QW.mjs";import{RELATION_EXISTS_KEY as Ja}from"./packem_shared/RELATION_EXISTS_KEY-BaqSIFU1.mjs";import{runShardMigrations as $a}from"./packem_shared/runShardMigrations-CPxqCh3O.mjs";import{stableStringify as rt}from"./packem_shared/stableStringify-BjLh4gvA.mjs";import{stableWireKey as at}from"./packem_shared/stableWireKey-YEHLaX6X.mjs";export{Br as ADMIN_FUNCTIONS,Gr as ADMIN_FUNCTION_PREFIX,p as AGGREGATE_SQL_FUNCTION,Xe as AGG_COUNT,He as AGG_KEY,Qe as AGG_VALUE,y as AUDIT_LOG_TABLE,z as CDC_LOG_TABLE,V as CDC_META_TABLE,ae as CLIENT_WATERMARK_TABLE,Ka as ConflictError,C as CountRlsUnsupportedError,Pe as DATA_MIGRATION_STATE_TABLE,Ur as DEFAULT_FANOUT_TOPIC_LIMIT,Go as DEFAULT_MAX_RELATION_KEYS,oa as DEFAULT_MAX_RELAYS,jo as DEFAULT_PROMOTION_THRESHOLDS,Ye as DOC_COLUMN,qr as FLAGS_FUNCTION_PREFIX,Nr as GEO_DEFAULT_PRECISION,pe as GLOBAL_SHAPE_SNAPSHOT_TABLE,Ee as IDEMPOTENCY_TABLE,Zr as MAIL_RETENTION,$r as MAIL_TABLE,wr as MAX_PAGE_SIZE,Ma as MAX_SQL_ROWS,no as NotFoundError,P as NotUniqueError,aa as OwnerRelay,Ao as QUEUE_TABLE,Lo as RANK_TIEBREAK,Ja as RELATION_EXISTS_KEY,Wr as RELATION_FUNCTION_PREFIX,ia as RLS_UNWRAP_SYMBOL,Po as ReactiveCache,ta as RelayMember,sa as RlsRequiredError,Ue as SCAN_DEP,da as SCHEMA_HISTORY_MAX_VERSIONS,Le as SEARCH_STATE_TABLE,La as ShardRunner,te as advanceClientWatermark,je as aggUpsertSql,d as aggregateSqlFunction,f as aggregateTableName,M as appendAuditEntry,X as appendCdcChange,H as applyCdcChanges,zo as applyOnDelete,po as applySelect,io as armRestore,Uo as assertFlatPredicate,Oa as assertReadonly,qo as assertShapeShardable,k as assertValidClientId,ka as awaitWsDrain,q as backfillAggregateIndexes,w as backfillRankIndexes,W as backfillSearchIndexes,K as backfillSearchIndexesForTable,yr as boundingBoxCenter,Mr as boundingBoxGeohashes,Ta as buildPokeFrames,co as buildSeekBeforeWhere,So as buildSeekWhere,ga as buildSettings,Q as bumpCdcEpoch,Jo as clampPromotionThresholds,eo as clearCapturedMail,ho as clearQueueMessages,E as coerceAggregateNumber,Ya as compileWhereSql,Ie as computeRankPage,wo as containsRelationPredicate,Or as coveringGeohashes,se as createCompanionSync,qe as createDependencyTracker,Kr as createFanoutCounters,Je as createIndexSql,na as createRelayLink,B as createShardCtxDb,wa as createSystemReader,uo as decodeCursor,de as deleteGlobalShapeSnapshot,ce as deleteGlobalShapeSnapshotsForConnection,we as depKey,cr as diffExternalSource,Ca as diffGlobalMembership,Vo as distinctValues,g as encodeAggregateKey,xo as encodeCursor,Dr as encodeGeohash,bo as encodePartitionKey,Ia as encodeRowsPatch,O as ensureAuditTable,ro as ensureMailTable,o as exportShardRows,a as exportShardTable,vr as facetColumn,Xo as fanOutScalarCounts,zr as findStorageReferences,A as foldAggregateTally,Ze as geoTableName,ma as guardWriter,za as hasTrigger,Fr as haversineMeters,_e as hydrateDocsById,t as importShardRows,Aa as isDevEnvironment,$e as isFtsAvailable,To as isLossyBody,Wo as isRelationPredicate,Ir as isSoftDeleted,_r as isSourceDue,er as jsonPath,rr as jsonPathSql,ur as liftSourceId,Da as lintReadonlySql,Vr as listTables,No as matchesRankStaticWhere,c as matchesStaticWhere,gr as materializeExternalRows,Ar as materializeExternalRowsIncremental,I as mergeWhere,Y as migrateCdcLog,j as migrateCdcMeta,ne as migrateClientWatermark,Se as migrateGlobalShapeSnapshot,ge as migrateIdempotency,be as migrateSearchState,J as minCdcSeq,Zo as nextPromotionState,S as normalizeCountArgument,G as normalizeIdStructurally,fo as normalizeOrderKeys,xr as normalizeSourceDocument,fr as normalizeSourceValue,mr as param,n as parseExportShardArgs,l as parseImportShardArgs,_ as planAggregateLookup,Pr as pointInBoundingBox,_a as projectColumns,Rr as pullExternalSourceIncrementalTick,Lr as pullExternalSourceTick,or as qualifiedJsonPath,ar as qualifiedJsonPathSql,tr as quoteIdentifier,yo as rankKeyFromDoc,Mo as rankTableName,ko as reactiveCacheKey,h as readAggregateValue,D as readAuditLog,so as readBookmark,oo as readCapturedMail,Z as readCdcChanges,$ as readCdcCursor,ee as readCdcEpoch,le as readClientWatermark,hr as readExternalSourceBaseline,ue as readGlobalShapeSnapshot,Ae as readIdempotent,ke as readMigrationStatus,Co as readQueueMessageById,Io as readQueueMessages,ca as readSchemaHistory,Sa as readSchemaVersion,Ne as readSearchBackfillState,Xr as readTablePage,ao as recordCapturedMail,Hr as recordFanoutPass,_o as recordQueueMessages,ua as recordSchemaVersion,$o as relayCountFor,pr as renderSql,Oo as resolveRankPartition,Ko as resolveRelationPredicates,Ho as resolveWith,nr as rowToDocument,Be as runDataMigration,ve as runDrizzle,Tr as runExternalSourceTick,Fa as runReadonlySql,Qo as runRowValidators,$a as runShardMigrations,Na as runSocketPool,ze as runSql,Va as runTriggers,Ha as selectExpiredIds,i as selectExportTables,R as selectIndexForAggregate,L as selectIndexForCount,b as selectIndexForGroupBy,Qr as selectMatchingIds,Oe as selectShapeMemberIds,De as selectShapeRows,Ba as sendDeltaFrames,fa as serializeSqlValue,ea as shapeRoutingKey,Eo as softDeleteScope,Do as sortColumnName,rt as stableStringify,at as stableWireKey,Ga as subscriptionListDeltas,Yr as summarizeFanoutTopics,jr as summarizeSubscriptions,lr as tableColumns,We as tableFromDepKey,u as throwingScheduler,re as trimCdcChanges,he as trimIdempotent,ir as tryRowToDocument,Ua as trySendFrame,s as validateImportRow,xe as writeGlobalShapeSnapshot,Te as writeIdempotent,ye as writeSearchBackfillState};
|
|
1
|
+
import{exportShardRows as o,exportShardTable as a,importShardRows as t,parseExportShardArgs as n,parseImportShardArgs as s,selectExportTables as l,validateImportRow as i}from"./packem_shared/exportShardRows-Bbi_JGfn.mjs";import{AGGREGATE_SQL_FUNCTION as m,aggregateSqlFunction as d,matchesStaticWhere as c,normalizeCountArgument as S,throwingScheduler as u}from"./packem_shared/AGGREGATE_SQL_FUNCTION-CTo0-9iZ.mjs";import{aggregateTableName as f,coerceAggregateNumber as T,encodeAggregateKey as g,foldAggregateTally as E,readAggregateValue as h}from"./packem_shared/aggregateTableName-DgYMC5tr.mjs";import{CountRlsUnsupportedError as I,mergeWhere as R,planAggregateLookup as C,selectIndexForAggregate as _,selectIndexForCount as L,selectIndexForGroupBy as b}from"./packem_shared/CountRlsUnsupportedError-8BqPYQoP.mjs";import{AUDIT_LOG_TABLE as N,appendAuditEntry as M,ensureAuditTable as O,readAuditLog as F}from"./packem_shared/AUDIT_LOG_TABLE-C6nwXFPd.mjs";import{NotUniqueError as P,assertValidClientId as k,createShardCtxDb as G,normalizeIdStructurally as B}from"./packem_shared/NotUniqueError-CVHdtVw6.mjs";import{backfillAggregateIndexes as w,backfillRankIndexes as K,backfillSearchIndexes as q,backfillSearchIndexesForTable as W}from"./packem_shared/backfillAggregateIndexes-DmqOHg0U.mjs";import{CDC_LOG_TABLE as z,CDC_META_TABLE as H,appendCdcChange as V,applyCdcChanges as X,bumpCdcEpoch as j,migrateCdcLog as Q,migrateCdcMeta as Y,minCdcSeq as J,readCdcChanges as Z,readCdcCursor as $,readCdcEpoch as ee,trimCdcChanges as re}from"./packem_shared/CDC_LOG_TABLE-ZqcflEen.mjs";import{CLIENT_WATERMARK_TABLE as ae,advanceClientWatermark as te,migrateClientWatermark as ne,readClientWatermark as se}from"./packem_shared/CLIENT_WATERMARK_TABLE-CzApRlyv.mjs";import{w as ie}from"./packem_shared/ctx-db-companions-BTi8DLUl.mjs";import{GLOBAL_SHAPE_SNAPSHOT_TABLE as me,deleteGlobalShapeSnapshot as de,deleteGlobalShapeSnapshotsForConnection as ce,migrateGlobalShapeSnapshot as Se,readGlobalShapeSnapshot as ue,writeGlobalShapeSnapshot as xe}from"./packem_shared/GLOBAL_SHAPE_SNAPSHOT_TABLE-soMJDSBs.mjs";import{IDEMPOTENCY_TABLE as Te,migrateIdempotency as ge,readIdempotent as Ee,trimIdempotent as he,writeIdempotent as Ae}from"./packem_shared/IDEMPOTENCY_TABLE-Bvu9JkiL.mjs";import{computeRankPage as Re,hydrateDocsById as Ce}from"./packem_shared/computeRankPage-QK8SeTZ-.mjs";import{SEARCH_STATE_TABLE as Le,migrateSearchState as be,readSearchBackfillState as ye,writeSearchBackfillState as Ne}from"./packem_shared/SEARCH_STATE_TABLE-BZ_fxI5l.mjs";import{selectShapeMemberIds as Oe,selectShapeRows as Fe}from"./packem_shared/selectShapeMemberIds-BdBcbrUP.mjs";import{DATA_MIGRATION_STATE_TABLE as Pe,readMigrationStatus as ke,runDataMigration as Ge}from"./packem_shared/DATA_MIGRATION_STATE_TABLE-BrpAGtXf.mjs";import{SCAN_DEP as Ue,createDependencyTracker as we,depKey as Ke,tableFromDepKey as qe}from"./packem_shared/SCAN_DEP-D_yR9EeV.mjs";import{runDrizzle as ve,runSql as ze}from"./packem_shared/runDrizzle-B6rnz3so.mjs";import{T as Ve,c as Xe,p as je,a as Qe,A as Ye,y as Je,h as Ze,C as $e,_ as er,N as rr,S as or,O as ar,E as tr,I as nr,D as sr}from"./packem_shared/do-sql-1Yi1_Yq0.mjs";import{param as ir,renderSql as pr}from"./packem_shared/param-B5lF5Jd9.mjs";import{diffExternalSource as dr}from"./packem_shared/diffExternalSource-DMpkJta1.mjs";import{liftSourceId as Sr,normalizeSourceDocument as ur,normalizeSourceValue as xr}from"./packem_shared/liftSourceId-DApAbu7Q.mjs";import{materializeExternalRows as Tr,materializeExternalRowsIncremental as gr,readExternalSourceBaseline as Er,runExternalSourceTick as hr}from"./packem_shared/materializeExternalRows-DcCENzpV.mjs";import{isSoftDeleted as Ir,isSourceDue as Rr,pullExternalSourceIncrementalTick as Cr,pullExternalSourceTick as _r}from"./packem_shared/isSoftDeleted-Bo-y3DOe.mjs";import{GEO_DEFAULT_PRECISION as br,boundingBoxCenter as yr,boundingBoxGeohashes as Nr,coveringGeohashes as Mr,encodeGeohash as Or,haversineMeters as Fr,pointInBoundingBox as Dr}from"./packem_shared/GEO_DEFAULT_PRECISION-DyI5zggj.mjs";import{ADMIN_FUNCTIONS as kr,ADMIN_FUNCTION_PREFIX as Gr,DEFAULT_FANOUT_TOPIC_LIMIT as Br,FLAGS_FUNCTION_PREFIX as Ur,MAX_PAGE_SIZE as wr,RELATION_FUNCTION_PREFIX as Kr,createFanoutCounters as qr,facetColumn as Wr,findStorageReferences as vr,listTables as zr,readTablePage as Hr,recordFanoutPass as Vr,selectMatchingIds as Xr,summarizeFanoutTopics as jr,summarizeSubscriptions as Qr}from"./packem_shared/ADMIN_FUNCTIONS-OnYxyTXW.mjs";import{MAIL_RETENTION as Jr,MAIL_TABLE as Zr,clearCapturedMail as $r,ensureMailTable as eo,readCapturedMail as ro,recordCapturedMail as oo}from"./packem_shared/MAIL_RETENTION-BefR9Sei.mjs";import{NotFoundError as to}from"./packem_shared/NotFoundError-BhF7FeFr.mjs";import{armRestore as so,readBookmark as lo}from"./packem_shared/armRestore-BNzdvQ_o.mjs";import{applySelect as po,buildSeekBeforeWhere as mo,buildSeekWhere as co,decodeCursor as So,encodeCursor as uo,normalizeOrderKeys as xo,softDeleteScope as fo}from"./packem_shared/applySelect-UY-o13Ia.mjs";import{QUEUE_TABLE as go,clearQueueMessages as Eo,isLossyBody as ho,readQueueMessageById as Ao,readQueueMessages as Io,recordQueueMessages as Ro}from"./packem_shared/QUEUE_TABLE-DgBqWrXX.mjs";import{RANK_TIEBREAK as _o,encodePartitionKey as Lo,matchesRankStaticWhere as bo,rankKeyFromDoc as yo,rankTableName as No,resolveRankPartition as Mo,sortColumnName as Oo}from"./packem_shared/RANK_TIEBREAK-DDtST3gN.mjs";import{ReactiveCache as Do,reactiveCacheKey as Po}from"./packem_shared/ReactiveCache-Cu8IfE1M.mjs";import{createReadFootprint as Go}from"./packem_shared/createReadFootprint-DIrrxRTE.mjs";import{buildIndexRange as Uo,indexKeysForRow as wo,keysTouchRanges as Ko}from"./packem_shared/buildIndexRange-DFsdtPjD.mjs";import{DEFAULT_MAX_RELATION_KEYS as Wo,assertFlatPredicate as vo,assertShapeShardable as zo,containsRelationPredicate as Ho,isRelationPredicate as Vo,resolveRelationPredicates as Xo}from"./packem_shared/DEFAULT_MAX_RELATION_KEYS-DjKka36Z.mjs";import{applyOnDelete as Qo,distinctValues as Yo,fanOutScalarCounts as Jo,relationHooks as Zo,resolveWith as $o,runRowValidators as ea}from"./packem_shared/applyOnDelete-By23GK-k.mjs";import{DEFAULT_PROMOTION_THRESHOLDS as oa,clampPromotionThresholds as aa,nextPromotionState as ta,relayCountFor as na,shapeRoutingKey as sa}from"./packem_shared/DEFAULT_PROMOTION_THRESHOLDS-B2rUe1bg.mjs";import{DEFAULT_MAX_RELAYS as ia,OwnerRelay as pa,RelayMember as ma,createRelayLink as da}from"./packem_shared/DEFAULT_MAX_RELAYS-B19vrJxP.mjs";import{createReplicaLink as Sa,gateReplicaDispatch as ua,handleReplicaControl as xa}from"./packem_shared/createReplicaLink-BMNW0SX6.mjs";import{buildReprojectionMigration as Ta,countLegacyRows as ga,reprojectableFields as Ea,reprojectionTables as ha}from"./packem_shared/buildReprojectionMigration-Ctl4r84d.mjs";import{RLS_UNWRAP_SYMBOL as Ia,RlsRequiredError as Ra,guardWriter as Ca}from"./packem_shared/RLS_UNWRAP_SYMBOL-DcqORh2s.mjs";import{SCHEMA_HISTORY_MAX_VERSIONS as La,readSchemaHistory as ba,readSchemaVersion as ya,recordSchemaVersion as Na}from"./packem_shared/SCHEMA_HISTORY_MAX_VERSIONS-BEU0CuW5.mjs";import{serializeSqlValue as Oa}from"./packem_shared/serializeSqlValue-BR4UOWoP.mjs";import{buildSettings as Da,isDevEnvironment as Pa}from"./packem_shared/buildSettings-COIJsw7a.mjs";import{buildPokeFrames as Ga,diffGlobalMembership as Ba,encodeRowsPatch as Ua,projectColumns as wa}from"./packem_shared/buildPokeFrames-CqxaN8_H.mjs";import{ShardRunner as qa}from"./packem_shared/ShardRunner-DIqVdWtk.mjs";import{runSocketPool as va}from"./packem_shared/runSocketPool-DPQLVyWF.mjs";import{MAX_SQL_ROWS as Ha,assertReadonly as Va,lintReadonlySql as Xa,runReadonlySql as ja}from"./packem_shared/MAX_SQL_ROWS-nMwkxv5f.mjs";import{awaitWsDrain as Ya,sendDeltaFrames as Ja,subscriptionListDeltas as Za,trySendFrame as $a}from"./packem_shared/awaitWsDrain-Bp2jKzIb.mjs";import{mergeChangedKeys as rt,recordChangedKeys as ot,writeTouchesMemo as at}from"./packem_shared/mergeChangedKeys-BXtUgIPW.mjs";import{createSystemReader as nt}from"./packem_shared/createSystemReader-DcDcrtM3.mjs";import{ConflictError as lt}from"./packem_shared/ConflictError-C8GtJmjS.mjs";import{DEFAULT_TRANSACTION_LIMITS as pt,TransactionHeadroomTracker as mt}from"./packem_shared/DEFAULT_TRANSACTION_LIMITS-q7ouI3i0.mjs";import{hasTrigger as ct,runTriggers as St}from"./packem_shared/hasTrigger-CbkOHExZ.mjs";import{selectExpiredIds as xt}from"./packem_shared/selectExpiredIds-C6nQK7E2.mjs";import{compileWhereSql as Tt}from"./packem_shared/compileWhereSql-B4rPariq.mjs";import{RELATION_EXISTS_KEY as Et}from"./packem_shared/RELATION_EXISTS_KEY-BaqSIFU1.mjs";import{REPROJECTION_MIGRATION_PREFIX as At,reprojectionMigrationId as It}from"./packem_shared/REPROJECTION_MIGRATION_PREFIX-D2dltRFC.mjs";import{quoteIdentifier as Ct}from"./packem_shared/quoteIdentifier-CObIFRhb.mjs";import{runShardMigrations as Lt}from"./packem_shared/runShardMigrations-BqO6HPtX.mjs";import{stableStringify as yt}from"./packem_shared/stableStringify-BjLh4gvA.mjs";import{stableWireKey as Mt}from"./packem_shared/stableWireKey-l3cjIt-9.mjs";export{kr as ADMIN_FUNCTIONS,Gr as ADMIN_FUNCTION_PREFIX,m as AGGREGATE_SQL_FUNCTION,Ve as AGG_COUNT,Xe as AGG_KEY,je as AGG_VALUE,N as AUDIT_LOG_TABLE,z as CDC_LOG_TABLE,H as CDC_META_TABLE,ae as CLIENT_WATERMARK_TABLE,lt as ConflictError,I as CountRlsUnsupportedError,Pe as DATA_MIGRATION_STATE_TABLE,Br as DEFAULT_FANOUT_TOPIC_LIMIT,Wo as DEFAULT_MAX_RELATION_KEYS,ia as DEFAULT_MAX_RELAYS,oa as DEFAULT_PROMOTION_THRESHOLDS,pt as DEFAULT_TRANSACTION_LIMITS,Qe as DOC_COLUMN,Ur as FLAGS_FUNCTION_PREFIX,br as GEO_DEFAULT_PRECISION,me as GLOBAL_SHAPE_SNAPSHOT_TABLE,Te as IDEMPOTENCY_TABLE,Jr as MAIL_RETENTION,Zr as MAIL_TABLE,wr as MAX_PAGE_SIZE,Ha as MAX_SQL_ROWS,to as NotFoundError,P as NotUniqueError,pa as OwnerRelay,go as QUEUE_TABLE,_o as RANK_TIEBREAK,Et as RELATION_EXISTS_KEY,Kr as RELATION_FUNCTION_PREFIX,At as REPROJECTION_MIGRATION_PREFIX,Ia as RLS_UNWRAP_SYMBOL,Do as ReactiveCache,ma as RelayMember,Ra as RlsRequiredError,Ue as SCAN_DEP,La as SCHEMA_HISTORY_MAX_VERSIONS,Le as SEARCH_STATE_TABLE,qa as ShardRunner,mt as TransactionHeadroomTracker,te as advanceClientWatermark,Ye as aggUpsertSql,d as aggregateSqlFunction,f as aggregateTableName,M as appendAuditEntry,V as appendCdcChange,X as applyCdcChanges,Qo as applyOnDelete,po as applySelect,so as armRestore,vo as assertFlatPredicate,Va as assertReadonly,zo as assertShapeShardable,k as assertValidClientId,Ya as awaitWsDrain,w as backfillAggregateIndexes,K as backfillRankIndexes,q as backfillSearchIndexes,W as backfillSearchIndexesForTable,yr as boundingBoxCenter,Nr as boundingBoxGeohashes,Uo as buildIndexRange,Ga as buildPokeFrames,Ta as buildReprojectionMigration,mo as buildSeekBeforeWhere,co as buildSeekWhere,Da as buildSettings,j as bumpCdcEpoch,aa as clampPromotionThresholds,$r as clearCapturedMail,Eo as clearQueueMessages,T as coerceAggregateNumber,Tt as compileWhereSql,Re as computeRankPage,Ho as containsRelationPredicate,ga as countLegacyRows,Mr as coveringGeohashes,ie as createCompanionSync,we as createDependencyTracker,qr as createFanoutCounters,Je as createIndexSql,Go as createReadFootprint,da as createRelayLink,Sa as createReplicaLink,G as createShardCtxDb,nt as createSystemReader,So as decodeCursor,de as deleteGlobalShapeSnapshot,ce as deleteGlobalShapeSnapshotsForConnection,Ke as depKey,dr as diffExternalSource,Ba as diffGlobalMembership,Yo as distinctValues,g as encodeAggregateKey,uo as encodeCursor,Or as encodeGeohash,Lo as encodePartitionKey,Ua as encodeRowsPatch,O as ensureAuditTable,eo as ensureMailTable,o as exportShardRows,a as exportShardTable,Wr as facetColumn,Jo as fanOutScalarCounts,vr as findStorageReferences,E as foldAggregateTally,ua as gateReplicaDispatch,Ze as geoTableName,Ca as guardWriter,xa as handleReplicaControl,ct as hasTrigger,Fr as haversineMeters,Ce as hydrateDocsById,t as importShardRows,wo as indexKeysForRow,Pa as isDevEnvironment,$e as isFtsAvailable,ho as isLossyBody,Vo as isRelationPredicate,Ir as isSoftDeleted,Rr as isSourceDue,er as jsonPath,rr as jsonPathSql,Ko as keysTouchRanges,Sr as liftSourceId,Xa as lintReadonlySql,zr as listTables,bo as matchesRankStaticWhere,c as matchesStaticWhere,Tr as materializeExternalRows,gr as materializeExternalRowsIncremental,rt as mergeChangedKeys,R as mergeWhere,Q as migrateCdcLog,Y as migrateCdcMeta,ne as migrateClientWatermark,Se as migrateGlobalShapeSnapshot,ge as migrateIdempotency,be as migrateSearchState,J as minCdcSeq,ta as nextPromotionState,S as normalizeCountArgument,B as normalizeIdStructurally,xo as normalizeOrderKeys,ur as normalizeSourceDocument,xr as normalizeSourceValue,ir as param,n as parseExportShardArgs,s as parseImportShardArgs,C as planAggregateLookup,Dr as pointInBoundingBox,wa as projectColumns,Cr as pullExternalSourceIncrementalTick,_r as pullExternalSourceTick,or as qualifiedJsonPath,ar as qualifiedJsonPathSql,Ct as quoteIdentifier,yo as rankKeyFromDoc,No as rankTableName,Po as reactiveCacheKey,h as readAggregateValue,F as readAuditLog,lo as readBookmark,ro as readCapturedMail,Z as readCdcChanges,$ as readCdcCursor,ee as readCdcEpoch,se as readClientWatermark,Er as readExternalSourceBaseline,ue as readGlobalShapeSnapshot,Ee as readIdempotent,ke as readMigrationStatus,Ao as readQueueMessageById,Io as readQueueMessages,ba as readSchemaHistory,ya as readSchemaVersion,ye as readSearchBackfillState,Hr as readTablePage,oo as recordCapturedMail,ot as recordChangedKeys,Vr as recordFanoutPass,Ro as recordQueueMessages,Na as recordSchemaVersion,Zo as relationHooks,na as relayCountFor,pr as renderSql,Ea as reprojectableFields,It as reprojectionMigrationId,ha as reprojectionTables,Mo as resolveRankPartition,Xo as resolveRelationPredicates,$o as resolveWith,tr as rowToDocument,Ge as runDataMigration,ve as runDrizzle,hr as runExternalSourceTick,ja as runReadonlySql,ea as runRowValidators,Lt as runShardMigrations,va as runSocketPool,ze as runSql,St as runTriggers,xt as selectExpiredIds,l as selectExportTables,_ as selectIndexForAggregate,L as selectIndexForCount,b as selectIndexForGroupBy,Xr as selectMatchingIds,Oe as selectShapeMemberIds,Fe as selectShapeRows,Ja as sendDeltaFrames,Oa as serializeSqlValue,sa as shapeRoutingKey,fo as softDeleteScope,Oo as sortColumnName,yt as stableStringify,Mt as stableWireKey,Za as subscriptionListDeltas,jr as summarizeFanoutTopics,Qr as summarizeSubscriptions,nr as tableColumns,qe as tableFromDepKey,u as throwingScheduler,re as trimCdcChanges,he as trimIdempotent,sr as tryRowToDocument,$a as trySendFrame,i as validateImportRow,xe as writeGlobalShapeSnapshot,Ae as writeIdempotent,Ne as writeSearchBackfillState,at as writeTouchesMemo};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{LunoraError as T}from"@lunora/errors";import{j as L,s as O}from"./do-sql-1Yi1_Yq0.mjs";import{quoteIdentifier as d}from"./quoteIdentifier-CObIFRhb.mjs";import{s as P}from"./wire-codec-Dsy70M3Q.mjs";const te="__lunora_admin__:",ae="__lunora_relation__:",re="__lunora_flags__:",se={applyCdc:"__lunora_admin__:applyCdc",aiAvailable:"__lunora_admin__:aiAvailable",aiChartConfig:"__lunora_admin__:aiChartConfig",aiGenerateSql:"__lunora_admin__:aiGenerateSql",aiTableFilter:"__lunora_admin__:aiTableFilter",assignIssue:"__lunora_admin__:assignIssue",backRelationCounts:"__lunora_admin__:backRelationCounts",cdcSync:"__lunora_admin__:cdcSync",clearCapturedMail:"__lunora_admin__:clearCapturedMail",clearQueueMessages:"__lunora_admin__:clearQueueMessages",clearTable:"__lunora_admin__:clearTable",createWorkflowInstance:"__lunora_admin__:createWorkflowInstance",deleteRows:"__lunora_admin__:deleteRows",describeTable:"__lunora_admin__:describeTable",describeTables:"__lunora_admin__:describeTables",explainIssue:"__lunora_admin__:explainIssue",exportShard:"__lunora_admin__:exportShard",facetColumn:"__lunora_admin__:facetColumn",getAdvisories:"__lunora_admin__:getAdvisories",getAdvisorProcedures:"__lunora_admin__:getAdvisorProcedures",getAuditLog:"__lunora_admin__:getAuditLog",getAuthMetrics:"__lunora_admin__:getAuthMetrics",getCapturedMail:"__lunora_admin__:getCapturedMail",getFanoutMetrics:"__lunora_admin__:getFanoutMetrics",getFunctionStats:"__lunora_admin__:getFunctionStats",getIssues:"__lunora_admin__:getIssues",getMetricHistory:"__lunora_admin__:getMetricHistory",getMetricSeries:"__lunora_admin__:getMetricSeries",listSubscriptions:"__lunora_admin__:listSubscriptions",listTableIndexes:"__lunora_admin__:listTableIndexes",listTablesIndexes:"__lunora_admin__:listTablesIndexes",getLogs:"__lunora_admin__:getLogs",getMetrics:"__lunora_admin__:getMetrics",getPitrBookmark:"__lunora_admin__:getPitrBookmark",getQueryInsights:"__lunora_admin__:getQueryInsights",getQueueMessages:"__lunora_admin__:getQueueMessages",getRequestLog:"__lunora_admin__:getRequestLog",getSecurityAudit:"__lunora_admin__:getSecurityAudit",getSettings:"__lunora_admin__:getSettings",getTraces:"__lunora_admin__:getTraces",getWorkflowInstanceStatus:"__lunora_admin__:getWorkflowInstanceStatus",ignoreIssue:"__lunora_admin__:ignoreIssue",importShard:"__lunora_admin__:importShard",listFlags:"__lunora_admin__:listFlags",listQueues:"__lunora_admin__:listQueues",lintSql:"__lunora_admin__:lintSql",listTables:"__lunora_admin__:listTables",listWorkflows:"__lunora_admin__:listWorkflows",maskPolicies:"__lunora_admin__:maskPolicies",migrationStatus:"__lunora_admin__:migrationStatus",pitrRestore:"__lunora_admin__:pitrRestore",rankBefore:"__lunora_admin__:rankBefore",rankPage:"__lunora_admin__:rankPage",readTablePage:"__lunora_admin__:readTablePage",recordAuthEvent:"__lunora_admin__:recordAuthEvent",recordContainerEvent:"__lunora_admin__:recordContainerEvent",recordMail:"__lunora_admin__:recordMail",recordQueueMessage:"__lunora_admin__:recordQueueMessage",replayQueueMessage:"__lunora_admin__:replayQueueMessage",resolveIssue:"__lunora_admin__:resolveIssue",rlsPolicies:"__lunora_admin__:rlsPolicies",schemaHistory:"__lunora_admin__:schemaHistory",schemaVersion:"__lunora_admin__:schemaVersion",runAs:"__lunora_admin__:runAs",runMigration:"__lunora_admin__:runMigration",runSql:"__lunora_admin__:runSql",sendQueueMessage:"__lunora_admin__:sendQueueMessage",sendTestMail:"__lunora_admin__:sendTestMail",setIssueSeverity:"__lunora_admin__:setIssueSeverity",storageOrphans:"__lunora_admin__:storageOrphans",storageReferences:"__lunora_admin__:storageReferences",storageRules:"__lunora_admin__:storageRules",studioFeatures:"__lunora_admin__:studioFeatures",writeRow:"__lunora_admin__:writeRow"},U=50,f=500,D=30,q=200,m="__doc__",k=e=>{try{const t=JSON.parse(e);return t!==null&&typeof t=="object"&&!Array.isArray(t)?t:void 0}catch{return}},W=e=>{const{[O]:t,...a}=e;return t===void 0?a:t===null||typeof t!="object"||Array.isArray(t)?{[O]:t,...a}:{...a,...P(t)}},j=(e,t)=>{if(!e.includes(m))return{columns:e,rows:t};const a=[];for(const s of t){const _=s[m],i=typeof _=="string"?k(_):void 0;if(i===void 0)return{columns:e,rows:t};const u=Object.fromEntries(Object.entries(s).filter(([l])=>l!==m));a.push({...u,...W(i)})}const r=e.filter(s=>s!==m),n=[],o=new Set(r);for(const s of a)for(const _ of Object.keys(s))o.has(_)||(o.add(_),n.push(_));return{columns:[...r,...n],rows:a}},R=e=>e.replaceAll(/[\\%_]/g,t=>`\\${t}`),E=e=>e.startsWith("sqlite_")||e.startsWith("_cf_")||e.startsWith("__miniflare")||e.startsWith("__lunora")||e.includes("__fts_"),I=(e,t,a)=>Math.min(Math.max(e,t),a),w=(e,t)=>{const a=e.exec(`SELECT COUNT(*) AS c FROM ${t}`).one();return Number(a.c)},ne=e=>{const t=e.exec("SELECT name FROM sqlite_master WHERE type = 'table' ORDER BY name").toArray(),a=[];for(const{name:r}of t)E(r)||a.push({name:r,rowCount:w(e,d(r))});return a},x=(e,t)=>e.exec("SELECT name FROM sqlite_master WHERE type = 'table' AND name = ? LIMIT 1",t).toArray().length>0,A=(e,t)=>{if(E(t)||!x(e,t))throw new T("UNKNOWN_TABLE",`unknown table: ${t}`,{status:404})},b=(e,t)=>e.exec(`PRAGMA table_info(${t})`).toArray().map(a=>a.name),Q={eq:"=",gt:">",gte:">=",lt:"<",lte:"<=",ne:"<>"},B=e=>typeof e=="string"?e:typeof e=="number"||typeof e=="boolean"?String(e):"",M=(e,t)=>{const a=t.includes(e),r=t.includes(m);if(!(!a&&!r))return a?{expression:d(e),params:[]}:{expression:`json_extract(${d(m)}, ?)`,params:[`$.${L(e)}`]}},H=(e,t)=>{const a=M(e.column,t);if(a===void 0)return;const{expression:r,params:n}=a;return e.operator==="contains"?{params:[...n,`%${R(B(e.value))}%`],sql:String.raw`CAST(${r} AS TEXT) LIKE ? ESCAPE '\'`}:{params:[...n,e.value],sql:`${r} ${Q[e.operator]} ?`}},G=/^(\d{4})(?:-(\d{2}))?(?:-(\d{2}))?$/u,X=e=>{const t=G.exec(e.trim());if(t===null)return;const a=Number(t[1]),r=t[2]===void 0?void 0:Number(t[2]),n=t[3]===void 0?void 0:Number(t[3]);if(r!==void 0&&(r<1||r>12)||n!==void 0&&(n<1||n>31)||a<100)return;const o=Date.UTC(a,(r??1)-1,n??1);if(n!==void 0&&new Date(o).getUTCDate()!==n)return;let s;return n!==void 0?s=Date.UTC(a,(r??1)-1,n+1):r===void 0?s=Date.UTC(a+1,0,1):s=Date.UTC(a,r,1),{from:o,to:s}},C=(e,t,a)=>{const r=[],n=[];if(t!==""&&e.length>0){const o=`%${R(t)}%`,s=e.map(i=>String.raw`CAST(${d(i)} AS TEXT) LIKE ? ESCAPE '\'`);n.push(...e.map(()=>o));const _=X(t);if(_!==void 0)for(const i of e)s.push(`(${d(i)} >= ? AND ${d(i)} < ?)`),n.push(_.from,_.to);r.push(`(${s.join(" OR ")})`)}for(const o of a??[]){const s=H(o,e);s!==void 0&&(r.push(`(${s.sql})`),n.push(...s.params))}return r.length===0?void 0:{parameters:n,where:r.join(" AND ")}},K=(e,t)=>{if(e===void 0)return;const a=M(e.column,t);if(a===void 0)return;const r=e.direction==="desc"?"DESC":"ASC";return{params:a.params,sql:`${a.expression} ${r}`}},oe=(e,t)=>{const{table:a}=t;A(e,a);const r=I(Math.trunc(t.limit??U),1,f),n=Math.max(0,Math.trunc(t.offset??0)),o=d(a),s=b(e,o),_=t.search?.trim()??"",i=h=>{if(t.refs===void 0)return h;const S={};for(const $ of h.columns){const y=t.refs[$];y!==void 0&&(S[$]=y)}return Object.keys(S).length>0?{...h,refs:S}:h},u=C(s,_,t.filters),l=K(t.orderBy,s),c=u===void 0?"":` WHERE ${u.where}`,p=l===void 0?"":` ORDER BY ${l.sql}`,g=u?.parameters??[],N=l?.params??[];let v;t.skipCount||(v=u===void 0?w(e,o):Number(e.exec(`SELECT COUNT(*) AS c FROM ${o}${c}`,...g).one().c));const F=e.exec(`SELECT * FROM ${o}${c}${p} LIMIT ? OFFSET ?`,...g,...N,r,n).toArray();return i({...j(s,F),total:v})},_e=(e,t)=>{const{table:a}=t;A(e,a);const r=I(Math.trunc(t.limit??f),1,f),n=d(a),o=b(e,n),s=t.search?.trim()??"",_=C(o,s,t.filters),i=_===void 0?e.exec(`SELECT id FROM ${n} LIMIT ?`,r+1).toArray():e.exec(`SELECT id FROM ${n} WHERE ${_.where} LIMIT ?`,..._.parameters,r+1).toArray(),u=i.length>r,l=i.slice(0,r).map(c=>c.id);return{hasMore:u,ids:l}},Y=(e,t,a)=>{const r=new Set(a.filter(o=>o!==m));if(!a.includes(m))return r;const n=e.exec(`SELECT ${d(m)} AS doc FROM ${t} LIMIT ?`,f).toArray();for(const{doc:o}of n){const s=typeof o=="string"?k(o):void 0;if(s!==void 0)for(const _ of Object.keys(s))r.add(_)}return r},ie=(e,t)=>{const{column:a,table:r}=t;A(e,r);const n=d(r),o=b(e,n);if(!Y(e,n,o).has(a))throw new T("UNKNOWN_COLUMN",`unknown column: ${a}`,{status:404});const s=M(a,o);if(s===void 0)throw new T("UNKNOWN_COLUMN",`unknown column: ${a}`,{status:404});const _=I(Math.trunc(t.limit??D),1,q),i=t.search?.trim()??"",u=C(o,i,t.filters),l=u===void 0?"":` WHERE ${u.where}`,c=u?.parameters??[],p=e.exec(`SELECT ${s.expression} AS value, COUNT(*) AS count FROM ${n}${l} GROUP BY ${s.expression} ORDER BY count DESC LIMIT ?`,...s.params,...c,...s.params,_+1).toArray();return{truncated:p.length>_,values:p.slice(0,_).map(g=>({count:Number(g.count),value:g.value}))}},ue=(e,t,a)=>{const r={},n=a.slice(0,f);for(const s of n)r[s]=[];if(n.length===0)return{references:r,storageColumns:t};const o=n.map(()=>"?").join(", ");for(const[s,_]of Object.entries(t)){if(E(s)||!x(e,s))continue;const i=d(s),u=b(e,i);for(const l of _){const c=M(l,u);if(c===void 0)continue;const p=e.exec(`SELECT id, ${c.expression} AS ref FROM ${i} WHERE ${c.expression} IN (${o})`,...c.params,...c.params,...n).toArray();for(const g of p)r[g.ref]?.push({column:l,id:g.id,table:s})}}return{references:r,storageColumns:t}},le=e=>{const t=e.map((r,n)=>{const o=Object.values(r.subs??{}).map(s=>({args:s.args,functionPath:s.functionPath,table:s.table}));return{admin:r.admin===!0,id:n,subscriptions:o}}),a=t.reduce((r,n)=>r+n.subscriptions.length,0);return{connections:t,totalConnections:t.length,totalSubscriptions:a}},z=20,ce=()=>({maxMs:0,passes:0,peakSocketsIterated:0,socketsDelivered:0,socketsIterated:0,totalMs:0}),de=(e,t,a,r)=>({maxMs:Math.max(e.maxMs,r),passes:e.passes+1,peakSocketsIterated:Math.max(e.peakSocketsIterated,t),socketsDelivered:e.socketsDelivered+a,socketsIterated:e.socketsIterated+t,totalMs:e.totalMs+r}),me=(e,t=z)=>{const a=new Map,r=new Map;for(const o of e){for(const s of Object.values(o.shapes??{})){const _=s.name??"(unknown shape)";a.set(_,(a.get(_)??0)+1)}for(const s of o.whispers??[])r.set(s,(r.get(s)??0)+1)}const n=[...[...a].map(([o,s])=>({kind:"shape",subscribers:s,topic:o})),...[...r].map(([o,s])=>({kind:"whisper",subscribers:s,topic:o}))];return n.sort((o,s)=>s.subscribers-o.subscribers||o.topic.localeCompare(s.topic)),{peakSubscribers:n[0]?.subscribers??0,topics:n.slice(0,t),totalConnections:e.length}};export{se as ADMIN_FUNCTIONS,te as ADMIN_FUNCTION_PREFIX,z as DEFAULT_FANOUT_TOPIC_LIMIT,re as FLAGS_FUNCTION_PREFIX,f as MAX_PAGE_SIZE,ae as RELATION_FUNCTION_PREFIX,ce as createFanoutCounters,X as datePrefixRange,ie as facetColumn,ue as findStorageReferences,ne as listTables,oe as readTablePage,de as recordFanoutPass,_e as selectMatchingIds,me as summarizeFanoutTopics,le as summarizeSubscriptions};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{LunoraError as i}from"@lunora/errors";const a=new Set(["baseWhere","relationBaseWhere","restrictsCounts","where"]),c=()=>{throw new i("INTERNAL","ctx.scheduler: no scheduler configured for triggers. Pass `scheduler` to the ctx-db factory.")},h=(e,r)=>{for(const[n,t]of Object.entries(r)){const o=e[n];if(t!==null&&typeof t=="object"&&!Array.isArray(t)){const s=Object.keys(t);if(s.length===1&&s[0]==="eq"){if(o!==t.eq)return!1;continue}return!1}if(o!==t)return!1}return!0},g=e=>{if(e===void 0)return{};if(typeof e!="object"||Array.isArray(e))return{where:e};const r=Object.keys(e);return r.length===0?{}:r.every(n=>a.has(n))?e:{where:e}},u={avg:"AVG",count:"COUNT",max:"MAX",min:"MIN",sum:"SUM"},l=e=>{const r=u[e];if(r===void 0)throw new i("INTERNAL",`unknown aggregate op "${e}": expected one of ${Object.keys(u).join(", ")}`);return r},A={runAfter:c,runAt:c};export{u as AGGREGATE_SQL_FUNCTION,l as aggregateSqlFunction,h as matchesStaticWhere,g as normalizeCountArgument,A as throwingScheduler};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"@lunora/errors";import"drizzle-orm";import{T as l,c as m,p as n,a as p,s as c,A as q,y as d,g as u,L as A,h as D,C as G,_ as S,N as _,S as f,O as C,E as O,I as h,D as I}from"./do-sql-1Yi1_Yq0.mjs";import{quoteIdentifier as T}from"./quoteIdentifier-CObIFRhb.mjs";import"./wire-codec-Dsy70M3Q.mjs";import"./runDrizzle-B6rnz3so.mjs";import"./sql-projection-jfoe331H.mjs";import{serializeSqlValue as x}from"./serializeSqlValue-BR4UOWoP.mjs";export{l as AGG_COUNT,m as AGG_KEY,n as AGG_VALUE,p as DOC_COLUMN,c as DOC_ORIGINALS_KEY,q as aggUpsertSql,d as createIndexSql,u as decodeDocJson,A as encodeDocJson,D as geoTableName,G as isFtsAvailable,S as jsonPath,_ as jsonPathSql,f as qualifiedJsonPath,C as qualifiedJsonPathSql,T as quoteIdentifier,O as rowToDocument,x as serializeSqlValue,h as tableColumns,I as tryRowToDocument};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import{runSql as i}from"./runDrizzle-B6rnz3so.mjs";const a="__lunora_audit__",T=1e3,s=E=>{i(E,`CREATE TABLE IF NOT EXISTS "${a}" (
|
|
2
|
+
seq INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
3
|
+
ts REAL NOT NULL,
|
|
4
|
+
op TEXT NOT NULL,
|
|
5
|
+
"table" TEXT,
|
|
6
|
+
id TEXT,
|
|
7
|
+
detail TEXT
|
|
8
|
+
)`)},o=(E,l)=>{s(E),i(E,`INSERT INTO "${a}" (ts, op, "table", id, detail) VALUES (?, ?, ?, ?, ?)`,l.ts,l.op,l.table??null,l.id??null,l.detail===void 0?null:JSON.stringify(l.detail)),i(E,`DELETE FROM "${a}" WHERE seq <= (SELECT MAX(seq) - ? FROM "${a}")`,T)},u=(E,l={})=>{s(E);const d=l.sinceSeq??0,r=Math.max(1,Math.min(l.limit??T,1e4));return i(E,`SELECT seq, ts, op, "table", id, detail FROM "${a}" WHERE seq > ? ORDER BY seq DESC LIMIT ?`,d,r).toArray().map(t=>{const e={op:t.op,seq:t.seq,ts:t.ts};return t.table!==null&&(e.table=t.table),t.id!==null&&(e.id=t.id),t.detail!==null&&(e.detail=JSON.parse(t.detail)),e})};export{a as AUDIT_LOG_TABLE,o as appendAuditEntry,s as ensureAuditTable,u as readAuditLog};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import{sql as e}from"drizzle-orm";import{runDrizzle as a}from"./runDrizzle-B6rnz3so.mjs";import{L as C,g as l}from"./do-sql-1Yi1_Yq0.mjs";import{ConflictError as L}from"./ConflictError-C8GtJmjS.mjs";const d="__cdc_log",I=t=>{a(t,e`CREATE TABLE IF NOT EXISTS ${e.identifier(d)} (
|
|
2
|
+
seq INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
3
|
+
ts REAL NOT NULL,
|
|
4
|
+
${e.identifier("table")} TEXT NOT NULL,
|
|
5
|
+
id TEXT NOT NULL,
|
|
6
|
+
op TEXT NOT NULL,
|
|
7
|
+
doc TEXT
|
|
8
|
+
)`)},m=(t,i,r,E,s,c)=>{const o=c===void 0?null:C(c);a(t,e`INSERT INTO ${e.identifier(d)} (ts, ${e.identifier("table")}, id, op, doc) VALUES (${i}, ${r}, ${E}, ${s}, ${o})`)},q=(t,i={})=>{const r=i.sinceSeq??0,E=Math.max(1,Math.min(i.limit??1e3,1e4)),s=i.tables&&i.tables.size>0?e` AND ${e.identifier("table")} IN (${e.join([...i.tables].map(o=>e`${o}`),e`, `)})`:e``,c=a(t,e`SELECT seq, ts, ${e.identifier("table")}, id, op, doc FROM ${e.identifier(d)} WHERE seq > ${r}${s} ORDER BY seq ASC LIMIT ${E}`).toArray().map(o=>{const T={id:o.id,op:o.op,seq:o.seq,table:o.table,ts:o.ts};return o.doc===null?T:{...T,doc:l(o.doc)}});return{changes:c,cursor:c.at(-1)?.seq??r}},O=(t,i)=>{a(t,e`DELETE FROM ${e.identifier(d)} WHERE seq <= ${i}`)},S=t=>{const i=a(t,e`SELECT seq FROM sqlite_sequence WHERE name = ${d}`).toArray()[0]?.seq;return typeof i=="number"?i:a(t,e`SELECT MAX(seq) AS seq FROM ${e.identifier(d)}`).toArray()[0]?.seq??0},h=t=>a(t,e`SELECT MIN(seq) AS seq FROM ${e.identifier(d)}`).toArray()[0]?.seq??void 0,n="__cdc_meta",p=t=>{a(t,e`CREATE TABLE IF NOT EXISTS ${e.identifier(n)} (id INTEGER PRIMARY KEY CHECK (id = 1), epoch TEXT NOT NULL)`)},u=t=>{p(t);const i=a(t,e`SELECT epoch FROM ${e.identifier(n)} WHERE id = 1`).toArray()[0]?.epoch;if(typeof i=="string"&&i.length>0)return i;const r=crypto.randomUUID();return a(t,e`INSERT INTO ${e.identifier(n)} (id, epoch) VALUES (1, ${r})`),r},M=t=>{p(t);const i=crypto.randomUUID();return a(t,e`INSERT INTO ${e.identifier(n)} (id, epoch) VALUES (1, ${i}) ON CONFLICT(id) DO UPDATE SET epoch = excluded.epoch`),i},$=async(t,i)=>{if(i.op==="delete"){await t.delete(i.id,i.table);return}const r=i.doc??{};try{await t.insert(i.table,r,{allowExplicitId:!0})}catch(E){if(!(E instanceof L))throw E;const s={...r};delete s._id,await t.replace(i.id,s,void 0,{allowExplicitId:!0})}},b=async(t,i)=>{for(const r of i)await $(t,r)};export{d as CDC_LOG_TABLE,n as CDC_META_TABLE,m as appendCdcChange,b as applyCdcChanges,M as bumpCdcEpoch,I as migrateCdcLog,p as migrateCdcMeta,h as minCdcSeq,q as readCdcChanges,S as readCdcCursor,u as readCdcEpoch,O as trimCdcChanges};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{sql as t}from"drizzle-orm";import{runDrizzle as n}from"./runDrizzle-
|
|
1
|
+
import{sql as t}from"drizzle-orm";import{runDrizzle as n}from"./runDrizzle-B6rnz3so.mjs";const _="__client_watermark",l=i=>{n(i,t`CREATE TABLE IF NOT EXISTS ${t.identifier(_)} (
|
|
2
2
|
identity TEXT NOT NULL,
|
|
3
3
|
client_id TEXT NOT NULL,
|
|
4
4
|
last_mutation_id INTEGER NOT NULL,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{LunoraError as y}from"@lunora/errors";class A extends y{constructor(e){super("COUNT_RLS_UNSUPPORTED",e===void 0?"count() is not supported in an RLS-restricted context":`count() is not supported on table "${e}" inside an RLS-restricted context`)}}const R=(t,e)=>t?e?{AND:[t,e]}:t:e,g=new Set(["AND","NOT","OR"]),f=Symbol("not-eq"),x=t=>{if(t!==null&&typeof t=="object"&&!Array.isArray(t)){const e=Object.keys(t);return e.length===1&&e[0]==="eq"?t.eq:f}return t},d=(t,e)=>{const s={};for(const[r,n]of Object.entries(t)){if(g.has(r)||!e(r))return;const o=x(n);if(o===f)return;s[r]=o}return s},a=(t,e,s)=>{const r={...e};if(!t)return r;for(const[n,o]of Object.entries(t))if(n in r){if(r[n]!==o)return}else if(n in s){if(s[n]!==o)return}else r[n]=o;return r},b=(t,e)=>{const s=t.by??[],r=e??{},n=d(r,o=>s.includes(o));if(n!==void 0){for(const o of s)if(!(o in n))return;return a(t.where,n,r)}},h=(t,e,s)=>{const r=d(e??{},n=>s.has(n));if(r!==void 0)return a(t.where,r,{})},l=(t,e,s,r)=>{let n;for(const o of t){if(o.op!==e||e!=="count"&&o.field!==s)continue;const i=b(o,r);i&&(!n||(o.by?.length??0)>(n.index.by?.length??0))&&(n={index:o,key:i})}return n},S=(t,e)=>l(t,"count",void 0,e),v=(t,e,s,r)=>l(t,e,s,r),L=(t,e,s,r,n)=>{const o=new Set(r);for(const i of t){if(i.op!==e||e!=="count"&&i.field!==s)continue;const c=i.by??[];if(c.length!==o.size||!c.every(p=>o.has(p)))continue;const u=h(i,n,o);if(u!==void 0)return{index:i,partial:u}}};export{A as CountRlsUnsupportedError,R as mergeWhere,b as planAggregateLookup,v as selectIndexForAggregate,S as selectIndexForCount,L as selectIndexForGroupBy};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import{LunoraError as y}from"@lunora/errors";import{runSql as n}from"./runDrizzle-B6rnz3so.mjs";const o="__lunora_migrations",D=100,$=3e4,U=1e4,b=r=>{n(r,`CREATE TABLE IF NOT EXISTS "${o}" (
|
|
2
|
+
id TEXT PRIMARY KEY,
|
|
3
|
+
direction TEXT NOT NULL,
|
|
4
|
+
status TEXT NOT NULL,
|
|
5
|
+
cursor TEXT,
|
|
6
|
+
processed INTEGER NOT NULL DEFAULT 0,
|
|
7
|
+
changed INTEGER NOT NULL DEFAULT 0,
|
|
8
|
+
started_at REAL,
|
|
9
|
+
updated_at REAL,
|
|
10
|
+
error TEXT
|
|
11
|
+
)`)},m=r=>({changed:r.changed,cursor:typeof r.cursor=="string"?r.cursor:null,direction:r.direction==="down"?"down":"up",processed:r.processed,status:r.status==="completed"||r.status==="failed"?r.status:"in_progress"}),N=(r,t)=>{const e=n(r,`SELECT * FROM "${o}" WHERE id = ?`,t).toArray()[0];if(e)return{...m(e),startedAt:typeof e.started_at=="number"?e.started_at:void 0}},w=(r,t)=>{n(r,`DELETE FROM "${o}" WHERE id = ?`,t)},R=(r,t)=>{n(r,`INSERT INTO "${o}"
|
|
12
|
+
(id, direction, status, cursor, processed, changed, started_at, updated_at, error)
|
|
13
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
14
|
+
ON CONFLICT(id) DO UPDATE SET
|
|
15
|
+
direction = excluded.direction,
|
|
16
|
+
status = excluded.status,
|
|
17
|
+
cursor = excluded.cursor,
|
|
18
|
+
processed = excluded.processed,
|
|
19
|
+
changed = excluded.changed,
|
|
20
|
+
updated_at = excluded.updated_at,
|
|
21
|
+
error = excluded.error`,t.id,t.direction,t.status,t.cursor,t.processed,t.changed,t.startedAt,t.updatedAt,t.error)},x=(r,t,e,a)=>(n(r,`INSERT INTO "${o}"
|
|
22
|
+
(id, direction, status, cursor, processed, changed, started_at, updated_at, error)
|
|
23
|
+
VALUES (?, ?, 'in_progress', NULL, 0, 0, ?, ?, NULL)
|
|
24
|
+
ON CONFLICT(id) DO UPDATE SET
|
|
25
|
+
status = 'in_progress',
|
|
26
|
+
updated_at = excluded.updated_at
|
|
27
|
+
WHERE
|
|
28
|
+
"${o}".direction <> excluded.direction
|
|
29
|
+
OR "${o}".status <> 'in_progress'
|
|
30
|
+
OR "${o}".updated_at IS NULL
|
|
31
|
+
OR "${o}".updated_at <= excluded.updated_at - ${String($)}`,t,e,a,a),n(r,"SELECT changes() AS changed").one().changed>0),F=(r,t,e)=>{n(r,`UPDATE "${o}" SET updated_at = ? WHERE id = ? AND status = 'in_progress'`,e,t)},M=(r,t)=>{n(r,`UPDATE "${o}" SET updated_at = 0 WHERE id = ? AND status = 'in_progress'`,t)},W=(r,t)=>{if(n(r,"SELECT name FROM sqlite_master WHERE type = 'table' AND name = ? LIMIT 1",o).toArray().length===0)return[];const e=t===void 0?" ORDER BY id":" WHERE id = ?",a=t===void 0?[]:[t];return n(r,`SELECT * FROM "${o}"${e}`,...a).toArray().map(d=>({...m(d),error:typeof d.error=="string"?d.error:null,id:d.id,startedAt:typeof d.started_at=="number"?d.started_at:null,updatedAt:typeof d.updated_at=="number"?d.updated_at:null}))},v=async r=>{const{migration:t,sql:e,writer:a}=r,d=r.direction??"up",c=r.dryRun??!1,g=r.clock??(()=>Date.now()),S=r.maxBatches??Number.POSITIVE_INFINITY,I=r.batchSize??t.batchSize??D,f=d==="up"?t.up:t.down;if(!f)throw new y("INTERNAL",`data migration "${t.id}" has no \`${d}\` transform`);const O={db:{count:a.count.bind(a),findFirst:a.findFirst.bind(a),findMany:a.findMany.bind(a),get:a.get.bind(a)}};let u=null,l=0,T=0,_=g();if(!c){b(e);const s=N(e,t.id);if(s?.direction===d&&s.status==="completed")return{changed:s.changed,cursor:null,direction:d,dryRun:c,id:t.id,processed:s.processed,status:"completed"};if(s&&s.direction!==d&&w(e,t.id),!x(e,t.id,d,g())){const E=N(e,t.id);return{changed:E?.changed??0,cursor:E?.cursor??u,direction:d,dryRun:c,id:t.id,processed:E?.processed??0,status:E?.status??"in_progress"}}const i=s?.direction===d?s:void 0;i&&(u=i.cursor,l=i.processed,T=i.changed,_=i.startedAt??_)}let p=!1,A=0,h=_;try{for(;!p&&A<S;){const s=await a.findMany(t.table,{cursor:u,limit:I});for(const i of s.page){l+=1;const E=await f(i,O);if(E!==void 0&&(T+=1,c||await a.replace(String(i._id),{...E,_creationTime:i._creationTime,_id:i._id},void 0,{allowExplicitId:!0})),!c){const L=g();L-h>=U&&(F(e,t.id,L),h=L)}}if(u=s.continueCursor,p=s.isDone,A+=1,!c){const i=g();R(e,{changed:T,cursor:p?null:u,direction:d,error:null,id:t.id,processed:l,startedAt:_,status:p?"completed":"in_progress",updatedAt:i}),h=i;try{await r.onBatch?.({batches:A,changed:T,processed:l})}catch{}}}}catch(s){throw c||R(e,{changed:T,cursor:u,direction:d,error:s instanceof Error?s.message:String(s),id:t.id,processed:l,startedAt:_,status:"failed",updatedAt:g()}),s}if(!c&&!p)try{M(e,t.id)}catch(s){console.warn(`data migration "${t.id}": releaseClaim failed`,s)}return{changed:T,cursor:p?null:u,direction:d,dryRun:c,id:t.id,processed:l,status:p?"completed":"in_progress"}};export{o as DATA_MIGRATION_STATE_TABLE,W as readMigrationStatus,v as runDataMigration};
|