@ubercode/channelvault 0.1.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/CHANGELOG.md +18 -0
- package/LICENSE +21 -0
- package/README.md +175 -0
- package/dist/cli.js +3083 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +170 -0
- package/dist/index.js +1368 -0
- package/dist/index.js.map +1 -0
- package/docs/roadmap.md +142 -0
- package/package.json +80 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
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
|
+
|
|
5
|
+
## [0.1.0] — 2026-09-25
|
|
6
|
+
|
|
7
|
+
First release. Tested against Mirth Connect 4.5.2; the offline round trip is also tested on Mirth 3.8 and 4.0.1 exports.
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- `explode` / `implode`: a Mirth backup XML to a git-friendly tree and back, losslessly. Channel config is stored as JSON; every transformer, filter, connector and code-template script is its own `.js` file.
|
|
12
|
+
- `pull`, `push`, `diff`, `status` against a live server over its REST API.
|
|
13
|
+
- Scoped `push`: only the channels, code templates, libraries and global scripts that changed, one resource at a time, after a preview and confirmation. Conflicts with server-side edits, deletions and duplicate ids are refused unless you opt in; `--deploy` redeploys only channels that are deployed now. `--whole-server` replaces the entire configuration.
|
|
14
|
+
- Secrets: credentials and configuration-map values become `{{env:NAME}}` placeholders with their values in a git-ignored `.env`. Secrets inside values (URLs, connection strings, headers, scripts, keys, tokens) block `pull`/`explode` until they are extracted (`--extract-secrets`) or allowed.
|
|
15
|
+
- `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`.
|
|
16
|
+
- `diff` exits 0 when the tree matches the server, 1 when it differs, 2 on error.
|
|
17
|
+
|
|
18
|
+
[0.1.0]: https://github.com/MichaelLeeHobbs/channelvault/releases/tag/v0.1.0
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Michael L. Hobbs
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
# channelvault
|
|
2
|
+
|
|
3
|
+
> Git-style **pull / push / diff** for Mirth Connect (NextGen Connect, Open Integration Engine, BridgeLink).
|
|
4
|
+
|
|
5
|
+
`channelvault` explodes a Mirth server configuration into a git-friendly directory tree (channel config as JSON, each transformer, filter, connector and code-template script as its own `.js` file) and reassembles it losslessly, so Mirth changes can be edited in an IDE, reviewed as diffs and moved between servers.
|
|
6
|
+
|
|
7
|
+
Where it is going: [docs/roadmap.md](docs/roadmap.md). Changes: [CHANGELOG.md](CHANGELOG.md).
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
Node 20.18.1 or later.
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
npm install -g @ubercode/channelvault # then: channelvault --help
|
|
15
|
+
npx @ubercode/channelvault --help # or run it without installing
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## How it works
|
|
19
|
+
|
|
20
|
+
Everything centers on one in-memory representation, the **canonical config**: a plain JSON object mirroring Mirth's `serverConfiguration` document. Two adapters produce it:
|
|
21
|
+
|
|
22
|
+
| Path | Source | Module |
|
|
23
|
+
| ------------- | -------------------------------------- | ------------ |
|
|
24
|
+
| Dev / offline | Administrator *Backup Config* `.xml` | `src/xml` |
|
|
25
|
+
| Live server | `GET /server/configuration` (JSON) | `src/client` |
|
|
26
|
+
|
|
27
|
+
The explode engine (`src/explode`) projects a canonical config onto a directory tree and reverses it. Script bodies move to sidecar `.js` files, leaving `{ "@file": "..." }` in their place; split-out resources leave `{ "@ref": "..." }`.
|
|
28
|
+
|
|
29
|
+
The two adapters produce **different shapes** for the same server (XML: `@_version`, all-string values; live: `@version`, native types), and nothing converts between them yet. `push` refuses an XML-exploded tree and `implode` refuses a live-pulled one unless you pass `--force`.
|
|
30
|
+
|
|
31
|
+
### Round-trip fidelity
|
|
32
|
+
|
|
33
|
+
The exploded tree is a projection, not a re-derivation: config is stored verbatim and code is patched back at its exact location. Unknown elements, attributes, plugin step types, comments and interleaved sibling order all survive. The contract lives in the tests:
|
|
34
|
+
|
|
35
|
+
- `test/xml.test.ts`, `test/xml.robustness.test.ts`: XML parse/build fixed point, entity and whitespace handling, document order, unexpected XML
|
|
36
|
+
- `test/explode.test.ts`, `test/explode.paths.test.ts`: `implode(explode(c))` deep-equals `c`, byte-identical sidecars, file naming
|
|
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 mirthsync's Mirth 3.8, 4.0.1 and OIE 4.5.2 exports (`test/fixtures/third-party/mirthsync`, EPL-1.0, pinned by hash in its `SOURCE.md`)
|
|
39
|
+
|
|
40
|
+
## Layout produced by `explode` / `pull`
|
|
41
|
+
|
|
42
|
+
```
|
|
43
|
+
<root>/
|
|
44
|
+
channelvault.json # provenance: source, pulledAt, engine version
|
|
45
|
+
.env # secret values (git-ignored; see below)
|
|
46
|
+
server/configuration.json # everything not split out below
|
|
47
|
+
channelGroups/<group>.json
|
|
48
|
+
codeTemplates/<library>/
|
|
49
|
+
library.json
|
|
50
|
+
<template>.js
|
|
51
|
+
channels/<channel>/
|
|
52
|
+
channel.json
|
|
53
|
+
scripts/{preprocessor,postprocessor,deploy,undeploy}.js
|
|
54
|
+
source/receiver.js # JavaScript Reader body
|
|
55
|
+
source/{transformer,filter}/<n>.<step>.js
|
|
56
|
+
destinations/<dest>/writer.js # JavaScript Writer body
|
|
57
|
+
destinations/<dest>/{transformer,responseTransformer,filter}/<n>.<step>.js
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Global scripts, server settings, alerts and the configuration map stay inline in `server/configuration.json`.
|
|
61
|
+
|
|
62
|
+
## Commands
|
|
63
|
+
|
|
64
|
+
```
|
|
65
|
+
channelvault explode <backup.xml> <dir> # XML -> tree
|
|
66
|
+
channelvault implode <dir> <backup.xml> # tree -> XML
|
|
67
|
+
channelvault pull <dir> # live server -> tree
|
|
68
|
+
channelvault push <dir> # changed channels/templates -> live server
|
|
69
|
+
channelvault diff <dir> # tree vs live server
|
|
70
|
+
channelvault status <dir> # summary of a tree
|
|
71
|
+
channelvault backup # live server -> .backup/<server>-<UTC time>.xml
|
|
72
|
+
channelvault restore [file] # backup -> live server (default: newest of this server)
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
`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
|
+
`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
|
+
|
|
79
|
+
`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.
|
|
80
|
+
|
|
81
|
+
## Secrets and per-environment values
|
|
82
|
+
|
|
83
|
+
`explode` and `pull` keep the credentials they detect out of the tree. Detection is heuristic (see below), so review a first pull of a real server before committing it. Fields named like credentials (passwords, passphrases, passcodes, tokens, secrets, API/access/private keys, and DICOM's `keyPW`, `keyStorePW` and `trustStorePW`), and every configuration-map value, become `{{env:NAME}}` placeholders, and their values go to `<dir>/.env`, which is added to the tree's `.gitignore`. `push` and `implode` fill the placeholders back in and refuse to run if any are missing, naming each one.
|
|
84
|
+
|
|
85
|
+
- You can add placeholders yourself anywhere, in JSON or in a `.js` file (for example `"host": "{{env:DB_HOST}}"`). A re-pull keeps them as long as they still resolve to what the server holds.
|
|
86
|
+
- `--dotenv .env.prod` selects another environment. Variables already set in the process environment take precedence over the file, so CI can supply them directly.
|
|
87
|
+
- A server's error response can echo the credentials that were sent, so error messages leave it out and show only the HTTP status. `CHANNELVAULT_DEBUG=1` includes it, decoded from JSON or XML, with credential fields and the env file's values redacted. That redaction matches known values and field names, so a secret the server transformed some other way (for example base64) is not recognised: don't use `CHANNELVAULT_DEBUG` where output is logged or shared.
|
|
88
|
+
- If git would commit the env file (for example `--dotenv` pointing outside the tree, into a repository that doesn't ignore it), `pull` and `explode` warn.
|
|
89
|
+
- A password rotated on the server updates `.env` on the next `pull`, and `diff` reports it by name only. The previous env file is kept in the tree's `.secrets/` (git-ignored, newest 5 only) whenever a value in it changes. An extracted secret inside a script survives server-side edits to the rest of that script.
|
|
90
|
+
|
|
91
|
+
Secrets inside values are caught too: credentials in URLs and connection strings, `Authorization` headers, `createDatabaseConnection(…, 'password')` and `setPassword('…')` calls, password/key assignments in scripts (`password`, `dbPass`, `DB_PASS`, `apiKey`…), private keys, and AWS, GitHub, Slack and JWT tokens. If `pull` or `explode` finds one, it writes nothing and lists each finding by location and kind (never the value). Then either:
|
|
92
|
+
|
|
93
|
+
- rerun with `--extract-secrets`, which replaces just the secret part with a placeholder, or
|
|
94
|
+
- list a false positive in `channelvault.allow.json` (committed): `{ "ignore": [{ "location": "<as printed>", "kind": "assignment", "context": "<as printed>", "note": "why" }] }`. `context` identifies the surrounding text, so the entry stops applying if that text changes.
|
|
95
|
+
|
|
96
|
+
`diff` redacts any such secret the server holds that the tree hasn't extracted. After extraction, a known secret value (8+ characters) that still appears in plain text elsewhere, where no rule matched, is reported as a warning naming the variable and location.
|
|
97
|
+
|
|
98
|
+
## Pushing
|
|
99
|
+
|
|
100
|
+
`push` sends only what changed, one resource at a time: channels, code templates (and library membership), and global scripts. It prints the plan and asks before applying it.
|
|
101
|
+
|
|
102
|
+
```
|
|
103
|
+
channelvault push ./mirth # everything that changed
|
|
104
|
+
channelvault push ./mirth --channel "ADT Router" # just this channel (repeat --channel for more)
|
|
105
|
+
channelvault push ./mirth --library Formatting --deploy # one library, then redeploy the channels using it
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
- **Copies**: every channel, library and code template is saved by its `id`, and a copied directory keeps its source's. `push` refuses a tree where two resources share an id, and a save under a name another channel holds (case-insensitive), even one a delete or rename in the same push frees: push that delete or rename first. Give a copy a new UUID.
|
|
109
|
+
- **Deletions** (a channel directory or template you removed) need `--allow-deletes`. Something created on the server since your last pull is never treated as a deletion; `push` leaves it alone and says so.
|
|
110
|
+
- **Conflicts**: if the server's copy has a newer revision than your tree (someone saved it in the Administrator since your last pull), `push` refuses. Pull, merge in git, and push again, or pass `--force`.
|
|
111
|
+
- **`--deploy`** redeploys the channels that changed and the channels a changed code-template library is enabled for, but only those deployed on the server right now; it never starts a channel someone took down. Failures are reported per channel.
|
|
112
|
+
- After a push the tree's revision numbers are updated from the server, so `diff` and the next `push` stay clean.
|
|
113
|
+
- Server settings, the configuration map, channel groups and tags are **not** pushed; `push` names them if they differ. `--whole-server` replaces the entire server configuration instead. It shows the same change list and needs the same `--allow-deletes` / `--force`, and it can't be combined with `--channel` or `--library`.
|
|
114
|
+
- A tree exploded from an XML backup is refused (its shape differs from the live API's); `--ignore-origin` overrides that.
|
|
115
|
+
- Before it changes anything, `push` backs up the server (see below) and prints the `restore` command that undoes it. `--no-backup` skips that.
|
|
116
|
+
- Without a terminal, `push` needs `--yes`.
|
|
117
|
+
|
|
118
|
+
## Backups
|
|
119
|
+
|
|
120
|
+
`backup` saves the server's configuration exactly as the Administrator's *Backup Config* does, so the Administrator can restore it too. `restore` puts one back. They are for recovery, outside the git workflow: the tree is what you review and promote.
|
|
121
|
+
|
|
122
|
+
```
|
|
123
|
+
channelvault backup # .backup/vns-gov-20260925T143012Z.xml
|
|
124
|
+
channelvault backup --out before-upgrade.xml # exactly this file
|
|
125
|
+
channelvault restore # the newest backup of this server
|
|
126
|
+
channelvault restore .backup/vns-gov-20260925T143012Z.xml --deploy
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
- **Names.** The file is named after the server name in Server Settings, else the environment name, else the host and port, followed by the time in UTC. `.backup` is relative to the current directory; `--backup-dir` picks another.
|
|
130
|
+
- **Which server.** That name is part of the configuration, so a restore or `push --whole-server` carries it to another server. Which server a backup came from is therefore recorded by Mirth's server ID, which belongs to the installation, in the directory's `channelvault-backups.json`. Choosing, checking and rotating backups go by that ID.
|
|
131
|
+
- **Plain-text credentials.** A backup holds every connector password and configuration-map value; channelvault's `{{env:…}}` placeholders don't apply. Files are readable by their owner only (on Windows they get the folder's permissions instead), and a backup directory channelvault creates contains a `.gitignore` that ignores everything in it. If git would still commit a backup, you get a warning. Keep backups off shared drives and out of CI artifacts.
|
|
132
|
+
- **Rotation.** The newest 10 backups of each server are kept (`--keep` changes that); older ones are deleted. Files the manifest doesn't attribute to the server, such as ones copied in by hand, are never deleted.
|
|
133
|
+
- **Restore replaces the entire server**, like `push --whole-server`:
|
|
134
|
+
- Without a file it takes the newest backup of the server it is connected to, never another server's. A backup taken from another server is refused unless you pass `--force`. For a file from outside the backup directory only the server names can be compared, and it says so.
|
|
135
|
+
- The preview says when the restore changes the server's name. `push --whole-server` does too.
|
|
136
|
+
- A backup from a newer Mirth version is refused; an older one is converted by the server.
|
|
137
|
+
- It previews the channels and templates it creates, changes and deletes, and asks before continuing (`--yes` without a terminal).
|
|
138
|
+
- It saves the server's current configuration first, as a new backup, and prints the command that undoes the restore. That backup is the newest, so a second plain `restore` reverts the first.
|
|
139
|
+
- If the server changes while you confirm, nothing is restored; run it again to review the new state.
|
|
140
|
+
- `--deploy` redeploys every channel afterwards; `--overwrite-config-map` also replaces the configuration map.
|
|
141
|
+
|
|
142
|
+
## Local test server
|
|
143
|
+
|
|
144
|
+
```
|
|
145
|
+
docker compose up -d # nextgenhealthcare/connect:4.5.2, https://localhost:8443, admin/admin
|
|
146
|
+
MIRTH_HOST=localhost MIRTH_PORT=8443 MIRTH_USER=admin MIRTH_PASS=admin \
|
|
147
|
+
channelvault pull ./work --insecure
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
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.
|
|
151
|
+
|
|
152
|
+
`pnpm test:integration` creates two disposable Mirth 4.5.2 servers on random localhost ports, imports only 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.
|
|
153
|
+
|
|
154
|
+
`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.
|
|
155
|
+
|
|
156
|
+
### Promoting between environments
|
|
157
|
+
|
|
158
|
+
Use a separate working copy and env file for each server. Resource revisions and the sync baseline belong to the server that supplied them; they are not comparable version numbers across independent servers. Do not alternate a single working copy between destinations.
|
|
159
|
+
|
|
160
|
+
For an initial promotion, copy the reviewed source tree into a destination working copy and supply all of its placeholders in a destination env file. The example below assumes the `MIRTH_*` connection variables point to the destination:
|
|
161
|
+
|
|
162
|
+
```sh
|
|
163
|
+
channelvault diff ./destination --dotenv .env.destination
|
|
164
|
+
channelvault push ./destination --dotenv .env.destination --channel "Report Distributor"
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
Review the destination differences before overriding an independent revision history with `--force`. The initial source baseline cannot establish whether an independently managed destination changed since its last review. After the first successful push, keep the destination working copy and its refreshed baseline for subsequent changes. `--force` permits overwriting concurrent edits, while deletions still require `--allow-deletes`. A scoped push does not promote the configuration map or other server settings; manage those separately.
|
|
168
|
+
|
|
169
|
+
### Checks
|
|
170
|
+
|
|
171
|
+
`pnpm typecheck`, `pnpm lint`, `pnpm test`, and `pnpm build` run the local checks. GitHub Actions defines those checks and packaging on Windows and Linux with Node 20.18.1, 22, and 24, plus the disposable two-server promotion on Linux. CLI tests cover partial saves and retries, failed refreshes, deployment failures, confirmation cancellation and EOF, and concurrent edits. File-symlink write protection is tested on Linux; directory junction protection is also tested on Windows.
|
|
172
|
+
|
|
173
|
+
## License
|
|
174
|
+
|
|
175
|
+
MIT
|