diff --git a/components/wolfram_alpha/actions/perform-computation/perform-computation.mjs b/components/wolfram_alpha/actions/perform-computation/perform-computation.mjs new file mode 100644 index 0000000000000..daffdc3f8e428 --- /dev/null +++ b/components/wolfram_alpha/actions/perform-computation/perform-computation.mjs @@ -0,0 +1,81 @@ +import app from "../../wolfram_alpha.app.mjs"; + +export default { + key: "wolfram_alpha-perform-computation", + name: "Perform Computation", + description: "Executes a computation query using the Wolfram Alpha API. [See the documentation](https://products.wolframalpha.com/api/documentation)", + version: "0.0.1", + type: "action", + props: { + app, + input: { + type: "string", + label: "Input", + description: "Text specifying the input string.", + }, + width: { + type: "string", + label: "Width", + description: "Specify an approximate width limit for text and tables. Eg. `200`, `500`. This parameter does not affect plots or graphics. Width values are approximate; behavior may vary for different content.", + optional: true, + }, + maxWidth: { + type: "string", + label: "Max Width", + description: "Specify an extended maximum width for large objects. Eg. `200`, `500`. This parameter does not affect plots or graphics. Width values are approximate; behavior may vary for different content.", + optional: true, + }, + plotWidth: { + type: "string", + label: "Plot Width", + description: "Specify an approximate width limit for plots and graphics. Eg. `100`, `200`. This parameter does not affect text or tables. Width values are approximate; behavior may vary for different content.", + optional: true, + }, + mag: { + type: "string", + label: "Magnification", + description: "Specify magnification of objects within a pod. Eg. `0.5`, `1.0`, `2.0`. Changing this parameter does not affect the overall size of pods.", + optional: true, + }, + assumption: { + type: "string", + label: "Assumption", + description: "Specifies an assumption, such as the meaning of a word or the value of a formula variable. Eg. `*C.pi-_*Movie`, `DateOrder_**Day.Month.Year--`. Assumptions made implicitly by the API. Values for this parameter are given by the input properties of `` subelements of `` elements in XML results.", + optional: true, + }, + }, + methods: { + performComputation(args = {}) { + return this.app.makeRequest({ + path: "/llm-api", + ...args, + }); + }, + }, + async run({ $ }) { + const { + performComputation, + input, + width, + maxWidth, + plotWidth, + mag, + assumption, + } = this; + + const response = await performComputation({ + $, + params: { + input, + width, + maxwidth: maxWidth, + plotwidth: plotWidth, + mag, + assumption, + }, + }); + + $.export("$summary", "Computation performed successfully"); + return response; + }, +}; diff --git a/components/wolfram_alpha/common/constants.mjs b/components/wolfram_alpha/common/constants.mjs new file mode 100644 index 0000000000000..3b9f30472c918 --- /dev/null +++ b/components/wolfram_alpha/common/constants.mjs @@ -0,0 +1,7 @@ +const BASE_URL = "https://www.wolframalpha.com"; +const VERSION_PATH = "/api/v1"; + +export default { + BASE_URL, + VERSION_PATH, +}; diff --git a/components/wolfram_alpha/package.json b/components/wolfram_alpha/package.json index 59438df9afa6b..29e6de1510245 100644 --- a/components/wolfram_alpha/package.json +++ b/components/wolfram_alpha/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/wolfram_alpha", - "version": "0.0.1", + "version": "0.1.0", "description": "Pipedream Wolfram Alpha Components", "main": "wolfram_alpha.app.mjs", "keywords": [ @@ -11,5 +11,8 @@ "author": "Pipedream (https://pipedream.com/)", "publishConfig": { "access": "public" + }, + "dependencies": { + "@pipedream/platform": "^3.0.3" } -} \ No newline at end of file +} diff --git a/components/wolfram_alpha/wolfram_alpha.app.mjs b/components/wolfram_alpha/wolfram_alpha.app.mjs index 6bfa6b5006c3e..98cac1a0d57e3 100644 --- a/components/wolfram_alpha/wolfram_alpha.app.mjs +++ b/components/wolfram_alpha/wolfram_alpha.app.mjs @@ -1,11 +1,27 @@ +import { axios } from "@pipedream/platform"; +import constants from "./common/constants.mjs"; + export default { type: "app", app: "wolfram_alpha", - propDefinitions: {}, methods: { - // this.$auth contains connected account data - authKeys() { - console.log(Object.keys(this.$auth)); + getUrl(path) { + return `${constants.BASE_URL}${constants.VERSION_PATH}${path}`; + }, + getAuthParams(params) { + return { + ...params, + appid: this.$auth.app_id, + }; + }, + makeRequest({ + $ = this, path, params, ...args + } = {}) { + return axios($, { + ...args, + url: this.getUrl(path), + params: this.getAuthParams(params), + }); }, }, }; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c923106a30908..b4c176d0b4499 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1891,11 +1891,9 @@ importers: components/clarify: {} - components/claris_filemaker_server_admin_api: - specifiers: {} + components/claris_filemaker_server_admin_api: {} - components/claris_filemaker_server_data_api: - specifiers: {} + components/claris_filemaker_server_data_api: {} components/claris_filemaker_server_odata_api: {} @@ -6810,8 +6808,7 @@ importers: specifier: ^1.5.1 version: 1.6.6 - components/morgen: - specifiers: {} + components/morgen: {} components/morningmate: dependencies: @@ -12003,7 +12000,11 @@ importers: specifier: ^1.6.5 version: 1.6.6 - components/wolfram_alpha: {} + components/wolfram_alpha: + dependencies: + '@pipedream/platform': + specifier: ^3.0.3 + version: 3.0.3 components/wolfram_alpha_api: {} @@ -32230,8 +32231,6 @@ snapshots: '@putout/operator-filesystem': 5.0.0(putout@36.13.1(eslint@8.57.1)(typescript@5.6.3)) '@putout/operator-json': 2.2.0 putout: 36.13.1(eslint@8.57.1)(typescript@5.6.3) - transitivePeerDependencies: - - supports-color '@putout/operator-regexp@1.0.0(putout@36.13.1(eslint@8.57.1)(typescript@5.6.3))': dependencies: