@redseat/api 0.0.12 → 0.0.14

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/package.json CHANGED
@@ -1,50 +1,50 @@
1
- {
2
- "name": "@redseat/api",
3
- "version": "0.0.12",
4
- "description": "TypeScript API client library for interacting with Redseat servers",
5
- "type": "module",
6
- "main": "./dist/index.js",
7
- "module": "./dist/index.js",
8
- "types": "./dist/index.d.ts",
9
- "exports": {
10
- ".": {
11
- "import": "./dist/index.js",
12
- "types": "./dist/index.d.ts"
13
- }
14
- },
15
- "files": [
16
- "dist/**/*",
17
- "README.md",
18
- "*.md"
19
- ],
20
- "keywords": [
21
- "redseat",
22
- "api",
23
- "client",
24
- "typescript"
25
- ],
26
- "author": "Arnaud JEZEQUEL <arnaud.jezequel@gmail.com>",
27
- "license": "MIT",
28
- "repository": {
29
- "type": "git",
30
- "url": "https://github.com/yourusername/redseat-svelte.git",
31
- "directory": "packages/api"
32
- },
33
- "scripts": {
34
- "build": "tsc",
35
- "test": "vitest run",
36
- "test:watch": "vitest"
37
- },
38
- "dependencies": {
39
- "axios": "^1.11.0",
40
- "rxjs": "^7.8.2"
41
- },
42
- "devDependencies": {
43
- "typescript": "^5.8.3",
44
- "vite": "^7.3.0",
45
- "vitest": "^4.0.16"
46
- },
47
- "publishConfig": {
48
- "access": "public"
49
- }
1
+ {
2
+ "name": "@redseat/api",
3
+ "version": "0.0.14",
4
+ "description": "TypeScript API client library for interacting with Redseat servers",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "module": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "import": "./dist/index.js",
12
+ "types": "./dist/index.d.ts"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist/**/*",
17
+ "README.md",
18
+ "*.md"
19
+ ],
20
+ "keywords": [
21
+ "redseat",
22
+ "api",
23
+ "client",
24
+ "typescript"
25
+ ],
26
+ "author": "Arnaud JEZEQUEL <arnaud.jezequel@gmail.com>",
27
+ "license": "MIT",
28
+ "repository": {
29
+ "type": "git",
30
+ "url": "https://github.com/yourusername/redseat-svelte.git",
31
+ "directory": "packages/api"
32
+ },
33
+ "scripts": {
34
+ "build": "tsc",
35
+ "test": "vitest run",
36
+ "test:watch": "vitest"
37
+ },
38
+ "dependencies": {
39
+ "axios": "^1.11.0",
40
+ "rxjs": "^7.8.2"
41
+ },
42
+ "devDependencies": {
43
+ "typescript": "^5.8.3",
44
+ "vite": "^7.3.0",
45
+ "vitest": "^4.0.16"
46
+ },
47
+ "publishConfig": {
48
+ "access": "public"
49
+ }
50
50
  }
package/server.md CHANGED
@@ -1,196 +1,196 @@
1
- # ServerApi
2
-
3
- The `ServerApi` class provides server-level operations for managing libraries, settings, plugins, and credentials.
4
-
5
- ## Overview
6
-
7
- `ServerApi` handles operations that are not specific to a single library, such as:
8
- - Listing and creating libraries
9
- - Getting current user information
10
- - Managing server settings
11
- - Listing plugins and credentials
12
- - Adding credentials to libraries
13
-
14
- ## Constructor
15
-
16
- ```typescript
17
- new ServerApi(client: RedseatClient)
18
- ```
19
-
20
- **Parameters:**
21
- - `client`: An initialized `RedseatClient` instance
22
-
23
- **Example:**
24
- ```typescript
25
- import { RedseatClient, ServerApi } from '@redseat/api';
26
-
27
- const client = new RedseatClient({ /* ... */ });
28
- const serverApi = new ServerApi(client);
29
- ```
30
-
31
- ## Methods
32
-
33
- ### `getLibraries(): Promise<ILibrary[]>`
34
-
35
- Retrieves all libraries available to the current user.
36
-
37
- **Returns:** Promise resolving to an array of `ILibrary` objects
38
-
39
- **Example:**
40
- ```typescript
41
- const libraries = await serverApi.getLibraries();
42
- libraries.forEach(library => {
43
- console.log(`Library: ${library.name} (${library.type})`);
44
- });
45
- ```
46
-
47
- ### `getMe(): Promise<any>`
48
-
49
- Gets information about the current authenticated user.
50
-
51
- **Returns:** Promise resolving to user information object
52
-
53
- **Example:**
54
- ```typescript
55
- const user = await serverApi.getMe();
56
- console.log(`Logged in as: ${user.name}`);
57
- ```
58
-
59
- ### `addLibrary(library: Partial<ILibrary>): Promise<ILibrary>`
60
-
61
- Creates a new library.
62
-
63
- **Parameters:**
64
- - `library`: Partial library object with required fields:
65
- - `name`: Library name (required)
66
- - `type`: Library type - `'photos'`, `'shows'`, `'movies'`, or `'iptv'` (required)
67
- - `source`: Optional source type
68
- - `crypt`: Optional boolean to enable encryption
69
- - `hidden`: Optional boolean to hide library
70
-
71
- **Returns:** Promise resolving to the created `ILibrary` object with generated `id`
72
-
73
- **Example:**
74
- ```typescript
75
- const newLibrary = await serverApi.addLibrary({
76
- name: 'My Photos',
77
- type: 'photos',
78
- crypt: true // Enable encryption
79
- });
80
- console.log(`Created library with ID: ${newLibrary.id}`);
81
- ```
82
-
83
- ### `getSetting(key: string): Promise<string>`
84
-
85
- Retrieves a server setting value by key.
86
-
87
- **Parameters:**
88
- - `key`: The setting key to retrieve
89
-
90
- **Returns:** Promise resolving to the setting value as a string
91
-
92
- **Example:**
93
- ```typescript
94
- const maxUploadSize = await serverApi.getSetting('max_upload_size');
95
- console.log(`Max upload size: ${maxUploadSize}`);
96
- ```
97
-
98
- ### `getPlugins(): Promise<any[]>`
99
-
100
- Retrieves all available plugins on the server.
101
-
102
- **Returns:** Promise resolving to an array of plugin objects
103
-
104
- **Example:**
105
- ```typescript
106
- const plugins = await serverApi.getPlugins();
107
- plugins.forEach(plugin => {
108
- console.log(`Plugin: ${plugin.name} - ${plugin.description}`);
109
- });
110
- ```
111
-
112
- ### `getCredentials(): Promise<any[]>`
113
-
114
- Retrieves all available credentials configured on the server.
115
-
116
- **Returns:** Promise resolving to an array of credential objects
117
-
118
- **Example:**
119
- ```typescript
120
- const credentials = await serverApi.getCredentials();
121
- credentials.forEach(cred => {
122
- console.log(`Credential: ${cred.name} (${cred.type})`);
123
- });
124
- ```
125
-
126
- ### `addLibraryCredential(credential: any): Promise<ILibrary>`
127
-
128
- Adds a credential to a library. This is used to configure external service access for libraries.
129
-
130
- **Parameters:**
131
- - `credential`: Credential configuration object (structure depends on credential type)
132
-
133
- **Returns:** Promise resolving to the updated `ILibrary` object
134
-
135
- **Example:**
136
- ```typescript
137
- const library = await serverApi.addLibraryCredential({
138
- libraryId: 'library-123',
139
- credentialId: 'credential-456',
140
- // Additional credential-specific configuration
141
- });
142
- ```
143
-
144
- ## Usage Examples
145
-
146
- ### Complete Workflow: Create Library and Get Info
147
-
148
- ```typescript
149
- import { RedseatClient, ServerApi } from '@redseat/api';
150
-
151
- // Initialize
152
- const client = new RedseatClient({ /* ... */ });
153
- const serverApi = new ServerApi(client);
154
-
155
- // Get current user
156
- const user = await serverApi.getMe();
157
- console.log(`User: ${user.name}`);
158
-
159
- // List existing libraries
160
- const libraries = await serverApi.getLibraries();
161
- console.log(`Found ${libraries.length} libraries`);
162
-
163
- // Create a new encrypted photo library
164
- const newLibrary = await serverApi.addLibrary({
165
- name: 'Encrypted Photos',
166
- type: 'photos',
167
- crypt: true
168
- });
169
-
170
- // Get server settings
171
- const maxUpload = await serverApi.getSetting('max_upload_size');
172
- console.log(`Max upload size: ${maxUpload}`);
173
- ```
174
-
175
- ### Error Handling
176
-
177
- ```typescript
178
- try {
179
- const libraries = await serverApi.getLibraries();
180
- } catch (error) {
181
- if (error.response?.status === 401) {
182
- console.error('Authentication failed');
183
- } else if (error.response?.status === 403) {
184
- console.error('Insufficient permissions');
185
- } else {
186
- console.error('Failed to get libraries:', error.message);
187
- }
188
- }
189
- ```
190
-
191
- ## Related Documentation
192
-
193
- - [RedseatClient Documentation](client.md) - HTTP client used by ServerApi
194
- - [LibraryApi Documentation](libraries.md) - Library-specific operations
195
- - [README](README.md) - Package overview
196
-
1
+ # ServerApi
2
+
3
+ The `ServerApi` class provides server-level operations for managing libraries, settings, plugins, and credentials.
4
+
5
+ ## Overview
6
+
7
+ `ServerApi` handles operations that are not specific to a single library, such as:
8
+ - Listing and creating libraries
9
+ - Getting current user information
10
+ - Managing server settings
11
+ - Listing plugins and credentials
12
+ - Adding credentials to libraries
13
+
14
+ ## Constructor
15
+
16
+ ```typescript
17
+ new ServerApi(client: RedseatClient)
18
+ ```
19
+
20
+ **Parameters:**
21
+ - `client`: An initialized `RedseatClient` instance
22
+
23
+ **Example:**
24
+ ```typescript
25
+ import { RedseatClient, ServerApi } from '@redseat/api';
26
+
27
+ const client = new RedseatClient({ /* ... */ });
28
+ const serverApi = new ServerApi(client);
29
+ ```
30
+
31
+ ## Methods
32
+
33
+ ### `getLibraries(): Promise<ILibrary[]>`
34
+
35
+ Retrieves all libraries available to the current user.
36
+
37
+ **Returns:** Promise resolving to an array of `ILibrary` objects
38
+
39
+ **Example:**
40
+ ```typescript
41
+ const libraries = await serverApi.getLibraries();
42
+ libraries.forEach(library => {
43
+ console.log(`Library: ${library.name} (${library.type})`);
44
+ });
45
+ ```
46
+
47
+ ### `getMe(): Promise<any>`
48
+
49
+ Gets information about the current authenticated user.
50
+
51
+ **Returns:** Promise resolving to user information object
52
+
53
+ **Example:**
54
+ ```typescript
55
+ const user = await serverApi.getMe();
56
+ console.log(`Logged in as: ${user.name}`);
57
+ ```
58
+
59
+ ### `addLibrary(library: Partial<ILibrary>): Promise<ILibrary>`
60
+
61
+ Creates a new library.
62
+
63
+ **Parameters:**
64
+ - `library`: Partial library object with required fields:
65
+ - `name`: Library name (required)
66
+ - `type`: Library type - `'photos'`, `'shows'`, `'movies'`, or `'iptv'` (required)
67
+ - `source`: Optional source type
68
+ - `crypt`: Optional boolean to enable encryption
69
+ - `hidden`: Optional boolean to hide library
70
+
71
+ **Returns:** Promise resolving to the created `ILibrary` object with generated `id`
72
+
73
+ **Example:**
74
+ ```typescript
75
+ const newLibrary = await serverApi.addLibrary({
76
+ name: 'My Photos',
77
+ type: 'photos',
78
+ crypt: true // Enable encryption
79
+ });
80
+ console.log(`Created library with ID: ${newLibrary.id}`);
81
+ ```
82
+
83
+ ### `getSetting(key: string): Promise<string>`
84
+
85
+ Retrieves a server setting value by key.
86
+
87
+ **Parameters:**
88
+ - `key`: The setting key to retrieve
89
+
90
+ **Returns:** Promise resolving to the setting value as a string
91
+
92
+ **Example:**
93
+ ```typescript
94
+ const maxUploadSize = await serverApi.getSetting('max_upload_size');
95
+ console.log(`Max upload size: ${maxUploadSize}`);
96
+ ```
97
+
98
+ ### `getPlugins(): Promise<any[]>`
99
+
100
+ Retrieves all available plugins on the server.
101
+
102
+ **Returns:** Promise resolving to an array of plugin objects
103
+
104
+ **Example:**
105
+ ```typescript
106
+ const plugins = await serverApi.getPlugins();
107
+ plugins.forEach(plugin => {
108
+ console.log(`Plugin: ${plugin.name} - ${plugin.description}`);
109
+ });
110
+ ```
111
+
112
+ ### `getCredentials(): Promise<any[]>`
113
+
114
+ Retrieves all available credentials configured on the server.
115
+
116
+ **Returns:** Promise resolving to an array of credential objects
117
+
118
+ **Example:**
119
+ ```typescript
120
+ const credentials = await serverApi.getCredentials();
121
+ credentials.forEach(cred => {
122
+ console.log(`Credential: ${cred.name} (${cred.type})`);
123
+ });
124
+ ```
125
+
126
+ ### `addLibraryCredential(credential: any): Promise<ILibrary>`
127
+
128
+ Adds a credential to a library. This is used to configure external service access for libraries.
129
+
130
+ **Parameters:**
131
+ - `credential`: Credential configuration object (structure depends on credential type)
132
+
133
+ **Returns:** Promise resolving to the updated `ILibrary` object
134
+
135
+ **Example:**
136
+ ```typescript
137
+ const library = await serverApi.addLibraryCredential({
138
+ libraryId: 'library-123',
139
+ credentialId: 'credential-456',
140
+ // Additional credential-specific configuration
141
+ });
142
+ ```
143
+
144
+ ## Usage Examples
145
+
146
+ ### Complete Workflow: Create Library and Get Info
147
+
148
+ ```typescript
149
+ import { RedseatClient, ServerApi } from '@redseat/api';
150
+
151
+ // Initialize
152
+ const client = new RedseatClient({ /* ... */ });
153
+ const serverApi = new ServerApi(client);
154
+
155
+ // Get current user
156
+ const user = await serverApi.getMe();
157
+ console.log(`User: ${user.name}`);
158
+
159
+ // List existing libraries
160
+ const libraries = await serverApi.getLibraries();
161
+ console.log(`Found ${libraries.length} libraries`);
162
+
163
+ // Create a new encrypted photo library
164
+ const newLibrary = await serverApi.addLibrary({
165
+ name: 'Encrypted Photos',
166
+ type: 'photos',
167
+ crypt: true
168
+ });
169
+
170
+ // Get server settings
171
+ const maxUpload = await serverApi.getSetting('max_upload_size');
172
+ console.log(`Max upload size: ${maxUpload}`);
173
+ ```
174
+
175
+ ### Error Handling
176
+
177
+ ```typescript
178
+ try {
179
+ const libraries = await serverApi.getLibraries();
180
+ } catch (error) {
181
+ if (error.response?.status === 401) {
182
+ console.error('Authentication failed');
183
+ } else if (error.response?.status === 403) {
184
+ console.error('Insufficient permissions');
185
+ } else {
186
+ console.error('Failed to get libraries:', error.message);
187
+ }
188
+ }
189
+ ```
190
+
191
+ ## Related Documentation
192
+
193
+ - [RedseatClient Documentation](client.md) - HTTP client used by ServerApi
194
+ - [LibraryApi Documentation](libraries.md) - Library-specific operations
195
+ - [README](README.md) - Package overview
196
+