@finlight/n8n-nodes-finlight 0.1.0 → 0.1.2
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/package.json +4 -5
- package/dist/nodes/finlight/actions/FinlightArticleSearch.node.js +0 -217
- package/dist/nodes/finlight/credentials/FinlightApi.credentials.js +0 -18
- package/dist/nodes/finlight/helpers/types.js +0 -2
- package/dist/nodes/finlight/helpers/utils.js +0 -14
- package/dist/nodes/finlight/index.js +0 -6
- package/dist/nodes/finlight/triggers/FinlightWebhookTrigger.node.js +0 -125
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@finlight/n8n-nodes-finlight",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Official n8n integration for finlight: real-time finance and news API",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Ali Büyükkakac",
|
|
@@ -20,17 +20,16 @@
|
|
|
20
20
|
"lint": "eslint . --ext .ts",
|
|
21
21
|
"test": "jest"
|
|
22
22
|
},
|
|
23
|
-
"dependencies": {
|
|
24
|
-
"n8n-core": "^1.14.1",
|
|
25
|
-
"n8n-workflow": "*"
|
|
26
|
-
},
|
|
23
|
+
"dependencies": {},
|
|
27
24
|
"devDependencies": {
|
|
28
25
|
"@types/node": "^24.1.0",
|
|
29
26
|
"@typescript-eslint/eslint-plugin": "^8.38.0",
|
|
30
27
|
"@typescript-eslint/parser": "^8.38.0",
|
|
31
28
|
"eslint": "^9.32.0",
|
|
32
29
|
"eslint-plugin-n8n-nodes-base": "^1.16.3",
|
|
30
|
+
"n8n-core": "^1.14.1",
|
|
33
31
|
"jest": "^29.4.0",
|
|
32
|
+
"n8n-workflow": "*",
|
|
34
33
|
"ts-jest": "^29.4.0",
|
|
35
34
|
"typescript": "^5.8.3"
|
|
36
35
|
},
|
|
@@ -1,217 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FinlightArticleSearch = void 0;
|
|
4
|
-
const n8n_workflow_1 = require("n8n-workflow");
|
|
5
|
-
class FinlightArticleSearch {
|
|
6
|
-
constructor() {
|
|
7
|
-
this.description = {
|
|
8
|
-
displayName: "finlight Article Search",
|
|
9
|
-
name: "finlightArticleSearch",
|
|
10
|
-
group: ["transform"],
|
|
11
|
-
version: 1,
|
|
12
|
-
description: "Search articles using the finlight REST API",
|
|
13
|
-
defaults: {
|
|
14
|
-
name: "finlight Article Search",
|
|
15
|
-
},
|
|
16
|
-
inputs: [n8n_workflow_1.NodeConnectionTypes.Main],
|
|
17
|
-
outputs: [n8n_workflow_1.NodeConnectionTypes.Main],
|
|
18
|
-
icon: "file:../finlight.svg",
|
|
19
|
-
credentials: [
|
|
20
|
-
{
|
|
21
|
-
name: "finlightApi",
|
|
22
|
-
required: true,
|
|
23
|
-
},
|
|
24
|
-
],
|
|
25
|
-
properties: [
|
|
26
|
-
{
|
|
27
|
-
displayName: "Query",
|
|
28
|
-
name: "query",
|
|
29
|
-
type: "string",
|
|
30
|
-
required: false,
|
|
31
|
-
default: "",
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
displayName: "Sources",
|
|
35
|
-
name: "sources",
|
|
36
|
-
type: "fixedCollection",
|
|
37
|
-
placeholder: "Add Source",
|
|
38
|
-
default: {},
|
|
39
|
-
typeOptions: {
|
|
40
|
-
multipleValues: true,
|
|
41
|
-
},
|
|
42
|
-
options: [
|
|
43
|
-
{
|
|
44
|
-
name: "sourceList",
|
|
45
|
-
displayName: "Source List",
|
|
46
|
-
values: [
|
|
47
|
-
{
|
|
48
|
-
displayName: "Source",
|
|
49
|
-
name: "source",
|
|
50
|
-
type: "string",
|
|
51
|
-
default: "",
|
|
52
|
-
},
|
|
53
|
-
],
|
|
54
|
-
},
|
|
55
|
-
],
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
displayName: "Exclude Sources",
|
|
59
|
-
name: "excludeSources",
|
|
60
|
-
type: "fixedCollection",
|
|
61
|
-
placeholder: "Exclude Source",
|
|
62
|
-
default: {},
|
|
63
|
-
typeOptions: {
|
|
64
|
-
multipleValues: true,
|
|
65
|
-
},
|
|
66
|
-
options: [
|
|
67
|
-
{
|
|
68
|
-
name: "sourceList",
|
|
69
|
-
displayName: "Source List",
|
|
70
|
-
values: [
|
|
71
|
-
{
|
|
72
|
-
displayName: "Source",
|
|
73
|
-
name: "source",
|
|
74
|
-
type: "string",
|
|
75
|
-
default: "",
|
|
76
|
-
},
|
|
77
|
-
],
|
|
78
|
-
},
|
|
79
|
-
],
|
|
80
|
-
},
|
|
81
|
-
{
|
|
82
|
-
displayName: "From (ISO date)",
|
|
83
|
-
name: "from",
|
|
84
|
-
type: "string",
|
|
85
|
-
default: "",
|
|
86
|
-
},
|
|
87
|
-
{
|
|
88
|
-
displayName: "To (ISO date)",
|
|
89
|
-
name: "to",
|
|
90
|
-
type: "string",
|
|
91
|
-
default: "",
|
|
92
|
-
},
|
|
93
|
-
{
|
|
94
|
-
displayName: "Language",
|
|
95
|
-
name: "language",
|
|
96
|
-
type: "string",
|
|
97
|
-
default: "en",
|
|
98
|
-
},
|
|
99
|
-
{
|
|
100
|
-
displayName: "Order",
|
|
101
|
-
name: "order",
|
|
102
|
-
type: "options",
|
|
103
|
-
options: [
|
|
104
|
-
{ name: "DESC", value: "DESC" },
|
|
105
|
-
{ name: "ASC", value: "ASC" },
|
|
106
|
-
],
|
|
107
|
-
default: "DESC",
|
|
108
|
-
},
|
|
109
|
-
{
|
|
110
|
-
displayName: "Page Size",
|
|
111
|
-
name: "pageSize",
|
|
112
|
-
type: "number",
|
|
113
|
-
default: 20,
|
|
114
|
-
typeOptions: { minValue: 1, maxValue: 100 },
|
|
115
|
-
},
|
|
116
|
-
{
|
|
117
|
-
displayName: "Page",
|
|
118
|
-
name: "page",
|
|
119
|
-
type: "number",
|
|
120
|
-
default: 1,
|
|
121
|
-
typeOptions: { minValue: 1 },
|
|
122
|
-
},
|
|
123
|
-
{
|
|
124
|
-
displayName: "Include Content",
|
|
125
|
-
name: "includeContent",
|
|
126
|
-
type: "boolean",
|
|
127
|
-
default: false,
|
|
128
|
-
},
|
|
129
|
-
{
|
|
130
|
-
displayName: "Include Entities",
|
|
131
|
-
name: "includeEntities",
|
|
132
|
-
type: "boolean",
|
|
133
|
-
default: false,
|
|
134
|
-
},
|
|
135
|
-
{
|
|
136
|
-
displayName: "Exclude Empty Content",
|
|
137
|
-
name: "excludeEmptyContent",
|
|
138
|
-
type: "boolean",
|
|
139
|
-
default: false,
|
|
140
|
-
},
|
|
141
|
-
{
|
|
142
|
-
displayName: "Tickers",
|
|
143
|
-
name: "tickers",
|
|
144
|
-
type: "fixedCollection",
|
|
145
|
-
placeholder: "Add Ticker",
|
|
146
|
-
default: {},
|
|
147
|
-
typeOptions: {
|
|
148
|
-
multipleValues: true,
|
|
149
|
-
},
|
|
150
|
-
options: [
|
|
151
|
-
{
|
|
152
|
-
name: "tickerList",
|
|
153
|
-
displayName: "Ticker List",
|
|
154
|
-
values: [
|
|
155
|
-
{
|
|
156
|
-
displayName: "Ticker",
|
|
157
|
-
name: "ticker",
|
|
158
|
-
type: "string",
|
|
159
|
-
default: "",
|
|
160
|
-
},
|
|
161
|
-
],
|
|
162
|
-
},
|
|
163
|
-
],
|
|
164
|
-
},
|
|
165
|
-
],
|
|
166
|
-
};
|
|
167
|
-
}
|
|
168
|
-
async execute() {
|
|
169
|
-
const items = this.getInputData();
|
|
170
|
-
const returnData = [];
|
|
171
|
-
const apiKey = (await this.getCredentials("finlightApi"));
|
|
172
|
-
for (let i = 0; i < items.length; i++) {
|
|
173
|
-
const body = {};
|
|
174
|
-
const query = this.getNodeParameter("query", i);
|
|
175
|
-
if (query)
|
|
176
|
-
body.query = query;
|
|
177
|
-
const from = this.getNodeParameter("from", i);
|
|
178
|
-
if (from)
|
|
179
|
-
body.from = from;
|
|
180
|
-
const to = this.getNodeParameter("to", i);
|
|
181
|
-
if (to)
|
|
182
|
-
body.to = to;
|
|
183
|
-
const sourcesRaw = this.getNodeParameter("sources.sourceList", i, []);
|
|
184
|
-
if (sourcesRaw.length) {
|
|
185
|
-
body.sources = sourcesRaw.map(s => s.source);
|
|
186
|
-
}
|
|
187
|
-
const excludeSourcesRaw = this.getNodeParameter("excludeSources.sourceList", i, []);
|
|
188
|
-
if (excludeSourcesRaw.length) {
|
|
189
|
-
body.excludeSources = excludeSourcesRaw.map(s => s.source);
|
|
190
|
-
}
|
|
191
|
-
const tickersRaw = this.getNodeParameter("tickers.tickerList", i, []);
|
|
192
|
-
if (tickersRaw.length) {
|
|
193
|
-
body.tickers = tickersRaw.map(t => t.ticker);
|
|
194
|
-
}
|
|
195
|
-
body.language = this.getNodeParameter("language", i);
|
|
196
|
-
body.order = this.getNodeParameter("order", i);
|
|
197
|
-
body.pageSize = this.getNodeParameter("pageSize", i);
|
|
198
|
-
body.page = this.getNodeParameter("page", i);
|
|
199
|
-
body.includeContent = this.getNodeParameter("includeContent", i);
|
|
200
|
-
body.includeEntities = this.getNodeParameter("includeEntities", i);
|
|
201
|
-
body.excludeEmptyContent = this.getNodeParameter("excludeEmptyContent", i);
|
|
202
|
-
const response = await this.helpers.httpRequest({
|
|
203
|
-
method: "POST",
|
|
204
|
-
url: "https://api.finlight.me/v2/articles",
|
|
205
|
-
headers: {
|
|
206
|
-
"Content-Type": "application/json",
|
|
207
|
-
"x-api-key": apiKey.apiKey,
|
|
208
|
-
},
|
|
209
|
-
body,
|
|
210
|
-
json: true,
|
|
211
|
-
});
|
|
212
|
-
returnData.push(...(Array.isArray(response.articles) ? response.articles : [response]));
|
|
213
|
-
}
|
|
214
|
-
return [this.helpers.returnJsonArray(returnData)];
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
exports.FinlightArticleSearch = FinlightArticleSearch;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FinlightApi = void 0;
|
|
4
|
-
class FinlightApi {
|
|
5
|
-
constructor() {
|
|
6
|
-
this.name = "finlightApi";
|
|
7
|
-
this.displayName = "finlight API Key";
|
|
8
|
-
this.properties = [
|
|
9
|
-
{
|
|
10
|
-
displayName: "API Key",
|
|
11
|
-
name: "apiKey",
|
|
12
|
-
type: "string",
|
|
13
|
-
default: "",
|
|
14
|
-
},
|
|
15
|
-
];
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
exports.FinlightApi = FinlightApi;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getAuthHeaders = getAuthHeaders;
|
|
4
|
-
function getAuthHeaders(params) {
|
|
5
|
-
const headers = {};
|
|
6
|
-
if (params.authentication === "apiKey" && params.apiKey) {
|
|
7
|
-
headers["x-finlight-key"] = params.apiKey;
|
|
8
|
-
}
|
|
9
|
-
if (params.authentication === "basicAuth" && params.credentials) {
|
|
10
|
-
const token = Buffer.from(`${params.credentials.user}:${params.credentials.password}`).toString("base64");
|
|
11
|
-
headers["Authorization"] = `Basic ${token}`;
|
|
12
|
-
}
|
|
13
|
-
return headers;
|
|
14
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.nodes = void 0;
|
|
4
|
-
const FinlightWebhookTrigger_node_1 = require("./triggers/FinlightWebhookTrigger.node");
|
|
5
|
-
const FinlightArticleSearch_node_1 = require("./actions/FinlightArticleSearch.node");
|
|
6
|
-
exports.nodes = [FinlightWebhookTrigger_node_1.FinlightWebhookTrigger, FinlightArticleSearch_node_1.FinlightArticleSearch];
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FinlightWebhookTrigger = void 0;
|
|
4
|
-
const n8n_workflow_1 = require("n8n-workflow");
|
|
5
|
-
class FinlightWebhookTrigger {
|
|
6
|
-
constructor() {
|
|
7
|
-
this.description = {
|
|
8
|
-
displayName: "finlight Webhook Trigger",
|
|
9
|
-
name: "finlightWebhookTrigger",
|
|
10
|
-
group: ["trigger"],
|
|
11
|
-
version: 1,
|
|
12
|
-
description: "Triggers on new webhook events from finlight",
|
|
13
|
-
defaults: {
|
|
14
|
-
name: "finlight Webhook Trigger",
|
|
15
|
-
},
|
|
16
|
-
inputs: [],
|
|
17
|
-
outputs: [n8n_workflow_1.NodeConnectionTypes.Main],
|
|
18
|
-
credentials: [
|
|
19
|
-
{
|
|
20
|
-
name: "finlightApi",
|
|
21
|
-
required: true,
|
|
22
|
-
displayOptions: {
|
|
23
|
-
show: {
|
|
24
|
-
authentication: ["apiKey"],
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
name: "httpBasicAuth",
|
|
30
|
-
required: true,
|
|
31
|
-
displayOptions: {
|
|
32
|
-
show: {
|
|
33
|
-
authentication: ["basicAuth"],
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
],
|
|
38
|
-
properties: [
|
|
39
|
-
{
|
|
40
|
-
displayName: "Authentication Method",
|
|
41
|
-
name: "authentication",
|
|
42
|
-
type: "options",
|
|
43
|
-
options: [
|
|
44
|
-
{ name: "API Key Header (x-finlight-key)", value: "apiKey" },
|
|
45
|
-
{ name: "Basic Auth", value: "basicAuth" },
|
|
46
|
-
{ name: "None", value: "none" },
|
|
47
|
-
],
|
|
48
|
-
default: "apiKey",
|
|
49
|
-
},
|
|
50
|
-
],
|
|
51
|
-
webhooks: [
|
|
52
|
-
{
|
|
53
|
-
name: "default",
|
|
54
|
-
httpMethod: "POST",
|
|
55
|
-
responseMode: "onReceived",
|
|
56
|
-
path: "finlight",
|
|
57
|
-
},
|
|
58
|
-
],
|
|
59
|
-
documentationUrl: "https://docs.finlight.me",
|
|
60
|
-
icon: "file:../finlight.svg",
|
|
61
|
-
};
|
|
62
|
-
this.webhookMethods = {
|
|
63
|
-
default: {
|
|
64
|
-
async checkExists() {
|
|
65
|
-
return true;
|
|
66
|
-
},
|
|
67
|
-
async create() {
|
|
68
|
-
return true;
|
|
69
|
-
},
|
|
70
|
-
async delete() {
|
|
71
|
-
return true;
|
|
72
|
-
},
|
|
73
|
-
},
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
async webhook() {
|
|
77
|
-
const req = this.getRequestObject();
|
|
78
|
-
const headers = req.headers;
|
|
79
|
-
const body = req.body;
|
|
80
|
-
const rawBody = this.getBodyData(); // raw JSON string, not parsed
|
|
81
|
-
const authMethod = this.getNodeParameter("authentication", "");
|
|
82
|
-
// Auth: API Key Header
|
|
83
|
-
if (authMethod === "apiKey") {
|
|
84
|
-
const expectedKey = this.getNodeParameter("apiKey", "");
|
|
85
|
-
const receivedKey = headers["x-finlight-key"];
|
|
86
|
-
if (!receivedKey || receivedKey !== expectedKey) {
|
|
87
|
-
throw new Error("Unauthorized: Invalid API key");
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
// Auth: Basic
|
|
91
|
-
if (authMethod === "basicAuth") {
|
|
92
|
-
const credentials = await this.getCredentials("httpBasicAuth");
|
|
93
|
-
const authHeader = headers["authorization"];
|
|
94
|
-
const expected = "Basic " + Buffer.from(`${credentials.user}:${credentials.password}`).toString("base64");
|
|
95
|
-
if (authHeader !== expected) {
|
|
96
|
-
throw new Error("Unauthorized: Invalid Basic Auth");
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
// Build clean output with optional fields
|
|
100
|
-
const payload = body;
|
|
101
|
-
const output = {
|
|
102
|
-
link: payload.link,
|
|
103
|
-
source: payload.source,
|
|
104
|
-
title: payload.title,
|
|
105
|
-
publishDate: payload.publishDate,
|
|
106
|
-
language: payload.language,
|
|
107
|
-
};
|
|
108
|
-
if (payload.summary)
|
|
109
|
-
output.summary = payload.summary;
|
|
110
|
-
if (payload.content)
|
|
111
|
-
output.content = payload.content;
|
|
112
|
-
if (payload.sentiment)
|
|
113
|
-
output.sentiment = payload.sentiment;
|
|
114
|
-
if (payload.confidence)
|
|
115
|
-
output.confidence = payload.confidence;
|
|
116
|
-
if (payload.images?.length)
|
|
117
|
-
output.images = payload.images;
|
|
118
|
-
if (payload.companies?.length)
|
|
119
|
-
output.companies = payload.companies;
|
|
120
|
-
return {
|
|
121
|
-
workflowData: [[{ json: output }]],
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
exports.FinlightWebhookTrigger = FinlightWebhookTrigger;
|