@gfed-medusa/sf-lib-common 3.7.4 → 3.8.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/dist/components/breadcrumbs/index.d.ts +2 -2
- package/dist/components/cart-mismatch-banner/index.d.ts +2 -2
- package/dist/components/delete-button/index.d.ts +2 -2
- package/dist/components/device-id-setter/index.d.ts +5 -0
- package/dist/components/device-id-setter/index.d.ts.map +1 -0
- package/dist/components/device-id-setter/index.js +16 -0
- package/dist/components/device-id-setter/index.js.map +1 -0
- package/dist/components/error-message/index.d.ts +2 -2
- package/dist/components/error-message/index.d.ts.map +1 -1
- package/dist/components/free-shipping-price-nudge/index.d.ts +2 -2
- package/dist/components/free-shipping-price-nudge/index.d.ts.map +1 -1
- package/dist/components/interactive-link/index.d.ts +2 -2
- package/dist/components/interactive-link/index.d.ts.map +1 -1
- package/dist/components/line-item-options/index.d.ts +2 -2
- package/dist/components/line-item-options/index.d.ts.map +1 -1
- package/dist/components/localized-client-link/index.d.ts +2 -2
- package/dist/components/modal/index.d.ts +2 -2
- package/dist/components/modal/index.d.ts.map +1 -1
- package/dist/components/personalized-content/components/hero-banner.d.ts +31 -0
- package/dist/components/personalized-content/components/hero-banner.d.ts.map +1 -0
- package/dist/components/personalized-content/components/hero-banner.js +85 -0
- package/dist/components/personalized-content/components/hero-banner.js.map +1 -0
- package/dist/components/personalized-content/components/index.d.ts +2 -0
- package/dist/components/personalized-content/components/index.js +3 -0
- package/dist/components/preview-price/index.d.ts +2 -2
- package/dist/components/product-card/index.d.ts +2 -2
- package/dist/components/product-preview/index.d.ts +2 -4
- package/dist/components/product-preview/index.d.ts.map +1 -1
- package/dist/components/product-preview/index.js +1 -2
- package/dist/components/product-preview/index.js.map +1 -1
- package/dist/components/submit-button/index.d.ts +2 -2
- package/dist/components/thumbnail/index.d.ts +0 -1
- package/dist/components/thumbnail/index.d.ts.map +1 -1
- package/dist/components/thumbnail/index.js +9 -11
- package/dist/components/thumbnail/index.js.map +1 -1
- package/dist/lib/context/apollo-context.d.ts +2 -2
- package/dist/lib/context/modal-context.d.ts +2 -2
- package/dist/lib/context/modal-context.d.ts.map +1 -1
- package/dist/lib/data/context.d.ts +2 -2
- package/dist/lib/data/context.d.ts.map +1 -1
- package/dist/lib/data/personalization.d.ts +51 -0
- package/dist/lib/data/personalization.d.ts.map +1 -0
- package/dist/lib/data/personalization.js +77 -0
- package/dist/lib/data/personalization.js.map +1 -0
- package/dist/lib/gql/apollo-client.d.ts.map +1 -1
- package/dist/lib/gql/apollo-client.js +6 -2
- package/dist/lib/gql/apollo-client.js.map +1 -1
- package/dist/lib/gql/fragments/cart.d.ts +9 -9
- package/dist/lib/gql/fragments/customer.d.ts +3 -3
- package/dist/lib/gql/fragments/product.d.ts +8 -8
- package/dist/lib/gql/mutations/cart.d.ts +6 -6
- package/dist/lib/gql/queries/cart-summary.d.ts +2 -2
- package/dist/lib/gql/queries/cart-summary.js +1 -1
- package/dist/lib/gql/queries/cart-summary.js.map +1 -1
- package/dist/lib/gql/queries/cart-total.d.ts +7 -0
- package/dist/lib/gql/queries/cart-total.d.ts.map +1 -0
- package/dist/lib/gql/queries/cart-total.js +14 -0
- package/dist/lib/gql/queries/cart-total.js.map +1 -0
- package/dist/lib/gql/queries/cart.d.ts +2 -2
- package/dist/lib/gql/queries/cart.js +1 -1
- package/dist/lib/gql/queries/cart.js.map +1 -1
- package/dist/lib/gql/queries/collections.d.ts +3 -3
- package/dist/lib/gql/queries/customer.d.ts +2 -2
- package/dist/lib/gql/queries/footer.d.ts +3 -3
- package/dist/lib/gql/queries/home-banner.d.ts +2 -2
- package/dist/lib/gql/queries/order.d.ts +4 -4
- package/dist/lib/gql/queries/order.d.ts.map +1 -1
- package/dist/lib/gql/queries/order.js +5 -0
- package/dist/lib/gql/queries/order.js.map +1 -1
- package/dist/lib/gql/queries/product-personalization.d.ts +7 -0
- package/dist/lib/gql/queries/product-personalization.d.ts.map +1 -0
- package/dist/lib/gql/queries/product-personalization.js +22 -0
- package/dist/lib/gql/queries/product-personalization.js.map +1 -0
- package/dist/lib/gql/queries/product.d.ts +2 -2
- package/dist/lib/gql/queries/regions.d.ts +3 -3
- package/dist/lib/hooks/use-apollo.d.ts +2 -2
- package/dist/lib/hooks/use-time-on-page.d.ts +13 -0
- package/dist/lib/hooks/use-time-on-page.d.ts.map +1 -0
- package/dist/lib/hooks/use-time-on-page.js +46 -0
- package/dist/lib/hooks/use-time-on-page.js.map +1 -0
- package/dist/lib/personalization/behavior-tracker.d.ts +1 -5
- package/dist/lib/personalization/behavior-tracker.d.ts.map +1 -1
- package/dist/lib/personalization/behavior-tracker.js +1 -18
- package/dist/lib/personalization/behavior-tracker.js.map +1 -1
- package/dist/lib/personalization/client-signal.d.ts +26 -0
- package/dist/lib/personalization/client-signal.d.ts.map +1 -0
- package/dist/lib/personalization/client-signal.js +105 -0
- package/dist/lib/personalization/client-signal.js.map +1 -0
- package/dist/lib/personalization/config.d.ts +2 -6
- package/dist/lib/personalization/config.d.ts.map +1 -1
- package/dist/lib/personalization/config.js +2 -16
- package/dist/lib/personalization/config.js.map +1 -1
- package/dist/lib/personalization/device-id.d.ts +5 -0
- package/dist/lib/personalization/device-id.d.ts.map +1 -0
- package/dist/lib/personalization/device-id.js +24 -0
- package/dist/lib/personalization/device-id.js.map +1 -0
- package/dist/lib/personalization/personalization-gql.d.ts +9 -0
- package/dist/lib/personalization/personalization-gql.d.ts.map +1 -0
- package/dist/lib/personalization/personalization-gql.js +42 -0
- package/dist/lib/personalization/personalization-gql.js.map +1 -0
- package/dist/lib/utils/imagekit.d.ts +2 -2
- package/dist/lib/utils/imagekit.js +1 -1
- package/dist/lib/utils/imagekit.js.map +1 -1
- package/dist/types/graphql.d.ts +247 -5
- package/dist/types/graphql.d.ts.map +1 -1
- package/dist/types/graphql.js +410 -3
- package/dist/types/graphql.js.map +1 -1
- package/package.json +1 -1
- package/dist/lib/data/contextual-banner.d.ts +0 -15
- package/dist/lib/data/contextual-banner.d.ts.map +0 -1
- package/dist/lib/data/contextual-banner.js +0 -19
- package/dist/lib/data/contextual-banner.js.map +0 -1
- package/dist/lib/gql/queries/contextual-banner.d.ts +0 -7
- package/dist/lib/gql/queries/contextual-banner.d.ts.map +0 -1
- package/dist/lib/gql/queries/contextual-banner.js +0 -21
- package/dist/lib/gql/queries/contextual-banner.js.map +0 -1
- package/dist/lib/personalization/user-profile.d.ts +0 -15
- package/dist/lib/personalization/user-profile.d.ts.map +0 -1
- package/dist/lib/personalization/user-profile.js +0 -47
- package/dist/lib/personalization/user-profile.js.map +0 -1
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { StorefrontContext } from "./context.js";
|
|
2
|
+
|
|
3
|
+
//#region src/lib/data/personalization.d.ts
|
|
4
|
+
declare function getDeviceIdFromCookieHeader(cookieHeader?: string): string;
|
|
5
|
+
declare function sendSignal(type: string, ctx: StorefrontContext, payload?: Record<string, unknown>, url?: string, userId?: string): Promise<boolean>;
|
|
6
|
+
declare function sendPageViewSignal(surface: string, ctx: StorefrontContext, payload?: Record<string, unknown>, userId?: string): Promise<boolean>;
|
|
7
|
+
interface PersonalizedComponent {
|
|
8
|
+
component: string;
|
|
9
|
+
contentId: string | null;
|
|
10
|
+
propsOverrides: Record<string, unknown>;
|
|
11
|
+
priority: number;
|
|
12
|
+
reasoning: string;
|
|
13
|
+
score: number;
|
|
14
|
+
}
|
|
15
|
+
interface PersonalizationReasoning {
|
|
16
|
+
intent: string;
|
|
17
|
+
confidence: number;
|
|
18
|
+
factors: string[];
|
|
19
|
+
modelVersion: string;
|
|
20
|
+
}
|
|
21
|
+
interface PersonalizationResult {
|
|
22
|
+
components: PersonalizedComponent[];
|
|
23
|
+
reasoning: PersonalizationReasoning;
|
|
24
|
+
cacheKey: string;
|
|
25
|
+
servedAt: string;
|
|
26
|
+
}
|
|
27
|
+
declare function getPersonalization(surface: string, page: string, deviceId: string, ctx: StorefrontContext, context?: {
|
|
28
|
+
productId?: string;
|
|
29
|
+
cartValue?: number;
|
|
30
|
+
category?: string;
|
|
31
|
+
searchQuery?: string;
|
|
32
|
+
}, userId?: string): Promise<PersonalizationResult | null>;
|
|
33
|
+
interface ConversionInput {
|
|
34
|
+
deviceId: string;
|
|
35
|
+
userId?: string;
|
|
36
|
+
checkoutSignalId?: string;
|
|
37
|
+
orderId: string;
|
|
38
|
+
amount: number;
|
|
39
|
+
currency: string;
|
|
40
|
+
items?: Array<{
|
|
41
|
+
productId: string;
|
|
42
|
+
variantId?: string;
|
|
43
|
+
quantity: number;
|
|
44
|
+
price: number;
|
|
45
|
+
category?: string;
|
|
46
|
+
}>;
|
|
47
|
+
}
|
|
48
|
+
declare function submitConversion(input: ConversionInput, ctx: StorefrontContext): Promise<boolean>;
|
|
49
|
+
//#endregion
|
|
50
|
+
export { PersonalizationReasoning, PersonalizationResult, PersonalizedComponent, getDeviceIdFromCookieHeader, getPersonalization, sendPageViewSignal, sendSignal, submitConversion };
|
|
51
|
+
//# sourceMappingURL=personalization.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"personalization.d.ts","names":[],"sources":["../../../src/lib/data/personalization.ts"],"sourcesContent":[],"mappings":";;;iBAWgB,2BAAA;iBAMM,UAAA,oBAEf,6BACK,yDAGT;AAZa,iBA0CA,kBAAA,CA1C2B,OAAA,EAAA,MAAA,EAAA,GAAA,EA4CpC,iBA5CoC,EAAA,OAAA,CAAA,EA6C/B,MA7C+B,CAAA,MAAA,EAAA,OAAA,CAAA,EAAA,MAAA,CAAA,EAAA,MAAA,CAAA,EA+CxC,OA/CwC,CAAA,OAAA,CAAA;AAMrB,UA6CL,qBAAA,CA7Ce;EAEzB,SAAA,EAAA,MAAA;EACK,SAAA,EAAA,MAAA,GAAA,IAAA;EAGT,cAAA,EA0Ce,MA1Cf,CAAA,MAAA,EAAA,OAAA,CAAA;EAAO,QAAA,EAAA,MAAA;EA8BM,SAAA,EAAA,MAAA;EAET,KAAA,EAAA,MAAA;;AAGJ,UAac,wBAAA,CAbd;EAAO,MAAA,EAAA,MAAA;EAIO,UAAA,EAAA,MAAA;EASA,OAAA,EAAA,MAAA,EAAA;EAOA,YAAA,EAAA,MAAA;AAwBjB;AAIO,UA5BU,qBAAA,CA4BV;EAQI,UAAA,EAnCG,qBAmCH,EAAA;EAAR,SAAA,EAlCU,wBAkCV;EAAO,QAAA,EAAA,MAAA;EA6BA,QAAA,EAAA,MAAA;AAUV;AACS,iBApDa,kBAAA,CAoDb,OAAA,EAAA,MAAA,EAAA,IAAA,EAAA,MAAA,EAAA,QAAA,EAAA,MAAA,EAAA,GAAA,EAhDF,iBAgDE,EAAA,QAAA,EAAA;EACF,SAAA,CAAA,EAAA,MAAA;EACJ,SAAA,CAAA,EAAA,MAAA;EAAO,QAAA,CAAA,EAAA,MAAA;;qBA1CP,QAAQ;UA6BD,eAAA;;;;;;;UAOA;;;;;;;;iBAGY,gBAAA,QACb,sBACF,oBACJ"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { createServerApolloClient, graphqlFetch, graphqlMutation } from "../gql/apollo-client.js";
|
|
2
|
+
import { PERSONALIZE_QUERY, SEND_SIGNAL_MUTATION, SUBMIT_CONVERSION_MUTATION } from "../personalization/personalization-gql.js";
|
|
3
|
+
|
|
4
|
+
//#region src/lib/data/personalization.ts
|
|
5
|
+
const DEVICE_ID_COOKIE = "_jg_device_id";
|
|
6
|
+
function getDeviceIdFromCookieHeader(cookieHeader) {
|
|
7
|
+
if (!cookieHeader) return "";
|
|
8
|
+
const match = cookieHeader.match(/* @__PURE__ */ new RegExp(`${DEVICE_ID_COOKIE}=([^;]+)`));
|
|
9
|
+
return match ? decodeURIComponent(match[1] ?? "") : "";
|
|
10
|
+
}
|
|
11
|
+
async function sendSignal(type, ctx, payload, url, userId) {
|
|
12
|
+
const deviceId = getDeviceIdFromCookieHeader(ctx.cookieHeader);
|
|
13
|
+
if (!deviceId) return false;
|
|
14
|
+
const apolloClient = createServerApolloClient(ctx.cookieHeader);
|
|
15
|
+
try {
|
|
16
|
+
await graphqlMutation({
|
|
17
|
+
mutation: SEND_SIGNAL_MUTATION,
|
|
18
|
+
variables: { input: {
|
|
19
|
+
deviceId,
|
|
20
|
+
...userId ? { userId } : {},
|
|
21
|
+
type,
|
|
22
|
+
payload: payload ?? {},
|
|
23
|
+
url: url ?? "",
|
|
24
|
+
timestamp: Date.now()
|
|
25
|
+
} }
|
|
26
|
+
}, apolloClient);
|
|
27
|
+
return true;
|
|
28
|
+
} catch (error) {
|
|
29
|
+
console.warn("[sendSignal] Failed to send signal:", type, error);
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
function sendPageViewSignal(surface, ctx, payload, userId) {
|
|
34
|
+
return sendSignal("PAGE_VIEW", ctx, {
|
|
35
|
+
...payload,
|
|
36
|
+
surface
|
|
37
|
+
}, void 0, userId);
|
|
38
|
+
}
|
|
39
|
+
async function getPersonalization(surface, page, deviceId, ctx, context, userId) {
|
|
40
|
+
if (!deviceId) return null;
|
|
41
|
+
const apolloClient = createServerApolloClient(ctx.cookieHeader);
|
|
42
|
+
try {
|
|
43
|
+
return (await graphqlFetch({
|
|
44
|
+
query: PERSONALIZE_QUERY,
|
|
45
|
+
variables: {
|
|
46
|
+
input: {
|
|
47
|
+
surface,
|
|
48
|
+
page,
|
|
49
|
+
...context
|
|
50
|
+
},
|
|
51
|
+
deviceId,
|
|
52
|
+
...userId ? { userId } : {}
|
|
53
|
+
}
|
|
54
|
+
}, apolloClient))?.personalize ?? null;
|
|
55
|
+
} catch (error) {
|
|
56
|
+
console.error("[getPersonalization]", error);
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
async function submitConversion(input, ctx) {
|
|
61
|
+
if (!input.deviceId) return false;
|
|
62
|
+
const apolloClient = createServerApolloClient(ctx.cookieHeader);
|
|
63
|
+
try {
|
|
64
|
+
await graphqlMutation({
|
|
65
|
+
mutation: SUBMIT_CONVERSION_MUTATION,
|
|
66
|
+
variables: { input }
|
|
67
|
+
}, apolloClient);
|
|
68
|
+
return true;
|
|
69
|
+
} catch (error) {
|
|
70
|
+
console.error("[submitConversion] Failed:", error);
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
//#endregion
|
|
76
|
+
export { getDeviceIdFromCookieHeader, getPersonalization, sendPageViewSignal, sendSignal, submitConversion };
|
|
77
|
+
//# sourceMappingURL=personalization.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"personalization.js","names":[],"sources":["../../../src/lib/data/personalization.ts"],"sourcesContent":["import { createServerApolloClient, graphqlFetch, graphqlMutation } from '@/lib/gql/apollo-client';\n\nimport {\n PERSONALIZE_QUERY,\n SEND_SIGNAL_MUTATION,\n SUBMIT_CONVERSION_MUTATION,\n} from '@/lib/personalization/personalization-gql';\nimport type { StorefrontContext } from './context';\n\nconst DEVICE_ID_COOKIE = '_jg_device_id';\n\nexport function getDeviceIdFromCookieHeader(cookieHeader?: string): string {\n if (!cookieHeader) return '';\n const match = cookieHeader.match(new RegExp(`${DEVICE_ID_COOKIE}=([^;]+)`));\n return match ? decodeURIComponent(match[1] ?? '') : '';\n}\n\nexport async function sendSignal(\n type: string,\n ctx: StorefrontContext,\n payload?: Record<string, unknown>,\n url?: string,\n userId?: string\n): Promise<boolean> {\n const deviceId = getDeviceIdFromCookieHeader(ctx.cookieHeader);\n if (!deviceId) return false;\n\n const apolloClient = createServerApolloClient(ctx.cookieHeader);\n\n try {\n await graphqlMutation<Record<string, unknown>, { input: Record<string, unknown> }>(\n {\n mutation: SEND_SIGNAL_MUTATION,\n variables: {\n input: {\n deviceId,\n ...(userId ? { userId } : {}),\n type,\n payload: payload ?? {},\n url: url ?? '',\n timestamp: Date.now(),\n },\n },\n },\n apolloClient\n );\n return true;\n } catch (error) {\n console.warn('[sendSignal] Failed to send signal:', type, error);\n return false;\n }\n}\n\nexport function sendPageViewSignal(\n surface: string,\n ctx: StorefrontContext,\n payload?: Record<string, unknown>,\n userId?: string\n): Promise<boolean> {\n return sendSignal('PAGE_VIEW', ctx, { ...payload, surface }, undefined, userId);\n}\n\nexport interface PersonalizedComponent {\n component: string;\n contentId: string | null;\n propsOverrides: Record<string, unknown>;\n priority: number;\n reasoning: string;\n score: number;\n}\n\nexport interface PersonalizationReasoning {\n intent: string;\n confidence: number;\n factors: string[];\n modelVersion: string;\n}\n\nexport interface PersonalizationResult {\n components: PersonalizedComponent[];\n reasoning: PersonalizationReasoning;\n cacheKey: string;\n servedAt: string;\n}\n\ntype PersonalizeQueryResult = {\n personalize: PersonalizationResult;\n};\n\ntype PersonalizeQueryVariables = {\n input: {\n surface: string;\n page: string;\n productId?: string;\n cartValue?: number;\n category?: string;\n searchQuery?: string;\n };\n deviceId: string;\n userId?: string;\n};\n\nexport async function getPersonalization(\n surface: string,\n page: string,\n deviceId: string,\n ctx: StorefrontContext,\n context?: {\n productId?: string;\n cartValue?: number;\n category?: string;\n searchQuery?: string;\n },\n userId?: string\n): Promise<PersonalizationResult | null> {\n if (!deviceId) return null;\n\n const apolloClient = createServerApolloClient(ctx.cookieHeader);\n\n try {\n const data = await graphqlFetch<PersonalizeQueryResult, PersonalizeQueryVariables>(\n {\n query: PERSONALIZE_QUERY,\n variables: {\n input: {\n surface,\n page,\n ...context,\n },\n deviceId,\n ...(userId ? { userId } : {}),\n },\n },\n apolloClient\n );\n\n return data?.personalize ?? null;\n } catch (error) {\n console.error('[getPersonalization]', error);\n return null;\n }\n}\n\ninterface ConversionInput {\n deviceId: string;\n userId?: string;\n checkoutSignalId?: string;\n orderId: string;\n amount: number;\n currency: string;\n items?: Array<{ productId: string; variantId?: string; quantity: number; price: number; category?: string }>;\n}\n\nexport async function submitConversion(\n input: ConversionInput,\n ctx: StorefrontContext\n): Promise<boolean> {\n if (!input.deviceId) return false;\n\n const apolloClient = createServerApolloClient(ctx.cookieHeader);\n\n try {\n await graphqlMutation<Record<string, boolean>, { input: ConversionInput }>(\n {\n mutation: SUBMIT_CONVERSION_MUTATION,\n variables: { input },\n },\n apolloClient\n );\n return true;\n } catch (error) {\n console.error('[submitConversion] Failed:', error);\n return false;\n }\n}\n"],"mappings":";;;;AASA,MAAM,mBAAmB;AAEzB,SAAgB,4BAA4B,cAA+B;AACzE,KAAI,CAAC,aAAc,QAAO;CAC1B,MAAM,QAAQ,aAAa,sBAAM,IAAI,OAAO,GAAG,iBAAiB,UAAU,CAAC;AAC3E,QAAO,QAAQ,mBAAmB,MAAM,MAAM,GAAG,GAAG;;AAGtD,eAAsB,WACpB,MACA,KACA,SACA,KACA,QACkB;CAClB,MAAM,WAAW,4BAA4B,IAAI,aAAa;AAC9D,KAAI,CAAC,SAAU,QAAO;CAEtB,MAAM,eAAe,yBAAyB,IAAI,aAAa;AAE/D,KAAI;AACF,QAAM,gBACJ;GACE,UAAU;GACV,WAAW,EACT,OAAO;IACL;IACA,GAAI,SAAS,EAAE,QAAQ,GAAG,EAAE;IAC5B;IACA,SAAS,WAAW,EAAE;IACtB,KAAK,OAAO;IACZ,WAAW,KAAK,KAAK;IACtB,EACF;GACF,EACD,aACD;AACD,SAAO;UACA,OAAO;AACd,UAAQ,KAAK,uCAAuC,MAAM,MAAM;AAChE,SAAO;;;AAIX,SAAgB,mBACd,SACA,KACA,SACA,QACkB;AAClB,QAAO,WAAW,aAAa,KAAK;EAAE,GAAG;EAAS;EAAS,EAAE,QAAW,OAAO;;AA2CjF,eAAsB,mBACpB,SACA,MACA,UACA,KACA,SAMA,QACuC;AACvC,KAAI,CAAC,SAAU,QAAO;CAEtB,MAAM,eAAe,yBAAyB,IAAI,aAAa;AAE/D,KAAI;AAiBF,UAhBa,MAAM,aACjB;GACE,OAAO;GACP,WAAW;IACT,OAAO;KACL;KACA;KACA,GAAG;KACJ;IACD;IACA,GAAI,SAAS,EAAE,QAAQ,GAAG,EAAE;IAC7B;GACF,EACD,aACD,GAEY,eAAe;UACrB,OAAO;AACd,UAAQ,MAAM,wBAAwB,MAAM;AAC5C,SAAO;;;AAcX,eAAsB,iBACpB,OACA,KACkB;AAClB,KAAI,CAAC,MAAM,SAAU,QAAO;CAE5B,MAAM,eAAe,yBAAyB,IAAI,aAAa;AAE/D,KAAI;AACF,QAAM,gBACJ;GACE,UAAU;GACV,WAAW,EAAE,OAAO;GACrB,EACD,aACD;AACD,SAAO;UACA,OAAO;AACd,UAAQ,MAAM,8BAA8B,MAAM;AAClD,SAAO"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apollo-client.d.ts","names":[],"sources":["../../../src/lib/gql/apollo-client.ts"],"sourcesContent":[],"mappings":";;;;cA2BM,cAAY;;AAnBM;AAmCxB;
|
|
1
|
+
{"version":3,"file":"apollo-client.d.ts","names":[],"sources":["../../../src/lib/gql/apollo-client.ts"],"sourcesContent":[],"mappings":";;;;cA2BM,cAAY;;AAnBM;AAmCxB;AAqCA;AASA;;AAIqC,iBAlDrB,wBAAA,CAkDqB,YAAA,CAAA,EAAA,MAAA,CAAA,EAlDyB,YAkDzB;AAAS,iBAb9B,gBAAA,CAa8B,GAAA,CAAA,EAbR,eAaQ,GAAA,IAAA,CAAA,EAbqB,YAarB;AAAnC,iBAJW,YAIE,CAAA,OAAA,EAAA,mBAFH,kBAEG,CAAA,CAAA,OAAA,EAAb,YAAA,CAAa,YAAA,CAAa,OAAb,EAAsB,UAAtB,CAAA,EAAA,oBAAA,CAAA,EACC,YADD,CAAA,EAErB,OAFqB,CAEb,OAFa,GAAA,SAAA,CAAA;AACC,iBAgBH,eAhBG,CAAA,OAAA,EAAA,mBAkBJ,kBAlBI,CAAA,CAAA,OAAA,EAoBd,YAAA,CAAa,aApBC,CAoBa,OApBb,EAoBsB,UApBtB,CAAA,EAAA,oBAAA,CAAA,EAqBA,YArBA,CAAA,EAsBtB,OAtBsB,CAsBd,OAtBc,GAAA,SAAA,CAAA"}
|
|
@@ -24,11 +24,15 @@ const apolloClient = new ApolloClient({
|
|
|
24
24
|
* @returns Server-side Apollo client
|
|
25
25
|
*/
|
|
26
26
|
function createServerApolloClient(cookieHeader) {
|
|
27
|
+
const bffApiKey = process.env.BFF_API_KEY;
|
|
27
28
|
return new ApolloClient({
|
|
28
29
|
link: new ApolloLink((operation, forward) => {
|
|
29
|
-
|
|
30
|
+
const headers = {};
|
|
31
|
+
if (cookieHeader) headers.Cookie = cookieHeader;
|
|
32
|
+
if (bffApiKey) headers["x-bff-api-key"] = bffApiKey;
|
|
33
|
+
if (Object.keys(headers).length > 0) operation.setContext({
|
|
30
34
|
http: { includeCredentials: true },
|
|
31
|
-
headers
|
|
35
|
+
headers
|
|
32
36
|
});
|
|
33
37
|
return forward(operation);
|
|
34
38
|
}).concat(httpLink),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apollo-client.js","names":["error: any"],"sources":["../../../src/lib/gql/apollo-client.ts"],"sourcesContent":["import { IncomingMessage } from 'http';\n\nimport { ApolloLink } from '@apollo/client';\nimport {\n ApolloClient,\n HttpLink,\n InMemoryCache,\n OperationVariables,\n} from '@apollo/client';\n\nimport { getBaseURL } from '../utils/env';\n\nconst isServer = () => typeof window === 'undefined';\n\nconst getGraphQLEndpoint = () => {\n const endpoint = process.env.NEXT_PUBLIC_GRAPHQL_ENDPOINT;\n if (endpoint) return isServer() ? `${getBaseURL()}${endpoint}` : endpoint;\n\n // Defaults to home's graphql endpoint\n return isServer() ? `${getBaseURL()}/api/graphql` : '/api/graphql';\n};\n\nconst httpLink = new HttpLink({\n uri: getGraphQLEndpoint(),\n credentials: 'include',\n});\n\nconst apolloClient = new ApolloClient({\n link: httpLink,\n cache: new InMemoryCache({}),\n defaultOptions: {\n watchQuery: {\n notifyOnNetworkStatusChange: true,\n },\n },\n});\n\n/**\n * When requests are sent from the server, cookies need to be manually attached.\n *\n * @param cookieHeader Cookies string to forward\n * @returns Server-side Apollo client\n */\nexport function createServerApolloClient(cookieHeader?: string) {\n const authLink = new ApolloLink((operation, forward) => {\n if (cookieHeader) {\n operation.setContext({\n http: {\n includeCredentials: true,\n },\n headers
|
|
1
|
+
{"version":3,"file":"apollo-client.js","names":["headers: Record<string, string>","error: any"],"sources":["../../../src/lib/gql/apollo-client.ts"],"sourcesContent":["import { IncomingMessage } from 'http';\n\nimport { ApolloLink } from '@apollo/client';\nimport {\n ApolloClient,\n HttpLink,\n InMemoryCache,\n OperationVariables,\n} from '@apollo/client';\n\nimport { getBaseURL } from '../utils/env';\n\nconst isServer = () => typeof window === 'undefined';\n\nconst getGraphQLEndpoint = () => {\n const endpoint = process.env.NEXT_PUBLIC_GRAPHQL_ENDPOINT;\n if (endpoint) return isServer() ? `${getBaseURL()}${endpoint}` : endpoint;\n\n // Defaults to home's graphql endpoint\n return isServer() ? `${getBaseURL()}/api/graphql` : '/api/graphql';\n};\n\nconst httpLink = new HttpLink({\n uri: getGraphQLEndpoint(),\n credentials: 'include',\n});\n\nconst apolloClient = new ApolloClient({\n link: httpLink,\n cache: new InMemoryCache({}),\n defaultOptions: {\n watchQuery: {\n notifyOnNetworkStatusChange: true,\n },\n },\n});\n\n/**\n * When requests are sent from the server, cookies need to be manually attached.\n *\n * @param cookieHeader Cookies string to forward\n * @returns Server-side Apollo client\n */\nexport function createServerApolloClient(cookieHeader?: string) {\n const bffApiKey = process.env.BFF_API_KEY;\n\n const authLink = new ApolloLink((operation, forward) => {\n const headers: Record<string, string> = {};\n\n if (cookieHeader) {\n headers.Cookie = cookieHeader;\n }\n\n if (bffApiKey) {\n headers['x-bff-api-key'] = bffApiKey;\n }\n\n if (Object.keys(headers).length > 0) {\n operation.setContext({\n http: {\n includeCredentials: true,\n },\n headers,\n });\n }\n\n return forward(operation);\n });\n\n return new ApolloClient({\n link: authLink.concat(httpLink),\n cache: new InMemoryCache({}),\n defaultOptions: {\n watchQuery: {\n notifyOnNetworkStatusChange: true,\n },\n },\n });\n}\n\nexport function initializeApollo(req: IncomingMessage | null = null) {\n if (isServer()) {\n const cookieHeader = req?.headers.cookie;\n return createServerApolloClient(cookieHeader);\n }\n\n return apolloClient;\n}\n\nexport async function graphqlFetch<\n TResult,\n TVariables extends OperationVariables,\n>(\n options: ApolloClient.QueryOptions<TResult, TVariables>,\n apolloClientOverride?: ApolloClient\n): Promise<TResult | undefined> {\n try {\n const client = apolloClientOverride || apolloClient;\n\n const { data } = await client.query<TResult, TVariables>({\n ...options,\n fetchPolicy: 'network-only',\n });\n\n return data;\n } catch (error: any) {\n throw new Error(error.message || 'GraphQL error');\n }\n}\n\nexport async function graphqlMutation<\n TResult,\n TVariables extends OperationVariables,\n>(\n options: ApolloClient.MutateOptions<TResult, TVariables>,\n apolloClientOverride?: ApolloClient\n): Promise<TResult | undefined> {\n try {\n const client = apolloClientOverride || apolloClient;\n\n const { data } = await client.mutate<TResult, TVariables>({\n ...options,\n fetchPolicy: 'network-only',\n });\n\n return data;\n } catch (error: any) {\n throw new Error(error.message || 'GraphQL error');\n }\n}\nexport default apolloClient;\n"],"mappings":";;;;AAYA,MAAM,iBAAiB,OAAO,WAAW;AAEzC,MAAM,2BAA2B;CAC/B,MAAM,WAAW,QAAQ,IAAI;AAC7B,KAAI,SAAU,QAAO,UAAU,GAAG,GAAG,YAAY,GAAG,aAAa;AAGjE,QAAO,UAAU,GAAG,GAAG,YAAY,CAAC,gBAAgB;;AAGtD,MAAM,WAAW,IAAI,SAAS;CAC5B,KAAK,oBAAoB;CACzB,aAAa;CACd,CAAC;AAEF,MAAM,eAAe,IAAI,aAAa;CACpC,MAAM;CACN,OAAO,IAAI,cAAc,EAAE,CAAC;CAC5B,gBAAgB,EACd,YAAY,EACV,6BAA6B,MAC9B,EACF;CACF,CAAC;;;;;;;AAQF,SAAgB,yBAAyB,cAAuB;CAC9D,MAAM,YAAY,QAAQ,IAAI;AAyB9B,QAAO,IAAI,aAAa;EACtB,MAxBe,IAAI,YAAY,WAAW,YAAY;GACtD,MAAMA,UAAkC,EAAE;AAE1C,OAAI,aACF,SAAQ,SAAS;AAGnB,OAAI,UACF,SAAQ,mBAAmB;AAG7B,OAAI,OAAO,KAAK,QAAQ,CAAC,SAAS,EAChC,WAAU,WAAW;IACnB,MAAM,EACJ,oBAAoB,MACrB;IACD;IACD,CAAC;AAGJ,UAAO,QAAQ,UAAU;IACzB,CAGe,OAAO,SAAS;EAC/B,OAAO,IAAI,cAAc,EAAE,CAAC;EAC5B,gBAAgB,EACd,YAAY,EACV,6BAA6B,MAC9B,EACF;EACF,CAAC;;AAGJ,SAAgB,iBAAiB,MAA8B,MAAM;AACnE,KAAI,UAAU,EAAE;EACd,MAAM,eAAe,KAAK,QAAQ;AAClC,SAAO,yBAAyB,aAAa;;AAG/C,QAAO;;AAGT,eAAsB,aAIpB,SACA,sBAC8B;AAC9B,KAAI;EAGF,MAAM,EAAE,SAAS,OAFF,wBAAwB,cAET,MAA2B;GACvD,GAAG;GACH,aAAa;GACd,CAAC;AAEF,SAAO;UACAC,OAAY;AACnB,QAAM,IAAI,MAAM,MAAM,WAAW,gBAAgB;;;AAIrD,eAAsB,gBAIpB,SACA,sBAC8B;AAC9B,KAAI;EAGF,MAAM,EAAE,SAAS,OAFF,wBAAwB,cAET,OAA4B;GACxD,GAAG;GACH,aAAa;GACd,CAAC;AAEF,SAAO;UACAA,OAAY;AACnB,QAAM,IAAI,MAAM,MAAM,WAAW,gBAAgB;;;AAGrD,4BAAe"}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _apollo_client5 from "@apollo/client";
|
|
2
2
|
|
|
3
3
|
//#region src/lib/gql/fragments/cart.d.ts
|
|
4
|
-
declare const LINE_ITEM_FRAGMENT:
|
|
5
|
-
declare const COUNTRY_FRAGMENT:
|
|
6
|
-
declare const REGION_FRAGMENT:
|
|
7
|
-
declare const SHIPPING_METHODS_FRAGMENT:
|
|
8
|
-
declare const PAYMENT_COLLECTION_FRAGMENT:
|
|
9
|
-
declare const ADDRESS_FRAGMENT:
|
|
10
|
-
declare const PROMOTION_FRAGMENT:
|
|
11
|
-
declare const CART_FRAGMENT:
|
|
4
|
+
declare const LINE_ITEM_FRAGMENT: _apollo_client5.DocumentNode;
|
|
5
|
+
declare const COUNTRY_FRAGMENT: _apollo_client5.DocumentNode;
|
|
6
|
+
declare const REGION_FRAGMENT: _apollo_client5.DocumentNode;
|
|
7
|
+
declare const SHIPPING_METHODS_FRAGMENT: _apollo_client5.DocumentNode;
|
|
8
|
+
declare const PAYMENT_COLLECTION_FRAGMENT: _apollo_client5.DocumentNode;
|
|
9
|
+
declare const ADDRESS_FRAGMENT: _apollo_client5.DocumentNode;
|
|
10
|
+
declare const PROMOTION_FRAGMENT: _apollo_client5.DocumentNode;
|
|
11
|
+
declare const CART_FRAGMENT: _apollo_client5.DocumentNode;
|
|
12
12
|
//#endregion
|
|
13
13
|
export { ADDRESS_FRAGMENT, CART_FRAGMENT, COUNTRY_FRAGMENT, LINE_ITEM_FRAGMENT, PAYMENT_COLLECTION_FRAGMENT, PROMOTION_FRAGMENT, REGION_FRAGMENT, SHIPPING_METHODS_FRAGMENT };
|
|
14
14
|
//# sourceMappingURL=cart.d.ts.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _apollo_client13 from "@apollo/client";
|
|
2
2
|
|
|
3
3
|
//#region src/lib/gql/fragments/customer.d.ts
|
|
4
|
-
declare const CUSTOMER_ADDRESS_FRAGMENT:
|
|
5
|
-
declare const CUSTOMER_FRAGMENT:
|
|
4
|
+
declare const CUSTOMER_ADDRESS_FRAGMENT: _apollo_client13.DocumentNode;
|
|
5
|
+
declare const CUSTOMER_FRAGMENT: _apollo_client13.DocumentNode;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { CUSTOMER_ADDRESS_FRAGMENT, CUSTOMER_FRAGMENT };
|
|
8
8
|
//# sourceMappingURL=customer.d.ts.map
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _apollo_client18 from "@apollo/client";
|
|
2
2
|
|
|
3
3
|
//#region src/lib/gql/fragments/product.d.ts
|
|
4
|
-
declare const PRICE_FRAGMENT:
|
|
5
|
-
declare const PRODUCT_VARIANT_FRAGMENT:
|
|
6
|
-
declare const PRODUCT_CATEGORY_FRAGMENT:
|
|
7
|
-
declare const PRODUCT_COLLECTION_FRAGMENT:
|
|
8
|
-
declare const PRODUCT_IMAGE_FRAGMENT:
|
|
9
|
-
declare const COLLECTION_PRODUCTS_FRAGMENT:
|
|
10
|
-
declare const COLLECTION_PRODUCTS_HOME_FRAGMENT:
|
|
4
|
+
declare const PRICE_FRAGMENT: _apollo_client18.DocumentNode;
|
|
5
|
+
declare const PRODUCT_VARIANT_FRAGMENT: _apollo_client18.DocumentNode;
|
|
6
|
+
declare const PRODUCT_CATEGORY_FRAGMENT: _apollo_client18.DocumentNode;
|
|
7
|
+
declare const PRODUCT_COLLECTION_FRAGMENT: _apollo_client18.DocumentNode;
|
|
8
|
+
declare const PRODUCT_IMAGE_FRAGMENT: _apollo_client18.DocumentNode;
|
|
9
|
+
declare const COLLECTION_PRODUCTS_FRAGMENT: _apollo_client18.DocumentNode;
|
|
10
|
+
declare const COLLECTION_PRODUCTS_HOME_FRAGMENT: _apollo_client18.DocumentNode;
|
|
11
11
|
//#endregion
|
|
12
12
|
export { COLLECTION_PRODUCTS_FRAGMENT, COLLECTION_PRODUCTS_HOME_FRAGMENT, PRICE_FRAGMENT, PRODUCT_CATEGORY_FRAGMENT, PRODUCT_COLLECTION_FRAGMENT, PRODUCT_IMAGE_FRAGMENT, PRODUCT_VARIANT_FRAGMENT };
|
|
13
13
|
//# sourceMappingURL=product.d.ts.map
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _apollo_client33 from "@apollo/client";
|
|
2
2
|
|
|
3
3
|
//#region src/lib/gql/mutations/cart.d.ts
|
|
4
|
-
declare const CREATE_CART_MUTATION:
|
|
5
|
-
declare const CREATE_LINE_ITEM_MUTATION:
|
|
6
|
-
declare const UPDATE_CART_MUTATION:
|
|
7
|
-
declare const DELETE_LINE_ITEM_MUTATION:
|
|
8
|
-
declare const TRANSFER_CART_MUTATION:
|
|
4
|
+
declare const CREATE_CART_MUTATION: _apollo_client33.DocumentNode;
|
|
5
|
+
declare const CREATE_LINE_ITEM_MUTATION: _apollo_client33.DocumentNode;
|
|
6
|
+
declare const UPDATE_CART_MUTATION: _apollo_client33.DocumentNode;
|
|
7
|
+
declare const DELETE_LINE_ITEM_MUTATION: _apollo_client33.DocumentNode;
|
|
8
|
+
declare const TRANSFER_CART_MUTATION: _apollo_client33.DocumentNode;
|
|
9
9
|
//#endregion
|
|
10
10
|
export { CREATE_CART_MUTATION, CREATE_LINE_ITEM_MUTATION, DELETE_LINE_ITEM_MUTATION, TRANSFER_CART_MUTATION, UPDATE_CART_MUTATION };
|
|
11
11
|
//# sourceMappingURL=cart.d.ts.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _apollo_client15 from "@apollo/client";
|
|
2
2
|
|
|
3
3
|
//#region src/lib/gql/queries/cart-summary.d.ts
|
|
4
|
-
declare const GET_CART_ITEM_COUNT_QUERY:
|
|
4
|
+
declare const GET_CART_ITEM_COUNT_QUERY: _apollo_client15.DocumentNode;
|
|
5
5
|
//#endregion
|
|
6
6
|
export { GET_CART_ITEM_COUNT_QUERY };
|
|
7
7
|
//# sourceMappingURL=cart-summary.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cart-summary.js","names":[],"sources":["../../../../src/lib/gql/queries/cart-summary.ts"],"sourcesContent":["import { gql } from '@apollo/client';\n\nexport const GET_CART_ITEM_COUNT_QUERY = gql`\n query GetCartItemCount($id:
|
|
1
|
+
{"version":3,"file":"cart-summary.js","names":[],"sources":["../../../../src/lib/gql/queries/cart-summary.ts"],"sourcesContent":["import { gql } from '@apollo/client';\n\nexport const GET_CART_ITEM_COUNT_QUERY = gql`\n query GetCartItemCount($id: String!) {\n cart(id: $id) {\n items {\n quantity\n }\n }\n }\n`;\n"],"mappings":";;;AAEA,MAAa,4BAA4B,GAAG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cart-total.d.ts","names":[],"sources":["../../../../src/lib/gql/queries/cart-total.ts"],"sourcesContent":[],"mappings":";;;cAEa,sBAMZ,gBAAA,CANgC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { gql } from "@apollo/client";
|
|
2
|
+
|
|
3
|
+
//#region src/lib/gql/queries/cart-total.ts
|
|
4
|
+
const GET_CART_TOTAL_QUERY = gql`
|
|
5
|
+
query GetCartTotal($id: String!) {
|
|
6
|
+
cart(id: $id) {
|
|
7
|
+
total
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
`;
|
|
11
|
+
|
|
12
|
+
//#endregion
|
|
13
|
+
export { GET_CART_TOTAL_QUERY };
|
|
14
|
+
//# sourceMappingURL=cart-total.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cart-total.js","names":[],"sources":["../../../../src/lib/gql/queries/cart-total.ts"],"sourcesContent":["import { gql } from '@apollo/client';\n\nexport const GET_CART_TOTAL_QUERY = gql`\n query GetCartTotal($id: String!) {\n cart(id: $id) {\n total\n }\n }\n`;"],"mappings":";;;AAEA,MAAa,uBAAuB,GAAG"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _apollo_client17 from "@apollo/client";
|
|
2
2
|
|
|
3
3
|
//#region src/lib/gql/queries/cart.d.ts
|
|
4
|
-
declare const GET_CART_QUERY:
|
|
4
|
+
declare const GET_CART_QUERY: _apollo_client17.DocumentNode;
|
|
5
5
|
//#endregion
|
|
6
6
|
export { GET_CART_QUERY };
|
|
7
7
|
//# sourceMappingURL=cart.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cart.js","names":[],"sources":["../../../../src/lib/gql/queries/cart.ts"],"sourcesContent":["import { gql } from '@apollo/client';\n\nimport { CART_FRAGMENT } from '../fragments/cart';\n\nexport const GET_CART_QUERY = gql`\n query GetCart($id:
|
|
1
|
+
{"version":3,"file":"cart.js","names":[],"sources":["../../../../src/lib/gql/queries/cart.ts"],"sourcesContent":["import { gql } from '@apollo/client';\n\nimport { CART_FRAGMENT } from '../fragments/cart';\n\nexport const GET_CART_QUERY = gql`\n query GetCart($id: String!) {\n cart(id: $id) {\n ...CartFields\n }\n }\n ${CART_FRAGMENT}\n`;\n"],"mappings":";;;;AAIA,MAAa,iBAAiB,GAAG;;;;;;IAM7B,cAAc"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _apollo_client25 from "@apollo/client";
|
|
2
2
|
|
|
3
3
|
//#region src/lib/gql/queries/collections.d.ts
|
|
4
|
-
declare const GET_COLLECTIONS_QUERY:
|
|
5
|
-
declare const GET_COLLECTIONS_HOME_QUERY:
|
|
4
|
+
declare const GET_COLLECTIONS_QUERY: _apollo_client25.DocumentNode;
|
|
5
|
+
declare const GET_COLLECTIONS_HOME_QUERY: _apollo_client25.DocumentNode;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { GET_COLLECTIONS_HOME_QUERY, GET_COLLECTIONS_QUERY };
|
|
8
8
|
//# sourceMappingURL=collections.d.ts.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _apollo_client16 from "@apollo/client";
|
|
2
2
|
|
|
3
3
|
//#region src/lib/gql/queries/customer.d.ts
|
|
4
|
-
declare const GET_CUSTOMER_QUERY:
|
|
4
|
+
declare const GET_CUSTOMER_QUERY: _apollo_client16.DocumentNode;
|
|
5
5
|
//#endregion
|
|
6
6
|
export { GET_CUSTOMER_QUERY };
|
|
7
7
|
//# sourceMappingURL=customer.d.ts.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _apollo_client27 from "@apollo/client";
|
|
2
2
|
|
|
3
3
|
//#region src/lib/gql/queries/footer.d.ts
|
|
4
|
-
declare const GET_FOOTER_QUERY:
|
|
5
|
-
declare const GET_FOOTER_DATA_QUERY:
|
|
4
|
+
declare const GET_FOOTER_QUERY: _apollo_client27.DocumentNode;
|
|
5
|
+
declare const GET_FOOTER_DATA_QUERY: _apollo_client27.DocumentNode;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { GET_FOOTER_DATA_QUERY, GET_FOOTER_QUERY };
|
|
8
8
|
//# sourceMappingURL=footer.d.ts.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _apollo_client32 from "@apollo/client";
|
|
2
2
|
|
|
3
3
|
//#region src/lib/gql/queries/home-banner.d.ts
|
|
4
|
-
declare const GET_HOME_BANNER_QUERY:
|
|
4
|
+
declare const GET_HOME_BANNER_QUERY: _apollo_client32.DocumentNode;
|
|
5
5
|
//#endregion
|
|
6
6
|
export { GET_HOME_BANNER_QUERY };
|
|
7
7
|
//# sourceMappingURL=home-banner.d.ts.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _apollo_client29 from "@apollo/client";
|
|
2
2
|
|
|
3
3
|
//#region src/lib/gql/queries/order.d.ts
|
|
4
|
-
declare const ORDER_FRAGMENT:
|
|
5
|
-
declare const GET_ORDER_QUERY:
|
|
6
|
-
declare const GET_ORDERS_QUERY:
|
|
4
|
+
declare const ORDER_FRAGMENT: _apollo_client29.DocumentNode;
|
|
5
|
+
declare const GET_ORDER_QUERY: _apollo_client29.DocumentNode;
|
|
6
|
+
declare const GET_ORDERS_QUERY: _apollo_client29.DocumentNode;
|
|
7
7
|
//#endregion
|
|
8
8
|
export { GET_ORDERS_QUERY, GET_ORDER_QUERY, ORDER_FRAGMENT };
|
|
9
9
|
//# sourceMappingURL=order.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"order.d.ts","names":[],"sources":["../../../../src/lib/gql/queries/order.ts"],"sourcesContent":[],"mappings":";;;cAEa,
|
|
1
|
+
{"version":3,"file":"order.d.ts","names":[],"sources":["../../../../src/lib/gql/queries/order.ts"],"sourcesContent":[],"mappings":";;;cAEa,gBAgFZ,gBAAA,CAhF0B;cAkFd,iBAOZ,gBAAA,CAP2B;cASf,kBAYZ,gBAAA,CAZ4B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"order.js","names":[],"sources":["../../../../src/lib/gql/queries/order.ts"],"sourcesContent":["import { gql } from '@apollo/client';\n\nexport const ORDER_FRAGMENT = gql`\n fragment OrderFields on Order {\n id\n displayId\n email\n customerId\n regionId\n status\n paymentStatus\n fulfillmentStatus\n currencyCode\n total\n subtotal\n discountTotal\n giftCardTotal\n shippingTotal\n taxTotal\n createdAt\n items {\n id\n title\n quantity\n unitPrice\n total\n originalTotal\n thumbnail\n productHandle\n productTitle\n variant {\n id\n title\n sku\n product {\n id\n title\n handle\n thumbnail\n createdAt\n }\n }\n }\n shippingMethods {\n id\n name\n amount\n shippingOptionId\n }\n shippingAddress {\n firstName\n lastName\n address1\n address2\n city\n postalCode\n countryCode\n phone\n }\n paymentCollections {\n id\n currencyCode\n amount\n status\n paymentProviders {\n id\n }\n payments {\n id\n amount\n currencyCode\n providerId\n cardLast4\n createdAt\n }\n }\n }\n`;\n\nexport const GET_ORDER_QUERY = gql`\n query GetOrder($id: ID!) {\n order(id: $id) {\n ...OrderFields\n }\n }\n ${ORDER_FRAGMENT}\n`;\n\nexport const GET_ORDERS_QUERY = gql`\n query GetOrders($limit: Int, $offset: Int) {\n orders(limit: $limit, offset: $offset) {\n orders {\n ...OrderFields\n }\n count\n limit\n offset\n }\n }\n ${ORDER_FRAGMENT}\n`;\n"],"mappings":";;;AAEA,MAAa,iBAAiB,GAAG
|
|
1
|
+
{"version":3,"file":"order.js","names":[],"sources":["../../../../src/lib/gql/queries/order.ts"],"sourcesContent":["import { gql } from '@apollo/client';\n\nexport const ORDER_FRAGMENT = gql`\n fragment OrderFields on Order {\n id\n displayId\n email\n customerId\n regionId\n status\n paymentStatus\n fulfillmentStatus\n currencyCode\n total\n subtotal\n discountTotal\n giftCardTotal\n shippingTotal\n taxTotal\n createdAt\n items {\n id\n title\n quantity\n unitPrice\n total\n originalTotal\n thumbnail\n productHandle\n productTitle\n variant {\n id\n title\n sku\n product {\n id\n title\n handle\n thumbnail\n createdAt\n categories {\n id\n name\n handle\n }\n }\n }\n }\n shippingMethods {\n id\n name\n amount\n shippingOptionId\n }\n shippingAddress {\n firstName\n lastName\n address1\n address2\n city\n postalCode\n countryCode\n phone\n }\n paymentCollections {\n id\n currencyCode\n amount\n status\n paymentProviders {\n id\n }\n payments {\n id\n amount\n currencyCode\n providerId\n cardLast4\n createdAt\n }\n }\n }\n`;\n\nexport const GET_ORDER_QUERY = gql`\n query GetOrder($id: ID!) {\n order(id: $id) {\n ...OrderFields\n }\n }\n ${ORDER_FRAGMENT}\n`;\n\nexport const GET_ORDERS_QUERY = gql`\n query GetOrders($limit: Int, $offset: Int) {\n orders(limit: $limit, offset: $offset) {\n orders {\n ...OrderFields\n }\n count\n limit\n offset\n }\n }\n ${ORDER_FRAGMENT}\n`;\n"],"mappings":";;;AAEA,MAAa,iBAAiB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkFjC,MAAa,kBAAkB,GAAG;;;;;;IAM9B,eAAe;;AAGnB,MAAa,mBAAmB,GAAG;;;;;;;;;;;IAW/B,eAAe"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as _apollo_client41 from "@apollo/client";
|
|
2
|
+
|
|
3
|
+
//#region src/lib/gql/queries/product-personalization.d.ts
|
|
4
|
+
declare const GET_PRODUCT_BY_HANDLE_FOR_PERSONALIZATION: _apollo_client41.DocumentNode;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { GET_PRODUCT_BY_HANDLE_FOR_PERSONALIZATION };
|
|
7
|
+
//# sourceMappingURL=product-personalization.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"product-personalization.d.ts","names":[],"sources":["../../../../src/lib/gql/queries/product-personalization.ts"],"sourcesContent":[],"mappings":";;;cAEa,2CAcZ,gBAAA,CAdqD"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { gql } from "@apollo/client";
|
|
2
|
+
|
|
3
|
+
//#region src/lib/gql/queries/product-personalization.ts
|
|
4
|
+
const GET_PRODUCT_BY_HANDLE_FOR_PERSONALIZATION = gql`
|
|
5
|
+
query GetProductByHandleForPersonalization($handle: String!) {
|
|
6
|
+
products(handle: $handle, limit: 1) {
|
|
7
|
+
products {
|
|
8
|
+
id
|
|
9
|
+
variants {
|
|
10
|
+
id
|
|
11
|
+
calculatedPrice {
|
|
12
|
+
amount
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
`;
|
|
19
|
+
|
|
20
|
+
//#endregion
|
|
21
|
+
export { GET_PRODUCT_BY_HANDLE_FOR_PERSONALIZATION };
|
|
22
|
+
//# sourceMappingURL=product-personalization.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"product-personalization.js","names":[],"sources":["../../../../src/lib/gql/queries/product-personalization.ts"],"sourcesContent":["import { gql } from '@apollo/client';\n\nexport const GET_PRODUCT_BY_HANDLE_FOR_PERSONALIZATION = gql`\n query GetProductByHandleForPersonalization($handle: String!) {\n products(handle: $handle, limit: 1) {\n products {\n id\n variants {\n id\n calculatedPrice {\n amount\n }\n }\n }\n }\n }\n`;"],"mappings":";;;AAEA,MAAa,4CAA4C,GAAG"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _apollo_client42 from "@apollo/client";
|
|
2
2
|
|
|
3
3
|
//#region src/lib/gql/queries/product.d.ts
|
|
4
|
-
declare const GET_PRODUCT_CATEGORIES_QUERY:
|
|
4
|
+
declare const GET_PRODUCT_CATEGORIES_QUERY: _apollo_client42.DocumentNode;
|
|
5
5
|
//#endregion
|
|
6
6
|
export { GET_PRODUCT_CATEGORIES_QUERY };
|
|
7
7
|
//# sourceMappingURL=product.d.ts.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _apollo_client38 from "@apollo/client";
|
|
2
2
|
|
|
3
3
|
//#region src/lib/gql/queries/regions.d.ts
|
|
4
|
-
declare const LIST_REGIONS_QUERY:
|
|
5
|
-
declare const GET_REGION_QUERY:
|
|
4
|
+
declare const LIST_REGIONS_QUERY: _apollo_client38.DocumentNode;
|
|
5
|
+
declare const GET_REGION_QUERY: _apollo_client38.DocumentNode;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { GET_REGION_QUERY, LIST_REGIONS_QUERY };
|
|
8
8
|
//# sourceMappingURL=regions.d.ts.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _apollo_client1 from "@apollo/client";
|
|
2
2
|
|
|
3
3
|
//#region src/lib/hooks/use-apollo.d.ts
|
|
4
|
-
declare function useApollo():
|
|
4
|
+
declare function useApollo(): _apollo_client1.ApolloClient;
|
|
5
5
|
//#endregion
|
|
6
6
|
export { useApollo };
|
|
7
7
|
//# sourceMappingURL=use-apollo.d.ts.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region src/lib/hooks/use-time-on-page.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Fires TIME_ON_PAGE analytics signals at configurable time thresholds.
|
|
4
|
+
* Cleans up timers on unmount. Each threshold fires only once per mount.
|
|
5
|
+
*
|
|
6
|
+
* @param pageSurface - A label identifying the page surface (e.g. "pdp", "plp", "home")
|
|
7
|
+
* @param enabled - Allows conditional activation (default: true)
|
|
8
|
+
* @param thresholds - Custom time thresholds in seconds (default: [15, 30, 60, 120, 180])
|
|
9
|
+
*/
|
|
10
|
+
declare function useTimeOnPage(pageSurface: string, enabled?: boolean, thresholds?: readonly number[]): void;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { useTimeOnPage };
|
|
13
|
+
//# sourceMappingURL=use-time-on-page.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-time-on-page.d.ts","names":[],"sources":["../../../src/lib/hooks/use-time-on-page.ts"],"sourcesContent":[],"mappings":";;AAgBA;;;;;;;iBAAgB,aAAA"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { SignalType } from "../../types/graphql.js";
|
|
4
|
+
import { sendClientSignal } from "../personalization/client-signal.js";
|
|
5
|
+
import { useEffect, useRef } from "react";
|
|
6
|
+
|
|
7
|
+
//#region src/lib/hooks/use-time-on-page.ts
|
|
8
|
+
const DEFAULT_THRESHOLDS_SEC = [
|
|
9
|
+
15,
|
|
10
|
+
30,
|
|
11
|
+
60,
|
|
12
|
+
120,
|
|
13
|
+
180
|
|
14
|
+
];
|
|
15
|
+
/**
|
|
16
|
+
* Fires TIME_ON_PAGE analytics signals at configurable time thresholds.
|
|
17
|
+
* Cleans up timers on unmount. Each threshold fires only once per mount.
|
|
18
|
+
*
|
|
19
|
+
* @param pageSurface - A label identifying the page surface (e.g. "pdp", "plp", "home")
|
|
20
|
+
* @param enabled - Allows conditional activation (default: true)
|
|
21
|
+
* @param thresholds - Custom time thresholds in seconds (default: [15, 30, 60, 120, 180])
|
|
22
|
+
*/
|
|
23
|
+
function useTimeOnPage(pageSurface, enabled = true, thresholds = DEFAULT_THRESHOLDS_SEC) {
|
|
24
|
+
const firedRef = useRef(/* @__PURE__ */ new Set());
|
|
25
|
+
const thresholdsRef = useRef(thresholds);
|
|
26
|
+
thresholdsRef.current = thresholds;
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
if (!enabled) return;
|
|
29
|
+
const timers = thresholdsRef.current.map((seconds) => setTimeout(() => {
|
|
30
|
+
if (!firedRef.current.has(seconds)) {
|
|
31
|
+
firedRef.current.add(seconds);
|
|
32
|
+
sendClientSignal(SignalType.TimeOnPage, {
|
|
33
|
+
surface: pageSurface,
|
|
34
|
+
seconds
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
}, seconds * 1e3));
|
|
38
|
+
return () => {
|
|
39
|
+
timers.forEach(clearTimeout);
|
|
40
|
+
};
|
|
41
|
+
}, [pageSurface, enabled]);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
//#endregion
|
|
45
|
+
export { useTimeOnPage };
|
|
46
|
+
//# sourceMappingURL=use-time-on-page.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-time-on-page.js","names":[],"sources":["../../../src/lib/hooks/use-time-on-page.ts"],"sourcesContent":["'use client';\n\nimport { useEffect, useRef } from 'react';\nimport { sendClientSignal } from '../personalization/client-signal';\nimport { SignalType } from '../../types/graphql';\n\nconst DEFAULT_THRESHOLDS_SEC = [15, 30, 60, 120, 180] as const;\n\n/**\n * Fires TIME_ON_PAGE analytics signals at configurable time thresholds.\n * Cleans up timers on unmount. Each threshold fires only once per mount.\n *\n * @param pageSurface - A label identifying the page surface (e.g. \"pdp\", \"plp\", \"home\")\n * @param enabled - Allows conditional activation (default: true)\n * @param thresholds - Custom time thresholds in seconds (default: [15, 30, 60, 120, 180])\n */\nexport function useTimeOnPage(\n pageSurface: string,\n enabled = true,\n thresholds: readonly number[] = DEFAULT_THRESHOLDS_SEC\n): void {\n const firedRef = useRef<Set<number>>(new Set());\n const thresholdsRef = useRef(thresholds);\n thresholdsRef.current = thresholds;\n\n useEffect(() => {\n if (!enabled) return;\n\n const timers = thresholdsRef.current.map((seconds) =>\n setTimeout(() => {\n if (!firedRef.current.has(seconds)) {\n firedRef.current.add(seconds);\n void sendClientSignal(SignalType.TimeOnPage, {\n surface: pageSurface,\n seconds,\n });\n }\n }, seconds * 1000)\n );\n\n return () => {\n timers.forEach(clearTimeout);\n };\n }, [pageSurface, enabled]); // thresholds omitted — stabilized via ref\n}\n"],"mappings":";;;;;;;AAMA,MAAM,yBAAyB;CAAC;CAAI;CAAI;CAAI;CAAK;CAAI;;;;;;;;;AAUrD,SAAgB,cACd,aACA,UAAU,MACV,aAAgC,wBAC1B;CACN,MAAM,WAAW,uBAAoB,IAAI,KAAK,CAAC;CAC/C,MAAM,gBAAgB,OAAO,WAAW;AACxC,eAAc,UAAU;AAExB,iBAAgB;AACd,MAAI,CAAC,QAAS;EAEd,MAAM,SAAS,cAAc,QAAQ,KAAK,YACxC,iBAAiB;AACf,OAAI,CAAC,SAAS,QAAQ,IAAI,QAAQ,EAAE;AAClC,aAAS,QAAQ,IAAI,QAAQ;AAC7B,IAAK,iBAAiB,WAAW,YAAY;KAC3C,SAAS;KACT;KACD,CAAC;;KAEH,UAAU,IAAK,CACnB;AAED,eAAa;AACX,UAAO,QAAQ,aAAa;;IAE7B,CAAC,aAAa,QAAQ,CAAC"}
|
|
@@ -6,10 +6,6 @@ interface SegmentData {
|
|
|
6
6
|
}
|
|
7
7
|
declare function getSegmentCookie(): SegmentData;
|
|
8
8
|
declare function setSegmentCookie(data: SegmentData): void;
|
|
9
|
-
declare function emitSignal(type: string, payload?: unknown): void;
|
|
10
|
-
declare function getSignal(type: string): unknown;
|
|
11
|
-
declare function getAllSignals(): Record<string, unknown>;
|
|
12
|
-
declare function clearSignals(): void;
|
|
13
9
|
//#endregion
|
|
14
|
-
export { SegmentData,
|
|
10
|
+
export { SegmentData, getSegmentCookie, setSegmentCookie };
|
|
15
11
|
//# sourceMappingURL=behavior-tracker.d.ts.map
|