sauruspro-bail 5.0.0 → 5.0.1

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 (39) hide show
  1. package/README.md +8 -9
  2. package/docs/CHANGELOG.md +25 -4
  3. package/docs/SPR.md +2 -2
  4. package/lib/Defaults/index.js +5 -1
  5. package/lib/Socket/dinonic-handler.d.ts +27 -0
  6. package/lib/Socket/dinonic-handler.js +882 -0
  7. package/lib/Socket/index.js +5 -1
  8. package/lib/Socket/messages-recv.js +26 -0
  9. package/lib/Socket/messages-send.js +25 -0
  10. package/lib/Utils/MessageBuilder.d.ts +215 -0
  11. package/lib/Utils/MessageBuilder.js +3991 -0
  12. package/lib/Utils/a2ui.d.ts +202 -0
  13. package/lib/Utils/a2ui.js +732 -0
  14. package/lib/Utils/airich-registry.js +3 -0
  15. package/lib/Utils/baileys-event-stream.js +58 -0
  16. package/lib/Utils/bot-signature.d.ts +22 -0
  17. package/lib/Utils/bot-signature.js +124 -0
  18. package/lib/Utils/{dinolith-spr.js → dinonic-spr.js} +1 -1
  19. package/lib/Utils/extras.d.ts +449 -0
  20. package/lib/Utils/extras.js +1377 -0
  21. package/lib/Utils/html-app.d.ts +39 -0
  22. package/lib/Utils/html-app.js +291 -0
  23. package/lib/Utils/index.js +14 -2
  24. package/lib/Utils/metaai.d.ts +438 -0
  25. package/lib/Utils/metaai.js +911 -0
  26. package/lib/Utils/modern-messages.d.ts +150 -0
  27. package/lib/Utils/modern-messages.js +496 -0
  28. package/lib/Utils/native-flow.d.ts +14 -0
  29. package/lib/Utils/native-flow.js +118 -0
  30. package/lib/Utils/newsletter-status.js +9 -53
  31. package/lib/Utils/payment-messages.d.ts +59 -0
  32. package/lib/Utils/payment-messages.js +156 -0
  33. package/lib/Utils/scheduled-message.d.ts +82 -0
  34. package/lib/Utils/scheduled-message.js +113 -0
  35. package/lib/Utils/status-stickers.d.ts +78 -0
  36. package/lib/Utils/status-stickers.js +261 -0
  37. package/lib/index.js +2 -2
  38. package/package.json +4 -4
  39. /package/lib/Utils/{dinolith-spr.d.ts → dinonic-spr.d.ts} +0 -0
@@ -0,0 +1,150 @@
1
+ import { proto } from '../../WAProto/index.js'
2
+
3
+ export declare function makeQuestionMessage(input: {
4
+ text: string
5
+ contextInfo?: proto.IContextInfo
6
+ }): proto.IMessage
7
+
8
+ export declare function makeQuestionResponseMessage(input: {
9
+ key: proto.IMessageKey
10
+ text?: string
11
+ }): proto.IMessage
12
+
13
+ export declare function makeQuestionReplyMessage(input: {
14
+ text: string
15
+ serverQuestionId: number | string
16
+ quotedQuestion?: proto.IMessage
17
+ quotedResponse?: proto.IMessage
18
+ contextInfo?: proto.IContextInfo
19
+ }): proto.IMessage
20
+
21
+ export declare function makeStatusQuestionAnswerMessage(input: {
22
+ key: proto.IMessageKey
23
+ text?: string
24
+ }): proto.IMessage
25
+
26
+ export declare function makeStatusQuotedMessage(input: {
27
+ type?: number | string
28
+ text?: string
29
+ thumbnail?: Uint8Array
30
+ originalStatusId: proto.IMessageKey
31
+ }): proto.IMessage
32
+
33
+ export declare function makeStatusStickerInteractionMessage(input: {
34
+ key: proto.IMessageKey
35
+ stickerKey: string
36
+ type?: number | string
37
+ }): proto.IMessage
38
+
39
+ export declare function makeStatusNotificationMessage(input: {
40
+ responseMessageKey: proto.IMessageKey
41
+ originalMessageKey: proto.IMessageKey
42
+ type?: number | string
43
+ }): proto.IMessage
44
+
45
+ export declare function makeNewsletterAdminInviteMessage(input: {
46
+ newsletterJid: string
47
+ newsletterName?: string
48
+ jpegThumbnail?: Uint8Array
49
+ caption?: string
50
+ inviteExpiration?: number
51
+ contextInfo?: proto.IContextInfo
52
+ }): proto.IMessage
53
+
54
+ export declare function makeNewsletterFollowerInviteMessage(input: {
55
+ newsletterJid: string
56
+ newsletterName?: string
57
+ jpegThumbnail?: Uint8Array
58
+ caption?: string
59
+ contextInfo?: proto.IContextInfo
60
+ }): proto.IMessage
61
+
62
+ export declare function makePollAddOptionMessage(input: {
63
+ pollCreationMessageKey: proto.IMessageKey
64
+ option?: string | proto.Message.PollCreationMessage.IOption
65
+ addOption?: proto.Message.PollCreationMessage.IOption
66
+ metadata?: proto.Message.IPollUpdateMessageMetadata
67
+ }): proto.IMessage
68
+
69
+ export declare function makeCommentMessage(input: {
70
+ message?: proto.IMessage
71
+ content?: Record<string, any>
72
+ targetMessageKey: proto.IMessageKey
73
+ }): proto.IMessage
74
+
75
+ export declare function makeEventInviteMessage(input: {
76
+ eventId: string
77
+ eventTitle?: string
78
+ jpegThumbnail?: Uint8Array
79
+ startTime?: number | Date
80
+ caption?: string
81
+ isCanceled?: boolean
82
+ endTime?: number | Date
83
+ callLink?: string
84
+ contextInfo?: proto.IContextInfo
85
+ }): proto.IMessage
86
+
87
+ export declare function makeScheduledCallCreationMessage(input: {
88
+ scheduledTimestampMs: number | Date
89
+ callType?: number | string
90
+ title?: string
91
+ }): proto.IMessage
92
+
93
+ export declare function makeScheduledCallEditMessage(input: {
94
+ key: proto.IMessageKey
95
+ editType?: number | string
96
+ }): proto.IMessage
97
+
98
+ export declare function makeGroupStatusReactionMessage(input: {
99
+ key: proto.IMessageKey
100
+ text?: string
101
+ groupingKey?: string
102
+ senderTimestampMs?: number
103
+ }): proto.IMessage
104
+
105
+ export declare function makeNewsletterStatusAttribution(input: {
106
+ newsletterJid: string
107
+ messageId: string | number
108
+ duration?: number
109
+ hasMultipleReshares?: boolean
110
+ actionUrl?: string
111
+ }): proto.IStatusAttribution
112
+
113
+ export declare function makeGroupStatusAttribution(input: {
114
+ authorJid: string
115
+ actionUrl?: string
116
+ }): proto.IStatusAttribution
117
+
118
+ export declare const STATUS_AUDIENCE_DEFAULT_LIST_NAME: string
119
+ export declare const STATUS_AUDIENCE_DEFAULT_EMOJI: string
120
+
121
+ export declare function makeStatusAudienceMetadata(input: string | {
122
+ listName?: string
123
+ listEmoji?: string
124
+ audienceType?: number | string
125
+ }): proto.ContextInfo.IStatusAudienceMetadata
126
+
127
+ export declare const STATUS_NOTIFICATION_TYPES: Readonly<Record<string, number>>
128
+
129
+ export declare function makeMessageAssociation(input: {
130
+ parentMessageKey?: proto.IMessageKey
131
+ key?: proto.IMessageKey
132
+ associationType?: number | string
133
+ type?: number | string
134
+ messageIndex?: number
135
+ }): proto.IMessageAssociation
136
+
137
+ export declare function makeStatusAddYoursAssociation(input: proto.IMessageKey | {
138
+ key?: proto.IMessageKey
139
+ parentMessageKey?: proto.IMessageKey
140
+ type?: number | string
141
+ associationType?: number | string
142
+ messageIndex?: number
143
+ }): proto.IMessageAssociation
144
+
145
+ export declare function makeStatusMentionMessage(input: {
146
+ key: proto.IMessageKey
147
+ group?: boolean
148
+ }): any
149
+
150
+ export declare function prepareModernMessageContent(content: any): any
@@ -0,0 +1,496 @@
1
+ import { proto } from '../../WAProto/index.js';
2
+ const requireObject = (value, name) => {
3
+ if (!value || typeof value !== 'object' || Array.isArray(value)) {
4
+ throw new TypeError(`${name} must be an object`)
5
+ }
6
+ return value
7
+ }
8
+
9
+ const requireKey = (value, name = 'key') => {
10
+ requireObject(value, name)
11
+ if (!value.id) {
12
+ throw new TypeError(`${name}.id is required`)
13
+ }
14
+ return value
15
+ }
16
+
17
+ const enumValue = (enumObject, value, fallback) => {
18
+ if (typeof value === 'number') return value
19
+ if (typeof value === 'string') {
20
+ const key = value.trim().toUpperCase()
21
+ if (key in enumObject) return enumObject[key]
22
+ }
23
+ return fallback
24
+ }
25
+
26
+ export const STATUS_NOTIFICATION_TYPES = Object.freeze({
27
+ ...proto.Message.StatusNotificationMessage.StatusNotificationType,
28
+ STATUS_GROUP_STATUS_REPLY: 4
29
+ })
30
+
31
+ const toSeconds = value => value instanceof Date ? Math.floor(value.getTime() / 1000) : value
32
+ const toMilliseconds = value => value instanceof Date ? value.getTime() : value
33
+
34
+ const makeInnerCommentMessage = content => {
35
+ const data = requireObject(content, 'comment.content')
36
+ if (data.raw && typeof data.raw === 'object') return data.raw
37
+ if (typeof data.text === 'string') {
38
+ return {
39
+ extendedTextMessage: proto.Message.ExtendedTextMessage.create({
40
+ text: data.text,
41
+ contextInfo: data.contextInfo
42
+ })
43
+ }
44
+ }
45
+ const keys = Object.keys(data)
46
+ if (keys.some(key => key.endsWith('Message'))) return data
47
+ throw new TypeError('comment.content supports text, raw, or protobuf message fields')
48
+ }
49
+
50
+ export const makeQuestionMessage = input => {
51
+ const data = requireObject(input, 'question')
52
+ if (typeof data.text !== 'string' || !data.text.length) {
53
+ throw new TypeError('question.text is required')
54
+ }
55
+ return {
56
+ questionMessage: proto.Message.FutureProofMessage.create({
57
+ message: {
58
+ extendedTextMessage: proto.Message.ExtendedTextMessage.create({
59
+ text: data.text,
60
+ contextInfo: {
61
+ ...(data.contextInfo || {}),
62
+ isQuestion: true
63
+ }
64
+ })
65
+ }
66
+ })
67
+ }
68
+ }
69
+
70
+ export const makeQuestionResponseMessage = input => {
71
+ const data = requireObject(input, 'questionResponse')
72
+ requireKey(data.key, 'questionResponse.key')
73
+ return {
74
+ questionResponseMessage: proto.Message.QuestionResponseMessage.create({
75
+ key: data.key,
76
+ text: data.text ?? ''
77
+ })
78
+ }
79
+ }
80
+
81
+ export const makeQuestionReplyMessage = input => {
82
+ const data = requireObject(input, 'questionReply')
83
+ if (typeof data.text !== 'string' || !data.text.length) {
84
+ throw new TypeError('questionReply.text is required')
85
+ }
86
+ if (data.serverQuestionId === undefined || data.serverQuestionId === null) {
87
+ throw new TypeError('questionReply.serverQuestionId is required')
88
+ }
89
+ const quoted = {
90
+ serverQuestionId: Number(data.serverQuestionId)
91
+ }
92
+ if (data.quotedQuestion) quoted.quotedQuestion = data.quotedQuestion
93
+ if (data.quotedResponse) quoted.quotedResponse = data.quotedResponse
94
+ return {
95
+ questionReplyMessage: proto.Message.FutureProofMessage.create({
96
+ message: {
97
+ extendedTextMessage: proto.Message.ExtendedTextMessage.create({
98
+ text: data.text,
99
+ contextInfo: {
100
+ ...(data.contextInfo || {}),
101
+ questionReplyQuotedMessage: quoted
102
+ }
103
+ })
104
+ }
105
+ })
106
+ }
107
+ }
108
+
109
+ export const makeStatusQuestionAnswerMessage = input => {
110
+ const data = requireObject(input, 'statusQuestionAnswer')
111
+ requireKey(data.key, 'statusQuestionAnswer.key')
112
+ return {
113
+ statusQuestionAnswerMessage: proto.Message.StatusQuestionAnswerMessage.create({
114
+ key: data.key,
115
+ text: data.text ?? ''
116
+ })
117
+ }
118
+ }
119
+
120
+ export const makeStatusQuotedMessage = input => {
121
+ const data = requireObject(input, 'statusQuoted')
122
+ requireKey(data.originalStatusId, 'statusQuoted.originalStatusId')
123
+ const type = enumValue(
124
+ proto.Message.StatusQuotedMessage.StatusQuotedMessageType,
125
+ data.type,
126
+ proto.Message.StatusQuotedMessage.StatusQuotedMessageType.QUESTION_ANSWER
127
+ )
128
+ return {
129
+ statusQuotedMessage: proto.Message.StatusQuotedMessage.create({
130
+ type,
131
+ text: data.text,
132
+ thumbnail: data.thumbnail,
133
+ originalStatusId: data.originalStatusId
134
+ })
135
+ }
136
+ }
137
+
138
+ export const makeStatusStickerInteractionMessage = input => {
139
+ const data = requireObject(input, 'statusStickerInteraction')
140
+ requireKey(data.key, 'statusStickerInteraction.key')
141
+ if (!data.stickerKey) {
142
+ throw new TypeError('statusStickerInteraction.stickerKey is required')
143
+ }
144
+ const type = enumValue(
145
+ proto.Message.StatusStickerInteractionMessage.StatusStickerType,
146
+ data.type,
147
+ proto.Message.StatusStickerInteractionMessage.StatusStickerType.REACTION
148
+ )
149
+ return {
150
+ statusStickerInteractionMessage: proto.Message.StatusStickerInteractionMessage.create({
151
+ key: data.key,
152
+ stickerKey: data.stickerKey,
153
+ type
154
+ })
155
+ }
156
+ }
157
+
158
+ export const makeStatusNotificationMessage = input => {
159
+ const data = requireObject(input, 'statusNotification')
160
+ requireKey(data.responseMessageKey, 'statusNotification.responseMessageKey')
161
+ requireKey(data.originalMessageKey, 'statusNotification.originalMessageKey')
162
+ const type = enumValue(
163
+ STATUS_NOTIFICATION_TYPES,
164
+ data.type,
165
+ STATUS_NOTIFICATION_TYPES.UNKNOWN
166
+ )
167
+ return {
168
+ statusNotificationMessage: proto.Message.StatusNotificationMessage.create({
169
+ responseMessageKey: data.responseMessageKey,
170
+ originalMessageKey: data.originalMessageKey,
171
+ type
172
+ })
173
+ }
174
+ }
175
+
176
+ export const makeNewsletterAdminInviteMessage = input => {
177
+ const data = requireObject(input, 'newsletterAdminInvite')
178
+ if (!data.newsletterJid) {
179
+ throw new TypeError('newsletterAdminInvite.newsletterJid is required')
180
+ }
181
+ return {
182
+ newsletterAdminInviteMessage: proto.Message.NewsletterAdminInviteMessage.create({
183
+ newsletterJid: data.newsletterJid,
184
+ newsletterName: data.newsletterName,
185
+ jpegThumbnail: data.jpegThumbnail,
186
+ caption: data.caption,
187
+ inviteExpiration: data.inviteExpiration,
188
+ contextInfo: data.contextInfo
189
+ })
190
+ }
191
+ }
192
+
193
+ export const makeNewsletterFollowerInviteMessage = input => {
194
+ const data = requireObject(input, 'newsletterFollowerInvite')
195
+ if (!data.newsletterJid) {
196
+ throw new TypeError('newsletterFollowerInvite.newsletterJid is required')
197
+ }
198
+ return {
199
+ newsletterFollowerInviteMessageV2: proto.Message.NewsletterFollowerInviteMessage.create({
200
+ newsletterJid: data.newsletterJid,
201
+ newsletterName: data.newsletterName,
202
+ jpegThumbnail: data.jpegThumbnail,
203
+ caption: data.caption,
204
+ contextInfo: data.contextInfo
205
+ })
206
+ }
207
+ }
208
+
209
+ export const makePollAddOptionMessage = input => {
210
+ const data = requireObject(input, 'pollAddOption')
211
+ requireKey(data.pollCreationMessageKey, 'pollAddOption.pollCreationMessageKey')
212
+ const addOption = typeof data.option === 'string'
213
+ ? { optionName: data.option }
214
+ : data.addOption || data.option
215
+ if (!addOption?.optionName) {
216
+ throw new TypeError('pollAddOption.option is required')
217
+ }
218
+ return {
219
+ pollAddOptionMessage: proto.Message.PollAddOptionMessage.create({
220
+ pollCreationMessageKey: data.pollCreationMessageKey,
221
+ addOption,
222
+ metadata: data.metadata
223
+ })
224
+ }
225
+ }
226
+
227
+ export const makeCommentMessage = input => {
228
+ const data = requireObject(input, 'comment')
229
+ requireKey(data.targetMessageKey, 'comment.targetMessageKey')
230
+ const message = data.message || (data.content ? makeInnerCommentMessage(data.content) : null)
231
+ requireObject(message, 'comment.message')
232
+ return {
233
+ commentMessage: proto.Message.CommentMessage.create({
234
+ message,
235
+ targetMessageKey: data.targetMessageKey
236
+ })
237
+ }
238
+ }
239
+
240
+ export const makeEventInviteMessage = input => {
241
+ const data = requireObject(input, 'eventInvite')
242
+ if (!data.eventId) {
243
+ throw new TypeError('eventInvite.eventId is required')
244
+ }
245
+ return {
246
+ eventInviteMessage: proto.Message.EventInviteMessage.create({
247
+ contextInfo: data.contextInfo,
248
+ eventId: data.eventId,
249
+ eventTitle: data.eventTitle,
250
+ jpegThumbnail: data.jpegThumbnail,
251
+ startTime: toSeconds(data.startTime),
252
+ caption: data.caption,
253
+ isCanceled: data.isCanceled,
254
+ endTime: toSeconds(data.endTime),
255
+ callLink: data.callLink
256
+ })
257
+ }
258
+ }
259
+
260
+ export const makeScheduledCallCreationMessage = input => {
261
+ const data = requireObject(input, 'scheduledCall')
262
+ if (!data.scheduledTimestampMs) {
263
+ throw new TypeError('scheduledCall.scheduledTimestampMs is required')
264
+ }
265
+ const callType = enumValue(
266
+ proto.Message.ScheduledCallCreationMessage.CallType,
267
+ data.callType,
268
+ proto.Message.ScheduledCallCreationMessage.CallType.UNKNOWN
269
+ )
270
+ return {
271
+ scheduledCallCreationMessage: proto.Message.ScheduledCallCreationMessage.create({
272
+ scheduledTimestampMs: toMilliseconds(data.scheduledTimestampMs),
273
+ callType,
274
+ title: data.title
275
+ })
276
+ }
277
+ }
278
+
279
+ export const makeScheduledCallEditMessage = input => {
280
+ const data = requireObject(input, 'scheduledCallEdit')
281
+ requireKey(data.key, 'scheduledCallEdit.key')
282
+ const editType = enumValue(
283
+ proto.Message.ScheduledCallEditMessage.EditType,
284
+ data.editType,
285
+ proto.Message.ScheduledCallEditMessage.EditType.CANCEL
286
+ )
287
+ return {
288
+ scheduledCallEditMessage: proto.Message.ScheduledCallEditMessage.create({
289
+ key: data.key,
290
+ editType
291
+ })
292
+ }
293
+ }
294
+
295
+ export const makeGroupStatusReactionMessage = input => {
296
+ const data = requireObject(input, 'groupStatusReaction')
297
+ requireKey(data.key, 'groupStatusReaction.key')
298
+ return {
299
+ groupStatusMessageV2: proto.Message.FutureProofMessage.create({
300
+ message: {
301
+ reactionMessage: proto.Message.ReactionMessage.create({
302
+ key: data.key,
303
+ text: data.text ?? '',
304
+ groupingKey: data.groupingKey,
305
+ senderTimestampMs: data.senderTimestampMs || Date.now()
306
+ })
307
+ }
308
+ })
309
+ }
310
+ }
311
+
312
+ export const makeNewsletterStatusAttribution = input => {
313
+ const data = requireObject(input, 'newsletterStatus')
314
+ if (!data.newsletterJid) {
315
+ throw new TypeError('newsletterStatus.newsletterJid is required')
316
+ }
317
+ if (data.messageId === undefined || data.messageId === null) {
318
+ throw new TypeError('newsletterStatus.messageId is required')
319
+ }
320
+ return proto.StatusAttribution.create({
321
+ type: proto.StatusAttribution.Type.NEWSLETTER_STATUS,
322
+ actionUrl: data.actionUrl,
323
+ statusReshare: {
324
+ source: proto.StatusAttribution.StatusReshare.Source.CHANNEL_RESHARE,
325
+ metadata: {
326
+ duration: data.duration,
327
+ channelJid: data.newsletterJid,
328
+ channelMessageId: Number(data.messageId),
329
+ hasMultipleReshares: data.hasMultipleReshares ?? false
330
+ }
331
+ }
332
+ })
333
+ }
334
+
335
+ export const makeGroupStatusAttribution = input => {
336
+ const data = requireObject(input, 'groupStatusAttribution')
337
+ if (!data.authorJid) {
338
+ throw new TypeError('groupStatusAttribution.authorJid is required')
339
+ }
340
+ return proto.StatusAttribution.create({
341
+ type: proto.StatusAttribution.Type.GROUP_STATUS,
342
+ actionUrl: data.actionUrl,
343
+ groupStatus: {
344
+ authorJid: data.authorJid
345
+ }
346
+ })
347
+ }
348
+
349
+ export const STATUS_AUDIENCE_DEFAULT_LIST_NAME = 'Close friends'
350
+ export const STATUS_AUDIENCE_DEFAULT_EMOJI = '⭐'
351
+
352
+ export const makeStatusAudienceMetadata = input => {
353
+ const data = typeof input === 'string' ? { listName: input } : requireObject(input, 'statusAudience')
354
+ const audienceType = enumValue(
355
+ proto.ContextInfo.StatusAudienceMetadata.AudienceType,
356
+ data.audienceType,
357
+ proto.ContextInfo.StatusAudienceMetadata.AudienceType.CLOSE_FRIENDS
358
+ )
359
+ const listName = data.listName === undefined ? STATUS_AUDIENCE_DEFAULT_LIST_NAME : String(data.listName)
360
+ const listEmoji = data.listEmoji === undefined ? STATUS_AUDIENCE_DEFAULT_EMOJI : String(data.listEmoji)
361
+ return proto.ContextInfo.StatusAudienceMetadata.create({
362
+ audienceType,
363
+ listName,
364
+ listEmoji
365
+ })
366
+ }
367
+
368
+ export const makeMessageAssociation = input => {
369
+ const data = requireObject(input, 'messageAssociation')
370
+ const parentMessageKey = data.parentMessageKey ?? data.key
371
+ requireKey(parentMessageKey, 'messageAssociation.parentMessageKey')
372
+ const associationType = enumValue(
373
+ proto.MessageAssociation.AssociationType,
374
+ data.associationType ?? data.type,
375
+ proto.MessageAssociation.AssociationType.UNKNOWN
376
+ )
377
+ return proto.MessageAssociation.create({
378
+ associationType,
379
+ parentMessageKey,
380
+ messageIndex: data.messageIndex
381
+ })
382
+ }
383
+
384
+ export const makeStatusAddYoursAssociation = input => {
385
+ const data = input && typeof input === 'object' && !Array.isArray(input) && input.id
386
+ ? { key: input }
387
+ : requireObject(input, 'addYours')
388
+ const parentMessageKey = data.key ?? data.parentMessageKey
389
+ requireKey(parentMessageKey, 'addYours.key')
390
+ const associationType = enumValue(
391
+ proto.MessageAssociation.AssociationType,
392
+ data.type ?? data.associationType,
393
+ proto.MessageAssociation.AssociationType.STATUS_ADD_YOURS
394
+ )
395
+ return proto.MessageAssociation.create({
396
+ associationType,
397
+ parentMessageKey,
398
+ messageIndex: data.messageIndex
399
+ })
400
+ }
401
+
402
+ export const makeStatusMentionMessage = input => {
403
+ const data = requireObject(input, 'statusMention')
404
+ requireKey(data.key, 'statusMention.key')
405
+ const field = data.group ? 'groupStatusMentionMessage' : 'statusMentionMessage'
406
+ return {
407
+ [field]: proto.Message.FutureProofMessage.create({
408
+ message: {
409
+ protocolMessage: proto.Message.ProtocolMessage.create({
410
+ key: data.key,
411
+ type: proto.Message.ProtocolMessage.Type.STATUS_MENTION_MESSAGE
412
+ })
413
+ }
414
+ })
415
+ }
416
+ }
417
+
418
+ const modernBuilders = [
419
+ ['question', makeQuestionMessage],
420
+ ['questionReply', makeQuestionReplyMessage],
421
+ ['questionResponse', makeQuestionResponseMessage],
422
+ ['statusQuestionAnswer', makeStatusQuestionAnswerMessage],
423
+ ['statusQuoted', makeStatusQuotedMessage],
424
+ ['statusStickerInteraction', makeStatusStickerInteractionMessage],
425
+ ['statusNotification', makeStatusNotificationMessage],
426
+ ['newsletterAdminInvite', makeNewsletterAdminInviteMessage],
427
+ ['newsletterFollowerInvite', makeNewsletterFollowerInviteMessage],
428
+ ['pollAddOption', makePollAddOptionMessage],
429
+ ['comment', makeCommentMessage],
430
+ ['eventInvite', makeEventInviteMessage],
431
+ ['scheduledCall', makeScheduledCallCreationMessage],
432
+ ['scheduledCallEdit', makeScheduledCallEditMessage],
433
+ ['groupStatusReaction', makeGroupStatusReactionMessage],
434
+ ['statusMention', makeStatusMentionMessage]
435
+ ]
436
+
437
+ export const prepareModernMessageContent = content => {
438
+ if (!content || typeof content !== 'object' || Array.isArray(content)) return content
439
+ let output = { ...content }
440
+ const attributions = Array.isArray(output.contextInfo?.statusAttributions)
441
+ ? [...output.contextInfo.statusAttributions]
442
+ : []
443
+ if (output.newsletterStatus) {
444
+ attributions.push(makeNewsletterStatusAttribution(output.newsletterStatus))
445
+ delete output.newsletterStatus
446
+ }
447
+ if (output.groupStatusAttribution) {
448
+ attributions.push(makeGroupStatusAttribution(output.groupStatusAttribution))
449
+ delete output.groupStatusAttribution
450
+ }
451
+ if (Array.isArray(output.statusAttributions)) {
452
+ attributions.push(...output.statusAttributions)
453
+ delete output.statusAttributions
454
+ }
455
+ const carried = []
456
+ const audience = output.statusAudience
457
+ if (audience !== undefined && audience !== null) {
458
+ carried.push('statusAudience')
459
+ output.contextInfo = {
460
+ ...(output.contextInfo || {}),
461
+ statusAudienceMetadata: makeStatusAudienceMetadata(audience)
462
+ }
463
+ delete output.statusAudience
464
+ }
465
+ if (attributions.length) {
466
+ output.contextInfo = {
467
+ ...(output.contextInfo || {}),
468
+ statusAttributions: attributions
469
+ }
470
+ }
471
+ if (output.addYours !== undefined && output.addYours !== null) {
472
+ carried.push('addYours')
473
+ output.messageAssociation = makeStatusAddYoursAssociation(output.addYours)
474
+ delete output.addYours
475
+ }
476
+ else if (output.messageAssociation !== undefined && output.messageAssociation !== null) {
477
+ carried.push('messageAssociation')
478
+ output.messageAssociation = makeMessageAssociation(output.messageAssociation)
479
+ }
480
+ for (const [key, builder] of modernBuilders) {
481
+ if (output[key] !== undefined && output[key] !== null) {
482
+ if (carried.length) {
483
+ throw new TypeError(
484
+ `${carried.join(' and ')} cannot be combined with ${key}: ${key} builds its own message and keeps no room for them. `
485
+ + 'Build it with the low-level makers and generateWAMessageFromContent instead.'
486
+ )
487
+ }
488
+ return {
489
+ raw: true,
490
+ ...builder(output[key])
491
+ }
492
+ }
493
+ }
494
+ return output
495
+ }
496
+
@@ -0,0 +1,14 @@
1
+ export const NATIVE_FLOW_NAMES: readonly string[];
2
+ export const WEB_SUPPORTED_INTERACTIVE_FLOWS: readonly string[];
3
+ export const NATIVE_FLOW_BUTTON_LIMIT: {
4
+ readonly quickReply: 10;
5
+ readonly other: 3;
6
+ };
7
+ export const getNativeFlowNameByButtonName: (name: string) => string | undefined;
8
+ export const isWebSupportedButtonName: (name: string) => boolean;
9
+ export const checkNativeFlowButtons: (buttons: any[]) => {
10
+ ok: boolean;
11
+ limit: number;
12
+ problems: string[];
13
+ unsupported: string[];
14
+ };