topsyde-utils 1.0.203 → 1.0.204

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.
@@ -25,8 +25,7 @@ export declare abstract class Dto {
25
25
  * @param options - Class transformer options
26
26
  * @returns New instance of the DTO
27
27
  */
28
- static Create<T extends Dto>(this: ClassConstructor<T>, // 🔑 Key change: use 'this' parameter
29
- data: Record<string, unknown>, options?: ClassTransformOptions): T;
28
+ static Create<T extends Dto>(this: ClassConstructor<T>, data: Record<string, unknown>, options?: ClassTransformOptions): T;
30
29
  /**
31
30
  * Creates an array of DTOs from an array of plain objects
32
31
  */
@@ -40,10 +40,8 @@ export class Dto {
40
40
  * @param options - Class transformer options
41
41
  * @returns New instance of the DTO
42
42
  */
43
- static Create(// 🔑 Key change: use 'this' parameter
44
- data, options = {}) {
43
+ static Create(data, options = {}) {
45
44
  const instance = plainToInstance(this, data, {
46
- // 🔑 Use 'this' instead of 'cls'
47
45
  ...Dto.defaultTransformOptions,
48
46
  ...options,
49
47
  });
@@ -1 +1 @@
1
- {"version":3,"file":"BaseDto.js","sourceRoot":"","sources":["../../src/utils/BaseDto.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,MAAM,MAAM,UAAU,CAAC;AAC9B,OAAO,EAAmB,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEhE;;GAEG;AACH,MAAM,OAAgB,GAAG;IAWxB;;;OAGG;IACI,QAAQ;QACd,MAAM,MAAM,GAAG,YAAY,CAAC,IAAI,EAAE;YACjC,eAAe,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE;YAClC,mBAAmB,EAAE,IAAI;SACzB,CAAC,CAAC;QACH,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACvB,MAAM,MAAM,CAAC;QACd,CAAC;QACD,OAAO,MAAM,CAAC;IACf,CAAC;IAED;;;;OAIG;IACI,MAAM,CAA8B,oBAA6B,IAAI,EAAE,OAA+B;QAC5G,MAAM,KAAK,GAAG,eAAe,CAAC,IAAI,EAAE;YACnC,GAAG,GAAG,CAAC,uBAAuB;YAC9B,GAAG,OAAO;SACV,CAAM,CAAC;QAER,IAAI,CAAC,iBAAiB,EAAE,CAAC;YACxB,OAAO,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,KAAgC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAM,CAAC;QACvH,CAAC;QAED,OAAO,KAAK,CAAC;IACd,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,MAAM,CACQ,sCAAsC;IACjE,IAA6B,EAC7B,UAAiC,EAAE;QAEnC,MAAM,QAAQ,GAAG,eAAe,CAAC,IAAI,EAAE,IAAI,EAAE;YAC5C,iCAAiC;YACjC,GAAG,GAAG,CAAC,uBAAuB;YAC9B,GAAG,OAAO;SACV,CAAC,CAAC;QAEH,OAAO,QAAQ,CAAC;IACjB,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,UAAU,CAA2C,SAAoC,EAAE,UAAiC,EAAE;QAC3I,OAAO,eAAe,CAAC,IAAI,EAAE,SAAS,EAAE;YACvC,GAAG,GAAG,CAAC,uBAAuB;YAC9B,GAAG,OAAO;SACV,CAAQ,CAAC;IACX,CAAC;;AAvED;;GAEG;AACuB,2BAAuB,GAA0B;IAC1E,uBAAuB,EAAE,IAAI;IAC7B,mBAAmB,EAAE,IAAI;IACzB,mBAAmB,EAAE,IAAI;IACzB,wBAAwB,EAAE,KAAK,EAAE,uDAAuD;CACxF,CAAC","sourcesContent":["import type { ClassConstructor, ClassTransformOptions } from \"class-transformer\";\nimport { instanceToPlain, plainToInstance } from \"class-transformer\";\nimport Guards from \"./Guards\";\nimport { ValidationError, validateSync } from \"class-validator\";\n\n/**\n * Base typesafe class for Data Transfer Objects (DTOs)\n */\nexport abstract class Dto {\n\t/**\n\t * Default options for class transformation\n\t */\n\tprotected static readonly defaultTransformOptions: ClassTransformOptions = {\n\t\texcludeExtraneousValues: true,\n\t\tenableCircularCheck: true,\n\t\texposeDefaultValues: true,\n\t\tenableImplicitConversion: false, // Safer default, especially when using class-validator\n\t};\n\n\t/**\n\t * Validates the DTO instance\n\t * @throws ValidationError[] if validation fails\n\t */\n\tpublic validate(): ValidationError[] {\n\t\tconst errors = validateSync(this, {\n\t\t\tvalidationError: { target: false },\n\t\t\tforbidUnknownValues: true,\n\t\t});\n\t\tif (errors.length > 0) {\n\t\t\tthrow errors;\n\t\t}\n\t\treturn errors;\n\t}\n\n\t/**\n\t * Converts the DTO to a plain object\n\t * @param options - Class transformer options for controlling exposure and transformation\n\t * @returns Plain object representation of the DTO\n\t */\n\tpublic toJSON<T = Record<string, unknown>>(include_undefined: boolean = true, options?: ClassTransformOptions): T {\n\t\tconst value = instanceToPlain(this, {\n\t\t\t...Dto.defaultTransformOptions,\n\t\t\t...options,\n\t\t}) as T;\n\n\t\tif (!include_undefined) {\n\t\t\treturn Object.fromEntries(Object.entries(value as Record<string, unknown>).filter(([_, v]) => !Guards.IsNil(v))) as T;\n\t\t}\n\n\t\treturn value;\n\t}\n\n\t/**\n\t * Creates a new instance of the DTO with validation (infers class from `this`)\n\t * @param data - Data to create the DTO from\n\t * @param options - Class transformer options\n\t * @returns New instance of the DTO\n\t */\n\tpublic static Create<T extends Dto>(\n\t\tthis: ClassConstructor<T>, // 🔑 Key change: use 'this' parameter\n\t\tdata: Record<string, unknown>,\n\t\toptions: ClassTransformOptions = {},\n\t): T {\n\t\tconst instance = plainToInstance(this, data, {\n\t\t\t// 🔑 Use 'this' instead of 'cls'\n\t\t\t...Dto.defaultTransformOptions,\n\t\t\t...options,\n\t\t});\n\n\t\treturn instance;\n\t}\n\n\t/**\n\t * Creates an array of DTOs from an array of plain objects\n\t */\n\tpublic static CreateMany<T extends Dto>(this: ClassConstructor<T>, dataArray: Record<string, unknown>[], options: ClassTransformOptions = {}): T[] {\n\t\treturn plainToInstance(this, dataArray, {\n\t\t\t...Dto.defaultTransformOptions,\n\t\t\t...options,\n\t\t}) as T[];\n\t}\n}\n"]}
1
+ {"version":3,"file":"BaseDto.js","sourceRoot":"","sources":["../../src/utils/BaseDto.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,MAAM,MAAM,UAAU,CAAC;AAC9B,OAAO,EAAmB,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEhE;;GAEG;AACH,MAAM,OAAgB,GAAG;IAWxB;;;OAGG;IACI,QAAQ;QACd,MAAM,MAAM,GAAG,YAAY,CAAC,IAAI,EAAE;YACjC,eAAe,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE;YAClC,mBAAmB,EAAE,IAAI;SACzB,CAAC,CAAC;QACH,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACvB,MAAM,MAAM,CAAC;QACd,CAAC;QACD,OAAO,MAAM,CAAC;IACf,CAAC;IAED;;;;OAIG;IACI,MAAM,CAA8B,oBAA6B,IAAI,EAAE,OAA+B;QAC5G,MAAM,KAAK,GAAG,eAAe,CAAC,IAAI,EAAE;YACnC,GAAG,GAAG,CAAC,uBAAuB;YAC9B,GAAG,OAAO;SACV,CAAM,CAAC;QAER,IAAI,CAAC,iBAAiB,EAAE,CAAC;YACxB,OAAO,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,KAAgC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAM,CAAC;QACvH,CAAC;QAED,OAAO,KAAK,CAAC;IACd,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,MAAM,CAA2C,IAA6B,EAAE,UAAiC,EAAE;QAChI,MAAM,QAAQ,GAAG,eAAe,CAAC,IAAI,EAAE,IAAI,EAAE;YAC5C,GAAG,GAAG,CAAC,uBAAuB;YAC9B,GAAG,OAAO;SACV,CAAC,CAAC;QAEH,OAAO,QAAQ,CAAC;IACjB,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,UAAU,CAA2C,SAAoC,EAAE,UAAiC,EAAE;QAC3I,OAAO,eAAe,CAAC,IAAI,EAAE,SAAS,EAAE;YACvC,GAAG,GAAG,CAAC,uBAAuB;YAC9B,GAAG,OAAO;SACV,CAAQ,CAAC;IACX,CAAC;;AAlED;;GAEG;AACuB,2BAAuB,GAA0B;IAC1E,uBAAuB,EAAE,IAAI;IAC7B,mBAAmB,EAAE,IAAI;IACzB,mBAAmB,EAAE,IAAI;IACzB,wBAAwB,EAAE,KAAK,EAAE,uDAAuD;CACxF,CAAC","sourcesContent":["import type { ClassConstructor, ClassTransformOptions } from \"class-transformer\";\nimport { instanceToPlain, plainToInstance } from \"class-transformer\";\nimport Guards from \"./Guards\";\nimport { ValidationError, validateSync } from \"class-validator\";\n\n/**\n * Base typesafe class for Data Transfer Objects (DTOs)\n */\nexport abstract class Dto {\n\t/**\n\t * Default options for class transformation\n\t */\n\tprotected static readonly defaultTransformOptions: ClassTransformOptions = {\n\t\texcludeExtraneousValues: true,\n\t\tenableCircularCheck: true,\n\t\texposeDefaultValues: true,\n\t\tenableImplicitConversion: false, // Safer default, especially when using class-validator\n\t};\n\n\t/**\n\t * Validates the DTO instance\n\t * @throws ValidationError[] if validation fails\n\t */\n\tpublic validate(): ValidationError[] {\n\t\tconst errors = validateSync(this, {\n\t\t\tvalidationError: { target: false },\n\t\t\tforbidUnknownValues: true,\n\t\t});\n\t\tif (errors.length > 0) {\n\t\t\tthrow errors;\n\t\t}\n\t\treturn errors;\n\t}\n\n\t/**\n\t * Converts the DTO to a plain object\n\t * @param options - Class transformer options for controlling exposure and transformation\n\t * @returns Plain object representation of the DTO\n\t */\n\tpublic toJSON<T = Record<string, unknown>>(include_undefined: boolean = true, options?: ClassTransformOptions): T {\n\t\tconst value = instanceToPlain(this, {\n\t\t\t...Dto.defaultTransformOptions,\n\t\t\t...options,\n\t\t}) as T;\n\n\t\tif (!include_undefined) {\n\t\t\treturn Object.fromEntries(Object.entries(value as Record<string, unknown>).filter(([_, v]) => !Guards.IsNil(v))) as T;\n\t\t}\n\n\t\treturn value;\n\t}\n\n\t/**\n\t * Creates a new instance of the DTO with validation (infers class from `this`)\n\t * @param data - Data to create the DTO from\n\t * @param options - Class transformer options\n\t * @returns New instance of the DTO\n\t */\n\tpublic static Create<T extends Dto>(this: ClassConstructor<T>, data: Record<string, unknown>, options: ClassTransformOptions = {}): T {\n\t\tconst instance = plainToInstance(this, data, {\n\t\t\t...Dto.defaultTransformOptions,\n\t\t\t...options,\n\t\t});\n\n\t\treturn instance;\n\t}\n\n\t/**\n\t * Creates an array of DTOs from an array of plain objects\n\t */\n\tpublic static CreateMany<T extends Dto>(this: ClassConstructor<T>, dataArray: Record<string, unknown>[], options: ClassTransformOptions = {}): T[] {\n\t\treturn plainToInstance(this, dataArray, {\n\t\t\t...Dto.defaultTransformOptions,\n\t\t\t...options,\n\t\t}) as T[];\n\t}\n}\n"]}
@@ -16,14 +16,12 @@ export default abstract class BaseEntity {
16
16
  */
17
17
  update<T extends BaseEntity>(this: T, data: Partial<T>): T;
18
18
  /**
19
- * Creates a new entity instance from DTO with validation
20
- * @param cls - Entity class constructor
19
+ * Creates a new entity instance from DTO (infers class from `this`)
21
20
  * @param dto - DTO to create entity from
22
- * @param validate - Whether to validate after creation (default: true)
23
21
  */
24
- static FromDto<T extends BaseEntity>(cls: ClassConstructor<T>, dto: Dto): T;
22
+ static FromDto<T extends BaseEntity>(this: ClassConstructor<T>, dto: Dto): T;
25
23
  /**
26
24
  * Creates multiple entities from DTOs
27
25
  */
28
- static FromDtos<T extends BaseEntity>(cls: ClassConstructor<T>, dtos: Dto[]): T[];
26
+ static FromDtos<T extends BaseEntity>(this: ClassConstructor<T>, dtos: Dto[]): T[];
29
27
  }
@@ -16,20 +16,18 @@ export default class BaseEntity {
16
16
  return updated;
17
17
  }
18
18
  /**
19
- * Creates a new entity instance from DTO with validation
20
- * @param cls - Entity class constructor
19
+ * Creates a new entity instance from DTO (infers class from `this`)
21
20
  * @param dto - DTO to create entity from
22
- * @param validate - Whether to validate after creation (default: true)
23
21
  */
24
- static FromDto(cls, dto) {
25
- const instance = plainToInstance(cls, dto.toJSON());
22
+ static FromDto(dto) {
23
+ const instance = plainToInstance(this, dto.toJSON());
26
24
  return instance;
27
25
  }
28
26
  /**
29
27
  * Creates multiple entities from DTOs
30
28
  */
31
- static FromDtos(cls, dtos) {
32
- return dtos.map((dto) => BaseEntity.FromDto(cls, dto));
29
+ static FromDtos(dtos) {
30
+ return plainToInstance(this, dtos.map((dto) => dto.toJSON()));
33
31
  }
34
32
  }
35
33
  //# sourceMappingURL=BaseEntity.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"BaseEntity.js","sourceRoot":"","sources":["../../src/utils/BaseEntity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,eAAe,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGvF,MAAM,CAAC,OAAO,OAAgB,UAAU;IACvC;;OAEG;IACI,MAAM;QACZ,OAAO,eAAe,CAAC,IAAI,CAAM,CAAC;IACnC,CAAC;IAOD;;;;OAIG;IACI,MAAM,CAAgC,IAAgB;QAC5D,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;QACtF,OAAO,OAAO,CAAC;IAChB,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,OAAO,CAAuB,GAAwB,EAAE,GAAQ;QAC7E,MAAM,QAAQ,GAAG,eAAe,CAAC,GAAG,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC;QACpD,OAAO,QAAQ,CAAC;IACjB,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,QAAQ,CAAuB,GAAwB,EAAE,IAAW;QACjF,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;IACxD,CAAC;CACD","sourcesContent":["import { ClassConstructor, instanceToPlain, plainToInstance } from \"class-transformer\";\nimport { Dto } from \"./BaseDto\";\n\nexport default abstract class BaseEntity {\n\t/**\n\t * Converts entity to plain object\n\t */\n\tpublic toJSON<T = Record<string, unknown>>(): T {\n\t\treturn instanceToPlain(this) as T;\n\t}\n\n\t/**\n\t * Abstract method - entities must define how to convert to DTO\n\t */\n\tpublic abstract toDto(): Dto;\n\n\t/**\n\t * Updates entity with partial data (immutable - returns new instance)\n\t * @param data - Partial data to update\n\t * @param validate - Whether to validate after update (default: true)\n\t */\n\tpublic update<T extends BaseEntity>(this: T, data: Partial<T>): T {\n\t\tconst updated = Object.assign(Object.create(Object.getPrototypeOf(this)), this, data);\n\t\treturn updated;\n\t}\n\n\t/**\n\t * Creates a new entity instance from DTO with validation\n\t * @param cls - Entity class constructor\n\t * @param dto - DTO to create entity from\n\t * @param validate - Whether to validate after creation (default: true)\n\t */\n\tpublic static FromDto<T extends BaseEntity>(cls: ClassConstructor<T>, dto: Dto): T {\n\t\tconst instance = plainToInstance(cls, dto.toJSON());\n\t\treturn instance;\n\t}\n\n\t/**\n\t * Creates multiple entities from DTOs\n\t */\n\tpublic static FromDtos<T extends BaseEntity>(cls: ClassConstructor<T>, dtos: Dto[]): T[] {\n\t\treturn dtos.map((dto) => BaseEntity.FromDto(cls, dto));\n\t}\n}\n"]}
1
+ {"version":3,"file":"BaseEntity.js","sourceRoot":"","sources":["../../src/utils/BaseEntity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,eAAe,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGvF,MAAM,CAAC,OAAO,OAAgB,UAAU;IACvC;;OAEG;IACI,MAAM;QACZ,OAAO,eAAe,CAAC,IAAI,CAAM,CAAC;IACnC,CAAC;IAOD;;;;OAIG;IACI,MAAM,CAAgC,IAAgB;QAC5D,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;QACtF,OAAO,OAAO,CAAC;IAChB,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,OAAO,CAAkD,GAAQ;QAC9E,MAAM,QAAQ,GAAG,eAAe,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC;QACrD,OAAO,QAAQ,CAAC;IACjB,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,QAAQ,CAAkD,IAAW;QAClF,OAAO,eAAe,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;IAC/D,CAAC;CACD","sourcesContent":["import { ClassConstructor, instanceToPlain, plainToInstance } from \"class-transformer\";\nimport { Dto } from \"./BaseDto\";\n\nexport default abstract class BaseEntity {\n\t/**\n\t * Converts entity to plain object\n\t */\n\tpublic toJSON<T = Record<string, unknown>>(): T {\n\t\treturn instanceToPlain(this) as T;\n\t}\n\n\t/**\n\t * Abstract method - entities must define how to convert to DTO\n\t */\n\tpublic abstract toDto(): Dto;\n\n\t/**\n\t * Updates entity with partial data (immutable - returns new instance)\n\t * @param data - Partial data to update\n\t * @param validate - Whether to validate after update (default: true)\n\t */\n\tpublic update<T extends BaseEntity>(this: T, data: Partial<T>): T {\n\t\tconst updated = Object.assign(Object.create(Object.getPrototypeOf(this)), this, data);\n\t\treturn updated;\n\t}\n\n\t/**\n\t * Creates a new entity instance from DTO (infers class from `this`)\n\t * @param dto - DTO to create entity from\n\t */\n\tpublic static FromDto<T extends BaseEntity>(this: ClassConstructor<T>, dto: Dto): T {\n\t\tconst instance = plainToInstance(this, dto.toJSON());\n\t\treturn instance;\n\t}\n\n\t/**\n\t * Creates multiple entities from DTOs\n\t */\n\tpublic static FromDtos<T extends BaseEntity>(this: ClassConstructor<T>, dtos: Dto[]): T[] {\n\t\treturn plainToInstance(this, dtos.map((dto) => dto.toJSON()));\n\t}\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "topsyde-utils",
3
- "version": "1.0.203",
3
+ "version": "1.0.204",
4
4
  "description": "A bundle of TypeScript utility classes and functions",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -56,13 +56,8 @@ export abstract class Dto {
56
56
  * @param options - Class transformer options
57
57
  * @returns New instance of the DTO
58
58
  */
59
- public static Create<T extends Dto>(
60
- this: ClassConstructor<T>, // 🔑 Key change: use 'this' parameter
61
- data: Record<string, unknown>,
62
- options: ClassTransformOptions = {},
63
- ): T {
59
+ public static Create<T extends Dto>(this: ClassConstructor<T>, data: Record<string, unknown>, options: ClassTransformOptions = {}): T {
64
60
  const instance = plainToInstance(this, data, {
65
- // 🔑 Use 'this' instead of 'cls'
66
61
  ...Dto.defaultTransformOptions,
67
62
  ...options,
68
63
  });
@@ -25,20 +25,18 @@ export default abstract class BaseEntity {
25
25
  }
26
26
 
27
27
  /**
28
- * Creates a new entity instance from DTO with validation
29
- * @param cls - Entity class constructor
28
+ * Creates a new entity instance from DTO (infers class from `this`)
30
29
  * @param dto - DTO to create entity from
31
- * @param validate - Whether to validate after creation (default: true)
32
30
  */
33
- public static FromDto<T extends BaseEntity>(cls: ClassConstructor<T>, dto: Dto): T {
34
- const instance = plainToInstance(cls, dto.toJSON());
31
+ public static FromDto<T extends BaseEntity>(this: ClassConstructor<T>, dto: Dto): T {
32
+ const instance = plainToInstance(this, dto.toJSON());
35
33
  return instance;
36
34
  }
37
35
 
38
36
  /**
39
37
  * Creates multiple entities from DTOs
40
38
  */
41
- public static FromDtos<T extends BaseEntity>(cls: ClassConstructor<T>, dtos: Dto[]): T[] {
42
- return dtos.map((dto) => BaseEntity.FromDto(cls, dto));
39
+ public static FromDtos<T extends BaseEntity>(this: ClassConstructor<T>, dtos: Dto[]): T[] {
40
+ return plainToInstance(this, dtos.map((dto) => dto.toJSON()));
43
41
  }
44
42
  }