babelfhir-ts 1.5.7 → 1.5.8
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/README.md +1 -0
- package/out/fhir-r4.d.ts +2 -4
- package/out/fhir-r4b.d.ts +3 -4
- package/out/src/cli/installCommand.js +72 -8
- package/out/src/main.js +8 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -237,6 +237,7 @@ Options:
|
|
|
237
237
|
--prefab-styles <path> Path to styles module (.ts/.js) copied into the generated prefab/ folder
|
|
238
238
|
--recursive (update only) Recursively search subdirectories for lib/ folders
|
|
239
239
|
--force (update only) Force regeneration even if version and flags haven't changed
|
|
240
|
+
--skip-install (install only) Generate tarball without running package manager install
|
|
240
241
|
--outDir <dir> Output directory (alias for second positional argument)
|
|
241
242
|
--fhir-version <ver> FHIR version to target: r4, r4b, or r5 (auto-detected from package if omitted)
|
|
242
243
|
--package <pkg[@version]> Download FHIR package from registry and process it (latest if no version)
|
package/out/fhir-r4.d.ts
CHANGED
|
@@ -437,6 +437,7 @@ declare module 'fhir/r4' {
|
|
|
437
437
|
export type MolecularSequenceStructureVariantOuter = fhir4.MolecularSequenceStructureVariantOuter;
|
|
438
438
|
export type MolecularSequenceVariant = fhir4.MolecularSequenceVariant;
|
|
439
439
|
export type Money = fhir4.Money;
|
|
440
|
+
export type MoneyQuantity = fhir4.MoneyQuantity;
|
|
440
441
|
export type NamingSystem = fhir4.NamingSystem;
|
|
441
442
|
export type NamingSystemUniqueId = fhir4.NamingSystemUniqueId;
|
|
442
443
|
export type Narrative = fhir4.Narrative;
|
|
@@ -540,6 +541,7 @@ declare module 'fhir/r4' {
|
|
|
540
541
|
export type SearchParameterComponent = fhir4.SearchParameterComponent;
|
|
541
542
|
export type ServiceRequest = fhir4.ServiceRequest;
|
|
542
543
|
export type Signature = fhir4.Signature;
|
|
544
|
+
export type SimpleQuantity = fhir4.SimpleQuantity;
|
|
543
545
|
export type Slot = fhir4.Slot;
|
|
544
546
|
export type Specimen = fhir4.Specimen;
|
|
545
547
|
export type SpecimenCollection = fhir4.SpecimenCollection;
|
|
@@ -673,8 +675,4 @@ declare module 'fhir/r4' {
|
|
|
673
675
|
export type VisionPrescription = fhir4.VisionPrescription;
|
|
674
676
|
export type VisionPrescriptionLensSpecification = fhir4.VisionPrescriptionLensSpecification;
|
|
675
677
|
export type VisionPrescriptionLensSpecificationPrism = fhir4.VisionPrescriptionLensSpecificationPrism;
|
|
676
|
-
/** Constraint profile on Quantity — missing from @types/fhir */
|
|
677
|
-
export type MoneyQuantity = fhir4.Quantity;
|
|
678
|
-
/** Constraint profile on Quantity — missing from @types/fhir */
|
|
679
|
-
export type SimpleQuantity = fhir4.Quantity;
|
|
680
678
|
}
|
package/out/fhir-r4b.d.ts
CHANGED
|
@@ -468,6 +468,7 @@ declare module 'fhir/r4b' {
|
|
|
468
468
|
export type MolecularSequenceStructureVariantOuter = fhir4b.MolecularSequenceStructureVariantOuter;
|
|
469
469
|
export type MolecularSequenceVariant = fhir4b.MolecularSequenceVariant;
|
|
470
470
|
export type Money = fhir4b.Money;
|
|
471
|
+
export type MoneyQuantity = fhir4b.MoneyQuantity;
|
|
471
472
|
export type NamingSystem = fhir4b.NamingSystem;
|
|
472
473
|
export type NamingSystemUniqueId = fhir4b.NamingSystemUniqueId;
|
|
473
474
|
export type Narrative = fhir4b.Narrative;
|
|
@@ -579,6 +580,7 @@ declare module 'fhir/r4b' {
|
|
|
579
580
|
export type SearchParameterComponent = fhir4b.SearchParameterComponent;
|
|
580
581
|
export type ServiceRequest = fhir4b.ServiceRequest;
|
|
581
582
|
export type Signature = fhir4b.Signature;
|
|
583
|
+
export type SimpleQuantity = fhir4b.SimpleQuantity;
|
|
582
584
|
export type Slot = fhir4b.Slot;
|
|
583
585
|
export type Specimen = fhir4b.Specimen;
|
|
584
586
|
export type SpecimenCollection = fhir4b.SpecimenCollection;
|
|
@@ -693,8 +695,5 @@ declare module 'fhir/r4b' {
|
|
|
693
695
|
export type VisionPrescription = fhir4b.VisionPrescription;
|
|
694
696
|
export type VisionPrescriptionLensSpecification = fhir4b.VisionPrescriptionLensSpecification;
|
|
695
697
|
export type VisionPrescriptionLensSpecificationPrism = fhir4b.VisionPrescriptionLensSpecificationPrism;
|
|
696
|
-
|
|
697
|
-
export type MoneyQuantity = fhir4b.Quantity;
|
|
698
|
-
/** Constraint profile on Quantity — missing from @types/fhir */
|
|
699
|
-
export type SimpleQuantity = fhir4b.Quantity;
|
|
698
|
+
|
|
700
699
|
}
|
|
@@ -52,11 +52,18 @@ export function detectPackageManager(startDir) {
|
|
|
52
52
|
* Build the install arguments for the package manager.
|
|
53
53
|
* Returns `['install']` when the dep already exists, or `[...pmArgs, relativePath]` for new deps.
|
|
54
54
|
* Always uses a relative path (e.g. `./lib/foo.tgz`) — never an absolute path.
|
|
55
|
+
*
|
|
56
|
+
* For pnpm: always writes the dep into package.json and returns `['install']`.
|
|
57
|
+
* This avoids `pnpm add` triggering full resolution that chokes on `workspace:*`
|
|
58
|
+
* protocol dependencies in monorepo setups (see issue #104).
|
|
59
|
+
*
|
|
55
60
|
* Exported for testing.
|
|
56
61
|
*/
|
|
57
62
|
export function buildInstallArgs(opts) {
|
|
58
|
-
const { packagePath, pmArgs, cwd, packageJsonContent } = opts;
|
|
63
|
+
const { packagePath, pmArgs, cwd, packageJsonContent, pmCmd, packageName } = opts;
|
|
59
64
|
const tgzRelPath = './' + path.relative(cwd, packagePath).replace(/\\/g, '/');
|
|
65
|
+
// pnpm and yarn both support workspace:* protocol which chokes `add` commands
|
|
66
|
+
const isWorkspaceAwarePm = pmCmd ? (pmCmd.includes('pnpm') || pmCmd.includes('yarn')) : false;
|
|
60
67
|
if (packageJsonContent) {
|
|
61
68
|
try {
|
|
62
69
|
const projectPkg = JSON.parse(packageJsonContent);
|
|
@@ -71,21 +78,71 @@ export function buildInstallArgs(opts) {
|
|
|
71
78
|
}
|
|
72
79
|
const tgzBaseName = path.basename(packagePath, '.tgz').replace(/^-/, '');
|
|
73
80
|
for (const name of Object.keys(deps)) {
|
|
74
|
-
if (name.replace(/[@/]/g, '-') === tgzBaseName) {
|
|
81
|
+
if (name.replace(/[@/]/g, '-').replace(/^-/, '') === tgzBaseName) {
|
|
75
82
|
deps[name] = tgzRelPath;
|
|
76
83
|
projectPkg.dependencies = deps;
|
|
84
|
+
// For workspace-aware PMs: write dep and use plain install to avoid
|
|
85
|
+
// workspace:* resolution failure
|
|
86
|
+
if (isWorkspaceAwarePm) {
|
|
87
|
+
return {
|
|
88
|
+
args: ['install'],
|
|
89
|
+
updatedPackageJson: JSON.stringify(projectPkg, null, 2) + '\n',
|
|
90
|
+
};
|
|
91
|
+
}
|
|
77
92
|
return {
|
|
78
93
|
args: [...pmArgs, tgzRelPath],
|
|
79
94
|
updatedPackageJson: JSON.stringify(projectPkg, null, 2) + '\n',
|
|
80
95
|
};
|
|
81
96
|
}
|
|
82
97
|
}
|
|
98
|
+
// For workspace-aware PMs: write the dep directly into package.json and use `install`
|
|
99
|
+
// instead of `add` to avoid full resolution that chokes on workspace:* protocol
|
|
100
|
+
if (isWorkspaceAwarePm && packageName) {
|
|
101
|
+
if (!projectPkg.dependencies)
|
|
102
|
+
projectPkg.dependencies = {};
|
|
103
|
+
projectPkg.dependencies[packageName] = tgzRelPath;
|
|
104
|
+
return {
|
|
105
|
+
args: ['install'],
|
|
106
|
+
updatedPackageJson: JSON.stringify(projectPkg, null, 2) + '\n',
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
// For workspace-aware PMs without packageName: still prefer plain install
|
|
110
|
+
// over add to avoid workspace:* resolution failure. The tgz won't be in
|
|
111
|
+
// package.json but at least the command won't crash.
|
|
112
|
+
if (isWorkspaceAwarePm) {
|
|
113
|
+
return { args: ['install'] };
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
catch {
|
|
117
|
+
// JSON parse failed (empty string, malformed content, etc.)
|
|
118
|
+
// For workspace-aware PMs: fall through to safe install path below
|
|
119
|
+
if (isWorkspaceAwarePm && packageName) {
|
|
120
|
+
const newPkg = { dependencies: { [packageName]: tgzRelPath } };
|
|
121
|
+
return {
|
|
122
|
+
args: ['install'],
|
|
123
|
+
updatedPackageJson: JSON.stringify(newPkg, null, 2) + '\n',
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
if (isWorkspaceAwarePm) {
|
|
127
|
+
return { args: ['install'] };
|
|
128
|
+
}
|
|
129
|
+
/* non-workspace PMs: fall through to normal add */
|
|
83
130
|
}
|
|
84
|
-
|
|
131
|
+
}
|
|
132
|
+
// For workspace-aware PMs without package.json: prefer install over add
|
|
133
|
+
if (isWorkspaceAwarePm && packageName && !packageJsonContent) {
|
|
134
|
+
const newPkg = { dependencies: { [packageName]: tgzRelPath } };
|
|
135
|
+
return {
|
|
136
|
+
args: ['install'],
|
|
137
|
+
updatedPackageJson: JSON.stringify(newPkg, null, 2) + '\n',
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
if (isWorkspaceAwarePm) {
|
|
141
|
+
return { args: ['install'] };
|
|
85
142
|
}
|
|
86
143
|
return { args: [...pmArgs, tgzRelPath] };
|
|
87
144
|
}
|
|
88
|
-
function npmInstall(packagePath) {
|
|
145
|
+
function npmInstall(packagePath, packageName) {
|
|
89
146
|
return new Promise((resolve, reject) => {
|
|
90
147
|
const pm = detectPackageManager();
|
|
91
148
|
const pmName = path.basename(pm.cmd).replace(/\.(cmd|exe)$/, '');
|
|
@@ -98,6 +155,8 @@ function npmInstall(packagePath) {
|
|
|
98
155
|
pmArgs: pm.args,
|
|
99
156
|
cwd: process.cwd(),
|
|
100
157
|
packageJsonContent,
|
|
158
|
+
pmCmd: pm.cmd,
|
|
159
|
+
packageName,
|
|
101
160
|
});
|
|
102
161
|
if (result.updatedPackageJson) {
|
|
103
162
|
fs.writeFileSync(projectPkgPath, result.updatedPackageJson);
|
|
@@ -174,7 +233,7 @@ function clearBunCache(packageName) {
|
|
|
174
233
|
}
|
|
175
234
|
}
|
|
176
235
|
export async function handleInstallCommand(opts) {
|
|
177
|
-
const { packageToInstall, registry, generationFlags, downloadPackage } = opts;
|
|
236
|
+
const { packageToInstall, registry, generationFlags, downloadPackage, skipInstall } = opts;
|
|
178
237
|
// Keep cache by default — dependency packages are large (hl7.fhir.r4.core ~50 MB)
|
|
179
238
|
// and re-downloading them every run is the single biggest bottleneck.
|
|
180
239
|
// Users can opt in to cache cleanup with --no-cache.
|
|
@@ -229,8 +288,13 @@ export async function handleInstallCommand(opts) {
|
|
|
229
288
|
// Workaround: nuke the .bun cache entry so bun is forced to re-extract.
|
|
230
289
|
// See: https://github.com/oven-sh/bun/issues/29372
|
|
231
290
|
clearBunCache(packageName);
|
|
232
|
-
|
|
233
|
-
|
|
291
|
+
if (skipInstall) {
|
|
292
|
+
console.log(`Skipping install (--skip-install). Tarball saved to ./lib/${path.basename(tarballPath)}`);
|
|
293
|
+
}
|
|
294
|
+
else {
|
|
295
|
+
console.log(`Installing ${packageName}...`);
|
|
296
|
+
await npmInstall(tarballPath, packageName);
|
|
297
|
+
}
|
|
234
298
|
// Clean up extracted package tree (but keep the tarball under ./lib)
|
|
235
299
|
generationCleanup();
|
|
236
300
|
generationCleanup = undefined;
|
|
@@ -243,7 +307,7 @@ export async function handleInstallCommand(opts) {
|
|
|
243
307
|
if (generationFlags.noCache) {
|
|
244
308
|
cleanupCache();
|
|
245
309
|
}
|
|
246
|
-
console.log(`\n✓ Package ${packageToInstall} installed and ready to use!`);
|
|
310
|
+
console.log(`\n✓ Package ${packageToInstall} ${skipInstall ? 'generated' : 'installed'} and ready to use!`);
|
|
247
311
|
}
|
|
248
312
|
catch (error) {
|
|
249
313
|
// Clean up extracted package on error
|
package/out/src/main.js
CHANGED
|
@@ -61,6 +61,7 @@ function printUsage() {
|
|
|
61
61
|
console.log(" --prefab-styles <path> Path to styles module (.ts/.js) copied into the generated prefab/ folder");
|
|
62
62
|
console.log(" --recursive (update only) Recursively search subdirectories for lib/ folders");
|
|
63
63
|
console.log(" --force (update only) Force regeneration even if version and flags haven't changed");
|
|
64
|
+
console.log(" --skip-install (install only) Generate tarball without running package manager install");
|
|
64
65
|
console.log(" --outDir <dir> Output directory (alias for second positional argument)");
|
|
65
66
|
console.log(" --fhir-version <ver> FHIR version to target: r4, r4b, or r5 (auto-detected from package if omitted)");
|
|
66
67
|
console.log(" --package <pkg[@version]> Download FHIR package from registry and process it (latest if no version)");
|
|
@@ -230,6 +231,10 @@ export function parseCliArgs(argv) {
|
|
|
230
231
|
out.flags.noClient = true;
|
|
231
232
|
continue;
|
|
232
233
|
}
|
|
234
|
+
if (arg === '--skip-install') {
|
|
235
|
+
out.flags.skipInstall = true;
|
|
236
|
+
continue;
|
|
237
|
+
}
|
|
233
238
|
if (arg === '--dicomweb') {
|
|
234
239
|
out.flags.dicomweb = true;
|
|
235
240
|
continue;
|
|
@@ -410,6 +415,7 @@ export async function run() {
|
|
|
410
415
|
registry,
|
|
411
416
|
generationFlags,
|
|
412
417
|
downloadPackage,
|
|
418
|
+
skipInstall: !!generationFlags.skipInstall,
|
|
413
419
|
});
|
|
414
420
|
}
|
|
415
421
|
return;
|
|
@@ -429,7 +435,8 @@ export async function run() {
|
|
|
429
435
|
packageToInstall,
|
|
430
436
|
registry,
|
|
431
437
|
generationFlags,
|
|
432
|
-
downloadPackage
|
|
438
|
+
downloadPackage,
|
|
439
|
+
skipInstall: !!generationFlags.skipInstall,
|
|
433
440
|
});
|
|
434
441
|
return;
|
|
435
442
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "babelfhir-ts",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.8",
|
|
4
4
|
"description": "BabelFHIR-TS: generate TypeScript interfaces, validators, and helper classes from FHIR R4/R4B/R5 StructureDefinitions (profiles) directly inside package archives.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "out/src/main.js",
|
|
@@ -98,7 +98,7 @@
|
|
|
98
98
|
"zod": "^4.3.6"
|
|
99
99
|
},
|
|
100
100
|
"dependencies": {
|
|
101
|
-
"@types/fhir": "^0.0.
|
|
101
|
+
"@types/fhir": "^0.0.43",
|
|
102
102
|
"consola": "^3.4.2",
|
|
103
103
|
"fhirpath": "^4.10.0",
|
|
104
104
|
"tar": "^7.4.3",
|