@vantage-ui/client 0.5.0 → 0.5.2

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/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.5.2 — 2026-10-25
4
+
5
+ - `vantage-client generate` leaves `--out` untouched when the content would be the same, and logs `unchanged <out> (schema <hash>)`.
6
+
7
+ ## 0.5.1 — 2026-10-25
8
+
9
+ - MockServer traverses `via` over a numeric foreign key (it compared the number with the wire's string id and found nothing).
10
+
3
11
  ## 0.5.0 — 2026-10-18
4
12
 
5
13
  - `db.reconnect()` works from any state: it closes an open socket and connects again with `token` called afresh, so a sign-in over an open anonymous connection switches to the new token. Breaking: before, it did nothing unless the connection was `refused`.
@@ -1,5 +1,5 @@
1
1
  // `vantage-client generate --from <url-or-file> --out <file>`.
2
- import { mkdir, writeFile } from "node:fs/promises";
2
+ import { mkdir, readFile, writeFile } from "node:fs/promises";
3
3
  import { dirname } from "node:path";
4
4
  import { emit } from "./emit.js";
5
5
  import { loadSchema } from "./fetch.js";
@@ -20,8 +20,8 @@ export async function main(args, log = console.log, fail = console.error) {
20
20
  return 1;
21
21
  }
22
22
  const schema = await loadSchema(from);
23
- await write(out, emit(schema, from));
24
- log(`wrote ${out} (schema ${schema.hash})`);
23
+ const wrote = await write(out, emit(schema, from));
24
+ log(`${wrote ? "wrote" : "unchanged"} ${out} (schema ${schema.hash})`);
25
25
  return 0;
26
26
  }
27
27
  catch (e) {
@@ -41,11 +41,23 @@ function option(args, name) {
41
41
  throw new GenerateError(`${name} needs a value`);
42
42
  return value;
43
43
  }
44
- /** Write `text` to `path`, creating its directory when missing. */
44
+ /**
45
+ * Write `text` to `path`, creating its directory when missing; false when the
46
+ * file already holds `text`. Leaving it alone keeps its mtime, so a watcher
47
+ * downstream (Vite) doesn't rebuild for the same output.
48
+ */
45
49
  async function write(path, text) {
50
+ try {
51
+ if ((await readFile(path, "utf8")) === text)
52
+ return false;
53
+ }
54
+ catch {
55
+ // Missing or unreadable: write it.
56
+ }
46
57
  try {
47
58
  await mkdir(dirname(path), { recursive: true });
48
59
  await writeFile(path, text);
60
+ return true;
49
61
  }
50
62
  catch (e) {
51
63
  const code = e.code ?? (e instanceof Error ? e.message : String(e));
@@ -6,7 +6,7 @@ export function query(schema, rows, spec) {
6
6
  rows = rows.filter((r) => matches(r[w[0]], w));
7
7
  if (spec.via) {
8
8
  const fk = schema.tables[spec.via.table]?.hasMany[spec.via.ref]?.foreignKey;
9
- rows = rows.filter((r) => fk && r[fk] === spec.via.id);
9
+ rows = rows.filter((r) => fk && r[fk] != null && String(r[fk]) === spec.via.id);
10
10
  }
11
11
  if (spec.search) {
12
12
  const q = spec.search.toLowerCase();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vantage-ui/client",
3
- "version": "0.5.0",
3
+ "version": "0.5.2",
4
4
  "description": "A vantage-ui project as a typed, live object graph: lazy references and collections, optimistic edits, server-side actions, React bindings.",
5
5
  "keywords": ["vantage", "vantage-ui", "websocket", "realtime", "react", "codegen"],
6
6
  "homepage": "https://vantage-ui.com",