@pisell/core 1.0.31 → 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/es/app/app.d.ts +3 -7
- package/es/app/app.js +0 -3
- package/es/indexDB/index.js +87 -62
- package/es/request/cache.d.ts +1 -1
- package/es/request/cache.js +29 -81
- package/es/request/index.d.ts +3 -3
- package/es/request/index.js +1 -14
- package/es/request/type.d.ts +0 -11
- package/es/request/type.js +1 -10
- package/es/request/utils.js +1 -1
- package/es/tasks/index.d.ts +0 -45
- package/es/tasks/index.js +101 -444
- package/es/tasks/type.d.ts +0 -38
- package/lib/app/app.d.ts +3 -7
- package/lib/app/app.js +0 -3
- package/lib/indexDB/index.js +38 -28
- package/lib/request/cache.d.ts +1 -1
- package/lib/request/cache.js +5 -42
- package/lib/request/index.d.ts +3 -3
- package/lib/request/index.js +1 -10
- package/lib/request/type.d.ts +0 -11
- package/lib/request/type.js +0 -19
- package/lib/request/utils.js +1 -1
- package/lib/tasks/index.d.ts +0 -45
- package/lib/tasks/index.js +77 -326
- package/lib/tasks/type.d.ts +0 -38
- package/package.json +1 -1
- package/es/tasks/scheduledTasksExample.d.ts +0 -61
- package/es/tasks/scheduledTasksExample.js +0 -351
- package/lib/tasks/scheduledTasksExample.d.ts +0 -61
- package/lib/tasks/scheduledTasksExample.js +0 -267
package/es/tasks/type.d.ts
CHANGED
|
@@ -18,18 +18,6 @@ export interface Task {
|
|
|
18
18
|
count: number;
|
|
19
19
|
timerId?: any;
|
|
20
20
|
};
|
|
21
|
-
scheduled?: {
|
|
22
|
-
executeAt: string | string[];
|
|
23
|
-
repeat?: boolean;
|
|
24
|
-
repeatType?: 'daily' | 'weekly' | 'monthly' | 'yearly';
|
|
25
|
-
repeatInterval?: number;
|
|
26
|
-
endAt?: string;
|
|
27
|
-
};
|
|
28
|
-
scheduledResult?: {
|
|
29
|
-
count: number;
|
|
30
|
-
timerId?: any;
|
|
31
|
-
nextExecuteTime?: string;
|
|
32
|
-
};
|
|
33
21
|
manual?: boolean;
|
|
34
22
|
destroy?: boolean;
|
|
35
23
|
[key: string]: any;
|
|
@@ -43,14 +31,6 @@ declare type TaskStatus = "uncompleted" | "completed";
|
|
|
43
31
|
export interface TaskQueue {
|
|
44
32
|
status: TaskStatus;
|
|
45
33
|
tasks: Task[];
|
|
46
|
-
isRunning?: boolean;
|
|
47
|
-
progress?: {
|
|
48
|
-
total: number;
|
|
49
|
-
completed: number;
|
|
50
|
-
failed: number;
|
|
51
|
-
inProgress: number;
|
|
52
|
-
};
|
|
53
|
-
lastRunAt?: string;
|
|
54
34
|
}
|
|
55
35
|
export interface RunTaskParams {
|
|
56
36
|
module: TaskModuleName;
|
|
@@ -67,33 +47,15 @@ export interface AddTaskParams {
|
|
|
67
47
|
queueId: TaskQueueName;
|
|
68
48
|
tasks: Task[];
|
|
69
49
|
}
|
|
70
|
-
export interface AddTaskDataParams {
|
|
71
|
-
module: TaskModuleName;
|
|
72
|
-
queueId: TaskQueueName;
|
|
73
|
-
[key: string]: any;
|
|
74
|
-
}
|
|
75
50
|
export interface TaskRunResult {
|
|
76
51
|
status: TaskRunStatus;
|
|
77
52
|
[key: string]: any;
|
|
78
53
|
}
|
|
79
|
-
/**
|
|
80
|
-
* 任务模块
|
|
81
|
-
* 注意:'scheduledTasks' 是保留的模块名,专门用于定时任务
|
|
82
|
-
* 在其他模块中,scheduled 配置会被忽略,任务将作为普通任务执行
|
|
83
|
-
*/
|
|
84
54
|
export interface TasksModule {
|
|
85
55
|
[key: TaskModuleName]: {
|
|
86
56
|
[key: TaskQueueName]: {
|
|
87
57
|
status: TaskStatus;
|
|
88
58
|
tasks: Task[];
|
|
89
|
-
isRunning?: boolean;
|
|
90
|
-
progress?: {
|
|
91
|
-
total: number;
|
|
92
|
-
completed: number;
|
|
93
|
-
failed: number;
|
|
94
|
-
inProgress: number;
|
|
95
|
-
};
|
|
96
|
-
lastRunAt?: string;
|
|
97
59
|
};
|
|
98
60
|
};
|
|
99
61
|
}
|
package/lib/app/app.d.ts
CHANGED
|
@@ -8,8 +8,8 @@ import { MenuManager } from '../menuManager';
|
|
|
8
8
|
import LoggerManager, { LoggerOptions } from '../logger';
|
|
9
9
|
import { TasksManager } from '../tasks';
|
|
10
10
|
import IndexDBManager, { DBOptions } from '../indexDB';
|
|
11
|
-
import CMD
|
|
12
|
-
import AWS
|
|
11
|
+
import CMD from "../cmd";
|
|
12
|
+
import AWS from "../aws";
|
|
13
13
|
declare global {
|
|
14
14
|
interface Window {
|
|
15
15
|
app: App;
|
|
@@ -22,9 +22,6 @@ export interface AppOptions {
|
|
|
22
22
|
history?: HistoryOptions;
|
|
23
23
|
storage?: StorageOptions;
|
|
24
24
|
locales?: LocalesOptions;
|
|
25
|
-
cmd?: CMDOptions;
|
|
26
|
-
aws?: AWSOptions;
|
|
27
|
-
getPisellos?: () => any;
|
|
28
25
|
}
|
|
29
26
|
declare class App {
|
|
30
27
|
private static instance;
|
|
@@ -46,7 +43,7 @@ declare class App {
|
|
|
46
43
|
post: (url: string, data: any, config: import("../request").RequestSetting | undefined) => Promise<any>;
|
|
47
44
|
put: (url: string, data: any, config: import("../request").RequestSetting | undefined) => Promise<any>;
|
|
48
45
|
remove: (url: string, data: any, config: import("../request").RequestSetting | undefined) => Promise<any>;
|
|
49
|
-
custom: (url: string, config: import("../request").RequestSetting | undefined) => any
|
|
46
|
+
custom: (url: string, config: import("../request").RequestSetting | undefined) => Promise<any>;
|
|
50
47
|
setConfig: (newConfig: Partial<import("../request").RequestConfig>) => void;
|
|
51
48
|
getConfig: () => import("../request").RequestConfig;
|
|
52
49
|
};
|
|
@@ -69,7 +66,6 @@ declare class App {
|
|
|
69
66
|
cmd: CMD;
|
|
70
67
|
aws: AWS;
|
|
71
68
|
tasksManager: TasksManager;
|
|
72
|
-
getPisellos: any;
|
|
73
69
|
dbManager: IndexDBManager | null;
|
|
74
70
|
constants: {
|
|
75
71
|
channel: string;
|
package/lib/app/app.js
CHANGED
|
@@ -92,8 +92,6 @@ var App = class _App {
|
|
|
92
92
|
aws;
|
|
93
93
|
// 任务管理
|
|
94
94
|
tasksManager;
|
|
95
|
-
// getPisellos
|
|
96
|
-
getPisellos;
|
|
97
95
|
dbManager = null;
|
|
98
96
|
constants = {
|
|
99
97
|
channel: ""
|
|
@@ -115,7 +113,6 @@ var App = class _App {
|
|
|
115
113
|
this.tasksManager = new import_tasks.TasksManager(this);
|
|
116
114
|
this.cmd = new import_cmd.default(this, options == null ? void 0 : options.cmd);
|
|
117
115
|
this.aws = new import_aws.default(this, options == null ? void 0 : options.aws);
|
|
118
|
-
this.getPisellos = options == null ? void 0 : options.getPisellos;
|
|
119
116
|
if (options == null ? void 0 : options.constants) {
|
|
120
117
|
this.constants = options.constants || {};
|
|
121
118
|
}
|
package/lib/indexDB/index.js
CHANGED
|
@@ -110,7 +110,7 @@ var IndexDBManager = class _IndexDBManager {
|
|
|
110
110
|
* @returns {Promise<T>} 添加的数据
|
|
111
111
|
* @template T
|
|
112
112
|
*/
|
|
113
|
-
async add(storeName, data, log) {
|
|
113
|
+
async add(storeName, data, log = true) {
|
|
114
114
|
var _a;
|
|
115
115
|
if (!this.useIndexDB) {
|
|
116
116
|
const key = this.getStorageKey(storeName, data[((_a = this.stores.find((s) => s.name === storeName)) == null ? void 0 : _a.keyPath) || "id"]);
|
|
@@ -217,7 +217,7 @@ var IndexDBManager = class _IndexDBManager {
|
|
|
217
217
|
* @returns {Promise<T|null>} 获取的数据,不存在则返回 null
|
|
218
218
|
* @template T
|
|
219
219
|
*/
|
|
220
|
-
async get(storeName, key, log) {
|
|
220
|
+
async get(storeName, key, log = true) {
|
|
221
221
|
const uuid = `[ IndexDB ] GET: - ${storeName} - ${key} - ${(0, import_dayjs.default)().valueOf()}`;
|
|
222
222
|
if (log) {
|
|
223
223
|
this.app.logger.addLog({
|
|
@@ -315,7 +315,7 @@ var IndexDBManager = class _IndexDBManager {
|
|
|
315
315
|
* @returns {Promise<T>} 更新后的数据
|
|
316
316
|
* @template T
|
|
317
317
|
*/
|
|
318
|
-
async update(storeName, data, log) {
|
|
318
|
+
async update(storeName, data, log = true) {
|
|
319
319
|
var _a;
|
|
320
320
|
if (!this.useIndexDB) {
|
|
321
321
|
const key = this.getStorageKey(storeName, data[((_a = this.stores.find((s) => s.name === storeName)) == null ? void 0 : _a.keyPath) || "id"]);
|
|
@@ -347,43 +347,53 @@ var IndexDBManager = class _IndexDBManager {
|
|
|
347
347
|
const store = transaction.objectStore(storeName);
|
|
348
348
|
const request = store.put(data);
|
|
349
349
|
request.onsuccess = () => {
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
350
|
+
if (log) {
|
|
351
|
+
this.app.logger.addLog({
|
|
352
|
+
type: "info",
|
|
353
|
+
title: uuid,
|
|
354
|
+
metadata: { msg: "数据更新完成" }
|
|
355
|
+
});
|
|
356
|
+
}
|
|
355
357
|
return resolve(data);
|
|
356
358
|
};
|
|
357
359
|
request.onerror = () => {
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
360
|
+
if (log) {
|
|
361
|
+
this.app.logger.addLog({
|
|
362
|
+
type: "info",
|
|
363
|
+
title: uuid,
|
|
364
|
+
metadata: { msg: "数据更新失败" }
|
|
365
|
+
});
|
|
366
|
+
}
|
|
363
367
|
return reject(request.error ?? new Error("更新数据失败"));
|
|
364
368
|
};
|
|
365
369
|
transaction.oncomplete = () => {
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
370
|
+
if (log) {
|
|
371
|
+
this.app.logger.addLog({
|
|
372
|
+
type: "info",
|
|
373
|
+
title: uuid,
|
|
374
|
+
metadata: { msg: "事务完成" }
|
|
375
|
+
});
|
|
376
|
+
}
|
|
371
377
|
return console.log("✅ 事务完成");
|
|
372
378
|
};
|
|
373
379
|
transaction.onabort = (e) => {
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
380
|
+
if (log) {
|
|
381
|
+
this.app.logger.addLog({
|
|
382
|
+
type: "info",
|
|
383
|
+
title: uuid,
|
|
384
|
+
metadata: { msg: "事务被中止" }
|
|
385
|
+
});
|
|
386
|
+
}
|
|
379
387
|
return reject(new Error("事务被中止"));
|
|
380
388
|
};
|
|
381
389
|
transaction.onerror = (e) => {
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
390
|
+
if (log) {
|
|
391
|
+
this.app.logger.addLog({
|
|
392
|
+
type: "info",
|
|
393
|
+
title: uuid,
|
|
394
|
+
metadata: { msg: "事务错误" }
|
|
395
|
+
});
|
|
396
|
+
}
|
|
387
397
|
return reject(transaction.error ?? new Error("事务错误"));
|
|
388
398
|
};
|
|
389
399
|
} catch (e) {
|
package/lib/request/cache.d.ts
CHANGED
|
@@ -32,7 +32,7 @@ export declare const getCacheData: (url: string, data: any, cache: CacheProps) =
|
|
|
32
32
|
* @return {*}
|
|
33
33
|
* @Author: zhiwei.Wang
|
|
34
34
|
*/
|
|
35
|
-
export declare const setCacheData: (url: string, data: any, res: any, cache
|
|
35
|
+
export declare const setCacheData: (url: string, data: any, res: any, cache: CacheProps) => any | null;
|
|
36
36
|
/**
|
|
37
37
|
* @title: 缓存函数包装器
|
|
38
38
|
* @description:
|
package/lib/request/cache.js
CHANGED
|
@@ -38,14 +38,12 @@ __export(cache_exports, {
|
|
|
38
38
|
module.exports = __toCommonJS(cache_exports);
|
|
39
39
|
var import_js_md5 = __toESM(require("js-md5"));
|
|
40
40
|
var import_config = require("./config");
|
|
41
|
-
var import_type = require("./type");
|
|
42
41
|
var import_app = require("../app");
|
|
43
42
|
var CACHES = {};
|
|
44
43
|
var MAX_CACHE_TIME = 7 * 60 * 60 * 1e3;
|
|
45
44
|
var createCacheKey = (url, data, cache) => {
|
|
46
45
|
const { storage } = (0, import_config.getConfig)();
|
|
47
|
-
|
|
48
|
-
return cache.key ? storage.createKey(cache.key) : (0, import_js_md5.default)(`${url}_${JSON.stringify(_data)}`);
|
|
46
|
+
return cache.key ? storage.createKey(cache.key) : (0, import_js_md5.default)(`${url}_${JSON.stringify(data)}`);
|
|
49
47
|
};
|
|
50
48
|
var setCache = async (key, data, cache) => {
|
|
51
49
|
const { storage } = (0, import_config.getConfig)();
|
|
@@ -79,9 +77,6 @@ var getIsEffectiveTime = (time) => {
|
|
|
79
77
|
var getCache = async (key, cache) => {
|
|
80
78
|
const { storage } = (0, import_config.getConfig)();
|
|
81
79
|
if (cache.type === "memory") {
|
|
82
|
-
if (!CACHES[key]) {
|
|
83
|
-
return null;
|
|
84
|
-
}
|
|
85
80
|
if (getIsEffectiveTime(CACHES[key].time)) {
|
|
86
81
|
return CACHES[key].data;
|
|
87
82
|
}
|
|
@@ -127,47 +122,15 @@ var getCacheData = async (url, data, cache) => {
|
|
|
127
122
|
const res = await getCache(_key, cache);
|
|
128
123
|
return res;
|
|
129
124
|
};
|
|
130
|
-
var setCacheData = (url, data, res, cache
|
|
131
|
-
type: "memory"
|
|
132
|
-
}) => {
|
|
125
|
+
var setCacheData = (url, data, res, cache) => {
|
|
133
126
|
let _key = createCacheKey(url, data, cache);
|
|
134
127
|
setCache(_key, res, cache);
|
|
135
128
|
};
|
|
136
|
-
var getIsCache = (config) => {
|
|
137
|
-
var _a, _b;
|
|
138
|
-
if (!(config == null ? void 0 : config.cache) && !(config == null ? void 0 : config.useCache)) {
|
|
139
|
-
return false;
|
|
140
|
-
}
|
|
141
|
-
const cache = (config == null ? void 0 : config.cache) || {};
|
|
142
|
-
if (cache.mode === import_type.RequestModeENUM.LOCAL) {
|
|
143
|
-
return true;
|
|
144
|
-
}
|
|
145
|
-
if (cache.mode === import_type.RequestModeENUM.REMOTE) {
|
|
146
|
-
return false;
|
|
147
|
-
}
|
|
148
|
-
if (cache.mode === import_type.RequestModeENUM.LOCAL_REMOTE) {
|
|
149
|
-
return true;
|
|
150
|
-
}
|
|
151
|
-
if (cache.mode === import_type.RequestModeENUM.REMOTE_LOCAL) {
|
|
152
|
-
if ((_b = (_a = (0, import_app.getApp)()) == null ? void 0 : _a.getPlugin("network")) == null ? void 0 : _b.connected) {
|
|
153
|
-
return false;
|
|
154
|
-
}
|
|
155
|
-
return true;
|
|
156
|
-
}
|
|
157
|
-
return true;
|
|
158
|
-
};
|
|
159
129
|
var cacheFn = async (props, fn) => {
|
|
160
130
|
var _a;
|
|
161
131
|
const { url, data, config } = props;
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
let cache = config.cache;
|
|
165
|
-
if (config.useCache) {
|
|
166
|
-
cache = {
|
|
167
|
-
type: "memory"
|
|
168
|
-
};
|
|
169
|
-
}
|
|
170
|
-
let _data = await getCacheData(url, data, cache);
|
|
132
|
+
if (config == null ? void 0 : config.cache) {
|
|
133
|
+
let _data = await getCacheData(url, data, config.cache);
|
|
171
134
|
if (_data) {
|
|
172
135
|
if ((_a = config.cache) == null ? void 0 : _a.updateCache) {
|
|
173
136
|
fn({
|
|
@@ -175,7 +138,7 @@ var cacheFn = async (props, fn) => {
|
|
|
175
138
|
config: {
|
|
176
139
|
...props.config,
|
|
177
140
|
cache: {
|
|
178
|
-
...cache,
|
|
141
|
+
...props.config.cache,
|
|
179
142
|
updateCache: false
|
|
180
143
|
}
|
|
181
144
|
}
|
package/lib/request/index.d.ts
CHANGED
|
@@ -5,19 +5,19 @@ export declare const createRequest: (props: RequestWrapperProps) => Promise<unkn
|
|
|
5
5
|
* @param props
|
|
6
6
|
* @returns
|
|
7
7
|
*/
|
|
8
|
-
export declare const request: (props: RequestWrapperProps) => any
|
|
8
|
+
export declare const request: (props: RequestWrapperProps) => Promise<any>;
|
|
9
9
|
export declare const get: (url: RequestWrapperProps["url"], data: RequestWrapperProps["data"], config: RequestWrapperProps["config"]) => Promise<any>;
|
|
10
10
|
export declare const post: (url: RequestWrapperProps["url"], data: RequestWrapperProps["data"], config: RequestWrapperProps["config"]) => Promise<any>;
|
|
11
11
|
export declare const put: (url: RequestWrapperProps["url"], data: RequestWrapperProps["data"], config: RequestWrapperProps["config"]) => Promise<any>;
|
|
12
12
|
export declare const remove: (url: RequestWrapperProps["url"], data: RequestWrapperProps["data"], config: RequestWrapperProps["config"]) => Promise<any>;
|
|
13
|
-
export declare const custom: (url: RequestWrapperProps["url"], config: RequestWrapperProps["config"]) => any
|
|
13
|
+
export declare const custom: (url: RequestWrapperProps["url"], config: RequestWrapperProps["config"]) => Promise<any>;
|
|
14
14
|
export * from "./type";
|
|
15
15
|
declare const _default: {
|
|
16
16
|
get: (url: string, data: any, config: import("./type").RequestSetting | undefined) => Promise<any>;
|
|
17
17
|
post: (url: string, data: any, config: import("./type").RequestSetting | undefined) => Promise<any>;
|
|
18
18
|
put: (url: string, data: any, config: import("./type").RequestSetting | undefined) => Promise<any>;
|
|
19
19
|
remove: (url: string, data: any, config: import("./type").RequestSetting | undefined) => Promise<any>;
|
|
20
|
-
custom: (url: string, config: import("./type").RequestSetting | undefined) => any
|
|
20
|
+
custom: (url: string, config: import("./type").RequestSetting | undefined) => Promise<any>;
|
|
21
21
|
setConfig: (newConfig: Partial<RequestConfig>) => void;
|
|
22
22
|
getConfig: () => RequestConfig;
|
|
23
23
|
};
|
package/lib/request/index.js
CHANGED
|
@@ -46,7 +46,6 @@ var import_cache = require("./cache");
|
|
|
46
46
|
var import_utils = require("./utils");
|
|
47
47
|
var import_axios = __toESM(require("axios"));
|
|
48
48
|
var import_config = require("./config");
|
|
49
|
-
var import_app = require("../app");
|
|
50
49
|
__reExport(request_exports, require("./type"), module.exports);
|
|
51
50
|
var axiosInstance = import_axios.default.create(import_constants.axiosConfig);
|
|
52
51
|
axiosInstance.interceptors.request.use(import_utils.interceptorsRequest, import_utils.interceptorsRequestError);
|
|
@@ -75,19 +74,11 @@ var createRequest = (props) => {
|
|
|
75
74
|
});
|
|
76
75
|
};
|
|
77
76
|
var request = (props) => {
|
|
78
|
-
|
|
79
|
-
const { config, url, method } = props;
|
|
77
|
+
const { config, url } = props;
|
|
80
78
|
if (config == null ? void 0 : config.abort) {
|
|
81
79
|
let signal = (0, import_cancelToken.createSignal)(config.abort, url);
|
|
82
80
|
config.signal = signal;
|
|
83
81
|
}
|
|
84
|
-
if (config == null ? void 0 : config.osServer) {
|
|
85
|
-
const app = (0, import_app.getApp)();
|
|
86
|
-
const pisellos = (_a = app.getPisellos) == null ? void 0 : _a.call(app);
|
|
87
|
-
if ((pisellos == null ? void 0 : pisellos.server) && ((_c = (_b = pisellos == null ? void 0 : pisellos.server) == null ? void 0 : _b.hasRoute) == null ? void 0 : _c.call(_b, method, url))) {
|
|
88
|
-
return (_e = (_d = pisellos == null ? void 0 : pisellos.server) == null ? void 0 : _d.handleRoute) == null ? void 0 : _e.call(_d, method, url, props);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
82
|
return (0, import_cache.cacheFn)(props, createRequest);
|
|
92
83
|
};
|
|
93
84
|
var get = async (url, data, config) => {
|
package/lib/request/type.d.ts
CHANGED
|
@@ -19,21 +19,11 @@ export interface RequestConfig {
|
|
|
19
19
|
[key: string]: any;
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
|
-
export declare enum RequestModeENUM {
|
|
23
|
-
LOCAL = "local",
|
|
24
|
-
REMOTE = "remote",
|
|
25
|
-
LOCAL_REMOTE = "local_remote",
|
|
26
|
-
REMOTE_LOCAL = "remote_local",
|
|
27
|
-
OS_SERVER = "os_server"
|
|
28
|
-
}
|
|
29
|
-
export declare type RequestModeType = RequestModeENUM.LOCAL | RequestModeENUM.REMOTE | RequestModeENUM.LOCAL_REMOTE | RequestModeENUM.REMOTE_LOCAL | RequestModeENUM.OS_SERVER;
|
|
30
22
|
export interface CacheProps {
|
|
31
23
|
key?: string;
|
|
32
24
|
type?: CacheType;
|
|
33
25
|
updateCache?: boolean;
|
|
34
26
|
cacheUpdateChange?: (data: any) => void;
|
|
35
|
-
mode?: RequestModeType;
|
|
36
|
-
cacheKeyData?: any;
|
|
37
27
|
}
|
|
38
28
|
export interface RequestSetting {
|
|
39
29
|
abort?: boolean;
|
|
@@ -41,7 +31,6 @@ export interface RequestSetting {
|
|
|
41
31
|
cache?: CacheProps;
|
|
42
32
|
signal?: any;
|
|
43
33
|
token?: string;
|
|
44
|
-
osServer?: boolean;
|
|
45
34
|
[key: string]: any;
|
|
46
35
|
}
|
|
47
36
|
export interface RequestWrapperProps {
|
package/lib/request/type.js
CHANGED
|
@@ -2,10 +2,6 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
5
|
var __copyProps = (to, from, except, desc) => {
|
|
10
6
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
7
|
for (let key of __getOwnPropNames(from))
|
|
@@ -18,19 +14,4 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
18
14
|
|
|
19
15
|
// src/request/type.ts
|
|
20
16
|
var type_exports = {};
|
|
21
|
-
__export(type_exports, {
|
|
22
|
-
RequestModeENUM: () => RequestModeENUM
|
|
23
|
-
});
|
|
24
17
|
module.exports = __toCommonJS(type_exports);
|
|
25
|
-
var RequestModeENUM = /* @__PURE__ */ ((RequestModeENUM2) => {
|
|
26
|
-
RequestModeENUM2["LOCAL"] = "local";
|
|
27
|
-
RequestModeENUM2["REMOTE"] = "remote";
|
|
28
|
-
RequestModeENUM2["LOCAL_REMOTE"] = "local_remote";
|
|
29
|
-
RequestModeENUM2["REMOTE_LOCAL"] = "remote_local";
|
|
30
|
-
RequestModeENUM2["OS_SERVER"] = "os_server";
|
|
31
|
-
return RequestModeENUM2;
|
|
32
|
-
})(RequestModeENUM || {});
|
|
33
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
34
|
-
0 && (module.exports = {
|
|
35
|
-
RequestModeENUM
|
|
36
|
-
});
|
package/lib/request/utils.js
CHANGED
|
@@ -86,7 +86,7 @@ var requestCallback = (resData) => {
|
|
|
86
86
|
const codeFn = requestCallbacks == null ? void 0 : requestCallbacks[res == null ? void 0 : res.code];
|
|
87
87
|
if (codeFn) {
|
|
88
88
|
if ((res == null ? void 0 : res.code) === 200) {
|
|
89
|
-
if (
|
|
89
|
+
if (config == null ? void 0 : config.cache) {
|
|
90
90
|
(0, import_cache.setCacheData)(props.url, props.data, res, config == null ? void 0 : config.cache);
|
|
91
91
|
(_a = config == null ? void 0 : config.cacheUpdateChange) == null ? void 0 : _a.call(config, res);
|
|
92
92
|
}
|
package/lib/tasks/index.d.ts
CHANGED
|
@@ -37,20 +37,6 @@ export declare class TasksManager {
|
|
|
37
37
|
* @param {NodeJS.Timeout} timerId
|
|
38
38
|
*/
|
|
39
39
|
private clearTaskTimer;
|
|
40
|
-
/**
|
|
41
|
-
* @title: 计算下一次执行时间
|
|
42
|
-
* @description: 根据定时任务配置计算下一次执行时间
|
|
43
|
-
* @param {Task} task
|
|
44
|
-
* @return {string | null} 下一次执行时间
|
|
45
|
-
*/
|
|
46
|
-
private calculateNextExecuteTime;
|
|
47
|
-
/**
|
|
48
|
-
* @title: 启动定时任务
|
|
49
|
-
* @description: 在特定时间点执行任务(仅在 scheduledTasks 模块中生效)
|
|
50
|
-
* @param {Task} task
|
|
51
|
-
* @return {*}
|
|
52
|
-
*/
|
|
53
|
-
private startScheduledTask;
|
|
54
40
|
/**
|
|
55
41
|
* @title: 启动轮询
|
|
56
42
|
* @description: 根据轮询间隔定期执行任务
|
|
@@ -89,40 +75,9 @@ export declare class TasksManager {
|
|
|
89
75
|
addTask(payload: AddTaskParams): void;
|
|
90
76
|
private updateTask;
|
|
91
77
|
private updateQueueStatus;
|
|
92
|
-
/**
|
|
93
|
-
* @title: 更新队列运行状态
|
|
94
|
-
* @description: 标记队列是否正在执行
|
|
95
|
-
*/
|
|
96
|
-
private updateQueueRunningState;
|
|
97
|
-
private setTasksData;
|
|
98
78
|
private setTasks;
|
|
99
79
|
clearAllTaskTimer(tasks: Task[]): void;
|
|
100
80
|
clearTasks(payload: RunTaskParams): void;
|
|
101
81
|
clearAllTasks(): void;
|
|
102
82
|
watchTask(callback: (taskModule: TasksModule) => void): void;
|
|
103
|
-
/**
|
|
104
|
-
* @title: 获取队列执行状态
|
|
105
|
-
* @description: 获取指定队列的执行状态和进度信息
|
|
106
|
-
* @param {string} module - 模块名
|
|
107
|
-
* @param {string} queueId - 队列ID
|
|
108
|
-
* @return {object} 队列状态信息
|
|
109
|
-
*/
|
|
110
|
-
getQueueStatus(module: string, queueId: string): {
|
|
111
|
-
isRunning: boolean;
|
|
112
|
-
status: "completed" | "uncompleted";
|
|
113
|
-
progress: {
|
|
114
|
-
total: number;
|
|
115
|
-
completed: number;
|
|
116
|
-
failed: number;
|
|
117
|
-
inProgress: number;
|
|
118
|
-
};
|
|
119
|
-
lastRunAt: string | null;
|
|
120
|
-
tasksCount: number;
|
|
121
|
-
} | null;
|
|
122
|
-
/**
|
|
123
|
-
* @title: 获取所有队列状态
|
|
124
|
-
* @description: 获取所有任务队列的执行状态概览
|
|
125
|
-
* @return {object} 所有队列的状态信息
|
|
126
|
-
*/
|
|
127
|
-
getAllQueuesStatus(): any;
|
|
128
83
|
}
|