@pluv/types 0.2.1 → 0.10.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 +7 -6
- package/CHANGELOG.md +13 -0
- package/dist/index.d.mts +152 -0
- package/package.json +6 -7
- package/src/general.ts +3 -3
- package/src/pluv.ts +7 -7
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
|
|
2
|
-
> @pluv/types@0.
|
|
2
|
+
> @pluv/types@0.10.0 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
|
|
6
6
|
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
7
|
-
[34mCLI[39m tsup v7.
|
|
7
|
+
[34mCLI[39m tsup v7.2.0
|
|
8
8
|
[34mCLI[39m Target: es6
|
|
9
9
|
[34mESM[39m Build start
|
|
10
10
|
[34mCJS[39m Build start
|
|
11
11
|
[32mESM[39m [1mdist/index.mjs [22m[32m0 B[39m
|
|
12
|
-
[32mESM[39m ⚡️ Build success in
|
|
12
|
+
[32mESM[39m ⚡️ Build success in 28ms
|
|
13
13
|
[32mCJS[39m [1mdist/index.js [22m[32m754.00 B[39m
|
|
14
|
-
[32mCJS[39m ⚡️ Build success in
|
|
14
|
+
[32mCJS[39m ⚡️ Build success in 30ms
|
|
15
15
|
[34mDTS[39m Build start
|
|
16
|
-
[32mDTS[39m ⚡️ Build success in
|
|
17
|
-
[32mDTS[39m [1mdist/index.d.
|
|
16
|
+
[32mDTS[39m ⚡️ Build success in 1764ms
|
|
17
|
+
[32mDTS[39m [1mdist/index.d.mts [22m[32m7.18 KB[39m
|
|
18
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m7.18 KB[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @pluv/types
|
|
2
2
|
|
|
3
|
+
## 0.10.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- f43f1cc: Change packages to all be versioned together for consistency.
|
|
8
|
+
|
|
9
|
+
## 0.2.2
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 8fba48b: fix including incorrect dependency
|
|
14
|
+
- 8997c65: bumped dependencies
|
|
15
|
+
|
|
3
16
|
## 0.2.1
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
type Constructable = {
|
|
2
|
+
new (...args: any[]): any;
|
|
3
|
+
};
|
|
4
|
+
type Maybe<T> = T | null | undefined;
|
|
5
|
+
type MaybePromise<T> = Promise<T> | T;
|
|
6
|
+
type MaybeReadonlyArray<T> = T[] | readonly T[];
|
|
7
|
+
type OptionalPropertyNames<T> = {
|
|
8
|
+
[K in keyof T]-?: {} extends {
|
|
9
|
+
[P in K]: T[K];
|
|
10
|
+
} ? K : never;
|
|
11
|
+
}[keyof T];
|
|
12
|
+
type SpreadProperties<L, R, K extends keyof L & keyof R> = {
|
|
13
|
+
[P in K]: L[P] | Exclude<R[P], undefined>;
|
|
14
|
+
};
|
|
15
|
+
type Id<T> = T extends infer U ? U extends Constructable ? U : {
|
|
16
|
+
[K in keyof U]: U[K];
|
|
17
|
+
} : never;
|
|
18
|
+
type SpreadTwo<L, R> = Id<Pick<L, Exclude<keyof L, keyof R>> & Pick<R, Exclude<keyof R, OptionalPropertyNames<R>>> & Pick<R, Exclude<OptionalPropertyNames<R>, keyof L>> & SpreadProperties<L, R, OptionalPropertyNames<R> & keyof L>>;
|
|
19
|
+
type Spread<A extends readonly [...any]> = A extends [
|
|
20
|
+
infer L,
|
|
21
|
+
...infer R
|
|
22
|
+
] ? SpreadTwo<L, Spread<R>> : unknown;
|
|
23
|
+
type DeepPartial<T> = {
|
|
24
|
+
[P in keyof T]?: T[P] extends Array<infer U> ? Array<DeepPartial<U>> : T[P] extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : DeepPartial<T[P]>;
|
|
25
|
+
};
|
|
26
|
+
type DeepWriteable<T> = {
|
|
27
|
+
-readonly [P in keyof T]: DeepWriteable<T[P]>;
|
|
28
|
+
};
|
|
29
|
+
type OptionalProps<T extends Record<string, any>, K extends keyof T = keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
30
|
+
type NonNilProps<T extends Record<string, any>, K extends keyof T = keyof T> = Omit<T, K> & {
|
|
31
|
+
[P in K]-?: NonNullable<T[P]>;
|
|
32
|
+
};
|
|
33
|
+
type JsonPrimitive = string | number | boolean | null;
|
|
34
|
+
type Json = JsonPrimitive | Json[] | readonly Json[] | {
|
|
35
|
+
[key: string]: Json;
|
|
36
|
+
};
|
|
37
|
+
type JsonObject = Record<string, Json>;
|
|
38
|
+
|
|
39
|
+
type BaseUser = {
|
|
40
|
+
id: string;
|
|
41
|
+
};
|
|
42
|
+
interface BaseClientEventRecord {
|
|
43
|
+
$GET_OTHERS: {};
|
|
44
|
+
$INITIALIZE_SESSION: {
|
|
45
|
+
presence: JsonObject;
|
|
46
|
+
update: string | null;
|
|
47
|
+
};
|
|
48
|
+
$PING: {};
|
|
49
|
+
$UPDATE_PRESENCE: {
|
|
50
|
+
presence: JsonObject;
|
|
51
|
+
};
|
|
52
|
+
$UPDATE_STORAGE: {
|
|
53
|
+
origin: string | null;
|
|
54
|
+
update: string;
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
type BaseClientMessage = InferEventMessage<BaseClientEventRecord>;
|
|
58
|
+
interface BaseIOAuthorize {
|
|
59
|
+
required: false;
|
|
60
|
+
secret: string;
|
|
61
|
+
user: InputZodLike<BaseUser>;
|
|
62
|
+
}
|
|
63
|
+
interface BaseIOAuthorizeEventRecord<TAuthorize extends IOAuthorize<any, any>> {
|
|
64
|
+
$OTHERS_RECEIVED: {
|
|
65
|
+
others: {
|
|
66
|
+
[connectionId: string]: {
|
|
67
|
+
connectionId: string;
|
|
68
|
+
presence: JsonObject | null;
|
|
69
|
+
room: string | null;
|
|
70
|
+
user: InferIOAuthorizeUser<TAuthorize>;
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
$USER_JOINED: {
|
|
75
|
+
connectionId: string;
|
|
76
|
+
user: NonNullable<InferIOAuthorizeUser<TAuthorize>>;
|
|
77
|
+
presence: JsonObject;
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
type BaseIOEventRecord<TAuthorize extends IOAuthorize<any, any>> = BaseIOAuthorizeEventRecord<TAuthorize> & {
|
|
81
|
+
$ERROR: {
|
|
82
|
+
message: string;
|
|
83
|
+
stack?: string | null;
|
|
84
|
+
};
|
|
85
|
+
$EXIT: {
|
|
86
|
+
sessionId: string;
|
|
87
|
+
};
|
|
88
|
+
$PONG: {};
|
|
89
|
+
$PRESENCE_UPDATED: {
|
|
90
|
+
presence: JsonObject;
|
|
91
|
+
};
|
|
92
|
+
$REGISTERED: {
|
|
93
|
+
sessionId: string;
|
|
94
|
+
};
|
|
95
|
+
$STORAGE_RECEIVED: {
|
|
96
|
+
state: string;
|
|
97
|
+
};
|
|
98
|
+
$STORAGE_UPDATED: {
|
|
99
|
+
state: string;
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
interface EventMessage<TEvent extends string, TData extends JsonObject = {}> {
|
|
103
|
+
data: TData;
|
|
104
|
+
type: TEvent;
|
|
105
|
+
}
|
|
106
|
+
type EventRecord<TEvent extends string, TData extends JsonObject> = {
|
|
107
|
+
[key in `${TEvent}`]: TData;
|
|
108
|
+
};
|
|
109
|
+
type GetEventMessage<T extends EventRecord<string, any>, TEvent extends keyof T> = TEvent extends string ? EventMessage<TEvent, T[TEvent]> : never;
|
|
110
|
+
type InferEventMessage<TEvents extends EventRecord<string, any> = EventRecord<string, any>, TEvent extends keyof TEvents = keyof TEvents> = {
|
|
111
|
+
[P in TEvent]: P extends string ? Id<EventMessage<P, TEvents[P]>> : never;
|
|
112
|
+
}[TEvent];
|
|
113
|
+
type InferIOAuthorize<TIO extends IOLike> = TIO extends IOLike<infer IAuthorize> ? IAuthorize : never;
|
|
114
|
+
type InferIOAuthorizeRequired<TAuthorize extends IOAuthorize<any, any>> = TAuthorize extends IOAuthorize<any, infer IRequired> ? IRequired : never;
|
|
115
|
+
type InferIOAuthorizeUser<TAuthorize extends IOAuthorize<any, any>> = TAuthorize extends IOAuthorize<infer IUser, infer IRequired> ? IRequired extends true ? IUser : IUser | null : never;
|
|
116
|
+
type InferIOInput<TIO extends IOLike> = TIO extends IOLike<any, infer IInput> ? IInput : never;
|
|
117
|
+
type InferIOOutput<TIO extends IOLike> = TIO extends IOLike<any, any, infer IOutputBroadcast, infer IOutputSelf, infer IOutputSync> ? Spread<[IOutputBroadcast, IOutputSelf, IOutputSync]> : never;
|
|
118
|
+
type InferIOOutputBroadcast<TIO extends IOLike> = TIO extends IOLike<any, any, infer IOutput> ? IOutput : never;
|
|
119
|
+
type InferIOOutputSelf<TIO extends IOLike> = TIO extends IOLike<any, any, any, infer IOutput> ? IOutput : never;
|
|
120
|
+
type InferIOOutputSync<TIO extends IOLike> = TIO extends IOLike<any, any, any, any, infer IOutput> ? IOutput : never;
|
|
121
|
+
type InputZodLike<TData extends JsonObject> = {
|
|
122
|
+
_input: TData;
|
|
123
|
+
parse: (data: unknown) => TData;
|
|
124
|
+
};
|
|
125
|
+
interface IOAuthorize<TUser extends BaseUser = any, TRequired extends boolean = false> {
|
|
126
|
+
required: TRequired;
|
|
127
|
+
secret: string;
|
|
128
|
+
user: InputZodLike<TUser>;
|
|
129
|
+
}
|
|
130
|
+
type IOAuthorizeEventMessage<TIO extends IOLike> = InferIOAuthorizeRequired<InferIOAuthorize<TIO>> extends false ? IOAuthorizeOptionalEventMessage<TIO> : IOAuthorizeRequiredEventMessage<TIO>;
|
|
131
|
+
interface IOAuthorizeOptionalEventMessage<TIO extends IOLike> {
|
|
132
|
+
connectionId: string | null;
|
|
133
|
+
user: InferIOAuthorizeUser<InferIOAuthorize<TIO>> | null;
|
|
134
|
+
}
|
|
135
|
+
type IOAuthorizeRequiredEventMessage<TIO extends IOLike> = NonNilProps<IOAuthorizeOptionalEventMessage<TIO>, "connectionId" | "user">;
|
|
136
|
+
type IOEventMessage<TIO extends IOLike, TEvent extends keyof InferIOOutput<TIO> = keyof InferIOOutput<TIO>> = Id<{
|
|
137
|
+
room: string;
|
|
138
|
+
} & InferEventMessage<InferIOOutput<TIO>, TEvent> & (InferEventMessage<InferIOOutput<TIO>, TEvent>["type"] extends "$ERROR" ? IOAuthorizeOptionalEventMessage<TIO> : IOAuthorizeEventMessage<TIO>)>;
|
|
139
|
+
interface IOLike<TAuthorize extends IOAuthorize<any, any> = IOAuthorize<any, any>, TInput extends EventRecord<string, any> = {}, TOutputBroadcast extends EventRecord<string, any> = {}, TOutputSelf extends EventRecord<string, any> = {}, TOutputSync extends EventRecord<string, any> = {}> {
|
|
140
|
+
_authorize: TAuthorize | null;
|
|
141
|
+
_events: {
|
|
142
|
+
[P in keyof TInput]: P extends string ? {
|
|
143
|
+
resolver: ((data: TInput[P], ...args: any[]) => MaybePromise<TOutputBroadcast | void>) | {
|
|
144
|
+
broadcast?: (data: TInput[P], ...args: any[]) => MaybePromise<TOutputBroadcast | void>;
|
|
145
|
+
self?: (data: TInput[P], ...args: any[]) => MaybePromise<TOutputSelf | void>;
|
|
146
|
+
sync?: (data: TInput[P], ...args: any[]) => MaybePromise<TOutputSync | void>;
|
|
147
|
+
};
|
|
148
|
+
} : never;
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export { BaseClientEventRecord, BaseClientMessage, BaseIOAuthorize, BaseIOAuthorizeEventRecord, BaseIOEventRecord, BaseUser, Constructable, DeepPartial, DeepWriteable, EventMessage, EventRecord, GetEventMessage, IOAuthorize, IOAuthorizeEventMessage, IOAuthorizeOptionalEventMessage, IOAuthorizeRequiredEventMessage, IOEventMessage, IOLike, Id, InferEventMessage, InferIOAuthorize, InferIOAuthorizeRequired, InferIOAuthorizeUser, InferIOInput, InferIOOutput, InferIOOutputBroadcast, InferIOOutputSelf, InferIOOutputSync, InputZodLike, Json, JsonObject, JsonPrimitive, Maybe, MaybePromise, MaybeReadonlyArray, NonNilProps, OptionalProps, Spread, SpreadProperties };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pluv/types",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "@pluv/io shared types",
|
|
5
5
|
"author": "leedavidcs",
|
|
6
6
|
"license": "MIT",
|
|
@@ -16,14 +16,13 @@
|
|
|
16
16
|
"access": "public"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
|
-
"tsup": "^7.
|
|
20
|
-
"typescript": "^5.1.
|
|
21
|
-
"@pluv/tsconfig": "^0.
|
|
22
|
-
"eslint-config-pluv": "^0.
|
|
19
|
+
"tsup": "^7.2.0",
|
|
20
|
+
"typescript": "^5.1.6",
|
|
21
|
+
"@pluv/tsconfig": "^0.10.0",
|
|
22
|
+
"eslint-config-pluv": "^0.2.0"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@
|
|
26
|
-
"@types/react": "^18.2.13"
|
|
25
|
+
"@types/react": "^18.2.20"
|
|
27
26
|
},
|
|
28
27
|
"scripts": {
|
|
29
28
|
"build": "tsup src/index.ts --format esm,cjs --dts",
|
package/src/general.ts
CHANGED
|
@@ -27,7 +27,7 @@ type SpreadTwo<L, R> = Id<
|
|
|
27
27
|
|
|
28
28
|
export type Spread<A extends readonly [...any]> = A extends [
|
|
29
29
|
infer L,
|
|
30
|
-
...infer R
|
|
30
|
+
...infer R,
|
|
31
31
|
]
|
|
32
32
|
? SpreadTwo<L, Spread<R>>
|
|
33
33
|
: unknown;
|
|
@@ -46,12 +46,12 @@ export type DeepWriteable<T> = {
|
|
|
46
46
|
|
|
47
47
|
export type OptionalProps<
|
|
48
48
|
T extends Record<string, any>,
|
|
49
|
-
K extends keyof T = keyof T
|
|
49
|
+
K extends keyof T = keyof T,
|
|
50
50
|
> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
51
51
|
|
|
52
52
|
export type NonNilProps<
|
|
53
53
|
T extends Record<string, any>,
|
|
54
|
-
K extends keyof T = keyof T
|
|
54
|
+
K extends keyof T = keyof T,
|
|
55
55
|
> = Omit<T, K> & { [P in K]-?: NonNullable<T[P]> };
|
|
56
56
|
|
|
57
57
|
export type JsonPrimitive = string | number | boolean | null;
|
package/src/pluv.ts
CHANGED
|
@@ -29,7 +29,7 @@ export interface BaseIOAuthorize {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
export interface BaseIOAuthorizeEventRecord<
|
|
32
|
-
TAuthorize extends IOAuthorize<any, any
|
|
32
|
+
TAuthorize extends IOAuthorize<any, any>,
|
|
33
33
|
> {
|
|
34
34
|
$OTHERS_RECEIVED: {
|
|
35
35
|
others: {
|
|
@@ -74,7 +74,7 @@ export type BaseIOEventRecord<TAuthorize extends IOAuthorize<any, any>> =
|
|
|
74
74
|
|
|
75
75
|
export interface EventMessage<
|
|
76
76
|
TEvent extends string,
|
|
77
|
-
TData extends JsonObject = {}
|
|
77
|
+
TData extends JsonObject = {},
|
|
78
78
|
> {
|
|
79
79
|
data: TData;
|
|
80
80
|
type: TEvent;
|
|
@@ -86,12 +86,12 @@ export type EventRecord<TEvent extends string, TData extends JsonObject> = {
|
|
|
86
86
|
|
|
87
87
|
export type GetEventMessage<
|
|
88
88
|
T extends EventRecord<string, any>,
|
|
89
|
-
TEvent extends keyof T
|
|
89
|
+
TEvent extends keyof T,
|
|
90
90
|
> = TEvent extends string ? EventMessage<TEvent, T[TEvent]> : never;
|
|
91
91
|
|
|
92
92
|
export type InferEventMessage<
|
|
93
93
|
TEvents extends EventRecord<string, any> = EventRecord<string, any>,
|
|
94
|
-
TEvent extends keyof TEvents = keyof TEvents
|
|
94
|
+
TEvent extends keyof TEvents = keyof TEvents,
|
|
95
95
|
> = {
|
|
96
96
|
[P in TEvent]: P extends string ? Id<EventMessage<P, TEvents[P]>> : never;
|
|
97
97
|
}[TEvent];
|
|
@@ -163,7 +163,7 @@ export type InputZodLike<TData extends JsonObject> = {
|
|
|
163
163
|
|
|
164
164
|
export interface IOAuthorize<
|
|
165
165
|
TUser extends BaseUser = any,
|
|
166
|
-
TRequired extends boolean = false
|
|
166
|
+
TRequired extends boolean = false,
|
|
167
167
|
> {
|
|
168
168
|
required: TRequired;
|
|
169
169
|
secret: string;
|
|
@@ -187,7 +187,7 @@ export type IOAuthorizeRequiredEventMessage<TIO extends IOLike> = NonNilProps<
|
|
|
187
187
|
|
|
188
188
|
export type IOEventMessage<
|
|
189
189
|
TIO extends IOLike,
|
|
190
|
-
TEvent extends keyof InferIOOutput<TIO> = keyof InferIOOutput<TIO
|
|
190
|
+
TEvent extends keyof InferIOOutput<TIO> = keyof InferIOOutput<TIO>,
|
|
191
191
|
> = Id<
|
|
192
192
|
{ room: string } & InferEventMessage<InferIOOutput<TIO>, TEvent> &
|
|
193
193
|
(InferEventMessage<InferIOOutput<TIO>, TEvent>["type"] extends "$ERROR"
|
|
@@ -200,7 +200,7 @@ export interface IOLike<
|
|
|
200
200
|
TInput extends EventRecord<string, any> = {},
|
|
201
201
|
TOutputBroadcast extends EventRecord<string, any> = {},
|
|
202
202
|
TOutputSelf extends EventRecord<string, any> = {},
|
|
203
|
-
TOutputSync extends EventRecord<string, any> = {}
|
|
203
|
+
TOutputSync extends EventRecord<string, any> = {},
|
|
204
204
|
> {
|
|
205
205
|
_authorize: TAuthorize | null;
|
|
206
206
|
_events: {
|