@xezzon/zeroweb-sdk 0.8.5-beta.0
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.
Potentially problematic release.
This version of @xezzon/zeroweb-sdk might be problematic. Click here for more details.
- package/README.md +91 -0
- package/dist/cjs/admin/app.js +22 -0
- package/dist/cjs/admin/authn.js +25 -0
- package/dist/cjs/admin/authz.js +41 -0
- package/dist/cjs/admin/crypto.js +9 -0
- package/dist/cjs/admin/dict.js +36 -0
- package/dist/cjs/admin/index.js +55 -0
- package/dist/cjs/admin/role.js +21 -0
- package/dist/cjs/admin/setting.js +31 -0
- package/dist/cjs/admin/user.js +9 -0
- package/dist/cjs/dev/index.js +20 -0
- package/dist/cjs/dev/locale.js +58 -0
- package/dist/cjs/file/attachment.js +69 -0
- package/dist/cjs/file/index.js +37 -0
- package/dist/cjs/file/upload.js +111 -0
- package/dist/cjs/index.js +22 -0
- package/dist/cjs/metadata/index.js +80 -0
- package/dist/cjs/open/index.js +35 -0
- package/dist/cjs/open/openapi.js +38 -0
- package/dist/cjs/open/subscription.js +39 -0
- package/dist/cjs/open/third_party_app.js +49 -0
- package/dist/cjs/types.js +2 -0
- package/dist/esm/admin/app.js +20 -0
- package/dist/esm/admin/authn.js +23 -0
- package/dist/esm/admin/authz.js +39 -0
- package/dist/esm/admin/crypto.js +7 -0
- package/dist/esm/admin/dict.js +34 -0
- package/dist/esm/admin/index.js +50 -0
- package/dist/esm/admin/role.js +19 -0
- package/dist/esm/admin/setting.js +29 -0
- package/dist/esm/admin/user.js +7 -0
- package/dist/esm/dev/index.js +15 -0
- package/dist/esm/dev/locale.js +56 -0
- package/dist/esm/file/attachment.js +66 -0
- package/dist/esm/file/index.js +30 -0
- package/dist/esm/file/upload.js +104 -0
- package/dist/esm/index.js +5 -0
- package/dist/esm/metadata/index.js +74 -0
- package/dist/esm/open/index.js +27 -0
- package/dist/esm/open/openapi.js +35 -0
- package/dist/esm/open/subscription.js +36 -0
- package/dist/esm/open/third_party_app.js +46 -0
- package/dist/esm/types.js +1 -0
- package/dist/typings/admin/app.d.ts +50 -0
- package/dist/typings/admin/authn.d.ts +76 -0
- package/dist/typings/admin/authz.d.ts +79 -0
- package/dist/typings/admin/crypto.d.ts +26 -0
- package/dist/typings/admin/dict.d.ts +86 -0
- package/dist/typings/admin/index.d.ts +51 -0
- package/dist/typings/admin/role.d.ts +60 -0
- package/dist/typings/admin/setting.d.ts +66 -0
- package/dist/typings/admin/user.d.ts +29 -0
- package/dist/typings/dev/index.d.ts +16 -0
- package/dist/typings/dev/locale.d.ts +142 -0
- package/dist/typings/file/attachment.d.ts +149 -0
- package/dist/typings/file/index.d.ts +28 -0
- package/dist/typings/file/upload.d.ts +15 -0
- package/dist/typings/index.d.ts +10 -0
- package/dist/typings/metadata/index.d.ts +124 -0
- package/dist/typings/open/index.d.ts +28 -0
- package/dist/typings/open/openapi.d.ts +67 -0
- package/dist/typings/open/subscription.d.ts +63 -0
- package/dist/typings/open/third_party_app.d.ts +120 -0
- package/dist/typings/types.d.ts +52 -0
- package/package.json +34 -0
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import CryptoJS from "crypto-js";
|
|
11
|
+
import { crc32 } from "js-crc";
|
|
12
|
+
/**
|
|
13
|
+
* 计算文件的校验和
|
|
14
|
+
* @param file 文件
|
|
15
|
+
* @returns 文件的SHA256值
|
|
16
|
+
*/
|
|
17
|
+
export function checksum(file) {
|
|
18
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
19
|
+
if (file.checksum && file.crc) {
|
|
20
|
+
return file;
|
|
21
|
+
}
|
|
22
|
+
return file.arrayBuffer()
|
|
23
|
+
.then(arrayBuffer => Promise.all([
|
|
24
|
+
Promise.resolve()
|
|
25
|
+
.then(() => CryptoJS
|
|
26
|
+
.SHA256(CryptoJS.lib.WordArray.create(arrayBuffer))
|
|
27
|
+
.toString(CryptoJS.enc.Base64))
|
|
28
|
+
.then(checksum => {
|
|
29
|
+
file.checksum = checksum;
|
|
30
|
+
}),
|
|
31
|
+
Promise.resolve()
|
|
32
|
+
.then(() => CryptoJS.enc.Base64.stringify(CryptoJS.enc.Hex.parse(crc32.hex(arrayBuffer))))
|
|
33
|
+
.then(crc => {
|
|
34
|
+
file.crc = crc;
|
|
35
|
+
}),
|
|
36
|
+
]))
|
|
37
|
+
.then(() => file);
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
export function upload(client, attachmentApi) {
|
|
41
|
+
return (file, uploadInfo) => __awaiter(this, void 0, void 0, function* () {
|
|
42
|
+
return file.arrayBuffer()
|
|
43
|
+
.then(arrayBuffer => {
|
|
44
|
+
const partCount = uploadInfo.partCount;
|
|
45
|
+
const partSize = uploadInfo.partSize;
|
|
46
|
+
const parts = [];
|
|
47
|
+
for (let index = 0; index < partCount - 1; index++) {
|
|
48
|
+
const content = arrayBuffer.slice(index * partSize, (index + 1) * partSize);
|
|
49
|
+
const crc = CryptoJS.enc.Base64.stringify(CryptoJS.enc.Hex.parse(crc32.hex(content)));
|
|
50
|
+
parts.push({ content, crc });
|
|
51
|
+
}
|
|
52
|
+
const content = arrayBuffer.slice((partCount - 1) * partSize, file.size);
|
|
53
|
+
const crc = CryptoJS.enc.Base64.stringify(CryptoJS.enc.Hex.parse(crc32.hex(content)));
|
|
54
|
+
parts.push({ content, crc });
|
|
55
|
+
return parts;
|
|
56
|
+
})
|
|
57
|
+
.then(parts => Promise.all(parts
|
|
58
|
+
.map((part, index) => __awaiter(this, void 0, void 0, function* () {
|
|
59
|
+
return Promise.resolve()
|
|
60
|
+
.then(() => {
|
|
61
|
+
if (uploadInfo.partCount > 1) {
|
|
62
|
+
return attachmentApi.getMultipartUploadEndpoint(uploadInfo.id, index + 1, part.crc);
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
return attachmentApi.getUploadEndpoint(uploadInfo.id);
|
|
66
|
+
}
|
|
67
|
+
})
|
|
68
|
+
.then(response => response.data)
|
|
69
|
+
.then((_a) => __awaiter(this, [_a], void 0, function* ({ endpoint }) {
|
|
70
|
+
if (!endpoint) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
const partChecksum = CryptoJS
|
|
74
|
+
.SHA256(CryptoJS.lib.WordArray.create(part.content))
|
|
75
|
+
.toString(CryptoJS.enc.Base64);
|
|
76
|
+
let headers;
|
|
77
|
+
if (uploadInfo.partCount > 1) {
|
|
78
|
+
// 分片上传的请求头
|
|
79
|
+
headers = {
|
|
80
|
+
'x-amz-sdk-checksum-algorithm': 'CRC32',
|
|
81
|
+
'x-amz-checksum-crc32': part.crc,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
headers = {
|
|
86
|
+
'x-amz-sdk-checksum-algorithm': 'SHA256',
|
|
87
|
+
'x-amz-checksum-sha256': partChecksum,
|
|
88
|
+
'x-amz-meta-id': uploadInfo.id,
|
|
89
|
+
'x-amz-meta-filename': file.name,
|
|
90
|
+
'Content-Type': file.type,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
return client
|
|
94
|
+
.request({
|
|
95
|
+
url: endpoint,
|
|
96
|
+
method: 'PUT',
|
|
97
|
+
data: part.content,
|
|
98
|
+
headers: headers,
|
|
99
|
+
});
|
|
100
|
+
}));
|
|
101
|
+
}))))
|
|
102
|
+
.then(() => attachmentApi.finishUpload(uploadInfo.id));
|
|
103
|
+
});
|
|
104
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { default as ZerowebMetadataClient, MenuType, ServiceType, } from './metadata';
|
|
2
|
+
export { default as ZerowebAdminClient } from './admin';
|
|
3
|
+
export { default as ZerowebOpenClient, OpenapiStatus, SubscriptionStatus, } from './open';
|
|
4
|
+
export { default as ZerowebFileClient, FileProvider, AttachmentStatus, } from './file';
|
|
5
|
+
export { default as ZerowebDevClient } from './dev';
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import axios from "axios";
|
|
2
|
+
/**
|
|
3
|
+
* 服务类型
|
|
4
|
+
*/
|
|
5
|
+
export var ServiceType;
|
|
6
|
+
(function (ServiceType) {
|
|
7
|
+
/**
|
|
8
|
+
* 前端
|
|
9
|
+
*/
|
|
10
|
+
ServiceType["CLIENT"] = "CLIENT";
|
|
11
|
+
/**
|
|
12
|
+
* 后端
|
|
13
|
+
*/
|
|
14
|
+
ServiceType["SERVER"] = "SERVER";
|
|
15
|
+
})(ServiceType || (ServiceType = {}));
|
|
16
|
+
/**
|
|
17
|
+
* 菜单类型
|
|
18
|
+
*/
|
|
19
|
+
export var MenuType;
|
|
20
|
+
(function (MenuType) {
|
|
21
|
+
/**
|
|
22
|
+
* 路由
|
|
23
|
+
*/
|
|
24
|
+
MenuType["ROUTE"] = "ROUTE";
|
|
25
|
+
/**
|
|
26
|
+
* 外部链接。
|
|
27
|
+
* 点击后会打开一个新的标签页
|
|
28
|
+
*/
|
|
29
|
+
MenuType["EXTERNAL_LINK"] = "EXTERNAL_LINK";
|
|
30
|
+
/**
|
|
31
|
+
* 嵌入页面。
|
|
32
|
+
* 会在当前页面嵌入一个外部网页。
|
|
33
|
+
*/
|
|
34
|
+
MenuType["EMBEDDED"] = "EMBEDDED";
|
|
35
|
+
/**
|
|
36
|
+
* 接口权限
|
|
37
|
+
* 路径格式为 `resource:operation`,operation 通常为 `read`(可省略)、`write` 等。
|
|
38
|
+
*/
|
|
39
|
+
MenuType["PERMISSION"] = "PERMISSION";
|
|
40
|
+
/**
|
|
41
|
+
* 资源权限
|
|
42
|
+
* 路径格式为 `resource:#:operation`,operation 通常为 `read`(可省略)、`write` 等。
|
|
43
|
+
*/
|
|
44
|
+
MenuType["GROUP_PERMISSION"] = "GROUP_PERMISSION";
|
|
45
|
+
})(MenuType || (MenuType = {}));
|
|
46
|
+
export default (config) => {
|
|
47
|
+
const instance = axios.create(config);
|
|
48
|
+
return {
|
|
49
|
+
/**
|
|
50
|
+
* 拦截器方法
|
|
51
|
+
*/
|
|
52
|
+
interceptors: instance.interceptors,
|
|
53
|
+
/**
|
|
54
|
+
* 获取服务信息
|
|
55
|
+
* @returns 服务信息
|
|
56
|
+
*/
|
|
57
|
+
loadServiceInfo() {
|
|
58
|
+
return instance.request({
|
|
59
|
+
url: '/metadata/info.json',
|
|
60
|
+
method: 'GET',
|
|
61
|
+
});
|
|
62
|
+
},
|
|
63
|
+
/**
|
|
64
|
+
* 获取菜单信息
|
|
65
|
+
* @returns 菜单信息
|
|
66
|
+
*/
|
|
67
|
+
loadResourceInfo() {
|
|
68
|
+
return instance.request({
|
|
69
|
+
url: '/metadata/menu.json',
|
|
70
|
+
method: 'GET',
|
|
71
|
+
});
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import axios from "axios";
|
|
2
|
+
import openapi from "./openapi";
|
|
3
|
+
import subscription from "./subscription";
|
|
4
|
+
import thirdPartyApp from "./third_party_app";
|
|
5
|
+
export default (config) => {
|
|
6
|
+
const instance = axios.create(config);
|
|
7
|
+
return {
|
|
8
|
+
/**
|
|
9
|
+
* 拦截器方法
|
|
10
|
+
*/
|
|
11
|
+
interceptors: instance.interceptors,
|
|
12
|
+
/**
|
|
13
|
+
* 对外接口相关接口
|
|
14
|
+
*/
|
|
15
|
+
openapi: openapi(instance),
|
|
16
|
+
/**
|
|
17
|
+
* 第三方应用订阅相关接口
|
|
18
|
+
*/
|
|
19
|
+
subscription: subscription(instance),
|
|
20
|
+
/**
|
|
21
|
+
* 第三方应用相关接口
|
|
22
|
+
*/
|
|
23
|
+
thirdPartyApp: thirdPartyApp(instance),
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
export { OpenapiStatus } from './openapi';
|
|
27
|
+
export { SubscriptionStatus } from './subscription';
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 对外接口状态
|
|
3
|
+
*/
|
|
4
|
+
export var OpenapiStatus;
|
|
5
|
+
(function (OpenapiStatus) {
|
|
6
|
+
/**
|
|
7
|
+
* 草稿
|
|
8
|
+
*/
|
|
9
|
+
OpenapiStatus[OpenapiStatus["DRAFT"] = 0] = "DRAFT";
|
|
10
|
+
/**
|
|
11
|
+
* 已发布
|
|
12
|
+
*/
|
|
13
|
+
OpenapiStatus[OpenapiStatus["PUBLISHED"] = 1] = "PUBLISHED";
|
|
14
|
+
})(OpenapiStatus || (OpenapiStatus = {}));
|
|
15
|
+
export default (client) => ({
|
|
16
|
+
addOpenapi: (openapi) => client.request({
|
|
17
|
+
url: '/openapi',
|
|
18
|
+
method: 'POST',
|
|
19
|
+
data: openapi,
|
|
20
|
+
}),
|
|
21
|
+
getOpenapiList: (odata) => client.request({
|
|
22
|
+
url: '/openapi',
|
|
23
|
+
method: 'GET',
|
|
24
|
+
params: odata,
|
|
25
|
+
}),
|
|
26
|
+
modifyOpenapi: (openapi) => client.request({
|
|
27
|
+
url: '/openapi',
|
|
28
|
+
method: 'PUT',
|
|
29
|
+
data: openapi,
|
|
30
|
+
}),
|
|
31
|
+
publishOpenapi: (id) => client.request({
|
|
32
|
+
url: `/openapi/publish/${id}`,
|
|
33
|
+
method: 'PUT',
|
|
34
|
+
}),
|
|
35
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { BASE_URL as THIRD_PARTY_APP_URL } from './third_party_app';
|
|
2
|
+
const BASE_URL = '/subscription';
|
|
3
|
+
/**
|
|
4
|
+
* 订阅状态
|
|
5
|
+
*/
|
|
6
|
+
export var SubscriptionStatus;
|
|
7
|
+
(function (SubscriptionStatus) {
|
|
8
|
+
/**
|
|
9
|
+
* 未订阅
|
|
10
|
+
*/
|
|
11
|
+
SubscriptionStatus[SubscriptionStatus["NONE"] = 0] = "NONE";
|
|
12
|
+
/**
|
|
13
|
+
* 审核中
|
|
14
|
+
*/
|
|
15
|
+
SubscriptionStatus[SubscriptionStatus["AUDITING"] = 1] = "AUDITING";
|
|
16
|
+
/**
|
|
17
|
+
* 已订阅
|
|
18
|
+
*/
|
|
19
|
+
SubscriptionStatus[SubscriptionStatus["SUBSCRIBED"] = 2] = "SUBSCRIBED";
|
|
20
|
+
})(SubscriptionStatus || (SubscriptionStatus = {}));
|
|
21
|
+
export default (client) => ({
|
|
22
|
+
subscribe: (subscription) => client.request({
|
|
23
|
+
url: `${BASE_URL}`,
|
|
24
|
+
method: 'POST',
|
|
25
|
+
data: subscription,
|
|
26
|
+
}),
|
|
27
|
+
listSubscription: (appId, odata) => client.request({
|
|
28
|
+
url: `${THIRD_PARTY_APP_URL}/${appId}/subscription`,
|
|
29
|
+
method: 'GET',
|
|
30
|
+
params: odata,
|
|
31
|
+
}),
|
|
32
|
+
auditSubscription: (id) => client.request({
|
|
33
|
+
url: `${BASE_URL}/audit/${id}`,
|
|
34
|
+
method: 'PUT',
|
|
35
|
+
}),
|
|
36
|
+
});
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export const BASE_URL = '/third-party-app';
|
|
2
|
+
export default (client) => ({
|
|
3
|
+
addThirdPartyApp: (thirdPartyApp) => client.request({
|
|
4
|
+
url: `${BASE_URL}`,
|
|
5
|
+
method: 'POST',
|
|
6
|
+
data: thirdPartyApp,
|
|
7
|
+
}),
|
|
8
|
+
listMyThirdPartyApp: (odata) => client.request({
|
|
9
|
+
url: `${BASE_URL}/mine`,
|
|
10
|
+
method: 'GET',
|
|
11
|
+
params: odata,
|
|
12
|
+
}),
|
|
13
|
+
listThirdPartyApp: (odata) => client.request({
|
|
14
|
+
url: `${BASE_URL}`,
|
|
15
|
+
method: 'GET',
|
|
16
|
+
params: odata,
|
|
17
|
+
}),
|
|
18
|
+
rollAccessSecret: (id) => client.request({
|
|
19
|
+
url: `${BASE_URL}/${id}/roll`,
|
|
20
|
+
method: 'PATCH',
|
|
21
|
+
}),
|
|
22
|
+
inviteMember: (appId, timeout) => client.request({
|
|
23
|
+
url: `/third-party-app/${appId}/member`,
|
|
24
|
+
method: 'POST',
|
|
25
|
+
params: { timeout, },
|
|
26
|
+
}),
|
|
27
|
+
inviteParticularMember: (appId, userId, timeout) => client.request({
|
|
28
|
+
url: `/third-party-app/${appId}/member`,
|
|
29
|
+
method: 'POST',
|
|
30
|
+
params: { userId, timeout, },
|
|
31
|
+
}),
|
|
32
|
+
addThirdPartyAppMember: (token) => client.request({
|
|
33
|
+
url: `/third-party-app/-/member`,
|
|
34
|
+
method: 'PUT',
|
|
35
|
+
params: { token, },
|
|
36
|
+
}),
|
|
37
|
+
listThirdPartyAppMember: (appId) => client.request({
|
|
38
|
+
url: `/third-party-app/${appId}/member`,
|
|
39
|
+
method: 'GET',
|
|
40
|
+
}),
|
|
41
|
+
moveOwnerShip: (appId, userId) => client.request({
|
|
42
|
+
url: `/third-party-app/${appId}/owner`,
|
|
43
|
+
method: 'PATCH',
|
|
44
|
+
params: { userId, },
|
|
45
|
+
}),
|
|
46
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { HttpClient, Id, PResponse } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* 应用
|
|
4
|
+
*/
|
|
5
|
+
export interface App {
|
|
6
|
+
/**
|
|
7
|
+
* 应用ID
|
|
8
|
+
*/
|
|
9
|
+
id: string;
|
|
10
|
+
/**
|
|
11
|
+
* 应用名称
|
|
12
|
+
*/
|
|
13
|
+
name: string;
|
|
14
|
+
/**
|
|
15
|
+
* 应用基础访问路径
|
|
16
|
+
*/
|
|
17
|
+
baseUrl: string;
|
|
18
|
+
/**
|
|
19
|
+
* 应用排序
|
|
20
|
+
* 顺序越小越靠前
|
|
21
|
+
*/
|
|
22
|
+
ordinal: number;
|
|
23
|
+
}
|
|
24
|
+
declare type AddAppReq = Omit<App, 'id'>;
|
|
25
|
+
declare type UpdateAppReq = App;
|
|
26
|
+
export interface AppAPI {
|
|
27
|
+
/**
|
|
28
|
+
* 新增应用
|
|
29
|
+
* @param app 应用
|
|
30
|
+
* @returns 应用ID
|
|
31
|
+
*/
|
|
32
|
+
addApp: (app: AddAppReq) => PResponse<Id>;
|
|
33
|
+
/**
|
|
34
|
+
* 查询应用列表
|
|
35
|
+
* @returns 应用列表
|
|
36
|
+
*/
|
|
37
|
+
listApp: () => PResponse<App[]>;
|
|
38
|
+
/**
|
|
39
|
+
* 更新应用信息
|
|
40
|
+
* @param app 应用信息
|
|
41
|
+
*/
|
|
42
|
+
updateApp: (app: UpdateAppReq) => PResponse<void>;
|
|
43
|
+
/**
|
|
44
|
+
* 删除应用
|
|
45
|
+
* @param id 应用ID
|
|
46
|
+
*/
|
|
47
|
+
deleteApp: (id: string) => PResponse<void>;
|
|
48
|
+
}
|
|
49
|
+
declare const _default: (client: HttpClient) => AppAPI;
|
|
50
|
+
export default _default;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { HttpClient, PResponse } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* 基础认证
|
|
4
|
+
*/
|
|
5
|
+
export interface BasicAuth {
|
|
6
|
+
/**
|
|
7
|
+
* 用户名
|
|
8
|
+
*/
|
|
9
|
+
username: string;
|
|
10
|
+
/**
|
|
11
|
+
* 口令
|
|
12
|
+
*/
|
|
13
|
+
password: string;
|
|
14
|
+
}
|
|
15
|
+
export interface SaTokenInfo {
|
|
16
|
+
/**
|
|
17
|
+
* token 名称
|
|
18
|
+
*/
|
|
19
|
+
tokenName: string;
|
|
20
|
+
/**
|
|
21
|
+
* token 值
|
|
22
|
+
*/
|
|
23
|
+
tokenValue: string;
|
|
24
|
+
}
|
|
25
|
+
export interface JwtClaim {
|
|
26
|
+
/**
|
|
27
|
+
* 用户ID
|
|
28
|
+
*/
|
|
29
|
+
sub: string;
|
|
30
|
+
/**
|
|
31
|
+
* 用户名
|
|
32
|
+
*/
|
|
33
|
+
preferredUsername: string;
|
|
34
|
+
/**
|
|
35
|
+
* 用户昵称
|
|
36
|
+
*/
|
|
37
|
+
nickname: string;
|
|
38
|
+
/**
|
|
39
|
+
* 角色
|
|
40
|
+
*/
|
|
41
|
+
roles: string[];
|
|
42
|
+
/**
|
|
43
|
+
* 权限
|
|
44
|
+
*/
|
|
45
|
+
entitlements: string[];
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* @see {@link https://openid.net/specs/openid-connect-core-1_0.html|OIDC}
|
|
49
|
+
*/
|
|
50
|
+
export interface OidcToken {
|
|
51
|
+
access_token: string;
|
|
52
|
+
refresh_token: string;
|
|
53
|
+
expires_in: number;
|
|
54
|
+
id_token: string;
|
|
55
|
+
}
|
|
56
|
+
export interface AuthnAPI {
|
|
57
|
+
/**
|
|
58
|
+
* 基础认证
|
|
59
|
+
* @param user 用户名口令
|
|
60
|
+
*/
|
|
61
|
+
basicLogin: (user: BasicAuth) => PResponse<OidcToken>;
|
|
62
|
+
/**
|
|
63
|
+
* @returns 当前用户的认证信息
|
|
64
|
+
*/
|
|
65
|
+
self: () => PResponse<JwtClaim>;
|
|
66
|
+
/**
|
|
67
|
+
* @returns 用户令牌
|
|
68
|
+
*/
|
|
69
|
+
token: () => PResponse<OidcToken>;
|
|
70
|
+
/**
|
|
71
|
+
* 退出登录
|
|
72
|
+
*/
|
|
73
|
+
logout: () => PResponse<void>;
|
|
74
|
+
}
|
|
75
|
+
declare const _default: (client: HttpClient) => AuthnAPI;
|
|
76
|
+
export default _default;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { HttpClient, PResponse } from "../types";
|
|
2
|
+
import { User } from "./user";
|
|
3
|
+
import { Role } from "./role";
|
|
4
|
+
/**
|
|
5
|
+
* 角色-用户
|
|
6
|
+
*/
|
|
7
|
+
export interface RoleUser {
|
|
8
|
+
id: string;
|
|
9
|
+
/**
|
|
10
|
+
* 角色ID
|
|
11
|
+
*/
|
|
12
|
+
roleId: string;
|
|
13
|
+
/**
|
|
14
|
+
* 用户ID
|
|
15
|
+
*/
|
|
16
|
+
userId: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* 角色-接口权限
|
|
20
|
+
*/
|
|
21
|
+
export interface RolePermission {
|
|
22
|
+
id: string;
|
|
23
|
+
/**
|
|
24
|
+
* 角色ID
|
|
25
|
+
*/
|
|
26
|
+
roleId: string;
|
|
27
|
+
/**
|
|
28
|
+
* 接口权限编码
|
|
29
|
+
*/
|
|
30
|
+
permission: string;
|
|
31
|
+
}
|
|
32
|
+
export interface AuthzAPI {
|
|
33
|
+
/**
|
|
34
|
+
* 查询角色绑定的用户
|
|
35
|
+
* @param roleId 角色ID
|
|
36
|
+
* @returns 用户信息列表
|
|
37
|
+
*/
|
|
38
|
+
queryUserByRole: (roleId: string) => PResponse<User[]>;
|
|
39
|
+
/**
|
|
40
|
+
* 将用户绑定到角色
|
|
41
|
+
* @param roleUsers 角色-用户绑定关系
|
|
42
|
+
*/
|
|
43
|
+
bindUserToRole: (roleUsers: RoleUser[]) => PResponse<void>;
|
|
44
|
+
/**
|
|
45
|
+
* 解除用户与角色的关联
|
|
46
|
+
* @param roleUsers 角色-用户关联
|
|
47
|
+
*/
|
|
48
|
+
releaseRoleUser: (roleUsers: RoleUser[]) => PResponse<void>;
|
|
49
|
+
/**
|
|
50
|
+
* 查询角色的接口权限编码集合
|
|
51
|
+
* @param roleId 角色ID
|
|
52
|
+
* @returns 接口权限编码
|
|
53
|
+
*/
|
|
54
|
+
queryPermissionByRole: (roleId: string) => PResponse<string[]>;
|
|
55
|
+
/**
|
|
56
|
+
* 解除角色与接口权限的关联
|
|
57
|
+
* @param rolePermissions 角色-接口权限关系
|
|
58
|
+
*/
|
|
59
|
+
bindPermissionToRole: (rolePermissions: RolePermission[]) => PResponse<void>;
|
|
60
|
+
/**
|
|
61
|
+
* 解除角色与接口权限的关联
|
|
62
|
+
* @param rolePermissions 角色-接口权限关系
|
|
63
|
+
*/
|
|
64
|
+
releaseRolePermission: (rolePermissions: RolePermission[]) => PResponse<void>;
|
|
65
|
+
/**
|
|
66
|
+
* 查询用户关联的角色
|
|
67
|
+
* @param userId 用户ID
|
|
68
|
+
* @returns 角色信息集合
|
|
69
|
+
*/
|
|
70
|
+
queryRoleByUser: (userId: string) => PResponse<Role[]>;
|
|
71
|
+
/**
|
|
72
|
+
* 查询接口权限关联的角色集合
|
|
73
|
+
* @param permission 接口权限编码
|
|
74
|
+
* @returns 角色信息集合
|
|
75
|
+
*/
|
|
76
|
+
queryRoleByPermission: (permission: string) => PResponse<Role[]>;
|
|
77
|
+
}
|
|
78
|
+
declare const _default: (client: HttpClient) => AuthzAPI;
|
|
79
|
+
export default _default;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { HttpClient, PResponse } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* 口令强度评估结果
|
|
4
|
+
*/
|
|
5
|
+
export interface PasswordStrength {
|
|
6
|
+
/**
|
|
7
|
+
* 口令强度得分
|
|
8
|
+
*/
|
|
9
|
+
score: number;
|
|
10
|
+
/**
|
|
11
|
+
* 强度量级
|
|
12
|
+
*/
|
|
13
|
+
guessesLog10: number;
|
|
14
|
+
}
|
|
15
|
+
export interface CryptoAPI {
|
|
16
|
+
/**
|
|
17
|
+
* 计算口令强度。
|
|
18
|
+
* @param password 口令
|
|
19
|
+
* @param username 用户名
|
|
20
|
+
*/
|
|
21
|
+
passwordStrength: (password: string, directory: {
|
|
22
|
+
username?: string;
|
|
23
|
+
}) => PResponse<PasswordStrength>;
|
|
24
|
+
}
|
|
25
|
+
declare const _default: ({ request }: HttpClient) => CryptoAPI;
|
|
26
|
+
export default _default;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { HttpClient, Id, OData, Page, PResponse } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* 字典
|
|
4
|
+
*/
|
|
5
|
+
export interface Dict {
|
|
6
|
+
id: string;
|
|
7
|
+
/**
|
|
8
|
+
* 字典目
|
|
9
|
+
*/
|
|
10
|
+
tag: string;
|
|
11
|
+
/**
|
|
12
|
+
* 字典键
|
|
13
|
+
*/
|
|
14
|
+
code: string;
|
|
15
|
+
/**
|
|
16
|
+
* 字典值
|
|
17
|
+
*/
|
|
18
|
+
label?: string;
|
|
19
|
+
/**
|
|
20
|
+
* 排序号
|
|
21
|
+
* 数值越小,顺序越靠前
|
|
22
|
+
*/
|
|
23
|
+
ordinal: number;
|
|
24
|
+
/**
|
|
25
|
+
* 上级字典ID
|
|
26
|
+
*/
|
|
27
|
+
parentId: string;
|
|
28
|
+
/**
|
|
29
|
+
* 是否启用
|
|
30
|
+
*/
|
|
31
|
+
enabled: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* 是否允许修改
|
|
34
|
+
*/
|
|
35
|
+
readonly editable: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* 下级字典列表
|
|
38
|
+
*/
|
|
39
|
+
children?: Dict[];
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* 新增字典
|
|
43
|
+
*/
|
|
44
|
+
declare type AddDictReq = Omit<Dict, 'id' | 'enabled' | 'editable' | 'children'>;
|
|
45
|
+
/**
|
|
46
|
+
* 更新字典
|
|
47
|
+
*/
|
|
48
|
+
declare type ModifyDictReq = Omit<Dict, 'tag' | 'editable' | 'children'>;
|
|
49
|
+
export interface DictAPI {
|
|
50
|
+
/**
|
|
51
|
+
* 新增字典
|
|
52
|
+
* @param dict 字典
|
|
53
|
+
*/
|
|
54
|
+
addDict: (dict: AddDictReq) => PResponse<Id>;
|
|
55
|
+
/**
|
|
56
|
+
* 分页查询字典目列表
|
|
57
|
+
* @param odata 分页参数
|
|
58
|
+
* @returns 字典目列表
|
|
59
|
+
*/
|
|
60
|
+
getDictTagList: (odata: OData) => PResponse<Page<Dict>>;
|
|
61
|
+
/**
|
|
62
|
+
* 查询指定字典目下所有字典项的列表
|
|
63
|
+
* @param tag 字典目编码
|
|
64
|
+
* @returns 字典项列表(树形)
|
|
65
|
+
*/
|
|
66
|
+
getDictTreeByTag: (tag: string) => PResponse<Dict[]>;
|
|
67
|
+
/**
|
|
68
|
+
* 更新字典目/字典项
|
|
69
|
+
* @param dict 字典
|
|
70
|
+
* @returns
|
|
71
|
+
*/
|
|
72
|
+
modifyDict: (dict: ModifyDictReq) => PResponse<void>;
|
|
73
|
+
/**
|
|
74
|
+
* 批量更新字典状态
|
|
75
|
+
* @param ids 字典ID集合
|
|
76
|
+
* @param enabled 更新后的字典启用状态
|
|
77
|
+
*/
|
|
78
|
+
updateDictStatus: (ids: string[], enabled: boolean) => PResponse<void>;
|
|
79
|
+
/**
|
|
80
|
+
* 批量删除字典目/字典项
|
|
81
|
+
* @param ids 字典ID集合
|
|
82
|
+
*/
|
|
83
|
+
removeDict: (ids: string[]) => PResponse<void>;
|
|
84
|
+
}
|
|
85
|
+
declare const _default: (client: HttpClient) => DictAPI;
|
|
86
|
+
export default _default;
|