@meandr/chat-sdk 0.0.2 → 0.0.3

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/types.d.ts CHANGED
@@ -3,6 +3,8 @@ export interface Conversation {
3
3
  id: string;
4
4
  createdAt: string;
5
5
  updatedAt: string;
6
+ endedAt: string | null;
7
+ title?: string;
6
8
  }
7
9
  export interface Message {
8
10
  id: number;
@@ -46,6 +48,7 @@ export interface ChatState {
46
48
  readonly anonymous: boolean | null;
47
49
  readonly conversation: Conversation | null;
48
50
  readonly messages: readonly Message[];
51
+ readonly hasOlder: boolean;
49
52
  readonly outgoing: string | null;
50
53
  readonly answer: Answer | null;
51
54
  readonly answering: boolean;
@@ -53,6 +56,7 @@ export interface ChatState {
53
56
  readonly stop: Stop | null;
54
57
  readonly error: ChatError | null;
55
58
  readonly files: FileLimits | null;
59
+ readonly conversationList: boolean | null;
56
60
  }
57
61
  export type SendResult = {
58
62
  ok: true;
@@ -76,6 +80,34 @@ export type ReadFileResult = {
76
80
  ok: false;
77
81
  error: ChatError;
78
82
  };
83
+ export type ListConversationsResult = {
84
+ ok: true;
85
+ conversations: Conversation[];
86
+ hasMore: boolean;
87
+ } | {
88
+ ok: false;
89
+ error: ChatError;
90
+ };
91
+ export type OpenConversationResult = {
92
+ ok: true;
93
+ conversation: Conversation;
94
+ } | {
95
+ ok: false;
96
+ error: ChatError;
97
+ };
98
+ export type DeleteConversationResult = {
99
+ ok: true;
100
+ } | {
101
+ ok: false;
102
+ error: ChatError;
103
+ };
104
+ export type LoadOlderResult = {
105
+ ok: true;
106
+ messages: Message[];
107
+ } | {
108
+ ok: false;
109
+ error: ChatError;
110
+ };
79
111
  export interface SendOptions {
80
112
  files?: ReadonlyArray<ChatFile | string>;
81
113
  }
@@ -87,6 +119,10 @@ export interface AttachOptions {
87
119
  export interface ReadFileOptions {
88
120
  signal?: AbortSignal;
89
121
  }
122
+ export interface ListConversationsOptions {
123
+ before?: Conversation | string;
124
+ signal?: AbortSignal;
125
+ }
90
126
  export interface TokenRequest {
91
127
  expired: boolean;
92
128
  signal: AbortSignal;
@@ -120,7 +156,18 @@ export interface Chat {
120
156
  readFile(file: ChatFile | string, options?: ReadFileOptions): Promise<ReadFileResult>;
121
157
  /** Has the assistant speak first, as the chat's start instructions say: the page can't supply them. */
122
158
  start(): Promise<SendResult>;
159
+ /** Ends the conversation shown and forgets it at once; before the session opens, the one it opens on. Never rejects. */
160
+ endConversation(): Promise<void>;
161
+ /** Ends the conversation shown, as endConversation does: the next message or start begins a new one. */
123
162
  newConversation(): void;
163
+ /** Lists the user's conversations, 20 at a time, most recently active first; before goes on after that one. */
164
+ listConversations(options?: ListConversationsOptions): Promise<ListConversationsResult>;
165
+ /** Shows that conversation, its last 20 messages, once read, in place of the current one, which it doesn't end. */
166
+ openConversation(conversation: Conversation | string): Promise<OpenConversationResult>;
167
+ /** Deletes that conversation with its messages and files, where the chat lists them; one already gone counts. */
168
+ deleteConversation(conversation: Conversation | string): Promise<DeleteConversationResult>;
169
+ /** Adds the 20 messages before the oldest shown, while hasOlder; calls while one runs share it. */
170
+ loadOlder(): Promise<LoadOlderResult>;
124
171
  reopen(options?: ReopenOptions): Promise<ChatState>;
125
172
  signOut(): Promise<void>;
126
173
  destroy(): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meandr/chat-sdk",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "Meandr Chat's JavaScript client: the visitor's session, their messages and the streamed answers, and safe Markdown for them.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {