@n8n/chat 0.1.5 → 0.2.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.
Files changed (98) hide show
  1. package/.eslintignore +2 -0
  2. package/.eslintrc.cjs +53 -0
  3. package/.np-config.json +5 -0
  4. package/.storybook/main.ts +27 -0
  5. package/.storybook/preview.scss +4 -0
  6. package/.storybook/preview.ts +16 -0
  7. package/.vscode/extensions.json +3 -0
  8. package/env.d.ts +1 -0
  9. package/index.html +13 -0
  10. package/package.json +5 -2
  11. package/resources/workflow.json +293 -0
  12. package/scripts/pack.js +11 -0
  13. package/scripts/postbuild.js +16 -0
  14. package/src/App.vue +23 -0
  15. package/src/__stories__/App.stories.ts +43 -0
  16. package/src/__tests__/index.spec.ts +223 -0
  17. package/src/__tests__/setup.ts +1 -0
  18. package/src/__tests__/utils/create.ts +16 -0
  19. package/src/__tests__/utils/fetch.ts +18 -0
  20. package/src/__tests__/utils/index.ts +3 -0
  21. package/src/__tests__/utils/selectors.ts +53 -0
  22. package/src/api/generic.ts +64 -0
  23. package/src/api/message.ts +31 -0
  24. package/src/components/Button.vue +41 -0
  25. package/src/components/Chat.vue +48 -0
  26. package/src/components/ChatWindow.vue +125 -0
  27. package/src/components/GetStarted.vue +24 -0
  28. package/src/components/GetStartedFooter.vue +20 -0
  29. package/src/components/Input.vue +93 -0
  30. package/src/components/Layout.vue +82 -0
  31. package/src/components/Message.vue +97 -0
  32. package/src/components/MessageTyping.vue +109 -0
  33. package/src/components/MessagesList.vue +37 -0
  34. package/src/components/PoweredBy.vue +17 -0
  35. package/src/composables/useChat.ts +7 -0
  36. package/src/composables/useI18n.ts +16 -0
  37. package/src/composables/useOptions.ts +11 -0
  38. package/src/constants/defaults.ts +25 -0
  39. package/src/constants/localStorage.ts +2 -0
  40. package/src/constants/symbols.ts +8 -0
  41. package/src/event-buses/chatEventBus.ts +3 -0
  42. package/src/index.ts +42 -0
  43. package/src/main.scss +40 -0
  44. package/src/plugins/chat.ts +101 -0
  45. package/src/shims.d.ts +6 -0
  46. package/src/types/chat.ts +12 -0
  47. package/src/types/messages.ts +6 -0
  48. package/src/types/options.ts +23 -0
  49. package/src/types/webhook.ts +17 -0
  50. package/src/utils/event-bus.ts +51 -0
  51. package/src/utils/mount.ts +16 -0
  52. package/tsconfig.json +27 -0
  53. package/vite.config.ts +51 -0
  54. package/vitest.config.ts +20 -0
  55. package/chat.bundle.es.js +0 -10773
  56. package/chat.bundle.umd.js +0 -18
  57. package/chat.es.js +0 -6869
  58. package/chat.umd.js +0 -18
  59. package/style.css +0 -1
  60. package/types/App.vue.d.ts +0 -8
  61. package/types/__stories__/App.stories.d.ts +0 -17
  62. package/types/api/generic.d.ts +0 -6
  63. package/types/api/message.d.ts +0 -3
  64. package/types/components/Button.vue.d.ts +0 -9
  65. package/types/components/Chat.vue.d.ts +0 -2
  66. package/types/components/ChatWindow.vue.d.ts +0 -2
  67. package/types/components/GetStarted.vue.d.ts +0 -2
  68. package/types/components/GetStartedFooter.vue.d.ts +0 -2
  69. package/types/components/Input.vue.d.ts +0 -2
  70. package/types/components/Layout.vue.d.ts +0 -11
  71. package/types/components/Message.vue.d.ts +0 -21
  72. package/types/components/MessageTyping.vue.d.ts +0 -15
  73. package/types/components/MessagesList.vue.d.ts +0 -14
  74. package/types/components/PoweredBy.vue.d.ts +0 -2
  75. package/types/composables/useChat.d.ts +0 -2
  76. package/types/composables/useI18n.d.ts +0 -4
  77. package/types/composables/useOptions.d.ts +0 -4
  78. package/types/constants/defaults.d.ts +0 -3
  79. package/types/constants/localStorage.d.ts +0 -2
  80. package/types/constants/symbols.d.ts +0 -4
  81. package/types/event-buses/chatEventBus.d.ts +0 -1
  82. package/types/index.d.ts +0 -2
  83. package/types/plugins/chat.d.ts +0 -3
  84. package/types/types/chat.d.ts +0 -11
  85. package/types/types/messages.d.ts +0 -6
  86. package/types/types/options.d.ts +0 -20
  87. package/types/types/webhook.d.ts +0 -15
  88. package/types/utils/event-bus.d.ts +0 -8
  89. package/types/utils/mount.d.ts +0 -1
  90. /package/{favicon.ico → public/favicon.ico} +0 -0
  91. /package/{types/api/index.d.ts → src/api/index.ts} +0 -0
  92. /package/{types/components/index.d.ts → src/components/index.ts} +0 -0
  93. /package/{types/composables/index.d.ts → src/composables/index.ts} +0 -0
  94. /package/{types/constants/index.d.ts → src/constants/index.ts} +0 -0
  95. /package/{types/event-buses/index.d.ts → src/event-buses/index.ts} +0 -0
  96. /package/{types/plugins/index.d.ts → src/plugins/index.ts} +0 -0
  97. /package/{types/types/index.d.ts → src/types/index.ts} +0 -0
  98. /package/{types/utils/index.d.ts → src/utils/index.ts} +0 -0
@@ -1,14 +0,0 @@
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;
@@ -1,2 +0,0 @@
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;
@@ -1,2 +0,0 @@
1
- import type { Chat } from '../types';
2
- export declare function useChat(): Chat;
@@ -1,4 +0,0 @@
1
- export declare function useI18n(): {
2
- t: (key: string) => string;
3
- te: (key: string) => boolean;
4
- };
@@ -1,4 +0,0 @@
1
- import type { ChatOptions } from '../types';
2
- export declare function useOptions(): {
3
- options: ChatOptions;
4
- };
@@ -1,3 +0,0 @@
1
- import type { ChatOptions } from '../types';
2
- export declare const defaultOptions: ChatOptions;
3
- export declare const defaultMountingTarget = "#n8n-chat";
@@ -1,2 +0,0 @@
1
- export declare const localStorageNamespace = "n8n-chat";
2
- export declare const localStorageSessionIdKey = "n8n-chat/sessionId";
@@ -1,4 +0,0 @@
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>;
@@ -1 +0,0 @@
1
- export declare const chatEventBus: import('../utils').EventBus;
package/types/index.d.ts DELETED
@@ -1,2 +0,0 @@
1
- import type { ChatOptions } from './types';
2
- export declare function createChat(options?: Partial<ChatOptions>): import("vue").App<Element>;
@@ -1,3 +0,0 @@
1
- import type { Plugin } from 'vue';
2
- import type { ChatOptions } from '../types';
3
- export declare const ChatPlugin: Plugin<ChatOptions>;
@@ -1,11 +0,0 @@
1
- import type { ChatMessage } from '../types/messages';
2
- import type { Ref } from 'vue';
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>;
9
- startNewSession: () => Promise<void>;
10
- sendMessage: (text: string) => Promise<void>;
11
- }
@@ -1,6 +0,0 @@
1
- export interface ChatMessage {
2
- id: string;
3
- text: string;
4
- createdAt: string;
5
- sender: 'user' | 'bot';
6
- }
@@ -1,20 +0,0 @@
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
- defaultLanguage?: 'en';
10
- initialMessages?: string[];
11
- i18n: Record<string, {
12
- title: string;
13
- subtitle: string;
14
- footer: string;
15
- getStarted: string;
16
- inputPlaceholder: string;
17
- [message: string]: string;
18
- }>;
19
- theme?: {};
20
- }
@@ -1,15 +0,0 @@
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
- }
@@ -1,8 +0,0 @@
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;
@@ -1 +0,0 @@
1
- export declare function createDefaultMountingTarget(mountingTarget: string): void;
File without changes
File without changes
File without changes
File without changes