@cloudbase/js-sdk 2.28.8 → 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,350 @@
|
|
|
1
|
+
import { DataType, QueueType, ISingleDBEvent } from './database'
|
|
2
|
+
|
|
3
|
+
export type IRequestMsgType =
|
|
4
|
+
| 'LOGIN' // 鉴权(环境维度)
|
|
5
|
+
| 'INIT_WATCH' // 初始化监听
|
|
6
|
+
| 'REBUILD_WATCH' // 重建监听,1)数据失序时 2)checkLast 不一致时
|
|
7
|
+
| 'CHECK_LAST' // 检查是否有未收到的消息
|
|
8
|
+
| 'CLOSE_WATCH' // 取消监听
|
|
9
|
+
| 'PING' // 心跳 ping
|
|
10
|
+
|
|
11
|
+
export type IResponseMsgType =
|
|
12
|
+
| 'LOGIN_RES' // LOGIN 回包
|
|
13
|
+
| 'INIT_EVENT' // INIT_WATCH 回包
|
|
14
|
+
| 'NEXT_EVENT' // 服务端主动推变更事件
|
|
15
|
+
| 'CHECK_EVENT' // CHECK_LAST 回包
|
|
16
|
+
| 'PONG' // 心跳 PING 回包
|
|
17
|
+
| 'ERROR' // 错误异常
|
|
18
|
+
|
|
19
|
+
export interface IRequestMessageBase<W extends boolean = true> {
|
|
20
|
+
watchId: W extends true ? string : undefined
|
|
21
|
+
requestId: string
|
|
22
|
+
msgType: IRequestMsgType
|
|
23
|
+
msgData: IRequestMessageMsgData
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export type IRequestMessageMsgData =
|
|
27
|
+
| IRequestMessageInitWatchData
|
|
28
|
+
| IRequestMessageLoginData
|
|
29
|
+
| IRequestMessageRebuildWatchData
|
|
30
|
+
| IRequestMessageCheckLastData
|
|
31
|
+
| IRequestMessageCloseWatchData
|
|
32
|
+
| IRequestMessagePingData
|
|
33
|
+
|
|
34
|
+
export type IRequestMessage =
|
|
35
|
+
| IRequestMessageInitWatchMsg
|
|
36
|
+
| IRequestMessageLoginMsg
|
|
37
|
+
| IRequestMessageRebuildWatchMsg
|
|
38
|
+
| IRequestMessageCheckLastMsg
|
|
39
|
+
| IRequestMessageCloseWatchMsg
|
|
40
|
+
| IRequestMessagePingMsg
|
|
41
|
+
|
|
42
|
+
export interface IRequestMessageLoginData {
|
|
43
|
+
envId: string
|
|
44
|
+
accessToken: string
|
|
45
|
+
referrer: 'web'
|
|
46
|
+
sdkVersion: string
|
|
47
|
+
dataVersion: string
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface IRequestExtraMessageLoginData {
|
|
51
|
+
runtime: string
|
|
52
|
+
signStr: string
|
|
53
|
+
secretVersion: string
|
|
54
|
+
}
|
|
55
|
+
export interface IRequestMessageLoginMsg extends IRequestMessageBase<false> {
|
|
56
|
+
msgType: 'LOGIN'
|
|
57
|
+
msgData: IRequestMessageLoginData
|
|
58
|
+
exMsgData?: IRequestExtraMessageLoginData
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export interface IRequestMessageInitWatchData {
|
|
62
|
+
envId: string
|
|
63
|
+
collName: string // collection name
|
|
64
|
+
query: string // query that is stringified
|
|
65
|
+
limit?: number
|
|
66
|
+
orderBy?: Record<string, string>
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export interface IRequestMessageInitWatchMsg extends IRequestMessageBase {
|
|
70
|
+
msgType: 'INIT_WATCH'
|
|
71
|
+
msgData: IRequestMessageInitWatchData
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export interface IRequestMessageRebuildWatchData {
|
|
75
|
+
envId: string
|
|
76
|
+
collName: string
|
|
77
|
+
queryID: string
|
|
78
|
+
eventID: number
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export interface IRequestMessageRebuildWatchMsg extends IRequestMessageBase {
|
|
82
|
+
msgType: 'REBUILD_WATCH'
|
|
83
|
+
msgData: IRequestMessageRebuildWatchData
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export interface IRequestMessageCheckLastData {
|
|
87
|
+
queryID: string
|
|
88
|
+
eventID: number
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export interface IRequestMessageCheckLastMsg extends IRequestMessageBase {
|
|
92
|
+
msgType: 'CHECK_LAST'
|
|
93
|
+
msgData: IRequestMessageCheckLastData
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export type IRequestMessageCloseWatchData = null
|
|
97
|
+
|
|
98
|
+
export interface IRequestMessageCloseWatchMsg extends IRequestMessageBase {
|
|
99
|
+
msgType: 'CLOSE_WATCH'
|
|
100
|
+
msgData: IRequestMessageCloseWatchData
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export type IRequestMessagePingData = null
|
|
104
|
+
|
|
105
|
+
export interface IRequestMessagePingMsg extends IRequestMessageBase<false> {
|
|
106
|
+
msgType: 'PING'
|
|
107
|
+
msgData: IRequestMessagePingData
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// export interface IResponseMessageBase {
|
|
111
|
+
|
|
112
|
+
export interface IResponseMessageBase<W extends boolean = true> {
|
|
113
|
+
watchId: W extends true ? string : undefined
|
|
114
|
+
// watchId: string
|
|
115
|
+
requestId: string
|
|
116
|
+
msgType: IResponseMsgType
|
|
117
|
+
msgData: IResponseMessageMsgData
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export type IResponseMessageMsgData =
|
|
121
|
+
| IResponseMessageLoginResData
|
|
122
|
+
| IResponseMessageInitEventData
|
|
123
|
+
| IResponseMessageNextEventData
|
|
124
|
+
| IResponseMessageCheckEventData
|
|
125
|
+
| IResponseMessagePongData
|
|
126
|
+
| IResponseMessageErrorData
|
|
127
|
+
|
|
128
|
+
export type IResponseMessage =
|
|
129
|
+
| IResponseMessageLoginResMsg
|
|
130
|
+
| IResponseMessageInitEventMsg
|
|
131
|
+
| IResponseMessageNextEventMsg
|
|
132
|
+
| IResponseMessageCheckEventMsg
|
|
133
|
+
| IResponseMessagePongMsg
|
|
134
|
+
| IResponseMessageErrorMsg
|
|
135
|
+
|
|
136
|
+
export type IResponseMessageLoginResData = {
|
|
137
|
+
envId: string
|
|
138
|
+
} & Partial<IResponseMessageErrorData>
|
|
139
|
+
|
|
140
|
+
export interface IResponseMessageLoginResMsg
|
|
141
|
+
extends IResponseMessageBase<false> {
|
|
142
|
+
msgType: 'LOGIN_RES'
|
|
143
|
+
msgData: IResponseMessageLoginResData
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export interface IResponseMessageInitEventData {
|
|
147
|
+
queryID: string
|
|
148
|
+
currEvent: number
|
|
149
|
+
events: IDBEvent[]
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export interface IResponseMessageInitEventMsg extends IResponseMessageBase {
|
|
153
|
+
msgType: 'INIT_EVENT'
|
|
154
|
+
msgData: IResponseMessageInitEventData
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export interface IResponseMessageNextEventData {
|
|
158
|
+
queryID: string
|
|
159
|
+
currEvent: number
|
|
160
|
+
events: IDBEvent[]
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export interface IResponseMessageNextEventMsg extends IResponseMessageBase {
|
|
164
|
+
msgType: 'NEXT_EVENT'
|
|
165
|
+
msgData: IResponseMessageNextEventData
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export interface IResponseMessageCheckEventData {
|
|
169
|
+
queryID: string
|
|
170
|
+
currEvent: number
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
export interface IResponseMessageCheckEventMsg extends IResponseMessageBase {
|
|
174
|
+
msgType: 'CHECK_EVENT'
|
|
175
|
+
msgData: IResponseMessageCheckEventData
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
export type IResponseMessagePongData = null
|
|
179
|
+
|
|
180
|
+
export interface IResponseMessagePongMsg extends IResponseMessageBase {
|
|
181
|
+
msgType: 'PONG'
|
|
182
|
+
msgData: IResponseMessagePongData
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
export type IResponseMessageErrorData = {
|
|
186
|
+
message: string
|
|
187
|
+
} & (
|
|
188
|
+
| { code: 'SYS_ERR' } // 服务器系统错误
|
|
189
|
+
| { code: 'CHECK_LOGIN_FAILED' } // 登陆校验失败
|
|
190
|
+
| { code: 'SIGN_INVALID_ERROR' } // ws签名无效
|
|
191
|
+
| { code: 'SIGN_EXPIRED_ERROR' } // 签名过期
|
|
192
|
+
| { code: 'INVALIID_ENV' } // 环境无效
|
|
193
|
+
| { code: 'SIGN_PARAM_INVALID' } // cam签名无效
|
|
194
|
+
| { code: 'COLLECTION_PERMISSION_DENIED' } // 没有集合操作权限
|
|
195
|
+
| { code: 'QUERYID_INVALID_ERROR' }) // queryID 无效
|
|
196
|
+
|
|
197
|
+
export interface IResponseMessageErrorMsg extends IResponseMessageBase {
|
|
198
|
+
msgType: 'ERROR'
|
|
199
|
+
msgData: IResponseMessageErrorData
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
export type IDBEvent = IDBInitEvent | IDBNextEvent
|
|
203
|
+
|
|
204
|
+
export interface IDBEventBase {
|
|
205
|
+
ID: number // event id
|
|
206
|
+
DataType: DataType
|
|
207
|
+
QueueType: QueueType
|
|
208
|
+
DocID: string
|
|
209
|
+
Doc: string
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
export interface IDBInitEvent extends IDBEventBase {
|
|
213
|
+
DataType: 'init'
|
|
214
|
+
QueueType: 'init'
|
|
215
|
+
UpdatedFields?: any
|
|
216
|
+
removedFields?: any
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
// <DataType, QueueType>
|
|
220
|
+
// * <update, update>
|
|
221
|
+
// * <update, enqueue>
|
|
222
|
+
// * <update, dequeue>
|
|
223
|
+
// * <add, enqueue>
|
|
224
|
+
// * <remove, dequeue>
|
|
225
|
+
|
|
226
|
+
// export interface IDBNextEvent extends IDBEventBase {
|
|
227
|
+
// DocID: string
|
|
228
|
+
// Doc: string
|
|
229
|
+
// UpdatedFields?: any
|
|
230
|
+
// removedFields?: any
|
|
231
|
+
// }
|
|
232
|
+
|
|
233
|
+
export type IDBNextEvent =
|
|
234
|
+
| IDBNextEventDataUpdate
|
|
235
|
+
| IDBNextEventDataReplace
|
|
236
|
+
| IDBNextEventDataAdd
|
|
237
|
+
| IDBNextEventDataRemove
|
|
238
|
+
| IDBNextEventDataLimit
|
|
239
|
+
|
|
240
|
+
export type IDBNextEventDataUpdate =
|
|
241
|
+
| IDBNextEventDataUpdateQueueUpdate
|
|
242
|
+
| IDBNextEventDataUpdateQueueEnqueue
|
|
243
|
+
| IDBNextEventDataUpdateQueueDequeue
|
|
244
|
+
|
|
245
|
+
export type IDBNextEventDataReplace =
|
|
246
|
+
| IDBNextEventDataReplaceQueueUpdate
|
|
247
|
+
| IDBNextEventDataReplaceQueueEnqueue
|
|
248
|
+
| IDBNextEventDataReplaceQueueDequeue
|
|
249
|
+
|
|
250
|
+
export type IDBNextEventDataLimit =
|
|
251
|
+
| IDBNextEventDataLimitQueueEnqueue
|
|
252
|
+
| IDBNextEventDataLimitQueueDequeue
|
|
253
|
+
|
|
254
|
+
export interface IDBNextEventDataUpdateQueueUpdate extends IDBEventBase {
|
|
255
|
+
DataType: 'update'
|
|
256
|
+
QueueType: 'update'
|
|
257
|
+
Doc: ''
|
|
258
|
+
UpdatedFields: string
|
|
259
|
+
RemovedFields: string
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
export interface IDBNextEventDataUpdateQueueEnqueue extends IDBEventBase {
|
|
263
|
+
DataType: 'update'
|
|
264
|
+
QueueType: 'enqueue'
|
|
265
|
+
Doc: string // full doc
|
|
266
|
+
UpdatedFields: string
|
|
267
|
+
RemovedFields: string
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
export interface IDBNextEventDataUpdateQueueDequeue extends IDBEventBase {
|
|
271
|
+
DataType: 'update'
|
|
272
|
+
QueueType: 'dequeue'
|
|
273
|
+
Doc: ''
|
|
274
|
+
UpdatedFields: string
|
|
275
|
+
RemovedFields: string
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
export interface IDBNextEventDataReplaceQueueUpdate extends IDBEventBase {
|
|
279
|
+
DataType: 'replace'
|
|
280
|
+
QueueType: 'update'
|
|
281
|
+
Doc: string
|
|
282
|
+
UpdatedFields: ''
|
|
283
|
+
RemovedFields: ''
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
export interface IDBNextEventDataReplaceQueueEnqueue extends IDBEventBase {
|
|
287
|
+
DataType: 'replace'
|
|
288
|
+
QueueType: 'enqueue'
|
|
289
|
+
Doc: string
|
|
290
|
+
UpdatedFields: ''
|
|
291
|
+
RemovedFields: ''
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
export interface IDBNextEventDataReplaceQueueDequeue extends IDBEventBase {
|
|
295
|
+
DataType: 'replace'
|
|
296
|
+
QueueType: 'dequeue'
|
|
297
|
+
Doc: string
|
|
298
|
+
UpdatedFields: ''
|
|
299
|
+
RemovedFields: ''
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
export interface IDBNextEventDataAdd extends IDBEventBase {
|
|
303
|
+
DataType: 'add'
|
|
304
|
+
QueueType: 'enqueue'
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
export interface IDBNextEventDataRemove extends IDBEventBase {
|
|
308
|
+
DataType: 'remove'
|
|
309
|
+
QueueType: 'dequeue'
|
|
310
|
+
Doc: ''
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
export interface IDBNextEventDataLimitQueueEnqueue extends IDBEventBase {
|
|
314
|
+
DataType: 'limit'
|
|
315
|
+
QueueType: 'enqueue'
|
|
316
|
+
Doc: string
|
|
317
|
+
UpdatedFields: ''
|
|
318
|
+
RemovedFields: ''
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
export interface IDBNextEventDataLimitQueueDequeue extends IDBEventBase {
|
|
322
|
+
DataType: 'limit'
|
|
323
|
+
QueueType: 'dequeue'
|
|
324
|
+
Doc: ''
|
|
325
|
+
UpdatedFields: ''
|
|
326
|
+
RemovedFields: ''
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
export interface IWatchOptions {
|
|
330
|
+
// server realtime data init & change event
|
|
331
|
+
onChange: (snapshot: ISnapshot) => void
|
|
332
|
+
// error while connecting / listening
|
|
333
|
+
onError: (error: any) => void
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
export interface ISnapshot {
|
|
337
|
+
id: number
|
|
338
|
+
docChanges: ISingleDBEvent[]
|
|
339
|
+
docs: Record<string, any>
|
|
340
|
+
type?: SnapshotType
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
export interface DBRealtimeListener {
|
|
344
|
+
// "And Now His Watch Is Ended"
|
|
345
|
+
close: () => void
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
export type IRealtimeListenerConstructorOptions = IWatchOptions
|
|
349
|
+
|
|
350
|
+
export type SnapshotType = 'init'
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import {
|
|
2
|
+
IFetchOptions,
|
|
3
|
+
IRequestOptions, IUploadRequestOptions, ResponseObject,
|
|
4
|
+
} from '@cloudbase/adapter-interface'
|
|
5
|
+
|
|
6
|
+
import { ICloudbaseConfig, KV } from '.'
|
|
7
|
+
|
|
8
|
+
export interface IGetAccessTokenResult {
|
|
9
|
+
accessToken: string;
|
|
10
|
+
accessTokenExpire: number;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export type ICloudbaseRequestConfig = Pick<ICloudbaseConfig, 'env' | 'region' | 'timeout' | 'oauthClient' | '_fromApp' | 'i18n' | 'endPointMode' | 'auth'>;
|
|
14
|
+
|
|
15
|
+
export interface IAppendedRequestInfo {
|
|
16
|
+
data: KV<any>;
|
|
17
|
+
headers: KV<string>;
|
|
18
|
+
}
|
|
19
|
+
export type IRequestBeforeHook = (...args: any[]) => IAppendedRequestInfo;
|
|
20
|
+
export interface ICloudbaseRequest {
|
|
21
|
+
// fetch: (urlOrPath: string, init?: RequestInit) => Promise<Response>;
|
|
22
|
+
post: (options: IRequestOptions) => Promise<ResponseObject>;
|
|
23
|
+
upload: (options: IUploadRequestOptions) => Promise<ResponseObject>;
|
|
24
|
+
download: (options: IRequestOptions) => Promise<ResponseObject>;
|
|
25
|
+
// refreshAccessToken: () => Promise<IGetAccessTokenResult>;
|
|
26
|
+
// getAccessToken: () => Promise<IGetAccessTokenResult>;
|
|
27
|
+
request: (action: string, params: KV<any>, options?: KV<any>) => Promise<ResponseObject>;
|
|
28
|
+
send: (action: string, data: KV<any>) => Promise<any>;
|
|
29
|
+
fetch: (options: IFetchOptions) => Promise<ResponseObject>;
|
|
30
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { KVstring } from '.'
|
|
2
|
+
import { ICustomReqOpts } from './functions'
|
|
3
|
+
|
|
4
|
+
export interface ICloudbaseUploadFileParams {
|
|
5
|
+
cloudPath: string;
|
|
6
|
+
filePath: string;
|
|
7
|
+
method?: 'post' | 'put';
|
|
8
|
+
headers?: KVstring;
|
|
9
|
+
onUploadProgress?: Function;
|
|
10
|
+
// 文件内容 Buffer 或 文件可读流, node端使用
|
|
11
|
+
fileContent?: any;
|
|
12
|
+
customReqOpts?: ICustomReqOpts;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface ICloudbaseUploadFileByPutParams {
|
|
16
|
+
cloudPath: string;
|
|
17
|
+
filePath: string;
|
|
18
|
+
headers?: KVstring;
|
|
19
|
+
onUploadProgress?: Function;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface ICloudbaseUploadFileResult {
|
|
23
|
+
fileID: string;
|
|
24
|
+
requestId: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export type ICloudbaseUploadFile = (params: ICloudbaseUploadFileParams, callback?: Function) => Promise<ICloudbaseUploadFileResult>;
|
|
28
|
+
|
|
29
|
+
export interface ICloudbaseGetUploadMetadataParams {
|
|
30
|
+
cloudPath: string;
|
|
31
|
+
customReqOpts?: ICustomReqOpts;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export type ICloudbaseGetUploadMetadata = (params: ICloudbaseGetUploadMetadataParams, callback?: Function) => Promise<any>;
|
|
35
|
+
|
|
36
|
+
export interface ICloudbaseDeleteFileParams {
|
|
37
|
+
fileList: string[];
|
|
38
|
+
customReqOpts?: ICustomReqOpts;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export type ICloudbaseDeleteFile = (params: ICloudbaseDeleteFileParams, callback?: Function) => Promise<ICloudbaseDeleteFileResult>;
|
|
42
|
+
|
|
43
|
+
export interface ICloudbaseDeleteFileResult {
|
|
44
|
+
code?: string;
|
|
45
|
+
message?: string;
|
|
46
|
+
fileList?: {
|
|
47
|
+
code?: string;
|
|
48
|
+
fileID: string;
|
|
49
|
+
}[];
|
|
50
|
+
requestId?: string;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface ICloudbaseFileInfo {
|
|
54
|
+
fileID: string;
|
|
55
|
+
maxAge: number;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export interface ICloudbaseGetTempFileURLParams {
|
|
59
|
+
fileList: string[] | ICloudbaseFileInfo[];
|
|
60
|
+
customReqOpts?: ICustomReqOpts;
|
|
61
|
+
}
|
|
62
|
+
export interface ICloudbaseGetTempFileURLResult {
|
|
63
|
+
code?: string;
|
|
64
|
+
message?: string;
|
|
65
|
+
fileList?: {
|
|
66
|
+
code?: string;
|
|
67
|
+
message?: string;
|
|
68
|
+
fileID: string;
|
|
69
|
+
tempFileURL: string;
|
|
70
|
+
download_url?: string;
|
|
71
|
+
}[];
|
|
72
|
+
requestId?: string;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export interface ICloudbaseCopyFileParams {
|
|
76
|
+
fileList: Array<{
|
|
77
|
+
srcPath: string
|
|
78
|
+
dstPath: string
|
|
79
|
+
overwrite?: boolean
|
|
80
|
+
removeOriginal?: boolean
|
|
81
|
+
}>
|
|
82
|
+
customReqOpts?: ICustomReqOpts;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
export interface ICloudbaseCopyFileResult {
|
|
87
|
+
fileList: Array<{
|
|
88
|
+
fileId?: string
|
|
89
|
+
code?: string
|
|
90
|
+
message?: string
|
|
91
|
+
}>
|
|
92
|
+
requestId?: string;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export type ICloudbaseGetTempFileURL = (params: ICloudbaseGetTempFileURLParams, callback?: Function) => Promise<ICloudbaseGetTempFileURLResult>;
|
|
96
|
+
|
|
97
|
+
export interface ICloudbaseDownloadFileParams {
|
|
98
|
+
fileID: string;
|
|
99
|
+
tempFilePath?: string;
|
|
100
|
+
customReqOpts?: ICustomReqOpts;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export interface ICloudbaseDownloadFileResult {
|
|
104
|
+
code?: string;
|
|
105
|
+
message?: string;
|
|
106
|
+
fileContent?: any;
|
|
107
|
+
requestId?: string;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export type ICloudbaseDownloadFile = (params: ICloudbaseDownloadFileParams, callback?: Function) => Promise<ICloudbaseDownloadFileResult>;
|
|
111
|
+
|
|
112
|
+
export interface ICloudbaseFileMetaData {
|
|
113
|
+
url: string;
|
|
114
|
+
token: string;
|
|
115
|
+
authorization: string;
|
|
116
|
+
fileId: string;
|
|
117
|
+
cosFileId: string;
|
|
118
|
+
download_url: string;
|
|
119
|
+
code?: string;
|
|
120
|
+
message?: string;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export interface ICloudbaseFileMetaDataRes {
|
|
124
|
+
data: ICloudbaseFileMetaData;
|
|
125
|
+
requestId: string;
|
|
126
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { CloudbaseAdapter, SDKAdapterInterface, NodeAdapterInterface } from '@cloudbase/adapter-interface';
|
|
2
|
+
export declare enum RUNTIME {
|
|
3
|
+
WEB = "web",
|
|
4
|
+
WX_MP = "wx_mp"
|
|
5
|
+
}
|
|
6
|
+
type ICloudbaseAdapter = CloudbaseAdapter & {
|
|
7
|
+
genAdapter: (options?: any) => SDKAdapterInterface | NodeAdapterInterface;
|
|
8
|
+
};
|
|
9
|
+
export declare function useAdapters(adapters: ICloudbaseAdapter | ICloudbaseAdapter[], options?: any): {
|
|
10
|
+
adapter: {
|
|
11
|
+
root: any;
|
|
12
|
+
wsClass: import("@cloudbase/adapter-interface").WebSocketContructor;
|
|
13
|
+
reqClass: import("@cloudbase/adapter-interface").SDKRequestConstructor;
|
|
14
|
+
localStorage?: import("@cloudbase/adapter-interface").StorageInterface;
|
|
15
|
+
sessionStorage?: import("@cloudbase/adapter-interface").StorageInterface;
|
|
16
|
+
primaryStorage?: import("@cloudbase/adapter-interface").StorageType;
|
|
17
|
+
captchaOptions?: {
|
|
18
|
+
openURIWithCallback?: (url: string) => Promise<import("@cloudbase/adapter-interface").CaptchaToken>;
|
|
19
|
+
};
|
|
20
|
+
getAppSign?(): string;
|
|
21
|
+
isMatch: () => boolean;
|
|
22
|
+
} | {
|
|
23
|
+
wsClass: import("@cloudbase/adapter-interface").WebSocketContructor;
|
|
24
|
+
reqClass: import("@cloudbase/adapter-interface").NodeRequestConstructor;
|
|
25
|
+
isMatch: () => boolean;
|
|
26
|
+
};
|
|
27
|
+
runtime: string;
|
|
28
|
+
};
|
|
29
|
+
export declare function useDefaultAdapter(): {
|
|
30
|
+
adapter: {
|
|
31
|
+
root: any;
|
|
32
|
+
wsClass: import("@cloudbase/adapter-interface").WebSocketContructor;
|
|
33
|
+
reqClass: import("@cloudbase/adapter-interface").SDKRequestConstructor;
|
|
34
|
+
localStorage?: import("@cloudbase/adapter-interface").StorageInterface;
|
|
35
|
+
sessionStorage?: import("@cloudbase/adapter-interface").StorageInterface;
|
|
36
|
+
primaryStorage?: import("@cloudbase/adapter-interface").StorageType;
|
|
37
|
+
captchaOptions?: {
|
|
38
|
+
openURIWithCallback?: (url: string) => Promise<import("@cloudbase/adapter-interface").CaptchaToken>;
|
|
39
|
+
};
|
|
40
|
+
getAppSign?(): string;
|
|
41
|
+
type?: "" | "default";
|
|
42
|
+
};
|
|
43
|
+
runtime: RUNTIME;
|
|
44
|
+
};
|
|
45
|
+
export {};
|
|
@@ -0,0 +1,68 @@
|
|
|
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 __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
16
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
17
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
18
|
+
}
|
|
19
|
+
Object.defineProperty(o, k2, desc);
|
|
20
|
+
}) : (function(o, m, k, k2) {
|
|
21
|
+
if (k2 === undefined) k2 = k;
|
|
22
|
+
o[k2] = m[k];
|
|
23
|
+
}));
|
|
24
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
25
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
26
|
+
}) : function(o, v) {
|
|
27
|
+
o["default"] = v;
|
|
28
|
+
});
|
|
29
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
30
|
+
if (mod && mod.__esModule) return mod;
|
|
31
|
+
var result = {};
|
|
32
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
33
|
+
__setModuleDefault(result, mod);
|
|
34
|
+
return result;
|
|
35
|
+
};
|
|
36
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
+
exports.useDefaultAdapter = exports.useAdapters = exports.RUNTIME = void 0;
|
|
38
|
+
var Web = __importStar(require("./platforms/web"));
|
|
39
|
+
var util_1 = require("../libs/util");
|
|
40
|
+
var RUNTIME;
|
|
41
|
+
(function (RUNTIME) {
|
|
42
|
+
RUNTIME["WEB"] = "web";
|
|
43
|
+
RUNTIME["WX_MP"] = "wx_mp";
|
|
44
|
+
})(RUNTIME = exports.RUNTIME || (exports.RUNTIME = {}));
|
|
45
|
+
function useAdapters(adapters, options) {
|
|
46
|
+
var adapterList = (0, util_1.isArray)(adapters)
|
|
47
|
+
? adapters
|
|
48
|
+
: [adapters];
|
|
49
|
+
for (var _i = 0, adapterList_1 = adapterList; _i < adapterList_1.length; _i++) {
|
|
50
|
+
var adapter = adapterList_1[_i];
|
|
51
|
+
var isMatch = adapter.isMatch, genAdapter = adapter.genAdapter, runtime = adapter.runtime;
|
|
52
|
+
if (isMatch()) {
|
|
53
|
+
return {
|
|
54
|
+
adapter: __assign({ isMatch: isMatch }, genAdapter(options)),
|
|
55
|
+
runtime: runtime,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
exports.useAdapters = useAdapters;
|
|
61
|
+
function useDefaultAdapter() {
|
|
62
|
+
return {
|
|
63
|
+
adapter: __assign({}, Web.genAdapter()),
|
|
64
|
+
runtime: RUNTIME.WEB,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
exports.useDefaultAdapter = useDefaultAdapter;
|
|
68
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvYWRhcHRlcnMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OztBQUNBLG1EQUFzQztBQUN0QyxxQ0FBc0M7QUFFdEMsSUFBWSxPQUdYO0FBSEQsV0FBWSxPQUFPO0lBQ2pCLHNCQUFXLENBQUE7SUFDWCwwQkFBZSxDQUFBO0FBQ2pCLENBQUMsRUFIVyxPQUFPLEdBQVAsZUFBTyxLQUFQLGVBQU8sUUFHbEI7QUFNRCxTQUFnQixXQUFXLENBQUMsUUFBaUQsRUFBRSxPQUFhO0lBQzFGLElBQU0sV0FBVyxHQUF3QixJQUFBLGNBQU8sRUFBQyxRQUFRLENBQUM7UUFDeEQsQ0FBQyxDQUFFLFFBQWdDO1FBQ25DLENBQUMsQ0FBQyxDQUFDLFFBQTZCLENBQUMsQ0FBQTtJQUNuQyxLQUFzQixVQUFXLEVBQVgsMkJBQVcsRUFBWCx5QkFBVyxFQUFYLElBQVcsRUFBRTtRQUE5QixJQUFNLE9BQU8sb0JBQUE7UUFDUixJQUFBLE9BQU8sR0FBMEIsT0FBTyxRQUFqQyxFQUFFLFVBQVUsR0FBYyxPQUFPLFdBQXJCLEVBQUUsT0FBTyxHQUFLLE9BQU8sUUFBWixDQUFZO1FBQ2hELElBQUksT0FBTyxFQUFFLEVBQUU7WUFDYixPQUFPO2dCQUNMLE9BQU8sYUFBSSxPQUFPLFNBQUEsSUFBSyxVQUFVLENBQUMsT0FBTyxDQUFDLENBQUU7Z0JBQzVDLE9BQU8sU0FBQTthQUNSLENBQUE7U0FDRjtLQUNGO0FBQ0gsQ0FBQztBQWJELGtDQWFDO0FBRUQsU0FBZ0IsaUJBQWlCO0lBQy9CLE9BQU87UUFDTCxPQUFPLGVBQU8sR0FBRyxDQUFDLFVBQVUsRUFBRSxDQUFFO1FBQ2hDLE9BQU8sRUFBRSxPQUFPLENBQUMsR0FBRztLQUNyQixDQUFBO0FBQ0gsQ0FBQztBQUxELDhDQUtDIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHsgQ2xvdWRiYXNlQWRhcHRlciwgU0RLQWRhcHRlckludGVyZmFjZSwgTm9kZUFkYXB0ZXJJbnRlcmZhY2UgfSBmcm9tICdAY2xvdWRiYXNlL2FkYXB0ZXItaW50ZXJmYWNlJ1xuaW1wb3J0ICogYXMgV2ViIGZyb20gJy4vcGxhdGZvcm1zL3dlYidcbmltcG9ydCB7IGlzQXJyYXkgfSBmcm9tICcuLi9saWJzL3V0aWwnXG5cbmV4cG9ydCBlbnVtIFJVTlRJTUUge1xuICBXRUIgPSAnd2ViJyxcbiAgV1hfTVAgPSAnd3hfbXAnLCAvLyDlvq7kv6HlsI/nqIvluo9cbn1cblxudHlwZSBJQ2xvdWRiYXNlQWRhcHRlciA9IENsb3VkYmFzZUFkYXB0ZXIgJiB7XG4gIGdlbkFkYXB0ZXI6IChvcHRpb25zPzogYW55KSA9PiBTREtBZGFwdGVySW50ZXJmYWNlIHwgTm9kZUFkYXB0ZXJJbnRlcmZhY2Vcbn1cblxuZXhwb3J0IGZ1bmN0aW9uIHVzZUFkYXB0ZXJzKGFkYXB0ZXJzOiBJQ2xvdWRiYXNlQWRhcHRlciB8IElDbG91ZGJhc2VBZGFwdGVyW10sIG9wdGlvbnM/OiBhbnkpIHtcbiAgY29uc3QgYWRhcHRlckxpc3Q6IElDbG91ZGJhc2VBZGFwdGVyW10gPSBpc0FycmF5KGFkYXB0ZXJzKVxuICAgID8gKGFkYXB0ZXJzIGFzIElDbG91ZGJhc2VBZGFwdGVyW10pXG4gICAgOiBbYWRhcHRlcnMgYXMgSUNsb3VkYmFzZUFkYXB0ZXJdXG4gIGZvciAoY29uc3QgYWRhcHRlciBvZiBhZGFwdGVyTGlzdCkge1xuICAgIGNvbnN0IHsgaXNNYXRjaCwgZ2VuQWRhcHRlciwgcnVudGltZSB9ID0gYWRhcHRlclxuICAgIGlmIChpc01hdGNoKCkpIHtcbiAgICAgIHJldHVybiB7XG4gICAgICAgIGFkYXB0ZXI6IHsgaXNNYXRjaCwgLi4uZ2VuQWRhcHRlcihvcHRpb25zKSB9LFxuICAgICAgICBydW50aW1lLFxuICAgICAgfVxuICAgIH1cbiAgfVxufVxuXG5leHBvcnQgZnVuY3Rpb24gdXNlRGVmYXVsdEFkYXB0ZXIoKSB7XG4gIHJldHVybiB7XG4gICAgYWRhcHRlcjogeyAuLi5XZWIuZ2VuQWRhcHRlcigpIH0sXG4gICAgcnVudGltZTogUlVOVElNRS5XRUIsXG4gIH1cbn1cbiJdfQ==
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { SDKAdapterInterface, AbstractSDKRequest, IRequestOptions, ResponseObject, IUploadRequestOptions, IRequestConfig, IFetchOptions } from '@cloudbase/adapter-interface';
|
|
2
|
+
declare class WebRequest extends AbstractSDKRequest {
|
|
3
|
+
private readonly timeout;
|
|
4
|
+
private readonly timeoutMsg;
|
|
5
|
+
private readonly restrictedMethods;
|
|
6
|
+
constructor(config: IRequestConfig);
|
|
7
|
+
get(options: IRequestOptions): Promise<ResponseObject>;
|
|
8
|
+
post(options: IRequestOptions): Promise<ResponseObject>;
|
|
9
|
+
put(options: IRequestOptions): Promise<ResponseObject>;
|
|
10
|
+
upload(options: IUploadRequestOptions): Promise<ResponseObject>;
|
|
11
|
+
download(options: IRequestOptions): Promise<any>;
|
|
12
|
+
fetch(options: IFetchOptions & {
|
|
13
|
+
shouldThrowOnError?: boolean;
|
|
14
|
+
}): Promise<ResponseObject>;
|
|
15
|
+
protected request(options: IRequestOptions, enableAbort?: boolean): Promise<ResponseObject>;
|
|
16
|
+
}
|
|
17
|
+
declare function genAdapter(): SDKAdapterInterface & {
|
|
18
|
+
type?: 'default' | '';
|
|
19
|
+
};
|
|
20
|
+
export { genAdapter, WebRequest };
|