@decocms/apps-vtex 7.37.1 → 7.37.3
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/package.json +5 -5
- package/src/client.ts +3 -2
- package/src/utils/fetch.ts +5 -1
- package/src/utils/instrumentedFetch.ts +2 -1
- package/src/utils/sitemap.ts +3 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@decocms/apps-vtex",
|
|
3
|
-
"version": "7.37.
|
|
3
|
+
"version": "7.37.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Deco commerce app: VTEX integration",
|
|
6
6
|
"repository": {
|
|
@@ -51,10 +51,10 @@
|
|
|
51
51
|
"lint:unused": "knip"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@decocms/blocks": "7.37.
|
|
55
|
-
"@decocms/apps-commerce": "7.37.
|
|
56
|
-
"@decocms/apps-website": "7.37.
|
|
57
|
-
"@decocms/tanstack": "7.37.
|
|
54
|
+
"@decocms/blocks": "7.37.3",
|
|
55
|
+
"@decocms/apps-commerce": "7.37.3",
|
|
56
|
+
"@decocms/apps-website": "7.37.3",
|
|
57
|
+
"@decocms/tanstack": "7.37.3"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
60
|
"@tanstack/react-query": ">=5.0.0",
|
package/src/client.ts
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* Uses VTEX's public REST APIs (Intelligent Search + Catalog + Checkout).
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
+
import { type FetchFn, withFetchTimeout } from "@decocms/blocks/sdk/fetchTimeout";
|
|
6
7
|
import type {
|
|
7
8
|
InstrumentedFetch,
|
|
8
9
|
InstrumentedFetchInit,
|
|
@@ -147,7 +148,7 @@ export interface VtexConfig {
|
|
|
147
148
|
}
|
|
148
149
|
|
|
149
150
|
let _config: VtexConfig | null = null;
|
|
150
|
-
let _fetch:
|
|
151
|
+
let _fetch: FetchFn | InstrumentedFetch = withFetchTimeout();
|
|
151
152
|
|
|
152
153
|
export function configureVtex(config: VtexConfig) {
|
|
153
154
|
_config = config;
|
|
@@ -169,7 +170,7 @@ export function configureVtex(config: VtexConfig) {
|
|
|
169
170
|
* uninstrumented (useful for tests + sites that haven't onboarded
|
|
170
171
|
* the observability stack yet).
|
|
171
172
|
*/
|
|
172
|
-
export function setVtexFetch(fetchFn:
|
|
173
|
+
export function setVtexFetch(fetchFn: FetchFn | InstrumentedFetch) {
|
|
173
174
|
_fetch = fetchFn;
|
|
174
175
|
}
|
|
175
176
|
|
package/src/utils/fetch.ts
CHANGED
|
@@ -15,6 +15,10 @@
|
|
|
15
15
|
* the platform.
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
+
import { withFetchTimeout } from "@decocms/blocks/sdk/fetchTimeout";
|
|
19
|
+
|
|
20
|
+
const timeoutFetch = withFetchTimeout();
|
|
21
|
+
|
|
18
22
|
type CachingMode = "stale-while-revalidate";
|
|
19
23
|
|
|
20
24
|
type DecoInit = {
|
|
@@ -88,7 +92,7 @@ export async function fetchSafe(
|
|
|
88
92
|
init?: DecoRequestInit,
|
|
89
93
|
): Promise<Response> {
|
|
90
94
|
const sanitized = sanitizeUrl(input);
|
|
91
|
-
const response = await
|
|
95
|
+
const response = await timeoutFetch(sanitized as RequestInfo, init);
|
|
92
96
|
if (!response.ok) {
|
|
93
97
|
throw new HttpError(response);
|
|
94
98
|
}
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
* behavior.
|
|
31
31
|
*/
|
|
32
32
|
|
|
33
|
+
import type { FetchFn } from "@decocms/blocks/sdk/fetchTimeout";
|
|
33
34
|
import {
|
|
34
35
|
createInstrumentedFetch,
|
|
35
36
|
type InstrumentedFetch,
|
|
@@ -45,7 +46,7 @@ export interface CreateVtexFetchOptions {
|
|
|
45
46
|
* or routes through a proxy) to preserve its behavior while adding
|
|
46
47
|
* the VTEX instrumentation layer on top.
|
|
47
48
|
*/
|
|
48
|
-
baseFetch?:
|
|
49
|
+
baseFetch?: FetchFn;
|
|
49
50
|
/**
|
|
50
51
|
* Disable the `http.client.request.duration` histogram emission for
|
|
51
52
|
* VTEX calls. The framework's span and structured logs still emit.
|
package/src/utils/sitemap.ts
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
* needs to expose VTEX's existing crawl tree to the public hostname.
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
+
import { type FetchFn, withFetchTimeout } from "@decocms/blocks/sdk/fetchTimeout";
|
|
14
15
|
import { getVtexConfig, vtexFetchResponse, vtexHost } from "../client";
|
|
15
16
|
|
|
16
17
|
export interface SitemapEntry {
|
|
@@ -185,7 +186,7 @@ export interface VtexSitemapProxyConfig {
|
|
|
185
186
|
* Optional fetch override — primarily for tests. Defaults to the
|
|
186
187
|
* platform `fetch`.
|
|
187
188
|
*/
|
|
188
|
-
fetchImpl?:
|
|
189
|
+
fetchImpl?: FetchFn;
|
|
189
190
|
}
|
|
190
191
|
|
|
191
192
|
const DEFAULT_SITEMAP_CACHE_CONTROL = "public, s-maxage=3600, stale-while-revalidate=86400";
|
|
@@ -238,7 +239,7 @@ export function createVtexSitemapProxy(
|
|
|
238
239
|
const environment = config.environment ?? "vtexcommercestable";
|
|
239
240
|
const cacheControl = config.cacheControl ?? DEFAULT_SITEMAP_CACHE_CONTROL;
|
|
240
241
|
const extraSitemaps = config.extraSitemaps ?? [];
|
|
241
|
-
const fetchImpl = config.fetchImpl ??
|
|
242
|
+
const fetchImpl = config.fetchImpl ?? withFetchTimeout();
|
|
242
243
|
|
|
243
244
|
return async (_request: Request, url: URL): Promise<Response | null> => {
|
|
244
245
|
if (!isVtexSitemapPath(url.pathname)) return null;
|