plumb-fhir 0.6.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.
Files changed (102) hide show
  1. package/CHANGELOG.md +130 -0
  2. package/LICENSE.txt +176 -0
  3. package/NOTICE +20 -0
  4. package/README.md +767 -0
  5. package/dist/checker.cjs +1790 -0
  6. package/dist/cjs/checker/bundle.d.ts +23 -0
  7. package/dist/cjs/checker/bundle.d.ts.map +1 -0
  8. package/dist/cjs/checker/handler.d.ts +46 -0
  9. package/dist/cjs/checker/handler.d.ts.map +1 -0
  10. package/dist/cjs/checker/input.d.ts +12 -0
  11. package/dist/cjs/checker/input.d.ts.map +1 -0
  12. package/dist/cjs/checker/install.d.ts +33 -0
  13. package/dist/cjs/checker/install.d.ts.map +1 -0
  14. package/dist/cjs/commands.d.ts +21 -0
  15. package/dist/cjs/commands.d.ts.map +1 -0
  16. package/dist/cjs/config.d.ts +159 -0
  17. package/dist/cjs/config.d.ts.map +1 -0
  18. package/dist/cjs/conformance.d.ts +89 -0
  19. package/dist/cjs/conformance.d.ts.map +1 -0
  20. package/dist/cjs/connect.d.ts +70 -0
  21. package/dist/cjs/connect.d.ts.map +1 -0
  22. package/dist/cjs/emit/print.d.ts +11 -0
  23. package/dist/cjs/emit/print.d.ts.map +1 -0
  24. package/dist/cjs/emit/routes.d.ts +34 -0
  25. package/dist/cjs/emit/routes.d.ts.map +1 -0
  26. package/dist/cjs/emit/transform.d.ts +130 -0
  27. package/dist/cjs/emit/transform.d.ts.map +1 -0
  28. package/dist/cjs/emit/valuesets.d.ts +18 -0
  29. package/dist/cjs/emit/valuesets.d.ts.map +1 -0
  30. package/dist/cjs/emit/write.d.ts +31 -0
  31. package/dist/cjs/emit/write.d.ts.map +1 -0
  32. package/dist/cjs/generate.d.ts +45 -0
  33. package/dist/cjs/generate.d.ts.map +1 -0
  34. package/dist/cjs/index.cjs +848 -0
  35. package/dist/cjs/index.cjs.map +7 -0
  36. package/dist/cjs/index.d.ts +5 -0
  37. package/dist/cjs/index.d.ts.map +1 -0
  38. package/dist/cjs/loader.d.ts +59 -0
  39. package/dist/cjs/loader.d.ts.map +1 -0
  40. package/dist/cjs/package.json +1 -0
  41. package/dist/cjs/packages.d.ts +50 -0
  42. package/dist/cjs/packages.d.ts.map +1 -0
  43. package/dist/cjs/project.d.ts +145 -0
  44. package/dist/cjs/project.d.ts.map +1 -0
  45. package/dist/cjs/push.d.ts +57 -0
  46. package/dist/cjs/push.d.ts.map +1 -0
  47. package/dist/cjs/sushi.d.ts +35 -0
  48. package/dist/cjs/sushi.d.ts.map +1 -0
  49. package/dist/cjs/tar.d.ts +7 -0
  50. package/dist/cjs/tar.d.ts.map +1 -0
  51. package/dist/cjs/validate.d.ts +22 -0
  52. package/dist/cjs/validate.d.ts.map +1 -0
  53. package/dist/esm/checker/bundle.d.ts +23 -0
  54. package/dist/esm/checker/bundle.d.ts.map +1 -0
  55. package/dist/esm/checker/handler.d.ts +46 -0
  56. package/dist/esm/checker/handler.d.ts.map +1 -0
  57. package/dist/esm/checker/input.d.ts +12 -0
  58. package/dist/esm/checker/input.d.ts.map +1 -0
  59. package/dist/esm/checker/install.d.ts +33 -0
  60. package/dist/esm/checker/install.d.ts.map +1 -0
  61. package/dist/esm/cli.mjs +4247 -0
  62. package/dist/esm/cli.mjs.map +7 -0
  63. package/dist/esm/commands.d.ts +21 -0
  64. package/dist/esm/commands.d.ts.map +1 -0
  65. package/dist/esm/config.d.ts +159 -0
  66. package/dist/esm/config.d.ts.map +1 -0
  67. package/dist/esm/conformance.d.ts +89 -0
  68. package/dist/esm/conformance.d.ts.map +1 -0
  69. package/dist/esm/connect.d.ts +70 -0
  70. package/dist/esm/connect.d.ts.map +1 -0
  71. package/dist/esm/emit/print.d.ts +11 -0
  72. package/dist/esm/emit/print.d.ts.map +1 -0
  73. package/dist/esm/emit/routes.d.ts +34 -0
  74. package/dist/esm/emit/routes.d.ts.map +1 -0
  75. package/dist/esm/emit/transform.d.ts +130 -0
  76. package/dist/esm/emit/transform.d.ts.map +1 -0
  77. package/dist/esm/emit/valuesets.d.ts +18 -0
  78. package/dist/esm/emit/valuesets.d.ts.map +1 -0
  79. package/dist/esm/emit/write.d.ts +31 -0
  80. package/dist/esm/emit/write.d.ts.map +1 -0
  81. package/dist/esm/generate.d.ts +45 -0
  82. package/dist/esm/generate.d.ts.map +1 -0
  83. package/dist/esm/index.d.ts +5 -0
  84. package/dist/esm/index.d.ts.map +1 -0
  85. package/dist/esm/index.mjs +832 -0
  86. package/dist/esm/index.mjs.map +7 -0
  87. package/dist/esm/loader.d.ts +59 -0
  88. package/dist/esm/loader.d.ts.map +1 -0
  89. package/dist/esm/package.json +1 -0
  90. package/dist/esm/packages.d.ts +50 -0
  91. package/dist/esm/packages.d.ts.map +1 -0
  92. package/dist/esm/project.d.ts +145 -0
  93. package/dist/esm/project.d.ts.map +1 -0
  94. package/dist/esm/push.d.ts +57 -0
  95. package/dist/esm/push.d.ts.map +1 -0
  96. package/dist/esm/sushi.d.ts +35 -0
  97. package/dist/esm/sushi.d.ts.map +1 -0
  98. package/dist/esm/tar.d.ts +7 -0
  99. package/dist/esm/tar.d.ts.map +1 -0
  100. package/dist/esm/validate.d.ts +22 -0
  101. package/dist/esm/validate.d.ts.map +1 -0
  102. package/package.json +79 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,130 @@
1
+ # Changelog
2
+
3
+ ## 0.6.0 (2026-10-05)
4
+
5
+ The first published release; it includes everything in 0.1.0 to 0.5.0, which were not published.
6
+
7
+ Project config as code: `push` converges what a project admin can write.
8
+
9
+ - **`project`** in the config declares settings, secrets, AccessPolicies,
10
+ default access policies and clients, typed with `@medplum/fhirtypes`. An
11
+ environment's `settings` merge over `project.settings`. An unknown policy
12
+ key, duplicate names, a setting that is not a string, boolean or number,
13
+ and a super-admin field (`strictMode`, `features`, `link`,
14
+ `systemSetting`) are config errors.
15
+ - **`push` runs a `project` step** once the profile gate has passed. It plans
16
+ each AccessPolicy and client by a `meta.tag` with its config key, updates
17
+ it in place, and writes the Project's settings, secrets, `defaultProfile`
18
+ and `defaultAccessPolicies` in one update. A second push with no config
19
+ change writes nothing.
20
+ - **`--adopt`** tags and converges an untagged policy or client with a key's
21
+ name; without it, one stops the plan. **`--prune`** deletes a tagged one
22
+ whose key left the config.
23
+ - **Secrets** come from environment variables (`{ env }`) or must already
24
+ exist (`true`); no plan, `--json` output or error holds a value. A created
25
+ client's id is printed, never its secret.
26
+ - **`push --check`** plans without installing or writing anything, and exits
27
+ 1 when `push` would change something, naming what drifted.
28
+ - **Lockdown warnings:** a writable `*` entry, an admin client with no
29
+ policy, and a policy other than push's own that writes
30
+ StructureDefinition.
31
+ - `strictMode` and `features` are reported, never written. A linked
32
+ project's resources are never planned.
33
+ - **Breaking:** the checker bot's identifier system is now
34
+ `https://www.npmjs.com/package/plumb-fhir`, as is Plumb's tag system, so a
35
+ checker installed by 0.5 is installed again.
36
+
37
+ ## 0.5.0 (not published)
38
+
39
+ SUSHI in `generate`: one command builds FSH and types it.
40
+
41
+ - **`fsh`** in the config names the folder holding `sushi-config.yaml`, in
42
+ place of `local`. Setting both is a config error, as is a folder with no
43
+ `sushi-config.yaml`.
44
+ - **`generate` runs the project's own SUSHI** (`fsh-sushi` 3 or later) with
45
+ `--snapshot`, as a first `sushi` step. Its errors stop `generate`, with
46
+ their FSH file and line; its warnings are listed under the step. SUSHI
47
+ missing or too old exits 2, naming the install command.
48
+ - **`generate --check`** rebuilds the FSH into a temporary folder and fails
49
+ when the committed `fsh-generated/resources` differs from it, file by file,
50
+ as well as when the types do. The project is not touched.
51
+ - **Version warnings:** the `sushi` step warns when `sushi-config.yaml`
52
+ depends on a package at a version `igs` does not select, and `load` warns
53
+ (`base-version-mismatch`) when a local profile's pinned parent version
54
+ differs from the one the config provides.
55
+
56
+ ## 0.4.0 (not published)
57
+
58
+ Typed reads: reads that return the profile type once its content is checked.
59
+
60
+ - **`_reads.ts`**, generated into `out`, lists the paths each selected
61
+ profile's type requires beyond `@medplum/fhirtypes`, for the presence check
62
+ typed reads run.
63
+ - **`isProfiled`, `asProfiled` and `pickProfiled`**, generated into `out`,
64
+ check a resource's stamp and what its type requires, offline, and narrow it
65
+ to the profile type; a failure throws a **`ProfileReadError`** naming the
66
+ records and paths, with the records that passed in a non-enumerable
67
+ `passed`.
68
+ - **`readProfiled` and `searchProfiled`** read from Medplum and return the
69
+ profile type once checked. The search filters on `_profile` (the profile and
70
+ any selected child), refuses `_elements`, `_fields`, `_summary`, `_include`
71
+ and `_revinclude` before any request, and fails as a whole when one result
72
+ does, with the rest in `passed`.
73
+ - A choice narrowed to `Reference` keeps the base element's targets instead of
74
+ widening them to any resource.
75
+
76
+ ## 0.3.0 (not published)
77
+
78
+ Routing: each write held to the profile its content selects.
79
+
80
+ - **`route(resource)`**, generated into `out`, returns the selected profile a
81
+ resource's content selects, preferring a child over its parent, and throws
82
+ a `RoutingError` naming what would select each candidate rather than
83
+ guess.
84
+ - **`createProfiled` and `updateProfiled`** route, stamp the type's
85
+ `defaultProfile` plus the routed profile, and write; `{ profile }` chooses
86
+ one, typed, and `{ profile: false }` writes no stamp.
87
+ - **`routes`** in the config adds rows for profiles keyed on a value set, or
88
+ `false` to take one out; **`defaultProfile`** names the defaults stamped
89
+ with each write. `generate` warns for profiles one resource could match.
90
+
91
+ ## 0.2.0 (not published)
92
+
93
+ The conformance check: what stored data would fail a profile, before it loads.
94
+
95
+ - **`environments`** in `plumb.config.ts` name a Medplum project and the
96
+ environment variables holding its client credentials.
97
+ - **`plumb validate --env <env>`** counts, per profile, the stored resources
98
+ that would fail and why, with Plumb's checker bot inside the project, so
99
+ patient data never leaves Medplum. It reports unstamped resources, silent
100
+ stamps, shadowed profiles, and readable against stored counts; failing ids
101
+ go only to a gitignored file. `--resume` continues an interrupted run.
102
+ - **`plumb push --env <env>`** installs the checker, then loads the selected
103
+ profiles and their dependencies, refusing while any stored resource would
104
+ fail them, and re-checks once they are loaded. `--dry-run` stops after the
105
+ gate. Strict mode is reported, never set.
106
+
107
+ ## 0.1.0 (not published)
108
+
109
+ The first release: profile-aware types for Medplum.
110
+
111
+ - **`plumb generate`** fetches the IG packages `plumb.config.ts` names from
112
+ the FHIR package registry into `~/.fhir/packages`, locks each one's version
113
+ and hash in `plumb.lock`, and generates a TypeScript file per profile that
114
+ narrows `@medplum/fhirtypes`: required fields at every depth, prohibited
115
+ fields, choice types, fixed and pattern values, reference targets, slices
116
+ with typed builders and readers, extension types shared across profiles,
117
+ and literal unions for required bindings whose value sets can be listed
118
+ offline.
119
+ - **`plumb generate --check`** compares with the committed output byte for
120
+ byte, writes nothing to the project, and names the cause of each
121
+ difference; for CI.
122
+ - **`validateProfiled`** runs Medplum's validator against a selected profile,
123
+ offline, for tests.
124
+ - Profiles by canonical URL, or `name/*` for every resource profile in an IG;
125
+ local StructureDefinition JSON, such as SUSHI's output; `bindings.maxCodes`.
126
+ - Supports `@medplum/*` 5.1.0 and later, TypeScript 5.0 and later, and Node
127
+ `^22.18.0 || >=24.2.0`.
128
+
129
+ See the README's known limits for what the types leave to `validateProfiled`
130
+ and the server.
package/LICENSE.txt ADDED
@@ -0,0 +1,176 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
package/NOTICE ADDED
@@ -0,0 +1,20 @@
1
+ Plumb
2
+ Copyright 2026 Balance Hormone Center and Plumb contributors
3
+
4
+ This product includes software developed by Balance Hormone Center and
5
+ other contributors under the Apache License, Version 2.0.
6
+
7
+ Plumb is built on Medplum (https://www.medplum.com). "Medplum" is a
8
+ registered trademark of Orangebot, Inc.
9
+
10
+ Licensed under the Apache License, Version 2.0 (the "License");
11
+ you may not use this file except in compliance with the License.
12
+ You may obtain a copy of the License at:
13
+
14
+ http://www.apache.org/licenses/LICENSE-2.0
15
+
16
+ Unless required by applicable law or agreed to in writing, software
17
+ distributed under the License is distributed on an "AS IS" BASIS,
18
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
+ See the License for the specific language governing permissions and
20
+ limitations under the License.