@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.
Files changed (133) hide show
  1. package/package.json +1 -1
  2. package/src/__tests__/object-mapper.helper.spec.ts +1 -1
  3. package/src/__tests__/object-mapper.interceptor.spec.ts +1 -1
  4. package/src/index.d.ts +19 -19
  5. package/src/index.js +22 -35
  6. package/src/index.js.map +1 -1
  7. package/src/index.ts +21 -21
  8. package/src/object-mapper.interceptor.d.ts +1 -1
  9. package/src/object-mapper.interceptor.js +5 -10
  10. package/src/object-mapper.interceptor.js.map +1 -1
  11. package/src/object-mapper.interceptor.ts +1 -1
  12. package/src/simple-mapper.interceptor.js +2 -7
  13. package/src/simple-mapper.interceptor.js.map +1 -1
  14. package/src/__mocks__/enum.mock.ts +0 -9
  15. package/src/__tests__/class.helper.spec.ts +0 -32
  16. package/src/__tests__/command.helper.spec.ts +0 -35
  17. package/src/__tests__/config-manager.helper.spec.ts +0 -93
  18. package/src/__tests__/custom-validator.spec.ts +0 -34
  19. package/src/__tests__/data-structure.helper.spec.ts +0 -30
  20. package/src/__tests__/date.helper.spec.ts +0 -78
  21. package/src/__tests__/encryption.helper.spec.ts +0 -45
  22. package/src/__tests__/enum.helper.spec.ts +0 -53
  23. package/src/__tests__/env.helper.spec.ts +0 -68
  24. package/src/__tests__/error.helper.spec.ts +0 -20
  25. package/src/__tests__/faker-helper.spec.ts +0 -187
  26. package/src/__tests__/files.helper.spec.ts +0 -22
  27. package/src/__tests__/http.helper.spec.ts +0 -15
  28. package/src/__tests__/interval.helper.spec.ts +0 -29
  29. package/src/__tests__/math.helper.spec.ts +0 -24
  30. package/src/__tests__/object.helper.spec.ts +0 -181
  31. package/src/__tests__/plugin.helper.spec.ts +0 -85
  32. package/src/__tests__/promise.helper.spec.ts +0 -76
  33. package/src/__tests__/returnValue.spec.ts +0 -49
  34. package/src/__tests__/rxjs.helper.spec.ts +0 -79
  35. package/src/__tests__/tsconfig.json +0 -3
  36. package/src/__tests__/validator-helper.spec.ts +0 -34
  37. package/src/__tests__/zlib.helper.spec.ts +0 -20
  38. package/src/class.helper.d.ts +0 -4
  39. package/src/class.helper.js +0 -19
  40. package/src/class.helper.js.map +0 -1
  41. package/src/class.helper.ts +0 -33
  42. package/src/command.helper.d.ts +0 -1
  43. package/src/command.helper.js +0 -16
  44. package/src/command.helper.js.map +0 -1
  45. package/src/command.helper.ts +0 -19
  46. package/src/config-manager.helper.d.ts +0 -12
  47. package/src/config-manager.helper.js +0 -60
  48. package/src/config-manager.helper.js.map +0 -1
  49. package/src/config-manager.helper.ts +0 -122
  50. package/src/custom-validator.d.ts +0 -3
  51. package/src/custom-validator.js +0 -13
  52. package/src/custom-validator.js.map +0 -1
  53. package/src/custom-validator.ts +0 -13
  54. package/src/data-structure.helper.d.ts +0 -1
  55. package/src/data-structure.helper.js +0 -13
  56. package/src/data-structure.helper.js.map +0 -1
  57. package/src/data-structure.helper.ts +0 -14
  58. package/src/date.helper.d.ts +0 -12
  59. package/src/date.helper.js +0 -47
  60. package/src/date.helper.js.map +0 -1
  61. package/src/date.helper.ts +0 -65
  62. package/src/encryption.helper.d.ts +0 -2
  63. package/src/encryption.helper.js +0 -58
  64. package/src/encryption.helper.js.map +0 -1
  65. package/src/encryption.helper.ts +0 -29
  66. package/src/enum.helper.d.ts +0 -8
  67. package/src/enum.helper.js +0 -21
  68. package/src/enum.helper.js.map +0 -1
  69. package/src/enum.helper.ts +0 -34
  70. package/src/env.helper.d.ts +0 -3
  71. package/src/env.helper.js +0 -23
  72. package/src/env.helper.js.map +0 -1
  73. package/src/env.helper.ts +0 -35
  74. package/src/error.helper.d.ts +0 -1
  75. package/src/error.helper.js +0 -12
  76. package/src/error.helper.js.map +0 -1
  77. package/src/error.helper.ts +0 -12
  78. package/src/faker-helper.d.ts +0 -16
  79. package/src/faker-helper.js +0 -73
  80. package/src/faker-helper.js.map +0 -1
  81. package/src/faker-helper.ts +0 -98
  82. package/src/files.helper.d.ts +0 -2
  83. package/src/files.helper.js +0 -13
  84. package/src/files.helper.js.map +0 -1
  85. package/src/files.helper.ts +0 -20
  86. package/src/http.helper.d.ts +0 -26
  87. package/src/http.helper.js +0 -84
  88. package/src/http.helper.js.map +0 -1
  89. package/src/http.helper.ts +0 -152
  90. package/src/interval.helper.d.ts +0 -5
  91. package/src/interval.helper.js +0 -16
  92. package/src/interval.helper.js.map +0 -1
  93. package/src/interval.helper.ts +0 -13
  94. package/src/math.helper.d.ts +0 -1
  95. package/src/math.helper.js +0 -8
  96. package/src/math.helper.js.map +0 -1
  97. package/src/math.helper.ts +0 -4
  98. package/src/nest.decorator.d.ts +0 -3
  99. package/src/nest.decorator.js +0 -10
  100. package/src/nest.decorator.js.map +0 -1
  101. package/src/nest.decorator.ts +0 -10
  102. package/src/object-mapper.helper.d.ts +0 -16
  103. package/src/object-mapper.helper.js +0 -47
  104. package/src/object-mapper.helper.js.map +0 -1
  105. package/src/object-mapper.helper.ts +0 -148
  106. package/src/object.helper.d.ts +0 -18
  107. package/src/object.helper.js +0 -91
  108. package/src/object.helper.js.map +0 -1
  109. package/src/object.helper.ts +0 -173
  110. package/src/plugin.helper.d.ts +0 -22
  111. package/src/plugin.helper.js +0 -26
  112. package/src/plugin.helper.js.map +0 -1
  113. package/src/plugin.helper.ts +0 -42
  114. package/src/promise.helper.d.ts +0 -13
  115. package/src/promise.helper.js +0 -71
  116. package/src/promise.helper.js.map +0 -1
  117. package/src/promise.helper.ts +0 -65
  118. package/src/returnValue.d.ts +0 -14
  119. package/src/returnValue.js +0 -17
  120. package/src/returnValue.js.map +0 -1
  121. package/src/returnValue.ts +0 -26
  122. package/src/rxjs.helper.d.ts +0 -7
  123. package/src/rxjs.helper.js +0 -33
  124. package/src/rxjs.helper.js.map +0 -1
  125. package/src/rxjs.helper.ts +0 -71
  126. package/src/validator-helper.d.ts +0 -2
  127. package/src/validator-helper.js +0 -22
  128. package/src/validator-helper.js.map +0 -1
  129. package/src/validator-helper.ts +0 -26
  130. package/src/zlib.helper.d.ts +0 -3
  131. package/src/zlib.helper.js +0 -25
  132. package/src/zlib.helper.js.map +0 -1
  133. package/src/zlib.helper.ts +0 -19
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nest-yalc-2/utils",
3
- "version": "1.0.0",
3
+ "version": "2.1.0",
4
4
  "description": "",
5
5
  "main": "./src/index.js",
6
6
  "exports": {
@@ -1,6 +1,6 @@
1
1
  import { describe, expect, it } from '@jest/globals';
2
2
 
3
- import { objectMapper } from '../object-mapper.helper.js';
3
+ import { objectMapper } from '.@node-yalc/utils/object-mapper.helper.js';
4
4
 
5
5
  describe('objectMapper', () => {
6
6
  it('should map properties with the specified mapper', () => {
@@ -2,7 +2,7 @@ import { describe, expect, it } from '@jest/globals';
2
2
 
3
3
  import { CallHandler, ExecutionContext } from '@nestjs/common';
4
4
  import { objectMapperInterceptor } from '../object-mapper.interceptor.js';
5
- import { ObjectMapperType } from '../object-mapper.helper.js';
5
+ import { ObjectMapperType } from '.@node-yalc/utils/object-mapper.helper.js';
6
6
  import { of } from 'rxjs';
7
7
  import { createMock } from '@golevelup/ts-jest';
8
8
 
package/src/index.d.ts CHANGED
@@ -1,21 +1,21 @@
1
- export * from './class.helper.js';
2
- export * from './custom-validator.js';
3
- export * from './data-structure.helper.js';
4
- export * from './date.helper.js';
5
- export * from './encryption.helper.js';
6
- export * from './enum.helper.js';
7
- export * from './env.helper.js';
8
- export * from './error.helper.js';
9
- export * from './interval.helper.js';
1
+ export * from '@node-yalc/utils/class.helper';
2
+ export * from '@node-yalc/utils/custom-validator';
3
+ export * from '@node-yalc/utils/data-structure.helper';
4
+ export * from '@node-yalc/utils/date.helper';
5
+ export * from '@node-yalc/utils/encryption.helper';
6
+ export * from '@node-yalc/utils/enum.helper';
7
+ export * from '@node-yalc/utils/env.helper';
8
+ export * from '@node-yalc/utils/error.helper';
9
+ export * from '@node-yalc/utils/interval.helper';
10
10
  export * from './nestjs/nest.decorator.js';
11
- export * from './object.helper.js';
12
- export * from './object-mapper.helper.js';
11
+ export * from '@node-yalc/utils/object.helper';
12
+ export * from '@node-yalc/utils/object-mapper.helper';
13
13
  export * from './object-mapper.interceptor.js';
14
- export * from './returnValue.js';
15
- export * from './validator-helper.js';
16
- export * from './zlib.helper.js';
17
- export * from './command.helper.js';
18
- export * from './files.helper.js';
19
- export * from './rxjs.helper.js';
20
- export * from './math.helper.js';
21
- export * from './config-manager.helper.js';
14
+ export * from '@node-yalc/utils/returnValue';
15
+ export * from '@node-yalc/utils/validator-helper';
16
+ export * from '@node-yalc/utils/zlib.helper';
17
+ export * from '@node-yalc/utils/command.helper';
18
+ export * from '@node-yalc/utils/files.helper';
19
+ export * from '@node-yalc/utils/rxjs.helper';
20
+ export * from '@node-yalc/utils/math.helper';
21
+ export * from '@node-yalc/utils/config-manager.helper';
package/src/index.js CHANGED
@@ -1,38 +1,25 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
2
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./class.helper.js"), exports);
18
- __exportStar(require("./custom-validator.js"), exports);
19
- __exportStar(require("./data-structure.helper.js"), exports);
20
- __exportStar(require("./date.helper.js"), exports);
21
- __exportStar(require("./encryption.helper.js"), exports);
22
- __exportStar(require("./enum.helper.js"), exports);
23
- __exportStar(require("./env.helper.js"), exports);
24
- __exportStar(require("./error.helper.js"), exports);
25
- __exportStar(require("./interval.helper.js"), exports);
26
- __exportStar(require("./nestjs/nest.decorator.js"), exports);
27
- __exportStar(require("./object.helper.js"), exports);
28
- __exportStar(require("./object-mapper.helper.js"), exports);
29
- __exportStar(require("./object-mapper.interceptor.js"), exports);
30
- __exportStar(require("./returnValue.js"), exports);
31
- __exportStar(require("./validator-helper.js"), exports);
32
- __exportStar(require("./zlib.helper.js"), exports);
33
- __exportStar(require("./command.helper.js"), exports);
34
- __exportStar(require("./files.helper.js"), exports);
35
- __exportStar(require("./rxjs.helper.js"), exports);
36
- __exportStar(require("./math.helper.js"), exports);
37
- __exportStar(require("./config-manager.helper.js"), exports);
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("@node-yalc/utils/class.helper"), exports);
5
+ tslib_1.__exportStar(require("@node-yalc/utils/custom-validator"), exports);
6
+ tslib_1.__exportStar(require("@node-yalc/utils/data-structure.helper"), exports);
7
+ tslib_1.__exportStar(require("@node-yalc/utils/date.helper"), exports);
8
+ tslib_1.__exportStar(require("@node-yalc/utils/encryption.helper"), exports);
9
+ tslib_1.__exportStar(require("@node-yalc/utils/enum.helper"), exports);
10
+ tslib_1.__exportStar(require("@node-yalc/utils/env.helper"), exports);
11
+ tslib_1.__exportStar(require("@node-yalc/utils/error.helper"), exports);
12
+ tslib_1.__exportStar(require("@node-yalc/utils/interval.helper"), exports);
13
+ tslib_1.__exportStar(require("./nestjs/nest.decorator.js"), exports);
14
+ tslib_1.__exportStar(require("@node-yalc/utils/object.helper"), exports);
15
+ tslib_1.__exportStar(require("@node-yalc/utils/object-mapper.helper"), exports);
16
+ tslib_1.__exportStar(require("./object-mapper.interceptor.js"), exports);
17
+ tslib_1.__exportStar(require("@node-yalc/utils/returnValue"), exports);
18
+ tslib_1.__exportStar(require("@node-yalc/utils/validator-helper"), exports);
19
+ tslib_1.__exportStar(require("@node-yalc/utils/zlib.helper"), exports);
20
+ tslib_1.__exportStar(require("@node-yalc/utils/command.helper"), exports);
21
+ tslib_1.__exportStar(require("@node-yalc/utils/files.helper"), exports);
22
+ tslib_1.__exportStar(require("@node-yalc/utils/rxjs.helper"), exports);
23
+ tslib_1.__exportStar(require("@node-yalc/utils/math.helper"), exports);
24
+ tslib_1.__exportStar(require("@node-yalc/utils/config-manager.helper"), exports);
38
25
  //# sourceMappingURL=index.js.map
package/src/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAkC;AAClC,wDAAsC;AACtC,6DAA2C;AAC3C,mDAAiC;AACjC,yDAAuC;AACvC,mDAAiC;AACjC,kDAAgC;AAChC,oDAAkC;AAElC,uDAAqC;AACrC,6DAA2C;AAC3C,qDAAmC;AACnC,4DAA0C;AAC1C,iEAA+C;AAE/C,mDAAiC;AACjC,wDAAsC;AACtC,mDAAiC;AACjC,sDAAoC;AACpC,oDAAkC;AAClC,mDAAiC;AACjC,mDAAiC;AACjC,6DAA2C"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;AAAA,wEAA8C;AAC9C,4EAAkD;AAClD,iFAAuD;AACvD,uEAA6C;AAC7C,6EAAmD;AACnD,uEAA6C;AAC7C,sEAA4C;AAC5C,wEAA8C;AAE9C,2EAAiD;AACjD,qEAA2C;AAC3C,yEAA+C;AAC/C,gFAAsD;AACtD,yEAA+C;AAE/C,uEAA6C;AAC7C,4EAAkD;AAClD,uEAA6C;AAC7C,0EAAgD;AAChD,wEAA8C;AAC9C,uEAA6C;AAC7C,uEAA6C;AAC7C,iFAAuD"}
package/src/index.ts CHANGED
@@ -1,23 +1,23 @@
1
- export * from './class.helper.js';
2
- export * from './custom-validator.js';
3
- export * from './data-structure.helper.js';
4
- export * from './date.helper.js';
5
- export * from './encryption.helper.js';
6
- export * from './enum.helper.js';
7
- export * from './env.helper.js';
8
- export * from './error.helper.js';
9
- // export * from './faker-helper.js';
10
- export * from './interval.helper.js';
1
+ export * from '@node-yalc/utils/class.helper';
2
+ export * from '@node-yalc/utils/custom-validator';
3
+ export * from '@node-yalc/utils/data-structure.helper';
4
+ export * from '@node-yalc/utils/date.helper';
5
+ export * from '@node-yalc/utils/encryption.helper';
6
+ export * from '@node-yalc/utils/enum.helper';
7
+ export * from '@node-yalc/utils/env.helper';
8
+ export * from '@node-yalc/utils/error.helper';
9
+ // export * from '@node-yalc/utils/faker-helper';
10
+ export * from '@node-yalc/utils/interval.helper';
11
11
  export * from './nestjs/nest.decorator.js';
12
- export * from './object.helper.js';
13
- export * from './object-mapper.helper.js';
12
+ export * from '@node-yalc/utils/object.helper';
13
+ export * from '@node-yalc/utils/object-mapper.helper';
14
14
  export * from './object-mapper.interceptor.js';
15
- // export * from './promise.helper.js';
16
- export * from './returnValue.js';
17
- export * from './validator-helper.js';
18
- export * from './zlib.helper.js';
19
- export * from './command.helper.js';
20
- export * from './files.helper.js';
21
- export * from './rxjs.helper.js';
22
- export * from './math.helper.js';
23
- export * from './config-manager.helper.js';
15
+ // export * from '@node-yalc/utils/promise.helper';
16
+ export * from '@node-yalc/utils/returnValue';
17
+ export * from '@node-yalc/utils/validator-helper';
18
+ export * from '@node-yalc/utils/zlib.helper';
19
+ export * from '@node-yalc/utils/command.helper';
20
+ export * from '@node-yalc/utils/files.helper';
21
+ export * from '@node-yalc/utils/rxjs.helper';
22
+ export * from '@node-yalc/utils/math.helper';
23
+ export * from '@node-yalc/utils/config-manager.helper';
@@ -1,6 +1,6 @@
1
1
  import { CallHandler, ExecutionContext } from '@nestjs/common';
2
2
  import { Observable } from 'rxjs';
3
- import { ObjectMapperType } from './object-mapper.helper.js';
3
+ import { ObjectMapperType } from '@node-yalc/utils/object-mapper.helper';
4
4
  export declare function objectMapperInterceptor<TInputObject extends Record<string, any>, TOutputObject extends Record<string, any>>(mapper: ObjectMapperType<TInputObject, TOutputObject>, options?: {
5
5
  copyNonMappedProperties?: boolean;
6
6
  transformData?: {
@@ -1,15 +1,10 @@
1
1
  "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
2
  Object.defineProperty(exports, "__esModule", { value: true });
9
3
  exports.objectMapperInterceptor = objectMapperInterceptor;
4
+ const tslib_1 = require("tslib");
10
5
  const common_1 = require("@nestjs/common");
11
6
  const rxjs_1 = require("rxjs");
12
- const object_mapper_helper_js_1 = require("./object-mapper.helper.js");
7
+ const object_mapper_helper_1 = require("@node-yalc/utils/object-mapper.helper");
13
8
  function objectMapperInterceptor(mapper, options = {}) {
14
9
  let ObjectMapperInterceptor = class ObjectMapperInterceptor {
15
10
  intercept(_context, next) {
@@ -18,17 +13,17 @@ function objectMapperInterceptor(mapper, options = {}) {
18
13
  ? options.transformData(data)
19
14
  : data;
20
15
  if (Array.isArray(_data)) {
21
- const result = _data.map((item) => (0, object_mapper_helper_js_1.objectMapper)(item, mapper));
16
+ const result = _data.map((item) => (0, object_mapper_helper_1.objectMapper)(item, mapper));
22
17
  return options.callback?.(data, result) ?? result;
23
18
  }
24
- const result = (0, object_mapper_helper_js_1.objectMapper)(_data, mapper, {
19
+ const result = (0, object_mapper_helper_1.objectMapper)(_data, mapper, {
25
20
  copyNonMappedProperties: options.copyNonMappedProperties,
26
21
  });
27
22
  return options.callback?.(data, result) ?? result;
28
23
  }));
29
24
  }
30
25
  };
31
- ObjectMapperInterceptor = __decorate([
26
+ ObjectMapperInterceptor = tslib_1.__decorate([
32
27
  (0, common_1.Injectable)()
33
28
  ], ObjectMapperInterceptor);
34
29
  return ObjectMapperInterceptor;
@@ -1 +1 @@
1
- {"version":3,"file":"object-mapper.interceptor.js","sourceRoot":"","sources":["object-mapper.interceptor.ts"],"names":[],"mappings":";;;;;;;;AASA,0DAyCC;AAlDD,2CAKwB;AACxB,+BAAuC;AACvC,uEAA2E;AAE3E,SAAgB,uBAAuB,CAIrC,MAAqD,EACrD,UASI,EAAE;IAGN,IAAM,uBAAuB,GAA7B,MAAM,uBAAuB;QAC3B,SAAS,CAAC,QAA0B,EAAE,IAAiB;YACrD,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,CACvB,IAAA,UAAG,EAAC,CAAC,IAAI,EAAE,EAAE;gBACX,MAAM,KAAK,GAAG,OAAO,CAAC,aAAa;oBACjC,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC;oBAC7B,CAAC,CAAC,IAAI,CAAC;gBAET,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;oBACzB,MAAM,MAAM,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAA,sCAAY,EAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;oBAC/D,OAAO,OAAO,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,MAAM,CAAC;gBACpD,CAAC;gBAED,MAAM,MAAM,GAAG,IAAA,sCAAY,EAAC,KAAK,EAAE,MAAM,EAAE;oBACzC,uBAAuB,EAAE,OAAO,CAAC,uBAAuB;iBACzD,CAAC,CAAC;gBAEH,OAAO,OAAO,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,MAAM,CAAC;YACpD,CAAC,CAAC,CACH,CAAC;QACJ,CAAC;KACF,CAAA;IArBK,uBAAuB;QAD5B,IAAA,mBAAU,GAAE;OACP,uBAAuB,CAqB5B;IAED,OAAO,uBAAuB,CAAC;AACjC,CAAC"}
1
+ {"version":3,"file":"object-mapper.interceptor.js","sourceRoot":"","sources":["object-mapper.interceptor.ts"],"names":[],"mappings":";;AASA,0DAyCC;;AAlDD,2CAKwB;AACxB,+BAAuC;AACvC,gFAAuF;AAEvF,SAAgB,uBAAuB,CAIrC,MAAqD,EACrD,UASI,EAAE;IAGN,IAAM,uBAAuB,GAA7B,MAAM,uBAAuB;QAC3B,SAAS,CAAC,QAA0B,EAAE,IAAiB;YACrD,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,CACvB,IAAA,UAAG,EAAC,CAAC,IAAI,EAAE,EAAE;gBACX,MAAM,KAAK,GAAG,OAAO,CAAC,aAAa;oBACjC,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC;oBAC7B,CAAC,CAAC,IAAI,CAAC;gBAET,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;oBACzB,MAAM,MAAM,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAA,mCAAY,EAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;oBAC/D,OAAO,OAAO,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,MAAM,CAAC;gBACpD,CAAC;gBAED,MAAM,MAAM,GAAG,IAAA,mCAAY,EAAC,KAAK,EAAE,MAAM,EAAE;oBACzC,uBAAuB,EAAE,OAAO,CAAC,uBAAuB;iBACzD,CAAC,CAAC;gBAEH,OAAO,OAAO,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,MAAM,CAAC;YACpD,CAAC,CAAC,CACH,CAAC;QACJ,CAAC;KACF,CAAA;IArBK,uBAAuB;QAD5B,IAAA,mBAAU,GAAE;OACP,uBAAuB,CAqB5B;IAED,OAAO,uBAAuB,CAAC;AACjC,CAAC"}
@@ -5,7 +5,7 @@ import {
5
5
  NestInterceptor,
6
6
  } from '@nestjs/common';
7
7
  import { Observable, map } from 'rxjs';
8
- import { objectMapper, ObjectMapperType } from './object-mapper.helper.js';
8
+ import { objectMapper, ObjectMapperType } from '@node-yalc/utils/object-mapper.helper';
9
9
 
10
10
  export function objectMapperInterceptor<
11
11
  TInputObject extends Record<string, any>,
@@ -1,12 +1,7 @@
1
1
  "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
2
  Object.defineProperty(exports, "__esModule", { value: true });
9
3
  exports.buildSimpleMapperInterceptor = buildSimpleMapperInterceptor;
4
+ const tslib_1 = require("tslib");
10
5
  const common_1 = require("@nestjs/common");
11
6
  const rxjs_1 = require("rxjs");
12
7
  function buildSimpleMapperInterceptor(Dto, options) {
@@ -21,7 +16,7 @@ function buildSimpleMapperInterceptor(Dto, options) {
21
16
  }));
22
17
  }
23
18
  };
24
- SimpleMapper = __decorate([
19
+ SimpleMapper = tslib_1.__decorate([
25
20
  (0, common_1.Injectable)()
26
21
  ], SimpleMapper);
27
22
  return SimpleMapper;
@@ -1 +1 @@
1
- {"version":3,"file":"simple-mapper.interceptor.js","sourceRoot":"","sources":["simple-mapper.interceptor.ts"],"names":[],"mappings":";;;;;;;;AAeA,oEA2BC;AA1CD,2CAKwB;AACxB,+BAAuC;AASvC,SAAgB,4BAA4B,CAC1C,GAAuB,EACvB,OAGC;IAGD,IAAM,YAAY,GAAlB,MAAM,YAAY;QAChB,SAAS,CACP,QAA0B,EAC1B,IAAoB;YAEpB,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,CACvB,IAAA,UAAG,EAAC,CAAC,IAAI,EAAE,EAAE;gBACX,MAAM,KAAK,GAAG,OAAO,EAAE,WAAW,EAAE,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC;gBACnD,MAAM,UAAU,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;oBACrC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC;oBAC9B,CAAC,CAAC,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC;gBAEnB,OAAO,OAAO,EAAE,QAAQ,EAAE,CAAC,IAAI,EAAE,UAAU,CAAC,IAAI,UAAU,CAAC;YAC7D,CAAC,CAAC,CACH,CAAC;QACJ,CAAC;KACF,CAAA;IAhBK,YAAY;QADjB,IAAA,mBAAU,GAAE;OACP,YAAY,CAgBjB;IAED,OAAO,YAAY,CAAC;AACtB,CAAC"}
1
+ {"version":3,"file":"simple-mapper.interceptor.js","sourceRoot":"","sources":["simple-mapper.interceptor.ts"],"names":[],"mappings":";;AAeA,oEA2BC;;AA1CD,2CAKwB;AACxB,+BAAuC;AASvC,SAAgB,4BAA4B,CAC1C,GAAuB,EACvB,OAGC;IAGD,IAAM,YAAY,GAAlB,MAAM,YAAY;QAChB,SAAS,CACP,QAA0B,EAC1B,IAAoB;YAEpB,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,CACvB,IAAA,UAAG,EAAC,CAAC,IAAI,EAAE,EAAE;gBACX,MAAM,KAAK,GAAG,OAAO,EAAE,WAAW,EAAE,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC;gBACnD,MAAM,UAAU,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;oBACrC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC;oBAC9B,CAAC,CAAC,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC;gBAEnB,OAAO,OAAO,EAAE,QAAQ,EAAE,CAAC,IAAI,EAAE,UAAU,CAAC,IAAI,UAAU,CAAC;YAC7D,CAAC,CAAC,CACH,CAAC;QACJ,CAAC;KACF,CAAA;IAhBK,YAAY;QADjB,IAAA,mBAAU,GAAE;OACP,YAAY,CAgBjB;IAED,OAAO,YAAY,CAAC;AACtB,CAAC"}
@@ -1,9 +0,0 @@
1
- export enum TestEnum1 {
2
- TEST1 = 'test1',
3
- TEST2 = 'test2',
4
- }
5
-
6
- export enum TestEnum2 {
7
- TEST2 = 'test2',
8
- TEST3 = 'test3',
9
- }
@@ -1,32 +0,0 @@
1
- import { isClass, isES6Class } from '../class.helper.js';
2
- import { describe, expect, it } from '@jest/globals';
3
- import { DefaultError } from '@nest-yalc-2/errors/default.error.js';
4
-
5
- describe('Test Class Helpers', () => {
6
- it('should test a class correctly', () => {
7
- expect(isClass(class {})).toBeTruthy();
8
- });
9
-
10
- it('should test a class correctly', () => {
11
- expect(
12
- isClass(function (nothing: any) {
13
- nothing;
14
- }),
15
- ).toBeTruthy();
16
- expect(isClass(Error)).toBeTruthy();
17
- expect(isES6Class(Error)).toBeFalsy();
18
- expect(isClass(() => {})).toBeFalsy();
19
- });
20
-
21
- it('expect an instance of a class to not be a class', () => {
22
- expect(isClass(new (class {})())).toBeFalsy();
23
- });
24
-
25
- it('should test a class against a name', () => {
26
- const defaultError = DefaultError;
27
- expect(isClass(class Test {}, 'Test')).toBeTruthy();
28
- expect(isClass(class Test {}, 'Test2')).toBeFalsy();
29
- expect(isES6Class(class Test {}, 'Test2')).toBeFalsy();
30
- expect(isClass(defaultError, DefaultError.name)).toBeTruthy();
31
- });
32
- });
@@ -1,35 +0,0 @@
1
- import {
2
- describe,
3
- expect,
4
- it,
5
- jest,
6
- beforeAll,
7
- beforeEach,
8
- test,
9
- } from '@jest/globals';
10
-
11
- import { commandWithErrors } from '../command.helper.js';
12
-
13
- describe('test shared functions', () => {
14
- it('should run cliWithErrors without errors', async () => {
15
- const fn = jest.fn();
16
- const cliWithErrorsResult = commandWithErrors(fn);
17
- await cliWithErrorsResult(1);
18
-
19
- expect(fn).toHaveBeenCalledTimes(1);
20
- expect(fn).toHaveBeenLastCalledWith(1);
21
- });
22
-
23
- it('should run cliWithErrors and call the process exit', async () => {
24
- const spiedProcessExit = jest.spyOn(process, 'exit');
25
-
26
- spiedProcessExit.mockImplementation((() => {}) as any);
27
-
28
- await commandWithErrors(async () => {
29
- throw new Error('Test');
30
- })('Test');
31
- expect(spiedProcessExit).toHaveBeenCalledWith(1);
32
-
33
- spiedProcessExit.mockRestore();
34
- });
35
- });
@@ -1,93 +0,0 @@
1
- import { describe, expect, it } from '@jest/globals';
2
- import { ConfigValueManager, checkForDuplicateKeys } from '../config-manager.helper.js'; // Adjust the import path accordingly
3
-
4
- describe('ConfigValueManager and Utilities', () => {
5
-
6
- describe('checkForDuplicateKeys', () => {
7
- it('should not throw an error for unique keys', () => {
8
- const execute = () => checkForDuplicateKeys(['key1', 'key2', 'key3']);
9
- expect(execute).not.toThrow();
10
- });
11
-
12
- it('should throw an error for duplicate keys', () => {
13
- const execute = () => checkForDuplicateKeys(['key1', 'key1']);
14
- expect(execute).toThrow(/Duplicate key found in configuration: key1/);
15
- });
16
- });
17
-
18
- describe('ConfigValueManager.value', () => {
19
- it('returns the correct value for a matching key', () => {
20
- const result = ConfigValueManager.value('myKey', {k: 'myKey', v: 'myValue'});
21
- expect(result).toBe('myValue');
22
- });
23
-
24
- it('returns the default value when key does not match', () => {
25
- const result = ConfigValueManager.value('otherKey', { k: 'myKey', v: 'myValue' }, 'default');
26
- expect(result).toBe('default');
27
- });
28
-
29
- it('returns the value from a function when key matches', () => {
30
- const result = ConfigValueManager.value('myKey', { k: 'myKey', v: () => 'dynamicValue' });
31
- expect(result).toBe('dynamicValue');
32
- });
33
-
34
- it('returns the default value from a function when key does not match', () => {
35
- const result = ConfigValueManager.value('otherKey', { k: 'myKey', v: 'myValue' }, () => 'dynamicDefault');
36
- expect(result).toBe('dynamicDefault');
37
- });
38
-
39
- it('handles multiple configurations and returns the first matching value', () => {
40
- const configs = [{ k: 'myKey1', v: 'value1' }, { k: 'myKey2', v: 'value2' }];
41
- const result = ConfigValueManager.value('myKey2', configs);
42
- expect(result).toBe('value2');
43
- });
44
-
45
- it('throws an error for duplicate keys in configurations', () => {
46
- const configs = [{ k: 'myKey', v:'value1'}, { k: 'myKey', v: 'value2'}];
47
- const execute = () => ConfigValueManager.value('myKey', configs);
48
- expect(execute).toThrow(/Duplicate key found in configuration: myKey/);
49
- });
50
- });
51
-
52
- describe('ConfigValueManager.is', () => {
53
- it('returns true when the key matches', () => {
54
- const result = ConfigValueManager.is('myKey', 'myKey');
55
- expect(result).toBe(true);
56
- });
57
-
58
- it('returns false when the key does not match', () => {
59
- const result = ConfigValueManager.is('otherKey', 'myKey');
60
- expect(result).toBe(false);
61
- });
62
-
63
- it('returns false when using negation and the key matches', () => {
64
- const result = ConfigValueManager.is('myKey', 'myKey', true);
65
- expect(result).toBe(false);
66
- });
67
- });
68
-
69
- describe('ConfigValueManager.only', () => {
70
- it('returns the value for a matching key', () => {
71
- const result = ConfigValueManager.only('myKey', 'myKey', 'returnValue');
72
- expect(result).toBe('returnValue');
73
- });
74
-
75
- it('returns undefined for a non-matching key', () => {
76
- const result = ConfigValueManager.only('otherKey', 'myKey', 'returnValue');
77
- expect(result).toBeUndefined();
78
- });
79
- });
80
-
81
- describe('ConfigValueManager.skip', () => {
82
- it('returns undefined for a matching key', () => {
83
- const result = ConfigValueManager.skip('myKey', 'myKey', 'returnValue');
84
- expect(result).toBeUndefined();
85
- });
86
-
87
- it('returns the value for a non-matching key', () => {
88
- const result = ConfigValueManager.skip('otherKey', 'myKey', 'returnValue');
89
- expect(result).toBe('returnValue');
90
- });
91
- });
92
-
93
- });
@@ -1,34 +0,0 @@
1
- import {
2
- describe,
3
- expect,
4
- it,
5
- jest,
6
- beforeAll,
7
- beforeEach,
8
- test,
9
- } from '@jest/globals';
10
- import { stringIsInEnumValidatorFactory } from '../custom-validator.js';
11
-
12
- describe('stringIsInEnumValidatorFactory', () => {
13
- enum TestEnum {
14
- Value1 = 'Value1',
15
- Value2 = 'Value2',
16
- }
17
-
18
- it('should validate if a string is in the enum', () => {
19
- const validator = stringIsInEnumValidatorFactory(TestEnum);
20
-
21
- const validString = 'Value1';
22
- const invalidString = 'Invalid';
23
-
24
- expect(validator.validate(validString)).toBe(true);
25
- expect(validator.validate(invalidString)).toBe(false);
26
- });
27
-
28
- it('should call stringIsInEnum with the right arguments', () => {
29
- const validator = stringIsInEnumValidatorFactory(TestEnum);
30
-
31
- const validString = 'Value1';
32
- expect(validator.validate(validString)).toBe(true);
33
- });
34
- });
@@ -1,30 +0,0 @@
1
- import {
2
- describe,
3
- expect,
4
- it,
5
- jest,
6
- beforeAll,
7
- beforeEach,
8
- test,
9
- } from '@jest/globals';
10
-
11
- import { arrayGroupByField } from '../data-structure.helper.js';
12
-
13
- const testArray = [
14
- {
15
- key: 'xx',
16
- data: 'firstData',
17
- },
18
- {
19
- key: 'xx',
20
- data: 'seconData',
21
- },
22
- ];
23
- describe('Test Data Structure Helpers', () => {
24
- it('should groupby an array with a field', () => {
25
- const groupedArray = arrayGroupByField(testArray, (item) => item.key);
26
- expect(groupedArray['xx']).toEqual(
27
- expect.arrayContaining([testArray[0], testArray[1]]),
28
- );
29
- });
30
- });
@@ -1,78 +0,0 @@
1
- import {
2
- describe,
3
- expect,
4
- it,
5
- jest,
6
- beforeAll,
7
- beforeEach,
8
- } from '@jest/globals';
9
-
10
- import { DateHelper } from '../date.helper.js';
11
-
12
- describe('Date helper test suite', () => {
13
- it('getDateQuery - returns proper query', () => {
14
- jest
15
- .spyOn(global.Date, 'now')
16
- .mockImplementation(() => Date.parse('01-30-2022'));
17
-
18
- const result = DateHelper.getWeekEdgeDates();
19
-
20
- expect(result).toEqual({ endDate: '2022-01-30', startDate: '2022-01-23' });
21
- });
22
-
23
- it('getDateQuery - gets months with single number code', () => {
24
- jest
25
- .spyOn(global.Date, 'now')
26
- .mockImplementation(() => Date.parse('09-09-2022'));
27
-
28
- const result = DateHelper.getWeekEdgeDates();
29
-
30
- expect(result).toEqual({ endDate: '2022-09-09', startDate: '2022-09-02' });
31
- });
32
-
33
- it('getDateQuery - gets month with double number code', () => {
34
- jest
35
- .spyOn(global.Date, 'now')
36
- .mockImplementation(() => Date.parse('12-09-2022'));
37
-
38
- const result = DateHelper.getWeekEdgeDates();
39
-
40
- expect(result).toEqual({ endDate: '2022-12-09', startDate: '2022-12-02' });
41
- });
42
-
43
- it('getDateQuery - returns query with week overlapping on two months', () => {
44
- jest
45
- .spyOn(global.Date, 'now')
46
- .mockImplementation(() => Date.parse('12-04-2022'));
47
-
48
- const result = DateHelper.getWeekEdgeDates();
49
-
50
- expect(result).toEqual({ endDate: '2022-12-04', startDate: '2022-11-27' });
51
- });
52
-
53
- it('should be able add minutes to a Date', () => {
54
- const date = new Date('2021-10-13T13:13:00.000Z');
55
- const result = DateHelper.addMinutes(date, 5);
56
- expect(result).toBeInstanceOf(Date);
57
- expect(result.toISOString()).toBe('2021-10-13T13:18:00.000Z');
58
- });
59
-
60
- it('should be able substract minutes from a Date', () => {
61
- const date = new Date('2003-01-05T20:00:00.000Z');
62
- const result = DateHelper.subsMinutes(date, 5);
63
- expect(result).toBeInstanceOf(Date);
64
- expect(result.toISOString()).toBe('2003-01-05T19:55:00.000Z');
65
- });
66
-
67
- it('should be able to convert to SQL format', () => {
68
- const date = new Date('2003-01-05T20:00:00.000Z');
69
- const result = DateHelper.dateToSQLDateTime(date);
70
- expect(result).toBe('2003-01-05 20:00:00');
71
- });
72
-
73
- it('dateToPlainISO - converts date to plain ISO format', () => {
74
- const date = new Date('2003-01-05T20:00:00.000Z');
75
- const result = DateHelper.dateToPlainISO(date);
76
- expect(result).toBe('20030105T200000000Z');
77
- });
78
- });
@@ -1,45 +0,0 @@
1
- import {
2
- describe,
3
- expect,
4
- it,
5
- jest,
6
- beforeAll,
7
- beforeEach,
8
- test,
9
- } from '@jest/globals';
10
-
11
- import { encryptAes, decryptAes } from '../encryption.helper.js';
12
- import crypto from 'crypto';
13
-
14
- // Please let me know if you know how to solve this as unknown as void.
15
- jest
16
- .spyOn(crypto, 'randomBytes')
17
- .mockReturnValue(
18
- Buffer.from('173606b5fe22770c890b48c41866abc3', 'hex') as unknown as void,
19
- );
20
-
21
- describe('Utils encryption helper test', () => {
22
- const key =
23
- '60f810732e3c8d1eb5ba227143d46aabce1bb1ae0aa7081ef0b0c3bbaaed76a6';
24
- const decrypted = 'should be able to encrypt a simple message with a key';
25
- it('should be defined', () => {
26
- expect(encryptAes).toBeDefined();
27
- });
28
-
29
- it('should be defined', () => {
30
- expect(decryptAes).toBeDefined();
31
- });
32
-
33
- it('should be able to encrypt a simple message with a key', () => {
34
- expect(encryptAes(decrypted, key)).toBeDefined();
35
- });
36
-
37
- it('should be able to decrypt a simple message with a key', () => {
38
- const encrypted = encryptAes(decrypted, key);
39
- expect(decryptAes(encrypted, key)).toEqual(decrypted);
40
- });
41
-
42
- it('should return an empty string if the input is empty as well', () => {
43
- expect(decryptAes('', key)).toEqual('');
44
- });
45
- });