@ubercode/channelvault 0.2.0 → 0.2.1
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 +13 -0
- package/README.md +6 -5
- package/dist/cli.js +54 -5
- package/dist/cli.js.map +1 -1
- package/dist/index.js +6 -1
- package/dist/index.js.map +1 -1
- package/docs/roadmap.md +7 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to `@ubercode/channelvault` are documented here. The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and the version follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
4
4
|
|
|
5
|
+
## [0.2.1] — 2026-09-29
|
|
6
|
+
|
|
7
|
+
### Fixed
|
|
8
|
+
|
|
9
|
+
- `diff` compares content: revision numbers and timestamps, which Mirth bumps on any save or restore, no longer count as differences; `diff --json` lists them as `staleRevisions`.
|
|
10
|
+
- Channels whose names collide once made into directory names (`Lab Feed`, `LAB FEED`) keep their directories when the server lists them in another order, as it does after a restore.
|
|
11
|
+
- `push` no longer refuses to update one of two channels that already share a name on the server (Mirth allows `Lab Feed` beside `LAB FEED`); only a new name or a rename is checked.
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
|
|
15
|
+
- Tests on a production-shaped synthetic mesh (on real Mirth 4.5.2 too) and on 36 public exports from Mirth 3.0 to OIE 4.6.
|
|
16
|
+
|
|
5
17
|
## [0.2.0] — 2026-09-29
|
|
6
18
|
|
|
7
19
|
### Added
|
|
@@ -23,5 +35,6 @@ First release. Tested against Mirth Connect 4.5.2; the offline round trip is als
|
|
|
23
35
|
- `backup` / `restore`: the server's own configuration XML saved as `.backup/<server>-<UTC time>.xml`, identified by Mirth's server ID, restored with a preview, an undo backup and a version check. `push` backs up first unless `--no-backup`.
|
|
24
36
|
- `diff` exits 0 when the tree matches the server, 1 when it differs, 2 on error.
|
|
25
37
|
|
|
38
|
+
[0.2.1]: https://github.com/MichaelLeeHobbs/channelvault/releases/tag/v0.2.1
|
|
26
39
|
[0.2.0]: https://github.com/MichaelLeeHobbs/channelvault/releases/tag/v0.2.0
|
|
27
40
|
[0.1.0]: https://github.com/MichaelLeeHobbs/channelvault/releases/tag/v0.1.0
|
package/README.md
CHANGED
|
@@ -35,7 +35,8 @@ The exploded tree is a projection, not a re-derivation: config is stored verbati
|
|
|
35
35
|
- `test/xml.test.ts`, `test/xml.robustness.test.ts`: XML parse/build fixed point, entity and whitespace handling, document order, unexpected XML
|
|
36
36
|
- `test/explode.test.ts`, `test/explode.paths.test.ts`: `implode(explode(c))` deep-equals `c`, byte-identical sidecars, file naming
|
|
37
37
|
- `test/e2e.test.ts`: the whole pipeline on a Mirth-exported fixture (`test/fixtures`, synthetic; `test/fixtures.guard.test.ts` rejects real exports)
|
|
38
|
-
- `test/third-party-fixtures.test.ts`: the same pipeline on
|
|
38
|
+
- `test/third-party-fixtures.test.ts` and `test/third-party-corpus.test.ts`: the same pipeline on public exports from Mirth 3.0 to OIE 4.6 (mirthsync, Open Integration Engine, NextGen's FHIR examples and six other projects; `test/fixtures/third-party/<source>/`, each pinned by hash in its `SOURCE.md` with its license)
|
|
39
|
+
- `test/mesh.test.ts`: a synthetic, production-shaped routing mesh (`test/fixtures/serverConfiguration.mesh.xml`: 26 channels, an 18-destination hub, a 10,000-line code template, attachment handlers), generated by `scripts/fixtures/generate-mesh.ts` and exported by Mirth after every channel deployed (`node scripts/fixtures/build-mesh.mjs`)
|
|
39
40
|
|
|
40
41
|
## Layout produced by `explode` / `pull`
|
|
41
42
|
|
|
@@ -74,12 +75,12 @@ channelvault restore [file] # backup -> live server (default: ne
|
|
|
74
75
|
|
|
75
76
|
`channelvault <command> --help` lists the flags. Server connection comes from flags or `MIRTH_HOST`, `MIRTH_PORT`, `MIRTH_USER`, `MIRTH_PASS`; prefer the env var over `--pass`, which shows up in process listings. Mirth's default certificate is self-signed; `--insecure` accepts it by turning verification off.
|
|
76
77
|
|
|
77
|
-
`diff` exits 0 when the tree matches the server, 1 when they differ, and 2 on any error (including a bad flag), so a scheduled drift check can tell drift from an outage.
|
|
78
|
+
`diff` exits 0 when the tree matches the server, 1 when they differ, and 2 on any error (including a bad flag), so a scheduled drift check can tell drift from an outage. It compares content: Mirth bumps revision numbers and timestamps on any save (even an unchanged one in the Administrator) and on a restore, so those are reported as a note ("pull to update the tree's baseline") and don't count as differences.
|
|
78
79
|
|
|
79
80
|
For scripts, CI and AI agents, `status`, `diff` and `push --plan-only` take `--json` and print one JSON document on stdout; errors still go to stderr with the usual exit code.
|
|
80
81
|
|
|
81
82
|
- `status --json`: `{ root, source, pulledAt, engineVersion, counts }`.
|
|
82
|
-
- `diff --json`: `{ clean, files: [{ path, change }], secretDrift, notes, patch }`, where `change` is `modified`, `only-in-tree` or `only-on-server` and `patch` is the redacted unified diff.
|
|
83
|
+
- `diff --json`: `{ clean, files: [{ path, change }], secretDrift, staleRevisions, notes, patch }`, where `change` is `modified`, `only-in-tree` or `only-on-server` and `patch` is the redacted unified diff.
|
|
83
84
|
- `push --plan-only --json`: `{ target, mode, changes: [{ kind, op, id, label }], conflicts, serverOnly, notPushed, wouldStop }` (plus `redeploy` and `notRedeployed` with `--deploy`). `wouldStop` lists what would refuse a real push with the same flags, such as unconfirmed deletions or conflicts.
|
|
84
85
|
|
|
85
86
|
`pull` and `explode` replace `server/`, `channels/`, `codeTemplates/` and `channelGroups/` in `<dir>`, so they refuse a directory that has any of those but no `channelvault.json`, an unreadable `channelvault.json`, or a `--dotenv` file inside one of those directories. All of this is checked before anything is written.
|
|
@@ -156,7 +157,7 @@ An agent can safely edit a tree and check its work. Pushing, restoring and anyth
|
|
|
156
157
|
`mirth/` is a channelvault tree of our Mirth Connect server. Channel scripts are the `.js` files under `mirth/channels/<channel>/`, settings are in `channel.json`, and code templates are under `mirth/codeTemplates/<library>/`.
|
|
157
158
|
|
|
158
159
|
- Edit the `.js` and `.json` files; leave `id`, `revision`, `channelvault.json` and the `{"@file": …}` / `{"@ref": …}` markers alone. A new channel or template needs its own new UUID for `id`; a copied directory keeps the old one.
|
|
159
|
-
- Mirth runs these scripts in Rhino, not Node: no
|
|
160
|
+
- Mirth runs these scripts in Rhino, not Node: no `async`/`await`, optional chaining (`?.`), classes, `require`, `import` or shorthand object properties (`{ status }`; write `{ status: status }`). `let`, `const` and arrow functions work.
|
|
160
161
|
- `{{env:NAME}}` is a placeholder for a secret kept outside git. Never replace one with a real value, and never read, print or copy `.env`, `.secrets/` or `.backup/`.
|
|
161
162
|
- Check your work with `channelvault diff mirth --json` (exit 0: matches the server, 1: differs) and `channelvault push mirth --plan-only --json`, which shows what a push would change and `wouldStop` reasons.
|
|
162
163
|
- Do not run `channelvault push` (other than with `--plan-only`), `restore` or `pull`, and never pass `--force`, `--allow-deletes` or `--yes`. Summarise the plan and let a person push.
|
|
@@ -172,7 +173,7 @@ MIRTH_HOST=localhost MIRTH_PORT=8443 MIRTH_USER=admin MIRTH_PASS=admin \
|
|
|
172
173
|
|
|
173
174
|
To try channelvault on a **real** configuration, use `docker compose -f docker-compose.isolated.yml up -d` instead: the same server with no outbound network (a deployed channel cannot reach anything), startup deploy off, and port 8443 on localhost only. `down` deletes it and everything in it.
|
|
174
175
|
|
|
175
|
-
`pnpm test:integration` creates two disposable Mirth 4.5.2 servers on random localhost ports, imports
|
|
176
|
+
`pnpm test:integration` creates two disposable Mirth 4.5.2 servers on random localhost ports and runs two suites. The mesh suite loads the production-shaped mesh and checks that a pull converges (nothing to push, no diff) before and after scoped pushes, a redeploy and a restore. The promotion suite imports the synthetic fixture and drives the CLI through a promotion with different destination credentials and independent revision history. It verifies conflict refusal, an explicit override, preserved tags and unrelated channels, and a clean repeat push. It removes its containers and network on success or failure. Docker is required; unavailable servers fail the command.
|
|
176
177
|
|
|
177
178
|
`test/integration/live.test.ts` is an optional additional suite for a disposable server you manage yourself. It runs when `MIRTH_HOST` is set; connection failures fail the suite. It writes the server configuration, so do not point it at a production or shared server.
|
|
178
179
|
|
package/dist/cli.js
CHANGED
|
@@ -398,12 +398,17 @@ async function splitCollection(parent, containerKey, elementKey, root, serverDir
|
|
|
398
398
|
const wasArray = Array.isArray(raw);
|
|
399
399
|
const elements = asArray(raw);
|
|
400
400
|
const refs = [];
|
|
401
|
+
const byName = (el) => `${slug(el["name"]).toLowerCase()}\0${String(el["id"] ?? "")}`;
|
|
402
|
+
const slugs = /* @__PURE__ */ new Map();
|
|
403
|
+
for (const el of elements.filter(isPlainObject).sort((a, b) => byName(a) < byName(b) ? -1 : byName(a) > byName(b) ? 1 : 0)) {
|
|
404
|
+
slugs.set(el, uniqueSlug(slug(el["name"]), usedSlugs));
|
|
405
|
+
}
|
|
401
406
|
for (const el of elements) {
|
|
402
407
|
if (!isPlainObject(el)) {
|
|
403
408
|
refs.push(el);
|
|
404
409
|
continue;
|
|
405
410
|
}
|
|
406
|
-
const slugName =
|
|
411
|
+
const slugName = slugs.get(el);
|
|
407
412
|
const { jsonFile, resourceDir } = targetFor(el["name"], slugName);
|
|
408
413
|
const transformed = await explodeResource(el, resourceDir);
|
|
409
414
|
await writeJson(jsonFile, transformed);
|
|
@@ -1669,6 +1674,44 @@ function stripVolatile(o) {
|
|
|
1669
1674
|
}
|
|
1670
1675
|
return out;
|
|
1671
1676
|
}
|
|
1677
|
+
var groupsOf = (c) => isObj(c["channelGroups"]) ? list(c["channelGroups"]["channelGroup"]) : [];
|
|
1678
|
+
function withoutVolatile(c) {
|
|
1679
|
+
const out = structuredClone(c);
|
|
1680
|
+
const strip = (o) => {
|
|
1681
|
+
delete o["revision"];
|
|
1682
|
+
delete o["lastModified"];
|
|
1683
|
+
const md = isObj(o["exportData"]) ? o["exportData"]["metadata"] : void 0;
|
|
1684
|
+
if (isObj(md)) {
|
|
1685
|
+
delete md["lastModified"];
|
|
1686
|
+
delete md["userId"];
|
|
1687
|
+
}
|
|
1688
|
+
};
|
|
1689
|
+
for (const ch of channelsOf(out)) strip(ch);
|
|
1690
|
+
for (const lib of librariesOf(out)) {
|
|
1691
|
+
strip(lib);
|
|
1692
|
+
for (const t of templatesOf2(lib)) strip(t);
|
|
1693
|
+
}
|
|
1694
|
+
for (const g of groupsOf(out)) {
|
|
1695
|
+
strip(g);
|
|
1696
|
+
for (const member of isObj(g["channels"]) ? list(g["channels"]["channel"]) : []) delete member["revision"];
|
|
1697
|
+
}
|
|
1698
|
+
return out;
|
|
1699
|
+
}
|
|
1700
|
+
function newerOnServer(tree, server) {
|
|
1701
|
+
const out = [];
|
|
1702
|
+
const compare = (kind, local, remote) => {
|
|
1703
|
+
const mine = new Map(local.map((o) => [idOf(o), revisionOf(o)]));
|
|
1704
|
+
for (const r of remote) {
|
|
1705
|
+
const rev = mine.get(idOf(r));
|
|
1706
|
+
if (rev !== void 0 && revisionOf(r) > rev) out.push(`${kind} "${nameOf(r)}"`);
|
|
1707
|
+
}
|
|
1708
|
+
};
|
|
1709
|
+
compare("channel", channelsOf(tree), channelsOf(server));
|
|
1710
|
+
compare("library", librariesOf(tree), librariesOf(server));
|
|
1711
|
+
compare("code template", librariesOf(tree).flatMap(templatesOf2), librariesOf(server).flatMap(templatesOf2));
|
|
1712
|
+
compare("channel group", groupsOf(tree), groupsOf(server));
|
|
1713
|
+
return out;
|
|
1714
|
+
}
|
|
1672
1715
|
function libraryShape(lib) {
|
|
1673
1716
|
const out = stripVolatile(lib);
|
|
1674
1717
|
out["codeTemplates"] = templatesOf2(lib).map(idOf);
|
|
@@ -1823,10 +1866,12 @@ function planPush(local, remote, scope = {}, known, opts = {}) {
|
|
|
1823
1866
|
for (const r of channelsOf(remote)) if (!deletedChannels.has(idOf(r))) effective.set(idOf(r), r);
|
|
1824
1867
|
for (const l of channelsOf(local)) if (writtenChannels.has(idOf(l))) effective.set(idOf(l), l);
|
|
1825
1868
|
const nameKey = (c) => nameOf(c).toLowerCase();
|
|
1869
|
+
const remoteNames = new Map(channelsOf(remote).map((c) => [idOf(c), nameKey(c)]));
|
|
1870
|
+
const introducesName = (c) => writtenChannels.has(idOf(c)) && remoteNames.get(idOf(c)) !== nameKey(c);
|
|
1826
1871
|
const during = opts.wholeReplace ? [] : channelsOf(remote);
|
|
1827
1872
|
const holders = [...new Map([...during, ...effective.values()].map((c) => [`${idOf(c)}
|
|
1828
1873
|
${nameKey(c)}`, c])).values()];
|
|
1829
|
-
const clashes = duplicates(holders, nameKey).filter(([, g]) => g.some(
|
|
1874
|
+
const clashes = duplicates(holders, nameKey).filter(([, g]) => g.some(introducesName));
|
|
1830
1875
|
if (clashes.length > 0) {
|
|
1831
1876
|
throw new Error(
|
|
1832
1877
|
`the push would save a channel under a name another channel holds:
|
|
@@ -3038,8 +3083,12 @@ addJsonFlag(addEnvFlag(addConnectionFlags(
|
|
|
3038
3083
|
...notes
|
|
3039
3084
|
];
|
|
3040
3085
|
const allow = await readAllow(root);
|
|
3041
|
-
const
|
|
3042
|
-
|
|
3086
|
+
const staleRevisions = newerOnServer(tree, templatedRemote);
|
|
3087
|
+
if (staleRevisions.length > 0) {
|
|
3088
|
+
messages.push(`${staleRevisions.length} resource(s) have a newer revision on the server; pull to update the tree's baseline`);
|
|
3089
|
+
}
|
|
3090
|
+
const treeView = scanSecrets(redactKnownSecrets(normalizeEolDeep(withoutVolatile(tree))), { mode: "redact", allow });
|
|
3091
|
+
const serverView = scanSecrets(redactKnownSecrets(normalizeEolDeep(withoutVolatile(templatedRemote))), { mode: "redact", allow });
|
|
3043
3092
|
if (treeView.findings.length > 0) {
|
|
3044
3093
|
messages.push(`the tree holds ${treeView.findings.length} unextracted secret(s), redacted below; pull --extract-secrets`);
|
|
3045
3094
|
}
|
|
@@ -3077,7 +3126,7 @@ addJsonFlag(addEnvFlag(addConnectionFlags(
|
|
|
3077
3126
|
if (!clean) process.exitCode = 1;
|
|
3078
3127
|
if (flags.json) {
|
|
3079
3128
|
const files = await changedFiles(path5.join(tmp, "tree"), path5.join(tmp, "server"));
|
|
3080
|
-
writeJson2({ clean, files, secretDrift, notes: messages, patch: out });
|
|
3129
|
+
writeJson2({ clean, files, secretDrift, staleRevisions, notes: messages, patch: out });
|
|
3081
3130
|
} else if (clean) {
|
|
3082
3131
|
process.stdout.write("no differences \u2014 working tree matches the server.\n");
|
|
3083
3132
|
} else {
|