nestjs-typeorm3-kit 0.1.8 → 0.2.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 (120) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +801 -148
  3. package/dist/common/decorator/index.d.ts.map +1 -1
  4. package/dist/common/decorator/index.js +1 -5
  5. package/dist/common/decorator/index.js.map +1 -1
  6. package/dist/controller/decorator/index.d.ts.map +1 -1
  7. package/dist/controller/decorator/index.js +66 -117
  8. package/dist/controller/decorator/index.js.map +1 -1
  9. package/dist/helpers/index.d.ts +2 -0
  10. package/dist/helpers/index.d.ts.map +1 -1
  11. package/dist/helpers/index.js +49 -10
  12. package/dist/helpers/index.js.map +1 -1
  13. package/dist/module/decorator/index.d.ts +1 -1
  14. package/dist/module/decorator/index.d.ts.map +1 -1
  15. package/dist/module/decorator/index.js +188 -19
  16. package/dist/module/decorator/index.js.map +1 -1
  17. package/dist/repository/config/constants.d.ts +1 -0
  18. package/dist/repository/config/constants.d.ts.map +1 -1
  19. package/dist/repository/config/constants.js +2 -1
  20. package/dist/repository/config/constants.js.map +1 -1
  21. package/dist/repository/config/types.d.ts +2 -2
  22. package/dist/repository/config/types.d.ts.map +1 -1
  23. package/dist/repository/config/types.js +34 -6
  24. package/dist/repository/config/types.js.map +1 -1
  25. package/dist/repository/config/utils.d.ts +1 -1
  26. package/dist/repository/config/utils.d.ts.map +1 -1
  27. package/dist/repository/config/utils.js +12 -13
  28. package/dist/repository/config/utils.js.map +1 -1
  29. package/dist/repository/decorator/index.d.ts +2 -2
  30. package/dist/repository/decorator/index.d.ts.map +1 -1
  31. package/dist/repository/decorator/index.js +1 -1
  32. package/dist/repository/decorator/index.js.map +1 -1
  33. package/dist/repository/module/index.d.ts +2 -5
  34. package/dist/repository/module/index.d.ts.map +1 -1
  35. package/dist/repository/module/index.js +23 -87
  36. package/dist/repository/module/index.js.map +1 -1
  37. package/dist/transaction/decorator/index.d.ts +5 -3
  38. package/dist/transaction/decorator/index.d.ts.map +1 -1
  39. package/dist/transaction/decorator/index.js +20 -19
  40. package/dist/transaction/decorator/index.js.map +1 -1
  41. package/dist/transaction/setup/index.d.ts +8 -3
  42. package/dist/transaction/setup/index.d.ts.map +1 -1
  43. package/dist/transaction/setup/index.js +19 -5
  44. package/dist/transaction/setup/index.js.map +1 -1
  45. package/dist/validate/decorator/index.d.ts.map +1 -1
  46. package/dist/validate/decorator/index.js +6 -4
  47. package/dist/validate/decorator/index.js.map +1 -1
  48. package/dist/vendor/transactional/common/constants.d.ts +6 -0
  49. package/dist/vendor/transactional/common/constants.d.ts.map +1 -0
  50. package/dist/vendor/transactional/common/constants.js +9 -0
  51. package/dist/vendor/transactional/common/constants.js.map +1 -0
  52. package/dist/vendor/transactional/common/index.d.ts +26 -0
  53. package/dist/vendor/transactional/common/index.d.ts.map +1 -0
  54. package/dist/vendor/transactional/common/index.js +136 -0
  55. package/dist/vendor/transactional/common/index.js.map +1 -0
  56. package/dist/vendor/transactional/decorators/transactional.d.ts +3 -0
  57. package/dist/vendor/transactional/decorators/transactional.d.ts.map +1 -0
  58. package/dist/vendor/transactional/decorators/transactional.js +20 -0
  59. package/dist/vendor/transactional/decorators/transactional.js.map +1 -0
  60. package/dist/vendor/transactional/enums/isolation-level.d.ts +7 -0
  61. package/dist/vendor/transactional/enums/isolation-level.d.ts.map +1 -0
  62. package/dist/vendor/transactional/enums/isolation-level.js +11 -0
  63. package/dist/vendor/transactional/enums/isolation-level.js.map +1 -0
  64. package/dist/vendor/transactional/enums/propagation.d.ts +10 -0
  65. package/dist/vendor/transactional/enums/propagation.d.ts.map +1 -0
  66. package/dist/vendor/transactional/enums/propagation.js +14 -0
  67. package/dist/vendor/transactional/enums/propagation.js.map +1 -0
  68. package/dist/vendor/transactional/enums/storage-driver.d.ts +5 -0
  69. package/dist/vendor/transactional/enums/storage-driver.d.ts.map +1 -0
  70. package/dist/vendor/transactional/enums/storage-driver.js +9 -0
  71. package/dist/vendor/transactional/enums/storage-driver.js.map +1 -0
  72. package/dist/vendor/transactional/errors/transactional.d.ts +4 -0
  73. package/dist/vendor/transactional/errors/transactional.d.ts.map +1 -0
  74. package/dist/vendor/transactional/errors/transactional.js +11 -0
  75. package/dist/vendor/transactional/errors/transactional.js.map +1 -0
  76. package/dist/vendor/transactional/errors/typeorm-updated-patch.d.ts +5 -0
  77. package/dist/vendor/transactional/errors/typeorm-updated-patch.d.ts.map +1 -0
  78. package/dist/vendor/transactional/errors/typeorm-updated-patch.js +11 -0
  79. package/dist/vendor/transactional/errors/typeorm-updated-patch.js.map +1 -0
  80. package/dist/vendor/transactional/hooks/index.d.ts +11 -0
  81. package/dist/vendor/transactional/hooks/index.d.ts.map +1 -0
  82. package/dist/vendor/transactional/hooks/index.js +79 -0
  83. package/dist/vendor/transactional/hooks/index.js.map +1 -0
  84. package/dist/vendor/transactional/index.d.ts +10 -0
  85. package/dist/vendor/transactional/index.d.ts.map +1 -0
  86. package/dist/vendor/transactional/index.js +27 -0
  87. package/dist/vendor/transactional/index.js.map +1 -0
  88. package/dist/vendor/transactional/storage/driver/async-local-storage/index.d.ts +9 -0
  89. package/dist/vendor/transactional/storage/driver/async-local-storage/index.d.ts.map +1 -0
  90. package/dist/vendor/transactional/storage/driver/async-local-storage/index.js +25 -0
  91. package/dist/vendor/transactional/storage/driver/async-local-storage/index.js.map +1 -0
  92. package/dist/vendor/transactional/storage/driver/interface.d.ts +10 -0
  93. package/dist/vendor/transactional/storage/driver/interface.d.ts.map +1 -0
  94. package/dist/vendor/transactional/storage/driver/interface.js +3 -0
  95. package/dist/vendor/transactional/storage/driver/interface.js.map +1 -0
  96. package/dist/vendor/transactional/storage/index.d.ts +3 -0
  97. package/dist/vendor/transactional/storage/index.d.ts.map +1 -0
  98. package/dist/vendor/transactional/storage/index.js +6 -0
  99. package/dist/vendor/transactional/storage/index.js.map +1 -0
  100. package/dist/vendor/transactional/storage/storage.d.ts +7 -0
  101. package/dist/vendor/transactional/storage/storage.d.ts.map +1 -0
  102. package/dist/vendor/transactional/storage/storage.js +21 -0
  103. package/dist/vendor/transactional/storage/storage.js.map +1 -0
  104. package/dist/vendor/transactional/transactions/nested-scope.d.ts +12 -0
  105. package/dist/vendor/transactional/transactions/nested-scope.d.ts.map +1 -0
  106. package/dist/vendor/transactional/transactions/nested-scope.js +42 -0
  107. package/dist/vendor/transactional/transactions/nested-scope.js.map +1 -0
  108. package/dist/vendor/transactional/transactions/run-in-transaction.d.ts +3 -0
  109. package/dist/vendor/transactional/transactions/run-in-transaction.d.ts.map +1 -0
  110. package/dist/vendor/transactional/transactions/run-in-transaction.js +9 -0
  111. package/dist/vendor/transactional/transactions/run-in-transaction.js.map +1 -0
  112. package/dist/vendor/transactional/transactions/wrap-in-transaction.d.ts +11 -0
  113. package/dist/vendor/transactional/transactions/wrap-in-transaction.d.ts.map +1 -0
  114. package/dist/vendor/transactional/transactions/wrap-in-transaction.js +109 -0
  115. package/dist/vendor/transactional/transactions/wrap-in-transaction.js.map +1 -0
  116. package/dist/vendor/transactional/utils/index.d.ts +3 -0
  117. package/dist/vendor/transactional/utils/index.d.ts.map +1 -0
  118. package/dist/vendor/transactional/utils/index.js +12 -0
  119. package/dist/vendor/transactional/utils/index.js.map +1 -0
  120. package/package.json +28 -25
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/common/decorator/index.ts"],"names":[],"mappings":"AAAA,wBAAgB,KAAK,KACF,QAAQ,MAAM,EAAE,KAAK,MAAM,GAAG,MAAM,UAkBtD;AAED,wBAAgB,QAAQ,IAAI,cAAc,CAwBzC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/common/decorator/index.ts"],"names":[],"mappings":"AAAA,wBAAgB,KAAK,KACF,QAAQ,MAAM,EAAE,KAAK,MAAM,GAAG,MAAM,UAkBtD;AAED,wBAAgB,QAAQ,IAAI,cAAc,CAqBzC"}
@@ -23,11 +23,7 @@ function NewClass() {
23
23
  return function (target) {
24
24
  const original = target;
25
25
  function construct(constructor, args) {
26
- const c = function () {
27
- return constructor.apply(this, args);
28
- };
29
- c.prototype = constructor.prototype;
30
- return new c();
26
+ return Reflect.construct(constructor, args);
31
27
  }
32
28
  const newConstructor = function (...args) {
33
29
  return construct(original, args);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/common/decorator/index.ts"],"names":[],"mappings":";;AAAA,sBAmBC;AAED,4BAwBC;AA7CD,SAAgB,KAAK;IACnB,OAAO,UAAU,MAAc,EAAE,GAAoB;QACnD,IAAI,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;QAEtB,MAAM,MAAM,GAAG,GAAG,EAAE;YAClB,OAAO,GAAG,CAAC;QACb,CAAC,CAAC;QACF,MAAM,MAAM,GAAG,CAAC,IAAI,EAAE,EAAE;YAEtB,GAAG,GAAG,MAAM,IAAI,KAAK,CAAC;QACxB,CAAC,CAAC;QAEF,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,GAAG,EAAE;YACjC,GAAG,EAAE,MAAM;YACX,GAAG,EAAE,MAAM;YACX,UAAU,EAAE,IAAI;YAChB,YAAY,EAAE,IAAI;SACnB,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC;AAED,SAAgB,QAAQ;IACtB,OAAO,UAAU,MAAgB;QAC/B,MAAM,QAAQ,GAAG,MAAM,CAAC;QAExB,SAAS,SAAS,CAAC,WAAqB,EAAE,IAAW;YACnD,MAAM,CAAC,GAAQ;gBACb,OAAO,WAAW,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;YACvC,CAAC,CAAC;YACF,CAAC,CAAC,SAAS,GAAG,WAAW,CAAC,SAAS,CAAC;YACpC,OAAO,IAAI,CAAC,EAAE,CAAC;QACjB,CAAC;QAGD,MAAM,cAAc,GAAQ,UAAU,GAAG,IAAW;YAElD,OAAO,SAAS,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;QACnC,CAAC,CAAC;QAGF,cAAc,CAAC,SAAS,GAAG,QAAQ,CAAC,SAAS,CAAC;QAG9C,OAAO,cAAc,CAAC;IACxB,CAAC,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/common/decorator/index.ts"],"names":[],"mappings":";;AAAA,sBAmBC;AAED,4BAqBC;AA1CD,SAAgB,KAAK;IACnB,OAAO,UAAU,MAAc,EAAE,GAAoB;QACnD,IAAI,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;QAEtB,MAAM,MAAM,GAAG,GAAG,EAAE;YAClB,OAAO,GAAG,CAAC;QACb,CAAC,CAAC;QACF,MAAM,MAAM,GAAG,CAAC,IAAI,EAAE,EAAE;YAEtB,GAAG,GAAG,MAAM,IAAI,KAAK,CAAC;QACxB,CAAC,CAAC;QAEF,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,GAAG,EAAE;YACjC,GAAG,EAAE,MAAM;YACX,GAAG,EAAE,MAAM;YACX,UAAU,EAAE,IAAI;YAChB,YAAY,EAAE,IAAI;SACnB,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC;AAED,SAAgB,QAAQ;IACtB,OAAO,UAAU,MAAgB;QAC/B,MAAM,QAAQ,GAAG,MAAM,CAAC;QAExB,SAAS,SAAS,CAAC,WAAqB,EAAE,IAAW;YAEnD,OAAO,OAAO,CAAC,SAAS,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;QAC9C,CAAC;QAGD,MAAM,cAAc,GAAQ,UAAU,GAAG,IAAW;YAElD,OAAO,SAAS,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;QACnC,CAAC,CAAC;QAGF,cAAc,CAAC,SAAS,GAAG,QAAQ,CAAC,SAAS,CAAC;QAG9C,OAAO,cAAc,CAAC;IACxB,CAAC,CAAC;AACJ,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/controller/decorator/index.ts"],"names":[],"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I,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,EACxB,OAAO,GAAE,gBAAyC,GACjD,eAAe,CAYjB;AAED,wBAAgB,OAAO,CACrB,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,EACxB,OAAO,GAAE,aAAmC,GAC3C,eAAe,CAmBjB;AAED,wBAAgB,MAAM,CACpB,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,EACxB,OAAO,GAAE,aAAmC,GAC3C,eAAe,CAmBjB;AAED,wBAAgB,QAAQ,CACtB,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,EACxB,OAAO,GAAE,aAAmC,GAC3C,eAAe,CAmBjB;AAED,wBAAgB,SAAS,CACvB,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,EACxB,OAAO,GAAE,aAAmC,GAC3C,eAAe,CAmBjB"}
@@ -7,135 +7,84 @@ exports.DefPut = DefPut;
7
7
  exports.DefPatch = DefPatch;
8
8
  exports.DefDelete = DefDelete;
9
9
  const common_1 = require("@nestjs/common");
10
- const constants_1 = require("@nestjs/common/constants");
11
10
  const swagger_1 = require("@nestjs/swagger");
12
11
  const _types_1 = require("../../@types");
13
12
  function DefController(options) {
14
- return (target) => {
15
- const modulePath = Reflect.getMetadata(constants_1.MODULE_PATH, target);
16
- const pathMetadata = Reflect.getMetadata(constants_1.PATH_METADATA, target);
17
- console.log('-------------------');
18
- console.log(JSON.stringify({ modulePath, pathMetadata }));
19
- console.log('-------------------');
20
- (0, swagger_1.ApiBearerAuth)()(target);
21
- (0, common_1.Controller)(options)(target);
22
- };
13
+ const nestController = options && !Array.isArray(options) && typeof options === 'object'
14
+ ? (0, common_1.Controller)(options)
15
+ : (0, common_1.Controller)(options);
16
+ return (0, common_1.applyDecorators)((0, swagger_1.ApiBearerAuth)(), nestController);
23
17
  }
24
18
  function DefGet(path, options = new _types_1.MethodGetOptions()) {
25
- return function (target, propertyKey, descriptor) {
26
- const { statusCode = common_1.HttpStatus.OK, summary, responseType = undefined } = options;
27
- const output = {
28
- ...(0, common_1.HttpCode)(statusCode)(target, propertyKey, descriptor),
29
- ...(0, swagger_1.ApiOperation)({ summary })(target, propertyKey, descriptor),
30
- ...(0, common_1.Get)(path)(target, propertyKey, descriptor),
31
- };
32
- if (responseType) {
33
- Object.assign(output, {
34
- ...(0, swagger_1.ApiResponse)({ status: statusCode, type: responseType })(target, propertyKey, descriptor),
35
- });
36
- }
37
- else {
38
- Object.assign(output, {
39
- ...(0, swagger_1.ApiResponse)({ status: statusCode })(target, propertyKey, descriptor),
40
- });
41
- }
42
- return output;
43
- };
19
+ const { statusCode = common_1.HttpStatus.OK, summary, responseType = undefined } = options || new _types_1.MethodGetOptions();
20
+ const decorators = [
21
+ (0, common_1.HttpCode)(statusCode),
22
+ (0, swagger_1.ApiOperation)({ summary }),
23
+ (0, common_1.Get)(path),
24
+ responseType
25
+ ? (0, swagger_1.ApiResponse)({ status: statusCode, type: responseType })
26
+ : (0, swagger_1.ApiResponse)({ status: statusCode }),
27
+ ];
28
+ return (0, common_1.applyDecorators)(...decorators);
44
29
  }
45
30
  function DefPost(path, options = new _types_1.MethodOptions()) {
46
- return function (target, propertyKey, descriptor) {
47
- const { statusCode = common_1.HttpStatus.OK, summary, responseType = undefined, bodyType = undefined, } = options;
48
- const output = {
49
- ...(0, common_1.HttpCode)(statusCode)(target, propertyKey, descriptor),
50
- ...(0, swagger_1.ApiOperation)({ summary })(target, propertyKey, descriptor),
51
- ...(0, common_1.Post)(path)(target, propertyKey, descriptor),
52
- };
53
- if (responseType) {
54
- Object.assign(output, {
55
- ...(0, swagger_1.ApiResponse)({ status: statusCode, type: responseType })(target, propertyKey, descriptor),
56
- });
57
- }
58
- else {
59
- Object.assign(output, {
60
- ...(0, swagger_1.ApiResponse)({ status: statusCode })(target, propertyKey, descriptor),
61
- });
62
- }
63
- if (bodyType) {
64
- Object.assign(output, { ...(0, swagger_1.ApiBody)({ type: bodyType })(target, propertyKey, descriptor) });
65
- }
66
- return output;
67
- };
31
+ const { statusCode = common_1.HttpStatus.OK, summary, responseType = undefined, bodyType = undefined, } = options || new _types_1.MethodOptions();
32
+ const decorators = [
33
+ (0, common_1.HttpCode)(statusCode),
34
+ (0, swagger_1.ApiOperation)({ summary }),
35
+ (0, common_1.Post)(path),
36
+ responseType
37
+ ? (0, swagger_1.ApiResponse)({ status: statusCode, type: responseType })
38
+ : (0, swagger_1.ApiResponse)({ status: statusCode }),
39
+ ];
40
+ if (bodyType) {
41
+ decorators.push((0, swagger_1.ApiBody)({ type: bodyType }));
42
+ }
43
+ return (0, common_1.applyDecorators)(...decorators);
68
44
  }
69
45
  function DefPut(path, options = new _types_1.MethodOptions()) {
70
- return function (target, propertyKey, descriptor) {
71
- const { statusCode = common_1.HttpStatus.OK, summary, responseType = undefined, bodyType = undefined, } = options;
72
- const output = {
73
- ...(0, common_1.HttpCode)(statusCode)(target, propertyKey, descriptor),
74
- ...(0, swagger_1.ApiOperation)({ summary })(target, propertyKey, descriptor),
75
- ...(0, common_1.Put)(path)(target, propertyKey, descriptor),
76
- };
77
- if (responseType) {
78
- Object.assign(output, {
79
- ...(0, swagger_1.ApiResponse)({ status: statusCode, type: responseType })(target, propertyKey, descriptor),
80
- });
81
- }
82
- else {
83
- Object.assign(output, {
84
- ...(0, swagger_1.ApiResponse)({ status: statusCode })(target, propertyKey, descriptor),
85
- });
86
- }
87
- if (bodyType) {
88
- Object.assign(output, { ...(0, swagger_1.ApiBody)({ type: bodyType })(target, propertyKey, descriptor) });
89
- }
90
- return output;
91
- };
46
+ const { statusCode = common_1.HttpStatus.OK, summary, responseType = undefined, bodyType = undefined, } = options || new _types_1.MethodOptions();
47
+ const decorators = [
48
+ (0, common_1.HttpCode)(statusCode),
49
+ (0, swagger_1.ApiOperation)({ summary }),
50
+ (0, common_1.Put)(path),
51
+ responseType
52
+ ? (0, swagger_1.ApiResponse)({ status: statusCode, type: responseType })
53
+ : (0, swagger_1.ApiResponse)({ status: statusCode }),
54
+ ];
55
+ if (bodyType) {
56
+ decorators.push((0, swagger_1.ApiBody)({ type: bodyType }));
57
+ }
58
+ return (0, common_1.applyDecorators)(...decorators);
92
59
  }
93
60
  function DefPatch(path, options = new _types_1.MethodOptions()) {
94
- return function (target, propertyKey, descriptor) {
95
- const { statusCode = common_1.HttpStatus.OK, summary, responseType = undefined, bodyType = undefined, } = options;
96
- const output = {
97
- ...(0, common_1.HttpCode)(statusCode)(target, propertyKey, descriptor),
98
- ...(0, swagger_1.ApiOperation)({ summary })(target, propertyKey, descriptor),
99
- ...(0, common_1.Patch)(path)(target, propertyKey, descriptor),
100
- };
101
- if (responseType) {
102
- Object.assign(output, {
103
- ...(0, swagger_1.ApiResponse)({ status: statusCode, type: responseType })(target, propertyKey, descriptor),
104
- });
105
- }
106
- else {
107
- Object.assign(output, {
108
- ...(0, swagger_1.ApiResponse)({ status: statusCode })(target, propertyKey, descriptor),
109
- });
110
- }
111
- if (bodyType) {
112
- Object.assign(output, { ...(0, swagger_1.ApiBody)({ type: bodyType })(target, propertyKey, descriptor) });
113
- }
114
- return output;
115
- };
61
+ const { statusCode = common_1.HttpStatus.OK, summary, responseType = undefined, bodyType = undefined, } = options || new _types_1.MethodOptions();
62
+ const decorators = [
63
+ (0, common_1.HttpCode)(statusCode),
64
+ (0, swagger_1.ApiOperation)({ summary }),
65
+ (0, common_1.Patch)(path),
66
+ responseType
67
+ ? (0, swagger_1.ApiResponse)({ status: statusCode, type: responseType })
68
+ : (0, swagger_1.ApiResponse)({ status: statusCode }),
69
+ ];
70
+ if (bodyType) {
71
+ decorators.push((0, swagger_1.ApiBody)({ type: bodyType }));
72
+ }
73
+ return (0, common_1.applyDecorators)(...decorators);
116
74
  }
117
75
  function DefDelete(path, options = new _types_1.MethodOptions()) {
118
- return function (target, propertyKey, descriptor) {
119
- const { statusCode = common_1.HttpStatus.OK, summary, responseType = undefined, bodyType = undefined, } = options;
120
- const output = {
121
- ...(0, common_1.HttpCode)(statusCode)(target, propertyKey, descriptor),
122
- ...(0, swagger_1.ApiOperation)({ summary })(target, propertyKey, descriptor),
123
- ...(0, common_1.Delete)(path)(target, propertyKey, descriptor),
124
- };
125
- if (responseType) {
126
- Object.assign(output, {
127
- ...(0, swagger_1.ApiResponse)({ status: statusCode, type: responseType })(target, propertyKey, descriptor),
128
- });
129
- }
130
- else {
131
- Object.assign(output, {
132
- ...(0, swagger_1.ApiResponse)({ status: statusCode })(target, propertyKey, descriptor),
133
- });
134
- }
135
- if (bodyType) {
136
- Object.assign(output, { ...(0, swagger_1.ApiBody)({ type: bodyType })(target, propertyKey, descriptor) });
137
- }
138
- return output;
139
- };
76
+ const { statusCode = common_1.HttpStatus.OK, summary, responseType = undefined, bodyType = undefined, } = options || new _types_1.MethodOptions();
77
+ const decorators = [
78
+ (0, common_1.HttpCode)(statusCode),
79
+ (0, swagger_1.ApiOperation)({ summary }),
80
+ (0, common_1.Delete)(path),
81
+ responseType
82
+ ? (0, swagger_1.ApiResponse)({ status: statusCode, type: responseType })
83
+ : (0, swagger_1.ApiResponse)({ status: statusCode }),
84
+ ];
85
+ if (bodyType) {
86
+ decorators.push((0, swagger_1.ApiBody)({ type: bodyType }));
87
+ }
88
+ return (0, common_1.applyDecorators)(...decorators);
140
89
  }
141
90
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/controller/decorator/index.ts"],"names":[],"mappings":";;AAiBA,sCAWC;AAED,wBA2BC;AAED,0BAmCC;AAED,wBAmCC;AAED,4BAmCC;AAED,8BAmCC;AA7MD,2CAUwB;AACxB,wDAAsE;AACtE,6CAAoF;AACpF,yCAA+D;AAI/D,SAAgB,aAAa,CAAC,OAAY;IACxC,OAAO,CAAC,MAAgB,EAAE,EAAE;QAC1B,MAAM,UAAU,GAAG,OAAO,CAAC,WAAW,CAAC,uBAAW,EAAE,MAAM,CAAC,CAAC;QAC5D,MAAM,YAAY,GAAG,OAAO,CAAC,WAAW,CAAC,yBAAa,EA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;AAED,SAAgB,SAAS,CACvB,IAAwB,EACxB,UAAyB,IAAI,sBAAa,EAAE;IAE5C,MAAM,EACJ,UAAU,GAAG,mBAAU,CAAC,EAAE,EAC1B,OAAO,EACP,YAAY,GAAG,SAAS,EACxB,QAAQ,GAAG,SAAS,GACrB,GAAG,OAAO,IAAI,IAAI,sBAAa,EAAE,CAAC;IACnC,MAAM,UAAU,GAAgE;QAC9E,IAAA,iBAAQ,EAAC,UAAU,CAAC;QACpB,IAAA,sBAAY,EAAC,EAAE,OAAO,EAAE,CAAC;QACzB,IAAA,eAAM,EAAC,IAAI,CAAC;QACZ,YAAY;YACV,CAAC,CAAC,IAAA,qBAAW,EAAC,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC;YACzD,CAAC,CAAC,IAAA,qBAAW,EAAC,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC;KACxC,CAAC;IACF,IAAI,QAAQ,EAAE,CAAC;QACb,UAAU,CAAC,IAAI,CAAC,IAAA,iBAAO,EAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC;IAC/C,CAAC;IACD,OAAO,IAAA,wBAAe,EAAC,GAAG,UAAU,CAAC,CAAC;AACxC,CAAC"}
@@ -1,6 +1,8 @@
1
1
  import { INestApplication } from "@nestjs/common";
2
+ import type { SwaggerDocumentOptions } from "@nestjs/swagger";
2
3
  import { OpenAPIObject } from "@nestjs/swagger/dist/interfaces/open-api-spec.interface";
3
4
  export declare const configSwaggerDocument: (app: INestApplication, document: OpenAPIObject, swaggerPath?: string) => void;
5
+ export declare function createScopedSwaggerDocument(app: INestApplication, config: Omit<OpenAPIObject, "paths">, options?: SwaggerDocumentOptions): OpenAPIObject;
4
6
  import { Type } from "@nestjs/common";
5
7
  export declare const lazyLoadClasses: (baseDir: string, suffixes: string[], additionalClasses?: Type<any>[]) => Type<any>[];
6
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAGlD,OAAO,EACL,aAAa,EAEd,MAAM,yDAAyD,CAAC;AAGjE,eAAO,MAAM,qBAAqB,GAChC,KAAK,gBAAgB,EACrB,UAAU,aAAa,EACvB,cAAa,MAAkB,SAsBhC,CAAC;AAIF,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAatC,eAAO,MAAM,eAAe,GAC1B,SAAS,MAAM,EACf,UAAU,MAAM,EAAE,EAClB,oBAAmB,IAAI,CAAC,GAAG,CAAC,EAAO,KAClC,IAAI,CAAC,GAAG,CAAC,EAoCX,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAGlD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAE9D,OAAO,EACL,aAAa,EAEd,MAAM,yDAAyD,CAAC;AAGjE,eAAO,MAAM,qBAAqB,GAChC,KAAK,gBAAgB,EACrB,UAAU,aAAa,EACvB,cAAa,MAAkB,SAqChC,CAAC;AAOF,wBAAgB,2BAA2B,CACzC,GAAG,EAAE,gBAAgB,EACrB,MAAM,EAAE,IAAI,CAAC,aAAa,EAAE,OAAO,CAAC,EACpC,OAAO,CAAC,EAAE,sBAAsB,GAC/B,aAAa,CAwBf;AAID,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAatC,eAAO,MAAM,eAAe,GAC1B,SAAS,MAAM,EACf,UAAU,MAAM,EAAE,EAClB,oBAAmB,IAAI,CAAC,GAAG,CAAC,EAAO,KAClC,IAAI,CAAC,GAAG,CAAC,EAoCX,CAAC"}
@@ -1,30 +1,69 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.lazyLoadClasses = exports.configSwaggerDocument = void 0;
4
+ exports.createScopedSwaggerDocument = createScopedSwaggerDocument;
5
+ const core_1 = require("@nestjs/core");
4
6
  const swagger_1 = require("@nestjs/swagger");
5
7
  const class_validator_1 = require("class-validator");
6
8
  const class_validator_jsonschema_1 = require("class-validator-jsonschema");
7
9
  const configSwaggerDocument = (app, document, swaggerPath = "swagger") => {
8
- const metadatas = (0, class_validator_1.getFromContainer)(class_validator_1.MetadataStorage)
9
- .validationMetadatas;
10
+ document.components = document.components || {};
10
11
  const targetSchemas = document.components.schemas || {};
11
- const schemasBinding = (0, class_validator_jsonschema_1.validationMetadatasToSchemas)(metadatas) || {};
12
+ const schemasBinding = (0, class_validator_jsonschema_1.validationMetadatasToSchemas)({
13
+ classValidatorMetadataStorage: (0, class_validator_1.getMetadataStorage)(),
14
+ refPointerPrefix: "#/components/schemas/",
15
+ }) || {};
12
16
  Object.keys(schemasBinding).forEach((key) => {
13
17
  const value = schemasBinding[key];
14
- if (!targetSchemas[key]) {
15
- Object.assign(targetSchemas, { key: value });
18
+ const targetValue = targetSchemas[key];
19
+ if (!targetValue) {
20
+ targetSchemas[key] = value;
21
+ return;
16
22
  }
17
- else {
18
- const targetValue = targetSchemas[key];
19
- Object.assign(targetValue.properties, value.properties);
20
- targetValue.required = value.required;
21
- Object.assign(targetSchemas, { key: targetValue });
23
+ if ("$ref" in targetValue) {
24
+ return;
22
25
  }
26
+ const properties = (targetValue.properties = targetValue.properties || {});
27
+ Object.keys(value.properties || {}).forEach((prop) => {
28
+ if (!(prop in properties))
29
+ properties[prop] = value.properties[prop];
30
+ });
31
+ const required = new Set([
32
+ ...(targetValue.required || []),
33
+ ...(value.required || []),
34
+ ]);
35
+ if (required.size)
36
+ targetValue.required = [...required];
23
37
  });
24
38
  document.components.schemas = Object.assign({}, targetSchemas);
25
39
  swagger_1.SwaggerModule.setup(swaggerPath, app, document);
26
40
  };
27
41
  exports.configSwaggerDocument = configSwaggerDocument;
42
+ function createScopedSwaggerDocument(app, config, options) {
43
+ var _a;
44
+ if (!((_a = options === null || options === void 0 ? void 0 : options.include) === null || _a === void 0 ? void 0 : _a.length)) {
45
+ return swagger_1.SwaggerModule.createDocument(app, config, options);
46
+ }
47
+ const included = new Set(options.include);
48
+ for (const module of app.get(core_1.ModulesContainer).values()) {
49
+ const moduleType = module.metatype;
50
+ if (typeof moduleType !== "function" || included.has(moduleType)) {
51
+ continue;
52
+ }
53
+ let prototype = Object.getPrototypeOf(moduleType.prototype);
54
+ while (prototype) {
55
+ if (included.has(prototype.constructor)) {
56
+ included.add(moduleType);
57
+ break;
58
+ }
59
+ prototype = Object.getPrototypeOf(prototype);
60
+ }
61
+ }
62
+ return swagger_1.SwaggerModule.createDocument(app, config, {
63
+ ...options,
64
+ include: [...included],
65
+ });
66
+ }
28
67
  const path_1 = require("path");
29
68
  const fs_1 = require("fs");
30
69
  const lazyLoadClasses = (baseDir, suffixes, additionalClasses = []) => {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":";;;AACA,6CAAgD;AAChD,qDAAoE;AAKpE,2EAA0E;AAEnE,MAAM,qBAAqB,GAAG,CACnC,GAAqB,EACrB,QAAuB,EACvB,cAAsB,SAAS,EAC/B,EAAE;IAEF,MAAM,SAAS,GAAI,IAAA,kCAAgB,EAAC,iCAAe,CAAS;SACzD,mBAAmB,CAAC;IACvB,MAAM,aAAa,GAAG,QAAQ,CAAC,UAAU,CAAC,OAAO,IAAI,EAAE,CAAC;IACxD,MAAM,cAAc,GAAG,IAAA,yDAA4B,EAAC,SAAS,CAAC,IAAI,EAAE,CAAC;IAErE,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;QAC1C,MAAM,KAAK,GAAG,cAAc,CAAC,GAAG,CAAkB,CAAC;QACnD,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,EAAE,CAAC;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IAAI,CAAC,iCAAiC,QAAQ,EAAE,EAAE,KAAK,CAAC,CAAC;YACnE,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAxCW,QAAA,eAAe,mBAwC1B"}
@@ -1,4 +1,4 @@
1
- import { ModuleMetadata } from '@nestjs/common/interfaces';
1
+ import { ModuleMetadata } from '@nestjs/common';
2
2
  export interface IChildModuleMetadata extends ModuleMetadata {
3
3
  prefix?: string;
4
4
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/module/decorator/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAG3D,MAAM,WAAW,oBAAqB,SAAQ,cAAc;IAC1D,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAyBD,wBAAgB,WAAW,CAAC,aAAa,CAAC,EAAE,oBAAoB,GAAG,cAAc,CA2BhF"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/module/decorator/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmC,cAAc,EAAQ,MAAM,gBAAgB,CAAC;AAKvF,MAAM,WAAW,oBAAqB,SAAQ,cAAc;IAC1D,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAyND,wBAAgB,WAAW,CAAC,aAAa,CAAC,EAAE,oBAAoB,GAAG,cAAc,CA+BhF"}
@@ -1,10 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ChildModule = ChildModule;
4
- const validate_module_keys_util_1 = require("@nestjs/common/utils/validate-module-keys.util");
5
4
  const constants_1 = require("@nestjs/common/constants");
5
+ const validate_module_keys_util_1 = require("@nestjs/common/utils/validate-module-keys.util");
6
6
  const swagger_1 = require("@nestjs/swagger");
7
- const PREFIX_METADATA = '__prefix___';
8
7
  function fixPath(strInput) {
9
8
  let path = strInput;
10
9
  const regex = new RegExp('//', 'g');
@@ -22,30 +21,200 @@ const toPascalCase = (str) => {
22
21
  .replace(new RegExp(/\s/, 'g'), '')
23
22
  .replace(new RegExp(/\w/), s => s.toUpperCase());
24
23
  };
24
+ const SCOPED_IMPORTS = Symbol('child-module:scoped-imports');
25
+ const scopedModuleCache = new WeakMap();
26
+ const scopedDynamicCache = new WeakMap();
27
+ function pathOf(moduleType) {
28
+ const path = Reflect.getMetadata(constants_1.MODULE_PATH, moduleType);
29
+ return typeof path === 'string' ? fixPath(path) : '';
30
+ }
31
+ function isDynamicModule(item) {
32
+ return !!item && typeof item === 'object' && 'module' in item;
33
+ }
34
+ function isForwardReference(item) {
35
+ return !!item && typeof item === 'object' && 'forwardRef' in item;
36
+ }
37
+ function scopeModule(moduleType, parentPath) {
38
+ if (!parentPath) {
39
+ return moduleType;
40
+ }
41
+ let byPath = scopedModuleCache.get(moduleType);
42
+ const existing = byPath === null || byPath === void 0 ? void 0 : byPath.get(parentPath);
43
+ if (existing) {
44
+ return existing;
45
+ }
46
+ if (!byPath) {
47
+ byPath = new Map();
48
+ scopedModuleCache.set(moduleType, byPath);
49
+ }
50
+ class ScopedModule {
51
+ constructor(...args) {
52
+ return Reflect.construct(moduleType, args, new.target);
53
+ }
54
+ }
55
+ Object.setPrototypeOf(ScopedModule.prototype, moduleType.prototype);
56
+ byPath.set(parentPath, ScopedModule);
57
+ Object.defineProperty(ScopedModule, 'name', { value: moduleType.name });
58
+ for (const key of Reflect.getMetadataKeys(moduleType)) {
59
+ Reflect.defineMetadata(key, Reflect.getMetadata(key, moduleType), ScopedModule);
60
+ }
61
+ const path = fixPath(`${parentPath}/${pathOf(moduleType)}`);
62
+ Reflect.defineMetadata(constants_1.MODULE_PATH, path ? `/${path}` : '', ScopedModule);
63
+ const imports = Reflect.getMetadata('imports', moduleType);
64
+ if (imports) {
65
+ const importParentPath = Reflect.getMetadata(SCOPED_IMPORTS, moduleType) ? parentPath : path;
66
+ const scoped = scopeLists(imports, Reflect.getMetadata('exports', moduleType), importParentPath);
67
+ Reflect.defineMetadata('imports', scoped.imports, ScopedModule);
68
+ Reflect.defineMetadata(SCOPED_IMPORTS, true, ScopedModule);
69
+ if (scoped.exports) {
70
+ Reflect.defineMetadata('exports', scoped.exports, ScopedModule);
71
+ }
72
+ }
73
+ return ScopedModule;
74
+ }
75
+ function scopeDynamicModule(item, parentPath) {
76
+ if (!parentPath) {
77
+ return item;
78
+ }
79
+ let byPath = scopedDynamicCache.get(item);
80
+ const existing = byPath === null || byPath === void 0 ? void 0 : byPath.get(parentPath);
81
+ if (existing) {
82
+ return existing;
83
+ }
84
+ if (!byPath) {
85
+ byPath = new Map();
86
+ scopedDynamicCache.set(item, byPath);
87
+ }
88
+ const scoped = Object.fromEntries(Object.entries(item));
89
+ byPath.set(parentPath, scoped);
90
+ scoped.module = scopeModule(item.module, parentPath);
91
+ if (item.imports) {
92
+ const importParentPath = item[SCOPED_IMPORTS]
93
+ ? parentPath
94
+ : fixPath(pathOf(scoped.module));
95
+ const lists = scopeLists(item.imports, item.exports, importParentPath);
96
+ scoped.imports = lists.imports;
97
+ if (lists.exports) {
98
+ scoped.exports = lists.exports;
99
+ }
100
+ scoped[SCOPED_IMPORTS] = true;
101
+ }
102
+ return scoped;
103
+ }
104
+ function scopeImport(item, parentPath) {
105
+ if (!parentPath) {
106
+ return item;
107
+ }
108
+ if (typeof item === 'function') {
109
+ return scopeModule(item, parentPath);
110
+ }
111
+ if (item instanceof Promise) {
112
+ return item.then(resolved => scopeImport(resolved, parentPath));
113
+ }
114
+ if (isDynamicModule(item)) {
115
+ return scopeDynamicModule(item, parentPath);
116
+ }
117
+ if (isForwardReference(item)) {
118
+ return {
119
+ forwardRef: () => scopeImport(item.forwardRef(), parentPath),
120
+ };
121
+ }
122
+ return item;
123
+ }
124
+ function scopeLists(imports, exports, parentPath) {
125
+ if (!parentPath) {
126
+ return { imports, exports };
127
+ }
128
+ const scopedByOriginal = new Map();
129
+ const remember = (item, scoped) => {
130
+ if (typeof item === 'function' && typeof scoped === 'function') {
131
+ scopedByOriginal.set(item, scoped);
132
+ }
133
+ else if (isDynamicModule(item) && isDynamicModule(scoped)) {
134
+ scopedByOriginal.set(item.module, scoped.module);
135
+ }
136
+ };
137
+ const scopedImports = imports.map(item => {
138
+ if (item instanceof Promise) {
139
+ return item.then(resolved => {
140
+ const scoped = scopeImport(resolved, parentPath);
141
+ remember(resolved, scoped);
142
+ return scoped;
143
+ });
144
+ }
145
+ const scoped = scopeImport(item, parentPath);
146
+ remember(item, scoped);
147
+ return scoped;
148
+ });
149
+ if (!exports) {
150
+ return { imports: scopedImports };
151
+ }
152
+ const hasForwardImports = imports.some(isForwardReference);
153
+ const hasPromiseImports = imports.some(item => item instanceof Promise);
154
+ const scopedExports = exports.map(item => {
155
+ var _a;
156
+ if (isForwardReference(item)) {
157
+ return { forwardRef: () => scopeImport(item.forwardRef(), parentPath) };
158
+ }
159
+ if (typeof item === 'function') {
160
+ const direct = scopedByOriginal.get(item);
161
+ if (direct)
162
+ return direct;
163
+ if (hasForwardImports || hasPromiseImports) {
164
+ return {
165
+ forwardRef: () => {
166
+ const resolved = scopedByOriginal.get(item);
167
+ if (resolved)
168
+ return resolved;
169
+ const matches = imports.some(ref => {
170
+ if (!isForwardReference(ref))
171
+ return false;
172
+ const resolved = ref.forwardRef();
173
+ return resolved === item || (isDynamicModule(resolved) && resolved.module === item);
174
+ });
175
+ return matches ? scopeModule(item, parentPath) : item;
176
+ },
177
+ };
178
+ }
179
+ return item;
180
+ }
181
+ if (isDynamicModule(item)) {
182
+ return (_a = scopedByOriginal.get(item.module)) !== null && _a !== void 0 ? _a : item;
183
+ }
184
+ return item;
185
+ });
186
+ return { imports: scopedImports, exports: scopedExports };
187
+ }
25
188
  function ChildModule(childMetadata) {
26
- let { prefix = '', ...metadata } = childMetadata;
189
+ const { prefix = '', ...metadata } = childMetadata || {};
27
190
  const propsKeys = Object.keys(metadata);
28
191
  (0, validate_module_keys_util_1.validateModuleKeys)(propsKeys);
29
192
  return target => {
30
- console.log('=====ChildModule=====');
31
- for (const property in metadata) {
32
- if (metadata.hasOwnProperty(property)) {
33
- Reflect.defineMetadata(property, metadata[property], target);
34
- }
35
- }
193
+ var _a;
36
194
  const defPrefix = fixPath(prefix);
37
- Reflect.defineMetadata(constants_1.MODULE_PATH, defPrefix ? '/' + defPrefix : defPrefix, target);
38
- const data = metadata['imports'] || [];
39
- data.forEach(item => {
40
- const childPath = Reflect.getMetadata(constants_1.MODULE_PATH, item) || '';
41
- const mixPath = fixPath(defPrefix + childPath);
42
- Reflect.defineMetadata(constants_1.MODULE_PATH, mixPath ? '/' + mixPath : mixPath, item);
43
- });
44
- const controllers = metadata['controllers'] || [];
45
- controllers.forEach(ctr => {
195
+ const scoped = metadata.imports
196
+ ? scopeLists(metadata.imports, metadata.exports, defPrefix)
197
+ : undefined;
198
+ for (const property of Object.keys(metadata)) {
199
+ const value = property === 'imports'
200
+ ? scoped === null || scoped === void 0 ? void 0 : scoped.imports
201
+ : property === 'exports'
202
+ ? ((_a = scoped === null || scoped === void 0 ? void 0 : scoped.exports) !== null && _a !== void 0 ? _a : metadata.exports)
203
+ : metadata[property];
204
+ Reflect.defineMetadata(property, value, target);
205
+ }
206
+ if (metadata.imports) {
207
+ Reflect.defineMetadata(SCOPED_IMPORTS, true, target);
208
+ }
209
+ Reflect.defineMetadata(constants_1.MODULE_PATH, defPrefix ? `/${defPrefix}` : defPrefix, target);
210
+ const controllers = metadata.controllers || [];
211
+ for (const ctr of controllers) {
212
+ if (!ctr) {
213
+ continue;
214
+ }
46
215
  const groupName = prefix ? `[${toPascalCase(prefix)}] ${ctr.name}` : `[API]${ctr.name}`;
47
216
  (0, swagger_1.ApiTags)(groupName)(ctr);
48
- });
217
+ }
49
218
  };
50
219
  }
51
220
  //# sourceMappingURL=index.js.map