Skip to content

Commit 79d8a49

Browse files
committed
CodeRabbit change
1 parent b780b29 commit 79d8a49

File tree

7 files changed

+14
-91
lines changed

7 files changed

+14
-91
lines changed

components/wordpress_com/actions/create-post.mjs

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

33
export default {
4-
key: "worpress_com-create-post",
4+
key: "wordpress_com-create-post",
55
name: "Create New Post",
6-
description: "Retrieves the authenticated user's account information.",
6+
description: "Creates a new post on a WordPress.com site.",
77
version: "0.0.1",
88
type: "action",
99
props: {

components/wordpress_com/actions/delete-post.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import wordpress from "../wordpress_com.app.mjs";
22

33
export default {
44

5-
key: "worpress_com-delete-post",
5+
key: "wordpress_com-delete-post",
66
name: "Delete Post",
7-
description: "Delete post",
7+
description: "Deletes a post",
88
version: "0.0.1",
99
type: "action",
1010
props: {

components/wordpress_com/actions/upload-media.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export default {
8282
data : form,
8383
});
8484

85-
const media = response.media?.[0];
85+
const media = response.media.[0];
8686

8787
$.export("$summary", `Media "${media.title}" uploaded successfully (ID: ${media.ID})` + "\n- " + warnings.join("\n- "));
8888

components/wordpress_com/common/methods.mjs

Lines changed: 5 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -58,65 +58,6 @@ trimIfString(input) {
5858
return (typeof input === 'string') ? input.trim() : input;
5959
},
6060

61-
/* ===================================================================================================
62-
Throws if not string or if not whole number.
63-
====================================================================================================== */
64-
65-
throwIfNotStrOrId(input, reason) {
66-
if (typeof input === "number") {
67-
this.throwIfNotWholeNumber(input, reason);
68-
return;
69-
}
70-
71-
if (typeof input === "string") {
72-
this.throwIfBlankOrNotString(input, reason);
73-
return;
74-
}
75-
76-
this.throwCustomError(
77-
`Expected a non-empty string or a whole number. but got ${typeof input}` + this._reasonMsg(reason)
78-
);
79-
},
80-
81-
82-
/* ===================================================================================================
83-
Checks if a string follows the YYYY-MM-DD date format.
84-
Warns if the format or any individual part (year, month, day) is invalid.
85-
====================================================================================================== */
86-
87-
checkYMDDashDate(input) {
88-
89-
const warings = [];
90-
this.throwIfBlankOrNotString(input);
91-
92-
const parts = input.trim().split("-");
93-
94-
if (parts.length !== 3) {
95-
warings.push("Date must be in format YYYY-MM-DD" + this._reasonMsg(input));
96-
};
97-
98-
let [year, month, day] = parts;
99-
100-
// --- YEAR ---
101-
year = +year;
102-
if (!Number.isInteger(year) || year < 1990 || year > 2100) {
103-
warings.push("Year must be between 1990 and 2100" + this._reasonMsg(input));
104-
};
105-
106-
const monthNum = +month;
107-
if (month.length !== 2 || Number.isNaN(monthNum) || monthNum < 1 || monthNum > 12 ) {
108-
warings.push(`Month must be between 01 and 12. Got: '${month}'` + this._reasonMsg(input));
109-
};
110-
111-
const dayNum = +day;
112-
if (day.length !== 2 || Number.isNaN(dayNum) || dayNum < 1 || dayNum > 31 ) {
113-
warings.push(`Day must be between 01 and 31. Got: '${day}'` + this._reasonMsg(reason));
114-
};
115-
116-
return warings;
117-
118-
},
119-
12061

12162
/* ===================================================================================================
12263
Function tries to parse the input as JSON, If it is not return the value as it was passed
@@ -141,11 +82,6 @@ throwIfNotStrOrId(input, reason) {
14182
- Rejects blank strings, spaces, tabs, and newlines
14283
- Warns about suspicious or unusual characters
14384
- Adds a warning if protocol is missing or malformed
144-
Returns:
145-
{
146-
warnings: string[],
147-
url: string (trimmed original input)
148-
}
14985
====================================================================================================== */
15086
checkIfUrlValid(input) {
15187

@@ -167,7 +103,7 @@ throwIfNotStrOrId(input, reason) {
167103

168104
// Reject if spaces, tabs, or newlines are present
169105
if ((/[ \t\n]/.test(trimmedInput))) {
170-
warnings.push( `Url contains invalid characters like space, backslash etc., please check.` + this._reasonMsg(reason));
106+
warnings.push( `Url contains invalid characters like space, backslash etc., please check.` + this._reasonMsg(input));
171107
return warnings;
172108
};
173109

@@ -178,8 +114,7 @@ throwIfNotStrOrId(input, reason) {
178114

179115
if (dubiousMatches) {
180116
const uniqueChars = [...new Set(dubiousMatches)].join(" ");
181-
warnings.push(` URL contains dubious or non-standard characters " ${uniqueChars} " ` +
182-
`that may be rejected by Google. Proceed only if you know what you are doing. ${this._reasonMsg(reason)}`) ;
117+
warnings.push(` URL contains dubious or non-standard characters ` + this._reasonMsg(input) );
183118
};
184119

185120
// urlObject for further use if the next check passes.
@@ -192,7 +127,7 @@ throwIfNotStrOrId(input, reason) {
192127
if (/^(https?):\/(?!\/)/.test(input)) {
193128

194129
warnings.push(` It looks like you're missing one slash after "${urlObject.protocol}".` +
195-
`Did you mean "${urlObject.protocol}//..."? ${this._reasonMsg(reason)} `);
130+
`Did you mean "${urlObject.protocol}//..."? ${this._reasonMsg(input)} `);
196131

197132
};
198133

@@ -206,7 +141,7 @@ throwIfNotStrOrId(input, reason) {
206141

207142
} catch(err) {
208143
// If after all checks we are here that means that the url contain potentially unacceptable characters.
209-
warnings.push(` URL contains potentionally unacceptable characters" ${this._reasonMsg(reason)}`);
144+
warnings.push(` URL contains potentionally unacceptable characters" ${this._reasonMsg(input)}`);
210145

211146
};
212147

@@ -220,18 +155,6 @@ throwIfNotStrOrId(input, reason) {
220155
Validates a Site Identifier string, which may be either:
221156
- A numeric Site ID (e.g., "123456")
222157
- A custom or subdomain (e.g., "mysite.example.com")
223-
224-
The function:
225-
- Throws on blank or non-string input
226-
- Detects and skips further checks if the input is a valid numeric Site ID
227-
- If the input is not numeric, performs domain checks:
228-
- Warns if the input includes protocol (http:// or https://)
229-
- Warns if it starts with 'www.'
230-
- Warns about unusual characters (only letters, numbers, dots, and dashes are allowed)
231-
- Warns if the domain does not contain at least one dot (.)
232-
233-
Returns:
234-
string[]: An array of warning messages (empty if input is clean)
235158
====================================================================================================== */
236159

237160
checkDomainOrId(input) {
@@ -269,7 +192,7 @@ throwIfNotStrOrId(input, reason) {
269192

270193

271194
/* ===================================================================================================
272-
throws a custom ERROR if axios request fails.
195+
Throws if axios request fails.
273196
Determines whether an error originated from your own validation code or from the API request.
274197
Useful for debugging and crafting more helpful error messages.
275198
====================================================================================================== */

components/wordpress_com/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/wordpress_com",
3-
"version": "0.6.0",
3+
"version": "0.7.0",
44
"description": "Pipedream wordpress_com Components",
55
"main": "wordpress_com.app.mjs",
66
"keywords": [

components/wordpress_com/sources/new-comment.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export default {
8282
let maxCommentIdTracker = lastCommentId;
8383
const newComments = [];
8484

85-
for (const comment of comments.reverse()) {
85+
for (const comment of comments) {
8686
if (comment.ID > lastCommentId) {
8787
newComments.push(comment);
8888
if (comment.ID > maxCommentIdTracker) {
@@ -91,7 +91,7 @@ export default {
9191
}
9292
}
9393

94-
for (const comment of newComments) {
94+
for (const comment of newComments.reverse()) {
9595
this.$emit(comment, {
9696
id: comment.ID,
9797
summary: comment.author?.name || "Anonymous Comment",

components/wordpress_com/wordpress_com.app.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export default {
1919
return axios($, {
2020
url,
2121
headers : {
22-
"Authorization": `Bearer v6Dp%5xWzh(rsgW9PR&xY4C#Ibs&Jo3W12nv@6Te3cZOrI5XACdoate$DQ#pIyYP`, //${this.$auth.oauth_access_token} TEST
22+
"Authorization": `Bearer ${this.$auth.oauth_access_token}`,
2323
"Content-Type": (contentType) ? contentType : "application/json",
2424
},
2525
...opts,

0 commit comments

Comments
 (0)