@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,61 @@
|
|
|
1
|
+
import { _IKAllEndpoint, _IKSyncEndpoint, _IKQuery } from './IObject';
|
|
2
|
+
import { ITransactionGetter } from './transaction';
|
|
3
|
+
import { IDB, IDBSync, IDBWithCurrentObject } from '../db';
|
|
4
|
+
import { currentObjApiName, metadataMap } from '../../../data/index';
|
|
5
|
+
import { IOql } from "./oql/ioql";
|
|
6
|
+
import { AppCtx } from "../../../application/application";
|
|
7
|
+
export declare class DB<T, mt = metadataMap> implements IDB<T, mt> {
|
|
8
|
+
objectApiName: string;
|
|
9
|
+
constructor(objectApiName?: string);
|
|
10
|
+
/**
|
|
11
|
+
* 操作指定对象的记录数据
|
|
12
|
+
* @param objectApiName 指定对象的 ApiName
|
|
13
|
+
* @example
|
|
14
|
+
* ```
|
|
15
|
+
* context.db.object("_user").where({
|
|
16
|
+
* gender: "male"
|
|
17
|
+
* }).find()
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
object<K extends keyof mt>(objectApiName: K): _IKAllEndpoint<mt[K]> & _IKQuery<mt[K]>;
|
|
21
|
+
/**
|
|
22
|
+
* 创建一个新的空事务
|
|
23
|
+
* @example
|
|
24
|
+
* ```
|
|
25
|
+
* let tx = context.db.newTransaction();
|
|
26
|
+
* let user = tx.object("_user").registerCreate({
|
|
27
|
+
* _name: new kunlun.type.Multilingual({ zh: "用户1", en: "user1" }),
|
|
28
|
+
* });
|
|
29
|
+
* let contract = tx.object("contract").registerCreate({
|
|
30
|
+
* _name: new kunlun.type.Multilingual({ zh: "用户1的合同", en: "user1's contract" }),
|
|
31
|
+
* user: {id: user._id}
|
|
32
|
+
* });
|
|
33
|
+
* await tx.commit();
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
newTransaction(): ITransactionGetter<T, mt>;
|
|
37
|
+
/**
|
|
38
|
+
* OQL 操作
|
|
39
|
+
* @param oql 指定 OQL 语句
|
|
40
|
+
* @example
|
|
41
|
+
* ```
|
|
42
|
+
* let users = await context.db.oql("select _email from _user").execute();
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
oql(oql: string): IOql;
|
|
46
|
+
}
|
|
47
|
+
export declare class DBWithCurrentObject<T, mt = metadataMap> extends DB<T, mt> implements IDB<T, mt>, IDBWithCurrentObject<T, mt> {
|
|
48
|
+
/**
|
|
49
|
+
* 无需入参,操作当前对象的记录数据
|
|
50
|
+
*/
|
|
51
|
+
currentObject(): _IKAllEndpoint<mt[currentObjApiName]> & _IKQuery<mt[currentObjApiName]>;
|
|
52
|
+
constructor(objectApiName: string);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* ApplicationDB: 用于支持 OpenSDK 相关能力的 DB 相关类,目前仅实现 DB 同步操作接口
|
|
56
|
+
*/
|
|
57
|
+
export declare class ApplicationDB implements IDBSync {
|
|
58
|
+
appCtx: AppCtx;
|
|
59
|
+
constructor(appCtx: AppCtx);
|
|
60
|
+
object(objectApiName: string): _IKSyncEndpoint<{}> & _IKQuery<{}>;
|
|
61
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ApplicationDB = exports.DBWithCurrentObject = exports.DB = void 0;
|
|
4
|
+
const object_1 = require("./object");
|
|
5
|
+
const server_common_node_1 = require("@byted-apaas/server-common-node");
|
|
6
|
+
const index_1 = require("./transaction/index");
|
|
7
|
+
const oql_1 = require("./oql/oql");
|
|
8
|
+
class DB {
|
|
9
|
+
constructor(objectApiName) {
|
|
10
|
+
this.objectApiName = objectApiName;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* 操作指定对象的记录数据
|
|
14
|
+
* @param objectApiName 指定对象的 ApiName
|
|
15
|
+
* @example
|
|
16
|
+
* ```
|
|
17
|
+
* context.db.object("_user").where({
|
|
18
|
+
* gender: "male"
|
|
19
|
+
* }).find()
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
object(objectApiName) {
|
|
23
|
+
return new object_1._KObject(objectApiName);
|
|
24
|
+
}
|
|
25
|
+
;
|
|
26
|
+
/**
|
|
27
|
+
* 创建一个新的空事务
|
|
28
|
+
* @example
|
|
29
|
+
* ```
|
|
30
|
+
* let tx = context.db.newTransaction();
|
|
31
|
+
* let user = tx.object("_user").registerCreate({
|
|
32
|
+
* _name: new kunlun.type.Multilingual({ zh: "用户1", en: "user1" }),
|
|
33
|
+
* });
|
|
34
|
+
* let contract = tx.object("contract").registerCreate({
|
|
35
|
+
* _name: new kunlun.type.Multilingual({ zh: "用户1的合同", en: "user1's contract" }),
|
|
36
|
+
* user: {id: user._id}
|
|
37
|
+
* });
|
|
38
|
+
* await tx.commit();
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
newTransaction() {
|
|
42
|
+
return new index_1.Transaction(this.objectApiName);
|
|
43
|
+
}
|
|
44
|
+
;
|
|
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) {
|
|
54
|
+
return new oql_1.Oql(oql);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
exports.DB = DB;
|
|
58
|
+
class DBWithCurrentObject extends DB {
|
|
59
|
+
/**
|
|
60
|
+
* 无需入参,操作当前对象的记录数据
|
|
61
|
+
*/
|
|
62
|
+
// @ts-ignore
|
|
63
|
+
currentObject() {
|
|
64
|
+
if (!this.objectApiName) {
|
|
65
|
+
throw new server_common_node_1.exceptions.InternalError(`context.objectApiName is empty`);
|
|
66
|
+
}
|
|
67
|
+
return new object_1._KObject(this.objectApiName);
|
|
68
|
+
}
|
|
69
|
+
;
|
|
70
|
+
constructor(objectApiName) {
|
|
71
|
+
super(objectApiName);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
exports.DBWithCurrentObject = DBWithCurrentObject;
|
|
75
|
+
/**
|
|
76
|
+
* ApplicationDB: 用于支持 OpenSDK 相关能力的 DB 相关类,目前仅实现 DB 同步操作接口
|
|
77
|
+
*/
|
|
78
|
+
class ApplicationDB {
|
|
79
|
+
constructor(appCtx) {
|
|
80
|
+
this.appCtx = appCtx;
|
|
81
|
+
}
|
|
82
|
+
object(objectApiName) {
|
|
83
|
+
return new object_1._KApplicationObject(objectApiName, this.appCtx);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
exports.ApplicationDB = ApplicationDB;
|
|
87
|
+
//# sourceMappingURL=db.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"db.js","sourceRoot":"","sources":["db.ts"],"names":[],"mappings":";;;AAAA,qCAAwD;AAKxD,wEAA4D;AAC5D,+CAAiD;AAEjD,mCAAgC;AAGhC,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;IAEF;;;;;;;OAOG;IACH,GAAG,CAAC,GAAW;QACX,OAAO,IAAI,SAAG,CAAC,GAAG,CAAC,CAAC;IACxB,CAAC;CACJ;AAnDD,gBAmDC;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"}
|
|
@@ -0,0 +1,95 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { _Cond, _Record, _WhereCond } from '../../../types/types';
|
|
2
|
+
import { _IKAsyncEndpoint, _IKQuery, _IKSyncEndpoint } from './IObject';
|
|
3
|
+
import { AppCtx } from '../../../application/application';
|
|
4
|
+
/**
|
|
5
|
+
* _KObject is kunlun object, every method new a _KQuery object to deal.
|
|
6
|
+
*/
|
|
7
|
+
export interface _KObject<T> extends _KObjectSync<T>, _KObjectAsync<T>, _KObjectQuery<T> {
|
|
8
|
+
}
|
|
9
|
+
export declare class _KObject<T> {
|
|
10
|
+
apiName: string;
|
|
11
|
+
constructor(objectApiName: string);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* _KApplicationObject is open sdk object implement.
|
|
15
|
+
*/
|
|
16
|
+
export interface _KApplicationObject<T> extends _KObjectSync<T>, _KObjectQuery<T> {
|
|
17
|
+
}
|
|
18
|
+
export declare class _KApplicationObject<T> {
|
|
19
|
+
apiName: string;
|
|
20
|
+
appCtx: AppCtx;
|
|
21
|
+
constructor(objectApiName: string, appCtx: AppCtx);
|
|
22
|
+
}
|
|
23
|
+
declare class _KObjectSync<T> implements _IKSyncEndpoint<T> {
|
|
24
|
+
apiName: string;
|
|
25
|
+
appCtx: AppCtx;
|
|
26
|
+
create(recordMap: _Cond<T>): Promise<{
|
|
27
|
+
_id: number;
|
|
28
|
+
}>;
|
|
29
|
+
delete(recordID: number): Promise<void>;
|
|
30
|
+
delete(record: _Cond<T>): Promise<void>;
|
|
31
|
+
update(_id: number, recordMap: _Cond<T>): Promise<void>;
|
|
32
|
+
update(recordMap: _Cond<T>): Promise<void>;
|
|
33
|
+
batchCreate(recordMapList: _Cond<T>[]): Promise<number[]>;
|
|
34
|
+
batchDelete(recordIdList: number[]): Promise<void>;
|
|
35
|
+
batchDelete(recordList: _Cond<T>[]): Promise<void>;
|
|
36
|
+
batchUpdate(recordMapList: _Cond<T>[]): Promise<void>;
|
|
37
|
+
}
|
|
38
|
+
declare class _KObjectAsync<T> implements _IKAsyncEndpoint<T> {
|
|
39
|
+
apiName: string;
|
|
40
|
+
batchCreateAsync(recordMapList: _Cond<T>[]): Promise<{
|
|
41
|
+
taskID: number;
|
|
42
|
+
}>;
|
|
43
|
+
batchDeleteAsync(recordIDList: number[]): Promise<{
|
|
44
|
+
taskID: number;
|
|
45
|
+
}>;
|
|
46
|
+
batchDeleteAsync(recordList: _Cond<T>[]): Promise<{
|
|
47
|
+
taskID: number;
|
|
48
|
+
}>;
|
|
49
|
+
batchUpdateAsync(recordMapList: _Cond<T>[]): Promise<{
|
|
50
|
+
taskID: number;
|
|
51
|
+
}>;
|
|
52
|
+
}
|
|
53
|
+
declare class _KObjectQuery<T> implements _IKQuery<T> {
|
|
54
|
+
apiName: string;
|
|
55
|
+
appCtx: AppCtx;
|
|
56
|
+
find(): Promise<_Record<T>[]>;
|
|
57
|
+
findOne(): Promise<_Record<T>>;
|
|
58
|
+
findAll(): Promise<_Record<T>[]>;
|
|
59
|
+
orderBy<K extends keyof T>(fieldApiNames: K[]): _KQuery<T>;
|
|
60
|
+
orderBy<K extends keyof T>(...fieldApiNames: K[]): _KQuery<T>;
|
|
61
|
+
orderByDesc<K extends keyof T>(fieldApiNames: K[]): _KQuery<T>;
|
|
62
|
+
orderByDesc<K extends keyof T>(...fieldApiNames: K[]): _KQuery<T>;
|
|
63
|
+
select<K extends keyof T>(fieldApiNames: K[]): _KQuery<T>;
|
|
64
|
+
select<K extends keyof T>(...fieldApiNames: K[]): _KQuery<T>;
|
|
65
|
+
where(conditionMap: _WhereCond<T>): _KQuery<T>;
|
|
66
|
+
where(): _KQuery<T>;
|
|
67
|
+
limit(limit: number): _KQuery<T>;
|
|
68
|
+
offset(offset: number): _KQuery<T>;
|
|
69
|
+
count(): Promise<number>;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* _KQuery is kunlun query implement, implements ORM operations.
|
|
73
|
+
*/
|
|
74
|
+
declare class _KQuery<T> implements _IKQuery<T> {
|
|
75
|
+
constructor(objectApiName: string, appCtx?: AppCtx);
|
|
76
|
+
find(): Promise<_Record<T>[]>;
|
|
77
|
+
findOne(): Promise<_Record<T>>;
|
|
78
|
+
findAll(): Promise<_Record<T>[]>;
|
|
79
|
+
private getRecordsByPage;
|
|
80
|
+
orderBy<K extends keyof T>(fieldApiNames: K[]): this;
|
|
81
|
+
orderBy<K extends keyof T>(...fieldApiNames: K[]): this;
|
|
82
|
+
orderByDesc<K extends keyof T>(fieldApiNames: K[]): this;
|
|
83
|
+
orderByDesc<K extends keyof T>(...fieldApiNames: K[]): this;
|
|
84
|
+
select<K extends keyof T>(fieldApiNames: K[]): this;
|
|
85
|
+
select<K extends keyof T>(...fieldApiNames: K[]): this;
|
|
86
|
+
where(conditionMap: _WhereCond<T>): this;
|
|
87
|
+
where(): this;
|
|
88
|
+
limit(limit: number): this;
|
|
89
|
+
offset(offset: number): this;
|
|
90
|
+
count(): Promise<number>;
|
|
91
|
+
}
|
|
92
|
+
export {};
|