@freedome/client 1.1.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 +10 -0
- package/dist/index.cjs +187 -138
- package/dist/index.d.cts +29 -3
- package/dist/index.d.ts +29 -3
- package/dist/index.js +164 -114
- package/dist/testing.cjs +51 -3
- package/dist/testing.d.cts +5 -0
- package/dist/testing.d.ts +5 -0
- package/dist/testing.js +51 -3
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -21,6 +21,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
23
|
ApiCaller: () => ApiCaller,
|
|
24
|
+
AssistantRepository: () => AssistantRepository,
|
|
24
25
|
AudioReactiveRepository: () => AudioReactiveRepository,
|
|
25
26
|
AudioRepository: () => AudioRepository,
|
|
26
27
|
BackoffPolicy: () => BackoffPolicy,
|
|
@@ -34,11 +35,11 @@ __export(index_exports, {
|
|
|
34
35
|
ContentRepository: () => ContentRepository,
|
|
35
36
|
Credentials: () => Credentials,
|
|
36
37
|
DEFAULT_OFFLINE_POLICY: () => DEFAULT_OFFLINE_POLICY,
|
|
37
|
-
DomeTopics: () =>
|
|
38
|
+
DomeTopics: () => import_protocol22.DomeTopics,
|
|
38
39
|
Emitter: () => Emitter,
|
|
39
40
|
EngineRepository: () => EngineRepository,
|
|
40
41
|
EventHub: () => EventHub,
|
|
41
|
-
EventKinds: () =>
|
|
42
|
+
EventKinds: () => import_protocol22.EventKinds,
|
|
42
43
|
FREEDOME_CLIENT_VERSION: () => FREEDOME_CLIENT_VERSION,
|
|
43
44
|
FetchTransport: () => FetchTransport,
|
|
44
45
|
ForbiddenError: () => ForbiddenError,
|
|
@@ -62,7 +63,7 @@ __export(index_exports, {
|
|
|
62
63
|
NetworkError: () => NetworkError,
|
|
63
64
|
NotFoundError: () => NotFoundError,
|
|
64
65
|
OfflineError: () => OfflineError,
|
|
65
|
-
Operations: () =>
|
|
66
|
+
Operations: () => import_protocol22.Operations,
|
|
66
67
|
OscRepository: () => OscRepository,
|
|
67
68
|
PACKAGE_NAME: () => PACKAGE_NAME,
|
|
68
69
|
PairingLink: () => PairingLink,
|
|
@@ -70,12 +71,12 @@ __export(index_exports, {
|
|
|
70
71
|
PlayTargets: () => PlayTargets,
|
|
71
72
|
PlaybackRepository: () => PlaybackRepository,
|
|
72
73
|
PlayerHandle: () => PlayerHandle,
|
|
73
|
-
ProtocolVersions: () =>
|
|
74
|
+
ProtocolVersions: () => import_protocol22.ProtocolVersions,
|
|
74
75
|
QueuedForReplayError: () => QueuedForReplayError,
|
|
75
76
|
RateLimitedError: () => RateLimitedError,
|
|
76
77
|
RepositoryContext: () => RepositoryContext,
|
|
77
78
|
RequestTimeoutError: () => RequestTimeoutError,
|
|
78
|
-
SemVer: () =>
|
|
79
|
+
SemVer: () => import_protocol22.SemVer,
|
|
79
80
|
ServerError: () => ServerError,
|
|
80
81
|
Sha256: () => Sha256,
|
|
81
82
|
ShowParts: () => ShowParts,
|
|
@@ -672,7 +673,7 @@ var BackoffPolicy = class {
|
|
|
672
673
|
};
|
|
673
674
|
|
|
674
675
|
// src/client.ts
|
|
675
|
-
var
|
|
676
|
+
var import_protocol20 = require("@freedome/protocol");
|
|
676
677
|
|
|
677
678
|
// src/context.ts
|
|
678
679
|
var import_protocol3 = require("@freedome/protocol");
|
|
@@ -2496,28 +2497,54 @@ var CalibrationRepository = class {
|
|
|
2496
2497
|
}
|
|
2497
2498
|
};
|
|
2498
2499
|
|
|
2499
|
-
// src/repositories/
|
|
2500
|
+
// src/repositories/assistant.ts
|
|
2500
2501
|
var import_protocol11 = require("@freedome/protocol");
|
|
2502
|
+
var AssistantRepository = class {
|
|
2503
|
+
constructor(c) {
|
|
2504
|
+
this.c = c;
|
|
2505
|
+
}
|
|
2506
|
+
c;
|
|
2507
|
+
/** Newest first, with codes for a person. */
|
|
2508
|
+
confirmations() {
|
|
2509
|
+
return readAllPages(this.c.api, import_protocol11.Operations.listAssistantConfirmations);
|
|
2510
|
+
}
|
|
2511
|
+
refuse(confirmationId) {
|
|
2512
|
+
return this.c.api.json(import_protocol11.Operations.refuseAssistantConfirmation, { params: { confirmationId } });
|
|
2513
|
+
}
|
|
2514
|
+
link() {
|
|
2515
|
+
return this.c.api.json(import_protocol11.Operations.getAssistantLink);
|
|
2516
|
+
}
|
|
2517
|
+
/** Approves the code the assistant showed. Lasts 8 hours, with the scopes of the person signed in here. */
|
|
2518
|
+
approve(code) {
|
|
2519
|
+
return this.c.api.json(import_protocol11.Operations.approveAssistantLink, { body: { code } });
|
|
2520
|
+
}
|
|
2521
|
+
async end(sessionId) {
|
|
2522
|
+
await this.c.api.call(import_protocol11.Operations.endAssistantLink, { params: { sessionId } });
|
|
2523
|
+
}
|
|
2524
|
+
};
|
|
2525
|
+
|
|
2526
|
+
// src/repositories/clients.ts
|
|
2527
|
+
var import_protocol12 = require("@freedome/protocol");
|
|
2501
2528
|
var ClientsRepository = class {
|
|
2502
2529
|
constructor(c) {
|
|
2503
2530
|
this.c = c;
|
|
2504
2531
|
}
|
|
2505
2532
|
c;
|
|
2506
2533
|
register(registration) {
|
|
2507
|
-
return this.c.api.json(
|
|
2534
|
+
return this.c.api.json(import_protocol12.Operations.registerClient, { body: registration });
|
|
2508
2535
|
}
|
|
2509
2536
|
list() {
|
|
2510
|
-
return readAllPages(this.c.api,
|
|
2537
|
+
return readAllPages(this.c.api, import_protocol12.Operations.listClients);
|
|
2511
2538
|
}
|
|
2512
2539
|
async telemetry(clientId, batch) {
|
|
2513
|
-
await this.c.api.call(
|
|
2540
|
+
await this.c.api.call(import_protocol12.Operations.postClientTelemetry, { params: { clientId }, body: batch });
|
|
2514
2541
|
}
|
|
2515
2542
|
async unregister(clientId) {
|
|
2516
|
-
await this.c.api.call(
|
|
2543
|
+
await this.c.api.call(import_protocol12.Operations.unregisterClient, { params: { clientId } });
|
|
2517
2544
|
}
|
|
2518
2545
|
/** Commands the dome sends to this device (`clients/{id}/commands`). */
|
|
2519
2546
|
commands(clientId, fn) {
|
|
2520
|
-
return this.c.hub.on([
|
|
2547
|
+
return this.c.hub.on([import_protocol12.DomeTopics.clientCommands(clientId)], (e) => {
|
|
2521
2548
|
const r = e.resource ?? {};
|
|
2522
2549
|
if (typeof r.command === "string") fn(r.command, r.args);
|
|
2523
2550
|
});
|
|
@@ -2525,10 +2552,10 @@ var ClientsRepository = class {
|
|
|
2525
2552
|
};
|
|
2526
2553
|
|
|
2527
2554
|
// src/repositories/content.ts
|
|
2528
|
-
var
|
|
2555
|
+
var import_protocol14 = require("@freedome/protocol");
|
|
2529
2556
|
|
|
2530
2557
|
// src/repositories/upload.ts
|
|
2531
|
-
var
|
|
2558
|
+
var import_protocol13 = require("@freedome/protocol");
|
|
2532
2559
|
|
|
2533
2560
|
// src/sha256.ts
|
|
2534
2561
|
var K = new Uint32Array([
|
|
@@ -2810,7 +2837,7 @@ var UploadTask = class {
|
|
|
2810
2837
|
const id = this.uploadIdValue;
|
|
2811
2838
|
if (id) {
|
|
2812
2839
|
try {
|
|
2813
|
-
await this.c.api.call(
|
|
2840
|
+
await this.c.api.call(import_protocol13.Operations.deleteUpload, {
|
|
2814
2841
|
params: { uploadId: id },
|
|
2815
2842
|
headers: { "tus-resumable": "1.0.0" }
|
|
2816
2843
|
});
|
|
@@ -2871,7 +2898,7 @@ var UploadTask = class {
|
|
|
2871
2898
|
}
|
|
2872
2899
|
const api = this.c.api;
|
|
2873
2900
|
if (!this.uploadIdValue) {
|
|
2874
|
-
const res = await api.call(
|
|
2901
|
+
const res = await api.call(import_protocol13.Operations.createUpload, {
|
|
2875
2902
|
headers: {
|
|
2876
2903
|
"tus-resumable": "1.0.0",
|
|
2877
2904
|
"upload-length": String(total),
|
|
@@ -2899,7 +2926,7 @@ var UploadTask = class {
|
|
|
2899
2926
|
const chunk = await this.source.read(this.offset, end);
|
|
2900
2927
|
let res;
|
|
2901
2928
|
try {
|
|
2902
|
-
res = await api.call(
|
|
2929
|
+
res = await api.call(import_protocol13.Operations.appendUpload, {
|
|
2903
2930
|
params: { uploadId: this.uploadIdValue },
|
|
2904
2931
|
bytes: chunk,
|
|
2905
2932
|
contentType: "application/offset+octet-stream",
|
|
@@ -2927,7 +2954,7 @@ var UploadTask = class {
|
|
|
2927
2954
|
uploadId: this.uploadIdValue,
|
|
2928
2955
|
name: this.o.asset?.name ?? this.source.name
|
|
2929
2956
|
};
|
|
2930
|
-
asset = await api.json(
|
|
2957
|
+
asset = await api.json(import_protocol13.Operations.createAsset, { body: req });
|
|
2931
2958
|
}
|
|
2932
2959
|
this.set("done");
|
|
2933
2960
|
if (!this.finished) {
|
|
@@ -2941,7 +2968,7 @@ var UploadTask = class {
|
|
|
2941
2968
|
this.progress.close();
|
|
2942
2969
|
}
|
|
2943
2970
|
async headOffset() {
|
|
2944
|
-
const res = await this.c.api.call(
|
|
2971
|
+
const res = await this.c.api.call(import_protocol13.Operations.getUploadOffset, {
|
|
2945
2972
|
params: { uploadId: this.uploadIdValue },
|
|
2946
2973
|
headers: { "tus-resumable": "1.0.0" }
|
|
2947
2974
|
});
|
|
@@ -2975,7 +3002,7 @@ var ContentRepository = class {
|
|
|
2975
3002
|
/** One page of assets (first pages cache-backed). */
|
|
2976
3003
|
list(query = {}, cursor) {
|
|
2977
3004
|
const q = { type: query.type, tag: query.tag, q: query.q, status: query.status };
|
|
2978
|
-
const read = () => readPage(this.c.api,
|
|
3005
|
+
const read = () => readPage(this.c.api, import_protocol14.Operations.listAssets, {
|
|
2979
3006
|
query: q,
|
|
2980
3007
|
cursor,
|
|
2981
3008
|
limit: query.limit
|
|
@@ -2992,7 +3019,26 @@ var ContentRepository = class {
|
|
|
2992
3019
|
);
|
|
2993
3020
|
}
|
|
2994
3021
|
get(assetId) {
|
|
2995
|
-
return this.c.api.json(
|
|
3022
|
+
return this.c.api.json(import_protocol14.Operations.getAsset, { params: { assetId } });
|
|
3023
|
+
}
|
|
3024
|
+
/**
|
|
3025
|
+
* The first asset whose `name` equals `name` exactly (case-sensitive), or `null` when there is none.
|
|
3026
|
+
*
|
|
3027
|
+
* Asks the server with `q` = `name` (a case-insensitive substring match), keeps exact matches only and reads more
|
|
3028
|
+
* pages while needed; `type` / `tag` / `status` narrow it as in `list`. Several assets with the name: the first in
|
|
3029
|
+
* the server's order wins. Offline, the first page comes from the cache as in `list`. Added in 1.2.0.
|
|
3030
|
+
*/
|
|
3031
|
+
async findAssetByName(name, filter = {}) {
|
|
3032
|
+
if (!name) throw new RangeError("findAssetByName: empty name");
|
|
3033
|
+
const query = { ...filter, q: name, limit: 100 };
|
|
3034
|
+
let cursor;
|
|
3035
|
+
do {
|
|
3036
|
+
const page = await this.list(query, cursor);
|
|
3037
|
+
const hit = page.items.find((a) => a.name === name);
|
|
3038
|
+
if (hit) return hit;
|
|
3039
|
+
cursor = page.nextCursor ?? void 0;
|
|
3040
|
+
} while (cursor);
|
|
3041
|
+
return null;
|
|
2996
3042
|
}
|
|
2997
3043
|
/** Starts a resumable upload creating an asset (await `task.done`). */
|
|
2998
3044
|
upload(source, o = {}) {
|
|
@@ -3031,7 +3077,7 @@ var ContentRepository = class {
|
|
|
3031
3077
|
/** Uploads [source] and runs an import job; returns the finished job (rejects when it failed). */
|
|
3032
3078
|
async importFile(source, format, o = {}) {
|
|
3033
3079
|
const up = await this.uploadFor("import", source).done;
|
|
3034
|
-
const job = await this.c.api.json(
|
|
3080
|
+
const job = await this.c.api.json(import_protocol14.Operations.startImport, {
|
|
3035
3081
|
body: {
|
|
3036
3082
|
uploadId: up.uploadId,
|
|
3037
3083
|
format,
|
|
@@ -3067,13 +3113,13 @@ var ContentRepository = class {
|
|
|
3067
3113
|
if (Date.now() > deadline)
|
|
3068
3114
|
throw new RequestTimeoutError(`job ${j.id} not finished in time`, o.timeoutMs);
|
|
3069
3115
|
await new Promise((r) => setTimeout(r, o.pollMs ?? 500));
|
|
3070
|
-
j = await this.c.api.json(
|
|
3116
|
+
j = await this.c.api.json(import_protocol14.Operations.getJob, { params: { jobId: j.id } });
|
|
3071
3117
|
}
|
|
3072
3118
|
}
|
|
3073
3119
|
/** Merge-patches an asset (ETag read first when not given). */
|
|
3074
3120
|
async patch(assetId, patch, ifMatch) {
|
|
3075
3121
|
const etag = ifMatch ?? `"r${(await this.get(assetId)).revision}"`;
|
|
3076
|
-
return this.c.api.json(
|
|
3122
|
+
return this.c.api.json(import_protocol14.Operations.patchAsset, {
|
|
3077
3123
|
params: { assetId },
|
|
3078
3124
|
body: patch,
|
|
3079
3125
|
headers: { "if-match": etag }
|
|
@@ -3082,23 +3128,23 @@ var ContentRepository = class {
|
|
|
3082
3128
|
/** Deletes an asset (409 while referenced unless [force]). */
|
|
3083
3129
|
async delete(assetId, o = {}) {
|
|
3084
3130
|
const etag = o.ifMatch ?? `"r${(await this.get(assetId)).revision}"`;
|
|
3085
|
-
await this.c.api.call(
|
|
3131
|
+
await this.c.api.call(import_protocol14.Operations.deleteAsset, {
|
|
3086
3132
|
params: { assetId },
|
|
3087
3133
|
query: o.force ? { force: "true" } : {},
|
|
3088
3134
|
headers: { "if-match": etag }
|
|
3089
3135
|
});
|
|
3090
3136
|
}
|
|
3091
3137
|
async thumbnail(assetId, size) {
|
|
3092
|
-
return (await this.c.api.call(
|
|
3138
|
+
return (await this.c.api.call(import_protocol14.Operations.getAssetThumbnail, {
|
|
3093
3139
|
params: { assetId },
|
|
3094
3140
|
query: { size: size?.toString() }
|
|
3095
3141
|
})).body;
|
|
3096
3142
|
}
|
|
3097
3143
|
async download(assetId) {
|
|
3098
|
-
return (await this.c.api.call(
|
|
3144
|
+
return (await this.c.api.call(import_protocol14.Operations.downloadAsset, { params: { assetId }, timeoutMs: 18e5 })).body;
|
|
3099
3145
|
}
|
|
3100
3146
|
storage() {
|
|
3101
|
-
return this.c.api.json(
|
|
3147
|
+
return this.c.api.json(import_protocol14.Operations.getStorageStats);
|
|
3102
3148
|
}
|
|
3103
3149
|
/** Changes of the content store. */
|
|
3104
3150
|
changes(fn) {
|
|
@@ -3113,59 +3159,59 @@ var ContentRepository = class {
|
|
|
3113
3159
|
});
|
|
3114
3160
|
}
|
|
3115
3161
|
listShows(o = {}) {
|
|
3116
|
-
return readPage(this.c.api,
|
|
3162
|
+
return readPage(this.c.api, import_protocol14.Operations.listShows, {
|
|
3117
3163
|
query: { q: o.q },
|
|
3118
3164
|
cursor: o.cursor,
|
|
3119
3165
|
limit: o.limit
|
|
3120
3166
|
});
|
|
3121
3167
|
}
|
|
3122
3168
|
async getShow(showId) {
|
|
3123
|
-
const res = await this.c.api.call(
|
|
3169
|
+
const res = await this.c.api.call(import_protocol14.Operations.getShow, { params: { showId } });
|
|
3124
3170
|
return {
|
|
3125
|
-
value: ApiCaller.decodeBody(
|
|
3171
|
+
value: ApiCaller.decodeBody(import_protocol14.Operations.getShow, res),
|
|
3126
3172
|
etag: res.headers.etag
|
|
3127
3173
|
};
|
|
3128
3174
|
}
|
|
3129
3175
|
async createShow(body) {
|
|
3130
|
-
const res = await this.c.api.call(
|
|
3176
|
+
const res = await this.c.api.call(import_protocol14.Operations.createShow, { body });
|
|
3131
3177
|
return {
|
|
3132
|
-
value: ApiCaller.decodeBody(
|
|
3178
|
+
value: ApiCaller.decodeBody(import_protocol14.Operations.createShow, res),
|
|
3133
3179
|
etag: res.headers.etag
|
|
3134
3180
|
};
|
|
3135
3181
|
}
|
|
3136
3182
|
/** Replaces a show (`ifMatch`; without: create with If-None-Match: *). Queued in the outbox while offline. */
|
|
3137
3183
|
async saveShow(showId, body, ifMatch) {
|
|
3138
|
-
const res = await this.c.idempotentWrite(
|
|
3184
|
+
const res = await this.c.idempotentWrite(import_protocol14.Operations.putShow, {
|
|
3139
3185
|
params: { showId },
|
|
3140
3186
|
body,
|
|
3141
3187
|
headers: ifMatch ? { "if-match": ifMatch } : { "if-none-match": "*" }
|
|
3142
3188
|
});
|
|
3143
3189
|
return {
|
|
3144
|
-
value: ApiCaller.decodeBody(
|
|
3190
|
+
value: ApiCaller.decodeBody(import_protocol14.Operations.putShow, res),
|
|
3145
3191
|
etag: res.headers.etag
|
|
3146
3192
|
};
|
|
3147
3193
|
}
|
|
3148
3194
|
async patchShow(showId, patch, ifMatch) {
|
|
3149
3195
|
const etag = ifMatch ?? (await this.getShow(showId)).etag;
|
|
3150
|
-
const res = await this.c.api.call(
|
|
3196
|
+
const res = await this.c.api.call(import_protocol14.Operations.patchShow, {
|
|
3151
3197
|
params: { showId },
|
|
3152
3198
|
body: patch,
|
|
3153
3199
|
headers: { "if-match": etag }
|
|
3154
3200
|
});
|
|
3155
3201
|
return {
|
|
3156
|
-
value: ApiCaller.decodeBody(
|
|
3202
|
+
value: ApiCaller.decodeBody(import_protocol14.Operations.patchShow, res),
|
|
3157
3203
|
etag: res.headers.etag
|
|
3158
3204
|
};
|
|
3159
3205
|
}
|
|
3160
3206
|
async deleteShow(showId, ifMatch) {
|
|
3161
|
-
await this.c.api.call(
|
|
3207
|
+
await this.c.api.call(import_protocol14.Operations.deleteShow, {
|
|
3162
3208
|
params: { showId },
|
|
3163
3209
|
headers: { "if-match": ifMatch }
|
|
3164
3210
|
});
|
|
3165
3211
|
}
|
|
3166
3212
|
/** Exports a show as `.dome` bytes. */
|
|
3167
3213
|
async exportShow(showId, embedAssets = false) {
|
|
3168
|
-
return (await this.c.api.call(
|
|
3214
|
+
return (await this.c.api.call(import_protocol14.Operations.exportShow, {
|
|
3169
3215
|
params: { showId },
|
|
3170
3216
|
query: embedAssets ? { embedAssets: "true" } : {},
|
|
3171
3217
|
timeoutMs: 18e5
|
|
@@ -3173,7 +3219,7 @@ var ContentRepository = class {
|
|
|
3173
3219
|
}
|
|
3174
3220
|
/** tus capabilities. */
|
|
3175
3221
|
async uploadCapabilities() {
|
|
3176
|
-
const res = await this.c.api.call(
|
|
3222
|
+
const res = await this.c.api.call(import_protocol14.Operations.getUploadCapabilities);
|
|
3177
3223
|
const list = (h) => (res.headers[h] ?? "").split(",").map((x) => x.trim()).filter(Boolean);
|
|
3178
3224
|
const max = Number.parseInt(res.headers["tus-max-size"] ?? "", 10);
|
|
3179
3225
|
return {
|
|
@@ -3184,11 +3230,11 @@ var ContentRepository = class {
|
|
|
3184
3230
|
};
|
|
3185
3231
|
}
|
|
3186
3232
|
uploadStatus(uploadId) {
|
|
3187
|
-
return this.c.api.json(
|
|
3233
|
+
return this.c.api.json(import_protocol14.Operations.getUpload, { params: { uploadId } });
|
|
3188
3234
|
}
|
|
3189
3235
|
/** Watch hook used by apps showing one asset. */
|
|
3190
3236
|
watchAsset(assetId, fn) {
|
|
3191
|
-
return this.c.watchResource(
|
|
3237
|
+
return this.c.watchResource(import_protocol14.DomeTopics.asset(assetId), () => this.get(assetId), { next: fn });
|
|
3192
3238
|
}
|
|
3193
3239
|
};
|
|
3194
3240
|
var ShowParts = class {
|
|
@@ -3197,29 +3243,29 @@ var ShowParts = class {
|
|
|
3197
3243
|
}
|
|
3198
3244
|
c;
|
|
3199
3245
|
async etag(showId, ifMatch) {
|
|
3200
|
-
return ifMatch ?? (await this.c.api.call(
|
|
3246
|
+
return ifMatch ?? (await this.c.api.call(import_protocol14.Operations.getShow, { params: { showId } })).headers.etag;
|
|
3201
3247
|
}
|
|
3202
3248
|
get(part, showId, itemId) {
|
|
3203
|
-
return this.c.api.json(
|
|
3249
|
+
return this.c.api.json(import_protocol14.Operations[`get${part}`], { params: { showId, itemId } });
|
|
3204
3250
|
}
|
|
3205
3251
|
async put(part, showId, item, ifMatch) {
|
|
3206
|
-
return this.c.api.json(
|
|
3252
|
+
return this.c.api.json(import_protocol14.Operations[`put${part}`], {
|
|
3207
3253
|
params: { showId, itemId: item.id },
|
|
3208
3254
|
body: item,
|
|
3209
3255
|
headers: { "if-match": await this.etag(showId, ifMatch) }
|
|
3210
3256
|
});
|
|
3211
3257
|
}
|
|
3212
3258
|
async delete(part, showId, itemId, ifMatch) {
|
|
3213
|
-
await this.c.api.call(
|
|
3259
|
+
await this.c.api.call(import_protocol14.Operations[`delete${part}`], {
|
|
3214
3260
|
params: { showId, itemId },
|
|
3215
3261
|
headers: { "if-match": await this.etag(showId, ifMatch) }
|
|
3216
3262
|
});
|
|
3217
3263
|
}
|
|
3218
3264
|
matrix(showId) {
|
|
3219
|
-
return this.c.api.json(
|
|
3265
|
+
return this.c.api.json(import_protocol14.Operations.getMatrix, { params: { showId } });
|
|
3220
3266
|
}
|
|
3221
3267
|
async putMatrix(showId, matrix, ifMatch) {
|
|
3222
|
-
return this.c.api.json(
|
|
3268
|
+
return this.c.api.json(import_protocol14.Operations.putMatrix, {
|
|
3223
3269
|
params: { showId },
|
|
3224
3270
|
body: matrix,
|
|
3225
3271
|
headers: { "if-match": await this.etag(showId, ifMatch) }
|
|
@@ -3228,7 +3274,7 @@ var ShowParts = class {
|
|
|
3228
3274
|
};
|
|
3229
3275
|
|
|
3230
3276
|
// src/repositories/engine.ts
|
|
3231
|
-
var
|
|
3277
|
+
var import_protocol15 = require("@freedome/protocol");
|
|
3232
3278
|
var EngineRepository = class {
|
|
3233
3279
|
constructor(c) {
|
|
3234
3280
|
this.c = c;
|
|
@@ -3236,23 +3282,23 @@ var EngineRepository = class {
|
|
|
3236
3282
|
c;
|
|
3237
3283
|
/** Every engine (visual, audio, …; `name@node` on multi-node installations). */
|
|
3238
3284
|
engines() {
|
|
3239
|
-
return readAllPages(this.c.api,
|
|
3285
|
+
return readAllPages(this.c.api, import_protocol15.Operations.listEngines);
|
|
3240
3286
|
}
|
|
3241
3287
|
/** Displays of a venue. */
|
|
3242
3288
|
outputs(venueId = "default") {
|
|
3243
|
-
return readAllPages(this.c.api,
|
|
3289
|
+
return readAllPages(this.c.api, import_protocol15.Operations.listDisplays, {
|
|
3244
3290
|
params: { venueId }
|
|
3245
3291
|
});
|
|
3246
3292
|
}
|
|
3247
3293
|
/** One display. */
|
|
3248
3294
|
display(displayId, venueId = "default") {
|
|
3249
|
-
return this.c.api.json(
|
|
3295
|
+
return this.c.api.json(import_protocol15.Operations.getDisplay, {
|
|
3250
3296
|
params: { venueId, displayId }
|
|
3251
3297
|
});
|
|
3252
3298
|
}
|
|
3253
3299
|
/** Shows a test pattern on a display. */
|
|
3254
3300
|
showTestPattern(displayId, pattern, venueId = "default") {
|
|
3255
|
-
return this.c.api.json(
|
|
3301
|
+
return this.c.api.json(import_protocol15.Operations.setTestPattern, {
|
|
3256
3302
|
params: { venueId, displayId },
|
|
3257
3303
|
body: pattern,
|
|
3258
3304
|
preferRealtime: true
|
|
@@ -3268,28 +3314,28 @@ var EngineRepository = class {
|
|
|
3268
3314
|
}
|
|
3269
3315
|
/** Flashes the id overlay. */
|
|
3270
3316
|
async identify(displayId, durationMs, venueId = "default") {
|
|
3271
|
-
await this.c.api.call(
|
|
3317
|
+
await this.c.api.call(import_protocol15.Operations.identifyDisplay, {
|
|
3272
3318
|
params: { venueId, displayId },
|
|
3273
3319
|
body: durationMs === void 0 ? {} : { durationS: durationMs / 1e3 }
|
|
3274
3320
|
});
|
|
3275
3321
|
}
|
|
3276
3322
|
/** Power / shutter (what `state.capabilities` lists). */
|
|
3277
3323
|
setPower(displayId, request, venueId = "default") {
|
|
3278
|
-
return this.c.api.json(
|
|
3324
|
+
return this.c.api.json(import_protocol15.Operations.setDisplayPower, {
|
|
3279
3325
|
params: { venueId, displayId },
|
|
3280
3326
|
body: request
|
|
3281
3327
|
});
|
|
3282
3328
|
}
|
|
3283
3329
|
/** Status of engine [name]. */
|
|
3284
3330
|
async engineStatus(name = "visual") {
|
|
3285
|
-
const s = await this.c.api.json(
|
|
3331
|
+
const s = await this.c.api.json(import_protocol15.Operations.getEngine, { params: { name } });
|
|
3286
3332
|
if (name === "visual") this.c.onEngineHealth?.(String(s.status));
|
|
3287
3333
|
return s;
|
|
3288
3334
|
}
|
|
3289
3335
|
/** Watches an engine (feeds the `degraded` state for the visual engine). */
|
|
3290
3336
|
status(obs, name = "visual", intervalMs = 2e3) {
|
|
3291
3337
|
return this.c.watchResource(
|
|
3292
|
-
|
|
3338
|
+
import_protocol15.DomeTopics.engine(name),
|
|
3293
3339
|
() => this.engineStatus(name),
|
|
3294
3340
|
{
|
|
3295
3341
|
next: (s) => {
|
|
@@ -3299,13 +3345,13 @@ var EngineRepository = class {
|
|
|
3299
3345
|
},
|
|
3300
3346
|
...obs.error ? { error: obs.error } : {}
|
|
3301
3347
|
},
|
|
3302
|
-
{ intervalMs, kinds: /* @__PURE__ */ new Set([
|
|
3348
|
+
{ intervalMs, kinds: /* @__PURE__ */ new Set([import_protocol15.EventKinds.engineStatus]) }
|
|
3303
3349
|
);
|
|
3304
3350
|
}
|
|
3305
3351
|
};
|
|
3306
3352
|
|
|
3307
3353
|
// src/repositories/gateways.ts
|
|
3308
|
-
var
|
|
3354
|
+
var import_protocol16 = require("@freedome/protocol");
|
|
3309
3355
|
var GatewaysRepository = class {
|
|
3310
3356
|
constructor(c) {
|
|
3311
3357
|
this.c = c;
|
|
@@ -3313,13 +3359,13 @@ var GatewaysRepository = class {
|
|
|
3313
3359
|
c;
|
|
3314
3360
|
/** Every gateway. */
|
|
3315
3361
|
list() {
|
|
3316
|
-
return readAllPages(this.c.api,
|
|
3362
|
+
return readAllPages(this.c.api, import_protocol16.Operations.listGateways, {});
|
|
3317
3363
|
}
|
|
3318
3364
|
/** One gateway with its ETag. */
|
|
3319
3365
|
async get(gatewayId) {
|
|
3320
|
-
const res = await this.c.api.call(
|
|
3366
|
+
const res = await this.c.api.call(import_protocol16.Operations.getGateway, { params: { gatewayId } });
|
|
3321
3367
|
return {
|
|
3322
|
-
value: ApiCaller.decodeBody(
|
|
3368
|
+
value: ApiCaller.decodeBody(import_protocol16.Operations.getGateway, res),
|
|
3323
3369
|
etag: res.headers.etag
|
|
3324
3370
|
};
|
|
3325
3371
|
}
|
|
@@ -3329,24 +3375,24 @@ var GatewaysRepository = class {
|
|
|
3329
3375
|
*/
|
|
3330
3376
|
async patch(gatewayId, patch, o = {}) {
|
|
3331
3377
|
const etag = o.ifMatch ?? (await this.get(gatewayId)).etag;
|
|
3332
|
-
const res = await this.c.api.call(
|
|
3378
|
+
const res = await this.c.api.call(import_protocol16.Operations.patchGateway, {
|
|
3333
3379
|
params: { gatewayId },
|
|
3334
3380
|
body: patch,
|
|
3335
3381
|
headers: { "if-match": etag }
|
|
3336
3382
|
});
|
|
3337
3383
|
return {
|
|
3338
|
-
value: ApiCaller.decodeBody(
|
|
3384
|
+
value: ApiCaller.decodeBody(import_protocol16.Operations.patchGateway, res),
|
|
3339
3385
|
etag: res.headers.etag
|
|
3340
3386
|
};
|
|
3341
3387
|
}
|
|
3342
3388
|
/** Runs the gateway's connectivity test. */
|
|
3343
3389
|
test(gatewayId) {
|
|
3344
|
-
return this.c.api.json(
|
|
3390
|
+
return this.c.api.json(import_protocol16.Operations.testGateway, { params: { gatewayId } });
|
|
3345
3391
|
}
|
|
3346
3392
|
};
|
|
3347
3393
|
|
|
3348
3394
|
// src/repositories/osc.ts
|
|
3349
|
-
var
|
|
3395
|
+
var import_protocol17 = require("@freedome/protocol");
|
|
3350
3396
|
function oscArg(a) {
|
|
3351
3397
|
if (a !== null && typeof a === "object" && "type" in a && !(a instanceof Uint8Array) && !(a instanceof Date))
|
|
3352
3398
|
return a;
|
|
@@ -3373,12 +3419,12 @@ var OscRepository = class {
|
|
|
3373
3419
|
async send(address, args, target) {
|
|
3374
3420
|
if (!address.startsWith("/")) throw new TypeError("OSC address must start with /");
|
|
3375
3421
|
const body = { target, address, args: args.map(oscArg) };
|
|
3376
|
-
await this.c.api.call(
|
|
3422
|
+
await this.c.api.call(import_protocol17.Operations.sendOsc, { body, preferRealtime: true });
|
|
3377
3423
|
}
|
|
3378
3424
|
/** OSC traffic of gateways (`gateway.message` events). */
|
|
3379
3425
|
messages(fn, gatewayId = "+") {
|
|
3380
3426
|
return this.c.hub.on(
|
|
3381
|
-
[gatewayId === "+" ? "gateways/+" :
|
|
3427
|
+
[gatewayId === "+" ? "gateways/+" : import_protocol17.DomeTopics.gateway(gatewayId)],
|
|
3382
3428
|
(e) => {
|
|
3383
3429
|
const r = e.resource ?? e.data;
|
|
3384
3430
|
if (typeof r?.address === "string")
|
|
@@ -3389,7 +3435,7 @@ var OscRepository = class {
|
|
|
3389
3435
|
};
|
|
3390
3436
|
|
|
3391
3437
|
// src/repositories/playback.ts
|
|
3392
|
-
var
|
|
3438
|
+
var import_protocol18 = require("@freedome/protocol");
|
|
3393
3439
|
var PlayTargets = {
|
|
3394
3440
|
show: (showId, o = {}) => ({
|
|
3395
3441
|
kind: "show",
|
|
@@ -3477,13 +3523,13 @@ var PlayerHandle = class {
|
|
|
3477
3523
|
watch(fn) {
|
|
3478
3524
|
const off = this.states.on(fn);
|
|
3479
3525
|
if (this.listeners++ === 0) {
|
|
3480
|
-
const topic =
|
|
3526
|
+
const topic = import_protocol18.DomeTopics.player(this.playerId, this.venueId);
|
|
3481
3527
|
this.offEvents = this.c.hub.on([topic], (e) => {
|
|
3482
|
-
if (e.kind ===
|
|
3528
|
+
if (e.kind === import_protocol18.EventKinds.playerState || e.kind === import_protocol18.EventKinds.playerError) {
|
|
3483
3529
|
if (e.resource && typeof e.resource === "object")
|
|
3484
3530
|
this.push({ state: e.resource });
|
|
3485
|
-
} else if (e.kind ===
|
|
3486
|
-
this.push({ state: (0,
|
|
3531
|
+
} else if (e.kind === import_protocol18.EventKinds.playerPosition && e.patch && this.last) {
|
|
3532
|
+
this.push({ state: (0, import_protocol18.jsonMergePatch)(this.last.state, e.patch) });
|
|
3487
3533
|
}
|
|
3488
3534
|
});
|
|
3489
3535
|
this.offSnapshot = this.c.hub.onSnapshot(topic, async () => {
|
|
@@ -3511,7 +3557,7 @@ var PlayerHandle = class {
|
|
|
3511
3557
|
const snap = await this.c.cachedRead(
|
|
3512
3558
|
`players/${this.venueId}/${this.playerId}`,
|
|
3513
3559
|
async () => {
|
|
3514
|
-
const s = await this.c.api.json(
|
|
3560
|
+
const s = await this.c.api.json(import_protocol18.Operations.getPlayer, { params: this.params });
|
|
3515
3561
|
return [{ state: s }, s];
|
|
3516
3562
|
},
|
|
3517
3563
|
(json, asOf) => ({ state: json, stale: true, asOf })
|
|
@@ -3543,7 +3589,7 @@ var PlayerHandle = class {
|
|
|
3543
3589
|
/** Plays [target] (optionally from [positionMs], at server time [at] for multi-node sync). */
|
|
3544
3590
|
async play(target, o = {}) {
|
|
3545
3591
|
if (target.kind === "app") {
|
|
3546
|
-
await this.c.api.call(
|
|
3592
|
+
await this.c.api.call(import_protocol18.Operations.publishAppPayload, {
|
|
3547
3593
|
params: { app: target.app },
|
|
3548
3594
|
body: target.payload,
|
|
3549
3595
|
preferRealtime: true
|
|
@@ -3561,40 +3607,40 @@ var PlayerHandle = class {
|
|
|
3561
3607
|
if (target.itemIndex !== void 0) req.itemIndex = target.itemIndex;
|
|
3562
3608
|
} else if (target.kind === "asset") req.assetId = target.assetId;
|
|
3563
3609
|
if (o.positionMs !== void 0) req.position = o.positionMs / 1e3;
|
|
3564
|
-
if (o.at) req.at = (0,
|
|
3565
|
-
return this.command(
|
|
3610
|
+
if (o.at) req.at = (0, import_protocol18.rfc3339Millis)(o.at);
|
|
3611
|
+
return this.command(import_protocol18.Operations.play, req);
|
|
3566
3612
|
}
|
|
3567
3613
|
pause() {
|
|
3568
|
-
return this.command(
|
|
3614
|
+
return this.command(import_protocol18.Operations.pause);
|
|
3569
3615
|
}
|
|
3570
3616
|
resume() {
|
|
3571
|
-
return this.command(
|
|
3617
|
+
return this.command(import_protocol18.Operations.resume);
|
|
3572
3618
|
}
|
|
3573
3619
|
stop() {
|
|
3574
|
-
return this.command(
|
|
3620
|
+
return this.command(import_protocol18.Operations.stop);
|
|
3575
3621
|
}
|
|
3576
3622
|
next() {
|
|
3577
|
-
return this.command(
|
|
3623
|
+
return this.command(import_protocol18.Operations.next);
|
|
3578
3624
|
}
|
|
3579
3625
|
previous() {
|
|
3580
|
-
return this.command(
|
|
3626
|
+
return this.command(import_protocol18.Operations.previous);
|
|
3581
3627
|
}
|
|
3582
3628
|
/** Seeks (coalesced while scrubbing). */
|
|
3583
3629
|
seek(positionMs) {
|
|
3584
3630
|
return this.fader(
|
|
3585
3631
|
"seek",
|
|
3586
3632
|
{ position: positionMs / 1e3 },
|
|
3587
|
-
(b) => this.command(
|
|
3633
|
+
(b) => this.command(import_protocol18.Operations.seek, b)
|
|
3588
3634
|
);
|
|
3589
3635
|
}
|
|
3590
3636
|
seekToMarker(marker) {
|
|
3591
|
-
return this.command(
|
|
3637
|
+
return this.command(import_protocol18.Operations.seek, { marker });
|
|
3592
3638
|
}
|
|
3593
3639
|
patch(body) {
|
|
3594
3640
|
return this.fader(
|
|
3595
3641
|
`patch:${Object.keys(body).join(",")}`,
|
|
3596
3642
|
body,
|
|
3597
|
-
(b) => this.command(
|
|
3643
|
+
(b) => this.command(import_protocol18.Operations.patchPlayer, b)
|
|
3598
3644
|
);
|
|
3599
3645
|
}
|
|
3600
3646
|
/** Player volume 0..1 (fader). */
|
|
@@ -3644,7 +3690,7 @@ var PlaybackRepository = class {
|
|
|
3644
3690
|
return this.main.watch(fn);
|
|
3645
3691
|
}
|
|
3646
3692
|
list(venueId = "default") {
|
|
3647
|
-
return readAllPages(this.c.api,
|
|
3693
|
+
return readAllPages(this.c.api, import_protocol18.Operations.listPlayers, { params: { venueId } });
|
|
3648
3694
|
}
|
|
3649
3695
|
play(target, o = {}) {
|
|
3650
3696
|
return this.main.play(target, o);
|
|
@@ -3669,7 +3715,7 @@ var PlaybackRepository = class {
|
|
|
3669
3715
|
}
|
|
3670
3716
|
/** Fires cue [cueId] of the active show (or of [showId]). */
|
|
3671
3717
|
async cue(cueId, o = {}) {
|
|
3672
|
-
await this.c.api.call(
|
|
3718
|
+
await this.c.api.call(import_protocol18.Operations.fireCue, {
|
|
3673
3719
|
params: { venueId: o.venueId ?? "default", cueId },
|
|
3674
3720
|
body: o.showId ? { showId: o.showId } : {},
|
|
3675
3721
|
preferRealtime: true
|
|
@@ -3677,21 +3723,21 @@ var PlaybackRepository = class {
|
|
|
3677
3723
|
}
|
|
3678
3724
|
/** Loads a show onto the venue. */
|
|
3679
3725
|
async setActiveShow(showId, o = {}) {
|
|
3680
|
-
await this.c.api.call(
|
|
3726
|
+
await this.c.api.call(import_protocol18.Operations.setActiveShow, {
|
|
3681
3727
|
params: { venueId: o.venueId ?? "default" },
|
|
3682
3728
|
body: { showId, autoplay: o.autoplay ?? false }
|
|
3683
3729
|
});
|
|
3684
3730
|
}
|
|
3685
3731
|
activeShow(venueId = "default") {
|
|
3686
|
-
return this.c.api.json(
|
|
3732
|
+
return this.c.api.json(import_protocol18.Operations.getActiveShow, { params: { venueId } });
|
|
3687
3733
|
}
|
|
3688
3734
|
parameters(venueId = "default") {
|
|
3689
|
-
return readAllPages(this.c.api,
|
|
3735
|
+
return readAllPages(this.c.api, import_protocol18.Operations.listParameters, {
|
|
3690
3736
|
params: { venueId }
|
|
3691
3737
|
});
|
|
3692
3738
|
}
|
|
3693
3739
|
parameter(path, venueId = "default") {
|
|
3694
|
-
return this.c.api.json(
|
|
3740
|
+
return this.c.api.json(import_protocol18.Operations.getParameter, { params: { venueId, path } });
|
|
3695
3741
|
}
|
|
3696
3742
|
/** Sets a parameter (fader; coalesced). */
|
|
3697
3743
|
async setParameter(path, value, venueId = "default") {
|
|
@@ -3699,7 +3745,7 @@ var PlaybackRepository = class {
|
|
|
3699
3745
|
let f = this.outputFaders.get(k);
|
|
3700
3746
|
if (!f) {
|
|
3701
3747
|
f = new Fader(async (b) => {
|
|
3702
|
-
await this.c.api.call(
|
|
3748
|
+
await this.c.api.call(import_protocol18.Operations.setParameter, {
|
|
3703
3749
|
params: { venueId, path },
|
|
3704
3750
|
body: b,
|
|
3705
3751
|
preferRealtime: true
|
|
@@ -3712,14 +3758,14 @@ var PlaybackRepository = class {
|
|
|
3712
3758
|
}
|
|
3713
3759
|
/** Removes every payload an app published. */
|
|
3714
3760
|
async clearAppPayloads(app) {
|
|
3715
|
-
await this.c.api.call(
|
|
3761
|
+
await this.c.api.call(import_protocol18.Operations.clearAppPayloads, { params: { app }, preferRealtime: true });
|
|
3716
3762
|
}
|
|
3717
3763
|
/** Master output of a venue. */
|
|
3718
3764
|
readOutput(venueId = "default") {
|
|
3719
3765
|
return this.c.cachedRead(
|
|
3720
3766
|
`output/${venueId}`,
|
|
3721
3767
|
async () => {
|
|
3722
|
-
const o = await this.c.api.json(
|
|
3768
|
+
const o = await this.c.api.json(import_protocol18.Operations.getOutput, { params: { venueId } });
|
|
3723
3769
|
return [o, o];
|
|
3724
3770
|
},
|
|
3725
3771
|
(json) => json
|
|
@@ -3728,9 +3774,9 @@ var PlaybackRepository = class {
|
|
|
3728
3774
|
/** Follows the master output (`output.changed` events / patches). */
|
|
3729
3775
|
watchOutput(fn, venueId = "default") {
|
|
3730
3776
|
let last;
|
|
3731
|
-
const off = this.c.hub.on([
|
|
3777
|
+
const off = this.c.hub.on([import_protocol18.DomeTopics.output(venueId)], (e) => {
|
|
3732
3778
|
if (e.resource && typeof e.resource === "object") last = e.resource;
|
|
3733
|
-
else if (e.patch && last) last = (0,
|
|
3779
|
+
else if (e.patch && last) last = (0, import_protocol18.jsonMergePatch)(last, e.patch);
|
|
3734
3780
|
else return;
|
|
3735
3781
|
fn(last);
|
|
3736
3782
|
});
|
|
@@ -3748,7 +3794,7 @@ var PlaybackRepository = class {
|
|
|
3748
3794
|
let f = this.outputFaders.get(k);
|
|
3749
3795
|
if (!f) {
|
|
3750
3796
|
f = new Fader(
|
|
3751
|
-
(b) => this.c.api.json(
|
|
3797
|
+
(b) => this.c.api.json(import_protocol18.Operations.patchOutput, {
|
|
3752
3798
|
params: { venueId },
|
|
3753
3799
|
body: b,
|
|
3754
3800
|
preferRealtime: true
|
|
@@ -3779,7 +3825,7 @@ var PlaybackRepository = class {
|
|
|
3779
3825
|
};
|
|
3780
3826
|
|
|
3781
3827
|
// src/repositories/venues.ts
|
|
3782
|
-
var
|
|
3828
|
+
var import_protocol19 = require("@freedome/protocol");
|
|
3783
3829
|
var CALIBRATION_FILE_TYPES = {
|
|
3784
3830
|
warp: "application/vnd.nativemind.freedome.fdmesh",
|
|
3785
3831
|
blend: "image/png",
|
|
@@ -3798,7 +3844,7 @@ var VenuesRepository = class {
|
|
|
3798
3844
|
return this.c.cachedRead(
|
|
3799
3845
|
"venues",
|
|
3800
3846
|
async () => {
|
|
3801
|
-
const l = await readAllPages(this.api,
|
|
3847
|
+
const l = await readAllPages(this.api, import_protocol19.Operations.listVenues);
|
|
3802
3848
|
return [{ value: l, etag: void 0 }, l];
|
|
3803
3849
|
},
|
|
3804
3850
|
(json, asOf) => ({ value: json, etag: void 0, stale: true, asOf })
|
|
@@ -3806,8 +3852,8 @@ var VenuesRepository = class {
|
|
|
3806
3852
|
}
|
|
3807
3853
|
/** One venue with its ETag (`default` = the active venue). */
|
|
3808
3854
|
async get(venueId = "default") {
|
|
3809
|
-
const res = await this.api.call(
|
|
3810
|
-
return { value: ApiCaller.decodeBody(
|
|
3855
|
+
const res = await this.api.call(import_protocol19.Operations.getVenue, { params: { venueId } });
|
|
3856
|
+
return { value: ApiCaller.decodeBody(import_protocol19.Operations.getVenue, res), etag: res.headers.etag };
|
|
3811
3857
|
}
|
|
3812
3858
|
/** The venue the server runs now. */
|
|
3813
3859
|
async current() {
|
|
@@ -3815,22 +3861,22 @@ var VenuesRepository = class {
|
|
|
3815
3861
|
}
|
|
3816
3862
|
/** Creates a venue (`POST /venues`; id = `meta.id`). */
|
|
3817
3863
|
async create(body) {
|
|
3818
|
-
const res = await this.api.call(
|
|
3864
|
+
const res = await this.api.call(import_protocol19.Operations.createVenue, { body });
|
|
3819
3865
|
return {
|
|
3820
|
-
value: ApiCaller.decodeBody(
|
|
3866
|
+
value: ApiCaller.decodeBody(import_protocol19.Operations.createVenue, res),
|
|
3821
3867
|
etag: res.headers.etag
|
|
3822
3868
|
};
|
|
3823
3869
|
}
|
|
3824
3870
|
/** Replaces a venue (`ifMatch` = ETag; without it: create with If-None-Match: *). 409 / 412 → ConflictError with `latest`. */
|
|
3825
3871
|
async save(venueId, body, ifMatch) {
|
|
3826
3872
|
try {
|
|
3827
|
-
const res = await this.api.call(
|
|
3873
|
+
const res = await this.api.call(import_protocol19.Operations.putVenue, {
|
|
3828
3874
|
params: { venueId },
|
|
3829
3875
|
body,
|
|
3830
3876
|
headers: ifMatch ? { "if-match": ifMatch } : { "if-none-match": "*" }
|
|
3831
3877
|
});
|
|
3832
3878
|
return {
|
|
3833
|
-
value: ApiCaller.decodeBody(
|
|
3879
|
+
value: ApiCaller.decodeBody(import_protocol19.Operations.putVenue, res),
|
|
3834
3880
|
etag: res.headers.etag
|
|
3835
3881
|
};
|
|
3836
3882
|
} catch (e) {
|
|
@@ -3851,31 +3897,31 @@ var VenuesRepository = class {
|
|
|
3851
3897
|
/** Merge-patches a venue (reads the ETag when not given). */
|
|
3852
3898
|
async patch(venueId, patch, ifMatch) {
|
|
3853
3899
|
const etag = ifMatch ?? (await this.get(venueId)).etag;
|
|
3854
|
-
const res = await this.api.call(
|
|
3900
|
+
const res = await this.api.call(import_protocol19.Operations.patchVenue, {
|
|
3855
3901
|
params: { venueId },
|
|
3856
3902
|
body: patch,
|
|
3857
3903
|
headers: { "if-match": etag }
|
|
3858
3904
|
});
|
|
3859
3905
|
return {
|
|
3860
|
-
value: ApiCaller.decodeBody(
|
|
3906
|
+
value: ApiCaller.decodeBody(import_protocol19.Operations.patchVenue, res),
|
|
3861
3907
|
etag: res.headers.etag
|
|
3862
3908
|
};
|
|
3863
3909
|
}
|
|
3864
3910
|
/** Watches a venue (events, resync re-read, polling while realtime is down). */
|
|
3865
3911
|
watch(venueId, obs, intervalMs = 5e3) {
|
|
3866
3912
|
return this.c.watchResource(
|
|
3867
|
-
|
|
3913
|
+
import_protocol19.DomeTopics.venue(venueId),
|
|
3868
3914
|
async () => (await this.get(venueId)).value,
|
|
3869
3915
|
obs,
|
|
3870
3916
|
{
|
|
3871
3917
|
intervalMs,
|
|
3872
|
-
kinds: /* @__PURE__ */ new Set([
|
|
3918
|
+
kinds: /* @__PURE__ */ new Set([import_protocol19.EventKinds.venueUpdated])
|
|
3873
3919
|
}
|
|
3874
3920
|
);
|
|
3875
3921
|
}
|
|
3876
3922
|
/** Exports the venue as `.dome` bytes. */
|
|
3877
3923
|
async export(venueId = "default") {
|
|
3878
|
-
const res = await this.api.call(
|
|
3924
|
+
const res = await this.api.call(import_protocol19.Operations.exportVenue, {
|
|
3879
3925
|
params: { venueId },
|
|
3880
3926
|
headers: { accept: "application/vnd.nativemind.freedome.dome+zip, application/problem+json" },
|
|
3881
3927
|
timeoutMs: 3e5
|
|
@@ -3884,15 +3930,15 @@ var VenuesRepository = class {
|
|
|
3884
3930
|
}
|
|
3885
3931
|
/** Calibration block with the venue ETag. */
|
|
3886
3932
|
async calibration(venueId = "default") {
|
|
3887
|
-
const res = await this.api.call(
|
|
3933
|
+
const res = await this.api.call(import_protocol19.Operations.getCalibration, { params: { venueId } });
|
|
3888
3934
|
return {
|
|
3889
|
-
value: ApiCaller.decodeBody(
|
|
3935
|
+
value: ApiCaller.decodeBody(import_protocol19.Operations.getCalibration, res),
|
|
3890
3936
|
etag: res.headers.etag
|
|
3891
3937
|
};
|
|
3892
3938
|
}
|
|
3893
3939
|
/** Bytes of a calibration sidecar. */
|
|
3894
3940
|
async calibrationFile(venueId, displayId, file) {
|
|
3895
|
-
return (await this.api.call(
|
|
3941
|
+
return (await this.api.call(import_protocol19.Operations.getCalibrationFile, {
|
|
3896
3942
|
params: { venueId, displayId, file },
|
|
3897
3943
|
headers: { accept: "*/*" }
|
|
3898
3944
|
})).body;
|
|
@@ -3900,21 +3946,21 @@ var VenuesRepository = class {
|
|
|
3900
3946
|
/** Uploads a calibration sidecar (If-Match = venue ETag, read when not given). */
|
|
3901
3947
|
async putCalibrationFile(venueId, displayId, file, bytes, ifMatch) {
|
|
3902
3948
|
const etag = ifMatch ?? (await this.calibration(venueId)).etag;
|
|
3903
|
-
const res = await this.api.call(
|
|
3949
|
+
const res = await this.api.call(import_protocol19.Operations.putCalibrationFile, {
|
|
3904
3950
|
params: { venueId, displayId, file },
|
|
3905
3951
|
bytes,
|
|
3906
3952
|
contentType: CALIBRATION_FILE_TYPES[file],
|
|
3907
3953
|
headers: { "if-match": etag }
|
|
3908
3954
|
});
|
|
3909
3955
|
return {
|
|
3910
|
-
value: ApiCaller.decodeBody(
|
|
3956
|
+
value: ApiCaller.decodeBody(import_protocol19.Operations.putCalibrationFile, res),
|
|
3911
3957
|
etag: res.headers.etag
|
|
3912
3958
|
};
|
|
3913
3959
|
}
|
|
3914
3960
|
};
|
|
3915
3961
|
|
|
3916
3962
|
// src/client.ts
|
|
3917
|
-
var FREEDOME_CLIENT_VERSION = "1.
|
|
3963
|
+
var FREEDOME_CLIENT_VERSION = "1.2.0";
|
|
3918
3964
|
function defaultTransports() {
|
|
3919
3965
|
return { rest: (e) => new FetchTransport(e), sockets: webSocketConnector() };
|
|
3920
3966
|
}
|
|
@@ -3931,6 +3977,7 @@ var FreedomeClient = class {
|
|
|
3931
3977
|
playback;
|
|
3932
3978
|
content;
|
|
3933
3979
|
osc;
|
|
3980
|
+
assistant;
|
|
3934
3981
|
clients;
|
|
3935
3982
|
audio;
|
|
3936
3983
|
audioReactive;
|
|
@@ -4018,6 +4065,7 @@ var FreedomeClient = class {
|
|
|
4018
4065
|
this.playback = new PlaybackRepository(this.ctx);
|
|
4019
4066
|
this.content = new ContentRepository(this.ctx);
|
|
4020
4067
|
this.osc = new OscRepository(this.ctx);
|
|
4068
|
+
this.assistant = new AssistantRepository(this.ctx);
|
|
4021
4069
|
this.clients = new ClientsRepository(this.ctx);
|
|
4022
4070
|
this.audio = new AudioRepository(this.ctx);
|
|
4023
4071
|
this.audioReactive = new AudioReactiveRepository(this.ctx);
|
|
@@ -4039,7 +4087,7 @@ var FreedomeClient = class {
|
|
|
4039
4087
|
*/
|
|
4040
4088
|
get contractVersion() {
|
|
4041
4089
|
const v = this.serverInfo?.contractVersion;
|
|
4042
|
-
return typeof v === "string" ?
|
|
4090
|
+
return typeof v === "string" ? import_protocol20.SemVer.tryParse(v) ?? void 0 : void 0;
|
|
4043
4091
|
}
|
|
4044
4092
|
get state() {
|
|
4045
4093
|
return this.stateValue;
|
|
@@ -4123,7 +4171,7 @@ var FreedomeClient = class {
|
|
|
4123
4171
|
this.set("negotiating");
|
|
4124
4172
|
let info;
|
|
4125
4173
|
try {
|
|
4126
|
-
info = await this.api.json(
|
|
4174
|
+
info = await this.api.json(import_protocol20.Operations.getInfo, { authenticated: false });
|
|
4127
4175
|
} catch (e) {
|
|
4128
4176
|
if (e instanceof NetworkError) {
|
|
4129
4177
|
this.set("offline", "server not reachable");
|
|
@@ -4137,17 +4185,17 @@ var FreedomeClient = class {
|
|
|
4137
4185
|
throw new IncompatibleServerError(
|
|
4138
4186
|
`no Freedome API v1 at ${this.endpointValue.apiBase} (${e.message})`,
|
|
4139
4187
|
[],
|
|
4140
|
-
|
|
4188
|
+
import_protocol20.ProtocolVersions.apiMajors
|
|
4141
4189
|
);
|
|
4142
4190
|
}
|
|
4143
4191
|
const versions = (info.apiVersions ?? []).map(String);
|
|
4144
4192
|
const majors = versions.map((v) => Number.parseInt(v.replace(/^v/, ""), 10));
|
|
4145
|
-
if (!majors.some((m) =>
|
|
4193
|
+
if (!majors.some((m) => import_protocol20.ProtocolVersions.apiMajors.includes(m))) {
|
|
4146
4194
|
this.set("incompatible");
|
|
4147
4195
|
throw new IncompatibleServerError(
|
|
4148
|
-
`server speaks ${versions.join(", ")}, this client v${
|
|
4196
|
+
`server speaks ${versions.join(", ")}, this client v${import_protocol20.ProtocolVersions.apiMajors.join(", v")}`,
|
|
4149
4197
|
versions,
|
|
4150
|
-
|
|
4198
|
+
import_protocol20.ProtocolVersions.apiMajors
|
|
4151
4199
|
);
|
|
4152
4200
|
}
|
|
4153
4201
|
this.serverInfo = info;
|
|
@@ -4166,12 +4214,12 @@ var FreedomeClient = class {
|
|
|
4166
4214
|
return;
|
|
4167
4215
|
case "apiKey":
|
|
4168
4216
|
this.api.authorization = `Bearer ${c.key}`;
|
|
4169
|
-
this.setSession(sessionFromPrincipal(await this.api.json(
|
|
4217
|
+
this.setSession(sessionFromPrincipal(await this.api.json(import_protocol20.Operations.getMe)));
|
|
4170
4218
|
return;
|
|
4171
4219
|
case "password": {
|
|
4172
4220
|
const stored = await this.tokenStore.read(key);
|
|
4173
4221
|
if (stored && await this.tryStored(stored)) return;
|
|
4174
|
-
const t = await this.api.json(
|
|
4222
|
+
const t = await this.api.json(import_protocol20.Operations.createSession, {
|
|
4175
4223
|
body: { username: c.username, password: c.password, client },
|
|
4176
4224
|
authenticated: false
|
|
4177
4225
|
});
|
|
@@ -4187,7 +4235,7 @@ var FreedomeClient = class {
|
|
|
4187
4235
|
case "cloud": {
|
|
4188
4236
|
const stored = await this.tokenStore.read(key);
|
|
4189
4237
|
if (stored && await this.tryStored(stored)) return;
|
|
4190
|
-
const t = await this.api.json(
|
|
4238
|
+
const t = await this.api.json(import_protocol20.Operations.exchangeCloudToken, {
|
|
4191
4239
|
body: { subjectToken: await c.token(), client },
|
|
4192
4240
|
authenticated: false
|
|
4193
4241
|
});
|
|
@@ -4199,7 +4247,7 @@ var FreedomeClient = class {
|
|
|
4199
4247
|
async tryStored(t) {
|
|
4200
4248
|
this.api.authorization = `Bearer ${t.accessToken}`;
|
|
4201
4249
|
try {
|
|
4202
|
-
this.setSession(sessionFromPrincipal(await this.api.json(
|
|
4250
|
+
this.setSession(sessionFromPrincipal(await this.api.json(import_protocol20.Operations.getMe)));
|
|
4203
4251
|
return true;
|
|
4204
4252
|
} catch (e) {
|
|
4205
4253
|
if (!(e instanceof UnauthorizedError)) throw e;
|
|
@@ -4214,7 +4262,7 @@ var FreedomeClient = class {
|
|
|
4214
4262
|
this.setSession(sessionFromTokens(t, user ?? this.sessionValue.user));
|
|
4215
4263
|
}
|
|
4216
4264
|
async pair(p) {
|
|
4217
|
-
let pairing = await this.api.json(
|
|
4265
|
+
let pairing = await this.api.json(import_protocol20.Operations.createPairing, {
|
|
4218
4266
|
body: {
|
|
4219
4267
|
app: p.app,
|
|
4220
4268
|
deviceName: p.deviceName,
|
|
@@ -4237,7 +4285,7 @@ var FreedomeClient = class {
|
|
|
4237
4285
|
while (!["approved", "denied", "expired", "revoked"].includes(pr().status)) {
|
|
4238
4286
|
if (Date.now() > deadline) throw new UnauthorizedError("pairing was not approved in time");
|
|
4239
4287
|
await new Promise((r) => setTimeout(r, this.options.pairingPollIntervalMs));
|
|
4240
|
-
pairing = await this.api.json(
|
|
4288
|
+
pairing = await this.api.json(import_protocol20.Operations.getPairing, {
|
|
4241
4289
|
params: { pairingId: pr().pairingId },
|
|
4242
4290
|
authenticated: false
|
|
4243
4291
|
});
|
|
@@ -4255,7 +4303,7 @@ var FreedomeClient = class {
|
|
|
4255
4303
|
const rt = stored?.refreshToken;
|
|
4256
4304
|
if (!rt) return await this.reauthenticate();
|
|
4257
4305
|
try {
|
|
4258
|
-
const t = await this.api.json(
|
|
4306
|
+
const t = await this.api.json(import_protocol20.Operations.refreshSession, {
|
|
4259
4307
|
body: { refreshToken: rt },
|
|
4260
4308
|
authenticated: false
|
|
4261
4309
|
});
|
|
@@ -4293,7 +4341,7 @@ var FreedomeClient = class {
|
|
|
4293
4341
|
async logout() {
|
|
4294
4342
|
if (this.api.authorization && this.credentials.kind !== "apiKey") {
|
|
4295
4343
|
try {
|
|
4296
|
-
await this.api.call(
|
|
4344
|
+
await this.api.call(import_protocol20.Operations.deleteSession);
|
|
4297
4345
|
} catch (e) {
|
|
4298
4346
|
this.log("warning", "logout", e);
|
|
4299
4347
|
}
|
|
@@ -4329,7 +4377,7 @@ var FreedomeClient = class {
|
|
|
4329
4377
|
);
|
|
4330
4378
|
return GraphqlWsChannel.open(s2, hello, { ...o, ...log });
|
|
4331
4379
|
}
|
|
4332
|
-
const s = await sockets(this.endpointValue, "/api/v1/ws", [
|
|
4380
|
+
const s = await sockets(this.endpointValue, "/api/v1/ws", [import_protocol20.WS_SUBPROTOCOL], o.timeoutMs);
|
|
4333
4381
|
return WsChannel.open(s, hello, { ...o, ...log });
|
|
4334
4382
|
};
|
|
4335
4383
|
}
|
|
@@ -4424,9 +4472,9 @@ var FreedomeClient = class {
|
|
|
4424
4472
|
async replayOutbox() {
|
|
4425
4473
|
if (!this.outbox) return;
|
|
4426
4474
|
await this.ctx.replayOutbox(async (e) => {
|
|
4427
|
-
const op =
|
|
4475
|
+
const op = import_protocol20.Operations[e.operationId];
|
|
4428
4476
|
if (!op || op.method !== "PUT" && op.method !== "PATCH") return void 0;
|
|
4429
|
-
const get = Object.values(
|
|
4477
|
+
const get = Object.values(import_protocol20.Operations).find(
|
|
4430
4478
|
(o) => o.method === "GET" && o.path === op.path
|
|
4431
4479
|
);
|
|
4432
4480
|
if (!get) return void 0;
|
|
@@ -4447,7 +4495,7 @@ var FreedomeClient = class {
|
|
|
4447
4495
|
async seedSeq(filters) {
|
|
4448
4496
|
if (this.hub.lastSeq !== void 0) return;
|
|
4449
4497
|
try {
|
|
4450
|
-
const page = await this.api.json(
|
|
4498
|
+
const page = await this.api.json(import_protocol20.Operations.listEvents, {
|
|
4451
4499
|
query: { topics: filters.join(","), limit: "1" }
|
|
4452
4500
|
});
|
|
4453
4501
|
if (typeof page.lastSeq === "number") this.hub.seed(page.lastSeq);
|
|
@@ -4566,7 +4614,7 @@ var FreedomeClient = class {
|
|
|
4566
4614
|
};
|
|
4567
4615
|
|
|
4568
4616
|
// src/discovery.ts
|
|
4569
|
-
var
|
|
4617
|
+
var import_protocol21 = require("@freedome/protocol");
|
|
4570
4618
|
|
|
4571
4619
|
// src/endpoint.ts
|
|
4572
4620
|
var FreedomeEndpoint = class _FreedomeEndpoint {
|
|
@@ -4694,8 +4742,8 @@ async function probe(endpoint, timeoutMs = 2e3) {
|
|
|
4694
4742
|
try {
|
|
4695
4743
|
const res = await t.send(
|
|
4696
4744
|
{
|
|
4697
|
-
method:
|
|
4698
|
-
path:
|
|
4745
|
+
method: import_protocol21.Operations.getInfo.method,
|
|
4746
|
+
path: import_protocol21.Operations.getInfo.path,
|
|
4699
4747
|
headers: { accept: "application/json" }
|
|
4700
4748
|
},
|
|
4701
4749
|
timeoutMs
|
|
@@ -4757,11 +4805,12 @@ var CompositeDiscovery = class {
|
|
|
4757
4805
|
};
|
|
4758
4806
|
|
|
4759
4807
|
// src/index.ts
|
|
4760
|
-
var
|
|
4808
|
+
var import_protocol22 = require("@freedome/protocol");
|
|
4761
4809
|
var PACKAGE_NAME = "@freedome/client";
|
|
4762
4810
|
// Annotate the CommonJS export names for ESM import in node:
|
|
4763
4811
|
0 && (module.exports = {
|
|
4764
4812
|
ApiCaller,
|
|
4813
|
+
AssistantRepository,
|
|
4765
4814
|
AudioReactiveRepository,
|
|
4766
4815
|
AudioRepository,
|
|
4767
4816
|
BackoffPolicy,
|