@fleetless/sdk 5.0.0 → 5.2.0-next.1
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/CHANGELOG.md +35 -0
- package/README.md +52 -2
- package/dist/index.cjs +3132 -914
- package/dist/index.d.cts +911 -7
- package/dist/index.d.ts +911 -7
- package/dist/index.js +3127 -913
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,41 @@ All notable changes to `@fleetless/sdk`. The format follows Keep a Changelog; th
|
|
|
4
4
|
|
|
5
5
|
## [Unreleased]
|
|
6
6
|
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- **MCP clients by Client ID Metadata Document** (fleetless/fleetless#1218). `ClientMcpInteraction`, what `auth.mcpInteraction()` resolves, carries `client_id_host` (the domain the client's metadata document was fetched from, `null` for a self-registered client), `redirect_uri_host` and `redirect_uri_loopback`: a consent screen shows the domain and where the answer goes beside the unverified name, and warns when the answer goes to the person's own computer. `McpConsentGrant`, what `auth.listMcpGrants()` resolves, carries `client_id_host`. A grant's `client_id` may be the document's HTTPS URL; `auth.revokeMcpGrant()` encodes it as one path segment, as it encodes every id.
|
|
10
|
+
|
|
11
|
+
### Changed
|
|
12
|
+
|
|
13
|
+
- Built against `@fleetless/contracts` 18.1.0-next.2 (the release pin follows the contracts release).
|
|
14
|
+
|
|
15
|
+
## [5.1.0] — 2026-11-06
|
|
16
|
+
|
|
17
|
+
### Added
|
|
18
|
+
|
|
19
|
+
- **`client.collections`: an app's own data, over REST and realtime.** A developer defines collections (typed fields, a binding to robots, and which roles may read, create, update and delete) in the console; the app reads and writes their records as the signed-in user or with a server key.
|
|
20
|
+
- REST: `definitions()` (resolves `{ version, collections }`: the readable collections with their fields and what the caller may do, and the schema version they belong to, `null` before anything was published), `list(collection, options)` (search, filter, sort, `limit`, `cursor`, `count`, `expand`, `robot`, `deleted`; resolves `{ records, nextCursor, total? }`), `get` by id or by `{ robot }` for a `one_per_robot` collection, `create`, `update` (with `expectedRevision`), `delete` and `history` (resolves `{ revisions, nextBeforeSeq, purged }`).
|
|
21
|
+
- Realtime: `subscribe(collection, { robot?, filter?, onError?, onSchemaPublished?, onReady? }, onEvent)` follows a collection's records over the client's channel, subscribes again after every reconnect and returns the function that ends it. There is no first snapshot. `onReady` is called each time the cloud confirms the subscription (`collection_subscribed`): the first time, and again on every new connection once the subscription was sent again. It is the place to `list`: every change after the confirmation reaches `onEvent`, so none falls between the list and the events, and the same code refreshes what the app holds after a reconnect, because changes made while the connection was down are not replayed. It needs a cloud that sends the confirmation.
|
|
22
|
+
- A subscription whose frame, with its filter, is larger than the 16,384 bytes the cloud takes on its realtime socket is refused with `invalid_option` before anything is sent: the cloud would close the connection for it, and again after every reconnect, taking the client's other subscriptions with it. `subscribe` throws; narrow the filter or follow the collection by `robot`.
|
|
23
|
+
- Filters: a `filter` of `list` or `subscribe` is plain JSON, and the SDK copies it as JSON, so a reactive proxy (a Vue `reactive`, a Svelte `$state`, a MobX observable) is fine. A value JSON cannot hold (a BigInt, a function, a number that is not finite, a cycle) is refused with `invalid_option` before anything is sent: `list` rejects, `subscribe` throws.
|
|
24
|
+
- New exports: the types `CollectionsApi`, `CollectionListOptions`, `CollectionPage`, `CollectionHistoryOptions`, `CollectionHistoryPage`, `CollectionRecord`, `CollectionRevision`, `CollectionDefinition`, `CollectionDefinitions`, `CollectionEvent`, `CollectionSubscribeOptions`, `CollectionField`, `CollectionBinding` and `CollectionActor`, and the `error.details` schemas of the refusals specific to records, with their types: `recordChangedDetails`, `recordReferencedDetails`, `referenceInvalidDetails` and `requiredMissingDetails`.
|
|
25
|
+
|
|
26
|
+
### Changed
|
|
27
|
+
|
|
28
|
+
- Built against `@fleetless/contracts` 15.0.0.
|
|
29
|
+
|
|
30
|
+
### Fixed
|
|
31
|
+
|
|
32
|
+
- **An id, slug or key of `.` or `..` is refused instead of climbing out of its route.** `encodeURIComponent` leaves a value that is only dots alone, and the URL parser `fetch` runs resolves `..` (and `%2E%2E`) as a dot-segment, so `client.collections.get('..', id)` reached a different route with the caller's credentials. Every call that puts an id, slug or key into a path now rejects with `invalid_option` before a request is built. Values that merely contain dots (`a.b`, `...`) are unchanged.
|
|
33
|
+
|
|
34
|
+
### Removed
|
|
35
|
+
|
|
36
|
+
- Nothing in this SDK's API. `robot_details` is no longer a built-in datapoint, and the platform has no route to set it: a robot's description is data an app keeps in its own collections now. Reading or subscribing to that slug is refused like any other slug the robot does not expose, with `unknown_datapoint`, and the SDK relays it as it does every code.
|
|
37
|
+
|
|
38
|
+
### Compatibility
|
|
39
|
+
|
|
40
|
+
- `FleetlessErrorCode` gains `collection_not_found`, `collection_removed`, `record_changed`, `record_referenced`, `reference_invalid`, `required_missing` and `robot_not_attached` through `ErrorCode`. An exhaustive `switch` over `ErrorCode` gains the cases.
|
|
41
|
+
|
|
7
42
|
## [5.0.0] — 2026-11-06
|
|
8
43
|
|
|
9
44
|
### Changed
|
package/README.md
CHANGED
|
@@ -19,8 +19,7 @@ sessions, the reconnects, the subscriptions and the errors, so your code can
|
|
|
19
19
|
get on with the part that is actually about your robot. Framework-agnostic,
|
|
20
20
|
ESM and CJS, types included.
|
|
21
21
|
|
|
22
|
-
Fleetless is in
|
|
23
|
-
<https://fleetless.dev/#waiting-list>.
|
|
22
|
+
Fleetless is in open beta: sign up at <https://console.fleetless.dev/signup>.
|
|
24
23
|
|
|
25
24
|
## ✨ What you can do with it
|
|
26
25
|
|
|
@@ -35,6 +34,9 @@ Fleetless is in closed beta. The waiting list is at
|
|
|
35
34
|
- **Show cameras**: a snapshot that is always there, or live video over
|
|
36
35
|
WebRTC that starts with the first viewer and stops with the last.
|
|
37
36
|
- **Follow jobs**, sync assets, and render the robot's URDF with its meshes.
|
|
37
|
+
- **Keep your app's own data** in collections a developer defines in the
|
|
38
|
+
console: records you list, search, write and follow live, under the same
|
|
39
|
+
roles as everything else.
|
|
38
40
|
- **Sign your users in** — registration, verification, invitations, password
|
|
39
41
|
reset, single sign-on and MCP consent — from screens that are entirely
|
|
40
42
|
yours. Fleetless renders no page for an app user.
|
|
@@ -101,6 +103,54 @@ const { password, emailCode, twoFactor } = await client.auth.signInMethods()
|
|
|
101
103
|
// listProviders() separately returns only federated sign-in buttons.
|
|
102
104
|
```
|
|
103
105
|
|
|
106
|
+
## 🗂️ Collections
|
|
107
|
+
|
|
108
|
+
Besides what the robot exposes, an app has data of its own: **collections** a
|
|
109
|
+
developer defines in the console, such as a logbook per robot, a list of
|
|
110
|
+
components with their locations, or one settings record per robot. Each has
|
|
111
|
+
typed fields and says which roles may read, create, update and delete. The
|
|
112
|
+
records are read and written as the signed-in user, or with a server key.
|
|
113
|
+
|
|
114
|
+
```ts
|
|
115
|
+
import type { CollectionRecord } from '@fleetless/sdk'
|
|
116
|
+
|
|
117
|
+
// What this caller may read, with the fields and what they may do with each,
|
|
118
|
+
// and the schema version they belong to.
|
|
119
|
+
const { version, collections } = await client.collections.definitions()
|
|
120
|
+
|
|
121
|
+
// A subscription delivers changes, not a snapshot. Once the cloud has confirmed it,
|
|
122
|
+
// `onReady` is called: list there, and every change after that reaches the callback.
|
|
123
|
+
// After a dropped connection nothing is replayed, but `onReady` is called again.
|
|
124
|
+
// The SDK does not handle what `onReady` returns, so a failing `list` is caught here.
|
|
125
|
+
let records: CollectionRecord[] = []
|
|
126
|
+
const reload = async () => {
|
|
127
|
+
try {
|
|
128
|
+
records = (await client.collections.list('logbook', { robot: robotId, sort: ['-created_at'], limit: 20 })).records
|
|
129
|
+
} catch (error) {
|
|
130
|
+
console.error('Could not read the logbook', error)
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
const unsubscribe = client.collections.subscribe('logbook', { robot: robotId, onReady: reload }, (change) => {
|
|
134
|
+
console.log(change.event, change.id, change.record?.display)
|
|
135
|
+
})
|
|
136
|
+
|
|
137
|
+
// Search and filter run in the cloud.
|
|
138
|
+
await client.collections.list('components', { search: 'quad xtd1', filter: { position_m: { gte: 2 } }, sort: ['position_m'] })
|
|
139
|
+
|
|
140
|
+
// Write. A `one_per_robot` collection has exactly one record per robot.
|
|
141
|
+
await client.collections.create('logbook', { text: 'Replaced the left wheel' }, { robot: robotId })
|
|
142
|
+
const settings = await client.collections.get('robot_settings', { robot: robotId })
|
|
143
|
+
await client.collections.update('robot_settings', settings.id, { max_linear_speed: 0.6 }, { expectedRevision: settings.revision })
|
|
144
|
+
|
|
145
|
+
unsubscribe()
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
An update that names `expectedRevision` is refused with `record_changed` when
|
|
149
|
+
somebody saved first, and `recordChangedDetails.parse(error.details)` tells you
|
|
150
|
+
the revision the record is at now. The other refusals specific to records keep
|
|
151
|
+
their own codes too: `required_missing`, `reference_invalid` and
|
|
152
|
+
`record_referenced`.
|
|
153
|
+
|
|
104
154
|
## 📚 Documentation
|
|
105
155
|
|
|
106
156
|
Everything past this point lives at **[docs.fleetless.dev](https://docs.fleetless.dev)**.
|