durable-db 0.12.0 → 0.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +59 -11
- package/dist/{actionArgs-DP2tQrlf.js → actionArgs-oUWwX6Xn.js} +1 -1
- package/dist/cli/bin.js +1 -1
- package/dist/cli/index.d.ts +107 -7
- package/dist/cli/index.js +3 -3
- package/dist/{cli-CRZWralu.js → cli--9cKeEka.js} +473 -17
- package/dist/db/index.d.ts +2 -2
- package/dist/db/index.js +6 -197
- package/dist/{defineDatabase-Cb5sMNg0.js → defineDatabase-B1pKzO-V.js} +4 -4
- package/dist/{defineDatabase-BE7YRtLh.d.ts → defineDatabase-DlgYfwhP.d.ts} +15 -6
- package/dist/{index-CUkSkt7G.d.ts → index-B5W4m0Dq.d.ts} +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3 -3
- package/dist/{kysely-q97dtmaQ.js → kysely-D07wMKZZ.js} +1 -1
- package/dist/migrations/generator.d.ts +1 -1
- package/dist/migrations/generator.js +1 -1
- package/dist/migrations/snapshot.d.ts +2 -2
- package/dist/migrations/snapshot.js +1 -1
- package/dist/referencingRows-B6rU7TDW.js +193 -0
- package/dist/registry.js +2 -2
- package/dist/{snapshot-CCIE4_Le.js → snapshot-CY4FLqAo.js} +58 -3
- package/dist/{snapshot-RFLfeZGw.d.ts → snapshot-D3_SNABU.d.ts} +12 -1
- package/dist/testing/index.js +5 -5
- package/dist/type/index.js +1 -1
- package/dist/{type-CUgZsZp3.js → type-pAQ37iEL.js} +18 -12
- package/dist/vite/durableDb.d.ts +1 -1
- package/package.json +1 -1
|
@@ -35,6 +35,17 @@ interface SchemaAmbiguity {
|
|
|
35
35
|
}
|
|
36
36
|
/** Every question drizzle-kit would ask to diff `prev` → `cur`. */
|
|
37
37
|
declare function findAmbiguities(prevSnapshot: Snapshot$2, curSnapshot: Snapshot$2): SchemaAmbiguity[];
|
|
38
|
+
/**
|
|
39
|
+
* The questions that have one answer: a table that lost exactly one column
|
|
40
|
+
* and gained exactly one that is declared the same way — its type, whether it
|
|
41
|
+
* may be null, its default, everything but the name — and a schema that lost
|
|
42
|
+
* exactly one table and gained exactly one with the same columns. That is a
|
|
43
|
+
* rename: the name changed and nothing else did. Taking it for a drop and a
|
|
44
|
+
* create would lose the data for a change nobody made; so it is answered
|
|
45
|
+
* without asking, and said (`renamesFromStatements()` of what was generated).
|
|
46
|
+
* Two candidates, or one that changed in more than its name, stay a question.
|
|
47
|
+
*/
|
|
48
|
+
declare function obviousRenames(prevSnapshot: Snapshot$2, curSnapshot: Snapshot$2, ambiguities?: SchemaAmbiguity[]): RenameAnswer[];
|
|
38
49
|
/** One line per ambiguity: `products: summary added, description removed`. */
|
|
39
50
|
declare function describeAmbiguity(ambiguity: SchemaAmbiguity): string;
|
|
40
51
|
/** Example `--rename` answers for an ambiguity (each new name from the first vanished one). */
|
|
@@ -177,4 +188,4 @@ declare function snapshotsEqual(a: Snapshot, b: Snapshot): boolean;
|
|
|
177
188
|
*/
|
|
178
189
|
declare function hashSnapshot(snapshot: Snapshot): string;
|
|
179
190
|
//#endregion
|
|
180
|
-
export {
|
|
191
|
+
export { parseRenameSpec as C, obviousRenames as S, unusedRenames as T, applyRenames as _, generateMigrationStatements as a, findAmbiguities as b, hashSnapshot as c, MigrationRiskKind as d, NOT_NULL_WITHOUT_DEFAULT_HINT as f, SchemaRenameRequiredError as g, SchemaAmbiguity as h, createEmptySnapshot as i, snapshotsEqual as l, RenameAnswer as m, Snapshot as n, generateSnapshotFromSchema as o, analyzeMigrationRisks as p, canPrompt as r, generateSnapshotId as s, MigrationResolution as t, MigrationRisk as u, describeAmbiguity as v, renamesFromStatements as w, formatRename as x, exampleRenames as y };
|
package/dist/testing/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { r as liveTestDatabases, t as ACTION_TEST_META } from "../defineDatabase-
|
|
2
|
-
import { r as type } from "../type-
|
|
3
|
-
import "../actionArgs-
|
|
1
|
+
import { r as liveTestDatabases, t as ACTION_TEST_META } from "../defineDatabase-B1pKzO-V.js";
|
|
2
|
+
import { r as type } from "../type-pAQ37iEL.js";
|
|
3
|
+
import "../actionArgs-oUWwX6Xn.js";
|
|
4
4
|
import { setTenantIdResolver } from "../context/index.js";
|
|
5
|
-
import { c as tenantOfInstanceKey, i as createActionOutbox, t as createKyselyFromSql } from "../kysely-
|
|
6
|
-
import { i as generateSnapshotFromSchema, n as createEmptySnapshot, r as generateMigrationStatements } from "../snapshot-
|
|
5
|
+
import { c as tenantOfInstanceKey, i as createActionOutbox, t as createKyselyFromSql } from "../kysely-D07wMKZZ.js";
|
|
6
|
+
import { i as generateSnapshotFromSchema, n as createEmptySnapshot, r as generateMigrationStatements } from "../snapshot-CY4FLqAo.js";
|
|
7
7
|
import { createRequire } from "node:module";
|
|
8
8
|
//#region src/testing/index.ts
|
|
9
9
|
const loadSqlite = () => createRequire(import.meta.url)("node:sqlite");
|
package/dist/type/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { o as ArkError, s as ArkErrors, i as ParseError, a as ToJsonSchemaError, c as TraversalError, t as createTypeParser, n as isType, r as type } from "../type-
|
|
1
|
+
export { o as ArkError, s as ArkErrors, i as ParseError, a as ToJsonSchemaError, c as TraversalError, t as createTypeParser, n as isType, r as type } from "../type-pAQ37iEL.js";
|
|
@@ -860,11 +860,14 @@ var ObjectNode = class extends Node {
|
|
|
860
860
|
expected = "an object";
|
|
861
861
|
/** Required keys, then optional ones, each sorted — the order ArkType checks and prints them in. */
|
|
862
862
|
props;
|
|
863
|
+
/** The keys in the order they were declared — what a JSON Schema's `properties` lists, so a form or an API shows them as written. */
|
|
864
|
+
declaredProps;
|
|
863
865
|
declared;
|
|
864
866
|
constructor(props, index = [], undeclared) {
|
|
865
867
|
super();
|
|
866
868
|
this.index = index;
|
|
867
869
|
this.undeclared = undeclared;
|
|
870
|
+
this.declaredProps = [...props];
|
|
868
871
|
const required = props.filter((p) => p.kind === "required").sort(byKey);
|
|
869
872
|
const optional = props.filter((p) => p.kind === "optional").sort(byKey);
|
|
870
873
|
this.props = [...required, ...optional];
|
|
@@ -956,7 +959,7 @@ var ObjectNode = class extends Node {
|
|
|
956
959
|
const schema = { type: "object" };
|
|
957
960
|
if (this.props.length > 0) {
|
|
958
961
|
const properties = {};
|
|
959
|
-
for (const prop of this.
|
|
962
|
+
for (const prop of this.declaredProps) {
|
|
960
963
|
const value = this.valueOf(prop, js.config).json(js);
|
|
961
964
|
properties[prop.key] = prop.default ? {
|
|
962
965
|
...value,
|
|
@@ -1645,7 +1648,7 @@ function parseObject(def, ctx) {
|
|
|
1645
1648
|
if (key === "...") {
|
|
1646
1649
|
const spread = parseDefinition(value, ctx);
|
|
1647
1650
|
if (!(spread instanceof ObjectNode)) throw new ParseError(`'...' must spread an object (was ${spread.expression})`);
|
|
1648
|
-
props = mergeProps(props, spread.
|
|
1651
|
+
props = mergeProps(props, spread.declaredProps);
|
|
1649
1652
|
index.push(...spread.index);
|
|
1650
1653
|
continue;
|
|
1651
1654
|
}
|
|
@@ -1676,9 +1679,12 @@ function parseObject(def, ctx) {
|
|
|
1676
1679
|
return new ObjectNode(props, index, undeclared);
|
|
1677
1680
|
}
|
|
1678
1681
|
/** Later props replace earlier ones with the same key (`'...'`, `.merge()`). */
|
|
1682
|
+
/** `base` with `over`'s keys: a key both have keeps its place and takes `over`'s prop (like an object spread), new keys follow. */
|
|
1679
1683
|
function mergeProps(base, over) {
|
|
1680
|
-
const
|
|
1681
|
-
|
|
1684
|
+
const byKey = new Map(over.map((p) => [p.key, p]));
|
|
1685
|
+
const merged = base.map((p) => byKey.get(p.key) ?? p);
|
|
1686
|
+
const known = new Set(base.map((p) => p.key));
|
|
1687
|
+
return [...merged, ...over.filter((p) => !known.has(p.key))];
|
|
1682
1688
|
}
|
|
1683
1689
|
/** `'number = 5'` → `{ def: 'number', value: '5' }`: the top-level `=` that is not `<=`, `>=` or `==`. */
|
|
1684
1690
|
function defaultSplit(text) {
|
|
@@ -1781,8 +1787,8 @@ function union(branches) {
|
|
|
1781
1787
|
/** `a & b`: one object of both's keys, one base with both's rules, or both checks in turn. */
|
|
1782
1788
|
function intersect(a, b) {
|
|
1783
1789
|
if (a instanceof ObjectNode && b instanceof ObjectNode) {
|
|
1784
|
-
const props = [...a.
|
|
1785
|
-
for (const prop of b.
|
|
1790
|
+
const props = [...a.declaredProps];
|
|
1791
|
+
for (const prop of b.declaredProps) {
|
|
1786
1792
|
const i = props.findIndex((p) => p.key === prop.key);
|
|
1787
1793
|
if (i < 0) props.push(prop);
|
|
1788
1794
|
else {
|
|
@@ -2144,22 +2150,22 @@ const prototype = {
|
|
|
2144
2150
|
const node = objectNode(this, "merge");
|
|
2145
2151
|
const other = parseDefinition(def, contextFor(this[CONFIG]));
|
|
2146
2152
|
if (!(other instanceof ObjectNode)) throw new TypeError(`.merge() needs an object (was ${other.expression})`);
|
|
2147
|
-
return makeType(new ObjectNode(mergeProps(node.
|
|
2153
|
+
return makeType(new ObjectNode(mergeProps(node.declaredProps, other.declaredProps), [...node.index, ...other.index], other.undeclared ?? node.undeclared), this[CONFIG]);
|
|
2148
2154
|
},
|
|
2149
2155
|
pick(...keys) {
|
|
2150
|
-
return withProps(this, objectNode(this, "pick").
|
|
2156
|
+
return withProps(this, objectNode(this, "pick").declaredProps.filter((p) => keys.includes(p.key)));
|
|
2151
2157
|
},
|
|
2152
2158
|
omit(...keys) {
|
|
2153
|
-
return withProps(this, objectNode(this, "omit").
|
|
2159
|
+
return withProps(this, objectNode(this, "omit").declaredProps.filter((p) => !keys.includes(p.key)));
|
|
2154
2160
|
},
|
|
2155
2161
|
partial() {
|
|
2156
|
-
return withProps(this, objectNode(this, "partial").
|
|
2162
|
+
return withProps(this, objectNode(this, "partial").declaredProps.map((p) => ({
|
|
2157
2163
|
...p,
|
|
2158
2164
|
kind: "optional"
|
|
2159
2165
|
})));
|
|
2160
2166
|
},
|
|
2161
2167
|
required() {
|
|
2162
|
-
return withProps(this, objectNode(this, "required").
|
|
2168
|
+
return withProps(this, objectNode(this, "required").declaredProps.map(({ default: _default, ...p }) => ({
|
|
2163
2169
|
...p,
|
|
2164
2170
|
kind: "required"
|
|
2165
2171
|
})));
|
|
@@ -2202,7 +2208,7 @@ const prototype = {
|
|
|
2202
2208
|
},
|
|
2203
2209
|
onUndeclaredKey(behavior) {
|
|
2204
2210
|
const node = objectNode(this, "onUndeclaredKey");
|
|
2205
|
-
return makeType(new ObjectNode(node.
|
|
2211
|
+
return makeType(new ObjectNode(node.declaredProps, node.index, behavior), this[CONFIG]);
|
|
2206
2212
|
},
|
|
2207
2213
|
atLeast(limit) {
|
|
2208
2214
|
return bounded(this, ">=", limit, "value");
|
package/dist/vite/durableDb.d.ts
CHANGED