@wenex/sdk 0.0.7 → 0.0.8
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/common/classes/restful.service.d.ts +12 -12
- package/common/classes/restful.service.js +46 -13
- package/common/classes/restful.service.js.map +1 -1
- package/common/providers/request.provider.d.ts +6 -6
- package/common/providers/request.provider.js +24 -5
- package/common/providers/request.provider.js.map +1 -1
- package/package.json +6 -6
- package/services/auth/authentication.service.d.ts +3 -3
- package/services/auth/authorization.service.d.ts +2 -2
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { AxiosInstance,
|
|
2
|
-
import { Dto as DtoInterface, Core,
|
|
1
|
+
import { AxiosInstance, AxiosRequestConfig } from 'axios';
|
|
2
|
+
import { Dto as DtoInterface, Core, Filter, QueryFilter, Serializer } from '../interfaces';
|
|
3
3
|
import { RequestService } from '../providers';
|
|
4
4
|
export declare class RestfulService<T extends Core, Dto extends DtoInterface<Core>> extends RequestService {
|
|
5
5
|
protected readonly name: string;
|
|
6
6
|
protected readonly client: AxiosInstance;
|
|
7
7
|
protected readonly url: (path: string) => string;
|
|
8
8
|
constructor(name: string, client: AxiosInstance);
|
|
9
|
-
count(filter: QueryFilter<T>, config?: AxiosRequestConfig):
|
|
10
|
-
create(data: Dto, config?: AxiosRequestConfig):
|
|
11
|
-
createBulk(data: Dto[], config?: AxiosRequestConfig):
|
|
12
|
-
find(filter: Filter<T>, config?: AxiosRequestConfig):
|
|
13
|
-
findById(id: string, config?: AxiosRequestConfig):
|
|
14
|
-
deleteById(id: string, config?: AxiosRequestConfig):
|
|
15
|
-
restoreById(id: string, config?: AxiosRequestConfig):
|
|
16
|
-
destroyById(id: string, config?: AxiosRequestConfig):
|
|
17
|
-
updateById(id: string, data: Dto, config?: AxiosRequestConfig):
|
|
18
|
-
updateBulk(data: Dto, filter: QueryFilter<T>, config?: AxiosRequestConfig):
|
|
9
|
+
count(filter: QueryFilter<T>, config?: AxiosRequestConfig): Promise<number>;
|
|
10
|
+
create(data: Dto, config?: AxiosRequestConfig): Promise<Serializer<T>>;
|
|
11
|
+
createBulk(data: Dto[], config?: AxiosRequestConfig): Promise<Serializer<T>[]>;
|
|
12
|
+
find(filter: Filter<T>, config?: AxiosRequestConfig): Promise<Serializer<T>[]>;
|
|
13
|
+
findById(id: string, config?: AxiosRequestConfig): Promise<Serializer<T>>;
|
|
14
|
+
deleteById(id: string, config?: AxiosRequestConfig): Promise<Serializer<T>>;
|
|
15
|
+
restoreById(id: string, config?: AxiosRequestConfig): Promise<Serializer<T>>;
|
|
16
|
+
destroyById(id: string, config?: AxiosRequestConfig): Promise<Serializer<T>>;
|
|
17
|
+
updateById(id: string, data: Dto, config?: AxiosRequestConfig): Promise<Serializer<T>>;
|
|
18
|
+
updateBulk(data: Dto, filter: QueryFilter<T>, config?: AxiosRequestConfig): Promise<number>;
|
|
19
19
|
}
|
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
2
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
12
|
exports.RestfulService = void 0;
|
|
4
13
|
const providers_1 = require("../providers");
|
|
@@ -10,37 +19,61 @@ class RestfulService extends providers_1.RequestService {
|
|
|
10
19
|
this.url = (path) => `/${this.name}/${path}`;
|
|
11
20
|
}
|
|
12
21
|
count(filter, config) {
|
|
13
|
-
|
|
14
|
-
|
|
22
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
const params = Object.assign({ filter }, config === null || config === void 0 ? void 0 : config.params);
|
|
24
|
+
return (yield this.get(this.url('/count'), Object.assign(Object.assign({}, config), { params }))).total;
|
|
25
|
+
});
|
|
15
26
|
}
|
|
16
27
|
create(data, config) {
|
|
17
|
-
return
|
|
28
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
return this.post(this.url(''), data, config);
|
|
30
|
+
});
|
|
18
31
|
}
|
|
19
32
|
createBulk(data, config) {
|
|
20
|
-
return
|
|
33
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
34
|
+
return (yield this.post(this.url(''), data, config))
|
|
35
|
+
.items;
|
|
36
|
+
});
|
|
21
37
|
}
|
|
22
38
|
find(filter, config) {
|
|
23
|
-
|
|
24
|
-
|
|
39
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
+
const params = Object.assign({ filter }, config === null || config === void 0 ? void 0 : config.params);
|
|
41
|
+
return (yield this.get(this.url(''), Object.assign(Object.assign({}, config), { params })))
|
|
42
|
+
.items;
|
|
43
|
+
});
|
|
25
44
|
}
|
|
26
45
|
findById(id, config) {
|
|
27
|
-
return
|
|
46
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
+
return (yield this.get(this.url(id), config)).data;
|
|
48
|
+
});
|
|
28
49
|
}
|
|
29
50
|
deleteById(id, config) {
|
|
30
|
-
return
|
|
51
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
52
|
+
return (yield this.delete(this.url(id), config)).data;
|
|
53
|
+
});
|
|
31
54
|
}
|
|
32
55
|
restoreById(id, config) {
|
|
33
|
-
return
|
|
56
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
57
|
+
return (yield this.put(`${this.url(id)}/restore`, undefined, config)).data;
|
|
58
|
+
});
|
|
34
59
|
}
|
|
35
60
|
destroyById(id, config) {
|
|
36
|
-
return
|
|
61
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
62
|
+
return (yield this.delete(`${this.url(id)}/destroy`, config))
|
|
63
|
+
.data;
|
|
64
|
+
});
|
|
37
65
|
}
|
|
38
66
|
updateById(id, data, config) {
|
|
39
|
-
return
|
|
67
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
68
|
+
return (yield this.patch(`${this.url(id)}`, data, config))
|
|
69
|
+
.data;
|
|
70
|
+
});
|
|
40
71
|
}
|
|
41
72
|
updateBulk(data, filter, config) {
|
|
42
|
-
|
|
43
|
-
|
|
73
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
74
|
+
const params = Object.assign({ filter }, config === null || config === void 0 ? void 0 : config.params);
|
|
75
|
+
return (yield this.patch('/bulk', data, Object.assign(Object.assign({}, config), { params }))).total;
|
|
76
|
+
});
|
|
44
77
|
}
|
|
45
78
|
}
|
|
46
79
|
exports.RestfulService = RestfulService;
|
|
@@ -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":";;;;;;;;;;;;AAaA,4CAA8C;AAE9C,MAAa,cAGX,SAAQ,0BAAc;IAGtB,YACqB,IAAY,EACZ,MAAqB;QAExC,KAAK,CAAC,MAAM,CAAC,CAAC;QAHK,SAAI,GAAJ,IAAI,CAAQ;QACZ,WAAM,GAAN,MAAM,CAAe;QAJvB,QAAG,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,EAAE,CAAC;IAOnE,CAAC;IAEK,KAAK,CAAC,MAAsB,EAAE,MAA2B;;YAC7D,MAAM,MAAM,mBAAK,MAAM,IAAK,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,MAAM,CAAE,CAAC;YAC7C,OAAO,CAAC,MAAM,IAAI,CA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AG,CACZ,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,UAAU,EACzB,SAAS,EACT,MAAM,CACP,CACF,CAAC,IAAI,CAAC;QACT,CAAC;KAAA;IAEK,WAAW,CAAC,EAAU,EAAE,MAA2B;;YACvD,OAAO,CAAC,MAAM,IAAI,CAAC,MAAM,CAAsB,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;iBAC/E,IAAI,CAAC;QACV,CAAC;KAAA;IAEK,UAAU,CACd,EAAU,EACV,IAAS,EACT,MAA2B;;YAE3B,OAAO,CAAC,MAAM,IAAI,CAAC,KAAK,CAA2B,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;iBACjF,IAAI,CAAC;QACV,CAAC;KAAA;IAEK,UAAU,CACd,IAAS,EACT,MAAsB,EACtB,MAA2B;;YAE3B,MAAM,MAAM,mBAAK,MAAM,IAAK,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,MAAM,CAAE,CAAC;YAC7C,OAAO,CAAC,MAAM,IAAI,CAAC,KAAK,CAAa,OAAO,EAAE,IAAI,kCAAO,MAAM,KAAE,MAAM,IAAG,CAAC,CAAC,KAAK,CAAC;QACpF,CAAC;KAAA;CACF;AAzED,wCAyEC"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { AxiosInstance,
|
|
1
|
+
import { AxiosInstance, AxiosRequestConfig } from 'axios';
|
|
2
2
|
export declare class RequestService {
|
|
3
3
|
protected readonly client: AxiosInstance;
|
|
4
4
|
constructor(client: AxiosInstance);
|
|
5
|
-
get<T>(url: string, config?: AxiosRequestConfig):
|
|
6
|
-
post<T, D>(url: string, data?: D, config?: AxiosRequestConfig):
|
|
7
|
-
delete<T>(url: string, config?: AxiosRequestConfig):
|
|
8
|
-
put<T, D>(url: string, data?: D, config?: AxiosRequestConfig):
|
|
9
|
-
patch<T, D>(url: string, data: D, config?: AxiosRequestConfig):
|
|
5
|
+
get<T>(url: string, config?: AxiosRequestConfig): Promise<T>;
|
|
6
|
+
post<T, D>(url: string, data?: D, config?: AxiosRequestConfig): Promise<T>;
|
|
7
|
+
delete<T>(url: string, config?: AxiosRequestConfig): Promise<T>;
|
|
8
|
+
put<T, D>(url: string, data?: D, config?: AxiosRequestConfig): Promise<T>;
|
|
9
|
+
patch<T, D>(url: string, data: D, config?: AxiosRequestConfig): Promise<T>;
|
|
10
10
|
}
|
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
2
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
12
|
exports.RequestService = void 0;
|
|
4
13
|
class RequestService {
|
|
@@ -6,19 +15,29 @@ class RequestService {
|
|
|
6
15
|
this.client = client;
|
|
7
16
|
}
|
|
8
17
|
get(url, config) {
|
|
9
|
-
return this
|
|
18
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
19
|
+
return (yield this.client.get(url, config)).data;
|
|
20
|
+
});
|
|
10
21
|
}
|
|
11
22
|
post(url, data, config) {
|
|
12
|
-
return this
|
|
23
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
return (yield this.client.post(url, data, config)).data;
|
|
25
|
+
});
|
|
13
26
|
}
|
|
14
27
|
delete(url, config) {
|
|
15
|
-
return this
|
|
28
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
return (yield this.client.delete(url, config)).data;
|
|
30
|
+
});
|
|
16
31
|
}
|
|
17
32
|
put(url, data, config) {
|
|
18
|
-
return this
|
|
33
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
34
|
+
return (yield this.client.put(url, data, config)).data;
|
|
35
|
+
});
|
|
19
36
|
}
|
|
20
37
|
patch(url, data, config) {
|
|
21
|
-
return this
|
|
38
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
+
return (yield this.client.patch(url, data, config)).data;
|
|
40
|
+
});
|
|
22
41
|
}
|
|
23
42
|
}
|
|
24
43
|
exports.RequestService = RequestService;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request.provider.js","sourceRoot":"","sources":["../../src/common/providers/request.provider.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"request.provider.js","sourceRoot":"","sources":["../../src/common/providers/request.provider.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,MAAa,cAAc;IACzB,YAA+B,MAAqB;QAArB,WAAM,GAAN,MAAM,CAAe;IAAG,CAAC;IAElD,GAAG,CAAI,GAAW,EAAE,MAA2B;;YACnD,OAAO,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAI,GAAG,EAAE,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC;QACtD,CAAC;KAAA;IAEK,IAAI,CAAO,GAAW,EAAE,IAAQ,EAAE,MAA2B;;YACjE,OAAO,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAI,GAAG,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC;QAC7D,CAAC;KAAA;IAEK,MAAM,CAAI,GAAW,EAAE,MAA2B;;YACtD,OAAO,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,MAAM,CAAI,GAAG,EAAE,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC;QACzD,CAAC;KAAA;IAEK,GAAG,CAAO,GAAW,EAAE,IAAQ,EAAE,MAA2B;;YAChE,OAAO,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAI,GAAG,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC;QAC5D,CAAC;KAAA;IAEK,KAAK,CAAO,GAAW,EAAE,IAAO,EAAE,MAA2B;;YACjE,OAAO,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,CAAI,GAAG,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC;QAC9D,CAAC;KAAA;CACF;AAtBD,wCAsBC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wenex/sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
4
4
|
"description": "Wenex SDK",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -37,10 +37,10 @@
|
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@types/debug": "^4.1.12",
|
|
39
39
|
"@types/jest": "^29.5.10",
|
|
40
|
-
"@types/node": "^20.
|
|
41
|
-
"@types/react": "^18.2.
|
|
42
|
-
"@typescript-eslint/eslint-plugin": "^6.
|
|
43
|
-
"@typescript-eslint/parser": "^6.
|
|
40
|
+
"@types/node": "^20.10.1",
|
|
41
|
+
"@types/react": "^18.2.39",
|
|
42
|
+
"@typescript-eslint/eslint-plugin": "^6.13.1",
|
|
43
|
+
"@typescript-eslint/parser": "^6.13.1",
|
|
44
44
|
"dotenv": "^16.3.1",
|
|
45
45
|
"eslint": "^8.54.0",
|
|
46
46
|
"eslint-config-prettier": "^9.0.0",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"ts-jest": "^29.1.1",
|
|
54
54
|
"ts-node": "^10.9.1",
|
|
55
55
|
"tsconfig-paths": "^4.2.0",
|
|
56
|
-
"typedoc": "^0.25.
|
|
56
|
+
"typedoc": "^0.25.4",
|
|
57
57
|
"typescript": "^5.3.2"
|
|
58
58
|
},
|
|
59
59
|
"files": [
|
|
@@ -5,8 +5,8 @@ export declare class Authentication {
|
|
|
5
5
|
protected readonly request: RequestService;
|
|
6
6
|
constructor(request: RequestService);
|
|
7
7
|
protected readonly url: (path: string) => string;
|
|
8
|
-
token(data: AuthenticationRequest, config?: AxiosRequestConfig):
|
|
9
|
-
logout(data: Token, config?: AxiosRequestConfig):
|
|
10
|
-
verify(data: Token, config?: AxiosRequestConfig):
|
|
8
|
+
token(data: AuthenticationRequest, config?: AxiosRequestConfig): Promise<AuthenticationResponse>;
|
|
9
|
+
logout(data: Token, config?: AxiosRequestConfig): Promise<Result>;
|
|
10
|
+
verify(data: Token, config?: AxiosRequestConfig): Promise<JwtToken>;
|
|
11
11
|
static build(client: AxiosInstance): Authentication;
|
|
12
12
|
}
|
|
@@ -5,7 +5,7 @@ export declare class Authorization {
|
|
|
5
5
|
protected readonly request: RequestService;
|
|
6
6
|
constructor(request: RequestService);
|
|
7
7
|
protected readonly url: (path: string) => string;
|
|
8
|
-
can(data: AuthorizationCanRequest, config?: AxiosRequestConfig):
|
|
9
|
-
policy(data: AuthorizationPolicyRequest, config?: AxiosRequestConfig):
|
|
8
|
+
can(data: AuthorizationCanRequest, config?: AxiosRequestConfig): Promise<AuthorizationCanResponse>;
|
|
9
|
+
policy(data: AuthorizationPolicyRequest, config?: AxiosRequestConfig): Promise<AuthorizationPolicyResponse>;
|
|
10
10
|
static build(client: AxiosInstance): Authorization;
|
|
11
11
|
}
|