@optimizely-campaign/n8n-nodes-optimizely-campaign 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.
Files changed (52) hide show
  1. package/LICENSE.md +19 -0
  2. package/README.md +29 -0
  3. package/dist/credentials/OptimizelyCampaignApi.credentials.d.ts +10 -0
  4. package/dist/credentials/OptimizelyCampaignApi.credentials.js +51 -0
  5. package/dist/credentials/OptimizelyCampaignApi.credentials.js.map +1 -0
  6. package/dist/icons/optimizely.dark.svg +1 -0
  7. package/dist/icons/optimizely.svg +1 -0
  8. package/dist/nodes/OptimizelyCampaign/OptimizelyCampaign.node.d.ts +20 -0
  9. package/dist/nodes/OptimizelyCampaign/OptimizelyCampaign.node.js +333 -0
  10. package/dist/nodes/OptimizelyCampaign/OptimizelyCampaign.node.js.map +1 -0
  11. package/dist/nodes/OptimizelyCampaign/OptimizelyCampaignTrigger.node.d.ts +12 -0
  12. package/dist/nodes/OptimizelyCampaign/OptimizelyCampaignTrigger.node.js +285 -0
  13. package/dist/nodes/OptimizelyCampaign/OptimizelyCampaignTrigger.node.js.map +1 -0
  14. package/dist/nodes/OptimizelyCampaign/actions/recipient/Recipient.resource.d.ts +10 -0
  15. package/dist/nodes/OptimizelyCampaign/actions/recipient/Recipient.resource.js +179 -0
  16. package/dist/nodes/OptimizelyCampaign/actions/recipient/Recipient.resource.js.map +1 -0
  17. package/dist/nodes/OptimizelyCampaign/actions/router.d.ts +2 -0
  18. package/dist/nodes/OptimizelyCampaign/actions/router.js +64 -0
  19. package/dist/nodes/OptimizelyCampaign/actions/router.js.map +1 -0
  20. package/dist/nodes/OptimizelyCampaign/actions/transactionalMail/TransactionalMail.resource.d.ts +4 -0
  21. package/dist/nodes/OptimizelyCampaign/actions/transactionalMail/TransactionalMail.resource.js +48 -0
  22. package/dist/nodes/OptimizelyCampaign/actions/transactionalMail/TransactionalMail.resource.js.map +1 -0
  23. package/dist/nodes/OptimizelyCampaign/descriptions/recipient.description.d.ts +2 -0
  24. package/dist/nodes/OptimizelyCampaign/descriptions/recipient.description.js +165 -0
  25. package/dist/nodes/OptimizelyCampaign/descriptions/recipient.description.js.map +1 -0
  26. package/dist/nodes/OptimizelyCampaign/descriptions/transactionalMail.description.d.ts +2 -0
  27. package/dist/nodes/OptimizelyCampaign/descriptions/transactionalMail.description.js +82 -0
  28. package/dist/nodes/OptimizelyCampaign/descriptions/transactionalMail.description.js.map +1 -0
  29. package/dist/nodes/OptimizelyCampaign/helpers/constants.d.ts +3 -0
  30. package/dist/nodes/OptimizelyCampaign/helpers/constants.js +7 -0
  31. package/dist/nodes/OptimizelyCampaign/helpers/constants.js.map +1 -0
  32. package/dist/nodes/OptimizelyCampaign/helpers/types.d.ts +209 -0
  33. package/dist/nodes/OptimizelyCampaign/helpers/types.js +14 -0
  34. package/dist/nodes/OptimizelyCampaign/helpers/types.js.map +1 -0
  35. package/dist/nodes/OptimizelyCampaign/helpers/utils.d.ts +2 -0
  36. package/dist/nodes/OptimizelyCampaign/helpers/utils.js +29 -0
  37. package/dist/nodes/OptimizelyCampaign/helpers/utils.js.map +1 -0
  38. package/dist/nodes/OptimizelyCampaign/methods/generalFunctions.d.ts +15 -0
  39. package/dist/nodes/OptimizelyCampaign/methods/generalFunctions.js +223 -0
  40. package/dist/nodes/OptimizelyCampaign/methods/generalFunctions.js.map +1 -0
  41. package/dist/nodes/OptimizelyCampaign/methods/index.d.ts +2 -0
  42. package/dist/nodes/OptimizelyCampaign/methods/index.js +8 -0
  43. package/dist/nodes/OptimizelyCampaign/methods/index.js.map +1 -0
  44. package/dist/nodes/OptimizelyCampaign/methods/loadOptions.d.ts +11 -0
  45. package/dist/nodes/OptimizelyCampaign/methods/loadOptions.js +198 -0
  46. package/dist/nodes/OptimizelyCampaign/methods/loadOptions.js.map +1 -0
  47. package/dist/nodes/OptimizelyCampaign/methods/resourceMapping.d.ts +5 -0
  48. package/dist/nodes/OptimizelyCampaign/methods/resourceMapping.js +58 -0
  49. package/dist/nodes/OptimizelyCampaign/methods/resourceMapping.js.map +1 -0
  50. package/dist/package.json +52 -0
  51. package/dist/tsconfig.tsbuildinfo +1 -0
  52. package/package.json +52 -0
@@ -0,0 +1,223 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.webhookHelpers = void 0;
4
+ const n8n_workflow_1 = require("n8n-workflow");
5
+ const constants_1 = require("../helpers/constants");
6
+ exports.webhookHelpers = {
7
+ async getVerifyMailing() {
8
+ var _a, _b;
9
+ const { client: clientId } = (await this.getCredentials(constants_1.CREDENTIALS_KEY));
10
+ let campaigns;
11
+ try {
12
+ campaigns = (await this.helpers.httpRequestWithAuthentication.call(this, constants_1.CREDENTIALS_KEY, {
13
+ method: 'GET',
14
+ baseURL: constants_1.BASE_URL + clientId,
15
+ url: '/smartcampaigns',
16
+ qs: { sort: 'CREATED', direction: 'DESC', offset: 0, limit: 1 },
17
+ headers: { accept: 'application/json' },
18
+ json: true,
19
+ }));
20
+ }
21
+ catch (error) {
22
+ throw new n8n_workflow_1.NodeApiError(this.getNode(), error, { message: 'Failed to fetch Smart Campaigns' });
23
+ }
24
+ if (!((_a = campaigns.elements) === null || _a === void 0 ? void 0 : _a.length)) {
25
+ return 0;
26
+ }
27
+ const smartCampaignId = campaigns.elements[0].id;
28
+ let mailings;
29
+ try {
30
+ mailings = (await this.helpers.httpRequestWithAuthentication.call(this, constants_1.CREDENTIALS_KEY, {
31
+ method: 'GET',
32
+ baseURL: constants_1.BASE_URL + clientId,
33
+ url: `/smartcampaigns/${smartCampaignId}/messages`,
34
+ headers: { accept: 'application/json' },
35
+ json: true,
36
+ }));
37
+ }
38
+ catch (error) {
39
+ throw new n8n_workflow_1.NodeApiError(this.getNode(), error, { message: `Failed to fetch mailings for Smart Campaign ${smartCampaignId}` });
40
+ }
41
+ if (!mailings.length) {
42
+ return 0;
43
+ }
44
+ return (_b = mailings[0].mailingId) !== null && _b !== void 0 ? _b : 0;
45
+ },
46
+ async createSmartCampaign() {
47
+ const { client: clientId } = (await this.getCredentials(constants_1.CREDENTIALS_KEY));
48
+ try {
49
+ const response = (await this.helpers.httpRequestWithAuthentication.call(this, constants_1.CREDENTIALS_KEY, {
50
+ method: 'POST',
51
+ baseURL: constants_1.BASE_URL + clientId,
52
+ url: '/smartcampaigns',
53
+ headers: { 'content-type': 'application/x-www-form-urlencoded' },
54
+ body: {
55
+ name: 'n8n - DO NOT TOUCH',
56
+ },
57
+ json: true,
58
+ }));
59
+ return response;
60
+ }
61
+ catch (e) {
62
+ throw new n8n_workflow_1.NodeApiError(this.getNode(), e);
63
+ }
64
+ },
65
+ async createMailingForSmartCampaign(smartCampaignId) {
66
+ const { client: clientId } = (await this.getCredentials(constants_1.CREDENTIALS_KEY));
67
+ try {
68
+ const response = (await this.helpers.httpRequestWithAuthentication.call(this, constants_1.CREDENTIALS_KEY, {
69
+ method: 'POST',
70
+ baseURL: constants_1.BASE_URL + clientId,
71
+ url: `/smartcampaigns/${smartCampaignId}/messages`,
72
+ headers: { 'content-type': 'application/x-www-form-urlencoded' },
73
+ body: {
74
+ name: 'n8n - webhook verification mailing',
75
+ mediaType: 'email',
76
+ },
77
+ json: true,
78
+ }));
79
+ return response;
80
+ }
81
+ catch (e) {
82
+ throw new n8n_workflow_1.NodeApiError(this.getNode(), e);
83
+ }
84
+ },
85
+ async deleteSmartCampaign(smartCampaignId) {
86
+ const { client: clientId } = (await this.getCredentials(constants_1.CREDENTIALS_KEY));
87
+ try {
88
+ const response = (await this.helpers.httpRequestWithAuthentication.call(this, constants_1.CREDENTIALS_KEY, {
89
+ method: 'DELETE',
90
+ baseURL: constants_1.BASE_URL + clientId,
91
+ url: `/smartcampaigns/${smartCampaignId}`,
92
+ json: true,
93
+ }));
94
+ return response;
95
+ }
96
+ catch (e) {
97
+ throw new n8n_workflow_1.NodeApiError(this.getNode(), e);
98
+ }
99
+ },
100
+ async getWebhooks(offset = 0, limit = 100) {
101
+ const { client: clientId } = (await this.getCredentials(constants_1.CREDENTIALS_KEY));
102
+ try {
103
+ const response = (await this.helpers.httpRequestWithAuthentication.call(this, constants_1.CREDENTIALS_KEY, {
104
+ method: 'GET',
105
+ baseURL: constants_1.BASE_URL + clientId,
106
+ url: '/webhooks',
107
+ qs: {
108
+ sort: 'CREATED',
109
+ direction: 'DESC',
110
+ offset,
111
+ limit,
112
+ integrationId: constants_1.INTEGRATION_ID,
113
+ },
114
+ headers: { accept: 'application/json' },
115
+ json: true,
116
+ }));
117
+ return response;
118
+ }
119
+ catch (e) {
120
+ throw new n8n_workflow_1.NodeApiError(this.getNode(), e);
121
+ }
122
+ },
123
+ getNodeIdFromWebHookUrl(targetUrl) {
124
+ try {
125
+ const url = new URL(targetUrl);
126
+ const excludedValues = new Set(['', ' ', 'webhook', 'webhook-test', 'optimizely']);
127
+ const pathParts = url.pathname
128
+ .split('/')
129
+ .filter((part) => !excludedValues.has(part.toLowerCase()));
130
+ return pathParts.length > 0 ? String(pathParts[0]) : targetUrl;
131
+ }
132
+ catch {
133
+ return targetUrl;
134
+ }
135
+ },
136
+ async createWebhook(webhookType, targetUrl) {
137
+ const { client: clientId } = (await this.getCredentials(constants_1.CREDENTIALS_KEY));
138
+ try {
139
+ const response = (await this.helpers.httpRequestWithAuthentication.call(this, constants_1.CREDENTIALS_KEY, {
140
+ method: 'POST',
141
+ baseURL: constants_1.BASE_URL + clientId,
142
+ url: '/webhooks',
143
+ headers: { 'content-type': 'application/x-www-form-urlencoded' },
144
+ body: {
145
+ type: webhookType,
146
+ format: 'json',
147
+ targetUrl,
148
+ integrationId: constants_1.INTEGRATION_ID,
149
+ },
150
+ json: true,
151
+ }));
152
+ return response;
153
+ }
154
+ catch (e) {
155
+ throw new n8n_workflow_1.NodeApiError(this.getNode(), e);
156
+ }
157
+ },
158
+ async verifyWebhook(webHookId, testWebhookMailingId) {
159
+ const { client: clientId } = (await this.getCredentials(constants_1.CREDENTIALS_KEY));
160
+ try {
161
+ const response = (await this.helpers.httpRequestWithAuthentication.call(this, constants_1.CREDENTIALS_KEY, {
162
+ method: 'GET',
163
+ baseURL: constants_1.BASE_URL + clientId,
164
+ url: `/webhooks/${webHookId}/verify`,
165
+ qs: {
166
+ mailingId: testWebhookMailingId,
167
+ numberOfEvents: 1,
168
+ },
169
+ headers: { accept: 'application/json' },
170
+ json: true,
171
+ }));
172
+ return response;
173
+ }
174
+ catch (e) {
175
+ throw new n8n_workflow_1.NodeApiError(this.getNode(), e);
176
+ }
177
+ },
178
+ async activateWebhook(webHookId) {
179
+ const { client: clientId } = (await this.getCredentials(constants_1.CREDENTIALS_KEY));
180
+ try {
181
+ const response = (await this.helpers.httpRequestWithAuthentication.call(this, constants_1.CREDENTIALS_KEY, {
182
+ method: 'POST',
183
+ baseURL: constants_1.BASE_URL + clientId,
184
+ url: `/webhooks/${webHookId}/activate`,
185
+ json: true,
186
+ }));
187
+ return response;
188
+ }
189
+ catch (e) {
190
+ throw new n8n_workflow_1.NodeApiError(this.getNode(), e);
191
+ }
192
+ },
193
+ async deactivateWebhook(webHookId) {
194
+ const { client: clientId } = (await this.getCredentials(constants_1.CREDENTIALS_KEY));
195
+ try {
196
+ const response = (await this.helpers.httpRequestWithAuthentication.call(this, constants_1.CREDENTIALS_KEY, {
197
+ method: 'POST',
198
+ baseURL: constants_1.BASE_URL + clientId,
199
+ url: `/webhooks/${webHookId}/deactivate`,
200
+ json: true,
201
+ }));
202
+ return response;
203
+ }
204
+ catch (e) {
205
+ throw new n8n_workflow_1.NodeApiError(this.getNode(), e);
206
+ }
207
+ },
208
+ async deleteWebhook(webHookId) {
209
+ const { client: clientId } = (await this.getCredentials(constants_1.CREDENTIALS_KEY));
210
+ try {
211
+ await this.helpers.httpRequestWithAuthentication.call(this, constants_1.CREDENTIALS_KEY, {
212
+ method: 'DELETE',
213
+ baseURL: constants_1.BASE_URL + clientId,
214
+ url: `/webhooks/${webHookId}`,
215
+ json: true,
216
+ });
217
+ }
218
+ catch (e) {
219
+ throw new n8n_workflow_1.NodeApiError(this.getNode(), e);
220
+ }
221
+ },
222
+ };
223
+ //# sourceMappingURL=generalFunctions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generalFunctions.js","sourceRoot":"","sources":["../../../../nodes/OptimizelyCampaign/methods/generalFunctions.ts"],"names":[],"mappings":";;;AAAA,+CAKsB;AACtB,oDAAiF;AAUpE,QAAA,cAAc,GAAG;IAI7B,KAAK,CAAC,gBAAgB;;QAGrB,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,CAAC,MAAM,IAAI,CAAC,cAAc,CAAC,2BAAe,CAAC,CAAuB,CAAC;QAEhG,IAAI,SAAkD,CAAC;QACvD,IAAI,CAAC;YACJ,SAAS,GAAG,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,6BAA6B,CAAC,IAAI,CAAC,IAAI,EAAE,2BAAe,EAAE;gBACzF,MAAM,EAAE,KAAK;gBACb,OAAO,EAAE,oBAAQ,GAAG,QAAQ;gBAC5B,GAAG,EAAE,iBAAiB;gBACtB,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE;gBAC/D,OAAO,EAAE,EAAE,MAAM,EAAE,kBAAkB,EAAE;gBACvC,IAAI,EAAE,IAAI;aACV,CAAC,CAA4C,CAAC;QAChD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,MAAM,IAAI,2BAAY,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,iCAAiC,EAAE,CAAC,CAAC;QAC/F,CAAC;QAED,IAAI,CAAC,CAAA,MAAA,SAAS,CAAC,QAAQ,0CAAE,MAAM,CAAA,EAAE,CAAC;YACjC,OAAO,CAAC,CAAC;QACV,CAAC;QAED,MAAM,eAAe,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAEjD,IAAI,QAA2D,CA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AC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;QAC3C,CAAC;IACF,CAAC;CACD,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const getRecipientLists: (this: import("n8n-workflow").ILoadOptionsFunctions) => Promise<import("n8n-workflow").INodePropertyOptions[]>, getTransactionalRecipientLists: (this: import("n8n-workflow").ILoadOptionsFunctions) => Promise<import("n8n-workflow").INodePropertyOptions[]>, getRecipientListAttributes: (this: import("n8n-workflow").ILoadOptionsFunctions) => Promise<import("n8n-workflow").INodePropertyOptions[]>, getRecipientListIdAttributes: (this: import("n8n-workflow").ILoadOptionsFunctions) => Promise<import("n8n-workflow").INodePropertyOptions[]>, getOptInProcesses: (this: import("n8n-workflow").ILoadOptionsFunctions) => Promise<import("n8n-workflow").INodePropertyOptions[]>, getTransactionalMails: (this: import("n8n-workflow").ILoadOptionsFunctions) => Promise<import("n8n-workflow").INodePropertyOptions[]>, getTransactionalMailRecipientLists: (this: import("n8n-workflow").ILoadOptionsFunctions) => Promise<import("n8n-workflow").INodePropertyOptions[]>;
2
+ export declare const getCampaignAttributes: (this: import("n8n-workflow").ILoadOptionsFunctions) => Promise<import("n8n-workflow").ResourceMapperFields>, getCampaignAttributesForTransactional: (this: import("n8n-workflow").ILoadOptionsFunctions) => Promise<import("n8n-workflow").ResourceMapperFields>;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getCampaignAttributesForTransactional = exports.getCampaignAttributes = exports.getTransactionalMailRecipientLists = exports.getTransactionalMails = exports.getOptInProcesses = exports.getRecipientListIdAttributes = exports.getRecipientListAttributes = exports.getTransactionalRecipientLists = exports.getRecipientLists = void 0;
4
+ const loadOptions_1 = require("./loadOptions");
5
+ const resourceMapping_1 = require("./resourceMapping");
6
+ exports.getRecipientLists = loadOptions_1.loadOptions.getRecipientLists, exports.getTransactionalRecipientLists = loadOptions_1.loadOptions.getTransactionalRecipientLists, exports.getRecipientListAttributes = loadOptions_1.loadOptions.getRecipientListAttributes, exports.getRecipientListIdAttributes = loadOptions_1.loadOptions.getRecipientListIdAttributes, exports.getOptInProcesses = loadOptions_1.loadOptions.getOptInProcesses, exports.getTransactionalMails = loadOptions_1.loadOptions.getTransactionalMails, exports.getTransactionalMailRecipientLists = loadOptions_1.loadOptions.getTransactionalMailRecipientLists;
7
+ exports.getCampaignAttributes = resourceMapping_1.resourceMapping.getCampaignAttributes, exports.getCampaignAttributesForTransactional = resourceMapping_1.resourceMapping.getCampaignAttributesForTransactional;
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../nodes/OptimizelyCampaign/methods/index.ts"],"names":[],"mappings":";;;AAAA,+CAA4C;AAC5C,uDAAoD;AAGnD,yBAAiB,GAOd,yBAAW,oBANd,sCAA8B,GAM3B,yBAAW,iCALd,kCAA0B,GAKvB,yBAAW,6BAJd,oCAA4B,GAIzB,yBAAW,+BAHd,yBAAiB,GAGd,yBAAW,oBAFd,6BAAqB,GAElB,yBAAW,wBADd,0CAAkC,GAC/B,yBAAW,oCAAC;AACD,6BAAqB,GAA4C,iCAAe,wBAAzD,6CAAqC,GAAK,iCAAe,uCAAC"}
@@ -0,0 +1,11 @@
1
+ import { ILoadOptionsFunctions, INodePropertyOptions } from 'n8n-workflow';
2
+ export declare const loadOptions: {
3
+ getRecipientListsInternal(this: ILoadOptionsFunctions, onlyTransactionalLists?: boolean): Promise<INodePropertyOptions[]>;
4
+ getRecipientLists(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]>;
5
+ getTransactionalRecipientLists(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]>;
6
+ getRecipientListAttributes(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]>;
7
+ getRecipientListIdAttributes(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]>;
8
+ getOptInProcesses(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]>;
9
+ getTransactionalMails(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]>;
10
+ getTransactionalMailRecipientLists(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]>;
11
+ };
@@ -0,0 +1,198 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.loadOptions = void 0;
4
+ const constants_1 = require("./../helpers/constants");
5
+ exports.loadOptions = {
6
+ async getRecipientListsInternal(onlyTransactionalLists = false) {
7
+ var _a, _b;
8
+ const returnData = [];
9
+ try {
10
+ const { client: clientId } = (await this.getCredentials(constants_1.CREDENTIALS_KEY));
11
+ let nextUrl = `${constants_1.BASE_URL}${clientId}/recipientlists?includeTestLists=true&sort=created&limit=100`;
12
+ while (nextUrl) {
13
+ const options = { method: 'GET', url: nextUrl, json: true };
14
+ const resp = (await this.helpers.httpRequestWithAuthentication.call(this, constants_1.CREDENTIALS_KEY, options));
15
+ for (const list of (_a = resp.elements) !== null && _a !== void 0 ? _a : []) {
16
+ const isTransactional = Boolean(list.forTransactionApi);
17
+ if (!onlyTransactionalLists || isTransactional) {
18
+ returnData.push({ name: list.name, value: String(list.id) });
19
+ }
20
+ }
21
+ const nextLink = ((_b = resp.links) !== null && _b !== void 0 ? _b : []).find((l) => l.rel === 'next');
22
+ nextUrl = nextLink === null || nextLink === void 0 ? void 0 : nextLink.href;
23
+ }
24
+ }
25
+ catch {
26
+ return [];
27
+ }
28
+ return returnData;
29
+ },
30
+ async getRecipientLists() {
31
+ return await exports.loadOptions.getRecipientListsInternal.call(this, false);
32
+ },
33
+ async getTransactionalRecipientLists() {
34
+ return await exports.loadOptions.getRecipientListsInternal.call(this, true);
35
+ },
36
+ async getRecipientListAttributes() {
37
+ const recipientListId = this.getNodeParameter('recipientListId', 0);
38
+ if (!recipientListId) {
39
+ return [];
40
+ }
41
+ const returnData = [];
42
+ try {
43
+ const { client: clientId } = (await this.getCredentials(constants_1.CREDENTIALS_KEY));
44
+ let requestUrl = `${constants_1.BASE_URL}${clientId}/recipientlists/${recipientListId}/fields?limit=100`;
45
+ while (requestUrl) {
46
+ const options = {
47
+ method: 'GET',
48
+ url: requestUrl,
49
+ json: true,
50
+ };
51
+ const response = (await this.helpers.httpRequestWithAuthentication.call(this, constants_1.CREDENTIALS_KEY, options));
52
+ const elements = response.elements || [];
53
+ for (const field of elements) {
54
+ returnData.push({
55
+ name: field.displayName,
56
+ value: field.internalName,
57
+ });
58
+ }
59
+ const nextLink = response.links.find((link) => link.rel === 'next');
60
+ requestUrl = nextLink ? nextLink.href : undefined;
61
+ }
62
+ }
63
+ catch {
64
+ return [];
65
+ }
66
+ return returnData;
67
+ },
68
+ async getRecipientListIdAttributes() {
69
+ var _a, _b;
70
+ const paramCandidates = ['transactionalMailRecipientListId', 'recipientListId'];
71
+ let recipientListId = '';
72
+ for (const name of paramCandidates) {
73
+ try {
74
+ const val = this.getNodeParameter(name, 0);
75
+ if (val) {
76
+ recipientListId = val;
77
+ break;
78
+ }
79
+ }
80
+ catch {
81
+ }
82
+ }
83
+ if (!recipientListId) {
84
+ return [];
85
+ }
86
+ const returnData = [];
87
+ try {
88
+ const { client: clientId } = (await this.getCredentials(constants_1.CREDENTIALS_KEY));
89
+ let requestUrl = `${constants_1.BASE_URL}${clientId}/recipientlists/${recipientListId}/fields?limit=100`;
90
+ while (requestUrl) {
91
+ const options = {
92
+ method: 'GET',
93
+ url: requestUrl,
94
+ json: true,
95
+ };
96
+ const response = (await this.helpers.httpRequestWithAuthentication.call(this, constants_1.CREDENTIALS_KEY, options));
97
+ const elements = (_a = response.elements) !== null && _a !== void 0 ? _a : [];
98
+ const idFields = elements.filter((field) => field.required === true);
99
+ for (const field of idFields) {
100
+ returnData.push({
101
+ name: field.displayName,
102
+ value: field.internalName,
103
+ });
104
+ }
105
+ const nextLink = ((_b = response.links) !== null && _b !== void 0 ? _b : []).find((l) => l.rel === 'next');
106
+ requestUrl = nextLink === null || nextLink === void 0 ? void 0 : nextLink.href;
107
+ }
108
+ }
109
+ catch {
110
+ return [];
111
+ }
112
+ return returnData;
113
+ },
114
+ async getOptInProcesses() {
115
+ const optInMailings = [];
116
+ try {
117
+ const { client: clientId } = (await this.getCredentials(constants_1.CREDENTIALS_KEY));
118
+ let requestUrl = `${constants_1.BASE_URL}${clientId}/optinprocesses?offset=0&limit=100&hasMailing=true`;
119
+ while (requestUrl) {
120
+ const options = {
121
+ method: 'GET',
122
+ url: requestUrl,
123
+ json: true,
124
+ };
125
+ const response = (await this.helpers.httpRequestWithAuthentication.call(this, constants_1.CREDENTIALS_KEY, options));
126
+ const optInProcesses = response.elements || [];
127
+ for (const optInProcess of optInProcesses) {
128
+ optInMailings.push({
129
+ name: optInProcess.name,
130
+ value: optInProcess.id,
131
+ });
132
+ }
133
+ const nextLink = response.links.find((link) => link.rel === 'next');
134
+ requestUrl = nextLink ? nextLink.href : undefined;
135
+ }
136
+ }
137
+ catch {
138
+ return [];
139
+ }
140
+ return optInMailings;
141
+ },
142
+ async getTransactionalMails() {
143
+ const returnData = [];
144
+ try {
145
+ const { client: clientId } = (await this.getCredentials(constants_1.CREDENTIALS_KEY));
146
+ let requestUrl = `${constants_1.BASE_URL}${clientId}/transactionalmail?offset=0&limit=100&resultView=SUMMARY&sort=created&direction=DESC&status=running`;
147
+ while (requestUrl) {
148
+ const options = {
149
+ method: 'GET',
150
+ url: requestUrl,
151
+ json: true,
152
+ };
153
+ const response = (await this.helpers.httpRequestWithAuthentication.call(this, constants_1.CREDENTIALS_KEY, options));
154
+ const elements = response.elements || [];
155
+ for (const mail of elements) {
156
+ returnData.push({
157
+ name: mail.name,
158
+ value: String(mail.id),
159
+ });
160
+ }
161
+ const nextLink = response.links.find((link) => link.rel === 'next');
162
+ requestUrl = nextLink ? nextLink.href : undefined;
163
+ }
164
+ }
165
+ catch {
166
+ return [];
167
+ }
168
+ return returnData;
169
+ },
170
+ async getTransactionalMailRecipientLists() {
171
+ var _a;
172
+ const transactionalMailId = this.getNodeParameter('transactionalMailId', 0);
173
+ if (!transactionalMailId) {
174
+ return [];
175
+ }
176
+ try {
177
+ const { client: clientId } = (await this.getCredentials(constants_1.CREDENTIALS_KEY));
178
+ const requestUrl = `${constants_1.BASE_URL}${clientId}/transactionalmail/${transactionalMailId}`;
179
+ const options = {
180
+ method: 'GET',
181
+ url: requestUrl,
182
+ json: true,
183
+ };
184
+ const transactionalMailDetails = (await this.helpers.httpRequestWithAuthentication.call(this, constants_1.CREDENTIALS_KEY, options));
185
+ const recipientListIds = (_a = transactionalMailDetails.recipientLists.recipientListIds) !== null && _a !== void 0 ? _a : [];
186
+ if (recipientListIds.length === 0) {
187
+ return [];
188
+ }
189
+ const allTransactionalLists = await exports.loadOptions.getTransactionalRecipientLists.call(this);
190
+ const returnData = allTransactionalLists.filter((list) => recipientListIds.includes(Number(list.value)));
191
+ return returnData;
192
+ }
193
+ catch {
194
+ return [];
195
+ }
196
+ },
197
+ };
198
+ //# sourceMappingURL=loadOptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loadOptions.js","sourceRoot":"","sources":["../../../../nodes/OptimizelyCampaign/methods/loadOptions.ts"],"names":[],"mappings":";;;AACA,sDAAmE;AAStD,QAAA,WAAW,GAAG;IAC1B,KAAK,CAAC,yBAAyB,CAE9B,sBAAsB,GAAG,KAAK;;QAE9B,MAAM,UAAU,GAA2B,EAAE,CAAC;QAE9C,IAAI,CAAC;YACJ,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,CAAC,MAAM,IAAI,CAAC,cAAc,CAAC,2BAAe,CAAC,CAAuB,CAAC;YAChG,IAAI,OAAO,GACV,GAAG,oBAAQ,GAAG,QAAQ,8DAA8D,CAAC;YAEtF,OAAO,OAAO,EAAE,CAAC;gBAChB,MAAM,OAAO,GAAG,EAAE,MAAM,EAAE,KAAc,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;gBACrE,MAAM,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,6BAA6B,CAAC,IA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,IAAI,CAAC,KAAK,CAAC,CAAC,CAC7C,CAAC;YAEF,OAAO,UAAU,CAAC;QACnB,CAAC;QAAC,MAAM,CAAC;YACR,OAAO,EAAE,CAAC;QACX,CAAC;IACF,CAAC;CACD,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { ILoadOptionsFunctions, ResourceMapperFields } from 'n8n-workflow';
2
+ export declare const resourceMapping: {
3
+ getCampaignAttributes(this: ILoadOptionsFunctions): Promise<ResourceMapperFields>;
4
+ getCampaignAttributesForTransactional(this: ILoadOptionsFunctions): Promise<ResourceMapperFields>;
5
+ };
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resourceMapping = void 0;
4
+ const utils_1 = require("../helpers/utils");
5
+ const constants_1 = require("./../helpers/constants");
6
+ async function loadRecipientListFieldsPaged(clientId, recipientListId) {
7
+ var _a, _b;
8
+ const out = [];
9
+ let nextUrl = `${constants_1.BASE_URL}${encodeURIComponent(clientId)}/recipientlists/${recipientListId}/fields?limit=100`;
10
+ while (nextUrl) {
11
+ try {
12
+ const res = (await this.helpers.httpRequestWithAuthentication.call(this, constants_1.CREDENTIALS_KEY, { method: 'GET', url: nextUrl, json: true }));
13
+ out.push(...((_a = res.elements) !== null && _a !== void 0 ? _a : []));
14
+ const nextLink = ((_b = res.links) !== null && _b !== void 0 ? _b : []).find((l) => l.rel === 'next');
15
+ nextUrl = nextLink === null || nextLink === void 0 ? void 0 : nextLink.href;
16
+ }
17
+ catch {
18
+ break;
19
+ }
20
+ }
21
+ return out;
22
+ }
23
+ async function buildMapperFields(listIdParamName, idFieldParamName) {
24
+ const recipientListId = this.getNodeParameter(listIdParamName, 0);
25
+ if (!recipientListId)
26
+ return { fields: [] };
27
+ let recipientIdField;
28
+ if (idFieldParamName) {
29
+ recipientIdField = this.getNodeParameter(idFieldParamName, 0);
30
+ }
31
+ try {
32
+ const { client: clientId } = (await this.getCredentials(constants_1.CREDENTIALS_KEY));
33
+ const fields = await loadRecipientListFieldsPaged.call(this, clientId, recipientListId);
34
+ const attributes = fields
35
+ .filter((f) => !(0, utils_1.isCampaignSystemField)(f.internalName))
36
+ .map((f) => ({
37
+ id: f.internalName,
38
+ displayName: f.displayName,
39
+ required: f.required,
40
+ defaultMatch: recipientIdField ? f.internalName === recipientIdField : false,
41
+ display: true,
42
+ type: (0, utils_1.mapApiTypeToN8nType)(f.type.toString()),
43
+ }));
44
+ return { fields: attributes };
45
+ }
46
+ catch {
47
+ return { fields: [] };
48
+ }
49
+ }
50
+ exports.resourceMapping = {
51
+ async getCampaignAttributes() {
52
+ return buildMapperFields.call(this, 'recipientListId', 'recipientIdField');
53
+ },
54
+ async getCampaignAttributesForTransactional() {
55
+ return buildMapperFields.call(this, 'transactionalMailRecipientListId', 'transactionalMailRecipientIdField');
56
+ },
57
+ };
58
+ //# sourceMappingURL=resourceMapping.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resourceMapping.js","sourceRoot":"","sources":["../../../../nodes/OptimizelyCampaign/methods/resourceMapping.ts"],"names":[],"mappings":";;;AACA,4CAA8E;AAC9E,sDAAmE;AAGnE,KAAK,UAAU,4BAA4B,CAE1C,QAAgB,EAChB,eAAuB;;IAEvB,MAAM,GAAG,GAAoC,EAAE,CAAC;IAChD,IAAI,OAAO,GACV,GAAG,oBAAQ,GAAG,kBAAkB,CAAC,QAAQ,CAAC,mBAAmB,eAAe,mBAAmB,CAAC;IAEjG,OAAO,OAAO,EAAE,CAAC;QAChB,IAAI,CAAC;YACJ,MAAM,GAAG,GAAG,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,6BAA6B,CAAC,IAAI,CACjE,IAAI,EACJ,2BAAe,EACf,EAAE,MAAM,EAAE,KAAc,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CACpD,CAA6C,CAAC;YAE/C,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,MAAA,GAAG,CAAC,QAAQ,mCAAI,EA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C,CAAC,QAAQ;YACpB,YAAY,EAAE,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC,YAAY,KAAK,gBAAgB,CAAC,CAAC,CAAC,KAAK;YAC5E,OAAO,EAAE,IAAI;YACb,IAAI,EAAE,IAAA,2BAAmB,EAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;SAC5C,CAAC,CAAC,CAAC;QAEL,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC;IAC/B,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;IACvB,CAAC;AACF,CAAC;AAEY,QAAA,eAAe,GAAG;IAC9B,KAAK,CAAC,qBAAqB;QAC1B,OAAO,iBAAiB,CAAC,IAAI,CAAC,IAAI,EAAE,iBAAiB,EAAE,kBAAkB,CAAC,CAAC;IAC5E,CAAC;IAED,KAAK,CAAC,qCAAqC;QAG1C,OAAO,iBAAiB,CAAC,IAAI,CAC5B,IAAI,EACJ,kCAAkC,EAClC,mCAAmC,CACnC,CAAC;IACH,CAAC;CACD,CAAC"}
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "@optimizely-campaign/n8n-nodes-optimizely-campaign",
3
+ "version": "0.1.0",
4
+ "description": "n8n community node for interacting with the Optimizely Campaign API",
5
+ "license": "MIT",
6
+ "homepage": "https://www.optimizely.com",
7
+ "keywords": [
8
+ "n8n-community-node-package"
9
+ ],
10
+ "author": {
11
+ "name": "Optimizely Campaign Integration Management Team",
12
+ "email": "integration.management@optimizely.com"
13
+ },
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "https://github.com/optimizely-campaign/campaign-n8n-nodes.git"
17
+ },
18
+ "scripts": {
19
+ "build": "n8n-node build",
20
+ "build:watch": "tsc --watch",
21
+ "dev": "n8n-node dev",
22
+ "lint": "n8n-node lint",
23
+ "lint:fix": "n8n-node lint --fix",
24
+ "release": "n8n-node release",
25
+ "prepublishOnly": "npm run build"
26
+ },
27
+ "files": [
28
+ "dist"
29
+ ],
30
+ "n8n": {
31
+ "n8nNodesApiVersion": 1,
32
+ "strict": true,
33
+ "credentials": [
34
+ "dist/credentials/OptimizelyCampaignApi.credentials.js"
35
+ ],
36
+ "nodes": [
37
+ "dist/nodes/OptimizelyCampaign/OptimizelyCampaign.node.js",
38
+ "dist/nodes/OptimizelyCampaign/OptimizelyCampaignTrigger.node.js"
39
+ ]
40
+ },
41
+ "devDependencies": {
42
+ "@n8n/node-cli": "*",
43
+ "@types/node": "^24.10.0",
44
+ "eslint": "9.32.0",
45
+ "prettier": "3.6.2",
46
+ "release-it": "^19.0.4",
47
+ "typescript": "5.9.2"
48
+ },
49
+ "peerDependencies": {
50
+ "n8n-workflow": "*"
51
+ }
52
+ }