@maxim_mazurok/gapi.client.pagespeedonline-v5 0.0.20220811
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/index.d.ts +379 -0
- package/package.json +20 -0
- package/readme.md +73 -0
- package/tests.ts +43 -0
- package/tsconfig.json +18 -0
- package/tslint.json +6 -0
package/index.d.ts
ADDED
|
@@ -0,0 +1,379 @@
|
|
|
1
|
+
/* Type definitions for non-npm package PageSpeed Insights API v5 0.0 */
|
|
2
|
+
// Project: https://developers.google.com/speed/docs/insights/v5/about
|
|
3
|
+
// Definitions by: Maxim Mazurok <https://github.com/Maxim-Mazurok>
|
|
4
|
+
// Nick Amoscato <https://github.com/namoscato>
|
|
5
|
+
// Declan Vong <https://github.com/declanvong>
|
|
6
|
+
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
|
7
|
+
// TypeScript Version: 2.8
|
|
8
|
+
|
|
9
|
+
// IMPORTANT
|
|
10
|
+
// This file was generated by https://github.com/Maxim-Mazurok/google-api-typings-generator. Please do not edit it manually.
|
|
11
|
+
// In case of any problems please post issue to https://github.com/Maxim-Mazurok/google-api-typings-generator
|
|
12
|
+
// Generated from: https://pagespeedonline.googleapis.com/$discovery/rest?version=v5
|
|
13
|
+
// Revision: 20220811
|
|
14
|
+
|
|
15
|
+
/// <reference types="gapi.client" />
|
|
16
|
+
|
|
17
|
+
declare namespace gapi.client {
|
|
18
|
+
/** Load PageSpeed Insights API v5 */
|
|
19
|
+
function load(urlOrObject: "https://pagespeedonline.googleapis.com/$discovery/rest?version=v5"): Promise<void>;
|
|
20
|
+
/** @deprecated Please load APIs with discovery documents. */
|
|
21
|
+
function load(name: "pagespeedonline", version: "v5"): Promise<void>;
|
|
22
|
+
/** @deprecated Please load APIs with discovery documents. */
|
|
23
|
+
function load(name: "pagespeedonline", version: "v5", callback: () => any): void;
|
|
24
|
+
|
|
25
|
+
namespace pagespeedonline {
|
|
26
|
+
interface AuditRefs {
|
|
27
|
+
/** The conventional acronym for the audit/metric. */
|
|
28
|
+
acronym?: string;
|
|
29
|
+
/** The category group that the audit belongs to (optional). */
|
|
30
|
+
group?: string;
|
|
31
|
+
/** The audit ref id. */
|
|
32
|
+
id?: string;
|
|
33
|
+
/** Any audit IDs closely relevant to this one. */
|
|
34
|
+
relevantAudits?: string[];
|
|
35
|
+
/** The weight this audit's score has on the overall category score. */
|
|
36
|
+
weight?: number;
|
|
37
|
+
}
|
|
38
|
+
interface Bucket {
|
|
39
|
+
/** Upper bound for a bucket's range. */
|
|
40
|
+
max?: number;
|
|
41
|
+
/** Lower bound for a bucket's range. */
|
|
42
|
+
min?: number;
|
|
43
|
+
/** The proportion of data in this bucket. */
|
|
44
|
+
proportion?: number;
|
|
45
|
+
}
|
|
46
|
+
interface Categories {
|
|
47
|
+
/** The accessibility category, containing all accessibility related audits. */
|
|
48
|
+
accessibility?: LighthouseCategoryV5;
|
|
49
|
+
/** The best practices category, containing all best practices related audits. */
|
|
50
|
+
"best-practices"?: LighthouseCategoryV5;
|
|
51
|
+
/** The performance category, containing all performance related audits. */
|
|
52
|
+
performance?: LighthouseCategoryV5;
|
|
53
|
+
/** The Progressive-Web-App (PWA) category, containing all pwa related audits. */
|
|
54
|
+
pwa?: LighthouseCategoryV5;
|
|
55
|
+
/** The Search-Engine-Optimization (SEO) category, containing all seo related audits. */
|
|
56
|
+
seo?: LighthouseCategoryV5;
|
|
57
|
+
}
|
|
58
|
+
interface CategoryGroupV5 {
|
|
59
|
+
/** The description of what the category is grouping */
|
|
60
|
+
description?: string;
|
|
61
|
+
/** The human readable title of the group */
|
|
62
|
+
title?: string;
|
|
63
|
+
}
|
|
64
|
+
interface ConfigSettings {
|
|
65
|
+
/** How Lighthouse was run, e.g. from the Chrome extension or from the npm module. */
|
|
66
|
+
channel?: string;
|
|
67
|
+
/** The form factor the emulation should use. This field is deprecated, form_factor should be used instead. */
|
|
68
|
+
emulatedFormFactor?: string;
|
|
69
|
+
/** How Lighthouse should interpret this run in regards to scoring performance metrics and skipping mobile-only tests in desktop. */
|
|
70
|
+
formFactor?: string;
|
|
71
|
+
/** The locale setting. */
|
|
72
|
+
locale?: string;
|
|
73
|
+
/** List of categories of audits the run should conduct. */
|
|
74
|
+
onlyCategories?: any;
|
|
75
|
+
}
|
|
76
|
+
interface Environment {
|
|
77
|
+
/** The benchmark index number that indicates rough device class. */
|
|
78
|
+
benchmarkIndex?: number;
|
|
79
|
+
/** The user agent string of the version of Chrome used. */
|
|
80
|
+
hostUserAgent?: string;
|
|
81
|
+
/** The user agent string that was sent over the network. */
|
|
82
|
+
networkUserAgent?: string;
|
|
83
|
+
}
|
|
84
|
+
// tslint:disable-next-line:interface-name
|
|
85
|
+
interface I18n {
|
|
86
|
+
/** Internationalized strings that are formatted to the locale in configSettings. */
|
|
87
|
+
rendererFormattedStrings?: RendererFormattedStrings;
|
|
88
|
+
}
|
|
89
|
+
interface LighthouseAuditResultV5 {
|
|
90
|
+
/** The description of the audit. */
|
|
91
|
+
description?: string;
|
|
92
|
+
/** Freeform details section of the audit. */
|
|
93
|
+
details?: { [P in string]: any };
|
|
94
|
+
/** The value that should be displayed on the UI for this audit. */
|
|
95
|
+
displayValue?: string;
|
|
96
|
+
/** An error message from a thrown error inside the audit. */
|
|
97
|
+
errorMessage?: string;
|
|
98
|
+
/** An explanation of the errors in the audit. */
|
|
99
|
+
explanation?: string;
|
|
100
|
+
/** The audit's id. */
|
|
101
|
+
id?: string;
|
|
102
|
+
/** The unit of the numeric_value field. Used to format the numeric value for display. */
|
|
103
|
+
numericUnit?: string;
|
|
104
|
+
/**
|
|
105
|
+
* A numeric value that has a meaning specific to the audit, e.g. the number of nodes in the DOM or the timestamp of a specific load event. More information can be found in the audit
|
|
106
|
+
* details, if present.
|
|
107
|
+
*/
|
|
108
|
+
numericValue?: number;
|
|
109
|
+
/** The score of the audit, can be null. */
|
|
110
|
+
score?: any;
|
|
111
|
+
/** The enumerated score display mode. */
|
|
112
|
+
scoreDisplayMode?: string;
|
|
113
|
+
/** The human readable title. */
|
|
114
|
+
title?: string;
|
|
115
|
+
/** Possible warnings that occurred in the audit, can be null. */
|
|
116
|
+
warnings?: any;
|
|
117
|
+
}
|
|
118
|
+
interface LighthouseCategoryV5 {
|
|
119
|
+
/** An array of references to all the audit members of this category. */
|
|
120
|
+
auditRefs?: AuditRefs[];
|
|
121
|
+
/** A more detailed description of the category and its importance. */
|
|
122
|
+
description?: string;
|
|
123
|
+
/** The string identifier of the category. */
|
|
124
|
+
id?: string;
|
|
125
|
+
/** A description for the manual audits in the category. */
|
|
126
|
+
manualDescription?: string;
|
|
127
|
+
/** The overall score of the category, the weighted average of all its audits. (The category's score, can be null.) */
|
|
128
|
+
score?: any;
|
|
129
|
+
/** The human-friendly name of the category. */
|
|
130
|
+
title?: string;
|
|
131
|
+
}
|
|
132
|
+
interface LighthouseResultV5 {
|
|
133
|
+
/** Map of audits in the LHR. */
|
|
134
|
+
audits?: { [P in string]: LighthouseAuditResultV5 };
|
|
135
|
+
/** Map of categories in the LHR. */
|
|
136
|
+
categories?: Categories;
|
|
137
|
+
/** Map of category groups in the LHR. */
|
|
138
|
+
categoryGroups?: { [P in string]: CategoryGroupV5 };
|
|
139
|
+
/** The configuration settings for this LHR. */
|
|
140
|
+
configSettings?: ConfigSettings;
|
|
141
|
+
/** Environment settings that were used when making this LHR. */
|
|
142
|
+
environment?: Environment;
|
|
143
|
+
/** The time that this run was fetched. */
|
|
144
|
+
fetchTime?: string;
|
|
145
|
+
/** The final resolved url that was audited. */
|
|
146
|
+
finalUrl?: string;
|
|
147
|
+
/** The internationalization strings that are required to render the LHR. */
|
|
148
|
+
i18n?: I18n;
|
|
149
|
+
/** The lighthouse version that was used to generate this LHR. */
|
|
150
|
+
lighthouseVersion?: string;
|
|
151
|
+
/** The original requested url. */
|
|
152
|
+
requestedUrl?: string;
|
|
153
|
+
/** A top-level error message that, if present, indicates a serious enough problem that this Lighthouse result may need to be discarded. */
|
|
154
|
+
runtimeError?: RuntimeError;
|
|
155
|
+
/** List of all run warnings in the LHR. Will always output to at least `[]`. */
|
|
156
|
+
runWarnings?: any[];
|
|
157
|
+
/** The Stack Pack advice strings. */
|
|
158
|
+
stackPacks?: StackPack[];
|
|
159
|
+
/** Timing information for this LHR. */
|
|
160
|
+
timing?: Timing;
|
|
161
|
+
/** The user agent that was used to run this LHR. */
|
|
162
|
+
userAgent?: string;
|
|
163
|
+
}
|
|
164
|
+
interface PagespeedApiLoadingExperienceV5 {
|
|
165
|
+
/** The url, pattern or origin which the metrics are on. */
|
|
166
|
+
id?: string;
|
|
167
|
+
/** The requested URL, which may differ from the resolved "id". */
|
|
168
|
+
initial_url?: string;
|
|
169
|
+
/** The map of . */
|
|
170
|
+
metrics?: { [P in string]: UserPageLoadMetricV5 };
|
|
171
|
+
/** True if the result is an origin fallback from a page, false otherwise. */
|
|
172
|
+
origin_fallback?: boolean;
|
|
173
|
+
/** The human readable speed "category" of the id. */
|
|
174
|
+
overall_category?: string;
|
|
175
|
+
}
|
|
176
|
+
interface PagespeedApiPagespeedResponseV5 {
|
|
177
|
+
/** The UTC timestamp of this analysis. */
|
|
178
|
+
analysisUTCTimestamp?: string;
|
|
179
|
+
/** The captcha verify result */
|
|
180
|
+
captchaResult?: string;
|
|
181
|
+
/** Canonicalized and final URL for the document, after following page redirects (if any). */
|
|
182
|
+
id?: string;
|
|
183
|
+
/** Kind of result. */
|
|
184
|
+
kind?: string;
|
|
185
|
+
/** Lighthouse response for the audit url as an object. */
|
|
186
|
+
lighthouseResult?: LighthouseResultV5;
|
|
187
|
+
/** Metrics of end users' page loading experience. */
|
|
188
|
+
loadingExperience?: PagespeedApiLoadingExperienceV5;
|
|
189
|
+
/** Metrics of the aggregated page loading experience of the origin */
|
|
190
|
+
originLoadingExperience?: PagespeedApiLoadingExperienceV5;
|
|
191
|
+
/** The version of PageSpeed used to generate these results. */
|
|
192
|
+
version?: PagespeedVersion;
|
|
193
|
+
}
|
|
194
|
+
interface PagespeedVersion {
|
|
195
|
+
/** The major version number of PageSpeed used to generate these results. */
|
|
196
|
+
major?: string;
|
|
197
|
+
/** The minor version number of PageSpeed used to generate these results. */
|
|
198
|
+
minor?: string;
|
|
199
|
+
}
|
|
200
|
+
interface RendererFormattedStrings {
|
|
201
|
+
/** The tooltip text on an expandable chevron icon. */
|
|
202
|
+
auditGroupExpandTooltip?: string;
|
|
203
|
+
/** Text link pointing to the Lighthouse scoring calculator. This link immediately follows a sentence stating the performance score is calculated from the perf metrics. */
|
|
204
|
+
calculatorLink?: string;
|
|
205
|
+
/** The label for the initial request in a critical request chain. */
|
|
206
|
+
crcInitialNavigation?: string;
|
|
207
|
+
/** The label for values shown in the summary of critical request chains. */
|
|
208
|
+
crcLongestDurationLabel?: string;
|
|
209
|
+
/** Option in a dropdown menu that copies the Lighthouse JSON object to the system clipboard. */
|
|
210
|
+
dropdownCopyJSON?: string;
|
|
211
|
+
/** Option in a dropdown menu that toggles the themeing of the report between Light(default) and Dark themes. */
|
|
212
|
+
dropdownDarkTheme?: string;
|
|
213
|
+
/** Option in a dropdown menu that opens a full Lighthouse report in a print dialog. */
|
|
214
|
+
dropdownPrintExpanded?: string;
|
|
215
|
+
/** Option in a dropdown menu that opens a small, summary report in a print dialog. */
|
|
216
|
+
dropdownPrintSummary?: string;
|
|
217
|
+
/** Option in a dropdown menu that saves the current report as a new GitHub Gist. */
|
|
218
|
+
dropdownSaveGist?: string;
|
|
219
|
+
/** Option in a dropdown menu that saves the Lighthouse report HTML locally to the system as a '.html' file. */
|
|
220
|
+
dropdownSaveHTML?: string;
|
|
221
|
+
/** Option in a dropdown menu that saves the Lighthouse JSON object to the local system as a '.json' file. */
|
|
222
|
+
dropdownSaveJSON?: string;
|
|
223
|
+
/** Option in a dropdown menu that opens the current report in the Lighthouse Viewer Application. */
|
|
224
|
+
dropdownViewer?: string;
|
|
225
|
+
/** The label shown next to an audit or metric that has had an error. */
|
|
226
|
+
errorLabel?: string;
|
|
227
|
+
/** The error string shown next to an erroring audit. */
|
|
228
|
+
errorMissingAuditInfo?: string;
|
|
229
|
+
/** Label for button to create an issue against the Lighthouse GitHub project. */
|
|
230
|
+
footerIssue?: string;
|
|
231
|
+
/** The title of the lab data performance category. */
|
|
232
|
+
labDataTitle?: string;
|
|
233
|
+
/** The disclaimer shown under performance explaining that the network can vary. */
|
|
234
|
+
lsPerformanceCategoryDescription?: string;
|
|
235
|
+
/** The heading shown above a list of audits that were not computerd in the run. */
|
|
236
|
+
manualAuditsGroupTitle?: string;
|
|
237
|
+
/** The heading shown above a list of audits that do not apply to a page. */
|
|
238
|
+
notApplicableAuditsGroupTitle?: string;
|
|
239
|
+
/** The heading for the estimated page load savings opportunity of an audit. */
|
|
240
|
+
opportunityResourceColumnLabel?: string;
|
|
241
|
+
/** The heading for the estimated page load savings of opportunity audits. */
|
|
242
|
+
opportunitySavingsColumnLabel?: string;
|
|
243
|
+
/** The heading that is shown above a list of audits that are passing. */
|
|
244
|
+
passedAuditsGroupTitle?: string;
|
|
245
|
+
/** Descriptive explanation for emulation setting when emulating a generic desktop form factor, as opposed to a mobile-device like form factor. */
|
|
246
|
+
runtimeDesktopEmulation?: string;
|
|
247
|
+
/** Descriptive explanation for emulation setting when emulating a Nexus 5X mobile device. */
|
|
248
|
+
runtimeMobileEmulation?: string;
|
|
249
|
+
/** Descriptive explanation for emulation setting when no device emulation is set. */
|
|
250
|
+
runtimeNoEmulation?: string;
|
|
251
|
+
/** Label for a row in a table that shows the version of the Axe library used */
|
|
252
|
+
runtimeSettingsAxeVersion?: string;
|
|
253
|
+
/** Label for a row in a table that shows the estimated CPU power of the machine running Lighthouse. Example row values: 532, 1492, 783. */
|
|
254
|
+
runtimeSettingsBenchmark?: string;
|
|
255
|
+
/** Label for a row in a table that shows in what tool Lighthouse is being run (e.g. The lighthouse CLI, Chrome DevTools, Lightrider, WebPageTest, etc). */
|
|
256
|
+
runtimeSettingsChannel?: string;
|
|
257
|
+
/** Label for a row in a table that describes the CPU throttling conditions that were used during a Lighthouse run, if any. */
|
|
258
|
+
runtimeSettingsCPUThrottling?: string;
|
|
259
|
+
/** Label for a row in a table that describes the kind of device that was emulated for the Lighthouse run. Example values for row elements: 'No Emulation', 'Emulated Desktop', etc. */
|
|
260
|
+
runtimeSettingsDevice?: string;
|
|
261
|
+
/** Label for a row in a table that shows the time at which a Lighthouse run was conducted; formatted as a timestamp, e.g. Jan 1, 1970 12:00 AM UTC. */
|
|
262
|
+
runtimeSettingsFetchTime?: string;
|
|
263
|
+
/** Label for a row in a table that describes the network throttling conditions that were used during a Lighthouse run, if any. */
|
|
264
|
+
runtimeSettingsNetworkThrottling?: string;
|
|
265
|
+
/** Title of the Runtime settings table in a Lighthouse report. Runtime settings are the environment configurations that a specific report used at auditing time. */
|
|
266
|
+
runtimeSettingsTitle?: string;
|
|
267
|
+
/** Label for a row in a table that shows the User Agent that was detected on the Host machine that ran Lighthouse. */
|
|
268
|
+
runtimeSettingsUA?: string;
|
|
269
|
+
/** Label for a row in a table that shows the User Agent that was used to send out all network requests during the Lighthouse run. */
|
|
270
|
+
runtimeSettingsUANetwork?: string;
|
|
271
|
+
/** Label for a row in a table that shows the URL that was audited during a Lighthouse run. */
|
|
272
|
+
runtimeSettingsUrl?: string;
|
|
273
|
+
/** Descriptive explanation for a runtime setting that is set to an unknown value. */
|
|
274
|
+
runtimeUnknown?: string;
|
|
275
|
+
/** The label that explains the score gauges scale (0-49, 50-89, 90-100). */
|
|
276
|
+
scorescaleLabel?: string;
|
|
277
|
+
/**
|
|
278
|
+
* Label preceding a radio control for filtering the list of audits. The radio choices are various performance metrics (FCP, LCP, TBT), and if chosen, the audits in the report are
|
|
279
|
+
* hidden if they are not relevant to the selected metric.
|
|
280
|
+
*/
|
|
281
|
+
showRelevantAudits?: string;
|
|
282
|
+
/** The label for the button to show only a few lines of a snippet */
|
|
283
|
+
snippetCollapseButtonLabel?: string;
|
|
284
|
+
/** The label for the button to show all lines of a snippet */
|
|
285
|
+
snippetExpandButtonLabel?: string;
|
|
286
|
+
/** This label is for a filter checkbox above a table of items */
|
|
287
|
+
thirdPartyResourcesLabel?: string;
|
|
288
|
+
/** Descriptive explanation for environment throttling that was provided by the runtime environment instead of provided by Lighthouse throttling. */
|
|
289
|
+
throttlingProvided?: string;
|
|
290
|
+
/** The label shown preceding important warnings that may have invalidated an entire report. */
|
|
291
|
+
toplevelWarningsMessage?: string;
|
|
292
|
+
/** The disclaimer shown below a performance metric value. */
|
|
293
|
+
varianceDisclaimer?: string;
|
|
294
|
+
/** Label for a button that opens the Treemap App */
|
|
295
|
+
viewTreemapLabel?: string;
|
|
296
|
+
/** The heading that is shown above a list of audits that have warnings */
|
|
297
|
+
warningAuditsGroupTitle?: string;
|
|
298
|
+
/** The label shown above a bulleted list of warnings. */
|
|
299
|
+
warningHeader?: string;
|
|
300
|
+
}
|
|
301
|
+
interface RuntimeError {
|
|
302
|
+
/** The enumerated Lighthouse Error code. */
|
|
303
|
+
code?: string;
|
|
304
|
+
/** A human readable message explaining the error code. */
|
|
305
|
+
message?: string;
|
|
306
|
+
}
|
|
307
|
+
interface StackPack {
|
|
308
|
+
/** The stack pack advice strings. */
|
|
309
|
+
descriptions?: { [P in string]: string };
|
|
310
|
+
/** The stack pack icon data uri. */
|
|
311
|
+
iconDataURL?: string;
|
|
312
|
+
/** The stack pack id. */
|
|
313
|
+
id?: string;
|
|
314
|
+
/** The stack pack title. */
|
|
315
|
+
title?: string;
|
|
316
|
+
}
|
|
317
|
+
interface Timing {
|
|
318
|
+
/** The total duration of Lighthouse's run. */
|
|
319
|
+
total?: number;
|
|
320
|
+
}
|
|
321
|
+
interface UserPageLoadMetricV5 {
|
|
322
|
+
/** The category of the specific time metric. */
|
|
323
|
+
category?: string;
|
|
324
|
+
/** Metric distributions. Proportions should sum up to 1. */
|
|
325
|
+
distributions?: Bucket[];
|
|
326
|
+
/** Identifies the form factor of the metric being collected. */
|
|
327
|
+
formFactor?: string;
|
|
328
|
+
/** The median number of the metric, in millisecond. */
|
|
329
|
+
median?: number;
|
|
330
|
+
/** Identifies the type of the metric. */
|
|
331
|
+
metricId?: string;
|
|
332
|
+
/** We use this field to store certain percentile value for this metric. For v4, this field contains pc50. For v5, this field contains pc90. */
|
|
333
|
+
percentile?: number;
|
|
334
|
+
}
|
|
335
|
+
interface PagespeedapiResource {
|
|
336
|
+
/** Runs PageSpeed analysis on the page at the specified URL, and returns PageSpeed scores, a list of suggestions to make that page faster, and other information. */
|
|
337
|
+
runpagespeed(request?: {
|
|
338
|
+
/** V1 error format. */
|
|
339
|
+
"$.xgafv"?: string;
|
|
340
|
+
/** OAuth access token. */
|
|
341
|
+
access_token?: string;
|
|
342
|
+
/** Data format for response. */
|
|
343
|
+
alt?: string;
|
|
344
|
+
/** JSONP */
|
|
345
|
+
callback?: string;
|
|
346
|
+
/** The captcha token passed when filling out a captcha. */
|
|
347
|
+
captchaToken?: string;
|
|
348
|
+
/** A Lighthouse category to run; if none are given, only Performance category will be run */
|
|
349
|
+
category?: string | string[];
|
|
350
|
+
/** Selector specifying which fields to include in a partial response. */
|
|
351
|
+
fields?: string;
|
|
352
|
+
/** API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */
|
|
353
|
+
key?: string;
|
|
354
|
+
/** The locale used to localize formatted results */
|
|
355
|
+
locale?: string;
|
|
356
|
+
/** OAuth 2.0 token for the current user. */
|
|
357
|
+
oauth_token?: string;
|
|
358
|
+
/** Returns response with indentations and line breaks. */
|
|
359
|
+
prettyPrint?: boolean;
|
|
360
|
+
/** Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */
|
|
361
|
+
quotaUser?: string;
|
|
362
|
+
/** The analysis strategy (desktop or mobile) to use, and desktop is the default */
|
|
363
|
+
strategy?: string;
|
|
364
|
+
/** Upload protocol for media (e.g. "raw", "multipart"). */
|
|
365
|
+
upload_protocol?: string;
|
|
366
|
+
/** Legacy upload protocol for media (e.g. "media", "multipart"). */
|
|
367
|
+
uploadType?: string;
|
|
368
|
+
/** Required. The URL to fetch and analyze */
|
|
369
|
+
url: string;
|
|
370
|
+
/** Campaign name for analytics. */
|
|
371
|
+
utm_campaign?: string;
|
|
372
|
+
/** Campaign source for analytics. */
|
|
373
|
+
utm_source?: string;
|
|
374
|
+
}): Request<PagespeedApiPagespeedResponseV5>;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
const pagespeedapi: PagespeedapiResource;
|
|
378
|
+
}
|
|
379
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@maxim_mazurok/gapi.client.pagespeedonline-v5",
|
|
3
|
+
"version": "0.0.20220811",
|
|
4
|
+
"description": "TypeScript typings for PageSpeed Insights API v5",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": {
|
|
7
|
+
"email": "maxim@mazurok.com",
|
|
8
|
+
"name": "Maxim Mazurok",
|
|
9
|
+
"url": "https://maxim.mazurok.com"
|
|
10
|
+
},
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "https://github.com/Maxim-Mazurok/google-api-typings-generator.git"
|
|
14
|
+
},
|
|
15
|
+
"types": "index.d.ts",
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"@types/gapi.client": "*",
|
|
18
|
+
"@types/gapi.client.discovery": "*"
|
|
19
|
+
}
|
|
20
|
+
}
|
package/readme.md
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# TypeScript typings for PageSpeed Insights API v5
|
|
2
|
+
|
|
3
|
+
The PageSpeed Insights API lets you analyze the performance of your website with a simple API. It offers tailored suggestions for how you can optimize your site, and lets you easily integrate PageSpeed Insights analysis into your development tools and workflow.
|
|
4
|
+
For detailed description please check [documentation](https://developers.google.com/speed/docs/insights/v5/about).
|
|
5
|
+
|
|
6
|
+
## Installing
|
|
7
|
+
|
|
8
|
+
Install typings for PageSpeed Insights API:
|
|
9
|
+
|
|
10
|
+
```
|
|
11
|
+
npm install @types/gapi.client.pagespeedonline-v5 --save-dev
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Usage
|
|
15
|
+
|
|
16
|
+
You need to initialize Google API client in your code:
|
|
17
|
+
|
|
18
|
+
```typescript
|
|
19
|
+
gapi.load('client', () => {
|
|
20
|
+
// now we can use gapi.client
|
|
21
|
+
// ...
|
|
22
|
+
});
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Then load api client wrapper:
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
gapi.client.load('https://pagespeedonline.googleapis.com/$discovery/rest?version=v5', () => {
|
|
29
|
+
// now we can use:
|
|
30
|
+
// gapi.client.pagespeedonline
|
|
31
|
+
});
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
```typescript
|
|
35
|
+
// Deprecated, use discovery document URL, see https://github.com/google/google-api-javascript-client/blob/master/docs/reference.md#----gapiclientloadname----version----callback--
|
|
36
|
+
gapi.client.load('pagespeedonline', 'v5', () => {
|
|
37
|
+
// now we can use:
|
|
38
|
+
// gapi.client.pagespeedonline
|
|
39
|
+
});
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Don't forget to authenticate your client before sending any request to resources:
|
|
43
|
+
|
|
44
|
+
```typescript
|
|
45
|
+
// declare client_id registered in Google Developers Console
|
|
46
|
+
var client_id = '',
|
|
47
|
+
scope = [
|
|
48
|
+
// Associate you with your personal info on Google
|
|
49
|
+
'openid',
|
|
50
|
+
],
|
|
51
|
+
immediate = true;
|
|
52
|
+
// ...
|
|
53
|
+
|
|
54
|
+
gapi.auth.authorize(
|
|
55
|
+
{ client_id: client_id, scope: scope, immediate: immediate },
|
|
56
|
+
authResult => {
|
|
57
|
+
if (authResult && !authResult.error) {
|
|
58
|
+
/* handle successful authorization */
|
|
59
|
+
} else {
|
|
60
|
+
/* handle authorization error */
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
After that you can use PageSpeed Insights API resources: <!-- TODO: make this work for multiple namespaces -->
|
|
66
|
+
|
|
67
|
+
```typescript
|
|
68
|
+
|
|
69
|
+
/*
|
|
70
|
+
Runs PageSpeed analysis on the page at the specified URL, and returns PageSpeed scores, a list of suggestions to make that page faster, and other information.
|
|
71
|
+
*/
|
|
72
|
+
await gapi.client.pagespeedonline.pagespeedapi.runpagespeed({ url: "url", });
|
|
73
|
+
```
|
package/tests.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/* This is stub file for gapi.client.pagespeedonline-v5 definition tests */
|
|
2
|
+
// IMPORTANT
|
|
3
|
+
// This file was generated by https://github.com/Maxim-Mazurok/google-api-typings-generator. Please do not edit it manually.
|
|
4
|
+
// In case of any problems please post issue to https://github.com/Maxim-Mazurok/google-api-typings-generator
|
|
5
|
+
|
|
6
|
+
// Revision: 20220811
|
|
7
|
+
|
|
8
|
+
gapi.load('client', async () => {
|
|
9
|
+
/** now we can use gapi.client */
|
|
10
|
+
|
|
11
|
+
await gapi.client.load('https://pagespeedonline.googleapis.com/$discovery/rest?version=v5');
|
|
12
|
+
/** now we can use gapi.client.pagespeedonline */
|
|
13
|
+
|
|
14
|
+
/** don't forget to authenticate your client before sending any request to resources: */
|
|
15
|
+
/** declare client_id registered in Google Developers Console */
|
|
16
|
+
const client_id = '<<PUT YOUR CLIENT ID HERE>>';
|
|
17
|
+
const scope = [
|
|
18
|
+
/** Associate you with your personal info on Google */
|
|
19
|
+
'openid',
|
|
20
|
+
];
|
|
21
|
+
const immediate = false;
|
|
22
|
+
gapi.auth.authorize({ client_id, scope, immediate }, authResult => {
|
|
23
|
+
if (authResult && !authResult.error) {
|
|
24
|
+
/** handle successful authorization */
|
|
25
|
+
run();
|
|
26
|
+
} else {
|
|
27
|
+
/** handle authorization error */
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
async function run() {
|
|
32
|
+
/** Runs PageSpeed analysis on the page at the specified URL, and returns PageSpeed scores, a list of suggestions to make that page faster, and other information. */
|
|
33
|
+
await gapi.client.pagespeedonline.pagespeedapi.runpagespeed({
|
|
34
|
+
captchaToken: "Test string",
|
|
35
|
+
category: "Test string",
|
|
36
|
+
locale: "Test string",
|
|
37
|
+
strategy: "Test string",
|
|
38
|
+
url: "Test string",
|
|
39
|
+
utm_campaign: "Test string",
|
|
40
|
+
utm_source: "Test string",
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
});
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"module": "commonjs",
|
|
4
|
+
"lib": ["es6", "dom"],
|
|
5
|
+
"noImplicitAny": true,
|
|
6
|
+
"noImplicitThis": true,
|
|
7
|
+
"strictNullChecks": true,
|
|
8
|
+
"baseUrl": "../",
|
|
9
|
+
"typeRoots": [
|
|
10
|
+
"../"
|
|
11
|
+
],
|
|
12
|
+
"types": [],
|
|
13
|
+
"noEmit": true,
|
|
14
|
+
"forceConsistentCasingInFileNames": true,
|
|
15
|
+
"strictFunctionTypes": true
|
|
16
|
+
},
|
|
17
|
+
"files": ["index.d.ts", "tests.ts"]
|
|
18
|
+
}
|