@byted-apaas/server-sdk-node 1.1.18-beta.2 → 1.1.18-beta.22
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/application/application.d.ts +2 -4
- package/context/context.d.ts +2 -0
- package/context/db/impl/object.d.ts +1 -1
- package/context/db/impl/object.js +11 -16
- package/context/db/impl/oql/oql.d.ts +2 -4
- package/context/db/impl/oql/oql.js +1 -6
- package/context/db/impl/transaction/index.d.ts +1 -3
- package/context/db/impl/transaction/index.js +1 -7
- package/context/taskCenter/taskCenter.d.ts +39 -0
- package/context/taskCenter/taskCenter.js +44 -0
- package/global/global.d.ts +3 -3
- package/hooks/hooks.js +3 -2
- package/package.json +2 -3
- package/request/interface.d.ts +3 -0
- package/request/openapi.d.ts +3 -0
- package/request/openapi.js +51 -0
- package/context/db/impl/dbV3.d.ts +0 -47
- package/context/db/impl/dbV3.js +0 -63
|
@@ -22,12 +22,10 @@ export interface IApplication {
|
|
|
22
22
|
setLaneName(laneName: string): IApplication;
|
|
23
23
|
}
|
|
24
24
|
export type AppMode = 'openSDK' | 'faasSDK';
|
|
25
|
-
export type DataVersion = 'v1' | 'v2' | 'v3';
|
|
26
25
|
export interface AppCtx {
|
|
27
|
-
mode
|
|
26
|
+
mode: AppMode;
|
|
28
27
|
env?: PlatformEnvType;
|
|
29
|
-
credential
|
|
28
|
+
credential: AppCredential;
|
|
30
29
|
debugType?: '0' | '2';
|
|
31
30
|
x_tt_env?: string;
|
|
32
|
-
dataVersion?: DataVersion;
|
|
33
31
|
}
|
package/context/context.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { IDBGetter } from './db/db';
|
|
|
5
5
|
import { Context as CommonContext } from '@byted-apaas/server-common-node';
|
|
6
6
|
import { IMetaData } from './metadata/metadata';
|
|
7
7
|
import { _IIntegration } from './integration/IIntegration';
|
|
8
|
+
import { TaskCenter } from "./taskCenter/taskCenter";
|
|
8
9
|
export declare class Context<T, mt, cf, gv> extends CommonContext implements IContext<T, mt, cf, gv> {
|
|
9
10
|
/**
|
|
10
11
|
* 操作数据库中的记录数据
|
|
@@ -33,6 +34,7 @@ export declare class Context<T, mt, cf, gv> extends CommonContext implements ICo
|
|
|
33
34
|
* 向消息中心推送及更新消息
|
|
34
35
|
*/
|
|
35
36
|
msg: Message;
|
|
37
|
+
taskCenter: TaskCenter;
|
|
36
38
|
/**
|
|
37
39
|
* 根据 apiName 获取对应的全局变量
|
|
38
40
|
* @param apiName 全局变量的 API Name
|
|
@@ -9,7 +9,7 @@ export interface _KObject<T> extends _KObjectSync<T>, _KObjectAsync<T>, _KObject
|
|
|
9
9
|
}
|
|
10
10
|
export declare class _KObject<T> {
|
|
11
11
|
apiName: string;
|
|
12
|
-
constructor(objectApiName: string
|
|
12
|
+
constructor(objectApiName: string);
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
15
15
|
* _KApplicationObject is open sdk object implement.
|
|
@@ -18,13 +18,12 @@ const structs_1 = require("../../../common/structs");
|
|
|
18
18
|
const queryPropertiesStore = new propertiesStore_1.default();
|
|
19
19
|
// _KObject will be Mixin with [_KObjectSync, _KObjectAsync, _KObjectQuery]
|
|
20
20
|
class _KObject {
|
|
21
|
-
constructor(objectApiName
|
|
21
|
+
constructor(objectApiName) {
|
|
22
22
|
this.apiName = '';
|
|
23
23
|
if (!objectApiName) {
|
|
24
24
|
throw new server_common_node_1.exceptions.InvalidParamError('objectApiName is empty');
|
|
25
25
|
}
|
|
26
26
|
this.apiName = objectApiName;
|
|
27
|
-
this.appCtx = appCtx;
|
|
28
27
|
}
|
|
29
28
|
}
|
|
30
29
|
exports._KObject = _KObject;
|
|
@@ -331,7 +330,7 @@ class _KObjectQuery {
|
|
|
331
330
|
}
|
|
332
331
|
;
|
|
333
332
|
async findStream(handler) {
|
|
334
|
-
return new _KQuery(this.apiName, this.appCtx
|
|
333
|
+
return new _KQuery(this.apiName, this.appCtx).findStream(handler);
|
|
335
334
|
}
|
|
336
335
|
orderBy(fieldApiNames, ...restFieldApiNames) {
|
|
337
336
|
fieldApiNames = !fieldApiNames ? [] : fieldApiNames;
|
|
@@ -352,7 +351,7 @@ class _KObjectQuery {
|
|
|
352
351
|
return new _KQuery(this.apiName, this.appCtx, this.authType).where(conditionMap);
|
|
353
352
|
}
|
|
354
353
|
fuzzySearch(keyword, fieldAPINames) {
|
|
355
|
-
return new _KQuery(this.apiName, this.appCtx
|
|
354
|
+
return new _KQuery(this.apiName, this.appCtx).fuzzySearch(keyword, fieldAPINames);
|
|
356
355
|
}
|
|
357
356
|
// limit, offset, count
|
|
358
357
|
limit(limit) {
|
|
@@ -391,13 +390,13 @@ class _KQuery {
|
|
|
391
390
|
apiName: objectApiName,
|
|
392
391
|
appCtx: appCtx,
|
|
393
392
|
queryBuilder: new queryBuilder_1.QueryBuilder(objectApiName),
|
|
394
|
-
queryV2: appCtx
|
|
393
|
+
queryV2: appCtx ? new logicV2_1.QueryV2(objectApiName) : null,
|
|
395
394
|
});
|
|
396
395
|
}
|
|
397
396
|
async find() {
|
|
398
397
|
this.findPreCheck();
|
|
399
398
|
const { apiName, appCtx, queryBuilder, queryV2 } = queryPropertiesStore.get(this);
|
|
400
|
-
if (
|
|
399
|
+
if (appCtx) {
|
|
401
400
|
const param = {
|
|
402
401
|
limit: queryV2._limit,
|
|
403
402
|
offset: queryV2._offset,
|
|
@@ -479,7 +478,7 @@ class _KQuery {
|
|
|
479
478
|
let maxId = 0, queryCount = 0;
|
|
480
479
|
let criterionV2;
|
|
481
480
|
let criterion;
|
|
482
|
-
if (
|
|
481
|
+
if (appCtx) {
|
|
483
482
|
criterionV2 = (0, logicV2_1.buildCriterionV2)(queryV2.filter);
|
|
484
483
|
criterionV2.push({ leftValue: '_id', operator: operator_1.operates.GT, rightValue: maxId });
|
|
485
484
|
}
|
|
@@ -500,7 +499,7 @@ class _KQuery {
|
|
|
500
499
|
break;
|
|
501
500
|
}
|
|
502
501
|
let rs;
|
|
503
|
-
if (
|
|
502
|
+
if (appCtx) {
|
|
504
503
|
criterionV2[criterionV2.length - 1].rightValue = maxId;
|
|
505
504
|
const param = {
|
|
506
505
|
limit: newLimit,
|
|
@@ -563,7 +562,7 @@ class _KQuery {
|
|
|
563
562
|
let maxId = 0, queryCount = 0;
|
|
564
563
|
let criterionV2;
|
|
565
564
|
let criterion;
|
|
566
|
-
if (
|
|
565
|
+
if (appCtx) {
|
|
567
566
|
criterionV2 = (0, logicV2_1.buildCriterionV2)(queryV2.filter);
|
|
568
567
|
criterionV2.push({ leftValue: '_id', operator: operator_1.operates.GT, rightValue: maxId });
|
|
569
568
|
}
|
|
@@ -590,7 +589,7 @@ class _KQuery {
|
|
|
590
589
|
break;
|
|
591
590
|
}
|
|
592
591
|
let rs;
|
|
593
|
-
if (
|
|
592
|
+
if (appCtx) {
|
|
594
593
|
criterionV2[criterionV2.length - 1].rightValue = maxId;
|
|
595
594
|
const param = {
|
|
596
595
|
limit: newLimit,
|
|
@@ -630,7 +629,7 @@ class _KQuery {
|
|
|
630
629
|
let maxId = 0, records = [];
|
|
631
630
|
while (true) {
|
|
632
631
|
let rs;
|
|
633
|
-
if (
|
|
632
|
+
if (appCtx) {
|
|
634
633
|
let criterion = (0, logicV2_1.buildCriterionV2)(queryV2.filter);
|
|
635
634
|
criterion.push({ leftValue: '_id', operator: operator_1.operates.GT, rightValue: maxId });
|
|
636
635
|
const param = {
|
|
@@ -689,10 +688,6 @@ class _KQuery {
|
|
|
689
688
|
return this;
|
|
690
689
|
}
|
|
691
690
|
select(fieldApiNames, ...restFieldApiNames) {
|
|
692
|
-
const { appCtx } = queryPropertiesStore.get(this);
|
|
693
|
-
if (appCtx && appCtx.dataVersion == "v3") {
|
|
694
|
-
console.log("=======================wby test: ", appCtx.dataVersion);
|
|
695
|
-
}
|
|
696
691
|
fieldApiNames = !fieldApiNames ? [] : fieldApiNames;
|
|
697
692
|
let fields = server_common_node_1.utils.argsToList(fieldApiNames, restFieldApiNames);
|
|
698
693
|
const { queryBuilder, queryV2 } = queryPropertiesStore.get(this);
|
|
@@ -772,7 +767,7 @@ class _KQuery {
|
|
|
772
767
|
;
|
|
773
768
|
async count() {
|
|
774
769
|
const { apiName, appCtx, queryBuilder, queryV2 } = queryPropertiesStore.get(this);
|
|
775
|
-
if (
|
|
770
|
+
if (appCtx) {
|
|
776
771
|
const param = {
|
|
777
772
|
limit: 1,
|
|
778
773
|
offset: queryV2._offset,
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import { IOql } from './ioql';
|
|
2
|
-
import { AppCtx } from '../../../../application/application';
|
|
3
2
|
export declare class Oql implements IOql {
|
|
4
3
|
oql: string;
|
|
5
4
|
params: any[];
|
|
6
5
|
namedParams: Record<string, any>;
|
|
7
6
|
authType: string;
|
|
8
|
-
|
|
9
|
-
constructor(oql: string,
|
|
10
|
-
constructor(oql: string, namedArgs: Record<string, any>, appCtx?: AppCtx);
|
|
7
|
+
constructor(oql: string);
|
|
8
|
+
constructor(oql: string, namedArgs: Record<string, any>);
|
|
11
9
|
execute(): Promise<any[]>;
|
|
12
10
|
useSystemAuth(): IOql;
|
|
13
11
|
useUserAuth(): IOql;
|
|
@@ -6,8 +6,7 @@ exports.Oql = void 0;
|
|
|
6
6
|
const Request = require("../../../../request/interface");
|
|
7
7
|
const constants_1 = require("@byted-apaas/server-common-node/constants/constants");
|
|
8
8
|
class Oql {
|
|
9
|
-
constructor(oql, namedArgs
|
|
10
|
-
this.appCtx = null;
|
|
9
|
+
constructor(oql, namedArgs) {
|
|
11
10
|
this.oql = oql;
|
|
12
11
|
this.params = [];
|
|
13
12
|
this.namedParams = {};
|
|
@@ -15,12 +14,8 @@ class Oql {
|
|
|
15
14
|
if (namedArgs) {
|
|
16
15
|
this.namedParams = namedArgs;
|
|
17
16
|
}
|
|
18
|
-
this.appCtx = appCtx;
|
|
19
17
|
}
|
|
20
18
|
async execute() {
|
|
21
|
-
if (this.appCtx && this.appCtx.dataVersion === "v3") {
|
|
22
|
-
// todo wby
|
|
23
|
-
}
|
|
24
19
|
let records = await Request.GetInstance().oql(this.oql, this.params, this.namedParams, this.authType);
|
|
25
20
|
if (records && Array.isArray(records)) {
|
|
26
21
|
return records;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { ITransaction, ITransactionWithCurrentObject, TransactionObject } from '../transaction';
|
|
2
2
|
import { TransactionOperation } from './operation';
|
|
3
3
|
import { currentObjApiName } from '../../../../data';
|
|
4
|
-
import { AppCtx } from '../../../../application/application';
|
|
5
4
|
type uuidOrRecordIDResult = {
|
|
6
5
|
_id: uuidOrRecordID;
|
|
7
6
|
};
|
|
@@ -13,9 +12,8 @@ export declare class Transaction<T, mt> implements ITransaction<mt>, ITransactio
|
|
|
13
12
|
uuid2result: Record<string, uuidOrRecordIDResult>;
|
|
14
13
|
isCommit: boolean;
|
|
15
14
|
authType: string;
|
|
16
|
-
appCtx?: AppCtx;
|
|
17
15
|
batchResults: (string | number)[][];
|
|
18
|
-
constructor(objectApiName: string
|
|
16
|
+
constructor(objectApiName: string);
|
|
19
17
|
currentObject(): TransactionObject<mt[currentObjApiName]>;
|
|
20
18
|
object<T extends keyof mt>(objectApiName: T): TransactionObject<mt[T]>;
|
|
21
19
|
commit(): Promise<void>;
|
|
@@ -12,15 +12,13 @@ const assert = require('assert');
|
|
|
12
12
|
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
13
13
|
const { v4: uuidv4 } = require('uuid'); //nolint:byted_s_ts_no_require_imports
|
|
14
14
|
class Transaction {
|
|
15
|
-
constructor(objectApiName
|
|
16
|
-
this.appCtx = null;
|
|
15
|
+
constructor(objectApiName) {
|
|
17
16
|
this.objectApiName = objectApiName;
|
|
18
17
|
this.placeholders = {};
|
|
19
18
|
this.operations = [];
|
|
20
19
|
this.uuid2result = {};
|
|
21
20
|
this.isCommit = false;
|
|
22
21
|
this.batchResults = [];
|
|
23
|
-
this.appCtx = appCtx;
|
|
24
22
|
}
|
|
25
23
|
// @ts-ignore
|
|
26
24
|
currentObject() {
|
|
@@ -217,10 +215,6 @@ class Transaction {
|
|
|
217
215
|
};
|
|
218
216
|
}
|
|
219
217
|
async commit() {
|
|
220
|
-
if (this.appCtx && this.appCtx.dataVersion === "v3") {
|
|
221
|
-
// todo wby
|
|
222
|
-
console.log("==========wby test= commit");
|
|
223
|
-
}
|
|
224
218
|
if (this.isCommit) {
|
|
225
219
|
throw new server_common_node_1.exceptions.InvalidParamError('The transaction cannot be committed repeatedly');
|
|
226
220
|
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export interface _Task {
|
|
2
|
+
taskID?: string;
|
|
3
|
+
APaaSRecord?: _APaaSRecord;
|
|
4
|
+
}
|
|
5
|
+
export interface _APaaSRecord {
|
|
6
|
+
objectID?: string;
|
|
7
|
+
objectAPIName?: string;
|
|
8
|
+
recordID?: string;
|
|
9
|
+
recordData?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare class _TaskCenter {
|
|
12
|
+
/**
|
|
13
|
+
* 推送任务
|
|
14
|
+
* @param tasks 任务
|
|
15
|
+
* @param cacheDuration 缓存时长
|
|
16
|
+
*/
|
|
17
|
+
syncTasks(tasks?: _Task[], cacheDuration?: number): Promise<number>;
|
|
18
|
+
/**
|
|
19
|
+
* 查询任务详情(从缓存)
|
|
20
|
+
* @param task 任务
|
|
21
|
+
*/
|
|
22
|
+
getTaskDetail(task?: _Task): Promise<_Task>;
|
|
23
|
+
/**
|
|
24
|
+
* 刷新任务详情缓存
|
|
25
|
+
* @param tasks 任务
|
|
26
|
+
* @param cacheDuration 缓存时长
|
|
27
|
+
*/
|
|
28
|
+
refreshTasksCache(tasks?: _Task[], cacheDuration?: number): Promise<number>;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* 任务中心类
|
|
32
|
+
*/
|
|
33
|
+
export declare class TaskCenter {
|
|
34
|
+
/**
|
|
35
|
+
* 任务中心
|
|
36
|
+
*/
|
|
37
|
+
taskCenter: _TaskCenter;
|
|
38
|
+
constructor();
|
|
39
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright 2022 ByteDance Ltd. and/or its affiliates
|
|
3
|
+
// SPDX-License-Identifier: MIT
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.TaskCenter = exports._TaskCenter = void 0;
|
|
6
|
+
const Request = require("../../request/interface");
|
|
7
|
+
class _TaskCenter {
|
|
8
|
+
/**
|
|
9
|
+
* 推送任务
|
|
10
|
+
* @param tasks 任务
|
|
11
|
+
* @param cacheDuration 缓存时长
|
|
12
|
+
*/
|
|
13
|
+
async syncTasks(tasks, cacheDuration) {
|
|
14
|
+
return await Request.GetInstance().syncTasks(tasks, cacheDuration);
|
|
15
|
+
}
|
|
16
|
+
;
|
|
17
|
+
/**
|
|
18
|
+
* 查询任务详情(从缓存)
|
|
19
|
+
* @param task 任务
|
|
20
|
+
*/
|
|
21
|
+
async getTaskDetail(task) {
|
|
22
|
+
return await Request.GetInstance().getTaskDetail(task);
|
|
23
|
+
}
|
|
24
|
+
;
|
|
25
|
+
/**
|
|
26
|
+
* 刷新任务详情缓存
|
|
27
|
+
* @param tasks 任务
|
|
28
|
+
* @param cacheDuration 缓存时长
|
|
29
|
+
*/
|
|
30
|
+
async refreshTasksCache(tasks, cacheDuration) {
|
|
31
|
+
return await Request.GetInstance().refreshTasksCache(tasks, cacheDuration);
|
|
32
|
+
}
|
|
33
|
+
;
|
|
34
|
+
}
|
|
35
|
+
exports._TaskCenter = _TaskCenter;
|
|
36
|
+
/**
|
|
37
|
+
* 任务中心类
|
|
38
|
+
*/
|
|
39
|
+
class TaskCenter {
|
|
40
|
+
constructor() {
|
|
41
|
+
this.taskCenter = new _TaskCenter();
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.TaskCenter = TaskCenter;
|
package/global/global.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { Flow } from './application/flow/flow';
|
|
|
6
6
|
import { _Resources } from '../context/resources/impl/resources';
|
|
7
7
|
import { Message } from '../context/msg/msg';
|
|
8
8
|
import { _IIntegration } from '../context/integration/IIntegration';
|
|
9
|
-
import {
|
|
9
|
+
import { TaskCenter } from "../context/taskCenter/taskCenter";
|
|
10
10
|
declare global {
|
|
11
11
|
export namespace application {
|
|
12
12
|
/**
|
|
@@ -26,9 +26,9 @@ declare global {
|
|
|
26
26
|
*/
|
|
27
27
|
let operator: IOperator;
|
|
28
28
|
/**
|
|
29
|
-
*
|
|
29
|
+
* 消息中心
|
|
30
30
|
*/
|
|
31
|
-
let
|
|
31
|
+
let taskCenter: TaskCenter;
|
|
32
32
|
/**
|
|
33
33
|
* 常量
|
|
34
34
|
*/
|
package/hooks/hooks.js
CHANGED
|
@@ -11,7 +11,7 @@ const common_1 = require("../request/common");
|
|
|
11
11
|
const integration_1 = require("../context/integration/impl/integration");
|
|
12
12
|
const metadataApi = require("../context/metadata/metadata");
|
|
13
13
|
const flow_1 = require("../global/application/flow/flow");
|
|
14
|
-
const
|
|
14
|
+
const taskCenter_1 = require("../context/taskCenter/taskCenter");
|
|
15
15
|
/**
|
|
16
16
|
* 根据 key 获取对应的全局变量
|
|
17
17
|
* @param key 全局变量的 key
|
|
@@ -58,6 +58,7 @@ function mountContext(context, logger, requireFunc) {
|
|
|
58
58
|
context.function = api.getFunctionSync(context, logger);
|
|
59
59
|
context.tasks = new tasks_1.Tasks(context.function);
|
|
60
60
|
context.msg = new msg_1.Message();
|
|
61
|
+
context.taskCenter = new taskCenter_1.TaskCenter();
|
|
61
62
|
context.resources = new resources_1._Resources();
|
|
62
63
|
context.integration = new integration_1._Integration();
|
|
63
64
|
context.getVar = getVar;
|
|
@@ -74,7 +75,6 @@ function mountApplication(context) {
|
|
|
74
75
|
global.application = {};
|
|
75
76
|
}
|
|
76
77
|
global.application.data = new db_1.DB();
|
|
77
|
-
global.application.dataV2 = new dbV3_1.DBV3();
|
|
78
78
|
// publicAPI
|
|
79
79
|
if (!global.application.publicAPI) {
|
|
80
80
|
global.application.publicAPI = {};
|
|
@@ -84,6 +84,7 @@ function mountApplication(context) {
|
|
|
84
84
|
global.application.publicAPI.method = server_common_node_1.utils.getHttpMethod();
|
|
85
85
|
global.application.publicAPI.headers = server_common_node_1.utils.getHttpHeaders();
|
|
86
86
|
global.application.msg = new msg_1.Message();
|
|
87
|
+
global.application.taskCenter = new taskCenter_1.TaskCenter();
|
|
87
88
|
global.application.resources = new resources_1._Resources();
|
|
88
89
|
global.application.metadata = metadataApi.metadata(context);
|
|
89
90
|
// globalVar
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@byted-apaas/server-sdk-node",
|
|
3
|
-
"version": "1.1.18-beta.
|
|
3
|
+
"version": "1.1.18-beta.22",
|
|
4
4
|
"description": "aPaaS Server SDK",
|
|
5
5
|
"author": "zhouwexin <zhouwexin@bytedance.com>",
|
|
6
6
|
"homepage": "",
|
|
@@ -13,11 +13,10 @@
|
|
|
13
13
|
"clean": "tsc --build --clean && rm -rf **/*.js.map"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@byted-apaas/server-common-node": "^2.0.
|
|
16
|
+
"@byted-apaas/server-common-node": "^2.0.13-beta.35",
|
|
17
17
|
"@jorgeferrero/stream-to-buffer": "^2.0.6",
|
|
18
18
|
"dayjs": "^1.9.6",
|
|
19
19
|
"form-data": "^3.0.0",
|
|
20
|
-
"package.json": "^2.0.1",
|
|
21
20
|
"typescript": "^4.9.3",
|
|
22
21
|
"uuid": "^8.3.2"
|
|
23
22
|
},
|
package/request/interface.d.ts
CHANGED
|
@@ -59,6 +59,9 @@ export interface IInnerAPIBaseRequest {
|
|
|
59
59
|
downloadFileByToken: (fileToken: string, filePath?: string) => Promise<Buffer | undefined>;
|
|
60
60
|
createMessage: (msg: any) => Promise<number>;
|
|
61
61
|
updateMessage: (msgId: number, msg: any) => Promise<void>;
|
|
62
|
+
syncTasks: (tasks: any, cacheDuration: number) => Promise<number>;
|
|
63
|
+
getTaskDetail: (task: any) => Promise<any>;
|
|
64
|
+
refreshTasksCache: (tasks: any, cacheDuration: number) => Promise<number>;
|
|
62
65
|
getFields: (objectApiName: string) => Promise<any>;
|
|
63
66
|
getField: (objectApiName: string, fieldApiName: string) => Promise<any>;
|
|
64
67
|
terminateWorkflowInstance: (workflowInstanceId: number, operator: number, reason: string) => Promise<void>;
|
package/request/openapi.d.ts
CHANGED
|
@@ -26,6 +26,9 @@ export declare class RequestHttp implements IInnerAPIRequest {
|
|
|
26
26
|
downloadFileByToken(fileToken: string, filePath?: string): Promise<Buffer | undefined>;
|
|
27
27
|
createMessage(msg: any): Promise<number>;
|
|
28
28
|
updateMessage(msgId: number, msg: any): Promise<void>;
|
|
29
|
+
syncTasks(tasks: any, cacheDuration: number): Promise<number>;
|
|
30
|
+
getTaskDetail(task: any): Promise<any>;
|
|
31
|
+
refreshTasksCache(cacheDuration: number, tasks: any): Promise<number>;
|
|
29
32
|
getFields(objectApiName: string): any;
|
|
30
33
|
getField(objectApiName: string, fieldApiName: string): any;
|
|
31
34
|
terminateWorkflowInstance(workflowInstanceId: number, operator: number, reason: string): any;
|
package/request/openapi.js
CHANGED
|
@@ -818,6 +818,9 @@ class RequestHttp {
|
|
|
818
818
|
this.openSDKUploadFile = openSDKUploadFile;
|
|
819
819
|
this.openSDKUploadAvatar = openSDKUploadAvatar;
|
|
820
820
|
this.openSDKDownloadAvatar = openSDKDownloadAvatar;
|
|
821
|
+
this.syncTasks = syncTasks;
|
|
822
|
+
this.getTaskDetail = getTaskDetail;
|
|
823
|
+
this.refreshTasksCache = refreshTasksCache;
|
|
821
824
|
}
|
|
822
825
|
updateWorkflowVariables(ctx, instanceId, variables, variableTypes) {
|
|
823
826
|
}
|
|
@@ -860,6 +863,15 @@ class RequestHttp {
|
|
|
860
863
|
updateMessage(msgId, msg) {
|
|
861
864
|
return null;
|
|
862
865
|
}
|
|
866
|
+
syncTasks(tasks, cacheDuration) {
|
|
867
|
+
return null;
|
|
868
|
+
}
|
|
869
|
+
getTaskDetail(task) {
|
|
870
|
+
return null;
|
|
871
|
+
}
|
|
872
|
+
refreshTasksCache(cacheDuration, tasks) {
|
|
873
|
+
return null;
|
|
874
|
+
}
|
|
863
875
|
getFields(objectApiName) {
|
|
864
876
|
}
|
|
865
877
|
getField(objectApiName, fieldApiName) {
|
|
@@ -1285,3 +1297,42 @@ async function getDefaultIntegrationTenantAccessToken() {
|
|
|
1285
1297
|
appId: res.appId,
|
|
1286
1298
|
};
|
|
1287
1299
|
}
|
|
1300
|
+
async function syncTasks(tasks, cacheDuration) {
|
|
1301
|
+
let options = commonHttp.getOptions(null, openapiHttpPath.taskCenterSyncTasks);
|
|
1302
|
+
let urlPath = options._reqPath.replace(replaceKeys.namespace, await (0, common_1.getNamespaceForOpenAndFaaSSDK)());
|
|
1303
|
+
options.json = {
|
|
1304
|
+
'tasks': JSON.stringify(tasks),
|
|
1305
|
+
'cache_duration': cacheDuration,
|
|
1306
|
+
};
|
|
1307
|
+
let res = await openapi.doRequest(null, urlPath, options);
|
|
1308
|
+
return res.affect;
|
|
1309
|
+
}
|
|
1310
|
+
async function getTaskDetail(task) {
|
|
1311
|
+
let options = commonHttp.getOptions(null, openapiHttpPath.taskCenterGetTaskDetail);
|
|
1312
|
+
let urlPath = options._reqPath.replace(replaceKeys.namespace, await (0, common_1.getNamespaceForOpenAndFaaSSDK)());
|
|
1313
|
+
options.json = {
|
|
1314
|
+
'task': JSON.stringify(task),
|
|
1315
|
+
};
|
|
1316
|
+
let res = await openapi.doRequest(null, urlPath, options);
|
|
1317
|
+
return {
|
|
1318
|
+
taskDetail: {
|
|
1319
|
+
taskID: res?.task_id,
|
|
1320
|
+
aPaaSRecord: {
|
|
1321
|
+
objectID: res?.APaaSRecord?.object_id,
|
|
1322
|
+
ObjectAPIName: res?.APaaSRecord?.object_api_name,
|
|
1323
|
+
RecordID: res?.APaaSRecord?.record_id,
|
|
1324
|
+
RecordData: res?.APaaSRecord?.record_data,
|
|
1325
|
+
}
|
|
1326
|
+
}
|
|
1327
|
+
};
|
|
1328
|
+
}
|
|
1329
|
+
async function refreshTasksCache(tasks, cacheDuration) {
|
|
1330
|
+
let options = commonHttp.getOptions(null, openapiHttpPath.taskCenterRefreshTasksCache);
|
|
1331
|
+
let urlPath = options._reqPath.replace(replaceKeys.namespace, await (0, common_1.getNamespaceForOpenAndFaaSSDK)());
|
|
1332
|
+
options.json = {
|
|
1333
|
+
'tasks': JSON.stringify(tasks),
|
|
1334
|
+
'cache_duration': cacheDuration,
|
|
1335
|
+
};
|
|
1336
|
+
let res = await openapi.doRequest(null, urlPath, options);
|
|
1337
|
+
return res.affect;
|
|
1338
|
+
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { _IKAllEndpoint, _IKQuery } from './IObject';
|
|
2
|
-
import { ITransactionGetter } from './transaction';
|
|
3
|
-
import { IDB } from '../db';
|
|
4
|
-
import { metadataMap } from '../../../data/index';
|
|
5
|
-
import { IOql } from './oql/ioql';
|
|
6
|
-
export declare class DBV3<T, mt = metadataMap> implements IDB<T, mt> {
|
|
7
|
-
objectApiName: string;
|
|
8
|
-
constructor(objectApiName?: string);
|
|
9
|
-
/**
|
|
10
|
-
* 操作指定对象的记录数据
|
|
11
|
-
* @param objectApiName 指定对象的 ApiName
|
|
12
|
-
* @example
|
|
13
|
-
* ```
|
|
14
|
-
* context.db.object('_user').where({
|
|
15
|
-
* gender: 'male'
|
|
16
|
-
* }).find()
|
|
17
|
-
* ```
|
|
18
|
-
*/
|
|
19
|
-
object<K extends keyof mt>(objectApiName: K): _IKAllEndpoint<mt[K]> & _IKQuery<mt[K]>;
|
|
20
|
-
/**
|
|
21
|
-
* 创建一个新的空事务
|
|
22
|
-
* @example
|
|
23
|
-
* ```
|
|
24
|
-
* let tx = context.db.newTransaction();
|
|
25
|
-
* let user = tx.object('_user').registerCreate({
|
|
26
|
-
* _name: new kunlun.type.Multilingual({ zh: '用户1', en: 'user1' }),
|
|
27
|
-
* });
|
|
28
|
-
* let contract = tx.object('contract').registerCreate({
|
|
29
|
-
* _name: new kunlun.type.Multilingual({ zh: '用户1的合同', en: 'user1's contract' }),
|
|
30
|
-
* user: {id: user._id}
|
|
31
|
-
* });
|
|
32
|
-
* await tx.commit();
|
|
33
|
-
* ```
|
|
34
|
-
*/
|
|
35
|
-
newTransaction(): ITransactionGetter<T, mt>;
|
|
36
|
-
/**
|
|
37
|
-
* OQL 操作
|
|
38
|
-
* @param oql 指定 OQL 语句
|
|
39
|
-
* @example
|
|
40
|
-
* ```
|
|
41
|
-
* let users = await context.db.oql('select _email from _user').execute();
|
|
42
|
-
* ```
|
|
43
|
-
*/
|
|
44
|
-
oql(oql: string): IOql;
|
|
45
|
-
oql(oql: string, nameArgs: Record<string, any>): IOql;
|
|
46
|
-
toDataParam(): any;
|
|
47
|
-
}
|
package/context/db/impl/dbV3.js
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DBV3 = void 0;
|
|
4
|
-
const object_1 = require("./object");
|
|
5
|
-
const index_1 = require("./transaction/index");
|
|
6
|
-
const oql_1 = require("./oql/oql");
|
|
7
|
-
class DBV3 {
|
|
8
|
-
constructor(objectApiName) {
|
|
9
|
-
this.objectApiName = objectApiName;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* 操作指定对象的记录数据
|
|
13
|
-
* @param objectApiName 指定对象的 ApiName
|
|
14
|
-
* @example
|
|
15
|
-
* ```
|
|
16
|
-
* context.db.object('_user').where({
|
|
17
|
-
* gender: 'male'
|
|
18
|
-
* }).find()
|
|
19
|
-
* ```
|
|
20
|
-
*/
|
|
21
|
-
object(objectApiName) {
|
|
22
|
-
const appCtx = {
|
|
23
|
-
dataVersion: "v3",
|
|
24
|
-
};
|
|
25
|
-
return new object_1._KObject(objectApiName, appCtx);
|
|
26
|
-
}
|
|
27
|
-
;
|
|
28
|
-
/**
|
|
29
|
-
* 创建一个新的空事务
|
|
30
|
-
* @example
|
|
31
|
-
* ```
|
|
32
|
-
* let tx = context.db.newTransaction();
|
|
33
|
-
* let user = tx.object('_user').registerCreate({
|
|
34
|
-
* _name: new kunlun.type.Multilingual({ zh: '用户1', en: 'user1' }),
|
|
35
|
-
* });
|
|
36
|
-
* let contract = tx.object('contract').registerCreate({
|
|
37
|
-
* _name: new kunlun.type.Multilingual({ zh: '用户1的合同', en: 'user1's contract' }),
|
|
38
|
-
* user: {id: user._id}
|
|
39
|
-
* });
|
|
40
|
-
* await tx.commit();
|
|
41
|
-
* ```
|
|
42
|
-
*/
|
|
43
|
-
newTransaction() {
|
|
44
|
-
const appCtx = {
|
|
45
|
-
dataVersion: "v3",
|
|
46
|
-
};
|
|
47
|
-
return new index_1.Transaction(this.objectApiName, appCtx);
|
|
48
|
-
}
|
|
49
|
-
;
|
|
50
|
-
oql(oql, nameArgs) {
|
|
51
|
-
const appCtx = {
|
|
52
|
-
dataVersion: "v3",
|
|
53
|
-
};
|
|
54
|
-
if (nameArgs) {
|
|
55
|
-
return new oql_1.Oql(oql, nameArgs, appCtx);
|
|
56
|
-
}
|
|
57
|
-
return new oql_1.Oql(oql, undefined, appCtx);
|
|
58
|
-
}
|
|
59
|
-
toDataParam() {
|
|
60
|
-
console.log("================= toDataParam");
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
exports.DBV3 = DBV3;
|