@openuverse/uvapi 0.0.0-stage → 1.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.
- package/README.md +3871 -3
- package/dist/_virtual/_commonjsHelpers.js +6 -0
- package/dist/_virtual/index.js +4 -0
- package/dist/api/RestAPIClient.d.ts +191 -0
- package/dist/api/RestAPIClient.js +328 -0
- package/dist/api/WebSocketClient.d.ts +174 -0
- package/dist/api/WebSocketClient.js +277 -0
- package/dist/api/index.d.ts +6 -0
- package/dist/api/modules/index.d.ts +2 -0
- package/dist/api/modules/task.d.ts +124 -0
- package/dist/api/modules/task.js +121 -0
- package/dist/api/modules/user.d.ts +114 -0
- package/dist/api/modules/user.js +113 -0
- package/dist/config/index.d.ts +120 -0
- package/dist/config/index.js +112 -0
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/useAttributeMonitor.d.ts +45 -0
- package/dist/hooks/useAttributeMonitor.js +115 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.js +93 -0
- package/dist/locale/de-DE.d.ts +18 -0
- package/dist/locale/de-DE.js +20 -0
- package/dist/locale/en-US.d.ts +18 -0
- package/dist/locale/en-US.js +20 -0
- package/dist/locale/es-ES.d.ts +18 -0
- package/dist/locale/es-ES.js +20 -0
- package/dist/locale/fr-FR.d.ts +18 -0
- package/dist/locale/fr-FR.js +20 -0
- package/dist/locale/id-ID.d.ts +18 -0
- package/dist/locale/id-ID.js +20 -0
- package/dist/locale/index.d.ts +19 -0
- package/dist/locale/index.js +70 -0
- package/dist/locale/ja-JP.d.ts +18 -0
- package/dist/locale/ja-JP.js +20 -0
- package/dist/locale/ko-KR.d.ts +18 -0
- package/dist/locale/ko-KR.js +20 -0
- package/dist/locale/pl-PL.d.ts +18 -0
- package/dist/locale/pl-PL.js +20 -0
- package/dist/locale/pt-BR.d.ts +18 -0
- package/dist/locale/pt-BR.js +20 -0
- package/dist/locale/ru-RU.d.ts +18 -0
- package/dist/locale/ru-RU.js +20 -0
- package/dist/locale/th-TH.d.ts +18 -0
- package/dist/locale/th-TH.js +20 -0
- package/dist/locale/zh-CN.d.ts +18 -0
- package/dist/locale/zh-CN.js +20 -0
- package/dist/locale/zh-TW.d.ts +18 -0
- package/dist/locale/zh-TW.js +20 -0
- package/dist/node_modules/@msgpack/msgpack/dist.esm/CachedKeyDecoder.js +38 -0
- package/dist/node_modules/@msgpack/msgpack/dist.esm/DecodeError.js +14 -0
- package/dist/node_modules/@msgpack/msgpack/dist.esm/Decoder.js +474 -0
- package/dist/node_modules/@msgpack/msgpack/dist.esm/Encoder.js +232 -0
- package/dist/node_modules/@msgpack/msgpack/dist.esm/ExtData.js +8 -0
- package/dist/node_modules/@msgpack/msgpack/dist.esm/ExtensionCodec.js +46 -0
- package/dist/node_modules/@msgpack/msgpack/dist.esm/decode.js +7 -0
- package/dist/node_modules/@msgpack/msgpack/dist.esm/encode.js +7 -0
- package/dist/node_modules/@msgpack/msgpack/dist.esm/timestamp.js +66 -0
- package/dist/node_modules/@msgpack/msgpack/dist.esm/utils/int.js +24 -0
- package/dist/node_modules/@msgpack/msgpack/dist.esm/utils/prettyByte.js +6 -0
- package/dist/node_modules/@msgpack/msgpack/dist.esm/utils/typedArrays.js +9 -0
- package/dist/node_modules/@msgpack/msgpack/dist.esm/utils/utf8.js +93 -0
- package/dist/node_modules/axios/index.js +38 -0
- package/dist/node_modules/axios/lib/adapters/adapters.js +55 -0
- package/dist/node_modules/axios/lib/adapters/fetch.js +169 -0
- package/dist/node_modules/axios/lib/adapters/xhr.js +72 -0
- package/dist/node_modules/axios/lib/axios.js +46 -0
- package/dist/node_modules/axios/lib/cancel/CancelToken.js +77 -0
- package/dist/node_modules/axios/lib/cancel/CanceledError.js +11 -0
- package/dist/node_modules/axios/lib/cancel/isCancel.js +6 -0
- package/dist/node_modules/axios/lib/core/Axios.js +136 -0
- package/dist/node_modules/axios/lib/core/AxiosError.js +56 -0
- package/dist/node_modules/axios/lib/core/AxiosHeaders.js +181 -0
- package/dist/node_modules/axios/lib/core/InterceptorManager.js +58 -0
- package/dist/node_modules/axios/lib/core/buildFullPath.js +9 -0
- package/dist/node_modules/axios/lib/core/dispatchRequest.js +31 -0
- package/dist/node_modules/axios/lib/core/mergeConfig.js +70 -0
- package/dist/node_modules/axios/lib/core/settle.js +14 -0
- package/dist/node_modules/axios/lib/core/transformData.js +13 -0
- package/dist/node_modules/axios/lib/defaults/index.js +89 -0
- package/dist/node_modules/axios/lib/defaults/transitional.js +8 -0
- package/dist/node_modules/axios/lib/env/data.js +4 -0
- package/dist/node_modules/axios/lib/helpers/AxiosURLSearchParams.js +33 -0
- package/dist/node_modules/axios/lib/helpers/HttpStatusCode.js +71 -0
- package/dist/node_modules/axios/lib/helpers/bind.js +8 -0
- package/dist/node_modules/axios/lib/helpers/buildURL.js +23 -0
- package/dist/node_modules/axios/lib/helpers/combineURLs.js +6 -0
- package/dist/node_modules/axios/lib/helpers/composeSignals.js +30 -0
- package/dist/node_modules/axios/lib/helpers/cookies.js +32 -0
- package/dist/node_modules/axios/lib/helpers/formDataToJSON.js +31 -0
- package/dist/node_modules/axios/lib/helpers/isAbsoluteURL.js +6 -0
- package/dist/node_modules/axios/lib/helpers/isAxiosError.js +7 -0
- package/dist/node_modules/axios/lib/helpers/isURLSameOrigin.js +8 -0
- package/dist/node_modules/axios/lib/helpers/null.js +4 -0
- package/dist/node_modules/axios/lib/helpers/parseHeaders.js +30 -0
- package/dist/node_modules/axios/lib/helpers/parseProtocol.js +7 -0
- package/dist/node_modules/axios/lib/helpers/progressEventReducer.js +35 -0
- package/dist/node_modules/axios/lib/helpers/resolveConfig.js +33 -0
- package/dist/node_modules/axios/lib/helpers/speedometer.js +19 -0
- package/dist/node_modules/axios/lib/helpers/spread.js +8 -0
- package/dist/node_modules/axios/lib/helpers/throttle.js +15 -0
- package/dist/node_modules/axios/lib/helpers/toFormData.js +85 -0
- package/dist/node_modules/axios/lib/helpers/toURLEncodedForm.js +14 -0
- package/dist/node_modules/axios/lib/helpers/trackStream.js +63 -0
- package/dist/node_modules/axios/lib/helpers/validator.js +54 -0
- package/dist/node_modules/axios/lib/platform/browser/classes/Blob.js +4 -0
- package/dist/node_modules/axios/lib/platform/browser/classes/FormData.js +4 -0
- package/dist/node_modules/axios/lib/platform/browser/classes/URLSearchParams.js +5 -0
- package/dist/node_modules/axios/lib/platform/browser/index.js +15 -0
- package/dist/node_modules/axios/lib/platform/common/utils.js +9 -0
- package/dist/node_modules/axios/lib/platform/index.js +9 -0
- package/dist/node_modules/axios/lib/utils.js +237 -0
- package/dist/node_modules/postcss-pxtorem/index.js +109 -0
- package/dist/node_modules/postcss-pxtorem/lib/filter-prop-list.js +13 -0
- package/dist/node_modules/postcss-pxtorem/lib/pixel-unit-regex.js +7 -0
- package/dist/node_modules/postcss-pxtorem/lib/type.js +14 -0
- package/dist/preload/index.d.ts +125 -0
- package/dist/preload/index.js +79 -0
- package/dist/store/index.d.ts +1 -0
- package/dist/store/storeFactory.d.ts +584 -0
- package/dist/store/storeFactory.js +216 -0
- package/dist/theme/index.d.ts +1 -0
- package/dist/theme/index.js +14 -0
- package/dist/types/index.d.ts +57 -0
- package/dist/types/uVerseAPI.d.ts +67 -0
- package/dist/utils/_internal.d.ts +14 -0
- package/dist/utils/_internal.js +72 -0
- package/dist/utils/constance.d.ts +16 -0
- package/dist/utils/constance.js +7 -0
- package/dist/utils/index.d.ts +79 -0
- package/dist/utils/index.js +96 -0
- package/dist/utils/logger.d.ts +118 -0
- package/dist/utils/logger.js +170 -0
- package/dist/utils/px2rem/remAdapter.d.ts +17 -0
- package/dist/utils/px2rem/remAdapter.js +62 -0
- package/dist/utils/px2rem/vite.d.ts +14 -0
- package/dist/utils/px2rem/vite.js +33 -0
- package/package.json +102 -4
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { RestAPIClient as e } from "../RestAPIClient.js";
|
|
2
|
+
class r extends e {
|
|
3
|
+
/**
|
|
4
|
+
* 创建 TaskClient 实例
|
|
5
|
+
* @param {Omit<RestAPIConfig, 'workerId'>} [config] - REST API 配置对象(可选参数)
|
|
6
|
+
* @param {string} [config.baseURL] - API 基础 URL(可选)
|
|
7
|
+
* @param {number} [config.timeout] - 请求超时时间(可选)
|
|
8
|
+
* @param {Record<string, string>} [config.headers] - 自定义请求头(可选)
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* const taskClient = new TaskClient({
|
|
12
|
+
* baseURL: 'https://api.example.com',
|
|
13
|
+
* timeout: 5000,
|
|
14
|
+
* headers: {
|
|
15
|
+
* 'Authorization': 'Bearer token123'
|
|
16
|
+
* }
|
|
17
|
+
* });
|
|
18
|
+
*/
|
|
19
|
+
constructor(t) {
|
|
20
|
+
super({
|
|
21
|
+
// workerId: '5cd2fc653a0c4f50b894db9a8db627e3', // 待实际项目确认最终workerId
|
|
22
|
+
...t
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* 创建新任务
|
|
27
|
+
* @param {Omit<Task, 'id' | 'created_at' | 'updated_at'>} task - 任务信息对象
|
|
28
|
+
* @param {string} task.title - 任务标题(必填)
|
|
29
|
+
* @param {string} [task.description] - 任务描述(可选参数)
|
|
30
|
+
* @param {boolean} [task.completed] - 任务完成状态(可选参数)
|
|
31
|
+
* @param {1 | 2 | 3 | 4 | 5} [task.priority] - 任务优先级,1-5(可选参数)
|
|
32
|
+
* @param {number} [task.user_id] - 关联的用户 ID(可选参数)
|
|
33
|
+
* @returns {Promise<Response<Task>>} 返回包含任务对象的响应
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* const response = await taskClient.create_task({
|
|
37
|
+
* title: '完成项目文档',
|
|
38
|
+
* description: '编写 API 接口文档',
|
|
39
|
+
* completed: false,
|
|
40
|
+
* priority: 1,
|
|
41
|
+
* user_id: 123
|
|
42
|
+
* });
|
|
43
|
+
* const newTask = response.result;
|
|
44
|
+
*/
|
|
45
|
+
create_task(t) {
|
|
46
|
+
return this.action("create_task", t);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* 获取所有任务列表
|
|
50
|
+
* @returns {Promise<Response<Task[]>>} 返回包含任务列表的响应
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* const response = await taskClient.get_tasks();
|
|
54
|
+
* const tasks = response.result;
|
|
55
|
+
*/
|
|
56
|
+
get_tasks() {
|
|
57
|
+
return this.action("get_tasks");
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* 根据任务 ID 获取单个任务信息
|
|
61
|
+
* @param {Object} data - 查询参数对象
|
|
62
|
+
* @param {number} data.task_id - 任务 ID(必填)
|
|
63
|
+
* @returns {Promise<Response<Task>>} 返回包含任务对象的响应
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* const response = await taskClient.get_task({
|
|
67
|
+
* task_id: 1
|
|
68
|
+
* });
|
|
69
|
+
* const task = response.result;
|
|
70
|
+
*/
|
|
71
|
+
get_task(t) {
|
|
72
|
+
return this.action("get_task", t);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* 更新任务信息
|
|
76
|
+
* @param {Object} data - 更新参数对象
|
|
77
|
+
* @param {number} data.task_id - 任务 ID(必填)
|
|
78
|
+
* @param {Object} data.task_update - 任务更新信息对象(必填)
|
|
79
|
+
* @param {string} [data.task_update.title] - 任务标题(可选参数)
|
|
80
|
+
* @param {string} [data.task_update.description] - 任务描述(可选参数)
|
|
81
|
+
* @param {boolean} [data.task_update.completed] - 任务完成状态(可选参数)
|
|
82
|
+
* @param {1 | 2 | 3 | 4 | 5} [data.task_update.priority] - 任务优先级,1-5(可选参数)
|
|
83
|
+
* @param {number} [data.task_update.user_id] - 关联的用户 ID(可选参数)
|
|
84
|
+
* @returns {Promise<Response<Task>>} 返回包含更新后任务对象的响应
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* const response = await taskClient.update_task({
|
|
88
|
+
* task_id: 1,
|
|
89
|
+
* task_update: {
|
|
90
|
+
* title: '完成项目文档(已更新)',
|
|
91
|
+
* description: '编写完整的 API 接口文档',
|
|
92
|
+
* completed: true,
|
|
93
|
+
* priority: 2,
|
|
94
|
+
* user_id: 456
|
|
95
|
+
* }
|
|
96
|
+
* });
|
|
97
|
+
* const updatedTask = response.result;
|
|
98
|
+
*/
|
|
99
|
+
update_task(t) {
|
|
100
|
+
return this.action("update_task", t);
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* 删除任务
|
|
104
|
+
* @param {Object} data - 删除参数对象
|
|
105
|
+
* @param {Object} data.task_delete - 任务删除信息对象(必填)
|
|
106
|
+
* @param {number} data.task_delete.id - 要删除的任务 ID(必填)
|
|
107
|
+
* @returns {Promise<Response<Task>>} 返回包含被删除任务对象的响应
|
|
108
|
+
*
|
|
109
|
+
* @example
|
|
110
|
+
* const response = await taskClient.delete_task({
|
|
111
|
+
* id: 1
|
|
112
|
+
* });
|
|
113
|
+
* const deletedTask = response.result;
|
|
114
|
+
*/
|
|
115
|
+
delete_task(t) {
|
|
116
|
+
return this.action("delete_task", t);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
export {
|
|
120
|
+
r as TaskClient
|
|
121
|
+
};
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { RestAPIClient, RestAPIConfig } from '../RestAPIClient';
|
|
2
|
+
export interface User {
|
|
3
|
+
id: number;
|
|
4
|
+
name: string;
|
|
5
|
+
email: string;
|
|
6
|
+
age?: number;
|
|
7
|
+
created_at: string;
|
|
8
|
+
updated_at?: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* 用户客户端类,用于处理用户相关的 API 请求
|
|
12
|
+
* @extends RestAPIClient
|
|
13
|
+
*/
|
|
14
|
+
export declare class UserClient extends RestAPIClient {
|
|
15
|
+
/**
|
|
16
|
+
* 创建 UserClient 实例
|
|
17
|
+
* @param {Omit<RestAPIConfig, 'workerId'>} [config] - REST API 配置对象(可选参数)
|
|
18
|
+
* @param {string} [config.baseURL] - API 基础 URL(可选)
|
|
19
|
+
* @param {number} [config.timeout] - 请求超时时间(可选)
|
|
20
|
+
* @param {Record<string, string>} [config.headers] - 自定义请求头(可选)
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* const userClient = new UserClient({
|
|
24
|
+
* baseURL: 'https://api.example.com',
|
|
25
|
+
* timeout: 5000,
|
|
26
|
+
* headers: {
|
|
27
|
+
* 'Authorization': 'Bearer token123'
|
|
28
|
+
* }
|
|
29
|
+
* });
|
|
30
|
+
*/
|
|
31
|
+
constructor(config?: Omit<RestAPIConfig, 'workerId'>);
|
|
32
|
+
/**
|
|
33
|
+
* 创建新用户
|
|
34
|
+
* @param {Pick<User, 'name' | 'email' | 'age'>} user - 用户信息对象
|
|
35
|
+
* @param {string} user.name - 用户名称(必填)
|
|
36
|
+
* @param {string} user.email - 用户邮箱(必填)
|
|
37
|
+
* @param {number} [user.age] - 用户年龄(可选参数)
|
|
38
|
+
* @returns {Promise<Response<User>>} 返回包含用户对象的响应
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* const response = await userClient.create_user({
|
|
42
|
+
* name: '张三',
|
|
43
|
+
* email: 'zhangsan@example.com',
|
|
44
|
+
* age: 25
|
|
45
|
+
* });
|
|
46
|
+
* const newUser = response.result;
|
|
47
|
+
*/
|
|
48
|
+
create_user(user: Pick<User, 'name' | 'email' | 'age'>): Promise<import('../RestAPIClient').Response<User>>;
|
|
49
|
+
/**
|
|
50
|
+
* 获取所有用户列表
|
|
51
|
+
* @returns {Promise<Response<User[]>>} 返回包含用户列表的响应
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* const response = await userClient.get_users();
|
|
55
|
+
* const users = response.result;
|
|
56
|
+
*/
|
|
57
|
+
get_users(): Promise<import('../RestAPIClient').Response<User[]>>;
|
|
58
|
+
/**
|
|
59
|
+
* 根据用户 ID 获取单个用户信息
|
|
60
|
+
* @param {Object} data - 查询参数对象
|
|
61
|
+
* @param {number} data.user_id - 用户 ID(必填)
|
|
62
|
+
* @returns {Promise<Response<User>>} 返回包含用户对象的响应
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* const response = await userClient.get_user({
|
|
66
|
+
* user_id: 1
|
|
67
|
+
* });
|
|
68
|
+
* const user = response.result;
|
|
69
|
+
*/
|
|
70
|
+
get_user(data: {
|
|
71
|
+
user_id: number;
|
|
72
|
+
}): Promise<import('../RestAPIClient').Response<User>>;
|
|
73
|
+
/**
|
|
74
|
+
* 更新用户信息
|
|
75
|
+
* @param {Object} data - 更新参数对象
|
|
76
|
+
* @param {string} data.userId - 用户 ID(必填)
|
|
77
|
+
* @param {Object} data.user_update - 用户更新信息对象(必填)
|
|
78
|
+
* @param {string} [data.user_update.name] - 用户名称(可选参数)
|
|
79
|
+
* @param {string} [data.user_update.email] - 用户邮箱(可选参数)
|
|
80
|
+
* @param {number} [data.user_update.age] - 用户年龄(可选参数)
|
|
81
|
+
* @returns {Promise<Response<User>>} 返回包含更新后用户对象的响应
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* const response = await userClient.update_user({
|
|
85
|
+
* user_id: 1,
|
|
86
|
+
* user_update: {
|
|
87
|
+
* name: '张三(已更新)',
|
|
88
|
+
* email: 'zhangsan_new@example.com',
|
|
89
|
+
* age: 26
|
|
90
|
+
* }
|
|
91
|
+
* });
|
|
92
|
+
* const updatedUser = response.result;
|
|
93
|
+
*/
|
|
94
|
+
update_user(data: {
|
|
95
|
+
user_id: number;
|
|
96
|
+
user_update: Partial<Pick<User, 'name' | 'email' | 'age'>>;
|
|
97
|
+
}): Promise<import('../RestAPIClient').Response<User>>;
|
|
98
|
+
/**
|
|
99
|
+
* 删除用户
|
|
100
|
+
* @param {Object} data - 删除参数对象
|
|
101
|
+
* @param {Object} data.user_delete - 用户删除信息对象(必填)
|
|
102
|
+
* @param {number} data.user_delete.id - 要删除的用户 ID(必填)
|
|
103
|
+
* @returns {Promise<Response<User>>} 返回包含被删除用户对象的响应
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* const response = await userClient.delete_user({
|
|
107
|
+
* id: 1
|
|
108
|
+
* });
|
|
109
|
+
* const deletedUser = response.result;
|
|
110
|
+
*/
|
|
111
|
+
delete_user(data: {
|
|
112
|
+
id: number;
|
|
113
|
+
}): Promise<import('../RestAPIClient').Response<User>>;
|
|
114
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { RestAPIClient as t } from "../RestAPIClient.js";
|
|
2
|
+
class u extends t {
|
|
3
|
+
/**
|
|
4
|
+
* 创建 UserClient 实例
|
|
5
|
+
* @param {Omit<RestAPIConfig, 'workerId'>} [config] - REST API 配置对象(可选参数)
|
|
6
|
+
* @param {string} [config.baseURL] - API 基础 URL(可选)
|
|
7
|
+
* @param {number} [config.timeout] - 请求超时时间(可选)
|
|
8
|
+
* @param {Record<string, string>} [config.headers] - 自定义请求头(可选)
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* const userClient = new UserClient({
|
|
12
|
+
* baseURL: 'https://api.example.com',
|
|
13
|
+
* timeout: 5000,
|
|
14
|
+
* headers: {
|
|
15
|
+
* 'Authorization': 'Bearer token123'
|
|
16
|
+
* }
|
|
17
|
+
* });
|
|
18
|
+
*/
|
|
19
|
+
constructor(e) {
|
|
20
|
+
super({
|
|
21
|
+
// workerId: '5cd2fc653a0c4f50b894db9a8db627e3', // 待实际项目确认最终workerId
|
|
22
|
+
...e
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* 创建新用户
|
|
27
|
+
* @param {Pick<User, 'name' | 'email' | 'age'>} user - 用户信息对象
|
|
28
|
+
* @param {string} user.name - 用户名称(必填)
|
|
29
|
+
* @param {string} user.email - 用户邮箱(必填)
|
|
30
|
+
* @param {number} [user.age] - 用户年龄(可选参数)
|
|
31
|
+
* @returns {Promise<Response<User>>} 返回包含用户对象的响应
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* const response = await userClient.create_user({
|
|
35
|
+
* name: '张三',
|
|
36
|
+
* email: 'zhangsan@example.com',
|
|
37
|
+
* age: 25
|
|
38
|
+
* });
|
|
39
|
+
* const newUser = response.result;
|
|
40
|
+
*/
|
|
41
|
+
create_user(e) {
|
|
42
|
+
return this.action("create_user", e);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* 获取所有用户列表
|
|
46
|
+
* @returns {Promise<Response<User[]>>} 返回包含用户列表的响应
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* const response = await userClient.get_users();
|
|
50
|
+
* const users = response.result;
|
|
51
|
+
*/
|
|
52
|
+
get_users() {
|
|
53
|
+
return this.action("get_users");
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* 根据用户 ID 获取单个用户信息
|
|
57
|
+
* @param {Object} data - 查询参数对象
|
|
58
|
+
* @param {number} data.user_id - 用户 ID(必填)
|
|
59
|
+
* @returns {Promise<Response<User>>} 返回包含用户对象的响应
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* const response = await userClient.get_user({
|
|
63
|
+
* user_id: 1
|
|
64
|
+
* });
|
|
65
|
+
* const user = response.result;
|
|
66
|
+
*/
|
|
67
|
+
get_user(e) {
|
|
68
|
+
return this.action("get_user", e);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* 更新用户信息
|
|
72
|
+
* @param {Object} data - 更新参数对象
|
|
73
|
+
* @param {string} data.userId - 用户 ID(必填)
|
|
74
|
+
* @param {Object} data.user_update - 用户更新信息对象(必填)
|
|
75
|
+
* @param {string} [data.user_update.name] - 用户名称(可选参数)
|
|
76
|
+
* @param {string} [data.user_update.email] - 用户邮箱(可选参数)
|
|
77
|
+
* @param {number} [data.user_update.age] - 用户年龄(可选参数)
|
|
78
|
+
* @returns {Promise<Response<User>>} 返回包含更新后用户对象的响应
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* const response = await userClient.update_user({
|
|
82
|
+
* user_id: 1,
|
|
83
|
+
* user_update: {
|
|
84
|
+
* name: '张三(已更新)',
|
|
85
|
+
* email: 'zhangsan_new@example.com',
|
|
86
|
+
* age: 26
|
|
87
|
+
* }
|
|
88
|
+
* });
|
|
89
|
+
* const updatedUser = response.result;
|
|
90
|
+
*/
|
|
91
|
+
update_user(e) {
|
|
92
|
+
return this.action("update_user", e);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* 删除用户
|
|
96
|
+
* @param {Object} data - 删除参数对象
|
|
97
|
+
* @param {Object} data.user_delete - 用户删除信息对象(必填)
|
|
98
|
+
* @param {number} data.user_delete.id - 要删除的用户 ID(必填)
|
|
99
|
+
* @returns {Promise<Response<User>>} 返回包含被删除用户对象的响应
|
|
100
|
+
*
|
|
101
|
+
* @example
|
|
102
|
+
* const response = await userClient.delete_user({
|
|
103
|
+
* id: 1
|
|
104
|
+
* });
|
|
105
|
+
* const deletedUser = response.result;
|
|
106
|
+
*/
|
|
107
|
+
delete_user(e) {
|
|
108
|
+
return this.action("delete_user", e);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
export {
|
|
112
|
+
u as UserClient
|
|
113
|
+
};
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { RestAPIConfig } from '../api/RestAPIClient';
|
|
2
|
+
import { WebSocketConfig } from '../api/WebSocketClient';
|
|
3
|
+
import { PluginOptions } from '../types';
|
|
4
|
+
import { App } from 'vue';
|
|
5
|
+
declare class RestConfigManager {
|
|
6
|
+
private config;
|
|
7
|
+
setConfig(config: RestAPIConfig): void;
|
|
8
|
+
getConfig(): RestAPIConfig;
|
|
9
|
+
}
|
|
10
|
+
declare class WebSocketConfigManager {
|
|
11
|
+
private config;
|
|
12
|
+
setConfig(config: WebSocketConfig): void;
|
|
13
|
+
getConfig(): WebSocketConfig;
|
|
14
|
+
}
|
|
15
|
+
declare class GlobalConfigManager {
|
|
16
|
+
private app;
|
|
17
|
+
private appId;
|
|
18
|
+
readonly rest: RestConfigManager;
|
|
19
|
+
readonly websocket: WebSocketConfigManager;
|
|
20
|
+
setApp(app: App): void;
|
|
21
|
+
getApp(): App | null;
|
|
22
|
+
setAppId(appId: string): void;
|
|
23
|
+
getAppId(): string;
|
|
24
|
+
setConfig(app: App, options: PluginOptions): void;
|
|
25
|
+
}
|
|
26
|
+
export declare const globalConfig: GlobalConfigManager;
|
|
27
|
+
export declare const restConfig: RestConfigManager;
|
|
28
|
+
export declare const websocketConfig: WebSocketConfigManager;
|
|
29
|
+
export declare function initConfig(app: App, options: PluginOptions): void;
|
|
30
|
+
declare const _PLATFORM_INTERNAL_APPIDS: {
|
|
31
|
+
/** 仪器管理器应用 ID */
|
|
32
|
+
UVAPP_INSTRUMENT_MANAGER: string;
|
|
33
|
+
/** 包管理器应用 ID */
|
|
34
|
+
UVAPP_PACKAGE_MANAGER: string;
|
|
35
|
+
/** 低代码平台应用 ID */
|
|
36
|
+
UVAPP_LOWCODE: string;
|
|
37
|
+
/** 消息总线服务 ID */
|
|
38
|
+
UVAPP_SRV_MESSAGEBUS: string;
|
|
39
|
+
/** 守护进程 Worker 服务 ID */
|
|
40
|
+
UVAPP_SRV_DAEMONWORKER: string;
|
|
41
|
+
/** 日志 Worker 服务 ID */
|
|
42
|
+
UVAPP_SRV_LOGGINGWORKER: string;
|
|
43
|
+
/** API Worker 服务 ID */
|
|
44
|
+
UVAPP_SRV_APIWORKER: string;
|
|
45
|
+
/** AI Worker 服务 ID */
|
|
46
|
+
UVAPP_SRV_AIWORKER: string;
|
|
47
|
+
/** 存储 Worker 服务 ID */
|
|
48
|
+
UVAPP_SRV_STORAGEWORKER: string;
|
|
49
|
+
/** 许可证 Worker 服务 ID */
|
|
50
|
+
UVAPP_SRV_LICENSEWORKER: string;
|
|
51
|
+
/** 序列 Worker 服务 ID */
|
|
52
|
+
UVAPP_SRV_SEQUENCEWORKER: string;
|
|
53
|
+
/** 当前应用自身的 ID(在 UV-API 初始化时动态设置) */
|
|
54
|
+
UVAPP_SELF: string;
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* 平台内部应用 ID 常量
|
|
58
|
+
*
|
|
59
|
+
* 包含平台所有内置应用和服务的唯一标识符。
|
|
60
|
+
* 这些 ID 用于应用间通信、权限控制和服务调用。
|
|
61
|
+
*
|
|
62
|
+
* @remarks
|
|
63
|
+
* - 所有属性都是只读的,TypeScript 会阻止外部修改
|
|
64
|
+
* - `UVAPP_SELF` 会在 UV-API 初始化时自动设置为当前应用的 ID
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```typescript
|
|
68
|
+
* import { PLATFORM_INTERNAL_APPIDS } from '@openuverse/uvapi'
|
|
69
|
+
*
|
|
70
|
+
* // 获取仪器管理器应用 ID
|
|
71
|
+
* const instrumentManagerId = PLATFORM_INTERNAL_APPIDS.UVAPP_INSTRUMENT_MANAGER
|
|
72
|
+
*
|
|
73
|
+
* // 获取当前应用 ID
|
|
74
|
+
* const currentAppId = PLATFORM_INTERNAL_APPIDS.UVAPP_SELF
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
export declare const PLATFORM_INTERNAL_APPIDS: Readonly<typeof _PLATFORM_INTERNAL_APPIDS>;
|
|
78
|
+
/**
|
|
79
|
+
* 平台应用 ID 类型
|
|
80
|
+
*
|
|
81
|
+
* 从 `PLATFORM_INTERNAL_APPIDS` 中提取所有应用 ID 值的联合类型。
|
|
82
|
+
* 可用于类型检查和类型推导。
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* ```typescript
|
|
86
|
+
* const appId: PlatformAppId = 'd0a9a7f6473948c6b5ee204c4d4dea10' // ✅ 有效
|
|
87
|
+
* const appId: PlatformAppId = 'invalid-id' // ❌ TypeScript 错误
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
export type PlatformAppId = (typeof PLATFORM_INTERNAL_APPIDS)[keyof typeof PLATFORM_INTERNAL_APPIDS];
|
|
91
|
+
/**
|
|
92
|
+
* 根据应用 ID 值查找对应的键名
|
|
93
|
+
*
|
|
94
|
+
* 通过应用 ID 反向查找其在 `PLATFORM_INTERNAL_APPIDS` 中的键名。
|
|
95
|
+
* 如果找不到匹配的键名,返回 `undefined`。
|
|
96
|
+
*
|
|
97
|
+
* @param id - 要查找的应用 ID 值
|
|
98
|
+
* @returns 对应的键名,如果未找到则返回 `undefined`
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* ```typescript
|
|
102
|
+
* const appName = getAppNameById('d0a9a7f6473948c6b5ee204c4d4dea10')
|
|
103
|
+
* console.log(appName) // 输出: 'UVAPP_INSTRUMENT_MANAGER'
|
|
104
|
+
*
|
|
105
|
+
* const unknownName = getAppNameById('unknown-id')
|
|
106
|
+
* console.log(unknownName) // 输出: undefined
|
|
107
|
+
* ```
|
|
108
|
+
*/
|
|
109
|
+
export declare const getAppNameById: (id: string) => keyof typeof PLATFORM_INTERNAL_APPIDS | undefined;
|
|
110
|
+
/**
|
|
111
|
+
* 初始化内部应用 ID
|
|
112
|
+
*
|
|
113
|
+
* 设置 `PLATFORM_INTERNAL_APPIDS.UVAPP_SELF` 为当前应用的 ID。
|
|
114
|
+
* 此函数会在 UV-API 初始化时自动调用。
|
|
115
|
+
*
|
|
116
|
+
* @param appId - 当前应用的唯一标识符
|
|
117
|
+
* @internal
|
|
118
|
+
*/
|
|
119
|
+
export declare function initInternalAppIds(appId: string): void;
|
|
120
|
+
export {};
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
class a {
|
|
2
|
+
constructor() {
|
|
3
|
+
this.config = {
|
|
4
|
+
baseURL: "",
|
|
5
|
+
timeout: 1e4,
|
|
6
|
+
urlType: "header"
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
// 设置配置
|
|
10
|
+
setConfig(e) {
|
|
11
|
+
this.config = { ...this.config, ...e };
|
|
12
|
+
}
|
|
13
|
+
// 获取配置
|
|
14
|
+
getConfig() {
|
|
15
|
+
return { ...this.config };
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
class i {
|
|
19
|
+
constructor() {
|
|
20
|
+
this.config = {
|
|
21
|
+
reconnectInterval: 5e3,
|
|
22
|
+
maxReconnectAttempts: 5
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
// 设置配置
|
|
26
|
+
setConfig(e) {
|
|
27
|
+
this.config = { ...this.config, ...e };
|
|
28
|
+
}
|
|
29
|
+
// 获取配置
|
|
30
|
+
getConfig() {
|
|
31
|
+
return { ...this.config };
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
class o {
|
|
35
|
+
constructor() {
|
|
36
|
+
this.app = null, this.appId = "", this.rest = new a(), this.websocket = new i();
|
|
37
|
+
}
|
|
38
|
+
// 设置应用
|
|
39
|
+
setApp(e) {
|
|
40
|
+
this.app = e;
|
|
41
|
+
}
|
|
42
|
+
getApp() {
|
|
43
|
+
return this.app;
|
|
44
|
+
}
|
|
45
|
+
// 设置应用ID
|
|
46
|
+
setAppId(e) {
|
|
47
|
+
this.appId = e;
|
|
48
|
+
}
|
|
49
|
+
// 获取应用ID
|
|
50
|
+
getAppId() {
|
|
51
|
+
return this.appId;
|
|
52
|
+
}
|
|
53
|
+
// 批量设置配置
|
|
54
|
+
setConfig(e, c) {
|
|
55
|
+
this.setApp(e), this.setAppId(c.appId), c.restAPI && this.rest.setConfig(c.restAPI), c.websocket && this.websocket.setConfig(c.websocket);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
const s = new o(), b = s.rest, A = s.websocket;
|
|
59
|
+
function r(t, e) {
|
|
60
|
+
s.setConfig(t, e);
|
|
61
|
+
}
|
|
62
|
+
const n = {
|
|
63
|
+
/** 仪器管理器应用 ID */
|
|
64
|
+
UVAPP_INSTRUMENT_MANAGER: "d0a9a7f6473948c6b5ee204c4d4dea10",
|
|
65
|
+
/** 包管理器应用 ID */
|
|
66
|
+
UVAPP_PACKAGE_MANAGER: "14706eda67f34b7ebb4b487a0b6e7f2d",
|
|
67
|
+
/** 低代码平台应用 ID */
|
|
68
|
+
UVAPP_LOWCODE: "c4f9b4ea0e4b4500b1176fe251510db8",
|
|
69
|
+
/** 消息总线服务 ID */
|
|
70
|
+
UVAPP_SRV_MESSAGEBUS: "e6c8dfd5d79045e8b3e21515aceda86d",
|
|
71
|
+
/** 守护进程 Worker 服务 ID */
|
|
72
|
+
UVAPP_SRV_DAEMONWORKER: "de34fa54b2c342b6b2afc496b819d285",
|
|
73
|
+
/** 日志 Worker 服务 ID */
|
|
74
|
+
UVAPP_SRV_LOGGINGWORKER: "35afa63c62524f25862d3f9fcc50d932",
|
|
75
|
+
/** API Worker 服务 ID */
|
|
76
|
+
UVAPP_SRV_APIWORKER: "2cfbbcdbbfcc41218be0700af688e5a8",
|
|
77
|
+
/** AI Worker 服务 ID */
|
|
78
|
+
UVAPP_SRV_AIWORKER: "d61cc09a1d8a48198ff5b6ab81dcbfd2",
|
|
79
|
+
/** 存储 Worker 服务 ID */
|
|
80
|
+
UVAPP_SRV_STORAGEWORKER: "f6f086417c484b0484d78e0bcbc5311a",
|
|
81
|
+
/** 许可证 Worker 服务 ID */
|
|
82
|
+
UVAPP_SRV_LICENSEWORKER: "48e5a3f7ffa14d5cb5a70485863dff1f",
|
|
83
|
+
/** 序列 Worker 服务 ID */
|
|
84
|
+
UVAPP_SRV_SEQUENCEWORKER: "01bfa07867bc4b09a323fce50b0cfd2b",
|
|
85
|
+
/** 当前应用自身的 ID(在 UV-API 初始化时动态设置) */
|
|
86
|
+
UVAPP_SELF: ""
|
|
87
|
+
// 初始化为空,将在 initInternalAppIds 中设置
|
|
88
|
+
}, f = new Proxy(
|
|
89
|
+
n,
|
|
90
|
+
{
|
|
91
|
+
set() {
|
|
92
|
+
return !1;
|
|
93
|
+
},
|
|
94
|
+
deleteProperty() {
|
|
95
|
+
return !1;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
), P = (t) => Object.keys(f).find(
|
|
99
|
+
(e) => f[e] === t
|
|
100
|
+
);
|
|
101
|
+
function d(t) {
|
|
102
|
+
n.UVAPP_SELF = t;
|
|
103
|
+
}
|
|
104
|
+
export {
|
|
105
|
+
f as PLATFORM_INTERNAL_APPIDS,
|
|
106
|
+
P as getAppNameById,
|
|
107
|
+
s as globalConfig,
|
|
108
|
+
r as initConfig,
|
|
109
|
+
d as initInternalAppIds,
|
|
110
|
+
b as restConfig,
|
|
111
|
+
A as websocketConfig
|
|
112
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './useAttributeMonitor';
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { WebSocketClient, WebSocketConfig, WebSocketState } from '../api';
|
|
2
|
+
import { Store } from '../store';
|
|
3
|
+
export interface MonitorSocketConfig extends WebSocketConfig {
|
|
4
|
+
appId?: string;
|
|
5
|
+
store?: Store<any>;
|
|
6
|
+
onOpen?: (event: any) => void;
|
|
7
|
+
onMessage?: (message: any) => void;
|
|
8
|
+
onClose?: (event: any) => void;
|
|
9
|
+
onError?: (error: any) => void;
|
|
10
|
+
onReconnect?: (data: {
|
|
11
|
+
attempt: number;
|
|
12
|
+
}) => void;
|
|
13
|
+
onReconnectFailed?: (data: {
|
|
14
|
+
attempts: number;
|
|
15
|
+
}) => void;
|
|
16
|
+
autoConnect?: boolean;
|
|
17
|
+
heartbeatInterval?: number;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* WebSocket 属性监听 Hook
|
|
21
|
+
* 用于在 Vue3 组件中管理 WebSocket 连接
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```ts
|
|
25
|
+
* const { isConnected, send, close } = useAttributeMonitor({
|
|
26
|
+
* url: 'ws://localhost:8080',
|
|
27
|
+
* onMessage: (data) => {
|
|
28
|
+
* console.log('收到消息:', data)
|
|
29
|
+
* }
|
|
30
|
+
* })
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export declare const useAttributeMonitor: (options: MonitorSocketConfig) => {
|
|
34
|
+
client: () => WebSocketClient | null;
|
|
35
|
+
isConnected: import('vue').Ref<boolean, boolean>;
|
|
36
|
+
readyState: import('vue').Ref<WebSocketState, WebSocketState>;
|
|
37
|
+
reconnectAttempts: import('vue').Ref<number, number>;
|
|
38
|
+
init: () => void;
|
|
39
|
+
connect: (url?: string) => Promise<void>;
|
|
40
|
+
send: <T = any>(message: string | T) => void;
|
|
41
|
+
close: (code?: number, reason?: string) => void;
|
|
42
|
+
cleanup: () => void;
|
|
43
|
+
getMessageQueueLength: () => number;
|
|
44
|
+
clearMessageQueue: () => void;
|
|
45
|
+
};
|