@thisisagile/easy 13.4.8 → 13.4.11
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/services/ApiGateway.d.ts +2 -2
- package/dist/services/ApiGateway.js.map +1 -1
- package/dist/sql/Table.d.ts +1 -1
- package/dist/types/Constructor.d.ts +2 -2
- package/dist/types/Constructor.js.map +1 -1
- package/dist/types/PageList.d.ts +1 -1
- package/dist/utils/If.d.ts +4 -4
- package/dist/utils/If.js +1 -1
- package/dist/utils/If.js.map +1 -1
- package/dist/utils/Mapper.d.ts +1 -1
- package/dist/utils/State.d.ts +2 -2
- package/package.json +2 -2
- package/src/services/ApiGateway.ts +2 -2
- package/src/types/Constructor.ts +2 -1
- package/src/utils/If.ts +3 -4
|
@@ -8,7 +8,7 @@ export declare class ApiGateway extends Gateway<RouteOptions> {
|
|
|
8
8
|
getOne(uri: Uri, options?: RouteOptions): Promise<Optional<Json>>;
|
|
9
9
|
post(uri: Uri, item?: Json, options?: RouteOptions): Promise<Json>;
|
|
10
10
|
postSearch(uri: Uri, options?: RequestOptions | FetchOptions): Promise<PageList<Json>>;
|
|
11
|
-
patch(uri: Uri, item
|
|
12
|
-
put(uri: Uri, item
|
|
11
|
+
patch(uri: Uri, item?: Json, options?: RouteOptions): Promise<Json>;
|
|
12
|
+
put(uri: Uri, item?: Json, options?: RouteOptions): Promise<Json>;
|
|
13
13
|
delete(uri: Uri, options?: RouteOptions): Promise<boolean>;
|
|
14
14
|
}
|
|
@@ -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,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 +17,7 @@ export declare class Table extends Mapper {
|
|
|
17
17
|
skipOut: (property: string) => import("../utils").Mapping;
|
|
18
18
|
func: (property: string, funcIn: import("../types").Get<import("../types").Optional<import("../types").JsonValue>, Json>, funcOut: import("../types").Get<import("../types").Optional<import("../types").JsonValue>, Json>) => import("../utils").Mapping;
|
|
19
19
|
add: (funcIn: import("../types").Get<import("../types").JsonValue, Json>) => import("../utils").Mapping;
|
|
20
|
-
map: (mapper: import("../types").Construct<Mapper>, property?: string) => import("../utils").Mapping;
|
|
20
|
+
map: (mapper: import("../types").Construct<Mapper, any>, property?: string) => import("../utils").Mapping;
|
|
21
21
|
propsToList: (...maps: import("../utils").Mapping[]) => import("../utils").Mapping;
|
|
22
22
|
list: (mapper: import("../utils").Mapping, property: string) => import("../utils").Mapping;
|
|
23
23
|
};
|
|
@@ -3,9 +3,9 @@ import { Optional } from './Types';
|
|
|
3
3
|
export type Constructor<T = unknown> = {
|
|
4
4
|
new (...args: any[]): T;
|
|
5
5
|
};
|
|
6
|
-
export type Construct<
|
|
6
|
+
export type Construct<Out, In = any> = Get<Out, In> | Constructor<Out>;
|
|
7
7
|
export declare const isConstructor: <T>(c?: unknown) => c is Constructor<T>;
|
|
8
|
-
export declare const ofConstruct: <T>(c: Construct<T>, ...args: unknown[]) => T;
|
|
8
|
+
export declare const ofConstruct: <T>(c: Construct<T, any>, ...args: unknown[]) => T;
|
|
9
9
|
export declare const toName: (subject?: unknown, postfix?: string) => string;
|
|
10
10
|
export declare const on: <T>(t: T, f: (t: T) => unknown) => T;
|
|
11
11
|
export declare const ifA: <T>(c: Constructor<T>, t?: unknown, alt?: unknown) => Optional<T>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Constructor.js","sourceRoot":"","sources":["../../src/types/Constructor.ts"],"names":[],"mappings":";;;AACA,iCAAgC;AAChC,6BAAiC;AACjC,2CAA0C;
|
|
1
|
+
{"version":3,"file":"Constructor.js","sourceRoot":"","sources":["../../src/types/Constructor.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EAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;AAAjJ,QAAA,GAAG,OAA8I"}
|
package/dist/types/PageList.d.ts
CHANGED
|
@@ -27,4 +27,4 @@ export declare const isPageList: <T>(l?: T[] | undefined) => l is PageList<T>;
|
|
|
27
27
|
export declare const toPageList: <T>(items?: T[] | undefined, options?: Omit<PageOptions, 'sort'> & {
|
|
28
28
|
total?: number;
|
|
29
29
|
}) => PageList<T>;
|
|
30
|
-
export declare const asPageList: <T, U>(c: Construct<T>, items?: PageList<U>) => PageList<T>;
|
|
30
|
+
export declare const asPageList: <T, U>(c: Construct<T, any>, items?: PageList<U>) => PageList<T>;
|
package/dist/utils/If.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Construct, Optional } from '../types';
|
|
2
|
-
export declare const ifTrue: <T>(o: unknown, f: Construct<T>, alt?: Construct<T> | undefined) => Optional<T>;
|
|
3
|
-
export declare const ifFalse: <T>(o: unknown, f: Construct<T>, alt?: Construct<T> | undefined) => Optional<T>;
|
|
4
|
-
export declare const ifDefined: <
|
|
5
|
-
export declare const ifNotEmpty: <T>(o: unknown, f?: Construct<T>, alt?: Construct<T> | undefined) => Optional<T>;
|
|
2
|
+
export declare const ifTrue: <T>(o: unknown, f: Construct<T, any>, alt?: Construct<T, any> | undefined) => Optional<T>;
|
|
3
|
+
export declare const ifFalse: <T>(o: unknown, f: Construct<T, any>, alt?: Construct<T, any> | undefined) => Optional<T>;
|
|
4
|
+
export declare const ifDefined: <Out, In = unknown>(o: Optional<In>, f: Construct<Out, NonNullable<In>>, alt?: Construct<Out, any> | undefined) => Optional<Out>;
|
|
5
|
+
export declare const ifNotEmpty: <T>(o: unknown, f?: Construct<T, any>, alt?: Construct<T, any> | undefined) => Optional<T>;
|
package/dist/utils/If.js
CHANGED
|
@@ -6,7 +6,7 @@ const ifTrue = (o, f, alt) => ((0, types_1.isTrue)(o) ? (0, types_1.ofConstruct)
|
|
|
6
6
|
exports.ifTrue = ifTrue;
|
|
7
7
|
const ifFalse = (o, f, alt) => (!(0, types_1.isTrue)(o) ? (0, types_1.ofConstruct)(f, o) : (0, types_1.ofConstruct)(alt, o));
|
|
8
8
|
exports.ifFalse = ifFalse;
|
|
9
|
-
const ifDefined = (o, f, alt) => ((0, types_1.isDefined)(o) ? (0, types_1.ofConstruct)(f, o) : (0, types_1.ofConstruct)(alt
|
|
9
|
+
const ifDefined = (o, f, alt) => ((0, types_1.isDefined)(o) ? (0, types_1.ofConstruct)(f, o) : (0, types_1.ofConstruct)(alt));
|
|
10
10
|
exports.ifDefined = ifDefined;
|
|
11
11
|
const ifNotEmpty = (o, f = o => o, alt) => (0, types_1.isNotEmpty)(o) ? (0, types_1.ofConstruct)(f, o) : (0, types_1.ofConstruct)(alt, o);
|
|
12
12
|
exports.ifNotEmpty = ifNotEmpty;
|
package/dist/utils/If.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"If.js","sourceRoot":"","sources":["../../src/utils/If.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"If.js","sourceRoot":"","sources":["../../src/utils/If.ts"],"names":[],"mappings":";;;AAAA,oCAAyF;AAElF,MAAM,MAAM,GAAG,CAAI,CAAU,EAAE,CAAe,EAAE,GAAkB,EAAe,EAAE,CAAC,CAAC,IAAA,cAAM,EAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAA,mBAAW,EAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,IAAA,mBAAW,EAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;AAApI,QAAA,MAAM,UAA8H;AAC1I,MAAM,OAAO,GAAG,CAAI,CAAU,EAAE,CAAe,EAAE,GAAkB,EAAe,EAAE,CAAC,CAAC,CAAC,IAAA,cAAM,EAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAA,mBAAW,EAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,IAAA,mBAAW,EAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;AAAtI,QAAA,OAAO,WAA+H;AAC5I,MAAM,SAAS,GAAG,CAAoB,CAAe,EAAE,CAAkC,EAAE,GAAoB,EAAiB,EAAE,CAAC,CAAC,IAAA,iBAAS,EAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAA,mBAAW,EAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,IAAA,mBAAW,EAAC,GAAG,CAAC,CAAC,CAAC;AAAnL,QAAA,SAAS,aAA0K;AACzL,MAAM,UAAU,GAAG,CAAI,CAAU,EAAE,IAAkB,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,GAAkB,EAAe,EAAE,CAAC,IAAA,kBAAU,EAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAA,mBAAW,EAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,IAAA,mBAAW,EAAC,GAAG,EAAE,CAAC,CAAC,CAAC;AAAnJ,QAAA,UAAU,cAAyI"}
|
package/dist/utils/Mapper.d.ts
CHANGED
|
@@ -21,7 +21,7 @@ export declare class Mapper extends State implements Mapping {
|
|
|
21
21
|
skipOut: (property: string) => Mapping;
|
|
22
22
|
func: (property: string, funcIn: Get<Optional<JsonValue>, Json>, funcOut: Get<Optional<JsonValue>, Json>) => Mapping;
|
|
23
23
|
add: (funcIn: Get<JsonValue, Json>) => Mapping;
|
|
24
|
-
map: (mapper: Construct<Mapper>, property?: string) => Mapping;
|
|
24
|
+
map: (mapper: Construct<Mapper, any>, property?: string) => Mapping;
|
|
25
25
|
propsToList: (...maps: Mapping[]) => Mapping;
|
|
26
26
|
list: (mapper: Mapping, property: string) => Mapping;
|
|
27
27
|
};
|
package/dist/utils/State.d.ts
CHANGED
|
@@ -2,6 +2,6 @@ import { Construct } from '../types';
|
|
|
2
2
|
export declare class State {
|
|
3
3
|
protected readonly state: any;
|
|
4
4
|
constructor(state?: any);
|
|
5
|
-
protected get: <T>(key: string, alt?: Construct<T> | undefined) => T;
|
|
6
|
-
protected set: <T>(key: string, value: Construct<T>) => T;
|
|
5
|
+
protected get: <T>(key: string, alt?: Construct<T, any> | undefined) => T;
|
|
6
|
+
protected set: <T>(key: string, value: Construct<T, any>) => T;
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thisisagile/easy",
|
|
3
|
-
"version": "13.4.
|
|
3
|
+
"version": "13.4.11",
|
|
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": "13.4.
|
|
34
|
+
"@thisisagile/easy-test": "13.4.11",
|
|
35
35
|
"@types/form-urlencoded": "^4.4.0",
|
|
36
36
|
"@types/jsonwebtoken": "^9.0.1",
|
|
37
37
|
"@types/luxon": "3.2.0",
|
|
@@ -39,11 +39,11 @@ export class ApiGateway extends Gateway<RouteOptions> {
|
|
|
39
39
|
);
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
patch(uri: Uri, item
|
|
42
|
+
patch(uri: Uri, item?: Json, options?: RouteOptions): Promise<Json> {
|
|
43
43
|
return this.api.patch(uri, item, options).then(r => r.body.data?.items.first() ?? {});
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
put(uri: Uri, item
|
|
46
|
+
put(uri: Uri, item?: Json, options?: RouteOptions): Promise<Json> {
|
|
47
47
|
return this.api.put(uri, item, options).then(r => r.body.data?.items.first() ?? {});
|
|
48
48
|
}
|
|
49
49
|
|
package/src/types/Constructor.ts
CHANGED
|
@@ -6,7 +6,8 @@ import { Optional } from './Types';
|
|
|
6
6
|
|
|
7
7
|
export type Constructor<T = unknown> = { new (...args: any[]): T };
|
|
8
8
|
|
|
9
|
-
export type Construct<T> = Get<T> | Constructor<T>;
|
|
9
|
+
// export type Construct<T> = Get<T> | Constructor<T>;
|
|
10
|
+
export type Construct<Out, In = any> = Get<Out, In> | Constructor<Out>;
|
|
10
11
|
|
|
11
12
|
export const isConstructor = <T>(c?: unknown): c is Constructor<T> => (isDefined(c) && isFunc<T, unknown>(c) && c.prototype && c.prototype.constructor) === c;
|
|
12
13
|
|
package/src/utils/If.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {Construct, isDefined, isNotEmpty, isTrue, ofConstruct, Optional} from '../types';
|
|
2
2
|
|
|
3
3
|
export const ifTrue = <T>(o: unknown, f: Construct<T>, alt?: Construct<T>): Optional<T> => (isTrue(o) ? ofConstruct(f, o) : ofConstruct(alt, o));
|
|
4
4
|
export const ifFalse = <T>(o: unknown, f: Construct<T>, alt?: Construct<T>): Optional<T> => (!isTrue(o) ? ofConstruct(f, o) : ofConstruct(alt, o));
|
|
5
|
-
export const ifDefined = <
|
|
6
|
-
export const ifNotEmpty = <T>(o: unknown, f: Construct<T> = o => o, alt?: Construct<T>): Optional<T> =>
|
|
7
|
-
isNotEmpty(o) ? ofConstruct(f, o) : ofConstruct(alt, o);
|
|
5
|
+
export const ifDefined = <Out, In = unknown>(o: Optional<In>, f: Construct<Out, NonNullable<In>>, alt?: Construct<Out>): Optional<Out> => (isDefined(o) ? ofConstruct(f, o) : ofConstruct(alt));
|
|
6
|
+
export const ifNotEmpty = <T>(o: unknown, f: Construct<T> = o => o, alt?: Construct<T>): Optional<T> => isNotEmpty(o) ? ofConstruct(f, o) : ofConstruct(alt, o);
|