@crewhaus/migration-engine 0.1.8 → 0.2.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/index.d.ts CHANGED
@@ -37,6 +37,13 @@ export declare class MigrationEngine {
37
37
  migrate(spec: SpecObject, toVersion: number): SpecObject;
38
38
  /** Diagnostic: list registered migration keys. */
39
39
  list(): ReadonlyArray<string>;
40
+ /**
41
+ * #43 — the highest version this engine can migrate TO, i.e. the current
42
+ * spec-schema version. It is the max `to` across every registered migration
43
+ * (`0` when none are registered — nothing to upgrade to). `crewhaus upgrade`
44
+ * uses this as the drift target so the CLI never hardcodes "1".
45
+ */
46
+ latestVersion(): number;
40
47
  /** Reset the registry (tests). */
41
48
  clear(): void;
42
49
  }
package/dist/index.js CHANGED
@@ -74,6 +74,20 @@ export class MigrationEngine {
74
74
  list() {
75
75
  return [...this.migrations.keys()].sort();
76
76
  }
77
+ /**
78
+ * #43 — the highest version this engine can migrate TO, i.e. the current
79
+ * spec-schema version. It is the max `to` across every registered migration
80
+ * (`0` when none are registered — nothing to upgrade to). `crewhaus upgrade`
81
+ * uses this as the drift target so the CLI never hardcodes "1".
82
+ */
83
+ latestVersion() {
84
+ let latest = 0;
85
+ for (const m of this.migrations.values()) {
86
+ if (m.to > latest)
87
+ latest = m.to;
88
+ }
89
+ return latest;
90
+ }
77
91
  /** Reset the registry (tests). */
78
92
  clear() {
79
93
  this.migrations.clear();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crewhaus/migration-engine",
3
- "version": "0.1.8",
3
+ "version": "0.2.0",
4
4
  "type": "module",
5
5
  "description": "IR version migrations: register up/down chains; migrate(spec, fromVersion, toVersion) walks the chain",
6
6
  "main": "dist/index.js",
@@ -15,7 +15,7 @@
15
15
  "test": "bun test src"
16
16
  },
17
17
  "dependencies": {
18
- "@crewhaus/errors": "0.1.8"
18
+ "@crewhaus/errors": "0.2.0"
19
19
  },
20
20
  "license": "Apache-2.0",
21
21
  "author": {