@voidedhost/shared-types 1.0.1 → 1.0.3

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.
@@ -0,0 +1 @@
1
+ export * from "./structures";
@@ -0,0 +1 @@
1
+ export {};
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export * from "./websocket";
2
+ export * from "./api";
@@ -1,10 +1,11 @@
1
1
  import { ApiComment, ApiImage } from "../api";
2
- import { Level, SocketResponse } from "./general";
3
- export interface ServerToClientEvents {
2
+ import { WebSocketLevel, WebSocketResponse } from "./general";
3
+ export type WebSocketSubscriptionChannel = `images:*` | `users:${number}:images` | `images:${number}`;
4
+ export interface WebSocketServerToClientEvents {
4
5
  welcome: (payload: {
5
6
  userId: number;
6
7
  username: string;
7
- level: Level;
8
+ level: WebSocketLevel;
8
9
  }) => void;
9
10
  error: (message: string) => void;
10
11
  "share:count": (payload: {
@@ -25,13 +26,12 @@ export interface ServerToClientEvents {
25
26
  id: number;
26
27
  } & Partial<ApiComment>) => void;
27
28
  }
28
- type SubscriptionChannel = `images:*` | `users:${number}:images` | `images:${number}`;
29
- export interface ClientToServerEvents {
29
+ export interface WebSocketClientToServerEvents {
30
30
  ping: (callback: () => void) => void;
31
- subscribe: (intent: SubscriptionChannel, callback?: (response: SocketResponse) => void) => void;
32
- unsubscribe: (intent: SubscriptionChannel, callback?: (response: SocketResponse) => void) => void;
33
- "share:join": (shareId: number, callback?: (response: SocketResponse) => void) => void;
34
- "share:leave": (shareId: number, callback?: (response: SocketResponse) => void) => void;
31
+ subscribe: (intent: WebSocketSubscriptionChannel, callback?: (response: WebSocketResponse) => void) => void;
32
+ unsubscribe: (intent: WebSocketSubscriptionChannel, callback?: (response: WebSocketResponse) => void) => void;
33
+ "share:join": (shareId: number, callback?: (response: WebSocketResponse) => void) => void;
34
+ "share:leave": (shareId: number, callback?: (response: WebSocketResponse) => void) => void;
35
35
  "image:update": (payload: {
36
36
  exclude?: string[];
37
37
  rooms: string[];
@@ -66,4 +66,3 @@ export interface ClientToServerEvents {
66
66
  } & Partial<ApiComment>;
67
67
  }) => void;
68
68
  }
69
- export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -1,9 +1,9 @@
1
- export declare enum Level {
1
+ export declare enum WebSocketLevel {
2
2
  GUEST = 1,
3
3
  USER = 2,
4
4
  MASTER = 3
5
5
  }
6
- export type SocketResponse<T = void> = [T] extends [void] ? {
6
+ export type WebSocketResponse<T = void> = [T] extends [void] ? {
7
7
  success: true;
8
8
  } | {
9
9
  success: false;
@@ -0,0 +1,6 @@
1
+ export var Level;
2
+ (function (Level) {
3
+ Level[Level["GUEST"] = 1] = "GUEST";
4
+ Level[Level["USER"] = 2] = "USER";
5
+ Level[Level["MASTER"] = 3] = "MASTER";
6
+ })(Level || (Level = {}));
@@ -1 +1,2 @@
1
1
  export * from "./events";
2
+ export * from "./general";
@@ -0,0 +1,2 @@
1
+ export * from "./events";
2
+ export * from "./general";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voidedhost/shared-types",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "Shared TypeScript types for voided.host projects",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [