Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
52 changes: 51 additions & 1 deletion components/confluence/actions/get-page-by-id/get-page-by-id.mjs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import confluence from "../../confluence.app.mjs";
import { BODY_FORMAT_FULL_OPTIONS } from "../../common/constants.mjs";
import { parseObjectEntries } from "../../common/utils.mjs";

export default {
key: "confluence-get-page-by-id",
name: "Get Page by ID",
description: "Retrieve a page by its ID. [See the documentation](https://developer.atlassian.com/cloud/confluence/rest/v2/api-group-page/#api-pages-id-get)",
version: "0.0.2",
version: "0.1.0",
annotations: {
destructiveHint: false,
openWorldHint: true,
Expand All @@ -19,6 +21,47 @@ export default {
"pageId",
],
},
bodyFormat: {
type: "string",
label: "Body Format",
description: "The content format types to be returned in the `body` field of the response. If available, the representation will be available under a response field of the same name under the `body` field.",
optional: true,
options: BODY_FORMAT_FULL_OPTIONS,
},
getDraft: {
type: "boolean",
label: "Get Draft",
description: "If true, retrieves the draft version of this page.",
optional: true,
default: false,
},
status: {
type: "string[]",
label: "Status",
description: "Filter the page being retrieved by its status.",
optional: true,
options: [
"current",
"archived",
"trashed",
"deleted",
"historical",
"draft",
],
},
version: {
type: "integer",
label: "Version",
description: "Allows you to retrieve a previously published version. Specify the previous version's number to retrieve its details.",
optional: true,
},
additionalOptions: {
type: "object",
label: "Additional Options",
description:
"Additional parameters to send in the request. [See the documentation](https://developer.atlassian.com/cloud/confluence/rest/v2/api-group-page/#api-pages-id-get) for available parameters. Values will be parsed as JSON where applicable.",
optional: true,
},
},
async run({ $ }) {
const cloudId = await this.confluence.getCloudId({
Expand All @@ -28,6 +71,13 @@ export default {
$,
cloudId,
pageId: this.pageId,
params: {
"body-format": this.bodyFormat,
"get-draft": this.getDraft,
"status": this.status,
"version": this.version,
...parseObjectEntries(this.additionalOptions),
},
});
$.export("$summary", `Successfully retrieved page with ID: ${this.pageId}`);
return response;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "confluence-get-pages-in-space",
name: "Get Pages in Space",
description: "Retrieve a list of pages in a space. [See the documentation](https://developer.atlassian.com/cloud/confluence/rest/v2/api-group-page/#api-spaces-id-pages-get)",
version: "0.0.2",
version: "0.0.3",
annotations: {
destructiveHint: false,
openWorldHint: true,
Expand Down Expand Up @@ -43,12 +43,6 @@ export default {
"bodyFormat",
],
},
subType: {
propDefinition: [
confluence,
"subType",
],
},
cursor: {
propDefinition: [
confluence,
Expand All @@ -71,13 +65,12 @@ export default {
cloudId,
spaceId: this.spaceId,
params: {
sort: this.sort,
status: this.status,
title: this.pageTitle,
bodyFormat: this.bodyFormat,
subType: this.subType,
cursor: this.cursor,
limit: this.limit,
"sort": this.sort,
"status": this.status,
"title": this.pageTitle,
"body-format": this.bodyFormat,
"cursor": this.cursor,
"limit": this.limit,
},
});
$.export("$summary", `Successfully retrieved ${response.results.length} page${response.results.length === 1
Expand Down
16 changes: 8 additions & 8 deletions components/confluence/actions/get-pages/get-pages.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "confluence-get-pages",
name: "Get Pages",
description: "Retrieve a list of pages. [See the documentation](https://developer.atlassian.com/cloud/confluence/rest/v2/api-group-page/#api-pages-get)",
version: "0.0.2",
version: "0.0.3",
annotations: {
destructiveHint: false,
openWorldHint: true,
Expand Down Expand Up @@ -64,13 +64,13 @@ export default {
$,
cloudId,
params: {
sort: this.sort,
status: this.status,
title: this.pageTitle,
bodyFormat: this.bodyFormat,
subType: this.subType,
cursor: this.cursor,
limit: this.limit,
"sort": this.sort,
"status": this.status,
"title": this.pageTitle,
"body-format": this.bodyFormat,
"subtype": this.subType,
"cursor": this.cursor,
"limit": this.limit,
},
});
$.export("$summary", `Successfully retrieved ${response.results.length} page${response.results.length === 1
Expand Down
13 changes: 13 additions & 0 deletions components/confluence/common/constants.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export const BODY_FORMAT_OPTIONS = [
"storage",
"atlas_doc_format",
];

export const BODY_FORMAT_FULL_OPTIONS = [
...BODY_FORMAT_OPTIONS,
"view",
"export_view",
"anonymous_export_view",
"styled_view",
"editor",
];
29 changes: 29 additions & 0 deletions components/confluence/common/utils.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { ConfigurationError } from "@pipedream/platform";

function optionalParseAsJSON(value) {
try {
return JSON.parse(value);
} catch (e) {
return value;
}
}

export function parseObjectEntries(value = {}) {
if (typeof value === "string") {
try {
value = JSON.parse(value);
} catch (e) {
throw new ConfigurationError(`Invalid JSON string provided: ${e.message}`);
}
}

return Object.fromEntries(
Object.entries(value).map(([
key,
value,
]) => [
key,
optionalParseAsJSON(value),
]),
);
}
6 changes: 2 additions & 4 deletions components/confluence/confluence.app.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { axios } from "@pipedream/platform";
import { BODY_FORMAT_OPTIONS } from "./common/constants.mjs";

export default {
type: "app",
Expand Down Expand Up @@ -192,10 +193,7 @@ export default {
type: "string",
label: "Body Format",
description: "The content format types to be returned in the body field of the response. If available, the representation will be available under a response field of the same name under the body field.",
options: [
"storage",
"atlas_doc_format",
],
options: BODY_FORMAT_OPTIONS,
optional: true,
},
subType: {
Expand Down
2 changes: 1 addition & 1 deletion components/confluence/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/confluence",
"version": "0.3.0",
"version": "0.4.0",
"description": "Pipedream Confluence Components",
"main": "confluence.app.mjs",
"keywords": [
Expand Down
Loading