n8n-nodes-fingrid 0.2.1 → 0.2.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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { IAuthenticateGeneric, ICredentialTestRequest, ICredentialType, INodeProperties } from
|
|
1
|
+
import type { IAuthenticateGeneric, ICredentialTestRequest, ICredentialType, INodeProperties } from "n8n-workflow";
|
|
2
2
|
export declare class FingridApi implements ICredentialType {
|
|
3
3
|
name: string;
|
|
4
4
|
displayName: string;
|
|
@@ -3,33 +3,33 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.FingridApi = void 0;
|
|
4
4
|
class FingridApi {
|
|
5
5
|
constructor() {
|
|
6
|
-
this.name =
|
|
7
|
-
this.displayName =
|
|
8
|
-
this.documentationUrl =
|
|
6
|
+
this.name = "fingridApi";
|
|
7
|
+
this.displayName = "Fingrid API";
|
|
8
|
+
this.documentationUrl = "https://data.fingrid.fi/en/instructions";
|
|
9
9
|
this.properties = [
|
|
10
10
|
{
|
|
11
|
-
displayName:
|
|
12
|
-
name:
|
|
13
|
-
type:
|
|
11
|
+
displayName: "API Key",
|
|
12
|
+
name: "apiKey",
|
|
13
|
+
type: "string",
|
|
14
14
|
typeOptions: { password: true },
|
|
15
|
-
default:
|
|
15
|
+
default: "",
|
|
16
16
|
required: true,
|
|
17
|
-
description:
|
|
17
|
+
description: "Your personal Fingrid Open Data API key. Register for free at https://data.fingrid.fi/en to get one instantly by email.",
|
|
18
18
|
},
|
|
19
19
|
];
|
|
20
20
|
this.authenticate = {
|
|
21
|
-
type:
|
|
21
|
+
type: "generic",
|
|
22
22
|
properties: {
|
|
23
23
|
headers: {
|
|
24
|
-
|
|
24
|
+
"x-api-key": "={{$credentials.apiKey}}",
|
|
25
25
|
},
|
|
26
26
|
},
|
|
27
27
|
};
|
|
28
28
|
this.test = {
|
|
29
29
|
request: {
|
|
30
|
-
baseURL:
|
|
31
|
-
url:
|
|
32
|
-
method:
|
|
30
|
+
baseURL: "https://data.fingrid.fi/api",
|
|
31
|
+
url: "/health",
|
|
32
|
+
method: "GET",
|
|
33
33
|
},
|
|
34
34
|
};
|
|
35
35
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Fingrid = void 0;
|
|
4
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
4
5
|
const GenericFunctions_1 = require("./GenericFunctions");
|
|
5
6
|
class Fingrid {
|
|
6
7
|
constructor() {
|
|
@@ -10,13 +11,14 @@ class Fingrid {
|
|
|
10
11
|
icon: "file:fingrid.svg",
|
|
11
12
|
group: ["transform"],
|
|
12
13
|
version: 1,
|
|
14
|
+
usableAsTool: true,
|
|
13
15
|
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
|
|
14
16
|
description: "Read Finnish power grid and electricity market data from Fingrid Open Data",
|
|
15
17
|
defaults: {
|
|
16
18
|
name: "Fingrid",
|
|
17
19
|
},
|
|
18
|
-
inputs: [
|
|
19
|
-
outputs: [
|
|
20
|
+
inputs: [n8n_workflow_1.NodeConnectionTypes.Main],
|
|
21
|
+
outputs: [n8n_workflow_1.NodeConnectionTypes.Main],
|
|
20
22
|
credentials: [
|
|
21
23
|
{
|
|
22
24
|
name: "fingridApi",
|
|
@@ -423,7 +425,13 @@ class Fingrid {
|
|
|
423
425
|
});
|
|
424
426
|
continue;
|
|
425
427
|
}
|
|
426
|
-
|
|
428
|
+
if (error instanceof n8n_workflow_1.NodeApiError ||
|
|
429
|
+
error instanceof n8n_workflow_1.NodeOperationError) {
|
|
430
|
+
throw error;
|
|
431
|
+
}
|
|
432
|
+
throw new n8n_workflow_1.NodeApiError(this.getNode(), error, {
|
|
433
|
+
itemIndex: i,
|
|
434
|
+
});
|
|
427
435
|
}
|
|
428
436
|
}
|
|
429
437
|
return [returnData];
|
|
@@ -16,13 +16,10 @@ exports.PAGINATED_OPERATIONS = [
|
|
|
16
16
|
];
|
|
17
17
|
const MIN_REQUEST_INTERVAL_MS = 2200;
|
|
18
18
|
let lastRequestTimestamp = 0;
|
|
19
|
-
async function sleep(ms) {
|
|
20
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
21
|
-
}
|
|
22
19
|
async function respectRateLimit() {
|
|
23
20
|
const elapsed = Date.now() - lastRequestTimestamp;
|
|
24
21
|
if (elapsed < MIN_REQUEST_INTERVAL_MS) {
|
|
25
|
-
await sleep(MIN_REQUEST_INTERVAL_MS - elapsed);
|
|
22
|
+
await (0, n8n_workflow_1.sleep)(MIN_REQUEST_INTERVAL_MS - elapsed);
|
|
26
23
|
}
|
|
27
24
|
lastRequestTimestamp = Date.now();
|
|
28
25
|
}
|
|
@@ -40,7 +37,9 @@ async function requestWithRateLimitHandling(options, i) {
|
|
|
40
37
|
itemIndex: i,
|
|
41
38
|
});
|
|
42
39
|
}
|
|
43
|
-
throw error
|
|
40
|
+
throw new n8n_workflow_1.NodeApiError(this.getNode(), error, {
|
|
41
|
+
itemIndex: i,
|
|
42
|
+
});
|
|
44
43
|
}
|
|
45
44
|
}
|
|
46
45
|
function buildDatasetRequest(operation, i) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "n8n-nodes-fingrid",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "n8n community node for Fingrid Open Data — Finnish power grid and electricity market data",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"n8n-community-node-package",
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"homepage": "https://github.com/MychelGarzon/n8n-nodes-fingrid",
|
|
15
15
|
"author": {
|
|
16
|
-
"name": "Mychel Garzon"
|
|
16
|
+
"name": "Mychel Garzon",
|
|
17
|
+
"email": "mychel.garzon@gmail.com"
|
|
17
18
|
},
|
|
18
19
|
"repository": {
|
|
19
20
|
"type": "git",
|