@redseat/api 0.1.9 → 0.1.11
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 +8 -0
- package/dist/client.js +15 -0
- package/dist/library.d.ts +29 -0
- package/dist/library.js +47 -0
- package/package.json +1 -1
package/dist/client.d.ts
CHANGED
|
@@ -33,4 +33,12 @@ export declare class RedseatClient {
|
|
|
33
33
|
patch<T = unknown>(url: string, data?: unknown, config?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<T, any>>;
|
|
34
34
|
delete<T = unknown>(url: string, config?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<T, any>>;
|
|
35
35
|
request<T = unknown>(method: Method, url: string, data?: unknown, config?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<T, any>>;
|
|
36
|
+
/**
|
|
37
|
+
* Constructs a full absolute URL from a path.
|
|
38
|
+
* Uses the current baseUrl (which may be local or remote depending on detection).
|
|
39
|
+
* @param path - The path to append to the base URL
|
|
40
|
+
* @param params - Optional query parameters to include
|
|
41
|
+
* @returns The full absolute URL
|
|
42
|
+
*/
|
|
43
|
+
getFullUrl(path: string, params?: Record<string, string>): string;
|
|
36
44
|
}
|
package/dist/client.js
CHANGED
|
@@ -159,4 +159,19 @@ export class RedseatClient {
|
|
|
159
159
|
...config
|
|
160
160
|
});
|
|
161
161
|
}
|
|
162
|
+
/**
|
|
163
|
+
* Constructs a full absolute URL from a path.
|
|
164
|
+
* Uses the current baseUrl (which may be local or remote depending on detection).
|
|
165
|
+
* @param path - The path to append to the base URL
|
|
166
|
+
* @param params - Optional query parameters to include
|
|
167
|
+
* @returns The full absolute URL
|
|
168
|
+
*/
|
|
169
|
+
getFullUrl(path, params) {
|
|
170
|
+
let url = `${this.baseUrl}${path}`;
|
|
171
|
+
if (params && Object.keys(params).length > 0) {
|
|
172
|
+
const searchParams = new URLSearchParams(params);
|
|
173
|
+
url = `${url}?${searchParams.toString()}`;
|
|
174
|
+
}
|
|
175
|
+
return url;
|
|
176
|
+
}
|
|
162
177
|
}
|
package/dist/library.d.ts
CHANGED
|
@@ -72,6 +72,7 @@ export interface LibraryHttpClient {
|
|
|
72
72
|
delete<T = unknown>(url: string, config?: any): Promise<{
|
|
73
73
|
data: T;
|
|
74
74
|
}>;
|
|
75
|
+
getFullUrl(path: string, params?: Record<string, string>): string;
|
|
75
76
|
}
|
|
76
77
|
export declare class LibraryApi {
|
|
77
78
|
private client;
|
|
@@ -201,6 +202,34 @@ export declare class LibraryApi {
|
|
|
201
202
|
* @throws Error if the URL is not available or cannot be made permanent
|
|
202
203
|
*/
|
|
203
204
|
checkRequestPermanent(request: RsRequest): Promise<RsRequest>;
|
|
205
|
+
/**
|
|
206
|
+
* Get a share token for a request URL.
|
|
207
|
+
* The token can be used to stream/download the resource without authentication.
|
|
208
|
+
* @param url - The request URL to get a share token for
|
|
209
|
+
* @returns A temporary share token valid for 6 hours
|
|
210
|
+
*/
|
|
211
|
+
getRequestShareToken(url: string): Promise<string>;
|
|
212
|
+
/**
|
|
213
|
+
* Get a share token for a media file.
|
|
214
|
+
* The token can be used to access the media without authentication.
|
|
215
|
+
* @param mediaId - The media ID to get a share token for
|
|
216
|
+
* @returns A temporary share token valid for 6 hours
|
|
217
|
+
*/
|
|
218
|
+
getMediaShareToken(mediaId: string): Promise<string>;
|
|
219
|
+
/**
|
|
220
|
+
* Get a shareable URL for streaming a request.
|
|
221
|
+
* Fetches a share token and returns a complete URL that can be used without authentication.
|
|
222
|
+
* @param url - The request URL to create a share link for
|
|
223
|
+
* @returns A complete URL with sharetoken that can be used to stream the content
|
|
224
|
+
*/
|
|
225
|
+
getRequestShareUrl(url: string): Promise<string>;
|
|
226
|
+
/**
|
|
227
|
+
* Get a shareable URL for a media file.
|
|
228
|
+
* Fetches a share token and returns a complete URL that can be used without authentication.
|
|
229
|
+
* @param mediaId - The media ID to create a share link for
|
|
230
|
+
* @returns A complete URL with sharetoken that can be used to access the media
|
|
231
|
+
*/
|
|
232
|
+
getMediaShareUrl(mediaId: string): Promise<string>;
|
|
204
233
|
getUnassignedFaces(params?: Map<string, string>): Promise<any>;
|
|
205
234
|
getClusters(): Promise<any>;
|
|
206
235
|
assignFaces(request: any): Promise<any>;
|
package/dist/library.js
CHANGED
|
@@ -459,6 +459,53 @@ export class LibraryApi {
|
|
|
459
459
|
const res = await this.client.post(this.getUrl('/plugins/requests/permanent'), request);
|
|
460
460
|
return res.data;
|
|
461
461
|
}
|
|
462
|
+
/**
|
|
463
|
+
* Get a share token for a request URL.
|
|
464
|
+
* The token can be used to stream/download the resource without authentication.
|
|
465
|
+
* @param url - The request URL to get a share token for
|
|
466
|
+
* @returns A temporary share token valid for 6 hours
|
|
467
|
+
*/
|
|
468
|
+
async getRequestShareToken(url) {
|
|
469
|
+
const res = await this.client.get(this.getUrl('/plugins/requests/url/sharetoken'), {
|
|
470
|
+
params: { url }
|
|
471
|
+
});
|
|
472
|
+
return res.data;
|
|
473
|
+
}
|
|
474
|
+
/**
|
|
475
|
+
* Get a share token for a media file.
|
|
476
|
+
* The token can be used to access the media without authentication.
|
|
477
|
+
* @param mediaId - The media ID to get a share token for
|
|
478
|
+
* @returns A temporary share token valid for 6 hours
|
|
479
|
+
*/
|
|
480
|
+
async getMediaShareToken(mediaId) {
|
|
481
|
+
const res = await this.client.get(this.getUrl(`/medias/${mediaId}/sharetoken`));
|
|
482
|
+
return res.data;
|
|
483
|
+
}
|
|
484
|
+
/**
|
|
485
|
+
* Get a shareable URL for streaming a request.
|
|
486
|
+
* Fetches a share token and returns a complete URL that can be used without authentication.
|
|
487
|
+
* @param url - The request URL to create a share link for
|
|
488
|
+
* @returns A complete URL with sharetoken that can be used to stream the content
|
|
489
|
+
*/
|
|
490
|
+
async getRequestShareUrl(url) {
|
|
491
|
+
const shareToken = await this.getRequestShareToken(url);
|
|
492
|
+
return this.client.getFullUrl(this.getUrl('/plugins/requests/url/stream'), {
|
|
493
|
+
sharetoken: shareToken,
|
|
494
|
+
url
|
|
495
|
+
});
|
|
496
|
+
}
|
|
497
|
+
/**
|
|
498
|
+
* Get a shareable URL for a media file.
|
|
499
|
+
* Fetches a share token and returns a complete URL that can be used without authentication.
|
|
500
|
+
* @param mediaId - The media ID to create a share link for
|
|
501
|
+
* @returns A complete URL with sharetoken that can be used to access the media
|
|
502
|
+
*/
|
|
503
|
+
async getMediaShareUrl(mediaId) {
|
|
504
|
+
const shareToken = await this.getMediaShareToken(mediaId);
|
|
505
|
+
return this.client.getFullUrl(this.getUrl(`/medias/${mediaId}`), {
|
|
506
|
+
sharetoken: shareToken
|
|
507
|
+
});
|
|
508
|
+
}
|
|
462
509
|
async getUnassignedFaces(params) {
|
|
463
510
|
const queryParams = {};
|
|
464
511
|
if (params) {
|