@cloudbase/database 1.4.3-alpha.0 → 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 (194) 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.js +4 -3
  35. package/dist/commonjs/operator-map.js +7 -6
  36. package/dist/commonjs/query.d.ts +8 -4
  37. package/dist/commonjs/query.js +308 -201
  38. package/dist/commonjs/regexp/index.d.ts +1 -1
  39. package/dist/commonjs/regexp/index.js +16 -9
  40. package/dist/commonjs/serializer/common.d.ts +2 -2
  41. package/dist/commonjs/serializer/common.js +59 -22
  42. package/dist/commonjs/serializer/datatype.d.ts +2 -2
  43. package/dist/commonjs/serializer/datatype.js +58 -21
  44. package/dist/commonjs/serializer/query.d.ts +1 -1
  45. package/dist/commonjs/serializer/query.js +137 -127
  46. package/dist/commonjs/serializer/update.d.ts +1 -1
  47. package/dist/commonjs/serializer/update.js +83 -78
  48. package/dist/commonjs/serverDate/index.d.ts +1 -1
  49. package/dist/commonjs/serverDate/index.js +16 -9
  50. package/dist/commonjs/transaction/collection.d.ts +1 -1
  51. package/dist/commonjs/transaction/collection.js +5 -2
  52. package/dist/commonjs/transaction/document.d.ts +1 -1
  53. package/dist/commonjs/transaction/document.js +5 -5
  54. package/dist/commonjs/transaction/index.js +196 -86
  55. package/dist/commonjs/transaction/query.d.ts +39 -1
  56. package/dist/commonjs/transaction/query.js +252 -1
  57. package/dist/commonjs/typings/index.d.ts +4 -4
  58. package/dist/commonjs/typings/realtime.d.ts +16 -16
  59. package/dist/commonjs/util.js +123 -92
  60. package/dist/commonjs/utils/error.d.ts +2 -1
  61. package/dist/commonjs/utils/error.js +74 -38
  62. package/dist/commonjs/utils/symbol.js +33 -14
  63. package/dist/commonjs/utils/type.d.ts +1 -1
  64. package/dist/commonjs/utils/type.js +25 -13
  65. package/dist/commonjs/utils/utils.d.ts +4 -1
  66. package/dist/commonjs/utils/utils.js +93 -22
  67. package/dist/commonjs/validate.js +79 -63
  68. package/dist/esm/ObjectId/index.d.ts +1 -1
  69. package/dist/esm/ObjectId/index.js +15 -8
  70. package/dist/esm/aggregate.js +118 -66
  71. package/dist/esm/collection.d.ts +3 -2
  72. package/dist/esm/collection.js +125 -52
  73. package/dist/esm/command.d.ts +5 -5
  74. package/dist/esm/command.js +175 -147
  75. package/dist/esm/commands/logic.js +30 -20
  76. package/dist/esm/commands/query.d.ts +1 -1
  77. package/dist/esm/commands/query.js +91 -71
  78. package/dist/esm/commands/update.js +8 -6
  79. package/dist/esm/config/error.config.js +1 -1
  80. package/dist/esm/const/code.js +1 -1
  81. package/dist/esm/constant.d.ts +7 -7
  82. package/dist/esm/constant.js +12 -11
  83. package/dist/esm/document.d.ts +10 -6
  84. package/dist/esm/document.js +297 -185
  85. package/dist/esm/geo/interface.js +1 -0
  86. package/dist/esm/geo/lineString.d.ts +1 -1
  87. package/dist/esm/geo/lineString.js +57 -28
  88. package/dist/esm/geo/multiLineString.d.ts +1 -1
  89. package/dist/esm/geo/multiLineString.js +66 -27
  90. package/dist/esm/geo/multiPoint.d.ts +1 -1
  91. package/dist/esm/geo/multiPoint.js +53 -24
  92. package/dist/esm/geo/multiPolygon.d.ts +1 -1
  93. package/dist/esm/geo/multiPolygon.js +91 -31
  94. package/dist/esm/geo/point.d.ts +1 -1
  95. package/dist/esm/geo/point.js +26 -19
  96. package/dist/esm/geo/polygon.d.ts +1 -1
  97. package/dist/esm/geo/polygon.js +73 -34
  98. package/dist/esm/helper/symbol.js +13 -13
  99. package/dist/esm/index.d.ts +8 -2
  100. package/dist/esm/index.js +62 -9
  101. package/dist/esm/lib/util.js +1 -2
  102. package/dist/esm/operator-map.js +4 -4
  103. package/dist/esm/query.d.ts +8 -4
  104. package/dist/esm/query.js +299 -192
  105. package/dist/esm/regexp/index.d.ts +1 -1
  106. package/dist/esm/regexp/index.js +15 -8
  107. package/dist/esm/serializer/common.d.ts +2 -2
  108. package/dist/esm/serializer/common.js +49 -13
  109. package/dist/esm/serializer/datatype.d.ts +2 -2
  110. package/dist/esm/serializer/datatype.js +44 -8
  111. package/dist/esm/serializer/query.d.ts +1 -1
  112. package/dist/esm/serializer/query.js +112 -102
  113. package/dist/esm/serializer/update.d.ts +1 -1
  114. package/dist/esm/serializer/update.js +69 -64
  115. package/dist/esm/serverDate/index.d.ts +1 -1
  116. package/dist/esm/serverDate/index.js +15 -8
  117. package/dist/esm/transaction/collection.d.ts +1 -1
  118. package/dist/esm/transaction/collection.js +4 -2
  119. package/dist/esm/transaction/document.d.ts +1 -1
  120. package/dist/esm/transaction/document.js +2 -3
  121. package/dist/esm/transaction/index.js +191 -81
  122. package/dist/esm/transaction/query.d.ts +39 -1
  123. package/dist/esm/transaction/query.js +251 -1
  124. package/dist/esm/typings/index.d.ts +4 -4
  125. package/dist/esm/typings/index.js +1 -0
  126. package/dist/esm/typings/realtime.d.ts +16 -16
  127. package/dist/esm/typings/realtime.js +1 -0
  128. package/dist/esm/util.js +121 -90
  129. package/dist/esm/utils/error.d.ts +2 -1
  130. package/dist/esm/utils/error.js +70 -35
  131. package/dist/esm/utils/symbol.js +33 -14
  132. package/dist/esm/utils/type.d.ts +1 -1
  133. package/dist/esm/utils/type.js +12 -12
  134. package/dist/esm/utils/utils.d.ts +4 -1
  135. package/dist/esm/utils/utils.js +78 -16
  136. package/dist/esm/validate.js +65 -49
  137. package/jest.config.js +14 -0
  138. package/package.json +14 -10
  139. package/src/aggregate.ts +1 -5
  140. package/src/collection.ts +15 -2
  141. package/src/document.ts +45 -34
  142. package/src/index.ts +51 -4
  143. package/src/query.ts +33 -29
  144. package/src/serializer/query.ts +18 -6
  145. package/src/transaction/index.ts +1 -1
  146. package/src/typings/index.ts +0 -4
  147. package/src/utils/utils.ts +46 -0
  148. package/src/validate.ts +3 -6
  149. package/tests/gateway-contract.test.ts +180 -0
  150. package/tests/index.test.ts +283 -0
  151. package/tests/transaction-query.test.ts +207 -0
  152. package/tsconfig.esm.json +4 -2
  153. package/tsconfig.json +16 -6
  154. package/tsconfig.test.json +15 -0
  155. package/dist/commonjs/realtime/error.d.ts +0 -7
  156. package/dist/commonjs/realtime/error.js +0 -11
  157. package/dist/commonjs/realtime/listener.d.ts +0 -14
  158. package/dist/commonjs/realtime/listener.js +0 -17
  159. package/dist/commonjs/realtime/message.d.ts +0 -3
  160. package/dist/commonjs/realtime/message.js +0 -10
  161. package/dist/commonjs/realtime/snapshot.d.ts +0 -16
  162. package/dist/commonjs/realtime/snapshot.js +0 -42
  163. package/dist/commonjs/realtime/virtual-websocket-client.d.ts +0 -63
  164. package/dist/commonjs/realtime/virtual-websocket-client.js +0 -736
  165. package/dist/commonjs/realtime/websocket-client.d.ts +0 -78
  166. package/dist/commonjs/realtime/websocket-client.js +0 -567
  167. package/dist/commonjs/realtime/ws-event.d.ts +0 -126
  168. package/dist/commonjs/realtime/ws-event.js +0 -139
  169. package/dist/commonjs/transaction.d.ts +0 -42
  170. package/dist/commonjs/transaction.js +0 -126
  171. package/dist/esm/realtime/error.d.ts +0 -7
  172. package/dist/esm/realtime/error.js +0 -8
  173. package/dist/esm/realtime/listener.d.ts +0 -14
  174. package/dist/esm/realtime/listener.js +0 -14
  175. package/dist/esm/realtime/message.d.ts +0 -3
  176. package/dist/esm/realtime/message.js +0 -6
  177. package/dist/esm/realtime/snapshot.d.ts +0 -16
  178. package/dist/esm/realtime/snapshot.js +0 -39
  179. package/dist/esm/realtime/virtual-websocket-client.d.ts +0 -63
  180. package/dist/esm/realtime/virtual-websocket-client.js +0 -733
  181. package/dist/esm/realtime/websocket-client.d.ts +0 -78
  182. package/dist/esm/realtime/websocket-client.js +0 -564
  183. package/dist/esm/realtime/ws-event.d.ts +0 -126
  184. package/dist/esm/realtime/ws-event.js +0 -137
  185. package/dist/esm/transaction.d.ts +0 -42
  186. package/dist/esm/transaction.js +0 -121
  187. package/src/realtime/error.ts +0 -19
  188. package/src/realtime/listener.ts +0 -35
  189. package/src/realtime/message.ts +0 -14
  190. package/src/realtime/snapshot.ts +0 -60
  191. package/src/realtime/virtual-websocket-client.ts +0 -1195
  192. package/src/realtime/websocket-client.ts +0 -995
  193. package/src/realtime/ws-event.ts +0 -163
  194. 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
- export class MultiLineString {
5
- constructor(lines) {
15
+ var MultiLineString = (function () {
16
+ function MultiLineString(lines) {
6
17
  if (!isArray(lines)) {
7
- throw new TypeError(`"lines" must be of type LineString[]. Received type ${typeof lines}`);
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(`"lines" must be of type LineString[]. Received type ${typeof line}[]`);
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
- return {
21
- [key]: {
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 => [point.longitude, point.latitude]);
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 => [point.longitude, point.latitude]);
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
- static validate(multiLineString) {
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
- for (let line of multiLineString.coordinates) {
42
- for (let point of line) {
43
- if (!isNumber(point[0]) || !isNumber(point[1])) {
44
- return false;
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
- get _internalType() {
51
- return SYMBOL_GEO_MULTI_LINE_STRING;
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
- readonly _internalType: import("../utils/symbol").InternalSymbol;
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
- export class MultiPoint {
5
- constructor(points) {
15
+ var MultiPoint = (function () {
16
+ function MultiPoint(points) {
6
17
  if (!isArray(points)) {
7
- throw new TypeError(`"points" must be of type Point[]. Received type ${typeof points}`);
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(`"points" must be of type Point[]. Received type ${typeof point}[]`);
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
- return {
21
- [key]: {
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 => point.toJSON().coordinates)
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 => point.toJSON().coordinates)
42
+ coordinates: this.points.map(function (point) { return point.toJSON().coordinates; })
31
43
  };
32
- }
33
- static validate(multiPoint) {
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
- for (let point of multiPoint.coordinates) {
38
- if (!isNumber(point[0]) || !isNumber(point[1])) {
39
- return false;
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
- get _internalType() {
45
- return SYMBOL_GEO_MULTI_POINT;
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
- readonly _internalType: import("../utils/symbol").InternalSymbol;
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
- export class MultiPolygon {
5
- constructor(polygons) {
15
+ var MultiPolygon = (function () {
16
+ function MultiPolygon(polygons) {
17
+ var e_1, _a;
6
18
  if (!isArray(polygons)) {
7
- throw new TypeError(`"polygons" must be of type Polygon[]. Received type ${typeof polygons}`);
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
- for (let polygon of polygons) {
13
- if (!(polygon instanceof Polygon)) {
14
- throw new TypeError(`"polygon" must be of type Polygon[]. Received type ${typeof polygon}[]`);
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
- return {
21
- [key]: {
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 => [point.longitude, point.latitude]);
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 => [point.longitude, point.latitude]);
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
- static validate(multiPolygon) {
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
- for (let polygon of multiPolygon.coordinates) {
46
- for (let line of polygon) {
47
- for (let point of line) {
48
- if (!isNumber(point[0]) || !isNumber(point[1])) {
49
- return false;
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
- get _internalType() {
57
- return SYMBOL_GEO_MULTI_POLYGON;
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 };
@@ -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,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
- export class Point {
5
- constructor(longitude, latitude) {
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
- return {
13
- [key]: {
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 `[${this.longitude},${this.latitude}]`;
30
- }
31
- static validate(point) {
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
- get _internalType() {
38
- return SYMBOL_GEO_POINT;
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
- readonly _internalType: import("../utils/symbol").InternalSymbol;
18
+ get _internalType(): import("../utils/symbol").InternalSymbol;
19
19
  }
@@ -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
- export class Polygon {
5
- constructor(lines) {
15
+ var Polygon = (function () {
16
+ function Polygon(lines) {
6
17
  if (!isArray(lines)) {
7
- throw new TypeError(`"lines" must be of type LineString[]. Received type ${typeof lines}`);
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(`"lines" must be of type LineString[]. Received type ${typeof line}[]`);
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(`LineString ${line.points.map(p => p.toReadableString())} is not a closed cycle`);
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
- return {
24
- [key]: {
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 => [point.longitude, point.latitude]);
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 => [point.longitude, point.latitude]);
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
- static validate(polygon) {
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
- for (let line of polygon.coordinates) {
45
- if (!this.isCloseLineString(line)) {
46
- return false;
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
- static isCloseLineString(lineString) {
57
- const firstPoint = lineString[0];
58
- const lastPoint = lineString[lineString.length - 1];
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
- get _internalType() {
65
- return SYMBOL_GEO_POLYGON;
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 const SYMBOL_UNSET_FIELD_NAME = InternalSymbol.for('UNSET_FIELD_NAME');
4
- export const SYMBOL_UPDATE_COMMAND = InternalSymbol.for('UPDATE_COMMAND');
5
- export const SYMBOL_QUERY_COMMAND = InternalSymbol.for('QUERY_COMMAND');
6
- export const SYMBOL_LOGIC_COMMAND = InternalSymbol.for('LOGIC_COMMAND');
7
- export const SYMBOL_GEO_POINT = InternalSymbol.for('GEO_POINT');
8
- export const SYMBOL_GEO_LINE_STRING = InternalSymbol.for('SYMBOL_GEO_LINE_STRING');
9
- export const SYMBOL_GEO_POLYGON = InternalSymbol.for('SYMBOL_GEO_POLYGON');
10
- export const SYMBOL_GEO_MULTI_POINT = InternalSymbol.for('SYMBOL_GEO_MULTI_POINT');
11
- export const SYMBOL_GEO_MULTI_LINE_STRING = InternalSymbol.for('SYMBOL_GEO_MULTI_LINE_STRING');
12
- export const SYMBOL_GEO_MULTI_POLYGON = InternalSymbol.for('SYMBOL_GEO_MULTI_POLYGON');
13
- export const SYMBOL_SERVER_DATE = InternalSymbol.for('SERVER_DATE');
14
- export const SYMBOL_REGEXP = InternalSymbol.for('REGEXP');
15
- export const SYMBOL_OBJECTID = InternalSymbol.for('OBJECTID');
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');