@thisisagile/easy 7.40.1 → 7.40.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/data/InMemoryGateway.d.ts +1 -2
- package/dist/data/InMemoryGateway.js +2 -4
- package/dist/data/InMemoryGateway.js.map +1 -1
- package/dist/services/RouteGateway.d.ts +1 -2
- package/dist/services/RouteGateway.js +2 -5
- package/dist/services/RouteGateway.js.map +1 -1
- package/dist/types/Gateway.d.ts +9 -9
- package/dist/types/Gateway.js +36 -0
- package/dist/types/Gateway.js.map +1 -1
- package/package.json +2 -2
- package/src/data/InMemoryGateway.ts +2 -6
- package/src/services/RouteGateway.ts +5 -8
- package/src/types/Gateway.ts +32 -9
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Gateway, Id, Json, JsonValue, List } from '../types';
|
|
2
|
-
export declare class InMemoryGateway
|
|
2
|
+
export declare class InMemoryGateway extends Gateway {
|
|
3
3
|
private readonly data;
|
|
4
4
|
constructor(data: Promise<List<Json>>);
|
|
5
5
|
all(): Promise<List<Json>>;
|
|
@@ -8,6 +8,5 @@ export declare class InMemoryGateway implements Gateway {
|
|
|
8
8
|
exists(id: Id): Promise<boolean>;
|
|
9
9
|
add(item: Json): Promise<Json>;
|
|
10
10
|
remove(id: Id): Promise<true>;
|
|
11
|
-
search(_q: JsonValue): Promise<List<Json>>;
|
|
12
11
|
update(item: Json): Promise<Json>;
|
|
13
12
|
}
|
|
@@ -3,8 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.InMemoryGateway = void 0;
|
|
4
4
|
const types_1 = require("../types");
|
|
5
5
|
const validation_1 = require("../validation");
|
|
6
|
-
class InMemoryGateway {
|
|
6
|
+
class InMemoryGateway extends types_1.Gateway {
|
|
7
7
|
constructor(data) {
|
|
8
|
+
super();
|
|
8
9
|
this.data = data;
|
|
9
10
|
this.by = (key, value) => {
|
|
10
11
|
return this.data.then(d => d.filter(i => i[key] === value));
|
|
@@ -36,9 +37,6 @@ class InMemoryGateway {
|
|
|
36
37
|
.then(i => d.splice(i, 1)))
|
|
37
38
|
.then(() => true);
|
|
38
39
|
}
|
|
39
|
-
search(_q) {
|
|
40
|
-
return Promise.reject();
|
|
41
|
-
}
|
|
42
40
|
update(item) {
|
|
43
41
|
return (0, validation_1.when)(item)
|
|
44
42
|
.not.contains(i => i.id)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InMemoryGateway.js","sourceRoot":"","sources":["../../src/data/InMemoryGateway.ts"],"names":[],"mappings":";;;AAAA,oCAA4F;AAC5F,8CAAqC;AAErC,MAAa,
|
|
1
|
+
{"version":3,"file":"InMemoryGateway.js","sourceRoot":"","sources":["../../src/data/InMemoryGateway.ts"],"names":[],"mappings":";;;AAAA,oCAA4F;AAC5F,8CAAqC;AAErC,MAAa,eAAgB,SAAQ,eAAO;IAC1C,YAA6B,IAAyB;QAAI,KAAK,EAAE,CAAC;QAArC,SAAI,GAAJ,IAAI,CAAqB;QAUtD,OAAE,GAAG,CAAC,GAAW,EAAE,KAAgB,EAAuB,EAAE;YAC1D,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC;QAC9D,CAAC,CAAC;IAZiE,CAAC;IAEpE,GAAG;QACD,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,IAAA,cAAM,EAAC,CAAC,CAAC,CAAC,CAAC;IACxC,CAAC;IAED,IAAI,CAAC,EAAM;QACT,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CA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,GAAG,CAAC,CAAC;aAChB,MAAM,CAAC,iBAAS,CAAC,YAAY,CAAC;aAC9B,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAC7B;aACA,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;IACtB,CAAC;IAED,MAAM,CAAC,IAAU;QACf,OAAO,IAAA,iBAAI,EAAC,IAAI,CAAC;aACd,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aACvB,MAAM,CAAC,iBAAS,CAAC,WAAW,CAAC;aAC7B,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAQ,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAChE,CAAC;CACF;AA9CD,0CA8CC"}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { Api } from './Api';
|
|
2
2
|
import { Func, Gateway, Id, Json, JsonValue, List, Uri } from '../types';
|
|
3
|
-
export declare class RouteGateway
|
|
3
|
+
export declare class RouteGateway extends Gateway {
|
|
4
4
|
readonly route: Func<Uri>;
|
|
5
5
|
readonly routeId: Func<Uri>;
|
|
6
6
|
readonly api: Api;
|
|
7
7
|
constructor(route: Func<Uri>, routeId: Func<Uri>, api?: Api);
|
|
8
8
|
all(): Promise<List<Json>>;
|
|
9
9
|
byId(id: Id): Promise<Json | undefined>;
|
|
10
|
-
by(_key: string, _value: JsonValue): Promise<List<Json>>;
|
|
11
10
|
search(q: JsonValue): Promise<List<Json>>;
|
|
12
11
|
exists(id: Id): Promise<boolean>;
|
|
13
12
|
add(item: Json): Promise<Json>;
|
|
@@ -4,9 +4,9 @@ exports.RouteGateway = void 0;
|
|
|
4
4
|
const Api_1 = require("./Api");
|
|
5
5
|
const types_1 = require("../types");
|
|
6
6
|
const http_1 = require("../http");
|
|
7
|
-
|
|
8
|
-
class RouteGateway {
|
|
7
|
+
class RouteGateway extends types_1.Gateway {
|
|
9
8
|
constructor(route, routeId, api = new Api_1.Api()) {
|
|
9
|
+
super();
|
|
10
10
|
this.route = route;
|
|
11
11
|
this.routeId = routeId;
|
|
12
12
|
this.api = api;
|
|
@@ -17,9 +17,6 @@ class RouteGateway {
|
|
|
17
17
|
byId(id) {
|
|
18
18
|
return this.api.get(this.routeId().id(id)).then(r => r.body.data?.items.first());
|
|
19
19
|
}
|
|
20
|
-
by(_key, _value) {
|
|
21
|
-
return (0, utils_1.reject)(types_1.Exception.IsNotImplemented);
|
|
22
|
-
}
|
|
23
20
|
search(q) {
|
|
24
21
|
return this.api.get(this.route().query(q)).then(r => r.body.data?.items ?? (0, types_1.toList)());
|
|
25
22
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RouteGateway.js","sourceRoot":"","sources":["../../src/services/RouteGateway.ts"],"names":[],"mappings":";;;AAAA,+BAA4B;AAC5B,
|
|
1
|
+
{"version":3,"file":"RouteGateway.js","sourceRoot":"","sources":["../../src/services/RouteGateway.ts"],"names":[],"mappings":";;;AAAA,+BAA4B;AAC5B,oCAAiF;AACjF,kCAAqC;AAErC,MAAa,YAAa,SAAQ,eAAO;IACvC,YAAqB,KAAgB,EAAW,OAAkB,EAAW,MAAW,IAAI,SAAG,EAAE;QAC/F,KAAK,EAAE,CAAC;QADW,UAAK,GAAL,KAAK,CAAW;QAAW,YAAO,GAAP,OAAO,CAAW;QAAW,QAAG,GAAH,GAAG,CAAiB;IAEjG,CAAC;IAED,GAAG;QACD,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,IAAI,IAAA,cAAM,GAAE,C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AAE,CAAC,CAAC;IACvF,CAAC;IAED,MAAM,CAAC,IAAU;QACf,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IACtG,CAAC;IAED,MAAM,CAAC,IAAU;QACf,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IACpG,CAAC;IAED,MAAM,CAAC,EAAM;QACX,OAAO,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;IACjE,CAAC;CACF;AAvCD,oCAuCC"}
|
package/dist/types/Gateway.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { List } from './List';
|
|
2
2
|
import { Json, JsonValue } from './Json';
|
|
3
3
|
import { Id } from './Id';
|
|
4
|
-
export
|
|
5
|
-
all
|
|
6
|
-
byId
|
|
7
|
-
by
|
|
8
|
-
search
|
|
9
|
-
exists
|
|
10
|
-
add
|
|
11
|
-
update
|
|
12
|
-
remove
|
|
4
|
+
export declare abstract class Gateway {
|
|
5
|
+
all(): Promise<List<Json>>;
|
|
6
|
+
byId(id: Id): Promise<Json | undefined>;
|
|
7
|
+
by(key: string, value: JsonValue): Promise<List<Json>>;
|
|
8
|
+
search(q: JsonValue): Promise<List<Json>>;
|
|
9
|
+
exists(id: Id): Promise<boolean>;
|
|
10
|
+
add(item: Json): Promise<Json>;
|
|
11
|
+
update(item: Json): Promise<Json>;
|
|
12
|
+
remove(id: Id): Promise<boolean>;
|
|
13
13
|
}
|
package/dist/types/Gateway.js
CHANGED
|
@@ -1,3 +1,39 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Gateway = void 0;
|
|
4
|
+
const Exception_1 = require("./Exception");
|
|
5
|
+
class Gateway {
|
|
6
|
+
all() {
|
|
7
|
+
throw Exception_1.Exception.IsNotImplemented;
|
|
8
|
+
}
|
|
9
|
+
byId(id) {
|
|
10
|
+
throw Exception_1.Exception.IsNotImplemented;
|
|
11
|
+
}
|
|
12
|
+
;
|
|
13
|
+
by(key, value) {
|
|
14
|
+
throw Exception_1.Exception.IsNotImplemented;
|
|
15
|
+
}
|
|
16
|
+
;
|
|
17
|
+
search(q) {
|
|
18
|
+
throw Exception_1.Exception.IsNotImplemented;
|
|
19
|
+
}
|
|
20
|
+
;
|
|
21
|
+
exists(id) {
|
|
22
|
+
throw Exception_1.Exception.IsNotImplemented;
|
|
23
|
+
}
|
|
24
|
+
;
|
|
25
|
+
add(item) {
|
|
26
|
+
throw Exception_1.Exception.IsNotImplemented;
|
|
27
|
+
}
|
|
28
|
+
;
|
|
29
|
+
update(item) {
|
|
30
|
+
throw Exception_1.Exception.IsNotImplemented;
|
|
31
|
+
}
|
|
32
|
+
;
|
|
33
|
+
remove(id) {
|
|
34
|
+
throw Exception_1.Exception.IsNotImplemented;
|
|
35
|
+
}
|
|
36
|
+
;
|
|
37
|
+
}
|
|
38
|
+
exports.Gateway = Gateway;
|
|
3
39
|
//# sourceMappingURL=Gateway.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Gateway.js","sourceRoot":"","sources":["../../src/types/Gateway.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"Gateway.js","sourceRoot":"","sources":["../../src/types/Gateway.ts"],"names":[],"mappings":";;;AAGA,2CAAwC;AAExC,MAAsB,OAAO;IAC3B,GAAG;QACD,MAAM,qBAAS,CAAC,gBAAgB,CAAC;IACnC,CAAC;IAED,IAAI,CAAC,EAAM;QACT,MAAM,qBAAS,CAAC,gBAAgB,CAAC;IACnC,CAAC;IAAA,CAAC;IAEF,EAAE,CAAC,GAAW,EAAE,KAAgB;QAC9B,MAAM,qBAAS,CAAC,gBAAgB,CAAC;IACnC,CAAC;IAAA,CAAC;IAEF,MAAM,CAAC,CAAY;QACjB,MAAM,qBAAS,CAAC,gBAAgB,CAAC;IACnC,CAAC;IAAA,CAAC;IAEF,MAAM,CAAC,EAAM;QACX,MAAM,qBAAS,CAAC,gBAAgB,CAAC;IACnC,CAAC;IAAA,CAAC;IAEF,GAAG,CAAC,IAAU;QACZ,MAAM,qBAAS,CAAC,gBAAgB,CAAC;IACnC,CAAC;IAAA,CAAC;IAEF,MAAM,CAAC,IAAU;QACf,MAAM,qBAAS,CAAC,gBAAgB,CAAC;IACnC,CAAC;IAAA,CAAC;IAEF,MAAM,CAAC,EAAM;QACX,MAAM,qBAAS,CAAC,gBAAgB,CAAC;IACnC,CAAC;IAAA,CAAC;CACH;AAhCD,0BAgCC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thisisagile/easy",
|
|
3
|
-
"version": "7.40.
|
|
3
|
+
"version": "7.40.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": "7.40.
|
|
34
|
+
"@thisisagile/easy-test": "7.40.5",
|
|
35
35
|
"@types/form-urlencoded": "^4.4.0",
|
|
36
36
|
"@types/jsonwebtoken": "^8.5.5",
|
|
37
37
|
"@types/validator": "^13.6.6"
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Exception, Gateway, Id, isDefined, Json, JsonValue, List, toList } from '../types';
|
|
2
2
|
import { when } from '../validation';
|
|
3
3
|
|
|
4
|
-
export class InMemoryGateway
|
|
5
|
-
constructor(private readonly data: Promise<List<Json>>) {}
|
|
4
|
+
export class InMemoryGateway extends Gateway {
|
|
5
|
+
constructor(private readonly data: Promise<List<Json>>) { super(); }
|
|
6
6
|
|
|
7
7
|
all(): Promise<List<Json>> {
|
|
8
8
|
return this.data.then(d => toList(d));
|
|
@@ -41,10 +41,6 @@ export class InMemoryGateway implements Gateway {
|
|
|
41
41
|
.then(() => true);
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
search(_q: JsonValue): Promise<List<Json>> {
|
|
45
|
-
return Promise.reject();
|
|
46
|
-
}
|
|
47
|
-
|
|
48
44
|
update(item: Json): Promise<Json> {
|
|
49
45
|
return when(item)
|
|
50
46
|
.not.contains(i => i.id)
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { Api } from './Api';
|
|
2
|
-
import {
|
|
2
|
+
import { Func, Gateway, Id, Json, JsonValue, List, toList, Uri } from '../types';
|
|
3
3
|
import { HttpStatus } from '../http';
|
|
4
|
-
import { reject } from '../utils';
|
|
5
4
|
|
|
6
|
-
export class RouteGateway
|
|
7
|
-
constructor(readonly route: Func<Uri>, readonly routeId: Func<Uri>, readonly api: Api = new Api()) {
|
|
5
|
+
export class RouteGateway extends Gateway {
|
|
6
|
+
constructor(readonly route: Func<Uri>, readonly routeId: Func<Uri>, readonly api: Api = new Api()) {
|
|
7
|
+
super();
|
|
8
|
+
}
|
|
8
9
|
|
|
9
10
|
all(): Promise<List<Json>> {
|
|
10
11
|
return this.api.get(this.route()).then(r => r.body.data?.items ?? toList());
|
|
@@ -14,10 +15,6 @@ export class RouteGateway implements Gateway {
|
|
|
14
15
|
return this.api.get(this.routeId().id(id)).then(r => r.body.data?.items.first());
|
|
15
16
|
}
|
|
16
17
|
|
|
17
|
-
by(_key: string, _value: JsonValue): Promise<List<Json>> {
|
|
18
|
-
return reject(Exception.IsNotImplemented);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
18
|
search(q: JsonValue): Promise<List<Json>> {
|
|
22
19
|
return this.api.get(this.route().query(q)).then(r => r.body.data?.items ?? toList());
|
|
23
20
|
}
|
package/src/types/Gateway.ts
CHANGED
|
@@ -1,15 +1,38 @@
|
|
|
1
1
|
import { List } from './List';
|
|
2
2
|
import { Json, JsonValue } from './Json';
|
|
3
3
|
import { Id } from './Id';
|
|
4
|
+
import { Exception } from './Exception';
|
|
4
5
|
|
|
5
|
-
export
|
|
6
|
-
all
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
search: (q: JsonValue) => Promise<List<Json>>;
|
|
10
|
-
exists: (id: Id) => Promise<boolean>;
|
|
6
|
+
export abstract class Gateway {
|
|
7
|
+
all(): Promise<List<Json>> {
|
|
8
|
+
throw Exception.IsNotImplemented;
|
|
9
|
+
}
|
|
11
10
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
byId(id: Id): Promise<Json | undefined> {
|
|
12
|
+
throw Exception.IsNotImplemented;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
by(key: string, value: JsonValue): Promise<List<Json>> {
|
|
16
|
+
throw Exception.IsNotImplemented;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
search(q: JsonValue): Promise<List<Json>> {
|
|
20
|
+
throw Exception.IsNotImplemented;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
exists(id: Id): Promise<boolean> {
|
|
24
|
+
throw Exception.IsNotImplemented;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
add(item: Json): Promise<Json> {
|
|
28
|
+
throw Exception.IsNotImplemented;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
update(item: Json): Promise<Json> {
|
|
32
|
+
throw Exception.IsNotImplemented;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
remove(id: Id): Promise<boolean> {
|
|
36
|
+
throw Exception.IsNotImplemented;
|
|
37
|
+
};
|
|
15
38
|
}
|