@byted-apaas/server-sdk-node 0.0.2-beta.2 → 0.0.2-beta.5

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 (129) hide show
  1. package/LICENSE +7 -0
  2. package/NOTICE +3 -0
  3. package/application/impl/impl.js +2 -1
  4. package/application/impl/impl.js.map +1 -1
  5. package/constants/constants.js +2 -0
  6. package/constants/constants.js.map +1 -1
  7. package/context/context.js +2 -0
  8. package/context/context.js.map +1 -1
  9. package/context/db/db.js +2 -0
  10. package/context/db/db.js.map +1 -1
  11. package/context/db/impl/IObject.js +2 -0
  12. package/context/db/impl/IObject.js.map +1 -1
  13. package/context/db/impl/object.js +2 -0
  14. package/context/db/impl/object.js.map +1 -1
  15. package/context/db/impl/oql/ioql.js +2 -0
  16. package/context/db/impl/oql/ioql.js.map +1 -1
  17. package/context/db/impl/oql/oql.js +2 -0
  18. package/context/db/impl/oql/oql.js.map +1 -1
  19. package/context/db/impl/order.js +2 -0
  20. package/context/db/impl/order.js.map +1 -1
  21. package/context/db/impl/propertiesStore.js +2 -0
  22. package/context/db/impl/propertiesStore.js.map +1 -1
  23. package/context/db/impl/queryBuilder.js +2 -0
  24. package/context/db/impl/queryBuilder.js.map +1 -1
  25. package/context/db/impl/transaction/index.js +2 -0
  26. package/context/db/impl/transaction/index.js.map +1 -1
  27. package/context/db/impl/transaction.js +2 -0
  28. package/context/db/impl/transaction.js.map +1 -1
  29. package/context/globalConfig/globalConfig.js +2 -0
  30. package/context/globalConfig/globalConfig.js.map +1 -1
  31. package/context/metadata/components/common.js +2 -0
  32. package/context/metadata/components/common.js.map +1 -1
  33. package/context/metadata/components/components.js +2 -0
  34. package/context/metadata/components/components.js.map +1 -1
  35. package/context/metadata/components/desktop/recordDetail.js +2 -0
  36. package/context/metadata/components/desktop/recordDetail.js.map +1 -1
  37. package/context/metadata/components/mobile/list.js +2 -0
  38. package/context/metadata/components/mobile/list.js.map +1 -1
  39. package/context/metadata/metadata.js +2 -0
  40. package/context/metadata/metadata.js.map +1 -1
  41. package/context/metadata/objects/fields.js +2 -0
  42. package/context/metadata/objects/fields.js.map +1 -1
  43. package/context/metadata/objects/objects.js +2 -0
  44. package/context/metadata/objects/objects.js.map +1 -1
  45. package/context/metadata/types/common.js +2 -0
  46. package/context/metadata/types/common.js.map +1 -1
  47. package/context/metadata/types/components.js +2 -0
  48. package/context/metadata/types/components.js.map +1 -1
  49. package/context/metadata/types/objects.js +2 -0
  50. package/context/metadata/types/objects.js.map +1 -1
  51. package/context/msg/msg.js +2 -0
  52. package/context/msg/msg.js.map +1 -1
  53. package/context/resources/impl/resources.js +2 -0
  54. package/context/resources/impl/resources.js.map +1 -1
  55. package/kunlun/kunlun.js +2 -0
  56. package/kunlun/kunlun.js.map +1 -1
  57. package/kunlun/operator/IOperator.js +2 -0
  58. package/kunlun/operator/IOperator.js.map +1 -1
  59. package/kunlun/operator/impl/expression.js +2 -0
  60. package/kunlun/operator/impl/expression.js.map +1 -1
  61. package/kunlun/operator/impl/logic.js +2 -0
  62. package/kunlun/operator/impl/logic.js.map +1 -1
  63. package/kunlun/operator/impl/operator.js +2 -0
  64. package/kunlun/operator/impl/operator.js.map +1 -1
  65. package/lib/core.js +2 -0
  66. package/lib/core.js.map +1 -1
  67. package/package.json +3 -14
  68. package/request/innerapi.js +4 -2
  69. package/request/innerapi.js.map +1 -1
  70. package/request/interface.js +2 -0
  71. package/request/interface.js.map +1 -1
  72. package/request/openapi.js +2 -0
  73. package/request/openapi.js.map +1 -1
  74. package/types/types.js +2 -0
  75. package/types/types.js.map +1 -1
  76. package/LICENSE.md +0 -0
  77. package/application/application.ts +0 -40
  78. package/application/function/function.ts +0 -37
  79. package/application/impl/common.ts +0 -50
  80. package/application/impl/impl.ts +0 -48
  81. package/constants/constants.ts +0 -12
  82. package/context/context.ts +0 -127
  83. package/context/db/db.ts +0 -77
  84. package/context/db/impl/IObject.ts +0 -244
  85. package/context/db/impl/db.ts +0 -95
  86. package/context/db/impl/object.ts +0 -628
  87. package/context/db/impl/oql/ioql.ts +0 -6
  88. package/context/db/impl/oql/oql.ts +0 -22
  89. package/context/db/impl/order.ts +0 -16
  90. package/context/db/impl/propertiesStore.ts +0 -28
  91. package/context/db/impl/queryBuilder.ts +0 -103
  92. package/context/db/impl/transaction/index.ts +0 -337
  93. package/context/db/impl/transaction/operation.ts +0 -72
  94. package/context/db/impl/transaction.ts +0 -76
  95. package/context/globalConfig/globalConfig.ts +0 -11
  96. package/context/metadata/components/common.ts +0 -19
  97. package/context/metadata/components/components.ts +0 -19
  98. package/context/metadata/components/desktop/list.ts +0 -457
  99. package/context/metadata/components/desktop/recordDetail.ts +0 -64
  100. package/context/metadata/components/mobile/list.ts +0 -176
  101. package/context/metadata/metadata.ts +0 -175
  102. package/context/metadata/objects/fields.ts +0 -454
  103. package/context/metadata/objects/fields.util.ts +0 -360
  104. package/context/metadata/objects/objects.ts +0 -27
  105. package/context/metadata/types/common.ts +0 -10
  106. package/context/metadata/types/components.ts +0 -105
  107. package/context/metadata/types/objects.ts +0 -251
  108. package/context/msg/msg.ts +0 -49
  109. package/context/resources/IResources.ts +0 -73
  110. package/context/resources/impl/resources.ts +0 -170
  111. package/context/tasks/tasks.ts +0 -159
  112. package/data/index.ts +0 -30
  113. package/hooks/api.ts +0 -341
  114. package/hooks/hooks.ts +0 -100
  115. package/kunlun/kunlun.ts +0 -69
  116. package/kunlun/operator/IOperator.ts +0 -163
  117. package/kunlun/operator/impl/expression.ts +0 -71
  118. package/kunlun/operator/impl/logic.ts +0 -595
  119. package/kunlun/operator/impl/logicV2.ts +0 -254
  120. package/kunlun/operator/impl/operator.ts +0 -255
  121. package/kunlun/operator/impl/operatorV2.ts +0 -249
  122. package/lib/core.ts +0 -4
  123. package/request/common.ts +0 -91
  124. package/request/constants.ts +0 -25
  125. package/request/faasinfra.ts +0 -393
  126. package/request/innerapi.ts +0 -1645
  127. package/request/interface.ts +0 -166
  128. package/request/openapi.ts +0 -1220
  129. package/types/types.ts +0 -105
@@ -1,244 +0,0 @@
1
- import { _Cond, _Record, _WhereCond } from '../../../types/types'
2
-
3
- export interface _IKAllEndpoint<T> extends _IKSyncEndpoint<T>, _IKAsyncEndpoint<T> { };
4
-
5
- export interface _IKSyncEndpoint<T> {
6
- /**
7
- * 创建记录
8
- * @param recordMap 用于创建的一条记录
9
- * @paramExample {_name: "John", age: 19, gender: "male"}
10
- * @example
11
- * ```
12
- * context.db.object("_department").create({
13
- * _name: new kunlun.type.Multilingual({ zh: "部门" }),
14
- * _manager: { _id: 1660000000 },
15
- * _status: "_active"
16
- * })
17
- * ```
18
- */
19
- create(recordMap: _Cond<T>): Promise<{ _id: number }>;
20
- /**
21
- * 删除记录
22
- * @param recordID 用于删除的一条记录的 ID
23
- * @example
24
- * ```
25
- * context.db.object("_user").delete(123456789123)
26
- * ```
27
- */
28
- delete(recordID: number): Promise<void>;
29
- /**
30
- * 删除记录
31
- * @param record 用于删除的一条完整记录
32
- * @example
33
- * ```
34
- * context.db.object("_user").delete(context.targetRecord.original)
35
- * ```
36
- */
37
- delete(record: _Cond<T>): Promise<void>;
38
- /**
39
- * 指定 _id 后,更新对应记录
40
- * @param _id 主键
41
- * @param recordMap 用于更新的一条记录
42
- * @paramExample {_name: "John", age: 19, gender: "male"}
43
- * @example
44
- * ```
45
- * context.db.object("_user").update(1660000000, {
46
- * gender: "male"
47
- * })
48
- * ```
49
- */
50
- update(_id: number, recordMap: _Cond<T>): Promise<void>;
51
- /**
52
- * 指定 _id 后,更新对应记录
53
- * @param recordMap 用于更新的一条记录,需对 _id 赋值
54
- * @paramExample {_id: 1660000000, _name: "John", age: 19, gender: "male"}
55
- * @example
56
- * ```
57
- * context.db.object("_user").update({
58
- * _id: 1660000000,
59
- * gender: "male"
60
- * })
61
- * ```
62
- */
63
- update(recordMap: _Cond<T>): Promise<void>;
64
- /**
65
- * 批量创建记录
66
- * @param recordMapList 多条用于创建的记录数据组成的数组
67
- * @paramExample [{_name: "John", age: 19, gender: "male"}, {_name: "Alis", age: 16, gender: "female"}]
68
- */
69
- batchCreate(recordMapList: _Cond<T>[]): Promise<number[]>;
70
- /**
71
- * 批量删除记录
72
- * @param recordIdList 多个用于删除的记录 ID 组成的数组
73
- * @paramExample [1001, 1002, 1003]
74
- */
75
- batchDelete(recordIdList: number[]): Promise<void>;
76
- /**
77
- * 批量删除记录
78
- * @param recordList 多条用于删除的记录数据组成的数组,记录数据需对 _id 赋值
79
- * @paramExample [{_id: 1001, _name: "John", gender: "male"}, {_id: 1002, _name: "Alis", gender: "female"}]
80
- */
81
- batchDelete(recordList: _Cond<T>[]): Promise<void>;
82
- /**
83
- * 根据 _id 批量更新记录
84
- * @param recordMapList 多条用于更新的记录数据组成的数组,记录数据需对 _id 赋值
85
- * @paramExample [{_id: 1001, _name: "John", gender: "male"}, {_id: 1002, _name: "Alis", gender: "female"}]
86
- */
87
- batchUpdate(recordMapList: _Cond<T>[]): Promise<void>;
88
- }
89
-
90
- export interface _IKAsyncEndpoint<T> {
91
- /**
92
- * 批量创建记录(为异步任务)
93
- * @param recordMapList 用于创建的多条记录
94
- * @paramExample [{_name: "John", age: 19, gender: "male"}, {_name: "Alis", age: 16, gender: "female"}]
95
- */
96
- batchCreateAsync(recordMapList: _Cond<T>[]): Promise<{ taskID: number }>;
97
- /**
98
- * 批量删除记录(为异步任务)
99
- * @param recordIDList 用于删除的多条记录的 ID 列表
100
- */
101
- batchDeleteAsync(recordIDList: number[]): Promise<{ taskID: number }>;
102
- /**
103
- * 批量删除记录(为异步任务)
104
- * @param recordList 用于删除的多条完整记录的列表
105
- */
106
- batchDeleteAsync(recordList: _Cond<T>[]): Promise<{ taskID: number }>;
107
- /**
108
- * 根据 _id 批量更新记录(为异步任务)
109
- * @param recordMapList 用于更新的多条记录,需对 _id 赋值
110
- * @paramExample [{_id: 1001, _name: "John", gender: "male"}, {_id: 1002, _name: "Alis", gender: "female"}]
111
- */
112
- batchUpdateAsync(recordMapList: _Cond<T>[]): Promise<{ taskID: number }>;
113
- }
114
-
115
- export interface _IKQuery<T> {
116
- /**
117
- * 无需入参,返回全部符合条件的记录
118
- * @example
119
- * ```
120
- * context.db.object("_user").where({
121
- * gender: "male"
122
- * }).findAll()
123
- * ```
124
- */
125
- findAll(): Promise<_Record<T>[]>;
126
- /**
127
- * 无需入参,返回符合条件的记录,单次返回 200 条
128
- * @example
129
- * ```
130
- * context.db.object("_user").where({
131
- * gender: "male"
132
- * }).find()
133
- * ```
134
- */
135
- find(): Promise<_Record<T>[]>;
136
- /**
137
- * 无需入参,返回排在第一位的记录
138
- * @example
139
- * ```
140
- * context.db.object("_user").where({
141
- * gender: "male"
142
- * }).findOne()
143
- * ```
144
- */
145
- findOne(): Promise<_Record<T>>;
146
- /**
147
- * 根据指定字段升序排序(a -> z, 0 -> 9)
148
- * @param fieldApiNames 排序依据的字段数组,按先后顺序确定优先级
149
- * @example
150
- * ```
151
- * context.db.object("_user").orderBy(["_email", "_phoneNumber"]).find()
152
- * ```
153
- */
154
- orderBy<K extends keyof T>(fieldApiNames: K[]): _IKQuery<T>;
155
- /**
156
- * 根据指定字段升序排序(a -> z, 0 -> 9)
157
- * @param fieldApiNames 排序依据的字段,按先后顺序确定优先级,用逗号分隔
158
- * @example
159
- * ```
160
- * context.db.object("_user").orderBy("_email", "_phoneNumber").find()
161
- * ```
162
- */
163
- orderBy<K extends keyof T>(...fieldApiNames: K[]): _IKQuery<T>;
164
- /**
165
- * 根据指定字段降序排序(z -> a, 9 -> 0)
166
- * @param fieldApiNames 排序依据的字段数组,按先后顺序确定优先级
167
- * @example
168
- * ```
169
- * context.db.object("_user").orderByDesc("_email", "_phoneNumber").find()
170
- * ```
171
- */
172
- orderByDesc<K extends keyof T>(fieldApiNames: K[]): _IKQuery<T>;
173
- /**
174
- * 根据指定字段降序排序(z -> a, 9 -> 0)
175
- * @param fieldApiNames 排序依据的字段,按先后顺序确定优先级,用逗号分隔
176
- * @example
177
- * ```
178
- * context.db.object("_user").orderByDesc("_email", "_phoneNumber").find()
179
- * ```
180
- */
181
- orderByDesc<K extends keyof T>(...fieldApiNames: K[]): _IKQuery<T>;
182
- /**
183
- * 指定需返回的字段
184
- * @param fieldApiNames 需返回的字段数组
185
- * @example
186
- * ```
187
- * context.db.object("_user").select(["_name", "_email"]).find()
188
- * ```
189
- */
190
- select<K extends keyof T>(fieldApiNames: K[]): _IKQuery<T>;
191
- /**
192
- * 指定需返回的字段
193
- * @param fieldApiNames 需返回的字段,用逗号分隔
194
- * @example
195
- * ```
196
- * context.db.object("_user").select("_name", "_email").find()
197
- * ```
198
- */
199
- select<K extends keyof T>(...fieldApiNames: K[]): _IKQuery<T>;
200
- /**
201
- * 设置查询条件
202
- * @param conditionMap 对字段赋值以指定查询筛选条件
203
- * @paramExample {gender: "male"}
204
- * @example
205
- * ```
206
- * context.db.object("_user").where({
207
- * gender: "male"
208
- * }).find()
209
- * ```
210
- */
211
- where(conditionMap: _WhereCond<T>): _IKQuery<T>;
212
- /**
213
- * 设置查询条件
214
- */
215
- where(): _IKQuery<T>;
216
- /**
217
- * 指定分页查询的数量
218
- * @param limit 分页查询的数量
219
- * @paramExample 10
220
- * @example
221
- * ```
222
- * context.db.object("_user").limit(10)
223
- * ```
224
- */
225
- limit(limit: number): _IKQuery<T>;
226
- /**
227
- * 指定分页查询的偏移量
228
- * @param offset 分页查询的偏移量
229
- * @paramExample 0
230
- * @example
231
- * ```
232
- * context.db.object("_user").offset(0)
233
- * ```
234
- */
235
- offset(offset: number): _IKQuery<T>;
236
- /**
237
- * 指定条件的行数
238
- * @example
239
- * ```
240
- * context.db.object("_user").count()
241
- * ```
242
- */
243
- count(): Promise<number>;
244
- }
@@ -1,95 +0,0 @@
1
- import { _KObject, _KApplicationObject } from './object'
2
- import { _IKAllEndpoint, _IKSyncEndpoint, _IKQuery } from './IObject'
3
- import { ITransactionGetter } from './transaction'
4
- import { IDB, IDBSync, IDBWithCurrentObject } from '../db'
5
- import { currentObjApiName, metadataMap } from '../../../data/index'
6
- import { exceptions } from '@byted-apaas/server-common-node'
7
- import { Transaction } from './transaction/index'
8
- import { IOql } from "./oql/ioql";
9
- import { Oql } from "./oql/oql";
10
- import { AppCtx } from "../../../application/application";
11
-
12
- export class DB<T, mt = metadataMap> implements IDB<T, mt> {
13
- objectApiName: string
14
-
15
- constructor(objectApiName?: string) {
16
- this.objectApiName = objectApiName
17
- }
18
-
19
- /**
20
- * 操作指定对象的记录数据
21
- * @param objectApiName 指定对象的 ApiName
22
- * @example
23
- * ```
24
- * context.db.object("_user").where({
25
- * gender: "male"
26
- * }).find()
27
- * ```
28
- */
29
- object<K extends keyof mt>(objectApiName: K): _IKAllEndpoint<mt[K]> & _IKQuery<mt[K]> {
30
- return new _KObject<mt[K]>(objectApiName as string)
31
- };
32
-
33
- /**
34
- * 创建一个新的空事务
35
- * @example
36
- * ```
37
- * let tx = context.db.newTransaction();
38
- * let user = tx.object("_user").registerCreate({
39
- * _name: new kunlun.type.Multilingual({ zh: "用户1", en: "user1" }),
40
- * });
41
- * let contract = tx.object("contract").registerCreate({
42
- * _name: new kunlun.type.Multilingual({ zh: "用户1的合同", en: "user1's contract" }),
43
- * user: {id: user._id}
44
- * });
45
- * await tx.commit();
46
- * ```
47
- */
48
- newTransaction(): ITransactionGetter<T, mt> {
49
- return new Transaction(this.objectApiName) as unknown as ITransactionGetter<T, mt>
50
- };
51
-
52
- /**
53
- * OQL 操作
54
- * @param oql 指定 OQL 语句
55
- * @example
56
- * ```
57
- * let users = await context.db.oql("select _email from _user").execute();
58
- * ```
59
- */
60
- oql(oql: string): IOql {
61
- return new Oql(oql);
62
- }
63
- }
64
-
65
- export class DBWithCurrentObject<T, mt = metadataMap> extends DB<T, mt> implements IDB<T, mt>, IDBWithCurrentObject<T, mt> {
66
- /**
67
- * 无需入参,操作当前对象的记录数据
68
- */
69
- // @ts-ignore
70
- currentObject(): _IKAllEndpoint<mt[currentObjApiName]> & _IKQuery<mt[currentObjApiName]> {
71
- if (!this.objectApiName) {
72
- throw new exceptions.InternalError(`context.objectApiName is empty`);
73
- }
74
- return new _KObject(this.objectApiName);
75
- };
76
-
77
- constructor(objectApiName: string) {
78
- super(objectApiName)
79
- }
80
- }
81
-
82
- /**
83
- * ApplicationDB: 用于支持 OpenSDK 相关能力的 DB 相关类,目前仅实现 DB 同步操作接口
84
- */
85
- export class ApplicationDB implements IDBSync {
86
- appCtx: AppCtx
87
-
88
- constructor(appCtx: AppCtx) {
89
- this.appCtx = appCtx
90
- }
91
-
92
- object(objectApiName: string): _IKSyncEndpoint<{}> & _IKQuery<{}> {
93
- return new _KApplicationObject(objectApiName, this.appCtx);
94
- }
95
- }