@cloudbase/js-sdk 2.28.6 → 2.29.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.
- package/CHANGELOG.md +147 -0
- package/ai/dist/index.esm.js +2 -3
- package/ai/dist/index.esm.js.map +1 -0
- package/ai/dist/index.js +2 -21
- package/ai/dist/index.js.map +1 -0
- package/apis/dist/index.esm.js +2 -3
- package/apis/dist/index.esm.js.map +1 -0
- package/apis/dist/index.js +2 -21
- package/apis/dist/index.js.map +1 -0
- package/app/dist/index.esm.js +2 -11
- package/app/dist/index.esm.js.map +1 -0
- package/app/dist/index.js +2 -18
- package/app/dist/index.js.map +1 -0
- package/auth/dist/index.d.ts +2 -2
- package/auth/dist/index.esm.js +3 -8
- package/auth/dist/index.esm.js.LICENSE.txt +12 -0
- package/auth/dist/index.esm.js.map +1 -0
- package/auth/dist/index.js +3 -13
- package/auth/dist/index.js.LICENSE.txt +12 -0
- package/auth/dist/index.js.map +1 -0
- package/cloudrun/dist/index.esm.js +2 -3
- package/cloudrun/dist/index.esm.js.map +1 -0
- package/cloudrun/dist/index.js +2 -21
- package/cloudrun/dist/index.js.map +1 -0
- package/container/dist/index.d.ts +2 -2
- package/container/dist/index.esm.js +2 -8
- package/container/dist/index.esm.js.map +1 -0
- package/container/dist/index.js +2 -13
- package/container/dist/index.js.map +1 -0
- package/database/dist/commonjs/aggregate.d.ts +29 -0
- package/database/dist/commonjs/aggregate.js +156 -0
- package/database/dist/commonjs/collection.d.ts +9 -0
- package/database/dist/commonjs/collection.js +49 -0
- package/database/dist/commonjs/command.d.ts +175 -0
- package/database/dist/commonjs/command.js +299 -0
- package/database/dist/commonjs/commands/logic.d.ts +24 -0
- package/database/dist/commonjs/commands/logic.js +89 -0
- package/database/dist/commonjs/commands/query.d.ts +68 -0
- package/database/dist/commonjs/commands/query.js +160 -0
- package/database/dist/commonjs/commands/update.d.ts +29 -0
- package/database/dist/commonjs/commands/update.js +51 -0
- package/database/dist/commonjs/config/app.config.d.ts +6 -0
- package/database/dist/commonjs/config/app.config.js +7 -0
- package/database/dist/commonjs/config/error.config.d.ts +3 -0
- package/database/dist/commonjs/config/error.config.js +16 -0
- package/database/dist/commonjs/const/code.d.ts +30 -0
- package/database/dist/commonjs/const/code.js +33 -0
- package/database/dist/commonjs/constant.d.ts +51 -0
- package/database/dist/commonjs/constant.js +75 -0
- package/database/dist/commonjs/document.d.ts +11 -0
- package/database/dist/commonjs/document.js +260 -0
- package/database/dist/commonjs/geo/index.d.ts +6 -0
- package/database/dist/commonjs/geo/index.js +22 -0
- package/database/dist/commonjs/geo/interface.d.ts +24 -0
- package/database/dist/commonjs/geo/interface.js +2 -0
- package/database/dist/commonjs/geo/lineString.d.ts +19 -0
- package/database/dist/commonjs/geo/lineString.js +86 -0
- package/database/dist/commonjs/geo/multiLineString.d.ts +18 -0
- package/database/dist/commonjs/geo/multiLineString.js +95 -0
- package/database/dist/commonjs/geo/multiPoint.d.ts +18 -0
- package/database/dist/commonjs/geo/multiPoint.js +79 -0
- package/database/dist/commonjs/geo/multiPolygon.d.ts +18 -0
- package/database/dist/commonjs/geo/multiPolygon.js +122 -0
- package/database/dist/commonjs/geo/point.d.ts +19 -0
- package/database/dist/commonjs/geo/point.js +50 -0
- package/database/dist/commonjs/geo/polygon.d.ts +19 -0
- package/database/dist/commonjs/geo/polygon.js +109 -0
- package/database/dist/commonjs/helper/symbol.d.ts +14 -0
- package/database/dist/commonjs/helper/symbol.js +31 -0
- package/database/dist/commonjs/index.d.ts +40 -0
- package/database/dist/commonjs/index.js +61 -0
- package/database/dist/commonjs/lib/util.d.ts +1 -0
- package/database/dist/commonjs/lib/util.js +26 -0
- package/database/dist/commonjs/operator-map.d.ts +4 -0
- package/database/dist/commonjs/operator-map.js +24 -0
- package/database/dist/commonjs/query.d.ts +22 -0
- package/database/dist/commonjs/query.js +252 -0
- package/database/dist/commonjs/regexp/index.d.ts +14 -0
- package/database/dist/commonjs/regexp/index.js +33 -0
- package/database/dist/commonjs/serializer/common.d.ts +11 -0
- package/database/dist/commonjs/serializer/common.js +127 -0
- package/database/dist/commonjs/serializer/datatype.d.ts +7 -0
- package/database/dist/commonjs/serializer/datatype.js +132 -0
- package/database/dist/commonjs/serializer/query.d.ts +7 -0
- package/database/dist/commonjs/serializer/query.js +232 -0
- package/database/dist/commonjs/serializer/update.d.ts +15 -0
- package/database/dist/commonjs/serializer/update.js +142 -0
- package/database/dist/commonjs/serverDate/index.d.ts +13 -0
- package/database/dist/commonjs/serverDate/index.js +30 -0
- package/database/dist/commonjs/transaction/collection.d.ts +7 -0
- package/database/dist/commonjs/transaction/collection.js +49 -0
- package/database/dist/commonjs/transaction/document.d.ts +27 -0
- package/database/dist/commonjs/transaction/document.js +205 -0
- package/database/dist/commonjs/transaction/index.d.ts +30 -0
- package/database/dist/commonjs/transaction/index.js +215 -0
- package/database/dist/commonjs/transaction/query.d.ts +43 -0
- package/database/dist/commonjs/transaction/query.js +261 -0
- package/database/dist/commonjs/typings/index.d.ts +40 -0
- package/database/dist/commonjs/typings/index.js +2 -0
- package/database/dist/commonjs/typings/realtime.d.ts +219 -0
- package/database/dist/commonjs/typings/realtime.js +2 -0
- package/database/dist/commonjs/util.d.ts +9 -0
- package/database/dist/commonjs/util.js +145 -0
- package/database/dist/commonjs/utils/error.d.ts +38 -0
- package/database/dist/commonjs/utils/error.js +91 -0
- package/database/dist/commonjs/utils/msg.d.ts +0 -0
- package/database/dist/commonjs/utils/msg.js +0 -0
- package/database/dist/commonjs/utils/symbol.d.ts +8 -0
- package/database/dist/commonjs/utils/symbol.js +58 -0
- package/database/dist/commonjs/utils/type.d.ts +13 -0
- package/database/dist/commonjs/utils/type.js +34 -0
- package/database/dist/commonjs/utils/utils.d.ts +4 -0
- package/database/dist/commonjs/utils/utils.js +39 -0
- package/database/dist/commonjs/validate.d.ts +1 -0
- package/database/dist/commonjs/validate.js +60 -0
- package/database/dist/esm/aggregate.d.ts +29 -0
- package/database/dist/esm/aggregate.js +154 -0
- package/database/dist/esm/collection.d.ts +9 -0
- package/database/dist/esm/collection.js +46 -0
- package/database/dist/esm/command.d.ts +175 -0
- package/database/dist/esm/command.js +296 -0
- package/database/dist/esm/commands/logic.d.ts +24 -0
- package/database/dist/esm/commands/logic.js +84 -0
- package/database/dist/esm/commands/query.d.ts +68 -0
- package/database/dist/esm/commands/query.js +154 -0
- package/database/dist/esm/commands/update.d.ts +29 -0
- package/database/dist/esm/commands/update.js +46 -0
- package/database/dist/esm/config/app.config.d.ts +6 -0
- package/database/dist/esm/config/app.config.js +5 -0
- package/database/dist/esm/config/error.config.d.ts +3 -0
- package/database/dist/esm/config/error.config.js +13 -0
- package/database/dist/esm/const/code.d.ts +30 -0
- package/database/dist/esm/const/code.js +30 -0
- package/database/dist/esm/constant.d.ts +51 -0
- package/database/dist/esm/constant.js +65 -0
- package/database/dist/esm/document.d.ts +11 -0
- package/database/dist/esm/document.js +257 -0
- package/database/dist/esm/geo/index.d.ts +6 -0
- package/database/dist/esm/geo/index.js +6 -0
- package/database/dist/esm/geo/interface.d.ts +24 -0
- package/database/dist/esm/geo/interface.js +1 -0
- package/database/dist/esm/geo/lineString.d.ts +19 -0
- package/database/dist/esm/geo/lineString.js +83 -0
- package/database/dist/esm/geo/multiLineString.d.ts +18 -0
- package/database/dist/esm/geo/multiLineString.js +92 -0
- package/database/dist/esm/geo/multiPoint.d.ts +18 -0
- package/database/dist/esm/geo/multiPoint.js +76 -0
- package/database/dist/esm/geo/multiPolygon.d.ts +18 -0
- package/database/dist/esm/geo/multiPolygon.js +119 -0
- package/database/dist/esm/geo/point.d.ts +19 -0
- package/database/dist/esm/geo/point.js +47 -0
- package/database/dist/esm/geo/polygon.d.ts +19 -0
- package/database/dist/esm/geo/polygon.js +106 -0
- package/database/dist/esm/helper/symbol.d.ts +14 -0
- package/database/dist/esm/helper/symbol.js +14 -0
- package/database/dist/esm/index.d.ts +40 -0
- package/database/dist/esm/index.js +55 -0
- package/database/dist/esm/lib/util.d.ts +1 -0
- package/database/dist/esm/lib/util.js +22 -0
- package/database/dist/esm/operator-map.d.ts +4 -0
- package/database/dist/esm/operator-map.js +20 -0
- package/database/dist/esm/query.d.ts +22 -0
- package/database/dist/esm/query.js +249 -0
- package/database/dist/esm/regexp/index.d.ts +14 -0
- package/database/dist/esm/regexp/index.js +29 -0
- package/database/dist/esm/serializer/common.d.ts +11 -0
- package/database/dist/esm/serializer/common.js +118 -0
- package/database/dist/esm/serializer/datatype.d.ts +7 -0
- package/database/dist/esm/serializer/datatype.js +127 -0
- package/database/dist/esm/serializer/query.d.ts +7 -0
- package/database/dist/esm/serializer/query.js +229 -0
- package/database/dist/esm/serializer/update.d.ts +15 -0
- package/database/dist/esm/serializer/update.js +139 -0
- package/database/dist/esm/serverDate/index.d.ts +13 -0
- package/database/dist/esm/serverDate/index.js +26 -0
- package/database/dist/esm/transaction/collection.d.ts +7 -0
- package/database/dist/esm/transaction/collection.js +46 -0
- package/database/dist/esm/transaction/document.d.ts +27 -0
- package/database/dist/esm/transaction/document.js +202 -0
- package/database/dist/esm/transaction/index.d.ts +30 -0
- package/database/dist/esm/transaction/index.js +210 -0
- package/database/dist/esm/transaction/query.d.ts +43 -0
- package/database/dist/esm/transaction/query.js +258 -0
- package/database/dist/esm/typings/index.d.ts +40 -0
- package/database/dist/esm/typings/index.js +1 -0
- package/database/dist/esm/typings/realtime.d.ts +219 -0
- package/database/dist/esm/typings/realtime.js +1 -0
- package/database/dist/esm/util.d.ts +9 -0
- package/database/dist/esm/util.js +142 -0
- package/database/dist/esm/utils/error.d.ts +38 -0
- package/database/dist/esm/utils/error.js +84 -0
- package/database/dist/esm/utils/msg.d.ts +0 -0
- package/database/dist/esm/utils/msg.js +0 -0
- package/database/dist/esm/utils/symbol.d.ts +8 -0
- package/database/dist/esm/utils/symbol.js +55 -0
- package/database/dist/esm/utils/type.d.ts +13 -0
- package/database/dist/esm/utils/type.js +20 -0
- package/database/dist/esm/utils/utils.d.ts +4 -0
- package/database/dist/esm/utils/utils.js +33 -0
- package/database/dist/esm/validate.d.ts +1 -0
- package/database/dist/esm/validate.js +57 -0
- package/database/package.json +34 -4
- package/dist/index.cjs.js +3 -40
- package/dist/index.cjs.js.LICENSE.txt +12 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.esm.js +3 -35
- package/dist/index.esm.js.LICENSE.txt +12 -0
- package/dist/index.esm.js.map +1 -0
- package/functions/dist/index.d.ts +2 -2
- package/functions/dist/index.esm.js +2 -8
- package/functions/dist/index.esm.js.map +1 -0
- package/functions/dist/index.js +2 -13
- package/functions/dist/index.js.map +1 -0
- package/index.d.ts +654 -45
- package/miniprogram_dist/ai.js +1 -1
- package/miniprogram_dist/apis.js +1 -1
- package/miniprogram_dist/app.js +1 -1
- package/miniprogram_dist/auth.js +1 -1
- package/miniprogram_dist/cloudrun.js +1 -1
- package/miniprogram_dist/container.js +1 -1
- package/miniprogram_dist/database.js +1 -1
- package/miniprogram_dist/functions.js +1 -1
- package/miniprogram_dist/index.js +1 -1
- package/miniprogram_dist/model.js +1 -1
- package/miniprogram_dist/mysql.js +1 -1
- package/miniprogram_dist/oauth.js +2 -1
- package/miniprogram_dist/realtime.js +1 -1
- package/miniprogram_dist/storage.js +1 -1
- package/model/dist/index.esm.js +2 -3
- package/model/dist/index.esm.js.map +1 -0
- package/model/dist/index.js +2 -21
- package/model/dist/index.js.map +1 -0
- package/mysql/dist/index.esm.js +2 -3
- package/mysql/dist/index.esm.js.map +1 -0
- package/mysql/dist/index.js +2 -21
- package/mysql/dist/index.js.map +1 -0
- package/oauth/dist/index.esm.js +3 -3
- package/oauth/dist/index.esm.js.LICENSE.txt +12 -0
- package/oauth/dist/index.esm.js.map +1 -0
- package/oauth/dist/index.js +3 -21
- package/oauth/dist/index.js.LICENSE.txt +12 -0
- package/oauth/dist/index.js.map +1 -0
- package/package.json +113 -20
- package/realtime/dist/index.d.ts +2 -2
- package/realtime/dist/index.esm.js +2 -8
- package/realtime/dist/index.esm.js.map +1 -0
- package/realtime/dist/index.js +2 -13
- package/realtime/dist/index.js.map +1 -0
- package/storage/dist/index.d.ts +2 -2
- package/storage/dist/index.esm.js +2 -4
- package/storage/dist/index.esm.js.map +1 -0
- package/storage/dist/index.js +2 -9
- package/storage/dist/index.js.map +1 -0
- package/types/analytics.d.ts +51 -0
- package/types/auth.d.ts +99 -0
- package/types/cache.d.ts +26 -0
- package/types/cloudrun.d.ts +9 -0
- package/types/component.d.ts +17 -0
- package/types/container.d.ts +93 -0
- package/types/database.d.ts +31 -0
- package/types/events.d.ts +13 -0
- package/types/functions.d.ts +40 -0
- package/types/index.d.ts +211 -0
- package/types/package.json +43 -0
- package/types/realtime.d.ts +350 -0
- package/types/request.d.ts +30 -0
- package/types/storage.d.ts +126 -0
- package/utilities/dist/cjs/adapters/index.d.ts +45 -0
- package/utilities/dist/cjs/adapters/index.js +68 -0
- package/utilities/dist/cjs/adapters/platforms/web.d.ts +20 -0
- package/utilities/dist/cjs/adapters/platforms/web.js +286 -0
- package/utilities/dist/cjs/constants/common.d.ts +6 -0
- package/utilities/dist/cjs/constants/common.js +24 -0
- package/utilities/dist/cjs/constants/errors.d.ts +8 -0
- package/utilities/dist/cjs/constants/errors.js +12 -0
- package/utilities/dist/cjs/constants/index.d.ts +3 -0
- package/utilities/dist/cjs/constants/index.js +21 -0
- package/utilities/dist/cjs/helpers/decorators.d.ts +11 -0
- package/utilities/dist/cjs/helpers/decorators.js +238 -0
- package/utilities/dist/cjs/helpers/index.d.ts +1 -0
- package/utilities/dist/cjs/helpers/index.js +18 -0
- package/utilities/dist/cjs/index.d.ts +13 -0
- package/utilities/dist/cjs/index.js +51 -0
- package/utilities/dist/cjs/libs/abortController.d.ts +9 -0
- package/utilities/dist/cjs/libs/abortController.js +25 -0
- package/utilities/dist/cjs/libs/cache.d.ts +17 -0
- package/utilities/dist/cjs/libs/cache.js +261 -0
- package/utilities/dist/cjs/libs/events.d.ts +27 -0
- package/utilities/dist/cjs/libs/events.js +108 -0
- package/utilities/dist/cjs/libs/langEvent.d.ts +3 -0
- package/utilities/dist/cjs/libs/langEvent.js +7 -0
- package/utilities/dist/cjs/libs/util.d.ts +49 -0
- package/utilities/dist/cjs/libs/util.js +282 -0
- package/utilities/dist/esm/adapters/index.d.ts +45 -0
- package/utilities/dist/esm/adapters/index.js +40 -0
- package/utilities/dist/esm/adapters/platforms/web.d.ts +20 -0
- package/utilities/dist/esm/adapters/platforms/web.js +282 -0
- package/utilities/dist/esm/constants/common.d.ts +6 -0
- package/utilities/dist/esm/constants/common.js +17 -0
- package/utilities/dist/esm/constants/errors.d.ts +8 -0
- package/utilities/dist/esm/constants/errors.js +9 -0
- package/utilities/dist/esm/constants/index.d.ts +3 -0
- package/utilities/dist/esm/constants/index.js +4 -0
- package/utilities/dist/esm/helpers/decorators.d.ts +11 -0
- package/utilities/dist/esm/helpers/decorators.js +234 -0
- package/utilities/dist/esm/helpers/index.d.ts +1 -0
- package/utilities/dist/esm/helpers/index.js +2 -0
- package/utilities/dist/esm/index.d.ts +13 -0
- package/utilities/dist/esm/index.js +14 -0
- package/utilities/dist/esm/libs/abortController.d.ts +9 -0
- package/utilities/dist/esm/libs/abortController.js +23 -0
- package/utilities/dist/esm/libs/cache.d.ts +17 -0
- package/utilities/dist/esm/libs/cache.js +258 -0
- package/utilities/dist/esm/libs/events.d.ts +27 -0
- package/utilities/dist/esm/libs/events.js +102 -0
- package/utilities/dist/esm/libs/langEvent.d.ts +3 -0
- package/utilities/dist/esm/libs/langEvent.js +4 -0
- package/utilities/dist/esm/libs/util.d.ts +49 -0
- package/utilities/dist/esm/libs/util.js +254 -0
- package/utilities/dist/miniprogram/index.js +1 -0
- package/utilities/package.json +26 -0
- package/analytics/dist/index.d.ts +0 -2
- package/analytics/dist/index.esm.js +0 -4
- package/analytics/dist/index.js +0 -9
- package/analytics/package.json +0 -6
- package/database/dist/index.d.ts +0 -3
- package/database/dist/index.esm.js +0 -503
- package/database/dist/index.js +0 -509
- package/miniprogram_dist/analytics.js +0 -1
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export interface ICloudSDKError extends Error {
|
|
2
|
+
errCode: number;
|
|
3
|
+
errMsg: string;
|
|
4
|
+
}
|
|
5
|
+
export declare class CloudSDKError extends Error {
|
|
6
|
+
errCode: string;
|
|
7
|
+
errMsg: string;
|
|
8
|
+
requestID?: string;
|
|
9
|
+
constructor(options: IErrorConstructorOptions);
|
|
10
|
+
get message(): string;
|
|
11
|
+
set message(msg: string);
|
|
12
|
+
}
|
|
13
|
+
interface IErrorConstructorOptions {
|
|
14
|
+
errCode?: string;
|
|
15
|
+
errMsg: string;
|
|
16
|
+
}
|
|
17
|
+
export declare function isSDKError(error: any): error is CloudSDKError;
|
|
18
|
+
export interface IGenericError<T extends string, P = any> extends Error {
|
|
19
|
+
type: T;
|
|
20
|
+
payload: P;
|
|
21
|
+
generic: boolean;
|
|
22
|
+
}
|
|
23
|
+
export declare const isGenericError: <T extends string, P>(e: any) => e is IGenericError<T, P>;
|
|
24
|
+
export declare class TimeoutError extends Error implements IGenericError<'timeout', null> {
|
|
25
|
+
type: "timeout";
|
|
26
|
+
payload: any;
|
|
27
|
+
generic: boolean;
|
|
28
|
+
constructor(message: string);
|
|
29
|
+
}
|
|
30
|
+
export declare const isTimeoutError: (e: any) => e is TimeoutError;
|
|
31
|
+
export declare class CancelledError extends Error implements IGenericError<'cancelled', null> {
|
|
32
|
+
type: "cancelled";
|
|
33
|
+
payload: any;
|
|
34
|
+
generic: boolean;
|
|
35
|
+
constructor(message: string);
|
|
36
|
+
}
|
|
37
|
+
export declare const isCancelledError: (e: any) => e is CancelledError;
|
|
38
|
+
export {};
|
|
@@ -0,0 +1,84 @@
|
|
|
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 { isString } from './type';
|
|
17
|
+
import { ERR_CODE } from '../config/error.config';
|
|
18
|
+
var CloudSDKError = (function (_super) {
|
|
19
|
+
__extends(CloudSDKError, _super);
|
|
20
|
+
function CloudSDKError(options) {
|
|
21
|
+
var _this = _super.call(this, options.errMsg) || this;
|
|
22
|
+
_this.errCode = 'UNKNOWN_ERROR';
|
|
23
|
+
Object.defineProperties(_this, {
|
|
24
|
+
message: {
|
|
25
|
+
get: function () {
|
|
26
|
+
return ("errCode: ".concat(this.errCode, " ").concat(ERR_CODE[this.errCode] ||
|
|
27
|
+
'', " | errMsg: ") + this.errMsg);
|
|
28
|
+
},
|
|
29
|
+
set: function (msg) {
|
|
30
|
+
this.errMsg = msg;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
_this.errCode = options.errCode || 'UNKNOWN_ERROR';
|
|
35
|
+
_this.errMsg = options.errMsg;
|
|
36
|
+
return _this;
|
|
37
|
+
}
|
|
38
|
+
Object.defineProperty(CloudSDKError.prototype, "message", {
|
|
39
|
+
get: function () {
|
|
40
|
+
return "errCode: ".concat(this.errCode, " | errMsg: ") + this.errMsg;
|
|
41
|
+
},
|
|
42
|
+
set: function (msg) {
|
|
43
|
+
this.errMsg = msg;
|
|
44
|
+
},
|
|
45
|
+
enumerable: false,
|
|
46
|
+
configurable: true
|
|
47
|
+
});
|
|
48
|
+
return CloudSDKError;
|
|
49
|
+
}(Error));
|
|
50
|
+
export { CloudSDKError };
|
|
51
|
+
export function isSDKError(error) {
|
|
52
|
+
return (error && error instanceof Error && isString(error.errMsg));
|
|
53
|
+
}
|
|
54
|
+
export var isGenericError = function (e) { return e.generic; };
|
|
55
|
+
var TimeoutError = (function (_super) {
|
|
56
|
+
__extends(TimeoutError, _super);
|
|
57
|
+
function TimeoutError(message) {
|
|
58
|
+
var _this = _super.call(this, message) || this;
|
|
59
|
+
_this.type = 'timeout';
|
|
60
|
+
_this.payload = null;
|
|
61
|
+
_this.generic = true;
|
|
62
|
+
return _this;
|
|
63
|
+
}
|
|
64
|
+
return TimeoutError;
|
|
65
|
+
}(Error));
|
|
66
|
+
export { TimeoutError };
|
|
67
|
+
export var isTimeoutError = function (e) {
|
|
68
|
+
return e.type === 'timeout';
|
|
69
|
+
};
|
|
70
|
+
var CancelledError = (function (_super) {
|
|
71
|
+
__extends(CancelledError, _super);
|
|
72
|
+
function CancelledError(message) {
|
|
73
|
+
var _this = _super.call(this, message) || this;
|
|
74
|
+
_this.type = 'cancelled';
|
|
75
|
+
_this.payload = null;
|
|
76
|
+
_this.generic = true;
|
|
77
|
+
return _this;
|
|
78
|
+
}
|
|
79
|
+
return CancelledError;
|
|
80
|
+
}(Error));
|
|
81
|
+
export { CancelledError };
|
|
82
|
+
export var isCancelledError = function (e) {
|
|
83
|
+
return e.type === 'cancelled';
|
|
84
|
+
};
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,55 @@
|
|
|
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
|
+
var _symbols = [];
|
|
17
|
+
var __internalMark__ = {};
|
|
18
|
+
var HiddenSymbol = (function () {
|
|
19
|
+
function HiddenSymbol(target) {
|
|
20
|
+
Object.defineProperties(this, {
|
|
21
|
+
target: {
|
|
22
|
+
enumerable: false,
|
|
23
|
+
writable: false,
|
|
24
|
+
configurable: false,
|
|
25
|
+
value: target,
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
return HiddenSymbol;
|
|
30
|
+
}());
|
|
31
|
+
var InternalSymbol = (function (_super) {
|
|
32
|
+
__extends(InternalSymbol, _super);
|
|
33
|
+
function InternalSymbol(target, __mark__) {
|
|
34
|
+
if (__mark__ !== __internalMark__) {
|
|
35
|
+
throw new TypeError('InternalSymbol cannot be constructed with new operator');
|
|
36
|
+
}
|
|
37
|
+
return _super.call(this, target) || this;
|
|
38
|
+
}
|
|
39
|
+
InternalSymbol.for = function (target) {
|
|
40
|
+
for (var i = 0, len = _symbols.length; i < len; i++) {
|
|
41
|
+
if (_symbols[i].target === target) {
|
|
42
|
+
return _symbols[i].instance;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
var symbol = new InternalSymbol(target, __internalMark__);
|
|
46
|
+
_symbols.push({
|
|
47
|
+
target: target,
|
|
48
|
+
instance: symbol,
|
|
49
|
+
});
|
|
50
|
+
return symbol;
|
|
51
|
+
};
|
|
52
|
+
return InternalSymbol;
|
|
53
|
+
}(HiddenSymbol));
|
|
54
|
+
export { InternalSymbol };
|
|
55
|
+
export default InternalSymbol;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare const getType: (x: any) => string;
|
|
2
|
+
export declare const isObject: <T extends object>(x: any) => x is T;
|
|
3
|
+
export declare const isString: (x: any) => x is string;
|
|
4
|
+
export declare const isNumber: (x: any) => x is number;
|
|
5
|
+
export declare const isPromise: <T extends Promise<any> = Promise<any>>(x: any) => x is T;
|
|
6
|
+
type AnyFn = (...args: any[]) => any;
|
|
7
|
+
export declare const isFunction: <T extends AnyFn = AnyFn>(x: any) => x is T;
|
|
8
|
+
export declare const isArray: <T extends any[] = any[]>(x: any) => x is T;
|
|
9
|
+
export declare const isDate: (x: any) => x is Date;
|
|
10
|
+
export declare const isRegExp: (x: any) => x is RegExp;
|
|
11
|
+
export declare const isInternalObject: (x: any) => boolean;
|
|
12
|
+
export declare const isPlainObject: (obj: any) => obj is object;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { InternalSymbol } from './symbol';
|
|
2
|
+
export var getType = function (x) { return Object.prototype.toString.call(x).slice(8, -1).toLowerCase(); };
|
|
3
|
+
export var isObject = function (x) { return getType(x) === 'object'; };
|
|
4
|
+
export var isString = function (x) { return getType(x) === 'string'; };
|
|
5
|
+
export var isNumber = function (x) { return getType(x) === 'number'; };
|
|
6
|
+
export var isPromise = function (x) { return getType(x) === 'promise'; };
|
|
7
|
+
export var isFunction = function (x) { return typeof x === 'function'; };
|
|
8
|
+
export var isArray = function (x) { return Array.isArray(x); };
|
|
9
|
+
export var isDate = function (x) { return getType(x) === 'date'; };
|
|
10
|
+
export var isRegExp = function (x) { return getType(x) === 'regexp'; };
|
|
11
|
+
export var isInternalObject = function (x) { return x && (x._internalType instanceof InternalSymbol); };
|
|
12
|
+
export var isPlainObject = function (obj) {
|
|
13
|
+
if (typeof obj !== 'object' || obj === null)
|
|
14
|
+
return false;
|
|
15
|
+
var proto = obj;
|
|
16
|
+
while (Object.getPrototypeOf(proto) !== null) {
|
|
17
|
+
proto = Object.getPrototypeOf(proto);
|
|
18
|
+
}
|
|
19
|
+
return Object.getPrototypeOf(obj) === proto;
|
|
20
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Db } from '../';
|
|
2
|
+
export var sleep = function (ms) {
|
|
3
|
+
if (ms === void 0) { ms = 0; }
|
|
4
|
+
return new Promise(function (r) { return setTimeout(r, ms); });
|
|
5
|
+
};
|
|
6
|
+
var counters = {};
|
|
7
|
+
export var autoCount = function (domain) {
|
|
8
|
+
if (domain === void 0) { domain = 'any'; }
|
|
9
|
+
if (!counters[domain]) {
|
|
10
|
+
counters[domain] = 0;
|
|
11
|
+
}
|
|
12
|
+
return counters[domain]++;
|
|
13
|
+
};
|
|
14
|
+
var wsList = {};
|
|
15
|
+
export function getWsInstance(db) {
|
|
16
|
+
if (!Db.wsClientClass) {
|
|
17
|
+
throw new Error('to use realtime you must import realtime module first');
|
|
18
|
+
}
|
|
19
|
+
var env = db.config.env;
|
|
20
|
+
if (!wsList[env]) {
|
|
21
|
+
wsList[env] = new Db.wsClientClass({
|
|
22
|
+
context: {
|
|
23
|
+
appConfig: {
|
|
24
|
+
docSizeLimit: 1000,
|
|
25
|
+
realtimePingInterval: 10000,
|
|
26
|
+
realtimePongWaitTimeout: 5000,
|
|
27
|
+
request: Db.createRequest(db.config)
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
return wsList[env];
|
|
33
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -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/database/package.json
CHANGED
|
@@ -1,6 +1,36 @@
|
|
|
1
1
|
{
|
|
2
|
-
"name": "@cloudbase/
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"
|
|
2
|
+
"name": "@cloudbase/database",
|
|
3
|
+
"version": "0.12.1",
|
|
4
|
+
"description": "database for (node.)js sdk ",
|
|
5
|
+
"main": "dist/commonjs/index.js",
|
|
6
|
+
"module": "dist/esm/index.js",
|
|
7
|
+
"publishConfig": {
|
|
8
|
+
"tag": "next"
|
|
9
|
+
},
|
|
10
|
+
"scripts": {
|
|
11
|
+
"eslint": "eslint \"./**/*.ts\"",
|
|
12
|
+
"eslint-fix": "eslint --fix \"./**/*.ts\"",
|
|
13
|
+
"test": "jest",
|
|
14
|
+
"build": "tsc -p tsconfig.json && tsc -p tsconfig.esm.json",
|
|
15
|
+
"prepublishOnly": "npm run build"
|
|
16
|
+
},
|
|
17
|
+
"author": "",
|
|
18
|
+
"license": "ISC",
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"@types/jest": "26.0.24",
|
|
21
|
+
"@types/node": "14.14.31",
|
|
22
|
+
"eslint": "^5.15.3",
|
|
23
|
+
"eslint-config-prettier": "^4.1.0",
|
|
24
|
+
"eslint-plugin-prettier": "^3.0.1",
|
|
25
|
+
"eslint-plugin-typescript": "^0.14.0",
|
|
26
|
+
"jest": "26.6.3",
|
|
27
|
+
"ts-jest": "26.5.6",
|
|
28
|
+
"typescript": "^4.1.0",
|
|
29
|
+
"typescript-eslint-parser": "^22.0.0"
|
|
30
|
+
},
|
|
31
|
+
"sideEffects": false,
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"bson": "^7.1.1"
|
|
34
|
+
},
|
|
35
|
+
"packageManager": "yarn@1.22.22"
|
|
6
36
|
}
|