zyjj-web-sdk 1.1.34 → 2.0.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.
@@ -1,4 +1,4 @@
1
- import { FileSource, ToolParamFile } from "../types/local-task.ts";
1
+ import { FileSource, ToolParamFile } from "../types/resource.ts";
2
2
  import COS from 'cos-js-sdk-v5';
3
3
  import OSS from 'ali-oss';
4
4
  export declare const convertFileSize: (bytes: number) => string;
@@ -40,13 +40,19 @@ export declare enum ToolType {
40
40
  Task = 0,// 任务类型
41
41
  Lab = 1,// 实验室
42
42
  Flow = 2,// 流程
43
- Custom = 3
43
+ Custom = 3,// 自定义
44
+ DynamicComponent = 4
44
45
  }
45
46
  export interface ToolDetailInfo {
46
47
  tool_id?: string;
47
48
  info?: string;
48
49
  extra?: string;
49
50
  }
51
+ export interface ToolDetailDynamicComponent {
52
+ url: string;
53
+ scope: string;
54
+ module: string;
55
+ }
50
56
  export interface TaskInfo {
51
57
  id: string;
52
58
  uid: string;
@@ -0,0 +1,24 @@
1
+ export interface ToolParamFile {
2
+ path: string;
3
+ source?: FileSource;
4
+ duration?: number;
5
+ size?: number;
6
+ ext?: string;
7
+ name?: string;
8
+ uid?: string;
9
+ cloudSource?: FileSource;
10
+ cloud_source?: FileSource;
11
+ objectUrl?: string;
12
+ object_url?: string;
13
+ }
14
+ export declare enum FileSource {
15
+ LocalPath = 0,
16
+ TencentCos = 1,
17
+ ObjectUrl = 2,
18
+ AliYunOss = 3
19
+ }
20
+ export interface CloudDownload {
21
+ url: string;
22
+ filename: string;
23
+ headers?: Record<string, string>;
24
+ }
@@ -1,4 +1,4 @@
1
- import { FileSource, TaskType } from "./local-task.ts";
1
+ import { FileSource } from "./resource.ts";
2
2
  export interface ToolConfigInfo {
3
3
  unique: string;
4
4
  name: string;
@@ -57,7 +57,7 @@ export interface FfmpegTaskParam {
57
57
  data?: string;
58
58
  }
59
59
  export interface TaskDataCloud {
60
- task_type: number;
60
+ entity_id: string;
61
61
  output?: string;
62
62
  upload_list?: string[];
63
63
  upload_source?: number;
@@ -76,7 +76,7 @@ export interface ToolDetailLab {
76
76
  form_init?: {
77
77
  [key: string]: any;
78
78
  };
79
- task_type: TaskType;
79
+ entity_id: string;
80
80
  loading: string;
81
81
  submit_text: string;
82
82
  price: number;
package/package.json CHANGED
@@ -1,21 +1,31 @@
1
1
  {
2
2
  "name": "zyjj-web-sdk",
3
- "version": "1.1.34",
3
+ "version": "2.0.0",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "lib"
7
7
  ],
8
8
  "module": "./lib/index.js",
9
- "main": "./lib/index.umd.cjs",
10
9
  "types": "./lib/index.d.ts",
11
10
  "scripts": {
12
11
  "dev": "vite",
13
- "build": "tsc && vite build",
14
- "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
12
+ "build": "tsc && vite build && vite build --config vite.contract.config.ts && node scripts/verify-package.mjs",
13
+ "lint": "eslint packages tests --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
14
+ "test": "node --experimental-strip-types --test tests/*.test.ts",
15
15
  "preview": "vite preview",
16
16
  "link": "rm -rf lib/* && yarn build && yarn unlink && yarn link",
17
17
  "publish_pkg": "rm -rf lib/* && yarn build && npm publish --access public"
18
18
  },
19
+ "exports": {
20
+ ".": {
21
+ "node": {
22
+ "types": "./lib/contract-v2/index.d.ts",
23
+ "import": "./lib/contract-v2/index.js"
24
+ },
25
+ "types": "./lib/index.d.ts",
26
+ "import": "./lib/index.js"
27
+ }
28
+ },
19
29
  "dependencies": {
20
30
  "@arco-design/web-react": "^2.61.2"
21
31
  },
package/lib/tool/db.d.ts DELETED
@@ -1,7 +0,0 @@
1
- import { LocalTaskInfo } from '../types/local-task';
2
- export declare const storeNameTask = "task";
3
- export declare const AddTask: (data: LocalTaskInfo, table?: string) => Promise<IDBValidKey>;
4
- export declare const GetAllData: <T>(table?: string) => Promise<T[]>;
5
- export declare const GetData: <T>(id: string, table?: string) => Promise<T>;
6
- export declare const UpdateData: <T>(id: string, data: T, table?: string) => Promise<IDBValidKey>;
7
- export declare const DeleteData: (id: string, table?: string) => Promise<void>;
@@ -1,168 +0,0 @@
1
- import { MqttRequest, MqttResponse } from "./mqtt.ts";
2
- import { ToolTaskInfo } from "./tool-task.ts";
3
- import { TaskActionInfo, WorkActionInfo } from "./new-local-task";
4
- import { ToolInfo } from "./cloud.ts";
5
- export type SendTaskActionRequest = (info: LocalActionRequest) => void;
6
- export type TaskActionClose = () => void;
7
- export type GetTaskActionRequest = (uid: string, info: LocalActionRequest) => void;
8
- export type GetTaskActionResponse = (info: LocalActionResponse) => void;
9
- export type SendTaskActionResponse = (uid: string, send: GetTaskActionResponse) => void;
10
- export type TaskProgressCallback = (i: number) => void;
11
- export type GlobalData = {
12
- [key: string]: GlobalDataType;
13
- };
14
- export type GlobalDataType = ToolParamFile | ToolParamFile[] | ToolParamFileDownload | string | object;
15
- export interface ToolParamFile {
16
- path: string;
17
- source?: FileSource;
18
- duration?: number;
19
- size?: number;
20
- ext?: string;
21
- name?: string;
22
- uid?: string;
23
- cloud_source?: FileSource;
24
- object_url?: string;
25
- }
26
- export declare enum FileSource {
27
- LocalPath = 0,// 本地(路径)
28
- TencentCos = 1,// 腾讯云cos
29
- ObjectUrl = 2,// ObjectUrl
30
- AliYunOss = 3
31
- }
32
- export interface ToolParamFileDownload {
33
- url: string;
34
- filename: string;
35
- headers?: {
36
- [key: string]: string;
37
- };
38
- }
39
- export interface LocalActionRequest {
40
- action_type: LocalActionReqType;
41
- data?: TaskActionInfo | WorkActionInfo | MqttRequest | ToolParamFile | LocalActionReqDataOpenTool | ToolParamFileDownload | string;
42
- }
43
- export declare enum LocalActionReqType {
44
- TaskAction = 0,// 任务操作
45
- WorkAction = 1,// work操作
46
- MqttSend = 3,// 发送MQTT
47
- ActionClose = 4,// 关闭action链接
48
- MqttReconnect = 5,// MQTT重连
49
- NavigateTo = 7,// 跳转到指定页面
50
- OpenTool = 10,// 打开某个工具
51
- DownloadFile = 11
52
- }
53
- export interface LocalActionReqDataCreatTask {
54
- name: string;
55
- desc: string;
56
- replace_param?: string[];
57
- global_param: GlobalData;
58
- task_list: ToolTaskInfo[];
59
- }
60
- export interface LocalActionReqDataRestoreTask {
61
- task_data: LocalActionReqDataCreatTask;
62
- restore_info?: TaskRestoreInfo;
63
- }
64
- export interface LocalActionReqDataOpenTool {
65
- id: string;
66
- init?: any;
67
- tool_info?: ToolInfo;
68
- data?: any;
69
- }
70
- export interface TaskRestoreInfo {
71
- idx: number;
72
- info: {
73
- [key: number]: any;
74
- };
75
- }
76
- export interface LocalActionResponse {
77
- action_type: LocalActionResType;
78
- data: LocalActionResData;
79
- }
80
- export type LocalActionResData = TaskActionInfo | MqttResponse | LocalActionReqDataOpenTool | string;
81
- export declare enum LocalActionResType {
82
- TaskAction = 0,// 任务操作
83
- NavigateTo = 3,// 跳转到指定页面
84
- OpenTool = 6,// 打开某个工具
85
- MqttBack = 1,// Mqtt数据回调
86
- ExtensionBlobUrl = 4,// 返回blob url(extension)
87
- ExtensionId = 5,// 返回扩展id(extension)
88
- UrlCallback = 7,// 外部url回调
89
- DownloadFileRes = 8
90
- }
91
- export interface LocalActionResDataUpdateTaskInfo {
92
- progress?: number;
93
- status?: LocalTaskStatus;
94
- msg?: string;
95
- restore_info?: any;
96
- output?: ToolParamFile;
97
- outputs?: GlobalData;
98
- }
99
- export interface LocalTaskInfo {
100
- id: string;
101
- name: string;
102
- desc: string;
103
- status: LocalTaskStatus;
104
- progress: number;
105
- msg?: string;
106
- task_data: string;
107
- restore_info?: string;
108
- output: string;
109
- create_time: number;
110
- }
111
- export declare enum LocalTaskStatus {
112
- Waiting = "\u7B49\u5F85",
113
- Running = "\u8FDB\u884C",
114
- Fail = "\u5931\u8D25",
115
- Success = "\u6210\u529F",
116
- Canceled = "\u53D6\u6D88"
117
- }
118
- export interface TaskService {
119
- taskActionBackHandle: (callback: GetTaskActionResponse, id?: string) => Promise<{
120
- send: SendTaskActionRequest;
121
- close: TaskActionClose;
122
- id: string;
123
- }>;
124
- taskActionHandle: (callback: GetTaskActionRequest, addSend: SendTaskActionResponse) => void;
125
- ListenApplicationMessage: (callback: GetTaskActionResponse) => void;
126
- }
127
- export interface IframeDataRequest {
128
- id?: string;
129
- task_type: TaskType;
130
- data?: LocalActionRequest | SendDataRequest | SendDataCostPoint | SendDataChooseFile | ToolParamFile;
131
- }
132
- export interface SendDataRequest {
133
- url: string;
134
- data: any;
135
- method: 'get' | 'post' | 'put' | 'delete';
136
- }
137
- export interface SendDataCostPoint {
138
- name: string;
139
- point: number;
140
- desc: string;
141
- }
142
- export interface SendDataChooseFile {
143
- title: string;
144
- accept: string;
145
- }
146
- export interface IframeDataResponse {
147
- id?: string;
148
- task_type: TaskType;
149
- event_type: LocalTaskEventType;
150
- data: any;
151
- }
152
- export declare enum LocalTaskEventType {
153
- Start = 1,
154
- Progress = 2,
155
- Success = 3,
156
- Error = 4,
157
- DetailAppend = 5,
158
- DetailSet = 6
159
- }
160
- export declare enum TaskType {
161
- ChoosePic = -3,
162
- CostPoint = -4,
163
- AddAction = -5,
164
- CloseWindow = -6,
165
- SendRequest = -7,
166
- UploadFileByPath = -8,
167
- GetInitData = -9
168
- }
@@ -1,68 +0,0 @@
1
- import { MqttResponse } from "./mqtt";
2
- import { LocalActionReqDataCreatTask, LocalActionReqDataRestoreTask, LocalActionResDataUpdateTaskInfo, LocalTaskInfo, ToolParamFile, ToolParamFileDownload } from "./local-task.ts";
3
- import { SendCommonRequestInfo } from "../api/entity.ts";
4
- import { ToolInfo } from "./cloud.ts";
5
- export type ToolOnEventBase<D, R> = (event_type: ToolEventType, data?: ToolEventRequest, on_detail?: (detail: D) => void, get_cancel?: (cancel: () => void) => void) => Promise<R>;
6
- export type ToolOnEvent = ToolOnEventBase<ToolEventDetail, ToolEventResponse>;
7
- export declare enum ToolEventType {
8
- MqttListener = 0,// 监听MQTT消息
9
- CloudFileUpload = 1,// 云端文件上传
10
- CloudFileDownload = 2,// 云端文件下载
11
- NavigateTo = 4,// 导航到某个地址
12
- CloseWindow = 5,// 关闭窗口
13
- TaskAction = 6,// 任务操作
14
- SendRequest = 7,// 发送请求
15
- FFMPEG = 8,// 执行ffmpeg命令
16
- FileDownload = 9,// 文件下载
17
- OpenVideoEditor = 10,// 打开视频编辑器
18
- OpenTool = 11,// 打开工具
19
- OpenHelp = 12,// 打开帮助文档
20
- GetFileData = 13
21
- }
22
- export type ToolEventRequest = string | ToolParamFile | LocalActionReqDataCreatTask | TaskActionInfo | SendCommonRequestInfo | ToolEventFfmpegRequest | ToolEventCloudDownloadRequest | ToolParamFileDownload | ToolInfo | ToolEventOpenToolWithIdRequest;
23
- export type ToolEventResponse = string | ToolParamFile | ToolEventFfmpegRequest | Blob | any;
24
- export type ToolEventDetail = string | number | MqttResponse;
25
- export interface TaskActionInfo {
26
- acton: TaskActionType;
27
- info: LocalActionReqDataCreatTask | LocalTaskInfo | TaskActionUpdateInfo;
28
- }
29
- export declare enum TaskActionType {
30
- Add = 0,// 添加一个新任务
31
- Update = 1,// 更新任务进度
32
- Output = 2,// 获取文件
33
- Cancel = 4,// 取消任务
34
- Restore = 5,// 恢复任务
35
- Delete = 6
36
- }
37
- export interface TaskActionUpdateInfo {
38
- task_id: string;
39
- info: LocalActionResDataUpdateTaskInfo;
40
- }
41
- export interface ToolEventFfmpegRequest {
42
- cmd: string[];
43
- inputs?: ToolParamFile[];
44
- outputs?: ToolParamFile[];
45
- }
46
- export interface ToolEventCloudDownloadRequest {
47
- source: ToolParamFile;
48
- target: ToolParamFile;
49
- }
50
- export interface ToolEventOpenToolWithIdRequest {
51
- id: string;
52
- init?: any;
53
- }
54
- export interface ToolEventFfmpegResponse {
55
- outputs?: ToolParamFile[];
56
- }
57
- export interface WorkActionInfo {
58
- task_id: string;
59
- action: WorkActionType;
60
- data?: LocalActionReqDataCreatTask | LocalActionReqDataRestoreTask;
61
- }
62
- export declare enum WorkActionType {
63
- Create = 0,// 创建任务
64
- Start = 1,// 启动
65
- Cancel = 2,// 取消
66
- Restore = 3,// 恢复
67
- Delete = 4
68
- }