@cloudbase/js-sdk 3.6.7 → 3.6.8-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (207) 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 +1 -1
  10. package/auth/dist/index.esm.js.map +1 -1
  11. package/auth/dist/index.js +1 -1
  12. package/auth/dist/index.js.map +1 -1
  13. package/database/dist/index.d.ts +3 -0
  14. package/database/dist/index.esm.js +2 -0
  15. package/database/dist/index.esm.js.map +1 -0
  16. package/database/dist/index.js +2 -0
  17. package/database/dist/index.js.map +1 -0
  18. package/dist/index.cjs.js +1 -1
  19. package/dist/index.cjs.js.map +1 -1
  20. package/dist/index.esm.js +1 -1
  21. package/dist/index.esm.js.map +1 -1
  22. package/dist/index.node.cjs.js +1 -1
  23. package/dist/index.node.cjs.js.map +1 -1
  24. package/dist/index.node.esm.js +1 -1
  25. package/dist/index.node.esm.js.map +1 -1
  26. package/miniprogram_dist/auth/index.js +1 -1
  27. package/miniprogram_dist/index.js +1 -1
  28. package/miniprogram_dist/oauth/index.js +1 -1
  29. package/oauth/dist/index.esm.js +1 -1
  30. package/oauth/dist/index.esm.js.map +1 -1
  31. package/oauth/dist/index.js +1 -1
  32. package/oauth/dist/index.js.map +1 -1
  33. package/package.json +2 -2
  34. package/types/package.json +1 -1
  35. package/utilities/package.json +2 -2
  36. package/database/dist/commonjs/aggregate.d.ts +0 -29
  37. package/database/dist/commonjs/aggregate.js +0 -156
  38. package/database/dist/commonjs/collection.d.ts +0 -9
  39. package/database/dist/commonjs/collection.js +0 -49
  40. package/database/dist/commonjs/command.d.ts +0 -175
  41. package/database/dist/commonjs/command.js +0 -299
  42. package/database/dist/commonjs/commands/logic.d.ts +0 -24
  43. package/database/dist/commonjs/commands/logic.js +0 -89
  44. package/database/dist/commonjs/commands/query.d.ts +0 -68
  45. package/database/dist/commonjs/commands/query.js +0 -160
  46. package/database/dist/commonjs/commands/update.d.ts +0 -29
  47. package/database/dist/commonjs/commands/update.js +0 -51
  48. package/database/dist/commonjs/config/app.config.d.ts +0 -6
  49. package/database/dist/commonjs/config/app.config.js +0 -7
  50. package/database/dist/commonjs/config/error.config.d.ts +0 -3
  51. package/database/dist/commonjs/config/error.config.js +0 -16
  52. package/database/dist/commonjs/const/code.d.ts +0 -30
  53. package/database/dist/commonjs/const/code.js +0 -33
  54. package/database/dist/commonjs/constant.d.ts +0 -51
  55. package/database/dist/commonjs/constant.js +0 -75
  56. package/database/dist/commonjs/document.d.ts +0 -11
  57. package/database/dist/commonjs/document.js +0 -260
  58. package/database/dist/commonjs/geo/index.d.ts +0 -6
  59. package/database/dist/commonjs/geo/index.js +0 -22
  60. package/database/dist/commonjs/geo/interface.d.ts +0 -24
  61. package/database/dist/commonjs/geo/interface.js +0 -2
  62. package/database/dist/commonjs/geo/lineString.d.ts +0 -19
  63. package/database/dist/commonjs/geo/lineString.js +0 -86
  64. package/database/dist/commonjs/geo/multiLineString.d.ts +0 -18
  65. package/database/dist/commonjs/geo/multiLineString.js +0 -95
  66. package/database/dist/commonjs/geo/multiPoint.d.ts +0 -18
  67. package/database/dist/commonjs/geo/multiPoint.js +0 -79
  68. package/database/dist/commonjs/geo/multiPolygon.d.ts +0 -18
  69. package/database/dist/commonjs/geo/multiPolygon.js +0 -122
  70. package/database/dist/commonjs/geo/point.d.ts +0 -19
  71. package/database/dist/commonjs/geo/point.js +0 -50
  72. package/database/dist/commonjs/geo/polygon.d.ts +0 -19
  73. package/database/dist/commonjs/geo/polygon.js +0 -109
  74. package/database/dist/commonjs/helper/symbol.d.ts +0 -14
  75. package/database/dist/commonjs/helper/symbol.js +0 -31
  76. package/database/dist/commonjs/index.d.ts +0 -40
  77. package/database/dist/commonjs/index.js +0 -61
  78. package/database/dist/commonjs/lib/util.d.ts +0 -1
  79. package/database/dist/commonjs/lib/util.js +0 -26
  80. package/database/dist/commonjs/operator-map.d.ts +0 -4
  81. package/database/dist/commonjs/operator-map.js +0 -24
  82. package/database/dist/commonjs/query.d.ts +0 -22
  83. package/database/dist/commonjs/query.js +0 -252
  84. package/database/dist/commonjs/regexp/index.d.ts +0 -14
  85. package/database/dist/commonjs/regexp/index.js +0 -33
  86. package/database/dist/commonjs/serializer/common.d.ts +0 -11
  87. package/database/dist/commonjs/serializer/common.js +0 -127
  88. package/database/dist/commonjs/serializer/datatype.d.ts +0 -7
  89. package/database/dist/commonjs/serializer/datatype.js +0 -132
  90. package/database/dist/commonjs/serializer/query.d.ts +0 -7
  91. package/database/dist/commonjs/serializer/query.js +0 -232
  92. package/database/dist/commonjs/serializer/update.d.ts +0 -15
  93. package/database/dist/commonjs/serializer/update.js +0 -142
  94. package/database/dist/commonjs/serverDate/index.d.ts +0 -13
  95. package/database/dist/commonjs/serverDate/index.js +0 -30
  96. package/database/dist/commonjs/transaction/collection.d.ts +0 -7
  97. package/database/dist/commonjs/transaction/collection.js +0 -49
  98. package/database/dist/commonjs/transaction/document.d.ts +0 -27
  99. package/database/dist/commonjs/transaction/document.js +0 -205
  100. package/database/dist/commonjs/transaction/index.d.ts +0 -30
  101. package/database/dist/commonjs/transaction/index.js +0 -215
  102. package/database/dist/commonjs/transaction/query.d.ts +0 -43
  103. package/database/dist/commonjs/transaction/query.js +0 -261
  104. package/database/dist/commonjs/typings/index.d.ts +0 -40
  105. package/database/dist/commonjs/typings/index.js +0 -2
  106. package/database/dist/commonjs/typings/realtime.d.ts +0 -219
  107. package/database/dist/commonjs/typings/realtime.js +0 -2
  108. package/database/dist/commonjs/util.d.ts +0 -9
  109. package/database/dist/commonjs/util.js +0 -145
  110. package/database/dist/commonjs/utils/error.d.ts +0 -38
  111. package/database/dist/commonjs/utils/error.js +0 -91
  112. package/database/dist/commonjs/utils/msg.d.ts +0 -0
  113. package/database/dist/commonjs/utils/msg.js +0 -0
  114. package/database/dist/commonjs/utils/symbol.d.ts +0 -8
  115. package/database/dist/commonjs/utils/symbol.js +0 -58
  116. package/database/dist/commonjs/utils/type.d.ts +0 -13
  117. package/database/dist/commonjs/utils/type.js +0 -34
  118. package/database/dist/commonjs/utils/utils.d.ts +0 -4
  119. package/database/dist/commonjs/utils/utils.js +0 -39
  120. package/database/dist/commonjs/validate.d.ts +0 -1
  121. package/database/dist/commonjs/validate.js +0 -60
  122. package/database/dist/esm/aggregate.d.ts +0 -29
  123. package/database/dist/esm/aggregate.js +0 -154
  124. package/database/dist/esm/collection.d.ts +0 -9
  125. package/database/dist/esm/collection.js +0 -46
  126. package/database/dist/esm/command.d.ts +0 -175
  127. package/database/dist/esm/command.js +0 -296
  128. package/database/dist/esm/commands/logic.d.ts +0 -24
  129. package/database/dist/esm/commands/logic.js +0 -84
  130. package/database/dist/esm/commands/query.d.ts +0 -68
  131. package/database/dist/esm/commands/query.js +0 -154
  132. package/database/dist/esm/commands/update.d.ts +0 -29
  133. package/database/dist/esm/commands/update.js +0 -46
  134. package/database/dist/esm/config/app.config.d.ts +0 -6
  135. package/database/dist/esm/config/app.config.js +0 -5
  136. package/database/dist/esm/config/error.config.d.ts +0 -3
  137. package/database/dist/esm/config/error.config.js +0 -13
  138. package/database/dist/esm/const/code.d.ts +0 -30
  139. package/database/dist/esm/const/code.js +0 -30
  140. package/database/dist/esm/constant.d.ts +0 -51
  141. package/database/dist/esm/constant.js +0 -65
  142. package/database/dist/esm/document.d.ts +0 -11
  143. package/database/dist/esm/document.js +0 -257
  144. package/database/dist/esm/geo/index.d.ts +0 -6
  145. package/database/dist/esm/geo/index.js +0 -6
  146. package/database/dist/esm/geo/interface.d.ts +0 -24
  147. package/database/dist/esm/geo/interface.js +0 -1
  148. package/database/dist/esm/geo/lineString.d.ts +0 -19
  149. package/database/dist/esm/geo/lineString.js +0 -83
  150. package/database/dist/esm/geo/multiLineString.d.ts +0 -18
  151. package/database/dist/esm/geo/multiLineString.js +0 -92
  152. package/database/dist/esm/geo/multiPoint.d.ts +0 -18
  153. package/database/dist/esm/geo/multiPoint.js +0 -76
  154. package/database/dist/esm/geo/multiPolygon.d.ts +0 -18
  155. package/database/dist/esm/geo/multiPolygon.js +0 -119
  156. package/database/dist/esm/geo/point.d.ts +0 -19
  157. package/database/dist/esm/geo/point.js +0 -47
  158. package/database/dist/esm/geo/polygon.d.ts +0 -19
  159. package/database/dist/esm/geo/polygon.js +0 -106
  160. package/database/dist/esm/helper/symbol.d.ts +0 -14
  161. package/database/dist/esm/helper/symbol.js +0 -14
  162. package/database/dist/esm/index.d.ts +0 -40
  163. package/database/dist/esm/index.js +0 -55
  164. package/database/dist/esm/lib/util.d.ts +0 -1
  165. package/database/dist/esm/lib/util.js +0 -22
  166. package/database/dist/esm/operator-map.d.ts +0 -4
  167. package/database/dist/esm/operator-map.js +0 -20
  168. package/database/dist/esm/query.d.ts +0 -22
  169. package/database/dist/esm/query.js +0 -249
  170. package/database/dist/esm/regexp/index.d.ts +0 -14
  171. package/database/dist/esm/regexp/index.js +0 -29
  172. package/database/dist/esm/serializer/common.d.ts +0 -11
  173. package/database/dist/esm/serializer/common.js +0 -118
  174. package/database/dist/esm/serializer/datatype.d.ts +0 -7
  175. package/database/dist/esm/serializer/datatype.js +0 -127
  176. package/database/dist/esm/serializer/query.d.ts +0 -7
  177. package/database/dist/esm/serializer/query.js +0 -229
  178. package/database/dist/esm/serializer/update.d.ts +0 -15
  179. package/database/dist/esm/serializer/update.js +0 -139
  180. package/database/dist/esm/serverDate/index.d.ts +0 -13
  181. package/database/dist/esm/serverDate/index.js +0 -26
  182. package/database/dist/esm/transaction/collection.d.ts +0 -7
  183. package/database/dist/esm/transaction/collection.js +0 -46
  184. package/database/dist/esm/transaction/document.d.ts +0 -27
  185. package/database/dist/esm/transaction/document.js +0 -202
  186. package/database/dist/esm/transaction/index.d.ts +0 -30
  187. package/database/dist/esm/transaction/index.js +0 -210
  188. package/database/dist/esm/transaction/query.d.ts +0 -43
  189. package/database/dist/esm/transaction/query.js +0 -258
  190. package/database/dist/esm/typings/index.d.ts +0 -40
  191. package/database/dist/esm/typings/index.js +0 -1
  192. package/database/dist/esm/typings/realtime.d.ts +0 -219
  193. package/database/dist/esm/typings/realtime.js +0 -1
  194. package/database/dist/esm/util.d.ts +0 -9
  195. package/database/dist/esm/util.js +0 -142
  196. package/database/dist/esm/utils/error.d.ts +0 -38
  197. package/database/dist/esm/utils/error.js +0 -84
  198. package/database/dist/esm/utils/msg.d.ts +0 -0
  199. package/database/dist/esm/utils/msg.js +0 -0
  200. package/database/dist/esm/utils/symbol.d.ts +0 -8
  201. package/database/dist/esm/utils/symbol.js +0 -55
  202. package/database/dist/esm/utils/type.d.ts +0 -13
  203. package/database/dist/esm/utils/type.js +0 -20
  204. package/database/dist/esm/utils/utils.d.ts +0 -4
  205. package/database/dist/esm/utils/utils.js +0 -33
  206. package/database/dist/esm/validate.d.ts +0 -1
  207. 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
- }