@pluv/io 0.34.1 → 0.35.1
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 +9 -9
- package/CHANGELOG.md +55 -0
- package/dist/index.d.mts +38 -43
- package/dist/index.d.ts +38 -43
- package/dist/index.js +9 -4
- package/dist/index.mjs +9 -4
- package/package.json +6 -6
- package/src/AbstractWebSocket.ts +4 -3
- package/src/IORoom.ts +21 -10
- package/src/PluvIO.ts +11 -15
- package/src/PluvProcedure.ts +2 -2
- package/src/PluvRouter.ts +3 -3
- package/src/PluvServer.ts +14 -11
- package/src/authorize.ts +2 -2
- package/src/createIO.ts +7 -23
- package/src/types.ts +15 -23
- package/src/version.generated.ts +1 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
|
|
2
|
-
> @pluv/io@0.
|
|
2
|
+
> @pluv/io@0.35.1 build /home/runner/work/pluv/pluv/packages/io
|
|
3
3
|
> pnpm run version && tsup src/index.ts --format esm,cjs --dts
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
> @pluv/io@0.
|
|
6
|
+
> @pluv/io@0.35.1 version /home/runner/work/pluv/pluv/packages/io
|
|
7
7
|
> genversion ./src/version.generated.ts --esm
|
|
8
8
|
|
|
9
9
|
[34mCLI[39m Building entry: src/index.ts
|
|
@@ -12,11 +12,11 @@
|
|
|
12
12
|
[34mCLI[39m Target: es6
|
|
13
13
|
[34mESM[39m Build start
|
|
14
14
|
[34mCJS[39m Build start
|
|
15
|
-
[32mCJS[39m [1mdist/index.js [22m[32m45.
|
|
16
|
-
[32mCJS[39m ⚡️ Build success in
|
|
17
|
-
[32mESM[39m [1mdist/index.mjs [22m[32m43.
|
|
18
|
-
[32mESM[39m ⚡️ Build success in
|
|
15
|
+
[32mCJS[39m [1mdist/index.js [22m[32m45.71 KB[39m
|
|
16
|
+
[32mCJS[39m ⚡️ Build success in 159ms
|
|
17
|
+
[32mESM[39m [1mdist/index.mjs [22m[32m43.53 KB[39m
|
|
18
|
+
[32mESM[39m ⚡️ Build success in 174ms
|
|
19
19
|
[34mDTS[39m Build start
|
|
20
|
-
[32mDTS[39m ⚡️ Build success in
|
|
21
|
-
[32mDTS[39m [1mdist/index.d.mts [22m[32m29.
|
|
22
|
-
[32mDTS[39m [1mdist/index.d.ts [22m[32m29.
|
|
20
|
+
[32mDTS[39m ⚡️ Build success in 2552ms
|
|
21
|
+
[32mDTS[39m [1mdist/index.d.mts [22m[32m29.57 KB[39m
|
|
22
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m29.57 KB[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,60 @@
|
|
|
1
1
|
# @pluv/io
|
|
2
2
|
|
|
3
|
+
## 0.35.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- @pluv/crdt@0.35.1
|
|
8
|
+
- @pluv/types@0.35.1
|
|
9
|
+
|
|
10
|
+
## 0.35.0
|
|
11
|
+
|
|
12
|
+
### Minor Changes
|
|
13
|
+
|
|
14
|
+
- c9073ad: **BREAKING**
|
|
15
|
+
|
|
16
|
+
Removed the `required` property on the `authorize` config when creating a `PluvIO` instance. When `authorize` is provided, the session will be required to be authorized.
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
// Before
|
|
20
|
+
import { z } from "zod";
|
|
21
|
+
|
|
22
|
+
const io = createIO({
|
|
23
|
+
// ...
|
|
24
|
+
authorize: {
|
|
25
|
+
// Previously required: true to force all users to authorize
|
|
26
|
+
required: true,
|
|
27
|
+
user: z.object({
|
|
28
|
+
id: z.string(),
|
|
29
|
+
name: z.string(),
|
|
30
|
+
}),
|
|
31
|
+
secret: "sk_...",
|
|
32
|
+
},
|
|
33
|
+
// ...
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
// After
|
|
37
|
+
|
|
38
|
+
const io = createIO({
|
|
39
|
+
// ...
|
|
40
|
+
authorize: {
|
|
41
|
+
// No more `required` property. Now automatically applied always if
|
|
42
|
+
// `authorize` prop is provided to `createIO`
|
|
43
|
+
user: z.object({
|
|
44
|
+
id: z.string(),
|
|
45
|
+
name: z.string(),
|
|
46
|
+
}),
|
|
47
|
+
secret: "sk_...",
|
|
48
|
+
},
|
|
49
|
+
// ...
|
|
50
|
+
});
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Patch Changes
|
|
54
|
+
|
|
55
|
+
- @pluv/crdt@0.35.0
|
|
56
|
+
- @pluv/types@0.35.0
|
|
57
|
+
|
|
3
58
|
## 0.34.1
|
|
4
59
|
|
|
5
60
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { JsonObject, MaybePromise, IOAuthorize, IOEventMessage, EventRecord, InputZodLike, ProcedureLike, IORouterLike,
|
|
1
|
+
import { JsonObject, MaybePromise, IOAuthorize, IOEventMessage, EventRecord, InputZodLike, ProcedureLike, IORouterLike, InferIOAuthorizeUser, Id, Maybe, BaseUser, UndefinedProps, InferEventMessage, InferEventsOutput, IOLike, InferIOOutput, InferIOInput, InferIOAuthorize } from '@pluv/types';
|
|
2
2
|
export { BaseUser, EventMessage, EventRecord, IOEventMessage } from '@pluv/types';
|
|
3
3
|
import { AbstractCrdtDocFactory, AbstractCrdtDoc } from '@pluv/crdt';
|
|
4
4
|
|
|
@@ -77,18 +77,18 @@ declare abstract class AbstractWebSocket<TWebSocket = any> {
|
|
|
77
77
|
abstract close(code?: number | undefined, reason?: string | undefined): void;
|
|
78
78
|
abstract send(message: ArrayBuffer | ArrayBufferView | string): void;
|
|
79
79
|
abstract terminate(): void;
|
|
80
|
-
getSession<TAuthorize extends IOAuthorize<any, any
|
|
80
|
+
getSession<TAuthorize extends IOAuthorize<any, any> | null>(): Promise<WebSocketSession<TAuthorize>>;
|
|
81
81
|
handleError(params: AbstractWebSocketHandleErrorParams): void;
|
|
82
82
|
sendMessage<TMessage extends IOEventMessage<any> = IOEventMessage<any>>(data: TMessage): void;
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
-
interface PluvProcedureConfig<TPlatform extends AbstractPlatform<any>, TAuthorize extends IOAuthorize<any,
|
|
85
|
+
interface PluvProcedureConfig<TPlatform extends AbstractPlatform<any>, TAuthorize extends IOAuthorize<any, InferInitContextType<TPlatform>> | null, TContext extends Record<string, any>, TInput extends JsonObject = {}, TOutput extends EventRecord<string, any> = {}> {
|
|
86
86
|
broadcast?: EventResolver<"broadcast", TPlatform, TAuthorize, TContext, TInput, Partial<TOutput>> | null;
|
|
87
87
|
input?: InputZodLike<TInput>;
|
|
88
88
|
self?: EventResolver<"self", TPlatform, TAuthorize, TContext, TInput, Partial<TOutput>> | null;
|
|
89
89
|
sync?: EventResolver<"sync", TPlatform, TAuthorize, TContext, TInput, Partial<TOutput>> | null;
|
|
90
90
|
}
|
|
91
|
-
declare class PluvProcedure<TPlatform extends AbstractPlatform<any>, TAuthorize extends IOAuthorize<any,
|
|
91
|
+
declare class PluvProcedure<TPlatform extends AbstractPlatform<any>, TAuthorize extends IOAuthorize<any, InferInitContextType<TPlatform>> | null, TContext extends Record<string, any>, TInput extends JsonObject = {}, TOutput extends EventRecord<string, any> = {}, TFilled extends "input" | "broadcast" | "self" | "sync" | "" = ""> {
|
|
92
92
|
private _broadcast;
|
|
93
93
|
private _input;
|
|
94
94
|
private _self;
|
|
@@ -102,14 +102,14 @@ declare class PluvProcedure<TPlatform extends AbstractPlatform<any>, TAuthorize
|
|
|
102
102
|
private _resolver;
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
-
type PluvRouterEventConfig<TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>, TAuthorize extends PluvIOAuthorize<TPlatform, any,
|
|
105
|
+
type PluvRouterEventConfig<TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>, TAuthorize extends PluvIOAuthorize<TPlatform, any, InferInitContextType<TPlatform>> | null = any, TContext extends Record<string, any> = {}> = {
|
|
106
106
|
[P: string]: Pick<PluvProcedure<TPlatform, TAuthorize, TContext, any, any>, "config">;
|
|
107
107
|
};
|
|
108
|
-
type MergedRouter<TRouters extends PluvRouter<TPlatform, TAuthorize, TContext, any>[] = [], TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>, TAuthorize extends PluvIOAuthorize<TPlatform, any,
|
|
108
|
+
type MergedRouter<TRouters extends PluvRouter<TPlatform, TAuthorize, TContext, any>[] = [], TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>, TAuthorize extends PluvIOAuthorize<TPlatform, any, InferInitContextType<TPlatform>> = any, TContext extends Record<string, any> = {}, TRoot extends TRouters[0]["_defs"]["events"] = {}> = TRouters extends [
|
|
109
109
|
infer IHead extends PluvRouter<TPlatform, TAuthorize, TContext, any>,
|
|
110
110
|
...infer ITail extends PluvRouter<TPlatform, TAuthorize, TContext, any>[]
|
|
111
111
|
] ? MergedRouter<ITail, TPlatform, TAuthorize, TContext, TRoot & IHead["_defs"]["events"]> : PluvRouter<TPlatform, TAuthorize, TContext, TRoot>;
|
|
112
|
-
declare class PluvRouter<TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>, TAuthorize extends PluvIOAuthorize<TPlatform, any,
|
|
112
|
+
declare class PluvRouter<TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>, TAuthorize extends PluvIOAuthorize<TPlatform, any, InferInitContextType<TPlatform>> | null = any, TContext extends Record<string, any> = {}, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext> = {}> implements IORouterLike<TEvents> {
|
|
113
113
|
readonly _defs: {
|
|
114
114
|
events: TEvents;
|
|
115
115
|
};
|
|
@@ -128,8 +128,8 @@ interface CrdtLibraryType {
|
|
|
128
128
|
kind: "loro" | "yjs";
|
|
129
129
|
}
|
|
130
130
|
type EventResolverKind = "broadcast" | "self" | "sync";
|
|
131
|
-
type EventResolver<TKind extends EventResolverKind = EventResolverKind, TPlatform extends AbstractPlatform = AbstractPlatform, TAuthorize extends IOAuthorize<any,
|
|
132
|
-
interface EventResolverContext<TKind extends EventResolverKind = EventResolverKind, TPlatform extends AbstractPlatform = AbstractPlatform, TAuthorize extends IOAuthorize<any,
|
|
131
|
+
type EventResolver<TKind extends EventResolverKind = EventResolverKind, TPlatform extends AbstractPlatform = AbstractPlatform, TAuthorize extends IOAuthorize<any, InferInitContextType<TPlatform>> | null = null, TContext extends Record<string, any> = {}, TInput extends JsonObject = {}, TOutput extends EventRecord<string, any> = {}> = (data: TInput, context: EventResolverContext<TKind, TPlatform, TAuthorize, TContext>) => MaybePromise<TOutput | void>;
|
|
132
|
+
interface EventResolverContext<TKind extends EventResolverKind = EventResolverKind, TPlatform extends AbstractPlatform = AbstractPlatform, TAuthorize extends IOAuthorize<any, InferInitContextType<TPlatform>> | null = null, TContext extends Record<string, any> = {}> {
|
|
133
133
|
context: TContext;
|
|
134
134
|
doc: AbstractCrdtDoc<any>;
|
|
135
135
|
room: string;
|
|
@@ -153,7 +153,7 @@ interface WebSocketSerializedState {
|
|
|
153
153
|
room: string;
|
|
154
154
|
timers: WebSocketSessionTimers;
|
|
155
155
|
}
|
|
156
|
-
type WebSocketSession<TAuthorize extends IOAuthorize<any, any
|
|
156
|
+
type WebSocketSession<TAuthorize extends IOAuthorize<any, any> | null = null> = WebSocketSerializedState & {
|
|
157
157
|
id: string;
|
|
158
158
|
user: InferIOAuthorizeUser<TAuthorize>;
|
|
159
159
|
webSocket: AbstractWebSocket;
|
|
@@ -173,7 +173,6 @@ type HandleMode = "io" | "fetch";
|
|
|
173
173
|
type WebSocketRegistrationMode = "attached" | "detached";
|
|
174
174
|
interface PlatformConfig {
|
|
175
175
|
authorize: {
|
|
176
|
-
required?: boolean;
|
|
177
176
|
secret?: boolean;
|
|
178
177
|
};
|
|
179
178
|
requireAuth?: boolean;
|
|
@@ -187,21 +186,20 @@ interface PlatformConfig {
|
|
|
187
186
|
onUserDisconnected?: boolean;
|
|
188
187
|
};
|
|
189
188
|
}
|
|
190
|
-
type ResolvedPluvIOAuthorize<TPlatform extends AbstractPlatform<any, any, any, any>, TUser extends BaseUser = any
|
|
189
|
+
type ResolvedPluvIOAuthorize<TPlatform extends AbstractPlatform<any, any, any, any>, TUser extends BaseUser = any> = {
|
|
191
190
|
user: InputZodLike<TUser>;
|
|
192
|
-
required?: TRequired;
|
|
193
191
|
} & UndefinedProps<{
|
|
194
192
|
secret?: string;
|
|
195
193
|
}, Exclude<"secret", InferPlatformAuthorizeProperties<TPlatform>>>;
|
|
196
|
-
type PluvIOAuthorize<TPlatform extends AbstractPlatform<any, any, any, any>, TUser extends BaseUser = any,
|
|
197
|
-
type BasePluvIOListeners<TPlatform extends AbstractPlatform<any, any, any, any>, TAuthorize extends PluvIOAuthorize<TPlatform, any,
|
|
194
|
+
type PluvIOAuthorize<TPlatform extends AbstractPlatform<any, any, any, any>, TUser extends BaseUser = any, TContext extends Record<string, unknown> = {}> = ResolvedPluvIOAuthorize<TPlatform, TUser> | ((context: TContext) => ResolvedPluvIOAuthorize<TPlatform, TUser>);
|
|
195
|
+
type BasePluvIOListeners<TPlatform extends AbstractPlatform<any, any, any, any>, TAuthorize extends PluvIOAuthorize<TPlatform, any, InferInitContextType<TPlatform>> | null, TContext extends Record<string, any>, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext>> = {
|
|
198
196
|
onRoomDeleted: (event: IORoomListenerEvent<TContext>) => void;
|
|
199
197
|
onRoomMessage: (event: IORoomMessageEvent<TPlatform, TAuthorize, TContext, TEvents>) => void;
|
|
200
198
|
onStorageUpdated: (event: IOStorageUpdatedEvent<TPlatform, TAuthorize, TContext>) => void;
|
|
201
199
|
onUserConnected: (event: IOUserConnectedEvent<TPlatform, TAuthorize, TContext>) => void;
|
|
202
200
|
onUserDisconnected: (event: IOUserDisconnectedEvent<TPlatform, TAuthorize, TContext>) => void;
|
|
203
201
|
};
|
|
204
|
-
type PluvIOListeners<TPlatform extends AbstractPlatform<any, any, any, any>, TAuthorize extends PluvIOAuthorize<TPlatform, any,
|
|
202
|
+
type PluvIOListeners<TPlatform extends AbstractPlatform<any, any, any, any>, TAuthorize extends PluvIOAuthorize<TPlatform, any, InferInitContextType<TPlatform>> | null, TContext extends Record<string, any>, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext>> = UndefinedProps<BasePluvIOListeners<TPlatform, TAuthorize, TContext, TEvents>, Exclude<keyof BasePluvIOListeners<TPlatform, TAuthorize, TContext, TEvents>, InferPlatformListeners<TPlatform>>>;
|
|
205
203
|
type InferPlatformConfig<TPlatform extends AbstractPlatform<any, any, any, any>> = TPlatform extends AbstractPlatform<any, any, any, infer IConfig> ? IConfig : never;
|
|
206
204
|
type InferPlatformAuthorizeProperties<TPlatform extends AbstractPlatform<any, any, any, any>> = keyof {
|
|
207
205
|
[P in keyof PlatformConfig["authorize"] as InferPlatformConfig<TPlatform>["authorize"][P] extends true | undefined ? P : never]: true;
|
|
@@ -214,20 +212,20 @@ type IORoomListenerEvent<TContext extends Record<string, any>> = {
|
|
|
214
212
|
encodedState: string | null;
|
|
215
213
|
room: string;
|
|
216
214
|
};
|
|
217
|
-
type IORoomMessageEvent<TPlatform extends AbstractPlatform<any>, TAuthorize extends PluvIOAuthorize<TPlatform, any,
|
|
215
|
+
type IORoomMessageEvent<TPlatform extends AbstractPlatform<any>, TAuthorize extends PluvIOAuthorize<TPlatform, any, InferInitContextType<TPlatform>> | null, TContext extends Record<string, any>, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext>> = IORoomListenerEvent<TContext> & {
|
|
218
216
|
message: InferEventMessage<InferEventsOutput<TEvents>, keyof InferEventsOutput<TEvents>>;
|
|
219
217
|
user?: InferIOAuthorizeUser<TAuthorize>;
|
|
220
218
|
webSocket?: InferPlatformWebSocketSource<TPlatform>;
|
|
221
219
|
};
|
|
222
|
-
type IOStorageUpdatedEvent<TPlatform extends AbstractPlatform<any>, TAuthorize extends IOAuthorize<any,
|
|
220
|
+
type IOStorageUpdatedEvent<TPlatform extends AbstractPlatform<any>, TAuthorize extends IOAuthorize<any, InferInitContextType<TPlatform>> | null, TContext extends Record<string, any>> = IORoomListenerEvent<TContext> & {
|
|
223
221
|
user?: InferIOAuthorizeUser<TAuthorize>;
|
|
224
222
|
webSocket?: InferPlatformWebSocketSource<TPlatform>;
|
|
225
223
|
};
|
|
226
|
-
type IOUserConnectedEvent<TPlatform extends AbstractPlatform<any>, TAuthorize extends IOAuthorize<any,
|
|
224
|
+
type IOUserConnectedEvent<TPlatform extends AbstractPlatform<any>, TAuthorize extends IOAuthorize<any, InferInitContextType<TPlatform>> | null, TContext extends Record<string, any>> = IORoomListenerEvent<TContext> & {
|
|
227
225
|
user?: InferIOAuthorizeUser<TAuthorize>;
|
|
228
226
|
webSocket?: InferPlatformWebSocketSource<TPlatform>;
|
|
229
227
|
};
|
|
230
|
-
type IOUserDisconnectedEvent<TPlatform extends AbstractPlatform<any>, TAuthorize extends IOAuthorize<any,
|
|
228
|
+
type IOUserDisconnectedEvent<TPlatform extends AbstractPlatform<any>, TAuthorize extends IOAuthorize<any, InferInitContextType<TPlatform>> | null, TContext extends Record<string, any>> = IORoomListenerEvent<TContext> & {
|
|
231
229
|
user?: InferIOAuthorizeUser<TAuthorize>;
|
|
232
230
|
};
|
|
233
231
|
type WebSocketType<TPlatform extends AbstractPlatform> = InferPlatformWebSocketType<TPlatform> | InferPlatformWebSocketSource<TPlatform>;
|
|
@@ -246,10 +244,10 @@ interface JWT<TUser extends BaseUser> {
|
|
|
246
244
|
sub: string;
|
|
247
245
|
user: TUser;
|
|
248
246
|
}
|
|
249
|
-
type JWTEncodeParams<TUser extends BaseUser, TPlatform extends AbstractPlatform> = {
|
|
247
|
+
type JWTEncodeParams<TUser extends BaseUser | null, TPlatform extends AbstractPlatform> = {
|
|
250
248
|
maxAge?: number;
|
|
251
249
|
room: string;
|
|
252
|
-
user: TUser;
|
|
250
|
+
user: TUser extends BaseUser ? TUser : "Error: Cannot create token without authorization!";
|
|
253
251
|
} & InferInitContextType<TPlatform>;
|
|
254
252
|
interface AuthorizeParams {
|
|
255
253
|
platform: AbstractPlatform;
|
|
@@ -301,7 +299,7 @@ declare abstract class AbstractPlatform<TWebSocket extends AbstractWebSocket = A
|
|
|
301
299
|
protected _initialize(): this;
|
|
302
300
|
}
|
|
303
301
|
|
|
304
|
-
interface IORoomListeners<TPlatform extends AbstractPlatform<any>, TAuthorize extends PluvIOAuthorize<TPlatform, any,
|
|
302
|
+
interface IORoomListeners<TPlatform extends AbstractPlatform<any>, TAuthorize extends PluvIOAuthorize<TPlatform, any, InferInitContextType<TPlatform>> | null, TContext extends Record<string, any>, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext>> {
|
|
305
303
|
onDestroy: (event: IORoomListenerEvent<TContext>) => void;
|
|
306
304
|
onMessage: (event: IORoomMessageEvent<TPlatform, TAuthorize, TContext, TEvents>) => void;
|
|
307
305
|
onUserConnected: (event: IOUserConnectedEvent<TPlatform, TAuthorize, TContext>) => void;
|
|
@@ -310,7 +308,7 @@ interface IORoomListeners<TPlatform extends AbstractPlatform<any>, TAuthorize ex
|
|
|
310
308
|
type BroadcastProxy<TIO extends IORoom<any, any, any, any>> = (<TEvent extends keyof InferIOInput<TIO>>(event: TEvent, data: Id<InferIOInput<TIO>[TEvent]>) => Promise<void>) & {
|
|
311
309
|
[event in keyof InferIOInput<TIO>]: (data: Id<InferIOInput<TIO>>[event]) => Promise<void>;
|
|
312
310
|
};
|
|
313
|
-
type IORoomConfig<TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>, TAuthorize extends PluvIOAuthorize<TPlatform, any,
|
|
311
|
+
type IORoomConfig<TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>, TAuthorize extends PluvIOAuthorize<TPlatform, any, InferInitContextType<TPlatform>> | null = any, TContext extends Record<string, any> = {}, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext> = {}> = Partial<IORoomListeners<TPlatform, TAuthorize, TContext, TEvents>> & {
|
|
314
312
|
authorize?: TAuthorize;
|
|
315
313
|
context: TContext;
|
|
316
314
|
crdt?: {
|
|
@@ -324,7 +322,7 @@ type IORoomConfig<TPlatform extends AbstractPlatform<any> = AbstractPlatform<any
|
|
|
324
322
|
type WebsocketRegisterConfig<TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>> = {
|
|
325
323
|
token?: string | null;
|
|
326
324
|
} & InferInitContextType<TPlatform>;
|
|
327
|
-
declare class IORoom<TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>, TAuthorize extends PluvIOAuthorize<TPlatform, any,
|
|
325
|
+
declare class IORoom<TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>, TAuthorize extends PluvIOAuthorize<TPlatform, any, InferInitContextType<TPlatform>> | null = null, TContext extends Record<string, any> = {}, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext> = {}> implements IOLike<TAuthorize, TEvents> {
|
|
328
326
|
readonly id: string;
|
|
329
327
|
private _doc;
|
|
330
328
|
private _uninitialize;
|
|
@@ -342,7 +340,7 @@ declare class IORoom<TPlatform extends AbstractPlatform<any> = AbstractPlatform<
|
|
|
342
340
|
* @deprecated Internal use only. Changes to this will never be marked as breaking.
|
|
343
341
|
*/
|
|
344
342
|
get _defs(): {
|
|
345
|
-
authorize: TAuthorize
|
|
343
|
+
authorize: TAuthorize;
|
|
346
344
|
context: TContext;
|
|
347
345
|
events: TEvents;
|
|
348
346
|
platform: TPlatform;
|
|
@@ -392,7 +390,7 @@ declare class IORoom<TPlatform extends AbstractPlatform<any> = AbstractPlatform<
|
|
|
392
390
|
}
|
|
393
391
|
|
|
394
392
|
type InferIORoom<TServer extends PluvServer<any, any, any, any>> = TServer extends PluvServer<infer IPlatform, infer IAuthorize, infer IContext, infer IEvents> ? IORoom<IPlatform, IAuthorize, IContext, IEvents> : never;
|
|
395
|
-
type PluvServerConfig<TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>, TAuthorize extends PluvIOAuthorize<TPlatform, any,
|
|
393
|
+
type PluvServerConfig<TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>, TAuthorize extends PluvIOAuthorize<TPlatform, any, InferInitContextType<TPlatform>> | null = any, TContext extends Record<string, any> = {}, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext> = {}> = Partial<PluvIOListeners<TPlatform, TAuthorize, TContext, TEvents>> & {
|
|
396
394
|
authorize?: TAuthorize;
|
|
397
395
|
context?: PluvContext<TPlatform, TContext>;
|
|
398
396
|
crdt?: {
|
|
@@ -403,11 +401,11 @@ type PluvServerConfig<TPlatform extends AbstractPlatform<any> = AbstractPlatform
|
|
|
403
401
|
platform: TPlatform;
|
|
404
402
|
router?: PluvRouter<TPlatform, TAuthorize, TContext, TEvents>;
|
|
405
403
|
};
|
|
406
|
-
type BaseCreateRoomOptions<TPlatform extends AbstractPlatform<any>, TAuthorize extends PluvIOAuthorize<TPlatform, any,
|
|
404
|
+
type BaseCreateRoomOptions<TPlatform extends AbstractPlatform<any>, TAuthorize extends PluvIOAuthorize<TPlatform, any, InferInitContextType<TPlatform>> | null, TContext extends Record<string, any>, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext>> = Partial<IORoomListeners<TPlatform, TAuthorize, TContext, TEvents>> & {
|
|
407
405
|
debug?: boolean;
|
|
408
406
|
};
|
|
409
|
-
type CreateRoomOptions<TPlatform extends AbstractPlatform<any>, TAuthorize extends PluvIOAuthorize<TPlatform, any,
|
|
410
|
-
declare class PluvServer<TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>, TAuthorize extends PluvIOAuthorize<TPlatform, any,
|
|
407
|
+
type CreateRoomOptions<TPlatform extends AbstractPlatform<any>, TAuthorize extends PluvIOAuthorize<TPlatform, any, InferInitContextType<TPlatform>> | null, TContext extends Record<string, any>, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext>> = keyof InferRoomContextType<TPlatform> extends never ? [BaseCreateRoomOptions<TPlatform, TAuthorize, TContext, TEvents>] | [] : [Id<BaseCreateRoomOptions<TPlatform, TAuthorize, TContext, TEvents> & InferRoomContextType<TPlatform>>];
|
|
408
|
+
declare class PluvServer<TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>, TAuthorize extends PluvIOAuthorize<TPlatform, any, InferInitContextType<TPlatform>> | null = any, TContext extends Record<string, any> = {}, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext> = {}> implements IOLike<TAuthorize, TEvents> {
|
|
411
409
|
readonly version: string;
|
|
412
410
|
private readonly _authorize;
|
|
413
411
|
private readonly _baseRouter;
|
|
@@ -424,8 +422,8 @@ declare class PluvServer<TPlatform extends AbstractPlatform<any> = AbstractPlatf
|
|
|
424
422
|
* @deprecated Internal use only. Changes to this will never be marked as breaking.
|
|
425
423
|
*/
|
|
426
424
|
get _defs(): {
|
|
427
|
-
authorize: TAuthorize
|
|
428
|
-
context:
|
|
425
|
+
authorize: TAuthorize;
|
|
426
|
+
context: TContext;
|
|
429
427
|
events: TEvents;
|
|
430
428
|
platform: TPlatform;
|
|
431
429
|
};
|
|
@@ -438,21 +436,18 @@ declare class PluvServer<TPlatform extends AbstractPlatform<any> = AbstractPlatf
|
|
|
438
436
|
private _logDebug;
|
|
439
437
|
}
|
|
440
438
|
|
|
441
|
-
type PluvIOConfig<TPlatform extends AbstractPlatform<any>, TAuthorize extends IOAuthorize<any,
|
|
439
|
+
type PluvIOConfig<TPlatform extends AbstractPlatform<any>, TAuthorize extends IOAuthorize<any, InferInitContextType<TPlatform>> | null, TContext extends Record<string, any>> = {
|
|
440
|
+
authorize?: TAuthorize;
|
|
442
441
|
context?: PluvContext<TPlatform, TContext>;
|
|
443
442
|
crdt?: CrdtLibraryType;
|
|
444
443
|
debug?: boolean;
|
|
445
444
|
platform: TPlatform;
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
} : {
|
|
449
|
-
authorize?: TAuthorize;
|
|
450
|
-
});
|
|
451
|
-
type ServerConfig<TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>, TAuthorize extends PluvIOAuthorize<TPlatform, any, any, InferInitContextType<TPlatform>> = any, TContext extends Record<string, any> = {}, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext> = {}> = Partial<PluvIOListeners<TPlatform, TAuthorize, TContext, TEvents>> & {
|
|
445
|
+
};
|
|
446
|
+
type ServerConfig<TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>, TAuthorize extends PluvIOAuthorize<TPlatform, any, InferInitContextType<TPlatform>> | null = any, TContext extends Record<string, any> = {}, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext> = {}> = Partial<PluvIOListeners<TPlatform, TAuthorize, TContext, TEvents>> & {
|
|
452
447
|
getInitialStorage?: GetInitialStorageFn<TContext>;
|
|
453
448
|
router?: PluvRouter<TPlatform, TAuthorize, TContext, TEvents>;
|
|
454
449
|
};
|
|
455
|
-
declare class PluvIO<TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>, TAuthorize extends PluvIOAuthorize<TPlatform, any,
|
|
450
|
+
declare class PluvIO<TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>, TAuthorize extends PluvIOAuthorize<TPlatform, any, InferInitContextType<TPlatform>> | null = any, TContext extends Record<string, any> = {}> {
|
|
456
451
|
readonly version: string;
|
|
457
452
|
private readonly _authorize;
|
|
458
453
|
private readonly _context;
|
|
@@ -468,13 +463,13 @@ declare class PluvIO<TPlatform extends AbstractPlatform<any> = AbstractPlatform<
|
|
|
468
463
|
private _getIOAuthorize;
|
|
469
464
|
}
|
|
470
465
|
|
|
471
|
-
type CreateIOParams<TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>, TContext extends Record<string, any> = {},
|
|
472
|
-
authorize?:
|
|
466
|
+
type CreateIOParams<TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>, TContext extends Record<string, any> = {}, TAuthorize extends PluvIOAuthorize<TPlatform, any, InferInitContextType<TPlatform>> | null = null> = {
|
|
467
|
+
authorize?: TAuthorize;
|
|
473
468
|
context?: PluvContext<TPlatform, TContext>;
|
|
474
469
|
crdt?: CrdtLibraryType;
|
|
475
470
|
debug?: boolean;
|
|
476
471
|
platform: TPlatform;
|
|
477
472
|
};
|
|
478
|
-
declare const createIO: <TPlatform extends AbstractPlatform<any> = AbstractPlatform<any, {}, {}, PlatformConfig>, TContext extends Record<string, any> = {},
|
|
473
|
+
declare const createIO: <TPlatform extends AbstractPlatform<any> = AbstractPlatform<any, {}, {}, PlatformConfig>, TContext extends Record<string, any> = {}, TAuthorize extends PluvIOAuthorize<TPlatform, any, InferInitContextType<TPlatform>> | null = null>(params: CreateIOParams<TPlatform, TContext, TAuthorize>) => PluvIO<TPlatform, TAuthorize, TContext>;
|
|
479
474
|
|
|
480
475
|
export { type AbstractCloseEvent, type AbstractErrorEvent, type AbstractEvent, type AbstractEventMap, type AbstractListener, type AbstractMessageEvent, AbstractPersistence, AbstractPlatform, type AbstractPlatformConfig, AbstractPubSub, AbstractWebSocket, type AbstractWebSocketConfig, type AbstractWebSocketHandleErrorParams, type AuthorizeModule, type AuthorizeParams, type ConvertWebSocketConfig, type CrdtLibraryType, type CreateIOParams, type CreateRoomOptions, type GetInitialStorageFn, type HandleMode, type IOPubSubEventMessage, IORoom, type IORoomListenerEvent, type IORoomMessageEvent, type IOStorageUpdatedEvent, type IOUserConnectedEvent, type IOUserDisconnectedEvent, type InferIORoom, type InferInitContextType, type InferPlatformWebSocketType, type InferRoomContextType, type JWT, type JWTEncodeParams, type MergedRouter, type PlatformConfig, PluvIO, type PluvIOConfig, type PluvIOListeners, PluvProcedure, type PluvProcedureConfig, PluvRouter, type PluvRouterEventConfig, PluvServer, type PluvServerConfig, type ServerConfig, type WebSocketRegistrationMode, type WebSocketSerializedState, type WebSocketSession, authorize, createIO };
|