@rixl/sdk 0.1.0 → 0.2.2
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/README.md +163 -88
- package/dist/index.d.ts +1665 -5
- package/dist/index.js +1021 -5
- package/dist/index.js.map +1 -0
- package/package.json +34 -30
- package/dist/feeds/index.d.ts +0 -21
- package/dist/feeds/index.js +0 -21
- package/dist/feeds/item/creators/index.d.ts +0 -21
- package/dist/feeds/item/creators/index.js +0 -20
- package/dist/feeds/item/creators/item/index.d.ts +0 -42
- package/dist/feeds/item/creators/item/index.js +0 -28
- package/dist/feeds/item/index.d.ts +0 -58
- package/dist/feeds/item/index.js +0 -44
- package/dist/feeds/item/item/index.d.ts +0 -29
- package/dist/feeds/item/item/index.js +0 -28
- package/dist/images/index.d.ts +0 -68
- package/dist/images/index.js +0 -46
- package/dist/images/item/index.d.ts +0 -48
- package/dist/images/item/index.js +0 -43
- package/dist/images/upload/complete/index.d.ts +0 -35
- package/dist/images/upload/complete/index.js +0 -36
- package/dist/images/upload/index.d.ts +0 -24
- package/dist/images/upload/index.js +0 -24
- package/dist/images/upload/init/index.d.ts +0 -33
- package/dist/images/upload/init/index.js +0 -33
- package/dist/models/github_com_rixlhq_api_db_sqlc/index.d.ts +0 -13
- package/dist/models/github_com_rixlhq_api_db_sqlc/index.js +0 -16
- package/dist/models/github_com_rixlhq_api_internal_errors/index.d.ts +0 -37
- package/dist/models/github_com_rixlhq_api_internal_errors/index.js +0 -40
- package/dist/models/github_com_rixlhq_api_internal_videos/index.d.ts +0 -72
- package/dist/models/github_com_rixlhq_api_internal_videos/index.js +0 -65
- package/dist/models/github_com_rixlhq_api_internal_videos_handler_upload/index.d.ts +0 -70
- package/dist/models/github_com_rixlhq_api_internal_videos_handler_upload/index.js +0 -78
- package/dist/models/github_com_rixlhq_api_internal_videos_types/index.d.ts +0 -30
- package/dist/models/github_com_rixlhq_api_internal_videos_types/index.js +0 -38
- package/dist/models/index.d.ts +0 -548
- package/dist/models/index.js +0 -543
- package/dist/models/internal_images_handler/index.d.ts +0 -98
- package/dist/models/internal_images_handler/index.js +0 -112
- package/dist/models/internal_videos_handler_subtitles/index.d.ts +0 -30
- package/dist/models/internal_videos_handler_subtitles/index.js +0 -38
- package/dist/models/pagination/index.d.ts +0 -125
- package/dist/models/pagination/index.js +0 -153
- package/dist/rixlClient.d.ts +0 -34
- package/dist/rixlClient.js +0 -69
- package/dist/videos/index.d.ts +0 -73
- package/dist/videos/index.js +0 -52
- package/dist/videos/item/audioTracks/index.d.ts +0 -38
- package/dist/videos/item/audioTracks/index.js +0 -33
- package/dist/videos/item/audioTracks/item/index.d.ts +0 -70
- package/dist/videos/item/audioTracks/item/index.js +0 -67
- package/dist/videos/item/chapters/index.d.ts +0 -50
- package/dist/videos/item/chapters/index.js +0 -46
- package/dist/videos/item/delete/index.d.ts +0 -30
- package/dist/videos/item/delete/index.js +0 -28
- package/dist/videos/item/index.d.ts +0 -61
- package/dist/videos/item/index.js +0 -63
- package/dist/videos/item/subtitles/index.d.ts +0 -38
- package/dist/videos/item/subtitles/index.js +0 -33
- package/dist/videos/item/subtitles/item/index.d.ts +0 -70
- package/dist/videos/item/subtitles/item/index.js +0 -67
- package/dist/videos/item/thumbnail/index.d.ts +0 -59
- package/dist/videos/item/thumbnail/index.js +0 -68
- package/dist/videos/languages/index.d.ts +0 -27
- package/dist/videos/languages/index.js +0 -22
- package/dist/videos/upload/complete/index.d.ts +0 -35
- package/dist/videos/upload/complete/index.js +0 -36
- package/dist/videos/upload/index.d.ts +0 -24
- package/dist/videos/upload/index.js +0 -24
- package/dist/videos/upload/init/index.d.ts +0 -34
- package/dist/videos/upload/init/index.js +0 -35
package/README.md
CHANGED
|
@@ -2,150 +2,225 @@
|
|
|
2
2
|
|
|
3
3
|
Official TypeScript / JavaScript SDK for the [Rixl](https://rixl.com) REST API.
|
|
4
4
|
|
|
5
|
+
Published on npm as [`@rixl/sdk`](https://www.npmjs.com/package/@rixl/sdk).
|
|
6
|
+
|
|
5
7
|
[](https://www.npmjs.com/package/@rixl/sdk)
|
|
6
8
|
|
|
7
9
|
## Install
|
|
8
10
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
| npm | pnpm | bun | vite plus |
|
|
12
|
+
| ----------------- | ------------------ | ----------------- | ---------------- |
|
|
13
|
+
| `npm i @rixl/sdk` | `pnpm i @rixl/sdk` | `bun i @rixl/sdk` | `vp i @rixl/sdk` |
|
|
12
14
|
|
|
13
|
-
Requires Node.js 18+. ESM only
|
|
15
|
+
Requires Node.js 18+. ESM only.
|
|
14
16
|
|
|
15
|
-
## Quick
|
|
17
|
+
## Quick Start
|
|
16
18
|
|
|
17
19
|
```ts
|
|
18
|
-
import {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
);
|
|
25
|
-
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
20
|
+
import {createClient, getImages} from "@rixl/sdk";
|
|
21
|
+
|
|
22
|
+
const client = createClient({
|
|
23
|
+
baseUrl: "https://api.rixl.com",
|
|
24
|
+
auth: process.env.RIXL_API_KEY,
|
|
25
|
+
responseStyle: "data",
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
const page = await getImages({
|
|
29
|
+
client,
|
|
30
|
+
query: {limit: 10},
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
console.log(page.data?.map((image) => image.id));
|
|
30
34
|
```
|
|
31
35
|
|
|
32
|
-
|
|
36
|
+
`auth` can be either a string or a function, so you can plug in API keys, bearer tokens, or runtime token refresh logic.
|
|
33
37
|
|
|
34
|
-
##
|
|
38
|
+
## Feed API
|
|
35
39
|
|
|
36
|
-
|
|
40
|
+
Fetch a feed and read posts:
|
|
37
41
|
|
|
38
42
|
```ts
|
|
39
|
-
import {
|
|
40
|
-
|
|
41
|
-
const auth = new ApiKeyAuthenticationProvider(
|
|
42
|
-
"YOUR_RIXL_API_KEY", "X-API-Key", "header",
|
|
43
|
-
);
|
|
44
|
-
```
|
|
43
|
+
import {createClient, getFeedsByFeedId} from "@rixl/sdk";
|
|
45
44
|
|
|
46
|
-
|
|
45
|
+
const client = createClient({
|
|
46
|
+
baseUrl: "https://api.rixl.com",
|
|
47
|
+
auth: process.env.RIXL_API_KEY,
|
|
48
|
+
responseStyle: "data",
|
|
49
|
+
});
|
|
47
50
|
|
|
48
|
-
|
|
51
|
+
const feed = await getFeedsByFeedId({
|
|
52
|
+
client,
|
|
53
|
+
path: {feedId: "FD4y3QB38S"},
|
|
54
|
+
query: {limit: 20, offset: 0},
|
|
55
|
+
});
|
|
49
56
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
for (const post of posts?.data ?? []) {
|
|
53
|
-
console.log(post.id);
|
|
57
|
+
for (const post of feed.data ?? []) {
|
|
58
|
+
console.log(post.id, post.type);
|
|
54
59
|
}
|
|
55
60
|
```
|
|
56
61
|
|
|
57
|
-
##
|
|
62
|
+
## Image API
|
|
63
|
+
|
|
64
|
+
List images and fetch one by ID:
|
|
58
65
|
|
|
59
66
|
```ts
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
67
|
+
import {createClient, getImages, getImagesByImageId} from "@rixl/sdk";
|
|
68
|
+
|
|
69
|
+
const client = createClient({
|
|
70
|
+
baseUrl: "https://api.rixl.com",
|
|
71
|
+
auth: process.env.RIXL_API_KEY,
|
|
72
|
+
responseStyle: "data",
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
const page = await getImages({
|
|
76
|
+
client,
|
|
77
|
+
query: {limit: 25, offset: 0},
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
const image = await getImagesByImageId({
|
|
81
|
+
client,
|
|
82
|
+
path: {imageId: "PS5IMKoFLm"},
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
console.log(page.data?.length, image.id, image.width, image.height);
|
|
63
86
|
```
|
|
64
87
|
|
|
65
|
-
|
|
88
|
+
Initialize an upload, PUT the bytes to storage, then complete the upload:
|
|
66
89
|
|
|
67
90
|
```ts
|
|
68
|
-
|
|
91
|
+
import {createClient, postImagesUploadComplete, postImagesUploadInit} from "@rixl/sdk";
|
|
92
|
+
|
|
93
|
+
const client = createClient({
|
|
94
|
+
baseUrl: "https://api.rixl.com",
|
|
95
|
+
auth: process.env.RIXL_API_KEY,
|
|
96
|
+
responseStyle: "data",
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
const init = await postImagesUploadInit({
|
|
100
|
+
client,
|
|
101
|
+
body: {
|
|
69
102
|
name: "photo.jpg",
|
|
70
103
|
format: "jpeg",
|
|
104
|
+
},
|
|
71
105
|
});
|
|
72
106
|
|
|
73
|
-
await fetch(
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
107
|
+
await fetch(init.presigned_url!, {
|
|
108
|
+
method: "PUT",
|
|
109
|
+
body: imageBytes,
|
|
110
|
+
headers: {"Content-Type": "image/jpeg"},
|
|
77
111
|
});
|
|
78
112
|
|
|
79
|
-
const image = await
|
|
80
|
-
|
|
81
|
-
|
|
113
|
+
const image = await postImagesUploadComplete({
|
|
114
|
+
client,
|
|
115
|
+
body: {
|
|
116
|
+
image_id: init.image_id,
|
|
117
|
+
attached_to_video: false,
|
|
118
|
+
},
|
|
82
119
|
});
|
|
120
|
+
|
|
121
|
+
console.log(image.id);
|
|
83
122
|
```
|
|
84
123
|
|
|
85
|
-
##
|
|
124
|
+
## Video API
|
|
125
|
+
|
|
126
|
+
List videos and fetch one by ID:
|
|
86
127
|
|
|
87
128
|
```ts
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
const
|
|
129
|
+
import {createClient, getVideos, getVideosByVideoId} from "@rixl/sdk";
|
|
130
|
+
|
|
131
|
+
const client = createClient({
|
|
132
|
+
baseUrl: "https://api.rixl.com",
|
|
133
|
+
auth: process.env.RIXL_API_KEY,
|
|
134
|
+
responseStyle: "data",
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
const page = await getVideos({
|
|
138
|
+
client,
|
|
139
|
+
query: {limit: 25, offset: 0},
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
const video = await getVideosByVideoId({
|
|
143
|
+
client,
|
|
144
|
+
path: {videoId: "VI9VXQxWXQ"},
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
console.log(page.data?.length, video.id, video.duration);
|
|
91
148
|
```
|
|
92
149
|
|
|
93
|
-
|
|
150
|
+
Video uploads follow the same pattern, but `init` returns both video and poster upload URLs:
|
|
94
151
|
|
|
95
152
|
```ts
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
153
|
+
import {createClient, postVideosUploadComplete, postVideosUploadInit} from "@rixl/sdk";
|
|
154
|
+
|
|
155
|
+
const client = createClient({
|
|
156
|
+
baseUrl: "https://api.rixl.com",
|
|
157
|
+
auth: process.env.RIXL_API_KEY,
|
|
158
|
+
responseStyle: "data",
|
|
99
159
|
});
|
|
100
|
-
// PUT bytes to initRes.videoPresignedUrl and initRes.posterPresignedUrl
|
|
101
160
|
|
|
102
|
-
const
|
|
103
|
-
|
|
161
|
+
const init = await postVideosUploadInit({
|
|
162
|
+
client,
|
|
163
|
+
body: {
|
|
164
|
+
file_name: "clip.mp4",
|
|
165
|
+
image_format: "jpeg",
|
|
166
|
+
},
|
|
104
167
|
});
|
|
168
|
+
|
|
169
|
+
await Promise.all([
|
|
170
|
+
fetch(init.video_presigned_url!, {
|
|
171
|
+
method: "PUT",
|
|
172
|
+
body: videoBytes,
|
|
173
|
+
headers: {"Content-Type": "video/mp4"},
|
|
174
|
+
}),
|
|
175
|
+
fetch(init.poster_presigned_url!, {
|
|
176
|
+
method: "PUT",
|
|
177
|
+
body: posterBytes,
|
|
178
|
+
headers: {"Content-Type": "image/jpeg"},
|
|
179
|
+
}),
|
|
180
|
+
]);
|
|
181
|
+
|
|
182
|
+
const video = await postVideosUploadComplete({
|
|
183
|
+
client,
|
|
184
|
+
body: {
|
|
185
|
+
video_id: init.video_id,
|
|
186
|
+
},
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
console.log(video.id);
|
|
105
190
|
```
|
|
106
191
|
|
|
107
|
-
##
|
|
192
|
+
## Development
|
|
108
193
|
|
|
109
|
-
|
|
194
|
+
This repository uses [Vite+](https://viteplus.dev/guide/) as the unified toolchain and package manager wrapper, with Bun underneath.
|
|
110
195
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
while (true) {
|
|
116
|
-
const page = await client.images.get({
|
|
117
|
-
queryParameters: { limit, offset, sort: "created_at", order: "desc" },
|
|
118
|
-
});
|
|
119
|
-
const total = page?.pagination?.total ?? 0;
|
|
120
|
-
offset += limit;
|
|
121
|
-
if (offset >= total) break;
|
|
122
|
-
}
|
|
196
|
+
Install dependencies:
|
|
197
|
+
|
|
198
|
+
```bash
|
|
199
|
+
vp install
|
|
123
200
|
```
|
|
124
201
|
|
|
125
|
-
|
|
202
|
+
Regenerate config after dependency or config changes:
|
|
126
203
|
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
try {
|
|
131
|
-
const image = await client.images.byImageId("PS5IMKoFLm").get();
|
|
132
|
-
} catch (err) {
|
|
133
|
-
if (err instanceof ErrorResponse) {
|
|
134
|
-
console.error(`HTTP ${err.code}: ${err.errorEscaped}`);
|
|
135
|
-
}
|
|
136
|
-
throw err;
|
|
137
|
-
}
|
|
204
|
+
```bash
|
|
205
|
+
vp config
|
|
138
206
|
```
|
|
139
207
|
|
|
140
|
-
|
|
208
|
+
Build the library:
|
|
209
|
+
|
|
210
|
+
```bash
|
|
211
|
+
vp pack
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
Run formatting, linting, and type checks:
|
|
215
|
+
|
|
216
|
+
```bash
|
|
217
|
+
vp check
|
|
218
|
+
```
|
|
141
219
|
|
|
142
|
-
|
|
220
|
+
Run tests:
|
|
143
221
|
|
|
144
222
|
```bash
|
|
145
|
-
|
|
146
|
-
export RIXL_API_KEY=<key>
|
|
147
|
-
npm run basic:images
|
|
148
|
-
npm run advanced:videos
|
|
223
|
+
vp test
|
|
149
224
|
```
|
|
150
225
|
|
|
151
226
|
## Issues
|