@onedeskpro/chatbot-types 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Typetech IT
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,28 @@
1
+ # @onedeskpro/chatbot-types
2
+
3
+ Shared TypeScript types for the [Onedesk Pro](https://onedeskpro.com) Chatbot SDK. Types only — the runtime bundle is empty.
4
+
5
+ You normally do not install this directly: [`@onedeskpro/chatbot-core`](https://www.npmjs.com/package/@onedeskpro/chatbot-core) and [`@onedeskpro/chatbot-react`](https://www.npmjs.com/package/@onedeskpro/chatbot-react) both re-export what you need. Install it when you want the types on their own — for example in a backend that mirrors the chat API shapes.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ npm install --save-dev @onedeskpro/chatbot-types
11
+ ```
12
+
13
+ ## Exports
14
+
15
+ | Type | Purpose |
16
+ | --- | --- |
17
+ | `ChatbotInitOptions` | Options accepted by `ChatbotCore.init` and `ChatbotProvider`. |
18
+ | `ChatbotState` | Snapshot of widget state. |
19
+ | `ChatMessage` | A single human or AI message. |
20
+ | `ChatbotEventMap` | Event names mapped to payloads, including `state-change`. |
21
+ | `ChatbotBlockReason` | Why a bot is not ready (`'no-prompt' \| 'no-directories' \| null`). |
22
+ | `SdkConfigResponse` | Remote agent configuration and readiness. |
23
+ | `ChatRequest` / `ChatResponseData` | Chat endpoint request and response bodies. |
24
+ | `ApiResponse<T>` / `ApiError` | Onedesk Pro API envelopes. |
25
+
26
+ ## License
27
+
28
+ MIT © Typetech IT
package/dist/index.cjs ADDED
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+
16
+ // src/index.ts
17
+ var index_exports = {};
18
+ module.exports = __toCommonJS(index_exports);
@@ -0,0 +1,77 @@
1
+ interface ChatbotInitOptions {
2
+ apiKey: string;
3
+ apiBaseUrl?: string;
4
+ chatbotName?: string;
5
+ primaryColor?: string;
6
+ theme?: 'light' | 'dark' | 'auto';
7
+ position?: 'bottom-right' | 'bottom-left';
8
+ welcomeMessage?: string;
9
+ placeholder?: string;
10
+ autoOpen?: boolean;
11
+ sessionId?: string;
12
+ /** Abort an API request that has not responded in this many ms. Defaults to 30000. */
13
+ requestTimeoutMs?: number;
14
+ }
15
+ interface ApiResponse<T> {
16
+ statusCode: number;
17
+ message: string;
18
+ data: T;
19
+ timestamp: string;
20
+ path: string;
21
+ }
22
+ interface ApiError {
23
+ statusCode: number;
24
+ message: string;
25
+ code: string;
26
+ timestamp: string;
27
+ path: string;
28
+ }
29
+ interface ChatRequest {
30
+ chatInput: string;
31
+ sessionId?: string;
32
+ }
33
+ interface ChatResponseData {
34
+ text: string;
35
+ sessionId: string;
36
+ }
37
+ interface ChatMessage {
38
+ id: number;
39
+ sessionId: string;
40
+ message: {
41
+ type: 'human' | 'ai';
42
+ content: string;
43
+ };
44
+ }
45
+ type ChatbotBlockReason = 'no-prompt' | 'no-directories' | null;
46
+ interface SdkConfigResponse {
47
+ agentId: string;
48
+ agentName: string;
49
+ ready: boolean;
50
+ blockReason: ChatbotBlockReason;
51
+ }
52
+ type ChatbotEventMap = {
53
+ /** Fired for every message added to the conversation, human and AI alike. */
54
+ message: ChatMessage;
55
+ /**
56
+ * Fired whenever any part of the state changes — including the ones no other
57
+ * event covers, such as `isLoading` flipping while a reply is in flight.
58
+ * Carries the new state so subscribers do not have to call `getState()`.
59
+ */
60
+ 'state-change': ChatbotState;
61
+ open: void;
62
+ close: void;
63
+ error: Error;
64
+ 'session-reset': void;
65
+ ready: void;
66
+ };
67
+ interface ChatbotState {
68
+ isOpen: boolean;
69
+ isLoading: boolean;
70
+ isReady: boolean;
71
+ blockReason: ChatbotBlockReason;
72
+ messages: ChatMessage[];
73
+ sessionId: string | null;
74
+ error: string | null;
75
+ }
76
+
77
+ export type { ApiError, ApiResponse, ChatMessage, ChatRequest, ChatResponseData, ChatbotBlockReason, ChatbotEventMap, ChatbotInitOptions, ChatbotState, SdkConfigResponse };
@@ -0,0 +1,77 @@
1
+ interface ChatbotInitOptions {
2
+ apiKey: string;
3
+ apiBaseUrl?: string;
4
+ chatbotName?: string;
5
+ primaryColor?: string;
6
+ theme?: 'light' | 'dark' | 'auto';
7
+ position?: 'bottom-right' | 'bottom-left';
8
+ welcomeMessage?: string;
9
+ placeholder?: string;
10
+ autoOpen?: boolean;
11
+ sessionId?: string;
12
+ /** Abort an API request that has not responded in this many ms. Defaults to 30000. */
13
+ requestTimeoutMs?: number;
14
+ }
15
+ interface ApiResponse<T> {
16
+ statusCode: number;
17
+ message: string;
18
+ data: T;
19
+ timestamp: string;
20
+ path: string;
21
+ }
22
+ interface ApiError {
23
+ statusCode: number;
24
+ message: string;
25
+ code: string;
26
+ timestamp: string;
27
+ path: string;
28
+ }
29
+ interface ChatRequest {
30
+ chatInput: string;
31
+ sessionId?: string;
32
+ }
33
+ interface ChatResponseData {
34
+ text: string;
35
+ sessionId: string;
36
+ }
37
+ interface ChatMessage {
38
+ id: number;
39
+ sessionId: string;
40
+ message: {
41
+ type: 'human' | 'ai';
42
+ content: string;
43
+ };
44
+ }
45
+ type ChatbotBlockReason = 'no-prompt' | 'no-directories' | null;
46
+ interface SdkConfigResponse {
47
+ agentId: string;
48
+ agentName: string;
49
+ ready: boolean;
50
+ blockReason: ChatbotBlockReason;
51
+ }
52
+ type ChatbotEventMap = {
53
+ /** Fired for every message added to the conversation, human and AI alike. */
54
+ message: ChatMessage;
55
+ /**
56
+ * Fired whenever any part of the state changes — including the ones no other
57
+ * event covers, such as `isLoading` flipping while a reply is in flight.
58
+ * Carries the new state so subscribers do not have to call `getState()`.
59
+ */
60
+ 'state-change': ChatbotState;
61
+ open: void;
62
+ close: void;
63
+ error: Error;
64
+ 'session-reset': void;
65
+ ready: void;
66
+ };
67
+ interface ChatbotState {
68
+ isOpen: boolean;
69
+ isLoading: boolean;
70
+ isReady: boolean;
71
+ blockReason: ChatbotBlockReason;
72
+ messages: ChatMessage[];
73
+ sessionId: string | null;
74
+ error: string | null;
75
+ }
76
+
77
+ export type { ApiError, ApiResponse, ChatMessage, ChatRequest, ChatResponseData, ChatbotBlockReason, ChatbotEventMap, ChatbotInitOptions, ChatbotState, SdkConfigResponse };
package/dist/index.js ADDED
File without changes
package/package.json ADDED
@@ -0,0 +1,56 @@
1
+ {
2
+ "name": "@onedeskpro/chatbot-types",
3
+ "version": "0.1.0",
4
+ "description": "Shared TypeScript types for the Onedesk Pro Chatbot SDK",
5
+ "license": "MIT",
6
+ "author": "Typetech IT <support@onedeskpro.com>",
7
+ "homepage": "https://github.com/onedeskpro/onedeskpro-chatbot-sdk#readme",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/onedeskpro/onedeskpro-chatbot-sdk.git",
11
+ "directory": "packages/shared-types"
12
+ },
13
+ "bugs": {
14
+ "url": "https://github.com/onedeskpro/onedeskpro-chatbot-sdk/issues"
15
+ },
16
+ "keywords": [
17
+ "onedeskpro",
18
+ "chatbot",
19
+ "types",
20
+ "typescript",
21
+ "sdk"
22
+ ],
23
+ "sideEffects": false,
24
+ "type": "module",
25
+ "main": "./dist/index.cjs",
26
+ "module": "./dist/index.js",
27
+ "types": "./dist/index.d.ts",
28
+ "exports": {
29
+ ".": {
30
+ "import": {
31
+ "types": "./dist/index.d.ts",
32
+ "default": "./dist/index.js"
33
+ },
34
+ "require": {
35
+ "types": "./dist/index.d.cts",
36
+ "default": "./dist/index.cjs"
37
+ }
38
+ },
39
+ "./package.json": "./package.json"
40
+ },
41
+ "files": [
42
+ "dist"
43
+ ],
44
+ "publishConfig": {
45
+ "access": "public"
46
+ },
47
+ "devDependencies": {
48
+ "tsup": "^8.0.0",
49
+ "typescript": "^5.5.0"
50
+ },
51
+ "scripts": {
52
+ "build": "tsup",
53
+ "type-check": "tsc --noEmit",
54
+ "clean": "rm -rf dist"
55
+ }
56
+ }