@my-devkit/core 1.0.26 → 1.0.30

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 (182) hide show
  1. package/.eslintrc.js +15 -0
  2. package/.vscode/settings.json +7 -0
  3. package/{command.d.ts → dist/command.d.ts} +0 -0
  4. package/{command.js → dist/command.js} +1 -1
  5. package/{command.js.map → dist/command.js.map} +1 -1
  6. package/{date-helper.d.ts → dist/date-helper.d.ts} +0 -0
  7. package/{date-helper.js → dist/date-helper.js} +3 -3
  8. package/{date-helper.js.map → dist/date-helper.js.map} +1 -1
  9. package/{decorators → dist/decorators}/cacheable.decorator.d.ts +0 -0
  10. package/{decorators → dist/decorators}/cacheable.decorator.js +2 -2
  11. package/dist/decorators/cacheable.decorator.js.map +1 -0
  12. package/{decorators → dist/decorators}/index.d.ts +0 -0
  13. package/{decorators → dist/decorators}/index.js +0 -0
  14. package/{decorators → dist/decorators}/index.js.map +0 -0
  15. package/{decorators → dist/decorators}/retryable.decorator.d.ts +0 -0
  16. package/{decorators → dist/decorators}/retryable.decorator.js +1 -1
  17. package/{decorators → dist/decorators}/retryable.decorator.js.map +1 -1
  18. package/{document.d.ts → dist/document.d.ts} +0 -0
  19. package/{document.js → dist/document.js} +0 -0
  20. package/{document.js.map → dist/document.js.map} +0 -0
  21. package/{enum-helper.d.ts → dist/enum-helper.d.ts} +1 -0
  22. package/{enum-helper.js → dist/enum-helper.js} +13 -5
  23. package/dist/enum-helper.js.map +1 -0
  24. package/{errors → dist/errors}/bad-request-error.d.ts +0 -0
  25. package/{errors → dist/errors}/bad-request-error.js +0 -0
  26. package/{errors → dist/errors}/bad-request-error.js.map +0 -0
  27. package/{errors → dist/errors}/domain-error.d.ts +0 -0
  28. package/{errors → dist/errors}/domain-error.js +0 -0
  29. package/{errors → dist/errors}/domain-error.js.map +0 -0
  30. package/{errors → dist/errors}/error-base.d.ts +0 -0
  31. package/{errors → dist/errors}/error-base.js +0 -0
  32. package/{errors → dist/errors}/error-base.js.map +0 -0
  33. package/{errors → dist/errors}/forbidden-error.d.ts +0 -0
  34. package/{errors → dist/errors}/forbidden-error.js +0 -0
  35. package/{errors → dist/errors}/forbidden-error.js.map +0 -0
  36. package/{errors → dist/errors}/index.d.ts +0 -0
  37. package/{errors → dist/errors}/index.js +0 -0
  38. package/{errors → dist/errors}/index.js.map +0 -0
  39. package/{errors → dist/errors}/not-found-error.d.ts +0 -0
  40. package/{errors → dist/errors}/not-found-error.js +0 -0
  41. package/{errors → dist/errors}/not-found-error.js.map +0 -0
  42. package/{errors → dist/errors}/not-implemented-error.d.ts +0 -0
  43. package/{errors → dist/errors}/not-implemented-error.js +0 -0
  44. package/{errors → dist/errors}/not-implemented-error.js.map +0 -0
  45. package/{errors → dist/errors}/unauthorized-error.d.ts +0 -0
  46. package/{errors → dist/errors}/unauthorized-error.js +0 -0
  47. package/{errors → dist/errors}/unauthorized-error.js.map +0 -0
  48. package/{guid → dist/guid}/index.d.ts +0 -0
  49. package/{guid → dist/guid}/index.js +0 -0
  50. package/{guid → dist/guid}/index.js.map +0 -0
  51. package/{index.d.ts → dist/index.d.ts} +0 -0
  52. package/{index.js → dist/index.js} +0 -0
  53. package/{index.js.map → dist/index.js.map} +0 -0
  54. package/{logger.d.ts → dist/logger.d.ts} +0 -0
  55. package/{logger.js → dist/logger.js} +4 -4
  56. package/{logger.js.map → dist/logger.js.map} +1 -1
  57. package/{maintenance-model.d.ts → dist/maintenance-model.d.ts} +0 -0
  58. package/{maintenance-model.js → dist/maintenance-model.js} +2 -2
  59. package/{maintenance-model.js.map → dist/maintenance-model.js.map} +1 -1
  60. package/{model.d.ts → dist/model.d.ts} +0 -0
  61. package/{model.js → dist/model.js} +1 -1
  62. package/{model.js.map → dist/model.js.map} +1 -1
  63. package/dist/package.json +39 -0
  64. package/{release-model.d.ts → dist/release-model.d.ts} +0 -0
  65. package/{release-model.js → dist/release-model.js} +2 -2
  66. package/{release-model.js.map → dist/release-model.js.map} +1 -1
  67. package/{retry.d.ts → dist/retry.d.ts} +0 -0
  68. package/{retry.js → dist/retry.js} +2 -2
  69. package/{retry.js.map → dist/retry.js.map} +1 -1
  70. package/{serialize → dist/serialize}/deserialize.d.ts +0 -0
  71. package/{serialize → dist/serialize}/deserialize.js +2 -2
  72. package/{serialize → dist/serialize}/deserialize.js.map +1 -1
  73. package/{serialize → dist/serialize}/index.d.ts +0 -0
  74. package/{serialize → dist/serialize}/index.js +0 -0
  75. package/{serialize → dist/serialize}/index.js.map +0 -0
  76. package/{serialize → dist/serialize}/serializable.d.ts +0 -0
  77. package/{serialize → dist/serialize}/serializable.js +2 -2
  78. package/{serialize → dist/serialize}/serializable.js.map +1 -1
  79. package/{serialize → dist/serialize}/serialize.d.ts +0 -0
  80. package/{serialize → dist/serialize}/serialize.js +1 -1
  81. package/{serialize → dist/serialize}/serialize.js.map +1 -1
  82. package/{serialize → dist/serialize}/type-helper.d.ts +0 -0
  83. package/{serialize → dist/serialize}/type-helper.js +4 -4
  84. package/dist/serialize/type-helper.js.map +1 -0
  85. package/{sleep.d.ts → dist/sleep.d.ts} +0 -0
  86. package/{sleep.js → dist/sleep.js} +1 -1
  87. package/dist/sleep.js.map +1 -0
  88. package/{validators → dist/validators}/custom-validators/camel-case.d.ts +0 -0
  89. package/{validators → dist/validators}/custom-validators/camel-case.js +1 -1
  90. package/dist/validators/custom-validators/camel-case.js.map +1 -0
  91. package/{validators → dist/validators}/custom-validators/equals-to.d.ts +0 -0
  92. package/{validators → dist/validators}/custom-validators/equals-to.js +1 -1
  93. package/dist/validators/custom-validators/equals-to.js.map +1 -0
  94. package/{validators → dist/validators}/custom-validators/greater-or-equal-than.d.ts +0 -0
  95. package/{validators → dist/validators}/custom-validators/greater-or-equal-than.js +1 -1
  96. package/dist/validators/custom-validators/greater-or-equal-than.js.map +1 -0
  97. package/{validators → dist/validators}/custom-validators/greater-than-date.d.ts +0 -0
  98. package/{validators → dist/validators}/custom-validators/greater-than-date.js +1 -1
  99. package/dist/validators/custom-validators/greater-than-date.js.map +1 -0
  100. package/{validators → dist/validators}/custom-validators/index.d.ts +0 -0
  101. package/{validators → dist/validators}/custom-validators/index.js +0 -0
  102. package/{validators → dist/validators}/custom-validators/index.js.map +0 -0
  103. package/{validators → dist/validators}/custom-validators/is-not-in-relative-to.d.ts +0 -0
  104. package/{validators → dist/validators}/custom-validators/is-not-in-relative-to.js +1 -1
  105. package/dist/validators/custom-validators/is-not-in-relative-to.js.map +1 -0
  106. package/{validators → dist/validators}/custom-validators/is-optional-if.d.ts +0 -0
  107. package/{validators → dist/validators}/custom-validators/is-optional-if.js +1 -1
  108. package/{validators → dist/validators}/custom-validators/is-optional-if.js.map +1 -1
  109. package/{validators → dist/validators}/custom-validators/pascal-case.d.ts +0 -0
  110. package/{validators → dist/validators}/custom-validators/pascal-case.js +1 -1
  111. package/dist/validators/custom-validators/pascal-case.js.map +1 -0
  112. package/{validators → dist/validators}/index.d.ts +0 -0
  113. package/{validators → dist/validators}/index.js +0 -0
  114. package/{validators → dist/validators}/index.js.map +0 -0
  115. package/{validators → dist/validators}/validate.d.ts +0 -0
  116. package/{validators → dist/validators}/validate.js +6 -6
  117. package/dist/validators/validate.js.map +1 -0
  118. package/{validators → dist/validators}/validation-error.d.ts +0 -0
  119. package/{validators → dist/validators}/validation-error.js +0 -0
  120. package/{validators → dist/validators}/validation-error.js.map +0 -0
  121. package/{vendors → dist/vendors}/index.d.ts +0 -0
  122. package/{vendors → dist/vendors}/index.js +0 -0
  123. package/{vendors → dist/vendors}/index.js.map +0 -0
  124. package/{vendors → dist/vendors}/lodash.d.ts +0 -0
  125. package/{vendors → dist/vendors}/lodash.js +0 -0
  126. package/{vendors → dist/vendors}/lodash.js.map +0 -0
  127. package/my-devkit-core-1.0.30.tgz +0 -0
  128. package/package.json +9 -17
  129. package/src/command.ts +9 -0
  130. package/src/date-helper.ts +26 -0
  131. package/src/decorators/cacheable.decorator.ts +20 -0
  132. package/src/decorators/index.ts +2 -0
  133. package/src/decorators/retryable.decorator.ts +11 -0
  134. package/src/document.ts +5 -0
  135. package/src/enum-helper.ts +17 -0
  136. package/src/errors/bad-request-error.ts +8 -0
  137. package/src/errors/domain-error.ts +8 -0
  138. package/src/errors/error-base.ts +3 -0
  139. package/src/errors/forbidden-error.ts +8 -0
  140. package/src/errors/index.ts +8 -0
  141. package/src/errors/not-found-error.ts +8 -0
  142. package/src/errors/not-implemented-error.ts +8 -0
  143. package/src/errors/unauthorized-error.ts +8 -0
  144. package/src/guid/index.ts +3 -0
  145. package/src/index.ts +19 -0
  146. package/src/logger.ts +71 -0
  147. package/src/maintenance-model.ts +12 -0
  148. package/src/model.ts +15 -0
  149. package/src/release-model.ts +12 -0
  150. package/src/retry.ts +41 -0
  151. package/src/serialize/deserialize.ts +11 -0
  152. package/src/serialize/index.ts +6 -0
  153. package/src/serialize/serializable.ts +30 -0
  154. package/src/serialize/serialize.ts +7 -0
  155. package/src/serialize/type-helper.ts +167 -0
  156. package/src/sleep.ts +10 -0
  157. package/src/validators/custom-validators/camel-case.ts +18 -0
  158. package/src/validators/custom-validators/equals-to.ts +20 -0
  159. package/src/validators/custom-validators/greater-or-equal-than.ts +23 -0
  160. package/src/validators/custom-validators/greater-than-date.ts +28 -0
  161. package/src/validators/custom-validators/index.ts +7 -0
  162. package/src/validators/custom-validators/is-not-in-relative-to.ts +25 -0
  163. package/src/validators/custom-validators/is-optional-if.ts +21 -0
  164. package/src/validators/custom-validators/pascal-case.ts +18 -0
  165. package/src/validators/index.ts +24 -0
  166. package/src/validators/validate.ts +134 -0
  167. package/src/validators/validation-error.ts +27 -0
  168. package/src/vendors/index.ts +1 -0
  169. package/src/vendors/lodash.ts +62 -0
  170. package/tsconfig.json +20 -0
  171. package/decorators/cacheable.decorator.js.map +0 -1
  172. package/enum-helper.js.map +0 -1
  173. package/my-devkit-core-1.0.26.tgz +0 -0
  174. package/serialize/type-helper.js.map +0 -1
  175. package/sleep.js.map +0 -1
  176. package/validators/custom-validators/camel-case.js.map +0 -1
  177. package/validators/custom-validators/equals-to.js.map +0 -1
  178. package/validators/custom-validators/greater-or-equal-than.js.map +0 -1
  179. package/validators/custom-validators/greater-than-date.js.map +0 -1
  180. package/validators/custom-validators/is-not-in-relative-to.js.map +0 -1
  181. package/validators/custom-validators/pascal-case.js.map +0 -1
  182. package/validators/validate.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"equals-to.js","sourceRoot":"","sources":["../../../src/validators/custom-validators/equals-to.ts"],"names":[],"mappings":";;;AAAA,mDAA4F;AAE5F,SAAgB,QAAQ,CAAC,QAAgB,EAAE,iBAAqC;IAC5E,OAAO,UAAU,MAA2B,EAAE,YAAoB;QAC9D,IAAA,mCAAiB,EAAC;YACd,IAAI,EAAE,UAAU;YAChB,MAAM,EAAE,MAAM,CAAC,WAAW;YAC1B,YAAY,EAAE,YAAY;YAC1B,WAAW,EAAE,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,UAAA,EAAE,CAAC;YAC7C,OAAO,EAAE,iBAAiB;YAC1B,SAAS,EAAE;gBACP,QAAQ,EAAR,UAAS,KAAU,EAAE,IAAyB;oBAC1C,IAAM,mBAAmB,GAAG,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;oBACzD,IAAM,YAAY,GAAI,IAAI,CAAC,MAAc,CAAC,mBAAmB,CAAC,CAAC;oBAC/D,OAAO,KAAK,KAAK,YAAY,CAAC;gBAClC,CAAC;aACJ;SACJ,CAAC,CAAC;IACP,CAAC,CAAC;AACN,CAAC;AAjBD,4BAiBC"}
@@ -4,7 +4,7 @@ exports.GreaterOrEqualThan = void 0;
4
4
  var class_validator_1 = require("class-validator");
5
5
  function GreaterOrEqualThan(property, validationOptions) {
6
6
  return function (object, propertyName) {
7
- class_validator_1.registerDecorator({
7
+ (0, class_validator_1.registerDecorator)({
8
8
  name: 'greaterOrEqualThan',
9
9
  target: object.constructor,
10
10
  propertyName: propertyName,
@@ -0,0 +1 @@
1
+ {"version":3,"file":"greater-or-equal-than.js","sourceRoot":"","sources":["../../../src/validators/custom-validators/greater-or-equal-than.ts"],"names":[],"mappings":";;;AAAA,mDAA4F;AAE5F,SAAgB,kBAAkB,CAAC,QAAgB,EAAE,iBAAqC;IACtF,OAAO,UAAU,MAA2B,EAAE,YAAoB;QAC9D,IAAA,mCAAiB,EAAC;YACd,IAAI,EAAE,oBAAoB;YAC1B,MAAM,EAAE,MAAM,CAAC,WAAW;YAC1B,YAAY,EAAE,YAAY;YAC1B,WAAW,EAAE,CAAC,EAAE,IAAI,EAAE,oBAAoB,EAAE,QAAQ,UAAA,EAAE,CAAC;YACvD,OAAO,EAAE,iBAAiB;YAC1B,SAAS,EAAE;gBACP,QAAQ,EAAR,UAAS,KAAU,EAAE,IAAyB;oBAC1C,IAAM,mBAAmB,GAAG,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;oBACzD,IAAM,YAAY,GAAI,IAAI,CAAC,MAAc,CAAC,mBAAmB,CAAC,CAAC;oBAC/D,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,YAAY,KAAK,QAAQ,EAAE;wBAC/D,OAAO,KAAK,IAAI,YAAY,CAAC;qBAChC;oBACD,OAAO,KAAK,CAAC;gBACjB,CAAC;aACJ;SACJ,CAAC,CAAC;IACP,CAAC,CAAC;AACN,CAAC;AApBD,gDAoBC"}
@@ -4,7 +4,7 @@ exports.GreaterThanDate = void 0;
4
4
  var class_validator_1 = require("class-validator");
5
5
  function GreaterThanDate(property, milliSecondsOffset, validationOptions) {
6
6
  return function (object, propertyName) {
7
- class_validator_1.registerDecorator({
7
+ (0, class_validator_1.registerDecorator)({
8
8
  name: 'greaterThanDate',
9
9
  target: object.constructor,
10
10
  propertyName: propertyName,
@@ -0,0 +1 @@
1
+ {"version":3,"file":"greater-than-date.js","sourceRoot":"","sources":["../../../src/validators/custom-validators/greater-than-date.ts"],"names":[],"mappings":";;;AAAA,mDAA4F;AAE5F,SAAgB,eAAe,CAAC,QAAgB,EAAE,kBAA2B,EAAE,iBAAqC;IAChH,OAAO,UAAU,MAA2B,EAAE,YAAoB;QAC9D,IAAA,mCAAiB,EAAC;YACd,IAAI,EAAE,iBAAiB;YACvB,MAAM,EAAE,MAAM,CAAC,WAAW;YAC1B,YAAY,EAAE,YAAY;YAC1B,WAAW,EAAE,CAAC,EAAE,IAAI,EAAE,iBAAiB,EAAE,QAAQ,UAAA,EAAE,CAAC;YACpD,OAAO,EAAE,iBAAiB;YAC1B,SAAS,EAAE;gBACP,QAAQ,EAAR,UAAS,KAAU,EAAE,IAAyB;oBAC1C,IAAM,mBAAmB,GAAG,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;oBACzD,IAAI,YAAY,GAAI,IAAI,CAAC,MAAc,CAAC,mBAAmB,CAAC,CAAC;oBAC7D,IAAI,KAAK,YAAY,IAAI,IAAI,YAAY,YAAY,IAAI,EAAE;wBACvD,IAAI,kBAAkB,EAAE;4BACpB,IAAM,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;4BACxB,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,OAAO,EAAE,GAAG,kBAAkB,CAAC,CAAC;4BAC1D,YAAY,GAAG,IAAI,CAAC;yBACvB;wBACD,OAAO,KAAK,GAAG,YAAY,CAAC;qBAC/B;oBACD,OAAO,KAAK,CAAC;gBACjB,CAAC;aACJ;SACJ,CAAC,CAAC;IACP,CAAC,CAAC;AACN,CAAC;AAzBD,0CAyBC"}
@@ -5,7 +5,7 @@ var class_validator_1 = require("class-validator");
5
5
  var globalValidator = new class_validator_1.Validator();
6
6
  function IsNotInRelativeTo(excludedValuesCallback, validationOptions) {
7
7
  return function (object, propertyName) {
8
- class_validator_1.registerDecorator({
8
+ (0, class_validator_1.registerDecorator)({
9
9
  name: 'isNotInRelativeTo',
10
10
  target: object.constructor,
11
11
  propertyName: propertyName,
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-not-in-relative-to.js","sourceRoot":"","sources":["../../../src/validators/custom-validators/is-not-in-relative-to.ts"],"names":[],"mappings":";;;AAAA,mDAAuG;AAEvG,IAAM,eAAe,GAAG,IAAI,2BAAS,EAAE,CAAC;AAExC,SAAgB,iBAAiB,CAAO,sBAA0C,EAAE,iBAAqC;IACrH,OAAO,UAAU,MAA2B,EAAE,YAAoB;QAC9D,IAAA,mCAAiB,EAAC;YACd,IAAI,EAAE,mBAAmB;YACzB,MAAM,EAAE,MAAM,CAAC,WAAW;YAC1B,YAAY,EAAE,YAAY;YAC1B,WAAW,EAAE,CAAC,EAAE,IAAI,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,CAAC;YAC3F,OAAO,EAAE,iBAAiB;YAC1B,SAAS,EAAE;gBACP,QAAQ,EAAR,UAAS,KAAU,EAAE,IAAyB;oBAC1C,IAAM,cAAc,GAAG,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,qBAAqB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;oBAC9E,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,iBAAiB,IAAI,iBAAiB,CAAC,IAAI,EAAE;wBACrE,OAAO,KAAK,CAAC,KAAK,CAAC,UAAA,CAAC,IAAI,OAAA,eAAe,CAAC,OAAO,CAAC,CAAC,EAAE,cAAc,CAAC,EAA1C,CAA0C,CAAC,CAAC;qBACvE;yBAAM;wBACH,OAAO,eAAe,CAAC,OAAO,CAAC,KAAK,EAAE,cAAc,CAAC,CAAC;qBACzD;gBACL,CAAC;aACJ;SACJ,CAAC,CAAC;IACP,CAAC,CAAC;AACN,CAAC;AApBD,8CAoBC"}
@@ -17,7 +17,7 @@ function IsOptionalIf(condition, validationOptions) {
17
17
  }],
18
18
  validationOptions: validationOptions
19
19
  };
20
- class_validator_1.getFromContainer(class_validator_1.MetadataStorage).addValidationMetadata(new ValidationMetadata_1.ValidationMetadata(args));
20
+ (0, class_validator_1.getFromContainer)(class_validator_1.MetadataStorage).addValidationMetadata(new ValidationMetadata_1.ValidationMetadata(args));
21
21
  };
22
22
  }
23
23
  exports.IsOptionalIf = IsOptionalIf;
@@ -1 +1 @@
1
- {"version":3,"file":"is-optional-if.js","sourceRoot":"","sources":["../../../src/validators/custom-validators/is-optional-if.ts"],"names":[],"mappings":";;;AAAA,mDAAwG;AACxG,kFAAiF;AAGjF,SAAgB,YAAY,CAAC,SAA+C,EAAE,iBAAqC;IAC/G,OAAO,UAAU,MAA2B,EAAE,YAAoB;QAC9D,IAAM,IAAI,GAA2B;YACjC,IAAI,EAAE,iCAAe,CAAC,sBAAsB;YAC5C,MAAM,EAAE,MAAM,CAAC,WAAW;YAC1B,YAAY,EAAE,YAAY;YAC1B,WAAW,EAAE,CAAC,UAAC,OAAY,EAAE,KAAU;oBACnC,IAAI,SAAS,CAAC,OAAO,EAAE,KAAK,CAAC,EAAE;wBAC3B,OAAO,OAAO,CAAC,YAAY,CAAC,KAAK,EAAE,IAAI,OAAO,CAAC,YAAY,CAAC,KAAK,IAAI,IAAI,OAAO,CAAC,YAAY,CAAC,KAAK,SAAS,CAAC;qBAChH;oBACD,OAAO,IAAI,CAAC;gBAChB,CAAC,CAAC;YACF,iBAAiB,EAAE,iBAAiB;SACvC,CAAC;QACF,kCAAgB,CAAC,iCAAe,CAAC,CAAC,qBAAqB,CAAC,IAAI,uCAAkB,CAAC,IAAI,CAAC,CAAC,CAAC;IAC1F,CAAC,CAAC;AACN,CAAC;AAhBD,oCAgBC"}
1
+ {"version":3,"file":"is-optional-if.js","sourceRoot":"","sources":["../../../src/validators/custom-validators/is-optional-if.ts"],"names":[],"mappings":";;;AAAA,mDAAwG;AACxG,kFAAiF;AAGjF,SAAgB,YAAY,CAAC,SAA+C,EAAE,iBAAqC;IAC/G,OAAO,UAAU,MAA2B,EAAE,YAAoB;QAC9D,IAAM,IAAI,GAA2B;YACjC,IAAI,EAAE,iCAAe,CAAC,sBAAsB;YAC5C,MAAM,EAAE,MAAM,CAAC,WAAW;YAC1B,YAAY,EAAE,YAAY;YAC1B,WAAW,EAAE,CAAC,UAAC,OAAY,EAAE,KAAU;oBACnC,IAAI,SAAS,CAAC,OAAO,EAAE,KAAK,CAAC,EAAE;wBAC3B,OAAO,OAAO,CAAC,YAAY,CAAC,KAAK,EAAE,IAAI,OAAO,CAAC,YAAY,CAAC,KAAK,IAAI,IAAI,OAAO,CAAC,YAAY,CAAC,KAAK,SAAS,CAAC;qBAChH;oBACD,OAAO,IAAI,CAAC;gBAChB,CAAC,CAAC;YACF,iBAAiB,EAAE,iBAAiB;SACvC,CAAC;QACF,IAAA,kCAAgB,EAAC,iCAAe,CAAC,CAAC,qBAAqB,CAAC,IAAI,uCAAkB,CAAC,IAAI,CAAC,CAAC,CAAC;IAC1F,CAAC,CAAC;AACN,CAAC;AAhBD,oCAgBC"}
@@ -4,7 +4,7 @@ exports.PascalCase = void 0;
4
4
  var class_validator_1 = require("class-validator");
5
5
  function PascalCase(validationOptions) {
6
6
  return function (object, propertyName) {
7
- class_validator_1.registerDecorator({
7
+ (0, class_validator_1.registerDecorator)({
8
8
  name: 'pascalCase',
9
9
  target: object.constructor,
10
10
  propertyName: propertyName,
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pascal-case.js","sourceRoot":"","sources":["../../../src/validators/custom-validators/pascal-case.ts"],"names":[],"mappings":";;;AAAA,mDAAuE;AAEvE,SAAgB,UAAU,CAAC,iBAAqC;IAC5D,OAAO,UAAU,MAA2B,EAAE,YAAoB;QAC9D,IAAA,mCAAiB,EAAC;YACd,IAAI,EAAE,YAAY;YAClB,MAAM,EAAE,MAAM,CAAC,WAAW;YAC1B,YAAY,EAAE,YAAY;YAC1B,WAAW,EAAE,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC;YACrC,OAAO,EAAE,iBAAiB;YAC1B,SAAS,EAAE;gBACP,QAAQ,EAAR,UAAS,KAAU;oBACf,OAAO,0BAA0B,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;gBAClD,CAAC;aACJ;SACJ,CAAC,CAAC;IACP,CAAC,CAAC;AACN,CAAC;AAfD,gCAeC"}
File without changes
File without changes
File without changes
File without changes
@@ -5,7 +5,7 @@ var class_validator_1 = require("class-validator");
5
5
  var logger_1 = require("../logger");
6
6
  var validation_error_1 = require("./validation-error");
7
7
  function validate(data) {
8
- var errors = class_validator_1.validateSync(data);
8
+ var errors = (0, class_validator_1.validateSync)(data);
9
9
  return recursiveGetErrors(errors);
10
10
  }
11
11
  exports.validate = validate;
@@ -90,7 +90,7 @@ var validationPriorities = [
90
90
  'pascalCase'
91
91
  ];
92
92
  function getMetadatas(validationError, constraintName) {
93
- var metadatas = class_validator_1.getFromContainer(class_validator_1.MetadataStorage);
93
+ var metadatas = (0, class_validator_1.getFromContainer)(class_validator_1.MetadataStorage);
94
94
  var validationMetadatas = metadatas.validationMetadatas;
95
95
  var filteredMetadatas = validationMetadatas
96
96
  .filter(function (vmd) { return vmd.target === validationError.target.constructor
@@ -107,21 +107,21 @@ function recursiveGetErrors(validationErrors, errors, propertyName, previousValu
107
107
  var actualPreviousValueWasArray = previousValueWasArray;
108
108
  if (validationError.children.length > 0) {
109
109
  if (actualPreviousValueWasArray) {
110
- actualPropertyName = actualPropertyName + "[" + validationError.property + "]";
110
+ actualPropertyName = "".concat(actualPropertyName, "[").concat(validationError.property, "]");
111
111
  }
112
112
  else {
113
113
  actualPropertyName =
114
- actualPropertyName ? actualPropertyName + "." + validationError.property : validationError.property;
114
+ actualPropertyName ? "".concat(actualPropertyName, ".").concat(validationError.property) : validationError.property;
115
115
  }
116
116
  actualPreviousValueWasArray = Array.isArray(validationError.value);
117
117
  validationErrors = validationError.children;
118
118
  errors = recursiveGetErrors(validationErrors, errors, actualPropertyName, actualPreviousValueWasArray);
119
119
  }
120
120
  else {
121
- actualPropertyName = actualPropertyName ? actualPropertyName + "." + validationError.property : validationError.property;
121
+ actualPropertyName = actualPropertyName ? "".concat(actualPropertyName, ".").concat(validationError.property) : validationError.property;
122
122
  var constraintName = validationPriorities.find(function (cm) { return Object.keys(validationError.constraints).some(function (cs) { return cs === cm; }); });
123
123
  if (!constraintName) {
124
- logger_1.Logger.warn("validate: Constraint not found for " + actualPropertyName);
124
+ logger_1.Logger.warn("validate: Constraint not found for ".concat(actualPropertyName));
125
125
  }
126
126
  else {
127
127
  var metadatas = getMetadatas(validationError, constraintName);
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate.js","sourceRoot":"","sources":["../../src/validators/validate.ts"],"names":[],"mappings":"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"}
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
Binary file
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@my-devkit/core",
3
- "version": "1.0.26",
3
+ "version": "1.0.30",
4
4
  "description": "My Devkit: common tools",
5
- "module": "index.js",
6
- "typings": "index.d.ts",
5
+ "main": "dist/index.js",
6
+ "typings": "dist/index.d.ts",
7
7
  "keywords": [],
8
8
  "author": "Jean-Guy BUON",
9
9
  "license": "MIT",
@@ -12,18 +12,10 @@
12
12
  "url": "https://github.com/BUONJG/my-devkit.git"
13
13
  },
14
14
  "scripts": {
15
- "prebuild": "npm run clean && npm run eslint",
16
- "build": "tsc",
17
- "watch": "tsc -w",
18
- "deploy:increment-package-version": "npm version patch",
19
- "deploy:copy": "cpx package.json dist",
20
- "deploy:pack": "cd dist && npm pack",
21
- "deploy:publish": "cd dist && npm publish --access public",
22
- "predeploy": "rimraf ./dist && npm run deploy:increment-package-version",
23
- "deploy": "npm run build && npm run deploy:copy && npm run deploy:pack && npm run deploy:publish",
24
- "clean": "npx ts-cleaner -d ./dist -s ./src || true",
25
- "eslint": "npx eslint src/**/*.ts",
26
- "reinstall": "rimraf node_modules && npm install && npm outdated"
15
+ "preinstall": "npx only-allow pnpm",
16
+ "clean": "pnpx ts-cleaner -d ./dist -s ./src || true",
17
+ "build": "pnpm run clean && tsc",
18
+ "watch": "pnpm run clean && tsc -w"
27
19
  },
28
20
  "dependencies": {
29
21
  "cerialize": "0.1.18",
@@ -35,13 +27,13 @@
35
27
  "peerDependencies": {},
36
28
  "devDependencies": {
37
29
  "@types/lodash": "4.14.173",
38
- "@types/node": "14.11.8",
30
+ "@types/node": "^14.14.19",
39
31
  "@typescript-eslint/eslint-plugin": "4.22.1",
40
32
  "@typescript-eslint/parser": "4.22.1",
41
33
  "cpx": "1.5.0",
42
34
  "eslint": "7.26.0",
43
35
  "ts-cleaner": "1.0.5",
44
- "typescript": "4.2.4",
36
+ "typescript": "^4.5.2",
45
37
  "rimraf": "3.0.2"
46
38
  }
47
39
  }
package/src/command.ts ADDED
@@ -0,0 +1,9 @@
1
+ import { autoserializeAs, serializable } from './serialize';
2
+
3
+ export abstract class Command implements serializable.SerializableObject {
4
+ @autoserializeAs(String) public _type: string = null;
5
+
6
+ constructor(commandType: string) {
7
+ this._type = commandType;
8
+ }
9
+ }
@@ -0,0 +1,26 @@
1
+ export class DateHelper {
2
+ public static getUTCTimestamp(): number {
3
+ const now = new Date;
4
+ return Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate(),
5
+ now.getUTCHours(), now.getUTCMinutes(), now.getUTCSeconds(), now.getUTCMilliseconds());
6
+ }
7
+
8
+ public static getElapsedTime(startDate: Date): number {
9
+ return (new Date()).getTime() - startDate.getTime();
10
+ }
11
+
12
+ public static getReadableElapsedTime(startDate: Date): string {
13
+ const elapsedTime = this.getElapsedTime(startDate);
14
+
15
+ const minutes = Math.floor(elapsedTime / 60000);
16
+ const seconds = Math.floor(elapsedTime / 1000) - 60000 * minutes;
17
+ const miliseconds = elapsedTime - 60000 * minutes - 1000 * seconds;
18
+
19
+ if (minutes) {
20
+ return `${minutes} min ${seconds} sec ${miliseconds} ms`;
21
+ } else if (seconds) {
22
+ return `${seconds} sec ${miliseconds} ms`;
23
+ }
24
+ return `${miliseconds} ms`;
25
+ }
26
+ }
@@ -0,0 +1,20 @@
1
+ import { guid } from '../guid';
2
+ import { Logger } from '../logger';
3
+
4
+ export function Cacheable(): MethodDecorator {
5
+ return (target, propertyKey, descriptor) => {
6
+ const originalMethod: any = descriptor.value;
7
+ const cachePropertyName = `__cache_${propertyKey.toString()}_${guid()}__`;
8
+ target[cachePropertyName] = new Map<string, any>();
9
+
10
+ (descriptor as any).value = (...args) => {
11
+ const cacheKey = JSON.stringify(args);
12
+ if (!target[cachePropertyName].has(cacheKey)) {
13
+ target[cachePropertyName].set(cacheKey, originalMethod.apply(this, args));
14
+ } else {
15
+ Logger.info(`Cacheable: ${target.constructor.name}.${propertyKey.toString()} result retrieved from cache`, { args });
16
+ }
17
+ return target[cachePropertyName].get(cacheKey);
18
+ };
19
+ };
20
+ }
@@ -0,0 +1,2 @@
1
+ export * from './cacheable.decorator';
2
+ export * from './retryable.decorator';
@@ -0,0 +1,11 @@
1
+ import { retry } from '../retry';
2
+
3
+ export function Retryable(options?: retry.Options): MethodDecorator {
4
+ return (_target, _propertyKey, descriptor) => {
5
+ const originalMethod: any = descriptor.value;
6
+
7
+ (descriptor as any).value = async function (...args) {
8
+ return retry(async () => await originalMethod.apply(this, args), options);
9
+ };
10
+ };
11
+ }
@@ -0,0 +1,5 @@
1
+ import { serializable } from './serialize';
2
+
3
+ export interface Document extends serializable.SerializableObject {
4
+ _path: string;
5
+ }
@@ -0,0 +1,17 @@
1
+ export class EnumHelper<T> {
2
+ constructor(private _name: string, private _members: T[]) {
3
+ }
4
+
5
+ public get name(): string {
6
+ return this._name;
7
+ }
8
+
9
+ public get members(): T[] {
10
+ return [...this._members];
11
+ }
12
+
13
+ public membersNotIn(excludedMembers: T[]): T[] {
14
+ const notExcludedMembers = this._members.filter(m => !excludedMembers.includes(m));
15
+ return [...notExcludedMembers];
16
+ }
17
+ }
@@ -0,0 +1,8 @@
1
+ import { ErrorBase } from './error-base';
2
+
3
+ export class BadRequestError extends Error implements ErrorBase {
4
+ constructor(public message: string) {
5
+ super(message);
6
+ this.name = 'BadRequestError';
7
+ }
8
+ }
@@ -0,0 +1,8 @@
1
+ import { ErrorBase } from './error-base';
2
+
3
+ export class DomainError extends Error implements ErrorBase {
4
+ constructor(public message: string) {
5
+ super(message);
6
+ this.name = 'DomainError';
7
+ }
8
+ }
@@ -0,0 +1,3 @@
1
+ export interface ErrorBase extends Error {
2
+ message: string;
3
+ }
@@ -0,0 +1,8 @@
1
+ import { ErrorBase } from './error-base';
2
+
3
+ export class ForbiddenError extends Error implements ErrorBase {
4
+ constructor(public message: string) {
5
+ super(message);
6
+ this.name = 'ForbiddenError';
7
+ }
8
+ }
@@ -0,0 +1,8 @@
1
+ export * from './error-base';
2
+
3
+ export * from './bad-request-error';
4
+ export * from './forbidden-error';
5
+ export * from './not-found-error';
6
+ export * from './not-implemented-error';
7
+ export * from './unauthorized-error';
8
+ export * from './domain-error';
@@ -0,0 +1,8 @@
1
+ import { ErrorBase } from './error-base';
2
+
3
+ export class NotFoundError extends Error implements ErrorBase {
4
+ constructor(public message: string) {
5
+ super(message);
6
+ this.name = 'NotFoundError';
7
+ }
8
+ }
@@ -0,0 +1,8 @@
1
+ import { ErrorBase } from './error-base';
2
+
3
+ export class NotImplementedError extends Error implements ErrorBase {
4
+ constructor(public message: string) {
5
+ super(message);
6
+ this.name = 'NotImplementedError';
7
+ }
8
+ }
@@ -0,0 +1,8 @@
1
+ import { ErrorBase } from './error-base';
2
+
3
+ export class UnauthorizedError extends Error implements ErrorBase {
4
+ constructor(public message: string) {
5
+ super(message);
6
+ this.name = 'UnauthorizedError';
7
+ }
8
+ }
@@ -0,0 +1,3 @@
1
+ import { v4 } from 'uuid';
2
+
3
+ export const guid = v4;
package/src/index.ts ADDED
@@ -0,0 +1,19 @@
1
+ import * as validators from './validators';
2
+
3
+ export * from './decorators';
4
+ export * from './document';
5
+ export * from './command';
6
+ export * from './date-helper';
7
+ export * from './enum-helper';
8
+ export * from './errors';
9
+ export * from './guid';
10
+ export * from './logger';
11
+ export * from './model';
12
+ export * from './maintenance-model';
13
+ export * from './release-model';
14
+ export * from './serialize';
15
+ export * from './retry';
16
+ export * from './sleep';
17
+ export * from './vendors';
18
+ export const Validators = validators;
19
+ export { ValidationError } from './validators/validation-error';
package/src/logger.ts ADDED
@@ -0,0 +1,71 @@
1
+ import { DateHelper } from './date-helper';
2
+
3
+ export class Logger {
4
+ private static implementations: Logger.Implementation[] = [];
5
+
6
+ public static registerLogger(logger: Logger.Implementation): void {
7
+ this.implementations.push(logger);
8
+ }
9
+
10
+ public static debug(message: string, meta?: Logger.LogMetaData): void {
11
+ for (const implementation of this.implementations) {
12
+ implementation.debug(message, meta);
13
+ }
14
+ }
15
+
16
+ public static info(message: string, meta?: Logger.LogMetaData): void {
17
+ for (const implementation of this.implementations) {
18
+ implementation.info(message, meta);
19
+ }
20
+ }
21
+
22
+ public static infoWithElapesedTime(message: string, startDate: Date, meta?: Logger.LogMetaData): void {
23
+ this.info(message, {
24
+ ...meta,
25
+ elpasedTime: { ms: DateHelper.getElapsedTime(startDate), readable: DateHelper.getReadableElapsedTime(startDate) }
26
+ });
27
+ }
28
+
29
+ public static warn(message: string, meta?: Logger.LogMetaData): void {
30
+ for (const implementation of this.implementations) {
31
+ implementation.warn(message, meta);
32
+ }
33
+ }
34
+
35
+ public static error(message: string, meta?: Logger.LogMetaData): void {
36
+ for (const implementation of this.implementations) {
37
+ implementation.error(message, meta);
38
+ }
39
+ }
40
+ }
41
+
42
+ export namespace Logger {
43
+ export interface LogMetaData {
44
+ [key: string]: any;
45
+ }
46
+
47
+ export interface Implementation {
48
+ debug(message: string, data: LogMetaData): void;
49
+ info(message: string, data: LogMetaData): void;
50
+ warn(message: string, data: LogMetaData): void;
51
+ error(message: string, data: LogMetaData): void;
52
+ }
53
+
54
+ export class ConsoleImplementation implements Implementation {
55
+ public debug(message: string): void {
56
+ console.debug(`debug: ${message}`);
57
+ }
58
+
59
+ public info(message: string): void {
60
+ console.info(`info: ${message}`);
61
+ }
62
+
63
+ public warn(message: string): void {
64
+ console.warn(`warn: ${message}`);
65
+ }
66
+
67
+ public error(message: string): void {
68
+ console.error(`error: ${message}`);
69
+ }
70
+ }
71
+ }
@@ -0,0 +1,12 @@
1
+ import { Model } from './model';
2
+ import { autoserializeAs, inheritSerialization, serializable } from './serialize';
3
+
4
+ @serializable
5
+ @inheritSerialization(Model)
6
+ export class MaintenanceModel extends Model {
7
+ @autoserializeAs(Boolean) public status: boolean = null;
8
+
9
+ constructor() {
10
+ super('MaintenanceModel', () => `/continuous-integration/maintenance`);
11
+ }
12
+ }
package/src/model.ts ADDED
@@ -0,0 +1,15 @@
1
+ import { autoserializeAs } from 'cerialize';
2
+
3
+ import { Document } from './document';
4
+
5
+ export abstract class Model implements Document {
6
+ @autoserializeAs(String) public _type: string = null;
7
+
8
+ constructor(modelType: string, private pathCallback: () => string) {
9
+ this._type = modelType;
10
+ }
11
+
12
+ public get _path(): string {
13
+ return this.pathCallback();
14
+ }
15
+ }
@@ -0,0 +1,12 @@
1
+ import { Model } from './model';
2
+ import { autoserializeAs, inheritSerialization, serializable } from './serialize';
3
+
4
+ @serializable
5
+ @inheritSerialization(Model)
6
+ export class ReleaseModel extends Model {
7
+ @autoserializeAs(String) public version: string = null;
8
+
9
+ constructor() {
10
+ super('ReleaseModel', () => `/continuous-integration/release`);
11
+ }
12
+ }
package/src/retry.ts ADDED
@@ -0,0 +1,41 @@
1
+ import { Logger } from './logger';
2
+ import { sleep } from './sleep';
3
+
4
+ /**
5
+ * Retry operation
6
+ * @param operation
7
+ * @param options
8
+ */
9
+ export async function retry<T>(operation: () => Promise<T>, options?: retry.Options): Promise<T> {
10
+ options = { maxAttempts: 6, exponential: false, condition: () => true, ...options };
11
+
12
+ let continueTrying = true;
13
+ let retryCount = 0;
14
+ do {
15
+ try {
16
+ return await operation();
17
+ } catch (e) {
18
+ continueTrying = retryCount < options.maxAttempts && options.condition(e);
19
+ if (!continueTrying) {
20
+ throw e;
21
+ }
22
+ if (options.exponential) {
23
+ await sleep(Math.pow(2, retryCount) * 1000 + Math.round(Math.random() * 1000));
24
+ }
25
+
26
+ retryCount++;
27
+ Logger.info(`Retry: retrying... ${retryCount}/${options.maxAttempts}`);
28
+ }
29
+ } while (continueTrying)
30
+ }
31
+
32
+ export namespace retry {
33
+ export interface Options {
34
+ /**
35
+ * Condition callback
36
+ */
37
+ condition?: (error: any) => boolean;
38
+ maxAttempts?: number;
39
+ exponential?: boolean;
40
+ }
41
+ }
@@ -0,0 +1,11 @@
1
+ import { Deserialize } from 'cerialize';
2
+
3
+ import { serializable } from './serializable';
4
+
5
+ // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
6
+ export function deserialize<T>(object: any, type?: new () => T): T {
7
+ if (type) {
8
+ return Deserialize(object, type);
9
+ }
10
+ return Deserialize(object, serializable.getConstructor(object));
11
+ }
@@ -0,0 +1,6 @@
1
+ export * from './deserialize';
2
+ export * from './serialize';
3
+ export * from './serializable';
4
+ export * from './type-helper';
5
+
6
+ export { autoserializeAs, inheritSerialization } from 'cerialize';