@pipedream/wordpress_org 0.4.1 → 0.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/actions/create-post/create-post.mjs +74 -22
- package/actions/create-user/create-user.mjs +6 -1
- package/actions/get-user/get-user.mjs +6 -1
- package/actions/search-posts/search-posts.mjs +6 -1
- package/actions/update-post/update-post.mjs +6 -1
- package/actions/update-user/update-user.mjs +6 -1
- package/actions/upload-media/upload-media.mjs +13 -1
- package/package.json +2 -2
- package/wordpress_org.app.mjs +32 -6
|
@@ -4,8 +4,13 @@ import utils from "../../common/utils.mjs";
|
|
|
4
4
|
export default {
|
|
5
5
|
key: "wordpress_org-create-post",
|
|
6
6
|
name: "Create Post",
|
|
7
|
-
description: "
|
|
8
|
-
version: "0.0.
|
|
7
|
+
description: "Create a new WordPress post using the REST API directly. [See the documentation](https://developer.wordpress.org/rest-api/reference/posts/#create-a-post)",
|
|
8
|
+
version: "0.0.6",
|
|
9
|
+
annotations: {
|
|
10
|
+
destructiveHint: false,
|
|
11
|
+
openWorldHint: true,
|
|
12
|
+
readOnlyHint: false,
|
|
13
|
+
},
|
|
9
14
|
type: "action",
|
|
10
15
|
props: {
|
|
11
16
|
wordpress,
|
|
@@ -21,11 +26,24 @@ export default {
|
|
|
21
26
|
"content",
|
|
22
27
|
],
|
|
23
28
|
},
|
|
29
|
+
excerpt: {
|
|
30
|
+
propDefinition: [
|
|
31
|
+
wordpress,
|
|
32
|
+
"excerpt",
|
|
33
|
+
],
|
|
34
|
+
},
|
|
24
35
|
status: {
|
|
25
36
|
propDefinition: [
|
|
26
37
|
wordpress,
|
|
27
38
|
"status",
|
|
28
39
|
],
|
|
40
|
+
default: "publish",
|
|
41
|
+
},
|
|
42
|
+
commentStatus: {
|
|
43
|
+
propDefinition: [
|
|
44
|
+
wordpress,
|
|
45
|
+
"commentStatus",
|
|
46
|
+
],
|
|
29
47
|
},
|
|
30
48
|
author: {
|
|
31
49
|
propDefinition: [
|
|
@@ -39,16 +57,16 @@ export default {
|
|
|
39
57
|
"categories",
|
|
40
58
|
],
|
|
41
59
|
},
|
|
42
|
-
|
|
60
|
+
tags: {
|
|
43
61
|
propDefinition: [
|
|
44
62
|
wordpress,
|
|
45
|
-
"
|
|
63
|
+
"tags",
|
|
46
64
|
],
|
|
47
65
|
},
|
|
48
|
-
|
|
66
|
+
featuredMedia: {
|
|
49
67
|
propDefinition: [
|
|
50
68
|
wordpress,
|
|
51
|
-
"
|
|
69
|
+
"media",
|
|
52
70
|
],
|
|
53
71
|
},
|
|
54
72
|
meta: {
|
|
@@ -57,30 +75,64 @@ export default {
|
|
|
57
75
|
"meta",
|
|
58
76
|
],
|
|
59
77
|
},
|
|
60
|
-
media: {
|
|
61
|
-
propDefinition: [
|
|
62
|
-
wordpress,
|
|
63
|
-
"media",
|
|
64
|
-
],
|
|
65
|
-
},
|
|
66
78
|
},
|
|
67
79
|
async run({ $ }) {
|
|
68
|
-
|
|
80
|
+
// Prepare post data
|
|
81
|
+
const postData = {
|
|
69
82
|
title: this.title,
|
|
70
83
|
content: this.content,
|
|
71
84
|
status: this.status,
|
|
72
|
-
author: this.author,
|
|
73
|
-
categories: this.categories,
|
|
74
|
-
excerpt: this.excerpt,
|
|
75
|
-
comment_status: this.commentStatus,
|
|
76
|
-
meta: utils.parseObj(this.meta),
|
|
77
|
-
featured_media: this.media,
|
|
78
85
|
};
|
|
79
86
|
|
|
80
|
-
|
|
87
|
+
// Add optional fields if provided
|
|
88
|
+
if (this.excerpt) {
|
|
89
|
+
postData.excerpt = this.excerpt;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (this.author) {
|
|
93
|
+
const parsedAuthor = parseInt(this.author, 10);
|
|
94
|
+
if (!Number.isNaN(parsedAuthor)) {
|
|
95
|
+
postData.author = parsedAuthor;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (this.commentStatus) {
|
|
100
|
+
postData.comment_status = this.commentStatus;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (this.categories && this.categories.length > 0) {
|
|
104
|
+
const parsedCategories = this.categories
|
|
105
|
+
.map((cat) => parseInt(cat, 10))
|
|
106
|
+
.filter((val) => !Number.isNaN(val));
|
|
107
|
+
if (parsedCategories.length > 0) {
|
|
108
|
+
postData.categories = parsedCategories;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (this.tags && this.tags.length > 0) {
|
|
113
|
+
const parsedTags = this.tags
|
|
114
|
+
.map((tag) => parseInt(tag, 10))
|
|
115
|
+
.filter((val) => !Number.isNaN(val));
|
|
116
|
+
if (parsedTags.length > 0) {
|
|
117
|
+
postData.tags = parsedTags;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
if (this.featuredMedia) {
|
|
122
|
+
const parsedMedia = parseInt(this.featuredMedia, 10);
|
|
123
|
+
if (!Number.isNaN(parsedMedia)) {
|
|
124
|
+
postData.featured_media = parsedMedia;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if (this.meta) {
|
|
129
|
+
postData.meta = utils.parseObj(this.meta);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const response = await this.wordpress.createPost(postData);
|
|
81
133
|
|
|
82
|
-
$.export("$summary",
|
|
134
|
+
$.export("$summary", `Successfully created post: "${response?.title?.rendered || response?.id || "New Post"}"`);
|
|
83
135
|
|
|
84
|
-
return
|
|
136
|
+
return response;
|
|
85
137
|
},
|
|
86
138
|
};
|
|
@@ -4,7 +4,12 @@ export default {
|
|
|
4
4
|
key: "wordpress_org-create-user",
|
|
5
5
|
name: "Create User",
|
|
6
6
|
description: "Creates a user. [See the documentation](https://developer.wordpress.org/rest-api/reference/users/#create-a-user)",
|
|
7
|
-
version: "0.0.
|
|
7
|
+
version: "0.0.6",
|
|
8
|
+
annotations: {
|
|
9
|
+
destructiveHint: false,
|
|
10
|
+
openWorldHint: true,
|
|
11
|
+
readOnlyHint: false,
|
|
12
|
+
},
|
|
8
13
|
type: "action",
|
|
9
14
|
props: {
|
|
10
15
|
wordpress,
|
|
@@ -4,7 +4,12 @@ export default {
|
|
|
4
4
|
key: "wordpress_org-get-user",
|
|
5
5
|
name: "Get User",
|
|
6
6
|
description: "Retrieves information for a user. [See the documentation](https://developer.wordpress.org/rest-api/reference/users/#retrieve-a-user-2)",
|
|
7
|
-
version: "0.0.
|
|
7
|
+
version: "0.0.4",
|
|
8
|
+
annotations: {
|
|
9
|
+
destructiveHint: false,
|
|
10
|
+
openWorldHint: true,
|
|
11
|
+
readOnlyHint: true,
|
|
12
|
+
},
|
|
8
13
|
type: "action",
|
|
9
14
|
props: {
|
|
10
15
|
wordpress,
|
|
@@ -4,7 +4,12 @@ export default {
|
|
|
4
4
|
key: "wordpress_org-search-posts",
|
|
5
5
|
name: "Search Posts",
|
|
6
6
|
description: "Searches for specific posts. [See the documentation](https://developer.wordpress.org/rest-api/reference/posts/#list-posts)",
|
|
7
|
-
version: "0.0.
|
|
7
|
+
version: "0.0.5",
|
|
8
|
+
annotations: {
|
|
9
|
+
destructiveHint: false,
|
|
10
|
+
openWorldHint: true,
|
|
11
|
+
readOnlyHint: true,
|
|
12
|
+
},
|
|
8
13
|
type: "action",
|
|
9
14
|
props: {
|
|
10
15
|
wordpress,
|
|
@@ -5,7 +5,12 @@ export default {
|
|
|
5
5
|
key: "wordpress_org-update-post",
|
|
6
6
|
name: "Update Post",
|
|
7
7
|
description: "Updates a post specified by its ID. [See the documentation](https://developer.wordpress.org/rest-api/reference/posts/#update-a-post)",
|
|
8
|
-
version: "0.0.
|
|
8
|
+
version: "0.0.5",
|
|
9
|
+
annotations: {
|
|
10
|
+
destructiveHint: true,
|
|
11
|
+
openWorldHint: true,
|
|
12
|
+
readOnlyHint: false,
|
|
13
|
+
},
|
|
9
14
|
type: "action",
|
|
10
15
|
props: {
|
|
11
16
|
wordpress,
|
|
@@ -5,7 +5,12 @@ export default {
|
|
|
5
5
|
key: "wordpress_org-update-user",
|
|
6
6
|
name: "Update User",
|
|
7
7
|
description: "Updates the information of a user. [See the documentation](https://developer.wordpress.org/rest-api/reference/users/#update-a-user-2)",
|
|
8
|
-
version: "0.0.
|
|
8
|
+
version: "0.0.4",
|
|
9
|
+
annotations: {
|
|
10
|
+
destructiveHint: true,
|
|
11
|
+
openWorldHint: true,
|
|
12
|
+
readOnlyHint: false,
|
|
13
|
+
},
|
|
9
14
|
type: "action",
|
|
10
15
|
props: {
|
|
11
16
|
wordpress,
|
|
@@ -6,7 +6,12 @@ export default {
|
|
|
6
6
|
key: "wordpress_org-upload-media",
|
|
7
7
|
name: "Upload Media",
|
|
8
8
|
description: "Upload a media item to your WordPress media library. Returns a media ID to be used in creating or updating posts.[See the documentation](https://www.npmjs.com/package/wpapi#uploading-media)",
|
|
9
|
-
version: "0.0.
|
|
9
|
+
version: "0.0.5",
|
|
10
|
+
annotations: {
|
|
11
|
+
destructiveHint: false,
|
|
12
|
+
openWorldHint: true,
|
|
13
|
+
readOnlyHint: false,
|
|
14
|
+
},
|
|
10
15
|
type: "action",
|
|
11
16
|
props: {
|
|
12
17
|
wordpress,
|
|
@@ -14,6 +19,7 @@ export default {
|
|
|
14
19
|
type: "string",
|
|
15
20
|
label: "File Path or URL",
|
|
16
21
|
description: "Provide either a file URL or a path to a file in the /tmp directory (for example, /tmp/myFile.pdf).",
|
|
22
|
+
format: "file-ref",
|
|
17
23
|
},
|
|
18
24
|
title: {
|
|
19
25
|
propDefinition: [
|
|
@@ -37,6 +43,12 @@ export default {
|
|
|
37
43
|
description: "Description of the media item",
|
|
38
44
|
optional: true,
|
|
39
45
|
},
|
|
46
|
+
syncDir: {
|
|
47
|
+
type: "dir",
|
|
48
|
+
accessMode: "read",
|
|
49
|
+
sync: true,
|
|
50
|
+
optional: true,
|
|
51
|
+
},
|
|
40
52
|
},
|
|
41
53
|
async run({ $ }) {
|
|
42
54
|
const content = await getFileStream(this.filePath);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pipedream/wordpress_org",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.3",
|
|
4
4
|
"description": "Pipedream Wordpress.org Components",
|
|
5
5
|
"main": "wordpress_org.app.mjs",
|
|
6
6
|
"keywords": [
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"homepage": "https://pipedream.com/apps/wordpress_org",
|
|
11
11
|
"author": "Pipedream <support@pipedream.com> (https://pipedream.com/)",
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@pipedream/platform": "^3.
|
|
13
|
+
"@pipedream/platform": "^3.2.5",
|
|
14
14
|
"lodash.pickby": "^4.6.0",
|
|
15
15
|
"wpapi": "^1.2.2"
|
|
16
16
|
},
|
package/wordpress_org.app.mjs
CHANGED
|
@@ -126,6 +126,19 @@ export default {
|
|
|
126
126
|
}));
|
|
127
127
|
},
|
|
128
128
|
},
|
|
129
|
+
tags: {
|
|
130
|
+
type: "string[]",
|
|
131
|
+
label: "Tags",
|
|
132
|
+
description: "Tags assigned to the post",
|
|
133
|
+
optional: true,
|
|
134
|
+
async options({ page }) {
|
|
135
|
+
const tags = await this.listTags(page + 1);
|
|
136
|
+
return tags.map((tag) => ({
|
|
137
|
+
label: tag?.name,
|
|
138
|
+
value: tag?.id,
|
|
139
|
+
}));
|
|
140
|
+
},
|
|
141
|
+
},
|
|
129
142
|
post: {
|
|
130
143
|
type: "string",
|
|
131
144
|
label: "Post",
|
|
@@ -177,13 +190,21 @@ export default {
|
|
|
177
190
|
username,
|
|
178
191
|
application_password: applicationPassword,
|
|
179
192
|
} = this.$auth;
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
193
|
+
|
|
194
|
+
// Normalize URL: preserve existing protocol or default to https://
|
|
195
|
+
let normalizedUrl = url;
|
|
196
|
+
if (url.startsWith("http://") || url.startsWith("https://")) {
|
|
197
|
+
// URL already has protocol, use as-is
|
|
198
|
+
normalizedUrl = url.replace(/\/$/, ""); // Remove trailing slash if present
|
|
199
|
+
} else {
|
|
200
|
+
// No protocol provided, default to https://
|
|
201
|
+
normalizedUrl = `https://${url}`;
|
|
185
202
|
}
|
|
186
|
-
|
|
203
|
+
|
|
204
|
+
const wp = new WPAPI({
|
|
205
|
+
endpoint: `${normalizedUrl}/wp-json`,
|
|
206
|
+
});
|
|
207
|
+
return wp.auth({
|
|
187
208
|
username,
|
|
188
209
|
password: applicationPassword,
|
|
189
210
|
});
|
|
@@ -203,6 +224,11 @@ export default {
|
|
|
203
224
|
return wp.categories().perPage(PER_PAGE)
|
|
204
225
|
.page(page);
|
|
205
226
|
},
|
|
227
|
+
async listTags(page) {
|
|
228
|
+
const wp = await this.getClient();
|
|
229
|
+
return wp.tags().perPage(PER_PAGE)
|
|
230
|
+
.page(page);
|
|
231
|
+
},
|
|
206
232
|
async listPosts(page) {
|
|
207
233
|
const wp = await this.getClient();
|
|
208
234
|
return wp.posts().perPage(PER_PAGE)
|