@redseat/api 0.1.10 → 0.1.12
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 +14 -0
- package/dist/client.js +26 -0
- package/dist/interfaces.d.ts +3 -11
- package/dist/interfaces.js +0 -9
- package/dist/library.d.ts +11 -5
- package/dist/library.js +21 -17
- package/package.json +1 -1
package/dist/client.d.ts
CHANGED
|
@@ -33,4 +33,18 @@ 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;
|
|
44
|
+
/**
|
|
45
|
+
* Gets the current auth token.
|
|
46
|
+
* @returns The current auth token string
|
|
47
|
+
* @throws Error if not authenticated
|
|
48
|
+
*/
|
|
49
|
+
getAuthToken(): string;
|
|
36
50
|
}
|
package/dist/client.js
CHANGED
|
@@ -159,4 +159,30 @@ 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
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Gets the current auth token.
|
|
179
|
+
* @returns The current auth token string
|
|
180
|
+
* @throws Error if not authenticated
|
|
181
|
+
*/
|
|
182
|
+
getAuthToken() {
|
|
183
|
+
if (!this.tokenData?.token) {
|
|
184
|
+
throw new Error('Not authenticated. No auth token available.');
|
|
185
|
+
}
|
|
186
|
+
return this.tokenData.token;
|
|
187
|
+
}
|
|
162
188
|
}
|
package/dist/interfaces.d.ts
CHANGED
|
@@ -13,14 +13,6 @@ export interface SerieInMedia {
|
|
|
13
13
|
episode?: number;
|
|
14
14
|
episodeTo?: number;
|
|
15
15
|
}
|
|
16
|
-
export declare enum FileType {
|
|
17
|
-
Directory = "Directory",
|
|
18
|
-
Photo = "Photo",
|
|
19
|
-
Video = "Video",
|
|
20
|
-
Archive = "Archive",
|
|
21
|
-
Album = "Album",
|
|
22
|
-
Other = "Other"
|
|
23
|
-
}
|
|
24
16
|
export interface MediaItemReference {
|
|
25
17
|
id: string;
|
|
26
18
|
conf?: number;
|
|
@@ -55,12 +47,12 @@ export interface IFile {
|
|
|
55
47
|
name: string;
|
|
56
48
|
source?: string;
|
|
57
49
|
description?: string;
|
|
58
|
-
type:
|
|
50
|
+
type: FileTypes;
|
|
59
51
|
mimetype: string;
|
|
60
52
|
size?: number;
|
|
61
53
|
params?: any;
|
|
62
|
-
added
|
|
63
|
-
modified
|
|
54
|
+
added: number;
|
|
55
|
+
modified: number;
|
|
64
56
|
created?: number;
|
|
65
57
|
rating?: number;
|
|
66
58
|
avgRating?: number;
|
package/dist/interfaces.js
CHANGED
|
@@ -8,15 +8,6 @@ export var FileTypes;
|
|
|
8
8
|
FileTypes["channel"] = "channel";
|
|
9
9
|
FileTypes["other"] = "other";
|
|
10
10
|
})(FileTypes || (FileTypes = {}));
|
|
11
|
-
export var FileType;
|
|
12
|
-
(function (FileType) {
|
|
13
|
-
FileType["Directory"] = "Directory";
|
|
14
|
-
FileType["Photo"] = "Photo";
|
|
15
|
-
FileType["Video"] = "Video";
|
|
16
|
-
FileType["Archive"] = "Archive";
|
|
17
|
-
FileType["Album"] = "Album";
|
|
18
|
-
FileType["Other"] = "Other";
|
|
19
|
-
})(FileType || (FileType = {}));
|
|
20
11
|
export var LibraryTypes;
|
|
21
12
|
(function (LibraryTypes) {
|
|
22
13
|
LibraryTypes["Photos"] = "photos";
|
package/dist/library.d.ts
CHANGED
|
@@ -72,6 +72,8 @@ 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;
|
|
76
|
+
getAuthToken(): string;
|
|
75
77
|
}
|
|
76
78
|
export declare class LibraryApi {
|
|
77
79
|
private client;
|
|
@@ -79,9 +81,7 @@ export declare class LibraryApi {
|
|
|
79
81
|
private library;
|
|
80
82
|
private key?;
|
|
81
83
|
private keyText?;
|
|
82
|
-
|
|
83
|
-
constructor(client: LibraryHttpClient, libraryId: string, library: ILibrary, baseUrl?: string);
|
|
84
|
-
setBaseUrl(baseUrl: string): void;
|
|
84
|
+
constructor(client: LibraryHttpClient, libraryId: string, library: ILibrary);
|
|
85
85
|
setKey(passPhrase: string): Promise<void>;
|
|
86
86
|
private getUrl;
|
|
87
87
|
getTags(query?: {
|
|
@@ -222,7 +222,6 @@ export declare class LibraryApi {
|
|
|
222
222
|
* Fetches a share token and returns a complete URL that can be used without authentication.
|
|
223
223
|
* @param url - The request URL to create a share link for
|
|
224
224
|
* @returns A complete URL with sharetoken that can be used to stream the content
|
|
225
|
-
* @throws Error if baseUrl is not set
|
|
226
225
|
*/
|
|
227
226
|
getRequestShareUrl(url: string): Promise<string>;
|
|
228
227
|
/**
|
|
@@ -230,9 +229,16 @@ export declare class LibraryApi {
|
|
|
230
229
|
* Fetches a share token and returns a complete URL that can be used without authentication.
|
|
231
230
|
* @param mediaId - The media ID to create a share link for
|
|
232
231
|
* @returns A complete URL with sharetoken that can be used to access the media
|
|
233
|
-
* @throws Error if baseUrl is not set
|
|
234
232
|
*/
|
|
235
233
|
getMediaShareUrl(mediaId: string): Promise<string>;
|
|
234
|
+
/**
|
|
235
|
+
* Get a streaming URL for a media file using the current auth token.
|
|
236
|
+
* This is synchronous and doesn't require an API call, making it suitable for video playback.
|
|
237
|
+
* @param mediaId - The media ID to stream
|
|
238
|
+
* @returns A complete URL with auth token for streaming
|
|
239
|
+
* @throws Error if not authenticated
|
|
240
|
+
*/
|
|
241
|
+
getMediaStreamingUrl(mediaId: string): string;
|
|
236
242
|
getUnassignedFaces(params?: Map<string, string>): Promise<any>;
|
|
237
243
|
getClusters(): Promise<any>;
|
|
238
244
|
assignFaces(request: any): Promise<any>;
|
package/dist/library.js
CHANGED
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
import { deriveKey, encryptText as encryptTextUtil, decryptText as decryptTextUtil, encryptBuffer, decryptBuffer, encryptFile as encryptFileUtil, decryptFile as decryptFileUtil, decryptFileThumb, encryptFilename as encryptFilenameUtil, getRandomIV as getRandomIVUtil } from './encryption.js';
|
|
2
2
|
import { uint8ArrayFromBase64 } from './crypto.js';
|
|
3
3
|
export class LibraryApi {
|
|
4
|
-
constructor(client, libraryId, library
|
|
4
|
+
constructor(client, libraryId, library) {
|
|
5
5
|
this.client = client;
|
|
6
6
|
this.libraryId = libraryId;
|
|
7
7
|
this.library = library;
|
|
8
|
-
this.baseUrl = baseUrl;
|
|
9
|
-
}
|
|
10
|
-
setBaseUrl(baseUrl) {
|
|
11
|
-
this.baseUrl = baseUrl;
|
|
12
8
|
}
|
|
13
9
|
async setKey(passPhrase) {
|
|
14
10
|
// Derive keys
|
|
@@ -490,30 +486,38 @@ export class LibraryApi {
|
|
|
490
486
|
* Fetches a share token and returns a complete URL that can be used without authentication.
|
|
491
487
|
* @param url - The request URL to create a share link for
|
|
492
488
|
* @returns A complete URL with sharetoken that can be used to stream the content
|
|
493
|
-
* @throws Error if baseUrl is not set
|
|
494
489
|
*/
|
|
495
490
|
async getRequestShareUrl(url) {
|
|
496
|
-
if (!this.baseUrl) {
|
|
497
|
-
throw new Error('baseUrl must be set to generate share URLs. Call setBaseUrl() first.');
|
|
498
|
-
}
|
|
499
491
|
const shareToken = await this.getRequestShareToken(url);
|
|
500
|
-
|
|
501
|
-
|
|
492
|
+
return this.client.getFullUrl(this.getUrl('/plugins/requests/url/stream'), {
|
|
493
|
+
sharetoken: shareToken,
|
|
494
|
+
url
|
|
495
|
+
});
|
|
502
496
|
}
|
|
503
497
|
/**
|
|
504
498
|
* Get a shareable URL for a media file.
|
|
505
499
|
* Fetches a share token and returns a complete URL that can be used without authentication.
|
|
506
500
|
* @param mediaId - The media ID to create a share link for
|
|
507
501
|
* @returns A complete URL with sharetoken that can be used to access the media
|
|
508
|
-
* @throws Error if baseUrl is not set
|
|
509
502
|
*/
|
|
510
503
|
async getMediaShareUrl(mediaId) {
|
|
511
|
-
if (!this.baseUrl) {
|
|
512
|
-
throw new Error('baseUrl must be set to generate share URLs. Call setBaseUrl() first.');
|
|
513
|
-
}
|
|
514
504
|
const shareToken = await this.getMediaShareToken(mediaId);
|
|
515
|
-
|
|
516
|
-
|
|
505
|
+
return this.client.getFullUrl(this.getUrl(`/medias/${mediaId}`), {
|
|
506
|
+
sharetoken: shareToken
|
|
507
|
+
});
|
|
508
|
+
}
|
|
509
|
+
/**
|
|
510
|
+
* Get a streaming URL for a media file using the current auth token.
|
|
511
|
+
* This is synchronous and doesn't require an API call, making it suitable for video playback.
|
|
512
|
+
* @param mediaId - The media ID to stream
|
|
513
|
+
* @returns A complete URL with auth token for streaming
|
|
514
|
+
* @throws Error if not authenticated
|
|
515
|
+
*/
|
|
516
|
+
getMediaStreamingUrl(mediaId) {
|
|
517
|
+
const token = this.client.getAuthToken();
|
|
518
|
+
return this.client.getFullUrl(this.getUrl(`/medias/${mediaId}`), {
|
|
519
|
+
token
|
|
520
|
+
});
|
|
517
521
|
}
|
|
518
522
|
async getUnassignedFaces(params) {
|
|
519
523
|
const queryParams = {};
|