@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.
Files changed (64) hide show
  1. package/application/application.js +1 -0
  2. package/application/function/function.js +1 -0
  3. package/application/impl/common.js +1 -0
  4. package/application/impl/impl.js +1 -0
  5. package/constants/constants.js +1 -0
  6. package/context/context.js +1 -0
  7. package/context/db/db.js +1 -0
  8. package/context/db/impl/IObject.d.ts +4 -3
  9. package/context/db/impl/IObject.js +1 -0
  10. package/context/db/impl/db.js +1 -0
  11. package/context/db/impl/object.d.ts +4 -3
  12. package/context/db/impl/object.js +16 -3
  13. package/context/db/impl/oql/ioql.js +1 -0
  14. package/context/db/impl/oql/oql.js +2 -1
  15. package/context/db/impl/order.js +1 -0
  16. package/context/db/impl/propertiesStore.js +1 -0
  17. package/context/db/impl/queryBuilder.js +1 -0
  18. package/context/db/impl/transaction/index.js +6 -1
  19. package/context/db/impl/transaction/operation.js +1 -0
  20. package/context/db/impl/transaction.js +1 -0
  21. package/context/globalConfig/globalConfig.js +1 -0
  22. package/context/integration/IIntegration.js +1 -0
  23. package/context/integration/impl/integration.js +5 -4
  24. package/context/metadata/components/common.js +1 -0
  25. package/context/metadata/components/components.js +1 -0
  26. package/context/metadata/components/desktop/list.js +1 -0
  27. package/context/metadata/components/desktop/recordDetail.js +1 -0
  28. package/context/metadata/components/mobile/list.js +1 -0
  29. package/context/metadata/metadata.js +1 -0
  30. package/context/metadata/objects/fields.js +1 -0
  31. package/context/metadata/objects/fields.util.js +1 -0
  32. package/context/metadata/objects/objects.js +1 -0
  33. package/context/metadata/types/common.js +1 -0
  34. package/context/metadata/types/components.js +1 -0
  35. package/context/metadata/types/objects.js +1 -0
  36. package/context/msg/msg.js +1 -0
  37. package/context/resources/IResources.js +1 -0
  38. package/context/resources/impl/resources.js +1 -0
  39. package/context/tasks/tasks.js +1 -0
  40. package/data/index.js +1 -0
  41. package/global/application/flow/flow.js +1 -0
  42. package/global/application/globalVar/globalVar.js +1 -0
  43. package/global/global.js +1 -0
  44. package/hooks/api.js +1 -0
  45. package/hooks/hooks.js +1 -0
  46. package/kunlun/kunlun.js +1 -0
  47. package/kunlun/operator/IOperator.js +1 -0
  48. package/kunlun/operator/impl/expression.js +1 -0
  49. package/kunlun/operator/impl/logic.js +1 -0
  50. package/kunlun/operator/impl/logicV2.js +1 -0
  51. package/kunlun/operator/impl/operator.js +1 -0
  52. package/kunlun/operator/impl/operatorV2.js +1 -0
  53. package/lib/core.js +1 -0
  54. package/package.json +2 -2
  55. package/request/common.js +1 -0
  56. package/request/constants.js +1 -0
  57. package/request/faasinfra.js +1 -0
  58. package/request/innerapi.d.ts +2 -2
  59. package/request/innerapi.js +30 -4
  60. package/request/interface.d.ts +2 -2
  61. package/request/interface.js +1 -0
  62. package/request/openapi.d.ts +2 -2
  63. package/request/openapi.js +42 -5
  64. package/types/types.js +1 -0
@@ -1,2 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=application.js.map
@@ -18,3 +18,4 @@ class Function {
18
18
  }
19
19
  }
20
20
  exports.Function = Function;
21
+ //# sourceMappingURL=function.js.map
@@ -50,3 +50,4 @@ async function runCtxForOpenSDK(appCtx, promise) {
50
50
  return await promise();
51
51
  }
52
52
  exports.runCtxForOpenSDK = runCtxForOpenSDK;
53
+ //# sourceMappingURL=common.js.map
@@ -43,3 +43,4 @@ class Application {
43
43
  }
44
44
  }
45
45
  exports.Application = Application;
46
+ //# sourceMappingURL=impl.js.map
@@ -16,3 +16,4 @@ exports.httpStatusCodes = {
16
16
  exports.triggerType = {
17
17
  defaultTrigger: 'default-trigger',
18
18
  };
19
+ //# sourceMappingURL=constants.js.map
@@ -23,3 +23,4 @@ class Context extends server_common_node_1.Context {
23
23
  }
24
24
  }
25
25
  exports.Context = Context;
26
+ //# sourceMappingURL=context.js.map
package/context/db/db.js CHANGED
@@ -2,3 +2,4 @@
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
+ //# sourceMappingURL=db.js.map
@@ -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<void>;
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<void>;
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<void>;
89
+ batchUpdate(recordMapList: _Cond<T>[]): Promise<BatchResult>;
89
90
  /**
90
91
  * 用户级鉴权
91
92
  */
@@ -3,3 +3,4 @@
3
3
  // SPDX-License-Identifier: MIT
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
5
  ;
6
+ //# sourceMappingURL=IObject.js.map
@@ -79,3 +79,4 @@ class ApplicationDB {
79
79
  }
80
80
  }
81
81
  exports.ApplicationDB = ApplicationDB;
82
+ //# sourceMappingURL=db.js.map
@@ -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<void>;
36
- batchDelete(recordList: _Cond<T>[]): Promise<void>;
37
- batchUpdate(recordMapList: _Cond<T>[]): Promise<void>;
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
- return await Request.GetInstance().deleteRecordsBySync(this.apiName, recordIDs, this.authType);
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
- return await Request.GetInstance().updateRecordsBySync(this.apiName, recordMap, this.authType);
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
@@ -2,3 +2,4 @@
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
+ //# sourceMappingURL=ioql.js.map
@@ -27,8 +27,9 @@ class Oql {
27
27
  return this;
28
28
  }
29
29
  useUserAuth() {
30
- this.authType = constants_1.AuthTypeUser;
30
+ this.authType = constants_1.AuthTypeMixUserSystem;
31
31
  return this;
32
32
  }
33
33
  }
34
34
  exports.Oql = Oql;
35
+ //# sourceMappingURL=oql.js.map
@@ -13,3 +13,4 @@ class Order {
13
13
  }
14
14
  }
15
15
  exports.Order = Order;
16
+ //# sourceMappingURL=order.js.map
@@ -27,3 +27,4 @@ class PropertiesStore {
27
27
  }
28
28
  }
29
29
  exports.default = PropertiesStore;
30
+ //# sourceMappingURL=propertiesStore.js.map
@@ -70,3 +70,4 @@ class QueryBuilder {
70
70
  }
71
71
  }
72
72
  exports.QueryBuilder = QueryBuilder;
73
+ //# sourceMappingURL=queryBuilder.js.map
@@ -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 = { ...oldRecord };
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
@@ -67,3 +67,4 @@ class BatchUpdateSameValueOperation extends TransactionOperation {
67
67
  }
68
68
  }
69
69
  exports.BatchUpdateSameValueOperation = BatchUpdateSameValueOperation;
70
+ //# sourceMappingURL=operation.js.map
@@ -2,3 +2,4 @@
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
+ //# sourceMappingURL=transaction.js.map
@@ -14,3 +14,4 @@ class GlobalConfig {
14
14
  }
15
15
  }
16
16
  exports.GlobalConfig = GlobalConfig;
17
+ //# sourceMappingURL=globalConfig.js.map
@@ -2,3 +2,4 @@
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
+ //# sourceMappingURL=IIntegration.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.GetHttpInstance().getIntegrationAppAccessToken(apiName);
47
+ return await Request.GetInstance().getIntegrationAppAccessToken(apiName);
48
48
  }
49
49
  async getDefaultAppAccessToken() {
50
- return await Request.GetHttpInstance().getDefaultIntegrationAppAccessToken();
50
+ return await Request.GetInstance().getDefaultIntegrationAppAccessToken();
51
51
  }
52
52
  async getDefaultTenantAccessToken() {
53
- return await Request.GetHttpInstance().getDefaultIntegrationTenantAccessToken();
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.GetHttpInstance().getIntegrationTenantAccessToken(apiName);
59
+ return await Request.GetInstance().getIntegrationTenantAccessToken(apiName);
60
60
  }
61
61
  }
62
62
  exports._Integration = _Integration;
63
+ //# sourceMappingURL=integration.js.map
@@ -15,3 +15,4 @@ class Component {
15
15
  }
16
16
  }
17
17
  exports.Component = Component;
18
+ //# sourceMappingURL=common.js.map
@@ -17,3 +17,4 @@ const mobile = {
17
17
  List: list_2.List,
18
18
  };
19
19
  exports.mobile = mobile;
20
+ //# sourceMappingURL=components.js.map
@@ -400,3 +400,4 @@ function parseConcatenate(element) {
400
400
  }
401
401
  return null;
402
402
  }
403
+ //# sourceMappingURL=list.js.map
@@ -51,3 +51,4 @@ function getSelectedFields(input) {
51
51
  }
52
52
  return selectedFields;
53
53
  }
54
+ //# sourceMappingURL=recordDetail.js.map
@@ -143,3 +143,4 @@ function getFilter(input) {
143
143
  return {};
144
144
  }
145
145
  }
146
+ //# sourceMappingURL=list.js.map
@@ -97,3 +97,4 @@ function metaType() {
97
97
  };
98
98
  }
99
99
  exports.metaType = metaType;
100
+ //# sourceMappingURL=metadata.js.map
@@ -332,3 +332,4 @@ const fieldTypeMap = {
332
332
  'extractSingleRecord': 'compositeType',
333
333
  'richText': 'richText',
334
334
  };
335
+ //# sourceMappingURL=fields.js.map
@@ -317,3 +317,4 @@ function getRecordPosition(field) {
317
317
  return pos;
318
318
  }
319
319
  exports.getRecordPosition = getRecordPosition;
320
+ //# sourceMappingURL=fields.util.js.map
@@ -18,3 +18,4 @@ class Objects {
18
18
  }
19
19
  }
20
20
  exports.Object = Objects;
21
+ //# sourceMappingURL=objects.js.map
@@ -7,3 +7,4 @@ function isNullOrUndefined(param) {
7
7
  return param === null || param === undefined;
8
8
  }
9
9
  exports.isNullOrUndefined = isNullOrUndefined;
10
+ //# sourceMappingURL=common.js.map
@@ -2,3 +2,4 @@
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
+ //# sourceMappingURL=components.js.map
@@ -2,3 +2,4 @@
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
+ //# sourceMappingURL=objects.js.map
@@ -33,3 +33,4 @@ class Message {
33
33
  }
34
34
  }
35
35
  exports.Message = Message;
36
+ //# sourceMappingURL=msg.js.map
@@ -1,2 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=IResources.js.map
@@ -159,3 +159,4 @@ class _Resources {
159
159
  }
160
160
  }
161
161
  exports._Resources = _Resources;
162
+ //# sourceMappingURL=resources.js.map
@@ -137,3 +137,4 @@ class Tasks {
137
137
  ;
138
138
  }
139
139
  exports.Tasks = Tasks;
140
+ //# sourceMappingURL=tasks.js.map
package/data/index.js CHANGED
@@ -2,3 +2,4 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  ;
4
4
  ;
5
+ //# sourceMappingURL=index.js.map
@@ -1,2 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=flow.js.map
@@ -1,2 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=globalVar.js.map
package/global/global.js CHANGED
@@ -1,3 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const common = require("@byted-apaas/server-common-node");
4
+ //# sourceMappingURL=global.js.map
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
@@ -107,3 +107,4 @@ function mountApplication(context) {
107
107
  module.exports = {
108
108
  pre,
109
109
  };
110
+ //# sourceMappingURL=hooks.js.map
package/kunlun/kunlun.js CHANGED
@@ -56,3 +56,4 @@ var kunlun;
56
56
  */
57
57
  kunlun.operator = new operator_1.Operator();
58
58
  })(kunlun = exports.kunlun || (exports.kunlun = {}));
59
+ //# sourceMappingURL=kunlun.js.map
@@ -2,3 +2,4 @@
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
+ //# sourceMappingURL=IOperator.js.map
@@ -54,3 +54,4 @@ class MetadataExpressionField extends ExpressionField {
54
54
  }
55
55
  }
56
56
  exports.MetadataExpressionField = MetadataExpressionField;
57
+ //# sourceMappingURL=expression.js.map
@@ -524,3 +524,4 @@ function dateAdd(date, num) {
524
524
  return date;
525
525
  }
526
526
  }
527
+ //# sourceMappingURL=logic.js.map
@@ -195,3 +195,4 @@ function buildCriterionV2(filter) {
195
195
  return conditions;
196
196
  }
197
197
  exports.buildCriterionV2 = buildCriterionV2;
198
+ //# sourceMappingURL=logicV2.js.map
@@ -220,3 +220,4 @@ class Operator {
220
220
  ;
221
221
  }
222
222
  exports.Operator = Operator;
223
+ //# sourceMappingURL=operator.js.map
@@ -214,3 +214,4 @@ class OperatorV2 {
214
214
  ;
215
215
  }
216
216
  exports.OperatorV2 = OperatorV2;
217
+ //# sourceMappingURL=operatorV2.js.map
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",
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.18",
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
@@ -86,3 +86,4 @@ async function getNamespaceForOpenAndFaaSSDK() {
86
86
  return utils.getNamespaceFromCtx();
87
87
  }
88
88
  exports.getNamespaceForOpenAndFaaSSDK = getNamespaceForOpenAndFaaSSDK;
89
+ //# sourceMappingURL=common.js.map
@@ -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
@@ -146,3 +146,4 @@ function parseQueryParams(path) {
146
146
  }
147
147
  return params;
148
148
  }
149
+ //# sourceMappingURL=faasinfra.js.map
@@ -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): any;
19
- deleteRecordsBySync(objectApiName: string, recordIDs: number[], authType: string): any;
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>;
@@ -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 { err_map: errMap };
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 { err_map: errMap };
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
- return JSON.parse(resp.DataList);
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
- return JSON.parse(resp.Rows ? resp.Rows : '[]');
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
@@ -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) => any;
53
- deleteRecordsBySync: (objectApiName: string, recordIDs: number[], authType: string) => any;
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>;
@@ -39,3 +39,4 @@ function GetFaaSInfraInstance() {
39
39
  return new faasinfra_1.FaaSInfraRequest();
40
40
  }
41
41
  exports.GetFaaSInfraInstance = GetFaaSInfraInstance;
42
+ //# sourceMappingURL=interface.js.map
@@ -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): any;
21
- deleteRecordsBySync(objectApiName: string, recordIDs: number[], authType: string): any;
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>;
@@ -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
- return openapi.doRequest(null, urlPath, options);
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
- return openapi.doRequest(null, urlPath, options);
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
- return data.data_list;
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
@@ -2,3 +2,4 @@
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
+ //# sourceMappingURL=types.js.map