@forklaunch/core 0.1.5 → 0.1.7
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/cache/redisTtlCache.d.ts +1 -0
- package/dist/cache/redisTtlCache.js +1 -0
- package/dist/cache/redisTtlCache.js.map +1 -1
- package/dist/entityMapper/interfaces/entityMapper.interface.d.ts +1 -0
- package/dist/entityMapper/models/baseEntityMapper.model.d.ts +7 -7
- package/dist/entityMapper/models/baseEntityMapper.model.js +7 -7
- package/dist/entityMapper/models/baseEntityMapper.model.js.map +1 -1
- package/dist/entityMapper/models/requestEntityMapper.model.d.ts +13 -9
- package/dist/entityMapper/models/requestEntityMapper.model.js +13 -9
- package/dist/entityMapper/models/requestEntityMapper.model.js.map +1 -1
- package/dist/entityMapper/models/responseEntityMapper.model.d.ts +14 -7
- package/dist/entityMapper/models/responseEntityMapper.model.js +12 -6
- package/dist/entityMapper/models/responseEntityMapper.model.js.map +1 -1
- package/dist/entityMapper/types/entityMapper.types.d.ts +2 -2
- package/dist/http/index.d.ts +1 -0
- package/dist/http/index.js +1 -0
- package/dist/http/index.js.map +1 -1
- package/dist/http/middleware/request.middleware.d.ts +84 -0
- package/dist/http/middleware/request.middleware.js +105 -2
- package/dist/http/middleware/request.middleware.js.map +1 -1
- package/dist/http/middleware/response.middleware.d.ts +11 -0
- package/dist/http/middleware/response.middleware.js +23 -3
- package/dist/http/middleware/response.middleware.js.map +1 -1
- package/dist/http/openApiV3Generator.d.ts +9 -0
- package/dist/http/openApiV3Generator.js +43 -6
- package/dist/http/openApiV3Generator.js.map +1 -1
- package/dist/http/regex.d.ts +8 -0
- package/dist/http/regex.js +115 -0
- package/dist/http/regex.js.map +1 -0
- package/dist/http/types/api.types.d.ts +71 -0
- package/dist/http/types/forklaunch.types.d.ts +17 -0
- package/dist/http/types/primitive.types.d.ts +73 -0
- package/package.json +3 -2
@@ -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.ttlMilliseconds = ttlMilliseconds;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"redisTtlCache.js","sourceRoot":"","sources":["../../cache/redisTtlCache.ts"],"names":[],"mappings":";;;AAAA,iCAAyD;AAIzD;;;GAGG;AACH,MAAa,aAAa;
|
1
|
+
{"version":3,"file":"redisTtlCache.js","sourceRoot":"","sources":["../../cache/redisTtlCache.ts"],"names":[],"mappings":";;;AAAA,iCAAyD;AAIzD;;;GAGG;AACH,MAAa,aAAa;IAUd;IATF,MAAM,CAAC;IAEf;;;;;OAKG;IACH,YACU,eAAuB,EAC/B,cAAmC;QAD3B,oBAAe,GAAf,eAAe,CAAQ;QAG/B,wCAAwC;QACxC,0EAA0E;QAC1E,IAAI,CAAC,MAAM,GAAG,IAAA,oBAAY,EAAC,cAAc,CAAC,CAAC;QAC3C,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,oBAAoB,EAAE,GAAG,CAAC,CAAC,CAAC;QACzE,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE;YAC7B,OAAO,CAAC,GAAG,CAAC,mBAAmB,EAAE,iCAAiC,CAAC,CAAC,CAAC,aAAa;QACpF,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAC7C,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,SAAS,CAAC,EACd,GAAG,EACH,KAAK,EACL,eAAe,GAAG,IAAI,CAAC,eAAe,EACvB;QACf,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE;YAChD,EAAE,EAAE,eAAe;SACpB,CAAC,CAAC;IACL,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,YAAY,CAAC,cAAsB;QACvC,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IACxC,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,UAAU,CAAC,cAAsB;QACrC,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;QACpD,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;YACnB,MAAM,IAAI,KAAK,CAAC,6BAA6B,cAAc,EAAE,CAAC,CAAC;QACjE,CAAC;QACD,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,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
|
-
* @
|
9
|
-
* @param {
|
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
|
15
|
+
* Abstract class representing a base entity mapper.
|
15
16
|
*
|
16
|
-
* @template SV - A type that extends
|
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
|
-
* @
|
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
|
-
* @
|
10
|
-
* @param {
|
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
|
18
|
+
* Abstract class representing a base entity mapper.
|
18
19
|
*
|
19
|
-
* @template SV - A type that extends
|
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
|
-
* @
|
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":";;;
|
1
|
+
{"version":3,"file":"baseEntityMapper.model.js","sourceRoot":"","sources":["../../../entityMapper/models/baseEntityMapper.model.ts"],"names":[],"mappings":";;;AAiBA,8BAKC;AAdD;;;;;;;;GAQG;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;;;OAGG;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;;;;OAIG;IACH,IAAI,GAAG;QACL,OAAO,IAAI,CAAC,IAA+B,CAAC;IAC9C,CAAC;IAED;;;;;;;OAOG;IACH,MAAM,CAAC,MAAM;QAGX,OAAO,SAAS,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC;IAChC,CAAC;CACF;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
|
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
|
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
|
-
* @
|
47
|
-
* @
|
48
|
-
* @param {T
|
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
|
-
* @
|
57
|
-
* @
|
58
|
-
* @param {T
|
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
|
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
|
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
|
-
* @
|
47
|
-
* @
|
48
|
-
* @param {T
|
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
|
-
* @
|
59
|
-
* @
|
60
|
-
* @param {T
|
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
|
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
|
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
|
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
|
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
|
44
|
+
* Populates entity mapper with DTO from an entity.
|
43
45
|
*
|
44
46
|
* @template T - A type that extends ResponseEntityMapper.
|
45
|
-
* @
|
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
|
-
* @
|
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
|
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
|
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
|
42
|
+
* Populates entity mapper with DTO from an entity.
|
42
43
|
*
|
43
44
|
* @template T - A type that extends ResponseEntityMapper.
|
44
|
-
* @
|
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
|
-
* @
|
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;
|
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
|
7
|
-
* @typedef {
|
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>;
|
package/dist/http/index.d.ts
CHANGED
package/dist/http/index.js
CHANGED
@@ -17,5 +17,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./httpStatusCodes"), exports);
|
18
18
|
__exportStar(require("./middleware"), exports);
|
19
19
|
__exportStar(require("./openApiV3Generator"), exports);
|
20
|
+
__exportStar(require("./regex"), exports);
|
20
21
|
__exportStar(require("./types"), exports);
|
21
22
|
//# sourceMappingURL=index.js.map
|
package/dist/http/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../http/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAkC;AAClC,+CAA6B;AAC7B,uDAAqC;AACrC,0CAAwB"}
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../http/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAkC;AAClC,+CAA6B;AAC7B,uDAAqC;AACrC,0CAAwB;AACxB,0CAAwB"}
|
@@ -1,11 +1,95 @@
|
|
1
1
|
import { AnySchemaValidator, SchemaValidator } from '@forklaunch/validator';
|
2
2
|
import { ForklaunchNextFunction, ForklaunchRequest, ForklaunchResponse } from '../types/api.types';
|
3
3
|
import { HttpContractDetails, PathParamHttpContractDetails, StringOnlyObject } from '../types/primitive.types';
|
4
|
+
/**
|
5
|
+
* Middleware to create and add a request context.
|
6
|
+
*
|
7
|
+
* @template SV - A type that extends AnySchemaValidator.
|
8
|
+
* @template Request - A type that extends ForklaunchRequest.
|
9
|
+
* @template Response - A type that extends ForklaunchResponse.
|
10
|
+
* @template NextFunction - A type that extends ForklaunchNextFunction.
|
11
|
+
* @param {SV} schemaValidator - The schema validator.
|
12
|
+
* @returns {Function} - Middleware function to create request context.
|
13
|
+
*/
|
4
14
|
export declare function createRequestContext<SV extends AnySchemaValidator, Request extends ForklaunchRequest<SV>, Response extends ForklaunchResponse, NextFunction extends ForklaunchNextFunction>(schemaValidator: SV): (req: Request, res: Response, next?: NextFunction) => void;
|
15
|
+
/**
|
16
|
+
* Middleware to enrich the request details with contract details.
|
17
|
+
*
|
18
|
+
* @template SV - A type that extends AnySchemaValidator.
|
19
|
+
* @template Request - A type that extends ForklaunchRequest.
|
20
|
+
* @template Response - A type that extends ForklaunchResponse.
|
21
|
+
* @template NextFunction - A type that extends ForklaunchNextFunction.
|
22
|
+
* @param {PathParamHttpContractDetails<SV> | HttpContractDetails<SV>} contractDetails - The contract details.
|
23
|
+
* @returns {Function} - Middleware function to enrich request details.
|
24
|
+
*/
|
5
25
|
export declare function enrichRequestDetails<SV extends AnySchemaValidator, Request extends ForklaunchRequest<SV>, Response extends ForklaunchResponse, NextFunction extends ForklaunchNextFunction>(contractDetails: PathParamHttpContractDetails<SV> | HttpContractDetails<SV>): (req: Request, _res: Response, next?: NextFunction) => void;
|
26
|
+
/**
|
27
|
+
* Pre-handler function to parse and validate input.
|
28
|
+
*
|
29
|
+
* @template SV - A type that extends AnySchemaValidator.
|
30
|
+
* @param {SchemaValidator} schemaValidator - The schema validator.
|
31
|
+
* @param {unknown} object - The object to validate.
|
32
|
+
* @param {StringOnlyObject<SV>} [schemaInput] - The schema input.
|
33
|
+
* @returns {number | void} - Returns 400 if validation fails.
|
34
|
+
*/
|
6
35
|
export declare function preHandlerParse<SV extends AnySchemaValidator>(schemaValidator: SchemaValidator, object: unknown, schemaInput?: StringOnlyObject<SV>): 400 | undefined;
|
36
|
+
/**
|
37
|
+
* Middleware to parse request parameters.
|
38
|
+
*
|
39
|
+
* @template SV - A type that extends AnySchemaValidator.
|
40
|
+
* @template Request - A type that extends ForklaunchRequest.
|
41
|
+
* @template Response - A type that extends ForklaunchResponse.
|
42
|
+
* @template NextFunction - A type that extends ForklaunchNextFunction.
|
43
|
+
* @param {Request} req - The request object.
|
44
|
+
* @param {Response} res - The response object.
|
45
|
+
* @param {NextFunction} [next] - The next middleware function.
|
46
|
+
*/
|
7
47
|
export declare function parseRequestParams<SV extends AnySchemaValidator, Request extends ForklaunchRequest<SV>, Response extends ForklaunchResponse, NextFunction extends ForklaunchNextFunction>(req: Request, res: Response, next?: NextFunction): void;
|
48
|
+
/**
|
49
|
+
* Middleware to parse request body.
|
50
|
+
*
|
51
|
+
* @template SV - A type that extends AnySchemaValidator.
|
52
|
+
* @template Request - A type that extends ForklaunchRequest.
|
53
|
+
* @template Response - A type that extends ForklaunchResponse.
|
54
|
+
* @template NextFunction - A type that extends ForklaunchNextFunction.
|
55
|
+
* @param {Request} req - The request object.
|
56
|
+
* @param {Response} res - The response object.
|
57
|
+
* @param {NextFunction} [next] - The next middleware function.
|
58
|
+
*/
|
8
59
|
export declare function parseRequestBody<SV extends AnySchemaValidator, Request extends ForklaunchRequest<SV>, Response extends ForklaunchResponse, NextFunction extends ForklaunchNextFunction>(req: Request, res: Response, next?: NextFunction): void;
|
60
|
+
/**
|
61
|
+
* Middleware to parse request headers.
|
62
|
+
*
|
63
|
+
* @template SV - A type that extends AnySchemaValidator.
|
64
|
+
* @template Request - A type that extends ForklaunchRequest.
|
65
|
+
* @template Response - A type that extends ForklaunchResponse.
|
66
|
+
* @template NextFunction - A type that extends ForklaunchNextFunction.
|
67
|
+
* @param {Request} req - The request object.
|
68
|
+
* @param {Response} res - The response object.
|
69
|
+
* @param {NextFunction} [next] - The next middleware function.
|
70
|
+
*/
|
9
71
|
export declare function parseRequestHeaders<SV extends AnySchemaValidator, Request extends ForklaunchRequest<SV>, Response extends ForklaunchResponse, NextFunction extends ForklaunchNextFunction>(req: Request, res: Response, next?: NextFunction): void;
|
72
|
+
/**
|
73
|
+
* Middleware to parse request query.
|
74
|
+
*
|
75
|
+
* @template SV - A type that extends AnySchemaValidator.
|
76
|
+
* @template Request - A type that extends ForklaunchRequest.
|
77
|
+
* @template Response - A type that extends ForklaunchResponse.
|
78
|
+
* @template NextFunction - A type that extends ForklaunchNextFunction.
|
79
|
+
* @param {Request} req - The request object.
|
80
|
+
* @param {Response} res - The response object.
|
81
|
+
* @param {NextFunction} [next] - The next middleware function.
|
82
|
+
*/
|
10
83
|
export declare function parseRequestQuery<SV extends AnySchemaValidator, Request extends ForklaunchRequest<SV>, Response extends ForklaunchResponse, NextFunction extends ForklaunchNextFunction>(req: Request, res: Response, next?: NextFunction): void;
|
84
|
+
/**
|
85
|
+
* Middleware to parse request authorization.
|
86
|
+
*
|
87
|
+
* @template SV - A type that extends AnySchemaValidator.
|
88
|
+
* @template Request - A type that extends ForklaunchRequest.
|
89
|
+
* @template Response - A type that extends ForklaunchResponse.
|
90
|
+
* @template NextFunction - A type that extends ForklaunchNextFunction.
|
91
|
+
* @param {Request} req - The request object.
|
92
|
+
* @param {Response} res - The response object.
|
93
|
+
* @param {NextFunction} [next] - The next middleware function.
|
94
|
+
*/
|
11
95
|
export declare function parseRequestAuth<SV extends AnySchemaValidator, Request extends ForklaunchRequest<SV>, Response extends ForklaunchResponse, NextFunction extends ForklaunchNextFunction>(req: Request, res: Response, next?: NextFunction): Promise<void>;
|