@famgia/omnify-core 0.0.13 → 0.0.14

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
@@ -1,4 +1,4 @@
1
- import { ErrorCode, ErrorLocation, OmnifyErrorInfo, LoadedSchema, SchemaCollection, SchemaDefinition, PropertyDefinition, PluginLogger, CustomTypeDefinition, GeneratorDefinition, OmnifyPlugin, GeneratorOutput, OmnifyConfig, AssociationDefinition } from '@famgia/omnify-types';
1
+ import { ErrorCode, ErrorLocation, OmnifyErrorInfo, LoadedSchema, SchemaCollection, SchemaDefinition, PropertyDefinition, PluginLogger, CustomTypeDefinition, GeneratorDefinition, OmnifyPlugin, GeneratorOutput, SchemaChange, OmnifyConfig, AssociationDefinition } from '@famgia/omnify-types';
2
2
  export { AssociationRelation, CustomTypeDefinition, DatabaseConfig, ErrorCode, ErrorLocation, LoadedSchema, OmnifyConfig, OmnifyErrorInfo, OmnifyPlugin, OutputConfig, PropertyDefinition, PropertyType, Result, SchemaCollection, SchemaDefinition, SchemaOptions, err, ok } from '@famgia/omnify-types';
3
3
 
4
4
  /**
@@ -624,9 +624,10 @@ declare class PluginManager {
624
624
  /**
625
625
  * Runs all registered generators in topological order.
626
626
  * @param schemas - The schemas to generate from
627
+ * @param changes - Schema changes detected from lock file comparison
627
628
  * @returns Result with all generated outputs
628
629
  */
629
- runGenerators(schemas: SchemaCollection): Promise<GeneratorRunResult>;
630
+ runGenerators(schemas: SchemaCollection, changes?: readonly SchemaChange[]): Promise<GeneratorRunResult>;
630
631
  /**
631
632
  * Clears all registered plugins, types, and generators.
632
633
  */
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ErrorCode, ErrorLocation, OmnifyErrorInfo, LoadedSchema, SchemaCollection, SchemaDefinition, PropertyDefinition, PluginLogger, CustomTypeDefinition, GeneratorDefinition, OmnifyPlugin, GeneratorOutput, OmnifyConfig, AssociationDefinition } from '@famgia/omnify-types';
1
+ import { ErrorCode, ErrorLocation, OmnifyErrorInfo, LoadedSchema, SchemaCollection, SchemaDefinition, PropertyDefinition, PluginLogger, CustomTypeDefinition, GeneratorDefinition, OmnifyPlugin, GeneratorOutput, SchemaChange, OmnifyConfig, AssociationDefinition } from '@famgia/omnify-types';
2
2
  export { AssociationRelation, CustomTypeDefinition, DatabaseConfig, ErrorCode, ErrorLocation, LoadedSchema, OmnifyConfig, OmnifyErrorInfo, OmnifyPlugin, OutputConfig, PropertyDefinition, PropertyType, Result, SchemaCollection, SchemaDefinition, SchemaOptions, err, ok } from '@famgia/omnify-types';
3
3
 
4
4
  /**
@@ -624,9 +624,10 @@ declare class PluginManager {
624
624
  /**
625
625
  * Runs all registered generators in topological order.
626
626
  * @param schemas - The schemas to generate from
627
+ * @param changes - Schema changes detected from lock file comparison
627
628
  * @returns Result with all generated outputs
628
629
  */
629
- runGenerators(schemas: SchemaCollection): Promise<GeneratorRunResult>;
630
+ runGenerators(schemas: SchemaCollection, changes?: readonly SchemaChange[]): Promise<GeneratorRunResult>;
630
631
  /**
631
632
  * Clears all registered plugins, types, and generators.
632
633
  */
package/dist/index.js CHANGED
@@ -554,10 +554,13 @@ function buildSchemaDefinition(data) {
554
554
  }
555
555
  }
556
556
  if (data.properties !== void 0 && typeof data.properties === "object") {
557
- const properties = buildProperties(data.properties);
557
+ const { properties, invalidProperties } = buildProperties(data.properties);
558
558
  if (Object.keys(properties).length > 0) {
559
559
  schema.properties = properties;
560
560
  }
561
+ if (invalidProperties.length > 0) {
562
+ schema._invalidProperties = invalidProperties;
563
+ }
561
564
  }
562
565
  if (data.values !== void 0 && Array.isArray(data.values)) {
563
566
  schema.values = data.values;
@@ -606,12 +609,25 @@ function buildSchemaOptions(data) {
606
609
  }
607
610
  function buildProperties(data) {
608
611
  const properties = {};
612
+ const invalidProperties = [];
609
613
  for (const [name, value] of Object.entries(data)) {
610
- if (value !== void 0 && typeof value === "object" && value !== null) {
614
+ if (value === void 0 || value === null) {
615
+ continue;
616
+ }
617
+ if (typeof value === "object") {
611
618
  properties[name] = buildPropertyDefinition(value);
619
+ } else {
620
+ invalidProperties.push({
621
+ propertyName: name,
622
+ value,
623
+ expectedFormat: `Property '${name}' must be an object with 'type' field. Example:
624
+ ${name}:
625
+ type: String
626
+ nullable: true`
627
+ });
612
628
  }
613
629
  }
614
- return properties;
630
+ return { properties, invalidProperties };
615
631
  }
616
632
  var VALID_PROPERTY_FIELDS = /* @__PURE__ */ new Set([
617
633
  "type",
@@ -2095,6 +2111,25 @@ function validateUnknownOptionsFields(schema, filePath) {
2095
2111
  }
2096
2112
  return errors;
2097
2113
  }
2114
+ function validatePropertyFormat(schema, filePath) {
2115
+ const errors = [];
2116
+ const invalidProperties = schema._invalidProperties;
2117
+ if (!invalidProperties || invalidProperties.length === 0) {
2118
+ return errors;
2119
+ }
2120
+ for (const invalid of invalidProperties) {
2121
+ const valueType = typeof invalid.value;
2122
+ const valuePreview = valueType === "string" ? `"${invalid.value}"` : String(invalid.value);
2123
+ errors.push(
2124
+ validationError(
2125
+ `Property '${invalid.propertyName}' has invalid format: got ${valueType} (${valuePreview})`,
2126
+ buildLocation7(filePath),
2127
+ invalid.expectedFormat
2128
+ )
2129
+ );
2130
+ }
2131
+ return errors;
2132
+ }
2098
2133
  function validateDbCompatibility(propertyName, property, filePath, databaseDriver) {
2099
2134
  const errors = [];
2100
2135
  const warnings = [];
@@ -2424,6 +2459,8 @@ function validateSchema(schema, options = {}) {
2424
2459
  errors.push(...unknownSchemaFieldErrors);
2425
2460
  const unknownOptionsErrors = validateUnknownOptionsFields(schema, schema.filePath);
2426
2461
  errors.push(...unknownOptionsErrors);
2462
+ const propertyFormatErrors = validatePropertyFormat(schema, schema.filePath);
2463
+ errors.push(...propertyFormatErrors);
2427
2464
  const propErrors = validateProperties(schema, schema.filePath, customTypes);
2428
2465
  errors.push(...propErrors);
2429
2466
  const optErrors = validateOptions(schema, schema.filePath);
@@ -2541,8 +2578,10 @@ var GeneratorRunner = class {
2541
2578
  }
2542
2579
  /**
2543
2580
  * Run all generators in topological order.
2581
+ * @param schemas - The schemas to generate from
2582
+ * @param changes - Schema changes detected from lock file comparison
2544
2583
  */
2545
- async runAll(schemas) {
2584
+ async runAll(schemas, changes) {
2546
2585
  const errors = [];
2547
2586
  const outputs = [];
2548
2587
  const outputsByGenerator = /* @__PURE__ */ new Map();
@@ -2570,10 +2609,12 @@ var GeneratorRunner = class {
2570
2609
  this.options.logger.debug(`Running generator: ${name}`);
2571
2610
  const ctx = {
2572
2611
  schemas,
2612
+ changes,
2573
2613
  pluginConfig,
2574
2614
  cwd: this.options.cwd,
2575
2615
  logger: this.options.logger,
2576
- previousOutputs
2616
+ previousOutputs,
2617
+ customTypes: this.options.customTypes ?? /* @__PURE__ */ new Map()
2577
2618
  };
2578
2619
  const result = await definition.generate(ctx);
2579
2620
  const generatorOutputs = Array.isArray(result) ? result : [result];
@@ -2925,17 +2966,24 @@ var PluginManager = class {
2925
2966
  /**
2926
2967
  * Runs all registered generators in topological order.
2927
2968
  * @param schemas - The schemas to generate from
2969
+ * @param changes - Schema changes detected from lock file comparison
2928
2970
  * @returns Result with all generated outputs
2929
2971
  */
2930
- async runGenerators(schemas) {
2972
+ async runGenerators(schemas, changes) {
2973
+ const customTypes = /* @__PURE__ */ new Map();
2974
+ for (const [name, registeredType] of this._types) {
2975
+ const { pluginName, pluginVersion, ...typeDefinition } = registeredType;
2976
+ customTypes.set(name, typeDefinition);
2977
+ }
2931
2978
  const runner = new GeneratorRunner({
2932
2979
  cwd: this._cwd,
2933
- logger: this._logger
2980
+ logger: this._logger,
2981
+ customTypes
2934
2982
  });
2935
2983
  for (const gen of this._generators.values()) {
2936
2984
  runner.register(gen);
2937
2985
  }
2938
- return runner.runAll(schemas);
2986
+ return runner.runAll(schemas, changes);
2939
2987
  }
2940
2988
  /**
2941
2989
  * Clears all registered plugins, types, and generators.