@byted-apaas/server-sdk-node 1.0.16 → 1.1.0-beta.11

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 (88) hide show
  1. package/README.md +22 -0
  2. package/application/application.d.ts +9 -7
  3. package/application/function/function.d.ts +1 -1
  4. package/application/function/function.js +0 -1
  5. package/application/impl/common.d.ts +1 -1
  6. package/application/impl/common.js +13 -12
  7. package/application/impl/impl.d.ts +8 -6
  8. package/application/impl/impl.js +6 -4
  9. package/common/structs.d.ts +15 -0
  10. package/common/structs.js +21 -0
  11. package/constants/constants.js +4 -4
  12. package/context/context.d.ts +8 -38
  13. package/context/context.js +2 -2
  14. package/context/db/db.d.ts +11 -19
  15. package/context/db/impl/IObject.d.ts +41 -40
  16. package/context/db/impl/db.d.ts +9 -9
  17. package/context/db/impl/db.js +6 -6
  18. package/context/db/impl/object.d.ts +4 -3
  19. package/context/db/impl/object.js +62 -50
  20. package/context/db/impl/oql/oql.d.ts +1 -1
  21. package/context/db/impl/oql/oql.js +1 -1
  22. package/context/db/impl/order.js +1 -1
  23. package/context/db/impl/propertiesStore.js +1 -1
  24. package/context/db/impl/transaction/index.d.ts +1 -1
  25. package/context/db/impl/transaction/index.js +51 -46
  26. package/context/db/impl/transaction.d.ts +0 -5
  27. package/context/integration/IIntegration.d.ts +30 -0
  28. package/context/integration/IIntegration.js +4 -0
  29. package/context/integration/impl/integration.d.ts +16 -0
  30. package/context/integration/impl/integration.js +62 -0
  31. package/context/metadata/components/common.js +3 -3
  32. package/context/metadata/components/components.d.ts +4 -4
  33. package/context/metadata/components/desktop/list.d.ts +3 -3
  34. package/context/metadata/components/desktop/list.js +23 -23
  35. package/context/metadata/components/desktop/recordDetail.d.ts +2 -2
  36. package/context/metadata/components/mobile/list.d.ts +4 -4
  37. package/context/metadata/components/mobile/list.js +1 -1
  38. package/context/metadata/metadata.d.ts +5 -6
  39. package/context/metadata/metadata.js +5 -6
  40. package/context/metadata/objects/fields.d.ts +6 -6
  41. package/context/metadata/objects/fields.js +57 -57
  42. package/context/metadata/objects/fields.util.d.ts +3 -3
  43. package/context/metadata/objects/fields.util.js +21 -21
  44. package/context/metadata/objects/objects.d.ts +1 -1
  45. package/context/metadata/objects/objects.js +1 -1
  46. package/context/metadata/types/components.d.ts +5 -5
  47. package/context/metadata/types/objects.d.ts +88 -88
  48. package/context/msg/msg.d.ts +2 -2
  49. package/context/resources/IResources.d.ts +6 -4
  50. package/context/resources/impl/resources.d.ts +6 -6
  51. package/context/resources/impl/resources.js +5 -5
  52. package/context/tasks/tasks.d.ts +3 -3
  53. package/context/tasks/tasks.js +5 -5
  54. package/data/index.d.ts +2 -2
  55. package/global/application/flow/flow.d.ts +85 -0
  56. package/global/application/flow/flow.js +2 -0
  57. package/global/application/globalVar/globalVar.d.ts +7 -0
  58. package/global/application/globalVar/globalVar.js +2 -0
  59. package/global/global.d.ts +64 -0
  60. package/global/global.js +3 -0
  61. package/hooks/api.d.ts +12 -7
  62. package/hooks/api.js +28 -23
  63. package/hooks/hooks.js +41 -0
  64. package/kunlun/kunlun.d.ts +5 -5
  65. package/kunlun/operator/IOperator.d.ts +16 -16
  66. package/kunlun/operator/impl/expression.d.ts +2 -2
  67. package/kunlun/operator/impl/expression.js +5 -5
  68. package/kunlun/operator/impl/logic.js +48 -31
  69. package/kunlun/operator/impl/logicV2.d.ts +2 -2
  70. package/kunlun/operator/impl/logicV2.js +12 -13
  71. package/kunlun/operator/impl/operator.d.ts +17 -17
  72. package/kunlun/operator/impl/operator.js +38 -38
  73. package/kunlun/operator/impl/operatorV2.d.ts +17 -17
  74. package/kunlun/operator/impl/operatorV2.js +38 -38
  75. package/lib/core.d.ts +3 -3
  76. package/package.json +2 -2
  77. package/request/common.d.ts +1 -1
  78. package/request/common.js +4 -3
  79. package/request/constants.d.ts +1 -1
  80. package/request/constants.js +6 -6
  81. package/request/faasinfra.d.ts +1 -1
  82. package/request/faasinfra.js +41 -253
  83. package/request/innerapi.d.ts +14 -10
  84. package/request/innerapi.js +220 -66
  85. package/request/interface.d.ts +68 -54
  86. package/request/interface.js +8 -9
  87. package/request/openapi.d.ts +15 -11
  88. package/request/openapi.js +266 -158
@@ -1,17 +1,18 @@
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> {
5
6
  /**
6
7
  * 创建记录
7
8
  * @param recordMap 用于创建的一条记录
8
- * @paramExample {_name: "John", age: 19, gender: "male"}
9
+ * @paramExample {_name: 'John', age: 19, gender: 'male'}
9
10
  * @example
10
11
  * ```
11
- * context.db.object("_department").create({
12
- * _name: new kunlun.type.Multilingual({ zh: "部门" }),
12
+ * application.data.object('_department').create({
13
+ * _name: new application.constants.type.Multilingual({ zh: '部门' }),
13
14
  * _manager: { _id: 1660000000 },
14
- * _status: "_active"
15
+ * _status: '_active'
15
16
  * })
16
17
  * ```
17
18
  */
@@ -23,7 +24,7 @@ export interface _IKSyncEndpoint<T> {
23
24
  * @param recordID 用于删除的一条记录的 ID
24
25
  * @example
25
26
  * ```
26
- * context.db.object("_user").delete(123456789123)
27
+ * application.data.object('_user').delete(123456789123)
27
28
  * ```
28
29
  */
29
30
  delete(recordID: number): Promise<void>;
@@ -32,7 +33,7 @@ export interface _IKSyncEndpoint<T> {
32
33
  * @param record 用于删除的一条完整记录
33
34
  * @example
34
35
  * ```
35
- * context.db.object("_user").delete(context.targetRecord.original)
36
+ * application.data.object('_user').delete(context.targetRecord.original)
36
37
  * ```
37
38
  */
38
39
  delete(record: _Cond<T>): Promise<void>;
@@ -40,11 +41,11 @@ export interface _IKSyncEndpoint<T> {
40
41
  * 指定 _id 后,更新对应记录
41
42
  * @param _id 主键
42
43
  * @param recordMap 用于更新的一条记录
43
- * @paramExample {_name: "John", age: 19, gender: "male"}
44
+ * @paramExample {_name: 'John', age: 19, gender: 'male'}
44
45
  * @example
45
46
  * ```
46
- * context.db.object("_user").update(1660000000, {
47
- * gender: "male"
47
+ * application.data.object('_user').update(1660000000, {
48
+ * gender: 'male'
48
49
  * })
49
50
  * ```
50
51
  */
@@ -52,12 +53,12 @@ export interface _IKSyncEndpoint<T> {
52
53
  /**
53
54
  * 指定 _id 后,更新对应记录
54
55
  * @param recordMap 用于更新的一条记录,需对 _id 赋值
55
- * @paramExample {_id: 1660000000, _name: "John", age: 19, gender: "male"}
56
+ * @paramExample {_id: 1660000000, _name: 'John', age: 19, gender: 'male'}
56
57
  * @example
57
58
  * ```
58
- * context.db.object("_user").update({
59
+ * application.data.object('_user').update({
59
60
  * _id: 1660000000,
60
- * gender: "male"
61
+ * gender: 'male'
61
62
  * })
62
63
  * ```
63
64
  */
@@ -65,7 +66,7 @@ export interface _IKSyncEndpoint<T> {
65
66
  /**
66
67
  * 批量创建记录
67
68
  * @param recordMapList 多条用于创建的记录数据组成的数组
68
- * @paramExample [{_name: "John", age: 19, gender: "male"}, {_name: "Alis", age: 16, gender: "female"}]
69
+ * @paramExample [{_name: 'John', age: 19, gender: 'male'}, {_name: 'Alis', age: 16, gender: 'female'}]
69
70
  */
70
71
  batchCreate(recordMapList: _Cond<T>[]): Promise<number[]>;
71
72
  /**
@@ -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
- * @paramExample [{_id: 1001, _name: "John", gender: "male"}, {_id: 1002, _name: "Alis", gender: "female"}]
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
- * @paramExample [{_id: 1001, _name: "John", gender: "male"}, {_id: 1002, _name: "Alis", gender: "female"}]
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
  */
@@ -99,7 +100,7 @@ export interface _IKAsyncEndpoint<T> {
99
100
  /**
100
101
  * 批量创建记录(为异步任务)
101
102
  * @param recordMapList 用于创建的多条记录
102
- * @paramExample [{_name: "John", age: 19, gender: "male"}, {_name: "Alis", age: 16, gender: "female"}]
103
+ * @paramExample [{_name: 'John', age: 19, gender: 'male'}, {_name: 'Alis', age: 16, gender: 'female'}]
103
104
  */
104
105
  batchCreateAsync(recordMapList: _Cond<T>[]): Promise<{
105
106
  taskID: number;
@@ -121,7 +122,7 @@ export interface _IKAsyncEndpoint<T> {
121
122
  /**
122
123
  * 根据 _id 批量更新记录(为异步任务)
123
124
  * @param recordMapList 用于更新的多条记录,需对 _id 赋值
124
- * @paramExample [{_id: 1001, _name: "John", gender: "male"}, {_id: 1002, _name: "Alis", gender: "female"}]
125
+ * @paramExample [{_id: 1001, _name: 'John', gender: 'male'}, {_id: 1002, _name: 'Alis', gender: 'female'}]
125
126
  */
126
127
  batchUpdateAsync(recordMapList: _Cond<T>[]): Promise<{
127
128
  taskID: number;
@@ -142,8 +143,8 @@ export interface _IKQuery<T> {
142
143
  * 无需入参,返回全部符合条件的记录
143
144
  * @example
144
145
  * ```
145
- * context.db.object("_user").where({
146
- * gender: "male"
146
+ * application.data.object('_user').where({
147
+ * gender: 'male'
147
148
  * }).findAll()
148
149
  * ```
149
150
  */
@@ -153,7 +154,7 @@ export interface _IKQuery<T> {
153
154
  * @param handler 业务处理函数
154
155
  * @example
155
156
  * ```
156
- * await context.db.object("_user").findStream(async (records) => {
157
+ * await application.data.object('_user').findStream(async (records) => {
157
158
  * // doSomething ...
158
159
  * });
159
160
  * ```
@@ -163,8 +164,8 @@ export interface _IKQuery<T> {
163
164
  * 无需入参,返回符合条件的记录,单次返回 200 条
164
165
  * @example
165
166
  * ```
166
- * context.db.object("_user").where({
167
- * gender: "male"
167
+ * application.data.object('_user').where({
168
+ * gender: 'male'
168
169
  * }).find()
169
170
  * ```
170
171
  */
@@ -173,8 +174,8 @@ export interface _IKQuery<T> {
173
174
  * 无需入参,返回排在第一位的记录
174
175
  * @example
175
176
  * ```
176
- * context.db.object("_user").where({
177
- * gender: "male"
177
+ * application.data.object('_user').where({
178
+ * gender: 'male'
178
179
  * }).findOne()
179
180
  * ```
180
181
  */
@@ -184,7 +185,7 @@ export interface _IKQuery<T> {
184
185
  * @param fieldApiNames 排序依据的字段数组,按先后顺序确定优先级
185
186
  * @example
186
187
  * ```
187
- * context.db.object("_user").orderBy(["_email", "_phoneNumber"]).find()
188
+ * application.data.object('_user').orderBy(['_email', '_phoneNumber']).find()
188
189
  * ```
189
190
  */
190
191
  orderBy<K extends keyof T>(fieldApiNames: K[]): Omit<_IKQuery<T>, 'findAll'>;
@@ -193,7 +194,7 @@ export interface _IKQuery<T> {
193
194
  * @param fieldApiNames 排序依据的字段,按先后顺序确定优先级,用逗号分隔
194
195
  * @example
195
196
  * ```
196
- * context.db.object("_user").orderBy("_email", "_phoneNumber").find()
197
+ * application.data.object('_user').orderBy('_email', '_phoneNumber').find()
197
198
  * ```
198
199
  */
199
200
  orderBy<K extends keyof T>(...fieldApiNames: K[]): Omit<_IKQuery<T>, 'findAll'>;
@@ -202,7 +203,7 @@ export interface _IKQuery<T> {
202
203
  * @param fieldApiNames 排序依据的字段数组,按先后顺序确定优先级
203
204
  * @example
204
205
  * ```
205
- * context.db.object("_user").orderByDesc("_email", "_phoneNumber").find()
206
+ * application.data.object('_user').orderByDesc('_email', '_phoneNumber').find()
206
207
  * ```
207
208
  */
208
209
  orderByDesc<K extends keyof T>(fieldApiNames: K[]): Omit<_IKQuery<T>, 'findAll'>;
@@ -211,7 +212,7 @@ export interface _IKQuery<T> {
211
212
  * @param fieldApiNames 排序依据的字段,按先后顺序确定优先级,用逗号分隔
212
213
  * @example
213
214
  * ```
214
- * context.db.object("_user").orderByDesc("_email", "_phoneNumber").find()
215
+ * application.data.object('_user').orderByDesc('_email', '_phoneNumber').find()
215
216
  * ```
216
217
  */
217
218
  orderByDesc<K extends keyof T>(...fieldApiNames: K[]): Omit<_IKQuery<T>, 'findAll'>;
@@ -220,7 +221,7 @@ export interface _IKQuery<T> {
220
221
  * @param fieldApiNames 需返回的字段数组
221
222
  * @example
222
223
  * ```
223
- * context.db.object("_user").select(["_name", "_email"]).find()
224
+ * application.data.object('_user').select(['_name', '_email']).find()
224
225
  * ```
225
226
  */
226
227
  select<K extends keyof T>(fieldApiNames: K[]): Omit<_IKQuery<T>, 'findAll'>;
@@ -229,18 +230,18 @@ export interface _IKQuery<T> {
229
230
  * @param fieldApiNames 需返回的字段,用逗号分隔
230
231
  * @example
231
232
  * ```
232
- * context.db.object("_user").select("_name", "_email").find()
233
+ * application.data.object('_user').select('_name', '_email').find()
233
234
  * ```
234
235
  */
235
236
  select<K extends keyof T>(...fieldApiNames: K[]): Omit<_IKQuery<T>, 'findAll'>;
236
237
  /**
237
238
  * 设置查询条件
238
239
  * @param conditionMap 对字段赋值以指定查询筛选条件
239
- * @paramExample {gender: "male"}
240
+ * @paramExample {gender: 'male'}
240
241
  * @example
241
242
  * ```
242
- * context.db.object("_user").where({
243
- * gender: "male"
243
+ * application.data.object('_user').where({
244
+ * gender: 'male'
244
245
  * }).find()
245
246
  * ```
246
247
  */
@@ -255,7 +256,7 @@ export interface _IKQuery<T> {
255
256
  * @param fieldAPINames 『可搜索字段』的字段列表,不可为空
256
257
  * @example
257
258
  * ```
258
- * context.db.object("_user").fuzzySearch("张三", ["_name"]).find()
259
+ * application.data.object('_user').fuzzySearch('张三', ['_name']).find()
259
260
  * ```
260
261
  */
261
262
  fuzzySearch(keyword: string, fieldAPINames: string[]): Omit<_IKQuery<T>, 'findAll'>;
@@ -265,7 +266,7 @@ export interface _IKQuery<T> {
265
266
  * @paramExample 10
266
267
  * @example
267
268
  * ```
268
- * context.db.object("_user").limit(10)
269
+ * application.data.object('_user').limit(10)
269
270
  * ```
270
271
  */
271
272
  limit(limit: number): Omit<_IKQuery<T>, 'findAll'>;
@@ -275,7 +276,7 @@ export interface _IKQuery<T> {
275
276
  * @paramExample 0
276
277
  * @example
277
278
  * ```
278
- * context.db.object("_user").offset(0)
279
+ * application.data.object('_user').offset(0)
279
280
  * ```
280
281
  */
281
282
  offset(offset: number): Omit<_IKQuery<T>, 'findAll'>;
@@ -283,7 +284,7 @@ export interface _IKQuery<T> {
283
284
  * 指定条件的行数
284
285
  * @example
285
286
  * ```
286
- * context.db.object("_user").count()
287
+ * application.data.object('_user').count()
287
288
  * ```
288
289
  */
289
290
  count(): Promise<number>;
@@ -2,8 +2,8 @@ import { _IKAllEndpoint, _IKSyncEndpoint, _IKQuery } from './IObject';
2
2
  import { ITransactionGetter } from './transaction';
3
3
  import { IDB, IDBSync, IDBWithCurrentObject } from '../db';
4
4
  import { currentObjApiName, metadataMap } from '../../../data/index';
5
- import { IOql } from "./oql/ioql";
6
- import { AppCtx } from "../../../application/application";
5
+ import { IOql } from './oql/ioql';
6
+ import { AppCtx } from '../../../application/application';
7
7
  export declare class DB<T, mt = metadataMap> implements IDB<T, mt> {
8
8
  objectApiName: string;
9
9
  constructor(objectApiName?: string);
@@ -12,8 +12,8 @@ export declare class DB<T, mt = metadataMap> implements IDB<T, mt> {
12
12
  * @param objectApiName 指定对象的 ApiName
13
13
  * @example
14
14
  * ```
15
- * context.db.object("_user").where({
16
- * gender: "male"
15
+ * context.db.object('_user').where({
16
+ * gender: 'male'
17
17
  * }).find()
18
18
  * ```
19
19
  */
@@ -23,11 +23,11 @@ export declare class DB<T, mt = metadataMap> implements IDB<T, mt> {
23
23
  * @example
24
24
  * ```
25
25
  * let tx = context.db.newTransaction();
26
- * let user = tx.object("_user").registerCreate({
27
- * _name: new kunlun.type.Multilingual({ zh: "用户1", en: "user1" }),
26
+ * let user = tx.object('_user').registerCreate({
27
+ * _name: new kunlun.type.Multilingual({ zh: '用户1', en: 'user1' }),
28
28
  * });
29
- * let contract = tx.object("contract").registerCreate({
30
- * _name: new kunlun.type.Multilingual({ zh: "用户1的合同", en: "user1's contract" }),
29
+ * let contract = tx.object('contract').registerCreate({
30
+ * _name: new kunlun.type.Multilingual({ zh: '用户1的合同', en: 'user1's contract' }),
31
31
  * user: {id: user._id}
32
32
  * });
33
33
  * await tx.commit();
@@ -39,7 +39,7 @@ export declare class DB<T, mt = metadataMap> implements IDB<T, mt> {
39
39
  * @param oql 指定 OQL 语句
40
40
  * @example
41
41
  * ```
42
- * let users = await context.db.oql("select _email from _user").execute();
42
+ * let users = await context.db.oql('select _email from _user').execute();
43
43
  * ```
44
44
  */
45
45
  oql(oql: string): IOql;
@@ -14,8 +14,8 @@ class DB {
14
14
  * @param objectApiName 指定对象的 ApiName
15
15
  * @example
16
16
  * ```
17
- * context.db.object("_user").where({
18
- * gender: "male"
17
+ * context.db.object('_user').where({
18
+ * gender: 'male'
19
19
  * }).find()
20
20
  * ```
21
21
  */
@@ -28,11 +28,11 @@ class DB {
28
28
  * @example
29
29
  * ```
30
30
  * let tx = context.db.newTransaction();
31
- * let user = tx.object("_user").registerCreate({
32
- * _name: new kunlun.type.Multilingual({ zh: "用户1", en: "user1" }),
31
+ * let user = tx.object('_user').registerCreate({
32
+ * _name: new kunlun.type.Multilingual({ zh: '用户1', en: 'user1' }),
33
33
  * });
34
- * let contract = tx.object("contract").registerCreate({
35
- * _name: new kunlun.type.Multilingual({ zh: "用户1的合同", en: "user1's contract" }),
34
+ * let contract = tx.object('contract').registerCreate({
35
+ * _name: new kunlun.type.Multilingual({ zh: '用户1的合同', en: 'user1's contract' }),
36
36
  * user: {id: user._id}
37
37
  * });
38
38
  * await tx.commit();
@@ -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
  }