@rixl/sdk 0.37.1 → 0.37.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 +46 -62
- package/package.json +23 -9
package/README.md
CHANGED
|
@@ -20,20 +20,24 @@ Requires Node.js 18+. ESM only.
|
|
|
20
20
|
## Quick Start
|
|
21
21
|
|
|
22
22
|
```ts
|
|
23
|
-
import {createClient,
|
|
23
|
+
import {createClient, imagesV1ImageServiceListImages} from "@rixl/sdk";
|
|
24
24
|
|
|
25
25
|
const client = createClient({
|
|
26
26
|
baseUrl: "https://api.rixl.com",
|
|
27
27
|
auth: process.env.RIXL_API_KEY,
|
|
28
|
-
responseStyle: "data",
|
|
29
28
|
});
|
|
30
29
|
|
|
31
|
-
const
|
|
30
|
+
const {data, error} = await imagesV1ImageServiceListImages({
|
|
32
31
|
client,
|
|
33
|
-
|
|
32
|
+
path: {project_id: "your_project_id"},
|
|
33
|
+
query: {"pagination.limit": 10},
|
|
34
34
|
});
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
if (error) {
|
|
37
|
+
console.error("Failed to list images:", error);
|
|
38
|
+
} else {
|
|
39
|
+
console.log(data?.images?.map((image) => image.id));
|
|
40
|
+
}
|
|
37
41
|
```
|
|
38
42
|
|
|
39
43
|
`auth` can be either a string or a function, so you can plug in API keys, bearer tokens, or runtime token refresh logic.
|
|
@@ -43,22 +47,19 @@ console.log(page.data?.map((image) => image.id));
|
|
|
43
47
|
Fetch a feed and read posts:
|
|
44
48
|
|
|
45
49
|
```ts
|
|
46
|
-
import {createClient,
|
|
50
|
+
import {createClient, postsV1PostServiceListPosts3} from "@rixl/sdk";
|
|
47
51
|
|
|
48
52
|
const client = createClient({
|
|
49
53
|
baseUrl: "https://api.rixl.com",
|
|
50
|
-
auth: process.env.RIXL_API_KEY,
|
|
51
|
-
responseStyle: "data",
|
|
52
54
|
});
|
|
53
55
|
|
|
54
|
-
const
|
|
56
|
+
const {data, error} = await postsV1PostServiceListPosts3({
|
|
55
57
|
client,
|
|
56
|
-
path: {
|
|
57
|
-
query: {limit: 20, offset: 0},
|
|
58
|
+
path: {feed_id: "FD4y3QB38S"},
|
|
58
59
|
});
|
|
59
60
|
|
|
60
|
-
for (const post of
|
|
61
|
-
console.log(post.id, post.
|
|
61
|
+
for (const post of data?.posts ?? []) {
|
|
62
|
+
console.log(post.id, post.creator_id);
|
|
62
63
|
}
|
|
63
64
|
```
|
|
64
65
|
|
|
@@ -67,61 +68,50 @@ for (const post of feed.data ?? []) {
|
|
|
67
68
|
List images and fetch one by ID:
|
|
68
69
|
|
|
69
70
|
```ts
|
|
70
|
-
import {createClient,
|
|
71
|
+
import {createClient, imagesV1ImageServiceGetImage, imagesV1ImageServiceListImages} from "@rixl/sdk";
|
|
71
72
|
|
|
72
73
|
const client = createClient({
|
|
73
74
|
baseUrl: "https://api.rixl.com",
|
|
74
75
|
auth: process.env.RIXL_API_KEY,
|
|
75
|
-
responseStyle: "data",
|
|
76
76
|
});
|
|
77
77
|
|
|
78
|
-
const
|
|
78
|
+
const list = await imagesV1ImageServiceListImages({
|
|
79
79
|
client,
|
|
80
|
-
|
|
80
|
+
path: {project_id: "your_project_id"},
|
|
81
|
+
query: {"pagination.limit": 25},
|
|
81
82
|
});
|
|
82
83
|
|
|
83
|
-
const image = await
|
|
84
|
+
const image = await imagesV1ImageServiceGetImage({
|
|
84
85
|
client,
|
|
85
|
-
path: {
|
|
86
|
+
path: {image_id: "PS5IMKoFLm"},
|
|
86
87
|
});
|
|
87
88
|
|
|
88
|
-
console.log(
|
|
89
|
+
console.log(list.data?.images?.length, image.data?.image?.id);
|
|
89
90
|
```
|
|
90
91
|
|
|
91
|
-
Initialize an upload
|
|
92
|
+
Initialize an upload and PUT the bytes to storage:
|
|
92
93
|
|
|
93
94
|
```ts
|
|
94
|
-
import {createClient,
|
|
95
|
+
import {createClient, imagesV1ImageServiceCreateImageUpload} from "@rixl/sdk";
|
|
95
96
|
|
|
96
97
|
const client = createClient({
|
|
97
98
|
baseUrl: "https://api.rixl.com",
|
|
98
99
|
auth: process.env.RIXL_API_KEY,
|
|
99
|
-
responseStyle: "data",
|
|
100
100
|
});
|
|
101
101
|
|
|
102
|
-
const init = await
|
|
102
|
+
const init = await imagesV1ImageServiceCreateImageUpload({
|
|
103
103
|
client,
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
format: "jpeg",
|
|
107
|
-
},
|
|
104
|
+
path: {project_id: "your_project_id"},
|
|
105
|
+
body: {name: "photo.jpg"},
|
|
108
106
|
});
|
|
109
107
|
|
|
110
|
-
await fetch(init.
|
|
108
|
+
await fetch(init.data?.upload_url!, {
|
|
111
109
|
method: "PUT",
|
|
112
110
|
body: imageBytes,
|
|
113
111
|
headers: {"Content-Type": "image/jpeg"},
|
|
114
112
|
});
|
|
115
113
|
|
|
116
|
-
|
|
117
|
-
client,
|
|
118
|
-
body: {
|
|
119
|
-
image_id: init.image_id,
|
|
120
|
-
attached_to_video: false,
|
|
121
|
-
},
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
console.log(image.id);
|
|
114
|
+
console.log(`Image ${init.data?.image_id} uploaded.`);
|
|
125
115
|
```
|
|
126
116
|
|
|
127
117
|
## Video API
|
|
@@ -129,67 +119,60 @@ console.log(image.id);
|
|
|
129
119
|
List videos and fetch one by ID:
|
|
130
120
|
|
|
131
121
|
```ts
|
|
132
|
-
import {createClient,
|
|
122
|
+
import {createClient, videosV1VideoServiceGetVideo, videosV1VideoServiceListVideos} from "@rixl/sdk";
|
|
133
123
|
|
|
134
124
|
const client = createClient({
|
|
135
125
|
baseUrl: "https://api.rixl.com",
|
|
136
126
|
auth: process.env.RIXL_API_KEY,
|
|
137
|
-
responseStyle: "data",
|
|
138
127
|
});
|
|
139
128
|
|
|
140
|
-
const page = await
|
|
129
|
+
const page = await videosV1VideoServiceListVideos({
|
|
141
130
|
client,
|
|
142
|
-
|
|
131
|
+
path: {project_id: "your_project_id"},
|
|
132
|
+
query: {"pagination.limit": 25},
|
|
143
133
|
});
|
|
144
134
|
|
|
145
|
-
const video = await
|
|
135
|
+
const video = await videosV1VideoServiceGetVideo({
|
|
146
136
|
client,
|
|
147
|
-
path: {
|
|
137
|
+
path: {video_id: "VI9VXQxWXQ"},
|
|
148
138
|
});
|
|
149
139
|
|
|
150
|
-
console.log(page.data?.length, video.id, video.duration);
|
|
140
|
+
console.log(page.data?.videos?.length, video.data?.video?.id, video.data?.video?.duration);
|
|
151
141
|
```
|
|
152
142
|
|
|
153
|
-
Video uploads
|
|
143
|
+
Video uploads request presigned URLs for both the video and its poster:
|
|
154
144
|
|
|
155
145
|
```ts
|
|
156
|
-
import {createClient,
|
|
146
|
+
import {createClient, videosV1VideoServiceCreateVideoUpload} from "@rixl/sdk";
|
|
157
147
|
|
|
158
148
|
const client = createClient({
|
|
159
149
|
baseUrl: "https://api.rixl.com",
|
|
160
150
|
auth: process.env.RIXL_API_KEY,
|
|
161
|
-
responseStyle: "data",
|
|
162
151
|
});
|
|
163
152
|
|
|
164
|
-
const init = await
|
|
153
|
+
const init = await videosV1VideoServiceCreateVideoUpload({
|
|
165
154
|
client,
|
|
155
|
+
path: {project_id: "your_project_id"},
|
|
166
156
|
body: {
|
|
167
|
-
|
|
168
|
-
|
|
157
|
+
name: "clip.mp4",
|
|
158
|
+
video_quality: "VIDEO_QUALITY_PRO",
|
|
169
159
|
},
|
|
170
160
|
});
|
|
171
161
|
|
|
172
162
|
await Promise.all([
|
|
173
|
-
fetch(init.
|
|
163
|
+
fetch(init.data?.video_upload_url!, {
|
|
174
164
|
method: "PUT",
|
|
175
165
|
body: videoBytes,
|
|
176
166
|
headers: {"Content-Type": "video/mp4"},
|
|
177
167
|
}),
|
|
178
|
-
fetch(init.
|
|
168
|
+
fetch(init.data?.poster_upload_url!, {
|
|
179
169
|
method: "PUT",
|
|
180
170
|
body: posterBytes,
|
|
181
171
|
headers: {"Content-Type": "image/jpeg"},
|
|
182
172
|
}),
|
|
183
173
|
]);
|
|
184
174
|
|
|
185
|
-
|
|
186
|
-
client,
|
|
187
|
-
body: {
|
|
188
|
-
video_id: init.video_id,
|
|
189
|
-
},
|
|
190
|
-
});
|
|
191
|
-
|
|
192
|
-
console.log(video.id);
|
|
175
|
+
console.log(`Video ${init.data?.video_id} uploaded.`);
|
|
193
176
|
```
|
|
194
177
|
|
|
195
178
|
## Development
|
|
@@ -198,8 +181,9 @@ This repository uses [Vite+](https://viteplus.dev/guide/) as the unified toolcha
|
|
|
198
181
|
|
|
199
182
|
```bash
|
|
200
183
|
vp install # Install dependencies
|
|
201
|
-
vp
|
|
184
|
+
vp pack # Build the library
|
|
202
185
|
vp check # Run formatting, linting, and type checks
|
|
186
|
+
vp test # Run Vitest test suite
|
|
203
187
|
```
|
|
204
188
|
|
|
205
189
|
## Issues
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rixl/sdk",
|
|
3
|
-
"version": "0.37.
|
|
3
|
+
"version": "0.37.2",
|
|
4
4
|
"description": "Official TypeScript/JavaScript SDK for the Rixl platform — typed API client, authentication, and reactive state.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"media",
|
|
@@ -44,27 +44,41 @@
|
|
|
44
44
|
"test:coverage": "vp test --coverage",
|
|
45
45
|
"typecheck": "tsc --noEmit",
|
|
46
46
|
"examples:check": "tsc --noEmit -p examples/tsconfig.json",
|
|
47
|
+
"prepublishOnly": "vp run build",
|
|
47
48
|
"prepare": "[ -n \"$CI\" ] || lefthook install --reset-hooks-path",
|
|
48
49
|
"ci:release": "vp check && vp pack && npm publish"
|
|
49
50
|
},
|
|
50
51
|
"dependencies": {
|
|
51
|
-
"jose": "^6.2.
|
|
52
|
-
"nanostores": "^1.5.
|
|
53
|
-
"valibot": "^1.
|
|
52
|
+
"jose": "^6.2.13",
|
|
53
|
+
"nanostores": "^1.5.5",
|
|
54
|
+
"valibot": "^1.5.0"
|
|
54
55
|
},
|
|
55
56
|
"devDependencies": {
|
|
56
57
|
"@hey-api/vite-plugin": "0.3.2",
|
|
57
|
-
"@types/node": "^26.
|
|
58
|
+
"@types/node": "^26.6.5",
|
|
58
59
|
"@vitest/coverage-v8": "5.0.5",
|
|
59
60
|
"@vitest/ui": "5.0.5",
|
|
60
|
-
"jsdom": "^30.
|
|
61
|
+
"jsdom": "^30.1.3",
|
|
61
62
|
"lefthook": "^2.2.2",
|
|
62
|
-
"typescript": "
|
|
63
|
+
"typescript": "^7.0.2",
|
|
64
|
+
"typescript-compat": "npm:typescript@6.0.3",
|
|
63
65
|
"vite": "npm:@voidzero-dev/vite-plus-core@1.3.0",
|
|
64
66
|
"vite-plus": "1.3.0"
|
|
65
67
|
},
|
|
68
|
+
"overrides": {
|
|
69
|
+
"@hey-api/openapi-ts": {
|
|
70
|
+
"typescript": "6.0.3"
|
|
71
|
+
},
|
|
72
|
+
"vite": "npm:@voidzero-dev/vite-plus-core@1.3.0"
|
|
73
|
+
},
|
|
74
|
+
"devEngines": {
|
|
75
|
+
"packageManager": {
|
|
76
|
+
"name": "bun",
|
|
77
|
+
"version": "1.4.4",
|
|
78
|
+
"onFail": "warn"
|
|
79
|
+
}
|
|
80
|
+
},
|
|
66
81
|
"engines": {
|
|
67
82
|
"node": ">=24"
|
|
68
|
-
}
|
|
69
|
-
"packageManager": "bun@1.4.0"
|
|
83
|
+
}
|
|
70
84
|
}
|