@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.d.cts CHANGED
@@ -1199,7 +1199,7 @@ interface VersionIndexSnapshot {
1199
1199
  */
1200
1200
  interface VersionSchemaSnapshot {
1201
1201
  readonly name: string;
1202
- readonly kind: 'object' | 'enum';
1202
+ readonly kind: 'object' | 'enum' | 'partial';
1203
1203
  readonly displayName?: string;
1204
1204
  readonly singular?: string;
1205
1205
  readonly plural?: string;
package/dist/index.d.ts CHANGED
@@ -1199,7 +1199,7 @@ interface VersionIndexSnapshot {
1199
1199
  */
1200
1200
  interface VersionSchemaSnapshot {
1201
1201
  readonly name: string;
1202
- readonly kind: 'object' | 'enum';
1202
+ readonly kind: 'object' | 'enum' | 'partial';
1203
1203
  readonly displayName?: string;
1204
1204
  readonly singular?: string;
1205
1205
  readonly plural?: string;
package/dist/index.js CHANGED
@@ -494,6 +494,8 @@ function parseJsonSchema(content, filePath) {
494
494
  }
495
495
  var VALID_SCHEMA_FIELDS = /* @__PURE__ */ new Set([
496
496
  "kind",
497
+ "target",
498
+ // For partial schemas
497
499
  "displayName",
498
500
  "titleIndex",
499
501
  "group",
@@ -530,6 +532,9 @@ function buildSchemaDefinition(data) {
530
532
  if (data.kind !== void 0) {
531
533
  schema.kind = data.kind;
532
534
  }
535
+ if (data.target !== void 0 && typeof data.target === "string") {
536
+ schema.target = data.target;
537
+ }
533
538
  if (data.displayName !== void 0 && isLocalizedString(data.displayName)) {
534
539
  schema.displayName = data.displayName;
535
540
  }
@@ -855,9 +860,14 @@ async function loadSchemas(directoryPath, options = {}) {
855
860
  }
856
861
  const schemaFiles = await findSchemaFiles(absoluteDir, extensions, recursive);
857
862
  const schemas = {};
863
+ const partialSchemas = [];
858
864
  const schemaLocations = {};
859
865
  for (const filePath of schemaFiles) {
860
866
  const schema = await loadSchema(filePath, { baseDir: absoluteDir });
867
+ if (schema.kind === "partial") {
868
+ partialSchemas.push(schema);
869
+ continue;
870
+ }
861
871
  const existingLocation = schemaLocations[schema.name];
862
872
  if (existingLocation !== void 0) {
863
873
  throw duplicateSchemaError(
@@ -869,6 +879,26 @@ async function loadSchemas(directoryPath, options = {}) {
869
879
  schemas[schema.name] = schema;
870
880
  schemaLocations[schema.name] = filePath;
871
881
  }
882
+ for (const partial of partialSchemas) {
883
+ const targetName = partial.target;
884
+ if (!targetName) {
885
+ console.warn(`Partial schema '${partial.name}' has no target, skipping`);
886
+ continue;
887
+ }
888
+ const target = schemas[targetName];
889
+ if (!target) {
890
+ console.warn(`Partial schema '${partial.name}' targets unknown schema '${targetName}', skipping`);
891
+ continue;
892
+ }
893
+ const mergedProperties = {
894
+ ...partial.properties ?? {},
895
+ ...target.properties ?? {}
896
+ };
897
+ schemas[targetName] = {
898
+ ...target,
899
+ properties: mergedProperties
900
+ };
901
+ }
872
902
  return schemas;
873
903
  }
874
904
  var FILE_SCHEMA_NAME = "File";