@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.
- package/package.json +40 -15
- package/src/caching/cache-manager.ts +102 -0
- package/src/caching/cache.decorator.ts +56 -0
- package/src/caching/cache.ts +11 -0
- package/{es6/src/caching/index.js → src/caching/index.ts} +1 -1
- package/src/caching/invalidate-cache.decorator.ts +81 -0
- package/src/caching/memoize.decorator.ts +34 -0
- package/src/caching/node-cache-memoize.adapter.ts +47 -0
- package/src/cli/action.ts +77 -0
- package/src/cli/command.ts +173 -0
- package/src/cli/index.ts +30 -0
- package/src/cli/module.type.ts +48 -0
- package/src/cli/options.ts +81 -0
- package/src/collections/find-duplicates.ts +16 -0
- package/src/collections/merge-arrays.ts +9 -0
- package/src/collections/sum.ts +71 -0
- package/src/collections/unique-objects.ts +23 -0
- package/src/composition/index.ts +48 -0
- package/src/configuration/configuration.types.ts +13 -0
- package/src/diagnostics/index.ts +1 -0
- package/src/diagnostics/trace.ts +97 -0
- package/{es6/src/extensibility/decorator-factory-base.js → src/extensibility/decorator-factory-base.ts} +17 -9
- package/src/extensibility/decorator-factory.ts +44 -0
- package/src/extensibility/extension.ts +34 -0
- package/src/extensibility/mixwith.ts +42 -0
- package/src/extensibility/pipeline.ts +60 -0
- package/{types/src/extensibility/step.d.ts → src/extensibility/step.ts} +6 -4
- package/src/interop/docker/docker.ts +57 -0
- package/src/interop/errors/interop.error.ts +1 -0
- package/src/interop/git/git.ts +98 -0
- package/src/interop/git/git.types.ts +17 -0
- package/src/interop/index.ts +22 -0
- package/src/interop/node/index.ts +1 -0
- package/src/interop/node/node.ts +38 -0
- package/src/interop/npm/npm.ts +168 -0
- package/src/interop/npm/npm.types.ts +28 -0
- package/src/interop/pnpm/pnpm.ts +22 -0
- package/src/interop/pnpm/pnpm.types.ts +3 -0
- package/src/interop/shell/shell.argv.ts +31 -0
- package/src/interop/shell/shell.ts +100 -0
- package/src/interop/shell/shell.types.ts +9 -0
- package/src/interop/types/detect-package-manager.ts +45 -0
- package/src/interop/types/package-manager.ts +7 -0
- package/src/interop/yarn/yarn.ts +28 -0
- package/src/interop/yarn/yarn.types.ts +3 -0
- package/src/io/copy-file.ts +13 -0
- package/src/io/delete-file.ts +4 -0
- package/src/io/directory-exists.ts +9 -0
- package/src/io/file-exists.ts +10 -0
- package/src/io/find-directories.ts +13 -0
- package/src/io/find-file.ts +37 -0
- package/{es6/src/io/io.js → src/io/io.ts} +3 -0
- package/src/io/read-file.ts +25 -0
- package/src/io/remove-dir.ts +11 -0
- package/src/io/types/directory.type.ts +4 -0
- package/src/io/types/file.ts +34 -0
- package/src/io/url-to-path.ts +17 -0
- package/src/io/watch.ts +290 -0
- package/src/io/write-file.ts +21 -0
- package/src/objects/deep-merge.ts +131 -0
- package/{es6/src/reflection/index.js → src/reflection/index.ts} +1 -0
- package/src/reflection/types/reflection.types.ts +28 -0
- package/src/reflection/utilities.ts +92 -0
- package/src/semver/index.ts +1 -0
- package/src/semver/semver.ts +96 -0
- package/src/system/camel-case.ts +3 -0
- package/src/system/debounce.ts +13 -0
- package/src/system/decorator.ts +41 -0
- package/src/system/environment.ts +6 -0
- package/{types/src/system/function.types.d.ts → src/system/function.types.ts} +10 -2
- package/src/system/retry.decorator.ts +43 -0
- package/src/system/sleep.ts +6 -0
- package/src/system/type.utils.ts +5 -0
- package/src/testing/flush-promises.ts +7 -0
- package/src/testing/glob-with-memfs.ts +25 -0
- package/src/testing/index.ts +5 -0
- package/src/testing/memfs.ts +28 -0
- package/src/testing/mock-logger.ts +42 -0
- package/src/testing/spy-on-constructor.ts +33 -0
- package/tests/caching/cache-manager.spec.ts +147 -0
- package/tests/caching/cache-test-class.ts +91 -0
- package/tests/caching/cache.decorator.spec.ts +259 -0
- package/tests/caching/invalidate-cache-test-class.ts +52 -0
- package/tests/caching/invalidate-cache.decorator.spec.ts +120 -0
- package/tests/caching/memoize-test-class.ts +99 -0
- package/tests/caching/memoize.decorator.spec.ts +203 -0
- package/tests/cli/command.model.spec.ts +91 -0
- package/tests/collections/merge-arrays.spec.ts +50 -0
- package/tests/collections/sum.spec.ts +86 -0
- package/tests/collections/unique-objects.spec.ts +233 -0
- package/tests/extensibility/extension.spec.ts +29 -0
- package/tests/extensibility/pipeline.spec.ts +379 -0
- package/tests/interop/detect-package-manager.spec.ts +70 -0
- package/tests/interop/npm.spec.ts +129 -0
- package/tests/interop/pnpm.spec.ts +30 -0
- package/tests/interop/shell.spec.ts +47 -0
- package/tests/interop/yarn.spec.ts +18 -0
- package/tests/io/find-file.spec.ts +188 -0
- package/tests/io/watch.real-fs.spec.ts +76 -0
- package/tests/io/watch.spec.ts +291 -0
- package/tests/mock-prototype.ts +12 -0
- package/tests/semver/semver.spec.ts +51 -0
- package/tests/system/decorator.spec.ts +250 -0
- package/tests/system/retry.decorator.spec.ts +57 -0
- package/LICENSE +0 -15
- package/commonjs/src/caching/cache-manager.js +0 -98
- package/commonjs/src/caching/cache.decorator.js +0 -69
- package/commonjs/src/caching/cache.js +0 -6
- package/commonjs/src/caching/index.js +0 -23
- package/commonjs/src/caching/invalidate-cache.decorator.js +0 -92
- package/commonjs/src/caching/map-cache.js +0 -39
- package/commonjs/src/caching/memoize.decorator.js +0 -36
- package/commonjs/src/collections/collections.js +0 -21
- package/commonjs/src/collections/find-duplicates.js +0 -35
- package/commonjs/src/collections/index.js +0 -52
- package/commonjs/src/collections/merge-arrays.js +0 -34
- package/commonjs/src/collections/sum.js +0 -63
- package/commonjs/src/collections/unique-objects.js +0 -39
- package/commonjs/src/composition/index.js +0 -4
- package/commonjs/src/configuration/configuration.types.js +0 -11
- package/commonjs/src/configuration/index.js +0 -18
- package/commonjs/src/extensibility/decorator-factory-base.js +0 -22
- package/commonjs/src/extensibility/decorator-factory.js +0 -31
- package/commonjs/src/extensibility/extension.js +0 -37
- package/commonjs/src/extensibility/index.js +0 -23
- package/commonjs/src/extensibility/mixwith.js +0 -36
- package/commonjs/src/extensibility/pipeline.js +0 -56
- package/commonjs/src/extensibility/step.js +0 -18
- package/commonjs/src/io/copy-file.js +0 -25
- package/commonjs/src/io/delete-file.js +0 -21
- package/commonjs/src/io/directory-exists.js +0 -24
- package/commonjs/src/io/file-exists.js +0 -19
- package/commonjs/src/io/index.js +0 -66
- package/commonjs/src/io/io.js +0 -25
- package/commonjs/src/io/read-file.js +0 -39
- package/commonjs/src/io/remove-dir.js +0 -22
- package/commonjs/src/io/types/directory.type.js +0 -4
- package/commonjs/src/io/types/file.js +0 -28
- package/commonjs/src/io/types/index.js +0 -19
- package/commonjs/src/io/url-to-path.js +0 -33
- package/commonjs/src/io/write-file.js +0 -30
- package/commonjs/src/objects/deep-merge.js +0 -67
- package/commonjs/src/objects/index.js +0 -11
- package/commonjs/src/reflection/index.js +0 -20
- package/commonjs/src/reflection/types/index.js +0 -18
- package/commonjs/src/reflection/types/reflection.types.js +0 -26
- package/commonjs/src/reflection/utilities.js +0 -118
- package/commonjs/src/system/camel-case.js +0 -13
- package/commonjs/src/system/debounce.js +0 -19
- package/commonjs/src/system/decorator.js +0 -46
- package/commonjs/src/system/environment.js +0 -23
- package/commonjs/src/system/function.types.js +0 -18
- package/commonjs/src/system/index.js +0 -24
- package/commonjs/src/system/retry.decorator.js +0 -40
- package/commonjs/src/system/sleep.js +0 -13
- package/commonjs/src/system/type.utils.js +0 -4
- package/es6/src/caching/cache-manager.js +0 -82
- package/es6/src/caching/cache.decorator.js +0 -51
- package/es6/src/caching/cache.js +0 -3
- package/es6/src/caching/invalidate-cache.decorator.js +0 -71
- package/es6/src/caching/map-cache.js +0 -35
- package/es6/src/caching/memoize.decorator.js +0 -27
- package/es6/src/collections/find-duplicates.js +0 -17
- package/es6/src/collections/merge-arrays.js +0 -16
- package/es6/src/collections/sum.js +0 -45
- package/es6/src/collections/unique-objects.js +0 -21
- package/es6/src/composition/index.js +0 -1
- package/es6/src/configuration/configuration.types.js +0 -1
- package/es6/src/extensibility/decorator-factory.js +0 -21
- package/es6/src/extensibility/extension.js +0 -27
- package/es6/src/extensibility/mixwith.js +0 -26
- package/es6/src/extensibility/pipeline.js +0 -46
- package/es6/src/extensibility/step.js +0 -16
- package/es6/src/io/copy-file.js +0 -10
- package/es6/src/io/delete-file.js +0 -6
- package/es6/src/io/directory-exists.js +0 -9
- package/es6/src/io/file-exists.js +0 -9
- package/es6/src/io/read-file.js +0 -13
- package/es6/src/io/remove-dir.js +0 -7
- package/es6/src/io/types/directory.type.js +0 -1
- package/es6/src/io/types/file.js +0 -18
- package/es6/src/io/url-to-path.js +0 -15
- package/es6/src/io/write-file.js +0 -15
- package/es6/src/objects/deep-merge.js +0 -57
- package/es6/src/reflection/types/reflection.types.js +0 -8
- package/es6/src/reflection/utilities.js +0 -74
- package/es6/src/system/camel-case.js +0 -3
- package/es6/src/system/debounce.js +0 -9
- package/es6/src/system/decorator.js +0 -30
- package/es6/src/system/environment.js +0 -5
- package/es6/src/system/function.types.js +0 -26
- package/es6/src/system/retry.decorator.js +0 -30
- package/es6/src/system/sleep.js +0 -3
- package/es6/src/system/type.utils.js +0 -1
- package/types/src/caching/cache-manager.d.ts +0 -59
- package/types/src/caching/cache.d.ts +0 -11
- package/types/src/caching/cache.decorator.d.ts +0 -18
- package/types/src/caching/index.d.ts +0 -6
- package/types/src/caching/invalidate-cache.decorator.d.ts +0 -17
- package/types/src/caching/map-cache.d.ts +0 -23
- package/types/src/caching/memoize.decorator.d.ts +0 -16
- package/types/src/collections/collections.d.ts +0 -4
- package/types/src/collections/find-duplicates.d.ts +0 -2
- package/types/src/collections/index.d.ts +0 -1
- package/types/src/collections/merge-arrays.d.ts +0 -2
- package/types/src/collections/sum.d.ts +0 -4
- package/types/src/collections/unique-objects.d.ts +0 -2
- package/types/src/composition/index.d.ts +0 -37
- package/types/src/configuration/configuration.types.d.ts +0 -10
- package/types/src/configuration/index.d.ts +0 -1
- package/types/src/extensibility/decorator-factory-base.d.ts +0 -39
- package/types/src/extensibility/decorator-factory.d.ts +0 -19
- package/types/src/extensibility/extension.d.ts +0 -9
- package/types/src/extensibility/index.d.ts +0 -6
- package/types/src/extensibility/mixwith.d.ts +0 -6
- package/types/src/extensibility/pipeline.d.ts +0 -12
- package/types/src/io/copy-file.d.ts +0 -4
- package/types/src/io/delete-file.d.ts +0 -1
- package/types/src/io/directory-exists.d.ts +0 -1
- package/types/src/io/file-exists.d.ts +0 -1
- package/types/src/io/index.d.ts +0 -2
- package/types/src/io/io.d.ts +0 -8
- package/types/src/io/read-file.d.ts +0 -4
- package/types/src/io/remove-dir.d.ts +0 -5
- package/types/src/io/types/directory.type.d.ts +0 -4
- package/types/src/io/types/file.d.ts +0 -20
- package/types/src/io/types/index.d.ts +0 -2
- package/types/src/io/url-to-path.d.ts +0 -2
- package/types/src/io/write-file.d.ts +0 -5
- package/types/src/objects/deep-merge.d.ts +0 -41
- package/types/src/objects/index.d.ts +0 -1
- package/types/src/reflection/index.d.ts +0 -3
- package/types/src/reflection/types/index.d.ts +0 -1
- package/types/src/reflection/types/reflection.types.d.ts +0 -21
- package/types/src/reflection/utilities.d.ts +0 -27
- package/types/src/system/camel-case.d.ts +0 -1
- package/types/src/system/debounce.d.ts +0 -1
- package/types/src/system/decorator.d.ts +0 -15
- package/types/src/system/environment.d.ts +0 -6
- package/types/src/system/index.d.ts +0 -7
- package/types/src/system/retry.decorator.d.ts +0 -6
- package/types/src/system/sleep.d.ts +0 -1
- package/types/src/system/type.utils.d.ts +0 -1
- /package/{es6/src/collections/collections.js → src/collections/collections.ts} +0 -0
- /package/{es6/src/collections/index.js → src/collections/index.ts} +0 -0
- /package/{es6/src/configuration/index.js → src/configuration/index.ts} +0 -0
- /package/{es6/src/extensibility/index.js → src/extensibility/index.ts} +0 -0
- /package/{es6/src/io/index.js → src/io/index.ts} +0 -0
- /package/{es6/src/io/types/index.js → src/io/types/index.ts} +0 -0
- /package/{es6/src/objects/index.js → src/objects/index.ts} +0 -0
- /package/{es6/src/reflection/types/index.js → src/reflection/types/index.ts} +0 -0
- /package/{es6/src/system/index.js → src/system/index.ts} +0 -0
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
_export_star(require("./find-duplicates.js"), exports);
|
|
6
|
-
_export_star(require("./merge-arrays.js"), exports);
|
|
7
|
-
_export_star(require("./sum.js"), exports);
|
|
8
|
-
_export_star(require("./unique-objects.js"), exports);
|
|
9
|
-
function _export_star(from, to) {
|
|
10
|
-
Object.keys(from).forEach(function(k) {
|
|
11
|
-
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
12
|
-
Object.defineProperty(to, k, {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function() {
|
|
15
|
-
return from[k];
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
return from;
|
|
21
|
-
}
|
|
@@ -1,35 +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 findDuplicatesBy () {
|
|
13
|
-
return findDuplicatesBy;
|
|
14
|
-
},
|
|
15
|
-
get findDuplicatesByKey () {
|
|
16
|
-
return findDuplicatesByKey;
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
function findDuplicatesByKey(items, key) {
|
|
20
|
-
return findDuplicatesBy(items, (item)=>String(item[key]));
|
|
21
|
-
}
|
|
22
|
-
function findDuplicatesBy(items, selector) {
|
|
23
|
-
const groups = new Map();
|
|
24
|
-
for (const item of items){
|
|
25
|
-
const k = selector(item);
|
|
26
|
-
const existing = groups.get(k) ?? [];
|
|
27
|
-
groups.set(k, [
|
|
28
|
-
...existing,
|
|
29
|
-
item
|
|
30
|
-
]);
|
|
31
|
-
}
|
|
32
|
-
return [
|
|
33
|
-
...groups.entries()
|
|
34
|
-
].filter(([, group])=>group.length > 1);
|
|
35
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "collections", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return _collections;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const _collections = /*#__PURE__*/ _interop_require_wildcard(require("./collections.js"));
|
|
12
|
-
function _getRequireWildcardCache(nodeInterop) {
|
|
13
|
-
if (typeof WeakMap !== "function") return null;
|
|
14
|
-
var cacheBabelInterop = new WeakMap();
|
|
15
|
-
var cacheNodeInterop = new WeakMap();
|
|
16
|
-
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
17
|
-
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
18
|
-
})(nodeInterop);
|
|
19
|
-
}
|
|
20
|
-
function _interop_require_wildcard(obj, nodeInterop) {
|
|
21
|
-
if (!nodeInterop && obj && obj.__esModule) {
|
|
22
|
-
return obj;
|
|
23
|
-
}
|
|
24
|
-
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
25
|
-
return {
|
|
26
|
-
default: obj
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
var cache = _getRequireWildcardCache(nodeInterop);
|
|
30
|
-
if (cache && cache.has(obj)) {
|
|
31
|
-
return cache.get(obj);
|
|
32
|
-
}
|
|
33
|
-
var newObj = {
|
|
34
|
-
__proto__: null
|
|
35
|
-
};
|
|
36
|
-
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
37
|
-
for(var key in obj){
|
|
38
|
-
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
39
|
-
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
40
|
-
if (desc && (desc.get || desc.set)) {
|
|
41
|
-
Object.defineProperty(newObj, key, desc);
|
|
42
|
-
} else {
|
|
43
|
-
newObj[key] = obj[key];
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
newObj.default = obj;
|
|
48
|
-
if (cache) {
|
|
49
|
-
cache.set(obj, newObj);
|
|
50
|
-
}
|
|
51
|
-
return newObj;
|
|
52
|
-
}
|
|
@@ -1,34 +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 mergeBy () {
|
|
13
|
-
return mergeBy;
|
|
14
|
-
},
|
|
15
|
-
get mergeByKey () {
|
|
16
|
-
return mergeByKey;
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
function mergeByKey(first, second, key) {
|
|
20
|
-
return mergeBy(first, second, (item)=>String(item[key]));
|
|
21
|
-
}
|
|
22
|
-
function mergeBy(first, second, selector) {
|
|
23
|
-
// Second collection values win when keys collide.
|
|
24
|
-
const merged = [
|
|
25
|
-
...first,
|
|
26
|
-
...second
|
|
27
|
-
];
|
|
28
|
-
return [
|
|
29
|
-
...new Map(merged.map((item)=>[
|
|
30
|
-
selector(item),
|
|
31
|
-
item
|
|
32
|
-
])).values()
|
|
33
|
-
];
|
|
34
|
-
}
|
|
@@ -1,63 +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 sumBy () {
|
|
13
|
-
return sumBy;
|
|
14
|
-
},
|
|
15
|
-
get sumByKey () {
|
|
16
|
-
return sumByKey;
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
function sumByKey(objects, key) {
|
|
20
|
-
return sum(objects, key);
|
|
21
|
-
}
|
|
22
|
-
function sumBy(objects, key) {
|
|
23
|
-
return sum(objects, key);
|
|
24
|
-
}
|
|
25
|
-
function extractValueFromItem(item, key) {
|
|
26
|
-
if (typeof key === "function") {
|
|
27
|
-
const result = key(item);
|
|
28
|
-
return isNumericValue(result) ? result : 0;
|
|
29
|
-
}
|
|
30
|
-
const value = item?.[key];
|
|
31
|
-
return isNumericValue(value) ? value : 0;
|
|
32
|
-
}
|
|
33
|
-
function isNumericValue(value) {
|
|
34
|
-
return typeof value === "number" || typeof value === "bigint";
|
|
35
|
-
}
|
|
36
|
-
function determineSumType(firstValue) {
|
|
37
|
-
return typeof firstValue === "bigint" ? "bigint" : "number";
|
|
38
|
-
}
|
|
39
|
-
function getInitialSumValue(sumType) {
|
|
40
|
-
return sumType === "bigint" ? 0n : 0;
|
|
41
|
-
}
|
|
42
|
-
function addValues(total, value, sumType) {
|
|
43
|
-
if (sumType === "bigint") {
|
|
44
|
-
const totalBigInt = total;
|
|
45
|
-
const valueBigInt = typeof value === "bigint" ? value : BigInt(value);
|
|
46
|
-
return totalBigInt + valueBigInt;
|
|
47
|
-
}
|
|
48
|
-
const totalNumber = total;
|
|
49
|
-
const valueNumber = typeof value === "number" ? value : Number(value);
|
|
50
|
-
return totalNumber + valueNumber;
|
|
51
|
-
}
|
|
52
|
-
function sum(objects, key) {
|
|
53
|
-
if (objects.length === 0) {
|
|
54
|
-
return 0;
|
|
55
|
-
}
|
|
56
|
-
const firstValue = extractValueFromItem(objects[0], key);
|
|
57
|
-
const sumType = determineSumType(firstValue);
|
|
58
|
-
const initialValue = getInitialSumValue(sumType);
|
|
59
|
-
return objects.reduce((total, item)=>{
|
|
60
|
-
const value = extractValueFromItem(item, key);
|
|
61
|
-
return addValues(total, value, sumType);
|
|
62
|
-
}, initialValue);
|
|
63
|
-
}
|
|
@@ -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 uniqueObjectsBy () {
|
|
13
|
-
return uniqueObjectsBy;
|
|
14
|
-
},
|
|
15
|
-
get uniqueObjectsByKey () {
|
|
16
|
-
return uniqueObjectsByKey;
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
function uniqueObjectsByKey(objects, key) {
|
|
20
|
-
return uniqueObjects(objects, key);
|
|
21
|
-
}
|
|
22
|
-
function uniqueObjectsBy(objects, key) {
|
|
23
|
-
return uniqueObjects(objects, key);
|
|
24
|
-
}
|
|
25
|
-
function uniqueObjects(objects, key) {
|
|
26
|
-
const getKey = (key, item)=>{
|
|
27
|
-
if (typeof key === "function") {
|
|
28
|
-
return key(item);
|
|
29
|
-
}
|
|
30
|
-
return item != null ? item[key] : null;
|
|
31
|
-
};
|
|
32
|
-
const arrayUniqueByKey = [
|
|
33
|
-
...new Map(objects.map((item)=>[
|
|
34
|
-
getKey(key, item),
|
|
35
|
-
item
|
|
36
|
-
])).values()
|
|
37
|
-
];
|
|
38
|
-
return arrayUniqueByKey;
|
|
39
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "ConfigurationServiceToken", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return ConfigurationServiceToken;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const ConfigurationServiceToken = Symbol("IConfigurationService");
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
_export_star(require("./configuration.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,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "DecoratorFactoryBase", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return DecoratorFactoryBase;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
class DecoratorFactoryBase {
|
|
12
|
-
/**
|
|
13
|
-
* Utility method to check if we're currently in a test environment
|
|
14
|
-
*/ isTestEnvironment() {
|
|
15
|
-
return process.env.TEST === "true";
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Creates a no-op decorator that returns the original function unchanged
|
|
19
|
-
*/ createNoOpDecorator() {
|
|
20
|
-
return (_target, _propertyKey, descriptor)=>descriptor;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Decorator factory class that provides decorator methods which can be conditionally
|
|
3
|
-
* disabled during unit testing using the @ignoreInUnitTest decorator.
|
|
4
|
-
*
|
|
5
|
-
* Inspired by: https://jasonharper.blog/2018/03/13/decorate-the-decorator-to-exclude-in-unit-testing/
|
|
6
|
-
*/ /**
|
|
7
|
-
* Decorator that disables the decorated decorator method when TEST environment variable is true.
|
|
8
|
-
* If TEST=true, it returns a no-op decorator that simply returns the original function unchanged.
|
|
9
|
-
*/ "use strict";
|
|
10
|
-
Object.defineProperty(exports, "__esModule", {
|
|
11
|
-
value: true
|
|
12
|
-
});
|
|
13
|
-
Object.defineProperty(exports, "ignoreInUnitTest", {
|
|
14
|
-
enumerable: true,
|
|
15
|
-
get: function() {
|
|
16
|
-
return ignoreInUnitTest;
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
function ignoreInUnitTest(_target, _propertyKey, descriptor) {
|
|
20
|
-
const originalMethod = descriptor.value;
|
|
21
|
-
descriptor.value = function(...args) {
|
|
22
|
-
// Check if we're in a test environment
|
|
23
|
-
if (process.env.TEST === "true") {
|
|
24
|
-
// Return a no-op decorator that just returns the original function
|
|
25
|
-
return (originalFunction)=>originalFunction;
|
|
26
|
-
}
|
|
27
|
-
// Otherwise, apply the original decorator method
|
|
28
|
-
return originalMethod.apply(this, args);
|
|
29
|
-
};
|
|
30
|
-
return descriptor;
|
|
31
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "extension", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return extension;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
function extension(ctor, options) {
|
|
12
|
-
return (_target, propertyKey, descriptor)=>{
|
|
13
|
-
const originalFunction = descriptor.value;
|
|
14
|
-
ctor.prototype[propertyKey] = function(...args) {
|
|
15
|
-
return originalFunction.apply(this, [
|
|
16
|
-
this,
|
|
17
|
-
...args
|
|
18
|
-
]);
|
|
19
|
-
};
|
|
20
|
-
if (options?.static) {
|
|
21
|
-
Object.defineProperty(ctor, propertyKey, {
|
|
22
|
-
configurable: true,
|
|
23
|
-
writable: true,
|
|
24
|
-
value (...args) {
|
|
25
|
-
const receiver = singletonOf(ctor) ?? this;
|
|
26
|
-
return originalFunction.apply(receiver, [
|
|
27
|
-
receiver,
|
|
28
|
-
...args
|
|
29
|
-
]);
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
function singletonOf(ctor) {
|
|
36
|
-
return ctor.instance;
|
|
37
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
_export_star(require("./decorator-factory.js"), exports);
|
|
6
|
-
_export_star(require("./decorator-factory-base.js"), exports);
|
|
7
|
-
_export_star(require("./extension.js"), exports);
|
|
8
|
-
_export_star(require("./mixwith.js"), exports);
|
|
9
|
-
_export_star(require("./pipeline.js"), exports);
|
|
10
|
-
_export_star(require("./step.js"), exports);
|
|
11
|
-
function _export_star(from, to) {
|
|
12
|
-
Object.keys(from).forEach(function(k) {
|
|
13
|
-
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
14
|
-
Object.defineProperty(to, k, {
|
|
15
|
-
enumerable: true,
|
|
16
|
-
get: function() {
|
|
17
|
-
return from[k];
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
return from;
|
|
23
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "mixwith", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return mixwith;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const BLOCKED_PROTOTYPE_KEYS = new Set([
|
|
12
|
-
"constructor",
|
|
13
|
-
"prototype",
|
|
14
|
-
"name",
|
|
15
|
-
"length"
|
|
16
|
-
]);
|
|
17
|
-
function copyPrototypeProperties(target, source) {
|
|
18
|
-
for (const key of Reflect.ownKeys(source)){
|
|
19
|
-
if (typeof key === "string" && BLOCKED_PROTOTYPE_KEYS.has(key)) {
|
|
20
|
-
continue;
|
|
21
|
-
}
|
|
22
|
-
const descriptor = Object.getOwnPropertyDescriptor(source, key);
|
|
23
|
-
if (descriptor == null) {
|
|
24
|
-
continue;
|
|
25
|
-
}
|
|
26
|
-
Object.defineProperty(target, key, descriptor);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
function mixwith(...mixins) {
|
|
30
|
-
class Mixed {
|
|
31
|
-
}
|
|
32
|
-
for (const mixin of mixins){
|
|
33
|
-
copyPrototypeProperties(Mixed.prototype, mixin.prototype);
|
|
34
|
-
}
|
|
35
|
-
return Mixed;
|
|
36
|
-
}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "Pipeline", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return Pipeline;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const _scribe = require("@decohere/scribe");
|
|
12
|
-
class Pipeline {
|
|
13
|
-
stack;
|
|
14
|
-
logger = _scribe.scribe.logger(Pipeline.name);
|
|
15
|
-
currentStep;
|
|
16
|
-
constructor(...steps){
|
|
17
|
-
this.stack = steps;
|
|
18
|
-
}
|
|
19
|
-
[Symbol.dispose]() {
|
|
20
|
-
for (const [, step] of this.stack){
|
|
21
|
-
if (Symbol.dispose in step) {
|
|
22
|
-
step[Symbol.dispose]();
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
async start(context) {
|
|
27
|
-
const runStep = async (index)=>{
|
|
28
|
-
const [key, middleware, when] = this.stack[index] ?? [];
|
|
29
|
-
if (middleware == null) {
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
if (when != null && !when(context)) {
|
|
33
|
-
this.logger.info(`Skipping step ${key}`);
|
|
34
|
-
return await runStep(index + 1);
|
|
35
|
-
}
|
|
36
|
-
this.currentStep = key;
|
|
37
|
-
this.logger.info(`Running step ${key}`);
|
|
38
|
-
await middleware.run(context, async ()=>{
|
|
39
|
-
await runStep(index + 1);
|
|
40
|
-
});
|
|
41
|
-
};
|
|
42
|
-
try {
|
|
43
|
-
await runStep(0);
|
|
44
|
-
} catch (error) {
|
|
45
|
-
const step = this.currentStep ?? "unknown";
|
|
46
|
-
if (error instanceof Error) {
|
|
47
|
-
throw new Error(`Pipeline step '${step}' failed: ${error.message}`, {
|
|
48
|
-
cause: error
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
throw new Error(`Pipeline step '${step}' failed with non-Error value`, {
|
|
52
|
-
cause: error
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "Step", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return Step;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
class Step {
|
|
12
|
-
type;
|
|
13
|
-
when;
|
|
14
|
-
constructor(type, when){
|
|
15
|
-
this.type = type;
|
|
16
|
-
this.when = when;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "copyFile", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return copyFile;
|
|
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 copyFile(src, dest, options = {}) {
|
|
19
|
-
if (options.mkdir) {
|
|
20
|
-
await _promises.default.mkdir(_nodepath.default.dirname(dest), {
|
|
21
|
-
recursive: true
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
await _promises.default.copyFile(src, dest);
|
|
25
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "deleteFile", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return deleteFile;
|
|
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 deleteFile(filePath) {
|
|
18
|
-
return _promises.default.rm(filePath, {
|
|
19
|
-
force: true
|
|
20
|
-
});
|
|
21
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "directoryExists", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return directoryExists;
|
|
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 directoryExists(path) {
|
|
18
|
-
try {
|
|
19
|
-
await _promises.default.access(path);
|
|
20
|
-
return true;
|
|
21
|
-
} catch {
|
|
22
|
-
return false;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "fileExists", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return fileExists;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const _promises = require("node:fs/promises");
|
|
12
|
-
async function fileExists(path) {
|
|
13
|
-
try {
|
|
14
|
-
const stats = await (0, _promises.stat)(path);
|
|
15
|
-
return stats.isFile();
|
|
16
|
-
} catch {
|
|
17
|
-
return false;
|
|
18
|
-
}
|
|
19
|
-
}
|
package/commonjs/src/io/index.js
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "io", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return _io;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const _io = /*#__PURE__*/ _interop_require_wildcard(require("./io.js"));
|
|
12
|
-
_export_star(require("./types/index.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
|
-
}
|
|
26
|
-
function _getRequireWildcardCache(nodeInterop) {
|
|
27
|
-
if (typeof WeakMap !== "function") return null;
|
|
28
|
-
var cacheBabelInterop = new WeakMap();
|
|
29
|
-
var cacheNodeInterop = new WeakMap();
|
|
30
|
-
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
31
|
-
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
32
|
-
})(nodeInterop);
|
|
33
|
-
}
|
|
34
|
-
function _interop_require_wildcard(obj, nodeInterop) {
|
|
35
|
-
if (!nodeInterop && obj && obj.__esModule) {
|
|
36
|
-
return obj;
|
|
37
|
-
}
|
|
38
|
-
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
39
|
-
return {
|
|
40
|
-
default: obj
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
var cache = _getRequireWildcardCache(nodeInterop);
|
|
44
|
-
if (cache && cache.has(obj)) {
|
|
45
|
-
return cache.get(obj);
|
|
46
|
-
}
|
|
47
|
-
var newObj = {
|
|
48
|
-
__proto__: null
|
|
49
|
-
};
|
|
50
|
-
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
51
|
-
for(var key in obj){
|
|
52
|
-
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
53
|
-
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
54
|
-
if (desc && (desc.get || desc.set)) {
|
|
55
|
-
Object.defineProperty(newObj, key, desc);
|
|
56
|
-
} else {
|
|
57
|
-
newObj[key] = obj[key];
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
newObj.default = obj;
|
|
62
|
-
if (cache) {
|
|
63
|
-
cache.set(obj, newObj);
|
|
64
|
-
}
|
|
65
|
-
return newObj;
|
|
66
|
-
}
|