diff --git a/components/short/actions/create-a-link/create-a-link.mjs b/components/short/actions/create-a-link/create-a-link.mjs index 5aca310dc4e6c..ddb577e56c54e 100644 --- a/components/short/actions/create-a-link/create-a-link.mjs +++ b/components/short/actions/create-a-link/create-a-link.mjs @@ -2,19 +2,39 @@ import shortApp from "../../short.app.mjs"; import common from "../common/common.mjs"; import lodash from "lodash"; +const { + props: { // eslint-disable-next-line no-unused-vars + domain, ...props + }, +} = common; + export default { key: "short-create-a-link", - name: "Create a Short Link", - description: "Create a Short Link. [See the docs](https://developers.short.io/reference/linkspost).", - version: "0.0.1", + name: "Create Link", + description: "Create a Short Link. [See the documentation](https://developers.short.io/reference/linkspost).", + version: "0.1.0", type: "action", props: { shortApp, - ...common.props, + domainId: { + propDefinition: [ + shortApp, + "domainId", + ], + }, + ...props, + folderId: { + propDefinition: [ + shortApp, + "folderId", + ({ domainId }) => ({ + domainId, + }), + ], + }, }, async run({ $ }) { const param = lodash.pick(this, [ - "domain", "originalURL", "path", "title", @@ -32,8 +52,13 @@ export default { "utmContent", "cloaking", "redirectType", + "folderId", ]); - const link = await this.shortApp.createLink($, param); + const { hostname: domain } = await this.shortApp.getDomainInfo(this.domainId); + const link = await this.shortApp.createLink($, { + domain, + ...param, + }); $.export("$summary", `Successfully created the link: ${link.secureShortURL}`); return link; }, diff --git a/components/short/actions/delete-a-link/delete-a-link.mjs b/components/short/actions/delete-a-link/delete-a-link.mjs index 485251d0bc6e5..8599db080e796 100644 --- a/components/short/actions/delete-a-link/delete-a-link.mjs +++ b/components/short/actions/delete-a-link/delete-a-link.mjs @@ -2,9 +2,9 @@ import shortApp from "../../short.app.mjs"; export default { key: "short-delete-a-link", - name: "Delete a Short Link", - description: "Delete a Short Link. [See the docs](https://developers.short.io/reference/linksbylinkiddelete).", - version: "0.0.1", + name: "Delete Link", + description: "Delete a Short Link. [See the documentation](https://developers.short.io/reference/linksbylinkiddelete).", + version: "0.0.2", type: "action", props: { shortApp, diff --git a/components/short/actions/domain-statistics/domain-statistics.mjs b/components/short/actions/domain-statistics/domain-statistics.mjs index d5d3eb6666985..f2ae2516e46fb 100644 --- a/components/short/actions/domain-statistics/domain-statistics.mjs +++ b/components/short/actions/domain-statistics/domain-statistics.mjs @@ -3,9 +3,9 @@ import lodash from "lodash"; export default { key: "short-domain-statistics", - name: "Domain Statistics.", - description: "Returns detailed statistics for domain in given period. [See the docs](https://developers.short.io/reference/getdomaindomainid).", - version: "0.0.1", + name: "Get Domain Statistics", + description: "Returns detailed statistics for a domain in given period. [See the documentation](https://developers.short.io/reference/getdomaindomainid).", + version: "0.0.2", type: "action", props: { shortApp, diff --git a/components/short/actions/expire-a-link/expire-a-link.mjs b/components/short/actions/expire-a-link/expire-a-link.mjs index 681bdcbce7148..60d8db137f26f 100644 --- a/components/short/actions/expire-a-link/expire-a-link.mjs +++ b/components/short/actions/expire-a-link/expire-a-link.mjs @@ -3,9 +3,9 @@ import lodash from "lodash"; export default { key: "short-expire-a-link", - name: "Expire a Link.", - description: "Expire a link by id. [See the docs](https://developers.short.io/reference/linksbylinkidpost).", - version: "0.0.1", + name: "Expire Link", + description: "Expire a short link by id. [See the documentation](https://developers.short.io/reference/linksbylinkidpost).", + version: "0.0.2", type: "action", props: { shortApp, diff --git a/components/short/actions/update-a-link/update-a-link.mjs b/components/short/actions/update-a-link/update-a-link.mjs index 2fee030695568..03f8a7f965d1a 100644 --- a/components/short/actions/update-a-link/update-a-link.mjs +++ b/components/short/actions/update-a-link/update-a-link.mjs @@ -4,9 +4,9 @@ import lodash from "lodash"; export default { key: "short-update-a-link", - name: "Update a Short Link.", - description: "Update original url, title or path for existing URL by id. [See the docs](https://developers.short.io/reference/linksbylinkidpost).", - version: "0.0.1", + name: "Update Link", + description: "Update original URL, title or path for existing URL by id. [See the documentation](https://developers.short.io/reference/linksbylinkidpost).", + version: "0.0.2", type: "action", props: { shortApp, diff --git a/components/short/package.json b/components/short/package.json index b3cc2202a2de0..c493777081cb2 100644 --- a/components/short/package.json +++ b/components/short/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/short", - "version": "0.0.5", + "version": "0.1.0", "description": "Pipedream Short.io Components", "main": "short.app.mjs", "keywords": [ diff --git a/components/short/short.app.mjs b/components/short/short.app.mjs index 4709b85368fcf..8c9991e745ef8 100644 --- a/components/short/short.app.mjs +++ b/components/short/short.app.mjs @@ -20,6 +20,15 @@ export default { return this.listDomainsOpts(true); }, }, + folderId: { + type: "string", + label: "Folder ID", + description: "The folder to use.", + optional: true, + async options({ domainId }) { + return this.listFolderOptions(domainId); + }, + }, originalURL: { type: "string", label: "Original URL", @@ -325,5 +334,21 @@ export default { })); return response; }, + async getDomainInfo(domainId) { + return axios(this, this._getRequestParams({ + path: `/domains/${domainId}`, + })); + }, + async listFolderOptions(domainId) { + const response = await axios(this, this._getRequestParams({ + path: `/links/folders/${domainId}`, + })); + return response.linkFolders?.map(({ + id, name, + }) => ({ + label: name, + value: id, + })); + }, }, }; diff --git a/components/short/sources/new-link-created/new-link-created.mjs b/components/short/sources/new-link-created/new-link-created.mjs index c3c9a499bd428..52ee94e855301 100644 --- a/components/short/sources/new-link-created/new-link-created.mjs +++ b/components/short/sources/new-link-created/new-link-created.mjs @@ -3,9 +3,9 @@ import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform"; export default { key: "short-new-link-created", - name: "New event for each link created.", + name: "New Link Created", description: "Emit new event when a link is created.", - version: "0.0.3", + version: "0.0.4", type: "source", dedupe: "unique", props: {