@wabot-dev/framework 0.1.0-beta.2 → 0.1.0-beta.20

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 (99) hide show
  1. package/dist/src/ai/claude/ClaudeChatBotAdapter.js +113 -0
  2. package/dist/src/ai/deepseek/DeepSeekChatBotAdapter.js +12 -13
  3. package/dist/src/ai/openia/OpenaiChatBotAdapter.js +9 -7
  4. package/dist/src/channels/cmd/@cmd.js +0 -4
  5. package/dist/src/channels/cmd/CmdChannel.js +0 -4
  6. package/dist/src/channels/express/ExpressProvider.js +46 -0
  7. package/dist/src/channels/http/HttpServerProvider.js +31 -0
  8. package/dist/src/channels/{socket-io → socket}/@socket.js +0 -4
  9. package/dist/src/channels/{socket-io → socket}/SocketChannel.js +12 -11
  10. package/dist/src/channels/socket/SocketServerProvider.js +50 -0
  11. package/dist/src/channels/telegram/@telegram.js +0 -4
  12. package/dist/src/channels/telegram/TelegramChannel.js +0 -4
  13. package/dist/src/channels/wabot/WabotDevConnection.js +57 -0
  14. package/dist/src/channels/{whatsapp/WhatsAppDevSocketContracts.js → wabot/WabotDevSocketContracts.js} +3 -3
  15. package/dist/src/channels/whatsapp/@whatsapp.js +0 -4
  16. package/dist/src/channels/whatsapp/EnvWhatsAppRepository.js +49 -0
  17. package/dist/src/channels/whatsapp/PgWhatsAppRepository.js +41 -0
  18. package/dist/src/channels/whatsapp/WhatsApp.js +32 -0
  19. package/dist/src/channels/whatsapp/WhatsAppChannel.js +33 -32
  20. package/dist/src/channels/whatsapp/{WhatsAppConnection.js → WhatsAppReceiver.js} +4 -6
  21. package/dist/src/channels/whatsapp/WhatsAppReceiverByDevConnection.js +32 -0
  22. package/dist/src/channels/whatsapp/WhatsAppReceiverByWebHook.js +63 -0
  23. package/dist/src/channels/whatsapp/WhatsAppRepository.js +10 -0
  24. package/dist/src/channels/whatsapp/WhatsAppSender.js +107 -20
  25. package/dist/src/channels/whatsapp/WhatsAppSenderByCloudApi.js +118 -0
  26. package/dist/src/channels/whatsapp/WhatsAppSenderByDevConnection.js +56 -0
  27. package/dist/src/chatbot/ChatBotAdapter.js +1 -5
  28. package/dist/src/chatbot/metadata/@chatBot.js +0 -5
  29. package/dist/src/chatbot/metadata/ChatBotMetadataStore.js +0 -5
  30. package/dist/src/controller/metadata/ControllerMetadataStore.js +0 -2
  31. package/dist/src/controller/metadata/controller/@chatController.js +0 -2
  32. package/dist/src/core/{Persistent.js → Entity.js} +24 -9
  33. package/dist/src/core/IMessageContext.js +0 -2
  34. package/dist/src/core/Storable.js +8 -0
  35. package/dist/src/core/chat/Chat.js +2 -2
  36. package/dist/src/core/chat/ChatItem.js +2 -2
  37. package/dist/src/core/user/User.js +2 -2
  38. package/dist/src/env/Env.js +39 -0
  39. package/dist/src/error/CustomError.js +15 -0
  40. package/dist/src/index.d.ts +539 -240
  41. package/dist/src/index.js +65 -34
  42. package/dist/src/mindset/MindsetOperator.js +1 -3
  43. package/dist/src/mindset/metadata/MindsetMetadataStore.js +0 -2
  44. package/dist/src/mindset/metadata/mindsets/@mindset.js +0 -2
  45. package/dist/src/mindset/metadata/modules/@mindsetModule.js +0 -2
  46. package/dist/src/pre-made/module/authentication/requests/SendOneTimePasswordRequest.js +0 -2
  47. package/dist/src/pre-made/module/authentication/requests/ValidateOneTimePasswordRequest.js +0 -2
  48. package/dist/src/pre-made/module/html/HtmlModule.js +70 -0
  49. package/dist/src/pre-made/module/register-user/requests/RegisterUserWithEmailRequest.js +0 -2
  50. package/dist/src/pre-made/repository/chat/pg/PgChatMemory.js +1 -7
  51. package/dist/src/pre-made/repository/chat/pg/PgChatRepository.js +0 -5
  52. package/dist/src/pre-made/repository/chat/ram/RamChatRepository.js +1 -1
  53. package/dist/src/pre-made/repository/user/pg/PgUserRepository.js +0 -5
  54. package/dist/src/repository/pg/PgCrudRepository.js +13 -3
  55. package/dist/src/repository/pg/PgRepositoryBase.js +2 -2
  56. package/dist/src/rest-controller/metadata/@get.js +19 -0
  57. package/dist/src/rest-controller/metadata/@middleware.js +16 -0
  58. package/dist/src/rest-controller/metadata/@post.js +19 -0
  59. package/dist/src/rest-controller/metadata/@restController.js +15 -0
  60. package/dist/src/rest-controller/metadata/RestControllerMetadataStore.js +50 -0
  61. package/dist/src/rest-controller/runRestControllers.js +93 -0
  62. package/dist/src/server/prepareChatContainer.js +6 -6
  63. package/dist/src/server/runChannel.js +2 -10
  64. package/dist/src/server/runServer.js +0 -43
  65. package/dist/src/validation/metadata/@isBoolean.js +17 -0
  66. package/dist/src/validation/metadata/@isDate.js +17 -0
  67. package/dist/src/validation/metadata/@isModel.js +18 -0
  68. package/dist/src/validation/metadata/@isNotEmpty.js +17 -0
  69. package/dist/src/validation/metadata/@isNumber.js +17 -0
  70. package/dist/src/validation/metadata/@isOptional.js +17 -0
  71. package/dist/src/validation/metadata/@isPresent.js +17 -0
  72. package/dist/src/validation/metadata/@isString.js +17 -0
  73. package/dist/src/validation/metadata/@max.js +18 -0
  74. package/dist/src/validation/metadata/@min.js +18 -0
  75. package/dist/src/validation/metadata/ValidationMetadataStore.js +70 -0
  76. package/dist/src/validation/validate.js +11 -0
  77. package/dist/src/validation/validators/validateIsBoolean.js +12 -0
  78. package/dist/src/validation/validators/validateIsDate.js +16 -0
  79. package/dist/src/validation/validators/validateIsNotEmpty.js +12 -0
  80. package/dist/src/validation/validators/validateIsNumber.js +12 -0
  81. package/dist/src/validation/validators/validateIsOptional.js +5 -0
  82. package/dist/src/validation/validators/validateIsPresent.js +12 -0
  83. package/dist/src/validation/validators/validateIsString.js +12 -0
  84. package/dist/src/validation/validators/validateMax.js +17 -0
  85. package/dist/src/validation/validators/validateMin.js +17 -0
  86. package/dist/src/validation/validators/validateModel.js +34 -0
  87. package/package.json +5 -6
  88. package/dist/src/channels/whatsapp/WhatsAppDevConnection.js +0 -69
  89. package/dist/src/channels/whatsapp/WhatsAppProdConnection.js +0 -39
  90. package/dist/src/controller/express/Express.js +0 -5
  91. package/dist/src/controller/socket.io/SocketIO.js +0 -5
  92. package/dist/src/env/WabotEnv.js +0 -21
  93. package/dist/src/mindset/metadata/params/@isOptional.js +0 -21
  94. package/dist/src/pre-made/repository/chat/sqlite/SqliteChatMemory.js +0 -23
  95. package/dist/src/pre-made/repository/chat/sqlite/SqliteChatRepository.js +0 -30
  96. package/dist/src/pre-made/repository/user/sqlite/SqliteUserRepository.js +0 -23
  97. package/dist/src/repository/sqlite/SqliteCrudRepository.js +0 -85
  98. package/dist/src/repository/sqlite/SqlitePersistentMapper.js +0 -17
  99. /package/dist/src/channels/{socket-io → socket}/SocketChannelConfig.js +0 -0
@@ -1,5 +1,3 @@
1
- import './user/IUserRepository.js';
2
-
3
1
  class MessageContext {
4
2
  message;
5
3
  chat;
@@ -0,0 +1,8 @@
1
+ class Storable {
2
+ data;
3
+ constructor(data) {
4
+ this.data = data;
5
+ }
6
+ }
7
+
8
+ export { Storable };
@@ -1,6 +1,6 @@
1
- import { Persistent } from '../Persistent.js';
1
+ import { Entity } from '../Entity.js';
2
2
 
3
- class Chat extends Persistent {
3
+ class Chat extends Entity {
4
4
  constructor(data) {
5
5
  super(data);
6
6
  }
@@ -1,6 +1,6 @@
1
- import { Persistent } from '../Persistent.js';
1
+ import { Entity } from '../Entity.js';
2
2
 
3
- class ChatItem extends Persistent {
3
+ class ChatItem extends Entity {
4
4
  getType() {
5
5
  return this.data.type;
6
6
  }
@@ -1,6 +1,6 @@
1
- import { Persistent } from '../Persistent.js';
1
+ import { Entity } from '../Entity.js';
2
2
 
3
- class User extends Persistent {
3
+ class User extends Entity {
4
4
  constructor(data) {
5
5
  super(data);
6
6
  }
@@ -0,0 +1,39 @@
1
+ import { __decorate, __metadata } from 'tslib';
2
+ import { singleton } from 'tsyringe';
3
+
4
+ let Env = class Env {
5
+ envType;
6
+ constructor() {
7
+ this.envType = process.env.WABOT_ENV ?? 'development';
8
+ }
9
+ isDevelopment() {
10
+ return this.envType === 'development';
11
+ }
12
+ isProduction() {
13
+ return this.envType === 'production';
14
+ }
15
+ isTesting() {
16
+ return this.envType === 'testing';
17
+ }
18
+ requireString(varName, options) {
19
+ const value = process.env[varName] ?? options?.default;
20
+ if (!value)
21
+ throw new Error(`Env Variable ${varName} is required`);
22
+ return value;
23
+ }
24
+ requireNumber(varName, options) {
25
+ const strValue = this.requireString(varName, {
26
+ default: options?.default != null ? String(options.default) : undefined,
27
+ });
28
+ const value = Number(strValue);
29
+ if (isNaN(value))
30
+ throw new Error(`Env Variable ${varName} should have number format`);
31
+ return value;
32
+ }
33
+ };
34
+ Env = __decorate([
35
+ singleton(),
36
+ __metadata("design:paramtypes", [])
37
+ ], Env);
38
+
39
+ export { Env };
@@ -0,0 +1,15 @@
1
+ class CustomError extends Error {
2
+ humanMessage;
3
+ code;
4
+ httpCode;
5
+ info;
6
+ constructor(data) {
7
+ super(data.message, { cause: data.cause });
8
+ this.humanMessage = data.humanMessage;
9
+ this.code = data.code;
10
+ this.httpCode = data.httpCode;
11
+ this.info = data.info;
12
+ }
13
+ }
14
+
15
+ export { CustomError };