@decohere/core 0.0.1-dev.126 → 0.0.1-dev.5

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 (252) hide show
  1. package/package.json +40 -15
  2. package/src/caching/cache-manager.ts +102 -0
  3. package/src/caching/cache.decorator.ts +56 -0
  4. package/src/caching/cache.ts +11 -0
  5. package/{es6/src/caching/index.js → src/caching/index.ts} +1 -1
  6. package/src/caching/invalidate-cache.decorator.ts +81 -0
  7. package/src/caching/memoize.decorator.ts +34 -0
  8. package/src/caching/node-cache-memoize.adapter.ts +47 -0
  9. package/src/cli/action.ts +77 -0
  10. package/src/cli/command.ts +173 -0
  11. package/src/cli/index.ts +30 -0
  12. package/src/cli/module.type.ts +48 -0
  13. package/src/cli/options.ts +81 -0
  14. package/src/collections/find-duplicates.ts +16 -0
  15. package/src/collections/merge-arrays.ts +9 -0
  16. package/src/collections/sum.ts +71 -0
  17. package/src/collections/unique-objects.ts +23 -0
  18. package/src/composition/index.ts +48 -0
  19. package/src/configuration/configuration.types.ts +13 -0
  20. package/src/diagnostics/index.ts +1 -0
  21. package/src/diagnostics/trace.ts +97 -0
  22. package/{es6/src/extensibility/decorator-factory-base.js → src/extensibility/decorator-factory-base.ts} +17 -9
  23. package/src/extensibility/decorator-factory.ts +44 -0
  24. package/src/extensibility/extension.ts +34 -0
  25. package/src/extensibility/mixwith.ts +42 -0
  26. package/src/extensibility/pipeline.ts +60 -0
  27. package/{types/src/extensibility/step.d.ts → src/extensibility/step.ts} +6 -4
  28. package/src/interop/docker/docker.ts +57 -0
  29. package/src/interop/errors/interop.error.ts +1 -0
  30. package/src/interop/git/git.ts +98 -0
  31. package/src/interop/git/git.types.ts +17 -0
  32. package/src/interop/index.ts +22 -0
  33. package/src/interop/node/index.ts +1 -0
  34. package/src/interop/node/node.ts +38 -0
  35. package/src/interop/npm/npm.ts +168 -0
  36. package/src/interop/npm/npm.types.ts +28 -0
  37. package/src/interop/pnpm/pnpm.ts +22 -0
  38. package/src/interop/pnpm/pnpm.types.ts +3 -0
  39. package/src/interop/shell/shell.argv.ts +31 -0
  40. package/src/interop/shell/shell.ts +100 -0
  41. package/src/interop/shell/shell.types.ts +9 -0
  42. package/src/interop/types/detect-package-manager.ts +45 -0
  43. package/src/interop/types/package-manager.ts +7 -0
  44. package/src/interop/yarn/yarn.ts +28 -0
  45. package/src/interop/yarn/yarn.types.ts +3 -0
  46. package/src/io/copy-file.ts +13 -0
  47. package/src/io/delete-file.ts +4 -0
  48. package/src/io/directory-exists.ts +9 -0
  49. package/src/io/file-exists.ts +10 -0
  50. package/src/io/find-directories.ts +13 -0
  51. package/src/io/find-file.ts +37 -0
  52. package/{es6/src/io/io.js → src/io/io.ts} +3 -0
  53. package/src/io/read-file.ts +25 -0
  54. package/src/io/remove-dir.ts +11 -0
  55. package/src/io/types/directory.type.ts +4 -0
  56. package/src/io/types/file.ts +34 -0
  57. package/src/io/url-to-path.ts +17 -0
  58. package/src/io/watch.ts +290 -0
  59. package/src/io/write-file.ts +21 -0
  60. package/src/objects/deep-merge.ts +131 -0
  61. package/{es6/src/reflection/index.js → src/reflection/index.ts} +1 -0
  62. package/src/reflection/types/reflection.types.ts +28 -0
  63. package/src/reflection/utilities.ts +92 -0
  64. package/src/semver/index.ts +1 -0
  65. package/src/semver/semver.ts +96 -0
  66. package/src/system/camel-case.ts +3 -0
  67. package/src/system/debounce.ts +13 -0
  68. package/src/system/decorator.ts +41 -0
  69. package/src/system/environment.ts +6 -0
  70. package/{types/src/system/function.types.d.ts → src/system/function.types.ts} +10 -2
  71. package/src/system/retry.decorator.ts +43 -0
  72. package/src/system/sleep.ts +6 -0
  73. package/src/system/type.utils.ts +5 -0
  74. package/src/testing/flush-promises.ts +7 -0
  75. package/src/testing/glob-with-memfs.ts +25 -0
  76. package/src/testing/index.ts +5 -0
  77. package/src/testing/memfs.ts +28 -0
  78. package/src/testing/mock-logger.ts +42 -0
  79. package/src/testing/spy-on-constructor.ts +33 -0
  80. package/tests/caching/cache-manager.spec.ts +147 -0
  81. package/tests/caching/cache-test-class.ts +91 -0
  82. package/tests/caching/cache.decorator.spec.ts +259 -0
  83. package/tests/caching/invalidate-cache-test-class.ts +52 -0
  84. package/tests/caching/invalidate-cache.decorator.spec.ts +120 -0
  85. package/tests/caching/memoize-test-class.ts +99 -0
  86. package/tests/caching/memoize.decorator.spec.ts +203 -0
  87. package/tests/cli/command.model.spec.ts +91 -0
  88. package/tests/collections/merge-arrays.spec.ts +50 -0
  89. package/tests/collections/sum.spec.ts +86 -0
  90. package/tests/collections/unique-objects.spec.ts +233 -0
  91. package/tests/extensibility/extension.spec.ts +29 -0
  92. package/tests/extensibility/pipeline.spec.ts +379 -0
  93. package/tests/interop/detect-package-manager.spec.ts +70 -0
  94. package/tests/interop/npm.spec.ts +129 -0
  95. package/tests/interop/pnpm.spec.ts +30 -0
  96. package/tests/interop/shell.spec.ts +47 -0
  97. package/tests/interop/yarn.spec.ts +18 -0
  98. package/tests/io/find-file.spec.ts +188 -0
  99. package/tests/io/watch.real-fs.spec.ts +76 -0
  100. package/tests/io/watch.spec.ts +291 -0
  101. package/tests/mock-prototype.ts +12 -0
  102. package/tests/semver/semver.spec.ts +51 -0
  103. package/tests/system/decorator.spec.ts +250 -0
  104. package/tests/system/retry.decorator.spec.ts +57 -0
  105. package/LICENSE +0 -15
  106. package/commonjs/src/caching/cache-manager.js +0 -98
  107. package/commonjs/src/caching/cache.decorator.js +0 -69
  108. package/commonjs/src/caching/cache.js +0 -6
  109. package/commonjs/src/caching/index.js +0 -23
  110. package/commonjs/src/caching/invalidate-cache.decorator.js +0 -92
  111. package/commonjs/src/caching/map-cache.js +0 -39
  112. package/commonjs/src/caching/memoize.decorator.js +0 -36
  113. package/commonjs/src/collections/collections.js +0 -21
  114. package/commonjs/src/collections/find-duplicates.js +0 -35
  115. package/commonjs/src/collections/index.js +0 -52
  116. package/commonjs/src/collections/merge-arrays.js +0 -34
  117. package/commonjs/src/collections/sum.js +0 -63
  118. package/commonjs/src/collections/unique-objects.js +0 -39
  119. package/commonjs/src/composition/index.js +0 -4
  120. package/commonjs/src/configuration/configuration.types.js +0 -11
  121. package/commonjs/src/configuration/index.js +0 -18
  122. package/commonjs/src/extensibility/decorator-factory-base.js +0 -22
  123. package/commonjs/src/extensibility/decorator-factory.js +0 -31
  124. package/commonjs/src/extensibility/extension.js +0 -37
  125. package/commonjs/src/extensibility/index.js +0 -23
  126. package/commonjs/src/extensibility/mixwith.js +0 -36
  127. package/commonjs/src/extensibility/pipeline.js +0 -56
  128. package/commonjs/src/extensibility/step.js +0 -18
  129. package/commonjs/src/io/copy-file.js +0 -25
  130. package/commonjs/src/io/delete-file.js +0 -21
  131. package/commonjs/src/io/directory-exists.js +0 -24
  132. package/commonjs/src/io/file-exists.js +0 -19
  133. package/commonjs/src/io/index.js +0 -66
  134. package/commonjs/src/io/io.js +0 -25
  135. package/commonjs/src/io/read-file.js +0 -39
  136. package/commonjs/src/io/remove-dir.js +0 -22
  137. package/commonjs/src/io/types/directory.type.js +0 -4
  138. package/commonjs/src/io/types/file.js +0 -28
  139. package/commonjs/src/io/types/index.js +0 -19
  140. package/commonjs/src/io/url-to-path.js +0 -33
  141. package/commonjs/src/io/write-file.js +0 -30
  142. package/commonjs/src/objects/deep-merge.js +0 -67
  143. package/commonjs/src/objects/index.js +0 -11
  144. package/commonjs/src/reflection/index.js +0 -20
  145. package/commonjs/src/reflection/types/index.js +0 -18
  146. package/commonjs/src/reflection/types/reflection.types.js +0 -26
  147. package/commonjs/src/reflection/utilities.js +0 -118
  148. package/commonjs/src/system/camel-case.js +0 -13
  149. package/commonjs/src/system/debounce.js +0 -19
  150. package/commonjs/src/system/decorator.js +0 -46
  151. package/commonjs/src/system/environment.js +0 -23
  152. package/commonjs/src/system/function.types.js +0 -18
  153. package/commonjs/src/system/index.js +0 -24
  154. package/commonjs/src/system/retry.decorator.js +0 -40
  155. package/commonjs/src/system/sleep.js +0 -13
  156. package/commonjs/src/system/type.utils.js +0 -4
  157. package/es6/src/caching/cache-manager.js +0 -82
  158. package/es6/src/caching/cache.decorator.js +0 -51
  159. package/es6/src/caching/cache.js +0 -3
  160. package/es6/src/caching/invalidate-cache.decorator.js +0 -71
  161. package/es6/src/caching/map-cache.js +0 -35
  162. package/es6/src/caching/memoize.decorator.js +0 -27
  163. package/es6/src/collections/find-duplicates.js +0 -17
  164. package/es6/src/collections/merge-arrays.js +0 -16
  165. package/es6/src/collections/sum.js +0 -45
  166. package/es6/src/collections/unique-objects.js +0 -21
  167. package/es6/src/composition/index.js +0 -1
  168. package/es6/src/configuration/configuration.types.js +0 -1
  169. package/es6/src/extensibility/decorator-factory.js +0 -21
  170. package/es6/src/extensibility/extension.js +0 -27
  171. package/es6/src/extensibility/mixwith.js +0 -26
  172. package/es6/src/extensibility/pipeline.js +0 -46
  173. package/es6/src/extensibility/step.js +0 -16
  174. package/es6/src/io/copy-file.js +0 -10
  175. package/es6/src/io/delete-file.js +0 -6
  176. package/es6/src/io/directory-exists.js +0 -9
  177. package/es6/src/io/file-exists.js +0 -9
  178. package/es6/src/io/read-file.js +0 -13
  179. package/es6/src/io/remove-dir.js +0 -7
  180. package/es6/src/io/types/directory.type.js +0 -1
  181. package/es6/src/io/types/file.js +0 -18
  182. package/es6/src/io/url-to-path.js +0 -15
  183. package/es6/src/io/write-file.js +0 -15
  184. package/es6/src/objects/deep-merge.js +0 -57
  185. package/es6/src/reflection/types/reflection.types.js +0 -8
  186. package/es6/src/reflection/utilities.js +0 -74
  187. package/es6/src/system/camel-case.js +0 -3
  188. package/es6/src/system/debounce.js +0 -9
  189. package/es6/src/system/decorator.js +0 -30
  190. package/es6/src/system/environment.js +0 -5
  191. package/es6/src/system/function.types.js +0 -26
  192. package/es6/src/system/retry.decorator.js +0 -30
  193. package/es6/src/system/sleep.js +0 -3
  194. package/es6/src/system/type.utils.js +0 -1
  195. package/types/src/caching/cache-manager.d.ts +0 -59
  196. package/types/src/caching/cache.d.ts +0 -11
  197. package/types/src/caching/cache.decorator.d.ts +0 -18
  198. package/types/src/caching/index.d.ts +0 -6
  199. package/types/src/caching/invalidate-cache.decorator.d.ts +0 -17
  200. package/types/src/caching/map-cache.d.ts +0 -23
  201. package/types/src/caching/memoize.decorator.d.ts +0 -16
  202. package/types/src/collections/collections.d.ts +0 -4
  203. package/types/src/collections/find-duplicates.d.ts +0 -2
  204. package/types/src/collections/index.d.ts +0 -1
  205. package/types/src/collections/merge-arrays.d.ts +0 -2
  206. package/types/src/collections/sum.d.ts +0 -4
  207. package/types/src/collections/unique-objects.d.ts +0 -2
  208. package/types/src/composition/index.d.ts +0 -37
  209. package/types/src/configuration/configuration.types.d.ts +0 -10
  210. package/types/src/configuration/index.d.ts +0 -1
  211. package/types/src/extensibility/decorator-factory-base.d.ts +0 -39
  212. package/types/src/extensibility/decorator-factory.d.ts +0 -19
  213. package/types/src/extensibility/extension.d.ts +0 -9
  214. package/types/src/extensibility/index.d.ts +0 -6
  215. package/types/src/extensibility/mixwith.d.ts +0 -6
  216. package/types/src/extensibility/pipeline.d.ts +0 -12
  217. package/types/src/io/copy-file.d.ts +0 -4
  218. package/types/src/io/delete-file.d.ts +0 -1
  219. package/types/src/io/directory-exists.d.ts +0 -1
  220. package/types/src/io/file-exists.d.ts +0 -1
  221. package/types/src/io/index.d.ts +0 -2
  222. package/types/src/io/io.d.ts +0 -8
  223. package/types/src/io/read-file.d.ts +0 -4
  224. package/types/src/io/remove-dir.d.ts +0 -5
  225. package/types/src/io/types/directory.type.d.ts +0 -4
  226. package/types/src/io/types/file.d.ts +0 -20
  227. package/types/src/io/types/index.d.ts +0 -2
  228. package/types/src/io/url-to-path.d.ts +0 -2
  229. package/types/src/io/write-file.d.ts +0 -5
  230. package/types/src/objects/deep-merge.d.ts +0 -41
  231. package/types/src/objects/index.d.ts +0 -1
  232. package/types/src/reflection/index.d.ts +0 -3
  233. package/types/src/reflection/types/index.d.ts +0 -1
  234. package/types/src/reflection/types/reflection.types.d.ts +0 -21
  235. package/types/src/reflection/utilities.d.ts +0 -27
  236. package/types/src/system/camel-case.d.ts +0 -1
  237. package/types/src/system/debounce.d.ts +0 -1
  238. package/types/src/system/decorator.d.ts +0 -15
  239. package/types/src/system/environment.d.ts +0 -6
  240. package/types/src/system/index.d.ts +0 -7
  241. package/types/src/system/retry.decorator.d.ts +0 -6
  242. package/types/src/system/sleep.d.ts +0 -1
  243. package/types/src/system/type.utils.d.ts +0 -1
  244. /package/{es6/src/collections/collections.js → src/collections/collections.ts} +0 -0
  245. /package/{es6/src/collections/index.js → src/collections/index.ts} +0 -0
  246. /package/{es6/src/configuration/index.js → src/configuration/index.ts} +0 -0
  247. /package/{es6/src/extensibility/index.js → src/extensibility/index.ts} +0 -0
  248. /package/{es6/src/io/index.js → src/io/index.ts} +0 -0
  249. /package/{es6/src/io/types/index.js → src/io/types/index.ts} +0 -0
  250. /package/{es6/src/objects/index.js → src/objects/index.ts} +0 -0
  251. /package/{es6/src/reflection/types/index.js → src/reflection/types/index.ts} +0 -0
  252. /package/{es6/src/system/index.js → src/system/index.ts} +0 -0
@@ -1,25 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- _export_star(require("./copy-file.js"), exports);
6
- _export_star(require("./delete-file.js"), exports);
7
- _export_star(require("./directory-exists.js"), exports);
8
- _export_star(require("./file-exists.js"), exports);
9
- _export_star(require("./read-file.js"), exports);
10
- _export_star(require("./remove-dir.js"), exports);
11
- _export_star(require("./url-to-path.js"), exports);
12
- _export_star(require("./write-file.js"), exports);
13
- function _export_star(from, to) {
14
- Object.keys(from).forEach(function(k) {
15
- if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
16
- Object.defineProperty(to, k, {
17
- enumerable: true,
18
- get: function() {
19
- return from[k];
20
- }
21
- });
22
- }
23
- });
24
- return from;
25
- }
@@ -1,39 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
6
- for(var name in all)Object.defineProperty(target, name, {
7
- enumerable: true,
8
- get: Object.getOwnPropertyDescriptor(all, name).get
9
- });
10
- }
11
- _export(exports, {
12
- get readFile () {
13
- return readFile;
14
- },
15
- get readFiles () {
16
- return readFiles;
17
- },
18
- get readJsonFile () {
19
- return readJsonFile;
20
- }
21
- });
22
- const _promises = /*#__PURE__*/ _interop_require_default(require("node:fs/promises"));
23
- function _interop_require_default(obj) {
24
- return obj && obj.__esModule ? obj : {
25
- default: obj
26
- };
27
- }
28
- async function readFiles(filePaths, encoding = "utf8") {
29
- const data = await Promise.all(filePaths.map((file)=>readFile(file.fullPath, encoding)));
30
- return data;
31
- }
32
- async function readFile(filePath, encoding = "utf8") {
33
- const data = await _promises.default.readFile(filePath, encoding);
34
- return data;
35
- }
36
- async function readJsonFile(filePath, encoding = "utf8") {
37
- const data = await readFile(filePath, encoding);
38
- return JSON.parse(data);
39
- }
@@ -1,22 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "removeDir", {
6
- enumerable: true,
7
- get: function() {
8
- return removeDir;
9
- }
10
- });
11
- const _promises = /*#__PURE__*/ _interop_require_default(require("node:fs/promises"));
12
- function _interop_require_default(obj) {
13
- return obj && obj.__esModule ? obj : {
14
- default: obj
15
- };
16
- }
17
- async function removeDir(path, options = {
18
- recursive: false,
19
- force: false
20
- }) {
21
- await _promises.default.rm(path, options);
22
- }
@@ -1,4 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
@@ -1,28 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "FileEx", {
6
- enumerable: true,
7
- get: function() {
8
- return FileEx;
9
- }
10
- });
11
- const _readfile = require("../read-file.js");
12
- class FileEx {
13
- constructor(data){
14
- this.fullPath = data.fullPath;
15
- this.relativePath = data.relativePath ?? data.fullPath;
16
- this.#content = data.content;
17
- }
18
- #content;
19
- fullPath;
20
- relativePath;
21
- toString() {
22
- return this.relativePath;
23
- }
24
- async getContent() {
25
- if (this.#content != null) return this.#content;
26
- return (0, _readfile.readFile)(this.fullPath);
27
- }
28
- }
@@ -1,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- _export_star(require("./directory.type.js"), exports);
6
- _export_star(require("./file.js"), exports);
7
- function _export_star(from, to) {
8
- Object.keys(from).forEach(function(k) {
9
- if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
10
- Object.defineProperty(to, k, {
11
- enumerable: true,
12
- get: function() {
13
- return from[k];
14
- }
15
- });
16
- }
17
- });
18
- return from;
19
- }
@@ -1,33 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
6
- for(var name in all)Object.defineProperty(target, name, {
7
- enumerable: true,
8
- get: Object.getOwnPropertyDescriptor(all, name).get
9
- });
10
- }
11
- _export(exports, {
12
- get fileUrlToPath () {
13
- return fileUrlToPath;
14
- },
15
- get pathToFileUrl () {
16
- return pathToFileUrl;
17
- }
18
- });
19
- const _nodeurl = require("node:url");
20
- const fileUrlToPath = (url)=>{
21
- try {
22
- return (0, _nodeurl.fileURLToPath)(url);
23
- } catch {
24
- return url;
25
- }
26
- };
27
- const pathToFileUrl = (path)=>{
28
- try {
29
- return (0, _nodeurl.pathToFileURL)(path).toString();
30
- } catch {
31
- return path;
32
- }
33
- };
@@ -1,30 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "writeFile", {
6
- enumerable: true,
7
- get: function() {
8
- return writeFile;
9
- }
10
- });
11
- const _promises = /*#__PURE__*/ _interop_require_default(require("node:fs/promises"));
12
- const _nodepath = /*#__PURE__*/ _interop_require_default(require("node:path"));
13
- function _interop_require_default(obj) {
14
- return obj && obj.__esModule ? obj : {
15
- default: obj
16
- };
17
- }
18
- async function writeFile(filePath, content, options = {
19
- encoding: "utf8",
20
- mkdir: false
21
- }) {
22
- const { encoding, mkdir } = options;
23
- if (mkdir) {
24
- const directory = _nodepath.default.dirname(filePath);
25
- await _promises.default.mkdir(directory, {
26
- recursive: true
27
- });
28
- }
29
- await _promises.default.writeFile(filePath, content, encoding);
30
- }
@@ -1,67 +0,0 @@
1
- // Source https://github.com/voodoocreation/ts-deepmerge/blob/master/package.json
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "merge", {
7
- enumerable: true,
8
- get: function() {
9
- return merge;
10
- }
11
- });
12
- // istanbul ignore next
13
- const isObject = (obj)=>{
14
- if (typeof obj === "object" && obj !== null) {
15
- if (typeof Object.getPrototypeOf === "function") {
16
- const prototype = Object.getPrototypeOf(obj);
17
- return prototype === Object.prototype || prototype === null;
18
- }
19
- return Object.prototype.toString.call(obj) === "[object Object]";
20
- }
21
- return false;
22
- };
23
- const merge = (...objects)=>objects.reduce((result, current)=>{
24
- if (current === undefined) {
25
- return result;
26
- }
27
- if (Array.isArray(current)) {
28
- throw new TypeError("Arguments provided to ts-deepmerge must be objects, not arrays.");
29
- }
30
- Object.keys(current).forEach((key)=>{
31
- if ([
32
- "__proto__",
33
- "constructor",
34
- "prototype"
35
- ].includes(key)) {
36
- return;
37
- }
38
- if (Array.isArray(result[key]) && Array.isArray(current[key])) {
39
- result[key] = merge.options.mergeArrays ? merge.options.uniqueArrayItems ? Array.from(new Set(result[key].concat(current[key]))) : [
40
- ...result[key],
41
- ...current[key]
42
- ] : current[key];
43
- } else if (isObject(result[key]) && isObject(current[key])) {
44
- result[key] = merge(result[key], current[key]);
45
- } else if (!isObject(result[key]) && isObject(current[key])) {
46
- result[key] = merge(current[key], undefined);
47
- } else {
48
- result[key] = current[key] === undefined ? merge.options.allowUndefinedOverrides ? current[key] : result[key] : current[key];
49
- }
50
- });
51
- return result;
52
- }, {});
53
- const defaultOptions = {
54
- allowUndefinedOverrides: true,
55
- mergeArrays: true,
56
- uniqueArrayItems: true
57
- };
58
- merge.options = defaultOptions;
59
- merge.withOptions = (options, ...objects)=>{
60
- merge.options = {
61
- ...defaultOptions,
62
- ...options
63
- };
64
- const result = merge(...objects);
65
- merge.options = defaultOptions;
66
- return result;
67
- };
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "merge", {
6
- enumerable: true,
7
- get: function() {
8
- return _deepmerge.merge;
9
- }
10
- });
11
- const _deepmerge = require("./deep-merge.js");
@@ -1,20 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- require("reflect-metadata");
6
- _export_star(require("./types/index.js"), exports);
7
- _export_star(require("./utilities.js"), exports);
8
- function _export_star(from, to) {
9
- Object.keys(from).forEach(function(k) {
10
- if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
11
- Object.defineProperty(to, k, {
12
- enumerable: true,
13
- get: function() {
14
- return from[k];
15
- }
16
- });
17
- }
18
- });
19
- return from;
20
- }
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- _export_star(require("./reflection.types.js"), exports);
6
- function _export_star(from, to) {
7
- Object.keys(from).forEach(function(k) {
8
- if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
9
- Object.defineProperty(to, k, {
10
- enumerable: true,
11
- get: function() {
12
- return from[k];
13
- }
14
- });
15
- }
16
- });
17
- return from;
18
- }
@@ -1,26 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
6
- for(var name in all)Object.defineProperty(target, name, {
7
- enumerable: true,
8
- get: Object.getOwnPropertyDescriptor(all, name).get
9
- });
10
- }
11
- _export(exports, {
12
- get MetaDataOwners () {
13
- return MetaDataOwners;
14
- },
15
- get ReflectionMeta () {
16
- return ReflectionMeta;
17
- }
18
- });
19
- const MetaDataOwners = {
20
- Hearth: "hearth",
21
- Reflect: "design"
22
- };
23
- const ReflectionMeta = {
24
- paramtypes: `${MetaDataOwners.Reflect}:paramtypes`,
25
- type: `${MetaDataOwners.Reflect}:type`
26
- };
@@ -1,118 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
6
- for(var name in all)Object.defineProperty(target, name, {
7
- enumerable: true,
8
- get: Object.getOwnPropertyDescriptor(all, name).get
9
- });
10
- }
11
- _export(exports, {
12
- get defineArgumentMeta () {
13
- return defineArgumentMeta;
14
- },
15
- get defineMeta () {
16
- return defineMeta;
17
- },
18
- get getArgumentMeta () {
19
- return getArgumentMeta;
20
- },
21
- get getFieldType () {
22
- return getFieldType;
23
- },
24
- get getFields () {
25
- return getFields;
26
- },
27
- get getFunction () {
28
- return getFunction;
29
- },
30
- get getFunctionArgs () {
31
- return getFunctionArgs;
32
- },
33
- get getFunctionMetadata () {
34
- return getFunctionMetadata;
35
- },
36
- get getFunctions () {
37
- return getFunctions;
38
- },
39
- get getMeta () {
40
- return getMeta;
41
- },
42
- get isArrayType () {
43
- return isArrayType;
44
- },
45
- get isConstructable () {
46
- return isConstructable;
47
- },
48
- get isDateType () {
49
- return isDateType;
50
- },
51
- get isPrimitiveOrDateType () {
52
- return isPrimitiveOrDateType;
53
- }
54
- });
55
- const _reflectiontypes = require("./types/reflection.types.js");
56
- const Primitives = [
57
- "string",
58
- "number",
59
- "bigint",
60
- "boolean",
61
- "undefined",
62
- "symbol",
63
- "null"
64
- ];
65
- const isPrimitiveOrDateType = (type)=>{
66
- return Primitives.includes(type.name.toLocaleLowerCase()) || isDateType(type);
67
- };
68
- const isDateType = (type)=>{
69
- return type?.prototype === Date.prototype;
70
- };
71
- function isConstructable(type) {
72
- const proto = type?.prototype;
73
- const isConstructable = typeof type === "function" && typeof proto === "object";
74
- return isConstructable;
75
- }
76
- const isArrayType = (type)=>{
77
- return type?.prototype === Array.prototype;
78
- };
79
- function getMeta(key, target, propertyKey) {
80
- const meta = Reflect.getMetadata(key, target, propertyKey);
81
- return meta;
82
- }
83
- function getFunctions(object) {
84
- const functions = Object.entries(Object.getOwnPropertyDescriptors(object.prototype)).filter(([key])=>key !== "constructor").map(([, value])=>value);
85
- return functions;
86
- }
87
- function getFunction(object, functionName) {
88
- const [, value] = Object.entries(Object.getOwnPropertyDescriptors(object.prototype)).find(([k])=>k !== "constructor" && k === functionName);
89
- return value;
90
- }
91
- function getFunctionMetadata(key, target, func) {
92
- const meta = Reflect.getMetadata(key, target, func.name);
93
- return meta;
94
- }
95
- function getFunctionArgs(target, func) {
96
- const meta = getFunctionMetadata(_reflectiontypes.ReflectionMeta.paramtypes, target, func);
97
- return meta;
98
- }
99
- function getFields(object) {
100
- const fields = Object.entries(Object.getOwnPropertyDescriptors(object)).filter(([, val])=>typeof val.value !== "function").map(([key, propertyDescriptor])=>({
101
- key,
102
- propertyDescriptor
103
- }));
104
- return fields;
105
- }
106
- function getFieldType(target, fieldName) {
107
- return Reflect.getMetadata(_reflectiontypes.ReflectionMeta.type, target, fieldName);
108
- }
109
- function getArgumentMeta(key, target, argIndex) {
110
- const meta = Reflect.getMetadata(key, target, argIndex.toString());
111
- return meta;
112
- }
113
- function defineMeta(key, value, target) {
114
- Reflect.defineMetadata(key, value, target);
115
- }
116
- function defineArgumentMeta(key, value, func, argIndex) {
117
- Reflect.defineMetadata(key, value, func, argIndex.toString());
118
- }
@@ -1,13 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "lowerCamelCase", {
6
- enumerable: true,
7
- get: function() {
8
- return lowerCamelCase;
9
- }
10
- });
11
- function lowerCamelCase(val) {
12
- return String(val).charAt(0).toLowerCase() + String(val).slice(1);
13
- }
@@ -1,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "debounce", {
6
- enumerable: true,
7
- get: function() {
8
- return debounce;
9
- }
10
- });
11
- function debounce(callback, delay) {
12
- let timeoutTimer;
13
- return (...args)=>{
14
- clearTimeout(timeoutTimer);
15
- timeoutTimer = setTimeout(async ()=>{
16
- await callback(...args);
17
- }, delay);
18
- };
19
- }
@@ -1,46 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
6
- for(var name in all)Object.defineProperty(target, name, {
7
- enumerable: true,
8
- get: Object.getOwnPropertyDescriptor(all, name).get
9
- });
10
- }
11
- _export(exports, {
12
- get FunctionDecorator () {
13
- return FunctionDecorator;
14
- },
15
- get ignoreDuringUnitTest () {
16
- return ignoreDuringUnitTest;
17
- },
18
- get ignoreIf () {
19
- return ignoreIf;
20
- }
21
- });
22
- class FunctionDecorator {
23
- options;
24
- constructor(){
25
- this.decoratorFactory = this.decoratorFactory.bind(this);
26
- }
27
- decoratorFactory(options) {
28
- this.options = options;
29
- return this.decorator.bind(this);
30
- }
31
- }
32
- function ignoreIf(...envVars) {
33
- return (_, __, descriptor)=>{
34
- const originalFunction = descriptor.value;
35
- descriptor.value = function(target, key, descriptor) {
36
- if (envVars.some((v)=>process.env[v] === "true")) {
37
- return descriptor;
38
- }
39
- return originalFunction.bind(this)(target, key, descriptor);
40
- };
41
- return descriptor;
42
- };
43
- }
44
- function ignoreDuringUnitTest() {
45
- return ignoreIf("TEST");
46
- }
@@ -1,23 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
6
- for(var name in all)Object.defineProperty(target, name, {
7
- enumerable: true,
8
- get: Object.getOwnPropertyDescriptor(all, name).get
9
- });
10
- }
11
- _export(exports, {
12
- get DefaultEnvironment () {
13
- return DefaultEnvironment;
14
- },
15
- get Environments () {
16
- return Environments;
17
- }
18
- });
19
- const Environments = {
20
- production: "production",
21
- development: "development"
22
- };
23
- const DefaultEnvironment = Environments.development;
@@ -1,18 +0,0 @@
1
- /**
2
- * Generic function type that can replace arrow function signatures.
3
- *
4
- * @example
5
- * ```typescript
6
- * // Instead of: (arg1: string, arg2: number) => boolean
7
- * type MyCallback = Func<[string, number], boolean>;
8
- *
9
- * // Instead of: (data: any) => void
10
- * type MyHandler = Func<[any], void>;
11
- *
12
- * // Instead of: () => Promise<string>
13
- * type MyAsyncFunc = Func<[], Promise<string>>;
14
- * ```
15
- */ "use strict";
16
- Object.defineProperty(exports, "__esModule", {
17
- value: true
18
- });
@@ -1,24 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- _export_star(require("./camel-case.js"), exports);
6
- _export_star(require("./debounce.js"), exports);
7
- _export_star(require("./decorator.js"), exports);
8
- _export_star(require("./environment.js"), exports);
9
- _export_star(require("./function.types.js"), exports);
10
- _export_star(require("./retry.decorator.js"), exports);
11
- _export_star(require("./type.utils.js"), exports);
12
- function _export_star(from, to) {
13
- Object.keys(from).forEach(function(k) {
14
- if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
15
- Object.defineProperty(to, k, {
16
- enumerable: true,
17
- get: function() {
18
- return from[k];
19
- }
20
- });
21
- }
22
- });
23
- return from;
24
- }
@@ -1,40 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "retry", {
6
- enumerable: true,
7
- get: function() {
8
- return retry;
9
- }
10
- });
11
- const _decorator = require("./decorator.js");
12
- const _sleep = require("./sleep.js");
13
- class RetryDecorator extends _decorator.FunctionDecorator {
14
- decorator(_target, _propertyKey, descriptor) {
15
- const originalMethod = descriptor.value;
16
- const attempts = Math.max(1, this.options?.attempts ?? 3);
17
- const delayMs = Math.max(0, this.options?.delayMs ?? 0);
18
- const shouldRetry = this.options?.shouldRetry ?? (()=>true);
19
- descriptor.value = async function(...args) {
20
- let lastError;
21
- for(let attempt = 1; attempt <= attempts; attempt++){
22
- try {
23
- return await Promise.resolve(originalMethod.apply(this, args));
24
- } catch (error) {
25
- lastError = error;
26
- const shouldAttemptAgain = attempt < attempts && shouldRetry(error);
27
- if (!shouldAttemptAgain) {
28
- throw error;
29
- }
30
- if (delayMs > 0) {
31
- await (0, _sleep.sleep)(delayMs);
32
- }
33
- }
34
- }
35
- throw lastError;
36
- };
37
- return descriptor;
38
- }
39
- }
40
- const retry = new RetryDecorator().decoratorFactory;
@@ -1,13 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "sleep", {
6
- enumerable: true,
7
- get: function() {
8
- return sleep;
9
- }
10
- });
11
- const sleep = (ms)=>new Promise((resolve)=>setTimeout(()=>{
12
- resolve(null);
13
- }, ms));