Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 31 additions & 6 deletions components/short/actions/create-a-link/create-a-link.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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;
},
Expand Down
6 changes: 3 additions & 3 deletions components/short/actions/delete-a-link/delete-a-link.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions components/short/actions/expire-a-link/expire-a-link.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions components/short/actions/update-a-link/update-a-link.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion components/short/package.json
Original file line number Diff line number Diff line change
@@ -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": [
Expand Down
25 changes: 25 additions & 0 deletions components/short/short.app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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,
}));
},
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
Loading