@byted-apaas/server-sdk-node 1.1.3-beta.23 → 1.1.3
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.js +0 -1
- package/application/function/function.js +0 -1
- package/application/impl/common.js +0 -1
- package/application/impl/impl.js +0 -1
- package/constants/constants.js +0 -1
- package/context/context.js +0 -1
- package/context/db/db.js +0 -1
- package/context/db/impl/IObject.d.ts +3 -4
- package/context/db/impl/IObject.js +0 -1
- package/context/db/impl/db.js +0 -1
- package/context/db/impl/object.d.ts +3 -4
- package/context/db/impl/object.js +3 -16
- package/context/db/impl/oql/ioql.js +0 -1
- package/context/db/impl/oql/oql.js +1 -2
- package/context/db/impl/order.js +0 -1
- package/context/db/impl/propertiesStore.js +0 -1
- package/context/db/impl/queryBuilder.js +0 -1
- package/context/db/impl/transaction/index.js +1 -6
- package/context/db/impl/transaction/operation.js +0 -1
- package/context/db/impl/transaction.js +0 -1
- package/context/globalConfig/globalConfig.js +0 -1
- package/context/integration/IIntegration.js +0 -1
- package/context/integration/impl/integration.js +4 -5
- package/context/metadata/components/common.js +0 -1
- package/context/metadata/components/components.js +0 -1
- package/context/metadata/components/desktop/list.js +0 -1
- package/context/metadata/components/desktop/recordDetail.js +0 -1
- package/context/metadata/components/mobile/list.js +0 -1
- package/context/metadata/metadata.js +0 -1
- package/context/metadata/objects/fields.js +0 -1
- package/context/metadata/objects/fields.util.js +0 -1
- package/context/metadata/objects/objects.js +0 -1
- package/context/metadata/types/common.js +0 -1
- package/context/metadata/types/components.js +0 -1
- package/context/metadata/types/objects.js +0 -1
- package/context/msg/msg.js +0 -1
- package/context/resources/IResources.js +0 -1
- package/context/resources/impl/resources.js +0 -1
- package/context/tasks/tasks.js +0 -1
- package/data/index.js +0 -1
- package/global/application/flow/flow.js +0 -1
- package/global/application/globalVar/globalVar.js +0 -1
- package/global/global.js +0 -1
- package/hooks/api.js +0 -1
- package/hooks/hooks.js +0 -1
- package/kunlun/kunlun.js +0 -1
- package/kunlun/operator/IOperator.js +0 -1
- package/kunlun/operator/impl/expression.js +0 -1
- package/kunlun/operator/impl/logic.js +0 -1
- package/kunlun/operator/impl/logicV2.js +0 -1
- package/kunlun/operator/impl/operator.js +0 -1
- package/kunlun/operator/impl/operatorV2.js +0 -1
- package/lib/core.js +0 -1
- package/package.json +2 -2
- package/request/common.js +0 -1
- package/request/constants.js +0 -1
- package/request/faasinfra.js +0 -1
- package/request/innerapi.d.ts +2 -2
- package/request/innerapi.js +4 -30
- package/request/interface.d.ts +2 -2
- package/request/interface.js +0 -1
- package/request/openapi.d.ts +2 -2
- package/request/openapi.js +5 -42
- package/types/types.js +0 -1
package/application/impl/impl.js
CHANGED
package/constants/constants.js
CHANGED
package/context/context.js
CHANGED
package/context/db/db.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { _Cond, _Record, _WhereCond } from '../../../types/types';
|
|
2
|
-
import { BatchResult } from "../../../common/structs";
|
|
3
2
|
export interface _IKAllEndpoint<T> extends _IKSyncEndpoint<T>, _IKAsyncEndpoint<T> {
|
|
4
3
|
}
|
|
5
4
|
export interface _IKSyncEndpoint<T> {
|
|
@@ -74,19 +73,19 @@ export interface _IKSyncEndpoint<T> {
|
|
|
74
73
|
* @param recordIdList 多个用于删除的记录 ID 组成的数组
|
|
75
74
|
* @paramExample [1001, 1002, 1003]
|
|
76
75
|
*/
|
|
77
|
-
batchDelete(recordIdList: number[]): Promise<
|
|
76
|
+
batchDelete(recordIdList: number[]): Promise<void>;
|
|
78
77
|
/**
|
|
79
78
|
* 批量删除记录
|
|
80
79
|
* @param recordList 多条用于删除的记录数据组成的数组,记录数据需对 _id 赋值
|
|
81
80
|
* @paramExample [{_id: 1001, _name: 'John', gender: 'male'}, {_id: 1002, _name: 'Alis', gender: 'female'}]
|
|
82
81
|
*/
|
|
83
|
-
batchDelete(recordList: _Cond<T>[]): Promise<
|
|
82
|
+
batchDelete(recordList: _Cond<T>[]): Promise<void>;
|
|
84
83
|
/**
|
|
85
84
|
* 根据 _id 批量更新记录
|
|
86
85
|
* @param recordMapList 多条用于更新的记录数据组成的数组,记录数据需对 _id 赋值
|
|
87
86
|
* @paramExample [{_id: 1001, _name: 'John', gender: 'male'}, {_id: 1002, _name: 'Alis', gender: 'female'}]
|
|
88
87
|
*/
|
|
89
|
-
batchUpdate(recordMapList: _Cond<T>[]): Promise<
|
|
88
|
+
batchUpdate(recordMapList: _Cond<T>[]): Promise<void>;
|
|
90
89
|
/**
|
|
91
90
|
* 用户级鉴权
|
|
92
91
|
*/
|
package/context/db/impl/db.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { _Cond, _Record, _WhereCond } from '../../../types/types';
|
|
2
2
|
import { _IKAsyncEndpoint, _IKQuery, _IKSyncEndpoint } from './IObject';
|
|
3
3
|
import { AppCtx } from '../../../application/application';
|
|
4
|
-
import { BatchResult } from "../../../common/structs";
|
|
5
4
|
/**
|
|
6
5
|
* _KObject is kunlun object, every method new a _KQuery object to deal.
|
|
7
6
|
*/
|
|
@@ -33,9 +32,9 @@ declare class _KObjectSync<T> implements _IKSyncEndpoint<T> {
|
|
|
33
32
|
update(_id: number, recordMap: _Cond<T>): Promise<void>;
|
|
34
33
|
update(recordMap: _Cond<T>): Promise<void>;
|
|
35
34
|
batchCreate(recordMapList: _Cond<T>[]): Promise<number[]>;
|
|
36
|
-
batchDelete(recordIdList: number[]): Promise<
|
|
37
|
-
batchDelete(recordList: _Cond<T>[]): Promise<
|
|
38
|
-
batchUpdate(recordMapList: _Cond<T>[]): Promise<
|
|
35
|
+
batchDelete(recordIdList: number[]): Promise<void>;
|
|
36
|
+
batchDelete(recordList: _Cond<T>[]): Promise<void>;
|
|
37
|
+
batchUpdate(recordMapList: _Cond<T>[]): Promise<void>;
|
|
39
38
|
useUserAuth(): this;
|
|
40
39
|
useSystemAuth(): this;
|
|
41
40
|
}
|
|
@@ -13,8 +13,6 @@ const common_1 = require("../../../application/impl/common");
|
|
|
13
13
|
const logicV2_1 = require("../../../kunlun/operator/impl/logicV2");
|
|
14
14
|
const operator_1 = require("../../../kunlun/operator/impl/operator");
|
|
15
15
|
const constants_1 = require("@byted-apaas/server-common-node/constants/constants");
|
|
16
|
-
const permissionUtils = require("@byted-apaas/server-common-node/utils/permissionUtils");
|
|
17
|
-
const structs_1 = require("../../../common/structs");
|
|
18
16
|
const queryPropertiesStore = new propertiesStore_1.default();
|
|
19
17
|
// _KObject will be Mixin with [_KObjectSync, _KObjectAsync, _KObjectQuery]
|
|
20
18
|
class _KObject {
|
|
@@ -49,7 +47,6 @@ class _KObjectSync {
|
|
|
49
47
|
if (server_common_node_1.checkUtils.isNotObject(recordMap)) {
|
|
50
48
|
throw new server_common_node_1.exceptions.InvalidParamError('record is not object');
|
|
51
49
|
}
|
|
52
|
-
recordMap = permissionUtils.delUnauthField(recordMap).newRecord;
|
|
53
50
|
if (this.appCtx && this.appCtx.mode == 'openSDK') {
|
|
54
51
|
// request from OpenSDK
|
|
55
52
|
return await (0, common_1.runCtxForOpenSDK)(this.appCtx, async () => {
|
|
@@ -109,7 +106,6 @@ class _KObjectSync {
|
|
|
109
106
|
if (!record) {
|
|
110
107
|
throw new server_common_node_1.exceptions.InvalidParamError('param is empty');
|
|
111
108
|
}
|
|
112
|
-
record = permissionUtils.delUnauthField(record).newRecord;
|
|
113
109
|
let recordID = record['_id'];
|
|
114
110
|
if (recordID <= 0) {
|
|
115
111
|
throw new server_common_node_1.exceptions.InvalidParamError('record._id must greater than 0');
|
|
@@ -137,7 +133,6 @@ class _KObjectSync {
|
|
|
137
133
|
throw new server_common_node_1.exceptions.InvalidParamError('record is not object');
|
|
138
134
|
}
|
|
139
135
|
}
|
|
140
|
-
recordMapList = permissionUtils.batchDelUnauthField(recordMapList).newRecords;
|
|
141
136
|
let data = (this.appCtx && this.appCtx.mode == 'openSDK') ?
|
|
142
137
|
await (0, common_1.runCtxForOpenSDK)(this.appCtx, async () => {
|
|
143
138
|
return await Request.GetInstance().openSDKCreateRecordsBySync(this.apiName, recordMapList);
|
|
@@ -175,8 +170,7 @@ class _KObjectSync {
|
|
|
175
170
|
return await Request.GetInstance().openSDKDeleteRecordsBySync(this.apiName, recordIDs);
|
|
176
171
|
});
|
|
177
172
|
}
|
|
178
|
-
|
|
179
|
-
return (0, structs_1.NewBatchResult)(recordIDs, errMap);
|
|
173
|
+
return await Request.GetInstance().deleteRecordsBySync(this.apiName, recordIDs, this.authType);
|
|
180
174
|
}
|
|
181
175
|
async batchUpdate(recordMapList) {
|
|
182
176
|
// 参数校验、组装
|
|
@@ -186,8 +180,6 @@ class _KObjectSync {
|
|
|
186
180
|
if (!(recordMapList instanceof Array) || recordMapList.length === 0) {
|
|
187
181
|
throw new server_common_node_1.exceptions.InvalidParamError('param records is not an array or an empty array');
|
|
188
182
|
}
|
|
189
|
-
recordMapList = permissionUtils.batchDelUnauthField(recordMapList).newRecords;
|
|
190
|
-
const recordIDs = [];
|
|
191
183
|
let recordMap = {};
|
|
192
184
|
for (let record of recordMapList) {
|
|
193
185
|
let recordID = record['_id'];
|
|
@@ -195,7 +187,6 @@ class _KObjectSync {
|
|
|
195
187
|
throw new server_common_node_1.exceptions.InvalidParamError('record._id is empty');
|
|
196
188
|
}
|
|
197
189
|
recordMap[recordID] = record;
|
|
198
|
-
recordIDs.push(recordID);
|
|
199
190
|
}
|
|
200
191
|
if (this.appCtx && this.appCtx.mode == 'openSDK') {
|
|
201
192
|
// request from OpenSDK
|
|
@@ -203,8 +194,7 @@ class _KObjectSync {
|
|
|
203
194
|
return await Request.GetInstance().openSDKUpdateRecordsBySync(this.apiName, recordMapList);
|
|
204
195
|
});
|
|
205
196
|
}
|
|
206
|
-
|
|
207
|
-
return (0, structs_1.NewBatchResult)(recordIDs, errMap);
|
|
197
|
+
return await Request.GetInstance().updateRecordsBySync(this.apiName, recordMap, this.authType);
|
|
208
198
|
}
|
|
209
199
|
;
|
|
210
200
|
useUserAuth() {
|
|
@@ -240,7 +230,6 @@ class _KObjectAsync {
|
|
|
240
230
|
if (server_common_node_1.utils.stringify(recordMapList).length > 50 * 1024 * 1024) {
|
|
241
231
|
throw new server_common_node_1.exceptions.InvalidParamError('parameter records size exceeds 50MB');
|
|
242
232
|
}
|
|
243
|
-
recordMapList = permissionUtils.batchDelUnauthField(recordMapList).newRecords;
|
|
244
233
|
return await Request.GetInstance().createRecordsByAsync(this.apiName, recordMapList, this.authType);
|
|
245
234
|
}
|
|
246
235
|
;
|
|
@@ -283,7 +272,6 @@ class _KObjectAsync {
|
|
|
283
272
|
if (recordMapList.length > 1000) {
|
|
284
273
|
throw new server_common_node_1.exceptions.InvalidParamError('more than 1000 records in one operation');
|
|
285
274
|
}
|
|
286
|
-
recordMapList = permissionUtils.batchDelUnauthField(recordMapList).newRecords;
|
|
287
275
|
let recordMap = {};
|
|
288
276
|
for (let record of recordMapList) {
|
|
289
277
|
let recordID = record['_id'];
|
|
@@ -774,5 +762,4 @@ function applyMixins(derivedCtor, constructors) {
|
|
|
774
762
|
});
|
|
775
763
|
}
|
|
776
764
|
applyMixins(_KObject, [_KObjectSync, _KObjectAsync, _KObjectQuery]);
|
|
777
|
-
applyMixins(_KApplicationObject, [_KObjectSync, _KObjectQuery]);
|
|
778
|
-
//# sourceMappingURL=object.js.map
|
|
765
|
+
applyMixins(_KApplicationObject, [_KObjectSync, _KObjectQuery]);
|
package/context/db/impl/order.js
CHANGED
|
@@ -7,7 +7,6 @@ const server_common_node_1 = require("@byted-apaas/server-common-node");
|
|
|
7
7
|
const Request = require("../../../../request/interface");
|
|
8
8
|
const operation_1 = require("./operation");
|
|
9
9
|
const constants_1 = require("@byted-apaas/server-common-node/constants/constants");
|
|
10
|
-
const permissionUtils = require("@byted-apaas/server-common-node/utils/permissionUtils");
|
|
11
10
|
const assert = require('assert');
|
|
12
11
|
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
13
12
|
const { v4: uuidv4 } = require('uuid'); //nolint:byted_s_ts_no_require_imports
|
|
@@ -45,7 +44,7 @@ class Transaction {
|
|
|
45
44
|
if (server_common_node_1.checkUtils.isNotObject(oldRecord)) {
|
|
46
45
|
throw new server_common_node_1.exceptions.InvalidParamError('record is not object');
|
|
47
46
|
}
|
|
48
|
-
let record =
|
|
47
|
+
let record = { ...oldRecord };
|
|
49
48
|
let uuid = uuidv4();
|
|
50
49
|
let result = { _id: uuid };
|
|
51
50
|
record._id = uuid;
|
|
@@ -71,7 +70,6 @@ class Transaction {
|
|
|
71
70
|
if (!recordMap) {
|
|
72
71
|
throw new server_common_node_1.exceptions.InvalidParamError('record is empty');
|
|
73
72
|
}
|
|
74
|
-
recordMap = permissionUtils.delUnauthField(recordMap).newRecord;
|
|
75
73
|
const recordID = recordMap._id;
|
|
76
74
|
if (!recordID) {
|
|
77
75
|
throw new server_common_node_1.exceptions.InvalidParamError('record._id is empty');
|
|
@@ -118,7 +116,6 @@ class Transaction {
|
|
|
118
116
|
if (recordMaps.length < 1) {
|
|
119
117
|
return [];
|
|
120
118
|
}
|
|
121
|
-
recordMaps = permissionUtils.batchDelUnauthField(recordMaps).newRecords;
|
|
122
119
|
let result = [];
|
|
123
120
|
let records = [];
|
|
124
121
|
for (let oldRecord of recordMaps) {
|
|
@@ -146,7 +143,6 @@ class Transaction {
|
|
|
146
143
|
if (recordMaps.length < 1) {
|
|
147
144
|
return;
|
|
148
145
|
}
|
|
149
|
-
recordMaps = permissionUtils.batchDelUnauthField(recordMaps).newRecords;
|
|
150
146
|
// 判断同字段同值更新标志
|
|
151
147
|
let isSameValue = true;
|
|
152
148
|
let ids = [];
|
|
@@ -289,4 +285,3 @@ function deepEqual(left, right) {
|
|
|
289
285
|
}
|
|
290
286
|
return true;
|
|
291
287
|
}
|
|
292
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -44,20 +44,19 @@ class _Integration {
|
|
|
44
44
|
if (!apiName) {
|
|
45
45
|
throw new exceptions.InvalidParamError(`apiName is null`);
|
|
46
46
|
}
|
|
47
|
-
return await Request.
|
|
47
|
+
return await Request.GetHttpInstance().getIntegrationAppAccessToken(apiName);
|
|
48
48
|
}
|
|
49
49
|
async getDefaultAppAccessToken() {
|
|
50
|
-
return await Request.
|
|
50
|
+
return await Request.GetHttpInstance().getDefaultIntegrationAppAccessToken();
|
|
51
51
|
}
|
|
52
52
|
async getDefaultTenantAccessToken() {
|
|
53
|
-
return await Request.
|
|
53
|
+
return await Request.GetHttpInstance().getDefaultIntegrationTenantAccessToken();
|
|
54
54
|
}
|
|
55
55
|
async getTenantAccessToken(apiName) {
|
|
56
56
|
if (!apiName) {
|
|
57
57
|
throw new exceptions.InvalidParamError(`apiName is null`);
|
|
58
58
|
}
|
|
59
|
-
return await Request.
|
|
59
|
+
return await Request.GetHttpInstance().getIntegrationTenantAccessToken(apiName);
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
exports._Integration = _Integration;
|
|
63
|
-
//# sourceMappingURL=integration.js.map
|
package/context/msg/msg.js
CHANGED
package/context/tasks/tasks.js
CHANGED
package/data/index.js
CHANGED
package/global/global.js
CHANGED
package/hooks/api.js
CHANGED
|
@@ -345,4 +345,3 @@ exports.workflow = {
|
|
|
345
345
|
exports.metaData = new metadata_1.MetaData(null);
|
|
346
346
|
var impl_1 = require("../application/impl/impl");
|
|
347
347
|
Object.defineProperty(exports, "Application", { enumerable: true, get: function () { return impl_1.Application; } });
|
|
348
|
-
//# sourceMappingURL=api.js.map
|
package/hooks/hooks.js
CHANGED
package/kunlun/kunlun.js
CHANGED
package/lib/core.js
CHANGED
|
@@ -17,4 +17,3 @@ Object.defineProperty(exports, "microservice", { enumerable: true, get: function
|
|
|
17
17
|
Object.defineProperty(exports, "workflow", { enumerable: true, get: function () { return api_1.workflow; } });
|
|
18
18
|
Object.defineProperty(exports, "metaData", { enumerable: true, get: function () { return api_1.metaData; } });
|
|
19
19
|
Object.defineProperty(exports, "Application", { enumerable: true, get: function () { return api_1.Application; } });
|
|
20
|
-
//# sourceMappingURL=core.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@byted-apaas/server-sdk-node",
|
|
3
|
-
"version": "1.1.3
|
|
3
|
+
"version": "1.1.3",
|
|
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.18",
|
|
16
16
|
"@jorgeferrero/stream-to-buffer": "^2.0.6",
|
|
17
17
|
"dayjs": "^1.9.6",
|
|
18
18
|
"form-data": "^3.0.0",
|
package/request/common.js
CHANGED
package/request/constants.js
CHANGED
|
@@ -23,4 +23,3 @@ exports.openapiHttpPath = {
|
|
|
23
23
|
revokeExecution: new config_1.PostHttpConfig(`/api/flow/v1/namespaces/${constants_1.replaceKeys.namespace}/executions/${constants_1.replaceKeys.id}/revoke`, exports.metricsMethodKeys.revokeExecution),
|
|
24
24
|
getExecutionInfo: new config_1.GetHttpConfig(`/api/flow/v1/namespaces/${constants_1.replaceKeys.namespace}/executions/${constants_1.replaceKeys.id}/detail`, exports.metricsMethodKeys.getExecutionInfo),
|
|
25
25
|
};
|
|
26
|
-
//# sourceMappingURL=constants.js.map
|
package/request/faasinfra.js
CHANGED
package/request/innerapi.d.ts
CHANGED
|
@@ -15,8 +15,8 @@ export declare class RequestRpc implements IInnerAPIRequest {
|
|
|
15
15
|
updateRecordsByAsync(objectApiName: string, recordMap: Record<number, object>, authType: string): any;
|
|
16
16
|
deleteRecordsByAsync(objectApiName: string, recordIDs: number[], authType: string): any;
|
|
17
17
|
createRecordsBySync(objectApiName: string, records: object[], authType: string): any;
|
|
18
|
-
updateRecordsBySync(objectApiName: string, recordMap: Record<number, object>, authType: string):
|
|
19
|
-
deleteRecordsBySync(objectApiName: string, recordIDs: number[], authType: string):
|
|
18
|
+
updateRecordsBySync(objectApiName: string, recordMap: Record<number, object>, authType: string): any;
|
|
19
|
+
deleteRecordsBySync(objectApiName: string, recordIDs: number[], authType: string): any;
|
|
20
20
|
getRecordsOrCountByCriterion(objectApiName: string, criterion: string | Criterion, fuzzySearch: any, order: Order[], ignoreBackLookupField: boolean, fieldApiNames: string[], offset: number, limit: number, needCount: boolean, authType: string): any;
|
|
21
21
|
updateWorkflowVariables(ctx: any, instanceId: number, variables: object, variableTypes: object): Promise<void>;
|
|
22
22
|
uploadFile(data: Stream, expire: number): Promise<UploadFileResp>;
|
package/request/innerapi.js
CHANGED
|
@@ -10,8 +10,6 @@ const common_1 = require("./common");
|
|
|
10
10
|
const exceptions_1 = require("@byted-apaas/server-common-node/utils/exceptions");
|
|
11
11
|
const fs = require("fs");
|
|
12
12
|
const path = require("path");
|
|
13
|
-
const permissionUtils = require("@byted-apaas/server-common-node/utils/permissionUtils");
|
|
14
|
-
const constants_2 = require("@byted-apaas/server-common-node/constants/constants");
|
|
15
13
|
const rpc = common.rpc;
|
|
16
14
|
const exceptions = common.exceptions;
|
|
17
15
|
const utils = common.utils;
|
|
@@ -289,14 +287,11 @@ async function updateRecordsBySync(objectApiName, recordMap, authType) {
|
|
|
289
287
|
}
|
|
290
288
|
// 5.后置处理
|
|
291
289
|
post(resp.BaseResp);
|
|
292
|
-
if (!resp || !resp.ErrMap) {
|
|
293
|
-
return undefined;
|
|
294
|
-
}
|
|
295
290
|
const errMap = {};
|
|
296
291
|
resp.ErrMap.forEach((v, k) => {
|
|
297
292
|
errMap[Number(k)] = v;
|
|
298
293
|
});
|
|
299
|
-
return errMap;
|
|
294
|
+
return { err_map: errMap };
|
|
300
295
|
}
|
|
301
296
|
async function deleteRecordsBySync(objectApiName, recordIDs, authType) {
|
|
302
297
|
// 1.check
|
|
@@ -330,14 +325,11 @@ async function deleteRecordsBySync(objectApiName, recordIDs, authType) {
|
|
|
330
325
|
}
|
|
331
326
|
// 5.后置处理
|
|
332
327
|
post(resp.BaseResp);
|
|
333
|
-
if (!resp || !resp.ErrMap) {
|
|
334
|
-
return undefined;
|
|
335
|
-
}
|
|
336
328
|
const errMap = {};
|
|
337
329
|
resp.ErrMap.forEach((v, k) => {
|
|
338
330
|
errMap[Number(k)] = v;
|
|
339
331
|
});
|
|
340
|
-
return errMap;
|
|
332
|
+
return { err_map: errMap };
|
|
341
333
|
}
|
|
342
334
|
async function getRecordsOrCountByCriterion(objectApiName, criterion, fuzzySearch, order, ignoreBackLookupField, fieldApiNames, offset, limit, needCount, authType) {
|
|
343
335
|
// 1.check
|
|
@@ -367,11 +359,6 @@ async function getRecordsOrCountByCriterion(objectApiName, criterion, fuzzySearc
|
|
|
367
359
|
param.NeedFilterUserPermission = false;
|
|
368
360
|
param.NeedTotalCount = needCount;
|
|
369
361
|
param.FuzzySearch = fuzzySearch;
|
|
370
|
-
// 只返回 slice 结果,使用 SliceResult
|
|
371
|
-
// 只返回 map 结果,使用 MapResult
|
|
372
|
-
// 分不清场景可以用 BothResult,性能较差,建议区分场景
|
|
373
|
-
// 0 表示不返回 unauth field 任何数据; 1 表示两者都返回;2 表示仅返回 slice;3 表示仅返回 map
|
|
374
|
-
param.ProcessAuthFieldType = 2;
|
|
375
362
|
// 4.发起请求
|
|
376
363
|
let resp;
|
|
377
364
|
try {
|
|
@@ -386,11 +373,7 @@ async function getRecordsOrCountByCriterion(objectApiName, criterion, fuzzySearc
|
|
|
386
373
|
return Number(resp.Total);
|
|
387
374
|
}
|
|
388
375
|
else {
|
|
389
|
-
|
|
390
|
-
if (resp.UnauthPermissionInfo && resp.UnauthPermissionInfo.unauth_field_slice) {
|
|
391
|
-
permissionUtils.appendUnauthFieldRecordList(objectApiName, records, resp.UnauthPermissionInfo.unauth_field_slice, true);
|
|
392
|
-
}
|
|
393
|
-
return records;
|
|
376
|
+
return JSON.parse(resp.DataList);
|
|
394
377
|
}
|
|
395
378
|
}
|
|
396
379
|
async function updateWorkflowVariables(iCtx, instanceId, variables, variableTypes) {
|
|
@@ -804,16 +787,12 @@ async function oql(oql, args, namedArgs, authType) {
|
|
|
804
787
|
args,
|
|
805
788
|
namedArgs,
|
|
806
789
|
'compat': true,
|
|
807
|
-
'unauthFields': true,
|
|
808
790
|
});
|
|
809
791
|
// 2. prepare args
|
|
810
792
|
let param = {};
|
|
811
793
|
param.Namespace = await (0, common_1.getNamespaceForOpenAndFaaSSDK)();
|
|
812
794
|
param.QueryData = Buffer.from(queryData);
|
|
813
795
|
// 3. prepare request
|
|
814
|
-
if (authType === constants_2.AuthTypeUser) {
|
|
815
|
-
authType = constants_2.AuthTypeMixUserSystem;
|
|
816
|
-
}
|
|
817
796
|
let ctx = await pre(true, authType);
|
|
818
797
|
// 4. do request
|
|
819
798
|
let resp;
|
|
@@ -826,9 +805,7 @@ async function oql(oql, args, namedArgs, authType) {
|
|
|
826
805
|
// 5. deal with response
|
|
827
806
|
post(resp.BaseResp);
|
|
828
807
|
try {
|
|
829
|
-
|
|
830
|
-
permissionUtils.appendUnauthFieldRecordList("", records, resp.UnauthFieldSlice, true);
|
|
831
|
-
return records;
|
|
808
|
+
return JSON.parse(resp.Rows ? resp.Rows : '[]');
|
|
832
809
|
}
|
|
833
810
|
catch (e) {
|
|
834
811
|
throw new exceptions.InternalError(`oql result parse failed: ${e.message}`);
|
|
@@ -1136,10 +1113,8 @@ class RequestRpc {
|
|
|
1136
1113
|
createRecordsBySync(objectApiName, records, authType) {
|
|
1137
1114
|
}
|
|
1138
1115
|
updateRecordsBySync(objectApiName, recordMap, authType) {
|
|
1139
|
-
return undefined;
|
|
1140
1116
|
}
|
|
1141
1117
|
deleteRecordsBySync(objectApiName, recordIDs, authType) {
|
|
1142
|
-
return undefined;
|
|
1143
1118
|
}
|
|
1144
1119
|
getRecordsOrCountByCriterion(objectApiName, criterion, fuzzySearch, order, ignoreBackLookupField, fieldApiNames, offset, limit, needCount, authType) {
|
|
1145
1120
|
}
|
|
@@ -1578,4 +1553,3 @@ async function getDefaultIntegrationTenantAccessToken() {
|
|
|
1578
1553
|
appId: resp.AppID ? resp.AppID : undefined,
|
|
1579
1554
|
};
|
|
1580
1555
|
}
|
|
1581
|
-
//# sourceMappingURL=innerapi.js.map
|
package/request/interface.d.ts
CHANGED
|
@@ -49,8 +49,8 @@ export interface IInnerAPIBaseRequest {
|
|
|
49
49
|
updateRecordsByAsync: (objectApiName: string, recordMap: Record<number, object>, authType: string) => any;
|
|
50
50
|
deleteRecordsByAsync: (objectApiName: string, recordIDs: number[], authType: string) => any;
|
|
51
51
|
createRecordsBySync: (objectApiName: string, records: object[], authType: string) => any;
|
|
52
|
-
updateRecordsBySync: (objectApiName: string, recordMap: Record<number, object>, authType: string) =>
|
|
53
|
-
deleteRecordsBySync: (objectApiName: string, recordIDs: number[], authType: string) =>
|
|
52
|
+
updateRecordsBySync: (objectApiName: string, recordMap: Record<number, object>, authType: string) => any;
|
|
53
|
+
deleteRecordsBySync: (objectApiName: string, recordIDs: number[], authType: string) => any;
|
|
54
54
|
getRecordsOrCountByCriterion: (objectApiName: string, criterion: string | Criterion, fuzzySearch: any, order: Order[], ignoreBackLookupField: boolean, fieldApiNames: string[], offset: number, limit: number, needCount: boolean, authType: string) => any;
|
|
55
55
|
updateWorkflowVariables: (ctx: any, instanceId: number, variables: object, variableTypes: object) => Promise<void>;
|
|
56
56
|
uploadFile: (data: Stream, expire: number) => Promise<UploadFileResp>;
|
package/request/interface.js
CHANGED
package/request/openapi.d.ts
CHANGED
|
@@ -17,8 +17,8 @@ export declare class RequestHttp implements IInnerAPIRequest {
|
|
|
17
17
|
updateRecordsByAsync(objectApiName: string, recordMap: Record<number, object>, authType: string): any;
|
|
18
18
|
deleteRecordsByAsync(objectApiName: string, recordIDs: number[], authType: string): any;
|
|
19
19
|
createRecordsBySync(objectApiName: string, records: object[], authType: string): any;
|
|
20
|
-
updateRecordsBySync(objectApiName: string, recordMap: Record<number, object>, authType: string):
|
|
21
|
-
deleteRecordsBySync(objectApiName: string, recordIDs: number[], authType: string):
|
|
20
|
+
updateRecordsBySync(objectApiName: string, recordMap: Record<number, object>, authType: string): any;
|
|
21
|
+
deleteRecordsBySync(objectApiName: string, recordIDs: number[], authType: string): any;
|
|
22
22
|
getRecordsOrCountByCriterion(objectApiName: string, criterion: string | Criterion, order: Order[], fuzzySearch: any, ignoreBackLookupField: boolean, fieldApiNames: string[], offset: number, limit: number, needCount: boolean, authType: string): any;
|
|
23
23
|
uploadFile(data: Stream, expire: number): Promise<UploadFileResp>;
|
|
24
24
|
downloadFileByID(fileID: string, filePath?: string): Promise<undefined | Buffer>;
|
package/request/openapi.js
CHANGED
|
@@ -10,7 +10,6 @@ const constants_2 = require("./constants");
|
|
|
10
10
|
const constants_3 = require("@byted-apaas/server-common-node/constants/constants");
|
|
11
11
|
const common_1 = require("./common");
|
|
12
12
|
const utils_1 = require("@byted-apaas/server-common-node/utils/utils");
|
|
13
|
-
const permissionUtils = require("@byted-apaas/server-common-node/utils/permissionUtils");
|
|
14
13
|
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
15
14
|
const nodeCls = require('node-cls'); //nolint:byted_s_ts_no_require_imports
|
|
16
15
|
const fs = require('fs');
|
|
@@ -224,15 +223,7 @@ async function updateRecordsBySync(objectApiName, recordMap, authType) {
|
|
|
224
223
|
if (task_id) {
|
|
225
224
|
options.json.automation_task_id = task_id;
|
|
226
225
|
}
|
|
227
|
-
|
|
228
|
-
if (!resp || !resp.err_map) {
|
|
229
|
-
return undefined;
|
|
230
|
-
}
|
|
231
|
-
const errMap = {};
|
|
232
|
-
for (let recordID of Object.keys(resp.err_map)) {
|
|
233
|
-
errMap[Number(recordID)] = resp.err_map[recordID];
|
|
234
|
-
}
|
|
235
|
-
return errMap;
|
|
226
|
+
return openapi.doRequest(null, urlPath, options);
|
|
236
227
|
}
|
|
237
228
|
async function deleteRecordsBySync(objectApiName, recordIDs, authType) {
|
|
238
229
|
// 1.获取 options
|
|
@@ -254,17 +245,9 @@ async function deleteRecordsBySync(objectApiName, recordIDs, authType) {
|
|
|
254
245
|
if (task_id) {
|
|
255
246
|
options.json.automation_task_id = task_id;
|
|
256
247
|
}
|
|
257
|
-
|
|
258
|
-
if (!resp || !resp.err_map) {
|
|
259
|
-
return undefined;
|
|
260
|
-
}
|
|
261
|
-
const errMap = {};
|
|
262
|
-
for (let recordID of Object.keys(resp.err_map)) {
|
|
263
|
-
errMap[Number(recordID)] = resp.err_map[recordID];
|
|
264
|
-
}
|
|
265
|
-
return errMap;
|
|
248
|
+
return openapi.doRequest(null, urlPath, options);
|
|
266
249
|
}
|
|
267
|
-
function handleResponse(
|
|
250
|
+
function handleResponse(data, needCount) {
|
|
268
251
|
// 返回数据的特殊处理
|
|
269
252
|
if (needCount) {
|
|
270
253
|
if (checkUtils.isObject(data) && data.total) {
|
|
@@ -274,11 +257,7 @@ function handleResponse(objectAPIName, data, needCount) {
|
|
|
274
257
|
}
|
|
275
258
|
else {
|
|
276
259
|
if (checkUtils.isObject(data) && data.data_list) {
|
|
277
|
-
|
|
278
|
-
if (data.unauthPermissionInfo && data.unauthPermissionInfo.UnauthFieldSlice) {
|
|
279
|
-
permissionUtils.appendUnauthFieldRecordList(objectAPIName, records, data.unauthPermissionInfo.UnauthFieldSlice, true);
|
|
280
|
-
}
|
|
281
|
-
return records;
|
|
260
|
+
return data.data_list;
|
|
282
261
|
}
|
|
283
262
|
return [];
|
|
284
263
|
}
|
|
@@ -303,11 +282,6 @@ async function getRecordsOrCountByCriterion(objectApiName, criterion, fuzzySearc
|
|
|
303
282
|
'need_filter_user_permission': false,
|
|
304
283
|
'need_total_count': needCount,
|
|
305
284
|
fuzzySearch,
|
|
306
|
-
// 只返回 slice 结果,使用 SliceResult
|
|
307
|
-
// 只返回 map 结果,使用 MapResult
|
|
308
|
-
// 分不清场景可以用 BothResult,性能较差,建议区分场景
|
|
309
|
-
// 0 表示不返回 unauth field 任何数据; 1 表示两者都返回;2 表示仅返回 slice;3 表示仅返回 map
|
|
310
|
-
'process_auth_field_type': 2,
|
|
311
285
|
};
|
|
312
286
|
authType = (0, utils_1.formatAuthType)(authType);
|
|
313
287
|
options.headers.User = String(utils.getUserIDFromCtx());
|
|
@@ -315,7 +289,7 @@ async function getRecordsOrCountByCriterion(objectApiName, criterion, fuzzySearc
|
|
|
315
289
|
options.headers[constants_3.AuthTypeHttpHeader] = authType;
|
|
316
290
|
}
|
|
317
291
|
let data = await openapi.doRequest(null, urlPath, options);
|
|
318
|
-
return handleResponse(
|
|
292
|
+
return handleResponse(data, needCount);
|
|
319
293
|
}
|
|
320
294
|
/**
|
|
321
295
|
* 上传文件
|
|
@@ -625,22 +599,14 @@ async function oql(oql, args, namedArgs, authType) {
|
|
|
625
599
|
args,
|
|
626
600
|
namedArgs,
|
|
627
601
|
'compat': true,
|
|
628
|
-
variable: {
|
|
629
|
-
unauth_fields: true,
|
|
630
|
-
},
|
|
631
602
|
};
|
|
632
603
|
authType = (0, utils_1.formatAuthType)(authType);
|
|
633
604
|
options.headers.User = String(utils.getUserIDFromCtx());
|
|
634
605
|
if (authType) {
|
|
635
|
-
if (authType === constants_3.AuthTypeUser) {
|
|
636
|
-
// select 鉴权,where、groupBy、orderBy 不鉴权
|
|
637
|
-
authType = constants_3.AuthTypeMixUserSystem;
|
|
638
|
-
}
|
|
639
606
|
options.headers[constants_3.AuthTypeHttpHeader] = authType;
|
|
640
607
|
}
|
|
641
608
|
let result = await openapi.doRequest(null, urlPath, options);
|
|
642
609
|
if (result && result.rows) {
|
|
643
|
-
permissionUtils.appendUnauthFieldRecordList("", result.rows, result.unauth_field_slice, true);
|
|
644
610
|
return result.rows;
|
|
645
611
|
}
|
|
646
612
|
return [];
|
|
@@ -825,10 +791,8 @@ class RequestHttp {
|
|
|
825
791
|
createRecordsBySync(objectApiName, records, authType) {
|
|
826
792
|
}
|
|
827
793
|
updateRecordsBySync(objectApiName, recordMap, authType) {
|
|
828
|
-
return undefined;
|
|
829
794
|
}
|
|
830
795
|
deleteRecordsBySync(objectApiName, recordIDs, authType) {
|
|
831
|
-
return undefined;
|
|
832
796
|
}
|
|
833
797
|
getRecordsOrCountByCriterion(objectApiName, criterion, order, fuzzySearch, ignoreBackLookupField, fieldApiNames, offset, limit, needCount, authType) {
|
|
834
798
|
}
|
|
@@ -1186,4 +1150,3 @@ async function getDefaultIntegrationTenantAccessToken() {
|
|
|
1186
1150
|
appId: res.appId,
|
|
1187
1151
|
};
|
|
1188
1152
|
}
|
|
1189
|
-
//# sourceMappingURL=openapi.js.map
|
package/types/types.js
CHANGED