@metaobjectsdev/migrate-ts 1.0.1 → 1.0.3

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.
Files changed (47) hide show
  1. package/dist/diff/index.d.ts +2 -1
  2. package/dist/diff/index.d.ts.map +1 -1
  3. package/dist/diff/index.js +18 -4
  4. package/dist/diff/index.js.map +1 -1
  5. package/dist/diff/status.d.ts.map +1 -1
  6. package/dist/diff/status.js +25 -13
  7. package/dist/diff/status.js.map +1 -1
  8. package/dist/drift/drift.d.ts +19 -0
  9. package/dist/drift/drift.d.ts.map +1 -1
  10. package/dist/drift/drift.js +2 -1
  11. package/dist/drift/drift.js.map +1 -1
  12. package/dist/emit/postgres.d.ts.map +1 -1
  13. package/dist/emit/postgres.js +130 -4
  14. package/dist/emit/postgres.js.map +1 -1
  15. package/dist/errors.d.ts +8 -1
  16. package/dist/errors.d.ts.map +1 -1
  17. package/dist/errors.js +24 -9
  18. package/dist/errors.js.map +1 -1
  19. package/dist/index.d.ts +1 -1
  20. package/dist/index.d.ts.map +1 -1
  21. package/dist/index.js +1 -1
  22. package/dist/index.js.map +1 -1
  23. package/dist/pg-identity-default.d.ts +6 -0
  24. package/dist/pg-identity-default.d.ts.map +1 -1
  25. package/dist/pg-identity-default.js +7 -0
  26. package/dist/pg-identity-default.js.map +1 -1
  27. package/dist/scope.d.ts +36 -8
  28. package/dist/scope.d.ts.map +1 -1
  29. package/dist/scope.js +71 -19
  30. package/dist/scope.js.map +1 -1
  31. package/dist/snapshot/plan.d.ts +14 -1
  32. package/dist/snapshot/plan.d.ts.map +1 -1
  33. package/dist/snapshot/plan.js +8 -2
  34. package/dist/snapshot/plan.js.map +1 -1
  35. package/dist/types.d.ts +8 -0
  36. package/dist/types.d.ts.map +1 -1
  37. package/package.json +2 -2
  38. package/src/diff/index.ts +15 -4
  39. package/src/diff/status.ts +28 -15
  40. package/src/drift/drift.ts +21 -0
  41. package/src/emit/postgres.ts +158 -4
  42. package/src/errors.ts +26 -10
  43. package/src/index.ts +1 -1
  44. package/src/pg-identity-default.ts +10 -0
  45. package/src/scope.ts +93 -18
  46. package/src/snapshot/plan.ts +22 -2
  47. package/src/types.ts +9 -1
@@ -22,6 +22,15 @@ export interface PlanOfflineArgs extends Pick<DiffArgs, "allow" | "onAmbiguous"
22
22
  * loaded (unchanged behavior).
23
23
  */
24
24
  inScope?: ObjectScopePredicate;
25
+ /**
26
+ * FR-023 — objects a DEPENDENCY owns. Imported metadata is loaded so this project's
27
+ * own model can resolve against it and is governed by nobody here unless `inScope`
28
+ * admits it, so such an object leaves BOTH sides of the diff and, unlike an
29
+ * `inScope` exclusion, takes its database schema out of the run's scope with it
30
+ * (migrate-ts `scope.ts` header). Omit for a project with no dependencies
31
+ * (unchanged behavior).
32
+ */
33
+ imported?: ObjectScopePredicate;
25
34
  }
26
35
 
27
36
  export interface PlanOfflineResult {
@@ -41,8 +50,12 @@ export interface PlanOfflineResult {
41
50
  * only for what it governs.
42
51
  */
43
52
  expected: SchemaSnapshot;
44
- /** Qualified physical names excluded by `inScope`; empty when no scope was given. */
53
+ /** Qualified physical names excluded by `inScope` OR by `imported`; empty when
54
+ * neither was given. */
45
55
  outOfScope: readonly string[];
56
+ /** The subset of `outOfScope` a dependency contributed (FR-023), so the CLI can say
57
+ * WHY those objects were excluded. `undefined` when no `imported` was given. */
58
+ importedOutOfScope: readonly string[] | undefined;
46
59
  }
47
60
 
48
61
  /**
@@ -58,6 +71,7 @@ export async function planOffline(args: PlanOfflineArgs): Promise<PlanOfflineRes
58
71
  ...(args.views !== undefined ? { views: args.views } : {}),
59
72
  }),
60
73
  args.inScope,
74
+ args.imported !== undefined ? { imported: args.imported } : undefined,
61
75
  );
62
76
  // The DIFF runs against the narrowed side; the SNAPSHOT keeps what this run
63
77
  // excluded. Committing the narrowed schema would delete every out-of-scope entry
@@ -82,7 +96,13 @@ export async function planOffline(args: PlanOfflineArgs): Promise<PlanOfflineRes
82
96
  ...(args.onAmbiguous ? { onAmbiguous: args.onAmbiguous } : {}),
83
97
  ...(args.ignoreTables ? { ignoreTables: args.ignoreTables } : {}),
84
98
  });
85
- return { diff: result, nextSnapshot, expected: scoped.snapshot, outOfScope: scoped.outOfScope };
99
+ return {
100
+ diff: result,
101
+ nextSnapshot,
102
+ expected: scoped.snapshot,
103
+ outOfScope: scoped.outOfScope,
104
+ importedOutOfScope: scoped.importedOutOfScope,
105
+ };
86
106
  }
87
107
 
88
108
  /** Seed an initial reference snapshot from metadata (greenfield baseline). */
package/src/types.ts CHANGED
@@ -233,7 +233,15 @@ export type Change =
233
233
  | { kind: "drop-column"; table: string; schema?: string; column: string; restore?: ColumnDescriptor; status: ChangeStatus }
234
234
  | { kind: "rename-column"; table: string; schema?: string; from: string; to: string; status: ChangeStatus }
235
235
  | { kind: "change-column-type"; table: string; schema?: string; column: string;
236
- from: SqlType; to: SqlType; status: ChangeStatus }
236
+ from: SqlType; to: SqlType;
237
+ /** The column's live default and the default it should end with, when either exists.
238
+ * Postgres converts a default with an ASSIGNMENT cast, never through USING, so a type
239
+ * change that needs USING must drop the default first and set it after, which the
240
+ * emitter can only do knowing both. A type change CARRIES its column's default change
241
+ * rather than sitting beside a separate `change-column-default`, whose down would run
242
+ * first and set the old default on a column still holding the new type. */
243
+ fromDefault?: ColumnDefault; toDefault?: ColumnDefault;
244
+ status: ChangeStatus }
237
245
  | { kind: "change-column-nullable"; table: string; schema?: string; column: string;
238
246
  from: boolean; to: boolean; status: ChangeStatus }
239
247
  | { kind: "change-column-default"; table: string; schema?: string; column: string;