@onedeskpro/chatbot-types 0.2.1 → 0.3.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.cts CHANGED
@@ -39,10 +39,38 @@ interface VisitorVerifyResponse {
39
39
  valid: boolean;
40
40
  name: string | null;
41
41
  }
42
+ /** A file attached to a message, as stored by the API and echoed in `message:receive`. */
43
+ interface ChatAttachment {
44
+ /** MIME type, e.g. `image/png`. */
45
+ type: string;
46
+ /** Public URL of the stored file. Local previews use a `blob:` URL until the upload lands. */
47
+ url: string;
48
+ fileName: string;
49
+ /** Size in bytes. */
50
+ size: number;
51
+ durationSeconds?: number;
52
+ /** Up to 64 loudness peaks (0–100) for drawing a voice note. */
53
+ waveform?: number[];
54
+ }
55
+ /** How a chat message is stored: plain text, files, or a recorded voice note. */
56
+ type ChatMessageKind = 'text' | 'media' | 'voice';
57
+ /** A finished recording to send with `sendVoice`, as `VoiceRecorder` produces it. */
58
+ interface VoiceRecording {
59
+ blob: Blob;
60
+ /** MIME type of `blob`; defaults to `blob.type`. */
61
+ mimeType?: string;
62
+ durationSeconds: number;
63
+ }
42
64
  interface ChatRequest {
65
+ /** Visitor text; may be empty when `attachments` carry the message. */
43
66
  chatInput: string;
44
67
  visitorToken: string;
68
+ /** Defaults to `media` when attachments are present, otherwise `text`. */
69
+ messageType?: ChatMessageKind;
70
+ attachments?: ChatAttachment[];
45
71
  }
72
+ /** `POST /sdk/upload` answers with the attachment to send back in `POST /sdk/chat`. */
73
+ type UploadAttachmentResponseData = ChatAttachment;
46
74
  /** Widget / bridge episode mode for AI vs human takeover. */
47
75
  type ChatbotTicketMode = 'ai' | 'waiting' | 'human' | 'closed';
48
76
  interface ChatResponseData {
@@ -61,8 +89,12 @@ interface ChatMessage {
61
89
  sessionId: string;
62
90
  message: {
63
91
  type: 'human' | 'ai' | 'agent';
92
+ /** Text, or the caption of a media message (may be empty when `attachments` is set). */
64
93
  content: string;
94
+ attachments?: ChatAttachment[];
65
95
  };
96
+ /** `true` while the visitor's files are still uploading; cleared once the message is sent. */
97
+ pending?: boolean;
66
98
  }
67
99
  /**
68
100
  * Why the chatbot cannot answer, or `null` when it can. The widget stays hidden
@@ -114,4 +146,4 @@ interface ChatbotState {
114
146
  mode: ChatbotTicketMode;
115
147
  }
116
148
 
117
- export type { ApiError, ApiResponse, ChatMessage, ChatRequest, ChatResponseData, ChatbotBlockReason, ChatbotEventMap, ChatbotInitOptions, ChatbotState, ChatbotTicketMode, IdentifyRequest, IdentifyResponseData, SdkConfigResponse, TicketStatusData, VisitorVerifyResponse };
149
+ export type { ApiError, ApiResponse, ChatAttachment, ChatMessage, ChatMessageKind, ChatRequest, ChatResponseData, ChatbotBlockReason, ChatbotEventMap, ChatbotInitOptions, ChatbotState, ChatbotTicketMode, IdentifyRequest, IdentifyResponseData, SdkConfigResponse, TicketStatusData, UploadAttachmentResponseData, VisitorVerifyResponse, VoiceRecording };
package/dist/index.d.ts CHANGED
@@ -39,10 +39,38 @@ interface VisitorVerifyResponse {
39
39
  valid: boolean;
40
40
  name: string | null;
41
41
  }
42
+ /** A file attached to a message, as stored by the API and echoed in `message:receive`. */
43
+ interface ChatAttachment {
44
+ /** MIME type, e.g. `image/png`. */
45
+ type: string;
46
+ /** Public URL of the stored file. Local previews use a `blob:` URL until the upload lands. */
47
+ url: string;
48
+ fileName: string;
49
+ /** Size in bytes. */
50
+ size: number;
51
+ durationSeconds?: number;
52
+ /** Up to 64 loudness peaks (0–100) for drawing a voice note. */
53
+ waveform?: number[];
54
+ }
55
+ /** How a chat message is stored: plain text, files, or a recorded voice note. */
56
+ type ChatMessageKind = 'text' | 'media' | 'voice';
57
+ /** A finished recording to send with `sendVoice`, as `VoiceRecorder` produces it. */
58
+ interface VoiceRecording {
59
+ blob: Blob;
60
+ /** MIME type of `blob`; defaults to `blob.type`. */
61
+ mimeType?: string;
62
+ durationSeconds: number;
63
+ }
42
64
  interface ChatRequest {
65
+ /** Visitor text; may be empty when `attachments` carry the message. */
43
66
  chatInput: string;
44
67
  visitorToken: string;
68
+ /** Defaults to `media` when attachments are present, otherwise `text`. */
69
+ messageType?: ChatMessageKind;
70
+ attachments?: ChatAttachment[];
45
71
  }
72
+ /** `POST /sdk/upload` answers with the attachment to send back in `POST /sdk/chat`. */
73
+ type UploadAttachmentResponseData = ChatAttachment;
46
74
  /** Widget / bridge episode mode for AI vs human takeover. */
47
75
  type ChatbotTicketMode = 'ai' | 'waiting' | 'human' | 'closed';
48
76
  interface ChatResponseData {
@@ -61,8 +89,12 @@ interface ChatMessage {
61
89
  sessionId: string;
62
90
  message: {
63
91
  type: 'human' | 'ai' | 'agent';
92
+ /** Text, or the caption of a media message (may be empty when `attachments` is set). */
64
93
  content: string;
94
+ attachments?: ChatAttachment[];
65
95
  };
96
+ /** `true` while the visitor's files are still uploading; cleared once the message is sent. */
97
+ pending?: boolean;
66
98
  }
67
99
  /**
68
100
  * Why the chatbot cannot answer, or `null` when it can. The widget stays hidden
@@ -114,4 +146,4 @@ interface ChatbotState {
114
146
  mode: ChatbotTicketMode;
115
147
  }
116
148
 
117
- export type { ApiError, ApiResponse, ChatMessage, ChatRequest, ChatResponseData, ChatbotBlockReason, ChatbotEventMap, ChatbotInitOptions, ChatbotState, ChatbotTicketMode, IdentifyRequest, IdentifyResponseData, SdkConfigResponse, TicketStatusData, VisitorVerifyResponse };
149
+ export type { ApiError, ApiResponse, ChatAttachment, ChatMessage, ChatMessageKind, ChatRequest, ChatResponseData, ChatbotBlockReason, ChatbotEventMap, ChatbotInitOptions, ChatbotState, ChatbotTicketMode, IdentifyRequest, IdentifyResponseData, SdkConfigResponse, TicketStatusData, UploadAttachmentResponseData, VisitorVerifyResponse, VoiceRecording };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onedeskpro/chatbot-types",
3
- "version": "0.2.1",
3
+ "version": "0.3.0",
4
4
  "description": "Shared TypeScript types for the Onedesk Pro Chatbot SDK",
5
5
  "license": "MIT",
6
6
  "author": "Typetech IT <support@onedeskpro.com>",
@@ -45,7 +45,7 @@
45
45
  "access": "public"
46
46
  },
47
47
  "devDependencies": {
48
- "tsup": "^8.5.1",
48
+ "tsup": "^9.0.0",
49
49
  "typescript": "^6"
50
50
  },
51
51
  "scripts": {