From e4bc63c30acb9b5d5779985f323ef16827bb5e87 Mon Sep 17 00:00:00 2001 From: Lucas Caresia Date: Tue, 19 Nov 2024 17:40:06 -0300 Subject: [PATCH 01/13] Added actions --- components/klipfolio/.gitignore | 3 - .../create-datasource/create-datasource.mjs | 73 ++++++++++++ .../delete-datasource/delete-datasource.mjs | 27 +++++ .../update-datasource/update-datasource.mjs | 50 ++++++++ components/klipfolio/app/klipfolio.app.ts | 13 --- components/klipfolio/common/constants.mjs | 8 ++ components/klipfolio/klipfolio.app.mjs | 107 ++++++++++++++++++ components/klipfolio/package.json | 9 +- 8 files changed, 272 insertions(+), 18 deletions(-) delete mode 100644 components/klipfolio/.gitignore create mode 100644 components/klipfolio/actions/create-datasource/create-datasource.mjs create mode 100644 components/klipfolio/actions/delete-datasource/delete-datasource.mjs create mode 100644 components/klipfolio/actions/update-datasource/update-datasource.mjs delete mode 100644 components/klipfolio/app/klipfolio.app.ts create mode 100644 components/klipfolio/common/constants.mjs create mode 100644 components/klipfolio/klipfolio.app.mjs diff --git a/components/klipfolio/.gitignore b/components/klipfolio/.gitignore deleted file mode 100644 index ec761ccab7595..0000000000000 --- a/components/klipfolio/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -*.js -*.mjs -dist \ No newline at end of file diff --git a/components/klipfolio/actions/create-datasource/create-datasource.mjs b/components/klipfolio/actions/create-datasource/create-datasource.mjs new file mode 100644 index 0000000000000..4d3ec53aa1f97 --- /dev/null +++ b/components/klipfolio/actions/create-datasource/create-datasource.mjs @@ -0,0 +1,73 @@ +import app from "../../klipfolio.app.mjs"; + +export default { + key: "klipfolio-create-datasource", + name: "Create Datasource", + description: "Create a data source. [See the documentation](https://apidocs.klipfolio.com/reference/data-sources#post-datasources)", + version: "0.0.1", + type: "action", + props: { + app, + name: { + propDefinition: [ + app, + "name" + ] + }, + description: { + propDefinition: [ + app, + "description" + ] + }, + format: { + propDefinition: [ + app, + "format" + ] + }, + connector: { + propDefinition: [ + app, + "connector" + ] + }, + refreshInterval: { + propDefinition: [ + app, + "refreshInterval" + ] + }, + endpointUrl: { + propDefinition: [ + app, + "endpointUrl" + ] + }, + method: { + propDefinition: [ + app, + "method" + ] + }, + }, + + async run({ $ }) { + const response = await this.app.createDatasource({ + $, + data: { + name: this.name, + description: this.description, + format: this.format, + connector: this.connector, + refresh_interval: parseInt(this.refreshInterval, 10), + properties: { + endpoint_url: this.endpointUrl, + method: this.method, + } + }, + }); + $.export("$summary", `Successfully created Datasource named '${this.name}'`); + return response; + }, +}; diff --git a/components/klipfolio/actions/delete-datasource/delete-datasource.mjs b/components/klipfolio/actions/delete-datasource/delete-datasource.mjs new file mode 100644 index 0000000000000..8074fac90aa05 --- /dev/null +++ b/components/klipfolio/actions/delete-datasource/delete-datasource.mjs @@ -0,0 +1,27 @@ +import app from "../../klipfolio.app.mjs"; + +export default { + key: "klipfolio-delete-datasource", + name: "Delete Datasource", + description: "Delete the data source associated with a specific data source ID. [See the documentation](https://apidocs.klipfolio.com/reference/data-sources#delete-datasourcesid)", + version: "0.0.1", + type: "action", + props: { + app, + datasourceId: { + propDefinition: [ + app, + "datasourceId" + ] + }, + }, + + async run({ $ }) { + const response = await this.app.deleteDatasource({ + $, + datasourceId: this.datasourceId, + }); + $.export("$summary", `Successfully deleted datasource with ID: ${this.datasourceId}`); + return response; + }, +}; diff --git a/components/klipfolio/actions/update-datasource/update-datasource.mjs b/components/klipfolio/actions/update-datasource/update-datasource.mjs new file mode 100644 index 0000000000000..ba97de3d2f163 --- /dev/null +++ b/components/klipfolio/actions/update-datasource/update-datasource.mjs @@ -0,0 +1,50 @@ +import app from "../../klipfolio.app.mjs"; + +export default { + key: "klipfolio-update-datasource", + name: "Update Datasource", + description: "Update the specified data source. [See the documentation](https://apidocs.klipfolio.com/reference/data-sources#put-datasourcesid)", + version: "0.0.1", + type: "action", + props: { + app, + datasourceId: { + propDefinition: [ + app, + "datasourceId" + ] + }, + name: { + propDefinition: [ + app, + "name" + ] + }, + description: { + propDefinition: [ + app, + "description" + ] + }, + refreshInterval: { + propDefinition: [ + app, + "refreshInterval" + ] + }, + }, + + async run({ $ }) { + const response = await this.app.updateDatasource({ + $, + datasourceId: this.datasourceId, + data: { + name: this.name, + description: this.description, + refreshInterval: this.refreshInterval, + }, + }); + $.export("$summary", `Successfully updated Datasource named '${this.name}'`); + return response; + }, +}; diff --git a/components/klipfolio/app/klipfolio.app.ts b/components/klipfolio/app/klipfolio.app.ts deleted file mode 100644 index 688ab9a4688e9..0000000000000 --- a/components/klipfolio/app/klipfolio.app.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { defineApp } from "@pipedream/types"; - -export default defineApp({ - type: "app", - app: "klipfolio", - propDefinitions: {}, - methods: { - // this.$auth contains connected account data - authKeys() { - console.log(Object.keys(this.$auth)); - }, - }, -}); \ No newline at end of file diff --git a/components/klipfolio/common/constants.mjs b/components/klipfolio/common/constants.mjs new file mode 100644 index 0000000000000..8c165d41937b6 --- /dev/null +++ b/components/klipfolio/common/constants.mjs @@ -0,0 +1,8 @@ +export default { + DATASOURCE_CONNECTORS: [ + 'box', 'comscore', 'db', 'dropbox', 'facebook', 'ftp', 'google_adwords', 'google_analytics', 'google_drive', 'google_spreadsheets', 'hubspot', 'iformbuilder', 'marketo', 'omniture', 'radian6', 'salesforce', 'searchMetrics', 'shopify', 'simple_rest', 'survey_monkey', 'versature', 'xero', 'xmla' + ], + REFRESH_INTERVALS: [ + '0', '60', '300', '900', '1800', '3600', '7200', '10800', '14400', '43200', '86400' + ] +} \ No newline at end of file diff --git a/components/klipfolio/klipfolio.app.mjs b/components/klipfolio/klipfolio.app.mjs new file mode 100644 index 0000000000000..dabf3278e4e0d --- /dev/null +++ b/components/klipfolio/klipfolio.app.mjs @@ -0,0 +1,107 @@ +import { axios } from "@pipedream/platform"; +import constants from "./common/constants.mjs"; + +export default { + type: "app", + app: "klipfolio", + propDefinitions: { + name: { + type: "string", + label: "Name", + description: "Name of the Datasource", + }, + description: { + type: "string", + label: "Description", + description: "Description of the Datasource", + }, + format: { + type: "string", + label: "Format", + description: "Format of the Datasource, i.e.: `xml`", + }, + connector: { + type: "string", + label: "Connector", + description: "Connector of the Datasource", + options: constants.DATASOURCE_CONNECTORS, + }, + refreshInterval: { + type: "string", + label: "Refresh Interval", + description: "Refresh Interval of the Datasource", + options: constants.REFRESH_INTERVALS, + }, + endpointUrl: { + type: "string", + label: "Endpoint URL", + description: "Endpoint URL of the Datasource, i.e.: `http://test/data/scatter.xml`", + }, + method: { + type: "string", + label: "Method", + description: "Method for the endpoint, i.e.: `GET`", + }, + datasourceId: { + type: "string", + label: "Datasource ID", + description: "ID of the Datasource", + async options() { + const response = await this.getDatasources(); + const datasourceIds = response.data.datasources; + return datasourceIds.map(({ id, name }) => ({ + label: name, + value: id + })); + } + }, + }, + methods: { + _baseUrl() { + return `https://app.klipfolio.com/api/1.0`; + }, + async _makeRequest(opts = {}) { + const { + $ = this, + path, + headers, + ...otherOpts + } = opts; + return axios($, { + ...otherOpts, + url: this._baseUrl() + path, + headers: { + ...headers, + "kf-api-key": `${this.$auth.api_key}`, + }, + }); + }, + async createDatasource(args = {}) { + return this._makeRequest({ + path: "/datasources", + method: "post", + ...args, + }); + }, + async updateDatasource({ datasourceId, ...args }) { + return this._makeRequest({ + path: `/datasources/${datasourceId}`, + method: "put", + ...args, + }); + }, + async deleteDatasource({ datasourceId, ...args }) { + return this._makeRequest({ + path: `/datasources/${datasourceId}`, + method: "delete", + ...args, + }); + }, + async getDatasources(args = {}) { + return this._makeRequest({ + path: "/datasources", + ...args, + }); + }, + }, +}; diff --git a/components/klipfolio/package.json b/components/klipfolio/package.json index cccf7a1e3674a..fa2d592ba3f1a 100644 --- a/components/klipfolio/package.json +++ b/components/klipfolio/package.json @@ -1,16 +1,21 @@ { "name": "@pipedream/klipfolio", - "version": "0.0.2", + "version": "0.1.0", "description": "Pipedream Klipfolio Components", "main": "dist/app/klipfolio.app.mjs", "keywords": [ "pipedream", "klipfolio" ], - "files": ["dist"], + "files": [ + "dist" + ], "homepage": "https://pipedream.com/apps/klipfolio", "author": "Pipedream (https://pipedream.com/)", "publishConfig": { "access": "public" + }, + "dependencies": { + "@pipedream/platform": "^3.0.3" } } From 8792a7ad637160511a867c9c8ed615f35445c660 Mon Sep 17 00:00:00 2001 From: Lucas Caresia Date: Wed, 27 Nov 2024 13:02:43 -0300 Subject: [PATCH 02/13] Update components/klipfolio/package.json Co-authored-by: michelle0927 --- components/klipfolio/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/klipfolio/package.json b/components/klipfolio/package.json index fa2d592ba3f1a..f21befb5c6e91 100644 --- a/components/klipfolio/package.json +++ b/components/klipfolio/package.json @@ -2,7 +2,7 @@ "name": "@pipedream/klipfolio", "version": "0.1.0", "description": "Pipedream Klipfolio Components", - "main": "dist/app/klipfolio.app.mjs", + "main": "klipfolio.app.mjs", "keywords": [ "pipedream", "klipfolio" From 47124214c16a570475bbb8655d303f048a226cef Mon Sep 17 00:00:00 2001 From: Lucas Caresia Date: Wed, 27 Nov 2024 13:02:52 -0300 Subject: [PATCH 03/13] Update components/klipfolio/package.json Co-authored-by: michelle0927 --- components/klipfolio/package.json | 3 --- 1 file changed, 3 deletions(-) diff --git a/components/klipfolio/package.json b/components/klipfolio/package.json index f21befb5c6e91..8256b3ed0f288 100644 --- a/components/klipfolio/package.json +++ b/components/klipfolio/package.json @@ -7,9 +7,6 @@ "pipedream", "klipfolio" ], - "files": [ - "dist" - ], "homepage": "https://pipedream.com/apps/klipfolio", "author": "Pipedream (https://pipedream.com/)", "publishConfig": { From ebf8b76eb9837a0e47eb967c2f261789de800d4c Mon Sep 17 00:00:00 2001 From: Lucas Caresia Date: Wed, 27 Nov 2024 13:02:58 -0300 Subject: [PATCH 04/13] Update components/klipfolio/actions/update-datasource/update-datasource.mjs Co-authored-by: michelle0927 --- .../klipfolio/actions/update-datasource/update-datasource.mjs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/klipfolio/actions/update-datasource/update-datasource.mjs b/components/klipfolio/actions/update-datasource/update-datasource.mjs index ba97de3d2f163..f5eac6e2bfbc0 100644 --- a/components/klipfolio/actions/update-datasource/update-datasource.mjs +++ b/components/klipfolio/actions/update-datasource/update-datasource.mjs @@ -41,7 +41,8 @@ export default { data: { name: this.name, description: this.description, - refreshInterval: this.refreshInterval, + refreshInterval: parseInt(this.refreshInterval, 10), + }, }); $.export("$summary", `Successfully updated Datasource named '${this.name}'`); From 8ab16ec15f0f66e62a625b805d31f6e5f8ca4e54 Mon Sep 17 00:00:00 2001 From: Lucas Caresia Date: Tue, 3 Dec 2024 15:50:38 -0300 Subject: [PATCH 05/13] Fixed requested changes --- pnpm-lock.yaml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 797a1ce86b743..1920f3ac21b10 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -5441,7 +5441,11 @@ importers: specifier: ^1.5.1 version: 1.6.6 - components/klipfolio: {} + components/klipfolio: + dependencies: + '@pipedream/platform': + specifier: ^3.0.3 + version: 3.0.3 components/knack: dependencies: From b489f66a0f57a4eb18cf3119f2bf985bf8441eba Mon Sep 17 00:00:00 2001 From: Lucas Caresia Date: Tue, 3 Dec 2024 16:11:32 -0300 Subject: [PATCH 06/13] Fixed requested changes --- .../create-datasource/create-datasource.mjs | 30 +++++++------- .../delete-datasource/delete-datasource.mjs | 4 +- .../update-datasource/update-datasource.mjs | 16 ++++---- components/klipfolio/common/constants.mjs | 40 +++++++++++++++++-- components/klipfolio/klipfolio.app.mjs | 18 ++++++--- 5 files changed, 73 insertions(+), 35 deletions(-) diff --git a/components/klipfolio/actions/create-datasource/create-datasource.mjs b/components/klipfolio/actions/create-datasource/create-datasource.mjs index 4d3ec53aa1f97..b28348b583288 100644 --- a/components/klipfolio/actions/create-datasource/create-datasource.mjs +++ b/components/klipfolio/actions/create-datasource/create-datasource.mjs @@ -11,44 +11,44 @@ export default { name: { propDefinition: [ app, - "name" - ] + "name", + ], }, description: { propDefinition: [ app, - "description" - ] + "description", + ], }, format: { propDefinition: [ app, - "format" - ] + "format", + ], }, connector: { propDefinition: [ app, - "connector" - ] + "connector", + ], }, refreshInterval: { propDefinition: [ app, - "refreshInterval" - ] + "refreshInterval", + ], }, endpointUrl: { propDefinition: [ app, - "endpointUrl" - ] + "endpointUrl", + ], }, method: { propDefinition: [ app, - "method" - ] + "method", + ], }, }, @@ -64,7 +64,7 @@ export default { properties: { endpoint_url: this.endpointUrl, method: this.method, - } + }, }, }); $.export("$summary", `Successfully created Datasource named '${this.name}'`); diff --git a/components/klipfolio/actions/delete-datasource/delete-datasource.mjs b/components/klipfolio/actions/delete-datasource/delete-datasource.mjs index 8074fac90aa05..218e02e05c706 100644 --- a/components/klipfolio/actions/delete-datasource/delete-datasource.mjs +++ b/components/klipfolio/actions/delete-datasource/delete-datasource.mjs @@ -11,8 +11,8 @@ export default { datasourceId: { propDefinition: [ app, - "datasourceId" - ] + "datasourceId", + ], }, }, diff --git a/components/klipfolio/actions/update-datasource/update-datasource.mjs b/components/klipfolio/actions/update-datasource/update-datasource.mjs index f5eac6e2bfbc0..b0d78ed8bfcae 100644 --- a/components/klipfolio/actions/update-datasource/update-datasource.mjs +++ b/components/klipfolio/actions/update-datasource/update-datasource.mjs @@ -11,26 +11,26 @@ export default { datasourceId: { propDefinition: [ app, - "datasourceId" - ] + "datasourceId", + ], }, name: { propDefinition: [ app, - "name" - ] + "name", + ], }, description: { propDefinition: [ app, - "description" - ] + "description", + ], }, refreshInterval: { propDefinition: [ app, - "refreshInterval" - ] + "refreshInterval", + ], }, }, diff --git a/components/klipfolio/common/constants.mjs b/components/klipfolio/common/constants.mjs index 8c165d41937b6..788b74f70bce4 100644 --- a/components/klipfolio/common/constants.mjs +++ b/components/klipfolio/common/constants.mjs @@ -1,8 +1,40 @@ export default { DATASOURCE_CONNECTORS: [ - 'box', 'comscore', 'db', 'dropbox', 'facebook', 'ftp', 'google_adwords', 'google_analytics', 'google_drive', 'google_spreadsheets', 'hubspot', 'iformbuilder', 'marketo', 'omniture', 'radian6', 'salesforce', 'searchMetrics', 'shopify', 'simple_rest', 'survey_monkey', 'versature', 'xero', 'xmla' + "box", + "comscore", + "db", + "dropbox", + "facebook", + "ftp", + "google_adwords", + "google_analytics", + "google_drive", + "google_spreadsheets", + "hubspot", + "iformbuilder", + "marketo", + "omniture", + "radian6", + "salesforce", + "searchMetrics", + "shopify", + "simple_rest", + "survey_monkey", + "versature", + "xero", + "xmla", ], REFRESH_INTERVALS: [ - '0', '60', '300', '900', '1800', '3600', '7200', '10800', '14400', '43200', '86400' - ] -} \ No newline at end of file + "0", + "60", + "300", + "900", + "1800", + "3600", + "7200", + "10800", + "14400", + "43200", + "86400", + ], +}; diff --git a/components/klipfolio/klipfolio.app.mjs b/components/klipfolio/klipfolio.app.mjs index dabf3278e4e0d..ea02b5484684a 100644 --- a/components/klipfolio/klipfolio.app.mjs +++ b/components/klipfolio/klipfolio.app.mjs @@ -49,16 +49,18 @@ export default { async options() { const response = await this.getDatasources(); const datasourceIds = response.data.datasources; - return datasourceIds.map(({ id, name }) => ({ + return datasourceIds.map(({ + id, name, + }) => ({ label: name, - value: id + value: id, })); - } + }, }, }, methods: { _baseUrl() { - return `https://app.klipfolio.com/api/1.0`; + return "https://app.klipfolio.com/api/1.0"; }, async _makeRequest(opts = {}) { const { @@ -83,14 +85,18 @@ export default { ...args, }); }, - async updateDatasource({ datasourceId, ...args }) { + async updateDatasource({ + datasourceId, ...args + }) { return this._makeRequest({ path: `/datasources/${datasourceId}`, method: "put", ...args, }); }, - async deleteDatasource({ datasourceId, ...args }) { + async deleteDatasource({ + datasourceId, ...args + }) { return this._makeRequest({ path: `/datasources/${datasourceId}`, method: "delete", From 047f162f01b014fefb0fc750a017174031c7a1a1 Mon Sep 17 00:00:00 2001 From: Lucas Caresia Date: Tue, 3 Dec 2024 16:28:11 -0300 Subject: [PATCH 07/13] Update components/klipfolio/actions/update-datasource/update-datasource.mjs Co-authored-by: michelle0927 --- .../klipfolio/actions/update-datasource/update-datasource.mjs | 1 - 1 file changed, 1 deletion(-) diff --git a/components/klipfolio/actions/update-datasource/update-datasource.mjs b/components/klipfolio/actions/update-datasource/update-datasource.mjs index b0d78ed8bfcae..7d60354cfb98a 100644 --- a/components/klipfolio/actions/update-datasource/update-datasource.mjs +++ b/components/klipfolio/actions/update-datasource/update-datasource.mjs @@ -42,7 +42,6 @@ export default { name: this.name, description: this.description, refreshInterval: parseInt(this.refreshInterval, 10), - }, }); $.export("$summary", `Successfully updated Datasource named '${this.name}'`); From a5055d912627cec7eb8e681813c8cfec2a9fa76d Mon Sep 17 00:00:00 2001 From: Lucas Caresia Date: Tue, 10 Dec 2024 19:34:49 -0300 Subject: [PATCH 08/13] Added requested changes --- .../create-datasource/create-datasource.mjs | 37 ++++++++++------- .../delete-datasource/delete-datasource.mjs | 4 +- .../update-datasource/update-datasource.mjs | 18 ++++----- components/klipfolio/common/constants.mjs | 40 ++----------------- components/klipfolio/klipfolio.app.mjs | 23 +++++------ 5 files changed, 48 insertions(+), 74 deletions(-) diff --git a/components/klipfolio/actions/create-datasource/create-datasource.mjs b/components/klipfolio/actions/create-datasource/create-datasource.mjs index b28348b583288..a291773a75745 100644 --- a/components/klipfolio/actions/create-datasource/create-datasource.mjs +++ b/components/klipfolio/actions/create-datasource/create-datasource.mjs @@ -11,45 +11,51 @@ export default { name: { propDefinition: [ app, - "name", - ], + "name" + ] }, description: { propDefinition: [ app, - "description", - ], + "description" + ] }, format: { propDefinition: [ app, - "format", - ], + "format" + ] }, connector: { propDefinition: [ app, - "connector", - ], + "connector" + ] }, refreshInterval: { propDefinition: [ app, - "refreshInterval", - ], + "refreshInterval" + ] }, endpointUrl: { propDefinition: [ app, - "endpointUrl", - ], + "endpointUrl" + ] }, method: { propDefinition: [ app, - "method", - ], + "method" + ] }, + additionalProperties: { + propDefinition: [ + app, + "additionalProperties", + ] + } }, async run({ $ }) { @@ -64,7 +70,8 @@ export default { properties: { endpoint_url: this.endpointUrl, method: this.method, - }, + ...this.additionalProperties, + } }, }); $.export("$summary", `Successfully created Datasource named '${this.name}'`); diff --git a/components/klipfolio/actions/delete-datasource/delete-datasource.mjs b/components/klipfolio/actions/delete-datasource/delete-datasource.mjs index 218e02e05c706..8074fac90aa05 100644 --- a/components/klipfolio/actions/delete-datasource/delete-datasource.mjs +++ b/components/klipfolio/actions/delete-datasource/delete-datasource.mjs @@ -11,8 +11,8 @@ export default { datasourceId: { propDefinition: [ app, - "datasourceId", - ], + "datasourceId" + ] }, }, diff --git a/components/klipfolio/actions/update-datasource/update-datasource.mjs b/components/klipfolio/actions/update-datasource/update-datasource.mjs index 7d60354cfb98a..a6722f10012c7 100644 --- a/components/klipfolio/actions/update-datasource/update-datasource.mjs +++ b/components/klipfolio/actions/update-datasource/update-datasource.mjs @@ -11,26 +11,26 @@ export default { datasourceId: { propDefinition: [ app, - "datasourceId", - ], + "datasourceId" + ] }, name: { propDefinition: [ app, - "name", - ], + "name" + ] }, description: { propDefinition: [ app, - "description", - ], + "description" + ] }, refreshInterval: { propDefinition: [ app, - "refreshInterval", - ], + "refreshInterval" + ] }, }, @@ -41,7 +41,7 @@ export default { data: { name: this.name, description: this.description, - refreshInterval: parseInt(this.refreshInterval, 10), + refresh_interval: parseInt(this.refreshInterval, 10), }, }); $.export("$summary", `Successfully updated Datasource named '${this.name}'`); diff --git a/components/klipfolio/common/constants.mjs b/components/klipfolio/common/constants.mjs index 788b74f70bce4..8c165d41937b6 100644 --- a/components/klipfolio/common/constants.mjs +++ b/components/klipfolio/common/constants.mjs @@ -1,40 +1,8 @@ export default { DATASOURCE_CONNECTORS: [ - "box", - "comscore", - "db", - "dropbox", - "facebook", - "ftp", - "google_adwords", - "google_analytics", - "google_drive", - "google_spreadsheets", - "hubspot", - "iformbuilder", - "marketo", - "omniture", - "radian6", - "salesforce", - "searchMetrics", - "shopify", - "simple_rest", - "survey_monkey", - "versature", - "xero", - "xmla", + 'box', 'comscore', 'db', 'dropbox', 'facebook', 'ftp', 'google_adwords', 'google_analytics', 'google_drive', 'google_spreadsheets', 'hubspot', 'iformbuilder', 'marketo', 'omniture', 'radian6', 'salesforce', 'searchMetrics', 'shopify', 'simple_rest', 'survey_monkey', 'versature', 'xero', 'xmla' ], REFRESH_INTERVALS: [ - "0", - "60", - "300", - "900", - "1800", - "3600", - "7200", - "10800", - "14400", - "43200", - "86400", - ], -}; + '0', '60', '300', '900', '1800', '3600', '7200', '10800', '14400', '43200', '86400' + ] +} \ No newline at end of file diff --git a/components/klipfolio/klipfolio.app.mjs b/components/klipfolio/klipfolio.app.mjs index ea02b5484684a..49e01f4a573f7 100644 --- a/components/klipfolio/klipfolio.app.mjs +++ b/components/klipfolio/klipfolio.app.mjs @@ -49,18 +49,21 @@ export default { async options() { const response = await this.getDatasources(); const datasourceIds = response.data.datasources; - return datasourceIds.map(({ - id, name, - }) => ({ + return datasourceIds.map(({ id, name }) => ({ label: name, - value: id, + value: id })); - }, + } }, + additionalProperties: { + type: "object", + label: "Additional Properties", + description: "Data source additional properties. For example, Google Analytics API has the following properties: `oauth_provider_id`, `oauth_user_header`, `oauth_user_token`, `token_id`, `prop:profile_id`." + } }, methods: { _baseUrl() { - return "https://app.klipfolio.com/api/1.0"; + return `https://app.klipfolio.com/api/1.0`; }, async _makeRequest(opts = {}) { const { @@ -85,18 +88,14 @@ export default { ...args, }); }, - async updateDatasource({ - datasourceId, ...args - }) { + async updateDatasource({ datasourceId, ...args }) { return this._makeRequest({ path: `/datasources/${datasourceId}`, method: "put", ...args, }); }, - async deleteDatasource({ - datasourceId, ...args - }) { + async deleteDatasource({ datasourceId, ...args }) { return this._makeRequest({ path: `/datasources/${datasourceId}`, method: "delete", From 0d4fffc3fe1e533bd577863990f4687dcd70f8ad Mon Sep 17 00:00:00 2001 From: Lucas Caresia Date: Tue, 10 Dec 2024 19:56:41 -0300 Subject: [PATCH 09/13] Added requested changes --- .../create-datasource/create-datasource.mjs | 34 ++++++++-------- .../delete-datasource/delete-datasource.mjs | 4 +- .../update-datasource/update-datasource.mjs | 16 ++++---- components/klipfolio/common/constants.mjs | 40 +++++++++++++++++-- components/klipfolio/klipfolio.app.mjs | 22 ++++++---- 5 files changed, 77 insertions(+), 39 deletions(-) diff --git a/components/klipfolio/actions/create-datasource/create-datasource.mjs b/components/klipfolio/actions/create-datasource/create-datasource.mjs index a291773a75745..7aef4b18e50a8 100644 --- a/components/klipfolio/actions/create-datasource/create-datasource.mjs +++ b/components/klipfolio/actions/create-datasource/create-datasource.mjs @@ -11,51 +11,51 @@ export default { name: { propDefinition: [ app, - "name" - ] + "name", + ], }, description: { propDefinition: [ app, - "description" - ] + "description", + ], }, format: { propDefinition: [ app, - "format" - ] + "format", + ], }, connector: { propDefinition: [ app, - "connector" - ] + "connector", + ], }, refreshInterval: { propDefinition: [ app, - "refreshInterval" - ] + "refreshInterval", + ], }, endpointUrl: { propDefinition: [ app, - "endpointUrl" - ] + "endpointUrl", + ], }, method: { propDefinition: [ app, - "method" - ] + "method", + ], }, additionalProperties: { propDefinition: [ app, "additionalProperties", - ] - } + ], + }, }, async run({ $ }) { @@ -71,7 +71,7 @@ export default { endpoint_url: this.endpointUrl, method: this.method, ...this.additionalProperties, - } + }, }, }); $.export("$summary", `Successfully created Datasource named '${this.name}'`); diff --git a/components/klipfolio/actions/delete-datasource/delete-datasource.mjs b/components/klipfolio/actions/delete-datasource/delete-datasource.mjs index 8074fac90aa05..218e02e05c706 100644 --- a/components/klipfolio/actions/delete-datasource/delete-datasource.mjs +++ b/components/klipfolio/actions/delete-datasource/delete-datasource.mjs @@ -11,8 +11,8 @@ export default { datasourceId: { propDefinition: [ app, - "datasourceId" - ] + "datasourceId", + ], }, }, diff --git a/components/klipfolio/actions/update-datasource/update-datasource.mjs b/components/klipfolio/actions/update-datasource/update-datasource.mjs index a6722f10012c7..d1521c7ec66f3 100644 --- a/components/klipfolio/actions/update-datasource/update-datasource.mjs +++ b/components/klipfolio/actions/update-datasource/update-datasource.mjs @@ -11,26 +11,26 @@ export default { datasourceId: { propDefinition: [ app, - "datasourceId" - ] + "datasourceId", + ], }, name: { propDefinition: [ app, - "name" - ] + "name", + ], }, description: { propDefinition: [ app, - "description" - ] + "description", + ], }, refreshInterval: { propDefinition: [ app, - "refreshInterval" - ] + "refreshInterval", + ], }, }, diff --git a/components/klipfolio/common/constants.mjs b/components/klipfolio/common/constants.mjs index 8c165d41937b6..788b74f70bce4 100644 --- a/components/klipfolio/common/constants.mjs +++ b/components/klipfolio/common/constants.mjs @@ -1,8 +1,40 @@ export default { DATASOURCE_CONNECTORS: [ - 'box', 'comscore', 'db', 'dropbox', 'facebook', 'ftp', 'google_adwords', 'google_analytics', 'google_drive', 'google_spreadsheets', 'hubspot', 'iformbuilder', 'marketo', 'omniture', 'radian6', 'salesforce', 'searchMetrics', 'shopify', 'simple_rest', 'survey_monkey', 'versature', 'xero', 'xmla' + "box", + "comscore", + "db", + "dropbox", + "facebook", + "ftp", + "google_adwords", + "google_analytics", + "google_drive", + "google_spreadsheets", + "hubspot", + "iformbuilder", + "marketo", + "omniture", + "radian6", + "salesforce", + "searchMetrics", + "shopify", + "simple_rest", + "survey_monkey", + "versature", + "xero", + "xmla", ], REFRESH_INTERVALS: [ - '0', '60', '300', '900', '1800', '3600', '7200', '10800', '14400', '43200', '86400' - ] -} \ No newline at end of file + "0", + "60", + "300", + "900", + "1800", + "3600", + "7200", + "10800", + "14400", + "43200", + "86400", + ], +}; diff --git a/components/klipfolio/klipfolio.app.mjs b/components/klipfolio/klipfolio.app.mjs index 49e01f4a573f7..eabdae91375ff 100644 --- a/components/klipfolio/klipfolio.app.mjs +++ b/components/klipfolio/klipfolio.app.mjs @@ -49,21 +49,23 @@ export default { async options() { const response = await this.getDatasources(); const datasourceIds = response.data.datasources; - return datasourceIds.map(({ id, name }) => ({ + return datasourceIds.map(({ + id, name, + }) => ({ label: name, - value: id + value: id, })); - } + }, }, additionalProperties: { type: "object", label: "Additional Properties", - description: "Data source additional properties. For example, Google Analytics API has the following properties: `oauth_provider_id`, `oauth_user_header`, `oauth_user_token`, `token_id`, `prop:profile_id`." - } + description: "Data source additional properties. For example, Google Analytics API has the following properties: `oauth_provider_id`, `oauth_user_header`, `oauth_user_token`, `token_id`, `prop:profile_id`.", + }, }, methods: { _baseUrl() { - return `https://app.klipfolio.com/api/1.0`; + return "https://app.klipfolio.com/api/1.0"; }, async _makeRequest(opts = {}) { const { @@ -88,14 +90,18 @@ export default { ...args, }); }, - async updateDatasource({ datasourceId, ...args }) { + async updateDatasource({ + datasourceId, ...args + }) { return this._makeRequest({ path: `/datasources/${datasourceId}`, method: "put", ...args, }); }, - async deleteDatasource({ datasourceId, ...args }) { + async deleteDatasource({ + datasourceId, ...args + }) { return this._makeRequest({ path: `/datasources/${datasourceId}`, method: "delete", From b356a1b72580f39749ad79088dec13665c022f54 Mon Sep 17 00:00:00 2001 From: Lucas Caresia Date: Fri, 20 Dec 2024 18:16:34 -0300 Subject: [PATCH 10/13] Done requests changes --- .../klipfolio/actions/create-datasource/create-datasource.mjs | 2 ++ .../klipfolio/actions/delete-datasource/delete-datasource.mjs | 2 ++ 2 files changed, 4 insertions(+) diff --git a/components/klipfolio/actions/create-datasource/create-datasource.mjs b/components/klipfolio/actions/create-datasource/create-datasource.mjs index 7aef4b18e50a8..f5d7ba7e86d56 100644 --- a/components/klipfolio/actions/create-datasource/create-datasource.mjs +++ b/components/klipfolio/actions/create-datasource/create-datasource.mjs @@ -74,7 +74,9 @@ export default { }, }, }); + $.export("$summary", `Successfully created Datasource named '${this.name}'`); + return response; }, }; diff --git a/components/klipfolio/actions/delete-datasource/delete-datasource.mjs b/components/klipfolio/actions/delete-datasource/delete-datasource.mjs index 218e02e05c706..78eb41418f6c9 100644 --- a/components/klipfolio/actions/delete-datasource/delete-datasource.mjs +++ b/components/klipfolio/actions/delete-datasource/delete-datasource.mjs @@ -21,7 +21,9 @@ export default { $, datasourceId: this.datasourceId, }); + $.export("$summary", `Successfully deleted datasource with ID: ${this.datasourceId}`); + return response; }, }; From c4c09227fc3dcb7463d02b1362b30a6e2329fa66 Mon Sep 17 00:00:00 2001 From: Lucas Caresia Date: Thu, 16 Jan 2025 14:26:51 -0300 Subject: [PATCH 11/13] Added actions --- .../update-datasource/update-datasource.mjs | 2 ++ components/klipfolio/common/constants.mjs | 14 +++++++------- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/components/klipfolio/actions/update-datasource/update-datasource.mjs b/components/klipfolio/actions/update-datasource/update-datasource.mjs index d1521c7ec66f3..3701e97107b36 100644 --- a/components/klipfolio/actions/update-datasource/update-datasource.mjs +++ b/components/klipfolio/actions/update-datasource/update-datasource.mjs @@ -44,7 +44,9 @@ export default { refresh_interval: parseInt(this.refreshInterval, 10), }, }); + $.export("$summary", `Successfully updated Datasource named '${this.name}'`); + return response; }, }; diff --git a/components/klipfolio/common/constants.mjs b/components/klipfolio/common/constants.mjs index 788b74f70bce4..7b2657c279f7c 100644 --- a/components/klipfolio/common/constants.mjs +++ b/components/klipfolio/common/constants.mjs @@ -1,5 +1,5 @@ -export default { - DATASOURCE_CONNECTORS: [ +export default { + DATASOURCE_CONNECTORS: [ "box", "comscore", "db", @@ -22,9 +22,9 @@ export default { "survey_monkey", "versature", "xero", - "xmla", - ], - REFRESH_INTERVALS: [ + "xmla", + ], + REFRESH_INTERVALS: [ "0", "60", "300", @@ -35,6 +35,6 @@ export default { "10800", "14400", "43200", - "86400", - ], + "86400", + ], }; From 9aed6617ecbda15c9c92d5f417da4e492db042d9 Mon Sep 17 00:00:00 2001 From: Leo Vu Date: Fri, 17 Jan 2025 08:41:25 +0700 Subject: [PATCH 12/13] Make additional properties optional --- components/klipfolio/klipfolio.app.mjs | 1 + 1 file changed, 1 insertion(+) diff --git a/components/klipfolio/klipfolio.app.mjs b/components/klipfolio/klipfolio.app.mjs index eabdae91375ff..f0def5c7c41fd 100644 --- a/components/klipfolio/klipfolio.app.mjs +++ b/components/klipfolio/klipfolio.app.mjs @@ -61,6 +61,7 @@ export default { type: "object", label: "Additional Properties", description: "Data source additional properties. For example, Google Analytics API has the following properties: `oauth_provider_id`, `oauth_user_header`, `oauth_user_token`, `token_id`, `prop:profile_id`.", + optional: true }, }, methods: { From 1c658fc499e1b18e85e3c0182ee1c51ee2f2172e Mon Sep 17 00:00:00 2001 From: Lucas Caresia Date: Tue, 21 Jan 2025 08:35:03 -0300 Subject: [PATCH 13/13] Update klipfolio.app.mjs --- components/klipfolio/klipfolio.app.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/klipfolio/klipfolio.app.mjs b/components/klipfolio/klipfolio.app.mjs index f0def5c7c41fd..e7fabc40b3685 100644 --- a/components/klipfolio/klipfolio.app.mjs +++ b/components/klipfolio/klipfolio.app.mjs @@ -61,7 +61,7 @@ export default { type: "object", label: "Additional Properties", description: "Data source additional properties. For example, Google Analytics API has the following properties: `oauth_provider_id`, `oauth_user_header`, `oauth_user_token`, `token_id`, `prop:profile_id`.", - optional: true + optional: true, }, }, methods: {