@famgia/omnify-core 0.0.128 → 0.0.129

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.js CHANGED
@@ -2369,6 +2369,9 @@ function validateDefaultValue(typeName, value, property) {
2369
2369
 
2370
2370
  // src/validation/validator.ts
2371
2371
  var VALID_ID_TYPES = ["Int", "BigInt", "Uuid", "String"];
2372
+ function toSnakeCase(str) {
2373
+ return str.replace(/([a-z])([A-Z])/g, "$1_$2").toLowerCase();
2374
+ }
2372
2375
  function buildLocation7(file, line, column) {
2373
2376
  const loc = { file };
2374
2377
  if (line !== void 0) {
@@ -2804,6 +2807,20 @@ function validateAssociations(schema, allSchemas) {
2804
2807
  )
2805
2808
  );
2806
2809
  }
2810
+ if (relation === "ManyToOne" || relation === "OneToOne" && !assocProp.mappedBy) {
2811
+ const expectedFkColumn = `${toSnakeCase(name)}_id`;
2812
+ if (schema.properties[expectedFkColumn]) {
2813
+ errors.push(
2814
+ validationError(
2815
+ `Duplicate FK definition: Property '${expectedFkColumn}' conflicts with Association '${name}'`,
2816
+ buildLocation7(schema.filePath),
2817
+ `Both create the same column '${expectedFkColumn}'. Choose one approach:
2818
+ 1. Use Association only (remove '${expectedFkColumn}' property) - recommended
2819
+ 2. Use explicit FK only (remove '${name}' Association)`
2820
+ )
2821
+ );
2822
+ }
2823
+ }
2807
2824
  }
2808
2825
  return errors;
2809
2826
  }