@nest-yalc-2/utils 1.0.0 → 2.1.0
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 +1 -1
- package/src/__tests__/object-mapper.helper.spec.ts +1 -1
- package/src/__tests__/object-mapper.interceptor.spec.ts +1 -1
- package/src/index.d.ts +19 -19
- package/src/index.js +22 -35
- package/src/index.js.map +1 -1
- package/src/index.ts +21 -21
- package/src/object-mapper.interceptor.d.ts +1 -1
- package/src/object-mapper.interceptor.js +5 -10
- package/src/object-mapper.interceptor.js.map +1 -1
- package/src/object-mapper.interceptor.ts +1 -1
- package/src/simple-mapper.interceptor.js +2 -7
- package/src/simple-mapper.interceptor.js.map +1 -1
- package/src/__mocks__/enum.mock.ts +0 -9
- package/src/__tests__/class.helper.spec.ts +0 -32
- package/src/__tests__/command.helper.spec.ts +0 -35
- package/src/__tests__/config-manager.helper.spec.ts +0 -93
- package/src/__tests__/custom-validator.spec.ts +0 -34
- package/src/__tests__/data-structure.helper.spec.ts +0 -30
- package/src/__tests__/date.helper.spec.ts +0 -78
- package/src/__tests__/encryption.helper.spec.ts +0 -45
- package/src/__tests__/enum.helper.spec.ts +0 -53
- package/src/__tests__/env.helper.spec.ts +0 -68
- package/src/__tests__/error.helper.spec.ts +0 -20
- package/src/__tests__/faker-helper.spec.ts +0 -187
- package/src/__tests__/files.helper.spec.ts +0 -22
- package/src/__tests__/http.helper.spec.ts +0 -15
- package/src/__tests__/interval.helper.spec.ts +0 -29
- package/src/__tests__/math.helper.spec.ts +0 -24
- package/src/__tests__/object.helper.spec.ts +0 -181
- package/src/__tests__/plugin.helper.spec.ts +0 -85
- package/src/__tests__/promise.helper.spec.ts +0 -76
- package/src/__tests__/returnValue.spec.ts +0 -49
- package/src/__tests__/rxjs.helper.spec.ts +0 -79
- package/src/__tests__/tsconfig.json +0 -3
- package/src/__tests__/validator-helper.spec.ts +0 -34
- package/src/__tests__/zlib.helper.spec.ts +0 -20
- package/src/class.helper.d.ts +0 -4
- package/src/class.helper.js +0 -19
- package/src/class.helper.js.map +0 -1
- package/src/class.helper.ts +0 -33
- package/src/command.helper.d.ts +0 -1
- package/src/command.helper.js +0 -16
- package/src/command.helper.js.map +0 -1
- package/src/command.helper.ts +0 -19
- package/src/config-manager.helper.d.ts +0 -12
- package/src/config-manager.helper.js +0 -60
- package/src/config-manager.helper.js.map +0 -1
- package/src/config-manager.helper.ts +0 -122
- package/src/custom-validator.d.ts +0 -3
- package/src/custom-validator.js +0 -13
- package/src/custom-validator.js.map +0 -1
- package/src/custom-validator.ts +0 -13
- package/src/data-structure.helper.d.ts +0 -1
- package/src/data-structure.helper.js +0 -13
- package/src/data-structure.helper.js.map +0 -1
- package/src/data-structure.helper.ts +0 -14
- package/src/date.helper.d.ts +0 -12
- package/src/date.helper.js +0 -47
- package/src/date.helper.js.map +0 -1
- package/src/date.helper.ts +0 -65
- package/src/encryption.helper.d.ts +0 -2
- package/src/encryption.helper.js +0 -58
- package/src/encryption.helper.js.map +0 -1
- package/src/encryption.helper.ts +0 -29
- package/src/enum.helper.d.ts +0 -8
- package/src/enum.helper.js +0 -21
- package/src/enum.helper.js.map +0 -1
- package/src/enum.helper.ts +0 -34
- package/src/env.helper.d.ts +0 -3
- package/src/env.helper.js +0 -23
- package/src/env.helper.js.map +0 -1
- package/src/env.helper.ts +0 -35
- package/src/error.helper.d.ts +0 -1
- package/src/error.helper.js +0 -12
- package/src/error.helper.js.map +0 -1
- package/src/error.helper.ts +0 -12
- package/src/faker-helper.d.ts +0 -16
- package/src/faker-helper.js +0 -73
- package/src/faker-helper.js.map +0 -1
- package/src/faker-helper.ts +0 -98
- package/src/files.helper.d.ts +0 -2
- package/src/files.helper.js +0 -13
- package/src/files.helper.js.map +0 -1
- package/src/files.helper.ts +0 -20
- package/src/http.helper.d.ts +0 -26
- package/src/http.helper.js +0 -84
- package/src/http.helper.js.map +0 -1
- package/src/http.helper.ts +0 -152
- package/src/interval.helper.d.ts +0 -5
- package/src/interval.helper.js +0 -16
- package/src/interval.helper.js.map +0 -1
- package/src/interval.helper.ts +0 -13
- package/src/math.helper.d.ts +0 -1
- package/src/math.helper.js +0 -8
- package/src/math.helper.js.map +0 -1
- package/src/math.helper.ts +0 -4
- package/src/nest.decorator.d.ts +0 -3
- package/src/nest.decorator.js +0 -10
- package/src/nest.decorator.js.map +0 -1
- package/src/nest.decorator.ts +0 -10
- package/src/object-mapper.helper.d.ts +0 -16
- package/src/object-mapper.helper.js +0 -47
- package/src/object-mapper.helper.js.map +0 -1
- package/src/object-mapper.helper.ts +0 -148
- package/src/object.helper.d.ts +0 -18
- package/src/object.helper.js +0 -91
- package/src/object.helper.js.map +0 -1
- package/src/object.helper.ts +0 -173
- package/src/plugin.helper.d.ts +0 -22
- package/src/plugin.helper.js +0 -26
- package/src/plugin.helper.js.map +0 -1
- package/src/plugin.helper.ts +0 -42
- package/src/promise.helper.d.ts +0 -13
- package/src/promise.helper.js +0 -71
- package/src/promise.helper.js.map +0 -1
- package/src/promise.helper.ts +0 -65
- package/src/returnValue.d.ts +0 -14
- package/src/returnValue.js +0 -17
- package/src/returnValue.js.map +0 -1
- package/src/returnValue.ts +0 -26
- package/src/rxjs.helper.d.ts +0 -7
- package/src/rxjs.helper.js +0 -33
- package/src/rxjs.helper.js.map +0 -1
- package/src/rxjs.helper.ts +0 -71
- package/src/validator-helper.d.ts +0 -2
- package/src/validator-helper.js +0 -22
- package/src/validator-helper.js.map +0 -1
- package/src/validator-helper.ts +0 -26
- package/src/zlib.helper.d.ts +0 -3
- package/src/zlib.helper.js +0 -25
- package/src/zlib.helper.js.map +0 -1
- package/src/zlib.helper.ts +0 -19
package/src/http.helper.js
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.httpExceptionStatusCodes = exports.getHttpStatusDescription = exports.HttpStatusCodes = void 0;
|
|
4
|
-
const common_1 = require("@nestjs/common");
|
|
5
|
-
const axios_1 = require("axios");
|
|
6
|
-
exports.HttpStatusCodes = {
|
|
7
|
-
...common_1.HttpStatus,
|
|
8
|
-
...axios_1.HttpStatusCode,
|
|
9
|
-
};
|
|
10
|
-
const httpStatusDescriptions = {
|
|
11
|
-
[common_1.HttpStatus.CONTINUE]: '100: Request received, server awaiting further info.',
|
|
12
|
-
[common_1.HttpStatus.SWITCHING_PROTOCOLS]: '101: Client asked server to switch protocols.',
|
|
13
|
-
[common_1.HttpStatus.PROCESSING]: '102: Server processing request, no response yet.',
|
|
14
|
-
[common_1.HttpStatus.OK]: '200: Request successful and response provided.',
|
|
15
|
-
[common_1.HttpStatus.CREATED]: '201: Request completed, and resource created.',
|
|
16
|
-
[common_1.HttpStatus.ACCEPTED]: '202: Request accepted but processing not complete.',
|
|
17
|
-
[common_1.HttpStatus.NON_AUTHORITATIVE_INFORMATION]: '203: Info from another source returned.',
|
|
18
|
-
[common_1.HttpStatus.NO_CONTENT]: '204: Request succeeded with no content to send.',
|
|
19
|
-
[common_1.HttpStatus.RESET_CONTENT]: '205: Client should reset document view.',
|
|
20
|
-
[common_1.HttpStatus.PARTIAL_CONTENT]: '206: Partial resource returned due to range header.',
|
|
21
|
-
[common_1.HttpStatus.MOVED_PERMANENTLY]: '301: Resource moved permanently.',
|
|
22
|
-
[common_1.HttpStatus.FOUND]: '302: Resource temporarily moved, use given URI.',
|
|
23
|
-
[common_1.HttpStatus.SEE_OTHER]: '303: Response found elsewhere, use GET for that.',
|
|
24
|
-
[common_1.HttpStatus.NOT_MODIFIED]: '304: Resource not modified since last request.',
|
|
25
|
-
[common_1.HttpStatus.TEMPORARY_REDIRECT]: '307: Resource temporarily moved, but use same method.',
|
|
26
|
-
[common_1.HttpStatus.PERMANENT_REDIRECT]: '308: Resource moved permanently, use same method.',
|
|
27
|
-
[common_1.HttpStatus.BAD_REQUEST]: "400: Server couldn't understand request due to invalid syntax.",
|
|
28
|
-
[common_1.HttpStatus.UNAUTHORIZED]: '401: Authentication needed for request.',
|
|
29
|
-
[common_1.HttpStatus.PAYMENT_REQUIRED]: '402: Payment required for this resource.',
|
|
30
|
-
[common_1.HttpStatus.FORBIDDEN]: '403: Server understood but refuses to authorize.',
|
|
31
|
-
[common_1.HttpStatus.NOT_FOUND]: "404: Server can't find the requested resource.",
|
|
32
|
-
[common_1.HttpStatus.METHOD_NOT_ALLOWED]: '405: HTTP method not allowed for resource.',
|
|
33
|
-
[common_1.HttpStatus.NOT_ACCEPTABLE]: "406: Resource doesn't match criteria.",
|
|
34
|
-
[common_1.HttpStatus.PROXY_AUTHENTICATION_REQUIRED]: '407: Proxy authentication required.',
|
|
35
|
-
[common_1.HttpStatus.REQUEST_TIMEOUT]: '408: Server timed out waiting for request.',
|
|
36
|
-
[common_1.HttpStatus.CONFLICT]: '409: Request conflict with server state.',
|
|
37
|
-
[common_1.HttpStatus.GONE]: '410: Resource requested is no longer available.',
|
|
38
|
-
[common_1.HttpStatus.LENGTH_REQUIRED]: '411: Length of request not specified.',
|
|
39
|
-
[common_1.HttpStatus.PRECONDITION_FAILED]: '412: Precondition for request not met.',
|
|
40
|
-
[common_1.HttpStatus.PAYLOAD_TOO_LARGE]: '413: Request payload too large.',
|
|
41
|
-
[common_1.HttpStatus.URI_TOO_LONG]: '414: URI requested is too long.',
|
|
42
|
-
[common_1.HttpStatus.UNSUPPORTED_MEDIA_TYPE]: '415: Media type not supported.',
|
|
43
|
-
[common_1.HttpStatus.REQUESTED_RANGE_NOT_SATISFIABLE]: '416: Range specified is invalid.',
|
|
44
|
-
[common_1.HttpStatus.EXPECTATION_FAILED]: "417: Server can't meet request expectation.",
|
|
45
|
-
[common_1.HttpStatus.I_AM_A_TEAPOT]: "418: I'm a teapot (April Fools joke).",
|
|
46
|
-
[common_1.HttpStatus.UNPROCESSABLE_ENTITY]: '422: Request understandable, but semantically wrong.',
|
|
47
|
-
[common_1.HttpStatus.FAILED_DEPENDENCY]: "424: Request failed due to server's previous request.",
|
|
48
|
-
[common_1.HttpStatus.PRECONDITION_REQUIRED]: '428: Precondition required for request.',
|
|
49
|
-
[common_1.HttpStatus.TOO_MANY_REQUESTS]: '429: Too many requests from this client.',
|
|
50
|
-
[axios_1.HttpStatusCode.UnavailableForLegalReasons]: '451: Unavailable due to legal reasons.',
|
|
51
|
-
[common_1.HttpStatus.INTERNAL_SERVER_ERROR]: "500: Server faced an error and can't provide response.",
|
|
52
|
-
[common_1.HttpStatus.NOT_IMPLEMENTED]: "501: Server doesn't support functionality needed.",
|
|
53
|
-
[common_1.HttpStatus.BAD_GATEWAY]: '502: Server got invalid response from upstream server.',
|
|
54
|
-
[common_1.HttpStatus.SERVICE_UNAVAILABLE]: '503: Server not ready to handle request.',
|
|
55
|
-
[common_1.HttpStatus.GATEWAY_TIMEOUT]: "504: Server didn't get response from another server.",
|
|
56
|
-
[common_1.HttpStatus.HTTP_VERSION_NOT_SUPPORTED]: "505: Server doesn't support HTTP protocol version.",
|
|
57
|
-
};
|
|
58
|
-
const getHttpStatusDescription = (status, fallbackDescription = 'Unknown status code') => {
|
|
59
|
-
return httpStatusDescriptions[status] ?? fallbackDescription;
|
|
60
|
-
};
|
|
61
|
-
exports.getHttpStatusDescription = getHttpStatusDescription;
|
|
62
|
-
exports.httpExceptionStatusCodes = {
|
|
63
|
-
[common_1.BadRequestException.name]: common_1.HttpStatus.BAD_REQUEST,
|
|
64
|
-
[common_1.UnauthorizedException.name]: common_1.HttpStatus.UNAUTHORIZED,
|
|
65
|
-
[common_1.ForbiddenException.name]: common_1.HttpStatus.FORBIDDEN,
|
|
66
|
-
[common_1.NotFoundException.name]: common_1.HttpStatus.NOT_FOUND,
|
|
67
|
-
[common_1.MethodNotAllowedException.name]: common_1.HttpStatus.METHOD_NOT_ALLOWED,
|
|
68
|
-
[common_1.NotAcceptableException.name]: common_1.HttpStatus.NOT_ACCEPTABLE,
|
|
69
|
-
[common_1.RequestTimeoutException.name]: common_1.HttpStatus.REQUEST_TIMEOUT,
|
|
70
|
-
[common_1.ConflictException.name]: common_1.HttpStatus.CONFLICT,
|
|
71
|
-
[common_1.GoneException.name]: common_1.HttpStatus.GONE,
|
|
72
|
-
[common_1.PreconditionFailedException.name]: common_1.HttpStatus.PRECONDITION_FAILED,
|
|
73
|
-
[common_1.PayloadTooLargeException.name]: common_1.HttpStatus.PAYLOAD_TOO_LARGE,
|
|
74
|
-
[common_1.UnsupportedMediaTypeException.name]: common_1.HttpStatus.UNSUPPORTED_MEDIA_TYPE,
|
|
75
|
-
[common_1.UnprocessableEntityException.name]: common_1.HttpStatus.UNPROCESSABLE_ENTITY,
|
|
76
|
-
[common_1.InternalServerErrorException.name]: common_1.HttpStatus.INTERNAL_SERVER_ERROR,
|
|
77
|
-
[common_1.NotImplementedException.name]: common_1.HttpStatus.NOT_IMPLEMENTED,
|
|
78
|
-
[common_1.BadGatewayException.name]: common_1.HttpStatus.BAD_GATEWAY,
|
|
79
|
-
[common_1.ServiceUnavailableException.name]: common_1.HttpStatus.SERVICE_UNAVAILABLE,
|
|
80
|
-
[common_1.GatewayTimeoutException.name]: common_1.HttpStatus.GATEWAY_TIMEOUT,
|
|
81
|
-
[common_1.HttpException.name]: common_1.HttpStatus.INTERNAL_SERVER_ERROR,
|
|
82
|
-
[common_1.MisdirectedException.name]: common_1.HttpStatus.MISDIRECTED,
|
|
83
|
-
};
|
|
84
|
-
//# sourceMappingURL=http.helper.js.map
|
package/src/http.helper.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"http.helper.js","sourceRoot":"","sources":["http.helper.ts"],"names":[],"mappings":";;;AAAA,2CAsBwB;AACxB,iCAAuC;AAE1B,QAAA,eAAe,GAAwB;IAClD,GAAG,mBAAU;IACb,GAAG,sBAAc;CAClB,CAAC;AAKF,MAAM,sBAAsB,GAExB;IACF,CAAC,mBAAU,CAAC,QAAQ,CAAC,EAAE,sDAAsD;IAC7E,CAAC,mBAAU,CAAC,mBAAmB,CAAC,EAC9B,+CAA+C;IACjD,CAAC,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,gCAAuB,CAAC,IAAI,CAAC,EAAE,mBAAU,CAAC,eAAe;IAC1D,CAAC,sBAAa,CAAC,IAAI,CAAC,EAAE,mBAAU,CAAC,qBAAqB;IACtD,CAAC,6BAAoB,CAAC,IAAI,CAAC,EAAE,mBAAU,CAAC,WAAW;CACpD,CAAC"}
|
package/src/http.helper.ts
DELETED
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
BadGatewayException,
|
|
3
|
-
BadRequestException,
|
|
4
|
-
ConflictException,
|
|
5
|
-
ForbiddenException,
|
|
6
|
-
GatewayTimeoutException,
|
|
7
|
-
GoneException,
|
|
8
|
-
HttpException,
|
|
9
|
-
HttpStatus,
|
|
10
|
-
InternalServerErrorException,
|
|
11
|
-
MethodNotAllowedException,
|
|
12
|
-
MisdirectedException,
|
|
13
|
-
NotAcceptableException,
|
|
14
|
-
NotFoundException,
|
|
15
|
-
NotImplementedException,
|
|
16
|
-
PayloadTooLargeException,
|
|
17
|
-
PreconditionFailedException,
|
|
18
|
-
RequestTimeoutException,
|
|
19
|
-
ServiceUnavailableException,
|
|
20
|
-
UnauthorizedException,
|
|
21
|
-
UnprocessableEntityException,
|
|
22
|
-
UnsupportedMediaTypeException,
|
|
23
|
-
} from '@nestjs/common';
|
|
24
|
-
import { HttpStatusCode } from 'axios';
|
|
25
|
-
|
|
26
|
-
export const HttpStatusCodes: Record<string, any> = {
|
|
27
|
-
...HttpStatus,
|
|
28
|
-
...HttpStatusCode,
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
export type HttpStatusCodes =
|
|
32
|
-
(typeof HttpStatusCodes)[keyof typeof HttpStatusCodes];
|
|
33
|
-
|
|
34
|
-
const httpStatusDescriptions: {
|
|
35
|
-
[key in HttpStatusCodes]?: string;
|
|
36
|
-
} = {
|
|
37
|
-
[HttpStatus.CONTINUE]: '100: Request received, server awaiting further info.',
|
|
38
|
-
[HttpStatus.SWITCHING_PROTOCOLS]:
|
|
39
|
-
'101: Client asked server to switch protocols.',
|
|
40
|
-
[HttpStatus.PROCESSING]: '102: Server processing request, no response yet.',
|
|
41
|
-
[HttpStatus.OK]: '200: Request successful and response provided.',
|
|
42
|
-
[HttpStatus.CREATED]: '201: Request completed, and resource created.',
|
|
43
|
-
[HttpStatus.ACCEPTED]: '202: Request accepted but processing not complete.',
|
|
44
|
-
[HttpStatus.NON_AUTHORITATIVE_INFORMATION]:
|
|
45
|
-
'203: Info from another source returned.',
|
|
46
|
-
[HttpStatus.NO_CONTENT]: '204: Request succeeded with no content to send.',
|
|
47
|
-
[HttpStatus.RESET_CONTENT]: '205: Client should reset document view.',
|
|
48
|
-
[HttpStatus.PARTIAL_CONTENT]:
|
|
49
|
-
'206: Partial resource returned due to range header.',
|
|
50
|
-
// [HttpStatus.MULTI_STATUS]: '207: Multiple status responses for request.',
|
|
51
|
-
// [HttpStatus.ALREADY_REPORTED]:
|
|
52
|
-
// '208: Resource state already sent in earlier request.',
|
|
53
|
-
// [HttpStatus.IM_USED]: '226: Request fulfilled and resource modified.',
|
|
54
|
-
// [HttpStatus.MULTIPLE_CHOICES]: '300: Multiple options for the resource.',
|
|
55
|
-
[HttpStatus.MOVED_PERMANENTLY]: '301: Resource moved permanently.',
|
|
56
|
-
[HttpStatus.FOUND]: '302: Resource temporarily moved, use given URI.',
|
|
57
|
-
[HttpStatus.SEE_OTHER]: '303: Response found elsewhere, use GET for that.',
|
|
58
|
-
[HttpStatus.NOT_MODIFIED]: '304: Resource not modified since last request.',
|
|
59
|
-
// [HttpStatus.USE_PROXY]: '305: Must access resource via specified proxy.',
|
|
60
|
-
[HttpStatus.TEMPORARY_REDIRECT]:
|
|
61
|
-
'307: Resource temporarily moved, but use same method.',
|
|
62
|
-
[HttpStatus.PERMANENT_REDIRECT]:
|
|
63
|
-
'308: Resource moved permanently, use same method.',
|
|
64
|
-
[HttpStatus.BAD_REQUEST]:
|
|
65
|
-
"400: Server couldn't understand request due to invalid syntax.",
|
|
66
|
-
[HttpStatus.UNAUTHORIZED]: '401: Authentication needed for request.',
|
|
67
|
-
[HttpStatus.PAYMENT_REQUIRED]: '402: Payment required for this resource.',
|
|
68
|
-
[HttpStatus.FORBIDDEN]: '403: Server understood but refuses to authorize.',
|
|
69
|
-
[HttpStatus.NOT_FOUND]: "404: Server can't find the requested resource.",
|
|
70
|
-
[HttpStatus.METHOD_NOT_ALLOWED]: '405: HTTP method not allowed for resource.',
|
|
71
|
-
[HttpStatus.NOT_ACCEPTABLE]: "406: Resource doesn't match criteria.",
|
|
72
|
-
[HttpStatus.PROXY_AUTHENTICATION_REQUIRED]:
|
|
73
|
-
'407: Proxy authentication required.',
|
|
74
|
-
[HttpStatus.REQUEST_TIMEOUT]: '408: Server timed out waiting for request.',
|
|
75
|
-
[HttpStatus.CONFLICT]: '409: Request conflict with server state.',
|
|
76
|
-
[HttpStatus.GONE]: '410: Resource requested is no longer available.',
|
|
77
|
-
[HttpStatus.LENGTH_REQUIRED]: '411: Length of request not specified.',
|
|
78
|
-
[HttpStatus.PRECONDITION_FAILED]: '412: Precondition for request not met.',
|
|
79
|
-
[HttpStatus.PAYLOAD_TOO_LARGE]: '413: Request payload too large.',
|
|
80
|
-
[HttpStatus.URI_TOO_LONG]: '414: URI requested is too long.',
|
|
81
|
-
[HttpStatus.UNSUPPORTED_MEDIA_TYPE]: '415: Media type not supported.',
|
|
82
|
-
[HttpStatus.REQUESTED_RANGE_NOT_SATISFIABLE]:
|
|
83
|
-
'416: Range specified is invalid.',
|
|
84
|
-
[HttpStatus.EXPECTATION_FAILED]:
|
|
85
|
-
"417: Server can't meet request expectation.",
|
|
86
|
-
[HttpStatus.I_AM_A_TEAPOT]: "418: I'm a teapot (April Fools joke).",
|
|
87
|
-
// [HttpStatus.MISDIRECTED_REQUEST]:
|
|
88
|
-
// "421: Request misdirected, can't produce response.",
|
|
89
|
-
[HttpStatus.UNPROCESSABLE_ENTITY]:
|
|
90
|
-
'422: Request understandable, but semantically wrong.',
|
|
91
|
-
// [HttpStatus.LOCKED]: "423: Resource you're accessing is locked.",
|
|
92
|
-
[HttpStatus.FAILED_DEPENDENCY]:
|
|
93
|
-
"424: Request failed due to server's previous request.",
|
|
94
|
-
// [HttpStatus.TOO_EARLY]: '425: Request might be replayed.',
|
|
95
|
-
// [HttpStatus.UPGRADE_REQUIRED]:
|
|
96
|
-
// '426: Client should switch to another protocol.',
|
|
97
|
-
[HttpStatus.PRECONDITION_REQUIRED]: '428: Precondition required for request.',
|
|
98
|
-
[HttpStatus.TOO_MANY_REQUESTS]: '429: Too many requests from this client.',
|
|
99
|
-
// [HttpStatus.REQUEST_HEADER_FIELDS_TOO_LARGE]: '431: Headers too long.',
|
|
100
|
-
[HttpStatusCode.UnavailableForLegalReasons]:
|
|
101
|
-
'451: Unavailable due to legal reasons.',
|
|
102
|
-
[HttpStatus.INTERNAL_SERVER_ERROR]:
|
|
103
|
-
"500: Server faced an error and can't provide response.",
|
|
104
|
-
[HttpStatus.NOT_IMPLEMENTED]:
|
|
105
|
-
"501: Server doesn't support functionality needed.",
|
|
106
|
-
[HttpStatus.BAD_GATEWAY]:
|
|
107
|
-
'502: Server got invalid response from upstream server.',
|
|
108
|
-
[HttpStatus.SERVICE_UNAVAILABLE]: '503: Server not ready to handle request.',
|
|
109
|
-
[HttpStatus.GATEWAY_TIMEOUT]:
|
|
110
|
-
"504: Server didn't get response from another server.",
|
|
111
|
-
[HttpStatus.HTTP_VERSION_NOT_SUPPORTED]:
|
|
112
|
-
"505: Server doesn't support HTTP protocol version.",
|
|
113
|
-
// [HttpStatus.VARIANT_ALSO_NEGOTIATES]:
|
|
114
|
-
// '506: Server has internal configuration error.',
|
|
115
|
-
// [HttpStatus.INSUFFICIENT_STORAGE]:
|
|
116
|
-
// "507: Server can't store the representation.",
|
|
117
|
-
// [HttpStatus.LOOP_DETECTED]:
|
|
118
|
-
// '508: Server detected an infinite loop while processing.',
|
|
119
|
-
// [HttpStatus.NOT_EXTENDED]: '510: Further extensions needed for request.',
|
|
120
|
-
// [HttpStatus.NETWORK_AUTHENTICATION_REQUIRED]:
|
|
121
|
-
// '511: Client needs to authenticate for network access.',
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
export const getHttpStatusDescription = (
|
|
125
|
-
status: HttpStatusCodes,
|
|
126
|
-
fallbackDescription = 'Unknown status code',
|
|
127
|
-
): string => {
|
|
128
|
-
return httpStatusDescriptions[status] ?? fallbackDescription;
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
export const httpExceptionStatusCodes = {
|
|
132
|
-
[BadRequestException.name]: HttpStatus.BAD_REQUEST,
|
|
133
|
-
[UnauthorizedException.name]: HttpStatus.UNAUTHORIZED,
|
|
134
|
-
[ForbiddenException.name]: HttpStatus.FORBIDDEN,
|
|
135
|
-
[NotFoundException.name]: HttpStatus.NOT_FOUND,
|
|
136
|
-
[MethodNotAllowedException.name]: HttpStatus.METHOD_NOT_ALLOWED,
|
|
137
|
-
[NotAcceptableException.name]: HttpStatus.NOT_ACCEPTABLE,
|
|
138
|
-
[RequestTimeoutException.name]: HttpStatus.REQUEST_TIMEOUT,
|
|
139
|
-
[ConflictException.name]: HttpStatus.CONFLICT,
|
|
140
|
-
[GoneException.name]: HttpStatus.GONE,
|
|
141
|
-
[PreconditionFailedException.name]: HttpStatus.PRECONDITION_FAILED,
|
|
142
|
-
[PayloadTooLargeException.name]: HttpStatus.PAYLOAD_TOO_LARGE,
|
|
143
|
-
[UnsupportedMediaTypeException.name]: HttpStatus.UNSUPPORTED_MEDIA_TYPE,
|
|
144
|
-
[UnprocessableEntityException.name]: HttpStatus.UNPROCESSABLE_ENTITY,
|
|
145
|
-
[InternalServerErrorException.name]: HttpStatus.INTERNAL_SERVER_ERROR,
|
|
146
|
-
[NotImplementedException.name]: HttpStatus.NOT_IMPLEMENTED,
|
|
147
|
-
[BadGatewayException.name]: HttpStatus.BAD_GATEWAY,
|
|
148
|
-
[ServiceUnavailableException.name]: HttpStatus.SERVICE_UNAVAILABLE,
|
|
149
|
-
[GatewayTimeoutException.name]: HttpStatus.GATEWAY_TIMEOUT,
|
|
150
|
-
[HttpException.name]: HttpStatus.INTERNAL_SERVER_ERROR,
|
|
151
|
-
[MisdirectedException.name]: HttpStatus.MISDIRECTED,
|
|
152
|
-
};
|
package/src/interval.helper.d.ts
DELETED
package/src/interval.helper.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.IntervalHelper = void 0;
|
|
4
|
-
class IntervalHelper {
|
|
5
|
-
static createOneDayInterval() {
|
|
6
|
-
return 24 * 60 * 60 * 1000;
|
|
7
|
-
}
|
|
8
|
-
static createOneSecondInterval() {
|
|
9
|
-
return 1000;
|
|
10
|
-
}
|
|
11
|
-
static createFiveMinutesInterval() {
|
|
12
|
-
return 1000 * 60 * 5;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
exports.IntervalHelper = IntervalHelper;
|
|
16
|
-
//# sourceMappingURL=interval.helper.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"interval.helper.js","sourceRoot":"","sources":["interval.helper.ts"],"names":[],"mappings":";;;AAAA,MAAa,cAAc;IACzB,MAAM,CAAC,oBAAoB;QACzB,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IAC7B,CAAC;IAED,MAAM,CAAC,uBAAuB;QAC5B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,CAAC,yBAAyB;QAC9B,OAAO,IAAI,GAAG,EAAE,GAAG,CAAC,CAAC;IACvB,CAAC;CACF;AAZD,wCAYC"}
|
package/src/interval.helper.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export class IntervalHelper {
|
|
2
|
-
static createOneDayInterval(): number {
|
|
3
|
-
return 24 * 60 * 60 * 1000;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
static createOneSecondInterval(): number {
|
|
7
|
-
return 1000;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
static createFiveMinutesInterval(): number {
|
|
11
|
-
return 1000 * 60 * 5;
|
|
12
|
-
}
|
|
13
|
-
}
|
package/src/math.helper.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function isScientificNotation(num: any): boolean;
|
package/src/math.helper.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isScientificNotation = isScientificNotation;
|
|
4
|
-
function isScientificNotation(num) {
|
|
5
|
-
const scientificPattern = /^[+-]?\d+(\.\d+)?[eE][+-]?\d+$/;
|
|
6
|
-
return scientificPattern.test(num.toString());
|
|
7
|
-
}
|
|
8
|
-
//# sourceMappingURL=math.helper.js.map
|
package/src/math.helper.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"math.helper.js","sourceRoot":"","sources":["math.helper.ts"],"names":[],"mappings":";;AAAA,oDAGC;AAHD,SAAgB,oBAAoB,CAAC,GAAQ;IAC3C,MAAM,iBAAiB,GAAG,gCAAgC,CAAC;IAC3D,OAAO,iBAAiB,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC;AAChD,CAAC"}
|
package/src/math.helper.ts
DELETED
package/src/nest.decorator.d.ts
DELETED
package/src/nest.decorator.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.GetContext = exports.paramDecoratorToCreate = void 0;
|
|
4
|
-
const common_1 = require("@nestjs/common");
|
|
5
|
-
const paramDecoratorToCreate = (_data, context) => {
|
|
6
|
-
return context;
|
|
7
|
-
};
|
|
8
|
-
exports.paramDecoratorToCreate = paramDecoratorToCreate;
|
|
9
|
-
exports.GetContext = (0, common_1.createParamDecorator)(exports.paramDecoratorToCreate);
|
|
10
|
-
//# sourceMappingURL=nest.decorator.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"nest.decorator.js","sourceRoot":"","sources":["nest.decorator.ts"],"names":[],"mappings":";;;AAAA,2CAAwE;AAEjE,MAAM,sBAAsB,GAAG,CACpC,KAAc,EACd,OAAyB,EACP,EAAE;IACpB,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AALW,QAAA,sBAAsB,0BAKjC;AAEW,QAAA,UAAU,GAAG,IAAA,6BAAoB,EAAC,8BAAsB,CAAC,CAAC"}
|
package/src/nest.decorator.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { ExecutionContext, createParamDecorator } from '@nestjs/common';
|
|
2
|
-
|
|
3
|
-
export const paramDecoratorToCreate = (
|
|
4
|
-
_data: unknown,
|
|
5
|
-
context: ExecutionContext,
|
|
6
|
-
): ExecutionContext => {
|
|
7
|
-
return context;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export const GetContext = createParamDecorator(paramDecoratorToCreate);
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export type ObjectMapperDestPropertyType<TInputObject extends Record<string, any>, TOutputObject extends Record<string, any>, TPropertyDest extends keyof TOutputObject> = {
|
|
2
|
-
transformer?: (inputObject: TInputObject, propertyName: keyof TInputObject) => TOutputObject[TPropertyDest];
|
|
3
|
-
exclude?: boolean;
|
|
4
|
-
};
|
|
5
|
-
type ObjectType<TInputObject extends Record<string, any>, TOutputObject extends Record<string, any>> = {
|
|
6
|
-
[index in keyof TInputObject]: Partial<{
|
|
7
|
-
[K in keyof TOutputObject]: ObjectMapperDestPropertyType<TInputObject, TOutputObject, K> | boolean;
|
|
8
|
-
}> | keyof TOutputObject | false;
|
|
9
|
-
} & Partial<{
|
|
10
|
-
[index in '$transformer']: (inputObject: TInputObject, outputObject: TOutputObject) => void;
|
|
11
|
-
}>;
|
|
12
|
-
export type ObjectMapperType<TInputObject extends Record<string, any>, TOutputObject extends Record<string, any>> = ObjectType<TInputObject, TOutputObject>;
|
|
13
|
-
export declare function objectMapper<TInputObject extends Record<string, any>, TOutputObject extends Record<string, any>>(inputObject: TInputObject, mapper: ObjectMapperType<TInputObject, TOutputObject>, options?: {
|
|
14
|
-
copyNonMappedProperties?: boolean;
|
|
15
|
-
}): TOutputObject;
|
|
16
|
-
export {};
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.objectMapper = objectMapper;
|
|
4
|
-
function setMappedProperty(mapProperty, inputObject, outputObject, propertyName, outputKey) {
|
|
5
|
-
let options;
|
|
6
|
-
if (mapProperty === true) {
|
|
7
|
-
options = {};
|
|
8
|
-
}
|
|
9
|
-
else {
|
|
10
|
-
options = mapProperty;
|
|
11
|
-
}
|
|
12
|
-
if (options.exclude === true)
|
|
13
|
-
return;
|
|
14
|
-
outputObject[outputKey] = options.transformer
|
|
15
|
-
? options.transformer(inputObject, propertyName)
|
|
16
|
-
: inputObject[propertyName];
|
|
17
|
-
}
|
|
18
|
-
function objectMapper(inputObject, mapper, options = {}) {
|
|
19
|
-
const outputObject = {};
|
|
20
|
-
for (const propertyName in inputObject) {
|
|
21
|
-
if (propertyName === '$transformer') {
|
|
22
|
-
const transformer = inputObject[propertyName];
|
|
23
|
-
transformer(inputObject, outputObject);
|
|
24
|
-
continue;
|
|
25
|
-
}
|
|
26
|
-
const mapProperty = mapper[propertyName];
|
|
27
|
-
if (mapProperty === undefined) {
|
|
28
|
-
if (options.copyNonMappedProperties === true)
|
|
29
|
-
outputObject[propertyName] = inputObject[propertyName];
|
|
30
|
-
continue;
|
|
31
|
-
}
|
|
32
|
-
if (mapProperty === false)
|
|
33
|
-
continue;
|
|
34
|
-
if (typeof mapProperty !== 'object') {
|
|
35
|
-
outputObject[mapProperty] = inputObject[propertyName];
|
|
36
|
-
continue;
|
|
37
|
-
}
|
|
38
|
-
Object.keys(mapProperty).forEach((mapPropertyKey) => {
|
|
39
|
-
const mapPropertyItem = mapProperty[mapPropertyKey];
|
|
40
|
-
if (!mapPropertyItem)
|
|
41
|
-
return;
|
|
42
|
-
setMappedProperty(mapPropertyItem, inputObject, outputObject, propertyName, mapPropertyKey);
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
return outputObject;
|
|
46
|
-
}
|
|
47
|
-
//# sourceMappingURL=object-mapper.helper.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"object-mapper.helper.js","sourceRoot":"","sources":["object-mapper.helper.ts"],"names":[],"mappings":";;AA0EA,oCAyEC;AA/GD,SAAS,iBAAiB,CAKxB,WAEQ,EACR,WAAyB,EACzB,YAA2B,EAC3B,YAAgC,EAChC,SAAwB;IAExB,IAAI,OAIH,CAAC;IAEF,IAAI,WAAW,KAAK,IAAI,EAAE,CAAC;QACzB,OAAO,GAAG,EAAE,CAAC;IACf,CAAC;SAAM,CAAC;QACN,OAAO,GAAG,WAAW,CAAC;IACxB,CAAC;IAED,IAAI,OAAO,CAAC,OAAO,KAAK,IAAI;QAAE,OAAO;IAErC,YAAY,CAAC,SAAS,CAAC,GAAG,OAAO,CAAC,WAAW;QAC3C,CAAC,CAAE,OAAO,CAAC,WAAW,CAAC,WAAW,EAAE,YAAY,CAAS;QACzD,CAAC,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC;AAChC,CAAC;AAQD,SAAgB,YAAY,CAI1B,WAAyB,EACzB,MAAqD,EACrD,UAEI,EAAE;IAEN,MAAM,YAAY,GAAkB,EAAmB,CAAC;IACxD,KAAK,MAAM,YAAY,IAAI,WAAW,EAAE,CAAC;QACvC,IAAI,YAAY,KAAK,cAAc,EAAE,CAAC;YACpC,MAAM,WAAW,GAAG,WAAW,CAAC,YAAY,CAGnC,CAAC;YACV,WAAW,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC;YACvC,SAAS;QACX,CAAC;QAED,MAAM,WAAW,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC;QAGzC,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;YAO9B,IAAI,OAAO,CAAC,uBAAuB,KAAK,IAAI;gBAC1C,YAAY,CAAC,YAAmC,CAAC,GAAG,WAAW,CAC7D,YAAY,CACN,CAAC;YAEX,SAAS;QACX,CAAC;QAGD,IAAI,WAAW,KAAK,KAAK;YAAE,SAAS;QAGpC,IAAI,OAAO,WAAW,KAAK,QAAQ,EAAE,CAAC;YACpC,YAAY,CAAC,WAAkC,CAAC,GAAG,WAAW,CAC5D,YAAY,CACN,CAAC;YACT,SAAS;QACX,CAAC;QAED,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,CAAC,cAAc,EAAE,EAAE;YAQlD,MAAM,eAAe,GAAG,WAAW,CAAC,cAAc,CAAC,CAAC;YAEpD,IAAI,CAAC,eAAe;gBAAE,OAAO;YAE7B,iBAAiB,CACf,eAAe,EACf,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,cAAc,CACf,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;IAED,OAAO,YAAY,CAAC;AACtB,CAAC"}
|
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
export type ObjectMapperDestPropertyType<
|
|
2
|
-
TInputObject extends Record<string, any>,
|
|
3
|
-
TOutputObject extends Record<string, any>,
|
|
4
|
-
TPropertyDest extends keyof TOutputObject,
|
|
5
|
-
> = {
|
|
6
|
-
transformer?: (
|
|
7
|
-
inputObject: TInputObject,
|
|
8
|
-
propertyName: keyof TInputObject,
|
|
9
|
-
) => TOutputObject[TPropertyDest];
|
|
10
|
-
exclude?: boolean;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
type ObjectType<
|
|
14
|
-
TInputObject extends Record<string, any>,
|
|
15
|
-
TOutputObject extends Record<string, any>,
|
|
16
|
-
> = {
|
|
17
|
-
[index in keyof TInputObject]:
|
|
18
|
-
| Partial<{
|
|
19
|
-
[K in keyof TOutputObject]:
|
|
20
|
-
| ObjectMapperDestPropertyType<TInputObject, TOutputObject, K>
|
|
21
|
-
| boolean;
|
|
22
|
-
}>
|
|
23
|
-
| keyof TOutputObject
|
|
24
|
-
| false;
|
|
25
|
-
} & Partial<{
|
|
26
|
-
[index in '$transformer']: (
|
|
27
|
-
inputObject: TInputObject,
|
|
28
|
-
outputObject: TOutputObject,
|
|
29
|
-
) => void;
|
|
30
|
-
}>;
|
|
31
|
-
|
|
32
|
-
export type ObjectMapperType<
|
|
33
|
-
TInputObject extends Record<string, any>,
|
|
34
|
-
TOutputObject extends Record<string, any>,
|
|
35
|
-
> = ObjectType<TInputObject, TOutputObject>;
|
|
36
|
-
|
|
37
|
-
function setMappedProperty<
|
|
38
|
-
TInputObject extends Record<string, any>,
|
|
39
|
-
TOutputObject extends Record<string, any>,
|
|
40
|
-
TPropertyDest extends keyof TOutputObject,
|
|
41
|
-
>(
|
|
42
|
-
mapProperty:
|
|
43
|
-
| ObjectMapperDestPropertyType<TInputObject, TOutputObject, TPropertyDest>
|
|
44
|
-
| true,
|
|
45
|
-
inputObject: TInputObject,
|
|
46
|
-
outputObject: TOutputObject,
|
|
47
|
-
propertyName: keyof TInputObject,
|
|
48
|
-
outputKey: TPropertyDest,
|
|
49
|
-
) {
|
|
50
|
-
let options: ObjectMapperDestPropertyType<
|
|
51
|
-
TInputObject,
|
|
52
|
-
TOutputObject,
|
|
53
|
-
TPropertyDest
|
|
54
|
-
>;
|
|
55
|
-
|
|
56
|
-
if (mapProperty === true) {
|
|
57
|
-
options = {};
|
|
58
|
-
} else {
|
|
59
|
-
options = mapProperty;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
if (options.exclude === true) return; // do not map
|
|
63
|
-
|
|
64
|
-
outputObject[outputKey] = options.transformer
|
|
65
|
-
? (options.transformer(inputObject, propertyName) as any)
|
|
66
|
-
: inputObject[propertyName];
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* This function allows to map 2 Objects with different properties by using
|
|
71
|
-
* a bridge object (the mapper). In this way we can avoid using property decorators
|
|
72
|
-
* that limit the mapping to a single destination, by allowing any mapping combinations.
|
|
73
|
-
*
|
|
74
|
-
*/
|
|
75
|
-
export function objectMapper<
|
|
76
|
-
TInputObject extends Record<string, any>,
|
|
77
|
-
TOutputObject extends Record<string, any>,
|
|
78
|
-
>(
|
|
79
|
-
inputObject: TInputObject,
|
|
80
|
-
mapper: ObjectMapperType<TInputObject, TOutputObject>,
|
|
81
|
-
options: {
|
|
82
|
-
copyNonMappedProperties?: boolean;
|
|
83
|
-
} = {},
|
|
84
|
-
): TOutputObject {
|
|
85
|
-
const outputObject: TOutputObject = {} as TOutputObject;
|
|
86
|
-
for (const propertyName in inputObject) {
|
|
87
|
-
if (propertyName === '$transformer') {
|
|
88
|
-
const transformer = inputObject[propertyName] as (
|
|
89
|
-
inputObject: TInputObject,
|
|
90
|
-
outputObject: TOutputObject,
|
|
91
|
-
) => void;
|
|
92
|
-
transformer(inputObject, outputObject);
|
|
93
|
-
continue;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
const mapProperty = mapper[propertyName];
|
|
97
|
-
|
|
98
|
-
// handle mapping when properties are not specified but the option is enabled
|
|
99
|
-
if (mapProperty === undefined) {
|
|
100
|
-
// TODO: use an option to enable this behaviour
|
|
101
|
-
// if (!Object.keys(outputObject).includes(propertyName))
|
|
102
|
-
// throw new Error(
|
|
103
|
-
// `Cannot map property ${propertyName} into the OutputObject. Property doesn't exist in the destination`,
|
|
104
|
-
// );
|
|
105
|
-
|
|
106
|
-
if (options.copyNonMappedProperties === true)
|
|
107
|
-
outputObject[propertyName as keyof TOutputObject] = inputObject[
|
|
108
|
-
propertyName
|
|
109
|
-
] as any;
|
|
110
|
-
|
|
111
|
-
continue;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
// handle excluded properties
|
|
115
|
-
if (mapProperty === false) continue; // do not map
|
|
116
|
-
|
|
117
|
-
// handle simple mapping with a string
|
|
118
|
-
if (typeof mapProperty !== 'object') {
|
|
119
|
-
outputObject[mapProperty as keyof TOutputObject] = inputObject[
|
|
120
|
-
propertyName
|
|
121
|
-
] as any;
|
|
122
|
-
continue;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
Object.keys(mapProperty).forEach((mapPropertyKey) => {
|
|
126
|
-
// if (typeof mapProperty === 'boolean') {
|
|
127
|
-
// outputObject[mapPropertyKey as keyof TOutputObject] = inputObject[
|
|
128
|
-
// propertyName
|
|
129
|
-
// ] as any;
|
|
130
|
-
// return;
|
|
131
|
-
// }
|
|
132
|
-
|
|
133
|
-
const mapPropertyItem = mapProperty[mapPropertyKey];
|
|
134
|
-
|
|
135
|
-
if (!mapPropertyItem) return; // do not map (should not happen)
|
|
136
|
-
|
|
137
|
-
setMappedProperty(
|
|
138
|
-
mapPropertyItem,
|
|
139
|
-
inputObject,
|
|
140
|
-
outputObject,
|
|
141
|
-
propertyName,
|
|
142
|
-
mapPropertyKey,
|
|
143
|
-
);
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
return outputObject;
|
|
148
|
-
}
|
package/src/object.helper.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
interface IIsObject {
|
|
2
|
-
(item: any): boolean;
|
|
3
|
-
}
|
|
4
|
-
interface IObject {
|
|
5
|
-
[key: string]: any;
|
|
6
|
-
}
|
|
7
|
-
interface IDeepMerge {
|
|
8
|
-
(target: IObject, ...sources: Array<IObject>): IObject;
|
|
9
|
-
}
|
|
10
|
-
export declare const isObject: IIsObject;
|
|
11
|
-
export declare function isObjectStrict(val: any): val is Record<string, any>;
|
|
12
|
-
export declare const _deepMerge: (isArrayConcat: boolean, target: IObject, ...sources: Array<IObject>) => IObject;
|
|
13
|
-
export declare const deepMerge: IDeepMerge;
|
|
14
|
-
export declare const deepMergeWithoutArrayConcat: IDeepMerge;
|
|
15
|
-
export declare function objectSetProp(obj: Record<any, any>, path: string, value: any): Record<any, any>;
|
|
16
|
-
export declare function objectsHaveSameKeys(...objects: any[]): boolean;
|
|
17
|
-
export declare function getObjectId(object: Record<string, unknown> | Array<unknown>): number;
|
|
18
|
-
export {};
|