@thisisagile/easy 10.5.16 → 10.5.20

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,16 +1,16 @@
1
- import { Constructor, Gateway, Id, Json, JsonValue, Key, TotalList } from '../types';
1
+ import { Constructor, Gateway, Id, Json, JsonValue, Key, PageList } from '../types';
2
2
  import { Struct } from './Struct';
3
3
  export declare class Repo<T extends Struct> {
4
4
  protected ctor: Constructor<T>;
5
5
  private readonly gateway;
6
6
  constructor(ctor: Constructor<T>, gateway: Gateway);
7
7
  create: (item: T | Json) => T;
8
- all(): Promise<TotalList<T>>;
8
+ all(): Promise<PageList<T>>;
9
9
  byId(id: Id): Promise<T>;
10
- byIds(...ids: Id[]): Promise<TotalList<T>>;
11
- byKey(key: Key): Promise<TotalList<T>>;
12
- by(key: keyof T, value: JsonValue): Promise<TotalList<T>>;
13
- search(q: JsonValue): Promise<TotalList<T>>;
10
+ byIds(...ids: Id[]): Promise<PageList<T>>;
11
+ byKey(key: Key): Promise<PageList<T>>;
12
+ by(key: keyof T, value: JsonValue): Promise<PageList<T>>;
13
+ search(q: JsonValue): Promise<PageList<T>>;
14
14
  exists(id: Id): Promise<boolean>;
15
15
  add(t: T | Json): Promise<T>;
16
16
  update(id: Id, json: Json): Promise<T>;
@@ -1,12 +1,12 @@
1
1
  import { Repo, Struct } from '../domain';
2
- import { Id, JsonValue, Key, TotalList } from '../types';
2
+ import { Id, JsonValue, Key, PageList } from '../types';
3
3
  export declare class Search<T extends Struct> {
4
4
  protected repo: Repo<T>;
5
5
  constructor(repo: Repo<T>);
6
- all: () => Promise<TotalList<T>>;
6
+ all: () => Promise<PageList<T>>;
7
7
  byId: (id: Id) => Promise<T>;
8
- byIds: (...ids: Id[]) => Promise<TotalList<T>>;
9
- byKey: (key: Key) => Promise<TotalList<T>>;
10
- search: (query: JsonValue) => Promise<TotalList<T>>;
8
+ byIds: (...ids: Id[]) => Promise<PageList<T>>;
9
+ byKey: (key: Key) => Promise<PageList<T>>;
10
+ search: (query: JsonValue) => Promise<PageList<T>>;
11
11
  exists: (id: Id) => Promise<boolean>;
12
12
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Search.js","sourceRoot":"","sources":["../../src/process/Search.ts"],"names":[],"mappings":";;;AACA,oCAAqF;AACrF,oCAAmC;AAEnC,MAAa,MAAM;IACjB,YAAsB,IAAa;QAAb,SAAI,GAAJ,IAAI,CAAS;QAGnC,QAAG,GAAG,GAA0B,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;QAEnD,SAAI,GAAG,CAAC,EAAM,EAAc,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAElD,UAAK,GAAG,CAAC,GAAG,GAAS,EAAyB,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC,CAAC;QAEzE,UAAK,GAAG,CAAC,GAAQ,EAAyB,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAElE,WAAM,GAAG,CAAC,KAAgB,EAAyB,EAAE,CACnD,IAAA,cAAM,EAAC,KAAK,CAAC;aACV,IAAI,CAAC,kBAAU,EAAE,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;aAC1C,IAAI,CAAC,IAAA,eAAO,EAAC,IAAA,cAAM,GAAK,CAAC,CAAC,CAAC;QAEhC,WAAM,GAAG,CAAC,EAAM,EAAoB,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IAf5D,CAAC;CAgBF;AAlBD,wBAkBC"}
1
+ {"version":3,"file":"Search.js","sourceRoot":"","sources":["../../src/process/Search.ts"],"names":[],"mappings":";;;AACA,oCAAoF;AACpF,oCAAmC;AAEnC,MAAa,MAAM;IACjB,YAAsB,IAAa;QAAb,SAAI,GAAJ,IAAI,CAAS;QAGnC,QAAG,GAAG,GAAyB,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;QAElD,SAAI,GAAG,CAAC,EAAM,EAAc,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAElD,UAAK,GAAG,CAAC,GAAG,GAAS,EAAwB,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC,CAAC;QAExE,UAAK,GAAG,CAAC,GAAQ,EAAwB,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAEjE,WAAM,GAAG,CAAC,KAAgB,EAAwB,EAAE,CAClD,IAAA,cAAM,EAAC,KAAK,CAAC;aACV,IAAI,CAAC,kBAAU,EAAE,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;aAC1C,IAAI,CAAC,IAAA,eAAO,EAAC,IAAA,cAAM,GAAK,CAAC,CAAC,CAAC;QAEhC,WAAM,GAAG,CAAC,EAAM,EAAoB,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IAf5D,CAAC;CAgBF;AAlBD,wBAkBC"}
@@ -1,16 +1,16 @@
1
1
  import { Api } from './Api';
2
- import { Func, Gateway, Id, Json, JsonValue, TotalList, Uri } from '../types';
2
+ import { Func, Gateway, Id, Json, JsonValue, PageList, Uri } from '../types';
3
3
  import { RequestOptions } from '../http';
4
4
  export declare class RouteGateway extends Gateway {
5
5
  readonly route: Func<Uri>;
6
6
  readonly routeId: Func<Uri>;
7
7
  readonly api: Api;
8
8
  constructor(route: Func<Uri>, routeId: Func<Uri>, api?: Api);
9
- get(uri: Uri, options?: RequestOptions): Promise<TotalList<Json>>;
9
+ get(uri: Uri, options?: RequestOptions): Promise<PageList<Json>>;
10
10
  getOne(uri: Uri, options?: RequestOptions): Promise<Json | undefined>;
11
- all(): Promise<TotalList<Json>>;
11
+ all(): Promise<PageList<Json>>;
12
12
  byId(id: Id): Promise<Json | undefined>;
13
- search(q: JsonValue): Promise<TotalList<Json>>;
13
+ search(q: JsonValue): Promise<PageList<Json>>;
14
14
  exists(id: Id): Promise<boolean>;
15
15
  add(item: Json): Promise<Json>;
16
16
  update(item: Json): Promise<Json>;
@@ -12,7 +12,7 @@ class RouteGateway extends types_1.Gateway {
12
12
  this.api = api;
13
13
  }
14
14
  get(uri, options) {
15
- return this.api.get(uri, options).then(r => (0, types_1.toTotalList)(r.body.data?.items, r.body.data?.totalItems));
15
+ return this.api.get(uri, options).then(r => (0, types_1.toPageList)(r.body.data?.items, { total: r.body.data?.totalItems }));
16
16
  }
17
17
  getOne(uri, options) {
18
18
  return this.get(uri, options).then(r => r.first());
@@ -1 +1 @@
1
- {"version":3,"file":"RouteGateway.js","sourceRoot":"","sources":["../../src/services/RouteGateway.ts"],"names":[],"mappings":";;;AAAA,+BAA4B;AAC5B,oCAA2F;AAC3F,kCAAqD;AAErD,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,CAAC,GAAQ,EAAE,OAAwB;QACpC,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,IAAA,mBAAW,EAAO,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC;IAC9G,CAAC;IAED,MAAM,CAAC,GAAQ,EAAE,OAAwB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AAI,CAAC,KAAK,EAAE,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,KAAK,EAAE,IAAI,EAAE,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;AA9CD,oCA8CC"}
@@ -1,12 +1,12 @@
1
1
  import { Json, JsonValue } from './Json';
2
2
  import { Id } from './Id';
3
- import { TotalList } from './TotalList';
3
+ import { PageList, PageOptions } from './PageList';
4
4
  export declare abstract class Gateway {
5
- all(): Promise<TotalList<Json>>;
5
+ all(options?: PageOptions): Promise<PageList<Json>>;
6
6
  byId(id: Id): Promise<Json | undefined>;
7
- by(key: string, value: JsonValue): Promise<TotalList<Json>>;
8
- byIds(...ids: Id[]): Promise<TotalList<Json>>;
9
- search(q: JsonValue): Promise<TotalList<Json>>;
7
+ by(_key: string, _value: JsonValue, _options?: PageOptions): Promise<PageList<Json>>;
8
+ byIds(..._ids: Id[]): Promise<PageList<Json>>;
9
+ search(q: JsonValue, options?: PageOptions): Promise<PageList<Json>>;
10
10
  exists(id: Id): Promise<boolean>;
11
11
  add(item: Json): Promise<Json>;
12
12
  update(item: Json): Promise<Json>;
@@ -4,19 +4,19 @@ exports.Gateway = void 0;
4
4
  const Exception_1 = require("./Exception");
5
5
  const utils_1 = require("../utils");
6
6
  class Gateway {
7
- all() {
7
+ all(options) {
8
8
  return (0, utils_1.reject)(Exception_1.Exception.IsNotImplemented);
9
9
  }
10
10
  byId(id) {
11
11
  return (0, utils_1.reject)(Exception_1.Exception.IsNotImplemented);
12
12
  }
13
- by(key, value) {
13
+ by(_key, _value, _options) {
14
14
  return (0, utils_1.reject)(Exception_1.Exception.IsNotImplemented);
15
15
  }
16
- byIds(...ids) {
16
+ byIds(..._ids) {
17
17
  return (0, utils_1.reject)(Exception_1.Exception.IsNotImplemented);
18
18
  }
19
- search(q) {
19
+ search(q, options) {
20
20
  return (0, utils_1.reject)(Exception_1.Exception.IsNotImplemented);
21
21
  }
22
22
  exists(id) {
@@ -1 +1 @@
1
- {"version":3,"file":"Gateway.js","sourceRoot":"","sources":["../../src/types/Gateway.ts"],"names":[],"mappings":";;;AAEA,2CAAwC;AACxC,oCAAkC;AAGlC,MAAsB,OAAO;IAC3B,GAAG;QACD,OAAO,IAAA,cAAM,EAAC,qBAAS,CAAC,gBAAgB,CAAC,CAAC;IAC5C,CAAC;IAED,IAAI,CAAC,EAAM;QACT,OAAO,IAAA,cAAM,EAAC,qBAAS,CAAC,gBAAgB,CAAC,CAAC;IAC5C,CAAC;IAED,EAAE,CAAC,GAAW,EAAE,KAAgB;QAC9B,OAAO,IAAA,cAAM,EAAC,qBAAS,CAAC,gBAAgB,CAAC,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AqB;QACxC,OAAO,IAAA,cAAM,EAAC,qBAAS,CAAC,gBAAgB,CAAC,CAAC;IAC5C,CAAC;IAED,MAAM,CAAC,EAAM;QACX,OAAO,IAAA,cAAM,EAAC,qBAAS,CAAC,gBAAgB,CAAC,CAAC;IAC5C,CAAC;IAED,GAAG,CAAC,IAAU;QACZ,OAAO,IAAA,cAAM,EAAC,qBAAS,CAAC,gBAAgB,CAAC,CAAC;IAC5C,CAAC;IAED,MAAM,CAAC,IAAU;QACf,OAAO,IAAA,cAAM,EAAC,qBAAS,CAAC,gBAAgB,CAAC,CAAC;IAC5C,CAAC;IAED,MAAM,CAAC,EAAM;QACX,OAAO,IAAA,cAAM,EAAC,qBAAS,CAAC,gBAAgB,CAAC,CAAC;IAC5C,CAAC;CACF;AArCD,0BAqCC"}
@@ -0,0 +1,8 @@
1
+ import { List } from './List';
2
+ export declare type PageOptions = {
3
+ take?: number;
4
+ skip?: number;
5
+ total?: number;
6
+ };
7
+ export declare type PageList<T> = List<T> & PageOptions;
8
+ export declare const toPageList: <T>(items?: T[] | undefined, options?: PageOptions) => PageList<T>;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.toPageList = void 0;
4
+ const List_1 = require("./List");
5
+ const toPageList = (items, options = { take: 250, skip: 0 }) => {
6
+ const list = (0, List_1.toList)(...items ?? []);
7
+ list.take = options.take;
8
+ list.skip = options.skip;
9
+ list.total = options.total;
10
+ return list;
11
+ };
12
+ exports.toPageList = toPageList;
13
+ //# sourceMappingURL=PageList.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PageList.js","sourceRoot":"","sources":["../../src/types/PageList.ts"],"names":[],"mappings":";;;AAAA,iCAAsC;AAM/B,MAAM,UAAU,GAAG,CAAI,KAAW,EAAE,UAAuB,EAAC,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,EAAC,EAAe,EAAE;IACrG,MAAM,IAAI,GAAG,IAAA,aAAM,EAAI,GAAG,KAAK,IAAI,EAAE,CAAQ,CAAC;IAC9C,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IACzB,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IACzB,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;IAC3B,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AANW,QAAA,UAAU,cAMrB"}
@@ -25,7 +25,7 @@ export * from './Results';
25
25
  export * from './Tag';
26
26
  export * from './Template';
27
27
  export * from './Text';
28
- export * from './TotalList';
28
+ export * from './PageList';
29
29
  export * from './Try';
30
30
  export * from './Uri';
31
31
  export * from './Uuid';
@@ -41,7 +41,7 @@ __exportStar(require("./Results"), exports);
41
41
  __exportStar(require("./Tag"), exports);
42
42
  __exportStar(require("./Template"), exports);
43
43
  __exportStar(require("./Text"), exports);
44
- __exportStar(require("./TotalList"), exports);
44
+ __exportStar(require("./PageList"), exports);
45
45
  __exportStar(require("./Try"), exports);
46
46
  __exportStar(require("./Uri"), exports);
47
47
  __exportStar(require("./Uuid"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB;AACxB,4CAA0B;AAC1B,yCAAuB;AACvB,gDAA8B;AAC9B,4CAA0B;AAC1B,yCAAuB;AACvB,gDAA8B;AAC9B,8CAA4B;AAC5B,yCAAuB;AACvB,4CAA0B;AAC1B,wCAAsB;AACtB,uCAAqB;AACrB,6CAA2B;AAC3B,uCAAqB;AACrB,wCAAsB;AACtB,2CAAyB;AACzB,4CAA0B;AAC1B,yCAAuB;AACvB,yCAAuB;AACvB,4CAA0B;AAC1B,yCAAuB;AACvB,2CAAyB;AACzB,2CAAyB;AACzB,4CAA0B;AAC1B,wCAAsB;AACtB,6CAA2B;AAC3B,yCAAuB;AACvB,8CAA4B;AAC5B,wCAAsB;AACtB,wCAAsB;AACtB,yCAAuB;AACvB,gDAA8B;AAC9B,0CAAwB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB;AACxB,4CAA0B;AAC1B,yCAAuB;AACvB,gDAA8B;AAC9B,4CAA0B;AAC1B,yCAAuB;AACvB,gDAA8B;AAC9B,8CAA4B;AAC5B,yCAAuB;AACvB,4CAA0B;AAC1B,wCAAsB;AACtB,uCAAqB;AACrB,6CAA2B;AAC3B,uCAAqB;AACrB,wCAAsB;AACtB,2CAAyB;AACzB,4CAA0B;AAC1B,yCAAuB;AACvB,yCAAuB;AACvB,4CAA0B;AAC1B,yCAAuB;AACvB,2CAAyB;AACzB,2CAAyB;AACzB,4CAA0B;AAC1B,wCAAsB;AACtB,6CAA2B;AAC3B,yCAAuB;AACvB,6CAA2B;AAC3B,wCAAsB;AACtB,wCAAsB;AACtB,yCAAuB;AACvB,gDAA8B;AAC9B,0CAAwB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thisisagile/easy",
3
- "version": "10.5.16",
3
+ "version": "10.5.20",
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": "10.5.16",
34
+ "@thisisagile/easy-test": "10.5.20",
35
35
  "@types/form-urlencoded": "^4.4.0",
36
36
  "@types/jsonwebtoken": "^8.5.8",
37
37
  "@types/validator": "^13.7.2"
@@ -9,7 +9,7 @@ import {
9
9
  JsonValue,
10
10
  Key,
11
11
  toJson,
12
- TotalList,
12
+ PageList,
13
13
  } from '../types';
14
14
  import { when } from '../validation';
15
15
  import { reject, resolve } from '../utils';
@@ -21,7 +21,7 @@ export class Repo<T extends Struct> {
21
21
 
22
22
  create = (item: T | Json): T => (isValidatable(item) ? item : new this.ctor(item));
23
23
 
24
- all(): Promise<TotalList<T>> {
24
+ all(): Promise<PageList<T>> {
25
25
  return this.gateway.all().then(js => js.map(j => new this.ctor(j)));
26
26
  }
27
27
 
@@ -32,19 +32,19 @@ export class Repo<T extends Struct> {
32
32
  .then(j => new this.ctor(j));
33
33
  }
34
34
 
35
- byIds(...ids: Id[]): Promise<TotalList<T>> {
35
+ byIds(...ids: Id[]): Promise<PageList<T>> {
36
36
  return this.gateway.byIds(...ids).then(j => asList(this.ctor, j));
37
37
  }
38
38
 
39
- byKey(key: Key): Promise<TotalList<T>> {
39
+ byKey(key: Key): Promise<PageList<T>> {
40
40
  return this.gateway.by('key', key).then(js => js.map(j => new this.ctor(j)));
41
41
  }
42
42
 
43
- by(key: keyof T, value: JsonValue): Promise<TotalList<T>> {
43
+ by(key: keyof T, value: JsonValue): Promise<PageList<T>> {
44
44
  return this.gateway.by(key.toString(), value).then(js => js.map(j => new this.ctor(j)));
45
45
  }
46
46
 
47
- search(q: JsonValue): Promise<TotalList<T>> {
47
+ search(q: JsonValue): Promise<PageList<T>> {
48
48
  return this.gateway.search(q).then(js => js.map(j => new this.ctor(j)));
49
49
  }
50
50
 
@@ -1,20 +1,20 @@
1
1
  import { Repo, Struct } from '../domain';
2
- import { choose, Id, isNotEmpty, JsonValue, Key, toList, TotalList } from '../types';
2
+ import { choose, Id, isNotEmpty, JsonValue, Key, toList, PageList } from '../types';
3
3
  import { resolve } from '../utils';
4
4
 
5
5
  export class Search<T extends Struct> {
6
6
  constructor(protected repo: Repo<T>) {
7
7
  }
8
8
 
9
- all = (): Promise<TotalList<T>> => this.repo.all();
9
+ all = (): Promise<PageList<T>> => this.repo.all();
10
10
 
11
11
  byId = (id: Id): Promise<T> => this.repo.byId(id);
12
12
 
13
- byIds = (...ids: Id[]): Promise<TotalList<T>> => this.repo.byIds(...ids);
13
+ byIds = (...ids: Id[]): Promise<PageList<T>> => this.repo.byIds(...ids);
14
14
 
15
- byKey = (key: Key): Promise<TotalList<T>> => this.repo.byKey(key);
15
+ byKey = (key: Key): Promise<PageList<T>> => this.repo.byKey(key);
16
16
 
17
- search = (query: JsonValue): Promise<TotalList<T>> =>
17
+ search = (query: JsonValue): Promise<PageList<T>> =>
18
18
  choose(query)
19
19
  .case(isNotEmpty, q => this.repo.search(q))
20
20
  .else(resolve(toList<T>()));
@@ -1,5 +1,5 @@
1
1
  import { Api } from './Api';
2
- import { Func, Gateway, Id, Json, JsonValue, TotalList, toTotalList, Uri } from '../types';
2
+ import { Func, Gateway, Id, Json, JsonValue, PageList, toPageList, Uri } from '../types';
3
3
  import { HttpStatus, RequestOptions } from '../http';
4
4
 
5
5
  export class RouteGateway extends Gateway {
@@ -7,15 +7,15 @@ export class RouteGateway extends Gateway {
7
7
  super();
8
8
  }
9
9
 
10
- get(uri: Uri, options?: RequestOptions): Promise<TotalList<Json>> {
11
- return this.api.get(uri, options).then(r => toTotalList<Json>(r.body.data?.items, r.body.data?.totalItems));
10
+ get(uri: Uri, options?: RequestOptions): Promise<PageList<Json>> {
11
+ return this.api.get(uri, options).then(r => toPageList<Json>(r.body.data?.items, {total: r.body.data?.totalItems}));
12
12
  }
13
13
 
14
14
  getOne(uri: Uri, options?: RequestOptions): Promise<Json | undefined> {
15
15
  return this.get(uri, options).then(r => r.first());
16
16
  }
17
17
 
18
- all(): Promise<TotalList<Json>> {
18
+ all(): Promise<PageList<Json>> {
19
19
  return this.get(this.route());
20
20
  }
21
21
 
@@ -23,7 +23,7 @@ export class RouteGateway extends Gateway {
23
23
  return this.getOne(this.routeId().id(id));
24
24
  }
25
25
 
26
- search(q: JsonValue): Promise<TotalList<Json>> {
26
+ search(q: JsonValue): Promise<PageList<Json>> {
27
27
  return this.get(this.route().query(q));
28
28
  }
29
29
 
@@ -2,10 +2,11 @@ import { Json, JsonValue } from './Json';
2
2
  import { Id } from './Id';
3
3
  import { Exception } from './Exception';
4
4
  import { reject } from '../utils';
5
- import { TotalList } from './TotalList';
5
+ import { PageList, PageOptions } from './PageList';
6
6
 
7
7
  export abstract class Gateway {
8
- all(): Promise<TotalList<Json>> {
8
+
9
+ all(options?: PageOptions): Promise<PageList<Json>> {
9
10
  return reject(Exception.IsNotImplemented);
10
11
  }
11
12
 
@@ -13,15 +14,15 @@ export abstract class Gateway {
13
14
  return reject(Exception.IsNotImplemented);
14
15
  }
15
16
 
16
- by(key: string, value: JsonValue): Promise<TotalList<Json>> {
17
+ by(_key: string, _value: JsonValue, _options?: PageOptions): Promise<PageList<Json>> {
17
18
  return reject(Exception.IsNotImplemented);
18
19
  }
19
20
 
20
- byIds(...ids: Id[]): Promise<TotalList<Json>> {
21
+ byIds(..._ids: Id[]): Promise<PageList<Json>> {
21
22
  return reject(Exception.IsNotImplemented);
22
23
  }
23
24
 
24
- search(q: JsonValue): Promise<TotalList<Json>> {
25
+ search(q: JsonValue, options?: PageOptions): Promise<PageList<Json>> {
25
26
  return reject(Exception.IsNotImplemented);
26
27
  }
27
28
 
@@ -0,0 +1,13 @@
1
+ import { List, toList } from './List';
2
+
3
+ export type PageOptions = { take?: number, skip?: number, total?: number };
4
+
5
+ export type PageList<T> = List<T> & PageOptions;
6
+
7
+ export const toPageList = <T>(items?: T[], options: PageOptions = {take: 250, skip: 0}): PageList<T> => {
8
+ const list = toList<T>(...items ?? []) as any;
9
+ list.take = options.take;
10
+ list.skip = options.skip;
11
+ list.total = options.total;
12
+ return list;
13
+ };
@@ -25,7 +25,7 @@ export * from './Results';
25
25
  export * from './Tag';
26
26
  export * from './Template';
27
27
  export * from './Text';
28
- export * from './TotalList';
28
+ export * from './PageList';
29
29
  export * from './Try';
30
30
  export * from './Uri';
31
31
  export * from './Uuid';
@@ -1,5 +0,0 @@
1
- import { List } from './List';
2
- export declare type TotalList<T> = List<T> & {
3
- total?: number;
4
- };
5
- export declare const toTotalList: <T>(items?: T[] | undefined, total?: number | undefined) => TotalList<T>;
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.toTotalList = void 0;
4
- const List_1 = require("./List");
5
- const toTotalList = (items, total) => {
6
- const list = (0, List_1.toList)(...items ?? []);
7
- list.total = total;
8
- return list;
9
- };
10
- exports.toTotalList = toTotalList;
11
- //# sourceMappingURL=TotalList.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TotalList.js","sourceRoot":"","sources":["../../src/types/TotalList.ts"],"names":[],"mappings":";;;AAAA,iCAAsC;AAI/B,MAAM,WAAW,GAAG,CAAI,KAAW,EAAE,KAAc,EAAgB,EAAE;IAC1E,MAAM,IAAI,GAAG,IAAA,aAAM,EAAI,GAAG,KAAK,IAAI,EAAE,CAAC,CAAC;IACtC,IAAY,CAAC,KAAK,GAAG,KAAK,CAAC;IAC5B,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAJW,QAAA,WAAW,eAItB"}
@@ -1,9 +0,0 @@
1
- import { List, toList } from './List';
2
-
3
- export type TotalList<T> = List<T> & { total?: number };
4
-
5
- export const toTotalList = <T>(items?: T[], total?: number): TotalList<T> => {
6
- const list = toList<T>(...items ?? []);
7
- (list as any).total = total;
8
- return list;
9
- };