@cloudbase/js-sdk 3.6.7 → 3.6.8-beta.1

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 (207) hide show
  1. package/app/dist/index.esm.js +1 -1
  2. package/app/dist/index.esm.js.map +1 -1
  3. package/app/dist/index.js +1 -1
  4. package/app/dist/index.js.map +1 -1
  5. package/app/dist/index.node.esm.js +1 -1
  6. package/app/dist/index.node.esm.js.map +1 -1
  7. package/app/dist/index.node.js +1 -1
  8. package/app/dist/index.node.js.map +1 -1
  9. package/auth/dist/index.esm.js +1 -1
  10. package/auth/dist/index.esm.js.map +1 -1
  11. package/auth/dist/index.js +1 -1
  12. package/auth/dist/index.js.map +1 -1
  13. package/database/dist/index.d.ts +3 -0
  14. package/database/dist/index.esm.js +2 -0
  15. package/database/dist/index.esm.js.map +1 -0
  16. package/database/dist/index.js +2 -0
  17. package/database/dist/index.js.map +1 -0
  18. package/dist/index.cjs.js +1 -1
  19. package/dist/index.cjs.js.map +1 -1
  20. package/dist/index.esm.js +1 -1
  21. package/dist/index.esm.js.map +1 -1
  22. package/dist/index.node.cjs.js +1 -1
  23. package/dist/index.node.cjs.js.map +1 -1
  24. package/dist/index.node.esm.js +1 -1
  25. package/dist/index.node.esm.js.map +1 -1
  26. package/miniprogram_dist/auth/index.js +1 -1
  27. package/miniprogram_dist/index.js +1 -1
  28. package/miniprogram_dist/oauth/index.js +1 -1
  29. package/oauth/dist/index.esm.js +1 -1
  30. package/oauth/dist/index.esm.js.map +1 -1
  31. package/oauth/dist/index.js +1 -1
  32. package/oauth/dist/index.js.map +1 -1
  33. package/package.json +2 -2
  34. package/types/package.json +1 -1
  35. package/utilities/package.json +2 -2
  36. package/database/dist/commonjs/aggregate.d.ts +0 -29
  37. package/database/dist/commonjs/aggregate.js +0 -156
  38. package/database/dist/commonjs/collection.d.ts +0 -9
  39. package/database/dist/commonjs/collection.js +0 -49
  40. package/database/dist/commonjs/command.d.ts +0 -175
  41. package/database/dist/commonjs/command.js +0 -299
  42. package/database/dist/commonjs/commands/logic.d.ts +0 -24
  43. package/database/dist/commonjs/commands/logic.js +0 -89
  44. package/database/dist/commonjs/commands/query.d.ts +0 -68
  45. package/database/dist/commonjs/commands/query.js +0 -160
  46. package/database/dist/commonjs/commands/update.d.ts +0 -29
  47. package/database/dist/commonjs/commands/update.js +0 -51
  48. package/database/dist/commonjs/config/app.config.d.ts +0 -6
  49. package/database/dist/commonjs/config/app.config.js +0 -7
  50. package/database/dist/commonjs/config/error.config.d.ts +0 -3
  51. package/database/dist/commonjs/config/error.config.js +0 -16
  52. package/database/dist/commonjs/const/code.d.ts +0 -30
  53. package/database/dist/commonjs/const/code.js +0 -33
  54. package/database/dist/commonjs/constant.d.ts +0 -51
  55. package/database/dist/commonjs/constant.js +0 -75
  56. package/database/dist/commonjs/document.d.ts +0 -11
  57. package/database/dist/commonjs/document.js +0 -260
  58. package/database/dist/commonjs/geo/index.d.ts +0 -6
  59. package/database/dist/commonjs/geo/index.js +0 -22
  60. package/database/dist/commonjs/geo/interface.d.ts +0 -24
  61. package/database/dist/commonjs/geo/interface.js +0 -2
  62. package/database/dist/commonjs/geo/lineString.d.ts +0 -19
  63. package/database/dist/commonjs/geo/lineString.js +0 -86
  64. package/database/dist/commonjs/geo/multiLineString.d.ts +0 -18
  65. package/database/dist/commonjs/geo/multiLineString.js +0 -95
  66. package/database/dist/commonjs/geo/multiPoint.d.ts +0 -18
  67. package/database/dist/commonjs/geo/multiPoint.js +0 -79
  68. package/database/dist/commonjs/geo/multiPolygon.d.ts +0 -18
  69. package/database/dist/commonjs/geo/multiPolygon.js +0 -122
  70. package/database/dist/commonjs/geo/point.d.ts +0 -19
  71. package/database/dist/commonjs/geo/point.js +0 -50
  72. package/database/dist/commonjs/geo/polygon.d.ts +0 -19
  73. package/database/dist/commonjs/geo/polygon.js +0 -109
  74. package/database/dist/commonjs/helper/symbol.d.ts +0 -14
  75. package/database/dist/commonjs/helper/symbol.js +0 -31
  76. package/database/dist/commonjs/index.d.ts +0 -40
  77. package/database/dist/commonjs/index.js +0 -61
  78. package/database/dist/commonjs/lib/util.d.ts +0 -1
  79. package/database/dist/commonjs/lib/util.js +0 -26
  80. package/database/dist/commonjs/operator-map.d.ts +0 -4
  81. package/database/dist/commonjs/operator-map.js +0 -24
  82. package/database/dist/commonjs/query.d.ts +0 -22
  83. package/database/dist/commonjs/query.js +0 -252
  84. package/database/dist/commonjs/regexp/index.d.ts +0 -14
  85. package/database/dist/commonjs/regexp/index.js +0 -33
  86. package/database/dist/commonjs/serializer/common.d.ts +0 -11
  87. package/database/dist/commonjs/serializer/common.js +0 -127
  88. package/database/dist/commonjs/serializer/datatype.d.ts +0 -7
  89. package/database/dist/commonjs/serializer/datatype.js +0 -132
  90. package/database/dist/commonjs/serializer/query.d.ts +0 -7
  91. package/database/dist/commonjs/serializer/query.js +0 -232
  92. package/database/dist/commonjs/serializer/update.d.ts +0 -15
  93. package/database/dist/commonjs/serializer/update.js +0 -142
  94. package/database/dist/commonjs/serverDate/index.d.ts +0 -13
  95. package/database/dist/commonjs/serverDate/index.js +0 -30
  96. package/database/dist/commonjs/transaction/collection.d.ts +0 -7
  97. package/database/dist/commonjs/transaction/collection.js +0 -49
  98. package/database/dist/commonjs/transaction/document.d.ts +0 -27
  99. package/database/dist/commonjs/transaction/document.js +0 -205
  100. package/database/dist/commonjs/transaction/index.d.ts +0 -30
  101. package/database/dist/commonjs/transaction/index.js +0 -215
  102. package/database/dist/commonjs/transaction/query.d.ts +0 -43
  103. package/database/dist/commonjs/transaction/query.js +0 -261
  104. package/database/dist/commonjs/typings/index.d.ts +0 -40
  105. package/database/dist/commonjs/typings/index.js +0 -2
  106. package/database/dist/commonjs/typings/realtime.d.ts +0 -219
  107. package/database/dist/commonjs/typings/realtime.js +0 -2
  108. package/database/dist/commonjs/util.d.ts +0 -9
  109. package/database/dist/commonjs/util.js +0 -145
  110. package/database/dist/commonjs/utils/error.d.ts +0 -38
  111. package/database/dist/commonjs/utils/error.js +0 -91
  112. package/database/dist/commonjs/utils/msg.d.ts +0 -0
  113. package/database/dist/commonjs/utils/msg.js +0 -0
  114. package/database/dist/commonjs/utils/symbol.d.ts +0 -8
  115. package/database/dist/commonjs/utils/symbol.js +0 -58
  116. package/database/dist/commonjs/utils/type.d.ts +0 -13
  117. package/database/dist/commonjs/utils/type.js +0 -34
  118. package/database/dist/commonjs/utils/utils.d.ts +0 -4
  119. package/database/dist/commonjs/utils/utils.js +0 -39
  120. package/database/dist/commonjs/validate.d.ts +0 -1
  121. package/database/dist/commonjs/validate.js +0 -60
  122. package/database/dist/esm/aggregate.d.ts +0 -29
  123. package/database/dist/esm/aggregate.js +0 -154
  124. package/database/dist/esm/collection.d.ts +0 -9
  125. package/database/dist/esm/collection.js +0 -46
  126. package/database/dist/esm/command.d.ts +0 -175
  127. package/database/dist/esm/command.js +0 -296
  128. package/database/dist/esm/commands/logic.d.ts +0 -24
  129. package/database/dist/esm/commands/logic.js +0 -84
  130. package/database/dist/esm/commands/query.d.ts +0 -68
  131. package/database/dist/esm/commands/query.js +0 -154
  132. package/database/dist/esm/commands/update.d.ts +0 -29
  133. package/database/dist/esm/commands/update.js +0 -46
  134. package/database/dist/esm/config/app.config.d.ts +0 -6
  135. package/database/dist/esm/config/app.config.js +0 -5
  136. package/database/dist/esm/config/error.config.d.ts +0 -3
  137. package/database/dist/esm/config/error.config.js +0 -13
  138. package/database/dist/esm/const/code.d.ts +0 -30
  139. package/database/dist/esm/const/code.js +0 -30
  140. package/database/dist/esm/constant.d.ts +0 -51
  141. package/database/dist/esm/constant.js +0 -65
  142. package/database/dist/esm/document.d.ts +0 -11
  143. package/database/dist/esm/document.js +0 -257
  144. package/database/dist/esm/geo/index.d.ts +0 -6
  145. package/database/dist/esm/geo/index.js +0 -6
  146. package/database/dist/esm/geo/interface.d.ts +0 -24
  147. package/database/dist/esm/geo/interface.js +0 -1
  148. package/database/dist/esm/geo/lineString.d.ts +0 -19
  149. package/database/dist/esm/geo/lineString.js +0 -83
  150. package/database/dist/esm/geo/multiLineString.d.ts +0 -18
  151. package/database/dist/esm/geo/multiLineString.js +0 -92
  152. package/database/dist/esm/geo/multiPoint.d.ts +0 -18
  153. package/database/dist/esm/geo/multiPoint.js +0 -76
  154. package/database/dist/esm/geo/multiPolygon.d.ts +0 -18
  155. package/database/dist/esm/geo/multiPolygon.js +0 -119
  156. package/database/dist/esm/geo/point.d.ts +0 -19
  157. package/database/dist/esm/geo/point.js +0 -47
  158. package/database/dist/esm/geo/polygon.d.ts +0 -19
  159. package/database/dist/esm/geo/polygon.js +0 -106
  160. package/database/dist/esm/helper/symbol.d.ts +0 -14
  161. package/database/dist/esm/helper/symbol.js +0 -14
  162. package/database/dist/esm/index.d.ts +0 -40
  163. package/database/dist/esm/index.js +0 -55
  164. package/database/dist/esm/lib/util.d.ts +0 -1
  165. package/database/dist/esm/lib/util.js +0 -22
  166. package/database/dist/esm/operator-map.d.ts +0 -4
  167. package/database/dist/esm/operator-map.js +0 -20
  168. package/database/dist/esm/query.d.ts +0 -22
  169. package/database/dist/esm/query.js +0 -249
  170. package/database/dist/esm/regexp/index.d.ts +0 -14
  171. package/database/dist/esm/regexp/index.js +0 -29
  172. package/database/dist/esm/serializer/common.d.ts +0 -11
  173. package/database/dist/esm/serializer/common.js +0 -118
  174. package/database/dist/esm/serializer/datatype.d.ts +0 -7
  175. package/database/dist/esm/serializer/datatype.js +0 -127
  176. package/database/dist/esm/serializer/query.d.ts +0 -7
  177. package/database/dist/esm/serializer/query.js +0 -229
  178. package/database/dist/esm/serializer/update.d.ts +0 -15
  179. package/database/dist/esm/serializer/update.js +0 -139
  180. package/database/dist/esm/serverDate/index.d.ts +0 -13
  181. package/database/dist/esm/serverDate/index.js +0 -26
  182. package/database/dist/esm/transaction/collection.d.ts +0 -7
  183. package/database/dist/esm/transaction/collection.js +0 -46
  184. package/database/dist/esm/transaction/document.d.ts +0 -27
  185. package/database/dist/esm/transaction/document.js +0 -202
  186. package/database/dist/esm/transaction/index.d.ts +0 -30
  187. package/database/dist/esm/transaction/index.js +0 -210
  188. package/database/dist/esm/transaction/query.d.ts +0 -43
  189. package/database/dist/esm/transaction/query.js +0 -258
  190. package/database/dist/esm/typings/index.d.ts +0 -40
  191. package/database/dist/esm/typings/index.js +0 -1
  192. package/database/dist/esm/typings/realtime.d.ts +0 -219
  193. package/database/dist/esm/typings/realtime.js +0 -1
  194. package/database/dist/esm/util.d.ts +0 -9
  195. package/database/dist/esm/util.js +0 -142
  196. package/database/dist/esm/utils/error.d.ts +0 -38
  197. package/database/dist/esm/utils/error.js +0 -84
  198. package/database/dist/esm/utils/msg.d.ts +0 -0
  199. package/database/dist/esm/utils/msg.js +0 -0
  200. package/database/dist/esm/utils/symbol.d.ts +0 -8
  201. package/database/dist/esm/utils/symbol.js +0 -55
  202. package/database/dist/esm/utils/type.d.ts +0 -13
  203. package/database/dist/esm/utils/type.js +0 -20
  204. package/database/dist/esm/utils/utils.d.ts +0 -4
  205. package/database/dist/esm/utils/utils.js +0 -33
  206. package/database/dist/esm/validate.d.ts +0 -1
  207. package/database/dist/esm/validate.js +0 -57
@@ -1,132 +0,0 @@
1
- "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- var __read = (this && this.__read) || function (o, n) {
14
- var m = typeof Symbol === "function" && o[Symbol.iterator];
15
- if (!m) return o;
16
- var i = m.call(o), r, ar = [], e;
17
- try {
18
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
19
- }
20
- catch (error) { e = { error: error }; }
21
- finally {
22
- try {
23
- if (r && !r.done && (m = i["return"])) m.call(i);
24
- }
25
- finally { if (e) throw e.error; }
26
- }
27
- return ar;
28
- };
29
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
30
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
31
- if (ar || !(i in from)) {
32
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
33
- ar[i] = from[i];
34
- }
35
- }
36
- return to.concat(ar || Array.prototype.slice.call(from));
37
- };
38
- Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.deserialize = exports.serialize = void 0;
40
- var symbol_1 = require("../helper/symbol");
41
- var type_1 = require("../utils/type");
42
- var index_1 = require("../geo/index");
43
- var index_2 = require("../serverDate/index");
44
- function serialize(val) {
45
- return serializeHelper(val, [val]);
46
- }
47
- exports.serialize = serialize;
48
- function serializeHelper(val, visited) {
49
- if ((0, type_1.isInternalObject)(val)) {
50
- switch (val._internalType) {
51
- case symbol_1.SYMBOL_GEO_POINT: {
52
- return val.toJSON();
53
- }
54
- case symbol_1.SYMBOL_SERVER_DATE: {
55
- return val.parse();
56
- }
57
- case symbol_1.SYMBOL_REGEXP: {
58
- return val.parse();
59
- }
60
- default: {
61
- return val.toJSON ? val.toJSON() : val;
62
- }
63
- }
64
- }
65
- else if ((0, type_1.isDate)(val)) {
66
- return {
67
- $date: +val,
68
- };
69
- }
70
- else if ((0, type_1.isRegExp)(val)) {
71
- return {
72
- $regex: val.source,
73
- $options: val.flags,
74
- };
75
- }
76
- else if ((0, type_1.isArray)(val)) {
77
- return val.map(function (item) {
78
- if (visited.indexOf(item) > -1) {
79
- throw new Error('Cannot convert circular structure to JSON');
80
- }
81
- return serializeHelper(item, __spreadArray(__spreadArray([], __read(visited), false), [
82
- item,
83
- ], false));
84
- });
85
- }
86
- else if ((0, type_1.isObject)(val)) {
87
- var ret = __assign({}, val);
88
- for (var key in ret) {
89
- if (visited.indexOf(ret[key]) > -1) {
90
- throw new Error('Cannot convert circular structure to JSON');
91
- }
92
- ret[key] = serializeHelper(ret[key], __spreadArray(__spreadArray([], __read(visited), false), [
93
- ret[key],
94
- ], false));
95
- }
96
- return ret;
97
- }
98
- else {
99
- return val;
100
- }
101
- }
102
- function deserialize(object) {
103
- var ret = __assign({}, object);
104
- for (var key in ret) {
105
- switch (key) {
106
- case '$date': {
107
- switch ((0, type_1.getType)(ret[key])) {
108
- case 'number': {
109
- return new Date(ret[key]);
110
- }
111
- case 'object': {
112
- return new index_2.ServerDate(ret[key]);
113
- }
114
- }
115
- break;
116
- }
117
- case 'type': {
118
- switch (ret.type) {
119
- case 'Point': {
120
- if ((0, type_1.isArray)(ret.coordinates) && (0, type_1.isNumber)(ret.coordinates[0]) && (0, type_1.isNumber)(ret.coordinates[1])) {
121
- return new index_1.Point(ret.coordinates[0], ret.coordinates[1]);
122
- }
123
- break;
124
- }
125
- }
126
- break;
127
- }
128
- }
129
- }
130
- return object;
131
- }
132
- exports.deserialize = deserialize;
@@ -1,7 +0,0 @@
1
- import { QueryCommand } from '../commands/query';
2
- import { LogicCommand } from '../commands/logic';
3
- export type IQueryCondition = Record<string, any> | LogicCommand;
4
- export declare class QuerySerializer {
5
- constructor();
6
- static encode(query: IQueryCondition | QueryCommand | LogicCommand): IQueryCondition;
7
- }
@@ -1,232 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.QuerySerializer = void 0;
4
- var query_1 = require("../commands/query");
5
- var logic_1 = require("../commands/logic");
6
- var symbol_1 = require("../helper/symbol");
7
- var type_1 = require("../utils/type");
8
- var operator_map_1 = require("../operator-map");
9
- var common_1 = require("./common");
10
- var QuerySerializer = (function () {
11
- function QuerySerializer() {
12
- }
13
- QuerySerializer.encode = function (query) {
14
- var encoder = new QueryEncoder();
15
- return encoder.encodeQuery(query);
16
- };
17
- return QuerySerializer;
18
- }());
19
- exports.QuerySerializer = QuerySerializer;
20
- var QueryEncoder = (function () {
21
- function QueryEncoder() {
22
- }
23
- QueryEncoder.prototype.encodeQuery = function (query, key) {
24
- var _a;
25
- if ((0, common_1.isConversionRequired)(query)) {
26
- if ((0, logic_1.isLogicCommand)(query)) {
27
- return this.encodeLogicCommand(query);
28
- }
29
- else if ((0, query_1.isQueryCommand)(query)) {
30
- return this.encodeQueryCommand(query);
31
- }
32
- else {
33
- return _a = {}, _a[key] = this.encodeQueryObject(query), _a;
34
- }
35
- }
36
- else {
37
- if ((0, type_1.isObject)(query)) {
38
- return this.encodeQueryObject(query);
39
- }
40
- else {
41
- return query;
42
- }
43
- }
44
- };
45
- QueryEncoder.prototype.encodeRegExp = function (query) {
46
- return {
47
- $regex: query.source,
48
- $options: query.flags
49
- };
50
- };
51
- QueryEncoder.prototype.encodeLogicCommand = function (query) {
52
- var _a, _b, _c, _d, _e, _f, _g;
53
- var _this = this;
54
- switch (query.operator) {
55
- case logic_1.LOGIC_COMMANDS_LITERAL.NOR:
56
- case logic_1.LOGIC_COMMANDS_LITERAL.AND:
57
- case logic_1.LOGIC_COMMANDS_LITERAL.OR: {
58
- var $op = (0, operator_map_1.operatorToString)(query.operator);
59
- var subqueries = query.operands.map(function (oprand) {
60
- return _this.encodeQuery(oprand, query.fieldName);
61
- });
62
- return _a = {},
63
- _a[$op] = subqueries,
64
- _a;
65
- }
66
- case logic_1.LOGIC_COMMANDS_LITERAL.NOT: {
67
- var $op = (0, operator_map_1.operatorToString)(query.operator);
68
- var operatorExpression = query.operands[0];
69
- if ((0, type_1.isRegExp)(operatorExpression)) {
70
- return _b = {},
71
- _b[query.fieldName] = (_c = {},
72
- _c[$op] = this.encodeRegExp(operatorExpression),
73
- _c),
74
- _b;
75
- }
76
- else {
77
- var subqueries = this.encodeQuery(operatorExpression)[query.fieldName];
78
- return _d = {},
79
- _d[query.fieldName] = (_e = {},
80
- _e[$op] = subqueries,
81
- _e),
82
- _d;
83
- }
84
- }
85
- default: {
86
- var $op = (0, operator_map_1.operatorToString)(query.operator);
87
- if (query.operands.length === 1) {
88
- var subquery = this.encodeQuery(query.operands[0]);
89
- return _f = {},
90
- _f[$op] = subquery,
91
- _f;
92
- }
93
- else {
94
- var subqueries = query.operands.map(this.encodeQuery.bind(this));
95
- return _g = {},
96
- _g[$op] = subqueries,
97
- _g;
98
- }
99
- }
100
- }
101
- };
102
- QueryEncoder.prototype.encodeQueryCommand = function (query) {
103
- if ((0, query_1.isComparisonCommand)(query)) {
104
- return this.encodeComparisonCommand(query);
105
- }
106
- else {
107
- return this.encodeComparisonCommand(query);
108
- }
109
- };
110
- QueryEncoder.prototype.encodeComparisonCommand = function (query) {
111
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
112
- if (query.fieldName === symbol_1.SYMBOL_UNSET_FIELD_NAME) {
113
- throw new Error('Cannot encode a comparison command with unset field name');
114
- }
115
- var $op = (0, operator_map_1.operatorToString)(query.operator);
116
- switch (query.operator) {
117
- case query_1.QUERY_COMMANDS_LITERAL.EQ:
118
- case query_1.QUERY_COMMANDS_LITERAL.NEQ:
119
- case query_1.QUERY_COMMANDS_LITERAL.LT:
120
- case query_1.QUERY_COMMANDS_LITERAL.LTE:
121
- case query_1.QUERY_COMMANDS_LITERAL.GT:
122
- case query_1.QUERY_COMMANDS_LITERAL.GTE:
123
- case query_1.QUERY_COMMANDS_LITERAL.ELEM_MATCH:
124
- case query_1.QUERY_COMMANDS_LITERAL.EXISTS:
125
- case query_1.QUERY_COMMANDS_LITERAL.SIZE:
126
- case query_1.QUERY_COMMANDS_LITERAL.MOD: {
127
- return _a = {},
128
- _a[query.fieldName] = (_b = {},
129
- _b[$op] = (0, common_1.encodeInternalDataType)(query.operands[0]),
130
- _b),
131
- _a;
132
- }
133
- case query_1.QUERY_COMMANDS_LITERAL.IN:
134
- case query_1.QUERY_COMMANDS_LITERAL.NIN:
135
- case query_1.QUERY_COMMANDS_LITERAL.ALL: {
136
- return _c = {},
137
- _c[query.fieldName] = (_d = {},
138
- _d[$op] = (0, common_1.encodeInternalDataType)(query.operands),
139
- _d),
140
- _c;
141
- }
142
- case query_1.QUERY_COMMANDS_LITERAL.GEO_NEAR: {
143
- var options = query.operands[0];
144
- return _e = {},
145
- _e[query.fieldName] = {
146
- $nearSphere: {
147
- $geometry: options.geometry.toJSON(),
148
- $maxDistance: options.maxDistance,
149
- $minDistance: options.minDistance
150
- }
151
- },
152
- _e;
153
- }
154
- case query_1.QUERY_COMMANDS_LITERAL.GEO_WITHIN: {
155
- var options = query.operands[0];
156
- return _f = {},
157
- _f[query.fieldName] = {
158
- $geoWithin: {
159
- $geometry: options.geometry.toJSON()
160
- }
161
- },
162
- _f;
163
- }
164
- case query_1.QUERY_COMMANDS_LITERAL.GEO_INTERSECTS: {
165
- var options = query.operands[0];
166
- return _g = {},
167
- _g[query.fieldName] = {
168
- $geoIntersects: {
169
- $geometry: options.geometry.toJSON()
170
- }
171
- },
172
- _g;
173
- }
174
- default: {
175
- return _h = {},
176
- _h[query.fieldName] = (_j = {},
177
- _j[$op] = (0, common_1.encodeInternalDataType)(query.operands[0]),
178
- _j),
179
- _h;
180
- }
181
- }
182
- };
183
- QueryEncoder.prototype.encodeQueryObject = function (query) {
184
- var flattened = (0, common_1.flattenQueryObject)(query);
185
- for (var key in flattened) {
186
- var val = flattened[key];
187
- if ((0, logic_1.isLogicCommand)(val)) {
188
- flattened[key] = val._setFieldName(key);
189
- var condition = this.encodeLogicCommand(flattened[key]);
190
- this.mergeConditionAfterEncode(flattened, condition, key);
191
- }
192
- else if ((0, query_1.isComparisonCommand)(val)) {
193
- flattened[key] = val._setFieldName(key);
194
- var condition = this.encodeComparisonCommand(flattened[key]);
195
- this.mergeConditionAfterEncode(flattened, condition, key);
196
- }
197
- else if ((0, common_1.isConversionRequired)(val)) {
198
- flattened[key] = (0, common_1.encodeInternalDataType)(val);
199
- }
200
- }
201
- return flattened;
202
- };
203
- QueryEncoder.prototype.mergeConditionAfterEncode = function (query, condition, key) {
204
- if (!condition[key]) {
205
- delete query[key];
206
- }
207
- for (var conditionKey in condition) {
208
- if (query[conditionKey]) {
209
- if ((0, type_1.isArray)(query[conditionKey])) {
210
- query[conditionKey] = query[conditionKey].concat(condition[conditionKey]);
211
- }
212
- else if ((0, type_1.isObject)(query[conditionKey])) {
213
- if ((0, type_1.isObject)(condition[conditionKey])) {
214
- Object.assign(query, condition);
215
- }
216
- else {
217
- console.warn("unmergable condition, query is object but condition is ".concat((0, type_1.getType)(condition), ", can only overwrite"), condition, key);
218
- query[conditionKey] = condition[conditionKey];
219
- }
220
- }
221
- else {
222
- console.warn("to-merge query is of type ".concat((0, type_1.getType)(query), ", can only overwrite"), query, condition, key);
223
- query[conditionKey] = condition[conditionKey];
224
- }
225
- }
226
- else {
227
- query[conditionKey] = condition[conditionKey];
228
- }
229
- }
230
- };
231
- return QueryEncoder;
232
- }());
@@ -1,15 +0,0 @@
1
- import { UpdateCommand } from '../commands/update';
2
- import { LogicCommand } from '../commands/logic';
3
- export type IQueryCondition = Record<string, any> | LogicCommand;
4
- export interface IUpdateCondition {
5
- [key: string]: any;
6
- }
7
- export declare class UpdateSerializer {
8
- private constructor();
9
- static encode(query: IQueryCondition | UpdateCommand): IUpdateCondition;
10
- encodeUpdate(query: IQueryCondition | UpdateCommand): IUpdateCondition;
11
- encodeUpdateCommand(query: UpdateCommand): IQueryCondition;
12
- encodeFieldUpdateCommand(query: UpdateCommand): IQueryCondition;
13
- encodeArrayUpdateCommand(query: UpdateCommand): IQueryCondition;
14
- encodeUpdateObject(query: Record<string, any>): IQueryCondition;
15
- }
@@ -1,142 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.UpdateSerializer = void 0;
4
- var update_1 = require("../commands/update");
5
- var symbol_1 = require("../helper/symbol");
6
- var type_1 = require("../utils/type");
7
- var operator_map_1 = require("../operator-map");
8
- var common_1 = require("./common");
9
- var UpdateSerializer = (function () {
10
- function UpdateSerializer() {
11
- }
12
- UpdateSerializer.encode = function (query) {
13
- var stringifier = new UpdateSerializer();
14
- return stringifier.encodeUpdate(query);
15
- };
16
- UpdateSerializer.prototype.encodeUpdate = function (query) {
17
- if ((0, update_1.isUpdateCommand)(query)) {
18
- return this.encodeUpdateCommand(query);
19
- }
20
- else if ((0, type_1.getType)(query) === 'object') {
21
- return this.encodeUpdateObject(query);
22
- }
23
- else {
24
- return query;
25
- }
26
- };
27
- UpdateSerializer.prototype.encodeUpdateCommand = function (query) {
28
- if (query.fieldName === symbol_1.SYMBOL_UNSET_FIELD_NAME) {
29
- throw new Error('Cannot encode a comparison command with unset field name');
30
- }
31
- switch (query.operator) {
32
- case update_1.UPDATE_COMMANDS_LITERAL.PUSH:
33
- case update_1.UPDATE_COMMANDS_LITERAL.PULL:
34
- case update_1.UPDATE_COMMANDS_LITERAL.PULL_ALL:
35
- case update_1.UPDATE_COMMANDS_LITERAL.POP:
36
- case update_1.UPDATE_COMMANDS_LITERAL.SHIFT:
37
- case update_1.UPDATE_COMMANDS_LITERAL.UNSHIFT:
38
- case update_1.UPDATE_COMMANDS_LITERAL.ADD_TO_SET: {
39
- return this.encodeArrayUpdateCommand(query);
40
- }
41
- default: {
42
- return this.encodeFieldUpdateCommand(query);
43
- }
44
- }
45
- };
46
- UpdateSerializer.prototype.encodeFieldUpdateCommand = function (query) {
47
- var _a, _b, _c, _d;
48
- var $op = (0, operator_map_1.operatorToString)(query.operator);
49
- switch (query.operator) {
50
- case update_1.UPDATE_COMMANDS_LITERAL.REMOVE: {
51
- return _a = {},
52
- _a[$op] = (_b = {},
53
- _b[query.fieldName] = '',
54
- _b),
55
- _a;
56
- }
57
- default: {
58
- return _c = {},
59
- _c[$op] = (_d = {},
60
- _d[query.fieldName] = query.operands[0],
61
- _d),
62
- _c;
63
- }
64
- }
65
- };
66
- UpdateSerializer.prototype.encodeArrayUpdateCommand = function (query) {
67
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
68
- var $op = (0, operator_map_1.operatorToString)(query.operator);
69
- switch (query.operator) {
70
- case update_1.UPDATE_COMMANDS_LITERAL.PUSH: {
71
- var modifiers = void 0;
72
- if ((0, type_1.isArray)(query.operands)) {
73
- modifiers = {
74
- $each: query.operands.map(common_1.encodeInternalDataType)
75
- };
76
- }
77
- else {
78
- modifiers = query.operands;
79
- }
80
- return _a = {},
81
- _a[$op] = (_b = {},
82
- _b[query.fieldName] = modifiers,
83
- _b),
84
- _a;
85
- }
86
- case update_1.UPDATE_COMMANDS_LITERAL.UNSHIFT: {
87
- var modifiers = {
88
- $each: query.operands.map(common_1.encodeInternalDataType),
89
- $position: 0
90
- };
91
- return _c = {},
92
- _c[$op] = (_d = {},
93
- _d[query.fieldName] = modifiers,
94
- _d),
95
- _c;
96
- }
97
- case update_1.UPDATE_COMMANDS_LITERAL.POP: {
98
- return _e = {},
99
- _e[$op] = (_f = {},
100
- _f[query.fieldName] = 1,
101
- _f),
102
- _e;
103
- }
104
- case update_1.UPDATE_COMMANDS_LITERAL.SHIFT: {
105
- return _g = {},
106
- _g[$op] = (_h = {},
107
- _h[query.fieldName] = -1,
108
- _h),
109
- _g;
110
- }
111
- default: {
112
- return _j = {},
113
- _j[$op] = (_k = {},
114
- _k[query.fieldName] = (0, common_1.encodeInternalDataType)(query.operands),
115
- _k),
116
- _j;
117
- }
118
- }
119
- };
120
- UpdateSerializer.prototype.encodeUpdateObject = function (query) {
121
- var flattened = (0, common_1.flattenQueryObject)(query);
122
- for (var key in flattened) {
123
- if (/^\$/.test(key))
124
- continue;
125
- var val = flattened[key];
126
- if ((0, update_1.isUpdateCommand)(val)) {
127
- flattened[key] = val._setFieldName(key);
128
- var condition = this.encodeUpdateCommand(flattened[key]);
129
- (0, common_1.mergeConditionAfterEncode)(flattened, condition, key);
130
- }
131
- else {
132
- flattened[key] = val = (0, common_1.encodeInternalDataType)(val);
133
- var $setCommand = new update_1.UpdateCommand(update_1.UPDATE_COMMANDS_LITERAL.SET, [val], key);
134
- var condition = this.encodeUpdateCommand($setCommand);
135
- (0, common_1.mergeConditionAfterEncode)(flattened, condition, key);
136
- }
137
- }
138
- return flattened;
139
- };
140
- return UpdateSerializer;
141
- }());
142
- exports.UpdateSerializer = UpdateSerializer;
@@ -1,13 +0,0 @@
1
- export declare class ServerDate {
2
- readonly offset: number;
3
- constructor({ offset }?: {
4
- offset?: number;
5
- });
6
- get _internalType(): import("../utils/symbol").InternalSymbol;
7
- parse(): {
8
- $date: {
9
- offset: number;
10
- };
11
- };
12
- }
13
- export declare function ServerDateConstructor(opt: any): ServerDate;
@@ -1,30 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ServerDateConstructor = exports.ServerDate = void 0;
4
- var symbol_1 = require("../helper/symbol");
5
- var ServerDate = (function () {
6
- function ServerDate(_a) {
7
- var _b = _a === void 0 ? {} : _a, _c = _b.offset, offset = _c === void 0 ? 0 : _c;
8
- this.offset = offset;
9
- }
10
- Object.defineProperty(ServerDate.prototype, "_internalType", {
11
- get: function () {
12
- return symbol_1.SYMBOL_SERVER_DATE;
13
- },
14
- enumerable: false,
15
- configurable: true
16
- });
17
- ServerDate.prototype.parse = function () {
18
- return {
19
- $date: {
20
- offset: this.offset
21
- }
22
- };
23
- };
24
- return ServerDate;
25
- }());
26
- exports.ServerDate = ServerDate;
27
- function ServerDateConstructor(opt) {
28
- return new ServerDate(opt);
29
- }
30
- exports.ServerDateConstructor = ServerDateConstructor;
@@ -1,7 +0,0 @@
1
- import { DocumentReference } from './document';
2
- import { Query } from './query';
3
- export declare class CollectionReference extends Query {
4
- get name(): string;
5
- doc(docID?: string | number): DocumentReference;
6
- add(data: any): Promise<any>;
7
- }
@@ -1,49 +0,0 @@
1
- "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
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");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
- Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.CollectionReference = void 0;
19
- var document_1 = require("./document");
20
- var query_1 = require("./query");
21
- var CollectionReference = (function (_super) {
22
- __extends(CollectionReference, _super);
23
- function CollectionReference(transaction, coll) {
24
- return _super.call(this, transaction, coll) || this;
25
- }
26
- Object.defineProperty(CollectionReference.prototype, "name", {
27
- get: function () {
28
- return this._coll;
29
- },
30
- enumerable: false,
31
- configurable: true
32
- });
33
- CollectionReference.prototype.doc = function (docID) {
34
- if (typeof docID !== 'string' && typeof docID !== 'number') {
35
- throw new Error('docId必须为字符串或数字');
36
- }
37
- return new document_1.DocumentReference(this._transaction, this._coll, docID);
38
- };
39
- CollectionReference.prototype.add = function (data) {
40
- var docID;
41
- if (data._id !== undefined) {
42
- docID = data._id;
43
- }
44
- var docRef = new document_1.DocumentReference(this._transaction, this._coll, docID);
45
- return docRef.create(data);
46
- };
47
- return CollectionReference;
48
- }(query_1.Query));
49
- exports.CollectionReference = CollectionReference;
@@ -1,27 +0,0 @@
1
- interface GetResult {
2
- requestId: string;
3
- data: any;
4
- }
5
- interface UpdateResult {
6
- requestId: string;
7
- updated: number;
8
- }
9
- type JsonString = string;
10
- interface SetResult extends UpdateResult {
11
- upserted: JsonString;
12
- }
13
- interface DeleteResult {
14
- requestId: string;
15
- deleted: number | string;
16
- }
17
- export declare class DocumentReference {
18
- readonly id: string | number;
19
- private _transaction;
20
- private _transactionId;
21
- create(data: any): Promise<any>;
22
- get(): Promise<GetResult>;
23
- set(data: Object): Promise<SetResult>;
24
- update(data: Object): Promise<UpdateResult>;
25
- delete(): Promise<DeleteResult>;
26
- }
27
- export {};