diff --git a/components/elmah_io/elmah_io.app.mjs b/components/elmah_io/elmah_io.app.mjs index 6d1f04ae454e4..e076a93fb9e85 100644 --- a/components/elmah_io/elmah_io.app.mjs +++ b/components/elmah_io/elmah_io.app.mjs @@ -1,4 +1,6 @@ -import { axios } from "@pipedream/platform"; +import { + axios, ConfigurationError, +} from "@pipedream/platform"; export default { type: "app", @@ -6,15 +8,15 @@ export default { propDefinitions: { logId: { label: "Log ID", - description: "The ID of the log", + description: "The ID of the log. Requires that your api key have the `logs_read` permission.", type: "string", async options() { const logs = await this.getLogs(); - return logs.map((log) => ({ + return logs?.map((log) => ({ label: log.name, value: log.id, - })); + })) || []; }, }, }, @@ -28,14 +30,22 @@ export default { async _makeRequest({ $ = this, path, ...args }) { - return axios($, { - ...args, - url: `${this._apiUrl()}${path}`, - params: { - ...args?.params, - api_key: this._apiKey(), - }, - }); + try { + return await axios($, { + ...args, + url: `${this._apiUrl()}${path}`, + params: { + ...args?.params, + api_key: this._apiKey(), + }, + }); + } catch (error) { + if (error.response?.status === 401) { + console.log(error); + throw new ConfigurationError(`${error.response.data.title} ${error.response.data.detail}`); + } + throw error; + } }, async getLogs(args = {}) { return this._makeRequest({ diff --git a/components/elmah_io/package.json b/components/elmah_io/package.json index 50f9227798cd1..f9568838653bc 100644 --- a/components/elmah_io/package.json +++ b/components/elmah_io/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/elmah_io", - "version": "0.0.4", + "version": "0.0.5", "description": "Pipedream elmah.io Components", "main": "elmah_io.app.mjs", "keywords": [ @@ -14,6 +14,6 @@ "access": "public" }, "dependencies": { - "@pipedream/platform": "^1.2.0" + "@pipedream/platform": "^3.1.0" } } diff --git a/components/elmah_io/sources/new-error/new-error.mjs b/components/elmah_io/sources/new-error/new-error.mjs index 6ad69280d5310..b7c8fd66c4fca 100644 --- a/components/elmah_io/sources/new-error/new-error.mjs +++ b/components/elmah_io/sources/new-error/new-error.mjs @@ -2,13 +2,13 @@ import elmah_io from "../../elmah_io.app.mjs"; import constants from "../common/constants.mjs"; import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform"; -const QUERY = "isNew:true AND (severity:Error OR severity:Fatal)"; +const QUERY = "severity:Error OR severity:Fatal"; export default { name: "New Error", - version: "0.0.3", + version: "0.0.4", key: "elmah_io-new-error", - description: "Emit new event on each new error", + description: "Emit new event on each new error. [See the documentation](https://api.elmah.io/swagger/index.html#/Messages/Messages_GetAll)", type: "source", dedupe: "unique", props: { @@ -26,12 +26,17 @@ export default { "logId", ], }, + alert: { + type: "alert", + alertType: "info", + content: "Note: This source requires that your api key have the `logs_read` and `messages_read` permissions.", + }, }, methods: { emitEvent(event) { this.$emit(event, { id: event.id, - summary: `New error with id ${event.id}`, + summary: `New error with ID ${event.id}`, ts: Date.parse(event.dateTime), }); }, @@ -39,7 +44,7 @@ export default { this.db.set("lastEventDatetime", datetime); }, _getLastEventDatetime() { - this.db.get("lastEventDatetime"); + return this.db.get("lastEventDatetime"); }, }, hooks: { @@ -52,11 +57,17 @@ export default { }, }); + if (!messages.length) { + return; + } + messages.forEach(this.emitEvent); + this._setLastEventDatetime(messages[0].dateTime); }, }, async run() { let page = 0; + const lastEventDatetime = this._getLastEventDatetime(); while (page >= 0) { const messages = await this.elmah_io.getMessages({ @@ -65,10 +76,18 @@ export default { pageIndex: page, pageSize: constants.DEFAULT_PAGE_SIZE, query: QUERY, + from: lastEventDatetime + ? lastEventDatetime + : undefined, }, }); + if (!messages.length) { + return; + } + messages.forEach(this.emitEvent); + this._setLastEventDatetime(messages[0].dateTime); page++; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 866b3a7f82bb0..229cad9aec1bb 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -2742,8 +2742,7 @@ importers: components/codeq_natural_language_processing_api: {} - components/codeqr: - specifiers: {} + components/codeqr: {} components/codereadr: dependencies: @@ -4127,8 +4126,8 @@ importers: components/elmah_io: dependencies: '@pipedream/platform': - specifier: ^1.2.0 - version: 1.6.6 + specifier: ^3.1.0 + version: 3.1.0 components/elopage: {} @@ -4595,8 +4594,7 @@ importers: components/finage: {} - components/finalscout: - specifiers: {} + components/finalscout: {} components/findymail: dependencies: @@ -10335,8 +10333,7 @@ importers: specifier: ^1.5.1 version: 1.6.6 - components/predictleads: - specifiers: {} + components/predictleads: {} components/prepr_graphql: {} @@ -29185,22 +29182,22 @@ packages: superagent@3.8.1: resolution: {integrity: sha512-VMBFLYgFuRdfeNQSMLbxGSLfmXL/xc+OO+BZp41Za/NRDBet/BNbkRJrYzCUu0u4GU0i/ml2dtT8b9qgkw9z6Q==} engines: {node: '>= 4.0'} - deprecated: Please upgrade to v7.0.2+ of superagent. We have fixed numerous issues with streams, form-data, attach(), filesystem errors not bubbling up (ENOENT on attach()), and all tests are now passing. See the releases tab for more information at . + deprecated: Please upgrade to v9.0.0+ as we have fixed a public vulnerability with formidable dependency. Note that v9.0.0+ requires Node.js v14.18.0+. See https://github.com/ladjs/superagent/pull/1800 for insight. This project is supported and maintained by the team at Forward Email @ https://forwardemail.net superagent@4.1.0: resolution: {integrity: sha512-FT3QLMasz0YyCd4uIi5HNe+3t/onxMyEho7C3PSqmti3Twgy2rXT4fmkTz6wRL6bTF4uzPcfkUCa8u4JWHw8Ag==} engines: {node: '>= 6.0'} - deprecated: Please upgrade to v7.0.2+ of superagent. We have fixed numerous issues with streams, form-data, attach(), filesystem errors not bubbling up (ENOENT on attach()), and all tests are now passing. See the releases tab for more information at . + deprecated: Please upgrade to v9.0.0+ as we have fixed a public vulnerability with formidable dependency. Note that v9.0.0+ requires Node.js v14.18.0+. See https://github.com/ladjs/superagent/pull/1800 for insight. This project is supported and maintained by the team at Forward Email @ https://forwardemail.net superagent@5.3.1: resolution: {integrity: sha512-wjJ/MoTid2/RuGCOFtlacyGNxN9QLMgcpYLDQlWFIhhdJ93kNscFonGvrpAHSCVjRVj++DGCglocF7Aej1KHvQ==} engines: {node: '>= 7.0.0'} - deprecated: Please upgrade to v7.0.2+ of superagent. We have fixed numerous issues with streams, form-data, attach(), filesystem errors not bubbling up (ENOENT on attach()), and all tests are now passing. See the releases tab for more information at . + deprecated: Please upgrade to v9.0.0+ as we have fixed a public vulnerability with formidable dependency. Note that v9.0.0+ requires Node.js v14.18.0+. See https://github.com/ladjs/superagent/pull/1800 for insight. This project is supported and maintained by the team at Forward Email @ https://forwardemail.net superagent@7.1.6: resolution: {integrity: sha512-gZkVCQR1gy/oUXr+kxJMLDjla434KmSOKbx5iGD30Ql+AkJQ/YlPKECJy2nhqOsHLjGHzoDTXNSjhnvWhzKk7g==} engines: {node: '>=6.4.0 <13 || >=14'} - deprecated: Please downgrade to v7.1.5 if you need IE/ActiveXObject support OR upgrade to v8.0.0 as we no longer support IE and published an incorrect patch version (see https://github.com/visionmedia/superagent/issues/1731) + deprecated: Please upgrade to v9.0.0+ as we have fixed a public vulnerability with formidable dependency. Note that v9.0.0+ requires Node.js v14.18.0+. See https://github.com/ladjs/superagent/pull/1800 for insight. This project is supported and maintained by the team at Forward Email @ https://forwardemail.net supports-color@2.0.0: resolution: {integrity: sha512-KKNVtd6pCYgPIKU4cp2733HWYCpplQhddZLBUryaAHou723x+FRzQ5Df824Fj+IyyuiQTRoub4SnIFfIcrp70g==}