@deepdesk/deepdesk-sdk 11.6.1-beta.2 → 11.6.1-beta.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.
package/dist/index.d.mts CHANGED
@@ -214,7 +214,7 @@ type SelectionRange = {
214
214
  /**
215
215
  * A selection range representation for textarea's and contenteditables only using offsets.
216
216
  */
217
- type Caret = {
217
+ type CaretPosition = {
218
218
  top: number;
219
219
  left: number;
220
220
  };
@@ -224,19 +224,18 @@ interface InputEventMap {
224
224
  */
225
225
  change: (event: {
226
226
  plainText: string;
227
+ rawHTML: string | null;
227
228
  }) => void;
228
229
  /**
229
- * Updated value after User, platform and plugin changes
230
+ * Emits selection changes.
230
231
  */
231
- updated: (event: {
232
- plainText: string;
233
- }) => void;
232
+ selection: (event: SelectionRange | null) => void;
234
233
  /**
235
- * Emits when only the caret/selection changes. (No other state changes).
234
+ * Emits when the position of the caret on the screen changed
236
235
  */
237
- selection: (event: SelectionRange | null) => void;
238
- caret: (event: Caret | null) => void;
236
+ caretposition: (event: CaretPosition | null) => void;
239
237
  keydown: (event: KeyboardEvent) => void;
238
+ keyup: (event: KeyboardEvent) => void;
240
239
  paste: (event: {
241
240
  pastedText: string;
242
241
  selectionText: string;
@@ -255,40 +254,34 @@ type InputHandler<K extends keyof InputEventMap> = InputEventMap[K];
255
254
  type InputEventListeners<K extends keyof InputEventMap> = Record<K, InputHandler<K>[]>;
256
255
  declare abstract class InputMediator<HTMLElementType extends HTMLElement> {
257
256
  protected element: HTMLElementType;
257
+ isFocused: boolean;
258
+ isActive: boolean;
259
+ isDisposed: boolean;
258
260
  protected eventListeners: Partial<InputEventListeners<keyof InputEventMap>>;
259
261
  protected disposeHandlers: (() => void)[];
260
- protected currentText: string;
261
- protected currentCaret: Caret | null;
262
- protected currentSelection: SelectionRange;
263
- protected currentHTML: string | null;
264
- protected isFocused: boolean;
265
- protected isActive: boolean;
266
- protected isSettingValue: boolean;
262
+ protected cachedText: string;
263
+ protected cachedCaretPosition: CaretPosition | null;
264
+ protected cachedSelection: SelectionRange;
265
+ protected cachedHTML: string | null;
267
266
  protected isSubmitting: boolean;
268
267
  protected isPossibleClearInputAction: boolean;
269
- protected isDisposed: boolean;
270
268
  constructor(element: HTMLElementType);
271
269
  protected addEventListener(eventName: string, listener: EventListenerOrEventListenerObject): void;
272
270
  protected removeEventListener(eventName: string, listener: EventListenerOrEventListenerObject): void;
273
- protected triggerChange(): void;
274
- protected triggerSelection(): void;
275
- protected triggerCaretPosition(): void;
271
+ protected handleInteraction(): void;
276
272
  abstract getSelectedText(): string;
277
- protected handleKeyUp(event: KeyboardEvent): void;
278
273
  protected handleClick(): void;
279
274
  protected handleFocus(): void;
280
275
  protected handleBlur(): void;
281
276
  protected handleKeyDown(event: KeyboardEvent): void;
277
+ protected handleKeyUp(event: KeyboardEvent): void;
282
278
  protected handleCut(): void;
283
279
  protected handlePaste(event: ClipboardEvent): void;
284
- protected listen(options?: {
285
- shouldObserve?: boolean;
286
- }): void;
280
+ protected listen(): void;
287
281
  abstract getText(): string;
288
282
  abstract getHTML(): string | null;
289
283
  abstract getSelection(): SelectionRange;
290
- abstract getCaretPosition(): Caret | null;
291
- abstract applyChanges(callback: (element: HTMLElementType) => void | Promise<void>): void | Promise<void>;
284
+ abstract getCaretPosition(): CaretPosition | null;
292
285
  focus(): void;
293
286
  emit<K extends keyof InputEventMap>(type: K, ...args: Parameters<InputHandler<K>>): void;
294
287
  on<K extends keyof InputEventMap>(type: K, handler: InputHandler<K>): void;
@@ -1049,6 +1042,7 @@ declare namespace Server {
1049
1042
  nickname?: string;
1050
1043
  first_name?: string;
1051
1044
  last_name?: string;
1045
+ default_locale?: string;
1052
1046
  };
1053
1047
  /**
1054
1048
  * Profile
@@ -1467,6 +1461,7 @@ type AgentInfo = {
1467
1461
  agentName?: string;
1468
1462
  agentEmail?: string;
1469
1463
  agentTimeZone?: string;
1464
+ agentDefaultLocale?: string;
1470
1465
  };
1471
1466
  type KnowledgeAssistant = CamelCaseKeys<Server.KnowledgeAssistant>;
1472
1467
  type User = CamelCaseKeys<Server.User>;
@@ -1524,7 +1519,6 @@ declare enum FetchState {
1524
1519
  ERROR = "error"
1525
1520
  }
1526
1521
 
1527
- type KeyboardMetric = Pick<KeyboardEvent, 'key' | 'shiftKey' | 'ctrlKey' | 'altKey' | 'metaKey'>;
1528
1522
  type StageSuggestion = {
1529
1523
  text: string;
1530
1524
  suggestion: TextSuggestion;
@@ -1554,14 +1548,12 @@ type State$6 = {
1554
1548
  text: string;
1555
1549
  html: string | null;
1556
1550
  selection: SelectionRange;
1557
- stagedSuggestion: StageSuggestion | null;
1558
- userCommitted: {
1551
+ beforeKeyUp: {
1559
1552
  text: string;
1560
1553
  selection: SelectionRange;
1561
- };
1562
- tabCompletionSuggestion?: TextSuggestion;
1554
+ } | null;
1555
+ mixedSuggestion: TextSuggestion | null;
1563
1556
  metrics: MetricState;
1564
- previousKeyDownEvent: KeyboardMetric | null;
1565
1557
  textSuggestions: TextSuggestion[];
1566
1558
  selectedSuggestionIndex: number;
1567
1559
  };
@@ -2222,19 +2214,8 @@ declare class DeepdeskSDK {
2222
2214
  * Only refresh text suggestions when the agent is not typing.
2223
2215
  */
2224
2216
  refresh(): Promise<void>;
2225
- /**
2226
- * Method to call when the agent input has changed
2227
- */
2228
- private notifyInputChanged;
2229
- /**
2230
- * Method to call for the agent input keydown event
2231
- */
2232
- private notifyKeyDown;
2233
- private notifyPaste;
2234
- private notifyCut;
2235
2217
  notifyExternalSuggestion(suggestion: StageSuggestion): void;
2236
2218
  evaluateRule(label: string, params?: Record<string, any>, options?: EvaluateRuleOptions): Promise<Cue[]>;
2237
- private handleInputChanged;
2238
2219
  private handleKeyDown;
2239
2220
  private handleAfterSendMessage;
2240
2221
  handlingTimeStart(): void;
@@ -2248,10 +2229,7 @@ declare class DeepdeskSDK {
2248
2229
  notifySubmit(options?: {
2249
2230
  text?: string;
2250
2231
  }): void;
2251
- stageSelectedSuggestion(eventMetrics: SuggestionEventMetrics): void;
2252
- emit<K extends keyof SDKEventMap>(type: K, eventPayload: SDKEventMap[K], options?: {
2253
- mayApplyChanges?: boolean;
2254
- }): void;
2232
+ emit<K extends keyof SDKEventMap>(type: K, eventPayload: SDKEventMap[K]): void;
2255
2233
  /**
2256
2234
  * Attach listener to SDK event
2257
2235
  * Returns removeListener
@@ -2317,11 +2295,7 @@ declare class ContentEditableInput extends InputMediator<HTMLDivElement> {
2317
2295
  } | null;
2318
2296
  getSelection(): SelectionRange;
2319
2297
  getSelectedText(): string;
2320
- applyChanges(callback: (element: HTMLDivElement) => void | Promise<void>): void | Promise<void>;
2321
- listen(options?: {
2322
- shouldObserve?: boolean;
2323
- }): void;
2324
- dispose(): void;
2298
+ listen(): void;
2325
2299
  }
2326
2300
 
2327
2301
  declare class TextAreaInput extends InputMediator<HTMLTextAreaElement> {
@@ -2330,8 +2304,7 @@ declare class TextAreaInput extends InputMediator<HTMLTextAreaElement> {
2330
2304
  getHTML(): string | null;
2331
2305
  getSelection(): SelectionRange;
2332
2306
  getSelectedText(): string;
2333
- getCaretPosition(): Caret | null;
2334
- applyChanges(callback: (element: HTMLTextAreaElement) => void | Promise<void>): void | Promise<void>;
2307
+ getCaretPosition(): CaretPosition | null;
2335
2308
  listen(): void;
2336
2309
  }
2337
2310
 
package/dist/index.d.ts CHANGED
@@ -214,7 +214,7 @@ type SelectionRange = {
214
214
  /**
215
215
  * A selection range representation for textarea's and contenteditables only using offsets.
216
216
  */
217
- type Caret = {
217
+ type CaretPosition = {
218
218
  top: number;
219
219
  left: number;
220
220
  };
@@ -224,19 +224,18 @@ interface InputEventMap {
224
224
  */
225
225
  change: (event: {
226
226
  plainText: string;
227
+ rawHTML: string | null;
227
228
  }) => void;
228
229
  /**
229
- * Updated value after User, platform and plugin changes
230
+ * Emits selection changes.
230
231
  */
231
- updated: (event: {
232
- plainText: string;
233
- }) => void;
232
+ selection: (event: SelectionRange | null) => void;
234
233
  /**
235
- * Emits when only the caret/selection changes. (No other state changes).
234
+ * Emits when the position of the caret on the screen changed
236
235
  */
237
- selection: (event: SelectionRange | null) => void;
238
- caret: (event: Caret | null) => void;
236
+ caretposition: (event: CaretPosition | null) => void;
239
237
  keydown: (event: KeyboardEvent) => void;
238
+ keyup: (event: KeyboardEvent) => void;
240
239
  paste: (event: {
241
240
  pastedText: string;
242
241
  selectionText: string;
@@ -255,40 +254,34 @@ type InputHandler<K extends keyof InputEventMap> = InputEventMap[K];
255
254
  type InputEventListeners<K extends keyof InputEventMap> = Record<K, InputHandler<K>[]>;
256
255
  declare abstract class InputMediator<HTMLElementType extends HTMLElement> {
257
256
  protected element: HTMLElementType;
257
+ isFocused: boolean;
258
+ isActive: boolean;
259
+ isDisposed: boolean;
258
260
  protected eventListeners: Partial<InputEventListeners<keyof InputEventMap>>;
259
261
  protected disposeHandlers: (() => void)[];
260
- protected currentText: string;
261
- protected currentCaret: Caret | null;
262
- protected currentSelection: SelectionRange;
263
- protected currentHTML: string | null;
264
- protected isFocused: boolean;
265
- protected isActive: boolean;
266
- protected isSettingValue: boolean;
262
+ protected cachedText: string;
263
+ protected cachedCaretPosition: CaretPosition | null;
264
+ protected cachedSelection: SelectionRange;
265
+ protected cachedHTML: string | null;
267
266
  protected isSubmitting: boolean;
268
267
  protected isPossibleClearInputAction: boolean;
269
- protected isDisposed: boolean;
270
268
  constructor(element: HTMLElementType);
271
269
  protected addEventListener(eventName: string, listener: EventListenerOrEventListenerObject): void;
272
270
  protected removeEventListener(eventName: string, listener: EventListenerOrEventListenerObject): void;
273
- protected triggerChange(): void;
274
- protected triggerSelection(): void;
275
- protected triggerCaretPosition(): void;
271
+ protected handleInteraction(): void;
276
272
  abstract getSelectedText(): string;
277
- protected handleKeyUp(event: KeyboardEvent): void;
278
273
  protected handleClick(): void;
279
274
  protected handleFocus(): void;
280
275
  protected handleBlur(): void;
281
276
  protected handleKeyDown(event: KeyboardEvent): void;
277
+ protected handleKeyUp(event: KeyboardEvent): void;
282
278
  protected handleCut(): void;
283
279
  protected handlePaste(event: ClipboardEvent): void;
284
- protected listen(options?: {
285
- shouldObserve?: boolean;
286
- }): void;
280
+ protected listen(): void;
287
281
  abstract getText(): string;
288
282
  abstract getHTML(): string | null;
289
283
  abstract getSelection(): SelectionRange;
290
- abstract getCaretPosition(): Caret | null;
291
- abstract applyChanges(callback: (element: HTMLElementType) => void | Promise<void>): void | Promise<void>;
284
+ abstract getCaretPosition(): CaretPosition | null;
292
285
  focus(): void;
293
286
  emit<K extends keyof InputEventMap>(type: K, ...args: Parameters<InputHandler<K>>): void;
294
287
  on<K extends keyof InputEventMap>(type: K, handler: InputHandler<K>): void;
@@ -1049,6 +1042,7 @@ declare namespace Server {
1049
1042
  nickname?: string;
1050
1043
  first_name?: string;
1051
1044
  last_name?: string;
1045
+ default_locale?: string;
1052
1046
  };
1053
1047
  /**
1054
1048
  * Profile
@@ -1467,6 +1461,7 @@ type AgentInfo = {
1467
1461
  agentName?: string;
1468
1462
  agentEmail?: string;
1469
1463
  agentTimeZone?: string;
1464
+ agentDefaultLocale?: string;
1470
1465
  };
1471
1466
  type KnowledgeAssistant = CamelCaseKeys<Server.KnowledgeAssistant>;
1472
1467
  type User = CamelCaseKeys<Server.User>;
@@ -1524,7 +1519,6 @@ declare enum FetchState {
1524
1519
  ERROR = "error"
1525
1520
  }
1526
1521
 
1527
- type KeyboardMetric = Pick<KeyboardEvent, 'key' | 'shiftKey' | 'ctrlKey' | 'altKey' | 'metaKey'>;
1528
1522
  type StageSuggestion = {
1529
1523
  text: string;
1530
1524
  suggestion: TextSuggestion;
@@ -1554,14 +1548,12 @@ type State$6 = {
1554
1548
  text: string;
1555
1549
  html: string | null;
1556
1550
  selection: SelectionRange;
1557
- stagedSuggestion: StageSuggestion | null;
1558
- userCommitted: {
1551
+ beforeKeyUp: {
1559
1552
  text: string;
1560
1553
  selection: SelectionRange;
1561
- };
1562
- tabCompletionSuggestion?: TextSuggestion;
1554
+ } | null;
1555
+ mixedSuggestion: TextSuggestion | null;
1563
1556
  metrics: MetricState;
1564
- previousKeyDownEvent: KeyboardMetric | null;
1565
1557
  textSuggestions: TextSuggestion[];
1566
1558
  selectedSuggestionIndex: number;
1567
1559
  };
@@ -2222,19 +2214,8 @@ declare class DeepdeskSDK {
2222
2214
  * Only refresh text suggestions when the agent is not typing.
2223
2215
  */
2224
2216
  refresh(): Promise<void>;
2225
- /**
2226
- * Method to call when the agent input has changed
2227
- */
2228
- private notifyInputChanged;
2229
- /**
2230
- * Method to call for the agent input keydown event
2231
- */
2232
- private notifyKeyDown;
2233
- private notifyPaste;
2234
- private notifyCut;
2235
2217
  notifyExternalSuggestion(suggestion: StageSuggestion): void;
2236
2218
  evaluateRule(label: string, params?: Record<string, any>, options?: EvaluateRuleOptions): Promise<Cue[]>;
2237
- private handleInputChanged;
2238
2219
  private handleKeyDown;
2239
2220
  private handleAfterSendMessage;
2240
2221
  handlingTimeStart(): void;
@@ -2248,10 +2229,7 @@ declare class DeepdeskSDK {
2248
2229
  notifySubmit(options?: {
2249
2230
  text?: string;
2250
2231
  }): void;
2251
- stageSelectedSuggestion(eventMetrics: SuggestionEventMetrics): void;
2252
- emit<K extends keyof SDKEventMap>(type: K, eventPayload: SDKEventMap[K], options?: {
2253
- mayApplyChanges?: boolean;
2254
- }): void;
2232
+ emit<K extends keyof SDKEventMap>(type: K, eventPayload: SDKEventMap[K]): void;
2255
2233
  /**
2256
2234
  * Attach listener to SDK event
2257
2235
  * Returns removeListener
@@ -2317,11 +2295,7 @@ declare class ContentEditableInput extends InputMediator<HTMLDivElement> {
2317
2295
  } | null;
2318
2296
  getSelection(): SelectionRange;
2319
2297
  getSelectedText(): string;
2320
- applyChanges(callback: (element: HTMLDivElement) => void | Promise<void>): void | Promise<void>;
2321
- listen(options?: {
2322
- shouldObserve?: boolean;
2323
- }): void;
2324
- dispose(): void;
2298
+ listen(): void;
2325
2299
  }
2326
2300
 
2327
2301
  declare class TextAreaInput extends InputMediator<HTMLTextAreaElement> {
@@ -2330,8 +2304,7 @@ declare class TextAreaInput extends InputMediator<HTMLTextAreaElement> {
2330
2304
  getHTML(): string | null;
2331
2305
  getSelection(): SelectionRange;
2332
2306
  getSelectedText(): string;
2333
- getCaretPosition(): Caret | null;
2334
- applyChanges(callback: (element: HTMLTextAreaElement) => void | Promise<void>): void | Promise<void>;
2307
+ getCaretPosition(): CaretPosition | null;
2335
2308
  listen(): void;
2336
2309
  }
2337
2310