@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
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.QuerySerializer = void 0;
3
4
  var query_1 = require("../commands/query");
4
5
  var logic_1 = require("../commands/logic");
5
6
  var symbol_1 = require("../helper/symbol");
@@ -21,11 +22,11 @@ var QueryEncoder = (function () {
21
22
  }
22
23
  QueryEncoder.prototype.encodeQuery = function (query, key) {
23
24
  var _a;
24
- if (common_1.isConversionRequired(query)) {
25
- if (logic_1.isLogicCommand(query)) {
25
+ if ((0, common_1.isConversionRequired)(query)) {
26
+ if ((0, logic_1.isLogicCommand)(query)) {
26
27
  return this.encodeLogicCommand(query);
27
28
  }
28
- else if (query_1.isQueryCommand(query)) {
29
+ else if ((0, query_1.isQueryCommand)(query)) {
29
30
  return this.encodeQueryCommand(query);
30
31
  }
31
32
  else {
@@ -33,7 +34,7 @@ var QueryEncoder = (function () {
33
34
  }
34
35
  }
35
36
  else {
36
- if (type_1.isObject(query)) {
37
+ if ((0, type_1.isObject)(query)) {
37
38
  return this.encodeQueryObject(query);
38
39
  }
39
40
  else {
@@ -54,7 +55,7 @@ var QueryEncoder = (function () {
54
55
  case logic_1.LOGIC_COMMANDS_LITERAL.NOR:
55
56
  case logic_1.LOGIC_COMMANDS_LITERAL.AND:
56
57
  case logic_1.LOGIC_COMMANDS_LITERAL.OR: {
57
- var $op = operator_map_1.operatorToString(query.operator);
58
+ var $op = (0, operator_map_1.operatorToString)(query.operator);
58
59
  var subqueries = query.operands.map(function (oprand) {
59
60
  return _this.encodeQuery(oprand, query.fieldName);
60
61
  });
@@ -63,9 +64,9 @@ var QueryEncoder = (function () {
63
64
  _a;
64
65
  }
65
66
  case logic_1.LOGIC_COMMANDS_LITERAL.NOT: {
66
- var $op = operator_map_1.operatorToString(query.operator);
67
+ var $op = (0, operator_map_1.operatorToString)(query.operator);
67
68
  var operatorExpression = query.operands[0];
68
- if (type_1.isRegExp(operatorExpression)) {
69
+ if ((0, type_1.isRegExp)(operatorExpression)) {
69
70
  return _b = {},
70
71
  _b[query.fieldName] = (_c = {},
71
72
  _c[$op] = this.encodeRegExp(operatorExpression),
@@ -82,7 +83,7 @@ var QueryEncoder = (function () {
82
83
  }
83
84
  }
84
85
  default: {
85
- var $op = operator_map_1.operatorToString(query.operator);
86
+ var $op = (0, operator_map_1.operatorToString)(query.operator);
86
87
  if (query.operands.length === 1) {
87
88
  var subquery = this.encodeQuery(query.operands[0]);
88
89
  return _f = {},
@@ -99,7 +100,7 @@ var QueryEncoder = (function () {
99
100
  }
100
101
  };
101
102
  QueryEncoder.prototype.encodeQueryCommand = function (query) {
102
- if (query_1.isComparisonCommand(query)) {
103
+ if ((0, query_1.isComparisonCommand)(query)) {
103
104
  return this.encodeComparisonCommand(query);
104
105
  }
105
106
  else {
@@ -111,7 +112,7 @@ var QueryEncoder = (function () {
111
112
  if (query.fieldName === symbol_1.SYMBOL_UNSET_FIELD_NAME) {
112
113
  throw new Error('Cannot encode a comparison command with unset field name');
113
114
  }
114
- var $op = operator_map_1.operatorToString(query.operator);
115
+ var $op = (0, operator_map_1.operatorToString)(query.operator);
115
116
  switch (query.operator) {
116
117
  case query_1.QUERY_COMMANDS_LITERAL.EQ:
117
118
  case query_1.QUERY_COMMANDS_LITERAL.NEQ:
@@ -125,7 +126,7 @@ var QueryEncoder = (function () {
125
126
  case query_1.QUERY_COMMANDS_LITERAL.MOD: {
126
127
  return _a = {},
127
128
  _a[query.fieldName] = (_b = {},
128
- _b[$op] = common_1.encodeInternalDataType(query.operands[0]),
129
+ _b[$op] = (0, common_1.encodeInternalDataType)(query.operands[0]),
129
130
  _b),
130
131
  _a;
131
132
  }
@@ -134,7 +135,7 @@ var QueryEncoder = (function () {
134
135
  case query_1.QUERY_COMMANDS_LITERAL.ALL: {
135
136
  return _c = {},
136
137
  _c[query.fieldName] = (_d = {},
137
- _d[$op] = common_1.encodeInternalDataType(query.operands),
138
+ _d[$op] = (0, common_1.encodeInternalDataType)(query.operands),
138
139
  _d),
139
140
  _c;
140
141
  }
@@ -173,28 +174,28 @@ var QueryEncoder = (function () {
173
174
  default: {
174
175
  return _h = {},
175
176
  _h[query.fieldName] = (_j = {},
176
- _j[$op] = common_1.encodeInternalDataType(query.operands[0]),
177
+ _j[$op] = (0, common_1.encodeInternalDataType)(query.operands[0]),
177
178
  _j),
178
179
  _h;
179
180
  }
180
181
  }
181
182
  };
182
183
  QueryEncoder.prototype.encodeQueryObject = function (query) {
183
- var flattened = common_1.flattenQueryObject(query);
184
+ var flattened = (0, common_1.flattenQueryObject)(query);
184
185
  for (var key in flattened) {
185
186
  var val = flattened[key];
186
- if (logic_1.isLogicCommand(val)) {
187
+ if ((0, logic_1.isLogicCommand)(val)) {
187
188
  flattened[key] = val._setFieldName(key);
188
189
  var condition = this.encodeLogicCommand(flattened[key]);
189
190
  this.mergeConditionAfterEncode(flattened, condition, key);
190
191
  }
191
- else if (query_1.isComparisonCommand(val)) {
192
+ else if ((0, query_1.isComparisonCommand)(val)) {
192
193
  flattened[key] = val._setFieldName(key);
193
194
  var condition = this.encodeComparisonCommand(flattened[key]);
194
195
  this.mergeConditionAfterEncode(flattened, condition, key);
195
196
  }
196
- else if (common_1.isConversionRequired(val)) {
197
- flattened[key] = common_1.encodeInternalDataType(val);
197
+ else if ((0, common_1.isConversionRequired)(val)) {
198
+ flattened[key] = (0, common_1.encodeInternalDataType)(val);
198
199
  }
199
200
  }
200
201
  return flattened;
@@ -205,20 +206,20 @@ var QueryEncoder = (function () {
205
206
  }
206
207
  for (var conditionKey in condition) {
207
208
  if (query[conditionKey]) {
208
- if (type_1.isArray(query[conditionKey])) {
209
+ if ((0, type_1.isArray)(query[conditionKey])) {
209
210
  query[conditionKey] = query[conditionKey].concat(condition[conditionKey]);
210
211
  }
211
- else if (type_1.isObject(query[conditionKey])) {
212
- if (type_1.isObject(condition[conditionKey])) {
212
+ else if ((0, type_1.isObject)(query[conditionKey])) {
213
+ if ((0, type_1.isObject)(condition[conditionKey])) {
213
214
  Object.assign(query, condition);
214
215
  }
215
216
  else {
216
- console.warn("unmergable condition, query is object but condition is " + type_1.getType(condition) + ", can only overwrite", condition, key);
217
+ console.warn("unmergable condition, query is object but condition is ".concat((0, type_1.getType)(condition), ", can only overwrite"), condition, key);
217
218
  query[conditionKey] = condition[conditionKey];
218
219
  }
219
220
  }
220
221
  else {
221
- console.warn("to-merge query is of type " + type_1.getType(query) + ", can only overwrite", query, condition, key);
222
+ console.warn("to-merge query is of type ".concat((0, type_1.getType)(query), ", can only overwrite"), query, condition, key);
222
223
  query[conditionKey] = condition[conditionKey];
223
224
  }
224
225
  }
@@ -1,6 +1,6 @@
1
1
  import { UpdateCommand } from '../commands/update';
2
2
  import { LogicCommand } from '../commands/logic';
3
- export declare type IQueryCondition = Record<string, any> | LogicCommand;
3
+ export type IQueryCondition = Record<string, any> | LogicCommand;
4
4
  export interface IUpdateCondition {
5
5
  [key: string]: any;
6
6
  }
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UpdateSerializer = void 0;
3
4
  var update_1 = require("../commands/update");
4
5
  var symbol_1 = require("../helper/symbol");
5
6
  var type_1 = require("../utils/type");
@@ -13,10 +14,10 @@ var UpdateSerializer = (function () {
13
14
  return stringifier.encodeUpdate(query);
14
15
  };
15
16
  UpdateSerializer.prototype.encodeUpdate = function (query) {
16
- if (update_1.isUpdateCommand(query)) {
17
+ if ((0, update_1.isUpdateCommand)(query)) {
17
18
  return this.encodeUpdateCommand(query);
18
19
  }
19
- else if (type_1.getType(query) === 'object') {
20
+ else if ((0, type_1.getType)(query) === 'object') {
20
21
  return this.encodeUpdateObject(query);
21
22
  }
22
23
  else {
@@ -44,7 +45,7 @@ var UpdateSerializer = (function () {
44
45
  };
45
46
  UpdateSerializer.prototype.encodeFieldUpdateCommand = function (query) {
46
47
  var _a, _b, _c, _d;
47
- var $op = operator_map_1.operatorToString(query.operator);
48
+ var $op = (0, operator_map_1.operatorToString)(query.operator);
48
49
  switch (query.operator) {
49
50
  case update_1.UPDATE_COMMANDS_LITERAL.REMOVE: {
50
51
  return _a = {},
@@ -64,11 +65,11 @@ var UpdateSerializer = (function () {
64
65
  };
65
66
  UpdateSerializer.prototype.encodeArrayUpdateCommand = function (query) {
66
67
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
67
- var $op = operator_map_1.operatorToString(query.operator);
68
+ var $op = (0, operator_map_1.operatorToString)(query.operator);
68
69
  switch (query.operator) {
69
70
  case update_1.UPDATE_COMMANDS_LITERAL.PUSH: {
70
71
  var modifiers = void 0;
71
- if (type_1.isArray(query.operands)) {
72
+ if ((0, type_1.isArray)(query.operands)) {
72
73
  modifiers = {
73
74
  $each: query.operands.map(common_1.encodeInternalDataType)
74
75
  };
@@ -110,28 +111,28 @@ var UpdateSerializer = (function () {
110
111
  default: {
111
112
  return _j = {},
112
113
  _j[$op] = (_k = {},
113
- _k[query.fieldName] = common_1.encodeInternalDataType(query.operands),
114
+ _k[query.fieldName] = (0, common_1.encodeInternalDataType)(query.operands),
114
115
  _k),
115
116
  _j;
116
117
  }
117
118
  }
118
119
  };
119
120
  UpdateSerializer.prototype.encodeUpdateObject = function (query) {
120
- var flattened = common_1.flattenQueryObject(query);
121
+ var flattened = (0, common_1.flattenQueryObject)(query);
121
122
  for (var key in flattened) {
122
123
  if (/^\$/.test(key))
123
124
  continue;
124
125
  var val = flattened[key];
125
- if (update_1.isUpdateCommand(val)) {
126
+ if ((0, update_1.isUpdateCommand)(val)) {
126
127
  flattened[key] = val._setFieldName(key);
127
128
  var condition = this.encodeUpdateCommand(flattened[key]);
128
- common_1.mergeConditionAfterEncode(flattened, condition, key);
129
+ (0, common_1.mergeConditionAfterEncode)(flattened, condition, key);
129
130
  }
130
131
  else {
131
- flattened[key] = val = common_1.encodeInternalDataType(val);
132
+ flattened[key] = val = (0, common_1.encodeInternalDataType)(val);
132
133
  var $setCommand = new update_1.UpdateCommand(update_1.UPDATE_COMMANDS_LITERAL.SET, [val], key);
133
134
  var condition = this.encodeUpdateCommand($setCommand);
134
- common_1.mergeConditionAfterEncode(flattened, condition, key);
135
+ (0, common_1.mergeConditionAfterEncode)(flattened, condition, key);
135
136
  }
136
137
  }
137
138
  return flattened;
@@ -3,7 +3,7 @@ export declare class ServerDate {
3
3
  constructor({ offset }?: {
4
4
  offset?: number;
5
5
  });
6
- readonly _internalType: import("../utils/symbol").InternalSymbol;
6
+ get _internalType(): import("../utils/symbol").InternalSymbol;
7
7
  parse(): {
8
8
  $date: {
9
9
  offset: number;
@@ -1,16 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ServerDateConstructor = exports.ServerDate = void 0;
3
4
  var symbol_1 = require("../helper/symbol");
4
5
  var ServerDate = (function () {
5
6
  function ServerDate(_a) {
6
- var _b = (_a === void 0 ? {} : _a).offset, offset = _b === void 0 ? 0 : _b;
7
+ var _b = _a === void 0 ? {} : _a, _c = _b.offset, offset = _c === void 0 ? 0 : _c;
7
8
  this.offset = offset;
8
9
  }
9
10
  Object.defineProperty(ServerDate.prototype, "_internalType", {
10
11
  get: function () {
11
12
  return symbol_1.SYMBOL_SERVER_DATE;
12
13
  },
13
- enumerable: true,
14
+ enumerable: false,
14
15
  configurable: true
15
16
  });
16
17
  ServerDate.prototype.parse = function () {
@@ -1,7 +1,7 @@
1
1
  import { DocumentReference } from './document';
2
2
  import { Query } from './query';
3
3
  export declare class CollectionReference extends Query {
4
- readonly name: string;
4
+ get name(): string;
5
5
  doc(docID?: string | number): DocumentReference;
6
6
  add(data: any): Promise<any>;
7
7
  }
@@ -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 CollectionReference = (function (_super) {
@@ -24,7 +27,7 @@ var CollectionReference = (function (_super) {
24
27
  get: function () {
25
28
  return this._coll;
26
29
  },
27
- enumerable: true,
30
+ enumerable: false,
28
31
  configurable: true
29
32
  });
30
33
  CollectionReference.prototype.doc = function (docID) {
@@ -6,7 +6,7 @@ interface UpdateResult {
6
6
  requestId: string;
7
7
  updated: number;
8
8
  }
9
- declare type JsonString = string;
9
+ type JsonString = string;
10
10
  interface SetResult extends UpdateResult {
11
11
  upserted: JsonString;
12
12
  }
@@ -25,7 +25,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
25
25
  function verb(n) { return function (v) { return step([n, v]); }; }
26
26
  function step(op) {
27
27
  if (f) throw new TypeError("Generator is already executing.");
28
- while (_) try {
28
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
29
29
  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;
30
30
  if (y = 0, t) op = [op[0] & 2, t.value];
31
31
  switch (op[0]) {
@@ -47,6 +47,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
47
47
  }
48
48
  };
49
49
  Object.defineProperty(exports, "__esModule", { value: true });
50
+ exports.DocumentReference = void 0;
50
51
  var bson_1 = require("bson");
51
52
  var code_1 = require("../const/code");
52
53
  var update_1 = require("../serializer/update");
@@ -73,7 +74,7 @@ var DocumentReference = (function () {
73
74
  params = {
74
75
  collectionName: this._coll,
75
76
  transactionId: this._transactionId,
76
- data: bson_1.EJSON.stringify(datatype_1.serialize(data), { relaxed: false })
77
+ data: bson_1.EJSON.stringify((0, datatype_1.serialize)(data), { relaxed: false })
77
78
  };
78
79
  if (this.id) {
79
80
  params['_id'] = this.id;
@@ -87,8 +88,7 @@ var DocumentReference = (function () {
87
88
  inserted = bson_1.EJSON.parse(res.inserted);
88
89
  ok = bson_1.EJSON.parse(res.ok);
89
90
  if (ok == 1 && inserted == 1) {
90
- return [2, __assign(__assign({}, res), { ok: ok,
91
- inserted: inserted })];
91
+ return [2, __assign(__assign({}, res), { ok: ok, inserted: inserted })];
92
92
  }
93
93
  else {
94
94
  throw new Error(code_1.ERRORS.INSERT_DOC_FAIL.message);
@@ -136,7 +136,7 @@ var DocumentReference = (function () {
136
136
  query: {
137
137
  _id: { $eq: this.id }
138
138
  },
139
- data: bson_1.EJSON.stringify(datatype_1.serialize(data), { relaxed: false }),
139
+ data: bson_1.EJSON.stringify((0, datatype_1.serialize)(data), { relaxed: false }),
140
140
  upsert: true
141
141
  };
142
142
  return [4, this._request.send(UPDATE_DOC, param)];
@@ -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]) {
@@ -36,6 +36,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
36
36
  }
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.runTransaction = exports.startTransaction = exports.Transaction = void 0;
39
40
  var index_1 = require("../index");
40
41
  var collection_1 = require("./collection");
41
42
  var code_1 = require("../const/code");
@@ -45,7 +46,7 @@ var ABORT = 'database.abortTransaction';
45
46
  var Transaction = (function () {
46
47
  function Transaction(db) {
47
48
  this._db = db;
48
- this._request = new index_1.Db.reqClass(this._db.config);
49
+ this._request = index_1.Db.createRequest(this._db.config);
49
50
  this.aborted = false;
50
51
  this.commited = false;
51
52
  this.inited = false;
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Query = void 0;
3
4
  var Query = (function () {
4
5
  function Query(transaction, coll) {
5
6
  this._coll = coll;
@@ -1,5 +1,5 @@
1
- export declare type DataType = 'init' | 'update' | 'add' | 'remove' | 'replace' | 'limit';
2
- export declare type QueueType = 'init' | 'enqueue' | 'dequeue' | 'update';
1
+ export type DataType = 'init' | 'update' | 'add' | 'remove' | 'replace' | 'limit';
2
+ export type QueueType = 'init' | 'enqueue' | 'dequeue' | 'update';
3
3
  export interface IDatabaseServiceContext extends IServiceContext {
4
4
  appConfig: IAppConfig;
5
5
  ws?: any;
@@ -29,7 +29,7 @@ export interface ISingleDBEvent {
29
29
  updatedFields?: any;
30
30
  removedFields?: any;
31
31
  }
32
- export declare type SnapshotType = 'init';
32
+ export type SnapshotType = 'init';
33
33
  export interface DBRealtimeListener {
34
34
  close: () => void;
35
35
  }
@@ -1,14 +1,14 @@
1
1
  import { DataType, QueueType } from './index';
2
- export declare type IRequestMsgType = 'LOGIN' | 'INIT_WATCH' | 'REBUILD_WATCH' | 'CHECK_LAST' | 'CLOSE_WATCH' | 'PING';
3
- export declare type IResponseMsgType = 'LOGIN_RES' | 'INIT_EVENT' | 'NEXT_EVENT' | 'CHECK_EVENT' | 'PONG' | 'ERROR';
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
4
  export interface IRequestMessageBase<W extends boolean = true> {
5
5
  watchId: W extends true ? string : undefined;
6
6
  requestId: string;
7
7
  msgType: IRequestMsgType;
8
8
  msgData: IRequestMessageMsgData;
9
9
  }
10
- export declare type IRequestMessageMsgData = IRequestMessageInitWatchData | IRequestMessageLoginData | IRequestMessageRebuildWatchData | IRequestMessageCheckLastData | IRequestMessageCloseWatchData | IRequestMessagePingData;
11
- export declare type IRequestMessage = IRequestMessageInitWatchMsg | IRequestMessageLoginMsg | IRequestMessageRebuildWatchMsg | IRequestMessageCheckLastMsg | IRequestMessageCloseWatchMsg | IRequestMessagePingMsg;
10
+ export type IRequestMessageMsgData = IRequestMessageInitWatchData | IRequestMessageLoginData | IRequestMessageRebuildWatchData | IRequestMessageCheckLastData | IRequestMessageCloseWatchData | IRequestMessagePingData;
11
+ export type IRequestMessage = IRequestMessageInitWatchMsg | IRequestMessageLoginMsg | IRequestMessageRebuildWatchMsg | IRequestMessageCheckLastMsg | IRequestMessageCloseWatchMsg | IRequestMessagePingMsg;
12
12
  export interface IRequestMessageLoginData {
13
13
  envId: string;
14
14
  accessToken: string;
@@ -55,12 +55,12 @@ export interface IRequestMessageCheckLastMsg extends IRequestMessageBase {
55
55
  msgType: 'CHECK_LAST';
56
56
  msgData: IRequestMessageCheckLastData;
57
57
  }
58
- export declare type IRequestMessageCloseWatchData = null;
58
+ export type IRequestMessageCloseWatchData = null;
59
59
  export interface IRequestMessageCloseWatchMsg extends IRequestMessageBase {
60
60
  msgType: 'CLOSE_WATCH';
61
61
  msgData: IRequestMessageCloseWatchData;
62
62
  }
63
- export declare type IRequestMessagePingData = null;
63
+ export type IRequestMessagePingData = null;
64
64
  export interface IRequestMessagePingMsg extends IRequestMessageBase<false> {
65
65
  msgType: 'PING';
66
66
  msgData: IRequestMessagePingData;
@@ -71,9 +71,9 @@ export interface IResponseMessageBase<W extends boolean = true> {
71
71
  msgType: IResponseMsgType;
72
72
  msgData: IResponseMessageMsgData;
73
73
  }
74
- export declare type IResponseMessageMsgData = IResponseMessageLoginResData | IResponseMessageInitEventData | IResponseMessageNextEventData | IResponseMessageCheckEventData | IResponseMessagePongData | IResponseMessageErrorData;
75
- export declare type IResponseMessage = IResponseMessageLoginResMsg | IResponseMessageInitEventMsg | IResponseMessageNextEventMsg | IResponseMessageCheckEventMsg | IResponseMessagePongMsg | IResponseMessageErrorMsg;
76
- export declare type IResponseMessageLoginResData = {
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
77
  envId: string;
78
78
  } & Partial<IResponseMessageErrorData>;
79
79
  export interface IResponseMessageLoginResMsg extends IResponseMessageBase<false> {
@@ -106,12 +106,12 @@ export interface IResponseMessageCheckEventMsg extends IResponseMessageBase {
106
106
  msgType: 'CHECK_EVENT';
107
107
  msgData: IResponseMessageCheckEventData;
108
108
  }
109
- export declare type IResponseMessagePongData = null;
109
+ export type IResponseMessagePongData = null;
110
110
  export interface IResponseMessagePongMsg extends IResponseMessageBase {
111
111
  msgType: 'PONG';
112
112
  msgData: IResponseMessagePongData;
113
113
  }
114
- export declare type IResponseMessageErrorData = {
114
+ export type IResponseMessageErrorData = {
115
115
  message: string;
116
116
  } & ({
117
117
  code: 'SYS_ERR';
@@ -134,7 +134,7 @@ export interface IResponseMessageErrorMsg extends IResponseMessageBase {
134
134
  msgType: 'ERROR';
135
135
  msgData: IResponseMessageErrorData;
136
136
  }
137
- export declare type IDBEvent = IDBInitEvent | IDBNextEvent;
137
+ export type IDBEvent = IDBInitEvent | IDBNextEvent;
138
138
  export interface IDBEventBase {
139
139
  ID: number;
140
140
  DataType: DataType;
@@ -148,10 +148,10 @@ export interface IDBInitEvent extends IDBEventBase {
148
148
  UpdatedFields?: any;
149
149
  removedFields?: any;
150
150
  }
151
- export declare type IDBNextEvent = IDBNextEventDataUpdate | IDBNextEventDataReplace | IDBNextEventDataAdd | IDBNextEventDataRemove | IDBNextEventDataLimit;
152
- export declare type IDBNextEventDataUpdate = IDBNextEventDataUpdateQueueUpdate | IDBNextEventDataUpdateQueueEnqueue | IDBNextEventDataUpdateQueueDequeue;
153
- export declare type IDBNextEventDataReplace = IDBNextEventDataReplaceQueueUpdate | IDBNextEventDataReplaceQueueEnqueue | IDBNextEventDataReplaceQueueDequeue;
154
- export declare type IDBNextEventDataLimit = IDBNextEventDataLimitQueueEnqueue | IDBNextEventDataLimitQueueDequeue;
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
155
  export interface IDBNextEventDataUpdateQueueUpdate extends IDBEventBase {
156
156
  DataType: 'update';
157
157
  QueueType: 'update';
@@ -16,6 +16,7 @@ var __read = (this && this.__read) || function (o, n) {
16
16
  return ar;
17
17
  };
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
+ exports.Util = void 0;
19
20
  var constant_1 = require("./constant");
20
21
  var index_1 = require("./geo/index");
21
22
  var index_2 = require("./serverDate/index");
@@ -7,7 +7,8 @@ export declare class CloudSDKError extends Error {
7
7
  errMsg: string;
8
8
  requestID?: string;
9
9
  constructor(options: IErrorConstructorOptions);
10
- message: string;
10
+ get message(): string;
11
+ set message(msg: string);
11
12
  }
12
13
  interface IErrorConstructorOptions {
13
14
  errCode?: string;
@@ -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.isCancelledError = exports.CancelledError = exports.isTimeoutError = exports.TimeoutError = exports.isGenericError = exports.isSDKError = exports.CloudSDKError = void 0;
16
19
  var type_1 = require("./type");
17
20
  var error_config_1 = require("../config/error.config");
18
21
  var CloudSDKError = (function (_super) {
@@ -23,8 +26,8 @@ var CloudSDKError = (function (_super) {
23
26
  Object.defineProperties(_this, {
24
27
  message: {
25
28
  get: function () {
26
- return ("errCode: " + this.errCode + " " + (error_config_1.ERR_CODE[this.errCode] ||
27
- '') + " | errMsg: " + this.errMsg);
29
+ return ("errCode: ".concat(this.errCode, " ").concat(error_config_1.ERR_CODE[this.errCode] ||
30
+ '', " | errMsg: ") + this.errMsg);
28
31
  },
29
32
  set: function (msg) {
30
33
  this.errMsg = msg;
@@ -37,22 +40,23 @@ var CloudSDKError = (function (_super) {
37
40
  }
38
41
  Object.defineProperty(CloudSDKError.prototype, "message", {
39
42
  get: function () {
40
- return "errCode: " + this.errCode + " | errMsg: " + this.errMsg;
43
+ return "errCode: ".concat(this.errCode, " | errMsg: ") + this.errMsg;
41
44
  },
42
45
  set: function (msg) {
43
46
  this.errMsg = msg;
44
47
  },
45
- enumerable: true,
48
+ enumerable: false,
46
49
  configurable: true
47
50
  });
48
51
  return CloudSDKError;
49
52
  }(Error));
50
53
  exports.CloudSDKError = CloudSDKError;
51
54
  function isSDKError(error) {
52
- return (error && error instanceof Error && type_1.isString(error.errMsg));
55
+ return (error && error instanceof Error && (0, type_1.isString)(error.errMsg));
53
56
  }
54
57
  exports.isSDKError = isSDKError;
55
- exports.isGenericError = function (e) { return e.generic; };
58
+ var isGenericError = function (e) { return e.generic; };
59
+ exports.isGenericError = isGenericError;
56
60
  var TimeoutError = (function (_super) {
57
61
  __extends(TimeoutError, _super);
58
62
  function TimeoutError(message) {
@@ -65,9 +69,10 @@ var TimeoutError = (function (_super) {
65
69
  return TimeoutError;
66
70
  }(Error));
67
71
  exports.TimeoutError = TimeoutError;
68
- exports.isTimeoutError = function (e) {
72
+ var isTimeoutError = function (e) {
69
73
  return e.type === 'timeout';
70
74
  };
75
+ exports.isTimeoutError = isTimeoutError;
71
76
  var CancelledError = (function (_super) {
72
77
  __extends(CancelledError, _super);
73
78
  function CancelledError(message) {
@@ -80,6 +85,7 @@ var CancelledError = (function (_super) {
80
85
  return CancelledError;
81
86
  }(Error));
82
87
  exports.CancelledError = CancelledError;
83
- exports.isCancelledError = function (e) {
88
+ var isCancelledError = function (e) {
84
89
  return e.type === 'cancelled';
85
90
  };
91
+ exports.isCancelledError = isCancelledError;
@@ -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.InternalSymbol = void 0;
16
19
  var _symbols = [];
17
20
  var __internalMark__ = {};
18
21
  var HiddenSymbol = (function () {
@@ -31,12 +34,10 @@ var HiddenSymbol = (function () {
31
34
  var InternalSymbol = (function (_super) {
32
35
  __extends(InternalSymbol, _super);
33
36
  function InternalSymbol(target, __mark__) {
34
- var _this = this;
35
37
  if (__mark__ !== __internalMark__) {
36
38
  throw new TypeError('InternalSymbol cannot be constructed with new operator');
37
39
  }
38
- _this = _super.call(this, target) || this;
39
- return _this;
40
+ return _super.call(this, target) || this;
40
41
  }
41
42
  InternalSymbol.for = function (target) {
42
43
  for (var i = 0, len = _symbols.length; i < len; i++) {
@@ -3,7 +3,7 @@ export declare const isObject: <T extends object>(x: any) => x is T;
3
3
  export declare const isString: (x: any) => x is string;
4
4
  export declare const isNumber: (x: any) => x is number;
5
5
  export declare const isPromise: <T extends Promise<any> = Promise<any>>(x: any) => x is T;
6
- declare type AnyFn = (...args: any[]) => any;
6
+ type AnyFn = (...args: any[]) => any;
7
7
  export declare const isFunction: <T extends AnyFn = AnyFn>(x: any) => x is T;
8
8
  export declare const isArray: <T extends any[] = any[]>(x: any) => x is T;
9
9
  export declare const isDate: (x: any) => x is Date;