Skip to content

Commit 36b8610

Browse files
authored
Confluence new action (#17483)
* Initial action generation * version bump * pnpm * Create Page adjustments * version bumps
1 parent 56fde23 commit 36b8610

File tree

11 files changed

+166
-14
lines changed

11 files changed

+166
-14
lines changed
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
import confluence from "../../confluence.app.mjs";
2+
3+
export default {
4+
key: "confluence-create-page",
5+
name: "Create Page",
6+
description: "Creates a new page in the space. [See the documentation](https://developer.atlassian.com/cloud/confluence/rest/v2/api-group-page/#api-pages-post)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
confluence,
11+
draftInfo: {
12+
type: "alert",
13+
alertType: "info",
14+
content: "Pages are created as published by default, unless specified as a draft in the `Status` prop.",
15+
},
16+
spaceId: {
17+
propDefinition: [
18+
confluence,
19+
"spaceId",
20+
],
21+
},
22+
title: {
23+
propDefinition: [
24+
confluence,
25+
"title",
26+
],
27+
description: "The title of the page",
28+
},
29+
body: {
30+
propDefinition: [
31+
confluence,
32+
"body",
33+
],
34+
description: "The body of the page",
35+
},
36+
status: {
37+
propDefinition: [
38+
confluence,
39+
"status",
40+
],
41+
description: "The status of the page, specifies if the page will be created as a new page or a draft.",
42+
},
43+
parentId: {
44+
propDefinition: [
45+
confluence,
46+
"parentId",
47+
({ spaceId }) => ({
48+
spaceId,
49+
}),
50+
],
51+
optional: true,
52+
},
53+
subtype: {
54+
type: "string",
55+
label: "Subtype",
56+
description: "The subtype of the page",
57+
optional: true,
58+
options: [
59+
"live",
60+
],
61+
},
62+
embedded: {
63+
type: "boolean",
64+
label: "Embedded",
65+
description: "Whether the page should be embedded",
66+
optional: true,
67+
},
68+
private: {
69+
type: "boolean",
70+
label: "Private",
71+
description: "Whether the page should be private",
72+
optional: true,
73+
},
74+
rootLevel: {
75+
type: "boolean",
76+
label: "Root Level",
77+
description: "Whether the page should be created at the root level",
78+
optional: true,
79+
},
80+
},
81+
async run({ $ }) {
82+
const response = await this.confluence.createPage({
83+
$,
84+
cloudId: await this.confluence.getCloudId({
85+
$,
86+
}),
87+
data: {
88+
spaceId: this.spaceId,
89+
status: this.status,
90+
title: this.title,
91+
parentId: this.parentId,
92+
subtype: this.subtype,
93+
body: {
94+
representation: "storage",
95+
value: this.body,
96+
},
97+
},
98+
params: {
99+
"embedded": this.embedded,
100+
"private": this.private,
101+
"root-level": this.rootLevel,
102+
},
103+
});
104+
105+
$.export("$summary", `Successfully created page with ID: ${response.id}`);
106+
return response;
107+
},
108+
};

components/confluence/actions/create-post/create-post.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "confluence-create-post",
55
name: "Create Post",
66
description: "Creates a new page or blog post on Confluence. [See the documentation](https://developer.atlassian.com/cloud/confluence/rest/v2/api-group-blog-post/#api-blogposts-post)",
7-
version: "0.0.2",
7+
version: "0.0.3",
88
type: "action",
99
props: {
1010
confluence,

components/confluence/actions/delete-post/delete-post.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "confluence-delete-post",
55
name: "Delete Post",
66
description: "Removes a blog post from Confluence by its ID. Use with caution, the action is irreversible. [See the documentation](https://developer.atlassian.com/cloud/confluence/rest/v2/api-group-blog-post/#api-blogposts-id-delete)",
7-
version: "0.0.2",
7+
version: "0.0.3",
88
type: "action",
99
props: {
1010
confluence,

components/confluence/actions/search-content/search-content.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "confluence-search-content",
55
name: "Search Content",
66
description: "Searches for content using the Confluence Query Language (CQL). [See the documentation](https://developer.atlassian.com/cloud/confluence/rest/v1/api-group-search#api-wiki-rest-api-search-get)",
7-
version: "0.0.1",
7+
version: "0.0.2",
88
type: "action",
99
props: {
1010
confluence,

components/confluence/actions/update-post/update-post.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
key: "confluence-update-post",
66
name: "Update a Post",
77
description: "Updates a page or blog post on Confluence by its ID. [See the documentation](https://developer.atlassian.com/cloud/confluence/rest/v2/api-group-blog-post/#api-blogposts-id-put)",
8-
version: "0.0.2",
8+
version: "0.0.3",
99
type: "action",
1010
props: {
1111
confluence,

components/confluence/confluence.app.mjs

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default {
77
postId: {
88
type: "string",
99
label: "Post ID",
10-
description: "The ID of the post",
10+
description: "Select a post or provide its ID",
1111
async options({ prevContext }) {
1212
const params = prevContext?.cursor
1313
? {
@@ -37,8 +37,8 @@ export default {
3737
},
3838
spaceId: {
3939
type: "string",
40-
label: "Space Id",
41-
description: "The Id of the space",
40+
label: "Space ID",
41+
description: "Select a space or provide its ID",
4242
async options({ prevContext }) {
4343
const params = prevContext?.cursor
4444
? {
@@ -86,6 +86,43 @@ export default {
8686
label: "Body",
8787
description: "Body of the blog post",
8888
},
89+
parentId: {
90+
type: "string",
91+
label: "Parent Page ID",
92+
description: "Select a parent page or provide its ID",
93+
async options({
94+
prevContext, spaceId,
95+
}) {
96+
if (!spaceId) {
97+
return [];
98+
}
99+
const params = prevContext?.cursor
100+
? {
101+
cursor: prevContext.cursor,
102+
}
103+
: {};
104+
const cloudId = await this.getCloudId();
105+
const {
106+
results, _links: links,
107+
} = await this.listPagesInSpace({
108+
cloudId,
109+
spaceId,
110+
params,
111+
});
112+
const options = results?.map(({
113+
id: value, title: label,
114+
}) => ({
115+
value,
116+
label,
117+
})) || [];
118+
return {
119+
options,
120+
context: {
121+
cursor: this._extractCursorFromLink(links?.next),
122+
},
123+
};
124+
},
125+
},
89126
},
90127
methods: {
91128
_baseUrl(cloudId) {
@@ -175,6 +212,13 @@ export default {
175212
...opts,
176213
});
177214
},
215+
createPage(opts = {}) {
216+
return this._makeRequest({
217+
method: "POST",
218+
path: "/pages",
219+
...opts,
220+
});
221+
},
178222
deletePost({
179223
postId, ...opts
180224
}) {

components/confluence/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/confluence",
3-
"version": "0.1.0",
3+
"version": "0.2.0",
44
"description": "Pipedream Confluence Components",
55
"main": "confluence.app.mjs",
66
"keywords": [
@@ -13,6 +13,6 @@
1313
"access": "public"
1414
},
1515
"dependencies": {
16-
"@pipedream/platform": "^3.0.3"
16+
"@pipedream/platform": "^3.1.0"
1717
}
1818
}

components/confluence/sources/new-page-or-blog-post/new-page-or-blog-post.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default {
66
key: "confluence-new-page-or-blog-post",
77
name: "New Page or Blog Post",
88
description: "Emit new event whenever a new page or blog post is created in a specified space",
9-
version: "0.0.2",
9+
version: "0.0.3",
1010
type: "source",
1111
dedupe: "unique",
1212
props: {

components/confluence/sources/watch-blog-posts/watch-blog-posts.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default {
66
key: "confluence-watch-blog-posts",
77
name: "Watch Blog Posts",
88
description: "Emit new event when a blog post is created or updated",
9-
version: "0.0.2",
9+
version: "0.0.3",
1010
type: "source",
1111
dedupe: "unique",
1212
methods: {

components/confluence/sources/watch-pages/watch-pages.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default {
66
key: "confluence-watch-pages",
77
name: "Watch Pages",
88
description: "Emit new event when a page is created or updated in Confluence",
9-
version: "0.0.2",
9+
version: "0.0.3",
1010
type: "source",
1111
dedupe: "unique",
1212
methods: {

0 commit comments

Comments
 (0)