plumb-fhir 0.16.0 → 0.18.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 +29 -0
- package/README.md +44 -3
- package/dist/cjs/config.d.ts +16 -6
- package/dist/cjs/config.d.ts.map +1 -1
- package/dist/cjs/index.cjs +59 -19
- package/dist/cjs/index.cjs.map +3 -3
- package/dist/cjs/testing.cjs +120 -26
- package/dist/cjs/testing.cjs.map +3 -3
- package/dist/cjs/testing.d.ts.map +1 -1
- package/dist/cjs/vitest.cjs +156 -38
- package/dist/cjs/vitest.cjs.map +3 -3
- package/dist/esm/cli.mjs +214 -66
- package/dist/esm/cli.mjs.map +3 -3
- package/dist/esm/config.d.ts +16 -6
- package/dist/esm/config.d.ts.map +1 -1
- package/dist/esm/index.mjs +60 -20
- package/dist/esm/index.mjs.map +3 -3
- package/dist/esm/testing.d.ts.map +1 -1
- package/dist/esm/testing.mjs +123 -29
- package/dist/esm/testing.mjs.map +3 -3
- package/dist/esm/vitest.mjs +156 -38
- package/dist/esm/vitest.mjs.map +3 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,34 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.18.0 (2026-10-08)
|
|
4
|
+
|
|
5
|
+
The checker's version changes, so the next `push` redeploys it. The generated migration runner changes, so `generate --check` is stale
|
|
6
|
+
until it is generated and the migrator rebuilt.
|
|
7
|
+
|
|
8
|
+
- **`restamp: { exclude }`** names a module whose default export gives the
|
|
9
|
+
reason a record must stay unstamped: correct FHIR that the profile it
|
|
10
|
+
routes to cannot express. The restamps skip those records and count them by
|
|
11
|
+
reason in `plumb migrate`'s output and `--json`; the module is part of the
|
|
12
|
+
restamps' hash, so editing it makes them pending again. A path that is not
|
|
13
|
+
a file, or a module that does not default-export a function, is
|
|
14
|
+
`invalid-restamp-exclude`, and a migrator built without the exclusion
|
|
15
|
+
refuses the page. `restamp: true` is unchanged (#265).
|
|
16
|
+
|
|
17
|
+
## 0.17.0 (2026-10-07)
|
|
18
|
+
|
|
19
|
+
The checker's version changes, so the next `push` redeploys it.
|
|
20
|
+
|
|
21
|
+
- **An unset variable leaves a held secret alone:** `push` and `--check`
|
|
22
|
+
warn that it was not compared rather than blocking, so a run that cannot
|
|
23
|
+
read one source (a least-privilege CI drift check, an operator without
|
|
24
|
+
access to one vendor) still converges the rest. A secret the project lacks
|
|
25
|
+
still blocks (#270).
|
|
26
|
+
- **`environments` on an `{ env }` secret** keeps it out of every other
|
|
27
|
+
environment's push, and the `scope` step lists it. One an environment
|
|
28
|
+
holds anyway is reported, and removed with `--prune`, so
|
|
29
|
+
`push --check --prune` fails while it is there: a value for testing that
|
|
30
|
+
must never reach production (#268).
|
|
31
|
+
|
|
3
32
|
## 0.16.0 (2026-10-07)
|
|
4
33
|
|
|
5
34
|
The checker's version changes, so the next `push` redeploys it.
|
package/README.md
CHANGED
|
@@ -692,7 +692,7 @@ plumb migrate --env prod
|
|
|
692
692
|
✔ load 1 profiles of Patient 1.9s
|
|
693
693
|
✔ connect https://api.medplum.com/ 320ms
|
|
694
694
|
✔ migrations 1 of 1 chosen 40ms
|
|
695
|
-
✔ checker plumb-checker 0.
|
|
695
|
+
✔ checker plumb-checker 0.18.0 installed 60ms
|
|
696
696
|
✔ migrator migrator current (migrator-3c07…) 70ms
|
|
697
697
|
✔ 20261006-patient-birthdate dry run: 312 read, 312 to change, 0 unchanged 9.8s
|
|
698
698
|
forecast: 312 would pass the selected profiles, 0 would still fail
|
|
@@ -746,6 +746,41 @@ record that routes to no single profile alone. They run again whenever
|
|
|
746
746
|
`_routes.ts` changes, so a new routing row or profile restamps what is
|
|
747
747
|
stored.
|
|
748
748
|
|
|
749
|
+
Some records are correct FHIR that the profile they route to cannot express,
|
|
750
|
+
such as a Coverage with no member id under `us-core-15`; stamped, their next
|
|
751
|
+
edit is refused. Declare them, and the restamps leave them alone:
|
|
752
|
+
|
|
753
|
+
```ts
|
|
754
|
+
// in plumb.config.ts
|
|
755
|
+
migrations: {
|
|
756
|
+
bot: 'migrator',
|
|
757
|
+
modules: ['./src/migrations/*.ts'],
|
|
758
|
+
restamp: { exclude: './src/migrations/never-stamped.ts' },
|
|
759
|
+
},
|
|
760
|
+
```
|
|
761
|
+
|
|
762
|
+
```ts
|
|
763
|
+
// src/migrations/never-stamped.ts
|
|
764
|
+
import type { Resource } from '@medplum/fhirtypes';
|
|
765
|
+
|
|
766
|
+
/** Why a record must stay unstamped, or undefined to restamp it. */
|
|
767
|
+
export default function neverStamped(resource: Resource): string | undefined {
|
|
768
|
+
if (resource.resourceType === 'Coverage' && !resource.subscriberId && !resource.identifier) {
|
|
769
|
+
return 'no member id: us-core-15 cannot express it';
|
|
770
|
+
}
|
|
771
|
+
return undefined;
|
|
772
|
+
}
|
|
773
|
+
```
|
|
774
|
+
|
|
775
|
+
The function is pure, and its reason names a kind of record, never anything
|
|
776
|
+
read from one: each run counts what it skipped by reason, as
|
|
777
|
+
`3 skipped: no member id: us-core-15 cannot express it`, and `--json` holds the
|
|
778
|
+
same counts under `skipped` and `skips`. The module and the files it imports
|
|
779
|
+
are part of the restamps' hash, so editing it makes them pending again and
|
|
780
|
+
`generate --check` stale until it is generated and the bot rebuilt. A path that
|
|
781
|
+
is not a file, or a module whose default export is not a function, is
|
|
782
|
+
`invalid-restamp-exclude`.
|
|
783
|
+
|
|
749
784
|
**`push` names what is pending.** The two stay separate: `push` never writes
|
|
750
785
|
patient data, and `migrate` never loads a profile. When the gate refuses, it
|
|
751
786
|
lists the pending migrations on each failing type:
|
|
@@ -805,8 +840,11 @@ export default defineConfig({
|
|
|
805
840
|
project: {
|
|
806
841
|
settings: { supportEmail: 'support@example.org', maxUploadMb: 25 },
|
|
807
842
|
secrets: {
|
|
808
|
-
|
|
843
|
+
// Set from its variable; with the variable unset, a held value is left as it is.
|
|
844
|
+
LAB_API_KEY: { env: 'LAB_API_KEY' },
|
|
809
845
|
SFTP_KEY: true, // must exist; set by hand in the console
|
|
846
|
+
// Only in dev: left out of every other push, removed there with --prune.
|
|
847
|
+
TEST_RECIPIENTS: { env: 'TEST_RECIPIENTS', environments: ['dev'] },
|
|
810
848
|
},
|
|
811
849
|
accessPolicies: {
|
|
812
850
|
clinician: {
|
|
@@ -880,7 +918,10 @@ Done in 3.2s
|
|
|
880
918
|
- **Removal needs `--prune`.** A tagged policy or client whose key left the
|
|
881
919
|
config is listed, and deleted only with `--prune`, a client with its
|
|
882
920
|
membership. Settings and secrets the config does not name are left alone,
|
|
883
|
-
even with `--prune`: they carry no tag.
|
|
921
|
+
even with `--prune`: they carry no tag. A secret scoped to other
|
|
922
|
+
environments is the exception, since the config names it: one an
|
|
923
|
+
environment holds is reported, and removed with `--prune`, so
|
|
924
|
+
`push --check --prune` fails while it is there.
|
|
884
925
|
- **A client's secret is never printed or stored.** A created client's id is
|
|
885
926
|
printed; read its secret in the console, and keep it in your secrets store.
|
|
886
927
|
- **Only this project's own resources.** A linked project's policies are never
|
package/dist/cjs/config.d.ts
CHANGED
|
@@ -64,8 +64,15 @@ export interface MigrationsConfig {
|
|
|
64
64
|
bot: string;
|
|
65
65
|
/** Modules, as paths or globs, each default-exporting a `defineMigration`. */
|
|
66
66
|
modules: string[];
|
|
67
|
-
/**
|
|
68
|
-
|
|
67
|
+
/**
|
|
68
|
+
* Adds Plumb's restamp migration, for every type with routing rows. With
|
|
69
|
+
* `exclude`, a module whose default export, `(resource) => string |
|
|
70
|
+
* undefined`, gives the reason a record must stay as it is stamped: correct
|
|
71
|
+
* FHIR that a routed profile cannot express. Those are skipped and counted.
|
|
72
|
+
*/
|
|
73
|
+
restamp?: boolean | {
|
|
74
|
+
exclude: string;
|
|
75
|
+
};
|
|
69
76
|
}
|
|
70
77
|
/** A bot: its built bundle and the Bot's own fields, written as declared. */
|
|
71
78
|
export interface BotConfig {
|
|
@@ -166,9 +173,12 @@ export interface ProjectConfig {
|
|
|
166
173
|
/**
|
|
167
174
|
* `Project.secret` by name: `{ env }` names the variable holding its value,
|
|
168
175
|
* since the config is committed; `true` means it is set by hand and must exist.
|
|
176
|
+
* `environments` keeps a secret out of every other environment, where one
|
|
177
|
+
* found is removed with `--prune`.
|
|
169
178
|
*/
|
|
170
179
|
secrets?: Record<string, {
|
|
171
180
|
env: string;
|
|
181
|
+
environments?: string[];
|
|
172
182
|
} | true>;
|
|
173
183
|
/** AccessPolicies by key; `name` is the key unless given. */
|
|
174
184
|
accessPolicies?: Record<string, AccessPolicyConfig>;
|
|
@@ -229,7 +239,7 @@ export interface ResolvedEnvironment {
|
|
|
229
239
|
/** Holds no real patient data, as the config or a test project says. */
|
|
230
240
|
synthetic?: boolean;
|
|
231
241
|
}
|
|
232
|
-
export type ConfigErrorCode = 'config-not-found' | 'unsupported-syntax' | 'unresolved-import' | 'no-default-export' | 'unknown-key' | 'missing-out' | 'invalid-type' | 'invalid-ig' | 'unlisted-ig' | 'invalid-profile' | 'invalid-max-codes' | 'invalid-base-url' | 'unknown-environment' | 'missing-variable' | 'invalid-route' | 'unselected-route' | 'invalid-route-element' | 'invalid-default-profile' | 'versioned-url' | 'fsh-and-local' | 'no-sushi-config' | 'invalid-setting' | 'super-admin-field' | 'unknown-access-policy' | 'duplicate-key' | 'invalid-check' | 'invalid-server-version' | 'invalid-bot' | 'invalid-subscription' | 'unknown-bot' | 'invalid-operation' | 'invalid-migration';
|
|
242
|
+
export type ConfigErrorCode = 'config-not-found' | 'unsupported-syntax' | 'unresolved-import' | 'no-default-export' | 'unknown-key' | 'missing-out' | 'invalid-type' | 'invalid-ig' | 'unlisted-ig' | 'invalid-profile' | 'invalid-max-codes' | 'invalid-base-url' | 'unknown-environment' | 'missing-variable' | 'invalid-route' | 'unselected-route' | 'invalid-route-element' | 'invalid-default-profile' | 'versioned-url' | 'fsh-and-local' | 'no-sushi-config' | 'invalid-setting' | 'super-admin-field' | 'unknown-access-policy' | 'duplicate-key' | 'invalid-check' | 'invalid-server-version' | 'invalid-bot' | 'invalid-subscription' | 'unknown-bot' | 'invalid-operation' | 'invalid-migration' | 'invalid-restamp-exclude';
|
|
233
243
|
export interface ConfigError {
|
|
234
244
|
code: ConfigErrorCode;
|
|
235
245
|
message: string;
|
|
@@ -315,13 +325,13 @@ export interface ConfigWarning {
|
|
|
315
325
|
}
|
|
316
326
|
/** A bot or Subscription a push to one environment leaves out, and where it does go. */
|
|
317
327
|
export interface ScopedOut {
|
|
318
|
-
kind: 'Bot' | 'Subscription' | 'Operation';
|
|
328
|
+
kind: 'Bot' | 'Subscription' | 'Operation' | 'Secret';
|
|
319
329
|
key: string;
|
|
320
330
|
environments: string[];
|
|
321
331
|
}
|
|
322
332
|
/**
|
|
323
|
-
* The config as one environment sees it: without the bots and
|
|
324
|
-
* scoped to others. A Subscription with no scope of its own takes its bot's.
|
|
333
|
+
* The config as one environment sees it: without the bots, Subscriptions and
|
|
334
|
+
* secrets scoped to others. A Subscription with no scope of its own takes its bot's.
|
|
325
335
|
*/
|
|
326
336
|
export declare function scopeConfig(config: PlumbConfig, environment: string): {
|
|
327
337
|
config: PlumbConfig;
|
package/dist/cjs/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EACV,YAAY,EACZ,oBAAoB,EACpB,GAAG,EAEH,MAAM,EAEN,mBAAmB,EACpB,MAAM,oBAAoB,CAAC;AAG5B,MAAM,WAAW,WAAW;IAC1B,4DAA4D;IAC5D,GAAG,EAAE,MAAM,EAAE,CAAC;IACd;;;OAGG;IACH,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,gEAAgE;IAChE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,gDAAgD;IAChD,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE;QACT,0FAA0F;QAC1F,QAAQ,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";
|
|
67
67
|
var IG = new RegExp(`^(${NAME})@\\d+\\.\\d+\\.\\d+(?:-[0-9A-Za-z.-]+)?$`);
|
|
68
68
|
var ALL_PROFILES = new RegExp(`^(${NAME})/\\*$`);
|
|
69
|
+
function resolveMigrations(base2, migrations) {
|
|
70
|
+
if (!migrations) return {};
|
|
71
|
+
const modules = migrations.modules.map((p) => (0, import_node_path.resolve)(base2, p));
|
|
72
|
+
const { restamp } = migrations;
|
|
73
|
+
if (typeof restamp !== "object") return { migrations: { ...migrations, modules } };
|
|
74
|
+
const exclude = (0, import_node_path.resolve)(base2, restamp.exclude);
|
|
75
|
+
if ((0, import_node_fs.existsSync)(exclude) && (0, import_node_fs.statSync)(exclude).isFile()) {
|
|
76
|
+
return { migrations: { ...migrations, modules, restamp: { exclude } } };
|
|
77
|
+
}
|
|
78
|
+
return {
|
|
79
|
+
error: {
|
|
80
|
+
code: "invalid-restamp-exclude",
|
|
81
|
+
path: "migrations.restamp.exclude",
|
|
82
|
+
message: `"migrations.restamp.exclude" names ${exclude}, which is not a file.`
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
}
|
|
69
86
|
function sushiConfig(project) {
|
|
70
87
|
return ["sushi-config.yaml", "sushi-config.yml"].find((name) => (0, import_node_fs.existsSync)((0, import_node_path.join)(project, name)));
|
|
71
88
|
}
|
|
@@ -97,6 +114,8 @@ async function loadConfig(options) {
|
|
|
97
114
|
});
|
|
98
115
|
}
|
|
99
116
|
const local = fsh ? (0, import_node_path.join)(fsh, "fsh-generated", "resources") : config.local && (0, import_node_path.resolve)(base2, config.local);
|
|
117
|
+
const migrations = resolveMigrations(base2, config.migrations);
|
|
118
|
+
if ("error" in migrations) return fail(migrations.error);
|
|
100
119
|
return {
|
|
101
120
|
ok: true,
|
|
102
121
|
configPath,
|
|
@@ -106,12 +125,7 @@ async function loadConfig(options) {
|
|
|
106
125
|
...config.check ? { check: resolveCheck(base2, config.check) } : {},
|
|
107
126
|
...resolveList(base2, config, "content"),
|
|
108
127
|
...resolveList(base2, config, "operations"),
|
|
109
|
-
...
|
|
110
|
-
migrations: {
|
|
111
|
-
...config.migrations,
|
|
112
|
-
modules: config.migrations.modules.map((p) => (0, import_node_path.resolve)(base2, p))
|
|
113
|
-
}
|
|
114
|
-
} : {},
|
|
128
|
+
...migrations,
|
|
115
129
|
...resolveBots(base2, config.bots),
|
|
116
130
|
...config.test ? { test: resolveTest(base2, config.test) } : {},
|
|
117
131
|
...fsh ? { fsh } : {},
|
|
@@ -206,7 +220,7 @@ function check(config) {
|
|
|
206
220
|
...checkEnvironments(record.environments),
|
|
207
221
|
...checkRouteRows(record),
|
|
208
222
|
...checkDefaultProfile(record.defaultProfile),
|
|
209
|
-
...checkProject(record.project),
|
|
223
|
+
...checkProject(record.project, record),
|
|
210
224
|
...checkCheck(record.check),
|
|
211
225
|
...checkTest(record.test)
|
|
212
226
|
);
|
|
@@ -437,7 +451,7 @@ function checkSettings(settings, at) {
|
|
|
437
451
|
message: `"${at}.${name}" must be a string, boolean or number, the types a ProjectSetting holds.`
|
|
438
452
|
}));
|
|
439
453
|
}
|
|
440
|
-
function checkProject(project) {
|
|
454
|
+
function checkProject(project, config) {
|
|
441
455
|
if (project === void 0) return [];
|
|
442
456
|
if (!isObject(project)) return [notObject("project")];
|
|
443
457
|
const errors = Object.keys(project).filter((key) => !PROJECT_KEYS.includes(key)).map(
|
|
@@ -462,7 +476,7 @@ function checkProject(project) {
|
|
|
462
476
|
return [
|
|
463
477
|
...errors,
|
|
464
478
|
...checkSettings(project.settings, "project.settings"),
|
|
465
|
-
...checkSecrets(project.secrets),
|
|
479
|
+
...checkSecrets(project.secrets, config),
|
|
466
480
|
...checkAccessPolicies(project.accessPolicies),
|
|
467
481
|
...checkDefaultAccessPolicies(project.defaultAccessPolicies, checkPolicyKey),
|
|
468
482
|
...checkClients(project.clients, checkPolicyKey)
|
|
@@ -518,16 +532,36 @@ var notObject = (path) => ({
|
|
|
518
532
|
path,
|
|
519
533
|
message: `"${path}" must be an object.`
|
|
520
534
|
});
|
|
521
|
-
function checkSecrets(secrets) {
|
|
535
|
+
function checkSecrets(secrets, config) {
|
|
522
536
|
if (secrets === void 0) return [];
|
|
523
537
|
if (!isObject(secrets)) return [notObject("project.secrets")];
|
|
524
|
-
return Object.entries(secrets).
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
538
|
+
return Object.entries(secrets).flatMap(([name, secret]) => {
|
|
539
|
+
const at = `project.secrets.${name}`;
|
|
540
|
+
if (secret === true) return [];
|
|
541
|
+
if (!(isObject(secret) && typeof secret.env === "string" && secret.env !== "")) {
|
|
542
|
+
return [
|
|
543
|
+
{
|
|
544
|
+
code: "invalid-type",
|
|
545
|
+
path: at,
|
|
546
|
+
message: `"${at}" must be { env: 'VAR' }, naming the variable that holds its value, or true for one set by hand: the config is committed, so it never holds the value.`
|
|
547
|
+
}
|
|
548
|
+
];
|
|
549
|
+
}
|
|
550
|
+
const { environments } = secret;
|
|
551
|
+
if (environments !== void 0 && !isListOf(isText)(environments)) {
|
|
552
|
+
return [
|
|
553
|
+
{
|
|
554
|
+
code: "invalid-type",
|
|
555
|
+
path: `${at}.environments`,
|
|
556
|
+
message: `"${at}.environments" must be a list of keys in environments.`
|
|
557
|
+
}
|
|
558
|
+
];
|
|
559
|
+
}
|
|
560
|
+
return [
|
|
561
|
+
...unknownKeys(secret, { env: 0, environments: 0 }, at),
|
|
562
|
+
...scopeProblems(environments, config).map(toError("invalid-type", at))
|
|
563
|
+
];
|
|
564
|
+
});
|
|
531
565
|
}
|
|
532
566
|
function checkAccessPolicies(accessPolicies) {
|
|
533
567
|
if (accessPolicies === void 0) return [];
|
|
@@ -741,8 +775,14 @@ function checkMigrationsConfig(config) {
|
|
|
741
775
|
if (!isListOf(isText)(migrations.modules)) {
|
|
742
776
|
errors.push(invalidType("modules", "a list of paths or globs"));
|
|
743
777
|
}
|
|
744
|
-
|
|
745
|
-
|
|
778
|
+
const { restamp } = migrations;
|
|
779
|
+
if (isObject(restamp)) {
|
|
780
|
+
errors.push(...unknownKeys(restamp, { exclude: 1 }, "migrations.restamp"));
|
|
781
|
+
if (!isText(restamp.exclude)) {
|
|
782
|
+
errors.push(invalidType("restamp.exclude", "the path of the module that excludes records"));
|
|
783
|
+
}
|
|
784
|
+
} else if (restamp !== void 0 && typeof restamp !== "boolean") {
|
|
785
|
+
errors.push(invalidType("restamp", "true, false, or { exclude: a module path }"));
|
|
746
786
|
}
|
|
747
787
|
return errors;
|
|
748
788
|
}
|