@freedome/client 1.0.0 → 1.2.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/CHANGELOG.md +21 -0
- package/dist/{discovery-DTV9yp9S.d.ts → discovery-BkrBFXwA.d.ts} +13 -2
- package/dist/{discovery-BsEQfHam.d.cts → discovery-Do_9mAzB.d.cts} +13 -2
- package/dist/index.cjs +289 -139
- package/dist/index.d.cts +99 -7
- package/dist/index.d.ts +99 -7
- package/dist/index.js +274 -123
- package/dist/node.d.cts +1 -1
- package/dist/node.d.ts +1 -1
- package/dist/testing.cjs +244 -5
- package/dist/testing.d.cts +36 -1
- package/dist/testing.d.ts +36 -1
- package/dist/testing.js +251 -6
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -94,6 +94,9 @@ var ApiCaller = class _ApiCaller {
|
|
|
94
94
|
"patchAudioZone",
|
|
95
95
|
"startAudioSession",
|
|
96
96
|
"stopAudioSession",
|
|
97
|
+
"pauseAudioSession",
|
|
98
|
+
"resumeAudioSession",
|
|
99
|
+
"startAudioDeviceSweep",
|
|
97
100
|
"setSourcePosition"
|
|
98
101
|
]);
|
|
99
102
|
async call(op, o = {}) {
|
|
@@ -328,8 +331,9 @@ var BackoffPolicy = class {
|
|
|
328
331
|
|
|
329
332
|
// src/client.ts
|
|
330
333
|
import {
|
|
331
|
-
Operations as
|
|
332
|
-
ProtocolVersions,
|
|
334
|
+
Operations as Operations14,
|
|
335
|
+
ProtocolVersions as ProtocolVersions2,
|
|
336
|
+
SemVer as SemVer2,
|
|
333
337
|
WS_SUBPROTOCOL
|
|
334
338
|
} from "@freedome/protocol";
|
|
335
339
|
|
|
@@ -373,7 +377,7 @@ function nextValue(e, pred = () => true, timeoutMs = 5e3) {
|
|
|
373
377
|
|
|
374
378
|
// src/context.ts
|
|
375
379
|
var RepositoryContext = class {
|
|
376
|
-
constructor(api, hub, cache, outbox, offline, isOffline, cacheScope, realtimeUp, positionHz, onEngineHealth, logger) {
|
|
380
|
+
constructor(api, hub, cache, outbox, offline, isOffline, cacheScope, realtimeUp, positionHz, onEngineHealth, logger, contractVersion = () => void 0) {
|
|
377
381
|
this.api = api;
|
|
378
382
|
this.hub = hub;
|
|
379
383
|
this.cache = cache;
|
|
@@ -385,6 +389,7 @@ var RepositoryContext = class {
|
|
|
385
389
|
this.positionHz = positionHz;
|
|
386
390
|
this.onEngineHealth = onEngineHealth;
|
|
387
391
|
this.logger = logger;
|
|
392
|
+
this.contractVersion = contractVersion;
|
|
388
393
|
}
|
|
389
394
|
api;
|
|
390
395
|
hub;
|
|
@@ -397,7 +402,21 @@ var RepositoryContext = class {
|
|
|
397
402
|
positionHz;
|
|
398
403
|
onEngineHealth;
|
|
399
404
|
logger;
|
|
405
|
+
contractVersion;
|
|
400
406
|
outboxOutcomes = new Emitter();
|
|
407
|
+
/** Whether the server reports a contract of at least [version]. False while it is not known. */
|
|
408
|
+
contractAtLeast(version) {
|
|
409
|
+
const v = this.contractVersion();
|
|
410
|
+
return v !== void 0 && v.compareTo(version) >= 0;
|
|
411
|
+
}
|
|
412
|
+
/**
|
|
413
|
+
* Whether the server reports a contract older than [version]. False while it is not known: the call is then sent,
|
|
414
|
+
* and the server's answer decides.
|
|
415
|
+
*/
|
|
416
|
+
contractBelow(version) {
|
|
417
|
+
const v = this.contractVersion();
|
|
418
|
+
return v !== void 0 && v.compareTo(version) < 0;
|
|
419
|
+
}
|
|
401
420
|
log(level, message, error) {
|
|
402
421
|
this.logger?.({ level, message, ...error === void 0 ? {} : { error } });
|
|
403
422
|
}
|
|
@@ -1486,6 +1505,7 @@ import {
|
|
|
1486
1505
|
DomeTopics as DomeTopics2,
|
|
1487
1506
|
EventKinds as EventKinds2,
|
|
1488
1507
|
Operations as Operations3,
|
|
1508
|
+
ProtocolVersions,
|
|
1489
1509
|
jsonMergePatch as jsonMergePatch2,
|
|
1490
1510
|
rfc3339Millis as rfc3339Millis2
|
|
1491
1511
|
} from "@freedome/protocol";
|
|
@@ -1508,6 +1528,21 @@ var AudioRepository = class _AudioRepository {
|
|
|
1508
1528
|
get v() {
|
|
1509
1529
|
return { venueId: this.venueId };
|
|
1510
1530
|
}
|
|
1531
|
+
/**
|
|
1532
|
+
* Whether the server has the audio additions of contract 1.1.0: [pauseSession], [resumeSession], [startDeviceSweep],
|
|
1533
|
+
* `roleZones` of [startSession] and the `multi` block of the generator. False against a 1.0 server and while its
|
|
1534
|
+
* contract version is not known.
|
|
1535
|
+
*/
|
|
1536
|
+
get supportsAudioControl() {
|
|
1537
|
+
return this.c.contractAtLeast(ProtocolVersions.audioControl);
|
|
1538
|
+
}
|
|
1539
|
+
/** @internal A 1.0 server would answer 404 or 422: says why instead. Sent as it is when the version is not known. */
|
|
1540
|
+
requireAudioControl(what) {
|
|
1541
|
+
if (this.c.contractBelow(ProtocolVersions.audioControl))
|
|
1542
|
+
throw new UnsupportedCapabilityError(
|
|
1543
|
+
`${what} needs contract ${ProtocolVersions.audioControl.toString()}; the server reports ${String(this.c.contractVersion())}`
|
|
1544
|
+
);
|
|
1545
|
+
}
|
|
1511
1546
|
/** The same repository for another venue. */
|
|
1512
1547
|
venue(id) {
|
|
1513
1548
|
if (id === this.venueId) return this;
|
|
@@ -1689,6 +1724,20 @@ var AudioRepository = class _AudioRepository {
|
|
|
1689
1724
|
body: patch
|
|
1690
1725
|
});
|
|
1691
1726
|
}
|
|
1727
|
+
/**
|
|
1728
|
+
* Resonance sweep of one resonator channel of [deviceId] (scope `audio:calibrate`): answers a calibration job of kind
|
|
1729
|
+
* `audio-device-sweep`. Follow it with `client.calibration.progress`; progress is elapsed time, not measurement, and
|
|
1730
|
+
* the job's `sweep` member holds `peaks`, and with `modelHz` also `partials` and `warnings`, once it has succeeded.
|
|
1731
|
+
* There is nothing to apply. 409 while a session uses the device, another sweep runs or the device is in emergency
|
|
1732
|
+
* stop; 422 without such a resonator channel. Needs [supportsAudioControl].
|
|
1733
|
+
*/
|
|
1734
|
+
async startDeviceSweep(deviceId, sweep = {}) {
|
|
1735
|
+
this.requireAudioControl("startDeviceSweep");
|
|
1736
|
+
return this.c.api.json(Operations3.startAudioDeviceSweep, {
|
|
1737
|
+
params: { ...this.v, deviceId },
|
|
1738
|
+
body: sweep
|
|
1739
|
+
});
|
|
1740
|
+
}
|
|
1692
1741
|
/** Ping / tone / self-test / strike of a device. */
|
|
1693
1742
|
testDevice(deviceId, test = { kind: "ping" }) {
|
|
1694
1743
|
return this.c.api.json(Operations3.testAudioDevice, {
|
|
@@ -1747,10 +1796,12 @@ var AudioRepository = class _AudioRepository {
|
|
|
1747
1796
|
}
|
|
1748
1797
|
// ---- sessions ----
|
|
1749
1798
|
/** Runs an installed preset (live control). */
|
|
1750
|
-
startSession(s) {
|
|
1799
|
+
async startSession(s) {
|
|
1800
|
+
if (s.roleZones !== void 0) this.requireAudioControl("roleZones");
|
|
1751
1801
|
const body = { presetId: s.presetId };
|
|
1752
1802
|
if (s.gainDb !== void 0) body.gainDb = s.gainDb;
|
|
1753
1803
|
if (s.targets !== void 0) body.targets = s.targets;
|
|
1804
|
+
if (s.roleZones !== void 0) body.roleZones = s.roleZones;
|
|
1754
1805
|
if (s.at !== void 0) body.at = s.at instanceof Date ? rfc3339Millis2(s.at) : s.at;
|
|
1755
1806
|
if (s.loop !== void 0) body.loop = s.loop;
|
|
1756
1807
|
return this.c.api.json(Operations3.startAudioSession, {
|
|
@@ -1784,6 +1835,29 @@ var AudioRepository = class _AudioRepository {
|
|
|
1784
1835
|
}
|
|
1785
1836
|
);
|
|
1786
1837
|
}
|
|
1838
|
+
/**
|
|
1839
|
+
* Pauses a session (live control, scope `audio:control`): every engine holds its position, `audioSession.state`
|
|
1840
|
+
* follows. A paused session answers as it is; 409 for one that is starting or has ended. Needs
|
|
1841
|
+
* [supportsAudioControl].
|
|
1842
|
+
*/
|
|
1843
|
+
async pauseSession(sessionId) {
|
|
1844
|
+
this.requireAudioControl("pauseSession");
|
|
1845
|
+
return this.c.api.json(Operations3.pauseAudioSession, {
|
|
1846
|
+
params: { ...this.v, sessionId },
|
|
1847
|
+
preferRealtime: true
|
|
1848
|
+
});
|
|
1849
|
+
}
|
|
1850
|
+
/**
|
|
1851
|
+
* Resumes a paused session from its position (live control, scope `audio:control`). A running session answers as it
|
|
1852
|
+
* is; 409 for one that is starting or has ended. Needs [supportsAudioControl].
|
|
1853
|
+
*/
|
|
1854
|
+
async resumeSession(sessionId) {
|
|
1855
|
+
this.requireAudioControl("resumeSession");
|
|
1856
|
+
return this.c.api.json(Operations3.resumeAudioSession, {
|
|
1857
|
+
params: { ...this.v, sessionId },
|
|
1858
|
+
preferRealtime: true
|
|
1859
|
+
});
|
|
1860
|
+
}
|
|
1787
1861
|
/** Stops a session (live control). */
|
|
1788
1862
|
async stopSession(sessionId) {
|
|
1789
1863
|
await this.c.api.call(Operations3.stopAudioSession, {
|
|
@@ -1862,8 +1936,12 @@ var GeneratorSession = class {
|
|
|
1862
1936
|
this.push(s);
|
|
1863
1937
|
return s;
|
|
1864
1938
|
}
|
|
1865
|
-
/**
|
|
1939
|
+
/**
|
|
1940
|
+
* Starts the generator or replaces its settings (live control, scope `audio:control`). The `multi` block needs
|
|
1941
|
+
* [AudioRepository.supportsAudioControl].
|
|
1942
|
+
*/
|
|
1866
1943
|
async start(settings) {
|
|
1944
|
+
if (settings.multi !== void 0) this.r.requireAudioControl("generator multi");
|
|
1867
1945
|
const s = await this.r.ctx.api.json(Operations3.setGenerator, {
|
|
1868
1946
|
params: this.v,
|
|
1869
1947
|
body: settings,
|
|
@@ -1872,6 +1950,17 @@ var GeneratorSession = class {
|
|
|
1872
1950
|
this.push(s);
|
|
1873
1951
|
return s;
|
|
1874
1952
|
}
|
|
1953
|
+
/**
|
|
1954
|
+
* Plays a MULTI programme: `signal: multi` with the block [multi], the same object a phone gives to `setParams`
|
|
1955
|
+
* (contract 1.1.0, `docs/audio-control.md`).
|
|
1956
|
+
*/
|
|
1957
|
+
startMulti(multi, o = {}) {
|
|
1958
|
+
return this.start({
|
|
1959
|
+
...o,
|
|
1960
|
+
signal: "multi",
|
|
1961
|
+
multi: { ...multi, compatJava: multi.compatJava ?? false }
|
|
1962
|
+
});
|
|
1963
|
+
}
|
|
1875
1964
|
/** Stops the generator (live control). */
|
|
1876
1965
|
async stop() {
|
|
1877
1966
|
await this.r.ctx.api.call(Operations3.stopGenerator, { params: this.v, preferRealtime: true });
|
|
@@ -2018,10 +2107,38 @@ var CalibrationRepository = class {
|
|
|
2018
2107
|
}
|
|
2019
2108
|
};
|
|
2020
2109
|
|
|
2110
|
+
// src/repositories/assistant.ts
|
|
2111
|
+
import {
|
|
2112
|
+
Operations as Operations5
|
|
2113
|
+
} from "@freedome/protocol";
|
|
2114
|
+
var AssistantRepository = class {
|
|
2115
|
+
constructor(c) {
|
|
2116
|
+
this.c = c;
|
|
2117
|
+
}
|
|
2118
|
+
c;
|
|
2119
|
+
/** Newest first, with codes for a person. */
|
|
2120
|
+
confirmations() {
|
|
2121
|
+
return readAllPages(this.c.api, Operations5.listAssistantConfirmations);
|
|
2122
|
+
}
|
|
2123
|
+
refuse(confirmationId) {
|
|
2124
|
+
return this.c.api.json(Operations5.refuseAssistantConfirmation, { params: { confirmationId } });
|
|
2125
|
+
}
|
|
2126
|
+
link() {
|
|
2127
|
+
return this.c.api.json(Operations5.getAssistantLink);
|
|
2128
|
+
}
|
|
2129
|
+
/** Approves the code the assistant showed. Lasts 8 hours, with the scopes of the person signed in here. */
|
|
2130
|
+
approve(code) {
|
|
2131
|
+
return this.c.api.json(Operations5.approveAssistantLink, { body: { code } });
|
|
2132
|
+
}
|
|
2133
|
+
async end(sessionId) {
|
|
2134
|
+
await this.c.api.call(Operations5.endAssistantLink, { params: { sessionId } });
|
|
2135
|
+
}
|
|
2136
|
+
};
|
|
2137
|
+
|
|
2021
2138
|
// src/repositories/clients.ts
|
|
2022
2139
|
import {
|
|
2023
2140
|
DomeTopics as DomeTopics4,
|
|
2024
|
-
Operations as
|
|
2141
|
+
Operations as Operations6
|
|
2025
2142
|
} from "@freedome/protocol";
|
|
2026
2143
|
var ClientsRepository = class {
|
|
2027
2144
|
constructor(c) {
|
|
@@ -2029,16 +2146,16 @@ var ClientsRepository = class {
|
|
|
2029
2146
|
}
|
|
2030
2147
|
c;
|
|
2031
2148
|
register(registration) {
|
|
2032
|
-
return this.c.api.json(
|
|
2149
|
+
return this.c.api.json(Operations6.registerClient, { body: registration });
|
|
2033
2150
|
}
|
|
2034
2151
|
list() {
|
|
2035
|
-
return readAllPages(this.c.api,
|
|
2152
|
+
return readAllPages(this.c.api, Operations6.listClients);
|
|
2036
2153
|
}
|
|
2037
2154
|
async telemetry(clientId, batch) {
|
|
2038
|
-
await this.c.api.call(
|
|
2155
|
+
await this.c.api.call(Operations6.postClientTelemetry, { params: { clientId }, body: batch });
|
|
2039
2156
|
}
|
|
2040
2157
|
async unregister(clientId) {
|
|
2041
|
-
await this.c.api.call(
|
|
2158
|
+
await this.c.api.call(Operations6.unregisterClient, { params: { clientId } });
|
|
2042
2159
|
}
|
|
2043
2160
|
/** Commands the dome sends to this device (`clients/{id}/commands`). */
|
|
2044
2161
|
commands(clientId, fn) {
|
|
@@ -2052,11 +2169,11 @@ var ClientsRepository = class {
|
|
|
2052
2169
|
// src/repositories/content.ts
|
|
2053
2170
|
import {
|
|
2054
2171
|
DomeTopics as DomeTopics5,
|
|
2055
|
-
Operations as
|
|
2172
|
+
Operations as Operations8
|
|
2056
2173
|
} from "@freedome/protocol";
|
|
2057
2174
|
|
|
2058
2175
|
// src/repositories/upload.ts
|
|
2059
|
-
import { Operations as
|
|
2176
|
+
import { Operations as Operations7 } from "@freedome/protocol";
|
|
2060
2177
|
var MAX_UPLOAD_CHUNK = 95 * 1024 * 1024;
|
|
2061
2178
|
var BytesContentSource = class {
|
|
2062
2179
|
constructor(bytes, name, contentType) {
|
|
@@ -2161,7 +2278,7 @@ var UploadTask = class {
|
|
|
2161
2278
|
const id = this.uploadIdValue;
|
|
2162
2279
|
if (id) {
|
|
2163
2280
|
try {
|
|
2164
|
-
await this.c.api.call(
|
|
2281
|
+
await this.c.api.call(Operations7.deleteUpload, {
|
|
2165
2282
|
params: { uploadId: id },
|
|
2166
2283
|
headers: { "tus-resumable": "1.0.0" }
|
|
2167
2284
|
});
|
|
@@ -2222,7 +2339,7 @@ var UploadTask = class {
|
|
|
2222
2339
|
}
|
|
2223
2340
|
const api = this.c.api;
|
|
2224
2341
|
if (!this.uploadIdValue) {
|
|
2225
|
-
const res = await api.call(
|
|
2342
|
+
const res = await api.call(Operations7.createUpload, {
|
|
2226
2343
|
headers: {
|
|
2227
2344
|
"tus-resumable": "1.0.0",
|
|
2228
2345
|
"upload-length": String(total),
|
|
@@ -2250,7 +2367,7 @@ var UploadTask = class {
|
|
|
2250
2367
|
const chunk = await this.source.read(this.offset, end);
|
|
2251
2368
|
let res;
|
|
2252
2369
|
try {
|
|
2253
|
-
res = await api.call(
|
|
2370
|
+
res = await api.call(Operations7.appendUpload, {
|
|
2254
2371
|
params: { uploadId: this.uploadIdValue },
|
|
2255
2372
|
bytes: chunk,
|
|
2256
2373
|
contentType: "application/offset+octet-stream",
|
|
@@ -2278,7 +2395,7 @@ var UploadTask = class {
|
|
|
2278
2395
|
uploadId: this.uploadIdValue,
|
|
2279
2396
|
name: this.o.asset?.name ?? this.source.name
|
|
2280
2397
|
};
|
|
2281
|
-
asset = await api.json(
|
|
2398
|
+
asset = await api.json(Operations7.createAsset, { body: req });
|
|
2282
2399
|
}
|
|
2283
2400
|
this.set("done");
|
|
2284
2401
|
if (!this.finished) {
|
|
@@ -2292,7 +2409,7 @@ var UploadTask = class {
|
|
|
2292
2409
|
this.progress.close();
|
|
2293
2410
|
}
|
|
2294
2411
|
async headOffset() {
|
|
2295
|
-
const res = await this.c.api.call(
|
|
2412
|
+
const res = await this.c.api.call(Operations7.getUploadOffset, {
|
|
2296
2413
|
params: { uploadId: this.uploadIdValue },
|
|
2297
2414
|
headers: { "tus-resumable": "1.0.0" }
|
|
2298
2415
|
});
|
|
@@ -2326,7 +2443,7 @@ var ContentRepository = class {
|
|
|
2326
2443
|
/** One page of assets (first pages cache-backed). */
|
|
2327
2444
|
list(query = {}, cursor) {
|
|
2328
2445
|
const q = { type: query.type, tag: query.tag, q: query.q, status: query.status };
|
|
2329
|
-
const read = () => readPage(this.c.api,
|
|
2446
|
+
const read = () => readPage(this.c.api, Operations8.listAssets, {
|
|
2330
2447
|
query: q,
|
|
2331
2448
|
cursor,
|
|
2332
2449
|
limit: query.limit
|
|
@@ -2343,7 +2460,26 @@ var ContentRepository = class {
|
|
|
2343
2460
|
);
|
|
2344
2461
|
}
|
|
2345
2462
|
get(assetId) {
|
|
2346
|
-
return this.c.api.json(
|
|
2463
|
+
return this.c.api.json(Operations8.getAsset, { params: { assetId } });
|
|
2464
|
+
}
|
|
2465
|
+
/**
|
|
2466
|
+
* The first asset whose `name` equals `name` exactly (case-sensitive), or `null` when there is none.
|
|
2467
|
+
*
|
|
2468
|
+
* Asks the server with `q` = `name` (a case-insensitive substring match), keeps exact matches only and reads more
|
|
2469
|
+
* pages while needed; `type` / `tag` / `status` narrow it as in `list`. Several assets with the name: the first in
|
|
2470
|
+
* the server's order wins. Offline, the first page comes from the cache as in `list`. Added in 1.2.0.
|
|
2471
|
+
*/
|
|
2472
|
+
async findAssetByName(name, filter = {}) {
|
|
2473
|
+
if (!name) throw new RangeError("findAssetByName: empty name");
|
|
2474
|
+
const query = { ...filter, q: name, limit: 100 };
|
|
2475
|
+
let cursor;
|
|
2476
|
+
do {
|
|
2477
|
+
const page = await this.list(query, cursor);
|
|
2478
|
+
const hit = page.items.find((a) => a.name === name);
|
|
2479
|
+
if (hit) return hit;
|
|
2480
|
+
cursor = page.nextCursor ?? void 0;
|
|
2481
|
+
} while (cursor);
|
|
2482
|
+
return null;
|
|
2347
2483
|
}
|
|
2348
2484
|
/** Starts a resumable upload creating an asset (await `task.done`). */
|
|
2349
2485
|
upload(source, o = {}) {
|
|
@@ -2382,7 +2518,7 @@ var ContentRepository = class {
|
|
|
2382
2518
|
/** Uploads [source] and runs an import job; returns the finished job (rejects when it failed). */
|
|
2383
2519
|
async importFile(source, format, o = {}) {
|
|
2384
2520
|
const up = await this.uploadFor("import", source).done;
|
|
2385
|
-
const job = await this.c.api.json(
|
|
2521
|
+
const job = await this.c.api.json(Operations8.startImport, {
|
|
2386
2522
|
body: {
|
|
2387
2523
|
uploadId: up.uploadId,
|
|
2388
2524
|
format,
|
|
@@ -2418,13 +2554,13 @@ var ContentRepository = class {
|
|
|
2418
2554
|
if (Date.now() > deadline)
|
|
2419
2555
|
throw new RequestTimeoutError(`job ${j.id} not finished in time`, o.timeoutMs);
|
|
2420
2556
|
await new Promise((r) => setTimeout(r, o.pollMs ?? 500));
|
|
2421
|
-
j = await this.c.api.json(
|
|
2557
|
+
j = await this.c.api.json(Operations8.getJob, { params: { jobId: j.id } });
|
|
2422
2558
|
}
|
|
2423
2559
|
}
|
|
2424
2560
|
/** Merge-patches an asset (ETag read first when not given). */
|
|
2425
2561
|
async patch(assetId, patch, ifMatch) {
|
|
2426
2562
|
const etag = ifMatch ?? `"r${(await this.get(assetId)).revision}"`;
|
|
2427
|
-
return this.c.api.json(
|
|
2563
|
+
return this.c.api.json(Operations8.patchAsset, {
|
|
2428
2564
|
params: { assetId },
|
|
2429
2565
|
body: patch,
|
|
2430
2566
|
headers: { "if-match": etag }
|
|
@@ -2433,23 +2569,23 @@ var ContentRepository = class {
|
|
|
2433
2569
|
/** Deletes an asset (409 while referenced unless [force]). */
|
|
2434
2570
|
async delete(assetId, o = {}) {
|
|
2435
2571
|
const etag = o.ifMatch ?? `"r${(await this.get(assetId)).revision}"`;
|
|
2436
|
-
await this.c.api.call(
|
|
2572
|
+
await this.c.api.call(Operations8.deleteAsset, {
|
|
2437
2573
|
params: { assetId },
|
|
2438
2574
|
query: o.force ? { force: "true" } : {},
|
|
2439
2575
|
headers: { "if-match": etag }
|
|
2440
2576
|
});
|
|
2441
2577
|
}
|
|
2442
2578
|
async thumbnail(assetId, size) {
|
|
2443
|
-
return (await this.c.api.call(
|
|
2579
|
+
return (await this.c.api.call(Operations8.getAssetThumbnail, {
|
|
2444
2580
|
params: { assetId },
|
|
2445
2581
|
query: { size: size?.toString() }
|
|
2446
2582
|
})).body;
|
|
2447
2583
|
}
|
|
2448
2584
|
async download(assetId) {
|
|
2449
|
-
return (await this.c.api.call(
|
|
2585
|
+
return (await this.c.api.call(Operations8.downloadAsset, { params: { assetId }, timeoutMs: 18e5 })).body;
|
|
2450
2586
|
}
|
|
2451
2587
|
storage() {
|
|
2452
|
-
return this.c.api.json(
|
|
2588
|
+
return this.c.api.json(Operations8.getStorageStats);
|
|
2453
2589
|
}
|
|
2454
2590
|
/** Changes of the content store. */
|
|
2455
2591
|
changes(fn) {
|
|
@@ -2464,59 +2600,59 @@ var ContentRepository = class {
|
|
|
2464
2600
|
});
|
|
2465
2601
|
}
|
|
2466
2602
|
listShows(o = {}) {
|
|
2467
|
-
return readPage(this.c.api,
|
|
2603
|
+
return readPage(this.c.api, Operations8.listShows, {
|
|
2468
2604
|
query: { q: o.q },
|
|
2469
2605
|
cursor: o.cursor,
|
|
2470
2606
|
limit: o.limit
|
|
2471
2607
|
});
|
|
2472
2608
|
}
|
|
2473
2609
|
async getShow(showId) {
|
|
2474
|
-
const res = await this.c.api.call(
|
|
2610
|
+
const res = await this.c.api.call(Operations8.getShow, { params: { showId } });
|
|
2475
2611
|
return {
|
|
2476
|
-
value: ApiCaller.decodeBody(
|
|
2612
|
+
value: ApiCaller.decodeBody(Operations8.getShow, res),
|
|
2477
2613
|
etag: res.headers.etag
|
|
2478
2614
|
};
|
|
2479
2615
|
}
|
|
2480
2616
|
async createShow(body) {
|
|
2481
|
-
const res = await this.c.api.call(
|
|
2617
|
+
const res = await this.c.api.call(Operations8.createShow, { body });
|
|
2482
2618
|
return {
|
|
2483
|
-
value: ApiCaller.decodeBody(
|
|
2619
|
+
value: ApiCaller.decodeBody(Operations8.createShow, res),
|
|
2484
2620
|
etag: res.headers.etag
|
|
2485
2621
|
};
|
|
2486
2622
|
}
|
|
2487
2623
|
/** Replaces a show (`ifMatch`; without: create with If-None-Match: *). Queued in the outbox while offline. */
|
|
2488
2624
|
async saveShow(showId, body, ifMatch) {
|
|
2489
|
-
const res = await this.c.idempotentWrite(
|
|
2625
|
+
const res = await this.c.idempotentWrite(Operations8.putShow, {
|
|
2490
2626
|
params: { showId },
|
|
2491
2627
|
body,
|
|
2492
2628
|
headers: ifMatch ? { "if-match": ifMatch } : { "if-none-match": "*" }
|
|
2493
2629
|
});
|
|
2494
2630
|
return {
|
|
2495
|
-
value: ApiCaller.decodeBody(
|
|
2631
|
+
value: ApiCaller.decodeBody(Operations8.putShow, res),
|
|
2496
2632
|
etag: res.headers.etag
|
|
2497
2633
|
};
|
|
2498
2634
|
}
|
|
2499
2635
|
async patchShow(showId, patch, ifMatch) {
|
|
2500
2636
|
const etag = ifMatch ?? (await this.getShow(showId)).etag;
|
|
2501
|
-
const res = await this.c.api.call(
|
|
2637
|
+
const res = await this.c.api.call(Operations8.patchShow, {
|
|
2502
2638
|
params: { showId },
|
|
2503
2639
|
body: patch,
|
|
2504
2640
|
headers: { "if-match": etag }
|
|
2505
2641
|
});
|
|
2506
2642
|
return {
|
|
2507
|
-
value: ApiCaller.decodeBody(
|
|
2643
|
+
value: ApiCaller.decodeBody(Operations8.patchShow, res),
|
|
2508
2644
|
etag: res.headers.etag
|
|
2509
2645
|
};
|
|
2510
2646
|
}
|
|
2511
2647
|
async deleteShow(showId, ifMatch) {
|
|
2512
|
-
await this.c.api.call(
|
|
2648
|
+
await this.c.api.call(Operations8.deleteShow, {
|
|
2513
2649
|
params: { showId },
|
|
2514
2650
|
headers: { "if-match": ifMatch }
|
|
2515
2651
|
});
|
|
2516
2652
|
}
|
|
2517
2653
|
/** Exports a show as `.dome` bytes. */
|
|
2518
2654
|
async exportShow(showId, embedAssets = false) {
|
|
2519
|
-
return (await this.c.api.call(
|
|
2655
|
+
return (await this.c.api.call(Operations8.exportShow, {
|
|
2520
2656
|
params: { showId },
|
|
2521
2657
|
query: embedAssets ? { embedAssets: "true" } : {},
|
|
2522
2658
|
timeoutMs: 18e5
|
|
@@ -2524,7 +2660,7 @@ var ContentRepository = class {
|
|
|
2524
2660
|
}
|
|
2525
2661
|
/** tus capabilities. */
|
|
2526
2662
|
async uploadCapabilities() {
|
|
2527
|
-
const res = await this.c.api.call(
|
|
2663
|
+
const res = await this.c.api.call(Operations8.getUploadCapabilities);
|
|
2528
2664
|
const list = (h) => (res.headers[h] ?? "").split(",").map((x) => x.trim()).filter(Boolean);
|
|
2529
2665
|
const max = Number.parseInt(res.headers["tus-max-size"] ?? "", 10);
|
|
2530
2666
|
return {
|
|
@@ -2535,7 +2671,7 @@ var ContentRepository = class {
|
|
|
2535
2671
|
};
|
|
2536
2672
|
}
|
|
2537
2673
|
uploadStatus(uploadId) {
|
|
2538
|
-
return this.c.api.json(
|
|
2674
|
+
return this.c.api.json(Operations8.getUpload, { params: { uploadId } });
|
|
2539
2675
|
}
|
|
2540
2676
|
/** Watch hook used by apps showing one asset. */
|
|
2541
2677
|
watchAsset(assetId, fn) {
|
|
@@ -2548,29 +2684,29 @@ var ShowParts = class {
|
|
|
2548
2684
|
}
|
|
2549
2685
|
c;
|
|
2550
2686
|
async etag(showId, ifMatch) {
|
|
2551
|
-
return ifMatch ?? (await this.c.api.call(
|
|
2687
|
+
return ifMatch ?? (await this.c.api.call(Operations8.getShow, { params: { showId } })).headers.etag;
|
|
2552
2688
|
}
|
|
2553
2689
|
get(part, showId, itemId) {
|
|
2554
|
-
return this.c.api.json(
|
|
2690
|
+
return this.c.api.json(Operations8[`get${part}`], { params: { showId, itemId } });
|
|
2555
2691
|
}
|
|
2556
2692
|
async put(part, showId, item, ifMatch) {
|
|
2557
|
-
return this.c.api.json(
|
|
2693
|
+
return this.c.api.json(Operations8[`put${part}`], {
|
|
2558
2694
|
params: { showId, itemId: item.id },
|
|
2559
2695
|
body: item,
|
|
2560
2696
|
headers: { "if-match": await this.etag(showId, ifMatch) }
|
|
2561
2697
|
});
|
|
2562
2698
|
}
|
|
2563
2699
|
async delete(part, showId, itemId, ifMatch) {
|
|
2564
|
-
await this.c.api.call(
|
|
2700
|
+
await this.c.api.call(Operations8[`delete${part}`], {
|
|
2565
2701
|
params: { showId, itemId },
|
|
2566
2702
|
headers: { "if-match": await this.etag(showId, ifMatch) }
|
|
2567
2703
|
});
|
|
2568
2704
|
}
|
|
2569
2705
|
matrix(showId) {
|
|
2570
|
-
return this.c.api.json(
|
|
2706
|
+
return this.c.api.json(Operations8.getMatrix, { params: { showId } });
|
|
2571
2707
|
}
|
|
2572
2708
|
async putMatrix(showId, matrix, ifMatch) {
|
|
2573
|
-
return this.c.api.json(
|
|
2709
|
+
return this.c.api.json(Operations8.putMatrix, {
|
|
2574
2710
|
params: { showId },
|
|
2575
2711
|
body: matrix,
|
|
2576
2712
|
headers: { "if-match": await this.etag(showId, ifMatch) }
|
|
@@ -2582,7 +2718,7 @@ var ShowParts = class {
|
|
|
2582
2718
|
import {
|
|
2583
2719
|
DomeTopics as DomeTopics6,
|
|
2584
2720
|
EventKinds as EventKinds3,
|
|
2585
|
-
Operations as
|
|
2721
|
+
Operations as Operations9
|
|
2586
2722
|
} from "@freedome/protocol";
|
|
2587
2723
|
var EngineRepository = class {
|
|
2588
2724
|
constructor(c) {
|
|
@@ -2591,23 +2727,23 @@ var EngineRepository = class {
|
|
|
2591
2727
|
c;
|
|
2592
2728
|
/** Every engine (visual, audio, …; `name@node` on multi-node installations). */
|
|
2593
2729
|
engines() {
|
|
2594
|
-
return readAllPages(this.c.api,
|
|
2730
|
+
return readAllPages(this.c.api, Operations9.listEngines);
|
|
2595
2731
|
}
|
|
2596
2732
|
/** Displays of a venue. */
|
|
2597
2733
|
outputs(venueId = "default") {
|
|
2598
|
-
return readAllPages(this.c.api,
|
|
2734
|
+
return readAllPages(this.c.api, Operations9.listDisplays, {
|
|
2599
2735
|
params: { venueId }
|
|
2600
2736
|
});
|
|
2601
2737
|
}
|
|
2602
2738
|
/** One display. */
|
|
2603
2739
|
display(displayId, venueId = "default") {
|
|
2604
|
-
return this.c.api.json(
|
|
2740
|
+
return this.c.api.json(Operations9.getDisplay, {
|
|
2605
2741
|
params: { venueId, displayId }
|
|
2606
2742
|
});
|
|
2607
2743
|
}
|
|
2608
2744
|
/** Shows a test pattern on a display. */
|
|
2609
2745
|
showTestPattern(displayId, pattern, venueId = "default") {
|
|
2610
|
-
return this.c.api.json(
|
|
2746
|
+
return this.c.api.json(Operations9.setTestPattern, {
|
|
2611
2747
|
params: { venueId, displayId },
|
|
2612
2748
|
body: pattern,
|
|
2613
2749
|
preferRealtime: true
|
|
@@ -2623,21 +2759,21 @@ var EngineRepository = class {
|
|
|
2623
2759
|
}
|
|
2624
2760
|
/** Flashes the id overlay. */
|
|
2625
2761
|
async identify(displayId, durationMs, venueId = "default") {
|
|
2626
|
-
await this.c.api.call(
|
|
2762
|
+
await this.c.api.call(Operations9.identifyDisplay, {
|
|
2627
2763
|
params: { venueId, displayId },
|
|
2628
2764
|
body: durationMs === void 0 ? {} : { durationS: durationMs / 1e3 }
|
|
2629
2765
|
});
|
|
2630
2766
|
}
|
|
2631
2767
|
/** Power / shutter (what `state.capabilities` lists). */
|
|
2632
2768
|
setPower(displayId, request, venueId = "default") {
|
|
2633
|
-
return this.c.api.json(
|
|
2769
|
+
return this.c.api.json(Operations9.setDisplayPower, {
|
|
2634
2770
|
params: { venueId, displayId },
|
|
2635
2771
|
body: request
|
|
2636
2772
|
});
|
|
2637
2773
|
}
|
|
2638
2774
|
/** Status of engine [name]. */
|
|
2639
2775
|
async engineStatus(name = "visual") {
|
|
2640
|
-
const s = await this.c.api.json(
|
|
2776
|
+
const s = await this.c.api.json(Operations9.getEngine, { params: { name } });
|
|
2641
2777
|
if (name === "visual") this.c.onEngineHealth?.(String(s.status));
|
|
2642
2778
|
return s;
|
|
2643
2779
|
}
|
|
@@ -2660,7 +2796,7 @@ var EngineRepository = class {
|
|
|
2660
2796
|
};
|
|
2661
2797
|
|
|
2662
2798
|
// src/repositories/gateways.ts
|
|
2663
|
-
import { Operations as
|
|
2799
|
+
import { Operations as Operations10 } from "@freedome/protocol";
|
|
2664
2800
|
var GatewaysRepository = class {
|
|
2665
2801
|
constructor(c) {
|
|
2666
2802
|
this.c = c;
|
|
@@ -2668,13 +2804,13 @@ var GatewaysRepository = class {
|
|
|
2668
2804
|
c;
|
|
2669
2805
|
/** Every gateway. */
|
|
2670
2806
|
list() {
|
|
2671
|
-
return readAllPages(this.c.api,
|
|
2807
|
+
return readAllPages(this.c.api, Operations10.listGateways, {});
|
|
2672
2808
|
}
|
|
2673
2809
|
/** One gateway with its ETag. */
|
|
2674
2810
|
async get(gatewayId) {
|
|
2675
|
-
const res = await this.c.api.call(
|
|
2811
|
+
const res = await this.c.api.call(Operations10.getGateway, { params: { gatewayId } });
|
|
2676
2812
|
return {
|
|
2677
|
-
value: ApiCaller.decodeBody(
|
|
2813
|
+
value: ApiCaller.decodeBody(Operations10.getGateway, res),
|
|
2678
2814
|
etag: res.headers.etag
|
|
2679
2815
|
};
|
|
2680
2816
|
}
|
|
@@ -2684,24 +2820,24 @@ var GatewaysRepository = class {
|
|
|
2684
2820
|
*/
|
|
2685
2821
|
async patch(gatewayId, patch, o = {}) {
|
|
2686
2822
|
const etag = o.ifMatch ?? (await this.get(gatewayId)).etag;
|
|
2687
|
-
const res = await this.c.api.call(
|
|
2823
|
+
const res = await this.c.api.call(Operations10.patchGateway, {
|
|
2688
2824
|
params: { gatewayId },
|
|
2689
2825
|
body: patch,
|
|
2690
2826
|
headers: { "if-match": etag }
|
|
2691
2827
|
});
|
|
2692
2828
|
return {
|
|
2693
|
-
value: ApiCaller.decodeBody(
|
|
2829
|
+
value: ApiCaller.decodeBody(Operations10.patchGateway, res),
|
|
2694
2830
|
etag: res.headers.etag
|
|
2695
2831
|
};
|
|
2696
2832
|
}
|
|
2697
2833
|
/** Runs the gateway's connectivity test. */
|
|
2698
2834
|
test(gatewayId) {
|
|
2699
|
-
return this.c.api.json(
|
|
2835
|
+
return this.c.api.json(Operations10.testGateway, { params: { gatewayId } });
|
|
2700
2836
|
}
|
|
2701
2837
|
};
|
|
2702
2838
|
|
|
2703
2839
|
// src/repositories/osc.ts
|
|
2704
|
-
import { DomeTopics as DomeTopics7, Operations as
|
|
2840
|
+
import { DomeTopics as DomeTopics7, Operations as Operations11 } from "@freedome/protocol";
|
|
2705
2841
|
function oscArg(a) {
|
|
2706
2842
|
if (a !== null && typeof a === "object" && "type" in a && !(a instanceof Uint8Array) && !(a instanceof Date))
|
|
2707
2843
|
return a;
|
|
@@ -2728,7 +2864,7 @@ var OscRepository = class {
|
|
|
2728
2864
|
async send(address, args, target) {
|
|
2729
2865
|
if (!address.startsWith("/")) throw new TypeError("OSC address must start with /");
|
|
2730
2866
|
const body = { target, address, args: args.map(oscArg) };
|
|
2731
|
-
await this.c.api.call(
|
|
2867
|
+
await this.c.api.call(Operations11.sendOsc, { body, preferRealtime: true });
|
|
2732
2868
|
}
|
|
2733
2869
|
/** OSC traffic of gateways (`gateway.message` events). */
|
|
2734
2870
|
messages(fn, gatewayId = "+") {
|
|
@@ -2747,7 +2883,7 @@ var OscRepository = class {
|
|
|
2747
2883
|
import {
|
|
2748
2884
|
DomeTopics as DomeTopics8,
|
|
2749
2885
|
EventKinds as EventKinds4,
|
|
2750
|
-
Operations as
|
|
2886
|
+
Operations as Operations12,
|
|
2751
2887
|
jsonMergePatch as jsonMergePatch3,
|
|
2752
2888
|
rfc3339Millis as rfc3339Millis3
|
|
2753
2889
|
} from "@freedome/protocol";
|
|
@@ -2872,7 +3008,7 @@ var PlayerHandle = class {
|
|
|
2872
3008
|
const snap = await this.c.cachedRead(
|
|
2873
3009
|
`players/${this.venueId}/${this.playerId}`,
|
|
2874
3010
|
async () => {
|
|
2875
|
-
const s = await this.c.api.json(
|
|
3011
|
+
const s = await this.c.api.json(Operations12.getPlayer, { params: this.params });
|
|
2876
3012
|
return [{ state: s }, s];
|
|
2877
3013
|
},
|
|
2878
3014
|
(json, asOf) => ({ state: json, stale: true, asOf })
|
|
@@ -2904,7 +3040,7 @@ var PlayerHandle = class {
|
|
|
2904
3040
|
/** Plays [target] (optionally from [positionMs], at server time [at] for multi-node sync). */
|
|
2905
3041
|
async play(target, o = {}) {
|
|
2906
3042
|
if (target.kind === "app") {
|
|
2907
|
-
await this.c.api.call(
|
|
3043
|
+
await this.c.api.call(Operations12.publishAppPayload, {
|
|
2908
3044
|
params: { app: target.app },
|
|
2909
3045
|
body: target.payload,
|
|
2910
3046
|
preferRealtime: true
|
|
@@ -2923,39 +3059,39 @@ var PlayerHandle = class {
|
|
|
2923
3059
|
} else if (target.kind === "asset") req.assetId = target.assetId;
|
|
2924
3060
|
if (o.positionMs !== void 0) req.position = o.positionMs / 1e3;
|
|
2925
3061
|
if (o.at) req.at = rfc3339Millis3(o.at);
|
|
2926
|
-
return this.command(
|
|
3062
|
+
return this.command(Operations12.play, req);
|
|
2927
3063
|
}
|
|
2928
3064
|
pause() {
|
|
2929
|
-
return this.command(
|
|
3065
|
+
return this.command(Operations12.pause);
|
|
2930
3066
|
}
|
|
2931
3067
|
resume() {
|
|
2932
|
-
return this.command(
|
|
3068
|
+
return this.command(Operations12.resume);
|
|
2933
3069
|
}
|
|
2934
3070
|
stop() {
|
|
2935
|
-
return this.command(
|
|
3071
|
+
return this.command(Operations12.stop);
|
|
2936
3072
|
}
|
|
2937
3073
|
next() {
|
|
2938
|
-
return this.command(
|
|
3074
|
+
return this.command(Operations12.next);
|
|
2939
3075
|
}
|
|
2940
3076
|
previous() {
|
|
2941
|
-
return this.command(
|
|
3077
|
+
return this.command(Operations12.previous);
|
|
2942
3078
|
}
|
|
2943
3079
|
/** Seeks (coalesced while scrubbing). */
|
|
2944
3080
|
seek(positionMs) {
|
|
2945
3081
|
return this.fader(
|
|
2946
3082
|
"seek",
|
|
2947
3083
|
{ position: positionMs / 1e3 },
|
|
2948
|
-
(b) => this.command(
|
|
3084
|
+
(b) => this.command(Operations12.seek, b)
|
|
2949
3085
|
);
|
|
2950
3086
|
}
|
|
2951
3087
|
seekToMarker(marker) {
|
|
2952
|
-
return this.command(
|
|
3088
|
+
return this.command(Operations12.seek, { marker });
|
|
2953
3089
|
}
|
|
2954
3090
|
patch(body) {
|
|
2955
3091
|
return this.fader(
|
|
2956
3092
|
`patch:${Object.keys(body).join(",")}`,
|
|
2957
3093
|
body,
|
|
2958
|
-
(b) => this.command(
|
|
3094
|
+
(b) => this.command(Operations12.patchPlayer, b)
|
|
2959
3095
|
);
|
|
2960
3096
|
}
|
|
2961
3097
|
/** Player volume 0..1 (fader). */
|
|
@@ -3005,7 +3141,7 @@ var PlaybackRepository = class {
|
|
|
3005
3141
|
return this.main.watch(fn);
|
|
3006
3142
|
}
|
|
3007
3143
|
list(venueId = "default") {
|
|
3008
|
-
return readAllPages(this.c.api,
|
|
3144
|
+
return readAllPages(this.c.api, Operations12.listPlayers, { params: { venueId } });
|
|
3009
3145
|
}
|
|
3010
3146
|
play(target, o = {}) {
|
|
3011
3147
|
return this.main.play(target, o);
|
|
@@ -3030,7 +3166,7 @@ var PlaybackRepository = class {
|
|
|
3030
3166
|
}
|
|
3031
3167
|
/** Fires cue [cueId] of the active show (or of [showId]). */
|
|
3032
3168
|
async cue(cueId, o = {}) {
|
|
3033
|
-
await this.c.api.call(
|
|
3169
|
+
await this.c.api.call(Operations12.fireCue, {
|
|
3034
3170
|
params: { venueId: o.venueId ?? "default", cueId },
|
|
3035
3171
|
body: o.showId ? { showId: o.showId } : {},
|
|
3036
3172
|
preferRealtime: true
|
|
@@ -3038,21 +3174,21 @@ var PlaybackRepository = class {
|
|
|
3038
3174
|
}
|
|
3039
3175
|
/** Loads a show onto the venue. */
|
|
3040
3176
|
async setActiveShow(showId, o = {}) {
|
|
3041
|
-
await this.c.api.call(
|
|
3177
|
+
await this.c.api.call(Operations12.setActiveShow, {
|
|
3042
3178
|
params: { venueId: o.venueId ?? "default" },
|
|
3043
3179
|
body: { showId, autoplay: o.autoplay ?? false }
|
|
3044
3180
|
});
|
|
3045
3181
|
}
|
|
3046
3182
|
activeShow(venueId = "default") {
|
|
3047
|
-
return this.c.api.json(
|
|
3183
|
+
return this.c.api.json(Operations12.getActiveShow, { params: { venueId } });
|
|
3048
3184
|
}
|
|
3049
3185
|
parameters(venueId = "default") {
|
|
3050
|
-
return readAllPages(this.c.api,
|
|
3186
|
+
return readAllPages(this.c.api, Operations12.listParameters, {
|
|
3051
3187
|
params: { venueId }
|
|
3052
3188
|
});
|
|
3053
3189
|
}
|
|
3054
3190
|
parameter(path, venueId = "default") {
|
|
3055
|
-
return this.c.api.json(
|
|
3191
|
+
return this.c.api.json(Operations12.getParameter, { params: { venueId, path } });
|
|
3056
3192
|
}
|
|
3057
3193
|
/** Sets a parameter (fader; coalesced). */
|
|
3058
3194
|
async setParameter(path, value, venueId = "default") {
|
|
@@ -3060,7 +3196,7 @@ var PlaybackRepository = class {
|
|
|
3060
3196
|
let f = this.outputFaders.get(k);
|
|
3061
3197
|
if (!f) {
|
|
3062
3198
|
f = new Fader(async (b) => {
|
|
3063
|
-
await this.c.api.call(
|
|
3199
|
+
await this.c.api.call(Operations12.setParameter, {
|
|
3064
3200
|
params: { venueId, path },
|
|
3065
3201
|
body: b,
|
|
3066
3202
|
preferRealtime: true
|
|
@@ -3073,14 +3209,14 @@ var PlaybackRepository = class {
|
|
|
3073
3209
|
}
|
|
3074
3210
|
/** Removes every payload an app published. */
|
|
3075
3211
|
async clearAppPayloads(app) {
|
|
3076
|
-
await this.c.api.call(
|
|
3212
|
+
await this.c.api.call(Operations12.clearAppPayloads, { params: { app }, preferRealtime: true });
|
|
3077
3213
|
}
|
|
3078
3214
|
/** Master output of a venue. */
|
|
3079
3215
|
readOutput(venueId = "default") {
|
|
3080
3216
|
return this.c.cachedRead(
|
|
3081
3217
|
`output/${venueId}`,
|
|
3082
3218
|
async () => {
|
|
3083
|
-
const o = await this.c.api.json(
|
|
3219
|
+
const o = await this.c.api.json(Operations12.getOutput, { params: { venueId } });
|
|
3084
3220
|
return [o, o];
|
|
3085
3221
|
},
|
|
3086
3222
|
(json) => json
|
|
@@ -3109,7 +3245,7 @@ var PlaybackRepository = class {
|
|
|
3109
3245
|
let f = this.outputFaders.get(k);
|
|
3110
3246
|
if (!f) {
|
|
3111
3247
|
f = new Fader(
|
|
3112
|
-
(b) => this.c.api.json(
|
|
3248
|
+
(b) => this.c.api.json(Operations12.patchOutput, {
|
|
3113
3249
|
params: { venueId },
|
|
3114
3250
|
body: b,
|
|
3115
3251
|
preferRealtime: true
|
|
@@ -3143,7 +3279,7 @@ var PlaybackRepository = class {
|
|
|
3143
3279
|
import {
|
|
3144
3280
|
DomeTopics as DomeTopics9,
|
|
3145
3281
|
EventKinds as EventKinds5,
|
|
3146
|
-
Operations as
|
|
3282
|
+
Operations as Operations13
|
|
3147
3283
|
} from "@freedome/protocol";
|
|
3148
3284
|
var CALIBRATION_FILE_TYPES = {
|
|
3149
3285
|
warp: "application/vnd.nativemind.freedome.fdmesh",
|
|
@@ -3163,7 +3299,7 @@ var VenuesRepository = class {
|
|
|
3163
3299
|
return this.c.cachedRead(
|
|
3164
3300
|
"venues",
|
|
3165
3301
|
async () => {
|
|
3166
|
-
const l = await readAllPages(this.api,
|
|
3302
|
+
const l = await readAllPages(this.api, Operations13.listVenues);
|
|
3167
3303
|
return [{ value: l, etag: void 0 }, l];
|
|
3168
3304
|
},
|
|
3169
3305
|
(json, asOf) => ({ value: json, etag: void 0, stale: true, asOf })
|
|
@@ -3171,8 +3307,8 @@ var VenuesRepository = class {
|
|
|
3171
3307
|
}
|
|
3172
3308
|
/** One venue with its ETag (`default` = the active venue). */
|
|
3173
3309
|
async get(venueId = "default") {
|
|
3174
|
-
const res = await this.api.call(
|
|
3175
|
-
return { value: ApiCaller.decodeBody(
|
|
3310
|
+
const res = await this.api.call(Operations13.getVenue, { params: { venueId } });
|
|
3311
|
+
return { value: ApiCaller.decodeBody(Operations13.getVenue, res), etag: res.headers.etag };
|
|
3176
3312
|
}
|
|
3177
3313
|
/** The venue the server runs now. */
|
|
3178
3314
|
async current() {
|
|
@@ -3180,22 +3316,22 @@ var VenuesRepository = class {
|
|
|
3180
3316
|
}
|
|
3181
3317
|
/** Creates a venue (`POST /venues`; id = `meta.id`). */
|
|
3182
3318
|
async create(body) {
|
|
3183
|
-
const res = await this.api.call(
|
|
3319
|
+
const res = await this.api.call(Operations13.createVenue, { body });
|
|
3184
3320
|
return {
|
|
3185
|
-
value: ApiCaller.decodeBody(
|
|
3321
|
+
value: ApiCaller.decodeBody(Operations13.createVenue, res),
|
|
3186
3322
|
etag: res.headers.etag
|
|
3187
3323
|
};
|
|
3188
3324
|
}
|
|
3189
3325
|
/** Replaces a venue (`ifMatch` = ETag; without it: create with If-None-Match: *). 409 / 412 → ConflictError with `latest`. */
|
|
3190
3326
|
async save(venueId, body, ifMatch) {
|
|
3191
3327
|
try {
|
|
3192
|
-
const res = await this.api.call(
|
|
3328
|
+
const res = await this.api.call(Operations13.putVenue, {
|
|
3193
3329
|
params: { venueId },
|
|
3194
3330
|
body,
|
|
3195
3331
|
headers: ifMatch ? { "if-match": ifMatch } : { "if-none-match": "*" }
|
|
3196
3332
|
});
|
|
3197
3333
|
return {
|
|
3198
|
-
value: ApiCaller.decodeBody(
|
|
3334
|
+
value: ApiCaller.decodeBody(Operations13.putVenue, res),
|
|
3199
3335
|
etag: res.headers.etag
|
|
3200
3336
|
};
|
|
3201
3337
|
} catch (e) {
|
|
@@ -3216,13 +3352,13 @@ var VenuesRepository = class {
|
|
|
3216
3352
|
/** Merge-patches a venue (reads the ETag when not given). */
|
|
3217
3353
|
async patch(venueId, patch, ifMatch) {
|
|
3218
3354
|
const etag = ifMatch ?? (await this.get(venueId)).etag;
|
|
3219
|
-
const res = await this.api.call(
|
|
3355
|
+
const res = await this.api.call(Operations13.patchVenue, {
|
|
3220
3356
|
params: { venueId },
|
|
3221
3357
|
body: patch,
|
|
3222
3358
|
headers: { "if-match": etag }
|
|
3223
3359
|
});
|
|
3224
3360
|
return {
|
|
3225
|
-
value: ApiCaller.decodeBody(
|
|
3361
|
+
value: ApiCaller.decodeBody(Operations13.patchVenue, res),
|
|
3226
3362
|
etag: res.headers.etag
|
|
3227
3363
|
};
|
|
3228
3364
|
}
|
|
@@ -3240,7 +3376,7 @@ var VenuesRepository = class {
|
|
|
3240
3376
|
}
|
|
3241
3377
|
/** Exports the venue as `.dome` bytes. */
|
|
3242
3378
|
async export(venueId = "default") {
|
|
3243
|
-
const res = await this.api.call(
|
|
3379
|
+
const res = await this.api.call(Operations13.exportVenue, {
|
|
3244
3380
|
params: { venueId },
|
|
3245
3381
|
headers: { accept: "application/vnd.nativemind.freedome.dome+zip, application/problem+json" },
|
|
3246
3382
|
timeoutMs: 3e5
|
|
@@ -3249,15 +3385,15 @@ var VenuesRepository = class {
|
|
|
3249
3385
|
}
|
|
3250
3386
|
/** Calibration block with the venue ETag. */
|
|
3251
3387
|
async calibration(venueId = "default") {
|
|
3252
|
-
const res = await this.api.call(
|
|
3388
|
+
const res = await this.api.call(Operations13.getCalibration, { params: { venueId } });
|
|
3253
3389
|
return {
|
|
3254
|
-
value: ApiCaller.decodeBody(
|
|
3390
|
+
value: ApiCaller.decodeBody(Operations13.getCalibration, res),
|
|
3255
3391
|
etag: res.headers.etag
|
|
3256
3392
|
};
|
|
3257
3393
|
}
|
|
3258
3394
|
/** Bytes of a calibration sidecar. */
|
|
3259
3395
|
async calibrationFile(venueId, displayId, file) {
|
|
3260
|
-
return (await this.api.call(
|
|
3396
|
+
return (await this.api.call(Operations13.getCalibrationFile, {
|
|
3261
3397
|
params: { venueId, displayId, file },
|
|
3262
3398
|
headers: { accept: "*/*" }
|
|
3263
3399
|
})).body;
|
|
@@ -3265,21 +3401,21 @@ var VenuesRepository = class {
|
|
|
3265
3401
|
/** Uploads a calibration sidecar (If-Match = venue ETag, read when not given). */
|
|
3266
3402
|
async putCalibrationFile(venueId, displayId, file, bytes, ifMatch) {
|
|
3267
3403
|
const etag = ifMatch ?? (await this.calibration(venueId)).etag;
|
|
3268
|
-
const res = await this.api.call(
|
|
3404
|
+
const res = await this.api.call(Operations13.putCalibrationFile, {
|
|
3269
3405
|
params: { venueId, displayId, file },
|
|
3270
3406
|
bytes,
|
|
3271
3407
|
contentType: CALIBRATION_FILE_TYPES[file],
|
|
3272
3408
|
headers: { "if-match": etag }
|
|
3273
3409
|
});
|
|
3274
3410
|
return {
|
|
3275
|
-
value: ApiCaller.decodeBody(
|
|
3411
|
+
value: ApiCaller.decodeBody(Operations13.putCalibrationFile, res),
|
|
3276
3412
|
etag: res.headers.etag
|
|
3277
3413
|
};
|
|
3278
3414
|
}
|
|
3279
3415
|
};
|
|
3280
3416
|
|
|
3281
3417
|
// src/client.ts
|
|
3282
|
-
var FREEDOME_CLIENT_VERSION = "1.
|
|
3418
|
+
var FREEDOME_CLIENT_VERSION = "1.2.0";
|
|
3283
3419
|
function defaultTransports() {
|
|
3284
3420
|
return { rest: (e) => new FetchTransport(e), sockets: webSocketConnector() };
|
|
3285
3421
|
}
|
|
@@ -3296,6 +3432,7 @@ var FreedomeClient = class {
|
|
|
3296
3432
|
playback;
|
|
3297
3433
|
content;
|
|
3298
3434
|
osc;
|
|
3435
|
+
assistant;
|
|
3299
3436
|
clients;
|
|
3300
3437
|
audio;
|
|
3301
3438
|
audioReactive;
|
|
@@ -3373,7 +3510,8 @@ var FreedomeClient = class {
|
|
|
3373
3510
|
() => this.channel !== void 0,
|
|
3374
3511
|
this.options.positionHz,
|
|
3375
3512
|
(s) => this.onEngineHealth(s),
|
|
3376
|
-
init.logger
|
|
3513
|
+
init.logger,
|
|
3514
|
+
() => this.contractVersion
|
|
3377
3515
|
);
|
|
3378
3516
|
this.graphql = new GraphqlClient(this.api);
|
|
3379
3517
|
this.venues = new VenuesRepository(this.ctx);
|
|
@@ -3382,6 +3520,7 @@ var FreedomeClient = class {
|
|
|
3382
3520
|
this.playback = new PlaybackRepository(this.ctx);
|
|
3383
3521
|
this.content = new ContentRepository(this.ctx);
|
|
3384
3522
|
this.osc = new OscRepository(this.ctx);
|
|
3523
|
+
this.assistant = new AssistantRepository(this.ctx);
|
|
3385
3524
|
this.clients = new ClientsRepository(this.ctx);
|
|
3386
3525
|
this.audio = new AudioRepository(this.ctx);
|
|
3387
3526
|
this.audioReactive = new AudioReactiveRepository(this.ctx);
|
|
@@ -3396,6 +3535,15 @@ var FreedomeClient = class {
|
|
|
3396
3535
|
get server() {
|
|
3397
3536
|
return this.serverInfo;
|
|
3398
3537
|
}
|
|
3538
|
+
/**
|
|
3539
|
+
* Contract version the server reports (`contractVersion` of `GET /info`); undefined before [open], or when the server
|
|
3540
|
+
* reports none or an unreadable one. This is how an app tells what a server offers: a 1.0 server has no audio control
|
|
3541
|
+
* (`ProtocolVersions.audioControl`, `AudioRepository.supportsAudioControl`).
|
|
3542
|
+
*/
|
|
3543
|
+
get contractVersion() {
|
|
3544
|
+
const v = this.serverInfo?.contractVersion;
|
|
3545
|
+
return typeof v === "string" ? SemVer2.tryParse(v) ?? void 0 : void 0;
|
|
3546
|
+
}
|
|
3399
3547
|
get state() {
|
|
3400
3548
|
return this.stateValue;
|
|
3401
3549
|
}
|
|
@@ -3478,7 +3626,7 @@ var FreedomeClient = class {
|
|
|
3478
3626
|
this.set("negotiating");
|
|
3479
3627
|
let info;
|
|
3480
3628
|
try {
|
|
3481
|
-
info = await this.api.json(
|
|
3629
|
+
info = await this.api.json(Operations14.getInfo, { authenticated: false });
|
|
3482
3630
|
} catch (e) {
|
|
3483
3631
|
if (e instanceof NetworkError) {
|
|
3484
3632
|
this.set("offline", "server not reachable");
|
|
@@ -3492,17 +3640,17 @@ var FreedomeClient = class {
|
|
|
3492
3640
|
throw new IncompatibleServerError(
|
|
3493
3641
|
`no Freedome API v1 at ${this.endpointValue.apiBase} (${e.message})`,
|
|
3494
3642
|
[],
|
|
3495
|
-
|
|
3643
|
+
ProtocolVersions2.apiMajors
|
|
3496
3644
|
);
|
|
3497
3645
|
}
|
|
3498
3646
|
const versions = (info.apiVersions ?? []).map(String);
|
|
3499
3647
|
const majors = versions.map((v) => Number.parseInt(v.replace(/^v/, ""), 10));
|
|
3500
|
-
if (!majors.some((m) =>
|
|
3648
|
+
if (!majors.some((m) => ProtocolVersions2.apiMajors.includes(m))) {
|
|
3501
3649
|
this.set("incompatible");
|
|
3502
3650
|
throw new IncompatibleServerError(
|
|
3503
|
-
`server speaks ${versions.join(", ")}, this client v${
|
|
3651
|
+
`server speaks ${versions.join(", ")}, this client v${ProtocolVersions2.apiMajors.join(", v")}`,
|
|
3504
3652
|
versions,
|
|
3505
|
-
|
|
3653
|
+
ProtocolVersions2.apiMajors
|
|
3506
3654
|
);
|
|
3507
3655
|
}
|
|
3508
3656
|
this.serverInfo = info;
|
|
@@ -3521,12 +3669,12 @@ var FreedomeClient = class {
|
|
|
3521
3669
|
return;
|
|
3522
3670
|
case "apiKey":
|
|
3523
3671
|
this.api.authorization = `Bearer ${c.key}`;
|
|
3524
|
-
this.setSession(sessionFromPrincipal(await this.api.json(
|
|
3672
|
+
this.setSession(sessionFromPrincipal(await this.api.json(Operations14.getMe)));
|
|
3525
3673
|
return;
|
|
3526
3674
|
case "password": {
|
|
3527
3675
|
const stored = await this.tokenStore.read(key);
|
|
3528
3676
|
if (stored && await this.tryStored(stored)) return;
|
|
3529
|
-
const t = await this.api.json(
|
|
3677
|
+
const t = await this.api.json(Operations14.createSession, {
|
|
3530
3678
|
body: { username: c.username, password: c.password, client },
|
|
3531
3679
|
authenticated: false
|
|
3532
3680
|
});
|
|
@@ -3542,7 +3690,7 @@ var FreedomeClient = class {
|
|
|
3542
3690
|
case "cloud": {
|
|
3543
3691
|
const stored = await this.tokenStore.read(key);
|
|
3544
3692
|
if (stored && await this.tryStored(stored)) return;
|
|
3545
|
-
const t = await this.api.json(
|
|
3693
|
+
const t = await this.api.json(Operations14.exchangeCloudToken, {
|
|
3546
3694
|
body: { subjectToken: await c.token(), client },
|
|
3547
3695
|
authenticated: false
|
|
3548
3696
|
});
|
|
@@ -3554,7 +3702,7 @@ var FreedomeClient = class {
|
|
|
3554
3702
|
async tryStored(t) {
|
|
3555
3703
|
this.api.authorization = `Bearer ${t.accessToken}`;
|
|
3556
3704
|
try {
|
|
3557
|
-
this.setSession(sessionFromPrincipal(await this.api.json(
|
|
3705
|
+
this.setSession(sessionFromPrincipal(await this.api.json(Operations14.getMe)));
|
|
3558
3706
|
return true;
|
|
3559
3707
|
} catch (e) {
|
|
3560
3708
|
if (!(e instanceof UnauthorizedError)) throw e;
|
|
@@ -3569,7 +3717,7 @@ var FreedomeClient = class {
|
|
|
3569
3717
|
this.setSession(sessionFromTokens(t, user ?? this.sessionValue.user));
|
|
3570
3718
|
}
|
|
3571
3719
|
async pair(p) {
|
|
3572
|
-
let pairing = await this.api.json(
|
|
3720
|
+
let pairing = await this.api.json(Operations14.createPairing, {
|
|
3573
3721
|
body: {
|
|
3574
3722
|
app: p.app,
|
|
3575
3723
|
deviceName: p.deviceName,
|
|
@@ -3592,7 +3740,7 @@ var FreedomeClient = class {
|
|
|
3592
3740
|
while (!["approved", "denied", "expired", "revoked"].includes(pr().status)) {
|
|
3593
3741
|
if (Date.now() > deadline) throw new UnauthorizedError("pairing was not approved in time");
|
|
3594
3742
|
await new Promise((r) => setTimeout(r, this.options.pairingPollIntervalMs));
|
|
3595
|
-
pairing = await this.api.json(
|
|
3743
|
+
pairing = await this.api.json(Operations14.getPairing, {
|
|
3596
3744
|
params: { pairingId: pr().pairingId },
|
|
3597
3745
|
authenticated: false
|
|
3598
3746
|
});
|
|
@@ -3610,7 +3758,7 @@ var FreedomeClient = class {
|
|
|
3610
3758
|
const rt = stored?.refreshToken;
|
|
3611
3759
|
if (!rt) return await this.reauthenticate();
|
|
3612
3760
|
try {
|
|
3613
|
-
const t = await this.api.json(
|
|
3761
|
+
const t = await this.api.json(Operations14.refreshSession, {
|
|
3614
3762
|
body: { refreshToken: rt },
|
|
3615
3763
|
authenticated: false
|
|
3616
3764
|
});
|
|
@@ -3648,7 +3796,7 @@ var FreedomeClient = class {
|
|
|
3648
3796
|
async logout() {
|
|
3649
3797
|
if (this.api.authorization && this.credentials.kind !== "apiKey") {
|
|
3650
3798
|
try {
|
|
3651
|
-
await this.api.call(
|
|
3799
|
+
await this.api.call(Operations14.deleteSession);
|
|
3652
3800
|
} catch (e) {
|
|
3653
3801
|
this.log("warning", "logout", e);
|
|
3654
3802
|
}
|
|
@@ -3779,9 +3927,9 @@ var FreedomeClient = class {
|
|
|
3779
3927
|
async replayOutbox() {
|
|
3780
3928
|
if (!this.outbox) return;
|
|
3781
3929
|
await this.ctx.replayOutbox(async (e) => {
|
|
3782
|
-
const op =
|
|
3930
|
+
const op = Operations14[e.operationId];
|
|
3783
3931
|
if (!op || op.method !== "PUT" && op.method !== "PATCH") return void 0;
|
|
3784
|
-
const get = Object.values(
|
|
3932
|
+
const get = Object.values(Operations14).find(
|
|
3785
3933
|
(o) => o.method === "GET" && o.path === op.path
|
|
3786
3934
|
);
|
|
3787
3935
|
if (!get) return void 0;
|
|
@@ -3802,7 +3950,7 @@ var FreedomeClient = class {
|
|
|
3802
3950
|
async seedSeq(filters) {
|
|
3803
3951
|
if (this.hub.lastSeq !== void 0) return;
|
|
3804
3952
|
try {
|
|
3805
|
-
const page = await this.api.json(
|
|
3953
|
+
const page = await this.api.json(Operations14.listEvents, {
|
|
3806
3954
|
query: { topics: filters.join(","), limit: "1" }
|
|
3807
3955
|
});
|
|
3808
3956
|
if (typeof page.lastSeq === "number") this.hub.seed(page.lastSeq);
|
|
@@ -3921,14 +4069,14 @@ var FreedomeClient = class {
|
|
|
3921
4069
|
};
|
|
3922
4070
|
|
|
3923
4071
|
// src/discovery.ts
|
|
3924
|
-
import { Operations as
|
|
4072
|
+
import { Operations as Operations15 } from "@freedome/protocol";
|
|
3925
4073
|
async function probe(endpoint, timeoutMs = 2e3) {
|
|
3926
4074
|
const t = new FetchTransport(endpoint);
|
|
3927
4075
|
try {
|
|
3928
4076
|
const res = await t.send(
|
|
3929
4077
|
{
|
|
3930
|
-
method:
|
|
3931
|
-
path:
|
|
4078
|
+
method: Operations15.getInfo.method,
|
|
4079
|
+
path: Operations15.getInfo.path,
|
|
3932
4080
|
headers: { accept: "application/json" }
|
|
3933
4081
|
},
|
|
3934
4082
|
timeoutMs
|
|
@@ -3990,10 +4138,11 @@ var CompositeDiscovery = class {
|
|
|
3990
4138
|
};
|
|
3991
4139
|
|
|
3992
4140
|
// src/index.ts
|
|
3993
|
-
import { Operations as
|
|
4141
|
+
import { Operations as Operations16, DomeTopics as DomeTopics10, EventKinds as EventKinds6, ProtocolVersions as ProtocolVersions3, SemVer as SemVer3 } from "@freedome/protocol";
|
|
3994
4142
|
var PACKAGE_NAME = "@freedome/client";
|
|
3995
4143
|
export {
|
|
3996
4144
|
ApiCaller,
|
|
4145
|
+
AssistantRepository,
|
|
3997
4146
|
AudioReactiveRepository,
|
|
3998
4147
|
AudioRepository,
|
|
3999
4148
|
BackoffPolicy,
|
|
@@ -4035,7 +4184,7 @@ export {
|
|
|
4035
4184
|
NetworkError,
|
|
4036
4185
|
NotFoundError,
|
|
4037
4186
|
OfflineError,
|
|
4038
|
-
|
|
4187
|
+
Operations16 as Operations,
|
|
4039
4188
|
OscRepository,
|
|
4040
4189
|
PACKAGE_NAME,
|
|
4041
4190
|
PairingLink,
|
|
@@ -4043,10 +4192,12 @@ export {
|
|
|
4043
4192
|
PlayTargets,
|
|
4044
4193
|
PlaybackRepository,
|
|
4045
4194
|
PlayerHandle,
|
|
4195
|
+
ProtocolVersions3 as ProtocolVersions,
|
|
4046
4196
|
QueuedForReplayError,
|
|
4047
4197
|
RateLimitedError,
|
|
4048
4198
|
RepositoryContext,
|
|
4049
4199
|
RequestTimeoutError,
|
|
4200
|
+
SemVer3 as SemVer,
|
|
4050
4201
|
ServerError,
|
|
4051
4202
|
Sha256,
|
|
4052
4203
|
ShowParts,
|