@pluv/types 1.0.0 → 1.0.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.
- package/.turbo/turbo-build.log +7 -7
- package/CHANGELOG.md +4 -0
- package/dist/index.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/package.json +3 -3
- package/src/general.ts +6 -2
- package/src/pluv.ts +31 -13
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @pluv/types@1.0.
|
|
2
|
+
> @pluv/types@1.0.2 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 718ms
|
|
17
|
+
[32mDTS[39m [1mdist/index.d.mts [22m[32m7.48 KB[39m
|
|
18
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m7.48 KB[39m
|
package/CHANGELOG.md
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -90,11 +90,13 @@ type BaseIOEventRecord<TAuthorize extends IOAuthorize<any, any>> = {
|
|
|
90
90
|
$registered: {
|
|
91
91
|
presence: JsonObject | null;
|
|
92
92
|
sessionId: string;
|
|
93
|
+
state: string | null;
|
|
93
94
|
timers: {
|
|
94
95
|
presence: number | null;
|
|
95
96
|
};
|
|
96
97
|
};
|
|
97
98
|
$storageReceived: {
|
|
99
|
+
changeKind: "empty" | "initialized" | "unchanged";
|
|
98
100
|
state: string;
|
|
99
101
|
};
|
|
100
102
|
$storageUpdated: {
|
package/dist/index.d.ts
CHANGED
|
@@ -90,11 +90,13 @@ type BaseIOEventRecord<TAuthorize extends IOAuthorize<any, any>> = {
|
|
|
90
90
|
$registered: {
|
|
91
91
|
presence: JsonObject | null;
|
|
92
92
|
sessionId: string;
|
|
93
|
+
state: string | null;
|
|
93
94
|
timers: {
|
|
94
95
|
presence: number | null;
|
|
95
96
|
};
|
|
96
97
|
};
|
|
97
98
|
$storageReceived: {
|
|
99
|
+
changeKind: "empty" | "initialized" | "unchanged";
|
|
98
100
|
state: string;
|
|
99
101
|
};
|
|
100
102
|
$storageUpdated: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pluv/types",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
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.2",
|
|
23
|
+
"eslint-config-pluv": "^1.0.2"
|
|
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,9 +49,11 @@ export type BaseIOEventRecord<TAuthorize extends IOAuthorize<any, any>> = {
|
|
|
49
49
|
$registered: {
|
|
50
50
|
presence: JsonObject | null;
|
|
51
51
|
sessionId: string;
|
|
52
|
+
state: string | null;
|
|
52
53
|
timers: { presence: number | null };
|
|
53
54
|
};
|
|
54
55
|
$storageReceived: {
|
|
56
|
+
changeKind: "empty" | "initialized" | "unchanged";
|
|
55
57
|
state: string;
|
|
56
58
|
};
|
|
57
59
|
$storageUpdated: {
|
|
@@ -77,11 +79,13 @@ export type EventRecord<TEvent extends string, TData extends JsonObject> = {
|
|
|
77
79
|
[key in `${TEvent}`]: TData;
|
|
78
80
|
};
|
|
79
81
|
|
|
80
|
-
export type GetEventMessage<
|
|
81
|
-
|
|
82
|
-
|
|
82
|
+
export type GetEventMessage<
|
|
83
|
+
T extends EventRecord<string, any>,
|
|
84
|
+
TEvent extends keyof T,
|
|
85
|
+
> = TEvent extends string ? EventMessage<TEvent, T[TEvent]> : never;
|
|
83
86
|
|
|
84
|
-
export type InferIOAuthorize<TIO extends IOLike<any, any>> =
|
|
87
|
+
export type InferIOAuthorize<TIO extends IOLike<any, any>> =
|
|
88
|
+
TIO extends IOLike<infer IAuthorize> ? IAuthorize : never;
|
|
85
89
|
|
|
86
90
|
export type InferIOAuthorizeUser<TAuthorize extends IOAuthorize<any, any> | null> =
|
|
87
91
|
TAuthorize extends IOAuthorize<infer IUser, any> ? IUser : null;
|
|
@@ -90,7 +94,10 @@ export type InputZodLike<TData extends JsonObject> = {
|
|
|
90
94
|
parse: (data: unknown) => TData;
|
|
91
95
|
} & ({ _input: TData } | { _zod: { input: TData } });
|
|
92
96
|
|
|
93
|
-
export type IOAuthorize<
|
|
97
|
+
export type IOAuthorize<
|
|
98
|
+
TUser extends BaseUser | null = any,
|
|
99
|
+
TContext extends Record<string, unknown> = {},
|
|
100
|
+
> =
|
|
94
101
|
| (TUser extends BaseUser
|
|
95
102
|
? {
|
|
96
103
|
secret?: string;
|
|
@@ -109,9 +116,14 @@ export type IOAuthorizeEventMessage<TIO extends IOLike> = {
|
|
|
109
116
|
user: InferIOAuthorizeUser<InferIOAuthorize<TIO>>;
|
|
110
117
|
};
|
|
111
118
|
|
|
112
|
-
export type ProcedureLike<
|
|
119
|
+
export type ProcedureLike<
|
|
120
|
+
TInput extends JsonObject = {},
|
|
121
|
+
TOutput extends EventRecord<string, any> = {},
|
|
122
|
+
> = {
|
|
113
123
|
config: {
|
|
114
|
-
broadcast?:
|
|
124
|
+
broadcast?:
|
|
125
|
+
| ((data: TInput, ...args: any[]) => MaybePromise<Partial<TOutput> | void>)
|
|
126
|
+
| null;
|
|
115
127
|
input?: InputZodLike<TInput> | null;
|
|
116
128
|
resolver: (data: TInput, ...args: any[]) => MaybePromise<TOutput>;
|
|
117
129
|
self?: ((data: TInput, ...args: any[]) => MaybePromise<Partial<TOutput> | void>) | null;
|
|
@@ -139,11 +151,14 @@ export type InferEventsInput<TEvents extends Record<string, ProcedureLike<any, a
|
|
|
139
151
|
[P in keyof TEvents]: TEvents[P] extends ProcedureLike<infer IInput, any> ? IInput : never;
|
|
140
152
|
};
|
|
141
153
|
|
|
142
|
-
export type InferEventsOutput<TEvents extends Record<string, ProcedureLike<any, any>>> =
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
154
|
+
export type InferEventsOutput<TEvents extends Record<string, ProcedureLike<any, any>>> =
|
|
155
|
+
UnionToIntersection<
|
|
156
|
+
{
|
|
157
|
+
[P in keyof TEvents]: TEvents[P] extends ProcedureLike<any, infer IOutput>
|
|
158
|
+
? IOutput
|
|
159
|
+
: never;
|
|
160
|
+
}[keyof TEvents]
|
|
161
|
+
>;
|
|
147
162
|
|
|
148
163
|
export type InferIOInput<TRouter extends IORouterLike<any>> =
|
|
149
164
|
TRouter extends IORouterLike<infer IEvents> ? InferEventsInput<IEvents> : never;
|
|
@@ -151,7 +166,10 @@ export type InferIOInput<TRouter extends IORouterLike<any>> =
|
|
|
151
166
|
export type InferIOOutput<TRouter extends IORouterLike<any>> =
|
|
152
167
|
TRouter extends IORouterLike<infer IEvents> ? InferEventsOutput<IEvents> : never;
|
|
153
168
|
|
|
154
|
-
export type InferEventMessage<
|
|
169
|
+
export type InferEventMessage<
|
|
170
|
+
TEvents = EventRecord<string, any>,
|
|
171
|
+
TEvent extends keyof TEvents = keyof TEvents,
|
|
172
|
+
> =
|
|
155
173
|
TEvents extends EventRecord<string, any>
|
|
156
174
|
? { [P in TEvent]: P extends string ? Id<EventMessage<P, TEvents[P]>> : never }[TEvent]
|
|
157
175
|
: never;
|