@visma-swno/gaia-chat-ui 0.1.6 → 0.1.7
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/core/chat/chat.dto.d.ts +36 -37
- package/dist/core/chat/chat.dto.d.ts.map +1 -1
- package/dist/core/chat/chat.service.d.ts.map +1 -1
- package/dist/core/chat/chat.store.d.ts +3 -3
- package/dist/core/chat/chat.store.d.ts.map +1 -1
- package/dist/core/chat/chat.utils.d.ts +5 -4
- package/dist/core/chat/chat.utils.d.ts.map +1 -1
- package/dist/gaia-chat-ui.es.js +180 -164
- package/dist/gaia-chat-ui.es.js.map +1 -1
- package/dist/gaia-chat-ui.umd.js +41 -41
- package/dist/gaia-chat-ui.umd.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { EventSourceMessage } from 'eventsource-client';
|
|
2
1
|
import { ChatMessage, NotificationType } from './chat.types';
|
|
3
2
|
/**
|
|
4
3
|
* Chat DTOs
|
|
@@ -20,49 +19,49 @@ export type GetConversationByIdResponse = {
|
|
|
20
19
|
updatedAt: string;
|
|
21
20
|
};
|
|
22
21
|
/**
|
|
23
|
-
*
|
|
22
|
+
* Chat Events
|
|
24
23
|
*/
|
|
25
|
-
export type
|
|
26
|
-
export
|
|
27
|
-
op:
|
|
24
|
+
export type JsonPatchOperation = 'add' | 'remove' | 'replace';
|
|
25
|
+
export interface PatchPayload<T> {
|
|
26
|
+
op: JsonPatchOperation;
|
|
28
27
|
path: string;
|
|
29
|
-
value:
|
|
30
|
-
}
|
|
31
|
-
export
|
|
32
|
-
|
|
33
|
-
data: JsonPatch;
|
|
34
|
-
};
|
|
35
|
-
/**
|
|
36
|
-
* Notification Event
|
|
37
|
-
*/
|
|
38
|
-
type BaseNotificationPayload = {
|
|
39
|
-
timestamp: string;
|
|
28
|
+
value: T;
|
|
29
|
+
}
|
|
30
|
+
export interface BaseNotificationPayload {
|
|
31
|
+
type: NotificationType;
|
|
40
32
|
message: string;
|
|
41
|
-
details
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
notificationType: NotificationType.Success;
|
|
48
|
-
};
|
|
49
|
-
type WarningPayload = BaseNotificationPayload & {
|
|
50
|
-
notificationType: NotificationType.Warning;
|
|
51
|
-
};
|
|
52
|
-
type ErrorPayload = BaseNotificationPayload & {
|
|
53
|
-
notificationType: NotificationType.Info;
|
|
54
|
-
errorCode: string;
|
|
33
|
+
details?: Record<string, unknown>;
|
|
34
|
+
timestamp: string;
|
|
35
|
+
}
|
|
36
|
+
export interface ErrorPayload extends BaseNotificationPayload {
|
|
37
|
+
type: NotificationType.Error;
|
|
38
|
+
errorCode?: string;
|
|
55
39
|
exceptionType?: string;
|
|
56
40
|
stackTrace?: string;
|
|
41
|
+
}
|
|
42
|
+
export type NotificationPayload = (BaseNotificationPayload & {
|
|
43
|
+
type: NotificationType.Info;
|
|
44
|
+
}) | (BaseNotificationPayload & {
|
|
45
|
+
type: NotificationType.Success;
|
|
46
|
+
}) | (BaseNotificationPayload & {
|
|
47
|
+
type: NotificationType.Warning;
|
|
48
|
+
}) | ErrorPayload;
|
|
49
|
+
export type MessagePayload = {
|
|
50
|
+
type: 'conversationIdSet';
|
|
51
|
+
conversationId: string;
|
|
52
|
+
} | {
|
|
53
|
+
type: 'contentStart';
|
|
54
|
+
} | {
|
|
55
|
+
type: 'contentEnd';
|
|
57
56
|
};
|
|
58
|
-
export type
|
|
59
|
-
|
|
57
|
+
export type ChatUpdateEvent = {
|
|
58
|
+
event: 'patch';
|
|
59
|
+
data: PatchPayload<unknown>;
|
|
60
|
+
} | {
|
|
60
61
|
event: 'notify';
|
|
61
62
|
data: NotificationPayload;
|
|
63
|
+
} | {
|
|
64
|
+
event: 'message';
|
|
65
|
+
data: MessagePayload;
|
|
62
66
|
};
|
|
63
|
-
/**
|
|
64
|
-
* Server Sent Event
|
|
65
|
-
*/
|
|
66
|
-
export type ServerSentEvent = JsonPatchEvent | NotificationEvent;
|
|
67
|
-
export {};
|
|
68
67
|
//# sourceMappingURL=chat.dto.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat.dto.d.ts","sourceRoot":"","sources":["../../../src/core/chat/chat.dto.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"chat.dto.d.ts","sourceRoot":"","sources":["../../../src/core/chat/chat.dto.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAE7D;;GAEG;AAEH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,2BAA2B,GAAG;IACxC,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,WAAW,EAAE,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF;;GAEG;AAEH,MAAM,MAAM,kBAAkB,GAAG,KAAK,GAAG,QAAQ,GAAG,SAAS,CAAC;AAE9D,MAAM,WAAW,YAAY,CAAC,CAAC;IAC7B,EAAE,EAAE,kBAAkB,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,CAAC,CAAC;CACV;AAED,MAAM,WAAW,uBAAuB;IACtC,IAAI,EAAE,gBAAgB,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,YAAa,SAAQ,uBAAuB;IAC3D,IAAI,EAAE,gBAAgB,CAAC,KAAK,CAAC;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,MAAM,mBAAmB,GAC3B,CAAC,uBAAuB,GAAG;IAAE,IAAI,EAAE,gBAAgB,CAAC,IAAI,CAAA;CAAE,CAAC,GAC3D,CAAC,uBAAuB,GAAG;IAAE,IAAI,EAAE,gBAAgB,CAAC,OAAO,CAAA;CAAE,CAAC,GAC9D,CAAC,uBAAuB,GAAG;IAAE,IAAI,EAAE,gBAAgB,CAAC,OAAO,CAAA;CAAE,CAAC,GAC9D,YAAY,CAAC;AAEjB,MAAM,MAAM,cAAc,GACtB;IAAE,IAAI,EAAE,mBAAmB,CAAC;IAAC,cAAc,EAAE,MAAM,CAAA;CAAE,GACrD;IAAE,IAAI,EAAE,cAAc,CAAA;CAAE,GACxB;IAAE,IAAI,EAAE,YAAY,CAAA;CAAE,CAAC;AAE3B,MAAM,MAAM,eAAe,GACvB;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,YAAY,CAAC,OAAO,CAAC,CAAA;CAAE,GAC/C;IAAE,KAAK,EAAE,QAAQ,CAAC;IAAC,IAAI,EAAE,mBAAmB,CAAA;CAAE,GAC9C;IAAE,KAAK,EAAE,SAAS,CAAC;IAAC,IAAI,EAAE,cAAc,CAAA;CAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat.service.d.ts","sourceRoot":"","sources":["../../../src/core/chat/chat.service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"chat.service.d.ts","sourceRoot":"","sources":["../../../src/core/chat/chat.service.ts"],"names":[],"mappings":"AAMA,OAAO,EAEL,2BAA2B,EAE5B,MAAM,YAAY,CAAC;AAQpB,qBAAa,WAAW;IAChB,IAAI;IAcJ,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAgB9D,gBAAgB,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAkBzF,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC;IAKrC,mBAAmB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,2BAA2B,CAAC;YAQ7D,mBAAmB;CA+ClC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Store } from '../lib/store';
|
|
2
|
-
import {
|
|
2
|
+
import { PatchPayload } from './chat.dto';
|
|
3
3
|
import { ChatMessage, ConversationState } from './chat.types';
|
|
4
4
|
export declare class ChatStore extends Store<ConversationState> {
|
|
5
5
|
private readonly _conversationStorageKey;
|
|
@@ -10,8 +10,8 @@ export declare class ChatStore extends Store<ConversationState> {
|
|
|
10
10
|
setError(error: string): void;
|
|
11
11
|
setMessages(messages: Record<string, ChatMessage>): void;
|
|
12
12
|
addMessage(message: ChatMessage): void;
|
|
13
|
-
|
|
14
|
-
applyPatchOperation(patch:
|
|
13
|
+
setId(id: string): void;
|
|
14
|
+
applyPatchOperation(patch: PatchPayload<unknown>): void;
|
|
15
15
|
resetState(): void;
|
|
16
16
|
private _saveToStorage;
|
|
17
17
|
private _loadFromStorage;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat.store.d.ts","sourceRoot":"","sources":["../../../src/core/chat/chat.store.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAEzC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"chat.store.d.ts","sourceRoot":"","sources":["../../../src/core/chat/chat.store.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAEzC,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAE9D,qBAAa,SAAU,SAAQ,KAAK,CAAC,iBAAiB,CAAC;IACrD,OAAO,CAAC,QAAQ,CAAC,uBAAuB,CAAsC;;IAcvE,WAAW,IAAI,WAAW,EAAE;IAI5B,cAAc,IAAI,WAAW,GAAG,IAAI;IAKpC,SAAS,CAAC,MAAM,EAAE,iBAAiB,CAAC,QAAQ,CAAC;IAO7C,QAAQ,CAAC,KAAK,EAAE,MAAM;IAQtB,WAAW,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC;IAOjD,UAAU,CAAC,OAAO,EAAE,WAAW;IAU/B,KAAK,CAAC,EAAE,EAAE,MAAM;IAQhB,mBAAmB,CAAC,KAAK,EAAE,YAAY,CAAC,OAAO,CAAC;IAIhD,UAAU;IASjB,OAAO,CAAC,cAAc;IAItB,OAAO,CAAC,gBAAgB;IAWjB,YAAY;CAGpB"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { GetConversationByIdResponse,
|
|
1
|
+
import { GetConversationByIdResponse, MessagePayload, NotificationPayload, PatchPayload } from './chat.dto';
|
|
2
2
|
import { ChatMessage, NotificationMessage } from './chat.types';
|
|
3
3
|
export declare const createUserMessage: (content: string) => ChatMessage;
|
|
4
|
-
export declare const mapNotificationEventToMessage: (
|
|
4
|
+
export declare const mapNotificationEventToMessage: (payload: NotificationPayload) => NotificationMessage;
|
|
5
5
|
export declare const mapConversationToMessages: (conversation: GetConversationByIdResponse) => Record<string, ChatMessage>;
|
|
6
6
|
export interface SseEventHandlers {
|
|
7
|
-
onPatch: (patchEvent:
|
|
8
|
-
onNotify: (notification:
|
|
7
|
+
onPatch: (patchEvent: PatchPayload<unknown>) => void;
|
|
8
|
+
onNotify: (notification: NotificationPayload) => void;
|
|
9
|
+
onMessage: (message: MessagePayload) => void;
|
|
9
10
|
onError: (error: Error) => void;
|
|
10
11
|
onClose: () => void;
|
|
11
12
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat.utils.d.ts","sourceRoot":"","sources":["../../../src/core/chat/chat.utils.ts"],"names":[],"mappings":"AAGA,OAAO,
|
|
1
|
+
{"version":3,"file":"chat.utils.d.ts","sourceRoot":"","sources":["../../../src/core/chat/chat.utils.ts"],"names":[],"mappings":"AAGA,OAAO,EAEL,2BAA2B,EAC3B,cAAc,EACd,mBAAmB,EACnB,YAAY,EACb,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAEhE,eAAO,MAAM,iBAAiB,GAAI,SAAS,MAAM,KAAG,WAMlD,CAAC;AAEH,eAAO,MAAM,6BAA6B,GACxC,SAAS,mBAAmB,KAC3B,mBAUF,CAAC;AAEF,eAAO,MAAM,yBAAyB,GACpC,cAAc,2BAA2B,KACxC,MAAM,CAAC,MAAM,EAAE,WAAW,CAe5B,CAAC;AAGF,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,CAAC,UAAU,EAAE,YAAY,CAAC,OAAO,CAAC,KAAK,IAAI,CAAC;IACrD,QAAQ,EAAE,CAAC,YAAY,EAAE,mBAAmB,KAAK,IAAI,CAAC;IACtD,SAAS,EAAE,CAAC,OAAO,EAAE,cAAc,KAAK,IAAI,CAAC;IAC7C,OAAO,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IAChC,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED;;;;GAIG;AACH,wBAAsB,eAAe,CACnC,MAAM,EAAE,cAAc,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,EAC/C,QAAQ,EAAE,gBAAgB,GACzB,OAAO,CAAC,IAAI,CAAC,CAoCf;AAED,OAAO,CAAC,MAAM,CAAC;IAEb,UAAU,cAAc,CAAC,CAAC,GAAG,GAAG;QAC9B,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,qBAAqB,CAAC,CAAC,CAAC,CAAC;KACpD;CACF"}
|