@pluv/types 1.0.0 → 1.0.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 +7 -7
- package/CHANGELOG.md +2 -0
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/package.json +3 -3
- package/src/general.ts +6 -2
- package/src/pluv.ts +30 -13
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @pluv/types@1.0.
|
|
2
|
+
> @pluv/types@1.0.1 build /home/runner/work/pluv/pluv/packages/types
|
|
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
|
-
[32mESM[39m [1mdist/index.mjs [22m[32m0 B[39m
|
|
12
|
-
[32mESM[39m ⚡️ Build success in 36ms
|
|
13
11
|
[32mCJS[39m [1mdist/index.js [22m[32m758.00 B[39m
|
|
14
|
-
[32mCJS[39m ⚡️ Build success in
|
|
12
|
+
[32mCJS[39m ⚡️ Build success in 31ms
|
|
13
|
+
[32mESM[39m [1mdist/index.mjs [22m[32m0 B[39m
|
|
14
|
+
[32mESM[39m ⚡️ Build success in 32ms
|
|
15
15
|
[34mDTS[39m Build start
|
|
16
|
-
[32mDTS[39m ⚡️ Build success in
|
|
17
|
-
[32mDTS[39m [1mdist/index.d.mts [22m[32m7.
|
|
18
|
-
[32mDTS[39m [1mdist/index.d.ts [22m[32m7.
|
|
16
|
+
[32mDTS[39m ⚡️ Build success in 728ms
|
|
17
|
+
[32mDTS[39m [1mdist/index.d.mts [22m[32m7.42 KB[39m
|
|
18
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m7.42 KB[39m
|
package/CHANGELOG.md
CHANGED
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pluv/types",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "@pluv/io shared types",
|
|
5
5
|
"author": "leedavidcs",
|
|
6
6
|
"license": "MIT",
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
"eslint": "^9.25.1",
|
|
20
20
|
"tsup": "^8.4.0",
|
|
21
21
|
"typescript": "^5.8.3",
|
|
22
|
-
"@pluv/tsconfig": "^1.0.
|
|
23
|
-
"eslint-config-pluv": "^1.0.
|
|
22
|
+
"@pluv/tsconfig": "^1.0.1",
|
|
23
|
+
"eslint-config-pluv": "^1.0.1"
|
|
24
24
|
},
|
|
25
25
|
"scripts": {
|
|
26
26
|
"build": "tsup src/index.ts --format esm,cjs --dts",
|
package/src/general.ts
CHANGED
|
@@ -30,7 +30,9 @@ type SpreadTwo<L, R> = Id<
|
|
|
30
30
|
SpreadProperties<L, R, OptionalPropertyNames<R> & keyof L>
|
|
31
31
|
>;
|
|
32
32
|
|
|
33
|
-
export type Spread<A extends readonly [...any]> = A extends [infer L, ...infer R]
|
|
33
|
+
export type Spread<A extends readonly [...any]> = A extends [infer L, ...infer R]
|
|
34
|
+
? SpreadTwo<L, Spread<R>>
|
|
35
|
+
: unknown;
|
|
34
36
|
|
|
35
37
|
export type DeepPartial<T> = {
|
|
36
38
|
[P in keyof T]?: T[P] extends Array<infer U>
|
|
@@ -63,6 +65,8 @@ export type JsonObject = Record<string, Json>;
|
|
|
63
65
|
|
|
64
66
|
export type StringLiteral<T> = T extends string ? (string extends T ? never : T) : never;
|
|
65
67
|
|
|
66
|
-
export type UnionToIntersection<U> = (U extends any ? (arg: U) => any : never) extends (
|
|
68
|
+
export type UnionToIntersection<U> = (U extends any ? (arg: U) => any : never) extends (
|
|
69
|
+
arg: infer I,
|
|
70
|
+
) => void
|
|
67
71
|
? I
|
|
68
72
|
: never;
|
package/src/pluv.ts
CHANGED
|
@@ -49,6 +49,7 @@ export type BaseIOEventRecord<TAuthorize extends IOAuthorize<any, any>> = {
|
|
|
49
49
|
$registered: {
|
|
50
50
|
presence: JsonObject | null;
|
|
51
51
|
sessionId: string;
|
|
52
|
+
state: string;
|
|
52
53
|
timers: { presence: number | null };
|
|
53
54
|
};
|
|
54
55
|
$storageReceived: {
|
|
@@ -77,11 +78,13 @@ export type EventRecord<TEvent extends string, TData extends JsonObject> = {
|
|
|
77
78
|
[key in `${TEvent}`]: TData;
|
|
78
79
|
};
|
|
79
80
|
|
|
80
|
-
export type GetEventMessage<
|
|
81
|
-
|
|
82
|
-
|
|
81
|
+
export type GetEventMessage<
|
|
82
|
+
T extends EventRecord<string, any>,
|
|
83
|
+
TEvent extends keyof T,
|
|
84
|
+
> = TEvent extends string ? EventMessage<TEvent, T[TEvent]> : never;
|
|
83
85
|
|
|
84
|
-
export type InferIOAuthorize<TIO extends IOLike<any, any>> =
|
|
86
|
+
export type InferIOAuthorize<TIO extends IOLike<any, any>> =
|
|
87
|
+
TIO extends IOLike<infer IAuthorize> ? IAuthorize : never;
|
|
85
88
|
|
|
86
89
|
export type InferIOAuthorizeUser<TAuthorize extends IOAuthorize<any, any> | null> =
|
|
87
90
|
TAuthorize extends IOAuthorize<infer IUser, any> ? IUser : null;
|
|
@@ -90,7 +93,10 @@ export type InputZodLike<TData extends JsonObject> = {
|
|
|
90
93
|
parse: (data: unknown) => TData;
|
|
91
94
|
} & ({ _input: TData } | { _zod: { input: TData } });
|
|
92
95
|
|
|
93
|
-
export type IOAuthorize<
|
|
96
|
+
export type IOAuthorize<
|
|
97
|
+
TUser extends BaseUser | null = any,
|
|
98
|
+
TContext extends Record<string, unknown> = {},
|
|
99
|
+
> =
|
|
94
100
|
| (TUser extends BaseUser
|
|
95
101
|
? {
|
|
96
102
|
secret?: string;
|
|
@@ -109,9 +115,14 @@ export type IOAuthorizeEventMessage<TIO extends IOLike> = {
|
|
|
109
115
|
user: InferIOAuthorizeUser<InferIOAuthorize<TIO>>;
|
|
110
116
|
};
|
|
111
117
|
|
|
112
|
-
export type ProcedureLike<
|
|
118
|
+
export type ProcedureLike<
|
|
119
|
+
TInput extends JsonObject = {},
|
|
120
|
+
TOutput extends EventRecord<string, any> = {},
|
|
121
|
+
> = {
|
|
113
122
|
config: {
|
|
114
|
-
broadcast?:
|
|
123
|
+
broadcast?:
|
|
124
|
+
| ((data: TInput, ...args: any[]) => MaybePromise<Partial<TOutput> | void>)
|
|
125
|
+
| null;
|
|
115
126
|
input?: InputZodLike<TInput> | null;
|
|
116
127
|
resolver: (data: TInput, ...args: any[]) => MaybePromise<TOutput>;
|
|
117
128
|
self?: ((data: TInput, ...args: any[]) => MaybePromise<Partial<TOutput> | void>) | null;
|
|
@@ -139,11 +150,14 @@ export type InferEventsInput<TEvents extends Record<string, ProcedureLike<any, a
|
|
|
139
150
|
[P in keyof TEvents]: TEvents[P] extends ProcedureLike<infer IInput, any> ? IInput : never;
|
|
140
151
|
};
|
|
141
152
|
|
|
142
|
-
export type InferEventsOutput<TEvents extends Record<string, ProcedureLike<any, any>>> =
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
153
|
+
export type InferEventsOutput<TEvents extends Record<string, ProcedureLike<any, any>>> =
|
|
154
|
+
UnionToIntersection<
|
|
155
|
+
{
|
|
156
|
+
[P in keyof TEvents]: TEvents[P] extends ProcedureLike<any, infer IOutput>
|
|
157
|
+
? IOutput
|
|
158
|
+
: never;
|
|
159
|
+
}[keyof TEvents]
|
|
160
|
+
>;
|
|
147
161
|
|
|
148
162
|
export type InferIOInput<TRouter extends IORouterLike<any>> =
|
|
149
163
|
TRouter extends IORouterLike<infer IEvents> ? InferEventsInput<IEvents> : never;
|
|
@@ -151,7 +165,10 @@ export type InferIOInput<TRouter extends IORouterLike<any>> =
|
|
|
151
165
|
export type InferIOOutput<TRouter extends IORouterLike<any>> =
|
|
152
166
|
TRouter extends IORouterLike<infer IEvents> ? InferEventsOutput<IEvents> : never;
|
|
153
167
|
|
|
154
|
-
export type InferEventMessage<
|
|
168
|
+
export type InferEventMessage<
|
|
169
|
+
TEvents = EventRecord<string, any>,
|
|
170
|
+
TEvent extends keyof TEvents = keyof TEvents,
|
|
171
|
+
> =
|
|
155
172
|
TEvents extends EventRecord<string, any>
|
|
156
173
|
? { [P in TEvent]: P extends string ? Id<EventMessage<P, TEvents[P]>> : never }[TEvent]
|
|
157
174
|
: never;
|