@aldinokemal2104/n8n-nodes-gowa 1.0.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.md +19 -0
- package/README.md +102 -0
- package/dist/credentials/GOWAApi.credentials.d.ts +9 -0
- package/dist/credentials/GOWAApi.credentials.js +49 -0
- package/dist/credentials/GOWAApi.credentials.js.map +1 -0
- package/dist/nodes/GOWA/Gowa.node.d.ts +5 -0
- package/dist/nodes/GOWA/Gowa.node.js +136 -0
- package/dist/nodes/GOWA/Gowa.node.js.map +1 -0
- package/dist/nodes/GOWA/app.operations.d.ts +4 -0
- package/dist/nodes/GOWA/app.operations.js +59 -0
- package/dist/nodes/GOWA/app.operations.js.map +1 -0
- package/dist/nodes/GOWA/gowa-icon.svg +1 -0
- package/dist/nodes/GOWA/group.operations.d.ts +5 -0
- package/dist/nodes/GOWA/group.operations.js +176 -0
- package/dist/nodes/GOWA/group.operations.js.map +1 -0
- package/dist/nodes/GOWA/message.operations.d.ts +5 -0
- package/dist/nodes/GOWA/message.operations.js +166 -0
- package/dist/nodes/GOWA/message.operations.js.map +1 -0
- package/dist/nodes/GOWA/send.operations.d.ts +5 -0
- package/dist/nodes/GOWA/send.operations.js +440 -0
- package/dist/nodes/GOWA/send.operations.js.map +1 -0
- package/dist/nodes/GOWA/types.d.ts +11 -0
- package/dist/nodes/GOWA/types.js +3 -0
- package/dist/nodes/GOWA/types.js.map +1 -0
- package/dist/nodes/GOWA/user.operations.d.ts +5 -0
- package/dist/nodes/GOWA/user.operations.js +137 -0
- package/dist/nodes/GOWA/user.operations.js.map +1 -0
- package/dist/package.json +56 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/index.js +0 -0
- package/package.json +56 -0
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { INodeProperties } from 'n8n-workflow';
|
|
2
|
+
import { OperationExecutor } from './types';
|
|
3
|
+
export declare const groupOperations: INodeProperties[];
|
|
4
|
+
export declare const groupProperties: INodeProperties[];
|
|
5
|
+
export declare const executeGroupOperation: OperationExecutor;
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.executeGroupOperation = exports.groupProperties = exports.groupOperations = void 0;
|
|
4
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
5
|
+
exports.groupOperations = [
|
|
6
|
+
{
|
|
7
|
+
displayName: 'Operation',
|
|
8
|
+
name: 'operation',
|
|
9
|
+
type: 'options',
|
|
10
|
+
noDataExpression: true,
|
|
11
|
+
displayOptions: {
|
|
12
|
+
show: {
|
|
13
|
+
resource: ['group'],
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
options: [
|
|
17
|
+
{
|
|
18
|
+
name: 'Add Participant',
|
|
19
|
+
value: 'addParticipant',
|
|
20
|
+
description: 'Add participant to group',
|
|
21
|
+
action: 'Add participant to group',
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
name: 'Create Group',
|
|
25
|
+
value: 'createGroup',
|
|
26
|
+
description: 'Create a new group',
|
|
27
|
+
action: 'Create a new group',
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
name: 'Demote Participant',
|
|
31
|
+
value: 'demoteParticipant',
|
|
32
|
+
description: 'Demote participant from admin',
|
|
33
|
+
action: 'Demote participant from admin',
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
name: 'Leave Group',
|
|
37
|
+
value: 'leaveGroup',
|
|
38
|
+
description: 'Leave a group',
|
|
39
|
+
action: 'Leave a group',
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
name: 'Promote Participant',
|
|
43
|
+
value: 'promoteParticipant',
|
|
44
|
+
description: 'Promote participant to admin',
|
|
45
|
+
action: 'Promote participant to admin',
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
name: 'Remove Participant',
|
|
49
|
+
value: 'removeParticipant',
|
|
50
|
+
description: 'Remove participant from group',
|
|
51
|
+
action: 'Remove participant from group',
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
default: 'createGroup',
|
|
55
|
+
},
|
|
56
|
+
];
|
|
57
|
+
exports.groupProperties = [
|
|
58
|
+
{
|
|
59
|
+
displayName: 'Group Name',
|
|
60
|
+
name: 'groupName',
|
|
61
|
+
type: 'string',
|
|
62
|
+
required: true,
|
|
63
|
+
displayOptions: {
|
|
64
|
+
show: {
|
|
65
|
+
resource: ['group'],
|
|
66
|
+
operation: ['createGroup'],
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
default: '',
|
|
70
|
+
description: 'Name of the group to create',
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
displayName: 'Participants',
|
|
74
|
+
name: 'groupParticipants',
|
|
75
|
+
type: 'string',
|
|
76
|
+
displayOptions: {
|
|
77
|
+
show: {
|
|
78
|
+
resource: ['group'],
|
|
79
|
+
operation: ['createGroup'],
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
default: '',
|
|
83
|
+
placeholder: '628123,628456',
|
|
84
|
+
description: 'Comma-separated phone numbers of participants to add to the new group',
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
displayName: 'Group ID',
|
|
88
|
+
name: 'groupId',
|
|
89
|
+
type: 'string',
|
|
90
|
+
required: true,
|
|
91
|
+
displayOptions: {
|
|
92
|
+
show: {
|
|
93
|
+
resource: ['group'],
|
|
94
|
+
operation: ['addParticipant', 'removeParticipant', 'promoteParticipant', 'demoteParticipant', 'leaveGroup'],
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
default: '',
|
|
98
|
+
description: 'ID of the group',
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
displayName: 'Participant Phone',
|
|
102
|
+
name: 'participantPhone',
|
|
103
|
+
type: 'string',
|
|
104
|
+
required: true,
|
|
105
|
+
displayOptions: {
|
|
106
|
+
show: {
|
|
107
|
+
resource: ['group'],
|
|
108
|
+
operation: ['addParticipant', 'removeParticipant', 'promoteParticipant', 'demoteParticipant'],
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
default: '',
|
|
112
|
+
description: 'Comma-separated phone numbers of the participant(s)',
|
|
113
|
+
},
|
|
114
|
+
];
|
|
115
|
+
const executeGroupOperation = async function (operation, itemIndex) {
|
|
116
|
+
const credentials = await this.getCredentials('goWhatsappApi');
|
|
117
|
+
const baseUrl = credentials.hostUrl || 'http://localhost:3000';
|
|
118
|
+
const requestOptions = {
|
|
119
|
+
method: 'POST',
|
|
120
|
+
url: '',
|
|
121
|
+
body: {},
|
|
122
|
+
};
|
|
123
|
+
switch (operation) {
|
|
124
|
+
case 'createGroup':
|
|
125
|
+
const groupName = this.getNodeParameter('groupName', itemIndex);
|
|
126
|
+
const groupParticipants = this.getNodeParameter('groupParticipants', itemIndex, '');
|
|
127
|
+
requestOptions.url = `${baseUrl.replace(/\/$/, '')}/group/create`;
|
|
128
|
+
requestOptions.body.name = groupName;
|
|
129
|
+
if (groupParticipants) {
|
|
130
|
+
requestOptions.body.participants = groupParticipants.split(',').map(p => p.trim());
|
|
131
|
+
}
|
|
132
|
+
break;
|
|
133
|
+
case 'addParticipant':
|
|
134
|
+
const addGroupId = this.getNodeParameter('groupId', itemIndex);
|
|
135
|
+
const addParticipantPhone = this.getNodeParameter('participantPhone', itemIndex);
|
|
136
|
+
requestOptions.url = `${baseUrl.replace(/\/$/, '')}/group/participant/add`;
|
|
137
|
+
requestOptions.body.id = addGroupId;
|
|
138
|
+
requestOptions.body.participants = addParticipantPhone.split(',').map(p => p.trim());
|
|
139
|
+
break;
|
|
140
|
+
case 'removeParticipant':
|
|
141
|
+
const removeGroupId = this.getNodeParameter('groupId', itemIndex);
|
|
142
|
+
const removeParticipantPhone = this.getNodeParameter('participantPhone', itemIndex);
|
|
143
|
+
requestOptions.url = `${baseUrl.replace(/\/$/, '')}/group/participant/remove`;
|
|
144
|
+
requestOptions.body.id = removeGroupId;
|
|
145
|
+
requestOptions.body.participants = removeParticipantPhone.split(',').map(p => p.trim());
|
|
146
|
+
break;
|
|
147
|
+
case 'promoteParticipant':
|
|
148
|
+
const promoteGroupId = this.getNodeParameter('groupId', itemIndex);
|
|
149
|
+
const promoteParticipantPhone = this.getNodeParameter('participantPhone', itemIndex);
|
|
150
|
+
requestOptions.url = `${baseUrl.replace(/\/$/, '')}/group/participant/promote`;
|
|
151
|
+
requestOptions.body.id = promoteGroupId;
|
|
152
|
+
requestOptions.body.participants = promoteParticipantPhone.split(',').map(p => p.trim());
|
|
153
|
+
break;
|
|
154
|
+
case 'demoteParticipant':
|
|
155
|
+
const demoteGroupId = this.getNodeParameter('groupId', itemIndex);
|
|
156
|
+
const demoteParticipantPhone = this.getNodeParameter('participantPhone', itemIndex);
|
|
157
|
+
requestOptions.url = `${baseUrl.replace(/\/$/, '')}/group/participant/demote`;
|
|
158
|
+
requestOptions.body.id = demoteGroupId;
|
|
159
|
+
requestOptions.body.participants = demoteParticipantPhone.split(',').map(p => p.trim());
|
|
160
|
+
break;
|
|
161
|
+
case 'leaveGroup':
|
|
162
|
+
const leaveGroupId = this.getNodeParameter('groupId', itemIndex);
|
|
163
|
+
requestOptions.url = `${baseUrl.replace(/\/$/, '')}/group/leave`;
|
|
164
|
+
requestOptions.body.id = leaveGroupId;
|
|
165
|
+
break;
|
|
166
|
+
default:
|
|
167
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Unknown group operation: ${operation}`);
|
|
168
|
+
}
|
|
169
|
+
const response = await this.helpers.requestWithAuthentication.call(this, 'goWhatsappApi', {
|
|
170
|
+
...requestOptions,
|
|
171
|
+
json: true,
|
|
172
|
+
});
|
|
173
|
+
return response;
|
|
174
|
+
};
|
|
175
|
+
exports.executeGroupOperation = executeGroupOperation;
|
|
176
|
+
//# sourceMappingURL=group.operations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"group.operations.js","sourceRoot":"","sources":["../../../nodes/GOWA/group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Ac,CAAC,GAAG,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,2BAA2B,CAAC;YAC9E,cAAc,CAAC,IAAI,CAAC,EAAE,GAAG,aAAa,CAAC;YACvC,cAAc,CAAC,IAAI,CAAC,YAAY,GAAG,sBAAsB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;YACxF,MAAM;QAEP,KAAK,YAAY;YAChB,MAAM,YAAY,GAAG,IAAI,CAAC,gBAAgB,CAAC,SAAS,EAAE,SAAS,CAAW,CAAC;YAC3E,cAAc,CAAC,GAAG,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,cAAc,CAAC;YACjE,cAAc,CAAC,IAAI,CAAC,EAAE,GAAG,YAAY,CAAC;YACtC,MAAM;QAEP;YACC,MAAM,IAAI,iCAAkB,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,4BAA4B,SAAS,EAAE,CAAC,CAAC;IACxF,CAAC;IAED,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,yBAAyB,CAAC,IAAI,CAAC,IAAI,EAAE,eAAe,EAAE;QACzF,GAAG,cAAc;QACjB,IAAI,EAAE,IAAI;KACV,CAAC,CAAC;IACH,OAAO,QAAQ,CAAC;AACjB,CAAC,CAAC;AAzEW,QAAA,qBAAqB,yBAyEhC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { INodeProperties } from 'n8n-workflow';
|
|
2
|
+
import { OperationExecutor } from './types';
|
|
3
|
+
export declare const messageOperations: INodeProperties[];
|
|
4
|
+
export declare const messageProperties: INodeProperties[];
|
|
5
|
+
export declare const executeMessageOperation: OperationExecutor;
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.executeMessageOperation = exports.messageProperties = exports.messageOperations = void 0;
|
|
4
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
5
|
+
exports.messageOperations = [
|
|
6
|
+
{
|
|
7
|
+
displayName: 'Operation',
|
|
8
|
+
name: 'operation',
|
|
9
|
+
type: 'options',
|
|
10
|
+
noDataExpression: true,
|
|
11
|
+
displayOptions: {
|
|
12
|
+
show: {
|
|
13
|
+
resource: ['message'],
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
options: [
|
|
17
|
+
{
|
|
18
|
+
name: 'Delete Message',
|
|
19
|
+
value: 'deleteMessage',
|
|
20
|
+
description: 'Delete a message',
|
|
21
|
+
action: 'Delete a message',
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
name: 'React to Message',
|
|
25
|
+
value: 'reactMessage',
|
|
26
|
+
description: 'React to a message',
|
|
27
|
+
action: 'React to a message',
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
name: 'Read Message',
|
|
31
|
+
value: 'readMessage',
|
|
32
|
+
description: 'Mark message as read',
|
|
33
|
+
action: 'Mark message as read',
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
name: 'Revoke Message',
|
|
37
|
+
value: 'revokeMessage',
|
|
38
|
+
description: 'Revoke a message',
|
|
39
|
+
action: 'Revoke a message',
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
name: 'Star Message',
|
|
43
|
+
value: 'starMessage',
|
|
44
|
+
description: 'Star a message',
|
|
45
|
+
action: 'Star a message',
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
name: 'Unstar Message',
|
|
49
|
+
value: 'unstarMessage',
|
|
50
|
+
description: 'Unstar a message',
|
|
51
|
+
action: 'Unstar a message',
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
name: 'Update Message',
|
|
55
|
+
value: 'updateMessage',
|
|
56
|
+
description: 'Update a message',
|
|
57
|
+
action: 'Update a message',
|
|
58
|
+
},
|
|
59
|
+
],
|
|
60
|
+
default: 'revokeMessage',
|
|
61
|
+
},
|
|
62
|
+
];
|
|
63
|
+
exports.messageProperties = [
|
|
64
|
+
{
|
|
65
|
+
displayName: 'Phone Number or Group ID',
|
|
66
|
+
name: 'phoneOrGroupId',
|
|
67
|
+
type: 'string',
|
|
68
|
+
required: true,
|
|
69
|
+
displayOptions: {
|
|
70
|
+
show: {
|
|
71
|
+
resource: ['message'],
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
default: '',
|
|
75
|
+
description: 'Phone number (for private chat) or Group ID (for group chat)',
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
displayName: 'Message ID',
|
|
79
|
+
name: 'messageId',
|
|
80
|
+
type: 'string',
|
|
81
|
+
required: true,
|
|
82
|
+
displayOptions: {
|
|
83
|
+
show: {
|
|
84
|
+
resource: ['message'],
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
default: '',
|
|
88
|
+
description: 'ID of the message to operate on',
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
displayName: 'Emoji',
|
|
92
|
+
name: 'emoji',
|
|
93
|
+
type: 'string',
|
|
94
|
+
displayOptions: {
|
|
95
|
+
show: {
|
|
96
|
+
resource: ['message'],
|
|
97
|
+
operation: ['reactMessage'],
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
default: '👍',
|
|
101
|
+
description: 'Emoji reaction to add',
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
displayName: 'New Message',
|
|
105
|
+
name: 'newMessage',
|
|
106
|
+
type: 'string',
|
|
107
|
+
required: true,
|
|
108
|
+
displayOptions: {
|
|
109
|
+
show: {
|
|
110
|
+
resource: ['message'],
|
|
111
|
+
operation: ['updateMessage'],
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
default: '',
|
|
115
|
+
description: 'The new content of the message',
|
|
116
|
+
},
|
|
117
|
+
];
|
|
118
|
+
const executeMessageOperation = async function (operation, itemIndex) {
|
|
119
|
+
const messageId = this.getNodeParameter('messageId', itemIndex);
|
|
120
|
+
const phoneOrGroupId = this.getNodeParameter('phoneOrGroupId', itemIndex);
|
|
121
|
+
const credentials = await this.getCredentials('goWhatsappApi');
|
|
122
|
+
const baseUrl = credentials.hostUrl || 'http://localhost:3000';
|
|
123
|
+
const requestOptions = {
|
|
124
|
+
method: 'POST',
|
|
125
|
+
url: '',
|
|
126
|
+
body: {
|
|
127
|
+
phone: phoneOrGroupId,
|
|
128
|
+
},
|
|
129
|
+
};
|
|
130
|
+
switch (operation) {
|
|
131
|
+
case 'deleteMessage':
|
|
132
|
+
requestOptions.url = `${baseUrl.replace(/\/$/, '')}/message/${messageId}/delete`;
|
|
133
|
+
break;
|
|
134
|
+
case 'reactMessage':
|
|
135
|
+
const emoji = this.getNodeParameter('emoji', itemIndex);
|
|
136
|
+
requestOptions.url = `${baseUrl.replace(/\/$/, '')}/message/${messageId}/reaction`;
|
|
137
|
+
requestOptions.body.emoji = emoji;
|
|
138
|
+
break;
|
|
139
|
+
case 'readMessage':
|
|
140
|
+
requestOptions.url = `${baseUrl.replace(/\/$/, '')}/message/${messageId}/read`;
|
|
141
|
+
break;
|
|
142
|
+
case 'revokeMessage':
|
|
143
|
+
requestOptions.url = `${baseUrl.replace(/\/$/, '')}/message/${messageId}/revoke`;
|
|
144
|
+
break;
|
|
145
|
+
case 'starMessage':
|
|
146
|
+
requestOptions.url = `${baseUrl.replace(/\/$/, '')}/message/${messageId}/star`;
|
|
147
|
+
break;
|
|
148
|
+
case 'unstarMessage':
|
|
149
|
+
requestOptions.url = `${baseUrl.replace(/\/$/, '')}/message/${messageId}/unstar`;
|
|
150
|
+
break;
|
|
151
|
+
case 'updateMessage':
|
|
152
|
+
const newMessage = this.getNodeParameter('newMessage', itemIndex);
|
|
153
|
+
requestOptions.url = `${baseUrl.replace(/\/$/, '')}/message/${messageId}/update`;
|
|
154
|
+
requestOptions.body.message = newMessage;
|
|
155
|
+
break;
|
|
156
|
+
default:
|
|
157
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Unknown message operation: ${operation}`);
|
|
158
|
+
}
|
|
159
|
+
const response = await this.helpers.requestWithAuthentication.call(this, 'goWhatsappApi', {
|
|
160
|
+
...requestOptions,
|
|
161
|
+
json: true,
|
|
162
|
+
});
|
|
163
|
+
return response;
|
|
164
|
+
};
|
|
165
|
+
exports.executeMessageOperation = executeMessageOperation;
|
|
166
|
+
//# sourceMappingURL=message.operations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message.operations.js","sourceRoot":"","sources":["../../../nodes/GOWA/message.operations.ts"],"names":[],"mappings":";;;AAAA,+CAKsB;AAGT,QAAA,iBAAiB,GAAsB;IACnD;QACC,WAAW,EAAE,WAAW;QACxB,IAAI,EAAE,WAAW;QACjB,IAAI,EAAE,SAAS;QACf,gBAAgB,EAAE,IAAI;QACtB,cAAc,EAAE;YACf,IAAI,EAAE;gBACL,QAAQ,EAAE,CAAC,SAAS,CAAC;aACrB;SACD;QACD,OAAO,EAAE;YACR;gBACC,IAAI,EAAE,gBAAgB;gBACtB,KAAK,EAAE,eAAe;gBACtB,WAAW,EAAE,kBAAkB;gBAC/B,MAAM,EAAE,kBAAkB;aAC1B;YACD;gBACC,IAAI,EAAE,kBAAkB;gBACxB,KAAK,EAAE,cAAc;gBACrB,WAAW,EAAE,oBAAoB;gBACjC,MAAM,EAAE,oBAAoB;aAC5B;YACD;gBACC,IAAI,EAAE,cAAc;gBACpB,KAAK,EAAE,aAAa;gBACpB,WAAW,EAAE,sBAAsB;gBACnC,MAAM,EAAE,sBAAsB;aAC9B;YACD;gBACC,IAAI,EAAE,gBAAgB;gBACtB,KAAK,EAAE,eAAe;gBACtB,WAAW,EAAE,kBAAkB;gBAC/B,MAAM,EAAE,kBAAkB;aAC1B;YACD;gBACC,IAAI,EAAE,cAAc;gBACpB,KAAK,EAAE,aAAa;gBACpB,WAAW,EAAE,gBAAgB;gBAC7B,MAAM,EAAE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AG,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,YAAY,SAAS,SAAS,CAAC;YACjF,MAAM;QACP,KAAK,aAAa;YACjB,cAAc,CAAC,GAAG,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,YAAY,SAAS,OAAO,CAAC;YAC/E,MAAM;QACP,KAAK,eAAe;YACnB,cAAc,CAAC,GAAG,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,YAAY,SAAS,SAAS,CAAC;YACjF,MAAM;QACP,KAAK,eAAe;YACnB,MAAM,UAAU,GAAG,IAAI,CAAC,gBAAgB,CAAC,YAAY,EAAE,SAAS,CAAW,CAAC;YAC5E,cAAc,CAAC,GAAG,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,YAAY,SAAS,SAAS,CAAC;YACjF,cAAc,CAAC,IAAI,CAAC,OAAO,GAAG,UAAU,CAAC;YACzC,MAAM;QACP;YACC,MAAM,IAAI,iCAAkB,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,8BAA8B,SAAS,EAAE,CAAC,CAAC;IAC1F,CAAC;IAED,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,yBAAyB,CAAC,IAAI,CAAC,IAAI,EAAE,eAAe,EAAE;QACzF,GAAG,cAAc;QACjB,IAAI,EAAE,IAAI;KACV,CAAC,CAAC;IACH,OAAO,QAAQ,CAAC;AACjB,CAAC,CAAC;AAvDW,QAAA,uBAAuB,2BAuDlC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { INodeProperties } from 'n8n-workflow';
|
|
2
|
+
import { OperationExecutor } from './types';
|
|
3
|
+
export declare const sendOperations: INodeProperties[];
|
|
4
|
+
export declare const sendProperties: INodeProperties[];
|
|
5
|
+
export declare const executeSendOperation: OperationExecutor;
|