@thisisagile/easy 15.8.5 → 15.8.6
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/index.d.mts +12 -12
- package/dist/index.d.ts +12 -12
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +2 -2
- package/src/process/Manage.ts +15 -4
- package/src/process/Search.ts +24 -9
- package/src/utils/If.ts +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thisisagile/easy",
|
|
3
|
-
"version": "15.8.
|
|
3
|
+
"version": "15.8.6",
|
|
4
4
|
"description": "Straightforward library for building domain-driven microservice architectures",
|
|
5
5
|
"author": "Sander Hoogendoorn",
|
|
6
6
|
"license": "MIT",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"access": "public"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@thisisagile/easy-test": "15.8.
|
|
36
|
+
"@thisisagile/easy-test": "15.8.6",
|
|
37
37
|
"@types/form-urlencoded": "^4.4.0",
|
|
38
38
|
"@types/jsonwebtoken": "^9.0.2",
|
|
39
39
|
"@types/luxon": "3.2.0",
|
package/src/process/Manage.ts
CHANGED
|
@@ -2,8 +2,19 @@ import { Search } from './Search';
|
|
|
2
2
|
import { FetchOptions, Id, Json } from '../types';
|
|
3
3
|
|
|
4
4
|
export class Manage<T, Options = FetchOptions> extends Search<T, Options> {
|
|
5
|
-
add
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
add(json: Json): Promise<T> {
|
|
6
|
+
return this.repo.add(json);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
update(id: Id, json: Json): Promise<T> {
|
|
10
|
+
return this.repo.update(id, json);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
upsert(id: Id, json: Json): Promise<T> {
|
|
14
|
+
return this.repo.upsert(id, json);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
remove(id: Id): Promise<boolean> {
|
|
18
|
+
return this.repo.remove(id);
|
|
19
|
+
}
|
|
9
20
|
}
|
package/src/process/Search.ts
CHANGED
|
@@ -5,25 +5,40 @@ import { Req } from '../resources';
|
|
|
5
5
|
export class Search<T, Options = FetchOptions> {
|
|
6
6
|
constructor(protected repo: Repository<T, Options>) {}
|
|
7
7
|
|
|
8
|
-
all
|
|
8
|
+
all(options?: Options): Promise<PageList<T>> {
|
|
9
|
+
return this.repo.all(options);
|
|
10
|
+
}
|
|
9
11
|
|
|
10
|
-
byId
|
|
12
|
+
byId(id: Id): Promise<T> {
|
|
13
|
+
return this.repo.byId(id);
|
|
14
|
+
}
|
|
11
15
|
|
|
12
|
-
byIds
|
|
16
|
+
byIds(...ids: Id[]): Promise<List<T>> {
|
|
17
|
+
return this.repo.byIds(...ids);
|
|
18
|
+
}
|
|
13
19
|
|
|
14
|
-
byKey
|
|
20
|
+
byKey(key: Key, options?: Options): Promise<PageList<T>> {
|
|
21
|
+
return this.repo.byKey(key, options);
|
|
22
|
+
}
|
|
15
23
|
|
|
16
|
-
query
|
|
24
|
+
query({ query, skip, take }: Req): Promise<PageList<T>> {
|
|
25
|
+
return this.search(query, { skip, take } as Options);
|
|
26
|
+
}
|
|
17
27
|
|
|
18
|
-
search
|
|
19
|
-
choose(query)
|
|
28
|
+
search(query: JsonValue, options?: Options): Promise<PageList<T>> {
|
|
29
|
+
return choose(query)
|
|
20
30
|
.is.not.empty(
|
|
21
31
|
q => q,
|
|
22
32
|
q => this.repo.search(q, options)
|
|
23
33
|
)
|
|
24
34
|
.else(() => resolve(toPageList<T>()));
|
|
35
|
+
}
|
|
25
36
|
|
|
26
|
-
filter
|
|
37
|
+
filter(options?: Options): Promise<PageList<T>> {
|
|
38
|
+
return this.repo.filter(options);
|
|
39
|
+
}
|
|
27
40
|
|
|
28
|
-
exists
|
|
41
|
+
exists(id: Id): Promise<boolean> {
|
|
42
|
+
return this.repo.exists(id);
|
|
43
|
+
}
|
|
29
44
|
}
|
package/src/utils/If.ts
CHANGED
|
@@ -17,6 +17,7 @@ export function ifDefined<Out, In = unknown>(o: Optional<In>, f: Construct<Out,
|
|
|
17
17
|
export function ifDefined<Out, In = unknown>(o: Optional<In>, f: Construct<Out, NonNullable<In>>, alt?: Construct<Out>): Optional<Out> {
|
|
18
18
|
return isDefined(o) ? ofConstruct(f, o) : ofConstruct(alt);
|
|
19
19
|
}
|
|
20
|
+
|
|
20
21
|
export function ifNotEmpty<Out, In = unknown>(o: In, f: Construct<Out, NonNullable<In>>, alt: Construct<Out>): Out;
|
|
21
22
|
export function ifNotEmpty<Out, In = unknown>(o: In, f?: Construct<Out, NonNullable<In>>, alt?: Construct<Out>): Optional<Out>;
|
|
22
23
|
export function ifNotEmpty<Out, In = unknown>(o: In, f: Construct<Out, NonNullable<In>>, alt?: Construct<Out>): Optional<Out>;
|