@cloudbase/database 1.4.3 → 1.5.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/dist/commonjs/ObjectId/index.d.ts +1 -1
- package/dist/commonjs/ObjectId/index.js +16 -9
- package/dist/commonjs/aggregate.js +126 -75
- package/dist/commonjs/collection.d.ts +3 -2
- package/dist/commonjs/collection.js +131 -58
- package/dist/commonjs/command.d.ts +5 -5
- package/dist/commonjs/command.js +181 -154
- package/dist/commonjs/commands/logic.js +30 -20
- package/dist/commonjs/commands/query.d.ts +1 -1
- package/dist/commonjs/commands/query.js +85 -65
- package/dist/commonjs/commands/update.js +9 -7
- package/dist/commonjs/config/error.config.js +1 -0
- package/dist/commonjs/const/code.js +1 -0
- package/dist/commonjs/constant.d.ts +7 -7
- package/dist/commonjs/constant.js +13 -11
- package/dist/commonjs/document.d.ts +10 -6
- package/dist/commonjs/document.js +305 -193
- package/dist/commonjs/geo/index.js +20 -9
- package/dist/commonjs/geo/lineString.d.ts +1 -1
- package/dist/commonjs/geo/lineString.js +62 -33
- package/dist/commonjs/geo/multiLineString.d.ts +1 -1
- package/dist/commonjs/geo/multiLineString.js +71 -32
- package/dist/commonjs/geo/multiPoint.d.ts +1 -1
- package/dist/commonjs/geo/multiPoint.js +58 -29
- package/dist/commonjs/geo/multiPolygon.d.ts +1 -1
- package/dist/commonjs/geo/multiPolygon.js +96 -36
- package/dist/commonjs/geo/point.d.ts +1 -1
- package/dist/commonjs/geo/point.js +30 -23
- package/dist/commonjs/geo/polygon.d.ts +1 -1
- package/dist/commonjs/geo/polygon.js +78 -39
- package/dist/commonjs/helper/symbol.js +17 -5
- package/dist/commonjs/index.d.ts +8 -2
- package/dist/commonjs/index.js +73 -20
- package/dist/commonjs/lib/util.d.ts +1 -0
- package/dist/commonjs/lib/util.js +26 -0
- package/dist/commonjs/operator-map.js +7 -6
- package/dist/commonjs/query.d.ts +8 -4
- package/dist/commonjs/query.js +308 -201
- package/dist/commonjs/regexp/index.d.ts +1 -1
- package/dist/commonjs/regexp/index.js +16 -9
- package/dist/commonjs/serializer/common.d.ts +2 -2
- package/dist/commonjs/serializer/common.js +59 -22
- package/dist/commonjs/serializer/datatype.d.ts +2 -2
- package/dist/commonjs/serializer/datatype.js +58 -21
- package/dist/commonjs/serializer/query.d.ts +1 -1
- package/dist/commonjs/serializer/query.js +137 -127
- package/dist/commonjs/serializer/update.d.ts +1 -1
- package/dist/commonjs/serializer/update.js +83 -78
- package/dist/commonjs/serverDate/index.d.ts +1 -1
- package/dist/commonjs/serverDate/index.js +16 -9
- package/dist/commonjs/transaction/collection.d.ts +7 -0
- package/dist/commonjs/transaction/collection.js +49 -0
- package/dist/commonjs/transaction/document.d.ts +27 -0
- package/dist/commonjs/transaction/document.js +205 -0
- package/dist/commonjs/transaction/index.js +196 -86
- package/dist/commonjs/transaction/query.d.ts +43 -0
- package/dist/commonjs/transaction/query.js +261 -0
- package/dist/commonjs/typings/index.d.ts +4 -4
- package/dist/commonjs/typings/realtime.d.ts +16 -16
- package/dist/commonjs/util.js +123 -92
- package/dist/commonjs/utils/error.d.ts +2 -1
- package/dist/commonjs/utils/error.js +74 -38
- package/dist/commonjs/utils/symbol.js +33 -14
- package/dist/commonjs/utils/type.d.ts +1 -1
- package/dist/commonjs/utils/type.js +25 -13
- package/dist/commonjs/utils/utils.d.ts +4 -1
- package/dist/commonjs/utils/utils.js +93 -22
- package/dist/commonjs/validate.js +79 -63
- package/dist/esm/ObjectId/index.d.ts +1 -1
- package/dist/esm/ObjectId/index.js +15 -8
- package/dist/esm/aggregate.js +118 -66
- package/dist/esm/collection.d.ts +3 -2
- package/dist/esm/collection.js +125 -52
- package/dist/esm/command.d.ts +5 -5
- package/dist/esm/command.js +175 -147
- package/dist/esm/commands/logic.js +30 -20
- package/dist/esm/commands/query.d.ts +1 -1
- package/dist/esm/commands/query.js +91 -71
- package/dist/esm/commands/update.js +8 -6
- package/dist/esm/config/error.config.js +1 -1
- package/dist/esm/const/code.js +1 -1
- package/dist/esm/constant.d.ts +7 -7
- package/dist/esm/constant.js +12 -11
- package/dist/esm/document.d.ts +10 -6
- package/dist/esm/document.js +297 -185
- package/dist/esm/geo/interface.js +1 -0
- package/dist/esm/geo/lineString.d.ts +1 -1
- package/dist/esm/geo/lineString.js +57 -28
- package/dist/esm/geo/multiLineString.d.ts +1 -1
- package/dist/esm/geo/multiLineString.js +66 -27
- package/dist/esm/geo/multiPoint.d.ts +1 -1
- package/dist/esm/geo/multiPoint.js +53 -24
- package/dist/esm/geo/multiPolygon.d.ts +1 -1
- package/dist/esm/geo/multiPolygon.js +91 -31
- package/dist/esm/geo/point.d.ts +1 -1
- package/dist/esm/geo/point.js +26 -19
- package/dist/esm/geo/polygon.d.ts +1 -1
- package/dist/esm/geo/polygon.js +73 -34
- package/dist/esm/helper/symbol.js +13 -13
- package/dist/esm/index.d.ts +8 -2
- package/dist/esm/index.js +62 -9
- package/dist/esm/lib/util.d.ts +1 -0
- package/dist/esm/lib/util.js +22 -0
- package/dist/esm/operator-map.js +4 -4
- package/dist/esm/query.d.ts +8 -4
- package/dist/esm/query.js +299 -192
- package/dist/esm/regexp/index.d.ts +1 -1
- package/dist/esm/regexp/index.js +15 -8
- package/dist/esm/serializer/common.d.ts +2 -2
- package/dist/esm/serializer/common.js +49 -13
- package/dist/esm/serializer/datatype.d.ts +2 -2
- package/dist/esm/serializer/datatype.js +44 -8
- package/dist/esm/serializer/query.d.ts +1 -1
- package/dist/esm/serializer/query.js +112 -102
- package/dist/esm/serializer/update.d.ts +1 -1
- package/dist/esm/serializer/update.js +69 -64
- package/dist/esm/serverDate/index.d.ts +1 -1
- package/dist/esm/serverDate/index.js +15 -8
- package/dist/esm/transaction/collection.d.ts +7 -0
- package/dist/esm/transaction/collection.js +46 -0
- package/dist/esm/transaction/document.d.ts +27 -0
- package/dist/esm/transaction/document.js +202 -0
- package/dist/esm/transaction/index.js +191 -81
- package/dist/esm/transaction/query.d.ts +43 -0
- package/dist/esm/transaction/query.js +258 -0
- package/dist/esm/typings/index.d.ts +4 -4
- package/dist/esm/typings/index.js +1 -0
- package/dist/esm/typings/realtime.d.ts +16 -16
- package/dist/esm/typings/realtime.js +1 -0
- package/dist/esm/util.js +121 -90
- package/dist/esm/utils/error.d.ts +2 -1
- package/dist/esm/utils/error.js +70 -35
- package/dist/esm/utils/symbol.js +33 -14
- package/dist/esm/utils/type.d.ts +1 -1
- package/dist/esm/utils/type.js +12 -12
- package/dist/esm/utils/utils.d.ts +4 -1
- package/dist/esm/utils/utils.js +78 -16
- package/dist/esm/validate.js +65 -49
- package/jest.config.js +14 -0
- package/package.json +14 -10
- package/src/aggregate.ts +1 -5
- package/src/collection.ts +15 -2
- package/src/document.ts +45 -34
- package/src/index.ts +51 -4
- package/src/query.ts +33 -29
- package/src/serializer/query.ts +18 -6
- package/src/transaction/index.ts +1 -1
- package/src/typings/index.ts +0 -4
- package/src/utils/utils.ts +46 -0
- package/src/validate.ts +3 -6
- package/tests/gateway-contract.test.ts +180 -0
- package/tests/index.test.ts +283 -0
- package/tests/transaction-query.test.ts +207 -0
- package/tsconfig.esm.json +4 -2
- package/tsconfig.json +16 -6
- package/tsconfig.test.json +15 -0
- package/dist/commonjs/realtime/error.d.ts +0 -7
- package/dist/commonjs/realtime/error.js +0 -11
- package/dist/commonjs/realtime/listener.d.ts +0 -14
- package/dist/commonjs/realtime/listener.js +0 -17
- package/dist/commonjs/realtime/message.d.ts +0 -3
- package/dist/commonjs/realtime/message.js +0 -10
- package/dist/commonjs/realtime/snapshot.d.ts +0 -16
- package/dist/commonjs/realtime/snapshot.js +0 -42
- package/dist/commonjs/realtime/virtual-websocket-client.d.ts +0 -63
- package/dist/commonjs/realtime/virtual-websocket-client.js +0 -736
- package/dist/commonjs/realtime/websocket-client.d.ts +0 -78
- package/dist/commonjs/realtime/websocket-client.js +0 -567
- package/dist/commonjs/realtime/ws-event.d.ts +0 -126
- package/dist/commonjs/realtime/ws-event.js +0 -139
- package/dist/commonjs/transaction.d.ts +0 -42
- package/dist/commonjs/transaction.js +0 -126
- package/dist/esm/realtime/error.d.ts +0 -7
- package/dist/esm/realtime/error.js +0 -8
- package/dist/esm/realtime/listener.d.ts +0 -14
- package/dist/esm/realtime/listener.js +0 -14
- package/dist/esm/realtime/message.d.ts +0 -3
- package/dist/esm/realtime/message.js +0 -6
- package/dist/esm/realtime/snapshot.d.ts +0 -16
- package/dist/esm/realtime/snapshot.js +0 -39
- package/dist/esm/realtime/virtual-websocket-client.d.ts +0 -63
- package/dist/esm/realtime/virtual-websocket-client.js +0 -733
- package/dist/esm/realtime/websocket-client.d.ts +0 -78
- package/dist/esm/realtime/websocket-client.js +0 -564
- package/dist/esm/realtime/ws-event.d.ts +0 -126
- package/dist/esm/realtime/ws-event.js +0 -137
- package/dist/esm/transaction.d.ts +0 -42
- package/dist/esm/transaction.js +0 -121
- package/src/realtime/error.ts +0 -19
- package/src/realtime/listener.ts +0 -35
- package/src/realtime/message.ts +0 -14
- package/src/realtime/snapshot.ts +0 -60
- package/src/realtime/virtual-websocket-client.ts +0 -1195
- package/src/realtime/websocket-client.ts +0 -995
- package/src/realtime/ws-event.ts +0 -163
- package/src/transaction.ts +0 -190
|
@@ -1,31 +1,68 @@
|
|
|
1
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
|
+
};
|
|
2
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
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");
|
|
5
42
|
function flatten(query, shouldPreserverObject, parents, visited) {
|
|
6
|
-
|
|
7
|
-
for (
|
|
43
|
+
var cloned = __assign({}, query);
|
|
44
|
+
for (var key in query) {
|
|
8
45
|
if (/^\$/.test(key))
|
|
9
46
|
continue;
|
|
10
|
-
|
|
47
|
+
var value = query[key];
|
|
11
48
|
if (value === undefined) {
|
|
12
49
|
delete cloned[key];
|
|
13
50
|
continue;
|
|
14
51
|
}
|
|
15
52
|
if (!value)
|
|
16
53
|
continue;
|
|
17
|
-
if (type_1.isObject(value) && !shouldPreserverObject(value)) {
|
|
54
|
+
if ((0, type_1.isObject)(value) && !shouldPreserverObject(value)) {
|
|
18
55
|
if (visited.indexOf(value) > -1) {
|
|
19
56
|
throw new Error('Cannot convert circular structure to JSON');
|
|
20
57
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
58
|
+
var newParents = __spreadArray(__spreadArray([], __read(parents), false), [key], false);
|
|
59
|
+
var newVisited = __spreadArray(__spreadArray([], __read(visited), false), [value], false);
|
|
60
|
+
var flattenedChild = flatten(value, shouldPreserverObject, newParents, newVisited);
|
|
24
61
|
cloned[key] = flattenedChild;
|
|
25
|
-
|
|
26
|
-
for (
|
|
62
|
+
var hasKeyNotCombined = false;
|
|
63
|
+
for (var childKey in flattenedChild) {
|
|
27
64
|
if (!/^\$/.test(childKey)) {
|
|
28
|
-
cloned[
|
|
65
|
+
cloned["".concat(key, ".").concat(childKey)] = flattenedChild[childKey];
|
|
29
66
|
delete cloned[key][childKey];
|
|
30
67
|
}
|
|
31
68
|
else {
|
|
@@ -44,29 +81,29 @@ function flattenQueryObject(query) {
|
|
|
44
81
|
}
|
|
45
82
|
exports.flattenQueryObject = flattenQueryObject;
|
|
46
83
|
function flattenObject(object) {
|
|
47
|
-
return flatten(object, (_)
|
|
84
|
+
return flatten(object, function (_) { return false; }, [], [object]);
|
|
48
85
|
}
|
|
49
86
|
exports.flattenObject = flattenObject;
|
|
50
87
|
function mergeConditionAfterEncode(query, condition, key) {
|
|
51
88
|
if (!condition[key]) {
|
|
52
89
|
delete query[key];
|
|
53
90
|
}
|
|
54
|
-
for (
|
|
91
|
+
for (var conditionKey in condition) {
|
|
55
92
|
if (query[conditionKey]) {
|
|
56
|
-
if (type_1.isArray(query[conditionKey])) {
|
|
93
|
+
if ((0, type_1.isArray)(query[conditionKey])) {
|
|
57
94
|
query[conditionKey].push(condition[conditionKey]);
|
|
58
95
|
}
|
|
59
|
-
else if (type_1.isObject(query[conditionKey])) {
|
|
60
|
-
if (type_1.isObject(condition[conditionKey])) {
|
|
96
|
+
else if ((0, type_1.isObject)(query[conditionKey])) {
|
|
97
|
+
if ((0, type_1.isObject)(condition[conditionKey])) {
|
|
61
98
|
Object.assign(query[conditionKey], condition[conditionKey]);
|
|
62
99
|
}
|
|
63
100
|
else {
|
|
64
|
-
console.warn(
|
|
101
|
+
console.warn("unmergable condition, query is object but condition is ".concat((0, type_1.getType)(condition), ", can only overwrite"), condition, key);
|
|
65
102
|
query[conditionKey] = condition[conditionKey];
|
|
66
103
|
}
|
|
67
104
|
}
|
|
68
105
|
else {
|
|
69
|
-
console.warn(
|
|
106
|
+
console.warn("to-merge query is of type ".concat((0, type_1.getType)(query), ", can only overwrite"), query, condition, key);
|
|
70
107
|
query[conditionKey] = condition[conditionKey];
|
|
71
108
|
}
|
|
72
109
|
}
|
|
@@ -77,14 +114,14 @@ function mergeConditionAfterEncode(query, condition, key) {
|
|
|
77
114
|
}
|
|
78
115
|
exports.mergeConditionAfterEncode = mergeConditionAfterEncode;
|
|
79
116
|
function isConversionRequired(val) {
|
|
80
|
-
return type_1.isInternalObject(val) || type_1.isDate(val) || type_1.isRegExp(val);
|
|
117
|
+
return (0, type_1.isInternalObject)(val) || (0, type_1.isDate)(val) || (0, type_1.isRegExp)(val);
|
|
81
118
|
}
|
|
82
119
|
exports.isConversionRequired = isConversionRequired;
|
|
83
120
|
function encodeInternalDataType(val) {
|
|
84
|
-
return datatype_1.serialize(val);
|
|
121
|
+
return (0, datatype_1.serialize)(val);
|
|
85
122
|
}
|
|
86
123
|
exports.encodeInternalDataType = encodeInternalDataType;
|
|
87
124
|
function decodeInternalDataType(object) {
|
|
88
|
-
return datatype_1.deserialize(object);
|
|
125
|
+
return (0, datatype_1.deserialize)(object);
|
|
89
126
|
}
|
|
90
127
|
exports.decodeInternalDataType = decodeInternalDataType;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { LogicCommand } from '../commands/logic';
|
|
2
|
-
export
|
|
3
|
-
export
|
|
2
|
+
export type IQueryCondition = Record<string, any> | LogicCommand;
|
|
3
|
+
export type AnyObject = {
|
|
4
4
|
[x: string]: any;
|
|
5
5
|
};
|
|
6
6
|
export declare function serialize(val: any): IQueryCondition;
|
|
@@ -1,15 +1,52 @@
|
|
|
1
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
|
+
};
|
|
2
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
39
|
+
exports.deserialize = exports.serialize = void 0;
|
|
40
|
+
var symbol_1 = require("../helper/symbol");
|
|
41
|
+
var type_1 = require("../utils/type");
|
|
42
|
+
var index_1 = require("../geo/index");
|
|
43
|
+
var index_2 = require("../serverDate/index");
|
|
7
44
|
function serialize(val) {
|
|
8
45
|
return serializeHelper(val, [val]);
|
|
9
46
|
}
|
|
10
47
|
exports.serialize = serialize;
|
|
11
48
|
function serializeHelper(val, visited) {
|
|
12
|
-
if (type_1.isInternalObject(val)) {
|
|
49
|
+
if ((0, type_1.isInternalObject)(val)) {
|
|
13
50
|
switch (val._internalType) {
|
|
14
51
|
case symbol_1.SYMBOL_GEO_POINT: {
|
|
15
52
|
return val.toJSON();
|
|
@@ -28,10 +65,10 @@ function serializeHelper(val, visited) {
|
|
|
28
65
|
}
|
|
29
66
|
}
|
|
30
67
|
}
|
|
31
|
-
else if (type_1.isDate(val)) {
|
|
68
|
+
else if ((0, type_1.isDate)(val)) {
|
|
32
69
|
return val;
|
|
33
70
|
}
|
|
34
|
-
else if (type_1.isRegExp(val)) {
|
|
71
|
+
else if ((0, type_1.isRegExp)(val)) {
|
|
35
72
|
return {
|
|
36
73
|
$regularExpression: {
|
|
37
74
|
pattern: val.source,
|
|
@@ -39,23 +76,23 @@ function serializeHelper(val, visited) {
|
|
|
39
76
|
}
|
|
40
77
|
};
|
|
41
78
|
}
|
|
42
|
-
else if (type_1.isArray(val)) {
|
|
43
|
-
return val.map(item
|
|
79
|
+
else if ((0, type_1.isArray)(val)) {
|
|
80
|
+
return val.map(function (item) {
|
|
44
81
|
if (visited.indexOf(item) > -1) {
|
|
45
82
|
throw new Error('Cannot convert circular structure to JSON');
|
|
46
83
|
}
|
|
47
|
-
return serializeHelper(item, [
|
|
84
|
+
return serializeHelper(item, __spreadArray(__spreadArray([], __read(visited), false), [item], false));
|
|
48
85
|
});
|
|
49
86
|
}
|
|
50
|
-
else if (type_1.isObject(val)) {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
for (
|
|
87
|
+
else if ((0, type_1.isObject)(val)) {
|
|
88
|
+
var rawRet = __assign({}, val);
|
|
89
|
+
var finalRet = {};
|
|
90
|
+
for (var key in rawRet) {
|
|
54
91
|
if (visited.indexOf(rawRet[key]) > -1) {
|
|
55
92
|
throw new Error('Cannot convert circular structure to JSON');
|
|
56
93
|
}
|
|
57
94
|
if (rawRet[key] !== undefined) {
|
|
58
|
-
finalRet[key] = serializeHelper(rawRet[key], [
|
|
95
|
+
finalRet[key] = serializeHelper(rawRet[key], __spreadArray(__spreadArray([], __read(visited), false), [rawRet[key]], false));
|
|
59
96
|
}
|
|
60
97
|
}
|
|
61
98
|
return finalRet;
|
|
@@ -65,11 +102,11 @@ function serializeHelper(val, visited) {
|
|
|
65
102
|
}
|
|
66
103
|
}
|
|
67
104
|
function deserialize(object) {
|
|
68
|
-
|
|
69
|
-
for (
|
|
105
|
+
var ret = __assign({}, object);
|
|
106
|
+
for (var key in ret) {
|
|
70
107
|
switch (key) {
|
|
71
108
|
case '$date': {
|
|
72
|
-
switch (type_1.getType(ret[key])) {
|
|
109
|
+
switch ((0, type_1.getType)(ret[key])) {
|
|
73
110
|
case 'number': {
|
|
74
111
|
return new Date(ret[key]);
|
|
75
112
|
}
|
|
@@ -82,9 +119,9 @@ function deserialize(object) {
|
|
|
82
119
|
case 'type': {
|
|
83
120
|
switch (ret.type) {
|
|
84
121
|
case 'Point': {
|
|
85
|
-
if (type_1.isArray(ret.coordinates) &&
|
|
86
|
-
type_1.isNumber(ret.coordinates[0]) &&
|
|
87
|
-
type_1.isNumber(ret.coordinates[1])) {
|
|
122
|
+
if ((0, type_1.isArray)(ret.coordinates) &&
|
|
123
|
+
(0, type_1.isNumber)(ret.coordinates[0]) &&
|
|
124
|
+
(0, type_1.isNumber)(ret.coordinates[1])) {
|
|
88
125
|
return new index_1.Point(ret.coordinates[0], ret.coordinates[1]);
|
|
89
126
|
}
|
|
90
127
|
break;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { QueryCommand } from '../commands/query';
|
|
2
2
|
import { LogicCommand } from '../commands/logic';
|
|
3
|
-
export
|
|
3
|
+
export type IQueryCondition = Record<string, any> | LogicCommand;
|
|
4
4
|
export declare class QuerySerializer {
|
|
5
5
|
constructor();
|
|
6
6
|
static encode(query: IQueryCondition | QueryCommand | LogicCommand): IQueryCondition;
|