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