@cloudbase/js-sdk 3.6.4 → 3.6.5-alpha.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 (249) hide show
  1. package/ai/dist/index.esm.js +1 -1
  2. package/ai/dist/index.esm.js.map +1 -1
  3. package/ai/dist/index.js +1 -1
  4. package/ai/dist/index.js.map +1 -1
  5. package/apis/dist/index.esm.js +1 -1
  6. package/apis/dist/index.esm.js.map +1 -1
  7. package/apis/dist/index.js +1 -1
  8. package/apis/dist/index.js.map +1 -1
  9. package/app/dist/index.esm.js +1 -1
  10. package/app/dist/index.esm.js.map +1 -1
  11. package/app/dist/index.js +1 -1
  12. package/app/dist/index.js.map +1 -1
  13. package/app/dist/index.node.esm.js +1 -1
  14. package/app/dist/index.node.esm.js.map +1 -1
  15. package/app/dist/index.node.js +1 -1
  16. package/app/dist/index.node.js.map +1 -1
  17. package/auth/dist/index.esm.js +1 -2
  18. package/auth/dist/index.esm.js.map +1 -1
  19. package/auth/dist/index.js +1 -2
  20. package/auth/dist/index.js.map +1 -1
  21. package/cloudrun/dist/index.esm.js +1 -1
  22. package/cloudrun/dist/index.esm.js.map +1 -1
  23. package/cloudrun/dist/index.js +1 -1
  24. package/cloudrun/dist/index.js.map +1 -1
  25. package/container/dist/index.esm.js +1 -1
  26. package/container/dist/index.esm.js.map +1 -1
  27. package/container/dist/index.js +1 -1
  28. package/container/dist/index.js.map +1 -1
  29. package/database/dist/index.d.ts +3 -0
  30. package/database/dist/index.esm.js +2 -0
  31. package/database/dist/index.esm.js.map +1 -0
  32. package/database/dist/index.js +2 -0
  33. package/database/dist/index.js.map +1 -0
  34. package/dist/index.cjs.js +1 -2
  35. package/dist/index.cjs.js.map +1 -1
  36. package/dist/index.esm.js +1 -2
  37. package/dist/index.esm.js.map +1 -1
  38. package/dist/index.node.cjs.js +1 -1
  39. package/dist/index.node.cjs.js.LICENSE.txt +0 -13
  40. package/dist/index.node.cjs.js.map +1 -1
  41. package/dist/index.node.esm.js +1 -1
  42. package/dist/index.node.esm.js.LICENSE.txt +0 -13
  43. package/dist/index.node.esm.js.map +1 -1
  44. package/functions/dist/index.esm.js +1 -1
  45. package/functions/dist/index.esm.js.map +1 -1
  46. package/functions/dist/index.js +1 -1
  47. package/functions/dist/index.js.map +1 -1
  48. package/miniprogram_dist/index.js +1 -1
  49. package/model/dist/index.esm.js +1 -1
  50. package/model/dist/index.esm.js.map +1 -1
  51. package/model/dist/index.js +1 -1
  52. package/model/dist/index.js.map +1 -1
  53. package/mysql/dist/index.esm.js +1 -1
  54. package/mysql/dist/index.esm.js.map +1 -1
  55. package/mysql/dist/index.js +1 -1
  56. package/mysql/dist/index.js.map +1 -1
  57. package/oauth/dist/index.esm.js +1 -2
  58. package/oauth/dist/index.esm.js.map +1 -1
  59. package/oauth/dist/index.js +1 -2
  60. package/oauth/dist/index.js.map +1 -1
  61. package/package.json +17 -2
  62. package/realtime/dist/index.esm.js +1 -1
  63. package/realtime/dist/index.esm.js.map +1 -1
  64. package/realtime/dist/index.js +1 -1
  65. package/realtime/dist/index.js.map +1 -1
  66. package/storage/dist/index.esm.js +1 -1
  67. package/storage/dist/index.esm.js.map +1 -1
  68. package/storage/dist/index.js +1 -1
  69. package/storage/dist/index.js.map +1 -1
  70. package/types/package.json +2 -1
  71. package/utilities/package.json +9 -3
  72. package/auth/dist/index.esm.js.LICENSE.txt +0 -12
  73. package/auth/dist/index.js.LICENSE.txt +0 -12
  74. package/database/dist/commonjs/aggregate.d.ts +0 -29
  75. package/database/dist/commonjs/aggregate.js +0 -156
  76. package/database/dist/commonjs/collection.d.ts +0 -9
  77. package/database/dist/commonjs/collection.js +0 -49
  78. package/database/dist/commonjs/command.d.ts +0 -175
  79. package/database/dist/commonjs/command.js +0 -299
  80. package/database/dist/commonjs/commands/logic.d.ts +0 -24
  81. package/database/dist/commonjs/commands/logic.js +0 -89
  82. package/database/dist/commonjs/commands/query.d.ts +0 -68
  83. package/database/dist/commonjs/commands/query.js +0 -160
  84. package/database/dist/commonjs/commands/update.d.ts +0 -29
  85. package/database/dist/commonjs/commands/update.js +0 -51
  86. package/database/dist/commonjs/config/app.config.d.ts +0 -6
  87. package/database/dist/commonjs/config/app.config.js +0 -7
  88. package/database/dist/commonjs/config/error.config.d.ts +0 -3
  89. package/database/dist/commonjs/config/error.config.js +0 -16
  90. package/database/dist/commonjs/const/code.d.ts +0 -30
  91. package/database/dist/commonjs/const/code.js +0 -33
  92. package/database/dist/commonjs/constant.d.ts +0 -51
  93. package/database/dist/commonjs/constant.js +0 -75
  94. package/database/dist/commonjs/document.d.ts +0 -11
  95. package/database/dist/commonjs/document.js +0 -260
  96. package/database/dist/commonjs/geo/index.d.ts +0 -6
  97. package/database/dist/commonjs/geo/index.js +0 -22
  98. package/database/dist/commonjs/geo/interface.d.ts +0 -24
  99. package/database/dist/commonjs/geo/interface.js +0 -2
  100. package/database/dist/commonjs/geo/lineString.d.ts +0 -19
  101. package/database/dist/commonjs/geo/lineString.js +0 -86
  102. package/database/dist/commonjs/geo/multiLineString.d.ts +0 -18
  103. package/database/dist/commonjs/geo/multiLineString.js +0 -95
  104. package/database/dist/commonjs/geo/multiPoint.d.ts +0 -18
  105. package/database/dist/commonjs/geo/multiPoint.js +0 -79
  106. package/database/dist/commonjs/geo/multiPolygon.d.ts +0 -18
  107. package/database/dist/commonjs/geo/multiPolygon.js +0 -122
  108. package/database/dist/commonjs/geo/point.d.ts +0 -19
  109. package/database/dist/commonjs/geo/point.js +0 -50
  110. package/database/dist/commonjs/geo/polygon.d.ts +0 -19
  111. package/database/dist/commonjs/geo/polygon.js +0 -109
  112. package/database/dist/commonjs/helper/symbol.d.ts +0 -14
  113. package/database/dist/commonjs/helper/symbol.js +0 -31
  114. package/database/dist/commonjs/index.d.ts +0 -40
  115. package/database/dist/commonjs/index.js +0 -61
  116. package/database/dist/commonjs/lib/util.d.ts +0 -1
  117. package/database/dist/commonjs/lib/util.js +0 -26
  118. package/database/dist/commonjs/operator-map.d.ts +0 -4
  119. package/database/dist/commonjs/operator-map.js +0 -24
  120. package/database/dist/commonjs/query.d.ts +0 -22
  121. package/database/dist/commonjs/query.js +0 -252
  122. package/database/dist/commonjs/regexp/index.d.ts +0 -14
  123. package/database/dist/commonjs/regexp/index.js +0 -33
  124. package/database/dist/commonjs/serializer/common.d.ts +0 -11
  125. package/database/dist/commonjs/serializer/common.js +0 -127
  126. package/database/dist/commonjs/serializer/datatype.d.ts +0 -7
  127. package/database/dist/commonjs/serializer/datatype.js +0 -132
  128. package/database/dist/commonjs/serializer/query.d.ts +0 -7
  129. package/database/dist/commonjs/serializer/query.js +0 -232
  130. package/database/dist/commonjs/serializer/update.d.ts +0 -15
  131. package/database/dist/commonjs/serializer/update.js +0 -142
  132. package/database/dist/commonjs/serverDate/index.d.ts +0 -13
  133. package/database/dist/commonjs/serverDate/index.js +0 -30
  134. package/database/dist/commonjs/transaction/collection.d.ts +0 -7
  135. package/database/dist/commonjs/transaction/collection.js +0 -49
  136. package/database/dist/commonjs/transaction/document.d.ts +0 -27
  137. package/database/dist/commonjs/transaction/document.js +0 -205
  138. package/database/dist/commonjs/transaction/index.d.ts +0 -30
  139. package/database/dist/commonjs/transaction/index.js +0 -215
  140. package/database/dist/commonjs/transaction/query.d.ts +0 -43
  141. package/database/dist/commonjs/transaction/query.js +0 -261
  142. package/database/dist/commonjs/typings/index.d.ts +0 -40
  143. package/database/dist/commonjs/typings/index.js +0 -2
  144. package/database/dist/commonjs/typings/realtime.d.ts +0 -219
  145. package/database/dist/commonjs/typings/realtime.js +0 -2
  146. package/database/dist/commonjs/util.d.ts +0 -9
  147. package/database/dist/commonjs/util.js +0 -145
  148. package/database/dist/commonjs/utils/error.d.ts +0 -38
  149. package/database/dist/commonjs/utils/error.js +0 -91
  150. package/database/dist/commonjs/utils/msg.d.ts +0 -0
  151. package/database/dist/commonjs/utils/msg.js +0 -0
  152. package/database/dist/commonjs/utils/symbol.d.ts +0 -8
  153. package/database/dist/commonjs/utils/symbol.js +0 -58
  154. package/database/dist/commonjs/utils/type.d.ts +0 -13
  155. package/database/dist/commonjs/utils/type.js +0 -34
  156. package/database/dist/commonjs/utils/utils.d.ts +0 -4
  157. package/database/dist/commonjs/utils/utils.js +0 -39
  158. package/database/dist/commonjs/validate.d.ts +0 -1
  159. package/database/dist/commonjs/validate.js +0 -60
  160. package/database/dist/esm/aggregate.d.ts +0 -29
  161. package/database/dist/esm/aggregate.js +0 -154
  162. package/database/dist/esm/collection.d.ts +0 -9
  163. package/database/dist/esm/collection.js +0 -46
  164. package/database/dist/esm/command.d.ts +0 -175
  165. package/database/dist/esm/command.js +0 -296
  166. package/database/dist/esm/commands/logic.d.ts +0 -24
  167. package/database/dist/esm/commands/logic.js +0 -84
  168. package/database/dist/esm/commands/query.d.ts +0 -68
  169. package/database/dist/esm/commands/query.js +0 -154
  170. package/database/dist/esm/commands/update.d.ts +0 -29
  171. package/database/dist/esm/commands/update.js +0 -46
  172. package/database/dist/esm/config/app.config.d.ts +0 -6
  173. package/database/dist/esm/config/app.config.js +0 -5
  174. package/database/dist/esm/config/error.config.d.ts +0 -3
  175. package/database/dist/esm/config/error.config.js +0 -13
  176. package/database/dist/esm/const/code.d.ts +0 -30
  177. package/database/dist/esm/const/code.js +0 -30
  178. package/database/dist/esm/constant.d.ts +0 -51
  179. package/database/dist/esm/constant.js +0 -65
  180. package/database/dist/esm/document.d.ts +0 -11
  181. package/database/dist/esm/document.js +0 -257
  182. package/database/dist/esm/geo/index.d.ts +0 -6
  183. package/database/dist/esm/geo/index.js +0 -6
  184. package/database/dist/esm/geo/interface.d.ts +0 -24
  185. package/database/dist/esm/geo/interface.js +0 -1
  186. package/database/dist/esm/geo/lineString.d.ts +0 -19
  187. package/database/dist/esm/geo/lineString.js +0 -83
  188. package/database/dist/esm/geo/multiLineString.d.ts +0 -18
  189. package/database/dist/esm/geo/multiLineString.js +0 -92
  190. package/database/dist/esm/geo/multiPoint.d.ts +0 -18
  191. package/database/dist/esm/geo/multiPoint.js +0 -76
  192. package/database/dist/esm/geo/multiPolygon.d.ts +0 -18
  193. package/database/dist/esm/geo/multiPolygon.js +0 -119
  194. package/database/dist/esm/geo/point.d.ts +0 -19
  195. package/database/dist/esm/geo/point.js +0 -47
  196. package/database/dist/esm/geo/polygon.d.ts +0 -19
  197. package/database/dist/esm/geo/polygon.js +0 -106
  198. package/database/dist/esm/helper/symbol.d.ts +0 -14
  199. package/database/dist/esm/helper/symbol.js +0 -14
  200. package/database/dist/esm/index.d.ts +0 -40
  201. package/database/dist/esm/index.js +0 -55
  202. package/database/dist/esm/lib/util.d.ts +0 -1
  203. package/database/dist/esm/lib/util.js +0 -22
  204. package/database/dist/esm/operator-map.d.ts +0 -4
  205. package/database/dist/esm/operator-map.js +0 -20
  206. package/database/dist/esm/query.d.ts +0 -22
  207. package/database/dist/esm/query.js +0 -249
  208. package/database/dist/esm/regexp/index.d.ts +0 -14
  209. package/database/dist/esm/regexp/index.js +0 -29
  210. package/database/dist/esm/serializer/common.d.ts +0 -11
  211. package/database/dist/esm/serializer/common.js +0 -118
  212. package/database/dist/esm/serializer/datatype.d.ts +0 -7
  213. package/database/dist/esm/serializer/datatype.js +0 -127
  214. package/database/dist/esm/serializer/query.d.ts +0 -7
  215. package/database/dist/esm/serializer/query.js +0 -229
  216. package/database/dist/esm/serializer/update.d.ts +0 -15
  217. package/database/dist/esm/serializer/update.js +0 -139
  218. package/database/dist/esm/serverDate/index.d.ts +0 -13
  219. package/database/dist/esm/serverDate/index.js +0 -26
  220. package/database/dist/esm/transaction/collection.d.ts +0 -7
  221. package/database/dist/esm/transaction/collection.js +0 -46
  222. package/database/dist/esm/transaction/document.d.ts +0 -27
  223. package/database/dist/esm/transaction/document.js +0 -202
  224. package/database/dist/esm/transaction/index.d.ts +0 -30
  225. package/database/dist/esm/transaction/index.js +0 -210
  226. package/database/dist/esm/transaction/query.d.ts +0 -43
  227. package/database/dist/esm/transaction/query.js +0 -258
  228. package/database/dist/esm/typings/index.d.ts +0 -40
  229. package/database/dist/esm/typings/index.js +0 -1
  230. package/database/dist/esm/typings/realtime.d.ts +0 -219
  231. package/database/dist/esm/typings/realtime.js +0 -1
  232. package/database/dist/esm/util.d.ts +0 -9
  233. package/database/dist/esm/util.js +0 -142
  234. package/database/dist/esm/utils/error.d.ts +0 -38
  235. package/database/dist/esm/utils/error.js +0 -84
  236. package/database/dist/esm/utils/msg.d.ts +0 -0
  237. package/database/dist/esm/utils/msg.js +0 -0
  238. package/database/dist/esm/utils/symbol.d.ts +0 -8
  239. package/database/dist/esm/utils/symbol.js +0 -55
  240. package/database/dist/esm/utils/type.d.ts +0 -13
  241. package/database/dist/esm/utils/type.js +0 -20
  242. package/database/dist/esm/utils/utils.d.ts +0 -4
  243. package/database/dist/esm/utils/utils.js +0 -33
  244. package/database/dist/esm/validate.d.ts +0 -1
  245. package/database/dist/esm/validate.js +0 -57
  246. package/dist/index.cjs.js.LICENSE.txt +0 -12
  247. package/dist/index.esm.js.LICENSE.txt +0 -12
  248. package/oauth/dist/index.esm.js.LICENSE.txt +0 -12
  249. package/oauth/dist/index.js.LICENSE.txt +0 -12
@@ -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
- }