@thisisagile/easy 15.2.0 → 15.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.
@@ -1,6 +1,6 @@
1
- import { Api, RouteOptions } from './Api';
2
- import { FetchOptions, Gateway, Json, Optional, PageList, Uri } from '../types';
3
- import { RequestOptions } from '../http';
1
+ import { Api, RouteOptions } from "./Api";
2
+ import { FetchOptions, Gateway, Json, Optional, PageList, Uri } from "../types";
3
+ import { RequestOptions } from "../http";
4
4
  export declare class ApiGateway extends Gateway<RouteOptions> {
5
5
  readonly api: Api;
6
6
  constructor(api?: Api);
@@ -3,17 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ApiGateway = void 0;
4
4
  const Api_1 = require("./Api");
5
5
  const types_1 = require("../types");
6
- const http_1 = require("../http");
7
6
  class ApiGateway extends types_1.Gateway {
8
7
  constructor(api = new Api_1.Api()) {
9
8
  super();
10
9
  this.api = api;
11
10
  }
12
11
  get(uri, options) {
13
- return this.api.get(uri, options).then(r => (0, types_1.toPageList)(r.body.data?.items, (0, http_1.toPageOptions)(options) && {
14
- total: r.body.data?.totalItems,
15
- filters: r.body.data?.meta?.filters,
16
- }));
12
+ return this.api.get(uri, options).then(r => (0, types_1.use)(r.body.data, d => (0, types_1.toPageList)(d?.items, { total: d?.totalItems, ...d?.meta })));
17
13
  }
18
14
  getOne(uri, options) {
19
15
  return this.get(uri, options).then(r => r.first());
@@ -22,10 +18,7 @@ class ApiGateway extends types_1.Gateway {
22
18
  return this.api.post(uri, item, options).then(r => r.body.data?.items.first() ?? {});
23
19
  }
24
20
  postSearch(uri, options) {
25
- return this.api.post(uri, options).then(r => (0, types_1.toPageList)(r.body.data?.items, (0, http_1.toPageOptions)(options) && {
26
- total: r.body.data?.totalItems,
27
- filters: r.body.data?.meta?.filters,
28
- }));
21
+ return this.api.post(uri, options).then(r => (0, types_1.use)(r.body.data, d => (0, types_1.toPageList)(d?.items, { total: d?.totalItems, ...d?.meta })));
29
22
  }
30
23
  patch(uri, item, options) {
31
24
  return this.api.patch(uri, item, options).then(r => r.body.data?.items.first() ?? {});
@@ -1 +1 @@
1
- {"version":3,"file":"ApiGateway.js","sourceRoot":"","sources":["../../src/services/ApiGateway.ts"],"names":[],"mappings":";;;AAAA,+BAA0C;AAC1C,oCAAoG;AACpG,kCAAwD;AAExD,MAAa,UAAW,SAAQ,eAAqB;IACnD,YAAqB,MAAW,IAAI,SAAG,EAAE;QACvC,KAAK,EAAE,CAAC;QADW,QAAG,GAAH,GAAG,CAAiB;IAEzC,CAAC;IAED,GAAG,CAAC,GAAQ,EAAE,OAAsB;QAClC,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CACzC,IAAA,kBAAU,EACR,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,EAClB,IAAA,oBAAa,EAAC,OAAO,CAAC,IAAI;YACxB,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU;YAC9B,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,OAAmB;SAChD,CACF,CACF,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,GAAQ,EAAE,OAAsB;QACrC,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC;IACrD,CAAC;IAED,IAAI,CAAC,GAAQ,EAAE,IAAW,EAAE,OAAsB;QAChD,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,KAAK,EAAE,IAAI,EAAE,CA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AAI,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,IAAA,kBAAU,EAAC,CAAC,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,UAAU,EAAE,GAAG,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IAClI,CAAC;IAED,KAAK,CAAC,GAAQ,EAAE,IAAW,EAAE,OAAsB;QACjD,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IACxF,CAAC;IAED,GAAG,CAAC,GAAQ,EAAE,IAAW,EAAE,OAAsB;QAC/C,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IACtF,CAAC;IAED,MAAM,CAAC,GAAQ,EAAE,OAAsB;QACrC,OAAO,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;IACxD,CAAC;CACF;AAhCD,gCAgCC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thisisagile/easy",
3
- "version": "15.2.0",
3
+ "version": "15.2.3",
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": "15.2.0",
34
+ "@thisisagile/easy-test": "15.2.3",
35
35
  "@types/form-urlencoded": "^4.4.0",
36
36
  "@types/jsonwebtoken": "^9.0.2",
37
37
  "@types/luxon": "3.2.0",
@@ -1,6 +1,6 @@
1
- import { Api, RouteOptions } from './Api';
2
- import { FetchOptions, Filter, Gateway, Json, Optional, PageList, toPageList, Uri } from '../types';
3
- import { RequestOptions, toPageOptions } from '../http';
1
+ import { Api, RouteOptions } from "./Api";
2
+ import { FetchOptions, Gateway, Json, Optional, PageList, toPageList, Uri, use } from "../types";
3
+ import { RequestOptions } from "../http";
4
4
 
5
5
  export class ApiGateway extends Gateway<RouteOptions> {
6
6
  constructor(readonly api: Api = new Api()) {
@@ -8,15 +8,7 @@ export class ApiGateway extends Gateway<RouteOptions> {
8
8
  }
9
9
 
10
10
  get(uri: Uri, options?: RouteOptions): Promise<PageList<Json>> {
11
- return this.api.get(uri, options).then(r =>
12
- toPageList<Json>(
13
- r.body.data?.items,
14
- toPageOptions(options) && {
15
- total: r.body.data?.totalItems,
16
- filters: r.body.data?.meta?.filters as Filter[],
17
- }
18
- )
19
- );
11
+ return this.api.get(uri, options).then(r => use(r.body.data, d => toPageList(d?.items, { total: d?.totalItems, ...d?.meta })));
20
12
  }
21
13
 
22
14
  getOne(uri: Uri, options?: RouteOptions): Promise<Optional<Json>> {
@@ -28,15 +20,7 @@ export class ApiGateway extends Gateway<RouteOptions> {
28
20
  }
29
21
 
30
22
  postSearch(uri: Uri, options?: RequestOptions | FetchOptions): Promise<PageList<Json>> {
31
- return this.api.post(uri, options).then(r =>
32
- toPageList<Json>(
33
- r.body.data?.items,
34
- toPageOptions(options) && {
35
- total: r.body.data?.totalItems,
36
- filters: r.body.data?.meta?.filters as Filter[],
37
- }
38
- )
39
- );
23
+ return this.api.post(uri, options).then(r => use(r.body.data, d => toPageList(d?.items, { total: d?.totalItems, ...d?.meta })));
40
24
  }
41
25
 
42
26
  patch(uri: Uri, item?: Json, options?: RouteOptions): Promise<Json> {