core-services-sdk 1.3.45 → 1.3.46

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 (42) hide show
  1. package/package.json +1 -1
  2. package/src/ids/generators.js +7 -0
  3. package/src/ids/prefixes.js +3 -0
  4. package/src/index.js +1 -0
  5. package/src/instant-messages/im-platform.js +18 -0
  6. package/src/instant-messages/index.js +4 -0
  7. package/src/instant-messages/message-type.js +153 -0
  8. package/src/instant-messages/message-types.js +127 -0
  9. package/src/instant-messages/message-unified-mapper.js +251 -0
  10. package/tests/ids/prefixes.unit.test.js +1 -0
  11. package/tests/instant-messages/applications.unit.test.js +27 -0
  12. package/tests/instant-messages/message-type.unit.test.js +193 -0
  13. package/tests/instant-messages/message-types.unit.test.js +93 -0
  14. package/tests/instant-messages/message-unified-mapper-telegram.unit.test.js +66 -0
  15. package/tests/instant-messages/message-unified-mapper-united.unit.test.js +94 -0
  16. package/tests/instant-messages/message-unified-mapper-whatsapp.unit.test.js +65 -0
  17. package/tests/instant-messages/mock-messages/telegram/contact.json +27 -0
  18. package/tests/instant-messages/mock-messages/telegram/document.json +43 -0
  19. package/tests/instant-messages/mock-messages/telegram/location.json +26 -0
  20. package/tests/instant-messages/mock-messages/telegram/photo.json +52 -0
  21. package/tests/instant-messages/mock-messages/telegram/poll.json +45 -0
  22. package/tests/instant-messages/mock-messages/telegram/text.json +63 -0
  23. package/tests/instant-messages/mock-messages/telegram/video.json +46 -0
  24. package/tests/instant-messages/mock-messages/telegram/video_note.json +43 -0
  25. package/tests/instant-messages/mock-messages/telegram/voice.json +29 -0
  26. package/tests/instant-messages/mock-messages/whatsapp/audio.json +42 -0
  27. package/tests/instant-messages/mock-messages/whatsapp/contacts.json +50 -0
  28. package/tests/instant-messages/mock-messages/whatsapp/document.json +42 -0
  29. package/tests/instant-messages/mock-messages/whatsapp/image.json +41 -0
  30. package/tests/instant-messages/mock-messages/whatsapp/location.json +40 -0
  31. package/tests/instant-messages/mock-messages/whatsapp/reaction.json +40 -0
  32. package/tests/instant-messages/mock-messages/whatsapp/sticker.json +42 -0
  33. package/tests/instant-messages/mock-messages/whatsapp/text.json +39 -0
  34. package/tests/instant-messages/mock-messages/whatsapp/video.json +41 -0
  35. package/types/ids/generators.d.ts +1 -0
  36. package/types/ids/prefixes.d.ts +2 -0
  37. package/types/index.d.ts +1 -0
  38. package/types/instant-messages/im-platform.d.ts +13 -0
  39. package/types/instant-messages/index.d.ts +4 -0
  40. package/types/instant-messages/message-type.d.ts +28 -0
  41. package/types/instant-messages/message-types.d.ts +62 -0
  42. package/types/instant-messages/message-unified-mapper.d.ts +380 -0
@@ -0,0 +1,28 @@
1
+ export function isItMediaType(
2
+ mediaType: string,
3
+ ): (params: { originalMessage: any }) => boolean
4
+ export function isMessageTypeof(
5
+ typeOfMessage: string,
6
+ ): (params: { originalMessage: any }) => boolean
7
+ export function isCallbackQuery({
8
+ originalMessage,
9
+ }: {
10
+ originalMessage: any
11
+ }): boolean
12
+ export const isItPoll: (params: { originalMessage: any }) => boolean
13
+ export const isItMessage: (params: { originalMessage: any }) => boolean
14
+ export const isItVoice: (params: { originalMessage: any }) => boolean
15
+ export const isItVideo: (params: { originalMessage: any }) => boolean
16
+ export const isItPhoto: (params: { originalMessage: any }) => boolean
17
+ export const isItFreeText: (params: { originalMessage: any }) => boolean
18
+ export const isItSticker: (params: { originalMessage: any }) => boolean
19
+ export const isItContact: (params: { originalMessage: any }) => boolean
20
+ export const isItLocation: (params: { originalMessage: any }) => boolean
21
+ export const isItDocument: (params: { originalMessage: any }) => boolean
22
+ export const isItVideoNote: (params: { originalMessage: any }) => boolean
23
+ export const isItButtonClick: (params: { originalMessage: any }) => boolean
24
+ export function getTelegramMessageType({
25
+ originalMessage,
26
+ }: {
27
+ originalMessage: any
28
+ }): string
@@ -0,0 +1,62 @@
1
+ /**
2
+ * *
3
+ */
4
+ export type MESSAGE_MEDIA_TYPE = string
5
+ export namespace MESSAGE_MEDIA_TYPE {
6
+ let TEXT: string
7
+ let POLL: string
8
+ let VIDEO: string
9
+ let PHOTO: string
10
+ let IMAGE: string
11
+ let VOICE: string
12
+ let AUDIO: string
13
+ let STICKER: string
14
+ let CONTACT: string
15
+ let MESSAGE: string
16
+ let REACTION: string
17
+ let DOCUMENT: string
18
+ let LOCATION: string
19
+ let CONTACTS: string
20
+ let VIDEO_NOTE: string
21
+ let BUTTON_CLICK: string
22
+ let BUTTON_CLICK_MULTIPLE: string
23
+ }
24
+ /**
25
+ * *
26
+ */
27
+ export type MESSAGE_TYPE = string
28
+ export namespace MESSAGE_TYPE {
29
+ let MESSAGE_1: string
30
+ export { MESSAGE_1 as MESSAGE }
31
+ import BUTTON_CLICK_1 = MESSAGE_MEDIA_TYPE.BUTTON_CLICK
32
+ export { BUTTON_CLICK_1 as BUTTON_CLICK }
33
+ import BUTTON_CLICK_MULTIPLE_1 = MESSAGE_MEDIA_TYPE.BUTTON_CLICK_MULTIPLE
34
+ export { BUTTON_CLICK_MULTIPLE_1 as BUTTON_CLICK_MULTIPLE }
35
+ export let UNKNOWN_MESSAGE_TYPE: string
36
+ }
37
+ /**
38
+ * *
39
+ */
40
+ export type MESSAGE_MEDIA_TYPE_MAPPER = string
41
+ /**
42
+ * Maps platform-specific message types into the unified equivalents.
43
+ *
44
+ * This is used to convert raw provider terminology into internal naming.
45
+ *
46
+ * @readonly
47
+ * @enum {string}
48
+ *
49
+ * @property {"audio"} VOICE
50
+ * Telegram's "voice" is normalized into the system's AUDIO type.
51
+ *
52
+ * @property {"image"} PHOTO
53
+ * Telegram's "photo" array is normalized into IMAGE.
54
+ *
55
+ * @property {"contact"} CONTACTS
56
+ * WhatsApp's "contacts" array is normalized into CONTACT.
57
+ */
58
+ export const MESSAGE_MEDIA_TYPE_MAPPER: {
59
+ [MESSAGE_MEDIA_TYPE.VOICE]: string
60
+ [MESSAGE_MEDIA_TYPE.PHOTO]: string
61
+ [MESSAGE_MEDIA_TYPE.CONTACTS]: string
62
+ }
@@ -0,0 +1,380 @@
1
+ export function getMessageType({
2
+ originalMessage,
3
+ }: {
4
+ originalMessage: any
5
+ }): string
6
+ export function mapMessageTelegramBase({
7
+ originalMessage,
8
+ }: {
9
+ originalMessage: any
10
+ }): {
11
+ messageBase: {
12
+ timestamp: string
13
+ forwardInfo: {
14
+ forward_date: any
15
+ forward_from: any
16
+ }
17
+ id: any
18
+ imExtraInfo: {
19
+ tmId: any
20
+ }
21
+ chatId: any
22
+ type: string
23
+ chatter: any
24
+ itIsForward: boolean
25
+ }
26
+ message: any
27
+ type: string
28
+ }
29
+ export function mapMessageWhatsAppContent({
30
+ message,
31
+ type,
32
+ }: {
33
+ message: any
34
+ type: any
35
+ }):
36
+ | {
37
+ text: any
38
+ reply?: undefined
39
+ }
40
+ | {
41
+ [x: number]: any
42
+ text?: undefined
43
+ reply?: undefined
44
+ }
45
+ | {
46
+ reply: any
47
+ text?: undefined
48
+ }
49
+ export function mapMessageTelegram({
50
+ originalMessage,
51
+ }: {
52
+ originalMessage: any
53
+ }):
54
+ | {
55
+ text: any
56
+ reply?: undefined
57
+ timestamp: string
58
+ forwardInfo: {
59
+ forward_date: any
60
+ forward_from: any
61
+ }
62
+ id: any
63
+ imExtraInfo: {
64
+ tmId: any
65
+ }
66
+ chatId: any
67
+ type: string
68
+ chatter: any
69
+ itIsForward: boolean
70
+ }
71
+ | {
72
+ text?: undefined
73
+ reply?: undefined
74
+ timestamp: string
75
+ forwardInfo: {
76
+ forward_date: any
77
+ forward_from: any
78
+ }
79
+ id: any
80
+ imExtraInfo: {
81
+ tmId: any
82
+ }
83
+ chatId: any
84
+ type: string
85
+ chatter: any
86
+ itIsForward: boolean
87
+ }
88
+ | {
89
+ attachment: string
90
+ animation: any
91
+ text?: undefined
92
+ reply?: undefined
93
+ timestamp: string
94
+ forwardInfo: {
95
+ forward_date: any
96
+ forward_from: any
97
+ }
98
+ id: any
99
+ imExtraInfo: {
100
+ tmId: any
101
+ }
102
+ chatId: any
103
+ type: string
104
+ chatter: any
105
+ itIsForward: boolean
106
+ }
107
+ | {
108
+ reply: {
109
+ id: any
110
+ title: any
111
+ }
112
+ text?: undefined
113
+ timestamp: string
114
+ forwardInfo: {
115
+ forward_date: any
116
+ forward_from: any
117
+ }
118
+ id: any
119
+ imExtraInfo: {
120
+ tmId: any
121
+ }
122
+ chatId: any
123
+ type: string
124
+ chatter: any
125
+ itIsForward: boolean
126
+ }
127
+ export function getWhatsAppMessageType({ message }: { message: any }): any
128
+ export function extractReply({ originalMessage }: { originalMessage: any }): {
129
+ id: any
130
+ title: any
131
+ }
132
+ export function whatsappBaseExtraction({
133
+ originalMessage,
134
+ }: {
135
+ originalMessage: any
136
+ }): {
137
+ field: any
138
+ value: any
139
+ wbaid: any
140
+ }
141
+ export function mapMessageWhatsAppBase({
142
+ originalMessage,
143
+ }: {
144
+ originalMessage: any
145
+ }): {
146
+ messageBase: {
147
+ id: any
148
+ chatId: any
149
+ imExtraInfo: {
150
+ wbaid: any
151
+ }
152
+ type: any
153
+ chatter: {
154
+ id: any
155
+ name: any
156
+ username: any
157
+ }
158
+ itIsForward: boolean
159
+ timestamp: any
160
+ }
161
+ message: any
162
+ contact: any
163
+ context: any
164
+ }
165
+ export function mapMessageTelegramContent({
166
+ type,
167
+ message,
168
+ originalMessage,
169
+ }: {
170
+ type: any
171
+ message: any
172
+ originalMessage: any
173
+ }):
174
+ | {
175
+ text: any
176
+ reply?: undefined
177
+ }
178
+ | {
179
+ [x: number]: any
180
+ text?: undefined
181
+ reply?: undefined
182
+ }
183
+ | {
184
+ attachment: string
185
+ animation: any
186
+ text?: undefined
187
+ reply?: undefined
188
+ }
189
+ | {
190
+ reply: {
191
+ id: any
192
+ title: any
193
+ }
194
+ text?: undefined
195
+ }
196
+ export function mapMessageWhatsApp({
197
+ originalMessage,
198
+ }: {
199
+ originalMessage: any
200
+ }):
201
+ | {
202
+ text: any
203
+ reply?: undefined
204
+ id: any
205
+ chatId: any
206
+ imExtraInfo: {
207
+ wbaid: any
208
+ }
209
+ type: any
210
+ chatter: {
211
+ id: any
212
+ name: any
213
+ username: any
214
+ }
215
+ itIsForward: boolean
216
+ timestamp: any
217
+ }
218
+ | {
219
+ text?: undefined
220
+ reply?: undefined
221
+ id: any
222
+ chatId: any
223
+ imExtraInfo: {
224
+ wbaid: any
225
+ }
226
+ type: any
227
+ chatter: {
228
+ id: any
229
+ name: any
230
+ username: any
231
+ }
232
+ itIsForward: boolean
233
+ timestamp: any
234
+ }
235
+ | {
236
+ reply: any
237
+ text?: undefined
238
+ id: any
239
+ chatId: any
240
+ imExtraInfo: {
241
+ wbaid: any
242
+ }
243
+ type: any
244
+ chatter: {
245
+ id: any
246
+ name: any
247
+ username: any
248
+ }
249
+ itIsForward: boolean
250
+ timestamp: any
251
+ }
252
+ export const messageUnifiedMapper: {
253
+ [IM_PLATFORM.TELEGRAM]: ({ originalMessage }: { originalMessage: any }) =>
254
+ | {
255
+ text: any
256
+ reply?: undefined
257
+ timestamp: string
258
+ forwardInfo: {
259
+ forward_date: any
260
+ forward_from: any
261
+ }
262
+ id: any
263
+ imExtraInfo: {
264
+ tmId: any
265
+ }
266
+ chatId: any
267
+ type: string
268
+ chatter: any
269
+ itIsForward: boolean
270
+ }
271
+ | {
272
+ text?: undefined
273
+ reply?: undefined
274
+ timestamp: string
275
+ forwardInfo: {
276
+ forward_date: any
277
+ forward_from: any
278
+ }
279
+ id: any
280
+ imExtraInfo: {
281
+ tmId: any
282
+ }
283
+ chatId: any
284
+ type: string
285
+ chatter: any
286
+ itIsForward: boolean
287
+ }
288
+ | {
289
+ attachment: string
290
+ animation: any
291
+ text?: undefined
292
+ reply?: undefined
293
+ timestamp: string
294
+ forwardInfo: {
295
+ forward_date: any
296
+ forward_from: any
297
+ }
298
+ id: any
299
+ imExtraInfo: {
300
+ tmId: any
301
+ }
302
+ chatId: any
303
+ type: string
304
+ chatter: any
305
+ itIsForward: boolean
306
+ }
307
+ | {
308
+ reply: {
309
+ id: any
310
+ title: any
311
+ }
312
+ text?: undefined
313
+ timestamp: string
314
+ forwardInfo: {
315
+ forward_date: any
316
+ forward_from: any
317
+ }
318
+ id: any
319
+ imExtraInfo: {
320
+ tmId: any
321
+ }
322
+ chatId: any
323
+ type: string
324
+ chatter: any
325
+ itIsForward: boolean
326
+ }
327
+ [IM_PLATFORM.WHATSAPP]: ({ originalMessage }: { originalMessage: any }) =>
328
+ | {
329
+ text: any
330
+ reply?: undefined
331
+ id: any
332
+ chatId: any
333
+ imExtraInfo: {
334
+ wbaid: any
335
+ }
336
+ type: any
337
+ chatter: {
338
+ id: any
339
+ name: any
340
+ username: any
341
+ }
342
+ itIsForward: boolean
343
+ timestamp: any
344
+ }
345
+ | {
346
+ text?: undefined
347
+ reply?: undefined
348
+ id: any
349
+ chatId: any
350
+ imExtraInfo: {
351
+ wbaid: any
352
+ }
353
+ type: any
354
+ chatter: {
355
+ id: any
356
+ name: any
357
+ username: any
358
+ }
359
+ itIsForward: boolean
360
+ timestamp: any
361
+ }
362
+ | {
363
+ reply: any
364
+ text?: undefined
365
+ id: any
366
+ chatId: any
367
+ imExtraInfo: {
368
+ wbaid: any
369
+ }
370
+ type: any
371
+ chatter: {
372
+ id: any
373
+ name: any
374
+ username: any
375
+ }
376
+ itIsForward: boolean
377
+ timestamp: any
378
+ }
379
+ }
380
+ import { IM_PLATFORM } from './im-platform.js'