@omirion/orbit-sdk 0.4.0 → 0.5.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 +4 -1
- package/dist/index.cjs +9 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +58 -1
- package/dist/index.d.ts +58 -1
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -1
- package/examples/device-rpc-flow/README.md +1 -1
- package/examples/device-rpc-flow/index.tsx +4 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -38,7 +38,8 @@ import { InsufficientScopeError, DeviceRpcError } from '@omirion/orbit-sdk'
|
|
|
38
38
|
try {
|
|
39
39
|
// Commands are declared per device type, a name plus typed key/value args, no shell.
|
|
40
40
|
// `orbit.commands.manifest(deviceId)` lists what this device accepts.
|
|
41
|
-
const
|
|
41
|
+
const requestId = crypto.randomUUID() // Save before sending; reuse for retries of this command.
|
|
42
|
+
const result = await orbit.commands.exec(deviceId, { name: 'state-request', requestId, timeoutMs: 10_000 })
|
|
42
43
|
if (result.queued) {
|
|
43
44
|
// Store-and-forward device: poll orbit.commands.get(deviceId, result.invocationId)
|
|
44
45
|
}
|
|
@@ -49,6 +50,8 @@ try {
|
|
|
49
50
|
}
|
|
50
51
|
```
|
|
51
52
|
|
|
53
|
+
Command submissions require a caller-generated `requestId` UUID. Persist it before sending when recovery must survive a restart. Reuse it with the same device, issuing user and command body for retries; generate a new ID for a new intended action. HTTP retries within one SDK call preserve the body. `commands.getByRequestId(deviceId, requestId)` recovers an accepted command without resubmitting it.
|
|
54
|
+
|
|
52
55
|
### Surface
|
|
53
56
|
|
|
54
57
|
Every collection has a cursor-paginated `list(params?)` and a lazy `iterate(params?)` async-generator twin that walks all pages.
|
package/dist/index.cjs
CHANGED
|
@@ -976,6 +976,11 @@ var getDeviceCommandInvocation = (options) => (options.client ?? client).get({
|
|
|
976
976
|
url: "/api/v1/devices/{id}/commands/{invocationId}",
|
|
977
977
|
...options
|
|
978
978
|
});
|
|
979
|
+
var getDeviceCommandByRequestId = (options) => (options.client ?? client).get({
|
|
980
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
981
|
+
url: "/api/v1/devices/{id}/commands/by-request/{requestId}",
|
|
982
|
+
...options
|
|
983
|
+
});
|
|
979
984
|
var getDeviceCommands = (options) => (options.client ?? client).get({
|
|
980
985
|
security: [{ scheme: "bearer", type: "http" }],
|
|
981
986
|
url: "/api/v1/devices/{id}/commands",
|
|
@@ -1578,6 +1583,9 @@ var OrbitClient = class {
|
|
|
1578
1583
|
throwOnError: false
|
|
1579
1584
|
})
|
|
1580
1585
|
).then((result) => result.data),
|
|
1586
|
+
getByRequestId: (deviceId, requestId) => run(
|
|
1587
|
+
() => getDeviceCommandByRequestId({ client: client2, path: { id: deviceId, requestId }, throwOnError: false })
|
|
1588
|
+
).then((result) => result.data),
|
|
1581
1589
|
manifest: (deviceId) => run(
|
|
1582
1590
|
() => getDeviceCommands({
|
|
1583
1591
|
client: client2,
|
|
@@ -1788,6 +1796,7 @@ __export(generated_exports, {
|
|
|
1788
1796
|
getAdmission: () => getAdmission,
|
|
1789
1797
|
getCommandManifest: () => getCommandManifest,
|
|
1790
1798
|
getDevice: () => getDevice,
|
|
1799
|
+
getDeviceCommandByRequestId: () => getDeviceCommandByRequestId,
|
|
1791
1800
|
getDeviceCommandInvocation: () => getDeviceCommandInvocation,
|
|
1792
1801
|
getDeviceCommands: () => getDeviceCommands,
|
|
1793
1802
|
getDeviceType: () => getDeviceType,
|