Skip to content

Commit b23c590

Browse files
committed
new components
1 parent 9bdc89b commit b23c590

File tree

7 files changed

+185
-8
lines changed

7 files changed

+185
-8
lines changed

components/dropbox/actions/create-update-share-link/create-update-share-link.mjs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
name: "Create/Update a Share Link",
66
description: "Creates or updates a public share link to the file or folder (It allows you to share the file or folder with anyone). [See the documentation](https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#sharingCreateSharedLinkWithSettings__anchor)",
77
key: "dropbox-create-update-share-link",
8-
version: "0.0.11",
8+
version: "0.0.12",
99
type: "action",
1010
props: {
1111
...common.props,
@@ -66,6 +66,13 @@ export default {
6666
optional: true,
6767
options: consts.CREATE_SHARED_LINK_ACCESS_OPTIONS,
6868
};
69+
props.audience = {
70+
type: "string",
71+
label: "Audience",
72+
description: "The audience for the shared link",
73+
optional: true,
74+
options: consts.CREATE_SHARED_LINK_AUDIENCE_OPTIONS,
75+
};
6976
}
7077

7178
return props;
@@ -84,6 +91,7 @@ export default {
8491
linkPassword,
8592
expires,
8693
access,
94+
audience,
8795
} = this;
8896

8997
const accountType = await this.getCurrentAccount();
@@ -107,6 +115,7 @@ export default {
107115
expires,
108116
access,
109117
allow_download: allowDownload,
118+
audience,
110119
},
111120
});
112121
$.export("$summary", `Shared link for "${path?.label || path}" successfully created`);
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import dropbox from "../../dropbox.app.mjs";
2+
3+
export default {
4+
name: "Get Shared Link File",
5+
description: "Get a file from a shared link. [See the documentation](https://www.dropbox.com/developers/documentation/http/documentation#sharing-get_shared_link_file)",
6+
key: "dropbox-get-shared-link-file",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
dropbox,
11+
sharedLinkUrl: {
12+
propDefinition: [
13+
dropbox,
14+
"sharedLinkUrl",
15+
],
16+
},
17+
linkPassword: {
18+
propDefinition: [
19+
dropbox,
20+
"linkPassword",
21+
],
22+
},
23+
},
24+
async run({ $ }) {
25+
const { result } = await this.dropbox.getSharedLinkFile({
26+
url: this.sharedLinkUrl,
27+
password: this.linkPassword,
28+
});
29+
$.export("$summary", "Successfully retrieved shared link file");
30+
return result;
31+
},
32+
};
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import dropbox from "../../dropbox.app.mjs";
2+
3+
export default {
4+
name: "Get Shared Link Metadata",
5+
description: "Retrieves the shared link metadata for a given shared link. [See the documentation](https://www.dropbox.com/developers/documentation/http/documentation#sharing-get_shared_link_metadata)",
6+
key: "dropbox-get-shared-link-metadata",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
dropbox,
11+
sharedLinkUrl: {
12+
propDefinition: [
13+
dropbox,
14+
"sharedLinkUrl",
15+
],
16+
},
17+
linkPassword: {
18+
propDefinition: [
19+
dropbox,
20+
"linkPassword",
21+
],
22+
},
23+
},
24+
async run({ $ }) {
25+
const { result } = await this.dropbox.getSharedLinkMetadata({
26+
url: this.sharedLinkUrl,
27+
link_password: this.linkPassword,
28+
});
29+
$.export("$summary", "Successfully retrieved shared link metadata");
30+
return result;
31+
},
32+
};
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import dropbox from "../../dropbox.app.mjs";
2+
3+
export default {
4+
key: "dropbox-list-shared-links",
5+
name: "List Shared Links",
6+
description: "Retrieves a list of shared links for a given path. [See the documentation](https://www.dropbox.com/developers/documentation/http/documentation#sharing-list_shared_links)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
dropbox,
11+
path: {
12+
propDefinition: [
13+
dropbox,
14+
"path",
15+
() => ({
16+
initialOptions: [],
17+
filter: ({ metadata: { metadata: { [".tag"]: type } } }) => [
18+
"file",
19+
"folder",
20+
].includes(type),
21+
}),
22+
],
23+
optional: true,
24+
description: "Type the file or folder name to search for it in the user's Dropbox",
25+
},
26+
},
27+
async run({ $ }) {
28+
const sharedLinks = [];
29+
let hasMore;
30+
const args = {
31+
path: this.path?.value || this.path,
32+
};
33+
34+
do {
35+
const {
36+
result: {
37+
links, cursor, has_more,
38+
},
39+
} = await this.dropbox.listSharedLinks(args);
40+
sharedLinks.push(...links);
41+
args.cursor = cursor;
42+
hasMore = has_more;
43+
} while (hasMore);
44+
45+
$.export("$summary", `Successfully retrieved ${sharedLinks.length} shared link${sharedLinks.length === 1
46+
? ""
47+
: "s"}.`);
48+
return sharedLinks;
49+
},
50+
};

components/dropbox/common/consts.mjs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@ export default {
2828
"public",
2929
"team",
3030
"no_one",
31-
"password",
32-
"members",
33-
"other",
3431
],
3532
CREATE_SHARED_LINK_ACCESS_OPTIONS: [
3633
{

components/dropbox/dropbox.app.mjs

Lines changed: 60 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,38 @@ export default {
9696
}
9797
},
9898
},
99+
sharedLinkUrl: {
100+
type: "string",
101+
label: "Shared Link URL",
102+
description: "The URL of a shared link",
103+
async options({ prevContext }) {
104+
const {
105+
result: {
106+
links, cursor,
107+
},
108+
} = await this.listSharedLinks({
109+
cursor: prevContext?.cursor,
110+
});
111+
const options = links?.map(({
112+
url: value, name: label,
113+
}) => ({
114+
value,
115+
label: `${label} - ${value}`,
116+
})) || [];
117+
return {
118+
options,
119+
context: {
120+
cursor,
121+
},
122+
};
123+
},
124+
},
125+
linkPassword: {
126+
type: "string",
127+
label: "Link Password",
128+
description: "The password required to access the shared link",
129+
optional: true,
130+
},
99131
fileRevision: {
100132
type: "string",
101133
label: "Revision",
@@ -357,17 +389,18 @@ export default {
357389
this.normalizeError(err);
358390
}
359391
},
360-
async createSharedLink(args) {
392+
async createSharedLink(args) { console.log(args);
361393
try {
362394
const dpx = await this.sdk();
363395
const links = await dpx.sharingListSharedLinks({
364396
path: args.path,
365397
});
366-
if (links.result?.links.length > 0) {
398+
const link = links.result?.links.find((l) => l.path_lower === args.path); console.log(link);
399+
if (link) {
367400
return await dpx.sharingModifySharedLinkSettings({
368401
...args,
369402
path: undefined,
370-
url: links.result?.links[0].url,
403+
url: link.url,
371404
remove_expiration: isEmpty(args.remove_expiration)
372405
? false
373406
: args.remove_expiration,
@@ -382,6 +415,30 @@ export default {
382415
this.normalizeError(err);
383416
}
384417
},
418+
async listSharedLinks(args) {
419+
try {
420+
const dpx = await this.sdk();
421+
return await dpx.sharingListSharedLinks(args);
422+
} catch (err) {
423+
this.normalizeError(err);
424+
}
425+
},
426+
async getSharedLinkMetadata(args) {
427+
try {
428+
const dpx = await this.sdk();
429+
return await dpx.sharingGetSharedLinkMetadata(args);
430+
} catch (err) {
431+
this.normalizeError(err);
432+
}
433+
},
434+
async getSharedLinkFile(args) {
435+
try {
436+
const dpx = await this.sdk();
437+
return await dpx.sharingGetSharedLinkFile(args);
438+
} catch (err) {
439+
this.normalizeError(err);
440+
}
441+
},
385442
async deleteFileFolder(args) {
386443
try {
387444
const dpx = await this.sdk();

components/dropbox/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/dropbox",
3-
"version": "1.0.1",
3+
"version": "1.1.0",
44
"description": "Pipedream Dropbox Components",
55
"main": "dropbox.app.mjs",
66
"keywords": [

0 commit comments

Comments
 (0)