@redseat/api 0.2.8 → 0.3.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/client.md +6 -4
- package/dist/client.d.ts +4 -3
- package/dist/client.js +21 -3
- package/dist/library.d.ts +3 -3
- package/dist/library.js +1 -1
- package/dist/sse-types.d.ts +14 -5
- package/libraries.md +6 -4
- package/package.json +1 -1
package/client.md
CHANGED
|
@@ -458,13 +458,15 @@ client.medias$.subscribe(event => {
|
|
|
458
458
|
});
|
|
459
459
|
```
|
|
460
460
|
|
|
461
|
-
#### `
|
|
461
|
+
#### `uploadProgress$: Observable<SSEUploadProgressEvent>`
|
|
462
462
|
|
|
463
|
-
Emits
|
|
463
|
+
Emits upload progress updates including download, transfer, and analysis stages.
|
|
464
464
|
|
|
465
465
|
```typescript
|
|
466
|
-
client.
|
|
467
|
-
|
|
466
|
+
client.uploadProgress$.subscribe(event => {
|
|
467
|
+
const { progress } = event;
|
|
468
|
+
const percent = progress.total ? Math.round((progress.current ?? 0) / progress.total * 100) : 0;
|
|
469
|
+
console.log(`Upload ${progress.id} (${progress.type}): ${percent}% - ${progress.filename}`);
|
|
468
470
|
});
|
|
469
471
|
```
|
|
470
472
|
|
package/dist/client.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { Method, AxiosRequestConfig } from 'axios';
|
|
|
2
2
|
import { Observable } from 'rxjs';
|
|
3
3
|
import { IToken } from './auth.js';
|
|
4
4
|
import { IServer } from './interfaces.js';
|
|
5
|
-
import { SSEConnectionState, SSEConnectionOptions, SSEConnectionError, SSELibraryEvent, SSELibraryStatusEvent, SSEMediasEvent,
|
|
5
|
+
import { SSEConnectionState, SSEConnectionOptions, SSEConnectionError, SSELibraryEvent, SSELibraryStatusEvent, SSEMediasEvent, SSEUploadProgressEvent, SSEConvertProgressEvent, SSEEpisodesEvent, SSESeriesEvent, SSEMoviesEvent, SSEPeopleEvent, SSETagsEvent, SSEBackupsEvent, SSEBackupFilesEvent } from './sse-types.js';
|
|
6
6
|
export interface ClientOptions {
|
|
7
7
|
server: IServer;
|
|
8
8
|
getIdToken: () => Promise<string>;
|
|
@@ -33,7 +33,7 @@ export declare class RedseatClient {
|
|
|
33
33
|
readonly library$: Observable<SSELibraryEvent>;
|
|
34
34
|
readonly libraryStatus$: Observable<SSELibraryStatusEvent>;
|
|
35
35
|
readonly medias$: Observable<SSEMediasEvent>;
|
|
36
|
-
readonly
|
|
36
|
+
readonly uploadProgress$: Observable<SSEUploadProgressEvent>;
|
|
37
37
|
readonly convertProgress$: Observable<SSEConvertProgressEvent>;
|
|
38
38
|
readonly episodes$: Observable<SSEEpisodesEvent>;
|
|
39
39
|
readonly series$: Observable<SSESeriesEvent>;
|
|
@@ -43,7 +43,8 @@ export declare class RedseatClient {
|
|
|
43
43
|
readonly backups$: Observable<SSEBackupsEvent>;
|
|
44
44
|
readonly backupFiles$: Observable<SSEBackupFilesEvent>;
|
|
45
45
|
/**
|
|
46
|
-
* Creates a typed observable for a specific SSE event type
|
|
46
|
+
* Creates a typed observable for a specific SSE event type.
|
|
47
|
+
* Unwraps the nested data structure from the server (e.g., {uploadProgress: {...}} -> {...})
|
|
47
48
|
*/
|
|
48
49
|
private createEventStream;
|
|
49
50
|
constructor(options: ClientOptions);
|
package/dist/client.js
CHANGED
|
@@ -3,10 +3,27 @@ import { BehaviorSubject, Subject, filter, map } from 'rxjs';
|
|
|
3
3
|
import { fetchServerToken } from './auth.js';
|
|
4
4
|
export class RedseatClient {
|
|
5
5
|
/**
|
|
6
|
-
* Creates a typed observable for a specific SSE event type
|
|
6
|
+
* Creates a typed observable for a specific SSE event type.
|
|
7
|
+
* Unwraps the nested data structure from the server (e.g., {uploadProgress: {...}} -> {...})
|
|
7
8
|
*/
|
|
8
9
|
createEventStream(eventName) {
|
|
9
|
-
|
|
10
|
+
// Map event names to their wrapper property names (snake_case -> camelCase)
|
|
11
|
+
const wrapperMap = {
|
|
12
|
+
'upload_progress': 'uploadProgress',
|
|
13
|
+
'convert_progress': 'convertProgress',
|
|
14
|
+
'media_progress': 'mediaProgress',
|
|
15
|
+
'library-status': 'libraryStatus',
|
|
16
|
+
'backups-files': 'backupsFiles',
|
|
17
|
+
};
|
|
18
|
+
const wrapperKey = wrapperMap[eventName];
|
|
19
|
+
return this._sseEvents.pipe(filter((event) => event.event === eventName), map(event => {
|
|
20
|
+
// If there's a wrapper, unwrap it; otherwise return data as-is
|
|
21
|
+
const data = event.data;
|
|
22
|
+
if (wrapperKey && data && typeof data === 'object' && wrapperKey in data) {
|
|
23
|
+
return data[wrapperKey];
|
|
24
|
+
}
|
|
25
|
+
return event.data;
|
|
26
|
+
}));
|
|
10
27
|
}
|
|
11
28
|
constructor(options) {
|
|
12
29
|
this.sseReconnectAttempts = 0;
|
|
@@ -22,7 +39,7 @@ export class RedseatClient {
|
|
|
22
39
|
this.library$ = this.createEventStream('library');
|
|
23
40
|
this.libraryStatus$ = this.createEventStream('library-status');
|
|
24
41
|
this.medias$ = this.createEventStream('medias');
|
|
25
|
-
this.
|
|
42
|
+
this.uploadProgress$ = this.createEventStream('upload_progress');
|
|
26
43
|
this.convertProgress$ = this.createEventStream('convert_progress');
|
|
27
44
|
this.episodes$ = this.createEventStream('episodes');
|
|
28
45
|
this.series$ = this.createEventStream('series');
|
|
@@ -303,6 +320,7 @@ export class RedseatClient {
|
|
|
303
320
|
}
|
|
304
321
|
const url = this.buildSSEUrl();
|
|
305
322
|
this.sseAbortController = new AbortController();
|
|
323
|
+
console.log("SSSEEEE URL", url);
|
|
306
324
|
const response = await fetch(url, {
|
|
307
325
|
method: 'GET',
|
|
308
326
|
headers: {
|
package/dist/library.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Observable } from 'rxjs';
|
|
2
2
|
import { IFile, ITag, IPerson, ISerie, IMovie, MediaRequest, IEpisode, ExternalImage, IBackupFile, ILibrary, SerieInMedia, DeletedQuery, RsDeleted, MovieSort, RsSort, SqlOrder, RsRequest, DetectedFaceResult, UnassignFaceResponse, RsGroupDownload } from './interfaces.js';
|
|
3
|
-
import { SSEMediasEvent,
|
|
3
|
+
import { SSEMediasEvent, SSEUploadProgressEvent, SSEConvertProgressEvent, SSEEpisodesEvent, SSESeriesEvent, SSEMoviesEvent, SSEPeopleEvent, SSETagsEvent, SSELibraryStatusEvent } from './sse-types.js';
|
|
4
4
|
import { EncryptFileOptions, EncryptedFile } from './encryption.js';
|
|
5
5
|
export interface MediaForUpdate {
|
|
6
6
|
name?: string;
|
|
@@ -77,7 +77,7 @@ export interface LibraryHttpClient {
|
|
|
77
77
|
getFullUrl(path: string, params?: Record<string, string>): string;
|
|
78
78
|
getAuthToken(): string;
|
|
79
79
|
readonly medias$?: Observable<SSEMediasEvent>;
|
|
80
|
-
readonly
|
|
80
|
+
readonly uploadProgress$?: Observable<SSEUploadProgressEvent>;
|
|
81
81
|
readonly convertProgress$?: Observable<SSEConvertProgressEvent>;
|
|
82
82
|
readonly episodes$?: Observable<SSEEpisodesEvent>;
|
|
83
83
|
readonly series$?: Observable<SSESeriesEvent>;
|
|
@@ -94,7 +94,7 @@ export declare class LibraryApi {
|
|
|
94
94
|
private keyText?;
|
|
95
95
|
private disposed;
|
|
96
96
|
readonly medias$: Observable<SSEMediasEvent>;
|
|
97
|
-
readonly
|
|
97
|
+
readonly uploadProgress$: Observable<SSEUploadProgressEvent>;
|
|
98
98
|
readonly convertProgress$: Observable<SSEConvertProgressEvent>;
|
|
99
99
|
readonly episodes$: Observable<SSEEpisodesEvent>;
|
|
100
100
|
readonly series$: Observable<SSESeriesEvent>;
|
package/dist/library.js
CHANGED
|
@@ -9,7 +9,7 @@ export class LibraryApi {
|
|
|
9
9
|
this.library = library;
|
|
10
10
|
// Create library-filtered streams
|
|
11
11
|
this.medias$ = this.createLibraryFilteredStream(client.medias$);
|
|
12
|
-
this.
|
|
12
|
+
this.uploadProgress$ = this.createLibraryFilteredStream(client.uploadProgress$);
|
|
13
13
|
this.convertProgress$ = this.createLibraryFilteredStream(client.convertProgress$);
|
|
14
14
|
this.episodes$ = this.createLibraryFilteredStream(client.episodes$);
|
|
15
15
|
this.series$ = this.createLibraryFilteredStream(client.series$);
|
package/dist/sse-types.d.ts
CHANGED
|
@@ -35,11 +35,20 @@ export interface SSEMediasEvent {
|
|
|
35
35
|
media: IFile;
|
|
36
36
|
}[];
|
|
37
37
|
}
|
|
38
|
-
export
|
|
38
|
+
export type RsProgressType = 'download' | 'transfert' | 'analysing' | 'finished' | {
|
|
39
|
+
duplicate: string;
|
|
40
|
+
};
|
|
41
|
+
export interface RsProgress {
|
|
42
|
+
id: string;
|
|
43
|
+
total?: number;
|
|
44
|
+
current?: number;
|
|
45
|
+
filename?: string;
|
|
46
|
+
type: RsProgressType;
|
|
47
|
+
}
|
|
48
|
+
export interface SSEUploadProgressEvent {
|
|
39
49
|
library: string;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
status?: string;
|
|
50
|
+
progress: RsProgress;
|
|
51
|
+
remainingSecondes?: number;
|
|
43
52
|
}
|
|
44
53
|
export interface SSEConvertProgressEvent {
|
|
45
54
|
library: string;
|
|
@@ -102,7 +111,7 @@ export interface SSEEventMap {
|
|
|
102
111
|
'library': SSELibraryEvent;
|
|
103
112
|
'library-status': SSELibraryStatusEvent;
|
|
104
113
|
'medias': SSEMediasEvent;
|
|
105
|
-
'
|
|
114
|
+
'upload_progress': SSEUploadProgressEvent;
|
|
106
115
|
'convert_progress': SSEConvertProgressEvent;
|
|
107
116
|
'episodes': SSEEpisodesEvent;
|
|
108
117
|
'series': SSESeriesEvent;
|
package/libraries.md
CHANGED
|
@@ -98,13 +98,15 @@ libraryApi.medias$.subscribe(event => {
|
|
|
98
98
|
});
|
|
99
99
|
```
|
|
100
100
|
|
|
101
|
-
#### `
|
|
101
|
+
#### `uploadProgress$: Observable<SSEUploadProgressEvent>`
|
|
102
102
|
|
|
103
|
-
Emits
|
|
103
|
+
Emits upload progress updates for this library, including download, transfer, and analysis stages.
|
|
104
104
|
|
|
105
105
|
```typescript
|
|
106
|
-
libraryApi.
|
|
107
|
-
|
|
106
|
+
libraryApi.uploadProgress$.subscribe(event => {
|
|
107
|
+
const { progress } = event;
|
|
108
|
+
const percent = progress.total ? Math.round((progress.current ?? 0) / progress.total * 100) : 0;
|
|
109
|
+
console.log(`Upload ${progress.id} (${progress.type}): ${percent}% - ${progress.filename}`);
|
|
108
110
|
});
|
|
109
111
|
```
|
|
110
112
|
|