n8n-nodes-instapage 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/dist/credentials/InstapageApi.credentials.d.ts +7 -0
- package/dist/credentials/InstapageApi.credentials.js +22 -0
- package/dist/credentials/InstapageApi.credentials.js.map +1 -0
- package/dist/nodes/Instapage/GenericFunctions.d.ts +11 -0
- package/dist/nodes/Instapage/GenericFunctions.js +55 -0
- package/dist/nodes/Instapage/GenericFunctions.js.map +1 -0
- package/dist/nodes/Instapage/Instapage.node.d.ts +11 -0
- package/dist/nodes/Instapage/Instapage.node.js +159 -0
- package/dist/nodes/Instapage/Instapage.node.js.map +1 -0
- package/dist/nodes/Instapage/InstapageTrigger.node.d.ts +11 -0
- package/dist/nodes/Instapage/InstapageTrigger.node.js +130 -0
- package/dist/nodes/Instapage/InstapageTrigger.node.js.map +1 -0
- package/dist/nodes/Instapage/instapage.svg +7 -0
- package/package.json +49 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InstapageApi = void 0;
|
|
4
|
+
class InstapageApi {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.name = 'instapageApi';
|
|
7
|
+
this.displayName = 'Instapage API';
|
|
8
|
+
this.documentationUrl = 'https://devdocs.instapage.com/';
|
|
9
|
+
this.properties = [
|
|
10
|
+
{
|
|
11
|
+
displayName: 'API Token',
|
|
12
|
+
name: 'apiToken',
|
|
13
|
+
type: 'string',
|
|
14
|
+
typeOptions: { password: true },
|
|
15
|
+
default: '',
|
|
16
|
+
description: 'Your Instapage API token. Find it under Account Settings at https://app.instapage.com/account. Use an account-level token to access all workspaces.',
|
|
17
|
+
},
|
|
18
|
+
];
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.InstapageApi = InstapageApi;
|
|
22
|
+
//# sourceMappingURL=InstapageApi.credentials.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InstapageApi.credentials.js","sourceRoot":"","sources":["../../credentials/InstapageApi.credentials.ts"],"names":[],"mappings":";;;AAEA,MAAa,YAAY;IAAzB;QACC,SAAI,GAAG,cAAc,CAAC;QACtB,gBAAW,GAAG,eAAe,CAAC;QAC9B,qBAAgB,GAAG,gCAAgC,CAAC;QAEpD,eAAU,GAAsB;YAC/B;gBACC,WAAW,EAAE,WAAW;gBACxB,IAAI,EAAE,UAAU;gBAChB,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE;gBAC/B,OAAO,EAAE,EAAE;gBACX,WAAW,EAAE,qJAAqJ;aAClK;SACD,CAAC;IACH,CAAC;CAAA;AAfD,oCAeC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { IExecuteFunctions, IHookFunctions, ILoadOptionsFunctions, IPollFunctions, IHttpRequestMethods, IDataObject } from 'n8n-workflow';
|
|
2
|
+
/**
|
|
3
|
+
* Make an authenticated request to the Instapage API v1.
|
|
4
|
+
* Auth: Authorization: Bearer {api_token}
|
|
5
|
+
*/
|
|
6
|
+
export declare function instapageApiRequest(this: IExecuteFunctions | ILoadOptionsFunctions | IHookFunctions | IPollFunctions, method: IHttpRequestMethods, endpoint: string, body?: IDataObject, qs?: IDataObject): Promise<any>;
|
|
7
|
+
/**
|
|
8
|
+
* Fetch all items across paginated responses.
|
|
9
|
+
* Instapage uses page-based pagination with meta.pagination.nextPage.
|
|
10
|
+
*/
|
|
11
|
+
export declare function instapageApiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions | IPollFunctions, method: IHttpRequestMethods, endpoint: string, dataKey: string, qs?: IDataObject): Promise<IDataObject[]>;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.instapageApiRequestAllItems = exports.instapageApiRequest = void 0;
|
|
4
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
5
|
+
const BASE_URL = 'https://api.instapage.com/v1';
|
|
6
|
+
/**
|
|
7
|
+
* Make an authenticated request to the Instapage API v1.
|
|
8
|
+
* Auth: Authorization: Bearer {api_token}
|
|
9
|
+
*/
|
|
10
|
+
async function instapageApiRequest(method, endpoint, body = {}, qs = {}) {
|
|
11
|
+
const credentials = await this.getCredentials('instapageApi');
|
|
12
|
+
const apiToken = credentials.apiToken;
|
|
13
|
+
const options = {
|
|
14
|
+
method,
|
|
15
|
+
qs,
|
|
16
|
+
uri: `${BASE_URL}${endpoint}`,
|
|
17
|
+
json: true,
|
|
18
|
+
headers: {
|
|
19
|
+
Authorization: `Bearer ${apiToken}`,
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
if (Object.keys(body).length > 0) {
|
|
23
|
+
options.body = body;
|
|
24
|
+
}
|
|
25
|
+
try {
|
|
26
|
+
return await this.helpers.request(options);
|
|
27
|
+
}
|
|
28
|
+
catch (error) {
|
|
29
|
+
throw new n8n_workflow_1.NodeApiError(this.getNode(), error);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.instapageApiRequest = instapageApiRequest;
|
|
33
|
+
/**
|
|
34
|
+
* Fetch all items across paginated responses.
|
|
35
|
+
* Instapage uses page-based pagination with meta.pagination.nextPage.
|
|
36
|
+
*/
|
|
37
|
+
async function instapageApiRequestAllItems(method, endpoint, dataKey, qs = {}) {
|
|
38
|
+
var _a;
|
|
39
|
+
const results = [];
|
|
40
|
+
let page = 1;
|
|
41
|
+
while (true) {
|
|
42
|
+
qs.page = page;
|
|
43
|
+
const response = await instapageApiRequest.call(this, method, endpoint, {}, qs);
|
|
44
|
+
const items = (response.data || []);
|
|
45
|
+
results.push(...items);
|
|
46
|
+
const pagination = (_a = response.meta) === null || _a === void 0 ? void 0 : _a.pagination;
|
|
47
|
+
if (!pagination || !pagination.nextPage) {
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
50
|
+
page = pagination.nextPage;
|
|
51
|
+
}
|
|
52
|
+
return results;
|
|
53
|
+
}
|
|
54
|
+
exports.instapageApiRequestAllItems = instapageApiRequestAllItems;
|
|
55
|
+
//# sourceMappingURL=GenericFunctions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GenericFunctions.js","sourceRoot":"","sources":["../../../nodes/Instapage/GenericFunctions.ts"],"names":[],"mappings":";;;AAUA,+CAA4C;AAE5C,MAAM,QAAQ,GAAG,8BAA8B,CAAC;AAEhD;;;GAGG;AACI,KAAK,UAAU,mBAAmB,CAExC,MAA2B,EAC3B,QAAgB,EAChB,OAAoB,EAAE,EACtB,KAAkB,EAAE;IAEpB,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,CAAC;IAC9D,MAAM,QAAQ,GAAG,WAAW,CAAC,QAAkB,CAAC;IAEhD,MAAM,OAAO,GAAoB;QAChC,MAAM;QACN,EAAE;QACF,GAAG,EAAE,GAAG,QAAQ,GAAG,QAAQ,EAAE;QAC7B,IAAI,EAAE,IAAI;QACV,OAAO,EAAE;YACR,aAAa,EAAE,UAAU,QAAQ,EAAE;SACnC;KACD,CAAC;IAEF,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAClC,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC;IACrB,CAAC;IAED,IAAI,CAAC;QACJ,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAC5C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,MAAM,IAAI,2BAAY,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,KAAmB,CAAC,CAAC;IAC7D,CAAC;AACF,CAAC;AA7BD,kDA6BC;AAED;;;GAGG;AACI,KAAK,UAAU,2BAA2B,CAEhD,MAA2B,EAC3B,QAAgB,EAChB,OAAe,EACf,KAAkB,EAAE;;IAEpB,MAAM,OAAO,GAAkB,EAAE,CAAC;IAClC,IAAI,IAAI,GAAG,CAAC,CAAC;IAEb,OAAO,IAAI,EAAE,CAAC;QACb,EAAE,CAAC,IAAI,GAAG,IAAI,CAAC;QACf,MAAM,QAAQ,GAAG,MAAM,mBAAmB,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;QAEhF,MAAM,KAAK,GAAG,CAAC,QAAQ,CAAC,IAAI,IAAI,EAAE,CAAkB,CAAC;QACrD,OAAO,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC;QAEvB,MAAM,UAAU,GAAG,MAAA,QAAQ,CAAC,IAAI,0CAAE,UAAU,CAAC;QAC7C,IAAI,CAAC,UAAU,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC;YACzC,MAAM;QACP,CAAC;QAED,IAAI,GAAG,UAAU,CAAC,QAAkB,CAAC;IACtC,CAAC;IAED,OAAO,OAAO,CAAC;AAChB,CAAC;AA1BD,kEA0BC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { IExecuteFunctions, INodeExecutionData, INodeType, INodeTypeDescription, ILoadOptionsFunctions, INodePropertyOptions } from 'n8n-workflow';
|
|
2
|
+
export declare class Instapage implements INodeType {
|
|
3
|
+
description: INodeTypeDescription;
|
|
4
|
+
methods: {
|
|
5
|
+
loadOptions: {
|
|
6
|
+
getWorkspaces(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]>;
|
|
7
|
+
getPages(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]>;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Instapage = void 0;
|
|
4
|
+
const GenericFunctions_1 = require("./GenericFunctions");
|
|
5
|
+
class Instapage {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.description = {
|
|
8
|
+
displayName: 'Instapage',
|
|
9
|
+
name: 'instapage',
|
|
10
|
+
icon: 'file:instapage.svg',
|
|
11
|
+
group: ['transform'],
|
|
12
|
+
version: 1,
|
|
13
|
+
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
|
|
14
|
+
description: 'Retrieve page and submission data from Instapage',
|
|
15
|
+
defaults: {
|
|
16
|
+
name: 'Instapage',
|
|
17
|
+
},
|
|
18
|
+
inputs: ['main'],
|
|
19
|
+
outputs: ['main'],
|
|
20
|
+
credentials: [
|
|
21
|
+
{
|
|
22
|
+
name: 'instapageApi',
|
|
23
|
+
required: true,
|
|
24
|
+
},
|
|
25
|
+
],
|
|
26
|
+
properties: [
|
|
27
|
+
// ------ Workspace (dynamic) ------
|
|
28
|
+
{
|
|
29
|
+
displayName: 'Workspace',
|
|
30
|
+
name: 'workspaceId',
|
|
31
|
+
type: 'options',
|
|
32
|
+
typeOptions: {
|
|
33
|
+
loadOptionsMethod: 'getWorkspaces',
|
|
34
|
+
},
|
|
35
|
+
required: true,
|
|
36
|
+
default: '',
|
|
37
|
+
description: 'The Instapage workspace to operate on',
|
|
38
|
+
},
|
|
39
|
+
// ------ Resource ------
|
|
40
|
+
{
|
|
41
|
+
displayName: 'Resource',
|
|
42
|
+
name: 'resource',
|
|
43
|
+
type: 'options',
|
|
44
|
+
noDataExpression: true,
|
|
45
|
+
options: [
|
|
46
|
+
{
|
|
47
|
+
name: 'Page',
|
|
48
|
+
value: 'page',
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
default: 'page',
|
|
52
|
+
},
|
|
53
|
+
// ------ Operation ------
|
|
54
|
+
{
|
|
55
|
+
displayName: 'Operation',
|
|
56
|
+
name: 'operation',
|
|
57
|
+
type: 'options',
|
|
58
|
+
noDataExpression: true,
|
|
59
|
+
displayOptions: {
|
|
60
|
+
show: {
|
|
61
|
+
resource: ['page'],
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
options: [
|
|
65
|
+
{
|
|
66
|
+
name: 'Get',
|
|
67
|
+
value: 'get',
|
|
68
|
+
description: 'Retrieve a single page by ID',
|
|
69
|
+
action: 'Get a page',
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
name: 'Get Many',
|
|
73
|
+
value: 'getAll',
|
|
74
|
+
description: 'Retrieve all pages in the workspace',
|
|
75
|
+
action: 'Get all pages',
|
|
76
|
+
},
|
|
77
|
+
],
|
|
78
|
+
default: 'get',
|
|
79
|
+
},
|
|
80
|
+
// ------ Page ID (for Get) ------
|
|
81
|
+
{
|
|
82
|
+
displayName: 'Page',
|
|
83
|
+
name: 'pageId',
|
|
84
|
+
type: 'options',
|
|
85
|
+
typeOptions: {
|
|
86
|
+
loadOptionsMethod: 'getPages',
|
|
87
|
+
loadOptionsDependsOn: ['workspaceId'],
|
|
88
|
+
},
|
|
89
|
+
required: true,
|
|
90
|
+
default: '',
|
|
91
|
+
displayOptions: {
|
|
92
|
+
show: {
|
|
93
|
+
resource: ['page'],
|
|
94
|
+
operation: ['get'],
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
description: 'The page to retrieve details for',
|
|
98
|
+
},
|
|
99
|
+
],
|
|
100
|
+
};
|
|
101
|
+
this.methods = {
|
|
102
|
+
loadOptions: {
|
|
103
|
+
async getWorkspaces() {
|
|
104
|
+
const workspaces = await GenericFunctions_1.instapageApiRequestAllItems.call(this, 'GET', '/workspaces', 'workspaces');
|
|
105
|
+
return workspaces.map((ws) => ({
|
|
106
|
+
name: ws.workspaceName,
|
|
107
|
+
value: ws.workspaceId.toString(),
|
|
108
|
+
}));
|
|
109
|
+
},
|
|
110
|
+
async getPages() {
|
|
111
|
+
const workspaceId = this.getNodeParameter('workspaceId');
|
|
112
|
+
if (!workspaceId) {
|
|
113
|
+
return [];
|
|
114
|
+
}
|
|
115
|
+
const pages = await GenericFunctions_1.instapageApiRequestAllItems.call(this, 'GET', `/workspaces/${workspaceId}/pages`, 'pages');
|
|
116
|
+
return pages.map((page) => ({
|
|
117
|
+
name: page.pageName,
|
|
118
|
+
value: page.pageId.toString(),
|
|
119
|
+
}));
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
async execute() {
|
|
125
|
+
const items = this.getInputData();
|
|
126
|
+
const returnData = [];
|
|
127
|
+
const resource = this.getNodeParameter('resource', 0);
|
|
128
|
+
const operation = this.getNodeParameter('operation', 0);
|
|
129
|
+
const workspaceId = this.getNodeParameter('workspaceId', 0);
|
|
130
|
+
for (let i = 0; i < items.length; i++) {
|
|
131
|
+
try {
|
|
132
|
+
if (resource === 'page') {
|
|
133
|
+
if (operation === 'get') {
|
|
134
|
+
const pageId = this.getNodeParameter('pageId', i);
|
|
135
|
+
const response = await GenericFunctions_1.instapageApiRequest.call(this, 'GET', `/workspaces/${workspaceId}/pages/${pageId}`);
|
|
136
|
+
const pageData = response.data || response;
|
|
137
|
+
returnData.push({ json: pageData });
|
|
138
|
+
}
|
|
139
|
+
else if (operation === 'getAll') {
|
|
140
|
+
const pages = await GenericFunctions_1.instapageApiRequestAllItems.call(this, 'GET', `/workspaces/${workspaceId}/pages`, 'pages');
|
|
141
|
+
for (const page of pages) {
|
|
142
|
+
returnData.push({ json: page });
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
catch (error) {
|
|
148
|
+
if (this.continueOnFail()) {
|
|
149
|
+
returnData.push({ json: { error: error.message } });
|
|
150
|
+
continue;
|
|
151
|
+
}
|
|
152
|
+
throw error;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
return [returnData];
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
exports.Instapage = Instapage;
|
|
159
|
+
//# sourceMappingURL=Instapage.node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Instapage.node.js","sourceRoot":"","sources":["../../../nodes/Instapage/Instapage.node.ts"],"names":[],"mappings":";;;AAUA,yDAG4B;AAE5B,MAAa,SAAS;IAAtB;QACC,gBAAW,GAAyB;YACnC,WAAW,EAAE,WAAW;YACxB,IAAI,EAAE,WAAW;YACjB,IAAI,EAAE,oBAAoB;YAC1B,KAAK,EAAE,CAAC,WAAW,CAAC;YACpB,OAAO,EAAE,CAAC;YACV,QAAQ,EAAE,8DAA8D;YACxE,WAAW,EAAE,kDAAkD;YAC/D,QAAQ,EAAE;gBACT,IAAI,EAAE,WAAW;aACjB;YACD,MAAM,EAAE,CAAC,MAAM,CAAC;YAChB,OAAO,EAAE,CAAC,MAAM,CAAC;YACjB,WAAW,EAAE;gBACZ;oBACC,IAAI,EAAE,cAAc;oBACpB,QAAQ,EAAE,IAAI;iBACd;aACD;YACD,UAAU,EAAE;gBACX,oCAAoC;gBACpC;oBACC,WAAW,EAAE,WAAW;oBACxB,IAAI,EAAE,aAAa;oBACnB,IAAI,EAAE,SAAS;oBACf,WAAW,EAAE;wBACZ,iBAAiB,EAAE,eAAe;qBAClC;oBACD,QAAQ,EAAE,IAAI;oBACd,OAAO,EAAE,EAAE;oBACX,WAAW,EAAE,uCAAuC;iBACpD;gBAED,yBAAyB;gBACzB;oBACC,WAAW,EAAE,UAAU;oBACvB,IAAI,EAAE,UAAU;oBAChB,IAAI,EAAE,SAAS;oBACf,gBAAgB,EAAE,IAAI;oBACtB,OAAO,EAAE;wBACR;4BACC,IAAI,EAAE,MAAM;4BACZ,KAAK,EAAE,MAAM;yBACb;qBACD;oBACD,OAAO,EAAE,MAAM;iBACf;gBAED,0BAA0B;gBAC1B;oBACC,WAAW,EAAE,WAAW;oBACxB,IAAI,EAAE,WAAW;oBACjB,IAAI,EAAE,SAAS;oBACf,gBAAgB,EAAE,IAAI;oBACtB,cAAc,EAAE;wBACf,IAAI,EAAE;4BACL,QAAQ,EAAE,CAAC,M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AAQ,CAAC;wBAC3C,UAAU,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,QAAuB,EAAE,CAAC,CAAC;oBAEpD,CAAC;yBAAM,IAAI,SAAS,KAAK,QAAQ,EAAE,CAAC;wBACnC,MAAM,KAAK,GAAG,MAAM,8CAA2B,CAAC,IAAI,CACnD,IAAI,EACJ,KAAK,EACL,eAAe,WAAW,QAAQ,EAClC,OAAO,CACP,CAAC;wBAEF,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;4BAC1B,UAAU,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;wBACjC,CAAC;oBACF,CAAC;gBACF,CAAC;YACF,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBAChB,IAAI,IAAI,CAAC,cAAc,EAAE,EAAE,CAAC;oBAC3B,UAAU,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,EAAE,KAAK,EAAG,KAAe,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;oBAC/D,SAAS;gBACV,CAAC;gBACD,MAAM,KAAK,CAAC;YACb,CAAC;QACF,CAAC;QAED,OAAO,CAAC,UAAU,CAAC,CAAC;IACrB,CAAC;CACD;AAtLD,8BAsLC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { IPollFunctions, INodeExecutionData, INodeType, INodeTypeDescription, ILoadOptionsFunctions, INodePropertyOptions } from 'n8n-workflow';
|
|
2
|
+
export declare class InstapageTrigger implements INodeType {
|
|
3
|
+
description: INodeTypeDescription;
|
|
4
|
+
methods: {
|
|
5
|
+
loadOptions: {
|
|
6
|
+
getWorkspaces(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]>;
|
|
7
|
+
getPages(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]>;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
poll(this: IPollFunctions): Promise<INodeExecutionData[][] | null>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InstapageTrigger = void 0;
|
|
4
|
+
const GenericFunctions_1 = require("./GenericFunctions");
|
|
5
|
+
class InstapageTrigger {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.description = {
|
|
8
|
+
displayName: 'Instapage Trigger',
|
|
9
|
+
name: 'instapageTrigger',
|
|
10
|
+
icon: 'file:instapage.svg',
|
|
11
|
+
group: ['trigger'],
|
|
12
|
+
version: 1,
|
|
13
|
+
subtitle: '=New Form Submission',
|
|
14
|
+
description: 'Triggers when a new form submission is received on an Instapage landing page',
|
|
15
|
+
defaults: {
|
|
16
|
+
name: 'Instapage Trigger',
|
|
17
|
+
},
|
|
18
|
+
polling: true,
|
|
19
|
+
inputs: [],
|
|
20
|
+
outputs: ['main'],
|
|
21
|
+
credentials: [
|
|
22
|
+
{
|
|
23
|
+
name: 'instapageApi',
|
|
24
|
+
required: true,
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
properties: [
|
|
28
|
+
// ------ Workspace (dynamic) ------
|
|
29
|
+
{
|
|
30
|
+
displayName: 'Workspace',
|
|
31
|
+
name: 'workspaceId',
|
|
32
|
+
type: 'options',
|
|
33
|
+
typeOptions: {
|
|
34
|
+
loadOptionsMethod: 'getWorkspaces',
|
|
35
|
+
},
|
|
36
|
+
required: true,
|
|
37
|
+
default: '',
|
|
38
|
+
description: 'The Instapage workspace to listen for form submissions on. All pages in this workspace are monitored.',
|
|
39
|
+
},
|
|
40
|
+
// ------ Page filter (optional, dynamic) ------
|
|
41
|
+
{
|
|
42
|
+
displayName: 'Page (Optional)',
|
|
43
|
+
name: 'pageId',
|
|
44
|
+
type: 'options',
|
|
45
|
+
typeOptions: {
|
|
46
|
+
loadOptionsMethod: 'getPages',
|
|
47
|
+
loadOptionsDependsOn: ['workspaceId'],
|
|
48
|
+
},
|
|
49
|
+
default: '',
|
|
50
|
+
description: 'Optionally filter to a specific page. Leave empty to receive submissions from all pages in the workspace.',
|
|
51
|
+
},
|
|
52
|
+
],
|
|
53
|
+
};
|
|
54
|
+
this.methods = {
|
|
55
|
+
loadOptions: {
|
|
56
|
+
async getWorkspaces() {
|
|
57
|
+
const workspaces = await GenericFunctions_1.instapageApiRequestAllItems.call(this, 'GET', '/workspaces', 'workspaces');
|
|
58
|
+
return workspaces.map((ws) => ({
|
|
59
|
+
name: ws.workspaceName,
|
|
60
|
+
value: ws.workspaceId.toString(),
|
|
61
|
+
}));
|
|
62
|
+
},
|
|
63
|
+
async getPages() {
|
|
64
|
+
const workspaceId = this.getNodeParameter('workspaceId');
|
|
65
|
+
if (!workspaceId) {
|
|
66
|
+
return [];
|
|
67
|
+
}
|
|
68
|
+
const pages = await GenericFunctions_1.instapageApiRequestAllItems.call(this, 'GET', `/workspaces/${workspaceId}/pages`, 'pages');
|
|
69
|
+
const options = [
|
|
70
|
+
{
|
|
71
|
+
name: 'All Pages',
|
|
72
|
+
value: '',
|
|
73
|
+
},
|
|
74
|
+
];
|
|
75
|
+
for (const page of pages) {
|
|
76
|
+
options.push({
|
|
77
|
+
name: page.pageName,
|
|
78
|
+
value: page.pageId.toString(),
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
return options;
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
async poll() {
|
|
87
|
+
const staticData = this.getWorkflowStaticData('node');
|
|
88
|
+
const workspaceId = this.getNodeParameter('workspaceId');
|
|
89
|
+
const pageId = this.getNodeParameter('pageId');
|
|
90
|
+
const isManualTest = this.getMode() === 'manual';
|
|
91
|
+
// Fetch submissions — the API returns them with createdAt timestamps
|
|
92
|
+
const allSubmissions = await GenericFunctions_1.instapageApiRequestAllItems.call(this, 'GET', `/workspaces/${workspaceId}/submissions`, 'submissions');
|
|
93
|
+
// Track which submission IDs we've already seen
|
|
94
|
+
const seenSubmissionIds = (staticData.seenSubmissionIds || []);
|
|
95
|
+
const lastPollTime = (staticData.lastPollTime || 0);
|
|
96
|
+
const now = Math.floor(Date.now() / 1000);
|
|
97
|
+
const newSubmissions = [];
|
|
98
|
+
const updatedSeenIds = [];
|
|
99
|
+
for (const submission of allSubmissions) {
|
|
100
|
+
const submissionId = submission.submissionId || submission.id;
|
|
101
|
+
const submissionPageId = submission.pageId;
|
|
102
|
+
const createdAt = submission.createdAt || 0;
|
|
103
|
+
// Optional page filter
|
|
104
|
+
if (pageId && submissionPageId && submissionPageId.toString() !== pageId) {
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
updatedSeenIds.push(submissionId);
|
|
108
|
+
if (isManualTest) {
|
|
109
|
+
// Manual test: return recent submissions so the user can see data
|
|
110
|
+
newSubmissions.push({ json: submission });
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
// Only emit submissions we haven't seen before
|
|
114
|
+
// Use both ID tracking and timestamp as a safety net
|
|
115
|
+
if (!seenSubmissionIds.includes(submissionId) && createdAt >= lastPollTime) {
|
|
116
|
+
newSubmissions.push({ json: submission });
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
// Update state for next poll
|
|
120
|
+
staticData.lastPollTime = now;
|
|
121
|
+
// Keep only the most recent 1000 IDs to prevent unbounded growth
|
|
122
|
+
staticData.seenSubmissionIds = updatedSeenIds.slice(0, 1000);
|
|
123
|
+
if (newSubmissions.length === 0) {
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
126
|
+
return [newSubmissions];
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
exports.InstapageTrigger = InstapageTrigger;
|
|
130
|
+
//# sourceMappingURL=InstapageTrigger.node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InstapageTrigger.node.js","sourceRoot":"","sources":["../../../nodes/Instapage/InstapageTrigger.node.ts"],"names":[],"mappings":";;;AAUA,yDAG4B;AAE5B,MAAa,gBAAgB;IAA7B;QACC,gBAAW,GAAyB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IAAI,cAAc,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACjC,OAAO,IAAI,CAAC;QACb,CAAC;QAED,OAAO,CAAC,cAAc,CAAC,CAAC;IACzB,CAAC;CACD;AA5JD,4CA4JC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" fill="none">
|
|
2
|
+
<rect width="64" height="64" rx="12" fill="#1E88E5"/>
|
|
3
|
+
<path d="M20 16h8v32h-8V16z" fill="#fff"/>
|
|
4
|
+
<path d="M20 16h24v8H20v-8z" fill="#fff"/>
|
|
5
|
+
<path d="M36 16h8v20h-8V16z" fill="#fff"/>
|
|
6
|
+
<path d="M28 28h16v8H28v-8z" fill="#fff"/>
|
|
7
|
+
</svg>
|
package/package.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "n8n-nodes-instapage",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "n8n community node for Instapage — form submission triggers and page retrieval",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"n8n-community-node-package",
|
|
7
|
+
"n8n",
|
|
8
|
+
"instapage",
|
|
9
|
+
"landing-pages",
|
|
10
|
+
"form-submissions",
|
|
11
|
+
"leads"
|
|
12
|
+
],
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"author": {
|
|
15
|
+
"name": "Webrunner Agents"
|
|
16
|
+
},
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "https://github.com/theCamArsenault-Boomerang/node-construction-site.git"
|
|
20
|
+
},
|
|
21
|
+
"main": "index.js",
|
|
22
|
+
"scripts": {
|
|
23
|
+
"build": "tsc && cp nodes/Instapage/instapage.svg dist/nodes/Instapage/instapage.svg",
|
|
24
|
+
"dev": "tsc --watch",
|
|
25
|
+
"lint": "tsc --noEmit",
|
|
26
|
+
"prepublishOnly": "npm run build"
|
|
27
|
+
},
|
|
28
|
+
"files": [
|
|
29
|
+
"dist"
|
|
30
|
+
],
|
|
31
|
+
"n8n": {
|
|
32
|
+
"n8nNodesApiVersion": 1,
|
|
33
|
+
"nodes": [
|
|
34
|
+
"dist/nodes/Instapage/Instapage.node.js",
|
|
35
|
+
"dist/nodes/Instapage/InstapageTrigger.node.js"
|
|
36
|
+
],
|
|
37
|
+
"credentials": [
|
|
38
|
+
"dist/credentials/InstapageApi.credentials.js"
|
|
39
|
+
]
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@types/node": "^20.0.0",
|
|
43
|
+
"n8n-workflow": "*",
|
|
44
|
+
"typescript": "~5.3.0"
|
|
45
|
+
},
|
|
46
|
+
"peerDependencies": {
|
|
47
|
+
"n8n-workflow": "*"
|
|
48
|
+
}
|
|
49
|
+
}
|