@metaobjectsdev/migrate-ts 0.23.1 → 0.24.0
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/diff/index.d.ts.map +1 -1
- package/dist/diff/index.js +17 -7
- package/dist/diff/index.js.map +1 -1
- package/dist/drift/drift.d.ts +32 -2
- package/dist/drift/drift.d.ts.map +1 -1
- package/dist/drift/drift.js +15 -8
- package/dist/drift/drift.js.map +1 -1
- package/dist/emit/postgres.js +69 -12
- package/dist/emit/postgres.js.map +1 -1
- package/dist/emit/sqlite.d.ts.map +1 -1
- package/dist/emit/sqlite.js +9 -2
- package/dist/emit/sqlite.js.map +1 -1
- package/dist/expected-schema.d.ts +37 -0
- package/dist/expected-schema.d.ts.map +1 -1
- package/dist/expected-schema.js +124 -16
- package/dist/expected-schema.js.map +1 -1
- package/dist/index.d.ts +8 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -1
- package/dist/index.js.map +1 -1
- package/dist/qualified-name.d.ts +9 -0
- package/dist/qualified-name.d.ts.map +1 -0
- package/dist/qualified-name.js +21 -0
- package/dist/qualified-name.js.map +1 -0
- package/dist/scope.d.ts +121 -0
- package/dist/scope.d.ts.map +1 -0
- package/dist/scope.js +193 -0
- package/dist/scope.js.map +1 -0
- package/dist/snapshot/plan.d.ts +23 -1
- package/dist/snapshot/plan.d.ts.map +1 -1
- package/dist/snapshot/plan.js +17 -9
- package/dist/snapshot/plan.js.map +1 -1
- package/dist/types.d.ts +17 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/unmanaged.d.ts.map +1 -1
- package/dist/unmanaged.js +3 -3
- package/dist/unmanaged.js.map +1 -1
- package/dist/verify/replay-engine.d.ts +10 -0
- package/dist/verify/replay-engine.d.ts.map +1 -0
- package/dist/verify/replay-engine.js +161 -0
- package/dist/verify/replay-engine.js.map +1 -0
- package/dist/verify/replay.d.ts +15 -0
- package/dist/verify/replay.d.ts.map +1 -1
- package/dist/verify/replay.js +7 -1
- package/dist/verify/replay.js.map +1 -1
- package/package.json +14 -3
- package/src/diff/index.ts +17 -9
- package/src/drift/drift.ts +55 -15
- package/src/emit/postgres.ts +70 -12
- package/src/emit/sqlite.ts +9 -2
- package/src/expected-schema.ts +155 -15
- package/src/index.ts +18 -2
- package/src/qualified-name.ts +22 -0
- package/src/scope.ts +261 -0
- package/src/snapshot/plan.ts +45 -13
- package/src/types.ts +17 -0
- package/src/unmanaged.ts +2 -3
- package/src/verify/replay-engine.ts +184 -0
- package/src/verify/replay.ts +21 -1
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// The ONE qualified-physical-name form: `<schema>.<name>`, with an absent schema
|
|
2
|
+
// normalized to the Postgres default.
|
|
3
|
+
//
|
|
4
|
+
// Three things must key DB objects identically or the diff silently disagrees with
|
|
5
|
+
// itself: `diff`'s table/view identity maps, the declared-`@unmanaged` exclusion set
|
|
6
|
+
// (`collectUnmanagedNames`), and the out-of-scope exclusion set (`scopeExpectedSchema`).
|
|
7
|
+
// The last two are ACT-side suppressions matched against the first, so a name built a
|
|
8
|
+
// second way — a different default schema, a different separator — reads as "not
|
|
9
|
+
// suppressed" and the object it names comes back as a proposed DROP. One function.
|
|
10
|
+
//
|
|
11
|
+
// SQLite has no schema concept, so every SQLite object normalizes to the same prefix.
|
|
12
|
+
// That is harmless: it is a constant, and the un-prefixed names were already unique.
|
|
13
|
+
import { DEFAULT_DB_SCHEMA_POSTGRES } from "@metaobjectsdev/metadata";
|
|
14
|
+
/** `<schema>.<name>`; an absent schema is the Postgres default (`public`). The
|
|
15
|
+
* parameter accepts an EXPLICIT `undefined` schema (not only an omitted key) so a
|
|
16
|
+
* caller holding a `string | undefined` can pass it straight through under
|
|
17
|
+
* `exactOptionalPropertyTypes` — the two spell the same thing here. */
|
|
18
|
+
export function qualifiedDbName(obj) {
|
|
19
|
+
return `${obj.schema ?? DEFAULT_DB_SCHEMA_POSTGRES}.${obj.name}`;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=qualified-name.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qualified-name.js","sourceRoot":"","sources":["../src/qualified-name.ts"],"names":[],"mappings":"AAAA,iFAAiF;AACjF,sCAAsC;AACtC,EAAE;AACF,mFAAmF;AACnF,qFAAqF;AACrF,yFAAyF;AACzF,sFAAsF;AACtF,iFAAiF;AACjF,mFAAmF;AACnF,EAAE;AACF,sFAAsF;AACtF,qFAAqF;AAErF,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AAEtE;;;wEAGwE;AACxE,MAAM,UAAU,eAAe,CAAC,GAAkD;IAChF,OAAO,GAAG,GAAG,CAAC,MAAM,IAAI,0BAA0B,IAAI,GAAG,CAAC,IAAI,EAAE,CAAC;AACnE,CAAC"}
|
package/dist/scope.d.ts
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import type { DiffArgs } from "./diff/index.js";
|
|
2
|
+
import type { ExpectedSchemaWithProvenance } from "./expected-schema.js";
|
|
3
|
+
import type { SchemaSnapshot } from "./types.js";
|
|
4
|
+
/**
|
|
5
|
+
* Decides whether an object's fully-qualified name (`resolutionKey()`) is governed
|
|
6
|
+
* by this run. Supplied by the caller as a PREDICATE so migrate-ts never carries a
|
|
7
|
+
* second implementation of the scope-pattern grammar — `matchesScope` in
|
|
8
|
+
* `@metaobjectsdev/sdk` is the only one, and the CLI adapts a compiled scope to
|
|
9
|
+
* this seam.
|
|
10
|
+
*/
|
|
11
|
+
export type ObjectScopePredicate = (fqn: string) => boolean;
|
|
12
|
+
export interface ScopedExpectedSchema {
|
|
13
|
+
/** The expected schema narrowed to the governed objects. */
|
|
14
|
+
snapshot: SchemaSnapshot;
|
|
15
|
+
/**
|
|
16
|
+
* Qualified physical names (`<schema>.<name>`) of the tables and views removed
|
|
17
|
+
* above. Reaches `diff`'s `unmanagedNames` (MERGED with `collectUnmanagedNames`,
|
|
18
|
+
* never replacing it) so the actual side is suppressed too — `scopedDiffInputs`
|
|
19
|
+
* does that merge; see the module header for why omitting it inverts the feature.
|
|
20
|
+
*/
|
|
21
|
+
outOfScope: string[];
|
|
22
|
+
/**
|
|
23
|
+
* The database schemas the UNSCOPED model declares, for `diff`'s `scopeSchemas`.
|
|
24
|
+
* `scopedDiffInputs` threads it — see the module header: without it a scope
|
|
25
|
+
* matching nothing hands `diff` an empty expected side, which it reads as "no
|
|
26
|
+
* model, govern the whole database".
|
|
27
|
+
*
|
|
28
|
+
* `undefined` when no predicate was supplied (so `diff` derives its own set from
|
|
29
|
+
* an untouched `expected`, exactly as before — an unscoped project's arguments are
|
|
30
|
+
* unchanged) and also when the unscoped model declares no tables or views at all
|
|
31
|
+
* (nothing to derive from; `diff`'s legacy whole-DB fallback is preserved).
|
|
32
|
+
*/
|
|
33
|
+
declaredSchemas?: string[];
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Carry an out-of-scope object forward into the snapshot a run is about to commit.
|
|
37
|
+
*
|
|
38
|
+
* The committed snapshot is built from the metadata-expected schema, which a scoped
|
|
39
|
+
* run has already narrowed — so accepting a scoped run DELETES every out-of-scope
|
|
40
|
+
* entry the previous snapshot held. Widening or removing `migrate.scope` later then
|
|
41
|
+
* proposes `CREATE TABLE` for a table that exists, and the migration fails at apply.
|
|
42
|
+
*
|
|
43
|
+
* `prior` is the snapshot (or introspected schema) the run diffed against, and the
|
|
44
|
+
* entries taken from it are exactly the ones this run excluded — nothing else is
|
|
45
|
+
* carried, so a table the model never declared is unaffected either way. An empty
|
|
46
|
+
* `outOfScope` returns the SAME object, so an unscoped run commits a byte-identical
|
|
47
|
+
* snapshot.
|
|
48
|
+
*/
|
|
49
|
+
export declare function carryForwardOutOfScope(next: SchemaSnapshot, prior: SchemaSnapshot, outOfScope: readonly string[]): SchemaSnapshot;
|
|
50
|
+
/**
|
|
51
|
+
* Drop the out-of-scope entries from a COMMITTED SNAPSHOT, producing the same
|
|
52
|
+
* three-part shape `scopeExpectedSchema` produces so the result can go straight
|
|
53
|
+
* through {@link scopedDiffInputs}.
|
|
54
|
+
*
|
|
55
|
+
* `verify`'s committed-snapshot gate (#292) needs this: `unmanagedNames` suppresses
|
|
56
|
+
* only the ACTUAL side, which is right when the expected side is the metadata (it is
|
|
57
|
+
* already scoped) and wrong here, where the expected side IS the snapshot — a
|
|
58
|
+
* snapshot written before the scope was declared still carries the other owner's
|
|
59
|
+
* tables, and leaving them in reports a phantom disagreement about an object this
|
|
60
|
+
* consumer does not manage.
|
|
61
|
+
*
|
|
62
|
+
* `governed` is the scope decision the caller's drift comparison already made — pass
|
|
63
|
+
* the `DriftResult` itself, which satisfies this shape. Taking `declaredSchemas`
|
|
64
|
+
* from there rather than re-deriving it from the snapshot is what closes the last
|
|
65
|
+
* whole-database door: a snapshot that is present but EMPTY (a never-migrated
|
|
66
|
+
* project) declares no schemas at all, so deriving from it hands `diff` nothing and
|
|
67
|
+
* reaches its "no model, govern the whole database" fallback — the very inversion
|
|
68
|
+
* this module exists to prevent, at the one call site that was still re-deriving.
|
|
69
|
+
*
|
|
70
|
+
* An empty `outOfScope` returns the SAME snapshot object with no schema pin, so an
|
|
71
|
+
* unscoped project's `diff` arguments are byte-for-byte what they always were.
|
|
72
|
+
*/
|
|
73
|
+
export declare function excludeFromSnapshot(snapshot: SchemaSnapshot, governed: GovernedScope): ScopedExpectedSchema;
|
|
74
|
+
/** The scope decision a run made, as `DriftResult` reports it. */
|
|
75
|
+
export interface GovernedScope {
|
|
76
|
+
/** Qualified physical names (`<schema>.<name>`) the run does not govern. */
|
|
77
|
+
readonly outOfScope: readonly string[];
|
|
78
|
+
/** The schemas the run governs — `ScopedExpectedSchema.declaredSchemas`. */
|
|
79
|
+
readonly declaredSchemas?: readonly string[] | undefined;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* The three `diff` arguments a scoped run owes, as ONE value.
|
|
83
|
+
*
|
|
84
|
+
* The module header lists them as three separate obligations, and five call sites
|
|
85
|
+
* re-derived them by hand — one of which had already drifted into its own guard.
|
|
86
|
+
* Every scoped `diff` call is now
|
|
87
|
+
* `diff({ ...scopedDiffInputs(scoped, collectUnmanagedNames(metadata)), actual, ... })`,
|
|
88
|
+
* so the rule is enforced by the type rather than by the comment.
|
|
89
|
+
*
|
|
90
|
+
* `unmanaged` is the `@unmanaged`-declared set (`collectUnmanagedNames`); it is
|
|
91
|
+
* MERGED with `outOfScope`, never replaced by it — both must reach `diff`.
|
|
92
|
+
* `scopeSchemas` is omitted entirely when the run narrowed nothing, so an unscoped
|
|
93
|
+
* project's arguments are unchanged.
|
|
94
|
+
*/
|
|
95
|
+
export declare function scopedDiffInputs(scoped: ScopedExpectedSchema, unmanaged: readonly string[]): Pick<DiffArgs, "expected" | "unmanagedNames" | "scopeSchemas">;
|
|
96
|
+
/**
|
|
97
|
+
* The distinct database schemas a snapshot's tables and views sit in, absent
|
|
98
|
+
* normalized to the Postgres default — the value `diff` derives for itself when no
|
|
99
|
+
* `scopeSchemas` is supplied. The ONE definition: any caller narrowing an expected
|
|
100
|
+
* side must pin `diff`'s schema scope to the UNNARROWED snapshot's schemas, and a
|
|
101
|
+
* second encoding of "absent means public" here would silently disagree with the
|
|
102
|
+
* one inside `diff`.
|
|
103
|
+
*
|
|
104
|
+
* Empty in ⇒ empty out, which callers translate to "pass nothing", preserving
|
|
105
|
+
* `diff`'s legacy whole-database fallback for a genuinely empty model.
|
|
106
|
+
*/
|
|
107
|
+
export declare function declaredSchemasOf(snapshot: SchemaSnapshot): string[];
|
|
108
|
+
/**
|
|
109
|
+
* Narrow an expected schema to the objects inside `inScope`.
|
|
110
|
+
*
|
|
111
|
+
* An undefined predicate returns the input untouched — the SAME snapshot object,
|
|
112
|
+
* not an equal copy — so a project that declares no `migrate.scope` reaches the
|
|
113
|
+
* diff, the emitter and the committed snapshot through an unchanged value.
|
|
114
|
+
*
|
|
115
|
+
* A table or view with NO recorded provenance is KEPT. Scope decides on the
|
|
116
|
+
* declaring object's FQN, and an object whose FQN is unknown was never proven to be
|
|
117
|
+
* anyone else's; dropping it would silently un-manage it (and, worse, suppressing
|
|
118
|
+
* its name on the actual side would hide real drift).
|
|
119
|
+
*/
|
|
120
|
+
export declare function scopeExpectedSchema(built: ExpectedSchemaWithProvenance, inScope: ObjectScopePredicate | undefined): ScopedExpectedSchema;
|
|
121
|
+
//# sourceMappingURL=scope.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scope.d.ts","sourceRoot":"","sources":["../src/scope.ts"],"names":[],"mappings":"AAwCA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,sBAAsB,CAAC;AAEzE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD;;;;;;GAMG;AACH,MAAM,MAAM,oBAAoB,GAAG,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC;AAE5D,MAAM,WAAW,oBAAoB;IACnC,4DAA4D;IAC5D,QAAQ,EAAE,cAAc,CAAC;IACzB;;;;;OAKG;IACH,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB;;;;;;;;;;OAUG;IACH,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;CAC5B;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,cAAc,EACpB,KAAK,EAAE,cAAc,EACrB,UAAU,EAAE,SAAS,MAAM,EAAE,GAC5B,cAAc,CAQhB;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,cAAc,EACxB,QAAQ,EAAE,aAAa,GACtB,oBAAoB,CAatB;AAED,kEAAkE;AAClE,MAAM,WAAW,aAAa;IAC5B,4EAA4E;IAC5E,QAAQ,CAAC,UAAU,EAAE,SAAS,MAAM,EAAE,CAAC;IACvC,4EAA4E;IAC5E,QAAQ,CAAC,eAAe,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,CAAC;CAC1D;AAoBD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,oBAAoB,EAC5B,SAAS,EAAE,SAAS,MAAM,EAAE,GAC3B,IAAI,CAAC,QAAQ,EAAE,UAAU,GAAG,gBAAgB,GAAG,cAAc,CAAC,CAMhE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,cAAc,GAAG,MAAM,EAAE,CAQpE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,4BAA4B,EACnC,OAAO,EAAE,oBAAoB,GAAG,SAAS,GACxC,oBAAoB,CA0BtB"}
|
package/dist/scope.js
ADDED
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
// Per-command scope — narrowing a migrate/verify run to the objects it governs.
|
|
2
|
+
//
|
|
3
|
+
// A consumer sharing a database with another owner declares
|
|
4
|
+
// `"migrate": { "scope": ["acme::platform::**"] }`. Tables and views outside that
|
|
5
|
+
// scope are neither created nor dropped, which takes TWO suppressions:
|
|
6
|
+
//
|
|
7
|
+
// 1. drop them from the EXPECTED side, so nothing is created or altered;
|
|
8
|
+
// 2. suppress the same names on the ACTUAL side (via `diff`'s `unmanagedNames`,
|
|
9
|
+
// the seam `@unmanaged` already uses), so nothing is dropped.
|
|
10
|
+
//
|
|
11
|
+
// Doing only (1) is strictly worse than doing nothing: every out-of-scope table that
|
|
12
|
+
// EXISTS in the database becomes a proposed `DROP TABLE` — the precise hazard this
|
|
13
|
+
// feature exists to remove. `scopeExpectedSchema` therefore returns both halves and
|
|
14
|
+
// callers must thread `outOfScope` into the diff.
|
|
15
|
+
//
|
|
16
|
+
// There is a THIRD half, and it is the one that bites hardest when the scope is
|
|
17
|
+
// wrong. `diff` derives its SCHEMA scope from the schemas the expected side
|
|
18
|
+
// mentions, falling back to "no schema scoping at all" when expected is empty (the
|
|
19
|
+
// legacy whole-DB path for a project with no model). A scope matching NOTHING
|
|
20
|
+
// empties `expected`, reaches that fallback, and every actual table in every schema
|
|
21
|
+
// becomes a drop candidate — another owner's included, which was never in `expected`
|
|
22
|
+
// so it has no provenance and never lands in `outOfScope`. Narrowing must never
|
|
23
|
+
// WIDEN. `declaredSchemas` below reports the UNSCOPED model's schemas so callers can
|
|
24
|
+
// pin `diff`'s `scopeSchemas` to a property of the whole model, which `migrate.scope`
|
|
25
|
+
// then cannot move in either direction.
|
|
26
|
+
//
|
|
27
|
+
// THE RULE THAT FOLLOWS FROM THAT, stated once because it is easy to read the other
|
|
28
|
+
// way: **a scope narrows which OBJECTS the tool governs, never which SCHEMAS it is
|
|
29
|
+
// allowed to see.** Pinning `scopeSchemas` to the unscoped model means a scope that
|
|
30
|
+
// excludes every declared object in schema `X` leaves `X` in scope, so another
|
|
31
|
+
// owner's UNDECLARED table in `X` stays a drop candidate — exactly as it would be on
|
|
32
|
+
// an unscoped run of the same model. That is deliberate: a schema this model
|
|
33
|
+
// declares into is a schema this model manages, and deriving the schema set from the
|
|
34
|
+
// survivors instead is precisely the inversion above. Declaring a scope is not a way
|
|
35
|
+
// to hand a schema over; removing the objects from the model is.
|
|
36
|
+
//
|
|
37
|
+
// `scopedDiffInputs` exists so no caller has to remember any of this: it returns all
|
|
38
|
+
// three obligations as one object, and every scoped `diff` call goes through it.
|
|
39
|
+
import { DEFAULT_DB_SCHEMA_POSTGRES } from "@metaobjectsdev/metadata";
|
|
40
|
+
import { qualifiedDbName } from "./qualified-name.js";
|
|
41
|
+
/**
|
|
42
|
+
* Carry an out-of-scope object forward into the snapshot a run is about to commit.
|
|
43
|
+
*
|
|
44
|
+
* The committed snapshot is built from the metadata-expected schema, which a scoped
|
|
45
|
+
* run has already narrowed — so accepting a scoped run DELETES every out-of-scope
|
|
46
|
+
* entry the previous snapshot held. Widening or removing `migrate.scope` later then
|
|
47
|
+
* proposes `CREATE TABLE` for a table that exists, and the migration fails at apply.
|
|
48
|
+
*
|
|
49
|
+
* `prior` is the snapshot (or introspected schema) the run diffed against, and the
|
|
50
|
+
* entries taken from it are exactly the ones this run excluded — nothing else is
|
|
51
|
+
* carried, so a table the model never declared is unaffected either way. An empty
|
|
52
|
+
* `outOfScope` returns the SAME object, so an unscoped run commits a byte-identical
|
|
53
|
+
* snapshot.
|
|
54
|
+
*/
|
|
55
|
+
export function carryForwardOutOfScope(next, prior, outOfScope) {
|
|
56
|
+
if (outOfScope.length === 0)
|
|
57
|
+
return next;
|
|
58
|
+
const excluded = new Set(outOfScope);
|
|
59
|
+
return {
|
|
60
|
+
...next,
|
|
61
|
+
tables: [...next.tables, ...splitOnName(prior.tables, excluded).named],
|
|
62
|
+
views: [...next.views, ...splitOnName(prior.views, excluded).named],
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Drop the out-of-scope entries from a COMMITTED SNAPSHOT, producing the same
|
|
67
|
+
* three-part shape `scopeExpectedSchema` produces so the result can go straight
|
|
68
|
+
* through {@link scopedDiffInputs}.
|
|
69
|
+
*
|
|
70
|
+
* `verify`'s committed-snapshot gate (#292) needs this: `unmanagedNames` suppresses
|
|
71
|
+
* only the ACTUAL side, which is right when the expected side is the metadata (it is
|
|
72
|
+
* already scoped) and wrong here, where the expected side IS the snapshot — a
|
|
73
|
+
* snapshot written before the scope was declared still carries the other owner's
|
|
74
|
+
* tables, and leaving them in reports a phantom disagreement about an object this
|
|
75
|
+
* consumer does not manage.
|
|
76
|
+
*
|
|
77
|
+
* `governed` is the scope decision the caller's drift comparison already made — pass
|
|
78
|
+
* the `DriftResult` itself, which satisfies this shape. Taking `declaredSchemas`
|
|
79
|
+
* from there rather than re-deriving it from the snapshot is what closes the last
|
|
80
|
+
* whole-database door: a snapshot that is present but EMPTY (a never-migrated
|
|
81
|
+
* project) declares no schemas at all, so deriving from it hands `diff` nothing and
|
|
82
|
+
* reaches its "no model, govern the whole database" fallback — the very inversion
|
|
83
|
+
* this module exists to prevent, at the one call site that was still re-deriving.
|
|
84
|
+
*
|
|
85
|
+
* An empty `outOfScope` returns the SAME snapshot object with no schema pin, so an
|
|
86
|
+
* unscoped project's `diff` arguments are byte-for-byte what they always were.
|
|
87
|
+
*/
|
|
88
|
+
export function excludeFromSnapshot(snapshot, governed) {
|
|
89
|
+
if (governed.outOfScope.length === 0)
|
|
90
|
+
return { snapshot, outOfScope: [] };
|
|
91
|
+
const excluded = new Set(governed.outOfScope);
|
|
92
|
+
const declared = governed.declaredSchemas ?? declaredSchemasOf(snapshot);
|
|
93
|
+
return {
|
|
94
|
+
snapshot: {
|
|
95
|
+
...snapshot,
|
|
96
|
+
tables: splitOnName(snapshot.tables, excluded).rest,
|
|
97
|
+
views: splitOnName(snapshot.views, excluded).rest,
|
|
98
|
+
},
|
|
99
|
+
outOfScope: [...governed.outOfScope],
|
|
100
|
+
declaredSchemas: [...declared],
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Partition `objs` on whether `qualifiedDbName(o)` is in `names`.
|
|
105
|
+
*
|
|
106
|
+
* `carryForwardOutOfScope` wants the `named` half (carry the excluded entries
|
|
107
|
+
* forward) and `excludeFromSnapshot` wants the `rest` half (drop them). They are
|
|
108
|
+
* exact complements over the same key function, so they share one traversal rather
|
|
109
|
+
* than two filters that could come to key differently.
|
|
110
|
+
*/
|
|
111
|
+
function splitOnName(objs, names) {
|
|
112
|
+
const named = [];
|
|
113
|
+
const rest = [];
|
|
114
|
+
for (const o of objs)
|
|
115
|
+
(names.has(qualifiedDbName(o)) ? named : rest).push(o);
|
|
116
|
+
return { named, rest };
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* The three `diff` arguments a scoped run owes, as ONE value.
|
|
120
|
+
*
|
|
121
|
+
* The module header lists them as three separate obligations, and five call sites
|
|
122
|
+
* re-derived them by hand — one of which had already drifted into its own guard.
|
|
123
|
+
* Every scoped `diff` call is now
|
|
124
|
+
* `diff({ ...scopedDiffInputs(scoped, collectUnmanagedNames(metadata)), actual, ... })`,
|
|
125
|
+
* so the rule is enforced by the type rather than by the comment.
|
|
126
|
+
*
|
|
127
|
+
* `unmanaged` is the `@unmanaged`-declared set (`collectUnmanagedNames`); it is
|
|
128
|
+
* MERGED with `outOfScope`, never replaced by it — both must reach `diff`.
|
|
129
|
+
* `scopeSchemas` is omitted entirely when the run narrowed nothing, so an unscoped
|
|
130
|
+
* project's arguments are unchanged.
|
|
131
|
+
*/
|
|
132
|
+
export function scopedDiffInputs(scoped, unmanaged) {
|
|
133
|
+
return {
|
|
134
|
+
expected: scoped.snapshot,
|
|
135
|
+
unmanagedNames: [...unmanaged, ...scoped.outOfScope],
|
|
136
|
+
...(scoped.declaredSchemas !== undefined ? { scopeSchemas: scoped.declaredSchemas } : {}),
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* The distinct database schemas a snapshot's tables and views sit in, absent
|
|
141
|
+
* normalized to the Postgres default — the value `diff` derives for itself when no
|
|
142
|
+
* `scopeSchemas` is supplied. The ONE definition: any caller narrowing an expected
|
|
143
|
+
* side must pin `diff`'s schema scope to the UNNARROWED snapshot's schemas, and a
|
|
144
|
+
* second encoding of "absent means public" here would silently disagree with the
|
|
145
|
+
* one inside `diff`.
|
|
146
|
+
*
|
|
147
|
+
* Empty in ⇒ empty out, which callers translate to "pass nothing", preserving
|
|
148
|
+
* `diff`'s legacy whole-database fallback for a genuinely empty model.
|
|
149
|
+
*/
|
|
150
|
+
export function declaredSchemasOf(snapshot) {
|
|
151
|
+
return [
|
|
152
|
+
...new Set([...snapshot.tables, ...snapshot.views].map((o) => o.schema ?? DEFAULT_DB_SCHEMA_POSTGRES)),
|
|
153
|
+
].sort();
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Narrow an expected schema to the objects inside `inScope`.
|
|
157
|
+
*
|
|
158
|
+
* An undefined predicate returns the input untouched — the SAME snapshot object,
|
|
159
|
+
* not an equal copy — so a project that declares no `migrate.scope` reaches the
|
|
160
|
+
* diff, the emitter and the committed snapshot through an unchanged value.
|
|
161
|
+
*
|
|
162
|
+
* A table or view with NO recorded provenance is KEPT. Scope decides on the
|
|
163
|
+
* declaring object's FQN, and an object whose FQN is unknown was never proven to be
|
|
164
|
+
* anyone else's; dropping it would silently un-manage it (and, worse, suppressing
|
|
165
|
+
* its name on the actual side would hide real drift).
|
|
166
|
+
*/
|
|
167
|
+
export function scopeExpectedSchema(built, inScope) {
|
|
168
|
+
if (inScope === undefined)
|
|
169
|
+
return { snapshot: built.snapshot, outOfScope: [] };
|
|
170
|
+
// Computed from `built.snapshot` — the UNSCOPED side — deliberately, and before
|
|
171
|
+
// the filter below runs. Deriving it from the survivors would reproduce exactly
|
|
172
|
+
// the defect this exists to close.
|
|
173
|
+
const declared = declaredSchemasOf(built.snapshot);
|
|
174
|
+
const outOfScope = [];
|
|
175
|
+
const governed = (obj) => {
|
|
176
|
+
const qualified = qualifiedDbName(obj);
|
|
177
|
+
const fqn = built.provenance.get(qualified);
|
|
178
|
+
if (fqn === undefined || inScope(fqn))
|
|
179
|
+
return true;
|
|
180
|
+
outOfScope.push(qualified);
|
|
181
|
+
return false;
|
|
182
|
+
};
|
|
183
|
+
return {
|
|
184
|
+
snapshot: {
|
|
185
|
+
...built.snapshot,
|
|
186
|
+
tables: built.snapshot.tables.filter(governed),
|
|
187
|
+
views: built.snapshot.views.filter(governed),
|
|
188
|
+
},
|
|
189
|
+
outOfScope,
|
|
190
|
+
...(declared.length > 0 ? { declaredSchemas: declared } : {}),
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
//# sourceMappingURL=scope.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scope.js","sourceRoot":"","sources":["../src/scope.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,EAAE;AACF,4DAA4D;AAC5D,kFAAkF;AAClF,uEAAuE;AACvE,EAAE;AACF,2EAA2E;AAC3E,kFAAkF;AAClF,mEAAm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AC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC;SAC7C;QACD,UAAU;QACV,GAAG,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,eAAe,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC9D,CAAC;AACJ,CAAC"}
|
package/dist/snapshot/plan.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ColumnNamingStrategy, MetaData } from "@metaobjectsdev/metadata";
|
|
2
2
|
import { type DiffArgs } from "../diff/index.js";
|
|
3
|
+
import { type ObjectScopePredicate } from "../scope.js";
|
|
3
4
|
import type { Dialect, DiffResult, SchemaSnapshot } from "../types.js";
|
|
4
5
|
import type { ExpectedViewInput } from "../expected-schema.js";
|
|
5
6
|
export interface PlanOfflineArgs extends Pick<DiffArgs, "allow" | "onAmbiguous" | "ignoreTables"> {
|
|
@@ -10,12 +11,33 @@ export interface PlanOfflineArgs extends Pick<DiffArgs, "allow" | "onAmbiguous"
|
|
|
10
11
|
columnNamingStrategy?: ColumnNamingStrategy;
|
|
11
12
|
/** Expected views (via codegen-ts `buildProjectionViews`) — threaded into buildExpectedSchema. */
|
|
12
13
|
views?: readonly ExpectedViewInput[];
|
|
14
|
+
/**
|
|
15
|
+
* Per-command scope (`migrate.scope`): objects whose declaring FQN this predicate
|
|
16
|
+
* rejects are governed by somebody else. They leave the expected side (so no
|
|
17
|
+
* create/alter) AND the snapshot side (so no drop). Omit to govern everything
|
|
18
|
+
* loaded (unchanged behavior).
|
|
19
|
+
*/
|
|
20
|
+
inScope?: ObjectScopePredicate;
|
|
13
21
|
}
|
|
14
22
|
export interface PlanOfflineResult {
|
|
15
23
|
/** The change set to emit, from diffing metadata-expected against the snapshot. */
|
|
16
24
|
diff: DiffResult;
|
|
17
|
-
/**
|
|
25
|
+
/**
|
|
26
|
+
* The schema the migration brings us to — write this back as the new snapshot on
|
|
27
|
+
* accept. Under a scope this is the governed schema PLUS the out-of-scope entries
|
|
28
|
+
* the prior snapshot held: committing the narrowed schema would delete them, and a
|
|
29
|
+
* later widening would then propose CREATE TABLE for a table that exists.
|
|
30
|
+
*/
|
|
18
31
|
nextSnapshot: SchemaSnapshot;
|
|
32
|
+
/**
|
|
33
|
+
* The governed (narrowed) expected side — what the diff compared and what the
|
|
34
|
+
* emitter renders against. Identical to `nextSnapshot` for an unscoped run; under
|
|
35
|
+
* a scope it is deliberately the SMALLER of the two, since a run must emit DDL
|
|
36
|
+
* only for what it governs.
|
|
37
|
+
*/
|
|
38
|
+
expected: SchemaSnapshot;
|
|
39
|
+
/** Qualified physical names excluded by `inScope`; empty when no scope was given. */
|
|
40
|
+
outOfScope: readonly string[];
|
|
19
41
|
}
|
|
20
42
|
/**
|
|
21
43
|
* Plan a migration offline: build the expected schema from metadata and diff it
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plan.d.ts","sourceRoot":"","sources":["../../src/snapshot/plan.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAE/E,OAAO,EAAQ,KAAK,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AACvE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE/D,MAAM,WAAW,eAAgB,SAAQ,IAAI,CAAC,QAAQ,EAAE,OAAO,GAAG,aAAa,GAAG,cAAc,CAAC;IAC/F,QAAQ,EAAE,QAAQ,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,4GAA4G;IAC5G,QAAQ,EAAE,cAAc,CAAC;IACzB,oBAAoB,CAAC,EAAE,oBAAoB,CAAC;IAC5C,kGAAkG;IAClG,KAAK,CAAC,EAAE,SAAS,iBAAiB,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"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SAAS,iBAAiB,EAAE,GACnC,cAAc,CAMhB"}
|
package/dist/snapshot/plan.js
CHANGED
|
@@ -1,34 +1,42 @@
|
|
|
1
|
-
import { buildExpectedSchema } from "../expected-schema.js";
|
|
1
|
+
import { buildExpectedSchema, buildExpectedSchemaWithProvenance } from "../expected-schema.js";
|
|
2
2
|
import { diff } from "../diff/index.js";
|
|
3
3
|
import { collectUnmanagedNames } from "../unmanaged.js";
|
|
4
|
+
import { carryForwardOutOfScope, scopeExpectedSchema, scopedDiffInputs } from "../scope.js";
|
|
4
5
|
/**
|
|
5
6
|
* Plan a migration offline: build the expected schema from metadata and diff it
|
|
6
7
|
* against the stored snapshot. No database. The caller emits `diff` and, on
|
|
7
8
|
* accept, persists `nextSnapshot` via writeSnapshot.
|
|
8
9
|
*/
|
|
9
10
|
export async function planOffline(args) {
|
|
10
|
-
const
|
|
11
|
+
const scoped = scopeExpectedSchema(buildExpectedSchemaWithProvenance(args.metadata, {
|
|
11
12
|
dialect: args.dialect,
|
|
12
13
|
...(args.columnNamingStrategy ? { columnNamingStrategy: args.columnNamingStrategy } : {}),
|
|
13
14
|
...(args.views !== undefined ? { views: args.views } : {}),
|
|
14
|
-
});
|
|
15
|
+
}), args.inScope);
|
|
16
|
+
// The DIFF runs against the narrowed side; the SNAPSHOT keeps what this run
|
|
17
|
+
// excluded. Committing the narrowed schema would delete every out-of-scope entry
|
|
18
|
+
// the previous snapshot held, so removing or widening `migrate.scope` later would
|
|
19
|
+
// propose CREATE TABLE for a table that exists and fail at apply. Byte-identical
|
|
20
|
+
// for an unscoped run (`outOfScope` empty ⇒ the same object).
|
|
21
|
+
const nextSnapshot = carryForwardOutOfScope(scoped.snapshot, args.snapshot, scoped.outOfScope);
|
|
15
22
|
const result = await diff({
|
|
16
|
-
|
|
23
|
+
// The three scoped-diff obligations as one value (see scope.ts's header). The
|
|
24
|
+
// `unmanagedNames` merge matters as much on the OFFLINE path as anywhere: an
|
|
25
|
+
// out-of-scope table already recorded in the snapshot must not be dropped just
|
|
26
|
+
// because the scope excludes it, and neither must a declared-@unmanaged one a
|
|
27
|
+
// `baseline --from-db` captured (#208 §7).
|
|
28
|
+
...scopedDiffInputs(scoped, collectUnmanagedNames(args.metadata)),
|
|
17
29
|
actual: args.snapshot,
|
|
18
30
|
dialect: args.dialect,
|
|
19
31
|
// #258 — migration generation refuses a primary-key MOVE (there is no primary-key
|
|
20
32
|
// change kind to express it; it would otherwise silently drop the constraint). The
|
|
21
33
|
// read-only verify/drift path does NOT set this, so `meta verify` still reports drift.
|
|
22
34
|
refusePrimaryKeyChange: true,
|
|
23
|
-
// #208 §7 — exclude declared-@unmanaged objects from the actual (snapshot) side too,
|
|
24
|
-
// so the OFFLINE generate path never proposes DROP for an external table that a
|
|
25
|
-
// `baseline --from-db` captured into the snapshot (parity with the online/verify paths).
|
|
26
|
-
unmanagedNames: collectUnmanagedNames(args.metadata),
|
|
27
35
|
...(args.allow ? { allow: args.allow } : {}),
|
|
28
36
|
...(args.onAmbiguous ? { onAmbiguous: args.onAmbiguous } : {}),
|
|
29
37
|
...(args.ignoreTables ? { ignoreTables: args.ignoreTables } : {}),
|
|
30
38
|
});
|
|
31
|
-
return { diff: result, nextSnapshot };
|
|
39
|
+
return { diff: result, nextSnapshot, expected: scoped.snapshot, outOfScope: scoped.outOfScope };
|
|
32
40
|
}
|
|
33
41
|
/** Seed an initial reference snapshot from metadata (greenfield baseline). */
|
|
34
42
|
export function baselineFromMetadata(metadata, dialect, columnNamingStrategy, views) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plan.js","sourceRoot":"","sources":["../../src/snapshot/plan.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"plan.js","sourceRoot":"","sources":["../../src/snapshot/plan.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,iCAAiC,EAAE,MAAM,uBAAuB,CAAC;AAC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GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC5C,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC9D,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,IAAI,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAClE,CAAC,CAAC;IACH,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,UAAU,EAAE,MAAM,CAAC,UAAU,EAAE,CAAC;AAClG,CAAC;AAED,8EAA8E;AAC9E,MAAM,UAAU,oBAAoB,CAClC,QAAkB,EAClB,OAAgB,EAChB,oBAA2C,EAC3C,KAAoC;IAEpC,OAAO,mBAAmB,CAAC,QAAQ,EAAE;QACnC,OAAO;QACP,GAAG,CAAC,oBAAoB,CAAC,CAAC,CAAC,EAAE,oBAAoB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACzD,GAAG,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC1C,CAAC,CAAC;AACL,CAAC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -401,6 +401,23 @@ export interface AllowOptions {
|
|
|
401
401
|
* skips the default-diff for a live auto-sequence default entirely.)
|
|
402
402
|
*/
|
|
403
403
|
dropIdentityDefault?: boolean;
|
|
404
|
+
/**
|
|
405
|
+
* Permits dropping an object the COMMITTED SNAPSHOT never contained — i.e. one
|
|
406
|
+
* this toolchain never managed. Without it, such a drop is refused at generation
|
|
407
|
+
* time, because the migration it would write cannot replay against a database
|
|
408
|
+
* where that object never existed (#313). `classify.ts` already states the
|
|
409
|
+
* doctrine: objects present in the DB but not the snapshot "must never be treated
|
|
410
|
+
* as actionable drift or auto-dropped".
|
|
411
|
+
*
|
|
412
|
+
* The ONE field here read by the CLI's generation-time provenance guard rather
|
|
413
|
+
* than by `diff()`'s status pass — `diff` compares metadata against introspection
|
|
414
|
+
* and never sees the snapshot, which is precisely why the doctrine was not
|
|
415
|
+
* enforced where it mattered. It lives in `AllowOptions` anyway so `--allow` keeps
|
|
416
|
+
* ONE token list and ONE grant map (`ALLOW_TOKENS` / `ALLOW_TOKEN_MAP`, pinned
|
|
417
|
+
* together by `cli/test/unit/allow-tokens-pinned.test.ts`): a second parallel
|
|
418
|
+
* validation path for a single token is the exact drift that pin exists to catch.
|
|
419
|
+
*/
|
|
420
|
+
dropUnmanaged?: boolean;
|
|
404
421
|
}
|
|
405
422
|
export type AmbiguousChange = {
|
|
406
423
|
kind: "possible-column-rename";
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAO7C,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,eAAe,EAAE,CAAC;IAC1B,8EAA8E;IAC9E,KAAK,EAAE,cAAc,EAAE,CAAC;IACxB;;;OAGG;IACH,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB;AAED,MAAM,WAAW,YAAY;IAC3B,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,gBAAgB,EAAE,CAAC;IAC5B,OAAO,EAAE,eAAe,EAAE,CAAC;IAC3B,WAAW,EAAE,YAAY,EAAE,CAAC;IAC5B,MAAM,EAAE,eAAe,EAAE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AAM,MAAM,eAAe,GACvB;IACE,IAAI,EAAE,wBAAwB,CAAC;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC;IACzC,EAAE,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC;CACxC,GACD;IACE,IAAI,EAAE,uBAAuB,CAAC;IAC9B,IAAI,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC;IAC5C,EAAE,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC;IAC1C,aAAa,EAAE,MAAM,CAAC;CACvB,CAAC;AAEN,MAAM,MAAM,mBAAmB,GAAG,QAAQ,GAAG,UAAU,GAAG,OAAO,CAAC;AAElE,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,EAAE,eAAe,KAAK,OAAO,CAAC,mBAAmB,CAAC,CAAC;AAErF,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,iGAAiG;IACjG,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAMD,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb;;;;;;OAMG;IACH,eAAe,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;CACtC;AAED,MAAM,MAAM,OAAO,GAAG,UAAU,GAAG,QAAQ,GAAG,IAAI,CAAC"}
|
package/dist/unmanaged.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unmanaged.d.ts","sourceRoot":"","sources":["../src/unmanaged.ts"],"names":[],"mappings":"AASA,OAAO,
|
|
1
|
+
{"version":3,"file":"unmanaged.d.ts","sourceRoot":"","sources":["../src/unmanaged.ts"],"names":[],"mappings":"AASA,OAAO,EAIL,KAAK,QAAQ,EACd,MAAM,0BAA0B,CAAC;AAGlC;;;;;;;;;;;;;GAaG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,QAAQ,GAAG,MAAM,EAAE,CAa9D"}
|
package/dist/unmanaged.js
CHANGED
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
// buildProjectionViews skips an @unmanaged view), so no create is proposed. This set is
|
|
7
7
|
// the ACT-side half: threaded into `diff`, it excludes these names from the introspected
|
|
8
8
|
// ACTUAL side so a declared-external object produces SILENCE, not a policy-gated drop.
|
|
9
|
-
import { isMetaSource, resolveTableSchema,
|
|
9
|
+
import { isMetaSource, resolveTableSchema, TYPE_OBJECT, } from "@metaobjectsdev/metadata";
|
|
10
|
+
import { qualifiedDbName } from "./qualified-name.js";
|
|
10
11
|
/**
|
|
11
12
|
* The qualified physical names (`schema.name`, schema defaulting to Postgres `public`)
|
|
12
13
|
* of every DB object declared `@unmanaged`. The format matches `tableIdentity` /
|
|
@@ -32,8 +33,7 @@ export function collectUnmanagedNames(root) {
|
|
|
32
33
|
// object, turning it back into a proposed drop.
|
|
33
34
|
if (!isMetaSource(src) || !src.isUnmanaged)
|
|
34
35
|
continue;
|
|
35
|
-
|
|
36
|
-
out.push(`${schema}.${src.physicalName}`);
|
|
36
|
+
out.push(qualifiedDbName({ name: src.physicalName, schema: resolveTableSchema(obj) }));
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
return out;
|
package/dist/unmanaged.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unmanaged.js","sourceRoot":"","sources":["../src/unmanaged.ts"],"names":[],"mappings":"AAAA,8CAA8C;AAC9C,EAAE;AACF,mFAAmF;AACnF,oFAAoF;AACpF,uFAAuF;AACvF,wFAAwF;AACxF,yFAAyF;AACzF,uFAAuF;AAEvF,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,
|
|
1
|
+
{"version":3,"file":"unmanaged.js","sourceRoot":"","sources":["../src/unmanaged.ts"],"names":[],"mappings":"AAAA,8CAA8C;AAC9C,EAAE;AACF,mFAAmF;AACnF,oFAAoF;AACpF,uFAAuF;AACvF,wFAAwF;AACxF,yFAAyF;AACzF,uFAAuF;AAEvF,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,WAAW,GAEZ,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,qBAAqB,CAAC,IAAc;IAClD,MAAM,GAAG,GAAa,EAAE,CAAC;IACzB,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,QAAQ,EAAE,EAAE,CAAC;QAClC,IAAI,GAAG,CAAC,IAAI,KAAK,WAAW;YAAE,SAAS;QACvC,KAAK,MAAM,GAAG,IAAI,GAAG,CAAC,WAAW,EAAE,EAAE,CAAC;YACpC,8EAA8E;YAC9E,2EAA2E;YAC3E,gDAAgD;YAChD,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,WAAW;gBAAE,SAAS;YACrD,GAAG,CAAC,IAAI,CAAC,eAAe,CAAC,EAAE,IAAI,EAAE,GAAG,CAAC,YAAY,EAAE,MAAM,EAAE,kBAAkB,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;QACzF,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Kysely } from "kysely";
|
|
2
|
+
export interface ReplayEngine {
|
|
3
|
+
/** An empty database. The caller owns applying migrations into it. */
|
|
4
|
+
db: Kysely<Record<string, unknown>>;
|
|
5
|
+
/** Release the engine. Safe to call more than once. */
|
|
6
|
+
dispose: () => Promise<void>;
|
|
7
|
+
}
|
|
8
|
+
/** Open an empty in-process database of the given dialect. */
|
|
9
|
+
export declare function openReplayEngine(dialect: "postgres" | "sqlite"): Promise<ReplayEngine>;
|
|
10
|
+
//# sourceMappingURL=replay-engine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"replay-engine.d.ts","sourceRoot":"","sources":["../../src/verify/replay-engine.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAKhC,MAAM,WAAW,YAAY;IAC3B,sEAAsE;IACtE,EAAE,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACpC,uDAAuD;IACvD,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9B;AAED,8DAA8D;AAC9D,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,UAAU,GAAG,QAAQ,GAC7B,OAAO,CAAC,YAAY,CAAC,CAEvB"}
|