@forklaunch/core 0.1.3 → 0.1.6

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.
Files changed (55) hide show
  1. package/dist/cache/redisTtlCache.d.ts +1 -0
  2. package/dist/cache/redisTtlCache.js +1 -0
  3. package/dist/cache/redisTtlCache.js.map +1 -1
  4. package/dist/entityMapper/interfaces/entityMapper.interface.d.ts +1 -0
  5. package/dist/entityMapper/models/baseEntityMapper.model.d.ts +7 -7
  6. package/dist/entityMapper/models/baseEntityMapper.model.js +7 -7
  7. package/dist/entityMapper/models/baseEntityMapper.model.js.map +1 -1
  8. package/dist/entityMapper/models/requestEntityMapper.model.d.ts +13 -9
  9. package/dist/entityMapper/models/requestEntityMapper.model.js +13 -9
  10. package/dist/entityMapper/models/requestEntityMapper.model.js.map +1 -1
  11. package/dist/entityMapper/models/responseEntityMapper.model.d.ts +14 -7
  12. package/dist/entityMapper/models/responseEntityMapper.model.js +12 -6
  13. package/dist/entityMapper/models/responseEntityMapper.model.js.map +1 -1
  14. package/dist/entityMapper/types/entityMapper.types.d.ts +2 -2
  15. package/dist/http/httpStatusCodes.d.ts +74 -0
  16. package/dist/http/httpStatusCodes.js +1050 -0
  17. package/dist/http/httpStatusCodes.js.map +1 -0
  18. package/dist/http/index.d.ts +4 -1
  19. package/dist/http/index.js +4 -1
  20. package/dist/http/index.js.map +1 -1
  21. package/dist/http/middleware/index.js.map +1 -0
  22. package/dist/http/middleware/request.middleware.d.ts +95 -0
  23. package/dist/http/{middlewares → middleware}/request.middleware.js +105 -2
  24. package/dist/http/middleware/request.middleware.js.map +1 -0
  25. package/dist/http/middleware/response.middleware.d.ts +14 -0
  26. package/dist/http/middleware/response.middleware.js +53 -0
  27. package/dist/http/middleware/response.middleware.js.map +1 -0
  28. package/dist/http/openApiV3Generator.d.ts +13 -0
  29. package/dist/http/openApiV3Generator.js +177 -0
  30. package/dist/http/openApiV3Generator.js.map +1 -0
  31. package/dist/http/regex.d.ts +8 -0
  32. package/dist/http/regex.js +115 -0
  33. package/dist/http/regex.js.map +1 -0
  34. package/dist/http/types/api.types.d.ts +71 -0
  35. package/dist/http/types/forklaunch.types.d.ts +30 -0
  36. package/dist/http/types/forklaunch.types.js +3 -0
  37. package/dist/http/types/forklaunch.types.js.map +1 -0
  38. package/dist/http/types/index.d.ts +1 -0
  39. package/dist/http/types/index.js +1 -0
  40. package/dist/http/types/index.js.map +1 -1
  41. package/dist/http/types/primitive.types.d.ts +73 -0
  42. package/dist/tests/http.middleware.test.js +1 -1
  43. package/dist/tests/http.middleware.test.js.map +1 -1
  44. package/dist/tests/openApiV3Generator.test.d.ts +1 -0
  45. package/dist/tests/openApiV3Generator.test.js +71 -0
  46. package/dist/tests/openApiV3Generator.test.js.map +1 -0
  47. package/package.json +3 -2
  48. package/dist/http/middlewares/index.js.map +0 -1
  49. package/dist/http/middlewares/request.middleware.d.ts +0 -11
  50. package/dist/http/middlewares/request.middleware.js.map +0 -1
  51. package/dist/http/middlewares/response.middleware.d.ts +0 -3
  52. package/dist/http/middlewares/response.middleware.js +0 -33
  53. package/dist/http/middlewares/response.middleware.js.map +0 -1
  54. /package/dist/http/{middlewares → middleware}/index.d.ts +0 -0
  55. /package/dist/http/{middlewares → middleware}/index.js +0 -0
@@ -12,6 +12,7 @@ export declare class RedisTtlCache implements TtlCache {
12
12
  * Creates an instance of RedisTtlCache.
13
13
  *
14
14
  * @param {number} ttlMilliseconds - The default TTL in milliseconds.
15
+ * @param {RedisClientOptions} [hostingOptions] - The Redis client options.
15
16
  */
16
17
  constructor(ttlMilliseconds: number, hostingOptions?: RedisClientOptions);
17
18
  /**
@@ -13,6 +13,7 @@ class RedisTtlCache {
13
13
  * Creates an instance of RedisTtlCache.
14
14
  *
15
15
  * @param {number} ttlMilliseconds - The default TTL in milliseconds.
16
+ * @param {RedisClientOptions} [hostingOptions] - The Redis client options.
16
17
  */
17
18
  constructor(ttlMilliseconds, hostingOptions) {
18
19
  this.ttlMilli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G,CAAC,cAAc,CAAC,CAAC,CAAC,uBAAuB;QAC1E,OAAO;YACL,GAAG,EAAE,cAAc;YACnB,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC;YACxB,eAAe,EAAE,GAAG,GAAG,IAAI;SAC5B,CAAC;IACJ,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,QAAQ,CAAC,cAAsB;QACnC,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,cAAc,GAAG,GAAG,CAAC,CAAC;QAC1D,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,UAAU,CAAC,cAAsB;QACrC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;QACxD,OAAO,MAAM,KAAK,CAAC,CAAC;IACtB,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,UAAU;QACd,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;IAC3B,CAAC;IAED;;;;OAIG;IACH,kBAAkB;QAChB,OAAO,IAAI,CAAC,eAAe,CAAC;IAC9B,CAAC;CACF;AA5GD,sCA4GC"}
@@ -3,6 +3,7 @@ import { AnySchemaValidator } from '@forklaunch/validator';
3
3
  * Interface representing a constructor for an entity mapper.
4
4
  *
5
5
  * @template T - The type of the entity mapper.
6
+ * @template SV - The type of the schema validator.
6
7
  * @interface EntityMapperConstructor
7
8
  */
8
9
  export interface EntityMapperConstructor<T, SV extends AnySchemaValidator> {
@@ -5,15 +5,16 @@ import { EntityMapperSchemaValidatorObject } from '../types/entityMapper.types';
5
5
  * Constructs an instance of a T.
6
6
  *
7
7
  * @template T - A type that extends BaseEntityMapper.
8
- * @param {EntityMapperConstructor<T>} self - The constructor of the T.
9
- * @param {...any[]} args - The arguments to pass to the constructor.
8
+ * @template SV - A type that extends AnySchemaValidator.
9
+ * @param {EntityMapperConstructor<T, SV>} self - The constructor of the T.
10
+ * @param {SV} [schemaValidator] - The optional schema validator.
10
11
  * @returns {T} - An instance of the T.
11
12
  */
12
13
  export declare function construct<T, SV extends AnySchemaValidator>(self: EntityMapperConstructor<T, SV>, schemaValidator?: SV): T;
13
14
  /**
14
- * Abstract class representing a base entityMapper.
15
+ * Abstract class representing a base entity mapper.
15
16
  *
16
- * @template SV - A type that extends SchemaValidator.
17
+ * @template SV - A type that extends AnySchemaValidator.
17
18
  */
18
19
  export declare abstract class BaseEntityMapper<SV extends AnySchemaValidator> {
19
20
  /**
@@ -37,7 +38,6 @@ export declare abstract class BaseEntityMapper<SV extends AnySchemaValidator> {
37
38
  /**
38
39
  * The Data Transfer Object (DTO).
39
40
  * @type {Schema<this['schema'], SV>}
40
- *
41
41
  */
42
42
  _dto: Schema<this['schema'], SV>;
43
43
  /**
@@ -57,14 +57,14 @@ export declare abstract class BaseEntityMapper<SV extends AnySchemaValidator> {
57
57
  * Validates and gets the Data Transfer Object (DTO).
58
58
  *
59
59
  * @returns {this['_dto']} - The Data Transfer Object (DTO).
60
- * @throws {Error} - Throws an error if the DTO is invalid.
61
60
  */
62
61
  get dto(): this['_dto'];
63
62
  /**
64
63
  * Gets the schema of a T.
65
64
  *
66
65
  * @template T - A type that extends BaseEntityMapper.
67
- * @param {EntityMapperConstructor<T>} this - The constructor of the T.
66
+ * @template SV - A type that extends AnySchemaValidator.
67
+ * @param {EntityMapperConstructor<T, SV>} this - The constructor of the T.
68
68
  * @returns {T['schema']} - The schema of the T.
69
69
  */
70
70
  static schema<T extends BaseEntityMapper<SV>, SV extends AnySchemaValidator>(this: EntityMapperConstructor<T, SV>): T['schema'];
@@ -6,17 +6,18 @@ exports.construct = construct;
6
6
  * Constructs an instance of a T.
7
7
  *
8
8
  * @template T - A type that extends BaseEntityMapper.
9
- * @param {EntityMapperConstructor<T>} self - The constructor of the T.
10
- * @param {...any[]} args - The arguments to pass to the constructor.
9
+ * @template SV - A type that extends AnySchemaValidator.
10
+ * @param {EntityMapperConstructor<T, SV>} self - The constructor of the T.
11
+ * @param {SV} [schemaValidator] - The optional schema validator.
11
12
  * @returns {T} - An instance of the T.
12
13
  */
13
14
  function construct(self, schemaValidator) {
14
15
  return new self(schemaValidator || {});
15
16
  }
16
17
  /**
17
- * Abstract class representing a base entityMapper.
18
+ * Abstract class representing a base entity mapper.
18
19
  *
19
- * @template SV - A type that extends SchemaValidator.
20
+ * @template SV - A type that extends AnySchemaValidator.
20
21
  */
21
22
  class BaseEntityMapper {
22
23
  /**
@@ -34,7 +35,6 @@ class BaseEntityMapper {
34
35
  /**
35
36
  * The Data Transfer Object (DTO).
36
37
  * @type {Schema<this['schema'], SV>}
37
- *
38
38
  */
39
39
  _dto = {};
40
40
  /**
@@ -61,7 +61,6 @@ class BaseEntityMapper {
61
61
  * Validates and gets the Data Transfer Object (DTO).
62
62
  *
63
63
  * @returns {this['_dto']} - The Data Transfer Object (DTO).
64
- * @throws {Error} - Throws an error if the DTO is invalid.
65
64
  */
66
65
  get dto() {
67
66
  return this._dto;
@@ -70,7 +69,8 @@ class BaseEntityMapper {
70
69
  * Gets the schema of a T.
71
70
  *
72
71
  * @template T - A type that extends BaseEntityMapper.
73
- * @param {EntityMapperConstructor<T>} this - The constructor of the T.
72
+ * @template SV - A type that extends AnySchemaValidator.
73
+ * @param {EntityMapperConstructor<T, SV>} this - The constructor of the T.
74
74
  * @returns {T['schema']} - The schema of the T.
75
75
  */
76
76
  static schema() {
@@ -1 +1 @@
1
- {"version":3,"file":"baseEntityMapper.model.js","sourceRoot":"","sources":["../../../entityMapper/models/baseEntityMapper.model.ts"],"names":[],"mappings":";;;AAgBA,8BAKC;AAbD;;;;;;;GAOG;AACH,SAAgB,SAAS,CACvB,IAAoC,EACpC,eAAoB;IAEpB,OAAO,IAAI,IAAI,CAAC,eAAe,IAAK,EAAS,CAAC,CAAC;AACjD,CAAC;AAED;;;;GAIG;AACH,MAAsB,gBAAgB;IACpC;;;;OAIG;IACH,GAAG,CAAM;IAET;;;;OAIG;IACO,eAAe,CAAkB;IAS3C;;;;OAIG;IACH,IAAI,GAA+B,EAGlC,CAAC;IAEF;;;;OAIG;IACH,YAAY,eAAmB;QAC7B,IAAI,CAAC,eAAe,GAAG,eAA6C,CAAC;IACvE,CAAC;IAED;;;;;OAKG;IACH,IAAI,GAAG,CAAC,IAAkB;QACxB,IACE,CAAC,IAAI,CAAC,eAAe,CAAC,QAAQ,CAC5B,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,EAC1C,IAAI,CACL,EACD,CAAC;YACD,MAAM,IAAI,KAAK,CAAC,aAAa,CAAC,CAAC;QACjC,CAAC;QACD,IAAI,CAAC,IAAI,GAAG,IAA6C,CAAC;IAC5D,CAAC;IAED;;;;;OAKG;IACH,IAAI,GAAG;QACL,OAAO,IAAI,CAAC,IAA+B,CAAC;IAC9C,CAAC;IAED;;;;;;OAMG;IACH,MAAM,CAAC,MAAM;QAGX,OAAO,SAAS,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC;IAChC,CAAC;CACF;AAjFD,4CAiFC"}
1
+ {"version":3,"file":"baseEntityMapper.model.js","sourceRoot":"","sources":["../../../entityMapper/models/baseEntityMapper.model.ts"],"names":[],"mappings":";;;AAiBA,8BAKC;AAdD;;;;;;;;GAQG;AACH,SAAgB,SAAS,CACrB,IAAoC,EACpC,eAAoB;IAEpB,OAAO,IAAI,IAAI,CAAC,eAAe,IAAK,EAAS,CAAC,CAAC;AACnD,CAAC;AAED;;;;GAIG;AACH,MAAsB,gBAAgB;IAClC;;;;OAIG;IACH,GAAG,CAAM;IAET;;;;OAIG;IACO,eAAe,CAAkB;IAS3C;;;OAGG;IACH,IAAI,GAA+B,EAGlC,CAAC;IAEF;;;;OAIG;IACH,YAAY,eAAmB;QAC3B,IAAI,CAAC,eAAe,GAAG,eAA6C,CAAC;IACzE,CAAC;IAED;;;;;OAKG;IACH,IAAI,GAAG,CAAC,IAAkB;QACtB,IACI,CAAC,IAAI,CAAC,eAAe,CAAC,QAAQ,CAC1B,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,EAC1C,IAAI,CACP,EACH,CAAC;YACC,MAAM,IAAI,KAAK,CAAC,aAAa,CAAC,CAAC;QACnC,CAAC;QACD,IAAI,CAAC,IAAI,GAAG,IAA6C,CAAC;IAC9D,CAAC;IAED;;;;OAIG;IACH,IAAI,GAAG;QACH,OAAO,IAAI,CAAC,IAA+B,CAAC;IAChD,CAAC;IAED;;;;;;;OAOG;IACH,MAAM,CAAC,MAAM;QAGT,OAAO,SAAS,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC;IAClC,CAAC;CACJ;AAhFD,4CAgFC"}
@@ -3,15 +3,15 @@ import { BaseEntity } from '../../database/mikro/models/entities/base.entity';
3
3
  import { EntityMapperConstructor } from '../interfaces/entityMapper.interface';
4
4
  import { BaseEntityMapper } from './baseEntityMapper.model';
5
5
  /**
6
- * Abstract class representing a request entityMapper.
6
+ * Abstract class representing a request entity mapper.
7
7
  *
8
8
  * @template Entity - A type that extends BaseEntity.
9
- * @template SV - A type that extends SchemaValidator.
9
+ * @template SV - A type that extends AnySchemaValidator.
10
10
  * @extends {BaseEntityMapper<SV>}
11
11
  */
12
12
  export declare abstract class RequestEntityMapper<Entity extends BaseEntity, SV extends AnySchemaValidator> extends BaseEntityMapper<SV> {
13
13
  /**
14
- * The entity.
14
+ * The entity type.
15
15
  * @type {Entity}
16
16
  * @protected
17
17
  */
@@ -43,9 +43,11 @@ export declare abstract class RequestEntityMapper<Entity extends BaseEntity, SV
43
43
  * Creates an instance of a RequestEntityMapper from a JSON object.
44
44
  *
45
45
  * @template T - A type that extends RequestEntityMapper.
46
- * @param {EntityMapperConstructor<T>} this - The constructor of the T.
47
- * @param {T['_SV']} schemaValidator - The schema provider.
48
- * @param {T['_dto']} json - The JSON object.
46
+ * @template SV - A type that extends AnySchemaValidator.
47
+ * @template JsonType - The type of the JSON object.
48
+ * @param {EntityMapperConstructor<T, SV>} this - The constructor of the T.
49
+ * @param {SV} schemaValidator - The schema provider.
50
+ * @param {JsonType} json - The JSON object.
49
51
  * @returns {T} - An instance of the T.
50
52
  */
51
53
  static fromJson<T extends RequestEntityMapper<BaseEntity, SV>, SV extends AnySchemaValidator, JsonType extends T['_dto']>(this: EntityMapperConstructor<T, SV>, schemaValidator: SV, json: JsonType): T;
@@ -53,9 +55,11 @@ export declare abstract class RequestEntityMapper<Entity extends BaseEntity, SV
53
55
  * Deserializes a JSON object to an entity.
54
56
  *
55
57
  * @template T - A type that extends RequestEntityMapper.
56
- * @param {EntityMapperConstructor<T>} this - The constructor of the T.
57
- * @param {T['_SV']} schemaValidator - The schema provider.
58
- * @param {T['_dto']} json - The JSON object.
58
+ * @template SV - A type that extends AnySchemaValidator.
59
+ * @template JsonType - The type of the JSON object.
60
+ * @param {EntityMapperConstructor<T, SV>} this - The constructor of the T.
61
+ * @param {SV} schemaValidator - The schema provider.
62
+ * @param {JsonType} json - The JSON object.
59
63
  * @param {...unknown[]} additionalArgs - Additional arguments.
60
64
  * @returns {T['_Entity']} - The entity.
61
65
  */
@@ -3,15 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.RequestEntityMapper = void 0;
4
4
  const baseEntityMapper_model_1 = require("./baseEntityMapper.model");
5
5
  /**
6
- * Abstract class representing a request entityMapper.
6
+ * Abstract class representing a request entity mapper.
7
7
  *
8
8
  * @template Entity - A type that extends BaseEntity.
9
- * @template SV - A type that extends SchemaValidator.
9
+ * @template SV - A type that extends AnySchemaValidator.
10
10
  * @extends {BaseEntityMapper<SV>}
11
11
  */
12
12
  class RequestEntityMapper extends baseEntityMapper_model_1.BaseEntityMapper {
13
13
  /**
14
- * The entity.
14
+ * The entity type.
15
15
  * @type {Entity}
16
16
  * @protected
17
17
  */
@@ -43,9 +43,11 @@ class RequestEntityMapper extends baseEntityMapper_model_1.BaseEntityMapper {
43
43
  * Creates an instance of a RequestEntityMapper from a JSON object.
44
44
  *
45
45
  * @template T - A type that extends RequestEntityMapper.
46
- * @param {EntityMapperConstructor<T>} this - The constructor of the T.
47
- * @param {T['_SV']} schemaValidator - The schema provider.
48
- * @param {T['_dto']} json - The JSON object.
46
+ * @template SV - A type that extends AnySchemaValidator.
47
+ * @template JsonType - The type of the JSON object.
48
+ * @param {EntityMapperConstructor<T, SV>} this - The constructor of the T.
49
+ * @param {SV} schemaValidator - The schema provider.
50
+ * @param {JsonType} json - The JSON object.
49
51
  * @returns {T} - An instance of the T.
50
52
  */
51
53
  static fromJson(schemaValidator, json) {
@@ -55,9 +57,11 @@ class RequestEntityMapper extends baseEntityMapper_model_1.BaseEntityMapper {
55
57
  * Deserializes a JSON object to an entity.
56
58
  *
57
59
  * @template T - A type that extends RequestEntityMapper.
58
- * @param {EntityMapperConstructor<T>} this - The constructor of the T.
59
- * @param {T['_SV']} schemaValidator - The schema provider.
60
- * @param {T['_dto']} json - The JSON object.
60
+ * @template SV - A type that extends AnySchemaValidator.
61
+ * @template JsonType - The type of the JSON object.
62
+ * @param {EntityMapperConstructor<T, SV>} this - The constructor of the T.
63
+ * @param {SV} schemaValidator - The schema provider.
64
+ * @param {JsonType} json - The JSON object.
61
65
  * @param {...unknown[]} additionalArgs - Additional arguments.
62
66
  * @returns {T['_Entity']} - The entity.
63
67
  */
@@ -1 +1 @@
1
- {"version":3,"file":"requestEntityMapper.model.js","sourceRoot":"","sources":["../../../entityMapper/models/requestEntityMapper.model.ts"],"names":[],"mappings":";;;AAGA,qEAAuE;AAEvE;;;;;;GAMG;AACH,MAAsB,mBAGpB,SAAQ,yCAAoB;IAC5B;;;;OAIG;IACH,OAAO,CAAU;IAWjB;;;;;OAKG;IACH,QAAQ,CAAC,IAAkB;QACzB,IACE,CAAC,IAAI,CAAC,eAAe,CAAC,QAAQ,CAC5B,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,EAC1C,IAAI,CACL,EACD,CAAC;YACD,MAAM,IAAI,KAAK,CAAC,aAAa,CAAC,CAAC;QACjC,CAAC;QACD,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC;QAChB,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;OAMG;IACH,uBAAuB,CACrB,IAAkB,EAClB,GAAG,cAAyB;QAE5B,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,GAAG,cAAc,CAAC,CAAC;IACzD,CAAC;IAED;;;;;;;;OAQG;IACH,MAAM,CAAC,QAAQ,CAMb,eAAmB,EACnB,IAAc;QAEd,OAAO,IAAA,kCAAS,EAAC,IAAI,EAAE,eAAe,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IACzD,CAAC;IAED;;;;;;;;;OASG;IACH,MAAM,CAAC,uBAAuB,CAM5B,eAAmB,EACnB,IAAc,EACd,GAAG,cAAyB;QAE5B,OAAO,IAAA,kCAAS,EAAC,IAAI,EAAE,eAAe,CAAC;aACpC,QAAQ,CAAC,IAAI,CAAC;aACd,QAAQ,CAAC,GAAG,cAAc,CAAC,CAAC;IACjC,CAAC;CACF;AAlGD,kDAkGC"}
1
+ {"version":3,"file":"requestEntityMapper.model.js","sourceRoot":"","sources":["../../../entityMapper/models/requestEntityMapper.model.ts"],"names":[],"mappings":";;;AAGA,qEAAuE;AAEvE;;;;;;GAMG;AACH,MAAsB,mBAGpB,SAAQ,yCAAoB;IAC5B;;;;OAIG;IACH,OAAO,CAAU;IAWjB;;;;;OAKG;IACH,QAAQ,CAAC,IAAkB;QACzB,IACE,CAAC,IAAI,CAAC,eAAe,CAAC,QAAQ,CAC5B,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,EAC1C,IAAI,CACL,EACD,CAAC;YACD,MAAM,IAAI,KAAK,CAAC,aAAa,CAAC,CAAC;QACjC,CAAC;QACD,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC;QAChB,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;OAMG;IACH,uBAAuB,CACrB,IAAkB,EAClB,GAAG,cAAyB;QAE5B,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,GAAG,cAAc,CAAC,CAAC;IACzD,CAAC;IAED;;;;;;;;;;OAUG;IACH,MAAM,CAAC,QAAQ,CAMb,eAAmB,EACnB,IAAc;QAEd,OAAO,IAAA,kCAAS,EAAC,IAAI,EAAE,eAAe,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IACzD,CAAC;IAED;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,uBAAuB,CAM5B,eAAmB,EACnB,IAAc,EACd,GAAG,cAAyB;QAE5B,OAAO,IAAA,kCAAS,EAAC,IAAI,EAAE,eAAe,CAAC;aACpC,QAAQ,CAAC,IAAI,CAAC;aACd,QAAQ,CAAC,GAAG,cAAc,CAAC,CAAC;IACjC,CAAC;CACF;AAtGD,kDAsGC"}
@@ -3,10 +3,10 @@ import { BaseEntity } from '../../database/mikro/models/entities/base.entity';
3
3
  import { EntityMapperConstructor } from '../interfaces/entityMapper.interface';
4
4
  import { BaseEntityMapper } from './baseEntityMapper.model';
5
5
  /**
6
- * Abstract class representing a response entityMapper.
6
+ * Abstract class representing a response entity mapper.
7
7
  *
8
8
  * @template Entity - A type that extends BaseEntity.
9
- * @template SV - A type that extends SchemaValidator.
9
+ * @template SV - A type that extends AnySchemaValidator.
10
10
  * @extends {BaseEntityMapper<SV>}
11
11
  */
12
12
  export declare abstract class ResponseEntityMapper<Entity extends BaseEntity, SV extends AnySchemaValidator> extends BaseEntityMapper<SV> {
@@ -17,18 +17,19 @@ export declare abstract class ResponseEntityMapper<Entity extends BaseEntity, SV
17
17
  */
18
18
  _Entity: Entity;
19
19
  /**
20
- * Populates entityMapper with DTO from an entity.
20
+ * Populates entity mapper with DTO from an entity.
21
21
  *
22
22
  * @abstract
23
23
  * @param {Entity} entity - The entity to convert.
24
+ * @param {...unknown[]} additionalArgs - Additional arguments.
24
25
  * @returns {this} - The instance of the ResponseEntityMapper.
25
26
  */
26
27
  abstract fromEntity(entity: Entity, ...additionalArgs: unknown[]): this;
27
28
  /**
28
29
  * Converts the underlying DTO to a JSON object.
29
30
  *
30
- * @param {...unknown[]} additionalArgs - Additional arguments.
31
31
  * @returns {this['_dto']} - The JSON object.
32
+ * @throws {Error} - Throws an error if the DTO is invalid.
32
33
  */
33
34
  toJson(): this['_dto'];
34
35
  /**
@@ -36,13 +37,16 @@ export declare abstract class ResponseEntityMapper<Entity extends BaseEntity, SV
36
37
  *
37
38
  * @param {Entity} entity - The entity to serialize.
38
39
  * @returns {this['_dto']} - The JSON object.
40
+ * @throws {Error} - Throws an error if the DTO is invalid.
39
41
  */
40
42
  serializeEntityToJson(entity: Entity): this['_dto'];
41
43
  /**
42
- * Populates entityMapper with DTO from an entity.
44
+ * Populates entity mapper with DTO from an entity.
43
45
  *
44
46
  * @template T - A type that extends ResponseEntityMapper.
45
- * @param {EntityMapperConstructor<T>} this - The constructor of the T.
47
+ * @template SV - A type that extends AnySchemaValidator.
48
+ * @param {EntityMapperConstructor<T, SV>} this - The constructor of the T.
49
+ * @param {SV} schemaValidator - The schema provider.
46
50
  * @param {T['_Entity']} entity - The entity to convert.
47
51
  * @returns {T} - An instance of the T.
48
52
  */
@@ -51,9 +55,12 @@ export declare abstract class ResponseEntityMapper<Entity extends BaseEntity, SV
51
55
  * Serializes an entity to a JSON object.
52
56
  *
53
57
  * @template T - A type that extends ResponseEntityMapper.
54
- * @param {EntityMapperConstructor<T>} this - The constructor of the T.
58
+ * @template SV - A type that extends AnySchemaValidator.
59
+ * @param {EntityMapperConstructor<T, SV>} this - The constructor of the T.
60
+ * @param {SV} schemaValidator - The schema provider.
55
61
  * @param {T['_Entity']} entity - The entity to serialize.
56
62
  * @returns {T['_dto']} - The JSON object.
63
+ * @throws {Error} - Throws an error if the DTO is invalid.
57
64
  */
58
65
  static serializeEntityToJson<T extends ResponseEntityMapper<BaseEntity, SV>, SV extends AnySchemaValidator>(this: EntityMapperConstructor<T, SV>, schemaValidator: SV, entity: T['_Entity']): T['_dto'];
59
66
  }
@@ -3,10 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ResponseEntityMapper = void 0;
4
4
  const baseEntityMapper_model_1 = require("./baseEntityMapper.model");
5
5
  /**
6
- * Abstract class representing a response entityMapper.
6
+ * Abstract class representing a response entity mapper.
7
7
  *
8
8
  * @template Entity - A type that extends BaseEntity.
9
- * @template SV - A type that extends SchemaValidator.
9
+ * @template SV - A type that extends AnySchemaValidator.
10
10
  * @extends {BaseEntityMapper<SV>}
11
11
  */
12
12
  class ResponseEntityMapper extends baseEntityMapper_model_1.BaseEntityMapper {
@@ -19,8 +19,8 @@ class ResponseEntityMapper extends baseEntityMapper_model_1.BaseEntityMapper {
19
19
  /**
20
20
  * Converts the underlying DTO to a JSON object.
21
21
  *
22
- * @param {...unknown[]} additionalArgs - Additional arguments.
23
22
  * @returns {this['_dto']} - The JSON object.
23
+ * @throws {Error} - Throws an error if the DTO is invalid.
24
24
  */
25
25
  toJson() {
26
26
  if (!this.schemaValidator.validate(this.schemaValidator.schemify(this.schema), this.dto)) {
@@ -33,15 +33,18 @@ class ResponseEntityMapper extends baseEntityMapper_model_1.BaseEntityMapper {
33
33
  *
34
34
  * @param {Entity} entity - The entity to serialize.
35
35
  * @returns {this['_dto']} - The JSON object.
36
+ * @throws {Error} - Throws an error if the DTO is invalid.
36
37
  */
37
38
  serializeEntityToJson(entity) {
38
39
  return this.fromEntity(entity).toJson();
39
40
  }
40
41
  /**
41
- * Populates entityMapper with DTO from an entity.
42
+ * Populates entity mapper with DTO from an entity.
42
43
  *
43
44
  * @template T - A type that extends ResponseEntityMapper.
44
- * @param {EntityMapperConstructor<T>} this - The constructor of the T.
45
+ * @template SV - A type that extends AnySchemaValidator.
46
+ * @param {EntityMapperConstructor<T, SV>} this - The constructor of the T.
47
+ * @param {SV} schemaValidator - The schema provider.
45
48
  * @param {T['_Entity']} entity - The entity to convert.
46
49
  * @returns {T} - An instance of the T.
47
50
  */
@@ -52,9 +55,12 @@ class ResponseEntityMapper extends baseEntityMapper_model_1.BaseEntityMapper {
52
55
  * Serializes an entity to a JSON object.
53
56
  *
54
57
  * @template T - A type that extends ResponseEntityMapper.
55
- * @param {EntityMapperConstructor<T>} this - The constructor of the T.
58
+ * @template SV - A type that extends AnySchemaValidator.
59
+ * @param {EntityMapperConstructor<T, SV>} this - The constructor of the T.
60
+ * @param {SV} schemaValidator - The schema provider.
56
61
  * @param {T['_Entity']} entity - The entity to serialize.
57
62
  * @returns {T['_dto']} - The JSON object.
63
+ * @throws {Error} - Throws an error if the DTO is invalid.
58
64
  */
59
65
  static serializeEntityToJson(schemaValidator, entity) {
60
66
  return (0, baseEntityMapper_model_1.construct)(this, schemaValidator).serializeEntityToJson(entity);
@@ -1 +1 @@
1
- {"version":3,"file":"responseEntityMapper.model.js","sourceRoot":"","sources":["../../../entityMapper/models/responseEntityMapper.model.ts"],"names":[],"mappings":";;;AAGA,qEAAuE;AAEvE;;;;;;GAMG;AACH,MAAsB,oBAGpB,SAAQ,yCAAoB;IAC5B;;;;OAIG;IACH,OAAO,CAAU;IAWjB;;;;;OAKG;IACH,MAAM;QACJ,IACE,CAAC,IAAI,CAAC,eAAe,CAAC,QAAQ,CAC5B,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,EAC1C,IAAI,CAAC,GAAG,CACT,EACD,CAAC;YACD,MAAM,IAAI,KAAK,CAAC,aAAa,CAAC,CAAC;QACjC,CAAC;QACD,OAAO,IAAI,CAAC,GAAG,CAAC;IAClB,CAAC;IAED;;;;;OAKG;IACH,qBAAqB,CAAC,MAAc;QAClC,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,CAAC;IAC1C,CAAC;IAED;;;;;;;OAOG;IACH,MAAM,CAAC,UAAU,CAKf,eAAmB,EACnB,MAAoB;QAEpB,OAAO,IAAA,kCAAS,EAAC,IAAI,EAAE,eAAe,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;IAC7D,CAAC;IAED;;;;;;;OAOG;IACH,MAAM,CAAC,qBAAqB,CAK1B,eAAmB,EACnB,MAAoB;QAEpB,OAAO,IAAA,kCAAS,EAAC,IAAI,EAAE,eAAe,CAAC,CAAC,qBAAqB,CAAC,MAAM,CAAC,CAAC;IACxE,CAAC;CACF;AArFD,oDAqFC"}
1
+ {"version":3,"file":"responseEntityMapper.model.js","sourceRoot":"","sources":["../../../entityMapper/models/responseEntityMapper.model.ts"],"names":[],"mappings":";;;AAGA,qEAAuE;AAEvE;;;;;;GAMG;AACH,MAAsB,oBAGpB,SAAQ,yCAAoB;IAC5B;;;;OAIG;IACH,OAAO,CAAU;IAYjB;;;;;OAKG;IACH,MAAM;QACJ,IACE,CAAC,IAAI,CAAC,eAAe,CAAC,QAAQ,CAC5B,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,EAC1C,IAAI,CAAC,GAAG,CACT,EACD,CAAC;YACD,MAAM,IAAI,KAAK,CAAC,aAAa,CAAC,CAAC;QACjC,CAAC;QACD,OAAO,IAAI,CAAC,GAAG,CAAC;IAClB,CAAC;IAED;;;;;;OAMG;IACH,qBAAqB,CAAC,MAAc;QAClC,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,CAAC;IAC1C,CAAC;IAED;;;;;;;;;OASG;IACH,MAAM,CAAC,UAAU,CAKf,eAAmB,EACnB,MAAoB;QAEpB,OAAO,IAAA,kCAAS,EAAC,IAAI,EAAE,eAAe,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;IAC7D,CAAC;IAED;;;;;;;;;;OAUG;IACH,MAAM,CAAC,qBAAqB,CAK1B,eAAmB,EACnB,MAAoB;QAEpB,OAAO,IAAA,kCAAS,EAAC,IAAI,EAAE,eAAe,CAAC,CAAC,qBAAqB,CAAC,MAAM,CAAC,CAAC;IACxE,CAAC;CACF;AA5FD,oDA4FC"}
@@ -3,7 +3,7 @@ import { UnboxedObjectSchema } from '@forklaunch/validator/types';
3
3
  /**
4
4
  * Type representing a schema validator object for an entity mapper.
5
5
  *
6
- * @template SV - A type that extends SchemaValidator.
7
- * @typedef {ValidSchemaObject<SV> | UnboxedObjectSchema<SchemaCatchall<SV>> & {}} EntityMapperSchemaValidatorObject
6
+ * @template SV - A type that extends AnySchemaValidator.
7
+ * @typedef {SV['_ValidSchemaObject'] | UnboxedObjectSchema<SV>} EntityMapperSchemaValidatorObject
8
8
  */
9
9
  export type EntityMapperSchemaValidatorObject<SV extends AnySchemaValidator> = SV['_ValidSchemaObject'] | UnboxedObjectSchema<SV>;
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Object-map of the HTTP Status Codes. Maps from the status code, to the
3
+ * textual name. The key is the HTTP Status Code number, and the resulting
4
+ * value will be the textual name for that Status Code.
5
+ *
6
+ * The comments for each item are taken from httpstatuses.com and the RFC-7231
7
+ * document.
8
+ *
9
+ * @see https://httpstatuses.com
10
+ * @see https://datatracker.ietf.org/doc/html/rfc7231
11
+ */
12
+ export declare const HTTPStatuses: Readonly<{
13
+ [key: number]: string;
14
+ }>;
15
+ /**
16
+ * Numerical HTTP status code.
17
+ */
18
+ export type StatusCode = keyof typeof HTTPStatuses;
19
+ /**
20
+ * Checks if the given numerical status code is in the known HTTP status codes
21
+ * list.
22
+ *
23
+ * @param code HTTP Status code
24
+ * @returns True if the code is a valid HTTP status code
25
+ */
26
+ export declare const isValidStatusCode: (code: number) => boolean;
27
+ /**
28
+ * Checks if the given status code is in the informational range (1XX).
29
+ *
30
+ * @param code HTTP Status code
31
+ * @returns True if the code is in the "informational" range.
32
+ */
33
+ export declare const isInformational: (code: StatusCode) => boolean;
34
+ /**
35
+ * Checks if the given status code is in the successful range (2XX).
36
+ *
37
+ * @param code HTTP Status code
38
+ * @returns True if the code is in the "success" range.
39
+ */
40
+ export declare const isSuccessful: (code: StatusCode) => boolean;
41
+ /**
42
+ * Checks if the given status code is in the redirection range (3XX).
43
+ *
44
+ * @param code HTTP Status code
45
+ * @returns True if the code is in the "redirection" range.
46
+ */
47
+ export declare const isRedirection: (code: StatusCode) => boolean;
48
+ /**
49
+ * Checks if the given status code is in the client error range (4XX).
50
+ *
51
+ * @param code HTTP Status code
52
+ * @returns True if the code is in the "client error" range.
53
+ */
54
+ export declare const isClientError: (code: StatusCode) => boolean;
55
+ /**
56
+ * Checks if the given status code is in the server error range (5XX).
57
+ *
58
+ * @param code HTTP Status code
59
+ * @returns True if the code is in the "server error" range.
60
+ */
61
+ export declare const isServerError: (code: StatusCode) => boolean;
62
+ /**
63
+ * Searches the list of HTTP statuses for a matching textual name to the one
64
+ * provided. If a match is found, then the numerical status code is returned,
65
+ * otherwise `null`.
66
+ *
67
+ * Internally, the parameter and the status names are normalized by lower-casing
68
+ * the strings and trimming space.
69
+ *
70
+ * @param status HTTP Status textual name
71
+ * @returns The numerical status code, or null if not found
72
+ */
73
+ export declare const getCodeForStatus: (status: string) => null | StatusCode;
74
+ export default HTTPStatuses;