@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,229 +0,0 @@
1
- import { isQueryCommand, isComparisonCommand, QUERY_COMMANDS_LITERAL } from '../commands/query';
2
- import { isLogicCommand, LOGIC_COMMANDS_LITERAL } from '../commands/logic';
3
- import { SYMBOL_UNSET_FIELD_NAME } from '../helper/symbol';
4
- import { getType, isObject, isArray, isRegExp } from '../utils/type';
5
- import { operatorToString } from '../operator-map';
6
- import { flattenQueryObject, isConversionRequired, encodeInternalDataType } from './common';
7
- var QuerySerializer = (function () {
8
- function QuerySerializer() {
9
- }
10
- QuerySerializer.encode = function (query) {
11
- var encoder = new QueryEncoder();
12
- return encoder.encodeQuery(query);
13
- };
14
- return QuerySerializer;
15
- }());
16
- export { QuerySerializer };
17
- var QueryEncoder = (function () {
18
- function QueryEncoder() {
19
- }
20
- QueryEncoder.prototype.encodeQuery = function (query, key) {
21
- var _a;
22
- if (isConversionRequired(query)) {
23
- if (isLogicCommand(query)) {
24
- return this.encodeLogicCommand(query);
25
- }
26
- else if (isQueryCommand(query)) {
27
- return this.encodeQueryCommand(query);
28
- }
29
- else {
30
- return _a = {}, _a[key] = this.encodeQueryObject(query), _a;
31
- }
32
- }
33
- else {
34
- if (isObject(query)) {
35
- return this.encodeQueryObject(query);
36
- }
37
- else {
38
- return query;
39
- }
40
- }
41
- };
42
- QueryEncoder.prototype.encodeRegExp = function (query) {
43
- return {
44
- $regex: query.source,
45
- $options: query.flags
46
- };
47
- };
48
- QueryEncoder.prototype.encodeLogicCommand = function (query) {
49
- var _a, _b, _c, _d, _e, _f, _g;
50
- var _this = this;
51
- switch (query.operator) {
52
- case LOGIC_COMMANDS_LITERAL.NOR:
53
- case LOGIC_COMMANDS_LITERAL.AND:
54
- case LOGIC_COMMANDS_LITERAL.OR: {
55
- var $op = operatorToString(query.operator);
56
- var subqueries = query.operands.map(function (oprand) {
57
- return _this.encodeQuery(oprand, query.fieldName);
58
- });
59
- return _a = {},
60
- _a[$op] = subqueries,
61
- _a;
62
- }
63
- case LOGIC_COMMANDS_LITERAL.NOT: {
64
- var $op = operatorToString(query.operator);
65
- var operatorExpression = query.operands[0];
66
- if (isRegExp(operatorExpression)) {
67
- return _b = {},
68
- _b[query.fieldName] = (_c = {},
69
- _c[$op] = this.encodeRegExp(operatorExpression),
70
- _c),
71
- _b;
72
- }
73
- else {
74
- var subqueries = this.encodeQuery(operatorExpression)[query.fieldName];
75
- return _d = {},
76
- _d[query.fieldName] = (_e = {},
77
- _e[$op] = subqueries,
78
- _e),
79
- _d;
80
- }
81
- }
82
- default: {
83
- var $op = operatorToString(query.operator);
84
- if (query.operands.length === 1) {
85
- var subquery = this.encodeQuery(query.operands[0]);
86
- return _f = {},
87
- _f[$op] = subquery,
88
- _f;
89
- }
90
- else {
91
- var subqueries = query.operands.map(this.encodeQuery.bind(this));
92
- return _g = {},
93
- _g[$op] = subqueries,
94
- _g;
95
- }
96
- }
97
- }
98
- };
99
- QueryEncoder.prototype.encodeQueryCommand = function (query) {
100
- if (isComparisonCommand(query)) {
101
- return this.encodeComparisonCommand(query);
102
- }
103
- else {
104
- return this.encodeComparisonCommand(query);
105
- }
106
- };
107
- QueryEncoder.prototype.encodeComparisonCommand = function (query) {
108
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
109
- if (query.fieldName === SYMBOL_UNSET_FIELD_NAME) {
110
- throw new Error('Cannot encode a comparison command with unset field name');
111
- }
112
- var $op = operatorToString(query.operator);
113
- switch (query.operator) {
114
- case QUERY_COMMANDS_LITERAL.EQ:
115
- case QUERY_COMMANDS_LITERAL.NEQ:
116
- case QUERY_COMMANDS_LITERAL.LT:
117
- case QUERY_COMMANDS_LITERAL.LTE:
118
- case QUERY_COMMANDS_LITERAL.GT:
119
- case QUERY_COMMANDS_LITERAL.GTE:
120
- case QUERY_COMMANDS_LITERAL.ELEM_MATCH:
121
- case QUERY_COMMANDS_LITERAL.EXISTS:
122
- case QUERY_COMMANDS_LITERAL.SIZE:
123
- case QUERY_COMMANDS_LITERAL.MOD: {
124
- return _a = {},
125
- _a[query.fieldName] = (_b = {},
126
- _b[$op] = encodeInternalDataType(query.operands[0]),
127
- _b),
128
- _a;
129
- }
130
- case QUERY_COMMANDS_LITERAL.IN:
131
- case QUERY_COMMANDS_LITERAL.NIN:
132
- case QUERY_COMMANDS_LITERAL.ALL: {
133
- return _c = {},
134
- _c[query.fieldName] = (_d = {},
135
- _d[$op] = encodeInternalDataType(query.operands),
136
- _d),
137
- _c;
138
- }
139
- case QUERY_COMMANDS_LITERAL.GEO_NEAR: {
140
- var options = query.operands[0];
141
- return _e = {},
142
- _e[query.fieldName] = {
143
- $nearSphere: {
144
- $geometry: options.geometry.toJSON(),
145
- $maxDistance: options.maxDistance,
146
- $minDistance: options.minDistance
147
- }
148
- },
149
- _e;
150
- }
151
- case QUERY_COMMANDS_LITERAL.GEO_WITHIN: {
152
- var options = query.operands[0];
153
- return _f = {},
154
- _f[query.fieldName] = {
155
- $geoWithin: {
156
- $geometry: options.geometry.toJSON()
157
- }
158
- },
159
- _f;
160
- }
161
- case QUERY_COMMANDS_LITERAL.GEO_INTERSECTS: {
162
- var options = query.operands[0];
163
- return _g = {},
164
- _g[query.fieldName] = {
165
- $geoIntersects: {
166
- $geometry: options.geometry.toJSON()
167
- }
168
- },
169
- _g;
170
- }
171
- default: {
172
- return _h = {},
173
- _h[query.fieldName] = (_j = {},
174
- _j[$op] = encodeInternalDataType(query.operands[0]),
175
- _j),
176
- _h;
177
- }
178
- }
179
- };
180
- QueryEncoder.prototype.encodeQueryObject = function (query) {
181
- var flattened = flattenQueryObject(query);
182
- for (var key in flattened) {
183
- var val = flattened[key];
184
- if (isLogicCommand(val)) {
185
- flattened[key] = val._setFieldName(key);
186
- var condition = this.encodeLogicCommand(flattened[key]);
187
- this.mergeConditionAfterEncode(flattened, condition, key);
188
- }
189
- else if (isComparisonCommand(val)) {
190
- flattened[key] = val._setFieldName(key);
191
- var condition = this.encodeComparisonCommand(flattened[key]);
192
- this.mergeConditionAfterEncode(flattened, condition, key);
193
- }
194
- else if (isConversionRequired(val)) {
195
- flattened[key] = encodeInternalDataType(val);
196
- }
197
- }
198
- return flattened;
199
- };
200
- QueryEncoder.prototype.mergeConditionAfterEncode = function (query, condition, key) {
201
- if (!condition[key]) {
202
- delete query[key];
203
- }
204
- for (var conditionKey in condition) {
205
- if (query[conditionKey]) {
206
- if (isArray(query[conditionKey])) {
207
- query[conditionKey] = query[conditionKey].concat(condition[conditionKey]);
208
- }
209
- else if (isObject(query[conditionKey])) {
210
- if (isObject(condition[conditionKey])) {
211
- Object.assign(query, condition);
212
- }
213
- else {
214
- console.warn("unmergable condition, query is object but condition is ".concat(getType(condition), ", can only overwrite"), condition, key);
215
- query[conditionKey] = condition[conditionKey];
216
- }
217
- }
218
- else {
219
- console.warn("to-merge query is of type ".concat(getType(query), ", can only overwrite"), query, condition, key);
220
- query[conditionKey] = condition[conditionKey];
221
- }
222
- }
223
- else {
224
- query[conditionKey] = condition[conditionKey];
225
- }
226
- }
227
- };
228
- return QueryEncoder;
229
- }());
@@ -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,139 +0,0 @@
1
- import { UpdateCommand, isUpdateCommand, UPDATE_COMMANDS_LITERAL } from '../commands/update';
2
- import { SYMBOL_UNSET_FIELD_NAME } from '../helper/symbol';
3
- import { getType, isArray } from '../utils/type';
4
- import { operatorToString } from '../operator-map';
5
- import { flattenQueryObject, encodeInternalDataType, mergeConditionAfterEncode } from './common';
6
- var UpdateSerializer = (function () {
7
- function UpdateSerializer() {
8
- }
9
- UpdateSerializer.encode = function (query) {
10
- var stringifier = new UpdateSerializer();
11
- return stringifier.encodeUpdate(query);
12
- };
13
- UpdateSerializer.prototype.encodeUpdate = function (query) {
14
- if (isUpdateCommand(query)) {
15
- return this.encodeUpdateCommand(query);
16
- }
17
- else if (getType(query) === 'object') {
18
- return this.encodeUpdateObject(query);
19
- }
20
- else {
21
- return query;
22
- }
23
- };
24
- UpdateSerializer.prototype.encodeUpdateCommand = function (query) {
25
- if (query.fieldName === SYMBOL_UNSET_FIELD_NAME) {
26
- throw new Error('Cannot encode a comparison command with unset field name');
27
- }
28
- switch (query.operator) {
29
- case UPDATE_COMMANDS_LITERAL.PUSH:
30
- case UPDATE_COMMANDS_LITERAL.PULL:
31
- case UPDATE_COMMANDS_LITERAL.PULL_ALL:
32
- case UPDATE_COMMANDS_LITERAL.POP:
33
- case UPDATE_COMMANDS_LITERAL.SHIFT:
34
- case UPDATE_COMMANDS_LITERAL.UNSHIFT:
35
- case UPDATE_COMMANDS_LITERAL.ADD_TO_SET: {
36
- return this.encodeArrayUpdateCommand(query);
37
- }
38
- default: {
39
- return this.encodeFieldUpdateCommand(query);
40
- }
41
- }
42
- };
43
- UpdateSerializer.prototype.encodeFieldUpdateCommand = function (query) {
44
- var _a, _b, _c, _d;
45
- var $op = operatorToString(query.operator);
46
- switch (query.operator) {
47
- case UPDATE_COMMANDS_LITERAL.REMOVE: {
48
- return _a = {},
49
- _a[$op] = (_b = {},
50
- _b[query.fieldName] = '',
51
- _b),
52
- _a;
53
- }
54
- default: {
55
- return _c = {},
56
- _c[$op] = (_d = {},
57
- _d[query.fieldName] = query.operands[0],
58
- _d),
59
- _c;
60
- }
61
- }
62
- };
63
- UpdateSerializer.prototype.encodeArrayUpdateCommand = function (query) {
64
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
65
- var $op = operatorToString(query.operator);
66
- switch (query.operator) {
67
- case UPDATE_COMMANDS_LITERAL.PUSH: {
68
- var modifiers = void 0;
69
- if (isArray(query.operands)) {
70
- modifiers = {
71
- $each: query.operands.map(encodeInternalDataType)
72
- };
73
- }
74
- else {
75
- modifiers = query.operands;
76
- }
77
- return _a = {},
78
- _a[$op] = (_b = {},
79
- _b[query.fieldName] = modifiers,
80
- _b),
81
- _a;
82
- }
83
- case UPDATE_COMMANDS_LITERAL.UNSHIFT: {
84
- var modifiers = {
85
- $each: query.operands.map(encodeInternalDataType),
86
- $position: 0
87
- };
88
- return _c = {},
89
- _c[$op] = (_d = {},
90
- _d[query.fieldName] = modifiers,
91
- _d),
92
- _c;
93
- }
94
- case UPDATE_COMMANDS_LITERAL.POP: {
95
- return _e = {},
96
- _e[$op] = (_f = {},
97
- _f[query.fieldName] = 1,
98
- _f),
99
- _e;
100
- }
101
- case UPDATE_COMMANDS_LITERAL.SHIFT: {
102
- return _g = {},
103
- _g[$op] = (_h = {},
104
- _h[query.fieldName] = -1,
105
- _h),
106
- _g;
107
- }
108
- default: {
109
- return _j = {},
110
- _j[$op] = (_k = {},
111
- _k[query.fieldName] = encodeInternalDataType(query.operands),
112
- _k),
113
- _j;
114
- }
115
- }
116
- };
117
- UpdateSerializer.prototype.encodeUpdateObject = function (query) {
118
- var flattened = flattenQueryObject(query);
119
- for (var key in flattened) {
120
- if (/^\$/.test(key))
121
- continue;
122
- var val = flattened[key];
123
- if (isUpdateCommand(val)) {
124
- flattened[key] = val._setFieldName(key);
125
- var condition = this.encodeUpdateCommand(flattened[key]);
126
- mergeConditionAfterEncode(flattened, condition, key);
127
- }
128
- else {
129
- flattened[key] = val = encodeInternalDataType(val);
130
- var $setCommand = new UpdateCommand(UPDATE_COMMANDS_LITERAL.SET, [val], key);
131
- var condition = this.encodeUpdateCommand($setCommand);
132
- mergeConditionAfterEncode(flattened, condition, key);
133
- }
134
- }
135
- return flattened;
136
- };
137
- return UpdateSerializer;
138
- }());
139
- export { 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,26 +0,0 @@
1
- import { SYMBOL_SERVER_DATE } from '../helper/symbol';
2
- var ServerDate = (function () {
3
- function ServerDate(_a) {
4
- var _b = _a === void 0 ? {} : _a, _c = _b.offset, offset = _c === void 0 ? 0 : _c;
5
- this.offset = offset;
6
- }
7
- Object.defineProperty(ServerDate.prototype, "_internalType", {
8
- get: function () {
9
- return SYMBOL_SERVER_DATE;
10
- },
11
- enumerable: false,
12
- configurable: true
13
- });
14
- ServerDate.prototype.parse = function () {
15
- return {
16
- $date: {
17
- offset: this.offset
18
- }
19
- };
20
- };
21
- return ServerDate;
22
- }());
23
- export { ServerDate };
24
- export function ServerDateConstructor(opt) {
25
- return new ServerDate(opt);
26
- }
@@ -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,46 +0,0 @@
1
- var __extends = (this && this.__extends) || (function () {
2
- var extendStatics = function (d, b) {
3
- extendStatics = Object.setPrototypeOf ||
4
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6
- return extendStatics(d, b);
7
- };
8
- return function (d, b) {
9
- if (typeof b !== "function" && b !== null)
10
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
11
- extendStatics(d, b);
12
- function __() { this.constructor = d; }
13
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14
- };
15
- })();
16
- import { DocumentReference } from './document';
17
- import { Query } from './query';
18
- var CollectionReference = (function (_super) {
19
- __extends(CollectionReference, _super);
20
- function CollectionReference(transaction, coll) {
21
- return _super.call(this, transaction, coll) || this;
22
- }
23
- Object.defineProperty(CollectionReference.prototype, "name", {
24
- get: function () {
25
- return this._coll;
26
- },
27
- enumerable: false,
28
- configurable: true
29
- });
30
- CollectionReference.prototype.doc = function (docID) {
31
- if (typeof docID !== 'string' && typeof docID !== 'number') {
32
- throw new Error('docId必须为字符串或数字');
33
- }
34
- return new DocumentReference(this._transaction, this._coll, docID);
35
- };
36
- CollectionReference.prototype.add = function (data) {
37
- var docID;
38
- if (data._id !== undefined) {
39
- docID = data._id;
40
- }
41
- var docRef = new DocumentReference(this._transaction, this._coll, docID);
42
- return docRef.create(data);
43
- };
44
- return CollectionReference;
45
- }(Query));
46
- export { 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 {};