@famgia/omnify-core 0.0.128 → 0.0.130
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 +44 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +44 -0
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -535,6 +535,9 @@ function buildSchemaDefinition(data) {
|
|
|
535
535
|
if (data.target !== void 0 && typeof data.target === "string") {
|
|
536
536
|
schema.target = data.target;
|
|
537
537
|
}
|
|
538
|
+
if (data.priority !== void 0 && typeof data.priority === "number") {
|
|
539
|
+
schema.priority = data.priority;
|
|
540
|
+
}
|
|
538
541
|
if (data.displayName !== void 0 && isLocalizedString(data.displayName)) {
|
|
539
542
|
schema.displayName = data.displayName;
|
|
540
543
|
}
|
|
@@ -899,6 +902,11 @@ function mergePartialSchemas(schemas, partials) {
|
|
|
899
902
|
cleanSchemas[key] = schema;
|
|
900
903
|
}
|
|
901
904
|
}
|
|
905
|
+
partialSchemas.sort((a, b) => {
|
|
906
|
+
const priorityA = a.priority ?? 50;
|
|
907
|
+
const priorityB = b.priority ?? 50;
|
|
908
|
+
return priorityA - priorityB;
|
|
909
|
+
});
|
|
902
910
|
for (const partial of partialSchemas) {
|
|
903
911
|
const targetName = partial.target;
|
|
904
912
|
if (!targetName) {
|
|
@@ -2369,6 +2377,9 @@ function validateDefaultValue(typeName, value, property) {
|
|
|
2369
2377
|
|
|
2370
2378
|
// src/validation/validator.ts
|
|
2371
2379
|
var VALID_ID_TYPES = ["Int", "BigInt", "Uuid", "String"];
|
|
2380
|
+
function toSnakeCase(str) {
|
|
2381
|
+
return str.replace(/([a-z])([A-Z])/g, "$1_$2").toLowerCase();
|
|
2382
|
+
}
|
|
2372
2383
|
function buildLocation7(file, line, column) {
|
|
2373
2384
|
const loc = { file };
|
|
2374
2385
|
if (line !== void 0) {
|
|
@@ -2804,6 +2815,20 @@ function validateAssociations(schema, allSchemas) {
|
|
|
2804
2815
|
)
|
|
2805
2816
|
);
|
|
2806
2817
|
}
|
|
2818
|
+
if (relation === "ManyToOne" || relation === "OneToOne" && !assocProp.mappedBy) {
|
|
2819
|
+
const expectedFkColumn = `${toSnakeCase(name)}_id`;
|
|
2820
|
+
if (schema.properties[expectedFkColumn]) {
|
|
2821
|
+
errors.push(
|
|
2822
|
+
validationError(
|
|
2823
|
+
`Duplicate FK definition: Property '${expectedFkColumn}' conflicts with Association '${name}'`,
|
|
2824
|
+
buildLocation7(schema.filePath),
|
|
2825
|
+
`Both create the same column '${expectedFkColumn}'. Choose one approach:
|
|
2826
|
+
1. Use Association only (remove '${expectedFkColumn}' property) - recommended
|
|
2827
|
+
2. Use explicit FK only (remove '${name}' Association)`
|
|
2828
|
+
)
|
|
2829
|
+
);
|
|
2830
|
+
}
|
|
2831
|
+
}
|
|
2807
2832
|
}
|
|
2808
2833
|
return errors;
|
|
2809
2834
|
}
|
|
@@ -2934,6 +2959,25 @@ function validatePartialSchema(schema, filePath) {
|
|
|
2934
2959
|
)
|
|
2935
2960
|
);
|
|
2936
2961
|
}
|
|
2962
|
+
if (schema.priority !== void 0) {
|
|
2963
|
+
if (typeof schema.priority !== "number") {
|
|
2964
|
+
errors.push(
|
|
2965
|
+
validationError(
|
|
2966
|
+
"Partial schema priority must be a number",
|
|
2967
|
+
buildLocation7(filePath),
|
|
2968
|
+
"Example: priority: 10 (lower = higher priority, default is 50)"
|
|
2969
|
+
)
|
|
2970
|
+
);
|
|
2971
|
+
} else if (schema.priority < 1 || schema.priority > 100) {
|
|
2972
|
+
errors.push(
|
|
2973
|
+
validationError(
|
|
2974
|
+
`Partial schema priority must be between 1 and 100 (got ${schema.priority})`,
|
|
2975
|
+
buildLocation7(filePath),
|
|
2976
|
+
"Use 1-49 for high priority, 51-100 for low priority (default is 50)"
|
|
2977
|
+
)
|
|
2978
|
+
);
|
|
2979
|
+
}
|
|
2980
|
+
}
|
|
2937
2981
|
if (!schema.properties || Object.keys(schema.properties).length === 0) {
|
|
2938
2982
|
errors.push(
|
|
2939
2983
|
validationError(
|