@workglow/storage 0.2.30 → 0.2.32
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/browser.js +998 -61
- package/dist/browser.js.map +24 -14
- package/dist/bun.js +1051 -66
- package/dist/bun.js.map +25 -15
- package/dist/common.d.ts +7 -0
- package/dist/common.d.ts.map +1 -1
- package/dist/migrations/IMigration.d.ts +57 -0
- package/dist/migrations/IMigration.d.ts.map +1 -0
- package/dist/migrations/MigrationRunner.d.ts +44 -0
- package/dist/migrations/MigrationRunner.d.ts.map +1 -0
- package/dist/migrations/TabularMigration.d.ts +85 -0
- package/dist/migrations/TabularMigration.d.ts.map +1 -0
- package/dist/migrations/TabularMigrationOrchestrator.d.ts +34 -0
- package/dist/migrations/TabularMigrationOrchestrator.d.ts.map +1 -0
- package/dist/migrations/index.d.ts +11 -0
- package/dist/migrations/index.d.ts.map +1 -0
- package/dist/migrations/runBackfill.d.ts +19 -0
- package/dist/migrations/runBackfill.d.ts.map +1 -0
- package/dist/node.js +1051 -66
- package/dist/node.js.map +25 -15
- package/dist/sql/Dialect.d.ts +26 -0
- package/dist/sql/Dialect.d.ts.map +1 -0
- package/dist/sql/PredicateBuilder.d.ts +30 -0
- package/dist/sql/PredicateBuilder.d.ts.map +1 -0
- package/dist/sql/PrefixDdl.d.ts +79 -0
- package/dist/sql/PrefixDdl.d.ts.map +1 -0
- package/dist/sql/index.d.ts +9 -0
- package/dist/sql/index.d.ts.map +1 -0
- package/dist/tabular/BaseSqlTabularStorage.d.ts +63 -2
- package/dist/tabular/BaseSqlTabularStorage.d.ts.map +1 -1
- package/dist/tabular/BaseTabularStorage.d.ts +111 -6
- package/dist/tabular/BaseTabularStorage.d.ts.map +1 -1
- package/dist/tabular/CachedTabularStorage.d.ts +38 -0
- package/dist/tabular/CachedTabularStorage.d.ts.map +1 -1
- package/dist/tabular/Cursor.d.ts +79 -0
- package/dist/tabular/Cursor.d.ts.map +1 -0
- package/dist/tabular/FsFolderTabularStorage.d.ts +5 -1
- package/dist/tabular/FsFolderTabularStorage.d.ts.map +1 -1
- package/dist/tabular/HuggingFaceTabularStorage.d.ts +26 -2
- package/dist/tabular/HuggingFaceTabularStorage.d.ts.map +1 -1
- package/dist/tabular/ITabularStorage.d.ts +203 -3
- package/dist/tabular/ITabularStorage.d.ts.map +1 -1
- package/dist/tabular/InMemoryTabularMigrationApplier.d.ts +39 -0
- package/dist/tabular/InMemoryTabularMigrationApplier.d.ts.map +1 -0
- package/dist/tabular/InMemoryTabularStorage.d.ts +6 -2
- package/dist/tabular/InMemoryTabularStorage.d.ts.map +1 -1
- package/dist/tabular/SharedInMemoryTabularStorage.d.ts +4 -1
- package/dist/tabular/SharedInMemoryTabularStorage.d.ts.map +1 -1
- package/dist/tabular/SqlTabularMigrationApplier.d.ts +53 -0
- package/dist/tabular/SqlTabularMigrationApplier.d.ts.map +1 -0
- package/dist/tabular/StorageError.d.ts.map +1 -1
- package/dist/tabular/TabularStorageRegistry.d.ts +13 -10
- package/dist/tabular/TabularStorageRegistry.d.ts.map +1 -1
- package/dist/tabular/TelemetryTabularStorage.d.ts +11 -1
- package/dist/tabular/TelemetryTabularStorage.d.ts.map +1 -1
- package/dist/tabular/sqlMigrationDdl.d.ts +11 -0
- package/dist/tabular/sqlMigrationDdl.d.ts.map +1 -0
- package/dist/vector/IVectorStorage.d.ts +61 -1
- package/dist/vector/IVectorStorage.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/tabular/README.md +73 -0
- package/src/vector/README.md +79 -0
package/dist/common.d.ts
CHANGED
|
@@ -9,11 +9,16 @@ export * from "./tabular/CachedTabularStorage";
|
|
|
9
9
|
export * from "./tabular/CoveringIndexMissingError";
|
|
10
10
|
export { pickCoveringIndex } from "./tabular/coveringIndexPicker";
|
|
11
11
|
export type { RegisteredIndex, PickCoveringIndexInput, PickedIndex, } from "./tabular/coveringIndexPicker";
|
|
12
|
+
export { encodeCursor, decodeCursor, assertCursorMatches, MAX_CURSOR_LENGTH, } from "./tabular/Cursor";
|
|
13
|
+
export type { PageCursor } from "./tabular/Cursor";
|
|
12
14
|
export * from "./tabular/HuggingFaceTabularStorage";
|
|
15
|
+
export * from "./tabular/InMemoryTabularMigrationApplier";
|
|
13
16
|
export * from "./tabular/InMemoryTabularStorage";
|
|
14
17
|
export * from "./tabular/ITabularStorage";
|
|
15
18
|
export * from "./tabular/StorageError";
|
|
16
19
|
export * from "./tabular/TabularStorageRegistry";
|
|
20
|
+
export * from "./tabular/sqlMigrationDdl";
|
|
21
|
+
export * from "./tabular/SqlTabularMigrationApplier";
|
|
17
22
|
export * from "./tabular/TelemetryTabularStorage";
|
|
18
23
|
export * from "./kv/IKvStorage";
|
|
19
24
|
export * from "./kv/InMemoryKvStorage";
|
|
@@ -22,6 +27,8 @@ export * from "./kv/KvViaTabularStorage";
|
|
|
22
27
|
export * from "./kv/TelemetryKvStorage";
|
|
23
28
|
export * from "./util/HybridSubscriptionManager";
|
|
24
29
|
export * from "./util/PollingSubscriptionManager";
|
|
30
|
+
export * from "./sql";
|
|
31
|
+
export * from "./migrations";
|
|
25
32
|
export * from "./vector/InMemoryVectorStorage";
|
|
26
33
|
export * from "./vector/IVectorStorage";
|
|
27
34
|
export * from "./vector/TelemetryVectorStorage";
|
package/dist/common.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../src/common.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,8BAA8B,CAAC;AAC7C,cAAc,iCAAiC,CAAC;AAChD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,qCAAqC,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAClE,YAAY,EACV,eAAe,EACf,sBAAsB,EACtB,WAAW,GACZ,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../src/common.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,8BAA8B,CAAC;AAC7C,cAAc,iCAAiC,CAAC;AAChD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,qCAAqC,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAClE,YAAY,EACV,eAAe,EACf,sBAAsB,EACtB,WAAW,GACZ,MAAM,+BAA+B,CAAC;AAMvC,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,cAAc,qCAAqC,CAAC;AACpD,cAAc,2CAA2C,CAAC;AAC1D,cAAc,kCAAkC,CAAC;AACjD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,wBAAwB,CAAC;AACvC,cAAc,kCAAkC,CAAC;AACjD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,sCAAsC,CAAC;AACrD,cAAc,mCAAmC,CAAC;AAElD,cAAc,iBAAiB,CAAC;AAChC,cAAc,wBAAwB,CAAC;AACvC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC;AAExC,cAAc,kCAAkC,CAAC;AACjD,cAAc,mCAAmC,CAAC;AAElD,cAAc,OAAO,CAAC;AACtB,cAAc,cAAc,CAAC;AAE7B,cAAc,gCAAgC,CAAC;AAC/C,cAAc,yBAAyB,CAAC;AACxC,cAAc,iCAAiC,CAAC;AAEhD,cAAc,0CAA0C,CAAC;AACzD,cAAc,4CAA4C,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Steven Roussey <sroussey@gmail.com>
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Progress event emitted by {@link IMigrationRunner.run} as it works through
|
|
8
|
+
* a migration set.
|
|
9
|
+
*
|
|
10
|
+
* `phase` semantics:
|
|
11
|
+
* - `"starting"` — `up()` is about to be invoked. `fraction` is `undefined`.
|
|
12
|
+
* - `"running"` — intra-migration tick; `fraction` (when present) is in
|
|
13
|
+
* `[0, 1]` reflecting how far along this single migration's `up()` is.
|
|
14
|
+
* Migrations are NOT required to emit running events; many are too short
|
|
15
|
+
* to be worth instrumenting. The runner does not synthesise them.
|
|
16
|
+
* - `"completed"` — `up()` and the bookkeeping write succeeded.
|
|
17
|
+
* `fraction` is `1`.
|
|
18
|
+
* - `"failed"` — `up()` or the bookkeeping write threw. `error` carries
|
|
19
|
+
* the thrown value. The runner re-throws after emitting; this event is
|
|
20
|
+
* for observability, not recovery.
|
|
21
|
+
*/
|
|
22
|
+
export interface MigrationProgressEvent {
|
|
23
|
+
readonly component: string;
|
|
24
|
+
readonly version: number;
|
|
25
|
+
readonly phase: "starting" | "running" | "completed" | "failed";
|
|
26
|
+
readonly description?: string;
|
|
27
|
+
readonly fraction?: number;
|
|
28
|
+
readonly error?: unknown;
|
|
29
|
+
}
|
|
30
|
+
/** Subscriber for {@link MigrationProgressEvent}s emitted by an {@link IMigrationRunner}. */
|
|
31
|
+
export type MigrationProgressListener = (event: MigrationProgressEvent) => void;
|
|
32
|
+
/**
|
|
33
|
+
* A single, versioned, idempotent migration step.
|
|
34
|
+
*
|
|
35
|
+
* Migrations are addressed by `(component, version)`:
|
|
36
|
+
* - `component` groups migrations belonging to the same logical schema
|
|
37
|
+
* (e.g. `"queue:job_queue_tenant"`, `"rate-limiter"`, `"vector:chunks"`).
|
|
38
|
+
* - `version` is a monotonically increasing positive integer within a
|
|
39
|
+
* component. Versions MUST NOT be reused or renumbered after a release.
|
|
40
|
+
*
|
|
41
|
+
* The migration runner records each successfully applied `(component, version)`
|
|
42
|
+
* pair in an internal `_storage_migrations` table and skips any that have
|
|
43
|
+
* already been applied — so `up()` only runs once per environment.
|
|
44
|
+
*
|
|
45
|
+
* `up()` may report intra-migration progress via `report` (a fraction in
|
|
46
|
+
* `[0, 1]`). The runner forwards each `report` call to its
|
|
47
|
+
* {@link MigrationProgressListener} as a `phase: "running"` event. Migrations
|
|
48
|
+
* that aren't worth instrumenting can ignore the parameter.
|
|
49
|
+
*/
|
|
50
|
+
export interface IMigration<DB> {
|
|
51
|
+
readonly component: string;
|
|
52
|
+
readonly version: number;
|
|
53
|
+
readonly description?: string;
|
|
54
|
+
/** Apply the migration. Should be idempotent w.r.t. its own DDL. */
|
|
55
|
+
up(db: DB, report?: (fraction: number) => void): Promise<void> | void;
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=IMigration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IMigration.d.ts","sourceRoot":"","sources":["../../src/migrations/IMigration.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,UAAU,GAAG,SAAS,GAAG,WAAW,GAAG,QAAQ,CAAC;IAChE,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,6FAA6F;AAC7F,MAAM,MAAM,yBAAyB,GAAG,CAAC,KAAK,EAAE,sBAAsB,KAAK,IAAI,CAAC;AAEhF;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,WAAW,UAAU,CAAC,EAAE;IAC5B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,oEAAoE;IACpE,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;CACvE"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Steven Roussey <sroussey@gmail.com>
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import type { IMigration, MigrationProgressListener } from "./IMigration";
|
|
7
|
+
/**
|
|
8
|
+
* Name of the bookkeeping table used by every runner. The leading underscore
|
|
9
|
+
* is intentional — it sorts before user tables in catalog views and signals
|
|
10
|
+
* "system table, don't touch".
|
|
11
|
+
*/
|
|
12
|
+
export declare const MIGRATIONS_TABLE = "_storage_migrations";
|
|
13
|
+
/**
|
|
14
|
+
* Optional knobs accepted by {@link IMigrationRunner.run}.
|
|
15
|
+
*
|
|
16
|
+
* `onProgress` is invoked synchronously from inside the migration's
|
|
17
|
+
* transaction (or upgrade callback for IndexedDB), so listeners must NOT
|
|
18
|
+
* await IO that touches the same database — they would deadlock against
|
|
19
|
+
* the open transaction. Use them for logging, telemetry, or in-memory
|
|
20
|
+
* progress UI updates.
|
|
21
|
+
*/
|
|
22
|
+
export interface RunMigrationsOptions {
|
|
23
|
+
readonly onProgress?: MigrationProgressListener;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Common runner contract — runs the supplied migrations in (component, version)
|
|
27
|
+
* order, skipping any that have already been recorded. Returns the migrations
|
|
28
|
+
* that were actually applied this call (useful for logging/tests).
|
|
29
|
+
*
|
|
30
|
+
* Concrete runners live in driver-specific packages (`@workglow/postgres`,
|
|
31
|
+
* `@workglow/sqlite`) so that `@workglow/storage` does not have to depend on
|
|
32
|
+
* any database driver.
|
|
33
|
+
*/
|
|
34
|
+
export interface IMigrationRunner<DB> {
|
|
35
|
+
ensureBookkeepingTable(): Promise<void>;
|
|
36
|
+
appliedVersions(component: string): Promise<Set<number>>;
|
|
37
|
+
run(migrations: ReadonlyArray<IMigration<DB>>, options?: RunMigrationsOptions): Promise<ReadonlyArray<IMigration<DB>>>;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Stable sort by `(component asc, version asc)`. Exposed so concrete runners
|
|
41
|
+
* in driver packages don't need their own copy.
|
|
42
|
+
*/
|
|
43
|
+
export declare function sortMigrations<DB>(migrations: ReadonlyArray<IMigration<DB>>): IMigration<DB>[];
|
|
44
|
+
//# sourceMappingURL=MigrationRunner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MigrationRunner.d.ts","sourceRoot":"","sources":["../../src/migrations/MigrationRunner.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAC;AAE1E;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,wBAAwB,CAAC;AAEtD;;;;;;;;GAQG;AACH,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,UAAU,CAAC,EAAE,yBAAyB,CAAC;CACjD;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,gBAAgB,CAAC,EAAE;IAClC,sBAAsB,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACxC,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;IACzD,GAAG,CACD,UAAU,EAAE,aAAa,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC,EACzC,OAAO,CAAC,EAAE,oBAAoB,GAC7B,OAAO,CAAC,aAAa,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;CAC3C;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,EAAE,EAAE,UAAU,EAAE,aAAa,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC,GAAG,UAAU,CAAC,EAAE,CAAC,EAAE,CAK9F"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Steven Roussey <sroussey@gmail.com>
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import type { JsonSchema } from "@workglow/util/schema";
|
|
7
|
+
import type { MigrationProgressListener } from "./IMigration";
|
|
8
|
+
/**
|
|
9
|
+
* Backend-agnostic, declarative description of a single schema-evolution step.
|
|
10
|
+
* Each op is translated to native operations by a per-backend
|
|
11
|
+
* {@link ITabularMigrationApplier}.
|
|
12
|
+
*
|
|
13
|
+
* Ops within a single migration are applied in array order inside one atomic
|
|
14
|
+
* unit (a `withTransaction` on SQL backends, an upgrade transaction on
|
|
15
|
+
* IndexedDB, best-effort sequential on schemaless backends).
|
|
16
|
+
*/
|
|
17
|
+
export type TabularMigrationOp = {
|
|
18
|
+
readonly kind: "addColumn";
|
|
19
|
+
readonly name: string;
|
|
20
|
+
readonly schema: JsonSchema;
|
|
21
|
+
readonly default?: string | number | boolean | null;
|
|
22
|
+
} | {
|
|
23
|
+
readonly kind: "dropColumn";
|
|
24
|
+
readonly name: string;
|
|
25
|
+
} | {
|
|
26
|
+
readonly kind: "renameColumn";
|
|
27
|
+
readonly from: string;
|
|
28
|
+
readonly to: string;
|
|
29
|
+
} | {
|
|
30
|
+
readonly kind: "addIndex";
|
|
31
|
+
readonly name: string;
|
|
32
|
+
readonly columns: readonly string[];
|
|
33
|
+
readonly unique?: boolean;
|
|
34
|
+
} | {
|
|
35
|
+
readonly kind: "dropIndex";
|
|
36
|
+
readonly name: string;
|
|
37
|
+
} | {
|
|
38
|
+
readonly kind: "backfill";
|
|
39
|
+
readonly batchSize?: number;
|
|
40
|
+
readonly transform: (row: Record<string, unknown>) => Promise<Record<string, unknown> | undefined> | Record<string, unknown> | undefined;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* One versioned migration for a tabular storage. Identified by
|
|
44
|
+
* `(component, version)` like {@link IMigration}; bookkeeping shares
|
|
45
|
+
* the existing `_storage_migrations` table.
|
|
46
|
+
*
|
|
47
|
+
* `component` defaults to `tabular:${storageName}` when omitted (the
|
|
48
|
+
* orchestrator fills it in from the owning storage).
|
|
49
|
+
*/
|
|
50
|
+
export interface ITabularMigration {
|
|
51
|
+
readonly component?: string;
|
|
52
|
+
readonly version: number;
|
|
53
|
+
readonly description?: string;
|
|
54
|
+
readonly ops: ReadonlyArray<TabularMigrationOp>;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Per-backend primitive that the orchestrator drives. A backend implements
|
|
58
|
+
* `applyMigration` as an atomic unit (DDL + backfill + bookkeeping write
|
|
59
|
+
* in one transaction where the backend supports it).
|
|
60
|
+
*
|
|
61
|
+
* `tableExists` is the freshness probe used by the orchestrator to decide
|
|
62
|
+
* whether to take the fast path (CREATE + mark all migrations applied) or
|
|
63
|
+
* the run-pending path.
|
|
64
|
+
*/
|
|
65
|
+
export interface ITabularMigrationApplier {
|
|
66
|
+
ensureBookkeeping(): Promise<void>;
|
|
67
|
+
appliedVersions(component: string): Promise<Set<number>>;
|
|
68
|
+
tableExists(): Promise<boolean>;
|
|
69
|
+
/**
|
|
70
|
+
* Apply all ops AND record `(component, version)` in bookkeeping in one
|
|
71
|
+
* atomic unit on backends with native transactions; best-effort sequential
|
|
72
|
+
* on schemaless backends (DDL no-ops + backfill + bookkeeping write).
|
|
73
|
+
*/
|
|
74
|
+
applyMigration(component: string, version: number, description: string | undefined, ops: ReadonlyArray<TabularMigrationOp>, onProgress?: (fraction: number) => void): Promise<void>;
|
|
75
|
+
/**
|
|
76
|
+
* Mark all supplied `(component, version)` pairs as applied in bookkeeping
|
|
77
|
+
* without running their ops. Used by the fresh-DB fast path.
|
|
78
|
+
*/
|
|
79
|
+
markAllApplied(component: string, versions: ReadonlyArray<{
|
|
80
|
+
version: number;
|
|
81
|
+
description: string | undefined;
|
|
82
|
+
}>): Promise<void>;
|
|
83
|
+
}
|
|
84
|
+
export type TabularMigrationProgressListener = MigrationProgressListener;
|
|
85
|
+
//# sourceMappingURL=TabularMigration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TabularMigration.d.ts","sourceRoot":"","sources":["../../src/migrations/TabularMigration.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAC;AAE9D;;;;;;;;GAQG;AACH,MAAM,MAAM,kBAAkB,GAC1B;IACE,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;IAC5B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC;CACrD,GACD;IAAE,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACtD;IAAE,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;CAAE,GAC7E;IACE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;CAC3B,GACD;IAAE,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACrD;IACE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,SAAS,EAAE,CAClB,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KACzB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;CACzF,CAAC;AAEN;;;;;;;GAOG;AACH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,GAAG,EAAE,aAAa,CAAC,kBAAkB,CAAC,CAAC;CACjD;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,wBAAwB;IACvC,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACnC,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;IACzD,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IAChC;;;;OAIG;IACH,cAAc,CACZ,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,MAAM,GAAG,SAAS,EAC/B,GAAG,EAAE,aAAa,CAAC,kBAAkB,CAAC,EACtC,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,GACtC,OAAO,CAAC,IAAI,CAAC,CAAC;IACjB;;;OAGG;IACH,cAAc,CACZ,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,aAAa,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,GAAG,SAAS,CAAA;KAAE,CAAC,GAC5E,OAAO,CAAC,IAAI,CAAC,CAAC;CAClB;AAED,MAAM,MAAM,gCAAgC,GAAG,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Steven Roussey <sroussey@gmail.com>
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import type { ITabularMigration, ITabularMigrationApplier, TabularMigrationProgressListener } from "./TabularMigration";
|
|
7
|
+
/**
|
|
8
|
+
* Sequences pending tabular migrations through a backend's
|
|
9
|
+
* {@link ITabularMigrationApplier}.
|
|
10
|
+
*
|
|
11
|
+
* Two paths:
|
|
12
|
+
* - **fresh-DB fast path** — applied is empty AND the caller signaled (via
|
|
13
|
+
* `freshTable: true`) that the underlying table/store did not exist
|
|
14
|
+
* before this run, OR `applier.tableExists()` returns false. The
|
|
15
|
+
* orchestrator records every declared migration as already-applied
|
|
16
|
+
* without running its ops.
|
|
17
|
+
* - **run-pending path** — sorted-by-version, skip already-applied,
|
|
18
|
+
* call `applyMigration` for each remaining one.
|
|
19
|
+
*
|
|
20
|
+
* Bookkeeping is owned by the applier (one row per `(component, version)`
|
|
21
|
+
* in the existing `_storage_migrations` table).
|
|
22
|
+
*
|
|
23
|
+
* The `freshTable` option exists because `setupDatabase()` typically creates
|
|
24
|
+
* the table at the target schema *before* invoking the orchestrator, which
|
|
25
|
+
* defeats the `tableExists()` probe (the store always looks "existing" by
|
|
26
|
+
* the time the orchestrator runs). Callers should pass the freshness probe
|
|
27
|
+
* they took *before* creating the table.
|
|
28
|
+
*/
|
|
29
|
+
export interface RunTabularMigrationsOptions {
|
|
30
|
+
readonly onProgress?: TabularMigrationProgressListener;
|
|
31
|
+
readonly freshTable?: boolean;
|
|
32
|
+
}
|
|
33
|
+
export declare function runTabularMigrations(applier: ITabularMigrationApplier, defaultComponent: string, migrations: ReadonlyArray<ITabularMigration>, options?: RunTabularMigrationsOptions): Promise<void>;
|
|
34
|
+
//# sourceMappingURL=TabularMigrationOrchestrator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TabularMigrationOrchestrator.d.ts","sourceRoot":"","sources":["../../src/migrations/TabularMigrationOrchestrator.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,iBAAiB,EACjB,wBAAwB,EACxB,gCAAgC,EACjC,MAAM,oBAAoB,CAAC;AAE5B;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,WAAW,2BAA2B;IAC1C,QAAQ,CAAC,UAAU,CAAC,EAAE,gCAAgC,CAAC;IACvD,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC;CAC/B;AAED,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,wBAAwB,EACjC,gBAAgB,EAAE,MAAM,EACxB,UAAU,EAAE,aAAa,CAAC,iBAAiB,CAAC,EAC5C,OAAO,GAAE,2BAAgC,GACxC,OAAO,CAAC,IAAI,CAAC,CA6Ef"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Steven Roussey <sroussey@gmail.com>
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
export * from "./IMigration";
|
|
7
|
+
export * from "./MigrationRunner";
|
|
8
|
+
export * from "./TabularMigration";
|
|
9
|
+
export * from "./TabularMigrationOrchestrator";
|
|
10
|
+
export * from "./runBackfill";
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/migrations/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,eAAe,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Steven Roussey <sroussey@gmail.com>
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import type { AnyTabularStorage } from "../tabular/ITabularStorage";
|
|
7
|
+
/**
|
|
8
|
+
* Backend-agnostic, page-based backfill loop. Iterates every row in the
|
|
9
|
+
* storage in `batchSize`-row pages using cursor pagination so iteration
|
|
10
|
+
* is stable under concurrent writes.
|
|
11
|
+
*
|
|
12
|
+
* For each row, calls `transform` and:
|
|
13
|
+
* - if it returns the **same reference** as the input, skips the write
|
|
14
|
+
* (the row is unchanged);
|
|
15
|
+
* - if it returns `undefined`, deletes the row;
|
|
16
|
+
* - otherwise, writes the new row via `put`.
|
|
17
|
+
*/
|
|
18
|
+
export declare function runBackfill(storage: AnyTabularStorage, batchSize: number, transform: (row: Record<string, unknown>) => Promise<Record<string, unknown> | undefined> | Record<string, unknown> | undefined): Promise<void>;
|
|
19
|
+
//# sourceMappingURL=runBackfill.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runBackfill.d.ts","sourceRoot":"","sources":["../../src/migrations/runBackfill.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAc,MAAM,4BAA4B,CAAC;AAEhF;;;;;;;;;;GAUG;AACH,wBAAsB,WAAW,CAC/B,OAAO,EAAE,iBAAiB,EAC1B,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,CACT,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KACzB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,GACtF,OAAO,CAAC,IAAI,CAAC,CAgBf"}
|