@bikefinder/staff-sdk 0.0.0-stage → 0.4.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
@@ -1,3 +1,53 @@
1
- # Temporary Holding Version
1
+ # @bikefinder/staff-sdk
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Typed staff HTTP and WebSocket client for the [API](../../README.md). Version 0.4
4
+ uses native oRPC contracts, Zod validation and async iterators. Customer apps use
5
+ [@bikefinder/sdk](../sdk/README.md). MCP invokes application workflows directly.
6
+
7
+ ```ts
8
+ import { createBikeFinderStaffClient, ORPCError } from '@bikefinder/staff-sdk';
9
+
10
+ const client = createBikeFinderStaffClient({
11
+ baseUrl: 'https://api.prod.bikefinder.com',
12
+ accessToken: () => session.getAccessToken(),
13
+ onReconnect: () => restartActiveViews(),
14
+ });
15
+ const diagnostics = await client.api.trackers.diagnostics.get({ id: trackerId });
16
+ const controller = new AbortController();
17
+ for await (const reading of await client.api.trackers.observations.events(
18
+ { id: inventoryId },
19
+ { signal: controller.signal },
20
+ )) {
21
+ if (reading.type === 'battery.displayedLevel') updateBattery(reading.value.percent);
22
+ }
23
+ controller.abort();
24
+ client.dispose();
25
+ ```
26
+
27
+ Ordinary procedures use authenticated HTTP under `/rpc/staff`. Event iterators
28
+ share one API Gateway WebSocket connection admitted using a fresh, single-use
29
+ HTTP ticket. Access tokens never appear in the WebSocket URL or frames. The
30
+ application owns Auth0 login and refresh; `accessToken` supplies current credentials.
31
+ HTTP requests omit cookies, disable caching and refuse redirects.
32
+
33
+ Each procedure accepts optional `{ signal }` as its second argument. Full
34
+ reconnects end existing subscriptions: explicitly resubscribe in `onReconnect`.
35
+ Events are not replayed, and writes are never automatically retried. Keep a
36
+ command's original `idempotencyKey` when retrying an uncertain submission.
37
+ `dispose()` cancels pending work and closes the shared socket.
38
+
39
+ Overview and diagnostics are separate typed resources. Observations retain their
40
+ original `id`, measurement and receipt timestamps. Current selections use
41
+ `{ type, subject }`; paginated requests use `after` and responses `nextAfter`.
42
+ DTOs are explicit public projections with no storage-document envelope. Native
43
+ `ORPCError` failures preserve `code`, `status` and `data`.
44
+
45
+ Command and observation metadata ship with the SDK. Runtime validators are
46
+ exported from `@bikefinder/staff-sdk/schemas`; no schema bootstrap request is
47
+ required. Staff tools must still obtain the tracker's command catalog to check
48
+ its authoritative identity and availability before enabling writes.
49
+
50
+ Photo and support-attachment procedures return typed, short-lived download
51
+ references with storage URLs. Download file bytes over HTTP. WebSockets carry
52
+ metadata and events. Customer photo uploads use the customer SDK's staged-upload
53
+ helper; staff battery firmware uses its typed file procedure.