@darco2903/altv-web-api 0.0.0-stage → 1.0.0-pre

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.
@@ -0,0 +1,108 @@
1
+ import { initContract, ZodErrorSchema } from "@ts-rest/core";
2
+ import { z } from "zod";
3
+ import { apiError, apiSuccess } from "../types.js";
4
+ const c = initContract();
5
+ export default c.router({
6
+ init: {
7
+ method: "POST",
8
+ path: "/media-stream/init",
9
+ description: "Initialize a new media stream from a YouTube video",
10
+ body: z.object({
11
+ videoId: z.string(),
12
+ }),
13
+ responses: {
14
+ 200: apiSuccess(z.object({
15
+ streamId: z.string(),
16
+ })),
17
+ 400: z.union([
18
+ ZodErrorSchema,
19
+ apiError(z.literal("INVALID_VIDEO_ID"), z.literal("The provided video ID is invalid")),
20
+ ]),
21
+ // 401: apiError(z.literal("UNAUTHORIZED"), z.literal("Unauthorized")),
22
+ 500: apiError(z.literal("INTERNAL_SERVER_ERROR"), z.string()),
23
+ },
24
+ },
25
+ get: {
26
+ method: "GET",
27
+ path: "/media-stream/get/:streamId",
28
+ description: "Get media stream info",
29
+ responses: {
30
+ 200: apiSuccess(z.object({
31
+ streamId: z.string(),
32
+ startTime: z.number(),
33
+ duration: z.number(),
34
+ url: z.string(),
35
+ paused: z.boolean(),
36
+ })),
37
+ 400: z.union([
38
+ ZodErrorSchema,
39
+ apiError(z.literal("INVALID_STREAM_ID"), z.literal("The provided stream ID is invalid")),
40
+ ]),
41
+ // 401: apiError(z.literal("UNAUTHORIZED"), z.literal("Unauthorized")),
42
+ 500: apiError(z.literal("INTERNAL_SERVER_ERROR"), z.string()),
43
+ },
44
+ },
45
+ play: {
46
+ method: "POST",
47
+ path: "/media-stream/play/:streamId",
48
+ description: "Play a media stream",
49
+ body: z.undefined(),
50
+ responses: {
51
+ 200: apiSuccess(z.undefined()),
52
+ 400: z.union([
53
+ ZodErrorSchema,
54
+ apiError(z.literal("INVALID_STREAM_ID"), z.literal("The provided stream ID is invalid")),
55
+ ]),
56
+ // 401: apiError(z.literal("UNAUTHORIZED"), z.literal("Unauthorized")),
57
+ 404: apiError(z.literal("STREAM_NOT_FOUND"), z.literal("The requested stream was not found")),
58
+ 500: apiError(z.literal("INTERNAL_SERVER_ERROR"), z.string()),
59
+ },
60
+ },
61
+ pause: {
62
+ method: "POST",
63
+ path: "/media-stream/pause/:streamId",
64
+ description: "Pause a media stream",
65
+ body: z.undefined(),
66
+ responses: {
67
+ 200: apiSuccess(z.undefined()),
68
+ 400: z.union([
69
+ ZodErrorSchema,
70
+ apiError(z.literal("INVALID_STREAM_ID"), z.literal("The provided stream ID is invalid")),
71
+ ]),
72
+ // 401: apiError(z.literal("UNAUTHORIZED"), z.literal("Unauthorized")),
73
+ 404: apiError(z.literal("STREAM_NOT_FOUND"), z.literal("The requested stream was not found")),
74
+ 500: apiError(z.literal("INTERNAL_SERVER_ERROR"), z.string()),
75
+ },
76
+ },
77
+ seek: {
78
+ method: "POST",
79
+ path: "/media-stream/seek/:streamId",
80
+ description: "Seek a media stream",
81
+ query: z.object({
82
+ time: z.coerce.number().min(0),
83
+ }),
84
+ body: z.undefined(),
85
+ responses: {
86
+ 200: apiSuccess(z.undefined()),
87
+ 400: z.union([
88
+ ZodErrorSchema,
89
+ apiError(z.literal("INVALID_STREAM_ID"), z.literal("The provided stream ID is invalid")),
90
+ ]),
91
+ // 401: apiError(z.literal("UNAUTHORIZED"), z.literal("Unauthorized")),
92
+ 404: apiError(z.literal("STREAM_NOT_FOUND"), z.literal("The requested stream was not found")),
93
+ 500: apiError(z.literal("INTERNAL_SERVER_ERROR"), z.string()),
94
+ },
95
+ },
96
+ stream: {
97
+ method: "GET",
98
+ path: "/media-stream/stream/:streamId",
99
+ description: "Get media stream by stream ID",
100
+ responses: {
101
+ 200: apiSuccess(z.any()),
102
+ 400: apiError(z.literal("INVALID_VIDEO_ID"), z.literal("The provided video ID is invalid")),
103
+ // 401: apiError(z.literal("UNAUTHORIZED"), z.literal("Unauthorized")),
104
+ 404: apiError(z.literal("STREAM_NOT_FOUND"), z.literal("The requested stream was not found")),
105
+ 500: apiError(z.literal("INTERNAL_SERVER_ERROR"), z.string()),
106
+ },
107
+ },
108
+ });
@@ -0,0 +1,157 @@
1
+ import { z } from "zod";
2
+ declare const _default: {
3
+ sync: {
4
+ description: "Synchronize time with the server";
5
+ method: "POST";
6
+ body: z.ZodObject<{
7
+ clientTime: z.ZodNumber;
8
+ }, "strip", z.ZodTypeAny, {
9
+ clientTime: number;
10
+ }, {
11
+ clientTime: number;
12
+ }>;
13
+ path: "/sync";
14
+ responses: {
15
+ 200: z.ZodObject<{
16
+ clientTime: z.ZodNumber;
17
+ serverTime: z.ZodNumber;
18
+ }, "strip", z.ZodTypeAny, {
19
+ clientTime: number;
20
+ serverTime: number;
21
+ }, {
22
+ clientTime: number;
23
+ serverTime: number;
24
+ }>;
25
+ 400: z.ZodObject<{
26
+ name: z.ZodLiteral<"ZodError">;
27
+ issues: z.ZodArray<z.ZodObject<{
28
+ path: z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber]>, "many">;
29
+ message: z.ZodOptional<z.ZodString>;
30
+ code: z.ZodNativeEnum<{
31
+ invalid_type: "invalid_type";
32
+ invalid_literal: "invalid_literal";
33
+ custom: "custom";
34
+ invalid_union: "invalid_union";
35
+ invalid_union_discriminator: "invalid_union_discriminator";
36
+ invalid_enum_value: "invalid_enum_value";
37
+ unrecognized_keys: "unrecognized_keys";
38
+ invalid_arguments: "invalid_arguments";
39
+ invalid_return_type: "invalid_return_type";
40
+ invalid_date: "invalid_date";
41
+ invalid_string: "invalid_string";
42
+ too_small: "too_small";
43
+ too_big: "too_big";
44
+ invalid_intersection_types: "invalid_intersection_types";
45
+ not_multiple_of: "not_multiple_of";
46
+ not_finite: "not_finite";
47
+ }>;
48
+ }, "strip", z.ZodAny, z.objectOutputType<{
49
+ path: z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber]>, "many">;
50
+ message: z.ZodOptional<z.ZodString>;
51
+ code: z.ZodNativeEnum<{
52
+ invalid_type: "invalid_type";
53
+ invalid_literal: "invalid_literal";
54
+ custom: "custom";
55
+ invalid_union: "invalid_union";
56
+ invalid_union_discriminator: "invalid_union_discriminator";
57
+ invalid_enum_value: "invalid_enum_value";
58
+ unrecognized_keys: "unrecognized_keys";
59
+ invalid_arguments: "invalid_arguments";
60
+ invalid_return_type: "invalid_return_type";
61
+ invalid_date: "invalid_date";
62
+ invalid_string: "invalid_string";
63
+ too_small: "too_small";
64
+ too_big: "too_big";
65
+ invalid_intersection_types: "invalid_intersection_types";
66
+ not_multiple_of: "not_multiple_of";
67
+ not_finite: "not_finite";
68
+ }>;
69
+ }, z.ZodAny, "strip">, z.objectInputType<{
70
+ path: z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber]>, "many">;
71
+ message: z.ZodOptional<z.ZodString>;
72
+ code: z.ZodNativeEnum<{
73
+ invalid_type: "invalid_type";
74
+ invalid_literal: "invalid_literal";
75
+ custom: "custom";
76
+ invalid_union: "invalid_union";
77
+ invalid_union_discriminator: "invalid_union_discriminator";
78
+ invalid_enum_value: "invalid_enum_value";
79
+ unrecognized_keys: "unrecognized_keys";
80
+ invalid_arguments: "invalid_arguments";
81
+ invalid_return_type: "invalid_return_type";
82
+ invalid_date: "invalid_date";
83
+ invalid_string: "invalid_string";
84
+ too_small: "too_small";
85
+ too_big: "too_big";
86
+ invalid_intersection_types: "invalid_intersection_types";
87
+ not_multiple_of: "not_multiple_of";
88
+ not_finite: "not_finite";
89
+ }>;
90
+ }, z.ZodAny, "strip">>, "many">;
91
+ }, "strip", z.ZodTypeAny, {
92
+ name: "ZodError";
93
+ issues: z.objectOutputType<{
94
+ path: z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber]>, "many">;
95
+ message: z.ZodOptional<z.ZodString>;
96
+ code: z.ZodNativeEnum<{
97
+ invalid_type: "invalid_type";
98
+ invalid_literal: "invalid_literal";
99
+ custom: "custom";
100
+ invalid_union: "invalid_union";
101
+ invalid_union_discriminator: "invalid_union_discriminator";
102
+ invalid_enum_value: "invalid_enum_value";
103
+ unrecognized_keys: "unrecognized_keys";
104
+ invalid_arguments: "invalid_arguments";
105
+ invalid_return_type: "invalid_return_type";
106
+ invalid_date: "invalid_date";
107
+ invalid_string: "invalid_string";
108
+ too_small: "too_small";
109
+ too_big: "too_big";
110
+ invalid_intersection_types: "invalid_intersection_types";
111
+ not_multiple_of: "not_multiple_of";
112
+ not_finite: "not_finite";
113
+ }>;
114
+ }, z.ZodAny, "strip">[];
115
+ }, {
116
+ name: "ZodError";
117
+ issues: z.objectInputType<{
118
+ path: z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber]>, "many">;
119
+ message: z.ZodOptional<z.ZodString>;
120
+ code: z.ZodNativeEnum<{
121
+ invalid_type: "invalid_type";
122
+ invalid_literal: "invalid_literal";
123
+ custom: "custom";
124
+ invalid_union: "invalid_union";
125
+ invalid_union_discriminator: "invalid_union_discriminator";
126
+ invalid_enum_value: "invalid_enum_value";
127
+ unrecognized_keys: "unrecognized_keys";
128
+ invalid_arguments: "invalid_arguments";
129
+ invalid_return_type: "invalid_return_type";
130
+ invalid_date: "invalid_date";
131
+ invalid_string: "invalid_string";
132
+ too_small: "too_small";
133
+ too_big: "too_big";
134
+ invalid_intersection_types: "invalid_intersection_types";
135
+ not_multiple_of: "not_multiple_of";
136
+ not_finite: "not_finite";
137
+ }>;
138
+ }, z.ZodAny, "strip">[];
139
+ }>;
140
+ };
141
+ };
142
+ time: {
143
+ description: "Get the current server time";
144
+ method: "GET";
145
+ path: "/time";
146
+ responses: {
147
+ 200: z.ZodObject<{
148
+ serverTime: z.ZodNumber;
149
+ }, "strip", z.ZodTypeAny, {
150
+ serverTime: number;
151
+ }, {
152
+ serverTime: number;
153
+ }>;
154
+ };
155
+ };
156
+ };
157
+ export default _default;
@@ -0,0 +1,31 @@
1
+ import { initContract, ZodErrorSchema } from "@ts-rest/core";
2
+ import { z } from "zod";
3
+ import { apiSuccess } from "../types.js";
4
+ const c = initContract();
5
+ export default c.router({
6
+ sync: {
7
+ method: "POST",
8
+ path: "/sync",
9
+ description: "Synchronize time with the server",
10
+ body: z.object({
11
+ clientTime: z.number().int().nonnegative(),
12
+ }),
13
+ responses: {
14
+ 200: apiSuccess(z.object({
15
+ clientTime: z.number().int().nonnegative(),
16
+ serverTime: z.number().int().nonnegative(),
17
+ })),
18
+ 400: ZodErrorSchema,
19
+ },
20
+ },
21
+ time: {
22
+ method: "GET",
23
+ path: "/time",
24
+ description: "Get the current server time",
25
+ responses: {
26
+ 200: apiSuccess(z.object({
27
+ serverTime: z.number().int().nonnegative(),
28
+ })),
29
+ },
30
+ },
31
+ });
@@ -0,0 +1,168 @@
1
+ import { z } from "zod";
2
+ declare const _default: {
3
+ getLink: {
4
+ query: z.ZodObject<{
5
+ quality: z.ZodOptional<z.ZodEnum<["highest", "highestaudio", "highestvideo", "lowest", "lowestaudio", "lowestvideo"]>>;
6
+ filter: z.ZodOptional<z.ZodEnum<["audio", "audioandvideo", "audioonly", "video", "videoandaudio", "videoonly"]>>;
7
+ }, "strip", z.ZodTypeAny, {
8
+ filter?: "audio" | "audioandvideo" | "audioonly" | "video" | "videoandaudio" | "videoonly" | undefined;
9
+ quality?: "highest" | "highestaudio" | "highestvideo" | "lowest" | "lowestaudio" | "lowestvideo" | undefined;
10
+ }, {
11
+ filter?: "audio" | "audioandvideo" | "audioonly" | "video" | "videoandaudio" | "videoonly" | undefined;
12
+ quality?: "highest" | "highestaudio" | "highestvideo" | "lowest" | "lowestaudio" | "lowestvideo" | undefined;
13
+ }>;
14
+ description: "Get direct audio link from a YouTube video URL";
15
+ method: "GET";
16
+ path: "/youtube/audio-link/:videoId";
17
+ responses: {
18
+ 200: z.ZodObject<{
19
+ url: z.ZodString;
20
+ }, "strip", z.ZodTypeAny, {
21
+ url: string;
22
+ }, {
23
+ url: string;
24
+ }>;
25
+ 400: z.ZodUnion<[z.ZodObject<{
26
+ name: z.ZodLiteral<"ZodError">;
27
+ issues: z.ZodArray<z.ZodObject<{
28
+ path: z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber]>, "many">;
29
+ message: z.ZodOptional<z.ZodString>;
30
+ code: z.ZodNativeEnum<{
31
+ invalid_type: "invalid_type";
32
+ invalid_literal: "invalid_literal";
33
+ custom: "custom";
34
+ invalid_union: "invalid_union";
35
+ invalid_union_discriminator: "invalid_union_discriminator";
36
+ invalid_enum_value: "invalid_enum_value";
37
+ unrecognized_keys: "unrecognized_keys";
38
+ invalid_arguments: "invalid_arguments";
39
+ invalid_return_type: "invalid_return_type";
40
+ invalid_date: "invalid_date";
41
+ invalid_string: "invalid_string";
42
+ too_small: "too_small";
43
+ too_big: "too_big";
44
+ invalid_intersection_types: "invalid_intersection_types";
45
+ not_multiple_of: "not_multiple_of";
46
+ not_finite: "not_finite";
47
+ }>;
48
+ }, "strip", z.ZodAny, z.objectOutputType<{
49
+ path: z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber]>, "many">;
50
+ message: z.ZodOptional<z.ZodString>;
51
+ code: z.ZodNativeEnum<{
52
+ invalid_type: "invalid_type";
53
+ invalid_literal: "invalid_literal";
54
+ custom: "custom";
55
+ invalid_union: "invalid_union";
56
+ invalid_union_discriminator: "invalid_union_discriminator";
57
+ invalid_enum_value: "invalid_enum_value";
58
+ unrecognized_keys: "unrecognized_keys";
59
+ invalid_arguments: "invalid_arguments";
60
+ invalid_return_type: "invalid_return_type";
61
+ invalid_date: "invalid_date";
62
+ invalid_string: "invalid_string";
63
+ too_small: "too_small";
64
+ too_big: "too_big";
65
+ invalid_intersection_types: "invalid_intersection_types";
66
+ not_multiple_of: "not_multiple_of";
67
+ not_finite: "not_finite";
68
+ }>;
69
+ }, z.ZodAny, "strip">, z.objectInputType<{
70
+ path: z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber]>, "many">;
71
+ message: z.ZodOptional<z.ZodString>;
72
+ code: z.ZodNativeEnum<{
73
+ invalid_type: "invalid_type";
74
+ invalid_literal: "invalid_literal";
75
+ custom: "custom";
76
+ invalid_union: "invalid_union";
77
+ invalid_union_discriminator: "invalid_union_discriminator";
78
+ invalid_enum_value: "invalid_enum_value";
79
+ unrecognized_keys: "unrecognized_keys";
80
+ invalid_arguments: "invalid_arguments";
81
+ invalid_return_type: "invalid_return_type";
82
+ invalid_date: "invalid_date";
83
+ invalid_string: "invalid_string";
84
+ too_small: "too_small";
85
+ too_big: "too_big";
86
+ invalid_intersection_types: "invalid_intersection_types";
87
+ not_multiple_of: "not_multiple_of";
88
+ not_finite: "not_finite";
89
+ }>;
90
+ }, z.ZodAny, "strip">>, "many">;
91
+ }, "strip", z.ZodTypeAny, {
92
+ name: "ZodError";
93
+ issues: z.objectOutputType<{
94
+ path: z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber]>, "many">;
95
+ message: z.ZodOptional<z.ZodString>;
96
+ code: z.ZodNativeEnum<{
97
+ invalid_type: "invalid_type";
98
+ invalid_literal: "invalid_literal";
99
+ custom: "custom";
100
+ invalid_union: "invalid_union";
101
+ invalid_union_discriminator: "invalid_union_discriminator";
102
+ invalid_enum_value: "invalid_enum_value";
103
+ unrecognized_keys: "unrecognized_keys";
104
+ invalid_arguments: "invalid_arguments";
105
+ invalid_return_type: "invalid_return_type";
106
+ invalid_date: "invalid_date";
107
+ invalid_string: "invalid_string";
108
+ too_small: "too_small";
109
+ too_big: "too_big";
110
+ invalid_intersection_types: "invalid_intersection_types";
111
+ not_multiple_of: "not_multiple_of";
112
+ not_finite: "not_finite";
113
+ }>;
114
+ }, z.ZodAny, "strip">[];
115
+ }, {
116
+ name: "ZodError";
117
+ issues: z.objectInputType<{
118
+ path: z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber]>, "many">;
119
+ message: z.ZodOptional<z.ZodString>;
120
+ code: z.ZodNativeEnum<{
121
+ invalid_type: "invalid_type";
122
+ invalid_literal: "invalid_literal";
123
+ custom: "custom";
124
+ invalid_union: "invalid_union";
125
+ invalid_union_discriminator: "invalid_union_discriminator";
126
+ invalid_enum_value: "invalid_enum_value";
127
+ unrecognized_keys: "unrecognized_keys";
128
+ invalid_arguments: "invalid_arguments";
129
+ invalid_return_type: "invalid_return_type";
130
+ invalid_date: "invalid_date";
131
+ invalid_string: "invalid_string";
132
+ too_small: "too_small";
133
+ too_big: "too_big";
134
+ invalid_intersection_types: "invalid_intersection_types";
135
+ not_multiple_of: "not_multiple_of";
136
+ not_finite: "not_finite";
137
+ }>;
138
+ }, z.ZodAny, "strip">[];
139
+ }>, z.ZodObject<{
140
+ code: z.ZodType<"INVALID_VIDEO_ID", z.ZodTypeDef, "INVALID_VIDEO_ID">;
141
+ error: z.ZodType<"The provided video ID is invalid", z.ZodTypeDef, "The provided video ID is invalid">;
142
+ name: z.ZodLiteral<"APIError">;
143
+ }, "strip", z.ZodTypeAny, {
144
+ code: "INVALID_VIDEO_ID";
145
+ error: "The provided video ID is invalid";
146
+ name: "APIError";
147
+ }, {
148
+ code: "INVALID_VIDEO_ID";
149
+ error: "The provided video ID is invalid";
150
+ name: "APIError";
151
+ }>]>;
152
+ 500: z.ZodObject<{
153
+ code: z.ZodType<"INTERNAL_SERVER_ERROR", z.ZodTypeDef, "INTERNAL_SERVER_ERROR">;
154
+ error: z.ZodType<string, z.ZodTypeDef, string>;
155
+ name: z.ZodLiteral<"APIError">;
156
+ }, "strip", z.ZodTypeAny, {
157
+ code: "INTERNAL_SERVER_ERROR";
158
+ error: string;
159
+ name: "APIError";
160
+ }, {
161
+ code: "INTERNAL_SERVER_ERROR";
162
+ error: string;
163
+ name: "APIError";
164
+ }>;
165
+ };
166
+ };
167
+ };
168
+ export default _default;
@@ -0,0 +1,27 @@
1
+ import { initContract, ZodErrorSchema } from "@ts-rest/core";
2
+ import { z } from "zod";
3
+ import { apiError, apiSuccess } from "../types.js";
4
+ import { youTubeFilterSchema, youTubeQualitySchema } from "../types/youtube.js";
5
+ const c = initContract();
6
+ export default c.router({
7
+ getLink: {
8
+ method: "GET",
9
+ path: "/youtube/audio-link/:videoId",
10
+ description: "Get direct audio link from a YouTube video URL",
11
+ query: z.object({
12
+ quality: youTubeQualitySchema.optional(),
13
+ filter: youTubeFilterSchema.optional(),
14
+ }),
15
+ responses: {
16
+ 200: apiSuccess(z.object({
17
+ url: z.string().url(),
18
+ })),
19
+ 400: z.union([
20
+ ZodErrorSchema,
21
+ apiError(z.literal("INVALID_VIDEO_ID"), z.literal("The provided video ID is invalid")),
22
+ ]),
23
+ // 401: apiError(z.literal("UNAUTHORIZED"), z.literal("Unauthorized")),
24
+ 500: apiError(z.literal("INTERNAL_SERVER_ERROR"), z.string()),
25
+ },
26
+ },
27
+ });
@@ -0,0 +1,4 @@
1
+ export * from "./common.js";
2
+ export * from "./client.js";
3
+ export * from "./server.js";
4
+ export * from "./socket/index.js";
package/dist/index.js ADDED
@@ -0,0 +1,4 @@
1
+ export * from "./common.js";
2
+ export * from "./client.js";
3
+ export * from "./server.js";
4
+ export * from "./socket/index.js";
@@ -0,0 +1 @@
1
+ export * from "./common.js";
package/dist/server.js ADDED
@@ -0,0 +1,18 @@
1
+ export * from "./common.js";
2
+ // import type { JwtPayload } from "jsonwebtoken";
3
+ // export async function JWTVerify(
4
+ // token: string,
5
+ // pubKey: string
6
+ // ): Promise<JwtPayload | string | undefined> {
7
+ // if (typeof window !== "undefined") {
8
+ // throw new Error(
9
+ // "JWTverify should not be called in the browser context"
10
+ // );
11
+ // }
12
+ // return new Promise(async (resolve) => {
13
+ // const jwt = (await import("jsonwebtoken")).default;
14
+ // jwt.verify(token, pubKey, (err, decoded) => {
15
+ // resolve(err ? undefined : decoded);
16
+ // });
17
+ // });
18
+ // }
@@ -0,0 +1,2 @@
1
+ export * from "./mediaStream.js";
2
+ export * from "./types.js";
@@ -0,0 +1,2 @@
1
+ export * from "./mediaStream.js";
2
+ export * from "./types.js";
@@ -0,0 +1,9 @@
1
+ export interface SocketClientToServerMediaStream {
2
+ mediaStreamListen: (streamId: string, callback: (success: boolean) => void) => void;
3
+ mediaStreamUnlisten: (streamId: string, callback: (success: boolean) => void) => void;
4
+ }
5
+ export interface SocketServerToClientMediaStream {
6
+ mediaStreamPlay: (streamId: string, startTime: number) => void;
7
+ mediaStreamPause: (streamId: string) => void;
8
+ mediaStreamSeek: (streamId: string, startTime: number) => void;
9
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ import { SocketClientToServerMediaStream, SocketServerToClientMediaStream } from "./mediaStream.js";
2
+ export interface ClientToServerEvents extends SocketClientToServerMediaStream {
3
+ }
4
+ export interface ServerToClientEvents extends SocketServerToClientMediaStream {
5
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export * from "./youtube.js";
@@ -0,0 +1 @@
1
+ export * from "./youtube.js";
@@ -0,0 +1,5 @@
1
+ import { z } from "zod";
2
+ export declare const youTubeQualitySchema: z.ZodEnum<["highest", "highestaudio", "highestvideo", "lowest", "lowestaudio", "lowestvideo"]>;
3
+ export type YouTubeQuality = z.infer<typeof youTubeQualitySchema>;
4
+ export declare const youTubeFilterSchema: z.ZodEnum<["audio", "audioandvideo", "audioonly", "video", "videoandaudio", "videoonly"]>;
5
+ export type YouTubeFilter = z.infer<typeof youTubeFilterSchema>;
@@ -0,0 +1,17 @@
1
+ import { z } from "zod";
2
+ export const youTubeQualitySchema = z.enum([
3
+ "highest",
4
+ "highestaudio",
5
+ "highestvideo",
6
+ "lowest",
7
+ "lowestaudio",
8
+ "lowestvideo",
9
+ ]);
10
+ export const youTubeFilterSchema = z.enum([
11
+ "audio",
12
+ "audioandvideo",
13
+ "audioonly",
14
+ "video",
15
+ "videoandaudio",
16
+ "videoonly",
17
+ ]);
@@ -0,0 +1,31 @@
1
+ import { z, ZodType } from "zod";
2
+ export declare const apiSuccess: <T>(schema: T) => T;
3
+ export declare const apiError: <T, U>(code: ZodType<T>, error: ZodType<U>) => z.ZodObject<{
4
+ code: z.ZodType<T, z.ZodTypeDef, T>;
5
+ error: z.ZodType<U, z.ZodTypeDef, U>;
6
+ name: z.ZodLiteral<"APIError">;
7
+ }, "strip", z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<{
8
+ code: z.ZodType<T, z.ZodTypeDef, T>;
9
+ error: z.ZodType<U, z.ZodTypeDef, U>;
10
+ name: z.ZodLiteral<"APIError">;
11
+ }>, any> extends infer T_1 ? { [k in keyof T_1]: T_1[k]; } : never, z.baseObjectInputType<{
12
+ code: z.ZodType<T, z.ZodTypeDef, T>;
13
+ error: z.ZodType<U, z.ZodTypeDef, U>;
14
+ name: z.ZodLiteral<"APIError">;
15
+ }> extends infer T_2 ? { [k_1 in keyof T_2]: T_2[k_1]; } : never>;
16
+ export declare const apiErrorData: <T, U, V>(code: ZodType<T>, error: ZodType<U>, data: ZodType<V>) => z.ZodObject<{
17
+ code: z.ZodType<T, z.ZodTypeDef, T>;
18
+ error: z.ZodType<U, z.ZodTypeDef, U>;
19
+ name: z.ZodLiteral<"APIError">;
20
+ data: z.ZodType<V, z.ZodTypeDef, V>;
21
+ }, "strip", z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<{
22
+ code: z.ZodType<T, z.ZodTypeDef, T>;
23
+ error: z.ZodType<U, z.ZodTypeDef, U>;
24
+ name: z.ZodLiteral<"APIError">;
25
+ data: z.ZodType<V, z.ZodTypeDef, V>;
26
+ }>, any> extends infer T_1 ? { [k in keyof T_1]: T_1[k]; } : never, z.baseObjectInputType<{
27
+ code: z.ZodType<T, z.ZodTypeDef, T>;
28
+ error: z.ZodType<U, z.ZodTypeDef, U>;
29
+ name: z.ZodLiteral<"APIError">;
30
+ data: z.ZodType<V, z.ZodTypeDef, V>;
31
+ }> extends infer T_2 ? { [k_1 in keyof T_2]: T_2[k_1]; } : never>;
package/dist/types.js ADDED
@@ -0,0 +1,14 @@
1
+ import { z } from "zod";
2
+ // export const apiSuccess = <T>(schema: ZodType<T>) => schema;
3
+ export const apiSuccess = (schema) => schema;
4
+ export const apiError = (code, error) => z.object({
5
+ code,
6
+ error,
7
+ name: z.literal("APIError"),
8
+ });
9
+ export const apiErrorData = (code, error, data) => z.object({
10
+ code,
11
+ error,
12
+ name: z.literal("APIError"),
13
+ data,
14
+ });