@byted-apaas/server-sdk-node 1.0.17 → 1.1.0

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 (163) hide show
  1. package/README.md +7 -0
  2. package/application/application.d.ts +9 -7
  3. package/application/application.js +1 -0
  4. package/application/application.js.map +1 -0
  5. package/application/function/function.d.ts +1 -1
  6. package/application/function/function.js +1 -1
  7. package/application/function/function.js.map +1 -0
  8. package/application/impl/common.d.ts +1 -1
  9. package/application/impl/common.js +14 -12
  10. package/application/impl/common.js.map +1 -0
  11. package/application/impl/impl.d.ts +8 -6
  12. package/application/impl/impl.js +7 -4
  13. package/application/impl/impl.js.map +1 -0
  14. package/constants/constants.js +5 -4
  15. package/constants/constants.js.map +1 -0
  16. package/context/context.d.ts +2 -71
  17. package/context/context.js +1 -16
  18. package/context/context.js.map +1 -0
  19. package/context/db/db.d.ts +11 -19
  20. package/context/db/db.js +1 -0
  21. package/context/db/db.js.map +1 -0
  22. package/context/db/impl/IObject.d.ts +37 -37
  23. package/context/db/impl/IObject.js +1 -0
  24. package/context/db/impl/IObject.js.map +1 -0
  25. package/context/db/impl/db.d.ts +9 -9
  26. package/context/db/impl/db.js +7 -6
  27. package/context/db/impl/db.js.map +1 -0
  28. package/context/db/impl/object.js +48 -47
  29. package/context/db/impl/object.js.map +1 -0
  30. package/context/db/impl/oql/ioql.js +1 -0
  31. package/context/db/impl/oql/ioql.js.map +1 -0
  32. package/context/db/impl/oql/oql.d.ts +1 -1
  33. package/context/db/impl/oql/oql.js +1 -0
  34. package/context/db/impl/oql/oql.js.map +1 -0
  35. package/context/db/impl/order.js +2 -1
  36. package/context/db/impl/order.js.map +1 -0
  37. package/context/db/impl/propertiesStore.js +2 -1
  38. package/context/db/impl/propertiesStore.js.map +1 -0
  39. package/context/db/impl/queryBuilder.js +1 -0
  40. package/context/db/impl/queryBuilder.js.map +1 -0
  41. package/context/db/impl/transaction/index.d.ts +1 -1
  42. package/context/db/impl/transaction/index.js +47 -45
  43. package/context/db/impl/transaction/index.js.map +1 -0
  44. package/context/db/impl/transaction/operation.js +1 -0
  45. package/context/db/impl/transaction/operation.js.map +1 -0
  46. package/context/db/impl/transaction.d.ts +0 -5
  47. package/context/db/impl/transaction.js +1 -0
  48. package/context/db/impl/transaction.js.map +1 -0
  49. package/context/globalConfig/globalConfig.js +1 -0
  50. package/context/globalConfig/globalConfig.js.map +1 -0
  51. package/context/integration/IIntegration.d.ts +30 -0
  52. package/context/integration/IIntegration.js +5 -0
  53. package/context/integration/IIntegration.js.map +1 -0
  54. package/context/integration/impl/integration.d.ts +16 -0
  55. package/context/integration/impl/integration.js +63 -0
  56. package/context/integration/impl/integration.js.map +1 -0
  57. package/context/metadata/components/common.js +4 -3
  58. package/context/metadata/components/common.js.map +1 -0
  59. package/context/metadata/components/components.d.ts +4 -4
  60. package/context/metadata/components/components.js +1 -0
  61. package/context/metadata/components/components.js.map +1 -0
  62. package/context/metadata/components/desktop/list.d.ts +3 -3
  63. package/context/metadata/components/desktop/list.js +24 -23
  64. package/context/metadata/components/desktop/list.js.map +1 -0
  65. package/context/metadata/components/desktop/recordDetail.d.ts +2 -2
  66. package/context/metadata/components/desktop/recordDetail.js +1 -0
  67. package/context/metadata/components/desktop/recordDetail.js.map +1 -0
  68. package/context/metadata/components/mobile/list.d.ts +4 -4
  69. package/context/metadata/components/mobile/list.js +2 -1
  70. package/context/metadata/components/mobile/list.js.map +1 -0
  71. package/context/metadata/metadata.d.ts +5 -6
  72. package/context/metadata/metadata.js +6 -6
  73. package/context/metadata/metadata.js.map +1 -0
  74. package/context/metadata/objects/fields.d.ts +6 -6
  75. package/context/metadata/objects/fields.js +58 -57
  76. package/context/metadata/objects/fields.js.map +1 -0
  77. package/context/metadata/objects/fields.util.d.ts +3 -3
  78. package/context/metadata/objects/fields.util.js +22 -21
  79. package/context/metadata/objects/fields.util.js.map +1 -0
  80. package/context/metadata/objects/objects.d.ts +1 -1
  81. package/context/metadata/objects/objects.js +2 -1
  82. package/context/metadata/objects/objects.js.map +1 -0
  83. package/context/metadata/types/common.js +1 -0
  84. package/context/metadata/types/common.js.map +1 -0
  85. package/context/metadata/types/components.d.ts +5 -5
  86. package/context/metadata/types/components.js +1 -0
  87. package/context/metadata/types/components.js.map +1 -0
  88. package/context/metadata/types/objects.d.ts +88 -88
  89. package/context/metadata/types/objects.js +1 -0
  90. package/context/metadata/types/objects.js.map +1 -0
  91. package/context/msg/msg.d.ts +2 -2
  92. package/context/msg/msg.js +1 -0
  93. package/context/msg/msg.js.map +1 -0
  94. package/context/resources/IResources.d.ts +2 -2
  95. package/context/resources/IResources.js +1 -0
  96. package/context/resources/IResources.js.map +1 -0
  97. package/context/resources/impl/resources.d.ts +4 -4
  98. package/context/resources/impl/resources.js +4 -3
  99. package/context/resources/impl/resources.js.map +1 -0
  100. package/context/tasks/tasks.d.ts +3 -3
  101. package/context/tasks/tasks.js +6 -5
  102. package/context/tasks/tasks.js.map +1 -0
  103. package/data/index.d.ts +2 -2
  104. package/data/index.js +1 -0
  105. package/data/index.js.map +1 -0
  106. package/global/application/flow/flow.d.ts +85 -0
  107. package/global/application/flow/flow.js +3 -0
  108. package/global/application/flow/flow.js.map +1 -0
  109. package/global/global.d.ts +88 -0
  110. package/global/global.js +4 -0
  111. package/global/global.js.map +1 -0
  112. package/hooks/api.d.ts +12 -7
  113. package/hooks/api.js +29 -23
  114. package/hooks/api.js.map +1 -0
  115. package/hooks/hooks.js +42 -0
  116. package/hooks/hooks.js.map +1 -0
  117. package/kunlun/kunlun.d.ts +5 -5
  118. package/kunlun/kunlun.js +1 -0
  119. package/kunlun/kunlun.js.map +1 -0
  120. package/kunlun/operator/IOperator.d.ts +16 -16
  121. package/kunlun/operator/IOperator.js +1 -0
  122. package/kunlun/operator/IOperator.js.map +1 -0
  123. package/kunlun/operator/impl/expression.d.ts +2 -2
  124. package/kunlun/operator/impl/expression.js +6 -5
  125. package/kunlun/operator/impl/expression.js.map +1 -0
  126. package/kunlun/operator/impl/logic.js +49 -31
  127. package/kunlun/operator/impl/logic.js.map +1 -0
  128. package/kunlun/operator/impl/logicV2.d.ts +2 -2
  129. package/kunlun/operator/impl/logicV2.js +13 -13
  130. package/kunlun/operator/impl/logicV2.js.map +1 -0
  131. package/kunlun/operator/impl/operator.d.ts +17 -17
  132. package/kunlun/operator/impl/operator.js +39 -38
  133. package/kunlun/operator/impl/operator.js.map +1 -0
  134. package/kunlun/operator/impl/operatorV2.d.ts +17 -17
  135. package/kunlun/operator/impl/operatorV2.js +39 -38
  136. package/kunlun/operator/impl/operatorV2.js.map +1 -0
  137. package/lib/core.d.ts +3 -3
  138. package/lib/core.js +1 -0
  139. package/lib/core.js.map +1 -0
  140. package/log/app.access.log +0 -0
  141. package/log/app.call.log +0 -0
  142. package/log/app.log +0 -0
  143. package/package.json +2 -2
  144. package/request/common.d.ts +1 -1
  145. package/request/common.js +5 -3
  146. package/request/common.js.map +1 -0
  147. package/request/constants.d.ts +1 -1
  148. package/request/constants.js +7 -6
  149. package/request/constants.js.map +1 -0
  150. package/request/faasinfra.d.ts +1 -1
  151. package/request/faasinfra.js +42 -251
  152. package/request/faasinfra.js.map +1 -0
  153. package/request/innerapi.d.ts +12 -8
  154. package/request/innerapi.js +173 -57
  155. package/request/innerapi.js.map +1 -0
  156. package/request/interface.d.ts +68 -54
  157. package/request/interface.js +9 -9
  158. package/request/interface.js.map +1 -0
  159. package/request/openapi.d.ts +12 -8
  160. package/request/openapi.js +215 -149
  161. package/request/openapi.js.map +1 -0
  162. package/types/types.js +1 -0
  163. package/types/types.js.map +1 -0
@@ -5,13 +5,13 @@ export interface _IKSyncEndpoint<T> {
5
5
  /**
6
6
  * 创建记录
7
7
  * @param recordMap 用于创建的一条记录
8
- * @paramExample {_name: "John", age: 19, gender: "male"}
8
+ * @paramExample {_name: 'John', age: 19, gender: 'male'}
9
9
  * @example
10
10
  * ```
11
- * context.db.object("_department").create({
12
- * _name: new kunlun.type.Multilingual({ zh: "部门" }),
11
+ * application.data.object('_department').create({
12
+ * _name: new application.constants.type.Multilingual({ zh: '部门' }),
13
13
  * _manager: { _id: 1660000000 },
14
- * _status: "_active"
14
+ * _status: '_active'
15
15
  * })
16
16
  * ```
17
17
  */
@@ -23,7 +23,7 @@ export interface _IKSyncEndpoint<T> {
23
23
  * @param recordID 用于删除的一条记录的 ID
24
24
  * @example
25
25
  * ```
26
- * context.db.object("_user").delete(123456789123)
26
+ * application.data.object('_user').delete(123456789123)
27
27
  * ```
28
28
  */
29
29
  delete(recordID: number): Promise<void>;
@@ -32,7 +32,7 @@ export interface _IKSyncEndpoint<T> {
32
32
  * @param record 用于删除的一条完整记录
33
33
  * @example
34
34
  * ```
35
- * context.db.object("_user").delete(context.targetRecord.original)
35
+ * application.data.object('_user').delete(context.targetRecord.original)
36
36
  * ```
37
37
  */
38
38
  delete(record: _Cond<T>): Promise<void>;
@@ -40,11 +40,11 @@ export interface _IKSyncEndpoint<T> {
40
40
  * 指定 _id 后,更新对应记录
41
41
  * @param _id 主键
42
42
  * @param recordMap 用于更新的一条记录
43
- * @paramExample {_name: "John", age: 19, gender: "male"}
43
+ * @paramExample {_name: 'John', age: 19, gender: 'male'}
44
44
  * @example
45
45
  * ```
46
- * context.db.object("_user").update(1660000000, {
47
- * gender: "male"
46
+ * application.data.object('_user').update(1660000000, {
47
+ * gender: 'male'
48
48
  * })
49
49
  * ```
50
50
  */
@@ -52,12 +52,12 @@ export interface _IKSyncEndpoint<T> {
52
52
  /**
53
53
  * 指定 _id 后,更新对应记录
54
54
  * @param recordMap 用于更新的一条记录,需对 _id 赋值
55
- * @paramExample {_id: 1660000000, _name: "John", age: 19, gender: "male"}
55
+ * @paramExample {_id: 1660000000, _name: 'John', age: 19, gender: 'male'}
56
56
  * @example
57
57
  * ```
58
- * context.db.object("_user").update({
58
+ * application.data.object('_user').update({
59
59
  * _id: 1660000000,
60
- * gender: "male"
60
+ * gender: 'male'
61
61
  * })
62
62
  * ```
63
63
  */
@@ -65,7 +65,7 @@ export interface _IKSyncEndpoint<T> {
65
65
  /**
66
66
  * 批量创建记录
67
67
  * @param recordMapList 多条用于创建的记录数据组成的数组
68
- * @paramExample [{_name: "John", age: 19, gender: "male"}, {_name: "Alis", age: 16, gender: "female"}]
68
+ * @paramExample [{_name: 'John', age: 19, gender: 'male'}, {_name: 'Alis', age: 16, gender: 'female'}]
69
69
  */
70
70
  batchCreate(recordMapList: _Cond<T>[]): Promise<number[]>;
71
71
  /**
@@ -77,13 +77,13 @@ export interface _IKSyncEndpoint<T> {
77
77
  /**
78
78
  * 批量删除记录
79
79
  * @param recordList 多条用于删除的记录数据组成的数组,记录数据需对 _id 赋值
80
- * @paramExample [{_id: 1001, _name: "John", gender: "male"}, {_id: 1002, _name: "Alis", gender: "female"}]
80
+ * @paramExample [{_id: 1001, _name: 'John', gender: 'male'}, {_id: 1002, _name: 'Alis', gender: 'female'}]
81
81
  */
82
82
  batchDelete(recordList: _Cond<T>[]): Promise<void>;
83
83
  /**
84
84
  * 根据 _id 批量更新记录
85
85
  * @param recordMapList 多条用于更新的记录数据组成的数组,记录数据需对 _id 赋值
86
- * @paramExample [{_id: 1001, _name: "John", gender: "male"}, {_id: 1002, _name: "Alis", gender: "female"}]
86
+ * @paramExample [{_id: 1001, _name: 'John', gender: 'male'}, {_id: 1002, _name: 'Alis', gender: 'female'}]
87
87
  */
88
88
  batchUpdate(recordMapList: _Cond<T>[]): Promise<void>;
89
89
  /**
@@ -99,7 +99,7 @@ export interface _IKAsyncEndpoint<T> {
99
99
  /**
100
100
  * 批量创建记录(为异步任务)
101
101
  * @param recordMapList 用于创建的多条记录
102
- * @paramExample [{_name: "John", age: 19, gender: "male"}, {_name: "Alis", age: 16, gender: "female"}]
102
+ * @paramExample [{_name: 'John', age: 19, gender: 'male'}, {_name: 'Alis', age: 16, gender: 'female'}]
103
103
  */
104
104
  batchCreateAsync(recordMapList: _Cond<T>[]): Promise<{
105
105
  taskID: number;
@@ -121,7 +121,7 @@ export interface _IKAsyncEndpoint<T> {
121
121
  /**
122
122
  * 根据 _id 批量更新记录(为异步任务)
123
123
  * @param recordMapList 用于更新的多条记录,需对 _id 赋值
124
- * @paramExample [{_id: 1001, _name: "John", gender: "male"}, {_id: 1002, _name: "Alis", gender: "female"}]
124
+ * @paramExample [{_id: 1001, _name: 'John', gender: 'male'}, {_id: 1002, _name: 'Alis', gender: 'female'}]
125
125
  */
126
126
  batchUpdateAsync(recordMapList: _Cond<T>[]): Promise<{
127
127
  taskID: number;
@@ -142,8 +142,8 @@ export interface _IKQuery<T> {
142
142
  * 无需入参,返回全部符合条件的记录
143
143
  * @example
144
144
  * ```
145
- * context.db.object("_user").where({
146
- * gender: "male"
145
+ * application.data.object('_user').where({
146
+ * gender: 'male'
147
147
  * }).findAll()
148
148
  * ```
149
149
  */
@@ -153,7 +153,7 @@ export interface _IKQuery<T> {
153
153
  * @param handler 业务处理函数
154
154
  * @example
155
155
  * ```
156
- * await context.db.object("_user").findStream(async (records) => {
156
+ * await application.data.object('_user').findStream(async (records) => {
157
157
  * // doSomething ...
158
158
  * });
159
159
  * ```
@@ -163,8 +163,8 @@ export interface _IKQuery<T> {
163
163
  * 无需入参,返回符合条件的记录,单次返回 200 条
164
164
  * @example
165
165
  * ```
166
- * context.db.object("_user").where({
167
- * gender: "male"
166
+ * application.data.object('_user').where({
167
+ * gender: 'male'
168
168
  * }).find()
169
169
  * ```
170
170
  */
@@ -173,8 +173,8 @@ export interface _IKQuery<T> {
173
173
  * 无需入参,返回排在第一位的记录
174
174
  * @example
175
175
  * ```
176
- * context.db.object("_user").where({
177
- * gender: "male"
176
+ * application.data.object('_user').where({
177
+ * gender: 'male'
178
178
  * }).findOne()
179
179
  * ```
180
180
  */
@@ -184,7 +184,7 @@ export interface _IKQuery<T> {
184
184
  * @param fieldApiNames 排序依据的字段数组,按先后顺序确定优先级
185
185
  * @example
186
186
  * ```
187
- * context.db.object("_user").orderBy(["_email", "_phoneNumber"]).find()
187
+ * application.data.object('_user').orderBy(['_email', '_phoneNumber']).find()
188
188
  * ```
189
189
  */
190
190
  orderBy<K extends keyof T>(fieldApiNames: K[]): Omit<_IKQuery<T>, 'findAll'>;
@@ -193,7 +193,7 @@ export interface _IKQuery<T> {
193
193
  * @param fieldApiNames 排序依据的字段,按先后顺序确定优先级,用逗号分隔
194
194
  * @example
195
195
  * ```
196
- * context.db.object("_user").orderBy("_email", "_phoneNumber").find()
196
+ * application.data.object('_user').orderBy('_email', '_phoneNumber').find()
197
197
  * ```
198
198
  */
199
199
  orderBy<K extends keyof T>(...fieldApiNames: K[]): Omit<_IKQuery<T>, 'findAll'>;
@@ -202,7 +202,7 @@ export interface _IKQuery<T> {
202
202
  * @param fieldApiNames 排序依据的字段数组,按先后顺序确定优先级
203
203
  * @example
204
204
  * ```
205
- * context.db.object("_user").orderByDesc("_email", "_phoneNumber").find()
205
+ * application.data.object('_user').orderByDesc('_email', '_phoneNumber').find()
206
206
  * ```
207
207
  */
208
208
  orderByDesc<K extends keyof T>(fieldApiNames: K[]): Omit<_IKQuery<T>, 'findAll'>;
@@ -211,7 +211,7 @@ export interface _IKQuery<T> {
211
211
  * @param fieldApiNames 排序依据的字段,按先后顺序确定优先级,用逗号分隔
212
212
  * @example
213
213
  * ```
214
- * context.db.object("_user").orderByDesc("_email", "_phoneNumber").find()
214
+ * application.data.object('_user').orderByDesc('_email', '_phoneNumber').find()
215
215
  * ```
216
216
  */
217
217
  orderByDesc<K extends keyof T>(...fieldApiNames: K[]): Omit<_IKQuery<T>, 'findAll'>;
@@ -220,7 +220,7 @@ export interface _IKQuery<T> {
220
220
  * @param fieldApiNames 需返回的字段数组
221
221
  * @example
222
222
  * ```
223
- * context.db.object("_user").select(["_name", "_email"]).find()
223
+ * application.data.object('_user').select(['_name', '_email']).find()
224
224
  * ```
225
225
  */
226
226
  select<K extends keyof T>(fieldApiNames: K[]): Omit<_IKQuery<T>, 'findAll'>;
@@ -229,18 +229,18 @@ export interface _IKQuery<T> {
229
229
  * @param fieldApiNames 需返回的字段,用逗号分隔
230
230
  * @example
231
231
  * ```
232
- * context.db.object("_user").select("_name", "_email").find()
232
+ * application.data.object('_user').select('_name', '_email').find()
233
233
  * ```
234
234
  */
235
235
  select<K extends keyof T>(...fieldApiNames: K[]): Omit<_IKQuery<T>, 'findAll'>;
236
236
  /**
237
237
  * 设置查询条件
238
238
  * @param conditionMap 对字段赋值以指定查询筛选条件
239
- * @paramExample {gender: "male"}
239
+ * @paramExample {gender: 'male'}
240
240
  * @example
241
241
  * ```
242
- * context.db.object("_user").where({
243
- * gender: "male"
242
+ * application.data.object('_user').where({
243
+ * gender: 'male'
244
244
  * }).find()
245
245
  * ```
246
246
  */
@@ -255,7 +255,7 @@ export interface _IKQuery<T> {
255
255
  * @param fieldAPINames 『可搜索字段』的字段列表,不可为空
256
256
  * @example
257
257
  * ```
258
- * context.db.object("_user").fuzzySearch("张三", ["_name"]).find()
258
+ * application.data.object('_user').fuzzySearch('张三', ['_name']).find()
259
259
  * ```
260
260
  */
261
261
  fuzzySearch(keyword: string, fieldAPINames: string[]): Omit<_IKQuery<T>, 'findAll'>;
@@ -265,7 +265,7 @@ export interface _IKQuery<T> {
265
265
  * @paramExample 10
266
266
  * @example
267
267
  * ```
268
- * context.db.object("_user").limit(10)
268
+ * application.data.object('_user').limit(10)
269
269
  * ```
270
270
  */
271
271
  limit(limit: number): Omit<_IKQuery<T>, 'findAll'>;
@@ -275,7 +275,7 @@ export interface _IKQuery<T> {
275
275
  * @paramExample 0
276
276
  * @example
277
277
  * ```
278
- * context.db.object("_user").offset(0)
278
+ * application.data.object('_user').offset(0)
279
279
  * ```
280
280
  */
281
281
  offset(offset: number): Omit<_IKQuery<T>, 'findAll'>;
@@ -283,7 +283,7 @@ export interface _IKQuery<T> {
283
283
  * 指定条件的行数
284
284
  * @example
285
285
  * ```
286
- * context.db.object("_user").count()
286
+ * application.data.object('_user').count()
287
287
  * ```
288
288
  */
289
289
  count(): Promise<number>;
@@ -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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IObject.js","sourceRoot":"","sources":["IObject.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,+BAA+B;;AAK9B,CAAC"}
@@ -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();
@@ -79,3 +79,4 @@ class ApplicationDB {
79
79
  }
80
80
  }
81
81
  exports.ApplicationDB = ApplicationDB;
82
+ //# sourceMappingURL=db.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"db.js","sourceRoot":"","sources":["db.ts"],"names":[],"mappings":";;;AAAA,qCAAsD;AAKtD,wEAA0D;AAC1D,+CAA+C;AAE/C,mCAA8B;AAG9B,MAAa,EAAE;IAGX,YAAY,aAAsB;QAC9B,IAAI,CAAC,aAAa,GAAG,aAAa,CAAA;IACtC,CAAC;IAED;;;;;;;;;OASG;IACH,MAAM,CAAqB,aAAgB;QACvC,OAAO,IAAI,iBAAQ,CAAQ,aAAuB,CAAC,CAAA;IACvD,CAAC;IAAA,CAAC;IAEF;;;;;;;;;;;;;;OAcG;IACH,cAAc;QACV,OAAO,IAAI,mBAAW,CAAC,IAAI,CAAC,aAAa,CAAyC,CAAA;IACtF,CAAC;IAAA,CAAC;IAYF,GAAG,CAAC,GAAW,EAAE,QAA8B;QAC3C,IAAI,QAAQ,EAAE;YACV,OAAO,IAAI,SAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;SACjC;QACD,OAAO,IAAI,SAAG,CAAC,GAAG,CAAC,CAAC;IACxB,CAAC;CACJ;AAxDD,gBAwDC;AAED,MAAa,mBAAyC,SAAQ,EAAS;IACnE;;OAEG;IACH,aAAa;IACb,aAAa;QACT,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE;YACrB,MAAM,IAAI,+BAAU,CAAC,aAAa,CAAC,gCAAgC,CAAC,CAAC;SACxE;QACD,OAAO,IAAI,iBAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IAC5C,CAAC;IAAA,CAAC;IAEF,YAAY,aAAqB;QAC7B,KAAK,CAAC,aAAa,CAAC,CAAA;IACxB,CAAC;CACJ;AAfD,kDAeC;AAED;;GAEG;AACH,MAAa,aAAa;IAGtB,YAAY,MAAc;QACtB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;IACxB,CAAC;IAED,MAAM,CAAC,aAAqB;QACxB,OAAO,IAAI,4BAAmB,CAAC,aAAa,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IAC/D,CAAC;CACJ;AAVD,sCAUC"}
@@ -19,7 +19,7 @@ class _KObject {
19
19
  constructor(objectApiName) {
20
20
  this.apiName = '';
21
21
  if (!objectApiName) {
22
- throw new server_common_node_1.exceptions.InvalidParamError("objectApiName is empty");
22
+ throw new server_common_node_1.exceptions.InvalidParamError('objectApiName is empty');
23
23
  }
24
24
  this.apiName = objectApiName;
25
25
  }
@@ -42,10 +42,10 @@ class _KObjectSync {
42
42
  // create, update, delete
43
43
  async create(recordMap) {
44
44
  if (!recordMap) {
45
- throw new server_common_node_1.exceptions.InvalidParamError("record is empty");
45
+ throw new server_common_node_1.exceptions.InvalidParamError('record is empty');
46
46
  }
47
47
  if (server_common_node_1.checkUtils.isNotObject(recordMap)) {
48
- throw new server_common_node_1.exceptions.InvalidParamError("record is not object");
48
+ throw new server_common_node_1.exceptions.InvalidParamError('record is not object');
49
49
  }
50
50
  if (this.appCtx && this.appCtx.mode == 'openSDK') {
51
51
  // request from OpenSDK
@@ -59,7 +59,7 @@ class _KObjectSync {
59
59
  async delete(recordOrRecordID) {
60
60
  let recordID = 0;
61
61
  // 用户直接传入 record id 来进行删除的情况
62
- if (typeof recordOrRecordID === "number") {
62
+ if (typeof recordOrRecordID === 'number') {
63
63
  recordID = recordOrRecordID;
64
64
  }
65
65
  else {
@@ -68,7 +68,7 @@ class _KObjectSync {
68
68
  if (server_common_node_1.checkUtils.isObject(record)) {
69
69
  // 如果用户没有传入包含 id 的 record,则报错
70
70
  if (!record._id) {
71
- throw new server_common_node_1.exceptions.InvalidParamError("record._id is empty");
71
+ throw new server_common_node_1.exceptions.InvalidParamError('record._id is empty');
72
72
  }
73
73
  recordID = record._id;
74
74
  }
@@ -82,14 +82,14 @@ class _KObjectSync {
82
82
  }
83
83
  return await Request.GetInstance().deleteRecordBySync(this.apiName, recordID, this.authType);
84
84
  }
85
- throw new server_common_node_1.exceptions.InvalidParamError("record must be number or object");
85
+ throw new server_common_node_1.exceptions.InvalidParamError('record must be number or object');
86
86
  }
87
87
  ;
88
88
  async update(_idOrRecordMap, recordMap) {
89
89
  // record 必须包含 _id
90
90
  let record;
91
91
  // 用户显式传入 id 的情况
92
- if (recordMap && typeof _idOrRecordMap === "number") {
92
+ if (recordMap && typeof _idOrRecordMap === 'number') {
93
93
  record = recordMap;
94
94
  record['_id'] = _idOrRecordMap;
95
95
  }
@@ -97,18 +97,18 @@ class _KObjectSync {
97
97
  // 用户隐式传入 id 的情况
98
98
  record = _idOrRecordMap;
99
99
  if (!record._id) {
100
- throw new server_common_node_1.exceptions.InvalidParamError("record._id is empty");
100
+ throw new server_common_node_1.exceptions.InvalidParamError('record._id is empty');
101
101
  }
102
- if (typeof record._id !== "number") {
103
- throw new server_common_node_1.exceptions.InvalidParamError("the type of record._id is not number");
102
+ if (typeof record._id !== 'number') {
103
+ throw new server_common_node_1.exceptions.InvalidParamError('the type of record._id is not number');
104
104
  }
105
105
  }
106
106
  if (!record) {
107
- throw new server_common_node_1.exceptions.InvalidParamError("param is empty");
107
+ throw new server_common_node_1.exceptions.InvalidParamError('param is empty');
108
108
  }
109
109
  let recordID = record['_id'];
110
110
  if (recordID <= 0) {
111
- throw new server_common_node_1.exceptions.InvalidParamError("record._id must greater than 0");
111
+ throw new server_common_node_1.exceptions.InvalidParamError('record._id must greater than 0');
112
112
  }
113
113
  if (this.appCtx && this.appCtx.mode == 'openSDK') {
114
114
  // request from OpenSDK
@@ -123,14 +123,14 @@ class _KObjectSync {
123
123
  async batchCreate(recordMapList) {
124
124
  // 参数校验
125
125
  if (!this.apiName) {
126
- throw new server_common_node_1.exceptions.InvalidParamError("objectApiName is empty");
126
+ throw new server_common_node_1.exceptions.InvalidParamError('objectApiName is empty');
127
127
  }
128
128
  if (!(recordMapList instanceof Array) || recordMapList.length === 0) {
129
- throw new server_common_node_1.exceptions.InvalidParamError("param records is not an array or an empty array");
129
+ throw new server_common_node_1.exceptions.InvalidParamError('param records is not an array or an empty array');
130
130
  }
131
131
  for (let record of recordMapList) {
132
132
  if (server_common_node_1.checkUtils.isNotObject(record)) {
133
- throw new server_common_node_1.exceptions.InvalidParamError("record is not object");
133
+ throw new server_common_node_1.exceptions.InvalidParamError('record is not object');
134
134
  }
135
135
  }
136
136
  let data = (this.appCtx && this.appCtx.mode == 'openSDK') ?
@@ -138,8 +138,8 @@ class _KObjectSync {
138
138
  return await Request.GetInstance().openSDKCreateRecordsBySync(this.apiName, recordMapList);
139
139
  }) : await Request.GetInstance().createRecordsBySync(this.apiName, recordMapList, this.authType);
140
140
  // todo: 确定函数返回值
141
- if (!(data instanceof Array) && data["record_ids"]) {
142
- return data["record_ids"];
141
+ if (!(data instanceof Array) && data.record_ids) {
142
+ return data.record_ids;
143
143
  }
144
144
  return data;
145
145
  }
@@ -147,10 +147,10 @@ class _KObjectSync {
147
147
  async batchDelete(idOrRecordList) {
148
148
  // 参数校验、组装
149
149
  if (!this.apiName) {
150
- throw new server_common_node_1.exceptions.InvalidParamError("objectApiName is empty");
150
+ throw new server_common_node_1.exceptions.InvalidParamError('objectApiName is empty');
151
151
  }
152
152
  if (!(idOrRecordList instanceof Array) || idOrRecordList.length === 0) {
153
- throw new server_common_node_1.exceptions.InvalidParamError("param records is not an array or an empty array");
153
+ throw new server_common_node_1.exceptions.InvalidParamError('param records is not an array or an empty array');
154
154
  }
155
155
  let recordIDs = [];
156
156
  for (let record of idOrRecordList) {
@@ -161,7 +161,7 @@ class _KObjectSync {
161
161
  recordIDs.push(record._id);
162
162
  }
163
163
  else {
164
- throw new server_common_node_1.exceptions.InvalidParamError("record must be number or object");
164
+ throw new server_common_node_1.exceptions.InvalidParamError('record must be number or object');
165
165
  }
166
166
  }
167
167
  if (this.appCtx && this.appCtx.mode == 'openSDK') {
@@ -175,16 +175,16 @@ class _KObjectSync {
175
175
  async batchUpdate(recordMapList) {
176
176
  // 参数校验、组装
177
177
  if (!this.apiName) {
178
- throw new server_common_node_1.exceptions.InvalidParamError("objectApiName is empty");
178
+ throw new server_common_node_1.exceptions.InvalidParamError('objectApiName is empty');
179
179
  }
180
180
  if (!(recordMapList instanceof Array) || recordMapList.length === 0) {
181
- throw new server_common_node_1.exceptions.InvalidParamError("param records is not an array or an empty array");
181
+ throw new server_common_node_1.exceptions.InvalidParamError('param records is not an array or an empty array');
182
182
  }
183
183
  let recordMap = {};
184
184
  for (let record of recordMapList) {
185
185
  let recordID = record['_id'];
186
- if ((typeof recordID !== "number") || recordID <= 0) {
187
- throw new server_common_node_1.exceptions.InvalidParamError("record._id is empty");
186
+ if ((typeof recordID !== 'number') || recordID <= 0) {
187
+ throw new server_common_node_1.exceptions.InvalidParamError('record._id is empty');
188
188
  }
189
189
  recordMap[recordID] = record;
190
190
  }
@@ -214,21 +214,21 @@ class _KObjectAsync {
214
214
  async batchCreateAsync(recordMapList) {
215
215
  // 参数校验
216
216
  if (!this.apiName) {
217
- throw new server_common_node_1.exceptions.InvalidParamError("objectApiName is empty");
217
+ throw new server_common_node_1.exceptions.InvalidParamError('objectApiName is empty');
218
218
  }
219
219
  if (!(recordMapList instanceof Array) || recordMapList.length === 0) {
220
- throw new server_common_node_1.exceptions.InvalidParamError("param records is not an array or an empty array");
220
+ throw new server_common_node_1.exceptions.InvalidParamError('param records is not an array or an empty array');
221
221
  }
222
222
  if (recordMapList.length > 1000) {
223
- throw new server_common_node_1.exceptions.InvalidParamError("more than 1000 records in one operation");
223
+ throw new server_common_node_1.exceptions.InvalidParamError('more than 1000 records in one operation');
224
224
  }
225
225
  for (let record of recordMapList) {
226
226
  if (server_common_node_1.checkUtils.isNotObject(record)) {
227
- throw new server_common_node_1.exceptions.InvalidParamError("record is not object");
227
+ throw new server_common_node_1.exceptions.InvalidParamError('record is not object');
228
228
  }
229
229
  }
230
230
  if (server_common_node_1.utils.stringify(recordMapList).length > 50 * 1024 * 1024) {
231
- throw new server_common_node_1.exceptions.InvalidParamError("parameter records size exceeds 50MB");
231
+ throw new server_common_node_1.exceptions.InvalidParamError('parameter records size exceeds 50MB');
232
232
  }
233
233
  return await Request.GetInstance().createRecordsByAsync(this.apiName, recordMapList, this.authType);
234
234
  }
@@ -236,13 +236,13 @@ class _KObjectAsync {
236
236
  async batchDeleteAsync(recordOrIDList) {
237
237
  // 参数校验、组装
238
238
  if (!this.apiName) {
239
- throw new server_common_node_1.exceptions.InvalidParamError("objectApiName is empty");
239
+ throw new server_common_node_1.exceptions.InvalidParamError('objectApiName is empty');
240
240
  }
241
241
  if (!(recordOrIDList instanceof Array) || recordOrIDList.length === 0) {
242
- throw new server_common_node_1.exceptions.InvalidParamError("param records is not an array or an empty array");
242
+ throw new server_common_node_1.exceptions.InvalidParamError('param records is not an array or an empty array');
243
243
  }
244
244
  if (recordOrIDList.length > 1000) {
245
- throw new server_common_node_1.exceptions.InvalidParamError("more than 1000 records in one operation");
245
+ throw new server_common_node_1.exceptions.InvalidParamError('more than 1000 records in one operation');
246
246
  }
247
247
  let recordIDs = [];
248
248
  for (let record of recordOrIDList) {
@@ -253,41 +253,41 @@ class _KObjectAsync {
253
253
  recordIDs.push(record._id);
254
254
  }
255
255
  else {
256
- throw new server_common_node_1.exceptions.InvalidParamError("record must be number or object");
256
+ throw new server_common_node_1.exceptions.InvalidParamError('record must be number or object');
257
257
  }
258
258
  }
259
259
  if (server_common_node_1.utils.stringify(recordIDs).length > 50 * 1024 * 1024) {
260
- throw new server_common_node_1.exceptions.InvalidParamError("parameter records size exceeds 50MB");
260
+ throw new server_common_node_1.exceptions.InvalidParamError('parameter records size exceeds 50MB');
261
261
  }
262
262
  return await Request.GetInstance().deleteRecordsByAsync(this.apiName, recordIDs, this.authType);
263
263
  }
264
264
  async batchUpdateAsync(recordMapList) {
265
265
  // 参数校验、组装
266
266
  if (!this.apiName) {
267
- throw new server_common_node_1.exceptions.InvalidParamError("objectApiName is empty");
267
+ throw new server_common_node_1.exceptions.InvalidParamError('objectApiName is empty');
268
268
  }
269
269
  if (!(recordMapList instanceof Array) || recordMapList.length === 0) {
270
- throw new server_common_node_1.exceptions.InvalidParamError("param records is not an array or an empty array");
270
+ throw new server_common_node_1.exceptions.InvalidParamError('param records is not an array or an empty array');
271
271
  }
272
272
  if (recordMapList.length > 1000) {
273
- throw new server_common_node_1.exceptions.InvalidParamError("more than 1000 records in one operation");
273
+ throw new server_common_node_1.exceptions.InvalidParamError('more than 1000 records in one operation');
274
274
  }
275
275
  let recordMap = {};
276
276
  for (let record of recordMapList) {
277
277
  let recordID = record['_id'];
278
278
  if (recordID === undefined || recordID === null) {
279
- throw new server_common_node_1.exceptions.InvalidParamError("record._id is empty");
279
+ throw new server_common_node_1.exceptions.InvalidParamError('record._id is empty');
280
280
  }
281
- if (typeof recordID !== "number") {
282
- throw new server_common_node_1.exceptions.InvalidParamError("the type of record._id is not number");
281
+ if (typeof recordID !== 'number') {
282
+ throw new server_common_node_1.exceptions.InvalidParamError('the type of record._id is not number');
283
283
  }
284
284
  if (recordID <= 0) {
285
- throw new server_common_node_1.exceptions.InvalidParamError("record._id must greater than 0");
285
+ throw new server_common_node_1.exceptions.InvalidParamError('record._id must greater than 0');
286
286
  }
287
287
  recordMap[recordID] = record;
288
288
  }
289
289
  if (server_common_node_1.utils.stringify(recordMap).length > 50 * 1024 * 1024) {
290
- throw new server_common_node_1.exceptions.InvalidParamError("parameter records size exceeds 50MB");
290
+ throw new server_common_node_1.exceptions.InvalidParamError('parameter records size exceeds 50MB');
291
291
  }
292
292
  return await Request.GetInstance().updateRecordsByAsync(this.apiName, recordMap, this.authType);
293
293
  }
@@ -373,7 +373,7 @@ class _KQuery {
373
373
  this.authType = authType;
374
374
  }
375
375
  if (!objectApiName) {
376
- throw new server_common_node_1.exceptions.InvalidParamError("objectApiName is empty");
376
+ throw new server_common_node_1.exceptions.InvalidParamError('objectApiName is empty');
377
377
  }
378
378
  queryPropertiesStore.set(this, {
379
379
  apiName: objectApiName,
@@ -417,10 +417,10 @@ class _KQuery {
417
417
  async findAll() {
418
418
  const { queryBuilder, queryV2 } = queryPropertiesStore.get(this);
419
419
  if (queryBuilder.getOrder().length > 0) {
420
- throw new server_common_node_1.exceptions.InvalidParamError("findAll does not support orderBy and orderByDesc");
420
+ throw new server_common_node_1.exceptions.InvalidParamError('findAll does not support orderBy and orderByDesc');
421
421
  }
422
422
  if (queryV2 && queryV2._order.length > 0) {
423
- throw new server_common_node_1.exceptions.InvalidParamError("findAll does not support orderBy and orderByDesc");
423
+ throw new server_common_node_1.exceptions.InvalidParamError('findAll does not support orderBy and orderByDesc');
424
424
  }
425
425
  return await this.getRecordsByPage();
426
426
  }
@@ -485,7 +485,7 @@ class _KQuery {
485
485
  }
486
486
  else {
487
487
  let criterion = (0, logic_1.buildCriterion)(queryBuilder.getLogic(), apiName, maxId);
488
- rs = await Request.GetInstance().getRecordsOrCountByCriterion(apiName, await (0, logic_1.handleCriterion)(criterion), queryBuilder.fuzzySearch, [new order_1.Order("_id", "asc")], false, queryBuilder.getSelect(), 0, newLimit, false, this.authType);
488
+ rs = await Request.GetInstance().getRecordsOrCountByCriterion(apiName, await (0, logic_1.handleCriterion)(criterion), queryBuilder.fuzzySearch, [new order_1.Order('_id', 'asc')], false, queryBuilder.getSelect(), 0, newLimit, false, this.authType);
489
489
  }
490
490
  queryCount += rs.length;
491
491
  rs.forEach((r) => {
@@ -594,7 +594,7 @@ class _KQuery {
594
594
  else {
595
595
  let criterion = (0, logic_1.buildCriterion)(queryBuilder.getLogic(), apiName, maxId);
596
596
  rs = await Request.GetInstance().getRecordsOrCountByCriterion(apiName, await (0, logic_1.handleCriterion)(criterion), null, // FindAll 不再迭代
597
- [new order_1.Order("_id", "asc")], false, queryBuilder.getSelect(), 0, queryBuilder_1.defaultLimit, false, this.authType);
597
+ [new order_1.Order('_id', 'asc')], false, queryBuilder.getSelect(), 0, queryBuilder_1.defaultLimit, false, this.authType);
598
598
  }
599
599
  rs.forEach((r) => {
600
600
  maxId = r._id > maxId ? r._id : maxId;
@@ -763,3 +763,4 @@ function applyMixins(derivedCtor, constructors) {
763
763
  }
764
764
  applyMixins(_KObject, [_KObjectSync, _KObjectAsync, _KObjectQuery]);
765
765
  applyMixins(_KApplicationObject, [_KObjectSync, _KObjectQuery]);
766
+ //# sourceMappingURL=object.js.map