@byted-apaas/server-sdk-node 1.1.18-beta.3 → 1.1.18-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.
- package/context/db/db.d.ts +2 -1
- package/context/db/impl/IObjectV3.d.ts +253 -0
- package/context/db/impl/IObjectV3.js +5 -0
- package/context/db/impl/dbV3.d.ts +2 -2
- package/context/db/impl/object.d.ts +5 -3
- package/context/db/impl/object.js +0 -1
- package/context/metadata/metadata.d.ts +3 -3
- package/context/metadata/metadata.js +5 -5
- package/global/global.d.ts +5 -5
- package/hooks/hooks.js +2 -2
- package/package.json +1 -1
- package/request/interface.d.ts +1 -0
- package/request/openapi.d.ts +3 -0
- package/request/openapi.js +91 -1
package/context/db/db.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { _IKAllEndpoint, _IKSyncEndpoint, _IKQuery } from './impl/IObject';
|
|
2
2
|
import { ITransactionGetter } from './impl/transaction';
|
|
3
3
|
import { IOql } from './impl/oql/ioql';
|
|
4
|
+
import { _IKAllEndpointV3, _IKQueryV3 } from './impl/IObjectV3';
|
|
4
5
|
/**
|
|
5
6
|
* IDBGetter 是声明 DB interface 的顶级入口
|
|
6
7
|
*/
|
|
@@ -74,7 +75,7 @@ export interface IDBV3<T, mt> {
|
|
|
74
75
|
* }).find()
|
|
75
76
|
* ```
|
|
76
77
|
*/
|
|
77
|
-
object<T extends keyof mt>(objectApiName: T):
|
|
78
|
+
object<T extends keyof mt>(objectApiName: T): _IKAllEndpointV3<mt[T]> & _IKQueryV3<mt[T]>;
|
|
78
79
|
/**
|
|
79
80
|
* 创建一个新的空事务
|
|
80
81
|
* @example
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
import { _Cond, _Record, _WhereCond } from '../../../types/types';
|
|
2
|
+
import { BatchResult } from "../../../common/structs";
|
|
3
|
+
export interface _IKAllEndpointV3<T> extends _IKSyncEndpointV3<T>, _IKAsyncEndpointV3<T> {
|
|
4
|
+
}
|
|
5
|
+
export interface _IKSyncEndpointV3<T> {
|
|
6
|
+
/**
|
|
7
|
+
* 创建记录
|
|
8
|
+
* @param recordMap 用于创建的一条记录
|
|
9
|
+
* @paramExample {_name: 'John', age: 19, gender: 'male'}
|
|
10
|
+
* @example
|
|
11
|
+
* ```
|
|
12
|
+
* application.data.object('_department').create({
|
|
13
|
+
* _name: new application.constants.type.Multilingual({ zh: '部门' }),
|
|
14
|
+
* _manager: { _id: 1660000000 },
|
|
15
|
+
* _status: '_active'
|
|
16
|
+
* })
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
create(recordMap: _Cond<T>): Promise<{
|
|
20
|
+
_id: number | string;
|
|
21
|
+
}>;
|
|
22
|
+
/**
|
|
23
|
+
* 删除记录
|
|
24
|
+
* @param recordID 用于删除的一条记录的 ID
|
|
25
|
+
* @example
|
|
26
|
+
* ```
|
|
27
|
+
* application.data.object('_user').delete(123456789123)
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
delete(recordID: number | string): Promise<void>;
|
|
31
|
+
/**
|
|
32
|
+
* 删除记录
|
|
33
|
+
* @param record 用于删除的一条完整记录
|
|
34
|
+
* @example
|
|
35
|
+
* ```
|
|
36
|
+
* application.data.object('_user').delete(context.targetRecord.original)
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
delete(record: _Cond<T>): Promise<void>;
|
|
40
|
+
/**
|
|
41
|
+
* 指定 _id 后,更新对应记录
|
|
42
|
+
* @param _id 主键
|
|
43
|
+
* @param recordMap 用于更新的一条记录
|
|
44
|
+
* @paramExample {_name: 'John', age: 19, gender: 'male'}
|
|
45
|
+
* @example
|
|
46
|
+
* ```
|
|
47
|
+
* application.data.object('_user').update(1660000000, {
|
|
48
|
+
* gender: 'male'
|
|
49
|
+
* })
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
update(_id: number | string, recordMap: _Cond<T>): Promise<void>;
|
|
53
|
+
/**
|
|
54
|
+
* 指定 _id 后,更新对应记录
|
|
55
|
+
* @param recordMap 用于更新的一条记录,需对 _id 赋值
|
|
56
|
+
* @paramExample {_id: 1660000000, _name: 'John', age: 19, gender: 'male'}
|
|
57
|
+
* @example
|
|
58
|
+
* ```
|
|
59
|
+
* application.data.object('_user').update({
|
|
60
|
+
* _id: 1660000000,
|
|
61
|
+
* gender: 'male'
|
|
62
|
+
* })
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
update(recordMap: _Cond<T>): Promise<void>;
|
|
66
|
+
/**
|
|
67
|
+
* 批量创建记录
|
|
68
|
+
* @param recordMapList 多条用于创建的记录数据组成的数组
|
|
69
|
+
* @paramExample [{_name: 'John', age: 19, gender: 'male'}, {_name: 'Alis', age: 16, gender: 'female'}]
|
|
70
|
+
*/
|
|
71
|
+
batchCreate(recordMapList: _Cond<T>[]): Promise<number[]>;
|
|
72
|
+
/**
|
|
73
|
+
* 批量删除记录
|
|
74
|
+
* @param recordIdList 多个用于删除的记录 ID 组成的数组
|
|
75
|
+
* @paramExample [1001, 1002, 1003]
|
|
76
|
+
*/
|
|
77
|
+
batchDelete(recordIdList: number[] | string[]): Promise<BatchResult>;
|
|
78
|
+
/**
|
|
79
|
+
* 批量删除记录
|
|
80
|
+
* @param recordList 多条用于删除的记录数据组成的数组,记录数据需对 _id 赋值
|
|
81
|
+
* @paramExample [{_id: 1001, _name: 'John', gender: 'male'}, {_id: 1002, _name: 'Alis', gender: 'female'}]
|
|
82
|
+
*/
|
|
83
|
+
batchDelete(recordList: _Cond<T>[]): Promise<BatchResult>;
|
|
84
|
+
/**
|
|
85
|
+
* 根据 _id 批量更新记录
|
|
86
|
+
* @param recordMapList 多条用于更新的记录数据组成的数组,记录数据需对 _id 赋值
|
|
87
|
+
* @paramExample [{_id: 1001, _name: 'John', gender: 'male'}, {_id: 1002, _name: 'Alis', gender: 'female'}]
|
|
88
|
+
*/
|
|
89
|
+
batchUpdate(recordMapList: _Cond<T>[]): Promise<BatchResult>;
|
|
90
|
+
/**
|
|
91
|
+
* 用户级鉴权
|
|
92
|
+
*/
|
|
93
|
+
useUserAuth(): this;
|
|
94
|
+
/**
|
|
95
|
+
* 系统级鉴权
|
|
96
|
+
*/
|
|
97
|
+
useSystemAuth(): this;
|
|
98
|
+
}
|
|
99
|
+
export interface _IKAsyncEndpointV3<T> {
|
|
100
|
+
}
|
|
101
|
+
export interface _IKQueryV3<T> {
|
|
102
|
+
/**
|
|
103
|
+
* 遍历全部符合条件的记录
|
|
104
|
+
* 注:
|
|
105
|
+
* 如果未设置排序字段,默认以 _id 增序查询;
|
|
106
|
+
* 如果有设置排序字段,必须设置具有唯一属性的字段,否则会有数据重复的风险;
|
|
107
|
+
* @param handler 业务处理函数
|
|
108
|
+
* @param pageLimit 分页查询的数量,可选参数,默认值为 200,
|
|
109
|
+
* @example
|
|
110
|
+
* ```
|
|
111
|
+
* await application.data.object('_user').findStream(async (records) => {
|
|
112
|
+
* // doSomething ...
|
|
113
|
+
* }, 300);
|
|
114
|
+
* ```
|
|
115
|
+
*/
|
|
116
|
+
findStream: (handler: (records: object[]) => Promise<void>, pageLimit?: number) => Promise<void>;
|
|
117
|
+
/**
|
|
118
|
+
* 无需入参,返回符合条件的记录,单次返回 200 条
|
|
119
|
+
* @example
|
|
120
|
+
* ```
|
|
121
|
+
* application.data.object('_user').where({
|
|
122
|
+
* gender: 'male'
|
|
123
|
+
* }).find()
|
|
124
|
+
* ```
|
|
125
|
+
*/
|
|
126
|
+
find(): Promise<_Record<T>[]>;
|
|
127
|
+
/**
|
|
128
|
+
* 无需入参,返回排在第一位的记录
|
|
129
|
+
* @example
|
|
130
|
+
* ```
|
|
131
|
+
* application.data.object('_user').where({
|
|
132
|
+
* gender: 'male'
|
|
133
|
+
* }).findOne()
|
|
134
|
+
* ```
|
|
135
|
+
*/
|
|
136
|
+
findOne(): Promise<_Record<T>>;
|
|
137
|
+
/**
|
|
138
|
+
* 根据指定字段升序排序(a -> z, 0 -> 9)
|
|
139
|
+
* @param fieldApiNames 排序依据的字段数组,按先后顺序确定优先级
|
|
140
|
+
* @example
|
|
141
|
+
* ```
|
|
142
|
+
* application.data.object('_user').orderBy(['_email', '_phoneNumber']).find()
|
|
143
|
+
* ```
|
|
144
|
+
*/
|
|
145
|
+
orderBy<K extends keyof T>(fieldApiNames: K[]): Omit<_IKQueryV3<T>, 'findAll'>;
|
|
146
|
+
/**
|
|
147
|
+
* 根据指定字段升序排序(a -> z, 0 -> 9)
|
|
148
|
+
* @param fieldApiNames 排序依据的字段,按先后顺序确定优先级,用逗号分隔
|
|
149
|
+
* @example
|
|
150
|
+
* ```
|
|
151
|
+
* application.data.object('_user').orderBy('_email', '_phoneNumber').find()
|
|
152
|
+
* ```
|
|
153
|
+
*/
|
|
154
|
+
orderBy<K extends keyof T>(...fieldApiNames: K[]): Omit<_IKQueryV3<T>, 'findAll'>;
|
|
155
|
+
/**
|
|
156
|
+
* 根据指定字段降序排序(z -> a, 9 -> 0)
|
|
157
|
+
* @param fieldApiNames 排序依据的字段数组,按先后顺序确定优先级
|
|
158
|
+
* @example
|
|
159
|
+
* ```
|
|
160
|
+
* application.data.object('_user').orderByDesc('_email', '_phoneNumber').find()
|
|
161
|
+
* ```
|
|
162
|
+
*/
|
|
163
|
+
orderByDesc<K extends keyof T>(fieldApiNames: K[]): Omit<_IKQueryV3<T>, 'findAll'>;
|
|
164
|
+
/**
|
|
165
|
+
* 根据指定字段降序排序(z -> a, 9 -> 0)
|
|
166
|
+
* @param fieldApiNames 排序依据的字段,按先后顺序确定优先级,用逗号分隔
|
|
167
|
+
* @example
|
|
168
|
+
* ```
|
|
169
|
+
* application.data.object('_user').orderByDesc('_email', '_phoneNumber').find()
|
|
170
|
+
* ```
|
|
171
|
+
*/
|
|
172
|
+
orderByDesc<K extends keyof T>(...fieldApiNames: K[]): Omit<_IKQueryV3<T>, 'findAll'>;
|
|
173
|
+
/**
|
|
174
|
+
* 指定需返回的字段
|
|
175
|
+
* @param fieldApiNames 需返回的字段数组
|
|
176
|
+
* @example
|
|
177
|
+
* ```
|
|
178
|
+
* application.data.object('_user').select(['_name', '_email']).find()
|
|
179
|
+
* ```
|
|
180
|
+
*/
|
|
181
|
+
select<K extends keyof T>(fieldApiNames: K[]): Omit<_IKQueryV3<T>, 'findAll'>;
|
|
182
|
+
/**
|
|
183
|
+
* 指定需返回的字段
|
|
184
|
+
* @param fieldApiNames 需返回的字段,用逗号分隔
|
|
185
|
+
* @example
|
|
186
|
+
* ```
|
|
187
|
+
* application.data.object('_user').select('_name', '_email').find()
|
|
188
|
+
* ```
|
|
189
|
+
*/
|
|
190
|
+
select<K extends keyof T>(...fieldApiNames: K[]): Omit<_IKQueryV3<T>, 'findAll'>;
|
|
191
|
+
/**
|
|
192
|
+
* 设置查询条件
|
|
193
|
+
* @param conditionMap 对字段赋值以指定查询筛选条件
|
|
194
|
+
* @paramExample {gender: 'male'}
|
|
195
|
+
* @example
|
|
196
|
+
* ```
|
|
197
|
+
* application.data.object('_user').where({
|
|
198
|
+
* gender: 'male'
|
|
199
|
+
* }).find()
|
|
200
|
+
* ```
|
|
201
|
+
*/
|
|
202
|
+
where(conditionMap: _WhereCond<T>): Omit<_IKQueryV3<T>, 'findAll'>;
|
|
203
|
+
/**
|
|
204
|
+
* 设置查询条件
|
|
205
|
+
*/
|
|
206
|
+
where(): Omit<_IKQueryV3<T>, 'findAll'>;
|
|
207
|
+
/**
|
|
208
|
+
* 模糊查询:与 where 之间是与关系
|
|
209
|
+
* @param keyword 模糊查询的关键字,必填且不可以为空串
|
|
210
|
+
* @param fieldAPINames 『可搜索字段』的字段列表,不可为空
|
|
211
|
+
* @example
|
|
212
|
+
* ```
|
|
213
|
+
* application.data.object('_user').fuzzySearch('张三', ['_name']).find()
|
|
214
|
+
* ```
|
|
215
|
+
*/
|
|
216
|
+
fuzzySearch(keyword: string, fieldAPINames: string[]): Omit<_IKQueryV3<T>, 'findAll'>;
|
|
217
|
+
/**
|
|
218
|
+
* 指定分页查询的数量
|
|
219
|
+
* @param limit 分页查询的数量
|
|
220
|
+
* @paramExample 10
|
|
221
|
+
* @example
|
|
222
|
+
* ```
|
|
223
|
+
* application.data.object('_user').limit(10)
|
|
224
|
+
* ```
|
|
225
|
+
*/
|
|
226
|
+
limit(limit: number): Omit<_IKQueryV3<T>, 'findAll'>;
|
|
227
|
+
/**
|
|
228
|
+
* 指定分页查询的偏移量
|
|
229
|
+
* @param offset 分页查询的偏移量
|
|
230
|
+
* @paramExample 0
|
|
231
|
+
* @example
|
|
232
|
+
* ```
|
|
233
|
+
* application.data.object('_user').offset(0)
|
|
234
|
+
* ```
|
|
235
|
+
*/
|
|
236
|
+
offset(offset: number): Omit<_IKQueryV3<T>, 'findAll'>;
|
|
237
|
+
/**
|
|
238
|
+
* 指定条件的行数
|
|
239
|
+
* @example
|
|
240
|
+
* ```
|
|
241
|
+
* application.data.object('_user').count()
|
|
242
|
+
* ```
|
|
243
|
+
*/
|
|
244
|
+
count(): Promise<number>;
|
|
245
|
+
/**
|
|
246
|
+
* 用户级鉴权
|
|
247
|
+
*/
|
|
248
|
+
useUserAuth(): this;
|
|
249
|
+
/**
|
|
250
|
+
* 系统级鉴权
|
|
251
|
+
*/
|
|
252
|
+
useSystemAuth(): this;
|
|
253
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { _IKAllEndpoint, _IKQuery } from './IObject';
|
|
2
1
|
import { IDBV3 } from '../db';
|
|
3
2
|
import { metadataMap } from '../../../data/index';
|
|
4
3
|
import { IOql } from './oql/ioql';
|
|
4
|
+
import { _IKAllEndpointV3, _IKQueryV3 } from './IObjectV3';
|
|
5
5
|
export declare class DBV3<T, mt = metadataMap> implements IDBV3<T, mt> {
|
|
6
6
|
objectApiName: string;
|
|
7
7
|
constructor(objectApiName?: string);
|
|
@@ -15,7 +15,7 @@ export declare class DBV3<T, mt = metadataMap> implements IDBV3<T, mt> {
|
|
|
15
15
|
* }).find()
|
|
16
16
|
* ```
|
|
17
17
|
*/
|
|
18
|
-
object<K extends keyof mt>(objectApiName: K):
|
|
18
|
+
object<K extends keyof mt>(objectApiName: K): _IKAllEndpointV3<mt[K]> & _IKQueryV3<mt[K]>;
|
|
19
19
|
/**
|
|
20
20
|
* 创建一个新的空事务
|
|
21
21
|
* @example
|
|
@@ -2,6 +2,7 @@ import { _Cond, _Record, _WhereCond } from '../../../types/types';
|
|
|
2
2
|
import { _IKAsyncEndpoint, _IKQuery, _IKSyncEndpoint } from './IObject';
|
|
3
3
|
import { AppCtx } from '../../../application/application';
|
|
4
4
|
import { BatchResult } from '../../../common/structs';
|
|
5
|
+
import { _IKQueryV3, _IKSyncEndpointV3 } from './IObjectV3';
|
|
5
6
|
/**
|
|
6
7
|
* _KObject is kunlun object, every method new a _KQuery object to deal.
|
|
7
8
|
*/
|
|
@@ -21,7 +22,7 @@ export declare class _KApplicationObject<T> {
|
|
|
21
22
|
appCtx: AppCtx;
|
|
22
23
|
constructor(objectApiName: string, appCtx: AppCtx);
|
|
23
24
|
}
|
|
24
|
-
declare class _KObjectSync<T> implements _IKSyncEndpoint<T> {
|
|
25
|
+
declare class _KObjectSync<T> implements _IKSyncEndpoint<T>, _IKSyncEndpointV3<T> {
|
|
25
26
|
apiName: string;
|
|
26
27
|
appCtx: AppCtx;
|
|
27
28
|
authType: string;
|
|
@@ -35,6 +36,7 @@ declare class _KObjectSync<T> implements _IKSyncEndpoint<T> {
|
|
|
35
36
|
update(recordMap: _Cond<T>): Promise<void>;
|
|
36
37
|
private updateV3;
|
|
37
38
|
batchCreate(recordMapList: _Cond<T>[]): Promise<number[]>;
|
|
39
|
+
batchDelete(recordIdList: string[]): Promise<BatchResult>;
|
|
38
40
|
batchDelete(recordIdList: number[]): Promise<BatchResult>;
|
|
39
41
|
batchDelete(recordList: _Cond<T>[]): Promise<BatchResult>;
|
|
40
42
|
batchUpdate(recordMapList: _Cond<T>[]): Promise<BatchResult>;
|
|
@@ -59,7 +61,7 @@ declare class _KObjectAsync<T> implements _IKAsyncEndpoint<T> {
|
|
|
59
61
|
useUserAuth(): this;
|
|
60
62
|
useSystemAuth(): this;
|
|
61
63
|
}
|
|
62
|
-
declare class _KObjectQuery<T> implements _IKQuery<T> {
|
|
64
|
+
declare class _KObjectQuery<T> implements _IKQuery<T>, _IKQueryV3<T> {
|
|
63
65
|
apiName: string;
|
|
64
66
|
appCtx: AppCtx;
|
|
65
67
|
authType: string;
|
|
@@ -85,7 +87,7 @@ declare class _KObjectQuery<T> implements _IKQuery<T> {
|
|
|
85
87
|
/**
|
|
86
88
|
* _KQuery is kunlun query implement, implements ORM operations.
|
|
87
89
|
*/
|
|
88
|
-
declare class _KQuery<T> implements _IKQuery<T> {
|
|
90
|
+
declare class _KQuery<T> implements _IKQuery<T>, _IKQueryV3<T> {
|
|
89
91
|
private authType;
|
|
90
92
|
constructor(objectApiName: string, appCtx?: AppCtx, authType?: string);
|
|
91
93
|
find(): Promise<_Record<T>[]>;
|
|
@@ -58,7 +58,6 @@ class _KObjectSync {
|
|
|
58
58
|
});
|
|
59
59
|
}
|
|
60
60
|
else if (this.appCtx && this.appCtx.dataVersion === 'v3') {
|
|
61
|
-
console.log("dataV3");
|
|
62
61
|
return await Request.GetInstance().createRecordV3BySync(this.apiName, recordMap, this.authType);
|
|
63
62
|
}
|
|
64
63
|
return await Request.GetInstance().createRecordBySync(this.apiName, recordMap, this.authType);
|
|
@@ -37,12 +37,12 @@ declare class MetaData<mt> implements IMetaData<mt> {
|
|
|
37
37
|
page(apiName: string, objectApiName: string, type: string): Page;
|
|
38
38
|
}
|
|
39
39
|
declare function metadata<mt>(ctx: any): IMetaData<mt>;
|
|
40
|
-
declare class
|
|
40
|
+
declare class MetaDataV3<mt> implements IMetaData<mt> {
|
|
41
41
|
constructor(ctx: any);
|
|
42
42
|
object<T>(objectApiName: keyof mt): IKObject<T>;
|
|
43
43
|
page(apiName: string, objectApiName: string, type: string): Page;
|
|
44
44
|
}
|
|
45
|
-
declare function
|
|
45
|
+
declare function metadataV3<mt>(ctx: any): IMetaData<mt>;
|
|
46
46
|
declare class Page implements IPage {
|
|
47
47
|
pageApiName: string;
|
|
48
48
|
objectApiName: string;
|
|
@@ -61,4 +61,4 @@ declare class Page implements IPage {
|
|
|
61
61
|
updateMobileList(componentName: string, params: any): Promise<void>;
|
|
62
62
|
}
|
|
63
63
|
declare function metaType(): any;
|
|
64
|
-
export { IMetaData, IKObject, IPage, MetaData, metadata, metaType,
|
|
64
|
+
export { IMetaData, IKObject, IPage, MetaData, metadata, metaType, MetaDataV3, metadataV3, };
|
|
@@ -2,7 +2,7 @@
|
|
|
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
|
-
exports.
|
|
5
|
+
exports.metadataV3 = exports.MetaDataV3 = exports.metaType = exports.metadata = exports.MetaData = void 0;
|
|
6
6
|
const components = require("./components/components");
|
|
7
7
|
const common = require("@byted-apaas/server-common-node");
|
|
8
8
|
const fields = require("./objects/fields");
|
|
@@ -36,7 +36,7 @@ function metadata(ctx) {
|
|
|
36
36
|
return new MetaData(ctx);
|
|
37
37
|
}
|
|
38
38
|
exports.metadata = metadata;
|
|
39
|
-
class
|
|
39
|
+
class MetaDataV3 {
|
|
40
40
|
constructor(ctx) {
|
|
41
41
|
}
|
|
42
42
|
object(objectApiName) {
|
|
@@ -58,11 +58,11 @@ class MetaDataV2 {
|
|
|
58
58
|
return new Page(apiName, objectApiName, type);
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
|
-
exports.
|
|
62
|
-
function
|
|
61
|
+
exports.MetaDataV3 = MetaDataV3;
|
|
62
|
+
function metadataV3(ctx) {
|
|
63
63
|
return new MetaData(ctx);
|
|
64
64
|
}
|
|
65
|
-
exports.
|
|
65
|
+
exports.metadataV3 = metadataV3;
|
|
66
66
|
class KObject {
|
|
67
67
|
constructor(objectApiName) {
|
|
68
68
|
this.objectApiName = objectApiName;
|
package/global/global.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { _Resources } from '../context/resources/impl/resources';
|
|
|
7
7
|
import { Message } from '../context/msg/msg';
|
|
8
8
|
import { _IIntegration } from '../context/integration/IIntegration';
|
|
9
9
|
import { DBV3 } from '../context/db/impl/dbV3';
|
|
10
|
-
import {
|
|
10
|
+
import { MetaDataV3 } from '../context/metadata/metadata';
|
|
11
11
|
declare global {
|
|
12
12
|
export namespace application {
|
|
13
13
|
/**
|
|
@@ -27,13 +27,13 @@ declare global {
|
|
|
27
27
|
*/
|
|
28
28
|
let operator: IOperator;
|
|
29
29
|
/**
|
|
30
|
-
*
|
|
30
|
+
* dataV3 接口
|
|
31
31
|
*/
|
|
32
|
-
let
|
|
32
|
+
let dataV3: DBV3<{}>;
|
|
33
33
|
/**
|
|
34
|
-
*
|
|
34
|
+
* metadataV3 接口
|
|
35
35
|
*/
|
|
36
|
-
let
|
|
36
|
+
let metadataV3: MetaDataV3<{}>;
|
|
37
37
|
/**
|
|
38
38
|
* 常量
|
|
39
39
|
*/
|
package/hooks/hooks.js
CHANGED
|
@@ -74,7 +74,7 @@ function mountApplication(context) {
|
|
|
74
74
|
global.application = {};
|
|
75
75
|
}
|
|
76
76
|
global.application.data = new db_1.DB();
|
|
77
|
-
global.application.
|
|
77
|
+
global.application.dataV3 = new dbV3_1.DBV3();
|
|
78
78
|
// publicAPI
|
|
79
79
|
if (!global.application.publicAPI) {
|
|
80
80
|
global.application.publicAPI = {};
|
|
@@ -86,7 +86,7 @@ function mountApplication(context) {
|
|
|
86
86
|
global.application.msg = new msg_1.Message();
|
|
87
87
|
global.application.resources = new resources_1._Resources();
|
|
88
88
|
global.application.metadata = metadataApi.metadata(context);
|
|
89
|
-
global.application.
|
|
89
|
+
global.application.metadataV3 = metadataApi.metadataV3(context);
|
|
90
90
|
// globalVar
|
|
91
91
|
if (!global.application.globalVar) {
|
|
92
92
|
global.application.globalVar = {};
|
package/package.json
CHANGED
package/request/interface.d.ts
CHANGED
|
@@ -53,6 +53,7 @@ export interface IInnerAPIBaseRequest {
|
|
|
53
53
|
updateRecordsByAsync: (objectApiName: string, recordMap: Record<number, object>, authType: string) => any;
|
|
54
54
|
deleteRecordsByAsync: (objectApiName: string, recordIDs: number[], authType: string) => any;
|
|
55
55
|
createRecordsBySync: (objectApiName: string, records: object[], authType: string) => any;
|
|
56
|
+
createRecordsV3BySync: (objectApiName: string, records: object[], authType: string) => any;
|
|
56
57
|
updateRecordsBySync: (objectApiName: string, recordMap: Record<number, object>, authType: string) => Promise<Record<number, string>>;
|
|
57
58
|
deleteRecordsBySync: (objectApiName: string, recordIDs: number[], authType: string) => Promise<Record<number, string>>;
|
|
58
59
|
getRecordsOrCountByCriterion: (objectApiName: string, criterion: string | Criterion, fuzzySearch: any, order: Order[], ignoreBackLookupField: boolean, fieldApiNames: string[], offset: number, limit: number, needCount: boolean, authType: string) => any;
|
package/request/openapi.d.ts
CHANGED
|
@@ -21,8 +21,11 @@ export declare class RequestHttp implements IInnerAPIRequest {
|
|
|
21
21
|
updateRecordsByAsync(objectApiName: string, recordMap: Record<number, object>, authType: string): any;
|
|
22
22
|
deleteRecordsByAsync(objectApiName: string, recordIDs: number[], authType: string): any;
|
|
23
23
|
createRecordsBySync(objectApiName: string, records: object[], authType: string): any;
|
|
24
|
+
createRecordsV3BySync(objectApiName: string, records: object[], authType: string): any;
|
|
24
25
|
updateRecordsBySync(objectApiName: string, recordMap: Record<number, object>, authType: string): Promise<Record<number, string>>;
|
|
26
|
+
updateRecordsV3BySync(objectApiName: string, records: object[], authType: string): Promise<Record<string, string>>;
|
|
25
27
|
deleteRecordsBySync(objectApiName: string, recordIDs: number[], authType: string): Promise<Record<number, string>>;
|
|
28
|
+
deleteRecordsV3BySync(objectApiName: string, recordIDs: number[], authType: string): Promise<Record<number, string>>;
|
|
26
29
|
getRecordsOrCountByCriterion(objectApiName: string, criterion: string | Criterion, order: Order[], fuzzySearch: any, ignoreBackLookupField: boolean, fieldApiNames: string[], offset: number, limit: number, needCount: boolean, authType: string): any;
|
|
27
30
|
getRecordsV3OrCounByCriterion(objectApiName: string, criterion: string | CriterionV3, order: Order[], fuzzySearch: any, fieldApiNames: string[], offset: number, limit: number, needCount: boolean, authType: string): any;
|
|
28
31
|
uploadFile(data: Stream, expire: number, fileName?: string): Promise<UploadFileResp>;
|
package/request/openapi.js
CHANGED
|
@@ -268,6 +268,27 @@ async function createRecordsBySync(objectApiName, records, authType) {
|
|
|
268
268
|
}
|
|
269
269
|
return openapi.doRequest(null, urlPath, options);
|
|
270
270
|
}
|
|
271
|
+
async function createRecordsV3BySync(objectApiName, records, authType) {
|
|
272
|
+
// 1.获取 options
|
|
273
|
+
let options = commonHttp.getOptions(null, openapiHttpPath.createRecordsV3BySync);
|
|
274
|
+
let urlPath = options._reqPath.replace(replaceKeys.namespace, await (0, common_1.getNamespaceForOpenAndFaaSSDK)());
|
|
275
|
+
urlPath = urlPath.replace(replaceKeys.objectApiName, objectApiName);
|
|
276
|
+
// 2.请求
|
|
277
|
+
options.json = {
|
|
278
|
+
'records': records,
|
|
279
|
+
'data_version': 'v3',
|
|
280
|
+
};
|
|
281
|
+
authType = (0, utils_1.formatAuthType)(authType);
|
|
282
|
+
options.headers.User = String(utils.getUserIDFromCtx());
|
|
283
|
+
if (authType) {
|
|
284
|
+
options.headers[constants_3.AuthTypeHttpHeader] = authType;
|
|
285
|
+
}
|
|
286
|
+
let task_id = utils.getTriggerTaskID();
|
|
287
|
+
if (task_id) {
|
|
288
|
+
options.json.automation_task_id = task_id;
|
|
289
|
+
}
|
|
290
|
+
return openapi.doRequest(null, urlPath, options);
|
|
291
|
+
}
|
|
271
292
|
async function updateRecordsBySync(objectApiName, recordMap, authType) {
|
|
272
293
|
// 1.获取 options
|
|
273
294
|
let options = commonHttp.getOptions(null, openapiHttpPath.mUpdateRecordsBySyncV2);
|
|
@@ -298,6 +319,36 @@ async function updateRecordsBySync(objectApiName, recordMap, authType) {
|
|
|
298
319
|
}
|
|
299
320
|
return errMap;
|
|
300
321
|
}
|
|
322
|
+
async function updateRecordsV3BySync(objectApiName, records, authType) {
|
|
323
|
+
// 1.获取 options
|
|
324
|
+
let options = commonHttp.getOptions(null, openapiHttpPath.updateRecordsV3BySync);
|
|
325
|
+
let urlPath = options._reqPath.replace(replaceKeys.namespace, await (0, common_1.getNamespaceForOpenAndFaaSSDK)());
|
|
326
|
+
urlPath = urlPath.replace(replaceKeys.objectApiName, objectApiName);
|
|
327
|
+
// 2.请求
|
|
328
|
+
options.json = {
|
|
329
|
+
'records': records,
|
|
330
|
+
'data_version': 'v3',
|
|
331
|
+
};
|
|
332
|
+
authType = (0, utils_1.formatAuthType)(authType);
|
|
333
|
+
options.headers.User = String(utils.getUserIDFromCtx());
|
|
334
|
+
if (authType) {
|
|
335
|
+
options.headers[constants_3.AuthTypeHttpHeader] = authType;
|
|
336
|
+
}
|
|
337
|
+
let task_id = utils.getTriggerTaskID();
|
|
338
|
+
if (task_id) {
|
|
339
|
+
options.json.automation_task_id = task_id;
|
|
340
|
+
}
|
|
341
|
+
const resp = await openapi.doRequest(null, urlPath, options);
|
|
342
|
+
if (!resp || !resp.err_map) {
|
|
343
|
+
return undefined;
|
|
344
|
+
}
|
|
345
|
+
// todo wby 待确认返回值
|
|
346
|
+
const errMap = {};
|
|
347
|
+
for (let recordID of Object.keys(resp.err_map)) {
|
|
348
|
+
errMap[Number(recordID)] = resp.err_map[recordID];
|
|
349
|
+
}
|
|
350
|
+
return errMap;
|
|
351
|
+
}
|
|
301
352
|
async function deleteRecordsBySync(objectApiName, recordIDs, authType) {
|
|
302
353
|
// 1.获取 options
|
|
303
354
|
let options = commonHttp.getOptions(null, openapiHttpPath.mDeleteRecordsBySyncV2);
|
|
@@ -328,6 +379,35 @@ async function deleteRecordsBySync(objectApiName, recordIDs, authType) {
|
|
|
328
379
|
}
|
|
329
380
|
return errMap;
|
|
330
381
|
}
|
|
382
|
+
async function deleteRecordsV3BySync(objectApiName, recordIDs, authType) {
|
|
383
|
+
// 1.获取 options
|
|
384
|
+
let options = commonHttp.getOptions(null, openapiHttpPath.deleteRecordsV3BySync);
|
|
385
|
+
let urlPath = options._reqPath.replace(replaceKeys.namespace, await (0, common_1.getNamespaceForOpenAndFaaSSDK)());
|
|
386
|
+
urlPath = urlPath.replace(replaceKeys.objectApiName, objectApiName);
|
|
387
|
+
// 2.请求
|
|
388
|
+
options.json = {
|
|
389
|
+
'ids': recordIDs,
|
|
390
|
+
'data_version': 'v3',
|
|
391
|
+
};
|
|
392
|
+
authType = (0, utils_1.formatAuthType)(authType);
|
|
393
|
+
options.headers.User = String(utils.getUserIDFromCtx());
|
|
394
|
+
if (authType) {
|
|
395
|
+
options.headers[constants_3.AuthTypeHttpHeader] = authType;
|
|
396
|
+
}
|
|
397
|
+
let task_id = utils.getTriggerTaskID();
|
|
398
|
+
if (task_id) {
|
|
399
|
+
options.json.automation_task_id = task_id;
|
|
400
|
+
}
|
|
401
|
+
const resp = await openapi.doRequest(null, urlPath, options);
|
|
402
|
+
if (!resp || !resp.err_map) {
|
|
403
|
+
return undefined;
|
|
404
|
+
}
|
|
405
|
+
const errMap = {};
|
|
406
|
+
for (let recordID of Object.keys(resp.err_map)) {
|
|
407
|
+
errMap[Number(recordID)] = resp.err_map[recordID];
|
|
408
|
+
}
|
|
409
|
+
return errMap;
|
|
410
|
+
}
|
|
331
411
|
function handleResponse(objectAPIName, data, needCount) {
|
|
332
412
|
// 返回数据的特殊处理
|
|
333
413
|
if (needCount) {
|
|
@@ -405,7 +485,6 @@ async function getRecordsV3OrCountByCriterion(objectApiName, criterion, order, f
|
|
|
405
485
|
if (typeof criterion === 'string') {
|
|
406
486
|
criterion = JSON.parse(criterion);
|
|
407
487
|
}
|
|
408
|
-
console.log('criterion', JSON.stringify(criterion));
|
|
409
488
|
// 3.请求
|
|
410
489
|
options.json = {
|
|
411
490
|
'page_size': limit,
|
|
@@ -897,8 +976,11 @@ class RequestHttp {
|
|
|
897
976
|
this.updateRecordsByAsync = updateRecordsByAsync;
|
|
898
977
|
this.deleteRecordsByAsync = deleteRecordsByAsync;
|
|
899
978
|
this.createRecordsBySync = createRecordsBySync;
|
|
979
|
+
this.createRecordsV3BySync = createRecordsV3BySync;
|
|
900
980
|
this.updateRecordsBySync = updateRecordsBySync;
|
|
981
|
+
this.updateRecordsV3BySync = updateRecordsV3BySync;
|
|
901
982
|
this.deleteRecordsBySync = deleteRecordsBySync;
|
|
983
|
+
this.deleteRecordsV3BySync = deleteRecordsV3BySync;
|
|
902
984
|
this.getRecordsOrCountByCriterion = getRecordsOrCountByCriterion;
|
|
903
985
|
this.getRecordsV3OrCounByCriterion = getRecordsV3OrCountByCriterion;
|
|
904
986
|
this.uploadFile = uploadFile;
|
|
@@ -951,12 +1033,20 @@ class RequestHttp {
|
|
|
951
1033
|
}
|
|
952
1034
|
createRecordsBySync(objectApiName, records, authType) {
|
|
953
1035
|
}
|
|
1036
|
+
createRecordsV3BySync(objectApiName, records, authType) {
|
|
1037
|
+
}
|
|
954
1038
|
updateRecordsBySync(objectApiName, recordMap, authType) {
|
|
955
1039
|
return new Promise(undefined);
|
|
956
1040
|
}
|
|
1041
|
+
updateRecordsV3BySync(objectApiName, records, authType) {
|
|
1042
|
+
return new Promise(undefined);
|
|
1043
|
+
}
|
|
957
1044
|
deleteRecordsBySync(objectApiName, recordIDs, authType) {
|
|
958
1045
|
return new Promise(undefined);
|
|
959
1046
|
}
|
|
1047
|
+
deleteRecordsV3BySync(objectApiName, recordIDs, authType) {
|
|
1048
|
+
return new Promise(undefined);
|
|
1049
|
+
}
|
|
960
1050
|
getRecordsOrCountByCriterion(objectApiName, criterion, order, fuzzySearch, ignoreBackLookupField, fieldApiNames, offset, limit, needCount, authType) {
|
|
961
1051
|
}
|
|
962
1052
|
getRecordsV3OrCounByCriterion(objectApiName, criterion, order, fuzzySearch, fieldApiNames, offset, limit, needCount, authType) {
|