@thisisagile/easy 14.2.0 → 14.2.3
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/domain/Child.d.ts +1 -1
- package/dist/domain/Child.js +3 -1
- package/dist/domain/Child.js.map +1 -1
- package/dist/domain/Entity.d.ts +1 -1
- package/dist/domain/Entity.js +3 -1
- package/dist/domain/Entity.js.map +1 -1
- package/dist/domain/Struct.d.ts +3 -3
- package/dist/domain/Struct.js +9 -3
- package/dist/domain/Struct.js.map +1 -1
- package/dist/domain/structs/Box.d.ts +2 -2
- package/dist/domain/structs/Box.js +8 -6
- package/dist/domain/structs/Box.js.map +1 -1
- package/dist/domain/structs/Dimension.d.ts +3 -2
- package/dist/domain/structs/Dimension.js +9 -2
- package/dist/domain/structs/Dimension.js.map +1 -1
- package/dist/domain/structs/Money.d.ts +3 -3
- package/dist/domain/structs/Money.js +9 -3
- package/dist/domain/structs/Money.js.map +1 -1
- package/dist/domain/structs/Weight.d.ts +6 -5
- package/dist/domain/structs/Weight.js +18 -5
- package/dist/domain/structs/Weight.js.map +1 -1
- package/dist/resources/Req.js.map +1 -1
- package/dist/types/Enum.js +3 -1
- package/dist/types/Enum.js.map +1 -1
- package/dist/types/List.d.ts +16 -16
- package/dist/types/List.js +62 -39
- package/dist/types/List.js.map +1 -1
- package/dist/types/Meta.d.ts +2 -1
- package/dist/types/Meta.js.map +1 -1
- package/dist/types/PageList.js +1 -2
- package/dist/types/PageList.js.map +1 -1
- package/dist/types/Uri.d.ts +7 -3
- package/dist/types/Uri.js +10 -2
- package/dist/types/Uri.js.map +1 -1
- package/dist/utils/View.js.map +1 -1
- package/package.json +2 -2
- package/src/domain/Child.ts +3 -1
- package/src/domain/Entity.ts +3 -2
- package/src/domain/Struct.ts +9 -3
- package/src/domain/structs/Box.ts +6 -4
- package/src/domain/structs/Dimension.ts +13 -2
- package/src/domain/structs/Money.ts +9 -3
- package/src/domain/structs/Weight.ts +23 -5
- package/src/resources/Req.ts +2 -8
- package/src/types/Enum.ts +3 -1
- package/src/types/List.ts +43 -20
- package/src/types/Meta.ts +4 -2
- package/src/types/PageList.ts +11 -10
- package/src/types/Uri.ts +25 -5
- package/src/utils/View.ts +11 -12
package/src/utils/View.ts
CHANGED
|
@@ -29,13 +29,13 @@ export type InOut = { in?: Func | View<any>; col?: string };
|
|
|
29
29
|
const isColOnly = (v: unknown): v is InOut => isObject(v) && isDefined(v.col) && !isDefined(v.in);
|
|
30
30
|
const isInOnly = (v: unknown): v is InOut => isObject(v) && !isDefined(v.col) && isFunction(v.in);
|
|
31
31
|
const isColAndFunction = (
|
|
32
|
-
v: unknown
|
|
32
|
+
v: unknown
|
|
33
33
|
): v is {
|
|
34
34
|
col: string;
|
|
35
35
|
in: Func;
|
|
36
36
|
} => isObject(v) && isDefined(v.col) && isFunction(v.in);
|
|
37
37
|
const isColAndView = (
|
|
38
|
-
v: unknown
|
|
38
|
+
v: unknown
|
|
39
39
|
): v is {
|
|
40
40
|
col: string;
|
|
41
41
|
in: View;
|
|
@@ -50,9 +50,9 @@ const toFunc = (a: any, col: string, f: Func = a => a): Func =>
|
|
|
50
50
|
const toViewer = (key: string, value: unknown): Viewer =>
|
|
51
51
|
choose(value)
|
|
52
52
|
.is.not.defined(
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
53
|
+
v => v,
|
|
54
|
+
() => toViewer(key, () => undefined)
|
|
55
|
+
)
|
|
56
56
|
.type(isBoolean, b => toViewer(key, () => b))
|
|
57
57
|
.type(isNumber, n => toViewer(key, () => n))
|
|
58
58
|
.type(isString, s => toViewer(key, (a: any) => toFunc(a, s)(a)))
|
|
@@ -69,8 +69,7 @@ const toViewers = (views: Views): Viewer[] =>
|
|
|
69
69
|
.map(([k, v]) => toViewer(k, v));
|
|
70
70
|
|
|
71
71
|
export class View<V = Json> {
|
|
72
|
-
constructor(private views: Views<V> = {} as Views<V>, readonly startsFrom: 'scratch' | 'source' = 'scratch', readonly viewers: Viewer[] = toViewers(views)) {
|
|
73
|
-
}
|
|
72
|
+
constructor(private views: Views<V> = {} as Views<V>, readonly startsFrom: 'scratch' | 'source' = 'scratch', readonly viewers: Viewer[] = toViewers(views)) {}
|
|
74
73
|
|
|
75
74
|
get fromSource(): View<V> {
|
|
76
75
|
return new View(this.views, 'source', this.viewers);
|
|
@@ -84,7 +83,7 @@ export class View<V = Json> {
|
|
|
84
83
|
if (isPageList(source))
|
|
85
84
|
return toPageList(
|
|
86
85
|
source.map(s => this.reduce(asJson(s))),
|
|
87
|
-
source
|
|
86
|
+
source
|
|
88
87
|
);
|
|
89
88
|
if (isArray(source)) return source.map(s => this.reduce(asJson(s)));
|
|
90
89
|
return this.reduce(asJson(source));
|
|
@@ -105,11 +104,11 @@ export const views = {
|
|
|
105
104
|
keepOr: (alt?: unknown) => (a: unknown, key?: string) => traverse(a, key) ?? alt,
|
|
106
105
|
or:
|
|
107
106
|
(key: string, alt = '') =>
|
|
108
|
-
|
|
109
|
-
|
|
107
|
+
(a: unknown) =>
|
|
108
|
+
traverse(a, key) ?? alt,
|
|
110
109
|
value: (value: unknown) => () => value,
|
|
111
110
|
to:
|
|
112
111
|
<T>(ctor: Constructor<T>) =>
|
|
113
|
-
|
|
114
|
-
|
|
112
|
+
(a: unknown, key?: string) =>
|
|
113
|
+
new ctor(traverse(a, key)),
|
|
115
114
|
};
|