@n8n/chat 0.8.0 → 0.9.1

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.
Files changed (207) hide show
  1. package/__stories__/App.stories.d.ts +16 -0
  2. package/__stories__/App.stories.js +38 -0
  3. package/__stories__/App.stories.mjs +32 -0
  4. package/__tests__/index.spec.d.ts +1 -0
  5. package/__tests__/index.spec.js +146 -0
  6. package/__tests__/index.spec.mjs +172 -0
  7. package/__tests__/setup.js +3 -0
  8. package/__tests__/setup.mjs +1 -0
  9. package/__tests__/utils/create.d.ts +5 -0
  10. package/__tests__/utils/create.js +16 -0
  11. package/__tests__/utils/create.mjs +10 -0
  12. package/__tests__/utils/fetch.d.ts +3 -0
  13. package/__tests__/utils/fetch.js +20 -0
  14. package/__tests__/utils/fetch.mjs +9 -0
  15. package/__tests__/utils/index.js +38 -0
  16. package/__tests__/utils/index.mjs +3 -0
  17. package/__tests__/utils/selectors.d.ts +12 -0
  18. package/__tests__/utils/selectors.js +58 -0
  19. package/__tests__/utils/selectors.mjs +41 -0
  20. package/api/generic.d.ts +6 -0
  21. package/api/generic.js +68 -0
  22. package/api/generic.mjs +54 -0
  23. package/api/index.js +27 -0
  24. package/api/index.mjs +2 -0
  25. package/api/message.d.ts +3 -0
  26. package/api/message.js +33 -0
  27. package/api/message.mjs +30 -0
  28. package/chat.bundle.es.js +10761 -0
  29. package/chat.bundle.umd.js +18 -0
  30. package/chat.es.js +6872 -0
  31. package/chat.umd.js +18 -0
  32. package/components/Button.vue +34 -0
  33. package/components/ChatWindow.vue +104 -0
  34. package/{src/components → components}/GetStarted.vue +7 -7
  35. package/{src/components → components}/GetStartedFooter.vue +2 -2
  36. package/{src/components → components}/Input.vue +34 -39
  37. package/{src/components → components}/Layout.vue +26 -42
  38. package/{src/components → components}/Message.vue +39 -46
  39. package/components/MessageTyping.vue +101 -0
  40. package/{src/components → components}/MessagesList.vue +4 -4
  41. package/{src/components → components}/PoweredBy.vue +6 -7
  42. package/components/index.js +76 -0
  43. package/components/index.mjs +10 -0
  44. package/composables/index.js +38 -0
  45. package/composables/index.mjs +3 -0
  46. package/composables/useChat.d.ts +1 -0
  47. package/composables/useChat.js +11 -0
  48. package/composables/useChat.mjs +5 -0
  49. package/composables/useI18n.d.ts +4 -0
  50. package/composables/useI18n.js +23 -0
  51. package/composables/useI18n.mjs +12 -0
  52. package/composables/useOptions.d.ts +3 -0
  53. package/composables/useOptions.js +14 -0
  54. package/composables/useOptions.mjs +8 -0
  55. package/constants/defaults.d.ts +3 -0
  56. package/constants/defaults.js +32 -0
  57. package/constants/defaults.mjs +26 -0
  58. package/constants/index.js +38 -0
  59. package/constants/index.mjs +3 -0
  60. package/constants/localStorage.d.ts +2 -0
  61. package/constants/localStorage.js +8 -0
  62. package/{src/constants/localStorage.ts → constants/localStorage.mjs} +1 -1
  63. package/constants/symbols.d.ts +3 -0
  64. package/constants/symbols.js +8 -0
  65. package/constants/symbols.mjs +2 -0
  66. package/css/index.css +31 -0
  67. package/event-buses/chatEventBus.d.ts +1 -0
  68. package/event-buses/chatEventBus.js +8 -0
  69. package/event-buses/chatEventBus.mjs +2 -0
  70. package/event-buses/index.js +16 -0
  71. package/event-buses/index.mjs +1 -0
  72. package/index.d.ts +3 -0
  73. package/index.js +43 -0
  74. package/index.mjs +36 -0
  75. package/main.css +151 -0
  76. package/package.json +35 -2
  77. package/plugins/chat.d.ts +3 -0
  78. package/plugins/chat.js +91 -0
  79. package/plugins/chat.mjs +90 -0
  80. package/plugins/index.js +16 -0
  81. package/plugins/index.mjs +1 -0
  82. package/style.css +1 -0
  83. package/types/App.vue.d.ts +8 -0
  84. package/types/__stories__/App.stories.d.ts +17 -0
  85. package/types/__tests__/index.spec.d.ts +1 -0
  86. package/types/__tests__/setup.d.ts +0 -0
  87. package/types/__tests__/utils/create.d.ts +5 -0
  88. package/types/__tests__/utils/fetch.d.ts +4 -0
  89. package/types/__tests__/utils/index.d.ts +3 -0
  90. package/types/__tests__/utils/selectors.d.ts +12 -0
  91. package/types/api/generic.d.ts +6 -0
  92. package/types/api/index.d.ts +2 -0
  93. package/types/api/message.d.ts +3 -0
  94. package/types/chat.d.ts +11 -0
  95. package/types/chat.js +1 -0
  96. package/types/chat.mjs +0 -0
  97. package/types/components/Button.vue.d.ts +9 -0
  98. package/types/components/Chat.vue.d.ts +2 -0
  99. package/types/components/ChatWindow.vue.d.ts +2 -0
  100. package/types/components/GetStarted.vue.d.ts +2 -0
  101. package/types/components/GetStartedFooter.vue.d.ts +2 -0
  102. package/types/components/Input.vue.d.ts +2 -0
  103. package/types/components/Layout.vue.d.ts +11 -0
  104. package/types/components/Message.vue.d.ts +21 -0
  105. package/types/components/MessageTyping.vue.d.ts +15 -0
  106. package/types/components/MessagesList.vue.d.ts +14 -0
  107. package/types/components/PoweredBy.vue.d.ts +2 -0
  108. package/types/components/index.d.ts +10 -0
  109. package/types/composables/index.d.ts +3 -0
  110. package/types/composables/useChat.d.ts +2 -0
  111. package/types/composables/useI18n.d.ts +4 -0
  112. package/types/composables/useOptions.d.ts +4 -0
  113. package/types/constants/defaults.d.ts +3 -0
  114. package/types/constants/index.d.ts +3 -0
  115. package/types/constants/localStorage.d.ts +2 -0
  116. package/types/constants/symbols.d.ts +4 -0
  117. package/types/event-buses/chatEventBus.d.ts +1 -0
  118. package/types/event-buses/index.d.ts +1 -0
  119. package/types/index.js +49 -0
  120. package/types/index.mjs +4 -0
  121. package/types/messages.d.ts +6 -0
  122. package/types/messages.js +1 -0
  123. package/types/messages.mjs +0 -0
  124. package/types/options.d.ts +25 -0
  125. package/types/options.js +1 -0
  126. package/types/options.mjs +0 -0
  127. package/types/plugins/chat.d.ts +3 -0
  128. package/types/plugins/index.d.ts +1 -0
  129. package/types/types/chat.d.ts +11 -0
  130. package/types/types/index.d.ts +4 -0
  131. package/types/types/messages.d.ts +6 -0
  132. package/types/types/options.d.ts +25 -0
  133. package/types/types/webhook.d.ts +16 -0
  134. package/types/utils/event-bus.d.ts +8 -0
  135. package/types/utils/mount.d.ts +1 -0
  136. package/types/webhook.d.ts +16 -0
  137. package/types/webhook.js +1 -0
  138. package/types/webhook.mjs +0 -0
  139. package/utils/event-bus.d.ts +8 -0
  140. package/utils/event-bus.js +38 -0
  141. package/utils/event-bus.mjs +32 -0
  142. package/utils/index.d.ts +2 -0
  143. package/utils/index.js +27 -0
  144. package/utils/index.mjs +2 -0
  145. package/utils/mount.d.ts +1 -0
  146. package/utils/mount.js +19 -0
  147. package/utils/mount.mjs +13 -0
  148. package/.eslintignore +0 -2
  149. package/.eslintrc.cjs +0 -10
  150. package/.np-config.json +0 -5
  151. package/.storybook/main.ts +0 -27
  152. package/.storybook/preview.scss +0 -4
  153. package/.storybook/preview.ts +0 -16
  154. package/.vscode/extensions.json +0 -3
  155. package/build.config.js +0 -21
  156. package/env.d.ts +0 -1
  157. package/index.html +0 -13
  158. package/resources/images/fullscreen.png +0 -0
  159. package/resources/images/windowed.png +0 -0
  160. package/resources/workflow-manual.json +0 -238
  161. package/resources/workflow.json +0 -119
  162. package/scripts/pack.js +0 -11
  163. package/scripts/postbuild.js +0 -36
  164. package/src/__stories__/App.stories.ts +0 -43
  165. package/src/__tests__/index.spec.ts +0 -218
  166. package/src/__tests__/utils/create.ts +0 -16
  167. package/src/__tests__/utils/fetch.ts +0 -18
  168. package/src/__tests__/utils/selectors.ts +0 -53
  169. package/src/api/generic.ts +0 -63
  170. package/src/api/message.ts +0 -37
  171. package/src/components/Button.vue +0 -41
  172. package/src/components/ChatWindow.vue +0 -125
  173. package/src/components/MessageTyping.vue +0 -109
  174. package/src/composables/useChat.ts +0 -7
  175. package/src/composables/useI18n.ts +0 -16
  176. package/src/composables/useOptions.ts +0 -11
  177. package/src/constants/defaults.ts +0 -29
  178. package/src/constants/symbols.ts +0 -8
  179. package/src/css/_tokens.scss +0 -36
  180. package/src/css/index.scss +0 -1
  181. package/src/event-buses/chatEventBus.ts +0 -3
  182. package/src/index.ts +0 -42
  183. package/src/main.scss +0 -5
  184. package/src/plugins/chat.ts +0 -105
  185. package/src/types/chat.ts +0 -12
  186. package/src/types/messages.ts +0 -6
  187. package/src/types/options.ts +0 -28
  188. package/src/types/webhook.ts +0 -17
  189. package/src/utils/event-bus.ts +0 -51
  190. package/src/utils/mount.ts +0 -16
  191. package/tsconfig.json +0 -27
  192. package/vite.config.ts +0 -53
  193. package/vitest.config.ts +0 -20
  194. /package/{src/App.vue → App.vue} +0 -0
  195. /package/{src/__tests__/setup.ts → __tests__/setup.d.ts} +0 -0
  196. /package/{src/__tests__/utils/index.ts → __tests__/utils/index.d.ts} +0 -0
  197. /package/{src/api/index.ts → api/index.d.ts} +0 -0
  198. /package/{src/components → components}/Chat.vue +0 -0
  199. /package/{src/components/index.ts → components/index.d.ts} +0 -0
  200. /package/{src/composables/index.ts → composables/index.d.ts} +0 -0
  201. /package/{src/constants/index.ts → constants/index.d.ts} +0 -0
  202. /package/{src/event-buses/index.ts → event-buses/index.d.ts} +0 -0
  203. /package/{public/favicon.ico → favicon.ico} +0 -0
  204. /package/{src/plugins/index.ts → plugins/index.d.ts} +0 -0
  205. /package/{src/shims.d.ts → shims.d.ts} +0 -0
  206. /package/{src/types/index.ts → types/index.d.ts} +0 -0
  207. /package/{src/utils/index.ts → types/utils/index.d.ts} +0 -0
package/style.css ADDED
@@ -0,0 +1 @@
1
+ .n8n-chat pre code.hljs{display:block;overflow-x:auto;padding:1em}.n8n-chat code.hljs{padding:3px 5px}.n8n-chat .hljs{color:#24292e;background:#ffffff}.n8n-chat .hljs-doctag,.n8n-chat .hljs-keyword,.n8n-chat .hljs-meta .hljs-keyword,.n8n-chat .hljs-template-tag,.n8n-chat .hljs-template-variable,.n8n-chat .hljs-type,.n8n-chat .hljs-variable.language_{color:#d73a49}.n8n-chat .hljs-title,.n8n-chat .hljs-title.class_,.n8n-chat .hljs-title.class_.inherited__,.n8n-chat .hljs-title.function_{color:#6f42c1}.n8n-chat .hljs-attr,.n8n-chat .hljs-attribute,.n8n-chat .hljs-literal,.n8n-chat .hljs-meta,.n8n-chat .hljs-number,.n8n-chat .hljs-operator,.n8n-chat .hljs-variable,.n8n-chat .hljs-selector-attr,.n8n-chat .hljs-selector-class,.n8n-chat .hljs-selector-id{color:#005cc5}.n8n-chat .hljs-regexp,.n8n-chat .hljs-string,.n8n-chat .hljs-meta .hljs-string{color:#032f62}.n8n-chat .hljs-built_in,.n8n-chat .hljs-symbol{color:#e36209}.n8n-chat .hljs-comment,.n8n-chat .hljs-code,.n8n-chat .hljs-formula{color:#6a737d}.n8n-chat .hljs-name,.n8n-chat .hljs-quote,.n8n-chat .hljs-selector-tag,.n8n-chat .hljs-selector-pseudo{color:#22863a}.n8n-chat .hljs-subst{color:#24292e}.n8n-chat .hljs-section{color:#005cc5;font-weight:700}.n8n-chat .hljs-bullet{color:#735c0f}.n8n-chat .hljs-emphasis{color:#24292e;font-style:italic}.n8n-chat .hljs-strong{color:#24292e;font-weight:700}.n8n-chat .hljs-addition{color:#22863a;background-color:#f0fff4}.n8n-chat .hljs-deletion{color:#b31d28;background-color:#ffeef0}:root{--chat--color-primary: #e74266;--chat--color-primary-shade-50: #db4061;--chat--color-primary-shade-100: #cf3c5c;--chat--color-secondary: #20b69e;--chat--color-secondary-shade-50: #1ca08a;--chat--color-white: #ffffff;--chat--color-light: #f2f4f8;--chat--color-light-shade-50: #e6e9f1;--chat--color-light-shade-100: #c2c5cc;--chat--color-medium: #d2d4d9;--chat--color-dark: #101330;--chat--color-disabled: #777980;--chat--color-typing: #404040;--chat--spacing: 1rem;--chat--border-radius: .25rem;--chat--transition-duration: .15s;--chat--window--width: 400px;--chat--window--height: 600px;--chat--textarea--height: 50px;--chat--message--bot--background: var(--chat--color-white);--chat--message--bot--color: var(--chat--color-dark);--chat--message--user--background: var(--chat--color-secondary);--chat--message--user--color: var(--chat--color-white);--chat--message--pre--background: rgba(0, 0, 0, .05);--chat--toggle--background: var(--chat--color-primary);--chat--toggle--hover--background: var(--chat--color-primary-shade-50);--chat--toggle--active--background: var(--chat--color-primary-shade-100);--chat--toggle--color: var(--chat--color-white);--chat--toggle--size: 64px}.chat-button{display:inline-flex;text-align:center;vertical-align:middle;-webkit-user-select:none;user-select:none;color:var(--chat--button--color, var(--chat--color-light));background-color:var(--chat--button--background, var(--chat--color-primary));border:1px solid transparent;padding:var(--chat--button--padding, calc(var(--chat--spacing) * 1 / 2) var(--chat--spacing));font-size:1rem;line-height:1.5;border-radius:var(--chat--button--border-radius, var(--chat--border-radius));transition:color var(--chat--transition-duration) ease-in-out,background-color var(--chat--transition-duration) ease-in-out,border-color var(--chat--transition-duration) ease-in-out,box-shadow var(--chat--transition-duration) ease-in-out;cursor:pointer}.chat-button:hover{color:var(--chat--button--hover--color, var(--chat--color-light));background-color:var(--chat--button--hover--background, var(--chat--color-primary-shade-50));text-decoration:none}.chat-button:focus{outline:0;box-shadow:0 0 0 .2rem #007bff40}.chat-button:disabled{opacity:.65}.chat-layout{width:100%;height:100%;display:flex;overflow-y:auto;flex-direction:column;font-family:var(--chat--font-family, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif)}.chat-layout .chat-header{padding:var(--chat--header--padding, var(--chat--spacing));background:var(--chat--header--background, var(--chat--color-dark));color:var(--chat--header--color, var(--chat--color-light))}.chat-layout .chat-body{background:var(--chat--body--background, var(--chat--color-light));flex:1;display:flex;flex-direction:column;overflow-y:auto;position:relative;min-height:100px}.chat-layout .chat-footer{border-top:1px solid var(--chat--color-light-shade-100);background:var(--chat--footer--background, var(--chat--color-light));color:var(--chat--footer--color, var(--chat--color-dark))}.chat-get-started{padding-top:var(--chat--spacing);padding-bottom:var(--chat--spacing);display:flex;justify-content:center;align-items:center;height:100%}.chat-powered-by{text-align:center}.chat-powered-by a{color:var(--chat--color-primary);text-decoration:none}.chat-get-started-footer{padding:var(--chat--spacing)}.chat-message{display:block;max-width:80%;padding:var(--chat--message--padding, var(--chat--spacing));border-radius:var(--chat--message--border-radius, var(--chat--border-radius))}.chat-message+.chat-message{margin-top:var(--chat--message--margin-bottom, calc(var(--chat--spacing) * .5))}.chat-message.chat-message-from-bot{background-color:var(--chat--message--bot--background);color:var(--chat--message--bot--color);border-bottom-left-radius:0}.chat-message.chat-message-from-user{background-color:var(--chat--message--user--background);color:var(--chat--message--user--color);margin-left:auto;border-bottom-right-radius:0}.chat-message>.chat-message-markdown{display:block;box-sizing:border-box}.chat-message>.chat-message-markdown>*:first-child{margin-top:0}.chat-message>.chat-message-markdown>*:last-child{margin-bottom:0}.chat-message>.chat-message-markdown pre{font-family:inherit;font-size:inherit;margin:0;white-space:pre-wrap;box-sizing:border-box;padding:var(--chat--spacing);background:var(--chat--message--pre--background);border-radius:var(--chat--border-radius)}.chat-message-typing{max-width:80px}.chat-message-typing.chat-message-typing-animation-scaling .chat-message-typing-circle{animation:chat-message-typing-animation-scaling .8s ease-in-out infinite;animation-delay:3.6s}.chat-message-typing.chat-message-typing-animation-bouncing .chat-message-typing-circle{animation:chat-message-typing-animation-bouncing .8s ease-in-out infinite;animation-delay:3.6s}.chat-message-typing .chat-message-typing-body{display:flex;justify-content:center;align-items:center}.chat-message-typing .chat-message-typing-circle{display:block;height:10px;width:10px;border-radius:50%;background-color:var(--chat--color-typing);margin:3px}.chat-message-typing .chat-message-typing-circle:nth-child(1){animation-delay:0ms}.chat-message-typing .chat-message-typing-circle:nth-child(2){animation-delay:333ms}.chat-message-typing .chat-message-typing-circle:nth-child(3){animation-delay:666ms}@keyframes chat-message-typing-animation-scaling{0%{transform:scale(1)}33%{transform:scale(1)}50%{transform:scale(1.4)}to{transform:scale(1)}}@keyframes chat-message-typing-animation-bouncing{0%{transform:translateY(0)}33%{transform:translateY(0)}50%{transform:translateY(-10px)}to{transform:translateY(0)}}.chat-messages-list{margin-top:auto;display:block;padding:var(--chat--messages-list--padding, var(--chat--spacing))}.chat-input{display:flex;justify-content:center;align-items:center;width:100%}.chat-input textarea{font-family:inherit;font-size:inherit;width:100%;border:0;padding:var(--chat--spacing);max-height:var(--chat--textarea--height);resize:none}.chat-input .chat-input-send-button{height:var(--chat--textarea--height);width:var(--chat--textarea--height);background:white;cursor:pointer;color:var(--chat--color-secondary);border:0;font-size:24px;display:inline-flex;align-items:center;justify-content:center;transition:color var(--chat--transition-duration) ease}.chat-input .chat-input-send-button:hover,.chat-input .chat-input-send-button:focus{color:var(--chat--color-secondary-shade-50)}.chat-input .chat-input-send-button[disabled]{cursor:default;color:var(--chat--color-disabled)}.chat-window-wrapper{position:fixed;display:flex;flex-direction:column;bottom:var(--chat--window--bottom, var(--chat--spacing));right:var(--chat--window--right, var(--chat--spacing));z-index:var(--chat--window--z-index, 9999);max-width:calc(100% - var(--chat--window--right, var(--chat--spacing)) * 2);max-height:calc(100% - var(--chat--window--bottom, var(--chat--spacing)) * 2)}.chat-window-wrapper .chat-window{display:flex;width:var(--chat--window--width);height:var(--chat--window--height);max-width:100%;max-height:100%;border:var(--chat--window--border, 1px solid var(--chat--color-light-shade-100));border-radius:var(--chat--window--border-radius, var(--chat--border-radius));margin-bottom:var(--chat--window--margin-bottom, var(--chat--spacing));overflow:hidden;transform-origin:bottom right}.chat-window-wrapper .chat-window .chat-layout{width:auto;height:auto;flex:1}.chat-window-wrapper .chat-window-toggle{flex:0 0 auto;background:var(--chat--toggle--background);color:var(--chat--toggle--color);cursor:pointer;width:var(--chat--toggle--width, var(--chat--toggle--size));height:var(--chat--toggle--height, var(--chat--toggle--size));border-radius:var(--chat--toggle--border-radius, 50%);display:inline-flex;align-items:center;justify-content:center;margin-left:auto;transition:transform var(--chat--transition-duration) ease,background var(--chat--transition-duration) ease}.chat-window-wrapper .chat-window-toggle:hover,.chat-window-wrapper .chat-window-toggle:focus{transform:scale(1.05);background:var(--chat--toggle--hover--background)}.chat-window-wrapper .chat-window-toggle:active{transform:scale(.95);background:var(--chat--toggle--active--background)}.chat-window-transition-enter-active,.chat-window-transition-leave-active{transition:transform var(--chat--transition-duration) ease,opacity var(--chat--transition-duration) ease}.chat-window-transition-enter-from,.chat-window-transition-leave-to{transform:scale(0);opacity:0}.chat-window-toggle-transition-enter-active,.chat-window-toggle-transition-leave-active{transition:opacity var(--chat--transition-duration) ease}.chat-window-toggle-transition-enter-from,.chat-window-toggle-transition-leave-to{opacity:0}
@@ -0,0 +1,8 @@
1
+ declare const _default: import("vue").DefineComponent<Readonly<import("vue").ComponentPropsOptions<{
2
+ [x: string]: unknown;
3
+ }>>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, readonly string[] | Readonly<import("vue").ExtractPropTypes<Readonly<import("vue").ComponentObjectPropsOptions<{
4
+ [x: string]: unknown;
5
+ }>>>>, {
6
+ readonly [x: number]: string;
7
+ } | {}, {}>;
8
+ export default _default;
@@ -0,0 +1,17 @@
1
+ import type { StoryObj } from '@storybook/vue3';
2
+ import type { ChatOptions } from '../types';
3
+ declare const meta: {
4
+ title: string;
5
+ render: (args: Partial<ChatOptions>) => {
6
+ setup(): {};
7
+ template: string;
8
+ };
9
+ parameters: {
10
+ layout: string;
11
+ };
12
+ tags: string[];
13
+ };
14
+ export default meta;
15
+ type Story = StoryObj<typeof meta>;
16
+ export declare const Fullscreen: Story;
17
+ export declare const Windowed: Story;
@@ -0,0 +1 @@
1
+ export {};
File without changes
@@ -0,0 +1,5 @@
1
+ import { createChat } from '../../index';
2
+ export declare function createTestChat(options?: Parameters<typeof createChat>[0]): {
3
+ unmount: () => void;
4
+ container: Element;
5
+ };
@@ -0,0 +1,4 @@
1
+ import type { LoadPreviousSessionResponse, SendMessageResponse } from '../../types';
2
+ export declare function createFetchResponse<T>(data: T): () => Promise<Response>;
3
+ export declare const createGetLatestMessagesResponse: (data?: LoadPreviousSessionResponse['data']) => LoadPreviousSessionResponse;
4
+ export declare const createSendMessageResponse: (output: SendMessageResponse['output']) => SendMessageResponse;
@@ -0,0 +1,3 @@
1
+ export * from './create';
2
+ export * from './fetch';
3
+ export * from './selectors';
@@ -0,0 +1,12 @@
1
+ export declare function getMountingTarget(target?: string): Element | null;
2
+ export declare function getChatWindowWrapper(): Element | null;
3
+ export declare function getChatWindowToggle(): Element | null;
4
+ export declare function getChatWrapper(): Element | null;
5
+ export declare function getChatMessages(): NodeListOf<Element>;
6
+ export declare function getChatMessage(index: number): Element;
7
+ export declare function getChatMessageByText(text: string): HTMLElement | null;
8
+ export declare function getChatMessageTyping(): Element | null;
9
+ export declare function getGetStartedButton(): Element | null;
10
+ export declare function getChatInput(): Element | null;
11
+ export declare function getChatInputTextarea(): Element | null;
12
+ export declare function getChatInputSendButton(): Element | null;
@@ -0,0 +1,6 @@
1
+ export declare function authenticatedFetch<T>(...args: Parameters<typeof fetch>): Promise<T>;
2
+ export declare function get<T>(url: string, query?: object, options?: RequestInit): Promise<T>;
3
+ export declare function post<T>(url: string, body?: object, options?: RequestInit): Promise<T>;
4
+ export declare function put<T>(url: string, body?: object, options?: RequestInit): Promise<T>;
5
+ export declare function patch<T>(url: string, body?: object, options?: RequestInit): Promise<T>;
6
+ export declare function del<T>(url: string, body?: object, options?: RequestInit): Promise<T>;
@@ -0,0 +1,2 @@
1
+ export * from './generic';
2
+ export * from './message';
@@ -0,0 +1,3 @@
1
+ import type { ChatOptions, LoadPreviousSessionResponse, SendMessageResponse } from '../types';
2
+ export declare function loadPreviousSession(sessionId: string, options: ChatOptions): Promise<LoadPreviousSessionResponse>;
3
+ export declare function sendMessage(message: string, sessionId: string, options: ChatOptions): Promise<SendMessageResponse>;
@@ -0,0 +1,11 @@
1
+ import type { Ref } from 'vue';
2
+ import type { ChatMessage } from '@n8n/chat/types/messages';
3
+ export interface Chat {
4
+ initialMessages: Ref<ChatMessage[]>;
5
+ messages: Ref<ChatMessage[]>;
6
+ currentSessionId: Ref<string | null>;
7
+ waitingForResponse: Ref<boolean>;
8
+ loadPreviousSession: () => Promise<string | undefined>;
9
+ startNewSession: () => Promise<void>;
10
+ sendMessage: (text: string) => Promise<void>;
11
+ }
package/types/chat.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";
package/types/chat.mjs ADDED
File without changes
@@ -0,0 +1,9 @@
1
+ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}, {}>, {
2
+ default?(_: {}): any;
3
+ }>;
4
+ export default _default;
5
+ type __VLS_WithTemplateSlots<T, S> = T & {
6
+ new (): {
7
+ $slots: S;
8
+ };
9
+ };
@@ -0,0 +1,2 @@
1
+ declare const _default: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}, {}>;
2
+ export default _default;
@@ -0,0 +1,2 @@
1
+ declare const _default: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}, {}>;
2
+ export default _default;
@@ -0,0 +1,2 @@
1
+ declare const _default: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}, {}>;
2
+ export default _default;
@@ -0,0 +1,2 @@
1
+ declare const _default: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}, {}>;
2
+ export default _default;
@@ -0,0 +1,2 @@
1
+ declare const _default: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}, {}>;
2
+ export default _default;
@@ -0,0 +1,11 @@
1
+ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}, {}>, {
2
+ header?(_: {}): any;
3
+ default?(_: {}): any;
4
+ footer?(_: {}): any;
5
+ }>;
6
+ export default _default;
7
+ type __VLS_WithTemplateSlots<T, S> = T & {
8
+ new (): {
9
+ $slots: S;
10
+ };
11
+ };
@@ -0,0 +1,21 @@
1
+ import type { PropType } from 'vue';
2
+ import type { ChatMessage } from '../types';
3
+ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
4
+ message: {
5
+ type: PropType<ChatMessage>;
6
+ required: true;
7
+ };
8
+ }, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
9
+ message: {
10
+ type: PropType<ChatMessage>;
11
+ required: true;
12
+ };
13
+ }>>, {}, {}>, {
14
+ default?(_: {}): any;
15
+ }>;
16
+ export default _default;
17
+ type __VLS_WithTemplateSlots<T, S> = T & {
18
+ new (): {
19
+ $slots: S;
20
+ };
21
+ };
@@ -0,0 +1,15 @@
1
+ import type { PropType } from 'vue';
2
+ declare const _default: import("vue").DefineComponent<{
3
+ animation: {
4
+ type: PropType<"bouncing" | "scaling">;
5
+ default: string;
6
+ };
7
+ }, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
8
+ animation: {
9
+ type: PropType<"bouncing" | "scaling">;
10
+ default: string;
11
+ };
12
+ }>>, {
13
+ animation: "bouncing" | "scaling";
14
+ }, {}>;
15
+ export default _default;
@@ -0,0 +1,14 @@
1
+ import type { PropType } from 'vue';
2
+ import type { ChatMessage } from '../types';
3
+ declare const _default: import("vue").DefineComponent<{
4
+ messages: {
5
+ type: PropType<ChatMessage[]>;
6
+ required: true;
7
+ };
8
+ }, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
9
+ messages: {
10
+ type: PropType<ChatMessage[]>;
11
+ required: true;
12
+ };
13
+ }>>, {}, {}>;
14
+ export default _default;
@@ -0,0 +1,2 @@
1
+ declare const _default: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}, {}>;
2
+ export default _default;
@@ -0,0 +1,10 @@
1
+ export { default as Button } from './Button.vue';
2
+ export { default as Chat } from './Chat.vue';
3
+ export { default as ChatWindow } from './ChatWindow.vue';
4
+ export { default as GetStarted } from './GetStarted.vue';
5
+ export { default as GetStartedFooter } from './GetStartedFooter.vue';
6
+ export { default as Input } from './Input.vue';
7
+ export { default as Layout } from './Layout.vue';
8
+ export { default as Message } from './Message.vue';
9
+ export { default as MessagesList } from './MessagesList.vue';
10
+ export { default as PoweredBy } from './PoweredBy.vue';
@@ -0,0 +1,3 @@
1
+ export * from './useChat';
2
+ export * from './useI18n';
3
+ export * from './useOptions';
@@ -0,0 +1,2 @@
1
+ import type { Chat } from '../types';
2
+ export declare function useChat(): Chat;
@@ -0,0 +1,4 @@
1
+ export declare function useI18n(): {
2
+ t: (key: string) => string;
3
+ te: (key: string) => boolean;
4
+ };
@@ -0,0 +1,4 @@
1
+ import type { ChatOptions } from '../types';
2
+ export declare function useOptions(): {
3
+ options: ChatOptions;
4
+ };
@@ -0,0 +1,3 @@
1
+ import type { ChatOptions } from '../types';
2
+ export declare const defaultOptions: ChatOptions;
3
+ export declare const defaultMountingTarget = "#n8n-chat";
@@ -0,0 +1,3 @@
1
+ export * from './defaults';
2
+ export * from './localStorage';
3
+ export * from './symbols';
@@ -0,0 +1,2 @@
1
+ export declare const localStorageNamespace = "n8n-chat";
2
+ export declare const localStorageSessionIdKey = "n8n-chat/sessionId";
@@ -0,0 +1,4 @@
1
+ import type { InjectionKey } from 'vue';
2
+ import type { Chat, ChatOptions } from '../types';
3
+ export declare const ChatSymbol: InjectionKey<Chat>;
4
+ export declare const ChatOptionsSymbol: InjectionKey<ChatOptions>;
@@ -0,0 +1 @@
1
+ export declare const chatEventBus: import('../utils').EventBus;
@@ -0,0 +1 @@
1
+ export * from './chatEventBus';
package/types/index.js ADDED
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _chat = require("./chat");
7
+ Object.keys(_chat).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _chat[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _chat[key];
14
+ }
15
+ });
16
+ });
17
+ var _messages = require("./messages");
18
+ Object.keys(_messages).forEach(function (key) {
19
+ if (key === "default" || key === "__esModule") return;
20
+ if (key in exports && exports[key] === _messages[key]) return;
21
+ Object.defineProperty(exports, key, {
22
+ enumerable: true,
23
+ get: function () {
24
+ return _messages[key];
25
+ }
26
+ });
27
+ });
28
+ var _options = require("./options");
29
+ Object.keys(_options).forEach(function (key) {
30
+ if (key === "default" || key === "__esModule") return;
31
+ if (key in exports && exports[key] === _options[key]) return;
32
+ Object.defineProperty(exports, key, {
33
+ enumerable: true,
34
+ get: function () {
35
+ return _options[key];
36
+ }
37
+ });
38
+ });
39
+ var _webhook = require("./webhook");
40
+ Object.keys(_webhook).forEach(function (key) {
41
+ if (key === "default" || key === "__esModule") return;
42
+ if (key in exports && exports[key] === _webhook[key]) return;
43
+ Object.defineProperty(exports, key, {
44
+ enumerable: true,
45
+ get: function () {
46
+ return _webhook[key];
47
+ }
48
+ });
49
+ });
@@ -0,0 +1,4 @@
1
+ export * from "./chat.mjs";
2
+ export * from "./messages.mjs";
3
+ export * from "./options.mjs";
4
+ export * from "./webhook.mjs";
@@ -0,0 +1,6 @@
1
+ export interface ChatMessage {
2
+ id: string;
3
+ text: string;
4
+ createdAt: string;
5
+ sender: 'user' | 'bot';
6
+ }
@@ -0,0 +1 @@
1
+ "use strict";
File without changes
@@ -0,0 +1,25 @@
1
+ export interface ChatOptions {
2
+ webhookUrl: string;
3
+ webhookConfig?: {
4
+ method?: 'GET' | 'POST';
5
+ headers?: Record<string, string>;
6
+ };
7
+ target?: string | Element;
8
+ mode?: 'window' | 'fullscreen';
9
+ showWelcomeScreen?: boolean;
10
+ loadPreviousSession?: boolean;
11
+ chatInputKey?: string;
12
+ chatSessionKey?: string;
13
+ defaultLanguage?: 'en';
14
+ initialMessages?: string[];
15
+ metadata?: Record<string, unknown>;
16
+ i18n: Record<string, {
17
+ title: string;
18
+ subtitle: string;
19
+ footer: string;
20
+ getStarted: string;
21
+ inputPlaceholder: string;
22
+ [message: string]: string;
23
+ }>;
24
+ theme?: {};
25
+ }
@@ -0,0 +1 @@
1
+ "use strict";
File without changes
@@ -0,0 +1,3 @@
1
+ import type { Plugin } from 'vue';
2
+ import type { ChatOptions } from '../types';
3
+ export declare const ChatPlugin: Plugin<ChatOptions>;
@@ -0,0 +1 @@
1
+ export * from './chat';
@@ -0,0 +1,11 @@
1
+ import type { Ref } from 'vue';
2
+ import type { ChatMessage } from './messages';
3
+ export interface Chat {
4
+ initialMessages: Ref<ChatMessage[]>;
5
+ messages: Ref<ChatMessage[]>;
6
+ currentSessionId: Ref<string | null>;
7
+ waitingForResponse: Ref<boolean>;
8
+ loadPreviousSession: () => Promise<string | undefined>;
9
+ startNewSession: () => Promise<void>;
10
+ sendMessage: (text: string) => Promise<void>;
11
+ }
@@ -0,0 +1,4 @@
1
+ export * from './chat';
2
+ export * from './messages';
3
+ export * from './options';
4
+ export * from './webhook';
@@ -0,0 +1,6 @@
1
+ export interface ChatMessage {
2
+ id: string;
3
+ text: string;
4
+ createdAt: string;
5
+ sender: 'user' | 'bot';
6
+ }
@@ -0,0 +1,25 @@
1
+ export interface ChatOptions {
2
+ webhookUrl: string;
3
+ webhookConfig?: {
4
+ method?: 'GET' | 'POST';
5
+ headers?: Record<string, string>;
6
+ };
7
+ target?: string | Element;
8
+ mode?: 'window' | 'fullscreen';
9
+ showWelcomeScreen?: boolean;
10
+ loadPreviousSession?: boolean;
11
+ chatInputKey?: string;
12
+ chatSessionKey?: string;
13
+ defaultLanguage?: 'en';
14
+ initialMessages?: string[];
15
+ metadata?: Record<string, unknown>;
16
+ i18n: Record<string, {
17
+ title: string;
18
+ subtitle: string;
19
+ footer: string;
20
+ getStarted: string;
21
+ inputPlaceholder: string;
22
+ [message: string]: string;
23
+ }>;
24
+ theme?: {};
25
+ }
@@ -0,0 +1,16 @@
1
+ export interface LoadPreviousSessionResponseItem {
2
+ id: string[];
3
+ kwargs: {
4
+ content: string;
5
+ additional_kwargs: Record<string, unknown>;
6
+ };
7
+ lc: number;
8
+ type: string;
9
+ }
10
+ export interface LoadPreviousSessionResponse {
11
+ data: LoadPreviousSessionResponseItem[];
12
+ }
13
+ export interface SendMessageResponse {
14
+ output?: string;
15
+ text?: string;
16
+ }
@@ -0,0 +1,8 @@
1
+ export type CallbackFn = Function;
2
+ export type UnregisterFn = () => void;
3
+ export interface EventBus {
4
+ on: (eventName: string, fn: CallbackFn) => UnregisterFn;
5
+ off: (eventName: string, fn: CallbackFn) => void;
6
+ emit: <T = Event>(eventName: string, event?: T) => void;
7
+ }
8
+ export declare function createEventBus(): EventBus;
@@ -0,0 +1 @@
1
+ export declare function createDefaultMountingTarget(mountingTarget: string): void;
@@ -0,0 +1,16 @@
1
+ export interface LoadPreviousSessionResponseItem {
2
+ id: string[];
3
+ kwargs: {
4
+ content: string;
5
+ additional_kwargs: Record<string, unknown>;
6
+ };
7
+ lc: number;
8
+ type: string;
9
+ }
10
+ export interface LoadPreviousSessionResponse {
11
+ data: LoadPreviousSessionResponseItem[];
12
+ }
13
+ export interface SendMessageResponse {
14
+ output?: string;
15
+ text?: string;
16
+ }
@@ -0,0 +1 @@
1
+ "use strict";
File without changes
@@ -0,0 +1,8 @@
1
+ export type CallbackFn = Function;
2
+ export type UnregisterFn = () => void;
3
+ export interface EventBus {
4
+ on: (eventName: string, fn: CallbackFn) => UnregisterFn;
5
+ off: (eventName: string, fn: CallbackFn) => void;
6
+ emit: <T = Event>(eventName: string, event?: T) => void;
7
+ }
8
+ export declare function createEventBus(): EventBus;
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createEventBus = createEventBus;
7
+ function createEventBus() {
8
+ const handlers = /* @__PURE__ */new Map();
9
+ function off(eventName, fn) {
10
+ const eventFns = handlers.get(eventName);
11
+ if (eventFns) {
12
+ eventFns.splice(eventFns.indexOf(fn) >>> 0, 1);
13
+ }
14
+ }
15
+ function on(eventName, fn) {
16
+ let eventFns = handlers.get(eventName);
17
+ if (!eventFns) {
18
+ eventFns = [fn];
19
+ } else {
20
+ eventFns.push(fn);
21
+ }
22
+ handlers.set(eventName, eventFns);
23
+ return () => off(eventName, fn);
24
+ }
25
+ function emit(eventName, event) {
26
+ const eventFns = handlers.get(eventName);
27
+ if (eventFns) {
28
+ eventFns.slice().forEach(async handler => {
29
+ await handler(event);
30
+ });
31
+ }
32
+ }
33
+ return {
34
+ on,
35
+ off,
36
+ emit
37
+ };
38
+ }
@@ -0,0 +1,32 @@
1
+ export function createEventBus() {
2
+ const handlers = /* @__PURE__ */ new Map();
3
+ function off(eventName, fn) {
4
+ const eventFns = handlers.get(eventName);
5
+ if (eventFns) {
6
+ eventFns.splice(eventFns.indexOf(fn) >>> 0, 1);
7
+ }
8
+ }
9
+ function on(eventName, fn) {
10
+ let eventFns = handlers.get(eventName);
11
+ if (!eventFns) {
12
+ eventFns = [fn];
13
+ } else {
14
+ eventFns.push(fn);
15
+ }
16
+ handlers.set(eventName, eventFns);
17
+ return () => off(eventName, fn);
18
+ }
19
+ function emit(eventName, event) {
20
+ const eventFns = handlers.get(eventName);
21
+ if (eventFns) {
22
+ eventFns.slice().forEach(async (handler) => {
23
+ await handler(event);
24
+ });
25
+ }
26
+ }
27
+ return {
28
+ on,
29
+ off,
30
+ emit
31
+ };
32
+ }
@@ -0,0 +1,2 @@
1
+ export * from './event-bus';
2
+ export * from './mount';
package/utils/index.js ADDED
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _eventBus = require("./event-bus");
7
+ Object.keys(_eventBus).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _eventBus[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _eventBus[key];
14
+ }
15
+ });
16
+ });
17
+ var _mount = require("./mount");
18
+ Object.keys(_mount).forEach(function (key) {
19
+ if (key === "default" || key === "__esModule") return;
20
+ if (key in exports && exports[key] === _mount[key]) return;
21
+ Object.defineProperty(exports, key, {
22
+ enumerable: true,
23
+ get: function () {
24
+ return _mount[key];
25
+ }
26
+ });
27
+ });
@@ -0,0 +1,2 @@
1
+ export * from "./event-bus.mjs";
2
+ export * from "./mount.mjs";
@@ -0,0 +1 @@
1
+ export declare function createDefaultMountingTarget(mountingTarget: string): void;