@pluv/platform-pluv 0.33.0 → 0.34.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/.turbo/turbo-build.log +8 -8
- package/CHANGELOG.md +58 -0
- package/dist/index.d.mts +60 -213
- package/dist/index.d.ts +60 -213
- package/dist/index.js +101 -84
- package/dist/index.mjs +96 -79
- package/package.json +9 -9
- package/src/PluvPlatform.ts +197 -5
- package/src/index.ts +8 -4
- package/src/platformPluv.ts +6 -0
- package/src/types.ts +29 -0
- package/src/PluvIO.ts +0 -221
- package/src/createIO.ts +0 -7
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @pluv/platform-pluv@0.
|
|
2
|
+
> @pluv/platform-pluv@0.34.0 build /home/runner/work/pluv/pluv/packages/platform-pluv
|
|
3
3
|
> tsup src/index.ts --format esm,cjs --dts
|
|
4
4
|
|
|
5
5
|
[34mCLI[39m Building entry: src/index.ts
|
|
@@ -8,11 +8,11 @@
|
|
|
8
8
|
[34mCLI[39m Target: es6
|
|
9
9
|
[34mESM[39m Build start
|
|
10
10
|
[34mCJS[39m Build start
|
|
11
|
-
[32mCJS[39m [1mdist/index.js [22m[
|
|
12
|
-
[32mCJS[39m ⚡️ Build success in
|
|
13
|
-
[32mESM[39m [1mdist/index.mjs [22m[
|
|
14
|
-
[32mESM[39m ⚡️ Build success in
|
|
11
|
+
[32mCJS[39m [1mdist/index.js [22m[32m10.70 KB[39m
|
|
12
|
+
[32mCJS[39m ⚡️ Build success in 82ms
|
|
13
|
+
[32mESM[39m [1mdist/index.mjs [22m[32m9.82 KB[39m
|
|
14
|
+
[32mESM[39m ⚡️ Build success in 90ms
|
|
15
15
|
[34mDTS[39m Build start
|
|
16
|
-
[32mDTS[39m ⚡️ Build success in
|
|
17
|
-
[32mDTS[39m [1mdist/index.d.mts [22m[
|
|
18
|
-
[32mDTS[39m [1mdist/index.d.ts [22m[
|
|
16
|
+
[32mDTS[39m ⚡️ Build success in 6566ms
|
|
17
|
+
[32mDTS[39m [1mdist/index.d.mts [22m[32m2.91 KB[39m
|
|
18
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m2.91 KB[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,63 @@
|
|
|
1
1
|
# @pluv/platform-pluv
|
|
2
2
|
|
|
3
|
+
## 0.34.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 70af3b2: **BREAKING**: The API has been updated to now be called as function `platformPluv` into `createIO` from `@pluv/io`.
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
// Before
|
|
11
|
+
|
|
12
|
+
import { createIO } from "@pluv/platform-pluv";
|
|
13
|
+
|
|
14
|
+
export const io = createIO({
|
|
15
|
+
authorize: {
|
|
16
|
+
user: z.object({
|
|
17
|
+
id: z.string(),
|
|
18
|
+
}),
|
|
19
|
+
},
|
|
20
|
+
basePath: "/api/pluv",
|
|
21
|
+
publicKey: "pk_...",
|
|
22
|
+
secretKey: "sk_...",
|
|
23
|
+
webhookSecret: "whsec_...",
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
export const GET = pluv.handler;
|
|
27
|
+
|
|
28
|
+
// After
|
|
29
|
+
|
|
30
|
+
import { createIO } from "@pluv/io";
|
|
31
|
+
import { platformPluv } from "@pluv/platform-pluv";
|
|
32
|
+
|
|
33
|
+
export const io = createIO({
|
|
34
|
+
authorize: {
|
|
35
|
+
user: z.object({
|
|
36
|
+
id: z.string(),
|
|
37
|
+
}),
|
|
38
|
+
},
|
|
39
|
+
platform: platformPluv({
|
|
40
|
+
basePath: "/api/pluv",
|
|
41
|
+
publicKey: "pk_...",
|
|
42
|
+
secretKey: "sk_...",
|
|
43
|
+
webhookSecret: "whsec_...",
|
|
44
|
+
}),
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
export const ioServer = io.server();
|
|
48
|
+
|
|
49
|
+
// Example: If you're on Next.js
|
|
50
|
+
export const GET = ioServer.fetch;
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Patch Changes
|
|
54
|
+
|
|
55
|
+
- Updated dependencies [0c920ea]
|
|
56
|
+
- Updated dependencies [70af3b2]
|
|
57
|
+
- @pluv/io@0.34.0
|
|
58
|
+
- @pluv/crdt@0.34.0
|
|
59
|
+
- @pluv/types@0.34.0
|
|
60
|
+
|
|
3
61
|
## 0.33.0
|
|
4
62
|
|
|
5
63
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -1,27 +1,5 @@
|
|
|
1
|
-
import { AbstractPlatform,
|
|
2
|
-
import * as hono from 'hono';
|
|
3
|
-
import { BaseUser, InputZodLike, IOLike } from '@pluv/types';
|
|
4
|
-
import { z } from 'zod';
|
|
1
|
+
import { AbstractPlatform, JWTEncodeParams, AbstractWebSocket, ConvertWebSocketConfig, WebSocketSerializedState, AbstractPlatformConfig } from '@pluv/io';
|
|
5
2
|
|
|
6
|
-
declare class PluvPlatform extends AbstractPlatform {
|
|
7
|
-
_registrationMode: WebSocketRegistrationMode;
|
|
8
|
-
acceptWebSocket(webSocket: AbstractWebSocket): Promise<void>;
|
|
9
|
-
convertWebSocket(webSocket: any, config: ConvertWebSocketConfig): AbstractWebSocket;
|
|
10
|
-
getLastPing(webSocket: AbstractWebSocket): number | null;
|
|
11
|
-
getSerializedState(webSocket: any): WebSocketSerializedState | null;
|
|
12
|
-
getSessionId(webSocket: any): string | null;
|
|
13
|
-
getWebSockets(): readonly any[];
|
|
14
|
-
initialize(config: AbstractPlatformConfig<{}>): this;
|
|
15
|
-
parseData(data: string | ArrayBuffer): Record<string, any>;
|
|
16
|
-
randomUUID(): string;
|
|
17
|
-
setSerializedState(webSocket: AbstractWebSocket, state: WebSocketSerializedState): void;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
interface PluvAuthorize<TUser extends BaseUser> {
|
|
21
|
-
required: true;
|
|
22
|
-
secret: string;
|
|
23
|
-
user: InputZodLike<TUser>;
|
|
24
|
-
}
|
|
25
3
|
interface PluvIOEndpoints {
|
|
26
4
|
createToken: string;
|
|
27
5
|
}
|
|
@@ -29,30 +7,18 @@ type RoomDeletedMessageEventData = {
|
|
|
29
7
|
encodedState: string | null;
|
|
30
8
|
room: string;
|
|
31
9
|
};
|
|
32
|
-
type UserConnectedEventData
|
|
10
|
+
type UserConnectedEventData = {
|
|
33
11
|
encodedState: string | null;
|
|
34
12
|
room: string;
|
|
35
|
-
user:
|
|
13
|
+
user: any;
|
|
36
14
|
};
|
|
37
|
-
type UserDisconnectedEventData
|
|
15
|
+
type UserDisconnectedEventData = {
|
|
38
16
|
encodedState: string | null;
|
|
39
17
|
room: string;
|
|
40
|
-
user:
|
|
41
|
-
};
|
|
42
|
-
type PluvIOListeners<TUser extends BaseUser> = {
|
|
43
|
-
getInitialStorage?: GetInitialStorageFn<{}>;
|
|
44
|
-
onRoomDeleted: (event: RoomDeletedMessageEventData) => void;
|
|
45
|
-
onUserConnected: (event: UserConnectedEventData<TUser>) => void;
|
|
46
|
-
onUserDisconnected: (event: UserDisconnectedEventData<TUser>) => void;
|
|
18
|
+
user: any;
|
|
47
19
|
};
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
} & {
|
|
51
|
-
[P in keyof PluvIOListeners<TUser>]?: undefined;
|
|
52
|
-
}) | ({
|
|
53
|
-
webhookSecret: string;
|
|
54
|
-
} & Partial<PluvIOListeners<TUser>>);
|
|
55
|
-
type PluvIOConfig<TUser extends BaseUser> = WebhooksConfig<TUser> & {
|
|
20
|
+
|
|
21
|
+
interface PluvPlatformConfig {
|
|
56
22
|
/**
|
|
57
23
|
* @ignore
|
|
58
24
|
* @readonly
|
|
@@ -61,187 +27,68 @@ type PluvIOConfig<TUser extends BaseUser> = WebhooksConfig<TUser> & {
|
|
|
61
27
|
_defs?: {
|
|
62
28
|
endpoints?: PluvIOEndpoints;
|
|
63
29
|
};
|
|
64
|
-
authorize: {
|
|
65
|
-
user: InputZodLike<TUser>;
|
|
66
|
-
};
|
|
67
30
|
basePath: string;
|
|
68
31
|
publicKey: string;
|
|
69
32
|
secretKey: string;
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
33
|
+
webhookSecret?: string;
|
|
34
|
+
}
|
|
35
|
+
declare class PluvPlatform extends AbstractPlatform<any, {}, {}, {
|
|
36
|
+
authorize: {
|
|
37
|
+
required: false;
|
|
38
|
+
secret: false;
|
|
39
|
+
};
|
|
40
|
+
handleMode: "fetch";
|
|
41
|
+
registrationMode: "attached";
|
|
42
|
+
requireAuth: true;
|
|
43
|
+
listeners: {
|
|
44
|
+
onRoomDeleted: true;
|
|
45
|
+
onRoomMessage: false;
|
|
46
|
+
onStorageUpdated: false;
|
|
47
|
+
onUserConnected: true;
|
|
48
|
+
onUserDisconnected: true;
|
|
49
|
+
};
|
|
50
|
+
}> {
|
|
51
|
+
readonly _config: {
|
|
52
|
+
authorize: {
|
|
53
|
+
required: false;
|
|
54
|
+
secret: false;
|
|
55
|
+
};
|
|
56
|
+
handleMode: "fetch";
|
|
57
|
+
registrationMode: "attached";
|
|
58
|
+
requireAuth: true;
|
|
59
|
+
listeners: {
|
|
60
|
+
onRoomDeleted: true;
|
|
61
|
+
onRoomMessage: false;
|
|
62
|
+
onStorageUpdated: false;
|
|
63
|
+
onUserConnected: true;
|
|
64
|
+
onUserDisconnected: true;
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
readonly _name = "platformPluv";
|
|
68
|
+
private _authorize;
|
|
73
69
|
private readonly _basePath;
|
|
74
70
|
private readonly _endpoints;
|
|
75
|
-
private
|
|
76
|
-
private
|
|
71
|
+
private _getInitialStorage?;
|
|
72
|
+
private _listeners?;
|
|
77
73
|
private readonly _publicKey;
|
|
78
74
|
private readonly _secretKey;
|
|
79
75
|
private readonly _webhookSecret?;
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
76
|
+
_createToken: (params: JWTEncodeParams<any, any>) => Promise<string>;
|
|
77
|
+
constructor(params: PluvPlatformConfig);
|
|
78
|
+
acceptWebSocket(webSocket: AbstractWebSocket): Promise<void>;
|
|
79
|
+
convertWebSocket(webSocket: any, config: ConvertWebSocketConfig): AbstractWebSocket;
|
|
80
|
+
getLastPing(webSocket: AbstractWebSocket): number | null;
|
|
81
|
+
getSerializedState(webSocket: any): WebSocketSerializedState | null;
|
|
82
|
+
getSessionId(webSocket: any): string | null;
|
|
83
|
+
getWebSockets(): readonly any[];
|
|
84
|
+
initialize(config: AbstractPlatformConfig<{}>): this;
|
|
85
|
+
parseData(data: string | ArrayBuffer): Record<string, any>;
|
|
86
|
+
randomUUID(): string;
|
|
87
|
+
setSerializedState(webSocket: AbstractWebSocket, state: WebSocketSerializedState): void;
|
|
88
|
+
validateConfig(config: any): void;
|
|
93
89
|
private _webhooks;
|
|
94
|
-
constructor(options: PluvIOConfig<TUser>);
|
|
95
|
-
createToken(params: JWTEncodeParams<TUser, PluvPlatform>): Promise<string>;
|
|
96
90
|
}
|
|
97
91
|
|
|
98
|
-
declare const
|
|
99
|
-
|
|
100
|
-
declare const ZodEvent: z.ZodDiscriminatedUnion<"event", [z.ZodObject<{
|
|
101
|
-
event: z.ZodLiteral<"initial-storage">;
|
|
102
|
-
data: z.ZodObject<{
|
|
103
|
-
room: z.ZodNullable<z.ZodString>;
|
|
104
|
-
}, "strip", z.ZodTypeAny, {
|
|
105
|
-
room: string | null;
|
|
106
|
-
}, {
|
|
107
|
-
room: string | null;
|
|
108
|
-
}>;
|
|
109
|
-
}, "strip", z.ZodTypeAny, {
|
|
110
|
-
event: "initial-storage";
|
|
111
|
-
data: {
|
|
112
|
-
room: string | null;
|
|
113
|
-
};
|
|
114
|
-
}, {
|
|
115
|
-
event: "initial-storage";
|
|
116
|
-
data: {
|
|
117
|
-
room: string | null;
|
|
118
|
-
};
|
|
119
|
-
}>, z.ZodObject<{
|
|
120
|
-
event: z.ZodLiteral<"room-deleted">;
|
|
121
|
-
data: z.ZodObject<{
|
|
122
|
-
room: z.ZodString;
|
|
123
|
-
storage: z.ZodNullable<z.ZodString>;
|
|
124
|
-
}, "strip", z.ZodTypeAny, {
|
|
125
|
-
room: string;
|
|
126
|
-
storage: string | null;
|
|
127
|
-
}, {
|
|
128
|
-
room: string;
|
|
129
|
-
storage: string | null;
|
|
130
|
-
}>;
|
|
131
|
-
}, "strip", z.ZodTypeAny, {
|
|
132
|
-
event: "room-deleted";
|
|
133
|
-
data: {
|
|
134
|
-
room: string;
|
|
135
|
-
storage: string | null;
|
|
136
|
-
};
|
|
137
|
-
}, {
|
|
138
|
-
event: "room-deleted";
|
|
139
|
-
data: {
|
|
140
|
-
room: string;
|
|
141
|
-
storage: string | null;
|
|
142
|
-
};
|
|
143
|
-
}>, z.ZodObject<{
|
|
144
|
-
event: z.ZodLiteral<"user-connected">;
|
|
145
|
-
data: z.ZodObject<{
|
|
146
|
-
room: z.ZodString;
|
|
147
|
-
storage: z.ZodNullable<z.ZodString>;
|
|
148
|
-
user: z.ZodObject<{
|
|
149
|
-
id: z.ZodString;
|
|
150
|
-
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
151
|
-
id: z.ZodString;
|
|
152
|
-
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
153
|
-
id: z.ZodString;
|
|
154
|
-
}, z.ZodTypeAny, "passthrough">>;
|
|
155
|
-
}, "strip", z.ZodTypeAny, {
|
|
156
|
-
room: string;
|
|
157
|
-
storage: string | null;
|
|
158
|
-
user: {
|
|
159
|
-
id: string;
|
|
160
|
-
} & {
|
|
161
|
-
[k: string]: unknown;
|
|
162
|
-
};
|
|
163
|
-
}, {
|
|
164
|
-
room: string;
|
|
165
|
-
storage: string | null;
|
|
166
|
-
user: {
|
|
167
|
-
id: string;
|
|
168
|
-
} & {
|
|
169
|
-
[k: string]: unknown;
|
|
170
|
-
};
|
|
171
|
-
}>;
|
|
172
|
-
}, "strip", z.ZodTypeAny, {
|
|
173
|
-
event: "user-connected";
|
|
174
|
-
data: {
|
|
175
|
-
room: string;
|
|
176
|
-
storage: string | null;
|
|
177
|
-
user: {
|
|
178
|
-
id: string;
|
|
179
|
-
} & {
|
|
180
|
-
[k: string]: unknown;
|
|
181
|
-
};
|
|
182
|
-
};
|
|
183
|
-
}, {
|
|
184
|
-
event: "user-connected";
|
|
185
|
-
data: {
|
|
186
|
-
room: string;
|
|
187
|
-
storage: string | null;
|
|
188
|
-
user: {
|
|
189
|
-
id: string;
|
|
190
|
-
} & {
|
|
191
|
-
[k: string]: unknown;
|
|
192
|
-
};
|
|
193
|
-
};
|
|
194
|
-
}>, z.ZodObject<{
|
|
195
|
-
event: z.ZodLiteral<"user-disconnected">;
|
|
196
|
-
data: z.ZodObject<{
|
|
197
|
-
room: z.ZodString;
|
|
198
|
-
storage: z.ZodNullable<z.ZodString>;
|
|
199
|
-
user: z.ZodObject<{
|
|
200
|
-
id: z.ZodString;
|
|
201
|
-
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
202
|
-
id: z.ZodString;
|
|
203
|
-
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
204
|
-
id: z.ZodString;
|
|
205
|
-
}, z.ZodTypeAny, "passthrough">>;
|
|
206
|
-
}, "strip", z.ZodTypeAny, {
|
|
207
|
-
room: string;
|
|
208
|
-
storage: string | null;
|
|
209
|
-
user: {
|
|
210
|
-
id: string;
|
|
211
|
-
} & {
|
|
212
|
-
[k: string]: unknown;
|
|
213
|
-
};
|
|
214
|
-
}, {
|
|
215
|
-
room: string;
|
|
216
|
-
storage: string | null;
|
|
217
|
-
user: {
|
|
218
|
-
id: string;
|
|
219
|
-
} & {
|
|
220
|
-
[k: string]: unknown;
|
|
221
|
-
};
|
|
222
|
-
}>;
|
|
223
|
-
}, "strip", z.ZodTypeAny, {
|
|
224
|
-
event: "user-disconnected";
|
|
225
|
-
data: {
|
|
226
|
-
room: string;
|
|
227
|
-
storage: string | null;
|
|
228
|
-
user: {
|
|
229
|
-
id: string;
|
|
230
|
-
} & {
|
|
231
|
-
[k: string]: unknown;
|
|
232
|
-
};
|
|
233
|
-
};
|
|
234
|
-
}, {
|
|
235
|
-
event: "user-disconnected";
|
|
236
|
-
data: {
|
|
237
|
-
room: string;
|
|
238
|
-
storage: string | null;
|
|
239
|
-
user: {
|
|
240
|
-
id: string;
|
|
241
|
-
} & {
|
|
242
|
-
[k: string]: unknown;
|
|
243
|
-
};
|
|
244
|
-
};
|
|
245
|
-
}>]>;
|
|
92
|
+
declare const platformPluv: (config: PluvPlatformConfig) => PluvPlatform;
|
|
246
93
|
|
|
247
|
-
export {
|
|
94
|
+
export { type PluvIOEndpoints, PluvPlatform, type RoomDeletedMessageEventData, type UserConnectedEventData, type UserDisconnectedEventData, platformPluv };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,27 +1,5 @@
|
|
|
1
|
-
import { AbstractPlatform,
|
|
2
|
-
import * as hono from 'hono';
|
|
3
|
-
import { BaseUser, InputZodLike, IOLike } from '@pluv/types';
|
|
4
|
-
import { z } from 'zod';
|
|
1
|
+
import { AbstractPlatform, JWTEncodeParams, AbstractWebSocket, ConvertWebSocketConfig, WebSocketSerializedState, AbstractPlatformConfig } from '@pluv/io';
|
|
5
2
|
|
|
6
|
-
declare class PluvPlatform extends AbstractPlatform {
|
|
7
|
-
_registrationMode: WebSocketRegistrationMode;
|
|
8
|
-
acceptWebSocket(webSocket: AbstractWebSocket): Promise<void>;
|
|
9
|
-
convertWebSocket(webSocket: any, config: ConvertWebSocketConfig): AbstractWebSocket;
|
|
10
|
-
getLastPing(webSocket: AbstractWebSocket): number | null;
|
|
11
|
-
getSerializedState(webSocket: any): WebSocketSerializedState | null;
|
|
12
|
-
getSessionId(webSocket: any): string | null;
|
|
13
|
-
getWebSockets(): readonly any[];
|
|
14
|
-
initialize(config: AbstractPlatformConfig<{}>): this;
|
|
15
|
-
parseData(data: string | ArrayBuffer): Record<string, any>;
|
|
16
|
-
randomUUID(): string;
|
|
17
|
-
setSerializedState(webSocket: AbstractWebSocket, state: WebSocketSerializedState): void;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
interface PluvAuthorize<TUser extends BaseUser> {
|
|
21
|
-
required: true;
|
|
22
|
-
secret: string;
|
|
23
|
-
user: InputZodLike<TUser>;
|
|
24
|
-
}
|
|
25
3
|
interface PluvIOEndpoints {
|
|
26
4
|
createToken: string;
|
|
27
5
|
}
|
|
@@ -29,30 +7,18 @@ type RoomDeletedMessageEventData = {
|
|
|
29
7
|
encodedState: string | null;
|
|
30
8
|
room: string;
|
|
31
9
|
};
|
|
32
|
-
type UserConnectedEventData
|
|
10
|
+
type UserConnectedEventData = {
|
|
33
11
|
encodedState: string | null;
|
|
34
12
|
room: string;
|
|
35
|
-
user:
|
|
13
|
+
user: any;
|
|
36
14
|
};
|
|
37
|
-
type UserDisconnectedEventData
|
|
15
|
+
type UserDisconnectedEventData = {
|
|
38
16
|
encodedState: string | null;
|
|
39
17
|
room: string;
|
|
40
|
-
user:
|
|
41
|
-
};
|
|
42
|
-
type PluvIOListeners<TUser extends BaseUser> = {
|
|
43
|
-
getInitialStorage?: GetInitialStorageFn<{}>;
|
|
44
|
-
onRoomDeleted: (event: RoomDeletedMessageEventData) => void;
|
|
45
|
-
onUserConnected: (event: UserConnectedEventData<TUser>) => void;
|
|
46
|
-
onUserDisconnected: (event: UserDisconnectedEventData<TUser>) => void;
|
|
18
|
+
user: any;
|
|
47
19
|
};
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
} & {
|
|
51
|
-
[P in keyof PluvIOListeners<TUser>]?: undefined;
|
|
52
|
-
}) | ({
|
|
53
|
-
webhookSecret: string;
|
|
54
|
-
} & Partial<PluvIOListeners<TUser>>);
|
|
55
|
-
type PluvIOConfig<TUser extends BaseUser> = WebhooksConfig<TUser> & {
|
|
20
|
+
|
|
21
|
+
interface PluvPlatformConfig {
|
|
56
22
|
/**
|
|
57
23
|
* @ignore
|
|
58
24
|
* @readonly
|
|
@@ -61,187 +27,68 @@ type PluvIOConfig<TUser extends BaseUser> = WebhooksConfig<TUser> & {
|
|
|
61
27
|
_defs?: {
|
|
62
28
|
endpoints?: PluvIOEndpoints;
|
|
63
29
|
};
|
|
64
|
-
authorize: {
|
|
65
|
-
user: InputZodLike<TUser>;
|
|
66
|
-
};
|
|
67
30
|
basePath: string;
|
|
68
31
|
publicKey: string;
|
|
69
32
|
secretKey: string;
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
33
|
+
webhookSecret?: string;
|
|
34
|
+
}
|
|
35
|
+
declare class PluvPlatform extends AbstractPlatform<any, {}, {}, {
|
|
36
|
+
authorize: {
|
|
37
|
+
required: false;
|
|
38
|
+
secret: false;
|
|
39
|
+
};
|
|
40
|
+
handleMode: "fetch";
|
|
41
|
+
registrationMode: "attached";
|
|
42
|
+
requireAuth: true;
|
|
43
|
+
listeners: {
|
|
44
|
+
onRoomDeleted: true;
|
|
45
|
+
onRoomMessage: false;
|
|
46
|
+
onStorageUpdated: false;
|
|
47
|
+
onUserConnected: true;
|
|
48
|
+
onUserDisconnected: true;
|
|
49
|
+
};
|
|
50
|
+
}> {
|
|
51
|
+
readonly _config: {
|
|
52
|
+
authorize: {
|
|
53
|
+
required: false;
|
|
54
|
+
secret: false;
|
|
55
|
+
};
|
|
56
|
+
handleMode: "fetch";
|
|
57
|
+
registrationMode: "attached";
|
|
58
|
+
requireAuth: true;
|
|
59
|
+
listeners: {
|
|
60
|
+
onRoomDeleted: true;
|
|
61
|
+
onRoomMessage: false;
|
|
62
|
+
onStorageUpdated: false;
|
|
63
|
+
onUserConnected: true;
|
|
64
|
+
onUserDisconnected: true;
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
readonly _name = "platformPluv";
|
|
68
|
+
private _authorize;
|
|
73
69
|
private readonly _basePath;
|
|
74
70
|
private readonly _endpoints;
|
|
75
|
-
private
|
|
76
|
-
private
|
|
71
|
+
private _getInitialStorage?;
|
|
72
|
+
private _listeners?;
|
|
77
73
|
private readonly _publicKey;
|
|
78
74
|
private readonly _secretKey;
|
|
79
75
|
private readonly _webhookSecret?;
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
76
|
+
_createToken: (params: JWTEncodeParams<any, any>) => Promise<string>;
|
|
77
|
+
constructor(params: PluvPlatformConfig);
|
|
78
|
+
acceptWebSocket(webSocket: AbstractWebSocket): Promise<void>;
|
|
79
|
+
convertWebSocket(webSocket: any, config: ConvertWebSocketConfig): AbstractWebSocket;
|
|
80
|
+
getLastPing(webSocket: AbstractWebSocket): number | null;
|
|
81
|
+
getSerializedState(webSocket: any): WebSocketSerializedState | null;
|
|
82
|
+
getSessionId(webSocket: any): string | null;
|
|
83
|
+
getWebSockets(): readonly any[];
|
|
84
|
+
initialize(config: AbstractPlatformConfig<{}>): this;
|
|
85
|
+
parseData(data: string | ArrayBuffer): Record<string, any>;
|
|
86
|
+
randomUUID(): string;
|
|
87
|
+
setSerializedState(webSocket: AbstractWebSocket, state: WebSocketSerializedState): void;
|
|
88
|
+
validateConfig(config: any): void;
|
|
93
89
|
private _webhooks;
|
|
94
|
-
constructor(options: PluvIOConfig<TUser>);
|
|
95
|
-
createToken(params: JWTEncodeParams<TUser, PluvPlatform>): Promise<string>;
|
|
96
90
|
}
|
|
97
91
|
|
|
98
|
-
declare const
|
|
99
|
-
|
|
100
|
-
declare const ZodEvent: z.ZodDiscriminatedUnion<"event", [z.ZodObject<{
|
|
101
|
-
event: z.ZodLiteral<"initial-storage">;
|
|
102
|
-
data: z.ZodObject<{
|
|
103
|
-
room: z.ZodNullable<z.ZodString>;
|
|
104
|
-
}, "strip", z.ZodTypeAny, {
|
|
105
|
-
room: string | null;
|
|
106
|
-
}, {
|
|
107
|
-
room: string | null;
|
|
108
|
-
}>;
|
|
109
|
-
}, "strip", z.ZodTypeAny, {
|
|
110
|
-
event: "initial-storage";
|
|
111
|
-
data: {
|
|
112
|
-
room: string | null;
|
|
113
|
-
};
|
|
114
|
-
}, {
|
|
115
|
-
event: "initial-storage";
|
|
116
|
-
data: {
|
|
117
|
-
room: string | null;
|
|
118
|
-
};
|
|
119
|
-
}>, z.ZodObject<{
|
|
120
|
-
event: z.ZodLiteral<"room-deleted">;
|
|
121
|
-
data: z.ZodObject<{
|
|
122
|
-
room: z.ZodString;
|
|
123
|
-
storage: z.ZodNullable<z.ZodString>;
|
|
124
|
-
}, "strip", z.ZodTypeAny, {
|
|
125
|
-
room: string;
|
|
126
|
-
storage: string | null;
|
|
127
|
-
}, {
|
|
128
|
-
room: string;
|
|
129
|
-
storage: string | null;
|
|
130
|
-
}>;
|
|
131
|
-
}, "strip", z.ZodTypeAny, {
|
|
132
|
-
event: "room-deleted";
|
|
133
|
-
data: {
|
|
134
|
-
room: string;
|
|
135
|
-
storage: string | null;
|
|
136
|
-
};
|
|
137
|
-
}, {
|
|
138
|
-
event: "room-deleted";
|
|
139
|
-
data: {
|
|
140
|
-
room: string;
|
|
141
|
-
storage: string | null;
|
|
142
|
-
};
|
|
143
|
-
}>, z.ZodObject<{
|
|
144
|
-
event: z.ZodLiteral<"user-connected">;
|
|
145
|
-
data: z.ZodObject<{
|
|
146
|
-
room: z.ZodString;
|
|
147
|
-
storage: z.ZodNullable<z.ZodString>;
|
|
148
|
-
user: z.ZodObject<{
|
|
149
|
-
id: z.ZodString;
|
|
150
|
-
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
151
|
-
id: z.ZodString;
|
|
152
|
-
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
153
|
-
id: z.ZodString;
|
|
154
|
-
}, z.ZodTypeAny, "passthrough">>;
|
|
155
|
-
}, "strip", z.ZodTypeAny, {
|
|
156
|
-
room: string;
|
|
157
|
-
storage: string | null;
|
|
158
|
-
user: {
|
|
159
|
-
id: string;
|
|
160
|
-
} & {
|
|
161
|
-
[k: string]: unknown;
|
|
162
|
-
};
|
|
163
|
-
}, {
|
|
164
|
-
room: string;
|
|
165
|
-
storage: string | null;
|
|
166
|
-
user: {
|
|
167
|
-
id: string;
|
|
168
|
-
} & {
|
|
169
|
-
[k: string]: unknown;
|
|
170
|
-
};
|
|
171
|
-
}>;
|
|
172
|
-
}, "strip", z.ZodTypeAny, {
|
|
173
|
-
event: "user-connected";
|
|
174
|
-
data: {
|
|
175
|
-
room: string;
|
|
176
|
-
storage: string | null;
|
|
177
|
-
user: {
|
|
178
|
-
id: string;
|
|
179
|
-
} & {
|
|
180
|
-
[k: string]: unknown;
|
|
181
|
-
};
|
|
182
|
-
};
|
|
183
|
-
}, {
|
|
184
|
-
event: "user-connected";
|
|
185
|
-
data: {
|
|
186
|
-
room: string;
|
|
187
|
-
storage: string | null;
|
|
188
|
-
user: {
|
|
189
|
-
id: string;
|
|
190
|
-
} & {
|
|
191
|
-
[k: string]: unknown;
|
|
192
|
-
};
|
|
193
|
-
};
|
|
194
|
-
}>, z.ZodObject<{
|
|
195
|
-
event: z.ZodLiteral<"user-disconnected">;
|
|
196
|
-
data: z.ZodObject<{
|
|
197
|
-
room: z.ZodString;
|
|
198
|
-
storage: z.ZodNullable<z.ZodString>;
|
|
199
|
-
user: z.ZodObject<{
|
|
200
|
-
id: z.ZodString;
|
|
201
|
-
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
202
|
-
id: z.ZodString;
|
|
203
|
-
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
204
|
-
id: z.ZodString;
|
|
205
|
-
}, z.ZodTypeAny, "passthrough">>;
|
|
206
|
-
}, "strip", z.ZodTypeAny, {
|
|
207
|
-
room: string;
|
|
208
|
-
storage: string | null;
|
|
209
|
-
user: {
|
|
210
|
-
id: string;
|
|
211
|
-
} & {
|
|
212
|
-
[k: string]: unknown;
|
|
213
|
-
};
|
|
214
|
-
}, {
|
|
215
|
-
room: string;
|
|
216
|
-
storage: string | null;
|
|
217
|
-
user: {
|
|
218
|
-
id: string;
|
|
219
|
-
} & {
|
|
220
|
-
[k: string]: unknown;
|
|
221
|
-
};
|
|
222
|
-
}>;
|
|
223
|
-
}, "strip", z.ZodTypeAny, {
|
|
224
|
-
event: "user-disconnected";
|
|
225
|
-
data: {
|
|
226
|
-
room: string;
|
|
227
|
-
storage: string | null;
|
|
228
|
-
user: {
|
|
229
|
-
id: string;
|
|
230
|
-
} & {
|
|
231
|
-
[k: string]: unknown;
|
|
232
|
-
};
|
|
233
|
-
};
|
|
234
|
-
}, {
|
|
235
|
-
event: "user-disconnected";
|
|
236
|
-
data: {
|
|
237
|
-
room: string;
|
|
238
|
-
storage: string | null;
|
|
239
|
-
user: {
|
|
240
|
-
id: string;
|
|
241
|
-
} & {
|
|
242
|
-
[k: string]: unknown;
|
|
243
|
-
};
|
|
244
|
-
};
|
|
245
|
-
}>]>;
|
|
92
|
+
declare const platformPluv: (config: PluvPlatformConfig) => PluvPlatform;
|
|
246
93
|
|
|
247
|
-
export {
|
|
94
|
+
export { type PluvIOEndpoints, PluvPlatform, type RoomDeletedMessageEventData, type UserConnectedEventData, type UserDisconnectedEventData, platformPluv };
|