@pelican.ts/sdk 0.3.4-next.2 → 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/index.d.mts CHANGED
@@ -1505,7 +1505,7 @@ declare class Roles {
1505
1505
  type Egg = {
1506
1506
  id: number;
1507
1507
  uuid: string;
1508
- name: number;
1508
+ name: string;
1509
1509
  author: string;
1510
1510
  description: string;
1511
1511
  features: string[];
@@ -1548,7 +1548,7 @@ type ExportedEgg = {
1548
1548
  update_url: Nullable<string>;
1549
1549
  };
1550
1550
  exported_at: string;
1551
- name: number;
1551
+ name: string;
1552
1552
  author: string;
1553
1553
  description: string;
1554
1554
  uuid: string;
package/dist/index.d.ts CHANGED
@@ -1505,7 +1505,7 @@ declare class Roles {
1505
1505
  type Egg = {
1506
1506
  id: number;
1507
1507
  uuid: string;
1508
- name: number;
1508
+ name: string;
1509
1509
  author: string;
1510
1510
  description: string;
1511
1511
  features: string[];
@@ -1548,7 +1548,7 @@ type ExportedEgg = {
1548
1548
  update_url: Nullable<string>;
1549
1549
  };
1550
1550
  exported_at: string;
1551
- name: number;
1551
+ name: string;
1552
1552
  author: string;
1553
1553
  description: string;
1554
1554
  uuid: string;
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
 
@@ -844,7 +846,7 @@ type Role = {
844
846
  type Egg = {
845
847
  id: number;
846
848
  uuid: string;
847
- name: number;
849
+ name: string;
848
850
  author: string;
849
851
  description: string;
850
852
  features: string[];
@@ -887,7 +889,7 @@ type ExportedEgg = {
887
889
  update_url: Nullable<string>;
888
890
  };
889
891
  exported_at: string;
890
- name: number;
892
+ name: string;
891
893
  author: string;
892
894
  description: string;
893
895
  uuid: string;
@@ -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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pelican.ts/sdk",
3
- "version": "0.3.4-next.2",
3
+ "version": "0.3.4-next.4",
4
4
  "description": "Pelican panel SDK for TypeScript",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -4,7 +4,7 @@ import {EggVariable} from "@/api/common/types";
4
4
  export type Egg = {
5
5
  id: number,
6
6
  uuid: string,
7
- name: number,
7
+ name: string,
8
8
  author: string,
9
9
  description: string,
10
10
  features: string[],
@@ -50,7 +50,7 @@ export type ExportedEgg = {
50
50
  update_url: Nullable<string>
51
51
  },
52
52
  exported_at: string,
53
- name: number,
53
+ name: string,
54
54
  author: string,
55
55
  description: string,
56
56
  uuid: string,
@@ -147,4 +147,4 @@ export type JwtErrorEvent = {
147
147
  args: [string];
148
148
  };
149
149
 
150
-
150
+ export {ServerWebsocket} from "@/api/client/server_websocket";