@substrat-run/cli 0.37.1 → 0.37.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.
@@ -1,24 +1,3 @@
1
- /**
2
- * FK-safe ordering for scope dumps.
3
- *
4
- * A dump's `tables` array carries no ordering guarantee — the server export sorts
5
- * by table NAME, and `readDump` enumerates `sqlite_master` in creation order. Neither
6
- * says anything about foreign keys: a child table (`crm_bank_accounts`) can precede
7
- * its parent (`crm_vendors`), and a loader that inserts in array order then trips
8
- * `FOREIGN KEY constraint failed` on the child's first row.
9
- *
10
- * The adapters defer FK checks to a transaction commit (their "suspenders"), but not
11
- * every loader does — `writeSqlite` below inserts row-by-row with no deferral, and an
12
- * older deployed control plane predates the deferral fix. So we make the dump FK-safe
13
- * BY CONSTRUCTION here (the "belt"): order every table after the tables it references,
14
- * so parents insert before children whatever the loader does.
15
- *
16
- * Deferral still covers what a total order cannot express — FK cycles and
17
- * self-references — so a cycle isn't an error here: we break it deterministically and
18
- * lean on the loader's deferral for the within-cycle rows.
19
- */
20
- /** Table names referenced by this table's DDL (`... REFERENCES <name> ...`). */
21
- export declare function referencedTables(ddl: string): string[];
22
1
  /**
23
2
  * Order tables so every FK target precedes the table referencing it. Stable
24
3
  * (independent tables keep their input order), total, and cycle-tolerant.
@@ -1 +1 @@
1
- {"version":3,"file":"dump-order.d.ts","sourceRoot":"","sources":["../src/dump-order.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,gFAAgF;AAChF,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,CAUtD;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,CAAC,SAAS;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,EAAE,MAAM,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,CAmClG"}
1
+ {"version":3,"file":"dump-order.d.ts","sourceRoot":"","sources":["../src/dump-order.ts"],"names":[],"mappings":"AAuBA;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,CAAC,SAAS;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,EAAE,MAAM,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,CAmClG"}
@@ -17,18 +17,9 @@
17
17
  * self-references — so a cycle isn't an error here: we break it deterministically and
18
18
  * lean on the loader's deferral for the within-cycle rows.
19
19
  */
20
- /** Table names referenced by this table's DDL (`... REFERENCES <name> ...`). */
21
- export function referencedTables(ddl) {
22
- // SQLite identifiers after REFERENCES may be bare or quoted with " ` [] or '.
23
- const re = /\bREFERENCES\s+(?:"([^"]+)"|`([^`]+)`|\[([^\]]+)\]|'([^']+)'|([A-Za-z_][\w$]*))/gi;
24
- const out = [];
25
- for (let m = re.exec(ddl); m; m = re.exec(ddl)) {
26
- // Exactly one alternation group captures the identifier; the last is a bare word,
27
- // so the coalesced result is always a string (the `!` satisfies the checker).
28
- out.push((m[1] ?? m[2] ?? m[3] ?? m[4] ?? m[5]));
29
- }
30
- return out;
31
- }
20
+ // `REFERENCES` is read with the dump checks' own grammar, which skips comments and string
21
+ // literals (a regex here did not).
22
+ import { referencedTables } from '@substrat-run/contracts';
32
23
  /**
33
24
  * Order tables so every FK target precedes the table referencing it. Stable
34
25
  * (independent tables keep their input order), total, and cycle-tolerant.
@@ -1 +1 @@
1
- {"version":3,"file":"dump-order.js","sourceRoot":"","sources":["../src/dump-order.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,gFAAgF;AAChF,MAAM,UAAU,gBAAgB,CAAC,GAAW;IAC1C,8EAA8E;IAC9E,MAAM,EAAE,GAAG,mFAAmF,CAAC;IAC/F,MAAM,GAAG,GAAa,EAAE,CAAC;IACzB,KAAK,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC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ChB,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QACtB,CAAC;IACH,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
package/dist/scope.js CHANGED
@@ -145,7 +145,7 @@ async function readDump(file) {
145
145
  try {
146
146
  const tables = [];
147
147
  const rows = db
148
- .prepare(`SELECT name, sql FROM sqlite_master WHERE type = 'table' AND name NOT LIKE 'sqlite_%'`)
148
+ .prepare(`SELECT name, sql FROM sqlite_master WHERE type = 'table' AND name NOT GLOB 'sqlite_*'`)
149
149
  .all();
150
150
  for (const t of rows) {
151
151
  // `sqlite_master` is data in the file we were handed, so its names are as
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@substrat-run/cli",
3
- "version": "0.37.1",
3
+ "version": "0.37.3",
4
4
  "description": "The substrat CLI — authenticated deploy tooling: push a vertical to the platform, manage its versions and channels",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -29,9 +29,9 @@
29
29
  },
30
30
  "dependencies": {
31
31
  "esbuild": "^0.28.2",
32
- "@substrat-run/contracts": "^0.127.0",
33
- "@substrat-run/model-view": "^0.2.29",
34
- "@substrat-run/boundary-lint": "^0.6.0"
32
+ "@substrat-run/boundary-lint": "^0.6.0",
33
+ "@substrat-run/model-view": "^0.2.31",
34
+ "@substrat-run/contracts": "^0.129.0"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@types/node": "^22.20.4",