@famgia/omnify-core 0.0.127 → 0.0.128

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.cjs CHANGED
@@ -85,6 +85,7 @@ __export(index_exports, {
85
85
  jsonSyntaxError: () => jsonSyntaxError,
86
86
  loadSchema: () => loadSchema,
87
87
  loadSchemas: () => loadSchemas,
88
+ mergePartialSchemas: () => mergePartialSchemas,
88
89
  missingConfigFieldError: () => missingConfigFieldError,
89
90
  missingFieldError: () => missingFieldError,
90
91
  notImplementedError: () => notImplementedError,
@@ -955,7 +956,8 @@ async function findSchemaFiles(dirPath, extensions, recursive) {
955
956
  async function loadSchemas(directoryPath, options = {}) {
956
957
  const {
957
958
  extensions = [".yaml", ".yml", ".json"],
958
- recursive = true
959
+ recursive = true,
960
+ skipPartialResolution = false
959
961
  } = options;
960
962
  const absoluteDir = path.resolve(directoryPath);
961
963
  try {
@@ -990,16 +992,35 @@ async function loadSchemas(directoryPath, options = {}) {
990
992
  schemas[schema.name] = schema;
991
993
  schemaLocations[schema.name] = filePath;
992
994
  }
995
+ if (skipPartialResolution) {
996
+ for (const partial of partialSchemas) {
997
+ const partialKey = `__partial__${partial.name}`;
998
+ schemas[partialKey] = partial;
999
+ }
1000
+ return schemas;
1001
+ }
1002
+ return mergePartialSchemas(schemas, partialSchemas);
1003
+ }
1004
+ function mergePartialSchemas(schemas, partials) {
1005
+ const partialSchemas = partials ?? [];
1006
+ const cleanSchemas = {};
1007
+ for (const [key, schema] of Object.entries(schemas)) {
1008
+ if (key.startsWith("__partial__")) {
1009
+ partialSchemas.push(schema);
1010
+ } else {
1011
+ cleanSchemas[key] = schema;
1012
+ }
1013
+ }
993
1014
  for (const partial of partialSchemas) {
994
1015
  const targetName = partial.target;
995
1016
  if (!targetName) {
996
1017
  console.warn(`Partial schema '${partial.name}' has no target, skipping`);
997
1018
  continue;
998
1019
  }
999
- const target = schemas[targetName];
1020
+ const target = cleanSchemas[targetName];
1000
1021
  if (!target) {
1001
1022
  if (partial.name === targetName) {
1002
- schemas[partial.name] = {
1023
+ cleanSchemas[partial.name] = {
1003
1024
  ...partial,
1004
1025
  kind: "object"
1005
1026
  };
@@ -1012,12 +1033,12 @@ async function loadSchemas(directoryPath, options = {}) {
1012
1033
  ...partial.properties ?? {},
1013
1034
  ...target.properties ?? {}
1014
1035
  };
1015
- schemas[targetName] = {
1036
+ cleanSchemas[targetName] = {
1016
1037
  ...target,
1017
1038
  properties: mergedProperties
1018
1039
  };
1019
1040
  }
1020
- return schemas;
1041
+ return cleanSchemas;
1021
1042
  }
1022
1043
  var FILE_SCHEMA_NAME = "File";
1023
1044
  function schemasHaveFileProperties(schemas) {
@@ -4768,6 +4789,7 @@ function createVersionStore(config) {
4768
4789
  jsonSyntaxError,
4769
4790
  loadSchema,
4770
4791
  loadSchemas,
4792
+ mergePartialSchemas,
4771
4793
  missingConfigFieldError,
4772
4794
  missingFieldError,
4773
4795
  notImplementedError,