@thisisagile/easy 18.5.0 → 18.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-WGDPSWDJ.mjs → chunk-5N6Q7OXJ.mjs} +3 -3
- package/dist/{chunk-32JNUNPT.mjs → chunk-63DTRTSC.mjs} +4 -8
- package/dist/{chunk-32JNUNPT.mjs.map → chunk-63DTRTSC.mjs.map} +1 -1
- package/dist/{chunk-TRHTO2EW.mjs → chunk-6PMTGQVO.mjs} +3 -3
- package/dist/{chunk-6BH22YKR.mjs → chunk-6YTIRHPN.mjs} +4 -6
- package/dist/{chunk-6BH22YKR.mjs.map → chunk-6YTIRHPN.mjs.map} +1 -1
- package/dist/{chunk-QFOUEEXU.mjs → chunk-7TW4TBFN.mjs} +8 -16
- package/dist/{chunk-QFOUEEXU.mjs.map → chunk-7TW4TBFN.mjs.map} +1 -1
- package/dist/{chunk-PYDTZUGI.mjs → chunk-AYR4US3Z.mjs} +2 -2
- package/dist/{chunk-A4BT3ONR.mjs → chunk-B37NZCNW.mjs} +2 -2
- package/dist/{chunk-5KIMOU2T.mjs → chunk-FF3BNZ4H.mjs} +3 -5
- package/dist/{chunk-5KIMOU2T.mjs.map → chunk-FF3BNZ4H.mjs.map} +1 -1
- package/dist/{chunk-YYLTSI5X.mjs → chunk-FFD2T6YV.mjs} +2 -2
- package/dist/{chunk-FM3C7UJ5.mjs → chunk-FSWASMJZ.mjs} +2 -2
- package/dist/{chunk-TZMIA2P4.mjs → chunk-GF7JYGJU.mjs} +4 -8
- package/dist/{chunk-TZMIA2P4.mjs.map → chunk-GF7JYGJU.mjs.map} +1 -1
- package/dist/{chunk-XCE2MDKJ.mjs → chunk-GKQMIKIY.mjs} +2 -2
- package/dist/{chunk-NDOE57NV.mjs → chunk-IESVFCB3.mjs} +3 -3
- package/dist/{chunk-S5ROAZ73.mjs → chunk-IYUYA5OX.mjs} +5 -5
- package/dist/{chunk-G2NE3X2O.mjs → chunk-J5PB7ZVO.mjs} +4 -6
- package/dist/{chunk-G2NE3X2O.mjs.map → chunk-J5PB7ZVO.mjs.map} +1 -1
- package/dist/{chunk-YH6IWZDQ.mjs → chunk-JI7MC5EA.mjs} +2 -2
- package/dist/{chunk-6L2QT25T.mjs → chunk-JM6NAJQ3.mjs} +4 -6
- package/dist/{chunk-6L2QT25T.mjs.map → chunk-JM6NAJQ3.mjs.map} +1 -1
- package/dist/{chunk-7HAFUM6F.mjs → chunk-JNZUGKMO.mjs} +2 -2
- package/dist/{chunk-7JZYEQC2.mjs → chunk-KPXOQFEB.mjs} +4 -6
- package/dist/{chunk-7JZYEQC2.mjs.map → chunk-KPXOQFEB.mjs.map} +1 -1
- package/dist/{chunk-UK7JEY65.mjs → chunk-LHDTOERW.mjs} +3 -5
- package/dist/{chunk-UK7JEY65.mjs.map → chunk-LHDTOERW.mjs.map} +1 -1
- package/dist/{chunk-ZA3RBSEC.mjs → chunk-M2S4OLVZ.mjs} +2 -2
- package/dist/{chunk-WIBO6IZF.mjs → chunk-O4RWZGFC.mjs} +4 -6
- package/dist/{chunk-WIBO6IZF.mjs.map → chunk-O4RWZGFC.mjs.map} +1 -1
- package/dist/{chunk-GSRE7B6A.mjs → chunk-QBPSI5NM.mjs} +4 -4
- package/dist/{chunk-75E6U7F3.mjs → chunk-QLEGIYVU.mjs} +3 -5
- package/dist/{chunk-75E6U7F3.mjs.map → chunk-QLEGIYVU.mjs.map} +1 -1
- package/dist/{chunk-YP6UP7XS.mjs → chunk-QZPBFVZL.mjs} +2 -2
- package/dist/{chunk-DBQGZ42Q.mjs → chunk-RBJBAJOK.mjs} +2 -2
- package/dist/{chunk-3QWILJ53.mjs → chunk-RW4AKBCN.mjs} +3 -3
- package/dist/{chunk-M2YNFJCR.mjs → chunk-SBT3WGBP.mjs} +7 -7
- package/dist/{chunk-WSSDODHS.mjs → chunk-TNIG6FU2.mjs} +2 -2
- package/dist/{chunk-UL2QXFW5.mjs → chunk-TUO7ZPSP.mjs} +541 -105
- package/dist/chunk-TUO7ZPSP.mjs.map +1 -0
- package/dist/{chunk-KMYWEWV2.mjs → chunk-WOUH6UVC.mjs} +3 -5
- package/dist/{chunk-KMYWEWV2.mjs.map → chunk-WOUH6UVC.mjs.map} +1 -1
- package/dist/{chunk-CUA35DFA.mjs → chunk-XQJ5LQEQ.mjs} +2 -2
- package/dist/{chunk-NTNX63YD.mjs → chunk-ZBOGLMG2.mjs} +4 -4
- package/dist/{chunk-DRKXISJA.mjs → chunk-ZRH6FGUK.mjs} +4 -4
- package/dist/{chunk-LHBXZT7D.mjs → chunk-ZZ73Z5CU.mjs} +2 -2
- package/dist/data/Condition.mjs +6 -5
- package/dist/data/Database.mjs +5 -6
- package/dist/data/Field.mjs +6 -5
- package/dist/data/Field.mjs.map +1 -1
- package/dist/data/InMemoryGateway.mjs +5 -10
- package/dist/data/InMemoryGateway.mjs.map +1 -1
- package/dist/domain/Audit.mjs +9 -14
- package/dist/domain/Child.mjs +6 -11
- package/dist/domain/Child.mjs.map +1 -1
- package/dist/domain/DateTime.mjs +5 -10
- package/dist/domain/Entity.mjs +9 -14
- package/dist/domain/Entity.mjs.map +1 -1
- package/dist/domain/Repo.mjs +8 -15
- package/dist/domain/Repo.mjs.map +1 -1
- package/dist/domain/Struct.mjs +5 -10
- package/dist/domain/Typo.mjs +5 -10
- package/dist/domain/Typo.mjs.map +1 -1
- package/dist/http/CacheControl.mjs +7 -13
- package/dist/http/CacheControl.mjs.map +1 -1
- package/dist/http/ContentType.mjs +5 -6
- package/dist/http/HttpStatus.mjs +5 -6
- package/dist/http/HttpVerb.mjs +5 -6
- package/dist/http/LocalRequestStore.mjs +3 -8
- package/dist/http/LocalRequestStore.mjs.map +1 -1
- package/dist/http/RequestOptions.mjs +5 -10
- package/dist/http/RestResult.mjs +5 -10
- package/dist/http/toResponse.mjs +6 -11
- package/dist/index.js +528 -523
- package/dist/index.js.map +1 -1
- package/dist/process/App.mjs +4 -9
- package/dist/process/App.mjs.map +1 -1
- package/dist/process/Manage.mjs +5 -10
- package/dist/process/Manage.mjs.map +1 -1
- package/dist/process/Scope.mjs +4 -9
- package/dist/process/Search.mjs +5 -10
- package/dist/process/UseCase.mjs +6 -13
- package/dist/process/UseCase.mjs.map +1 -1
- package/dist/resources/Req.mjs +5 -10
- package/dist/resources/Req.mjs.map +1 -1
- package/dist/services/Api.mjs +13 -18
- package/dist/services/ApiGateway.mjs +16 -21
- package/dist/services/AxiosProvider.mjs +11 -16
- package/dist/services/MappedRouteGateway.mjs +19 -24
- package/dist/services/MappedRouteGateway.mjs.map +1 -1
- package/dist/services/RouteGateway.mjs +17 -22
- package/dist/services/ViewRouteGateway.mjs +19 -25
- package/dist/services/ViewRouteGateway.mjs.map +1 -1
- package/dist/sql/Column.mjs +4 -9
- package/dist/sql/Count.mjs +7 -5
- package/dist/sql/Delete.mjs +6 -4
- package/dist/sql/Insert.mjs +6 -4
- package/dist/sql/Select.mjs +6 -4
- package/dist/sql/SqlQuery.mjs +5 -3
- package/dist/sql/Table.mjs +14 -19
- package/dist/sql/Table.mjs.map +1 -1
- package/dist/sql/TableGateway.mjs +6 -12
- package/dist/sql/TableGateway.mjs.map +1 -1
- package/dist/sql/Update.mjs +6 -4
- package/dist/types/Cache.mjs +4 -4
- package/dist/types/CacheAge.mjs +5 -10
- package/dist/types/Case.mjs +3 -8
- package/dist/types/Context.mjs +3 -8
- package/dist/types/Enum.mjs +4 -5
- package/dist/types/Environment.mjs +4 -5
- package/dist/types/Environment.mjs.map +1 -1
- package/dist/types/Exception.mjs +3 -8
- package/dist/types/Gateway.mjs +4 -9
- package/dist/types/IsEqual.mjs +3 -9
- package/dist/types/Json.mjs +5 -4
- package/dist/types/List.mjs +4 -2
- package/dist/types/Meta.mjs +4 -4
- package/dist/types/Number.mjs +4 -9
- package/dist/types/Object.mjs +4 -3
- package/dist/types/PageList.mjs +4 -9
- package/dist/types/Parser.mjs +3 -8
- package/dist/types/Parser.mjs.map +1 -1
- package/dist/types/Repository.mjs +4 -9
- package/dist/types/Result.mjs +3 -8
- package/dist/types/Results.mjs +3 -8
- package/dist/types/Tag.mjs +4 -4
- package/dist/types/Template.mjs +3 -8
- package/dist/types/ToText.mjs +3 -8
- package/dist/types/Try.mjs +3 -8
- package/dist/types/Uri.mjs +6 -14
- package/dist/types/Uri.mjs.map +1 -1
- package/dist/utils/If.d.ts +2 -0
- package/dist/utils/If.mjs +6 -2
- package/dist/utils/Mapper.mjs +6 -6
- package/dist/utils/Period.mjs +5 -10
- package/dist/utils/Period.mjs.map +1 -1
- package/dist/utils/Promise.mjs +4 -4
- package/dist/utils/Seconds.mjs +5 -3
- package/dist/utils/Sentence.mjs +3 -8
- package/dist/utils/Sentence.mjs.map +1 -1
- package/dist/utils/View.mjs +6 -12
- package/dist/validation/Contraints.mjs +4 -9
- package/dist/validation/Validate.mjs +3 -8
- package/dist/validation/When.mjs +3 -8
- package/package.json +1 -1
- package/src/utils/If.ts +7 -0
- package/dist/chunk-FECVT2OY.mjs +0 -58
- package/dist/chunk-FECVT2OY.mjs.map +0 -1
- package/dist/chunk-GRMWYEPU.mjs +0 -37
- package/dist/chunk-GRMWYEPU.mjs.map +0 -1
- package/dist/chunk-HNW64DUZ.mjs +0 -54
- package/dist/chunk-HNW64DUZ.mjs.map +0 -1
- package/dist/chunk-MQ6KZAFL.mjs +0 -310
- package/dist/chunk-MQ6KZAFL.mjs.map +0 -1
- package/dist/chunk-NYKMQY5N.mjs +0 -23
- package/dist/chunk-NYKMQY5N.mjs.map +0 -1
- package/dist/chunk-UL2QXFW5.mjs.map +0 -1
- package/dist/chunk-VN4JL4JB.mjs +0 -68
- package/dist/chunk-VN4JL4JB.mjs.map +0 -1
- /package/dist/{chunk-WGDPSWDJ.mjs.map → chunk-5N6Q7OXJ.mjs.map} +0 -0
- /package/dist/{chunk-TRHTO2EW.mjs.map → chunk-6PMTGQVO.mjs.map} +0 -0
- /package/dist/{chunk-PYDTZUGI.mjs.map → chunk-AYR4US3Z.mjs.map} +0 -0
- /package/dist/{chunk-A4BT3ONR.mjs.map → chunk-B37NZCNW.mjs.map} +0 -0
- /package/dist/{chunk-YYLTSI5X.mjs.map → chunk-FFD2T6YV.mjs.map} +0 -0
- /package/dist/{chunk-FM3C7UJ5.mjs.map → chunk-FSWASMJZ.mjs.map} +0 -0
- /package/dist/{chunk-XCE2MDKJ.mjs.map → chunk-GKQMIKIY.mjs.map} +0 -0
- /package/dist/{chunk-NDOE57NV.mjs.map → chunk-IESVFCB3.mjs.map} +0 -0
- /package/dist/{chunk-S5ROAZ73.mjs.map → chunk-IYUYA5OX.mjs.map} +0 -0
- /package/dist/{chunk-YH6IWZDQ.mjs.map → chunk-JI7MC5EA.mjs.map} +0 -0
- /package/dist/{chunk-7HAFUM6F.mjs.map → chunk-JNZUGKMO.mjs.map} +0 -0
- /package/dist/{chunk-ZA3RBSEC.mjs.map → chunk-M2S4OLVZ.mjs.map} +0 -0
- /package/dist/{chunk-GSRE7B6A.mjs.map → chunk-QBPSI5NM.mjs.map} +0 -0
- /package/dist/{chunk-YP6UP7XS.mjs.map → chunk-QZPBFVZL.mjs.map} +0 -0
- /package/dist/{chunk-DBQGZ42Q.mjs.map → chunk-RBJBAJOK.mjs.map} +0 -0
- /package/dist/{chunk-3QWILJ53.mjs.map → chunk-RW4AKBCN.mjs.map} +0 -0
- /package/dist/{chunk-M2YNFJCR.mjs.map → chunk-SBT3WGBP.mjs.map} +0 -0
- /package/dist/{chunk-WSSDODHS.mjs.map → chunk-TNIG6FU2.mjs.map} +0 -0
- /package/dist/{chunk-CUA35DFA.mjs.map → chunk-XQJ5LQEQ.mjs.map} +0 -0
- /package/dist/{chunk-NTNX63YD.mjs.map → chunk-ZBOGLMG2.mjs.map} +0 -0
- /package/dist/{chunk-DRKXISJA.mjs.map → chunk-ZRH6FGUK.mjs.map} +0 -0
- /package/dist/{chunk-LHBXZT7D.mjs.map → chunk-ZZ73Z5CU.mjs.map} +0 -0
|
@@ -1,43 +1,34 @@
|
|
|
1
|
-
import {
|
|
2
|
-
reject,
|
|
3
|
-
resolve
|
|
4
|
-
} from "./chunk-HNW64DUZ.mjs";
|
|
5
1
|
import {
|
|
6
2
|
isValidatable
|
|
7
3
|
} from "./chunk-GPNPXSOF.mjs";
|
|
8
|
-
import {
|
|
9
|
-
isValue
|
|
10
|
-
} from "./chunk-AMS2ELWR.mjs";
|
|
11
|
-
import {
|
|
12
|
-
Enum,
|
|
13
|
-
isEnum
|
|
14
|
-
} from "./chunk-VN4JL4JB.mjs";
|
|
15
|
-
import {
|
|
16
|
-
meta
|
|
17
|
-
} from "./chunk-FECVT2OY.mjs";
|
|
18
|
-
import {
|
|
19
|
-
entries
|
|
20
|
-
} from "./chunk-GRMWYEPU.mjs";
|
|
21
|
-
import {
|
|
22
|
-
toList
|
|
23
|
-
} from "./chunk-MQ6KZAFL.mjs";
|
|
24
4
|
import {
|
|
25
5
|
toArray
|
|
26
6
|
} from "./chunk-QCPWEAAJ.mjs";
|
|
7
|
+
import {
|
|
8
|
+
traverse
|
|
9
|
+
} from "./chunk-SSROJBD5.mjs";
|
|
10
|
+
import {
|
|
11
|
+
isValue
|
|
12
|
+
} from "./chunk-AMS2ELWR.mjs";
|
|
27
13
|
import {
|
|
28
14
|
asString,
|
|
29
15
|
capitalize,
|
|
16
|
+
equals,
|
|
30
17
|
replaceAll
|
|
31
18
|
} from "./chunk-4Q6IHSAU.mjs";
|
|
32
19
|
import {
|
|
33
|
-
ofGet
|
|
20
|
+
ofGet,
|
|
21
|
+
ofProperty
|
|
34
22
|
} from "./chunk-SJGQU3OG.mjs";
|
|
35
23
|
import {
|
|
36
|
-
isA
|
|
24
|
+
isA,
|
|
25
|
+
isAn
|
|
37
26
|
} from "./chunk-MDIO6K2O.mjs";
|
|
38
27
|
import {
|
|
39
28
|
ofConstruct,
|
|
40
|
-
|
|
29
|
+
on,
|
|
30
|
+
toName,
|
|
31
|
+
use
|
|
41
32
|
} from "./chunk-QK5XGRSM.mjs";
|
|
42
33
|
import {
|
|
43
34
|
isArray,
|
|
@@ -46,9 +37,144 @@ import {
|
|
|
46
37
|
isFunction,
|
|
47
38
|
isIn,
|
|
48
39
|
isNotEmpty,
|
|
40
|
+
isObject,
|
|
41
|
+
isPresent,
|
|
49
42
|
isTrue
|
|
50
43
|
} from "./chunk-YYWOQNZQ.mjs";
|
|
51
44
|
|
|
45
|
+
// src/types/Object.ts
|
|
46
|
+
function entries(subject) {
|
|
47
|
+
return ifDefined(
|
|
48
|
+
subject,
|
|
49
|
+
() => toList([...Object.entries(subject), ...Object.entries(Object.getPrototypeOf(subject) ?? {})]),
|
|
50
|
+
() => toList()
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
function values(subject) {
|
|
54
|
+
return toList([...Object.values(subject), ...Object.values(Object.getPrototypeOf(subject) ?? {})]);
|
|
55
|
+
}
|
|
56
|
+
function keys(subject) {
|
|
57
|
+
return toList([...Object.keys(subject), ...Object.keys(Object.getPrototypeOf(subject) ?? {})]);
|
|
58
|
+
}
|
|
59
|
+
function extractKeys(obj, keys2) {
|
|
60
|
+
return keys2.filter((k) => k in obj).reduce(
|
|
61
|
+
(acc, key) => {
|
|
62
|
+
acc.keys[key] = obj[key];
|
|
63
|
+
delete acc[key];
|
|
64
|
+
return acc;
|
|
65
|
+
},
|
|
66
|
+
{ keys: {}, ...obj }
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// src/utils/Promise.ts
|
|
71
|
+
var resolve = (subject) => Promise.resolve(subject);
|
|
72
|
+
var reject = (e) => Promise.reject(e);
|
|
73
|
+
var tuple = {
|
|
74
|
+
2: (first, second) => Promise.all([first, second]),
|
|
75
|
+
3: (first, second, third) => Promise.all([first, second, third]),
|
|
76
|
+
4: (first, second, third, forth) => Promise.all([first, second, third, forth]),
|
|
77
|
+
5: (first, second, third, forth, fifth) => Promise.all([first, second, third, forth, fifth]),
|
|
78
|
+
all: (first, second) => Promise.all([first, Promise.all(second)]),
|
|
79
|
+
spread: (first, ...second) => Promise.all([first, Promise.all(toArray(second))]),
|
|
80
|
+
list: (list) => Promise.all([...list]).then(toList),
|
|
81
|
+
settled: (list) => Promise.allSettled([...list]).then((rs) => ({
|
|
82
|
+
fulfilled: toList(...rs.filter((r) => r.status === "fulfilled").map((r) => r.value)),
|
|
83
|
+
rejected: toList(...rs.filter((r) => r.status === "rejected").map((r) => asString(r.reason)))
|
|
84
|
+
})),
|
|
85
|
+
object: (obj) => use(keys(obj), (ks) => tuple.list(values(obj)).then((vs) => vs.reduce((acc, v, i) => on(acc, (a) => a[ks[i]] = v), {})))
|
|
86
|
+
};
|
|
87
|
+
var tuple2 = tuple[2];
|
|
88
|
+
var tuple3 = tuple[3];
|
|
89
|
+
var tuple4 = tuple[4];
|
|
90
|
+
var tuple5 = tuple[5];
|
|
91
|
+
var tupleO = tuple.object;
|
|
92
|
+
var settled = tuple.settled;
|
|
93
|
+
|
|
94
|
+
// src/types/Meta.ts
|
|
95
|
+
import "reflect-metadata";
|
|
96
|
+
var ClassMeta = class {
|
|
97
|
+
constructor(subject, data = (subject.prototype ?? subject).constructor) {
|
|
98
|
+
this.subject = subject;
|
|
99
|
+
this.data = data;
|
|
100
|
+
}
|
|
101
|
+
get = (key) => Reflect.getMetadata(key, this.data);
|
|
102
|
+
set = (key, value) => {
|
|
103
|
+
Reflect.defineMetadata(key, value, this.data);
|
|
104
|
+
return value;
|
|
105
|
+
};
|
|
106
|
+
entries = () => entries(this.subject);
|
|
107
|
+
parse = (f, options = {}) => {
|
|
108
|
+
const { initial = {}, skipUndefined = false } = options;
|
|
109
|
+
return this.entries().reduce((a, [k, val]) => use(f(val), (v) => isDefined(v) || !skipUndefined ? on(a, (a2) => a2[k] = v) : a), initial);
|
|
110
|
+
};
|
|
111
|
+
properties = (key) => toList([...Object.getOwnPropertyNames(this.subject), ...Object.getOwnPropertyNames(Object.getPrototypeOf(this.subject))]).map((p) => this.property(p)).filter((p) => key ? p.get(key) : p);
|
|
112
|
+
keys = (key) => this.properties().map((p) => p.get(key)).reduce((list, u) => u ? list.add(u) : list, toList());
|
|
113
|
+
values = () => values(this.subject);
|
|
114
|
+
property = (property) => new PropertyMeta(this.subject, property);
|
|
115
|
+
};
|
|
116
|
+
var PropertyMeta = class {
|
|
117
|
+
constructor(subject, property, data = Reflect.getMetadata(property, subject)) {
|
|
118
|
+
this.subject = subject;
|
|
119
|
+
this.property = property;
|
|
120
|
+
this.data = data;
|
|
121
|
+
}
|
|
122
|
+
get value() {
|
|
123
|
+
return this.subject[this.property];
|
|
124
|
+
}
|
|
125
|
+
get = (key) => isDefined(this.data) && isDefined(this.data[key]) ? this.data[key] : void 0;
|
|
126
|
+
set = (key, value) => {
|
|
127
|
+
Reflect.defineMetadata(this.property, { ...this.data, [key]: value }, this.subject);
|
|
128
|
+
return value;
|
|
129
|
+
};
|
|
130
|
+
};
|
|
131
|
+
var meta = (subject) => new ClassMeta(subject ?? {});
|
|
132
|
+
|
|
133
|
+
// src/types/Enum.ts
|
|
134
|
+
var isEnumConstructor = (c) => isFunction(c) && c.isEnum;
|
|
135
|
+
var Enum = class {
|
|
136
|
+
constructor(name, id = name.toLowerCase(), code = id.toString()) {
|
|
137
|
+
this.name = name;
|
|
138
|
+
this.id = id;
|
|
139
|
+
this.code = code;
|
|
140
|
+
}
|
|
141
|
+
static isEnum = true;
|
|
142
|
+
get isValid() {
|
|
143
|
+
return isDefined(this.id);
|
|
144
|
+
}
|
|
145
|
+
static all() {
|
|
146
|
+
return meta(this.allTuple()).values();
|
|
147
|
+
}
|
|
148
|
+
static filter(p, params) {
|
|
149
|
+
return this.all().filter(p, params);
|
|
150
|
+
}
|
|
151
|
+
static first(p, params) {
|
|
152
|
+
return this.all().first(p, params);
|
|
153
|
+
}
|
|
154
|
+
static byIds(ids = []) {
|
|
155
|
+
return toList(ids).mapDefined((id) => this.byId(id)).distinct();
|
|
156
|
+
}
|
|
157
|
+
static byId(id, alt) {
|
|
158
|
+
return this.allTuple()[id] ?? ofGet(alt);
|
|
159
|
+
}
|
|
160
|
+
static allTuple() {
|
|
161
|
+
return meta(this).get(`all-${this.name}`) ?? meta(this).set(`all-${this.name}`, meta(this).values().filter(isEnum).toObject("id"));
|
|
162
|
+
}
|
|
163
|
+
equals(other) {
|
|
164
|
+
return this.id === (isEnum(other) ? other.id : other);
|
|
165
|
+
}
|
|
166
|
+
isIn(...items) {
|
|
167
|
+
return items.some((i) => this.equals(i));
|
|
168
|
+
}
|
|
169
|
+
toJSON() {
|
|
170
|
+
return this.id;
|
|
171
|
+
}
|
|
172
|
+
toString() {
|
|
173
|
+
return this.id.toString();
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
var isEnum = (e) => isDefined(e) && e instanceof Enum && isAn(e, "name", "id", "code");
|
|
177
|
+
|
|
52
178
|
// src/types/Try.ts
|
|
53
179
|
var Try = class _Try {
|
|
54
180
|
is = {
|
|
@@ -288,6 +414,64 @@ function textValue(subject, prop) {
|
|
|
288
414
|
return p.splice(1).reduce((t, s) => (typeof t === "object" && t !== null ? t : text(t))?.[s], initial)?.toString() ?? "";
|
|
289
415
|
}
|
|
290
416
|
|
|
417
|
+
// src/types/Exception.ts
|
|
418
|
+
var Exception = class _Exception extends Enum {
|
|
419
|
+
constructor(message, id, reason) {
|
|
420
|
+
super(message, id ?? text(message).pascal.toString());
|
|
421
|
+
this.message = message;
|
|
422
|
+
this.reason = reason;
|
|
423
|
+
}
|
|
424
|
+
static AlreadyExists = new _Exception("Subject already exists");
|
|
425
|
+
static DoesNotExist = new _Exception("Does not exist");
|
|
426
|
+
static IsMissingId = new _Exception("Subject is missing an id");
|
|
427
|
+
static IsNotImplemented = new _Exception("Is not implemented");
|
|
428
|
+
static IsNotValid = new _Exception("Is not valid");
|
|
429
|
+
static Unknown = new _Exception("Unknown error");
|
|
430
|
+
static CouldNotExecute = (target) => new _Exception(`Could not execute ${target}.`, "CouldNotExecute");
|
|
431
|
+
static CouldNotValidate = (target) => new _Exception(`Could not validate ${target}.`, "CouldNotValidate");
|
|
432
|
+
static EnvironmentVariableNotFound = (variable) => new _Exception(`Environment variable ${text(variable).upper} could not be found.`, "EnvironmentVariableNotFound");
|
|
433
|
+
because = (reason) => new _Exception(this.message, this.id, reason);
|
|
434
|
+
};
|
|
435
|
+
var isException = (e, t) => e instanceof Exception && (isDefined(t) ? e.equals(asString(t)) : true);
|
|
436
|
+
var isDoesNotExist = (e) => e instanceof Exception && Exception.DoesNotExist.equals(e);
|
|
437
|
+
|
|
438
|
+
// src/validation/When.ts
|
|
439
|
+
var When = class _When {
|
|
440
|
+
constructor(subject, valid = true, results) {
|
|
441
|
+
this.subject = subject;
|
|
442
|
+
this.valid = valid;
|
|
443
|
+
this.results = results;
|
|
444
|
+
}
|
|
445
|
+
get not() {
|
|
446
|
+
return this.clone(!this.valid);
|
|
447
|
+
}
|
|
448
|
+
get and() {
|
|
449
|
+
return this.clone(this.valid);
|
|
450
|
+
}
|
|
451
|
+
get isDefined() {
|
|
452
|
+
return this.clone(this.valid === isDefined(this.subject));
|
|
453
|
+
}
|
|
454
|
+
get isEmpty() {
|
|
455
|
+
return this.clone(this.valid === isEmpty(this.subject));
|
|
456
|
+
}
|
|
457
|
+
get isTrue() {
|
|
458
|
+
return this.clone(this.valid === !!this.subject);
|
|
459
|
+
}
|
|
460
|
+
get isValid() {
|
|
461
|
+
this.results = validate(this.subject);
|
|
462
|
+
return this.clone(this.valid === this.results.isValid);
|
|
463
|
+
}
|
|
464
|
+
isInstance = (c) => this.clone(this.valid === this.subject instanceof c);
|
|
465
|
+
with = (pred) => this.clone(this.valid === ofGet(pred, this.subject));
|
|
466
|
+
contains = (property) => this.clone(this.valid === isDefined(ofGet(property, this.subject)));
|
|
467
|
+
in = (...items) => this.clone(this.valid === isIn(this.subject, toArray(...items)));
|
|
468
|
+
is = (item) => this.clone(this.valid === (this.subject === item));
|
|
469
|
+
reject = (error) => !this.valid ? resolve(this.subject) : reject(ofGet(error, this.subject) ?? this.results ?? Exception.Unknown);
|
|
470
|
+
recover = (f) => resolve(!this.valid ? this.subject : f(this.subject));
|
|
471
|
+
clone = (result = true) => new _When(this.subject, result, this.results);
|
|
472
|
+
};
|
|
473
|
+
var when = (subject) => new When(subject);
|
|
474
|
+
|
|
291
475
|
// src/types/Context.ts
|
|
292
476
|
var DotEnvContext = class {
|
|
293
477
|
domain = process.env.DOMAIN ?? "easy";
|
|
@@ -396,6 +580,29 @@ var Results = class {
|
|
|
396
580
|
var toResults = (...r) => new Results(...r);
|
|
397
581
|
var isResults = (r) => isDefined(r) && r instanceof Results;
|
|
398
582
|
|
|
583
|
+
// src/validation/Validate.ts
|
|
584
|
+
var asResults = (subject, template2, options = {}) => toResults(toResult(text(template2).parse(subject, options), toName(subject)));
|
|
585
|
+
var validators = (subject) => meta(subject).keys("constraint").reduce((list, vs) => list.add(vs), toList());
|
|
586
|
+
var runValidator = (v, subject) => {
|
|
587
|
+
try {
|
|
588
|
+
const actual = isFunction(subject[v.property]) ? subject[v.property]() : subject[v.property];
|
|
589
|
+
const constraint = v.constraint(actual);
|
|
590
|
+
return isResults(constraint) ? constraint : !constraint ? asResults(subject, v.text, {
|
|
591
|
+
...v,
|
|
592
|
+
actual
|
|
593
|
+
}) : toResults();
|
|
594
|
+
} catch (e) {
|
|
595
|
+
return asResults(subject, asString(e));
|
|
596
|
+
}
|
|
597
|
+
};
|
|
598
|
+
var constraints = (subject) => validators(subject).map((vs) => runValidator(vs, subject)).reduce((rs, r) => rs.add(...r.results), toResults());
|
|
599
|
+
var validate = (subject) => choose(subject).is.not.defined(
|
|
600
|
+
(s) => s,
|
|
601
|
+
() => toResults("Subject is not defined.")
|
|
602
|
+
).type(isEnum, (e) => e.isValid ? toResults() : asResults(e, "This is not a valid {typeof}.")).type(isValue, (v) => v.isValid ? toResults() : asResults(v, "This is not a valid {typeof}.")).type(isArray, (a) => a.map((i) => validate(i)).reduce((rs, r) => rs.add(...r.results), toResults())).type(isValidatable, (v) => constraints(v)).else(toResults());
|
|
603
|
+
var validateReject = (subject) => when(subject).not.isValid.reject();
|
|
604
|
+
var isValid = (t) => validate(t).isValid;
|
|
605
|
+
|
|
399
606
|
// src/types/Case.ts
|
|
400
607
|
var CaseBuilder = class {
|
|
401
608
|
constructor(v) {
|
|
@@ -496,88 +703,320 @@ var Found = class extends Case {
|
|
|
496
703
|
};
|
|
497
704
|
var choose = (value) => new CaseBuilder(value);
|
|
498
705
|
|
|
499
|
-
// src/
|
|
500
|
-
var
|
|
501
|
-
var
|
|
502
|
-
var
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
}) : toResults();
|
|
510
|
-
} catch (e) {
|
|
511
|
-
return asResults(subject, asString(e));
|
|
512
|
-
}
|
|
513
|
-
};
|
|
514
|
-
var constraints = (subject) => validators(subject).map((vs) => runValidator(vs, subject)).reduce((rs, r) => rs.add(...r.results), toResults());
|
|
515
|
-
var validate = (subject) => choose(subject).is.not.defined(
|
|
516
|
-
(s) => s,
|
|
517
|
-
() => toResults("Subject is not defined.")
|
|
518
|
-
).type(isEnum, (e) => e.isValid ? toResults() : asResults(e, "This is not a valid {typeof}.")).type(isValue, (v) => v.isValid ? toResults() : asResults(v, "This is not a valid {typeof}.")).type(isArray, (a) => a.map((i) => validate(i)).reduce((rs, r) => rs.add(...r.results), toResults())).type(isValidatable, (v) => constraints(v)).else(toResults());
|
|
519
|
-
var validateReject = (subject) => when(subject).not.isValid.reject();
|
|
520
|
-
var isValid = (t) => validate(t).isValid;
|
|
706
|
+
// src/types/IsEqual.ts
|
|
707
|
+
var isEqualArray = (one, another) => choose([one, another]).case(([o, a]) => !isArray(o) || !isArray(a), false).case(([o, a]) => o?.length !== a?.length, false).else(([o, a]) => !o.some((v, i) => !isEqual(v, a[i])));
|
|
708
|
+
var isEqualObject = (one, another) => choose([Object.keys(one), Object.keys(another)]).case(([keysO, keysA]) => keysO.length !== keysA.length, false).case(([keysO, keysA]) => keysO.some((k) => !keysA.includes(k)), false).case(([keysO]) => keysO.some((k) => !isEqual(one[k], another[k])), false).else(true);
|
|
709
|
+
var isEqual = (one, another) => choose([one, another]).case(([o, a]) => o === a, true).case(
|
|
710
|
+
([o, a]) => isArray(o) || isArray(a),
|
|
711
|
+
([o, a]) => isEqualArray(o, a)
|
|
712
|
+
).case(
|
|
713
|
+
([o, a]) => o == null || a == null || !isObject(o) && !isObject(a),
|
|
714
|
+
([o, a]) => o !== o && a !== a
|
|
715
|
+
).else(([o, a]) => isEqualObject(o, a));
|
|
521
716
|
|
|
522
|
-
// src/
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
717
|
+
// src/utils/If.ts
|
|
718
|
+
function ifTrue(o, f, alt) {
|
|
719
|
+
return isTrue(o) ? ofConstruct(f, o) : ofConstruct(alt, o);
|
|
720
|
+
}
|
|
721
|
+
function ifFalse(o, f, alt) {
|
|
722
|
+
return !isTrue(o) ? ofConstruct(f, o) : ofConstruct(alt, o);
|
|
723
|
+
}
|
|
724
|
+
function ifDefined(o, f, alt) {
|
|
725
|
+
return isDefined(o) ? ofConstruct(f, o) : ofConstruct(alt);
|
|
726
|
+
}
|
|
727
|
+
function ifNotEmpty(o, f = (o2) => o2, alt) {
|
|
728
|
+
return isNotEmpty(o) ? ofConstruct(f, o) : ofConstruct(alt, o);
|
|
729
|
+
}
|
|
730
|
+
function ifEqual(one, another, f, alt) {
|
|
731
|
+
return isEqual(one, another) ? ofConstruct(f) : ofConstruct(alt);
|
|
732
|
+
}
|
|
733
|
+
function ifEither(os, f = (o) => o, alt) {
|
|
734
|
+
return use(
|
|
735
|
+
toList(os).first((o) => isPresent(o)),
|
|
736
|
+
(o) => isDefined(o) ? ofConstruct(f, o) : ofConstruct(alt, o)
|
|
737
|
+
);
|
|
738
|
+
}
|
|
542
739
|
|
|
543
|
-
// src/
|
|
544
|
-
var
|
|
545
|
-
|
|
546
|
-
this.
|
|
547
|
-
this.valid = valid;
|
|
548
|
-
this.results = results;
|
|
740
|
+
// src/types/List.ts
|
|
741
|
+
var List8 = class extends Array {
|
|
742
|
+
get ids() {
|
|
743
|
+
return this.mapDefined((i) => i.id);
|
|
549
744
|
}
|
|
550
|
-
get
|
|
551
|
-
return this.
|
|
745
|
+
get indexed() {
|
|
746
|
+
return this.map((v, index) => ({ ...v, index }));
|
|
552
747
|
}
|
|
553
|
-
|
|
554
|
-
return this.
|
|
748
|
+
isSubSetOf(...items) {
|
|
749
|
+
return this.diff(items).length === 0;
|
|
555
750
|
}
|
|
556
|
-
|
|
557
|
-
return this.
|
|
751
|
+
isSuperSetOf(...items) {
|
|
752
|
+
return this.length > items.length && toList(...items).isSubSetOf(...this);
|
|
558
753
|
}
|
|
559
|
-
|
|
560
|
-
return this.
|
|
754
|
+
isIntersectingWith(...items) {
|
|
755
|
+
return this.intersect(items).length > 0;
|
|
561
756
|
}
|
|
562
|
-
|
|
563
|
-
return this.
|
|
757
|
+
isDisjointWith(...items) {
|
|
758
|
+
return !this.isIntersectingWith(...items);
|
|
564
759
|
}
|
|
565
|
-
|
|
566
|
-
this.
|
|
567
|
-
|
|
760
|
+
areEqual(...items) {
|
|
761
|
+
return this.isSubSetOf(...items) && toList(...items).isSubSetOf(...this);
|
|
762
|
+
}
|
|
763
|
+
asc(p) {
|
|
764
|
+
return toList(...this).sort((e1, e2) => ofProperty(e1, p) > ofProperty(e2, p) ? 1 : -1);
|
|
765
|
+
}
|
|
766
|
+
desc(p) {
|
|
767
|
+
return toList(...this).sort((e1, e2) => ofProperty(e1, p) < ofProperty(e2, p) ? 1 : -1);
|
|
768
|
+
}
|
|
769
|
+
first(p, params) {
|
|
770
|
+
return p ? this.find(p, params) : this[0];
|
|
771
|
+
}
|
|
772
|
+
firstValue(f, alt) {
|
|
773
|
+
return ifDefined(
|
|
774
|
+
this.first((t) => !!f(t)),
|
|
775
|
+
f,
|
|
776
|
+
(v) => ofGet(alt, v)
|
|
777
|
+
);
|
|
778
|
+
}
|
|
779
|
+
isFirst(value) {
|
|
780
|
+
return value === this.first();
|
|
781
|
+
}
|
|
782
|
+
next(p, params) {
|
|
783
|
+
return p ? this[this.findIndex(p, params) + 1] : this[0];
|
|
784
|
+
}
|
|
785
|
+
prev(p, params) {
|
|
786
|
+
return p ? this[this.findIndex(p, params) - 1] : this[0];
|
|
787
|
+
}
|
|
788
|
+
last(p, params) {
|
|
789
|
+
return p ? this.filter(p, params).last() : this[this.length - 1];
|
|
790
|
+
}
|
|
791
|
+
isLast(value) {
|
|
792
|
+
return value === this.last();
|
|
793
|
+
}
|
|
794
|
+
overlaps(...items) {
|
|
795
|
+
return toList(...items).some((i) => this.some((t) => i === t));
|
|
796
|
+
}
|
|
797
|
+
diff(others) {
|
|
798
|
+
return this.filter((i) => !others.includes(i));
|
|
799
|
+
}
|
|
800
|
+
diffByKey(others, key) {
|
|
801
|
+
return this.filter((i) => !others.some((o) => o[key] === i[key]));
|
|
802
|
+
}
|
|
803
|
+
symmetricDiff(others) {
|
|
804
|
+
return this.diff(others).concat(toList(...others).diff(this));
|
|
805
|
+
}
|
|
806
|
+
symmetricDiffByKey(others, key) {
|
|
807
|
+
return this.diffByKey(others, key).concat(toList(...others).diffByKey(this, key));
|
|
808
|
+
}
|
|
809
|
+
intersect(others) {
|
|
810
|
+
return this.filter((i) => others.includes(i));
|
|
811
|
+
}
|
|
812
|
+
intersectByKey(others, key) {
|
|
813
|
+
return this.filter((i) => others.some((o) => o[key] === i[key]));
|
|
814
|
+
}
|
|
815
|
+
intersectBy(others, f) {
|
|
816
|
+
return this.filter((i) => others.some((o) => f(i, o)));
|
|
817
|
+
}
|
|
818
|
+
accumulate(...keys2) {
|
|
819
|
+
return this.map((d, i, arr) => {
|
|
820
|
+
const acc = keys2.reduce((acc2, v) => {
|
|
821
|
+
acc2[v] = i === 0 ? d[v] : arr[i - 1][v] + d[v];
|
|
822
|
+
return acc2;
|
|
823
|
+
}, d);
|
|
824
|
+
arr[i] = acc;
|
|
825
|
+
return acc;
|
|
826
|
+
});
|
|
827
|
+
}
|
|
828
|
+
toJSON() {
|
|
829
|
+
return this.reduce((a, i) => {
|
|
830
|
+
a.push(JSON.parse(JSON.stringify(i ?? {})));
|
|
831
|
+
return a;
|
|
832
|
+
}, new Array());
|
|
833
|
+
}
|
|
834
|
+
map(f, params) {
|
|
835
|
+
return toList(super.map(f, params));
|
|
836
|
+
}
|
|
837
|
+
flatMap(f, params) {
|
|
838
|
+
return toList(super.flatMap(f, params));
|
|
839
|
+
}
|
|
840
|
+
mapDefined(f, params) {
|
|
841
|
+
return this.map(f, params).defined();
|
|
842
|
+
}
|
|
843
|
+
mapAsync(f) {
|
|
844
|
+
return Promise.all(super.map((e) => f(e))).then((a) => toList(a));
|
|
845
|
+
}
|
|
846
|
+
mapSerial(f) {
|
|
847
|
+
return super.reduce((p, item) => p.then((results) => on(results, async (r) => r.push(await f(item)))), Promise.resolve(toList()));
|
|
848
|
+
}
|
|
849
|
+
distinct() {
|
|
850
|
+
return this.filter((i, index) => this.indexOf(i) === index);
|
|
851
|
+
}
|
|
852
|
+
distinctByKey(key) {
|
|
853
|
+
const seen = /* @__PURE__ */ new Set();
|
|
854
|
+
return this.filter((item) => !seen.has(item[key]) && seen.add(item[key]));
|
|
855
|
+
}
|
|
856
|
+
distinctByValue() {
|
|
857
|
+
const seen = /* @__PURE__ */ new Set();
|
|
858
|
+
return this.filter((item) => !seen.has(JSON.stringify(item)) && seen.add(JSON.stringify(item)));
|
|
859
|
+
}
|
|
860
|
+
filter(p, params) {
|
|
861
|
+
return toList(super.filter(p, params));
|
|
862
|
+
}
|
|
863
|
+
sum(p) {
|
|
864
|
+
return this.reduce((sum, i) => sum + p(i), 0);
|
|
865
|
+
}
|
|
866
|
+
max(p) {
|
|
867
|
+
return this.desc(p).first();
|
|
868
|
+
}
|
|
869
|
+
min(p) {
|
|
870
|
+
return this.asc(p).first();
|
|
871
|
+
}
|
|
872
|
+
byId(id) {
|
|
873
|
+
return this.first((i) => equals(i.id, id));
|
|
874
|
+
}
|
|
875
|
+
byKey(key, value) {
|
|
876
|
+
return this.first((i) => i[key] == value);
|
|
877
|
+
}
|
|
878
|
+
add(...items) {
|
|
879
|
+
super.push(...toArray(...items));
|
|
880
|
+
return this;
|
|
881
|
+
}
|
|
882
|
+
concat(...items) {
|
|
883
|
+
return toList(super.concat(...items));
|
|
884
|
+
}
|
|
885
|
+
reverse() {
|
|
886
|
+
return toList(super.reverse());
|
|
887
|
+
}
|
|
888
|
+
splice(start, deleteCount, ...items) {
|
|
889
|
+
return toList(super.splice(start, deleteCount, ...items));
|
|
890
|
+
}
|
|
891
|
+
remove(item) {
|
|
892
|
+
const index = this.indexOf(item);
|
|
893
|
+
if (index > -1) {
|
|
894
|
+
this.splice(index, 1);
|
|
895
|
+
}
|
|
896
|
+
return this;
|
|
897
|
+
}
|
|
898
|
+
move(sourceId, destinationId) {
|
|
899
|
+
return this.moveOn("id", sourceId, destinationId);
|
|
900
|
+
}
|
|
901
|
+
moveOn(key, sourceId, destinationId) {
|
|
902
|
+
const source = this.findIndex((i) => equals(i[key], sourceId));
|
|
903
|
+
const dest = this.findIndex((i) => equals(i[key], destinationId));
|
|
904
|
+
return on(toList(...this), (r) => r.splice(dest, 0, ...r.splice(source, 1)));
|
|
905
|
+
}
|
|
906
|
+
replace(key, item) {
|
|
907
|
+
const index = this.findIndex((i) => i[key] === item?.[key]);
|
|
908
|
+
ifTrue(index != -1, () => this.splice(index, 1, item));
|
|
909
|
+
return this;
|
|
910
|
+
}
|
|
911
|
+
switch(item) {
|
|
912
|
+
return this.includes(item) ? this.remove(item) : this.add(item);
|
|
913
|
+
}
|
|
914
|
+
switchOn(item, on2) {
|
|
915
|
+
return use(
|
|
916
|
+
typeof on2 === "function" ? this.find(on2) : use(traverse(item, on2), (v) => this.find((i) => traverse(i, on2) === v)),
|
|
917
|
+
(i) => i ? this.remove(i) : this.add(item)
|
|
918
|
+
);
|
|
919
|
+
}
|
|
920
|
+
defined() {
|
|
921
|
+
return this.reduce((l, v) => isDefined(v) ? l.add(v) : l, toList());
|
|
922
|
+
}
|
|
923
|
+
toObject(key, options = {}) {
|
|
924
|
+
return this.reduce((o, i) => {
|
|
925
|
+
o[i[key]] = i;
|
|
926
|
+
if (options.deleteKey)
|
|
927
|
+
delete o[i[key]][key];
|
|
928
|
+
return o;
|
|
929
|
+
}, {});
|
|
930
|
+
}
|
|
931
|
+
toObjectList(key) {
|
|
932
|
+
return this.reduce(
|
|
933
|
+
(a, t) => {
|
|
934
|
+
const k = t[key];
|
|
935
|
+
a[k] = a[k] ?? toList();
|
|
936
|
+
a[k].push(t);
|
|
937
|
+
return a;
|
|
938
|
+
},
|
|
939
|
+
{}
|
|
940
|
+
);
|
|
941
|
+
}
|
|
942
|
+
orElse(...alt) {
|
|
943
|
+
return !isEmpty(this) ? this : !isEmpty(...alt) ? toList(...alt) : void 0;
|
|
944
|
+
}
|
|
945
|
+
weave(insertFrom, interval) {
|
|
946
|
+
for (let i = interval, n = 0; i <= this.length && n < insertFrom.length; i += interval + 1) {
|
|
947
|
+
this.splice(i, 0, insertFrom[n++]);
|
|
948
|
+
}
|
|
949
|
+
return this;
|
|
950
|
+
}
|
|
951
|
+
slice(start, end) {
|
|
952
|
+
return toList(super.slice(start, end));
|
|
953
|
+
}
|
|
954
|
+
none(p) {
|
|
955
|
+
return !this.some(p);
|
|
956
|
+
}
|
|
957
|
+
chunk(chunkSize) {
|
|
958
|
+
return this.reduce((acc, _, index) => index % chunkSize === 0 ? on(acc, (a) => a.push(this.slice(index, index + chunkSize))) : acc, toList());
|
|
959
|
+
}
|
|
960
|
+
//we needed to add U because of a Typescript issue with generics
|
|
961
|
+
update(p, val) {
|
|
962
|
+
return this.map((v, i, a) => p(v, i, a) ? ofGet(val, v, i, a) : v);
|
|
963
|
+
}
|
|
964
|
+
updateFirst(p, val) {
|
|
965
|
+
const index = this.findIndex(p);
|
|
966
|
+
return this.update((t, i) => p(t, i, this) && i == index, val);
|
|
967
|
+
}
|
|
968
|
+
updateFirstById(id, val) {
|
|
969
|
+
return this.updateFirst((i) => equals(i?.id, id), val);
|
|
970
|
+
}
|
|
971
|
+
updateById(id, val) {
|
|
972
|
+
return this.update((i) => equals(i?.id, id), val);
|
|
973
|
+
}
|
|
974
|
+
groupBy(by) {
|
|
975
|
+
return toList(
|
|
976
|
+
Array.from(this.reduce((m, v, i, a) => use(by(v, i, a), (key) => m.set(key, (m.get(key) ?? toList()).add(v))), /* @__PURE__ */ new Map()).values())
|
|
977
|
+
);
|
|
568
978
|
}
|
|
569
|
-
isInstance = (c) => this.clone(this.valid === this.subject instanceof c);
|
|
570
|
-
with = (pred) => this.clone(this.valid === ofGet(pred, this.subject));
|
|
571
|
-
contains = (property) => this.clone(this.valid === isDefined(ofGet(property, this.subject)));
|
|
572
|
-
in = (...items) => this.clone(this.valid === isIn(this.subject, toArray(...items)));
|
|
573
|
-
is = (item) => this.clone(this.valid === (this.subject === item));
|
|
574
|
-
reject = (error) => !this.valid ? resolve(this.subject) : reject(ofGet(error, this.subject) ?? this.results ?? Exception.Unknown);
|
|
575
|
-
recover = (f) => resolve(!this.valid ? this.subject : f(this.subject));
|
|
576
|
-
clone = (result = true) => new _When(this.subject, result, this.results);
|
|
577
979
|
};
|
|
578
|
-
var
|
|
980
|
+
var toList = (...items) => new List8().add(...items);
|
|
981
|
+
var isList = (l) => isDefined(l) && isArray(l) && isA(l, "first", "last", "asc", "desc");
|
|
982
|
+
var asList = (c, items = []) => toList(toArray(items).map((i) => new c(i)));
|
|
983
|
+
var maxValue = (l, key) => l.desc(key).first()?.[key];
|
|
984
|
+
var minValue = (l, key) => l.asc(key).first()?.[key];
|
|
579
985
|
|
|
580
986
|
export {
|
|
987
|
+
List8 as List,
|
|
988
|
+
toList,
|
|
989
|
+
isList,
|
|
990
|
+
asList,
|
|
991
|
+
maxValue,
|
|
992
|
+
minValue,
|
|
993
|
+
entries,
|
|
994
|
+
values,
|
|
995
|
+
keys,
|
|
996
|
+
extractKeys,
|
|
997
|
+
resolve,
|
|
998
|
+
reject,
|
|
999
|
+
tuple,
|
|
1000
|
+
tuple2,
|
|
1001
|
+
tuple3,
|
|
1002
|
+
tuple4,
|
|
1003
|
+
tuple5,
|
|
1004
|
+
tupleO,
|
|
1005
|
+
settled,
|
|
1006
|
+
meta,
|
|
1007
|
+
isEnumConstructor,
|
|
1008
|
+
Enum,
|
|
1009
|
+
isEnum,
|
|
1010
|
+
Try,
|
|
1011
|
+
tryTo,
|
|
1012
|
+
Template,
|
|
1013
|
+
template,
|
|
1014
|
+
ToText,
|
|
1015
|
+
text,
|
|
1016
|
+
textValue,
|
|
1017
|
+
Exception,
|
|
1018
|
+
isException,
|
|
1019
|
+
isDoesNotExist,
|
|
581
1020
|
When,
|
|
582
1021
|
when,
|
|
583
1022
|
DotEnvContext,
|
|
@@ -590,20 +1029,17 @@ export {
|
|
|
590
1029
|
Results,
|
|
591
1030
|
toResults,
|
|
592
1031
|
isResults,
|
|
593
|
-
choose,
|
|
594
1032
|
asResults,
|
|
595
1033
|
validate,
|
|
596
1034
|
validateReject,
|
|
597
1035
|
isValid,
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
isException,
|
|
607
|
-
isDoesNotExist
|
|
1036
|
+
choose,
|
|
1037
|
+
isEqual,
|
|
1038
|
+
ifTrue,
|
|
1039
|
+
ifFalse,
|
|
1040
|
+
ifDefined,
|
|
1041
|
+
ifNotEmpty,
|
|
1042
|
+
ifEqual,
|
|
1043
|
+
ifEither
|
|
608
1044
|
};
|
|
609
|
-
//# sourceMappingURL=chunk-
|
|
1045
|
+
//# sourceMappingURL=chunk-TUO7ZPSP.mjs.map
|