@bikefinder/staff-sdk 0.11.0 → 0.12.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
@@ -4,11 +4,19 @@ 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
5
  [@bikefinder/sdk](../sdk/README.md). MCP invokes application workflows directly.
6
6
 
7
+ Version 0.12 returns the canonical bike, including its new revision, from
8
+ `client.api.trackers.bike.edit`. Bind the edit to the tracker resource with `trackerCreatedAt: tracker.createdAt`. Supply `expected` values for exactly the fields
9
+ in `changes`; the API compares them atomically and preserves unrelated edits.
10
+ An already-applied retry returns the current bike. Deploy the matching API before updating consumers.
11
+ The public `@bikefinder/staff-sdk/schemas` exports `errorData` and `errorRecovery`
12
+ for validating declared recovery instructions.
13
+
7
14
  Version 0.11 adds `client.api.accounts.erasure.review`, `submit`, `get` and
8
15
  `retry`. Review the exact customer and retention policy with the requester before
9
16
  submitting `confirmation: "ERASE CUSTOMER"` and the returned `reviewVersion`.
10
17
  Keep the same request UUID across retries. `running` and `blocked` are incomplete;
11
- `cleanupAfter` explains the credential-expiry wait. See the
18
+ `cleanupAfter` exposes the 150-second allowance for requests already in flight;
19
+ the active-account gate rejects existing tokens without waiting for expiry. See the
12
20
  [erasure workflow](../../docs/customer-erasure.md).
13
21
 
14
22
  ```ts
@@ -243,30 +243,31 @@ var tracker = z2.object({
243
243
  })
244
244
  });
245
245
 
246
- // ../staff-contracts/src/erasure.ts
247
- import { oc } from "@orpc/contract";
246
+ // ../../../accounts/packages/client/src/contracts.ts
248
247
  import { z as z3 } from "zod";
249
- var erasureSelection = z3.strictObject({ accountId: documentId });
250
- var erasureReference = z3.strictObject({ requestId });
248
+ var documentId2 = z3.string().min(1).max(128).refine((v) => v.trim().length > 0 && ![".", ".."].includes(v) && !/[\\/\p{Cc}]/u.test(v) && !v.startsWith("__"), "Invalid document ID.");
249
+ var requestId2 = z3.guid().refine((v) => v !== "00000000-0000-0000-0000-000000000000", "Supply a nonempty request ID.").toLowerCase();
250
+ var erasureSelection = z3.strictObject({ accountId: documentId2 });
251
+ var erasureReference = z3.strictObject({ requestId: requestId2 });
251
252
  var erasurePolicy = "anonymize-financial-records-cancel-subscriptions-preserve-shared-trackers-v1";
252
253
  var erasureReview = z3.strictObject({
253
- accountId: documentId,
254
+ accountId: documentId2,
254
255
  email: z3.email(),
255
256
  emails: z3.array(z3.email()).min(1),
256
- accountIds: z3.array(documentId).min(1),
257
- exclusiveTrackers: z3.array(documentId),
258
- sharedTrackers: z3.array(documentId),
257
+ accountIds: z3.array(documentId2).min(1),
258
+ exclusiveTrackers: z3.array(documentId2),
259
+ sharedTrackers: z3.array(documentId2),
259
260
  policy: z3.literal(erasurePolicy),
260
261
  version: z3.string().regex(/^[a-f0-9]{64}$/)
261
262
  });
262
263
  var erasureSubmission = erasureReference.extend({
263
- accountId: documentId,
264
+ accountId: documentId2,
264
265
  reviewVersion: z3.string().regex(/^[a-f0-9]{64}$/),
265
266
  confirmation: z3.literal("ERASE CUSTOMER")
266
267
  });
267
268
  var erasureSystems = ["access", "commerce", "support", "firebase", "aws", "auth0"];
268
269
  var erasureOperation = z3.strictObject({
269
- requestId,
270
+ requestId: requestId2,
270
271
  state: z3.enum(["running", "blocked", "completed"]),
271
272
  policy: z3.literal(erasurePolicy),
272
273
  systems: z3.array(z3.strictObject({
@@ -278,6 +279,35 @@ var erasureOperation = z3.strictObject({
278
279
  updatedAt: z3.iso.datetime(),
279
280
  cleanupAfter: z3.iso.datetime().nullable()
280
281
  });
282
+ var trackerTarget = z3.strictObject({
283
+ id: z3.string(),
284
+ createdAt: z3.string(),
285
+ serialNumber: z3.string().nullable(),
286
+ exclusive: z3.boolean()
287
+ });
288
+ var targetSchema = z3.strictObject({
289
+ review: erasureReview,
290
+ directoryCreatedAt: z3.string(),
291
+ trackers: z3.array(trackerTarget),
292
+ cutoff: z3.iso.datetime()
293
+ });
294
+ var directoryIdentity = z3.strictObject({ accountId: documentId2, accountIds: z3.array(documentId2).min(1), email: z3.email(), emails: z3.array(z3.email()).min(1), directoryCreatedAt: z3.string().min(1) });
295
+ var cleanupRequest = z3.discriminatedUnion("action", [
296
+ z3.strictObject({ action: z3.literal("review"), identity: directoryIdentity }),
297
+ z3.strictObject({ action: z3.enum(["access", "commerce", "firebase", "aws", "support_select"]), target: targetSchema }),
298
+ z3.strictObject({ action: z3.literal("support_delete"), contactIds: z3.array(z3.int().positive()) })
299
+ ]);
300
+ var controlRequest = z3.discriminatedUnion("action", [
301
+ z3.strictObject({ action: z3.literal("review"), actor: documentId2, input: erasureSelection }),
302
+ z3.strictObject({ action: z3.literal("submit"), actor: documentId2, input: erasureSubmission }),
303
+ z3.strictObject({ action: z3.literal("get"), actor: documentId2, input: erasureReference }),
304
+ z3.strictObject({ action: z3.literal("retry"), actor: documentId2, input: erasureReference })
305
+ ]);
306
+ var failure = z3.strictObject({ status: z3.int().min(400).max(599), code: z3.string().regex(/^[a-z][a-z0-9_]{0,79}$/), message: z3.string().max(256) });
307
+ var completed = z3.strictObject({ completed: z3.literal(true) });
308
+
309
+ // ../staff-contracts/src/erasure.ts
310
+ import { oc } from "@orpc/contract";
281
311
  var erasureContract = {
282
312
  review: oc.meta({ operation: "read" }).errors(apiErrors).input(erasureSelection).output(erasureReview),
283
313
  submit: oc.errors(apiErrors).input(erasureSubmission).output(erasureOperation),
@@ -527,9 +557,15 @@ var bikeChanges = z10.strictObject({
527
557
  );
528
558
  var bikeEditInput = z10.strictObject({
529
559
  deviceId: documentId,
530
- expectedRevision: z10.string().regex(/^[a-f0-9]{64}$/),
560
+ trackerCreatedAt: z10.iso.datetime(),
561
+ expected: trackerBike.omit({ revision: true }).partial().strict(),
531
562
  changes: bikeChanges
532
- });
563
+ }).refine(({ expected, changes: changes2 }) => {
564
+ const fields = Object.entries(changes2).filter(([, value]) => value !== void 0).map(([key2]) => key2);
565
+ return fields.length === Object.keys(expected).length && fields.every(
566
+ (key2) => expected[key2] !== void 0
567
+ );
568
+ }, "Supply reviewed values for exactly the changed bike fields.");
533
569
  var membershipName = z10.string().min(1).max(100).regex(/^[^\p{Cc}]+$/u).refine((value) => value.trim().length > 0, "Supply a display name.");
534
570
  var trackerClaimInput = z10.strictObject({
535
571
  deviceId: documentId,
@@ -547,7 +583,7 @@ var trackerMovementAlertsInput = z10.strictObject({
547
583
  enabled: z10.boolean()
548
584
  });
549
585
  var trackerChangeContract = {
550
- bike: { edit: oc8.errors(apiErrors).input(bikeEditInput).output(z10.void()) },
586
+ bike: { edit: oc8.errors(apiErrors).input(bikeEditInput).output(trackerBike) },
551
587
  movementAlerts: {
552
588
  set: oc8.errors(apiErrors).input(trackerMovementAlertsInput).output(z10.void())
553
589
  },
@@ -16161,6 +16197,8 @@ var staffContract = {
16161
16197
 
16162
16198
  export {
16163
16199
  apiContractVersion,
16200
+ errorRecovery,
16201
+ errorData,
16164
16202
  readIssue,
16165
16203
  trackerBike,
16166
16204
  trackerBattery,