n8n-nodes-fingrid 0.2.0 → 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.
package/README.md CHANGED
@@ -35,7 +35,7 @@ You need a free Fingrid Open Data API key:
35
35
 
36
36
  - **Dataset**
37
37
  - Get — metadata for a single dataset by ID
38
- - Searchsearch/list all public datasets
38
+ - Get Many — list all public datasets, optionally filtered by search text
39
39
  - Get Data — time series data for a dataset within a time range
40
40
  - Get Latest Data — most recent data point for a dataset
41
41
  - Get File — a single dataset file
@@ -1,4 +1,4 @@
1
- import type { IAuthenticateGeneric, ICredentialTestRequest, ICredentialType, INodeProperties } from 'n8n-workflow';
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 = 'fingridApi';
7
- this.displayName = 'Fingrid API';
8
- this.documentationUrl = 'https://data.fingrid.fi/en/instructions';
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: 'API Key',
12
- name: 'apiKey',
13
- type: 'string',
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: 'Your personal Fingrid Open Data API key. Register for free at https://data.fingrid.fi/en to get one instantly by email.',
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: 'generic',
21
+ type: "generic",
22
22
  properties: {
23
23
  headers: {
24
- 'x-api-key': '={{$credentials.apiKey}}',
24
+ "x-api-key": "={{$credentials.apiKey}}",
25
25
  },
26
26
  },
27
27
  };
28
28
  this.test = {
29
29
  request: {
30
- baseURL: 'https://data.fingrid.fi/api',
31
- url: '/health',
32
- method: 'GET',
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: ["main"],
19
- outputs: ["main"],
20
+ inputs: [n8n_workflow_1.NodeConnectionTypes.Main],
21
+ outputs: [n8n_workflow_1.NodeConnectionTypes.Main],
20
22
  credentials: [
21
23
  {
22
24
  name: "fingridApi",
@@ -74,10 +76,10 @@ class Fingrid {
74
76
  action: "Get latest dataset data",
75
77
  },
76
78
  {
77
- name: "Search",
79
+ name: "Get Many",
78
80
  value: "search",
79
- description: "Search / list all public datasets",
80
- action: "Search datasets",
81
+ description: "Retrieve a list of datasets, optionally filtered by search text",
82
+ action: "Get many datasets",
81
83
  },
82
84
  ],
83
85
  default: "get",
@@ -303,7 +305,7 @@ class Fingrid {
303
305
  ],
304
306
  },
305
307
  },
306
- description: "Whether to return a streamlined version of the data without heavy metadata",
308
+ description: "Whether to return a simplified version of the response instead of the raw data",
307
309
  },
308
310
  {
309
311
  displayName: "Additional Options",
@@ -423,7 +425,13 @@ class Fingrid {
423
425
  });
424
426
  continue;
425
427
  }
426
- throw error;
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.0",
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",