@maxim_mazurok/gapi.client.chromeuxreport-v1 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 ADDED
@@ -0,0 +1,167 @@
1
+ /* Type definitions for non-npm package Chrome UX Report API v1 0.0 */
2
+ // Project: https://developers.google.com/web/tools/chrome-user-experience-report/api/reference
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://chromeuxreport.googleapis.com/$discovery/rest?version=v1
13
+ // Revision: 20220811
14
+
15
+ /// <reference types="gapi.client" />
16
+
17
+ declare namespace gapi.client {
18
+ /** Load Chrome UX Report API v1 */
19
+ function load(urlOrObject: "https://chromeuxreport.googleapis.com/$discovery/rest?version=v1"): Promise<void>;
20
+ /** @deprecated Please load APIs with discovery documents. */
21
+ function load(name: "chromeuxreport", version: "v1"): Promise<void>;
22
+ /** @deprecated Please load APIs with discovery documents. */
23
+ function load(name: "chromeuxreport", version: "v1", callback: () => any): void;
24
+
25
+ namespace chromeuxreport {
26
+ interface Bin {
27
+ /** The proportion of users that experienced this bin's value for the given metric. */
28
+ density?: number;
29
+ /** End is the end of the data bin. If end is not populated, then the bin has no end and is valid from start to +inf. */
30
+ end?: any;
31
+ /** Start is the beginning of the data bin. */
32
+ start?: any;
33
+ }
34
+ interface Key {
35
+ /**
36
+ * The effective connection type is the general connection class that all users experienced for this record. This field uses the values ["offline", "slow-2G", "2G", "3G", "4G"] as
37
+ * specified in: https://wicg.github.io/netinfo/#effective-connection-types If the effective connection type is unspecified, then aggregated data over all effective connection types
38
+ * will be returned.
39
+ */
40
+ effectiveConnectionType?: string;
41
+ /**
42
+ * The form factor is the device class that all users used to access the site for this record. If the form factor is unspecified, then aggregated data over all form factors will be
43
+ * returned.
44
+ */
45
+ formFactor?: string;
46
+ /**
47
+ * Origin specifies the origin that this record is for. Note: When specifying an origin, data for loads under this origin over all pages are aggregated into origin level user
48
+ * experience data.
49
+ */
50
+ origin?: string;
51
+ /** Url specifies a specific url that this record is for. Note: When specifying a "url" only data for that specific url will be aggregated. */
52
+ url?: string;
53
+ }
54
+ interface Metric {
55
+ /** The histogram of user experiences for a metric. The histogram will have at least one bin and the densities of all bins will add up to ~1. */
56
+ histogram?: Bin[];
57
+ /** Common useful percentiles of the Metric. The value type for the percentiles will be the same as the value types given for the Histogram bins. */
58
+ percentiles?: Percentiles;
59
+ }
60
+ interface Percentiles {
61
+ /** 75% of users experienced the given metric at or below this value. */
62
+ p75?: any;
63
+ }
64
+ interface QueryRequest {
65
+ /**
66
+ * The effective connection type is a query dimension that specifies the effective network class that the record's data should belong to. This field uses the values ["offline",
67
+ * "slow-2G", "2G", "3G", "4G"] as specified in: https://wicg.github.io/netinfo/#effective-connection-types Note: If no effective connection type is specified, then a special record
68
+ * with aggregated data over all effective connection types will be returned.
69
+ */
70
+ effectiveConnectionType?: string;
71
+ /**
72
+ * The form factor is a query dimension that specifies the device class that the record's data should belong to. Note: If no form factor is specified, then a special record with
73
+ * aggregated data over all form factors will be returned.
74
+ */
75
+ formFactor?: string;
76
+ /**
77
+ * The metrics that should be included in the response. If none are specified then any metrics found will be returned. Allowed values: ["first_contentful_paint", "first_input_delay",
78
+ * "largest_contentful_paint", "cumulative_layout_shift", "experimental_time_to_first_byte", "experimental_interaction_to_next_paint"]
79
+ */
80
+ metrics?: string[];
81
+ /** The url pattern "origin" refers to a url pattern that is the origin of a website. Examples: "https://example.com", "https://cloud.google.com" */
82
+ origin?: string;
83
+ /** The url pattern "url" refers to a url pattern that is any arbitrary url. Examples: "https://example.com/", "https://cloud.google.com/why-google-cloud/" */
84
+ url?: string;
85
+ }
86
+ interface QueryResponse {
87
+ /** The record that was found. */
88
+ record?: Record;
89
+ /** These are details about automated normalization actions that were taken in order to make the requested `url_pattern` valid. */
90
+ urlNormalizationDetails?: UrlNormalization;
91
+ }
92
+ interface Record {
93
+ /** Key defines all of the unique querying parameters needed to look up a user experience record. */
94
+ key?: Key;
95
+ /**
96
+ * Metrics is the map of user experience data available for the record defined in the key field. Metrics are keyed on the metric name. Allowed key values: ["first_contentful_paint",
97
+ * "first_input_delay", "largest_contentful_paint", "cumulative_layout_shift"]
98
+ */
99
+ metrics?: { [P in string]: Metric };
100
+ }
101
+ interface UrlNormalization {
102
+ /** The URL after any normalization actions. This is a valid user experience URL that could reasonably be looked up. */
103
+ normalizedUrl?: string;
104
+ /** The original requested URL prior to any normalization actions. */
105
+ originalUrl?: string;
106
+ }
107
+ interface RecordsResource {
108
+ /**
109
+ * Queries the Chrome User Experience for a single `record` for a given site. Returns a `record` that contains one or more `metrics` corresponding to performance data about the
110
+ * requested site.
111
+ */
112
+ queryRecord(request: {
113
+ /** V1 error format. */
114
+ "$.xgafv"?: string;
115
+ /** OAuth access token. */
116
+ access_token?: string;
117
+ /** Data format for response. */
118
+ alt?: string;
119
+ /** JSONP */
120
+ callback?: string;
121
+ /** Selector specifying which fields to include in a partial response. */
122
+ fields?: string;
123
+ /** 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. */
124
+ key?: string;
125
+ /** OAuth 2.0 token for the current user. */
126
+ oauth_token?: string;
127
+ /** Returns response with indentations and line breaks. */
128
+ prettyPrint?: boolean;
129
+ /** 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. */
130
+ quotaUser?: string;
131
+ /** Upload protocol for media (e.g. "raw", "multipart"). */
132
+ upload_protocol?: string;
133
+ /** Legacy upload protocol for media (e.g. "media", "multipart"). */
134
+ uploadType?: string;
135
+ /** Request body */
136
+ resource: QueryRequest;
137
+ }): Request<QueryResponse>;
138
+ queryRecord(request: {
139
+ /** V1 error format. */
140
+ "$.xgafv"?: string;
141
+ /** OAuth access token. */
142
+ access_token?: string;
143
+ /** Data format for response. */
144
+ alt?: string;
145
+ /** JSONP */
146
+ callback?: string;
147
+ /** Selector specifying which fields to include in a partial response. */
148
+ fields?: string;
149
+ /** 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. */
150
+ key?: string;
151
+ /** OAuth 2.0 token for the current user. */
152
+ oauth_token?: string;
153
+ /** Returns response with indentations and line breaks. */
154
+ prettyPrint?: boolean;
155
+ /** 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. */
156
+ quotaUser?: string;
157
+ /** Upload protocol for media (e.g. "raw", "multipart"). */
158
+ upload_protocol?: string;
159
+ /** Legacy upload protocol for media (e.g. "media", "multipart"). */
160
+ uploadType?: string;
161
+ },
162
+ body: QueryRequest): Request<QueryResponse>;
163
+ }
164
+
165
+ const records: RecordsResource;
166
+ }
167
+ }
package/package.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "@maxim_mazurok/gapi.client.chromeuxreport-v1",
3
+ "version": "0.0.20220811",
4
+ "description": "TypeScript typings for Chrome UX Report API v1",
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,52 @@
1
+ # TypeScript typings for Chrome UX Report API v1
2
+
3
+ The Chrome UX Report API lets you view real user experience data for millions of websites.
4
+ For detailed description please check [documentation](https://developers.google.com/web/tools/chrome-user-experience-report/api/reference).
5
+
6
+ ## Installing
7
+
8
+ Install typings for Chrome UX Report API:
9
+
10
+ ```
11
+ npm install @types/gapi.client.chromeuxreport-v1 --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://chromeuxreport.googleapis.com/$discovery/rest?version=v1', () => {
29
+ // now we can use:
30
+ // gapi.client.chromeuxreport
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('chromeuxreport', 'v1', () => {
37
+ // now we can use:
38
+ // gapi.client.chromeuxreport
39
+ });
40
+ ```
41
+
42
+
43
+
44
+ After that you can use Chrome UX Report API resources: <!-- TODO: make this work for multiple namespaces -->
45
+
46
+ ```typescript
47
+
48
+ /*
49
+ Queries the Chrome User Experience for a single `record` for a given site. Returns a `record` that contains one or more `metrics` corresponding to performance data about the requested site.
50
+ */
51
+ await gapi.client.chromeuxreport.records.queryRecord({ });
52
+ ```
package/tests.ts ADDED
@@ -0,0 +1,32 @@
1
+ /* This is stub file for gapi.client.chromeuxreport-v1 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://chromeuxreport.googleapis.com/$discovery/rest?version=v1');
12
+ /** now we can use gapi.client.chromeuxreport */
13
+
14
+ run();
15
+
16
+ async function run() {
17
+ /**
18
+ * Queries the Chrome User Experience for a single `record` for a given site. Returns a `record` that contains one or more `metrics` corresponding to performance data about the requested
19
+ * site.
20
+ */
21
+ await gapi.client.chromeuxreport.records.queryRecord({
22
+ }, {
23
+ effectiveConnectionType: "Test string",
24
+ formFactor: "Test string",
25
+ metrics: [
26
+ "Test string"
27
+ ],
28
+ origin: "Test string",
29
+ url: "Test string",
30
+ });
31
+ }
32
+ });
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
+ }
package/tslint.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "extends": "dtslint/dtslint.json",
3
+ "rules": {
4
+ "no-redundant-jsdoc": false
5
+ }
6
+ }