metal-orm 1.0.75 → 1.0.76

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "metal-orm",
3
- "version": "1.0.75",
3
+ "version": "1.0.76",
4
4
  "type": "module",
5
5
  "types": "./dist/index.d.ts",
6
6
  "engines": {
@@ -218,6 +218,7 @@ const METAL_ORM_IMPORT_ORDER = [
218
218
  'BelongsToMany',
219
219
  'HasManyCollection',
220
220
  'HasOneReference',
221
+ 'BelongsToReference',
221
222
  'ManyToManyCollection',
222
223
  'bootstrapEntities',
223
224
  'getTableDefFromEntity'
@@ -250,7 +251,7 @@ const renderEntityClassLines = ({ table, className, naming, relations, resolveCl
250
251
  lines.push(
251
252
  ` @BelongsTo({ target: () => ${targetClass}, foreignKey: '${escapeJsString(rel.foreignKey)}' })`
252
253
  );
253
- lines.push(` ${rel.property}?: ${targetClass};`);
254
+ lines.push(` ${rel.property}!: BelongsToReference<${targetClass}>;`);
254
255
  lines.push('');
255
256
  break;
256
257
  case 'hasMany':
@@ -301,6 +302,7 @@ const computeTableUsage = (table, relations, defaultSchema) => {
301
302
  needsBelongsToManyDecorator: false,
302
303
  needsHasManyCollection: false,
303
304
  needsHasOneReference: false,
305
+ needsBelongsToReference: false,
304
306
  needsManyToManyCollection: false
305
307
  };
306
308
 
@@ -325,6 +327,7 @@ const computeTableUsage = (table, relations, defaultSchema) => {
325
327
  }
326
328
  if (rel.kind === 'belongsTo') {
327
329
  usage.needsBelongsToDecorator = true;
330
+ usage.needsBelongsToReference = true;
328
331
  }
329
332
  if (rel.kind === 'belongsToMany') {
330
333
  usage.needsBelongsToManyDecorator = true;
@@ -347,6 +350,7 @@ const getMetalOrmImportNamesFromUsage = usage => {
347
350
  if (usage.needsBelongsToManyDecorator) names.add('BelongsToMany');
348
351
  if (usage.needsHasManyCollection) names.add('HasManyCollection');
349
352
  if (usage.needsHasOneReference) names.add('HasOneReference');
353
+ if (usage.needsBelongsToReference) names.add('BelongsToReference');
350
354
  if (usage.needsManyToManyCollection) names.add('ManyToManyCollection');
351
355
  return names;
352
356
  };
@@ -386,6 +390,7 @@ export const renderEntityFile = (schema, options) => {
386
390
  needsBelongsToManyDecorator: false,
387
391
  needsHasManyCollection: false,
388
392
  needsHasOneReference: false,
393
+ needsBelongsToReference: false,
389
394
  needsManyToManyCollection: false
390
395
  };
391
396
 
@@ -401,6 +406,7 @@ export const renderEntityFile = (schema, options) => {
401
406
  aggregateUsage.needsBelongsToManyDecorator ||= tableUsage.needsBelongsToManyDecorator;
402
407
  aggregateUsage.needsHasManyCollection ||= tableUsage.needsHasManyCollection;
403
408
  aggregateUsage.needsHasOneReference ||= tableUsage.needsHasOneReference;
409
+ aggregateUsage.needsBelongsToReference ||= tableUsage.needsBelongsToReference;
404
410
  aggregateUsage.needsManyToManyCollection ||= tableUsage.needsManyToManyCollection;
405
411
  }
406
412