@trainly/react 1.0.2 → 1.0.3

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.
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
3
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
4
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -1,3 +1,14 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
1
12
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
13
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
14
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -138,9 +149,9 @@ var TrainlyClient = /** @class */ (function () {
138
149
  };
139
150
  TrainlyClient.prototype.upload = function (file) {
140
151
  return __awaiter(this, void 0, void 0, function () {
141
- var formData, response, error, presignedResponse, error, upload_url, uploadResponse;
142
- return __generator(this, function (_a) {
143
- switch (_a.label) {
152
+ var formData, response, error, presignedResponse, error, _a, upload_url, upload_headers, formData, uploadResponse;
153
+ return __generator(this, function (_b) {
154
+ switch (_b.label) {
144
155
  case 0:
145
156
  if (!this.scopedToken) {
146
157
  throw new Error("Not connected. Call connect() first.");
@@ -156,11 +167,11 @@ var TrainlyClient = /** @class */ (function () {
156
167
  body: formData,
157
168
  })];
158
169
  case 1:
159
- response = _a.sent();
170
+ response = _b.sent();
160
171
  if (!!response.ok) return [3 /*break*/, 3];
161
172
  return [4 /*yield*/, response.json()];
162
173
  case 2:
163
- error = _a.sent();
174
+ error = _b.sent();
164
175
  throw new Error("Upload failed: ".concat(error.detail || response.statusText));
165
176
  case 3: return [2 /*return*/, {
166
177
  success: true,
@@ -183,24 +194,24 @@ var TrainlyClient = /** @class */ (function () {
183
194
  }),
184
195
  })];
185
196
  case 5:
186
- presignedResponse = _a.sent();
197
+ presignedResponse = _b.sent();
187
198
  if (!!presignedResponse.ok) return [3 /*break*/, 7];
188
199
  return [4 /*yield*/, presignedResponse.json()];
189
200
  case 6:
190
- error = _a.sent();
201
+ error = _b.sent();
191
202
  throw new Error("Failed to get upload URL: ".concat(error.detail || presignedResponse.statusText));
192
203
  case 7: return [4 /*yield*/, presignedResponse.json()];
193
204
  case 8:
194
- upload_url = (_a.sent()).upload_url;
205
+ _a = _b.sent(), upload_url = _a.upload_url, upload_headers = _a.upload_headers;
206
+ formData = new FormData();
207
+ formData.append("file", file);
195
208
  return [4 /*yield*/, fetch(upload_url, {
196
- method: "PUT",
197
- body: file,
198
- headers: {
199
- "Content-Type": file.type,
200
- },
209
+ method: "POST",
210
+ body: formData,
211
+ headers: __assign({}, upload_headers),
201
212
  })];
202
213
  case 9:
203
- uploadResponse = _a.sent();
214
+ uploadResponse = _b.sent();
204
215
  if (!uploadResponse.ok) {
205
216
  throw new Error("Failed to upload file");
206
217
  }
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
3
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
4
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
3
  import { useTrainly } from "../useTrainly";
3
4
  export function TrainlyStatus(_a) {
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
3
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
4
  return new (P || (P = Promise))(function (resolve, reject) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trainly/react",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "Dead simple RAG integration for React apps",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",