@decocms/apps-vtex 8.1.0-next.0 → 8.1.0-next.2
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/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/utils/constants.d.ts +28 -0
- package/dist/utils/constants.d.ts.map +1 -0
- package/dist/utils/constants.js +17 -0
- package/dist/utils/constants.js.map +1 -0
- package/dist/utils/cookieSanitizer.d.ts +87 -0
- package/dist/utils/cookieSanitizer.d.ts.map +1 -0
- package/dist/utils/cookieSanitizer.js +136 -0
- package/dist/utils/cookieSanitizer.js.map +1 -0
- package/dist/utils/operationRouter.d.ts +25 -0
- package/dist/utils/operationRouter.d.ts.map +1 -0
- package/dist/utils/operationRouter.js +120 -0
- package/dist/utils/operationRouter.js.map +1 -0
- package/dist/utils/types.d.ts +944 -0
- package/dist/utils/types.d.ts.map +1 -0
- package/dist/utils/types.js +25 -0
- package/dist/utils/types.js.map +1 -0
- package/dist/vtexClient.d.ts +173 -0
- package/dist/vtexClient.d.ts.map +1 -0
- package/dist/vtexClient.js +242 -0
- package/dist/vtexClient.js.map +1 -0
- package/package.json +16 -57
- package/src/index.ts +11 -29
- package/src/utils/constants.ts +2 -56
- package/src/utils/cookieSanitizer.ts +59 -59
- package/src/utils/operationRouter.ts +75 -65
- package/src/utils/types.ts +709 -1557
- package/src/vtexClient.ts +358 -347
- package/src/README.md +0 -6
- package/src/__conformance__/upstream.test.ts +0 -158
- package/src/__tests__/client-segment-cookie.test.ts +0 -255
- package/src/__tests__/client-set-cookie-forward.test.ts +0 -257
- package/src/__tests__/schemas.test.ts +0 -71
- package/src/actions/address.ts +0 -250
- package/src/actions/analytics/sendEvent.ts +0 -86
- package/src/actions/auth.ts +0 -333
- package/src/actions/checkout.ts +0 -659
- package/src/actions/index.ts +0 -11
- package/src/actions/masterData.ts +0 -168
- package/src/actions/misc.ts +0 -188
- package/src/actions/newsletter.ts +0 -105
- package/src/actions/orders.ts +0 -34
- package/src/actions/profile.ts +0 -201
- package/src/actions/session.ts +0 -85
- package/src/actions/trigger.ts +0 -43
- package/src/actions/wishlist.ts +0 -114
- package/src/client.ts +0 -724
- package/src/commerceLoaders.ts +0 -267
- package/src/hooks/__tests__/createCart.render.test.ts +0 -114
- package/src/hooks/__tests__/createCart.test.ts +0 -92
- package/src/hooks/__tests__/createUseCart.test.ts +0 -184
- package/src/hooks/__tests__/createUseUser.test.ts +0 -48
- package/src/hooks/__tests__/createUseWishlist.test.ts +0 -87
- package/src/hooks/cartQuery.ts +0 -204
- package/src/hooks/createCart.ts +0 -427
- package/src/hooks/createUseCart.ts +0 -360
- package/src/hooks/createUseUser.ts +0 -153
- package/src/hooks/createUseWishlist.ts +0 -242
- package/src/hooks/index.ts +0 -25
- package/src/hooks/useAutocomplete.ts +0 -83
- package/src/hooks/useCart.ts +0 -243
- package/src/hooks/useUser.ts +0 -78
- package/src/hooks/useWishlist.ts +0 -119
- package/src/invoke.ts +0 -235
- package/src/loaders/ProductDetailsPage.ts +0 -1
- package/src/loaders/ProductList.ts +0 -1
- package/src/loaders/ProductListingPage.ts +0 -1
- package/src/loaders/__tests__/legacyProductList.test.ts +0 -157
- package/src/loaders/address.ts +0 -115
- package/src/loaders/autocomplete.ts +0 -56
- package/src/loaders/brands.ts +0 -44
- package/src/loaders/cart/attachments.ts +0 -53
- package/src/loaders/cart/full.ts +0 -67
- package/src/loaders/cart/gifts.ts +0 -43
- package/src/loaders/cart/orderFormId.ts +0 -31
- package/src/loaders/cart/shipping.test.ts +0 -125
- package/src/loaders/cart/shipping.ts +0 -136
- package/src/loaders/cart/summary.ts +0 -36
- package/src/loaders/cart.ts +0 -52
- package/src/loaders/catalog.ts +0 -163
- package/src/loaders/collections.ts +0 -55
- package/src/loaders/index.ts +0 -20
- package/src/loaders/intelligentSearch/__tests__/productListingPage.test.ts +0 -51
- package/src/loaders/intelligentSearch/productDetailsPage.ts +0 -111
- package/src/loaders/intelligentSearch/productList.ts +0 -170
- package/src/loaders/intelligentSearch/productListingPage.ts +0 -525
- package/src/loaders/intelligentSearch/suggestions.ts +0 -44
- package/src/loaders/legacy/productDetailsPage.ts +0 -1
- package/src/loaders/legacy/productList.ts +0 -1
- package/src/loaders/legacy/relatedProductsLoader.ts +0 -79
- package/src/loaders/legacy.ts +0 -710
- package/src/loaders/logistics.ts +0 -111
- package/src/loaders/minicart.ts +0 -78
- package/src/loaders/navbar.ts +0 -26
- package/src/loaders/orders.ts +0 -92
- package/src/loaders/pageType.ts +0 -68
- package/src/loaders/paths/PDPDefaultPath.ts +0 -51
- package/src/loaders/payment.ts +0 -97
- package/src/loaders/productListFull.ts +0 -157
- package/src/loaders/profile.ts +0 -138
- package/src/loaders/promotion.ts +0 -30
- package/src/loaders/search.ts +0 -124
- package/src/loaders/session.ts +0 -83
- package/src/loaders/user.ts +0 -87
- package/src/loaders/wishlist.ts +0 -89
- package/src/loaders/wishlistProducts.ts +0 -69
- package/src/loaders/workflow/products.ts +0 -62
- package/src/loaders/workflow.ts +0 -316
- package/src/logo.png +0 -0
- package/src/manifest.gen.ts +0 -89
- package/src/middleware.cacheHeaders.test.ts +0 -44
- package/src/middleware.ts +0 -240
- package/src/mod.ts +0 -173
- package/src/registry.ts +0 -9
- package/src/schemas.gen.ts +0 -3191
- package/src/schemas.ts +0 -30
- package/src/types.ts +0 -248
- package/src/utils/__tests__/cartProjection.test.ts +0 -118
- package/src/utils/__tests__/cookieSanitizer.test.ts +0 -162
- package/src/utils/__tests__/fetch.test.ts +0 -80
- package/src/utils/__tests__/fetchCache.test.ts +0 -155
- package/src/utils/__tests__/instrumentedFetch.test.ts +0 -158
- package/src/utils/__tests__/intelligentSearch.test.ts +0 -88
- package/src/utils/__tests__/minicart.test.ts +0 -184
- package/src/utils/__tests__/operationRouter.test.ts +0 -227
- package/src/utils/__tests__/resilience.test.ts +0 -205
- package/src/utils/__tests__/resourceRange.test.ts +0 -32
- package/src/utils/__tests__/simulationCache.test.ts +0 -40
- package/src/utils/__tests__/sitemap.test.ts +0 -185
- package/src/utils/__tests__/slugify.test.ts +0 -31
- package/src/utils/__tests__/storefrontBaseUrl.test.ts +0 -61
- package/src/utils/__tests__/transform.test.ts +0 -1111
- package/src/utils/accountLoaders.ts +0 -203
- package/src/utils/authHelpers.ts +0 -85
- package/src/utils/batch.ts +0 -18
- package/src/utils/buildOfferShelf.test.ts +0 -59
- package/src/utils/cartProjection.ts +0 -96
- package/src/utils/cookies.ts +0 -167
- package/src/utils/enrichment.ts +0 -556
- package/src/utils/fetch.ts +0 -111
- package/src/utils/fetchCache.ts +0 -55
- package/src/utils/index.ts +0 -19
- package/src/utils/instrumentedFetch.ts +0 -98
- package/src/utils/intelligentSearch.ts +0 -96
- package/src/utils/legacy.ts +0 -139
- package/src/utils/minicart.ts +0 -139
- package/src/utils/pickAndOmit.ts +0 -25
- package/src/utils/proxy.ts +0 -495
- package/src/utils/resilience.ts +0 -352
- package/src/utils/resourceRange.ts +0 -10
- package/src/utils/segment.ts +0 -152
- package/src/utils/similars.ts +0 -35
- package/src/utils/simulationCache.ts +0 -73
- package/src/utils/sitemap.ts +0 -283
- package/src/utils/slugCache.ts +0 -28
- package/src/utils/slugify.ts +0 -13
- package/src/utils/transform.ts +0 -1691
- package/src/utils/vtexId.ts +0 -151
- package/src/vtexClient.test.ts +0 -204
- package/tsconfig.json +0 -7
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { slugify } from "../slugify";
|
|
3
|
-
|
|
4
|
-
describe("slugify", () => {
|
|
5
|
-
it("lowercases and removes spaces", () => {
|
|
6
|
-
expect(slugify("Hello World")).toBe("hello-world");
|
|
7
|
-
});
|
|
8
|
-
|
|
9
|
-
it("replaces accented characters", () => {
|
|
10
|
-
expect(slugify("Calçados")).toBe("calcados");
|
|
11
|
-
expect(slugify("São Paulo")).toBe("sao-paulo");
|
|
12
|
-
expect(slugify("Café")).toBe("cafe");
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
it("replaces special characters with hyphens", () => {
|
|
16
|
-
expect(slugify("shoes/running")).toBe("shoes-running");
|
|
17
|
-
expect(slugify("men's wear")).toBe("men-s-wear");
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
it("removes commas", () => {
|
|
21
|
-
expect(slugify("shoes,sandals")).toBe("shoessandals");
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
it("handles already slugified strings", () => {
|
|
25
|
-
expect(slugify("already-slugified")).toBe("already-slugified");
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
it("handles empty string", () => {
|
|
29
|
-
expect(slugify("")).toBe("");
|
|
30
|
-
});
|
|
31
|
-
});
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { RequestContext } from "@decocms/blocks/sdk/requestContext";
|
|
2
|
-
import { beforeEach, describe, expect, it } from "vitest";
|
|
3
|
-
|
|
4
|
-
import { configureVtex, storefrontBaseUrl } from "../../client";
|
|
5
|
-
|
|
6
|
-
const ACCOUNT = { account: "examplestore" } as const;
|
|
7
|
-
|
|
8
|
-
describe("storefrontBaseUrl", () => {
|
|
9
|
-
beforeEach(() => {
|
|
10
|
-
configureVtex({ ...ACCOUNT });
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
it("uses the origin of the request being served", () => {
|
|
14
|
-
configureVtex({ ...ACCOUNT, publicUrl: "https://secure.example.com/" });
|
|
15
|
-
|
|
16
|
-
const origin = RequestContext.run(new Request("https://www.example.com/camisas?page=2"), () =>
|
|
17
|
-
storefrontBaseUrl(),
|
|
18
|
-
);
|
|
19
|
-
|
|
20
|
-
expect(origin).toBe("https://www.example.com");
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
it("never returns the double-scheme origin a full publicUrl used to produce", () => {
|
|
24
|
-
// `https://${publicUrl}` on "https://secure.example.com/" parsed with
|
|
25
|
-
// host "https", so every product URL came out as https://https/<slug>/p.
|
|
26
|
-
configureVtex({ ...ACCOUNT, publicUrl: "https://secure.example.com/" });
|
|
27
|
-
|
|
28
|
-
const origin = storefrontBaseUrl();
|
|
29
|
-
|
|
30
|
-
expect(origin).toBe("https://secure.example.com");
|
|
31
|
-
expect(new URL("/camisa-paris/p", origin).href).toBe("https://secure.example.com/camisa-paris/p");
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
it("accepts a publicUrl stored without a scheme", () => {
|
|
35
|
-
configureVtex({ ...ACCOUNT, publicUrl: "secure.example.com" });
|
|
36
|
-
|
|
37
|
-
expect(storefrontBaseUrl()).toBe("https://secure.example.com");
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
it("falls back to the account host when publicUrl is absent", () => {
|
|
41
|
-
expect(storefrontBaseUrl()).toBe("https://examplestore.vtexcommercestable.com.br");
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
it("honours a configured domain in the account-host fallback", () => {
|
|
45
|
-
configureVtex({ ...ACCOUNT, domain: "com" });
|
|
46
|
-
|
|
47
|
-
expect(storefrontBaseUrl()).toBe("https://examplestore.vtexcommercestable.com");
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
it("falls back to the account host rather than publish an unparseable publicUrl", () => {
|
|
51
|
-
configureVtex({ ...ACCOUNT, publicUrl: "://" });
|
|
52
|
-
|
|
53
|
-
expect(storefrontBaseUrl()).toBe("https://examplestore.vtexcommercestable.com.br");
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
it("returns an origin with no trailing slash", () => {
|
|
57
|
-
configureVtex({ ...ACCOUNT, publicUrl: "https://secure.example.com/" });
|
|
58
|
-
|
|
59
|
-
expect(storefrontBaseUrl()).not.toMatch(/\/$/);
|
|
60
|
-
});
|
|
61
|
-
});
|