@pluv/types 3.2.1 → 3.2.2

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.
@@ -1,5 +1,5 @@
1
1
 
2
- > @pluv/types@3.2.1 build /home/runner/work/pluv/pluv/packages/types
2
+ > @pluv/types@3.2.2 build /home/runner/work/pluv/pluv/packages/types
3
3
  > tsup src/index.ts --format esm,cjs --dts
4
4
 
5
5
  CLI Building entry: src/index.ts
@@ -9,10 +9,10 @@
9
9
  ESM Build start
10
10
  CJS Build start
11
11
  ESM dist/index.mjs 330.00 B
12
- ESM ⚡️ Build success in 40ms
12
+ ESM ⚡️ Build success in 39ms
13
13
  CJS dist/index.js 1.37 KB
14
- CJS ⚡️ Build success in 40ms
14
+ CJS ⚡️ Build success in 39ms
15
15
  DTS Build start
16
- DTS ⚡️ Build success in 1364ms
17
- DTS dist/index.d.mts 19.42 KB
18
- DTS dist/index.d.ts 19.42 KB
16
+ DTS ⚡️ Build success in 1405ms
17
+ DTS dist/index.d.mts 20.23 KB
18
+ DTS dist/index.d.ts 20.23 KB
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @pluv/types
2
2
 
3
+ ## 3.2.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 8665dbe: Updated types of `createClient` so that the types inferred from `createClient` are flattened and no-longer depend on `@pluv/server`.
8
+
3
9
  ## 3.2.1
4
10
 
5
11
  ## 3.2.0
package/dist/index.d.mts CHANGED
@@ -195,7 +195,9 @@ type EventRecord<TEvent extends string, TData extends JsonObject> = {
195
195
  [key in `${TEvent}`]: TData;
196
196
  };
197
197
  type GetEventMessage<T extends EventRecord<string, any>, TEvent extends keyof T> = TEvent extends string ? EventMessage<TEvent, T[TEvent]> : never;
198
- type InferIOAuthorize<TIO extends IOLike<any, any, any>> = TIO extends IOLike<infer IAuthorize, any, any> ? IAuthorize : never;
198
+ type InferIOAuthorize<TIO extends IOLike<any, any, any>> = TIO extends IOLike<infer IAuthorize, any, any> ? InferIOAuthorizeUser<IAuthorize> extends BaseUser ? {
199
+ user: InputZodLike<InferIOAuthorizeUser<IAuthorize>>;
200
+ } : null : never;
199
201
  type InferIOAuthorizeUser<TAuthorize extends IOAuthorize<any, any> | null> = TAuthorize extends IOAuthorize<infer IUser, any> ? IUser : null;
200
202
  type InputZodLike<TData extends JsonObject> = {
201
203
  parse: (data: unknown) => TData;
@@ -211,13 +213,13 @@ type IOAuthorize<TUser extends BaseUser | null = any, TContext extends Record<st
211
213
  user: InputZodLike<TUser>;
212
214
  } : null) | ((context: TContext) => TUser extends BaseUser ? {
213
215
  secret?: string;
214
- user: TUser extends BaseUser ? InputZodLike<TUser> : null;
216
+ user: InputZodLike<TUser>;
215
217
  } : null);
216
218
  type IOAuthorizeEventMessage<TIO extends IOLike> = {
217
219
  connectionId: string;
218
220
  user: InferIOAuthorizeUser<InferIOAuthorize<TIO>>;
219
221
  };
220
- type ProcedureLike<TInput extends JsonObject = {}, TOutput extends EventRecord<string, any> = {}> = {
222
+ type ProcedureLike<TInput extends Record<string, any> = {}, TOutput extends EventRecord<string, any> = {}> = {
221
223
  config: {
222
224
  broadcast?: ((data: TInput, ...args: any[]) => MaybePromise<Partial<TOutput> | void>) | null;
223
225
  input?: InputZodLike<TInput> | null;
@@ -239,11 +241,17 @@ interface IOLike<TAuthorize extends IOAuthorize<any, any> | null = null, TCrdt e
239
241
  };
240
242
  }
241
243
  type InferIOCrdtKind<TIO extends IOLike<any, any, any>> = TIO extends IOLike<any, infer ICrdt, any> ? ICrdt extends CrdtLibraryType<infer IDoc> ? IDoc : never : never;
244
+ type InferIOCrdt<TIO extends IOLike<any, any, any>> = TIO extends IOLike<any, infer ICrdt, any> ? ICrdt : never;
245
+ type InferIOEvents<TIO extends IOLike<any, any, any>> = TIO extends IOLike<any, any, infer IEvents> ? {
246
+ [P in keyof IEvents]: ProcedureLike<InferIOProcedureInput<IEvents[P]>, InferIOProcedureOutput<IEvents[P]>>;
247
+ } : never;
248
+ type InferIOProcedureInput<TProcedure extends ProcedureLike<any, any>> = TProcedure extends ProcedureLike<infer IInput, any> ? Id<IInput> : never;
249
+ type InferIOProcedureOutput<TProcedure extends ProcedureLike<any, any>> = TProcedure extends ProcedureLike<any, infer IOutput> ? Id<IOutput> : never;
242
250
  type InferEventsInput<TEvents extends Record<string, ProcedureLike<any, any>>> = {
243
- [P in keyof TEvents]: TEvents[P] extends ProcedureLike<infer IInput, any> ? IInput : never;
251
+ [P in keyof TEvents]: TEvents[P] extends ProcedureLike<infer IInput, any> ? Id<IInput> : never;
244
252
  };
245
253
  type InferEventsOutput<TEvents extends Record<string, ProcedureLike<any, any>>> = UnionToIntersection<{
246
- [P in keyof TEvents]: TEvents[P] extends ProcedureLike<any, infer IOutput> ? IOutput : never;
254
+ [P in keyof TEvents]: TEvents[P] extends ProcedureLike<any, infer IOutput> ? Id<IOutput> : never;
247
255
  }[keyof TEvents]>;
248
256
  type InferIOInput<TRouter extends IORouterLike<any>> = TRouter extends IORouterLike<infer IEvents> ? InferEventsInput<IEvents> : never;
249
257
  type InferIOOutput<TRouter extends IORouterLike<any>> = TRouter extends IORouterLike<infer IEvents> ? InferEventsOutput<IEvents> : never;
@@ -376,4 +384,4 @@ interface RoomLike<TIO extends IOLike, TDoc extends any, TPresence extends Recor
376
384
  updateMyPresence(presence: UpdateMyPresenceAction<TPresence>): void;
377
385
  }
378
386
 
379
- export { type BaseClientEventRecord, type BaseClientMessage, type BaseIOEventRecord, type BaseUser, type BroadcastProxy, ConnectionState, type Constructable, type CrdtDocFactory, type CrdtDocLike, type CrdtLibraryType, type CrdtType, type DeepPartial, type DeepWriteable, type DocApplyEncodedStateParams, type DocBatchApplyEncodedStateParams, type DocSubscribeCallbackParams, type EventMessage, type EventNotifierSubscriptionCallback, type EventProxy, type EventRecord, type GetEventMessage, type HasRequiredProperty, type IOAuthorize, type IOAuthorizeEventMessage, type IOEventMessage, type IOLike, type IORouterLike, type Id, type InferCrdtJson, type InferEventMessage, type InferEventsInput, type InferEventsOutput, type InferIOAuthorize, type InferIOAuthorizeUser, type InferIOCrdtKind, type InferIOInput, type InferIOOutput, type InputZodLike, type Json, type JsonObject, type JsonPrimitive, type Maybe, type MaybePromise, type MaybeReadonlyArray, type MergeEvents, type NonNilProps, type OptionalProps, type OtherSubscriptionCallback, type OtherSubscriptionFn, type OthersSubscriptionCallback, type OthersSubscriptionEvent, type OthersSubscriptionFn, type PluvRouterEventConfig, type ProcedureLike, type RoomEventListenerMap, type RoomLike, type Spread, type SpreadProperties, type StateNotifierSubjects, type StorageInfo, type StorageProxy, type StorageRootSubscriptionCallback, type StorageRootSubscriptionFn, StorageState, type StorageSubscriptionCallback, type StorageSubscriptionFn, type SubscribeFn, type SubscribeProxy, type SubscriptionCallback, type UndefinedProps, type UpdateMyPresenceAction, type UserInfo, type WebSocketConnection, type WebSocketState };
387
+ export { type BaseClientEventRecord, type BaseClientMessage, type BaseIOEventRecord, type BaseUser, type BroadcastProxy, ConnectionState, type Constructable, type CrdtDocFactory, type CrdtDocLike, type CrdtLibraryType, type CrdtType, type DeepPartial, type DeepWriteable, type DocApplyEncodedStateParams, type DocBatchApplyEncodedStateParams, type DocSubscribeCallbackParams, type EventMessage, type EventNotifierSubscriptionCallback, type EventProxy, type EventRecord, type GetEventMessage, type HasRequiredProperty, type IOAuthorize, type IOAuthorizeEventMessage, type IOEventMessage, type IOLike, type IORouterLike, type Id, type InferCrdtJson, type InferEventMessage, type InferEventsInput, type InferEventsOutput, type InferIOAuthorize, type InferIOAuthorizeUser, type InferIOCrdt, type InferIOCrdtKind, type InferIOEvents, type InferIOInput, type InferIOOutput, type InferIOProcedureInput, type InferIOProcedureOutput, type InputZodLike, type Json, type JsonObject, type JsonPrimitive, type Maybe, type MaybePromise, type MaybeReadonlyArray, type MergeEvents, type NonNilProps, type OptionalProps, type OtherSubscriptionCallback, type OtherSubscriptionFn, type OthersSubscriptionCallback, type OthersSubscriptionEvent, type OthersSubscriptionFn, type PluvRouterEventConfig, type ProcedureLike, type RoomEventListenerMap, type RoomLike, type Spread, type SpreadProperties, type StateNotifierSubjects, type StorageInfo, type StorageProxy, type StorageRootSubscriptionCallback, type StorageRootSubscriptionFn, StorageState, type StorageSubscriptionCallback, type StorageSubscriptionFn, type SubscribeFn, type SubscribeProxy, type SubscriptionCallback, type UndefinedProps, type UpdateMyPresenceAction, type UserInfo, type WebSocketConnection, type WebSocketState };
package/dist/index.d.ts CHANGED
@@ -195,7 +195,9 @@ type EventRecord<TEvent extends string, TData extends JsonObject> = {
195
195
  [key in `${TEvent}`]: TData;
196
196
  };
197
197
  type GetEventMessage<T extends EventRecord<string, any>, TEvent extends keyof T> = TEvent extends string ? EventMessage<TEvent, T[TEvent]> : never;
198
- type InferIOAuthorize<TIO extends IOLike<any, any, any>> = TIO extends IOLike<infer IAuthorize, any, any> ? IAuthorize : never;
198
+ type InferIOAuthorize<TIO extends IOLike<any, any, any>> = TIO extends IOLike<infer IAuthorize, any, any> ? InferIOAuthorizeUser<IAuthorize> extends BaseUser ? {
199
+ user: InputZodLike<InferIOAuthorizeUser<IAuthorize>>;
200
+ } : null : never;
199
201
  type InferIOAuthorizeUser<TAuthorize extends IOAuthorize<any, any> | null> = TAuthorize extends IOAuthorize<infer IUser, any> ? IUser : null;
200
202
  type InputZodLike<TData extends JsonObject> = {
201
203
  parse: (data: unknown) => TData;
@@ -211,13 +213,13 @@ type IOAuthorize<TUser extends BaseUser | null = any, TContext extends Record<st
211
213
  user: InputZodLike<TUser>;
212
214
  } : null) | ((context: TContext) => TUser extends BaseUser ? {
213
215
  secret?: string;
214
- user: TUser extends BaseUser ? InputZodLike<TUser> : null;
216
+ user: InputZodLike<TUser>;
215
217
  } : null);
216
218
  type IOAuthorizeEventMessage<TIO extends IOLike> = {
217
219
  connectionId: string;
218
220
  user: InferIOAuthorizeUser<InferIOAuthorize<TIO>>;
219
221
  };
220
- type ProcedureLike<TInput extends JsonObject = {}, TOutput extends EventRecord<string, any> = {}> = {
222
+ type ProcedureLike<TInput extends Record<string, any> = {}, TOutput extends EventRecord<string, any> = {}> = {
221
223
  config: {
222
224
  broadcast?: ((data: TInput, ...args: any[]) => MaybePromise<Partial<TOutput> | void>) | null;
223
225
  input?: InputZodLike<TInput> | null;
@@ -239,11 +241,17 @@ interface IOLike<TAuthorize extends IOAuthorize<any, any> | null = null, TCrdt e
239
241
  };
240
242
  }
241
243
  type InferIOCrdtKind<TIO extends IOLike<any, any, any>> = TIO extends IOLike<any, infer ICrdt, any> ? ICrdt extends CrdtLibraryType<infer IDoc> ? IDoc : never : never;
244
+ type InferIOCrdt<TIO extends IOLike<any, any, any>> = TIO extends IOLike<any, infer ICrdt, any> ? ICrdt : never;
245
+ type InferIOEvents<TIO extends IOLike<any, any, any>> = TIO extends IOLike<any, any, infer IEvents> ? {
246
+ [P in keyof IEvents]: ProcedureLike<InferIOProcedureInput<IEvents[P]>, InferIOProcedureOutput<IEvents[P]>>;
247
+ } : never;
248
+ type InferIOProcedureInput<TProcedure extends ProcedureLike<any, any>> = TProcedure extends ProcedureLike<infer IInput, any> ? Id<IInput> : never;
249
+ type InferIOProcedureOutput<TProcedure extends ProcedureLike<any, any>> = TProcedure extends ProcedureLike<any, infer IOutput> ? Id<IOutput> : never;
242
250
  type InferEventsInput<TEvents extends Record<string, ProcedureLike<any, any>>> = {
243
- [P in keyof TEvents]: TEvents[P] extends ProcedureLike<infer IInput, any> ? IInput : never;
251
+ [P in keyof TEvents]: TEvents[P] extends ProcedureLike<infer IInput, any> ? Id<IInput> : never;
244
252
  };
245
253
  type InferEventsOutput<TEvents extends Record<string, ProcedureLike<any, any>>> = UnionToIntersection<{
246
- [P in keyof TEvents]: TEvents[P] extends ProcedureLike<any, infer IOutput> ? IOutput : never;
254
+ [P in keyof TEvents]: TEvents[P] extends ProcedureLike<any, infer IOutput> ? Id<IOutput> : never;
247
255
  }[keyof TEvents]>;
248
256
  type InferIOInput<TRouter extends IORouterLike<any>> = TRouter extends IORouterLike<infer IEvents> ? InferEventsInput<IEvents> : never;
249
257
  type InferIOOutput<TRouter extends IORouterLike<any>> = TRouter extends IORouterLike<infer IEvents> ? InferEventsOutput<IEvents> : never;
@@ -376,4 +384,4 @@ interface RoomLike<TIO extends IOLike, TDoc extends any, TPresence extends Recor
376
384
  updateMyPresence(presence: UpdateMyPresenceAction<TPresence>): void;
377
385
  }
378
386
 
379
- export { type BaseClientEventRecord, type BaseClientMessage, type BaseIOEventRecord, type BaseUser, type BroadcastProxy, ConnectionState, type Constructable, type CrdtDocFactory, type CrdtDocLike, type CrdtLibraryType, type CrdtType, type DeepPartial, type DeepWriteable, type DocApplyEncodedStateParams, type DocBatchApplyEncodedStateParams, type DocSubscribeCallbackParams, type EventMessage, type EventNotifierSubscriptionCallback, type EventProxy, type EventRecord, type GetEventMessage, type HasRequiredProperty, type IOAuthorize, type IOAuthorizeEventMessage, type IOEventMessage, type IOLike, type IORouterLike, type Id, type InferCrdtJson, type InferEventMessage, type InferEventsInput, type InferEventsOutput, type InferIOAuthorize, type InferIOAuthorizeUser, type InferIOCrdtKind, type InferIOInput, type InferIOOutput, type InputZodLike, type Json, type JsonObject, type JsonPrimitive, type Maybe, type MaybePromise, type MaybeReadonlyArray, type MergeEvents, type NonNilProps, type OptionalProps, type OtherSubscriptionCallback, type OtherSubscriptionFn, type OthersSubscriptionCallback, type OthersSubscriptionEvent, type OthersSubscriptionFn, type PluvRouterEventConfig, type ProcedureLike, type RoomEventListenerMap, type RoomLike, type Spread, type SpreadProperties, type StateNotifierSubjects, type StorageInfo, type StorageProxy, type StorageRootSubscriptionCallback, type StorageRootSubscriptionFn, StorageState, type StorageSubscriptionCallback, type StorageSubscriptionFn, type SubscribeFn, type SubscribeProxy, type SubscriptionCallback, type UndefinedProps, type UpdateMyPresenceAction, type UserInfo, type WebSocketConnection, type WebSocketState };
387
+ export { type BaseClientEventRecord, type BaseClientMessage, type BaseIOEventRecord, type BaseUser, type BroadcastProxy, ConnectionState, type Constructable, type CrdtDocFactory, type CrdtDocLike, type CrdtLibraryType, type CrdtType, type DeepPartial, type DeepWriteable, type DocApplyEncodedStateParams, type DocBatchApplyEncodedStateParams, type DocSubscribeCallbackParams, type EventMessage, type EventNotifierSubscriptionCallback, type EventProxy, type EventRecord, type GetEventMessage, type HasRequiredProperty, type IOAuthorize, type IOAuthorizeEventMessage, type IOEventMessage, type IOLike, type IORouterLike, type Id, type InferCrdtJson, type InferEventMessage, type InferEventsInput, type InferEventsOutput, type InferIOAuthorize, type InferIOAuthorizeUser, type InferIOCrdt, type InferIOCrdtKind, type InferIOEvents, type InferIOInput, type InferIOOutput, type InferIOProcedureInput, type InferIOProcedureOutput, type InputZodLike, type Json, type JsonObject, type JsonPrimitive, type Maybe, type MaybePromise, type MaybeReadonlyArray, type MergeEvents, type NonNilProps, type OptionalProps, type OtherSubscriptionCallback, type OtherSubscriptionFn, type OthersSubscriptionCallback, type OthersSubscriptionEvent, type OthersSubscriptionFn, type PluvRouterEventConfig, type ProcedureLike, type RoomEventListenerMap, type RoomLike, type Spread, type SpreadProperties, type StateNotifierSubjects, type StorageInfo, type StorageProxy, type StorageRootSubscriptionCallback, type StorageRootSubscriptionFn, StorageState, type StorageSubscriptionCallback, type StorageSubscriptionFn, type SubscribeFn, type SubscribeProxy, type SubscriptionCallback, type UndefinedProps, type UpdateMyPresenceAction, type UserInfo, type WebSocketConnection, type WebSocketState };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pluv/types",
3
- "version": "3.2.1",
3
+ "version": "3.2.2",
4
4
  "description": "@pluv/io shared types",
5
5
  "author": {
6
6
  "email": "david@pluv.io",
@@ -23,8 +23,8 @@
23
23
  "eslint": "^9.31.0",
24
24
  "tsup": "^8.5.0",
25
25
  "typescript": "^5.8.3",
26
- "@pluv/tsconfig": "^3.2.1",
27
- "eslint-config-pluv": "^3.2.1"
26
+ "@pluv/tsconfig": "^3.2.2",
27
+ "eslint-config-pluv": "^3.2.2"
28
28
  },
29
29
  "dependencies": {
30
30
  "wonka": "^6.3.5"
package/src/index.ts CHANGED
@@ -41,9 +41,13 @@ export type {
41
41
  InferEventsOutput,
42
42
  InferIOAuthorize,
43
43
  InferIOAuthorizeUser,
44
+ InferIOCrdt,
44
45
  InferIOCrdtKind,
46
+ InferIOEvents,
45
47
  InferIOInput,
46
48
  InferIOOutput,
49
+ InferIOProcedureInput,
50
+ InferIOProcedureOutput,
47
51
  InputZodLike,
48
52
  IOAuthorize,
49
53
  IOAuthorizeEventMessage,
@@ -86,7 +86,11 @@ export type GetEventMessage<
86
86
  > = TEvent extends string ? EventMessage<TEvent, T[TEvent]> : never;
87
87
 
88
88
  export type InferIOAuthorize<TIO extends IOLike<any, any, any>> =
89
- TIO extends IOLike<infer IAuthorize, any, any> ? IAuthorize : never;
89
+ TIO extends IOLike<infer IAuthorize, any, any>
90
+ ? InferIOAuthorizeUser<IAuthorize> extends BaseUser
91
+ ? { user: InputZodLike<InferIOAuthorizeUser<IAuthorize>> }
92
+ : null
93
+ : never;
90
94
 
91
95
  export type InferIOAuthorizeUser<TAuthorize extends IOAuthorize<any, any> | null> =
92
96
  TAuthorize extends IOAuthorize<infer IUser, any> ? IUser : null;
@@ -108,7 +112,7 @@ export type IOAuthorize<
108
112
  | ((context: TContext) => TUser extends BaseUser
109
113
  ? {
110
114
  secret?: string;
111
- user: TUser extends BaseUser ? InputZodLike<TUser> : null;
115
+ user: InputZodLike<TUser>;
112
116
  }
113
117
  : null);
114
118
 
@@ -118,7 +122,7 @@ export type IOAuthorizeEventMessage<TIO extends IOLike> = {
118
122
  };
119
123
 
120
124
  export type ProcedureLike<
121
- TInput extends JsonObject = {},
125
+ TInput extends Record<string, any> = {},
122
126
  TOutput extends EventRecord<string, any> = {},
123
127
  > = {
124
128
  config: {
@@ -157,15 +161,34 @@ export type InferIOCrdtKind<TIO extends IOLike<any, any, any>> =
157
161
  : never
158
162
  : never;
159
163
 
164
+ export type InferIOCrdt<TIO extends IOLike<any, any, any>> =
165
+ TIO extends IOLike<any, infer ICrdt, any> ? ICrdt : never;
166
+
167
+ export type InferIOEvents<TIO extends IOLike<any, any, any>> =
168
+ TIO extends IOLike<any, any, infer IEvents>
169
+ ? {
170
+ [P in keyof IEvents]: ProcedureLike<
171
+ InferIOProcedureInput<IEvents[P]>,
172
+ InferIOProcedureOutput<IEvents[P]>
173
+ >;
174
+ }
175
+ : never;
176
+
177
+ export type InferIOProcedureInput<TProcedure extends ProcedureLike<any, any>> =
178
+ TProcedure extends ProcedureLike<infer IInput, any> ? Id<IInput> : never;
179
+
180
+ export type InferIOProcedureOutput<TProcedure extends ProcedureLike<any, any>> =
181
+ TProcedure extends ProcedureLike<any, infer IOutput> ? Id<IOutput> : never;
182
+
160
183
  export type InferEventsInput<TEvents extends Record<string, ProcedureLike<any, any>>> = {
161
- [P in keyof TEvents]: TEvents[P] extends ProcedureLike<infer IInput, any> ? IInput : never;
184
+ [P in keyof TEvents]: TEvents[P] extends ProcedureLike<infer IInput, any> ? Id<IInput> : never;
162
185
  };
163
186
 
164
187
  export type InferEventsOutput<TEvents extends Record<string, ProcedureLike<any, any>>> =
165
188
  UnionToIntersection<
166
189
  {
167
190
  [P in keyof TEvents]: TEvents[P] extends ProcedureLike<any, infer IOutput>
168
- ? IOutput
191
+ ? Id<IOutput>
169
192
  : never;
170
193
  }[keyof TEvents]
171
194
  >;