@pelican.ts/sdk 0.3.4-next.3 → 0.3.4-next.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/types.d.ts +58 -1
- package/package.json +1 -1
- package/src/api/client/types/websocket.ts +1 -1
package/dist/types.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import z from 'zod';
|
|
2
|
+
import { AxiosInstance } from 'axios';
|
|
3
|
+
import WebSocket from 'isomorphic-ws';
|
|
2
4
|
|
|
3
5
|
type ServerSignalOption = 'start' | 'stop' | 'restart' | 'kill';
|
|
4
6
|
|
|
@@ -938,6 +940,61 @@ type ApplicationUserApiKey = {
|
|
|
938
940
|
updated_at: string;
|
|
939
941
|
};
|
|
940
942
|
|
|
943
|
+
type SocketEventPayloadMap = {
|
|
944
|
+
[SOCKET_EVENT.AUTH_SUCCESS]: undefined;
|
|
945
|
+
[SOCKET_EVENT.STATUS]: PowerState;
|
|
946
|
+
[SOCKET_EVENT.CONSOLE_OUTPUT]: string;
|
|
947
|
+
[SOCKET_EVENT.STATS]: StatsWsJson;
|
|
948
|
+
[SOCKET_EVENT.DAEMON_ERROR]: undefined;
|
|
949
|
+
[SOCKET_EVENT.DAEMON_MESSAGE]: string;
|
|
950
|
+
[SOCKET_EVENT.INSTALL_OUTPUT]: string;
|
|
951
|
+
[SOCKET_EVENT.INSTALL_STARTED]: undefined;
|
|
952
|
+
[SOCKET_EVENT.INSTALL_COMPLETED]: undefined;
|
|
953
|
+
[SOCKET_EVENT.TRANSFER_LOGS]: string;
|
|
954
|
+
[SOCKET_EVENT.TRANSFER_STATUS]: string;
|
|
955
|
+
[SOCKET_EVENT.BACKUP_COMPLETED]: BackupCompletedJson;
|
|
956
|
+
[SOCKET_EVENT.BACKUP_RESTORE_COMPLETED]: undefined;
|
|
957
|
+
[SOCKET_EVENT.TOKEN_EXPIRING]: undefined;
|
|
958
|
+
[SOCKET_EVENT.TOKEN_EXPIRED]: undefined;
|
|
959
|
+
[SOCKET_EVENT.JWT_ERROR]: string;
|
|
960
|
+
};
|
|
961
|
+
type Listener<E extends SOCKET_EVENT> = SocketEventPayloadMap[E] extends undefined ? () => void : (payload: SocketEventPayloadMap[E]) => void;
|
|
962
|
+
type CloseEventLike = Parameters<NonNullable<WebSocket["onclose"]>>[0];
|
|
963
|
+
type ErrorEventLike = Parameters<NonNullable<WebSocket["onerror"]>>[0];
|
|
964
|
+
declare class ServerWebsocket {
|
|
965
|
+
private readonly r;
|
|
966
|
+
private readonly serverId;
|
|
967
|
+
private socket?;
|
|
968
|
+
private currentToken?;
|
|
969
|
+
private readonly bus;
|
|
970
|
+
private debugLogging;
|
|
971
|
+
private stripColors;
|
|
972
|
+
private detachMessageListener?;
|
|
973
|
+
constructor(requester: AxiosInstance, id: string, stripColors?: boolean);
|
|
974
|
+
on<E extends SOCKET_EVENT>(event: E, listener: Listener<E>): () => void;
|
|
975
|
+
deregister<E extends SOCKET_EVENT>(event: E, listener: Listener<E>): void;
|
|
976
|
+
private emit;
|
|
977
|
+
connect(resumable?: boolean, debugLogging?: boolean): Promise<void>;
|
|
978
|
+
onSocketDisconnect(handler: (event: CloseEventLike) => void): void;
|
|
979
|
+
onSocketError(handler: (event: ErrorEventLike) => void): void;
|
|
980
|
+
makeResumable(disconnectsToo: boolean): void;
|
|
981
|
+
private attachMessageListener;
|
|
982
|
+
private handleIncomingMessage;
|
|
983
|
+
private parseMessage;
|
|
984
|
+
private normalisePayload;
|
|
985
|
+
private dispatchMessage;
|
|
986
|
+
private refreshCredentials;
|
|
987
|
+
private authenticate;
|
|
988
|
+
disconnect(): void;
|
|
989
|
+
requestStats(): void;
|
|
990
|
+
requestLogs(): void;
|
|
991
|
+
private send;
|
|
992
|
+
getStats(): Promise<StatsWsJson>;
|
|
993
|
+
getLogs(): Promise<string[]>;
|
|
994
|
+
sendPoweraction(action: ServerSignalOption): void;
|
|
995
|
+
sendCommand(cmd: string): void;
|
|
996
|
+
}
|
|
997
|
+
|
|
941
998
|
type ServerStatus = 'starting' | 'stopping' | 'online' | 'offline';
|
|
942
999
|
declare enum SERVER_SIGNAL {
|
|
943
1000
|
'START' = "start",
|
|
@@ -1164,4 +1221,4 @@ type Permission = {
|
|
|
1164
1221
|
keys: Record<string, string>;
|
|
1165
1222
|
};
|
|
1166
1223
|
|
|
1167
|
-
export { type APIKey, type Allocation, type AllocationRel, type ApplicationEggVariable, type ApplicationServer, type ApplicationUser, type ApplicationUserApiKey, type AuthSuccessWsEvent, type BackupCompletedEvent, type BackupCompletedJson, type BackupRestoreCompletedEvent, type ConsoleLogWsEvent, type Container, type DaemonErrorEvent, type DaemonMessageEvent, type DatabaseHost, type Egg, type EggVariable, type ExportedEgg, type FeatureLimits, type FileObject, type InstallCompletedEvent, type InstallOutputEvent, type InstallStartedEvent, type JwtErrorEvent, type LanguagesType, type Location, type Mount, type Node, type NodeConfiguration, type Permission, type PowerState, type Role, SERVER_SIGNAL, SOCKET_EVENT, type SSHKey, type Schedule, type ScheduleTask, type Server, type ServerActivityLog, type ServerAllocation, type ServerBackup, type ServerDatabase, type ServerLimits, type ServerSignalOption, type ServerStats, type ServerStatus, type ServerSubuser, type StartupMeta, type StartupParams, type StatsWsEvent, type StatsWsJson, type StatusWsEvent, type SubuserPermission, type TimezonesType, type TokenExpiredWsEvent, type TokenExpiringWsEvent, type TransferLogsEvent, type TransferStatusEvent, type User, type WebsocketEvent, languagesSchema, timezonesSchema };
|
|
1224
|
+
export { type APIKey, type Allocation, type AllocationRel, type ApplicationEggVariable, type ApplicationServer, type ApplicationUser, type ApplicationUserApiKey, type AuthSuccessWsEvent, type BackupCompletedEvent, type BackupCompletedJson, type BackupRestoreCompletedEvent, type ConsoleLogWsEvent, type Container, type DaemonErrorEvent, type DaemonMessageEvent, type DatabaseHost, type Egg, type EggVariable, type ExportedEgg, type FeatureLimits, type FileObject, type InstallCompletedEvent, type InstallOutputEvent, type InstallStartedEvent, type JwtErrorEvent, type LanguagesType, type Location, type Mount, type Node, type NodeConfiguration, type Permission, type PowerState, type Role, SERVER_SIGNAL, SOCKET_EVENT, type SSHKey, type Schedule, type ScheduleTask, type Server, type ServerActivityLog, type ServerAllocation, type ServerBackup, type ServerDatabase, type ServerLimits, type ServerSignalOption, type ServerStats, type ServerStatus, type ServerSubuser, ServerWebsocket, type StartupMeta, type StartupParams, type StatsWsEvent, type StatsWsJson, type StatusWsEvent, type SubuserPermission, type TimezonesType, type TokenExpiredWsEvent, type TokenExpiringWsEvent, type TransferLogsEvent, type TransferStatusEvent, type User, type WebsocketEvent, languagesSchema, timezonesSchema };
|
package/package.json
CHANGED