@automattic/jetpack-boost-score-api 0.1.34 → 0.1.36
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/CHANGELOG.md +10 -0
- package/build/api.d.ts +8 -8
- package/build/index.d.ts +11 -11
- package/build/utils/cast-to-number.d.ts +1 -1
- package/build/utils/cast-to-string.d.ts +1 -1
- package/build/utils/json-types.d.ts +2 -2
- package/build/utils/poll-promise.d.ts +1 -1
- package/build/utils/standardize-error.d.ts +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [0.1.36] - 2024-08-23
|
|
9
|
+
### Changed
|
|
10
|
+
- Updated package dependencies. [#39004]
|
|
11
|
+
|
|
12
|
+
## [0.1.35] - 2024-08-21
|
|
13
|
+
### Changed
|
|
14
|
+
- Internal updates.
|
|
15
|
+
|
|
8
16
|
## [0.1.34] - 2024-08-15
|
|
9
17
|
### Changed
|
|
10
18
|
- Updated package dependencies. [#38662]
|
|
@@ -151,6 +159,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
151
159
|
### Added
|
|
152
160
|
- Create package for the boost score bar API [#30781]
|
|
153
161
|
|
|
162
|
+
[0.1.36]: https://github.com/Automattic/jetpack-boost-score-api/compare/v0.1.35...v0.1.36
|
|
163
|
+
[0.1.35]: https://github.com/Automattic/jetpack-boost-score-api/compare/v0.1.34...v0.1.35
|
|
154
164
|
[0.1.34]: https://github.com/Automattic/jetpack-boost-score-api/compare/v0.1.33...v0.1.34
|
|
155
165
|
[0.1.33]: https://github.com/Automattic/jetpack-boost-score-api/compare/v0.1.32...v0.1.33
|
|
156
166
|
[0.1.32]: https://github.com/Automattic/jetpack-boost-score-api/compare/v0.1.31...v0.1.32
|
package/build/api.d.ts
CHANGED
|
@@ -2,20 +2,20 @@ import type { JSONObject } from './utils/json-object-type';
|
|
|
2
2
|
/**
|
|
3
3
|
* Make a GET request to the Boost REST API.
|
|
4
4
|
*
|
|
5
|
-
* @param {string} root
|
|
6
|
-
* @param {string} path
|
|
5
|
+
* @param {string} root - The root URL to use.
|
|
6
|
+
* @param {string} path - The path to the endpoint.
|
|
7
7
|
* @param {string} nonce - The nonce to use.
|
|
8
|
-
* @
|
|
8
|
+
* @return {Promise} - The response.
|
|
9
9
|
*/
|
|
10
10
|
declare function get<T = JSONObject>(root: string, path: string, nonce: string): Promise<T>;
|
|
11
11
|
/**
|
|
12
12
|
* Make a POST request to the Boost REST API.
|
|
13
13
|
*
|
|
14
|
-
* @param {string}
|
|
15
|
-
* @param {string}
|
|
16
|
-
* @param {null | JSONObject} body
|
|
17
|
-
* @param {string}
|
|
18
|
-
* @
|
|
14
|
+
* @param {string} root - The root URL to use.
|
|
15
|
+
* @param {string} path - The path to the endpoint.
|
|
16
|
+
* @param {null | JSONObject} body - The body of the request.
|
|
17
|
+
* @param {string} nonce - The nonce to use.
|
|
18
|
+
* @return {Promise} - The response.
|
|
19
19
|
*/
|
|
20
20
|
declare function post<T = JSONObject>(root: string, path: string, body: JSONObject | null, nonce: string): Promise<T>;
|
|
21
21
|
declare const _default: {
|
package/build/index.d.ts
CHANGED
|
@@ -44,11 +44,11 @@ interface SpeedHistoryResponse {
|
|
|
44
44
|
* Kick off a request to generate speed scores for this site. Will automatically
|
|
45
45
|
* poll for a response until the task is done, returning a SpeedScores object.
|
|
46
46
|
*
|
|
47
|
-
* @param {boolean} force
|
|
48
|
-
* @param {string}
|
|
49
|
-
* @param {string}
|
|
50
|
-
* @param {string}
|
|
51
|
-
* @
|
|
47
|
+
* @param {boolean} force - Force regenerate speed scores.
|
|
48
|
+
* @param {string} rootUrl - Root URL for the HTTP request.
|
|
49
|
+
* @param {string} siteUrl - URL of the site.
|
|
50
|
+
* @param {string} nonce - Nonce to use for authentication.
|
|
51
|
+
* @return {SpeedScoresSet} Speed scores returned by the server.
|
|
52
52
|
*/
|
|
53
53
|
export declare function requestSpeedScores(force: boolean, rootUrl: string, siteUrl: string, nonce: string): Promise<SpeedScoresSet>;
|
|
54
54
|
/**
|
|
@@ -57,8 +57,8 @@ export declare function requestSpeedScores(force: boolean, rootUrl: string, site
|
|
|
57
57
|
*
|
|
58
58
|
* @param {string} rootUrl - Root URL for the HTTP request.
|
|
59
59
|
* @param {string} siteUrl - URL of the site.
|
|
60
|
-
* @param {string} nonce
|
|
61
|
-
* @
|
|
60
|
+
* @param {string} nonce - Nonce to use for authentication.
|
|
61
|
+
* @return {SpeedHistoryResponse} Speed score history returned by the server.
|
|
62
62
|
*/
|
|
63
63
|
export declare function requestSpeedScoresHistory(rootUrl: string, siteUrl: string, nonce: string): Promise<SpeedHistoryResponse>;
|
|
64
64
|
/**
|
|
@@ -67,7 +67,7 @@ export declare function requestSpeedScoresHistory(rootUrl: string, siteUrl: stri
|
|
|
67
67
|
*
|
|
68
68
|
* @param {number} mobile - Mobile speed score
|
|
69
69
|
* @param {number} desktop - Desktop speed score
|
|
70
|
-
* @
|
|
70
|
+
* @return {string} letter score
|
|
71
71
|
*/
|
|
72
72
|
export declare function getScoreLetter(mobile: number, desktop: number): string;
|
|
73
73
|
/**
|
|
@@ -75,21 +75,21 @@ export declare function getScoreLetter(mobile: number, desktop: number): string;
|
|
|
75
75
|
* The message varies depending on the results of the speed scores so lets modify this
|
|
76
76
|
*
|
|
77
77
|
* @param {SpeedScoresSet} scores - Speed scores returned by the server.
|
|
78
|
-
* @
|
|
78
|
+
* @return {boolean} true if scores changed.
|
|
79
79
|
*/
|
|
80
80
|
export declare function didScoresChange(scores: SpeedScoresSet): boolean;
|
|
81
81
|
/**
|
|
82
82
|
* Determine the change in scores to pass through to other functions.
|
|
83
83
|
*
|
|
84
84
|
* @param {SpeedScoresSet} scores - Speed scores returned by the server.
|
|
85
|
-
* @
|
|
85
|
+
* @return {number} - The change in scores in percentage.
|
|
86
86
|
*/
|
|
87
87
|
export declare function getScoreMovementPercentage(scores: SpeedScoresSet): number;
|
|
88
88
|
/**
|
|
89
89
|
* Determine the number of days since the last timestamp.
|
|
90
90
|
*
|
|
91
91
|
* @param {number} timestamp - the timestamp returned by the server.
|
|
92
|
-
* @
|
|
92
|
+
* @return {number} - The number of days.
|
|
93
93
|
*/
|
|
94
94
|
export declare function calculateDaysSince(timestamp: number): number;
|
|
95
95
|
export {};
|
|
@@ -6,6 +6,6 @@
|
|
|
6
6
|
* @template DefaultType
|
|
7
7
|
* @param {*} value - External value to process as a number
|
|
8
8
|
* @param {DefaultType} defaultValue - Default value to return if not a number.
|
|
9
|
-
* @
|
|
9
|
+
* @return {number | DefaultType} value as a number, of defaultValue.
|
|
10
10
|
*/
|
|
11
11
|
export declare function castToNumber<DefaultType = number>(value: unknown, defaultValue?: DefaultType): number | DefaultType;
|
|
@@ -6,6 +6,6 @@
|
|
|
6
6
|
* @template DefaultType
|
|
7
7
|
* @param {*} value - External value to process as a string
|
|
8
8
|
* @param {DefaultType} defaultValue - Default value to return if not a string
|
|
9
|
-
* @
|
|
9
|
+
* @return {string | DefaultType} value as a string, of defaultValue.
|
|
10
10
|
*/
|
|
11
11
|
export declare function castToString<DefaultType = undefined>(value: unknown, defaultValue?: DefaultType | undefined): string | DefaultType | undefined;
|
|
@@ -12,7 +12,7 @@ export type JSONValue = string | number | boolean | JSONObject | JSONArray | nul
|
|
|
12
12
|
* Returns true if the given JSONValue is a JSONObject.
|
|
13
13
|
*
|
|
14
14
|
* @param {JSONValue} value - Value to check.
|
|
15
|
-
* @
|
|
15
|
+
* @return {boolean} True if the given value is a JSONObject.
|
|
16
16
|
*/
|
|
17
17
|
export declare function isJsonObject(value: JSONValue): value is JSONObject;
|
|
18
18
|
/**
|
|
@@ -20,6 +20,6 @@ export declare function isJsonObject(value: JSONValue): value is JSONObject;
|
|
|
20
20
|
* Sure, you could use x instanceof Array but this is shorter and more consistent.
|
|
21
21
|
*
|
|
22
22
|
* @param {JSONValue} value - Value to check.
|
|
23
|
-
* @
|
|
23
|
+
* @return {boolean} True if the given value is a JSONArray.
|
|
24
24
|
*/
|
|
25
25
|
export declare function isJsonArray(value: JSONValue): value is JSONArray;
|
|
@@ -18,7 +18,7 @@ type PollPromiseArgs<RetType = void> = {
|
|
|
18
18
|
* @param {number} obj.timeout - Milliseconds before rejecting w/ a timeout
|
|
19
19
|
* @param {Function} obj.callback - Callback to call every <interval> ms.
|
|
20
20
|
* @param {string} obj.timeoutError - Message to throw on timeout.
|
|
21
|
-
* @
|
|
21
|
+
* @return {Promise< RetType >} - A promise which resolves to the value resolved() inside callback.
|
|
22
22
|
*/
|
|
23
23
|
export default function pollPromise<RetType = void>({ interval, callback, timeout, timeoutError, }: PollPromiseArgs<RetType>): Promise<RetType>;
|
|
24
24
|
export {};
|
|
@@ -5,6 +5,6 @@ import type { JSONValue } from './json-types';
|
|
|
5
5
|
*
|
|
6
6
|
* @param {*} data - Any thrown error data to interpret as an Error (or subclass)
|
|
7
7
|
* @param {JSONValue|Error} defaultMessage - A default message to throw if no sensible error can be found.
|
|
8
|
-
* @
|
|
8
|
+
* @return {Error} the data guaranteed to be an Error or subclass thereof.
|
|
9
9
|
*/
|
|
10
10
|
export declare function standardizeError(data: JSONValue | Error, defaultMessage?: string): Error;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@automattic/jetpack-boost-score-api",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.36",
|
|
4
4
|
"description": "A package to get the Jetpack Boost score of a site",
|
|
5
5
|
"homepage": "https://github.com/Automattic/jetpack/tree/HEAD/projects/js-packages/boost-score-api/#readme",
|
|
6
6
|
"bugs": {
|