core-services-sdk 1.3.47 → 1.3.48

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "core-services-sdk",
3
- "version": "1.3.47",
3
+ "version": "1.3.48",
4
4
  "main": "src/index.js",
5
5
  "type": "module",
6
6
  "types": "types/index.d.ts",
@@ -124,8 +124,12 @@ export const mapMessageTelegram = ({ imMessage }) => {
124
124
  message,
125
125
  imMessage,
126
126
  })
127
- const messageMapped = { ...messageBase, ...messageContent }
128
- return messageMapped
127
+
128
+ return {
129
+ ...messageBase,
130
+ ...messageContent,
131
+ type: MESSAGE_MEDIA_TYPE_MAPPER[type] || type,
132
+ }
129
133
  }
130
134
 
131
135
  export const getWhatsAppMessageType = ({ message }) => {
@@ -238,7 +242,11 @@ export const mapMessageWhatsApp = ({ imMessage }) => {
238
242
  context,
239
243
  })
240
244
 
241
- return { ...messageBase, ...messageContent }
245
+ return {
246
+ ...messageBase,
247
+ ...messageContent,
248
+ type: MESSAGE_MEDIA_TYPE_MAPPER[type] || type,
249
+ }
242
250
  }
243
251
 
244
252
  export const messageUnifiedMapper = {
@@ -8,7 +8,10 @@ import {
8
8
  mapMessageWhatsApp,
9
9
  } from '../../src/instant-messages/message-unified-mapper.js'
10
10
 
11
- import { MESSAGE_MEDIA_TYPE } from '../../src/instant-messages/message-types.js'
11
+ import {
12
+ MESSAGE_MEDIA_TYPE,
13
+ MESSAGE_MEDIA_TYPE_MAPPER,
14
+ } from '../../src/instant-messages/message-types.js'
12
15
  const __filename = fileURLToPath(import.meta.url)
13
16
  const __dirname = dirname(__filename)
14
17
 
@@ -40,7 +43,9 @@ describe('WhatsApp unified message mapper – all mock samples', () => {
40
43
  expect(unifiedType).toBeTypeOf('string')
41
44
 
42
45
  // Type must match mapper result
43
- expect(unifiedMessage.type).toBe(unifiedType)
46
+ expect(unifiedMessage.type).toBe(
47
+ MESSAGE_MEDIA_TYPE_MAPPER[unifiedType] || unifiedType,
48
+ )
44
49
 
45
50
  // All unified types must be supported values
46
51
  expect(Object.values(MESSAGE_MEDIA_TYPE)).toContain(unifiedType)
@@ -40,6 +40,7 @@ export function mapMessageWhatsAppContent({
40
40
  }
41
41
  export function mapMessageTelegram({ imMessage }: { imMessage: any }):
42
42
  | {
43
+ type: string
43
44
  text: any
44
45
  reply?: undefined
45
46
  timestamp: string
@@ -52,11 +53,11 @@ export function mapMessageTelegram({ imMessage }: { imMessage: any }):
52
53
  tmId: any
53
54
  }
54
55
  chatId: any
55
- type: string
56
56
  chatter: any
57
57
  itIsForward: boolean
58
58
  }
59
59
  | {
60
+ type: string
60
61
  text?: undefined
61
62
  reply?: undefined
62
63
  timestamp: string
@@ -69,11 +70,11 @@ export function mapMessageTelegram({ imMessage }: { imMessage: any }):
69
70
  tmId: any
70
71
  }
71
72
  chatId: any
72
- type: string
73
73
  chatter: any
74
74
  itIsForward: boolean
75
75
  }
76
76
  | {
77
+ type: string
77
78
  attachment: string
78
79
  animation: any
79
80
  text?: undefined
@@ -88,11 +89,11 @@ export function mapMessageTelegram({ imMessage }: { imMessage: any }):
88
89
  tmId: any
89
90
  }
90
91
  chatId: any
91
- type: string
92
92
  chatter: any
93
93
  itIsForward: boolean
94
94
  }
95
95
  | {
96
+ type: string
96
97
  reply: {
97
98
  id: any
98
99
  title: any
@@ -108,7 +109,6 @@ export function mapMessageTelegram({ imMessage }: { imMessage: any }):
108
109
  tmId: any
109
110
  }
110
111
  chatId: any
111
- type: string
112
112
  chatter: any
113
113
  itIsForward: boolean
114
114
  }
@@ -175,6 +175,7 @@ export function mapMessageTelegramContent({
175
175
  }
176
176
  export function mapMessageWhatsApp({ imMessage }: { imMessage: any }):
177
177
  | {
178
+ type: any
178
179
  text: any
179
180
  reply?: undefined
180
181
  id: any
@@ -182,7 +183,6 @@ export function mapMessageWhatsApp({ imMessage }: { imMessage: any }):
182
183
  imExtraInfo: {
183
184
  wbaid: any
184
185
  }
185
- type: any
186
186
  chatter: {
187
187
  id: any
188
188
  name: any
@@ -192,6 +192,7 @@ export function mapMessageWhatsApp({ imMessage }: { imMessage: any }):
192
192
  timestamp: any
193
193
  }
194
194
  | {
195
+ type: any
195
196
  text?: undefined
196
197
  reply?: undefined
197
198
  id: any
@@ -199,7 +200,6 @@ export function mapMessageWhatsApp({ imMessage }: { imMessage: any }):
199
200
  imExtraInfo: {
200
201
  wbaid: any
201
202
  }
202
- type: any
203
203
  chatter: {
204
204
  id: any
205
205
  name: any
@@ -209,6 +209,7 @@ export function mapMessageWhatsApp({ imMessage }: { imMessage: any }):
209
209
  timestamp: any
210
210
  }
211
211
  | {
212
+ type: any
212
213
  reply: any
213
214
  text?: undefined
214
215
  id: any
@@ -216,7 +217,6 @@ export function mapMessageWhatsApp({ imMessage }: { imMessage: any }):
216
217
  imExtraInfo: {
217
218
  wbaid: any
218
219
  }
219
- type: any
220
220
  chatter: {
221
221
  id: any
222
222
  name: any
@@ -228,6 +228,7 @@ export function mapMessageWhatsApp({ imMessage }: { imMessage: any }):
228
228
  export const messageUnifiedMapper: {
229
229
  [IM_PLATFORM.TELEGRAM]: ({ imMessage }: { imMessage: any }) =>
230
230
  | {
231
+ type: string
231
232
  text: any
232
233
  reply?: undefined
233
234
  timestamp: string
@@ -240,11 +241,11 @@ export const messageUnifiedMapper: {
240
241
  tmId: any
241
242
  }
242
243
  chatId: any
243
- type: string
244
244
  chatter: any
245
245
  itIsForward: boolean
246
246
  }
247
247
  | {
248
+ type: string
248
249
  text?: undefined
249
250
  reply?: undefined
250
251
  timestamp: string
@@ -257,11 +258,11 @@ export const messageUnifiedMapper: {
257
258
  tmId: any
258
259
  }
259
260
  chatId: any
260
- type: string
261
261
  chatter: any
262
262
  itIsForward: boolean
263
263
  }
264
264
  | {
265
+ type: string
265
266
  attachment: string
266
267
  animation: any
267
268
  text?: undefined
@@ -276,11 +277,11 @@ export const messageUnifiedMapper: {
276
277
  tmId: any
277
278
  }
278
279
  chatId: any
279
- type: string
280
280
  chatter: any
281
281
  itIsForward: boolean
282
282
  }
283
283
  | {
284
+ type: string
284
285
  reply: {
285
286
  id: any
286
287
  title: any
@@ -296,12 +297,12 @@ export const messageUnifiedMapper: {
296
297
  tmId: any
297
298
  }
298
299
  chatId: any
299
- type: string
300
300
  chatter: any
301
301
  itIsForward: boolean
302
302
  }
303
303
  [IM_PLATFORM.WHATSAPP]: ({ imMessage }: { imMessage: any }) =>
304
304
  | {
305
+ type: any
305
306
  text: any
306
307
  reply?: undefined
307
308
  id: any
@@ -309,7 +310,6 @@ export const messageUnifiedMapper: {
309
310
  imExtraInfo: {
310
311
  wbaid: any
311
312
  }
312
- type: any
313
313
  chatter: {
314
314
  id: any
315
315
  name: any
@@ -319,6 +319,7 @@ export const messageUnifiedMapper: {
319
319
  timestamp: any
320
320
  }
321
321
  | {
322
+ type: any
322
323
  text?: undefined
323
324
  reply?: undefined
324
325
  id: any
@@ -326,7 +327,6 @@ export const messageUnifiedMapper: {
326
327
  imExtraInfo: {
327
328
  wbaid: any
328
329
  }
329
- type: any
330
330
  chatter: {
331
331
  id: any
332
332
  name: any
@@ -336,6 +336,7 @@ export const messageUnifiedMapper: {
336
336
  timestamp: any
337
337
  }
338
338
  | {
339
+ type: any
339
340
  reply: any
340
341
  text?: undefined
341
342
  id: any
@@ -343,7 +344,6 @@ export const messageUnifiedMapper: {
343
344
  imExtraInfo: {
344
345
  wbaid: any
345
346
  }
346
- type: any
347
347
  chatter: {
348
348
  id: any
349
349
  name: any