@darco2903/altv-web-api 1.0.0 → 1.2.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/dist/client.d.ts CHANGED
@@ -203,8 +203,10 @@ export declare function createClient(origin: string): {
203
203
  status: 200;
204
204
  body: {
205
205
  streamId: string;
206
+ title: string;
206
207
  startTime: number;
207
208
  duration: number;
209
+ currentTime: number;
208
210
  url: string;
209
211
  paused: boolean;
210
212
  };
@@ -487,20 +487,26 @@ declare const _default: {
487
487
  responses: {
488
488
  200: import("zod").ZodObject<{
489
489
  streamId: import("zod").ZodString;
490
+ title: import("zod").ZodString;
490
491
  startTime: import("zod").ZodNumber;
491
492
  duration: import("zod").ZodNumber;
493
+ currentTime: import("zod").ZodNumber;
492
494
  url: import("zod").ZodString;
493
495
  paused: import("zod").ZodBoolean;
494
496
  }, "strip", import("zod").ZodTypeAny, {
495
497
  streamId: string;
498
+ title: string;
496
499
  startTime: number;
497
500
  duration: number;
501
+ currentTime: number;
498
502
  url: string;
499
503
  paused: boolean;
500
504
  }, {
501
505
  streamId: string;
506
+ title: string;
502
507
  startTime: number;
503
508
  duration: number;
509
+ currentTime: number;
504
510
  url: string;
505
511
  paused: boolean;
506
512
  }>;
@@ -652,7 +658,7 @@ declare const _default: {
652
658
  body: import("zod").ZodUndefined;
653
659
  path: "/api/v2/media-stream/play/:streamId";
654
660
  responses: {
655
- 200: import("zod").ZodUndefined;
661
+ 200: typeof import("@ts-rest/core").ContractNoBody;
656
662
  400: import("zod").ZodUnion<[import("zod").ZodObject<{
657
663
  name: import("zod").ZodLiteral<"ZodError">;
658
664
  issues: import("zod").ZodArray<import("zod").ZodObject<{
@@ -814,7 +820,7 @@ declare const _default: {
814
820
  body: import("zod").ZodUndefined;
815
821
  path: "/api/v2/media-stream/pause/:streamId";
816
822
  responses: {
817
- 200: import("zod").ZodUndefined;
823
+ 200: typeof import("@ts-rest/core").ContractNoBody;
818
824
  400: import("zod").ZodUnion<[import("zod").ZodObject<{
819
825
  name: import("zod").ZodLiteral<"ZodError">;
820
826
  issues: import("zod").ZodArray<import("zod").ZodObject<{
@@ -983,7 +989,7 @@ declare const _default: {
983
989
  body: import("zod").ZodUndefined;
984
990
  path: "/api/v2/media-stream/seek/:streamId";
985
991
  responses: {
986
- 200: import("zod").ZodUndefined;
992
+ 200: typeof import("@ts-rest/core").ContractNoBody;
987
993
  400: import("zod").ZodUnion<[import("zod").ZodObject<{
988
994
  name: import("zod").ZodLiteral<"ZodError">;
989
995
  issues: import("zod").ZodArray<import("zod").ZodObject<{
@@ -168,20 +168,28 @@ declare const _default: {
168
168
  responses: {
169
169
  200: z.ZodObject<{
170
170
  streamId: z.ZodString;
171
+ title: z.ZodString;
171
172
  startTime: z.ZodNumber;
173
+ /** seconds */
172
174
  duration: z.ZodNumber;
175
+ /** seconds, media position when the response was sent */
176
+ currentTime: z.ZodNumber;
173
177
  url: z.ZodString;
174
178
  paused: z.ZodBoolean;
175
179
  }, "strip", z.ZodTypeAny, {
176
180
  streamId: string;
181
+ title: string;
177
182
  startTime: number;
178
183
  duration: number;
184
+ currentTime: number;
179
185
  url: string;
180
186
  paused: boolean;
181
187
  }, {
182
188
  streamId: string;
189
+ title: string;
183
190
  startTime: number;
184
191
  duration: number;
192
+ currentTime: number;
185
193
  url: string;
186
194
  paused: boolean;
187
195
  }>;
@@ -333,7 +341,7 @@ declare const _default: {
333
341
  body: z.ZodUndefined;
334
342
  path: "/media-stream/play/:streamId";
335
343
  responses: {
336
- 200: z.ZodUndefined;
344
+ 200: typeof import("@ts-rest/core").ContractNoBody;
337
345
  400: z.ZodUnion<[z.ZodObject<{
338
346
  name: z.ZodLiteral<"ZodError">;
339
347
  issues: z.ZodArray<z.ZodObject<{
@@ -495,7 +503,7 @@ declare const _default: {
495
503
  body: z.ZodUndefined;
496
504
  path: "/media-stream/pause/:streamId";
497
505
  responses: {
498
- 200: z.ZodUndefined;
506
+ 200: typeof import("@ts-rest/core").ContractNoBody;
499
507
  400: z.ZodUnion<[z.ZodObject<{
500
508
  name: z.ZodLiteral<"ZodError">;
501
509
  issues: z.ZodArray<z.ZodObject<{
@@ -664,7 +672,7 @@ declare const _default: {
664
672
  body: z.ZodUndefined;
665
673
  path: "/media-stream/seek/:streamId";
666
674
  responses: {
667
- 200: z.ZodUndefined;
675
+ 200: typeof import("@ts-rest/core").ContractNoBody;
668
676
  400: z.ZodUnion<[z.ZodObject<{
669
677
  name: z.ZodLiteral<"ZodError">;
670
678
  issues: z.ZodArray<z.ZodObject<{
@@ -29,8 +29,12 @@ export default c.router({
29
29
  responses: {
30
30
  200: apiSuccess(z.object({
31
31
  streamId: z.string(),
32
+ title: z.string(),
32
33
  startTime: z.number(),
34
+ /** seconds */
33
35
  duration: z.number(),
36
+ /** seconds, media position when the response was sent */
37
+ currentTime: z.number(),
34
38
  url: z.string(),
35
39
  paused: z.boolean(),
36
40
  })),
@@ -48,7 +52,7 @@ export default c.router({
48
52
  description: "Play a media stream",
49
53
  body: z.undefined(),
50
54
  responses: {
51
- 200: apiSuccess(z.undefined()),
55
+ 200: c.noBody(),
52
56
  400: z.union([
53
57
  ZodErrorSchema,
54
58
  apiError(z.literal("INVALID_STREAM_ID"), z.literal("The provided stream ID is invalid")),
@@ -64,7 +68,7 @@ export default c.router({
64
68
  description: "Pause a media stream",
65
69
  body: z.undefined(),
66
70
  responses: {
67
- 200: apiSuccess(z.undefined()),
71
+ 200: c.noBody(),
68
72
  400: z.union([
69
73
  ZodErrorSchema,
70
74
  apiError(z.literal("INVALID_STREAM_ID"), z.literal("The provided stream ID is invalid")),
@@ -83,7 +87,7 @@ export default c.router({
83
87
  }),
84
88
  body: z.undefined(),
85
89
  responses: {
86
- 200: apiSuccess(z.undefined()),
90
+ 200: c.noBody(),
87
91
  400: z.union([
88
92
  ZodErrorSchema,
89
93
  apiError(z.literal("INVALID_STREAM_ID"), z.literal("The provided stream ID is invalid")),
@@ -2,8 +2,17 @@ export interface SocketClientToServerMediaStream {
2
2
  mediaStreamListen: (streamId: string, callback: (success: boolean) => void) => void;
3
3
  mediaStreamUnlisten: (streamId: string, callback: (success: boolean) => void) => void;
4
4
  }
5
+ /**
6
+ * - `ended`: the media played to the end, clients still have the last seconds buffered
7
+ * - `idle`: nobody listened for a while
8
+ * - `error`: the media couldn't be read
9
+ * - `shutdown`: the server is stopping
10
+ */
11
+ export type MediaStreamEndReason = "ended" | "idle" | "error" | "shutdown";
5
12
  export interface SocketServerToClientMediaStream {
6
13
  mediaStreamPlay: (streamId: string, startTime: number) => void;
7
14
  mediaStreamPause: (streamId: string) => void;
8
15
  mediaStreamSeek: (streamId: string, startTime: number) => void;
16
+ /** The stream is gone, every request about it now returns 404 */
17
+ mediaStreamEnd: (streamId: string, reason: MediaStreamEndReason) => void;
9
18
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@darco2903/altv-web-api",
3
- "version": "1.0.0",
3
+ "version": "1.2.0",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "keywords": [],
@@ -39,11 +39,13 @@
39
39
  "access": "public"
40
40
  },
41
41
  "dependencies": {
42
- "@ts-rest/core": "^3.52.1",
43
42
  "@ts-rest/open-api": "^3.52.1",
44
43
  "socket.io-client": "^4.8.1",
45
44
  "zod": "^3.25.76"
46
45
  },
46
+ "peerDependencies": {
47
+ "@ts-rest/core": "^3.52.1"
48
+ },
47
49
  "devDependencies": {
48
50
  "@types/node": "^24.8.1",
49
51
  "prettier": "^3.6.2",