@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.cjs
CHANGED
|
@@ -647,6 +647,9 @@ function buildSchemaDefinition(data) {
|
|
|
647
647
|
if (data.target !== void 0 && typeof data.target === "string") {
|
|
648
648
|
schema.target = data.target;
|
|
649
649
|
}
|
|
650
|
+
if (data.priority !== void 0 && typeof data.priority === "number") {
|
|
651
|
+
schema.priority = data.priority;
|
|
652
|
+
}
|
|
650
653
|
if (data.displayName !== void 0 && (0, import_omnify_types.isLocalizedString)(data.displayName)) {
|
|
651
654
|
schema.displayName = data.displayName;
|
|
652
655
|
}
|
|
@@ -1011,6 +1014,11 @@ function mergePartialSchemas(schemas, partials) {
|
|
|
1011
1014
|
cleanSchemas[key] = schema;
|
|
1012
1015
|
}
|
|
1013
1016
|
}
|
|
1017
|
+
partialSchemas.sort((a, b) => {
|
|
1018
|
+
const priorityA = a.priority ?? 50;
|
|
1019
|
+
const priorityB = b.priority ?? 50;
|
|
1020
|
+
return priorityA - priorityB;
|
|
1021
|
+
});
|
|
1014
1022
|
for (const partial of partialSchemas) {
|
|
1015
1023
|
const targetName = partial.target;
|
|
1016
1024
|
if (!targetName) {
|
|
@@ -2481,6 +2489,9 @@ function validateDefaultValue(typeName, value, property) {
|
|
|
2481
2489
|
|
|
2482
2490
|
// src/validation/validator.ts
|
|
2483
2491
|
var VALID_ID_TYPES = ["Int", "BigInt", "Uuid", "String"];
|
|
2492
|
+
function toSnakeCase(str) {
|
|
2493
|
+
return str.replace(/([a-z])([A-Z])/g, "$1_$2").toLowerCase();
|
|
2494
|
+
}
|
|
2484
2495
|
function buildLocation7(file, line, column) {
|
|
2485
2496
|
const loc = { file };
|
|
2486
2497
|
if (line !== void 0) {
|
|
@@ -2916,6 +2927,20 @@ function validateAssociations(schema, allSchemas) {
|
|
|
2916
2927
|
)
|
|
2917
2928
|
);
|
|
2918
2929
|
}
|
|
2930
|
+
if (relation === "ManyToOne" || relation === "OneToOne" && !assocProp.mappedBy) {
|
|
2931
|
+
const expectedFkColumn = `${toSnakeCase(name)}_id`;
|
|
2932
|
+
if (schema.properties[expectedFkColumn]) {
|
|
2933
|
+
errors.push(
|
|
2934
|
+
validationError(
|
|
2935
|
+
`Duplicate FK definition: Property '${expectedFkColumn}' conflicts with Association '${name}'`,
|
|
2936
|
+
buildLocation7(schema.filePath),
|
|
2937
|
+
`Both create the same column '${expectedFkColumn}'. Choose one approach:
|
|
2938
|
+
1. Use Association only (remove '${expectedFkColumn}' property) - recommended
|
|
2939
|
+
2. Use explicit FK only (remove '${name}' Association)`
|
|
2940
|
+
)
|
|
2941
|
+
);
|
|
2942
|
+
}
|
|
2943
|
+
}
|
|
2919
2944
|
}
|
|
2920
2945
|
return errors;
|
|
2921
2946
|
}
|
|
@@ -3046,6 +3071,25 @@ function validatePartialSchema(schema, filePath) {
|
|
|
3046
3071
|
)
|
|
3047
3072
|
);
|
|
3048
3073
|
}
|
|
3074
|
+
if (schema.priority !== void 0) {
|
|
3075
|
+
if (typeof schema.priority !== "number") {
|
|
3076
|
+
errors.push(
|
|
3077
|
+
validationError(
|
|
3078
|
+
"Partial schema priority must be a number",
|
|
3079
|
+
buildLocation7(filePath),
|
|
3080
|
+
"Example: priority: 10 (lower = higher priority, default is 50)"
|
|
3081
|
+
)
|
|
3082
|
+
);
|
|
3083
|
+
} else if (schema.priority < 1 || schema.priority > 100) {
|
|
3084
|
+
errors.push(
|
|
3085
|
+
validationError(
|
|
3086
|
+
`Partial schema priority must be between 1 and 100 (got ${schema.priority})`,
|
|
3087
|
+
buildLocation7(filePath),
|
|
3088
|
+
"Use 1-49 for high priority, 51-100 for low priority (default is 50)"
|
|
3089
|
+
)
|
|
3090
|
+
);
|
|
3091
|
+
}
|
|
3092
|
+
}
|
|
3049
3093
|
if (!schema.properties || Object.keys(schema.properties).length === 0) {
|
|
3050
3094
|
errors.push(
|
|
3051
3095
|
validationError(
|