mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
- definition file for PageSpeedInsights v.4 - tests https://github.com/GoogleChromeLabs/psi https://github.com/GoogleChromeLabs/psi#usage https://developers.google.com/speed/docs/insights/v5/about Thanks! /cc @astronaute77 Closes #45210
182 lines
4.5 KiB
TypeScript
182 lines
4.5 KiB
TypeScript
// Type definitions for psi 4.0
|
|
// Project: https://github.com/GoogleChromeLabs/psi#readme
|
|
// Definitions by: Piotr Błażejewicz <https://github.com/peterblazejewicz>
|
|
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
|
|
|
/**
|
|
* PageSpeed Insights with reporting
|
|
*/
|
|
declare function psi(url: string, options?: psi.Options): Promise<psi.ResponseData>;
|
|
|
|
declare namespace psi {
|
|
/**
|
|
* Output the formatted report to the terminal.
|
|
*/
|
|
function output(url: string, options?: Options): Promise<ResponseData>;
|
|
|
|
interface Options {
|
|
/**
|
|
* When using this module for a production-level build process,
|
|
* registering for an API key from the Google Developer Console is recommended.
|
|
*/
|
|
key?: string;
|
|
nokey?: string;
|
|
/**
|
|
* Strategy to use when analyzing the page.
|
|
* @default 'mobile'
|
|
*/
|
|
strategy?: 'mobile' | 'desktop';
|
|
/**
|
|
* Locale results should be generated in.
|
|
* @default 'en_US'
|
|
*/
|
|
locale?: string;
|
|
/**
|
|
* Threshold score to pass the PageSpeed test. Useful for setting a performance budget.
|
|
* @default 70
|
|
*/
|
|
treshold?: number;
|
|
}
|
|
|
|
interface Experience {
|
|
id: string;
|
|
metrics: {
|
|
[key: string]: {
|
|
percentile: number;
|
|
distributions: Array<{
|
|
min: number;
|
|
max: number;
|
|
proportion: number;
|
|
}>;
|
|
category: string;
|
|
};
|
|
};
|
|
overall_category: string;
|
|
initial_url: string;
|
|
}
|
|
|
|
interface Environment {
|
|
networkUserAgent: string;
|
|
hostUserAgent: string;
|
|
benchmarkIndex: number;
|
|
}
|
|
|
|
interface ConfigSettings {
|
|
emulatedFormFactor: string;
|
|
locale: string;
|
|
onlyCategories: object;
|
|
}
|
|
|
|
interface Audit {
|
|
id: string;
|
|
title: string;
|
|
description: string;
|
|
score: object;
|
|
displayValue: string;
|
|
scoreDisplayMode: string;
|
|
explanation: string;
|
|
errorMessage: string;
|
|
warnings: object;
|
|
details: {
|
|
[key: string]: object;
|
|
};
|
|
}
|
|
|
|
interface AuditRef {
|
|
id: string;
|
|
weight: number;
|
|
group: string;
|
|
}
|
|
|
|
interface Category {
|
|
id: string;
|
|
title: string;
|
|
description: string;
|
|
score: object;
|
|
manualDescription: string;
|
|
auditRefs: AuditRef[];
|
|
}
|
|
|
|
interface CategoryGroup {
|
|
title: string;
|
|
description: string;
|
|
}
|
|
|
|
interface RuntimeError {
|
|
code: string;
|
|
message: string;
|
|
}
|
|
|
|
interface Timing {
|
|
total: number;
|
|
}
|
|
|
|
interface RendererFormattedStrings {
|
|
varianceDisclaimer: string;
|
|
opportunityResourceColumnLabel: string;
|
|
opportunitySavingsColumnLabel: string;
|
|
errorMissingAuditInfo: string;
|
|
errorLabel: string;
|
|
warningHeader: string;
|
|
auditGroupExpandTooltip: string;
|
|
passedAuditsGroupTitle: string;
|
|
notApplicableAuditsGroupTitle: string;
|
|
manualAuditsGroupTitle: string;
|
|
toplevelWarningsMessage: string;
|
|
scorescaleLabel: string;
|
|
crcLongestDurationLabel: string;
|
|
crcInitialNavigation: string;
|
|
lsPerformanceCategoryDescription: string;
|
|
labDataTitle: string;
|
|
}
|
|
|
|
// tslint:disable-next-line:interface-name I18N is established convention
|
|
interface I18N {
|
|
rendererFormattedStrings: RendererFormattedStrings;
|
|
}
|
|
|
|
interface Version {
|
|
major: number;
|
|
minor: number;
|
|
}
|
|
|
|
interface ResponseData {
|
|
data: Result;
|
|
}
|
|
|
|
interface LighthouseResult {
|
|
requestedUrl: string;
|
|
finalUrl: string;
|
|
lighthouseVersion: string;
|
|
userAgent: string;
|
|
fetchTime: string;
|
|
environment: Environment;
|
|
runWarnings: string[];
|
|
configSettings: ConfigSettings;
|
|
audits: {
|
|
[key: string]: Audit;
|
|
};
|
|
categories: {
|
|
[key: string]: Category;
|
|
};
|
|
categoryGroups: {
|
|
[key: string]: CategoryGroup;
|
|
};
|
|
runtimeError: RuntimeError;
|
|
timing: Timing;
|
|
i18n: I18N;
|
|
}
|
|
interface Result {
|
|
captchaResult: string;
|
|
kind: string;
|
|
id: string;
|
|
loadingExperience: Experience;
|
|
originLoadingExperience: Experience;
|
|
lighthouseResult: LighthouseResult;
|
|
analysisUTCTimestamp: string;
|
|
version: Version;
|
|
}
|
|
}
|
|
|
|
export = psi;
|