@deepdesk/deepdesk-sdk 10.1.14 → 10.1.16-beta.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.d.mts CHANGED
@@ -218,7 +218,7 @@ interface InputEventMap {
218
218
  plainText: string;
219
219
  }) => void;
220
220
  /**
221
- * Changed selection of input
221
+ * Emits when only the caret/selection changes. (No other state changes).
222
222
  */
223
223
  selection: (event: SelectionRange | null) => void;
224
224
  keydown: (event: KeyboardEvent) => void;
@@ -243,6 +243,7 @@ declare abstract class InputMediator<HTMLElementType extends HTMLElement> {
243
243
  protected eventListeners: Partial<InputEventListeners<keyof InputEventMap>>;
244
244
  protected disposeHandlers: (() => void)[];
245
245
  protected currentText: string;
246
+ protected currentSelection: SelectionRange;
246
247
  protected currentHTML: string | null;
247
248
  protected isFocused: boolean;
248
249
  protected isActive: boolean;
@@ -254,8 +255,10 @@ declare abstract class InputMediator<HTMLElementType extends HTMLElement> {
254
255
  protected addEventListener(eventName: string, listener: EventListenerOrEventListenerObject): void;
255
256
  protected removeEventListener(eventName: string, listener: EventListenerOrEventListenerObject): void;
256
257
  protected triggerChange(): void;
258
+ protected triggerSelection(): void;
257
259
  abstract getSelectedText(): string;
258
260
  protected handleKeyUp(event: KeyboardEvent): void;
261
+ protected handleClick(): void;
259
262
  protected handleFocus(): void;
260
263
  protected handleBlur(): void;
261
264
  protected handleKeyDown(event: KeyboardEvent): void;
@@ -264,7 +267,7 @@ declare abstract class InputMediator<HTMLElementType extends HTMLElement> {
264
267
  protected listen(): void;
265
268
  abstract getText(): string;
266
269
  abstract getHTML(): string | null;
267
- abstract getSelection(): SelectionRange | null;
270
+ abstract getSelection(): SelectionRange;
268
271
  abstract applyChanges(callback: (element: HTMLElementType) => void): void;
269
272
  focus(): void;
270
273
  emit<K extends keyof InputEventMap>(type: K, ...args: Parameters<InputHandler<K>>): void;
@@ -452,9 +455,9 @@ interface StoreConfig {
452
455
  }
453
456
  declare const reducers: redux.Reducer<redux.CombinedState<{
454
457
  activeSuggestion: State$e;
455
- answer: State$c;
458
+ answer: State$6;
456
459
  auth: State$d;
457
- autoflows: State$6;
460
+ autoflows: State$c;
458
461
  conversation: State$b;
459
462
  contentTypes: State$a;
460
463
  customMessages: State$9;
@@ -513,9 +516,9 @@ declare const reducers: redux.Reducer<redux.CombinedState<{
513
516
  }>, redux.AnyAction>;
514
517
  declare function createStore(config: StoreConfig): _reduxjs_toolkit_dist_configureStore.ToolkitStore<redux.EmptyObject & {
515
518
  activeSuggestion: State$e;
516
- answer: State$c;
519
+ answer: State$6;
517
520
  auth: State$d;
518
- autoflows: State$6;
521
+ autoflows: State$c;
519
522
  conversation: State$b;
520
523
  contentTypes: State$a;
521
524
  customMessages: State$9;
@@ -573,9 +576,9 @@ declare function createStore(config: StoreConfig): _reduxjs_toolkit_dist_configu
573
576
  textSuggestions: TextSuggestionState;
574
577
  }, redux.AnyAction, _reduxjs_toolkit.ThunkMiddleware<redux.CombinedState<{
575
578
  activeSuggestion: State$e;
576
- answer: State$c;
579
+ answer: State$6;
577
580
  auth: State$d;
578
- autoflows: State$6;
581
+ autoflows: State$c;
579
582
  conversation: State$b;
580
583
  contentTypes: State$a;
581
584
  customMessages: State$9;
@@ -646,6 +649,47 @@ interface State$d {
646
649
  showLoginOverlay: boolean;
647
650
  }
648
651
 
652
+ type Autoflow = CamelCaseKeys<Server$1.Autoflow> & {
653
+ isBusy?: boolean;
654
+ };
655
+ interface State$c {
656
+ list: Autoflow[];
657
+ fetchState: FetchState;
658
+ isInitialRequest: null | boolean;
659
+ }
660
+
661
+ interface State$b {
662
+ current: Conversation | null;
663
+ isSupported: boolean | null;
664
+ }
665
+
666
+ type ContentType = CamelCaseKeys<Server.ContentType>;
667
+ type State$a = {
668
+ data: ContentType[] | null;
669
+ fetchState: FetchState;
670
+ };
671
+
672
+ type CustomMessage = CamelCaseKeys<Server$1.CustomMessage>;
673
+ interface State$9 {
674
+ list: CustomMessage[];
675
+ fetchState: FetchState;
676
+ isInitialRequest: null | boolean;
677
+ sentSuggestions: string[];
678
+ errorSuggestions: string[];
679
+ answeredSuggestions: string[];
680
+ }
681
+
682
+ type State$8 = {
683
+ jwt: string | null;
684
+ accountUrl: string | null;
685
+ interval: NodeJS.Timer | null;
686
+ };
687
+
688
+ type State$7 = {
689
+ data: Entity[] | null;
690
+ fetchState: FetchState;
691
+ };
692
+
649
693
  interface ListItemSource {
650
694
  url?: string;
651
695
  name: string;
@@ -663,7 +707,7 @@ interface KnowledgeResponse {
663
707
  question: string;
664
708
  answer: KnowledgeAnswer;
665
709
  }
666
- type State$c = {
710
+ type State$6 = {
667
711
  data: KnowledgeResponse[];
668
712
  fetchState: FetchState;
669
713
  };
@@ -1192,45 +1236,201 @@ declare class DeepdeskAPI {
1192
1236
  private handleDeepdeskVersionHeaders;
1193
1237
  }
1194
1238
 
1195
- interface State$b {
1196
- current: Conversation | null;
1197
- isSupported: boolean | null;
1239
+ declare enum Locale {
1240
+ NL_NL = "nl-NL",
1241
+ EN_US = "en-US"
1242
+ }
1243
+ interface SuggestionApiMetrics {
1244
+ source?: string;
1245
+ score?: number;
1246
+ abVariant?: string;
1247
+ abTestName?: string;
1248
+ sourceText?: string;
1249
+ trainingJobs?: string[];
1198
1250
  }
1251
+ interface TextSuggestion extends SuggestionApiMetrics {
1252
+ id?: string;
1253
+ text: string;
1254
+ url?: string;
1255
+ title?: string;
1256
+ sourceLabel?: string;
1257
+ searchTerm?: string;
1258
+ type?: string;
1259
+ searchKeywords?: string[];
1260
+ image?: string;
1261
+ message?: string;
1262
+ imageSizes?: {
1263
+ small: string;
1264
+ medium: string;
1265
+ large: string;
1266
+ };
1267
+ }
1268
+ interface PinnedMessage extends SuggestionApiMetrics {
1269
+ title: string;
1270
+ message: string;
1271
+ image: string;
1272
+ imageSizes?: {
1273
+ small: string;
1274
+ medium: string;
1275
+ large: string;
1276
+ };
1277
+ }
1278
+ interface UrlSuggestion extends SuggestionApiMetrics {
1279
+ id?: string;
1280
+ url: string;
1281
+ context?: string;
1282
+ image: string;
1283
+ summary?: string;
1284
+ title?: string;
1285
+ imageSizes?: {
1286
+ small: string;
1287
+ medium: string;
1288
+ large: string;
1289
+ };
1290
+ }
1291
+ interface SearchSuggestion extends SuggestionApiMetrics {
1292
+ id?: string;
1293
+ text: string;
1294
+ title?: string;
1295
+ source?: string;
1296
+ context?: string;
1297
+ image?: string;
1298
+ type?: SearchResultType;
1299
+ }
1300
+ interface SuggestionEventMetrics {
1301
+ inputType: InputType;
1302
+ }
1303
+ interface SuggestionMetrics extends SuggestionApiMetrics, SuggestionEventMetrics {
1304
+ text: string;
1305
+ searchTerm?: string | null;
1306
+ }
1307
+ type VisitorInfo = {
1308
+ visitorId?: string;
1309
+ visitorName?: string;
1310
+ visitorTimeZone?: string;
1311
+ psid?: string;
1312
+ };
1313
+ type AgentInfo = {
1314
+ agentId: string;
1315
+ agentNickname: string;
1316
+ agentName?: string;
1317
+ agentEmail?: string;
1318
+ agentTimeZone?: string;
1319
+ };
1320
+ type User = CamelCaseKeys<Server.User>;
1321
+ type SendMessageEventData = CamelCaseKeys<Server.SendMessageEventData>;
1322
+ type Profile = CamelCaseKeys<Server.Profile>;
1199
1323
 
1200
- type ContentType = CamelCaseKeys<Server.ContentType>;
1201
- type State$a = {
1202
- data: ContentType[] | null;
1324
+ type CreateConversation = {
1325
+ platform: string;
1326
+ sessionId: string;
1327
+ profileCode?: string;
1328
+ agentId: string;
1329
+ agentName?: string;
1330
+ agentNickname?: string;
1331
+ agentEmail?: string;
1332
+ tags?: Record<string, string> | null;
1333
+ };
1334
+ interface Entity {
1335
+ text: string;
1336
+ label: string;
1337
+ }
1338
+ /**
1339
+ * Utils
1340
+ */
1341
+ type Logger = {
1342
+ info(...args: any[]): void;
1343
+ warn(...args: any[]): void;
1344
+ error(...args: any[]): void;
1345
+ };
1346
+ declare enum FetchState {
1347
+ IDLE = "idle",
1348
+ LOADING = "loading",
1349
+ DONE = "done",
1350
+ ERROR = "error"
1351
+ }
1352
+
1353
+ type KeyboardMetric = Pick<KeyboardEvent, 'key' | 'shiftKey' | 'ctrlKey' | 'altKey' | 'metaKey'>;
1354
+ type StageSuggestion = {
1355
+ text: string;
1356
+ suggestion: TextSuggestion;
1357
+ eventMetrics: SuggestionEventMetrics;
1358
+ replace: 'selection' | 'until-selection-end';
1359
+ };
1360
+ type EditTextSuggestionPayload = {
1361
+ contentType: string;
1362
+ index: number | null;
1363
+ suggestions: TextSuggestion[];
1364
+ };
1365
+ type MetricState = {
1366
+ numCharsTyped: number;
1367
+ numCharsPasted: number;
1368
+ numCharsCut: number;
1369
+ numCharsDeleted: number;
1370
+ numPaste: number;
1371
+ agentStartedTypingTimestamp: number | null;
1372
+ externalTimeTotalSeconds: number | null;
1373
+ pastes: any[];
1374
+ deletions: any[];
1375
+ offeredTextSuggestions: TextSuggestion[];
1376
+ textSuggestions: SuggestionMetrics[];
1377
+ cuts: any[];
1378
+ };
1379
+ type State$5 = {
1380
+ text: string;
1381
+ html: string | null;
1382
+ selection: SelectionRange;
1383
+ stagedSuggestion: StageSuggestion | null;
1384
+ userCommitted: {
1385
+ text: string;
1386
+ selection: SelectionRange;
1387
+ };
1388
+ tabCompletionSuggestion?: TextSuggestion;
1389
+ metrics: MetricState;
1390
+ previousKeyDownEvent: KeyboardMetric | null;
1391
+ textSuggestions: TextSuggestion[];
1392
+ selectedSuggestionIndex: number;
1393
+ };
1394
+
1395
+ type State$4 = {
1396
+ data: Profile | null;
1203
1397
  fetchState: FetchState;
1204
1398
  };
1205
1399
 
1206
- type CustomMessage = CamelCaseKeys<Server$1.CustomMessage>;
1207
- interface State$9 {
1208
- list: CustomMessage[];
1400
+ type SearchResultType = string | SearchResultDefaultType;
1401
+ declare enum SearchResultDefaultType {
1402
+ url = "URL",
1403
+ personal = "PERSONAL",
1404
+ pinned = "STICKYMESSAGE",
1405
+ image = "IMAGE"
1406
+ }
1407
+ type SearchResult = SearchSuggestion;
1408
+ interface State$3 {
1409
+ list: Array<SearchResult>;
1410
+ page: string;
1209
1411
  fetchState: FetchState;
1210
- isInitialRequest: null | boolean;
1211
- sentSuggestions: string[];
1212
- errorSuggestions: string[];
1213
- answeredSuggestions: string[];
1412
+ isOpen: boolean;
1214
1413
  }
1215
1414
 
1216
- type State$8 = {
1217
- jwt: string | null;
1218
- accountUrl: string | null;
1219
- interval: NodeJS.Timer | null;
1415
+ type State$2 = {
1416
+ data: string | null;
1417
+ fetchState: FetchState;
1220
1418
  };
1221
1419
 
1222
- type State$7 = {
1223
- data: Entity[] | null;
1420
+ type StyleSuggestion = CamelCaseKeys<Server.StyleSuggestion>;
1421
+ interface State$1 {
1422
+ list: StyleSuggestion;
1224
1423
  fetchState: FetchState;
1225
- };
1424
+ isInitialRequest: null | boolean;
1425
+ }
1226
1426
 
1227
- type Autoflow = CamelCaseKeys<Server$1.Autoflow> & {
1228
- isBusy?: boolean;
1229
- };
1230
- interface State$6 {
1231
- list: Autoflow[];
1427
+ type SuggestionState = {
1428
+ suggestions: TextSuggestion[];
1232
1429
  fetchState: FetchState;
1233
1430
  isInitialRequest: null | boolean;
1431
+ };
1432
+ interface TextSuggestionState {
1433
+ [type: string]: SuggestionState;
1234
1434
  }
1235
1435
 
1236
1436
  declare const styles$d: {
@@ -1462,202 +1662,6 @@ type InputOverlayCustomStyles = {
1462
1662
  EditSuggestionTextInput?: Partial<EditSuggestionTextInputStyles>;
1463
1663
  EditSuggestionForm?: Partial<EditSuggestionFormStyles>;
1464
1664
  };
1465
- declare enum Locale {
1466
- NL_NL = "nl-NL",
1467
- EN_US = "en-US"
1468
- }
1469
- interface SuggestionApiMetrics {
1470
- source?: string;
1471
- score?: number;
1472
- abVariant?: string;
1473
- abTestName?: string;
1474
- sourceText?: string;
1475
- trainingJobs?: string[];
1476
- }
1477
- interface TextSuggestion extends SuggestionApiMetrics {
1478
- id?: string;
1479
- text: string;
1480
- url?: string;
1481
- title?: string;
1482
- sourceLabel?: string;
1483
- searchTerm?: string;
1484
- type?: string;
1485
- searchKeywords?: string[];
1486
- image?: string;
1487
- message?: string;
1488
- imageSizes?: {
1489
- small: string;
1490
- medium: string;
1491
- large: string;
1492
- };
1493
- }
1494
- interface PinnedMessage extends SuggestionApiMetrics {
1495
- title: string;
1496
- message: string;
1497
- image: string;
1498
- imageSizes?: {
1499
- small: string;
1500
- medium: string;
1501
- large: string;
1502
- };
1503
- }
1504
- interface UrlSuggestion extends SuggestionApiMetrics {
1505
- id?: string;
1506
- url: string;
1507
- context?: string;
1508
- image: string;
1509
- summary?: string;
1510
- title?: string;
1511
- imageSizes?: {
1512
- small: string;
1513
- medium: string;
1514
- large: string;
1515
- };
1516
- }
1517
- interface SearchSuggestion extends SuggestionApiMetrics {
1518
- id?: string;
1519
- text: string;
1520
- title?: string;
1521
- source?: string;
1522
- context?: string;
1523
- image?: string;
1524
- type?: SearchResultType;
1525
- }
1526
- interface SuggestionEventMetrics {
1527
- inputType: InputType;
1528
- }
1529
- interface SuggestionMetrics extends SuggestionApiMetrics, SuggestionEventMetrics {
1530
- text: string;
1531
- searchTerm?: string | null;
1532
- }
1533
- type VisitorInfo = {
1534
- visitorId?: string;
1535
- visitorName?: string;
1536
- visitorTimeZone?: string;
1537
- psid?: string;
1538
- };
1539
- type AgentInfo = {
1540
- agentId: string;
1541
- agentNickname: string;
1542
- agentName?: string;
1543
- agentEmail?: string;
1544
- agentTimeZone?: string;
1545
- };
1546
- type User = CamelCaseKeys<Server.User>;
1547
- type SendMessageEventData = CamelCaseKeys<Server.SendMessageEventData>;
1548
- type Profile = CamelCaseKeys<Server.Profile>;
1549
-
1550
- type CreateConversation = {
1551
- platform: string;
1552
- sessionId: string;
1553
- profileCode?: string;
1554
- agentId: string;
1555
- agentName?: string;
1556
- agentNickname?: string;
1557
- agentEmail?: string;
1558
- tags?: Record<string, string> | null;
1559
- };
1560
- interface Entity {
1561
- text: string;
1562
- label: string;
1563
- }
1564
- /**
1565
- * Utils
1566
- */
1567
- type Logger = {
1568
- info(...args: any[]): void;
1569
- warn(...args: any[]): void;
1570
- error(...args: any[]): void;
1571
- };
1572
- declare enum FetchState {
1573
- IDLE = "idle",
1574
- LOADING = "loading",
1575
- DONE = "done",
1576
- ERROR = "error"
1577
- }
1578
-
1579
- type KeyboardMetric = Pick<KeyboardEvent, 'key' | 'shiftKey' | 'ctrlKey' | 'altKey' | 'metaKey'>;
1580
- type StageSuggestion = {
1581
- text: string;
1582
- suggestion: TextSuggestion;
1583
- eventMetrics: SuggestionEventMetrics;
1584
- replace: 'selection' | 'until-selection-end';
1585
- };
1586
- type EditTextSuggestionPayload = {
1587
- contentType: string;
1588
- index: number | null;
1589
- suggestions: TextSuggestion[];
1590
- };
1591
- type MetricState = {
1592
- numCharsTyped: number;
1593
- numCharsPasted: number;
1594
- numCharsCut: number;
1595
- numCharsDeleted: number;
1596
- numPaste: number;
1597
- agentStartedTypingTimestamp: number | null;
1598
- externalTimeTotalSeconds: number | null;
1599
- pastes: any[];
1600
- deletions: any[];
1601
- offeredTextSuggestions: TextSuggestion[];
1602
- textSuggestions: SuggestionMetrics[];
1603
- cuts: any[];
1604
- };
1605
- type State$5 = {
1606
- text: string;
1607
- html: string | null;
1608
- selection: SelectionRange;
1609
- stagedSuggestion: StageSuggestion | null;
1610
- userCommitted: {
1611
- text: string;
1612
- selection: SelectionRange;
1613
- };
1614
- tabCompletionSuggestion?: TextSuggestion;
1615
- metrics: MetricState;
1616
- previousKeyDownEvent: KeyboardMetric | null;
1617
- textSuggestions: TextSuggestion[];
1618
- selectedSuggestionIndex: number;
1619
- };
1620
-
1621
- type State$4 = {
1622
- data: Profile | null;
1623
- fetchState: FetchState;
1624
- };
1625
-
1626
- type SearchResultType = string | SearchResultDefaultType;
1627
- declare enum SearchResultDefaultType {
1628
- url = "URL",
1629
- personal = "PERSONAL",
1630
- pinned = "STICKYMESSAGE",
1631
- image = "IMAGE"
1632
- }
1633
- type SearchResult = SearchSuggestion;
1634
- interface State$3 {
1635
- list: Array<SearchResult>;
1636
- page: string;
1637
- fetchState: FetchState;
1638
- isOpen: boolean;
1639
- }
1640
-
1641
- type State$2 = {
1642
- data: string | null;
1643
- fetchState: FetchState;
1644
- };
1645
-
1646
- type StyleSuggestion = CamelCaseKeys<Server.StyleSuggestion>;
1647
- interface State$1 {
1648
- list: StyleSuggestion;
1649
- fetchState: FetchState;
1650
- isInitialRequest: null | boolean;
1651
- }
1652
-
1653
- type SuggestionState = {
1654
- suggestions: TextSuggestion[];
1655
- fetchState: FetchState;
1656
- isInitialRequest: null | boolean;
1657
- };
1658
- interface TextSuggestionState {
1659
- [type: string]: SuggestionState;
1660
- }
1661
1665
 
1662
1666
  interface MessagePayload {
1663
1667
  name: string;
@@ -1795,9 +1799,9 @@ declare class DeepdeskSDK {
1795
1799
  constructor({ deepdeskUrl, brokerUrl, version, locale, token, fetch, productName, createCustomChannel, }: SDKOptions);
1796
1800
  get state(): redux.EmptyObject & {
1797
1801
  activeSuggestion: State$e;
1798
- answer: State$c;
1802
+ answer: State$6;
1799
1803
  auth: State$d;
1800
- autoflows: State$6;
1804
+ autoflows: State$c;
1801
1805
  conversation: State$b;
1802
1806
  contentTypes: State$a;
1803
1807
  customMessages: State$9;
@@ -2045,9 +2049,10 @@ declare class DeepdeskSDK {
2045
2049
  declare class ContentEditableInput extends InputMediator<HTMLDivElement> {
2046
2050
  protected observer?: MutationObserver;
2047
2051
  protected lastKnownSelection: SelectionRange | null;
2052
+ protected getRootNode(): Document | ShadowRoot;
2048
2053
  getText(): string;
2049
2054
  getHTML(): string;
2050
- getRange(): Range | null;
2055
+ getRange(): Range | StaticRange | null;
2051
2056
  getSelection(): SelectionRange;
2052
2057
  getSelectedText(): string;
2053
2058
  applyChanges(callback: (element: HTMLDivElement) => void | Promise<void>): void;
@@ -2145,11 +2150,11 @@ declare function attachFile(fileInput: HTMLInputElement, target: TargetFileOptio
2145
2150
 
2146
2151
  declare function createFullRange(rootElement: Node): Range;
2147
2152
  declare function createRangeFromOffsets(rootElement: HTMLElement, startOffset: number, endOffset: number): Range;
2148
- declare function getRangeOffsets(rootElement: HTMLElement, range: Range): {
2153
+ declare function getRangeOffsets(rootElement: HTMLElement, range: Range | StaticRange): {
2149
2154
  start: number;
2150
2155
  end: number;
2151
2156
  };
2152
- declare function getRangeText(rootElement: Node, range: Range): string;
2157
+ declare function getRangeText(rootElement: Node, range: Range | StaticRange): string;
2153
2158
 
2154
2159
  interface Cancelable {
2155
2160
  (): void;