@cloudbase/database 0.9.20 → 0.9.22

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 (88) hide show
  1. package/dist/esm/aggregate.d.ts +29 -0
  2. package/dist/esm/aggregate.js +154 -0
  3. package/dist/esm/collection.d.ts +9 -0
  4. package/dist/esm/collection.js +44 -0
  5. package/dist/esm/command.d.ts +175 -0
  6. package/dist/esm/command.js +296 -0
  7. package/dist/esm/commands/logic.d.ts +24 -0
  8. package/dist/esm/commands/logic.js +84 -0
  9. package/dist/esm/commands/query.d.ts +68 -0
  10. package/dist/esm/commands/query.js +152 -0
  11. package/dist/esm/commands/update.d.ts +29 -0
  12. package/dist/esm/commands/update.js +46 -0
  13. package/dist/esm/config/app.config.d.ts +6 -0
  14. package/dist/esm/config/app.config.js +5 -0
  15. package/dist/esm/config/error.config.d.ts +3 -0
  16. package/dist/esm/config/error.config.js +13 -0
  17. package/dist/esm/const/code.d.ts +30 -0
  18. package/dist/esm/const/code.js +30 -0
  19. package/dist/esm/constant.d.ts +51 -0
  20. package/dist/esm/constant.js +65 -0
  21. package/dist/esm/document.d.ts +11 -0
  22. package/dist/esm/document.js +247 -0
  23. package/dist/esm/geo/index.d.ts +6 -0
  24. package/dist/esm/geo/index.js +6 -0
  25. package/dist/esm/geo/interface.d.ts +24 -0
  26. package/dist/esm/geo/interface.js +0 -0
  27. package/dist/esm/geo/lineString.d.ts +19 -0
  28. package/dist/esm/geo/lineString.js +83 -0
  29. package/dist/esm/geo/multiLineString.d.ts +18 -0
  30. package/dist/esm/geo/multiLineString.js +92 -0
  31. package/dist/esm/geo/multiPoint.d.ts +18 -0
  32. package/dist/esm/geo/multiPoint.js +76 -0
  33. package/dist/esm/geo/multiPolygon.d.ts +18 -0
  34. package/dist/esm/geo/multiPolygon.js +119 -0
  35. package/dist/esm/geo/point.d.ts +19 -0
  36. package/dist/esm/geo/point.js +47 -0
  37. package/dist/esm/geo/polygon.d.ts +19 -0
  38. package/dist/esm/geo/polygon.js +106 -0
  39. package/dist/esm/helper/symbol.d.ts +14 -0
  40. package/dist/esm/helper/symbol.js +14 -0
  41. package/dist/esm/index.d.ts +33 -0
  42. package/dist/esm/index.js +41 -0
  43. package/dist/esm/lib/util.d.ts +1 -0
  44. package/dist/esm/lib/util.js +23 -0
  45. package/dist/esm/operator-map.d.ts +4 -0
  46. package/dist/esm/operator-map.js +20 -0
  47. package/dist/esm/query.d.ts +22 -0
  48. package/dist/esm/query.js +249 -0
  49. package/dist/esm/regexp/index.d.ts +14 -0
  50. package/dist/esm/regexp/index.js +29 -0
  51. package/dist/esm/serializer/common.d.ts +11 -0
  52. package/dist/esm/serializer/common.js +113 -0
  53. package/dist/esm/serializer/datatype.d.ts +7 -0
  54. package/dist/esm/serializer/datatype.js +122 -0
  55. package/dist/esm/serializer/query.d.ts +7 -0
  56. package/dist/esm/serializer/query.js +229 -0
  57. package/dist/esm/serializer/update.d.ts +15 -0
  58. package/dist/esm/serializer/update.js +139 -0
  59. package/dist/esm/serverDate/index.d.ts +13 -0
  60. package/dist/esm/serverDate/index.js +26 -0
  61. package/dist/esm/transaction/collection.d.ts +7 -0
  62. package/dist/esm/transaction/collection.js +44 -0
  63. package/dist/esm/transaction/document.d.ts +27 -0
  64. package/dist/esm/transaction/document.js +203 -0
  65. package/dist/esm/transaction/index.d.ts +30 -0
  66. package/dist/esm/transaction/index.js +210 -0
  67. package/dist/esm/transaction/query.d.ts +5 -0
  68. package/dist/esm/transaction/query.js +8 -0
  69. package/dist/esm/typings/index.d.ts +40 -0
  70. package/dist/esm/typings/index.js +0 -0
  71. package/dist/esm/typings/realtime.d.ts +219 -0
  72. package/dist/esm/typings/realtime.js +0 -0
  73. package/dist/esm/util.d.ts +9 -0
  74. package/dist/esm/util.js +142 -0
  75. package/dist/esm/utils/error.d.ts +37 -0
  76. package/dist/esm/utils/error.js +82 -0
  77. package/dist/esm/utils/msg.d.ts +0 -0
  78. package/dist/esm/utils/msg.js +0 -0
  79. package/dist/esm/utils/symbol.d.ts +8 -0
  80. package/dist/esm/utils/symbol.js +55 -0
  81. package/dist/esm/utils/type.d.ts +13 -0
  82. package/dist/esm/utils/type.js +20 -0
  83. package/dist/esm/utils/utils.d.ts +4 -0
  84. package/dist/esm/utils/utils.js +33 -0
  85. package/dist/esm/validate.d.ts +1 -0
  86. package/dist/esm/validate.js +57 -0
  87. package/package.json +4 -6
  88. package/src/transaction/document.ts +2 -2
@@ -0,0 +1,57 @@
1
+ import { ErrorCode, WhereFilterOpList, OrderDirectionList, FieldType } from './constant';
2
+ import { Util } from './util';
3
+ var Validate = (function () {
4
+ function Validate() {
5
+ }
6
+ Validate.isGeopoint = function (point, degree) {
7
+ if (Util.whichType(degree) !== FieldType.Number) {
8
+ throw new Error('Geo Point must be number type');
9
+ }
10
+ var degreeAbs = Math.abs(degree);
11
+ if (point === 'latitude' && degreeAbs > 90) {
12
+ throw new Error('latitude should be a number ranges from -90 to 90');
13
+ }
14
+ else if (point === 'longitude' && degreeAbs > 180) {
15
+ throw new Error('longitude should be a number ranges from -180 to 180');
16
+ }
17
+ return true;
18
+ };
19
+ Validate.isInteger = function (param, num) {
20
+ if (!Number.isInteger(num)) {
21
+ throw new Error(param + ErrorCode.IntergerError);
22
+ }
23
+ return true;
24
+ };
25
+ Validate.isFieldOrder = function (direction) {
26
+ if (OrderDirectionList.indexOf(direction) === -1) {
27
+ throw new Error(ErrorCode.DirectionError);
28
+ }
29
+ return true;
30
+ };
31
+ Validate.isFieldPath = function (path) {
32
+ if (!/^[a-zA-Z0-9-_\.]/.test(path)) {
33
+ throw new Error();
34
+ }
35
+ return true;
36
+ };
37
+ Validate.isOperator = function (op) {
38
+ if (WhereFilterOpList.indexOf(op) === -1) {
39
+ throw new Error(ErrorCode.OpStrError);
40
+ }
41
+ return true;
42
+ };
43
+ Validate.isCollName = function (name) {
44
+ if (!/^[a-zA-Z0-9]([a-zA-Z0-9-_]){1,32}$/.test(name)) {
45
+ throw new Error(ErrorCode.CollNameError);
46
+ }
47
+ return true;
48
+ };
49
+ Validate.isDocID = function (docId) {
50
+ if (!/^([a-fA-F0-9]){24}$/.test(docId)) {
51
+ throw new Error(ErrorCode.DocIDError);
52
+ }
53
+ return true;
54
+ };
55
+ return Validate;
56
+ }());
57
+ export { Validate };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudbase/database",
3
- "version": "0.9.20",
3
+ "version": "0.9.22",
4
4
  "description": "database for (node.)js sdk ",
5
5
  "main": "dist/commonjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -11,7 +11,8 @@
11
11
  "eslint": "eslint \"./**/*.ts\"",
12
12
  "eslint-fix": "eslint --fix \"./**/*.ts\"",
13
13
  "test": "echo \"Error: no test specified\" && exit 1",
14
- "build": "npx tsc -p tsconfig.json && npx tsc -p tsconfig.esm.json"
14
+ "build": "tsc -p tsconfig.json && tsc -p tsconfig.esm.json",
15
+ "prepublishOnly": "npm run build"
15
16
  },
16
17
  "author": "",
17
18
  "license": "ISC",
@@ -25,9 +26,6 @@
25
26
  },
26
27
  "sideEffects": false,
27
28
  "dependencies": {
28
- "bson": "^4.0.2",
29
- "lodash.clonedeep": "4.5.0",
30
- "lodash.set": "4.3.2",
31
- "lodash.unset": "4.5.2"
29
+ "bson": "^4.0.2"
32
30
  }
33
31
  }
@@ -168,7 +168,7 @@ export class DocumentReference {
168
168
  if ((res as TcbError).code) throw res
169
169
  return {
170
170
  ...res,
171
- updated: EJSON.parse((res as SetResult).updated),
171
+ updated: EJSON.parse((res as SetResult).updated as any) as any,
172
172
  upserted: (res as SetResult).upserted
173
173
  ? JSON.parse((res as SetResult).upserted as string)
174
174
  : null
@@ -214,7 +214,7 @@ export class DocumentReference {
214
214
  if ((res as TcbError).code) throw res
215
215
  return {
216
216
  ...res,
217
- deleted: EJSON.parse((res as DeleteResult).deleted)
217
+ deleted: EJSON.parse((res as DeleteResult).deleted as any) as any
218
218
  }
219
219
  }
220
220
  }