@cloudbase/database 1.4.3 → 1.5.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/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 +9 -5
- package/dist/commonjs/query.js +330 -205
- 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 +5 -1
- package/dist/commonjs/utils/utils.js +153 -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 +9 -5
- package/dist/esm/query.js +321 -196
- 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 +5 -1
- package/dist/esm/utils/utils.js +137 -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 +48 -38
- 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 +105 -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/tests/watch-query.test.ts +144 -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,53 +1,92 @@
|
|
|
1
|
+
var __values = (this && this.__values) || function(o) {
|
|
2
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
3
|
+
if (m) return m.call(o);
|
|
4
|
+
if (o && typeof o.length === "number") return {
|
|
5
|
+
next: function () {
|
|
6
|
+
if (o && i >= o.length) o = void 0;
|
|
7
|
+
return { value: o && o[i++], done: !o };
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
11
|
+
};
|
|
1
12
|
import { SYMBOL_GEO_MULTI_LINE_STRING } from '../helper/symbol';
|
|
2
13
|
import { isArray, isNumber } from '../utils/type';
|
|
3
14
|
import { LineString } from './lineString';
|
|
4
|
-
|
|
5
|
-
|
|
15
|
+
var MultiLineString = (function () {
|
|
16
|
+
function MultiLineString(lines) {
|
|
6
17
|
if (!isArray(lines)) {
|
|
7
|
-
throw new TypeError(
|
|
18
|
+
throw new TypeError("\"lines\" must be of type LineString[]. Received type ".concat(typeof lines));
|
|
8
19
|
}
|
|
9
20
|
if (lines.length === 0) {
|
|
10
21
|
throw new Error('Polygon must contain 1 linestring at least');
|
|
11
22
|
}
|
|
12
|
-
lines.forEach(line
|
|
23
|
+
lines.forEach(function (line) {
|
|
13
24
|
if (!(line instanceof LineString)) {
|
|
14
|
-
throw new TypeError(
|
|
25
|
+
throw new TypeError("\"lines\" must be of type LineString[]. Received type ".concat(typeof line, "[]"));
|
|
15
26
|
}
|
|
16
27
|
});
|
|
17
28
|
this.lines = lines;
|
|
18
29
|
}
|
|
19
|
-
parse(key) {
|
|
20
|
-
|
|
21
|
-
|
|
30
|
+
MultiLineString.prototype.parse = function (key) {
|
|
31
|
+
var _a;
|
|
32
|
+
return _a = {},
|
|
33
|
+
_a[key] = {
|
|
22
34
|
type: 'MultiLineString',
|
|
23
|
-
coordinates: this.lines.map(line
|
|
24
|
-
return line.points.map(point
|
|
35
|
+
coordinates: this.lines.map(function (line) {
|
|
36
|
+
return line.points.map(function (point) { return [point.longitude, point.latitude]; });
|
|
25
37
|
})
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
toJSON() {
|
|
38
|
+
},
|
|
39
|
+
_a;
|
|
40
|
+
};
|
|
41
|
+
MultiLineString.prototype.toJSON = function () {
|
|
30
42
|
return {
|
|
31
43
|
type: 'MultiLineString',
|
|
32
|
-
coordinates: this.lines.map(line
|
|
33
|
-
return line.points.map(point
|
|
44
|
+
coordinates: this.lines.map(function (line) {
|
|
45
|
+
return line.points.map(function (point) { return [point.longitude, point.latitude]; });
|
|
34
46
|
})
|
|
35
47
|
};
|
|
36
|
-
}
|
|
37
|
-
|
|
48
|
+
};
|
|
49
|
+
MultiLineString.validate = function (multiLineString) {
|
|
50
|
+
var e_1, _a, e_2, _b;
|
|
38
51
|
if (multiLineString.type !== 'MultiLineString' || !isArray(multiLineString.coordinates)) {
|
|
39
52
|
return false;
|
|
40
53
|
}
|
|
41
|
-
|
|
42
|
-
for (
|
|
43
|
-
|
|
44
|
-
|
|
54
|
+
try {
|
|
55
|
+
for (var _c = __values(multiLineString.coordinates), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
56
|
+
var line = _d.value;
|
|
57
|
+
try {
|
|
58
|
+
for (var line_1 = (e_2 = void 0, __values(line)), line_1_1 = line_1.next(); !line_1_1.done; line_1_1 = line_1.next()) {
|
|
59
|
+
var point = line_1_1.value;
|
|
60
|
+
if (!isNumber(point[0]) || !isNumber(point[1])) {
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
45
64
|
}
|
|
65
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
66
|
+
finally {
|
|
67
|
+
try {
|
|
68
|
+
if (line_1_1 && !line_1_1.done && (_b = line_1.return)) _b.call(line_1);
|
|
69
|
+
}
|
|
70
|
+
finally { if (e_2) throw e_2.error; }
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
75
|
+
finally {
|
|
76
|
+
try {
|
|
77
|
+
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
46
78
|
}
|
|
79
|
+
finally { if (e_1) throw e_1.error; }
|
|
47
80
|
}
|
|
48
81
|
return true;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
82
|
+
};
|
|
83
|
+
Object.defineProperty(MultiLineString.prototype, "_internalType", {
|
|
84
|
+
get: function () {
|
|
85
|
+
return SYMBOL_GEO_MULTI_LINE_STRING;
|
|
86
|
+
},
|
|
87
|
+
enumerable: false,
|
|
88
|
+
configurable: true
|
|
89
|
+
});
|
|
90
|
+
return MultiLineString;
|
|
91
|
+
}());
|
|
92
|
+
export { MultiLineString };
|
|
@@ -14,5 +14,5 @@ export declare class MultiPoint {
|
|
|
14
14
|
coordinates: number[][];
|
|
15
15
|
};
|
|
16
16
|
static validate(multiPoint: ISerializedMultiPoint): boolean;
|
|
17
|
-
|
|
17
|
+
get _internalType(): import("../utils/symbol").InternalSymbol;
|
|
18
18
|
}
|
|
@@ -1,47 +1,76 @@
|
|
|
1
|
+
var __values = (this && this.__values) || function(o) {
|
|
2
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
3
|
+
if (m) return m.call(o);
|
|
4
|
+
if (o && typeof o.length === "number") return {
|
|
5
|
+
next: function () {
|
|
6
|
+
if (o && i >= o.length) o = void 0;
|
|
7
|
+
return { value: o && o[i++], done: !o };
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
11
|
+
};
|
|
1
12
|
import { SYMBOL_GEO_MULTI_POINT } from '../helper/symbol';
|
|
2
13
|
import { Point } from './point';
|
|
3
14
|
import { isArray, isNumber } from '../utils/type';
|
|
4
|
-
|
|
5
|
-
|
|
15
|
+
var MultiPoint = (function () {
|
|
16
|
+
function MultiPoint(points) {
|
|
6
17
|
if (!isArray(points)) {
|
|
7
|
-
throw new TypeError(
|
|
18
|
+
throw new TypeError("\"points\" must be of type Point[]. Received type ".concat(typeof points));
|
|
8
19
|
}
|
|
9
20
|
if (points.length === 0) {
|
|
10
21
|
throw new Error('"points" must contain 1 point at least');
|
|
11
22
|
}
|
|
12
|
-
points.forEach(point
|
|
23
|
+
points.forEach(function (point) {
|
|
13
24
|
if (!(point instanceof Point)) {
|
|
14
|
-
throw new TypeError(
|
|
25
|
+
throw new TypeError("\"points\" must be of type Point[]. Received type ".concat(typeof point, "[]"));
|
|
15
26
|
}
|
|
16
27
|
});
|
|
17
28
|
this.points = points;
|
|
18
29
|
}
|
|
19
|
-
parse(key) {
|
|
20
|
-
|
|
21
|
-
|
|
30
|
+
MultiPoint.prototype.parse = function (key) {
|
|
31
|
+
var _a;
|
|
32
|
+
return _a = {},
|
|
33
|
+
_a[key] = {
|
|
22
34
|
type: 'MultiPoint',
|
|
23
|
-
coordinates: this.points.map(point
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
toJSON() {
|
|
35
|
+
coordinates: this.points.map(function (point) { return point.toJSON().coordinates; })
|
|
36
|
+
},
|
|
37
|
+
_a;
|
|
38
|
+
};
|
|
39
|
+
MultiPoint.prototype.toJSON = function () {
|
|
28
40
|
return {
|
|
29
41
|
type: 'MultiPoint',
|
|
30
|
-
coordinates: this.points.map(point
|
|
42
|
+
coordinates: this.points.map(function (point) { return point.toJSON().coordinates; })
|
|
31
43
|
};
|
|
32
|
-
}
|
|
33
|
-
|
|
44
|
+
};
|
|
45
|
+
MultiPoint.validate = function (multiPoint) {
|
|
46
|
+
var e_1, _a;
|
|
34
47
|
if (multiPoint.type !== 'MultiPoint' || !isArray(multiPoint.coordinates)) {
|
|
35
48
|
return false;
|
|
36
49
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
50
|
+
try {
|
|
51
|
+
for (var _b = __values(multiPoint.coordinates), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
52
|
+
var point = _c.value;
|
|
53
|
+
if (!isNumber(point[0]) || !isNumber(point[1])) {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
59
|
+
finally {
|
|
60
|
+
try {
|
|
61
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
40
62
|
}
|
|
63
|
+
finally { if (e_1) throw e_1.error; }
|
|
41
64
|
}
|
|
42
65
|
return true;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
66
|
+
};
|
|
67
|
+
Object.defineProperty(MultiPoint.prototype, "_internalType", {
|
|
68
|
+
get: function () {
|
|
69
|
+
return SYMBOL_GEO_MULTI_POINT;
|
|
70
|
+
},
|
|
71
|
+
enumerable: false,
|
|
72
|
+
configurable: true
|
|
73
|
+
});
|
|
74
|
+
return MultiPoint;
|
|
75
|
+
}());
|
|
76
|
+
export { MultiPoint };
|
|
@@ -14,5 +14,5 @@ export declare class MultiPolygon {
|
|
|
14
14
|
coordinates: number[][][][];
|
|
15
15
|
};
|
|
16
16
|
static validate(multiPolygon: ISerializedMultiPolygon): boolean;
|
|
17
|
-
|
|
17
|
+
get _internalType(): import("../utils/symbol").InternalSymbol;
|
|
18
18
|
}
|
|
@@ -1,59 +1,119 @@
|
|
|
1
|
+
var __values = (this && this.__values) || function(o) {
|
|
2
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
3
|
+
if (m) return m.call(o);
|
|
4
|
+
if (o && typeof o.length === "number") return {
|
|
5
|
+
next: function () {
|
|
6
|
+
if (o && i >= o.length) o = void 0;
|
|
7
|
+
return { value: o && o[i++], done: !o };
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
11
|
+
};
|
|
1
12
|
import { SYMBOL_GEO_MULTI_POLYGON } from '../helper/symbol';
|
|
2
13
|
import { isArray, isNumber } from '../utils/type';
|
|
3
14
|
import { Polygon } from './polygon';
|
|
4
|
-
|
|
5
|
-
|
|
15
|
+
var MultiPolygon = (function () {
|
|
16
|
+
function MultiPolygon(polygons) {
|
|
17
|
+
var e_1, _a;
|
|
6
18
|
if (!isArray(polygons)) {
|
|
7
|
-
throw new TypeError(
|
|
19
|
+
throw new TypeError("\"polygons\" must be of type Polygon[]. Received type ".concat(typeof polygons));
|
|
8
20
|
}
|
|
9
21
|
if (polygons.length === 0) {
|
|
10
22
|
throw new Error('MultiPolygon must contain 1 polygon at least');
|
|
11
23
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
24
|
+
try {
|
|
25
|
+
for (var polygons_1 = __values(polygons), polygons_1_1 = polygons_1.next(); !polygons_1_1.done; polygons_1_1 = polygons_1.next()) {
|
|
26
|
+
var polygon = polygons_1_1.value;
|
|
27
|
+
if (!(polygon instanceof Polygon)) {
|
|
28
|
+
throw new TypeError("\"polygon\" must be of type Polygon[]. Received type ".concat(typeof polygon, "[]"));
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
33
|
+
finally {
|
|
34
|
+
try {
|
|
35
|
+
if (polygons_1_1 && !polygons_1_1.done && (_a = polygons_1.return)) _a.call(polygons_1);
|
|
15
36
|
}
|
|
37
|
+
finally { if (e_1) throw e_1.error; }
|
|
16
38
|
}
|
|
17
39
|
this.polygons = polygons;
|
|
18
40
|
}
|
|
19
|
-
parse(key) {
|
|
20
|
-
|
|
21
|
-
|
|
41
|
+
MultiPolygon.prototype.parse = function (key) {
|
|
42
|
+
var _a;
|
|
43
|
+
return _a = {},
|
|
44
|
+
_a[key] = {
|
|
22
45
|
type: 'MultiPolygon',
|
|
23
|
-
coordinates: this.polygons.map(polygon
|
|
24
|
-
return polygon.lines.map(line
|
|
25
|
-
return line.points.map(point
|
|
46
|
+
coordinates: this.polygons.map(function (polygon) {
|
|
47
|
+
return polygon.lines.map(function (line) {
|
|
48
|
+
return line.points.map(function (point) { return [point.longitude, point.latitude]; });
|
|
26
49
|
});
|
|
27
50
|
})
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
toJSON() {
|
|
51
|
+
},
|
|
52
|
+
_a;
|
|
53
|
+
};
|
|
54
|
+
MultiPolygon.prototype.toJSON = function () {
|
|
32
55
|
return {
|
|
33
56
|
type: 'MultiPolygon',
|
|
34
|
-
coordinates: this.polygons.map(polygon
|
|
35
|
-
return polygon.lines.map(line
|
|
36
|
-
return line.points.map(point
|
|
57
|
+
coordinates: this.polygons.map(function (polygon) {
|
|
58
|
+
return polygon.lines.map(function (line) {
|
|
59
|
+
return line.points.map(function (point) { return [point.longitude, point.latitude]; });
|
|
37
60
|
});
|
|
38
61
|
})
|
|
39
62
|
};
|
|
40
|
-
}
|
|
41
|
-
|
|
63
|
+
};
|
|
64
|
+
MultiPolygon.validate = function (multiPolygon) {
|
|
65
|
+
var e_2, _a, e_3, _b, e_4, _c;
|
|
42
66
|
if (multiPolygon.type !== 'MultiPolygon' || !isArray(multiPolygon.coordinates)) {
|
|
43
67
|
return false;
|
|
44
68
|
}
|
|
45
|
-
|
|
46
|
-
for (
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
69
|
+
try {
|
|
70
|
+
for (var _d = __values(multiPolygon.coordinates), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
71
|
+
var polygon = _e.value;
|
|
72
|
+
try {
|
|
73
|
+
for (var polygon_1 = (e_3 = void 0, __values(polygon)), polygon_1_1 = polygon_1.next(); !polygon_1_1.done; polygon_1_1 = polygon_1.next()) {
|
|
74
|
+
var line = polygon_1_1.value;
|
|
75
|
+
try {
|
|
76
|
+
for (var line_1 = (e_4 = void 0, __values(line)), line_1_1 = line_1.next(); !line_1_1.done; line_1_1 = line_1.next()) {
|
|
77
|
+
var point = line_1_1.value;
|
|
78
|
+
if (!isNumber(point[0]) || !isNumber(point[1])) {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
84
|
+
finally {
|
|
85
|
+
try {
|
|
86
|
+
if (line_1_1 && !line_1_1.done && (_c = line_1.return)) _c.call(line_1);
|
|
87
|
+
}
|
|
88
|
+
finally { if (e_4) throw e_4.error; }
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
93
|
+
finally {
|
|
94
|
+
try {
|
|
95
|
+
if (polygon_1_1 && !polygon_1_1.done && (_b = polygon_1.return)) _b.call(polygon_1);
|
|
50
96
|
}
|
|
97
|
+
finally { if (e_3) throw e_3.error; }
|
|
51
98
|
}
|
|
52
99
|
}
|
|
53
100
|
}
|
|
101
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
102
|
+
finally {
|
|
103
|
+
try {
|
|
104
|
+
if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
|
|
105
|
+
}
|
|
106
|
+
finally { if (e_2) throw e_2.error; }
|
|
107
|
+
}
|
|
54
108
|
return true;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
109
|
+
};
|
|
110
|
+
Object.defineProperty(MultiPolygon.prototype, "_internalType", {
|
|
111
|
+
get: function () {
|
|
112
|
+
return SYMBOL_GEO_MULTI_POLYGON;
|
|
113
|
+
},
|
|
114
|
+
enumerable: false,
|
|
115
|
+
configurable: true
|
|
116
|
+
});
|
|
117
|
+
return MultiPolygon;
|
|
118
|
+
}());
|
|
119
|
+
export { MultiPolygon };
|
package/dist/esm/geo/point.d.ts
CHANGED
package/dist/esm/geo/point.js
CHANGED
|
@@ -1,22 +1,23 @@
|
|
|
1
1
|
import { Validate } from '../validate';
|
|
2
2
|
import { SYMBOL_GEO_POINT } from '../helper/symbol';
|
|
3
3
|
import { isArray } from '../utils/type';
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
var Point = (function () {
|
|
5
|
+
function Point(longitude, latitude) {
|
|
6
6
|
Validate.isGeopoint('longitude', longitude);
|
|
7
7
|
Validate.isGeopoint('latitude', latitude);
|
|
8
8
|
this.longitude = longitude;
|
|
9
9
|
this.latitude = latitude;
|
|
10
10
|
}
|
|
11
|
-
parse(key) {
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
Point.prototype.parse = function (key) {
|
|
12
|
+
var _a;
|
|
13
|
+
return _a = {},
|
|
14
|
+
_a[key] = {
|
|
14
15
|
type: 'Point',
|
|
15
16
|
coordinates: [this.longitude, this.latitude]
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
toJSON() {
|
|
17
|
+
},
|
|
18
|
+
_a;
|
|
19
|
+
};
|
|
20
|
+
Point.prototype.toJSON = function () {
|
|
20
21
|
return {
|
|
21
22
|
type: 'Point',
|
|
22
23
|
coordinates: [
|
|
@@ -24,17 +25,23 @@ export class Point {
|
|
|
24
25
|
this.latitude,
|
|
25
26
|
],
|
|
26
27
|
};
|
|
27
|
-
}
|
|
28
|
-
toReadableString() {
|
|
29
|
-
return
|
|
30
|
-
}
|
|
31
|
-
|
|
28
|
+
};
|
|
29
|
+
Point.prototype.toReadableString = function () {
|
|
30
|
+
return "[".concat(this.longitude, ",").concat(this.latitude, "]");
|
|
31
|
+
};
|
|
32
|
+
Point.validate = function (point) {
|
|
32
33
|
return point.type === 'Point' &&
|
|
33
34
|
isArray(point.coordinates) &&
|
|
34
35
|
Validate.isGeopoint('longitude', point.coordinates[0]) &&
|
|
35
36
|
Validate.isGeopoint('latitude', point.coordinates[1]);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(Point.prototype, "_internalType", {
|
|
39
|
+
get: function () {
|
|
40
|
+
return SYMBOL_GEO_POINT;
|
|
41
|
+
},
|
|
42
|
+
enumerable: false,
|
|
43
|
+
configurable: true
|
|
44
|
+
});
|
|
45
|
+
return Point;
|
|
46
|
+
}());
|
|
47
|
+
export { Point };
|
|
@@ -15,5 +15,5 @@ export declare class Polygon {
|
|
|
15
15
|
};
|
|
16
16
|
static validate(polygon: ISerializedPolygon): boolean;
|
|
17
17
|
static isCloseLineString(lineString: any): boolean;
|
|
18
|
-
|
|
18
|
+
get _internalType(): import("../utils/symbol").InternalSymbol;
|
|
19
19
|
}
|
package/dist/esm/geo/polygon.js
CHANGED
|
@@ -1,67 +1,106 @@
|
|
|
1
|
+
var __values = (this && this.__values) || function(o) {
|
|
2
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
3
|
+
if (m) return m.call(o);
|
|
4
|
+
if (o && typeof o.length === "number") return {
|
|
5
|
+
next: function () {
|
|
6
|
+
if (o && i >= o.length) o = void 0;
|
|
7
|
+
return { value: o && o[i++], done: !o };
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
11
|
+
};
|
|
1
12
|
import { SYMBOL_GEO_POLYGON } from '../helper/symbol';
|
|
2
13
|
import { isArray, isNumber } from '../utils/type';
|
|
3
14
|
import { LineString } from './lineString';
|
|
4
|
-
|
|
5
|
-
|
|
15
|
+
var Polygon = (function () {
|
|
16
|
+
function Polygon(lines) {
|
|
6
17
|
if (!isArray(lines)) {
|
|
7
|
-
throw new TypeError(
|
|
18
|
+
throw new TypeError("\"lines\" must be of type LineString[]. Received type ".concat(typeof lines));
|
|
8
19
|
}
|
|
9
20
|
if (lines.length === 0) {
|
|
10
21
|
throw new Error('Polygon must contain 1 linestring at least');
|
|
11
22
|
}
|
|
12
|
-
lines.forEach(line
|
|
23
|
+
lines.forEach(function (line) {
|
|
13
24
|
if (!(line instanceof LineString)) {
|
|
14
|
-
throw new TypeError(
|
|
25
|
+
throw new TypeError("\"lines\" must be of type LineString[]. Received type ".concat(typeof line, "[]"));
|
|
15
26
|
}
|
|
16
27
|
if (!LineString.isClosed(line)) {
|
|
17
|
-
throw new Error(
|
|
28
|
+
throw new Error("LineString ".concat(line.points.map(function (p) { return p.toReadableString(); }), " is not a closed cycle"));
|
|
18
29
|
}
|
|
19
30
|
});
|
|
20
31
|
this.lines = lines;
|
|
21
32
|
}
|
|
22
|
-
parse(key) {
|
|
23
|
-
|
|
24
|
-
|
|
33
|
+
Polygon.prototype.parse = function (key) {
|
|
34
|
+
var _a;
|
|
35
|
+
return _a = {},
|
|
36
|
+
_a[key] = {
|
|
25
37
|
type: 'Polygon',
|
|
26
|
-
coordinates: this.lines.map(line
|
|
27
|
-
return line.points.map(point
|
|
38
|
+
coordinates: this.lines.map(function (line) {
|
|
39
|
+
return line.points.map(function (point) { return [point.longitude, point.latitude]; });
|
|
28
40
|
})
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
toJSON() {
|
|
41
|
+
},
|
|
42
|
+
_a;
|
|
43
|
+
};
|
|
44
|
+
Polygon.prototype.toJSON = function () {
|
|
33
45
|
return {
|
|
34
46
|
type: 'Polygon',
|
|
35
|
-
coordinates: this.lines.map(line
|
|
36
|
-
return line.points.map(point
|
|
47
|
+
coordinates: this.lines.map(function (line) {
|
|
48
|
+
return line.points.map(function (point) { return [point.longitude, point.latitude]; });
|
|
37
49
|
})
|
|
38
50
|
};
|
|
39
|
-
}
|
|
40
|
-
|
|
51
|
+
};
|
|
52
|
+
Polygon.validate = function (polygon) {
|
|
53
|
+
var e_1, _a, e_2, _b;
|
|
41
54
|
if (polygon.type !== 'Polygon' || !isArray(polygon.coordinates)) {
|
|
42
55
|
return false;
|
|
43
56
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
for (let point of line) {
|
|
49
|
-
if (!isNumber(point[0]) || !isNumber(point[1])) {
|
|
57
|
+
try {
|
|
58
|
+
for (var _c = __values(polygon.coordinates), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
59
|
+
var line = _d.value;
|
|
60
|
+
if (!this.isCloseLineString(line)) {
|
|
50
61
|
return false;
|
|
51
62
|
}
|
|
63
|
+
try {
|
|
64
|
+
for (var line_1 = (e_2 = void 0, __values(line)), line_1_1 = line_1.next(); !line_1_1.done; line_1_1 = line_1.next()) {
|
|
65
|
+
var point = line_1_1.value;
|
|
66
|
+
if (!isNumber(point[0]) || !isNumber(point[1])) {
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
72
|
+
finally {
|
|
73
|
+
try {
|
|
74
|
+
if (line_1_1 && !line_1_1.done && (_b = line_1.return)) _b.call(line_1);
|
|
75
|
+
}
|
|
76
|
+
finally { if (e_2) throw e_2.error; }
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
81
|
+
finally {
|
|
82
|
+
try {
|
|
83
|
+
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
52
84
|
}
|
|
85
|
+
finally { if (e_1) throw e_1.error; }
|
|
53
86
|
}
|
|
54
87
|
return true;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
88
|
+
};
|
|
89
|
+
Polygon.isCloseLineString = function (lineString) {
|
|
90
|
+
var firstPoint = lineString[0];
|
|
91
|
+
var lastPoint = lineString[lineString.length - 1];
|
|
59
92
|
if (firstPoint[0] !== lastPoint[0] || firstPoint[1] !== lastPoint[1]) {
|
|
60
93
|
return false;
|
|
61
94
|
}
|
|
62
95
|
return true;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
96
|
+
};
|
|
97
|
+
Object.defineProperty(Polygon.prototype, "_internalType", {
|
|
98
|
+
get: function () {
|
|
99
|
+
return SYMBOL_GEO_POLYGON;
|
|
100
|
+
},
|
|
101
|
+
enumerable: false,
|
|
102
|
+
configurable: true
|
|
103
|
+
});
|
|
104
|
+
return Polygon;
|
|
105
|
+
}());
|
|
106
|
+
export { Polygon };
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import InternalSymbol from '../utils/symbol';
|
|
2
2
|
export * from '../utils/symbol';
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export
|
|
8
|
-
export
|
|
9
|
-
export
|
|
10
|
-
export
|
|
11
|
-
export
|
|
12
|
-
export
|
|
13
|
-
export
|
|
14
|
-
export
|
|
15
|
-
export
|
|
3
|
+
export var SYMBOL_UNSET_FIELD_NAME = InternalSymbol.for('UNSET_FIELD_NAME');
|
|
4
|
+
export var SYMBOL_UPDATE_COMMAND = InternalSymbol.for('UPDATE_COMMAND');
|
|
5
|
+
export var SYMBOL_QUERY_COMMAND = InternalSymbol.for('QUERY_COMMAND');
|
|
6
|
+
export var SYMBOL_LOGIC_COMMAND = InternalSymbol.for('LOGIC_COMMAND');
|
|
7
|
+
export var SYMBOL_GEO_POINT = InternalSymbol.for('GEO_POINT');
|
|
8
|
+
export var SYMBOL_GEO_LINE_STRING = InternalSymbol.for('SYMBOL_GEO_LINE_STRING');
|
|
9
|
+
export var SYMBOL_GEO_POLYGON = InternalSymbol.for('SYMBOL_GEO_POLYGON');
|
|
10
|
+
export var SYMBOL_GEO_MULTI_POINT = InternalSymbol.for('SYMBOL_GEO_MULTI_POINT');
|
|
11
|
+
export var SYMBOL_GEO_MULTI_LINE_STRING = InternalSymbol.for('SYMBOL_GEO_MULTI_LINE_STRING');
|
|
12
|
+
export var SYMBOL_GEO_MULTI_POLYGON = InternalSymbol.for('SYMBOL_GEO_MULTI_POLYGON');
|
|
13
|
+
export var SYMBOL_SERVER_DATE = InternalSymbol.for('SERVER_DATE');
|
|
14
|
+
export var SYMBOL_REGEXP = InternalSymbol.for('REGEXP');
|
|
15
|
+
export var SYMBOL_OBJECTID = InternalSymbol.for('OBJECTID');
|