@redseat/api 0.2.5 → 0.2.7
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/{agents.md → AGENTS.md} +275 -275
- package/CLAUDE.md +2 -0
- package/README.md +132 -132
- package/client.md +318 -318
- package/dist/client.d.ts +10 -0
- package/dist/client.js +28 -0
- package/dist/interfaces.d.ts +14 -0
- package/dist/library.d.ts +12 -1
- package/dist/library.js +14 -0
- package/encryption.md +533 -533
- package/firebase.md +602 -602
- package/libraries.md +84 -0
- package/package.json +49 -49
- package/server.md +196 -196
- package/test.md +291 -291
package/libraries.md
CHANGED
|
@@ -1064,6 +1064,90 @@ if (library.crypt) {
|
|
|
1064
1064
|
}
|
|
1065
1065
|
```
|
|
1066
1066
|
|
|
1067
|
+
### `uploadGroup(download: RsGroupDownload, options?: { spawn?: boolean }): Promise<IFile[] | { downloading: boolean }>`
|
|
1068
|
+
|
|
1069
|
+
Uploads a group of media files from URLs.
|
|
1070
|
+
|
|
1071
|
+
**Parameters:**
|
|
1072
|
+
|
|
1073
|
+
- `download`: The group download request containing:
|
|
1074
|
+
- `group`: Boolean indicating if files should be grouped
|
|
1075
|
+
- `groupThumbnailUrl?`: Optional thumbnail URL for the group
|
|
1076
|
+
- `groupFilename?`: Optional filename for the group
|
|
1077
|
+
- `groupMime?`: Optional MIME type for the group
|
|
1078
|
+
- `requests`: Array of `RsRequest` objects, each containing:
|
|
1079
|
+
- `url`: The URL to download from
|
|
1080
|
+
- `status`: `RsRequestStatus` (e.g., `NeedParsing`, `Unprocessed`)
|
|
1081
|
+
- `permanent`: Boolean for permanent storage
|
|
1082
|
+
- `method`: `RsRequestMethod` (e.g., `Get`, `Post`)
|
|
1083
|
+
- `ignoreOriginDuplicate`: Boolean to ignore duplicate origins
|
|
1084
|
+
- Optional fields: `headers`, `cookies`, `referer`, `filename`, `mime`, `thumbnailUrl`, `tagsLookup`, `peopleLookup`, `albumsLookup`, etc.
|
|
1085
|
+
- `options`: Optional settings object:
|
|
1086
|
+
- `spawn?`: If true, runs download in background and returns `{ downloading: true }`
|
|
1087
|
+
|
|
1088
|
+
**Returns:** Promise resolving to an array of `IFile` objects when `spawn=false`, or `{ downloading: boolean }` when `spawn=true`
|
|
1089
|
+
|
|
1090
|
+
**Example:**
|
|
1091
|
+
|
|
1092
|
+
```typescript
|
|
1093
|
+
import { RsRequestStatus, RsRequestMethod } from '@redseat/api';
|
|
1094
|
+
|
|
1095
|
+
// Download a single URL
|
|
1096
|
+
const files = await libraryApi.uploadGroup({
|
|
1097
|
+
group: false,
|
|
1098
|
+
requests: [
|
|
1099
|
+
{
|
|
1100
|
+
url: 'https://example.com/video.mp4',
|
|
1101
|
+
status: RsRequestStatus.Unprocessed,
|
|
1102
|
+
permanent: false,
|
|
1103
|
+
method: RsRequestMethod.Get,
|
|
1104
|
+
ignoreOriginDuplicate: false
|
|
1105
|
+
}
|
|
1106
|
+
]
|
|
1107
|
+
});
|
|
1108
|
+
|
|
1109
|
+
// Download multiple URLs as a group with parsing
|
|
1110
|
+
const groupedFiles = await libraryApi.uploadGroup({
|
|
1111
|
+
group: true,
|
|
1112
|
+
groupFilename: 'my-collection',
|
|
1113
|
+
requests: [
|
|
1114
|
+
{
|
|
1115
|
+
url: 'https://example.com/video1.mp4',
|
|
1116
|
+
status: RsRequestStatus.NeedParsing,
|
|
1117
|
+
permanent: false,
|
|
1118
|
+
method: RsRequestMethod.Get,
|
|
1119
|
+
ignoreOriginDuplicate: false,
|
|
1120
|
+
tagsLookup: ['vacation', 'beach']
|
|
1121
|
+
},
|
|
1122
|
+
{
|
|
1123
|
+
url: 'https://example.com/video2.mp4',
|
|
1124
|
+
status: RsRequestStatus.NeedParsing,
|
|
1125
|
+
permanent: false,
|
|
1126
|
+
method: RsRequestMethod.Get,
|
|
1127
|
+
ignoreOriginDuplicate: false
|
|
1128
|
+
}
|
|
1129
|
+
]
|
|
1130
|
+
});
|
|
1131
|
+
|
|
1132
|
+
// Run download in background
|
|
1133
|
+
const result = await libraryApi.uploadGroup(
|
|
1134
|
+
{
|
|
1135
|
+
group: false,
|
|
1136
|
+
requests: [
|
|
1137
|
+
{
|
|
1138
|
+
url: 'https://example.com/large-video.mp4',
|
|
1139
|
+
status: RsRequestStatus.Unprocessed,
|
|
1140
|
+
permanent: false,
|
|
1141
|
+
method: RsRequestMethod.Get,
|
|
1142
|
+
ignoreOriginDuplicate: false
|
|
1143
|
+
}
|
|
1144
|
+
]
|
|
1145
|
+
},
|
|
1146
|
+
{ spawn: true }
|
|
1147
|
+
);
|
|
1148
|
+
// result = { downloading: true }
|
|
1149
|
+
```
|
|
1150
|
+
|
|
1067
1151
|
### `removeMedias(mediaIds: string[]): Promise<void>`
|
|
1068
1152
|
|
|
1069
1153
|
Deletes multiple media files.
|
package/package.json
CHANGED
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@redseat/api",
|
|
3
|
-
"version": "0.2.
|
|
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.2.7",
|
|
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
|
+
|