@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.
Files changed (196) hide show
  1. package/dist/commonjs/ObjectId/index.d.ts +1 -1
  2. package/dist/commonjs/ObjectId/index.js +16 -9
  3. package/dist/commonjs/aggregate.js +126 -75
  4. package/dist/commonjs/collection.d.ts +3 -2
  5. package/dist/commonjs/collection.js +131 -58
  6. package/dist/commonjs/command.d.ts +5 -5
  7. package/dist/commonjs/command.js +181 -154
  8. package/dist/commonjs/commands/logic.js +30 -20
  9. package/dist/commonjs/commands/query.d.ts +1 -1
  10. package/dist/commonjs/commands/query.js +85 -65
  11. package/dist/commonjs/commands/update.js +9 -7
  12. package/dist/commonjs/config/error.config.js +1 -0
  13. package/dist/commonjs/const/code.js +1 -0
  14. package/dist/commonjs/constant.d.ts +7 -7
  15. package/dist/commonjs/constant.js +13 -11
  16. package/dist/commonjs/document.d.ts +10 -6
  17. package/dist/commonjs/document.js +305 -193
  18. package/dist/commonjs/geo/index.js +20 -9
  19. package/dist/commonjs/geo/lineString.d.ts +1 -1
  20. package/dist/commonjs/geo/lineString.js +62 -33
  21. package/dist/commonjs/geo/multiLineString.d.ts +1 -1
  22. package/dist/commonjs/geo/multiLineString.js +71 -32
  23. package/dist/commonjs/geo/multiPoint.d.ts +1 -1
  24. package/dist/commonjs/geo/multiPoint.js +58 -29
  25. package/dist/commonjs/geo/multiPolygon.d.ts +1 -1
  26. package/dist/commonjs/geo/multiPolygon.js +96 -36
  27. package/dist/commonjs/geo/point.d.ts +1 -1
  28. package/dist/commonjs/geo/point.js +30 -23
  29. package/dist/commonjs/geo/polygon.d.ts +1 -1
  30. package/dist/commonjs/geo/polygon.js +78 -39
  31. package/dist/commonjs/helper/symbol.js +17 -5
  32. package/dist/commonjs/index.d.ts +8 -2
  33. package/dist/commonjs/index.js +73 -20
  34. package/dist/commonjs/lib/util.d.ts +1 -0
  35. package/dist/commonjs/lib/util.js +26 -0
  36. package/dist/commonjs/operator-map.js +7 -6
  37. package/dist/commonjs/query.d.ts +8 -4
  38. package/dist/commonjs/query.js +308 -201
  39. package/dist/commonjs/regexp/index.d.ts +1 -1
  40. package/dist/commonjs/regexp/index.js +16 -9
  41. package/dist/commonjs/serializer/common.d.ts +2 -2
  42. package/dist/commonjs/serializer/common.js +59 -22
  43. package/dist/commonjs/serializer/datatype.d.ts +2 -2
  44. package/dist/commonjs/serializer/datatype.js +58 -21
  45. package/dist/commonjs/serializer/query.d.ts +1 -1
  46. package/dist/commonjs/serializer/query.js +137 -127
  47. package/dist/commonjs/serializer/update.d.ts +1 -1
  48. package/dist/commonjs/serializer/update.js +83 -78
  49. package/dist/commonjs/serverDate/index.d.ts +1 -1
  50. package/dist/commonjs/serverDate/index.js +16 -9
  51. package/dist/commonjs/transaction/collection.d.ts +7 -0
  52. package/dist/commonjs/transaction/collection.js +49 -0
  53. package/dist/commonjs/transaction/document.d.ts +27 -0
  54. package/dist/commonjs/transaction/document.js +205 -0
  55. package/dist/commonjs/transaction/index.js +196 -86
  56. package/dist/commonjs/transaction/query.d.ts +43 -0
  57. package/dist/commonjs/transaction/query.js +261 -0
  58. package/dist/commonjs/typings/index.d.ts +4 -4
  59. package/dist/commonjs/typings/realtime.d.ts +16 -16
  60. package/dist/commonjs/util.js +123 -92
  61. package/dist/commonjs/utils/error.d.ts +2 -1
  62. package/dist/commonjs/utils/error.js +74 -38
  63. package/dist/commonjs/utils/symbol.js +33 -14
  64. package/dist/commonjs/utils/type.d.ts +1 -1
  65. package/dist/commonjs/utils/type.js +25 -13
  66. package/dist/commonjs/utils/utils.d.ts +4 -1
  67. package/dist/commonjs/utils/utils.js +93 -22
  68. package/dist/commonjs/validate.js +79 -63
  69. package/dist/esm/ObjectId/index.d.ts +1 -1
  70. package/dist/esm/ObjectId/index.js +15 -8
  71. package/dist/esm/aggregate.js +118 -66
  72. package/dist/esm/collection.d.ts +3 -2
  73. package/dist/esm/collection.js +125 -52
  74. package/dist/esm/command.d.ts +5 -5
  75. package/dist/esm/command.js +175 -147
  76. package/dist/esm/commands/logic.js +30 -20
  77. package/dist/esm/commands/query.d.ts +1 -1
  78. package/dist/esm/commands/query.js +91 -71
  79. package/dist/esm/commands/update.js +8 -6
  80. package/dist/esm/config/error.config.js +1 -1
  81. package/dist/esm/const/code.js +1 -1
  82. package/dist/esm/constant.d.ts +7 -7
  83. package/dist/esm/constant.js +12 -11
  84. package/dist/esm/document.d.ts +10 -6
  85. package/dist/esm/document.js +297 -185
  86. package/dist/esm/geo/interface.js +1 -0
  87. package/dist/esm/geo/lineString.d.ts +1 -1
  88. package/dist/esm/geo/lineString.js +57 -28
  89. package/dist/esm/geo/multiLineString.d.ts +1 -1
  90. package/dist/esm/geo/multiLineString.js +66 -27
  91. package/dist/esm/geo/multiPoint.d.ts +1 -1
  92. package/dist/esm/geo/multiPoint.js +53 -24
  93. package/dist/esm/geo/multiPolygon.d.ts +1 -1
  94. package/dist/esm/geo/multiPolygon.js +91 -31
  95. package/dist/esm/geo/point.d.ts +1 -1
  96. package/dist/esm/geo/point.js +26 -19
  97. package/dist/esm/geo/polygon.d.ts +1 -1
  98. package/dist/esm/geo/polygon.js +73 -34
  99. package/dist/esm/helper/symbol.js +13 -13
  100. package/dist/esm/index.d.ts +8 -2
  101. package/dist/esm/index.js +62 -9
  102. package/dist/esm/lib/util.d.ts +1 -0
  103. package/dist/esm/lib/util.js +22 -0
  104. package/dist/esm/operator-map.js +4 -4
  105. package/dist/esm/query.d.ts +8 -4
  106. package/dist/esm/query.js +299 -192
  107. package/dist/esm/regexp/index.d.ts +1 -1
  108. package/dist/esm/regexp/index.js +15 -8
  109. package/dist/esm/serializer/common.d.ts +2 -2
  110. package/dist/esm/serializer/common.js +49 -13
  111. package/dist/esm/serializer/datatype.d.ts +2 -2
  112. package/dist/esm/serializer/datatype.js +44 -8
  113. package/dist/esm/serializer/query.d.ts +1 -1
  114. package/dist/esm/serializer/query.js +112 -102
  115. package/dist/esm/serializer/update.d.ts +1 -1
  116. package/dist/esm/serializer/update.js +69 -64
  117. package/dist/esm/serverDate/index.d.ts +1 -1
  118. package/dist/esm/serverDate/index.js +15 -8
  119. package/dist/esm/transaction/collection.d.ts +7 -0
  120. package/dist/esm/transaction/collection.js +46 -0
  121. package/dist/esm/transaction/document.d.ts +27 -0
  122. package/dist/esm/transaction/document.js +202 -0
  123. package/dist/esm/transaction/index.js +191 -81
  124. package/dist/esm/transaction/query.d.ts +43 -0
  125. package/dist/esm/transaction/query.js +258 -0
  126. package/dist/esm/typings/index.d.ts +4 -4
  127. package/dist/esm/typings/index.js +1 -0
  128. package/dist/esm/typings/realtime.d.ts +16 -16
  129. package/dist/esm/typings/realtime.js +1 -0
  130. package/dist/esm/util.js +121 -90
  131. package/dist/esm/utils/error.d.ts +2 -1
  132. package/dist/esm/utils/error.js +70 -35
  133. package/dist/esm/utils/symbol.js +33 -14
  134. package/dist/esm/utils/type.d.ts +1 -1
  135. package/dist/esm/utils/type.js +12 -12
  136. package/dist/esm/utils/utils.d.ts +4 -1
  137. package/dist/esm/utils/utils.js +78 -16
  138. package/dist/esm/validate.js +65 -49
  139. package/jest.config.js +14 -0
  140. package/package.json +14 -10
  141. package/src/aggregate.ts +1 -5
  142. package/src/collection.ts +15 -2
  143. package/src/document.ts +45 -34
  144. package/src/index.ts +51 -4
  145. package/src/query.ts +33 -29
  146. package/src/serializer/query.ts +18 -6
  147. package/src/transaction/index.ts +1 -1
  148. package/src/typings/index.ts +0 -4
  149. package/src/utils/utils.ts +46 -0
  150. package/src/validate.ts +3 -6
  151. package/tests/gateway-contract.test.ts +180 -0
  152. package/tests/index.test.ts +283 -0
  153. package/tests/transaction-query.test.ts +207 -0
  154. package/tsconfig.esm.json +4 -2
  155. package/tsconfig.json +16 -6
  156. package/tsconfig.test.json +15 -0
  157. package/dist/commonjs/realtime/error.d.ts +0 -7
  158. package/dist/commonjs/realtime/error.js +0 -11
  159. package/dist/commonjs/realtime/listener.d.ts +0 -14
  160. package/dist/commonjs/realtime/listener.js +0 -17
  161. package/dist/commonjs/realtime/message.d.ts +0 -3
  162. package/dist/commonjs/realtime/message.js +0 -10
  163. package/dist/commonjs/realtime/snapshot.d.ts +0 -16
  164. package/dist/commonjs/realtime/snapshot.js +0 -42
  165. package/dist/commonjs/realtime/virtual-websocket-client.d.ts +0 -63
  166. package/dist/commonjs/realtime/virtual-websocket-client.js +0 -736
  167. package/dist/commonjs/realtime/websocket-client.d.ts +0 -78
  168. package/dist/commonjs/realtime/websocket-client.js +0 -567
  169. package/dist/commonjs/realtime/ws-event.d.ts +0 -126
  170. package/dist/commonjs/realtime/ws-event.js +0 -139
  171. package/dist/commonjs/transaction.d.ts +0 -42
  172. package/dist/commonjs/transaction.js +0 -126
  173. package/dist/esm/realtime/error.d.ts +0 -7
  174. package/dist/esm/realtime/error.js +0 -8
  175. package/dist/esm/realtime/listener.d.ts +0 -14
  176. package/dist/esm/realtime/listener.js +0 -14
  177. package/dist/esm/realtime/message.d.ts +0 -3
  178. package/dist/esm/realtime/message.js +0 -6
  179. package/dist/esm/realtime/snapshot.d.ts +0 -16
  180. package/dist/esm/realtime/snapshot.js +0 -39
  181. package/dist/esm/realtime/virtual-websocket-client.d.ts +0 -63
  182. package/dist/esm/realtime/virtual-websocket-client.js +0 -733
  183. package/dist/esm/realtime/websocket-client.d.ts +0 -78
  184. package/dist/esm/realtime/websocket-client.js +0 -564
  185. package/dist/esm/realtime/ws-event.d.ts +0 -126
  186. package/dist/esm/realtime/ws-event.js +0 -137
  187. package/dist/esm/transaction.d.ts +0 -42
  188. package/dist/esm/transaction.js +0 -121
  189. package/src/realtime/error.ts +0 -19
  190. package/src/realtime/listener.ts +0 -35
  191. package/src/realtime/message.ts +0 -14
  192. package/src/realtime/snapshot.ts +0 -60
  193. package/src/realtime/virtual-websocket-client.ts +0 -1195
  194. package/src/realtime/websocket-client.ts +0 -995
  195. package/src/realtime/ws-event.ts +0 -163
  196. package/src/transaction.ts +0 -190
@@ -1,57 +1,86 @@
1
1
  "use strict";
2
+ var __values = (this && this.__values) || function(o) {
3
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
4
+ if (m) return m.call(o);
5
+ if (o && typeof o.length === "number") return {
6
+ next: function () {
7
+ if (o && i >= o.length) o = void 0;
8
+ return { value: o && o[i++], done: !o };
9
+ }
10
+ };
11
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
12
+ };
2
13
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const symbol_1 = require("../helper/symbol");
4
- const point_1 = require("./point");
5
- const type_1 = require("../utils/type");
6
- class LineString {
7
- constructor(points) {
8
- if (!type_1.isArray(points)) {
9
- throw new TypeError(`"points" must be of type Point[]. Received type ${typeof points}`);
14
+ exports.LineString = void 0;
15
+ var symbol_1 = require("../helper/symbol");
16
+ var point_1 = require("./point");
17
+ var type_1 = require("../utils/type");
18
+ var LineString = (function () {
19
+ function LineString(points) {
20
+ if (!(0, type_1.isArray)(points)) {
21
+ throw new TypeError("\"points\" must be of type Point[]. Received type ".concat(typeof points));
10
22
  }
11
23
  if (points.length < 2) {
12
24
  throw new Error('"points" must contain 2 points at least');
13
25
  }
14
- points.forEach(point => {
26
+ points.forEach(function (point) {
15
27
  if (!(point instanceof point_1.Point)) {
16
- throw new TypeError(`"points" must be of type Point[]. Received type ${typeof point}[]`);
28
+ throw new TypeError("\"points\" must be of type Point[]. Received type ".concat(typeof point, "[]"));
17
29
  }
18
30
  });
19
31
  this.points = points;
20
32
  }
21
- parse(key) {
22
- return {
23
- [key]: {
33
+ LineString.prototype.parse = function (key) {
34
+ var _a;
35
+ return _a = {},
36
+ _a[key] = {
24
37
  type: 'LineString',
25
- coordinates: this.points.map(point => point.toJSON().coordinates)
26
- }
27
- };
28
- }
29
- toJSON() {
38
+ coordinates: this.points.map(function (point) { return point.toJSON().coordinates; })
39
+ },
40
+ _a;
41
+ };
42
+ LineString.prototype.toJSON = function () {
30
43
  return {
31
44
  type: 'LineString',
32
- coordinates: this.points.map(point => point.toJSON().coordinates)
45
+ coordinates: this.points.map(function (point) { return point.toJSON().coordinates; })
33
46
  };
34
- }
35
- static validate(lineString) {
36
- if (lineString.type !== 'LineString' || !type_1.isArray(lineString.coordinates)) {
47
+ };
48
+ LineString.validate = function (lineString) {
49
+ var e_1, _a;
50
+ if (lineString.type !== 'LineString' || !(0, type_1.isArray)(lineString.coordinates)) {
37
51
  return false;
38
52
  }
39
- for (let point of lineString.coordinates) {
40
- if (!type_1.isNumber(point[0]) || !type_1.isNumber(point[1])) {
41
- return false;
53
+ try {
54
+ for (var _b = __values(lineString.coordinates), _c = _b.next(); !_c.done; _c = _b.next()) {
55
+ var point = _c.value;
56
+ if (!(0, type_1.isNumber)(point[0]) || !(0, type_1.isNumber)(point[1])) {
57
+ return false;
58
+ }
42
59
  }
43
60
  }
61
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
62
+ finally {
63
+ try {
64
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
65
+ }
66
+ finally { if (e_1) throw e_1.error; }
67
+ }
44
68
  return true;
45
- }
46
- static isClosed(lineString) {
47
- const firstPoint = lineString.points[0];
48
- const lastPoint = lineString.points[lineString.points.length - 1];
69
+ };
70
+ LineString.isClosed = function (lineString) {
71
+ var firstPoint = lineString.points[0];
72
+ var lastPoint = lineString.points[lineString.points.length - 1];
49
73
  if (firstPoint.latitude === lastPoint.latitude && firstPoint.longitude === lastPoint.longitude) {
50
74
  return true;
51
75
  }
52
- }
53
- get _internalType() {
54
- return symbol_1.SYMBOL_GEO_LINE_STRING;
55
- }
56
- }
76
+ };
77
+ Object.defineProperty(LineString.prototype, "_internalType", {
78
+ get: function () {
79
+ return symbol_1.SYMBOL_GEO_LINE_STRING;
80
+ },
81
+ enumerable: false,
82
+ configurable: true
83
+ });
84
+ return LineString;
85
+ }());
57
86
  exports.LineString = LineString;
@@ -14,5 +14,5 @@ export declare class MultiLineString {
14
14
  coordinates: number[][][];
15
15
  };
16
16
  static validate(multiLineString: ISerializedMultiLineString): boolean;
17
- readonly _internalType: import("../utils/symbol").InternalSymbol;
17
+ get _internalType(): import("../utils/symbol").InternalSymbol;
18
18
  }
@@ -1,56 +1,95 @@
1
1
  "use strict";
2
+ var __values = (this && this.__values) || function(o) {
3
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
4
+ if (m) return m.call(o);
5
+ if (o && typeof o.length === "number") return {
6
+ next: function () {
7
+ if (o && i >= o.length) o = void 0;
8
+ return { value: o && o[i++], done: !o };
9
+ }
10
+ };
11
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
12
+ };
2
13
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const symbol_1 = require("../helper/symbol");
4
- const type_1 = require("../utils/type");
5
- const lineString_1 = require("./lineString");
6
- class MultiLineString {
7
- constructor(lines) {
8
- if (!type_1.isArray(lines)) {
9
- throw new TypeError(`"lines" must be of type LineString[]. Received type ${typeof lines}`);
14
+ exports.MultiLineString = void 0;
15
+ var symbol_1 = require("../helper/symbol");
16
+ var type_1 = require("../utils/type");
17
+ var lineString_1 = require("./lineString");
18
+ var MultiLineString = (function () {
19
+ function MultiLineString(lines) {
20
+ if (!(0, type_1.isArray)(lines)) {
21
+ throw new TypeError("\"lines\" must be of type LineString[]. Received type ".concat(typeof lines));
10
22
  }
11
23
  if (lines.length === 0) {
12
24
  throw new Error('Polygon must contain 1 linestring at least');
13
25
  }
14
- lines.forEach(line => {
26
+ lines.forEach(function (line) {
15
27
  if (!(line instanceof lineString_1.LineString)) {
16
- throw new TypeError(`"lines" must be of type LineString[]. Received type ${typeof line}[]`);
28
+ throw new TypeError("\"lines\" must be of type LineString[]. Received type ".concat(typeof line, "[]"));
17
29
  }
18
30
  });
19
31
  this.lines = lines;
20
32
  }
21
- parse(key) {
22
- return {
23
- [key]: {
33
+ MultiLineString.prototype.parse = function (key) {
34
+ var _a;
35
+ return _a = {},
36
+ _a[key] = {
24
37
  type: 'MultiLineString',
25
- coordinates: this.lines.map(line => {
26
- return line.points.map(point => [point.longitude, point.latitude]);
38
+ coordinates: this.lines.map(function (line) {
39
+ return line.points.map(function (point) { return [point.longitude, point.latitude]; });
27
40
  })
28
- }
29
- };
30
- }
31
- toJSON() {
41
+ },
42
+ _a;
43
+ };
44
+ MultiLineString.prototype.toJSON = function () {
32
45
  return {
33
46
  type: 'MultiLineString',
34
- coordinates: this.lines.map(line => {
35
- return line.points.map(point => [point.longitude, point.latitude]);
47
+ coordinates: this.lines.map(function (line) {
48
+ return line.points.map(function (point) { return [point.longitude, point.latitude]; });
36
49
  })
37
50
  };
38
- }
39
- static validate(multiLineString) {
40
- if (multiLineString.type !== 'MultiLineString' || !type_1.isArray(multiLineString.coordinates)) {
51
+ };
52
+ MultiLineString.validate = function (multiLineString) {
53
+ var e_1, _a, e_2, _b;
54
+ if (multiLineString.type !== 'MultiLineString' || !(0, type_1.isArray)(multiLineString.coordinates)) {
41
55
  return false;
42
56
  }
43
- for (let line of multiLineString.coordinates) {
44
- for (let point of line) {
45
- if (!type_1.isNumber(point[0]) || !type_1.isNumber(point[1])) {
46
- return false;
57
+ try {
58
+ for (var _c = __values(multiLineString.coordinates), _d = _c.next(); !_d.done; _d = _c.next()) {
59
+ var line = _d.value;
60
+ try {
61
+ 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()) {
62
+ var point = line_1_1.value;
63
+ if (!(0, type_1.isNumber)(point[0]) || !(0, type_1.isNumber)(point[1])) {
64
+ return false;
65
+ }
66
+ }
47
67
  }
68
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
69
+ finally {
70
+ try {
71
+ if (line_1_1 && !line_1_1.done && (_b = line_1.return)) _b.call(line_1);
72
+ }
73
+ finally { if (e_2) throw e_2.error; }
74
+ }
75
+ }
76
+ }
77
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
78
+ finally {
79
+ try {
80
+ if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
48
81
  }
82
+ finally { if (e_1) throw e_1.error; }
49
83
  }
50
84
  return true;
51
- }
52
- get _internalType() {
53
- return symbol_1.SYMBOL_GEO_MULTI_LINE_STRING;
54
- }
55
- }
85
+ };
86
+ Object.defineProperty(MultiLineString.prototype, "_internalType", {
87
+ get: function () {
88
+ return symbol_1.SYMBOL_GEO_MULTI_LINE_STRING;
89
+ },
90
+ enumerable: false,
91
+ configurable: true
92
+ });
93
+ return MultiLineString;
94
+ }());
56
95
  exports.MultiLineString = MultiLineString;
@@ -14,5 +14,5 @@ export declare class MultiPoint {
14
14
  coordinates: number[][];
15
15
  };
16
16
  static validate(multiPoint: ISerializedMultiPoint): boolean;
17
- readonly _internalType: import("../utils/symbol").InternalSymbol;
17
+ get _internalType(): import("../utils/symbol").InternalSymbol;
18
18
  }
@@ -1,50 +1,79 @@
1
1
  "use strict";
2
+ var __values = (this && this.__values) || function(o) {
3
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
4
+ if (m) return m.call(o);
5
+ if (o && typeof o.length === "number") return {
6
+ next: function () {
7
+ if (o && i >= o.length) o = void 0;
8
+ return { value: o && o[i++], done: !o };
9
+ }
10
+ };
11
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
12
+ };
2
13
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const symbol_1 = require("../helper/symbol");
4
- const point_1 = require("./point");
5
- const type_1 = require("../utils/type");
6
- class MultiPoint {
7
- constructor(points) {
8
- if (!type_1.isArray(points)) {
9
- throw new TypeError(`"points" must be of type Point[]. Received type ${typeof points}`);
14
+ exports.MultiPoint = void 0;
15
+ var symbol_1 = require("../helper/symbol");
16
+ var point_1 = require("./point");
17
+ var type_1 = require("../utils/type");
18
+ var MultiPoint = (function () {
19
+ function MultiPoint(points) {
20
+ if (!(0, type_1.isArray)(points)) {
21
+ throw new TypeError("\"points\" must be of type Point[]. Received type ".concat(typeof points));
10
22
  }
11
23
  if (points.length === 0) {
12
24
  throw new Error('"points" must contain 1 point at least');
13
25
  }
14
- points.forEach(point => {
26
+ points.forEach(function (point) {
15
27
  if (!(point instanceof point_1.Point)) {
16
- throw new TypeError(`"points" must be of type Point[]. Received type ${typeof point}[]`);
28
+ throw new TypeError("\"points\" must be of type Point[]. Received type ".concat(typeof point, "[]"));
17
29
  }
18
30
  });
19
31
  this.points = points;
20
32
  }
21
- parse(key) {
22
- return {
23
- [key]: {
33
+ MultiPoint.prototype.parse = function (key) {
34
+ var _a;
35
+ return _a = {},
36
+ _a[key] = {
24
37
  type: 'MultiPoint',
25
- coordinates: this.points.map(point => point.toJSON().coordinates)
26
- }
27
- };
28
- }
29
- toJSON() {
38
+ coordinates: this.points.map(function (point) { return point.toJSON().coordinates; })
39
+ },
40
+ _a;
41
+ };
42
+ MultiPoint.prototype.toJSON = function () {
30
43
  return {
31
44
  type: 'MultiPoint',
32
- coordinates: this.points.map(point => point.toJSON().coordinates)
45
+ coordinates: this.points.map(function (point) { return point.toJSON().coordinates; })
33
46
  };
34
- }
35
- static validate(multiPoint) {
36
- if (multiPoint.type !== 'MultiPoint' || !type_1.isArray(multiPoint.coordinates)) {
47
+ };
48
+ MultiPoint.validate = function (multiPoint) {
49
+ var e_1, _a;
50
+ if (multiPoint.type !== 'MultiPoint' || !(0, type_1.isArray)(multiPoint.coordinates)) {
37
51
  return false;
38
52
  }
39
- for (let point of multiPoint.coordinates) {
40
- if (!type_1.isNumber(point[0]) || !type_1.isNumber(point[1])) {
41
- return false;
53
+ try {
54
+ for (var _b = __values(multiPoint.coordinates), _c = _b.next(); !_c.done; _c = _b.next()) {
55
+ var point = _c.value;
56
+ if (!(0, type_1.isNumber)(point[0]) || !(0, type_1.isNumber)(point[1])) {
57
+ return false;
58
+ }
59
+ }
60
+ }
61
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
62
+ finally {
63
+ try {
64
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
42
65
  }
66
+ finally { if (e_1) throw e_1.error; }
43
67
  }
44
68
  return true;
45
- }
46
- get _internalType() {
47
- return symbol_1.SYMBOL_GEO_MULTI_POINT;
48
- }
49
- }
69
+ };
70
+ Object.defineProperty(MultiPoint.prototype, "_internalType", {
71
+ get: function () {
72
+ return symbol_1.SYMBOL_GEO_MULTI_POINT;
73
+ },
74
+ enumerable: false,
75
+ configurable: true
76
+ });
77
+ return MultiPoint;
78
+ }());
50
79
  exports.MultiPoint = MultiPoint;
@@ -14,5 +14,5 @@ export declare class MultiPolygon {
14
14
  coordinates: number[][][][];
15
15
  };
16
16
  static validate(multiPolygon: ISerializedMultiPolygon): boolean;
17
- readonly _internalType: import("../utils/symbol").InternalSymbol;
17
+ get _internalType(): import("../utils/symbol").InternalSymbol;
18
18
  }
@@ -1,62 +1,122 @@
1
1
  "use strict";
2
+ var __values = (this && this.__values) || function(o) {
3
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
4
+ if (m) return m.call(o);
5
+ if (o && typeof o.length === "number") return {
6
+ next: function () {
7
+ if (o && i >= o.length) o = void 0;
8
+ return { value: o && o[i++], done: !o };
9
+ }
10
+ };
11
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
12
+ };
2
13
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const symbol_1 = require("../helper/symbol");
4
- const type_1 = require("../utils/type");
5
- const polygon_1 = require("./polygon");
6
- class MultiPolygon {
7
- constructor(polygons) {
8
- if (!type_1.isArray(polygons)) {
9
- throw new TypeError(`"polygons" must be of type Polygon[]. Received type ${typeof polygons}`);
14
+ exports.MultiPolygon = void 0;
15
+ var symbol_1 = require("../helper/symbol");
16
+ var type_1 = require("../utils/type");
17
+ var polygon_1 = require("./polygon");
18
+ var MultiPolygon = (function () {
19
+ function MultiPolygon(polygons) {
20
+ var e_1, _a;
21
+ if (!(0, type_1.isArray)(polygons)) {
22
+ throw new TypeError("\"polygons\" must be of type Polygon[]. Received type ".concat(typeof polygons));
10
23
  }
11
24
  if (polygons.length === 0) {
12
25
  throw new Error('MultiPolygon must contain 1 polygon at least');
13
26
  }
14
- for (let polygon of polygons) {
15
- if (!(polygon instanceof polygon_1.Polygon)) {
16
- throw new TypeError(`"polygon" must be of type Polygon[]. Received type ${typeof polygon}[]`);
27
+ try {
28
+ for (var polygons_1 = __values(polygons), polygons_1_1 = polygons_1.next(); !polygons_1_1.done; polygons_1_1 = polygons_1.next()) {
29
+ var polygon = polygons_1_1.value;
30
+ if (!(polygon instanceof polygon_1.Polygon)) {
31
+ throw new TypeError("\"polygon\" must be of type Polygon[]. Received type ".concat(typeof polygon, "[]"));
32
+ }
33
+ }
34
+ }
35
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
36
+ finally {
37
+ try {
38
+ if (polygons_1_1 && !polygons_1_1.done && (_a = polygons_1.return)) _a.call(polygons_1);
17
39
  }
40
+ finally { if (e_1) throw e_1.error; }
18
41
  }
19
42
  this.polygons = polygons;
20
43
  }
21
- parse(key) {
22
- return {
23
- [key]: {
44
+ MultiPolygon.prototype.parse = function (key) {
45
+ var _a;
46
+ return _a = {},
47
+ _a[key] = {
24
48
  type: 'MultiPolygon',
25
- coordinates: this.polygons.map(polygon => {
26
- return polygon.lines.map(line => {
27
- return line.points.map(point => [point.longitude, point.latitude]);
49
+ coordinates: this.polygons.map(function (polygon) {
50
+ return polygon.lines.map(function (line) {
51
+ return line.points.map(function (point) { return [point.longitude, point.latitude]; });
28
52
  });
29
53
  })
30
- }
31
- };
32
- }
33
- toJSON() {
54
+ },
55
+ _a;
56
+ };
57
+ MultiPolygon.prototype.toJSON = function () {
34
58
  return {
35
59
  type: 'MultiPolygon',
36
- coordinates: this.polygons.map(polygon => {
37
- return polygon.lines.map(line => {
38
- return line.points.map(point => [point.longitude, point.latitude]);
60
+ coordinates: this.polygons.map(function (polygon) {
61
+ return polygon.lines.map(function (line) {
62
+ return line.points.map(function (point) { return [point.longitude, point.latitude]; });
39
63
  });
40
64
  })
41
65
  };
42
- }
43
- static validate(multiPolygon) {
44
- if (multiPolygon.type !== 'MultiPolygon' || !type_1.isArray(multiPolygon.coordinates)) {
66
+ };
67
+ MultiPolygon.validate = function (multiPolygon) {
68
+ var e_2, _a, e_3, _b, e_4, _c;
69
+ if (multiPolygon.type !== 'MultiPolygon' || !(0, type_1.isArray)(multiPolygon.coordinates)) {
45
70
  return false;
46
71
  }
47
- for (let polygon of multiPolygon.coordinates) {
48
- for (let line of polygon) {
49
- for (let point of line) {
50
- if (!type_1.isNumber(point[0]) || !type_1.isNumber(point[1])) {
51
- return false;
72
+ try {
73
+ for (var _d = __values(multiPolygon.coordinates), _e = _d.next(); !_e.done; _e = _d.next()) {
74
+ var polygon = _e.value;
75
+ try {
76
+ for (var polygon_2 = (e_3 = void 0, __values(polygon)), polygon_2_1 = polygon_2.next(); !polygon_2_1.done; polygon_2_1 = polygon_2.next()) {
77
+ var line = polygon_2_1.value;
78
+ try {
79
+ 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()) {
80
+ var point = line_1_1.value;
81
+ if (!(0, type_1.isNumber)(point[0]) || !(0, type_1.isNumber)(point[1])) {
82
+ return false;
83
+ }
84
+ }
85
+ }
86
+ catch (e_4_1) { e_4 = { error: e_4_1 }; }
87
+ finally {
88
+ try {
89
+ if (line_1_1 && !line_1_1.done && (_c = line_1.return)) _c.call(line_1);
90
+ }
91
+ finally { if (e_4) throw e_4.error; }
92
+ }
93
+ }
94
+ }
95
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
96
+ finally {
97
+ try {
98
+ if (polygon_2_1 && !polygon_2_1.done && (_b = polygon_2.return)) _b.call(polygon_2);
52
99
  }
100
+ finally { if (e_3) throw e_3.error; }
53
101
  }
54
102
  }
55
103
  }
104
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
105
+ finally {
106
+ try {
107
+ if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
108
+ }
109
+ finally { if (e_2) throw e_2.error; }
110
+ }
56
111
  return true;
57
- }
58
- get _internalType() {
59
- return symbol_1.SYMBOL_GEO_MULTI_POLYGON;
60
- }
61
- }
112
+ };
113
+ Object.defineProperty(MultiPolygon.prototype, "_internalType", {
114
+ get: function () {
115
+ return symbol_1.SYMBOL_GEO_MULTI_POLYGON;
116
+ },
117
+ enumerable: false,
118
+ configurable: true
119
+ });
120
+ return MultiPolygon;
121
+ }());
62
122
  exports.MultiPolygon = MultiPolygon;
@@ -15,5 +15,5 @@ export declare class Point {
15
15
  };
16
16
  toReadableString(): string;
17
17
  static validate(point: ISerializedPoint): boolean;
18
- readonly _internalType: import("../utils/symbol").InternalSymbol;
18
+ get _internalType(): import("../utils/symbol").InternalSymbol;
19
19
  }
@@ -1,24 +1,26 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const validate_1 = require("../validate");
4
- const symbol_1 = require("../helper/symbol");
5
- const type_1 = require("../utils/type");
6
- class Point {
7
- constructor(longitude, latitude) {
3
+ exports.Point = void 0;
4
+ var validate_1 = require("../validate");
5
+ var symbol_1 = require("../helper/symbol");
6
+ var type_1 = require("../utils/type");
7
+ var Point = (function () {
8
+ function Point(longitude, latitude) {
8
9
  validate_1.Validate.isGeopoint('longitude', longitude);
9
10
  validate_1.Validate.isGeopoint('latitude', latitude);
10
11
  this.longitude = longitude;
11
12
  this.latitude = latitude;
12
13
  }
13
- parse(key) {
14
- return {
15
- [key]: {
14
+ Point.prototype.parse = function (key) {
15
+ var _a;
16
+ return _a = {},
17
+ _a[key] = {
16
18
  type: 'Point',
17
19
  coordinates: [this.longitude, this.latitude]
18
- }
19
- };
20
- }
21
- toJSON() {
20
+ },
21
+ _a;
22
+ };
23
+ Point.prototype.toJSON = function () {
22
24
  return {
23
25
  type: 'Point',
24
26
  coordinates: [
@@ -26,18 +28,23 @@ class Point {
26
28
  this.latitude,
27
29
  ],
28
30
  };
29
- }
30
- toReadableString() {
31
- return `[${this.longitude},${this.latitude}]`;
32
- }
33
- static validate(point) {
31
+ };
32
+ Point.prototype.toReadableString = function () {
33
+ return "[".concat(this.longitude, ",").concat(this.latitude, "]");
34
+ };
35
+ Point.validate = function (point) {
34
36
  return point.type === 'Point' &&
35
- type_1.isArray(point.coordinates) &&
37
+ (0, type_1.isArray)(point.coordinates) &&
36
38
  validate_1.Validate.isGeopoint('longitude', point.coordinates[0]) &&
37
39
  validate_1.Validate.isGeopoint('latitude', point.coordinates[1]);
38
- }
39
- get _internalType() {
40
- return symbol_1.SYMBOL_GEO_POINT;
41
- }
42
- }
40
+ };
41
+ Object.defineProperty(Point.prototype, "_internalType", {
42
+ get: function () {
43
+ return symbol_1.SYMBOL_GEO_POINT;
44
+ },
45
+ enumerable: false,
46
+ configurable: true
47
+ });
48
+ return Point;
49
+ }());
43
50
  exports.Point = 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
- readonly _internalType: import("../utils/symbol").InternalSymbol;
18
+ get _internalType(): import("../utils/symbol").InternalSymbol;
19
19
  }