@callimacus/thamyr-react 4.3.4

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,1948 @@
1
+ /*!
2
+ * Copyright © 2025–2026 Solomei AI SRL. All rights reserved.
3
+ *
4
+ * Proprietary software, licensed for use by Callimacus customers only.
5
+ * See LICENSE.md for the full terms.
6
+ *
7
+ */
8
+ import * as _callimacus_thamyr_core from '@callimacus/thamyr-core';
9
+ import { UiObserverConfig, CallimacusApi, ErrorMessage, ThamyrResponse, UserInteractionType, InteractionPayloadMap, TtsAudio } from '@callimacus/thamyr-core';
10
+ export { Block, BoundingBox, CallimacusEvent, Chapter, ChapterStatus, ClientEvents, ClientInfo, ConnectionStatusCallback, ErrorCallback, ErrorMessage, Gallery, GalleryMode, Image, ImageEdits, ImageFormatEdit, ImageResizeEdit, InteractionContext, InteractionPayloadMap, LocalizedEPArtwork, LocalizedEPChapter, LogLevel, LoggerConfig, ProductMatch, SLDocument, SLDocumentSection, SLInputEvent, SLInputEventType, ServerEvents, ServerResponseCallback, Story, ThamyrHttpError, ThamyrResponse, ThamyrResponseType, Topic, TtsAudio, UiElement, UiObserverConfig, UiSnapshot, UserInteraction, UserInteractionType, Video, WhisperPayload, callimacusService, clearIntentSessionId, ensureIntentSessionId, extractTtsAudio, getIntentSessionId, initIntent, isSetProduct, logger, setConsent, setDebug, setDebugPanel, setGeo, setIntentSessionMaxAge, transformImageUrl } from '@callimacus/thamyr-core';
11
+ import { Thamyr } from '@callimacus/thamyr';
12
+ import * as zustand from 'zustand';
13
+
14
+ /**
15
+ Represents the current state of the Thamyr SDK connection.
16
+ */
17
+ type ConnectionStatus = 'idle' | 'connecting' | 'connected' | 'disconnected' | 'error';
18
+ /**
19
+ Configuration for initializing the Thamyr SDK via `useInitThamyr`.
20
+ */
21
+ type CallimacusInitConfig = {
22
+ /**
23
+ Your Callimacus public client ID (`cal-pk-…`).
24
+ */
25
+ clientId?: string;
26
+ /**
27
+ Server endpoint URL. Uses the default Thamyr endpoint when omitted.
28
+ */
29
+ endpoint?: string;
30
+ /**
31
+ Configuration for the autonomous UI observer that tracks visible elements.
32
+ */
33
+ uiObserver?: UiObserverConfig;
34
+ /**
35
+ Maximum number of messages to retain in history. Set to `0` for unlimited. Defaults to `50`.
36
+ */
37
+ maxMessages?: number;
38
+ };
39
+
40
+ /**
41
+ Initialize the Thamyr SDK for React usage.
42
+
43
+ Call this once in your root component. When `clientId` or `endpoint` change,
44
+ the hook tears down the current instance via `reset()` and re-initializes.
45
+
46
+ `uiObserver` and `maxMessages` are intentionally excluded from the dependency
47
+ array because `uiObserver` is typically an object literal that would cause
48
+ infinite reset loops. If these need to change at runtime, unmount and remount
49
+ the component calling `useInitThamyr` instead (e.g., use a `key` prop).
50
+
51
+ @param config - SDK configuration (client ID, endpoint, UI observer, max messages).
52
+
53
+ @example
54
+ ```tsx
55
+ function App() {
56
+ useInitThamyr({ clientId: 'cal-pk-…' });
57
+ return <MyComponent />;
58
+ }
59
+ ```
60
+ */
61
+ declare function useInitThamyr(config: CallimacusInitConfig): void;
62
+ /**
63
+ Returns the message history and a function to send events to the Thamyr service.
64
+
65
+ @returns An object with:
66
+ - `history` — array of {@link ThamyrResponse} messages received so far
67
+ - `sendEvent` — sends a typed user interaction to the Thamyr service
68
+ - `sendAudio` — sends an audio recording (with optional text query) for transcription
69
+
70
+ @example
71
+ ```tsx
72
+ function Chat() {
73
+ const { history, sendEvent } = useThamyr();
74
+ const { status } = useConnection();
75
+
76
+ const handleSend = () => {
77
+ sendEvent(UserInteractionType.CREATE_ROUND, {
78
+ inputEvent: myInputEvent,
79
+ });
80
+ };
81
+
82
+ return <button onClick={handleSend} disabled={status !== 'connected'}>Send</button>;
83
+ }
84
+ ```
85
+ */
86
+ declare function useThamyr(): {
87
+ history: ({
88
+ type: "chapter-event";
89
+ chapter: {
90
+ id: string;
91
+ deleted: boolean;
92
+ language?: string;
93
+ receptors?: Array<string>;
94
+ intent?: Array<string>;
95
+ subCondition?: Array<string>;
96
+ inputEvent?: {
97
+ type: "question";
98
+ data: {
99
+ value: string;
100
+ file?: unknown | null;
101
+ };
102
+ } | {
103
+ type: "content";
104
+ data: {
105
+ value: string;
106
+ };
107
+ } | {
108
+ type: "topic";
109
+ data: {
110
+ value: string;
111
+ };
112
+ } | {
113
+ type: "image";
114
+ data: {
115
+ value: string;
116
+ };
117
+ } | {
118
+ type: "gallery";
119
+ data: {
120
+ value: string;
121
+ };
122
+ } | {
123
+ type: "page";
124
+ data: {
125
+ value: string;
126
+ };
127
+ } | {
128
+ type: "relatedQuestion";
129
+ data: {
130
+ value: string;
131
+ };
132
+ } | {
133
+ type: "customInteraction";
134
+ data: {
135
+ payload?: {
136
+ [key: string]: unknown;
137
+ };
138
+ nodeKey?: string;
139
+ interactionId: string;
140
+ value?: string | Array<string>;
141
+ };
142
+ } | {
143
+ type: "customPage";
144
+ data: {
145
+ value?: string;
146
+ };
147
+ };
148
+ related?: {
149
+ contentList?: Array<{
150
+ language: string;
151
+ type: "content" | "image" | "video";
152
+ name: string;
153
+ backgroundKnowledge: boolean;
154
+ topic?: number;
155
+ meta?: {
156
+ title?: string;
157
+ description?: string;
158
+ url?: string;
159
+ [key: string]: string | unknown | string | undefined;
160
+ };
161
+ status?: "draft" | "pending_approval" | "approved";
162
+ publishedAt?: string | null;
163
+ unpublishedAt?: string | null;
164
+ authors?: Array<string>;
165
+ source?: "backoffice" | "api" | "salesforce";
166
+ slug?: string;
167
+ documentGroupId: string;
168
+ id: string;
169
+ lastUpdate: string;
170
+ sections?: Array<{
171
+ id: string;
172
+ document: string;
173
+ type: "title" | "header" | "text";
174
+ content: string;
175
+ properties?: {
176
+ [key: string]: unknown;
177
+ };
178
+ } | {
179
+ id: string;
180
+ document: string;
181
+ type: "image";
182
+ content?: string;
183
+ url: string;
184
+ properties: {
185
+ size: {
186
+ width: number;
187
+ height: number;
188
+ };
189
+ alt?: string;
190
+ cloudinary?: {
191
+ publicId: string;
192
+ cloudName: string;
193
+ secureDistribution: string;
194
+ } & {
195
+ [key: string]: unknown;
196
+ };
197
+ };
198
+ } | {
199
+ id: string;
200
+ document: string;
201
+ type: "video";
202
+ content?: string;
203
+ url: string;
204
+ properties?: {
205
+ size?: {
206
+ width: number;
207
+ height: number;
208
+ };
209
+ poster?: string;
210
+ playerConfig?: {
211
+ autoplay: boolean;
212
+ muted: boolean;
213
+ controls: boolean;
214
+ loop: boolean;
215
+ };
216
+ cloudinary?: {
217
+ publicId: string;
218
+ cloudName: string;
219
+ secureDistribution: string;
220
+ } & {
221
+ [key: string]: unknown;
222
+ };
223
+ };
224
+ } | {
225
+ id: string;
226
+ document: string;
227
+ type: "custom";
228
+ content?: string;
229
+ typeId: string;
230
+ payload: {
231
+ [key: string]: unknown;
232
+ };
233
+ properties?: {
234
+ [key: string]: unknown;
235
+ };
236
+ }>;
237
+ }>;
238
+ topicList?: Array<{
239
+ id: number;
240
+ slug: string;
241
+ name: string;
242
+ description: string;
243
+ translations: {
244
+ [key: string]: string;
245
+ };
246
+ }>;
247
+ relatedQuestions?: Array<string>;
248
+ };
249
+ references?: Array<string>;
250
+ blocks?: Array<({
251
+ id: string;
252
+ priority?: number;
253
+ metaJson?: unknown;
254
+ type: "image";
255
+ data: {
256
+ type: "image";
257
+ content?: string;
258
+ url: string;
259
+ properties: {
260
+ size: {
261
+ width: number;
262
+ height: number;
263
+ };
264
+ alt?: string;
265
+ cloudinary?: {
266
+ publicId: string;
267
+ cloudName: string;
268
+ secureDistribution: string;
269
+ [key: string]: unknown;
270
+ };
271
+ };
272
+ id?: string;
273
+ document?: string;
274
+ };
275
+ } | {
276
+ id: string;
277
+ priority?: number;
278
+ metaJson?: unknown;
279
+ type: "content";
280
+ data: Array<{
281
+ language: string;
282
+ type: "content" | "image" | "video";
283
+ name: string;
284
+ backgroundKnowledge: boolean;
285
+ topic?: number;
286
+ meta?: {
287
+ title?: string;
288
+ description?: string;
289
+ url?: string;
290
+ [key: string]: string | unknown | string | undefined;
291
+ };
292
+ status?: "draft" | "pending_approval" | "approved";
293
+ publishedAt?: string | null;
294
+ unpublishedAt?: string | null;
295
+ authors?: Array<string>;
296
+ source?: "backoffice" | "api" | "salesforce";
297
+ slug?: string;
298
+ documentGroupId: string;
299
+ id: string;
300
+ lastUpdate: string;
301
+ sections?: Array<{
302
+ id: string;
303
+ document: string;
304
+ type: "title" | "header" | "text";
305
+ content: string;
306
+ properties?: {
307
+ [key: string]: unknown;
308
+ };
309
+ } | {
310
+ id: string;
311
+ document: string;
312
+ type: "image";
313
+ content?: string;
314
+ url: string;
315
+ properties: {
316
+ size: {
317
+ width: number;
318
+ height: number;
319
+ };
320
+ alt?: string;
321
+ cloudinary?: {
322
+ publicId: string;
323
+ cloudName: string;
324
+ secureDistribution: string;
325
+ } & {
326
+ [key: string]: unknown;
327
+ };
328
+ };
329
+ } | {
330
+ id: string;
331
+ document: string;
332
+ type: "video";
333
+ content?: string;
334
+ url: string;
335
+ properties?: {
336
+ size?: {
337
+ width: number;
338
+ height: number;
339
+ };
340
+ poster?: string;
341
+ playerConfig?: {
342
+ autoplay: boolean;
343
+ muted: boolean;
344
+ controls: boolean;
345
+ loop: boolean;
346
+ };
347
+ cloudinary?: {
348
+ publicId: string;
349
+ cloudName: string;
350
+ secureDistribution: string;
351
+ } & {
352
+ [key: string]: unknown;
353
+ };
354
+ };
355
+ } | {
356
+ id: string;
357
+ document: string;
358
+ type: "custom";
359
+ content?: string;
360
+ typeId: string;
361
+ payload: {
362
+ [key: string]: unknown;
363
+ };
364
+ properties?: {
365
+ [key: string]: unknown;
366
+ };
367
+ }>;
368
+ }>;
369
+ } | {
370
+ id: string;
371
+ priority?: number;
372
+ metaJson?: unknown;
373
+ type: "gallery";
374
+ data: {
375
+ images: Array<{
376
+ type: "image";
377
+ content?: string;
378
+ url: string;
379
+ properties: {
380
+ size: {
381
+ width: number;
382
+ height: number;
383
+ };
384
+ alt?: string;
385
+ cloudinary?: {
386
+ publicId: string;
387
+ cloudName: string;
388
+ secureDistribution: string;
389
+ [key: string]: unknown;
390
+ };
391
+ };
392
+ id?: string;
393
+ document?: string;
394
+ }>;
395
+ mode: "masonry" | "carousel";
396
+ };
397
+ } | {
398
+ id: string;
399
+ priority?: number;
400
+ metaJson?: unknown;
401
+ type: "video";
402
+ data: Array<{
403
+ type: "video";
404
+ content?: string;
405
+ url: string;
406
+ properties?: {
407
+ size?: {
408
+ width: number;
409
+ height: number;
410
+ };
411
+ poster?: string;
412
+ playerConfig?: {
413
+ autoplay: boolean;
414
+ muted: boolean;
415
+ controls: boolean;
416
+ loop: boolean;
417
+ };
418
+ cloudinary?: {
419
+ publicId: string;
420
+ cloudName: string;
421
+ secureDistribution: string;
422
+ [key: string]: unknown;
423
+ };
424
+ };
425
+ id?: string;
426
+ document?: string;
427
+ }>;
428
+ } | {
429
+ id: string;
430
+ priority?: number;
431
+ metaJson?: unknown;
432
+ type: "topic";
433
+ data: Array<{
434
+ id: number;
435
+ slug: string;
436
+ name: string;
437
+ description: string;
438
+ translations: {
439
+ [key: string]: string;
440
+ };
441
+ }>;
442
+ } | {
443
+ id: string;
444
+ priority?: number;
445
+ metaJson?: unknown;
446
+ type: "product";
447
+ data: Array<{
448
+ matches?: {
449
+ status: "success";
450
+ tier?: "fully" | "partially" | "no";
451
+ explanation?: string;
452
+ } | {
453
+ status: "error";
454
+ };
455
+ hit: {
456
+ match?: {
457
+ id: string;
458
+ metadata: {
459
+ c_macrocategoryacme: string;
460
+ c_microcategoryacme: string;
461
+ category: string;
462
+ description: string;
463
+ macroColor: string;
464
+ materials: string;
465
+ microColor: string;
466
+ name: string;
467
+ price: number;
468
+ sku: string;
469
+ subCategory: string;
470
+ taxonomy: string;
471
+ text: string;
472
+ type: string;
473
+ };
474
+ score: number;
475
+ values?: Array<number>;
476
+ };
477
+ product: {
478
+ type: {
479
+ set: true;
480
+ };
481
+ setProducts: Array<{
482
+ id: string;
483
+ }>;
484
+ fullSetProducts?: Array<{
485
+ type: {
486
+ master: true;
487
+ };
488
+ variationGroups: Array<{
489
+ c_sku: string;
490
+ c_pfas: string;
491
+ c_color: string;
492
+ c_model: string;
493
+ c_gender: string;
494
+ c_hscode: string;
495
+ c_season: string;
496
+ c_weight: string;
497
+ c_details?: string;
498
+ 'c_made-in': string;
499
+ productId: string;
500
+ c_material: string;
501
+ c_saleline: string;
502
+ assignedCategories?: Array<{
503
+ categoryId: string;
504
+ }>;
505
+ c_avalaraCode: string;
506
+ 'c_macro-color': string;
507
+ 'c_micro-color': string;
508
+ 'c_id-size-grid': string;
509
+ c_material_care: string;
510
+ 'c_material-1-desc'?: string;
511
+ 'c_material-2-desc'?: string;
512
+ 'c_material-3-desc'?: string;
513
+ primaryCategoryId?: string;
514
+ c_macrocategoryacme: string;
515
+ c_microcategoryacme: string;
516
+ c_short_description?: string;
517
+ 'c_material-1-percent': number;
518
+ 'c_material-2-percent': number;
519
+ 'c_material-3-percent': number;
520
+ 'c_material-4-percent': number;
521
+ 'c_material-5-percent': number;
522
+ 'c_material-6-percent': number;
523
+ 'c_material-7-percent': number;
524
+ 'c_material-8-percent': number;
525
+ productPromotions?: Array<{
526
+ calloutMsg: string;
527
+ promotionId: string;
528
+ c_formattedPrice: string;
529
+ promotionalPrice: number;
530
+ }>;
531
+ recommendations: Array<{
532
+ recommendedItemId: string;
533
+ }>;
534
+ variationValues: {
535
+ [key: string]: string;
536
+ };
537
+ imageGroups: Array<{
538
+ images: Array<{
539
+ alt?: string;
540
+ disBaseLink?: string;
541
+ url: string;
542
+ title?: string;
543
+ }>;
544
+ }>;
545
+ orderable: boolean;
546
+ online: boolean;
547
+ }>;
548
+ variants: Array<{
549
+ online: boolean;
550
+ orderable?: boolean;
551
+ price?: number;
552
+ productId: string;
553
+ c_formattedPrice?: string;
554
+ variationValues?: {
555
+ [key: string]: string;
556
+ };
557
+ productPromotions?: Array<{
558
+ calloutMsg: string;
559
+ promotionId: string;
560
+ c_formattedPrice: string;
561
+ promotionalPrice: number;
562
+ }>;
563
+ inventory?: {
564
+ ats: number;
565
+ };
566
+ }>;
567
+ variationAttributes: Array<{
568
+ id: string;
569
+ name?: string;
570
+ values?: Array<{
571
+ description?: string;
572
+ image?: {
573
+ alt?: string;
574
+ disBaseLink?: string;
575
+ url: string;
576
+ title?: string;
577
+ };
578
+ imageSwatch?: {
579
+ alt?: string;
580
+ disBaseLink?: string;
581
+ url: string;
582
+ title?: string;
583
+ };
584
+ name?: string;
585
+ orderable?: boolean;
586
+ value: string;
587
+ }>;
588
+ }>;
589
+ 'c_material-1-percent': number;
590
+ 'c_material-2-percent': number;
591
+ 'c_material-3-percent': number;
592
+ 'c_material-4-percent': number;
593
+ 'c_material-5-percent': number;
594
+ 'c_material-6-percent': number;
595
+ 'c_material-7-percent': number;
596
+ 'c_material-8-percent': number;
597
+ 'c_material-1-desc'?: string;
598
+ 'c_material-2-desc'?: string;
599
+ 'c_material-3-desc'?: string;
600
+ c_short_description?: string;
601
+ c_microcategoryacme: string;
602
+ longDescription: string;
603
+ shortDescription: string;
604
+ 'c_made-in': string;
605
+ c_material: string;
606
+ c_saleline: string;
607
+ c_avalaraCode: string;
608
+ 'c_id-size-grid': string;
609
+ c_material_care: string;
610
+ c_weight: string;
611
+ currency: string;
612
+ c_details?: string;
613
+ productPromotions?: Array<{
614
+ calloutMsg: string;
615
+ promotionId: string;
616
+ c_formattedPrice: string;
617
+ promotionalPrice: number;
618
+ }>;
619
+ c_sku: string;
620
+ c_hscode: string;
621
+ orderable: boolean;
622
+ price: number;
623
+ priceMax?: number | null;
624
+ id: string;
625
+ name: string;
626
+ online: boolean;
627
+ c_model: string;
628
+ c_gender: string;
629
+ c_season: string;
630
+ c_macrocategoryacme: string;
631
+ c_searchkeywords?: string;
632
+ hasHowToStyle: boolean;
633
+ } & {
634
+ selectedVariationGroup: string;
635
+ }>;
636
+ imageGroups: Array<{
637
+ images: Array<{
638
+ alt?: string;
639
+ disBaseLink?: string;
640
+ url: string;
641
+ title?: string;
642
+ }>;
643
+ }>;
644
+ primaryCategoryId: string;
645
+ assignedCategories?: Array<{
646
+ categoryId: string;
647
+ }>;
648
+ id: string;
649
+ name: string;
650
+ online: boolean;
651
+ c_model: string;
652
+ c_gender: string;
653
+ c_season: string;
654
+ c_macrocategoryacme: string;
655
+ c_searchkeywords?: string;
656
+ hasHowToStyle: boolean;
657
+ } | ({
658
+ type: {
659
+ master: true;
660
+ };
661
+ variationGroups: Array<{
662
+ c_sku: string;
663
+ c_pfas: string;
664
+ c_color: string;
665
+ c_model: string;
666
+ c_gender: string;
667
+ c_hscode: string;
668
+ c_season: string;
669
+ c_weight: string;
670
+ c_details?: string;
671
+ 'c_made-in': string;
672
+ productId: string;
673
+ c_material: string;
674
+ c_saleline: string;
675
+ assignedCategories?: Array<{
676
+ categoryId: string;
677
+ }>;
678
+ c_avalaraCode: string;
679
+ 'c_macro-color': string;
680
+ 'c_micro-color': string;
681
+ 'c_id-size-grid': string;
682
+ c_material_care: string;
683
+ 'c_material-1-desc'?: string;
684
+ 'c_material-2-desc'?: string;
685
+ 'c_material-3-desc'?: string;
686
+ primaryCategoryId?: string;
687
+ c_macrocategoryacme: string;
688
+ c_microcategoryacme: string;
689
+ c_short_description?: string;
690
+ 'c_material-1-percent': number;
691
+ 'c_material-2-percent': number;
692
+ 'c_material-3-percent': number;
693
+ 'c_material-4-percent': number;
694
+ 'c_material-5-percent': number;
695
+ 'c_material-6-percent': number;
696
+ 'c_material-7-percent': number;
697
+ 'c_material-8-percent': number;
698
+ productPromotions?: Array<{
699
+ calloutMsg: string;
700
+ promotionId: string;
701
+ c_formattedPrice: string;
702
+ promotionalPrice: number;
703
+ }>;
704
+ recommendations: Array<{
705
+ recommendedItemId: string;
706
+ }>;
707
+ variationValues: {
708
+ [key: string]: string;
709
+ };
710
+ imageGroups: Array<{
711
+ images: Array<{
712
+ alt?: string;
713
+ disBaseLink?: string;
714
+ url: string;
715
+ title?: string;
716
+ }>;
717
+ }>;
718
+ orderable: boolean;
719
+ online: boolean;
720
+ }>;
721
+ variants: Array<{
722
+ online: boolean;
723
+ orderable?: boolean;
724
+ price?: number;
725
+ productId: string;
726
+ c_formattedPrice?: string;
727
+ variationValues?: {
728
+ [key: string]: string;
729
+ };
730
+ productPromotions?: Array<{
731
+ calloutMsg: string;
732
+ promotionId: string;
733
+ c_formattedPrice: string;
734
+ promotionalPrice: number;
735
+ }>;
736
+ inventory?: {
737
+ ats: number;
738
+ };
739
+ }>;
740
+ variationAttributes: Array<{
741
+ id: string;
742
+ name?: string;
743
+ values?: Array<{
744
+ description?: string;
745
+ image?: {
746
+ alt?: string;
747
+ disBaseLink?: string;
748
+ url: string;
749
+ title?: string;
750
+ };
751
+ imageSwatch?: {
752
+ alt?: string;
753
+ disBaseLink?: string;
754
+ url: string;
755
+ title?: string;
756
+ };
757
+ name?: string;
758
+ orderable?: boolean;
759
+ value: string;
760
+ }>;
761
+ }>;
762
+ 'c_material-1-percent': number;
763
+ 'c_material-2-percent': number;
764
+ 'c_material-3-percent': number;
765
+ 'c_material-4-percent': number;
766
+ 'c_material-5-percent': number;
767
+ 'c_material-6-percent': number;
768
+ 'c_material-7-percent': number;
769
+ 'c_material-8-percent': number;
770
+ 'c_material-1-desc'?: string;
771
+ 'c_material-2-desc'?: string;
772
+ 'c_material-3-desc'?: string;
773
+ c_short_description?: string;
774
+ c_microcategoryacme: string;
775
+ longDescription: string;
776
+ shortDescription: string;
777
+ 'c_made-in': string;
778
+ c_material: string;
779
+ c_saleline: string;
780
+ c_avalaraCode: string;
781
+ 'c_id-size-grid': string;
782
+ c_material_care: string;
783
+ c_weight: string;
784
+ currency: string;
785
+ c_details?: string;
786
+ productPromotions?: Array<{
787
+ calloutMsg: string;
788
+ promotionId: string;
789
+ c_formattedPrice: string;
790
+ promotionalPrice: number;
791
+ }>;
792
+ c_sku: string;
793
+ c_hscode: string;
794
+ orderable: boolean;
795
+ price: number;
796
+ priceMax?: number | null;
797
+ id: string;
798
+ name: string;
799
+ online: boolean;
800
+ c_model: string;
801
+ c_gender: string;
802
+ c_season: string;
803
+ c_macrocategoryacme: string;
804
+ c_searchkeywords?: string;
805
+ hasHowToStyle: boolean;
806
+ } & {
807
+ selectedVariationGroup: string;
808
+ });
809
+ };
810
+ }>;
811
+ } | {
812
+ id: string;
813
+ priority?: number;
814
+ metaJson?: unknown;
815
+ type: "epicPaper";
816
+ data: Array<{
817
+ id: string;
818
+ title?: string;
819
+ bookmark?: {
820
+ id: string;
821
+ text: string;
822
+ title: string;
823
+ };
824
+ chapters?: Array<{
825
+ id: string;
826
+ text: string;
827
+ title: string;
828
+ }>;
829
+ language: string;
830
+ type: "ep";
831
+ }>;
832
+ } | {
833
+ id: string;
834
+ priority?: number;
835
+ metaJson?: unknown;
836
+ type: "demosthenesResponse";
837
+ data: {
838
+ text: string;
839
+ traceId?: string;
840
+ };
841
+ }) | {
842
+ id: string;
843
+ priority?: number;
844
+ metaJson?: unknown;
845
+ type: `custom:${string}`;
846
+ name?: string;
847
+ data: unknown;
848
+ }>;
849
+ status: 2 | 1 | 3 | 4;
850
+ };
851
+ } | {
852
+ type: "story-created";
853
+ story: {
854
+ id: string;
855
+ language?: string;
856
+ chapters: Array<{
857
+ id: string;
858
+ deleted: boolean;
859
+ language?: string;
860
+ receptors?: Array<string>;
861
+ intent?: Array<string>;
862
+ subCondition?: Array<string>;
863
+ inputEvent?: {
864
+ type: "question";
865
+ data: {
866
+ value: string;
867
+ file?: unknown | null;
868
+ };
869
+ } | {
870
+ type: "content";
871
+ data: {
872
+ value: string;
873
+ };
874
+ } | {
875
+ type: "topic";
876
+ data: {
877
+ value: string;
878
+ };
879
+ } | {
880
+ type: "image";
881
+ data: {
882
+ value: string;
883
+ };
884
+ } | {
885
+ type: "gallery";
886
+ data: {
887
+ value: string;
888
+ };
889
+ } | {
890
+ type: "page";
891
+ data: {
892
+ value: string;
893
+ };
894
+ } | {
895
+ type: "relatedQuestion";
896
+ data: {
897
+ value: string;
898
+ };
899
+ } | {
900
+ type: "customInteraction";
901
+ data: {
902
+ payload?: {
903
+ [key: string]: unknown;
904
+ };
905
+ nodeKey?: string;
906
+ interactionId: string;
907
+ value?: string | Array<string>;
908
+ };
909
+ } | {
910
+ type: "customPage";
911
+ data: {
912
+ value?: string;
913
+ };
914
+ };
915
+ related?: {
916
+ contentList?: Array<{
917
+ language: string;
918
+ type: "content" | "image" | "video";
919
+ name: string;
920
+ backgroundKnowledge: boolean;
921
+ topic?: number;
922
+ meta?: {
923
+ title?: string;
924
+ description?: string;
925
+ url?: string;
926
+ [key: string]: string | unknown | string | undefined;
927
+ };
928
+ status?: "draft" | "pending_approval" | "approved";
929
+ publishedAt?: string | null;
930
+ unpublishedAt?: string | null;
931
+ authors?: Array<string>;
932
+ source?: "backoffice" | "api" | "salesforce";
933
+ slug?: string;
934
+ documentGroupId: string;
935
+ id: string;
936
+ lastUpdate: string;
937
+ sections?: Array<{
938
+ id: string;
939
+ document: string;
940
+ type: "title" | "header" | "text";
941
+ content: string;
942
+ properties?: {
943
+ [key: string]: unknown;
944
+ };
945
+ } | {
946
+ id: string;
947
+ document: string;
948
+ type: "image";
949
+ content?: string;
950
+ url: string;
951
+ properties: {
952
+ size: {
953
+ width: number;
954
+ height: number;
955
+ };
956
+ alt?: string;
957
+ cloudinary?: {
958
+ publicId: string;
959
+ cloudName: string;
960
+ secureDistribution: string;
961
+ } & {
962
+ [key: string]: unknown;
963
+ };
964
+ };
965
+ } | {
966
+ id: string;
967
+ document: string;
968
+ type: "video";
969
+ content?: string;
970
+ url: string;
971
+ properties?: {
972
+ size?: {
973
+ width: number;
974
+ height: number;
975
+ };
976
+ poster?: string;
977
+ playerConfig?: {
978
+ autoplay: boolean;
979
+ muted: boolean;
980
+ controls: boolean;
981
+ loop: boolean;
982
+ };
983
+ cloudinary?: {
984
+ publicId: string;
985
+ cloudName: string;
986
+ secureDistribution: string;
987
+ } & {
988
+ [key: string]: unknown;
989
+ };
990
+ };
991
+ } | {
992
+ id: string;
993
+ document: string;
994
+ type: "custom";
995
+ content?: string;
996
+ typeId: string;
997
+ payload: {
998
+ [key: string]: unknown;
999
+ };
1000
+ properties?: {
1001
+ [key: string]: unknown;
1002
+ };
1003
+ }>;
1004
+ }>;
1005
+ topicList?: Array<{
1006
+ id: number;
1007
+ slug: string;
1008
+ name: string;
1009
+ description: string;
1010
+ translations: {
1011
+ [key: string]: string;
1012
+ };
1013
+ }>;
1014
+ relatedQuestions?: Array<string>;
1015
+ };
1016
+ references?: Array<string>;
1017
+ blocks?: Array<({
1018
+ id: string;
1019
+ priority?: number;
1020
+ metaJson?: unknown;
1021
+ type: "image";
1022
+ data: {
1023
+ type: "image";
1024
+ content?: string;
1025
+ url: string;
1026
+ properties: {
1027
+ size: {
1028
+ width: number;
1029
+ height: number;
1030
+ };
1031
+ alt?: string;
1032
+ cloudinary?: {
1033
+ publicId: string;
1034
+ cloudName: string;
1035
+ secureDistribution: string;
1036
+ [key: string]: unknown;
1037
+ };
1038
+ };
1039
+ id?: string;
1040
+ document?: string;
1041
+ };
1042
+ } | {
1043
+ id: string;
1044
+ priority?: number;
1045
+ metaJson?: unknown;
1046
+ type: "content";
1047
+ data: Array<{
1048
+ language: string;
1049
+ type: "content" | "image" | "video";
1050
+ name: string;
1051
+ backgroundKnowledge: boolean;
1052
+ topic?: number;
1053
+ meta?: {
1054
+ title?: string;
1055
+ description?: string;
1056
+ url?: string;
1057
+ [key: string]: string | unknown | string | undefined;
1058
+ };
1059
+ status?: "draft" | "pending_approval" | "approved";
1060
+ publishedAt?: string | null;
1061
+ unpublishedAt?: string | null;
1062
+ authors?: Array<string>;
1063
+ source?: "backoffice" | "api" | "salesforce";
1064
+ slug?: string;
1065
+ documentGroupId: string;
1066
+ id: string;
1067
+ lastUpdate: string;
1068
+ sections?: Array<{
1069
+ id: string;
1070
+ document: string;
1071
+ type: "title" | "header" | "text";
1072
+ content: string;
1073
+ properties?: {
1074
+ [key: string]: unknown;
1075
+ };
1076
+ } | {
1077
+ id: string;
1078
+ document: string;
1079
+ type: "image";
1080
+ content?: string;
1081
+ url: string;
1082
+ properties: {
1083
+ size: {
1084
+ width: number;
1085
+ height: number;
1086
+ };
1087
+ alt?: string;
1088
+ cloudinary?: {
1089
+ publicId: string;
1090
+ cloudName: string;
1091
+ secureDistribution: string;
1092
+ } & {
1093
+ [key: string]: unknown;
1094
+ };
1095
+ };
1096
+ } | {
1097
+ id: string;
1098
+ document: string;
1099
+ type: "video";
1100
+ content?: string;
1101
+ url: string;
1102
+ properties?: {
1103
+ size?: {
1104
+ width: number;
1105
+ height: number;
1106
+ };
1107
+ poster?: string;
1108
+ playerConfig?: {
1109
+ autoplay: boolean;
1110
+ muted: boolean;
1111
+ controls: boolean;
1112
+ loop: boolean;
1113
+ };
1114
+ cloudinary?: {
1115
+ publicId: string;
1116
+ cloudName: string;
1117
+ secureDistribution: string;
1118
+ } & {
1119
+ [key: string]: unknown;
1120
+ };
1121
+ };
1122
+ } | {
1123
+ id: string;
1124
+ document: string;
1125
+ type: "custom";
1126
+ content?: string;
1127
+ typeId: string;
1128
+ payload: {
1129
+ [key: string]: unknown;
1130
+ };
1131
+ properties?: {
1132
+ [key: string]: unknown;
1133
+ };
1134
+ }>;
1135
+ }>;
1136
+ } | {
1137
+ id: string;
1138
+ priority?: number;
1139
+ metaJson?: unknown;
1140
+ type: "gallery";
1141
+ data: {
1142
+ images: Array<{
1143
+ type: "image";
1144
+ content?: string;
1145
+ url: string;
1146
+ properties: {
1147
+ size: {
1148
+ width: number;
1149
+ height: number;
1150
+ };
1151
+ alt?: string;
1152
+ cloudinary?: {
1153
+ publicId: string;
1154
+ cloudName: string;
1155
+ secureDistribution: string;
1156
+ [key: string]: unknown;
1157
+ };
1158
+ };
1159
+ id?: string;
1160
+ document?: string;
1161
+ }>;
1162
+ mode: "masonry" | "carousel";
1163
+ };
1164
+ } | {
1165
+ id: string;
1166
+ priority?: number;
1167
+ metaJson?: unknown;
1168
+ type: "video";
1169
+ data: Array<{
1170
+ type: "video";
1171
+ content?: string;
1172
+ url: string;
1173
+ properties?: {
1174
+ size?: {
1175
+ width: number;
1176
+ height: number;
1177
+ };
1178
+ poster?: string;
1179
+ playerConfig?: {
1180
+ autoplay: boolean;
1181
+ muted: boolean;
1182
+ controls: boolean;
1183
+ loop: boolean;
1184
+ };
1185
+ cloudinary?: {
1186
+ publicId: string;
1187
+ cloudName: string;
1188
+ secureDistribution: string;
1189
+ [key: string]: unknown;
1190
+ };
1191
+ };
1192
+ id?: string;
1193
+ document?: string;
1194
+ }>;
1195
+ } | {
1196
+ id: string;
1197
+ priority?: number;
1198
+ metaJson?: unknown;
1199
+ type: "topic";
1200
+ data: Array<{
1201
+ id: number;
1202
+ slug: string;
1203
+ name: string;
1204
+ description: string;
1205
+ translations: {
1206
+ [key: string]: string;
1207
+ };
1208
+ }>;
1209
+ } | {
1210
+ id: string;
1211
+ priority?: number;
1212
+ metaJson?: unknown;
1213
+ type: "product";
1214
+ data: Array<{
1215
+ matches?: {
1216
+ status: "success";
1217
+ tier?: "fully" | "partially" | "no";
1218
+ explanation?: string;
1219
+ } | {
1220
+ status: "error";
1221
+ };
1222
+ hit: {
1223
+ match?: {
1224
+ id: string;
1225
+ metadata: {
1226
+ c_macrocategoryacme: string;
1227
+ c_microcategoryacme: string;
1228
+ category: string;
1229
+ description: string;
1230
+ macroColor: string;
1231
+ materials: string;
1232
+ microColor: string;
1233
+ name: string;
1234
+ price: number;
1235
+ sku: string;
1236
+ subCategory: string;
1237
+ taxonomy: string;
1238
+ text: string;
1239
+ type: string;
1240
+ };
1241
+ score: number;
1242
+ values?: Array<number>;
1243
+ };
1244
+ product: {
1245
+ type: {
1246
+ set: true;
1247
+ };
1248
+ setProducts: Array<{
1249
+ id: string;
1250
+ }>;
1251
+ fullSetProducts?: Array<{
1252
+ type: {
1253
+ master: true;
1254
+ };
1255
+ variationGroups: Array<{
1256
+ c_sku: string;
1257
+ c_pfas: string;
1258
+ c_color: string;
1259
+ c_model: string;
1260
+ c_gender: string;
1261
+ c_hscode: string;
1262
+ c_season: string;
1263
+ c_weight: string;
1264
+ c_details?: string;
1265
+ 'c_made-in': string;
1266
+ productId: string;
1267
+ c_material: string;
1268
+ c_saleline: string;
1269
+ assignedCategories?: Array<{
1270
+ categoryId: string;
1271
+ }>;
1272
+ c_avalaraCode: string;
1273
+ 'c_macro-color': string;
1274
+ 'c_micro-color': string;
1275
+ 'c_id-size-grid': string;
1276
+ c_material_care: string;
1277
+ 'c_material-1-desc'?: string;
1278
+ 'c_material-2-desc'?: string;
1279
+ 'c_material-3-desc'?: string;
1280
+ primaryCategoryId?: string;
1281
+ c_macrocategoryacme: string;
1282
+ c_microcategoryacme: string;
1283
+ c_short_description?: string;
1284
+ 'c_material-1-percent': number;
1285
+ 'c_material-2-percent': number;
1286
+ 'c_material-3-percent': number;
1287
+ 'c_material-4-percent': number;
1288
+ 'c_material-5-percent': number;
1289
+ 'c_material-6-percent': number;
1290
+ 'c_material-7-percent': number;
1291
+ 'c_material-8-percent': number;
1292
+ productPromotions?: Array<{
1293
+ calloutMsg: string;
1294
+ promotionId: string;
1295
+ c_formattedPrice: string;
1296
+ promotionalPrice: number;
1297
+ }>;
1298
+ recommendations: Array<{
1299
+ recommendedItemId: string;
1300
+ }>;
1301
+ variationValues: {
1302
+ [key: string]: string;
1303
+ };
1304
+ imageGroups: Array<{
1305
+ images: Array<{
1306
+ alt?: string;
1307
+ disBaseLink?: string;
1308
+ url: string;
1309
+ title?: string;
1310
+ }>;
1311
+ }>;
1312
+ orderable: boolean;
1313
+ online: boolean;
1314
+ }>;
1315
+ variants: Array<{
1316
+ online: boolean;
1317
+ orderable?: boolean;
1318
+ price?: number;
1319
+ productId: string;
1320
+ c_formattedPrice?: string;
1321
+ variationValues?: {
1322
+ [key: string]: string;
1323
+ };
1324
+ productPromotions?: Array<{
1325
+ calloutMsg: string;
1326
+ promotionId: string;
1327
+ c_formattedPrice: string;
1328
+ promotionalPrice: number;
1329
+ }>;
1330
+ inventory?: {
1331
+ ats: number;
1332
+ };
1333
+ }>;
1334
+ variationAttributes: Array<{
1335
+ id: string;
1336
+ name?: string;
1337
+ values?: Array<{
1338
+ description?: string;
1339
+ image?: {
1340
+ alt?: string;
1341
+ disBaseLink?: string;
1342
+ url: string;
1343
+ title?: string;
1344
+ };
1345
+ imageSwatch?: {
1346
+ alt?: string;
1347
+ disBaseLink?: string;
1348
+ url: string;
1349
+ title?: string;
1350
+ };
1351
+ name?: string;
1352
+ orderable?: boolean;
1353
+ value: string;
1354
+ }>;
1355
+ }>;
1356
+ 'c_material-1-percent': number;
1357
+ 'c_material-2-percent': number;
1358
+ 'c_material-3-percent': number;
1359
+ 'c_material-4-percent': number;
1360
+ 'c_material-5-percent': number;
1361
+ 'c_material-6-percent': number;
1362
+ 'c_material-7-percent': number;
1363
+ 'c_material-8-percent': number;
1364
+ 'c_material-1-desc'?: string;
1365
+ 'c_material-2-desc'?: string;
1366
+ 'c_material-3-desc'?: string;
1367
+ c_short_description?: string;
1368
+ c_microcategoryacme: string;
1369
+ longDescription: string;
1370
+ shortDescription: string;
1371
+ 'c_made-in': string;
1372
+ c_material: string;
1373
+ c_saleline: string;
1374
+ c_avalaraCode: string;
1375
+ 'c_id-size-grid': string;
1376
+ c_material_care: string;
1377
+ c_weight: string;
1378
+ currency: string;
1379
+ c_details?: string;
1380
+ productPromotions?: Array<{
1381
+ calloutMsg: string;
1382
+ promotionId: string;
1383
+ c_formattedPrice: string;
1384
+ promotionalPrice: number;
1385
+ }>;
1386
+ c_sku: string;
1387
+ c_hscode: string;
1388
+ orderable: boolean;
1389
+ price: number;
1390
+ priceMax?: number | null;
1391
+ id: string;
1392
+ name: string;
1393
+ online: boolean;
1394
+ c_model: string;
1395
+ c_gender: string;
1396
+ c_season: string;
1397
+ c_macrocategoryacme: string;
1398
+ c_searchkeywords?: string;
1399
+ hasHowToStyle: boolean;
1400
+ } & {
1401
+ selectedVariationGroup: string;
1402
+ }>;
1403
+ imageGroups: Array<{
1404
+ images: Array<{
1405
+ alt?: string;
1406
+ disBaseLink?: string;
1407
+ url: string;
1408
+ title?: string;
1409
+ }>;
1410
+ }>;
1411
+ primaryCategoryId: string;
1412
+ assignedCategories?: Array<{
1413
+ categoryId: string;
1414
+ }>;
1415
+ id: string;
1416
+ name: string;
1417
+ online: boolean;
1418
+ c_model: string;
1419
+ c_gender: string;
1420
+ c_season: string;
1421
+ c_macrocategoryacme: string;
1422
+ c_searchkeywords?: string;
1423
+ hasHowToStyle: boolean;
1424
+ } | ({
1425
+ type: {
1426
+ master: true;
1427
+ };
1428
+ variationGroups: Array<{
1429
+ c_sku: string;
1430
+ c_pfas: string;
1431
+ c_color: string;
1432
+ c_model: string;
1433
+ c_gender: string;
1434
+ c_hscode: string;
1435
+ c_season: string;
1436
+ c_weight: string;
1437
+ c_details?: string;
1438
+ 'c_made-in': string;
1439
+ productId: string;
1440
+ c_material: string;
1441
+ c_saleline: string;
1442
+ assignedCategories?: Array<{
1443
+ categoryId: string;
1444
+ }>;
1445
+ c_avalaraCode: string;
1446
+ 'c_macro-color': string;
1447
+ 'c_micro-color': string;
1448
+ 'c_id-size-grid': string;
1449
+ c_material_care: string;
1450
+ 'c_material-1-desc'?: string;
1451
+ 'c_material-2-desc'?: string;
1452
+ 'c_material-3-desc'?: string;
1453
+ primaryCategoryId?: string;
1454
+ c_macrocategoryacme: string;
1455
+ c_microcategoryacme: string;
1456
+ c_short_description?: string;
1457
+ 'c_material-1-percent': number;
1458
+ 'c_material-2-percent': number;
1459
+ 'c_material-3-percent': number;
1460
+ 'c_material-4-percent': number;
1461
+ 'c_material-5-percent': number;
1462
+ 'c_material-6-percent': number;
1463
+ 'c_material-7-percent': number;
1464
+ 'c_material-8-percent': number;
1465
+ productPromotions?: Array<{
1466
+ calloutMsg: string;
1467
+ promotionId: string;
1468
+ c_formattedPrice: string;
1469
+ promotionalPrice: number;
1470
+ }>;
1471
+ recommendations: Array<{
1472
+ recommendedItemId: string;
1473
+ }>;
1474
+ variationValues: {
1475
+ [key: string]: string;
1476
+ };
1477
+ imageGroups: Array<{
1478
+ images: Array<{
1479
+ alt?: string;
1480
+ disBaseLink?: string;
1481
+ url: string;
1482
+ title?: string;
1483
+ }>;
1484
+ }>;
1485
+ orderable: boolean;
1486
+ online: boolean;
1487
+ }>;
1488
+ variants: Array<{
1489
+ online: boolean;
1490
+ orderable?: boolean;
1491
+ price?: number;
1492
+ productId: string;
1493
+ c_formattedPrice?: string;
1494
+ variationValues?: {
1495
+ [key: string]: string;
1496
+ };
1497
+ productPromotions?: Array<{
1498
+ calloutMsg: string;
1499
+ promotionId: string;
1500
+ c_formattedPrice: string;
1501
+ promotionalPrice: number;
1502
+ }>;
1503
+ inventory?: {
1504
+ ats: number;
1505
+ };
1506
+ }>;
1507
+ variationAttributes: Array<{
1508
+ id: string;
1509
+ name?: string;
1510
+ values?: Array<{
1511
+ description?: string;
1512
+ image?: {
1513
+ alt?: string;
1514
+ disBaseLink?: string;
1515
+ url: string;
1516
+ title?: string;
1517
+ };
1518
+ imageSwatch?: {
1519
+ alt?: string;
1520
+ disBaseLink?: string;
1521
+ url: string;
1522
+ title?: string;
1523
+ };
1524
+ name?: string;
1525
+ orderable?: boolean;
1526
+ value: string;
1527
+ }>;
1528
+ }>;
1529
+ 'c_material-1-percent': number;
1530
+ 'c_material-2-percent': number;
1531
+ 'c_material-3-percent': number;
1532
+ 'c_material-4-percent': number;
1533
+ 'c_material-5-percent': number;
1534
+ 'c_material-6-percent': number;
1535
+ 'c_material-7-percent': number;
1536
+ 'c_material-8-percent': number;
1537
+ 'c_material-1-desc'?: string;
1538
+ 'c_material-2-desc'?: string;
1539
+ 'c_material-3-desc'?: string;
1540
+ c_short_description?: string;
1541
+ c_microcategoryacme: string;
1542
+ longDescription: string;
1543
+ shortDescription: string;
1544
+ 'c_made-in': string;
1545
+ c_material: string;
1546
+ c_saleline: string;
1547
+ c_avalaraCode: string;
1548
+ 'c_id-size-grid': string;
1549
+ c_material_care: string;
1550
+ c_weight: string;
1551
+ currency: string;
1552
+ c_details?: string;
1553
+ productPromotions?: Array<{
1554
+ calloutMsg: string;
1555
+ promotionId: string;
1556
+ c_formattedPrice: string;
1557
+ promotionalPrice: number;
1558
+ }>;
1559
+ c_sku: string;
1560
+ c_hscode: string;
1561
+ orderable: boolean;
1562
+ price: number;
1563
+ priceMax?: number | null;
1564
+ id: string;
1565
+ name: string;
1566
+ online: boolean;
1567
+ c_model: string;
1568
+ c_gender: string;
1569
+ c_season: string;
1570
+ c_macrocategoryacme: string;
1571
+ c_searchkeywords?: string;
1572
+ hasHowToStyle: boolean;
1573
+ } & {
1574
+ selectedVariationGroup: string;
1575
+ });
1576
+ };
1577
+ }>;
1578
+ } | {
1579
+ id: string;
1580
+ priority?: number;
1581
+ metaJson?: unknown;
1582
+ type: "epicPaper";
1583
+ data: Array<{
1584
+ id: string;
1585
+ title?: string;
1586
+ bookmark?: {
1587
+ id: string;
1588
+ text: string;
1589
+ title: string;
1590
+ };
1591
+ chapters?: Array<{
1592
+ id: string;
1593
+ text: string;
1594
+ title: string;
1595
+ }>;
1596
+ language: string;
1597
+ type: "ep";
1598
+ }>;
1599
+ } | {
1600
+ id: string;
1601
+ priority?: number;
1602
+ metaJson?: unknown;
1603
+ type: "demosthenesResponse";
1604
+ data: {
1605
+ text: string;
1606
+ traceId?: string;
1607
+ };
1608
+ }) | {
1609
+ id: string;
1610
+ priority?: number;
1611
+ metaJson?: unknown;
1612
+ type: `custom:${string}`;
1613
+ name?: string;
1614
+ data: unknown;
1615
+ }>;
1616
+ status: 2 | 1 | 3 | 4;
1617
+ }>;
1618
+ };
1619
+ } | {
1620
+ type: "story-shared";
1621
+ data: {
1622
+ storyId: string;
1623
+ shareId: string;
1624
+ };
1625
+ } | {
1626
+ type: "chapter-deleted";
1627
+ data: {
1628
+ storyId: string;
1629
+ chapterId: string;
1630
+ roundId?: string;
1631
+ success: boolean;
1632
+ };
1633
+ } | {
1634
+ type: "story-reset";
1635
+ data: {
1636
+ storyId: string;
1637
+ success: boolean;
1638
+ };
1639
+ })[];
1640
+ sendEvent: <T extends _callimacus_thamyr_core.UserInteractionType>(type: T, payload: _callimacus_thamyr_core.InteractionPayloadMap[T]) => void;
1641
+ sendAudio: (audio: Blob, query?: string) => void;
1642
+ };
1643
+ /**
1644
+ Returns the current connection status of the Thamyr SDK.
1645
+
1646
+ Starts at `idle`. Moves to `connecting` on init, then to `connected` — or straight
1647
+ to `disconnected` if the connection attempt fails. Can transition to `disconnected`
1648
+ from `connected`, or to `error` from any active state.
1649
+ After `reset()`: returns to `idle`.
1650
+
1651
+ @returns An object with `status` — one of `'idle'`, `'connecting'`, `'connected'`, `'disconnected'`, or `'error'`.
1652
+
1653
+ @example
1654
+ ```tsx
1655
+ function StatusBadge() {
1656
+ const { status } = useConnection();
1657
+ return <span>{status}</span>;
1658
+ }
1659
+ ```
1660
+ */
1661
+ declare function useConnection(): {
1662
+ status: ConnectionStatus;
1663
+ };
1664
+ /**
1665
+ Registers a callback that fires whenever a {@link ThamyrResponse} is received from the server.
1666
+ Automatically subscribes on mount and unsubscribes on unmount.
1667
+
1668
+ @param callback - Called on each server response.
1669
+
1670
+ @example
1671
+ ```tsx
1672
+ useOnResponse((response) => {
1673
+ console.log('Response:', response);
1674
+ });
1675
+ ```
1676
+ */
1677
+ declare function useOnResponse(callback: (message: ThamyrResponse) => void): void;
1678
+ /**
1679
+ Registers a callback that fires when the SDK transitions between connection states.
1680
+ The callback receives any {@link ConnectionStatus} value.
1681
+ Automatically subscribes on mount and unsubscribes on unmount.
1682
+
1683
+ @param callback - Called with the new {@link ConnectionStatus}.
1684
+
1685
+ @example
1686
+ ```tsx
1687
+ useOnConnectionChange((status) => {
1688
+ if (status === 'disconnected') {
1689
+ console.warn('Lost connection');
1690
+ }
1691
+ });
1692
+ ```
1693
+ */
1694
+ declare function useOnConnectionChange(callback: (status: ConnectionStatus) => void): void;
1695
+ /**
1696
+ Registers a callback that fires whenever an error occurs — either received from
1697
+ the server or generated locally by the SDK (e.g., missing client ID, failed
1698
+ initialization, or sending while disconnected).
1699
+ Automatically subscribes on mount and unsubscribes on unmount.
1700
+
1701
+ @param callback - Called with the {@link ErrorMessage}.
1702
+
1703
+ @example
1704
+ ```tsx
1705
+ useOnError((error) => {
1706
+ console.error('Thamyr error:', error);
1707
+ });
1708
+ ```
1709
+ */
1710
+ declare function useOnError(callback: (error: ErrorMessage) => void): void;
1711
+ /**
1712
+ The envelope branch of a generated method, i.e. `ThrowOnError` pinned to
1713
+ `false`. `ReturnType<>` alone instantiates the generic at its `boolean`
1714
+ constraint, which unions in the throwing `{data, request, response}` branch,
1715
+ loses `error`, and — because it becomes a union of promises — skips the
1716
+ weak-type check that keeps an envelope from being passed where a `Basket`
1717
+ is expected. Same limitation query.ts works around with `ApiCall`.
1718
+ */
1719
+ type Envelope<M extends (...args: never[]) => Promise<unknown>> = Promise<Extract<Awaited<ReturnType<M>>, {
1720
+ error: unknown;
1721
+ }>>;
1722
+ /**
1723
+ Return type of {@link useCart}. Like every contract namespace, the methods
1724
+ resolve the `{data, error, response}` envelope — the basket is `data`, and an
1725
+ HTTP or network failure arrives as `error` on a RESOLVED promise, never as a
1726
+ rejection. Check it; a discarded envelope makes failures invisible.
1727
+ */
1728
+ type CartActions = {
1729
+ /**
1730
+ Fetch the current cart. Resolves `{data: Basket}` or `{error}`.
1731
+ */
1732
+ getCart: () => Envelope<Thamyr['cart']['getCart']>;
1733
+ /**
1734
+ Add a product to the cart. Resolves the updated `{data: Basket}` or `{error}`.
1735
+ */
1736
+ addItem: (productId: string) => Envelope<Thamyr['cart']['addItemToCart']>;
1737
+ /**
1738
+ Remove a product from the cart. Resolves the updated `{data: Basket}` or `{error}`.
1739
+ */
1740
+ removeItem: (productId: string) => Envelope<Thamyr['cart']['removeItemFromCart']>;
1741
+ /**
1742
+ Update the quantity of a product in the cart. Resolves the updated `{data: Basket}` or `{error}`.
1743
+ */
1744
+ updateQuantity: (productId: string, quantity: number) => Envelope<Thamyr['cart']['updateProductQuantity']>;
1745
+ };
1746
+ /**
1747
+ Provides methods to interact with the shopping cart.
1748
+
1749
+ @returns A referentially stable object whose methods delegate to the current Thamyr instance at call time.
1750
+ Calls made before initialization completes wait for `useInitThamyr()` to finish;
1751
+ they reject if initialization fails or no `useInitThamyr()` is mounted.
1752
+ HTTP/network failures do NOT reject — they resolve with `error` set (see {@link CartActions}).
1753
+
1754
+ @example
1755
+ ```tsx
1756
+ function AddButton({ productId }: { productId: string }) {
1757
+ const { addItem } = useCart();
1758
+ const onClick = async () => {
1759
+ const { data, error } = await addItem(productId);
1760
+ if (error) showToast('Could not add to cart');
1761
+ };
1762
+ return <button onClick={onClick}>Add</button>;
1763
+ }
1764
+ ```
1765
+ */
1766
+ declare function useCart(): CartActions;
1767
+ /**
1768
+ The generated API surface (`api.content.getPage({language, id})`).
1769
+
1770
+ Referentially stable and never undefined: methods delegate to the current
1771
+ Thamyr instance at call time. A call made before initialization completes
1772
+ transparently waits for `useInitThamyr()` to finish (surviving StrictMode's
1773
+ init → reset → init); it rejects with the initialization error when init
1774
+ fails, and rejects immediately with setup guidance when no `useInitThamyr()`
1775
+ is mounted at all. Also available outside components as {@link thamyrApi}.
1776
+ */
1777
+ declare function useApi(): CallimacusApi;
1778
+ /**
1779
+ Return type of {@link useSkesis}.
1780
+ */
1781
+ type SkesisActions = {
1782
+ /**
1783
+ Vector neighbors of a skesis item ("more like this").
1784
+ */
1785
+ similar: (anchorId: string, options?: {
1786
+ topK?: number;
1787
+ locale?: string;
1788
+ }) => ReturnType<typeof Thamyr.prototype.skesis.similar<false>>;
1789
+ /**
1790
+ Graph-related items + sibling color variants of a skesis item.
1791
+ */
1792
+ related: (anchorId: string, options?: {
1793
+ locale?: string;
1794
+ }) => ReturnType<typeof Thamyr.prototype.skesis.related<false>>;
1795
+ };
1796
+ /**
1797
+ Lazy graph reads for skesis ITEMS of any tenant-declared kind — the on-demand sibling
1798
+ of the `skesis` content kind's block-level `expand` option (which pre-joins the same
1799
+ data into block payloads server-side). `anchorId` is the full skesis item id carried
1800
+ by every skesis block hit (`item.id`).
1801
+
1802
+ Positional arguments as before; since v4 the methods are the generated contract's and
1803
+ resolve `{data, error, response}` instead of the bare value.
1804
+
1805
+ @returns A referentially stable object whose methods delegate to the current Thamyr instance at call time.
1806
+ If the SDK is not yet initialized, methods return a rejected promise with an error message.
1807
+
1808
+ @example
1809
+ ```tsx
1810
+ function MoreLikeThis({ anchorId }: { anchorId: string }) {
1811
+ const { similar } = useSkesis();
1812
+ useEffect(() => { similar(anchorId, { topK: 4 }).then(({ data }) => setItems(data?.hits ?? [])); }, [anchorId]);
1813
+ }
1814
+ ```
1815
+ */
1816
+ declare function useSkesis(): SkesisActions;
1817
+ /**
1818
+ Return type of {@link useSitemap}.
1819
+ */
1820
+ type SitemapActions = {
1821
+ /**
1822
+ Fetch the complete sitemap.
1823
+ */
1824
+ getSitemap: () => ReturnType<Thamyr['sitemap']['getSitemap']>;
1825
+ };
1826
+ /**
1827
+ Provides a `getSitemap` method to retrieve the site map.
1828
+
1829
+ @returns A referentially stable object whose methods delegate to the current Thamyr instance at call time.
1830
+ Calls made before initialization completes wait for `useInitThamyr()` to finish;
1831
+ they reject if initialization fails or no `useInitThamyr()` is mounted.
1832
+
1833
+ @example
1834
+ ```tsx
1835
+ function SiteMap() {
1836
+ const { getSitemap } = useSitemap();
1837
+ useEffect(() => { getSitemap().then(setSitemap); }, []);
1838
+ }
1839
+ ```
1840
+ */
1841
+ declare function useSitemap(): SitemapActions;
1842
+
1843
+ /**
1844
+ The generated API surface (`thamyrApi.content.getPage({language, id})`),
1845
+ usable from anywhere — components, event handlers, plain modules.
1846
+
1847
+ Referentially stable and never undefined: it delegates to the current Thamyr
1848
+ instance at call time. A method called before initialization completes
1849
+ transparently waits for `useInitThamyr()` to finish (surviving StrictMode's
1850
+ init → reset → init), rejects with the initialization error when init fails,
1851
+ rejects with setup guidance when no `useInitThamyr()` is mounted at all, and
1852
+ rejects if the last `useInitThamyr()` unmounts while the call is waiting.
1853
+
1854
+ Only the generated namespaces are fronted (property probing like
1855
+ `'content' in thamyrApi` or `typeof ns.method === 'function'` is not
1856
+ meaningful on the facade); for the underlying instance or the raw fetch
1857
+ client, read `useCallimacusStore.getState()._thamyr`.
1858
+
1859
+ In React components, prefer {@link useApi}, which returns this object.
1860
+ */
1861
+ declare const thamyrApi: CallimacusApi;
1862
+
1863
+ type ResponseListener = (message: ThamyrResponse) => void;
1864
+ type ConnectionListener = (status: ConnectionStatus) => void;
1865
+ type ErrorListener = (error: ErrorMessage) => void;
1866
+ type CallimacusState = {
1867
+ connectionStatus: ConnectionStatus;
1868
+ messages: ThamyrResponse[];
1869
+ error: ErrorMessage | undefined;
1870
+ _initialized: boolean;
1871
+ _thamyr: Thamyr | undefined;
1872
+ init: (config: CallimacusInitConfig) => void;
1873
+ reset: () => void;
1874
+ sendEvent: <T extends UserInteractionType>(type: T, payload: InteractionPayloadMap[T]) => void;
1875
+ sendAudio: (audio: Blob, query?: string) => void;
1876
+ addResponseListener: (cb: ResponseListener) => () => void;
1877
+ addConnectionListener: (cb: ConnectionListener) => () => void;
1878
+ addErrorListener: (cb: ErrorListener) => () => void;
1879
+ };
1880
+ /**
1881
+ Low-level Zustand store powering the Thamyr React SDK.
1882
+
1883
+ Prefer the higher-level hooks (`useInitThamyr`, `useThamyr`, `useConnection`, etc.)
1884
+ unless you need direct access to the store state or actions.
1885
+ */
1886
+ declare const useCallimacusStore: zustand.UseBoundStore<zustand.StoreApi<CallimacusState>>;
1887
+
1888
+ type VoiceRecorderState = 'idle' | 'recording' | 'processing';
1889
+ type UseVoiceRecorderOptions = {
1890
+ silenceThreshold?: number;
1891
+ silenceDuration?: number;
1892
+ maxDuration?: number;
1893
+ onRecordingComplete: (audioBlob: Blob) => void;
1894
+ };
1895
+ type UseVoiceRecorderReturn = {
1896
+ state: VoiceRecorderState;
1897
+ audioLevels: number[];
1898
+ startRecording: () => Promise<void>;
1899
+ stopRecording: () => void;
1900
+ reset: () => void;
1901
+ error: string | undefined;
1902
+ };
1903
+ declare function useVoiceRecorder({ silenceThreshold, silenceDuration, maxDuration, onRecordingComplete, }: UseVoiceRecorderOptions): UseVoiceRecorderReturn;
1904
+
1905
+ type TtsAudioState = 'idle' | 'loading' | 'playing' | 'paused' | 'ended' | 'error';
1906
+ type UseTtsAudioReturn = {
1907
+ /**
1908
+ Fine-grained playback state.
1909
+ */
1910
+ state: TtsAudioState;
1911
+ /**
1912
+ True while the clip is playing or buffering toward playback.
1913
+ */
1914
+ isPlaying: boolean;
1915
+ /**
1916
+ Set when playback fails (autoplay blocked, network, decode).
1917
+ */
1918
+ error: string | undefined;
1919
+ /**
1920
+ Start (or resume) playback. Safe to call from a click handler.
1921
+ */
1922
+ play: () => Promise<void>;
1923
+ /**
1924
+ Pause without resetting position.
1925
+ */
1926
+ pause: () => void;
1927
+ /**
1928
+ Toggle play/pause.
1929
+ */
1930
+ toggle: () => void;
1931
+ /**
1932
+ Stop and rewind to the start.
1933
+ */
1934
+ stop: () => void;
1935
+ };
1936
+ /**
1937
+ Plays the audio of a streaming `tts` block. Pass the descriptor from
1938
+ `extractTtsAudio(block.data)`; pass `undefined` when the block has no audio.
1939
+
1940
+ The element is created with `preload="none"` so nothing is fetched — and no
1941
+ server-side synthesis is triggered — until the user actually plays. Works for
1942
+ any `tts` block since `audioUrl` is always a plain, progressively-playable
1943
+ stream URL.
1944
+ */
1945
+ declare function useTtsAudio(audio: TtsAudio | undefined): UseTtsAudioReturn;
1946
+
1947
+ export { thamyrApi, useApi, useCallimacusStore, useCart, useConnection, useInitThamyr, useOnConnectionChange, useOnError, useOnResponse, useSitemap, useSkesis, useThamyr, useTtsAudio, useVoiceRecorder };
1948
+ export type { CallimacusInitConfig, CartActions, ConnectionStatus, SitemapActions, SkesisActions, TtsAudioState, UseTtsAudioReturn, UseVoiceRecorderOptions, UseVoiceRecorderReturn, VoiceRecorderState };