@wabot-dev/framework 0.0.16 → 0.0.50

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 (111) hide show
  1. package/dist/src/_virtual/_commonjsHelpers.js +5 -0
  2. package/dist/src/_virtual/cjs.js +7 -0
  3. package/dist/src/ai/deepseek/DeepSeekChatBotAdapter.js +107 -0
  4. package/dist/src/ai/openia/OpenaiChatBotAdapter.js +9 -7
  5. package/dist/src/channels/cmd/@cmd.js +0 -4
  6. package/dist/src/channels/cmd/CmdChannel.js +0 -4
  7. package/dist/src/channels/express/ExpressProvider.js +46 -0
  8. package/dist/src/channels/http/HttpServerProvider.js +31 -0
  9. package/dist/src/channels/socket/@socket.js +20 -0
  10. package/dist/src/channels/socket/SocketChannel.js +79 -0
  11. package/dist/src/channels/socket/SocketChannelConfig.js +15 -0
  12. package/dist/src/channels/socket/SocketServerProvider.js +50 -0
  13. package/dist/src/channels/telegram/@telegram.js +0 -4
  14. package/dist/src/channels/telegram/TelegramChannel.js +0 -4
  15. package/dist/src/channels/wabot/WabotDevConnection.js +57 -0
  16. package/dist/src/channels/wabot/WabotDevSocketContracts.js +10 -0
  17. package/dist/src/channels/whatsapp/@whatsapp.js +0 -4
  18. package/dist/src/channels/whatsapp/EnvWhatsAppRepository.js +49 -0
  19. package/dist/src/channels/whatsapp/PgWhatsAppRepository.js +41 -0
  20. package/dist/src/channels/whatsapp/WhatsApp.js +32 -0
  21. package/dist/src/channels/whatsapp/WhatsAppChannel.js +33 -32
  22. package/dist/src/channels/whatsapp/{WhatsAppConnection.js → WhatsAppReceiver.js} +4 -6
  23. package/dist/src/channels/whatsapp/WhatsAppReceiverByDevConnection.js +32 -0
  24. package/dist/src/channels/whatsapp/WhatsAppReceiverByWebHook.js +63 -0
  25. package/dist/src/channels/whatsapp/WhatsAppRepository.js +10 -0
  26. package/dist/src/channels/whatsapp/WhatsAppSender.js +99 -0
  27. package/dist/src/channels/whatsapp/WhatsAppSenderByCloudApi.js +124 -0
  28. package/dist/src/channels/whatsapp/WhatsAppSenderByDevConnection.js +61 -0
  29. package/dist/src/chatbot/ChatBotAdapter.js +1 -5
  30. package/dist/src/chatbot/metadata/@chatBot.js +0 -5
  31. package/dist/src/chatbot/metadata/ChatBotMetadataStore.js +0 -5
  32. package/dist/src/controller/metadata/ControllerMetadataStore.js +0 -2
  33. package/dist/src/controller/metadata/controller/@chatController.js +0 -2
  34. package/dist/src/core/IMessageContext.js +0 -2
  35. package/dist/src/env/WabotEnv.js +6 -0
  36. package/dist/src/index.d.ts +454 -163
  37. package/dist/src/index.js +56 -21
  38. package/dist/src/mindset/MindsetOperator.js +1 -3
  39. package/dist/src/mindset/metadata/MindsetMetadataStore.js +0 -2
  40. package/dist/src/mindset/metadata/mindsets/@mindset.js +0 -2
  41. package/dist/src/mindset/metadata/modules/@mindsetModule.js +0 -2
  42. package/dist/src/node_modules/@selderee/plugin-htmlparser2/lib/hp2-builder.js +90 -0
  43. package/dist/src/node_modules/deepmerge/dist/cjs.js +142 -0
  44. package/dist/src/node_modules/dom-serializer/lib/esm/foreignNames.js +102 -0
  45. package/dist/src/node_modules/dom-serializer/lib/esm/index.js +186 -0
  46. package/dist/src/node_modules/domelementtype/lib/esm/index.js +53 -0
  47. package/dist/src/node_modules/domhandler/lib/esm/index.js +148 -0
  48. package/dist/src/node_modules/domhandler/lib/esm/node.js +334 -0
  49. package/dist/src/node_modules/entities/lib/esm/decode.js +458 -0
  50. package/dist/src/node_modules/entities/lib/esm/decode_codepoint.js +62 -0
  51. package/dist/src/node_modules/entities/lib/esm/escape.js +99 -0
  52. package/dist/src/node_modules/entities/lib/esm/generated/decode-data-html.js +8 -0
  53. package/dist/src/node_modules/entities/lib/esm/generated/decode-data-xml.js +8 -0
  54. package/dist/src/node_modules/html-to-text/lib/html-to-text.js +2147 -0
  55. package/dist/src/node_modules/htmlparser2/lib/esm/Parser.js +491 -0
  56. package/dist/src/node_modules/htmlparser2/lib/esm/Tokenizer.js +928 -0
  57. package/dist/src/node_modules/htmlparser2/lib/esm/index.js +18 -0
  58. package/dist/src/node_modules/leac/lib/leac.js +3 -0
  59. package/dist/src/node_modules/parseley/lib/parseley.js +270 -0
  60. package/dist/src/node_modules/peberminta/lib/core.js +171 -0
  61. package/dist/src/node_modules/selderee/lib/selderee.js +380 -0
  62. package/dist/src/pre-made/module/authentication/requests/SendOneTimePasswordRequest.js +0 -2
  63. package/dist/src/pre-made/module/authentication/requests/ValidateOneTimePasswordRequest.js +0 -2
  64. package/dist/src/pre-made/module/html/HtmlModule.js +70 -0
  65. package/dist/src/pre-made/module/register-user/requests/RegisterUserWithEmailRequest.js +0 -2
  66. package/dist/src/pre-made/repository/chat/pg/PgChatMemory.js +1 -7
  67. package/dist/src/pre-made/repository/chat/pg/PgChatRepository.js +0 -5
  68. package/dist/src/pre-made/repository/user/pg/PgUserRepository.js +0 -5
  69. package/dist/src/repository/pg/PgCrudRepository.js +0 -1
  70. package/dist/src/rest-controller/metadata/@get.js +19 -0
  71. package/dist/src/rest-controller/metadata/@post.js +19 -0
  72. package/dist/src/rest-controller/metadata/@restController.js +15 -0
  73. package/dist/src/rest-controller/metadata/RestControllerMetadataStore.js +37 -0
  74. package/dist/src/rest-controller/runRestControllers.js +74 -0
  75. package/dist/src/server/prepareChatContainer.js +4 -4
  76. package/dist/src/server/runChannel.js +2 -10
  77. package/dist/src/server/runServer.js +0 -43
  78. package/dist/src/validation/metadata/@isBoolean.js +17 -0
  79. package/dist/src/validation/metadata/@isDate.js +17 -0
  80. package/dist/src/validation/metadata/@isNotEmpty.js +17 -0
  81. package/dist/src/validation/metadata/@isNumber.js +17 -0
  82. package/dist/src/validation/metadata/@isOptional.js +17 -0
  83. package/dist/src/validation/metadata/@isPresent.js +17 -0
  84. package/dist/src/validation/metadata/@isString.js +17 -0
  85. package/dist/src/validation/metadata/@max.js +18 -0
  86. package/dist/src/validation/metadata/@min.js +18 -0
  87. package/dist/src/validation/metadata/@validable.js +14 -0
  88. package/dist/src/validation/metadata/ValidationMetadataStore.js +55 -0
  89. package/dist/src/validation/validateModel2.js +11 -0
  90. package/dist/src/validation/validators/validateIsBoolean.js +12 -0
  91. package/dist/src/validation/validators/validateIsDate.js +16 -0
  92. package/dist/src/validation/validators/validateIsNotEmpty.js +12 -0
  93. package/dist/src/validation/validators/validateIsNumber.js +12 -0
  94. package/dist/src/validation/validators/validateIsOptional.js +5 -0
  95. package/dist/src/validation/validators/validateIsPresent.js +12 -0
  96. package/dist/src/validation/validators/validateIsString.js +12 -0
  97. package/dist/src/validation/validators/validateMax.js +17 -0
  98. package/dist/src/validation/validators/validateMin.js +17 -0
  99. package/dist/src/validation/validators/validateModel.js +47 -0
  100. package/package.json +4 -6
  101. package/dist/src/channels/whatsapp/WhatsAppDevConnection.js +0 -61
  102. package/dist/src/channels/whatsapp/WhatsAppProdConnection.js +0 -36
  103. package/dist/src/channels/whatsapp/whatsAppDevSocketContracts.js +0 -9
  104. package/dist/src/controller/express/Express.js +0 -5
  105. package/dist/src/controller/socket.io/SocketIO.js +0 -5
  106. package/dist/src/mindset/metadata/params/@isOptional.js +0 -21
  107. package/dist/src/pre-made/repository/chat/sqlite/SqliteChatMemory.js +0 -23
  108. package/dist/src/pre-made/repository/chat/sqlite/SqliteChatRepository.js +0 -30
  109. package/dist/src/pre-made/repository/user/sqlite/SqliteUserRepository.js +0 -23
  110. package/dist/src/repository/sqlite/SqliteCrudRepository.js +0 -85
  111. package/dist/src/repository/sqlite/SqlitePersistentMapper.js +0 -17
@@ -0,0 +1,334 @@
1
+ import { ElementType, isTag as isTag$1 } from '../../../domelementtype/lib/esm/index.js';
2
+
3
+ /**
4
+ * This object will be used as the prototype for Nodes when creating a
5
+ * DOM-Level-1-compliant structure.
6
+ */
7
+ class Node {
8
+ constructor() {
9
+ /** Parent of the node */
10
+ this.parent = null;
11
+ /** Previous sibling */
12
+ this.prev = null;
13
+ /** Next sibling */
14
+ this.next = null;
15
+ /** The start index of the node. Requires `withStartIndices` on the handler to be `true. */
16
+ this.startIndex = null;
17
+ /** The end index of the node. Requires `withEndIndices` on the handler to be `true. */
18
+ this.endIndex = null;
19
+ }
20
+ // Read-write aliases for properties
21
+ /**
22
+ * Same as {@link parent}.
23
+ * [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
24
+ */
25
+ get parentNode() {
26
+ return this.parent;
27
+ }
28
+ set parentNode(parent) {
29
+ this.parent = parent;
30
+ }
31
+ /**
32
+ * Same as {@link prev}.
33
+ * [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
34
+ */
35
+ get previousSibling() {
36
+ return this.prev;
37
+ }
38
+ set previousSibling(prev) {
39
+ this.prev = prev;
40
+ }
41
+ /**
42
+ * Same as {@link next}.
43
+ * [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
44
+ */
45
+ get nextSibling() {
46
+ return this.next;
47
+ }
48
+ set nextSibling(next) {
49
+ this.next = next;
50
+ }
51
+ /**
52
+ * Clone this node, and optionally its children.
53
+ *
54
+ * @param recursive Clone child nodes as well.
55
+ * @returns A clone of the node.
56
+ */
57
+ cloneNode(recursive = false) {
58
+ return cloneNode(this, recursive);
59
+ }
60
+ }
61
+ /**
62
+ * A node that contains some data.
63
+ */
64
+ class DataNode extends Node {
65
+ /**
66
+ * @param data The content of the data node
67
+ */
68
+ constructor(data) {
69
+ super();
70
+ this.data = data;
71
+ }
72
+ /**
73
+ * Same as {@link data}.
74
+ * [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
75
+ */
76
+ get nodeValue() {
77
+ return this.data;
78
+ }
79
+ set nodeValue(data) {
80
+ this.data = data;
81
+ }
82
+ }
83
+ /**
84
+ * Text within the document.
85
+ */
86
+ class Text extends DataNode {
87
+ constructor() {
88
+ super(...arguments);
89
+ this.type = ElementType.Text;
90
+ }
91
+ get nodeType() {
92
+ return 3;
93
+ }
94
+ }
95
+ /**
96
+ * Comments within the document.
97
+ */
98
+ class Comment extends DataNode {
99
+ constructor() {
100
+ super(...arguments);
101
+ this.type = ElementType.Comment;
102
+ }
103
+ get nodeType() {
104
+ return 8;
105
+ }
106
+ }
107
+ /**
108
+ * Processing instructions, including doc types.
109
+ */
110
+ class ProcessingInstruction extends DataNode {
111
+ constructor(name, data) {
112
+ super(data);
113
+ this.name = name;
114
+ this.type = ElementType.Directive;
115
+ }
116
+ get nodeType() {
117
+ return 1;
118
+ }
119
+ }
120
+ /**
121
+ * A `Node` that can have children.
122
+ */
123
+ class NodeWithChildren extends Node {
124
+ /**
125
+ * @param children Children of the node. Only certain node types can have children.
126
+ */
127
+ constructor(children) {
128
+ super();
129
+ this.children = children;
130
+ }
131
+ // Aliases
132
+ /** First child of the node. */
133
+ get firstChild() {
134
+ var _a;
135
+ return (_a = this.children[0]) !== null && _a !== void 0 ? _a : null;
136
+ }
137
+ /** Last child of the node. */
138
+ get lastChild() {
139
+ return this.children.length > 0
140
+ ? this.children[this.children.length - 1]
141
+ : null;
142
+ }
143
+ /**
144
+ * Same as {@link children}.
145
+ * [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
146
+ */
147
+ get childNodes() {
148
+ return this.children;
149
+ }
150
+ set childNodes(children) {
151
+ this.children = children;
152
+ }
153
+ }
154
+ class CDATA extends NodeWithChildren {
155
+ constructor() {
156
+ super(...arguments);
157
+ this.type = ElementType.CDATA;
158
+ }
159
+ get nodeType() {
160
+ return 4;
161
+ }
162
+ }
163
+ /**
164
+ * The root node of the document.
165
+ */
166
+ class Document extends NodeWithChildren {
167
+ constructor() {
168
+ super(...arguments);
169
+ this.type = ElementType.Root;
170
+ }
171
+ get nodeType() {
172
+ return 9;
173
+ }
174
+ }
175
+ /**
176
+ * An element within the DOM.
177
+ */
178
+ class Element extends NodeWithChildren {
179
+ /**
180
+ * @param name Name of the tag, eg. `div`, `span`.
181
+ * @param attribs Object mapping attribute names to attribute values.
182
+ * @param children Children of the node.
183
+ */
184
+ constructor(name, attribs, children = [], type = name === "script"
185
+ ? ElementType.Script
186
+ : name === "style"
187
+ ? ElementType.Style
188
+ : ElementType.Tag) {
189
+ super(children);
190
+ this.name = name;
191
+ this.attribs = attribs;
192
+ this.type = type;
193
+ }
194
+ get nodeType() {
195
+ return 1;
196
+ }
197
+ // DOM Level 1 aliases
198
+ /**
199
+ * Same as {@link name}.
200
+ * [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
201
+ */
202
+ get tagName() {
203
+ return this.name;
204
+ }
205
+ set tagName(name) {
206
+ this.name = name;
207
+ }
208
+ get attributes() {
209
+ return Object.keys(this.attribs).map((name) => {
210
+ var _a, _b;
211
+ return ({
212
+ name,
213
+ value: this.attribs[name],
214
+ namespace: (_a = this["x-attribsNamespace"]) === null || _a === void 0 ? void 0 : _a[name],
215
+ prefix: (_b = this["x-attribsPrefix"]) === null || _b === void 0 ? void 0 : _b[name],
216
+ });
217
+ });
218
+ }
219
+ }
220
+ /**
221
+ * @param node Node to check.
222
+ * @returns `true` if the node is a `Element`, `false` otherwise.
223
+ */
224
+ function isTag(node) {
225
+ return isTag$1(node);
226
+ }
227
+ /**
228
+ * @param node Node to check.
229
+ * @returns `true` if the node has the type `CDATA`, `false` otherwise.
230
+ */
231
+ function isCDATA(node) {
232
+ return node.type === ElementType.CDATA;
233
+ }
234
+ /**
235
+ * @param node Node to check.
236
+ * @returns `true` if the node has the type `Text`, `false` otherwise.
237
+ */
238
+ function isText(node) {
239
+ return node.type === ElementType.Text;
240
+ }
241
+ /**
242
+ * @param node Node to check.
243
+ * @returns `true` if the node has the type `Comment`, `false` otherwise.
244
+ */
245
+ function isComment(node) {
246
+ return node.type === ElementType.Comment;
247
+ }
248
+ /**
249
+ * @param node Node to check.
250
+ * @returns `true` if the node has the type `ProcessingInstruction`, `false` otherwise.
251
+ */
252
+ function isDirective(node) {
253
+ return node.type === ElementType.Directive;
254
+ }
255
+ /**
256
+ * @param node Node to check.
257
+ * @returns `true` if the node has the type `ProcessingInstruction`, `false` otherwise.
258
+ */
259
+ function isDocument(node) {
260
+ return node.type === ElementType.Root;
261
+ }
262
+ /**
263
+ * Clone a node, and optionally its children.
264
+ *
265
+ * @param recursive Clone child nodes as well.
266
+ * @returns A clone of the node.
267
+ */
268
+ function cloneNode(node, recursive = false) {
269
+ let result;
270
+ if (isText(node)) {
271
+ result = new Text(node.data);
272
+ }
273
+ else if (isComment(node)) {
274
+ result = new Comment(node.data);
275
+ }
276
+ else if (isTag(node)) {
277
+ const children = recursive ? cloneChildren(node.children) : [];
278
+ const clone = new Element(node.name, { ...node.attribs }, children);
279
+ children.forEach((child) => (child.parent = clone));
280
+ if (node.namespace != null) {
281
+ clone.namespace = node.namespace;
282
+ }
283
+ if (node["x-attribsNamespace"]) {
284
+ clone["x-attribsNamespace"] = { ...node["x-attribsNamespace"] };
285
+ }
286
+ if (node["x-attribsPrefix"]) {
287
+ clone["x-attribsPrefix"] = { ...node["x-attribsPrefix"] };
288
+ }
289
+ result = clone;
290
+ }
291
+ else if (isCDATA(node)) {
292
+ const children = recursive ? cloneChildren(node.children) : [];
293
+ const clone = new CDATA(children);
294
+ children.forEach((child) => (child.parent = clone));
295
+ result = clone;
296
+ }
297
+ else if (isDocument(node)) {
298
+ const children = recursive ? cloneChildren(node.children) : [];
299
+ const clone = new Document(children);
300
+ children.forEach((child) => (child.parent = clone));
301
+ if (node["x-mode"]) {
302
+ clone["x-mode"] = node["x-mode"];
303
+ }
304
+ result = clone;
305
+ }
306
+ else if (isDirective(node)) {
307
+ const instruction = new ProcessingInstruction(node.name, node.data);
308
+ if (node["x-name"] != null) {
309
+ instruction["x-name"] = node["x-name"];
310
+ instruction["x-publicId"] = node["x-publicId"];
311
+ instruction["x-systemId"] = node["x-systemId"];
312
+ }
313
+ result = instruction;
314
+ }
315
+ else {
316
+ throw new Error(`Not implemented yet: ${node.type}`);
317
+ }
318
+ result.startIndex = node.startIndex;
319
+ result.endIndex = node.endIndex;
320
+ if (node.sourceCodeLocation != null) {
321
+ result.sourceCodeLocation = node.sourceCodeLocation;
322
+ }
323
+ return result;
324
+ }
325
+ function cloneChildren(childs) {
326
+ const children = childs.map((child) => cloneNode(child, true));
327
+ for (let i = 1; i < children.length; i++) {
328
+ children[i].prev = children[i - 1];
329
+ children[i - 1].next = children[i];
330
+ }
331
+ return children;
332
+ }
333
+
334
+ export { CDATA, Comment, DataNode, Document, Element, Node, NodeWithChildren, ProcessingInstruction, Text, cloneNode, isCDATA, isComment, isDirective, isDocument, isTag, isText };