@atomic-ehr/codegen 0.0.12 → 0.0.13-canary.20260421152026.cc8f05b
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/dist/index.d.ts +2 -1
- package/dist/index.js +36 -10
- package/dist/index.js.map +1 -1
- package/package.json +3 -22
package/dist/index.d.ts
CHANGED
|
@@ -67,7 +67,7 @@ interface Identifier extends Element {
|
|
|
67
67
|
interface Reference<T extends string = string> extends Element {
|
|
68
68
|
display?: string;
|
|
69
69
|
identifier?: Identifier;
|
|
70
|
-
reference?: `${T}/${string}`;
|
|
70
|
+
reference?: `${T}/${string}` | `http://${string}` | `https://${string}` | `urn:uuid:${string}` | `urn:oid:${string}` | `#${string}`;
|
|
71
71
|
type?: string;
|
|
72
72
|
}
|
|
73
73
|
|
|
@@ -1119,6 +1119,7 @@ declare class APIBuilder {
|
|
|
1119
1119
|
manager?: ReturnType<typeof CanonicalManager>;
|
|
1120
1120
|
register?: Register;
|
|
1121
1121
|
preprocessPackage?: (context: PreprocessContext) => PreprocessContext;
|
|
1122
|
+
ignorePackageIndex?: boolean;
|
|
1122
1123
|
logger?: CodegenLogManager;
|
|
1123
1124
|
});
|
|
1124
1125
|
fromPackage(packageName: string, version?: string): APIBuilder;
|
package/dist/index.js
CHANGED
|
@@ -1561,6 +1561,9 @@ var Python = class extends Writer {
|
|
|
1561
1561
|
generateResourceMethods(schema) {
|
|
1562
1562
|
const className = schema.identifier.name.toString();
|
|
1563
1563
|
this.line();
|
|
1564
|
+
this.line("def model_post_init(self, __context: Any) -> None:");
|
|
1565
|
+
this.line(' self.__pydantic_fields_set__.add("resource_type")');
|
|
1566
|
+
this.line();
|
|
1564
1567
|
this.line("def to_json(self, indent: int | None = None) -> str:");
|
|
1565
1568
|
this.line(" return self.model_dump_json(exclude_unset=True, exclude_none=True, indent=indent)");
|
|
1566
1569
|
this.line();
|
|
@@ -1578,7 +1581,7 @@ var Python = class extends Writer {
|
|
|
1578
1581
|
generateDefaultImports(includeGenericImports) {
|
|
1579
1582
|
this.pyImportFrom("__future__", "annotations");
|
|
1580
1583
|
this.pyImportFrom("pydantic", "BaseModel", "ConfigDict", "Field", "PositiveInt");
|
|
1581
|
-
const typingImports = ["List as PyList", "Literal"];
|
|
1584
|
+
const typingImports = ["Any", "List as PyList", "Literal"];
|
|
1582
1585
|
if (includeGenericImports) {
|
|
1583
1586
|
typingImports.push("Generic");
|
|
1584
1587
|
}
|
|
@@ -4406,7 +4409,9 @@ var tsEnumType = (enumDef) => {
|
|
|
4406
4409
|
var rewriteFieldTypeDefs = {
|
|
4407
4410
|
Coding: { code: () => "T" },
|
|
4408
4411
|
// biome-ignore lint: that is exactly string what we want
|
|
4409
|
-
Reference: {
|
|
4412
|
+
Reference: {
|
|
4413
|
+
reference: () => "`${T}/${string}` | `http://${string}` | `https://${string}` | `urn:uuid:${string}` | `urn:oid:${string}` | `#${string}`"
|
|
4414
|
+
},
|
|
4410
4415
|
CodeableConcept: { coding: () => "Coding<T>" }
|
|
4411
4416
|
};
|
|
4412
4417
|
var resolveFieldTsType = (schemaName, tsName, field, resolveRef, genericFieldMap, isFamilyType) => {
|
|
@@ -5476,14 +5481,22 @@ var generateFactoryMethods = (w, tsIndex, flatProfile, factoryInfo) => {
|
|
|
5476
5481
|
}
|
|
5477
5482
|
w.line();
|
|
5478
5483
|
const extensionVar = extSliceField ? "extensionWithDefaults" : "resolvedExtensions";
|
|
5484
|
+
const hasMetaParam = allFields.some((f) => f.name === "meta");
|
|
5479
5485
|
w.curlyBlock([`const resource: ${tsBaseResourceName} =`], () => {
|
|
5480
5486
|
for (const f of allFields) {
|
|
5481
5487
|
if (f.name === "extension") continue;
|
|
5488
|
+
if (f.name === "meta" && hasMeta) continue;
|
|
5482
5489
|
w.line(`${f.name}: ${f.value},`);
|
|
5483
5490
|
}
|
|
5484
5491
|
w.line(`extension: ${extensionVar},`);
|
|
5485
5492
|
if (hasMeta) {
|
|
5486
|
-
|
|
5493
|
+
if (hasMetaParam) {
|
|
5494
|
+
w.line(
|
|
5495
|
+
`meta: { ...args.meta, profile: [...(args.meta?.profile ?? []), ${profileClassName}.canonicalUrl] },`
|
|
5496
|
+
);
|
|
5497
|
+
} else {
|
|
5498
|
+
w.line(`meta: { profile: [${profileClassName}.canonicalUrl] },`);
|
|
5499
|
+
}
|
|
5487
5500
|
}
|
|
5488
5501
|
});
|
|
5489
5502
|
w.lineSM("return resource");
|
|
@@ -5512,12 +5525,20 @@ var generateFactoryMethods = (w, tsIndex, flatProfile, factoryInfo) => {
|
|
|
5512
5525
|
if (isPrimitiveIdentifier(flatProfile.base)) {
|
|
5513
5526
|
w.lineSM(`const resource = undefined as unknown as ${tsBaseResourceName}`);
|
|
5514
5527
|
} else {
|
|
5528
|
+
const hasMetaParam = allFields.some((f) => f.name === "meta");
|
|
5515
5529
|
w.curlyBlock([`const resource: ${tsBaseResourceName} =`], () => {
|
|
5516
5530
|
for (const f of allFields) {
|
|
5531
|
+
if (f.name === "meta" && hasMeta) continue;
|
|
5517
5532
|
w.line(`${f.name}: ${f.value},`);
|
|
5518
5533
|
}
|
|
5519
5534
|
if (hasMeta) {
|
|
5520
|
-
|
|
5535
|
+
if (hasMetaParam) {
|
|
5536
|
+
w.line(
|
|
5537
|
+
`meta: { ...args.meta, profile: [...(args.meta?.profile ?? []), ${profileClassName}.canonicalUrl] },`
|
|
5538
|
+
);
|
|
5539
|
+
} else {
|
|
5540
|
+
w.line(`meta: { profile: [${profileClassName}.canonicalUrl] },`);
|
|
5541
|
+
}
|
|
5521
5542
|
}
|
|
5522
5543
|
});
|
|
5523
5544
|
}
|
|
@@ -6037,13 +6058,17 @@ var APIBuilder = class {
|
|
|
6037
6058
|
registry: void 0,
|
|
6038
6059
|
dropCanonicalManagerCache: false
|
|
6039
6060
|
};
|
|
6061
|
+
const apiBuilderKeys = [
|
|
6062
|
+
"outputDir",
|
|
6063
|
+
"cleanOutput",
|
|
6064
|
+
"throwException",
|
|
6065
|
+
"typeSchema",
|
|
6066
|
+
"registry",
|
|
6067
|
+
"dropCanonicalManagerCache"
|
|
6068
|
+
];
|
|
6040
6069
|
const opts = {
|
|
6041
6070
|
...defaultOpts,
|
|
6042
|
-
...Object.fromEntries(
|
|
6043
|
-
Object.entries(userOpts).filter(
|
|
6044
|
-
([k, v]) => v !== void 0 && k !== "manager" && k !== "register" && k !== "preprocessPackage" && k !== "logger"
|
|
6045
|
-
)
|
|
6046
|
-
)
|
|
6071
|
+
...Object.fromEntries(apiBuilderKeys.filter((k) => userOpts[k] !== void 0).map((k) => [k, userOpts[k]]))
|
|
6047
6072
|
};
|
|
6048
6073
|
if (userOpts.manager && userOpts.register) {
|
|
6049
6074
|
throw new Error("Cannot provide both 'manager' and 'register' options. Use one or the other.");
|
|
@@ -6059,7 +6084,8 @@ var APIBuilder = class {
|
|
|
6059
6084
|
workingDir: ".codegen-cache/canonical-manager-cache",
|
|
6060
6085
|
registry: userOpts.registry,
|
|
6061
6086
|
dropCache: userOpts.dropCanonicalManagerCache,
|
|
6062
|
-
preprocessPackage: userOpts.preprocessPackage
|
|
6087
|
+
preprocessPackage: userOpts.preprocessPackage,
|
|
6088
|
+
ignorePackageIndex: userOpts.ignorePackageIndex
|
|
6063
6089
|
});
|
|
6064
6090
|
this.logger = userOpts.logger ?? mkLogger({ prefix: "api" });
|
|
6065
6091
|
this.options = opts;
|