@wenex/sdk 0.1.0 → 0.1.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,19 +1,29 @@
|
|
|
1
1
|
import { AxiosInstance, AxiosRequestConfig } from 'axios';
|
|
2
|
-
import { Dto as DtoInterface, Core, Filter, QueryFilter, Serializer } from '../interfaces';
|
|
2
|
+
import { Dto as DtoInterface, Core, Filter, QueryFilter, Serializer, Pagination, Optional } from '../interfaces';
|
|
3
3
|
import { RequestService } from '../providers';
|
|
4
|
+
export type RequestConfig<T> = Omit<AxiosRequestConfig, 'params'> & {
|
|
5
|
+
params?: Optional<Filter<T>> & {
|
|
6
|
+
zone?: string;
|
|
7
|
+
skip?: number;
|
|
8
|
+
limit?: number;
|
|
9
|
+
sort?: Pagination<T>['sort'];
|
|
10
|
+
} & {
|
|
11
|
+
[x: string]: any;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
4
14
|
export declare class RestfulService<T extends Core, Dto extends DtoInterface<Core>> extends RequestService {
|
|
5
15
|
protected readonly name: string;
|
|
6
16
|
protected readonly axios: AxiosInstance;
|
|
7
17
|
protected readonly url: (path: string) => string;
|
|
8
18
|
constructor(name: string, axios: AxiosInstance);
|
|
9
|
-
count(filter: QueryFilter<T>, config?:
|
|
10
|
-
create(data: Dto, config?:
|
|
11
|
-
createBulk(data: Dto[], config?:
|
|
12
|
-
find(filter: Filter<T>, config?:
|
|
13
|
-
findById(id: string, config?:
|
|
14
|
-
deleteById(id: string, config?:
|
|
15
|
-
restoreById(id: string, config?:
|
|
16
|
-
destroyById(id: string, config?:
|
|
17
|
-
updateById(id: string, data: Dto, config?:
|
|
18
|
-
updateBulk(data: Dto, filter: QueryFilter<T>, config?:
|
|
19
|
+
count(filter: QueryFilter<T>, config?: RequestConfig<T>): Promise<number>;
|
|
20
|
+
create(data: Dto, config?: RequestConfig<T>): Promise<Serializer<T>>;
|
|
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: Dto, config?: RequestConfig<T>): Promise<Serializer<T>>;
|
|
28
|
+
updateBulk(data: Dto, filter: QueryFilter<T>, config?: RequestConfig<T>): Promise<number>;
|
|
19
29
|
}
|
|
@@ -20,7 +20,7 @@ class RestfulService extends providers_1.RequestService {
|
|
|
20
20
|
}
|
|
21
21
|
count(filter, config) {
|
|
22
22
|
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
-
const params = Object.assign({ filter }, config === null || config === void 0 ? void 0 : config.params);
|
|
23
|
+
const params = Object.assign(Object.assign({}, filter), Object.assign({}, config === null || config === void 0 ? void 0 : config.params));
|
|
24
24
|
return (yield this.get(this.url('/count'), Object.assign(Object.assign({}, config), { params }))).total;
|
|
25
25
|
});
|
|
26
26
|
}
|
|
@@ -37,7 +37,7 @@ class RestfulService extends providers_1.RequestService {
|
|
|
37
37
|
}
|
|
38
38
|
find(filter, config) {
|
|
39
39
|
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
-
const params = Object.assign({ filter }, config === null || config === void 0 ? void 0 : config.params);
|
|
40
|
+
const params = Object.assign(Object.assign({}, filter), Object.assign({}, config === null || config === void 0 ? void 0 : config.params));
|
|
41
41
|
return (yield this.get(this.url(''), Object.assign(Object.assign({}, config), { params })))
|
|
42
42
|
.items;
|
|
43
43
|
});
|
|
@@ -71,7 +71,7 @@ class RestfulService extends providers_1.RequestService {
|
|
|
71
71
|
}
|
|
72
72
|
updateBulk(data, filter, config) {
|
|
73
73
|
return __awaiter(this, void 0, void 0, function* () {
|
|
74
|
-
const params = Object.assign({ filter }, config === null || config === void 0 ? void 0 : config.params);
|
|
74
|
+
const params = Object.assign(Object.assign({}, filter), Object.assign({}, config === null || config === void 0 ? void 0 : config.params));
|
|
75
75
|
return (yield this.patch('/bulk', data, Object.assign(Object.assign({}, config), { params }))).total;
|
|
76
76
|
});
|
|
77
77
|
}
|
|
@@ -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":";;;;;;;;;;;;AAeA,4CAA8C;AAW9C,MAAa,cAGX,SAAQ,0BAAc;IAGtB,YACqB,IAAY,EACZ,KAAoB;QAEvC,KAAK,CAAC,KAAK,CAAC,CAAC;QAHM,SAAI,GAAJ,IAAI,CAAQ;QACZ,UAAK,GAAL,KAAK,CAAe;QAJtB,QAAG,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,EAAE,CAAC;IAOnE,CAAC;IAEK,KAAK,CAAC,MAAsB,EAAE,MAAyB;;YAC3D,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,mBAAM,MAAM,qBAAS,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,MAAM,EAAG,CAAC;YACnE,OAAO,CAAC,MAAM,IAAI,CAAC,GAAG,CAAQ,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,kCAAO,MAAM,KAAE,MAAM,IAAG,CAAC,CAAC,KAAK,CAAC;QAClF,CAAC;KAAA;IAEK,MAAM,CAAC,IAAS,EAAE,MAAyB;;YAC/C,OAAO,IAAI,CAAC,IAAI,CAAqB,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;QACnE,CAA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