@cloudbase/js-sdk 3.6.4 → 3.6.5-alpha.0
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/ai/dist/index.esm.js +1 -1
- package/ai/dist/index.esm.js.map +1 -1
- package/ai/dist/index.js +1 -1
- package/ai/dist/index.js.map +1 -1
- package/apis/dist/index.esm.js +1 -1
- package/apis/dist/index.esm.js.map +1 -1
- package/apis/dist/index.js +1 -1
- package/apis/dist/index.js.map +1 -1
- package/app/dist/index.esm.js +1 -1
- package/app/dist/index.esm.js.map +1 -1
- package/app/dist/index.js +1 -1
- package/app/dist/index.js.map +1 -1
- package/app/dist/index.node.esm.js +1 -1
- package/app/dist/index.node.esm.js.map +1 -1
- package/app/dist/index.node.js +1 -1
- package/app/dist/index.node.js.map +1 -1
- package/auth/dist/index.esm.js +1 -2
- package/auth/dist/index.esm.js.map +1 -1
- package/auth/dist/index.js +1 -2
- package/auth/dist/index.js.map +1 -1
- package/cloudrun/dist/index.esm.js +1 -1
- package/cloudrun/dist/index.esm.js.map +1 -1
- package/cloudrun/dist/index.js +1 -1
- package/cloudrun/dist/index.js.map +1 -1
- package/container/dist/index.esm.js +1 -1
- package/container/dist/index.esm.js.map +1 -1
- package/container/dist/index.js +1 -1
- package/container/dist/index.js.map +1 -1
- package/database/dist/index.d.ts +3 -0
- package/database/dist/index.esm.js +2 -0
- package/database/dist/index.esm.js.map +1 -0
- package/database/dist/index.js +2 -0
- package/database/dist/index.js.map +1 -0
- package/dist/index.cjs.js +1 -2
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +1 -2
- package/dist/index.esm.js.map +1 -1
- package/dist/index.node.cjs.js +1 -1
- package/dist/index.node.cjs.js.LICENSE.txt +0 -13
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/index.node.esm.js +1 -1
- package/dist/index.node.esm.js.LICENSE.txt +0 -13
- package/dist/index.node.esm.js.map +1 -1
- package/functions/dist/index.esm.js +1 -1
- package/functions/dist/index.esm.js.map +1 -1
- package/functions/dist/index.js +1 -1
- package/functions/dist/index.js.map +1 -1
- package/miniprogram_dist/index.js +1 -1
- package/model/dist/index.esm.js +1 -1
- package/model/dist/index.esm.js.map +1 -1
- package/model/dist/index.js +1 -1
- package/model/dist/index.js.map +1 -1
- package/mysql/dist/index.esm.js +1 -1
- package/mysql/dist/index.esm.js.map +1 -1
- package/mysql/dist/index.js +1 -1
- package/mysql/dist/index.js.map +1 -1
- package/oauth/dist/index.esm.js +1 -2
- package/oauth/dist/index.esm.js.map +1 -1
- package/oauth/dist/index.js +1 -2
- package/oauth/dist/index.js.map +1 -1
- package/package.json +17 -2
- package/realtime/dist/index.esm.js +1 -1
- package/realtime/dist/index.esm.js.map +1 -1
- package/realtime/dist/index.js +1 -1
- package/realtime/dist/index.js.map +1 -1
- package/storage/dist/index.esm.js +1 -1
- package/storage/dist/index.esm.js.map +1 -1
- package/storage/dist/index.js +1 -1
- package/storage/dist/index.js.map +1 -1
- package/types/package.json +2 -1
- package/utilities/package.json +9 -3
- package/auth/dist/index.esm.js.LICENSE.txt +0 -12
- package/auth/dist/index.js.LICENSE.txt +0 -12
- package/database/dist/commonjs/aggregate.d.ts +0 -29
- package/database/dist/commonjs/aggregate.js +0 -156
- package/database/dist/commonjs/collection.d.ts +0 -9
- package/database/dist/commonjs/collection.js +0 -49
- package/database/dist/commonjs/command.d.ts +0 -175
- package/database/dist/commonjs/command.js +0 -299
- package/database/dist/commonjs/commands/logic.d.ts +0 -24
- package/database/dist/commonjs/commands/logic.js +0 -89
- package/database/dist/commonjs/commands/query.d.ts +0 -68
- package/database/dist/commonjs/commands/query.js +0 -160
- package/database/dist/commonjs/commands/update.d.ts +0 -29
- package/database/dist/commonjs/commands/update.js +0 -51
- package/database/dist/commonjs/config/app.config.d.ts +0 -6
- package/database/dist/commonjs/config/app.config.js +0 -7
- package/database/dist/commonjs/config/error.config.d.ts +0 -3
- package/database/dist/commonjs/config/error.config.js +0 -16
- package/database/dist/commonjs/const/code.d.ts +0 -30
- package/database/dist/commonjs/const/code.js +0 -33
- package/database/dist/commonjs/constant.d.ts +0 -51
- package/database/dist/commonjs/constant.js +0 -75
- package/database/dist/commonjs/document.d.ts +0 -11
- package/database/dist/commonjs/document.js +0 -260
- package/database/dist/commonjs/geo/index.d.ts +0 -6
- package/database/dist/commonjs/geo/index.js +0 -22
- package/database/dist/commonjs/geo/interface.d.ts +0 -24
- package/database/dist/commonjs/geo/interface.js +0 -2
- package/database/dist/commonjs/geo/lineString.d.ts +0 -19
- package/database/dist/commonjs/geo/lineString.js +0 -86
- package/database/dist/commonjs/geo/multiLineString.d.ts +0 -18
- package/database/dist/commonjs/geo/multiLineString.js +0 -95
- package/database/dist/commonjs/geo/multiPoint.d.ts +0 -18
- package/database/dist/commonjs/geo/multiPoint.js +0 -79
- package/database/dist/commonjs/geo/multiPolygon.d.ts +0 -18
- package/database/dist/commonjs/geo/multiPolygon.js +0 -122
- package/database/dist/commonjs/geo/point.d.ts +0 -19
- package/database/dist/commonjs/geo/point.js +0 -50
- package/database/dist/commonjs/geo/polygon.d.ts +0 -19
- package/database/dist/commonjs/geo/polygon.js +0 -109
- package/database/dist/commonjs/helper/symbol.d.ts +0 -14
- package/database/dist/commonjs/helper/symbol.js +0 -31
- package/database/dist/commonjs/index.d.ts +0 -40
- package/database/dist/commonjs/index.js +0 -61
- package/database/dist/commonjs/lib/util.d.ts +0 -1
- package/database/dist/commonjs/lib/util.js +0 -26
- package/database/dist/commonjs/operator-map.d.ts +0 -4
- package/database/dist/commonjs/operator-map.js +0 -24
- package/database/dist/commonjs/query.d.ts +0 -22
- package/database/dist/commonjs/query.js +0 -252
- package/database/dist/commonjs/regexp/index.d.ts +0 -14
- package/database/dist/commonjs/regexp/index.js +0 -33
- package/database/dist/commonjs/serializer/common.d.ts +0 -11
- package/database/dist/commonjs/serializer/common.js +0 -127
- package/database/dist/commonjs/serializer/datatype.d.ts +0 -7
- package/database/dist/commonjs/serializer/datatype.js +0 -132
- package/database/dist/commonjs/serializer/query.d.ts +0 -7
- package/database/dist/commonjs/serializer/query.js +0 -232
- package/database/dist/commonjs/serializer/update.d.ts +0 -15
- package/database/dist/commonjs/serializer/update.js +0 -142
- package/database/dist/commonjs/serverDate/index.d.ts +0 -13
- package/database/dist/commonjs/serverDate/index.js +0 -30
- package/database/dist/commonjs/transaction/collection.d.ts +0 -7
- package/database/dist/commonjs/transaction/collection.js +0 -49
- package/database/dist/commonjs/transaction/document.d.ts +0 -27
- package/database/dist/commonjs/transaction/document.js +0 -205
- package/database/dist/commonjs/transaction/index.d.ts +0 -30
- package/database/dist/commonjs/transaction/index.js +0 -215
- package/database/dist/commonjs/transaction/query.d.ts +0 -43
- package/database/dist/commonjs/transaction/query.js +0 -261
- package/database/dist/commonjs/typings/index.d.ts +0 -40
- package/database/dist/commonjs/typings/index.js +0 -2
- package/database/dist/commonjs/typings/realtime.d.ts +0 -219
- package/database/dist/commonjs/typings/realtime.js +0 -2
- package/database/dist/commonjs/util.d.ts +0 -9
- package/database/dist/commonjs/util.js +0 -145
- package/database/dist/commonjs/utils/error.d.ts +0 -38
- package/database/dist/commonjs/utils/error.js +0 -91
- package/database/dist/commonjs/utils/msg.d.ts +0 -0
- package/database/dist/commonjs/utils/msg.js +0 -0
- package/database/dist/commonjs/utils/symbol.d.ts +0 -8
- package/database/dist/commonjs/utils/symbol.js +0 -58
- package/database/dist/commonjs/utils/type.d.ts +0 -13
- package/database/dist/commonjs/utils/type.js +0 -34
- package/database/dist/commonjs/utils/utils.d.ts +0 -4
- package/database/dist/commonjs/utils/utils.js +0 -39
- package/database/dist/commonjs/validate.d.ts +0 -1
- package/database/dist/commonjs/validate.js +0 -60
- package/database/dist/esm/aggregate.d.ts +0 -29
- package/database/dist/esm/aggregate.js +0 -154
- package/database/dist/esm/collection.d.ts +0 -9
- package/database/dist/esm/collection.js +0 -46
- package/database/dist/esm/command.d.ts +0 -175
- package/database/dist/esm/command.js +0 -296
- package/database/dist/esm/commands/logic.d.ts +0 -24
- package/database/dist/esm/commands/logic.js +0 -84
- package/database/dist/esm/commands/query.d.ts +0 -68
- package/database/dist/esm/commands/query.js +0 -154
- package/database/dist/esm/commands/update.d.ts +0 -29
- package/database/dist/esm/commands/update.js +0 -46
- package/database/dist/esm/config/app.config.d.ts +0 -6
- package/database/dist/esm/config/app.config.js +0 -5
- package/database/dist/esm/config/error.config.d.ts +0 -3
- package/database/dist/esm/config/error.config.js +0 -13
- package/database/dist/esm/const/code.d.ts +0 -30
- package/database/dist/esm/const/code.js +0 -30
- package/database/dist/esm/constant.d.ts +0 -51
- package/database/dist/esm/constant.js +0 -65
- package/database/dist/esm/document.d.ts +0 -11
- package/database/dist/esm/document.js +0 -257
- package/database/dist/esm/geo/index.d.ts +0 -6
- package/database/dist/esm/geo/index.js +0 -6
- package/database/dist/esm/geo/interface.d.ts +0 -24
- package/database/dist/esm/geo/interface.js +0 -1
- package/database/dist/esm/geo/lineString.d.ts +0 -19
- package/database/dist/esm/geo/lineString.js +0 -83
- package/database/dist/esm/geo/multiLineString.d.ts +0 -18
- package/database/dist/esm/geo/multiLineString.js +0 -92
- package/database/dist/esm/geo/multiPoint.d.ts +0 -18
- package/database/dist/esm/geo/multiPoint.js +0 -76
- package/database/dist/esm/geo/multiPolygon.d.ts +0 -18
- package/database/dist/esm/geo/multiPolygon.js +0 -119
- package/database/dist/esm/geo/point.d.ts +0 -19
- package/database/dist/esm/geo/point.js +0 -47
- package/database/dist/esm/geo/polygon.d.ts +0 -19
- package/database/dist/esm/geo/polygon.js +0 -106
- package/database/dist/esm/helper/symbol.d.ts +0 -14
- package/database/dist/esm/helper/symbol.js +0 -14
- package/database/dist/esm/index.d.ts +0 -40
- package/database/dist/esm/index.js +0 -55
- package/database/dist/esm/lib/util.d.ts +0 -1
- package/database/dist/esm/lib/util.js +0 -22
- package/database/dist/esm/operator-map.d.ts +0 -4
- package/database/dist/esm/operator-map.js +0 -20
- package/database/dist/esm/query.d.ts +0 -22
- package/database/dist/esm/query.js +0 -249
- package/database/dist/esm/regexp/index.d.ts +0 -14
- package/database/dist/esm/regexp/index.js +0 -29
- package/database/dist/esm/serializer/common.d.ts +0 -11
- package/database/dist/esm/serializer/common.js +0 -118
- package/database/dist/esm/serializer/datatype.d.ts +0 -7
- package/database/dist/esm/serializer/datatype.js +0 -127
- package/database/dist/esm/serializer/query.d.ts +0 -7
- package/database/dist/esm/serializer/query.js +0 -229
- package/database/dist/esm/serializer/update.d.ts +0 -15
- package/database/dist/esm/serializer/update.js +0 -139
- package/database/dist/esm/serverDate/index.d.ts +0 -13
- package/database/dist/esm/serverDate/index.js +0 -26
- package/database/dist/esm/transaction/collection.d.ts +0 -7
- package/database/dist/esm/transaction/collection.js +0 -46
- package/database/dist/esm/transaction/document.d.ts +0 -27
- package/database/dist/esm/transaction/document.js +0 -202
- package/database/dist/esm/transaction/index.d.ts +0 -30
- package/database/dist/esm/transaction/index.js +0 -210
- package/database/dist/esm/transaction/query.d.ts +0 -43
- package/database/dist/esm/transaction/query.js +0 -258
- package/database/dist/esm/typings/index.d.ts +0 -40
- package/database/dist/esm/typings/index.js +0 -1
- package/database/dist/esm/typings/realtime.d.ts +0 -219
- package/database/dist/esm/typings/realtime.js +0 -1
- package/database/dist/esm/util.d.ts +0 -9
- package/database/dist/esm/util.js +0 -142
- package/database/dist/esm/utils/error.d.ts +0 -38
- package/database/dist/esm/utils/error.js +0 -84
- package/database/dist/esm/utils/msg.d.ts +0 -0
- package/database/dist/esm/utils/msg.js +0 -0
- package/database/dist/esm/utils/symbol.d.ts +0 -8
- package/database/dist/esm/utils/symbol.js +0 -55
- package/database/dist/esm/utils/type.d.ts +0 -13
- package/database/dist/esm/utils/type.js +0 -20
- package/database/dist/esm/utils/utils.d.ts +0 -4
- package/database/dist/esm/utils/utils.js +0 -33
- package/database/dist/esm/validate.d.ts +0 -1
- package/database/dist/esm/validate.js +0 -57
- package/dist/index.cjs.js.LICENSE.txt +0 -12
- package/dist/index.esm.js.LICENSE.txt +0 -12
- package/oauth/dist/index.esm.js.LICENSE.txt +0 -12
- package/oauth/dist/index.js.LICENSE.txt +0 -12
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.SYMBOL_REGEXP = exports.SYMBOL_SERVER_DATE = exports.SYMBOL_GEO_MULTI_POLYGON = exports.SYMBOL_GEO_MULTI_LINE_STRING = exports.SYMBOL_GEO_MULTI_POINT = exports.SYMBOL_GEO_POLYGON = exports.SYMBOL_GEO_LINE_STRING = exports.SYMBOL_GEO_POINT = exports.SYMBOL_LOGIC_COMMAND = exports.SYMBOL_QUERY_COMMAND = exports.SYMBOL_UPDATE_COMMAND = exports.SYMBOL_UNSET_FIELD_NAME = void 0;
|
|
18
|
-
var symbol_1 = require("../utils/symbol");
|
|
19
|
-
__exportStar(require("../utils/symbol"), exports);
|
|
20
|
-
exports.SYMBOL_UNSET_FIELD_NAME = symbol_1.default.for('UNSET_FIELD_NAME');
|
|
21
|
-
exports.SYMBOL_UPDATE_COMMAND = symbol_1.default.for('UPDATE_COMMAND');
|
|
22
|
-
exports.SYMBOL_QUERY_COMMAND = symbol_1.default.for('QUERY_COMMAND');
|
|
23
|
-
exports.SYMBOL_LOGIC_COMMAND = symbol_1.default.for('LOGIC_COMMAND');
|
|
24
|
-
exports.SYMBOL_GEO_POINT = symbol_1.default.for('GEO_POINT');
|
|
25
|
-
exports.SYMBOL_GEO_LINE_STRING = symbol_1.default.for('SYMBOL_GEO_LINE_STRING');
|
|
26
|
-
exports.SYMBOL_GEO_POLYGON = symbol_1.default.for('SYMBOL_GEO_POLYGON');
|
|
27
|
-
exports.SYMBOL_GEO_MULTI_POINT = symbol_1.default.for('SYMBOL_GEO_MULTI_POINT');
|
|
28
|
-
exports.SYMBOL_GEO_MULTI_LINE_STRING = symbol_1.default.for('SYMBOL_GEO_MULTI_LINE_STRING');
|
|
29
|
-
exports.SYMBOL_GEO_MULTI_POLYGON = symbol_1.default.for('SYMBOL_GEO_MULTI_POLYGON');
|
|
30
|
-
exports.SYMBOL_SERVER_DATE = symbol_1.default.for('SERVER_DATE');
|
|
31
|
-
exports.SYMBOL_REGEXP = symbol_1.default.for('REGEXP');
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { Point } from './geo/point';
|
|
2
|
-
import { CollectionReference } from './collection';
|
|
3
|
-
import { Command } from './command';
|
|
4
|
-
export interface IDbConfig {
|
|
5
|
-
env?: string;
|
|
6
|
-
instance?: string;
|
|
7
|
-
database?: string;
|
|
8
|
-
[key: string]: any;
|
|
9
|
-
}
|
|
10
|
-
interface GeoTeyp {
|
|
11
|
-
Point: typeof Point;
|
|
12
|
-
}
|
|
13
|
-
export { Query } from './query';
|
|
14
|
-
export { CollectionReference } from './collection';
|
|
15
|
-
export { DocumentReference } from './document';
|
|
16
|
-
export declare class Db {
|
|
17
|
-
Geo: GeoTeyp;
|
|
18
|
-
command: typeof Command;
|
|
19
|
-
RegExp: any;
|
|
20
|
-
serverDate: any;
|
|
21
|
-
startTransaction: any;
|
|
22
|
-
runTransaction: any;
|
|
23
|
-
logicCommand: any;
|
|
24
|
-
updateCommand: any;
|
|
25
|
-
queryCommand: any;
|
|
26
|
-
config: IDbConfig;
|
|
27
|
-
static ws: any;
|
|
28
|
-
static reqClass: any;
|
|
29
|
-
static wsClass: any;
|
|
30
|
-
static wsClientClass: any;
|
|
31
|
-
static createSign: Function;
|
|
32
|
-
static getAccessToken: Function;
|
|
33
|
-
static dataVersion: string;
|
|
34
|
-
static runtime: string;
|
|
35
|
-
static appSecretInfo: any;
|
|
36
|
-
static createRequest(config: IDbConfig): any;
|
|
37
|
-
constructor(config?: IDbConfig);
|
|
38
|
-
collection(collName: string): CollectionReference;
|
|
39
|
-
createCollection(collName: string): any;
|
|
40
|
-
}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Db = exports.DocumentReference = exports.CollectionReference = exports.Query = void 0;
|
|
4
|
-
var Geo = require("./geo/index");
|
|
5
|
-
var collection_1 = require("./collection");
|
|
6
|
-
var command_1 = require("./command");
|
|
7
|
-
var index_1 = require("./serverDate/index");
|
|
8
|
-
var index_2 = require("./regexp/index");
|
|
9
|
-
var index_3 = require("./transaction/index");
|
|
10
|
-
var logic_1 = require("./commands/logic");
|
|
11
|
-
var query_1 = require("./commands/query");
|
|
12
|
-
var update_1 = require("./commands/update");
|
|
13
|
-
var query_2 = require("./query");
|
|
14
|
-
Object.defineProperty(exports, "Query", { enumerable: true, get: function () { return query_2.Query; } });
|
|
15
|
-
var collection_2 = require("./collection");
|
|
16
|
-
Object.defineProperty(exports, "CollectionReference", { enumerable: true, get: function () { return collection_2.CollectionReference; } });
|
|
17
|
-
var document_1 = require("./document");
|
|
18
|
-
Object.defineProperty(exports, "DocumentReference", { enumerable: true, get: function () { return document_1.DocumentReference; } });
|
|
19
|
-
var Db = (function () {
|
|
20
|
-
function Db(config) {
|
|
21
|
-
this.config = config;
|
|
22
|
-
this.Geo = Geo;
|
|
23
|
-
this.serverDate = index_1.ServerDateConstructor;
|
|
24
|
-
this.command = command_1.Command;
|
|
25
|
-
this.RegExp = index_2.RegExpConstructor;
|
|
26
|
-
this.startTransaction = index_3.startTransaction;
|
|
27
|
-
this.runTransaction = index_3.runTransaction;
|
|
28
|
-
this.logicCommand = logic_1.LogicCommand;
|
|
29
|
-
this.updateCommand = update_1.UpdateCommand;
|
|
30
|
-
this.queryCommand = query_1.QueryCommand;
|
|
31
|
-
}
|
|
32
|
-
Db.createRequest = function (config) {
|
|
33
|
-
var request = new Db.reqClass(config);
|
|
34
|
-
var originalSend = request.send;
|
|
35
|
-
request.send = function (action, data) {
|
|
36
|
-
if (config.instance) {
|
|
37
|
-
data.instance = config.instance;
|
|
38
|
-
}
|
|
39
|
-
if (config.database) {
|
|
40
|
-
data.database = config.database;
|
|
41
|
-
}
|
|
42
|
-
return originalSend.call(this, action, data);
|
|
43
|
-
};
|
|
44
|
-
return request;
|
|
45
|
-
};
|
|
46
|
-
Db.prototype.collection = function (collName) {
|
|
47
|
-
if (!collName) {
|
|
48
|
-
throw new Error('Collection name is required');
|
|
49
|
-
}
|
|
50
|
-
return new collection_1.CollectionReference(this, collName);
|
|
51
|
-
};
|
|
52
|
-
Db.prototype.createCollection = function (collName) {
|
|
53
|
-
var request = Db.createRequest(this.config);
|
|
54
|
-
var params = {
|
|
55
|
-
collectionName: collName
|
|
56
|
-
};
|
|
57
|
-
return request.send('database.addCollection', params);
|
|
58
|
-
};
|
|
59
|
-
return Db;
|
|
60
|
-
}());
|
|
61
|
-
exports.Db = Db;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const createPromiseCallback: () => any;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createPromiseCallback = void 0;
|
|
4
|
-
var createPromiseCallback = function () {
|
|
5
|
-
var cb = function () { };
|
|
6
|
-
if (!Promise) {
|
|
7
|
-
cb.promise = {};
|
|
8
|
-
var throwPromiseNotDefined = function () {
|
|
9
|
-
throw new Error('Your Node runtime does support ES6 Promises. ' +
|
|
10
|
-
'Set "global.Promise" to your preferred implementation of promises.');
|
|
11
|
-
};
|
|
12
|
-
Object.defineProperty(cb.promise, 'then', { get: throwPromiseNotDefined });
|
|
13
|
-
Object.defineProperty(cb.promise, 'catch', { get: throwPromiseNotDefined });
|
|
14
|
-
return cb;
|
|
15
|
-
}
|
|
16
|
-
var promise = new Promise(function (resolve, reject) {
|
|
17
|
-
cb = function (err, data) {
|
|
18
|
-
if (err)
|
|
19
|
-
return reject(err);
|
|
20
|
-
return resolve(data);
|
|
21
|
-
};
|
|
22
|
-
});
|
|
23
|
-
cb.promise = promise;
|
|
24
|
-
return cb;
|
|
25
|
-
};
|
|
26
|
-
exports.createPromiseCallback = createPromiseCallback;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.operatorToString = exports.OperatorMap = void 0;
|
|
4
|
-
var query_1 = require("./commands/query");
|
|
5
|
-
var logic_1 = require("./commands/logic");
|
|
6
|
-
var update_1 = require("./commands/update");
|
|
7
|
-
exports.OperatorMap = {};
|
|
8
|
-
for (var key in query_1.QUERY_COMMANDS_LITERAL) {
|
|
9
|
-
exports.OperatorMap[key] = '$' + key;
|
|
10
|
-
}
|
|
11
|
-
for (var key in logic_1.LOGIC_COMMANDS_LITERAL) {
|
|
12
|
-
exports.OperatorMap[key] = '$' + key;
|
|
13
|
-
}
|
|
14
|
-
for (var key in update_1.UPDATE_COMMANDS_LITERAL) {
|
|
15
|
-
exports.OperatorMap[key] = '$' + key;
|
|
16
|
-
}
|
|
17
|
-
exports.OperatorMap[query_1.QUERY_COMMANDS_LITERAL.NEQ] = '$ne';
|
|
18
|
-
exports.OperatorMap[update_1.UPDATE_COMMANDS_LITERAL.REMOVE] = '$unset';
|
|
19
|
-
exports.OperatorMap[update_1.UPDATE_COMMANDS_LITERAL.SHIFT] = '$pop';
|
|
20
|
-
exports.OperatorMap[update_1.UPDATE_COMMANDS_LITERAL.UNSHIFT] = '$push';
|
|
21
|
-
function operatorToString(operator) {
|
|
22
|
-
return exports.OperatorMap[operator] || '$' + operator;
|
|
23
|
-
}
|
|
24
|
-
exports.operatorToString = operatorToString;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { OrderByDirection } from './constant';
|
|
2
|
-
import { IWatchOptions, DBRealtimeListener } from './typings/index';
|
|
3
|
-
interface GetRes {
|
|
4
|
-
data: any[];
|
|
5
|
-
requestId: string;
|
|
6
|
-
total: number;
|
|
7
|
-
limit: number;
|
|
8
|
-
offset: number;
|
|
9
|
-
}
|
|
10
|
-
export declare class Query {
|
|
11
|
-
get(callback?: any): Promise<GetRes>;
|
|
12
|
-
count(callback?: any): any;
|
|
13
|
-
where(query: object): Query;
|
|
14
|
-
orderBy(fieldPath: string, directionStr: OrderByDirection): Query;
|
|
15
|
-
limit(limit: number): Query;
|
|
16
|
-
skip(offset: number): Query;
|
|
17
|
-
update(data: Object, callback?: any): Promise<any>;
|
|
18
|
-
field(projection: any): Query;
|
|
19
|
-
remove(callback?: any): any;
|
|
20
|
-
watch: (options: IWatchOptions) => DBRealtimeListener;
|
|
21
|
-
}
|
|
22
|
-
export {};
|
|
@@ -1,252 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.Query = void 0;
|
|
15
|
-
var util_1 = require("./lib/util");
|
|
16
|
-
var constant_1 = require("./constant");
|
|
17
|
-
var index_1 = require("./index");
|
|
18
|
-
var validate_1 = require("./validate");
|
|
19
|
-
var util_2 = require("./util");
|
|
20
|
-
var query_1 = require("./serializer/query");
|
|
21
|
-
var update_1 = require("./serializer/update");
|
|
22
|
-
var constant_2 = require("./constant");
|
|
23
|
-
var utils_1 = require("./utils/utils");
|
|
24
|
-
var Query = (function () {
|
|
25
|
-
function Query(db, coll, fieldFilters, fieldOrders, queryOptions) {
|
|
26
|
-
var _this = this;
|
|
27
|
-
this.watch = function (options) {
|
|
28
|
-
var ws = (0, utils_1.getWsInstance)(_this._db);
|
|
29
|
-
return ws.watch(__assign(__assign({}, options), { envId: _this._db.config.env, collectionName: _this._coll, query: JSON.stringify(_this._fieldFilters || {}), limit: _this._queryOptions.limit, orderBy: _this._fieldOrders
|
|
30
|
-
? _this._fieldOrders.reduce(function (acc, cur) {
|
|
31
|
-
acc[cur.field] = cur.direction;
|
|
32
|
-
return acc;
|
|
33
|
-
}, {})
|
|
34
|
-
: undefined }));
|
|
35
|
-
};
|
|
36
|
-
this._db = db;
|
|
37
|
-
this._coll = coll;
|
|
38
|
-
this._fieldFilters = fieldFilters;
|
|
39
|
-
this._fieldOrders = fieldOrders || [];
|
|
40
|
-
this._queryOptions = queryOptions || {};
|
|
41
|
-
this._request = index_1.Db.createRequest(this._db.config);
|
|
42
|
-
}
|
|
43
|
-
Query.prototype.get = function (callback) {
|
|
44
|
-
callback = callback || (0, util_1.createPromiseCallback)();
|
|
45
|
-
var newOder = [];
|
|
46
|
-
if (this._fieldOrders) {
|
|
47
|
-
this._fieldOrders.forEach(function (order) {
|
|
48
|
-
newOder.push(order);
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
var param = {
|
|
52
|
-
collectionName: this._coll,
|
|
53
|
-
queryType: constant_1.QueryType.WHERE
|
|
54
|
-
};
|
|
55
|
-
if (this._fieldFilters) {
|
|
56
|
-
param.query = this._fieldFilters;
|
|
57
|
-
}
|
|
58
|
-
if (newOder.length > 0) {
|
|
59
|
-
param.order = newOder;
|
|
60
|
-
}
|
|
61
|
-
if (this._queryOptions.offset) {
|
|
62
|
-
param.offset = this._queryOptions.offset;
|
|
63
|
-
}
|
|
64
|
-
if (this._queryOptions.limit) {
|
|
65
|
-
param.limit = this._queryOptions.limit < 1000 ? this._queryOptions.limit : 1000;
|
|
66
|
-
}
|
|
67
|
-
else {
|
|
68
|
-
param.limit = 100;
|
|
69
|
-
}
|
|
70
|
-
if (this._queryOptions.projection) {
|
|
71
|
-
param.projection = this._queryOptions.projection;
|
|
72
|
-
}
|
|
73
|
-
this._request
|
|
74
|
-
.send('database.queryDocument', param)
|
|
75
|
-
.then(function (res) {
|
|
76
|
-
if (res.code) {
|
|
77
|
-
callback(0, res);
|
|
78
|
-
}
|
|
79
|
-
else {
|
|
80
|
-
var documents = util_2.Util.formatResDocumentData(res.data.list);
|
|
81
|
-
var result = {
|
|
82
|
-
data: documents,
|
|
83
|
-
requestId: res.requestId
|
|
84
|
-
};
|
|
85
|
-
if (res.total !== undefined)
|
|
86
|
-
result.total = res.total;
|
|
87
|
-
if (res.limit !== undefined)
|
|
88
|
-
result.limit = res.limit;
|
|
89
|
-
if (res.offset !== undefined)
|
|
90
|
-
result.offset = res.offset;
|
|
91
|
-
callback(0, result);
|
|
92
|
-
}
|
|
93
|
-
})
|
|
94
|
-
.catch(function (err) {
|
|
95
|
-
callback(err);
|
|
96
|
-
});
|
|
97
|
-
return callback.promise;
|
|
98
|
-
};
|
|
99
|
-
Query.prototype.count = function (callback) {
|
|
100
|
-
callback = callback || (0, util_1.createPromiseCallback)();
|
|
101
|
-
var param = {
|
|
102
|
-
collectionName: this._coll,
|
|
103
|
-
queryType: constant_1.QueryType.WHERE
|
|
104
|
-
};
|
|
105
|
-
if (this._fieldFilters) {
|
|
106
|
-
param.query = this._fieldFilters;
|
|
107
|
-
}
|
|
108
|
-
this._request
|
|
109
|
-
.send('database.countDocument', param)
|
|
110
|
-
.then(function (res) {
|
|
111
|
-
if (res.code) {
|
|
112
|
-
callback(0, res);
|
|
113
|
-
}
|
|
114
|
-
else {
|
|
115
|
-
callback(0, {
|
|
116
|
-
requestId: res.requestId,
|
|
117
|
-
total: res.data.total
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
})
|
|
121
|
-
.catch(function (e) {
|
|
122
|
-
callback(e);
|
|
123
|
-
});
|
|
124
|
-
return callback.promise;
|
|
125
|
-
};
|
|
126
|
-
Query.prototype.where = function (query) {
|
|
127
|
-
if (Object.prototype.toString.call(query).slice(8, -1) !== 'Object') {
|
|
128
|
-
throw Error(constant_2.ErrorCode.QueryParamTypeError);
|
|
129
|
-
}
|
|
130
|
-
var keys = Object.keys(query);
|
|
131
|
-
var checkFlag = keys.some(function (item) {
|
|
132
|
-
return query[item] !== undefined;
|
|
133
|
-
});
|
|
134
|
-
if (keys.length && !checkFlag) {
|
|
135
|
-
throw Error(constant_2.ErrorCode.QueryParamValueError);
|
|
136
|
-
}
|
|
137
|
-
return new Query(this._db, this._coll, query_1.QuerySerializer.encode(query), this._fieldOrders, this._queryOptions);
|
|
138
|
-
};
|
|
139
|
-
Query.prototype.orderBy = function (fieldPath, directionStr) {
|
|
140
|
-
validate_1.Validate.isFieldPath(fieldPath);
|
|
141
|
-
validate_1.Validate.isFieldOrder(directionStr);
|
|
142
|
-
var newOrder = {
|
|
143
|
-
field: fieldPath,
|
|
144
|
-
direction: directionStr
|
|
145
|
-
};
|
|
146
|
-
var combinedOrders = this._fieldOrders.concat(newOrder);
|
|
147
|
-
return new Query(this._db, this._coll, this._fieldFilters, combinedOrders, this._queryOptions);
|
|
148
|
-
};
|
|
149
|
-
Query.prototype.limit = function (limit) {
|
|
150
|
-
validate_1.Validate.isInteger('limit', limit);
|
|
151
|
-
var option = __assign({}, this._queryOptions);
|
|
152
|
-
option.limit = limit;
|
|
153
|
-
return new Query(this._db, this._coll, this._fieldFilters, this._fieldOrders, option);
|
|
154
|
-
};
|
|
155
|
-
Query.prototype.skip = function (offset) {
|
|
156
|
-
validate_1.Validate.isInteger('offset', offset);
|
|
157
|
-
var option = __assign({}, this._queryOptions);
|
|
158
|
-
option.offset = offset;
|
|
159
|
-
return new Query(this._db, this._coll, this._fieldFilters, this._fieldOrders, option);
|
|
160
|
-
};
|
|
161
|
-
Query.prototype.update = function (data, callback) {
|
|
162
|
-
callback = callback || (0, util_1.createPromiseCallback)();
|
|
163
|
-
if (!data || typeof data !== 'object') {
|
|
164
|
-
return Promise.resolve({
|
|
165
|
-
code: 'INVALID_PARAM',
|
|
166
|
-
message: '参数必需是非空对象'
|
|
167
|
-
});
|
|
168
|
-
}
|
|
169
|
-
if (data.hasOwnProperty('_id')) {
|
|
170
|
-
return Promise.resolve({
|
|
171
|
-
code: 'INVALID_PARAM',
|
|
172
|
-
message: '不能更新_id的值'
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
|
-
var param = {
|
|
176
|
-
collectionName: this._coll,
|
|
177
|
-
query: this._fieldFilters,
|
|
178
|
-
queryType: constant_1.QueryType.WHERE,
|
|
179
|
-
multi: true,
|
|
180
|
-
merge: true,
|
|
181
|
-
upsert: false,
|
|
182
|
-
data: update_1.UpdateSerializer.encode(data)
|
|
183
|
-
};
|
|
184
|
-
this._request
|
|
185
|
-
.send('database.updateDocument', param)
|
|
186
|
-
.then(function (res) {
|
|
187
|
-
if (res.code) {
|
|
188
|
-
callback(0, res);
|
|
189
|
-
}
|
|
190
|
-
else {
|
|
191
|
-
callback(0, {
|
|
192
|
-
requestId: res.requestId,
|
|
193
|
-
updated: res.data.updated,
|
|
194
|
-
upsertId: res.data.upsert_id
|
|
195
|
-
});
|
|
196
|
-
}
|
|
197
|
-
})
|
|
198
|
-
.catch(function (e) {
|
|
199
|
-
callback(e);
|
|
200
|
-
});
|
|
201
|
-
return callback.promise;
|
|
202
|
-
};
|
|
203
|
-
Query.prototype.field = function (projection) {
|
|
204
|
-
for (var k in projection) {
|
|
205
|
-
if (projection[k]) {
|
|
206
|
-
if (typeof projection[k] !== 'object') {
|
|
207
|
-
projection[k] = 1;
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
else {
|
|
211
|
-
projection[k] = 0;
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
var option = __assign({}, this._queryOptions);
|
|
215
|
-
option.projection = projection;
|
|
216
|
-
return new Query(this._db, this._coll, this._fieldFilters, this._fieldOrders, option);
|
|
217
|
-
};
|
|
218
|
-
Query.prototype.remove = function (callback) {
|
|
219
|
-
callback = callback || (0, util_1.createPromiseCallback)();
|
|
220
|
-
if (Object.keys(this._queryOptions).length > 0) {
|
|
221
|
-
console.warn('`offset`, `limit` and `projection` are not supported in remove() operation');
|
|
222
|
-
}
|
|
223
|
-
if (this._fieldOrders.length > 0) {
|
|
224
|
-
console.warn('`orderBy` is not supported in remove() operation');
|
|
225
|
-
}
|
|
226
|
-
var param = {
|
|
227
|
-
collectionName: this._coll,
|
|
228
|
-
query: query_1.QuerySerializer.encode(this._fieldFilters),
|
|
229
|
-
queryType: constant_1.QueryType.WHERE,
|
|
230
|
-
multi: true
|
|
231
|
-
};
|
|
232
|
-
this._request
|
|
233
|
-
.send('database.deleteDocument', param)
|
|
234
|
-
.then(function (res) {
|
|
235
|
-
if (res.code) {
|
|
236
|
-
callback(0, res);
|
|
237
|
-
}
|
|
238
|
-
else {
|
|
239
|
-
callback(0, {
|
|
240
|
-
requestId: res.requestId,
|
|
241
|
-
deleted: res.data.deleted
|
|
242
|
-
});
|
|
243
|
-
}
|
|
244
|
-
})
|
|
245
|
-
.catch(function (e) {
|
|
246
|
-
callback(e);
|
|
247
|
-
});
|
|
248
|
-
return callback.promise;
|
|
249
|
-
};
|
|
250
|
-
return Query;
|
|
251
|
-
}());
|
|
252
|
-
exports.Query = Query;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export declare class RegExp {
|
|
2
|
-
$regex: string;
|
|
3
|
-
$options: string;
|
|
4
|
-
constructor({ regexp, options }: {
|
|
5
|
-
regexp: any;
|
|
6
|
-
options: any;
|
|
7
|
-
});
|
|
8
|
-
parse(): {
|
|
9
|
-
$regex: string;
|
|
10
|
-
$options: string;
|
|
11
|
-
};
|
|
12
|
-
get _internalType(): import("../utils/symbol").InternalSymbol;
|
|
13
|
-
}
|
|
14
|
-
export declare function RegExpConstructor(param: any): RegExp;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RegExpConstructor = exports.RegExp = void 0;
|
|
4
|
-
var symbol_1 = require("../helper/symbol");
|
|
5
|
-
var RegExp = (function () {
|
|
6
|
-
function RegExp(_a) {
|
|
7
|
-
var regexp = _a.regexp, options = _a.options;
|
|
8
|
-
if (!regexp) {
|
|
9
|
-
throw new TypeError('regexp must be a string');
|
|
10
|
-
}
|
|
11
|
-
this.$regex = regexp;
|
|
12
|
-
this.$options = options;
|
|
13
|
-
}
|
|
14
|
-
RegExp.prototype.parse = function () {
|
|
15
|
-
return {
|
|
16
|
-
$regex: this.$regex,
|
|
17
|
-
$options: this.$options
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
Object.defineProperty(RegExp.prototype, "_internalType", {
|
|
21
|
-
get: function () {
|
|
22
|
-
return symbol_1.SYMBOL_REGEXP;
|
|
23
|
-
},
|
|
24
|
-
enumerable: false,
|
|
25
|
-
configurable: true
|
|
26
|
-
});
|
|
27
|
-
return RegExp;
|
|
28
|
-
}());
|
|
29
|
-
exports.RegExp = RegExp;
|
|
30
|
-
function RegExpConstructor(param) {
|
|
31
|
-
return new RegExp(param);
|
|
32
|
-
}
|
|
33
|
-
exports.RegExpConstructor = RegExpConstructor;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { LogicCommand } from '../commands/logic';
|
|
2
|
-
export type IQueryCondition = Record<string, any> | LogicCommand;
|
|
3
|
-
export type AnyObject = {
|
|
4
|
-
[x: string]: any;
|
|
5
|
-
};
|
|
6
|
-
export declare function flattenQueryObject(query: Record<string, any>): Record<string, any>;
|
|
7
|
-
export declare function flattenObject(object: AnyObject): AnyObject;
|
|
8
|
-
export declare function mergeConditionAfterEncode(query: Record<string, any>, condition: Record<string, any>, key: string): void;
|
|
9
|
-
export declare function isConversionRequired(val: any): boolean;
|
|
10
|
-
export declare function encodeInternalDataType(val: any): IQueryCondition;
|
|
11
|
-
export declare function decodeInternalDataType(object: AnyObject): any;
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
14
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
15
|
-
if (!m) return o;
|
|
16
|
-
var i = m.call(o), r, ar = [], e;
|
|
17
|
-
try {
|
|
18
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
19
|
-
}
|
|
20
|
-
catch (error) { e = { error: error }; }
|
|
21
|
-
finally {
|
|
22
|
-
try {
|
|
23
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
24
|
-
}
|
|
25
|
-
finally { if (e) throw e.error; }
|
|
26
|
-
}
|
|
27
|
-
return ar;
|
|
28
|
-
};
|
|
29
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
30
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
31
|
-
if (ar || !(i in from)) {
|
|
32
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
33
|
-
ar[i] = from[i];
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.decodeInternalDataType = exports.encodeInternalDataType = exports.isConversionRequired = exports.mergeConditionAfterEncode = exports.flattenObject = exports.flattenQueryObject = void 0;
|
|
40
|
-
var type_1 = require("../utils/type");
|
|
41
|
-
var datatype_1 = require("./datatype");
|
|
42
|
-
function flatten(query, shouldPreserverObject, parents, visited) {
|
|
43
|
-
var cloned = __assign({}, query);
|
|
44
|
-
for (var key in query) {
|
|
45
|
-
if (/^\$/.test(key))
|
|
46
|
-
continue;
|
|
47
|
-
var value = query[key];
|
|
48
|
-
if (!value)
|
|
49
|
-
continue;
|
|
50
|
-
if ((0, type_1.isObject)(value) && !shouldPreserverObject(value)) {
|
|
51
|
-
if (visited.indexOf(value) > -1) {
|
|
52
|
-
throw new Error('Cannot convert circular structure to JSON');
|
|
53
|
-
}
|
|
54
|
-
var newParents = __spreadArray(__spreadArray([], __read(parents), false), [
|
|
55
|
-
key,
|
|
56
|
-
], false);
|
|
57
|
-
var newVisited = __spreadArray(__spreadArray([], __read(visited), false), [
|
|
58
|
-
value,
|
|
59
|
-
], false);
|
|
60
|
-
var flattenedChild = flatten(value, shouldPreserverObject, newParents, newVisited);
|
|
61
|
-
cloned[key] = flattenedChild;
|
|
62
|
-
var hasKeyNotCombined = false;
|
|
63
|
-
for (var childKey in flattenedChild) {
|
|
64
|
-
if (!/^\$/.test(childKey)) {
|
|
65
|
-
cloned["".concat(key, ".").concat(childKey)] = flattenedChild[childKey];
|
|
66
|
-
delete cloned[key][childKey];
|
|
67
|
-
}
|
|
68
|
-
else {
|
|
69
|
-
hasKeyNotCombined = true;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
if (!hasKeyNotCombined) {
|
|
73
|
-
delete cloned[key];
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
return cloned;
|
|
78
|
-
}
|
|
79
|
-
function flattenQueryObject(query) {
|
|
80
|
-
return flatten(query, isConversionRequired, [], [query]);
|
|
81
|
-
}
|
|
82
|
-
exports.flattenQueryObject = flattenQueryObject;
|
|
83
|
-
function flattenObject(object) {
|
|
84
|
-
return flatten(object, function (_) { return false; }, [], [object]);
|
|
85
|
-
}
|
|
86
|
-
exports.flattenObject = flattenObject;
|
|
87
|
-
function mergeConditionAfterEncode(query, condition, key) {
|
|
88
|
-
if (!condition[key]) {
|
|
89
|
-
delete query[key];
|
|
90
|
-
}
|
|
91
|
-
for (var conditionKey in condition) {
|
|
92
|
-
if (query[conditionKey]) {
|
|
93
|
-
if ((0, type_1.isArray)(query[conditionKey])) {
|
|
94
|
-
query[conditionKey].push(condition[conditionKey]);
|
|
95
|
-
}
|
|
96
|
-
else if ((0, type_1.isObject)(query[conditionKey])) {
|
|
97
|
-
if ((0, type_1.isObject)(condition[conditionKey])) {
|
|
98
|
-
Object.assign(query[conditionKey], condition[conditionKey]);
|
|
99
|
-
}
|
|
100
|
-
else {
|
|
101
|
-
console.warn("unmergable condition, query is object but condition is ".concat((0, type_1.getType)(condition), ", can only overwrite"), condition, key);
|
|
102
|
-
query[conditionKey] = condition[conditionKey];
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
else {
|
|
106
|
-
console.warn("to-merge query is of type ".concat((0, type_1.getType)(query), ", can only overwrite"), query, condition, key);
|
|
107
|
-
query[conditionKey] = condition[conditionKey];
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
else {
|
|
111
|
-
query[conditionKey] = condition[conditionKey];
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
exports.mergeConditionAfterEncode = mergeConditionAfterEncode;
|
|
116
|
-
function isConversionRequired(val) {
|
|
117
|
-
return (0, type_1.isInternalObject)(val) || (0, type_1.isDate)(val) || (0, type_1.isRegExp)(val);
|
|
118
|
-
}
|
|
119
|
-
exports.isConversionRequired = isConversionRequired;
|
|
120
|
-
function encodeInternalDataType(val) {
|
|
121
|
-
return (0, datatype_1.serialize)(val);
|
|
122
|
-
}
|
|
123
|
-
exports.encodeInternalDataType = encodeInternalDataType;
|
|
124
|
-
function decodeInternalDataType(object) {
|
|
125
|
-
return (0, datatype_1.deserialize)(object);
|
|
126
|
-
}
|
|
127
|
-
exports.decodeInternalDataType = decodeInternalDataType;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { LogicCommand } from '../commands/logic';
|
|
2
|
-
export type IQueryCondition = Record<string, any> | LogicCommand;
|
|
3
|
-
export type AnyObject = {
|
|
4
|
-
[x: string]: any;
|
|
5
|
-
};
|
|
6
|
-
export declare function serialize(val: any): IQueryCondition;
|
|
7
|
-
export declare function deserialize(object: AnyObject): any;
|