@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.
- package/dist/esm/aggregate.d.ts +29 -0
- package/dist/esm/aggregate.js +154 -0
- package/dist/esm/collection.d.ts +9 -0
- package/dist/esm/collection.js +44 -0
- package/dist/esm/command.d.ts +175 -0
- package/dist/esm/command.js +296 -0
- package/dist/esm/commands/logic.d.ts +24 -0
- package/dist/esm/commands/logic.js +84 -0
- package/dist/esm/commands/query.d.ts +68 -0
- package/dist/esm/commands/query.js +152 -0
- package/dist/esm/commands/update.d.ts +29 -0
- package/dist/esm/commands/update.js +46 -0
- package/dist/esm/config/app.config.d.ts +6 -0
- package/dist/esm/config/app.config.js +5 -0
- package/dist/esm/config/error.config.d.ts +3 -0
- package/dist/esm/config/error.config.js +13 -0
- package/dist/esm/const/code.d.ts +30 -0
- package/dist/esm/const/code.js +30 -0
- package/dist/esm/constant.d.ts +51 -0
- package/dist/esm/constant.js +65 -0
- package/dist/esm/document.d.ts +11 -0
- package/dist/esm/document.js +247 -0
- package/dist/esm/geo/index.d.ts +6 -0
- package/dist/esm/geo/index.js +6 -0
- package/dist/esm/geo/interface.d.ts +24 -0
- package/dist/esm/geo/interface.js +0 -0
- package/dist/esm/geo/lineString.d.ts +19 -0
- package/dist/esm/geo/lineString.js +83 -0
- package/dist/esm/geo/multiLineString.d.ts +18 -0
- package/dist/esm/geo/multiLineString.js +92 -0
- package/dist/esm/geo/multiPoint.d.ts +18 -0
- package/dist/esm/geo/multiPoint.js +76 -0
- package/dist/esm/geo/multiPolygon.d.ts +18 -0
- package/dist/esm/geo/multiPolygon.js +119 -0
- package/dist/esm/geo/point.d.ts +19 -0
- package/dist/esm/geo/point.js +47 -0
- package/dist/esm/geo/polygon.d.ts +19 -0
- package/dist/esm/geo/polygon.js +106 -0
- package/dist/esm/helper/symbol.d.ts +14 -0
- package/dist/esm/helper/symbol.js +14 -0
- package/dist/esm/index.d.ts +33 -0
- package/dist/esm/index.js +41 -0
- package/dist/esm/lib/util.d.ts +1 -0
- package/dist/esm/lib/util.js +23 -0
- package/dist/esm/operator-map.d.ts +4 -0
- package/dist/esm/operator-map.js +20 -0
- package/dist/esm/query.d.ts +22 -0
- package/dist/esm/query.js +249 -0
- package/dist/esm/regexp/index.d.ts +14 -0
- package/dist/esm/regexp/index.js +29 -0
- package/dist/esm/serializer/common.d.ts +11 -0
- package/dist/esm/serializer/common.js +113 -0
- package/dist/esm/serializer/datatype.d.ts +7 -0
- package/dist/esm/serializer/datatype.js +122 -0
- package/dist/esm/serializer/query.d.ts +7 -0
- package/dist/esm/serializer/query.js +229 -0
- package/dist/esm/serializer/update.d.ts +15 -0
- package/dist/esm/serializer/update.js +139 -0
- package/dist/esm/serverDate/index.d.ts +13 -0
- package/dist/esm/serverDate/index.js +26 -0
- package/dist/esm/transaction/collection.d.ts +7 -0
- package/dist/esm/transaction/collection.js +44 -0
- package/dist/esm/transaction/document.d.ts +27 -0
- package/dist/esm/transaction/document.js +203 -0
- package/dist/esm/transaction/index.d.ts +30 -0
- package/dist/esm/transaction/index.js +210 -0
- package/dist/esm/transaction/query.d.ts +5 -0
- package/dist/esm/transaction/query.js +8 -0
- package/dist/esm/typings/index.d.ts +40 -0
- package/dist/esm/typings/index.js +0 -0
- package/dist/esm/typings/realtime.d.ts +219 -0
- package/dist/esm/typings/realtime.js +0 -0
- package/dist/esm/util.d.ts +9 -0
- package/dist/esm/util.js +142 -0
- package/dist/esm/utils/error.d.ts +37 -0
- package/dist/esm/utils/error.js +82 -0
- package/dist/esm/utils/msg.d.ts +0 -0
- package/dist/esm/utils/msg.js +0 -0
- package/dist/esm/utils/symbol.d.ts +8 -0
- package/dist/esm/utils/symbol.js +55 -0
- package/dist/esm/utils/type.d.ts +13 -0
- package/dist/esm/utils/type.js +20 -0
- package/dist/esm/utils/utils.d.ts +4 -0
- package/dist/esm/utils/utils.js +33 -0
- package/dist/esm/validate.d.ts +1 -0
- package/dist/esm/validate.js +57 -0
- package/package.json +4 -6
- 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.
|
|
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": "
|
|
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
|
}
|