@cloudbase/js-sdk 2.28.8 → 2.30.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 (330) hide show
  1. package/CHANGELOG.md +147 -0
  2. package/ai/dist/index.esm.js +2 -3
  3. package/ai/dist/index.esm.js.map +1 -0
  4. package/ai/dist/index.js +2 -21
  5. package/ai/dist/index.js.map +1 -0
  6. package/apis/dist/index.esm.js +2 -3
  7. package/apis/dist/index.esm.js.map +1 -0
  8. package/apis/dist/index.js +2 -21
  9. package/apis/dist/index.js.map +1 -0
  10. package/app/dist/index.esm.js +2 -11
  11. package/app/dist/index.esm.js.map +1 -0
  12. package/app/dist/index.js +2 -18
  13. package/app/dist/index.js.map +1 -0
  14. package/auth/dist/index.d.ts +2 -2
  15. package/auth/dist/index.esm.js +3 -8
  16. package/auth/dist/index.esm.js.LICENSE.txt +12 -0
  17. package/auth/dist/index.esm.js.map +1 -0
  18. package/auth/dist/index.js +3 -13
  19. package/auth/dist/index.js.LICENSE.txt +12 -0
  20. package/auth/dist/index.js.map +1 -0
  21. package/cloudrun/dist/index.esm.js +2 -3
  22. package/cloudrun/dist/index.esm.js.map +1 -0
  23. package/cloudrun/dist/index.js +2 -21
  24. package/cloudrun/dist/index.js.map +1 -0
  25. package/container/dist/index.d.ts +2 -2
  26. package/container/dist/index.esm.js +2 -8
  27. package/container/dist/index.esm.js.map +1 -0
  28. package/container/dist/index.js +2 -13
  29. package/container/dist/index.js.map +1 -0
  30. package/database/dist/commonjs/aggregate.d.ts +29 -0
  31. package/database/dist/commonjs/aggregate.js +156 -0
  32. package/database/dist/commonjs/collection.d.ts +9 -0
  33. package/database/dist/commonjs/collection.js +49 -0
  34. package/database/dist/commonjs/command.d.ts +175 -0
  35. package/database/dist/commonjs/command.js +299 -0
  36. package/database/dist/commonjs/commands/logic.d.ts +24 -0
  37. package/database/dist/commonjs/commands/logic.js +89 -0
  38. package/database/dist/commonjs/commands/query.d.ts +68 -0
  39. package/database/dist/commonjs/commands/query.js +160 -0
  40. package/database/dist/commonjs/commands/update.d.ts +29 -0
  41. package/database/dist/commonjs/commands/update.js +51 -0
  42. package/database/dist/commonjs/config/app.config.d.ts +6 -0
  43. package/database/dist/commonjs/config/app.config.js +7 -0
  44. package/database/dist/commonjs/config/error.config.d.ts +3 -0
  45. package/database/dist/commonjs/config/error.config.js +16 -0
  46. package/database/dist/commonjs/const/code.d.ts +30 -0
  47. package/database/dist/commonjs/const/code.js +33 -0
  48. package/database/dist/commonjs/constant.d.ts +51 -0
  49. package/database/dist/commonjs/constant.js +75 -0
  50. package/database/dist/commonjs/document.d.ts +11 -0
  51. package/database/dist/commonjs/document.js +260 -0
  52. package/database/dist/commonjs/geo/index.d.ts +6 -0
  53. package/database/dist/commonjs/geo/index.js +22 -0
  54. package/database/dist/commonjs/geo/interface.d.ts +24 -0
  55. package/database/dist/commonjs/geo/interface.js +2 -0
  56. package/database/dist/commonjs/geo/lineString.d.ts +19 -0
  57. package/database/dist/commonjs/geo/lineString.js +86 -0
  58. package/database/dist/commonjs/geo/multiLineString.d.ts +18 -0
  59. package/database/dist/commonjs/geo/multiLineString.js +95 -0
  60. package/database/dist/commonjs/geo/multiPoint.d.ts +18 -0
  61. package/database/dist/commonjs/geo/multiPoint.js +79 -0
  62. package/database/dist/commonjs/geo/multiPolygon.d.ts +18 -0
  63. package/database/dist/commonjs/geo/multiPolygon.js +122 -0
  64. package/database/dist/commonjs/geo/point.d.ts +19 -0
  65. package/database/dist/commonjs/geo/point.js +50 -0
  66. package/database/dist/commonjs/geo/polygon.d.ts +19 -0
  67. package/database/dist/commonjs/geo/polygon.js +109 -0
  68. package/database/dist/commonjs/helper/symbol.d.ts +14 -0
  69. package/database/dist/commonjs/helper/symbol.js +31 -0
  70. package/database/dist/commonjs/index.d.ts +40 -0
  71. package/database/dist/commonjs/index.js +61 -0
  72. package/database/dist/commonjs/lib/util.d.ts +1 -0
  73. package/database/dist/commonjs/lib/util.js +26 -0
  74. package/database/dist/commonjs/operator-map.d.ts +4 -0
  75. package/database/dist/commonjs/operator-map.js +24 -0
  76. package/database/dist/commonjs/query.d.ts +22 -0
  77. package/database/dist/commonjs/query.js +252 -0
  78. package/database/dist/commonjs/regexp/index.d.ts +14 -0
  79. package/database/dist/commonjs/regexp/index.js +33 -0
  80. package/database/dist/commonjs/serializer/common.d.ts +11 -0
  81. package/database/dist/commonjs/serializer/common.js +127 -0
  82. package/database/dist/commonjs/serializer/datatype.d.ts +7 -0
  83. package/database/dist/commonjs/serializer/datatype.js +132 -0
  84. package/database/dist/commonjs/serializer/query.d.ts +7 -0
  85. package/database/dist/commonjs/serializer/query.js +232 -0
  86. package/database/dist/commonjs/serializer/update.d.ts +15 -0
  87. package/database/dist/commonjs/serializer/update.js +142 -0
  88. package/database/dist/commonjs/serverDate/index.d.ts +13 -0
  89. package/database/dist/commonjs/serverDate/index.js +30 -0
  90. package/database/dist/commonjs/transaction/collection.d.ts +7 -0
  91. package/database/dist/commonjs/transaction/collection.js +49 -0
  92. package/database/dist/commonjs/transaction/document.d.ts +27 -0
  93. package/database/dist/commonjs/transaction/document.js +205 -0
  94. package/database/dist/commonjs/transaction/index.d.ts +30 -0
  95. package/database/dist/commonjs/transaction/index.js +215 -0
  96. package/database/dist/commonjs/transaction/query.d.ts +43 -0
  97. package/database/dist/commonjs/transaction/query.js +261 -0
  98. package/database/dist/commonjs/typings/index.d.ts +40 -0
  99. package/database/dist/commonjs/typings/index.js +2 -0
  100. package/database/dist/commonjs/typings/realtime.d.ts +219 -0
  101. package/database/dist/commonjs/typings/realtime.js +2 -0
  102. package/database/dist/commonjs/util.d.ts +9 -0
  103. package/database/dist/commonjs/util.js +145 -0
  104. package/database/dist/commonjs/utils/error.d.ts +38 -0
  105. package/database/dist/commonjs/utils/error.js +91 -0
  106. package/database/dist/commonjs/utils/msg.d.ts +0 -0
  107. package/database/dist/commonjs/utils/msg.js +0 -0
  108. package/database/dist/commonjs/utils/symbol.d.ts +8 -0
  109. package/database/dist/commonjs/utils/symbol.js +58 -0
  110. package/database/dist/commonjs/utils/type.d.ts +13 -0
  111. package/database/dist/commonjs/utils/type.js +34 -0
  112. package/database/dist/commonjs/utils/utils.d.ts +4 -0
  113. package/database/dist/commonjs/utils/utils.js +39 -0
  114. package/database/dist/commonjs/validate.d.ts +1 -0
  115. package/database/dist/commonjs/validate.js +60 -0
  116. package/database/dist/esm/aggregate.d.ts +29 -0
  117. package/database/dist/esm/aggregate.js +154 -0
  118. package/database/dist/esm/collection.d.ts +9 -0
  119. package/database/dist/esm/collection.js +46 -0
  120. package/database/dist/esm/command.d.ts +175 -0
  121. package/database/dist/esm/command.js +296 -0
  122. package/database/dist/esm/commands/logic.d.ts +24 -0
  123. package/database/dist/esm/commands/logic.js +84 -0
  124. package/database/dist/esm/commands/query.d.ts +68 -0
  125. package/database/dist/esm/commands/query.js +154 -0
  126. package/database/dist/esm/commands/update.d.ts +29 -0
  127. package/database/dist/esm/commands/update.js +46 -0
  128. package/database/dist/esm/config/app.config.d.ts +6 -0
  129. package/database/dist/esm/config/app.config.js +5 -0
  130. package/database/dist/esm/config/error.config.d.ts +3 -0
  131. package/database/dist/esm/config/error.config.js +13 -0
  132. package/database/dist/esm/const/code.d.ts +30 -0
  133. package/database/dist/esm/const/code.js +30 -0
  134. package/database/dist/esm/constant.d.ts +51 -0
  135. package/database/dist/esm/constant.js +65 -0
  136. package/database/dist/esm/document.d.ts +11 -0
  137. package/database/dist/esm/document.js +257 -0
  138. package/database/dist/esm/geo/index.d.ts +6 -0
  139. package/database/dist/esm/geo/index.js +6 -0
  140. package/database/dist/esm/geo/interface.d.ts +24 -0
  141. package/database/dist/esm/geo/interface.js +1 -0
  142. package/database/dist/esm/geo/lineString.d.ts +19 -0
  143. package/database/dist/esm/geo/lineString.js +83 -0
  144. package/database/dist/esm/geo/multiLineString.d.ts +18 -0
  145. package/database/dist/esm/geo/multiLineString.js +92 -0
  146. package/database/dist/esm/geo/multiPoint.d.ts +18 -0
  147. package/database/dist/esm/geo/multiPoint.js +76 -0
  148. package/database/dist/esm/geo/multiPolygon.d.ts +18 -0
  149. package/database/dist/esm/geo/multiPolygon.js +119 -0
  150. package/database/dist/esm/geo/point.d.ts +19 -0
  151. package/database/dist/esm/geo/point.js +47 -0
  152. package/database/dist/esm/geo/polygon.d.ts +19 -0
  153. package/database/dist/esm/geo/polygon.js +106 -0
  154. package/database/dist/esm/helper/symbol.d.ts +14 -0
  155. package/database/dist/esm/helper/symbol.js +14 -0
  156. package/database/dist/esm/index.d.ts +40 -0
  157. package/database/dist/esm/index.js +55 -0
  158. package/database/dist/esm/lib/util.d.ts +1 -0
  159. package/database/dist/esm/lib/util.js +22 -0
  160. package/database/dist/esm/operator-map.d.ts +4 -0
  161. package/database/dist/esm/operator-map.js +20 -0
  162. package/database/dist/esm/query.d.ts +22 -0
  163. package/database/dist/esm/query.js +249 -0
  164. package/database/dist/esm/regexp/index.d.ts +14 -0
  165. package/database/dist/esm/regexp/index.js +29 -0
  166. package/database/dist/esm/serializer/common.d.ts +11 -0
  167. package/database/dist/esm/serializer/common.js +118 -0
  168. package/database/dist/esm/serializer/datatype.d.ts +7 -0
  169. package/database/dist/esm/serializer/datatype.js +127 -0
  170. package/database/dist/esm/serializer/query.d.ts +7 -0
  171. package/database/dist/esm/serializer/query.js +229 -0
  172. package/database/dist/esm/serializer/update.d.ts +15 -0
  173. package/database/dist/esm/serializer/update.js +139 -0
  174. package/database/dist/esm/serverDate/index.d.ts +13 -0
  175. package/database/dist/esm/serverDate/index.js +26 -0
  176. package/database/dist/esm/transaction/collection.d.ts +7 -0
  177. package/database/dist/esm/transaction/collection.js +46 -0
  178. package/database/dist/esm/transaction/document.d.ts +27 -0
  179. package/database/dist/esm/transaction/document.js +202 -0
  180. package/database/dist/esm/transaction/index.d.ts +30 -0
  181. package/database/dist/esm/transaction/index.js +210 -0
  182. package/database/dist/esm/transaction/query.d.ts +43 -0
  183. package/database/dist/esm/transaction/query.js +258 -0
  184. package/database/dist/esm/typings/index.d.ts +40 -0
  185. package/database/dist/esm/typings/index.js +1 -0
  186. package/database/dist/esm/typings/realtime.d.ts +219 -0
  187. package/database/dist/esm/typings/realtime.js +1 -0
  188. package/database/dist/esm/util.d.ts +9 -0
  189. package/database/dist/esm/util.js +142 -0
  190. package/database/dist/esm/utils/error.d.ts +38 -0
  191. package/database/dist/esm/utils/error.js +84 -0
  192. package/database/dist/esm/utils/msg.d.ts +0 -0
  193. package/database/dist/esm/utils/msg.js +0 -0
  194. package/database/dist/esm/utils/symbol.d.ts +8 -0
  195. package/database/dist/esm/utils/symbol.js +55 -0
  196. package/database/dist/esm/utils/type.d.ts +13 -0
  197. package/database/dist/esm/utils/type.js +20 -0
  198. package/database/dist/esm/utils/utils.d.ts +4 -0
  199. package/database/dist/esm/utils/utils.js +33 -0
  200. package/database/dist/esm/validate.d.ts +1 -0
  201. package/database/dist/esm/validate.js +57 -0
  202. package/database/package.json +34 -4
  203. package/dist/index.cjs.js +3 -40
  204. package/dist/index.cjs.js.LICENSE.txt +12 -0
  205. package/dist/index.cjs.js.map +1 -0
  206. package/dist/index.d.ts +9 -0
  207. package/dist/index.esm.js +3 -35
  208. package/dist/index.esm.js.LICENSE.txt +12 -0
  209. package/dist/index.esm.js.map +1 -0
  210. package/functions/dist/index.d.ts +2 -2
  211. package/functions/dist/index.esm.js +2 -8
  212. package/functions/dist/index.esm.js.map +1 -0
  213. package/functions/dist/index.js +2 -13
  214. package/functions/dist/index.js.map +1 -0
  215. package/index.d.ts +654 -45
  216. package/miniprogram_dist/ai.js +1 -1
  217. package/miniprogram_dist/apis.js +1 -1
  218. package/miniprogram_dist/app.js +1 -1
  219. package/miniprogram_dist/auth.js +1 -1
  220. package/miniprogram_dist/cloudrun.js +1 -1
  221. package/miniprogram_dist/container.js +1 -1
  222. package/miniprogram_dist/database.js +1 -1
  223. package/miniprogram_dist/functions.js +1 -1
  224. package/miniprogram_dist/index.js +1 -1
  225. package/miniprogram_dist/model.js +1 -1
  226. package/miniprogram_dist/mysql.js +1 -1
  227. package/miniprogram_dist/oauth.js +2 -1
  228. package/miniprogram_dist/realtime.js +1 -1
  229. package/miniprogram_dist/storage.js +1 -1
  230. package/model/dist/index.esm.js +2 -3
  231. package/model/dist/index.esm.js.map +1 -0
  232. package/model/dist/index.js +2 -21
  233. package/model/dist/index.js.map +1 -0
  234. package/mysql/dist/index.esm.js +2 -3
  235. package/mysql/dist/index.esm.js.map +1 -0
  236. package/mysql/dist/index.js +2 -21
  237. package/mysql/dist/index.js.map +1 -0
  238. package/oauth/dist/index.esm.js +3 -3
  239. package/oauth/dist/index.esm.js.LICENSE.txt +12 -0
  240. package/oauth/dist/index.esm.js.map +1 -0
  241. package/oauth/dist/index.js +3 -21
  242. package/oauth/dist/index.js.LICENSE.txt +12 -0
  243. package/oauth/dist/index.js.map +1 -0
  244. package/package.json +113 -20
  245. package/realtime/dist/index.d.ts +2 -2
  246. package/realtime/dist/index.esm.js +2 -8
  247. package/realtime/dist/index.esm.js.map +1 -0
  248. package/realtime/dist/index.js +2 -13
  249. package/realtime/dist/index.js.map +1 -0
  250. package/storage/dist/index.d.ts +2 -2
  251. package/storage/dist/index.esm.js +2 -4
  252. package/storage/dist/index.esm.js.map +1 -0
  253. package/storage/dist/index.js +2 -9
  254. package/storage/dist/index.js.map +1 -0
  255. package/types/analytics.d.ts +51 -0
  256. package/types/auth.d.ts +99 -0
  257. package/types/cache.d.ts +26 -0
  258. package/types/cloudrun.d.ts +9 -0
  259. package/types/component.d.ts +17 -0
  260. package/types/container.d.ts +93 -0
  261. package/types/database.d.ts +31 -0
  262. package/types/events.d.ts +13 -0
  263. package/types/functions.d.ts +40 -0
  264. package/types/index.d.ts +211 -0
  265. package/types/package.json +43 -0
  266. package/types/realtime.d.ts +350 -0
  267. package/types/request.d.ts +30 -0
  268. package/types/storage.d.ts +126 -0
  269. package/utilities/dist/cjs/adapters/index.d.ts +45 -0
  270. package/utilities/dist/cjs/adapters/index.js +68 -0
  271. package/utilities/dist/cjs/adapters/platforms/web.d.ts +20 -0
  272. package/utilities/dist/cjs/adapters/platforms/web.js +286 -0
  273. package/utilities/dist/cjs/constants/common.d.ts +6 -0
  274. package/utilities/dist/cjs/constants/common.js +24 -0
  275. package/utilities/dist/cjs/constants/errors.d.ts +8 -0
  276. package/utilities/dist/cjs/constants/errors.js +12 -0
  277. package/utilities/dist/cjs/constants/index.d.ts +3 -0
  278. package/utilities/dist/cjs/constants/index.js +21 -0
  279. package/utilities/dist/cjs/helpers/decorators.d.ts +11 -0
  280. package/utilities/dist/cjs/helpers/decorators.js +238 -0
  281. package/utilities/dist/cjs/helpers/index.d.ts +1 -0
  282. package/utilities/dist/cjs/helpers/index.js +18 -0
  283. package/utilities/dist/cjs/index.d.ts +13 -0
  284. package/utilities/dist/cjs/index.js +51 -0
  285. package/utilities/dist/cjs/libs/abortController.d.ts +9 -0
  286. package/utilities/dist/cjs/libs/abortController.js +25 -0
  287. package/utilities/dist/cjs/libs/cache.d.ts +17 -0
  288. package/utilities/dist/cjs/libs/cache.js +261 -0
  289. package/utilities/dist/cjs/libs/events.d.ts +27 -0
  290. package/utilities/dist/cjs/libs/events.js +108 -0
  291. package/utilities/dist/cjs/libs/langEvent.d.ts +3 -0
  292. package/utilities/dist/cjs/libs/langEvent.js +7 -0
  293. package/utilities/dist/cjs/libs/util.d.ts +49 -0
  294. package/utilities/dist/cjs/libs/util.js +282 -0
  295. package/utilities/dist/esm/adapters/index.d.ts +45 -0
  296. package/utilities/dist/esm/adapters/index.js +40 -0
  297. package/utilities/dist/esm/adapters/platforms/web.d.ts +20 -0
  298. package/utilities/dist/esm/adapters/platforms/web.js +282 -0
  299. package/utilities/dist/esm/constants/common.d.ts +6 -0
  300. package/utilities/dist/esm/constants/common.js +17 -0
  301. package/utilities/dist/esm/constants/errors.d.ts +8 -0
  302. package/utilities/dist/esm/constants/errors.js +9 -0
  303. package/utilities/dist/esm/constants/index.d.ts +3 -0
  304. package/utilities/dist/esm/constants/index.js +4 -0
  305. package/utilities/dist/esm/helpers/decorators.d.ts +11 -0
  306. package/utilities/dist/esm/helpers/decorators.js +234 -0
  307. package/utilities/dist/esm/helpers/index.d.ts +1 -0
  308. package/utilities/dist/esm/helpers/index.js +2 -0
  309. package/utilities/dist/esm/index.d.ts +13 -0
  310. package/utilities/dist/esm/index.js +14 -0
  311. package/utilities/dist/esm/libs/abortController.d.ts +9 -0
  312. package/utilities/dist/esm/libs/abortController.js +23 -0
  313. package/utilities/dist/esm/libs/cache.d.ts +17 -0
  314. package/utilities/dist/esm/libs/cache.js +258 -0
  315. package/utilities/dist/esm/libs/events.d.ts +27 -0
  316. package/utilities/dist/esm/libs/events.js +102 -0
  317. package/utilities/dist/esm/libs/langEvent.d.ts +3 -0
  318. package/utilities/dist/esm/libs/langEvent.js +4 -0
  319. package/utilities/dist/esm/libs/util.d.ts +49 -0
  320. package/utilities/dist/esm/libs/util.js +254 -0
  321. package/utilities/dist/miniprogram/index.js +1 -0
  322. package/utilities/package.json +26 -0
  323. package/analytics/dist/index.d.ts +0 -2
  324. package/analytics/dist/index.esm.js +0 -4
  325. package/analytics/dist/index.js +0 -9
  326. package/analytics/package.json +0 -6
  327. package/database/dist/index.d.ts +0 -3
  328. package/database/dist/index.esm.js +0 -503
  329. package/database/dist/index.js +0 -509
  330. package/miniprogram_dist/analytics.js +0 -1
@@ -0,0 +1,258 @@
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
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
13
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
14
+ return new (P || (P = Promise))(function (resolve, reject) {
15
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
16
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
17
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
18
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
19
+ });
20
+ };
21
+ var __generator = (this && this.__generator) || function (thisArg, body) {
22
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
23
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
24
+ function verb(n) { return function (v) { return step([n, v]); }; }
25
+ function step(op) {
26
+ if (f) throw new TypeError("Generator is already executing.");
27
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
28
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
29
+ if (y = 0, t) op = [op[0] & 2, t.value];
30
+ switch (op[0]) {
31
+ case 0: case 1: t = op; break;
32
+ case 4: _.label++; return { value: op[1], done: false };
33
+ case 5: _.label++; y = op[1]; op = [0]; continue;
34
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
35
+ default:
36
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
37
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
38
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
39
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
40
+ if (t[2]) _.ops.pop();
41
+ _.trys.pop(); continue;
42
+ }
43
+ op = body.call(thisArg, _);
44
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
45
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
46
+ }
47
+ };
48
+ import { EJSON } from 'bson';
49
+ import { ErrorCode } from '../constant';
50
+ import { Validate } from '../validate';
51
+ import { QuerySerializer } from '../serializer/query';
52
+ import { UpdateSerializer } from '../serializer/update';
53
+ import { Util } from '../util';
54
+ var GET_DOC = 'database.getInTransaction';
55
+ var UPDATE_DOC = 'database.updateDocInTransaction';
56
+ var DELETE_DOC = 'database.deleteDocInTransaction';
57
+ var Query = (function () {
58
+ function Query(transaction, coll, fieldFilters, fieldOrders, queryOptions) {
59
+ this._coll = coll;
60
+ this._transaction = transaction;
61
+ this._fieldFilters = fieldFilters;
62
+ this._fieldOrders = fieldOrders || [];
63
+ this._queryOptions = queryOptions || {};
64
+ this._request = this._transaction.getRequestMethod();
65
+ this._transactionId = this._transaction.getTransactionId();
66
+ }
67
+ Query.prototype.where = function (query) {
68
+ if (Object.prototype.toString.call(query).slice(8, -1) !== 'Object') {
69
+ throw Error(ErrorCode.QueryParamTypeError);
70
+ }
71
+ var keys = Object.keys(query);
72
+ var checkFlag = keys.some(function (item) {
73
+ return query[item] !== undefined;
74
+ });
75
+ if (keys.length && !checkFlag) {
76
+ throw Error(ErrorCode.QueryParamValueError);
77
+ }
78
+ return new Query(this._transaction, this._coll, QuerySerializer.encode(query), this._fieldOrders, this._queryOptions);
79
+ };
80
+ Query.prototype.orderBy = function (fieldPath, directionStr) {
81
+ Validate.isFieldPath(fieldPath);
82
+ Validate.isFieldOrder(directionStr);
83
+ var newOrder = {
84
+ field: fieldPath,
85
+ direction: directionStr
86
+ };
87
+ var combinedOrders = this._fieldOrders.concat(newOrder);
88
+ return new Query(this._transaction, this._coll, this._fieldFilters, combinedOrders, this._queryOptions);
89
+ };
90
+ Query.prototype.limit = function (limit) {
91
+ Validate.isInteger('limit', limit);
92
+ var option = __assign({}, this._queryOptions);
93
+ option.limit = limit;
94
+ return new Query(this._transaction, this._coll, this._fieldFilters, this._fieldOrders, option);
95
+ };
96
+ Query.prototype.skip = function (offset) {
97
+ Validate.isInteger('offset', offset);
98
+ var option = __assign({}, this._queryOptions);
99
+ option.offset = offset;
100
+ return new Query(this._transaction, this._coll, this._fieldFilters, this._fieldOrders, option);
101
+ };
102
+ Query.prototype.field = function (projection) {
103
+ for (var k in projection) {
104
+ if (projection[k]) {
105
+ if (typeof projection[k] !== 'object') {
106
+ projection[k] = 1;
107
+ }
108
+ }
109
+ else {
110
+ projection[k] = 0;
111
+ }
112
+ }
113
+ var option = __assign({}, this._queryOptions);
114
+ option.projection = projection;
115
+ return new Query(this._transaction, this._coll, this._fieldFilters, this._fieldOrders, option);
116
+ };
117
+ Query.prototype.get = function () {
118
+ return __awaiter(this, void 0, void 0, function () {
119
+ var newOrder, param, res, data, documents, result;
120
+ return __generator(this, function (_a) {
121
+ switch (_a.label) {
122
+ case 0:
123
+ newOrder = [];
124
+ if (this._fieldOrders) {
125
+ this._fieldOrders.forEach(function (order) {
126
+ newOrder.push(order);
127
+ });
128
+ }
129
+ param = {
130
+ collectionName: this._coll,
131
+ transactionId: this._transactionId
132
+ };
133
+ if (this._fieldFilters) {
134
+ param.query = this._fieldFilters;
135
+ }
136
+ if (newOrder.length > 0) {
137
+ param.order = newOrder;
138
+ }
139
+ if (this._queryOptions.offset) {
140
+ param.offset = this._queryOptions.offset;
141
+ }
142
+ if (this._queryOptions.limit) {
143
+ param.limit = this._queryOptions.limit < 1000 ? this._queryOptions.limit : 1000;
144
+ }
145
+ else {
146
+ param.limit = 100;
147
+ }
148
+ if (this._queryOptions.projection) {
149
+ param.projection = this._queryOptions.projection;
150
+ }
151
+ return [4, this._request.send(GET_DOC, param)];
152
+ case 1:
153
+ res = _a.sent();
154
+ if (res.code)
155
+ throw res;
156
+ data = res.data !== 'null' ? EJSON.parse(res.data) : null;
157
+ documents = data ? (Array.isArray(data) ? Util.formatResDocumentData(data) : [Util.formatField(data)]) : [];
158
+ result = {
159
+ data: documents,
160
+ requestId: res.requestId
161
+ };
162
+ if (res.total !== undefined)
163
+ result.total = res.total;
164
+ if (res.limit !== undefined)
165
+ result.limit = res.limit;
166
+ if (res.offset !== undefined)
167
+ result.offset = res.offset;
168
+ return [2, result];
169
+ }
170
+ });
171
+ });
172
+ };
173
+ Query.prototype.count = function () {
174
+ return __awaiter(this, void 0, void 0, function () {
175
+ var param, res, data, total;
176
+ return __generator(this, function (_a) {
177
+ switch (_a.label) {
178
+ case 0:
179
+ param = {
180
+ collectionName: this._coll,
181
+ transactionId: this._transactionId
182
+ };
183
+ if (this._fieldFilters) {
184
+ param.query = this._fieldFilters;
185
+ }
186
+ return [4, this._request.send(GET_DOC, param)];
187
+ case 1:
188
+ res = _a.sent();
189
+ if (res.code)
190
+ throw res;
191
+ data = res.data !== 'null' ? EJSON.parse(res.data) : null;
192
+ total = Array.isArray(data) ? data.length : (data ? 1 : 0);
193
+ return [2, {
194
+ requestId: res.requestId,
195
+ total: res.total !== undefined ? res.total : total
196
+ }];
197
+ }
198
+ });
199
+ });
200
+ };
201
+ Query.prototype.update = function (data) {
202
+ return __awaiter(this, void 0, void 0, function () {
203
+ var param, res;
204
+ return __generator(this, function (_a) {
205
+ switch (_a.label) {
206
+ case 0:
207
+ if (!data || typeof data !== 'object') {
208
+ throw new Error('参数必需是非空对象');
209
+ }
210
+ if (data.hasOwnProperty('_id')) {
211
+ throw new Error('不能更新_id的值');
212
+ }
213
+ param = {
214
+ collectionName: this._coll,
215
+ transactionId: this._transactionId,
216
+ query: this._fieldFilters,
217
+ data: EJSON.stringify(UpdateSerializer.encode(data), { relaxed: false })
218
+ };
219
+ return [4, this._request.send(UPDATE_DOC, param)];
220
+ case 1:
221
+ res = _a.sent();
222
+ if (res.code)
223
+ throw res;
224
+ return [2, __assign(__assign({}, res), { updated: EJSON.parse(res.updated) })];
225
+ }
226
+ });
227
+ });
228
+ };
229
+ Query.prototype.remove = function () {
230
+ return __awaiter(this, void 0, void 0, function () {
231
+ var param, res;
232
+ return __generator(this, function (_a) {
233
+ switch (_a.label) {
234
+ case 0:
235
+ if (Object.keys(this._queryOptions).length > 0) {
236
+ console.warn('`offset`, `limit` and `projection` are not supported in remove() operation');
237
+ }
238
+ if (this._fieldOrders.length > 0) {
239
+ console.warn('`orderBy` is not supported in remove() operation');
240
+ }
241
+ param = {
242
+ collectionName: this._coll,
243
+ transactionId: this._transactionId,
244
+ query: this._fieldFilters
245
+ };
246
+ return [4, this._request.send(DELETE_DOC, param)];
247
+ case 1:
248
+ res = _a.sent();
249
+ if (res.code)
250
+ throw res;
251
+ return [2, __assign(__assign({}, res), { deleted: EJSON.parse(res.deleted) })];
252
+ }
253
+ });
254
+ });
255
+ };
256
+ return Query;
257
+ }());
258
+ export { Query };
@@ -0,0 +1,40 @@
1
+ export type DataType = 'init' | 'update' | 'add' | 'remove' | 'replace' | 'limit';
2
+ export type QueueType = 'init' | 'enqueue' | 'dequeue' | 'update';
3
+ export interface IDatabaseServiceContext extends IServiceContext {
4
+ appConfig: IAppConfig;
5
+ ws?: any;
6
+ }
7
+ export interface IAppConfig {
8
+ docSizeLimit: number;
9
+ realtimePingInterval: number;
10
+ realtimePongWaitTimeout: number;
11
+ request: any;
12
+ }
13
+ export interface IWatchOptions {
14
+ onChange: (snapshot: ISnapshot) => void;
15
+ onError: (error: any) => void;
16
+ }
17
+ export interface ISnapshot {
18
+ id: number;
19
+ docChanges: ISingleDBEvent[];
20
+ docs: Record<string, any>;
21
+ type?: SnapshotType;
22
+ }
23
+ export interface ISingleDBEvent {
24
+ id: number;
25
+ dataType: DataType;
26
+ queueType: QueueType;
27
+ docId: string;
28
+ doc: Record<string, any>;
29
+ updatedFields?: any;
30
+ removedFields?: any;
31
+ }
32
+ export type SnapshotType = 'init';
33
+ export interface DBRealtimeListener {
34
+ close: () => void;
35
+ }
36
+ export interface IRealtimeListenerConstructorOptions extends IWatchOptions {
37
+ }
38
+ export interface IServiceContext {
39
+ env?: string;
40
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,219 @@
1
+ import { DataType, QueueType } from './index';
2
+ export type IRequestMsgType = 'LOGIN' | 'INIT_WATCH' | 'REBUILD_WATCH' | 'CHECK_LAST' | 'CLOSE_WATCH' | 'PING';
3
+ export type IResponseMsgType = 'LOGIN_RES' | 'INIT_EVENT' | 'NEXT_EVENT' | 'CHECK_EVENT' | 'PONG' | 'ERROR';
4
+ export interface IRequestMessageBase<W extends boolean = true> {
5
+ watchId: W extends true ? string : undefined;
6
+ requestId: string;
7
+ msgType: IRequestMsgType;
8
+ msgData: IRequestMessageMsgData;
9
+ }
10
+ export type IRequestMessageMsgData = IRequestMessageInitWatchData | IRequestMessageLoginData | IRequestMessageRebuildWatchData | IRequestMessageCheckLastData | IRequestMessageCloseWatchData | IRequestMessagePingData;
11
+ export type IRequestMessage = IRequestMessageInitWatchMsg | IRequestMessageLoginMsg | IRequestMessageRebuildWatchMsg | IRequestMessageCheckLastMsg | IRequestMessageCloseWatchMsg | IRequestMessagePingMsg;
12
+ export interface IRequestMessageLoginData {
13
+ envId: string;
14
+ accessToken: string;
15
+ referrer: 'web';
16
+ sdkVersion: string;
17
+ dataVersion: string;
18
+ }
19
+ export interface IRequestExtraMessageLoginData {
20
+ runtime: string;
21
+ signStr: string;
22
+ secretVersion: string;
23
+ }
24
+ export interface IRequestMessageLoginMsg extends IRequestMessageBase<false> {
25
+ msgType: 'LOGIN';
26
+ msgData: IRequestMessageLoginData;
27
+ exMsgData?: IRequestExtraMessageLoginData;
28
+ }
29
+ export interface IRequestMessageInitWatchData {
30
+ envId: string;
31
+ collName: string;
32
+ query: string;
33
+ limit?: number;
34
+ orderBy?: Record<string, string>;
35
+ }
36
+ export interface IRequestMessageInitWatchMsg extends IRequestMessageBase {
37
+ msgType: 'INIT_WATCH';
38
+ msgData: IRequestMessageInitWatchData;
39
+ }
40
+ export interface IRequestMessageRebuildWatchData {
41
+ envId: string;
42
+ collName: string;
43
+ queryID: string;
44
+ eventID: number;
45
+ }
46
+ export interface IRequestMessageRebuildWatchMsg extends IRequestMessageBase {
47
+ msgType: 'REBUILD_WATCH';
48
+ msgData: IRequestMessageRebuildWatchData;
49
+ }
50
+ export interface IRequestMessageCheckLastData {
51
+ queryID: string;
52
+ eventID: number;
53
+ }
54
+ export interface IRequestMessageCheckLastMsg extends IRequestMessageBase {
55
+ msgType: 'CHECK_LAST';
56
+ msgData: IRequestMessageCheckLastData;
57
+ }
58
+ export type IRequestMessageCloseWatchData = null;
59
+ export interface IRequestMessageCloseWatchMsg extends IRequestMessageBase {
60
+ msgType: 'CLOSE_WATCH';
61
+ msgData: IRequestMessageCloseWatchData;
62
+ }
63
+ export type IRequestMessagePingData = null;
64
+ export interface IRequestMessagePingMsg extends IRequestMessageBase<false> {
65
+ msgType: 'PING';
66
+ msgData: IRequestMessagePingData;
67
+ }
68
+ export interface IResponseMessageBase<W extends boolean = true> {
69
+ watchId: W extends true ? string : undefined;
70
+ requestId: string;
71
+ msgType: IResponseMsgType;
72
+ msgData: IResponseMessageMsgData;
73
+ }
74
+ export type IResponseMessageMsgData = IResponseMessageLoginResData | IResponseMessageInitEventData | IResponseMessageNextEventData | IResponseMessageCheckEventData | IResponseMessagePongData | IResponseMessageErrorData;
75
+ export type IResponseMessage = IResponseMessageLoginResMsg | IResponseMessageInitEventMsg | IResponseMessageNextEventMsg | IResponseMessageCheckEventMsg | IResponseMessagePongMsg | IResponseMessageErrorMsg;
76
+ export type IResponseMessageLoginResData = {
77
+ envId: string;
78
+ } & Partial<IResponseMessageErrorData>;
79
+ export interface IResponseMessageLoginResMsg extends IResponseMessageBase<false> {
80
+ msgType: 'LOGIN_RES';
81
+ msgData: IResponseMessageLoginResData;
82
+ }
83
+ export interface IResponseMessageInitEventData {
84
+ queryID: string;
85
+ currEvent: number;
86
+ events: IDBEvent[];
87
+ }
88
+ export interface IResponseMessageInitEventMsg extends IResponseMessageBase {
89
+ msgType: 'INIT_EVENT';
90
+ msgData: IResponseMessageInitEventData;
91
+ }
92
+ export interface IResponseMessageNextEventData {
93
+ queryID: string;
94
+ currEvent: number;
95
+ events: IDBEvent[];
96
+ }
97
+ export interface IResponseMessageNextEventMsg extends IResponseMessageBase {
98
+ msgType: 'NEXT_EVENT';
99
+ msgData: IResponseMessageNextEventData;
100
+ }
101
+ export interface IResponseMessageCheckEventData {
102
+ queryID: string;
103
+ currEvent: number;
104
+ }
105
+ export interface IResponseMessageCheckEventMsg extends IResponseMessageBase {
106
+ msgType: 'CHECK_EVENT';
107
+ msgData: IResponseMessageCheckEventData;
108
+ }
109
+ export type IResponseMessagePongData = null;
110
+ export interface IResponseMessagePongMsg extends IResponseMessageBase {
111
+ msgType: 'PONG';
112
+ msgData: IResponseMessagePongData;
113
+ }
114
+ export type IResponseMessageErrorData = {
115
+ message: string;
116
+ } & ({
117
+ code: 'SYS_ERR';
118
+ } | {
119
+ code: 'CHECK_LOGIN_FAILED';
120
+ } | {
121
+ code: 'SIGN_INVALID_ERROR';
122
+ } | {
123
+ code: 'SIGN_EXPIRED_ERROR';
124
+ } | {
125
+ code: 'INVALIID_ENV';
126
+ } | {
127
+ code: 'SIGN_PARAM_INVALID';
128
+ } | {
129
+ code: 'COLLECTION_PERMISSION_DENIED';
130
+ } | {
131
+ code: 'QUERYID_INVALID_ERROR';
132
+ });
133
+ export interface IResponseMessageErrorMsg extends IResponseMessageBase {
134
+ msgType: 'ERROR';
135
+ msgData: IResponseMessageErrorData;
136
+ }
137
+ export type IDBEvent = IDBInitEvent | IDBNextEvent;
138
+ export interface IDBEventBase {
139
+ ID: number;
140
+ DataType: DataType;
141
+ QueueType: QueueType;
142
+ DocID: string;
143
+ Doc: string;
144
+ }
145
+ export interface IDBInitEvent extends IDBEventBase {
146
+ DataType: 'init';
147
+ QueueType: 'init';
148
+ UpdatedFields?: any;
149
+ removedFields?: any;
150
+ }
151
+ export type IDBNextEvent = IDBNextEventDataUpdate | IDBNextEventDataReplace | IDBNextEventDataAdd | IDBNextEventDataRemove | IDBNextEventDataLimit;
152
+ export type IDBNextEventDataUpdate = IDBNextEventDataUpdateQueueUpdate | IDBNextEventDataUpdateQueueEnqueue | IDBNextEventDataUpdateQueueDequeue;
153
+ export type IDBNextEventDataReplace = IDBNextEventDataReplaceQueueUpdate | IDBNextEventDataReplaceQueueEnqueue | IDBNextEventDataReplaceQueueDequeue;
154
+ export type IDBNextEventDataLimit = IDBNextEventDataLimitQueueEnqueue | IDBNextEventDataLimitQueueDequeue;
155
+ export interface IDBNextEventDataUpdateQueueUpdate extends IDBEventBase {
156
+ DataType: 'update';
157
+ QueueType: 'update';
158
+ Doc: '';
159
+ UpdatedFields: string;
160
+ RemovedFields: string;
161
+ }
162
+ export interface IDBNextEventDataUpdateQueueEnqueue extends IDBEventBase {
163
+ DataType: 'update';
164
+ QueueType: 'enqueue';
165
+ Doc: string;
166
+ UpdatedFields: string;
167
+ RemovedFields: string;
168
+ }
169
+ export interface IDBNextEventDataUpdateQueueDequeue extends IDBEventBase {
170
+ DataType: 'update';
171
+ QueueType: 'dequeue';
172
+ Doc: '';
173
+ UpdatedFields: string;
174
+ RemovedFields: string;
175
+ }
176
+ export interface IDBNextEventDataReplaceQueueUpdate extends IDBEventBase {
177
+ DataType: 'replace';
178
+ QueueType: 'update';
179
+ Doc: string;
180
+ UpdatedFields: '';
181
+ RemovedFields: '';
182
+ }
183
+ export interface IDBNextEventDataReplaceQueueEnqueue extends IDBEventBase {
184
+ DataType: 'replace';
185
+ QueueType: 'enqueue';
186
+ Doc: string;
187
+ UpdatedFields: '';
188
+ RemovedFields: '';
189
+ }
190
+ export interface IDBNextEventDataReplaceQueueDequeue extends IDBEventBase {
191
+ DataType: 'replace';
192
+ QueueType: 'dequeue';
193
+ Doc: string;
194
+ UpdatedFields: '';
195
+ RemovedFields: '';
196
+ }
197
+ export interface IDBNextEventDataAdd extends IDBEventBase {
198
+ DataType: 'add';
199
+ QueueType: 'enqueue';
200
+ }
201
+ export interface IDBNextEventDataRemove extends IDBEventBase {
202
+ DataType: 'remove';
203
+ QueueType: 'dequeue';
204
+ Doc: '';
205
+ }
206
+ export interface IDBNextEventDataLimitQueueEnqueue extends IDBEventBase {
207
+ DataType: 'limit';
208
+ QueueType: 'enqueue';
209
+ Doc: string;
210
+ UpdatedFields: '';
211
+ RemovedFields: '';
212
+ }
213
+ export interface IDBNextEventDataLimitQueueDequeue extends IDBEventBase {
214
+ DataType: 'limit';
215
+ QueueType: 'dequeue';
216
+ Doc: '';
217
+ UpdatedFields: '';
218
+ RemovedFields: '';
219
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,9 @@
1
+ interface DocumentModel {
2
+ _id: string;
3
+ }
4
+ export declare class Util {
5
+ static formatResDocumentData: (documents: DocumentModel[]) => {}[];
6
+ static whichType: (obj: any) => String;
7
+ static generateDocId: () => string;
8
+ }
9
+ export {};
@@ -0,0 +1,142 @@
1
+ var __read = (this && this.__read) || function (o, n) {
2
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
3
+ if (!m) return o;
4
+ var i = m.call(o), r, ar = [], e;
5
+ try {
6
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
7
+ }
8
+ catch (error) { e = { error: error }; }
9
+ finally {
10
+ try {
11
+ if (r && !r.done && (m = i["return"])) m.call(i);
12
+ }
13
+ finally { if (e) throw e.error; }
14
+ }
15
+ return ar;
16
+ };
17
+ import { FieldType } from './constant';
18
+ import { Point, LineString, Polygon, MultiPoint, MultiLineString, MultiPolygon } from './geo/index';
19
+ import { ServerDate } from './serverDate/index';
20
+ var Util = (function () {
21
+ function Util() {
22
+ }
23
+ Util.formatResDocumentData = function (documents) {
24
+ return documents.map(function (document) {
25
+ return Util.formatField(document);
26
+ });
27
+ };
28
+ Util.formatField = function (document) {
29
+ var keys = Object.keys(document);
30
+ var protoField = {};
31
+ if (Array.isArray(document)) {
32
+ protoField = [];
33
+ }
34
+ keys.forEach(function (key) {
35
+ var item = document[key];
36
+ var type = Util.whichType(item);
37
+ var realValue;
38
+ switch (type) {
39
+ case FieldType.GeoPoint:
40
+ realValue = new Point(item.coordinates[0], item.coordinates[1]);
41
+ break;
42
+ case FieldType.GeoLineString:
43
+ realValue = new LineString(item.coordinates.map(function (point) { return new Point(point[0], point[1]); }));
44
+ break;
45
+ case FieldType.GeoPolygon:
46
+ realValue = new Polygon(item.coordinates.map(function (line) { return new LineString(line.map(function (_a) {
47
+ var _b = __read(_a, 2), lng = _b[0], lat = _b[1];
48
+ return new Point(lng, lat);
49
+ })); }));
50
+ break;
51
+ case FieldType.GeoMultiPoint:
52
+ realValue = new MultiPoint(item.coordinates.map(function (point) { return new Point(point[0], point[1]); }));
53
+ break;
54
+ case FieldType.GeoMultiLineString:
55
+ realValue = new MultiLineString(item.coordinates.map(function (line) { return new LineString(line.map(function (_a) {
56
+ var _b = __read(_a, 2), lng = _b[0], lat = _b[1];
57
+ return new Point(lng, lat);
58
+ })); }));
59
+ break;
60
+ case FieldType.GeoMultiPolygon:
61
+ realValue = new MultiPolygon(item.coordinates.map(function (polygon) {
62
+ return new Polygon(polygon.map(function (line) { return new LineString(line.map(function (_a) {
63
+ var _b = __read(_a, 2), lng = _b[0], lat = _b[1];
64
+ return new Point(lng, lat);
65
+ })); }));
66
+ }));
67
+ break;
68
+ case FieldType.Timestamp:
69
+ realValue = new Date(item.$timestamp * 1000);
70
+ break;
71
+ case FieldType.Object:
72
+ case FieldType.Array:
73
+ realValue = Util.formatField(item);
74
+ break;
75
+ case FieldType.ServerDate:
76
+ realValue = new Date(item.$date);
77
+ break;
78
+ default:
79
+ realValue = item;
80
+ }
81
+ if (Array.isArray(protoField)) {
82
+ protoField.push(realValue);
83
+ }
84
+ else {
85
+ protoField[key] = realValue;
86
+ }
87
+ });
88
+ return protoField;
89
+ };
90
+ Util.whichType = function (obj) {
91
+ var type = Object.prototype.toString.call(obj).slice(8, -1);
92
+ if (type === FieldType.Timestamp) {
93
+ return FieldType.BsonDate;
94
+ }
95
+ if (type === FieldType.Object) {
96
+ if (obj instanceof Point) {
97
+ return FieldType.GeoPoint;
98
+ }
99
+ else if (obj instanceof Date) {
100
+ return FieldType.Timestamp;
101
+ }
102
+ else if (obj instanceof ServerDate) {
103
+ return FieldType.ServerDate;
104
+ }
105
+ if (obj.$timestamp) {
106
+ type = FieldType.Timestamp;
107
+ }
108
+ else if (obj.$date) {
109
+ type = FieldType.ServerDate;
110
+ }
111
+ else if (Point.validate(obj)) {
112
+ type = FieldType.GeoPoint;
113
+ }
114
+ else if (LineString.validate(obj)) {
115
+ type = FieldType.GeoLineString;
116
+ }
117
+ else if (Polygon.validate(obj)) {
118
+ type = FieldType.GeoPolygon;
119
+ }
120
+ else if (MultiPoint.validate(obj)) {
121
+ type = FieldType.GeoMultiPoint;
122
+ }
123
+ else if (MultiLineString.validate(obj)) {
124
+ type = FieldType.GeoMultiLineString;
125
+ }
126
+ else if (MultiPolygon.validate(obj)) {
127
+ type = FieldType.GeoMultiPolygon;
128
+ }
129
+ }
130
+ return type;
131
+ };
132
+ Util.generateDocId = function () {
133
+ var chars = 'ABCDEFabcdef0123456789';
134
+ var autoId = '';
135
+ for (var i = 0; i < 24; i++) {
136
+ autoId += chars.charAt(Math.floor(Math.random() * chars.length));
137
+ }
138
+ return autoId;
139
+ };
140
+ return Util;
141
+ }());
142
+ export { Util };