@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/dist/index.js CHANGED
@@ -331,7 +331,7 @@ var BackoffPolicy = class {
331
331
 
332
332
  // src/client.ts
333
333
  import {
334
- Operations as Operations13,
334
+ Operations as Operations14,
335
335
  ProtocolVersions as ProtocolVersions2,
336
336
  SemVer as SemVer2,
337
337
  WS_SUBPROTOCOL
@@ -2107,10 +2107,38 @@ var CalibrationRepository = class {
2107
2107
  }
2108
2108
  };
2109
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
+
2110
2138
  // src/repositories/clients.ts
2111
2139
  import {
2112
2140
  DomeTopics as DomeTopics4,
2113
- Operations as Operations5
2141
+ Operations as Operations6
2114
2142
  } from "@freedome/protocol";
2115
2143
  var ClientsRepository = class {
2116
2144
  constructor(c) {
@@ -2118,16 +2146,16 @@ var ClientsRepository = class {
2118
2146
  }
2119
2147
  c;
2120
2148
  register(registration) {
2121
- return this.c.api.json(Operations5.registerClient, { body: registration });
2149
+ return this.c.api.json(Operations6.registerClient, { body: registration });
2122
2150
  }
2123
2151
  list() {
2124
- return readAllPages(this.c.api, Operations5.listClients);
2152
+ return readAllPages(this.c.api, Operations6.listClients);
2125
2153
  }
2126
2154
  async telemetry(clientId, batch) {
2127
- await this.c.api.call(Operations5.postClientTelemetry, { params: { clientId }, body: batch });
2155
+ await this.c.api.call(Operations6.postClientTelemetry, { params: { clientId }, body: batch });
2128
2156
  }
2129
2157
  async unregister(clientId) {
2130
- await this.c.api.call(Operations5.unregisterClient, { params: { clientId } });
2158
+ await this.c.api.call(Operations6.unregisterClient, { params: { clientId } });
2131
2159
  }
2132
2160
  /** Commands the dome sends to this device (`clients/{id}/commands`). */
2133
2161
  commands(clientId, fn) {
@@ -2141,11 +2169,11 @@ var ClientsRepository = class {
2141
2169
  // src/repositories/content.ts
2142
2170
  import {
2143
2171
  DomeTopics as DomeTopics5,
2144
- Operations as Operations7
2172
+ Operations as Operations8
2145
2173
  } from "@freedome/protocol";
2146
2174
 
2147
2175
  // src/repositories/upload.ts
2148
- import { Operations as Operations6 } from "@freedome/protocol";
2176
+ import { Operations as Operations7 } from "@freedome/protocol";
2149
2177
  var MAX_UPLOAD_CHUNK = 95 * 1024 * 1024;
2150
2178
  var BytesContentSource = class {
2151
2179
  constructor(bytes, name, contentType) {
@@ -2250,7 +2278,7 @@ var UploadTask = class {
2250
2278
  const id = this.uploadIdValue;
2251
2279
  if (id) {
2252
2280
  try {
2253
- await this.c.api.call(Operations6.deleteUpload, {
2281
+ await this.c.api.call(Operations7.deleteUpload, {
2254
2282
  params: { uploadId: id },
2255
2283
  headers: { "tus-resumable": "1.0.0" }
2256
2284
  });
@@ -2311,7 +2339,7 @@ var UploadTask = class {
2311
2339
  }
2312
2340
  const api = this.c.api;
2313
2341
  if (!this.uploadIdValue) {
2314
- const res = await api.call(Operations6.createUpload, {
2342
+ const res = await api.call(Operations7.createUpload, {
2315
2343
  headers: {
2316
2344
  "tus-resumable": "1.0.0",
2317
2345
  "upload-length": String(total),
@@ -2339,7 +2367,7 @@ var UploadTask = class {
2339
2367
  const chunk = await this.source.read(this.offset, end);
2340
2368
  let res;
2341
2369
  try {
2342
- res = await api.call(Operations6.appendUpload, {
2370
+ res = await api.call(Operations7.appendUpload, {
2343
2371
  params: { uploadId: this.uploadIdValue },
2344
2372
  bytes: chunk,
2345
2373
  contentType: "application/offset+octet-stream",
@@ -2367,7 +2395,7 @@ var UploadTask = class {
2367
2395
  uploadId: this.uploadIdValue,
2368
2396
  name: this.o.asset?.name ?? this.source.name
2369
2397
  };
2370
- asset = await api.json(Operations6.createAsset, { body: req });
2398
+ asset = await api.json(Operations7.createAsset, { body: req });
2371
2399
  }
2372
2400
  this.set("done");
2373
2401
  if (!this.finished) {
@@ -2381,7 +2409,7 @@ var UploadTask = class {
2381
2409
  this.progress.close();
2382
2410
  }
2383
2411
  async headOffset() {
2384
- const res = await this.c.api.call(Operations6.getUploadOffset, {
2412
+ const res = await this.c.api.call(Operations7.getUploadOffset, {
2385
2413
  params: { uploadId: this.uploadIdValue },
2386
2414
  headers: { "tus-resumable": "1.0.0" }
2387
2415
  });
@@ -2415,7 +2443,7 @@ var ContentRepository = class {
2415
2443
  /** One page of assets (first pages cache-backed). */
2416
2444
  list(query = {}, cursor) {
2417
2445
  const q = { type: query.type, tag: query.tag, q: query.q, status: query.status };
2418
- const read = () => readPage(this.c.api, Operations7.listAssets, {
2446
+ const read = () => readPage(this.c.api, Operations8.listAssets, {
2419
2447
  query: q,
2420
2448
  cursor,
2421
2449
  limit: query.limit
@@ -2432,7 +2460,26 @@ var ContentRepository = class {
2432
2460
  );
2433
2461
  }
2434
2462
  get(assetId) {
2435
- return this.c.api.json(Operations7.getAsset, { params: { assetId } });
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;
2436
2483
  }
2437
2484
  /** Starts a resumable upload creating an asset (await `task.done`). */
2438
2485
  upload(source, o = {}) {
@@ -2471,7 +2518,7 @@ var ContentRepository = class {
2471
2518
  /** Uploads [source] and runs an import job; returns the finished job (rejects when it failed). */
2472
2519
  async importFile(source, format, o = {}) {
2473
2520
  const up = await this.uploadFor("import", source).done;
2474
- const job = await this.c.api.json(Operations7.startImport, {
2521
+ const job = await this.c.api.json(Operations8.startImport, {
2475
2522
  body: {
2476
2523
  uploadId: up.uploadId,
2477
2524
  format,
@@ -2507,13 +2554,13 @@ var ContentRepository = class {
2507
2554
  if (Date.now() > deadline)
2508
2555
  throw new RequestTimeoutError(`job ${j.id} not finished in time`, o.timeoutMs);
2509
2556
  await new Promise((r) => setTimeout(r, o.pollMs ?? 500));
2510
- j = await this.c.api.json(Operations7.getJob, { params: { jobId: j.id } });
2557
+ j = await this.c.api.json(Operations8.getJob, { params: { jobId: j.id } });
2511
2558
  }
2512
2559
  }
2513
2560
  /** Merge-patches an asset (ETag read first when not given). */
2514
2561
  async patch(assetId, patch, ifMatch) {
2515
2562
  const etag = ifMatch ?? `"r${(await this.get(assetId)).revision}"`;
2516
- return this.c.api.json(Operations7.patchAsset, {
2563
+ return this.c.api.json(Operations8.patchAsset, {
2517
2564
  params: { assetId },
2518
2565
  body: patch,
2519
2566
  headers: { "if-match": etag }
@@ -2522,23 +2569,23 @@ var ContentRepository = class {
2522
2569
  /** Deletes an asset (409 while referenced unless [force]). */
2523
2570
  async delete(assetId, o = {}) {
2524
2571
  const etag = o.ifMatch ?? `"r${(await this.get(assetId)).revision}"`;
2525
- await this.c.api.call(Operations7.deleteAsset, {
2572
+ await this.c.api.call(Operations8.deleteAsset, {
2526
2573
  params: { assetId },
2527
2574
  query: o.force ? { force: "true" } : {},
2528
2575
  headers: { "if-match": etag }
2529
2576
  });
2530
2577
  }
2531
2578
  async thumbnail(assetId, size) {
2532
- return (await this.c.api.call(Operations7.getAssetThumbnail, {
2579
+ return (await this.c.api.call(Operations8.getAssetThumbnail, {
2533
2580
  params: { assetId },
2534
2581
  query: { size: size?.toString() }
2535
2582
  })).body;
2536
2583
  }
2537
2584
  async download(assetId) {
2538
- return (await this.c.api.call(Operations7.downloadAsset, { params: { assetId }, timeoutMs: 18e5 })).body;
2585
+ return (await this.c.api.call(Operations8.downloadAsset, { params: { assetId }, timeoutMs: 18e5 })).body;
2539
2586
  }
2540
2587
  storage() {
2541
- return this.c.api.json(Operations7.getStorageStats);
2588
+ return this.c.api.json(Operations8.getStorageStats);
2542
2589
  }
2543
2590
  /** Changes of the content store. */
2544
2591
  changes(fn) {
@@ -2553,59 +2600,59 @@ var ContentRepository = class {
2553
2600
  });
2554
2601
  }
2555
2602
  listShows(o = {}) {
2556
- return readPage(this.c.api, Operations7.listShows, {
2603
+ return readPage(this.c.api, Operations8.listShows, {
2557
2604
  query: { q: o.q },
2558
2605
  cursor: o.cursor,
2559
2606
  limit: o.limit
2560
2607
  });
2561
2608
  }
2562
2609
  async getShow(showId) {
2563
- const res = await this.c.api.call(Operations7.getShow, { params: { showId } });
2610
+ const res = await this.c.api.call(Operations8.getShow, { params: { showId } });
2564
2611
  return {
2565
- value: ApiCaller.decodeBody(Operations7.getShow, res),
2612
+ value: ApiCaller.decodeBody(Operations8.getShow, res),
2566
2613
  etag: res.headers.etag
2567
2614
  };
2568
2615
  }
2569
2616
  async createShow(body) {
2570
- const res = await this.c.api.call(Operations7.createShow, { body });
2617
+ const res = await this.c.api.call(Operations8.createShow, { body });
2571
2618
  return {
2572
- value: ApiCaller.decodeBody(Operations7.createShow, res),
2619
+ value: ApiCaller.decodeBody(Operations8.createShow, res),
2573
2620
  etag: res.headers.etag
2574
2621
  };
2575
2622
  }
2576
2623
  /** Replaces a show (`ifMatch`; without: create with If-None-Match: *). Queued in the outbox while offline. */
2577
2624
  async saveShow(showId, body, ifMatch) {
2578
- const res = await this.c.idempotentWrite(Operations7.putShow, {
2625
+ const res = await this.c.idempotentWrite(Operations8.putShow, {
2579
2626
  params: { showId },
2580
2627
  body,
2581
2628
  headers: ifMatch ? { "if-match": ifMatch } : { "if-none-match": "*" }
2582
2629
  });
2583
2630
  return {
2584
- value: ApiCaller.decodeBody(Operations7.putShow, res),
2631
+ value: ApiCaller.decodeBody(Operations8.putShow, res),
2585
2632
  etag: res.headers.etag
2586
2633
  };
2587
2634
  }
2588
2635
  async patchShow(showId, patch, ifMatch) {
2589
2636
  const etag = ifMatch ?? (await this.getShow(showId)).etag;
2590
- const res = await this.c.api.call(Operations7.patchShow, {
2637
+ const res = await this.c.api.call(Operations8.patchShow, {
2591
2638
  params: { showId },
2592
2639
  body: patch,
2593
2640
  headers: { "if-match": etag }
2594
2641
  });
2595
2642
  return {
2596
- value: ApiCaller.decodeBody(Operations7.patchShow, res),
2643
+ value: ApiCaller.decodeBody(Operations8.patchShow, res),
2597
2644
  etag: res.headers.etag
2598
2645
  };
2599
2646
  }
2600
2647
  async deleteShow(showId, ifMatch) {
2601
- await this.c.api.call(Operations7.deleteShow, {
2648
+ await this.c.api.call(Operations8.deleteShow, {
2602
2649
  params: { showId },
2603
2650
  headers: { "if-match": ifMatch }
2604
2651
  });
2605
2652
  }
2606
2653
  /** Exports a show as `.dome` bytes. */
2607
2654
  async exportShow(showId, embedAssets = false) {
2608
- return (await this.c.api.call(Operations7.exportShow, {
2655
+ return (await this.c.api.call(Operations8.exportShow, {
2609
2656
  params: { showId },
2610
2657
  query: embedAssets ? { embedAssets: "true" } : {},
2611
2658
  timeoutMs: 18e5
@@ -2613,7 +2660,7 @@ var ContentRepository = class {
2613
2660
  }
2614
2661
  /** tus capabilities. */
2615
2662
  async uploadCapabilities() {
2616
- const res = await this.c.api.call(Operations7.getUploadCapabilities);
2663
+ const res = await this.c.api.call(Operations8.getUploadCapabilities);
2617
2664
  const list = (h) => (res.headers[h] ?? "").split(",").map((x) => x.trim()).filter(Boolean);
2618
2665
  const max = Number.parseInt(res.headers["tus-max-size"] ?? "", 10);
2619
2666
  return {
@@ -2624,7 +2671,7 @@ var ContentRepository = class {
2624
2671
  };
2625
2672
  }
2626
2673
  uploadStatus(uploadId) {
2627
- return this.c.api.json(Operations7.getUpload, { params: { uploadId } });
2674
+ return this.c.api.json(Operations8.getUpload, { params: { uploadId } });
2628
2675
  }
2629
2676
  /** Watch hook used by apps showing one asset. */
2630
2677
  watchAsset(assetId, fn) {
@@ -2637,29 +2684,29 @@ var ShowParts = class {
2637
2684
  }
2638
2685
  c;
2639
2686
  async etag(showId, ifMatch) {
2640
- return ifMatch ?? (await this.c.api.call(Operations7.getShow, { params: { showId } })).headers.etag;
2687
+ return ifMatch ?? (await this.c.api.call(Operations8.getShow, { params: { showId } })).headers.etag;
2641
2688
  }
2642
2689
  get(part, showId, itemId) {
2643
- return this.c.api.json(Operations7[`get${part}`], { params: { showId, itemId } });
2690
+ return this.c.api.json(Operations8[`get${part}`], { params: { showId, itemId } });
2644
2691
  }
2645
2692
  async put(part, showId, item, ifMatch) {
2646
- return this.c.api.json(Operations7[`put${part}`], {
2693
+ return this.c.api.json(Operations8[`put${part}`], {
2647
2694
  params: { showId, itemId: item.id },
2648
2695
  body: item,
2649
2696
  headers: { "if-match": await this.etag(showId, ifMatch) }
2650
2697
  });
2651
2698
  }
2652
2699
  async delete(part, showId, itemId, ifMatch) {
2653
- await this.c.api.call(Operations7[`delete${part}`], {
2700
+ await this.c.api.call(Operations8[`delete${part}`], {
2654
2701
  params: { showId, itemId },
2655
2702
  headers: { "if-match": await this.etag(showId, ifMatch) }
2656
2703
  });
2657
2704
  }
2658
2705
  matrix(showId) {
2659
- return this.c.api.json(Operations7.getMatrix, { params: { showId } });
2706
+ return this.c.api.json(Operations8.getMatrix, { params: { showId } });
2660
2707
  }
2661
2708
  async putMatrix(showId, matrix, ifMatch) {
2662
- return this.c.api.json(Operations7.putMatrix, {
2709
+ return this.c.api.json(Operations8.putMatrix, {
2663
2710
  params: { showId },
2664
2711
  body: matrix,
2665
2712
  headers: { "if-match": await this.etag(showId, ifMatch) }
@@ -2671,7 +2718,7 @@ var ShowParts = class {
2671
2718
  import {
2672
2719
  DomeTopics as DomeTopics6,
2673
2720
  EventKinds as EventKinds3,
2674
- Operations as Operations8
2721
+ Operations as Operations9
2675
2722
  } from "@freedome/protocol";
2676
2723
  var EngineRepository = class {
2677
2724
  constructor(c) {
@@ -2680,23 +2727,23 @@ var EngineRepository = class {
2680
2727
  c;
2681
2728
  /** Every engine (visual, audio, …; `name@node` on multi-node installations). */
2682
2729
  engines() {
2683
- return readAllPages(this.c.api, Operations8.listEngines);
2730
+ return readAllPages(this.c.api, Operations9.listEngines);
2684
2731
  }
2685
2732
  /** Displays of a venue. */
2686
2733
  outputs(venueId = "default") {
2687
- return readAllPages(this.c.api, Operations8.listDisplays, {
2734
+ return readAllPages(this.c.api, Operations9.listDisplays, {
2688
2735
  params: { venueId }
2689
2736
  });
2690
2737
  }
2691
2738
  /** One display. */
2692
2739
  display(displayId, venueId = "default") {
2693
- return this.c.api.json(Operations8.getDisplay, {
2740
+ return this.c.api.json(Operations9.getDisplay, {
2694
2741
  params: { venueId, displayId }
2695
2742
  });
2696
2743
  }
2697
2744
  /** Shows a test pattern on a display. */
2698
2745
  showTestPattern(displayId, pattern, venueId = "default") {
2699
- return this.c.api.json(Operations8.setTestPattern, {
2746
+ return this.c.api.json(Operations9.setTestPattern, {
2700
2747
  params: { venueId, displayId },
2701
2748
  body: pattern,
2702
2749
  preferRealtime: true
@@ -2712,21 +2759,21 @@ var EngineRepository = class {
2712
2759
  }
2713
2760
  /** Flashes the id overlay. */
2714
2761
  async identify(displayId, durationMs, venueId = "default") {
2715
- await this.c.api.call(Operations8.identifyDisplay, {
2762
+ await this.c.api.call(Operations9.identifyDisplay, {
2716
2763
  params: { venueId, displayId },
2717
2764
  body: durationMs === void 0 ? {} : { durationS: durationMs / 1e3 }
2718
2765
  });
2719
2766
  }
2720
2767
  /** Power / shutter (what `state.capabilities` lists). */
2721
2768
  setPower(displayId, request, venueId = "default") {
2722
- return this.c.api.json(Operations8.setDisplayPower, {
2769
+ return this.c.api.json(Operations9.setDisplayPower, {
2723
2770
  params: { venueId, displayId },
2724
2771
  body: request
2725
2772
  });
2726
2773
  }
2727
2774
  /** Status of engine [name]. */
2728
2775
  async engineStatus(name = "visual") {
2729
- const s = await this.c.api.json(Operations8.getEngine, { params: { name } });
2776
+ const s = await this.c.api.json(Operations9.getEngine, { params: { name } });
2730
2777
  if (name === "visual") this.c.onEngineHealth?.(String(s.status));
2731
2778
  return s;
2732
2779
  }
@@ -2749,7 +2796,7 @@ var EngineRepository = class {
2749
2796
  };
2750
2797
 
2751
2798
  // src/repositories/gateways.ts
2752
- import { Operations as Operations9 } from "@freedome/protocol";
2799
+ import { Operations as Operations10 } from "@freedome/protocol";
2753
2800
  var GatewaysRepository = class {
2754
2801
  constructor(c) {
2755
2802
  this.c = c;
@@ -2757,13 +2804,13 @@ var GatewaysRepository = class {
2757
2804
  c;
2758
2805
  /** Every gateway. */
2759
2806
  list() {
2760
- return readAllPages(this.c.api, Operations9.listGateways, {});
2807
+ return readAllPages(this.c.api, Operations10.listGateways, {});
2761
2808
  }
2762
2809
  /** One gateway with its ETag. */
2763
2810
  async get(gatewayId) {
2764
- const res = await this.c.api.call(Operations9.getGateway, { params: { gatewayId } });
2811
+ const res = await this.c.api.call(Operations10.getGateway, { params: { gatewayId } });
2765
2812
  return {
2766
- value: ApiCaller.decodeBody(Operations9.getGateway, res),
2813
+ value: ApiCaller.decodeBody(Operations10.getGateway, res),
2767
2814
  etag: res.headers.etag
2768
2815
  };
2769
2816
  }
@@ -2773,24 +2820,24 @@ var GatewaysRepository = class {
2773
2820
  */
2774
2821
  async patch(gatewayId, patch, o = {}) {
2775
2822
  const etag = o.ifMatch ?? (await this.get(gatewayId)).etag;
2776
- const res = await this.c.api.call(Operations9.patchGateway, {
2823
+ const res = await this.c.api.call(Operations10.patchGateway, {
2777
2824
  params: { gatewayId },
2778
2825
  body: patch,
2779
2826
  headers: { "if-match": etag }
2780
2827
  });
2781
2828
  return {
2782
- value: ApiCaller.decodeBody(Operations9.patchGateway, res),
2829
+ value: ApiCaller.decodeBody(Operations10.patchGateway, res),
2783
2830
  etag: res.headers.etag
2784
2831
  };
2785
2832
  }
2786
2833
  /** Runs the gateway's connectivity test. */
2787
2834
  test(gatewayId) {
2788
- return this.c.api.json(Operations9.testGateway, { params: { gatewayId } });
2835
+ return this.c.api.json(Operations10.testGateway, { params: { gatewayId } });
2789
2836
  }
2790
2837
  };
2791
2838
 
2792
2839
  // src/repositories/osc.ts
2793
- import { DomeTopics as DomeTopics7, Operations as Operations10 } from "@freedome/protocol";
2840
+ import { DomeTopics as DomeTopics7, Operations as Operations11 } from "@freedome/protocol";
2794
2841
  function oscArg(a) {
2795
2842
  if (a !== null && typeof a === "object" && "type" in a && !(a instanceof Uint8Array) && !(a instanceof Date))
2796
2843
  return a;
@@ -2817,7 +2864,7 @@ var OscRepository = class {
2817
2864
  async send(address, args, target) {
2818
2865
  if (!address.startsWith("/")) throw new TypeError("OSC address must start with /");
2819
2866
  const body = { target, address, args: args.map(oscArg) };
2820
- await this.c.api.call(Operations10.sendOsc, { body, preferRealtime: true });
2867
+ await this.c.api.call(Operations11.sendOsc, { body, preferRealtime: true });
2821
2868
  }
2822
2869
  /** OSC traffic of gateways (`gateway.message` events). */
2823
2870
  messages(fn, gatewayId = "+") {
@@ -2836,7 +2883,7 @@ var OscRepository = class {
2836
2883
  import {
2837
2884
  DomeTopics as DomeTopics8,
2838
2885
  EventKinds as EventKinds4,
2839
- Operations as Operations11,
2886
+ Operations as Operations12,
2840
2887
  jsonMergePatch as jsonMergePatch3,
2841
2888
  rfc3339Millis as rfc3339Millis3
2842
2889
  } from "@freedome/protocol";
@@ -2961,7 +3008,7 @@ var PlayerHandle = class {
2961
3008
  const snap = await this.c.cachedRead(
2962
3009
  `players/${this.venueId}/${this.playerId}`,
2963
3010
  async () => {
2964
- const s = await this.c.api.json(Operations11.getPlayer, { params: this.params });
3011
+ const s = await this.c.api.json(Operations12.getPlayer, { params: this.params });
2965
3012
  return [{ state: s }, s];
2966
3013
  },
2967
3014
  (json, asOf) => ({ state: json, stale: true, asOf })
@@ -2993,7 +3040,7 @@ var PlayerHandle = class {
2993
3040
  /** Plays [target] (optionally from [positionMs], at server time [at] for multi-node sync). */
2994
3041
  async play(target, o = {}) {
2995
3042
  if (target.kind === "app") {
2996
- await this.c.api.call(Operations11.publishAppPayload, {
3043
+ await this.c.api.call(Operations12.publishAppPayload, {
2997
3044
  params: { app: target.app },
2998
3045
  body: target.payload,
2999
3046
  preferRealtime: true
@@ -3012,39 +3059,39 @@ var PlayerHandle = class {
3012
3059
  } else if (target.kind === "asset") req.assetId = target.assetId;
3013
3060
  if (o.positionMs !== void 0) req.position = o.positionMs / 1e3;
3014
3061
  if (o.at) req.at = rfc3339Millis3(o.at);
3015
- return this.command(Operations11.play, req);
3062
+ return this.command(Operations12.play, req);
3016
3063
  }
3017
3064
  pause() {
3018
- return this.command(Operations11.pause);
3065
+ return this.command(Operations12.pause);
3019
3066
  }
3020
3067
  resume() {
3021
- return this.command(Operations11.resume);
3068
+ return this.command(Operations12.resume);
3022
3069
  }
3023
3070
  stop() {
3024
- return this.command(Operations11.stop);
3071
+ return this.command(Operations12.stop);
3025
3072
  }
3026
3073
  next() {
3027
- return this.command(Operations11.next);
3074
+ return this.command(Operations12.next);
3028
3075
  }
3029
3076
  previous() {
3030
- return this.command(Operations11.previous);
3077
+ return this.command(Operations12.previous);
3031
3078
  }
3032
3079
  /** Seeks (coalesced while scrubbing). */
3033
3080
  seek(positionMs) {
3034
3081
  return this.fader(
3035
3082
  "seek",
3036
3083
  { position: positionMs / 1e3 },
3037
- (b) => this.command(Operations11.seek, b)
3084
+ (b) => this.command(Operations12.seek, b)
3038
3085
  );
3039
3086
  }
3040
3087
  seekToMarker(marker) {
3041
- return this.command(Operations11.seek, { marker });
3088
+ return this.command(Operations12.seek, { marker });
3042
3089
  }
3043
3090
  patch(body) {
3044
3091
  return this.fader(
3045
3092
  `patch:${Object.keys(body).join(",")}`,
3046
3093
  body,
3047
- (b) => this.command(Operations11.patchPlayer, b)
3094
+ (b) => this.command(Operations12.patchPlayer, b)
3048
3095
  );
3049
3096
  }
3050
3097
  /** Player volume 0..1 (fader). */
@@ -3094,7 +3141,7 @@ var PlaybackRepository = class {
3094
3141
  return this.main.watch(fn);
3095
3142
  }
3096
3143
  list(venueId = "default") {
3097
- return readAllPages(this.c.api, Operations11.listPlayers, { params: { venueId } });
3144
+ return readAllPages(this.c.api, Operations12.listPlayers, { params: { venueId } });
3098
3145
  }
3099
3146
  play(target, o = {}) {
3100
3147
  return this.main.play(target, o);
@@ -3119,7 +3166,7 @@ var PlaybackRepository = class {
3119
3166
  }
3120
3167
  /** Fires cue [cueId] of the active show (or of [showId]). */
3121
3168
  async cue(cueId, o = {}) {
3122
- await this.c.api.call(Operations11.fireCue, {
3169
+ await this.c.api.call(Operations12.fireCue, {
3123
3170
  params: { venueId: o.venueId ?? "default", cueId },
3124
3171
  body: o.showId ? { showId: o.showId } : {},
3125
3172
  preferRealtime: true
@@ -3127,21 +3174,21 @@ var PlaybackRepository = class {
3127
3174
  }
3128
3175
  /** Loads a show onto the venue. */
3129
3176
  async setActiveShow(showId, o = {}) {
3130
- await this.c.api.call(Operations11.setActiveShow, {
3177
+ await this.c.api.call(Operations12.setActiveShow, {
3131
3178
  params: { venueId: o.venueId ?? "default" },
3132
3179
  body: { showId, autoplay: o.autoplay ?? false }
3133
3180
  });
3134
3181
  }
3135
3182
  activeShow(venueId = "default") {
3136
- return this.c.api.json(Operations11.getActiveShow, { params: { venueId } });
3183
+ return this.c.api.json(Operations12.getActiveShow, { params: { venueId } });
3137
3184
  }
3138
3185
  parameters(venueId = "default") {
3139
- return readAllPages(this.c.api, Operations11.listParameters, {
3186
+ return readAllPages(this.c.api, Operations12.listParameters, {
3140
3187
  params: { venueId }
3141
3188
  });
3142
3189
  }
3143
3190
  parameter(path, venueId = "default") {
3144
- return this.c.api.json(Operations11.getParameter, { params: { venueId, path } });
3191
+ return this.c.api.json(Operations12.getParameter, { params: { venueId, path } });
3145
3192
  }
3146
3193
  /** Sets a parameter (fader; coalesced). */
3147
3194
  async setParameter(path, value, venueId = "default") {
@@ -3149,7 +3196,7 @@ var PlaybackRepository = class {
3149
3196
  let f = this.outputFaders.get(k);
3150
3197
  if (!f) {
3151
3198
  f = new Fader(async (b) => {
3152
- await this.c.api.call(Operations11.setParameter, {
3199
+ await this.c.api.call(Operations12.setParameter, {
3153
3200
  params: { venueId, path },
3154
3201
  body: b,
3155
3202
  preferRealtime: true
@@ -3162,14 +3209,14 @@ var PlaybackRepository = class {
3162
3209
  }
3163
3210
  /** Removes every payload an app published. */
3164
3211
  async clearAppPayloads(app) {
3165
- await this.c.api.call(Operations11.clearAppPayloads, { params: { app }, preferRealtime: true });
3212
+ await this.c.api.call(Operations12.clearAppPayloads, { params: { app }, preferRealtime: true });
3166
3213
  }
3167
3214
  /** Master output of a venue. */
3168
3215
  readOutput(venueId = "default") {
3169
3216
  return this.c.cachedRead(
3170
3217
  `output/${venueId}`,
3171
3218
  async () => {
3172
- const o = await this.c.api.json(Operations11.getOutput, { params: { venueId } });
3219
+ const o = await this.c.api.json(Operations12.getOutput, { params: { venueId } });
3173
3220
  return [o, o];
3174
3221
  },
3175
3222
  (json) => json
@@ -3198,7 +3245,7 @@ var PlaybackRepository = class {
3198
3245
  let f = this.outputFaders.get(k);
3199
3246
  if (!f) {
3200
3247
  f = new Fader(
3201
- (b) => this.c.api.json(Operations11.patchOutput, {
3248
+ (b) => this.c.api.json(Operations12.patchOutput, {
3202
3249
  params: { venueId },
3203
3250
  body: b,
3204
3251
  preferRealtime: true
@@ -3232,7 +3279,7 @@ var PlaybackRepository = class {
3232
3279
  import {
3233
3280
  DomeTopics as DomeTopics9,
3234
3281
  EventKinds as EventKinds5,
3235
- Operations as Operations12
3282
+ Operations as Operations13
3236
3283
  } from "@freedome/protocol";
3237
3284
  var CALIBRATION_FILE_TYPES = {
3238
3285
  warp: "application/vnd.nativemind.freedome.fdmesh",
@@ -3252,7 +3299,7 @@ var VenuesRepository = class {
3252
3299
  return this.c.cachedRead(
3253
3300
  "venues",
3254
3301
  async () => {
3255
- const l = await readAllPages(this.api, Operations12.listVenues);
3302
+ const l = await readAllPages(this.api, Operations13.listVenues);
3256
3303
  return [{ value: l, etag: void 0 }, l];
3257
3304
  },
3258
3305
  (json, asOf) => ({ value: json, etag: void 0, stale: true, asOf })
@@ -3260,8 +3307,8 @@ var VenuesRepository = class {
3260
3307
  }
3261
3308
  /** One venue with its ETag (`default` = the active venue). */
3262
3309
  async get(venueId = "default") {
3263
- const res = await this.api.call(Operations12.getVenue, { params: { venueId } });
3264
- return { value: ApiCaller.decodeBody(Operations12.getVenue, res), etag: res.headers.etag };
3310
+ const res = await this.api.call(Operations13.getVenue, { params: { venueId } });
3311
+ return { value: ApiCaller.decodeBody(Operations13.getVenue, res), etag: res.headers.etag };
3265
3312
  }
3266
3313
  /** The venue the server runs now. */
3267
3314
  async current() {
@@ -3269,22 +3316,22 @@ var VenuesRepository = class {
3269
3316
  }
3270
3317
  /** Creates a venue (`POST /venues`; id = `meta.id`). */
3271
3318
  async create(body) {
3272
- const res = await this.api.call(Operations12.createVenue, { body });
3319
+ const res = await this.api.call(Operations13.createVenue, { body });
3273
3320
  return {
3274
- value: ApiCaller.decodeBody(Operations12.createVenue, res),
3321
+ value: ApiCaller.decodeBody(Operations13.createVenue, res),
3275
3322
  etag: res.headers.etag
3276
3323
  };
3277
3324
  }
3278
3325
  /** Replaces a venue (`ifMatch` = ETag; without it: create with If-None-Match: *). 409 / 412 → ConflictError with `latest`. */
3279
3326
  async save(venueId, body, ifMatch) {
3280
3327
  try {
3281
- const res = await this.api.call(Operations12.putVenue, {
3328
+ const res = await this.api.call(Operations13.putVenue, {
3282
3329
  params: { venueId },
3283
3330
  body,
3284
3331
  headers: ifMatch ? { "if-match": ifMatch } : { "if-none-match": "*" }
3285
3332
  });
3286
3333
  return {
3287
- value: ApiCaller.decodeBody(Operations12.putVenue, res),
3334
+ value: ApiCaller.decodeBody(Operations13.putVenue, res),
3288
3335
  etag: res.headers.etag
3289
3336
  };
3290
3337
  } catch (e) {
@@ -3305,13 +3352,13 @@ var VenuesRepository = class {
3305
3352
  /** Merge-patches a venue (reads the ETag when not given). */
3306
3353
  async patch(venueId, patch, ifMatch) {
3307
3354
  const etag = ifMatch ?? (await this.get(venueId)).etag;
3308
- const res = await this.api.call(Operations12.patchVenue, {
3355
+ const res = await this.api.call(Operations13.patchVenue, {
3309
3356
  params: { venueId },
3310
3357
  body: patch,
3311
3358
  headers: { "if-match": etag }
3312
3359
  });
3313
3360
  return {
3314
- value: ApiCaller.decodeBody(Operations12.patchVenue, res),
3361
+ value: ApiCaller.decodeBody(Operations13.patchVenue, res),
3315
3362
  etag: res.headers.etag
3316
3363
  };
3317
3364
  }
@@ -3329,7 +3376,7 @@ var VenuesRepository = class {
3329
3376
  }
3330
3377
  /** Exports the venue as `.dome` bytes. */
3331
3378
  async export(venueId = "default") {
3332
- const res = await this.api.call(Operations12.exportVenue, {
3379
+ const res = await this.api.call(Operations13.exportVenue, {
3333
3380
  params: { venueId },
3334
3381
  headers: { accept: "application/vnd.nativemind.freedome.dome+zip, application/problem+json" },
3335
3382
  timeoutMs: 3e5
@@ -3338,15 +3385,15 @@ var VenuesRepository = class {
3338
3385
  }
3339
3386
  /** Calibration block with the venue ETag. */
3340
3387
  async calibration(venueId = "default") {
3341
- const res = await this.api.call(Operations12.getCalibration, { params: { venueId } });
3388
+ const res = await this.api.call(Operations13.getCalibration, { params: { venueId } });
3342
3389
  return {
3343
- value: ApiCaller.decodeBody(Operations12.getCalibration, res),
3390
+ value: ApiCaller.decodeBody(Operations13.getCalibration, res),
3344
3391
  etag: res.headers.etag
3345
3392
  };
3346
3393
  }
3347
3394
  /** Bytes of a calibration sidecar. */
3348
3395
  async calibrationFile(venueId, displayId, file) {
3349
- return (await this.api.call(Operations12.getCalibrationFile, {
3396
+ return (await this.api.call(Operations13.getCalibrationFile, {
3350
3397
  params: { venueId, displayId, file },
3351
3398
  headers: { accept: "*/*" }
3352
3399
  })).body;
@@ -3354,21 +3401,21 @@ var VenuesRepository = class {
3354
3401
  /** Uploads a calibration sidecar (If-Match = venue ETag, read when not given). */
3355
3402
  async putCalibrationFile(venueId, displayId, file, bytes, ifMatch) {
3356
3403
  const etag = ifMatch ?? (await this.calibration(venueId)).etag;
3357
- const res = await this.api.call(Operations12.putCalibrationFile, {
3404
+ const res = await this.api.call(Operations13.putCalibrationFile, {
3358
3405
  params: { venueId, displayId, file },
3359
3406
  bytes,
3360
3407
  contentType: CALIBRATION_FILE_TYPES[file],
3361
3408
  headers: { "if-match": etag }
3362
3409
  });
3363
3410
  return {
3364
- value: ApiCaller.decodeBody(Operations12.putCalibrationFile, res),
3411
+ value: ApiCaller.decodeBody(Operations13.putCalibrationFile, res),
3365
3412
  etag: res.headers.etag
3366
3413
  };
3367
3414
  }
3368
3415
  };
3369
3416
 
3370
3417
  // src/client.ts
3371
- var FREEDOME_CLIENT_VERSION = "1.1.0";
3418
+ var FREEDOME_CLIENT_VERSION = "1.2.0";
3372
3419
  function defaultTransports() {
3373
3420
  return { rest: (e) => new FetchTransport(e), sockets: webSocketConnector() };
3374
3421
  }
@@ -3385,6 +3432,7 @@ var FreedomeClient = class {
3385
3432
  playback;
3386
3433
  content;
3387
3434
  osc;
3435
+ assistant;
3388
3436
  clients;
3389
3437
  audio;
3390
3438
  audioReactive;
@@ -3472,6 +3520,7 @@ var FreedomeClient = class {
3472
3520
  this.playback = new PlaybackRepository(this.ctx);
3473
3521
  this.content = new ContentRepository(this.ctx);
3474
3522
  this.osc = new OscRepository(this.ctx);
3523
+ this.assistant = new AssistantRepository(this.ctx);
3475
3524
  this.clients = new ClientsRepository(this.ctx);
3476
3525
  this.audio = new AudioRepository(this.ctx);
3477
3526
  this.audioReactive = new AudioReactiveRepository(this.ctx);
@@ -3577,7 +3626,7 @@ var FreedomeClient = class {
3577
3626
  this.set("negotiating");
3578
3627
  let info;
3579
3628
  try {
3580
- info = await this.api.json(Operations13.getInfo, { authenticated: false });
3629
+ info = await this.api.json(Operations14.getInfo, { authenticated: false });
3581
3630
  } catch (e) {
3582
3631
  if (e instanceof NetworkError) {
3583
3632
  this.set("offline", "server not reachable");
@@ -3620,12 +3669,12 @@ var FreedomeClient = class {
3620
3669
  return;
3621
3670
  case "apiKey":
3622
3671
  this.api.authorization = `Bearer ${c.key}`;
3623
- this.setSession(sessionFromPrincipal(await this.api.json(Operations13.getMe)));
3672
+ this.setSession(sessionFromPrincipal(await this.api.json(Operations14.getMe)));
3624
3673
  return;
3625
3674
  case "password": {
3626
3675
  const stored = await this.tokenStore.read(key);
3627
3676
  if (stored && await this.tryStored(stored)) return;
3628
- const t = await this.api.json(Operations13.createSession, {
3677
+ const t = await this.api.json(Operations14.createSession, {
3629
3678
  body: { username: c.username, password: c.password, client },
3630
3679
  authenticated: false
3631
3680
  });
@@ -3641,7 +3690,7 @@ var FreedomeClient = class {
3641
3690
  case "cloud": {
3642
3691
  const stored = await this.tokenStore.read(key);
3643
3692
  if (stored && await this.tryStored(stored)) return;
3644
- const t = await this.api.json(Operations13.exchangeCloudToken, {
3693
+ const t = await this.api.json(Operations14.exchangeCloudToken, {
3645
3694
  body: { subjectToken: await c.token(), client },
3646
3695
  authenticated: false
3647
3696
  });
@@ -3653,7 +3702,7 @@ var FreedomeClient = class {
3653
3702
  async tryStored(t) {
3654
3703
  this.api.authorization = `Bearer ${t.accessToken}`;
3655
3704
  try {
3656
- this.setSession(sessionFromPrincipal(await this.api.json(Operations13.getMe)));
3705
+ this.setSession(sessionFromPrincipal(await this.api.json(Operations14.getMe)));
3657
3706
  return true;
3658
3707
  } catch (e) {
3659
3708
  if (!(e instanceof UnauthorizedError)) throw e;
@@ -3668,7 +3717,7 @@ var FreedomeClient = class {
3668
3717
  this.setSession(sessionFromTokens(t, user ?? this.sessionValue.user));
3669
3718
  }
3670
3719
  async pair(p) {
3671
- let pairing = await this.api.json(Operations13.createPairing, {
3720
+ let pairing = await this.api.json(Operations14.createPairing, {
3672
3721
  body: {
3673
3722
  app: p.app,
3674
3723
  deviceName: p.deviceName,
@@ -3691,7 +3740,7 @@ var FreedomeClient = class {
3691
3740
  while (!["approved", "denied", "expired", "revoked"].includes(pr().status)) {
3692
3741
  if (Date.now() > deadline) throw new UnauthorizedError("pairing was not approved in time");
3693
3742
  await new Promise((r) => setTimeout(r, this.options.pairingPollIntervalMs));
3694
- pairing = await this.api.json(Operations13.getPairing, {
3743
+ pairing = await this.api.json(Operations14.getPairing, {
3695
3744
  params: { pairingId: pr().pairingId },
3696
3745
  authenticated: false
3697
3746
  });
@@ -3709,7 +3758,7 @@ var FreedomeClient = class {
3709
3758
  const rt = stored?.refreshToken;
3710
3759
  if (!rt) return await this.reauthenticate();
3711
3760
  try {
3712
- const t = await this.api.json(Operations13.refreshSession, {
3761
+ const t = await this.api.json(Operations14.refreshSession, {
3713
3762
  body: { refreshToken: rt },
3714
3763
  authenticated: false
3715
3764
  });
@@ -3747,7 +3796,7 @@ var FreedomeClient = class {
3747
3796
  async logout() {
3748
3797
  if (this.api.authorization && this.credentials.kind !== "apiKey") {
3749
3798
  try {
3750
- await this.api.call(Operations13.deleteSession);
3799
+ await this.api.call(Operations14.deleteSession);
3751
3800
  } catch (e) {
3752
3801
  this.log("warning", "logout", e);
3753
3802
  }
@@ -3878,9 +3927,9 @@ var FreedomeClient = class {
3878
3927
  async replayOutbox() {
3879
3928
  if (!this.outbox) return;
3880
3929
  await this.ctx.replayOutbox(async (e) => {
3881
- const op = Operations13[e.operationId];
3930
+ const op = Operations14[e.operationId];
3882
3931
  if (!op || op.method !== "PUT" && op.method !== "PATCH") return void 0;
3883
- const get = Object.values(Operations13).find(
3932
+ const get = Object.values(Operations14).find(
3884
3933
  (o) => o.method === "GET" && o.path === op.path
3885
3934
  );
3886
3935
  if (!get) return void 0;
@@ -3901,7 +3950,7 @@ var FreedomeClient = class {
3901
3950
  async seedSeq(filters) {
3902
3951
  if (this.hub.lastSeq !== void 0) return;
3903
3952
  try {
3904
- const page = await this.api.json(Operations13.listEvents, {
3953
+ const page = await this.api.json(Operations14.listEvents, {
3905
3954
  query: { topics: filters.join(","), limit: "1" }
3906
3955
  });
3907
3956
  if (typeof page.lastSeq === "number") this.hub.seed(page.lastSeq);
@@ -4020,14 +4069,14 @@ var FreedomeClient = class {
4020
4069
  };
4021
4070
 
4022
4071
  // src/discovery.ts
4023
- import { Operations as Operations14 } from "@freedome/protocol";
4072
+ import { Operations as Operations15 } from "@freedome/protocol";
4024
4073
  async function probe(endpoint, timeoutMs = 2e3) {
4025
4074
  const t = new FetchTransport(endpoint);
4026
4075
  try {
4027
4076
  const res = await t.send(
4028
4077
  {
4029
- method: Operations14.getInfo.method,
4030
- path: Operations14.getInfo.path,
4078
+ method: Operations15.getInfo.method,
4079
+ path: Operations15.getInfo.path,
4031
4080
  headers: { accept: "application/json" }
4032
4081
  },
4033
4082
  timeoutMs
@@ -4089,10 +4138,11 @@ var CompositeDiscovery = class {
4089
4138
  };
4090
4139
 
4091
4140
  // src/index.ts
4092
- import { Operations as Operations15, DomeTopics as DomeTopics10, EventKinds as EventKinds6, ProtocolVersions as ProtocolVersions3, SemVer as SemVer3 } from "@freedome/protocol";
4141
+ import { Operations as Operations16, DomeTopics as DomeTopics10, EventKinds as EventKinds6, ProtocolVersions as ProtocolVersions3, SemVer as SemVer3 } from "@freedome/protocol";
4093
4142
  var PACKAGE_NAME = "@freedome/client";
4094
4143
  export {
4095
4144
  ApiCaller,
4145
+ AssistantRepository,
4096
4146
  AudioReactiveRepository,
4097
4147
  AudioRepository,
4098
4148
  BackoffPolicy,
@@ -4134,7 +4184,7 @@ export {
4134
4184
  NetworkError,
4135
4185
  NotFoundError,
4136
4186
  OfflineError,
4137
- Operations15 as Operations,
4187
+ Operations16 as Operations,
4138
4188
  OscRepository,
4139
4189
  PACKAGE_NAME,
4140
4190
  PairingLink,