@limetech/n8n-nodes-lime 3.10.3 → 3.11.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/CHANGELOG.md +20 -0
- package/credentials/LimeCrmApi.credentials.ts +1 -0
- package/credentials/LimeFormsApi.credentials.ts +1 -0
- package/credentials/LimeMarketingApi.credentials.ts +92 -0
- package/credentials/assets/lime-crm.svg +1 -0
- package/credentials/index.ts +1 -0
- package/dist/credentials/LimeCrmApi.credentials.d.ts +1 -0
- package/dist/credentials/LimeCrmApi.credentials.js +1 -0
- package/dist/credentials/LimeCrmApi.credentials.js.map +1 -1
- package/dist/credentials/LimeFormsApi.credentials.d.ts +1 -0
- package/dist/credentials/LimeFormsApi.credentials.js +1 -0
- package/dist/credentials/LimeFormsApi.credentials.js.map +1 -1
- package/dist/credentials/LimeMarketingApi.credentials.d.ts +9 -0
- package/dist/credentials/LimeMarketingApi.credentials.js +64 -0
- package/dist/credentials/LimeMarketingApi.credentials.js.map +1 -0
- package/dist/credentials/assets/lime-crm.svg +1 -0
- package/dist/credentials/index.d.ts +1 -0
- package/dist/credentials/index.js +1 -0
- package/dist/credentials/index.js.map +1 -1
- package/dist/nodes/index.d.ts +1 -0
- package/dist/nodes/index.js +1 -0
- package/dist/nodes/index.js.map +1 -1
- package/dist/nodes/lime-crm/assets/lime-crm.svg +0 -0
- package/dist/nodes/lime-forms/assets/lime-crm.svg +0 -0
- package/dist/nodes/lime-marketing/LimeMarketing.node.d.ts +16 -0
- package/dist/nodes/lime-marketing/LimeMarketing.node.js +121 -0
- package/dist/nodes/lime-marketing/LimeMarketing.node.js.map +1 -0
- package/dist/nodes/lime-marketing/assets/lime-crm.svg +1 -0
- package/dist/nodes/lime-marketing/index.d.ts +1 -0
- package/dist/nodes/lime-marketing/index.js +18 -0
- package/dist/nodes/lime-marketing/index.js.map +1 -0
- package/dist/nodes/lime-marketing/methods/getTemplateMergeCodeMappingColumns.d.ts +3 -0
- package/dist/nodes/lime-marketing/methods/getTemplateMergeCodeMappingColumns.js +52 -0
- package/dist/nodes/lime-marketing/methods/getTemplateMergeCodeMappingColumns.js.map +1 -0
- package/dist/nodes/lime-marketing/methods/getTemplates.d.ts +2 -0
- package/dist/nodes/lime-marketing/methods/getTemplates.js +24 -0
- package/dist/nodes/lime-marketing/methods/getTemplates.js.map +1 -0
- package/dist/nodes/lime-marketing/methods/index.d.ts +2 -0
- package/dist/nodes/lime-marketing/methods/index.js +8 -0
- package/dist/nodes/lime-marketing/methods/index.js.map +1 -0
- package/dist/nodes/lime-marketing/models/constants.d.ts +9 -0
- package/dist/nodes/lime-marketing/models/constants.js +13 -0
- package/dist/nodes/lime-marketing/models/constants.js.map +1 -0
- package/dist/nodes/lime-marketing/models/index.d.ts +6 -0
- package/dist/nodes/lime-marketing/models/index.js +14 -0
- package/dist/nodes/lime-marketing/models/index.js.map +1 -0
- package/dist/nodes/lime-marketing/models/operationInputs.d.ts +36 -0
- package/dist/nodes/lime-marketing/models/operationInputs.js +3 -0
- package/dist/nodes/lime-marketing/models/operationInputs.js.map +1 -0
- package/dist/nodes/lime-marketing/models/template.d.ts +10 -0
- package/dist/nodes/lime-marketing/models/template.js +3 -0
- package/dist/nodes/lime-marketing/models/template.js.map +1 -0
- package/dist/nodes/lime-marketing/models/transactionMail.d.ts +60 -0
- package/dist/nodes/lime-marketing/models/transactionMail.js +3 -0
- package/dist/nodes/lime-marketing/models/transactionMail.js.map +1 -0
- package/dist/nodes/lime-marketing/models/transactionSms.d.ts +20 -0
- package/dist/nodes/lime-marketing/models/transactionSms.js +3 -0
- package/dist/nodes/lime-marketing/models/transactionSms.js.map +1 -0
- package/dist/nodes/lime-marketing/models/transportError.d.ts +7 -0
- package/dist/nodes/lime-marketing/models/transportError.js +3 -0
- package/dist/nodes/lime-marketing/models/transportError.js.map +1 -0
- package/dist/nodes/lime-marketing/resources/transactionmail/index.d.ts +6 -0
- package/dist/nodes/lime-marketing/resources/transactionmail/index.js +56 -0
- package/dist/nodes/lime-marketing/resources/transactionmail/index.js.map +1 -0
- package/dist/nodes/lime-marketing/resources/transactionmail/operations/send.operation.d.ts +10 -0
- package/dist/nodes/lime-marketing/resources/transactionmail/operations/send.operation.js +543 -0
- package/dist/nodes/lime-marketing/resources/transactionmail/operations/send.operation.js.map +1 -0
- package/dist/nodes/lime-marketing/resources/transactionsms/index.d.ts +6 -0
- package/dist/nodes/lime-marketing/resources/transactionsms/index.js +56 -0
- package/dist/nodes/lime-marketing/resources/transactionsms/index.js.map +1 -0
- package/dist/nodes/lime-marketing/resources/transactionsms/operations/send.operation.d.ts +10 -0
- package/dist/nodes/lime-marketing/resources/transactionsms/operations/send.operation.js +171 -0
- package/dist/nodes/lime-marketing/resources/transactionsms/operations/send.operation.js.map +1 -0
- package/dist/nodes/lime-marketing/transport/index.d.ts +7 -0
- package/dist/nodes/lime-marketing/transport/index.js +34 -0
- package/dist/nodes/lime-marketing/transport/index.js.map +1 -0
- package/dist/nodes/lime-marketing/utils/index.d.ts +8 -0
- package/dist/nodes/lime-marketing/utils/index.js +62 -0
- package/dist/nodes/lime-marketing/utils/index.js.map +1 -0
- package/dist/nodes/lime-marketing/utils/mergeCodes.d.ts +26 -0
- package/dist/nodes/lime-marketing/utils/mergeCodes.js +85 -0
- package/dist/nodes/lime-marketing/utils/mergeCodes.js.map +1 -0
- package/dist/package.json +5 -3
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/nodes/index.ts +1 -0
- package/nodes/lime-crm/assets/lime-crm.svg +0 -0
- package/nodes/lime-forms/assets/lime-crm.svg +0 -0
- package/nodes/lime-marketing/LimeMarketing.node.ts +180 -0
- package/nodes/lime-marketing/assets/lime-crm.svg +1 -0
- package/nodes/lime-marketing/index.ts +1 -0
- package/nodes/lime-marketing/methods/getTemplateMergeCodeMappingColumns.ts +70 -0
- package/nodes/lime-marketing/methods/getTemplates.ts +33 -0
- package/nodes/lime-marketing/methods/index.ts +2 -0
- package/nodes/lime-marketing/models/constants.ts +12 -0
- package/nodes/lime-marketing/models/index.ts +32 -0
- package/nodes/lime-marketing/models/operationInputs.ts +40 -0
- package/nodes/lime-marketing/models/template.ts +10 -0
- package/nodes/lime-marketing/models/transactionMail.ts +65 -0
- package/nodes/lime-marketing/models/transactionSms.ts +22 -0
- package/nodes/lime-marketing/models/transportError.ts +6 -0
- package/nodes/lime-marketing/resources/transactionmail/index.ts +22 -0
- package/nodes/lime-marketing/resources/transactionmail/operations/send.operation.ts +664 -0
- package/nodes/lime-marketing/resources/transactionsms/index.ts +22 -0
- package/nodes/lime-marketing/resources/transactionsms/operations/send.operation.ts +228 -0
- package/nodes/lime-marketing/transport/index.ts +68 -0
- package/nodes/lime-marketing/utils/index.ts +139 -0
- package/nodes/lime-marketing/utils/mergeCodes.ts +121 -0
- package/package.json +6 -4
package/nodes/index.ts
CHANGED
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import {
|
|
2
|
+
IDataObject,
|
|
3
|
+
IExecuteFunctions,
|
|
4
|
+
INodeExecutionData,
|
|
5
|
+
INodeType,
|
|
6
|
+
INodeTypeDescription,
|
|
7
|
+
NodeApiError,
|
|
8
|
+
NodeConnectionTypes,
|
|
9
|
+
NodeOperationError,
|
|
10
|
+
NodePropertyTypes,
|
|
11
|
+
} from 'n8n-workflow';
|
|
12
|
+
import {
|
|
13
|
+
LIME_MARKETING_API_CREDENTIAL_KEY,
|
|
14
|
+
TRANSACTIONAL_EMAIL_RESOURCE,
|
|
15
|
+
TRANSACTIONAL_SMS_RESOURCE,
|
|
16
|
+
} from './models';
|
|
17
|
+
import {
|
|
18
|
+
transactionMailFields,
|
|
19
|
+
transactionMailOperations,
|
|
20
|
+
} from './resources/transactionmail';
|
|
21
|
+
import {
|
|
22
|
+
transactionSmsFields,
|
|
23
|
+
transactionSmsOperations,
|
|
24
|
+
} from './resources/transactionsms';
|
|
25
|
+
import { getTemplates, getTemplateMergeCodeMappingColumns } from './methods';
|
|
26
|
+
import { getBaseUrl } from './utils';
|
|
27
|
+
|
|
28
|
+
// What an OperationExecutor returns: either a raw API response object, an
|
|
29
|
+
// array of them, or already-wrapped n8n execution items (single or many).
|
|
30
|
+
// `undefined` means "no items emitted from this input".
|
|
31
|
+
export type OperationExecutorResult =
|
|
32
|
+
| IDataObject
|
|
33
|
+
| IDataObject[]
|
|
34
|
+
| INodeExecutionData
|
|
35
|
+
| INodeExecutionData[]
|
|
36
|
+
| undefined;
|
|
37
|
+
|
|
38
|
+
// Signature for a per-item operation. Receives the item index and a
|
|
39
|
+
// pre-resolved baseURL so we don't re-fetch credentials on every call.
|
|
40
|
+
export type OperationExecutor = (
|
|
41
|
+
this: IExecuteFunctions,
|
|
42
|
+
i: number,
|
|
43
|
+
baseURL: string
|
|
44
|
+
) => Promise<OperationExecutorResult>;
|
|
45
|
+
|
|
46
|
+
const OPERATIONS: Record<string, Record<string, OperationExecutor>> = {
|
|
47
|
+
[TRANSACTIONAL_EMAIL_RESOURCE]: transactionMailOperations,
|
|
48
|
+
[TRANSACTIONAL_SMS_RESOURCE]: transactionSmsOperations,
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
function hasJsonField(
|
|
52
|
+
value: IDataObject | INodeExecutionData
|
|
53
|
+
): value is INodeExecutionData {
|
|
54
|
+
return 'json' in value;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Wrap one raw response into an n8n execution item, preserving `json` if
|
|
58
|
+
// already present and tagging `pairedItem`.
|
|
59
|
+
function toExecutionItem(
|
|
60
|
+
raw: IDataObject | INodeExecutionData,
|
|
61
|
+
i: number
|
|
62
|
+
): INodeExecutionData {
|
|
63
|
+
const base = hasJsonField(raw) ? raw : { json: raw };
|
|
64
|
+
return { ...base, pairedItem: { item: i } };
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// Normalize a response (single value, array, or undefined) into an array
|
|
68
|
+
// of execution items.
|
|
69
|
+
function toExecutionItems(
|
|
70
|
+
responseData: OperationExecutorResult,
|
|
71
|
+
i: number
|
|
72
|
+
): INodeExecutionData[] {
|
|
73
|
+
if (responseData === undefined) return [];
|
|
74
|
+
const list = Array.isArray(responseData) ? responseData : [responseData];
|
|
75
|
+
return list.map((item) => toExecutionItem(item, i));
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// Build an error-flavored execution item for the `continueOnFail` branch,
|
|
79
|
+
// attaching the original NodeError when available.
|
|
80
|
+
function buildErrorItem(error: Error, i: number): INodeExecutionData {
|
|
81
|
+
const nodeError =
|
|
82
|
+
error instanceof NodeApiError || error instanceof NodeOperationError
|
|
83
|
+
? error
|
|
84
|
+
: undefined;
|
|
85
|
+
// n8n's executor overwrites `json` with `{ error: error.message }` whenever
|
|
86
|
+
// an item has a top-level `error` field, so anything else in `json` would
|
|
87
|
+
// be discarded before downstream nodes see it.
|
|
88
|
+
return {
|
|
89
|
+
json: { error: error.message },
|
|
90
|
+
error: nodeError,
|
|
91
|
+
pairedItem: { item: i },
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export class LimeMarketing implements INodeType {
|
|
96
|
+
description: INodeTypeDescription = {
|
|
97
|
+
displayName: 'Lime CRM Marketing',
|
|
98
|
+
name: 'limeMarketing',
|
|
99
|
+
icon: 'file:assets/lime-crm.svg',
|
|
100
|
+
group: ['transform'],
|
|
101
|
+
version: 1,
|
|
102
|
+
subtitle:
|
|
103
|
+
'={{$parameter["operation"] + ": " + $parameter["resource"]}}',
|
|
104
|
+
description:
|
|
105
|
+
'Send transactional emails and SMS via the Lime CRM Marketing API',
|
|
106
|
+
defaults: { name: 'Lime CRM Marketing' },
|
|
107
|
+
inputs: [NodeConnectionTypes.Main],
|
|
108
|
+
outputs: [NodeConnectionTypes.Main],
|
|
109
|
+
credentials: [
|
|
110
|
+
{ name: LIME_MARKETING_API_CREDENTIAL_KEY, required: true },
|
|
111
|
+
],
|
|
112
|
+
usableAsTool: true,
|
|
113
|
+
properties: [
|
|
114
|
+
{
|
|
115
|
+
displayName:
|
|
116
|
+
'Tip: set On Error to "Continue (using error output)" in the Settings tab to route failed sends down a separate branch. The error output contains the API message as $json.error.',
|
|
117
|
+
name: 'errorHandlingHint',
|
|
118
|
+
type: 'notice',
|
|
119
|
+
default: '',
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
displayName: 'Resource',
|
|
123
|
+
name: 'resource',
|
|
124
|
+
type: 'options' as NodePropertyTypes,
|
|
125
|
+
noDataExpression: true,
|
|
126
|
+
options: [
|
|
127
|
+
{
|
|
128
|
+
name: 'Email',
|
|
129
|
+
value: TRANSACTIONAL_EMAIL_RESOURCE,
|
|
130
|
+
description: 'Send a transactional email',
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
name: 'SMS',
|
|
134
|
+
value: TRANSACTIONAL_SMS_RESOURCE,
|
|
135
|
+
description: 'Send a transactional SMS',
|
|
136
|
+
},
|
|
137
|
+
],
|
|
138
|
+
default: TRANSACTIONAL_EMAIL_RESOURCE,
|
|
139
|
+
},
|
|
140
|
+
|
|
141
|
+
...transactionMailFields,
|
|
142
|
+
...transactionSmsFields,
|
|
143
|
+
],
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
methods = {
|
|
147
|
+
loadOptions: {
|
|
148
|
+
getTemplates,
|
|
149
|
+
},
|
|
150
|
+
resourceMapping: {
|
|
151
|
+
getTemplateMergeCodeMappingColumns,
|
|
152
|
+
},
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
|
156
|
+
const items = this.getInputData();
|
|
157
|
+
const resource = this.getNodeParameter('resource', 0) as string;
|
|
158
|
+
const operation = this.getNodeParameter('operation', 0) as string;
|
|
159
|
+
const executor = OPERATIONS[resource]?.[operation];
|
|
160
|
+
if (!executor) return [[]];
|
|
161
|
+
|
|
162
|
+
const baseURL = await getBaseUrl(this);
|
|
163
|
+
const returnData: INodeExecutionData[] = [];
|
|
164
|
+
for (let i = 0; i < items.length; i++) {
|
|
165
|
+
try {
|
|
166
|
+
const responseData = await executor.call(this, i, baseURL);
|
|
167
|
+
returnData.push(...toExecutionItems(responseData, i));
|
|
168
|
+
} catch (error_) {
|
|
169
|
+
if (!this.continueOnFail()) throw error_;
|
|
170
|
+
const error =
|
|
171
|
+
error_ instanceof Error
|
|
172
|
+
? error_
|
|
173
|
+
: new Error(String(error_));
|
|
174
|
+
returnData.push(buildErrorItem(error, i));
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
return [returnData];
|
|
179
|
+
}
|
|
180
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg viewBox="0 0 1024 1025" xmlns="http://www.w3.org/2000/svg" xml:space="preserve"><clipPath id="a"><path d="M0 .03h1024v1024H0z"/></clipPath><g clip-path="url(#a)"><path d="M92.399 480.888c0-257.059 208.719-465.779 465.78-465.779C815.28 15.109 1024 223.829 1024 480.888c0 133.713-55.806 271.139-193.403 385.355-166.779 138.45-390.39 157.35-736.15 134.525-102.653-6.785-117.502-24.319-64.468-63.444 166.694-123.047 62.42-217.167 62.42-456.436Z" style="fill:#bee034"/><clipPath id="b"><path d="M92.399 480.888c0-257.059 208.719-465.779 465.78-465.779C815.28 15.109 1024 223.829 1024 480.888c0 133.713-55.806 271.139-193.403 385.355-166.779 138.45-390.39 157.35-736.15 134.525-102.653-6.785-117.502-24.319-64.468-63.444 166.694-123.047 62.42-217.167 62.42-456.436Z"/></clipPath><g clip-path="url(#b)"><path d="M1023-361.59c0 784.587-711.326 1420.62-1588.79 1420.62C-1402.638-283.55 1023-1146.18 1023-361.59Z" style="fill:#a6efff;filter:blur(200px)"/></g><path d="M433.85 723.911c-24.702-12.757-47.23-29.226-66.813-48.596-9.088-9.002-23.765-8.959-32.768.129-9.001 9.087-8.916 23.763.171 32.766 22.911 22.698 49.236 41.941 78.121 56.873 11.392 5.888 25.385 1.409 31.231-9.94 5.888-11.349 1.409-25.344-9.942-31.232Zm367.266-363.98a270.163 270.163 0 0 1 25.556 78.547c2.048 12.629 13.952 21.206 26.581 19.158 12.586-2.006 21.204-13.951 19.156-26.539a316.387 316.387 0 0 0-29.907-92.029c-5.803-11.434-19.754-15.999-31.146-10.24-11.393 5.76-16 19.713-10.24 31.103Zm-51.497 315.384c-19.584 19.37-42.069 35.839-66.815 48.596-11.349 5.888-15.786 19.883-9.94 31.232 5.887 11.349 19.881 15.828 31.229 9.94 28.929-14.932 55.253-34.175 78.164-56.873 9.045-9.003 9.131-23.679.128-32.766-9.002-9.088-23.678-9.131-32.766-.129ZM517.006 213.546a274.904 274.904 0 0 1 41.343-3.114c14.036 0 27.861 1.066 41.343 3.114 12.629 1.919 24.448-6.784 26.367-19.413 1.962-12.628-6.741-24.446-19.371-26.409a322.626 322.626 0 0 0-48.339-3.627 322.201 322.201 0 0 0-48.34 3.627c-12.672 1.963-21.332 13.781-19.413 26.409 1.92 12.629 13.739 21.332 26.41 19.413Zm41.343 490.355c-40.489 0-73.385 32.853-73.385 73.342s32.896 73.385 73.385 73.385c40.489 0 73.342-32.896 73.342-73.385 0-40.489-32.853-73.342-73.342-73.342ZM290.025 438.478c4.481-27.818 13.227-54.227 25.514-78.547 5.761-11.39 1.195-25.343-10.239-31.103-11.392-5.759-25.343-1.194-31.104 10.24a313.893 313.893 0 0 0-29.908 92.029c-2.048 12.588 6.527 24.533 19.157 26.539 12.629 2.048 24.532-6.529 26.58-19.158Zm479.092 112.254c-12.501 38.527 8.618 79.955 47.102 92.456 38.528 12.502 79.956-8.618 92.457-47.104 12.501-38.525-8.619-79.953-47.103-92.455-38.527-12.501-79.955 8.619-92.456 47.103Zm-80.51-247.802c32.766 23.808 78.675 16.554 102.482-16.212 23.808-32.767 16.512-78.675-16.256-102.482-32.723-23.809-78.675-16.512-102.439 16.254-23.808 32.725-16.555 78.633 16.213 102.44Zm-260.558 0c32.766-23.807 40.063-69.715 16.254-102.44-23.807-32.766-69.715-40.063-102.482-16.254-32.766 23.807-40.02 69.715-16.255 102.482 23.806 32.766 69.758 40.02 102.483 16.212Zm-80.51 247.802c-12.501-38.484-53.929-59.604-92.415-47.103-38.526 12.502-59.645 53.93-47.102 92.455 12.501 38.486 53.929 59.606 92.413 47.104 38.528-12.501 59.605-53.929 47.104-92.456Z" style="fill:#fff"/></g></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './LimeMarketing.node';
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { ILoadOptionsFunctions, ResourceMapperFields } from 'n8n-workflow';
|
|
2
|
+
import { limeMarketingRequest } from '../transport';
|
|
3
|
+
import { LoggerProxy as Logger } from 'n8n-workflow';
|
|
4
|
+
|
|
5
|
+
type TemplateVariablesResponse = {
|
|
6
|
+
RecipientVariables?: { Property: string; RawValue: string }[];
|
|
7
|
+
CustomVariables?: { Property: string; RawValue: string }[];
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
const PLACEHOLDER_ID = '__noMergeCodes__';
|
|
11
|
+
|
|
12
|
+
// True if `name` is the synthetic "no merge codes" sentinel produced for
|
|
13
|
+
// templates without merge codes — must be filtered out before sending.
|
|
14
|
+
export function isMergeCodePlaceholder(name: string): boolean {
|
|
15
|
+
return name === PLACEHOLDER_ID;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const noMergeCodesPlaceholder = {
|
|
19
|
+
id: PLACEHOLDER_ID,
|
|
20
|
+
displayName: 'No merge codes in this template',
|
|
21
|
+
required: false,
|
|
22
|
+
defaultMatch: false,
|
|
23
|
+
display: true,
|
|
24
|
+
type: 'string' as const,
|
|
25
|
+
canBeUsedToMatch: false,
|
|
26
|
+
readOnly: true,
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
// resourceMapping handler: fetch the merge codes (CustomVariables) for the
|
|
30
|
+
// currently-selected template and expose each as a mappable field. Returns a
|
|
31
|
+
// readOnly placeholder field when the template has none, since n8n's resource
|
|
32
|
+
// mapper requires at least one field to render.
|
|
33
|
+
export async function getTemplateMergeCodeMappingColumns(
|
|
34
|
+
this: ILoadOptionsFunctions
|
|
35
|
+
): Promise<ResourceMapperFields> {
|
|
36
|
+
const templateId = Number(this.getNodeParameter('templateId', 0));
|
|
37
|
+
if (!templateId) return { fields: [noMergeCodesPlaceholder] };
|
|
38
|
+
|
|
39
|
+
const tagsResponse = await limeMarketingRequest<TemplateVariablesResponse>(
|
|
40
|
+
this,
|
|
41
|
+
{
|
|
42
|
+
method: 'GET',
|
|
43
|
+
url: `mailtemplate/${templateId}/variables`,
|
|
44
|
+
json: true,
|
|
45
|
+
errorContext: 'load template merge codes',
|
|
46
|
+
}
|
|
47
|
+
);
|
|
48
|
+
if (!tagsResponse.success) {
|
|
49
|
+
Logger.error(
|
|
50
|
+
`There was an error with fetching merge codes: ${JSON.stringify(tagsResponse.data)}`
|
|
51
|
+
);
|
|
52
|
+
return { fields: [] };
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const fields = (tagsResponse?.data.CustomVariables ?? [])
|
|
56
|
+
.map((v) => v?.RawValue)
|
|
57
|
+
.filter(Boolean)
|
|
58
|
+
.map((code) => ({
|
|
59
|
+
id: code,
|
|
60
|
+
displayName: code,
|
|
61
|
+
required: false,
|
|
62
|
+
defaultMatch: false,
|
|
63
|
+
display: true,
|
|
64
|
+
type: 'string' as const,
|
|
65
|
+
canBeUsedToMatch: false,
|
|
66
|
+
}));
|
|
67
|
+
|
|
68
|
+
if (fields.length === 0) return { fields: [noMergeCodesPlaceholder] };
|
|
69
|
+
return { fields };
|
|
70
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ILoadOptionsFunctions,
|
|
3
|
+
INodePropertyOptions,
|
|
4
|
+
LoggerProxy as Logger,
|
|
5
|
+
} from 'n8n-workflow';
|
|
6
|
+
import { MailTemplate } from '../models';
|
|
7
|
+
import { limeMarketingRequest } from '../transport';
|
|
8
|
+
|
|
9
|
+
// loadOptions handler: fetch all mail templates and return them sorted by name
|
|
10
|
+
// for the Template dropdown on the email send operation.
|
|
11
|
+
export async function getTemplates(
|
|
12
|
+
this: ILoadOptionsFunctions
|
|
13
|
+
): Promise<INodePropertyOptions[]> {
|
|
14
|
+
const templates = await limeMarketingRequest<MailTemplate[]>(this, {
|
|
15
|
+
method: 'GET',
|
|
16
|
+
url: 'mailtemplate',
|
|
17
|
+
json: true,
|
|
18
|
+
errorContext: 'load templates',
|
|
19
|
+
});
|
|
20
|
+
if (!templates.success) {
|
|
21
|
+
Logger.error(
|
|
22
|
+
`There was an error with fetching properties: ${JSON.stringify(templates.data)}`
|
|
23
|
+
);
|
|
24
|
+
return [];
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return templates.data
|
|
28
|
+
.map((t) => ({
|
|
29
|
+
name: `${t.Name} (ID: ${t.Id})`,
|
|
30
|
+
value: t.Id,
|
|
31
|
+
}))
|
|
32
|
+
.sort((a, b) => a.name.localeCompare(b.name));
|
|
33
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export const LIME_MARKETING_API_CREDENTIAL_KEY = 'limeMarketingApi';
|
|
2
|
+
export const TRANSACTIONAL_EMAIL_RESOURCE = 'email';
|
|
3
|
+
export const TRANSACTIONAL_SMS_RESOURCE = 'sms';
|
|
4
|
+
|
|
5
|
+
export const CONTENT_TYPE_TEMPLATE = 'template';
|
|
6
|
+
export const CONTENT_TYPE_CUSTOM = 'html';
|
|
7
|
+
export const CONTENT_TYPE_TEXT = 'text';
|
|
8
|
+
|
|
9
|
+
export const MERGE_CODES_INPUT_FIELDS = 'fields';
|
|
10
|
+
export const MERGE_CODES_INPUT_JSON = 'json';
|
|
11
|
+
|
|
12
|
+
export const SEND_OPERATION = 'send';
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export {
|
|
2
|
+
LIME_MARKETING_API_CREDENTIAL_KEY,
|
|
3
|
+
TRANSACTIONAL_EMAIL_RESOURCE,
|
|
4
|
+
TRANSACTIONAL_SMS_RESOURCE,
|
|
5
|
+
CONTENT_TYPE_TEMPLATE,
|
|
6
|
+
CONTENT_TYPE_CUSTOM,
|
|
7
|
+
CONTENT_TYPE_TEXT,
|
|
8
|
+
MERGE_CODES_INPUT_FIELDS,
|
|
9
|
+
MERGE_CODES_INPUT_JSON,
|
|
10
|
+
SEND_OPERATION,
|
|
11
|
+
} from './constants';
|
|
12
|
+
export type { MailTemplate } from './template';
|
|
13
|
+
export type {
|
|
14
|
+
AttachmentModel,
|
|
15
|
+
TagModel,
|
|
16
|
+
SendTransactionMailArgs,
|
|
17
|
+
SendTransactionMailBase,
|
|
18
|
+
SendTransactionMailTemplateArgs,
|
|
19
|
+
TransactionMailModel,
|
|
20
|
+
} from './transactionMail';
|
|
21
|
+
export type {
|
|
22
|
+
SendTransactionSmsArgs,
|
|
23
|
+
TransactionSmsModel,
|
|
24
|
+
} from './transactionSms';
|
|
25
|
+
export type {
|
|
26
|
+
TagListInput,
|
|
27
|
+
AttachmentsInput,
|
|
28
|
+
HeadersInput,
|
|
29
|
+
AdditionalMailOptions,
|
|
30
|
+
AdditionalSmsOptions,
|
|
31
|
+
} from './operationInputs';
|
|
32
|
+
export type { LimeMarketingErrorBody } from './transportError';
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// Named types for the shapes n8n's `getNodeParameter` returns for our
|
|
2
|
+
// fixedCollection / collection inputs. The shapes are dictated by the
|
|
3
|
+
// `properties[]` definitions in each send.operation.ts; lifting them here
|
|
4
|
+
// gives us one source of truth and lets call sites avoid inline `as { ... }`
|
|
5
|
+
// structures.
|
|
6
|
+
|
|
7
|
+
export type TagListInput = {
|
|
8
|
+
tag?: { name: string; value?: string }[];
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export type AttachmentsInput = {
|
|
12
|
+
attachment?: {
|
|
13
|
+
binaryPropertyName: string;
|
|
14
|
+
fileNameOverride?: string;
|
|
15
|
+
}[];
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export type HeadersInput = {
|
|
19
|
+
header?: { name: string; value: string }[];
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export type AdditionalMailOptions = {
|
|
23
|
+
senderName?: string;
|
|
24
|
+
senderEmail?: string;
|
|
25
|
+
replyTo?: string;
|
|
26
|
+
scheduledSendDate?: string;
|
|
27
|
+
externalId?: string;
|
|
28
|
+
excludePublicationOptouts?: boolean;
|
|
29
|
+
excludeTotalOptouts?: boolean;
|
|
30
|
+
excludePreviousBounce?: boolean;
|
|
31
|
+
linkBaseUrl?: string;
|
|
32
|
+
includeEmailDataInWebhookPayload?: boolean;
|
|
33
|
+
headers?: HeadersInput;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export type AdditionalSmsOptions = {
|
|
37
|
+
maxParts?: number | null;
|
|
38
|
+
deliveryTimeoutHours?: number | null;
|
|
39
|
+
scheduledSendDate?: string;
|
|
40
|
+
};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
export type AttachmentModel = {
|
|
2
|
+
FileData: string;
|
|
3
|
+
FileNameWithExtension: string;
|
|
4
|
+
MimeType: string;
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
export type TagModel = {
|
|
8
|
+
Name: string;
|
|
9
|
+
Value?: string;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export type SendTransactionMailBase = {
|
|
13
|
+
RecipientEmail: string;
|
|
14
|
+
RecipientName?: string;
|
|
15
|
+
SenderName?: string;
|
|
16
|
+
SenderEmail?: string;
|
|
17
|
+
FromName?: string;
|
|
18
|
+
FromEmail?: string;
|
|
19
|
+
ReplyTo?: string;
|
|
20
|
+
Subject?: string;
|
|
21
|
+
ScheduledSendDate?: string;
|
|
22
|
+
ExternalId?: string;
|
|
23
|
+
Attachments?: AttachmentModel[];
|
|
24
|
+
TrackOpenings?: boolean;
|
|
25
|
+
ExcludePublicationOptouts?: boolean;
|
|
26
|
+
ExcludeTotaloptouts?: boolean;
|
|
27
|
+
ExcludePreviousBounce?: boolean;
|
|
28
|
+
TrackLinkClicks?: boolean;
|
|
29
|
+
LinkBaseUrl?: string;
|
|
30
|
+
HtmlContentTagModels?: TagModel[];
|
|
31
|
+
TextContentTagModels?: TagModel[];
|
|
32
|
+
Headers?: Record<string, string>;
|
|
33
|
+
IncludeEmailDataInWebhookPayload?: boolean;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export type SendTransactionMailArgs = SendTransactionMailBase & {
|
|
37
|
+
HtmlContent?: number[];
|
|
38
|
+
TextContent?: number[];
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export type SendTransactionMailTemplateArgs = SendTransactionMailBase & {
|
|
42
|
+
TemplateId: number;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export type TransactionMailModel = {
|
|
46
|
+
TransactionMailId: number;
|
|
47
|
+
RecipientName: string;
|
|
48
|
+
RecipientEmail: string;
|
|
49
|
+
SenderName: string;
|
|
50
|
+
SenderEmail: string;
|
|
51
|
+
FromName: string;
|
|
52
|
+
FromEmail: string;
|
|
53
|
+
ReplyTo: string;
|
|
54
|
+
Subject: string;
|
|
55
|
+
TrackOpenings: boolean;
|
|
56
|
+
TrackLinkClicks: boolean;
|
|
57
|
+
LinkBaseUrl: string;
|
|
58
|
+
ExternalId: string;
|
|
59
|
+
ExcludeTotalOptouts: boolean;
|
|
60
|
+
ExcludePublicationOptouts: boolean;
|
|
61
|
+
ExcludePreviousBounce: boolean;
|
|
62
|
+
IsInternalMail: boolean;
|
|
63
|
+
CreationDate: string;
|
|
64
|
+
IncludeEmailDataInWebhookPayload: boolean;
|
|
65
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { TagModel } from './transactionMail';
|
|
2
|
+
|
|
3
|
+
export type SendTransactionSmsArgs = {
|
|
4
|
+
Text: string;
|
|
5
|
+
FromNumber: string;
|
|
6
|
+
DestinationNumber: string;
|
|
7
|
+
MaxParts?: number;
|
|
8
|
+
DeliveryTimeoutHours?: number;
|
|
9
|
+
ScheduledSendDate?: string;
|
|
10
|
+
TextContentTagModels?: TagModel[];
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export type TransactionSmsModel = {
|
|
14
|
+
TransactionSmsId: number;
|
|
15
|
+
DestinationNumber: string;
|
|
16
|
+
FromNumber: string;
|
|
17
|
+
MaxParts: number | null;
|
|
18
|
+
ScheduledSendTime: string | null;
|
|
19
|
+
Text: string;
|
|
20
|
+
DeliveryTimeoutHours: number;
|
|
21
|
+
CreationDate: string;
|
|
22
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { INodeProperties } from 'n8n-workflow';
|
|
2
|
+
import { SEND_OPERATION, TRANSACTIONAL_EMAIL_RESOURCE } from '../../models';
|
|
3
|
+
import * as send from './operations/send.operation';
|
|
4
|
+
|
|
5
|
+
export const transactionMailFields: INodeProperties[] = [
|
|
6
|
+
{
|
|
7
|
+
displayName: 'Operation',
|
|
8
|
+
name: 'operation',
|
|
9
|
+
type: 'options',
|
|
10
|
+
noDataExpression: true,
|
|
11
|
+
displayOptions: {
|
|
12
|
+
show: { resource: [TRANSACTIONAL_EMAIL_RESOURCE] },
|
|
13
|
+
},
|
|
14
|
+
options: [send.description],
|
|
15
|
+
default: SEND_OPERATION,
|
|
16
|
+
},
|
|
17
|
+
...send.properties,
|
|
18
|
+
];
|
|
19
|
+
|
|
20
|
+
export const transactionMailOperations = {
|
|
21
|
+
[SEND_OPERATION]: send.execute,
|
|
22
|
+
};
|