@rixl/sdk 0.37.1 → 0.38.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/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, getImages} from "@rixl/sdk";
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 page = await getImages({
30
+ const {data, error} = await imagesV1ImageServiceListImages({
32
31
  client,
33
- query: {limit: 10},
32
+ path: {project_id: "your_project_id"},
33
+ query: {"pagination.limit": 10},
34
34
  });
35
35
 
36
- console.log(page.data?.map((image) => image.id));
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, getFeedsByFeedId} from "@rixl/sdk";
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 feed = await getFeedsByFeedId({
56
+ const {data, error} = await postsV1PostServiceListPosts3({
55
57
  client,
56
- path: {feedId: "FD4y3QB38S"},
57
- query: {limit: 20, offset: 0},
58
+ path: {feed_id: "FD4y3QB38S"},
58
59
  });
59
60
 
60
- for (const post of feed.data ?? []) {
61
- console.log(post.id, post.type);
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, getImages, getImagesByImageId} from "@rixl/sdk";
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 page = await getImages({
78
+ const list = await imagesV1ImageServiceListImages({
79
79
  client,
80
- query: {limit: 25, offset: 0},
80
+ path: {project_id: "your_project_id"},
81
+ query: {"pagination.limit": 25},
81
82
  });
82
83
 
83
- const image = await getImagesByImageId({
84
+ const image = await imagesV1ImageServiceGetImage({
84
85
  client,
85
- path: {imageId: "PS5IMKoFLm"},
86
+ path: {image_id: "PS5IMKoFLm"},
86
87
  });
87
88
 
88
- console.log(page.data?.length, image.id, image.width, image.height);
89
+ console.log(list.data?.images?.length, image.data?.image?.id);
89
90
  ```
90
91
 
91
- Initialize an upload, PUT the bytes to storage, then complete the upload:
92
+ Initialize an upload and PUT the bytes to storage:
92
93
 
93
94
  ```ts
94
- import {createClient, postImagesUploadComplete, postImagesUploadInit} from "@rixl/sdk";
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 postImagesUploadInit({
102
+ const init = await imagesV1ImageServiceCreateImageUpload({
103
103
  client,
104
- body: {
105
- name: "photo.jpg",
106
- format: "jpeg",
107
- },
104
+ path: {project_id: "your_project_id"},
105
+ body: {name: "photo.jpg"},
108
106
  });
109
107
 
110
- await fetch(init.presigned_url!, {
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
- const image = await postImagesUploadComplete({
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, getVideos, getVideosByVideoId} from "@rixl/sdk";
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 getVideos({
129
+ const page = await videosV1VideoServiceListVideos({
141
130
  client,
142
- query: {limit: 25, offset: 0},
131
+ path: {project_id: "your_project_id"},
132
+ query: {"pagination.limit": 25},
143
133
  });
144
134
 
145
- const video = await getVideosByVideoId({
135
+ const video = await videosV1VideoServiceGetVideo({
146
136
  client,
147
- path: {videoId: "VI9VXQxWXQ"},
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 follow the same pattern, but `init` returns both video and poster upload URLs:
143
+ Video uploads request presigned URLs for both the video and its poster:
154
144
 
155
145
  ```ts
156
- import {createClient, postVideosUploadComplete, postVideosUploadInit} from "@rixl/sdk";
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 postVideosUploadInit({
153
+ const init = await videosV1VideoServiceCreateVideoUpload({
165
154
  client,
155
+ path: {project_id: "your_project_id"},
166
156
  body: {
167
- file_name: "clip.mp4",
168
- image_format: "jpeg",
157
+ name: "clip.mp4",
158
+ video_quality: "VIDEO_QUALITY_PRO",
169
159
  },
170
160
  });
171
161
 
172
162
  await Promise.all([
173
- fetch(init.video_presigned_url!, {
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.poster_presigned_url!, {
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
- const video = await postVideosUploadComplete({
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 run pack # Build the library
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/dist/index.js CHANGED
@@ -3176,6 +3176,7 @@ function setCookie(name, value, options) {
3176
3176
  function deleteCookie(name) {
3177
3177
  if (typeof document === "undefined") return;
3178
3178
  document.cookie = name + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
3179
+ document.cookie = name + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC;";
3179
3180
  }
3180
3181
  const encodeName = (name) => encodeURIComponent(name).replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent);
3181
3182
  const encodeValue = (value) => encodeURIComponent(value).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g, decodeURIComponent);