@wabot-dev/framework 0.0.11 → 0.0.13
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/src/ai/openia/OpenaiChatBotAdapter.js +2 -4
- package/dist/src/channels/cmd/@cmd.js +2 -0
- package/dist/src/channels/cmd/CmdChannel.js +2 -4
- package/dist/src/channels/telegram/@telegram.js +2 -0
- package/dist/src/channels/telegram/TelegramChannel.js +2 -4
- package/dist/src/chatbot/ChatBot.js +2 -4
- package/dist/src/chatbot/ChatBotAdapter.js +1 -3
- package/dist/src/chatbot/metadata/@chatBot.js +2 -0
- package/dist/src/chatbot/metadata/ChatBotMetadataStore.js +2 -0
- package/dist/src/controller/channel/ChatResolver.js +1 -3
- package/dist/src/controller/channel/UserResolver.js +1 -3
- package/dist/src/controller/metadata/ControllerMetadataStore.js +2 -0
- package/dist/src/controller/metadata/controller/@chatController.js +2 -0
- package/dist/src/core/IMessageContext.js +1 -2
- package/dist/src/core/chat/Chat.js +1 -1
- package/dist/src/core/chat/ChatItem.js +1 -1
- package/dist/src/core/user/{repository/IUserRepository.js → IUserRepository.js} +1 -1
- package/dist/src/core/user/User.js +1 -1
- package/dist/src/index.d.ts +235 -202
- package/dist/src/index.js +21 -19
- package/dist/src/mindset/MindsetOperator.js +2 -0
- package/dist/src/mindset/metadata/MindsetMetadataStore.js +2 -0
- package/dist/src/mindset/metadata/mindsets/@mindset.js +2 -0
- package/dist/src/mindset/metadata/modules/@mindsetModule.js +2 -0
- package/dist/src/pre-made/module/authentication/AuthenticationModule.js +1 -3
- package/dist/src/pre-made/module/authentication/requests/SendOneTimePasswordRequest.js +2 -0
- package/dist/src/pre-made/module/authentication/requests/ValidateOneTimePasswordRequest.js +2 -0
- package/dist/src/pre-made/module/register-user/RegisterUserModule.js +1 -3
- package/dist/src/pre-made/module/register-user/requests/RegisterUserWithEmailRequest.js +2 -0
- package/dist/src/pre-made/repository/chat/pg/PgChatMemory.js +43 -0
- package/dist/src/pre-made/repository/chat/pg/PgChatRepository.js +42 -0
- package/dist/src/{core/chat/repository → pre-made/repository/chat}/ram/RamChatRepository.js +0 -1
- package/dist/src/pre-made/repository/{sqlite/chat → chat/sqlite}/SqliteChatMemory.js +5 -5
- package/dist/src/pre-made/repository/{sqlite/chat → chat/sqlite}/SqliteChatRepository.js +5 -5
- package/dist/src/pre-made/repository/user/pg/PgUserRepository.js +38 -0
- package/dist/src/{core/user/repository → pre-made/repository/user}/ram/RamUserRepository.js +0 -1
- package/dist/src/pre-made/repository/user/sqlite/SqliteUserRepository.js +23 -0
- package/dist/src/repository/pg/PgCrudRepository.js +63 -0
- package/dist/src/repository/pg/PgRepositoryBase.js +89 -0
- package/dist/src/server/prepareChatContainer.js +4 -6
- package/dist/src/server/runChannel.js +2 -4
- package/dist/src/server/runServer.js +2 -4
- package/package.json +2 -1
- package/dist/src/pre-made/repository/pg/PgCrudRepository.js +0 -70
- package/dist/src/pre-made/repository/pg/PgPersistentMapper.js +0 -17
- package/dist/src/pre-made/repository/pg/chat/PgChatRepository.js +0 -30
- package/dist/src/pre-made/repository/sqlite/user/SqliteUserRepository.js +0 -33
- /package/dist/src/{shared → core}/Persistent.js +0 -0
- /package/dist/src/{core/chat/repository → pre-made/repository/chat}/ram/RamChatMemory.js +0 -0
- /package/dist/src/{pre-made/repository → repository}/sqlite/SqliteCrudRepository.js +0 -0
- /package/dist/src/{pre-made/repository → repository}/sqlite/SqlitePersistentMapper.js +0 -0
package/dist/src/index.d.ts
CHANGED
|
@@ -24,19 +24,12 @@ interface IMindsetFunctionDecoration {
|
|
|
24
24
|
decorationConfig: any;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
type IConstructor<T> = new (...args: any[]) => T;
|
|
28
|
-
|
|
29
|
-
interface IReversibleMapper<T1, T2> {
|
|
30
|
-
map(input: T1): T2;
|
|
31
|
-
rev(input: T2): T1;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
27
|
interface IPersistent {
|
|
35
28
|
id?: string;
|
|
36
29
|
createdAt?: number | null;
|
|
37
30
|
discardedAt?: number | null;
|
|
38
31
|
}
|
|
39
|
-
declare class Persistent<D extends IPersistent> {
|
|
32
|
+
declare class Persistent<D extends IPersistent = IPersistent> {
|
|
40
33
|
protected data: D;
|
|
41
34
|
constructor(data: D);
|
|
42
35
|
getId(): string;
|
|
@@ -47,6 +40,143 @@ declare class Persistent<D extends IPersistent> {
|
|
|
47
40
|
discard(): void;
|
|
48
41
|
}
|
|
49
42
|
|
|
43
|
+
type IChatType = 'PRIVATE' | 'GROUP';
|
|
44
|
+
interface IChatConnection {
|
|
45
|
+
chatType: IChatType;
|
|
46
|
+
channelName: string;
|
|
47
|
+
id: string;
|
|
48
|
+
}
|
|
49
|
+
interface IChatData extends IPersistent {
|
|
50
|
+
type: IChatType;
|
|
51
|
+
connections: IChatConnection[];
|
|
52
|
+
}
|
|
53
|
+
declare class Chat extends Persistent<IChatData> {
|
|
54
|
+
constructor(data: IChatData);
|
|
55
|
+
isPrivate(): boolean;
|
|
56
|
+
isGroup(): boolean;
|
|
57
|
+
hasConnection(connection: IChatConnection): boolean;
|
|
58
|
+
private validatePrivateChat;
|
|
59
|
+
private validateGroupChat;
|
|
60
|
+
validate(): void;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
interface IChatDocument {
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
interface IChatImage {
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
interface IUserConnection {
|
|
70
|
+
channelName: string;
|
|
71
|
+
id: string;
|
|
72
|
+
}
|
|
73
|
+
interface IUserData extends IPersistent {
|
|
74
|
+
shortName: string;
|
|
75
|
+
connections: IUserConnection[];
|
|
76
|
+
keyValueData: {
|
|
77
|
+
[key: string]: string;
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
declare class User extends Persistent<IUserData> {
|
|
81
|
+
constructor(data: IUserData);
|
|
82
|
+
hasConnection(connection: IUserConnection): boolean;
|
|
83
|
+
getValue(key: string): string;
|
|
84
|
+
setValue(key: string, value: string): void;
|
|
85
|
+
addConnection(connection: IUserConnection): void;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
interface IChatMessage {
|
|
89
|
+
text?: string;
|
|
90
|
+
documents?: IChatDocument[];
|
|
91
|
+
images?: IChatImage[];
|
|
92
|
+
senderName: string;
|
|
93
|
+
}
|
|
94
|
+
interface IConnectionChatMessage extends IChatMessage {
|
|
95
|
+
chatConnection: IChatConnection;
|
|
96
|
+
userConnection: IUserConnection;
|
|
97
|
+
userId?: string;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
interface IChatFunctionCall {
|
|
101
|
+
id: string;
|
|
102
|
+
name: string;
|
|
103
|
+
arguments?: string;
|
|
104
|
+
result: string;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
type ISystemMessageItem = {
|
|
108
|
+
type: 'BOT_MESSAGE';
|
|
109
|
+
content: IChatMessage;
|
|
110
|
+
};
|
|
111
|
+
type IReceivedMessageItem = {
|
|
112
|
+
type: 'CONNECTION_MESSAGE';
|
|
113
|
+
content: IConnectionChatMessage;
|
|
114
|
+
};
|
|
115
|
+
type ISystemFunctionCallItem = {
|
|
116
|
+
type: 'FUNCTION_CALL';
|
|
117
|
+
content: IChatFunctionCall;
|
|
118
|
+
};
|
|
119
|
+
type IChatItemData = {
|
|
120
|
+
id?: string;
|
|
121
|
+
createdAt?: number;
|
|
122
|
+
} & (ISystemMessageItem | IReceivedMessageItem | ISystemFunctionCallItem);
|
|
123
|
+
type IChatItemType = IChatItemData['type'];
|
|
124
|
+
declare class ChatItem extends Persistent<IChatItemData> {
|
|
125
|
+
getType(): "BOT_MESSAGE" | "CONNECTION_MESSAGE" | "FUNCTION_CALL";
|
|
126
|
+
getContent(): IChatMessage | IConnectionChatMessage | IChatFunctionCall;
|
|
127
|
+
getData(): IChatItemData;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
interface IChatMemory {
|
|
131
|
+
findLastItems(count: number): Promise<ChatItem[]>;
|
|
132
|
+
create(item: ChatItem): Promise<void>;
|
|
133
|
+
}
|
|
134
|
+
declare class ChatMemory implements IChatMemory {
|
|
135
|
+
findLastItems(count: number): Promise<ChatItem[]>;
|
|
136
|
+
create(item: ChatItem): Promise<void>;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
interface IChatRepository {
|
|
140
|
+
create(chat: Chat): Promise<void>;
|
|
141
|
+
findByConnection(query: IChatConnection): Promise<Chat | null>;
|
|
142
|
+
findMemory(chatId: string): Promise<IChatMemory | null>;
|
|
143
|
+
}
|
|
144
|
+
declare class ChatRepository implements IChatRepository {
|
|
145
|
+
create(chat: Chat): Promise<void>;
|
|
146
|
+
findByConnection(query: IChatConnection): Promise<Chat | null>;
|
|
147
|
+
findMemory(chatId: string): Promise<IChatMemory | null>;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
interface IUserRepository {
|
|
151
|
+
create(chat: User): Promise<void>;
|
|
152
|
+
update(chat: User): Promise<void>;
|
|
153
|
+
findByConnection(query: IUserConnection): Promise<User | null>;
|
|
154
|
+
}
|
|
155
|
+
declare class UserRepository implements IUserRepository {
|
|
156
|
+
create(chat: User): Promise<void>;
|
|
157
|
+
update(chat: User): Promise<void>;
|
|
158
|
+
findByConnection(query: IUserConnection): Promise<User | null>;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
interface IMessageContext {
|
|
162
|
+
message: IConnectionChatMessage;
|
|
163
|
+
chat: Chat;
|
|
164
|
+
user: User | null;
|
|
165
|
+
}
|
|
166
|
+
declare class MessageContext implements IMessageContext {
|
|
167
|
+
message: IConnectionChatMessage;
|
|
168
|
+
chat: Chat;
|
|
169
|
+
user: User | null;
|
|
170
|
+
constructor(message: IConnectionChatMessage, chat: Chat, user: User | null);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
interface IReversibleMapper<T1, T2> {
|
|
174
|
+
map(input: T1): T2;
|
|
175
|
+
rev(input: T2): T1;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
type IConstructor<T> = new (...args: any[]) => T;
|
|
179
|
+
|
|
50
180
|
interface IMindsetIdentity {
|
|
51
181
|
name: string;
|
|
52
182
|
language: string;
|
|
@@ -210,159 +340,6 @@ declare class ChatBotMetadataStore {
|
|
|
210
340
|
getChatBotsMetadata(): IChatBotMetadata[];
|
|
211
341
|
}
|
|
212
342
|
|
|
213
|
-
type IChatType = 'PRIVATE' | 'GROUP';
|
|
214
|
-
interface IChatConnection {
|
|
215
|
-
chatType: IChatType;
|
|
216
|
-
channelName: string;
|
|
217
|
-
id: string;
|
|
218
|
-
}
|
|
219
|
-
interface IChatData extends IPersistent {
|
|
220
|
-
type: IChatType;
|
|
221
|
-
connections: IChatConnection[];
|
|
222
|
-
}
|
|
223
|
-
declare class Chat extends Persistent<IChatData> {
|
|
224
|
-
constructor(data: IChatData);
|
|
225
|
-
isPrivate(): boolean;
|
|
226
|
-
isGroup(): boolean;
|
|
227
|
-
hasConnection(connection: IChatConnection): boolean;
|
|
228
|
-
private validatePrivateChat;
|
|
229
|
-
private validateGroupChat;
|
|
230
|
-
validate(): void;
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
interface IChatDocument {
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
interface IChatImage {
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
interface IUserConnection {
|
|
240
|
-
channelName: string;
|
|
241
|
-
id: string;
|
|
242
|
-
}
|
|
243
|
-
interface IUserData extends IPersistent {
|
|
244
|
-
shortName: string;
|
|
245
|
-
connections: IUserConnection[];
|
|
246
|
-
keyValueData: {
|
|
247
|
-
[key: string]: string;
|
|
248
|
-
};
|
|
249
|
-
}
|
|
250
|
-
declare class User extends Persistent<IUserData> {
|
|
251
|
-
constructor(data: IUserData);
|
|
252
|
-
hasConnection(connection: IUserConnection): boolean;
|
|
253
|
-
getValue(key: string): string;
|
|
254
|
-
setValue(key: string, value: string): void;
|
|
255
|
-
addConnection(connection: IUserConnection): void;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
interface IChatMessage {
|
|
259
|
-
text?: string;
|
|
260
|
-
documents?: IChatDocument[];
|
|
261
|
-
images?: IChatImage[];
|
|
262
|
-
senderName: string;
|
|
263
|
-
}
|
|
264
|
-
interface IConnectionChatMessage extends IChatMessage {
|
|
265
|
-
chatConnection: IChatConnection;
|
|
266
|
-
userConnection: IUserConnection;
|
|
267
|
-
userId?: string;
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
interface IChatFunctionCall {
|
|
271
|
-
id: string;
|
|
272
|
-
name: string;
|
|
273
|
-
arguments?: string;
|
|
274
|
-
result: string;
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
type ISystemMessageItem = {
|
|
278
|
-
type: 'BOT_MESSAGE';
|
|
279
|
-
content: IChatMessage;
|
|
280
|
-
};
|
|
281
|
-
type IReceivedMessageItem = {
|
|
282
|
-
type: 'CONNECTION_MESSAGE';
|
|
283
|
-
content: IConnectionChatMessage;
|
|
284
|
-
};
|
|
285
|
-
type ISystemFunctionCallItem = {
|
|
286
|
-
type: 'FUNCTION_CALL';
|
|
287
|
-
content: IChatFunctionCall;
|
|
288
|
-
};
|
|
289
|
-
type IChatItemData = {
|
|
290
|
-
id?: string;
|
|
291
|
-
createdAt?: number;
|
|
292
|
-
} & (ISystemMessageItem | IReceivedMessageItem | ISystemFunctionCallItem);
|
|
293
|
-
type IChatItemType = IChatItemData['type'];
|
|
294
|
-
declare class ChatItem extends Persistent<IChatItemData> {
|
|
295
|
-
getType(): "BOT_MESSAGE" | "CONNECTION_MESSAGE" | "FUNCTION_CALL";
|
|
296
|
-
getContent(): IChatMessage | IConnectionChatMessage | IChatFunctionCall;
|
|
297
|
-
getData(): IChatItemData;
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
interface IChatMemory {
|
|
301
|
-
findLastItems(count: number): Promise<ChatItem[]>;
|
|
302
|
-
create(item: ChatItem): Promise<void>;
|
|
303
|
-
}
|
|
304
|
-
declare class ChatMemory implements IChatMemory {
|
|
305
|
-
findLastItems(count: number): Promise<ChatItem[]>;
|
|
306
|
-
create(item: ChatItem): Promise<void>;
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
declare class RamChatMemory implements IChatMemory {
|
|
310
|
-
private memory;
|
|
311
|
-
findLastItems(count: number): Promise<ChatItem[]>;
|
|
312
|
-
create(item: ChatItem): Promise<void>;
|
|
313
|
-
clearMemory(): Promise<void>;
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
interface IChatRepository {
|
|
317
|
-
create(chat: Chat): Promise<void>;
|
|
318
|
-
findByConnection(query: IChatConnection): Promise<Chat | null>;
|
|
319
|
-
findMemory(chatId: string): Promise<IChatMemory | null>;
|
|
320
|
-
}
|
|
321
|
-
declare class ChatRepository implements IChatRepository {
|
|
322
|
-
create(chat: Chat): Promise<void>;
|
|
323
|
-
findByConnection(query: IChatConnection): Promise<Chat | null>;
|
|
324
|
-
findMemory(chatId: string): Promise<IChatMemory | null>;
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
declare class RamChatRepository implements IChatRepository {
|
|
328
|
-
private items;
|
|
329
|
-
private memories;
|
|
330
|
-
create(chat: Chat): Promise<void>;
|
|
331
|
-
findByConnection(query: IChatConnection): Promise<Chat | null>;
|
|
332
|
-
findMemory(chatId: string): Promise<IChatMemory | null>;
|
|
333
|
-
private getMemory;
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
interface IUserRepository {
|
|
337
|
-
create(chat: User): Promise<void>;
|
|
338
|
-
update(chat: User): Promise<void>;
|
|
339
|
-
findByConnection(query: IUserConnection): Promise<User | null>;
|
|
340
|
-
}
|
|
341
|
-
declare class UserRepository implements IUserRepository {
|
|
342
|
-
create(chat: User): Promise<void>;
|
|
343
|
-
update(chat: User): Promise<void>;
|
|
344
|
-
findByConnection(query: IUserConnection): Promise<User | null>;
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
declare class RamUserRepository implements IUserRepository {
|
|
348
|
-
private items;
|
|
349
|
-
create(chat: User): Promise<void>;
|
|
350
|
-
findByConnection(query: IUserConnection): Promise<User | null>;
|
|
351
|
-
update(chat: User): Promise<void>;
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
interface IMessageContext {
|
|
355
|
-
message: IConnectionChatMessage;
|
|
356
|
-
chat: Chat;
|
|
357
|
-
user: User | null;
|
|
358
|
-
}
|
|
359
|
-
declare class MessageContext implements IMessageContext {
|
|
360
|
-
message: IConnectionChatMessage;
|
|
361
|
-
chat: Chat;
|
|
362
|
-
user: User | null;
|
|
363
|
-
constructor(message: IConnectionChatMessage, chat: Chat, user: User | null);
|
|
364
|
-
}
|
|
365
|
-
|
|
366
343
|
interface IChatBotAdapter {
|
|
367
344
|
generateNextChatItem(chatItems: ChatItem[]): Promise<ChatItem>;
|
|
368
345
|
}
|
|
@@ -552,11 +529,6 @@ declare class RegisterUserModule {
|
|
|
552
529
|
registerUserWithEmail(request: RegisterUserWithEmailRequest): Promise<string>;
|
|
553
530
|
}
|
|
554
531
|
|
|
555
|
-
interface IPgRecord {
|
|
556
|
-
id: string;
|
|
557
|
-
data: string;
|
|
558
|
-
}
|
|
559
|
-
|
|
560
532
|
interface ICrudRepository<T> {
|
|
561
533
|
find(id: string): Promise<T | null>;
|
|
562
534
|
findAll(id: string): Promise<T[]>;
|
|
@@ -565,36 +537,62 @@ interface ICrudRepository<T> {
|
|
|
565
537
|
discard(item: T): Promise<void>;
|
|
566
538
|
}
|
|
567
539
|
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
540
|
+
type IPgRepositoryConfig<P extends Persistent> = {
|
|
541
|
+
schema?: string;
|
|
542
|
+
table: string;
|
|
543
|
+
constructor: IConstructor<P>;
|
|
544
|
+
add?: {
|
|
545
|
+
columns: {
|
|
546
|
+
[column: string]: {
|
|
547
|
+
type: string;
|
|
548
|
+
value: (item: P) => boolean | number | string | null | Date;
|
|
549
|
+
};
|
|
550
|
+
};
|
|
551
|
+
};
|
|
552
|
+
};
|
|
553
|
+
|
|
554
|
+
declare class PgRepositoryBase<P extends Persistent> {
|
|
555
|
+
protected pool: Pool;
|
|
556
|
+
protected config: IPgRepositoryConfig<any>;
|
|
572
557
|
private tableIsCreated;
|
|
573
|
-
|
|
558
|
+
schema: string;
|
|
559
|
+
table: string;
|
|
560
|
+
columnsList: string[];
|
|
561
|
+
columnsAndTypes: string;
|
|
562
|
+
columns: string;
|
|
563
|
+
vars: string;
|
|
564
|
+
updates: string;
|
|
565
|
+
addColumns: {
|
|
566
|
+
[columns: string]: {
|
|
567
|
+
type: string;
|
|
568
|
+
value: (item: P) => number | boolean | string | null | Date;
|
|
569
|
+
};
|
|
570
|
+
};
|
|
571
|
+
constructor(pool: Pool, config: IPgRepositoryConfig<any>);
|
|
572
|
+
values(item: P): (string | number | boolean | Date | null)[];
|
|
573
|
+
protected exec(sql: string, values: any[]): Promise<void>;
|
|
574
|
+
protected query(sql: string, values: any[]): Promise<any[]>;
|
|
575
|
+
protected connect(): Promise<Pool>;
|
|
576
|
+
protected ensureTable(): Promise<void>;
|
|
577
|
+
protected ensureColumns(): Promise<void>;
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
declare class PgCrudRepository<P extends Persistent> extends PgRepositoryBase<P> implements ICrudRepository<P> {
|
|
581
|
+
protected readonly config: IPgRepositoryConfig<P>;
|
|
582
|
+
constructor(pool: Pool, config: IPgRepositoryConfig<P>);
|
|
574
583
|
find(id: string): Promise<P | null>;
|
|
575
584
|
findAll(): Promise<P[]>;
|
|
576
585
|
create(item: P): Promise<void>;
|
|
577
586
|
update(item: P): Promise<void>;
|
|
578
587
|
discard(item: P): Promise<void>;
|
|
579
|
-
protected getPool(): Promise<Pool>;
|
|
580
|
-
private createTableIfNotExists;
|
|
581
588
|
}
|
|
582
589
|
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
map(input: P): string;
|
|
587
|
-
rev(input: string): P;
|
|
588
|
-
}
|
|
589
|
-
declare function pgMapperFor<P extends Persistent<IPersistent>>(ctor: IConstructor<P>): PgPersistentMapper<P>;
|
|
590
|
-
|
|
591
|
-
declare class PgChatRepository extends PgCrudRepository<Chat> implements IChatRepository {
|
|
592
|
-
constructor(pool: Pool);
|
|
593
|
-
findByConnection(query: IChatConnection): Promise<Chat | null>;
|
|
594
|
-
findMemory(chatId: string): Promise<IChatMemory | null>;
|
|
590
|
+
interface ISqliteRecord {
|
|
591
|
+
id: string;
|
|
592
|
+
data: string;
|
|
595
593
|
}
|
|
596
594
|
|
|
597
|
-
declare class SqliteCrudRepository<P extends Persistent
|
|
595
|
+
declare class SqliteCrudRepository<P extends Persistent> implements ICrudRepository<P> {
|
|
598
596
|
private table;
|
|
599
597
|
private dbPath;
|
|
600
598
|
private mapper;
|
|
@@ -609,6 +607,44 @@ declare class SqliteCrudRepository<P extends Persistent<IPersistent>> implements
|
|
|
609
607
|
protected createTable(db: Database<sqlite3.Database, sqlite3.Statement>): Promise<void>;
|
|
610
608
|
}
|
|
611
609
|
|
|
610
|
+
declare class SqlitePersistentMapper<P extends Persistent> implements IReversibleMapper<P, string> {
|
|
611
|
+
private ctor;
|
|
612
|
+
constructor(ctor: IConstructor<P>);
|
|
613
|
+
map(input: P): string;
|
|
614
|
+
rev(input: string): P;
|
|
615
|
+
}
|
|
616
|
+
declare function sqliteMapperFor<P extends Persistent>(ctor: IConstructor<P>): SqlitePersistentMapper<P>;
|
|
617
|
+
|
|
618
|
+
declare class PgUserRepository extends PgCrudRepository<User> implements IUserRepository {
|
|
619
|
+
constructor(pool: Pool);
|
|
620
|
+
findByConnection(query: IUserConnection): Promise<User | null>;
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
declare class RamUserRepository implements IUserRepository {
|
|
624
|
+
private items;
|
|
625
|
+
create(chat: User): Promise<void>;
|
|
626
|
+
findByConnection(query: IUserConnection): Promise<User | null>;
|
|
627
|
+
update(chat: User): Promise<void>;
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
declare class SqliteUserRepository extends SqliteCrudRepository<User> implements IUserRepository {
|
|
631
|
+
constructor();
|
|
632
|
+
findByConnection(query: IUserConnection): Promise<User | null>;
|
|
633
|
+
static getDbPath(): string;
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
declare class PgChatRepository extends PgCrudRepository<Chat> implements IChatRepository {
|
|
637
|
+
constructor(pool: Pool);
|
|
638
|
+
findByConnection(query: IChatConnection): Promise<Chat | null>;
|
|
639
|
+
findMemory(chatId: string): Promise<IChatMemory | null>;
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
declare class PgChatMemory extends PgCrudRepository<ChatItem> implements IChatMemory {
|
|
643
|
+
private chatId;
|
|
644
|
+
constructor(pool: Pool, chatId: string);
|
|
645
|
+
findLastItems(count: number): Promise<ChatItem[]>;
|
|
646
|
+
}
|
|
647
|
+
|
|
612
648
|
declare class SqliteChatMemory extends SqliteCrudRepository<ChatItem> implements IChatMemory {
|
|
613
649
|
constructor(chatId: string);
|
|
614
650
|
findLastItems(count: number): Promise<ChatItem[]>;
|
|
@@ -622,23 +658,20 @@ declare class SqliteChatRepository extends SqliteCrudRepository<Chat> implements
|
|
|
622
658
|
static getDbPath(): string;
|
|
623
659
|
}
|
|
624
660
|
|
|
625
|
-
declare class
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
interface ISqliteRecord {
|
|
632
|
-
id: string;
|
|
633
|
-
data: string;
|
|
661
|
+
declare class RamChatMemory implements IChatMemory {
|
|
662
|
+
private memory;
|
|
663
|
+
findLastItems(count: number): Promise<ChatItem[]>;
|
|
664
|
+
create(item: ChatItem): Promise<void>;
|
|
665
|
+
clearMemory(): Promise<void>;
|
|
634
666
|
}
|
|
635
667
|
|
|
636
|
-
declare class
|
|
637
|
-
private
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
668
|
+
declare class RamChatRepository implements IChatRepository {
|
|
669
|
+
private items;
|
|
670
|
+
private memories;
|
|
671
|
+
create(chat: Chat): Promise<void>;
|
|
672
|
+
findByConnection(query: IChatConnection): Promise<Chat | null>;
|
|
673
|
+
findMemory(chatId: string): Promise<IChatMemory | null>;
|
|
674
|
+
private getMemory;
|
|
641
675
|
}
|
|
642
|
-
declare function sqliteMapperFor<P extends Persistent<IPersistent>>(ctor: IConstructor<P>): SqlitePersistentMapper<P>;
|
|
643
676
|
|
|
644
|
-
export { AuthenticationModule, Chat, ChatBot, ChatBotAdapter, ChatBotMetadataStore, ChatItem, ChatMemory, ChatRepository, ChatResolver, CmdChannel, Container, ControllerMetadataStore, EmailService, type IChannelMetadata, type IChatBot, type IChatBotAdapter, type IChatBotMetadata, type IChatChannel, type IChatConnection, type IChatControllerMetadata, type IChatData, type IChatFunctionCall, type IChatItemData, type IChatItemType, type IChatMemory, type IChatMessage, type IChatRepository, type IChatType, type IConnectionChatMessage, type IConstructor, type ICrudRepository, type IEmailService, type IMessageContext, type IMindset, type IMindsetDecoration, type IMindsetFunctionConfig, type IMindsetFunctionDecoration, type IMindsetFunctionMetadata, type IMindsetFunctionParamMetadata, type IMindsetIdentity, type IMindsetMetadata, type IMindsetModuleConfig, type IMindsetModuleDecoration, type IMindsetModuleMetadata, type IOtpService, type IParamConfig, type IParamDecoration, type IPersistent, type
|
|
677
|
+
export { AuthenticationModule, Chat, ChatBot, ChatBotAdapter, ChatBotMetadataStore, ChatItem, ChatMemory, ChatRepository, ChatResolver, CmdChannel, Container, ControllerMetadataStore, EmailService, type IChannelMetadata, type IChatBot, type IChatBotAdapter, type IChatBotMetadata, type IChatChannel, type IChatConnection, type IChatControllerMetadata, type IChatData, type IChatFunctionCall, type IChatItemData, type IChatItemType, type IChatMemory, type IChatMessage, type IChatRepository, type IChatType, type IConnectionChatMessage, type IConstructor, type ICrudRepository, type IEmailService, type IMessageContext, type IMindset, type IMindsetDecoration, type IMindsetFunctionConfig, type IMindsetFunctionDecoration, type IMindsetFunctionMetadata, type IMindsetFunctionParamMetadata, type IMindsetIdentity, type IMindsetMetadata, type IMindsetModuleConfig, type IMindsetModuleDecoration, type IMindsetModuleMetadata, type IOtpService, type IParamConfig, type IParamDecoration, type IPersistent, type IPgRepositoryConfig, type IReceivedMessage, type IReceivedMessageItem, type IReversibleMapper, type ISendEmailRequest, type IServerConfig, type IServerProvider, type ISqliteRecord, type ISystemFunctionCallItem, type ISystemMessageItem, type ITelegramChannelConfig, type IUserConnection, type IUserData, type IUserRepository, type IchatControllerConfig, type IrunChannelProps, MINDSET_DECORATION_MINDSET, MINDSET_FUNCTION_DECORATION_FUNCTION, MINDSET_MODULE_DECORATION_MODULE, MessageContext, Mindset, MindsetMetadataStore, MindsetOperator, OpenaiChatBotAdapter, OtpService, PARAM_DECORATION_IS_OPTIONAL, PARAM_DECORATION_PARAM, Persistent, PgChatMemory, PgChatRepository, PgCrudRepository, PgRepositoryBase, PgUserRepository, RamChatMemory, RamChatRepository, RamUserRepository, RegisterUserModule, RegisterUserWithEmailRequest, SendOneTimePasswordRequest, SqliteChatMemory, SqliteChatRepository, SqliteCrudRepository, SqlitePersistentMapper, SqliteUserRepository, TelegramChannel, TelegramChannelConfig, User, UserRepository, UserResolver, ValidateOneTimePasswordRequest, chatBot, chatController, cmd, container, inject, injectable, isOptional, mindset, mindsetFunction, mindsetModule, param, prepareChatContainer, runChannel, runServer, singleton, sqliteMapperFor, telegram };
|
package/dist/src/index.js
CHANGED
|
@@ -10,7 +10,14 @@ export { mindsetFunction } from './mindset/metadata/functions/@mindsetFunction.j
|
|
|
10
10
|
export { MINDSET_FUNCTION_DECORATION_FUNCTION } from './mindset/metadata/functions/decoratorNames.js';
|
|
11
11
|
export { mindset } from './mindset/metadata/mindsets/@mindset.js';
|
|
12
12
|
export { MINDSET_DECORATION_MINDSET } from './mindset/metadata/mindsets/decoratorNames.js';
|
|
13
|
-
export {
|
|
13
|
+
export { ChatMemory } from './core/chat/repository/IChatMemory.js';
|
|
14
|
+
export { ChatRepository } from './core/chat/repository/IChatRepository.js';
|
|
15
|
+
export { Chat } from './core/chat/Chat.js';
|
|
16
|
+
export { ChatItem } from './core/chat/ChatItem.js';
|
|
17
|
+
export { User } from './core/user/User.js';
|
|
18
|
+
export { UserRepository } from './core/user/IUserRepository.js';
|
|
19
|
+
export { MessageContext } from './core/IMessageContext.js';
|
|
20
|
+
export { Persistent } from './core/Persistent.js';
|
|
14
21
|
export { mindsetModule } from './mindset/metadata/modules/@mindsetModule.js';
|
|
15
22
|
export { MINDSET_MODULE_DECORATION_MODULE } from './mindset/metadata/modules/decoratorNames.js';
|
|
16
23
|
export { isOptional } from './mindset/metadata/params/@isOptional.js';
|
|
@@ -21,16 +28,6 @@ export { MindsetMetadataStore } from './mindset/metadata/MindsetMetadataStore.js
|
|
|
21
28
|
export { MindsetOperator } from './mindset/MindsetOperator.js';
|
|
22
29
|
export { ChatBot } from './chatbot/ChatBot.js';
|
|
23
30
|
export { ChatBotAdapter } from './chatbot/ChatBotAdapter.js';
|
|
24
|
-
export { RamChatMemory } from './core/chat/repository/ram/RamChatMemory.js';
|
|
25
|
-
export { RamChatRepository } from './core/chat/repository/ram/RamChatRepository.js';
|
|
26
|
-
export { ChatMemory } from './core/chat/repository/IChatMemory.js';
|
|
27
|
-
export { ChatRepository } from './core/chat/repository/IChatRepository.js';
|
|
28
|
-
export { Chat } from './core/chat/Chat.js';
|
|
29
|
-
export { ChatItem } from './core/chat/ChatItem.js';
|
|
30
|
-
export { User } from './core/user/User.js';
|
|
31
|
-
export { RamUserRepository } from './core/user/repository/ram/RamUserRepository.js';
|
|
32
|
-
export { UserRepository } from './core/user/repository/IUserRepository.js';
|
|
33
|
-
export { MessageContext } from './core/IMessageContext.js';
|
|
34
31
|
export { ChatResolver } from './controller/channel/ChatResolver.js';
|
|
35
32
|
export { UserResolver } from './controller/channel/UserResolver.js';
|
|
36
33
|
export { chatController } from './controller/metadata/controller/@chatController.js';
|
|
@@ -46,12 +43,17 @@ export { RegisterUserWithEmailRequest } from './pre-made/module/register-user/re
|
|
|
46
43
|
export { RegisterUserModule } from './pre-made/module/register-user/RegisterUserModule.js';
|
|
47
44
|
export { EmailService } from './pre-made/service/EmailService.js';
|
|
48
45
|
export { OtpService } from './pre-made/service/OtpService.js';
|
|
49
|
-
export {
|
|
50
|
-
export {
|
|
51
|
-
export {
|
|
52
|
-
export {
|
|
53
|
-
export {
|
|
54
|
-
export {
|
|
55
|
-
export {
|
|
56
|
-
export {
|
|
46
|
+
export { PgUserRepository } from './pre-made/repository/user/pg/PgUserRepository.js';
|
|
47
|
+
export { RamUserRepository } from './pre-made/repository/user/ram/RamUserRepository.js';
|
|
48
|
+
export { SqliteUserRepository } from './pre-made/repository/user/sqlite/SqliteUserRepository.js';
|
|
49
|
+
export { PgChatRepository } from './pre-made/repository/chat/pg/PgChatRepository.js';
|
|
50
|
+
export { PgChatMemory } from './pre-made/repository/chat/pg/PgChatMemory.js';
|
|
51
|
+
export { SqliteChatMemory } from './pre-made/repository/chat/sqlite/SqliteChatMemory.js';
|
|
52
|
+
export { SqliteChatRepository } from './pre-made/repository/chat/sqlite/SqliteChatRepository.js';
|
|
53
|
+
export { RamChatMemory } from './pre-made/repository/chat/ram/RamChatMemory.js';
|
|
54
|
+
export { RamChatRepository } from './pre-made/repository/chat/ram/RamChatRepository.js';
|
|
55
|
+
export { PgCrudRepository } from './repository/pg/PgCrudRepository.js';
|
|
56
|
+
export { PgRepositoryBase } from './repository/pg/PgRepositoryBase.js';
|
|
57
|
+
export { SqliteCrudRepository } from './repository/sqlite/SqliteCrudRepository.js';
|
|
58
|
+
export { SqlitePersistentMapper, sqliteMapperFor } from './repository/sqlite/SqlitePersistentMapper.js';
|
|
57
59
|
export { Container } from './injection/Container.js';
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { __decorate, __metadata } from 'tslib';
|
|
2
2
|
import { injectable } from '../injection/index.js';
|
|
3
3
|
import { Mindset } from './IMindset.js';
|
|
4
|
+
import '../core/chat/repository/IChatRepository.js';
|
|
5
|
+
import '../core/user/IUserRepository.js';
|
|
4
6
|
import { MindsetMetadataStore } from './metadata/MindsetMetadataStore.js';
|
|
5
7
|
import { Container } from '../injection/Container.js';
|
|
6
8
|
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { __decorate } from 'tslib';
|
|
2
2
|
import { singleton } from '../../injection/index.js';
|
|
3
|
+
import '../../core/chat/repository/IChatRepository.js';
|
|
4
|
+
import '../../core/user/IUserRepository.js';
|
|
3
5
|
import { MINDSET_FUNCTION_DECORATION_FUNCTION } from './functions/decoratorNames.js';
|
|
4
6
|
import { MINDSET_DECORATION_MINDSET } from './mindsets/decoratorNames.js';
|
|
5
7
|
import { MINDSET_MODULE_DECORATION_MODULE } from './modules/decoratorNames.js';
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
|
+
import '../../../core/chat/repository/IChatRepository.js';
|
|
3
|
+
import '../../../core/user/IUserRepository.js';
|
|
2
4
|
import { container, injectable } from '../../../injection/index.js';
|
|
3
5
|
import { MindsetMetadataStore } from '../MindsetMetadataStore.js';
|
|
4
6
|
import { MINDSET_DECORATION_MINDSET } from './decoratorNames.js';
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
2
|
import { container, injectable } from '../../../injection/index.js';
|
|
3
|
+
import '../../../core/chat/repository/IChatRepository.js';
|
|
4
|
+
import '../../../core/user/IUserRepository.js';
|
|
3
5
|
import { MindsetMetadataStore } from '../MindsetMetadataStore.js';
|
|
4
6
|
import { MINDSET_MODULE_DECORATION_MODULE } from './decoratorNames.js';
|
|
5
7
|
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { __decorate, __metadata } from 'tslib';
|
|
2
|
-
import '../../../core/chat/repository/ram/RamChatRepository.js';
|
|
3
2
|
import '../../../core/chat/repository/IChatRepository.js';
|
|
4
|
-
import '../../../core/user/
|
|
5
|
-
import { UserRepository } from '../../../core/user/repository/IUserRepository.js';
|
|
3
|
+
import { UserRepository } from '../../../core/user/IUserRepository.js';
|
|
6
4
|
import { MessageContext } from '../../../core/IMessageContext.js';
|
|
7
5
|
import { mindsetFunction } from '../../../mindset/metadata/functions/@mindsetFunction.js';
|
|
8
6
|
import 'reflect-metadata';
|
|
@@ -2,6 +2,8 @@ import { __decorate, __metadata } from 'tslib';
|
|
|
2
2
|
import 'reflect-metadata';
|
|
3
3
|
import '../../../../injection/index.js';
|
|
4
4
|
import '../../../../mindset/metadata/MindsetMetadataStore.js';
|
|
5
|
+
import '../../../../core/chat/repository/IChatRepository.js';
|
|
6
|
+
import '../../../../core/user/IUserRepository.js';
|
|
5
7
|
import { param } from '../../../../mindset/metadata/params/@param.js';
|
|
6
8
|
import '../../../../mindset/MindsetOperator.js';
|
|
7
9
|
|
|
@@ -2,6 +2,8 @@ import { __decorate, __metadata } from 'tslib';
|
|
|
2
2
|
import 'reflect-metadata';
|
|
3
3
|
import '../../../../injection/index.js';
|
|
4
4
|
import '../../../../mindset/metadata/MindsetMetadataStore.js';
|
|
5
|
+
import '../../../../core/chat/repository/IChatRepository.js';
|
|
6
|
+
import '../../../../core/user/IUserRepository.js';
|
|
5
7
|
import { param } from '../../../../mindset/metadata/params/@param.js';
|
|
6
8
|
import '../../../../mindset/MindsetOperator.js';
|
|
7
9
|
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { __decorate, __metadata } from 'tslib';
|
|
2
|
-
import '../../../core/chat/repository/ram/RamChatRepository.js';
|
|
3
2
|
import '../../../core/chat/repository/IChatRepository.js';
|
|
4
3
|
import { User } from '../../../core/user/User.js';
|
|
5
|
-
import '../../../core/user/
|
|
6
|
-
import { UserRepository } from '../../../core/user/repository/IUserRepository.js';
|
|
4
|
+
import { UserRepository } from '../../../core/user/IUserRepository.js';
|
|
7
5
|
import { MessageContext } from '../../../core/IMessageContext.js';
|
|
8
6
|
import { mindsetFunction } from '../../../mindset/metadata/functions/@mindsetFunction.js';
|
|
9
7
|
import 'reflect-metadata';
|
|
@@ -2,6 +2,8 @@ import { __decorate, __metadata } from 'tslib';
|
|
|
2
2
|
import 'reflect-metadata';
|
|
3
3
|
import '../../../../injection/index.js';
|
|
4
4
|
import '../../../../mindset/metadata/MindsetMetadataStore.js';
|
|
5
|
+
import '../../../../core/chat/repository/IChatRepository.js';
|
|
6
|
+
import '../../../../core/user/IUserRepository.js';
|
|
5
7
|
import { param } from '../../../../mindset/metadata/params/@param.js';
|
|
6
8
|
import '../../../../mindset/MindsetOperator.js';
|
|
7
9
|
|