Skip to content

Commit 3dec800

Browse files
committed
updates/formatting
1 parent f4c36fb commit 3dec800

File tree

13 files changed

+621
-578
lines changed

13 files changed

+621
-578
lines changed

components/google_search_console/actions/retrieve-site-performance-data/retrieve-site-performance-data.mjs

Lines changed: 45 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
1-
21
/**
32
* Fetches performance data (clicks, impressions, etc.) for a verified site
43
* via the Google Search Console Search Analytics API.
5-
*
4+
*
65
* Full usage docs in README.md
76
*/
87

9-
108
import { axios } from "@pipedream/platform";
119
import gsConsole from "../../google_search_console.app.mjs";
12-
import {removeCustomPropFields, trimIfString } from "../../common/utils.mjs"
10+
import {
11+
removeCustomPropFields, trimIfString,
12+
} from "../../common/utils.mjs";
1313

14-
/*
15-
Define prop metadata separately, including custom fields used for extended validation
14+
/*
15+
Define prop metadata separately, including custom fields used for extended validation
1616
and runtime behavior.
1717
18-
These extended fields (like `extendedType`, `postBody`, etc.) are not part of the standard
18+
These extended fields (like `extendedType`, `postBody`, etc.) are not part of the standard
1919
Pipedream prop schema.
2020
2121
A helper function (`removeCustomPropFields`) will later strip these non-standard fields,
2222
returning only valid Pipedream props for use in the UI.
2323
24-
Keeping the full metadata in closure allows access to helpful context (e.g. validation rules)
24+
Keeping the full metadata in closure allows access to helpful context (e.g. validation rules)
2525
during runtime.
2626
*/
2727
const propsMeta = {
@@ -55,15 +55,25 @@ const propsMeta = {
5555
type: "string",
5656
label: "Search Type",
5757
optional: true,
58-
options: ["web", "image", "video", "news", "googleNews", "discover"],
58+
options: [
59+
"web",
60+
"image",
61+
"video",
62+
"news",
63+
"googleNews",
64+
"discover",
65+
],
5966
default: "web",
6067
postBody: true,
6168
},
6269
aggregationType: {
6370
type: "string",
6471
label: "Aggregation Type",
6572
optional: true,
66-
options: ["auto", "byPage"],
73+
options: [
74+
"auto",
75+
"byPage",
76+
],
6777
postBody: true,
6878
},
6979
rowLimit: {
@@ -89,34 +99,33 @@ const propsMeta = {
8999
type: "string",
90100
label: "Data State",
91101
optional: true,
92-
options: ["all", "final"],
102+
options: [
103+
"all",
104+
"final",
105+
],
93106
default: "final",
94107
postBody: true,
95108
},
96-
97-
98-
99109
};
100110

101111
export default {
102112
name: "Retrieve Site Performance Data",
103113
description: "Fetches search analytics from Google Search Console for a verified site.",
104-
key: "retrieve-site-performance-data",
105-
version: "0.0.2",
114+
key: "google_search_console-retrieve-site-performance-data",
115+
version: "0.0.1",
106116
type: "action",
107117
props: {
108118
gsConsole,
109119
// Remove non-standard fields and expose only valid props to Pipedream UI
110120
...removeCustomPropFields(propsMeta),
111121
},
112122

113-
114123
//=================== RUN ==============================
115124
//======================================================
116125

117126
async run({ $ }) {
118127

119-
/*
128+
/*
120129
`dimensionFilterGroups` is expected to be an object.
121130
If a JSON string is passed instead (e.g. from UI input), attempt to parse it.
122131
- Returns parsed object if successful
@@ -131,24 +140,24 @@ export default {
131140
// Accumulator for non-blocking input warnings
132141
const warnings = [];
133142

134-
/*
143+
/*
135144
This loop:
136145
- Trims and validates all defined props
137146
- Skips empty optional fields
138147
- Accumulates non-blocking warnings
139148
- Adds valid props to the POST request payload (`body`) if marked with `postBody: true`
140149
*/
141-
for (let propName in propsMeta){
150+
for (let propName in propsMeta) {
142151

143152
// Just for convenience.
144153
const meta = propsMeta[propName];
145154

146-
// Trim the value if it's a string
147-
this[propName] = trimIfString(this[propName]);
155+
// Trim the value if it's a string
156+
this[propName] = trimIfString(this[propName]);
148157

149158
// Skip if the prop is optional and empty (null, undefined, or blank string)
150-
if (meta.optional === true && ((this[propName] ?? '') === '')) continue;
151-
159+
if (meta.optional === true && ((this[propName] ?? "") === "")) continue;
160+
152161
// Validate input (may throw or return warning messages)
153162
const validationResult = this.gsConsole.validateUserInput(meta, this[propName]);
154163

@@ -166,24 +175,23 @@ export default {
166175
let response;
167176

168177
try {
169-
response = await axios($, {
170-
method: "POST",
171-
url: `https://searchconsole.googleapis.com/webmasters/v3/sites/${encodeURIComponent(url)}/searchAnalytics/query`,
172-
headers: {
173-
Authorization: `Bearer ${this.gsConsole.$auth.oauth_access_token}`,
174-
"Content-Type": "application/json",
175-
},
176-
data: body,
177-
})
178+
response = await axios($, {
179+
method: "POST",
180+
url: `https://searchconsole.googleapis.com/webmasters/v3/sites/${encodeURIComponent(url)}/searchAnalytics/query`,
181+
headers: {
182+
"Authorization": `Bearer ${this.gsConsole.$auth.oauth_access_token}`,
183+
"Content-Type": "application/json",
184+
},
185+
data: body,
186+
});
178187

179188
} catch (error) {
180-
// Identify if the error was thrown by internal validation or by the API call
189+
// Identify if the error was thrown by internal validation or by the API call
181190
const thrower = this.gsConsole.checkWhoThrewError(error);
182-
191+
183192
throw new Error(`Failed to fetch data ( ${thrower.whoThrew} error ) : ${error.message}. ` + warnings.join("\n- "));
184-
185193
};
186-
194+
187195
// Output summary and any warnings for the user
188196
$.export("$summary", ` Fetched ${response.rows?.length || 0} rows of data. ` + warnings.join("\n- "));
189197
return response;

components/google_search_console/actions/submit-url-for-indexing/submit-url-for-indexing.mjs

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,39 +5,35 @@
55

66
import { axios } from "@pipedream/platform";
77
import gsConsole from "../../google_search_console.app.mjs";
8-
import { trimIfString } from "../../common/utils.mjs"
8+
import { trimIfString } from "../../common/utils.mjs";
99

10-
11-
1210
export default {
1311

1412
name: "Submit URL for Indexing",
1513
description: "Sends a URL update notification to the Google Indexing API",
16-
key: "submit-url-for-indexing",
14+
key: "google_search_console-submit-url-for-indexing",
1715
version: "0.0.1",
1816
type: "action",
1917
props: {
2018
gsConsole,
21-
siteUrl : {
22-
type: "string",
23-
label: "URL for indexing",
24-
description: "URL to be submitted for indexing"
19+
siteUrl: {
20+
type: "string",
21+
label: "URL for indexing",
22+
description: "URL to be submitted for indexing",
2523
},
2624
},
2725

28-
2926
//=================== RUN ==============================
3027
//======================================================
3128

32-
3329
async run({ $ }) {
3430

3531
this.siteUrl = trimIfString(this.siteUrl);
3632

3733
// Accumulator for non-blocking warnings
3834
let warnings = [];
3935

40-
/*
36+
/*
4137
Validate the submitted site URL.
4238
- May throw if invalid
4339
- May return warnings for issues like suspicious characters
@@ -46,7 +42,6 @@ export default {
4642

4743
if (urlCheck.warnings) warnings.push(...urlCheck.warnings);
4844

49-
5045
// Prepare the API response object
5146
let response;
5247

@@ -56,8 +51,7 @@ export default {
5651
method: "POST",
5752
url: "https://indexing.googleapis.com/v3/urlNotifications:publish",
5853
headers: {
59-
60-
Authorization: `Bearer ${this.gsConsole.$auth.oauth_access_token}`,
54+
"Authorization": `Bearer ${this.gsConsole.$auth.oauth_access_token}`,
6155
"Content-Type": "application/json",
6256
},
6357
data: {
@@ -74,13 +68,13 @@ export default {
7468
Helps distinguish between coding issues vs API issues.
7569
*/
7670
const thrower = gsConsole.methods.checkWhoThrewError(error);
77-
71+
7872
throw new Error(`Failed to fetch data ( ${thrower.whoThrew} error ) : ${error.message}. ` + warnings.join("\n- "));
79-
73+
8074
};
8175
// Output a summary message and any accumulated warnings
8276
$.export("$summary", ` URL submitted to Google: ${this.siteUrl}` + warnings.join("\n- "));
83-
// Return the raw API response
77+
// Return the raw API response
8478
return response;
8579
},
8680
};

0 commit comments

Comments
 (0)