@bikefinder/sdk 0.23.0 → 0.28.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.
@@ -0,0 +1,903 @@
1
+ // ../common-contracts/src/shared.ts
2
+ import { z } from "zod";
3
+ var apiContractVersion = "1";
4
+ var documentId = z.string().min(1).max(128).refine(
5
+ (value) => value.trim().length > 0 && ![".", ".."].includes(value) && !/[\\/\p{Cc}]/u.test(value) && !value.startsWith("__"),
6
+ "Invalid document ID."
7
+ );
8
+ var trackerInput = z.strictObject({ deviceId: documentId });
9
+ var subscriptionInput = z.strictObject({ subscriptionId: documentId });
10
+ var requestId = z.guid().refine(
11
+ (value) => value !== "00000000-0000-0000-0000-000000000000",
12
+ "Supply a nonempty request ID."
13
+ ).toLowerCase();
14
+ var documentFields = {
15
+ id: z.string(),
16
+ revision: z.string(),
17
+ createdAt: z.iso.datetime(),
18
+ updatedAt: z.iso.datetime()
19
+ };
20
+ var pageFields = {
21
+ limit: z.int().positive().default(50),
22
+ after: documentId.optional()
23
+ };
24
+ var pageInput = z.strictObject(pageFields).prefault({});
25
+ var timeCursorFields = { id: documentId, at: z.iso.datetime() };
26
+ var timePageInput = z.strictObject({
27
+ limit: pageFields.limit,
28
+ after: z.strictObject(timeCursorFields).optional()
29
+ }).prefault({});
30
+ var operationReference = z.discriminatedUnion("kind", [
31
+ z.object({
32
+ kind: z.literal("command"),
33
+ serialNumber: z.string(),
34
+ idempotencyKey: requestId
35
+ }),
36
+ z.object({
37
+ kind: z.literal("firmware"),
38
+ serialNumber: z.string(),
39
+ updateId: requestId
40
+ }),
41
+ z.object({
42
+ kind: z.literal("bluetooth_firmware"),
43
+ deviceId: documentId,
44
+ updateId: requestId
45
+ }),
46
+ z.object({
47
+ kind: z.enum(["invitation", "photo_upload", "legacy_firmware"]),
48
+ deviceId: documentId,
49
+ requestId
50
+ }),
51
+ z.object({ kind: z.literal("support"), requestId })
52
+ ]);
53
+ var recoverySchema = z.discriminatedUnion("action", [
54
+ z.object({
55
+ action: z.enum([
56
+ "none",
57
+ "correct_input",
58
+ "sign_in",
59
+ "refresh",
60
+ "retry_read",
61
+ "retry_same_request",
62
+ "verify_outcome"
63
+ ])
64
+ }),
65
+ z.object({
66
+ action: z.literal("read_operation"),
67
+ operation: operationReference
68
+ })
69
+ ]);
70
+ var errorRecovery = recoverySchema;
71
+ var conflictReason = z.enum([
72
+ "revision_changed",
73
+ "selection_changed",
74
+ "subscription_capacity_exhausted",
75
+ "subscription_unavailable",
76
+ "tracker_restricted",
77
+ "idempotency_conflict",
78
+ "already_claimed",
79
+ "membership_limit",
80
+ "identity_changed"
81
+ ]);
82
+ var errorDataSchema = z.object({
83
+ traceId: z.string(),
84
+ recovery: errorRecovery,
85
+ reason: conflictReason.optional(),
86
+ currentRevision: z.string().optional(),
87
+ retryAfterSeconds: z.int().positive().optional()
88
+ });
89
+ var errorData = errorDataSchema;
90
+ var apiErrors = {
91
+ invalid: { status: 400, data: errorData },
92
+ unauthenticated: { status: 401, data: errorData },
93
+ forbidden: { status: 403, data: errorData },
94
+ not_found: { status: 404, data: errorData },
95
+ conflict: { status: 409, data: errorData },
96
+ rate_limited: { status: 429, data: errorData },
97
+ stored_data_invalid: { status: 503, data: errorData },
98
+ service_unavailable: { status: 503, data: errorData },
99
+ read_unavailable: { status: 503, data: errorData },
100
+ stream_unavailable: { status: 503, data: errorData },
101
+ payload_too_large: { status: 413, data: errorData },
102
+ request_timeout: { status: 503, data: errorData },
103
+ operation_unconfirmed: { status: 503, data: errorData },
104
+ directory_unavailable: { status: 503, data: errorData }
105
+ };
106
+ var directoryErrors = {
107
+ ...apiErrors,
108
+ directory_unavailable: { status: 503, data: errorData },
109
+ directory_response_invalid: { status: 503, data: errorData }
110
+ };
111
+ var subscriptionErrors = {
112
+ ...apiErrors,
113
+ subscription_not_owned: { status: 403, data: errorData }
114
+ };
115
+ var firmwareErrors = {
116
+ ...apiErrors,
117
+ inventory_changed: { status: 412, data: errorData },
118
+ firmware_catalog_invalid: { status: 503, data: errorData },
119
+ firmware_catalog_full: { status: 503, data: errorData },
120
+ firmware_execution_invalid: { status: 503, data: errorData },
121
+ firmware_review_changed: { status: 412, data: errorData },
122
+ firmware_review_required: { status: 428, data: errorData },
123
+ firmware_policy_unavailable: { status: 503, data: errorData },
124
+ firmware_release_unavailable: { status: 503, data: errorData }
125
+ };
126
+ var inboxErrors = {
127
+ ...apiErrors,
128
+ inbox_unavailable: { status: 503, data: errorData }
129
+ };
130
+ var supportErrors = {
131
+ ...directoryErrors,
132
+ support_provider_unavailable: { status: 503, data: errorData },
133
+ support_journal_invalid: { status: 503, data: errorData },
134
+ support_actions_disabled: { status: 503, data: errorData },
135
+ support_billing_disabled: { status: 503, data: errorData },
136
+ support_agent_mismatch: { status: 503, data: errorData },
137
+ support_response_invalid: { status: 503, data: errorData },
138
+ support_response_too_large: { status: 503, data: errorData },
139
+ ticket_history_incomplete: { status: 503, data: errorData },
140
+ ticket_context_too_large: { status: 503, data: errorData }
141
+ };
142
+
143
+ // ../common-contracts/src/push.ts
144
+ import { oc } from "@orpc/contract";
145
+ import { z as z2 } from "zod";
146
+ var pushToken = z2.string().min(1).max(4096).refine(
147
+ (value) => value.trim().length > 0 && !/\p{Cc}/u.test(value) && !/^__.*__$/u.test(value) && // Tokens are literal Firestore field segments. Leave room for the parent and leaf paths.
148
+ new TextEncoder().encode(value.replace(/[\\`]/g, "\\$&")).length <= 1400,
149
+ "Use a valid push token that fits a literal field path."
150
+ );
151
+ var pushRegistrationInput = z2.strictObject({
152
+ installationId: requestId,
153
+ token: pushToken.nullable(),
154
+ platform: z2.enum(["android", "ios"]),
155
+ permission: z2.enum(["granted", "provisional", "denied", "not_determined"]),
156
+ replaceTokens: z2.array(pushToken).default([])
157
+ });
158
+ var pushRemovalInput = z2.strictObject({ installationId: requestId });
159
+ var pushContract = {
160
+ register: oc.errors(apiErrors).input(pushRegistrationInput).output(z2.void()),
161
+ unregister: oc.errors(apiErrors).input(pushRemovalInput).output(z2.void())
162
+ };
163
+
164
+ // ../common-contracts/src/inbox.ts
165
+ import { oc as oc2 } from "@orpc/contract";
166
+ import { z as z3 } from "zod";
167
+ var notificationSource = z3.object({
168
+ kind: z3.enum(["account", "subscription"]),
169
+ id: documentId
170
+ });
171
+ var inboxCursor = z3.object({
172
+ ...timeCursorFields,
173
+ source: notificationSource
174
+ });
175
+ var inboxPageInput = z3.strictObject({
176
+ limit: pageFields.limit,
177
+ after: inboxCursor.strict().extend({ source: notificationSource.strict() }).optional()
178
+ }).prefault({});
179
+ var notification = z3.object({
180
+ id: documentId,
181
+ source: notificationSource,
182
+ type: z3.string().nullable(),
183
+ title: z3.string().nullable(),
184
+ body: z3.string().nullable(),
185
+ trackerId: z3.string().nullable(),
186
+ subscriptionId: z3.string().nullable(),
187
+ createdAt: z3.iso.datetime()
188
+ });
189
+ var inboxPage = z3.object({
190
+ items: z3.array(notification),
191
+ nextAfter: inboxCursor.nullable()
192
+ });
193
+ var inboxContract = {
194
+ list: oc2.meta({ operation: "read" }).errors(inboxErrors).input(inboxPageInput).output(inboxPage)
195
+ };
196
+
197
+ // ../common-contracts/src/schemas.ts
198
+ import { z as z4 } from "zod";
199
+ var readIssue = z4.object({
200
+ path: z4.string(),
201
+ code: z4.literal("invalid_stored_value")
202
+ });
203
+ var unavailableReading = z4.object({
204
+ state: z4.literal("unavailable"),
205
+ reason: z4.enum(["not_observed", "not_assigned", "invalid"])
206
+ });
207
+ var trackerBike = z4.object({
208
+ revision: z4.string(),
209
+ name: z4.string().nullable(),
210
+ brand: z4.string().nullable(),
211
+ type: z4.string().nullable(),
212
+ model: z4.string().nullable(),
213
+ frameNumber: z4.string().nullable(),
214
+ url: z4.string().nullable(),
215
+ marketPrice: z4.string().nullable(),
216
+ marketPriceCurrency: z4.string().nullable()
217
+ });
218
+ var trackerBattery = z4.object({
219
+ level: z4.number().min(0).max(100).nullable(),
220
+ isCharging: z4.boolean().nullable(),
221
+ levelUpdatedAt: z4.iso.datetime().nullable(),
222
+ chargingObservedAt: z4.iso.datetime().nullable(),
223
+ observation: z4.object({
224
+ observedAt: z4.iso.datetime().nullable(),
225
+ receivedAt: z4.iso.datetime().nullable()
226
+ }).nullable(),
227
+ source: z4.string().nullable()
228
+ });
229
+ var trackerLocation = z4.object({
230
+ latitude: z4.number().min(-90).max(90),
231
+ longitude: z4.number().min(-180).max(180),
232
+ accuracy: z4.number().nonnegative().nullable(),
233
+ source: z4.string().nullable(),
234
+ observedAt: z4.iso.datetime().nullable()
235
+ });
236
+ var trackerSubscription = z4.object({
237
+ id: z4.string().min(1),
238
+ activity: z4.enum(["active", "inactive", "unknown"]),
239
+ isDemo: z4.boolean(),
240
+ status: z4.string().nullable(),
241
+ country: z4.string().nullable(),
242
+ endsAt: z4.iso.datetime().nullable()
243
+ });
244
+ var trackerFirmware = z4.object({
245
+ lte: z4.string().nullable(),
246
+ bluetooth: z4.string().nullable(),
247
+ battery: z4.string().nullable(),
248
+ modem: z4.string().nullable(),
249
+ mtk: z4.string().nullable(),
250
+ ti: z4.string().nullable(),
251
+ buildNumber: z4.int().nullable()
252
+ });
253
+ var trackerMember = z4.object({
254
+ active: z4.boolean().nullable(),
255
+ displayName: z4.string().nullable(),
256
+ listOrder: z4.int().nullable(),
257
+ joinedAt: z4.iso.datetime().nullable()
258
+ });
259
+ var trackerSummaryFields = {
260
+ ...documentFields,
261
+ generation: z4.int().positive().nullable(),
262
+ bike: trackerBike,
263
+ battery: z4.discriminatedUnion("state", [
264
+ trackerBattery.extend({ state: z4.literal("available") }),
265
+ unavailableReading
266
+ ]),
267
+ location: z4.discriminatedUnion("state", [
268
+ trackerLocation.extend({ state: z4.literal("available") }),
269
+ unavailableReading
270
+ ]),
271
+ subscription: z4.discriminatedUnion("state", [
272
+ trackerSubscription.extend({ state: z4.literal("available") }),
273
+ unavailableReading
274
+ ]),
275
+ readIssues: z4.array(readIssue)
276
+ };
277
+ var trackerFields = {
278
+ ...trackerSummaryFields,
279
+ firmware: trackerFirmware.nullable(),
280
+ members: z4.record(z4.string(), trackerMember).nullable()
281
+ };
282
+ var trackerSummary = z4.object({
283
+ ...trackerSummaryFields,
284
+ identity: z4.object({ serialNumber: z4.string().nullable() }).nullable()
285
+ });
286
+ var trackerPage = z4.object({
287
+ items: z4.array(trackerSummary),
288
+ nextAfter: z4.string().nullable()
289
+ });
290
+ var tracker = z4.object({
291
+ ...trackerFields,
292
+ identity: trackerSummary.shape.identity,
293
+ preferences: z4.object({ movementAlerts: z4.boolean() }),
294
+ capabilities: z4.object({
295
+ firmwareUpdates: z4.boolean(),
296
+ factoryResetReports: z4.boolean()
297
+ })
298
+ });
299
+
300
+ // ../common-contracts/src/accounts.ts
301
+ import { oc as oc3, eventIterator } from "@orpc/contract";
302
+ import { z as z5 } from "zod";
303
+ var directoryProfile = z5.object({
304
+ id: z5.string().min(1),
305
+ email: z5.string().nullable(),
306
+ emailVerified: z5.boolean().nullable(),
307
+ name: z5.string().nullable(),
308
+ picture: z5.string().nullable(),
309
+ blocked: z5.boolean().nullable()
310
+ });
311
+ var unit = z5.enum(["metric", "imperial"]);
312
+ var mapStyle = z5.enum(["minimal", "satellite"]);
313
+ var accountPreferences = z5.object({
314
+ alarm: z5.boolean(),
315
+ timeSensitive: z5.boolean(),
316
+ notifications: z5.boolean(),
317
+ language: z5.string().nullable(),
318
+ unit,
319
+ mapStyle
320
+ });
321
+ var defaultAccountPreferences = {
322
+ alarm: false,
323
+ timeSensitive: true,
324
+ notifications: false,
325
+ language: null,
326
+ unit: "metric",
327
+ mapStyle: "minimal"
328
+ };
329
+ var account = z5.object({
330
+ ...documentFields,
331
+ name: z5.string().nullable(),
332
+ email: z5.string().nullable(),
333
+ picture: z5.string().nullable(),
334
+ registeredAt: z5.iso.datetime().nullable(),
335
+ preferences: accountPreferences,
336
+ readIssues: z5.array(readIssue)
337
+ });
338
+ var language = z5.string().min(2).max(64).refine((value) => {
339
+ try {
340
+ return Intl.getCanonicalLocales(value).length === 1;
341
+ } catch {
342
+ return false;
343
+ }
344
+ }, "Use a valid language tag.");
345
+ var accountPreferencePatch = z5.strictObject({
346
+ alarm: z5.boolean().optional(),
347
+ timeSensitive: z5.boolean().optional(),
348
+ notifications: z5.boolean().optional(),
349
+ language: language.nullable().optional(),
350
+ unit: unit.optional(),
351
+ mapStyle: mapStyle.optional()
352
+ }).refine(
353
+ (value) => Object.values(value).some((field) => field !== void 0),
354
+ "Supply at least one preference."
355
+ );
356
+ var accountContract = {
357
+ inbox: inboxContract,
358
+ push: pushContract,
359
+ profile: oc3.meta({ operation: "read" }).errors(directoryErrors).input(z5.void()).output(directoryProfile),
360
+ get: oc3.meta({ operation: "read" }).errors(directoryErrors).input(z5.void()).output(account),
361
+ watch: oc3.meta({ operation: "read" }).errors(directoryErrors).input(z5.void()).output(eventIterator(account)),
362
+ initialize: oc3.errors(directoryErrors).input(z5.void()).output(z5.void()),
363
+ preferences: {
364
+ update: oc3.errors(directoryErrors).input(accountPreferencePatch).output(z5.void())
365
+ }
366
+ };
367
+
368
+ // ../common-contracts/src/photos.ts
369
+ import { oc as oc4 } from "@orpc/contract";
370
+ import { z as z6 } from "zod";
371
+ var photoInput = z6.strictObject({
372
+ deviceId: documentId,
373
+ photoId: documentId
374
+ });
375
+ var photoPageInput = z6.strictObject({
376
+ deviceId: documentId,
377
+ ...pageFields
378
+ });
379
+ var photoDownloadInput = photoInput.extend({
380
+ variant: z6.enum(["original", "thumbnail"]).default("original")
381
+ });
382
+ var photo = z6.object({
383
+ ...documentFields,
384
+ kind: z6.string().nullable(),
385
+ width: z6.int().nullable(),
386
+ height: z6.int().nullable(),
387
+ sizeBytes: z6.int().nullable(),
388
+ isVertical: z6.boolean().nullable(),
389
+ contentType: z6.string().nullable(),
390
+ capturedAt: z6.iso.datetime().nullable()
391
+ });
392
+ var photoPage = z6.object({
393
+ items: z6.array(photo),
394
+ nextAfter: documentId.nullable()
395
+ });
396
+ var downloadReference = z6.object({
397
+ url: z6.url({ protocol: /^https$/ }),
398
+ expiresAt: z6.iso.datetime(),
399
+ contentType: z6.string(),
400
+ name: z6.string()
401
+ });
402
+ var trackerPhotoContract = {
403
+ list: oc4.meta({ operation: "read" }).errors(apiErrors).input(photoPageInput).output(photoPage),
404
+ download: oc4.meta({ operation: "read" }).errors(apiErrors).input(photoDownloadInput).output(downloadReference),
405
+ delete: oc4.errors(apiErrors).input(photoInput).output(z6.void())
406
+ };
407
+
408
+ // ../common-contracts/src/realtime.ts
409
+ import { oc as oc5 } from "@orpc/contract";
410
+ import { z as z7 } from "zod";
411
+ var realtimeTicket = z7.object({
412
+ ticket: z7.string().regex(/^[A-Za-z0-9_-]{43}$/),
413
+ expiresAt: z7.iso.datetime(),
414
+ webSocketUrl: z7.url({ protocol: /^wss?$/ })
415
+ });
416
+ var realtimeContract = {
417
+ ticket: oc5.errors(apiErrors).input(z7.void()).output(realtimeTicket)
418
+ };
419
+
420
+ // ../common-contracts/src/subscriptions.ts
421
+ import { oc as oc6, eventIterator as eventIterator2 } from "@orpc/contract";
422
+ import { z as z8 } from "zod";
423
+ var subscription = z8.object({
424
+ ...documentFields,
425
+ accountId: z8.string().nullable(),
426
+ name: z8.string().nullable(),
427
+ quantity: z8.int().nullable(),
428
+ available: z8.int().nullable(),
429
+ trackers: z8.array(
430
+ z8.object({
431
+ trackerId: z8.string(),
432
+ addedAt: z8.iso.datetime().nullable()
433
+ })
434
+ ),
435
+ active: z8.boolean().nullable(),
436
+ status: z8.string().nullable(),
437
+ endsAt: z8.iso.datetime().nullable(),
438
+ nextPaymentAt: z8.iso.datetime().nullable(),
439
+ managementUrl: z8.string().nullable(),
440
+ country: z8.string().nullable(),
441
+ demo: z8.boolean().nullable(),
442
+ type: z8.string().nullable(),
443
+ deleted: z8.boolean()
444
+ });
445
+ var subscriptionPage = z8.object({
446
+ items: z8.array(subscription),
447
+ nextAfter: z8.string().nullable()
448
+ });
449
+ var subscriptionContract = {
450
+ get: oc6.meta({ operation: "read" }).errors(subscriptionErrors).input(subscriptionInput).output(subscription),
451
+ list: oc6.meta({ operation: "read" }).errors(subscriptionErrors).input(pageInput).output(subscriptionPage),
452
+ watch: oc6.meta({ operation: "read" }).errors(subscriptionErrors).input(pageInput).output(eventIterator2(subscriptionPage))
453
+ };
454
+ var subscriptionAllocationInput = z8.strictObject({
455
+ deviceId: documentId,
456
+ subscriptionId: documentId.nullable(),
457
+ expectedSubscriptionId: documentId.nullable()
458
+ });
459
+ var subscriptionAllocationContract = {
460
+ change: oc6.errors(subscriptionErrors).input(subscriptionAllocationInput).output(z8.void())
461
+ };
462
+
463
+ // ../common-contracts/src/tracker-changes.ts
464
+ import { z as z9 } from "zod";
465
+ import Decimal from "decimal.js";
466
+ import { oc as oc7 } from "@orpc/contract";
467
+ var text = z9.string().max(200).regex(/^[^\p{Cc}]*$/u);
468
+ var price = z9.string().max(200).regex(/^(?:\d+(?:\.\d{0,2})?|\.\d{1,2})$/).pipe(
469
+ z9.string().refine(
470
+ (value) => new Decimal(value).lte("90071992547409"),
471
+ "The price is too large."
472
+ )
473
+ ).transform((value) => new Decimal(value).toFixed(2));
474
+ var url = z9.string().max(2048).regex(/^[^\p{Cc}]*$/u).pipe(z9.url({ protocol: /^https?$/ }).or(z9.literal("")));
475
+ var bikeChanges = z9.strictObject({
476
+ name: text.nullable().optional(),
477
+ brand: text.nullable().optional(),
478
+ type: text.nullable().optional(),
479
+ model: text.nullable().optional(),
480
+ frameNumber: text.nullable().optional(),
481
+ url: url.nullable().optional(),
482
+ marketPrice: price.nullable().optional(),
483
+ marketPriceCurrency: z9.enum(["NOK", "SEK", "DKK", "EUR", "GBP", "USD"]).nullable().optional()
484
+ }).refine(
485
+ (changes) => Object.values(changes).some((value) => value !== void 0),
486
+ "Supply at least one changed bike field."
487
+ );
488
+ var bikeEditInput = z9.strictObject({
489
+ deviceId: documentId,
490
+ expectedRevision: z9.string().regex(/^[a-f0-9]{64}$/),
491
+ changes: bikeChanges
492
+ });
493
+ var membershipName = z9.string().min(1).max(100).regex(/^[^\p{Cc}]+$/u).refine((value) => value.trim().length > 0, "Supply a display name.");
494
+ var trackerClaimInput = z9.strictObject({
495
+ deviceId: documentId,
496
+ displayName: membershipName
497
+ });
498
+ var trackerMemberInput = z9.strictObject({
499
+ deviceId: documentId,
500
+ memberId: documentId
501
+ });
502
+ var trackerMemberAddInput = trackerMemberInput.extend({
503
+ displayName: membershipName
504
+ });
505
+ var trackerMovementAlertsInput = z9.strictObject({
506
+ deviceId: documentId,
507
+ enabled: z9.boolean()
508
+ });
509
+ var trackerChangeContract = {
510
+ bike: { edit: oc7.errors(apiErrors).input(bikeEditInput).output(z9.void()) },
511
+ movementAlerts: {
512
+ set: oc7.errors(apiErrors).input(trackerMovementAlertsInput).output(z9.void())
513
+ },
514
+ members: {
515
+ remove: oc7.errors(apiErrors).input(trackerMemberInput).output(z9.void())
516
+ }
517
+ };
518
+
519
+ // ../customer-contracts/src/discovery.ts
520
+ import { oc as oc8 } from "@orpc/contract";
521
+ import { z as z10 } from "zod";
522
+ var trackerLookupInput = z10.union([
523
+ z10.strictObject({ deviceId: documentId }),
524
+ z10.strictObject({
525
+ serialNumber: z10.string().min(1).max(128).regex(/^[^\p{Cc}]+$/u).refine((value) => value.trim().length > 0)
526
+ })
527
+ ]);
528
+ var trackerAdmission = z10.object({
529
+ id: documentId,
530
+ isMember: z10.boolean(),
531
+ canClaim: z10.boolean()
532
+ });
533
+ var trackerLookupContract = oc8.meta({ operation: "read" }).errors(apiErrors).input(trackerLookupInput).output(trackerAdmission);
534
+
535
+ // ../common-contracts/src/gcp/history.ts
536
+ import { oc as oc9 } from "@orpc/contract";
537
+ import { z as z11 } from "zod";
538
+ var historyCursor = z11.object({
539
+ ...timeCursorFields,
540
+ scope: z11.string().regex(/^[a-f0-9]{64}$/)
541
+ });
542
+ var historyInput = z11.strictObject({
543
+ deviceId: documentId,
544
+ from: z11.iso.datetime(),
545
+ until: z11.iso.datetime(),
546
+ limit: pageFields.limit,
547
+ after: historyCursor.strict().optional()
548
+ });
549
+ var historyEntry = z11.object({
550
+ ...documentFields,
551
+ type: z11.string().nullable(),
552
+ observedAt: z11.iso.datetime().nullable(),
553
+ latitude: z11.number().nullable(),
554
+ longitude: z11.number().nullable(),
555
+ accuracy: z11.number().nullable(),
556
+ speed: z11.number().nullable(),
557
+ altitude: z11.number().nullable(),
558
+ heading: z11.number().nullable(),
559
+ source: z11.string().nullable(),
560
+ battery: z11.object({
561
+ level: z11.int().nullable(),
562
+ isCharging: z11.boolean().nullable(),
563
+ source: z11.string().nullable(),
564
+ observedAt: z11.iso.datetime().nullable()
565
+ }).nullable()
566
+ });
567
+ var historyPage = z11.object({
568
+ items: z11.array(historyEntry),
569
+ nextAfter: historyCursor.nullable()
570
+ });
571
+ var historyContract = oc9.meta({ operation: "read" }).errors(apiErrors).input(historyInput).output(historyPage);
572
+
573
+ // ../customer-contracts/src/gcp/firmware.ts
574
+ import { oc as oc10 } from "@orpc/contract";
575
+ import { z as z12 } from "zod";
576
+ var firmwareAvailability = z12.object({
577
+ state: z12.enum(["available", "current", "unsupported", "blocked"]),
578
+ reason: z12.enum([
579
+ "subscriptionRequired",
580
+ "accountRestricted",
581
+ "temporarilyPaused",
582
+ "repeatedFailures",
583
+ "locationRequired",
584
+ "outsideSupportedArea",
585
+ "installedVersionUnknown",
586
+ "appUpdateRequired"
587
+ ]).nullable(),
588
+ retryAfter: z12.iso.datetime().nullable()
589
+ });
590
+ var trackerFirmwareRelease = z12.object({
591
+ id: z12.string().regex(/^[a-f0-9]{64}$/),
592
+ fromVersion: z12.string(),
593
+ version: z12.string(),
594
+ deliveryMethod: z12.literal("bluetoothOad"),
595
+ requiredBatteryPercent: z12.int().min(0).max(100)
596
+ });
597
+ var firmwareAppInput = trackerInput.extend({
598
+ platform: z12.enum(["ios", "android"]),
599
+ build: z12.int().min(0).max(2147483647)
600
+ });
601
+ var trackerFirmwareReleases = z12.object({
602
+ trackerId: z12.string(),
603
+ availability: firmwareAvailability,
604
+ items: z12.array(trackerFirmwareRelease).max(1),
605
+ revision: z12.string().regex(/^[a-f0-9]{64}$/)
606
+ });
607
+ var firmwareTransfer = z12.object({
608
+ imageUrl: z12.url({ protocol: /^https$/ }),
609
+ blockSize: z12.int().min(5).max(512),
610
+ requiredBatteryPercent: z12.int().min(0).max(100),
611
+ blockTimeoutMs: z12.int().min(1e3).max(6e4),
612
+ rebootTimeoutMs: z12.int().min(1e3).max(6e4)
613
+ });
614
+ var firmwareUpdateInput = trackerInput.extend({ updateId: requestId });
615
+ var startFirmwareUpdate = firmwareAppInput.extend({
616
+ updateId: requestId,
617
+ releaseId: z12.string().regex(/^[a-f0-9]{64}$/),
618
+ expectedRevision: z12.string().regex(/^[a-f0-9]{64}$/).optional()
619
+ });
620
+ var firmwareReportOutcome = z12.enum([
621
+ "transferFailed",
622
+ "targetVersionObserved"
623
+ ]);
624
+ var firmwareReportInput = firmwareUpdateInput.extend({
625
+ attemptId: requestId,
626
+ outcome: firmwareReportOutcome
627
+ });
628
+ var firmwareClientReport = z12.object({
629
+ attemptId: requestId,
630
+ outcome: firmwareReportOutcome,
631
+ reportedAt: z12.iso.datetime(),
632
+ pinnedTargetCleared: z12.boolean()
633
+ });
634
+ var trackerFirmwareUpdate = z12.object({
635
+ updateId: requestId,
636
+ trackerId: z12.string(),
637
+ requestedAt: z12.iso.datetime(),
638
+ release: trackerFirmwareRelease,
639
+ transfer: firmwareTransfer,
640
+ latestClientReport: firmwareClientReport.nullable()
641
+ });
642
+ var gen1FirmwareContract = {
643
+ start: oc10.errors(firmwareErrors).input(startFirmwareUpdate).output(trackerFirmwareUpdate),
644
+ get: oc10.meta({ operation: "read" }).errors(firmwareErrors).input(firmwareUpdateInput).output(trackerFirmwareUpdate),
645
+ report: oc10.errors(firmwareErrors).input(firmwareReportInput).output(firmwareClientReport),
646
+ catalog: oc10.meta({ operation: "read" }).errors(firmwareErrors).input(firmwareAppInput).output(trackerFirmwareReleases)
647
+ };
648
+
649
+ // ../customer-contracts/src/gcp/bluetooth.ts
650
+ import { oc as oc11 } from "@orpc/contract";
651
+ import { z as z13 } from "zod";
652
+ var bluetoothPin = z13.array(z13.int().min(0).max(255)).length(19);
653
+ var bluetoothCredentials = z13.object({
654
+ ...documentFields,
655
+ pin: bluetoothPin,
656
+ crowdKey: z13.int().min(0).max(16777215).nullable()
657
+ });
658
+ var factoryResetReport = z13.strictObject({
659
+ deviceId: documentId,
660
+ requestId,
661
+ trackerCreatedAt: z13.iso.datetime()
662
+ });
663
+ var batteryObservation = z13.strictObject({
664
+ deviceId: documentId,
665
+ observedAt: z13.iso.datetime(),
666
+ level: z13.int().min(0).max(100).nullable(),
667
+ isCharging: z13.boolean()
668
+ });
669
+ var locationObservation = z13.strictObject({
670
+ deviceId: documentId,
671
+ requestId,
672
+ observedAt: z13.iso.datetime({ offset: true }),
673
+ source: z13.enum(["BLE", "CBT"]),
674
+ latitude: z13.number().min(-90).max(90),
675
+ longitude: z13.number().min(-180).max(180),
676
+ accuracy: z13.number().min(0).max(1e5),
677
+ batteryLevel: z13.int().min(0).max(100).nullable(),
678
+ isCharging: z13.boolean(),
679
+ crowdKey: z13.int().min(0).max(16777215).nullable(),
680
+ rssi: z13.int().min(-127).max(20).nullable()
681
+ }).refine(
682
+ (value) => value.source !== "CBT" || value.crowdKey !== null,
683
+ "Crowd observations require a crowd key."
684
+ );
685
+ var bluetoothContract = {
686
+ reportLocation: oc11.errors(apiErrors).input(locationObservation).output(z13.object({ observationId: documentId })),
687
+ credentials: oc11.meta({ operation: "read" }).errors(apiErrors).input(trackerInput).output(bluetoothCredentials),
688
+ reportFactoryReset: oc11.errors(apiErrors).input(factoryResetReport).output(z13.void()),
689
+ reportBattery: oc11.errors(apiErrors).input(batteryObservation).output(z13.void())
690
+ };
691
+
692
+ // ../customer-contracts/src/invitations.ts
693
+ import { oc as oc12 } from "@orpc/contract";
694
+ import { z as z14 } from "zod";
695
+ var accessCode = z14.string().regex(/^[a-f0-9]{32}$/);
696
+ var invitationInput = z14.strictObject({
697
+ deviceId: documentId,
698
+ requestId
699
+ });
700
+ var invitationRedeemInput = z14.strictObject({
701
+ deviceId: documentId,
702
+ accessCode,
703
+ displayName: membershipName
704
+ });
705
+ var fields = { requestId: z14.guid(), createdAt: z14.iso.datetime() };
706
+ var trackerInvitation = z14.discriminatedUnion("state", [
707
+ z14.object({ ...fields, state: z14.literal("active"), accessCode }),
708
+ z14.object({
709
+ ...fields,
710
+ state: z14.literal("unavailable"),
711
+ accessCode: z14.null()
712
+ })
713
+ ]);
714
+ var trackerInvitationContract = {
715
+ create: oc12.errors(apiErrors).input(invitationInput).output(trackerInvitation),
716
+ get: oc12.meta({ operation: "read" }).errors(apiErrors).input(invitationInput).output(trackerInvitation),
717
+ revoke: oc12.errors(apiErrors).input(trackerInput).output(z14.void()),
718
+ redeem: oc12.errors(apiErrors).input(invitationRedeemInput).output(z14.void())
719
+ };
720
+
721
+ // ../customer-contracts/src/photo-uploads.ts
722
+ import { oc as oc13 } from "@orpc/contract";
723
+ import { z as z15 } from "zod";
724
+ var photoUploadInput = z15.strictObject({
725
+ deviceId: documentId,
726
+ requestId
727
+ });
728
+ var photoUploadStartInput = photoUploadInput.extend({
729
+ kind: z15.enum(["bike", "installation", "receipt"]),
730
+ length: z15.int().min(4).max(10 * 1024 * 1024),
731
+ sha256: z15.string().regex(/^[a-fA-F0-9]{64}$/).toUpperCase()
732
+ });
733
+ var photoUploadSession = z15.discriminatedUnion("status", [
734
+ z15.object({ status: z15.literal("published"), photoId: documentId }),
735
+ z15.object({
736
+ status: z15.literal("upload"),
737
+ url: z15.url({ protocol: /^https$/ }),
738
+ expiresAt: z15.iso.datetime(),
739
+ headers: z15.object({
740
+ "content-type": z15.literal("image/jpeg"),
741
+ "if-none-match": z15.literal("*")
742
+ })
743
+ })
744
+ ]);
745
+ var photoUploadContract = {
746
+ start: oc13.errors(apiErrors).input(photoUploadStartInput).output(photoUploadSession),
747
+ complete: oc13.errors(apiErrors).input(photoUploadInput).output(z15.object({ photoId: documentId }))
748
+ };
749
+
750
+ // ../customer-contracts/src/theft.ts
751
+ import { oc as oc14 } from "@orpc/contract";
752
+ import { z as z16 } from "zod";
753
+ var theftSubmission = z16.strictObject({
754
+ deviceId: documentId,
755
+ requestId,
756
+ phoneNumber: z16.string().min(1).max(80).refine((value) => {
757
+ if (/\p{Cc}/u.test(value)) return false;
758
+ const number = value.replaceAll("+", "").replace(/\p{Z}+$/u, "").replace(/(?:ext\.?|x)\p{Z}*\p{Nd}+$/iu, "");
759
+ return /\p{Nd}/u.test(number) && /^[\p{Nd}\p{Z}().-]+$/u.test(number);
760
+ }, "Supply a contact phone number.")
761
+ });
762
+ var theftContract = {
763
+ submit: oc14.errors(apiErrors).input(theftSubmission).output(z16.object({ reportId: documentId }))
764
+ };
765
+
766
+ // ../customer-contracts/src/session-migration.ts
767
+ import { z as z17 } from "zod";
768
+ var token = z17.string().min(1).max(16384).regex(/^[\x21-\x7e]+$/);
769
+ var migratedSession = z17.strictObject({
770
+ accessToken: token,
771
+ refreshToken: token,
772
+ expiresIn: z17.int32().positive()
773
+ });
774
+
775
+ // ../customer-contracts/src/index.ts
776
+ import { eventIterator as eventIterator3, oc as oc15 } from "@orpc/contract";
777
+ import { z as z18 } from "zod";
778
+
779
+ // ../customer-contracts/src/gcp/index.ts
780
+ var gcpContract = {
781
+ firmware: gen1FirmwareContract,
782
+ bluetooth: bluetoothContract,
783
+ history: historyContract
784
+ };
785
+
786
+ // ../customer-contracts/src/index.ts
787
+ var procedure = oc15.errors(apiErrors).input(trackerInput);
788
+ var trackerContract = {
789
+ subscription: subscriptionAllocationContract,
790
+ theft: theftContract,
791
+ lookup: trackerLookupContract,
792
+ photos: {
793
+ ...trackerPhotoContract,
794
+ uploads: photoUploadContract,
795
+ watchPage: oc15.meta({ operation: "read" }).errors(apiErrors).input(photoPageInput).output(eventIterator3(photoPage))
796
+ },
797
+ invitations: trackerInvitationContract,
798
+ ...trackerChangeContract,
799
+ claim: oc15.errors(apiErrors).input(trackerClaimInput).output(z18.void()),
800
+ list: oc15.meta({ operation: "read" }).errors(apiErrors).input(pageInput).output(trackerPage),
801
+ watchPage: oc15.meta({ operation: "read" }).errors(apiErrors).input(pageInput).output(eventIterator3(trackerPage)),
802
+ get: procedure.meta({ operation: "read" }).output(tracker),
803
+ watch: procedure.meta({ operation: "read" }).output(eventIterator3(tracker))
804
+ };
805
+ var customerContract = {
806
+ realtime: realtimeContract,
807
+ subscriptions: subscriptionContract,
808
+ account: accountContract,
809
+ trackers: trackerContract,
810
+ gcp: gcpContract
811
+ };
812
+
813
+ export {
814
+ apiContractVersion,
815
+ subscriptionInput,
816
+ pushToken,
817
+ pushRegistrationInput,
818
+ pushRemovalInput,
819
+ pushContract,
820
+ notificationSource,
821
+ inboxCursor,
822
+ inboxPageInput,
823
+ notification,
824
+ inboxPage,
825
+ inboxContract,
826
+ readIssue,
827
+ trackerBike,
828
+ trackerBattery,
829
+ trackerLocation,
830
+ trackerSubscription,
831
+ trackerFirmware,
832
+ trackerMember,
833
+ trackerSummaryFields,
834
+ trackerFields,
835
+ trackerSummary,
836
+ trackerPage,
837
+ tracker,
838
+ directoryProfile,
839
+ accountPreferences,
840
+ defaultAccountPreferences,
841
+ account,
842
+ accountPreferencePatch,
843
+ photoInput,
844
+ photoPageInput,
845
+ photoDownloadInput,
846
+ photo,
847
+ photoPage,
848
+ downloadReference,
849
+ trackerPhotoContract,
850
+ realtimeTicket,
851
+ realtimeContract,
852
+ subscription,
853
+ subscriptionPage,
854
+ subscriptionContract,
855
+ subscriptionAllocationInput,
856
+ subscriptionAllocationContract,
857
+ bikeChanges,
858
+ bikeEditInput,
859
+ membershipName,
860
+ trackerClaimInput,
861
+ trackerMemberInput,
862
+ trackerMemberAddInput,
863
+ trackerMovementAlertsInput,
864
+ trackerChangeContract,
865
+ trackerLookupInput,
866
+ trackerAdmission,
867
+ trackerLookupContract,
868
+ historyCursor,
869
+ historyInput,
870
+ historyEntry,
871
+ historyPage,
872
+ historyContract,
873
+ firmwareAvailability,
874
+ trackerFirmwareRelease,
875
+ firmwareAppInput,
876
+ trackerFirmwareReleases,
877
+ firmwareTransfer,
878
+ firmwareUpdateInput,
879
+ startFirmwareUpdate,
880
+ firmwareReportOutcome,
881
+ firmwareReportInput,
882
+ firmwareClientReport,
883
+ trackerFirmwareUpdate,
884
+ gen1FirmwareContract,
885
+ bluetoothPin,
886
+ bluetoothCredentials,
887
+ factoryResetReport,
888
+ batteryObservation,
889
+ locationObservation,
890
+ bluetoothContract,
891
+ invitationInput,
892
+ invitationRedeemInput,
893
+ trackerInvitation,
894
+ trackerInvitationContract,
895
+ photoUploadInput,
896
+ photoUploadStartInput,
897
+ photoUploadSession,
898
+ photoUploadContract,
899
+ theftSubmission,
900
+ theftContract,
901
+ migratedSession,
902
+ customerContract
903
+ };