@cloudbase/js-sdk 3.6.5-alpha.0 → 3.6.5

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