@thisisagile/easy 8.41.2 → 8.41.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/dist/http/RestResult.js +6 -5
- package/dist/http/RestResult.js.map +1 -1
- package/dist/utils/View.d.ts +3 -1
- package/dist/utils/View.js +3 -1
- package/dist/utils/View.js.map +1 -1
- package/package.json +2 -2
- package/src/http/RestResult.ts +21 -24
- package/src/utils/View.ts +4 -2
package/dist/http/RestResult.js
CHANGED
|
@@ -22,11 +22,12 @@ exports.rest = {
|
|
|
22
22
|
},
|
|
23
23
|
}),
|
|
24
24
|
to: (payload, status) => (0, utils_1.choose)(payload)
|
|
25
|
-
.
|
|
26
|
-
.
|
|
27
|
-
.
|
|
28
|
-
.
|
|
29
|
-
.
|
|
25
|
+
.type(types_1.isUndefined, p => p)
|
|
26
|
+
.type(HttpStatus_1.isHttpStatus, h => exports.rest.toError(h ?? status ?? HttpStatus_1.HttpStatus.InternalServerError, [(0, types_1.toResult)(h.name)]))
|
|
27
|
+
.type(types_1.isResult, r => exports.rest.toError(status ?? HttpStatus_1.HttpStatus.BadRequest, [r]))
|
|
28
|
+
.type(types_1.isError, e => exports.rest.toError(status ?? HttpStatus_1.HttpStatus.BadRequest, [e]))
|
|
29
|
+
.type(types_1.isResults, r => exports.rest.toError(status ?? HttpStatus_1.HttpStatus.BadRequest, r.results))
|
|
30
|
+
.type(Response_1.isResponse, r => exports.rest.toError(status ?? HttpStatus_1.HttpStatus.byId(r.body.error?.code), r.body.error?.errors))
|
|
30
31
|
.case(p => p.error && p.error.errors, p => exports.rest.toError(status ?? HttpStatus_1.HttpStatus.byId(p.error.code, HttpStatus_1.HttpStatus.BadRequest), p.error.errors))
|
|
31
32
|
.case(p => p.data && p.data.items, p => exports.rest.toData(status ?? HttpStatus_1.HttpStatus.byId(p.data.code, HttpStatus_1.HttpStatus.Ok), p.data.items))
|
|
32
33
|
.else(p => exports.rest.toData(status ?? HttpStatus_1.HttpStatus.Ok, (0, types_1.toList)(p))),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RestResult.js","sourceRoot":"","sources":["../../src/http/RestResult.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"RestResult.js","sourceRoot":"","sources":["../../src/http/RestResult.ts"],"names":[],"mappings":";;;AAAA,oCAYkB;AAClB,oCAAkC;AAClC,6CAAwD;AACxD,yCAAwC;AAO3B,QAAA,IAAI,GAAG;IAClB,MAAM,EAAE,CAAC,MAAkB,EAAE,QAAgB,EAAE,EAAc,EAAE,CAAC,CAAC;QAC/D,IAAI,EAAE;YACJ,IAAI,EAAE,MAAM,CAAC,MAAM;YACnB,KAAK,EAAE,IAAA,cAAM,EAAC,KAAK,CAAC;YACpB,SAAS,EAAE,KAAK,CAAC,MAAM;SACxB;KACF,CAAC;IACF,OAAO,EAAE,CAAC,MAAkB,EAAE,SAAmB,CAAC,IAAA,gBAAQ,EAAC,MAAM,CAAC,IAAI,CAAC,CAAC,EAAc,EAAE,CAAC,CAAC;QACxF,KAAK,EAAE;YACL,IAAI,EAAE,MAAM,CAAC,MAAM;YACnB,OAAO,EAAE,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,IAAI,SAAS;YACtD,MAAM,EAAE,IAAA,cAAM,EAAC,MAAM,CAAC;YACtB,UAAU,EAAE,MAAM,CAAC,MAAM;SAC1B;KACF,CAAC;IACF,EAAE,EAAE,CAAC,OAAqB,EAAE,MAAmB,EAAc,EAAE,CAC7D,IAAA,cAAM,EAAkB,OAAO,CAAC;SAC7B,IAAI,CAAC,mBAAW,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;SACzB,IAAI,CAAC,yBAAY,EAAE,CAAC,CAAC,EAAE,CAAC,YAAI,CAAC,OAAO,CAAC,CAAC,IAAI,MAAM,IAAI,uBAAU,CAAC,mBAAmB,EAAE,CAAC,IAAA,gBAAQ,EAAC,CAAC,C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AAC,EAAE,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CACtF;SACA,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,YAAI,CAAC,MAAM,CAAC,MAAM,IAAI,uBAAU,CAAC,EAAE,EAAE,IAAA,cAAM,EAAC,CAAC,CAAC,CAAC,CAAC;CAChE,CAAC;AAEK,MAAM,YAAY,GAAG,CAAC,CAAU,EAAmB,EAAE,CAAC,IAAA,iBAAS,EAAC,CAAC,CAAC,IAAI,CAAC,IAAA,iBAAS,EAAE,CAAgB,CAAC,IAAI,CAAC,IAAI,IAAA,iBAAS,EAAE,CAAgB,CAAC,KAAK,CAAC,CAAC,CAAC;AAA1I,QAAA,YAAY,gBAA8H"}
|
package/dist/utils/View.d.ts
CHANGED
|
@@ -14,12 +14,14 @@ declare type Viewer = {
|
|
|
14
14
|
};
|
|
15
15
|
};
|
|
16
16
|
export declare class View {
|
|
17
|
+
private views;
|
|
17
18
|
readonly startsFrom: 'scratch' | 'source';
|
|
18
19
|
readonly viewers: Viewer[];
|
|
19
20
|
constructor(views?: Views, startsFrom?: 'scratch' | 'source', viewers?: Viewer[]);
|
|
20
21
|
from: (source: unknown) => Json;
|
|
21
22
|
private reduce;
|
|
23
|
+
get fromSource(): View;
|
|
22
24
|
}
|
|
23
25
|
export declare const skip: () => undefined;
|
|
24
|
-
export declare const view: (views: Views
|
|
26
|
+
export declare const view: (views: Views) => View;
|
|
25
27
|
export {};
|
package/dist/utils/View.js
CHANGED
|
@@ -23,15 +23,17 @@ const toViewers = (views) => (0, types_1.meta)(views)
|
|
|
23
23
|
.map(([k, v]) => toViewer(k, v));
|
|
24
24
|
class View {
|
|
25
25
|
constructor(views = {}, startsFrom = 'scratch', viewers = toViewers(views)) {
|
|
26
|
+
this.views = views;
|
|
26
27
|
this.startsFrom = startsFrom;
|
|
27
28
|
this.viewers = viewers;
|
|
28
29
|
this.from = (source) => (0, types_1.isArray)(source) ? source.map(s => this.reduce((0, types_1.asJson)(s))) : this.reduce((0, types_1.asJson)(source));
|
|
29
30
|
this.reduce = (i) => this.viewers.reduce((a, v) => types_1.json.set(a, v.in.key, v.in.f(i)), this.startsFrom === 'scratch' ? {} : i);
|
|
30
31
|
}
|
|
32
|
+
get fromSource() { return new View(this.views, 'source', this.viewers); }
|
|
31
33
|
}
|
|
32
34
|
exports.View = View;
|
|
33
35
|
const skip = () => undefined;
|
|
34
36
|
exports.skip = skip;
|
|
35
|
-
const view = (views
|
|
37
|
+
const view = (views) => new View(views);
|
|
36
38
|
exports.view = view;
|
|
37
39
|
//# sourceMappingURL=View.js.map
|
package/dist/utils/View.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"View.js","sourceRoot":"","sources":["../../src/utils/View.ts"],"names":[],"mappings":";;;AAAA,oCAYkB;AAClB,yCAAsC;AACtC,iCAAgC;AAMhC,MAAM,SAAS,GAAG,CAAC,CAAU,EAAc,EAAE,CAAC,IAAA,gBAAQ,EAAC,CAAC,CAAC,IAAI,IAAA,iBAAS,EAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,IAAA,iBAAS,EAAC,CAAC,CAAC,EAAE,CAAC,CAAC;AAClG,MAAM,QAAQ,GAAG,CAAC,CAAU,EAAc,EAAE,CAAC,IAAA,gBAAQ,EAAC,CAAC,CAAC,IAAI,CAAC,IAAA,iBAAS,EAAC,CAAC,CAAC,GAAG,CAAC,IAAI,IAAA,kBAAU,EAAC,CAAC,CAAC,EAAE,CAAC,CAAC;AAClG,MAAM,gBAAgB,GAAG,CAAC,CAAU,EAAkC,EAAE,CAAC,IAAA,gBAAQ,EAAC,CAAC,CAAC,IAAI,IAAA,iBAAS,EAAC,CAAC,CAAC,GAAG,CAAC,IAAI,IAAA,kBAAU,EAAC,CAAC,CAAC,EAAE,CAAC,CAAC;AAC7H,MAAM,YAAY,GAAG,CAAC,CAAU,EAAkC,EAAE,CAAC,IAAA,gBAAQ,EAAC,CAAC,CAAC,IAAI,IAAA,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J/I,CAAC;IAMD,IAAI,UAAU,KAAW,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;CAChF;AATD,oBASC;AAEM,MAAM,IAAI,GAAG,GAAG,EAAE,CAAC,SAAS,CAAC;AAAvB,QAAA,IAAI,QAAmB;AAC7B,MAAM,IAAI,GAAG,CAAC,KAAY,EAAQ,EAAE,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC;AAA/C,QAAA,IAAI,QAA2C"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thisisagile/easy",
|
|
3
|
-
"version": "8.41.
|
|
3
|
+
"version": "8.41.5",
|
|
4
4
|
"description": "Straightforward library for building domain-driven microservice architectures",
|
|
5
5
|
"author": "Sander Hoogendoorn",
|
|
6
6
|
"license": "MIT",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"access": "public"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@thisisagile/easy-test": "8.41.
|
|
34
|
+
"@thisisagile/easy-test": "8.41.5",
|
|
35
35
|
"@types/form-urlencoded": "^4.4.0",
|
|
36
36
|
"@types/jsonwebtoken": "^8.5.8",
|
|
37
37
|
"@types/validator": "^13.7.1"
|
package/src/http/RestResult.ts
CHANGED
|
@@ -1,4 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
Id,
|
|
3
|
+
isDefined,
|
|
4
|
+
isError,
|
|
5
|
+
isResult,
|
|
6
|
+
isResults,
|
|
7
|
+
isUndefined,
|
|
8
|
+
Json,
|
|
9
|
+
List,
|
|
10
|
+
Result,
|
|
11
|
+
toList,
|
|
12
|
+
toResult,
|
|
13
|
+
} from '../types';
|
|
2
14
|
import { choose } from '../utils';
|
|
3
15
|
import { HttpStatus, isHttpStatus } from './HttpStatus';
|
|
4
16
|
import { isResponse } from './Response';
|
|
@@ -26,33 +38,18 @@ export const rest = {
|
|
|
26
38
|
}),
|
|
27
39
|
to: (payload?: any | any[], status?: HttpStatus): RestResult =>
|
|
28
40
|
choose<RestResult, any>(payload)
|
|
29
|
-
.
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
)
|
|
33
|
-
.
|
|
34
|
-
|
|
35
|
-
p => rest.toError(p ?? status ?? HttpStatus.InternalServerError, [toResult(p.name)])
|
|
36
|
-
)
|
|
37
|
-
.case(
|
|
38
|
-
p => isResult(p) || isError(p),
|
|
39
|
-
p => rest.toError(status ?? HttpStatus.BadRequest, [p])
|
|
40
|
-
)
|
|
41
|
-
.case(
|
|
42
|
-
p => isResults(p),
|
|
43
|
-
p => rest.toError(status ?? HttpStatus.BadRequest, p.results)
|
|
44
|
-
)
|
|
45
|
-
.case(
|
|
46
|
-
p => isResponse(p),
|
|
47
|
-
p => rest.toError(status ?? HttpStatus.byId(p.body.error?.code), p.body.error?.errors)
|
|
48
|
-
)
|
|
41
|
+
.type(isUndefined, p => p)
|
|
42
|
+
.type(isHttpStatus, h => rest.toError(h ?? status ?? HttpStatus.InternalServerError, [toResult(h.name)]))
|
|
43
|
+
.type(isResult, r => rest.toError(status ?? HttpStatus.BadRequest, [r]))
|
|
44
|
+
.type(isError, e => rest.toError(status ?? HttpStatus.BadRequest, [e]))
|
|
45
|
+
.type(isResults, r => rest.toError(status ?? HttpStatus.BadRequest, r.results))
|
|
46
|
+
.type(isResponse, r => rest.toError(status ?? HttpStatus.byId(r.body.error?.code as Id), r.body.error?.errors))
|
|
49
47
|
.case(
|
|
50
48
|
p => p.error && p.error.errors,
|
|
51
|
-
p => rest.toError(status ?? HttpStatus.byId(p.error.code, HttpStatus.BadRequest), p.error.errors)
|
|
52
|
-
)
|
|
49
|
+
p => rest.toError(status ?? HttpStatus.byId(p.error.code, HttpStatus.BadRequest), p.error.errors))
|
|
53
50
|
.case(
|
|
54
51
|
p => p.data && p.data.items,
|
|
55
|
-
p => rest.toData(status ?? HttpStatus.byId(p.data.code, HttpStatus.Ok), p.data.items)
|
|
52
|
+
p => rest.toData(status ?? HttpStatus.byId(p.data.code, HttpStatus.Ok), p.data.items),
|
|
56
53
|
)
|
|
57
54
|
.else(p => rest.toData(status ?? HttpStatus.Ok, toList(p))),
|
|
58
55
|
};
|
package/src/utils/View.ts
CHANGED
|
@@ -46,13 +46,15 @@ const toViewers = (views: Views): Viewer[] =>
|
|
|
46
46
|
.map(([k, v]) => toViewer(k, v));
|
|
47
47
|
|
|
48
48
|
export class View {
|
|
49
|
-
constructor(views: Views = {}, readonly startsFrom: 'scratch' | 'source' = 'scratch', readonly viewers: Viewer[] = toViewers(views)) {
|
|
49
|
+
constructor(private views: Views = {}, readonly startsFrom: 'scratch' | 'source' = 'scratch', readonly viewers: Viewer[] = toViewers(views)) {
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
from = (source: unknown): Json => isArray(source) ? source.map(s => this.reduce(asJson(s))) : this.reduce(asJson(source));
|
|
53
53
|
|
|
54
54
|
private reduce = (i: any): any => this.viewers.reduce((a: any, v) => json.set(a, v.in.key, v.in.f(i)), this.startsFrom === 'scratch' ? {} : i);
|
|
55
|
+
|
|
56
|
+
get fromSource(): View { return new View(this.views, 'source', this.viewers); }
|
|
55
57
|
}
|
|
56
58
|
|
|
57
59
|
export const skip = () => undefined;
|
|
58
|
-
export const view = (views: Views
|
|
60
|
+
export const view = (views: Views): View => new View(views);
|