@cloudbase/js-sdk 3.8.2-beta.1 → 3.8.2-beta.2
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/ai/dist/AI.d.ts +29 -0
- package/ai/dist/bot/index.d.ts +41 -0
- package/ai/dist/bot/types.d.ts +144 -0
- package/ai/dist/errors.d.ts +10 -0
- package/ai/dist/eventsource_parser/index.d.ts +2 -0
- package/ai/dist/eventsource_parser/parse.d.ts +2 -0
- package/ai/dist/eventsource_parser/stream.d.ts +5 -0
- package/ai/dist/eventsource_parser/types.d.ts +16 -0
- package/ai/dist/index.d.ts +42 -1
- package/ai/dist/models/Ark/index.d.ts +10 -0
- package/ai/dist/models/Ark/type.d.ts +71 -0
- package/ai/dist/models/DashScope/index.d.ts +10 -0
- package/ai/dist/models/DashScope/type.d.ts +74 -0
- package/ai/dist/models/DeepSeek/index.d.ts +10 -0
- package/ai/dist/models/Default/index.d.ts +10 -0
- package/ai/dist/models/HunYuan/index.d.ts +10 -0
- package/ai/dist/models/HunYuan/type.d.ts +74 -0
- package/ai/dist/models/HunYuan/util.d.ts +4 -0
- package/ai/dist/models/HunYuanBeta/index.d.ts +10 -0
- package/ai/dist/models/HunYuanExp/index.d.ts +10 -0
- package/ai/dist/models/HunYuanOpen/index.d.ts +10 -0
- package/ai/dist/models/Moonshot/index.d.ts +10 -0
- package/ai/dist/models/Moonshot/type.d.ts +85 -0
- package/ai/dist/models/Yi/index.d.ts +10 -0
- package/ai/dist/models/Yi/type.d.ts +75 -0
- package/ai/dist/models/ZhiPu/index.d.ts +10 -0
- package/ai/dist/models/ZhiPu/type.d.ts +71 -0
- package/ai/dist/models/image-model.d.ts +19 -0
- package/ai/dist/models/index.d.ts +26 -0
- package/ai/dist/models/model.d.ts +40 -0
- package/ai/dist/type.d.ts +192 -0
- package/ai/dist/utils.d.ts +38 -0
- package/apis/dist/callApis.d.ts +20 -0
- package/apis/dist/index.d.ts +5 -1
- package/apis/dist/type.d.ts +14 -0
- package/app/dist/constants/common.d.ts +38 -0
- package/app/dist/index.d.ts +66 -7
- package/app/dist/index.esm.js +1 -1
- package/app/dist/index.js +1 -1
- package/app/dist/index.js.map +1 -1
- package/app/dist/index.node.d.ts +6 -0
- package/app/dist/index.node.esm.js +1 -1
- package/app/dist/index.node.esm.js.map +1 -1
- package/app/dist/index.node.js +1 -1
- package/app/dist/index.node.js.map +1 -1
- package/app/dist/libs/adapter-node/constants.d.ts +33 -0
- package/app/dist/libs/adapter-node/context.d.ts +18 -0
- package/app/dist/libs/adapter-node/index.d.ts +26 -0
- package/app/dist/libs/adapter-node/metadata.d.ts +14 -0
- package/app/dist/libs/adapter-node/optional-require.d.ts +1 -0
- package/app/dist/libs/adapter-node/request.d.ts +44 -0
- package/app/dist/libs/adapter-node/tool.d.ts +2 -0
- package/app/dist/libs/adapter-node/types.d.ts +103 -0
- package/app/dist/libs/adapter-node/utils.d.ts +37 -0
- package/app/dist/libs/adapter-node/wx.d.ts +39 -0
- package/app/dist/libs/adapter.d.ts +3 -0
- package/app/dist/libs/cache.d.ts +6 -0
- package/app/dist/libs/component.d.ts +3 -0
- package/app/dist/libs/lang.d.ts +23 -0
- package/app/dist/libs/request.d.ts +62 -0
- package/auth/dist/adapter.d.ts +2 -0
- package/auth/dist/index.d.ts +271 -2
- package/auth/dist/type.d.ts +295 -0
- package/auth/dist/utilities.d.ts +7 -0
- package/auth/dist/utils.d.ts +5 -0
- package/auth/dist/v1-compat.d.ts +77 -0
- package/cloudrun/dist/index.d.ts +4 -1
- package/container/dist/constants/index.d.ts +1 -0
- package/container/dist/go_wams_exec.d.ts +2 -0
- package/container/dist/index.d.ts +13 -2
- package/container/dist/utils/index.d.ts +3 -0
- package/container/dist/utils/loader.d.ts +8 -0
- package/container/dist/utils/request.d.ts +12 -0
- package/core.d.ts +84 -81
- package/database/dist/index.d.ts +1 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.node.cjs.js +1 -1
- package/dist/index.node.esm.js +1 -1
- package/dist/index.node.esm.js.map +1 -1
- package/functions/dist/index.d.ts +2 -2
- package/miniprogram_dist/ai/index.d.ts +1 -1
- package/miniprogram_dist/apis/index.d.ts +1 -1
- package/miniprogram_dist/app/index.d.ts +5 -5
- package/miniprogram_dist/auth/index.d.ts +7 -7
- package/miniprogram_dist/cloudrun/index.d.ts +2 -2
- package/miniprogram_dist/container/index.d.ts +2 -2
- package/miniprogram_dist/database/index.d.ts +1 -1
- package/miniprogram_dist/functions/index.d.ts +1 -1
- package/miniprogram_dist/index.js +1 -1
- package/miniprogram_dist/model/index.d.ts +1 -1
- package/miniprogram_dist/mysql/index.d.ts +1 -1
- package/miniprogram_dist/realtime/index.d.ts +1 -1
- package/miniprogram_dist/storage/index.d.ts +1 -1
- package/model/dist/index.d.ts +5 -1
- package/mysql/dist/index.d.ts +4 -1
- package/oauth/dist/auth/apis.d.ts +143 -0
- package/oauth/dist/auth/auth-error.d.ts +32 -0
- package/oauth/dist/auth/consts.d.ts +165 -0
- package/oauth/dist/auth/models.d.ts +557 -0
- package/oauth/dist/captcha/captcha-dom.d.ts +3 -0
- package/oauth/dist/captcha/captcha.d.ts +42 -0
- package/oauth/dist/index.d.ts +22 -1
- package/oauth/dist/oauth2client/consts.d.ts +20 -0
- package/oauth/dist/oauth2client/interface.d.ts +15 -0
- package/oauth/dist/oauth2client/models.d.ts +75 -0
- package/oauth/dist/oauth2client/oauth2client.d.ts +154 -0
- package/oauth/dist/utils/base64.d.ts +9 -0
- package/oauth/dist/utils/encrypt.d.ts +4 -0
- package/oauth/dist/utils/encryptlong/index.d.ts +546 -0
- package/oauth/dist/utils/function/single-promise.d.ts +10 -0
- package/oauth/dist/utils/index.d.ts +2 -0
- package/oauth/dist/utils/mp.d.ts +2 -0
- package/oauth/dist/utils/urlSearchParams.d.ts +13 -0
- package/oauth/dist/utils/uuid.d.ts +1 -0
- package/package.json +20 -3
- package/realtime/dist/common.d.ts +4 -0
- package/realtime/dist/error.d.ts +36 -0
- package/realtime/dist/index.d.ts +4 -2
- package/realtime/dist/listener.d.ts +14 -0
- package/realtime/dist/message.d.ts +3 -0
- package/realtime/dist/snapshot.d.ts +17 -0
- package/realtime/dist/utils.d.ts +1 -0
- package/realtime/dist/virtual-websocket-client.d.ts +62 -0
- package/realtime/dist/websocket-client.d.ts +78 -0
- package/realtime/dist/ws-event.d.ts +126 -0
- package/storage/dist/cloudbase-storage.d.ts +58 -0
- package/storage/dist/download-builder.d.ts +24 -0
- package/storage/dist/encoding.d.ts +3 -0
- package/storage/dist/http.d.ts +38 -0
- package/storage/dist/index.d.ts +13 -2
- package/storage/dist/node-types.d.ts +6 -0
- package/storage/dist/storage-bucket-api-neo.d.ts +15 -0
- package/storage/dist/storage-file-api-classic.d.ts +80 -0
- package/storage/dist/storage-file-api-neo.d.ts +48 -0
- package/storage/dist/supabase/errors.d.ts +20 -0
- package/storage/dist/supabase/types.d.ts +63 -0
- package/storage/dist/types.d.ts +142 -0
- package/storage/dist/validation.d.ts +2 -0
- package/types/auth.d.ts +1 -1
- package/types/index.d.ts +3 -2
- package/types/package.json +1 -1
- package/utilities/dist/cjs/libs/cache.d.ts +2 -2
- package/utilities/dist/cjs/libs/events.d.ts +1 -1
- package/utilities/dist/cjs/libs/util.d.ts +1 -1
- package/utilities/dist/esm/libs/cache.d.ts +2 -2
- package/utilities/dist/esm/libs/events.d.ts +1 -1
- package/utilities/dist/esm/libs/util.d.ts +1 -1
- package/utilities/package.json +1 -1
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { SnapshotType, ISnapshot } from '@cloudbase/js-sdk/types/realtime';
|
|
2
|
+
import { ISingleDBEvent } from '@cloudbase/js-sdk/types/database';
|
|
3
|
+
interface ISnapshotConstructorOptions {
|
|
4
|
+
id: number;
|
|
5
|
+
docChanges: ISingleDBEvent[];
|
|
6
|
+
docs: Record<string, any>[];
|
|
7
|
+
type?: SnapshotType;
|
|
8
|
+
msgType?: String;
|
|
9
|
+
}
|
|
10
|
+
export declare class Snapshot implements ISnapshot {
|
|
11
|
+
id: number;
|
|
12
|
+
docChanges: ISingleDBEvent[];
|
|
13
|
+
docs: Record<string, any>[];
|
|
14
|
+
type?: 'init';
|
|
15
|
+
constructor(options: ISnapshotConstructorOptions);
|
|
16
|
+
}
|
|
17
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const sleep: (ms?: number) => Promise<unknown>;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { IResponseMessage, IWatchOptions } from '@cloudbase/js-sdk/types/realtime';
|
|
2
|
+
import { RealtimeListener } from './listener';
|
|
3
|
+
import { IWSSendOptions } from './websocket-client';
|
|
4
|
+
interface IVirtualWebSocketClientConstructorOptions extends IWatchOptions {
|
|
5
|
+
envId?: string;
|
|
6
|
+
collectionName: string;
|
|
7
|
+
query: string;
|
|
8
|
+
limit?: number;
|
|
9
|
+
orderBy?: Record<string, string>;
|
|
10
|
+
send: <T = any>(opts: IWSSendOptions) => Promise<T>;
|
|
11
|
+
login: (envId?: string, refresh?: boolean) => Promise<any>;
|
|
12
|
+
isWSConnected: () => boolean;
|
|
13
|
+
onceWSConnected: () => Promise<void>;
|
|
14
|
+
getWaitExpectedTimeoutLength: () => number;
|
|
15
|
+
onWatchStart: (client: VirtualWebSocketClient, queryID: string) => void;
|
|
16
|
+
onWatchClose: (client: VirtualWebSocketClient, queryID: string) => void;
|
|
17
|
+
debug?: boolean;
|
|
18
|
+
}
|
|
19
|
+
export declare class VirtualWebSocketClient {
|
|
20
|
+
watchId: string;
|
|
21
|
+
listener: RealtimeListener;
|
|
22
|
+
private envId?;
|
|
23
|
+
private collectionName;
|
|
24
|
+
private query;
|
|
25
|
+
private limit;
|
|
26
|
+
private orderBy;
|
|
27
|
+
private send;
|
|
28
|
+
private login;
|
|
29
|
+
private isWSConnected;
|
|
30
|
+
private onceWSConnected;
|
|
31
|
+
private getWaitExpectedTimeoutLength;
|
|
32
|
+
private onWatchStart;
|
|
33
|
+
private onWatchClose;
|
|
34
|
+
private debug?;
|
|
35
|
+
private watchStatus;
|
|
36
|
+
private availableRetries;
|
|
37
|
+
private ackTimeoutId?;
|
|
38
|
+
private initWatchPromise?;
|
|
39
|
+
private rebuildWatchPromise?;
|
|
40
|
+
private sessionInfo?;
|
|
41
|
+
private waitExpectedTimeoutId?;
|
|
42
|
+
constructor(options: IVirtualWebSocketClientConstructorOptions);
|
|
43
|
+
onMessage(msg: IResponseMessage): void;
|
|
44
|
+
closeWithError(error: any): void;
|
|
45
|
+
pause(): void;
|
|
46
|
+
resume(): Promise<void>;
|
|
47
|
+
private wsLogin;
|
|
48
|
+
private initWatch;
|
|
49
|
+
private rebuildWatch;
|
|
50
|
+
private handleWatchEstablishmentError;
|
|
51
|
+
private closeWatch;
|
|
52
|
+
private scheduleSendACK;
|
|
53
|
+
private clearACKSchedule;
|
|
54
|
+
private sendACK;
|
|
55
|
+
private handleCommonError;
|
|
56
|
+
private useRetryTicket;
|
|
57
|
+
private handleServerEvents;
|
|
58
|
+
private handleServerEventsInternel;
|
|
59
|
+
private postHandleServerEventsValidityCheck;
|
|
60
|
+
private clearWaitExpectedEvent;
|
|
61
|
+
}
|
|
62
|
+
export {};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { VirtualWebSocketClient } from './virtual-websocket-client';
|
|
2
|
+
import { IDatabaseServiceContext } from '@cloudbase/js-sdk/types/database';
|
|
3
|
+
import { IWatchOptions, DBRealtimeListener, IRequestMessage } from '@cloudbase/js-sdk/types/realtime';
|
|
4
|
+
import { CloseEventCode } from './ws-event';
|
|
5
|
+
export interface IRealtimeWebSocketClientConstructorOptions {
|
|
6
|
+
maxReconnect?: number;
|
|
7
|
+
reconnectInterval?: number;
|
|
8
|
+
context: IDatabaseServiceContext;
|
|
9
|
+
}
|
|
10
|
+
export interface ISignature {
|
|
11
|
+
envId: string;
|
|
12
|
+
secretVersion: number;
|
|
13
|
+
signStr: string;
|
|
14
|
+
wsUrl: string;
|
|
15
|
+
expireTS: number;
|
|
16
|
+
}
|
|
17
|
+
export interface ILoginInfo {
|
|
18
|
+
loggedIn: boolean;
|
|
19
|
+
loggingInPromise?: Promise<ILoginResult>;
|
|
20
|
+
loginStartTS?: number;
|
|
21
|
+
loginResult?: ILoginResult;
|
|
22
|
+
}
|
|
23
|
+
export interface ILoginResult {
|
|
24
|
+
envId: string;
|
|
25
|
+
}
|
|
26
|
+
export interface IWSSendOptions {
|
|
27
|
+
msg: IRequestMessage;
|
|
28
|
+
waitResponse?: boolean;
|
|
29
|
+
skipOnMessage?: boolean;
|
|
30
|
+
timeout?: number;
|
|
31
|
+
}
|
|
32
|
+
export interface IWSWatchOptions extends IWatchOptions {
|
|
33
|
+
envId?: string;
|
|
34
|
+
collectionName: string;
|
|
35
|
+
query: string;
|
|
36
|
+
limit?: number;
|
|
37
|
+
orderBy?: Record<string, string>;
|
|
38
|
+
}
|
|
39
|
+
export declare class RealtimeWebSocketClient {
|
|
40
|
+
private virtualWSClient;
|
|
41
|
+
private queryIdClientMap;
|
|
42
|
+
private watchIdClientMap;
|
|
43
|
+
private maxReconnect;
|
|
44
|
+
private reconnectInterval;
|
|
45
|
+
private context;
|
|
46
|
+
private ws?;
|
|
47
|
+
private lastPingSendTS?;
|
|
48
|
+
private pingFailed;
|
|
49
|
+
private pongMissed;
|
|
50
|
+
private pingTimeoutId?;
|
|
51
|
+
private pongTimeoutId?;
|
|
52
|
+
private logins;
|
|
53
|
+
private wsInitPromise?;
|
|
54
|
+
private wsReadySubsribers;
|
|
55
|
+
private wsResponseWait;
|
|
56
|
+
private rttObserved;
|
|
57
|
+
private reconnectState;
|
|
58
|
+
private wsSign;
|
|
59
|
+
constructor(options: IRealtimeWebSocketClientConstructorOptions);
|
|
60
|
+
clearHeartbeat(): void;
|
|
61
|
+
send: <T = any>(opts: IWSSendOptions) => Promise<T>;
|
|
62
|
+
close(code: CloseEventCode): void;
|
|
63
|
+
closeAllClients: (error: any) => void;
|
|
64
|
+
pauseClients: (clients?: Set<VirtualWebSocketClient>) => void;
|
|
65
|
+
resumeClients: (clients?: Set<VirtualWebSocketClient>) => void;
|
|
66
|
+
watch(options: IWSWatchOptions): DBRealtimeListener;
|
|
67
|
+
private initWebSocketConnection;
|
|
68
|
+
private initWebSocketEvent;
|
|
69
|
+
private isWSConnected;
|
|
70
|
+
private onceWSConnected;
|
|
71
|
+
private webLogin;
|
|
72
|
+
private getWsSign;
|
|
73
|
+
private getWaitExpectedTimeoutLength;
|
|
74
|
+
private heartbeat;
|
|
75
|
+
private ping;
|
|
76
|
+
private onWatchStart;
|
|
77
|
+
private onWatchClose;
|
|
78
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { CloudSDKError } from './error';
|
|
2
|
+
export declare const CLOSE_EVENT_CODE_INFO: {
|
|
3
|
+
1000: {
|
|
4
|
+
code: number;
|
|
5
|
+
name: string;
|
|
6
|
+
description: string;
|
|
7
|
+
};
|
|
8
|
+
1001: {
|
|
9
|
+
code: number;
|
|
10
|
+
name: string;
|
|
11
|
+
description: string;
|
|
12
|
+
};
|
|
13
|
+
1002: {
|
|
14
|
+
code: number;
|
|
15
|
+
name: string;
|
|
16
|
+
description: string;
|
|
17
|
+
};
|
|
18
|
+
1003: {
|
|
19
|
+
code: number;
|
|
20
|
+
name: string;
|
|
21
|
+
description: string;
|
|
22
|
+
};
|
|
23
|
+
1005: {
|
|
24
|
+
code: number;
|
|
25
|
+
name: string;
|
|
26
|
+
description: string;
|
|
27
|
+
};
|
|
28
|
+
1006: {
|
|
29
|
+
code: number;
|
|
30
|
+
name: string;
|
|
31
|
+
description: string;
|
|
32
|
+
};
|
|
33
|
+
1007: {
|
|
34
|
+
code: number;
|
|
35
|
+
name: string;
|
|
36
|
+
description: string;
|
|
37
|
+
};
|
|
38
|
+
1008: {
|
|
39
|
+
code: number;
|
|
40
|
+
name: string;
|
|
41
|
+
description: string;
|
|
42
|
+
};
|
|
43
|
+
1009: {
|
|
44
|
+
code: number;
|
|
45
|
+
name: string;
|
|
46
|
+
description: string;
|
|
47
|
+
};
|
|
48
|
+
1010: {
|
|
49
|
+
code: number;
|
|
50
|
+
name: string;
|
|
51
|
+
description: string;
|
|
52
|
+
};
|
|
53
|
+
1011: {
|
|
54
|
+
code: number;
|
|
55
|
+
name: string;
|
|
56
|
+
description: string;
|
|
57
|
+
};
|
|
58
|
+
1012: {
|
|
59
|
+
code: number;
|
|
60
|
+
name: string;
|
|
61
|
+
description: string;
|
|
62
|
+
};
|
|
63
|
+
1013: {
|
|
64
|
+
code: number;
|
|
65
|
+
name: string;
|
|
66
|
+
description: string;
|
|
67
|
+
};
|
|
68
|
+
1014: {
|
|
69
|
+
code: number;
|
|
70
|
+
name: string;
|
|
71
|
+
description: string;
|
|
72
|
+
};
|
|
73
|
+
1015: {
|
|
74
|
+
code: number;
|
|
75
|
+
name: string;
|
|
76
|
+
description: string;
|
|
77
|
+
};
|
|
78
|
+
3000: {
|
|
79
|
+
code: number;
|
|
80
|
+
name: string;
|
|
81
|
+
description: string;
|
|
82
|
+
};
|
|
83
|
+
3001: {
|
|
84
|
+
code: number;
|
|
85
|
+
name: string;
|
|
86
|
+
description: string;
|
|
87
|
+
};
|
|
88
|
+
3002: {
|
|
89
|
+
code: number;
|
|
90
|
+
name: string;
|
|
91
|
+
description: string;
|
|
92
|
+
};
|
|
93
|
+
3003: {
|
|
94
|
+
code: number;
|
|
95
|
+
name: string;
|
|
96
|
+
description: string;
|
|
97
|
+
};
|
|
98
|
+
3050: {
|
|
99
|
+
code: number;
|
|
100
|
+
name: string;
|
|
101
|
+
description: string;
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
export declare enum CloseEventCode {
|
|
105
|
+
NormalClosure = 1000,
|
|
106
|
+
GoingAway = 1001,
|
|
107
|
+
ProtocolError = 1002,
|
|
108
|
+
UnsupportedData = 1003,
|
|
109
|
+
NoStatusReceived = 1005,
|
|
110
|
+
AbnormalClosure = 1006,
|
|
111
|
+
InvalidFramePayloadData = 1007,
|
|
112
|
+
PolicyViolation = 1008,
|
|
113
|
+
MessageTooBig = 1009,
|
|
114
|
+
MissingExtension = 1010,
|
|
115
|
+
InternalError = 1011,
|
|
116
|
+
ServiceRestart = 1012,
|
|
117
|
+
TryAgainLater = 1013,
|
|
118
|
+
BadGateway = 1014,
|
|
119
|
+
TLSHandshake = 1015,
|
|
120
|
+
ReconnectWebSocket = 3000,
|
|
121
|
+
NoRealtimeListeners = 3001,
|
|
122
|
+
HeartbeatPingError = 3002,
|
|
123
|
+
HeartbeatPongTimeoutError = 3003,
|
|
124
|
+
NoAuthentication = 3050
|
|
125
|
+
}
|
|
126
|
+
export declare const getWSCloseError: (code: CloseEventCode, reason?: string) => CloudSDKError;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { ICloudbaseUploadFileParams, ICloudbaseUploadFileResult, ICloudbaseGetUploadMetadataParams, ICloudbaseDeleteFileParams, ICloudbaseDeleteFileResult, ICloudbaseGetTempFileURLResult, ICloudbaseGetTempFileURLParams, ICloudbaseDownloadFileResult, ICloudbaseDownloadFileParams, ICloudbaseCopyFileParams, ICloudbaseCopyFileResult } from '@cloudbase/js-sdk/types/storage';
|
|
2
|
+
export declare enum EUploadMethod {
|
|
3
|
+
put = "put",
|
|
4
|
+
post = "post"
|
|
5
|
+
}
|
|
6
|
+
export interface IUploadMetadata {
|
|
7
|
+
url: string;
|
|
8
|
+
token: string;
|
|
9
|
+
authorization: string;
|
|
10
|
+
fileId: string;
|
|
11
|
+
cosFileId: string;
|
|
12
|
+
download_url?: string;
|
|
13
|
+
}
|
|
14
|
+
export declare const COMPONENT_NAME = "storage";
|
|
15
|
+
type SignedHeader = Record<string, string[]>;
|
|
16
|
+
export interface ICloudbaseContext {
|
|
17
|
+
config: any;
|
|
18
|
+
request: any;
|
|
19
|
+
}
|
|
20
|
+
type TempFileURLItem = NonNullable<ICloudbaseGetTempFileURLResult['fileList']>[number];
|
|
21
|
+
type FileInfoItem = Pick<TempFileURLItem, 'code' | 'fileID' | 'tempFileURL'> & {
|
|
22
|
+
message?: TempFileURLItem['message'];
|
|
23
|
+
fileName?: string;
|
|
24
|
+
cloudId?: TempFileURLItem['fileID'];
|
|
25
|
+
contentType?: string;
|
|
26
|
+
mime?: string;
|
|
27
|
+
size?: number;
|
|
28
|
+
cacheControl?: string;
|
|
29
|
+
lastModified?: string;
|
|
30
|
+
etag?: string;
|
|
31
|
+
};
|
|
32
|
+
export declare class CloudbaseStorage {
|
|
33
|
+
protected context?: ICloudbaseContext;
|
|
34
|
+
constructor(context?: ICloudbaseContext);
|
|
35
|
+
get config(): any;
|
|
36
|
+
get request(): any;
|
|
37
|
+
isGateWay(): boolean;
|
|
38
|
+
uploadFile(params: Omit<ICloudbaseUploadFileParams, 'filePath'> & {
|
|
39
|
+
filePath?: string;
|
|
40
|
+
}, callback?: Function): Promise<ICloudbaseUploadFileResult>;
|
|
41
|
+
getUploadMetadata(params: ICloudbaseGetUploadMetadataParams & {
|
|
42
|
+
method?: EUploadMethod;
|
|
43
|
+
headers?: Record<string, string>;
|
|
44
|
+
signedHeader?: SignedHeader;
|
|
45
|
+
}, callback?: Function): Promise<{
|
|
46
|
+
data: IUploadMetadata;
|
|
47
|
+
requestId: string;
|
|
48
|
+
}>;
|
|
49
|
+
deleteFile(params: ICloudbaseDeleteFileParams, callback?: Function): Promise<ICloudbaseDeleteFileResult>;
|
|
50
|
+
getTempFileURL(params: ICloudbaseGetTempFileURLParams, callback?: Function): Promise<ICloudbaseGetTempFileURLResult>;
|
|
51
|
+
downloadFile(params: ICloudbaseDownloadFileParams, callback?: Function): Promise<ICloudbaseDownloadFileResult>;
|
|
52
|
+
copyFile(params: ICloudbaseCopyFileParams, callback?: Function): Promise<ICloudbaseCopyFileResult>;
|
|
53
|
+
getFileInfo(params: ICloudbaseGetTempFileURLParams): Promise<{
|
|
54
|
+
fileList: FileInfoItem[];
|
|
55
|
+
requestId: string;
|
|
56
|
+
}>;
|
|
57
|
+
}
|
|
58
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Http } from './http';
|
|
2
|
+
import { Result, DownloadOptions, FetchParameters } from './types';
|
|
3
|
+
export interface DownloadContext {
|
|
4
|
+
http: Http;
|
|
5
|
+
bucketId: string;
|
|
6
|
+
cleanName: string;
|
|
7
|
+
options?: DownloadOptions;
|
|
8
|
+
parameters?: FetchParameters;
|
|
9
|
+
headers?: Record<string, string>;
|
|
10
|
+
shouldThrowOnError: boolean;
|
|
11
|
+
}
|
|
12
|
+
export declare class StreamDownloadBuilder implements PromiseLike<Result<ReadableStream<Uint8Array>>> {
|
|
13
|
+
private ctx;
|
|
14
|
+
constructor(ctx: DownloadContext);
|
|
15
|
+
then<TResult1 = Result<ReadableStream<Uint8Array>>, TResult2 = never>(onfulfilled?: ((value: Result<ReadableStream<Uint8Array>>) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null): PromiseLike<TResult1 | TResult2>;
|
|
16
|
+
private execute;
|
|
17
|
+
}
|
|
18
|
+
export declare class DownloadBuilder implements PromiseLike<Result<Blob>> {
|
|
19
|
+
private ctx;
|
|
20
|
+
constructor(ctx: DownloadContext);
|
|
21
|
+
asStream(): StreamDownloadBuilder;
|
|
22
|
+
then<TResult1 = Result<Blob>, TResult2 = never>(onfulfilled?: ((value: Result<Blob>) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null): PromiseLike<TResult1 | TResult2>;
|
|
23
|
+
private execute;
|
|
24
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Result, FetchParameters } from './types';
|
|
2
|
+
export interface Context {
|
|
3
|
+
config: any;
|
|
4
|
+
request: any;
|
|
5
|
+
}
|
|
6
|
+
export declare function handleOperation<T>(fn: () => Promise<T>, shouldThrowOnError: boolean): Promise<Result<T>>;
|
|
7
|
+
export declare class Http {
|
|
8
|
+
readonly ctx: Context;
|
|
9
|
+
constructor(ctx: Context);
|
|
10
|
+
private get request();
|
|
11
|
+
gatewayOrigin(): string;
|
|
12
|
+
buildUrl(path: string, query?: Record<string, any>): string;
|
|
13
|
+
toFullUrl(maybeRelative: string): string;
|
|
14
|
+
send<T = any>(opts: {
|
|
15
|
+
method: string;
|
|
16
|
+
path: string;
|
|
17
|
+
json?: any;
|
|
18
|
+
rawBody?: any;
|
|
19
|
+
headers?: Record<string, string>;
|
|
20
|
+
query?: Record<string, any>;
|
|
21
|
+
withCredentials?: boolean;
|
|
22
|
+
signal?: AbortSignal;
|
|
23
|
+
cache?: FetchParameters['cache'];
|
|
24
|
+
}): Promise<T>;
|
|
25
|
+
download(opts: {
|
|
26
|
+
path: string;
|
|
27
|
+
headers?: Record<string, string>;
|
|
28
|
+
query?: Record<string, any>;
|
|
29
|
+
withCredentials?: boolean;
|
|
30
|
+
signal?: AbortSignal;
|
|
31
|
+
cache?: FetchParameters['cache'];
|
|
32
|
+
}): Promise<{
|
|
33
|
+
response: Response;
|
|
34
|
+
status: number;
|
|
35
|
+
header: any;
|
|
36
|
+
}>;
|
|
37
|
+
private unwrap;
|
|
38
|
+
}
|
package/storage/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,13 @@
|
|
|
1
|
-
import { ICloudbase } from '@cloudbase/types';
|
|
2
|
-
|
|
1
|
+
import { ICloudbase } from '@cloudbase/js-sdk/types';
|
|
2
|
+
import { StorageFileApi } from './storage-file-api-neo';
|
|
3
|
+
import { StorageBucketApi } from './storage-bucket-api-neo';
|
|
4
|
+
import { ClassicStorageFileApi } from './storage-file-api-classic';
|
|
5
|
+
export { COMPONENT_NAME, CloudbaseStorage } from './cloudbase-storage';
|
|
6
|
+
export type { ICloudbaseContext } from './cloudbase-storage';
|
|
7
|
+
export { ClassicStorageFileApi } from './storage-file-api-classic';
|
|
8
|
+
export { StorageFileApi } from './storage-file-api-neo';
|
|
9
|
+
export declare class StorageClient extends StorageBucketApi {
|
|
10
|
+
from(): ClassicStorageFileApi;
|
|
11
|
+
from<const B extends string>(bucketId: B): StorageFileApi;
|
|
12
|
+
}
|
|
13
|
+
export declare function registerStorage(app: Pick<ICloudbase, 'registerComponent'>): void;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Context, Http } from './http';
|
|
2
|
+
import { Result, Bucket, ListBucketOptions, CreateBucketOptions, UpdateBucketOptions, MessageResponse } from './types';
|
|
3
|
+
export declare class StorageBucketApi {
|
|
4
|
+
protected http: Http;
|
|
5
|
+
protected shouldThrowOnError: boolean;
|
|
6
|
+
constructor(context?: Context, shouldThrowOnError?: boolean);
|
|
7
|
+
throwOnError(): this;
|
|
8
|
+
listBuckets(options?: ListBucketOptions): Promise<Result<Bucket[]>>;
|
|
9
|
+
getBucket(bucketId: string): Promise<Result<Bucket>>;
|
|
10
|
+
createBucket(bucketId: string, options?: CreateBucketOptions): Promise<Result<{
|
|
11
|
+
name: string;
|
|
12
|
+
}>>;
|
|
13
|
+
updateBucket(bucketId: string, options: UpdateBucketOptions): Promise<Result<MessageResponse>>;
|
|
14
|
+
deleteBucket(bucketId: string): Promise<Result<MessageResponse>>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { Camelize, FileBody, FileObject, FileObjectV2, FileOptions, TransformOptions } from './supabase/types';
|
|
2
|
+
import { Result } from './types';
|
|
3
|
+
import { StorageError } from './supabase/errors';
|
|
4
|
+
import { ICloudbaseContext } from './cloudbase-storage';
|
|
5
|
+
export declare class ClassicStorageFileApi {
|
|
6
|
+
protected shouldThrowOnError: boolean;
|
|
7
|
+
protected bucketId: string;
|
|
8
|
+
protected context?: ICloudbaseContext;
|
|
9
|
+
private storage;
|
|
10
|
+
constructor(context?: ICloudbaseContext, shouldThrowOnError?: boolean);
|
|
11
|
+
get config(): any;
|
|
12
|
+
get request(): any;
|
|
13
|
+
throwOnError(): this;
|
|
14
|
+
upload(path: string, fileBody: FileBody, fileOptions?: FileOptions): Promise<Result<{
|
|
15
|
+
id: string;
|
|
16
|
+
path: string;
|
|
17
|
+
fullPath: string;
|
|
18
|
+
}>>;
|
|
19
|
+
uploadToSignedUrl(path: string, _token: string, fileBody: FileBody, fileOptions?: FileOptions): Promise<Result<{
|
|
20
|
+
id: string;
|
|
21
|
+
path: string;
|
|
22
|
+
fullPath: string;
|
|
23
|
+
}>>;
|
|
24
|
+
createSignedUploadUrl(path: string): Promise<Result<{
|
|
25
|
+
signedUrl: string;
|
|
26
|
+
token: string;
|
|
27
|
+
path: string;
|
|
28
|
+
authorization?: string;
|
|
29
|
+
id?: string;
|
|
30
|
+
cosFileId?: string;
|
|
31
|
+
downloadUrl?: string;
|
|
32
|
+
}>>;
|
|
33
|
+
update(path: string, fileBody: FileBody, fileOptions?: FileOptions): Promise<Result<{
|
|
34
|
+
id: string;
|
|
35
|
+
path: string;
|
|
36
|
+
fullPath: string;
|
|
37
|
+
}>>;
|
|
38
|
+
move(fromPath: string, toPath: string): Promise<Result<{
|
|
39
|
+
message: string;
|
|
40
|
+
}>>;
|
|
41
|
+
copy(fromPath: string, toPath: string): Promise<Result<{
|
|
42
|
+
path: string;
|
|
43
|
+
}>>;
|
|
44
|
+
createSignedUrl(path: string, expiresIn: number, options?: {
|
|
45
|
+
download?: string | boolean;
|
|
46
|
+
transform?: TransformOptions;
|
|
47
|
+
}): Promise<Result<{
|
|
48
|
+
signedUrl: string;
|
|
49
|
+
}>>;
|
|
50
|
+
createSignedUrls(paths: string[], expiresIn: number): Promise<Result<Array<{
|
|
51
|
+
path: string;
|
|
52
|
+
signedUrl: string;
|
|
53
|
+
error: string | null;
|
|
54
|
+
}>>>;
|
|
55
|
+
download(path: string, options?: TransformOptions): Promise<{
|
|
56
|
+
data: Blob | null;
|
|
57
|
+
error: StorageError | null;
|
|
58
|
+
}>;
|
|
59
|
+
info(pathOrFileId: string): Promise<Result<Camelize<FileObjectV2>>>;
|
|
60
|
+
exists(pathOrFileId: string): Promise<Result<boolean>>;
|
|
61
|
+
getPublicUrl(path: string, options?: {
|
|
62
|
+
download?: string | boolean;
|
|
63
|
+
transform?: TransformOptions;
|
|
64
|
+
}): Promise<{
|
|
65
|
+
data: {
|
|
66
|
+
publicUrl: string;
|
|
67
|
+
};
|
|
68
|
+
} | {
|
|
69
|
+
data: null;
|
|
70
|
+
error: StorageError;
|
|
71
|
+
}>;
|
|
72
|
+
remove(paths: string[]): Promise<Result<FileObject[]>>;
|
|
73
|
+
list(): Promise<void>;
|
|
74
|
+
private getCloudPath;
|
|
75
|
+
private normalizeCloudId;
|
|
76
|
+
private toBase64;
|
|
77
|
+
private transformOptsToQueryString;
|
|
78
|
+
private extractPathFromFileId;
|
|
79
|
+
private extractBucketFromFileId;
|
|
80
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Http } from './http';
|
|
2
|
+
import { DownloadBuilder } from './download-builder';
|
|
3
|
+
import { FileBody, Result, UploadOptions, UploadResult, DownloadOptions, ListOptions, ListObjectsResponse, ObjectInfo, FullObject, DestinationOptions, SignedUrlOptions, SignedUrlResult, SignedUrlsResultItem, CreateSignedUploadUrlResult, PublicUrlOptions, FetchParameters } from './types';
|
|
4
|
+
export declare class StorageFileApi {
|
|
5
|
+
readonly bucketId: string;
|
|
6
|
+
private http;
|
|
7
|
+
private shouldThrowOnError;
|
|
8
|
+
private headers;
|
|
9
|
+
constructor(http: Http, bucketId: string, shouldThrowOnError?: boolean);
|
|
10
|
+
throwOnError(): this;
|
|
11
|
+
setHeader(name: string, value: string): this;
|
|
12
|
+
upload(path: string, fileBody: FileBody, fileOptions?: UploadOptions): Promise<Result<UploadResult>>;
|
|
13
|
+
update(path: string, fileBody: FileBody, fileOptions?: UploadOptions): Promise<Result<UploadResult>>;
|
|
14
|
+
download(path: string, options?: DownloadOptions, parameters?: FetchParameters): DownloadBuilder;
|
|
15
|
+
list(path?: string, options?: ListOptions, parameters?: FetchParameters): Promise<Result<ListObjectsResponse>>;
|
|
16
|
+
remove(paths: string[]): Promise<Result<FullObject[]>>;
|
|
17
|
+
copy(fromPath: string, toPath: string, options?: DestinationOptions): Promise<Result<{
|
|
18
|
+
path: string;
|
|
19
|
+
}>>;
|
|
20
|
+
move(fromPath: string, toPath: string, options?: DestinationOptions): Promise<Result<{
|
|
21
|
+
message: string;
|
|
22
|
+
}>>;
|
|
23
|
+
info(path: string): Promise<Result<ObjectInfo>>;
|
|
24
|
+
exists(path: string): Promise<Result<boolean>>;
|
|
25
|
+
createSignedUrl(path: string, expiresIn: number, options?: SignedUrlOptions): Promise<Result<SignedUrlResult>>;
|
|
26
|
+
createSignedUrls(paths: string[], expiresIn: number, options?: SignedUrlOptions): Promise<Result<SignedUrlsResultItem[]>>;
|
|
27
|
+
createSignedUploadUrl(path: string, options?: {
|
|
28
|
+
upsert?: boolean;
|
|
29
|
+
}): Promise<Result<CreateSignedUploadUrlResult>>;
|
|
30
|
+
uploadToSignedUrl(path: string, token: string, fileBody: FileBody, fileOptions?: UploadOptions): Promise<Result<{
|
|
31
|
+
path: string;
|
|
32
|
+
fullPath: string;
|
|
33
|
+
}>>;
|
|
34
|
+
getPublicUrl(path: string, options?: PublicUrlOptions): {
|
|
35
|
+
data: {
|
|
36
|
+
publicUrl: string;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
private send;
|
|
40
|
+
private uploadOrUpdate;
|
|
41
|
+
private cleanPath;
|
|
42
|
+
private encodePath;
|
|
43
|
+
private buildUploadBody;
|
|
44
|
+
private extractFromFormData;
|
|
45
|
+
private buildCopyMoveHeaders;
|
|
46
|
+
private appendUrlOptions;
|
|
47
|
+
private toBase64;
|
|
48
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export declare class StorageError extends Error {
|
|
2
|
+
protected __isStorageError: boolean;
|
|
3
|
+
constructor(message: string);
|
|
4
|
+
}
|
|
5
|
+
export declare function isStorageError(error: unknown): error is StorageError;
|
|
6
|
+
export declare class StorageApiError extends StorageError {
|
|
7
|
+
status: number;
|
|
8
|
+
statusCode: string;
|
|
9
|
+
constructor(message: string, status: number, statusCode: string);
|
|
10
|
+
toJSON(): {
|
|
11
|
+
name: string;
|
|
12
|
+
message: string;
|
|
13
|
+
status: number;
|
|
14
|
+
statusCode: string;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export declare class StorageUnknownError extends StorageError {
|
|
18
|
+
originalError: unknown;
|
|
19
|
+
constructor(message: string, originalError: unknown);
|
|
20
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { MaybeNodeBuffer, NodeReadableStreamLike } from '../node-types';
|
|
2
|
+
export type FileBody = ArrayBuffer | ArrayBufferView | Blob | File | FormData | MaybeNodeBuffer | NodeReadableStreamLike | ReadableStream<Uint8Array> | URLSearchParams | string;
|
|
3
|
+
export type BucketType = 'STANDARD' | 'ANALYTICS';
|
|
4
|
+
export interface Bucket {
|
|
5
|
+
id: string;
|
|
6
|
+
type?: BucketType;
|
|
7
|
+
name: string;
|
|
8
|
+
owner: string;
|
|
9
|
+
file_size_limit?: number;
|
|
10
|
+
allowed_mime_types?: string[];
|
|
11
|
+
created_at: string;
|
|
12
|
+
updated_at: string;
|
|
13
|
+
public: boolean;
|
|
14
|
+
}
|
|
15
|
+
export interface FileObject {
|
|
16
|
+
name: string;
|
|
17
|
+
bucket_id: string;
|
|
18
|
+
owner: string;
|
|
19
|
+
id: string;
|
|
20
|
+
updated_at: string;
|
|
21
|
+
created_at: string;
|
|
22
|
+
last_accessed_at: string;
|
|
23
|
+
metadata: Record<string, any>;
|
|
24
|
+
buckets: Bucket;
|
|
25
|
+
}
|
|
26
|
+
export interface FileObjectV2 {
|
|
27
|
+
id: string;
|
|
28
|
+
version: string;
|
|
29
|
+
name: string;
|
|
30
|
+
bucket_id: string;
|
|
31
|
+
updated_at: string;
|
|
32
|
+
created_at: string;
|
|
33
|
+
last_accessed_at: string;
|
|
34
|
+
size?: number;
|
|
35
|
+
cache_control?: string;
|
|
36
|
+
content_type?: string;
|
|
37
|
+
etag?: string;
|
|
38
|
+
last_modified?: string;
|
|
39
|
+
metadata?: Record<string, any>;
|
|
40
|
+
}
|
|
41
|
+
export interface FileOptions {
|
|
42
|
+
cacheControl?: string;
|
|
43
|
+
contentType?: string;
|
|
44
|
+
upsert?: boolean;
|
|
45
|
+
duplex?: string;
|
|
46
|
+
metadata?: Record<string, any>;
|
|
47
|
+
headers?: Record<string, string>;
|
|
48
|
+
}
|
|
49
|
+
export interface DestinationOptions {
|
|
50
|
+
destinationBucket?: string;
|
|
51
|
+
}
|
|
52
|
+
export interface TransformOptions {
|
|
53
|
+
width?: number;
|
|
54
|
+
height?: number;
|
|
55
|
+
resize?: 'cover' | 'contain' | 'fill';
|
|
56
|
+
quality?: number;
|
|
57
|
+
format?: 'origin';
|
|
58
|
+
}
|
|
59
|
+
type CamelCase<S extends string> = S extends `${infer P1}_${infer P2}${infer P3}` ? `${Lowercase<P1>}${Uppercase<P2>}${CamelCase<P3>}` : S;
|
|
60
|
+
export type Camelize<T> = {
|
|
61
|
+
[K in keyof T as CamelCase<Extract<K, string>>]: T[K];
|
|
62
|
+
};
|
|
63
|
+
export {};
|