@cloudbase/js-sdk 3.6.7 → 3.6.8-beta.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 (201) hide show
  1. package/app/dist/index.esm.js +1 -1
  2. package/app/dist/index.esm.js.map +1 -1
  3. package/app/dist/index.js +1 -1
  4. package/app/dist/index.js.map +1 -1
  5. package/app/dist/index.node.esm.js +1 -1
  6. package/app/dist/index.node.esm.js.map +1 -1
  7. package/app/dist/index.node.js +1 -1
  8. package/app/dist/index.node.js.map +1 -1
  9. package/auth/dist/index.esm.js.map +1 -1
  10. package/auth/dist/index.js.map +1 -1
  11. package/database/dist/index.d.ts +3 -0
  12. package/database/dist/index.esm.js +2 -0
  13. package/database/dist/index.esm.js.map +1 -0
  14. package/database/dist/index.js +2 -0
  15. package/database/dist/index.js.map +1 -0
  16. package/dist/index.cjs.js +1 -1
  17. package/dist/index.cjs.js.map +1 -1
  18. package/dist/index.esm.js +1 -1
  19. package/dist/index.esm.js.map +1 -1
  20. package/dist/index.node.cjs.js +1 -1
  21. package/dist/index.node.cjs.js.map +1 -1
  22. package/dist/index.node.esm.js +1 -1
  23. package/dist/index.node.esm.js.map +1 -1
  24. package/miniprogram_dist/index.js +1 -1
  25. package/oauth/dist/index.esm.js.map +1 -1
  26. package/oauth/dist/index.js.map +1 -1
  27. package/package.json +2 -2
  28. package/types/package.json +1 -1
  29. package/utilities/package.json +2 -2
  30. package/database/dist/commonjs/aggregate.d.ts +0 -29
  31. package/database/dist/commonjs/aggregate.js +0 -156
  32. package/database/dist/commonjs/collection.d.ts +0 -9
  33. package/database/dist/commonjs/collection.js +0 -49
  34. package/database/dist/commonjs/command.d.ts +0 -175
  35. package/database/dist/commonjs/command.js +0 -299
  36. package/database/dist/commonjs/commands/logic.d.ts +0 -24
  37. package/database/dist/commonjs/commands/logic.js +0 -89
  38. package/database/dist/commonjs/commands/query.d.ts +0 -68
  39. package/database/dist/commonjs/commands/query.js +0 -160
  40. package/database/dist/commonjs/commands/update.d.ts +0 -29
  41. package/database/dist/commonjs/commands/update.js +0 -51
  42. package/database/dist/commonjs/config/app.config.d.ts +0 -6
  43. package/database/dist/commonjs/config/app.config.js +0 -7
  44. package/database/dist/commonjs/config/error.config.d.ts +0 -3
  45. package/database/dist/commonjs/config/error.config.js +0 -16
  46. package/database/dist/commonjs/const/code.d.ts +0 -30
  47. package/database/dist/commonjs/const/code.js +0 -33
  48. package/database/dist/commonjs/constant.d.ts +0 -51
  49. package/database/dist/commonjs/constant.js +0 -75
  50. package/database/dist/commonjs/document.d.ts +0 -11
  51. package/database/dist/commonjs/document.js +0 -260
  52. package/database/dist/commonjs/geo/index.d.ts +0 -6
  53. package/database/dist/commonjs/geo/index.js +0 -22
  54. package/database/dist/commonjs/geo/interface.d.ts +0 -24
  55. package/database/dist/commonjs/geo/interface.js +0 -2
  56. package/database/dist/commonjs/geo/lineString.d.ts +0 -19
  57. package/database/dist/commonjs/geo/lineString.js +0 -86
  58. package/database/dist/commonjs/geo/multiLineString.d.ts +0 -18
  59. package/database/dist/commonjs/geo/multiLineString.js +0 -95
  60. package/database/dist/commonjs/geo/multiPoint.d.ts +0 -18
  61. package/database/dist/commonjs/geo/multiPoint.js +0 -79
  62. package/database/dist/commonjs/geo/multiPolygon.d.ts +0 -18
  63. package/database/dist/commonjs/geo/multiPolygon.js +0 -122
  64. package/database/dist/commonjs/geo/point.d.ts +0 -19
  65. package/database/dist/commonjs/geo/point.js +0 -50
  66. package/database/dist/commonjs/geo/polygon.d.ts +0 -19
  67. package/database/dist/commonjs/geo/polygon.js +0 -109
  68. package/database/dist/commonjs/helper/symbol.d.ts +0 -14
  69. package/database/dist/commonjs/helper/symbol.js +0 -31
  70. package/database/dist/commonjs/index.d.ts +0 -40
  71. package/database/dist/commonjs/index.js +0 -61
  72. package/database/dist/commonjs/lib/util.d.ts +0 -1
  73. package/database/dist/commonjs/lib/util.js +0 -26
  74. package/database/dist/commonjs/operator-map.d.ts +0 -4
  75. package/database/dist/commonjs/operator-map.js +0 -24
  76. package/database/dist/commonjs/query.d.ts +0 -22
  77. package/database/dist/commonjs/query.js +0 -252
  78. package/database/dist/commonjs/regexp/index.d.ts +0 -14
  79. package/database/dist/commonjs/regexp/index.js +0 -33
  80. package/database/dist/commonjs/serializer/common.d.ts +0 -11
  81. package/database/dist/commonjs/serializer/common.js +0 -127
  82. package/database/dist/commonjs/serializer/datatype.d.ts +0 -7
  83. package/database/dist/commonjs/serializer/datatype.js +0 -132
  84. package/database/dist/commonjs/serializer/query.d.ts +0 -7
  85. package/database/dist/commonjs/serializer/query.js +0 -232
  86. package/database/dist/commonjs/serializer/update.d.ts +0 -15
  87. package/database/dist/commonjs/serializer/update.js +0 -142
  88. package/database/dist/commonjs/serverDate/index.d.ts +0 -13
  89. package/database/dist/commonjs/serverDate/index.js +0 -30
  90. package/database/dist/commonjs/transaction/collection.d.ts +0 -7
  91. package/database/dist/commonjs/transaction/collection.js +0 -49
  92. package/database/dist/commonjs/transaction/document.d.ts +0 -27
  93. package/database/dist/commonjs/transaction/document.js +0 -205
  94. package/database/dist/commonjs/transaction/index.d.ts +0 -30
  95. package/database/dist/commonjs/transaction/index.js +0 -215
  96. package/database/dist/commonjs/transaction/query.d.ts +0 -43
  97. package/database/dist/commonjs/transaction/query.js +0 -261
  98. package/database/dist/commonjs/typings/index.d.ts +0 -40
  99. package/database/dist/commonjs/typings/index.js +0 -2
  100. package/database/dist/commonjs/typings/realtime.d.ts +0 -219
  101. package/database/dist/commonjs/typings/realtime.js +0 -2
  102. package/database/dist/commonjs/util.d.ts +0 -9
  103. package/database/dist/commonjs/util.js +0 -145
  104. package/database/dist/commonjs/utils/error.d.ts +0 -38
  105. package/database/dist/commonjs/utils/error.js +0 -91
  106. package/database/dist/commonjs/utils/msg.d.ts +0 -0
  107. package/database/dist/commonjs/utils/msg.js +0 -0
  108. package/database/dist/commonjs/utils/symbol.d.ts +0 -8
  109. package/database/dist/commonjs/utils/symbol.js +0 -58
  110. package/database/dist/commonjs/utils/type.d.ts +0 -13
  111. package/database/dist/commonjs/utils/type.js +0 -34
  112. package/database/dist/commonjs/utils/utils.d.ts +0 -4
  113. package/database/dist/commonjs/utils/utils.js +0 -39
  114. package/database/dist/commonjs/validate.d.ts +0 -1
  115. package/database/dist/commonjs/validate.js +0 -60
  116. package/database/dist/esm/aggregate.d.ts +0 -29
  117. package/database/dist/esm/aggregate.js +0 -154
  118. package/database/dist/esm/collection.d.ts +0 -9
  119. package/database/dist/esm/collection.js +0 -46
  120. package/database/dist/esm/command.d.ts +0 -175
  121. package/database/dist/esm/command.js +0 -296
  122. package/database/dist/esm/commands/logic.d.ts +0 -24
  123. package/database/dist/esm/commands/logic.js +0 -84
  124. package/database/dist/esm/commands/query.d.ts +0 -68
  125. package/database/dist/esm/commands/query.js +0 -154
  126. package/database/dist/esm/commands/update.d.ts +0 -29
  127. package/database/dist/esm/commands/update.js +0 -46
  128. package/database/dist/esm/config/app.config.d.ts +0 -6
  129. package/database/dist/esm/config/app.config.js +0 -5
  130. package/database/dist/esm/config/error.config.d.ts +0 -3
  131. package/database/dist/esm/config/error.config.js +0 -13
  132. package/database/dist/esm/const/code.d.ts +0 -30
  133. package/database/dist/esm/const/code.js +0 -30
  134. package/database/dist/esm/constant.d.ts +0 -51
  135. package/database/dist/esm/constant.js +0 -65
  136. package/database/dist/esm/document.d.ts +0 -11
  137. package/database/dist/esm/document.js +0 -257
  138. package/database/dist/esm/geo/index.d.ts +0 -6
  139. package/database/dist/esm/geo/index.js +0 -6
  140. package/database/dist/esm/geo/interface.d.ts +0 -24
  141. package/database/dist/esm/geo/interface.js +0 -1
  142. package/database/dist/esm/geo/lineString.d.ts +0 -19
  143. package/database/dist/esm/geo/lineString.js +0 -83
  144. package/database/dist/esm/geo/multiLineString.d.ts +0 -18
  145. package/database/dist/esm/geo/multiLineString.js +0 -92
  146. package/database/dist/esm/geo/multiPoint.d.ts +0 -18
  147. package/database/dist/esm/geo/multiPoint.js +0 -76
  148. package/database/dist/esm/geo/multiPolygon.d.ts +0 -18
  149. package/database/dist/esm/geo/multiPolygon.js +0 -119
  150. package/database/dist/esm/geo/point.d.ts +0 -19
  151. package/database/dist/esm/geo/point.js +0 -47
  152. package/database/dist/esm/geo/polygon.d.ts +0 -19
  153. package/database/dist/esm/geo/polygon.js +0 -106
  154. package/database/dist/esm/helper/symbol.d.ts +0 -14
  155. package/database/dist/esm/helper/symbol.js +0 -14
  156. package/database/dist/esm/index.d.ts +0 -40
  157. package/database/dist/esm/index.js +0 -55
  158. package/database/dist/esm/lib/util.d.ts +0 -1
  159. package/database/dist/esm/lib/util.js +0 -22
  160. package/database/dist/esm/operator-map.d.ts +0 -4
  161. package/database/dist/esm/operator-map.js +0 -20
  162. package/database/dist/esm/query.d.ts +0 -22
  163. package/database/dist/esm/query.js +0 -249
  164. package/database/dist/esm/regexp/index.d.ts +0 -14
  165. package/database/dist/esm/regexp/index.js +0 -29
  166. package/database/dist/esm/serializer/common.d.ts +0 -11
  167. package/database/dist/esm/serializer/common.js +0 -118
  168. package/database/dist/esm/serializer/datatype.d.ts +0 -7
  169. package/database/dist/esm/serializer/datatype.js +0 -127
  170. package/database/dist/esm/serializer/query.d.ts +0 -7
  171. package/database/dist/esm/serializer/query.js +0 -229
  172. package/database/dist/esm/serializer/update.d.ts +0 -15
  173. package/database/dist/esm/serializer/update.js +0 -139
  174. package/database/dist/esm/serverDate/index.d.ts +0 -13
  175. package/database/dist/esm/serverDate/index.js +0 -26
  176. package/database/dist/esm/transaction/collection.d.ts +0 -7
  177. package/database/dist/esm/transaction/collection.js +0 -46
  178. package/database/dist/esm/transaction/document.d.ts +0 -27
  179. package/database/dist/esm/transaction/document.js +0 -202
  180. package/database/dist/esm/transaction/index.d.ts +0 -30
  181. package/database/dist/esm/transaction/index.js +0 -210
  182. package/database/dist/esm/transaction/query.d.ts +0 -43
  183. package/database/dist/esm/transaction/query.js +0 -258
  184. package/database/dist/esm/typings/index.d.ts +0 -40
  185. package/database/dist/esm/typings/index.js +0 -1
  186. package/database/dist/esm/typings/realtime.d.ts +0 -219
  187. package/database/dist/esm/typings/realtime.js +0 -1
  188. package/database/dist/esm/util.d.ts +0 -9
  189. package/database/dist/esm/util.js +0 -142
  190. package/database/dist/esm/utils/error.d.ts +0 -38
  191. package/database/dist/esm/utils/error.js +0 -84
  192. package/database/dist/esm/utils/msg.d.ts +0 -0
  193. package/database/dist/esm/utils/msg.js +0 -0
  194. package/database/dist/esm/utils/symbol.d.ts +0 -8
  195. package/database/dist/esm/utils/symbol.js +0 -55
  196. package/database/dist/esm/utils/type.d.ts +0 -13
  197. package/database/dist/esm/utils/type.js +0 -20
  198. package/database/dist/esm/utils/utils.d.ts +0 -4
  199. package/database/dist/esm/utils/utils.js +0 -33
  200. package/database/dist/esm/validate.d.ts +0 -1
  201. package/database/dist/esm/validate.js +0 -57
@@ -1,257 +0,0 @@
1
- var __assign = (this && this.__assign) || function () {
2
- __assign = Object.assign || function(t) {
3
- for (var s, i = 1, n = arguments.length; i < n; i++) {
4
- s = arguments[i];
5
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
- t[p] = s[p];
7
- }
8
- return t;
9
- };
10
- return __assign.apply(this, arguments);
11
- };
12
- import { createPromiseCallback } from './lib/util';
13
- import { Db } from './index';
14
- import { Util } from './util';
15
- import { UpdateSerializer } from './serializer/update';
16
- import { serialize } from './serializer/datatype';
17
- import { UpdateCommand } from './commands/update';
18
- import { QueryType } from './constant';
19
- import { getWsInstance } from './utils/utils';
20
- var DocumentReference = (function () {
21
- function DocumentReference(db, coll, docID, projection) {
22
- if (projection === void 0) { projection = {}; }
23
- var _this = this;
24
- this.watch = function (options) {
25
- var ws = getWsInstance(_this._db);
26
- return ws.watch(__assign(__assign({}, options), { envId: _this._db.config.env, collectionName: _this._coll, query: JSON.stringify({
27
- _id: _this.id
28
- }) }));
29
- };
30
- this._db = db;
31
- this._coll = coll;
32
- this.id = docID;
33
- this.request = Db.createRequest(this._db.config);
34
- this.projection = projection;
35
- }
36
- DocumentReference.prototype.create = function (data, callback) {
37
- callback = callback || createPromiseCallback();
38
- var isBatch = Array.isArray(data);
39
- var params = {
40
- collectionName: this._coll,
41
- data: isBatch ? data.map(function (item) { return serialize(item); }) : serialize(data)
42
- };
43
- if (!isBatch && this.id) {
44
- params['_id'] = this.id;
45
- }
46
- this.request
47
- .send('database.addDocument', params)
48
- .then(function (res) {
49
- var _a;
50
- if (res.code) {
51
- callback(0, res);
52
- }
53
- else {
54
- if (isBatch) {
55
- callback(0, {
56
- ids: ((_a = res.data) === null || _a === void 0 ? void 0 : _a.insertedIds) || [],
57
- requestId: res.requestId
58
- });
59
- }
60
- else {
61
- callback(0, {
62
- id: res.data._id,
63
- requestId: res.requestId
64
- });
65
- }
66
- }
67
- })
68
- .catch(function (err) {
69
- callback(err);
70
- });
71
- return callback.promise;
72
- };
73
- DocumentReference.prototype.set = function (data, callback) {
74
- callback = callback || createPromiseCallback();
75
- if (!this.id) {
76
- return Promise.resolve({
77
- code: 'INVALID_PARAM',
78
- message: 'docId不能为空'
79
- });
80
- }
81
- if (!data || typeof data !== 'object') {
82
- return Promise.resolve({
83
- code: 'INVALID_PARAM',
84
- message: '参数必需是非空对象'
85
- });
86
- }
87
- if (data.hasOwnProperty('_id')) {
88
- return Promise.resolve({
89
- code: 'INVALID_PARAM',
90
- message: '不能更新_id的值'
91
- });
92
- }
93
- var hasOperator = false;
94
- var checkMixed = function (objs) {
95
- if (typeof objs === 'object') {
96
- for (var key in objs) {
97
- if (objs[key] instanceof UpdateCommand) {
98
- hasOperator = true;
99
- }
100
- else if (typeof objs[key] === 'object') {
101
- checkMixed(objs[key]);
102
- }
103
- }
104
- }
105
- };
106
- checkMixed(data);
107
- if (hasOperator) {
108
- return Promise.resolve({
109
- code: 'DATABASE_REQUEST_FAILED',
110
- message: 'update operator complicit'
111
- });
112
- }
113
- var merge = false;
114
- var param = {
115
- collectionName: this._coll,
116
- queryType: QueryType.DOC,
117
- data: serialize(data),
118
- multi: false,
119
- merge: merge,
120
- upsert: true
121
- };
122
- if (this.id) {
123
- param['query'] = { _id: this.id };
124
- }
125
- this.request
126
- .send('database.updateDocument', param)
127
- .then(function (res) {
128
- if (res.code) {
129
- callback(0, res);
130
- }
131
- else {
132
- callback(0, {
133
- updated: res.data.updated,
134
- upsertedId: res.data.upserted_id,
135
- requestId: res.requestId
136
- });
137
- }
138
- })
139
- .catch(function (err) {
140
- callback(err);
141
- });
142
- return callback.promise;
143
- };
144
- DocumentReference.prototype.update = function (data, callback) {
145
- callback = callback || createPromiseCallback();
146
- if (!data || typeof data !== 'object') {
147
- return Promise.resolve({
148
- code: 'INVALID_PARAM',
149
- message: '参数必需是非空对象'
150
- });
151
- }
152
- if (data.hasOwnProperty('_id')) {
153
- return Promise.resolve({
154
- code: 'INVALID_PARAM',
155
- message: '不能更新_id的值'
156
- });
157
- }
158
- var query = { _id: this.id };
159
- var merge = true;
160
- var param = {
161
- collectionName: this._coll,
162
- data: UpdateSerializer.encode(data),
163
- query: query,
164
- queryType: QueryType.DOC,
165
- multi: false,
166
- merge: merge,
167
- upsert: false
168
- };
169
- this.request
170
- .send('database.updateDocument', param)
171
- .then(function (res) {
172
- if (res.code) {
173
- callback(0, res);
174
- }
175
- else {
176
- callback(0, {
177
- updated: res.data.updated,
178
- upsertedId: res.data.upserted_id,
179
- requestId: res.requestId
180
- });
181
- }
182
- })
183
- .catch(function (err) {
184
- callback(err);
185
- });
186
- return callback.promise;
187
- };
188
- DocumentReference.prototype.remove = function (callback) {
189
- callback = callback || createPromiseCallback();
190
- var query = { _id: this.id };
191
- var param = {
192
- collectionName: this._coll,
193
- query: query,
194
- queryType: QueryType.DOC,
195
- multi: false
196
- };
197
- this.request
198
- .send('database.deleteDocument', param)
199
- .then(function (res) {
200
- if (res.code) {
201
- callback(0, res);
202
- }
203
- else {
204
- callback(0, {
205
- deleted: res.data.deleted,
206
- requestId: res.requestId
207
- });
208
- }
209
- })
210
- .catch(function (err) {
211
- callback(err);
212
- });
213
- return callback.promise;
214
- };
215
- DocumentReference.prototype.get = function (callback) {
216
- callback = callback || createPromiseCallback();
217
- var query = { _id: this.id };
218
- var param = {
219
- collectionName: this._coll,
220
- query: query,
221
- queryType: QueryType.DOC,
222
- multi: false,
223
- projection: this.projection
224
- };
225
- this.request
226
- .send('database.queryDocument', param)
227
- .then(function (res) {
228
- if (res.code) {
229
- callback(0, res);
230
- }
231
- else {
232
- var documents = Util.formatResDocumentData(res.data.list);
233
- callback(0, {
234
- data: documents,
235
- requestId: res.requestId
236
- });
237
- }
238
- })
239
- .catch(function (err) {
240
- callback(err);
241
- });
242
- return callback.promise;
243
- };
244
- DocumentReference.prototype.field = function (projection) {
245
- for (var k in projection) {
246
- if (projection[k]) {
247
- projection[k] = 1;
248
- }
249
- else {
250
- projection[k] = 0;
251
- }
252
- }
253
- return new DocumentReference(this._db, this._coll, this.id, projection);
254
- };
255
- return DocumentReference;
256
- }());
257
- export { DocumentReference };
@@ -1,6 +0,0 @@
1
- export * from './point';
2
- export * from './lineString';
3
- export * from './polygon';
4
- export * from './multiPoint';
5
- export * from './multiLineString';
6
- export * from './multiPolygon';
@@ -1,6 +0,0 @@
1
- export * from './point';
2
- export * from './lineString';
3
- export * from './polygon';
4
- export * from './multiPoint';
5
- export * from './multiLineString';
6
- export * from './multiPolygon';
@@ -1,24 +0,0 @@
1
- export interface ISerializedPoint {
2
- type: string;
3
- coordinates: [number, number];
4
- }
5
- export interface ISerializedLineString {
6
- type: string;
7
- coordinates: [number, number][];
8
- }
9
- export interface ISerializedPolygon {
10
- type: string;
11
- coordinates: [number, number][][];
12
- }
13
- export interface ISerializedMultiPoint {
14
- type: string;
15
- coordinates: [number, number][];
16
- }
17
- export interface ISerializedMultiLineString {
18
- type: string;
19
- coordinates: [number, number][][];
20
- }
21
- export interface ISerializedMultiPolygon {
22
- type: string;
23
- coordinates: [number, number][][][];
24
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,19 +0,0 @@
1
- import { Point } from './point';
2
- import { ISerializedLineString } from './interface';
3
- export declare class LineString {
4
- readonly points: Point[];
5
- constructor(points: Point[]);
6
- parse(key: any): {
7
- [x: number]: {
8
- type: string;
9
- coordinates: number[][];
10
- };
11
- };
12
- toJSON(): {
13
- type: string;
14
- coordinates: number[][];
15
- };
16
- static validate(lineString: ISerializedLineString): boolean;
17
- static isClosed(lineString: LineString): boolean;
18
- get _internalType(): import("../utils/symbol").InternalSymbol;
19
- }
@@ -1,83 +0,0 @@
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
- };
12
- import { SYMBOL_GEO_LINE_STRING } from '../helper/symbol';
13
- import { Point } from './point';
14
- import { isArray, isNumber } from '../utils/type';
15
- var LineString = (function () {
16
- function LineString(points) {
17
- if (!isArray(points)) {
18
- throw new TypeError("\"points\" must be of type Point[]. Received type ".concat(typeof points));
19
- }
20
- if (points.length < 2) {
21
- throw new Error('"points" must contain 2 points at least');
22
- }
23
- points.forEach(function (point) {
24
- if (!(point instanceof Point)) {
25
- throw new TypeError("\"points\" must be of type Point[]. Received type ".concat(typeof point, "[]"));
26
- }
27
- });
28
- this.points = points;
29
- }
30
- LineString.prototype.parse = function (key) {
31
- var _a;
32
- return _a = {},
33
- _a[key] = {
34
- type: 'LineString',
35
- coordinates: this.points.map(function (point) { return point.toJSON().coordinates; })
36
- },
37
- _a;
38
- };
39
- LineString.prototype.toJSON = function () {
40
- return {
41
- type: 'LineString',
42
- coordinates: this.points.map(function (point) { return point.toJSON().coordinates; })
43
- };
44
- };
45
- LineString.validate = function (lineString) {
46
- var e_1, _a;
47
- if (lineString.type !== 'LineString' || !isArray(lineString.coordinates)) {
48
- return false;
49
- }
50
- try {
51
- for (var _b = __values(lineString.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);
62
- }
63
- finally { if (e_1) throw e_1.error; }
64
- }
65
- return true;
66
- };
67
- LineString.isClosed = function (lineString) {
68
- var firstPoint = lineString.points[0];
69
- var lastPoint = lineString.points[lineString.points.length - 1];
70
- if (firstPoint.latitude === lastPoint.latitude && firstPoint.longitude === lastPoint.longitude) {
71
- return true;
72
- }
73
- };
74
- Object.defineProperty(LineString.prototype, "_internalType", {
75
- get: function () {
76
- return SYMBOL_GEO_LINE_STRING;
77
- },
78
- enumerable: false,
79
- configurable: true
80
- });
81
- return LineString;
82
- }());
83
- export { LineString };
@@ -1,18 +0,0 @@
1
- import { LineString } from './lineString';
2
- import { ISerializedMultiLineString } from './interface';
3
- export declare class MultiLineString {
4
- readonly lines: LineString[];
5
- constructor(lines: LineString[]);
6
- parse(key: any): {
7
- [x: number]: {
8
- type: string;
9
- coordinates: number[][][];
10
- };
11
- };
12
- toJSON(): {
13
- type: string;
14
- coordinates: number[][][];
15
- };
16
- static validate(multiLineString: ISerializedMultiLineString): boolean;
17
- get _internalType(): import("../utils/symbol").InternalSymbol;
18
- }
@@ -1,92 +0,0 @@
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
- };
12
- import { SYMBOL_GEO_MULTI_LINE_STRING } from '../helper/symbol';
13
- import { isArray, isNumber } from '../utils/type';
14
- import { LineString } from './lineString';
15
- var MultiLineString = (function () {
16
- function MultiLineString(lines) {
17
- if (!isArray(lines)) {
18
- throw new TypeError("\"lines\" must be of type LineString[]. Received type ".concat(typeof lines));
19
- }
20
- if (lines.length === 0) {
21
- throw new Error('Polygon must contain 1 linestring at least');
22
- }
23
- lines.forEach(function (line) {
24
- if (!(line instanceof LineString)) {
25
- throw new TypeError("\"lines\" must be of type LineString[]. Received type ".concat(typeof line, "[]"));
26
- }
27
- });
28
- this.lines = lines;
29
- }
30
- MultiLineString.prototype.parse = function (key) {
31
- var _a;
32
- return _a = {},
33
- _a[key] = {
34
- type: 'MultiLineString',
35
- coordinates: this.lines.map(function (line) {
36
- return line.points.map(function (point) { return [point.longitude, point.latitude]; });
37
- })
38
- },
39
- _a;
40
- };
41
- MultiLineString.prototype.toJSON = function () {
42
- return {
43
- type: 'MultiLineString',
44
- coordinates: this.lines.map(function (line) {
45
- return line.points.map(function (point) { return [point.longitude, point.latitude]; });
46
- })
47
- };
48
- };
49
- MultiLineString.validate = function (multiLineString) {
50
- var e_1, _a, e_2, _b;
51
- if (multiLineString.type !== 'MultiLineString' || !isArray(multiLineString.coordinates)) {
52
- return false;
53
- }
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
- }
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);
78
- }
79
- finally { if (e_1) throw e_1.error; }
80
- }
81
- return true;
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 };
@@ -1,18 +0,0 @@
1
- import { Point } from './point';
2
- import { ISerializedMultiPoint } from './interface';
3
- export declare class MultiPoint {
4
- readonly points: Point[];
5
- constructor(points: Point[]);
6
- parse(key: any): {
7
- [x: number]: {
8
- type: string;
9
- coordinates: number[][];
10
- };
11
- };
12
- toJSON(): {
13
- type: string;
14
- coordinates: number[][];
15
- };
16
- static validate(multiPoint: ISerializedMultiPoint): boolean;
17
- get _internalType(): import("../utils/symbol").InternalSymbol;
18
- }
@@ -1,76 +0,0 @@
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
- };
12
- import { SYMBOL_GEO_MULTI_POINT } from '../helper/symbol';
13
- import { Point } from './point';
14
- import { isArray, isNumber } from '../utils/type';
15
- var MultiPoint = (function () {
16
- function MultiPoint(points) {
17
- if (!isArray(points)) {
18
- throw new TypeError("\"points\" must be of type Point[]. Received type ".concat(typeof points));
19
- }
20
- if (points.length === 0) {
21
- throw new Error('"points" must contain 1 point at least');
22
- }
23
- points.forEach(function (point) {
24
- if (!(point instanceof Point)) {
25
- throw new TypeError("\"points\" must be of type Point[]. Received type ".concat(typeof point, "[]"));
26
- }
27
- });
28
- this.points = points;
29
- }
30
- MultiPoint.prototype.parse = function (key) {
31
- var _a;
32
- return _a = {},
33
- _a[key] = {
34
- type: 'MultiPoint',
35
- coordinates: this.points.map(function (point) { return point.toJSON().coordinates; })
36
- },
37
- _a;
38
- };
39
- MultiPoint.prototype.toJSON = function () {
40
- return {
41
- type: 'MultiPoint',
42
- coordinates: this.points.map(function (point) { return point.toJSON().coordinates; })
43
- };
44
- };
45
- MultiPoint.validate = function (multiPoint) {
46
- var e_1, _a;
47
- if (multiPoint.type !== 'MultiPoint' || !isArray(multiPoint.coordinates)) {
48
- return false;
49
- }
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);
62
- }
63
- finally { if (e_1) throw e_1.error; }
64
- }
65
- return true;
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 };
@@ -1,18 +0,0 @@
1
- import { Polygon } from './polygon';
2
- import { ISerializedMultiPolygon } from './interface';
3
- export declare class MultiPolygon {
4
- readonly polygons: Polygon[];
5
- constructor(polygons: Polygon[]);
6
- parse(key: any): {
7
- [x: number]: {
8
- type: string;
9
- coordinates: number[][][][];
10
- };
11
- };
12
- toJSON(): {
13
- type: string;
14
- coordinates: number[][][][];
15
- };
16
- static validate(multiPolygon: ISerializedMultiPolygon): boolean;
17
- get _internalType(): import("../utils/symbol").InternalSymbol;
18
- }