Skip to content

Commit f62e918

Browse files
committed
updates
1 parent 9e00ce2 commit f62e918

File tree

7 files changed

+122
-93
lines changed

7 files changed

+122
-93
lines changed

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

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,31 @@ import wordpress from "../../wordpress_com.app.mjs";
33
export default {
44
key: "wordpress_com-create-post",
55
name: "Create New Post",
6-
description: "Creates a new post on a WordPress.com site.",
7-
version: "0.0.5",
6+
description: "Creates a new post on a WordPress.com site. [See the documentation](https://developer.wordpress.com/docs/api/1.1/post/sites/%24site/posts/new/)",
7+
version: "0.0.1",
88
type: "action",
99
props: {
1010
wordpress,
1111
site: {
12-
type: "string",
13-
label: "Site ID or domain",
14-
description: "Enter a site ID or domain (e.g. testsit38.wordpress.com). Do not include 'https://' or 'www'.",
12+
propDefinition: [
13+
wordpress,
14+
"siteId",
15+
],
1516
},
1617
title: {
1718
type: "string",
1819
label: "Post Title",
19-
description: "The title of the post.",
20+
description: "The title of the post",
2021
},
2122
content: {
2223
type: "string",
2324
label: "Post Content",
24-
description: "The content of the post (HTML or text).",
25+
description: "The content of the post (HTML or text)",
2526
},
2627
status: {
2728
type: "string",
2829
label: "Status",
29-
description: "The status of the post.",
30+
description: "The status of the post",
3031
options: [
3132
"publish",
3233
"draft",
@@ -54,9 +55,7 @@ export default {
5455
optional: true,
5556
},
5657
},
57-
5858
async run({ $ }) {
59-
6059
const warnings = [];
6160

6261
const {
@@ -65,26 +64,23 @@ export default {
6564
...fields
6665
} = this;
6766

68-
warnings.push(...wordpress.checkDomainOrId(site)); // TEST
67+
warnings.push(...wordpress.checkDomainOrId(site));
6968

7069
let response;
7170

7271
try {
73-
response = await wordpress.createWordpressPost({ //TEST
74-
72+
response = await wordpress.createWordpressPost({
7573
$,
7674
site,
7775
data: {
7876
...fields,
7977
},
8078
});
81-
8279
} catch (error) {
8380
wordpress.throwCustomError("Could not create post", error, warnings);
8481
};
8582

8683
$.export("$summary", `Post successfully created. ID = ${response?.ID}` + "\n- " + warnings.join("\n- "));
8784
},
88-
8985
};
9086

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

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,31 @@
11
import wordpress from "../../wordpress_com.app.mjs";
22

33
export default {
4-
54
key: "wordpress_com-delete-post",
65
name: "Delete Post",
7-
description: "Deletes a post",
8-
version: "0.0.4",
6+
description: "Deletes a post. [See the documentation](https://developer.wordpress.com/docs/api/1.1/post/sites/%24site/posts/%24post_ID/delete/)",
7+
version: "0.0.1",
98
type: "action",
109
props: {
1110
wordpress,
1211
site: {
13-
label: "Domain or ID",
14-
type: "string",
15-
description: "Enter a site ID or domain (e.g. testsit38.wordpress.com).",
12+
propDefinition: [
13+
wordpress,
14+
"siteId",
15+
],
1616
},
1717
postId: {
18-
type: "integer",
19-
label: "Post ID",
20-
description: "The ID of the post you want to delete.",
18+
propDefinition: [
19+
wordpress,
20+
"postId",
21+
(c) => ({
22+
site: c.site,
23+
}),
24+
],
25+
description: "The ID of the post you want to delete",
2126
},
2227
},
23-
2428
async run({ $ }) {
25-
2629
const warnings = [];
2730

2831
const {

components/wordpress_com/actions/upload-media/upload-media.mjs

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,18 @@ import { prepareMediaUpload } from "../../common/utils.mjs";
22
import wordpress from "../../wordpress_com.app.mjs";
33

44
export default {
5-
65
key: "wordpress_com-upload-media",
76
name: "Upload Media",
87
description: "Uploads a media file from a URL to the specified WordPress.com site.",
9-
version: "0.0.4",
8+
version: "0.0.1",
109
type: "action",
11-
1210
props: {
1311
wordpress,
1412
site: {
15-
type: "string",
16-
label: "Site ID or domain",
17-
description: "Enter a site ID or domain (e.g. testsit38.wordpress.com).",
13+
propDefinition: [
14+
wordpress,
15+
"siteId",
16+
],
1817
},
1918
media: {
2019
type: "any",
@@ -24,24 +23,23 @@ export default {
2423
title: {
2524
type: "string",
2625
label: "Title",
27-
description: "Title of the media.",
26+
description: "Title of the media",
2827
optional: true,
2928
},
3029
caption: {
3130
type: "string",
3231
label: "Caption",
33-
description: "Optional caption text to associate with the uploaded media.",
32+
description: "Optional caption text to associate with the uploaded media",
3433
optional: true,
3534
},
3635
description: {
3736
type: "string",
3837
label: "Description",
38+
description: "A description of the uploaded media",
3939
optional: true,
4040
},
4141
},
42-
4342
async run({ $ }) {
44-
4543
const warnings = [];
4644

4745
const
@@ -58,18 +56,15 @@ export default {
5856

5957
// If not form data
6058
if (wordpress.isFormData(media)) {
61-
6259
form = media;
6360

6461
} else {
65-
6662
form = await prepareMediaUpload(media, fields, $);
6763
}
6864

6965
let response;
7066

7167
try {
72-
7368
response = await wordpress.uploadWordpressMedia({
7469
$,
7570
contentType: form.getHeaders()["content-type"],
@@ -85,9 +80,7 @@ export default {
8580
return response;
8681

8782
} catch (error) {
88-
8983
wordpress.throwCustomError("Failed to upload media", error, warnings);
90-
9184
};
9285
},
9386
};

components/wordpress_com/sources/new-comment/new-comment.mjs

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,36 +4,40 @@ export default {
44
key: "wordpress_com-new-comment",
55
name: "New Comment",
66
description: "Emit new event for each new comment added since the last run. If no new comments, emit nothing.",
7-
version: "0.0.2",
7+
version: "0.0.1",
88
type: "source",
9+
dedupe: "unique",
910
props: {
1011
wordpress,
1112
db: "$.service.db",
1213
site: {
13-
type: "string",
14-
label: "Site ID or domain",
15-
description: "Enter a site ID or domain (e.g. testsit38.wordpress.com). Do not include 'https://' or 'www'.",
14+
propDefinition: [
15+
wordpress,
16+
"siteId",
17+
],
1618
},
1719
postId: {
18-
type: "integer",
19-
label: "Post ID",
20+
propDefinition: [
21+
wordpress,
22+
"postId",
23+
(c) => ({
24+
site: c.site,
25+
}),
26+
],
2027
description: "Enter a specific post ID to fetch comments for only that post. Leave empty to fetch all comments.",
2128
optional: true,
2229
},
2330
number: {
2431
type: "integer",
2532
label: "Maximum Comments to Fetch",
26-
description: "The number of most recent comments to fetch each time the source runs.",
33+
description: "The number of most recent comments to fetch each time the source runs",
2734
default: 10,
2835
optional: true,
2936
min: 1,
3037
max: 100,
3138
},
32-
3339
},
34-
3540
async run({ $ }) {
36-
3741
const warnings = [];
3842

3943
const {

components/wordpress_com/sources/new-follower/new-follower.mjs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,19 @@ export default {
44
key: "wordpress_com-new-follower",
55
name: "New Follower",
66
description: "Emit new event for each new follower that subscribes to the site.",
7-
version: "0.0.2",
7+
version: "0.0.1",
88
type: "source",
9+
dedupe: "unique",
910
props: {
1011
wordpress,
1112
db: "$.service.db",
1213
site: {
13-
type: "string",
14-
label: "Site ID or domain",
15-
description: "Enter a site ID or domain (e.g. testsit38.wordpress.com). Do not include 'https://' or 'www'.",
14+
propDefinition: [
15+
wordpress,
16+
"siteId",
17+
],
1618
},
1719
},
18-
1920
async run({ $ }) {
2021
const warnings = [];
2122

components/wordpress_com/sources/new-post/new-post.mjs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,17 @@ export default {
44
key: "wordpress_com-new-post",
55
name: "New Post",
66
description: "Emit new event for each new post published since the last run. If no new posts, emit nothing.",
7-
version: "0.0.5",
7+
version: "0.0.1",
88
type: "source",
9+
dedupe: "unique",
910
props: {
1011
wordpress,
1112
db: "$.service.db",
1213
site: {
13-
type: "string",
14-
label: "Site ID or domain",
15-
description: "Enter a site ID or domain (e.g. testsit38.wordpress.com). Do not include 'https://' or 'www'.",
14+
propDefinition: [
15+
wordpress,
16+
"siteId",
17+
],
1618
},
1719
type: {
1820
type: "string",
@@ -44,9 +46,7 @@ export default {
4446
max: 100,
4547
},
4648
},
47-
4849
async run({ $ }) {
49-
5050
const warnings = [];
5151

5252
const {
@@ -108,13 +108,11 @@ export default {
108108
}
109109

110110
for (const post of newPosts.reverse()) {
111-
112111
this.$emit(post, {
113112
id: post.ID,
114113
summary: post.title,
115114
ts: post.date && +new Date(post.date),
116115
});
117-
118116
}
119117

120118
// Update last seen post ID

0 commit comments

Comments
 (0)