@bikefinder/sdk 0.33.0 → 0.33.1

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
@@ -88,9 +88,10 @@ helper sends JPEG bytes directly to private staging storage, then asks the API
88
88
  to sanitize and publish the image:
89
89
 
90
90
  ```ts
91
+ const requestId = crypto.randomUUID();
91
92
  const result = await client.uploadPhoto({
92
93
  deviceId,
93
- requestId: crypto.randomUUID(),
94
+ requestId,
94
95
  kind: "bike",
95
96
  body: jpegBlob,
96
97
  });
@@ -100,6 +101,10 @@ const download = await client.api.trackers.photos.download({
100
101
  });
101
102
  ```
102
103
 
104
+ If the upload gets no storage response, the helper asks the API to verify and
105
+ complete the original upload. If the call still fails, keep the same request ID
106
+ and JPEG bytes when retrying.
107
+
103
108
  Uploads are limited to 10 MiB. Download URLs expire after two minutes; request a
104
109
  fresh reference if one expires. Photo bytes do not travel over WebSockets.
105
110
  Runtime schemas are available from `@bikefinder/sdk/schemas`.
package/dist/index.js CHANGED
@@ -333,6 +333,7 @@ async function uploadPhoto(uploads, input, fetch = globalThis.fetch) {
333
333
  },
334
334
  { signal: input.signal }
335
335
  );
336
+ input.signal?.throwIfAborted();
336
337
  if (session.status === "published") return { photoId: session.photoId };
337
338
  if (Date.parse(session.expiresAt) <= Date.now())
338
339
  throw new Error(
@@ -345,15 +346,20 @@ async function uploadPhoto(uploads, input, fetch = globalThis.fetch) {
345
346
  throw new TypeError(
346
347
  "The photo upload session targets an unexpected storage endpoint."
347
348
  );
348
- const uploaded = await fetch(url, {
349
- method: "PUT",
350
- body: input.body,
351
- credentials: "omit",
352
- redirect: "error",
353
- signal: input.signal,
354
- headers: session.headers
355
- });
356
- if (!uploaded.ok && uploaded.status !== 412)
349
+ let uploaded;
350
+ try {
351
+ uploaded = await fetch(url, {
352
+ method: "PUT",
353
+ body: input.body,
354
+ credentials: "omit",
355
+ redirect: "error",
356
+ signal: input.signal,
357
+ headers: session.headers
358
+ });
359
+ } catch {
360
+ }
361
+ input.signal?.throwIfAborted();
362
+ if (uploaded && !uploaded.ok && uploaded.status !== 412)
357
363
  throw new Error(
358
364
  "The private photo upload failed (" + uploaded.status + "). Retry with the same request ID."
359
365
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bikefinder/sdk",
3
- "version": "0.33.0",
3
+ "version": "0.33.1",
4
4
  "description": "Typed HTTP and WebSocket client for BikeFinder.",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {