@contentful/optimization-api-client 0.1.0-alpha
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/LICENSE +21 -0
- package/README.md +282 -0
- package/dist/ApiClient.d.ts +74 -0
- package/dist/ApiClient.d.ts.map +1 -0
- package/dist/ApiClient.js +61 -0
- package/dist/ApiClient.js.map +1 -0
- package/dist/ApiClientBase.d.ts +113 -0
- package/dist/ApiClientBase.d.ts.map +1 -0
- package/dist/ApiClientBase.js +94 -0
- package/dist/ApiClientBase.js.map +1 -0
- package/dist/builders/EventBuilder.d.ts +589 -0
- package/dist/builders/EventBuilder.d.ts.map +1 -0
- package/dist/builders/EventBuilder.js +349 -0
- package/dist/builders/EventBuilder.js.map +1 -0
- package/dist/builders/index.d.ts +3 -0
- package/dist/builders/index.d.ts.map +1 -0
- package/dist/builders/index.js +3 -0
- package/dist/builders/index.js.map +1 -0
- package/dist/experience/ExperienceApiClient.d.ts +267 -0
- package/dist/experience/ExperienceApiClient.d.ts.map +1 -0
- package/dist/experience/ExperienceApiClient.js +324 -0
- package/dist/experience/ExperienceApiClient.js.map +1 -0
- package/dist/experience/index.d.ts +4 -0
- package/dist/experience/index.d.ts.map +1 -0
- package/dist/experience/index.js +4 -0
- package/dist/experience/index.js.map +1 -0
- package/dist/fetch/Fetch.d.ts +96 -0
- package/dist/fetch/Fetch.d.ts.map +1 -0
- package/dist/fetch/Fetch.js +27 -0
- package/dist/fetch/Fetch.js.map +1 -0
- package/dist/fetch/createProtectedFetchMethod.d.ts +40 -0
- package/dist/fetch/createProtectedFetchMethod.d.ts.map +1 -0
- package/dist/fetch/createProtectedFetchMethod.js +53 -0
- package/dist/fetch/createProtectedFetchMethod.js.map +1 -0
- package/dist/fetch/createRetryFetchMethod.d.ts +60 -0
- package/dist/fetch/createRetryFetchMethod.d.ts.map +1 -0
- package/dist/fetch/createRetryFetchMethod.js +138 -0
- package/dist/fetch/createRetryFetchMethod.js.map +1 -0
- package/dist/fetch/createTimeoutFetchMethod.d.ts +51 -0
- package/dist/fetch/createTimeoutFetchMethod.d.ts.map +1 -0
- package/dist/fetch/createTimeoutFetchMethod.js +51 -0
- package/dist/fetch/createTimeoutFetchMethod.js.map +1 -0
- package/dist/fetch/index.d.ts +7 -0
- package/dist/fetch/index.d.ts.map +1 -0
- package/dist/fetch/index.js +7 -0
- package/dist/fetch/index.js.map +1 -0
- package/dist/index.cjs +708 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +583 -0
- package/dist/index.mjs.map +1 -0
- package/dist/insights/InsightsApiClient.d.ts +130 -0
- package/dist/insights/InsightsApiClient.d.ts.map +1 -0
- package/dist/insights/InsightsApiClient.js +142 -0
- package/dist/insights/InsightsApiClient.js.map +1 -0
- package/dist/insights/index.d.ts +4 -0
- package/dist/insights/index.d.ts.map +1 -0
- package/dist/insights/index.js +4 -0
- package/dist/insights/index.js.map +1 -0
- package/package.json +27 -0
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { createScopedLogger } from 'logger';
|
|
2
|
+
import retry from 'p-retry';
|
|
3
|
+
const logger = createScopedLogger('ApiClient:Retry');
|
|
4
|
+
/**
|
|
5
|
+
* Default interval (in milliseconds) between retry attempts.
|
|
6
|
+
*
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
const DEFAULT_INTERVAL_TIMEOUT = 0;
|
|
10
|
+
/**
|
|
11
|
+
* Default number of retry attempts.
|
|
12
|
+
*
|
|
13
|
+
* @internal
|
|
14
|
+
*/
|
|
15
|
+
const DEFAULT_RETRY_COUNT = 1;
|
|
16
|
+
/**
|
|
17
|
+
* HTTP status code that triggers a retry.
|
|
18
|
+
*
|
|
19
|
+
* @internal
|
|
20
|
+
*
|
|
21
|
+
* @remarks
|
|
22
|
+
* This value is currently fixed to `503 Service Unavailable`.
|
|
23
|
+
*/
|
|
24
|
+
const RETRY_RESPONSE_STATUS = 503;
|
|
25
|
+
/**
|
|
26
|
+
* Default HTTP status code used for {@link HttpError}.
|
|
27
|
+
*
|
|
28
|
+
* @internal
|
|
29
|
+
*/
|
|
30
|
+
const HTTP_ERROR_RESPONSE_STATUS = 500;
|
|
31
|
+
/**
|
|
32
|
+
* Error type representing HTTP failures with an associated status code.
|
|
33
|
+
*
|
|
34
|
+
* @internal
|
|
35
|
+
*/
|
|
36
|
+
class HttpError extends Error {
|
|
37
|
+
/**
|
|
38
|
+
* The HTTP status code associated with the error.
|
|
39
|
+
*/
|
|
40
|
+
status;
|
|
41
|
+
/**
|
|
42
|
+
* Creates a new {@link HttpError}.
|
|
43
|
+
*
|
|
44
|
+
* @param message - Description of the error.
|
|
45
|
+
* @param status - HTTP status code associated with the error.
|
|
46
|
+
*/
|
|
47
|
+
constructor(message, status = HTTP_ERROR_RESPONSE_STATUS) {
|
|
48
|
+
super(message);
|
|
49
|
+
Object.setPrototypeOf(this, HttpError.prototype);
|
|
50
|
+
this.status = status;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Creates a callback function used by `p-retry` to perform a fetch with retry logic.
|
|
55
|
+
*
|
|
56
|
+
* @param options - Internal options controlling the retry behavior.
|
|
57
|
+
* @returns A function that, when invoked, performs the fetch and applies retry rules.
|
|
58
|
+
*
|
|
59
|
+
* @internal
|
|
60
|
+
*/
|
|
61
|
+
function createRetryFetchCallback({ apiName = 'Optimization', controller, fetchMethod = fetch, init, url, }) {
|
|
62
|
+
return async () => {
|
|
63
|
+
try {
|
|
64
|
+
const response = await fetchMethod(url, init);
|
|
65
|
+
if (response.status === RETRY_RESPONSE_STATUS) {
|
|
66
|
+
throw new HttpError(`${apiName} API request to "${url.toString()}" failed with status: "[${response.status}] ${response.statusText}".`, RETRY_RESPONSE_STATUS);
|
|
67
|
+
}
|
|
68
|
+
if (!response.ok) {
|
|
69
|
+
const httpError = new Error(`Request to "${url.toString()}" failed with status: [${response.status}] ${response.statusText} - traceparent: ${response.headers.get('traceparent')}`);
|
|
70
|
+
logger.error('Request failed with non-OK status:', httpError);
|
|
71
|
+
controller.abort();
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
logger.debug(`Response from "${url.toString()}":`, response);
|
|
75
|
+
return response;
|
|
76
|
+
}
|
|
77
|
+
catch (error) {
|
|
78
|
+
if (error instanceof HttpError && error.status === RETRY_RESPONSE_STATUS) {
|
|
79
|
+
throw error;
|
|
80
|
+
}
|
|
81
|
+
logger.error(`Request to "${url.toString()}" failed:`, error);
|
|
82
|
+
controller.abort();
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Creates a {@link FetchMethod} that retries failed requests according to the
|
|
88
|
+
* provided configuration.
|
|
89
|
+
*
|
|
90
|
+
* @param options - Configuration options that control retry behavior.
|
|
91
|
+
* @returns A {@link FetchMethod} that automatically retries qualifying failures.
|
|
92
|
+
*
|
|
93
|
+
* @remarks
|
|
94
|
+
* This wrapper integrates with `p-retry` and uses an {@link AbortController}
|
|
95
|
+
* to cancel pending requests when a non-retriable error occurs.
|
|
96
|
+
*
|
|
97
|
+
* @throws {@link Error}
|
|
98
|
+
* Thrown when the request cannot be retried and no successful response is obtained.
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* ```ts
|
|
102
|
+
* const fetchWithRetry = createRetryFetchMethod({
|
|
103
|
+
* apiName: 'Optimization',
|
|
104
|
+
* retries: 3,
|
|
105
|
+
* intervalTimeout: 200,
|
|
106
|
+
* onFailedAttempt: ({ attemptNumber, retriesLeft }) => {
|
|
107
|
+
* console.warn(`Attempt ${attemptNumber} failed. Retries left: ${retriesLeft}`)
|
|
108
|
+
* },
|
|
109
|
+
* })
|
|
110
|
+
*
|
|
111
|
+
* const response = await fetchWithRetry('https://example.com', { method: 'GET' })
|
|
112
|
+
* ```
|
|
113
|
+
*/
|
|
114
|
+
export function createRetryFetchMethod({ apiName = 'Optimization', fetchMethod = fetch, intervalTimeout = DEFAULT_INTERVAL_TIMEOUT, onFailedAttempt, retries = DEFAULT_RETRY_COUNT, } = {}) {
|
|
115
|
+
return async (url, init) => {
|
|
116
|
+
const controller = new AbortController();
|
|
117
|
+
let retryResponse = undefined;
|
|
118
|
+
try {
|
|
119
|
+
retryResponse = await retry(createRetryFetchCallback({ apiName, controller, fetchMethod, init, url }), {
|
|
120
|
+
minTimeout: intervalTimeout,
|
|
121
|
+
onFailedAttempt: (options) => onFailedAttempt?.({ ...options, apiName }),
|
|
122
|
+
retries,
|
|
123
|
+
signal: controller.signal,
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
catch (error) {
|
|
127
|
+
// Abort errors caused by timeouts should not bubble up and be reported by third-party tools (e.g. Sentry)
|
|
128
|
+
if (!(error instanceof Error) || error.name !== 'AbortError') {
|
|
129
|
+
throw error;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
if (!retryResponse) {
|
|
133
|
+
throw new Error(`${apiName} API request to "${url.toString()}" may not be retried.`);
|
|
134
|
+
}
|
|
135
|
+
return retryResponse;
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
//# sourceMappingURL=createRetryFetchMethod.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createRetryFetchMethod.js","sourceRoot":"","sources":["../../src/fetch/createRetryFetchMethod.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,QAAQ,CAAA;AAC3C,OAAO,KAAK,MAAM,SAAS,CAAA;AAG3B,MAAM,MAAM,GAAG,kBAAkB,CAAC,iBAAiB,CAAC,CAAA;AAEpD;;;;GAIG;AACH,MAAM,wBAAwB,GAAG,CAAC,CAAA;AAElC;;;;GAIG;AACH,MAAM,mBAAmB,GAAG,CAAC,CAAA;AAE7B;;;;;;;GAOG;AACH,MAAM,qBAAqB,GAAG,GAAG,CAAA;AAEj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,KAAK,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;gBAC7D,MAAM,KAAK,CAAA;YACb,CAAC;QACH,CAAC;QAED,IAAI,CAAC,aAAa,EAAE,CAAC;YACnB,MAAM,IAAI,KAAK,CAAC,GAAG,OAAO,oBAAoB,GAAG,CAAC,QAAQ,EAAE,uBAAuB,CAAC,CAAA;QACtF,CAAC;QAED,OAAO,aAAa,CAAA;IACtB,CAAC,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { BaseFetchMethodOptions, FetchMethod, FetchMethodCallbackOptions } from './Fetch';
|
|
2
|
+
/**
|
|
3
|
+
* Configuration options for {@link createTimeoutFetchMethod}.
|
|
4
|
+
*/
|
|
5
|
+
export interface TimeoutFetchMethodOptions extends BaseFetchMethodOptions {
|
|
6
|
+
/**
|
|
7
|
+
* Callback invoked when a request exceeds the configured timeout.
|
|
8
|
+
*
|
|
9
|
+
* @param options - Information about the timed-out request.
|
|
10
|
+
*
|
|
11
|
+
* @remarks
|
|
12
|
+
* If this callback is not provided, a default error is logged.
|
|
13
|
+
*
|
|
14
|
+
* @see {@link FetchMethodCallbackOptions}
|
|
15
|
+
*/
|
|
16
|
+
onRequestTimeout?: (options: FetchMethodCallbackOptions) => void;
|
|
17
|
+
/**
|
|
18
|
+
* Maximum time (in milliseconds) to wait for a response before aborting the request.
|
|
19
|
+
*
|
|
20
|
+
* @remarks
|
|
21
|
+
* Defaults to {@link DEFAULT_REQUEST_TIMEOUT}.
|
|
22
|
+
*/
|
|
23
|
+
requestTimeout?: number;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Creates a {@link FetchMethod} that aborts requests after a configurable timeout.
|
|
27
|
+
*
|
|
28
|
+
* @param options - Configuration options controlling timeout behavior.
|
|
29
|
+
* @returns A {@link FetchMethod} that enforces a timeout for each request.
|
|
30
|
+
*
|
|
31
|
+
* @remarks
|
|
32
|
+
* When a timeout occurs, the request is aborted using an {@link AbortController}.
|
|
33
|
+
* If `onRequestTimeout` is not provided, an error is logged by the {@link logger}.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```ts
|
|
37
|
+
* const fetchWithTimeout = createTimeoutFetchMethod({
|
|
38
|
+
* apiName: 'Optimization',
|
|
39
|
+
* requestTimeout: 5000,
|
|
40
|
+
* onRequestTimeout: ({ apiName }) => {
|
|
41
|
+
* console.warn(`${apiName} request timed out`)
|
|
42
|
+
* },
|
|
43
|
+
* })
|
|
44
|
+
*
|
|
45
|
+
* const response = await fetchWithTimeout('https://example.com', { method: 'GET' })
|
|
46
|
+
* ```
|
|
47
|
+
*
|
|
48
|
+
* @see {@link TimeoutFetchMethodOptions}
|
|
49
|
+
*/
|
|
50
|
+
export declare function createTimeoutFetchMethod({ apiName, fetchMethod, onRequestTimeout, requestTimeout, }?: TimeoutFetchMethodOptions): FetchMethod;
|
|
51
|
+
//# sourceMappingURL=createTimeoutFetchMethod.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createTimeoutFetchMethod.d.ts","sourceRoot":"","sources":["../../src/fetch/createTimeoutFetchMethod.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,WAAW,EAAE,0BAA0B,EAAE,MAAM,SAAS,CAAA;AAW9F;;GAEG;AACH,MAAM,WAAW,yBAA0B,SAAQ,sBAAsB;IACvE;;;;;;;;;OASG;IACH,gBAAgB,CAAC,EAAE,CAAC,OAAO,EAAE,0BAA0B,KAAK,IAAI,CAAA;IAEhE;;;;;OAKG;IACH,cAAc,CAAC,EAAE,MAAM,CAAA;CACxB;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,wBAAwB,CAAC,EACvC,OAAwB,EACxB,WAAmB,EACnB,gBAAgB,EAChB,cAAwC,GACzC,GAAE,yBAA8B,GAAG,WAAW,CAoB9C"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { createScopedLogger } from 'logger';
|
|
2
|
+
const logger = createScopedLogger('ApiClient:Timeout');
|
|
3
|
+
/**
|
|
4
|
+
* Default timeout (in milliseconds) for outgoing requests.
|
|
5
|
+
*
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
8
|
+
const DEFAULT_REQUEST_TIMEOUT = 3000;
|
|
9
|
+
/**
|
|
10
|
+
* Creates a {@link FetchMethod} that aborts requests after a configurable timeout.
|
|
11
|
+
*
|
|
12
|
+
* @param options - Configuration options controlling timeout behavior.
|
|
13
|
+
* @returns A {@link FetchMethod} that enforces a timeout for each request.
|
|
14
|
+
*
|
|
15
|
+
* @remarks
|
|
16
|
+
* When a timeout occurs, the request is aborted using an {@link AbortController}.
|
|
17
|
+
* If `onRequestTimeout` is not provided, an error is logged by the {@link logger}.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```ts
|
|
21
|
+
* const fetchWithTimeout = createTimeoutFetchMethod({
|
|
22
|
+
* apiName: 'Optimization',
|
|
23
|
+
* requestTimeout: 5000,
|
|
24
|
+
* onRequestTimeout: ({ apiName }) => {
|
|
25
|
+
* console.warn(`${apiName} request timed out`)
|
|
26
|
+
* },
|
|
27
|
+
* })
|
|
28
|
+
*
|
|
29
|
+
* const response = await fetchWithTimeout('https://example.com', { method: 'GET' })
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* @see {@link TimeoutFetchMethodOptions}
|
|
33
|
+
*/
|
|
34
|
+
export function createTimeoutFetchMethod({ apiName = 'Optimization', fetchMethod = fetch, onRequestTimeout, requestTimeout = DEFAULT_REQUEST_TIMEOUT, } = {}) {
|
|
35
|
+
return async (url, init) => {
|
|
36
|
+
const controller = new AbortController();
|
|
37
|
+
const id = setTimeout(() => {
|
|
38
|
+
if (typeof onRequestTimeout === 'function') {
|
|
39
|
+
onRequestTimeout({ apiName });
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
logger.error(`Request to "${url.toString()}" timed out`, new Error('Request timeout'));
|
|
43
|
+
}
|
|
44
|
+
controller.abort();
|
|
45
|
+
}, requestTimeout);
|
|
46
|
+
const response = await fetchMethod(url, { ...init, signal: controller.signal });
|
|
47
|
+
clearTimeout(id);
|
|
48
|
+
return response;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=createTimeoutFetchMethod.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createTimeoutFetchMethod.js","sourceRoot":"","sources":["../../src/fetch/createTimeoutFetchMethod.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,QAAQ,CAAA;AAG3C,MAAM,MAAM,GAAG,kBAAkB,CAAC,mBAAmB,CAAC,CAAA;AAEtD;;;;GAIG;AACH,MAAM,uBAAuB,GAAG,IAAI,CAAA;AA2BpC;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,UAAU,wBAAwB,CAAC,EACvC,OAAO,GAAG,cAAc,EACxB,WAAW,GAAG,KAAK,EACnB,gBAAgB,EAChB,cAAc,GAAG,uBAAuB,MACX,EAAE;IAC/B,OAAO,KAAK,EAAE,GAAiB,EAAE,IAAiB,EAAE,EAAE;QACpD,MAAM,UAAU,GAAG,IAAI,eAAe,EAAE,CAAA;QAExC,MAAM,EAAE,GAAG,UAAU,CAAC,GAAG,EAAE;YACzB,IAAI,OAAO,gBAAgB,KAAK,UAAU,EAAE,CAAC;gBAC3C,gBAAgB,CAAC,EAAE,OAAO,EAAE,CAAC,CAAA;YAC/B,CAAC;iBAAM,CAAC;gBACN,MAAM,CAAC,KAAK,CAAC,eAAe,GAAG,CAAC,QAAQ,EAAE,aAAa,EAAE,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC,CAAA;YACxF,CAAC;YAED,UAAU,CAAC,KAAK,EAAE,CAAA;QACpB,CAAC,EAAE,cAAc,CAAC,CAAA;QAElB,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,GAAG,EAAE,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,UAAU,CAAC,MAAM,EAAE,CAAC,CAAA;QAE/E,YAAY,CAAC,EAAE,CAAC,CAAA;QAEhB,OAAO,QAAQ,CAAA;IACjB,CAAC,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/fetch/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,SAAS,CAAA;AAE3B,cAAc,8BAA8B,CAAA;AAC5C,cAAc,0BAA0B,CAAA;AACxC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,SAAS,CAAA;AAEvB,eAAe,KAAK,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/fetch/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,SAAS,CAAA;AAE3B,cAAc,8BAA8B,CAAA;AAC5C,cAAc,0BAA0B,CAAA;AACxC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,SAAS,CAAA;AAEvB,eAAe,KAAK,CAAA"}
|