@thisisagile/easy 8.41.19 → 8.42.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.
- package/dist/data/Field.d.ts +1 -1
- package/dist/data/Field.js.map +1 -1
- package/dist/domain/Child.d.ts +1 -1
- package/dist/domain/Child.js +1 -1
- package/dist/domain/Child.js.map +1 -1
- package/dist/domain/Entity.d.ts +1 -1
- package/dist/domain/Entity.js +1 -7
- package/dist/domain/Entity.js.map +1 -1
- package/dist/domain/Repo.d.ts +1 -0
- package/dist/domain/Repo.js +6 -2
- package/dist/domain/Repo.js.map +1 -1
- package/dist/domain/Struct.d.ts +1 -1
- package/dist/domain/Struct.js.map +1 -1
- package/dist/domain/enums/UnitOfMeasurement.js.map +1 -1
- package/dist/domain/structs/Address.js +1 -7
- package/dist/domain/structs/Address.js.map +1 -1
- package/dist/domain/structs/Box.js +1 -3
- package/dist/domain/structs/Box.js.map +1 -1
- package/dist/domain/structs/Dimension.js +1 -1
- package/dist/domain/structs/Dimension.js.map +1 -1
- package/dist/domain/structs/Money.js +2 -2
- package/dist/domain/structs/Money.js.map +1 -1
- package/dist/domain/structs/Weight.js +1 -1
- package/dist/domain/structs/Weight.js.map +1 -1
- package/dist/domain/values/DateTime.js +5 -2
- package/dist/domain/values/DateTime.js.map +1 -1
- package/dist/http/RestResult.js.map +1 -1
- package/dist/services/AxiosProvider.js.map +1 -1
- package/dist/types/Enum.js +3 -1
- package/dist/types/Enum.js.map +1 -1
- package/dist/types/Json.js +1 -1
- package/dist/types/Json.js.map +1 -1
- package/dist/types/List.js.map +1 -1
- package/dist/types/Number.js +4 -1
- package/dist/types/Number.js.map +1 -1
- package/dist/types/Text.js +4 -1
- package/dist/types/Text.js.map +1 -1
- package/dist/types/Value.d.ts +1 -1
- package/dist/types/Value.js.map +1 -1
- package/dist/utils/Case.js.map +1 -1
- package/dist/utils/Mapper.js.map +1 -1
- package/dist/utils/Promise.js.map +1 -1
- package/dist/utils/Traverse.js +1 -1
- package/dist/utils/Traverse.js.map +1 -1
- package/dist/utils/View.js +5 -3
- package/dist/utils/View.js.map +1 -1
- package/dist/validation/Validate.js.map +1 -1
- package/package.json +2 -2
- package/src/data/Field.ts +3 -3
- package/src/domain/Child.ts +2 -1
- package/src/domain/Entity.ts +3 -8
- package/src/domain/Repo.ts +12 -5
- package/src/domain/Struct.ts +1 -1
- package/src/domain/enums/UnitOfMeasurement.ts +1 -2
- package/src/domain/enums/UnitOfWeight.ts +1 -1
- package/src/domain/structs/Address.ts +2 -8
- package/src/domain/structs/Box.ts +1 -5
- package/src/domain/structs/Dimension.ts +3 -3
- package/src/domain/structs/Money.ts +2 -2
- package/src/domain/structs/Weight.ts +3 -3
- package/src/domain/values/DateTime.ts +34 -12
- package/src/http/RestResult.ts +3 -15
- package/src/services/AxiosProvider.ts +5 -3
- package/src/types/Enum.ts +6 -4
- package/src/types/Json.ts +4 -4
- package/src/types/List.ts +0 -1
- package/src/types/Number.ts +5 -1
- package/src/types/Text.ts +10 -5
- package/src/types/Value.ts +2 -2
- package/src/utils/Case.ts +1 -1
- package/src/utils/Mapper.ts +7 -8
- package/src/utils/Promise.ts +5 -3
- package/src/utils/Traverse.ts +1 -1
- package/src/utils/View.ts +12 -23
- package/src/validation/Validate.ts +1 -1
package/dist/utils/View.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"View.js","sourceRoot":"","sources":["../../src/utils/View.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"View.js","sourceRoot":"","sources":["../../src/utils/View.ts"],"names":[],"mappings":";;;AAAA,oCAA4H;AAC5H,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,EA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,IAAA,iBAAS,GAAE,CAAC,CAAC;KAChG,IAAI,CAAC,qBAAa,EAAE,CAAC,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;KACxC,IAAI,CAAC,IAAA,iBAAS,GAAE,CAAC,CAAC;AAPV,QAAA,QAAQ,YAOE;AAEhB,MAAM,cAAc,GAAG,CAAI,OAAU,EAAc,EAAE,CAAC,IAAA,WAAI,EAAC,OAAO,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;AAAnF,QAAA,cAAc,kBAAqE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thisisagile/easy",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.42.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": "8.
|
|
34
|
+
"@thisisagile/easy-test": "8.42.2",
|
|
35
35
|
"@types/form-urlencoded": "^4.4.0",
|
|
36
36
|
"@types/jsonwebtoken": "^8.5.8",
|
|
37
37
|
"@types/validator": "^13.7.1"
|
package/src/data/Field.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Property } from '../utils';
|
|
2
|
-
import { Condition, SortCondition, toCondition } from
|
|
2
|
+
import { Condition, SortCondition, toCondition } from './Condition';
|
|
3
3
|
import { toArray } from '../types';
|
|
4
4
|
|
|
5
5
|
export class Field extends Property {
|
|
@@ -21,9 +21,9 @@ export class Field extends Property {
|
|
|
21
21
|
|
|
22
22
|
lessEqual = (value: unknown): Condition => this.condition('lte', value);
|
|
23
23
|
|
|
24
|
-
asc = (): SortCondition => new SortCondition(this.property, -1)
|
|
24
|
+
asc = (): SortCondition => new SortCondition(this.property, -1);
|
|
25
25
|
|
|
26
|
-
desc = (): SortCondition => new SortCondition(this.property, 1)
|
|
26
|
+
desc = (): SortCondition => new SortCondition(this.property, 1);
|
|
27
27
|
|
|
28
28
|
protected condition = (operator: string, value: unknown): Condition => toCondition(this.property, operator, value, this.options?.convert);
|
|
29
29
|
}
|
package/src/domain/Child.ts
CHANGED
|
@@ -4,5 +4,6 @@ import { required } from '../validation';
|
|
|
4
4
|
|
|
5
5
|
export abstract class Child extends Struct {
|
|
6
6
|
@required() readonly id: Id = this.state.id ?? toId();
|
|
7
|
-
protected merge = (a:
|
|
7
|
+
protected merge = (a: unknown): Json => json.merge(this, a, { id: this.id });
|
|
8
|
+
// protected merge = (a: unknown): Json => json.parse({ ...this, ...{ a as any }, id: this.id });
|
|
8
9
|
}
|
package/src/domain/Entity.ts
CHANGED
|
@@ -8,12 +8,7 @@ export abstract class Entity extends Struct {
|
|
|
8
8
|
@required() readonly created: Audit = new Audit(this.state.created);
|
|
9
9
|
@required() readonly lastModified: Audit = new Audit(this.state.lastModified);
|
|
10
10
|
|
|
11
|
-
protected merge = (a:
|
|
12
|
-
json.
|
|
13
|
-
|
|
14
|
-
...a,
|
|
15
|
-
id: this.id,
|
|
16
|
-
created: this.created.toJSON(),
|
|
17
|
-
lastModified: new Audit().toJSON(),
|
|
18
|
-
});
|
|
11
|
+
protected merge = (a: unknown): Json =>
|
|
12
|
+
json.merge(this, a, { id: this.id, created: this.created.toJSON(), lastModified: new Audit().toJSON() });
|
|
13
|
+
|
|
19
14
|
}
|
package/src/domain/Repo.ts
CHANGED
|
@@ -4,7 +4,8 @@ import { reject, resolve } from '../utils';
|
|
|
4
4
|
import { Struct } from './Struct';
|
|
5
5
|
|
|
6
6
|
export class Repo<T extends Struct> {
|
|
7
|
-
constructor(protected ctor: Constructor<T>, private readonly gateway: Gateway) {
|
|
7
|
+
constructor(protected ctor: Constructor<T>, private readonly gateway: Gateway) {
|
|
8
|
+
}
|
|
8
9
|
|
|
9
10
|
all(): Promise<List<T>> {
|
|
10
11
|
return this.gateway.all().then(js => js.map(j => new this.ctor(j)));
|
|
@@ -34,8 +35,9 @@ export class Repo<T extends Struct> {
|
|
|
34
35
|
}
|
|
35
36
|
|
|
36
37
|
add(json: Json): Promise<T> {
|
|
37
|
-
|
|
38
|
-
|
|
38
|
+
|
|
39
|
+
return this.extend(new this.ctor(json))
|
|
40
|
+
.then(i => when(i).not.isValid.reject())
|
|
39
41
|
.then(i => this.validate(i))
|
|
40
42
|
.then(i => this.gateway.add(toJson(i)))
|
|
41
43
|
.then(j => new this.ctor(j));
|
|
@@ -45,8 +47,9 @@ export class Repo<T extends Struct> {
|
|
|
45
47
|
return this.gateway
|
|
46
48
|
.byId(id)
|
|
47
49
|
.then(j => when(j).not.isDefined.reject(Exception.DoesNotExist))
|
|
48
|
-
.then(j => new this.ctor(j).update(json))
|
|
49
|
-
.then(i =>
|
|
50
|
+
.then(j => new this.ctor(j).update(json) as T)
|
|
51
|
+
.then(i => this.extend(i))
|
|
52
|
+
.then(i => when(i).not.isValid.reject())
|
|
50
53
|
.then(i => this.validate(i))
|
|
51
54
|
.then(i => this.gateway.update(toJson(i)))
|
|
52
55
|
.then(j => new this.ctor(j));
|
|
@@ -56,6 +59,10 @@ export class Repo<T extends Struct> {
|
|
|
56
59
|
return this.gateway.remove(id);
|
|
57
60
|
}
|
|
58
61
|
|
|
62
|
+
extend(item: T): Promise<T> {
|
|
63
|
+
return resolve(item);
|
|
64
|
+
}
|
|
65
|
+
|
|
59
66
|
validate(item: T): Promise<T> {
|
|
60
67
|
return resolve(item);
|
|
61
68
|
}
|
package/src/domain/Struct.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isEmpty,
|
|
1
|
+
import { isEmpty, text } from '../../types';
|
|
2
2
|
import { Struct } from '../Struct';
|
|
3
3
|
import { required, valid } from '../../validation';
|
|
4
4
|
import { Country } from '../enums';
|
|
@@ -13,13 +13,7 @@ export class Address extends Struct {
|
|
|
13
13
|
@required() readonly country = Country.byId<Country>(this.state.country);
|
|
14
14
|
|
|
15
15
|
toString(): string {
|
|
16
|
-
return text(this.street, '')
|
|
17
|
-
.add(this.houseNumber, ' ')
|
|
18
|
-
.add(this.extension, ' ')
|
|
19
|
-
.add(isNotEmpty(this.postalCode?.value) ? this.postalCode : undefined, ', ')
|
|
20
|
-
.add(this.city, ' ')
|
|
21
|
-
.add(this.country?.name, ' ')
|
|
22
|
-
.toString();
|
|
16
|
+
return text(this.street).with(' ', this.houseNumber, this.extension).with(', ', text(this.postalCode).with(' ', this.city, this.country?.name)).toString();
|
|
23
17
|
}
|
|
24
18
|
}
|
|
25
19
|
|
|
@@ -22,10 +22,6 @@ export class Box extends Struct {
|
|
|
22
22
|
|
|
23
23
|
fits = (contents: Box, qty = 1): boolean => {
|
|
24
24
|
const stackedContent = contents.stack(qty);
|
|
25
|
-
return this.lowestDim.gte(
|
|
26
|
-
this.medianDim.gte(stackedContent.medianDim) &&
|
|
27
|
-
this.maxDim.gte( stackedContent.maxDim);
|
|
25
|
+
return this.lowestDim.gte(stackedContent.lowestDim) && this.medianDim.gte(stackedContent.medianDim) && this.maxDim.gte(stackedContent.maxDim);
|
|
28
26
|
};
|
|
29
|
-
|
|
30
|
-
|
|
31
27
|
}
|
|
@@ -3,12 +3,12 @@ import { required } from '../../validation';
|
|
|
3
3
|
import { UnitOfMeasurement } from '../enums';
|
|
4
4
|
|
|
5
5
|
export class Dimension extends Struct {
|
|
6
|
-
@required() readonly value
|
|
7
|
-
readonly uom
|
|
6
|
+
@required() readonly value = this.state.value as number;
|
|
7
|
+
readonly uom = UnitOfMeasurement.byId<UnitOfMeasurement>(this.state.uom, UnitOfMeasurement.MM);
|
|
8
8
|
|
|
9
9
|
static with = (value: number, uom: UnitOfMeasurement = UnitOfMeasurement.MM) => new Dimension({ value, uom });
|
|
10
10
|
|
|
11
11
|
sizeInMM = (): number => this.value * this.uom.mmMultiplier;
|
|
12
12
|
|
|
13
13
|
gte = (dim: Dimension): boolean => this.sizeInMM() >= dim.sizeInMM();
|
|
14
|
-
}
|
|
14
|
+
}
|
|
@@ -4,8 +4,8 @@ import { Currency } from '../enums';
|
|
|
4
4
|
import { isEmpty } from '../../types';
|
|
5
5
|
|
|
6
6
|
export class Money extends Struct {
|
|
7
|
-
@required() readonly currency
|
|
8
|
-
@required() readonly value
|
|
7
|
+
@required() readonly currency = Currency.byId<Currency>(this.state.currency);
|
|
8
|
+
@required() readonly value = this.state.value as number;
|
|
9
9
|
|
|
10
10
|
add = (amount: number): Money => money(this.currency, this.value + amount);
|
|
11
11
|
subtract = (amount: number): Money => money(this.currency, this.value - amount);
|
|
@@ -3,8 +3,8 @@ import { required } from '../../validation';
|
|
|
3
3
|
import { Struct } from '../Struct';
|
|
4
4
|
|
|
5
5
|
export class Weight extends Struct {
|
|
6
|
-
@required() readonly value
|
|
7
|
-
readonly uow
|
|
6
|
+
@required() readonly value = this.state.value as number;
|
|
7
|
+
readonly uow = UnitOfWeight.byId<UnitOfWeight>(this.state.uow, UnitOfWeight.G);
|
|
8
8
|
sizeInG = (): number => this.value * this.uow.gMultiplier;
|
|
9
9
|
|
|
10
10
|
gte = (w: Weight): boolean => this.sizeInG() >= w.sizeInG();
|
|
@@ -16,4 +16,4 @@ export class Weight extends Struct {
|
|
|
16
16
|
sum = (add: Weight): Weight => weight((this.sizeInG() + add.sizeInG()) / this.uow.gMultiplier, this.uow);
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
export const weight = (value: number, uow?: UnitOfWeight): Weight => new Weight({ value, uow });
|
|
19
|
+
export const weight = (value: number, uow?: UnitOfWeight): Weight => new Weight({ value, uow });
|
|
@@ -4,20 +4,42 @@ import { ifNotEmpty } from '../../utils';
|
|
|
4
4
|
import 'moment/min/locales';
|
|
5
5
|
|
|
6
6
|
export type DateTimeUnit =
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
7
|
+
| 'year'
|
|
8
|
+
| 'years'
|
|
9
|
+
| 'y'
|
|
10
|
+
| 'quarter'
|
|
11
|
+
| 'quarters'
|
|
12
|
+
| 'Q'
|
|
13
|
+
| 'month'
|
|
14
|
+
| 'months'
|
|
15
|
+
| 'M'
|
|
16
|
+
| 'week'
|
|
17
|
+
| 'weeks'
|
|
18
|
+
| 'w'
|
|
19
|
+
| 'day'
|
|
20
|
+
| 'days'
|
|
21
|
+
| 'd'
|
|
22
|
+
| 'hour'
|
|
23
|
+
| 'hours'
|
|
24
|
+
| 'h'
|
|
25
|
+
| 'minute'
|
|
26
|
+
| 'minutes'
|
|
27
|
+
| 'm'
|
|
28
|
+
| 'second'
|
|
29
|
+
| 'seconds'
|
|
30
|
+
| 's'
|
|
31
|
+
| 'millisecond'
|
|
32
|
+
| 'milliseconds'
|
|
33
|
+
| 'ms';
|
|
17
34
|
|
|
18
35
|
export class DateTime extends Value<string | undefined> {
|
|
19
36
|
constructor(value?: string | number | Date, format?: string) {
|
|
20
|
-
super(
|
|
37
|
+
super(
|
|
38
|
+
tryTo(value)
|
|
39
|
+
.is.defined()
|
|
40
|
+
.map(v => moment.utc(v, format, true).toISOString())
|
|
41
|
+
.orElse()
|
|
42
|
+
);
|
|
21
43
|
}
|
|
22
44
|
|
|
23
45
|
static get now(): DateTime {
|
|
@@ -40,7 +62,7 @@ export class DateTime extends Value<string | undefined> {
|
|
|
40
62
|
from(date?: DateTime, locales?: string | string[]): string;
|
|
41
63
|
from(param?: string | string[] | DateTime, other?: string | string[]): string {
|
|
42
64
|
const date: DateTime | undefined = isA<DateTime>(param) ? param : undefined;
|
|
43
|
-
const locales: string | string[] = isString(param) || isArray<string>(param) ? param :
|
|
65
|
+
const locales: string | string[] = isString(param) || isArray<string>(param) ? param : isString(other) || isArray<string>(other) ? other : 'en';
|
|
44
66
|
return isDefined(date) ? this.utc.locale(locales).from(date.utc) : this.utc.locale(locales).fromNow();
|
|
45
67
|
}
|
|
46
68
|
|
package/src/http/RestResult.ts
CHANGED
|
@@ -1,16 +1,4 @@
|
|
|
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';
|
|
1
|
+
import { Id, isDefined, isError, isResult, isResults, isUndefined, Json, List, Result, toList, toResult } from '../types';
|
|
14
2
|
import { choose } from '../utils';
|
|
15
3
|
import { HttpStatus, isHttpStatus } from './HttpStatus';
|
|
16
4
|
import { isResponse } from './Response';
|
|
@@ -20,8 +8,8 @@ export type RestResult = {
|
|
|
20
8
|
error?: { code: number; message: string; errorCount: number; errors: List<Result> };
|
|
21
9
|
};
|
|
22
10
|
|
|
23
|
-
const hasErrors = (a: any): a is { error: { code: number
|
|
24
|
-
const hasItems = (a: any): a is { data: { code: number
|
|
11
|
+
const hasErrors = (a: any): a is { error: { code: number; errors: List<Result> } } => isDefined(a?.error?.errors);
|
|
12
|
+
const hasItems = (a: any): a is { data: { code: number; items: List<Json> } } => isDefined(a?.data.items);
|
|
25
13
|
|
|
26
14
|
export const rest = {
|
|
27
15
|
toData: (status: HttpStatus, items: Json[] = []): RestResult => ({
|
|
@@ -3,12 +3,14 @@ import { HttpStatus, HttpVerb, isRestResult, Request, RequestOptions, RequestPro
|
|
|
3
3
|
import { ctx, isDefined, isEmpty, toResult, Uri } from '../types';
|
|
4
4
|
import { choose } from '../utils';
|
|
5
5
|
|
|
6
|
-
const isResponse = (a: unknown): a is {response: AxiosResponse} => isDefined((a as any)?.response);
|
|
7
|
-
const isRequest = (a: unknown): a is {request: any} => isDefined((a as any)?.request);
|
|
6
|
+
const isResponse = (a: unknown): a is { response: AxiosResponse } => isDefined((a as any)?.response);
|
|
7
|
+
const isRequest = (a: unknown): a is { request: any } => isDefined((a as any)?.request);
|
|
8
8
|
|
|
9
9
|
const asResponse = (uri: Uri, verb: HttpVerb, error: AxiosError): Response =>
|
|
10
10
|
choose<Response, AxiosError>(error)
|
|
11
|
-
.type(isResponse, r =>
|
|
11
|
+
.type(isResponse, r =>
|
|
12
|
+
toResponse(r.response.status, isRestResult(r.response.data) ? r.response.data : toResult(r.response.statusText, uri.path, uri), r.response.headers)
|
|
13
|
+
)
|
|
12
14
|
.type(isRequest, r => toResponse(r.request.status, toResult(r.request.message, uri.path, uri)))
|
|
13
15
|
.else(e => toResponse(HttpStatus.InternalServerError, toResult(e.message, uri.path, uri)));
|
|
14
16
|
|
package/src/types/Enum.ts
CHANGED
|
@@ -38,15 +38,17 @@ export abstract class Enum implements Validatable {
|
|
|
38
38
|
return this.all<E>().filter(p, params);
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
static first<E extends Enum>(p?: (value: E, index: number, array: E[]) => unknown, params?: unknown)
|
|
42
|
-
return
|
|
43
|
-
}
|
|
41
|
+
static first<E extends Enum>(p?: (value: E, index: number, array: E[]) => unknown, params?: unknown): E {
|
|
42
|
+
return this.all<E>().first(p, params);
|
|
43
|
+
}
|
|
44
44
|
|
|
45
45
|
equals<E extends Enum | Id>(other: E): boolean {
|
|
46
46
|
return this.id === (isEnum(other) ? other.id : other);
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
isIn<E extends Enum>(...items: E[]): boolean {
|
|
49
|
+
isIn<E extends Enum>(...items: E[]): boolean {
|
|
50
|
+
return items.some(i => i.equals(this));
|
|
51
|
+
}
|
|
50
52
|
|
|
51
53
|
toJSON(): JsonValue {
|
|
52
54
|
return this.id;
|
package/src/types/Json.ts
CHANGED
|
@@ -14,7 +14,8 @@ export const json = {
|
|
|
14
14
|
delete (subject as any)[key];
|
|
15
15
|
return subject as Json;
|
|
16
16
|
},
|
|
17
|
-
set: (subject: unknown, key = '', value?: unknown): Json =>
|
|
17
|
+
set: (subject: unknown, key = '', value?: unknown): Json =>
|
|
18
|
+
isEmpty(key) ? subject : isDefined(value) ? { ...(subject as any), ...{ [key]: value as Json } } : json.delete(subject, key),
|
|
18
19
|
omit: (subject: unknown, ...keys: string[]): Json => keys.reduce((js, k) => json.delete(js, k), json.parse(subject)),
|
|
19
20
|
};
|
|
20
21
|
|
|
@@ -23,11 +24,10 @@ export const toJson = json.merge;
|
|
|
23
24
|
export const asJson = (j?: unknown, alt: Get<Json> = {}): Json => (isJson(j) ? j.toJSON() : isObject(j) ? (j as Json) : ofGet(alt, j));
|
|
24
25
|
|
|
25
26
|
class Any {
|
|
26
|
-
constructor(readonly value: unknown = {}) {
|
|
27
|
-
}
|
|
27
|
+
constructor(readonly value: unknown = {}) {}
|
|
28
28
|
|
|
29
29
|
delete = (key: string): Any => new Any(json.delete(this.value, key));
|
|
30
30
|
set = (key: string, value?: unknown): Any => new Any(json.set(this.value, key, value));
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
export const any = (value: unknown): Any => new Any(value);
|
|
33
|
+
export const any = (value: unknown): Any => new Any(value);
|
package/src/types/List.ts
CHANGED
|
@@ -7,7 +7,6 @@ import { GetProperty, ofProperty } from './Get';
|
|
|
7
7
|
import { Id } from './Id';
|
|
8
8
|
import { asString } from './Text';
|
|
9
9
|
|
|
10
|
-
|
|
11
10
|
export class List<T = unknown> extends Array<T> {
|
|
12
11
|
asc = (p: GetProperty<T, any>): List<T> => this.sort((e1, e2) => (ofProperty(e1, p) > ofProperty(e2, p) ? 1 : -1));
|
|
13
12
|
|
package/src/types/Number.ts
CHANGED
|
@@ -3,4 +3,8 @@ import { tryTo } from './Try';
|
|
|
3
3
|
import { isNumber } from './Is';
|
|
4
4
|
import { asString } from './Text';
|
|
5
5
|
|
|
6
|
-
export const asNumber = (n: unknown, alt?: Get<number>): number =>
|
|
6
|
+
export const asNumber = (n: unknown, alt?: Get<number>): number =>
|
|
7
|
+
tryTo(() => asString(n))
|
|
8
|
+
.map(s => parseInt(s))
|
|
9
|
+
.filter(n => isNumber(n))
|
|
10
|
+
.or(ofGet(alt) ?? NaN);
|
package/src/types/Text.ts
CHANGED
|
@@ -14,8 +14,7 @@ export const asString = (t?: unknown, alt: Get<Text> = ''): string => (isText(t)
|
|
|
14
14
|
export const replaceAll = (origin: Text, search: Text, replace: Text = ''): string => asString(origin).split(asString(search)).join(asString(replace));
|
|
15
15
|
|
|
16
16
|
export class ToText implements Text {
|
|
17
|
-
constructor(readonly subject: string) {
|
|
18
|
-
}
|
|
17
|
+
constructor(readonly subject: string) {}
|
|
19
18
|
|
|
20
19
|
get cap(): ToText {
|
|
21
20
|
return this.map(s => s.charAt(0).toUpperCase() + s.slice(1).toLowerCase());
|
|
@@ -26,7 +25,7 @@ export class ToText implements Text {
|
|
|
26
25
|
s
|
|
27
26
|
.split(' ')
|
|
28
27
|
.map(w => text(w).cap)
|
|
29
|
-
.join(' ')
|
|
28
|
+
.join(' ')
|
|
30
29
|
);
|
|
31
30
|
}
|
|
32
31
|
|
|
@@ -71,7 +70,7 @@ export class ToText implements Text {
|
|
|
71
70
|
s
|
|
72
71
|
.split(' ')
|
|
73
72
|
.map(w => w[0])
|
|
74
|
-
.join('')
|
|
73
|
+
.join('')
|
|
75
74
|
);
|
|
76
75
|
}
|
|
77
76
|
|
|
@@ -107,7 +106,13 @@ export class ToText implements Text {
|
|
|
107
106
|
|
|
108
107
|
add = (add?: unknown, separator = ''): ToText => this.map(s => (isNotEmpty(add) ? `${s}${separator}${text(add)}` : s));
|
|
109
108
|
|
|
110
|
-
with = (separator: string, ...other: unknown[]): ToText =>
|
|
109
|
+
with = (separator: string, ...other: unknown[]): ToText =>
|
|
110
|
+
this.map(s =>
|
|
111
|
+
toList(s)
|
|
112
|
+
.add(...other.map(u => text(u).toString()))
|
|
113
|
+
.filter(s => isNotEmpty(s))
|
|
114
|
+
.join(separator)
|
|
115
|
+
);
|
|
111
116
|
|
|
112
117
|
toString(): string {
|
|
113
118
|
return this.subject;
|
package/src/types/Value.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { asString, isDefined, JsonValue, Validatable } from './index';
|
|
2
2
|
|
|
3
|
-
export class Value<V
|
|
3
|
+
export class Value<V = string> implements Validatable {
|
|
4
4
|
constructor(readonly value: V) {
|
|
5
5
|
this.value = value;
|
|
6
6
|
}
|
|
@@ -10,7 +10,7 @@ export class Value<V extends unknown = string> implements Validatable {
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
toJSON(): JsonValue {
|
|
13
|
-
return this.value as JsonValue;
|
|
13
|
+
return this.value as unknown as JsonValue;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
toString(): string {
|
package/src/utils/Case.ts
CHANGED
package/src/utils/Mapper.ts
CHANGED
|
@@ -25,7 +25,7 @@ export class Mapper extends State implements Mapping {
|
|
|
25
25
|
return this.get('props', () =>
|
|
26
26
|
meta(this)
|
|
27
27
|
.entries<Mapping>()
|
|
28
|
-
.filter(([, v]) => isMapping(v))
|
|
28
|
+
.filter(([, v]) => isMapping(v))
|
|
29
29
|
);
|
|
30
30
|
}
|
|
31
31
|
|
|
@@ -51,9 +51,8 @@ export class Mapper extends State implements Mapping {
|
|
|
51
51
|
|
|
52
52
|
public in(from: Json = {}): Json {
|
|
53
53
|
return json.omit(
|
|
54
|
-
this.properties.reduce((a, [k, p]) => json.merge(a, { [k]: p.in({ ...a, ...from }) }),
|
|
55
|
-
|
|
56
|
-
...this.droppedIn,
|
|
54
|
+
this.properties.reduce((a, [k, p]) => json.merge(a, { [k]: p.in({ ...a, ...from }) }), this.options.startFrom === 'source' ? from : {}),
|
|
55
|
+
...this.droppedIn
|
|
57
56
|
);
|
|
58
57
|
}
|
|
59
58
|
|
|
@@ -61,9 +60,9 @@ export class Mapper extends State implements Mapping {
|
|
|
61
60
|
return json.omit(
|
|
62
61
|
this.properties.reduce(
|
|
63
62
|
(a, [k, p]) => json.merge(a, isEmpty(p.property) ? p.out(to, k) : { [p.property ?? '']: p.out({ ...a, ...to }, k) }),
|
|
64
|
-
this.options.startFrom === 'source' ? to : {}
|
|
63
|
+
this.options.startFrom === 'source' ? to : {}
|
|
65
64
|
),
|
|
66
|
-
...this.droppedOut
|
|
65
|
+
...this.droppedOut
|
|
67
66
|
);
|
|
68
67
|
}
|
|
69
68
|
|
|
@@ -79,12 +78,12 @@ export const mappings = {
|
|
|
79
78
|
in: (): JsonValue | undefined => undefined,
|
|
80
79
|
out: (): JsonValue | undefined => undefined,
|
|
81
80
|
}),
|
|
82
|
-
skipIn: (property
|
|
81
|
+
skipIn: (property: string): Mapping => ({
|
|
83
82
|
property,
|
|
84
83
|
in: (): JsonValue | undefined => undefined,
|
|
85
84
|
out: (source: Json = {}): JsonValue => source[property],
|
|
86
85
|
}),
|
|
87
|
-
skipOut: (property: string
|
|
86
|
+
skipOut: (property: string): Mapping => ({
|
|
88
87
|
property,
|
|
89
88
|
in: (source: Json = {}): JsonValue => source[property],
|
|
90
89
|
out: (): JsonValue | undefined => undefined,
|
package/src/utils/Promise.ts
CHANGED
|
@@ -9,8 +9,10 @@ export const reject = <S = never>(e: ErrorOrigin): Promise<S> => Promise.reject(
|
|
|
9
9
|
export const tuple = {
|
|
10
10
|
2: <F, S>(first: Pro<F>, second: Pro<S>): Promise<[Aw<F>, Aw<S>]> => Promise.all([first, second]),
|
|
11
11
|
3: <F, S, T>(first: Pro<F>, second: Pro<S>, third: Pro<T>): Promise<[Aw<F>, Aw<S>, Aw<T>]> => Promise.all([first, second, third]),
|
|
12
|
-
4: <F, S, T, Fo>(first: Pro<F>, second: Pro<S>, third: Pro<T>, forth: Pro<Fo>): Promise<[Aw<F>, Aw<S>, Aw<T>, Aw<Fo>]> =>
|
|
13
|
-
|
|
12
|
+
4: <F, S, T, Fo>(first: Pro<F>, second: Pro<S>, third: Pro<T>, forth: Pro<Fo>): Promise<[Aw<F>, Aw<S>, Aw<T>, Aw<Fo>]> =>
|
|
13
|
+
Promise.all([first, second, third, forth]),
|
|
14
|
+
5: <F, S, T, Fo, Fi>(first: Pro<F>, second: Pro<S>, third: Pro<T>, forth: Pro<Fo>, fifth: Pro<Fi>): Promise<[Aw<F>, Aw<S>, Aw<T>, Aw<Fo>, Aw<Fi>]> =>
|
|
15
|
+
Promise.all([first, second, third, forth, fifth]),
|
|
14
16
|
all: <F, S>(first: Pro<F>, second: Pro<S>[]): Promise<[Aw<F>, Aw<S[]>]> => Promise.all([first, Promise.all(second)]),
|
|
15
17
|
spread: <F, S>(first: Pro<F>, ...second: Pro<S>[]): Promise<[Aw<F>, Aw<S[]>]> => Promise.all([first, Promise.all(toArray(second))]),
|
|
16
18
|
};
|
|
@@ -18,4 +20,4 @@ export const tuple = {
|
|
|
18
20
|
export const tuple2 = tuple[2];
|
|
19
21
|
export const tuple3 = tuple[3];
|
|
20
22
|
export const tuple4 = tuple[4];
|
|
21
|
-
export const tuple5 = tuple[5];
|
|
23
|
+
export const tuple5 = tuple[5];
|
package/src/utils/Traverse.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export const traverse = (subject: unknown = {}, property = ''): unknown => {
|
|
2
2
|
const [p, ...props] = property.split('.');
|
|
3
|
-
return
|
|
3
|
+
return props.length === 0 ? (subject as any)[p] : traverse((subject as any)[p], props.join('.'));
|
|
4
4
|
};
|
package/src/utils/View.ts
CHANGED
|
@@ -1,33 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
asJson,
|
|
3
|
-
isArray,
|
|
4
|
-
isDefined,
|
|
5
|
-
isFunction,
|
|
6
|
-
isObject,
|
|
7
|
-
isString,
|
|
8
|
-
isUndefined,
|
|
9
|
-
Json,
|
|
10
|
-
json,
|
|
11
|
-
meta,
|
|
12
|
-
tryTo,
|
|
13
|
-
} from '../types';
|
|
1
|
+
import { asJson, isArray, isDefined, isFunction, isObject, isString, isUndefined, Json, json, meta, tryTo } from '../types';
|
|
14
2
|
import { traverse } from './Traverse';
|
|
15
3
|
import { choose } from './Case';
|
|
16
4
|
|
|
17
5
|
type Func<T = unknown> = (a: any) => T;
|
|
18
6
|
|
|
19
|
-
export type InOut = { in?: Func | View
|
|
7
|
+
export type InOut = { in?: Func | View; col?: string };
|
|
20
8
|
|
|
21
9
|
const isColOnly = (v: unknown): v is InOut => isObject(v) && isDefined(v.col) && !isDefined(v.in);
|
|
22
10
|
const isInOnly = (v: unknown): v is InOut => isObject(v) && !isDefined(v.col) && isFunction(v.in);
|
|
23
|
-
const isColAndFunction = (v: unknown): v is { col: string
|
|
24
|
-
const isColAndView = (v: unknown): v is { col: string
|
|
11
|
+
const isColAndFunction = (v: unknown): v is { col: string; in: Func } => isObject(v) && isDefined(v.col) && isFunction(v.in);
|
|
12
|
+
const isColAndView = (v: unknown): v is { col: string; in: View } => isObject(v) && isDefined(v.col) && v.in instanceof View;
|
|
25
13
|
|
|
26
14
|
type Views = { [key: string]: string | Func | InOut | undefined };
|
|
27
|
-
type Viewer = { in: { key: string
|
|
15
|
+
type Viewer = { in: { key: string; f: Func } };
|
|
28
16
|
|
|
29
17
|
const toFunc = (a: any, col: string, f: Func = a => a): Func =>
|
|
30
|
-
tryTo(traverse(a, col)).map(v => isArray(v) ? () => v.map(i => f(i)) : (a: any) => f(traverse(a, col))).value;
|
|
18
|
+
tryTo(traverse(a, col)).map(v => (isArray(v) ? () => v.map(i => f(i)) : (a: any) => f(traverse(a, col)))).value;
|
|
31
19
|
|
|
32
20
|
const toViewer = (key: string, value: unknown): Viewer =>
|
|
33
21
|
choose<Viewer>(value)
|
|
@@ -46,15 +34,16 @@ const toViewers = (views: Views): Viewer[] =>
|
|
|
46
34
|
.map(([k, v]) => toViewer(k, v));
|
|
47
35
|
|
|
48
36
|
export class View {
|
|
49
|
-
constructor(private views: Views = {}, readonly startsFrom: 'scratch' | 'source' = 'scratch', readonly viewers: Viewer[] = toViewers(views)) {
|
|
50
|
-
}
|
|
37
|
+
constructor(private views: Views = {}, readonly startsFrom: 'scratch' | 'source' = 'scratch', readonly viewers: Viewer[] = toViewers(views)) {}
|
|
51
38
|
|
|
52
|
-
from = (source: unknown): Json => isArray(source) ? source.map(s => this.reduce(asJson(s))) : this.reduce(asJson(source));
|
|
39
|
+
from = (source: unknown): Json => (isArray(source) ? source.map(s => this.reduce(asJson(s))) : this.reduce(asJson(source)));
|
|
53
40
|
|
|
54
41
|
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
42
|
|
|
56
|
-
get fromSource(): View {
|
|
43
|
+
get fromSource(): View {
|
|
44
|
+
return new View(this.views, 'source', this.viewers);
|
|
45
|
+
}
|
|
57
46
|
}
|
|
58
47
|
|
|
59
48
|
export const skip = () => undefined;
|
|
60
|
-
export const view = (views: Views): View => new View(views);
|
|
49
|
+
export const view = (views: Views): View => new View(views);
|