@fastpix/fastpix-node 1.0.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/index.cjs ADDED
@@ -0,0 +1,635 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ default: () => index_default
24
+ });
25
+ module.exports = __toCommonJS(index_exports);
26
+ var import_buffer = require("buffer");
27
+
28
+ // src/NetworkFetcher/index.ts
29
+ var Fetcher = class {
30
+ // Fetches data from the specified URL using the provided headers.
31
+ async fetchData(url, header) {
32
+ if (!url || !header) {
33
+ throw new Error("Invalid arguments: URL and header are required.");
34
+ }
35
+ try {
36
+ const response = await fetch(url, header);
37
+ if (response.ok) {
38
+ const successResponse = await response.json();
39
+ return successResponse;
40
+ }
41
+ if ([400, 401, 403, 404, 409, 422].includes(response.status)) {
42
+ const errorResponse = await response.json();
43
+ const configErrorResponse = {
44
+ success: false,
45
+ error: {
46
+ code: response.status,
47
+ message: errorResponse?.error?.message ?? response.statusText ?? "An unexpected error occurred"
48
+ }
49
+ };
50
+ if (errorResponse?.error?.fields) {
51
+ configErrorResponse.error.fields = errorResponse.error.fields;
52
+ }
53
+ return configErrorResponse;
54
+ }
55
+ return {
56
+ success: false,
57
+ error: {
58
+ code: response.status ?? 500,
59
+ message: response.statusText ?? "An internal server error occurred."
60
+ }
61
+ };
62
+ } catch (error) {
63
+ throw new Error(
64
+ `An error occurred while fetching data: ${error?.message ?? "Internal error"}`
65
+ );
66
+ }
67
+ }
68
+ // Constructs a complete URL based on the provided request object, path, and query parameters.
69
+ constructUrl(requestObj, path = "", queryParams = "") {
70
+ const protocol = requestObj?.httpAgent ?? "https";
71
+ const domain = requestObj?.domain ?? "v1.fastpix.io";
72
+ return `${protocol}://${domain}/${path}${queryParams}`;
73
+ }
74
+ // Constructs HTTP headers for a request based on the provided request object.
75
+ constructHeaders(requestObj) {
76
+ if (!requestObj?.encodedAuthToken) {
77
+ throw new Error("Authorization credentials are missing.");
78
+ }
79
+ const method = requestObj?.method ?? "GET";
80
+ const headers = {
81
+ "Content-Type": "application/json",
82
+ Authorization: `Basic ${requestObj.encodedAuthToken}`
83
+ };
84
+ const requestOptions = {
85
+ method,
86
+ headers
87
+ };
88
+ if (method !== "GET" && method !== "DELETE" && requestObj?.body) {
89
+ requestOptions.body = JSON.stringify(requestObj.body);
90
+ }
91
+ return requestOptions;
92
+ }
93
+ };
94
+ var NetworkFetcher_default = Fetcher;
95
+
96
+ // src/VideoOnDemand/index.ts
97
+ var Media = class {
98
+ constructor() {
99
+ this.fetch = new NetworkFetcher_default();
100
+ this.mediaPath = "on-demand";
101
+ }
102
+ // Creates a new media asset.
103
+ async createAsset(requestObj, props = {}) {
104
+ const path = this.mediaPath;
105
+ const url = this.fetch.constructUrl(requestObj, path);
106
+ const { accessPolicy = "public", ...restProps } = props;
107
+ const constructObject = {
108
+ ...requestObj,
109
+ method: "POST",
110
+ body: {
111
+ accessPolicy,
112
+ ...restProps
113
+ }
114
+ };
115
+ const createAssetHeader = this.fetch.constructHeaders(constructObject);
116
+ const createUrlAsset = await this.fetch.fetchData(url, createAssetHeader);
117
+ return createUrlAsset;
118
+ }
119
+ // Uploads a media asset using direct upload.
120
+ async uploadAsset(requestObj, props = {
121
+ corsOrigin: "",
122
+ pushMediaSettings: {
123
+ accessPolicy: "public",
124
+ // Default access policy
125
+ inputs: []
126
+ // Default empty array for inputs (inside pushMediaSettings)
127
+ }
128
+ }) {
129
+ const path = `${this.mediaPath}/uploads`;
130
+ const url = this.fetch.constructUrl(requestObj, path);
131
+ const {
132
+ corsOrigin = "*",
133
+ pushMediaSettings = { accessPolicy: "public" },
134
+ ...restProps
135
+ } = props;
136
+ const { accessPolicy = "public", ...restPushMediaSettings } = pushMediaSettings;
137
+ const constructObject = {
138
+ ...requestObj,
139
+ method: "POST",
140
+ body: {
141
+ corsOrigin,
142
+ pushMediaSettings: {
143
+ accessPolicy,
144
+ ...restPushMediaSettings
145
+ },
146
+ ...restProps
147
+ }
148
+ };
149
+ const uploadAssetHeader = this.fetch.constructHeaders(constructObject);
150
+ const uploadMediaAsset = await this.fetch.fetchData(url, uploadAssetHeader);
151
+ return uploadMediaAsset;
152
+ }
153
+ // Retrieves all media assets with pagination support.
154
+ async getAllAssets(props, requestObj) {
155
+ const path = this.mediaPath;
156
+ const queryParams = `?limit=${props?.limit ?? 10}&offset=${props?.offset ?? 1}&orderBy=${props?.orderBy ?? "desc"}`;
157
+ const url = this.fetch.constructUrl(requestObj, path, queryParams);
158
+ const constructObject = {
159
+ ...requestObj,
160
+ method: "GET"
161
+ };
162
+ const getAllAssetsHeader = this.fetch.constructHeaders(constructObject);
163
+ const assetsResponse = await this.fetch.fetchData(url, getAllAssetsHeader);
164
+ return assetsResponse;
165
+ }
166
+ // Retrieves details of a specific media asset.
167
+ async getAsset(props, requestObj) {
168
+ const path = `${this.mediaPath}/${props?.mediaId ?? ""}`;
169
+ const url = this.fetch.constructUrl(requestObj, path);
170
+ const constructObject = {
171
+ ...requestObj,
172
+ method: "GET"
173
+ };
174
+ const getAssetsHeader = this.fetch.constructHeaders(constructObject);
175
+ const assetsResponse = await this.fetch.fetchData(url, getAssetsHeader);
176
+ return assetsResponse;
177
+ }
178
+ // Retrieves detailed information about a media asset's input.
179
+ async getAssetInfo(props, requestObj) {
180
+ const path = `${this.mediaPath}/${props?.mediaId ?? ""}/input-info`;
181
+ const url = this.fetch.constructUrl(requestObj, path);
182
+ const constructObject = {
183
+ ...requestObj,
184
+ method: "GET"
185
+ };
186
+ const getAssetInfoHeader = this.fetch.constructHeaders(constructObject);
187
+ const assetInfoResponse = await this.fetch.fetchData(
188
+ url,
189
+ getAssetInfoHeader
190
+ );
191
+ return assetInfoResponse;
192
+ }
193
+ // Updates the details of a media asset.
194
+ async updateAsset(props, updateObject, requestObj) {
195
+ const path = `${this.mediaPath}/${props?.mediaId ?? ""}`;
196
+ const url = this.fetch.constructUrl(requestObj, path);
197
+ const constructObject = {
198
+ ...requestObj,
199
+ method: "PATCH",
200
+ body: {
201
+ ...updateObject ?? {}
202
+ }
203
+ };
204
+ const updateAssetHeader = this.fetch.constructHeaders(constructObject);
205
+ const updateAssetResponse = await this.fetch.fetchData(
206
+ url,
207
+ updateAssetHeader
208
+ );
209
+ return updateAssetResponse;
210
+ }
211
+ // Deletes a media asset.
212
+ async deleteAsset(props, requestObj) {
213
+ const path = `${this.mediaPath}/${props?.mediaId ?? ""}`;
214
+ const url = this.fetch.constructUrl(requestObj, path);
215
+ const constructObject = {
216
+ ...requestObj,
217
+ method: "DELETE"
218
+ };
219
+ const deleteAssetHeader = this.fetch.constructHeaders(constructObject);
220
+ const deleteAssetResponse = await this.fetch.fetchData(
221
+ url,
222
+ deleteAssetHeader
223
+ );
224
+ return deleteAssetResponse;
225
+ }
226
+ // Adds a playback ID to a media asset with a specific access policy.
227
+ async addMediaPlaybackId(props, playbackPolicy, requestObj) {
228
+ const path = `${this.mediaPath}/${props?.mediaId ?? ""}/playback-ids`;
229
+ const url = this.fetch.constructUrl(requestObj, path);
230
+ const constructObject = {
231
+ ...requestObj,
232
+ method: "POST",
233
+ body: {
234
+ accessPolicy: playbackPolicy?.accessPolicy ?? "public"
235
+ }
236
+ };
237
+ const createPlaybackIdHeader = this.fetch.constructHeaders(constructObject);
238
+ const createPlaybackIdResponse = await this.fetch.fetchData(
239
+ url,
240
+ createPlaybackIdHeader
241
+ );
242
+ return createPlaybackIdResponse;
243
+ }
244
+ // Removes a playback ID from a media asset.
245
+ async removeMediaPlaybackId(props, requestObj) {
246
+ const path = `${this.mediaPath}/${props?.mediaId ?? ""}/playback-ids`;
247
+ let queryParams = "";
248
+ if (props?.playbackId) {
249
+ if (Array.isArray(props.playbackId)) {
250
+ const playbackIdParams = props.playbackId.map(
251
+ (id) => "playbackId=" + id
252
+ );
253
+ queryParams = "?" + playbackIdParams.join("&");
254
+ } else if (typeof props.playbackId === "string") {
255
+ queryParams = "?playbackId=" + props.playbackId;
256
+ }
257
+ }
258
+ const url = this.fetch.constructUrl(requestObj, path, queryParams);
259
+ const constructObject = {
260
+ ...requestObj,
261
+ method: "DELETE"
262
+ };
263
+ const deletePlaybackIdHeader = this.fetch.constructHeaders(constructObject);
264
+ const deletePlaybackIdResponse = await this.fetch.fetchData(
265
+ url,
266
+ deletePlaybackIdHeader
267
+ );
268
+ return deletePlaybackIdResponse;
269
+ }
270
+ };
271
+ var VideoOnDemand_default = Media;
272
+
273
+ // src/Live/index.ts
274
+ var LiveStream = class {
275
+ constructor() {
276
+ this.fetch = new NetworkFetcher_default();
277
+ this.livePath = "live/streams";
278
+ }
279
+ // Creates a new live stream with the given properties.
280
+ async createNewLiveStream(props, requestObj) {
281
+ const path = this.livePath;
282
+ const url = this.fetch.constructUrl(requestObj, path);
283
+ const constructObject = {
284
+ ...requestObj,
285
+ method: "POST",
286
+ body: {
287
+ playbackSettings: {
288
+ accessPolicy: props?.playbackSettings?.accessPolicy ?? "public"
289
+ },
290
+ inputMediaSettings: {
291
+ ...props?.inputMediaSettings
292
+ }
293
+ }
294
+ };
295
+ const createLiveStreamHeader = this.fetch.constructHeaders(constructObject);
296
+ const createLiveStreamResponse = await this.fetch.fetchData(
297
+ url,
298
+ createLiveStreamHeader
299
+ );
300
+ return createLiveStreamResponse;
301
+ }
302
+ // Retrieves all live streams with pagination support.
303
+ async getAllLiveStreams(props, requestObj) {
304
+ const path = this.livePath;
305
+ const queryParams = `?limit=${props?.limit ?? 10}&offset=${props?.offset ?? 1}&orderBy=${props?.orderBy ?? "desc"}`;
306
+ const url = this.fetch.constructUrl(requestObj, path, queryParams);
307
+ const constructObject = {
308
+ ...requestObj,
309
+ method: "GET"
310
+ };
311
+ const getAllLiveStreamHeader = this.fetch.constructHeaders(constructObject);
312
+ const getAllLiveStreamResponse = await this.fetch.fetchData(
313
+ url,
314
+ getAllLiveStreamHeader
315
+ );
316
+ return getAllLiveStreamResponse;
317
+ }
318
+ // Retrieves details of a specific live stream.
319
+ async getLiveStream(props, requestObj) {
320
+ const path = `${this.livePath}/${props?.streamId ?? ""}`;
321
+ const url = this.fetch.constructUrl(requestObj, path);
322
+ const constructObject = {
323
+ ...requestObj,
324
+ method: "GET"
325
+ };
326
+ const getLiveStreamHeader = this.fetch.constructHeaders(constructObject);
327
+ const getLiveStreamResponse = await this.fetch.fetchData(
328
+ url,
329
+ getLiveStreamHeader
330
+ );
331
+ return getLiveStreamResponse;
332
+ }
333
+ // Updates a live stream with new properties.
334
+ async updateLiveStream(props, updateObject, requestObj) {
335
+ const path = `${this.livePath}/${props?.streamId ?? ""}`;
336
+ const url = this.fetch.constructUrl(requestObj, path);
337
+ const constructObject = {
338
+ ...requestObj,
339
+ method: "PATCH",
340
+ body: {
341
+ ...updateObject ?? {}
342
+ }
343
+ };
344
+ const updateLiveStreamHeader = this.fetch.constructHeaders(constructObject);
345
+ const updateLiveStreamResponse = await this.fetch.fetchData(
346
+ url,
347
+ updateLiveStreamHeader
348
+ );
349
+ return updateLiveStreamResponse;
350
+ }
351
+ // Deletes a specific live stream.
352
+ async deleteLiveStream(props, requestObj) {
353
+ const path = `${this.livePath}/${props?.streamId ?? ""}`;
354
+ const url = this.fetch.constructUrl(requestObj, path);
355
+ const constructObject = {
356
+ ...requestObj,
357
+ method: "DELETE"
358
+ };
359
+ const deleteLiveStream = this.fetch.constructHeaders(constructObject);
360
+ const deleteLiveStreamResponse = await this.fetch.fetchData(
361
+ url,
362
+ deleteLiveStream
363
+ );
364
+ return deleteLiveStreamResponse;
365
+ }
366
+ // Creates a playback ID for a live stream with specified access policy.
367
+ async createLiveStreamPlaybackId(props, playbackPolicy, requestObj) {
368
+ const path = `${this.livePath}/${props?.streamId ?? ""}/playback-ids`;
369
+ const url = this.fetch.constructUrl(requestObj, path);
370
+ const constructObject = {
371
+ ...requestObj,
372
+ method: "POST",
373
+ body: {
374
+ accessPolicy: playbackPolicy?.accessPolicy ?? "public"
375
+ }
376
+ };
377
+ const createPlaybackIdHeader = this.fetch.constructHeaders(constructObject);
378
+ const createPlaybackIdResponse = await this.fetch.fetchData(
379
+ url,
380
+ createPlaybackIdHeader
381
+ );
382
+ return createPlaybackIdResponse;
383
+ }
384
+ // Removes a playback ID associated with a live stream.
385
+ async removeLivePlaybackId(props, requestObj) {
386
+ const path = `${this.livePath}/${props?.streamId ?? ""}/playback-ids`;
387
+ let queryParams = "";
388
+ if (props?.playbackId) {
389
+ if (Array.isArray(props.playbackId)) {
390
+ const playbackIdParams = props.playbackId.map(
391
+ (id) => "playbackId=" + id
392
+ );
393
+ queryParams = "?" + playbackIdParams.join("&");
394
+ } else if (typeof props.playbackId === "string") {
395
+ queryParams = "?playbackId=" + props.playbackId;
396
+ }
397
+ }
398
+ const url = this.fetch.constructUrl(requestObj, path, queryParams);
399
+ const constructObject = {
400
+ ...requestObj,
401
+ method: "DELETE"
402
+ };
403
+ const deletePlaybackIdHeader = this.fetch.constructHeaders(constructObject);
404
+ const deletePlaybackIdResponse = await this.fetch.fetchData(
405
+ url,
406
+ deletePlaybackIdHeader
407
+ );
408
+ return deletePlaybackIdResponse;
409
+ }
410
+ // Retrieves the playback policy for a specific playback ID in a live stream.
411
+ async getLiveStreamPlaybackPolicy(props, requestObj) {
412
+ const path = `${this.livePath}/${props?.streamId ?? ""}/playback-ids/${props?.playbackId}`;
413
+ const url = this.fetch.constructUrl(requestObj, path);
414
+ const constructObject = {
415
+ ...requestObj,
416
+ method: "GET"
417
+ };
418
+ const getLiveStreamPlaybackPolicyHeader = this.fetch.constructHeaders(constructObject);
419
+ const getLiveStreamPlaybackPolicyResponse = await this.fetch.fetchData(
420
+ url,
421
+ getLiveStreamPlaybackPolicyHeader
422
+ );
423
+ return getLiveStreamPlaybackPolicyResponse;
424
+ }
425
+ // Creates a new simulcast target for a live stream.
426
+ async createLiveStreamSimulcast(props, liveStreamObj, requestObj) {
427
+ const path = `${this.livePath}/${props?.streamId ?? ""}/simulcast`;
428
+ const url = this.fetch.constructUrl(requestObj, path);
429
+ const constructObject = {
430
+ ...requestObj,
431
+ method: "POST",
432
+ body: {
433
+ ...liveStreamObj
434
+ }
435
+ };
436
+ const createSimulCastHeader = this.fetch.constructHeaders(constructObject);
437
+ const createSimulCastResponse = await this.fetch.fetchData(
438
+ url,
439
+ createSimulCastHeader
440
+ );
441
+ return createSimulCastResponse;
442
+ }
443
+ // Retrieves details of a specific simulcast target for a live stream.
444
+ async getLiveStreamSimulcast(props, requestObj) {
445
+ const path = `${this.livePath}/${props?.streamId ?? ""}/simulcast/${props?.simulcastId}`;
446
+ const url = this.fetch.constructUrl(requestObj, path);
447
+ const constructObject = {
448
+ ...requestObj,
449
+ method: "GET"
450
+ };
451
+ const getSimulcastHeader = this.fetch.constructHeaders(constructObject);
452
+ const getSimulcastResponse = await this.fetch.fetchData(
453
+ url,
454
+ getSimulcastHeader
455
+ );
456
+ return getSimulcastResponse;
457
+ }
458
+ // Updates an existing simulcast target for a live stream.
459
+ async updateLiveStreamSimulcast(props, simulcastObj, requestObj) {
460
+ const path = `${this.livePath}/${props?.streamId ?? ""}/simulcast/${props?.simulcastId}`;
461
+ const url = this.fetch.constructUrl(requestObj, path);
462
+ const constructObject = {
463
+ ...requestObj,
464
+ method: "PUT",
465
+ body: {
466
+ ...simulcastObj
467
+ }
468
+ };
469
+ const updateLiveStreamHeader = this.fetch.constructHeaders(constructObject);
470
+ const updateLiveStreamResponse = await this.fetch.fetchData(
471
+ url,
472
+ updateLiveStreamHeader
473
+ );
474
+ return updateLiveStreamResponse;
475
+ }
476
+ // Deletes an existing simulcast target from a live stream.
477
+ async deleteLiveStreamSimulcast(props, requestObj) {
478
+ const path = `${this.livePath}/${props?.streamId ?? ""}/simulcast/${props?.simulcastId}`;
479
+ const url = this.fetch.constructUrl(requestObj, path);
480
+ const constructObject = {
481
+ ...requestObj,
482
+ method: "DELETE"
483
+ };
484
+ const deleteSimulcastHeader = this.fetch.constructHeaders(constructObject);
485
+ const deleteSimulcastResponse = await this.fetch.fetchData(
486
+ url,
487
+ deleteSimulcastHeader
488
+ );
489
+ return deleteSimulcastResponse;
490
+ }
491
+ };
492
+ var Live_default = LiveStream;
493
+
494
+ // src/index.ts
495
+ var Client = class {
496
+ // Request configuration object
497
+ constructor(props) {
498
+ // Secret key for authentication
499
+ this.mediaService = null;
500
+ // Media service instance
501
+ this.liveStream = null;
502
+ this.accessTokenId = props?.accessTokenId;
503
+ this.secretKey = props?.secretKey;
504
+ this.validateSecrets();
505
+ this.mediaService = new VideoOnDemand_default();
506
+ this.liveStream = new Live_default();
507
+ if (this.accessTokenId && this.secretKey) {
508
+ this.encodedAuthToken = import_buffer.Buffer.from(
509
+ `${this.accessTokenId}:${this.secretKey}`
510
+ ).toString("base64");
511
+ }
512
+ this.RequestObject = {
513
+ httpAgent: "https",
514
+ domain: "v1.fastpix.io",
515
+ encodedAuthToken: this.encodedAuthToken
516
+ };
517
+ }
518
+ // Validate the provided credentials
519
+ validateSecrets() {
520
+ if (!this.accessTokenId || typeof this.accessTokenId !== "string") {
521
+ throw new Error(
522
+ 'Invalid accessTokenId: The "accessTokenId" is required.'
523
+ );
524
+ }
525
+ if (!this.secretKey || typeof this.secretKey !== "string") {
526
+ throw new Error('Invalid secretKey: The "secretKey" is required.');
527
+ }
528
+ }
529
+ // Media Methods
530
+ // Uploads media from a given URL
531
+ uploadMediaFromUrl(props) {
532
+ return this.mediaService ? this.mediaService.createAsset(this.RequestObject, props) : null;
533
+ }
534
+ // Uploads media from a file input.
535
+ uploadMediaFromDevice(props) {
536
+ return this.mediaService ? this.mediaService.uploadAsset(this.RequestObject, props) : null;
537
+ }
538
+ // Retrieves all media assets with pagination.
539
+ getAllMediaAssets(props) {
540
+ return this.mediaService ? this.mediaService.getAllAssets(props, this.RequestObject) : null;
541
+ }
542
+ // Fetches a media asset by its ID.
543
+ getMediaAssetById(props) {
544
+ return this.mediaService ? this.mediaService.getAsset(props, this.RequestObject) : null;
545
+ }
546
+ // Fetches information about a media asset by its ID.
547
+ getMediaAssetInfo(props) {
548
+ return this.mediaService ? this.mediaService.getAssetInfo(props, this.RequestObject) : null;
549
+ }
550
+ // Modifies metadata of an existing media asset.
551
+ updateMediaAsset(props, updateObject) {
552
+ return this.mediaService ? this.mediaService.updateAsset(props, updateObject, this.RequestObject) : null;
553
+ }
554
+ // Removes a media asset by its ID.
555
+ deleteMediaAsset(props) {
556
+ return this.mediaService ? this.mediaService.deleteAsset(props, this.RequestObject) : null;
557
+ }
558
+ // Creates a playback ID for a media asset.
559
+ generateMediaPlaybackId(props, accessPolicy) {
560
+ return this.mediaService ? this.mediaService.addMediaPlaybackId(
561
+ props,
562
+ accessPolicy,
563
+ this.RequestObject
564
+ ) : null;
565
+ }
566
+ // Removes a playback ID from a media asset.
567
+ deleteMediaPlaybackId(props) {
568
+ return this.mediaService ? this.mediaService.removeMediaPlaybackId(props, this.RequestObject) : null;
569
+ }
570
+ // Initiates a new live stream.
571
+ initiateLiveStream(props) {
572
+ return this.liveStream ? this.liveStream.createNewLiveStream(props, this.RequestObject) : null;
573
+ }
574
+ // Retrieves all live streams with pagination.
575
+ getAllLiveStreams(props) {
576
+ return this.liveStream ? this.liveStream.getAllLiveStreams(props, this.RequestObject) : null;
577
+ }
578
+ // Fetches a live stream by its ID.
579
+ getLiveStreamById(props) {
580
+ return this.liveStream ? this.liveStream.getLiveStream(props, this.RequestObject) : null;
581
+ }
582
+ // Modifies an existing live stream.
583
+ updateLiveStream(props, updateObject) {
584
+ return this.liveStream ? this.liveStream.updateLiveStream(
585
+ props,
586
+ updateObject,
587
+ this.RequestObject
588
+ ) : null;
589
+ }
590
+ // Removes a live stream by its ID.
591
+ deleteLiveStream(props) {
592
+ return this.liveStream ? this.liveStream.deleteLiveStream(props, this.RequestObject) : null;
593
+ }
594
+ // Creates a playback ID for a live stream.
595
+ generateLiveStreamPlaybackId(props, accessPolicy) {
596
+ return this.liveStream ? this.liveStream.createLiveStreamPlaybackId(
597
+ props,
598
+ accessPolicy,
599
+ this.RequestObject
600
+ ) : null;
601
+ }
602
+ // Removes a playback ID from a live stream.
603
+ deleteLiveStreamPlaybackId(props) {
604
+ return this.liveStream ? this.liveStream.removeLivePlaybackId(props, this.RequestObject) : null;
605
+ }
606
+ // Fetches the playback policy for a live stream.
607
+ getLiveStreamPlaybackPolicy(props) {
608
+ return this.liveStream ? this.liveStream.getLiveStreamPlaybackPolicy(props, this.RequestObject) : null;
609
+ }
610
+ // Initiates a simulcast for a live stream.
611
+ initiateLiveStreamSimulcast(props, liveStreamObj) {
612
+ return this.liveStream ? this.liveStream.createLiveStreamSimulcast(
613
+ props,
614
+ liveStreamObj,
615
+ this.RequestObject
616
+ ) : null;
617
+ }
618
+ // Retrieves a simulcast for a live stream.
619
+ getLiveStreamSimulcast(props) {
620
+ return this.liveStream ? this.liveStream.getLiveStreamSimulcast(props, this.RequestObject) : null;
621
+ }
622
+ // Modifies an existing simulcast for a live stream.
623
+ updateLiveStreamSimulcast(props, simulcastObj) {
624
+ return this.liveStream ? this.liveStream.updateLiveStreamSimulcast(
625
+ props,
626
+ simulcastObj,
627
+ this.RequestObject
628
+ ) : null;
629
+ }
630
+ // Removes a simulcast from a live stream.
631
+ deleteLiveStreamSimulcast(props) {
632
+ return this.liveStream ? this.liveStream.deleteLiveStreamSimulcast(props, this.RequestObject) : null;
633
+ }
634
+ };
635
+ var index_default = Client;
@@ -0,0 +1,38 @@
1
+ import type { RequestObject, PaginationProps, UploadMediaFromUrlProps, DirectUploadRequest, MediaProps, AccessPolicy, LiveStreamProps, SimulcastObject, SimulcastProps, UpdateObject, InitiateLiveStreamProps, UpdateSimulcastProps } from "../types";
2
+ import Media from "./VideoOnDemand";
3
+ import LiveStream from "./Live";
4
+ declare class Client {
5
+ accessTokenId: string;
6
+ secretKey: string;
7
+ mediaService: Media | null;
8
+ liveStream: LiveStream | null;
9
+ encodedAuthToken: string | undefined;
10
+ RequestObject: RequestObject;
11
+ constructor(props: {
12
+ accessTokenId: string;
13
+ secretKey: string;
14
+ });
15
+ validateSecrets(): void;
16
+ uploadMediaFromUrl(props: UploadMediaFromUrlProps): Promise<import("../types").FetchResponse> | null;
17
+ uploadMediaFromDevice(props: DirectUploadRequest): Promise<import("../types").FetchResponse> | null;
18
+ getAllMediaAssets(props?: PaginationProps): Promise<import("../types").FetchResponse> | null;
19
+ getMediaAssetById(props: MediaProps): Promise<import("../types").FetchResponse> | null;
20
+ getMediaAssetInfo(props: MediaProps): Promise<import("../types").FetchResponse> | null;
21
+ updateMediaAsset(props: MediaProps, updateObject: UpdateObject): Promise<import("../types").FetchResponse> | null;
22
+ deleteMediaAsset(props: MediaProps): Promise<import("../types").FetchResponse> | null;
23
+ generateMediaPlaybackId(props: MediaProps, accessPolicy: AccessPolicy): Promise<import("../types").FetchResponse> | null;
24
+ deleteMediaPlaybackId(props: MediaProps): Promise<import("../types").FetchResponse> | null;
25
+ initiateLiveStream(props: InitiateLiveStreamProps): Promise<import("../types").FetchResponse> | null;
26
+ getAllLiveStreams(props?: PaginationProps): Promise<import("../types").FetchResponse> | null;
27
+ getLiveStreamById(props: LiveStreamProps): Promise<import("../types").FetchResponse> | null;
28
+ updateLiveStream(props: LiveStreamProps, updateObject: any): Promise<import("../types").FetchResponse> | null;
29
+ deleteLiveStream(props: LiveStreamProps): Promise<import("../types").FetchResponse> | null;
30
+ generateLiveStreamPlaybackId(props: LiveStreamProps, accessPolicy: AccessPolicy): Promise<import("../types").FetchResponse> | null;
31
+ deleteLiveStreamPlaybackId(props: LiveStreamProps): Promise<import("../types").FetchResponse> | null;
32
+ getLiveStreamPlaybackPolicy(props: LiveStreamProps): Promise<import("../types").FetchResponse> | null;
33
+ initiateLiveStreamSimulcast(props: LiveStreamProps, liveStreamObj: SimulcastObject): Promise<import("../types").FetchResponse> | null;
34
+ getLiveStreamSimulcast(props: SimulcastProps): Promise<import("../types").FetchResponse> | null;
35
+ updateLiveStreamSimulcast(props: SimulcastProps, simulcastObj: UpdateSimulcastProps): Promise<import("../types").FetchResponse> | null;
36
+ deleteLiveStreamSimulcast(props: SimulcastProps): Promise<import("../types").FetchResponse> | null;
37
+ }
38
+ export default Client;