@atomic-ehr/codegen 0.0.12 → 0.0.13

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 CHANGED
@@ -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
  }
@@ -5476,14 +5479,22 @@ var generateFactoryMethods = (w, tsIndex, flatProfile, factoryInfo) => {
5476
5479
  }
5477
5480
  w.line();
5478
5481
  const extensionVar = extSliceField ? "extensionWithDefaults" : "resolvedExtensions";
5482
+ const hasMetaParam = allFields.some((f) => f.name === "meta");
5479
5483
  w.curlyBlock([`const resource: ${tsBaseResourceName} =`], () => {
5480
5484
  for (const f of allFields) {
5481
5485
  if (f.name === "extension") continue;
5486
+ if (f.name === "meta" && hasMeta) continue;
5482
5487
  w.line(`${f.name}: ${f.value},`);
5483
5488
  }
5484
5489
  w.line(`extension: ${extensionVar},`);
5485
5490
  if (hasMeta) {
5486
- w.line(`meta: { profile: [${profileClassName}.canonicalUrl] },`);
5491
+ if (hasMetaParam) {
5492
+ w.line(
5493
+ `meta: { ...args.meta, profile: [...(args.meta?.profile ?? []), ${profileClassName}.canonicalUrl] },`
5494
+ );
5495
+ } else {
5496
+ w.line(`meta: { profile: [${profileClassName}.canonicalUrl] },`);
5497
+ }
5487
5498
  }
5488
5499
  });
5489
5500
  w.lineSM("return resource");
@@ -5512,12 +5523,20 @@ var generateFactoryMethods = (w, tsIndex, flatProfile, factoryInfo) => {
5512
5523
  if (isPrimitiveIdentifier(flatProfile.base)) {
5513
5524
  w.lineSM(`const resource = undefined as unknown as ${tsBaseResourceName}`);
5514
5525
  } else {
5526
+ const hasMetaParam = allFields.some((f) => f.name === "meta");
5515
5527
  w.curlyBlock([`const resource: ${tsBaseResourceName} =`], () => {
5516
5528
  for (const f of allFields) {
5529
+ if (f.name === "meta" && hasMeta) continue;
5517
5530
  w.line(`${f.name}: ${f.value},`);
5518
5531
  }
5519
5532
  if (hasMeta) {
5520
- w.line(`meta: { profile: [${profileClassName}.canonicalUrl] },`);
5533
+ if (hasMetaParam) {
5534
+ w.line(
5535
+ `meta: { ...args.meta, profile: [...(args.meta?.profile ?? []), ${profileClassName}.canonicalUrl] },`
5536
+ );
5537
+ } else {
5538
+ w.line(`meta: { profile: [${profileClassName}.canonicalUrl] },`);
5539
+ }
5521
5540
  }
5522
5541
  });
5523
5542
  }
@@ -6037,13 +6056,17 @@ var APIBuilder = class {
6037
6056
  registry: void 0,
6038
6057
  dropCanonicalManagerCache: false
6039
6058
  };
6059
+ const apiBuilderKeys = [
6060
+ "outputDir",
6061
+ "cleanOutput",
6062
+ "throwException",
6063
+ "typeSchema",
6064
+ "registry",
6065
+ "dropCanonicalManagerCache"
6066
+ ];
6040
6067
  const opts = {
6041
6068
  ...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
- )
6069
+ ...Object.fromEntries(apiBuilderKeys.filter((k) => userOpts[k] !== void 0).map((k) => [k, userOpts[k]]))
6047
6070
  };
6048
6071
  if (userOpts.manager && userOpts.register) {
6049
6072
  throw new Error("Cannot provide both 'manager' and 'register' options. Use one or the other.");
@@ -6059,7 +6082,8 @@ var APIBuilder = class {
6059
6082
  workingDir: ".codegen-cache/canonical-manager-cache",
6060
6083
  registry: userOpts.registry,
6061
6084
  dropCache: userOpts.dropCanonicalManagerCache,
6062
- preprocessPackage: userOpts.preprocessPackage
6085
+ preprocessPackage: userOpts.preprocessPackage,
6086
+ ignorePackageIndex: userOpts.ignorePackageIndex
6063
6087
  });
6064
6088
  this.logger = userOpts.logger ?? mkLogger({ prefix: "api" });
6065
6089
  this.options = opts;