@nuiisweety/baileys 0.1.11 → 0.1.13

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.
@@ -545,6 +545,37 @@ const prepareNativeFlowButtons = (message) => {
545
545
  else if (hasOptionalProperty(button, 'sections') && !!button.sections) {
546
546
  return { name: 'single_select', buttonParamsJson: JSON.stringify({ title: buttonText || '📋 Select', sections: button.sections, icon: buttonIcon }) };
547
547
  }
548
+ else if (hasOptionalProperty(button, 'catalog') && !!button.catalog) {
549
+ return { name: 'cta_catalog', buttonParamsJson: JSON.stringify({ display_text: buttonText || '🛍️ Catalog', business_phone_number: button.catalog, icon: buttonIcon }) };
550
+ }
551
+ else if (hasOptionalProperty(button, 'reminder') && button.reminder === true) {
552
+ return { name: 'cta_reminder', buttonParamsJson: JSON.stringify({ display_text: buttonText || '⏰ Remind Me', icon: buttonIcon }) };
553
+ }
554
+ else if (hasOptionalProperty(button, 'cancelReminder') && button.cancelReminder === true) {
555
+ return { name: 'cta_cancel_reminder', buttonParamsJson: JSON.stringify({ display_text: buttonText || '❌ Cancel Reminder', icon: buttonIcon }) };
556
+ }
557
+ else if (hasOptionalProperty(button, 'address') && button.address === true) {
558
+ return { name: 'address_message', buttonParamsJson: JSON.stringify({ display_text: buttonText || '📍 Share Address', icon: buttonIcon }) };
559
+ }
560
+ else if (hasOptionalProperty(button, 'location') && button.location === true) {
561
+ return { name: 'send_location', buttonParamsJson: JSON.stringify({ display_text: buttonText || '📍 Send Location', icon: buttonIcon }) };
562
+ }
563
+ else if (hasOptionalProperty(button, 'webview') && !!button.webview) {
564
+ return { name: 'open_webview', buttonParamsJson: JSON.stringify({ title: buttonText || '🌐 Open', link: { in_app_webview: button.inAppWebview !== false, url: button.webview }, icon: buttonIcon }) };
565
+ }
566
+ else if (hasOptionalProperty(button, 'productId') && !!button.productId) {
567
+ return { name: 'mpm', buttonParamsJson: JSON.stringify({ display_text: buttonText || '🛒 View Product', product_id: button.productId, icon: buttonIcon }) };
568
+ }
569
+ else if (hasOptionalProperty(button, 'transactionId') && !!button.transactionId) {
570
+ return { name: 'wa_payment_transaction_details', buttonParamsJson: JSON.stringify({ display_text: buttonText || '💳 Payment Details', transaction_id: button.transactionId, icon: buttonIcon }) };
571
+ }
572
+ else if (hasOptionalProperty(button, 'catalogProduct') && !!button.catalogProduct) {
573
+ return { name: 'automated_greeting_message_view_catalog', buttonParamsJson: JSON.stringify({ display_text: buttonText || '🛍️ View Catalog', business_phone_number: button.catalogProduct.bizPhone, catalog_product_id: button.catalogProduct.productId, icon: buttonIcon }) };
574
+ }
575
+ else if (hasOptionalProperty(button, 'flow') && !!button.flow) {
576
+ const f = button.flow;
577
+ return { name: 'galaxy_message', buttonParamsJson: JSON.stringify({ mode: f.mode || 'published', flow_message_version: f.flowMessageVersion || '3', flow_token: f.flowToken, flow_id: f.flowId, flow_cta: buttonText || f.flowCta || '▶️ Open Flow', flow_action: f.flowAction || 'navigate', flow_action_payload: f.flowActionPayload, flow_metadata: f.flowMetadata, icon: buttonIcon }) };
578
+ }
548
579
  return button;
549
580
  }),
550
581
  messageParamsJson: JSON.stringify(messageParamsJson),
@@ -919,6 +950,24 @@ export const generateWAMessageContent = async (message, options) => {
919
950
  }
920
951
  };
921
952
  }
953
+ else if (hasNonNullishProperty(message, 'buttonsMessage')) {
954
+ // Direct buttonsMessage passthrough — supports headerType 6 (locationMessage), etc.
955
+ const btnMsg = { ...message.buttonsMessage };
956
+ if (btnMsg.locationMessage?.jpegThumbnail && !Buffer.isBuffer(btnMsg.locationMessage.jpegThumbnail)) {
957
+ const lib = await getImageProcessingLibrary();
958
+ const hasSharp = 'sharp' in lib && !!lib.sharp?.default;
959
+ if (hasSharp) {
960
+ const rawBuf = typeof btnMsg.locationMessage.jpegThumbnail === 'string'
961
+ ? (await fs.readFile(btnMsg.locationMessage.jpegThumbnail))
962
+ : btnMsg.locationMessage.jpegThumbnail;
963
+ btnMsg.locationMessage.jpegThumbnail = await lib.sharp.default(rawBuf)
964
+ .resize(300, 300, { fit: 'inside', withoutEnlargement: true })
965
+ .jpeg({ quality: 80 })
966
+ .toBuffer();
967
+ }
968
+ }
969
+ m = { buttonsMessage: btnMsg };
970
+ }
922
971
  else {
923
972
  m = await prepareWAMessageMedia(message, options);
924
973
  }
@@ -1153,6 +1202,147 @@ export const generateWAMessageContent = async (message, options) => {
1153
1202
  }
1154
1203
  m = { interactiveMessage };
1155
1204
  }
1205
+ else if (hasNonNullishProperty(message, 'shop')) {
1206
+ const interactiveMessage = {
1207
+ shopStorefrontMessage: {
1208
+ surface: message.shop.surface || 1,
1209
+ id: message.shop.id,
1210
+ messageVersion: 1
1211
+ }
1212
+ };
1213
+ if (hasOptionalProperty(message, 'text')) {
1214
+ interactiveMessage.body = { text: message.text };
1215
+ }
1216
+ else if (hasOptionalProperty(message, 'caption')) {
1217
+ const isValidHeader = hasValidInteractiveHeader(m);
1218
+ interactiveMessage.header = {
1219
+ title: message.title || '',
1220
+ subtitle: message.subtitle || '',
1221
+ hasMediaAttachment: isValidHeader
1222
+ };
1223
+ interactiveMessage.body = { text: message.caption };
1224
+ Object.assign(interactiveMessage.header, m);
1225
+ }
1226
+ if (hasOptionalProperty(message, 'title') && !hasOptionalProperty(message, 'caption')) {
1227
+ interactiveMessage.header = {
1228
+ title: message.title,
1229
+ subtitle: message.subtitle || null,
1230
+ hasMediaAttachment: false
1231
+ };
1232
+ }
1233
+ if (hasOptionalProperty(message, 'footer')) {
1234
+ interactiveMessage.footer = { text: message.footer };
1235
+ }
1236
+ m = { interactiveMessage };
1237
+ }
1238
+ else if (hasNonNullishProperty(message, 'collection')) {
1239
+ const interactiveMessage = {
1240
+ collectionMessage: {
1241
+ bizJid: message.collection.bizJid,
1242
+ id: message.collection.id,
1243
+ messageVersion: message.collection.version || 1
1244
+ }
1245
+ };
1246
+ if (hasOptionalProperty(message, 'text')) {
1247
+ interactiveMessage.body = { text: message.text };
1248
+ }
1249
+ else if (hasOptionalProperty(message, 'caption')) {
1250
+ const isValidHeader = hasValidInteractiveHeader(m);
1251
+ interactiveMessage.header = {
1252
+ title: message.title || '',
1253
+ subtitle: message.subtitle || '',
1254
+ hasMediaAttachment: isValidHeader
1255
+ };
1256
+ interactiveMessage.body = { text: message.caption };
1257
+ Object.assign(interactiveMessage.header, m);
1258
+ }
1259
+ if (hasOptionalProperty(message, 'title') && !hasOptionalProperty(message, 'caption')) {
1260
+ interactiveMessage.header = {
1261
+ title: message.title,
1262
+ subtitle: message.subtitle || null,
1263
+ hasMediaAttachment: false
1264
+ };
1265
+ }
1266
+ if (hasOptionalProperty(message, 'footer')) {
1267
+ interactiveMessage.footer = { text: message.footer };
1268
+ }
1269
+ m = { interactiveMessage };
1270
+ }
1271
+ else if (hasNonNullishProperty(message, 'orderStatus')) {
1272
+ const os = message.orderStatus;
1273
+ if (!os.image) {
1274
+ throw new Boom('"image" wajib diisi untuk orderStatus', { statusCode: 400 });
1275
+ }
1276
+ let imageInput = os.image;
1277
+ if (typeof imageInput === 'string' && !imageInput.startsWith('http://') && !imageInput.startsWith('https://')) {
1278
+ const { promises: fsPromises } = await import('fs');
1279
+ imageInput = await fsPromises.readFile(imageInput);
1280
+ }
1281
+ const media = await prepareWAMessageMedia({ image: imageInput }, options);
1282
+ m = {
1283
+ viewOnceMessage: {
1284
+ message: {
1285
+ messageContextInfo: {
1286
+ deviceListMetadata: {},
1287
+ deviceListMetadataVersion: 2
1288
+ },
1289
+ interactiveMessage: proto.Message.InteractiveMessage.create({
1290
+ header: {
1291
+ title: os.title || 'Status Pesanan',
1292
+ hasMediaAttachment: true,
1293
+ ...media
1294
+ },
1295
+ body: { text: os.text || 'Silakan cek status pesanan Anda.' },
1296
+ footer: { text: os.footer || '' },
1297
+ nativeFlowMessage: {
1298
+ buttons: [{
1299
+ name: 'order_status',
1300
+ buttonParamsJson: JSON.stringify({
1301
+ reference_id: os.referenceId || 'ORDER-001',
1302
+ order: {
1303
+ status: os.status || 'PROCESSING',
1304
+ subtotal: {
1305
+ value: os.subtotalValue || 0,
1306
+ offset: os.subtotalOffset || 100
1307
+ },
1308
+ tax: {
1309
+ value: os.taxValue || 0,
1310
+ offset: os.taxOffset || 100
1311
+ },
1312
+ currency: os.currency || 'IDR'
1313
+ }
1314
+ })
1315
+ }]
1316
+ }
1317
+ })
1318
+ }
1319
+ }
1320
+ };
1321
+ }
1322
+ else if (hasNonNullishProperty(message, 'productList')) {
1323
+ let thumbnail = null;
1324
+ if (message.thumbnail) {
1325
+ const { imageMessage } = await prepareWAMessageMedia({ image: message.thumbnail }, options);
1326
+ thumbnail = imageMessage;
1327
+ }
1328
+ m = {
1329
+ listMessage: {
1330
+ title: message.title,
1331
+ buttonText: message.buttonText || 'Lihat Produk',
1332
+ footerText: message.footer,
1333
+ description: message.text,
1334
+ productListInfo: {
1335
+ productSections: message.productList,
1336
+ headerImage: {
1337
+ productId: message.productList?.[0]?.products?.[0]?.productId,
1338
+ jpegThumbnail: thumbnail?.jpegThumbnail || null
1339
+ },
1340
+ businessOwnerJid: message.businessOwnerJid
1341
+ },
1342
+ listType: proto.Message.ListMessage.ListType.PRODUCT_LIST
1343
+ }
1344
+ };
1345
+ }
1156
1346
  else if (hasNonNullishProperty(message, 'requestPaymentFrom')) {
1157
1347
  const requestPaymentMessage = {
1158
1348
  amount: {
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@nuiisweety/baileys",
3
3
  "type": "module",
4
- "version": "0.1.11",
5
- "description": "A WebSockets library for interacting with WhatsApp Web — forked STRICTLY from @whiskeysockets/baileys only, NOT from any other baileys fork. Modified by NuiiSweety.",
4
+ "version": "0.1.13",
5
+ "description": "A WebSockets library for interacting with WhatsApp Web — forked STRICTLY from @whiskeysockets/baileys only, NOT from any other baileys fork. Modified by © NuiiS4TORU.",
6
6
  "keywords": [
7
7
  "whatsapp",
8
8
  "automation"
@@ -12,7 +12,7 @@
12
12
  "url": "git@github.com:WhiskeySockets/Baileys.git"
13
13
  },
14
14
  "license": "MIT",
15
- "author": "NuiiSweety (based on WhiskeySockets/Baileys)",
15
+ "author": "© NuiiS4TORU (based on WhiskeySockets/Baileys)",
16
16
  "main": "lib/index.js",
17
17
  "types": "lib/index.d.ts",
18
18
  "files": [