@duplojs/utils 1.2.18 → 1.2.19
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/dist/array/every.cjs +6 -3
- package/dist/array/every.d.ts +4 -3
- package/dist/array/every.mjs +6 -3
- package/dist/array/fill/all.d.ts +2 -2
- package/dist/array/filter.cjs +6 -3
- package/dist/array/filter.d.ts +6 -5
- package/dist/array/filter.mjs +6 -3
- package/dist/array/flatMap.cjs +6 -3
- package/dist/array/flatMap.d.ts +4 -3
- package/dist/array/flatMap.mjs +6 -3
- package/dist/array/index.cjs +11 -10
- package/dist/array/index.d.ts +2 -0
- package/dist/array/index.mjs +4 -4
- package/dist/array/insert.cjs +12 -0
- package/dist/array/insert.d.ts +2 -0
- package/dist/array/insert.mjs +10 -0
- package/dist/array/isLastIndex.cjs +12 -0
- package/dist/array/isLastIndex.d.ts +2 -0
- package/dist/array/isLastIndex.mjs +10 -0
- package/dist/array/map.cjs +6 -3
- package/dist/array/map.d.ts +4 -3
- package/dist/array/map.mjs +6 -3
- package/dist/array/push.cjs +3 -3
- package/dist/array/push.d.ts +2 -2
- package/dist/array/push.mjs +3 -3
- package/dist/array/reduce.cjs +22 -9
- package/dist/array/reduce.d.ts +7 -4
- package/dist/array/reduce.mjs +22 -10
- package/dist/array/reduceRight.cjs +7 -10
- package/dist/array/reduceRight.d.ts +2 -2
- package/dist/array/reduceRight.mjs +7 -10
- package/dist/array/some.cjs +6 -3
- package/dist/array/some.d.ts +4 -3
- package/dist/array/some.mjs +6 -3
- package/dist/array/types/ArrayCoalescing.d.ts +1 -1
- package/dist/clean/constraint/base.cjs +77 -0
- package/dist/clean/constraint/base.d.ts +36 -0
- package/dist/clean/constraint/base.mjs +72 -0
- package/dist/{array/sort → clean/constraint/defaultConstraint}/index.d.ts +0 -1
- package/dist/clean/constraint/defaultConstraint/number.cjs +15 -0
- package/dist/clean/constraint/defaultConstraint/number.d.ts +8 -0
- package/dist/clean/constraint/defaultConstraint/number.mjs +11 -0
- package/dist/clean/constraint/defaultConstraint/string.cjs +12 -0
- package/dist/clean/constraint/defaultConstraint/string.d.ts +6 -0
- package/dist/clean/constraint/defaultConstraint/string.mjs +9 -0
- package/dist/clean/constraint/index.d.ts +2 -0
- package/dist/clean/entity.cjs +125 -0
- package/dist/clean/entity.d.ts +74 -0
- package/dist/clean/entity.mjs +121 -0
- package/dist/clean/flag.cjs +26 -0
- package/dist/clean/flag.d.ts +16 -0
- package/dist/clean/flag.mjs +23 -0
- package/dist/clean/index.cjs +84 -0
- package/dist/clean/index.d.ts +8 -0
- package/dist/clean/index.mjs +29 -0
- package/dist/clean/kind.cjs +9 -0
- package/dist/clean/kind.d.ts +1 -0
- package/dist/clean/kind.mjs +7 -0
- package/dist/clean/newType.cjs +91 -0
- package/dist/clean/newType.d.ts +38 -0
- package/dist/clean/newType.mjs +86 -0
- package/dist/clean/primitive/base.cjs +72 -0
- package/dist/clean/primitive/base.d.ts +36 -0
- package/dist/clean/primitive/base.mjs +64 -0
- package/dist/clean/primitive/index.d.ts +2 -0
- package/dist/clean/primitive/operations/date/dateGreaterThan.cjs +15 -0
- package/dist/clean/primitive/operations/date/dateGreaterThan.d.ts +4 -0
- package/dist/clean/primitive/operations/date/dateGreaterThan.mjs +13 -0
- package/dist/clean/primitive/operations/date/dateLessThan.cjs +15 -0
- package/dist/clean/primitive/operations/date/dateLessThan.d.ts +4 -0
- package/dist/clean/primitive/operations/date/dateLessThan.mjs +13 -0
- package/dist/clean/primitive/operations/date/dateMax.cjs +15 -0
- package/dist/clean/primitive/operations/date/dateMax.d.ts +5 -0
- package/dist/clean/primitive/operations/date/dateMax.mjs +13 -0
- package/dist/clean/primitive/operations/date/dateMin.cjs +15 -0
- package/dist/clean/primitive/operations/date/dateMin.d.ts +5 -0
- package/dist/clean/primitive/operations/date/dateMin.mjs +13 -0
- package/dist/clean/primitive/operations/date/index.d.ts +8 -0
- package/dist/clean/primitive/operations/equal.cjs +14 -0
- package/dist/clean/primitive/operations/equal.d.ts +4 -0
- package/dist/clean/primitive/operations/equal.mjs +12 -0
- package/dist/clean/primitive/operations/index.d.ts +5 -0
- package/dist/clean/primitive/operations/number/add.cjs +15 -0
- package/dist/clean/primitive/operations/number/add.d.ts +3 -0
- package/dist/clean/primitive/operations/number/add.mjs +13 -0
- package/dist/clean/primitive/operations/number/divide.cjs +15 -0
- package/dist/clean/primitive/operations/number/divide.d.ts +3 -0
- package/dist/clean/primitive/operations/number/divide.mjs +13 -0
- package/dist/clean/primitive/operations/number/greaterThan.cjs +14 -0
- package/dist/clean/primitive/operations/number/greaterThan.d.ts +3 -0
- package/dist/clean/primitive/operations/number/greaterThan.mjs +12 -0
- package/dist/clean/primitive/operations/number/index.d.ts +8 -0
- package/dist/clean/primitive/operations/number/lessThan.cjs +14 -0
- package/dist/clean/primitive/operations/number/lessThan.d.ts +3 -0
- package/dist/clean/primitive/operations/number/lessThan.mjs +12 -0
- package/dist/clean/primitive/operations/number/max.cjs +10 -0
- package/dist/clean/primitive/operations/number/max.d.ts +3 -0
- package/dist/clean/primitive/operations/number/max.mjs +8 -0
- package/dist/clean/primitive/operations/number/min.cjs +10 -0
- package/dist/clean/primitive/operations/number/min.d.ts +3 -0
- package/dist/clean/primitive/operations/number/min.mjs +8 -0
- package/dist/clean/primitive/operations/number/multiply.cjs +15 -0
- package/dist/clean/primitive/operations/number/multiply.d.ts +3 -0
- package/dist/clean/primitive/operations/number/multiply.mjs +13 -0
- package/dist/clean/primitive/operations/number/subtract.cjs +15 -0
- package/dist/clean/primitive/operations/number/subtract.d.ts +3 -0
- package/dist/clean/primitive/operations/number/subtract.mjs +13 -0
- package/dist/clean/primitive/operations/sort.cjs +35 -0
- package/dist/clean/primitive/operations/sort.d.ts +9 -0
- package/dist/clean/primitive/operations/sort.mjs +33 -0
- package/dist/clean/primitive/operations/string/concat.cjs +16 -0
- package/dist/clean/primitive/operations/string/concat.d.ts +3 -0
- package/dist/clean/primitive/operations/string/concat.mjs +14 -0
- package/dist/clean/primitive/operations/string/index.d.ts +5 -0
- package/dist/clean/primitive/operations/string/length.cjs +10 -0
- package/dist/clean/primitive/operations/string/length.d.ts +2 -0
- package/dist/clean/primitive/operations/string/length.mjs +8 -0
- package/dist/clean/primitive/operations/string/lengthEqual.cjs +14 -0
- package/dist/clean/primitive/operations/string/lengthEqual.d.ts +3 -0
- package/dist/clean/primitive/operations/string/lengthEqual.mjs +12 -0
- package/dist/clean/primitive/operations/string/lengthGreaterThan.cjs +14 -0
- package/dist/clean/primitive/operations/string/lengthGreaterThan.d.ts +3 -0
- package/dist/clean/primitive/operations/string/lengthGreaterThan.mjs +12 -0
- package/dist/clean/primitive/operations/string/lengthLessThan.cjs +14 -0
- package/dist/clean/primitive/operations/string/lengthLessThan.d.ts +3 -0
- package/dist/clean/primitive/operations/string/lengthLessThan.mjs +12 -0
- package/dist/clean/repository.cjs +15 -0
- package/dist/clean/repository.d.ts +8 -0
- package/dist/clean/repository.mjs +12 -0
- package/dist/clean/useCase.cjs +25 -0
- package/dist/clean/useCase.d.ts +23 -0
- package/dist/clean/useCase.mjs +21 -0
- package/dist/common/index.d.ts +0 -1
- package/dist/common/kind.d.ts +1 -0
- package/dist/common/types/index.d.ts +1 -0
- package/dist/common/types/sortType.d.ts +1 -0
- package/dist/common/unwrap.d.ts +1 -2
- package/dist/dataParser/base.d.ts +5 -4
- package/dist/dataParser/baseExtended.d.ts +1 -1
- package/dist/dataParser/extended/number.cjs +3 -0
- package/dist/dataParser/extended/number.d.ts +3 -0
- package/dist/dataParser/extended/number.mjs +3 -0
- package/dist/dataParser/extended/object.cjs +8 -13
- package/dist/dataParser/extended/object.d.ts +2 -0
- package/dist/dataParser/extended/object.mjs +8 -13
- package/dist/dataParser/identifier.d.ts +40 -40
- package/dist/dataParser/index.cjs +4 -0
- package/dist/dataParser/index.mjs +2 -0
- package/dist/dataParser/parsers/array/index.cjs +2 -2
- package/dist/dataParser/parsers/array/index.mjs +2 -2
- package/dist/dataParser/parsers/literal.d.ts +1 -1
- package/dist/dataParser/parsers/object/index.cjs +3 -3
- package/dist/dataParser/parsers/object/index.d.ts +2 -0
- package/dist/dataParser/parsers/object/index.mjs +3 -3
- package/dist/dataParser/parsers/object/partial.cjs +20 -0
- package/dist/dataParser/parsers/object/partial.d.ts +14 -0
- package/dist/dataParser/parsers/object/partial.mjs +18 -0
- package/dist/dataParser/parsers/object/required.cjs +20 -0
- package/dist/dataParser/parsers/object/required.d.ts +10 -0
- package/dist/dataParser/parsers/object/required.mjs +18 -0
- package/dist/dataParser/parsers/record/index.cjs +2 -2
- package/dist/dataParser/parsers/record/index.mjs +2 -2
- package/dist/dataParser/parsers/refine.d.ts +1 -1
- package/dist/dataParser/parsers/tuple.cjs +2 -2
- package/dist/dataParser/parsers/tuple.mjs +2 -2
- package/dist/date/index.cjs +8 -0
- package/dist/date/index.d.ts +4 -0
- package/dist/date/index.mjs +4 -0
- package/dist/date/is.cjs +9 -0
- package/dist/date/is.d.ts +2 -0
- package/dist/date/is.mjs +7 -0
- package/dist/date/max.cjs +10 -0
- package/dist/date/max.d.ts +3 -0
- package/dist/date/max.mjs +8 -0
- package/dist/date/min.cjs +10 -0
- package/dist/date/min.d.ts +3 -0
- package/dist/date/min.mjs +8 -0
- package/dist/date/sort.cjs +20 -0
- package/dist/date/sort.d.ts +4 -0
- package/dist/date/sort.mjs +18 -0
- package/dist/generator/reduce.cjs +2 -6
- package/dist/generator/reduce.d.ts +1 -0
- package/dist/generator/reduce.mjs +2 -6
- package/dist/index.cjs +3 -2
- package/dist/index.d.ts +2 -0
- package/dist/index.mjs +3 -1
- package/dist/number/index.cjs +2 -0
- package/dist/number/index.d.ts +1 -0
- package/dist/number/index.mjs +1 -0
- package/dist/number/max.cjs +2 -7
- package/dist/number/max.d.ts +2 -2
- package/dist/number/max.mjs +2 -7
- package/dist/number/min.cjs +2 -7
- package/dist/number/min.d.ts +2 -2
- package/dist/number/min.mjs +2 -7
- package/dist/number/sort.cjs +14 -0
- package/dist/number/sort.d.ts +3 -0
- package/dist/number/sort.mjs +12 -0
- package/dist/pattern/when.d.ts +5 -5
- package/dist/string/index.cjs +2 -0
- package/dist/string/index.d.ts +1 -0
- package/dist/string/index.mjs +1 -0
- package/dist/{array/sort/string.cjs → string/sort.cjs} +6 -6
- package/dist/string/sort.d.ts +3 -0
- package/dist/{array/sort/string.mjs → string/sort.mjs} +6 -6
- package/package.json +7 -2
- package/dist/array/sort/number.cjs +0 -14
- package/dist/array/sort/number.d.ts +0 -4
- package/dist/array/sort/number.mjs +0 -12
- package/dist/array/sort/string.d.ts +0 -4
- package/dist/common/not.cjs +0 -12
- package/dist/common/not.d.ts +0 -2
- package/dist/common/not.mjs +0 -10
- /package/dist/array/{sort/default.cjs → sort.cjs} +0 -0
- /package/dist/array/{sort/default.d.ts → sort.d.ts} +0 -0
- /package/dist/array/{sort/default.mjs → sort.mjs} +0 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { unwrap } from '../../../common/unwrap.mjs';
|
|
2
|
+
import { sort as sort$1 } from '../../../number/sort.mjs';
|
|
3
|
+
import { wrapValue } from '../../../common/wrapValue.mjs';
|
|
4
|
+
import { is } from '../../../date/is.mjs';
|
|
5
|
+
import { sort as sort$2 } from '../../../date/sort.mjs';
|
|
6
|
+
import { sort as sort$3 } from '../../../string/sort.mjs';
|
|
7
|
+
|
|
8
|
+
function sort(...args) {
|
|
9
|
+
if (args.length === 1) {
|
|
10
|
+
const [type] = args;
|
|
11
|
+
return ((input) => sort(input, type));
|
|
12
|
+
}
|
|
13
|
+
const [input, type] = args;
|
|
14
|
+
const rawArray = input.map(unwrap);
|
|
15
|
+
const first = rawArray.at(0);
|
|
16
|
+
if (!first) {
|
|
17
|
+
return [];
|
|
18
|
+
}
|
|
19
|
+
if (typeof first === "number") {
|
|
20
|
+
return sort$1(rawArray, type)
|
|
21
|
+
.map(wrapValue);
|
|
22
|
+
}
|
|
23
|
+
else if (is(first)) {
|
|
24
|
+
return sort$2(rawArray, type)
|
|
25
|
+
.map(wrapValue);
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
return sort$3(rawArray, type)
|
|
29
|
+
.map(wrapValue);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export { sort };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var wrapValue = require('../../../../common/wrapValue.cjs');
|
|
4
|
+
var unwrap = require('../../../../common/unwrap.cjs');
|
|
5
|
+
|
|
6
|
+
function concat(...args) {
|
|
7
|
+
if (args.length === 1) {
|
|
8
|
+
const [text] = args;
|
|
9
|
+
return (input) => concat(input, text);
|
|
10
|
+
}
|
|
11
|
+
const [input, ...textsRest] = args;
|
|
12
|
+
return wrapValue.wrapValue(unwrap.unwrap(input)
|
|
13
|
+
.concat(...textsRest.map(unwrap.unwrap)));
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
exports.concat = concat;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { wrapValue } from '../../../../common/wrapValue.mjs';
|
|
2
|
+
import { unwrap } from '../../../../common/unwrap.mjs';
|
|
3
|
+
|
|
4
|
+
function concat(...args) {
|
|
5
|
+
if (args.length === 1) {
|
|
6
|
+
const [text] = args;
|
|
7
|
+
return (input) => concat(input, text);
|
|
8
|
+
}
|
|
9
|
+
const [input, ...textsRest] = args;
|
|
10
|
+
return wrapValue(unwrap(input)
|
|
11
|
+
.concat(...textsRest.map(unwrap)));
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export { concat };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var wrapValue = require('../../../../common/wrapValue.cjs');
|
|
4
|
+
var unwrap = require('../../../../common/unwrap.cjs');
|
|
5
|
+
|
|
6
|
+
function length(primitive) {
|
|
7
|
+
return wrapValue.wrapValue(unwrap.unwrap(primitive).length);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
exports.length = length;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var unwrap = require('../../../../common/unwrap.cjs');
|
|
4
|
+
|
|
5
|
+
function lengthEqual(...args) {
|
|
6
|
+
if (args.length === 1) {
|
|
7
|
+
const [length] = args;
|
|
8
|
+
return (primitive) => lengthEqual(primitive, length);
|
|
9
|
+
}
|
|
10
|
+
const [primitive, length] = args;
|
|
11
|
+
return unwrap.unwrap(primitive).length === unwrap.unwrap(length);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
exports.lengthEqual = lengthEqual;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { unwrap } from '../../../../common/unwrap.mjs';
|
|
2
|
+
|
|
3
|
+
function lengthEqual(...args) {
|
|
4
|
+
if (args.length === 1) {
|
|
5
|
+
const [length] = args;
|
|
6
|
+
return (primitive) => lengthEqual(primitive, length);
|
|
7
|
+
}
|
|
8
|
+
const [primitive, length] = args;
|
|
9
|
+
return unwrap(primitive).length === unwrap(length);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export { lengthEqual };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var unwrap = require('../../../../common/unwrap.cjs');
|
|
4
|
+
|
|
5
|
+
function lengthGreaterThan(...args) {
|
|
6
|
+
if (args.length === 1) {
|
|
7
|
+
const [length] = args;
|
|
8
|
+
return (primitive) => lengthGreaterThan(primitive, length);
|
|
9
|
+
}
|
|
10
|
+
const [primitive, length] = args;
|
|
11
|
+
return unwrap.unwrap(primitive).length > unwrap.unwrap(length);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
exports.lengthGreaterThan = lengthGreaterThan;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { unwrap } from '../../../../common/unwrap.mjs';
|
|
2
|
+
|
|
3
|
+
function lengthGreaterThan(...args) {
|
|
4
|
+
if (args.length === 1) {
|
|
5
|
+
const [length] = args;
|
|
6
|
+
return (primitive) => lengthGreaterThan(primitive, length);
|
|
7
|
+
}
|
|
8
|
+
const [primitive, length] = args;
|
|
9
|
+
return unwrap(primitive).length > unwrap(length);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export { lengthGreaterThan };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var unwrap = require('../../../../common/unwrap.cjs');
|
|
4
|
+
|
|
5
|
+
function lengthLessThan(...args) {
|
|
6
|
+
if (args.length === 1) {
|
|
7
|
+
const [length] = args;
|
|
8
|
+
return (primitive) => lengthLessThan(primitive, length);
|
|
9
|
+
}
|
|
10
|
+
const [primitive, length] = args;
|
|
11
|
+
return unwrap.unwrap(primitive).length < unwrap.unwrap(length);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
exports.lengthLessThan = lengthLessThan;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { unwrap } from '../../../../common/unwrap.mjs';
|
|
2
|
+
|
|
3
|
+
function lengthLessThan(...args) {
|
|
4
|
+
if (args.length === 1) {
|
|
5
|
+
const [length] = args;
|
|
6
|
+
return (primitive) => lengthLessThan(primitive, length);
|
|
7
|
+
}
|
|
8
|
+
const [primitive, length] = args;
|
|
9
|
+
return unwrap(primitive).length < unwrap(length);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export { lengthLessThan };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var kind = require('./kind.cjs');
|
|
4
|
+
|
|
5
|
+
const repositoryHandlerKind = kind.createCleanKind("repository-handler");
|
|
6
|
+
function createRepository() {
|
|
7
|
+
return repositoryHandlerKind.setTo({
|
|
8
|
+
createImplementation(implementation) {
|
|
9
|
+
return implementation;
|
|
10
|
+
},
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
exports.createRepository = createRepository;
|
|
15
|
+
exports.repositoryHandlerKind = repositoryHandlerKind;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type AnyFunction, type Kind } from "../common";
|
|
2
|
+
export declare const repositoryHandlerKind: import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsClean/repository-handler", unknown>>;
|
|
3
|
+
export interface RepositoryHandler<GenericRepository extends object = object> extends Kind<typeof repositoryHandlerKind.definition> {
|
|
4
|
+
createImplementation(implementation: {
|
|
5
|
+
[Prop in keyof GenericRepository]: GenericRepository[Prop] extends AnyFunction ? AnyFunction<Parameters<GenericRepository[Prop]>, ReturnType<GenericRepository[Prop]>> : GenericRepository[Prop];
|
|
6
|
+
}): GenericRepository;
|
|
7
|
+
}
|
|
8
|
+
export declare function createRepository<GenericRepository extends object>(): RepositoryHandler<GenericRepository>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { createCleanKind } from './kind.mjs';
|
|
2
|
+
|
|
3
|
+
const repositoryHandlerKind = createCleanKind("repository-handler");
|
|
4
|
+
function createRepository() {
|
|
5
|
+
return repositoryHandlerKind.setTo({
|
|
6
|
+
createImplementation(implementation) {
|
|
7
|
+
return implementation;
|
|
8
|
+
},
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export { createRepository, repositoryHandlerKind };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var kind = require('./kind.cjs');
|
|
4
|
+
var pipe = require('../common/pipe.cjs');
|
|
5
|
+
var map = require('../array/map.cjs');
|
|
6
|
+
var entry = require('../object/entry.cjs');
|
|
7
|
+
var entries = require('../object/entries.cjs');
|
|
8
|
+
var fromEntries = require('../object/fromEntries.cjs');
|
|
9
|
+
|
|
10
|
+
const useCaseHandlerKind = kind.createCleanKind("use-case-handler");
|
|
11
|
+
function createUseCase(dependencies, getUseCase) {
|
|
12
|
+
return useCaseHandlerKind.setTo({
|
|
13
|
+
dependencies,
|
|
14
|
+
getUseCase: (repositories) => getUseCase(pipe.pipe(dependencies, entries.entries, map.map(([key, value]) => entry.entry(key, useCaseHandlerKind.has(value)
|
|
15
|
+
? value.getUseCase(repositories)
|
|
16
|
+
: repositories[key])), fromEntries.fromEntries)),
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
function useCaseInstances(useCases, repositories) {
|
|
20
|
+
return pipe.pipe(useCases, entries.entries, map.map(([key, useCase]) => entry.entry(key, useCase.getUseCase(repositories))), fromEntries.fromEntries);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
exports.createUseCase = createUseCase;
|
|
24
|
+
exports.useCaseHandlerKind = useCaseHandlerKind;
|
|
25
|
+
exports.useCaseInstances = useCaseInstances;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type ObjectEntry, type Kind, type SimplifyTopLevel, type UnionToIntersection } from "../common";
|
|
2
|
+
import { type RepositoryHandler } from "./repository";
|
|
3
|
+
export type UseCaseDependencies = Record<string, RepositoryHandler | UseCaseHandler>;
|
|
4
|
+
export type UseCaseDependenciesValue<GenericDependencies extends UseCaseDependencies> = SimplifyTopLevel<{
|
|
5
|
+
[Prop in keyof GenericDependencies]: GenericDependencies[Prop] extends RepositoryHandler ? ReturnType<GenericDependencies[Prop]["createImplementation"]> : GenericDependencies[Prop] extends UseCaseHandler ? ReturnType<GenericDependencies[Prop]["getUseCase"]> : never;
|
|
6
|
+
}>;
|
|
7
|
+
export type GetAllRepositories<GenericDependenciesValue extends UseCaseDependencies> = GenericDependenciesValue extends any ? ({
|
|
8
|
+
[Prop in keyof GenericDependenciesValue]: (GenericDependenciesValue[Prop] extends RepositoryHandler ? [
|
|
9
|
+
Prop,
|
|
10
|
+
ReturnType<GenericDependenciesValue[Prop]["createImplementation"]>
|
|
11
|
+
] : GenericDependenciesValue[Prop] extends UseCaseHandler ? GetAllRepositories<GenericDependenciesValue[Prop]["dependencies"]> : never);
|
|
12
|
+
})[keyof GenericDependenciesValue] : never;
|
|
13
|
+
export declare const useCaseHandlerKind: import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsClean/use-case-handler", unknown>>;
|
|
14
|
+
export interface UseCaseHandler<GenericDependencies extends UseCaseDependencies = any, GenericUseCase extends (input: any) => any = any> extends Kind<typeof useCaseHandlerKind.definition> {
|
|
15
|
+
dependencies: GenericDependencies;
|
|
16
|
+
getUseCase(repositories: (GetAllRepositories<GenericDependencies> extends infer InferredEntriesDependenciesValue extends ObjectEntry ? {
|
|
17
|
+
[Entry in InferredEntriesDependenciesValue as InferredEntriesDependenciesValue[0]]: InferredEntriesDependenciesValue[1];
|
|
18
|
+
} : never)): GenericUseCase;
|
|
19
|
+
}
|
|
20
|
+
export declare function createUseCase<const GenericDependencies extends UseCaseDependencies, GenericUseCase extends (input: any) => any>(dependencies: GenericDependencies, getUseCase: (dependenciesValue: UseCaseDependenciesValue<GenericDependencies>) => GenericUseCase): UseCaseHandler<GenericDependencies, GenericUseCase>;
|
|
21
|
+
export declare function useCaseInstances<GenericUseCases extends Record<string, UseCaseHandler>>(useCases: GenericUseCases, repositories: SimplifyTopLevel<UnionToIntersection<{
|
|
22
|
+
[Prop in keyof GenericUseCases]: Parameters<GenericUseCases[Prop]["getUseCase"]>[0];
|
|
23
|
+
}[keyof GenericUseCases]>>): UseCaseDependenciesValue<GenericUseCases>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { createCleanKind } from './kind.mjs';
|
|
2
|
+
import { pipe } from '../common/pipe.mjs';
|
|
3
|
+
import { map } from '../array/map.mjs';
|
|
4
|
+
import { entry } from '../object/entry.mjs';
|
|
5
|
+
import { entries } from '../object/entries.mjs';
|
|
6
|
+
import { fromEntries } from '../object/fromEntries.mjs';
|
|
7
|
+
|
|
8
|
+
const useCaseHandlerKind = createCleanKind("use-case-handler");
|
|
9
|
+
function createUseCase(dependencies, getUseCase) {
|
|
10
|
+
return useCaseHandlerKind.setTo({
|
|
11
|
+
dependencies,
|
|
12
|
+
getUseCase: (repositories) => getUseCase(pipe(dependencies, entries, map(([key, value]) => entry(key, useCaseHandlerKind.has(value)
|
|
13
|
+
? value.getUseCase(repositories)
|
|
14
|
+
: repositories[key])), fromEntries)),
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
function useCaseInstances(useCases, repositories) {
|
|
18
|
+
return pipe(useCases, entries, map(([key, useCase]) => entry(key, useCase.getUseCase(repositories))), fromEntries);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export { createUseCase, useCaseHandlerKind, useCaseInstances };
|
package/dist/common/index.d.ts
CHANGED
package/dist/common/kind.d.ts
CHANGED
|
@@ -44,6 +44,7 @@ export interface ReservedKindNamespace {
|
|
|
44
44
|
DuplojsUtilsDataParser: true;
|
|
45
45
|
DuplojsUtilsBuilder: true;
|
|
46
46
|
DuplojsUtilsError: true;
|
|
47
|
+
DuplojsUtilsClean: true;
|
|
47
48
|
}
|
|
48
49
|
type ForbiddenKindNamespace<GenericValue extends string> = (ForbiddenKindCharacters<GenericValue> & ForbiddenString<GenericValue, GetPropsWithValue<ReservedKindNamespace, true>>);
|
|
49
50
|
export declare function createKindNamespace<GenericNamespace extends string>(namespace: GenericNamespace & ForbiddenKindNamespace<GenericNamespace>): <GenericName extends string, GenericKindValue extends unknown = unknown>(name: GenericName & ForbiddenKindCharacters<GenericName>) => KindHandler<KindDefinition<`@${GenericNamespace}/${GenericName}`, GenericKindValue>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type SortType = "ASC" | "DSC";
|
package/dist/common/unwrap.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import { type WrappedValue } from "./wrapValue";
|
|
2
|
-
import { type AnyValue } from "./types/anyValue";
|
|
3
2
|
export type Unwrap<GenericAnyValue extends unknown> = GenericAnyValue extends WrappedValue<infer inferredValue> ? inferredValue : GenericAnyValue;
|
|
4
|
-
export declare function unwrap<GenericValue extends
|
|
3
|
+
export declare function unwrap<const GenericValue extends unknown>(anyValue: GenericValue): Unwrap<GenericValue>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type GetKindHandler, type GetKindValue, type Kind, type KindHandler, type RemoveKind } from "../common";
|
|
2
2
|
import { SymbolDataParserErrorIssue, SymbolDataParserErrorPromiseIssue, type DataParserError } from "./error";
|
|
3
3
|
import * as DEither from "../either";
|
|
4
4
|
export declare const SymbolDataParserErrorLabel = "SymbolDataParserError";
|
|
@@ -8,10 +8,11 @@ export declare const checkerKind: KindHandler<import("../common").KindDefinition
|
|
|
8
8
|
export interface DataParserCheckerDefinition {
|
|
9
9
|
readonly errorMessage?: string;
|
|
10
10
|
}
|
|
11
|
-
export interface DataParserChecker<GenericDefinition extends DataParserCheckerDefinition = DataParserCheckerDefinition, GenericInput extends
|
|
11
|
+
export interface DataParserChecker<GenericDefinition extends DataParserCheckerDefinition = DataParserCheckerDefinition, GenericInput extends unknown = unknown> extends Kind<typeof checkerKind.definition, GenericInput> {
|
|
12
12
|
readonly definition: GenericDefinition;
|
|
13
13
|
exec(data: GenericInput, self: this): GenericInput | SymbolDataParserErrorIssue;
|
|
14
14
|
}
|
|
15
|
+
export type InputChecker<GenericDataParser extends DataParserChecker> = Parameters<GenericDataParser["exec"]>[0];
|
|
15
16
|
export declare function dataParserCheckerInit<GenericDataParserChecker extends DataParserChecker>(kind: Exclude<GetKindHandler<GenericDataParserChecker>, typeof checkerKind>, params: NoInfer<Omit<RemoveKind<GenericDataParserChecker>, "exec">>, exec: (...args: Parameters<GenericDataParserChecker["exec"]>) => GetKindValue<typeof checkerKind, GenericDataParserChecker> | SymbolDataParserErrorIssue): GenericDataParserChecker;
|
|
16
17
|
export declare const dataParserKind: KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/base", {
|
|
17
18
|
input: unknown;
|
|
@@ -19,7 +20,7 @@ export declare const dataParserKind: KindHandler<import("../common").KindDefinit
|
|
|
19
20
|
}>>;
|
|
20
21
|
export interface DataParserDefinition<GenericChecker extends DataParserChecker = DataParserChecker> {
|
|
21
22
|
readonly errorMessage?: string;
|
|
22
|
-
readonly checkers: readonly
|
|
23
|
+
readonly checkers: readonly GenericChecker[];
|
|
23
24
|
}
|
|
24
25
|
export interface DataParser<GenericDefinition extends DataParserDefinition = DataParserDefinition, GenericOutput extends unknown = unknown, GenericInput extends unknown = GenericOutput> extends Kind<typeof dataParserKind.definition, {
|
|
25
26
|
input: GenericInput;
|
|
@@ -39,7 +40,7 @@ interface DataParserInitExecParams<GenericDataParser extends DataParser> {
|
|
|
39
40
|
}
|
|
40
41
|
export declare function dataParserInit<GenericDataParser extends DataParser>(kind: Exclude<GetKindHandler<GenericDataParser>, typeof dataParserKind>, params: NoInfer<Omit<RemoveKind<GenericDataParser>, "parse" | "exec" | "asyncParse" | "asyncExec" | "addChecker" | "clone">>, exec: (DataParserInitExecParams<GenericDataParser> | DataParserInitExecParams<GenericDataParser>["sync"])): GenericDataParser;
|
|
41
42
|
export declare namespace dataParserInit {
|
|
42
|
-
var overrideHandler: import("../common").OverrideHandler<DataParser<DataParserDefinition<DataParserChecker<DataParserCheckerDefinition,
|
|
43
|
+
var overrideHandler: import("../common").OverrideHandler<DataParser<DataParserDefinition<DataParserChecker<DataParserCheckerDefinition, unknown>>, unknown, unknown>>;
|
|
43
44
|
}
|
|
44
45
|
export type Output<GenericDataParser extends DataParser> = GetKindValue<typeof dataParserKind, GenericDataParser>["output"];
|
|
45
46
|
export type Input<GenericDataParser extends DataParser> = GetKindValue<typeof dataParserKind, GenericDataParser>["input"];
|
|
@@ -48,6 +48,6 @@ export declare function dataParserExtendedInit<GenericDataParser extends DataPar
|
|
|
48
48
|
[Prop in Exclude<keyof GenericDataParserExtended, keyof (GenericDataParser & DataParserExtended)>]: GenericDataParserExtended[Prop] extends AnyFunction ? (self: GenericDataParserExtended, ...args: Parameters<GenericDataParserExtended[Prop]>) => ReturnType<GenericDataParserExtended[Prop]> : GenericDataParserExtended[Prop];
|
|
49
49
|
}>): GenericDataParserExtended;
|
|
50
50
|
export declare namespace dataParserExtendedInit {
|
|
51
|
-
var overrideHandler: import("../common").OverrideHandler<DataParserExtended<DataParserDefinition<import("./base").DataParserChecker<import("./base").DataParserCheckerDefinition,
|
|
51
|
+
var overrideHandler: import("../common").OverrideHandler<DataParserExtended<DataParserDefinition<import("./base").DataParserChecker<import("./base").DataParserCheckerDefinition, unknown>>, unknown, unknown>>;
|
|
52
52
|
}
|
|
53
53
|
export {};
|
|
@@ -15,6 +15,9 @@ function number(definition) {
|
|
|
15
15
|
max(self, max$1, definition) {
|
|
16
16
|
return self.addChecker(max.checkerNumberMax(max$1, definition));
|
|
17
17
|
},
|
|
18
|
+
int(self, definition) {
|
|
19
|
+
return self.addChecker(int$1.checkerInt(definition));
|
|
20
|
+
},
|
|
18
21
|
});
|
|
19
22
|
return number.overrideHandler.apply(self);
|
|
20
23
|
}
|
|
@@ -21,6 +21,9 @@ export interface DataParserNumberExtended<GenericDefinition extends dataParsers.
|
|
|
21
21
|
max(max: number, definition?: Partial<Omit<dataParsers.DataParserCheckerDefinitionNumberMax, "max">>): DataParserNumberExtended<AddCheckersToDefinition<GenericDefinition, [
|
|
22
22
|
dataParsers.DataParserCheckerNumberMax
|
|
23
23
|
]>>;
|
|
24
|
+
int(definition?: Partial<dataParsers.DataParserCheckerDefinitionInt>): DataParserNumberExtended<AddCheckersToDefinition<GenericDefinition, [
|
|
25
|
+
dataParsers.DataParserCheckerInt
|
|
26
|
+
]>>;
|
|
24
27
|
}
|
|
25
28
|
export declare function number<const GenericDefinition extends Partial<dataParsers.DataParserDefinitionNumber> = never>(definition?: GenericDefinition): DataParserNumberExtended<MergeDefinition<dataParsers.DataParserDefinitionNumber, NeverCoalescing<GenericDefinition, {}>>>;
|
|
26
29
|
export declare namespace number {
|
|
@@ -13,6 +13,9 @@ function number(definition) {
|
|
|
13
13
|
max(self, max, definition) {
|
|
14
14
|
return self.addChecker(checkerNumberMax(max, definition));
|
|
15
15
|
},
|
|
16
|
+
int(self, definition) {
|
|
17
|
+
return self.addChecker(checkerInt(definition));
|
|
18
|
+
},
|
|
16
19
|
});
|
|
17
20
|
return number.overrideHandler.apply(self);
|
|
18
21
|
}
|
|
@@ -2,23 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
var baseExtended = require('../baseExtended.cjs');
|
|
4
4
|
var index = require('../parsers/object/index.cjs');
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var entries = require('../../object/entries.cjs');
|
|
5
|
+
var required = require('../parsers/object/required.cjs');
|
|
6
|
+
var partial = require('../parsers/object/partial.cjs');
|
|
7
|
+
var pick = require('../parsers/object/pick.cjs');
|
|
8
|
+
var omit = require('../parsers/object/omit.cjs');
|
|
10
9
|
var override = require('../../common/override.cjs');
|
|
11
10
|
|
|
12
11
|
function object(shape, definition) {
|
|
13
12
|
const self = baseExtended.dataParserExtendedInit(index.object(shape, definition), {
|
|
14
|
-
omit: (self, omitObject, definition) =>
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
pick: (self, omitObject, definition) => {
|
|
19
|
-
const newShape = pipe.pipe(self.definition.shape, entries.entries, filter.filter(([key]) => isKeyof.isKeyof(key, omitObject)), fromEntries.fromEntries);
|
|
20
|
-
return object(newShape, definition);
|
|
21
|
-
},
|
|
13
|
+
omit: (self, omitObject, definition) => omit.omit(self, omitObject, definition),
|
|
14
|
+
pick: (self, pickObject, definition) => pick.pick(self, pickObject, definition),
|
|
15
|
+
partial: (self, definition) => partial.partial(self, definition),
|
|
16
|
+
required: (self, definition) => required.required(self, definition),
|
|
22
17
|
});
|
|
23
18
|
return object.overrideHandler.apply(self);
|
|
24
19
|
}
|
|
@@ -17,6 +17,8 @@ export interface DataParserObjectExtended<GenericDefinition extends dataParsers.
|
|
|
17
17
|
]>>;
|
|
18
18
|
omit<const GenericOmitObject extends Partial<Record<keyof GenericDefinition["shape"], true>>, const GenericSubDefinition extends Partial<Omit<dataParsers.DataParserDefinitionObject, "shape" | "optimizedShape">> = never>(omitObject: GenericOmitObject, definition?: GenericDefinition): ReturnType<typeof dataParsers.omit<dataParsers.DataParserObject<GenericDefinition>, GenericOmitObject, GenericSubDefinition>>;
|
|
19
19
|
pick<const GenericPickObject extends Partial<Record<keyof GenericDefinition["shape"], true>>, const GenericSubDefinition extends Partial<Omit<dataParsers.DataParserDefinitionObject, "shape" | "optimizedShape">> = never>(pickObject: GenericPickObject, definition?: GenericDefinition): ReturnType<typeof dataParsers.pick<dataParsers.DataParserObject<GenericDefinition>, GenericPickObject, GenericSubDefinition>>;
|
|
20
|
+
partial<const GenericSubDefinition extends Partial<Omit<dataParsers.DataParserDefinitionObject, "shape" | "optimizedShape">> = never>(definition?: GenericDefinition): ReturnType<typeof dataParsers.partial<dataParsers.DataParserObject<GenericDefinition>, GenericSubDefinition>>;
|
|
21
|
+
required<const GenericSubDefinition extends Partial<Omit<dataParsers.DataParserDefinitionObject, "shape" | "optimizedShape">> = never>(definition?: GenericDefinition): ReturnType<typeof dataParsers.required<dataParsers.DataParserObject<GenericDefinition>, GenericSubDefinition>>;
|
|
20
22
|
}
|
|
21
23
|
export declare function object<const GenericShape extends dataParsers.DataParserObjectShape, const GenericDefinition extends Partial<Omit<dataParsers.DataParserDefinitionObject, "shape">> = never>(shape: GenericShape, definition?: GenericDefinition): DataParserObjectExtended<MergeDefinition<dataParsers.DataParserDefinitionObject, NeverCoalescing<GenericDefinition, {}> & {
|
|
22
24
|
shape: GenericShape;
|
|
@@ -1,22 +1,17 @@
|
|
|
1
1
|
import { dataParserExtendedInit } from '../baseExtended.mjs';
|
|
2
2
|
import { object as object$1 } from '../parsers/object/index.mjs';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { entries } from '../../object/entries.mjs';
|
|
3
|
+
import { required } from '../parsers/object/required.mjs';
|
|
4
|
+
import { partial } from '../parsers/object/partial.mjs';
|
|
5
|
+
import { pick } from '../parsers/object/pick.mjs';
|
|
6
|
+
import { omit } from '../parsers/object/omit.mjs';
|
|
8
7
|
import { createOverride } from '../../common/override.mjs';
|
|
9
8
|
|
|
10
9
|
function object(shape, definition) {
|
|
11
10
|
const self = dataParserExtendedInit(object$1(shape, definition), {
|
|
12
|
-
omit: (self, omitObject, definition) =>
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
pick: (self, omitObject, definition) => {
|
|
17
|
-
const newShape = pipe(self.definition.shape, entries, filter(([key]) => isKeyof(key, omitObject)), fromEntries);
|
|
18
|
-
return object(newShape, definition);
|
|
19
|
-
},
|
|
11
|
+
omit: (self, omitObject, definition) => omit(self, omitObject, definition),
|
|
12
|
+
pick: (self, pickObject, definition) => pick(self, pickObject, definition),
|
|
13
|
+
partial: (self, definition) => partial(self, definition),
|
|
14
|
+
required: (self, definition) => required(self, definition),
|
|
20
15
|
});
|
|
21
16
|
return object.overrideHandler.apply(self);
|
|
22
17
|
}
|