@famgia/omnify-core 0.0.113 → 0.0.114
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 +30 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +30 -0
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -605,6 +605,8 @@ function parseJsonSchema(content, filePath) {
|
|
|
605
605
|
}
|
|
606
606
|
var VALID_SCHEMA_FIELDS = /* @__PURE__ */ new Set([
|
|
607
607
|
"kind",
|
|
608
|
+
"target",
|
|
609
|
+
// For partial schemas
|
|
608
610
|
"displayName",
|
|
609
611
|
"titleIndex",
|
|
610
612
|
"group",
|
|
@@ -641,6 +643,9 @@ function buildSchemaDefinition(data) {
|
|
|
641
643
|
if (data.kind !== void 0) {
|
|
642
644
|
schema.kind = data.kind;
|
|
643
645
|
}
|
|
646
|
+
if (data.target !== void 0 && typeof data.target === "string") {
|
|
647
|
+
schema.target = data.target;
|
|
648
|
+
}
|
|
644
649
|
if (data.displayName !== void 0 && (0, import_omnify_types.isLocalizedString)(data.displayName)) {
|
|
645
650
|
schema.displayName = data.displayName;
|
|
646
651
|
}
|
|
@@ -966,9 +971,14 @@ async function loadSchemas(directoryPath, options = {}) {
|
|
|
966
971
|
}
|
|
967
972
|
const schemaFiles = await findSchemaFiles(absoluteDir, extensions, recursive);
|
|
968
973
|
const schemas = {};
|
|
974
|
+
const partialSchemas = [];
|
|
969
975
|
const schemaLocations = {};
|
|
970
976
|
for (const filePath of schemaFiles) {
|
|
971
977
|
const schema = await loadSchema(filePath, { baseDir: absoluteDir });
|
|
978
|
+
if (schema.kind === "partial") {
|
|
979
|
+
partialSchemas.push(schema);
|
|
980
|
+
continue;
|
|
981
|
+
}
|
|
972
982
|
const existingLocation = schemaLocations[schema.name];
|
|
973
983
|
if (existingLocation !== void 0) {
|
|
974
984
|
throw duplicateSchemaError(
|
|
@@ -980,6 +990,26 @@ async function loadSchemas(directoryPath, options = {}) {
|
|
|
980
990
|
schemas[schema.name] = schema;
|
|
981
991
|
schemaLocations[schema.name] = filePath;
|
|
982
992
|
}
|
|
993
|
+
for (const partial of partialSchemas) {
|
|
994
|
+
const targetName = partial.target;
|
|
995
|
+
if (!targetName) {
|
|
996
|
+
console.warn(`Partial schema '${partial.name}' has no target, skipping`);
|
|
997
|
+
continue;
|
|
998
|
+
}
|
|
999
|
+
const target = schemas[targetName];
|
|
1000
|
+
if (!target) {
|
|
1001
|
+
console.warn(`Partial schema '${partial.name}' targets unknown schema '${targetName}', skipping`);
|
|
1002
|
+
continue;
|
|
1003
|
+
}
|
|
1004
|
+
const mergedProperties = {
|
|
1005
|
+
...partial.properties ?? {},
|
|
1006
|
+
...target.properties ?? {}
|
|
1007
|
+
};
|
|
1008
|
+
schemas[targetName] = {
|
|
1009
|
+
...target,
|
|
1010
|
+
properties: mergedProperties
|
|
1011
|
+
};
|
|
1012
|
+
}
|
|
983
1013
|
return schemas;
|
|
984
1014
|
}
|
|
985
1015
|
var FILE_SCHEMA_NAME = "File";
|