@cloudbase/database 0.9.19 → 0.9.21
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/.trunk/configs/.markdownlint.yaml +10 -0
- package/.trunk/trunk.yaml +26 -0
- package/dist/commonjs/aggregate.d.ts +29 -29
- package/dist/commonjs/aggregate.js +156 -156
- package/dist/commonjs/collection.d.ts +9 -9
- package/dist/commonjs/collection.js +46 -46
- package/dist/commonjs/command.d.ts +175 -175
- package/dist/commonjs/command.js +298 -298
- package/dist/commonjs/commands/logic.d.ts +24 -24
- package/dist/commonjs/commands/logic.js +88 -88
- package/dist/commonjs/commands/query.d.ts +68 -68
- package/dist/commonjs/commands/query.js +157 -157
- package/dist/commonjs/commands/update.d.ts +29 -29
- package/dist/commonjs/commands/update.js +50 -50
- package/dist/commonjs/config/app.config.d.ts +6 -6
- package/dist/commonjs/config/app.config.js +7 -7
- package/dist/commonjs/config/error.config.d.ts +3 -3
- package/dist/commonjs/config/error.config.js +15 -15
- package/dist/commonjs/const/code.d.ts +30 -30
- package/dist/commonjs/const/code.js +32 -32
- package/dist/commonjs/constant.d.ts +51 -51
- package/dist/commonjs/constant.js +74 -74
- package/dist/commonjs/document.d.ts +11 -11
- package/dist/commonjs/document.js +249 -252
- package/dist/commonjs/geo/index.d.ts +6 -6
- package/dist/commonjs/geo/index.js +11 -11
- package/dist/commonjs/geo/interface.d.ts +24 -24
- package/dist/commonjs/geo/interface.js +2 -2
- package/dist/commonjs/geo/lineString.d.ts +19 -19
- package/dist/commonjs/geo/lineString.js +85 -85
- package/dist/commonjs/geo/multiLineString.d.ts +18 -18
- package/dist/commonjs/geo/multiLineString.js +94 -94
- package/dist/commonjs/geo/multiPoint.d.ts +18 -18
- package/dist/commonjs/geo/multiPoint.js +78 -78
- package/dist/commonjs/geo/multiPolygon.d.ts +18 -18
- package/dist/commonjs/geo/multiPolygon.js +121 -121
- package/dist/commonjs/geo/point.d.ts +19 -19
- package/dist/commonjs/geo/point.js +49 -49
- package/dist/commonjs/geo/polygon.d.ts +19 -19
- package/dist/commonjs/geo/polygon.js +108 -108
- package/dist/commonjs/helper/symbol.d.ts +14 -14
- package/dist/commonjs/helper/symbol.js +19 -19
- package/dist/commonjs/index.d.ts +33 -33
- package/dist/commonjs/index.js +46 -46
- package/dist/commonjs/lib/util.d.ts +1 -1
- package/dist/commonjs/lib/util.js +25 -25
- package/dist/commonjs/operator-map.d.ts +4 -4
- package/dist/commonjs/operator-map.js +23 -23
- package/dist/commonjs/query.d.ts +22 -22
- package/dist/commonjs/query.js +251 -251
- package/dist/commonjs/regexp/index.d.ts +14 -14
- package/dist/commonjs/regexp/index.js +32 -32
- package/dist/commonjs/serializer/common.d.ts +11 -11
- package/dist/commonjs/serializer/common.js +121 -121
- package/dist/commonjs/serializer/datatype.d.ts +7 -7
- package/dist/commonjs/serializer/datatype.js +126 -126
- package/dist/commonjs/serializer/query.d.ts +7 -7
- package/dist/commonjs/serializer/query.js +231 -231
- package/dist/commonjs/serializer/update.d.ts +15 -15
- package/dist/commonjs/serializer/update.js +141 -141
- package/dist/commonjs/serverDate/index.d.ts +13 -13
- package/dist/commonjs/serverDate/index.js +29 -29
- package/dist/commonjs/transaction/collection.d.ts +7 -7
- package/dist/commonjs/transaction/collection.js +46 -46
- package/dist/commonjs/transaction/document.d.ts +27 -27
- package/dist/commonjs/transaction/document.js +205 -205
- package/dist/commonjs/transaction/index.d.ts +30 -30
- package/dist/commonjs/transaction/index.js +214 -214
- package/dist/commonjs/transaction/query.d.ts +5 -5
- package/dist/commonjs/transaction/query.js +10 -10
- package/dist/commonjs/typings/index.d.ts +40 -40
- package/dist/commonjs/typings/index.js +2 -2
- package/dist/commonjs/typings/realtime.d.ts +219 -219
- package/dist/commonjs/typings/realtime.js +2 -2
- package/dist/commonjs/util.d.ts +9 -9
- package/dist/commonjs/util.js +144 -144
- package/dist/commonjs/utils/error.d.ts +37 -37
- package/dist/commonjs/utils/error.js +85 -85
- package/dist/commonjs/utils/symbol.d.ts +8 -8
- package/dist/commonjs/utils/symbol.js +57 -57
- package/dist/commonjs/utils/type.d.ts +13 -13
- package/dist/commonjs/utils/type.js +22 -22
- package/dist/commonjs/utils/utils.d.ts +4 -4
- package/dist/commonjs/utils/utils.js +36 -36
- package/dist/commonjs/validate.d.ts +1 -1
- package/dist/commonjs/validate.js +59 -59
- package/dist/esm/aggregate.d.ts +29 -29
- package/dist/esm/aggregate.js +154 -154
- package/dist/esm/collection.d.ts +9 -9
- package/dist/esm/collection.js +44 -44
- package/dist/esm/command.d.ts +175 -175
- package/dist/esm/command.js +296 -296
- package/dist/esm/commands/logic.d.ts +24 -24
- package/dist/esm/commands/logic.js +84 -84
- package/dist/esm/commands/query.d.ts +68 -68
- package/dist/esm/commands/query.js +152 -152
- package/dist/esm/commands/update.d.ts +29 -29
- package/dist/esm/commands/update.js +46 -46
- package/dist/esm/config/app.config.d.ts +6 -6
- package/dist/esm/config/app.config.js +5 -5
- package/dist/esm/config/error.config.d.ts +3 -3
- package/dist/esm/config/error.config.js +13 -13
- package/dist/esm/const/code.d.ts +30 -30
- package/dist/esm/const/code.js +30 -30
- package/dist/esm/constant.d.ts +51 -51
- package/dist/esm/constant.js +65 -65
- package/dist/esm/document.d.ts +11 -11
- package/dist/esm/document.js +247 -250
- package/dist/esm/geo/index.d.ts +6 -6
- package/dist/esm/geo/index.js +6 -6
- package/dist/esm/geo/interface.d.ts +24 -24
- package/dist/esm/geo/lineString.d.ts +19 -19
- package/dist/esm/geo/lineString.js +83 -83
- package/dist/esm/geo/multiLineString.d.ts +18 -18
- package/dist/esm/geo/multiLineString.js +92 -92
- package/dist/esm/geo/multiPoint.d.ts +18 -18
- package/dist/esm/geo/multiPoint.js +76 -76
- package/dist/esm/geo/multiPolygon.d.ts +18 -18
- package/dist/esm/geo/multiPolygon.js +119 -119
- package/dist/esm/geo/point.d.ts +19 -19
- package/dist/esm/geo/point.js +47 -47
- package/dist/esm/geo/polygon.d.ts +19 -19
- package/dist/esm/geo/polygon.js +106 -106
- package/dist/esm/helper/symbol.d.ts +14 -14
- package/dist/esm/helper/symbol.js +14 -14
- package/dist/esm/index.d.ts +33 -33
- package/dist/esm/index.js +41 -41
- package/dist/esm/lib/util.d.ts +1 -1
- package/dist/esm/lib/util.js +23 -23
- package/dist/esm/operator-map.d.ts +4 -4
- package/dist/esm/operator-map.js +20 -20
- package/dist/esm/query.d.ts +22 -22
- package/dist/esm/query.js +249 -249
- package/dist/esm/regexp/index.d.ts +14 -14
- package/dist/esm/regexp/index.js +29 -29
- package/dist/esm/serializer/common.d.ts +11 -11
- package/dist/esm/serializer/common.js +113 -113
- package/dist/esm/serializer/datatype.d.ts +7 -7
- package/dist/esm/serializer/datatype.js +122 -122
- package/dist/esm/serializer/query.d.ts +7 -7
- package/dist/esm/serializer/query.js +229 -229
- package/dist/esm/serializer/update.d.ts +15 -15
- package/dist/esm/serializer/update.js +139 -139
- package/dist/esm/serverDate/index.d.ts +13 -13
- package/dist/esm/serverDate/index.js +26 -26
- package/dist/esm/transaction/collection.d.ts +7 -7
- package/dist/esm/transaction/collection.js +44 -44
- package/dist/esm/transaction/document.d.ts +27 -27
- package/dist/esm/transaction/document.js +203 -203
- package/dist/esm/transaction/index.d.ts +30 -30
- package/dist/esm/transaction/index.js +210 -210
- package/dist/esm/transaction/query.d.ts +5 -5
- package/dist/esm/transaction/query.js +8 -8
- package/dist/esm/typings/index.d.ts +40 -40
- package/dist/esm/typings/realtime.d.ts +219 -219
- package/dist/esm/util.d.ts +9 -9
- package/dist/esm/util.js +142 -142
- package/dist/esm/utils/error.d.ts +37 -37
- package/dist/esm/utils/error.js +82 -82
- package/dist/esm/utils/symbol.d.ts +8 -8
- package/dist/esm/utils/symbol.js +55 -55
- package/dist/esm/utils/type.d.ts +13 -13
- package/dist/esm/utils/type.js +20 -20
- package/dist/esm/utils/utils.d.ts +4 -4
- package/dist/esm/utils/utils.js +33 -33
- package/dist/esm/validate.d.ts +1 -1
- package/dist/esm/validate.js +57 -57
- package/package.json +1 -1
- package/src/document.ts +1 -4
- package/src/query.ts +3 -3
- package/src/transaction/document.ts +2 -2
- package/dist/commonjs/ObjectId/index.d.ts +0 -11
- package/dist/commonjs/ObjectId/index.js +0 -21
- 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/ObjectId/index.d.ts +0 -11
- package/dist/esm/ObjectId/index.js +0 -17
- 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
|
@@ -1,113 +1,113 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
13
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
14
|
-
if (!m) return o;
|
|
15
|
-
var i = m.call(o), r, ar = [], e;
|
|
16
|
-
try {
|
|
17
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
18
|
-
}
|
|
19
|
-
catch (error) { e = { error: error }; }
|
|
20
|
-
finally {
|
|
21
|
-
try {
|
|
22
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
23
|
-
}
|
|
24
|
-
finally { if (e) throw e.error; }
|
|
25
|
-
}
|
|
26
|
-
return ar;
|
|
27
|
-
};
|
|
28
|
-
var __spread = (this && this.__spread) || function () {
|
|
29
|
-
for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
|
|
30
|
-
return ar;
|
|
31
|
-
};
|
|
32
|
-
import { getType, isObject, isArray, isDate, isRegExp, isInternalObject } from '../utils/type';
|
|
33
|
-
import { serialize as serializeInternalDataType, deserialize as deserializeInternalDataType } from './datatype';
|
|
34
|
-
function flatten(query, shouldPreserverObject, parents, visited) {
|
|
35
|
-
var cloned = __assign({}, query);
|
|
36
|
-
for (var key in query) {
|
|
37
|
-
if (/^\$/.test(key))
|
|
38
|
-
continue;
|
|
39
|
-
var value = query[key];
|
|
40
|
-
if (!value)
|
|
41
|
-
continue;
|
|
42
|
-
if (isObject(value) && !shouldPreserverObject(value)) {
|
|
43
|
-
if (visited.indexOf(value) > -1) {
|
|
44
|
-
throw new Error('Cannot convert circular structure to JSON');
|
|
45
|
-
}
|
|
46
|
-
var newParents = __spread(parents, [
|
|
47
|
-
key,
|
|
48
|
-
]);
|
|
49
|
-
var newVisited = __spread(visited, [
|
|
50
|
-
value,
|
|
51
|
-
]);
|
|
52
|
-
var flattenedChild = flatten(value, shouldPreserverObject, newParents, newVisited);
|
|
53
|
-
cloned[key] = flattenedChild;
|
|
54
|
-
var hasKeyNotCombined = false;
|
|
55
|
-
for (var childKey in flattenedChild) {
|
|
56
|
-
if (!/^\$/.test(childKey)) {
|
|
57
|
-
cloned[key + "." + childKey] = flattenedChild[childKey];
|
|
58
|
-
delete cloned[key][childKey];
|
|
59
|
-
}
|
|
60
|
-
else {
|
|
61
|
-
hasKeyNotCombined = true;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
if (!hasKeyNotCombined) {
|
|
65
|
-
delete cloned[key];
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
return cloned;
|
|
70
|
-
}
|
|
71
|
-
export function flattenQueryObject(query) {
|
|
72
|
-
return flatten(query, isConversionRequired, [], [query]);
|
|
73
|
-
}
|
|
74
|
-
export function flattenObject(object) {
|
|
75
|
-
return flatten(object, function (_) { return false; }, [], [object]);
|
|
76
|
-
}
|
|
77
|
-
export function mergeConditionAfterEncode(query, condition, key) {
|
|
78
|
-
if (!condition[key]) {
|
|
79
|
-
delete query[key];
|
|
80
|
-
}
|
|
81
|
-
for (var conditionKey in condition) {
|
|
82
|
-
if (query[conditionKey]) {
|
|
83
|
-
if (isArray(query[conditionKey])) {
|
|
84
|
-
query[conditionKey].push(condition[conditionKey]);
|
|
85
|
-
}
|
|
86
|
-
else if (isObject(query[conditionKey])) {
|
|
87
|
-
if (isObject(condition[conditionKey])) {
|
|
88
|
-
Object.assign(query[conditionKey], condition[conditionKey]);
|
|
89
|
-
}
|
|
90
|
-
else {
|
|
91
|
-
console.warn("unmergable condition, query is object but condition is " + getType(condition) + ", can only overwrite", condition, key);
|
|
92
|
-
query[conditionKey] = condition[conditionKey];
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
else {
|
|
96
|
-
console.warn("to-merge query is of type " + getType(query) + ", can only overwrite", query, condition, key);
|
|
97
|
-
query[conditionKey] = condition[conditionKey];
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
else {
|
|
101
|
-
query[conditionKey] = condition[conditionKey];
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
export function isConversionRequired(val) {
|
|
106
|
-
return isInternalObject(val) || isDate(val) || isRegExp(val);
|
|
107
|
-
}
|
|
108
|
-
export function encodeInternalDataType(val) {
|
|
109
|
-
return serializeInternalDataType(val);
|
|
110
|
-
}
|
|
111
|
-
export function decodeInternalDataType(object) {
|
|
112
|
-
return deserializeInternalDataType(object);
|
|
113
|
-
}
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
13
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
14
|
+
if (!m) return o;
|
|
15
|
+
var i = m.call(o), r, ar = [], e;
|
|
16
|
+
try {
|
|
17
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
18
|
+
}
|
|
19
|
+
catch (error) { e = { error: error }; }
|
|
20
|
+
finally {
|
|
21
|
+
try {
|
|
22
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
23
|
+
}
|
|
24
|
+
finally { if (e) throw e.error; }
|
|
25
|
+
}
|
|
26
|
+
return ar;
|
|
27
|
+
};
|
|
28
|
+
var __spread = (this && this.__spread) || function () {
|
|
29
|
+
for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
|
|
30
|
+
return ar;
|
|
31
|
+
};
|
|
32
|
+
import { getType, isObject, isArray, isDate, isRegExp, isInternalObject } from '../utils/type';
|
|
33
|
+
import { serialize as serializeInternalDataType, deserialize as deserializeInternalDataType } from './datatype';
|
|
34
|
+
function flatten(query, shouldPreserverObject, parents, visited) {
|
|
35
|
+
var cloned = __assign({}, query);
|
|
36
|
+
for (var key in query) {
|
|
37
|
+
if (/^\$/.test(key))
|
|
38
|
+
continue;
|
|
39
|
+
var value = query[key];
|
|
40
|
+
if (!value)
|
|
41
|
+
continue;
|
|
42
|
+
if (isObject(value) && !shouldPreserverObject(value)) {
|
|
43
|
+
if (visited.indexOf(value) > -1) {
|
|
44
|
+
throw new Error('Cannot convert circular structure to JSON');
|
|
45
|
+
}
|
|
46
|
+
var newParents = __spread(parents, [
|
|
47
|
+
key,
|
|
48
|
+
]);
|
|
49
|
+
var newVisited = __spread(visited, [
|
|
50
|
+
value,
|
|
51
|
+
]);
|
|
52
|
+
var flattenedChild = flatten(value, shouldPreserverObject, newParents, newVisited);
|
|
53
|
+
cloned[key] = flattenedChild;
|
|
54
|
+
var hasKeyNotCombined = false;
|
|
55
|
+
for (var childKey in flattenedChild) {
|
|
56
|
+
if (!/^\$/.test(childKey)) {
|
|
57
|
+
cloned[key + "." + childKey] = flattenedChild[childKey];
|
|
58
|
+
delete cloned[key][childKey];
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
hasKeyNotCombined = true;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
if (!hasKeyNotCombined) {
|
|
65
|
+
delete cloned[key];
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return cloned;
|
|
70
|
+
}
|
|
71
|
+
export function flattenQueryObject(query) {
|
|
72
|
+
return flatten(query, isConversionRequired, [], [query]);
|
|
73
|
+
}
|
|
74
|
+
export function flattenObject(object) {
|
|
75
|
+
return flatten(object, function (_) { return false; }, [], [object]);
|
|
76
|
+
}
|
|
77
|
+
export function mergeConditionAfterEncode(query, condition, key) {
|
|
78
|
+
if (!condition[key]) {
|
|
79
|
+
delete query[key];
|
|
80
|
+
}
|
|
81
|
+
for (var conditionKey in condition) {
|
|
82
|
+
if (query[conditionKey]) {
|
|
83
|
+
if (isArray(query[conditionKey])) {
|
|
84
|
+
query[conditionKey].push(condition[conditionKey]);
|
|
85
|
+
}
|
|
86
|
+
else if (isObject(query[conditionKey])) {
|
|
87
|
+
if (isObject(condition[conditionKey])) {
|
|
88
|
+
Object.assign(query[conditionKey], condition[conditionKey]);
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
console.warn("unmergable condition, query is object but condition is " + getType(condition) + ", can only overwrite", condition, key);
|
|
92
|
+
query[conditionKey] = condition[conditionKey];
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
console.warn("to-merge query is of type " + getType(query) + ", can only overwrite", query, condition, key);
|
|
97
|
+
query[conditionKey] = condition[conditionKey];
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
query[conditionKey] = condition[conditionKey];
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
export function isConversionRequired(val) {
|
|
106
|
+
return isInternalObject(val) || isDate(val) || isRegExp(val);
|
|
107
|
+
}
|
|
108
|
+
export function encodeInternalDataType(val) {
|
|
109
|
+
return serializeInternalDataType(val);
|
|
110
|
+
}
|
|
111
|
+
export function decodeInternalDataType(object) {
|
|
112
|
+
return deserializeInternalDataType(object);
|
|
113
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { LogicCommand } from '../commands/logic';
|
|
2
|
-
export declare type IQueryCondition = Record<string, any> | LogicCommand;
|
|
3
|
-
export declare type AnyObject = {
|
|
4
|
-
[x: string]: any;
|
|
5
|
-
};
|
|
6
|
-
export declare function serialize(val: any): IQueryCondition;
|
|
7
|
-
export declare function deserialize(object: AnyObject): any;
|
|
1
|
+
import { LogicCommand } from '../commands/logic';
|
|
2
|
+
export declare type IQueryCondition = Record<string, any> | LogicCommand;
|
|
3
|
+
export declare type AnyObject = {
|
|
4
|
+
[x: string]: any;
|
|
5
|
+
};
|
|
6
|
+
export declare function serialize(val: any): IQueryCondition;
|
|
7
|
+
export declare function deserialize(object: AnyObject): any;
|
|
@@ -1,122 +1,122 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
13
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
14
|
-
if (!m) return o;
|
|
15
|
-
var i = m.call(o), r, ar = [], e;
|
|
16
|
-
try {
|
|
17
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
18
|
-
}
|
|
19
|
-
catch (error) { e = { error: error }; }
|
|
20
|
-
finally {
|
|
21
|
-
try {
|
|
22
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
23
|
-
}
|
|
24
|
-
finally { if (e) throw e.error; }
|
|
25
|
-
}
|
|
26
|
-
return ar;
|
|
27
|
-
};
|
|
28
|
-
var __spread = (this && this.__spread) || function () {
|
|
29
|
-
for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
|
|
30
|
-
return ar;
|
|
31
|
-
};
|
|
32
|
-
import { SYMBOL_GEO_POINT, SYMBOL_SERVER_DATE, SYMBOL_REGEXP } from '../helper/symbol';
|
|
33
|
-
import { getType, isObject, isArray, isDate, isNumber, isInternalObject, isRegExp } from '../utils/type';
|
|
34
|
-
import { Point } from '../geo/index';
|
|
35
|
-
import { ServerDate } from '../serverDate/index';
|
|
36
|
-
export function serialize(val) {
|
|
37
|
-
return serializeHelper(val, [val]);
|
|
38
|
-
}
|
|
39
|
-
function serializeHelper(val, visited) {
|
|
40
|
-
if (isInternalObject(val)) {
|
|
41
|
-
switch (val._internalType) {
|
|
42
|
-
case SYMBOL_GEO_POINT: {
|
|
43
|
-
return val.toJSON();
|
|
44
|
-
}
|
|
45
|
-
case SYMBOL_SERVER_DATE: {
|
|
46
|
-
return val.parse();
|
|
47
|
-
}
|
|
48
|
-
case SYMBOL_REGEXP: {
|
|
49
|
-
return val.parse();
|
|
50
|
-
}
|
|
51
|
-
default: {
|
|
52
|
-
return val.toJSON ? val.toJSON() : val;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
else if (isDate(val)) {
|
|
57
|
-
return {
|
|
58
|
-
$date: +val,
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
else if (isRegExp(val)) {
|
|
62
|
-
return {
|
|
63
|
-
$regex: val.source,
|
|
64
|
-
$options: val.flags,
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
else if (isArray(val)) {
|
|
68
|
-
return val.map(function (item) {
|
|
69
|
-
if (visited.indexOf(item) > -1) {
|
|
70
|
-
throw new Error('Cannot convert circular structure to JSON');
|
|
71
|
-
}
|
|
72
|
-
return serializeHelper(item, __spread(visited, [
|
|
73
|
-
item,
|
|
74
|
-
]));
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
else if (isObject(val)) {
|
|
78
|
-
var ret = __assign({}, val);
|
|
79
|
-
for (var key in ret) {
|
|
80
|
-
if (visited.indexOf(ret[key]) > -1) {
|
|
81
|
-
throw new Error('Cannot convert circular structure to JSON');
|
|
82
|
-
}
|
|
83
|
-
ret[key] = serializeHelper(ret[key], __spread(visited, [
|
|
84
|
-
ret[key],
|
|
85
|
-
]));
|
|
86
|
-
}
|
|
87
|
-
return ret;
|
|
88
|
-
}
|
|
89
|
-
else {
|
|
90
|
-
return val;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
export function deserialize(object) {
|
|
94
|
-
var ret = __assign({}, object);
|
|
95
|
-
for (var key in ret) {
|
|
96
|
-
switch (key) {
|
|
97
|
-
case '$date': {
|
|
98
|
-
switch (getType(ret[key])) {
|
|
99
|
-
case 'number': {
|
|
100
|
-
return new Date(ret[key]);
|
|
101
|
-
}
|
|
102
|
-
case 'object': {
|
|
103
|
-
return new ServerDate(ret[key]);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
break;
|
|
107
|
-
}
|
|
108
|
-
case 'type': {
|
|
109
|
-
switch (ret.type) {
|
|
110
|
-
case 'Point': {
|
|
111
|
-
if (isArray(ret.coordinates) && isNumber(ret.coordinates[0]) && isNumber(ret.coordinates[1])) {
|
|
112
|
-
return new Point(ret.coordinates[0], ret.coordinates[1]);
|
|
113
|
-
}
|
|
114
|
-
break;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
break;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
return object;
|
|
122
|
-
}
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
13
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
14
|
+
if (!m) return o;
|
|
15
|
+
var i = m.call(o), r, ar = [], e;
|
|
16
|
+
try {
|
|
17
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
18
|
+
}
|
|
19
|
+
catch (error) { e = { error: error }; }
|
|
20
|
+
finally {
|
|
21
|
+
try {
|
|
22
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
23
|
+
}
|
|
24
|
+
finally { if (e) throw e.error; }
|
|
25
|
+
}
|
|
26
|
+
return ar;
|
|
27
|
+
};
|
|
28
|
+
var __spread = (this && this.__spread) || function () {
|
|
29
|
+
for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
|
|
30
|
+
return ar;
|
|
31
|
+
};
|
|
32
|
+
import { SYMBOL_GEO_POINT, SYMBOL_SERVER_DATE, SYMBOL_REGEXP } from '../helper/symbol';
|
|
33
|
+
import { getType, isObject, isArray, isDate, isNumber, isInternalObject, isRegExp } from '../utils/type';
|
|
34
|
+
import { Point } from '../geo/index';
|
|
35
|
+
import { ServerDate } from '../serverDate/index';
|
|
36
|
+
export function serialize(val) {
|
|
37
|
+
return serializeHelper(val, [val]);
|
|
38
|
+
}
|
|
39
|
+
function serializeHelper(val, visited) {
|
|
40
|
+
if (isInternalObject(val)) {
|
|
41
|
+
switch (val._internalType) {
|
|
42
|
+
case SYMBOL_GEO_POINT: {
|
|
43
|
+
return val.toJSON();
|
|
44
|
+
}
|
|
45
|
+
case SYMBOL_SERVER_DATE: {
|
|
46
|
+
return val.parse();
|
|
47
|
+
}
|
|
48
|
+
case SYMBOL_REGEXP: {
|
|
49
|
+
return val.parse();
|
|
50
|
+
}
|
|
51
|
+
default: {
|
|
52
|
+
return val.toJSON ? val.toJSON() : val;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
else if (isDate(val)) {
|
|
57
|
+
return {
|
|
58
|
+
$date: +val,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
else if (isRegExp(val)) {
|
|
62
|
+
return {
|
|
63
|
+
$regex: val.source,
|
|
64
|
+
$options: val.flags,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
else if (isArray(val)) {
|
|
68
|
+
return val.map(function (item) {
|
|
69
|
+
if (visited.indexOf(item) > -1) {
|
|
70
|
+
throw new Error('Cannot convert circular structure to JSON');
|
|
71
|
+
}
|
|
72
|
+
return serializeHelper(item, __spread(visited, [
|
|
73
|
+
item,
|
|
74
|
+
]));
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
else if (isObject(val)) {
|
|
78
|
+
var ret = __assign({}, val);
|
|
79
|
+
for (var key in ret) {
|
|
80
|
+
if (visited.indexOf(ret[key]) > -1) {
|
|
81
|
+
throw new Error('Cannot convert circular structure to JSON');
|
|
82
|
+
}
|
|
83
|
+
ret[key] = serializeHelper(ret[key], __spread(visited, [
|
|
84
|
+
ret[key],
|
|
85
|
+
]));
|
|
86
|
+
}
|
|
87
|
+
return ret;
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
return val;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
export function deserialize(object) {
|
|
94
|
+
var ret = __assign({}, object);
|
|
95
|
+
for (var key in ret) {
|
|
96
|
+
switch (key) {
|
|
97
|
+
case '$date': {
|
|
98
|
+
switch (getType(ret[key])) {
|
|
99
|
+
case 'number': {
|
|
100
|
+
return new Date(ret[key]);
|
|
101
|
+
}
|
|
102
|
+
case 'object': {
|
|
103
|
+
return new ServerDate(ret[key]);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
break;
|
|
107
|
+
}
|
|
108
|
+
case 'type': {
|
|
109
|
+
switch (ret.type) {
|
|
110
|
+
case 'Point': {
|
|
111
|
+
if (isArray(ret.coordinates) && isNumber(ret.coordinates[0]) && isNumber(ret.coordinates[1])) {
|
|
112
|
+
return new Point(ret.coordinates[0], ret.coordinates[1]);
|
|
113
|
+
}
|
|
114
|
+
break;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
break;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return object;
|
|
122
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { QueryCommand } from '../commands/query';
|
|
2
|
-
import { LogicCommand } from '../commands/logic';
|
|
3
|
-
export declare type IQueryCondition = Record<string, any> | LogicCommand;
|
|
4
|
-
export declare class QuerySerializer {
|
|
5
|
-
constructor();
|
|
6
|
-
static encode(query: IQueryCondition | QueryCommand | LogicCommand): IQueryCondition;
|
|
7
|
-
}
|
|
1
|
+
import { QueryCommand } from '../commands/query';
|
|
2
|
+
import { LogicCommand } from '../commands/logic';
|
|
3
|
+
export declare type IQueryCondition = Record<string, any> | LogicCommand;
|
|
4
|
+
export declare class QuerySerializer {
|
|
5
|
+
constructor();
|
|
6
|
+
static encode(query: IQueryCondition | QueryCommand | LogicCommand): IQueryCondition;
|
|
7
|
+
}
|