@redseat/api 0.1.10 → 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 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;
@@ -79,9 +80,7 @@ export declare class LibraryApi {
79
80
  private library;
80
81
  private key?;
81
82
  private keyText?;
82
- private baseUrl?;
83
- constructor(client: LibraryHttpClient, libraryId: string, library: ILibrary, baseUrl?: string);
84
- setBaseUrl(baseUrl: string): void;
83
+ constructor(client: LibraryHttpClient, libraryId: string, library: ILibrary);
85
84
  setKey(passPhrase: string): Promise<void>;
86
85
  private getUrl;
87
86
  getTags(query?: {
@@ -222,7 +221,6 @@ export declare class LibraryApi {
222
221
  * Fetches a share token and returns a complete URL that can be used without authentication.
223
222
  * @param url - The request URL to create a share link for
224
223
  * @returns A complete URL with sharetoken that can be used to stream the content
225
- * @throws Error if baseUrl is not set
226
224
  */
227
225
  getRequestShareUrl(url: string): Promise<string>;
228
226
  /**
@@ -230,7 +228,6 @@ export declare class LibraryApi {
230
228
  * Fetches a share token and returns a complete URL that can be used without authentication.
231
229
  * @param mediaId - The media ID to create a share link for
232
230
  * @returns A complete URL with sharetoken that can be used to access the media
233
- * @throws Error if baseUrl is not set
234
231
  */
235
232
  getMediaShareUrl(mediaId: string): Promise<string>;
236
233
  getUnassignedFaces(params?: Map<string, string>): 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, baseUrl) {
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,25 @@ 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
- const params = new URLSearchParams({ sharetoken: shareToken, url });
501
- return `${this.baseUrl}${this.getUrl('/plugins/requests/url/stream')}?${params.toString()}`;
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
- const params = new URLSearchParams({ sharetoken: shareToken });
516
- return `${this.baseUrl}${this.getUrl(`/medias/${mediaId}`)}?${params.toString()}`;
505
+ return this.client.getFullUrl(this.getUrl(`/medias/${mediaId}`), {
506
+ sharetoken: shareToken
507
+ });
517
508
  }
518
509
  async getUnassignedFaces(params) {
519
510
  const queryParams = {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redseat/api",
3
- "version": "0.1.10",
3
+ "version": "0.1.11",
4
4
  "description": "TypeScript API client library for interacting with Redseat servers",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",