@decocms/apps 0.23.3 → 0.25.0
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/commerce/components/Image.tsx +129 -143
- package/commerce/components/JsonLd.tsx +192 -201
- package/commerce/components/Picture.tsx +65 -75
- package/commerce/sdk/analytics.ts +15 -15
- package/commerce/sdk/formatPrice.ts +13 -16
- package/commerce/sdk/url.ts +7 -7
- package/commerce/sdk/useOffer.ts +46 -57
- package/commerce/sdk/useVariantPossibilities.ts +25 -25
- package/commerce/types/commerce.ts +868 -875
- package/commerce/utils/canonical.ts +5 -8
- package/commerce/utils/constants.ts +5 -6
- package/commerce/utils/filters.ts +4 -4
- package/commerce/utils/productToAnalyticsItem.ts +52 -56
- package/commerce/utils/stateByZip.ts +42 -42
- package/package.json +24 -4
- package/shopify/actions/cart/addItems.ts +24 -25
- package/shopify/actions/cart/updateCoupons.ts +19 -20
- package/shopify/actions/cart/updateItems.ts +19 -20
- package/shopify/actions/user/signIn.ts +25 -30
- package/shopify/actions/user/signUp.ts +19 -24
- package/shopify/client.ts +24 -24
- package/shopify/index.ts +20 -18
- package/shopify/init.ts +18 -21
- package/shopify/loaders/ProductDetailsPage.ts +16 -20
- package/shopify/loaders/ProductList.ts +66 -69
- package/shopify/loaders/ProductListingPage.ts +150 -158
- package/shopify/loaders/RelatedProducts.ts +24 -27
- package/shopify/loaders/cart.ts +53 -52
- package/shopify/loaders/shop.ts +22 -27
- package/shopify/loaders/user.ts +27 -32
- package/shopify/utils/admin/admin.ts +33 -34
- package/shopify/utils/admin/queries.ts +2 -2
- package/shopify/utils/cart.ts +18 -14
- package/shopify/utils/cookies.ts +62 -65
- package/shopify/utils/enums.ts +424 -424
- package/shopify/utils/graphql.ts +44 -55
- package/shopify/utils/storefront/queries.ts +24 -29
- package/shopify/utils/storefront/storefront.graphql.gen.ts +55 -55
- package/shopify/utils/transform.ts +370 -376
- package/shopify/utils/types.ts +118 -118
- package/shopify/utils/user.ts +11 -11
- package/shopify/utils/utils.ts +135 -140
- package/vtex/actions/address.ts +86 -86
- package/vtex/actions/auth.ts +14 -27
- package/vtex/actions/checkout.ts +36 -49
- package/vtex/actions/masterData.ts +10 -27
- package/vtex/actions/misc.ts +101 -111
- package/vtex/actions/newsletter.ts +48 -52
- package/vtex/actions/orders.ts +13 -16
- package/vtex/actions/profile.ts +55 -55
- package/vtex/actions/session.ts +36 -35
- package/vtex/actions/trigger.ts +25 -25
- package/vtex/actions/wishlist.ts +51 -53
- package/vtex/client.ts +14 -42
- package/vtex/hooks/index.ts +4 -4
- package/vtex/hooks/useAutocomplete.ts +42 -48
- package/vtex/hooks/useCart.ts +153 -165
- package/vtex/hooks/useUser.ts +40 -40
- package/vtex/hooks/useWishlist.ts +70 -70
- package/vtex/inline-loaders/productDetailsPage.ts +1 -3
- package/vtex/inline-loaders/productList.ts +121 -127
- package/vtex/inline-loaders/productListShelf.ts +159 -0
- package/vtex/inline-loaders/productListingPage.ts +10 -34
- package/vtex/inline-loaders/relatedProducts.ts +1 -3
- package/vtex/inline-loaders/suggestions.ts +36 -39
- package/vtex/inline-loaders/workflowProducts.ts +45 -49
- package/vtex/invoke.ts +159 -194
- package/vtex/loaders/address.ts +49 -54
- package/vtex/loaders/brands.ts +19 -26
- package/vtex/loaders/cart.ts +24 -21
- package/vtex/loaders/catalog.ts +51 -53
- package/vtex/loaders/collections.ts +25 -27
- package/vtex/loaders/legacy.ts +487 -534
- package/vtex/loaders/logistics.ts +33 -37
- package/vtex/loaders/navbar.ts +5 -8
- package/vtex/loaders/orders.ts +28 -39
- package/vtex/loaders/pageType.ts +41 -35
- package/vtex/loaders/payment.ts +27 -37
- package/vtex/loaders/profile.ts +38 -38
- package/vtex/loaders/promotion.ts +5 -8
- package/vtex/loaders/search.ts +56 -59
- package/vtex/loaders/session.ts +22 -30
- package/vtex/loaders/user.ts +39 -41
- package/vtex/loaders/wishlist.ts +35 -35
- package/vtex/loaders/wishlistProducts.ts +3 -15
- package/vtex/loaders/workflow.ts +220 -227
- package/vtex/middleware.ts +116 -119
- package/vtex/types.ts +201 -201
- package/vtex/utils/batch.ts +13 -16
- package/vtex/utils/cookies.ts +76 -80
- package/vtex/utils/enrichment.ts +62 -42
- package/vtex/utils/fetchCache.ts +1 -4
- package/vtex/utils/index.ts +6 -6
- package/vtex/utils/intelligentSearch.ts +48 -57
- package/vtex/utils/legacy.ts +108 -124
- package/vtex/utils/pickAndOmit.ts +15 -20
- package/vtex/utils/proxy.ts +136 -146
- package/vtex/utils/resourceRange.ts +3 -3
- package/vtex/utils/segment.ts +100 -111
- package/vtex/utils/similars.ts +1 -2
- package/vtex/utils/sitemap.ts +91 -91
- package/vtex/utils/slugCache.ts +2 -6
- package/vtex/utils/slugify.ts +9 -9
- package/vtex/utils/transform.ts +1178 -1105
- package/vtex/utils/types.ts +1381 -1381
- package/vtex/utils/vtexId.ts +44 -47
- package/.github/workflows/release.yml +0 -34
- package/.releaserc.json +0 -28
- package/knip.json +0 -19
- package/tsconfig.json +0 -11
|
@@ -1,57 +1,56 @@
|
|
|
1
|
-
|
|
2
1
|
// deno-fmt-ignore-file
|
|
3
2
|
// deno-lint-ignore-file no-explicit-any ban-types ban-unused-ignore
|
|
4
3
|
|
|
5
4
|
export type Maybe<T> = T | null;
|
|
6
5
|
|
|
7
6
|
export type Scalars = {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
7
|
+
ID: { input: string; output: string };
|
|
8
|
+
String: { input: string; output: string };
|
|
9
|
+
Boolean: { input: boolean; output: boolean };
|
|
10
|
+
Int: { input: number; output: number };
|
|
11
|
+
Float: { input: number; output: number };
|
|
12
|
+
ARN: { input: any; output: any };
|
|
13
|
+
Date: { input: any; output: any };
|
|
14
|
+
DateTime: { input: any; output: any };
|
|
15
|
+
Decimal: { input: any; output: any };
|
|
16
|
+
FormattedString: { input: any; output: any };
|
|
17
|
+
HTML: { input: any; output: any };
|
|
18
|
+
JSON: { input: any; output: any };
|
|
19
|
+
Money: { input: any; output: any };
|
|
20
|
+
StorefrontID: { input: any; output: any };
|
|
21
|
+
URL: { input: any; output: any };
|
|
22
|
+
UnsignedInt64: { input: any; output: any };
|
|
23
|
+
UtcOffset: { input: any; output: any };
|
|
25
24
|
};
|
|
26
25
|
|
|
27
26
|
/** Return type for `draftOrderCalculate` mutation. */
|
|
28
27
|
export type DraftOrderCalculatePayload = {
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
/** The calculated properties for a draft order. */
|
|
29
|
+
calculatedDraftOrder?: Maybe<CalculatedDraftOrder>;
|
|
31
30
|
};
|
|
32
31
|
|
|
33
32
|
export interface CalculatedDraftOrder {
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
/** The available shipping rates for the draft order. Requires a customer with a valid shipping address and at least one line item. */
|
|
34
|
+
availableShippingRates: Array<ShippingRate>;
|
|
36
35
|
}
|
|
37
36
|
|
|
38
37
|
export type ShippingRate = {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
38
|
+
/** Human-readable unique identifier for this shipping rate. */
|
|
39
|
+
handle: Scalars["String"]["output"];
|
|
40
|
+
/** The cost associated with the shipping rate. */
|
|
41
|
+
price: MoneyV2;
|
|
42
|
+
/** The name of the shipping rate. */
|
|
43
|
+
title: Scalars["String"]["output"];
|
|
45
44
|
};
|
|
46
45
|
|
|
47
46
|
export type MoneyV2 = {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
47
|
+
/** Decimal money amount. */
|
|
48
|
+
amount: Scalars["Decimal"]["output"];
|
|
49
|
+
/** Currency of the money. */
|
|
50
|
+
currencyCode: CurrencyCode;
|
|
52
51
|
};
|
|
53
52
|
|
|
54
53
|
export enum CurrencyCode {
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
CAD = "CAD",
|
|
55
|
+
Usd = "USD",
|
|
57
56
|
}
|
|
@@ -4,11 +4,11 @@ import { gql } from "../graphql";
|
|
|
4
4
|
// because it does not accept generating an empty schema
|
|
5
5
|
// TODO: Remove this once you add any other query
|
|
6
6
|
export const Noop = {
|
|
7
|
-
|
|
7
|
+
query: gql`query Noop { app(id: "") { description } }`,
|
|
8
8
|
};
|
|
9
9
|
|
|
10
10
|
export const draftOrderCalculate = {
|
|
11
|
-
|
|
11
|
+
query: gql` mutation draftOrderCalculate($input: DraftOrderInput!) {
|
|
12
12
|
calculatedDraftOrder: draftOrderCalculate(input: $input) {
|
|
13
13
|
calculatedDraftOrder {
|
|
14
14
|
availableShippingRates {
|
package/shopify/utils/cart.ts
CHANGED
|
@@ -6,23 +6,27 @@ const SHOPIFY_PREFIX = "gid://shopify/Cart/";
|
|
|
6
6
|
const ONE_WEEK_MS = 7 * 24 * 3600 * 1_000;
|
|
7
7
|
|
|
8
8
|
export const getCartCookie = (headers: Headers): string | null => {
|
|
9
|
-
|
|
9
|
+
const cookies = getCookies(headers);
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
if (!cookies[CART_COOKIE]) {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
try {
|
|
16
|
+
return decodeURIComponent(`${SHOPIFY_PREFIX}${cookies[CART_COOKIE]}`);
|
|
17
|
+
} catch {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
16
20
|
};
|
|
17
21
|
|
|
18
22
|
export const setCartCookie = (headers: Headers, cartId: string) => {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
setCookie(headers, {
|
|
24
|
+
name: CART_COOKIE,
|
|
25
|
+
value: cartId.replace(SHOPIFY_PREFIX, ""),
|
|
26
|
+
path: "/",
|
|
27
|
+
expires: new Date(Date.now() + ONE_WEEK_MS),
|
|
28
|
+
httpOnly: true,
|
|
29
|
+
secure: true,
|
|
30
|
+
sameSite: "Lax",
|
|
31
|
+
});
|
|
28
32
|
};
|
package/shopify/utils/cookies.ts
CHANGED
|
@@ -4,82 +4,79 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
export function getCookies(headers: Headers): Record<string, string> {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
7
|
+
const cookieHeader = headers.get("cookie") || "";
|
|
8
|
+
const cookies: Record<string, string> = {};
|
|
9
|
+
for (const pair of cookieHeader.split(";")) {
|
|
10
|
+
const [key, ...rest] = pair.trim().split("=");
|
|
11
|
+
if (key) {
|
|
12
|
+
cookies[key.trim()] = decodeURIComponent(rest.join("=").trim());
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return cookies;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
export function setCookie(
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
19
|
+
headers: Headers,
|
|
20
|
+
options: {
|
|
21
|
+
name: string;
|
|
22
|
+
value: string;
|
|
23
|
+
path?: string;
|
|
24
|
+
expires?: Date;
|
|
25
|
+
maxAge?: number;
|
|
26
|
+
httpOnly?: boolean;
|
|
27
|
+
secure?: boolean;
|
|
28
|
+
sameSite?: "Strict" | "Lax" | "None";
|
|
29
|
+
},
|
|
30
30
|
) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
31
|
+
const parts = [`${options.name}=${encodeURIComponent(options.value)}`];
|
|
32
|
+
if (options.path) parts.push(`Path=${options.path}`);
|
|
33
|
+
if (options.expires) parts.push(`Expires=${options.expires.toUTCString()}`);
|
|
34
|
+
if (options.maxAge !== undefined) parts.push(`Max-Age=${options.maxAge}`);
|
|
35
|
+
if (options.httpOnly) parts.push("HttpOnly");
|
|
36
|
+
if (options.secure) parts.push("Secure");
|
|
37
|
+
if (options.sameSite) parts.push(`SameSite=${options.sameSite}`);
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
headers.append("Set-Cookie", parts.join("; "));
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
export interface Cookie {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
43
|
+
name: string;
|
|
44
|
+
value: string;
|
|
45
|
+
path?: string;
|
|
46
|
+
expires?: Date;
|
|
47
|
+
maxAge?: number;
|
|
48
|
+
httpOnly?: boolean;
|
|
49
|
+
secure?: boolean;
|
|
50
|
+
sameSite?: "Strict" | "Lax" | "None";
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
export function getSetCookies(headers: Headers): Cookie[] {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
54
|
+
const cookies: Cookie[] = [];
|
|
55
|
+
const setCookieHeaders = headers.getSetCookie?.() ?? [];
|
|
56
|
+
for (const header of setCookieHeaders) {
|
|
57
|
+
const parts = header.split(";").map((p) => p.trim());
|
|
58
|
+
const [nameValue, ...attrs] = parts;
|
|
59
|
+
const [name, ...rest] = nameValue.split("=");
|
|
60
|
+
const value = rest.join("=");
|
|
61
|
+
const cookie: Cookie = { name: name.trim(), value };
|
|
62
|
+
for (const attr of attrs) {
|
|
63
|
+
const [k, v] = attr.split("=");
|
|
64
|
+
const key = k.trim().toLowerCase();
|
|
65
|
+
if (key === "path") cookie.path = v?.trim();
|
|
66
|
+
if (key === "httponly") cookie.httpOnly = true;
|
|
67
|
+
if (key === "secure") cookie.secure = true;
|
|
68
|
+
if (key === "samesite") cookie.sameSite = v?.trim() as any;
|
|
69
|
+
if (key === "max-age") cookie.maxAge = Number(v?.trim());
|
|
70
|
+
}
|
|
71
|
+
cookies.push(cookie);
|
|
72
|
+
}
|
|
73
|
+
return cookies;
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
export function debounce<T extends (...args: any[]) => void>(
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
)
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
clearTimeout(timer);
|
|
83
|
-
timer = setTimeout(() => fn(...args), delay);
|
|
84
|
-
}) as T;
|
|
76
|
+
export function debounce<T extends (...args: any[]) => void>(fn: T, delay: number): T {
|
|
77
|
+
let timer: ReturnType<typeof setTimeout>;
|
|
78
|
+
return ((...args: any[]) => {
|
|
79
|
+
clearTimeout(timer);
|
|
80
|
+
timer = setTimeout(() => fn(...args), delay);
|
|
81
|
+
}) as T;
|
|
85
82
|
}
|