@bikefinder/sdk 0.28.0 → 0.30.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,6 +1,18 @@
1
1
  # @bikefinder/sdk
2
2
 
3
- Version 0.28.0 adds live photo metadata pages through
3
+ Version 0.30 adds `trackers.getDetails` and `trackers.watchDetails`. They return
4
+ the authorized account ID and active-member count without the roster. Deploy
5
+ these API routes before switching clients. Existing `get` and `watch` retain
6
+ their previous response shape for installed clients.
7
+
8
+ Version 0.29.0 returns the canonical bike, including its new revision, from
9
+ `client.api.trackers.bike.edit`. Bind the edit to the tracker resource with `trackerCreatedAt: tracker.createdAt`. Supply `expected` values for exactly the fields in `changes`;
10
+ the API compares them atomically and preserves unrelated edits. Repeating an
11
+ already-applied edit succeeds. Use the result directly; saving needs no extra tracker reads. Deploy the matching API before updating consumers.
12
+ The public `@bikefinder/sdk/schemas` exports `errorData` and `errorRecovery` for
13
+ validating declared recovery instructions.
14
+
15
+ Version 0.28 adds live photo metadata pages through
4
16
  `client.api.trackers.photos.watchPage`. Deploy this API endpoint before updating
5
17
  consumers that subscribe to photos. The SDK uses the canonical API contracts directly for HTTP and WebSocket
6
18
  responses. Deploy the API's availability-state contract before updating consumers;
@@ -20,9 +32,9 @@ const client = createBikeFinderClient({
20
32
  onReconnect: () => restartActiveViews(),
21
33
  });
22
34
 
23
- const tracker = await client.api.trackers.get({ deviceId });
35
+ const tracker = await client.api.trackers.getDetails({ deviceId });
24
36
  const controller = new AbortController();
25
- const changes = await client.api.trackers.watch(
37
+ const changes = await client.api.trackers.watchDetails(
26
38
  { deviceId },
27
39
  { signal: controller.signal },
28
40
  );
@@ -296,6 +296,12 @@ var tracker = z4.object({
296
296
  factoryResetReports: z4.boolean()
297
297
  })
298
298
  });
299
+ var customerTrackerDetails = tracker.omit({ members: true }).extend({
300
+ membership: z4.object({
301
+ accountId: z4.string(),
302
+ activeMemberCount: z4.int().nonnegative()
303
+ })
304
+ });
299
305
 
300
306
  // ../common-contracts/src/accounts.ts
301
307
  import { oc as oc3, eventIterator } from "@orpc/contract";
@@ -487,9 +493,15 @@ var bikeChanges = z9.strictObject({
487
493
  );
488
494
  var bikeEditInput = z9.strictObject({
489
495
  deviceId: documentId,
490
- expectedRevision: z9.string().regex(/^[a-f0-9]{64}$/),
496
+ trackerCreatedAt: z9.iso.datetime(),
497
+ expected: trackerBike.omit({ revision: true }).partial().strict(),
491
498
  changes: bikeChanges
492
- });
499
+ }).refine(({ expected, changes }) => {
500
+ const fields2 = Object.entries(changes).filter(([, value]) => value !== void 0).map(([key]) => key);
501
+ return fields2.length === Object.keys(expected).length && fields2.every(
502
+ (key) => expected[key] !== void 0
503
+ );
504
+ }, "Supply reviewed values for exactly the changed bike fields.");
493
505
  var membershipName = z9.string().min(1).max(100).regex(/^[^\p{Cc}]+$/u).refine((value) => value.trim().length > 0, "Supply a display name.");
494
506
  var trackerClaimInput = z9.strictObject({
495
507
  deviceId: documentId,
@@ -507,7 +519,7 @@ var trackerMovementAlertsInput = z9.strictObject({
507
519
  enabled: z9.boolean()
508
520
  });
509
521
  var trackerChangeContract = {
510
- bike: { edit: oc7.errors(apiErrors).input(bikeEditInput).output(z9.void()) },
522
+ bike: { edit: oc7.errors(apiErrors).input(bikeEditInput).output(trackerBike) },
511
523
  movementAlerts: {
512
524
  set: oc7.errors(apiErrors).input(trackerMovementAlertsInput).output(z9.void())
513
525
  },
@@ -799,6 +811,8 @@ var trackerContract = {
799
811
  claim: oc15.errors(apiErrors).input(trackerClaimInput).output(z18.void()),
800
812
  list: oc15.meta({ operation: "read" }).errors(apiErrors).input(pageInput).output(trackerPage),
801
813
  watchPage: oc15.meta({ operation: "read" }).errors(apiErrors).input(pageInput).output(eventIterator3(trackerPage)),
814
+ getDetails: procedure.meta({ operation: "read" }).output(customerTrackerDetails),
815
+ watchDetails: procedure.meta({ operation: "read" }).output(eventIterator3(customerTrackerDetails)),
802
816
  get: procedure.meta({ operation: "read" }).output(tracker),
803
817
  watch: procedure.meta({ operation: "read" }).output(eventIterator3(tracker))
804
818
  };
@@ -813,6 +827,8 @@ var customerContract = {
813
827
  export {
814
828
  apiContractVersion,
815
829
  subscriptionInput,
830
+ errorRecovery,
831
+ errorData,
816
832
  pushToken,
817
833
  pushRegistrationInput,
818
834
  pushRemovalInput,
@@ -835,6 +851,7 @@ export {
835
851
  trackerSummary,
836
852
  trackerPage,
837
853
  tracker,
854
+ customerTrackerDetails,
838
855
  directoryProfile,
839
856
  accountPreferences,
840
857
  defaultAccountPreferences,