crux-api 2.0.0 → 3.0.1
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/README.md +822 -70
- package/package.json +24 -35
- package/src/index.js +55 -10
- package/types/index.d.ts +176 -0
- package/dist/batch/src/index.d.ts +0 -17
- package/dist/crux-api.d.ts +0 -100
- package/dist/crux-api.js +0 -1
- package/dist/keys.d.ts +0 -7
- package/dist/keys.js +0 -21
- package/dist/retry.d.ts +0 -8
- package/dist/retry.js +0 -66
- package/dist/script/batch-limits.d.ts +0 -1
- package/dist/script/batch.d.ts +0 -1
- package/dist/script/queryRecord.d.ts +0 -1
- package/dist/src/index.d.ts +0 -100
- package/dist/src/retry.d.ts +0 -8
- package/dist/test/batch.d.ts +0 -1
- package/dist/test/index.d.ts +0 -1
package/dist/src/index.d.ts
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @typedef {{ key: string, fetch?: function }} CreateOptions
|
|
3
|
-
* @typedef {{ url?: string, origin?: string, formFactor?: FormFactor, effectiveConnectionType?: Connection }} QueryRecordOptions
|
|
4
|
-
* @typedef {'ALL_FORM_FACTORS' | 'PHONE' | 'DESKTOP' | 'TABLET'} FormFactor
|
|
5
|
-
* @typedef {'4G' | '3G' | '2G' | 'slow-2G' | 'offline'} Connection
|
|
6
|
-
* @typedef {{ histogram: { start: number | string, end: number | string, density: number }[], percentiles: { p75: number | string } }} MetricValue
|
|
7
|
-
* @typedef {'first_contentful_paint' | 'largest_contentful_paint' | 'first_input_delay' | 'cumulative_layout_shift'} MetricName
|
|
8
|
-
* @typedef {{ error: { code: number, message: string, status: string } }} ErrorResponse
|
|
9
|
-
* @typedef {{
|
|
10
|
-
* record: {
|
|
11
|
-
* key: {
|
|
12
|
-
* url?: string,
|
|
13
|
-
* origin?: string,
|
|
14
|
-
* effectiveConnectionType?: Connection,
|
|
15
|
-
* formFactor?: FormFactor
|
|
16
|
-
* },
|
|
17
|
-
* metrics: {
|
|
18
|
-
* first_contentful_paint?: MetricValue,
|
|
19
|
-
* largest_contentful_paint?: MetricValue,
|
|
20
|
-
* first_input_delay?: MetricValue,
|
|
21
|
-
* cumulative_layout_shift?: MetricValue,
|
|
22
|
-
* }
|
|
23
|
-
* },
|
|
24
|
-
* urlNormalizationDetails?: {
|
|
25
|
-
* originalUrl: string,
|
|
26
|
-
* normalizedUrl: string
|
|
27
|
-
* }
|
|
28
|
-
* }} SuccessResponse
|
|
29
|
-
*/
|
|
30
|
-
/**
|
|
31
|
-
* Fetch CrUX API and handles 4xx errors.
|
|
32
|
-
* Inspired by: https://github.com/GoogleChrome/CrUX/blob/master/js/crux-api-util.js
|
|
33
|
-
*
|
|
34
|
-
* @param {CreateOptions} createOptions
|
|
35
|
-
*/
|
|
36
|
-
export function createQueryRecord(createOptions: CreateOptions): (queryOptions: QueryRecordOptions, retryCounter?: number) => Promise<SuccessResponse | null>;
|
|
37
|
-
/**
|
|
38
|
-
* Normalize URL to match CrUX API key.
|
|
39
|
-
*
|
|
40
|
-
* @param {string} url
|
|
41
|
-
*/
|
|
42
|
-
export function normalizeUrl(url: string): string;
|
|
43
|
-
/**
|
|
44
|
-
* Random delay from 1ms to `maxRetryTimeout`.
|
|
45
|
-
* Random logic is based on: https://stackoverflow.com/a/29246176
|
|
46
|
-
*
|
|
47
|
-
* @param {number} retryCounter
|
|
48
|
-
* @param {function} request
|
|
49
|
-
*/
|
|
50
|
-
export function retryAfterTimeout(retryCounter: number, request: Function): Promise<any>;
|
|
51
|
-
export type CreateOptions = {
|
|
52
|
-
key: string;
|
|
53
|
-
fetch?: Function;
|
|
54
|
-
};
|
|
55
|
-
export type QueryRecordOptions = {
|
|
56
|
-
url?: string;
|
|
57
|
-
origin?: string;
|
|
58
|
-
formFactor?: FormFactor;
|
|
59
|
-
effectiveConnectionType?: Connection;
|
|
60
|
-
};
|
|
61
|
-
export type FormFactor = 'ALL_FORM_FACTORS' | 'PHONE' | 'DESKTOP' | 'TABLET';
|
|
62
|
-
export type Connection = '4G' | '3G' | '2G' | 'slow-2G' | 'offline';
|
|
63
|
-
export type MetricValue = {
|
|
64
|
-
histogram: {
|
|
65
|
-
start: number | string;
|
|
66
|
-
end: number | string;
|
|
67
|
-
density: number;
|
|
68
|
-
}[];
|
|
69
|
-
percentiles: {
|
|
70
|
-
p75: number | string;
|
|
71
|
-
};
|
|
72
|
-
};
|
|
73
|
-
export type MetricName = 'first_contentful_paint' | 'largest_contentful_paint' | 'first_input_delay' | 'cumulative_layout_shift';
|
|
74
|
-
export type ErrorResponse = {
|
|
75
|
-
error: {
|
|
76
|
-
code: number;
|
|
77
|
-
message: string;
|
|
78
|
-
status: string;
|
|
79
|
-
};
|
|
80
|
-
};
|
|
81
|
-
export type SuccessResponse = {
|
|
82
|
-
record: {
|
|
83
|
-
key: {
|
|
84
|
-
url?: string;
|
|
85
|
-
origin?: string;
|
|
86
|
-
effectiveConnectionType?: Connection;
|
|
87
|
-
formFactor?: FormFactor;
|
|
88
|
-
};
|
|
89
|
-
metrics: {
|
|
90
|
-
first_contentful_paint?: MetricValue;
|
|
91
|
-
largest_contentful_paint?: MetricValue;
|
|
92
|
-
first_input_delay?: MetricValue;
|
|
93
|
-
cumulative_layout_shift?: MetricValue;
|
|
94
|
-
};
|
|
95
|
-
};
|
|
96
|
-
urlNormalizationDetails?: {
|
|
97
|
-
originalUrl: string;
|
|
98
|
-
normalizedUrl: string;
|
|
99
|
-
};
|
|
100
|
-
};
|
package/dist/src/retry.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Random delay from 1ms to `maxRetryTimeout`.
|
|
3
|
-
* Random logic is based on: https://stackoverflow.com/a/29246176
|
|
4
|
-
*
|
|
5
|
-
* @param {number} retryCounter
|
|
6
|
-
* @param {function} request
|
|
7
|
-
*/
|
|
8
|
-
export function retryAfterTimeout(retryCounter: number, request: Function): Promise<any>;
|
package/dist/test/batch.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/test/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|