@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.cjs +56 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +56 -8
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -665,10 +665,13 @@ function buildSchemaDefinition(data) {
|
|
|
665
665
|
}
|
|
666
666
|
}
|
|
667
667
|
if (data.properties !== void 0 && typeof data.properties === "object") {
|
|
668
|
-
const properties = buildProperties(data.properties);
|
|
668
|
+
const { properties, invalidProperties } = buildProperties(data.properties);
|
|
669
669
|
if (Object.keys(properties).length > 0) {
|
|
670
670
|
schema.properties = properties;
|
|
671
671
|
}
|
|
672
|
+
if (invalidProperties.length > 0) {
|
|
673
|
+
schema._invalidProperties = invalidProperties;
|
|
674
|
+
}
|
|
672
675
|
}
|
|
673
676
|
if (data.values !== void 0 && Array.isArray(data.values)) {
|
|
674
677
|
schema.values = data.values;
|
|
@@ -717,12 +720,25 @@ function buildSchemaOptions(data) {
|
|
|
717
720
|
}
|
|
718
721
|
function buildProperties(data) {
|
|
719
722
|
const properties = {};
|
|
723
|
+
const invalidProperties = [];
|
|
720
724
|
for (const [name, value] of Object.entries(data)) {
|
|
721
|
-
if (value
|
|
725
|
+
if (value === void 0 || value === null) {
|
|
726
|
+
continue;
|
|
727
|
+
}
|
|
728
|
+
if (typeof value === "object") {
|
|
722
729
|
properties[name] = buildPropertyDefinition(value);
|
|
730
|
+
} else {
|
|
731
|
+
invalidProperties.push({
|
|
732
|
+
propertyName: name,
|
|
733
|
+
value,
|
|
734
|
+
expectedFormat: `Property '${name}' must be an object with 'type' field. Example:
|
|
735
|
+
${name}:
|
|
736
|
+
type: String
|
|
737
|
+
nullable: true`
|
|
738
|
+
});
|
|
723
739
|
}
|
|
724
740
|
}
|
|
725
|
-
return properties;
|
|
741
|
+
return { properties, invalidProperties };
|
|
726
742
|
}
|
|
727
743
|
var VALID_PROPERTY_FIELDS = /* @__PURE__ */ new Set([
|
|
728
744
|
"type",
|
|
@@ -2206,6 +2222,25 @@ function validateUnknownOptionsFields(schema, filePath) {
|
|
|
2206
2222
|
}
|
|
2207
2223
|
return errors;
|
|
2208
2224
|
}
|
|
2225
|
+
function validatePropertyFormat(schema, filePath) {
|
|
2226
|
+
const errors = [];
|
|
2227
|
+
const invalidProperties = schema._invalidProperties;
|
|
2228
|
+
if (!invalidProperties || invalidProperties.length === 0) {
|
|
2229
|
+
return errors;
|
|
2230
|
+
}
|
|
2231
|
+
for (const invalid of invalidProperties) {
|
|
2232
|
+
const valueType = typeof invalid.value;
|
|
2233
|
+
const valuePreview = valueType === "string" ? `"${invalid.value}"` : String(invalid.value);
|
|
2234
|
+
errors.push(
|
|
2235
|
+
validationError(
|
|
2236
|
+
`Property '${invalid.propertyName}' has invalid format: got ${valueType} (${valuePreview})`,
|
|
2237
|
+
buildLocation7(filePath),
|
|
2238
|
+
invalid.expectedFormat
|
|
2239
|
+
)
|
|
2240
|
+
);
|
|
2241
|
+
}
|
|
2242
|
+
return errors;
|
|
2243
|
+
}
|
|
2209
2244
|
function validateDbCompatibility(propertyName, property, filePath, databaseDriver) {
|
|
2210
2245
|
const errors = [];
|
|
2211
2246
|
const warnings = [];
|
|
@@ -2535,6 +2570,8 @@ function validateSchema(schema, options = {}) {
|
|
|
2535
2570
|
errors.push(...unknownSchemaFieldErrors);
|
|
2536
2571
|
const unknownOptionsErrors = validateUnknownOptionsFields(schema, schema.filePath);
|
|
2537
2572
|
errors.push(...unknownOptionsErrors);
|
|
2573
|
+
const propertyFormatErrors = validatePropertyFormat(schema, schema.filePath);
|
|
2574
|
+
errors.push(...propertyFormatErrors);
|
|
2538
2575
|
const propErrors = validateProperties(schema, schema.filePath, customTypes);
|
|
2539
2576
|
errors.push(...propErrors);
|
|
2540
2577
|
const optErrors = validateOptions(schema, schema.filePath);
|
|
@@ -2652,8 +2689,10 @@ var GeneratorRunner = class {
|
|
|
2652
2689
|
}
|
|
2653
2690
|
/**
|
|
2654
2691
|
* Run all generators in topological order.
|
|
2692
|
+
* @param schemas - The schemas to generate from
|
|
2693
|
+
* @param changes - Schema changes detected from lock file comparison
|
|
2655
2694
|
*/
|
|
2656
|
-
async runAll(schemas) {
|
|
2695
|
+
async runAll(schemas, changes) {
|
|
2657
2696
|
const errors = [];
|
|
2658
2697
|
const outputs = [];
|
|
2659
2698
|
const outputsByGenerator = /* @__PURE__ */ new Map();
|
|
@@ -2681,10 +2720,12 @@ var GeneratorRunner = class {
|
|
|
2681
2720
|
this.options.logger.debug(`Running generator: ${name}`);
|
|
2682
2721
|
const ctx = {
|
|
2683
2722
|
schemas,
|
|
2723
|
+
changes,
|
|
2684
2724
|
pluginConfig,
|
|
2685
2725
|
cwd: this.options.cwd,
|
|
2686
2726
|
logger: this.options.logger,
|
|
2687
|
-
previousOutputs
|
|
2727
|
+
previousOutputs,
|
|
2728
|
+
customTypes: this.options.customTypes ?? /* @__PURE__ */ new Map()
|
|
2688
2729
|
};
|
|
2689
2730
|
const result = await definition.generate(ctx);
|
|
2690
2731
|
const generatorOutputs = Array.isArray(result) ? result : [result];
|
|
@@ -3036,17 +3077,24 @@ var PluginManager = class {
|
|
|
3036
3077
|
/**
|
|
3037
3078
|
* Runs all registered generators in topological order.
|
|
3038
3079
|
* @param schemas - The schemas to generate from
|
|
3080
|
+
* @param changes - Schema changes detected from lock file comparison
|
|
3039
3081
|
* @returns Result with all generated outputs
|
|
3040
3082
|
*/
|
|
3041
|
-
async runGenerators(schemas) {
|
|
3083
|
+
async runGenerators(schemas, changes) {
|
|
3084
|
+
const customTypes = /* @__PURE__ */ new Map();
|
|
3085
|
+
for (const [name, registeredType] of this._types) {
|
|
3086
|
+
const { pluginName, pluginVersion, ...typeDefinition } = registeredType;
|
|
3087
|
+
customTypes.set(name, typeDefinition);
|
|
3088
|
+
}
|
|
3042
3089
|
const runner = new GeneratorRunner({
|
|
3043
3090
|
cwd: this._cwd,
|
|
3044
|
-
logger: this._logger
|
|
3091
|
+
logger: this._logger,
|
|
3092
|
+
customTypes
|
|
3045
3093
|
});
|
|
3046
3094
|
for (const gen of this._generators.values()) {
|
|
3047
3095
|
runner.register(gen);
|
|
3048
3096
|
}
|
|
3049
|
-
return runner.runAll(schemas);
|
|
3097
|
+
return runner.runAll(schemas, changes);
|
|
3050
3098
|
}
|
|
3051
3099
|
/**
|
|
3052
3100
|
* Clears all registered plugins, types, and generators.
|