Skip to content

Commit e59d332

Browse files
update types and ci
1 parent 0655336 commit e59d332

File tree

2 files changed

+128
-13
lines changed

2 files changed

+128
-13
lines changed

.github/workflows/main.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ name: CI
22
on: push
33
jobs:
44
build:
5-
runs-on: ubuntu-latest
5+
runs-on: ubuntu-24.04
66
steps:
7-
- uses: actions/checkout@v4
8-
- uses: actions/setup-node@v3
7+
- uses: actions/checkout@v6
8+
- uses: actions/setup-node@v6
99
with:
10-
node-version: '18'
10+
node-version: 24
1111
cache: 'yarn'
12-
- run: yarn install
12+
- run: yarn install --frozen-lockfile
1313
- run: yarn test
1414
env:
1515
CRUX_KEY: ${{ secrets.CRUX_KEY }}

types/index.d.ts

Lines changed: 123 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@
22
* @typedef {{ key: string, fetch?: function }} CreateOptions
33
* @typedef {{ url?: string, origin?: string, formFactor?: FormFactor }} QueryRecordOptions
44
* @typedef {'ALL_FORM_FACTORS' | 'PHONE' | 'DESKTOP' | 'TABLET'} FormFactor
5+
* @typedef {{ percentiles: { p75: number } }} PercentileValue
56
* @typedef {{ histogram: { start: number | string, end: number | string, density: number }[], percentiles: { p75: number | string } }} MetricValue
7+
* @typedef {{ histogram: { start: string, end: string, density: number }[], percentiles: { p75: string } }} MetricStringValue
8+
* @typedef {{ fractions: { desktop: number, phone: number, tablet: number } }} FormFactorFractionValue
9+
* @typedef {{ fractions: { image: number, text: number } }} NavigationTypesFractionValue
10+
* @typedef {{ fractions: { navigate: number, navigate_cache: number, back_forward: number, back_forward_cache: number, reload: number, restore: number, prerender: number } }} ResourceTypesFractionValue
611
* @typedef {{ year: number, month: number, day: number }} MetricDate
712
* @typedef {{ firstDate: MetricDate, lastDate: MetricDate }} CollectionPeriod
813
* @typedef {{ error: { code: number, message: string, status: string } }} ErrorResponse
@@ -16,17 +21,24 @@
1621
* metrics: {
1722
* first_contentful_paint?: MetricValue,
1823
* largest_contentful_paint?: MetricValue,
19-
* first_input_delay?: MetricValue,
20-
* cumulative_layout_shift?: MetricValue,
24+
* cumulative_layout_shift?: MetricStringValue,
2125
* interaction_to_next_paint?: MetricValue,
2226
* experimental_time_to_first_byte?: MetricValue,
23-
* },
27+
* round_trip_time?: MetricValue,
28+
* form_factors?: FormFactorFractionValue,
29+
* navigation_types?: NavigationTypesFractionValue,
30+
* largest_contentful_paint_resource_type: ResourceTypesFractionValue,
31+
* largest_contentful_paint_image_time_to_first_byte: PercentileValue,
32+
* largest_contentful_paint_image_resource_load_delay: PercentileValue,
33+
* largest_contentful_paint_image_resource_load_duration: PercentileValue,
34+
* largest_contentful_paint_image_element_render_delay: PercentileValue,
35+
* }
2436
* collectionPeriod: CollectionPeriod
2537
* },
2638
* urlNormalizationDetails?: {
2739
* originalUrl: string,
2840
* normalizedUrl: string
29-
* }
41+
* },
3042
* }} SuccessResponse
3143
*
3244
* @typedef {(?number | string)[]} PercentileValues
@@ -36,6 +48,13 @@
3648
* percentilesTimeseries: { p75s: PercentileValues }
3749
* }} HistoryValue
3850
*
51+
* @typedef {number | 'NaN'} DensityValue
52+
* @typedef {{ fractions: DensityValue[] }} Fractions
53+
* @typedef {Object<string, Fractions>} FractionTimeseries
54+
* @typedef {{ desktop: Fractions, phone: Fractions, tablet: Fractions }} FormFactorsFractionTimeseries
55+
* @typedef {{ back_forward_cache: Fractions, prerender: Fractions, navigate: Fractions, navigate_cache: Fractions, reload: Fractions, restore: Fractions, back_forward: Fractions }} NavigationTypesFractionTimeseries
56+
* @typedef {{ image: Fractions, text: Fractions }} ResourceTypesFractionTimeseries
57+
* @typedef {{ percentilesTimeseries: { p75s: (?number)[] } }} HistoryPercentile
3958
* @typedef {{
4059
* record: {
4160
* key: {
@@ -44,12 +63,19 @@
4463
* formFactor?: FormFactor
4564
* },
4665
* metrics: {
47-
* first_input_delay?: HistoryValue,
4866
* first_contentful_paint?: HistoryValue,
4967
* largest_contentful_paint?: HistoryValue,
5068
* cumulative_layout_shift?: HistoryValue,
5169
* interaction_to_next_paint?: HistoryValue,
5270
* experimental_time_to_first_byte?: HistoryValue,
71+
* round_trip_time?: HistoryValue,
72+
* form_factors?: { fractionTimeseries: FormFactorsFractionTimeseries },
73+
* navigation_types?: { fractionTimeseries: NavigationTypesFractionTimeseries },
74+
* largest_contentful_paint_resource_type: { fractionTimeseries: ResourceTypesFractionTimeseries },
75+
* largest_contentful_paint_image_time_to_first_byte: HistoryPercentile,
76+
* largest_contentful_paint_image_resource_load_delay: HistoryPercentile,
77+
* largest_contentful_paint_image_resource_load_duration: HistoryPercentile,
78+
* largest_contentful_paint_image_element_render_delay: HistoryPercentile,
5379
* }
5480
* collectionPeriods: CollectionPeriod[]
5581
* },
@@ -87,6 +113,11 @@ export type QueryRecordOptions = {
87113
formFactor?: FormFactor;
88114
};
89115
export type FormFactor = "ALL_FORM_FACTORS" | "PHONE" | "DESKTOP" | "TABLET";
116+
export type PercentileValue = {
117+
percentiles: {
118+
p75: number;
119+
};
120+
};
90121
export type MetricValue = {
91122
histogram: {
92123
start: number | string;
@@ -97,6 +128,40 @@ export type MetricValue = {
97128
p75: number | string;
98129
};
99130
};
131+
export type MetricStringValue = {
132+
histogram: {
133+
start: string;
134+
end: string;
135+
density: number;
136+
}[];
137+
percentiles: {
138+
p75: string;
139+
};
140+
};
141+
export type FormFactorFractionValue = {
142+
fractions: {
143+
desktop: number;
144+
phone: number;
145+
tablet: number;
146+
};
147+
};
148+
export type NavigationTypesFractionValue = {
149+
fractions: {
150+
image: number;
151+
text: number;
152+
};
153+
};
154+
export type ResourceTypesFractionValue = {
155+
fractions: {
156+
navigate: number;
157+
navigate_cache: number;
158+
back_forward: number;
159+
back_forward_cache: number;
160+
reload: number;
161+
restore: number;
162+
prerender: number;
163+
};
164+
};
100165
export type MetricDate = {
101166
year: number;
102167
month: number;
@@ -123,10 +188,17 @@ export type SuccessResponse = {
123188
metrics: {
124189
first_contentful_paint?: MetricValue;
125190
largest_contentful_paint?: MetricValue;
126-
first_input_delay?: MetricValue;
127-
cumulative_layout_shift?: MetricValue;
191+
cumulative_layout_shift?: MetricStringValue;
128192
interaction_to_next_paint?: MetricValue;
129193
experimental_time_to_first_byte?: MetricValue;
194+
round_trip_time?: MetricValue;
195+
form_factors?: FormFactorFractionValue;
196+
navigation_types?: NavigationTypesFractionValue;
197+
largest_contentful_paint_resource_type: ResourceTypesFractionValue;
198+
largest_contentful_paint_image_time_to_first_byte: PercentileValue;
199+
largest_contentful_paint_image_resource_load_delay: PercentileValue;
200+
largest_contentful_paint_image_resource_load_duration: PercentileValue;
201+
largest_contentful_paint_image_element_render_delay: PercentileValue;
130202
};
131203
collectionPeriod: CollectionPeriod;
132204
};
@@ -147,6 +219,36 @@ export type HistoryValue = {
147219
p75s: PercentileValues;
148220
};
149221
};
222+
export type DensityValue = number | "NaN";
223+
export type Fractions = {
224+
fractions: DensityValue[];
225+
};
226+
export type FractionTimeseries = {
227+
[x: string]: Fractions;
228+
};
229+
export type FormFactorsFractionTimeseries = {
230+
desktop: Fractions;
231+
phone: Fractions;
232+
tablet: Fractions;
233+
};
234+
export type NavigationTypesFractionTimeseries = {
235+
back_forward_cache: Fractions;
236+
prerender: Fractions;
237+
navigate: Fractions;
238+
navigate_cache: Fractions;
239+
reload: Fractions;
240+
restore: Fractions;
241+
back_forward: Fractions;
242+
};
243+
export type ResourceTypesFractionTimeseries = {
244+
image: Fractions;
245+
text: Fractions;
246+
};
247+
export type HistoryPercentile = {
248+
percentilesTimeseries: {
249+
p75s: (number | null)[];
250+
};
251+
};
150252
export type HistoryResponse = {
151253
record: {
152254
key: {
@@ -155,12 +257,25 @@ export type HistoryResponse = {
155257
formFactor?: FormFactor;
156258
};
157259
metrics: {
158-
first_input_delay?: HistoryValue;
159260
first_contentful_paint?: HistoryValue;
160261
largest_contentful_paint?: HistoryValue;
161262
cumulative_layout_shift?: HistoryValue;
162263
interaction_to_next_paint?: HistoryValue;
163264
experimental_time_to_first_byte?: HistoryValue;
265+
round_trip_time?: HistoryValue;
266+
form_factors?: {
267+
fractionTimeseries: FormFactorsFractionTimeseries;
268+
};
269+
navigation_types?: {
270+
fractionTimeseries: NavigationTypesFractionTimeseries;
271+
};
272+
largest_contentful_paint_resource_type: {
273+
fractionTimeseries: ResourceTypesFractionTimeseries;
274+
};
275+
largest_contentful_paint_image_time_to_first_byte: HistoryPercentile;
276+
largest_contentful_paint_image_resource_load_delay: HistoryPercentile;
277+
largest_contentful_paint_image_resource_load_duration: HistoryPercentile;
278+
largest_contentful_paint_image_element_render_delay: HistoryPercentile;
164279
};
165280
collectionPeriods: CollectionPeriod[];
166281
};

0 commit comments

Comments
 (0)