Skip to content

Commit 5694736

Browse files
committed
Merge remote-tracking branch 'origin/master' into issue-12244
2 parents ac0d4cb + 62beaa3 commit 5694736

File tree

44 files changed

+1449
-250
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1449
-250
lines changed
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
import app from "../../documenterra.app.mjs";
2+
3+
export default {
4+
key: "documenterra-create-page",
5+
name: "Create Page",
6+
description: "Creates a new page. [See the documentation](https://documenterra.ru/docs/user-manual/api-sozdaniye-stranitsy.html)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
projectId: {
12+
propDefinition: [
13+
app,
14+
"projectId",
15+
],
16+
},
17+
id: {
18+
type: "string",
19+
label: "Page ID",
20+
description: "The unique identifier for the page.",
21+
},
22+
assigneeUserName: {
23+
type: "string",
24+
label: "Assignee User Name",
25+
description: "Login of the artist to whom the page is assigned.",
26+
},
27+
ownerUserName: {
28+
type: "string",
29+
label: "Owner User Name",
30+
description: "The name of the user who is the owner of the page.",
31+
},
32+
statusName: {
33+
type: "string",
34+
label: "Status Name",
35+
description: "Page workflow status.",
36+
options: [
37+
"Ready",
38+
"Draft",
39+
"Under Review",
40+
],
41+
},
42+
title: {
43+
type: "string",
44+
label: "Page Title",
45+
description: "The title of the page.",
46+
optional: true,
47+
},
48+
bodyHtml: {
49+
type: "string",
50+
label: "Body HTML",
51+
description: "HTML content of the page.",
52+
optional: true,
53+
},
54+
indexKeywords: {
55+
type: "string[]",
56+
label: "Index Keywords",
57+
description: "An array of strings containing keywords to be used when creating the page.",
58+
optional: true,
59+
},
60+
},
61+
methods: {
62+
createPage({
63+
projectId, ...args
64+
} = {}) {
65+
return this.app.post({
66+
path: `/projects/${projectId}/articles`,
67+
...args,
68+
});
69+
},
70+
},
71+
async run({ $ }) {
72+
const {
73+
createPage,
74+
projectId,
75+
assigneeUserName,
76+
id,
77+
ownerUserName,
78+
statusName,
79+
title,
80+
bodyHtml,
81+
indexKeywords,
82+
} = this;
83+
84+
const response = await createPage({
85+
$,
86+
projectId,
87+
data: {
88+
assigneeUserName,
89+
id,
90+
ownerUserName,
91+
statusName,
92+
title,
93+
bodyHtml,
94+
indexKeywords,
95+
},
96+
});
97+
98+
$.export("$summary", `Successfully created a new page with ID: \`${response?.id}\`.`);
99+
return response;
100+
},
101+
};
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import app from "../../documenterra.app.mjs";
2+
3+
export default {
4+
key: "documenterra-create-project-backup",
5+
name: "Create Project Backup",
6+
description: "Creates a backup of a project. [See the documentation](https://documenterra.ru/docs/user-manual/api-sozdaniye-rezervnoy-kopii-proyekta.html)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
projectId: {
12+
propDefinition: [
13+
app,
14+
"projectId",
15+
],
16+
},
17+
outputFileName: {
18+
propDefinition: [
19+
app,
20+
"outputFileName",
21+
],
22+
},
23+
},
24+
async run({ $ }) {
25+
const {
26+
app,
27+
projectId,
28+
outputFileName,
29+
} = this;
30+
31+
const response = await app.createProject({
32+
$,
33+
projectId,
34+
params: {
35+
action: "download",
36+
},
37+
data: {
38+
outputFileName,
39+
},
40+
});
41+
42+
$.export("$summary", `Successfully created project backup with taskKey: \`${response?.taskKey}\`.`);
43+
return response;
44+
},
45+
};
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
import app from "../../documenterra.app.mjs";
2+
import constants from "../../common/constants.mjs";
3+
4+
export default {
5+
key: "documenterra-export-publication",
6+
name: "Export Publication",
7+
description: "Exports an existing publication to a user-selected format. [See the documentation](https://documenterra.ru/docs/user-manual/api-eksport-publikatsii.html)",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
app,
12+
projectId: {
13+
label: "Publication ID",
14+
description: "The unique identifier for the publication.",
15+
propDefinition: [
16+
app,
17+
"projectId",
18+
() => ({
19+
filter: ({ parentId }) => !!parentId,
20+
}),
21+
],
22+
},
23+
outputFileName: {
24+
description: "The full name of the output file. If the output file is saved to Documenterra's file storage (the default), the full file name must be specified, including the file path starting with `Storage/` Eg. `Storage/export-files/deep-space-1.0-docs.zip`.",
25+
propDefinition: [
26+
app,
27+
"outputFileName",
28+
],
29+
},
30+
format: {
31+
type: "string",
32+
label: "Format",
33+
description: "The format of the publication to be exported.",
34+
options: constants.PRINTED_FORMAT_OPTIONS.concat(constants.OTHER_FORMAT_OPTIONS),
35+
reloadProps: true,
36+
},
37+
},
38+
additionalProps() {
39+
const {
40+
app,
41+
format,
42+
} = this;
43+
44+
const isPrintedFormat = constants.PRINTED_FORMAT_OPTIONS.some(({ value }) => value === format);
45+
46+
if (!isPrintedFormat) {
47+
return {};
48+
}
49+
return {
50+
exportPresetName: {
51+
type: "string",
52+
label: "Export Preset Name",
53+
description: `Full name of the Export Preset used. [See the settings page here](${app.getBaseUrl()}/settings/export-presets)`,
54+
default: "Default",
55+
},
56+
};
57+
},
58+
async run({ $ }) {
59+
const {
60+
app,
61+
projectId,
62+
format,
63+
outputFileName,
64+
exportPresetName,
65+
} = this;
66+
67+
const response = await app.createProject({
68+
$,
69+
projectId,
70+
params: {
71+
action: "export",
72+
},
73+
data: {
74+
format,
75+
outputFileName,
76+
exportPresetName,
77+
},
78+
});
79+
80+
$.export("$summary", `Successfully exported publication with task key \`${response.taskKey}\`.`);
81+
return response;
82+
},
83+
};
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
const PRINTED_FORMAT_OPTIONS = [
2+
{
3+
value: "Pdf",
4+
label: "Portable Document Format (.pdf)",
5+
},
6+
{
7+
value: "Docx",
8+
label: "OpenXML, Microsoft Word (.docx)",
9+
},
10+
{
11+
value: "Doc",
12+
label: "Microsoft Word 97-2003 (.doc)",
13+
},
14+
{
15+
value: "Rtf",
16+
label: "Rich Text Format (.rtf)",
17+
},
18+
{
19+
value: "Epub",
20+
label: "E-books and other digital publications (.epub)",
21+
},
22+
{
23+
value: "Odt",
24+
label: "OpenDocument, OpenOffice.org file format (.odt)",
25+
},
26+
{
27+
value: "Mht",
28+
label: "Web archive in one file (.mht)",
29+
},
30+
];
31+
32+
const OTHER_FORMAT_OPTIONS = [
33+
{
34+
value: "WebHelp",
35+
label: "HTML5 Web Help (no border, built-in search, page tree and index, one .zip archive)",
36+
},
37+
{
38+
value: "PureHtml",
39+
label: "HTML files (page content without user interface in one .zip archive)",
40+
},
41+
{
42+
value: "Chm",
43+
label: "Microsoft Compiled HTML Help (.chm)",
44+
},
45+
];
46+
47+
export default {
48+
PRINTED_FORMAT_OPTIONS,
49+
OTHER_FORMAT_OPTIONS,
50+
};
Lines changed: 99 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,106 @@
1+
import { axios } from "@pipedream/platform";
2+
13
export default {
24
type: "app",
35
app: "documenterra",
4-
propDefinitions: {},
6+
propDefinitions: {
7+
projectId: {
8+
type: "string",
9+
label: "Project Identity",
10+
description: "The unique identifier for the project.",
11+
async options({ filter = () => true }) {
12+
const response = await this.listProjects();
13+
return response
14+
?.filter(filter)
15+
.map(({
16+
id: value, title: label,
17+
}) => ({
18+
label,
19+
value,
20+
}));
21+
},
22+
},
23+
pageId: {
24+
type: "string",
25+
label: "Page ID",
26+
description: "The unique identifier for the page.",
27+
async options({ projectId }) {
28+
if (!projectId) {
29+
return [];
30+
}
31+
const response = await this.listPages({
32+
projectId,
33+
});
34+
return response?.map(({
35+
id: value, title: label,
36+
}) => ({
37+
label,
38+
value,
39+
}));
40+
},
41+
},
42+
outputFileName: {
43+
type: "string",
44+
label: "Output File Name",
45+
description: "The full file name, including the file path starting with `Storage/` Eg. `Storage/Backups/Project-backup_2023-03-13_03-46-07.zip`",
46+
},
47+
},
548
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
49+
getBaseUrl() {
50+
const { portal_url: baseUrl } = this.$auth;
51+
return baseUrl.endsWith("/")
52+
? baseUrl.slice(0, -1)
53+
: baseUrl;
54+
},
55+
getUrl(path) {
56+
return `${this.getBaseUrl()}/api/v1${path}`;
57+
},
58+
getAuth() {
59+
const {
60+
email: username,
61+
api_key: password,
62+
} = this.$auth;
63+
return {
64+
username,
65+
password,
66+
};
67+
},
68+
_makeRequest({
69+
$ = this, path, ...args
70+
} = {}) {
71+
return axios($, {
72+
...args,
73+
url: this.getUrl(path),
74+
auth: this.getAuth(),
75+
});
76+
},
77+
post(args = {}) {
78+
return this._makeRequest({
79+
method: "POST",
80+
...args,
81+
});
82+
},
83+
createProject({
84+
projectId, ...args
85+
} = {}) {
86+
return this.post({
87+
path: `/projects/${projectId}`,
88+
...args,
89+
});
90+
},
91+
listProjects(args = {}) {
92+
return this._makeRequest({
93+
path: "/projects",
94+
...args,
95+
});
96+
},
97+
listPages({
98+
projectId, ...args
99+
} = {}) {
100+
return this._makeRequest({
101+
path: `/projects/${projectId}/articles`,
102+
...args,
103+
});
9104
},
10105
},
11106
};

0 commit comments

Comments
 (0)