@pisell/core 1.0.26 → 1.0.28
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/request/cache.js +44 -28
- package/es/request/utils.js +1 -1
- package/es/tasks/index.js +444 -101
- package/es/tasks/scheduledTasksExample.js +351 -0
- package/lib/request/cache.js +15 -4
- package/lib/request/utils.js +1 -1
- package/lib/tasks/index.js +326 -77
- package/lib/tasks/scheduledTasksExample.js +267 -0
- package/package.json +1 -1
- package/es/app/app.d.ts +0 -89
- package/es/request/cache.d.ts +0 -46
- package/es/request/index.d.ts +0 -24
- package/es/request/type.d.ts +0 -42
- package/es/request/utils.d.ts +0 -46
- package/es/tasks/index.d.ts +0 -83
- package/es/tasks/type.d.ts +0 -62
- package/lib/app/app.d.ts +0 -89
- package/lib/request/cache.d.ts +0 -46
- package/lib/request/index.d.ts +0 -24
- package/lib/request/type.d.ts +0 -42
- package/lib/request/utils.d.ts +0 -46
- package/lib/tasks/index.d.ts +0 -83
- package/lib/tasks/type.d.ts +0 -62
package/lib/app/app.d.ts
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import { RouterManager } from '../routes';
|
|
2
|
-
import { ApplicationManager } from '../applicationManager';
|
|
3
|
-
import { History, HistoryOptions } from '../history';
|
|
4
|
-
import { Data } from '../data';
|
|
5
|
-
import { Locales, LocalesOptions } from '../locales';
|
|
6
|
-
import { Storage, StorageOptions } from '../storage';
|
|
7
|
-
import { MenuManager } from '../menuManager';
|
|
8
|
-
import LoggerManager, { LoggerOptions } from '../logger';
|
|
9
|
-
import { TasksManager } from '../tasks';
|
|
10
|
-
import IndexDBManager, { DBOptions } from '../indexDB';
|
|
11
|
-
import CMD from "../cmd";
|
|
12
|
-
import AWS from "../aws";
|
|
13
|
-
declare global {
|
|
14
|
-
interface Window {
|
|
15
|
-
app: App;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
export interface AppOptions {
|
|
19
|
-
logger?: LoggerOptions;
|
|
20
|
-
db?: DBOptions;
|
|
21
|
-
constants?: any;
|
|
22
|
-
history?: HistoryOptions;
|
|
23
|
-
storage?: StorageOptions;
|
|
24
|
-
locales?: LocalesOptions;
|
|
25
|
-
getPisellos?: () => any;
|
|
26
|
-
}
|
|
27
|
-
declare class App {
|
|
28
|
-
private static instance;
|
|
29
|
-
private plugins;
|
|
30
|
-
globalData: any;
|
|
31
|
-
router: RouterManager;
|
|
32
|
-
applicationManager: ApplicationManager;
|
|
33
|
-
history: History;
|
|
34
|
-
data: Data;
|
|
35
|
-
hooks: import("../hooks").HooksExport;
|
|
36
|
-
locales: Locales;
|
|
37
|
-
models: {
|
|
38
|
-
getStore: () => import("../models").Store;
|
|
39
|
-
StoreProvider: typeof import("react-redux").Provider;
|
|
40
|
-
setConfig: (models: any[]) => void;
|
|
41
|
-
};
|
|
42
|
-
request: {
|
|
43
|
-
get: (url: string, data: any, config: import("../request").RequestSetting | undefined) => Promise<any>;
|
|
44
|
-
post: (url: string, data: any, config: import("../request").RequestSetting | undefined) => Promise<any>;
|
|
45
|
-
put: (url: string, data: any, config: import("../request").RequestSetting | undefined) => Promise<any>;
|
|
46
|
-
remove: (url: string, data: any, config: import("../request").RequestSetting | undefined) => Promise<any>;
|
|
47
|
-
custom: (url: string, config: import("../request").RequestSetting | undefined) => any;
|
|
48
|
-
setConfig: (newConfig: Partial<import("../request").RequestConfig>) => void;
|
|
49
|
-
getConfig: () => import("../request").RequestConfig;
|
|
50
|
-
};
|
|
51
|
-
storage: Storage;
|
|
52
|
-
menuManager: MenuManager;
|
|
53
|
-
cookie: {
|
|
54
|
-
setCookie: (name: string, value: string, domain?: string | undefined) => void;
|
|
55
|
-
getCookie: (name: string) => string | null;
|
|
56
|
-
deleteCookie: (name: string, domain?: string | undefined) => void;
|
|
57
|
-
checkCookie: (name: string) => boolean;
|
|
58
|
-
updateCookie: (name: string, value: string, domain?: string | undefined) => void;
|
|
59
|
-
};
|
|
60
|
-
website: {
|
|
61
|
-
setTitle: (title: string) => void;
|
|
62
|
-
setIcon: (paramsIcon: string) => void;
|
|
63
|
-
setAppleWebAppTitle: (title: string) => void;
|
|
64
|
-
};
|
|
65
|
-
logger: LoggerManager;
|
|
66
|
-
pubsub: import("../pubsub").PubSub;
|
|
67
|
-
cmd: CMD;
|
|
68
|
-
aws: AWS;
|
|
69
|
-
tasksManager: TasksManager;
|
|
70
|
-
getPisellos: any;
|
|
71
|
-
dbManager: IndexDBManager | null;
|
|
72
|
-
constants: {
|
|
73
|
-
channel: string;
|
|
74
|
-
[key: string]: string;
|
|
75
|
-
};
|
|
76
|
-
private constructor();
|
|
77
|
-
static getInstance(options?: AppOptions): App;
|
|
78
|
-
setGlobalData(globalData: any): void;
|
|
79
|
-
usePlugin(name: string, plugin: any): void;
|
|
80
|
-
usePlugins(plugins: {
|
|
81
|
-
name: string;
|
|
82
|
-
plugin: any;
|
|
83
|
-
}[]): void;
|
|
84
|
-
getPlugin(name: string): any;
|
|
85
|
-
getGlobalData(): any;
|
|
86
|
-
install(): void;
|
|
87
|
-
unInstall(): void;
|
|
88
|
-
}
|
|
89
|
-
export default App;
|
package/lib/request/cache.d.ts
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { CacheProps } from './type';
|
|
2
|
-
export declare type CacheType = 'memory' | 'storage' | 'indexDB';
|
|
3
|
-
/**
|
|
4
|
-
* @title: 设置缓存
|
|
5
|
-
* @description:
|
|
6
|
-
* @return {*}
|
|
7
|
-
* @Author: zhiwei.Wang
|
|
8
|
-
*/
|
|
9
|
-
export declare const setCache: (key: string, data: any, cache: CacheProps) => Promise<void>;
|
|
10
|
-
/**
|
|
11
|
-
* @title: 删除缓存数据
|
|
12
|
-
* @description:
|
|
13
|
-
* @return {*}
|
|
14
|
-
* @Author: zhiwei.Wang
|
|
15
|
-
*/
|
|
16
|
-
export declare const removeCache: (key: string, cache: CacheProps) => void;
|
|
17
|
-
/**
|
|
18
|
-
* @title: 获取数据
|
|
19
|
-
* @description:
|
|
20
|
-
* @param {any} url
|
|
21
|
-
* @param {any} data
|
|
22
|
-
* @return {*}
|
|
23
|
-
* @Author: zhiwei.Wang
|
|
24
|
-
*/
|
|
25
|
-
export declare const getCacheData: (url: string, data: any, cache: CacheProps) => Promise<any>;
|
|
26
|
-
/**
|
|
27
|
-
* @title: 设置缓存
|
|
28
|
-
* @description:
|
|
29
|
-
* @param {any} url 路径
|
|
30
|
-
* @param {any} data 参数
|
|
31
|
-
* @param {any} res 数据
|
|
32
|
-
* @return {*}
|
|
33
|
-
* @Author: zhiwei.Wang
|
|
34
|
-
*/
|
|
35
|
-
export declare const setCacheData: (url: string, data: any, res: any, cache: CacheProps) => any | null;
|
|
36
|
-
/**
|
|
37
|
-
* @title: 缓存函数包装器
|
|
38
|
-
* @description:
|
|
39
|
-
* @param {any} url
|
|
40
|
-
* @param {any} data
|
|
41
|
-
* @param {any} config
|
|
42
|
-
* @param {any} fn
|
|
43
|
-
* @return {*}
|
|
44
|
-
* @Author: zhiwei.Wang
|
|
45
|
-
*/
|
|
46
|
-
export declare const cacheFn: (props: any, fn: any) => Promise<any>;
|
package/lib/request/index.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { RequestWrapperProps, RequestConfig } from "./type";
|
|
2
|
-
export declare const createRequest: (props: RequestWrapperProps) => Promise<unknown>;
|
|
3
|
-
/**
|
|
4
|
-
* 请求
|
|
5
|
-
* @param props
|
|
6
|
-
* @returns
|
|
7
|
-
*/
|
|
8
|
-
export declare const request: (props: RequestWrapperProps) => any;
|
|
9
|
-
export declare const get: (url: RequestWrapperProps["url"], data: RequestWrapperProps["data"], config: RequestWrapperProps["config"]) => Promise<any>;
|
|
10
|
-
export declare const post: (url: RequestWrapperProps["url"], data: RequestWrapperProps["data"], config: RequestWrapperProps["config"]) => Promise<any>;
|
|
11
|
-
export declare const put: (url: RequestWrapperProps["url"], data: RequestWrapperProps["data"], config: RequestWrapperProps["config"]) => Promise<any>;
|
|
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;
|
|
14
|
-
export * from "./type";
|
|
15
|
-
declare const _default: {
|
|
16
|
-
get: (url: string, data: any, config: import("./type").RequestSetting | undefined) => Promise<any>;
|
|
17
|
-
post: (url: string, data: any, config: import("./type").RequestSetting | undefined) => Promise<any>;
|
|
18
|
-
put: (url: string, data: any, config: import("./type").RequestSetting | undefined) => Promise<any>;
|
|
19
|
-
remove: (url: string, data: any, config: import("./type").RequestSetting | undefined) => Promise<any>;
|
|
20
|
-
custom: (url: string, config: import("./type").RequestSetting | undefined) => any;
|
|
21
|
-
setConfig: (newConfig: Partial<RequestConfig>) => void;
|
|
22
|
-
getConfig: () => RequestConfig;
|
|
23
|
-
};
|
|
24
|
-
export default _default;
|
package/lib/request/type.d.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { CreateAxiosDefaults } from "axios";
|
|
2
|
-
import { CacheType } from './cache';
|
|
3
|
-
export interface RequestConfig {
|
|
4
|
-
interceptorsRequest?: ((value: any) => any | Promise<any>) | null;
|
|
5
|
-
interceptorsRequestError?: ((error: any) => any) | null;
|
|
6
|
-
interceptorsResponse?: any;
|
|
7
|
-
interceptorsResponseError?: ((error: any) => any) | null;
|
|
8
|
-
axiosConfig?: CreateAxiosDefaults;
|
|
9
|
-
storage?: any;
|
|
10
|
-
getToken?: () => string | null;
|
|
11
|
-
setToken?: (token: string) => void;
|
|
12
|
-
getLocale?: () => string | null;
|
|
13
|
-
getUrl?: (config: any) => string;
|
|
14
|
-
requestCallbacks?: {
|
|
15
|
-
200?: (data: any) => void;
|
|
16
|
-
401?: (data: any) => void;
|
|
17
|
-
403?: (data: any) => void;
|
|
18
|
-
other?: (data: any) => void;
|
|
19
|
-
[key: string]: any;
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
export interface CacheProps {
|
|
23
|
-
key?: string;
|
|
24
|
-
type?: CacheType;
|
|
25
|
-
updateCache?: boolean;
|
|
26
|
-
cacheUpdateChange?: (data: any) => void;
|
|
27
|
-
}
|
|
28
|
-
export interface RequestSetting {
|
|
29
|
-
abort?: boolean;
|
|
30
|
-
headers?: any;
|
|
31
|
-
cache?: CacheProps;
|
|
32
|
-
signal?: any;
|
|
33
|
-
token?: string;
|
|
34
|
-
osServer?: boolean;
|
|
35
|
-
[key: string]: any;
|
|
36
|
-
}
|
|
37
|
-
export interface RequestWrapperProps {
|
|
38
|
-
url: string;
|
|
39
|
-
method: 'get' | 'post' | 'remove' | 'put';
|
|
40
|
-
data?: any;
|
|
41
|
-
config?: RequestSetting;
|
|
42
|
-
}
|
package/lib/request/utils.d.ts
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { InternalAxiosRequestConfig } from "axios";
|
|
2
|
-
import { RequestSetting, RequestConfig, RequestWrapperProps } from "./type";
|
|
3
|
-
export declare const getRequestHeaders: (config: InternalAxiosRequestConfig<RequestSetting> & Record<string, any>) => Record<string, string | null>;
|
|
4
|
-
/**
|
|
5
|
-
* @title: 请求前拦截
|
|
6
|
-
* @description:
|
|
7
|
-
* @param {any} config
|
|
8
|
-
* @return {*}
|
|
9
|
-
* @Author: zhiwei.Wang
|
|
10
|
-
* @Date: 2024-07-04 10:51
|
|
11
|
-
*/
|
|
12
|
-
export declare const interceptorsRequest: (config: InternalAxiosRequestConfig<RequestSetting> & Record<string, any>) => Promise<InternalAxiosRequestConfig<RequestSetting> & Record<string, any>>;
|
|
13
|
-
/**
|
|
14
|
-
* @title: 请求前error
|
|
15
|
-
* @description:
|
|
16
|
-
* @param {any} err
|
|
17
|
-
* @return {*}
|
|
18
|
-
* @Author: zhiwei.Wang
|
|
19
|
-
* @Date: 2024-07-04 10:51
|
|
20
|
-
*/
|
|
21
|
-
export declare const interceptorsRequestError: (err: RequestConfig["interceptorsRequestError"]) => any;
|
|
22
|
-
/**
|
|
23
|
-
* @title: 请求后拦截
|
|
24
|
-
* @description:
|
|
25
|
-
* @param {any} response
|
|
26
|
-
* @return {*}
|
|
27
|
-
* @Author: zhiwei.Wang
|
|
28
|
-
* @Date: 2024-07-04 10:51
|
|
29
|
-
*/
|
|
30
|
-
export declare const interceptorsResponse: (response: RequestConfig["interceptorsResponse"]) => any;
|
|
31
|
-
/**
|
|
32
|
-
* @title: 请求后错误拦截
|
|
33
|
-
* @description:
|
|
34
|
-
* @param {any} response
|
|
35
|
-
* @return {*}
|
|
36
|
-
* @Author: zhiwei.Wang
|
|
37
|
-
* @Date: 2024-07-04 10:51
|
|
38
|
-
*/
|
|
39
|
-
export declare const interceptorsResponseError: (response: RequestConfig["interceptorsResponseError"]) => any;
|
|
40
|
-
export declare const requestCallback: (resData: {
|
|
41
|
-
res?: any;
|
|
42
|
-
props: RequestWrapperProps;
|
|
43
|
-
resolve: (value: unknown) => void;
|
|
44
|
-
reject: () => void;
|
|
45
|
-
err?: any;
|
|
46
|
-
}) => void;
|
package/lib/tasks/index.d.ts
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import { Task, TasksModule, RunTaskParams, AddTaskParams, DeleteTaskParams } from "./type";
|
|
2
|
-
import App from "../app";
|
|
3
|
-
export declare class TasksManager {
|
|
4
|
-
private static instance;
|
|
5
|
-
private taskFunctions;
|
|
6
|
-
private tasks;
|
|
7
|
-
private app;
|
|
8
|
-
private db;
|
|
9
|
-
useTasks: () => {
|
|
10
|
-
tasks: TasksModule;
|
|
11
|
-
};
|
|
12
|
-
watchTaskCallback: (taskModule: TasksModule) => void;
|
|
13
|
-
private timerIds;
|
|
14
|
-
constructor(app: App);
|
|
15
|
-
static getInstance(app?: App): TasksManager;
|
|
16
|
-
addTaskFunction<T>(name: string, fun: T): void;
|
|
17
|
-
addTaskFunctions<T>(tasks: {
|
|
18
|
-
name: string;
|
|
19
|
-
fun: T;
|
|
20
|
-
}[]): void;
|
|
21
|
-
getTasks(): TasksModule;
|
|
22
|
-
getTaskFunction(name: string): any;
|
|
23
|
-
init(): Promise<void>;
|
|
24
|
-
private saveTaskQueueToLocal;
|
|
25
|
-
private loadTaskQueueFromLocal;
|
|
26
|
-
/**
|
|
27
|
-
* @title: 执行任务
|
|
28
|
-
* @description:
|
|
29
|
-
* @param {Task} task
|
|
30
|
-
* @return {*}
|
|
31
|
-
* @Author: zhiwei.Wang
|
|
32
|
-
* @Date: 2024-09-26 13:53
|
|
33
|
-
*/
|
|
34
|
-
private runTask;
|
|
35
|
-
/**
|
|
36
|
-
* @title: 清除任务定时器
|
|
37
|
-
* @param {NodeJS.Timeout} timerId
|
|
38
|
-
*/
|
|
39
|
-
private clearTaskTimer;
|
|
40
|
-
/**
|
|
41
|
-
* @title: 启动轮询
|
|
42
|
-
* @description: 根据轮询间隔定期执行任务
|
|
43
|
-
* @param {Task} task
|
|
44
|
-
* @return {*}
|
|
45
|
-
*/
|
|
46
|
-
private startPolling;
|
|
47
|
-
/**
|
|
48
|
-
* @title: 创建任务数据
|
|
49
|
-
* @description:
|
|
50
|
-
* @param {Partial} payload
|
|
51
|
-
* @return {*}
|
|
52
|
-
* @Author: zhiwei.Wang
|
|
53
|
-
* @Date: 2024-09-26 13:54
|
|
54
|
-
*/
|
|
55
|
-
private createTaskData;
|
|
56
|
-
private getTaskQueue;
|
|
57
|
-
private timeout;
|
|
58
|
-
/**
|
|
59
|
-
* @title: 执行任务队列
|
|
60
|
-
* @description:
|
|
61
|
-
* @return {*}
|
|
62
|
-
* @Author: zhiwei.Wang
|
|
63
|
-
* @Date: 2024-09-26 13:52
|
|
64
|
-
*/
|
|
65
|
-
run(payload: RunTaskParams): Promise<void>;
|
|
66
|
-
deleteTask(payload: DeleteTaskParams): void;
|
|
67
|
-
/**
|
|
68
|
-
* @title: 重试任务
|
|
69
|
-
* @description:
|
|
70
|
-
* @return {*}
|
|
71
|
-
* @Author: zhiwei.Wang
|
|
72
|
-
* @Date: 2024-09-26 13:53
|
|
73
|
-
*/
|
|
74
|
-
retryTask(payload: RunTaskParams): void;
|
|
75
|
-
addTask(payload: AddTaskParams): void;
|
|
76
|
-
private updateTask;
|
|
77
|
-
private updateQueueStatus;
|
|
78
|
-
private setTasks;
|
|
79
|
-
clearAllTaskTimer(tasks: Task[]): void;
|
|
80
|
-
clearTasks(payload: RunTaskParams): void;
|
|
81
|
-
clearAllTasks(): void;
|
|
82
|
-
watchTask(callback: (taskModule: TasksModule) => void): void;
|
|
83
|
-
}
|
package/lib/tasks/type.d.ts
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
export declare type TaskRunStatus = "pending" | "in-progress" | "success" | "failure";
|
|
2
|
-
export interface Task {
|
|
3
|
-
id?: string;
|
|
4
|
-
type?: "local" | "cloud";
|
|
5
|
-
retries?: number;
|
|
6
|
-
maxRetries?: number;
|
|
7
|
-
status?: TaskRunStatus;
|
|
8
|
-
action: string;
|
|
9
|
-
payload: any;
|
|
10
|
-
beforeAction?: string;
|
|
11
|
-
beforePayload?: any;
|
|
12
|
-
afterAction?: string;
|
|
13
|
-
afterPayload?: any;
|
|
14
|
-
polling?: {
|
|
15
|
-
interval?: number;
|
|
16
|
-
};
|
|
17
|
-
pollingResult?: {
|
|
18
|
-
count: number;
|
|
19
|
-
timerId?: any;
|
|
20
|
-
};
|
|
21
|
-
manual?: boolean;
|
|
22
|
-
destroy?: boolean;
|
|
23
|
-
[key: string]: any;
|
|
24
|
-
}
|
|
25
|
-
export interface TaskConfig {
|
|
26
|
-
tasks: Task[];
|
|
27
|
-
}
|
|
28
|
-
declare type TaskModuleName = string;
|
|
29
|
-
declare type TaskQueueName = string;
|
|
30
|
-
declare type TaskStatus = "uncompleted" | "completed";
|
|
31
|
-
export interface TaskQueue {
|
|
32
|
-
status: TaskStatus;
|
|
33
|
-
tasks: Task[];
|
|
34
|
-
}
|
|
35
|
-
export interface RunTaskParams {
|
|
36
|
-
module: TaskModuleName;
|
|
37
|
-
queueId: TaskQueueName;
|
|
38
|
-
callback?: () => void;
|
|
39
|
-
}
|
|
40
|
-
export interface DeleteTaskParams {
|
|
41
|
-
module: TaskModuleName;
|
|
42
|
-
queueId: TaskQueueName;
|
|
43
|
-
taskId: string;
|
|
44
|
-
}
|
|
45
|
-
export interface AddTaskParams {
|
|
46
|
-
module: TaskModuleName;
|
|
47
|
-
queueId: TaskQueueName;
|
|
48
|
-
tasks: Task[];
|
|
49
|
-
}
|
|
50
|
-
export interface TaskRunResult {
|
|
51
|
-
status: TaskRunStatus;
|
|
52
|
-
[key: string]: any;
|
|
53
|
-
}
|
|
54
|
-
export interface TasksModule {
|
|
55
|
-
[key: TaskModuleName]: {
|
|
56
|
-
[key: TaskQueueName]: {
|
|
57
|
-
status: TaskStatus;
|
|
58
|
-
tasks: Task[];
|
|
59
|
-
};
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
export {};
|