@matterbridge/types 3.5.3

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.
@@ -0,0 +1,851 @@
1
+ /**
2
+ * This file contains the BroadcastServer types.
3
+ *
4
+ * @file broadcastServerTypes.ts
5
+ * @author Luca Liguori
6
+ * @created 2025-10-05
7
+ * @version 2.0.0
8
+ * @license Apache-2.0
9
+ *
10
+ * Copyright 2025, 2026, 2027 Luca Liguori.
11
+ *
12
+ * Licensed under the Apache License, Version 2.0 (the "License");
13
+ * you may not use this file except in compliance with the License.
14
+ * You may obtain a copy of the License at
15
+ *
16
+ * http://www.apache.org/licenses/LICENSE-2.0
17
+ *
18
+ * Unless required by applicable law or agreed to in writing, software
19
+ * distributed under the License is distributed on an "AS IS" BASIS,
20
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21
+ * See the License for the specific language governing permissions and
22
+ * limitations under the License.
23
+ */
24
+ import { LogLevel } from 'node-ansi-logger';
25
+ import { EndpointNumber } from '@matter/types/datatype';
26
+ import type { RefreshRequiredChanged, WsMessageBroadcast } from './frontendTypes.js';
27
+ import type { PlatformConfig, PlatformMatterbridge, PlatformSchema } from './matterbridgePlatformTypes.js';
28
+ import type { ApiMatter, ApiPlugin, BaseDevice, SharedMatterbridge, StoragePlugin } from './matterbridgeTypes.js';
29
+ /** Types of worker source */
30
+ export type WorkerSrcType = 'manager' | 'matterbridge' | 'plugins' | 'devices' | 'frontend' | 'matter' | 'platform' | 'spawn' | 'updates';
31
+ /** Types of worker destination */
32
+ export type WorkerDstType = 'manager' | 'matterbridge' | 'plugins' | 'devices' | 'frontend' | 'matter' | 'platform' | 'spawn' | 'updates' | 'all';
33
+ /** Normalized message request structure */
34
+ type NormalizeRequest<T> = T extends {
35
+ params: infer P;
36
+ } ? ([P] extends [undefined] ? {
37
+ params?: undefined;
38
+ } : {
39
+ params: P;
40
+ }) : Record<never, never>;
41
+ /** Message request structure with id, timestamp, src and dst */
42
+ type WorkerMessageRequestMap = {
43
+ [K in keyof WorkerMessageTypes]: {
44
+ type: K;
45
+ id?: number;
46
+ timestamp?: number;
47
+ src: WorkerSrcType;
48
+ dst: WorkerDstType;
49
+ } & NormalizeRequest<WorkerMessageTypes[K]['request']>;
50
+ };
51
+ /** Message request structure with id, timestamp, src and dst */
52
+ export type WorkerMessageRequest<K extends keyof WorkerMessageTypes = keyof WorkerMessageTypes> = WorkerMessageRequestMap[K];
53
+ /** Normalized message response success structure that guarantees a successful result */
54
+ type NormalizeResponseSuccess<T> = T & {
55
+ error?: never;
56
+ };
57
+ /** Normalized message response error structure that guarantees an error-only payload */
58
+ type NormalizeResponseError<T> = {
59
+ error: string;
60
+ } & {
61
+ [K in keyof T]?: never;
62
+ };
63
+ /** Normalized message response structure */
64
+ type NormalizeResponse<T> = NormalizeResponseSuccess<T> | NormalizeResponseError<T>;
65
+ /** Message response structure with id, timestamp, elapsed, src and dst */
66
+ type WorkerMessageResponseMap = {
67
+ [K in keyof WorkerMessageTypes]: {
68
+ type: K;
69
+ id?: number;
70
+ timestamp?: number;
71
+ elapsed?: number;
72
+ src: WorkerSrcType;
73
+ dst: WorkerDstType;
74
+ } & NormalizeResponse<WorkerMessageTypes[K]['response']>;
75
+ };
76
+ /** Message response structure with id, timestamp, elapsed, src and dst */
77
+ export type WorkerMessageResponse<K extends keyof WorkerMessageTypes = keyof WorkerMessageTypes> = WorkerMessageResponseMap[K];
78
+ /** Message response success structure that guarantees a successful result */
79
+ type WorkerMessageResponseSuccessMap = {
80
+ [K in keyof WorkerMessageTypes]: {
81
+ type: K;
82
+ id?: number;
83
+ timestamp?: number;
84
+ elapsed?: number;
85
+ src: WorkerSrcType;
86
+ dst: WorkerDstType;
87
+ } & NormalizeResponseSuccess<WorkerMessageTypes[K]['response']>;
88
+ };
89
+ /** Message response success structure that guarantees a successful result */
90
+ export type WorkerMessageResponseSuccess<K extends keyof WorkerMessageTypes = keyof WorkerMessageTypes> = WorkerMessageResponseSuccessMap[K];
91
+ /** Message response error structure */
92
+ type WorkerMessageResponseErrorMap = {
93
+ [K in keyof WorkerMessageTypes]: {
94
+ type: K;
95
+ id?: number;
96
+ timestamp?: number;
97
+ elapsed?: number;
98
+ src: WorkerSrcType;
99
+ dst: WorkerDstType;
100
+ } & NormalizeResponseError<WorkerMessageTypes[K]['response']>;
101
+ };
102
+ /** Message response error structure */
103
+ export type WorkerMessageResponseError<K extends keyof WorkerMessageTypes = keyof WorkerMessageTypes> = WorkerMessageResponseErrorMap[K];
104
+ /** Convenience alias for any worker request */
105
+ export type WorkerMessageRequestAny = WorkerMessageRequest<keyof WorkerMessageTypes>;
106
+ /** Resolve a successful response type based on the originating request */
107
+ export type WorkerMessageResponseSuccessForRequest<T extends WorkerMessageRequestAny> = WorkerMessageResponseSuccess<Extract<keyof WorkerMessageTypes, T['type']>>;
108
+ /** Resolve an error response type based on the originating request */
109
+ export type WorkerMessageResponseErrorForRequest<T extends WorkerMessageRequestAny> = WorkerMessageResponseError<Extract<keyof WorkerMessageTypes, T['type']>>;
110
+ /** Union type for WorkerMessageRequest and WorkerMessageResponse */
111
+ export type WorkerMessage<K extends keyof WorkerMessageTypes = keyof WorkerMessageTypes> = WorkerMessageRequest<K> | WorkerMessageResponse<K> | WorkerMessageResponseSuccess<K> | WorkerMessageResponseError<K>;
112
+ /** Map of all worker message types with their request and response structures */
113
+ export type WorkerMessageTypes = {
114
+ jest: {
115
+ request: {
116
+ params: {
117
+ userId: number;
118
+ };
119
+ };
120
+ response: {
121
+ result: {
122
+ name: string;
123
+ age: number;
124
+ };
125
+ };
126
+ };
127
+ jest_simple: {
128
+ request: {
129
+ params: undefined;
130
+ };
131
+ response: {
132
+ result: {
133
+ success: true;
134
+ };
135
+ };
136
+ };
137
+ get_log_level: {
138
+ request: {
139
+ params: undefined;
140
+ };
141
+ response: {
142
+ result: {
143
+ logLevel: LogLevel;
144
+ };
145
+ };
146
+ };
147
+ set_log_level: {
148
+ request: {
149
+ params: {
150
+ logLevel: LogLevel;
151
+ };
152
+ };
153
+ response: {
154
+ result: {
155
+ logLevel: LogLevel;
156
+ };
157
+ };
158
+ };
159
+ matterbridge_initialize: {
160
+ request: {
161
+ params: undefined;
162
+ };
163
+ response: {
164
+ result: {
165
+ success: true;
166
+ };
167
+ };
168
+ };
169
+ matterbridge_latest_version: {
170
+ request: {
171
+ params: {
172
+ version: string;
173
+ };
174
+ };
175
+ response: {
176
+ result: {
177
+ success: true;
178
+ };
179
+ };
180
+ };
181
+ matterbridge_global_prefix: {
182
+ request: {
183
+ params: {
184
+ prefix: string;
185
+ };
186
+ };
187
+ response: {
188
+ result: {
189
+ success: true;
190
+ };
191
+ };
192
+ };
193
+ matterbridge_dev_version: {
194
+ request: {
195
+ params: {
196
+ version: string;
197
+ };
198
+ };
199
+ response: {
200
+ result: {
201
+ success: true;
202
+ };
203
+ };
204
+ };
205
+ matterbridge_sys_update: {
206
+ request: {
207
+ params: {
208
+ available: boolean;
209
+ };
210
+ };
211
+ response: {
212
+ result: {
213
+ success: true;
214
+ };
215
+ };
216
+ };
217
+ matterbridge_main_update: {
218
+ request: {
219
+ params: {
220
+ available: boolean;
221
+ };
222
+ };
223
+ response: {
224
+ result: {
225
+ success: true;
226
+ };
227
+ };
228
+ };
229
+ matterbridge_platform: {
230
+ request: {
231
+ params: undefined;
232
+ };
233
+ response: {
234
+ result: {
235
+ data: PlatformMatterbridge;
236
+ success: true;
237
+ };
238
+ };
239
+ };
240
+ matterbridge_shared: {
241
+ request: {
242
+ params: undefined;
243
+ };
244
+ response: {
245
+ result: {
246
+ data: SharedMatterbridge;
247
+ success: true;
248
+ };
249
+ };
250
+ };
251
+ matter_start: {
252
+ request: {
253
+ params: {
254
+ storeId: string;
255
+ };
256
+ };
257
+ response: {
258
+ result: {
259
+ storeId: string;
260
+ success: true;
261
+ };
262
+ };
263
+ };
264
+ matter_stop: {
265
+ request: {
266
+ params: {
267
+ storeId: string;
268
+ };
269
+ };
270
+ response: {
271
+ result: {
272
+ storeId: string;
273
+ success: true;
274
+ };
275
+ };
276
+ };
277
+ frontend_start: {
278
+ request: {
279
+ params: {
280
+ port: number;
281
+ };
282
+ };
283
+ response: {
284
+ result: {
285
+ success: true;
286
+ };
287
+ };
288
+ };
289
+ frontend_stop: {
290
+ request: {
291
+ params: undefined;
292
+ };
293
+ response: {
294
+ result: {
295
+ success: true;
296
+ };
297
+ };
298
+ };
299
+ frontend_refreshrequired: {
300
+ request: {
301
+ params: {
302
+ changed: RefreshRequiredChanged;
303
+ matter?: ApiMatter;
304
+ };
305
+ };
306
+ response: {
307
+ result: {
308
+ success: true;
309
+ };
310
+ };
311
+ };
312
+ frontend_restartrequired: {
313
+ request: {
314
+ params: {
315
+ snackbar: boolean;
316
+ fixed: boolean;
317
+ };
318
+ };
319
+ response: {
320
+ result: {
321
+ success: true;
322
+ };
323
+ };
324
+ };
325
+ frontend_restartnotrequired: {
326
+ request: {
327
+ params: {
328
+ snackbar: boolean;
329
+ };
330
+ };
331
+ response: {
332
+ result: {
333
+ success: true;
334
+ };
335
+ };
336
+ };
337
+ frontend_updaterequired: {
338
+ request: {
339
+ params: {
340
+ devVersion: boolean;
341
+ };
342
+ };
343
+ response: {
344
+ result: {
345
+ success: true;
346
+ };
347
+ };
348
+ };
349
+ frontend_snackbarmessage: {
350
+ request: {
351
+ params: {
352
+ message: string;
353
+ timeout?: number;
354
+ severity?: 'info' | 'success' | 'warning' | 'error';
355
+ };
356
+ };
357
+ response: {
358
+ result: {
359
+ success: true;
360
+ };
361
+ };
362
+ };
363
+ frontend_attributechanged: {
364
+ request: {
365
+ params: {
366
+ plugin: string;
367
+ serialNumber: string;
368
+ uniqueId: string;
369
+ number: EndpointNumber;
370
+ id: string;
371
+ cluster: string;
372
+ attribute: string;
373
+ value: number | string | boolean | null;
374
+ };
375
+ };
376
+ response: {
377
+ result: {
378
+ success: true;
379
+ };
380
+ };
381
+ };
382
+ frontend_logmessage: {
383
+ request: {
384
+ params: {
385
+ level: string;
386
+ time: string;
387
+ name: string;
388
+ message: string;
389
+ };
390
+ };
391
+ response: {
392
+ result: {
393
+ success: true;
394
+ };
395
+ };
396
+ };
397
+ frontend_broadcast_message: {
398
+ request: {
399
+ params: {
400
+ msg: WsMessageBroadcast;
401
+ };
402
+ };
403
+ response: {
404
+ result: {
405
+ success: true;
406
+ };
407
+ };
408
+ };
409
+ plugins_length: {
410
+ request: {
411
+ params: undefined;
412
+ };
413
+ response: {
414
+ result: {
415
+ length: number;
416
+ };
417
+ };
418
+ };
419
+ plugins_size: {
420
+ request: {
421
+ params: undefined;
422
+ };
423
+ response: {
424
+ result: {
425
+ size: number;
426
+ };
427
+ };
428
+ };
429
+ plugins_has: {
430
+ request: {
431
+ params: {
432
+ name: string;
433
+ };
434
+ };
435
+ response: {
436
+ result: {
437
+ has: boolean;
438
+ };
439
+ };
440
+ };
441
+ plugins_get: {
442
+ request: {
443
+ params: {
444
+ name: string;
445
+ };
446
+ };
447
+ response: {
448
+ result: {
449
+ plugin: ApiPlugin | undefined;
450
+ };
451
+ };
452
+ };
453
+ plugins_set: {
454
+ request: {
455
+ params: {
456
+ plugin: ApiPlugin;
457
+ };
458
+ };
459
+ response: {
460
+ result: {
461
+ plugin: ApiPlugin;
462
+ };
463
+ };
464
+ };
465
+ plugins_clear: {
466
+ request: {
467
+ params: undefined;
468
+ };
469
+ response: {
470
+ result: {
471
+ success: true;
472
+ };
473
+ };
474
+ };
475
+ plugins_storagepluginarray: {
476
+ request: {
477
+ params: undefined;
478
+ };
479
+ response: {
480
+ result: {
481
+ plugins: StoragePlugin[];
482
+ };
483
+ };
484
+ };
485
+ plugins_apipluginarray: {
486
+ request: {
487
+ params: undefined;
488
+ };
489
+ response: {
490
+ result: {
491
+ plugins: ApiPlugin[];
492
+ };
493
+ };
494
+ };
495
+ plugins_loadFromStorage: {
496
+ request: {
497
+ params: undefined;
498
+ };
499
+ response: {
500
+ result: {
501
+ plugins: ApiPlugin[];
502
+ };
503
+ };
504
+ };
505
+ plugins_saveToStorage: {
506
+ request: {
507
+ params: undefined;
508
+ };
509
+ response: {
510
+ result: {
511
+ count: number;
512
+ };
513
+ };
514
+ };
515
+ plugins_resolve: {
516
+ request: {
517
+ params: {
518
+ pluginPath: string;
519
+ };
520
+ };
521
+ response: {
522
+ result: {
523
+ resolved: string | null;
524
+ };
525
+ };
526
+ };
527
+ plugins_install: {
528
+ request: {
529
+ params: {
530
+ packageName: string;
531
+ };
532
+ };
533
+ response: {
534
+ result: {
535
+ packageName: string;
536
+ success: boolean;
537
+ };
538
+ };
539
+ };
540
+ plugins_uninstall: {
541
+ request: {
542
+ params: {
543
+ packageName: string;
544
+ };
545
+ };
546
+ response: {
547
+ result: {
548
+ packageName: string;
549
+ success: boolean;
550
+ };
551
+ };
552
+ };
553
+ plugins_enable: {
554
+ request: {
555
+ params: {
556
+ nameOrPath: string;
557
+ };
558
+ };
559
+ response: {
560
+ result: {
561
+ plugin: ApiPlugin | null;
562
+ };
563
+ };
564
+ };
565
+ plugins_disable: {
566
+ request: {
567
+ params: {
568
+ nameOrPath: string;
569
+ };
570
+ };
571
+ response: {
572
+ result: {
573
+ plugin: ApiPlugin | null;
574
+ };
575
+ };
576
+ };
577
+ plugins_remove: {
578
+ request: {
579
+ params: {
580
+ nameOrPath: string;
581
+ };
582
+ };
583
+ response: {
584
+ result: {
585
+ plugin: ApiPlugin | null;
586
+ };
587
+ };
588
+ };
589
+ plugins_add: {
590
+ request: {
591
+ params: {
592
+ nameOrPath: string;
593
+ };
594
+ };
595
+ response: {
596
+ result: {
597
+ plugin: ApiPlugin | null;
598
+ };
599
+ };
600
+ };
601
+ plugins_load: {
602
+ request: {
603
+ params: {
604
+ plugin: ApiPlugin | string;
605
+ start?: boolean;
606
+ message?: string;
607
+ configure?: boolean;
608
+ };
609
+ };
610
+ response: {
611
+ result: {
612
+ platform: unknown | undefined;
613
+ };
614
+ };
615
+ };
616
+ plugins_start: {
617
+ request: {
618
+ params: {
619
+ plugin: ApiPlugin | string;
620
+ message?: string;
621
+ configure?: boolean;
622
+ };
623
+ };
624
+ response: {
625
+ result: {
626
+ plugin: ApiPlugin | undefined;
627
+ };
628
+ };
629
+ };
630
+ plugins_configure: {
631
+ request: {
632
+ params: {
633
+ plugin: ApiPlugin | string;
634
+ };
635
+ };
636
+ response: {
637
+ result: {
638
+ plugin: ApiPlugin | undefined;
639
+ };
640
+ };
641
+ };
642
+ plugins_shutdown: {
643
+ request: {
644
+ params: {
645
+ plugin: ApiPlugin | string;
646
+ reason?: string;
647
+ removeAllDevices?: boolean;
648
+ force?: boolean;
649
+ };
650
+ };
651
+ response: {
652
+ result: {
653
+ plugin: ApiPlugin | undefined;
654
+ };
655
+ };
656
+ };
657
+ plugins_loadconfig: {
658
+ request: {
659
+ params: {
660
+ plugin: ApiPlugin;
661
+ };
662
+ };
663
+ response: {
664
+ result: {
665
+ config: PlatformConfig;
666
+ };
667
+ };
668
+ };
669
+ plugins_saveconfigfromplugin: {
670
+ request: {
671
+ params: {
672
+ name: string;
673
+ restartRequired?: boolean;
674
+ };
675
+ };
676
+ response: {
677
+ result: {
678
+ success: true;
679
+ };
680
+ };
681
+ };
682
+ plugins_saveconfigfromjson: {
683
+ request: {
684
+ params: {
685
+ name: string;
686
+ config: PlatformConfig;
687
+ restartRequired?: boolean;
688
+ };
689
+ };
690
+ response: {
691
+ result: {
692
+ success: true;
693
+ };
694
+ };
695
+ };
696
+ plugins_loadschema: {
697
+ request: {
698
+ params: {
699
+ name: string;
700
+ };
701
+ };
702
+ response: {
703
+ result: {
704
+ schema: PlatformSchema | undefined;
705
+ };
706
+ };
707
+ };
708
+ plugins_getschema: {
709
+ request: {
710
+ params: {
711
+ name: string;
712
+ };
713
+ };
714
+ response: {
715
+ result: {
716
+ schema: PlatformSchema | undefined;
717
+ };
718
+ };
719
+ };
720
+ plugins_setschema: {
721
+ request: {
722
+ params: {
723
+ name: string;
724
+ schema: PlatformSchema;
725
+ };
726
+ };
727
+ response: {
728
+ result: {
729
+ success: true;
730
+ };
731
+ };
732
+ };
733
+ plugins_set_latest_version: {
734
+ request: {
735
+ params: {
736
+ plugin: ApiPlugin;
737
+ version: string;
738
+ };
739
+ };
740
+ response: {
741
+ result: {
742
+ success: true;
743
+ };
744
+ };
745
+ };
746
+ plugins_set_dev_version: {
747
+ request: {
748
+ params: {
749
+ plugin: ApiPlugin;
750
+ version: string;
751
+ };
752
+ };
753
+ response: {
754
+ result: {
755
+ success: true;
756
+ };
757
+ };
758
+ };
759
+ devices_length: {
760
+ request: {
761
+ params: undefined;
762
+ };
763
+ response: {
764
+ result: {
765
+ length: number;
766
+ };
767
+ };
768
+ };
769
+ devices_size: {
770
+ request: {
771
+ params: undefined;
772
+ };
773
+ response: {
774
+ result: {
775
+ size: number;
776
+ };
777
+ };
778
+ };
779
+ devices_has: {
780
+ request: {
781
+ params: {
782
+ uniqueId: string;
783
+ };
784
+ };
785
+ response: {
786
+ result: {
787
+ has: boolean;
788
+ };
789
+ };
790
+ };
791
+ devices_get: {
792
+ request: {
793
+ params: {
794
+ uniqueId: string;
795
+ };
796
+ };
797
+ response: {
798
+ result: {
799
+ device: BaseDevice | undefined;
800
+ };
801
+ };
802
+ };
803
+ devices_set: {
804
+ request: {
805
+ params: {
806
+ device: BaseDevice;
807
+ };
808
+ };
809
+ response: {
810
+ result: {
811
+ device: BaseDevice;
812
+ };
813
+ };
814
+ };
815
+ devices_remove: {
816
+ request: {
817
+ params: {
818
+ device: BaseDevice;
819
+ };
820
+ };
821
+ response: {
822
+ result: {
823
+ success: boolean;
824
+ };
825
+ };
826
+ };
827
+ devices_clear: {
828
+ request: {
829
+ params: undefined;
830
+ };
831
+ response: {
832
+ result: {
833
+ success: true;
834
+ };
835
+ };
836
+ };
837
+ devices_basearray: {
838
+ request: {
839
+ params: {
840
+ pluginName?: string;
841
+ };
842
+ };
843
+ response: {
844
+ result: {
845
+ devices: BaseDevice[];
846
+ };
847
+ };
848
+ };
849
+ };
850
+ export {};
851
+ //# sourceMappingURL=broadcastServerTypes.d.ts.map