@cloudbase/database 0.9.22 → 0.10.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (176) hide show
  1. package/coverage/lcov-report/base.css +224 -0
  2. package/coverage/lcov-report/block-navigation.js +87 -0
  3. package/coverage/lcov-report/favicon.png +0 -0
  4. package/coverage/lcov-report/index.html +101 -0
  5. package/coverage/lcov-report/prettify.css +1 -0
  6. package/coverage/lcov-report/prettify.js +2 -0
  7. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  8. package/coverage/lcov-report/sorter.js +210 -0
  9. package/coverage/lcov.info +0 -0
  10. package/dist/commonjs/aggregate.js +3 -3
  11. package/dist/commonjs/collection.d.ts +1 -1
  12. package/dist/commonjs/collection.js +5 -2
  13. package/dist/commonjs/command.d.ts +5 -5
  14. package/dist/commonjs/command.js +9 -8
  15. package/dist/commonjs/commands/logic.js +3 -2
  16. package/dist/commonjs/commands/query.js +11 -8
  17. package/dist/commonjs/commands/update.js +1 -0
  18. package/dist/commonjs/config/error.config.js +1 -0
  19. package/dist/commonjs/const/code.js +1 -0
  20. package/dist/commonjs/constant.d.ts +7 -7
  21. package/dist/commonjs/constant.js +1 -0
  22. package/dist/commonjs/document.js +11 -10
  23. package/dist/commonjs/geo/index.js +20 -9
  24. package/dist/commonjs/geo/lineString.d.ts +1 -1
  25. package/dist/commonjs/geo/lineString.js +7 -6
  26. package/dist/commonjs/geo/multiLineString.d.ts +1 -1
  27. package/dist/commonjs/geo/multiLineString.js +7 -6
  28. package/dist/commonjs/geo/multiPoint.d.ts +1 -1
  29. package/dist/commonjs/geo/multiPoint.js +7 -6
  30. package/dist/commonjs/geo/multiPolygon.d.ts +1 -1
  31. package/dist/commonjs/geo/multiPolygon.js +7 -6
  32. package/dist/commonjs/geo/point.d.ts +1 -1
  33. package/dist/commonjs/geo/point.js +4 -3
  34. package/dist/commonjs/geo/polygon.d.ts +1 -1
  35. package/dist/commonjs/geo/polygon.js +8 -7
  36. package/dist/commonjs/helper/symbol.js +16 -4
  37. package/dist/commonjs/index.d.ts +9 -2
  38. package/dist/commonjs/index.js +19 -4
  39. package/dist/commonjs/lib/util.js +4 -3
  40. package/dist/commonjs/operator-map.js +1 -0
  41. package/dist/commonjs/query.js +10 -9
  42. package/dist/commonjs/regexp/index.d.ts +1 -1
  43. package/dist/commonjs/regexp/index.js +2 -1
  44. package/dist/commonjs/serializer/common.d.ts +2 -2
  45. package/dist/commonjs/serializer/common.js +23 -17
  46. package/dist/commonjs/serializer/datatype.d.ts +2 -2
  47. package/dist/commonjs/serializer/datatype.js +20 -14
  48. package/dist/commonjs/serializer/query.d.ts +1 -1
  49. package/dist/commonjs/serializer/query.js +24 -23
  50. package/dist/commonjs/serializer/update.d.ts +1 -1
  51. package/dist/commonjs/serializer/update.js +12 -11
  52. package/dist/commonjs/serverDate/index.d.ts +1 -1
  53. package/dist/commonjs/serverDate/index.js +3 -2
  54. package/dist/commonjs/transaction/collection.d.ts +1 -1
  55. package/dist/commonjs/transaction/collection.js +5 -2
  56. package/dist/commonjs/transaction/document.d.ts +1 -1
  57. package/dist/commonjs/transaction/document.js +5 -5
  58. package/dist/commonjs/transaction/index.js +3 -2
  59. package/dist/commonjs/transaction/query.js +1 -0
  60. package/dist/commonjs/typings/index.d.ts +3 -3
  61. package/dist/commonjs/typings/realtime.d.ts +16 -16
  62. package/dist/commonjs/util.js +1 -0
  63. package/dist/commonjs/utils/error.d.ts +2 -1
  64. package/dist/commonjs/utils/error.js +15 -9
  65. package/dist/commonjs/utils/symbol.js +5 -4
  66. package/dist/commonjs/utils/type.d.ts +1 -1
  67. package/dist/commonjs/utils/type.js +23 -11
  68. package/dist/commonjs/utils/utils.js +6 -3
  69. package/dist/commonjs/validate.js +1 -0
  70. package/dist/esm/aggregate.d.ts.map +1 -0
  71. package/dist/esm/aggregate.js +3 -3
  72. package/dist/esm/collection.d.ts +1 -1
  73. package/dist/esm/collection.d.ts.map +1 -0
  74. package/dist/esm/collection.js +4 -2
  75. package/dist/esm/command.d.ts +5 -5
  76. package/dist/esm/command.d.ts.map +1 -0
  77. package/dist/esm/commands/logic.d.ts.map +1 -0
  78. package/dist/esm/commands/query.d.ts.map +1 -0
  79. package/dist/esm/commands/query.js +8 -6
  80. package/dist/esm/commands/update.d.ts.map +1 -0
  81. package/dist/esm/config/app.config.d.ts.map +1 -0
  82. package/dist/esm/config/error.config.d.ts.map +1 -0
  83. package/dist/esm/const/code.d.ts.map +1 -0
  84. package/dist/esm/constant.d.ts +7 -7
  85. package/dist/esm/constant.d.ts.map +1 -0
  86. package/dist/esm/document.d.ts.map +1 -0
  87. package/dist/esm/document.js +2 -2
  88. package/dist/esm/geo/index.d.ts.map +1 -0
  89. package/dist/esm/geo/interface.d.ts.map +1 -0
  90. package/dist/esm/geo/interface.js +1 -0
  91. package/dist/esm/geo/lineString.d.ts +1 -1
  92. package/dist/esm/geo/lineString.d.ts.map +1 -0
  93. package/dist/esm/geo/lineString.js +3 -3
  94. package/dist/esm/geo/multiLineString.d.ts +1 -1
  95. package/dist/esm/geo/multiLineString.d.ts.map +1 -0
  96. package/dist/esm/geo/multiLineString.js +3 -3
  97. package/dist/esm/geo/multiPoint.d.ts +1 -1
  98. package/dist/esm/geo/multiPoint.d.ts.map +1 -0
  99. package/dist/esm/geo/multiPoint.js +3 -3
  100. package/dist/esm/geo/multiPolygon.d.ts +1 -1
  101. package/dist/esm/geo/multiPolygon.d.ts.map +1 -0
  102. package/dist/esm/geo/multiPolygon.js +3 -3
  103. package/dist/esm/geo/point.d.ts +1 -1
  104. package/dist/esm/geo/point.d.ts.map +1 -0
  105. package/dist/esm/geo/point.js +2 -2
  106. package/dist/esm/geo/polygon.d.ts +1 -1
  107. package/dist/esm/geo/polygon.d.ts.map +1 -0
  108. package/dist/esm/geo/polygon.js +4 -4
  109. package/dist/esm/helper/symbol.d.ts.map +1 -0
  110. package/dist/esm/index.d.ts +9 -2
  111. package/dist/esm/index.d.ts.map +1 -0
  112. package/dist/esm/index.js +15 -1
  113. package/dist/esm/lib/util.d.ts.map +1 -0
  114. package/dist/esm/lib/util.js +1 -2
  115. package/dist/esm/operator-map.d.ts.map +1 -0
  116. package/dist/esm/query.d.ts.map +1 -0
  117. package/dist/esm/query.js +4 -4
  118. package/dist/esm/regexp/index.d.ts +1 -1
  119. package/dist/esm/regexp/index.d.ts.map +1 -0
  120. package/dist/esm/regexp/index.js +1 -1
  121. package/dist/esm/serializer/common.d.ts +2 -2
  122. package/dist/esm/serializer/common.d.ts.map +1 -0
  123. package/dist/esm/serializer/common.js +15 -10
  124. package/dist/esm/serializer/datatype.d.ts +2 -2
  125. package/dist/esm/serializer/datatype.d.ts.map +1 -0
  126. package/dist/esm/serializer/datatype.js +12 -7
  127. package/dist/esm/serializer/query.d.ts +1 -1
  128. package/dist/esm/serializer/query.d.ts.map +1 -0
  129. package/dist/esm/serializer/query.js +2 -2
  130. package/dist/esm/serializer/update.d.ts +1 -1
  131. package/dist/esm/serializer/update.d.ts.map +1 -0
  132. package/dist/esm/serverDate/index.d.ts +1 -1
  133. package/dist/esm/serverDate/index.d.ts.map +1 -0
  134. package/dist/esm/serverDate/index.js +2 -2
  135. package/dist/esm/transaction/collection.d.ts +1 -1
  136. package/dist/esm/transaction/collection.d.ts.map +1 -0
  137. package/dist/esm/transaction/collection.js +4 -2
  138. package/dist/esm/transaction/document.d.ts +1 -1
  139. package/dist/esm/transaction/document.d.ts.map +1 -0
  140. package/dist/esm/transaction/document.js +2 -3
  141. package/dist/esm/transaction/index.d.ts.map +1 -0
  142. package/dist/esm/transaction/index.js +2 -2
  143. package/dist/esm/transaction/query.d.ts.map +1 -0
  144. package/dist/esm/typings/index.d.ts +3 -3
  145. package/dist/esm/typings/index.d.ts.map +1 -0
  146. package/dist/esm/typings/index.js +1 -0
  147. package/dist/esm/typings/realtime.d.ts +16 -16
  148. package/dist/esm/typings/realtime.d.ts.map +1 -0
  149. package/dist/esm/typings/realtime.js +1 -0
  150. package/dist/esm/util.d.ts.map +1 -0
  151. package/dist/esm/utils/error.d.ts +2 -1
  152. package/dist/esm/utils/error.d.ts.map +1 -0
  153. package/dist/esm/utils/error.js +7 -5
  154. package/dist/esm/utils/msg.d.ts.map +1 -0
  155. package/dist/esm/utils/symbol.d.ts.map +1 -0
  156. package/dist/esm/utils/symbol.js +4 -4
  157. package/dist/esm/utils/type.d.ts +1 -1
  158. package/dist/esm/utils/type.d.ts.map +1 -0
  159. package/dist/esm/utils/utils.d.ts.map +1 -0
  160. package/dist/esm/utils/utils.js +1 -1
  161. package/dist/esm/validate.d.ts.map +1 -0
  162. package/jest.config.js +14 -0
  163. package/package.json +9 -4
  164. package/src/aggregate.ts +1 -1
  165. package/src/document.ts +1 -1
  166. package/src/index.ts +40 -4
  167. package/src/lib/util.ts +1 -2
  168. package/src/query.ts +4 -4
  169. package/src/transaction/index.ts +1 -1
  170. package/src/utils/utils.ts +1 -1
  171. package/tests/index.test.ts +111 -0
  172. package/tsconfig.esm.json +2 -1
  173. package/tsconfig.json +14 -5
  174. package/tsconfig.test.json +15 -0
  175. package/.trunk/configs/.markdownlint.yaml +0 -10
  176. package/.trunk/trunk.yaml +0 -26
@@ -14,7 +14,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
14
14
  function verb(n) { return function (v) { return step([n, v]); }; }
15
15
  function step(op) {
16
16
  if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
18
  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;
19
19
  if (y = 0, t) op = [op[0] & 2, t.value];
20
20
  switch (op[0]) {
@@ -45,7 +45,7 @@ var Aggregation = (function () {
45
45
  this._stages = [];
46
46
  if (db && collectionName) {
47
47
  this._db = db;
48
- this._request = new index_1.Db.reqClass(this._db.config);
48
+ this._request = index_1.Db.createRequest(this._db.config);
49
49
  this._collectionName = collectionName;
50
50
  }
51
51
  }
@@ -89,7 +89,7 @@ var Aggregation = (function () {
89
89
  };
90
90
  Aggregation.prototype._pipe = function (stage, param) {
91
91
  this._stages.push({
92
- stageKey: "$" + stage,
92
+ stageKey: "$".concat(stage),
93
93
  stageValue: JSON.stringify(param)
94
94
  });
95
95
  return this;
@@ -2,7 +2,7 @@ import { DocumentReference } from './document';
2
2
  import { Query } from './query';
3
3
  import Aggregation from './aggregate';
4
4
  export declare class CollectionReference extends Query {
5
- readonly name: string;
5
+ get name(): string;
6
6
  doc(docID?: string | number): DocumentReference;
7
7
  add(data: Object, callback?: any): Promise<any>;
8
8
  aggregate(): Aggregation;
@@ -3,16 +3,19 @@ var __extends = (this && this.__extends) || (function () {
3
3
  var extendStatics = function (d, b) {
4
4
  extendStatics = Object.setPrototypeOf ||
5
5
  ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
7
  return extendStatics(d, b);
8
8
  };
9
9
  return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
10
12
  extendStatics(d, b);
11
13
  function __() { this.constructor = d; }
12
14
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13
15
  };
14
16
  })();
15
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.CollectionReference = void 0;
16
19
  var document_1 = require("./document");
17
20
  var query_1 = require("./query");
18
21
  var aggregate_1 = require("./aggregate");
@@ -25,7 +28,7 @@ var CollectionReference = (function (_super) {
25
28
  get: function () {
26
29
  return this._coll;
27
30
  },
28
- enumerable: true,
31
+ enumerable: false,
29
32
  configurable: true
30
33
  });
31
34
  CollectionReference.prototype.doc = function (docID) {
@@ -2,7 +2,7 @@ import { QueryCommand } from './commands/query';
2
2
  import { LogicCommand } from './commands/logic';
3
3
  import { UpdateCommand } from './commands/update';
4
4
  import Aggregation from './aggregate';
5
- export declare type IQueryCondition = Record<string, any> | LogicCommand;
5
+ export type IQueryCondition = Record<string, any> | LogicCommand;
6
6
  export declare const Command: {
7
7
  eq(val: any): QueryCommand;
8
8
  neq(val: any): QueryCommand;
@@ -20,10 +20,10 @@ export declare const Command: {
20
20
  geoNear(val: any): QueryCommand;
21
21
  geoWithin(val: any): QueryCommand;
22
22
  geoIntersects(val: any): QueryCommand;
23
- and(...__expressions__: import("./serializer/datatype").IQueryCondition[]): LogicCommand;
24
- nor(...__expressions__: import("./serializer/datatype").IQueryCondition[]): LogicCommand;
25
- or(...__expressions__: import("./serializer/datatype").IQueryCondition[]): LogicCommand;
26
- not(...__expressions__: import("./serializer/datatype").IQueryCondition[]): LogicCommand;
23
+ and(...__expressions__: IQueryCondition[]): LogicCommand;
24
+ nor(...__expressions__: IQueryCondition[]): LogicCommand;
25
+ or(...__expressions__: IQueryCondition[]): LogicCommand;
26
+ not(...__expressions__: IQueryCondition[]): LogicCommand;
27
27
  set(val: any): UpdateCommand;
28
28
  remove(): UpdateCommand;
29
29
  inc(val: number): UpdateCommand;
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Command = void 0;
3
4
  var query_1 = require("./commands/query");
4
5
  var logic_1 = require("./commands/logic");
5
6
  var update_1 = require("./commands/update");
@@ -59,7 +60,7 @@ exports.Command = {
59
60
  for (var _i = 0; _i < arguments.length; _i++) {
60
61
  __expressions__[_i] = arguments[_i];
61
62
  }
62
- var expressions = type_1.isArray(arguments[0]) ? arguments[0] : Array.from(arguments);
63
+ var expressions = (0, type_1.isArray)(arguments[0]) ? arguments[0] : Array.from(arguments);
63
64
  return new logic_1.LogicCommand(logic_1.LOGIC_COMMANDS_LITERAL.AND, expressions);
64
65
  },
65
66
  nor: function () {
@@ -67,7 +68,7 @@ exports.Command = {
67
68
  for (var _i = 0; _i < arguments.length; _i++) {
68
69
  __expressions__[_i] = arguments[_i];
69
70
  }
70
- var expressions = type_1.isArray(arguments[0]) ? arguments[0] : Array.from(arguments);
71
+ var expressions = (0, type_1.isArray)(arguments[0]) ? arguments[0] : Array.from(arguments);
71
72
  return new logic_1.LogicCommand(logic_1.LOGIC_COMMANDS_LITERAL.NOR, expressions);
72
73
  },
73
74
  or: function () {
@@ -75,7 +76,7 @@ exports.Command = {
75
76
  for (var _i = 0; _i < arguments.length; _i++) {
76
77
  __expressions__[_i] = arguments[_i];
77
78
  }
78
- var expressions = type_1.isArray(arguments[0]) ? arguments[0] : Array.from(arguments);
79
+ var expressions = (0, type_1.isArray)(arguments[0]) ? arguments[0] : Array.from(arguments);
79
80
  return new logic_1.LogicCommand(logic_1.LOGIC_COMMANDS_LITERAL.OR, expressions);
80
81
  },
81
82
  not: function () {
@@ -83,7 +84,7 @@ exports.Command = {
83
84
  for (var _i = 0; _i < arguments.length; _i++) {
84
85
  __expressions__[_i] = arguments[_i];
85
86
  }
86
- var expressions = type_1.isArray(arguments[0]) ? arguments[0] : Array.from(arguments);
87
+ var expressions = (0, type_1.isArray)(arguments[0]) ? arguments[0] : Array.from(arguments);
87
88
  return new logic_1.LogicCommand(logic_1.LOGIC_COMMANDS_LITERAL.NOT, expressions);
88
89
  },
89
90
  set: function (val) {
@@ -104,7 +105,7 @@ exports.Command = {
104
105
  args[_i] = arguments[_i];
105
106
  }
106
107
  var values;
107
- if (type_1.isObject(args[0]) && args[0].hasOwnProperty('each')) {
108
+ if ((0, type_1.isObject)(args[0]) && args[0].hasOwnProperty('each')) {
108
109
  var options = args[0];
109
110
  values = {
110
111
  $each: options.each,
@@ -113,7 +114,7 @@ exports.Command = {
113
114
  $slice: options.slice
114
115
  };
115
116
  }
116
- else if (type_1.isArray(args[0])) {
117
+ else if ((0, type_1.isArray)(args[0])) {
117
118
  values = args[0];
118
119
  }
119
120
  else {
@@ -138,7 +139,7 @@ exports.Command = {
138
139
  for (var _i = 0; _i < arguments.length; _i++) {
139
140
  __values__[_i] = arguments[_i];
140
141
  }
141
- var values = type_1.isArray(arguments[0]) ? arguments[0] : Array.from(arguments);
142
+ var values = (0, type_1.isArray)(arguments[0]) ? arguments[0] : Array.from(arguments);
142
143
  return new update_1.UpdateCommand(update_1.UPDATE_COMMANDS_LITERAL.UNSHIFT, values);
143
144
  },
144
145
  addToSet: function (values) {
@@ -167,7 +168,7 @@ exports.Command = {
167
168
  };
168
169
  },
169
170
  text: function (values) {
170
- if (type_1.isString(values)) {
171
+ if ((0, type_1.isString)(values)) {
171
172
  return {
172
173
  $search: values.search
173
174
  };
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isKnownLogicCommand = exports.isLogicCommand = exports.LogicCommand = exports.LOGIC_COMMANDS_LITERAL = exports.NOR = exports.NOT = exports.OR = exports.AND = void 0;
3
4
  var symbol_1 = require("../helper/symbol");
4
5
  var query_1 = require("./query");
5
6
  exports.AND = 'and';
@@ -31,14 +32,14 @@ var LogicCommand = (function () {
31
32
  this.operands = operands;
32
33
  for (var i = 0, len = operands.length; i < len; i++) {
33
34
  var query = operands[i];
34
- if (isLogicCommand(query) || query_1.isQueryCommand(query)) {
35
+ if (isLogicCommand(query) || (0, query_1.isQueryCommand)(query)) {
35
36
  operands[i] = query._setFieldName(this.fieldName);
36
37
  }
37
38
  }
38
39
  }
39
40
  else {
40
41
  var query = operands;
41
- if (isLogicCommand(query) || query_1.isQueryCommand(query)) {
42
+ if (isLogicCommand(query) || (0, query_1.isQueryCommand)(query)) {
42
43
  operands = query._setFieldName(this.fieldName);
43
44
  }
44
45
  }
@@ -3,16 +3,19 @@ var __extends = (this && this.__extends) || (function () {
3
3
  var extendStatics = function (d, b) {
4
4
  extendStatics = Object.setPrototypeOf ||
5
5
  ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
7
  return extendStatics(d, b);
8
8
  };
9
9
  return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
10
12
  extendStatics(d, b);
11
13
  function __() { this.constructor = d; }
12
14
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13
15
  };
14
16
  })();
15
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.isComparisonCommand = exports.isKnownQueryCommand = exports.isQueryCommand = exports.QueryCommand = exports.QUERY_COMMANDS_LITERAL = exports.MOD = exports.SIZE = exports.EXISTS = exports.ELEM_MATCH = exports.ALL = exports.NIN = exports.IN = exports.LTE = exports.LT = exports.GTE = exports.GT = exports.NEQ = exports.EQ = void 0;
16
19
  var logic_1 = require("./logic");
17
20
  var symbol_1 = require("../helper/symbol");
18
21
  var index_1 = require("../geo/index");
@@ -109,20 +112,20 @@ var QueryCommand = (function (_super) {
109
112
  };
110
113
  QueryCommand.prototype.geoNear = function (val) {
111
114
  if (!(val.geometry instanceof index_1.Point)) {
112
- throw new TypeError("\"geometry\" must be of type Point. Received type " + typeof val.geometry);
115
+ throw new TypeError("\"geometry\" must be of type Point. Received type ".concat(typeof val.geometry));
113
116
  }
114
- if (val.maxDistance !== undefined && !type_1.isNumber(val.maxDistance)) {
115
- throw new TypeError("\"maxDistance\" must be of type Number. Received type " + typeof val.maxDistance);
117
+ if (val.maxDistance !== undefined && !(0, type_1.isNumber)(val.maxDistance)) {
118
+ throw new TypeError("\"maxDistance\" must be of type Number. Received type ".concat(typeof val.maxDistance));
116
119
  }
117
- if (val.minDistance !== undefined && !type_1.isNumber(val.minDistance)) {
118
- throw new TypeError("\"minDistance\" must be of type Number. Received type " + typeof val.minDistance);
120
+ if (val.minDistance !== undefined && !(0, type_1.isNumber)(val.minDistance)) {
121
+ throw new TypeError("\"minDistance\" must be of type Number. Received type ".concat(typeof val.minDistance));
119
122
  }
120
123
  var command = new QueryCommand(QUERY_COMMANDS_LITERAL.GEO_NEAR, [val], this.fieldName);
121
124
  return this.and(command);
122
125
  };
123
126
  QueryCommand.prototype.geoWithin = function (val) {
124
127
  if (!(val.geometry instanceof index_1.MultiPolygon) && !(val.geometry instanceof index_1.Polygon)) {
125
- throw new TypeError("\"geometry\" must be of type Polygon or MultiPolygon. Received type " + typeof val.geometry);
128
+ throw new TypeError("\"geometry\" must be of type Polygon or MultiPolygon. Received type ".concat(typeof val.geometry));
126
129
  }
127
130
  var command = new QueryCommand(QUERY_COMMANDS_LITERAL.GEO_WITHIN, [val], this.fieldName);
128
131
  return this.and(command);
@@ -134,7 +137,7 @@ var QueryCommand = (function (_super) {
134
137
  !(val.geometry instanceof index_1.MultiPoint) &&
135
138
  !(val.geometry instanceof index_1.MultiLineString) &&
136
139
  !(val.geometry instanceof index_1.MultiPolygon)) {
137
- throw new TypeError("\"geometry\" must be of type Point, LineString, Polygon, MultiPoint, MultiLineString or MultiPolygon. Received type " + typeof val.geometry);
140
+ throw new TypeError("\"geometry\" must be of type Point, LineString, Polygon, MultiPoint, MultiLineString or MultiPolygon. Received type ".concat(typeof val.geometry));
138
141
  }
139
142
  var command = new QueryCommand(QUERY_COMMANDS_LITERAL.GEO_INTERSECTS, [val], this.fieldName);
140
143
  return this.and(command);
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isKnownUpdateCommand = exports.isUpdateCommand = exports.UpdateCommand = exports.UPDATE_COMMANDS_LITERAL = void 0;
3
4
  var symbol_1 = require("../helper/symbol");
4
5
  var UPDATE_COMMANDS_LITERAL;
5
6
  (function (UPDATE_COMMANDS_LITERAL) {
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ERR_CODE = void 0;
3
4
  exports.ERR_CODE = {
4
5
  UNKNOWN_ERROR: 'UNKNOWN_ERROR',
5
6
  SDK_DATABASE_REALTIME_LISTENER_INIT_WATCH_FAIL: 'SDK_DATABASE_REALTIME_LISTENER_INIT_WATCH_FAIL',
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ERRORS = void 0;
3
4
  exports.ERRORS = {
4
5
  CREATE_WATCH_NET_ERROR: {
5
6
  code: 'CREATE_WATCH_NET_ERROR',
@@ -25,9 +25,9 @@ declare const FieldType: {
25
25
  ServerDate: string;
26
26
  BsonDate: string;
27
27
  };
28
- declare type OrderByDirection = 'desc' | 'asc';
28
+ type OrderByDirection = 'desc' | 'asc';
29
29
  declare const OrderDirectionList: string[];
30
- declare type WhereFilterOp = '<' | '<=' | '==' | '>=' | '>';
30
+ type WhereFilterOp = '<' | '<=' | '==' | '>=' | '>';
31
31
  declare const WhereFilterOpList: string[];
32
32
  declare enum Opeartor {
33
33
  lt = "<",
@@ -37,11 +37,11 @@ declare enum Opeartor {
37
37
  eq = "=="
38
38
  }
39
39
  declare const OperatorMap: {
40
- [Opeartor.eq]: string;
41
- [Opeartor.lt]: string;
42
- [Opeartor.lte]: string;
43
- [Opeartor.gt]: string;
44
- [Opeartor.gte]: string;
40
+ "==": string;
41
+ "<": string;
42
+ "<=": string;
43
+ ">": string;
44
+ ">=": string;
45
45
  };
46
46
  declare const UpdateOperatorList: string[];
47
47
  declare enum QueryType {
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  var _a;
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.QueryType = exports.UpdateOperatorList = exports.OrderDirectionList = exports.OperatorMap = exports.Opeartor = exports.WhereFilterOpList = exports.FieldType = exports.ErrorCode = void 0;
4
5
  var ErrorCode;
5
6
  (function (ErrorCode) {
6
7
  ErrorCode["DocIDError"] = "\u6587\u6863ID\u4E0D\u5408\u6CD5";
@@ -11,6 +11,7 @@ var __assign = (this && this.__assign) || function () {
11
11
  return __assign.apply(this, arguments);
12
12
  };
13
13
  Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.DocumentReference = void 0;
14
15
  var util_1 = require("./lib/util");
15
16
  var index_1 = require("./index");
16
17
  var util_2 = require("./util");
@@ -21,10 +22,10 @@ var constant_1 = require("./constant");
21
22
  var utils_1 = require("./utils/utils");
22
23
  var DocumentReference = (function () {
23
24
  function DocumentReference(db, coll, docID, projection) {
24
- var _this = this;
25
25
  if (projection === void 0) { projection = {}; }
26
+ var _this = this;
26
27
  this.watch = function (options) {
27
- var ws = utils_1.getWsInstance(_this._db);
28
+ var ws = (0, utils_1.getWsInstance)(_this._db);
28
29
  return ws.watch(__assign(__assign({}, options), { envId: _this._db.config.env, collectionName: _this._coll, query: JSON.stringify({
29
30
  _id: _this.id
30
31
  }) }));
@@ -32,14 +33,14 @@ var DocumentReference = (function () {
32
33
  this._db = db;
33
34
  this._coll = coll;
34
35
  this.id = docID;
35
- this.request = new index_1.Db.reqClass(this._db.config);
36
+ this.request = index_1.Db.createRequest(this._db.config);
36
37
  this.projection = projection;
37
38
  }
38
39
  DocumentReference.prototype.create = function (data, callback) {
39
- callback = callback || util_1.createPromiseCallback();
40
+ callback = callback || (0, util_1.createPromiseCallback)();
40
41
  var params = {
41
42
  collectionName: this._coll,
42
- data: datatype_1.serialize(data)
43
+ data: (0, datatype_1.serialize)(data)
43
44
  };
44
45
  if (this.id) {
45
46
  params['_id'] = this.id;
@@ -63,7 +64,7 @@ var DocumentReference = (function () {
63
64
  return callback.promise;
64
65
  };
65
66
  DocumentReference.prototype.set = function (data, callback) {
66
- callback = callback || util_1.createPromiseCallback();
67
+ callback = callback || (0, util_1.createPromiseCallback)();
67
68
  if (!this.id) {
68
69
  return Promise.resolve({
69
70
  code: 'INVALID_PARAM',
@@ -106,7 +107,7 @@ var DocumentReference = (function () {
106
107
  var param = {
107
108
  collectionName: this._coll,
108
109
  queryType: constant_1.QueryType.DOC,
109
- data: datatype_1.serialize(data),
110
+ data: (0, datatype_1.serialize)(data),
110
111
  multi: false,
111
112
  merge: merge,
112
113
  upsert: true
@@ -134,7 +135,7 @@ var DocumentReference = (function () {
134
135
  return callback.promise;
135
136
  };
136
137
  DocumentReference.prototype.update = function (data, callback) {
137
- callback = callback || util_1.createPromiseCallback();
138
+ callback = callback || (0, util_1.createPromiseCallback)();
138
139
  if (!data || typeof data !== 'object') {
139
140
  return Promise.resolve({
140
141
  code: 'INVALID_PARAM',
@@ -178,7 +179,7 @@ var DocumentReference = (function () {
178
179
  return callback.promise;
179
180
  };
180
181
  DocumentReference.prototype.remove = function (callback) {
181
- callback = callback || util_1.createPromiseCallback();
182
+ callback = callback || (0, util_1.createPromiseCallback)();
182
183
  var query = { _id: this.id };
183
184
  var param = {
184
185
  collectionName: this._coll,
@@ -205,7 +206,7 @@ var DocumentReference = (function () {
205
206
  return callback.promise;
206
207
  };
207
208
  DocumentReference.prototype.get = function (callback) {
208
- callback = callback || util_1.createPromiseCallback();
209
+ callback = callback || (0, util_1.createPromiseCallback)();
209
210
  var query = { _id: this.id };
210
211
  var param = {
211
212
  collectionName: this._coll,
@@ -1,11 +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
- __export(require("./point"));
7
- __export(require("./lineString"));
8
- __export(require("./polygon"));
9
- __export(require("./multiPoint"));
10
- __export(require("./multiLineString"));
11
- __export(require("./multiPolygon"));
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);
@@ -15,5 +15,5 @@ export declare class LineString {
15
15
  };
16
16
  static validate(lineString: ISerializedLineString): boolean;
17
17
  static isClosed(lineString: LineString): boolean;
18
- readonly _internalType: import("../utils/symbol").InternalSymbol;
18
+ get _internalType(): import("../utils/symbol").InternalSymbol;
19
19
  }
@@ -11,20 +11,21 @@ var __values = (this && this.__values) || function(o) {
11
11
  throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
12
12
  };
13
13
  Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.LineString = void 0;
14
15
  var symbol_1 = require("../helper/symbol");
15
16
  var point_1 = require("./point");
16
17
  var type_1 = require("../utils/type");
17
18
  var LineString = (function () {
18
19
  function LineString(points) {
19
- if (!type_1.isArray(points)) {
20
- throw new TypeError("\"points\" must be of type Point[]. Received type " + typeof points);
20
+ if (!(0, type_1.isArray)(points)) {
21
+ throw new TypeError("\"points\" must be of type Point[]. Received type ".concat(typeof points));
21
22
  }
22
23
  if (points.length < 2) {
23
24
  throw new Error('"points" must contain 2 points at least');
24
25
  }
25
26
  points.forEach(function (point) {
26
27
  if (!(point instanceof point_1.Point)) {
27
- throw new TypeError("\"points\" must be of type Point[]. Received type " + typeof point + "[]");
28
+ throw new TypeError("\"points\" must be of type Point[]. Received type ".concat(typeof point, "[]"));
28
29
  }
29
30
  });
30
31
  this.points = points;
@@ -46,13 +47,13 @@ var LineString = (function () {
46
47
  };
47
48
  LineString.validate = function (lineString) {
48
49
  var e_1, _a;
49
- if (lineString.type !== 'LineString' || !type_1.isArray(lineString.coordinates)) {
50
+ if (lineString.type !== 'LineString' || !(0, type_1.isArray)(lineString.coordinates)) {
50
51
  return false;
51
52
  }
52
53
  try {
53
54
  for (var _b = __values(lineString.coordinates), _c = _b.next(); !_c.done; _c = _b.next()) {
54
55
  var point = _c.value;
55
- if (!type_1.isNumber(point[0]) || !type_1.isNumber(point[1])) {
56
+ if (!(0, type_1.isNumber)(point[0]) || !(0, type_1.isNumber)(point[1])) {
56
57
  return false;
57
58
  }
58
59
  }
@@ -77,7 +78,7 @@ var LineString = (function () {
77
78
  get: function () {
78
79
  return symbol_1.SYMBOL_GEO_LINE_STRING;
79
80
  },
80
- enumerable: true,
81
+ enumerable: false,
81
82
  configurable: true
82
83
  });
83
84
  return LineString;
@@ -14,5 +14,5 @@ export declare class MultiLineString {
14
14
  coordinates: number[][][];
15
15
  };
16
16
  static validate(multiLineString: ISerializedMultiLineString): boolean;
17
- readonly _internalType: import("../utils/symbol").InternalSymbol;
17
+ get _internalType(): import("../utils/symbol").InternalSymbol;
18
18
  }
@@ -11,20 +11,21 @@ var __values = (this && this.__values) || function(o) {
11
11
  throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
12
12
  };
13
13
  Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.MultiLineString = void 0;
14
15
  var symbol_1 = require("../helper/symbol");
15
16
  var type_1 = require("../utils/type");
16
17
  var lineString_1 = require("./lineString");
17
18
  var MultiLineString = (function () {
18
19
  function MultiLineString(lines) {
19
- if (!type_1.isArray(lines)) {
20
- throw new TypeError("\"lines\" must be of type LineString[]. Received type " + typeof lines);
20
+ if (!(0, type_1.isArray)(lines)) {
21
+ throw new TypeError("\"lines\" must be of type LineString[]. Received type ".concat(typeof lines));
21
22
  }
22
23
  if (lines.length === 0) {
23
24
  throw new Error('Polygon must contain 1 linestring at least');
24
25
  }
25
26
  lines.forEach(function (line) {
26
27
  if (!(line instanceof lineString_1.LineString)) {
27
- 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, "[]"));
28
29
  }
29
30
  });
30
31
  this.lines = lines;
@@ -50,7 +51,7 @@ var MultiLineString = (function () {
50
51
  };
51
52
  MultiLineString.validate = function (multiLineString) {
52
53
  var e_1, _a, e_2, _b;
53
- if (multiLineString.type !== 'MultiLineString' || !type_1.isArray(multiLineString.coordinates)) {
54
+ if (multiLineString.type !== 'MultiLineString' || !(0, type_1.isArray)(multiLineString.coordinates)) {
54
55
  return false;
55
56
  }
56
57
  try {
@@ -59,7 +60,7 @@ var MultiLineString = (function () {
59
60
  try {
60
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()) {
61
62
  var point = line_1_1.value;
62
- if (!type_1.isNumber(point[0]) || !type_1.isNumber(point[1])) {
63
+ if (!(0, type_1.isNumber)(point[0]) || !(0, type_1.isNumber)(point[1])) {
63
64
  return false;
64
65
  }
65
66
  }
@@ -86,7 +87,7 @@ var MultiLineString = (function () {
86
87
  get: function () {
87
88
  return symbol_1.SYMBOL_GEO_MULTI_LINE_STRING;
88
89
  },
89
- enumerable: true,
90
+ enumerable: false,
90
91
  configurable: true
91
92
  });
92
93
  return MultiLineString;
@@ -14,5 +14,5 @@ export declare class MultiPoint {
14
14
  coordinates: number[][];
15
15
  };
16
16
  static validate(multiPoint: ISerializedMultiPoint): boolean;
17
- readonly _internalType: import("../utils/symbol").InternalSymbol;
17
+ get _internalType(): import("../utils/symbol").InternalSymbol;
18
18
  }
@@ -11,20 +11,21 @@ var __values = (this && this.__values) || function(o) {
11
11
  throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
12
12
  };
13
13
  Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.MultiPoint = void 0;
14
15
  var symbol_1 = require("../helper/symbol");
15
16
  var point_1 = require("./point");
16
17
  var type_1 = require("../utils/type");
17
18
  var MultiPoint = (function () {
18
19
  function MultiPoint(points) {
19
- if (!type_1.isArray(points)) {
20
- throw new TypeError("\"points\" must be of type Point[]. Received type " + typeof points);
20
+ if (!(0, type_1.isArray)(points)) {
21
+ throw new TypeError("\"points\" must be of type Point[]. Received type ".concat(typeof points));
21
22
  }
22
23
  if (points.length === 0) {
23
24
  throw new Error('"points" must contain 1 point at least');
24
25
  }
25
26
  points.forEach(function (point) {
26
27
  if (!(point instanceof point_1.Point)) {
27
- throw new TypeError("\"points\" must be of type Point[]. Received type " + typeof point + "[]");
28
+ throw new TypeError("\"points\" must be of type Point[]. Received type ".concat(typeof point, "[]"));
28
29
  }
29
30
  });
30
31
  this.points = points;
@@ -46,13 +47,13 @@ var MultiPoint = (function () {
46
47
  };
47
48
  MultiPoint.validate = function (multiPoint) {
48
49
  var e_1, _a;
49
- if (multiPoint.type !== 'MultiPoint' || !type_1.isArray(multiPoint.coordinates)) {
50
+ if (multiPoint.type !== 'MultiPoint' || !(0, type_1.isArray)(multiPoint.coordinates)) {
50
51
  return false;
51
52
  }
52
53
  try {
53
54
  for (var _b = __values(multiPoint.coordinates), _c = _b.next(); !_c.done; _c = _b.next()) {
54
55
  var point = _c.value;
55
- if (!type_1.isNumber(point[0]) || !type_1.isNumber(point[1])) {
56
+ if (!(0, type_1.isNumber)(point[0]) || !(0, type_1.isNumber)(point[1])) {
56
57
  return false;
57
58
  }
58
59
  }
@@ -70,7 +71,7 @@ var MultiPoint = (function () {
70
71
  get: function () {
71
72
  return symbol_1.SYMBOL_GEO_MULTI_POINT;
72
73
  },
73
- enumerable: true,
74
+ enumerable: false,
74
75
  configurable: true
75
76
  });
76
77
  return MultiPoint;
@@ -14,5 +14,5 @@ export declare class MultiPolygon {
14
14
  coordinates: number[][][][];
15
15
  };
16
16
  static validate(multiPolygon: ISerializedMultiPolygon): boolean;
17
- readonly _internalType: import("../utils/symbol").InternalSymbol;
17
+ get _internalType(): import("../utils/symbol").InternalSymbol;
18
18
  }