@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,22 @@
|
|
|
1
|
+
import {IOql} from "./ioql";
|
|
2
|
+
import * as Request from "../../../../request/interface";
|
|
3
|
+
|
|
4
|
+
export class Oql implements IOql {
|
|
5
|
+
oql: string;
|
|
6
|
+
params: any[];
|
|
7
|
+
namedParams: Record<string, any>;
|
|
8
|
+
|
|
9
|
+
constructor(oql: string) {
|
|
10
|
+
this.oql = oql;
|
|
11
|
+
this.params = [];
|
|
12
|
+
this.namedParams = {};
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
async execute(): Promise<any[]> {
|
|
16
|
+
let records = await Request.GetInstance().oql(this.oql, this.params, this.namedParams)
|
|
17
|
+
if (records && Array.isArray(records)) {
|
|
18
|
+
return records;
|
|
19
|
+
}
|
|
20
|
+
return [];
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const ASC = "asc";
|
|
2
|
+
export declare const DESC = "desc";
|
|
3
|
+
export declare type OrderType = 'asc' | 'desc';
|
|
4
|
+
export declare class Order {
|
|
5
|
+
field: string;
|
|
6
|
+
type: string;
|
|
7
|
+
direction: OrderType;
|
|
8
|
+
constructor(fieldApiName: string, direction: OrderType);
|
|
9
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Order = exports.DESC = exports.ASC = void 0;
|
|
4
|
+
exports.ASC = 'asc';
|
|
5
|
+
exports.DESC = 'desc';
|
|
6
|
+
class Order {
|
|
7
|
+
constructor(fieldApiName, direction) {
|
|
8
|
+
this.field = fieldApiName;
|
|
9
|
+
this.type = "";
|
|
10
|
+
this.direction = direction;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.Order = Order;
|
|
14
|
+
//# sourceMappingURL=order.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"order.js","sourceRoot":"","sources":["order.ts"],"names":[],"mappings":";;;AAAa,QAAA,GAAG,GAAG,KAAK,CAAC;AACZ,QAAA,IAAI,GAAG,MAAM,CAAC;AAI3B,MAAa,KAAK;IAKd,YAAY,YAAoB,EAAE,SAAoB;QAClD,IAAI,CAAC,KAAK,GAAG,YAAY,CAAA;QACzB,IAAI,CAAC,IAAI,GAAG,EAAE,CAAA;QACd,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;IAC9B,CAAC;CACJ;AAVD,sBAUC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export const ASC = 'asc';
|
|
2
|
+
export const DESC = 'desc';
|
|
3
|
+
|
|
4
|
+
export type OrderType = 'asc' | 'desc';
|
|
5
|
+
|
|
6
|
+
export class Order {
|
|
7
|
+
field: string
|
|
8
|
+
type: string
|
|
9
|
+
direction: OrderType
|
|
10
|
+
|
|
11
|
+
constructor(fieldApiName: string, direction: OrderType) {
|
|
12
|
+
this.field = fieldApiName
|
|
13
|
+
this.type = ""
|
|
14
|
+
this.direction = direction
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export default class PropertiesStore<Properties> {
|
|
2
|
+
private map;
|
|
3
|
+
properties(obj: object): Properties;
|
|
4
|
+
get(key: object): Properties | undefined;
|
|
5
|
+
set(key: object, value: Properties): WeakMap<object, Properties>;
|
|
6
|
+
has(key: object): boolean;
|
|
7
|
+
delete(key: object): boolean;
|
|
8
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
class PropertiesStore {
|
|
4
|
+
constructor() {
|
|
5
|
+
this.map = new WeakMap();
|
|
6
|
+
}
|
|
7
|
+
properties(obj) {
|
|
8
|
+
const properties = this.get(obj);
|
|
9
|
+
if (!properties) {
|
|
10
|
+
throw Error("Properties store error. ");
|
|
11
|
+
}
|
|
12
|
+
return properties;
|
|
13
|
+
}
|
|
14
|
+
get(key) {
|
|
15
|
+
return this.map.get(key);
|
|
16
|
+
}
|
|
17
|
+
set(key, value) {
|
|
18
|
+
return this.map.set(key, value);
|
|
19
|
+
}
|
|
20
|
+
has(key) {
|
|
21
|
+
return this.map.has(key);
|
|
22
|
+
}
|
|
23
|
+
delete(key) {
|
|
24
|
+
return this.map.delete(key);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.default = PropertiesStore;
|
|
28
|
+
//# sourceMappingURL=propertiesStore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"propertiesStore.js","sourceRoot":"","sources":["propertiesStore.ts"],"names":[],"mappings":";;AAAA,MAAqB,eAAe;IAApC;QACY,QAAG,GAAG,IAAI,OAAO,EAAsB,CAAC;IAyBlD,CAAC;IAvBC,UAAU,CAAC,GAAW;QACpB,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACjC,IAAI,CAAC,UAAU,EAAE;YACf,MAAM,KAAK,CAAC,0BAA0B,CAAC,CAAC;SACzC;QACD,OAAO,UAAU,CAAC;IACpB,CAAC;IAED,GAAG,CAAC,GAAW;QACb,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC3B,CAAC;IAED,GAAG,CAAC,GAAW,EAAE,KAAiB;QAChC,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IAClC,CAAC;IAED,GAAG,CAAC,GAAW;QACb,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC3B,CAAC;IAED,MAAM,CAAC,GAAW;QAChB,OAAO,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAC9B,CAAC;CACF;AA1BH,kCA0BG"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export default class PropertiesStore<Properties> {
|
|
2
|
+
private map = new WeakMap<object, Properties>();
|
|
3
|
+
|
|
4
|
+
properties(obj: object): Properties {
|
|
5
|
+
const properties = this.get(obj);
|
|
6
|
+
if (!properties) {
|
|
7
|
+
throw Error("Properties store error. ");
|
|
8
|
+
}
|
|
9
|
+
return properties;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
get(key: object): Properties | undefined {
|
|
13
|
+
return this.map.get(key);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
set(key: object, value: Properties): WeakMap<object, Properties> {
|
|
17
|
+
return this.map.set(key, value);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
has(key: object): boolean {
|
|
21
|
+
return this.map.has(key);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
delete(key: object): boolean {
|
|
25
|
+
return this.map.delete(key);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Order, OrderType } from './order';
|
|
2
|
+
import { Logic } from '../../../kunlun/operator/impl/logic';
|
|
3
|
+
export declare const maxLimit = 200;
|
|
4
|
+
/**
|
|
5
|
+
* 查询构造器,在 DB 中被初始化,用于构建一次查询
|
|
6
|
+
*/
|
|
7
|
+
export declare class QueryBuilder {
|
|
8
|
+
objectApiName: string;
|
|
9
|
+
dataSource: string;
|
|
10
|
+
select: string[];
|
|
11
|
+
where: Logic[];
|
|
12
|
+
limit: number;
|
|
13
|
+
offset: number;
|
|
14
|
+
order: Order[];
|
|
15
|
+
logic: Logic;
|
|
16
|
+
constructor(objectApiName: string);
|
|
17
|
+
addLogic(logic: Logic): void;
|
|
18
|
+
getLogic(): Logic;
|
|
19
|
+
addSelect(fieldApiName: string): void;
|
|
20
|
+
addSelects(fields: string[]): void;
|
|
21
|
+
getSelect(): string[];
|
|
22
|
+
addOrder(field: string, orderType: OrderType): void;
|
|
23
|
+
addOrders(fields: string[], orderType: OrderType): void;
|
|
24
|
+
getOrder(): Order[];
|
|
25
|
+
setOffset(offset: number): void;
|
|
26
|
+
setLimit(limit: number): void;
|
|
27
|
+
getLimit(): number;
|
|
28
|
+
getOffset(): number;
|
|
29
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.QueryBuilder = exports.maxLimit = void 0;
|
|
4
|
+
const order_1 = require("./order");
|
|
5
|
+
const logic_1 = require("../../../kunlun/operator/impl/logic");
|
|
6
|
+
const server_common_node_1 = require("@byted-apaas/server-common-node");
|
|
7
|
+
exports.maxLimit = 200;
|
|
8
|
+
/**
|
|
9
|
+
* 查询构造器,在 DB 中被初始化,用于构建一次查询
|
|
10
|
+
*/
|
|
11
|
+
class QueryBuilder {
|
|
12
|
+
constructor(objectApiName) {
|
|
13
|
+
this.objectApiName = objectApiName;
|
|
14
|
+
this.dataSource = '';
|
|
15
|
+
this.select = [];
|
|
16
|
+
this.where = null;
|
|
17
|
+
this.limit = exports.maxLimit;
|
|
18
|
+
this.offset = 0;
|
|
19
|
+
this.order = [];
|
|
20
|
+
this.logic = new logic_1.Logic();
|
|
21
|
+
}
|
|
22
|
+
addLogic(logic) {
|
|
23
|
+
this.logic.addLogic(logic);
|
|
24
|
+
}
|
|
25
|
+
getLogic() {
|
|
26
|
+
return this.logic;
|
|
27
|
+
}
|
|
28
|
+
addSelect(fieldApiName) {
|
|
29
|
+
this.select.push(fieldApiName);
|
|
30
|
+
}
|
|
31
|
+
addSelects(fields) {
|
|
32
|
+
fields.forEach(field => {
|
|
33
|
+
// field 非空,则 push 进查询条件
|
|
34
|
+
if (field) {
|
|
35
|
+
this.select.push(field);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
getSelect() {
|
|
40
|
+
return this.select;
|
|
41
|
+
}
|
|
42
|
+
addOrder(field, orderType) {
|
|
43
|
+
this.order.push(new order_1.Order(field, orderType));
|
|
44
|
+
}
|
|
45
|
+
addOrders(fields, orderType) {
|
|
46
|
+
fields.forEach(field => this.order.push(new order_1.Order(field, orderType)));
|
|
47
|
+
}
|
|
48
|
+
getOrder() {
|
|
49
|
+
return this.order;
|
|
50
|
+
}
|
|
51
|
+
setOffset(offset) {
|
|
52
|
+
if (offset < 0) {
|
|
53
|
+
// need import exceptions
|
|
54
|
+
throw new server_common_node_1.exceptions.InvalidParamError(`offset(${offset}) < 0`);
|
|
55
|
+
}
|
|
56
|
+
this.offset = offset;
|
|
57
|
+
}
|
|
58
|
+
setLimit(limit) {
|
|
59
|
+
if (limit < 1) {
|
|
60
|
+
// need import exceptions
|
|
61
|
+
throw new server_common_node_1.exceptions.InvalidParamError(`limit(${limit}) < 1`);
|
|
62
|
+
}
|
|
63
|
+
if (limit > exports.maxLimit) {
|
|
64
|
+
// need import exceptions
|
|
65
|
+
throw new server_common_node_1.exceptions.InvalidParamError(`limit(${limit}) > ${exports.maxLimit}`);
|
|
66
|
+
}
|
|
67
|
+
this.limit = limit;
|
|
68
|
+
}
|
|
69
|
+
getLimit() {
|
|
70
|
+
return this.limit;
|
|
71
|
+
}
|
|
72
|
+
getOffset() {
|
|
73
|
+
return this.offset;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
exports.QueryBuilder = QueryBuilder;
|
|
77
|
+
//# sourceMappingURL=queryBuilder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queryBuilder.js","sourceRoot":"","sources":["queryBuilder.ts"],"names":[],"mappings":";;;AAAA,mCAA0C;AAC1C,+DAA2D;AAC3D,wEAA4D;AAE/C,QAAA,QAAQ,GAAG,GAAG,CAAC;AAE5B;;GAEG;AACH,MAAa,YAAY;IAkBrB,YAAY,aAAqB;QAC7B,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;QACjB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,KAAK,GAAG,gBAAQ,CAAC;QACtB,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;QAChB,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;QAChB,IAAI,CAAC,KAAK,GAAG,IAAI,aAAK,EAAE,CAAC;IAC7B,CAAC;IAEM,QAAQ,CAAC,KAAY;QACxB,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC/B,CAAC;IAEM,QAAQ;QACX,OAAO,IAAI,CAAC,KAAK,CAAC;IACtB,CAAC;IAEM,SAAS,CAAC,YAAoB;QACjC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAA;IAClC,CAAC;IAEM,UAAU,CAAC,MAAgB;QAC9B,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;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CAAC;IAEM,SAAS;QACZ,OAAO,IAAI,CAAC,MAAM,CAAC;IACvB,CAAC;CACJ;AA7FD,oCA6FC"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { Order, OrderType } from './order'
|
|
2
|
+
import { Logic } from '../../../kunlun/operator/impl/logic'
|
|
3
|
+
import { exceptions } from '@byted-apaas/server-common-node'
|
|
4
|
+
|
|
5
|
+
export const maxLimit = 200;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* 查询构造器,在 DB 中被初始化,用于构建一次查询
|
|
9
|
+
*/
|
|
10
|
+
export class QueryBuilder {
|
|
11
|
+
// 查询基于的对象的 api name
|
|
12
|
+
objectApiName: string
|
|
13
|
+
// data source
|
|
14
|
+
dataSource: string
|
|
15
|
+
// select 的字段名
|
|
16
|
+
select: string[]
|
|
17
|
+
// where 中的查询条件
|
|
18
|
+
where: Logic[]
|
|
19
|
+
// 查询到的记录上限
|
|
20
|
+
limit: number
|
|
21
|
+
// 查询到记录的 offset
|
|
22
|
+
offset: number
|
|
23
|
+
// 查询到记录中字段的排序,正反序由参数控制
|
|
24
|
+
order: Order[]
|
|
25
|
+
// 条件聚合后的查询逻辑
|
|
26
|
+
logic: Logic
|
|
27
|
+
|
|
28
|
+
constructor(objectApiName: string) {
|
|
29
|
+
this.objectApiName = objectApiName;
|
|
30
|
+
this.dataSource = '';
|
|
31
|
+
this.select = [];
|
|
32
|
+
this.where = null;
|
|
33
|
+
this.limit = maxLimit;
|
|
34
|
+
this.offset = 0;
|
|
35
|
+
this.order = [];
|
|
36
|
+
this.logic = new Logic();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
public addLogic(logic: Logic): void {
|
|
40
|
+
this.logic.addLogic(logic);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
public getLogic(): Logic {
|
|
44
|
+
return this.logic;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
public addSelect(fieldApiName: string): void {
|
|
48
|
+
this.select.push(fieldApiName)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
public addSelects(fields: string[]): void {
|
|
52
|
+
fields.forEach(field => {
|
|
53
|
+
// field 非空,则 push 进查询条件
|
|
54
|
+
if (field) {
|
|
55
|
+
this.select.push(field)
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
public getSelect(): string[] {
|
|
61
|
+
return this.select
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
public addOrder(field: string, orderType: OrderType): void {
|
|
65
|
+
this.order.push(new Order(field, orderType));
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
public addOrders(fields: string[], orderType: OrderType): void {
|
|
69
|
+
fields.forEach(field => this.order.push(new Order(field, orderType)));
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
public getOrder(): Order[]{
|
|
73
|
+
return this.order;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
public setOffset(offset: number): void {
|
|
77
|
+
if(offset < 0) {
|
|
78
|
+
// need import exceptions
|
|
79
|
+
throw new exceptions.InvalidParamError(`offset(${offset}) < 0`);
|
|
80
|
+
}
|
|
81
|
+
this.offset = offset;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
public setLimit(limit: number): void {
|
|
85
|
+
if(limit < 1) {
|
|
86
|
+
// need import exceptions
|
|
87
|
+
throw new exceptions.InvalidParamError(`limit(${limit}) < 1`);
|
|
88
|
+
}
|
|
89
|
+
if(limit > maxLimit) {
|
|
90
|
+
// need import exceptions
|
|
91
|
+
throw new exceptions.InvalidParamError(`limit(${limit}) > ${maxLimit}`);
|
|
92
|
+
}
|
|
93
|
+
this.limit = limit;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
public getLimit(): number {
|
|
97
|
+
return this.limit;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
public getOffset(): number {
|
|
101
|
+
return this.offset;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ITransaction, ITransactionWithCurrentObject, TransactionObject } from "../transaction";
|
|
2
|
+
import { TransactionOperation } from './operation';
|
|
3
|
+
import { currentObjApiName } from '../../../../data';
|
|
4
|
+
declare type uuidOrRecordIDResult = {
|
|
5
|
+
_id: uuidOrRecordID;
|
|
6
|
+
};
|
|
7
|
+
declare type uuidOrRecordID = number | string;
|
|
8
|
+
export declare class Transaction<T, mt> implements ITransaction<mt>, ITransactionWithCurrentObject<mt> {
|
|
9
|
+
objectApiName: string;
|
|
10
|
+
placeholders: Record<string, number>;
|
|
11
|
+
operations: TransactionOperation[];
|
|
12
|
+
uuid2result: Record<string, uuidOrRecordIDResult>;
|
|
13
|
+
isCommit: boolean;
|
|
14
|
+
batchResults: (string | number)[][];
|
|
15
|
+
constructor(objectApiName: string);
|
|
16
|
+
currentObject(): TransactionObject<mt[currentObjApiName]>;
|
|
17
|
+
object<T extends keyof mt>(objectApiName: T): TransactionObject<mt[T]>;
|
|
18
|
+
commit(): Promise<void>;
|
|
19
|
+
}
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Transaction = void 0;
|
|
4
|
+
const server_common_node_1 = require("@byted-apaas/server-common-node");
|
|
5
|
+
const Request = require("../../../../request/interface");
|
|
6
|
+
const operation_1 = require("./operation");
|
|
7
|
+
const assert = require('assert');
|
|
8
|
+
const { v4: uuidv4 } = require("uuid");
|
|
9
|
+
class Transaction {
|
|
10
|
+
constructor(objectApiName) {
|
|
11
|
+
this.objectApiName = objectApiName;
|
|
12
|
+
this.placeholders = {};
|
|
13
|
+
this.operations = [];
|
|
14
|
+
this.uuid2result = {};
|
|
15
|
+
this.isCommit = false;
|
|
16
|
+
this.batchResults = [];
|
|
17
|
+
}
|
|
18
|
+
// @ts-ignore
|
|
19
|
+
currentObject() {
|
|
20
|
+
if (!this.objectApiName) {
|
|
21
|
+
throw new server_common_node_1.exceptions.InternalError(`objectApiName is empty`);
|
|
22
|
+
}
|
|
23
|
+
return this.object(this.objectApiName);
|
|
24
|
+
}
|
|
25
|
+
object(objectApiName) {
|
|
26
|
+
if (!objectApiName) {
|
|
27
|
+
throw new server_common_node_1.exceptions.InvalidParamError(`objectApiName is empty`);
|
|
28
|
+
}
|
|
29
|
+
return {
|
|
30
|
+
// 注册创建的逻辑:
|
|
31
|
+
// 事务中进行创建和不使用事务其实是一样的,特别之处在于返回的 ID 是由 SDK 生成的 uuid。
|
|
32
|
+
// SDK 生成的 uuid 只是为了 Mock 住 ID 这个字段,在事务执行后并不会落库。
|
|
33
|
+
registerCreate: (oldRecord) => {
|
|
34
|
+
if (this.isCommit) {
|
|
35
|
+
throw new server_common_node_1.exceptions.InvalidParamError("Committed transaction cannot register operations");
|
|
36
|
+
}
|
|
37
|
+
if (!oldRecord) {
|
|
38
|
+
throw new server_common_node_1.exceptions.InvalidParamError("record is empty");
|
|
39
|
+
}
|
|
40
|
+
if (server_common_node_1.checkUtils.isNotObject(oldRecord)) {
|
|
41
|
+
throw new server_common_node_1.exceptions.InvalidParamError("record is not object");
|
|
42
|
+
}
|
|
43
|
+
let record = { ...oldRecord };
|
|
44
|
+
let uuid = uuidv4();
|
|
45
|
+
let result = { _id: uuid };
|
|
46
|
+
record._id = uuid;
|
|
47
|
+
this.placeholders[uuid] = 0;
|
|
48
|
+
this.operations.push(new operation_1.CreateOperation(objectApiName, record));
|
|
49
|
+
this.uuid2result[uuid] = result;
|
|
50
|
+
return result;
|
|
51
|
+
},
|
|
52
|
+
// 注册更新的逻辑:
|
|
53
|
+
// 由于事务中创建的 Record 的 ID 是 uuid,而已经创建的 Record 的 ID 是 number 类型,因此在传入 ID 的情况下类型为 string | number
|
|
54
|
+
registerUpdate: (idOrRecord, record) => {
|
|
55
|
+
let recordMap;
|
|
56
|
+
if (this.isCommit) {
|
|
57
|
+
throw new server_common_node_1.exceptions.InvalidParamError("Committed transaction cannot register operations");
|
|
58
|
+
}
|
|
59
|
+
if (typeof idOrRecord === "number" || typeof idOrRecord === "string") {
|
|
60
|
+
recordMap = record;
|
|
61
|
+
recordMap["_id"] = idOrRecord;
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
recordMap = idOrRecord;
|
|
65
|
+
}
|
|
66
|
+
if (!recordMap) {
|
|
67
|
+
throw new server_common_node_1.exceptions.InvalidParamError("record is empty");
|
|
68
|
+
}
|
|
69
|
+
let recordID = recordMap['_id'];
|
|
70
|
+
if (!recordID) {
|
|
71
|
+
throw new server_common_node_1.exceptions.InvalidParamError("record._id is empty");
|
|
72
|
+
}
|
|
73
|
+
this.operations.push(new operation_1.UpdateOperation(objectApiName, recordMap));
|
|
74
|
+
},
|
|
75
|
+
// 注册删除的逻辑:
|
|
76
|
+
// 注册删除和注册更新一样,ID 有可能是事务中创建的 Record,也有可能是现存的 Record,因此 ID 的类型是 string | number
|
|
77
|
+
registerDelete: (idOrRecord) => {
|
|
78
|
+
if (this.isCommit) {
|
|
79
|
+
throw new server_common_node_1.exceptions.InvalidParamError("Committed transaction cannot register operations");
|
|
80
|
+
}
|
|
81
|
+
if (!idOrRecord) {
|
|
82
|
+
throw new server_common_node_1.exceptions.InvalidParamError("record is empty");
|
|
83
|
+
}
|
|
84
|
+
let recordId = null;
|
|
85
|
+
if (typeof idOrRecord === "number" || typeof idOrRecord === "string") {
|
|
86
|
+
recordId = idOrRecord;
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
if (server_common_node_1.checkUtils.isObject(idOrRecord)) {
|
|
90
|
+
if (!idOrRecord._id) {
|
|
91
|
+
throw new server_common_node_1.exceptions.InvalidParamError("record._id is empty");
|
|
92
|
+
}
|
|
93
|
+
recordId = idOrRecord._id;
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
throw new server_common_node_1.exceptions.InvalidParamError("param type should be number | string | Object. ");
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
this.operations.push(new operation_1.DeleteOperation(objectApiName, { _id: recordId }));
|
|
100
|
+
},
|
|
101
|
+
// 注册批量创建
|
|
102
|
+
registerBatchCreate: (recordMaps) => {
|
|
103
|
+
if (this.isCommit) {
|
|
104
|
+
throw new server_common_node_1.exceptions.InvalidParamError("Committed transaction cannot register operations");
|
|
105
|
+
}
|
|
106
|
+
if (!recordMaps) {
|
|
107
|
+
throw new server_common_node_1.exceptions.InvalidParamError("recordMaps is empty");
|
|
108
|
+
}
|
|
109
|
+
if (!Array.isArray(recordMaps)) {
|
|
110
|
+
throw new server_common_node_1.exceptions.InvalidParamError("recordMaps is not Array");
|
|
111
|
+
}
|
|
112
|
+
if (recordMaps.length < 1) {
|
|
113
|
+
return [];
|
|
114
|
+
}
|
|
115
|
+
let result = [];
|
|
116
|
+
let records = [];
|
|
117
|
+
for (let oldRecord of recordMaps) {
|
|
118
|
+
let record = { ...oldRecord };
|
|
119
|
+
let uuid = uuidv4();
|
|
120
|
+
this.placeholders[uuid] = 0;
|
|
121
|
+
record['_id'] = uuid;
|
|
122
|
+
result.push(uuid);
|
|
123
|
+
records.push(record);
|
|
124
|
+
}
|
|
125
|
+
this.operations.push(new operation_1.BatchCreateOperation(objectApiName, records));
|
|
126
|
+
this.batchResults.push(result);
|
|
127
|
+
return result;
|
|
128
|
+
},
|
|
129
|
+
registerBatchUpdate: (recordMaps) => {
|
|
130
|
+
if (this.isCommit) {
|
|
131
|
+
throw new server_common_node_1.exceptions.InvalidParamError("Committed transaction cannot register operations");
|
|
132
|
+
}
|
|
133
|
+
if (!recordMaps) {
|
|
134
|
+
throw new server_common_node_1.exceptions.InvalidParamError("recordMaps is empty");
|
|
135
|
+
}
|
|
136
|
+
if (!Array.isArray(recordMaps)) {
|
|
137
|
+
throw new server_common_node_1.exceptions.InvalidParamError("recordMaps is not Array");
|
|
138
|
+
}
|
|
139
|
+
if (recordMaps.length < 1) {
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
// 判断同字段同值更新标志
|
|
143
|
+
let isSameValue = true;
|
|
144
|
+
let ids = [];
|
|
145
|
+
let flag = recordMaps[0];
|
|
146
|
+
for (let record of recordMaps) {
|
|
147
|
+
if (server_common_node_1.checkUtils.isNotObject(record)) {
|
|
148
|
+
throw new server_common_node_1.exceptions.InvalidParamError("one record of recordMaps is not object");
|
|
149
|
+
}
|
|
150
|
+
if (!record["_id"]) {
|
|
151
|
+
throw new server_common_node_1.exceptions.InvalidParamError(`one record of recordMaps has no _id ${JSON.stringify(record)}`);
|
|
152
|
+
}
|
|
153
|
+
ids.push(record["_id"]);
|
|
154
|
+
if (!deepEqualExceptID(flag, record)) {
|
|
155
|
+
isSameValue = false;
|
|
156
|
+
break;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
if (isSameValue) {
|
|
160
|
+
this.operations.push(new operation_1.BatchUpdateSameValueOperation(objectApiName, {
|
|
161
|
+
'ids': ids,
|
|
162
|
+
'value': flag,
|
|
163
|
+
}));
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
for (const i in ids) {
|
|
167
|
+
recordMaps[i]["_id"] = ids[i];
|
|
168
|
+
}
|
|
169
|
+
this.operations.push(new operation_1.BatchUpdateOperation(objectApiName, recordMaps));
|
|
170
|
+
}
|
|
171
|
+
},
|
|
172
|
+
// 注册批量删除
|
|
173
|
+
registerBatchDelete: (idOrRecords) => {
|
|
174
|
+
if (this.isCommit) {
|
|
175
|
+
throw new server_common_node_1.exceptions.InvalidParamError("Committed transaction cannot register operations");
|
|
176
|
+
}
|
|
177
|
+
if (!idOrRecords) {
|
|
178
|
+
throw new server_common_node_1.exceptions.InvalidParamError("idOrRecords is empty");
|
|
179
|
+
}
|
|
180
|
+
if (!Array.isArray(idOrRecords)) {
|
|
181
|
+
throw new server_common_node_1.exceptions.InvalidParamError("idOrRecords is not Array");
|
|
182
|
+
}
|
|
183
|
+
if (idOrRecords.length < 1) {
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
let ids = [];
|
|
187
|
+
for (const idOrRecord of idOrRecords) {
|
|
188
|
+
switch (typeof idOrRecord) {
|
|
189
|
+
case "string":
|
|
190
|
+
case "number":
|
|
191
|
+
ids.push(idOrRecord);
|
|
192
|
+
break;
|
|
193
|
+
case "object":
|
|
194
|
+
if (!idOrRecord['_id']) {
|
|
195
|
+
throw new server_common_node_1.exceptions.InvalidParamError("_id of one record is empty");
|
|
196
|
+
}
|
|
197
|
+
else {
|
|
198
|
+
ids.push(idOrRecord['_id']);
|
|
199
|
+
}
|
|
200
|
+
break;
|
|
201
|
+
default:
|
|
202
|
+
throw new server_common_node_1.exceptions.InvalidParamError("type of one param is not string | number | object");
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
this.operations.push(new operation_1.BatchDeleteOperation(objectApiName, { 'ids': ids }));
|
|
206
|
+
},
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
async commit() {
|
|
210
|
+
if (this.isCommit) {
|
|
211
|
+
throw new server_common_node_1.exceptions.InvalidParamError("The transaction cannot be committed repeatedly");
|
|
212
|
+
}
|
|
213
|
+
this.isCommit = true;
|
|
214
|
+
if (!this.operations || this.operations.length === 0) {
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
let uuid2recordId = await Request.GetInstance().modifyRecordsWithTransaction(this.placeholders, this.operations);
|
|
218
|
+
if (!uuid2recordId) {
|
|
219
|
+
throw new server_common_node_1.exceptions.InternalError("uuid2recordId is empty");
|
|
220
|
+
}
|
|
221
|
+
// 单个注册结果映射
|
|
222
|
+
for (let uuid of Object.keys(this.uuid2result)) {
|
|
223
|
+
let preResult = this.uuid2result[uuid];
|
|
224
|
+
let recordId = uuid2recordId.get(uuid);
|
|
225
|
+
if (!recordId) {
|
|
226
|
+
throw new server_common_node_1.exceptions.InternalError(`uuid (${uuid}) is not in uuid2recordId (${JSON.stringify(uuid2recordId)})`);
|
|
227
|
+
}
|
|
228
|
+
if (typeof (recordId) !== "number") {
|
|
229
|
+
throw new server_common_node_1.exceptions.InternalError(`the type (${typeof (recordId)}) of recordId (${recordId}) must be number`);
|
|
230
|
+
}
|
|
231
|
+
preResult._id = recordId;
|
|
232
|
+
}
|
|
233
|
+
if (!this.batchResults) {
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
// 批量注册结果映射
|
|
237
|
+
for (let i = 0; i < this.batchResults.length; i++) {
|
|
238
|
+
if (!this.batchResults[i]) {
|
|
239
|
+
continue;
|
|
240
|
+
}
|
|
241
|
+
for (let j = 0; j < this.batchResults[i].length; j++) {
|
|
242
|
+
if (!this.batchResults[i][j]) {
|
|
243
|
+
continue;
|
|
244
|
+
}
|
|
245
|
+
let recordId = uuid2recordId.get(this.batchResults[i][j]);
|
|
246
|
+
if (!recordId) {
|
|
247
|
+
throw new server_common_node_1.exceptions.InternalError(`uuid (${this.batchResults[i][j]}) is not in uuid2recordId (${JSON.stringify(uuid2recordId)})`);
|
|
248
|
+
}
|
|
249
|
+
if (typeof (recordId) !== "number") {
|
|
250
|
+
throw new server_common_node_1.exceptions.InternalError(`the type (${typeof (recordId)}) of recordId (${recordId}) must be number`);
|
|
251
|
+
}
|
|
252
|
+
this.batchResults[i][j] = recordId;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
exports.Transaction = Transaction;
|
|
258
|
+
function deepEqualExceptID(left, right) {
|
|
259
|
+
let leftID = left["_id"], rightID = right["_id"];
|
|
260
|
+
delete left["_id"];
|
|
261
|
+
delete right["_id"];
|
|
262
|
+
let result = deepEqual(left, right);
|
|
263
|
+
left["_id"] = leftID;
|
|
264
|
+
right["_id"] = rightID;
|
|
265
|
+
return result;
|
|
266
|
+
}
|
|
267
|
+
function deepEqual(left, right) {
|
|
268
|
+
try {
|
|
269
|
+
assert.deepStrictEqual(left, right);
|
|
270
|
+
}
|
|
271
|
+
catch (e) {
|
|
272
|
+
return false;
|
|
273
|
+
}
|
|
274
|
+
return true;
|
|
275
|
+
}
|
|
276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