@famgia/omnify-typescript 2.0.34 → 2.0.35

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
@@ -24,7 +24,7 @@ import {
24
24
  toEnumName,
25
25
  toInterfaceName,
26
26
  toPropertyName
27
- } from "./chunk-XOH4DFMH.js";
27
+ } from "./chunk-RBAAB73K.js";
28
28
 
29
29
  // src/ai-guides/generator.ts
30
30
  import { existsSync, readdirSync } from "fs";
package/dist/plugin.cjs CHANGED
@@ -210,6 +210,34 @@ function propertyToTSProperties(propertyName, property, allSchemas, options = {}
210
210
  }
211
211
  ];
212
212
  }
213
+ if ((assocProp.relation === "ManyToOne" || assocProp.relation === "OneToOne") && !assocProp.mappedBy) {
214
+ const propBaseName = toPropertyName(propertyName);
215
+ const targetName = assocProp.target ?? "unknown";
216
+ const isNullable = baseProp.nullable ?? false;
217
+ let fkType = "number";
218
+ const targetSchema = assocProp.target ? allSchemas[assocProp.target] : void 0;
219
+ const effectiveIdType = assocProp.idType ?? targetSchema?.options?.idType ?? "BigInt";
220
+ if (effectiveIdType === "Uuid" || effectiveIdType === "String") {
221
+ fkType = "string";
222
+ }
223
+ return [
224
+ {
225
+ name: `${propBaseName}_id`,
226
+ type: fkType,
227
+ optional: isNullable,
228
+ readonly: isReadonly,
229
+ comment: `Foreign key for ${propertyName}`
230
+ },
231
+ {
232
+ name: propBaseName,
233
+ type: isNullable ? `${targetName} | null` : targetName,
234
+ optional: true,
235
+ // Relation may not be loaded
236
+ readonly: isReadonly,
237
+ comment: displayName ?? `Relation to ${targetName}`
238
+ }
239
+ ];
240
+ }
213
241
  }
214
242
  const type = getPropertyType(property, allSchemas);
215
243
  return [{