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