@cloudbase/database 1.4.3-alpha.0 → 1.5.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 (194) hide show
  1. package/dist/commonjs/ObjectId/index.d.ts +1 -1
  2. package/dist/commonjs/ObjectId/index.js +16 -9
  3. package/dist/commonjs/aggregate.js +126 -75
  4. package/dist/commonjs/collection.d.ts +3 -2
  5. package/dist/commonjs/collection.js +131 -58
  6. package/dist/commonjs/command.d.ts +5 -5
  7. package/dist/commonjs/command.js +181 -154
  8. package/dist/commonjs/commands/logic.js +30 -20
  9. package/dist/commonjs/commands/query.d.ts +1 -1
  10. package/dist/commonjs/commands/query.js +85 -65
  11. package/dist/commonjs/commands/update.js +9 -7
  12. package/dist/commonjs/config/error.config.js +1 -0
  13. package/dist/commonjs/const/code.js +1 -0
  14. package/dist/commonjs/constant.d.ts +7 -7
  15. package/dist/commonjs/constant.js +13 -11
  16. package/dist/commonjs/document.d.ts +10 -6
  17. package/dist/commonjs/document.js +305 -193
  18. package/dist/commonjs/geo/index.js +20 -9
  19. package/dist/commonjs/geo/lineString.d.ts +1 -1
  20. package/dist/commonjs/geo/lineString.js +62 -33
  21. package/dist/commonjs/geo/multiLineString.d.ts +1 -1
  22. package/dist/commonjs/geo/multiLineString.js +71 -32
  23. package/dist/commonjs/geo/multiPoint.d.ts +1 -1
  24. package/dist/commonjs/geo/multiPoint.js +58 -29
  25. package/dist/commonjs/geo/multiPolygon.d.ts +1 -1
  26. package/dist/commonjs/geo/multiPolygon.js +96 -36
  27. package/dist/commonjs/geo/point.d.ts +1 -1
  28. package/dist/commonjs/geo/point.js +30 -23
  29. package/dist/commonjs/geo/polygon.d.ts +1 -1
  30. package/dist/commonjs/geo/polygon.js +78 -39
  31. package/dist/commonjs/helper/symbol.js +17 -5
  32. package/dist/commonjs/index.d.ts +8 -2
  33. package/dist/commonjs/index.js +73 -20
  34. package/dist/commonjs/lib/util.js +4 -3
  35. package/dist/commonjs/operator-map.js +7 -6
  36. package/dist/commonjs/query.d.ts +8 -4
  37. package/dist/commonjs/query.js +308 -201
  38. package/dist/commonjs/regexp/index.d.ts +1 -1
  39. package/dist/commonjs/regexp/index.js +16 -9
  40. package/dist/commonjs/serializer/common.d.ts +2 -2
  41. package/dist/commonjs/serializer/common.js +59 -22
  42. package/dist/commonjs/serializer/datatype.d.ts +2 -2
  43. package/dist/commonjs/serializer/datatype.js +58 -21
  44. package/dist/commonjs/serializer/query.d.ts +1 -1
  45. package/dist/commonjs/serializer/query.js +137 -127
  46. package/dist/commonjs/serializer/update.d.ts +1 -1
  47. package/dist/commonjs/serializer/update.js +83 -78
  48. package/dist/commonjs/serverDate/index.d.ts +1 -1
  49. package/dist/commonjs/serverDate/index.js +16 -9
  50. package/dist/commonjs/transaction/collection.d.ts +1 -1
  51. package/dist/commonjs/transaction/collection.js +5 -2
  52. package/dist/commonjs/transaction/document.d.ts +1 -1
  53. package/dist/commonjs/transaction/document.js +5 -5
  54. package/dist/commonjs/transaction/index.js +196 -86
  55. package/dist/commonjs/transaction/query.d.ts +39 -1
  56. package/dist/commonjs/transaction/query.js +252 -1
  57. package/dist/commonjs/typings/index.d.ts +4 -4
  58. package/dist/commonjs/typings/realtime.d.ts +16 -16
  59. package/dist/commonjs/util.js +123 -92
  60. package/dist/commonjs/utils/error.d.ts +2 -1
  61. package/dist/commonjs/utils/error.js +74 -38
  62. package/dist/commonjs/utils/symbol.js +33 -14
  63. package/dist/commonjs/utils/type.d.ts +1 -1
  64. package/dist/commonjs/utils/type.js +25 -13
  65. package/dist/commonjs/utils/utils.d.ts +4 -1
  66. package/dist/commonjs/utils/utils.js +93 -22
  67. package/dist/commonjs/validate.js +79 -63
  68. package/dist/esm/ObjectId/index.d.ts +1 -1
  69. package/dist/esm/ObjectId/index.js +15 -8
  70. package/dist/esm/aggregate.js +118 -66
  71. package/dist/esm/collection.d.ts +3 -2
  72. package/dist/esm/collection.js +125 -52
  73. package/dist/esm/command.d.ts +5 -5
  74. package/dist/esm/command.js +175 -147
  75. package/dist/esm/commands/logic.js +30 -20
  76. package/dist/esm/commands/query.d.ts +1 -1
  77. package/dist/esm/commands/query.js +91 -71
  78. package/dist/esm/commands/update.js +8 -6
  79. package/dist/esm/config/error.config.js +1 -1
  80. package/dist/esm/const/code.js +1 -1
  81. package/dist/esm/constant.d.ts +7 -7
  82. package/dist/esm/constant.js +12 -11
  83. package/dist/esm/document.d.ts +10 -6
  84. package/dist/esm/document.js +297 -185
  85. package/dist/esm/geo/interface.js +1 -0
  86. package/dist/esm/geo/lineString.d.ts +1 -1
  87. package/dist/esm/geo/lineString.js +57 -28
  88. package/dist/esm/geo/multiLineString.d.ts +1 -1
  89. package/dist/esm/geo/multiLineString.js +66 -27
  90. package/dist/esm/geo/multiPoint.d.ts +1 -1
  91. package/dist/esm/geo/multiPoint.js +53 -24
  92. package/dist/esm/geo/multiPolygon.d.ts +1 -1
  93. package/dist/esm/geo/multiPolygon.js +91 -31
  94. package/dist/esm/geo/point.d.ts +1 -1
  95. package/dist/esm/geo/point.js +26 -19
  96. package/dist/esm/geo/polygon.d.ts +1 -1
  97. package/dist/esm/geo/polygon.js +73 -34
  98. package/dist/esm/helper/symbol.js +13 -13
  99. package/dist/esm/index.d.ts +8 -2
  100. package/dist/esm/index.js +62 -9
  101. package/dist/esm/lib/util.js +1 -2
  102. package/dist/esm/operator-map.js +4 -4
  103. package/dist/esm/query.d.ts +8 -4
  104. package/dist/esm/query.js +299 -192
  105. package/dist/esm/regexp/index.d.ts +1 -1
  106. package/dist/esm/regexp/index.js +15 -8
  107. package/dist/esm/serializer/common.d.ts +2 -2
  108. package/dist/esm/serializer/common.js +49 -13
  109. package/dist/esm/serializer/datatype.d.ts +2 -2
  110. package/dist/esm/serializer/datatype.js +44 -8
  111. package/dist/esm/serializer/query.d.ts +1 -1
  112. package/dist/esm/serializer/query.js +112 -102
  113. package/dist/esm/serializer/update.d.ts +1 -1
  114. package/dist/esm/serializer/update.js +69 -64
  115. package/dist/esm/serverDate/index.d.ts +1 -1
  116. package/dist/esm/serverDate/index.js +15 -8
  117. package/dist/esm/transaction/collection.d.ts +1 -1
  118. package/dist/esm/transaction/collection.js +4 -2
  119. package/dist/esm/transaction/document.d.ts +1 -1
  120. package/dist/esm/transaction/document.js +2 -3
  121. package/dist/esm/transaction/index.js +191 -81
  122. package/dist/esm/transaction/query.d.ts +39 -1
  123. package/dist/esm/transaction/query.js +251 -1
  124. package/dist/esm/typings/index.d.ts +4 -4
  125. package/dist/esm/typings/index.js +1 -0
  126. package/dist/esm/typings/realtime.d.ts +16 -16
  127. package/dist/esm/typings/realtime.js +1 -0
  128. package/dist/esm/util.js +121 -90
  129. package/dist/esm/utils/error.d.ts +2 -1
  130. package/dist/esm/utils/error.js +70 -35
  131. package/dist/esm/utils/symbol.js +33 -14
  132. package/dist/esm/utils/type.d.ts +1 -1
  133. package/dist/esm/utils/type.js +12 -12
  134. package/dist/esm/utils/utils.d.ts +4 -1
  135. package/dist/esm/utils/utils.js +78 -16
  136. package/dist/esm/validate.js +65 -49
  137. package/jest.config.js +14 -0
  138. package/package.json +14 -10
  139. package/src/aggregate.ts +1 -5
  140. package/src/collection.ts +15 -2
  141. package/src/document.ts +45 -34
  142. package/src/index.ts +51 -4
  143. package/src/query.ts +33 -29
  144. package/src/serializer/query.ts +18 -6
  145. package/src/transaction/index.ts +1 -1
  146. package/src/typings/index.ts +0 -4
  147. package/src/utils/utils.ts +46 -0
  148. package/src/validate.ts +3 -6
  149. package/tests/gateway-contract.test.ts +180 -0
  150. package/tests/index.test.ts +283 -0
  151. package/tests/transaction-query.test.ts +207 -0
  152. package/tsconfig.esm.json +4 -2
  153. package/tsconfig.json +16 -6
  154. package/tsconfig.test.json +15 -0
  155. package/dist/commonjs/realtime/error.d.ts +0 -7
  156. package/dist/commonjs/realtime/error.js +0 -11
  157. package/dist/commonjs/realtime/listener.d.ts +0 -14
  158. package/dist/commonjs/realtime/listener.js +0 -17
  159. package/dist/commonjs/realtime/message.d.ts +0 -3
  160. package/dist/commonjs/realtime/message.js +0 -10
  161. package/dist/commonjs/realtime/snapshot.d.ts +0 -16
  162. package/dist/commonjs/realtime/snapshot.js +0 -42
  163. package/dist/commonjs/realtime/virtual-websocket-client.d.ts +0 -63
  164. package/dist/commonjs/realtime/virtual-websocket-client.js +0 -736
  165. package/dist/commonjs/realtime/websocket-client.d.ts +0 -78
  166. package/dist/commonjs/realtime/websocket-client.js +0 -567
  167. package/dist/commonjs/realtime/ws-event.d.ts +0 -126
  168. package/dist/commonjs/realtime/ws-event.js +0 -139
  169. package/dist/commonjs/transaction.d.ts +0 -42
  170. package/dist/commonjs/transaction.js +0 -126
  171. package/dist/esm/realtime/error.d.ts +0 -7
  172. package/dist/esm/realtime/error.js +0 -8
  173. package/dist/esm/realtime/listener.d.ts +0 -14
  174. package/dist/esm/realtime/listener.js +0 -14
  175. package/dist/esm/realtime/message.d.ts +0 -3
  176. package/dist/esm/realtime/message.js +0 -6
  177. package/dist/esm/realtime/snapshot.d.ts +0 -16
  178. package/dist/esm/realtime/snapshot.js +0 -39
  179. package/dist/esm/realtime/virtual-websocket-client.d.ts +0 -63
  180. package/dist/esm/realtime/virtual-websocket-client.js +0 -733
  181. package/dist/esm/realtime/websocket-client.d.ts +0 -78
  182. package/dist/esm/realtime/websocket-client.js +0 -564
  183. package/dist/esm/realtime/ws-event.d.ts +0 -126
  184. package/dist/esm/realtime/ws-event.js +0 -137
  185. package/dist/esm/transaction.d.ts +0 -42
  186. package/dist/esm/transaction.js +0 -121
  187. package/src/realtime/error.ts +0 -19
  188. package/src/realtime/listener.ts +0 -35
  189. package/src/realtime/message.ts +0 -14
  190. package/src/realtime/snapshot.ts +0 -60
  191. package/src/realtime/virtual-websocket-client.ts +0 -1195
  192. package/src/realtime/websocket-client.ts +0 -995
  193. package/src/realtime/ws-event.ts +0 -163
  194. package/src/transaction.ts +0 -190
@@ -1,70 +1,109 @@
1
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
+ };
2
13
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const symbol_1 = require("../helper/symbol");
4
- const type_1 = require("../utils/type");
5
- const lineString_1 = require("./lineString");
6
- class Polygon {
7
- constructor(lines) {
8
- if (!type_1.isArray(lines)) {
9
- throw new TypeError(`"lines" must be of type LineString[]. Received type ${typeof lines}`);
14
+ exports.Polygon = void 0;
15
+ var symbol_1 = require("../helper/symbol");
16
+ var type_1 = require("../utils/type");
17
+ var lineString_1 = require("./lineString");
18
+ var Polygon = (function () {
19
+ function Polygon(lines) {
20
+ if (!(0, type_1.isArray)(lines)) {
21
+ throw new TypeError("\"lines\" must be of type LineString[]. Received type ".concat(typeof lines));
10
22
  }
11
23
  if (lines.length === 0) {
12
24
  throw new Error('Polygon must contain 1 linestring at least');
13
25
  }
14
- lines.forEach(line => {
26
+ lines.forEach(function (line) {
15
27
  if (!(line instanceof lineString_1.LineString)) {
16
- throw new TypeError(`"lines" must be of type LineString[]. Received type ${typeof line}[]`);
28
+ throw new TypeError("\"lines\" must be of type LineString[]. Received type ".concat(typeof line, "[]"));
17
29
  }
18
30
  if (!lineString_1.LineString.isClosed(line)) {
19
- throw new Error(`LineString ${line.points.map(p => p.toReadableString())} is not a closed cycle`);
31
+ throw new Error("LineString ".concat(line.points.map(function (p) { return p.toReadableString(); }), " is not a closed cycle"));
20
32
  }
21
33
  });
22
34
  this.lines = lines;
23
35
  }
24
- parse(key) {
25
- return {
26
- [key]: {
36
+ Polygon.prototype.parse = function (key) {
37
+ var _a;
38
+ return _a = {},
39
+ _a[key] = {
27
40
  type: 'Polygon',
28
- coordinates: this.lines.map(line => {
29
- return line.points.map(point => [point.longitude, point.latitude]);
41
+ coordinates: this.lines.map(function (line) {
42
+ return line.points.map(function (point) { return [point.longitude, point.latitude]; });
30
43
  })
31
- }
32
- };
33
- }
34
- toJSON() {
44
+ },
45
+ _a;
46
+ };
47
+ Polygon.prototype.toJSON = function () {
35
48
  return {
36
49
  type: 'Polygon',
37
- coordinates: this.lines.map(line => {
38
- return line.points.map(point => [point.longitude, point.latitude]);
50
+ coordinates: this.lines.map(function (line) {
51
+ return line.points.map(function (point) { return [point.longitude, point.latitude]; });
39
52
  })
40
53
  };
41
- }
42
- static validate(polygon) {
43
- if (polygon.type !== 'Polygon' || !type_1.isArray(polygon.coordinates)) {
54
+ };
55
+ Polygon.validate = function (polygon) {
56
+ var e_1, _a, e_2, _b;
57
+ if (polygon.type !== 'Polygon' || !(0, type_1.isArray)(polygon.coordinates)) {
44
58
  return false;
45
59
  }
46
- for (let line of polygon.coordinates) {
47
- if (!this.isCloseLineString(line)) {
48
- return false;
49
- }
50
- for (let point of line) {
51
- if (!type_1.isNumber(point[0]) || !type_1.isNumber(point[1])) {
60
+ try {
61
+ for (var _c = __values(polygon.coordinates), _d = _c.next(); !_d.done; _d = _c.next()) {
62
+ var line = _d.value;
63
+ if (!this.isCloseLineString(line)) {
52
64
  return false;
53
65
  }
66
+ try {
67
+ 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()) {
68
+ var point = line_1_1.value;
69
+ if (!(0, type_1.isNumber)(point[0]) || !(0, type_1.isNumber)(point[1])) {
70
+ return false;
71
+ }
72
+ }
73
+ }
74
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
75
+ finally {
76
+ try {
77
+ if (line_1_1 && !line_1_1.done && (_b = line_1.return)) _b.call(line_1);
78
+ }
79
+ finally { if (e_2) throw e_2.error; }
80
+ }
81
+ }
82
+ }
83
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
84
+ finally {
85
+ try {
86
+ if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
54
87
  }
88
+ finally { if (e_1) throw e_1.error; }
55
89
  }
56
90
  return true;
57
- }
58
- static isCloseLineString(lineString) {
59
- const firstPoint = lineString[0];
60
- const lastPoint = lineString[lineString.length - 1];
91
+ };
92
+ Polygon.isCloseLineString = function (lineString) {
93
+ var firstPoint = lineString[0];
94
+ var lastPoint = lineString[lineString.length - 1];
61
95
  if (firstPoint[0] !== lastPoint[0] || firstPoint[1] !== lastPoint[1]) {
62
96
  return false;
63
97
  }
64
98
  return true;
65
- }
66
- get _internalType() {
67
- return symbol_1.SYMBOL_GEO_POLYGON;
68
- }
69
- }
99
+ };
100
+ Object.defineProperty(Polygon.prototype, "_internalType", {
101
+ get: function () {
102
+ return symbol_1.SYMBOL_GEO_POLYGON;
103
+ },
104
+ enumerable: false,
105
+ configurable: true
106
+ });
107
+ return Polygon;
108
+ }());
70
109
  exports.Polygon = Polygon;
@@ -1,10 +1,22 @@
1
1
  "use strict";
2
- function __export(m) {
3
- for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
4
- }
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
+ };
5
16
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const symbol_1 = require("../utils/symbol");
7
- __export(require("../utils/symbol"));
17
+ exports.SYMBOL_OBJECTID = exports.SYMBOL_REGEXP = exports.SYMBOL_SERVER_DATE = exports.SYMBOL_GEO_MULTI_POLYGON = exports.SYMBOL_GEO_MULTI_LINE_STRING = exports.SYMBOL_GEO_MULTI_POINT = exports.SYMBOL_GEO_POLYGON = exports.SYMBOL_GEO_LINE_STRING = exports.SYMBOL_GEO_POINT = exports.SYMBOL_LOGIC_COMMAND = exports.SYMBOL_QUERY_COMMAND = exports.SYMBOL_UPDATE_COMMAND = exports.SYMBOL_UNSET_FIELD_NAME = void 0;
18
+ var symbol_1 = require("../utils/symbol");
19
+ __exportStar(require("../utils/symbol"), exports);
8
20
  exports.SYMBOL_UNSET_FIELD_NAME = symbol_1.default.for('UNSET_FIELD_NAME');
9
21
  exports.SYMBOL_UPDATE_COMMAND = symbol_1.default.for('UPDATE_COMMAND');
10
22
  exports.SYMBOL_QUERY_COMMAND = symbol_1.default.for('QUERY_COMMAND');
@@ -1,13 +1,14 @@
1
1
  import { Point } from './geo/point';
2
2
  import { CollectionReference } from './collection';
3
3
  import { Command } from './command';
4
+ export type IDbConfig = ICloudBaseConfig;
4
5
  interface GeoTeyp {
5
6
  Point: typeof Point;
6
7
  }
7
8
  export { Query } from './query';
8
9
  export { CollectionReference } from './collection';
9
10
  export { DocumentReference } from './document';
10
- interface ICloudBaseConfig {
11
+ export interface ICloudBaseConfig {
11
12
  timeout?: number;
12
13
  isHttp?: boolean;
13
14
  secretId?: string;
@@ -37,16 +38,21 @@ export declare class Db {
37
38
  ObjectId: any;
38
39
  startTransaction: any;
39
40
  runTransaction: any;
41
+ logicCommand: any;
42
+ updateCommand: any;
43
+ queryCommand: any;
40
44
  config: ICloudBaseConfig;
41
45
  static ws: any;
42
46
  static reqClass: any;
43
47
  static wsClass: any;
48
+ static wsClientClass: any;
44
49
  static createSign: Function;
45
50
  static getAccessToken: Function;
46
51
  static dataVersion: string;
47
52
  static runtime: string;
48
53
  static appSecretInfo: any;
49
- constructor(config?: any);
54
+ static createRequest(config: ICloudBaseConfig): any;
55
+ constructor(config?: ICloudBaseConfig);
50
56
  collection(collName: string): CollectionReference;
51
57
  createCollection(collName: string): any;
52
58
  }
@@ -1,20 +1,49 @@
1
1
  "use strict";
2
+ var __read = (this && this.__read) || function (o, n) {
3
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
4
+ if (!m) return o;
5
+ var i = m.call(o), r, ar = [], e;
6
+ try {
7
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
8
+ }
9
+ catch (error) { e = { error: error }; }
10
+ finally {
11
+ try {
12
+ if (r && !r.done && (m = i["return"])) m.call(i);
13
+ }
14
+ finally { if (e) throw e.error; }
15
+ }
16
+ return ar;
17
+ };
18
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
19
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
20
+ if (ar || !(i in from)) {
21
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
22
+ ar[i] = from[i];
23
+ }
24
+ }
25
+ return to.concat(ar || Array.prototype.slice.call(from));
26
+ };
2
27
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const Geo = require("./geo/index");
4
- const collection_1 = require("./collection");
5
- const command_1 = require("./command");
6
- const index_1 = require("./serverDate/index");
7
- const index_2 = require("./regexp/index");
8
- const index_3 = require("./transaction/index");
9
- const index_4 = require("./ObjectId/index");
10
- var query_1 = require("./query");
11
- exports.Query = query_1.Query;
28
+ exports.Db = exports.DocumentReference = exports.CollectionReference = exports.Query = void 0;
29
+ var Geo = require("./geo/index");
30
+ var collection_1 = require("./collection");
31
+ var command_1 = require("./command");
32
+ var index_1 = require("./serverDate/index");
33
+ var index_2 = require("./regexp/index");
34
+ var index_3 = require("./transaction/index");
35
+ var logic_1 = require("./commands/logic");
36
+ var query_1 = require("./commands/query");
37
+ var update_1 = require("./commands/update");
38
+ var index_4 = require("./ObjectId/index");
39
+ var query_2 = require("./query");
40
+ Object.defineProperty(exports, "Query", { enumerable: true, get: function () { return query_2.Query; } });
12
41
  var collection_2 = require("./collection");
13
- exports.CollectionReference = collection_2.CollectionReference;
42
+ Object.defineProperty(exports, "CollectionReference", { enumerable: true, get: function () { return collection_2.CollectionReference; } });
14
43
  var document_1 = require("./document");
15
- exports.DocumentReference = document_1.DocumentReference;
16
- class Db {
17
- constructor(config) {
44
+ Object.defineProperty(exports, "DocumentReference", { enumerable: true, get: function () { return document_1.DocumentReference; } });
45
+ var Db = (function () {
46
+ function Db(config) {
18
47
  this.config = config;
19
48
  this.Geo = Geo;
20
49
  this.serverDate = index_1.ServerDateConstructor;
@@ -23,19 +52,43 @@ class Db {
23
52
  this.ObjectId = index_4.ObjectIdConstructor;
24
53
  this.startTransaction = index_3.startTransaction;
25
54
  this.runTransaction = index_3.runTransaction;
55
+ this.logicCommand = logic_1.LogicCommand;
56
+ this.updateCommand = update_1.UpdateCommand;
57
+ this.queryCommand = query_1.QueryCommand;
26
58
  }
27
- collection(collName) {
59
+ Db.createRequest = function (config) {
60
+ var request = new Db.reqClass(config);
61
+ var originalSend = request.send;
62
+ request.send = function (action, data) {
63
+ var args = [];
64
+ for (var _i = 2; _i < arguments.length; _i++) {
65
+ args[_i - 2] = arguments[_i];
66
+ }
67
+ if (data) {
68
+ if (config.instance) {
69
+ data.instance = config.instance;
70
+ }
71
+ if (config.database) {
72
+ data.database = config.database;
73
+ }
74
+ }
75
+ return originalSend.call.apply(originalSend, __spreadArray([this, action, data], __read(args), false));
76
+ };
77
+ return request;
78
+ };
79
+ Db.prototype.collection = function (collName) {
28
80
  if (!collName) {
29
81
  throw new Error('Collection name is required');
30
82
  }
31
83
  return new collection_1.CollectionReference(this, collName);
32
- }
33
- createCollection(collName) {
34
- let request = new Db.reqClass(this.config);
35
- const params = {
84
+ };
85
+ Db.prototype.createCollection = function (collName) {
86
+ var request = Db.createRequest(this.config);
87
+ var params = {
36
88
  collectionName: collName
37
89
  };
38
90
  return request.send('database.addCollection', params);
39
- }
40
- }
91
+ };
92
+ return Db;
93
+ }());
41
94
  exports.Db = Db;
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createPromiseCallback = function () {
4
- var cb;
3
+ exports.createPromiseCallback = void 0;
4
+ var createPromiseCallback = function () {
5
+ var cb = function () { };
5
6
  if (!Promise) {
6
- cb = function () { };
7
7
  cb.promise = {};
8
8
  var throwPromiseNotDefined = function () {
9
9
  throw new Error('Your Node runtime does support ES6 Promises. ' +
@@ -23,3 +23,4 @@ exports.createPromiseCallback = function () {
23
23
  cb.promise = promise;
24
24
  return cb;
25
25
  };
26
+ exports.createPromiseCallback = createPromiseCallback;
@@ -1,16 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const query_1 = require("./commands/query");
4
- const logic_1 = require("./commands/logic");
5
- const update_1 = require("./commands/update");
3
+ exports.operatorToString = exports.OperatorMap = void 0;
4
+ var query_1 = require("./commands/query");
5
+ var logic_1 = require("./commands/logic");
6
+ var update_1 = require("./commands/update");
6
7
  exports.OperatorMap = {};
7
- for (const key in query_1.QUERY_COMMANDS_LITERAL) {
8
+ for (var key in query_1.QUERY_COMMANDS_LITERAL) {
8
9
  exports.OperatorMap[key] = '$' + key;
9
10
  }
10
- for (const key in logic_1.LOGIC_COMMANDS_LITERAL) {
11
+ for (var key in logic_1.LOGIC_COMMANDS_LITERAL) {
11
12
  exports.OperatorMap[key] = '$' + key;
12
13
  }
13
- for (const key in update_1.UPDATE_COMMANDS_LITERAL) {
14
+ for (var key in update_1.UPDATE_COMMANDS_LITERAL) {
14
15
  exports.OperatorMap[key] = '$' + key;
15
16
  }
16
17
  exports.OperatorMap[query_1.QUERY_COMMANDS_LITERAL.NEQ] = '$ne';
@@ -22,16 +22,20 @@ export interface UpdateOption extends BaseOption {
22
22
  }
23
23
  export declare class Query {
24
24
  protected _transactionId: string;
25
- get(): Promise<GetRes>;
26
- count(): Promise<any>;
25
+ get(callback?: any): Promise<GetRes>;
26
+ private _get;
27
+ count(callback?: any): Promise<any>;
28
+ private _count;
27
29
  where(query: object): Query;
28
30
  options(apiOptions: QueryOption | UpdateOption): Query;
29
31
  orderBy(fieldPath: string, directionStr: OrderByDirection): Query;
30
32
  limit(limit: number): Query;
31
33
  skip(offset: number): Query;
32
- update(data: Object): Promise<any>;
34
+ update(data: Object, callback?: any): Promise<any>;
35
+ private _update;
33
36
  field(projection: any): Query;
34
- remove(): Promise<any>;
37
+ remove(callback?: any): Promise<any>;
38
+ private _remove;
35
39
  updateAndReturn(data: Object): Promise<any>;
36
40
  watch: (options: IWatchOptions) => DBRealtimeListener;
37
41
  }