@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.d.cts CHANGED
@@ -235,6 +235,8 @@ interface LoadSchemasOptions {
235
235
  readonly extensions?: readonly string[];
236
236
  /** Whether to load recursively from subdirectories (default: true) */
237
237
  readonly recursive?: boolean;
238
+ /** Skip partial schema resolution (default: false) - use mergePartialSchemas later */
239
+ readonly skipPartialResolution?: boolean;
238
240
  }
239
241
  /**
240
242
  * Converts a file name to a schema name (PascalCase).
@@ -284,6 +286,15 @@ declare function loadSchema(filePath: string, options?: LoadSchemaOptions): Prom
284
286
  * @throws OmnifyError if duplicate schema names or invalid files
285
287
  */
286
288
  declare function loadSchemas(directoryPath: string, options?: LoadSchemasOptions): Promise<SchemaCollection>;
289
+ /**
290
+ * Merges partial schemas into their target schemas.
291
+ * Call this after combining schemas from multiple sources.
292
+ *
293
+ * @param schemas - Collection of regular schemas
294
+ * @param partials - Array of partial schemas to merge (optional, extracted from schemas if not provided)
295
+ * @returns Schema collection with partials merged into targets
296
+ */
297
+ declare function mergePartialSchemas(schemas: Record<string, LoadedSchema>, partials?: LoadedSchema[]): SchemaCollection;
287
298
  /**
288
299
  * The reserved name for the File schema (polymorphic file storage).
289
300
  */
@@ -1363,4 +1374,4 @@ declare class VersionStore {
1363
1374
  */
1364
1375
  declare function createVersionStore(config: VersionStoreConfig): VersionStore;
1365
1376
 
1366
- export { type AssociationMetadata, type ChangeAction, type CreateVersionOptions, type DefaultValueValidationResult, type DiffOperationResult, type ExpandedProperty, FILE_SCHEMA_NAME, type FormatOptions, type GenerateOptions, type GenerateResult, type GeneratedFile, type LoadResult, type LoadSchemaOptions, type LoadSchemasOptions, Omnify, OmnifyError, type OmnifyLogger, type OmnifyOptions, PluginManager, type PluginManagerOptions, type PluginRegistrationResult, type PluginRegistry, type PropertyMetadata, type RegisteredType, type SchemaError, type SchemaIntrospection, type SchemaMetadata, type SchemaValidationResult, type SchemaWarning, type ValidationOptions, type ValidationResult, type VersionChange, type VersionDiff, type VersionFile, type VersionIndexSnapshot, type VersionPropertySnapshot, type VersionSchemaSnapshot, VersionStore, type VersionStoreConfig, type VersionSummary, atlasError, atlasNotFoundError, circularReferenceError, configError, configNotFoundError, createFileLoadedSchema, createFileSchemaDefinition, createOmnify, createPluginManager, createVersionStore, duplicateSchemaError, ensureFileSchema, expandProperty, expandSchema, expandSchemaProperties, expandSchemas, fileNameToSchemaName, findReferencedSchemas, findReferencingSchemas, formatError, formatErrorPlain, formatErrorSummary, generateFileSchemaYaml, generationError, getAssociationMetadata, getCustomTypeNames, getEntitySchemas, getEnumSchemas, getExitCode, getGroups, getPropertyMetadata, getRelationshipGraph, getSchemaMetadata, getSchemaNames, getSchemasByGroup, getSchemasByKind, getTopologicalOrder, getTypeInfo, hasCircularReferences, internalError, introspectSchema, introspectSchemas, invalidAssociationTargetError, invalidConfigError, invalidPropertyTypeError, isCompoundType, jsonSyntaxError, loadSchema, loadSchemas, missingConfigFieldError, missingFieldError, notImplementedError, outputWriteError, parseJsonSchema, parseYamlSchema, pluginError, pluginNotFoundError, pluginTypeConflictError, schemaNotFoundError, schemaParseError, schemasHaveFileProperties, validateAssociations, validateDefaultValue, validateEnumSchema, validateOptions, validateProperties, validatePropertyType, validateSchema, validateSchemas, validationError, yamlSyntaxError };
1377
+ export { type AssociationMetadata, type ChangeAction, type CreateVersionOptions, type DefaultValueValidationResult, type DiffOperationResult, type ExpandedProperty, FILE_SCHEMA_NAME, type FormatOptions, type GenerateOptions, type GenerateResult, type GeneratedFile, type LoadResult, type LoadSchemaOptions, type LoadSchemasOptions, Omnify, OmnifyError, type OmnifyLogger, type OmnifyOptions, PluginManager, type PluginManagerOptions, type PluginRegistrationResult, type PluginRegistry, type PropertyMetadata, type RegisteredType, type SchemaError, type SchemaIntrospection, type SchemaMetadata, type SchemaValidationResult, type SchemaWarning, type ValidationOptions, type ValidationResult, type VersionChange, type VersionDiff, type VersionFile, type VersionIndexSnapshot, type VersionPropertySnapshot, type VersionSchemaSnapshot, VersionStore, type VersionStoreConfig, type VersionSummary, atlasError, atlasNotFoundError, circularReferenceError, configError, configNotFoundError, createFileLoadedSchema, createFileSchemaDefinition, createOmnify, createPluginManager, createVersionStore, duplicateSchemaError, ensureFileSchema, expandProperty, expandSchema, expandSchemaProperties, expandSchemas, fileNameToSchemaName, findReferencedSchemas, findReferencingSchemas, formatError, formatErrorPlain, formatErrorSummary, generateFileSchemaYaml, generationError, getAssociationMetadata, getCustomTypeNames, getEntitySchemas, getEnumSchemas, getExitCode, getGroups, getPropertyMetadata, getRelationshipGraph, getSchemaMetadata, getSchemaNames, getSchemasByGroup, getSchemasByKind, getTopologicalOrder, getTypeInfo, hasCircularReferences, internalError, introspectSchema, introspectSchemas, invalidAssociationTargetError, invalidConfigError, invalidPropertyTypeError, isCompoundType, jsonSyntaxError, loadSchema, loadSchemas, mergePartialSchemas, missingConfigFieldError, missingFieldError, notImplementedError, outputWriteError, parseJsonSchema, parseYamlSchema, pluginError, pluginNotFoundError, pluginTypeConflictError, schemaNotFoundError, schemaParseError, schemasHaveFileProperties, validateAssociations, validateDefaultValue, validateEnumSchema, validateOptions, validateProperties, validatePropertyType, validateSchema, validateSchemas, validationError, yamlSyntaxError };
package/dist/index.d.ts CHANGED
@@ -235,6 +235,8 @@ interface LoadSchemasOptions {
235
235
  readonly extensions?: readonly string[];
236
236
  /** Whether to load recursively from subdirectories (default: true) */
237
237
  readonly recursive?: boolean;
238
+ /** Skip partial schema resolution (default: false) - use mergePartialSchemas later */
239
+ readonly skipPartialResolution?: boolean;
238
240
  }
239
241
  /**
240
242
  * Converts a file name to a schema name (PascalCase).
@@ -284,6 +286,15 @@ declare function loadSchema(filePath: string, options?: LoadSchemaOptions): Prom
284
286
  * @throws OmnifyError if duplicate schema names or invalid files
285
287
  */
286
288
  declare function loadSchemas(directoryPath: string, options?: LoadSchemasOptions): Promise<SchemaCollection>;
289
+ /**
290
+ * Merges partial schemas into their target schemas.
291
+ * Call this after combining schemas from multiple sources.
292
+ *
293
+ * @param schemas - Collection of regular schemas
294
+ * @param partials - Array of partial schemas to merge (optional, extracted from schemas if not provided)
295
+ * @returns Schema collection with partials merged into targets
296
+ */
297
+ declare function mergePartialSchemas(schemas: Record<string, LoadedSchema>, partials?: LoadedSchema[]): SchemaCollection;
287
298
  /**
288
299
  * The reserved name for the File schema (polymorphic file storage).
289
300
  */
@@ -1363,4 +1374,4 @@ declare class VersionStore {
1363
1374
  */
1364
1375
  declare function createVersionStore(config: VersionStoreConfig): VersionStore;
1365
1376
 
1366
- export { type AssociationMetadata, type ChangeAction, type CreateVersionOptions, type DefaultValueValidationResult, type DiffOperationResult, type ExpandedProperty, FILE_SCHEMA_NAME, type FormatOptions, type GenerateOptions, type GenerateResult, type GeneratedFile, type LoadResult, type LoadSchemaOptions, type LoadSchemasOptions, Omnify, OmnifyError, type OmnifyLogger, type OmnifyOptions, PluginManager, type PluginManagerOptions, type PluginRegistrationResult, type PluginRegistry, type PropertyMetadata, type RegisteredType, type SchemaError, type SchemaIntrospection, type SchemaMetadata, type SchemaValidationResult, type SchemaWarning, type ValidationOptions, type ValidationResult, type VersionChange, type VersionDiff, type VersionFile, type VersionIndexSnapshot, type VersionPropertySnapshot, type VersionSchemaSnapshot, VersionStore, type VersionStoreConfig, type VersionSummary, atlasError, atlasNotFoundError, circularReferenceError, configError, configNotFoundError, createFileLoadedSchema, createFileSchemaDefinition, createOmnify, createPluginManager, createVersionStore, duplicateSchemaError, ensureFileSchema, expandProperty, expandSchema, expandSchemaProperties, expandSchemas, fileNameToSchemaName, findReferencedSchemas, findReferencingSchemas, formatError, formatErrorPlain, formatErrorSummary, generateFileSchemaYaml, generationError, getAssociationMetadata, getCustomTypeNames, getEntitySchemas, getEnumSchemas, getExitCode, getGroups, getPropertyMetadata, getRelationshipGraph, getSchemaMetadata, getSchemaNames, getSchemasByGroup, getSchemasByKind, getTopologicalOrder, getTypeInfo, hasCircularReferences, internalError, introspectSchema, introspectSchemas, invalidAssociationTargetError, invalidConfigError, invalidPropertyTypeError, isCompoundType, jsonSyntaxError, loadSchema, loadSchemas, missingConfigFieldError, missingFieldError, notImplementedError, outputWriteError, parseJsonSchema, parseYamlSchema, pluginError, pluginNotFoundError, pluginTypeConflictError, schemaNotFoundError, schemaParseError, schemasHaveFileProperties, validateAssociations, validateDefaultValue, validateEnumSchema, validateOptions, validateProperties, validatePropertyType, validateSchema, validateSchemas, validationError, yamlSyntaxError };
1377
+ export { type AssociationMetadata, type ChangeAction, type CreateVersionOptions, type DefaultValueValidationResult, type DiffOperationResult, type ExpandedProperty, FILE_SCHEMA_NAME, type FormatOptions, type GenerateOptions, type GenerateResult, type GeneratedFile, type LoadResult, type LoadSchemaOptions, type LoadSchemasOptions, Omnify, OmnifyError, type OmnifyLogger, type OmnifyOptions, PluginManager, type PluginManagerOptions, type PluginRegistrationResult, type PluginRegistry, type PropertyMetadata, type RegisteredType, type SchemaError, type SchemaIntrospection, type SchemaMetadata, type SchemaValidationResult, type SchemaWarning, type ValidationOptions, type ValidationResult, type VersionChange, type VersionDiff, type VersionFile, type VersionIndexSnapshot, type VersionPropertySnapshot, type VersionSchemaSnapshot, VersionStore, type VersionStoreConfig, type VersionSummary, atlasError, atlasNotFoundError, circularReferenceError, configError, configNotFoundError, createFileLoadedSchema, createFileSchemaDefinition, createOmnify, createPluginManager, createVersionStore, duplicateSchemaError, ensureFileSchema, expandProperty, expandSchema, expandSchemaProperties, expandSchemas, fileNameToSchemaName, findReferencedSchemas, findReferencingSchemas, formatError, formatErrorPlain, formatErrorSummary, generateFileSchemaYaml, generationError, getAssociationMetadata, getCustomTypeNames, getEntitySchemas, getEnumSchemas, getExitCode, getGroups, getPropertyMetadata, getRelationshipGraph, getSchemaMetadata, getSchemaNames, getSchemasByGroup, getSchemasByKind, getTopologicalOrder, getTypeInfo, hasCircularReferences, internalError, introspectSchema, introspectSchemas, invalidAssociationTargetError, invalidConfigError, invalidPropertyTypeError, isCompoundType, jsonSyntaxError, loadSchema, loadSchemas, mergePartialSchemas, missingConfigFieldError, missingFieldError, notImplementedError, outputWriteError, parseJsonSchema, parseYamlSchema, pluginError, pluginNotFoundError, pluginTypeConflictError, schemaNotFoundError, schemaParseError, schemasHaveFileProperties, validateAssociations, validateDefaultValue, validateEnumSchema, validateOptions, validateProperties, validatePropertyType, validateSchema, validateSchemas, validationError, yamlSyntaxError };
package/dist/index.js CHANGED
@@ -844,7 +844,8 @@ async function findSchemaFiles(dirPath, extensions, recursive) {
844
844
  async function loadSchemas(directoryPath, options = {}) {
845
845
  const {
846
846
  extensions = [".yaml", ".yml", ".json"],
847
- recursive = true
847
+ recursive = true,
848
+ skipPartialResolution = false
848
849
  } = options;
849
850
  const absoluteDir = path.resolve(directoryPath);
850
851
  try {
@@ -879,16 +880,35 @@ async function loadSchemas(directoryPath, options = {}) {
879
880
  schemas[schema.name] = schema;
880
881
  schemaLocations[schema.name] = filePath;
881
882
  }
883
+ if (skipPartialResolution) {
884
+ for (const partial of partialSchemas) {
885
+ const partialKey = `__partial__${partial.name}`;
886
+ schemas[partialKey] = partial;
887
+ }
888
+ return schemas;
889
+ }
890
+ return mergePartialSchemas(schemas, partialSchemas);
891
+ }
892
+ function mergePartialSchemas(schemas, partials) {
893
+ const partialSchemas = partials ?? [];
894
+ const cleanSchemas = {};
895
+ for (const [key, schema] of Object.entries(schemas)) {
896
+ if (key.startsWith("__partial__")) {
897
+ partialSchemas.push(schema);
898
+ } else {
899
+ cleanSchemas[key] = schema;
900
+ }
901
+ }
882
902
  for (const partial of partialSchemas) {
883
903
  const targetName = partial.target;
884
904
  if (!targetName) {
885
905
  console.warn(`Partial schema '${partial.name}' has no target, skipping`);
886
906
  continue;
887
907
  }
888
- const target = schemas[targetName];
908
+ const target = cleanSchemas[targetName];
889
909
  if (!target) {
890
910
  if (partial.name === targetName) {
891
- schemas[partial.name] = {
911
+ cleanSchemas[partial.name] = {
892
912
  ...partial,
893
913
  kind: "object"
894
914
  };
@@ -901,12 +921,12 @@ async function loadSchemas(directoryPath, options = {}) {
901
921
  ...partial.properties ?? {},
902
922
  ...target.properties ?? {}
903
923
  };
904
- schemas[targetName] = {
924
+ cleanSchemas[targetName] = {
905
925
  ...target,
906
926
  properties: mergedProperties
907
927
  };
908
928
  }
909
- return schemas;
929
+ return cleanSchemas;
910
930
  }
911
931
  var FILE_SCHEMA_NAME = "File";
912
932
  function schemasHaveFileProperties(schemas) {
@@ -4656,6 +4676,7 @@ export {
4656
4676
  jsonSyntaxError,
4657
4677
  loadSchema,
4658
4678
  loadSchemas,
4679
+ mergePartialSchemas,
4659
4680
  missingConfigFieldError,
4660
4681
  missingFieldError,
4661
4682
  notImplementedError,