@thisisagile/easy 12.19.0 → 12.19.2

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,9 +1,6 @@
1
1
  import { List } from './List';
2
2
  import { Construct } from './Constructor';
3
- export declare type Sort = {
4
- key: string;
5
- value: -1 | 1;
6
- };
3
+ import { PlainSort, Sort } from './Sort';
7
4
  export declare type FilterValue = {
8
5
  label?: string;
9
6
  value: any;
@@ -20,6 +17,7 @@ export declare type PageOptions = {
20
17
  take?: number;
21
18
  skip?: number;
22
19
  sort?: Sort[];
20
+ sorts?: PlainSort;
23
21
  filters?: Filter[];
24
22
  };
25
23
  export declare type PageList<T> = List<T> & Omit<PageOptions, 'sort'> & {
@@ -14,14 +14,13 @@ const toShortFilter = (field, shortField, value) => ({
14
14
  exports.toShortFilter = toShortFilter;
15
15
  const isPageList = (l) => (0, List_1.isList)(l) && (0, IsA_1.isA)(l, 'total');
16
16
  exports.isPageList = isPageList;
17
- const toPageList = (items, options) => {
18
- const list = (0, List_1.toList)(...(items ?? []));
19
- list.take = options?.take ?? 250;
20
- list.skip = options?.skip ?? 0;
21
- list.total = options?.total;
22
- list.filters = options?.filters;
23
- return list;
24
- };
17
+ const toPageList = (items, options) => (0, Constructor_1.on)((0, List_1.toList)(...(items ?? [])), l => {
18
+ l.take = options?.take ?? 250;
19
+ l.skip = options?.skip ?? 0;
20
+ l.total = options?.total;
21
+ l.sorts = options?.sorts;
22
+ l.filters = options?.filters;
23
+ });
25
24
  exports.toPageList = toPageList;
26
25
  const asPageList = (c, items = (0, exports.toPageList)()) => (0, exports.toPageList)(items.map(i => (0, Constructor_1.ofConstruct)(c, i)), items);
27
26
  exports.asPageList = asPageList;
@@ -1 +1 @@
1
- {"version":3,"file":"PageList.js","sourceRoot":"","sources":["../../src/types/PageList.ts"],"names":[],"mappings":";;;AAAA,iCAA8C;AAC9C,+CAAuD;AACvD,+BAA4B;AAOrB,MAAM,QAAQ,GAAG,C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kBAAU,EACR,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,IAAA,yBAAW,EAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EACjC,KAAK,CACN,CAAC;AAJS,QAAA,UAAU,cAInB"}
@@ -0,0 +1,8 @@
1
+ export declare const asc = 1;
2
+ export declare const desc = -1;
3
+ export declare type SortDirection = typeof asc | typeof desc;
4
+ export declare type Sort = {
5
+ key: string;
6
+ value: SortDirection;
7
+ };
8
+ export declare type PlainSort = Record<string, SortDirection>;
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.desc = exports.asc = void 0;
4
+ exports.asc = 1;
5
+ exports.desc = -1;
6
+ //# sourceMappingURL=Sort.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Sort.js","sourceRoot":"","sources":["../../src/types/Sort.ts"],"names":[],"mappings":";;;AAAa,QAAA,GAAG,GAAG,CAAC,CAAC;AACR,QAAA,IAAI,GAAG,CAAC,CAAC,CAAC"}
@@ -24,14 +24,15 @@ export * from './Message';
24
24
  export * from './Meta';
25
25
  export * from './Nullish';
26
26
  export * from './Number';
27
+ export * from './PageList';
27
28
  export * from './Primitive';
28
29
  export * from './Repository';
29
30
  export * from './Result';
30
31
  export * from './Results';
32
+ export * from './Sort';
31
33
  export * from './Tag';
32
34
  export * from './Template';
33
35
  export * from './Text';
34
- export * from './PageList';
35
36
  export * from './Try';
36
37
  export * from './Types';
37
38
  export * from './Uri';
@@ -39,3 +40,8 @@ export * from './Uuid';
39
40
  export * from './Validatable';
40
41
  export * from './Value';
41
42
  export { isPrimitive } from './Primitive';
43
+ export { PlainSort } from "./Sort";
44
+ export { Sort } from "./Sort";
45
+ export { SortDirection } from "./Sort";
46
+ export { desc } from "./Sort";
47
+ export { asc } from "./Sort";
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.isPrimitive = void 0;
17
+ exports.asc = exports.desc = exports.isPrimitive = void 0;
18
18
  __exportStar(require("./Array"), exports);
19
19
  __exportStar(require("./Builder"), exports);
20
20
  __exportStar(require("./Cache"), exports);
@@ -41,14 +41,15 @@ __exportStar(require("./Message"), exports);
41
41
  __exportStar(require("./Meta"), exports);
42
42
  __exportStar(require("./Nullish"), exports);
43
43
  __exportStar(require("./Number"), exports);
44
+ __exportStar(require("./PageList"), exports);
44
45
  __exportStar(require("./Primitive"), exports);
45
46
  __exportStar(require("./Repository"), exports);
46
47
  __exportStar(require("./Result"), exports);
47
48
  __exportStar(require("./Results"), exports);
49
+ __exportStar(require("./Sort"), exports);
48
50
  __exportStar(require("./Tag"), exports);
49
51
  __exportStar(require("./Template"), exports);
50
52
  __exportStar(require("./Text"), exports);
51
- __exportStar(require("./PageList"), exports);
52
53
  __exportStar(require("./Try"), exports);
53
54
  __exportStar(require("./Types"), exports);
54
55
  __exportStar(require("./Uri"), exports);
@@ -57,4 +58,8 @@ __exportStar(require("./Validatable"), exports);
57
58
  __exportStar(require("./Value"), exports);
58
59
  var Primitive_1 = require("./Primitive");
59
60
  Object.defineProperty(exports, "isPrimitive", { enumerable: true, get: function () { return Primitive_1.isPrimitive; } });
61
+ var Sort_1 = require("./Sort");
62
+ Object.defineProperty(exports, "desc", { enumerable: true, get: function () { return Sort_1.desc; } });
63
+ var Sort_2 = require("./Sort");
64
+ Object.defineProperty(exports, "asc", { enumerable: true, get: function () { return Sort_2.asc; } });
60
65
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,0CAAwB;AACxB,4CAA0B;AAC1B,0CAAwB;AACxB,6CAA2B;AAC3B,yCAAuB;AACvB,gDAA8B;AAC9B,4CAA0B;AAC1B,yCAAuB;AACvB,gDAA8B;AAC9B,8CAA4B;AAC5B,0CAAwB;AACxB,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,4CAA0B;AAC1B,2CAAyB;AACzB,8CAA4B;AAC5B,+CAA6B;AAC7B,2CAAyB;AACzB,4CAA0B;AAC1B,wCAAsB;AACtB,6CAA2B;AAC3B,yCAAuB;AACvB,6CAA2B;AAC3B,wCAAsB;AACtB,0CAAwB;AACxB,wCAAsB;AACtB,yCAAuB;AACvB,gDAA8B;AAC9B,0CAAwB;AACxB,yCAA0C;AAAjC,wGAAA,WAAW,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,0CAAwB;AACxB,4CAA0B;AAC1B,0CAAwB;AACxB,6CAA2B;AAC3B,yCAAuB;AACvB,gDAA8B;AAC9B,4CAA0B;AAC1B,yCAAuB;AACvB,gDAA8B;AAC9B,8CAA4B;AAC5B,0CAAwB;AACxB,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,4CAA0B;AAC1B,2CAAyB;AACzB,6CAA2B;AAC3B,8CAA4B;AAC5B,+CAA6B;AAC7B,2CAAyB;AACzB,4CAA0B;AAC1B,yCAAuB;AACvB,wCAAsB;AACtB,6CAA2B;AAC3B,yCAAuB;AACvB,wCAAsB;AACtB,0CAAwB;AACxB,wCAAsB;AACtB,yCAAuB;AACvB,gDAA8B;AAC9B,0CAAwB;AACxB,yCAA0C;AAAjC,wGAAA,WAAW,OAAA;AAIpB,+BAA8B;AAArB,4FAAA,IAAI,OAAA;AACb,+BAA6B;AAApB,2FAAA,GAAG,OAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thisisagile/easy",
3
- "version": "12.19.0",
3
+ "version": "12.19.2",
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": "12.19.0",
34
+ "@thisisagile/easy-test": "12.19.2",
35
35
  "@types/form-urlencoded": "^4.4.0",
36
36
  "@types/jsonwebtoken": "^8.5.9",
37
37
  "@types/luxon": "3.1.0",
@@ -1,8 +1,7 @@
1
1
  import { isList, List, toList } from './List';
2
- import { Construct, ofConstruct } from './Constructor';
2
+ import { Construct, ofConstruct, on } from './Constructor';
3
3
  import { isA } from './IsA';
4
-
5
- export type Sort = { key: string; value: -1 | 1 };
4
+ import { PlainSort, Sort } from './Sort';
6
5
 
7
6
  export type FilterValue = { label?: string; value: any };
8
7
  export type Filter = { label?: string; field: string; shortField?: string; values: FilterValue[] };
@@ -14,19 +13,19 @@ export const toShortFilter = (field: string, shortField: string, value: any): Fi
14
13
  values: [{ value }],
15
14
  });
16
15
 
17
- export type PageOptions = { take?: number; skip?: number; sort?: Sort[]; filters?: Filter[] };
16
+ export type PageOptions = { take?: number; skip?: number; sort?: Sort[]; sorts?: PlainSort; filters?: Filter[] };
18
17
  export type PageList<T> = List<T> & Omit<PageOptions, 'sort'> & { total?: number };
19
18
 
20
19
  export const isPageList = <T>(l?: T[]): l is PageList<T> => isList<T>(l) && isA(l, 'total');
21
20
 
22
- export const toPageList = <T>(items?: T[], options?: Omit<PageOptions, 'sort'> & { total?: number }): PageList<T> => {
23
- const list = toList<T>(...(items ?? [])) as PageList<T>;
24
- list.take = options?.take ?? 250;
25
- list.skip = options?.skip ?? 0;
26
- list.total = options?.total;
27
- list.filters = options?.filters;
28
- return list;
29
- };
21
+ export const toPageList = <T>(items?: T[], options?: Omit<PageOptions, 'sort'> & { total?: number }): PageList<T> =>
22
+ on(toList<T>(...(items ?? [])) as PageList<T>, l => {
23
+ l.take = options?.take ?? 250;
24
+ l.skip = options?.skip ?? 0;
25
+ l.total = options?.total;
26
+ l.sorts = options?.sorts;
27
+ l.filters = options?.filters;
28
+ });
30
29
 
31
30
  export const asPageList = <T, U>(c: Construct<T>, items = toPageList<U>()): PageList<T> =>
32
31
  toPageList<T>(
@@ -0,0 +1,5 @@
1
+ export const asc = 1;
2
+ export const desc = -1;
3
+ export type SortDirection = typeof asc | typeof desc;
4
+ export type Sort = { key: string; value: SortDirection };
5
+ export type PlainSort = Record<string, SortDirection>;
@@ -24,14 +24,15 @@ export * from './Message';
24
24
  export * from './Meta';
25
25
  export * from './Nullish';
26
26
  export * from './Number';
27
+ export * from './PageList';
27
28
  export * from './Primitive';
28
29
  export * from './Repository';
29
30
  export * from './Result';
30
31
  export * from './Results';
32
+ export * from './Sort';
31
33
  export * from './Tag';
32
34
  export * from './Template';
33
35
  export * from './Text';
34
- export * from './PageList';
35
36
  export * from './Try';
36
37
  export * from './Types';
37
38
  export * from './Uri';
@@ -39,3 +40,8 @@ export * from './Uuid';
39
40
  export * from './Validatable';
40
41
  export * from './Value';
41
42
  export { isPrimitive } from './Primitive';
43
+ export { PlainSort } from "./Sort";
44
+ export { Sort } from "./Sort";
45
+ export { SortDirection } from "./Sort";
46
+ export { desc } from "./Sort";
47
+ export { asc } from "./Sort";