@bikefinder/sdk 0.12.0 → 0.23.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 +47 -128
- package/dist/chunk-HTKUP56M.js +786 -0
- package/dist/index.d.ts +17753 -39
- package/dist/index.js +385 -65
- package/dist/schemas.d.ts +17882 -0
- package/dist/schemas.js +174 -0
- package/package.json +20 -23
- package/dist/acquisition-schema.d.ts +0 -177
- package/dist/acquisition-schema.js +0 -250
- package/dist/device-schema.d.ts +0 -9095
- package/dist/device-schema.js +0 -10734
- package/dist/generated/client/client.gen.d.ts +0 -2
- package/dist/generated/client/client.gen.js +0 -217
- package/dist/generated/client/index.d.ts +0 -10
- package/dist/generated/client/index.js +0 -6
- package/dist/generated/client/types.gen.d.ts +0 -120
- package/dist/generated/client/types.gen.js +0 -2
- package/dist/generated/client/utils.gen.d.ts +0 -37
- package/dist/generated/client/utils.gen.js +0 -231
- package/dist/generated/client.gen.d.ts +0 -12
- package/dist/generated/client.gen.js +0 -3
- package/dist/generated/core/auth.gen.d.ts +0 -25
- package/dist/generated/core/auth.gen.js +0 -14
- package/dist/generated/core/bodySerializer.gen.d.ts +0 -25
- package/dist/generated/core/bodySerializer.gen.js +0 -57
- package/dist/generated/core/params.gen.d.ts +0 -43
- package/dist/generated/core/params.gen.js +0 -112
- package/dist/generated/core/pathSerializer.gen.d.ts +0 -33
- package/dist/generated/core/pathSerializer.gen.js +0 -114
- package/dist/generated/core/queryKeySerializer.gen.d.ts +0 -18
- package/dist/generated/core/queryKeySerializer.gen.js +0 -99
- package/dist/generated/core/serverSentEvents.gen.d.ts +0 -71
- package/dist/generated/core/serverSentEvents.gen.js +0 -136
- package/dist/generated/core/types.gen.d.ts +0 -83
- package/dist/generated/core/types.gen.js +0 -2
- package/dist/generated/core/utils.gen.d.ts +0 -19
- package/dist/generated/core/utils.gen.js +0 -87
- package/dist/generated/index.d.ts +0 -2
- package/dist/generated/index.js +0 -2
- package/dist/generated/sdk.gen.d.ts +0 -136
- package/dist/generated/sdk.gen.js +0 -1347
- package/dist/generated/types.gen.d.ts +0 -12633
- package/dist/generated/types.gen.js +0 -2
- package/dist/generated/zod.gen.d.ts +0 -40667
- package/dist/generated/zod.gen.js +0 -13757
- package/dist/signalr/BikeFinder.Api.Commands.d.ts +0 -1
- package/dist/signalr/BikeFinder.Api.Commands.js +0 -1
- package/dist/signalr/BikeFinder.Api.Firestore.d.ts +0 -1
- package/dist/signalr/BikeFinder.Api.Firestore.js +0 -1
- package/dist/signalr/BikeFinder.Api.Http.d.ts +0 -7
- package/dist/signalr/BikeFinder.Api.Http.js +0 -4
- package/dist/signalr/BikeFinder.Api.Observations.d.ts +0 -1
- package/dist/signalr/BikeFinder.Api.Observations.js +0 -1
- package/dist/signalr/BikeFinder.Api.Settings.d.ts +0 -1
- package/dist/signalr/BikeFinder.Api.Settings.js +0 -1
- package/dist/signalr/BikeFinder.Api.Trackers.d.ts +0 -22
- package/dist/signalr/BikeFinder.Api.Trackers.js +0 -4
- package/dist/signalr/BikeFinder.DeviceConfiguration.d.ts +0 -1
- package/dist/signalr/BikeFinder.DeviceConfiguration.js +0 -1
- package/dist/signalr/BikeFinder.Nucleus.Commands.d.ts +0 -1
- package/dist/signalr/BikeFinder.Nucleus.Commands.js +0 -1
- package/dist/signalr/BikeFinder.Observations.Model.d.ts +0 -1
- package/dist/signalr/BikeFinder.Observations.Model.js +0 -1
- package/dist/signalr/TypedSignalR.Client/BikeFinder.Api.Trackers.d.ts +0 -91
- package/dist/signalr/TypedSignalR.Client/BikeFinder.Api.Trackers.js +0 -1
- package/dist/signalr/TypedSignalR.Client/index.d.ts +0 -18
- package/dist/signalr/TypedSignalR.Client/index.js +0 -89
- package/openapi/api.json +0 -52163
package/README.md
CHANGED
|
@@ -1,144 +1,63 @@
|
|
|
1
1
|
# @bikefinder/sdk
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
This package remains prelaunch. It replaces the experimental
|
|
8
|
-
`@bikefinder/api-client` package so **1.0.0** can mark the eventual stable launch.
|
|
9
|
-
Pin exact versions during development. Existing consumers of the old package
|
|
10
|
-
continue to work; renaming the package does not change the API's `/v1` paths.
|
|
11
|
-
|
|
12
|
-
Staff can explicitly query Com4 with
|
|
13
|
-
`requests.getStaffTrackerCom4SimStatus({ path: { id: trackerId } })`. The server
|
|
14
|
-
resolves the tracker's ICCID and returns only its provider status and check time.
|
|
15
|
-
This call does not activate or suspend a SIM, and provisioning status does not
|
|
16
|
-
establish tracker connectivity.
|
|
17
|
-
|
|
18
|
-
Tracker audit responses model the existing log types separately: field changes
|
|
19
|
-
carry typed `old`/`new` values, messages carry `message`, and operator actions,
|
|
20
|
-
effect failures and historical operation batches retain their own fields. Map
|
|
21
|
-
changes are partial diffs. Unknown event types keep their envelope and include a
|
|
22
|
-
`readIssues` warning; stored payloads are never forwarded as arbitrary JSON.
|
|
3
|
+
Typed customer HTTP and WebSocket client for the [API](../../README.md).
|
|
4
|
+
Version 0.23 replaces the previous generated REST methods and custom realtime
|
|
5
|
+
protocol with native oRPC contracts, validation and async iterators. Staff tools
|
|
6
|
+
use [@bikefinder/staff-sdk](../staff-sdk/README.md).
|
|
23
7
|
|
|
24
8
|
```ts
|
|
25
|
-
import { createBikeFinderClient } from
|
|
9
|
+
import { createBikeFinderClient, ORPCError } from '@bikefinder/sdk';
|
|
26
10
|
|
|
27
|
-
const
|
|
28
|
-
baseUrl:
|
|
29
|
-
|
|
11
|
+
const client = createBikeFinderClient({
|
|
12
|
+
baseUrl: 'https://api.prod.bikefinder.com',
|
|
13
|
+
accessToken: () => session.getAccessToken(),
|
|
14
|
+
onReconnect: () => restartActiveViews(),
|
|
30
15
|
});
|
|
31
16
|
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
error: (error) => showSubscriptionError(error),
|
|
40
|
-
complete: () => showSubscriptionEnded(),
|
|
41
|
-
});
|
|
17
|
+
const tracker = await client.api.trackers.get({ id: trackerId });
|
|
18
|
+
const controller = new AbortController();
|
|
19
|
+
const changes = await client.api.trackers.watch(
|
|
20
|
+
{ id: trackerId },
|
|
21
|
+
{ signal: controller.signal },
|
|
22
|
+
);
|
|
23
|
+
for await (const tracker of changes) updateTracker(tracker);
|
|
42
24
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
// On sign-out/account change, discard account data and dispose this client.
|
|
46
|
-
await api.dispose();
|
|
25
|
+
controller.abort();
|
|
26
|
+
client.dispose();
|
|
47
27
|
```
|
|
48
28
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
The application's Auth0 SDK supplies tokens and handles refresh. Create a new client for a new account session. `dispose()` aborts HTTP requests and stops both connections. REST requests use bearer authentication, omit cookies and reject redirects. Realtime requests also use bearer authentication and allow affinity cookies. Network/validation failures reject; HTTP Problem Details are available as `result.error` by default. Writes are never automatically retried; a `503 operation_unconfirmed` may already have committed.
|
|
56
|
-
|
|
57
|
-
REST calls automatically validate response structure without transforming response JSON. The API uses native Firestore mapping and narrow field converters before responding. Malformed known values fail with `stored_data_invalid`; ordinary document responses no longer carry partial-data `readIssues`. Stream values use the native SignalR decoder; import `zTrackerDocument` from `@bikefinder/sdk/schemas` and call `.parse(value)` for the same runtime boundary check on a stream message. Both transports reference the same generated payload types. Firestore responses come from the actual C# DTOs in `Firestore/TrackerData.cs` and `Firestore/ResourceData.cs`. Unmodeled storage fields are ignored, never forwarded into response extensions. Server-serialized response fixtures are validated by both API and generated-client tests. IDs are exact Firestore IDs.
|
|
29
|
+
Ordinary procedures use HTTP under `/rpc/customer`. Event iterators share one
|
|
30
|
+
API Gateway WebSocket connection. The SDK obtains a fresh, single-use connection
|
|
31
|
+
ticket over authenticated HTTP; access tokens never appear in the WebSocket URL
|
|
32
|
+
or application frames. The application's Auth0 SDK owns login and token refresh.
|
|
33
|
+
HTTP requests omit cookies, disable caching and refuse redirects.
|
|
58
34
|
|
|
59
|
-
|
|
35
|
+
`baseUrl` accepts HTTPS, including an optional stage path. Plain HTTP is limited
|
|
36
|
+
to loopback development endpoints. Each procedure accepts an optional second
|
|
37
|
+
argument containing `signal`. `dispose()` cancels requests, uploads and the
|
|
38
|
+
shared socket. Typed failures use `ORPCError` with `code`, `status` and `data`.
|
|
60
39
|
|
|
61
|
-
|
|
40
|
+
Full reconnects end existing subscriptions. Use `onReconnect` to explicitly
|
|
41
|
+
subscribe again. The SDK does not replay events or retry writes automatically.
|
|
42
|
+
Retain the original request ID when explicitly retrying an uncertain mutation.
|
|
62
43
|
|
|
63
|
-
|
|
44
|
+
Photos use the normal typed HTTP API for authorization and metadata. The upload
|
|
45
|
+
helper sends JPEG bytes directly to private staging storage, then asks the API
|
|
46
|
+
to sanitize and publish the image:
|
|
64
47
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
`src/device-schema.ts` and `src/acquisition-schema.ts` are generated outputs required
|
|
77
|
-
by the client build and consumers.
|
|
78
|
-
|
|
79
|
-
From the repository root:
|
|
80
|
-
|
|
81
|
-
```powershell
|
|
82
|
-
dotnet tool restore
|
|
83
|
-
dotnet restore services/api/src/Api.csproj --locked-mode
|
|
84
|
-
npm ci --ignore-scripts
|
|
85
|
-
npm run contract --workspace @bikefinder/sdk
|
|
86
|
-
npm run generate --workspace @bikefinder/sdk
|
|
87
|
-
npm run check --workspace @bikefinder/sdk
|
|
88
|
-
npm test --workspace @bikefinder/sdk
|
|
89
|
-
npm run build --workspace @bikefinder/sdk
|
|
48
|
+
```ts
|
|
49
|
+
const result = await client.uploadPhoto({
|
|
50
|
+
id: trackerId,
|
|
51
|
+
requestId: crypto.randomUUID(),
|
|
52
|
+
kind: 'bike',
|
|
53
|
+
body: jpegBlob,
|
|
54
|
+
});
|
|
55
|
+
const download = await client.api.trackers.photos.download({
|
|
56
|
+
id: trackerId,
|
|
57
|
+
photoId: result.photoId,
|
|
58
|
+
});
|
|
90
59
|
```
|
|
91
60
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
## Publish
|
|
97
|
-
|
|
98
|
-
Bump this package's version and the root lockfile. Generate, check, test and build locally, then publish with `npm publish --workspace @bikefinder/sdk --access public` when release is authorized. Use the existing local npm authentication; never put a token in the repository. Publishing the package does not deploy the API.
|
|
99
|
-
|
|
100
|
-
The optional **Publish API client** workflow (`publish-client.yml`) uses GitHub OIDC when Actions minutes are available. Local releases do not depend on that workflow.
|
|
101
|
-
|
|
102
|
-
The npm package's trusted publisher must name organization `bikefinder`,
|
|
103
|
-
repository `aws_cloud`, workflow `publish-client.yml`, with direct `npm publish`
|
|
104
|
-
allowed and no environment name. This account setup is performed once in the
|
|
105
|
-
package's npm settings. See [npm trusted publishing](https://docs.npmjs.com/trusted-publishers/).
|
|
106
|
-
|
|
107
|
-
Command HTTP reads return `TrackerCommand`; command subscriptions return `CommandUpdate` with a command or an explicit read issue. Requests, broker publication and `execution.completed` are distinct stages on that resource. A completion includes its outcome, unavailable observation names and authenticated receipt time. Command output values are separate typed observations delivered through the observation endpoints and streams.
|
|
108
|
-
|
|
109
|
-
Version **0.7.0** reads selected current observations with a typed JSON body instead of repeated URL parameters. Pass `{path: {id}, body: {series: [{definitionId, subject?}]}}` to `readStaffTrackerObservations`. All registered observations, including request-scoped command events, support latest-value reads and streams. Observation `requestId` metadata is retained when recorded; older facts may lack it.
|
|
110
|
-
|
|
111
|
-
Version **0.6.0** aligned command receipts and independent domain observations. Consumers upgrading from 0.5 must read command output from the observation stream instead of a nested response-data union. `execution.accepted` is removed; use `publishedAt` for broker publication and `execution.completed` for the terminal device result.
|
|
112
|
-
|
|
113
|
-
## Observation timestamps
|
|
114
|
-
|
|
115
|
-
Observation history exposes `measuredAt` and `receivedAt`. Current readings expose these on `reading.observation`, which is null when no current value exists.
|
|
116
|
-
Observation IDs are opaque server-generated references. They carry no boot or
|
|
117
|
-
sequence information. Distinct rows can have identical capture timestamps;
|
|
118
|
-
clients must not infer physical ordering from their IDs. History can contain
|
|
119
|
-
separate rows for an at-least-once delivery of the same reading.
|
|
120
|
-
|
|
121
|
-
Settings responses use the API-owned `SettingsSnapshot` for HTTP and SignalR: read typed `desired`, `reported`, `application`, capabilities and schema/version evidence directly. `readIssues` identifies stored values the API could not interpret. The resource does not expose the underlying AWS shadow document or its independent owners. Settings fields and bounds come from the same protocol registry as the firmware.
|
|
122
|
-
|
|
123
|
-
Command reads validate stored identity, catalog arguments, artifacts, and execution evidence. A malformed single-command read returns `command_unreadable`; command pages keep valid items and attach per-request `readIssues`. Both command streams emit `CommandUpdate` with either a validated `command` or a `readIssue`, allowing subsequent events to continue.
|
|
124
|
-
|
|
125
|
-
## Current API contract
|
|
126
|
-
|
|
127
|
-
Version **0.12.0** enables native SignalR stateful reconnect on customer and staff connections. Temporary transport interruptions retain existing subscriptions when the original server connection survives. Negotiation and affinity cookies are enabled; a new connection still requires new subscriptions. Generated observation types also include the deployed `power.idleState` observation.
|
|
128
|
-
|
|
129
|
-
Version **0.11.0** adds `listStaffTrackerCommandObservations({path: {id, operationId}, query: {limit, cursor}})`. It returns a typed `ObservationPage` scoped to that tracker and command, including cached readings and later resolved locations. Subscribe to observation events and match both `deviceId` and `requestId` for live results.
|
|
130
|
-
|
|
131
|
-
Version **0.9.0** removes the separate positioning request/schedule APIs and
|
|
132
|
-
retires their device command. Request WiFi, LTE and GPS observations through
|
|
133
|
-
normal `requestObservations` commands. Fresh radio observations are geolocated
|
|
134
|
-
automatically; no workflow registration or automatic fallback is involved.
|
|
135
|
-
|
|
136
|
-
Generate HTTP methods and response schemas from the API-owned OpenAPI contract. Use the same explicit models for HTTP and SignalR: `TrackerCommand`, `CommandUpdate`, `ObservationSelection`, `SettingsSnapshot` and `FirmwareArtifact`. Deploy the matching API before updating consumers to a changed contract.
|
|
137
|
-
|
|
138
|
-
WiFi, LTE and GPS requests use normal observation commands. Fresh radio observations are geolocated automatically. Movement-alert preferences have their own typed request contract. The protocol registry owns settings fields and bounds; the runtime schema endpoints expose the deployed definitions. Firmware mode selectors, per-mode timers and command-listening settings are retired.
|
|
139
|
-
|
|
140
|
-
Observation history and events use the catalog-discriminated `Observation` union. Current readings identify a selected series and a nullable typed `CurrentObservation`; null means that no current reading exists. Request validation is strict. Response validation checks known fields while preserving additions.
|
|
141
|
-
|
|
142
|
-
Contract export uses `Microsoft.Extensions.ApiDescription.Server` through the contract script. It executes startup with inert configuration and disables cloud event workers; it opens no listening HTTP server and needs no cloud credentials. Ordinary builds do not rewrite the checked-in contract.
|
|
143
|
-
|
|
144
|
-
Run generation, type checks, runtime contract tests and the build before release. Publishing the SDK and deploying the API are separate operations; generated code does neither.
|
|
61
|
+
Uploads are limited to 10 MiB. Download URLs expire after two minutes; request a
|
|
62
|
+
fresh reference if one expires. Photo bytes do not travel over WebSockets.
|
|
63
|
+
Runtime schemas are available from `@bikefinder/sdk/schemas`.
|