@renatoascencio/n8n-nodes-evolution-api 0.1.0
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/LICENSE +21 -0
- package/README.md +330 -0
- package/dist/credentials/EvolutionApi.credentials.d.ts +10 -0
- package/dist/credentials/EvolutionApi.credentials.js +84 -0
- package/dist/credentials/EvolutionApi.credentials.js.map +1 -0
- package/dist/nodes/EvolutionApi/EvolutionApi.node.d.ts +19 -0
- package/dist/nodes/EvolutionApi/EvolutionApi.node.js +180 -0
- package/dist/nodes/EvolutionApi/EvolutionApi.node.js.map +1 -0
- package/dist/nodes/EvolutionApi/EvolutionApi.node.json +22 -0
- package/dist/nodes/EvolutionApi/EvolutionApiTrigger.node.d.ts +18 -0
- package/dist/nodes/EvolutionApi/EvolutionApiTrigger.node.js +615 -0
- package/dist/nodes/EvolutionApi/EvolutionApiTrigger.node.js.map +1 -0
- package/dist/nodes/EvolutionApi/EvolutionApiTrigger.node.json +19 -0
- package/dist/nodes/EvolutionApi/GenericFunctions.d.ts +114 -0
- package/dist/nodes/EvolutionApi/GenericFunctions.js +681 -0
- package/dist/nodes/EvolutionApi/GenericFunctions.js.map +1 -0
- package/dist/nodes/EvolutionApi/constants.d.ts +7 -0
- package/dist/nodes/EvolutionApi/constants.js +77 -0
- package/dist/nodes/EvolutionApi/constants.js.map +1 -0
- package/dist/nodes/EvolutionApi/evolution.svg +11 -0
- package/dist/nodes/EvolutionApi/resources/call/index.d.ts +5 -0
- package/dist/nodes/EvolutionApi/resources/call/index.js +62 -0
- package/dist/nodes/EvolutionApi/resources/call/index.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/call/offer.operation.d.ts +29 -0
- package/dist/nodes/EvolutionApi/resources/call/offer.operation.js +56 -0
- package/dist/nodes/EvolutionApi/resources/call/offer.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/chat/archive.operation.d.ts +29 -0
- package/dist/nodes/EvolutionApi/resources/chat/archive.operation.js +44 -0
- package/dist/nodes/EvolutionApi/resources/chat/archive.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/chat/checkNumbers.operation.d.ts +29 -0
- package/dist/nodes/EvolutionApi/resources/chat/checkNumbers.operation.js +28 -0
- package/dist/nodes/EvolutionApi/resources/chat/checkNumbers.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/chat/deleteMessage.operation.d.ts +29 -0
- package/dist/nodes/EvolutionApi/resources/chat/deleteMessage.operation.js +68 -0
- package/dist/nodes/EvolutionApi/resources/chat/deleteMessage.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/chat/downloadMedia.operation.d.ts +30 -0
- package/dist/nodes/EvolutionApi/resources/chat/downloadMedia.operation.js +143 -0
- package/dist/nodes/EvolutionApi/resources/chat/downloadMedia.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/chat/editMessage.operation.d.ts +29 -0
- package/dist/nodes/EvolutionApi/resources/chat/editMessage.operation.js +49 -0
- package/dist/nodes/EvolutionApi/resources/chat/editMessage.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/chat/get.operation.d.ts +29 -0
- package/dist/nodes/EvolutionApi/resources/chat/get.operation.js +28 -0
- package/dist/nodes/EvolutionApi/resources/chat/get.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/chat/getChannels.operation.d.ts +29 -0
- package/dist/nodes/EvolutionApi/resources/chat/getChannels.operation.js +23 -0
- package/dist/nodes/EvolutionApi/resources/chat/getChannels.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/chat/getContacts.operation.d.ts +29 -0
- package/dist/nodes/EvolutionApi/resources/chat/getContacts.operation.js +55 -0
- package/dist/nodes/EvolutionApi/resources/chat/getContacts.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/chat/getMany.operation.d.ts +30 -0
- package/dist/nodes/EvolutionApi/resources/chat/getMany.operation.js +74 -0
- package/dist/nodes/EvolutionApi/resources/chat/getMany.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/chat/getMessages.operation.d.ts +29 -0
- package/dist/nodes/EvolutionApi/resources/chat/getMessages.operation.js +124 -0
- package/dist/nodes/EvolutionApi/resources/chat/getMessages.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/chat/getPollVotes.operation.d.ts +29 -0
- package/dist/nodes/EvolutionApi/resources/chat/getPollVotes.operation.js +36 -0
- package/dist/nodes/EvolutionApi/resources/chat/getPollVotes.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/chat/getStatusUpdates.operation.d.ts +29 -0
- package/dist/nodes/EvolutionApi/resources/chat/getStatusUpdates.operation.js +57 -0
- package/dist/nodes/EvolutionApi/resources/chat/getStatusUpdates.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/chat/helpers.d.ts +25 -0
- package/dist/nodes/EvolutionApi/resources/chat/helpers.js +219 -0
- package/dist/nodes/EvolutionApi/resources/chat/helpers.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/chat/index.d.ts +5 -0
- package/dist/nodes/EvolutionApi/resources/chat/index.js +209 -0
- package/dist/nodes/EvolutionApi/resources/chat/index.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/chat/markAsPlayed.operation.d.ts +29 -0
- package/dist/nodes/EvolutionApi/resources/chat/markAsPlayed.operation.js +49 -0
- package/dist/nodes/EvolutionApi/resources/chat/markAsPlayed.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/chat/markAsRead.operation.d.ts +29 -0
- package/dist/nodes/EvolutionApi/resources/chat/markAsRead.operation.js +48 -0
- package/dist/nodes/EvolutionApi/resources/chat/markAsRead.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/chat/markUnread.operation.d.ts +29 -0
- package/dist/nodes/EvolutionApi/resources/chat/markUnread.operation.js +35 -0
- package/dist/nodes/EvolutionApi/resources/chat/markUnread.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/chat/sendPresence.operation.d.ts +29 -0
- package/dist/nodes/EvolutionApi/resources/chat/sendPresence.operation.js +53 -0
- package/dist/nodes/EvolutionApi/resources/chat/sendPresence.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/chat/updateBlockStatus.operation.d.ts +29 -0
- package/dist/nodes/EvolutionApi/resources/chat/updateBlockStatus.operation.js +44 -0
- package/dist/nodes/EvolutionApi/resources/chat/updateBlockStatus.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/chatbot/changeStatus.operation.d.ts +31 -0
- package/dist/nodes/EvolutionApi/resources/chatbot/changeStatus.operation.js +73 -0
- package/dist/nodes/EvolutionApi/resources/chatbot/changeStatus.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/chatbot/create.operation.d.ts +38 -0
- package/dist/nodes/EvolutionApi/resources/chatbot/create.operation.js +251 -0
- package/dist/nodes/EvolutionApi/resources/chatbot/create.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/chatbot/createCredential.operation.d.ts +29 -0
- package/dist/nodes/EvolutionApi/resources/chatbot/createCredential.operation.js +44 -0
- package/dist/nodes/EvolutionApi/resources/chatbot/createCredential.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/chatbot/delete.operation.d.ts +3 -0
- package/dist/nodes/EvolutionApi/resources/chatbot/delete.operation.js +19 -0
- package/dist/nodes/EvolutionApi/resources/chatbot/delete.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/chatbot/deleteCredential.operation.d.ts +29 -0
- package/dist/nodes/EvolutionApi/resources/chatbot/deleteCredential.operation.js +30 -0
- package/dist/nodes/EvolutionApi/resources/chatbot/deleteCredential.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/chatbot/fields.d.ts +10 -0
- package/dist/nodes/EvolutionApi/resources/chatbot/fields.js +229 -0
- package/dist/nodes/EvolutionApi/resources/chatbot/fields.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/chatbot/get.operation.d.ts +30 -0
- package/dist/nodes/EvolutionApi/resources/chatbot/get.operation.js +29 -0
- package/dist/nodes/EvolutionApi/resources/chatbot/get.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/chatbot/getCredentials.operation.d.ts +29 -0
- package/dist/nodes/EvolutionApi/resources/chatbot/getCredentials.operation.js +17 -0
- package/dist/nodes/EvolutionApi/resources/chatbot/getCredentials.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/chatbot/getMany.operation.d.ts +29 -0
- package/dist/nodes/EvolutionApi/resources/chatbot/getMany.operation.js +18 -0
- package/dist/nodes/EvolutionApi/resources/chatbot/getMany.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/chatbot/getModels.operation.d.ts +29 -0
- package/dist/nodes/EvolutionApi/resources/chatbot/getModels.operation.js +39 -0
- package/dist/nodes/EvolutionApi/resources/chatbot/getModels.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/chatbot/getSessions.operation.d.ts +29 -0
- package/dist/nodes/EvolutionApi/resources/chatbot/getSessions.operation.js +69 -0
- package/dist/nodes/EvolutionApi/resources/chatbot/getSessions.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/chatbot/getSettings.operation.d.ts +29 -0
- package/dist/nodes/EvolutionApi/resources/chatbot/getSettings.operation.js +17 -0
- package/dist/nodes/EvolutionApi/resources/chatbot/getSettings.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/chatbot/helpers.d.ts +24 -0
- package/dist/nodes/EvolutionApi/resources/chatbot/helpers.js +273 -0
- package/dist/nodes/EvolutionApi/resources/chatbot/helpers.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/chatbot/ignoreJid.operation.d.ts +29 -0
- package/dist/nodes/EvolutionApi/resources/chatbot/ignoreJid.operation.js +35 -0
- package/dist/nodes/EvolutionApi/resources/chatbot/ignoreJid.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/chatbot/index.d.ts +6 -0
- package/dist/nodes/EvolutionApi/resources/chatbot/index.js +210 -0
- package/dist/nodes/EvolutionApi/resources/chatbot/index.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/chatbot/methods.d.ts +2 -0
- package/dist/nodes/EvolutionApi/resources/chatbot/methods.js +58 -0
- package/dist/nodes/EvolutionApi/resources/chatbot/methods.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/chatbot/setSettings.operation.d.ts +33 -0
- package/dist/nodes/EvolutionApi/resources/chatbot/setSettings.operation.js +133 -0
- package/dist/nodes/EvolutionApi/resources/chatbot/setSettings.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/chatbot/start.operation.d.ts +29 -0
- package/dist/nodes/EvolutionApi/resources/chatbot/start.operation.js +112 -0
- package/dist/nodes/EvolutionApi/resources/chatbot/start.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/chatbot/update.operation.d.ts +29 -0
- package/dist/nodes/EvolutionApi/resources/chatbot/update.operation.js +191 -0
- package/dist/nodes/EvolutionApi/resources/chatbot/update.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/chatwoot/get.operation.d.ts +29 -0
- package/dist/nodes/EvolutionApi/resources/chatwoot/get.operation.js +25 -0
- package/dist/nodes/EvolutionApi/resources/chatwoot/get.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/chatwoot/helpers.d.ts +4 -0
- package/dist/nodes/EvolutionApi/resources/chatwoot/helpers.js +26 -0
- package/dist/nodes/EvolutionApi/resources/chatwoot/helpers.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/chatwoot/index.d.ts +5 -0
- package/dist/nodes/EvolutionApi/resources/chatwoot/index.js +70 -0
- package/dist/nodes/EvolutionApi/resources/chatwoot/index.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/chatwoot/set.operation.d.ts +30 -0
- package/dist/nodes/EvolutionApi/resources/chatwoot/set.operation.js +252 -0
- package/dist/nodes/EvolutionApi/resources/chatwoot/set.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/group/acceptInvite.operation.d.ts +29 -0
- package/dist/nodes/EvolutionApi/resources/group/acceptInvite.operation.js +25 -0
- package/dist/nodes/EvolutionApi/resources/group/acceptInvite.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/group/create.operation.d.ts +29 -0
- package/dist/nodes/EvolutionApi/resources/group/create.operation.js +68 -0
- package/dist/nodes/EvolutionApi/resources/group/create.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/group/get.operation.d.ts +29 -0
- package/dist/nodes/EvolutionApi/resources/group/get.operation.js +15 -0
- package/dist/nodes/EvolutionApi/resources/group/get.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/group/getInviteCode.operation.d.ts +29 -0
- package/dist/nodes/EvolutionApi/resources/group/getInviteCode.operation.js +15 -0
- package/dist/nodes/EvolutionApi/resources/group/getInviteCode.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/group/getInviteInfo.operation.d.ts +29 -0
- package/dist/nodes/EvolutionApi/resources/group/getInviteInfo.operation.js +25 -0
- package/dist/nodes/EvolutionApi/resources/group/getInviteInfo.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/group/getMany.operation.d.ts +29 -0
- package/dist/nodes/EvolutionApi/resources/group/getMany.operation.js +72 -0
- package/dist/nodes/EvolutionApi/resources/group/getMany.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/group/getParticipants.operation.d.ts +29 -0
- package/dist/nodes/EvolutionApi/resources/group/getParticipants.operation.js +21 -0
- package/dist/nodes/EvolutionApi/resources/group/getParticipants.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/group/helpers.d.ts +8 -0
- package/dist/nodes/EvolutionApi/resources/group/helpers.js +139 -0
- package/dist/nodes/EvolutionApi/resources/group/helpers.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/group/index.d.ts +7 -0
- package/dist/nodes/EvolutionApi/resources/group/index.js +216 -0
- package/dist/nodes/EvolutionApi/resources/group/index.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/group/leave.operation.d.ts +29 -0
- package/dist/nodes/EvolutionApi/resources/group/leave.operation.js +15 -0
- package/dist/nodes/EvolutionApi/resources/group/leave.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/group/revokeInviteCode.operation.d.ts +29 -0
- package/dist/nodes/EvolutionApi/resources/group/revokeInviteCode.operation.js +20 -0
- package/dist/nodes/EvolutionApi/resources/group/revokeInviteCode.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/group/sendInvite.operation.d.ts +29 -0
- package/dist/nodes/EvolutionApi/resources/group/sendInvite.operation.js +48 -0
- package/dist/nodes/EvolutionApi/resources/group/sendInvite.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/group/toggleEphemeral.operation.d.ts +29 -0
- package/dist/nodes/EvolutionApi/resources/group/toggleEphemeral.operation.js +43 -0
- package/dist/nodes/EvolutionApi/resources/group/toggleEphemeral.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/group/updateDescription.operation.d.ts +29 -0
- package/dist/nodes/EvolutionApi/resources/group/updateDescription.operation.js +34 -0
- package/dist/nodes/EvolutionApi/resources/group/updateDescription.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/group/updateMemberAddMode.operation.d.ts +29 -0
- package/dist/nodes/EvolutionApi/resources/group/updateMemberAddMode.operation.js +47 -0
- package/dist/nodes/EvolutionApi/resources/group/updateMemberAddMode.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/group/updateParticipants.operation.d.ts +29 -0
- package/dist/nodes/EvolutionApi/resources/group/updateParticipants.operation.js +67 -0
- package/dist/nodes/EvolutionApi/resources/group/updateParticipants.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/group/updatePicture.operation.d.ts +29 -0
- package/dist/nodes/EvolutionApi/resources/group/updatePicture.operation.js +99 -0
- package/dist/nodes/EvolutionApi/resources/group/updatePicture.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/group/updateSetting.operation.d.ts +29 -0
- package/dist/nodes/EvolutionApi/resources/group/updateSetting.operation.js +57 -0
- package/dist/nodes/EvolutionApi/resources/group/updateSetting.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/group/updateSubject.operation.d.ts +29 -0
- package/dist/nodes/EvolutionApi/resources/group/updateSubject.operation.js +31 -0
- package/dist/nodes/EvolutionApi/resources/group/updateSubject.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/index.d.ts +6 -0
- package/dist/nodes/EvolutionApi/resources/index.js +144 -0
- package/dist/nodes/EvolutionApi/resources/index.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/instance/connect.operation.d.ts +29 -0
- package/dist/nodes/EvolutionApi/resources/instance/connect.operation.js +40 -0
- package/dist/nodes/EvolutionApi/resources/instance/connect.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/instance/create.operation.d.ts +30 -0
- package/dist/nodes/EvolutionApi/resources/instance/create.operation.js +519 -0
- package/dist/nodes/EvolutionApi/resources/instance/create.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/instance/delete.operation.d.ts +3 -0
- package/dist/nodes/EvolutionApi/resources/instance/delete.operation.js +11 -0
- package/dist/nodes/EvolutionApi/resources/instance/delete.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/instance/getConnectionState.operation.d.ts +3 -0
- package/dist/nodes/EvolutionApi/resources/instance/getConnectionState.operation.js +11 -0
- package/dist/nodes/EvolutionApi/resources/instance/getConnectionState.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/instance/getMany.operation.d.ts +31 -0
- package/dist/nodes/EvolutionApi/resources/instance/getMany.operation.js +149 -0
- package/dist/nodes/EvolutionApi/resources/instance/getMany.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/instance/helpers.d.ts +5 -0
- package/dist/nodes/EvolutionApi/resources/instance/helpers.js +60 -0
- package/dist/nodes/EvolutionApi/resources/instance/helpers.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/instance/index.d.ts +6 -0
- package/dist/nodes/EvolutionApi/resources/instance/index.js +128 -0
- package/dist/nodes/EvolutionApi/resources/instance/index.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/instance/logout.operation.d.ts +3 -0
- package/dist/nodes/EvolutionApi/resources/instance/logout.operation.js +11 -0
- package/dist/nodes/EvolutionApi/resources/instance/logout.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/instance/restart.operation.d.ts +3 -0
- package/dist/nodes/EvolutionApi/resources/instance/restart.operation.js +13 -0
- package/dist/nodes/EvolutionApi/resources/instance/restart.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/instance/setPresence.operation.d.ts +29 -0
- package/dist/nodes/EvolutionApi/resources/instance/setPresence.operation.js +24 -0
- package/dist/nodes/EvolutionApi/resources/instance/setPresence.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/label/addToChat.operation.d.ts +29 -0
- package/dist/nodes/EvolutionApi/resources/label/addToChat.operation.js +11 -0
- package/dist/nodes/EvolutionApi/resources/label/addToChat.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/label/getMany.operation.d.ts +3 -0
- package/dist/nodes/EvolutionApi/resources/label/getMany.operation.js +12 -0
- package/dist/nodes/EvolutionApi/resources/label/getMany.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/label/helpers.d.ts +4 -0
- package/dist/nodes/EvolutionApi/resources/label/helpers.js +69 -0
- package/dist/nodes/EvolutionApi/resources/label/helpers.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/label/index.d.ts +6 -0
- package/dist/nodes/EvolutionApi/resources/label/index.js +88 -0
- package/dist/nodes/EvolutionApi/resources/label/index.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/label/removeFromChat.operation.d.ts +29 -0
- package/dist/nodes/EvolutionApi/resources/label/removeFromChat.operation.js +11 -0
- package/dist/nodes/EvolutionApi/resources/label/removeFromChat.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/message/generateMessageId.operation.d.ts +29 -0
- package/dist/nodes/EvolutionApi/resources/message/generateMessageId.operation.js +21 -0
- package/dist/nodes/EvolutionApi/resources/message/generateMessageId.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/message/helpers.d.ts +39 -0
- package/dist/nodes/EvolutionApi/resources/message/helpers.js +566 -0
- package/dist/nodes/EvolutionApi/resources/message/helpers.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/message/index.d.ts +6 -0
- package/dist/nodes/EvolutionApi/resources/message/index.js +192 -0
- package/dist/nodes/EvolutionApi/resources/message/index.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/message/sendAudio.operation.d.ts +29 -0
- package/dist/nodes/EvolutionApi/resources/message/sendAudio.operation.js +36 -0
- package/dist/nodes/EvolutionApi/resources/message/sendAudio.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/message/sendButtons.operation.d.ts +29 -0
- package/dist/nodes/EvolutionApi/resources/message/sendButtons.operation.js +114 -0
- package/dist/nodes/EvolutionApi/resources/message/sendButtons.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/message/sendCarousel.operation.d.ts +30 -0
- package/dist/nodes/EvolutionApi/resources/message/sendCarousel.operation.js +162 -0
- package/dist/nodes/EvolutionApi/resources/message/sendCarousel.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/message/sendContact.operation.d.ts +29 -0
- package/dist/nodes/EvolutionApi/resources/message/sendContact.operation.js +105 -0
- package/dist/nodes/EvolutionApi/resources/message/sendContact.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/message/sendList.operation.d.ts +30 -0
- package/dist/nodes/EvolutionApi/resources/message/sendList.operation.js +197 -0
- package/dist/nodes/EvolutionApi/resources/message/sendList.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/message/sendLocation.operation.d.ts +29 -0
- package/dist/nodes/EvolutionApi/resources/message/sendLocation.operation.js +70 -0
- package/dist/nodes/EvolutionApi/resources/message/sendLocation.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/message/sendMedia.operation.d.ts +29 -0
- package/dist/nodes/EvolutionApi/resources/message/sendMedia.operation.js +142 -0
- package/dist/nodes/EvolutionApi/resources/message/sendMedia.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/message/sendPoll.operation.d.ts +29 -0
- package/dist/nodes/EvolutionApi/resources/message/sendPoll.operation.js +67 -0
- package/dist/nodes/EvolutionApi/resources/message/sendPoll.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/message/sendPtv.operation.d.ts +29 -0
- package/dist/nodes/EvolutionApi/resources/message/sendPtv.operation.js +22 -0
- package/dist/nodes/EvolutionApi/resources/message/sendPtv.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/message/sendReaction.operation.d.ts +29 -0
- package/dist/nodes/EvolutionApi/resources/message/sendReaction.operation.js +81 -0
- package/dist/nodes/EvolutionApi/resources/message/sendReaction.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/message/sendStatus.operation.d.ts +29 -0
- package/dist/nodes/EvolutionApi/resources/message/sendStatus.operation.js +147 -0
- package/dist/nodes/EvolutionApi/resources/message/sendStatus.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/message/sendSticker.operation.d.ts +29 -0
- package/dist/nodes/EvolutionApi/resources/message/sendSticker.operation.js +41 -0
- package/dist/nodes/EvolutionApi/resources/message/sendSticker.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/message/sendTemplate.operation.d.ts +29 -0
- package/dist/nodes/EvolutionApi/resources/message/sendTemplate.operation.js +92 -0
- package/dist/nodes/EvolutionApi/resources/message/sendTemplate.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/message/sendText.operation.d.ts +29 -0
- package/dist/nodes/EvolutionApi/resources/message/sendText.operation.js +38 -0
- package/dist/nodes/EvolutionApi/resources/message/sendText.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/profile/get.operation.d.ts +29 -0
- package/dist/nodes/EvolutionApi/resources/profile/get.operation.js +27 -0
- package/dist/nodes/EvolutionApi/resources/profile/get.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/profile/getBusinessProfile.operation.d.ts +29 -0
- package/dist/nodes/EvolutionApi/resources/profile/getBusinessProfile.operation.js +24 -0
- package/dist/nodes/EvolutionApi/resources/profile/getBusinessProfile.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/profile/getPicture.operation.d.ts +29 -0
- package/dist/nodes/EvolutionApi/resources/profile/getPicture.operation.js +27 -0
- package/dist/nodes/EvolutionApi/resources/profile/getPicture.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/profile/getPrivacySettings.operation.d.ts +3 -0
- package/dist/nodes/EvolutionApi/resources/profile/getPrivacySettings.operation.js +11 -0
- package/dist/nodes/EvolutionApi/resources/profile/getPrivacySettings.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/profile/index.d.ts +5 -0
- package/dist/nodes/EvolutionApi/resources/profile/index.js +136 -0
- package/dist/nodes/EvolutionApi/resources/profile/index.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/profile/removePicture.operation.d.ts +3 -0
- package/dist/nodes/EvolutionApi/resources/profile/removePicture.operation.js +11 -0
- package/dist/nodes/EvolutionApi/resources/profile/removePicture.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/profile/updateName.operation.d.ts +29 -0
- package/dist/nodes/EvolutionApi/resources/profile/updateName.operation.js +27 -0
- package/dist/nodes/EvolutionApi/resources/profile/updateName.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/profile/updatePicture.operation.d.ts +29 -0
- package/dist/nodes/EvolutionApi/resources/profile/updatePicture.operation.js +86 -0
- package/dist/nodes/EvolutionApi/resources/profile/updatePicture.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/profile/updatePrivacySettings.operation.d.ts +30 -0
- package/dist/nodes/EvolutionApi/resources/profile/updatePrivacySettings.operation.js +133 -0
- package/dist/nodes/EvolutionApi/resources/profile/updatePrivacySettings.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/profile/updateStatus.operation.d.ts +29 -0
- package/dist/nodes/EvolutionApi/resources/profile/updateStatus.operation.js +28 -0
- package/dist/nodes/EvolutionApi/resources/profile/updateStatus.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/proxy/get.operation.d.ts +29 -0
- package/dist/nodes/EvolutionApi/resources/proxy/get.operation.js +25 -0
- package/dist/nodes/EvolutionApi/resources/proxy/get.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/proxy/helpers.d.ts +3 -0
- package/dist/nodes/EvolutionApi/resources/proxy/helpers.js +28 -0
- package/dist/nodes/EvolutionApi/resources/proxy/helpers.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/proxy/index.d.ts +5 -0
- package/dist/nodes/EvolutionApi/resources/proxy/index.js +70 -0
- package/dist/nodes/EvolutionApi/resources/proxy/index.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/proxy/set.operation.d.ts +30 -0
- package/dist/nodes/EvolutionApi/resources/proxy/set.operation.js +137 -0
- package/dist/nodes/EvolutionApi/resources/proxy/set.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/settings/get.operation.d.ts +29 -0
- package/dist/nodes/EvolutionApi/resources/settings/get.operation.js +25 -0
- package/dist/nodes/EvolutionApi/resources/settings/get.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/settings/helpers.d.ts +5 -0
- package/dist/nodes/EvolutionApi/resources/settings/helpers.js +37 -0
- package/dist/nodes/EvolutionApi/resources/settings/helpers.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/settings/index.d.ts +5 -0
- package/dist/nodes/EvolutionApi/resources/settings/index.js +70 -0
- package/dist/nodes/EvolutionApi/resources/settings/index.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/settings/set.operation.d.ts +30 -0
- package/dist/nodes/EvolutionApi/resources/settings/set.operation.js +128 -0
- package/dist/nodes/EvolutionApi/resources/settings/set.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/template/create.operation.d.ts +29 -0
- package/dist/nodes/EvolutionApi/resources/template/create.operation.js +97 -0
- package/dist/nodes/EvolutionApi/resources/template/create.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/template/delete.operation.d.ts +29 -0
- package/dist/nodes/EvolutionApi/resources/template/delete.operation.js +50 -0
- package/dist/nodes/EvolutionApi/resources/template/delete.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/template/getCatalog.operation.d.ts +30 -0
- package/dist/nodes/EvolutionApi/resources/template/getCatalog.operation.js +48 -0
- package/dist/nodes/EvolutionApi/resources/template/getCatalog.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/template/getCollections.operation.d.ts +29 -0
- package/dist/nodes/EvolutionApi/resources/template/getCollections.operation.js +41 -0
- package/dist/nodes/EvolutionApi/resources/template/getCollections.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/template/getMany.operation.d.ts +29 -0
- package/dist/nodes/EvolutionApi/resources/template/getMany.operation.js +109 -0
- package/dist/nodes/EvolutionApi/resources/template/getMany.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/template/helpers.d.ts +3 -0
- package/dist/nodes/EvolutionApi/resources/template/helpers.js +32 -0
- package/dist/nodes/EvolutionApi/resources/template/helpers.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/template/index.d.ts +5 -0
- package/dist/nodes/EvolutionApi/resources/template/index.js +109 -0
- package/dist/nodes/EvolutionApi/resources/template/index.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/template/update.operation.d.ts +29 -0
- package/dist/nodes/EvolutionApi/resources/template/update.operation.js +89 -0
- package/dist/nodes/EvolutionApi/resources/template/update.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/webhook/get.operation.d.ts +29 -0
- package/dist/nodes/EvolutionApi/resources/webhook/get.operation.js +25 -0
- package/dist/nodes/EvolutionApi/resources/webhook/get.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/webhook/getTransport.operation.d.ts +30 -0
- package/dist/nodes/EvolutionApi/resources/webhook/getTransport.operation.js +49 -0
- package/dist/nodes/EvolutionApi/resources/webhook/getTransport.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/webhook/helpers.d.ts +17 -0
- package/dist/nodes/EvolutionApi/resources/webhook/helpers.js +144 -0
- package/dist/nodes/EvolutionApi/resources/webhook/helpers.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/webhook/index.d.ts +5 -0
- package/dist/nodes/EvolutionApi/resources/webhook/index.js +91 -0
- package/dist/nodes/EvolutionApi/resources/webhook/index.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/webhook/set.operation.d.ts +29 -0
- package/dist/nodes/EvolutionApi/resources/webhook/set.operation.js +174 -0
- package/dist/nodes/EvolutionApi/resources/webhook/set.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/resources/webhook/setTransport.operation.d.ts +29 -0
- package/dist/nodes/EvolutionApi/resources/webhook/setTransport.operation.js +159 -0
- package/dist/nodes/EvolutionApi/resources/webhook/setTransport.operation.js.map +1 -0
- package/dist/nodes/EvolutionApi/trigger/auth.d.ts +26 -0
- package/dist/nodes/EvolutionApi/trigger/auth.js +96 -0
- package/dist/nodes/EvolutionApi/trigger/auth.js.map +1 -0
- package/dist/nodes/EvolutionApi/trigger/constants.d.ts +10 -0
- package/dist/nodes/EvolutionApi/trigger/constants.js +154 -0
- package/dist/nodes/EvolutionApi/trigger/constants.js.map +1 -0
- package/dist/nodes/EvolutionApi/trigger/dedupe.d.ts +5 -0
- package/dist/nodes/EvolutionApi/trigger/dedupe.js +87 -0
- package/dist/nodes/EvolutionApi/trigger/dedupe.js.map +1 -0
- package/dist/nodes/EvolutionApi/trigger/payload.d.ts +48 -0
- package/dist/nodes/EvolutionApi/trigger/payload.js +265 -0
- package/dist/nodes/EvolutionApi/trigger/payload.js.map +1 -0
- package/dist/nodes/EvolutionApi/trigger/registration.d.ts +36 -0
- package/dist/nodes/EvolutionApi/trigger/registration.js +156 -0
- package/dist/nodes/EvolutionApi/trigger/registration.js.map +1 -0
- package/dist/nodes/EvolutionApi/types.d.ts +44 -0
- package/dist/nodes/EvolutionApi/types.js +3 -0
- package/dist/nodes/EvolutionApi/types.js.map +1 -0
- package/package.json +83 -0
|
@@ -0,0 +1,681 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.JID_SUFFIXES = exports.MULTIPART_ROUTES = exports.CREDENTIAL_TYPE = void 0;
|
|
4
|
+
exports.setRetryPolicy = setRetryPolicy;
|
|
5
|
+
exports.resetRetryPolicy = resetRetryPolicy;
|
|
6
|
+
exports.getRetryPolicy = getRetryPolicy;
|
|
7
|
+
exports.isIdempotentMethod = isIdempotentMethod;
|
|
8
|
+
exports.isSafeMethod = isSafeMethod;
|
|
9
|
+
exports.shouldRetry = shouldRetry;
|
|
10
|
+
exports.parseRetryAfter = parseRetryAfter;
|
|
11
|
+
exports.computeRetryDelay = computeRetryDelay;
|
|
12
|
+
exports.normalizeBaseUrl = normalizeBaseUrl;
|
|
13
|
+
exports.isPlainObject = isPlainObject;
|
|
14
|
+
exports.compactObject = compactObject;
|
|
15
|
+
exports.toArray = toArray;
|
|
16
|
+
exports.parseJsonParameter = parseJsonParameter;
|
|
17
|
+
exports.isLicenseRequiredError = isLicenseRequiredError;
|
|
18
|
+
exports.extractEvolutionMessages = extractEvolutionMessages;
|
|
19
|
+
exports.buildEvolutionApiError = buildEvolutionApiError;
|
|
20
|
+
exports.assertNoSoftError = assertNoSoftError;
|
|
21
|
+
exports.extractHttpErrorDetails = extractHttpErrorDetails;
|
|
22
|
+
exports.evolutionApiRawRequest = evolutionApiRawRequest;
|
|
23
|
+
exports.evolutionApiRequest = evolutionApiRequest;
|
|
24
|
+
exports.extractResourceLocatorValue = extractResourceLocatorValue;
|
|
25
|
+
exports.encodePathSegment = encodePathSegment;
|
|
26
|
+
exports.resolveInstanceNameFromValue = resolveInstanceNameFromValue;
|
|
27
|
+
exports.resolveInstanceName = resolveInstanceName;
|
|
28
|
+
exports.searchInstances = searchInstances;
|
|
29
|
+
exports.normalizeNumber = normalizeNumber;
|
|
30
|
+
exports.toJid = toJid;
|
|
31
|
+
exports.normalizeNumberList = normalizeNumberList;
|
|
32
|
+
exports.isGroupJid = isGroupJid;
|
|
33
|
+
exports.isLidJid = isLidJid;
|
|
34
|
+
exports.parseDataUri = parseDataUri;
|
|
35
|
+
exports.cleanBase64 = cleanBase64;
|
|
36
|
+
exports.resolveMedia = resolveMedia;
|
|
37
|
+
exports.isMultipartSafe = isMultipartSafe;
|
|
38
|
+
exports.buildMultipartBody = buildMultipartBody;
|
|
39
|
+
exports.buildMediaRequestBody = buildMediaRequestBody;
|
|
40
|
+
exports.base64ToBinary = base64ToBinary;
|
|
41
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
42
|
+
exports.CREDENTIAL_TYPE = 'evolutionWhatsAppApi';
|
|
43
|
+
exports.MULTIPART_ROUTES = [
|
|
44
|
+
'sendMedia',
|
|
45
|
+
'sendPtv',
|
|
46
|
+
'sendWhatsAppAudio',
|
|
47
|
+
'sendStatus',
|
|
48
|
+
'sendSticker',
|
|
49
|
+
];
|
|
50
|
+
exports.JID_SUFFIXES = [
|
|
51
|
+
'@s.whatsapp.net',
|
|
52
|
+
'@g.us',
|
|
53
|
+
'@lid',
|
|
54
|
+
'@broadcast',
|
|
55
|
+
'@newsletter',
|
|
56
|
+
'@c.us',
|
|
57
|
+
];
|
|
58
|
+
const DEFAULT_RETRY_POLICY = {
|
|
59
|
+
maxRetries: 3,
|
|
60
|
+
baseDelayMs: 1000,
|
|
61
|
+
maxDelayMs: 15000,
|
|
62
|
+
sleep: async (ms) => await (0, n8n_workflow_1.sleep)(ms),
|
|
63
|
+
};
|
|
64
|
+
let retryPolicy = { ...DEFAULT_RETRY_POLICY };
|
|
65
|
+
function setRetryPolicy(overrides) {
|
|
66
|
+
retryPolicy = { ...retryPolicy, ...overrides };
|
|
67
|
+
}
|
|
68
|
+
function resetRetryPolicy() {
|
|
69
|
+
retryPolicy = { ...DEFAULT_RETRY_POLICY };
|
|
70
|
+
}
|
|
71
|
+
function getRetryPolicy() {
|
|
72
|
+
return retryPolicy;
|
|
73
|
+
}
|
|
74
|
+
const IDEMPOTENT_METHODS = ['GET', 'HEAD', 'PUT', 'DELETE'];
|
|
75
|
+
const SAFE_METHODS = ['GET', 'HEAD'];
|
|
76
|
+
function isIdempotentMethod(method) {
|
|
77
|
+
return IDEMPOTENT_METHODS.includes(method.toUpperCase());
|
|
78
|
+
}
|
|
79
|
+
function isSafeMethod(method) {
|
|
80
|
+
return SAFE_METHODS.includes(method.toUpperCase());
|
|
81
|
+
}
|
|
82
|
+
function shouldRetry(statusCode, method, body, idempotent) {
|
|
83
|
+
if (statusCode === 429)
|
|
84
|
+
return true;
|
|
85
|
+
if (statusCode !== 502 && statusCode !== 503 && statusCode !== 504)
|
|
86
|
+
return false;
|
|
87
|
+
if (isLicenseRequiredError(statusCode, body))
|
|
88
|
+
return false;
|
|
89
|
+
if (idempotent !== undefined)
|
|
90
|
+
return idempotent;
|
|
91
|
+
return statusCode === 504 ? isSafeMethod(method) : isIdempotentMethod(method);
|
|
92
|
+
}
|
|
93
|
+
function parseRetryAfter(value, now = Date.now()) {
|
|
94
|
+
if (value === undefined || value === null || value === '')
|
|
95
|
+
return undefined;
|
|
96
|
+
const raw = Array.isArray(value) ? value[0] : value;
|
|
97
|
+
const text = String(raw).trim();
|
|
98
|
+
if (/^\d+(\.\d+)?$/.test(text))
|
|
99
|
+
return Math.round(parseFloat(text) * 1000);
|
|
100
|
+
const date = Date.parse(text);
|
|
101
|
+
if (!Number.isNaN(date))
|
|
102
|
+
return Math.max(0, date - now);
|
|
103
|
+
return undefined;
|
|
104
|
+
}
|
|
105
|
+
function computeRetryDelay(attempt, retryAfterMs, policy = retryPolicy) {
|
|
106
|
+
const delay = retryAfterMs !== null && retryAfterMs !== void 0 ? retryAfterMs : policy.baseDelayMs * Math.pow(2, attempt);
|
|
107
|
+
return Math.min(Math.max(0, delay), policy.maxDelayMs);
|
|
108
|
+
}
|
|
109
|
+
function normalizeBaseUrl(baseUrl) {
|
|
110
|
+
const trimmed = String(baseUrl !== null && baseUrl !== void 0 ? baseUrl : '')
|
|
111
|
+
.trim()
|
|
112
|
+
.replace(/\/+$/, '');
|
|
113
|
+
if (!/^https?:\/\//i.test(trimmed)) {
|
|
114
|
+
throw new Error('Base URL must start with http:// or https:// (e.g. https://evolution.example.com)');
|
|
115
|
+
}
|
|
116
|
+
return trimmed;
|
|
117
|
+
}
|
|
118
|
+
function isPlainObject(value) {
|
|
119
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
120
|
+
}
|
|
121
|
+
function compactObject(obj) {
|
|
122
|
+
const result = {};
|
|
123
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
124
|
+
if (value === undefined || value === null || value === '')
|
|
125
|
+
continue;
|
|
126
|
+
result[key] = isPlainObject(value) ? compactObject(value) : value;
|
|
127
|
+
}
|
|
128
|
+
return result;
|
|
129
|
+
}
|
|
130
|
+
function toArray(value) {
|
|
131
|
+
if (value === undefined || value === null || value === '')
|
|
132
|
+
return [];
|
|
133
|
+
if (Array.isArray(value)) {
|
|
134
|
+
return value.map((entry) => (isPlainObject(entry) ? entry : { value: entry }));
|
|
135
|
+
}
|
|
136
|
+
if (isPlainObject(value))
|
|
137
|
+
return [value];
|
|
138
|
+
return [{ value: value }];
|
|
139
|
+
}
|
|
140
|
+
function parseJsonParameter(value, fieldName) {
|
|
141
|
+
if (typeof value !== 'string')
|
|
142
|
+
return value;
|
|
143
|
+
if (value.trim() === '')
|
|
144
|
+
return undefined;
|
|
145
|
+
let parsed;
|
|
146
|
+
let valid = true;
|
|
147
|
+
try {
|
|
148
|
+
parsed = JSON.parse(value);
|
|
149
|
+
}
|
|
150
|
+
catch {
|
|
151
|
+
valid = false;
|
|
152
|
+
}
|
|
153
|
+
if (!valid)
|
|
154
|
+
throw new Error(`Invalid JSON in "${fieldName}": check the JSON syntax`);
|
|
155
|
+
return parsed;
|
|
156
|
+
}
|
|
157
|
+
function safeStringify(value, maxLength = 300) {
|
|
158
|
+
let text;
|
|
159
|
+
try {
|
|
160
|
+
text = JSON.stringify(value);
|
|
161
|
+
}
|
|
162
|
+
catch {
|
|
163
|
+
text = String(value);
|
|
164
|
+
}
|
|
165
|
+
return text.length > maxLength ? `${text.substring(0, maxLength)}…` : text;
|
|
166
|
+
}
|
|
167
|
+
function isLicenseRequiredError(statusCode, body) {
|
|
168
|
+
return statusCode === 503 && isPlainObject(body) && body.code === 'LICENSE_REQUIRED';
|
|
169
|
+
}
|
|
170
|
+
function extractEvolutionMessages(body) {
|
|
171
|
+
const messages = [];
|
|
172
|
+
collectMessages(body, messages, 0);
|
|
173
|
+
return [...new Set(messages)];
|
|
174
|
+
}
|
|
175
|
+
function collectMessages(value, out, depth) {
|
|
176
|
+
var _a, _b;
|
|
177
|
+
if (value === undefined || value === null || depth > 6)
|
|
178
|
+
return;
|
|
179
|
+
if (typeof value === 'string') {
|
|
180
|
+
const text = value.trim();
|
|
181
|
+
if (text && text !== '[object Object]')
|
|
182
|
+
out.push(text);
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
if (typeof value === 'number' || typeof value === 'boolean') {
|
|
186
|
+
if (depth > 0)
|
|
187
|
+
out.push(String(value));
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
if (Array.isArray(value)) {
|
|
191
|
+
for (const entry of value)
|
|
192
|
+
collectMessages(entry, out, depth + 1);
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
if (!isPlainObject(value))
|
|
196
|
+
return;
|
|
197
|
+
if (depth > 0 && value.exists === false && (value.number || value.jid)) {
|
|
198
|
+
const who = String((_a = value.number) !== null && _a !== void 0 ? _a : value.jid);
|
|
199
|
+
const jid = value.jid && value.jid !== value.number ? ` (${String(value.jid)})` : '';
|
|
200
|
+
out.push(`The number ${who}${jid} is not on WhatsApp`);
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
if (typeof value.property === 'string' && value.message !== undefined) {
|
|
204
|
+
const inner = [];
|
|
205
|
+
collectMessages(value.message, inner, depth + 1);
|
|
206
|
+
out.push(inner.length ? `${value.property}: ${inner.join(', ')}` : value.property);
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
const start = out.length;
|
|
210
|
+
const response = value.response;
|
|
211
|
+
if (isPlainObject(response) && response.message !== undefined) {
|
|
212
|
+
collectMessages(response.message, out, depth + 1);
|
|
213
|
+
}
|
|
214
|
+
else if (value.message !== undefined) {
|
|
215
|
+
collectMessages(value.message, out, depth + 1);
|
|
216
|
+
}
|
|
217
|
+
const details = value.details;
|
|
218
|
+
if (isPlainObject(details)) {
|
|
219
|
+
const metaMessage = (_b = details.whatsapp_error) !== null && _b !== void 0 ? _b : details.error_user_msg;
|
|
220
|
+
if (typeof metaMessage === 'string' && metaMessage !== value.message) {
|
|
221
|
+
collectMessages(metaMessage, out, depth + 1);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
if (out.length === start) {
|
|
225
|
+
if (depth === 0) {
|
|
226
|
+
if (typeof value.error === 'string')
|
|
227
|
+
out.push(value.error);
|
|
228
|
+
}
|
|
229
|
+
else {
|
|
230
|
+
out.push(safeStringify(value));
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
const STATUS_TEXT = {
|
|
235
|
+
400: {
|
|
236
|
+
title: 'Bad request',
|
|
237
|
+
hint: 'Evolution API rejected the request parameters. Check the fields mentioned in the message.',
|
|
238
|
+
},
|
|
239
|
+
401: {
|
|
240
|
+
title: 'Unauthorized',
|
|
241
|
+
hint: 'The API key was rejected. Use the global API key (AUTHENTICATION_API_KEY) or the token of this instance in the Evolution API credential.',
|
|
242
|
+
},
|
|
243
|
+
403: {
|
|
244
|
+
title: 'Forbidden',
|
|
245
|
+
hint: 'The request is not allowed (for example the instance name is already in use, or the operation needs the global API key).',
|
|
246
|
+
},
|
|
247
|
+
404: {
|
|
248
|
+
title: 'Not found',
|
|
249
|
+
hint: 'Check the instance name and the IDs you sent. A message like "Cannot POST /..." means this Evolution API version does not have the endpoint (features marked "Requires Evolution API 2.4+" need 2.4 or later).',
|
|
250
|
+
},
|
|
251
|
+
413: {
|
|
252
|
+
title: 'Payload too large',
|
|
253
|
+
hint: 'The request body is too large for Evolution API or its reverse proxy. Send media as a URL or reduce the file size.',
|
|
254
|
+
},
|
|
255
|
+
429: {
|
|
256
|
+
title: 'Too many requests',
|
|
257
|
+
hint: 'Evolution API (or a proxy in front of it) is rate limiting. The node already retried with backoff; reduce the batch size or add a Wait node.',
|
|
258
|
+
},
|
|
259
|
+
500: {
|
|
260
|
+
title: 'Evolution API internal error',
|
|
261
|
+
hint: 'The server failed to process the request. WhatsApp-side problems (instance not connected, invalid number) often surface as 500; check the Evolution API logs.',
|
|
262
|
+
},
|
|
263
|
+
502: {
|
|
264
|
+
title: 'Bad gateway',
|
|
265
|
+
hint: 'The reverse proxy in front of Evolution API could not reach it. Check that the Evolution API container is running.',
|
|
266
|
+
},
|
|
267
|
+
503: {
|
|
268
|
+
title: 'Evolution API unavailable',
|
|
269
|
+
hint: 'The server is temporarily unavailable. Idempotent requests were retried automatically.',
|
|
270
|
+
},
|
|
271
|
+
504: {
|
|
272
|
+
title: 'Gateway timeout',
|
|
273
|
+
hint: 'Evolution API did not answer in time and may still have processed the request. Only read requests are retried automatically; check the result before repeating a write.',
|
|
274
|
+
},
|
|
275
|
+
};
|
|
276
|
+
function buildEvolutionApiError(node, details) {
|
|
277
|
+
var _a;
|
|
278
|
+
const { statusCode, body, method, endpoint, baseUrl, itemIndex } = details;
|
|
279
|
+
const errorResponse = isPlainObject(body)
|
|
280
|
+
? body
|
|
281
|
+
: { response: body === undefined || body === null ? '' : safeStringify(body, 1000) };
|
|
282
|
+
const where = method && endpoint ? ` (${method} ${endpoint})` : '';
|
|
283
|
+
if (isLicenseRequiredError(statusCode, body)) {
|
|
284
|
+
const license = body;
|
|
285
|
+
const registerUrl = license.register_url || (baseUrl ? `${baseUrl}/manager/login` : '<Base URL>/manager/login');
|
|
286
|
+
const statusUrl = baseUrl ? `${baseUrl}/license/status` : '<Base URL>/license/status';
|
|
287
|
+
const docs = license.docs_url ? ` Docs: ${license.docs_url}` : '';
|
|
288
|
+
return new n8n_workflow_1.NodeApiError(node, errorResponse, {
|
|
289
|
+
message: `Evolution API license not activated (503 LICENSE_REQUIRED). Activate it at ${registerUrl}`,
|
|
290
|
+
description: `Evolution API 2.4+ blocks every API route until the server license is activated. Open ${registerUrl} to activate it (or set AUTHENTICATION_API_KEY to a valid licensing key and restart the server), then confirm with GET ${statusUrl}. Retrying will not help until then.${docs}${where}`,
|
|
291
|
+
httpCode: '503',
|
|
292
|
+
itemIndex,
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
const text = (_a = STATUS_TEXT[statusCode]) !== null && _a !== void 0 ? _a : {
|
|
296
|
+
title: statusCode >= 500 ? 'Evolution API server error' : 'Evolution API request failed',
|
|
297
|
+
hint: 'Check the request parameters and the Evolution API logs.',
|
|
298
|
+
};
|
|
299
|
+
const apiMessages = extractEvolutionMessages(body);
|
|
300
|
+
const detail = apiMessages.join('; ');
|
|
301
|
+
const shortDetail = detail.length > 400 ? `${detail.substring(0, 400)}…` : detail;
|
|
302
|
+
return new n8n_workflow_1.NodeApiError(node, errorResponse, {
|
|
303
|
+
message: shortDetail ? `${text.title}: ${shortDetail}` : `${text.title} (HTTP ${statusCode})`,
|
|
304
|
+
description: `${text.hint}${where}`,
|
|
305
|
+
httpCode: String(statusCode),
|
|
306
|
+
itemIndex,
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
function assertNoSoftError(node, response, itemIndex, fallbackMessage) {
|
|
310
|
+
if (!isPlainObject(response) || response.error !== true)
|
|
311
|
+
return;
|
|
312
|
+
const detail = extractEvolutionMessages(response).join('; ');
|
|
313
|
+
throw new n8n_workflow_1.NodeApiError(node, response, {
|
|
314
|
+
message: detail ? `Evolution API reported an error: ${detail}` : fallbackMessage,
|
|
315
|
+
description: 'Evolution API answered HTTP 200 but flagged the result as an error.',
|
|
316
|
+
itemIndex,
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
function extractHttpErrorDetails(error) {
|
|
320
|
+
var _a, _b, _c, _d, _e, _f;
|
|
321
|
+
if (!isPlainObject(error) && !(error instanceof Error))
|
|
322
|
+
return {};
|
|
323
|
+
const err = error;
|
|
324
|
+
const response = isPlainObject(err.response) ? err.response : undefined;
|
|
325
|
+
const cause = isPlainObject(err.cause) ? err.cause : undefined;
|
|
326
|
+
const causeResponse = cause && isPlainObject(cause.response) ? cause.response : undefined;
|
|
327
|
+
const context = isPlainObject(err.context) ? err.context : undefined;
|
|
328
|
+
const candidates = [
|
|
329
|
+
response === null || response === void 0 ? void 0 : response.status,
|
|
330
|
+
response === null || response === void 0 ? void 0 : response.statusCode,
|
|
331
|
+
err.statusCode,
|
|
332
|
+
err.httpCode,
|
|
333
|
+
causeResponse === null || causeResponse === void 0 ? void 0 : causeResponse.status,
|
|
334
|
+
cause === null || cause === void 0 ? void 0 : cause.statusCode,
|
|
335
|
+
];
|
|
336
|
+
let statusCode;
|
|
337
|
+
for (const candidate of candidates) {
|
|
338
|
+
const parsed = Number(candidate);
|
|
339
|
+
if (candidate !== undefined &&
|
|
340
|
+
candidate !== null &&
|
|
341
|
+
Number.isInteger(parsed) &&
|
|
342
|
+
parsed >= 100) {
|
|
343
|
+
statusCode = parsed;
|
|
344
|
+
break;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
if (statusCode === undefined)
|
|
348
|
+
return {};
|
|
349
|
+
const body = (_e = (_d = (_c = (_b = (_a = response === null || response === void 0 ? void 0 : response.data) !== null && _a !== void 0 ? _a : response === null || response === void 0 ? void 0 : response.body) !== null && _b !== void 0 ? _b : causeResponse === null || causeResponse === void 0 ? void 0 : causeResponse.data) !== null && _c !== void 0 ? _c : context === null || context === void 0 ? void 0 : context.data) !== null && _d !== void 0 ? _d : err.errorResponse) !== null && _e !== void 0 ? _e : err.error;
|
|
350
|
+
const headers = (_f = (isPlainObject(response === null || response === void 0 ? void 0 : response.headers) ? response === null || response === void 0 ? void 0 : response.headers : undefined)) !== null && _f !== void 0 ? _f : (isPlainObject(causeResponse === null || causeResponse === void 0 ? void 0 : causeResponse.headers) ? causeResponse === null || causeResponse === void 0 ? void 0 : causeResponse.headers : undefined);
|
|
351
|
+
return { statusCode, body, headers: headers };
|
|
352
|
+
}
|
|
353
|
+
async function getBaseUrl(itemIndex) {
|
|
354
|
+
const credentials = await this.getCredentials(exports.CREDENTIAL_TYPE);
|
|
355
|
+
try {
|
|
356
|
+
return normalizeBaseUrl(credentials.baseUrl);
|
|
357
|
+
}
|
|
358
|
+
catch (error) {
|
|
359
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), error.message, { itemIndex });
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
function isFormData(value) {
|
|
363
|
+
return typeof FormData !== 'undefined' && value instanceof FormData;
|
|
364
|
+
}
|
|
365
|
+
function unwrapFullResponse(response) {
|
|
366
|
+
if (isPlainObject(response) && typeof response.statusCode === 'number' && 'body' in response) {
|
|
367
|
+
return {
|
|
368
|
+
statusCode: response.statusCode,
|
|
369
|
+
headers: isPlainObject(response.headers) ? response.headers : {},
|
|
370
|
+
body: response.body,
|
|
371
|
+
};
|
|
372
|
+
}
|
|
373
|
+
return { statusCode: 200, headers: {}, body: response };
|
|
374
|
+
}
|
|
375
|
+
function getHeader(headers, name) {
|
|
376
|
+
const key = Object.keys(headers).find((header) => header.toLowerCase() === name.toLowerCase());
|
|
377
|
+
return key ? headers[key] : undefined;
|
|
378
|
+
}
|
|
379
|
+
async function evolutionApiRawRequest(method, endpoint, body = {}, qs = {}, options = {}) {
|
|
380
|
+
var _a, _b, _c;
|
|
381
|
+
const baseUrl = await getBaseUrl.call(this, options.itemIndex);
|
|
382
|
+
const path = endpoint.startsWith('/') ? endpoint : `/${endpoint}`;
|
|
383
|
+
const requestOptions = {
|
|
384
|
+
method,
|
|
385
|
+
url: `${baseUrl}${path}`,
|
|
386
|
+
json: true,
|
|
387
|
+
returnFullResponse: true,
|
|
388
|
+
ignoreHttpStatusErrors: true,
|
|
389
|
+
headers: { Accept: 'application/json', ...((_a = options.headers) !== null && _a !== void 0 ? _a : {}) },
|
|
390
|
+
};
|
|
391
|
+
const cleanQs = compactObject(qs);
|
|
392
|
+
if (Object.keys(cleanQs).length > 0)
|
|
393
|
+
requestOptions.qs = cleanQs;
|
|
394
|
+
if (isFormData(body)) {
|
|
395
|
+
requestOptions.body = body;
|
|
396
|
+
}
|
|
397
|
+
else if (method !== 'GET' && method !== 'HEAD') {
|
|
398
|
+
const hasBody = Array.isArray(body) ? body.length > 0 : Object.keys(body).length > 0;
|
|
399
|
+
if (hasBody) {
|
|
400
|
+
requestOptions.body = body;
|
|
401
|
+
requestOptions.headers = { ...requestOptions.headers, 'Content-Type': 'application/json' };
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
if (options.timeout !== undefined)
|
|
405
|
+
requestOptions.timeout = options.timeout;
|
|
406
|
+
const policy = retryPolicy;
|
|
407
|
+
const maxRetries = Math.max(0, (_b = options.maxRetries) !== null && _b !== void 0 ? _b : policy.maxRetries);
|
|
408
|
+
for (let attempt = 0;; attempt++) {
|
|
409
|
+
let result;
|
|
410
|
+
try {
|
|
411
|
+
const response = await this.helpers.httpRequestWithAuthentication.call(this, exports.CREDENTIAL_TYPE, requestOptions);
|
|
412
|
+
result = unwrapFullResponse(response);
|
|
413
|
+
}
|
|
414
|
+
catch (error) {
|
|
415
|
+
const extracted = extractHttpErrorDetails(error);
|
|
416
|
+
if (extracted.statusCode === undefined) {
|
|
417
|
+
const apiError = new n8n_workflow_1.NodeApiError(this.getNode(), error, {
|
|
418
|
+
itemIndex: options.itemIndex,
|
|
419
|
+
});
|
|
420
|
+
if (options.itemIndex !== undefined)
|
|
421
|
+
apiError.context.itemIndex = options.itemIndex;
|
|
422
|
+
throw apiError;
|
|
423
|
+
}
|
|
424
|
+
result = {
|
|
425
|
+
statusCode: extracted.statusCode,
|
|
426
|
+
headers: (_c = extracted.headers) !== null && _c !== void 0 ? _c : {},
|
|
427
|
+
body: extracted.body,
|
|
428
|
+
};
|
|
429
|
+
}
|
|
430
|
+
if (result.statusCode < 400)
|
|
431
|
+
return result;
|
|
432
|
+
if (attempt < maxRetries &&
|
|
433
|
+
shouldRetry(result.statusCode, method, result.body, options.idempotent)) {
|
|
434
|
+
const retryAfter = parseRetryAfter(getHeader(result.headers, 'retry-after'));
|
|
435
|
+
await policy.sleep(computeRetryDelay(attempt, retryAfter, policy));
|
|
436
|
+
continue;
|
|
437
|
+
}
|
|
438
|
+
throw buildEvolutionApiError(this.getNode(), {
|
|
439
|
+
statusCode: result.statusCode,
|
|
440
|
+
body: result.body,
|
|
441
|
+
method,
|
|
442
|
+
endpoint: path,
|
|
443
|
+
baseUrl,
|
|
444
|
+
itemIndex: options.itemIndex,
|
|
445
|
+
});
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
async function evolutionApiRequest(method, endpoint, body = {}, qs = {}, options = {}) {
|
|
449
|
+
const response = await evolutionApiRawRequest.call(this, method, endpoint, body, qs, options);
|
|
450
|
+
const data = response.body;
|
|
451
|
+
if (data === undefined || data === null || data === '')
|
|
452
|
+
return {};
|
|
453
|
+
if (Array.isArray(data))
|
|
454
|
+
return data;
|
|
455
|
+
if (isPlainObject(data))
|
|
456
|
+
return data;
|
|
457
|
+
return { result: data };
|
|
458
|
+
}
|
|
459
|
+
function extractResourceLocatorValue(value) {
|
|
460
|
+
var _a;
|
|
461
|
+
if (value === undefined || value === null)
|
|
462
|
+
return '';
|
|
463
|
+
if (isPlainObject(value))
|
|
464
|
+
return String((_a = value.value) !== null && _a !== void 0 ? _a : '').trim();
|
|
465
|
+
return String(value).trim();
|
|
466
|
+
}
|
|
467
|
+
const UNSAFE_PATH_SEGMENTS = ['', '.', '..'];
|
|
468
|
+
function encodePathSegment(value, label = 'ID') {
|
|
469
|
+
const text = value === undefined || value === null ? '' : String(value);
|
|
470
|
+
if (UNSAFE_PATH_SEGMENTS.includes(text)) {
|
|
471
|
+
throw new Error(text ? `${label} "${text}" is not allowed in a URL path` : `${label} is required`);
|
|
472
|
+
}
|
|
473
|
+
return encodeURIComponent(text);
|
|
474
|
+
}
|
|
475
|
+
async function resolveInstanceNameFromValue(value, options = {}) {
|
|
476
|
+
var _a;
|
|
477
|
+
let name = extractResourceLocatorValue(value);
|
|
478
|
+
if (!name && options.allowDefault === false) {
|
|
479
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Instance Name is required for this operation', {
|
|
480
|
+
itemIndex: options.itemIndex,
|
|
481
|
+
description: 'Select an explicit instance. This operation does not use the credential default.',
|
|
482
|
+
});
|
|
483
|
+
}
|
|
484
|
+
if (!name) {
|
|
485
|
+
const credentials = await this.getCredentials(exports.CREDENTIAL_TYPE);
|
|
486
|
+
name = String((_a = credentials.defaultInstance) !== null && _a !== void 0 ? _a : '').trim();
|
|
487
|
+
}
|
|
488
|
+
if (!name) {
|
|
489
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'No instance selected', {
|
|
490
|
+
itemIndex: options.itemIndex,
|
|
491
|
+
description: 'Choose an instance in the "Instance Name" field or set "Default Instance Name" in the Evolution API credential.',
|
|
492
|
+
});
|
|
493
|
+
}
|
|
494
|
+
if (UNSAFE_PATH_SEGMENTS.includes(name)) {
|
|
495
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Invalid instance name "${name}"`, {
|
|
496
|
+
itemIndex: options.itemIndex,
|
|
497
|
+
description: '"." and ".." cannot be used as instance names in a URL.',
|
|
498
|
+
});
|
|
499
|
+
}
|
|
500
|
+
return options.encode === false ? name : encodeURIComponent(name);
|
|
501
|
+
}
|
|
502
|
+
async function resolveInstanceName(itemIndex, options = {}) {
|
|
503
|
+
var _a;
|
|
504
|
+
const parameterName = (_a = options.parameterName) !== null && _a !== void 0 ? _a : 'instanceName';
|
|
505
|
+
const value = this.getNodeParameter(parameterName, itemIndex, '', { extractValue: true });
|
|
506
|
+
if (!extractResourceLocatorValue(value)) {
|
|
507
|
+
const raw = this.getNodeParameter(parameterName, itemIndex, '', { rawExpressions: true });
|
|
508
|
+
if (extractResourceLocatorValue(raw).startsWith('=')) {
|
|
509
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Instance Name expression resolved to an empty value', {
|
|
510
|
+
itemIndex,
|
|
511
|
+
description: `Provide an instance for item ${itemIndex + 1}. Empty expressions do not use the credential default.`,
|
|
512
|
+
});
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
return await resolveInstanceNameFromValue.call(this, value, {
|
|
516
|
+
itemIndex,
|
|
517
|
+
encode: options.encode,
|
|
518
|
+
allowDefault: options.allowDefault,
|
|
519
|
+
});
|
|
520
|
+
}
|
|
521
|
+
async function searchInstances(filter) {
|
|
522
|
+
const response = await evolutionApiRequest.call(this, 'GET', '/instance/fetchInstances');
|
|
523
|
+
const needle = (filter !== null && filter !== void 0 ? filter : '').trim().toLowerCase();
|
|
524
|
+
const results = toArray(response)
|
|
525
|
+
.map((instance) => {
|
|
526
|
+
var _a, _b, _c;
|
|
527
|
+
const legacy = isPlainObject(instance.instance) ? instance.instance : {};
|
|
528
|
+
const name = String((_b = (_a = instance.name) !== null && _a !== void 0 ? _a : legacy.instanceName) !== null && _b !== void 0 ? _b : '').trim();
|
|
529
|
+
const status = (_c = instance.connectionStatus) !== null && _c !== void 0 ? _c : legacy.status;
|
|
530
|
+
return { name, status: typeof status === 'string' ? status : '' };
|
|
531
|
+
})
|
|
532
|
+
.filter((instance) => instance.name && (!needle || instance.name.toLowerCase().includes(needle)))
|
|
533
|
+
.sort((a, b) => a.name.localeCompare(b.name))
|
|
534
|
+
.map((instance) => ({
|
|
535
|
+
name: instance.status ? `${instance.name} (${instance.status})` : instance.name,
|
|
536
|
+
value: instance.name,
|
|
537
|
+
}));
|
|
538
|
+
return { results };
|
|
539
|
+
}
|
|
540
|
+
function normalizeNumber(value) {
|
|
541
|
+
const text = String(value !== null && value !== void 0 ? value : '').trim();
|
|
542
|
+
if (!text)
|
|
543
|
+
return '';
|
|
544
|
+
if (text.includes('@'))
|
|
545
|
+
return text;
|
|
546
|
+
if (/^\d+-\d+$/.test(text) && text.length >= 24)
|
|
547
|
+
return text;
|
|
548
|
+
const digits = text.replace(/[\s+().-]/g, '');
|
|
549
|
+
return /^\d+$/.test(digits) ? digits : text;
|
|
550
|
+
}
|
|
551
|
+
function toJid(value) {
|
|
552
|
+
const normalized = normalizeNumber(value);
|
|
553
|
+
if (!normalized || normalized.includes('@'))
|
|
554
|
+
return normalized;
|
|
555
|
+
if (/^\d+-\d+$/.test(normalized) || /^\d{18,}$/.test(normalized))
|
|
556
|
+
return `${normalized}@g.us`;
|
|
557
|
+
return `${normalized}@s.whatsapp.net`;
|
|
558
|
+
}
|
|
559
|
+
function normalizeNumberList(value) {
|
|
560
|
+
const entries = Array.isArray(value) ? value : String(value !== null && value !== void 0 ? value : '').split(/[,\n;]/);
|
|
561
|
+
const normalized = entries.map((entry) => normalizeNumber(entry)).filter((entry) => entry);
|
|
562
|
+
return [...new Set(normalized)];
|
|
563
|
+
}
|
|
564
|
+
function isGroupJid(value) {
|
|
565
|
+
return String(value !== null && value !== void 0 ? value : '')
|
|
566
|
+
.trim()
|
|
567
|
+
.toLowerCase()
|
|
568
|
+
.endsWith('@g.us');
|
|
569
|
+
}
|
|
570
|
+
function isLidJid(value) {
|
|
571
|
+
return String(value !== null && value !== void 0 ? value : '')
|
|
572
|
+
.trim()
|
|
573
|
+
.toLowerCase()
|
|
574
|
+
.endsWith('@lid');
|
|
575
|
+
}
|
|
576
|
+
function parseDataUri(value) {
|
|
577
|
+
const match = /^data:([^;,]*)(;[^,]*)?,(.*)$/s.exec(value.trim());
|
|
578
|
+
if (!match)
|
|
579
|
+
return { data: value.trim() };
|
|
580
|
+
return { mimeType: match[1] || undefined, data: match[3] };
|
|
581
|
+
}
|
|
582
|
+
function cleanBase64(value) {
|
|
583
|
+
const { mimeType, data } = parseDataUri(value);
|
|
584
|
+
const cleaned = data.replace(/\s+/g, '');
|
|
585
|
+
const valid = cleaned.length > 0 && cleaned.length % 4 === 0 && /^[A-Za-z0-9+/]+={0,2}$/.test(cleaned);
|
|
586
|
+
return { data: cleaned, mimeType, valid };
|
|
587
|
+
}
|
|
588
|
+
async function resolveMedia(itemIndex, input) {
|
|
589
|
+
var _a, _b, _c, _d;
|
|
590
|
+
if (input.type === 'url') {
|
|
591
|
+
const url = String((_a = input.url) !== null && _a !== void 0 ? _a : '').trim();
|
|
592
|
+
if (!/^https?:\/\//i.test(url)) {
|
|
593
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Media URL must start with http:// or https://', {
|
|
594
|
+
itemIndex,
|
|
595
|
+
});
|
|
596
|
+
}
|
|
597
|
+
return { type: 'url', value: url, fileName: input.fileName, mimeType: input.mimeType };
|
|
598
|
+
}
|
|
599
|
+
if (input.type === 'base64') {
|
|
600
|
+
const { data, mimeType, valid } = cleanBase64(String((_b = input.base64) !== null && _b !== void 0 ? _b : ''));
|
|
601
|
+
if (!valid) {
|
|
602
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Media is not valid base64', {
|
|
603
|
+
itemIndex,
|
|
604
|
+
description: 'Send raw base64 (a data: URI prefix is removed automatically) or use a URL.',
|
|
605
|
+
});
|
|
606
|
+
}
|
|
607
|
+
return {
|
|
608
|
+
type: 'base64',
|
|
609
|
+
value: data,
|
|
610
|
+
fileName: input.fileName,
|
|
611
|
+
mimeType: (_c = input.mimeType) !== null && _c !== void 0 ? _c : mimeType,
|
|
612
|
+
};
|
|
613
|
+
}
|
|
614
|
+
const propertyName = String((_d = input.binaryPropertyName) !== null && _d !== void 0 ? _d : 'data').trim() || 'data';
|
|
615
|
+
const binaryData = this.helpers.assertBinaryData(itemIndex, propertyName);
|
|
616
|
+
const buffer = await this.helpers.getBinaryDataBuffer(itemIndex, propertyName);
|
|
617
|
+
return {
|
|
618
|
+
type: 'binary',
|
|
619
|
+
value: buffer.toString('base64'),
|
|
620
|
+
buffer,
|
|
621
|
+
fileName: input.fileName || binaryData.fileName,
|
|
622
|
+
mimeType: input.mimeType || binaryData.mimeType,
|
|
623
|
+
};
|
|
624
|
+
}
|
|
625
|
+
function isMultipartSafe(fields) {
|
|
626
|
+
const check = (value) => {
|
|
627
|
+
if (value === undefined || value === null)
|
|
628
|
+
return true;
|
|
629
|
+
if (typeof value === 'string')
|
|
630
|
+
return true;
|
|
631
|
+
if (Array.isArray(value))
|
|
632
|
+
return value.every(check);
|
|
633
|
+
if (isPlainObject(value))
|
|
634
|
+
return Object.values(value).every(check);
|
|
635
|
+
return false;
|
|
636
|
+
};
|
|
637
|
+
return check(fields);
|
|
638
|
+
}
|
|
639
|
+
function appendFormValue(form, key, value) {
|
|
640
|
+
if (value === undefined || value === null)
|
|
641
|
+
return;
|
|
642
|
+
if (Array.isArray(value)) {
|
|
643
|
+
value.forEach((entry, index) => appendFormValue(form, `${key}[${index}]`, entry));
|
|
644
|
+
return;
|
|
645
|
+
}
|
|
646
|
+
if (isPlainObject(value)) {
|
|
647
|
+
for (const [subKey, subValue] of Object.entries(value)) {
|
|
648
|
+
appendFormValue(form, `${key}[${subKey}]`, subValue);
|
|
649
|
+
}
|
|
650
|
+
return;
|
|
651
|
+
}
|
|
652
|
+
form.append(key, String(value));
|
|
653
|
+
}
|
|
654
|
+
function buildMultipartBody(fields, file, fileField = 'file') {
|
|
655
|
+
const form = new FormData();
|
|
656
|
+
for (const [key, value] of Object.entries(fields))
|
|
657
|
+
appendFormValue(form, key, value);
|
|
658
|
+
if (file) {
|
|
659
|
+
const blob = new Blob([new Uint8Array(file.buffer)], {
|
|
660
|
+
type: file.mimeType || 'application/octet-stream',
|
|
661
|
+
});
|
|
662
|
+
form.append(fileField, blob, file.fileName || 'file');
|
|
663
|
+
}
|
|
664
|
+
return form;
|
|
665
|
+
}
|
|
666
|
+
function buildMediaRequestBody(media, fields, options = {}) {
|
|
667
|
+
var _a, _b;
|
|
668
|
+
const mediaField = (_a = options.mediaField) !== null && _a !== void 0 ? _a : 'media';
|
|
669
|
+
if (media.type === 'binary' &&
|
|
670
|
+
media.buffer &&
|
|
671
|
+
options.allowMultipart &&
|
|
672
|
+
isMultipartSafe(fields)) {
|
|
673
|
+
return buildMultipartBody(fields, { buffer: media.buffer, fileName: media.fileName, mimeType: media.mimeType }, (_b = options.fileField) !== null && _b !== void 0 ? _b : 'file');
|
|
674
|
+
}
|
|
675
|
+
return { ...fields, [mediaField]: media.value };
|
|
676
|
+
}
|
|
677
|
+
async function base64ToBinary(value, fileName, mimeType) {
|
|
678
|
+
const { data, mimeType: detectedMimeType } = cleanBase64(value);
|
|
679
|
+
return await this.helpers.prepareBinaryData(Buffer.from(data, 'base64'), fileName, mimeType !== null && mimeType !== void 0 ? mimeType : detectedMimeType);
|
|
680
|
+
}
|
|
681
|
+
//# sourceMappingURL=GenericFunctions.js.map
|