@byted-apaas/server-sdk-node 1.0.15 → 1.0.16-beta.16
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 +18 -0
- package/application/application.d.ts +10 -8
- package/application/impl/impl.d.ts +8 -6
- package/application/impl/impl.js +6 -4
- package/constants/constants.js +4 -4
- package/constants/constants.js.map +1 -0
- package/context/context.d.ts +2 -71
- package/context/context.js +0 -16
- package/context/context.js.map +1 -0
- package/context/db/db.d.ts +12 -20
- package/context/db/db.js.map +1 -0
- package/context/db/impl/IObject.d.ts +46 -36
- package/context/db/impl/IObject.js.map +1 -0
- package/context/db/impl/db.d.ts +9 -9
- package/context/db/impl/db.js +6 -6
- package/context/db/impl/db.js.map +1 -0
- package/context/db/impl/object.d.ts +2 -0
- package/context/db/impl/object.js +74 -50
- package/context/db/impl/object.js.map +1 -0
- package/context/db/impl/oql/ioql.js.map +1 -0
- package/context/db/impl/oql/oql.d.ts +1 -1
- package/context/db/impl/oql/oql.js.map +1 -0
- package/context/db/impl/order.d.ts +1 -1
- package/context/db/impl/order.js +1 -1
- package/context/db/impl/order.js.map +1 -0
- package/context/db/impl/propertiesStore.js +1 -1
- package/context/db/impl/propertiesStore.js.map +1 -0
- package/context/db/impl/queryBuilder.d.ts +1 -0
- package/context/db/impl/queryBuilder.js.map +1 -0
- package/context/db/impl/transaction/index.d.ts +3 -3
- package/context/db/impl/transaction/index.js +46 -45
- package/context/db/impl/transaction/index.js.map +1 -0
- package/context/db/impl/transaction/operation.js.map +1 -0
- package/context/db/impl/transaction.d.ts +1 -6
- package/context/db/impl/transaction.js.map +1 -0
- package/context/globalConfig/globalConfig.js.map +1 -0
- package/context/integration/IIntegration.d.ts +30 -0
- package/context/integration/IIntegration.js +4 -0
- package/context/integration/impl/integration.d.ts +16 -0
- package/context/integration/impl/integration.js +62 -0
- package/context/metadata/components/common.js +3 -3
- package/context/metadata/components/common.js.map +1 -0
- package/context/metadata/components/components.d.ts +4 -4
- package/context/metadata/components/components.js.map +1 -0
- package/context/metadata/components/desktop/list.d.ts +3 -3
- package/context/metadata/components/desktop/list.js +23 -23
- package/context/metadata/components/desktop/list.js.map +1 -0
- package/context/metadata/components/desktop/recordDetail.d.ts +2 -2
- package/context/metadata/components/desktop/recordDetail.js.map +1 -0
- package/context/metadata/components/mobile/list.d.ts +4 -4
- package/context/metadata/components/mobile/list.js +1 -1
- package/context/metadata/components/mobile/list.js.map +1 -0
- package/context/metadata/metadata.d.ts +5 -6
- package/context/metadata/metadata.js +5 -6
- package/context/metadata/metadata.js.map +1 -0
- package/context/metadata/objects/fields.d.ts +6 -6
- package/context/metadata/objects/fields.js +57 -57
- package/context/metadata/objects/fields.js.map +1 -0
- package/context/metadata/objects/fields.util.d.ts +3 -3
- package/context/metadata/objects/fields.util.js +21 -21
- package/context/metadata/objects/fields.util.js.map +1 -0
- package/context/metadata/objects/objects.d.ts +1 -1
- package/context/metadata/objects/objects.js +1 -1
- package/context/metadata/objects/objects.js.map +1 -0
- package/context/metadata/types/common.d.ts +2 -2
- package/context/metadata/types/common.js.map +1 -0
- package/context/metadata/types/components.d.ts +18 -18
- package/context/metadata/types/components.js.map +1 -0
- package/context/metadata/types/objects.d.ts +93 -93
- package/context/metadata/types/objects.js.map +1 -0
- package/context/msg/msg.d.ts +2 -2
- package/context/msg/msg.js.map +1 -0
- package/context/resources/IResources.d.ts +5 -4
- package/context/resources/IResources.js.map +1 -0
- package/context/resources/impl/resources.d.ts +1 -0
- package/context/resources/impl/resources.js.map +1 -0
- package/context/tasks/tasks.d.ts +3 -3
- package/context/tasks/tasks.js +5 -5
- package/context/tasks/tasks.js.map +1 -0
- package/data/index.d.ts +3 -3
- package/data/index.js.map +1 -0
- package/global/application/flow/flow.d.ts +85 -0
- package/global/application/flow/flow.js +2 -0
- package/global/global.d.ts +88 -0
- package/global/global.js +3 -0
- package/hooks/api.d.ts +15 -9
- package/hooks/api.js +28 -23
- package/hooks/api.js.map +1 -0
- package/hooks/hooks.js +41 -0
- package/hooks/hooks.js.map +1 -0
- package/kunlun/kunlun.d.ts +5 -5
- package/kunlun/kunlun.js.map +1 -0
- package/kunlun/operator/IOperator.d.ts +16 -16
- package/kunlun/operator/IOperator.js.map +1 -0
- package/kunlun/operator/impl/expression.d.ts +5 -5
- package/kunlun/operator/impl/expression.js +5 -5
- package/kunlun/operator/impl/expression.js.map +1 -0
- package/kunlun/operator/impl/logic.d.ts +1 -1
- package/kunlun/operator/impl/logic.js +56 -39
- package/kunlun/operator/impl/logic.js.map +1 -0
- package/kunlun/operator/impl/logicV2.d.ts +8 -8
- package/kunlun/operator/impl/logicV2.js +23 -24
- package/kunlun/operator/impl/operator.d.ts +17 -17
- package/kunlun/operator/impl/operator.js +38 -38
- package/kunlun/operator/impl/operator.js.map +1 -0
- package/kunlun/operator/impl/operatorV2.d.ts +17 -17
- package/kunlun/operator/impl/operatorV2.js +38 -38
- package/lib/core.d.ts +3 -3
- package/lib/core.js.map +1 -0
- package/package.json +2 -2
- package/request/common.d.ts +1 -1
- package/request/common.js +4 -3
- package/request/constants.d.ts +1 -1
- package/request/constants.js +6 -6
- package/request/constants.js.map +1 -0
- package/request/faasinfra.d.ts +1 -1
- package/request/faasinfra.js +41 -251
- package/request/faasinfra.js.map +1 -0
- package/request/innerapi.d.ts +2 -1
- package/request/innerapi.js +3 -5
- package/request/innerapi.js.map +1 -0
- package/request/interface.d.ts +5 -4
- package/request/interface.js.map +1 -0
- package/request/openapi.d.ts +14 -9
- package/request/openapi.js +216 -153
- package/request/openapi.js.map +1 -0
- package/types/types.d.ts +13 -13
- package/types/types.js.map +1 -0
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
export interface Flow {
|
|
2
|
+
/**
|
|
3
|
+
* 获取流程实例人工任务详情列表
|
|
4
|
+
* @param executionId
|
|
5
|
+
*/
|
|
6
|
+
getExecutionUserTaskInfo: (executionId: number) => Promise<FlowTaskInfo[]>;
|
|
7
|
+
/**
|
|
8
|
+
* 执行流程
|
|
9
|
+
* @param APIName 流程的 APIName
|
|
10
|
+
* @param options 流程执行选项
|
|
11
|
+
* - params 流程入参
|
|
12
|
+
* @constructor
|
|
13
|
+
*/
|
|
14
|
+
execute: (APIName: string, options?: ExecuteOptions) => Promise<ExecutionResult>;
|
|
15
|
+
/**
|
|
16
|
+
* 撤销流程实例 (仅支持撤销包含人工任务的流程实例)
|
|
17
|
+
* @param executionId 流程实例 Id
|
|
18
|
+
* @param options 撤销选项 reason: 多语原因
|
|
19
|
+
* @constructor
|
|
20
|
+
*/
|
|
21
|
+
revokeExecution: (executionId: number, options: RevokeExecutionOptions) => Promise<void>;
|
|
22
|
+
/**
|
|
23
|
+
* 获取流程实例信息
|
|
24
|
+
* @param executionId 流程实例 Id
|
|
25
|
+
* @constructor
|
|
26
|
+
*/
|
|
27
|
+
getExecutionInfo: (executionId: number) => Promise<ExecutionInfo>;
|
|
28
|
+
}
|
|
29
|
+
export interface Execution {
|
|
30
|
+
/**
|
|
31
|
+
* 流程实例 id (函数被流程调用时有值)
|
|
32
|
+
*/
|
|
33
|
+
id: number;
|
|
34
|
+
}
|
|
35
|
+
export interface ExecuteOptions {
|
|
36
|
+
params: Record<string, any>;
|
|
37
|
+
}
|
|
38
|
+
export interface ExecutionResult {
|
|
39
|
+
executionId: number;
|
|
40
|
+
status: ExecutionStatusType;
|
|
41
|
+
data: Record<string, any>;
|
|
42
|
+
errCode?: string;
|
|
43
|
+
errMsg?: string;
|
|
44
|
+
}
|
|
45
|
+
export declare type ExecutionStatusType = 'wait' | 'in_process' | 'end' | 'rejected' | 'canceled' | 'failed' | 'agreed';
|
|
46
|
+
export interface RevokeExecutionOptions {
|
|
47
|
+
reason?: NewMultilingual;
|
|
48
|
+
}
|
|
49
|
+
export interface ExecutionInfo {
|
|
50
|
+
status: ExecutionStatusType;
|
|
51
|
+
data: Record<string, any>;
|
|
52
|
+
errCode?: string;
|
|
53
|
+
errMsg?: string;
|
|
54
|
+
}
|
|
55
|
+
export interface FlowTaskInfo {
|
|
56
|
+
taskId: number;
|
|
57
|
+
label: NewMultilingual;
|
|
58
|
+
taskType: TaskType;
|
|
59
|
+
taskStatus: TaskStatus;
|
|
60
|
+
opinionList: TaskOpinion[];
|
|
61
|
+
assigneeList: FlowUser[];
|
|
62
|
+
startedTime: number;
|
|
63
|
+
completedTime?: number;
|
|
64
|
+
}
|
|
65
|
+
export declare type TaskType = 'form' | 'approval' | 'CC';
|
|
66
|
+
export declare type TaskStatus = 'in_process' | 'completed' | 'canceled' | 'failed' | 'auto_end' | 'agreed' | 'rejected';
|
|
67
|
+
export interface NewMultilingual {
|
|
68
|
+
en_US?: string;
|
|
69
|
+
zh_CN?: string;
|
|
70
|
+
}
|
|
71
|
+
export interface FlowUserAvatar {
|
|
72
|
+
url: string;
|
|
73
|
+
}
|
|
74
|
+
export interface FlowUser {
|
|
75
|
+
userId: number;
|
|
76
|
+
feishuOpenId: string;
|
|
77
|
+
userName: NewMultilingual;
|
|
78
|
+
}
|
|
79
|
+
export interface TaskOpinion {
|
|
80
|
+
user: FlowUser;
|
|
81
|
+
feishuOpenId: number;
|
|
82
|
+
opinionResult?: string;
|
|
83
|
+
submitTime: number;
|
|
84
|
+
opinionContent?: string;
|
|
85
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { IOperator } from '../kunlun/operator/IOperator';
|
|
2
|
+
import { GMTOffset as GMT } from '@byted-apaas/server-common-node/constants/timeZone';
|
|
3
|
+
import { area2code } from '@byted-apaas/server-common-node/constants/countryCode';
|
|
4
|
+
import * as common from '@byted-apaas/server-common-node';
|
|
5
|
+
import { Flow } from './application/flow/flow';
|
|
6
|
+
import { _Resources } from '../context/resources/impl/resources';
|
|
7
|
+
import { Message } from '../context/msg/msg';
|
|
8
|
+
import { _IIntegration } from '../context/integration/IIntegration';
|
|
9
|
+
declare global {
|
|
10
|
+
export namespace application {
|
|
11
|
+
/**
|
|
12
|
+
* 操作 flow
|
|
13
|
+
*/
|
|
14
|
+
let flow: Flow;
|
|
15
|
+
/**
|
|
16
|
+
* 静态资源类操作
|
|
17
|
+
*/
|
|
18
|
+
let resources: _Resources;
|
|
19
|
+
/**
|
|
20
|
+
* 向消息中心推送及更新消息
|
|
21
|
+
*/
|
|
22
|
+
let msg: Message;
|
|
23
|
+
/**
|
|
24
|
+
* 指令操作符
|
|
25
|
+
*/
|
|
26
|
+
let operator: IOperator;
|
|
27
|
+
/**
|
|
28
|
+
* 常量
|
|
29
|
+
*/
|
|
30
|
+
namespace constants {
|
|
31
|
+
/**
|
|
32
|
+
* 引用时区信息
|
|
33
|
+
*/
|
|
34
|
+
let GMTOffset: typeof GMT;
|
|
35
|
+
/**
|
|
36
|
+
* 引用国际区号
|
|
37
|
+
*/
|
|
38
|
+
let countryCode: typeof area2code;
|
|
39
|
+
/**
|
|
40
|
+
* 错误码
|
|
41
|
+
*/
|
|
42
|
+
const errorCode: {
|
|
43
|
+
RATE_LIMIT_ERROR: string;
|
|
44
|
+
Flows_NoPermission: string;
|
|
45
|
+
Flows_NotExist: string;
|
|
46
|
+
Flows_ExecutionNotExist: string;
|
|
47
|
+
Flows_NotSupportCallFlowType: string;
|
|
48
|
+
Flows_NotSupportRevokeFlow: string;
|
|
49
|
+
Flows_NoReqInputParamErr: string;
|
|
50
|
+
Flows_InvalidParamErr: string;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* 生成复杂数据结构
|
|
54
|
+
*/
|
|
55
|
+
namespace type {
|
|
56
|
+
export import Multilingual = common.fieldType.Multilingual;
|
|
57
|
+
export import Phone = common.fieldType.Phone;
|
|
58
|
+
export import Date = common.fieldType.Date;
|
|
59
|
+
export import DateTime = common.fieldType.DateTime;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* PublicAPI 功能
|
|
64
|
+
*/
|
|
65
|
+
namespace publicAPI {
|
|
66
|
+
/**
|
|
67
|
+
* 设置返回 header
|
|
68
|
+
* @param keyOrObject 要设置的 header 的 key 或对象
|
|
69
|
+
* @param value 要设置的 header 的 value,当 keyOrObject 为 key 时,该字段有效
|
|
70
|
+
*/
|
|
71
|
+
function setResponseHeader(keyOrObject: string | object, value?: string): void;
|
|
72
|
+
/**
|
|
73
|
+
* 重定向
|
|
74
|
+
* @param location 目标 url
|
|
75
|
+
*/
|
|
76
|
+
function setRedirectLocation(location: string): void;
|
|
77
|
+
/**
|
|
78
|
+
* 请求方法
|
|
79
|
+
*/
|
|
80
|
+
const method: string;
|
|
81
|
+
/**
|
|
82
|
+
* 请求头
|
|
83
|
+
*/
|
|
84
|
+
const headers: Record<string, string>;
|
|
85
|
+
}
|
|
86
|
+
const integration: _IIntegration;
|
|
87
|
+
}
|
|
88
|
+
}
|
package/global/global.js
ADDED
package/hooks/api.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import * as common from
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
1
|
+
import * as common from '@byted-apaas/server-common-node';
|
|
2
|
+
import { IGfCtx } from '@byted-apaas/server-common-node/context/IContext';
|
|
3
|
+
import { Tasks } from '../context/tasks/tasks';
|
|
4
|
+
import { DB } from '../context/db/impl/db';
|
|
5
|
+
import { _Resources } from '../context/resources/impl/resources';
|
|
6
|
+
import { Message } from '../context/msg/msg';
|
|
7
|
+
import { IMetaData } from '../context/metadata/metadata';
|
|
8
|
+
import { ExecuteOptions, ExecutionInfo, ExecutionResult, FlowTaskInfo, RevokeExecutionOptions } from '@byted-apaas/server-common-node/context/workflow/workflow';
|
|
9
|
+
declare type invokeGlobalFuncT = (funcNames: string) => {
|
|
8
10
|
invoke: (params?: any) => Promise<any>;
|
|
9
11
|
};
|
|
10
12
|
export declare function getFunctionSync(context?: any, logger?: common.Logger): invokeGlobalFuncT;
|
|
@@ -16,6 +18,10 @@ export declare function mountMetadata(context: any): void;
|
|
|
16
18
|
export declare function mountWorkflowFeature(context: any): void;
|
|
17
19
|
export declare function terminateWorkflow(): (workflowInstanceId: number, options: any) => Promise<void>;
|
|
18
20
|
export declare function mockFlowFeature(context: any): any;
|
|
21
|
+
export declare function mockGetExecutionUserTaskInfo(): (executionId: bigint) => Promise<FlowTaskInfo[]>;
|
|
22
|
+
export declare function mockExecuteFlow(): (APIName: string, options?: ExecuteOptions) => Promise<ExecutionResult>;
|
|
23
|
+
export declare function mockRevokeExecution(): (executionId: number, options: RevokeExecutionOptions) => Promise<void>;
|
|
24
|
+
export declare function mockGetExecutionInfo(): (executionId: number) => Promise<ExecutionInfo>;
|
|
19
25
|
export declare function invokeMicroservice(): (apiName: string) => {
|
|
20
26
|
/**
|
|
21
27
|
* 同步调用微服务
|
|
@@ -32,7 +38,7 @@ export declare function invokeMicroservice(): (apiName: string) => {
|
|
|
32
38
|
*/
|
|
33
39
|
invokeAsync: (path: string, method?: string, params?: any) => Promise<any>;
|
|
34
40
|
};
|
|
35
|
-
export declare const db: DB<
|
|
41
|
+
export declare const db: DB<IGfCtx, import("../data").metadataMap>;
|
|
36
42
|
export declare const resources: _Resources;
|
|
37
43
|
export declare const msg: Message;
|
|
38
44
|
export declare const tasks: Tasks<unknown>;
|
|
@@ -57,4 +63,4 @@ export declare const workflow: {
|
|
|
57
63
|
terminate: (workflowInstanceId: number, options: any) => Promise<void>;
|
|
58
64
|
};
|
|
59
65
|
export declare const metaData: IMetaData<{}>;
|
|
60
|
-
export { Application } from
|
|
66
|
+
export { Application } from '../application/impl/impl';
|
package/hooks/api.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Application = exports.metaData = exports.workflow = exports.microservice = exports.cloudfunction = exports.tasks = exports.msg = exports.resources = exports.db = exports.invokeMicroservice = exports.mockFlowFeature = exports.terminateWorkflow = exports.mountWorkflowFeature = exports.mountMetadata = exports.method = exports.setRedirectLocation = exports.toString = exports.setRespHeader = exports.getFunctionSync = void 0;
|
|
3
|
+
exports.Application = exports.metaData = exports.workflow = exports.microservice = exports.cloudfunction = exports.tasks = exports.msg = exports.resources = exports.db = exports.invokeMicroservice = exports.mockGetExecutionInfo = exports.mockRevokeExecution = exports.mockExecuteFlow = exports.mockGetExecutionUserTaskInfo = exports.mockFlowFeature = exports.terminateWorkflow = exports.mountWorkflowFeature = exports.mountMetadata = exports.method = exports.setRedirectLocation = exports.toString = exports.setRespHeader = exports.getFunctionSync = void 0;
|
|
4
4
|
const common = require("@byted-apaas/server-common-node");
|
|
5
5
|
const exceptions_1 = require("@byted-apaas/server-common-node/utils/exceptions");
|
|
6
6
|
const api = require("../hooks/api");
|
|
@@ -12,7 +12,8 @@ const msg_1 = require("../context/msg/msg");
|
|
|
12
12
|
const Request = require("../request/interface");
|
|
13
13
|
const constants = require("../constants/constants");
|
|
14
14
|
const metadata_1 = require("../context/metadata/metadata");
|
|
15
|
-
|
|
15
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
16
|
+
const nodeCls = require('node-cls'); //nolint:byted_s_ts_no_require_imports
|
|
16
17
|
const nodeClsCtx = common.nodeClsCtx;
|
|
17
18
|
const exceptions = common.exceptions;
|
|
18
19
|
const utils = common.utils;
|
|
@@ -66,7 +67,7 @@ function getFunctionSync(context, logger) {
|
|
|
66
67
|
return await Request.GetInstance().invokeFuncSync(idOrName, params);
|
|
67
68
|
}
|
|
68
69
|
let loopMasks = [funcName];
|
|
69
|
-
|
|
70
|
+
const reqCtx = nodeCls.get('loopCtx');
|
|
70
71
|
if (reqCtx && reqCtx.loopMasks && Array.isArray(reqCtx.loopMasks)) {
|
|
71
72
|
if (reqCtx.loopMasks.includes(funcName)) {
|
|
72
73
|
throw new exceptions.InvalidParamError(`Task execution forms a loop.`);
|
|
@@ -74,7 +75,7 @@ function getFunctionSync(context, logger) {
|
|
|
74
75
|
loopMasks.push(...reqCtx.loopMasks);
|
|
75
76
|
}
|
|
76
77
|
// 修改 source 全局函数
|
|
77
|
-
|
|
78
|
+
const ctx = nodeCls.create('loopCtx');
|
|
78
79
|
ctx.loopMasks = loopMasks;
|
|
79
80
|
return await ctx.run(async () => {
|
|
80
81
|
const dynCtx = nodeClsCtx.getDynCtx();
|
|
@@ -103,7 +104,7 @@ function getFunctionSync(context, logger) {
|
|
|
103
104
|
if (func) {
|
|
104
105
|
// 本地调用
|
|
105
106
|
let loopMasks = [funcName];
|
|
106
|
-
|
|
107
|
+
const reqCtx = nodeCls.get('loopCtx');
|
|
107
108
|
if (reqCtx && reqCtx.loopMasks && Array.isArray(reqCtx.loopMasks)) {
|
|
108
109
|
if (reqCtx.loopMasks.includes(funcName)) {
|
|
109
110
|
throw new exceptions.InvalidParamError(`Task execution forms a loop.`);
|
|
@@ -111,7 +112,7 @@ function getFunctionSync(context, logger) {
|
|
|
111
112
|
loopMasks.push(...reqCtx.loopMasks);
|
|
112
113
|
}
|
|
113
114
|
// 修改 source 全局函数
|
|
114
|
-
|
|
115
|
+
const ctx = nodeCls.create('loopCtx');
|
|
115
116
|
ctx.loopMasks = loopMasks;
|
|
116
117
|
return await ctx.run(async () => {
|
|
117
118
|
const dynCtx = nodeClsCtx.getDynCtx();
|
|
@@ -148,7 +149,7 @@ function setRespHeader() {
|
|
|
148
149
|
}
|
|
149
150
|
}
|
|
150
151
|
else {
|
|
151
|
-
throw new exceptions.InvalidParamError(
|
|
152
|
+
throw new exceptions.InvalidParamError('setResponseHeaders param is not a object');
|
|
152
153
|
}
|
|
153
154
|
break;
|
|
154
155
|
case 2:
|
|
@@ -160,7 +161,7 @@ function setRespHeader() {
|
|
|
160
161
|
}
|
|
161
162
|
break;
|
|
162
163
|
default:
|
|
163
|
-
throw new exceptions.InvalidParamError(
|
|
164
|
+
throw new exceptions.InvalidParamError('the number of setResponseHeaders param is 1 or 2');
|
|
164
165
|
}
|
|
165
166
|
};
|
|
166
167
|
}
|
|
@@ -169,16 +170,16 @@ function toString(value) {
|
|
|
169
170
|
if (value instanceof Array) {
|
|
170
171
|
let arr = [];
|
|
171
172
|
for (let v of value) {
|
|
172
|
-
if (typeof v ===
|
|
173
|
+
if (typeof v === 'string') {
|
|
173
174
|
arr.push(v);
|
|
174
175
|
}
|
|
175
176
|
else {
|
|
176
177
|
arr.push(utils.stringify(v));
|
|
177
178
|
}
|
|
178
179
|
}
|
|
179
|
-
return arr.join(
|
|
180
|
+
return arr.join(', ');
|
|
180
181
|
}
|
|
181
|
-
else if (typeof value ===
|
|
182
|
+
else if (typeof value === 'string') {
|
|
182
183
|
return value;
|
|
183
184
|
}
|
|
184
185
|
return utils.stringify(value);
|
|
@@ -248,19 +249,20 @@ function mockFlowFeature(context) {
|
|
|
248
249
|
exports.mockFlowFeature = mockFlowFeature;
|
|
249
250
|
function mockGetExecutionUserTaskInfo() {
|
|
250
251
|
return async (executionId) => {
|
|
251
|
-
if (!executionId || typeof executionId !==
|
|
252
|
+
if (!executionId || typeof executionId !== 'number') {
|
|
252
253
|
throw new exceptions_1.InvalidParamError(`param's type (${executionId}) need number, but is ${typeof executionId}`);
|
|
253
254
|
}
|
|
254
255
|
return await Request.GetInstance().getExecutionUserTaskInfo(executionId);
|
|
255
256
|
};
|
|
256
257
|
}
|
|
258
|
+
exports.mockGetExecutionUserTaskInfo = mockGetExecutionUserTaskInfo;
|
|
257
259
|
function mockExecuteFlow() {
|
|
258
260
|
return async (APIName, options) => {
|
|
259
|
-
if (!APIName || typeof APIName !==
|
|
261
|
+
if (!APIName || typeof APIName !== 'string') {
|
|
260
262
|
throw new exceptions_1.InvalidParamError(`param's type (${APIName}) need string, but is ${typeof APIName}`);
|
|
261
263
|
}
|
|
262
264
|
if (options && options.params && checkUtils.isNotObject(options.params)) {
|
|
263
|
-
throw new exceptions_1.InvalidParamError(`options.params's type (${options}) need object, but is ${Array.isArray(options) ?
|
|
265
|
+
throw new exceptions_1.InvalidParamError(`options.params's type (${options}) need object, but is ${Array.isArray(options) ? 'array' : typeof options.params}`);
|
|
264
266
|
}
|
|
265
267
|
if (!options) {
|
|
266
268
|
options = {};
|
|
@@ -268,29 +270,32 @@ function mockExecuteFlow() {
|
|
|
268
270
|
return await Request.GetInstance().executeFlow(APIName, options);
|
|
269
271
|
};
|
|
270
272
|
}
|
|
273
|
+
exports.mockExecuteFlow = mockExecuteFlow;
|
|
271
274
|
function mockRevokeExecution() {
|
|
272
275
|
return async (executionId, options) => {
|
|
273
|
-
if (!executionId || typeof executionId !==
|
|
276
|
+
if (!executionId || typeof executionId !== 'number') {
|
|
274
277
|
throw new exceptions_1.InvalidParamError(`param's type (${executionId}) is need number, but is ${typeof executionId}`);
|
|
275
278
|
}
|
|
276
279
|
return await Request.GetInstance().revokeExecution(executionId, options);
|
|
277
280
|
};
|
|
278
281
|
}
|
|
282
|
+
exports.mockRevokeExecution = mockRevokeExecution;
|
|
279
283
|
function mockGetExecutionInfo() {
|
|
280
284
|
return async (executionId) => {
|
|
281
|
-
if (!executionId || typeof executionId !==
|
|
285
|
+
if (!executionId || typeof executionId !== 'number') {
|
|
282
286
|
throw new exceptions_1.InvalidParamError(`param's type (${executionId}) is not matched to number, but is ${typeof executionId}`);
|
|
283
287
|
}
|
|
284
288
|
return await Request.GetInstance().getExecutionInfo(executionId);
|
|
285
289
|
};
|
|
286
290
|
}
|
|
291
|
+
exports.mockGetExecutionInfo = mockGetExecutionInfo;
|
|
287
292
|
function invokeMicroservice() {
|
|
288
293
|
/**
|
|
289
294
|
* 微服务
|
|
290
295
|
* @param apiName 微服务的名称
|
|
291
296
|
*/
|
|
292
297
|
return function (apiName) {
|
|
293
|
-
if (!apiName || typeof (apiName) !==
|
|
298
|
+
if (!apiName || typeof (apiName) !== 'string') {
|
|
294
299
|
throw new exceptions_1.InvalidParamError(`The apiName (${apiName}) is invalid and should be a non-empty field string.`);
|
|
295
300
|
}
|
|
296
301
|
return {
|
|
@@ -300,11 +305,11 @@ function invokeMicroservice() {
|
|
|
300
305
|
* @param method 请求方法,默认为 GET
|
|
301
306
|
* @param params 请求参数,默认为 undefined
|
|
302
307
|
*/
|
|
303
|
-
invoke: async
|
|
304
|
-
if (!path || typeof (path) !==
|
|
308
|
+
invoke: async (path, method = 'GET', params = undefined) => {
|
|
309
|
+
if (!path || typeof (path) !== 'string') {
|
|
305
310
|
throw new exceptions_1.InvalidParamError(`The path (${path}) is invalid and should be a non-empty field string.`);
|
|
306
311
|
}
|
|
307
|
-
if (!method || typeof (method) !==
|
|
312
|
+
if (!method || typeof (method) !== 'string') {
|
|
308
313
|
throw new exceptions_1.InvalidParamError(`The method (${method}) is invalid and should be a non-empty field string.`);
|
|
309
314
|
}
|
|
310
315
|
return await Request.GetFaaSInfraInstance().invokeMicroserviceSync(apiName, path, method, params);
|
|
@@ -315,11 +320,11 @@ function invokeMicroservice() {
|
|
|
315
320
|
* @param method 请求方法,默认为 GET
|
|
316
321
|
* @param params 请求参数,默认为 undefined
|
|
317
322
|
*/
|
|
318
|
-
invokeAsync: async
|
|
319
|
-
if (!path || typeof (path) !==
|
|
323
|
+
invokeAsync: async (path, method = 'GET', params = undefined) => {
|
|
324
|
+
if (!path || typeof (path) !== 'string') {
|
|
320
325
|
throw new exceptions_1.InvalidParamError(`The path (${path}) is invalid and should be a non-empty field string.`);
|
|
321
326
|
}
|
|
322
|
-
if (!method || typeof (method) !==
|
|
327
|
+
if (!method || typeof (method) !== 'string') {
|
|
323
328
|
throw new exceptions_1.InvalidParamError(`The method (${method}) is invalid and should be a non-empty field string.`);
|
|
324
329
|
}
|
|
325
330
|
return await Request.GetFaaSInfraInstance().invokeMicroserviceAsync(apiName, path, method, params);
|
package/hooks/api.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["api.ts"],"names":[],"mappings":";;;AAAA,oDAAqG;AAErG,qDAAqD;AAErD,4EAA8E;AAC9E,8CAA8C;AAE9C,oCAAoC;AACpC,4DAA2D;AAE3D,kDAA6C;AAC7C,8CAAyC;AACzC,mEAA+D;AAC/D,4CAA2C;AAC3C,gD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,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;YACvE,CAAC;YACD;;;;;eAKG;YACH,WAAW,EAAE,KAAK,WAAW,IAAY,EAAE,SAAiB,KAAK,EAAE,SAAc,SAAS;gBACtF,IAAI,CAAC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,KAAK,QAAQ,EAAE;oBACrC,MAAM,IAAI,8BAAiB,CAAC,aAAa,IAAI,sDAAsD,CAAC,CAAC;iBACxG;gBACD,IAAI,CAAC,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC,KAAK,QAAQ,EAAE;oBACzC,MAAM,IAAI,8BAAiB,CAAC,eAAe,MAAM,sDAAsD,CAAC,CAAC;iBAC5G;gBACD,OAAO,MAAM,IAAA,mCAAuB,EAAC,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;YACxE,CAAC;SACJ,CAAC;IACN,CAAC,CAAC;AACN,CAAC;AA3CD,gDA2CC;AAEY,QAAA,EAAE,GAAG,IAAI,OAAE,EAAU,CAAC;AACtB,QAAA,SAAS,GAAG,IAAI,sBAAU,EAAE,CAAC;AAC7B,QAAA,GAAG,GAAG,IAAI,aAAO,EAAE,CAAC;AACpB,QAAA,KAAK,GAAG,IAAI,aAAK,EAAE,CAAC;AACpB,QAAA,aAAa,GAAG,GAAG,CAAC,eAAe,EAAE,CAAC;AACtC,QAAA,YAAY,GAAG,GAAG,CAAC,kBAAkB,EAAE,CAAC;AACxC,QAAA,QAAQ,GAAG;IACpB,SAAS,EAAE,iBAAiB,EAAE;CACjC,CAAC;AACW,QAAA,QAAQ,GAAkB,IAAI,mBAAQ,CAAK,IAAI,CAAC,CAAA"}
|
package/hooks/hooks.js
CHANGED
|
@@ -8,6 +8,8 @@ const api = require("./api");
|
|
|
8
8
|
const operator_1 = require("../kunlun/operator/impl/operator");
|
|
9
9
|
const db_1 = require("../context/db/impl/db");
|
|
10
10
|
const common_1 = require("../request/common");
|
|
11
|
+
const integration_1 = require("../context/integration/impl/integration");
|
|
12
|
+
const metadataApi = require("../context/metadata/metadata");
|
|
11
13
|
/**
|
|
12
14
|
* 根据 key 获取对应的全局变量
|
|
13
15
|
* @param key 全局变量的 key
|
|
@@ -26,6 +28,7 @@ function pre(params, context, logger, requireFunc) {
|
|
|
26
28
|
global.kunlun.tool.getTenantInfo = common_1.getTenantInfo;
|
|
27
29
|
// 对 context 下的能力进行初始化
|
|
28
30
|
mountContext(context, logger, requireFunc);
|
|
31
|
+
mountApplication(context);
|
|
29
32
|
}
|
|
30
33
|
/**
|
|
31
34
|
* mountContext 函数用于初始化 context 在 core 包中实现的部分,包括:
|
|
@@ -54,6 +57,7 @@ function mountContext(context, logger, requireFunc) {
|
|
|
54
57
|
context.tasks = new tasks_1.Tasks(context.function);
|
|
55
58
|
context.msg = new msg_1.Message();
|
|
56
59
|
context.resources = new resources_1._Resources();
|
|
60
|
+
context.integration = new integration_1._Integration();
|
|
57
61
|
context.getVar = getVar;
|
|
58
62
|
context.microservice = api.invokeMicroservice();
|
|
59
63
|
api.mountWorkflowFeature(context);
|
|
@@ -63,6 +67,43 @@ function mountContext(context, logger, requireFunc) {
|
|
|
63
67
|
// 防止 context.function 被串改
|
|
64
68
|
Object.freeze(context.function);
|
|
65
69
|
}
|
|
70
|
+
function mountApplication(context) {
|
|
71
|
+
if (!global.application) {
|
|
72
|
+
global.application = {};
|
|
73
|
+
}
|
|
74
|
+
global.application.data = new db_1.DB();
|
|
75
|
+
// publicAPI
|
|
76
|
+
if (!global.application.publicAPI) {
|
|
77
|
+
global.application.publicAPI = {};
|
|
78
|
+
}
|
|
79
|
+
global.application.publicAPI.setResponseHeader = api.setRespHeader();
|
|
80
|
+
global.application.publicAPI.setRedirectLocation = api.setRedirectLocation(context);
|
|
81
|
+
global.application.publicAPI.method = server_common_node_1.utils.getHttpMethod();
|
|
82
|
+
global.application.publicAPI.headers = server_common_node_1.utils.getHttpHeaders();
|
|
83
|
+
global.application.msg = new msg_1.Message();
|
|
84
|
+
global.application.resources = new resources_1._Resources();
|
|
85
|
+
global.application.metadata = metadataApi.metadata(context);
|
|
86
|
+
// globalVar
|
|
87
|
+
if (!global.application.globalVar) {
|
|
88
|
+
global.application.globalVar = {};
|
|
89
|
+
}
|
|
90
|
+
global.application.globalVar.getVar = getVar;
|
|
91
|
+
// constants
|
|
92
|
+
if (!global.application.constants) {
|
|
93
|
+
global.application.constants = {};
|
|
94
|
+
}
|
|
95
|
+
global.application.constants.metaType = metadataApi.metaType();
|
|
96
|
+
// flow
|
|
97
|
+
global.application.flow = ({
|
|
98
|
+
getExecutionUserTaskInfo: api.mockGetExecutionUserTaskInfo(),
|
|
99
|
+
execute: api.mockExecuteFlow(),
|
|
100
|
+
revokeExecution: api.mockRevokeExecution(),
|
|
101
|
+
getExecutionInfo: api.mockGetExecutionInfo(),
|
|
102
|
+
});
|
|
103
|
+
// operator
|
|
104
|
+
global.application.operator = new operator_1.Operator();
|
|
105
|
+
global.integration = new integration_1._Integration();
|
|
106
|
+
}
|
|
66
107
|
module.exports = {
|
|
67
108
|
pre,
|
|
68
109
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks.js","sourceRoot":"","sources":["hooks.ts"],"names":[],"mappings":";;AAEA,mEAA+D;AAC/D,kDAA6C;AAC7C,4CAA2C;AAC3C,8DAA4D;AAC5D,6BAA4B;AAC5B,+DAA0D;AAC1D,8EAA+E;AAE/E,8CAA8D;AAK9D;;;GAGG;AACH,SAAS,MAAM,CAAC,GAAW;IACvB,OAAO,qBAAK,CAAC,sBAAsB,CAAC,GAAG,CAAC,CAAC;AAC7C,CAAC;AAED,SAAS,GAAG,CAAC,MAAW,EAAE,OAAgB,EAAE,MAAqB,EAAE,WAAqB;IACpF,aAAa;IACb,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE;QAChB,wBAAwB;QACvB,MAAc,CAAC,MAAM,GAAG,EAAE,CAAA;KAC9B;IACD,MAAM,CAAC,MAAM,CAAC,QAAQ,GAAG,IAAI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iBAAiB;IACjB,oBAAoB;IACnB,OAAqC,CAAC,QAAQ,GAAG,GAAG,CAAC,eAAe,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IACtF,OAAqC,CAAC,KAAK,GAAG,IAAI,aAAK,CAAE,OAAqC,CAAC,QAAQ,CAAC,CAAC;IACzG,OAAqC,CAAC,GAAG,GAAG,IAAI,aAAO,EAAE,CAAC;IAC1D,OAAqC,CAAC,SAAS,GAAG,IAAI,sBAAU,EAAE,CAAC;IACnE,OAAe,CAAC,YAAY,GAAG,GAAG,CAAC,kBAAkB,EAAE,CAAC;IACzD,GAAG,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC;IAClC,cAAc;IACd,GAAG,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;IAE3B,0BAA0B;IAC1B,MAAM,CAAC,MAAM,CAAE,OAAqC,CAAC,QAAQ,CAAC,CAAC;AACnE,CAAC;AAED,MAAM,CAAC,OAAO,GAAG;IACb,GAAG;CACN,CAAA"}
|
package/kunlun/kunlun.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { IOperator } from './operator/IOperator';
|
|
2
|
-
import { GMTOffset as GMT } from
|
|
3
|
-
import { area2code } from
|
|
4
|
-
import { ITool, IToolsExtra } from
|
|
5
|
-
import { errCodes } from
|
|
6
|
-
import * as common from
|
|
2
|
+
import { GMTOffset as GMT } from '@byted-apaas/server-common-node/constants/timeZone';
|
|
3
|
+
import { area2code } from '@byted-apaas/server-common-node/constants/countryCode';
|
|
4
|
+
import { ITool, IToolsExtra } from '@byted-apaas/server-common-node/kunlun/tool/Itool';
|
|
5
|
+
import { errCodes } from '@byted-apaas/server-common-node/utils/exceptions';
|
|
6
|
+
import * as common from '@byted-apaas/server-common-node';
|
|
7
7
|
declare global {
|
|
8
8
|
export namespace kunlun {
|
|
9
9
|
/**
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kunlun.js","sourceRoot":"","sources":["kunlun.ts"],"names":[],"mappings":";;;AAEA,4EAA+E;AAC/E,kFAA2E;AAE3E,2EAAsE;AACtE,4EAAqE;AACrE,uDAAkD;AAClD,qDAAqD;AACrD,gDAAgD;AAgBhD,IAAiB,MAAM,CAgDtB;AAhDD,WAAiB,MAAM;IACnB;;OAEG;IACU,gBAAS,GAAe,oBAAG,CAAC;IAEzC;;OAEG;IACU,kBAAW,GAAqB,uBAAS,CAAC;IAEvD;;OAEG;IACQ,WAAI,GAAU,IAAI,WAAI,EAAE,CAAC;IAEpC;;OAEG;IACH,IAAiB,IAAI,CAKpB;IALD,WAAiB,IAAI;QACH,iBAAY,GAAG,MAAM,CAAC,SAAS,CAAC,YAAY,CAAA;QAC5C,UAAK,GAAG,MAAM,CAAC,SAAS,CAAC,KAAK,CAAA;QAC9B,SAAI,GAAG,MAAM,CAAC,SAAS,CAAC,IAAI,CAAA;QAC5B,aAAQ,GAAG,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAA;IACtD,CAAC,EALgB,IAAI,GAAJ,WAAI,KAAJ,WAAI,QAKpB;IAED;;OAEG;IACU,gBAAS,GAAG;QACrB;;WAEG;QACH,gBAAgB,EAAE,qBAAQ,CAAC,gBAAgB;KAC9C,CAAA;IAED;;;OAGG;IACI,KAAK,UAAU,MAAM,CAAC,GAAW;QACpC,OAAO,MAAM,OAAO,CAAC,WAAW,EAAE,CAAC,oBAAoB,CAAC,GAAG,CAAC,CAAC;IACjE,CAAC;IAFqB,aAAM,SAE3B,CAAA;IAED;;OAEG;IACU,eAAQ,GAAc,IAAI,mBAAQ,EAAE,CAAC;AACtD,CAAC,EAhDgB,MAAM,GAAN,cAAM,KAAN,cAAM,QAgDtB"}
|
|
@@ -6,10 +6,10 @@ export interface IOperator {
|
|
|
6
6
|
* @param conditions 多个条件,用逗号分隔
|
|
7
7
|
* @example
|
|
8
8
|
* ```
|
|
9
|
-
* context.db.object(
|
|
10
|
-
* age:
|
|
9
|
+
* context.db.object('_user').where(kunlun.operator.and({
|
|
10
|
+
* age: '22'
|
|
11
11
|
* },{
|
|
12
|
-
* gender:
|
|
12
|
+
* gender: 'male'
|
|
13
13
|
* }))
|
|
14
14
|
* ```
|
|
15
15
|
*/
|
|
@@ -19,10 +19,10 @@ export interface IOperator {
|
|
|
19
19
|
* @param conditions 多个条件,用逗号分隔
|
|
20
20
|
* @example
|
|
21
21
|
* ```
|
|
22
|
-
* context.db.object(
|
|
23
|
-
* age:
|
|
22
|
+
* context.db.object('_user').where(kunlun.operator.or({
|
|
23
|
+
* age: '22'
|
|
24
24
|
* },{
|
|
25
|
-
* age:
|
|
25
|
+
* age: '25'
|
|
26
26
|
* }))
|
|
27
27
|
* ```
|
|
28
28
|
*/
|
|
@@ -32,7 +32,7 @@ export interface IOperator {
|
|
|
32
32
|
* @param value 判定是否包含的文本值
|
|
33
33
|
* @example
|
|
34
34
|
* ```
|
|
35
|
-
* context.db.object(
|
|
35
|
+
* context.db.object('_user').where({_name: kunlun.operator.contain('a')})
|
|
36
36
|
* ```
|
|
37
37
|
*/
|
|
38
38
|
contain<T>(value: UserDataType): _BooleanCond<T>;
|
|
@@ -41,7 +41,7 @@ export interface IOperator {
|
|
|
41
41
|
* @param value 判定是否不包含的文本值
|
|
42
42
|
* @example
|
|
43
43
|
* ```
|
|
44
|
-
* context.db.object(
|
|
44
|
+
* context.db.object('_user').where({_name: kunlun.operator.notContain('a')})
|
|
45
45
|
* ```
|
|
46
46
|
*/
|
|
47
47
|
notContain<T>(value: UserDataType): _BooleanCond<T>;
|
|
@@ -49,7 +49,7 @@ export interface IOperator {
|
|
|
49
49
|
* 无需入参,判断是否为空
|
|
50
50
|
* @example
|
|
51
51
|
* ```
|
|
52
|
-
* context.db.object(
|
|
52
|
+
* context.db.object('_user').where({employeeType: kunlun.operator.empty()})
|
|
53
53
|
* ```
|
|
54
54
|
*/
|
|
55
55
|
empty(): _BooleanCond<any>;
|
|
@@ -57,7 +57,7 @@ export interface IOperator {
|
|
|
57
57
|
* 无需入参,判断是否为空
|
|
58
58
|
* @example
|
|
59
59
|
* ```
|
|
60
|
-
* context.db.object(
|
|
60
|
+
* context.db.object('_user').where({employeeType: kunlun.operator.notEmpty()})
|
|
61
61
|
* ```
|
|
62
62
|
*/
|
|
63
63
|
notEmpty(): _BooleanCond<any>;
|
|
@@ -66,7 +66,7 @@ export interface IOperator {
|
|
|
66
66
|
* @param value 判定是否相等的值
|
|
67
67
|
* @example
|
|
68
68
|
* ```
|
|
69
|
-
* context.db.object(
|
|
69
|
+
* context.db.object('_user').where({age: kunlun.operator.eq(20)})
|
|
70
70
|
* ```
|
|
71
71
|
*/
|
|
72
72
|
eq<T>(value: UserDataType): _BooleanCond<T>;
|
|
@@ -75,7 +75,7 @@ export interface IOperator {
|
|
|
75
75
|
* @param value 判定是否不相等的值
|
|
76
76
|
* @example
|
|
77
77
|
* ```
|
|
78
|
-
* context.db.object(
|
|
78
|
+
* context.db.object('_user').where({age: kunlun.operator.neq(20)})
|
|
79
79
|
* ```
|
|
80
80
|
*/
|
|
81
81
|
neq<T>(value: UserDataType): _BooleanCond<T>;
|
|
@@ -84,7 +84,7 @@ export interface IOperator {
|
|
|
84
84
|
* @param value 判定是否大于或晚于的值
|
|
85
85
|
* @example
|
|
86
86
|
* ```
|
|
87
|
-
* kunlun.operator.gt(new Date(
|
|
87
|
+
* kunlun.operator.gt(new Date('2020-11-26').getTime())
|
|
88
88
|
* ```
|
|
89
89
|
*/
|
|
90
90
|
gt<T>(value: number | Date): _BooleanCond<T>;
|
|
@@ -93,7 +93,7 @@ export interface IOperator {
|
|
|
93
93
|
* @param value 判定是否大于等于或晚于等于的值
|
|
94
94
|
* @example
|
|
95
95
|
* ```
|
|
96
|
-
* kunlun.operator.gte(new Date(
|
|
96
|
+
* kunlun.operator.gte(new Date('2020-11-26').getTime())
|
|
97
97
|
* ```
|
|
98
98
|
*/
|
|
99
99
|
gte<T>(value: number | Date): _BooleanCond<T>;
|
|
@@ -102,7 +102,7 @@ export interface IOperator {
|
|
|
102
102
|
* @param value 判定是否小于或早于的值
|
|
103
103
|
* @example
|
|
104
104
|
* ```
|
|
105
|
-
* kunlun.operator.lt(new Date(
|
|
105
|
+
* kunlun.operator.lt(new Date('2020-11-26').getTime())
|
|
106
106
|
* ```
|
|
107
107
|
*/
|
|
108
108
|
lt<T>(value: number | Date): _BooleanCond<T>;
|
|
@@ -111,7 +111,7 @@ export interface IOperator {
|
|
|
111
111
|
* @param value 判定是否小于等于或早于等于的值
|
|
112
112
|
* @example
|
|
113
113
|
* ```
|
|
114
|
-
* kunlun.operator.lte(new Date(
|
|
114
|
+
* kunlun.operator.lte(new Date('2020-11-26').getTime())
|
|
115
115
|
* ```
|
|
116
116
|
*/
|
|
117
117
|
lte<T>(value: number | Date): _BooleanCond<T>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IOperator.js","sourceRoot":"","sources":["IOperator.ts"],"names":[],"mappings":""}
|