@wenex/sdk 0.4.0 → 0.4.1
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,5 +1,5 @@
|
|
|
1
1
|
import { AxiosInstance, AxiosRequestConfig } from 'axios';
|
|
2
|
-
import { Dto as DtoInterface, Core, Filter, QueryFilter, Serializer, Pagination, Optional } from '../interfaces';
|
|
2
|
+
import { Dto as DtoInterface, Core, Filter, QueryFilter, Serializer, Pagination, Optional, Population } from '../interfaces';
|
|
3
3
|
import { RequestService } from '../providers';
|
|
4
4
|
export type RequestConfig<T> = Omit<AxiosRequestConfig, 'params'> & {
|
|
5
5
|
params?: Optional<Filter<T>> & {
|
|
@@ -19,11 +19,11 @@ export declare class RestfulService<T extends Core, Dto extends DtoInterface<Cor
|
|
|
19
19
|
count(filter: QueryFilter<T>, config?: RequestConfig<T>): Promise<number>;
|
|
20
20
|
create(data: Dto, config?: RequestConfig<T>): Promise<Serializer<T>>;
|
|
21
21
|
createBulk(data: Dto[], config?: RequestConfig<T>): Promise<Serializer<T>[]>;
|
|
22
|
-
find(filter: Filter<T>, config?: RequestConfig<T>): Promise<Serializer<T>[]>;
|
|
23
|
-
findById(id: string, config?: RequestConfig<T>): Promise<Serializer<T>>;
|
|
24
|
-
deleteById(id: string, config?: RequestConfig<T>): Promise<Serializer<T>>;
|
|
25
|
-
restoreById(id: string, config?: RequestConfig<T>): Promise<Serializer<T>>;
|
|
26
|
-
destroyById(id: string, config?: RequestConfig<T>): Promise<Serializer<T>>;
|
|
27
|
-
updateById(id: string, data: Optional<Dto>, config?: RequestConfig<T>): Promise<Serializer<T>>;
|
|
22
|
+
find<Populate extends Population = 'id'>(filter: Filter<T>, config?: RequestConfig<T>): Promise<Serializer<T, Populate>[]>;
|
|
23
|
+
findById<Populate extends Population = 'id'>(id: string, config?: RequestConfig<T>): Promise<Serializer<T, Populate>>;
|
|
24
|
+
deleteById<Populate extends Population = 'id'>(id: string, config?: RequestConfig<T>): Promise<Serializer<T, Populate>>;
|
|
25
|
+
restoreById<Populate extends Population = 'id'>(id: string, config?: RequestConfig<T>): Promise<Serializer<T, Populate>>;
|
|
26
|
+
destroyById<Populate extends Population = 'id'>(id: string, config?: RequestConfig<T>): Promise<Serializer<T, Populate>>;
|
|
27
|
+
updateById<Populate extends Population = 'id'>(id: string, data: Optional<Dto>, config?: RequestConfig<T>): Promise<Serializer<T, Populate>>;
|
|
28
28
|
updateBulk(data: Optional<Dto>, filter: QueryFilter<T>, config?: RequestConfig<T>): Promise<number>;
|
|
29
29
|
}
|
|
@@ -38,8 +38,7 @@ class RestfulService extends providers_1.RequestService {
|
|
|
38
38
|
find(filter, config) {
|
|
39
39
|
return __awaiter(this, void 0, void 0, function* () {
|
|
40
40
|
const params = Object.assign(Object.assign({}, filter), Object.assign({}, config === null || config === void 0 ? void 0 : config.params));
|
|
41
|
-
return (yield this.get(this.url(), Object.assign(Object.assign({}, config), { params })))
|
|
42
|
-
.items;
|
|
41
|
+
return (yield this.get(this.url(), Object.assign(Object.assign({}, config), { params }))).items;
|
|
43
42
|
});
|
|
44
43
|
}
|
|
45
44
|
findById(id, config) {
|
|
@@ -59,8 +58,7 @@ class RestfulService extends providers_1.RequestService {
|
|
|
59
58
|
}
|
|
60
59
|
destroyById(id, config) {
|
|
61
60
|
return __awaiter(this, void 0, void 0, function* () {
|
|
62
|
-
return (yield this.delete(`${this.url(id)}/destroy`, config))
|
|
63
|
-
.data;
|
|
61
|
+
return (yield this.delete(`${this.url(id)}/destroy`, config)).data;
|
|
64
62
|
});
|
|
65
63
|
}
|
|
66
64
|
updateById(id, data, config) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"restful.service.js","sourceRoot":"","sources":["../../src/common/classes/restful.service.ts"],"names":[],"mappings":";;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"restful.service.js","sourceRoot":"","sources":["../../src/common/classes/restful.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AA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,MAAM,EAAG,CAAC;YACnE,OAAO,CACL,MAAM,IAAI,CAAC,KAAK,CAAuB,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,IAAI,kCACxD,MAAM,KACT,MAAM,IACN,CACH,CAAC,KAAK,CAAC;QACV,CAAC;KAAA;CACF;AApGD,wCAoGC"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { MakeRequired } from './generic.interface';
|
|
2
|
+
import { Client } from '../domain';
|
|
3
|
+
import { User } from '../identity';
|
|
2
4
|
export type Total = {
|
|
3
5
|
total: number;
|
|
4
6
|
};
|
|
@@ -11,9 +13,10 @@ export type Data<T> = {
|
|
|
11
13
|
export type Items<T> = {
|
|
12
14
|
items: T[];
|
|
13
15
|
};
|
|
14
|
-
|
|
16
|
+
type CoreT = {
|
|
15
17
|
id?: string;
|
|
16
18
|
owner?: string;
|
|
19
|
+
shares?: string[];
|
|
17
20
|
clients?: string[];
|
|
18
21
|
created_at?: Date;
|
|
19
22
|
created_by?: string;
|
|
@@ -21,4 +24,13 @@ export type Serializer<T extends {
|
|
|
21
24
|
version?: string;
|
|
22
25
|
rand?: string;
|
|
23
26
|
timestamp?: string;
|
|
24
|
-
}
|
|
27
|
+
};
|
|
28
|
+
type RequiredSerializerItems<T extends CoreT> = MakeRequired<T, 'id' | 'owner' | 'clients' | 'created_at' | 'created_by' | 'created_in' | 'version' | 'rand' | 'timestamp'>;
|
|
29
|
+
export type Population = 'id' | 'owner' | 'shares' | 'clients';
|
|
30
|
+
export type Serializer<T extends CoreT, Populate extends Population = 'id'> = Populate extends 'id' ? RequiredSerializerItems<T> : RequiredSerializerItems<Omit<T, Populate>> & Pick<{
|
|
31
|
+
id: string;
|
|
32
|
+
owner?: User;
|
|
33
|
+
shares?: User[];
|
|
34
|
+
clients?: Client[];
|
|
35
|
+
}, Populate>;
|
|
36
|
+
export {};
|