@byted-apaas/server-sdk-node 1.0.4 → 1.0.5-beta.8
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/application/application.d.ts +1 -1
- package/constants/constants.d.ts +3 -0
- package/constants/constants.js +4 -1
- package/context/context.d.ts +1 -1
- package/context/db/db.d.ts +1 -1
- package/context/db/impl/order.d.ts +1 -1
- package/context/db/impl/transaction/index.d.ts +2 -2
- package/context/db/impl/transaction.d.ts +1 -1
- package/context/metadata/types/common.d.ts +2 -2
- package/context/metadata/types/components.d.ts +13 -13
- package/context/metadata/types/objects.d.ts +5 -5
- package/context/msg/msg.d.ts +1 -1
- package/context/resources/IResources.d.ts +2 -2
- package/context/tasks/tasks.js +1 -1
- package/data/index.d.ts +3 -3
- package/hooks/api.d.ts +2 -3
- package/hooks/api.js +5 -25
- package/hooks/hooks.js +6 -26
- package/kunlun/operator/impl/expression.d.ts +3 -3
- package/kunlun/operator/impl/logic.d.ts +1 -1
- package/kunlun/operator/impl/logic.js +7 -7
- package/kunlun/operator/impl/logicV2.d.ts +6 -6
- package/kunlun/operator/impl/logicV2.js +12 -12
- package/package.json +3 -3
- package/request/innerapi.js +3 -3
- package/request/interface.d.ts +3 -3
- package/request/openapi.js +3 -3
- package/types/types.d.ts +13 -13
|
@@ -19,7 +19,7 @@ export interface IApplication {
|
|
|
19
19
|
localDebugMode(): IApplication;
|
|
20
20
|
setLaneName(laneName: string): IApplication;
|
|
21
21
|
}
|
|
22
|
-
export
|
|
22
|
+
export type AppMode = 'openSDK' | 'faasSDK';
|
|
23
23
|
export interface AppCtx {
|
|
24
24
|
mode: AppMode;
|
|
25
25
|
env?: PlatformEnvType;
|
package/constants/constants.d.ts
CHANGED
package/constants/constants.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2022 ByteDance Ltd. and/or its affiliates
|
|
3
3
|
// SPDX-License-Identifier: MIT
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.httpStatusCodes = exports.httpHeaderKeys = exports.notifyModel = void 0;
|
|
5
|
+
exports.triggerType = exports.httpStatusCodes = exports.httpHeaderKeys = exports.notifyModel = void 0;
|
|
6
6
|
exports.notifyModel = {
|
|
7
7
|
key: "ee.kunlun.cloudfunction.faas_buildin",
|
|
8
8
|
};
|
|
@@ -13,3 +13,6 @@ exports.httpHeaderKeys = {
|
|
|
13
13
|
exports.httpStatusCodes = {
|
|
14
14
|
redirect: 302,
|
|
15
15
|
};
|
|
16
|
+
exports.triggerType = {
|
|
17
|
+
defaultTrigger: "default-trigger"
|
|
18
|
+
};
|
package/context/context.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { Message } from "./msg/msg";
|
|
|
4
4
|
import { IDBGetter } from "./db/db";
|
|
5
5
|
import { Context as CommonContext } from '@byted-apaas/server-common-node';
|
|
6
6
|
import { IMetaData } from "./metadata/metadata";
|
|
7
|
-
export declare class Context<T, mt, cf, gv> extends CommonContext
|
|
7
|
+
export declare class Context<T, mt, cf, gv> extends CommonContext implements IContext<T, mt, cf, gv> {
|
|
8
8
|
/**
|
|
9
9
|
* 操作数据库中的记录数据
|
|
10
10
|
*/
|
package/context/db/db.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ import { IOql } from './impl/oql/ioql';
|
|
|
8
8
|
* - 目前 IDBGetter 支持的是 currentObject 方法的动态声明,使用泛型实现,期望传入的 T 是 Context 结构。
|
|
9
9
|
* - 如果 Context 有 objectApiName 属性,则拥有 .db.currentObject 和 .db.transaction.currentObject
|
|
10
10
|
*/
|
|
11
|
-
export
|
|
11
|
+
export type IDBGetter<T, mt> = T extends {
|
|
12
12
|
'objectApiName': string;
|
|
13
13
|
} ? IDB<T, mt> & IDBWithCurrentObject<{}, mt> : IDB<{}, mt>;
|
|
14
14
|
/**
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { ITransaction, ITransactionWithCurrentObject, TransactionObject } from "../transaction";
|
|
2
2
|
import { TransactionOperation } from './operation';
|
|
3
3
|
import { currentObjApiName } from '../../../../data';
|
|
4
|
-
|
|
4
|
+
type uuidOrRecordIDResult = {
|
|
5
5
|
_id: uuidOrRecordID;
|
|
6
6
|
};
|
|
7
|
-
|
|
7
|
+
type uuidOrRecordID = number | string;
|
|
8
8
|
export declare class Transaction<T, mt> implements ITransaction<mt>, ITransactionWithCurrentObject<mt> {
|
|
9
9
|
objectApiName: string;
|
|
10
10
|
placeholders: Record<string, number>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { _Cond } from '../../../types/types';
|
|
2
2
|
import { currentObjApiName } from "../../../data/index";
|
|
3
|
-
export
|
|
3
|
+
export type ITransactionGetter<T, mt> = T extends {
|
|
4
4
|
'objectApiName': string;
|
|
5
5
|
} ? ITransaction<mt> : ITransaction<mt> & ITransactionWithCurrentObject<mt>;
|
|
6
6
|
export interface ITransaction<mt> {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { I18ns } from "./common";
|
|
2
|
-
export
|
|
2
|
+
export type SelectFieldType = {
|
|
3
3
|
fieldPath: {
|
|
4
4
|
objectApiName: string;
|
|
5
5
|
fieldApiName: string;
|
|
6
6
|
}[];
|
|
7
7
|
};
|
|
8
|
-
export
|
|
8
|
+
export type FieldApiType = {
|
|
9
9
|
type?: string;
|
|
10
10
|
fieldApiName: string;
|
|
11
11
|
alias?: I18ns;
|
|
@@ -15,18 +15,18 @@ export declare type FieldApiType = {
|
|
|
15
15
|
};
|
|
16
16
|
color?: string;
|
|
17
17
|
};
|
|
18
|
-
export
|
|
18
|
+
export type UIMetaFilterType = {
|
|
19
19
|
conditions: Object[];
|
|
20
20
|
logic: string;
|
|
21
21
|
};
|
|
22
|
-
export
|
|
22
|
+
export type UIMetaSortConditionsType = {
|
|
23
23
|
fieldApiName: string;
|
|
24
24
|
sort: string;
|
|
25
25
|
};
|
|
26
|
-
export
|
|
26
|
+
export type DeskListTitleField = {
|
|
27
27
|
fieldApiName: string;
|
|
28
28
|
};
|
|
29
|
-
export
|
|
29
|
+
export type DeskListSubtitleField = {
|
|
30
30
|
type?: ("field" | "concatText");
|
|
31
31
|
fieldApiName: string;
|
|
32
32
|
alias: I18ns;
|
|
@@ -35,11 +35,11 @@ export declare type DeskListSubtitleField = {
|
|
|
35
35
|
en_US: ConcatTextType[];
|
|
36
36
|
};
|
|
37
37
|
};
|
|
38
|
-
export
|
|
38
|
+
export type DeskListDetailField = {
|
|
39
39
|
fieldApiName: string;
|
|
40
40
|
alias: I18ns;
|
|
41
41
|
};
|
|
42
|
-
export
|
|
42
|
+
export type UIMetaDesktopType = {
|
|
43
43
|
isCompositeType: boolean;
|
|
44
44
|
titleAreaText: I18ns;
|
|
45
45
|
objectApiName: string;
|
|
@@ -49,17 +49,17 @@ export declare type UIMetaDesktopType = {
|
|
|
49
49
|
filter: UIMetaFilterType;
|
|
50
50
|
sortConditions: UIMetaSortConditionsType[];
|
|
51
51
|
};
|
|
52
|
-
export
|
|
52
|
+
export type UIMetaLangType = {
|
|
53
53
|
dataType: string;
|
|
54
54
|
fieldApiName: string;
|
|
55
55
|
text: string;
|
|
56
56
|
};
|
|
57
|
-
export
|
|
57
|
+
export type ConcatTextType = {
|
|
58
58
|
dataType: "fieldApiName" | "text";
|
|
59
59
|
fieldApiName: string;
|
|
60
60
|
text: string;
|
|
61
61
|
};
|
|
62
|
-
export
|
|
62
|
+
export type UIMetaMobileType = {
|
|
63
63
|
pageType?: ("app" | "record_page");
|
|
64
64
|
pageApiName: string;
|
|
65
65
|
componentName: string;
|
|
@@ -69,11 +69,11 @@ export declare type UIMetaMobileType = {
|
|
|
69
69
|
filter: UIMetaFilterType;
|
|
70
70
|
sortConditions: UIMetaSortConditionsType[];
|
|
71
71
|
};
|
|
72
|
-
export
|
|
72
|
+
export type MobileListField = {
|
|
73
73
|
fieldApiName: string;
|
|
74
74
|
hiddenWhenEmpty?: boolean;
|
|
75
75
|
};
|
|
76
|
-
export
|
|
76
|
+
export type MobileListItem = {
|
|
77
77
|
avatar: {
|
|
78
78
|
active: boolean;
|
|
79
79
|
fieldApiName: string;
|
|
@@ -36,7 +36,7 @@ export interface KDateType extends BaseFieldType {
|
|
|
36
36
|
export interface DateTimeType extends BaseFieldType {
|
|
37
37
|
required: boolean;
|
|
38
38
|
}
|
|
39
|
-
export
|
|
39
|
+
export type SubOptionType = {
|
|
40
40
|
label: I18ns;
|
|
41
41
|
apiName: string;
|
|
42
42
|
description: I18ns;
|
|
@@ -70,7 +70,7 @@ export interface SortConditionType {
|
|
|
70
70
|
fieldApiName: string;
|
|
71
71
|
sort: ("asc" | "desc");
|
|
72
72
|
}
|
|
73
|
-
|
|
73
|
+
type ConditionType = {
|
|
74
74
|
left: {
|
|
75
75
|
objectApiName: string;
|
|
76
76
|
fieldApiName: string;
|
|
@@ -79,11 +79,11 @@ declare type ConditionType = {
|
|
|
79
79
|
valueType: ("reference" | "specified");
|
|
80
80
|
right: (object | string);
|
|
81
81
|
};
|
|
82
|
-
|
|
82
|
+
type CriterionType = {
|
|
83
83
|
conditions: ConditionType[];
|
|
84
84
|
logic: string;
|
|
85
85
|
};
|
|
86
|
-
export
|
|
86
|
+
export type FilterType = {
|
|
87
87
|
label: string;
|
|
88
88
|
needTriggerCriterion: boolean;
|
|
89
89
|
triggerCriterion: CriterionType;
|
|
@@ -135,7 +135,7 @@ export interface ExtractSingleRecordType extends BaseFieldType {
|
|
|
135
135
|
sortConditions: SortConditionType[];
|
|
136
136
|
recordPosition: number;
|
|
137
137
|
}
|
|
138
|
-
export
|
|
138
|
+
export type FieldType = {
|
|
139
139
|
"allow_search": boolean;
|
|
140
140
|
"api_name": string;
|
|
141
141
|
"calculated": boolean;
|
package/context/msg/msg.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as common from "@byted-apaas/server-common-node";
|
|
2
2
|
import Multilingual = common.fieldType.Multilingual;
|
|
3
|
-
export
|
|
3
|
+
export type _IconType = "success" | "error" | "progress" | "info";
|
|
4
4
|
export declare class _NotifyCenter {
|
|
5
5
|
/**
|
|
6
6
|
* 消息中心推送消息
|
|
@@ -41,13 +41,13 @@ export interface _IKunlunFile {
|
|
|
41
41
|
*/
|
|
42
42
|
download(fileInfo: _FileInfo, filePath: string): Promise<void>;
|
|
43
43
|
}
|
|
44
|
-
export
|
|
44
|
+
export type FileUploadResult = {
|
|
45
45
|
fileId: string;
|
|
46
46
|
type: string;
|
|
47
47
|
name: string;
|
|
48
48
|
size: number;
|
|
49
49
|
};
|
|
50
|
-
export
|
|
50
|
+
export type UploadAvatarResult = {
|
|
51
51
|
ImageId: string;
|
|
52
52
|
PreviewImageId: string;
|
|
53
53
|
};
|
package/context/tasks/tasks.js
CHANGED
|
@@ -23,7 +23,7 @@ class Tasks {
|
|
|
23
23
|
async createAsyncTask(apiName, params) {
|
|
24
24
|
if (apiName && params) {
|
|
25
25
|
// low_code 1.0
|
|
26
|
-
if (utils.isOnlineDev()) {
|
|
26
|
+
if (utils.isOnlineDev()) {
|
|
27
27
|
// 1.debug模式
|
|
28
28
|
if (utils.isDebug()) {
|
|
29
29
|
return await this.f(apiName).invoke(params);
|
package/data/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
export interface workflowVariables {
|
|
2
2
|
}
|
|
3
|
-
export
|
|
3
|
+
export type globalFuncNames = "a" | "b";
|
|
4
4
|
export interface globalVariablesMap {
|
|
5
5
|
a: string;
|
|
6
6
|
b: string;
|
|
7
7
|
}
|
|
8
|
-
export
|
|
8
|
+
export type globalVariables = keyof globalVariablesMap;
|
|
9
9
|
export interface metadataMap {
|
|
10
10
|
/**
|
|
11
11
|
* @description 用户
|
|
@@ -13,7 +13,7 @@ export interface metadataMap {
|
|
|
13
13
|
_user: User;
|
|
14
14
|
_department: Department;
|
|
15
15
|
}
|
|
16
|
-
export
|
|
16
|
+
export type currentObjApiName = "_user";
|
|
17
17
|
interface User {
|
|
18
18
|
_name: string;
|
|
19
19
|
_id: number;
|
package/hooks/api.d.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import * as common from "@byted-apaas/server-common-node";
|
|
2
|
-
import { IGfCtx } from "@byted-apaas/server-common-node/context/IContext";
|
|
3
2
|
import { Tasks } from "../context/tasks/tasks";
|
|
4
3
|
import { DB } from "../context/db/impl/db";
|
|
5
4
|
import { _Resources } from "../context/resources/impl/resources";
|
|
6
5
|
import { Message } from "../context/msg/msg";
|
|
7
6
|
import { IMetaData } from "../context/metadata/metadata";
|
|
8
|
-
|
|
7
|
+
type invokeGlobalFuncT = (funcNames: string) => {
|
|
9
8
|
invoke: (params?: any) => Promise<any>;
|
|
10
9
|
};
|
|
11
10
|
export declare function getFunctionSync(context?: any, logger?: common.Logger): invokeGlobalFuncT;
|
|
@@ -33,7 +32,7 @@ export declare function invokeMicroservice(): (apiName: string) => {
|
|
|
33
32
|
*/
|
|
34
33
|
invokeAsync: (path: string, method?: string, params?: any) => Promise<any>;
|
|
35
34
|
};
|
|
36
|
-
export declare const db: DB<
|
|
35
|
+
export declare const db: DB<import("@byted-apaas/server-common-node/context/IContext").IContext, import("../data").metadataMap>;
|
|
37
36
|
export declare const resources: _Resources;
|
|
38
37
|
export declare const msg: Message;
|
|
39
38
|
export declare const tasks: Tasks<unknown>;
|
package/hooks/api.js
CHANGED
|
@@ -11,14 +11,12 @@ const resources_1 = require("../context/resources/impl/resources");
|
|
|
11
11
|
const msg_1 = require("../context/msg/msg");
|
|
12
12
|
const Request = require("../request/interface");
|
|
13
13
|
const constants = require("../constants/constants");
|
|
14
|
-
const utils_1 = require("@byted-apaas/server-common-node/utils/utils");
|
|
15
14
|
const metadata_1 = require("../context/metadata/metadata");
|
|
16
15
|
const nodeCls = require("node-cls");
|
|
17
16
|
const nodeClsCtx = common.nodeClsCtx;
|
|
18
17
|
const exceptions = common.exceptions;
|
|
19
18
|
const utils = common.utils;
|
|
20
19
|
const checkUtils = common.checkUtils;
|
|
21
|
-
const functionSources = common.constants.functionSources;
|
|
22
20
|
// 同步调用云函数
|
|
23
21
|
function getFunctionSync(context, logger) {
|
|
24
22
|
return (funcName) => {
|
|
@@ -79,7 +77,6 @@ function getFunctionSync(context, logger) {
|
|
|
79
77
|
ctx.loopMasks = loopMasks;
|
|
80
78
|
return await ctx.run(async () => {
|
|
81
79
|
const dynCtx = nodeClsCtx.getDynCtx();
|
|
82
|
-
dynCtx.source = functionSources.globalFunction;
|
|
83
80
|
return await dynCtx.run(async () => {
|
|
84
81
|
return await common.hooks.invoke(func, params, context, logger);
|
|
85
82
|
});
|
|
@@ -89,29 +86,12 @@ function getFunctionSync(context, logger) {
|
|
|
89
86
|
};
|
|
90
87
|
}
|
|
91
88
|
return {
|
|
89
|
+
// 多语言函数开发, 走远端
|
|
92
90
|
invoke: async (params) => {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}
|
|
97
|
-
let loopMasks = [funcName];
|
|
98
|
-
let reqCtx = nodeCls.get("loopCtx");
|
|
99
|
-
if (reqCtx && reqCtx.loopMasks && Array.isArray(reqCtx.loopMasks)) {
|
|
100
|
-
if (reqCtx.loopMasks.includes(funcName)) {
|
|
101
|
-
throw new exceptions.InvalidParamError(`Task execution forms a loop.`);
|
|
102
|
-
}
|
|
103
|
-
loopMasks.push(...reqCtx.loopMasks);
|
|
104
|
-
}
|
|
105
|
-
// 修改 source 全局函数
|
|
106
|
-
let ctx = nodeCls.create("loopCtx");
|
|
107
|
-
ctx.loopMasks = loopMasks;
|
|
108
|
-
return await ctx.run(async () => {
|
|
109
|
-
const dynCtx = nodeClsCtx.getDynCtx();
|
|
110
|
-
dynCtx.source = functionSources.globalFunction;
|
|
111
|
-
return await dynCtx.run(async () => {
|
|
112
|
-
return await common.hooks.invoke(func, params, context, logger);
|
|
113
|
-
});
|
|
114
|
-
});
|
|
91
|
+
return await Request.GetInstance().invokeFuncSync({
|
|
92
|
+
APIName: funcName,
|
|
93
|
+
isInvokeByAPIName: true
|
|
94
|
+
}, params);
|
|
115
95
|
}
|
|
116
96
|
};
|
|
117
97
|
};
|
package/hooks/hooks.js
CHANGED
|
@@ -6,7 +6,6 @@ const msg_1 = require("../context/msg/msg");
|
|
|
6
6
|
const server_common_node_1 = require("@byted-apaas/server-common-node");
|
|
7
7
|
const api = require("./api");
|
|
8
8
|
const operator_1 = require("../kunlun/operator/impl/operator");
|
|
9
|
-
const constants_1 = require("@byted-apaas/server-common-node/constants/constants");
|
|
10
9
|
const db_1 = require("../context/db/impl/db");
|
|
11
10
|
const common_1 = require("../request/common");
|
|
12
11
|
/**
|
|
@@ -38,31 +37,12 @@ function pre(params, context, logger, requireFunc) {
|
|
|
38
37
|
* @param requireFunc
|
|
39
38
|
*/
|
|
40
39
|
function mountContext(context, logger, requireFunc) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
//
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
context.db = new db_1.DBWithCurrentObject(context.objectApiName);
|
|
48
|
-
break;
|
|
49
|
-
case constants_1.functionSources.globalFunction:
|
|
50
|
-
context.db = new db_1.DBWithCurrentObject(null);
|
|
51
|
-
// set response headers
|
|
52
|
-
context.setResponseHeader = api.setRespHeader();
|
|
53
|
-
context.setRedirectLocation = api.setRedirectLocation(context);
|
|
54
|
-
// 暴露context.method属性
|
|
55
|
-
context.method = server_common_node_1.utils.getHttpMethod();
|
|
56
|
-
break;
|
|
57
|
-
case constants_1.functionSources.recordAutomation:
|
|
58
|
-
context.db = new db_1.DBWithCurrentObject(context.objectApiName);
|
|
59
|
-
break;
|
|
60
|
-
case constants_1.functionSources.scheduleAutomation:
|
|
61
|
-
context.db = new db_1.DBWithCurrentObject(null);
|
|
62
|
-
break;
|
|
63
|
-
default:
|
|
64
|
-
throw new server_common_node_1.exceptions.InvalidParamError(`This npm package does not contain this source ${source}`);
|
|
65
|
-
}
|
|
40
|
+
// 1. 全量挂载
|
|
41
|
+
context.db = new db_1.DBWithCurrentObject(context.objectApiName);
|
|
42
|
+
// set response headers
|
|
43
|
+
context.setResponseHeader = api.setRespHeader();
|
|
44
|
+
context.setRedirectLocation = api.setRedirectLocation(context);
|
|
45
|
+
context.method = server_common_node_1.utils.getHttpMethod();
|
|
66
46
|
// 2. 初始化 core 包中需要初始化的内容,因此强转为 IContext 类型
|
|
67
47
|
// - function
|
|
68
48
|
// - tasks
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type UserDataType = null | string | boolean | number | Date | object;
|
|
2
2
|
export declare class Expression {
|
|
3
3
|
index: number;
|
|
4
4
|
left: ExpressionField;
|
|
@@ -6,11 +6,11 @@ export declare class Expression {
|
|
|
6
6
|
right: ExpressionField;
|
|
7
7
|
constructor(left: ExpressionField, operator: string, right: ExpressionField, index: number);
|
|
8
8
|
}
|
|
9
|
-
|
|
9
|
+
type SettingType = {
|
|
10
10
|
data?: UserDataType;
|
|
11
11
|
fieldPath?: PathType[];
|
|
12
12
|
};
|
|
13
|
-
export
|
|
13
|
+
export type PathType = {
|
|
14
14
|
objectApiName: string;
|
|
15
15
|
fieldApiName: string;
|
|
16
16
|
extendLogicTags: string[];
|
|
@@ -13,7 +13,7 @@ export declare class Condition {
|
|
|
13
13
|
toExpression(objectApiName: string, fieldApiName: string, index: number): Expression;
|
|
14
14
|
constructor(left: string, right: Condition | UserDataType, op?: string);
|
|
15
15
|
}
|
|
16
|
-
export
|
|
16
|
+
export type Criterion = {
|
|
17
17
|
conditions: Expression[];
|
|
18
18
|
logic: string;
|
|
19
19
|
};
|
|
@@ -12,13 +12,6 @@ var fieldType = common.fieldType;
|
|
|
12
12
|
const dayjs = require("dayjs");
|
|
13
13
|
// 条件操作
|
|
14
14
|
class Condition {
|
|
15
|
-
constructor(left, right, op = operator_1.operates.EQ) {
|
|
16
|
-
this.left = left;
|
|
17
|
-
this.right = right;
|
|
18
|
-
if (op) {
|
|
19
|
-
this.op = op;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
15
|
/**
|
|
23
16
|
*
|
|
24
17
|
* @param objectApiName 对象的ApiName
|
|
@@ -44,6 +37,13 @@ class Condition {
|
|
|
44
37
|
}
|
|
45
38
|
return new expression_1.Expression(left, op, right, index);
|
|
46
39
|
}
|
|
40
|
+
constructor(left, right, op = operator_1.operates.EQ) {
|
|
41
|
+
this.left = left;
|
|
42
|
+
this.right = right;
|
|
43
|
+
if (op) {
|
|
44
|
+
this.op = op;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
47
|
}
|
|
48
48
|
exports.Condition = Condition;
|
|
49
49
|
// param type should be spercific
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import { OrderV2 } from "../../../request/interface";
|
|
2
2
|
import { UserDataType } from "./expression";
|
|
3
|
-
export
|
|
3
|
+
export type FieldPath = {
|
|
4
4
|
objectApiName: string;
|
|
5
5
|
fieldApiName: string;
|
|
6
6
|
extendLogicTags: string[];
|
|
7
7
|
};
|
|
8
|
-
export
|
|
8
|
+
export type SettingType = {
|
|
9
9
|
data?: any;
|
|
10
10
|
fieldPath?: FieldPath[];
|
|
11
11
|
};
|
|
12
|
-
export
|
|
12
|
+
export type Expression = {
|
|
13
13
|
type: string;
|
|
14
14
|
settings: SettingType;
|
|
15
15
|
};
|
|
16
16
|
export declare function NewMetadataExpressionField(objectApiName: string, fieldApiName: string): Expression;
|
|
17
17
|
export declare function NewConstantExpressionField(data: UserDataType): Expression;
|
|
18
|
-
export
|
|
18
|
+
export type ExpressionV2 = {
|
|
19
19
|
leftValue: string;
|
|
20
20
|
operator: string;
|
|
21
21
|
rightValue: any;
|
|
@@ -49,10 +49,10 @@ export declare class QueryV2 {
|
|
|
49
49
|
select(fieldApiNames: string[]): QueryV2;
|
|
50
50
|
constructor(objectApiName: string);
|
|
51
51
|
}
|
|
52
|
-
export
|
|
52
|
+
export type logicalRet = {
|
|
53
53
|
logicalExps: LogicalExpression[];
|
|
54
54
|
arithmeticExps: ArithmeticExpression[];
|
|
55
55
|
};
|
|
56
56
|
export declare function logical(exps: (LogicalExpression | Record<string, ArithmeticExpression>)[]): logicalRet;
|
|
57
|
-
export
|
|
57
|
+
export type CriterionV2 = (Record<string, CriterionV2> | ExpressionV2)[];
|
|
58
58
|
export declare function buildCriterionV2(filter: LogicalExpression): CriterionV2;
|
|
@@ -73,18 +73,6 @@ class LogicalExpression {
|
|
|
73
73
|
}
|
|
74
74
|
exports.LogicalExpression = LogicalExpression;
|
|
75
75
|
class QueryV2 {
|
|
76
|
-
constructor(objectApiName) {
|
|
77
|
-
this.objectApiName = objectApiName;
|
|
78
|
-
this._limit = 200;
|
|
79
|
-
this._offset = 0;
|
|
80
|
-
this.fields = [];
|
|
81
|
-
this._order = [];
|
|
82
|
-
this.filter = {
|
|
83
|
-
type: "and",
|
|
84
|
-
arithmeticExpressions: [],
|
|
85
|
-
logicalExpressions: [],
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
76
|
buildCriterion(filter) {
|
|
89
77
|
if (!filter || filter.arithmeticExpressions.length == 0 && filter.logicalExpressions.length == 0) {
|
|
90
78
|
return null;
|
|
@@ -154,6 +142,18 @@ class QueryV2 {
|
|
|
154
142
|
});
|
|
155
143
|
return this;
|
|
156
144
|
}
|
|
145
|
+
constructor(objectApiName) {
|
|
146
|
+
this.objectApiName = objectApiName;
|
|
147
|
+
this._limit = 200;
|
|
148
|
+
this._offset = 0;
|
|
149
|
+
this.fields = [];
|
|
150
|
+
this._order = [];
|
|
151
|
+
this.filter = {
|
|
152
|
+
type: "and",
|
|
153
|
+
arithmeticExpressions: [],
|
|
154
|
+
logicalExpressions: [],
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
157
|
}
|
|
158
158
|
exports.QueryV2 = QueryV2;
|
|
159
159
|
function logical(exps) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@byted-apaas/server-sdk-node",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5-beta.8",
|
|
4
4
|
"description": "aPaaS Server SDK",
|
|
5
5
|
"author": "zhouwexin <zhouwexin@bytedance.com>",
|
|
6
6
|
"homepage": "",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"pre-build": "rm -rf build && tsc"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@byted-apaas/server-common-node": "^1.0.
|
|
15
|
+
"@byted-apaas/server-common-node": "^1.0.7-beta.15",
|
|
16
16
|
"@jorgeferrero/stream-to-buffer": "^2.0.6",
|
|
17
17
|
"dayjs": "^1.9.6",
|
|
18
18
|
"form-data": "^3.0.0",
|
|
@@ -38,5 +38,5 @@
|
|
|
38
38
|
],
|
|
39
39
|
"timeout": 20000
|
|
40
40
|
},
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "265483f5aeb63092eb719f2db49bf22070329227"
|
|
42
42
|
}
|
package/request/innerapi.js
CHANGED
|
@@ -1345,7 +1345,7 @@ async function invokeFuncSync(idOrName, params) {
|
|
|
1345
1345
|
}
|
|
1346
1346
|
param.Params = JSON.stringify(params);
|
|
1347
1347
|
param.Context = JSON.stringify((0, common_1.getTriggerCtx)());
|
|
1348
|
-
param.TriggerType =
|
|
1348
|
+
param.TriggerType = constants_1.triggerType.defaultTrigger;
|
|
1349
1349
|
let resp;
|
|
1350
1350
|
try {
|
|
1351
1351
|
resp = await rpc.getInnerAPICli().InvokeFuncSync(ctx, param);
|
|
@@ -1380,7 +1380,7 @@ async function createAsyncTaskV1(idOrName, params) {
|
|
|
1380
1380
|
}
|
|
1381
1381
|
param.Params = JSON.stringify(params);
|
|
1382
1382
|
param.Context = JSON.stringify((0, common_1.getTriggerCtx)());
|
|
1383
|
-
param.TriggerType =
|
|
1383
|
+
param.TriggerType = constants_1.triggerType.defaultTrigger;
|
|
1384
1384
|
let resp;
|
|
1385
1385
|
try {
|
|
1386
1386
|
resp = await rpc.getInnerAPICli().CreateAsyncTaskOld(ctx, param);
|
|
@@ -1399,7 +1399,7 @@ async function createAsyncTaskV2(APIName, params) {
|
|
|
1399
1399
|
param.APIAlias = APIName;
|
|
1400
1400
|
param.Params = JSON.stringify(params);
|
|
1401
1401
|
param.Context = JSON.stringify((0, common_1.getTriggerCtx)());
|
|
1402
|
-
param.TriggerType =
|
|
1402
|
+
param.TriggerType = constants_1.triggerType.defaultTrigger;
|
|
1403
1403
|
param.Extra = (0, common_1.getDebugExtraInfo)();
|
|
1404
1404
|
let resp;
|
|
1405
1405
|
try {
|
package/request/interface.d.ts
CHANGED
|
@@ -7,19 +7,19 @@ import { AppCtx } from "../application/application";
|
|
|
7
7
|
import { Order } from "../context/db/impl/order";
|
|
8
8
|
export declare function GetInstance(): IInnerAPIRequest;
|
|
9
9
|
export declare function GetFaaSInfraInstance(): IFaaSInfraRequest;
|
|
10
|
-
export
|
|
10
|
+
export type UploadFileResp = {
|
|
11
11
|
id: string;
|
|
12
12
|
token: string;
|
|
13
13
|
size: bigint;
|
|
14
14
|
mimeType: string;
|
|
15
15
|
name: string;
|
|
16
16
|
};
|
|
17
|
-
export
|
|
17
|
+
export type OrderV2 = {
|
|
18
18
|
field: string;
|
|
19
19
|
direction: string;
|
|
20
20
|
type: string;
|
|
21
21
|
};
|
|
22
|
-
export
|
|
22
|
+
export type OpenSDKGetRecordsReq = {
|
|
23
23
|
limit: number;
|
|
24
24
|
offset: number;
|
|
25
25
|
fields: string[];
|
package/request/openapi.js
CHANGED
|
@@ -852,7 +852,7 @@ async function invokeFuncSync(idOrName, params) {
|
|
|
852
852
|
options.json = {
|
|
853
853
|
"params": JSON.stringify(params),
|
|
854
854
|
"context": JSON.stringify(getTriggerCtx()),
|
|
855
|
-
"triggerType":
|
|
855
|
+
"triggerType": constants_1.triggerType.defaultTrigger,
|
|
856
856
|
};
|
|
857
857
|
// 相等时,表示是新版本函数的场景
|
|
858
858
|
if (idOrName.isInvokeByAPIName) {
|
|
@@ -877,7 +877,7 @@ async function createAsyncTaskV1(idOrName, params) {
|
|
|
877
877
|
options.json = {
|
|
878
878
|
"params": JSON.stringify(params),
|
|
879
879
|
"context": JSON.stringify(getTriggerCtx()),
|
|
880
|
-
"triggerType":
|
|
880
|
+
"triggerType": constants_1.triggerType.defaultTrigger,
|
|
881
881
|
};
|
|
882
882
|
// 相等时,表示是新版本函数的场景
|
|
883
883
|
if (idOrName.isInvokeByAPIName) {
|
|
@@ -914,7 +914,7 @@ async function createAsyncTaskV2(APIName, params) {
|
|
|
914
914
|
"apiAlias": APIName,
|
|
915
915
|
"params": JSON.stringify(params),
|
|
916
916
|
"context": JSON.stringify(getTriggerCtx()),
|
|
917
|
-
"triggerType":
|
|
917
|
+
"triggerType": constants_1.triggerType.defaultTrigger,
|
|
918
918
|
"extra": (0, common_1.getDebugExtraInfo)()
|
|
919
919
|
};
|
|
920
920
|
let res = await openapi.doRequest(null, urlPath, options);
|
package/types/types.d.ts
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
|
|
1
|
+
export type _BooleanCond<T> = {};
|
|
2
|
+
export type _LogicalCond<T> = {};
|
|
3
|
+
type _LookupCond = number | {
|
|
4
4
|
_id: number;
|
|
5
5
|
};
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
type _MultiLookupCond = _LookupCond[];
|
|
7
|
+
type PartialCompositeType<T> = Partial<{
|
|
8
8
|
[K in keyof T]: T[K] extends _LookupField[] ? _MultiLookupCond : T[K] extends _LookupField ? _LookupCond : Partial<T[K]>;
|
|
9
9
|
}>;
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
type _FieldCond<T> = T extends _LookupField[] ? _MultiLookupCond : T extends _LookupField ? _LookupCond : PartialCompositeType<T>;
|
|
11
|
+
type _FirstLevelFieldCond<T> = Partial<{
|
|
12
12
|
[K in keyof T]: T[K] extends _LookupField ? _FieldCond<T[K]> : T[K];
|
|
13
13
|
}>;
|
|
14
|
-
|
|
14
|
+
type _KCond<T> = Partial<{
|
|
15
15
|
[K in keyof T]: _FieldCond<T[K]> | _BooleanCond<T[K]> | _LogicalCond<T[K]>;
|
|
16
16
|
}>;
|
|
17
|
-
|
|
17
|
+
type _WhereKCond<T> = Partial<{
|
|
18
18
|
[K in keyof T]: _FirstLevelFieldCond<T[K]> | _BooleanCond<T[K]> | _LogicalCond<T[K]>;
|
|
19
19
|
}>;
|
|
20
|
-
export
|
|
21
|
-
export
|
|
22
|
-
export
|
|
20
|
+
export type _Cond<T> = _KCond<T> | _LogicalCond<Partial<T>>;
|
|
21
|
+
export type _WhereCond<T> = _WhereKCond<T> | _LogicalCond<Partial<T>>;
|
|
22
|
+
export type _Record<T> = {
|
|
23
23
|
[K in keyof T]: T[K] extends _LookupField ? _LookupFieldRet : T[K];
|
|
24
24
|
};
|
|
25
|
-
export
|
|
25
|
+
export type _CondRequireID<T> = _Cond<T> & {
|
|
26
26
|
_id: number;
|
|
27
27
|
};
|
|
28
28
|
interface _LookupFieldRet {
|