@faststore/api 4.10.1 → 4.10.2-dev.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/cjs/index.js +49 -46
- package/dist/cjs/index.js.map +1 -1
- package/dist/es/index.mjs +1160 -1030
- package/dist/es/index.mjs.map +1 -1
- package/dist/src/__generated__/schema.d.ts +1 -0
- package/dist/src/__generated__/schema.d.ts.map +1 -1
- package/dist/src/platforms/vtex/clients/commerce/index.d.ts +16 -2
- package/dist/src/platforms/vtex/clients/commerce/index.d.ts.map +1 -1
- package/dist/src/platforms/vtex/clients/fetch.d.ts +1 -0
- package/dist/src/platforms/vtex/clients/fetch.d.ts.map +1 -1
- package/dist/src/platforms/vtex/clients/index.d.ts +3 -3
- package/dist/src/platforms/vtex/clients/index.d.ts.map +1 -1
- package/dist/src/platforms/vtex/clients/search/index.d.ts +7 -1
- package/dist/src/platforms/vtex/clients/search/index.d.ts.map +1 -1
- package/dist/src/platforms/vtex/index.d.ts +1 -1
- package/dist/src/platforms/vtex/index.d.ts.map +1 -1
- package/dist/src/platforms/vtex/loaders/sku.d.ts.map +1 -1
- package/dist/src/platforms/vtex/resolvers/getOrderEntryOperation.d.ts.map +1 -1
- package/dist/src/platforms/vtex/resolvers/index.d.ts +1 -1
- package/dist/src/platforms/vtex/resolvers/index.d.ts.map +1 -1
- package/dist/src/platforms/vtex/resolvers/query.d.ts +1 -1
- package/dist/src/platforms/vtex/resolvers/query.d.ts.map +1 -1
- package/dist/src/platforms/vtex/resolvers/subscribeToNewsletter.d.ts.map +1 -1
- package/dist/src/platforms/vtex/resolvers/validateSession.d.ts.map +1 -1
- package/dist/src/platforms/vtex/utils/contractAssortment.d.ts +22 -0
- package/dist/src/platforms/vtex/utils/contractAssortment.d.ts.map +1 -0
- package/dist/src/platforms/vtex/utils/intelligentSearchRequest.d.ts +5 -0
- package/dist/src/platforms/vtex/utils/intelligentSearchRequest.d.ts.map +1 -1
- package/dist/src/platforms/vtex/utils/validateSessionHelpers.d.ts +29 -2
- package/dist/src/platforms/vtex/utils/validateSessionHelpers.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/__generated__/schema.ts +1 -0
- package/src/platforms/vtex/clients/commerce/index.ts +80 -3
- package/src/platforms/vtex/clients/fetch.ts +52 -1
- package/src/platforms/vtex/clients/search/index.ts +13 -1
- package/src/platforms/vtex/loaders/sku.ts +1 -0
- package/src/platforms/vtex/resolvers/query.ts +51 -37
- package/src/platforms/vtex/resolvers/subscribeToNewsletter.ts +28 -1
- package/src/platforms/vtex/resolvers/validateSession.ts +3 -3
- package/src/platforms/vtex/typeDefs/session.graphql +3 -0
- package/src/platforms/vtex/utils/contractAssortment.ts +87 -0
- package/src/platforms/vtex/utils/intelligentSearchRequest.ts +10 -0
- package/src/platforms/vtex/utils/validateSessionHelpers.ts +47 -5
package/dist/es/index.mjs
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import { mergeTypeDefs as
|
|
2
|
-
import { makeExecutableSchema as
|
|
3
|
-
import { mapSchema as
|
|
4
|
-
import { GraphQLScalarType as
|
|
5
|
-
import { logger as
|
|
6
|
-
import
|
|
7
|
-
import { parse as
|
|
8
|
-
import
|
|
1
|
+
import { mergeTypeDefs as Sn } from "@graphql-tools/merge";
|
|
2
|
+
import { makeExecutableSchema as it, mergeSchemas as at } from "@graphql-tools/schema";
|
|
3
|
+
import { mapSchema as yn, MapperKind as In, getDirective as vn } from "@graphql-tools/utils";
|
|
4
|
+
import { GraphQLScalarType as ot, print as st, parse as ct, isSchema as lt } from "graphql";
|
|
5
|
+
import { logger as dt, OTELAPI as H } from "@faststore/diagnostics";
|
|
6
|
+
import ut from "isomorphic-unfetch";
|
|
7
|
+
import { parse as ae } from "cookie";
|
|
8
|
+
import _e from "p-limit";
|
|
9
9
|
import fe from "dataloader";
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
var
|
|
14
|
-
const
|
|
10
|
+
import pt from "sanitize-html";
|
|
11
|
+
import Te from "fast-deep-equal";
|
|
12
|
+
import gt from "node:crypto";
|
|
13
|
+
var mt = /* @__PURE__ */ ((e) => (e.Personal = "personal", e.Shared = "shared", e))(mt || {}), ht = /* @__PURE__ */ ((e) => (e.Accepted = "accepted", e.Denied = "denied", e.Pending = "pending", e))(ht || {}), ft = /* @__PURE__ */ ((e) => (e.Brand = "Brand", e.Category = "Category", e.Cluster = "Cluster", e.Collection = "Collection", e.Department = "Department", e.SubCategory = "SubCategory", e))(ft || {}), St = /* @__PURE__ */ ((e) => (e.Boolean = "BOOLEAN", e.Range = "RANGE", e))(St || {}), yt = /* @__PURE__ */ ((e) => (e.DiscountDesc = "discount_desc", e.NameAsc = "name_asc", e.NameDesc = "name_desc", e.OrdersDesc = "orders_desc", e.PriceAsc = "price_asc", e.PriceDesc = "price_desc", e.ReleaseDesc = "release_desc", e.ScoreDesc = "score_desc", e))(yt || {}), It = /* @__PURE__ */ ((e) => (e.Error = "ERROR", e.Info = "INFO", e.Warning = "WARNING", e))(It || {}), vt = /* @__PURE__ */ ((e) => (e.Input = "Input", e.Output = "Output", e))(vt || {});
|
|
14
|
+
const Ot = () => function(n = {}) {
|
|
15
15
|
const t = process.env.FS_DISCOVERY_APP_KEY ?? "", r = process.env.FS_DISCOVERY_APP_TOKEN ?? "";
|
|
16
16
|
if (!t || !r)
|
|
17
|
-
throw new
|
|
17
|
+
throw new re("No authentication AppKey and AppToken passed.");
|
|
18
18
|
return {
|
|
19
19
|
...n,
|
|
20
20
|
"X-VTEX-API-AppKey": t,
|
|
21
21
|
"X-VTEX-API-AppToken": r
|
|
22
22
|
};
|
|
23
|
-
},
|
|
23
|
+
}, Ct = async (e) => {
|
|
24
24
|
const {
|
|
25
25
|
clients: { commerce: n }
|
|
26
26
|
} = e;
|
|
@@ -29,148 +29,168 @@ const mt = () => function(n = {}) {
|
|
|
29
29
|
throw new de("Authentication required");
|
|
30
30
|
} catch (t) {
|
|
31
31
|
const r = t.extensions?.status ?? t.status;
|
|
32
|
-
throw r === 401 ? new de("Authentication required") : r === 403 ? new
|
|
32
|
+
throw r === 401 ? new de("Authentication required") : r === 403 ? new re("You are not allowed to access this resource") : new de("Authentication required");
|
|
33
33
|
}
|
|
34
|
-
},
|
|
34
|
+
}, bt = "auth", wt = {
|
|
35
35
|
typeDefs: "directive @auth on FIELD_DEFINITION",
|
|
36
|
-
transformer: (e) =>
|
|
37
|
-
[
|
|
38
|
-
if (
|
|
36
|
+
transformer: (e) => yn(e, {
|
|
37
|
+
[In.OBJECT_FIELD]: (n) => {
|
|
38
|
+
if (vn(e, n, bt)?.[0]) {
|
|
39
39
|
const r = n.resolve;
|
|
40
|
-
n.resolve = async (i, a, o, s) => (await
|
|
40
|
+
n.resolve = async (i, a, o, s) => (await Ct(o), r?.(i, a, o, s));
|
|
41
41
|
}
|
|
42
42
|
return n;
|
|
43
43
|
}
|
|
44
44
|
})
|
|
45
|
-
},
|
|
45
|
+
}, At = "cacheControl", Ho = (e, n) => {
|
|
46
46
|
const {
|
|
47
47
|
scope: t = "private",
|
|
48
48
|
sMaxAge: r = 0,
|
|
49
49
|
staleWhileRevalidate: i = 0
|
|
50
50
|
} = e;
|
|
51
51
|
return `${n ? "private" : t}, s-maxage=${r}, stale-while-revalidate=${i}`;
|
|
52
|
-
},
|
|
52
|
+
}, $e = (e, n) => typeof e == "number" && typeof n == "number" ? e > n ? n : e : typeof e == "number" ? e : n, Pt = (e, n) => typeof e == "string" && typeof n == "string" ? e === "public" && n === "public" ? "public" : "private" : e || n, Dt = {
|
|
53
53
|
typeDefs: "directive @cacheControl(sMaxAge: Int, staleWhileRevalidate: Int, scope: String) on FIELD_DEFINITION",
|
|
54
|
-
transformer: (e) =>
|
|
55
|
-
[
|
|
56
|
-
const t =
|
|
54
|
+
transformer: (e) => yn(e, {
|
|
55
|
+
[In.OBJECT_FIELD]: (n) => {
|
|
56
|
+
const t = vn(e, n, At)?.[0];
|
|
57
57
|
if (t) {
|
|
58
58
|
const { sMaxAge: r, staleWhileRevalidate: i, scope: a } = t, o = n.resolve;
|
|
59
59
|
n.resolve = (s, c, d, g) => (d.cacheControl = {
|
|
60
|
-
sMaxAge:
|
|
61
|
-
staleWhileRevalidate:
|
|
60
|
+
sMaxAge: $e(d.cacheControl?.sMaxAge, r),
|
|
61
|
+
staleWhileRevalidate: $e(
|
|
62
62
|
d.cacheControl?.staleWhileRevalidate,
|
|
63
63
|
i
|
|
64
64
|
),
|
|
65
|
-
scope:
|
|
65
|
+
scope: Pt(d.cacheControl?.scope, a)
|
|
66
66
|
}, o?.(s, c, d, g));
|
|
67
67
|
}
|
|
68
68
|
return n;
|
|
69
69
|
}
|
|
70
70
|
})
|
|
71
|
-
},
|
|
72
|
-
const r =
|
|
71
|
+
}, Et = (e) => (n, t) => {
|
|
72
|
+
const r = Sn([
|
|
73
73
|
...(e ?? []).map(({ typeDefs: i }) => i),
|
|
74
74
|
t
|
|
75
75
|
]);
|
|
76
76
|
return (e ?? []).reduce(
|
|
77
77
|
(i, { transformer: a }) => a?.(i) ?? i,
|
|
78
|
-
|
|
78
|
+
it({
|
|
79
79
|
typeDefs: r,
|
|
80
80
|
resolvers: n
|
|
81
81
|
})
|
|
82
82
|
);
|
|
83
|
-
},
|
|
84
|
-
name:
|
|
85
|
-
version:
|
|
86
|
-
},
|
|
83
|
+
}, On = "@faststore/api", Cn = "4.10.1", Me = {
|
|
84
|
+
name: On,
|
|
85
|
+
version: Cn
|
|
86
|
+
}, Ue = dt("@faststore/api"), kt = (e, n = "Unknown Graphql Resolver") => (t, r, i, a) => {
|
|
87
87
|
if (!i?.OTEL_ENABLED)
|
|
88
88
|
return e(t, r, i, a);
|
|
89
|
-
const o =
|
|
90
|
-
kind:
|
|
89
|
+
const o = H.trace.getTracer("Graphql").startSpan(n, {
|
|
90
|
+
kind: H.SpanKind.INTERNAL,
|
|
91
91
|
attributes: {
|
|
92
92
|
timestamp: Date.now(),
|
|
93
|
-
"@faststore_version":
|
|
94
|
-
"@faststore_package_name":
|
|
93
|
+
"@faststore_version": Cn,
|
|
94
|
+
"@faststore_package_name": On,
|
|
95
95
|
"@faststore_account_name": i.account,
|
|
96
96
|
"@faststore_environment": process.env.NODE_ENV,
|
|
97
97
|
"@faststore_resolver_parent_type": a?.parentType?.name,
|
|
98
98
|
"@faststore_resolver_field_name": a?.fieldName
|
|
99
99
|
}
|
|
100
|
-
}), s =
|
|
100
|
+
}), s = H.trace.setSpan(H.context.active(), o);
|
|
101
101
|
try {
|
|
102
|
-
const c =
|
|
102
|
+
const c = H.context.with(
|
|
103
103
|
s,
|
|
104
104
|
() => e(t, r, i, a)
|
|
105
105
|
);
|
|
106
106
|
return c instanceof Promise ? c.then(
|
|
107
107
|
(d) => (o.end(), d),
|
|
108
|
-
(d) =>
|
|
108
|
+
(d) => ze(d, o, n)
|
|
109
109
|
) : (o.end(), c);
|
|
110
110
|
} catch (c) {
|
|
111
|
-
return
|
|
111
|
+
return ze(c, o, n);
|
|
112
112
|
}
|
|
113
113
|
};
|
|
114
|
-
function
|
|
115
|
-
throw n.setStatus({ code:
|
|
116
|
-
%o`, e),
|
|
114
|
+
function ze(e, n, t) {
|
|
115
|
+
throw n.setStatus({ code: H.SpanStatusCode.ERROR }), n.recordException(e), n.end(), console.error(`Error at resolver: ${t}:
|
|
116
|
+
%o`, e), Ue("error", `Error at resolver: %s
|
|
117
117
|
%o`, t, e), e;
|
|
118
118
|
}
|
|
119
|
-
class
|
|
119
|
+
class Q extends Error {
|
|
120
120
|
constructor(n, t) {
|
|
121
121
|
super(t), this.extensions = n, this.name = "FastStoreError";
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
|
-
class
|
|
124
|
+
class k extends Q {
|
|
125
125
|
constructor(n) {
|
|
126
126
|
super({ status: 400, type: "BadRequestError" }, n);
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
|
-
class de extends
|
|
129
|
+
class de extends Q {
|
|
130
130
|
constructor(n) {
|
|
131
131
|
super({ status: 401, type: "UnauthorizedError" }, n);
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
|
-
class
|
|
134
|
+
class re extends Q {
|
|
135
135
|
constructor(n) {
|
|
136
136
|
super({ status: 403, type: "ForbiddenError" }, n);
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
|
-
class
|
|
139
|
+
class B extends Q {
|
|
140
140
|
constructor(n) {
|
|
141
141
|
super({ status: 404, type: "NotFoundError" }, n);
|
|
142
142
|
}
|
|
143
143
|
}
|
|
144
|
-
const
|
|
145
|
-
|
|
144
|
+
const Go = (e) => e?.name === "FastStoreError", Xo = (e) => e?.extensions?.type === "BadRequestError", Yo = (e) => e?.extensions?.type === "UnauthorizedError", _t = (e) => e?.extensions?.type === "ForbiddenError", Y = (e) => e?.extensions?.type === "NotFoundError", Tt = `${Me.name}@${Me.version}`, Ut = /authorization|cookie|token|secret|api-?key|appkey/i, bn = "[redacted]", Ve = (e) => {
|
|
145
|
+
if (!e)
|
|
146
|
+
return;
|
|
147
|
+
const n = {}, t = (r, i) => {
|
|
148
|
+
n[r] = Ut.test(r) ? bn : i;
|
|
149
|
+
};
|
|
150
|
+
return Array.isArray(e) ? e.forEach(([r, i]) => t(r, i)) : typeof e.forEach == "function" ? e.forEach((i, a) => t(a, i)) : Object.entries(e).forEach(([r, i]) => t(r, i)), n;
|
|
151
|
+
}, y = async (e, n, t) => {
|
|
152
|
+
const r = await ut(e, {
|
|
146
153
|
...n,
|
|
147
154
|
headers: {
|
|
148
155
|
...n?.headers ?? {},
|
|
149
|
-
"User-Agent":
|
|
156
|
+
"User-Agent": Tt
|
|
150
157
|
}
|
|
151
158
|
});
|
|
152
159
|
if (r.ok)
|
|
153
160
|
return t?.storeCookies && t.storeCookies(r.headers), r.status !== 204 ? r.json() : void 0;
|
|
154
|
-
console.error(
|
|
161
|
+
console.error(
|
|
162
|
+
// Only the URL: a `Request` instance could carry unredacted headers.
|
|
163
|
+
typeof e == "string" ? e : e.url,
|
|
164
|
+
n && {
|
|
165
|
+
...n,
|
|
166
|
+
headers: Ve(n.headers),
|
|
167
|
+
body: n.body ? bn : void 0
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
status: r.status,
|
|
171
|
+
statusText: r.statusText,
|
|
172
|
+
headers: Ve(r.headers)
|
|
173
|
+
}
|
|
174
|
+
);
|
|
155
175
|
const i = await r.text();
|
|
156
176
|
if (typeof r?.status == "number")
|
|
157
177
|
switch (r.status) {
|
|
158
178
|
case 400:
|
|
159
|
-
throw new
|
|
179
|
+
throw new k(i);
|
|
160
180
|
case 401:
|
|
161
181
|
throw new de(i);
|
|
162
182
|
case 403:
|
|
163
|
-
throw new
|
|
183
|
+
throw new re(i);
|
|
164
184
|
case 404:
|
|
165
|
-
throw new
|
|
185
|
+
throw new B(i);
|
|
166
186
|
default:
|
|
167
|
-
throw new
|
|
187
|
+
throw new Q(
|
|
168
188
|
{ status: r.status, type: "UnknownError" },
|
|
169
189
|
i
|
|
170
190
|
);
|
|
171
191
|
}
|
|
172
192
|
throw new Error(i);
|
|
173
|
-
},
|
|
193
|
+
}, Rt = ({ account: e, environment: n }) => {
|
|
174
194
|
const t = `https://${e}.${n}.com.br`;
|
|
175
195
|
return {
|
|
176
196
|
getLocalizedProduct: (r, i) => y(`${t}/api/catalog-dataplane/product/${r}`, {
|
|
@@ -181,7 +201,7 @@ const _o = (e) => e?.name === "FastStoreError", Ro = (e) => e?.extensions?.type
|
|
|
181
201
|
}
|
|
182
202
|
})
|
|
183
203
|
};
|
|
184
|
-
},
|
|
204
|
+
}, wn = (e) => {
|
|
185
205
|
if (!e)
|
|
186
206
|
return e;
|
|
187
207
|
const n = /* @__PURE__ */ new Map(), t = e.split(";"), r = [];
|
|
@@ -195,8 +215,8 @@ const _o = (e) => e?.name === "FastStoreError", Ro = (e) => e?.extensions?.type
|
|
|
195
215
|
}
|
|
196
216
|
}
|
|
197
217
|
}), r.map((i) => `${i}=${n.get(i)}`).join("; ");
|
|
198
|
-
},
|
|
199
|
-
const t = n.match(
|
|
218
|
+
}, Nt = /^([^=]+)=([^;]*)/, Ft = (e, n) => {
|
|
219
|
+
const t = n.match(Nt);
|
|
200
220
|
if (t) {
|
|
201
221
|
const r = t[1], i = t[2];
|
|
202
222
|
e.storage.cookies.set(r, {
|
|
@@ -204,39 +224,39 @@ const _o = (e) => e?.name === "FastStoreError", Ro = (e) => e?.extensions?.type
|
|
|
204
224
|
setCookie: n
|
|
205
225
|
});
|
|
206
226
|
}
|
|
207
|
-
},
|
|
227
|
+
}, Lt = (e, n) => {
|
|
208
228
|
n.getSetCookie().forEach(
|
|
209
|
-
(t) =>
|
|
229
|
+
(t) => Ft(e, t)
|
|
210
230
|
);
|
|
211
|
-
},
|
|
231
|
+
}, Bt = (e) => (n) => Lt(e, n), Ie = (e) => {
|
|
212
232
|
if (!e.headers?.cookie)
|
|
213
233
|
return null;
|
|
214
|
-
const n =
|
|
234
|
+
const n = wn(e.headers.cookie), t = Array.from(e.storage.cookies.entries());
|
|
215
235
|
return t.length === 0 ? n : t.reduce(
|
|
216
|
-
(r, [i, { value: a }]) =>
|
|
236
|
+
(r, [i, { value: a }]) => $t(
|
|
217
237
|
r,
|
|
218
238
|
i,
|
|
219
239
|
a
|
|
220
240
|
),
|
|
221
241
|
n
|
|
222
242
|
);
|
|
223
|
-
},
|
|
243
|
+
}, An = (e) => function(t) {
|
|
224
244
|
const r = Ie(e);
|
|
225
245
|
return r ? {
|
|
226
246
|
...t,
|
|
227
247
|
cookie: r
|
|
228
248
|
} : t;
|
|
229
|
-
},
|
|
230
|
-
const t =
|
|
231
|
-
return
|
|
232
|
-
},
|
|
249
|
+
}, z = (e, n) => {
|
|
250
|
+
const t = wn(e);
|
|
251
|
+
return ae(t)[`VtexIdclientAutCookie_${n}`] || "";
|
|
252
|
+
}, $t = (e, n, t) => {
|
|
233
253
|
const r = new RegExp(`(${n})=([^;]*)`), i = e.match(r);
|
|
234
254
|
return i ? e.replace(
|
|
235
255
|
i[0],
|
|
236
256
|
`${i[1]}=${t}`
|
|
237
257
|
) : `${e};${n}=${t}`;
|
|
238
258
|
};
|
|
239
|
-
function
|
|
259
|
+
function G(e) {
|
|
240
260
|
if (!e)
|
|
241
261
|
return null;
|
|
242
262
|
try {
|
|
@@ -245,12 +265,12 @@ function H(e) {
|
|
|
245
265
|
return null;
|
|
246
266
|
}
|
|
247
267
|
}
|
|
248
|
-
const
|
|
268
|
+
const Mt = "storefront/faststore.recommendation-shelf@v4", ne = {
|
|
249
269
|
method: "POST",
|
|
250
270
|
headers: {
|
|
251
271
|
"content-type": "application/json"
|
|
252
272
|
}
|
|
253
|
-
},
|
|
273
|
+
}, zt = 100, se = /* @__PURE__ */ new Set(), Vt = (e) => e.split("/").map(encodeURIComponent).join("/"), Se = (e) => e ? { headers: { "Accept-Language": e } } : void 0, xt = /^\d{4}-\d{2}-\d{2}$/, qt = /* @__PURE__ */ new Set([
|
|
254
274
|
"Draft",
|
|
255
275
|
"Requested",
|
|
256
276
|
"InReview",
|
|
@@ -261,7 +281,7 @@ const _t = "storefront/faststore.recommendation-shelf@v4", Z = {
|
|
|
261
281
|
"ConvertedToCart",
|
|
262
282
|
"ConvertedToOrder"
|
|
263
283
|
]);
|
|
264
|
-
function
|
|
284
|
+
function jt({
|
|
265
285
|
page: e,
|
|
266
286
|
perPage: n,
|
|
267
287
|
status: t,
|
|
@@ -284,19 +304,19 @@ function Nt({
|
|
|
284
304
|
["expiresAtFrom", a],
|
|
285
305
|
["expiresAtTo", o]
|
|
286
306
|
])
|
|
287
|
-
if (c && !
|
|
307
|
+
if (c && !xt.test(c))
|
|
288
308
|
throw new Error(
|
|
289
309
|
`listUserQuotes: invalid ${s} "${c}" — must be YYYY-MM-DD`
|
|
290
310
|
);
|
|
291
311
|
if (t && t.length > 0) {
|
|
292
|
-
const s = t.filter((c) => !
|
|
312
|
+
const s = t.filter((c) => !qt.has(c));
|
|
293
313
|
if (s.length > 0)
|
|
294
314
|
throw new Error(
|
|
295
315
|
`listUserQuotes: invalid status values: ${s.join(", ")}`
|
|
296
316
|
);
|
|
297
317
|
}
|
|
298
318
|
}
|
|
299
|
-
function
|
|
319
|
+
function Wt({
|
|
300
320
|
page: e,
|
|
301
321
|
perPage: n,
|
|
302
322
|
status: t,
|
|
@@ -309,17 +329,17 @@ function Lt({
|
|
|
309
329
|
const c = new URLSearchParams();
|
|
310
330
|
return e && c.append("pageNumber", e.toString()), n && c.append("pageSize", n.toString()), t?.forEach((d) => c.append("status", d)), r && c.append("createdAtFrom", r), i && c.append("createdAtTo", i), a && c.append("expiresAtFrom", a), o && c.append("expiresAtTo", o), s?.trim() && c.append("label", s.trim()), c;
|
|
311
331
|
}
|
|
312
|
-
const
|
|
313
|
-
const a = `https://${e}.${n}.com.br`, o =
|
|
332
|
+
const Ht = ({ account: e, environment: n, incrementAddress: t, subDomainPrefix: r }, i) => {
|
|
333
|
+
const a = `https://${e}.${n}.com.br`, o = Bt(i), s = An(i), c = Ot(), d = new Headers(i.headers).get("x-forwarded-host") ?? i.headers?.host ?? "", g = r && r.map((l) => l + ".").find((l) => d.includes(l)) || "", u = d.replace(g, ""), f = `${a}/api/recommend-bff/v2`, h = s({
|
|
314
334
|
accept: "application/json",
|
|
315
335
|
"content-type": "application/json",
|
|
316
|
-
"x-vtex-rec-origin": `${e}/${
|
|
336
|
+
"x-vtex-rec-origin": `${e}/${Mt}`
|
|
317
337
|
}), I = (l = {}) => {
|
|
318
|
-
const
|
|
338
|
+
const p = z(Ie(i) ?? "", e);
|
|
319
339
|
return s({
|
|
320
340
|
...l,
|
|
321
|
-
"X-FORWARDED-HOST":
|
|
322
|
-
...
|
|
341
|
+
"X-FORWARDED-HOST": u,
|
|
342
|
+
...p ? { [`VtexIdclientAutCookie_${e}`]: p } : {}
|
|
323
343
|
});
|
|
324
344
|
};
|
|
325
345
|
return {
|
|
@@ -352,36 +372,36 @@ const Bt = ({ account: e, environment: n, incrementAddress: t, subDomainPrefix:
|
|
|
352
372
|
// The by-linkid endpoints resolve a slug to a single catalog entity
|
|
353
373
|
// (or 404 when there is no match). We surface a 404 as `null` so the
|
|
354
374
|
// loader can cascade category → brand → collection.
|
|
355
|
-
category: async (l,
|
|
375
|
+
category: async (l, p) => {
|
|
356
376
|
try {
|
|
357
377
|
return await y(
|
|
358
|
-
`${a}/api/catalog_system/pub/category/by-linkid/${
|
|
359
|
-
Se(
|
|
378
|
+
`${a}/api/catalog_system/pub/category/by-linkid/${Vt(l)}`,
|
|
379
|
+
Se(p)
|
|
360
380
|
);
|
|
361
381
|
} catch (m) {
|
|
362
|
-
if (
|
|
382
|
+
if (Y(m)) return null;
|
|
363
383
|
throw m;
|
|
364
384
|
}
|
|
365
385
|
},
|
|
366
|
-
brand: async (l,
|
|
386
|
+
brand: async (l, p) => {
|
|
367
387
|
try {
|
|
368
388
|
return await y(
|
|
369
389
|
`${a}/api/catalog_system/pub/brand/by-linkid/${encodeURIComponent(l)}`,
|
|
370
|
-
Se(
|
|
390
|
+
Se(p)
|
|
371
391
|
);
|
|
372
392
|
} catch (m) {
|
|
373
|
-
if (
|
|
393
|
+
if (Y(m)) return null;
|
|
374
394
|
throw m;
|
|
375
395
|
}
|
|
376
396
|
},
|
|
377
|
-
collection: async (l,
|
|
397
|
+
collection: async (l, p) => {
|
|
378
398
|
try {
|
|
379
399
|
return await y(
|
|
380
400
|
`${a}/api/catalog_system/pub/collection/by-linkid/${encodeURIComponent(l)}`,
|
|
381
|
-
Se(
|
|
401
|
+
Se(p)
|
|
382
402
|
);
|
|
383
403
|
} catch (m) {
|
|
384
|
-
if (
|
|
404
|
+
if (Y(m)) return null;
|
|
385
405
|
throw m;
|
|
386
406
|
}
|
|
387
407
|
}
|
|
@@ -389,7 +409,7 @@ const Bt = ({ account: e, environment: n, incrementAddress: t, subDomainPrefix:
|
|
|
389
409
|
products: {
|
|
390
410
|
crossselling: ({
|
|
391
411
|
type: l,
|
|
392
|
-
productId:
|
|
412
|
+
productId: p,
|
|
393
413
|
groupByProduct: m = !0
|
|
394
414
|
}) => {
|
|
395
415
|
const S = new URLSearchParams({
|
|
@@ -397,7 +417,7 @@ const Bt = ({ account: e, environment: n, incrementAddress: t, subDomainPrefix:
|
|
|
397
417
|
groupByProduct: m.toString()
|
|
398
418
|
});
|
|
399
419
|
return y(
|
|
400
|
-
`${a}/api/catalog_system/pub/products/crossselling/${l}/${
|
|
420
|
+
`${a}/api/catalog_system/pub/products/crossselling/${l}/${p}?${S}`,
|
|
401
421
|
void 0,
|
|
402
422
|
{ storeCookies: o }
|
|
403
423
|
);
|
|
@@ -405,17 +425,17 @@ const Bt = ({ account: e, environment: n, incrementAddress: t, subDomainPrefix:
|
|
|
405
425
|
}
|
|
406
426
|
},
|
|
407
427
|
checkout: {
|
|
408
|
-
simulation: (l, { salesChannel:
|
|
428
|
+
simulation: (l, { salesChannel: p } = i.storage.channel) => {
|
|
409
429
|
const m = new URLSearchParams({
|
|
410
|
-
sc:
|
|
430
|
+
sc: p
|
|
411
431
|
}), S = s({
|
|
412
432
|
"content-type": "application/json",
|
|
413
|
-
"X-FORWARDED-HOST":
|
|
433
|
+
"X-FORWARDED-HOST": u
|
|
414
434
|
});
|
|
415
435
|
return y(
|
|
416
436
|
`${a}/api/checkout/pub/orderForms/simulation?${m.toString()}`,
|
|
417
437
|
{
|
|
418
|
-
...
|
|
438
|
+
...ne,
|
|
419
439
|
headers: S,
|
|
420
440
|
body: JSON.stringify(l)
|
|
421
441
|
},
|
|
@@ -424,31 +444,31 @@ const Bt = ({ account: e, environment: n, incrementAddress: t, subDomainPrefix:
|
|
|
424
444
|
},
|
|
425
445
|
shippingData: ({
|
|
426
446
|
id: l,
|
|
427
|
-
index:
|
|
447
|
+
index: p,
|
|
428
448
|
deliveryMode: m,
|
|
429
449
|
selectedAddresses: S
|
|
430
450
|
}, v) => {
|
|
431
|
-
const
|
|
451
|
+
const O = v ? {
|
|
432
452
|
startDateUtc: m?.deliveryWindow?.startDate,
|
|
433
453
|
endDateUtc: m?.deliveryWindow?.endDate
|
|
434
454
|
} : null, C = {
|
|
435
|
-
logisticsInfo: Array.from({ length:
|
|
436
|
-
itemIndex:
|
|
455
|
+
logisticsInfo: Array.from({ length: p }, (w, b) => ({
|
|
456
|
+
itemIndex: b,
|
|
437
457
|
selectedDeliveryChannel: m?.deliveryChannel || null,
|
|
438
458
|
selectedSla: m?.deliveryMethod || null,
|
|
439
|
-
deliveryWindow:
|
|
459
|
+
deliveryWindow: O
|
|
440
460
|
})),
|
|
441
461
|
selectedAddresses: S,
|
|
442
462
|
clearAddressIfPostalCodeNotFound: t
|
|
443
|
-
},
|
|
463
|
+
}, T = s({
|
|
444
464
|
"content-type": "application/json",
|
|
445
|
-
"X-FORWARDED-HOST":
|
|
465
|
+
"X-FORWARDED-HOST": u
|
|
446
466
|
});
|
|
447
467
|
return y(
|
|
448
468
|
`${a}/api/checkout/pub/orderForm/${l}/attachments/shippingData`,
|
|
449
469
|
{
|
|
450
|
-
...
|
|
451
|
-
headers:
|
|
470
|
+
...ne,
|
|
471
|
+
headers: T,
|
|
452
472
|
body: JSON.stringify(C)
|
|
453
473
|
},
|
|
454
474
|
{ storeCookies: o }
|
|
@@ -456,17 +476,17 @@ const Bt = ({ account: e, environment: n, incrementAddress: t, subDomainPrefix:
|
|
|
456
476
|
},
|
|
457
477
|
marketingData: ({
|
|
458
478
|
id: l,
|
|
459
|
-
marketingData:
|
|
479
|
+
marketingData: p
|
|
460
480
|
}) => {
|
|
461
481
|
const m = s({
|
|
462
482
|
"content-type": "application/json",
|
|
463
|
-
"X-FORWARDED-HOST":
|
|
483
|
+
"X-FORWARDED-HOST": u
|
|
464
484
|
});
|
|
465
485
|
return y(
|
|
466
486
|
`${a}/api/checkout/pub/orderForm/${l}/attachments/marketingData`,
|
|
467
487
|
{
|
|
468
488
|
headers: m,
|
|
469
|
-
body: JSON.stringify(
|
|
489
|
+
body: JSON.stringify(p),
|
|
470
490
|
method: "POST"
|
|
471
491
|
},
|
|
472
492
|
{ storeCookies: o }
|
|
@@ -474,17 +494,17 @@ const Bt = ({ account: e, environment: n, incrementAddress: t, subDomainPrefix:
|
|
|
474
494
|
},
|
|
475
495
|
clientPreferencesData: ({
|
|
476
496
|
id: l,
|
|
477
|
-
clientPreferencesData:
|
|
497
|
+
clientPreferencesData: p
|
|
478
498
|
}) => {
|
|
479
499
|
const m = s({
|
|
480
500
|
"content-type": "application/json",
|
|
481
|
-
"X-FORWARDED-HOST":
|
|
501
|
+
"X-FORWARDED-HOST": u
|
|
482
502
|
});
|
|
483
503
|
return y(
|
|
484
504
|
`${a}/api/checkout/pub/orderForm/${l}/attachments/clientPreferencesData`,
|
|
485
505
|
{
|
|
486
506
|
headers: m,
|
|
487
|
-
body: JSON.stringify(
|
|
507
|
+
body: JSON.stringify(p),
|
|
488
508
|
method: "POST"
|
|
489
509
|
},
|
|
490
510
|
{ storeCookies: o }
|
|
@@ -492,60 +512,60 @@ const Bt = ({ account: e, environment: n, incrementAddress: t, subDomainPrefix:
|
|
|
492
512
|
},
|
|
493
513
|
orderForm: ({
|
|
494
514
|
id: l,
|
|
495
|
-
refreshOutdatedData:
|
|
515
|
+
refreshOutdatedData: p = !0,
|
|
496
516
|
channel: m = i.storage.channel,
|
|
497
517
|
preserveSalesChannel: S = !1
|
|
498
518
|
}) => {
|
|
499
|
-
const { salesChannel: v } = m,
|
|
519
|
+
const { salesChannel: v } = m, O = s({
|
|
500
520
|
"content-type": "application/json",
|
|
501
|
-
"X-FORWARDED-HOST":
|
|
521
|
+
"X-FORWARDED-HOST": u
|
|
502
522
|
}), C = new URLSearchParams();
|
|
503
|
-
(!S || !l) && C.set("sc", v), l && C.set("refreshOutdatedData",
|
|
504
|
-
const
|
|
523
|
+
(!S || !l) && C.set("sc", v), l && C.set("refreshOutdatedData", p.toString());
|
|
524
|
+
const T = l ? `/${l}` : "", w = `${a}/api/checkout/pub/orderForm${T}?${C}`;
|
|
505
525
|
return y(
|
|
506
|
-
|
|
526
|
+
w,
|
|
507
527
|
{
|
|
508
|
-
...
|
|
509
|
-
headers:
|
|
528
|
+
...ne,
|
|
529
|
+
headers: O,
|
|
510
530
|
...l ? {} : { body: "{}" }
|
|
511
531
|
},
|
|
512
532
|
{ storeCookies: o }
|
|
513
533
|
);
|
|
514
534
|
},
|
|
515
535
|
clearOrderFormMessages: ({ id: l }) => {
|
|
516
|
-
const
|
|
536
|
+
const p = s({
|
|
517
537
|
"content-type": "application/json",
|
|
518
|
-
"X-FORWARDED-HOST":
|
|
538
|
+
"X-FORWARDED-HOST": u
|
|
519
539
|
});
|
|
520
540
|
return y(
|
|
521
541
|
`${a}/api/checkout/pub/orderForm/${l}/messages/clear`,
|
|
522
542
|
{
|
|
523
|
-
...
|
|
524
|
-
headers:
|
|
543
|
+
...ne,
|
|
544
|
+
headers: p,
|
|
525
545
|
body: "{}"
|
|
526
546
|
}
|
|
527
547
|
);
|
|
528
548
|
},
|
|
529
549
|
updateOrderFormItems: ({
|
|
530
550
|
id: l,
|
|
531
|
-
orderItems:
|
|
551
|
+
orderItems: p,
|
|
532
552
|
allowOutdatedData: m = "paymentData",
|
|
533
553
|
salesChannel: S = i.storage.channel.salesChannel,
|
|
534
554
|
shouldSplitItem: v = !0
|
|
535
555
|
}) => {
|
|
536
|
-
const
|
|
556
|
+
const O = new URLSearchParams({
|
|
537
557
|
allowOutdatedData: m,
|
|
538
558
|
sc: S
|
|
539
559
|
}), C = s({
|
|
540
560
|
"content-type": "application/json",
|
|
541
|
-
"X-FORWARDED-HOST":
|
|
561
|
+
"X-FORWARDED-HOST": u
|
|
542
562
|
});
|
|
543
563
|
return y(
|
|
544
|
-
`${a}/api/checkout/pub/orderForm/${l}/items?${
|
|
564
|
+
`${a}/api/checkout/pub/orderForm/${l}/items?${O}`,
|
|
545
565
|
{
|
|
546
566
|
headers: C,
|
|
547
567
|
body: JSON.stringify({
|
|
548
|
-
orderItems:
|
|
568
|
+
orderItems: p,
|
|
549
569
|
noSplitItem: !v
|
|
550
570
|
}),
|
|
551
571
|
method: "PATCH"
|
|
@@ -555,16 +575,16 @@ const Bt = ({ account: e, environment: n, incrementAddress: t, subDomainPrefix:
|
|
|
555
575
|
},
|
|
556
576
|
setCustomData: ({
|
|
557
577
|
id: l,
|
|
558
|
-
appId:
|
|
578
|
+
appId: p,
|
|
559
579
|
key: m,
|
|
560
580
|
value: S
|
|
561
581
|
}) => {
|
|
562
582
|
const v = s({
|
|
563
583
|
"content-type": "application/json",
|
|
564
|
-
"X-FORWARDED-HOST":
|
|
584
|
+
"X-FORWARDED-HOST": u
|
|
565
585
|
});
|
|
566
586
|
return y(
|
|
567
|
-
`${a}/api/checkout/pub/orderForm/${l}/customData/${
|
|
587
|
+
`${a}/api/checkout/pub/orderForm/${l}/customData/${p}/${m}`,
|
|
568
588
|
{
|
|
569
589
|
headers: v,
|
|
570
590
|
body: JSON.stringify({ value: S }),
|
|
@@ -574,7 +594,7 @@ const Bt = ({ account: e, environment: n, incrementAddress: t, subDomainPrefix:
|
|
|
574
594
|
},
|
|
575
595
|
region: async ({
|
|
576
596
|
postalCode: l,
|
|
577
|
-
geoCoordinates:
|
|
597
|
+
geoCoordinates: p,
|
|
578
598
|
country: m,
|
|
579
599
|
salesChannel: S
|
|
580
600
|
}) => {
|
|
@@ -584,14 +604,14 @@ const Bt = ({ account: e, environment: n, incrementAddress: t, subDomainPrefix:
|
|
|
584
604
|
});
|
|
585
605
|
l ? v.append("postalCode", l) : v.append(
|
|
586
606
|
"geoCoordinates",
|
|
587
|
-
`${
|
|
607
|
+
`${p?.longitude};${p?.latitude}`
|
|
588
608
|
);
|
|
589
|
-
const
|
|
609
|
+
const O = `${a}/api/checkout/pub/regions/?${v.toString()}`, C = s({
|
|
590
610
|
"content-type": "application/json",
|
|
591
|
-
"X-FORWARDED-HOST":
|
|
611
|
+
"X-FORWARDED-HOST": u
|
|
592
612
|
});
|
|
593
613
|
return y(
|
|
594
|
-
|
|
614
|
+
O,
|
|
595
615
|
{
|
|
596
616
|
headers: C
|
|
597
617
|
},
|
|
@@ -600,14 +620,14 @@ const Bt = ({ account: e, environment: n, incrementAddress: t, subDomainPrefix:
|
|
|
600
620
|
},
|
|
601
621
|
address: async ({
|
|
602
622
|
postalCode: l,
|
|
603
|
-
country:
|
|
623
|
+
country: p
|
|
604
624
|
}) => {
|
|
605
625
|
const m = s({
|
|
606
626
|
"content-type": "application/json",
|
|
607
|
-
"X-FORWARDED-HOST":
|
|
627
|
+
"X-FORWARDED-HOST": u
|
|
608
628
|
});
|
|
609
629
|
return y(
|
|
610
|
-
`${a}/api/checkout/pub/postal-code/${
|
|
630
|
+
`${a}/api/checkout/pub/postal-code/${p}/${l}`,
|
|
611
631
|
{
|
|
612
632
|
headers: m
|
|
613
633
|
},
|
|
@@ -616,12 +636,12 @@ const Bt = ({ account: e, environment: n, incrementAddress: t, subDomainPrefix:
|
|
|
616
636
|
},
|
|
617
637
|
cancelOrder: ({
|
|
618
638
|
orderId: l,
|
|
619
|
-
customerEmail:
|
|
639
|
+
customerEmail: p,
|
|
620
640
|
reason: m
|
|
621
641
|
}) => {
|
|
622
642
|
const S = s({
|
|
623
643
|
"content-type": "application/json",
|
|
624
|
-
"X-FORWARDED-HOST":
|
|
644
|
+
"X-FORWARDED-HOST": u
|
|
625
645
|
});
|
|
626
646
|
return y(
|
|
627
647
|
`${a}/api/checkout/pub/orders/${l}/user-cancel-request`,
|
|
@@ -629,7 +649,7 @@ const Bt = ({ account: e, environment: n, incrementAddress: t, subDomainPrefix:
|
|
|
629
649
|
method: "POST",
|
|
630
650
|
headers: S,
|
|
631
651
|
body: JSON.stringify({
|
|
632
|
-
customerEmail:
|
|
652
|
+
customerEmail: p,
|
|
633
653
|
reason: m
|
|
634
654
|
})
|
|
635
655
|
},
|
|
@@ -638,16 +658,16 @@ const Bt = ({ account: e, environment: n, incrementAddress: t, subDomainPrefix:
|
|
|
638
658
|
}
|
|
639
659
|
},
|
|
640
660
|
session: (l) => {
|
|
641
|
-
const
|
|
642
|
-
|
|
661
|
+
const p = new URLSearchParams(l);
|
|
662
|
+
p.set(
|
|
643
663
|
"items",
|
|
644
664
|
"profile.id,profile.email,profile.firstName,profile.lastName,profile.phone,shopper.firstName,shopper.lastName,shopper.organizationManager,shopper.availableContracts,shopper.activeContractId,store.channel,store.countryCode,store.cultureInfo,store.currencyCode,store.currencySymbol,authentication.customerId,authentication.storeUserId,authentication.storeUserEmail,authentication.unitId,authentication.unitName,checkout.regionId,public.postalCode"
|
|
645
665
|
);
|
|
646
666
|
const m = s({
|
|
647
667
|
"content-type": "application/json"
|
|
648
|
-
}), S =
|
|
668
|
+
}), S = ae(i?.headers?.cookie ?? "")?.vtex_session;
|
|
649
669
|
return y(
|
|
650
|
-
`${a}/api/sessions?${
|
|
670
|
+
`${a}/api/sessions?${p.toString()}`,
|
|
651
671
|
{
|
|
652
672
|
method: S ? "PATCH" : "POST",
|
|
653
673
|
headers: m,
|
|
@@ -663,97 +683,138 @@ const Bt = ({ account: e, environment: n, incrementAddress: t, subDomainPrefix:
|
|
|
663
683
|
* no app keys involved.
|
|
664
684
|
*/
|
|
665
685
|
attachedContracts: (l) => {
|
|
666
|
-
const
|
|
686
|
+
const p = s({
|
|
667
687
|
"content-type": "application/json"
|
|
668
688
|
});
|
|
669
689
|
return y(
|
|
670
690
|
`https://${e}.myvtex.com/_v/store-front/units/${encodeURIComponent(
|
|
671
691
|
l
|
|
672
692
|
)}/contracts/attached?details=true`,
|
|
673
|
-
{ headers:
|
|
693
|
+
{ headers: p },
|
|
674
694
|
{ storeCookies: o }
|
|
675
695
|
);
|
|
676
696
|
}
|
|
677
697
|
},
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
698
|
+
/**
|
|
699
|
+
* Creates a newsletter subscription in the `NL` Master Data entity.
|
|
700
|
+
*
|
|
701
|
+
* With `FS_NEWSLETTER_APP_KEY`/`FS_NEWSLETTER_APP_TOKEN` set, the document is
|
|
702
|
+
* created with a `POST` authenticated by that dedicated key, so `NL` fields
|
|
703
|
+
* can stay private. The request is create-only: the body is built here from
|
|
704
|
+
* the validated fields and never carries a document id, so the caller can't
|
|
705
|
+
* reach an existing record.
|
|
706
|
+
*
|
|
707
|
+
* Without the credentials, it falls back to the legacy anonymous `PATCH`,
|
|
708
|
+
* which only works while `NL` fields are public.
|
|
709
|
+
*/
|
|
710
|
+
subscribeToNewsletter: ({
|
|
711
|
+
name: l,
|
|
712
|
+
email: p
|
|
713
|
+
}) => {
|
|
714
|
+
const m = JSON.stringify({
|
|
715
|
+
...l ? { name: l } : {},
|
|
716
|
+
email: p,
|
|
717
|
+
isNewsletterOptIn: !0
|
|
718
|
+
}), S = process.env.FS_NEWSLETTER_APP_KEY, v = process.env.FS_NEWSLETTER_APP_TOKEN;
|
|
719
|
+
if (S && v)
|
|
720
|
+
return y(`${a}/api/dataentities/NL/documents`, {
|
|
721
|
+
method: "POST",
|
|
722
|
+
headers: {
|
|
723
|
+
"content-type": "application/json",
|
|
724
|
+
accept: "application/json",
|
|
725
|
+
"X-VTEX-API-AppKey": S,
|
|
726
|
+
"X-VTEX-API-AppToken": v
|
|
727
|
+
},
|
|
728
|
+
body: m
|
|
729
|
+
});
|
|
730
|
+
if (!se.has(e)) {
|
|
731
|
+
se.size >= zt && se.clear(), se.add(e);
|
|
732
|
+
const O = [
|
|
733
|
+
!S && "FS_NEWSLETTER_APP_KEY",
|
|
734
|
+
!v && "FS_NEWSLETTER_APP_TOKEN"
|
|
735
|
+
].filter(Boolean), C = `[subscribeToNewsletter] ${O.join(" and ")} ${O.length > 1 ? "are" : "is"} not set. Falling back to an anonymous Master Data request, which requires public fields in the NL entity. Configure both credentials and make the NL fields private.`;
|
|
736
|
+
console.warn(C), Ue("warn", "%s", C);
|
|
737
|
+
}
|
|
738
|
+
return y(
|
|
739
|
+
`${a}/api/dataentities/NL/documents/`,
|
|
740
|
+
{
|
|
741
|
+
...ne,
|
|
742
|
+
body: m,
|
|
743
|
+
method: "PATCH"
|
|
744
|
+
},
|
|
745
|
+
{ storeCookies: o }
|
|
746
|
+
);
|
|
747
|
+
},
|
|
687
748
|
profile: {
|
|
688
749
|
addresses: async (l) => {
|
|
689
|
-
const
|
|
750
|
+
const p = s({
|
|
690
751
|
"content-type": "application/json",
|
|
691
|
-
"X-FORWARDED-HOST":
|
|
752
|
+
"X-FORWARDED-HOST": u
|
|
692
753
|
});
|
|
693
754
|
return y(
|
|
694
755
|
`${a}/api/profile-system/pvt/profiles/${l}/addresses`,
|
|
695
|
-
{ headers:
|
|
756
|
+
{ headers: p },
|
|
696
757
|
{ storeCookies: o }
|
|
697
758
|
);
|
|
698
759
|
}
|
|
699
760
|
},
|
|
700
761
|
oms: {
|
|
701
762
|
userOrder: ({ orderId: l }) => {
|
|
702
|
-
const
|
|
763
|
+
const p = s({
|
|
703
764
|
"content-type": "application/json",
|
|
704
|
-
"X-FORWARDED-HOST":
|
|
765
|
+
"X-FORWARDED-HOST": u
|
|
705
766
|
});
|
|
706
767
|
return y(
|
|
707
768
|
`${a}/api/oms/user/orders/${l}`,
|
|
708
769
|
{
|
|
709
770
|
method: "GET",
|
|
710
|
-
headers:
|
|
771
|
+
headers: p
|
|
711
772
|
},
|
|
712
773
|
{ storeCookies: o }
|
|
713
774
|
);
|
|
714
775
|
},
|
|
715
776
|
listUserOrders: ({
|
|
716
777
|
page: l,
|
|
717
|
-
status:
|
|
778
|
+
status: p,
|
|
718
779
|
dateInitial: m,
|
|
719
780
|
dateFinal: S,
|
|
720
781
|
text: v,
|
|
721
|
-
clientEmail:
|
|
782
|
+
clientEmail: O,
|
|
722
783
|
perPage: C,
|
|
723
|
-
pendingMyApproval:
|
|
784
|
+
pendingMyApproval: T
|
|
724
785
|
}) => {
|
|
725
|
-
const
|
|
786
|
+
const w = new URLSearchParams();
|
|
726
787
|
if (m) {
|
|
727
|
-
const
|
|
788
|
+
const A = new Date(m).setHours(
|
|
728
789
|
0,
|
|
729
790
|
0,
|
|
730
791
|
0,
|
|
731
792
|
0
|
|
732
793
|
);
|
|
733
|
-
m = new Date(
|
|
794
|
+
m = new Date(A).toISOString();
|
|
734
795
|
}
|
|
735
796
|
if (S) {
|
|
736
|
-
const
|
|
797
|
+
const A = new Date(S).setHours(
|
|
737
798
|
23,
|
|
738
799
|
59,
|
|
739
800
|
59,
|
|
740
801
|
999
|
|
741
802
|
);
|
|
742
|
-
S = new Date(
|
|
803
|
+
S = new Date(A).toISOString();
|
|
743
804
|
}
|
|
744
|
-
v &&
|
|
805
|
+
v && w.append("text", v), p && p.length > 0 && w.append("status", p.filter(Boolean).join(",")), m && S ? w.append(
|
|
745
806
|
"creation_date",
|
|
746
807
|
`creationDate:[${m} TO ${S}]`
|
|
747
|
-
) : m ?
|
|
748
|
-
const
|
|
808
|
+
) : m ? w.append("creation_date", `creationDate:[${m} TO *]`) : S && w.append("creation_date", `creationDate:[* TO ${S}]`), O && w.append("clientEmail", O), l && w.append("page", l.toString()), C && w.append("per_page", C.toString()), T && w.append("my_pending_approvals", String(!0));
|
|
809
|
+
const b = s({
|
|
749
810
|
"content-type": "application/json",
|
|
750
|
-
"X-FORWARDED-HOST":
|
|
811
|
+
"X-FORWARDED-HOST": u
|
|
751
812
|
});
|
|
752
813
|
return y(
|
|
753
|
-
`${a}/api/oms/user/orders?${
|
|
814
|
+
`${a}/api/oms/user/orders?${w.toString()}`,
|
|
754
815
|
{
|
|
755
816
|
method: "GET",
|
|
756
|
-
headers:
|
|
817
|
+
headers: b
|
|
757
818
|
},
|
|
758
819
|
{ storeCookies: o }
|
|
759
820
|
);
|
|
@@ -761,32 +822,32 @@ const Bt = ({ account: e, environment: n, incrementAddress: t, subDomainPrefix:
|
|
|
761
822
|
getCommercialAuthorizationsByOrderId: ({
|
|
762
823
|
orderId: l
|
|
763
824
|
}) => {
|
|
764
|
-
const
|
|
825
|
+
const p = s({
|
|
765
826
|
"content-type": "application/json",
|
|
766
|
-
"X-FORWARDED-HOST":
|
|
827
|
+
"X-FORWARDED-HOST": u
|
|
767
828
|
});
|
|
768
829
|
return y(
|
|
769
830
|
`${a}/${e}/commercial-authorizations/order/${l}`,
|
|
770
831
|
{
|
|
771
832
|
method: "GET",
|
|
772
|
-
headers:
|
|
833
|
+
headers: p
|
|
773
834
|
},
|
|
774
835
|
{ storeCookies: o }
|
|
775
836
|
);
|
|
776
837
|
},
|
|
777
838
|
processOrderAuthorization: async ({
|
|
778
839
|
orderAuthorizationId: l,
|
|
779
|
-
dimensionId:
|
|
840
|
+
dimensionId: p,
|
|
780
841
|
ruleId: m,
|
|
781
842
|
approved: S
|
|
782
843
|
}) => {
|
|
783
844
|
const v = s({
|
|
784
845
|
"content-type": "application/json",
|
|
785
|
-
"X-FORWARDED-HOST":
|
|
786
|
-
}),
|
|
846
|
+
"X-FORWARDED-HOST": u
|
|
847
|
+
}), T = {
|
|
787
848
|
params: {
|
|
788
849
|
ruleId: m,
|
|
789
|
-
dimensionId:
|
|
850
|
+
dimensionId: p,
|
|
790
851
|
score: S ? 100 : 0
|
|
791
852
|
}
|
|
792
853
|
};
|
|
@@ -795,7 +856,7 @@ const Bt = ({ account: e, environment: n, incrementAddress: t, subDomainPrefix:
|
|
|
795
856
|
{
|
|
796
857
|
method: "POST",
|
|
797
858
|
headers: v,
|
|
798
|
-
body: JSON.stringify(
|
|
859
|
+
body: JSON.stringify(T)
|
|
799
860
|
},
|
|
800
861
|
{ storeCookies: o }
|
|
801
862
|
);
|
|
@@ -805,7 +866,7 @@ const Bt = ({ account: e, environment: n, incrementAddress: t, subDomainPrefix:
|
|
|
805
866
|
listCreditCards: () => {
|
|
806
867
|
const l = s({
|
|
807
868
|
"content-type": "application/json",
|
|
808
|
-
"X-FORWARDED-HOST":
|
|
869
|
+
"X-FORWARDED-HOST": u
|
|
809
870
|
});
|
|
810
871
|
return y(
|
|
811
872
|
`${a}/api/saved-cards/credit-card?an=${e}`,
|
|
@@ -821,15 +882,15 @@ const Bt = ({ account: e, environment: n, incrementAddress: t, subDomainPrefix:
|
|
|
821
882
|
getUnitByUserId: ({
|
|
822
883
|
userId: l
|
|
823
884
|
}) => {
|
|
824
|
-
const
|
|
885
|
+
const p = s({
|
|
825
886
|
"content-type": "application/json",
|
|
826
|
-
"X-FORWARDED-HOST":
|
|
887
|
+
"X-FORWARDED-HOST": u
|
|
827
888
|
});
|
|
828
889
|
return y(
|
|
829
890
|
`${a}/api/units/v1/${l}/unit`,
|
|
830
891
|
{
|
|
831
892
|
method: "GET",
|
|
832
|
-
headers:
|
|
893
|
+
headers: p
|
|
833
894
|
},
|
|
834
895
|
{}
|
|
835
896
|
);
|
|
@@ -837,15 +898,15 @@ const Bt = ({ account: e, environment: n, incrementAddress: t, subDomainPrefix:
|
|
|
837
898
|
getOrgUnitById: ({
|
|
838
899
|
orgUnitId: l
|
|
839
900
|
}) => {
|
|
840
|
-
const
|
|
901
|
+
const p = s({
|
|
841
902
|
"content-type": "application/json",
|
|
842
|
-
"X-FORWARDED-HOST":
|
|
903
|
+
"X-FORWARDED-HOST": u
|
|
843
904
|
});
|
|
844
905
|
return y(
|
|
845
906
|
`${a}/api/units/v1/${l}`,
|
|
846
907
|
{
|
|
847
908
|
method: "GET",
|
|
848
|
-
headers:
|
|
909
|
+
headers: p
|
|
849
910
|
},
|
|
850
911
|
{}
|
|
851
912
|
);
|
|
@@ -853,15 +914,15 @@ const Bt = ({ account: e, environment: n, incrementAddress: t, subDomainPrefix:
|
|
|
853
914
|
getScopesByOrgUnit: ({
|
|
854
915
|
orgUnitId: l
|
|
855
916
|
}) => {
|
|
856
|
-
const
|
|
917
|
+
const p = s({
|
|
857
918
|
"content-type": "application/json",
|
|
858
|
-
"X-FORWARDED-HOST":
|
|
919
|
+
"X-FORWARDED-HOST": u
|
|
859
920
|
});
|
|
860
921
|
return y(
|
|
861
922
|
`${a}/api/units/v1/${l}/scopes`,
|
|
862
923
|
{
|
|
863
924
|
method: "GET",
|
|
864
|
-
headers:
|
|
925
|
+
headers: p
|
|
865
926
|
},
|
|
866
927
|
{}
|
|
867
928
|
);
|
|
@@ -871,15 +932,15 @@ const Bt = ({ account: e, environment: n, incrementAddress: t, subDomainPrefix:
|
|
|
871
932
|
getUserById: ({
|
|
872
933
|
userId: l
|
|
873
934
|
}) => {
|
|
874
|
-
const
|
|
935
|
+
const p = s({
|
|
875
936
|
"content-type": "application/json",
|
|
876
|
-
"X-FORWARDED-HOST":
|
|
937
|
+
"X-FORWARDED-HOST": u
|
|
877
938
|
});
|
|
878
939
|
return y(
|
|
879
940
|
`${a}/api/license-manager/users/${l}`,
|
|
880
941
|
{
|
|
881
942
|
method: "GET",
|
|
882
|
-
headers:
|
|
943
|
+
headers: p
|
|
883
944
|
},
|
|
884
945
|
{}
|
|
885
946
|
);
|
|
@@ -887,15 +948,15 @@ const Bt = ({ account: e, environment: n, incrementAddress: t, subDomainPrefix:
|
|
|
887
948
|
getUserByEmail: ({
|
|
888
949
|
email: l
|
|
889
950
|
}) => {
|
|
890
|
-
const
|
|
951
|
+
const p = s({
|
|
891
952
|
"content-type": "application/json",
|
|
892
|
-
"X-FORWARDED-HOST":
|
|
953
|
+
"X-FORWARDED-HOST": u
|
|
893
954
|
});
|
|
894
955
|
return y(
|
|
895
956
|
`${a}/api/license-manager/pvt/users/${l}`,
|
|
896
957
|
{
|
|
897
958
|
method: "GET",
|
|
898
|
-
headers:
|
|
959
|
+
headers: p
|
|
899
960
|
},
|
|
900
961
|
{}
|
|
901
962
|
);
|
|
@@ -903,15 +964,15 @@ const Bt = ({ account: e, environment: n, incrementAddress: t, subDomainPrefix:
|
|
|
903
964
|
getUserRoles: ({
|
|
904
965
|
userId: l
|
|
905
966
|
}) => {
|
|
906
|
-
const
|
|
967
|
+
const p = s({
|
|
907
968
|
"content-type": "application/json",
|
|
908
|
-
"X-FORWARDED-HOST":
|
|
969
|
+
"X-FORWARDED-HOST": u
|
|
909
970
|
});
|
|
910
971
|
return y(
|
|
911
972
|
`${a}/api/license-manager/storefront/users/${l}/roles`,
|
|
912
973
|
{
|
|
913
974
|
method: "GET",
|
|
914
|
-
headers:
|
|
975
|
+
headers: p
|
|
915
976
|
},
|
|
916
977
|
{}
|
|
917
978
|
);
|
|
@@ -924,14 +985,14 @@ const Bt = ({ account: e, environment: n, incrementAddress: t, subDomainPrefix:
|
|
|
924
985
|
*/
|
|
925
986
|
isResourceGranted: ({
|
|
926
987
|
userId: l,
|
|
927
|
-
resourceKey:
|
|
988
|
+
resourceKey: p
|
|
928
989
|
}) => {
|
|
929
990
|
const m = s({
|
|
930
991
|
"content-type": "application/json",
|
|
931
|
-
"X-FORWARDED-HOST":
|
|
992
|
+
"X-FORWARDED-HOST": u
|
|
932
993
|
});
|
|
933
994
|
return y(
|
|
934
|
-
`${a}/api/license-manager/storefront/bff/users/${l}/resources/${
|
|
995
|
+
`${a}/api/license-manager/storefront/bff/users/${l}/resources/${p}/granted?an=${e}`,
|
|
935
996
|
{
|
|
936
997
|
method: "GET",
|
|
937
998
|
headers: m
|
|
@@ -945,8 +1006,8 @@ const Bt = ({ account: e, environment: n, incrementAddress: t, subDomainPrefix:
|
|
|
945
1006
|
contractId: l
|
|
946
1007
|
}) => {
|
|
947
1008
|
if (!l)
|
|
948
|
-
throw new
|
|
949
|
-
const
|
|
1009
|
+
throw new k("Missing contractId to fetch CL fields.");
|
|
1010
|
+
const p = I({
|
|
950
1011
|
Accept: "application/json",
|
|
951
1012
|
"content-type": "application/json"
|
|
952
1013
|
});
|
|
@@ -954,7 +1015,7 @@ const Bt = ({ account: e, environment: n, incrementAddress: t, subDomainPrefix:
|
|
|
954
1015
|
`${a}/api/dataentities/CL/documents/${l}?_fields=_all`,
|
|
955
1016
|
{
|
|
956
1017
|
method: "GET",
|
|
957
|
-
headers:
|
|
1018
|
+
headers: p
|
|
958
1019
|
},
|
|
959
1020
|
{}
|
|
960
1021
|
);
|
|
@@ -963,17 +1024,17 @@ const Bt = ({ account: e, environment: n, incrementAddress: t, subDomainPrefix:
|
|
|
963
1024
|
userId: l
|
|
964
1025
|
}) => {
|
|
965
1026
|
if (!l)
|
|
966
|
-
throw new
|
|
967
|
-
const
|
|
1027
|
+
throw new k("Missing userId to fetch shopper name.");
|
|
1028
|
+
const p = c({
|
|
968
1029
|
Accept: "application/json",
|
|
969
1030
|
"content-type": "application/json",
|
|
970
|
-
"X-FORWARDED-HOST":
|
|
1031
|
+
"X-FORWARDED-HOST": u
|
|
971
1032
|
}), m = l.replace(/-/g, "");
|
|
972
1033
|
return y(
|
|
973
1034
|
`${a}/api/dataentities/shopper/search?_where=(userId=${m} OR userId=${l})&_fields=_all&_schema=v1`,
|
|
974
1035
|
{
|
|
975
1036
|
method: "GET",
|
|
976
|
-
headers:
|
|
1037
|
+
headers: p
|
|
977
1038
|
},
|
|
978
1039
|
{}
|
|
979
1040
|
);
|
|
@@ -981,13 +1042,13 @@ const Bt = ({ account: e, environment: n, incrementAddress: t, subDomainPrefix:
|
|
|
981
1042
|
},
|
|
982
1043
|
quotes: {
|
|
983
1044
|
listUserQuotes: (l) => {
|
|
984
|
-
|
|
985
|
-
const
|
|
1045
|
+
jt(l);
|
|
1046
|
+
const p = Wt(l), m = s({
|
|
986
1047
|
"content-type": "application/json",
|
|
987
|
-
"X-FORWARDED-HOST":
|
|
1048
|
+
"X-FORWARDED-HOST": u
|
|
988
1049
|
});
|
|
989
1050
|
return y(
|
|
990
|
-
`${a}/api/quoting/quotes?${
|
|
1051
|
+
`${a}/api/quoting/quotes?${p.toString()}`,
|
|
991
1052
|
{
|
|
992
1053
|
method: "GET",
|
|
993
1054
|
headers: m
|
|
@@ -1000,13 +1061,13 @@ const Bt = ({ account: e, environment: n, incrementAddress: t, subDomainPrefix:
|
|
|
1000
1061
|
validate: () => {
|
|
1001
1062
|
const l = s({
|
|
1002
1063
|
"content-type": "application/json",
|
|
1003
|
-
"X-FORWARDED-HOST":
|
|
1004
|
-
}),
|
|
1064
|
+
"X-FORWARDED-HOST": u
|
|
1065
|
+
}), p = z(Ie(i) ?? "", e);
|
|
1005
1066
|
return y(
|
|
1006
1067
|
`${a}/api/vtexid/credential/validate`,
|
|
1007
1068
|
{
|
|
1008
1069
|
headers: l,
|
|
1009
|
-
body: JSON.stringify({ token:
|
|
1070
|
+
body: JSON.stringify({ token: p }),
|
|
1010
1071
|
method: "POST"
|
|
1011
1072
|
},
|
|
1012
1073
|
{ storeCookies: o }
|
|
@@ -1016,24 +1077,24 @@ const Bt = ({ account: e, environment: n, incrementAddress: t, subDomainPrefix:
|
|
|
1016
1077
|
orderEntry: {
|
|
1017
1078
|
uploadFile: ({
|
|
1018
1079
|
fileBuffer: l,
|
|
1019
|
-
fileName:
|
|
1080
|
+
fileName: p,
|
|
1020
1081
|
mimeType: m
|
|
1021
1082
|
}) => {
|
|
1022
1083
|
const S = s({
|
|
1023
1084
|
"content-type": "application/json",
|
|
1024
|
-
"X-FORWARDED-HOST":
|
|
1025
|
-
}), v = `----FastStoreUploadBoundary${Date.now()}`,
|
|
1026
|
-
`,
|
|
1085
|
+
"X-FORWARDED-HOST": u
|
|
1086
|
+
}), v = `----FastStoreUploadBoundary${Date.now()}`, O = `\r
|
|
1087
|
+
`, T = /^[a-zA-Z0-9][a-zA-Z0-9!#$&\-.^_]*\/[a-zA-Z0-9][a-zA-Z0-9!#$&\-.^_+]*$/.test(m) ? m : "application/octet-stream", w = p.replaceAll(/[\r\n"]/g, "_"), b = [
|
|
1027
1088
|
`--${v}`,
|
|
1028
|
-
`Content-Disposition: form-data; name="file"; filename="${
|
|
1029
|
-
`Content-Type: ${
|
|
1089
|
+
`Content-Disposition: form-data; name="file"; filename="${w}"`,
|
|
1090
|
+
`Content-Type: ${T}`,
|
|
1030
1091
|
"",
|
|
1031
1092
|
""
|
|
1032
|
-
].join(
|
|
1033
|
-
|
|
1093
|
+
].join(O), A = `${O}--${v}--${O}`, E = Buffer.from(b), _ = Buffer.from(A), D = new Uint8Array(
|
|
1094
|
+
E.byteLength + l.byteLength + _.byteLength
|
|
1034
1095
|
);
|
|
1035
|
-
let
|
|
1036
|
-
return
|
|
1096
|
+
let U = 0;
|
|
1097
|
+
return D.set(E, U), U += E.byteLength, D.set(l, U), U += l.byteLength, D.set(_, U), y(
|
|
1037
1098
|
`${a}/api/order-entry/upload?an=${e}`,
|
|
1038
1099
|
{
|
|
1039
1100
|
method: "POST",
|
|
@@ -1041,22 +1102,22 @@ const Bt = ({ account: e, environment: n, incrementAddress: t, subDomainPrefix:
|
|
|
1041
1102
|
...S,
|
|
1042
1103
|
"content-type": `multipart/form-data; boundary=${v}`
|
|
1043
1104
|
},
|
|
1044
|
-
body:
|
|
1105
|
+
body: D.buffer
|
|
1045
1106
|
},
|
|
1046
1107
|
{}
|
|
1047
1108
|
);
|
|
1048
1109
|
},
|
|
1049
1110
|
startOperation: ({
|
|
1050
1111
|
objectKey: l,
|
|
1051
|
-
orderFormId:
|
|
1112
|
+
orderFormId: p,
|
|
1052
1113
|
sessionToken: m
|
|
1053
1114
|
}) => {
|
|
1054
1115
|
const S = s({
|
|
1055
1116
|
"content-type": "application/json",
|
|
1056
|
-
"X-FORWARDED-HOST":
|
|
1117
|
+
"X-FORWARDED-HOST": u
|
|
1057
1118
|
}), v = JSON.stringify({
|
|
1058
1119
|
objectKey: l,
|
|
1059
|
-
orderFormId:
|
|
1120
|
+
orderFormId: p,
|
|
1060
1121
|
operation: "CreateCart",
|
|
1061
1122
|
...m ? { sessionToken: m } : {}
|
|
1062
1123
|
});
|
|
@@ -1073,15 +1134,15 @@ const Bt = ({ account: e, environment: n, incrementAddress: t, subDomainPrefix:
|
|
|
1073
1134
|
getOperation: ({
|
|
1074
1135
|
operationId: l
|
|
1075
1136
|
}) => {
|
|
1076
|
-
const
|
|
1137
|
+
const p = s({
|
|
1077
1138
|
"content-type": "application/json",
|
|
1078
|
-
"X-FORWARDED-HOST":
|
|
1139
|
+
"X-FORWARDED-HOST": u
|
|
1079
1140
|
});
|
|
1080
1141
|
return y(
|
|
1081
1142
|
`${a}/api/order-entry/operation/${l}?an=${e}`,
|
|
1082
1143
|
{
|
|
1083
1144
|
method: "GET",
|
|
1084
|
-
headers:
|
|
1145
|
+
headers: p
|
|
1085
1146
|
},
|
|
1086
1147
|
{}
|
|
1087
1148
|
);
|
|
@@ -1089,7 +1150,7 @@ const Bt = ({ account: e, environment: n, incrementAddress: t, subDomainPrefix:
|
|
|
1089
1150
|
createOrderForm: () => {
|
|
1090
1151
|
const l = s({
|
|
1091
1152
|
"content-type": "application/json",
|
|
1092
|
-
"X-FORWARDED-HOST":
|
|
1153
|
+
"X-FORWARDED-HOST": u
|
|
1093
1154
|
});
|
|
1094
1155
|
return y(
|
|
1095
1156
|
`${a}/api/checkout/pub/orderForm?sc=${i.storage.channel.salesChannel}`,
|
|
@@ -1104,15 +1165,15 @@ const Bt = ({ account: e, environment: n, incrementAddress: t, subDomainPrefix:
|
|
|
1104
1165
|
getOrderFormItems: ({
|
|
1105
1166
|
orderFormId: l
|
|
1106
1167
|
}) => {
|
|
1107
|
-
const
|
|
1168
|
+
const p = s({
|
|
1108
1169
|
"content-type": "application/json",
|
|
1109
|
-
"X-FORWARDED-HOST":
|
|
1170
|
+
"X-FORWARDED-HOST": u
|
|
1110
1171
|
});
|
|
1111
1172
|
return y(
|
|
1112
1173
|
`${a}/api/checkout/pub/orderForm/${l}`,
|
|
1113
1174
|
{
|
|
1114
1175
|
method: "GET",
|
|
1115
|
-
headers:
|
|
1176
|
+
headers: p
|
|
1116
1177
|
},
|
|
1117
1178
|
{}
|
|
1118
1179
|
);
|
|
@@ -1125,14 +1186,14 @@ const Bt = ({ account: e, environment: n, incrementAddress: t, subDomainPrefix:
|
|
|
1125
1186
|
recommendation: {
|
|
1126
1187
|
recommendations: ({
|
|
1127
1188
|
campaignVrn: l,
|
|
1128
|
-
userId:
|
|
1189
|
+
userId: p,
|
|
1129
1190
|
products: m = [],
|
|
1130
1191
|
salesChannel: S,
|
|
1131
1192
|
locale: v
|
|
1132
1193
|
}) => {
|
|
1133
|
-
const
|
|
1134
|
-
return
|
|
1135
|
-
`${f}/recommendations?${
|
|
1194
|
+
const O = new URLSearchParams({ an: e, campaignVrn: l });
|
|
1195
|
+
return p && O.append("userId", p), m.length > 0 && O.append("products", m.join(",")), S && O.append("salesChannel", S), v && O.append("locale", v), y(
|
|
1196
|
+
`${f}/recommendations?${O.toString()}`,
|
|
1136
1197
|
{ headers: h },
|
|
1137
1198
|
{ storeCookies: o }
|
|
1138
1199
|
);
|
|
@@ -1147,27 +1208,27 @@ const Bt = ({ account: e, environment: n, incrementAddress: t, subDomainPrefix:
|
|
|
1147
1208
|
}
|
|
1148
1209
|
}
|
|
1149
1210
|
};
|
|
1150
|
-
},
|
|
1151
|
-
|
|
1152
|
-
|
|
1211
|
+
}, ie = (e) => e.discoveryConfig?.localization ?? {}, K = (e) => ie(e).enabled === !0, Gt = (e) => Object.keys(ie(e).locales ?? {}), Xt = (e) => ie(e).defaultLocale, Pn = (e) => K(e) && e.storage.locale || void 0, ve = "fuzzy", Oe = "operator", Ce = "pickupPoint", xe = "shipping", qe = "delivery-options", Yt = "in-stock", Kt = "trade-policy", Jt = "region-id", Qt = /* @__PURE__ */ new Set([
|
|
1212
|
+
Kt,
|
|
1213
|
+
Jt,
|
|
1153
1214
|
ve,
|
|
1154
1215
|
Oe,
|
|
1155
1216
|
Ce
|
|
1156
|
-
]),
|
|
1217
|
+
]), Zt = /* @__PURE__ */ new Set([
|
|
1157
1218
|
"zip-code",
|
|
1158
1219
|
"pickupPoint",
|
|
1159
1220
|
"country",
|
|
1160
1221
|
"coordinates",
|
|
1161
1222
|
"deliveryZonesHash",
|
|
1162
1223
|
"pickupPointsHash"
|
|
1163
|
-
]),
|
|
1224
|
+
]), je = (e) => encodeURI(decodeURI(e)), er = (e) => encodeURIComponent(
|
|
1164
1225
|
decodeURIComponent(e).normalize("NFD").replaceAll(/[\u0300-\u036f]/g, "")
|
|
1165
|
-
),
|
|
1166
|
-
function
|
|
1226
|
+
), nr = /^pickup-in-point-(.+)$/;
|
|
1227
|
+
function Re(e) {
|
|
1167
1228
|
if (!e)
|
|
1168
1229
|
return {};
|
|
1169
1230
|
try {
|
|
1170
|
-
const t =
|
|
1231
|
+
const t = ae(e).vtex_segment;
|
|
1171
1232
|
if (!t)
|
|
1172
1233
|
return {};
|
|
1173
1234
|
const r = Buffer.from(t, "base64").toString("utf-8");
|
|
@@ -1176,18 +1237,18 @@ function On(e) {
|
|
|
1176
1237
|
return {};
|
|
1177
1238
|
}
|
|
1178
1239
|
}
|
|
1179
|
-
function
|
|
1240
|
+
function tr(e) {
|
|
1180
1241
|
const n = {}, t = [];
|
|
1181
1242
|
for (const r of e.split(";")) {
|
|
1182
1243
|
const i = r.indexOf("=");
|
|
1183
1244
|
if (i < 0) continue;
|
|
1184
1245
|
const a = r.slice(0, i), o = r.slice(i + 1);
|
|
1185
|
-
!a || !o || (
|
|
1246
|
+
!a || !o || (Zt.has(a) ? n[a] = o : t.push({ key: a, value: o }));
|
|
1186
1247
|
}
|
|
1187
1248
|
return { shipping: n, extraFacets: t };
|
|
1188
1249
|
}
|
|
1189
|
-
function
|
|
1190
|
-
const n = typeof e.facets == "string" ? e.facets : "", { shipping: t, extraFacets: r } =
|
|
1250
|
+
function Dn(e) {
|
|
1251
|
+
const n = typeof e.facets == "string" ? e.facets : "", { shipping: t, extraFacets: r } = tr(n);
|
|
1191
1252
|
return {
|
|
1192
1253
|
segmentParams: {
|
|
1193
1254
|
sc: e.channel,
|
|
@@ -1208,7 +1269,10 @@ function Xt(e) {
|
|
|
1208
1269
|
extraFacets: r
|
|
1209
1270
|
};
|
|
1210
1271
|
}
|
|
1211
|
-
function
|
|
1272
|
+
function rr(e) {
|
|
1273
|
+
return Dn(e).extraFacets;
|
|
1274
|
+
}
|
|
1275
|
+
function En(e, n) {
|
|
1212
1276
|
const t = [
|
|
1213
1277
|
["sc", n.sc],
|
|
1214
1278
|
["regionId", n.regionId],
|
|
@@ -1228,11 +1292,11 @@ function Cn(e, n) {
|
|
|
1228
1292
|
for (const [r, i] of t)
|
|
1229
1293
|
i != null && i !== "" && e.append(r, String(i));
|
|
1230
1294
|
}
|
|
1231
|
-
function
|
|
1232
|
-
return
|
|
1295
|
+
function kn(e) {
|
|
1296
|
+
return nr.exec(e)?.[1];
|
|
1233
1297
|
}
|
|
1234
|
-
function
|
|
1235
|
-
const n = e.find((r) => r.key === "shipping"), t = n ?
|
|
1298
|
+
function ir(e) {
|
|
1299
|
+
const n = e.find((r) => r.key === "shipping"), t = n ? kn(n.value) : void 0;
|
|
1236
1300
|
if (t !== void 0)
|
|
1237
1301
|
try {
|
|
1238
1302
|
return decodeURIComponent(t);
|
|
@@ -1240,8 +1304,8 @@ function Yt(e) {
|
|
|
1240
1304
|
return t;
|
|
1241
1305
|
}
|
|
1242
1306
|
}
|
|
1243
|
-
function
|
|
1244
|
-
const t =
|
|
1307
|
+
function ar(e, n) {
|
|
1308
|
+
const t = ir(
|
|
1245
1309
|
n
|
|
1246
1310
|
);
|
|
1247
1311
|
return t === void 0 ? e : {
|
|
@@ -1249,25 +1313,25 @@ function Jt(e, n) {
|
|
|
1249
1313
|
pickupPoint: t
|
|
1250
1314
|
};
|
|
1251
1315
|
}
|
|
1252
|
-
function
|
|
1253
|
-
return e.map((n) => n.key !== "shipping" ||
|
|
1316
|
+
function or(e) {
|
|
1317
|
+
return e.map((n) => n.key !== "shipping" || kn(n.value) === void 0 ? n : { ...n, value: "pickup-in-point" });
|
|
1254
1318
|
}
|
|
1255
|
-
function
|
|
1319
|
+
function sr(e, n) {
|
|
1256
1320
|
let t = [...e];
|
|
1257
1321
|
const r = t.some((i) => i.key === "shipping");
|
|
1258
1322
|
for (const i of n)
|
|
1259
1323
|
(!r || i.key !== "shipping") && t.push(i);
|
|
1260
|
-
return t.some((i) => i.key === "shipping" && i.value === "ignore") && (t = t.filter((i) => i.key !== "shipping")),
|
|
1324
|
+
return t.some((i) => i.key === "shipping" && i.value === "ignore") && (t = t.filter((i) => i.key !== "shipping")), or(t);
|
|
1261
1325
|
}
|
|
1262
|
-
function
|
|
1326
|
+
function _n(e) {
|
|
1263
1327
|
return e.reduce((n, t) => {
|
|
1264
1328
|
let { key: r, value: i } = t;
|
|
1265
|
-
return r === "priceRange" && (r = "price", i = i.replace(" TO ", ":")), r === "ft" ? n : `${n}${
|
|
1329
|
+
return r === "priceRange" && (r = "price", i = i.replace(" TO ", ":")), r === "ft" ? n : `${n}${je(r)}/${er(je(i)).replaceAll(/ |%20/g, "-")}/`;
|
|
1266
1330
|
}, "");
|
|
1267
1331
|
}
|
|
1268
|
-
const
|
|
1269
|
-
function
|
|
1270
|
-
const { segmentParams: t, extraFacets: r } =
|
|
1332
|
+
const cr = (e) => e.key === "fuzzy" && (e.value === "0" || e.value === "1" || e.value === "auto"), lr = (e) => e.key === "operator" && (e.value === "and" || e.value === "or");
|
|
1333
|
+
function dr(e, n) {
|
|
1334
|
+
const { segmentParams: t, extraFacets: r } = Dn(e ?? {}), i = n?.salesChannel ?? t.sc, a = n?.regionId ?? t.regionId, o = n?.locale ?? t.locale ?? "";
|
|
1271
1335
|
return {
|
|
1272
1336
|
segmentParams: {
|
|
1273
1337
|
...t,
|
|
@@ -1278,23 +1342,23 @@ function nr(e, n) {
|
|
|
1278
1342
|
extraFacets: r
|
|
1279
1343
|
};
|
|
1280
1344
|
}
|
|
1281
|
-
function
|
|
1282
|
-
const t = e.filter(({ key: c }) => !
|
|
1283
|
-
({ key: c, value: d }) => c ===
|
|
1345
|
+
function ur(e, n) {
|
|
1346
|
+
const t = e.filter(({ key: c }) => !Qt.has(c)), r = e.find(
|
|
1347
|
+
({ key: c, value: d }) => c === xe && d !== "all-delivery-methods"
|
|
1284
1348
|
) ?? null, i = e.find(
|
|
1285
|
-
({ key: c, value: d }) => c ===
|
|
1349
|
+
({ key: c, value: d }) => c === qe && d !== "all-delivery-options"
|
|
1286
1350
|
) ?? null, a = [...t], o = a.some(
|
|
1287
|
-
({ key: c }) => c ===
|
|
1351
|
+
({ key: c }) => c === xe
|
|
1288
1352
|
), s = a.some(
|
|
1289
|
-
({ key: c }) => c ===
|
|
1353
|
+
({ key: c }) => c === qe
|
|
1290
1354
|
);
|
|
1291
|
-
return r !== null && !o && a.push(r), i !== null && !s && a.push(i),
|
|
1355
|
+
return r !== null && !o && a.push(r), i !== null && !s && a.push(i), sr(a, n);
|
|
1292
1356
|
}
|
|
1293
|
-
function
|
|
1357
|
+
function pr(e, n) {
|
|
1294
1358
|
const t = e.find(({ key: a }) => a === ve) ?? null, r = e.find(({ key: a }) => a === Oe) ?? null, i = e.find(({ key: a }) => a === Ce) ?? null;
|
|
1295
|
-
t &&
|
|
1359
|
+
t && cr(t) && n.append(ve, t.value), r && lr(r) && n.append(Oe, r.value), i && n.append(Ce, i.value);
|
|
1296
1360
|
}
|
|
1297
|
-
function
|
|
1361
|
+
function We(e, n, t, r) {
|
|
1298
1362
|
const {
|
|
1299
1363
|
query: i = "",
|
|
1300
1364
|
page: a,
|
|
@@ -1303,48 +1367,48 @@ function ze(e, n, t, r) {
|
|
|
1303
1367
|
selectedFacets: c = [],
|
|
1304
1368
|
showInvisibleItems: d,
|
|
1305
1369
|
sponsoredCount: g,
|
|
1306
|
-
hideUnavailableItems:
|
|
1370
|
+
hideUnavailableItems: u,
|
|
1307
1371
|
allowRedirect: f = !1
|
|
1308
1372
|
} = e, h = new URLSearchParams();
|
|
1309
1373
|
if (r.includePagination && a !== void 0 && o !== void 0) {
|
|
1310
|
-
const
|
|
1311
|
-
h.append("from",
|
|
1374
|
+
const p = a * o, m = o === 0 ? p : p + o - 1;
|
|
1375
|
+
h.append("from", p.toString()), h.append("to", m.toString());
|
|
1312
1376
|
}
|
|
1313
1377
|
i && h.append("query", i), r.includeSort && s && h.append("sort", s);
|
|
1314
|
-
const I =
|
|
1378
|
+
const I = ar(
|
|
1315
1379
|
t.segmentParams,
|
|
1316
1380
|
c
|
|
1317
1381
|
);
|
|
1318
|
-
if (
|
|
1319
|
-
const
|
|
1382
|
+
if (En(h, I ?? t.segmentParams), pr(c, h), d && h.append("show-invisible-items", "true"), n?.hideUnavailableItems !== void 0) {
|
|
1383
|
+
const p = c.find(({ key: S }) => S === Yt), m = p ? p.value : u?.toString() ?? n.hideUnavailableItems.toString();
|
|
1320
1384
|
h.append("hideUnavailableItems", m);
|
|
1321
1385
|
}
|
|
1322
1386
|
n?.simulationBehavior !== void 0 && h.append("simulationBehavior", n.simulationBehavior.toString()), n?.showSponsored !== void 0 && h.append("showSponsored", n.showSponsored.toString()), g !== void 0 && h.append("sponsoredCount", g.toString()), f !== void 0 && h.append("allowRedirect", f.toString());
|
|
1323
|
-
const l =
|
|
1324
|
-
|
|
1387
|
+
const l = _n(
|
|
1388
|
+
ur(c, t.extraFacets)
|
|
1325
1389
|
);
|
|
1326
1390
|
return { params: h, path: l };
|
|
1327
1391
|
}
|
|
1328
|
-
function
|
|
1392
|
+
function gr(e, n) {
|
|
1329
1393
|
const { field: t, value: r, hideUnavailableItems: i, showInvisibleItems: a } = e, o = new URLSearchParams({
|
|
1330
1394
|
field: t ?? "",
|
|
1331
1395
|
value: r ?? ""
|
|
1332
1396
|
});
|
|
1333
|
-
return
|
|
1397
|
+
return En(o, n), i && o.append("hideUnavailableItems", "true"), a && o.append("show-invisible-items", "true"), o;
|
|
1334
1398
|
}
|
|
1335
1399
|
function ce(e) {
|
|
1336
1400
|
return (e ?? "").replaceAll(/[\s-]/g, "").toUpperCase();
|
|
1337
1401
|
}
|
|
1338
|
-
function
|
|
1339
|
-
const { segmentParams: t, extraFacets: r } = n, { postalCode: i, country: a, coordinates: o } = e, s = !!i, c = a || t.country, d = s && ce(i) === ce(t["zip-code"]) && ce(c) === ce(t.country), g = s ? i : t["zip-code"],
|
|
1340
|
-
if ((!g || !
|
|
1402
|
+
function mr(e, n) {
|
|
1403
|
+
const { segmentParams: t, extraFacets: r } = n, { postalCode: i, country: a, coordinates: o } = e, s = !!i, c = a || t.country, d = s && ce(i) === ce(t["zip-code"]) && ce(c) === ce(t.country), g = s ? i : t["zip-code"], u = s ? c : t.country, f = d ? t.coordinates : void 0, h = s ? o ?? f : o || t.coordinates, I = !s || d, l = !!(t.deliveryZonesHash && t.pickupPointHash);
|
|
1404
|
+
if ((!g || !u) && !!!h && !(I && l))
|
|
1341
1405
|
throw new Error(
|
|
1342
1406
|
"Missing delivery location for pickup point availability. Provide postalCode and country, coordinates, or a segment with zip-code."
|
|
1343
1407
|
);
|
|
1344
|
-
const m = new URLSearchParams(), S = (v,
|
|
1345
|
-
|
|
1408
|
+
const m = new URLSearchParams(), S = (v, O) => {
|
|
1409
|
+
O != null && String(O) !== "" && m.append(v, String(O));
|
|
1346
1410
|
};
|
|
1347
|
-
return S("sc", t.sc), S("locale", t.locale), S("country",
|
|
1411
|
+
return S("sc", t.sc), S("locale", t.locale), S("country", u), S("zip-code", g), S("coordinates", h), I && (S("deliveryZonesHash", t.deliveryZonesHash), S("pickupPointsHash", t.pickupPointHash)), { params: m, path: _n(r) };
|
|
1348
1412
|
}
|
|
1349
1413
|
function q(e, n) {
|
|
1350
1414
|
return {
|
|
@@ -1356,12 +1420,12 @@ function q(e, n) {
|
|
|
1356
1420
|
}
|
|
1357
1421
|
};
|
|
1358
1422
|
}
|
|
1359
|
-
function
|
|
1360
|
-
const { endpoint: n, segment: t, defaults: r, args: i = {} } = e, a =
|
|
1423
|
+
function j(e) {
|
|
1424
|
+
const { endpoint: n, segment: t, defaults: r, args: i = {} } = e, a = dr(t, r);
|
|
1361
1425
|
switch (n) {
|
|
1362
1426
|
case "product-search":
|
|
1363
1427
|
case "facets": {
|
|
1364
|
-
const { params: o, path: s } =
|
|
1428
|
+
const { params: o, path: s } = We(
|
|
1365
1429
|
i,
|
|
1366
1430
|
r,
|
|
1367
1431
|
a,
|
|
@@ -1370,7 +1434,7 @@ function x(e) {
|
|
|
1370
1434
|
return q(s, o);
|
|
1371
1435
|
}
|
|
1372
1436
|
case "catalog-count": {
|
|
1373
|
-
const { params: o, path: s } =
|
|
1437
|
+
const { params: o, path: s } = We(
|
|
1374
1438
|
i,
|
|
1375
1439
|
r,
|
|
1376
1440
|
a,
|
|
@@ -1379,7 +1443,7 @@ function x(e) {
|
|
|
1379
1443
|
return q(s, o);
|
|
1380
1444
|
}
|
|
1381
1445
|
case "products": {
|
|
1382
|
-
const o =
|
|
1446
|
+
const o = gr(i, a.segmentParams);
|
|
1383
1447
|
return q("", o);
|
|
1384
1448
|
}
|
|
1385
1449
|
case "search-suggestions": {
|
|
@@ -1396,7 +1460,7 @@ function x(e) {
|
|
|
1396
1460
|
return q("", o);
|
|
1397
1461
|
}
|
|
1398
1462
|
case "pickup-point-availability": {
|
|
1399
|
-
const { params: o, path: s } =
|
|
1463
|
+
const { params: o, path: s } = mr(
|
|
1400
1464
|
i,
|
|
1401
1465
|
a
|
|
1402
1466
|
);
|
|
@@ -1408,16 +1472,16 @@ function x(e) {
|
|
|
1408
1472
|
}
|
|
1409
1473
|
}
|
|
1410
1474
|
}
|
|
1411
|
-
const
|
|
1412
|
-
function
|
|
1475
|
+
const hr = 10;
|
|
1476
|
+
function fr(e) {
|
|
1413
1477
|
const { regionId: n, seller: t } = e.storage.channel;
|
|
1414
1478
|
return (t ? Buffer.from(`SW#${t}`).toString("base64") : void 0) ?? (n || void 0);
|
|
1415
1479
|
}
|
|
1416
|
-
function
|
|
1417
|
-
const t =
|
|
1418
|
-
return
|
|
1480
|
+
function Sr(e) {
|
|
1481
|
+
const t = Re(e.headers?.cookie).cultureInfo || "";
|
|
1482
|
+
return K(e) ? e.storage.locale || t : t || e.storage.locale || "";
|
|
1419
1483
|
}
|
|
1420
|
-
const
|
|
1484
|
+
const yr = ({
|
|
1421
1485
|
account: e,
|
|
1422
1486
|
environment: n,
|
|
1423
1487
|
hideUnavailableItems: t,
|
|
@@ -1425,140 +1489,143 @@ const lr = ({
|
|
|
1425
1489
|
showSponsored: i,
|
|
1426
1490
|
subDomainPrefix: a
|
|
1427
1491
|
}, o) => {
|
|
1428
|
-
const s = `https://${e}.${n}.com.br`, c =
|
|
1492
|
+
const s = `https://${e}.${n}.com.br`, c = An(o), d = Re(o.headers?.cookie), g = () => ({
|
|
1429
1493
|
salesChannel: o.storage.channel.salesChannel,
|
|
1430
|
-
regionId:
|
|
1431
|
-
locale:
|
|
1494
|
+
regionId: fr(o),
|
|
1495
|
+
locale: Sr(o),
|
|
1432
1496
|
hideUnavailableItems: t,
|
|
1433
1497
|
simulationBehavior: r,
|
|
1434
1498
|
showSponsored: i
|
|
1435
|
-
}),
|
|
1499
|
+
}), u = new Headers(o.headers).get("x-forwarded-host") ?? o.headers?.host ?? "", f = a && a.map((b) => b + ".").find((b) => u.includes(b)) || "", h = u.replace(f, ""), I = c({
|
|
1436
1500
|
"content-type": "application/json",
|
|
1437
1501
|
"X-FORWARDED-HOST": h
|
|
1438
|
-
}), l = ({ type:
|
|
1439
|
-
const
|
|
1440
|
-
endpoint:
|
|
1502
|
+
}), l = ({ type: b, ...A }) => {
|
|
1503
|
+
const E = b === "facets" ? "facets" : "product-search", _ = j({
|
|
1504
|
+
endpoint: E,
|
|
1441
1505
|
segment: d,
|
|
1442
1506
|
defaults: g(),
|
|
1443
|
-
args:
|
|
1507
|
+
args: A
|
|
1444
1508
|
});
|
|
1445
1509
|
return y(
|
|
1446
|
-
`${s}/api/intelligent-search/v1/${
|
|
1510
|
+
`${s}/api/intelligent-search/v1/${E}/${_.path}?${_.params.toString()}`,
|
|
1447
1511
|
{ headers: I }
|
|
1448
1512
|
);
|
|
1449
|
-
},
|
|
1450
|
-
field:
|
|
1451
|
-
value:
|
|
1452
|
-
hideUnavailableItems:
|
|
1453
|
-
showInvisibleItems:
|
|
1513
|
+
}, p = (b) => l({ ...b, type: "product_search" }), m = ({
|
|
1514
|
+
field: b,
|
|
1515
|
+
value: A,
|
|
1516
|
+
hideUnavailableItems: E,
|
|
1517
|
+
showInvisibleItems: _
|
|
1454
1518
|
}) => {
|
|
1455
|
-
const
|
|
1519
|
+
const D = j({
|
|
1456
1520
|
endpoint: "products",
|
|
1457
1521
|
segment: d,
|
|
1458
1522
|
defaults: g(),
|
|
1459
1523
|
args: {
|
|
1460
|
-
field:
|
|
1461
|
-
value:
|
|
1462
|
-
hideUnavailableItems:
|
|
1463
|
-
showInvisibleItems:
|
|
1524
|
+
field: b,
|
|
1525
|
+
value: A,
|
|
1526
|
+
hideUnavailableItems: E,
|
|
1527
|
+
showInvisibleItems: _
|
|
1464
1528
|
}
|
|
1465
1529
|
});
|
|
1466
1530
|
return y(
|
|
1467
|
-
`${s}/api/intelligent-search/v1/products?${
|
|
1531
|
+
`${s}/api/intelligent-search/v1/products?${D.params.toString()}`,
|
|
1468
1532
|
{ headers: I }
|
|
1469
1533
|
);
|
|
1470
1534
|
};
|
|
1471
1535
|
return {
|
|
1472
|
-
facets: (
|
|
1473
|
-
products:
|
|
1536
|
+
facets: (b) => l({ ...b, type: "facets" }),
|
|
1537
|
+
products: p,
|
|
1474
1538
|
fetchProduct: m,
|
|
1475
1539
|
productsByIdentifier: async ({
|
|
1476
|
-
field:
|
|
1477
|
-
values:
|
|
1478
|
-
showInvisibleItems:
|
|
1479
|
-
hideUnavailableItems:
|
|
1540
|
+
field: b,
|
|
1541
|
+
values: A,
|
|
1542
|
+
showInvisibleItems: E,
|
|
1543
|
+
hideUnavailableItems: _,
|
|
1544
|
+
throwOnUpstreamError: D = !1
|
|
1480
1545
|
}) => {
|
|
1481
|
-
const
|
|
1546
|
+
const U = _e(hr);
|
|
1482
1547
|
return (await Promise.all(
|
|
1483
|
-
|
|
1484
|
-
(
|
|
1548
|
+
A.map(
|
|
1549
|
+
(R) => U(async () => {
|
|
1485
1550
|
try {
|
|
1486
1551
|
return await m({
|
|
1487
|
-
field:
|
|
1488
|
-
value:
|
|
1489
|
-
hideUnavailableItems:
|
|
1490
|
-
showInvisibleItems:
|
|
1552
|
+
field: b,
|
|
1553
|
+
value: R,
|
|
1554
|
+
hideUnavailableItems: _,
|
|
1555
|
+
showInvisibleItems: E
|
|
1491
1556
|
});
|
|
1492
|
-
} catch {
|
|
1557
|
+
} catch ($) {
|
|
1558
|
+
if (D && !Y($))
|
|
1559
|
+
throw $;
|
|
1493
1560
|
return null;
|
|
1494
1561
|
}
|
|
1495
1562
|
})
|
|
1496
1563
|
)
|
|
1497
1564
|
)).filter(
|
|
1498
|
-
(
|
|
1565
|
+
(R) => R !== null
|
|
1499
1566
|
);
|
|
1500
1567
|
},
|
|
1501
|
-
suggestedTerms: (
|
|
1502
|
-
const
|
|
1568
|
+
suggestedTerms: (b) => {
|
|
1569
|
+
const A = j({
|
|
1503
1570
|
endpoint: "search-suggestions",
|
|
1504
1571
|
segment: d,
|
|
1505
1572
|
defaults: g(),
|
|
1506
|
-
args: { query:
|
|
1573
|
+
args: { query: b.query }
|
|
1507
1574
|
});
|
|
1508
1575
|
return y(
|
|
1509
|
-
`${s}/api/intelligent-search/v1/search-suggestions?${
|
|
1576
|
+
`${s}/api/intelligent-search/v1/search-suggestions?${A.params.toString()}`,
|
|
1510
1577
|
{ headers: I }
|
|
1511
1578
|
);
|
|
1512
1579
|
},
|
|
1513
1580
|
topSearches: () => {
|
|
1514
|
-
const
|
|
1581
|
+
const b = j({
|
|
1515
1582
|
endpoint: "top-searches",
|
|
1516
1583
|
segment: d,
|
|
1517
1584
|
defaults: g()
|
|
1518
1585
|
});
|
|
1519
1586
|
return y(
|
|
1520
|
-
`${s}/api/intelligent-search/v1/top-searches?${
|
|
1587
|
+
`${s}/api/intelligent-search/v1/top-searches?${b.params.toString()}`,
|
|
1521
1588
|
{ headers: I }
|
|
1522
1589
|
);
|
|
1523
1590
|
},
|
|
1524
|
-
productCount: (
|
|
1525
|
-
const
|
|
1591
|
+
productCount: (b) => {
|
|
1592
|
+
const A = j({
|
|
1526
1593
|
endpoint: "catalog-count",
|
|
1527
1594
|
segment: d,
|
|
1528
1595
|
defaults: g(),
|
|
1529
|
-
args:
|
|
1596
|
+
args: b
|
|
1530
1597
|
});
|
|
1531
1598
|
return y(
|
|
1532
|
-
`${s}/api/intelligent-search/v1/catalog-count/${
|
|
1599
|
+
`${s}/api/intelligent-search/v1/catalog-count/${A.path}?${A.params.toString()}`,
|
|
1533
1600
|
{ headers: I }
|
|
1534
1601
|
);
|
|
1535
1602
|
},
|
|
1536
1603
|
pickupPointAvailability: ({
|
|
1537
|
-
postalCode:
|
|
1538
|
-
country:
|
|
1539
|
-
coordinates:
|
|
1604
|
+
postalCode: b,
|
|
1605
|
+
country: A,
|
|
1606
|
+
coordinates: E
|
|
1540
1607
|
}) => {
|
|
1541
|
-
const
|
|
1608
|
+
const _ = j({
|
|
1542
1609
|
endpoint: "pickup-point-availability",
|
|
1543
1610
|
segment: d,
|
|
1544
1611
|
defaults: g(),
|
|
1545
|
-
args: { postalCode:
|
|
1546
|
-
}),
|
|
1612
|
+
args: { postalCode: b, country: A, coordinates: E }
|
|
1613
|
+
}), D = _.path ? `/${_.path}` : "";
|
|
1547
1614
|
return y(
|
|
1548
|
-
`${s}/api/intelligent-search/v1/pickup-point-availability${
|
|
1615
|
+
`${s}/api/intelligent-search/v1/pickup-point-availability${D}?${_.params.toString()}`,
|
|
1549
1616
|
{ headers: I }
|
|
1550
1617
|
);
|
|
1551
1618
|
}
|
|
1552
1619
|
};
|
|
1553
|
-
},
|
|
1554
|
-
const t =
|
|
1620
|
+
}, Ir = (e, n) => {
|
|
1621
|
+
const t = yr(e, n), r = Ht(e, n), i = Rt(e);
|
|
1555
1622
|
return {
|
|
1556
1623
|
search: t,
|
|
1557
1624
|
commerce: r,
|
|
1558
1625
|
catalog: i
|
|
1559
1626
|
};
|
|
1560
|
-
},
|
|
1561
|
-
const t =
|
|
1627
|
+
}, vr = 20, Or = (e) => e.entityType === "category", be = (e) => e.entityType === "brand", He = (e) => e.entityType === "collection", Cr = (e, n) => {
|
|
1628
|
+
const t = _e(vr), r = async (i) => Promise.all(
|
|
1562
1629
|
i.map(
|
|
1563
1630
|
(a) => t(async () => {
|
|
1564
1631
|
const o = a.slug.toLowerCase(), s = a.locale, c = await n.commerce.catalog.byLinkId.category(
|
|
@@ -1583,7 +1650,7 @@ const lr = ({
|
|
|
1583
1650
|
);
|
|
1584
1651
|
if (g)
|
|
1585
1652
|
return { ...g, entityType: "collection" };
|
|
1586
|
-
throw new
|
|
1653
|
+
throw new B(
|
|
1587
1654
|
`No catalog entity found for slug: ${a.slug}. Cascade exhausted (category → brand → collection).`
|
|
1588
1655
|
);
|
|
1589
1656
|
})
|
|
@@ -1596,26 +1663,26 @@ const lr = ({
|
|
|
1596
1663
|
// entry while same-slug / different-locale loads stay isolated.
|
|
1597
1664
|
cacheKeyFn: ({ slug: i, locale: a }) => `${i.toLowerCase()}::${a ?? ""}`
|
|
1598
1665
|
});
|
|
1599
|
-
},
|
|
1666
|
+
}, br = (e, n) => {
|
|
1600
1667
|
const t = async (r) => Promise.all(r.map((i) => n.commerce.catalog.salesChannel(i)));
|
|
1601
1668
|
return new fe(t);
|
|
1602
|
-
},
|
|
1603
|
-
const t =
|
|
1604
|
-
const o = a.reduce((
|
|
1669
|
+
}, wr = 1, Ar = (e, n) => {
|
|
1670
|
+
const t = _e(wr), r = async (a) => {
|
|
1671
|
+
const o = a.reduce((u, { items: f }) => [...u, f], []), s = [...o.flat()], c = await n.commerce.checkout.simulation({
|
|
1605
1672
|
country: a[0].country,
|
|
1606
1673
|
postalCode: a[0].postalCode,
|
|
1607
1674
|
items: s
|
|
1608
1675
|
}), d = c.items.reduce(
|
|
1609
|
-
(
|
|
1676
|
+
(u, f) => {
|
|
1610
1677
|
const h = f.requestIndex;
|
|
1611
|
-
return typeof h == "number" && h <
|
|
1678
|
+
return typeof h == "number" && h < u.length && (u[h] = f), u;
|
|
1612
1679
|
},
|
|
1613
1680
|
Array(s.length).fill(null)
|
|
1614
1681
|
), g = o.reduce(
|
|
1615
|
-
(
|
|
1682
|
+
(u, f) => [...u, f.length + u[u.length - 1]],
|
|
1616
1683
|
[0]
|
|
1617
1684
|
);
|
|
1618
|
-
return o.map((
|
|
1685
|
+
return o.map((u, f) => ({
|
|
1619
1686
|
...c,
|
|
1620
1687
|
items: d.slice(g[f], g[f + 1]).filter((h) => !!h)
|
|
1621
1688
|
}));
|
|
@@ -1623,17 +1690,17 @@ const lr = ({
|
|
|
1623
1690
|
return new fe(i, {
|
|
1624
1691
|
maxBatchSize: 50
|
|
1625
1692
|
});
|
|
1626
|
-
},
|
|
1627
|
-
function
|
|
1693
|
+
}, Pr = (e, n) => pt(e, n);
|
|
1694
|
+
function Dr(e) {
|
|
1628
1695
|
return {
|
|
1629
1696
|
...e,
|
|
1630
|
-
description: e.description ?
|
|
1697
|
+
description: e.description ? Pr(e.description) : e.description
|
|
1631
1698
|
};
|
|
1632
1699
|
}
|
|
1633
1700
|
const L = (e, n) => ({
|
|
1634
1701
|
...e,
|
|
1635
|
-
isVariantOf:
|
|
1636
|
-
}),
|
|
1702
|
+
isVariantOf: Dr(n)
|
|
1703
|
+
}), Er = ({ flags: e }, n) => {
|
|
1637
1704
|
const t = async (r) => {
|
|
1638
1705
|
const i = r.map((g) => g.split("-")[0]), a = r.some(
|
|
1639
1706
|
(g) => g.split("-")[1] === "invisibleItems"
|
|
@@ -1641,19 +1708,20 @@ const L = (e, n) => ({
|
|
|
1641
1708
|
field: "sku",
|
|
1642
1709
|
values: i,
|
|
1643
1710
|
showInvisibleItems: a,
|
|
1711
|
+
throwOnUpstreamError: !0,
|
|
1644
1712
|
...e?.enableUnavailableItemsOnCart && {
|
|
1645
1713
|
hideUnavailableItems: !1
|
|
1646
1714
|
}
|
|
1647
1715
|
})).reduce(
|
|
1648
|
-
(g,
|
|
1649
|
-
for (const f of
|
|
1650
|
-
g[f.itemId] = L(f,
|
|
1716
|
+
(g, u) => {
|
|
1717
|
+
for (const f of u.items)
|
|
1718
|
+
g[f.itemId] = L(f, u);
|
|
1651
1719
|
return g;
|
|
1652
1720
|
},
|
|
1653
1721
|
{}
|
|
1654
1722
|
), c = i.map((g) => s[g]), d = i.filter((g) => !s[g]);
|
|
1655
1723
|
if (d.length > 0)
|
|
1656
|
-
throw new
|
|
1724
|
+
throw new B(
|
|
1657
1725
|
`Search API did not found the following skus: ${d.join(",")}`
|
|
1658
1726
|
);
|
|
1659
1727
|
return c;
|
|
@@ -1662,27 +1730,27 @@ const L = (e, n) => ({
|
|
|
1662
1730
|
maxBatchSize: 99
|
|
1663
1731
|
// Max allowed batch size of Search API
|
|
1664
1732
|
});
|
|
1665
|
-
},
|
|
1666
|
-
const { clients: t } = n, r =
|
|
1733
|
+
}, kr = (e, n) => {
|
|
1734
|
+
const { clients: t } = n, r = Er(e, t), i = Ar(e, t), a = Cr(e, t), o = br(e, t);
|
|
1667
1735
|
return {
|
|
1668
1736
|
skuLoader: r,
|
|
1669
1737
|
simulationLoader: i,
|
|
1670
1738
|
collectionLoader: a,
|
|
1671
1739
|
salesChannelLoader: o
|
|
1672
1740
|
};
|
|
1673
|
-
},
|
|
1741
|
+
}, V = (e) => e.AvailableQuantity > 0, J = (e) => e.spotPrice ?? 0, _r = (e) => e.Price ?? 0, Ge = (e) => e ? "https://schema.org/InStock" : "https://schema.org/OutOfStock", Tn = (e, n) => V(e) && !V(n) ? -1 : !V(e) && V(n) ? 1 : J(e) - J(n), Tr = (e) => e === "available", X = (e, n = 0, t = 1) => {
|
|
1674
1742
|
const r = n / t;
|
|
1675
1743
|
return Math.round((e + r) * 100) / 100;
|
|
1676
|
-
},
|
|
1677
|
-
const t = e.filter(
|
|
1678
|
-
return n.includeTaxes ?
|
|
1679
|
-
},
|
|
1680
|
-
const [t] = e.filter(
|
|
1681
|
-
return n.includeTaxes ?
|
|
1682
|
-
},
|
|
1683
|
-
highPrice: (e) =>
|
|
1684
|
-
lowPrice: (e) =>
|
|
1685
|
-
lowPriceWithTaxes: (e) =>
|
|
1744
|
+
}, Ur = (e, n = { includeTaxes: !1 }) => {
|
|
1745
|
+
const t = e.filter(V), r = t[t.length - 1], i = r ? J(r) : 0;
|
|
1746
|
+
return n.includeTaxes ? X(i, r?.Tax, r?.product?.unitMultiplier) : i;
|
|
1747
|
+
}, Xe = (e, n = { includeTaxes: !1 }) => {
|
|
1748
|
+
const [t] = e.filter(V), r = t ? J(t) : 0;
|
|
1749
|
+
return n.includeTaxes ? X(r, t?.Tax, t?.product?.unitMultiplier) : r;
|
|
1750
|
+
}, Rr = {
|
|
1751
|
+
highPrice: (e) => Ur(e),
|
|
1752
|
+
lowPrice: (e) => Xe(e),
|
|
1753
|
+
lowPriceWithTaxes: (e) => Xe(e, { includeTaxes: !0 }),
|
|
1686
1754
|
offerCount: (e) => e.length,
|
|
1687
1755
|
priceCurrency: async (e, n, t) => {
|
|
1688
1756
|
const {
|
|
@@ -1692,18 +1760,18 @@ const L = (e, n) => ({
|
|
|
1692
1760
|
return (await r.load(i.salesChannel)).CurrencyCode ?? "";
|
|
1693
1761
|
},
|
|
1694
1762
|
offers: (e) => e
|
|
1695
|
-
},
|
|
1763
|
+
}, Nr = {
|
|
1696
1764
|
ratingValue: () => 5,
|
|
1697
1765
|
reviewCount: () => 0
|
|
1698
|
-
},
|
|
1766
|
+
}, Ye = "ÁÄÂÀÃÅČÇĆĎÉĚËÈÊẼĔȆÍÌÎÏŇÑÓÖÒÔÕØŘŔŠŤÚŮÜÙÛÝŸŽáäâàãåčçćďéěëèêẽĕȇíìîïňñóöòôõøðřŕšťúůüùûýÿžþÞĐđ߯a", Fr = "AAAAAACCCDEEEEEEEEIIIINNOOOOOORRSTUUUUUYYZaaaaaacccdeeeeeeeeiiiinnooooooorrstuuuuuyyzbBDdBAa", Lr = (e) => {
|
|
1699
1767
|
let n = e.slice(0);
|
|
1700
|
-
for (let t = 0; t <
|
|
1701
|
-
n = n.replace(new RegExp(
|
|
1768
|
+
for (let t = 0; t < Ye.length; t++)
|
|
1769
|
+
n = n.replace(new RegExp(Ye.charAt(t), "g"), Fr.charAt(t));
|
|
1702
1770
|
return n;
|
|
1703
|
-
},
|
|
1771
|
+
}, Br = (e) => e.replace(/[·/_,:]/, "-");
|
|
1704
1772
|
function ge(e) {
|
|
1705
1773
|
const t = e.replace(/,/g, "").replace(/[*+~.()'"!:@&\[\]`/ %$#?{}><=_^]/g, "-");
|
|
1706
|
-
return
|
|
1774
|
+
return Br(Lr(t)).toLowerCase();
|
|
1707
1775
|
}
|
|
1708
1776
|
const ye = (e) => e.toLowerCase(), le = (e, n) => {
|
|
1709
1777
|
const t = n.split("/").filter(Boolean), {
|
|
@@ -1713,13 +1781,13 @@ const ye = (e) => e.toLowerCase(), le = (e, n) => {
|
|
|
1713
1781
|
t.map(
|
|
1714
1782
|
(i, a) => r.load({
|
|
1715
1783
|
slug: t.slice(0, a + 1).join("/"),
|
|
1716
|
-
locale:
|
|
1784
|
+
locale: Pn(e)
|
|
1717
1785
|
})
|
|
1718
1786
|
)
|
|
1719
1787
|
);
|
|
1720
|
-
},
|
|
1788
|
+
}, W = (e) => Or(e) ? e.slug : be(e) ? e.linkId : e.linkId ?? ge(e.name), Un = {
|
|
1721
1789
|
id: ({ id: e }) => e.toString(),
|
|
1722
|
-
slug: (e) =>
|
|
1790
|
+
slug: (e) => W(e),
|
|
1723
1791
|
seo: (e) => ({
|
|
1724
1792
|
title: e.title ?? e.name,
|
|
1725
1793
|
// pagetype.metaTagDescription and catalog `description` share the same
|
|
@@ -1727,14 +1795,14 @@ const ye = (e) => e.toLowerCase(), le = (e, n) => {
|
|
|
1727
1795
|
// for forward-compat; fall back to description for by-linkid parity.
|
|
1728
1796
|
description: e.metaTagDescription ?? e.description
|
|
1729
1797
|
}),
|
|
1730
|
-
type: (e) => be(e) ? "Brand" :
|
|
1798
|
+
type: (e) => be(e) ? "Brand" : He(e) ? "Collection" : e.fatherCategoryId === null ? "Department" : "Category",
|
|
1731
1799
|
meta: async (e, n, t) => {
|
|
1732
|
-
const r =
|
|
1800
|
+
const r = W(e);
|
|
1733
1801
|
if (be(e))
|
|
1734
1802
|
return { selectedFacets: [{ key: "brand", value: r }] };
|
|
1735
|
-
if (
|
|
1803
|
+
if (He(e))
|
|
1736
1804
|
return { selectedFacets: [{ key: "productclusterids", value: e.id }] };
|
|
1737
|
-
const { defaultLocale: i } =
|
|
1805
|
+
const { defaultLocale: i } = ie(t);
|
|
1738
1806
|
return {
|
|
1739
1807
|
selectedFacets: (await le(t, r)).map((o, s) => ({
|
|
1740
1808
|
key: `category-${s + 1}`,
|
|
@@ -1743,10 +1811,10 @@ const ye = (e) => e.toLowerCase(), le = (e, n) => {
|
|
|
1743
1811
|
};
|
|
1744
1812
|
},
|
|
1745
1813
|
breadcrumbList: async (e, n, t) => {
|
|
1746
|
-
const r = await le(t,
|
|
1814
|
+
const r = await le(t, W(e));
|
|
1747
1815
|
return {
|
|
1748
1816
|
itemListElement: r.map((i, a) => ({
|
|
1749
|
-
item: `/${
|
|
1817
|
+
item: `/${W(i)}`,
|
|
1750
1818
|
name: i.name,
|
|
1751
1819
|
position: a + 1
|
|
1752
1820
|
})),
|
|
@@ -1754,11 +1822,11 @@ const ye = (e) => e.toLowerCase(), le = (e, n) => {
|
|
|
1754
1822
|
};
|
|
1755
1823
|
},
|
|
1756
1824
|
otherLocales: async (e, n, t) => {
|
|
1757
|
-
const r =
|
|
1825
|
+
const r = ie(t);
|
|
1758
1826
|
if (!r.enabled) return null;
|
|
1759
1827
|
const i = Object.keys(r.locales ?? {});
|
|
1760
1828
|
if (i.length === 0) return null;
|
|
1761
|
-
const a =
|
|
1829
|
+
const a = W(e);
|
|
1762
1830
|
if (a.split("/").filter(Boolean).length === 0) return null;
|
|
1763
1831
|
let o;
|
|
1764
1832
|
try {
|
|
@@ -1780,7 +1848,7 @@ const ye = (e) => e.toLowerCase(), le = (e, n) => {
|
|
|
1780
1848
|
}).filter((s) => s !== null);
|
|
1781
1849
|
},
|
|
1782
1850
|
canonicalSlug: async (e, n, t) => {
|
|
1783
|
-
const r =
|
|
1851
|
+
const r = W(e);
|
|
1784
1852
|
if (r.split("/").filter(Boolean).length === 0) return null;
|
|
1785
1853
|
let i;
|
|
1786
1854
|
try {
|
|
@@ -1791,14 +1859,14 @@ const ye = (e) => e.toLowerCase(), le = (e, n) => {
|
|
|
1791
1859
|
const a = i.map((o) => o.linkId);
|
|
1792
1860
|
return a.every((o) => !!o) ? ye(a.join("/")) : ye(r);
|
|
1793
1861
|
}
|
|
1794
|
-
},
|
|
1862
|
+
}, Rn = {
|
|
1795
1863
|
buy: "whoboughtalsobought",
|
|
1796
1864
|
view: "whosawalsosaw",
|
|
1797
1865
|
similars: "similars",
|
|
1798
1866
|
viewAndBought: "whosawalsobought",
|
|
1799
1867
|
accessories: "accessories",
|
|
1800
1868
|
suggestions: "suggestions"
|
|
1801
|
-
},
|
|
1869
|
+
}, Ke = ({ key: e, value: n }) => {
|
|
1802
1870
|
switch (e) {
|
|
1803
1871
|
case "price":
|
|
1804
1872
|
return { key: e, value: n.replace("-to-", ":") };
|
|
@@ -1814,34 +1882,34 @@ const ye = (e) => e.toLowerCase(), le = (e, n) => {
|
|
|
1814
1882
|
default:
|
|
1815
1883
|
return { key: e, value: n };
|
|
1816
1884
|
}
|
|
1817
|
-
},
|
|
1885
|
+
}, Je = (e) => {
|
|
1818
1886
|
const n = e.split(":").map(Number);
|
|
1819
1887
|
return n.length !== 2 || Number.isNaN(n[0]) || Number.isNaN(n[1]) ? null : n;
|
|
1820
|
-
},
|
|
1888
|
+
}, $r = (e) => typeof Rn[e] == "string", Mr = (e) => {
|
|
1821
1889
|
const n = e?.filter(
|
|
1822
|
-
(t) =>
|
|
1890
|
+
(t) => $r(t.key)
|
|
1823
1891
|
);
|
|
1824
1892
|
if (Array.isArray(n) && n.length > 1)
|
|
1825
|
-
throw new
|
|
1893
|
+
throw new k(
|
|
1826
1894
|
`You passed ${n.length} cross selling facets but only one is allowed. Please leave one of the following facet: ${n.map((t) => t.key).join(",")}`
|
|
1827
1895
|
);
|
|
1828
1896
|
return n?.[0] ?? null;
|
|
1829
|
-
},
|
|
1897
|
+
}, zr = (e) => e?.find((n) => n.key === "slug")?.value ?? null, Vr = (e) => e?.find((n) => n.key === "id")?.value ?? null, Qe = (e) => e?.find((n) => n.key === "locale")?.value ?? null, Ze = (e) => e?.find((n) => n.key === "channel")?.value ?? null, we = (e, n) => {
|
|
1830
1898
|
let t = 0;
|
|
1831
1899
|
for (let r = 1; r < e.length; r++)
|
|
1832
1900
|
n(e[t], e[r]) > 0 && (t = r);
|
|
1833
1901
|
return e[t];
|
|
1834
|
-
},
|
|
1902
|
+
}, xr = {
|
|
1835
1903
|
__resolveType: ({ type: e, values: n }) => e !== "TEXT" && e !== "DELIVERY" ? "StoreFacetRange" : !n || n.length === 0 ? "StoreFacetBoolean" : n.every((t) => t.range) ? "StoreFacetRange" : "StoreFacetBoolean"
|
|
1836
|
-
},
|
|
1904
|
+
}, qr = {
|
|
1837
1905
|
key: ({ key: e }) => e,
|
|
1838
1906
|
label: ({ name: e }) => e,
|
|
1839
1907
|
values: ({ values: e }) => e.sort((n, t) => n.name.localeCompare(t.name))
|
|
1840
|
-
},
|
|
1908
|
+
}, jr = {
|
|
1841
1909
|
key: ({ key: e }) => e,
|
|
1842
1910
|
label: ({ name: e }) => e,
|
|
1843
1911
|
min: ({ values: e, key: n }, t, { storage: { searchArgs: r } }) => {
|
|
1844
|
-
const i =
|
|
1912
|
+
const i = Je(
|
|
1845
1913
|
r?.selectedFacets?.find((s) => s.key === n)?.value ?? ""
|
|
1846
1914
|
), o = we(e, (s, c) => s.range.from - c.range.from)?.range?.from ?? 0;
|
|
1847
1915
|
return {
|
|
@@ -1850,7 +1918,7 @@ const ye = (e) => e.toLowerCase(), le = (e, n) => {
|
|
|
1850
1918
|
};
|
|
1851
1919
|
},
|
|
1852
1920
|
max: ({ values: e, key: n }, t, { storage: { searchArgs: r } }) => {
|
|
1853
|
-
const i =
|
|
1921
|
+
const i = Je(
|
|
1854
1922
|
r?.selectedFacets?.find((s) => s.key === n)?.value ?? ""
|
|
1855
1923
|
), o = we(e, (s, c) => c.range.to - s.range.to)?.range?.to ?? 0;
|
|
1856
1924
|
return {
|
|
@@ -1858,17 +1926,17 @@ const ye = (e) => e.toLowerCase(), le = (e, n) => {
|
|
|
1858
1926
|
absolute: o
|
|
1859
1927
|
};
|
|
1860
1928
|
}
|
|
1861
|
-
},
|
|
1929
|
+
}, Wr = {
|
|
1862
1930
|
value: ({ value: e }) => e,
|
|
1863
1931
|
label: ({ name: e }) => e || "unknown",
|
|
1864
1932
|
selected: ({ selected: e }) => e,
|
|
1865
1933
|
quantity: ({ quantity: e }) => e
|
|
1866
|
-
},
|
|
1934
|
+
}, Hr = async (e, { data: n }, { clients: { commerce: t } }) => {
|
|
1867
1935
|
if (!n?.orderId)
|
|
1868
|
-
throw new
|
|
1936
|
+
throw new k("Missing orderId");
|
|
1869
1937
|
return { data: (await t.checkout.cancelOrder(n))?.data };
|
|
1870
1938
|
};
|
|
1871
|
-
function
|
|
1939
|
+
function Nn(e) {
|
|
1872
1940
|
if (!e || e.status !== "pending")
|
|
1873
1941
|
return null;
|
|
1874
1942
|
for (const n of e.dimensionStatus) {
|
|
@@ -1886,45 +1954,57 @@ function kn(e) {
|
|
|
1886
1954
|
}
|
|
1887
1955
|
return null;
|
|
1888
1956
|
}
|
|
1889
|
-
function
|
|
1957
|
+
function Gr(e) {
|
|
1890
1958
|
if (!e || e.status !== "pending") return !1;
|
|
1891
1959
|
const n = e.dimensionStatus.filter((t) => t.status === "pending").flatMap((t) => t.ruleCollection).filter((t) => t.status === "pending");
|
|
1892
1960
|
return n.length === 0 ? !1 : n.every((t) => !t.isUserNextAuthorizer);
|
|
1893
1961
|
}
|
|
1894
|
-
const
|
|
1895
|
-
const r = await t.oms.processOrderAuthorization(n), i =
|
|
1962
|
+
const Xr = async (e, { data: n }, { clients: { commerce: t } }) => {
|
|
1963
|
+
const r = await t.oms.processOrderAuthorization(n), i = Nn(r);
|
|
1896
1964
|
return {
|
|
1897
|
-
isPendingForOtherAuthorizer: !i &&
|
|
1965
|
+
isPendingForOtherAuthorizer: !i && Gr(r),
|
|
1898
1966
|
ruleForAuthorization: i
|
|
1899
1967
|
};
|
|
1900
|
-
},
|
|
1968
|
+
}, Yr = async (e, { data: n }, { clients: { commerce: t } }) => {
|
|
1901
1969
|
if (!n?.objectKey)
|
|
1902
|
-
throw new
|
|
1970
|
+
throw new k("Missing objectKey");
|
|
1903
1971
|
const r = n.orderFormId || (await t.orderEntry.createOrderForm()).orderFormId;
|
|
1904
1972
|
return t.orderEntry.startOperation({
|
|
1905
1973
|
objectKey: n.objectKey,
|
|
1906
1974
|
orderFormId: r,
|
|
1907
1975
|
sessionToken: n.sessionToken ?? void 0
|
|
1908
1976
|
});
|
|
1909
|
-
},
|
|
1977
|
+
}, Kr = async (e, n, t) => {
|
|
1910
1978
|
if (!(await t.clients.commerce.recommendation.startRecommendationSession())?.recommendationsUserId)
|
|
1911
1979
|
throw new Error(
|
|
1912
1980
|
"Failed to start recommendation session: no session data returned"
|
|
1913
1981
|
);
|
|
1914
1982
|
return !0;
|
|
1915
|
-
},
|
|
1983
|
+
}, Jr = 254, en = 100, Qr = /^[^\s@]+@[^\s@.]+(\.[^\s@.]+)+$/, Zr = async (e, { data: n }, { clients: { commerce: t } }) => {
|
|
1984
|
+
const r = n.email?.trim().toLowerCase() ?? "", i = n.name?.trim() ?? "";
|
|
1985
|
+
if (r.length > Jr || !Qr.test(r))
|
|
1986
|
+
throw new k("Invalid email");
|
|
1987
|
+
if (i.length > en)
|
|
1988
|
+
throw new k(
|
|
1989
|
+
`Invalid name: must have at most ${en} characters`
|
|
1990
|
+
);
|
|
1991
|
+
return { id: (await t.subscribeToNewsletter({
|
|
1992
|
+
email: r,
|
|
1993
|
+
name: i || void 0
|
|
1994
|
+
}))?.Id };
|
|
1995
|
+
}, ei = async (e, { data: n }, { clients: { commerce: t } }) => {
|
|
1916
1996
|
const { fileContent: r, fileName: i, mimeType: a } = n;
|
|
1917
1997
|
if (!r || !i || !a)
|
|
1918
|
-
throw new
|
|
1998
|
+
throw new k(
|
|
1919
1999
|
"Missing required fields: fileContent, fileName, mimeType"
|
|
1920
2000
|
);
|
|
1921
2001
|
const o = r.replaceAll(/\s/g, ""), s = 5 * 1024 * 1024;
|
|
1922
2002
|
if (Math.floor(o.length * 3 / 4) > s)
|
|
1923
|
-
throw new
|
|
2003
|
+
throw new k("File exceeds maximum allowed size of 5MB");
|
|
1924
2004
|
if (!/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(
|
|
1925
2005
|
o
|
|
1926
2006
|
))
|
|
1927
|
-
throw new
|
|
2007
|
+
throw new k("Invalid Base64 fileContent");
|
|
1928
2008
|
const g = Buffer.from(o, "base64");
|
|
1929
2009
|
return await t.orderEntry.uploadFile({
|
|
1930
2010
|
fileBuffer: g,
|
|
@@ -1932,7 +2012,7 @@ const Mr = async (e, { data: n }, { clients: { commerce: t } }) => {
|
|
|
1932
2012
|
mimeType: a
|
|
1933
2013
|
});
|
|
1934
2014
|
};
|
|
1935
|
-
class
|
|
2015
|
+
class oe {
|
|
1936
2016
|
static parse(n) {
|
|
1937
2017
|
try {
|
|
1938
2018
|
const t = JSON.parse(n);
|
|
@@ -1950,35 +2030,35 @@ class ae {
|
|
|
1950
2030
|
return JSON.stringify(n);
|
|
1951
2031
|
}
|
|
1952
2032
|
}
|
|
1953
|
-
function
|
|
1954
|
-
return n == null || n === "" || String(n) === String(e.salesChannel ?? "") ? null :
|
|
2033
|
+
function ni(e, n) {
|
|
2034
|
+
return n == null || n === "" || String(n) === String(e.salesChannel ?? "") ? null : oe.stringify({
|
|
1955
2035
|
...e,
|
|
1956
2036
|
salesChannel: String(n),
|
|
1957
2037
|
hasOnlyDefaultSalesChannel: !1
|
|
1958
2038
|
});
|
|
1959
2039
|
}
|
|
1960
|
-
function
|
|
2040
|
+
function ti(e, n, t) {
|
|
1961
2041
|
return t != null && String(e.salesChannel ?? "") === t && String(n ?? "") !== t ? !1 : e.items.length > 0 ? !0 : e.salesChannel == null || e.salesChannel === "" ? !1 : String(e.salesChannel) === String(n ?? "");
|
|
1962
2042
|
}
|
|
1963
|
-
const
|
|
2043
|
+
const Fn = (e) => {
|
|
1964
2044
|
try {
|
|
1965
2045
|
return JSON.parse(e ?? "") ?? {};
|
|
1966
2046
|
} catch {
|
|
1967
2047
|
return {};
|
|
1968
2048
|
}
|
|
1969
2049
|
};
|
|
1970
|
-
function
|
|
1971
|
-
const t =
|
|
2050
|
+
function Ln(e, { localizationEnabled: n = !0 } = {}) {
|
|
2051
|
+
const t = Fn(e).salesChannelSource;
|
|
1972
2052
|
return t === "url" ? n ? t : void 0 : t === "orderForm" ? t : void 0;
|
|
1973
2053
|
}
|
|
1974
|
-
const
|
|
1975
|
-
function
|
|
1976
|
-
const n =
|
|
2054
|
+
const Bn = (e) => !!e?.localization?.enabled;
|
|
2055
|
+
function $n(e) {
|
|
2056
|
+
const n = Fn(e).rejectedSalesChannel;
|
|
1977
2057
|
return (typeof n == "string" || typeof n == "number") && String(n) || void 0;
|
|
1978
2058
|
}
|
|
1979
|
-
function
|
|
2059
|
+
function ri(e, n, t, r, i, a) {
|
|
1980
2060
|
const o = n ?? void 0, s = t ?? e.regionId, c = i ? e.salesChannel || o : o ?? e.salesChannel, d = a != null && a !== String(c ?? "");
|
|
1981
|
-
return
|
|
2061
|
+
return oe.stringify({
|
|
1982
2062
|
salesChannel: c,
|
|
1983
2063
|
regionId: s ?? void 0,
|
|
1984
2064
|
seller: r,
|
|
@@ -1987,16 +2067,16 @@ function Hr(e, n, t, r, i, a) {
|
|
|
1987
2067
|
...d ? { rejectedSalesChannel: a } : {}
|
|
1988
2068
|
});
|
|
1989
2069
|
}
|
|
1990
|
-
const
|
|
1991
|
-
function
|
|
2070
|
+
const nn = "1";
|
|
2071
|
+
function ii(e, n, t, r) {
|
|
1992
2072
|
const i = String(e.salesChannel ?? "");
|
|
1993
|
-
return n === void 0 && i ===
|
|
2073
|
+
return n === void 0 && i === nn && !!t && t !== nn && !new URLSearchParams(r).has("sc") ? t : i;
|
|
1994
2074
|
}
|
|
1995
|
-
const
|
|
1996
|
-
e.storage.channel =
|
|
2075
|
+
const te = (e, n) => {
|
|
2076
|
+
e.storage.channel = oe.parse(n);
|
|
1997
2077
|
}, Ae = (e, n) => {
|
|
1998
2078
|
e.storage.locale = n;
|
|
1999
|
-
},
|
|
2079
|
+
}, Ne = (e) => gt.createHash("md5").update(e).digest("hex"), x = {
|
|
2000
2080
|
attachment: "ATTACHMENT",
|
|
2001
2081
|
specification: "SPECIFICATION",
|
|
2002
2082
|
attribute: "ATTRIBUTE",
|
|
@@ -2007,75 +2087,75 @@ const ne = (e, n) => {
|
|
|
2007
2087
|
*/
|
|
2008
2088
|
service: "SERVICE"
|
|
2009
2089
|
};
|
|
2010
|
-
function
|
|
2090
|
+
function Mn(e) {
|
|
2011
2091
|
return {
|
|
2012
2092
|
name: e.name,
|
|
2013
2093
|
value: e.content,
|
|
2014
|
-
valueReference:
|
|
2094
|
+
valueReference: x.attachment
|
|
2015
2095
|
};
|
|
2016
2096
|
}
|
|
2017
|
-
function
|
|
2097
|
+
function ai(e) {
|
|
2018
2098
|
return {
|
|
2019
2099
|
propertyID: e.id,
|
|
2020
2100
|
name: e.name,
|
|
2021
2101
|
value: e.value,
|
|
2022
2102
|
valueReference: {
|
|
2023
|
-
valueReference:
|
|
2103
|
+
valueReference: x.attribute,
|
|
2024
2104
|
visible: e.visible
|
|
2025
2105
|
}
|
|
2026
2106
|
};
|
|
2027
2107
|
}
|
|
2028
|
-
function
|
|
2029
|
-
return
|
|
2108
|
+
function zn(e) {
|
|
2109
|
+
return Ne(
|
|
2030
2110
|
`${e.name}:${JSON.stringify(e.value)}:${e.valueReference}`
|
|
2031
2111
|
);
|
|
2032
2112
|
}
|
|
2033
|
-
const
|
|
2113
|
+
const Vn = (e, n) => e < n ? -1 : e > n ? 1 : 0, oi = (e, n) => Vn(e.name, n.name), si = (e) => [...e ?? []].sort(oi), tn = (e) => e !== null && typeof e == "object" && !Array.isArray(e), ci = (e) => tn(e) && typeof e.name == "string" && tn(e.content), li = (e) => ({
|
|
2034
2114
|
name: e.name,
|
|
2035
2115
|
content: Object.fromEntries(
|
|
2036
|
-
Object.keys(e.content).sort(
|
|
2116
|
+
Object.keys(e.content).sort(Vn).map((n) => [n, e.content[n]])
|
|
2037
2117
|
)
|
|
2038
|
-
}),
|
|
2118
|
+
}), xn = (e, n) => Ne(
|
|
2039
2119
|
`SERVICE:${e}:${JSON.stringify(
|
|
2040
|
-
|
|
2041
|
-
|
|
2120
|
+
si((n ?? []).filter(ci)).map(
|
|
2121
|
+
li
|
|
2042
2122
|
)
|
|
2043
2123
|
)}`
|
|
2044
|
-
),
|
|
2045
|
-
function
|
|
2124
|
+
), di = "SERVICE:unreadable";
|
|
2125
|
+
function Fe(e) {
|
|
2046
2126
|
const n = e.attachments ?? [];
|
|
2047
2127
|
return {
|
|
2048
|
-
propertyID:
|
|
2128
|
+
propertyID: xn(e.id, n),
|
|
2049
2129
|
name: e.name,
|
|
2050
2130
|
value: {
|
|
2051
2131
|
id: e.id,
|
|
2052
2132
|
price: e.sellingPrice / 100,
|
|
2053
2133
|
attachments: n
|
|
2054
2134
|
},
|
|
2055
|
-
valueReference:
|
|
2135
|
+
valueReference: x.service
|
|
2056
2136
|
};
|
|
2057
2137
|
}
|
|
2058
|
-
const
|
|
2138
|
+
const ui = (e) => {
|
|
2059
2139
|
try {
|
|
2060
2140
|
return JSON.parse(e);
|
|
2061
2141
|
} catch {
|
|
2062
2142
|
return null;
|
|
2063
2143
|
}
|
|
2064
|
-
},
|
|
2065
|
-
const n = typeof e == "string" ?
|
|
2144
|
+
}, pi = (e) => {
|
|
2145
|
+
const n = typeof e == "string" ? ui(e) : e;
|
|
2066
2146
|
if (n === null || typeof n != "object")
|
|
2067
2147
|
return null;
|
|
2068
2148
|
const { id: t, attachments: r } = n;
|
|
2069
2149
|
return typeof t != "string" && typeof t != "number" ? null : { id: String(t), attachments: r };
|
|
2070
2150
|
};
|
|
2071
|
-
function
|
|
2072
|
-
const n =
|
|
2073
|
-
return n ?
|
|
2151
|
+
function gi(e) {
|
|
2152
|
+
const n = pi(e.value);
|
|
2153
|
+
return n ? xn(
|
|
2074
2154
|
n.id,
|
|
2075
2155
|
Array.isArray(n.attachments) ? n.attachments : []
|
|
2076
|
-
) :
|
|
2156
|
+
) : di;
|
|
2077
2157
|
}
|
|
2078
|
-
const
|
|
2158
|
+
const mi = (e) => {
|
|
2079
2159
|
const n = e.postalCode, t = e.geoCoordinates, r = {
|
|
2080
2160
|
addressType: e.addressType || null,
|
|
2081
2161
|
postalCode: n || null,
|
|
@@ -2094,7 +2174,7 @@ const ri = (e) => {
|
|
|
2094
2174
|
r.geoCoordinates = i !== null && a !== null ? [a, i] : [];
|
|
2095
2175
|
}
|
|
2096
2176
|
return [r];
|
|
2097
|
-
},
|
|
2177
|
+
}, hi = (e, n, t) => {
|
|
2098
2178
|
const r = n.postalCode, i = n.geoCoordinates, a = e?.shippingData?.availableAddresses ?? [], o = e?.shippingData?.selectedAddresses ?? [];
|
|
2099
2179
|
if (!t && o.length > 0)
|
|
2100
2180
|
return [o[0]];
|
|
@@ -2108,35 +2188,35 @@ const ri = (e) => {
|
|
|
2108
2188
|
return [s];
|
|
2109
2189
|
}
|
|
2110
2190
|
return null;
|
|
2111
|
-
},
|
|
2112
|
-
if (!
|
|
2191
|
+
}, qn = (e, n) => {
|
|
2192
|
+
if (!fi(n))
|
|
2113
2193
|
return { updateShipping: !1, addressChanged: !1 };
|
|
2114
|
-
if (!
|
|
2194
|
+
if (!vi(e))
|
|
2115
2195
|
return { updateShipping: !1, addressChanged: !1 };
|
|
2116
2196
|
const [t] = e?.shippingData?.selectedAddresses ?? [];
|
|
2117
|
-
if (
|
|
2197
|
+
if (Si(t, n.postalCode) || yi(t, n.geoCoordinates) || Ii(t, n.addressType))
|
|
2118
2198
|
return { updateShipping: !0, addressChanged: !0 };
|
|
2119
2199
|
const { logisticsInfo: r } = e.shippingData;
|
|
2120
|
-
return
|
|
2121
|
-
},
|
|
2200
|
+
return Oi(r, n) ? { updateShipping: !0, addressChanged: !1 } : { updateShipping: !1, addressChanged: !1 };
|
|
2201
|
+
}, fi = (e) => !!e.postalCode || e.geoCoordinates?.latitude && e.geoCoordinates?.longitude, Si = (e, n) => typeof n == "string" && e?.postalCode !== n, yi = (e, n) => typeof n?.latitude == "number" && typeof n?.longitude == "number" && (e?.geoCoordinates[0] !== n?.longitude || e?.geoCoordinates[1] !== n?.latitude), Ii = (e, n) => typeof n == "string" && e?.addressType !== n, vi = (e) => e.items.length !== 0, Oi = (e, n) => {
|
|
2122
2202
|
const t = n?.deliveryMode?.deliveryChannel, r = n?.deliveryMode?.deliveryMethod, { startDate: i, endDate: a } = n?.deliveryMode?.deliveryWindow || {};
|
|
2123
2203
|
return e.some(
|
|
2124
2204
|
({ selectedDeliveryChannel: o, selectedSla: s, slas: c }) => {
|
|
2125
2205
|
const d = t && o !== t, g = r && s !== r;
|
|
2126
|
-
return c?.some((
|
|
2206
|
+
return c?.some((u) => d && u.deliveryChannel === t || g && u.id === r ? !0 : i && a && u.deliveryChannel === t && u.id === r && (!u?.deliveryWindow || u?.deliveryWindow?.startDateUtc !== i || u?.deliveryWindow?.endDateUtc !== a) && u.availableDeliveryWindows?.some(
|
|
2127
2207
|
(f) => f?.startDateUtc === i && f?.endDateUtc === a
|
|
2128
2208
|
));
|
|
2129
2209
|
}
|
|
2130
2210
|
);
|
|
2131
|
-
},
|
|
2132
|
-
const n =
|
|
2211
|
+
}, jn = (e) => e.valueReference === x.attachment, Ci = (e) => e.valueReference === x.service, bi = (e) => (e.itemOffered.additionalProperty ?? []).filter(Ci).map(gi).sort((n, t) => n.localeCompare(t)), Wn = (e) => {
|
|
2212
|
+
const n = bi(e);
|
|
2133
2213
|
return n.length > 0 ? `services:${n.join("-")}` : void 0;
|
|
2134
|
-
},
|
|
2214
|
+
}, Pe = (e) => [
|
|
2135
2215
|
e.itemOffered.sku,
|
|
2136
2216
|
e.seller.identifier,
|
|
2137
2217
|
e.price < 0.01 ? "Gift" : void 0,
|
|
2138
|
-
e.itemOffered.additionalProperty?.filter(
|
|
2139
|
-
|
|
2218
|
+
e.itemOffered.additionalProperty?.filter(jn).map(zn).join("-"),
|
|
2219
|
+
Wn(e)
|
|
2140
2220
|
].filter(Boolean).join("::"), me = (e, n) => ({
|
|
2141
2221
|
listPrice: e.listPrice / 100,
|
|
2142
2222
|
price: e.sellingPrice / 100,
|
|
@@ -2147,49 +2227,49 @@ const ri = (e) => {
|
|
|
2147
2227
|
image: [],
|
|
2148
2228
|
name: e.name,
|
|
2149
2229
|
additionalProperty: [
|
|
2150
|
-
...e.attachments.map(
|
|
2151
|
-
...(e.bundleItems ?? []).map(
|
|
2230
|
+
...e.attachments.map(Mn),
|
|
2231
|
+
...(e.bundleItems ?? []).map(Fe)
|
|
2152
2232
|
]
|
|
2153
2233
|
},
|
|
2154
2234
|
index: n
|
|
2155
|
-
}),
|
|
2235
|
+
}), wi = (e) => ({
|
|
2156
2236
|
quantity: e.quantity,
|
|
2157
2237
|
seller: e.seller.identifier,
|
|
2158
2238
|
id: e.itemOffered.sku,
|
|
2159
2239
|
index: e.index,
|
|
2160
|
-
attachments: (e.itemOffered.additionalProperty?.filter(
|
|
2240
|
+
attachments: (e.itemOffered.additionalProperty?.filter(jn) ?? []).map((n) => ({
|
|
2161
2241
|
name: n.name,
|
|
2162
2242
|
content: n.value
|
|
2163
2243
|
})),
|
|
2164
2244
|
...e.priceToken ? { priceToken: e.priceToken } : {}
|
|
2165
|
-
}),
|
|
2166
|
-
const r =
|
|
2245
|
+
}), rn = (e) => e.reduce((n, t) => {
|
|
2246
|
+
const r = Pe(t);
|
|
2167
2247
|
return n.has(r) || n.set(r, []), n.get(r)?.push(t), n;
|
|
2168
|
-
}, /* @__PURE__ */ new Map()),
|
|
2248
|
+
}, /* @__PURE__ */ new Map()), Ai = (e, n) => {
|
|
2169
2249
|
const t = ({ priceToken: s, ...c }, d) => ({
|
|
2170
2250
|
...c,
|
|
2171
2251
|
itemOffered: {
|
|
2172
2252
|
sku: c.itemOffered.sku
|
|
2173
2253
|
},
|
|
2174
|
-
services:
|
|
2254
|
+
services: Wn(c),
|
|
2175
2255
|
index: d
|
|
2176
|
-
}), r = n.items.map(me).map(t), i = e.acceptedOffer.map(t), a = e.orderNumber === n.orderFormId, o =
|
|
2256
|
+
}), r = n.items.map(me).map(t), i = e.acceptedOffer.map(t), a = e.orderNumber === n.orderFormId, o = Te(r, i);
|
|
2177
2257
|
return a && o;
|
|
2178
2258
|
};
|
|
2179
|
-
function
|
|
2259
|
+
function Hn(e, n) {
|
|
2180
2260
|
return e?.some(
|
|
2181
2261
|
(t) => t.parentItemIndex !== null && t.parentItemIndex !== void 0 && e[t.parentItemIndex]?.id === n
|
|
2182
2262
|
);
|
|
2183
2263
|
}
|
|
2184
|
-
function
|
|
2264
|
+
function Gn(e, n) {
|
|
2185
2265
|
return e?.some(
|
|
2186
2266
|
(t) => t.id === n && t.parentItemIndex !== null
|
|
2187
2267
|
);
|
|
2188
2268
|
}
|
|
2189
|
-
const
|
|
2269
|
+
const an = (e) => {
|
|
2190
2270
|
const n = e.items.reduce(
|
|
2191
2271
|
(t, r, i) => {
|
|
2192
|
-
const a =
|
|
2272
|
+
const a = Gn(e.items, r.id) || Hn(e.items, r.id) ? `${Pe(me(r))}::${i}` : Pe(me(r));
|
|
2193
2273
|
return t[a] || (t[a] = []), t[a].push(r), t;
|
|
2194
2274
|
},
|
|
2195
2275
|
{}
|
|
@@ -2208,7 +2288,7 @@ const Qe = (e) => {
|
|
|
2208
2288
|
};
|
|
2209
2289
|
})
|
|
2210
2290
|
};
|
|
2211
|
-
},
|
|
2291
|
+
}, De = async (e, n, t, r) => ({
|
|
2212
2292
|
order: {
|
|
2213
2293
|
orderNumber: e.orderFormId,
|
|
2214
2294
|
acceptedOffer: e.items.map(async (i) => ({
|
|
@@ -2222,9 +2302,9 @@ const Qe = (e) => {
|
|
|
2222
2302
|
text: i,
|
|
2223
2303
|
status: a.toUpperCase()
|
|
2224
2304
|
}))
|
|
2225
|
-
}),
|
|
2305
|
+
}), Xn = ({ items: e }, n) => {
|
|
2226
2306
|
const t = e.map((r) => {
|
|
2227
|
-
const i = (r.bundleItems ?? []).map(
|
|
2307
|
+
const i = (r.bundleItems ?? []).map(Fe).map(({ propertyID: a }) => a).sort((a, o) => a.localeCompare(o));
|
|
2228
2308
|
return {
|
|
2229
2309
|
id: r.id,
|
|
2230
2310
|
quantity: r.quantity,
|
|
@@ -2234,16 +2314,16 @@ const Qe = (e) => {
|
|
|
2234
2314
|
...i.length > 0 ? { services: i } : {}
|
|
2235
2315
|
};
|
|
2236
2316
|
});
|
|
2237
|
-
return
|
|
2317
|
+
return Ne(
|
|
2238
2318
|
JSON.stringify({ sessionId: n?.id ?? "", items: t })
|
|
2239
2319
|
);
|
|
2240
|
-
},
|
|
2320
|
+
}, on = async (e, n, t) => {
|
|
2241
2321
|
try {
|
|
2242
2322
|
return await n.checkout.setCustomData({
|
|
2243
2323
|
id: e.orderFormId,
|
|
2244
2324
|
appId: "faststore",
|
|
2245
2325
|
key: "cartEtag",
|
|
2246
|
-
value:
|
|
2326
|
+
value: Xn(e, t)
|
|
2247
2327
|
});
|
|
2248
2328
|
} catch (r) {
|
|
2249
2329
|
throw console.error(
|
|
@@ -2253,22 +2333,22 @@ const Qe = (e) => {
|
|
|
2253
2333
|
More info at: https://developers.vtex.com/vtex-rest-api/docs/customizable-fields-with-checkout-api`
|
|
2254
2334
|
), r;
|
|
2255
2335
|
}
|
|
2256
|
-
},
|
|
2336
|
+
}, Pi = (e, n) => {
|
|
2257
2337
|
const r = e.customData?.customApps.find(
|
|
2258
2338
|
(a) => a.id === "faststore"
|
|
2259
2339
|
)?.fields?.cartEtag;
|
|
2260
|
-
return r == null ? !0 :
|
|
2261
|
-
},
|
|
2340
|
+
return r == null ? !0 : Xn(e, n) !== r;
|
|
2341
|
+
}, Di = async (e, { clients: { commerce: n } }) => n.checkout.clearOrderFormMessages({
|
|
2262
2342
|
id: e
|
|
2263
|
-
}),
|
|
2343
|
+
}), sn = async (e, n, { clients: { commerce: t } }) => {
|
|
2264
2344
|
if (!n)
|
|
2265
2345
|
return e;
|
|
2266
|
-
const { updateShipping: r, addressChanged: i } =
|
|
2346
|
+
const { updateShipping: r, addressChanged: i } = qn(
|
|
2267
2347
|
e,
|
|
2268
2348
|
n
|
|
2269
2349
|
);
|
|
2270
2350
|
if (r) {
|
|
2271
|
-
const a =
|
|
2351
|
+
const a = hi(e, n, i), s = a || mi(n);
|
|
2272
2352
|
return !!n.deliveryMode?.deliveryWindow && await t.checkout.shippingData(
|
|
2273
2353
|
{
|
|
2274
2354
|
id: e.orderFormId,
|
|
@@ -2288,18 +2368,18 @@ const Qe = (e) => {
|
|
|
2288
2368
|
);
|
|
2289
2369
|
}
|
|
2290
2370
|
return e;
|
|
2291
|
-
},
|
|
2371
|
+
}, Ei = (e, n) => {
|
|
2292
2372
|
if (!e)
|
|
2293
2373
|
return "";
|
|
2294
|
-
const r =
|
|
2374
|
+
const r = ae(e)[n];
|
|
2295
2375
|
return r ? r.split("=")[1] : "";
|
|
2296
|
-
},
|
|
2376
|
+
}, ki = async (e, n, t, r) => {
|
|
2297
2377
|
const { commerce: i } = e.clients, a = await i.checkout.orderForm({
|
|
2298
2378
|
id: n,
|
|
2299
2379
|
channel: e.storage.channel,
|
|
2300
2380
|
preserveSalesChannel: !!n && !t
|
|
2301
2381
|
});
|
|
2302
|
-
return !n ||
|
|
2382
|
+
return !n || ti(
|
|
2303
2383
|
a,
|
|
2304
2384
|
e.storage.channel.salesChannel,
|
|
2305
2385
|
r
|
|
@@ -2307,156 +2387,156 @@ const Qe = (e) => {
|
|
|
2307
2387
|
id: n,
|
|
2308
2388
|
channel: e.storage.channel
|
|
2309
2389
|
});
|
|
2310
|
-
},
|
|
2390
|
+
}, cn = (e, n, t) => {
|
|
2311
2391
|
if (!t || n.items.length === 0)
|
|
2312
2392
|
return null;
|
|
2313
|
-
const r =
|
|
2393
|
+
const r = ni(
|
|
2314
2394
|
e.storage.channel,
|
|
2315
2395
|
n.salesChannel
|
|
2316
2396
|
);
|
|
2317
|
-
return r ? (
|
|
2318
|
-
},
|
|
2319
|
-
const i =
|
|
2397
|
+
return r ? (te(e, r), n.salesChannel ? String(n.salesChannel) : null) : null;
|
|
2398
|
+
}, ln = (e, n, t, r) => r ? De(e, n, t, r) : null, _i = async (e, { cart: { order: n }, session: t }, r) => {
|
|
2399
|
+
const i = Ei(
|
|
2320
2400
|
r.headers.cookie,
|
|
2321
2401
|
"checkout.vtex.com"
|
|
2322
2402
|
), {
|
|
2323
2403
|
clients: { commerce: a },
|
|
2324
2404
|
loaders: { skuLoader: o }
|
|
2325
|
-
} = r, s = t?.channel, c = t?.locale, d =
|
|
2326
|
-
localizationEnabled:
|
|
2327
|
-
}) === "url", g =
|
|
2328
|
-
s &&
|
|
2329
|
-
const
|
|
2405
|
+
} = r, s = t?.channel, c = t?.locale, d = Ln(s, {
|
|
2406
|
+
localizationEnabled: Bn(r.discoveryConfig)
|
|
2407
|
+
}) === "url", g = $n(s);
|
|
2408
|
+
s && te(r, s), c && Ae(r, c);
|
|
2409
|
+
const u = await ki(
|
|
2330
2410
|
r,
|
|
2331
2411
|
i || void 0,
|
|
2332
2412
|
d,
|
|
2333
2413
|
g
|
|
2334
|
-
), f =
|
|
2335
|
-
|
|
2336
|
-
const h =
|
|
2337
|
-
if (
|
|
2338
|
-
const
|
|
2414
|
+
), f = u.orderFormId;
|
|
2415
|
+
u.messages.length !== 0 && await Di(f, r);
|
|
2416
|
+
const h = ae(r?.headers?.cookie ?? "")?.vtex_session, I = G(h), { acceptedOffer: l, shouldSplitItem: p } = n;
|
|
2417
|
+
if (Pi(u, I)) {
|
|
2418
|
+
const P = cn(
|
|
2339
2419
|
r,
|
|
2340
|
-
|
|
2420
|
+
u,
|
|
2341
2421
|
!d
|
|
2342
|
-
),
|
|
2343
|
-
|
|
2422
|
+
), R = await on(
|
|
2423
|
+
u,
|
|
2344
2424
|
a,
|
|
2345
2425
|
I
|
|
2346
|
-
).then(
|
|
2426
|
+
).then(an);
|
|
2347
2427
|
if (f)
|
|
2348
|
-
return
|
|
2349
|
-
|
|
2428
|
+
return De(
|
|
2429
|
+
R,
|
|
2350
2430
|
o,
|
|
2351
|
-
|
|
2352
|
-
|
|
2431
|
+
p,
|
|
2432
|
+
P
|
|
2353
2433
|
);
|
|
2354
2434
|
}
|
|
2355
|
-
const S =
|
|
2435
|
+
const S = cn(
|
|
2356
2436
|
r,
|
|
2357
|
-
|
|
2437
|
+
u,
|
|
2358
2438
|
!d
|
|
2359
|
-
), v =
|
|
2360
|
-
(
|
|
2361
|
-
const
|
|
2362
|
-
if (!
|
|
2363
|
-
return
|
|
2364
|
-
const [
|
|
2365
|
-
if (
|
|
2366
|
-
return
|
|
2367
|
-
const
|
|
2368
|
-
return
|
|
2369
|
-
...
|
|
2370
|
-
quantity:
|
|
2371
|
-
}),
|
|
2439
|
+
), v = rn(l), O = rn(u.items.map(me)), C = Array.from(O.entries()), T = Array.from(v.entries()), { itemsToAdd: w, itemsToUpdate: b } = T.reduce(
|
|
2440
|
+
(P, [R, $]) => {
|
|
2441
|
+
const Z = O.get(R);
|
|
2442
|
+
if (!Z)
|
|
2443
|
+
return $.forEach((ee) => P.itemsToAdd.push(ee)), P;
|
|
2444
|
+
const [M, ...nt] = Z;
|
|
2445
|
+
if (Gn(u.items, M.itemOffered.sku) || Hn(u.items, M.itemOffered.sku))
|
|
2446
|
+
return P.itemsToUpdate.push(M), P;
|
|
2447
|
+
const tt = $.reduce((ee, rt) => ee + rt.quantity, 0);
|
|
2448
|
+
return P.itemsToUpdate.push({
|
|
2449
|
+
...M,
|
|
2450
|
+
quantity: tt
|
|
2451
|
+
}), nt.forEach((ee) => P.itemsToUpdate.push({ ...ee, quantity: 0 })), P;
|
|
2372
2452
|
},
|
|
2373
2453
|
{
|
|
2374
2454
|
itemsToAdd: [],
|
|
2375
2455
|
itemsToUpdate: []
|
|
2376
2456
|
}
|
|
2377
|
-
),
|
|
2378
|
-
|
|
2379
|
-
), { updateShipping:
|
|
2380
|
-
if (
|
|
2381
|
-
return
|
|
2382
|
-
p,
|
|
2383
|
-
o,
|
|
2457
|
+
), A = C.filter(([P]) => !v.has(P)).flatMap(([, P]) => P.map((R) => ({ ...R, quantity: 0 }))), E = [...w, ...b, ...A].map(
|
|
2458
|
+
wi
|
|
2459
|
+
), { updateShipping: _ } = t ? qn(u, t) : { updateShipping: !1 };
|
|
2460
|
+
if (E.length === 0 && !_)
|
|
2461
|
+
return ln(
|
|
2384
2462
|
u,
|
|
2463
|
+
o,
|
|
2464
|
+
p,
|
|
2385
2465
|
S
|
|
2386
2466
|
);
|
|
2387
|
-
let
|
|
2388
|
-
|
|
2389
|
-
id:
|
|
2390
|
-
orderItems:
|
|
2391
|
-
shouldSplitItem:
|
|
2467
|
+
let D;
|
|
2468
|
+
E.length > 0 ? D = await a.checkout.updateOrderFormItems({
|
|
2469
|
+
id: u.orderFormId,
|
|
2470
|
+
orderItems: E,
|
|
2471
|
+
shouldSplitItem: p
|
|
2392
2472
|
}).then(
|
|
2393
|
-
(
|
|
2394
|
-
) :
|
|
2395
|
-
|
|
2473
|
+
(P) => sn(P, t, r)
|
|
2474
|
+
) : D = await sn(
|
|
2475
|
+
u,
|
|
2396
2476
|
t,
|
|
2397
2477
|
r
|
|
2398
|
-
),
|
|
2478
|
+
), D = await Promise.resolve(D).then((P) => {
|
|
2399
2479
|
if (t?.marketingData) {
|
|
2400
|
-
const
|
|
2401
|
-
...
|
|
2480
|
+
const R = {
|
|
2481
|
+
...P.marketingData,
|
|
2402
2482
|
...t.marketingData
|
|
2403
2483
|
};
|
|
2404
2484
|
return a.checkout.marketingData({
|
|
2405
|
-
id:
|
|
2406
|
-
marketingData:
|
|
2485
|
+
id: u.orderFormId,
|
|
2486
|
+
marketingData: R
|
|
2407
2487
|
});
|
|
2408
2488
|
}
|
|
2409
|
-
return
|
|
2410
|
-
}).then((
|
|
2411
|
-
id:
|
|
2489
|
+
return P;
|
|
2490
|
+
}).then((P) => c && P.clientPreferencesData?.locale !== c ? a.checkout.clientPreferencesData({
|
|
2491
|
+
id: P.orderFormId,
|
|
2412
2492
|
clientPreferencesData: {
|
|
2413
|
-
...
|
|
2493
|
+
...P.clientPreferencesData,
|
|
2414
2494
|
locale: c
|
|
2415
2495
|
}
|
|
2416
|
-
}) :
|
|
2417
|
-
const
|
|
2418
|
-
|
|
2419
|
-
|
|
2496
|
+
}) : P).then((P) => on(P, a, I)).then(an);
|
|
2497
|
+
const U = Te(
|
|
2498
|
+
u.messages,
|
|
2499
|
+
D.messages
|
|
2420
2500
|
);
|
|
2421
|
-
return
|
|
2422
|
-
|
|
2501
|
+
return Ai(n, D) && U ? ln(
|
|
2502
|
+
D,
|
|
2423
2503
|
o,
|
|
2424
|
-
|
|
2504
|
+
p,
|
|
2425
2505
|
S
|
|
2426
|
-
) :
|
|
2427
|
-
|
|
2506
|
+
) : De(
|
|
2507
|
+
D,
|
|
2428
2508
|
o,
|
|
2429
|
-
|
|
2509
|
+
p,
|
|
2430
2510
|
S
|
|
2431
2511
|
);
|
|
2432
|
-
},
|
|
2512
|
+
}, Ti = (e) => {
|
|
2433
2513
|
const n = (e?.corporateName ?? "").trim();
|
|
2434
2514
|
return n || (e?.firstName ?? "").trim();
|
|
2435
|
-
},
|
|
2515
|
+
}, Ui = (e) => {
|
|
2436
2516
|
if (!e || typeof e != "object")
|
|
2437
2517
|
return !1;
|
|
2438
2518
|
const n = e;
|
|
2439
2519
|
return typeof n.customerId == "string" && n.customerId.trim() !== "" && typeof n.contractName == "string" && typeof n.isActive == "boolean" && typeof n.isCurrent == "boolean";
|
|
2440
|
-
},
|
|
2520
|
+
}, Ri = (e) => {
|
|
2441
2521
|
const n = e?.availableContracts?.value;
|
|
2442
|
-
return Array.isArray(n) ? n.filter(
|
|
2443
|
-
},
|
|
2522
|
+
return Array.isArray(n) ? n.filter(Ui) : [];
|
|
2523
|
+
}, Ni = (e) => e?.customerId ? !!((e.contractName ?? "").trim() && e.isActive) : !1, Fi = (e) => e?.namespaces?.shopper?.activeContractId?.value?.trim() ?? e?.namespaces?.authentication?.customerId?.value?.trim() ?? e?.namespaces?.profile?.id?.value?.trim() ?? "", Li = (e) => {
|
|
2444
2524
|
if (!Array.isArray(e) || e.length === 0) return "";
|
|
2445
2525
|
const n = e.find((t) => t?.isDefault === !0) ?? e[0];
|
|
2446
2526
|
return String(n?.id ?? "").trim();
|
|
2447
|
-
},
|
|
2527
|
+
}, Bi = (e, n = "", t = "") => {
|
|
2448
2528
|
const r = n.trim(), i = t.trim();
|
|
2449
|
-
return e.filter(
|
|
2529
|
+
return e.filter(Ni).map((a) => ({
|
|
2450
2530
|
id: a.customerId,
|
|
2451
2531
|
corporateName: a.contractName.trim(),
|
|
2452
2532
|
isActive: r ? a.customerId === r : a.isCurrent,
|
|
2453
2533
|
isDefault: i !== "" && a.customerId === i
|
|
2454
2534
|
}));
|
|
2455
|
-
},
|
|
2456
|
-
const t =
|
|
2535
|
+
}, Yn = (e, n) => {
|
|
2536
|
+
const t = Ti(e);
|
|
2457
2537
|
return t || (n?.firstName?.value ?? "").trim();
|
|
2458
2538
|
};
|
|
2459
|
-
async function
|
|
2539
|
+
async function $i(e, n, t) {
|
|
2460
2540
|
try {
|
|
2461
2541
|
const r = await e.commerce.checkout.address({
|
|
2462
2542
|
postalCode: t,
|
|
@@ -2473,7 +2553,7 @@ async function Di(e, n, t) {
|
|
|
2473
2553
|
), r;
|
|
2474
2554
|
}
|
|
2475
2555
|
}
|
|
2476
|
-
function
|
|
2556
|
+
function Mi(e, n, t, r, i, a) {
|
|
2477
2557
|
const o = new URLSearchParams(e);
|
|
2478
2558
|
return o.has("facets") && o.delete("facets"), o.set("sc", o.get("sc") ?? n.salesChannel), t && o.set("postalCode", t), r && o.set("country", r), i && o.set(
|
|
2479
2559
|
"geoCoordinates",
|
|
@@ -2481,7 +2561,7 @@ function Pi(e, n, t, r, i, a) {
|
|
|
2481
2561
|
// long,lat is the format expected
|
|
2482
2562
|
), o.set("locale", a), o;
|
|
2483
2563
|
}
|
|
2484
|
-
function
|
|
2564
|
+
function zi(e, n) {
|
|
2485
2565
|
return {
|
|
2486
2566
|
utmCampaign: e.get("utm_campaign") ?? n?.utmCampaign ?? "",
|
|
2487
2567
|
utmMedium: e.get("utm_medium") ?? n?.utmMedium ?? "",
|
|
@@ -2491,8 +2571,8 @@ function ki(e, n) {
|
|
|
2491
2571
|
utmiPart: e.get("utmi_pc") ?? n?.utmiPart ?? ""
|
|
2492
2572
|
};
|
|
2493
2573
|
}
|
|
2494
|
-
async function
|
|
2495
|
-
const r =
|
|
2574
|
+
async function Vi(e, n, t) {
|
|
2575
|
+
const r = G(z(n ?? "", t));
|
|
2496
2576
|
let i = !1;
|
|
2497
2577
|
if (r)
|
|
2498
2578
|
try {
|
|
@@ -2501,12 +2581,11 @@ async function Ei(e, n, t) {
|
|
|
2501
2581
|
console.warn("JWT validation failed:", a), i = !1;
|
|
2502
2582
|
}
|
|
2503
2583
|
return {
|
|
2504
|
-
isRepresentative: i ? !!r?.isRepresentative : !1,
|
|
2505
2584
|
customerId: i ? r?.customerId : void 0,
|
|
2506
2585
|
unitId: i ? r?.unitId : void 0
|
|
2507
2586
|
};
|
|
2508
2587
|
}
|
|
2509
|
-
async function
|
|
2588
|
+
async function xi(e, n, t, r, i, a) {
|
|
2510
2589
|
return !n.seller || !(t || r) ? void 0 : (await e.commerce.checkout.region({
|
|
2511
2590
|
postalCode: t,
|
|
2512
2591
|
geoCoordinates: r,
|
|
@@ -2514,28 +2593,43 @@ async function Ui(e, n, t, r, i, a) {
|
|
|
2514
2593
|
salesChannel: a
|
|
2515
2594
|
}))?.[0]?.sellers.find((c) => n.seller === c.id)?.id;
|
|
2516
2595
|
}
|
|
2517
|
-
function
|
|
2596
|
+
function dn(e) {
|
|
2518
2597
|
return typeof e?.value == "string" ? e.value : "";
|
|
2519
2598
|
}
|
|
2520
|
-
function
|
|
2521
|
-
|
|
2599
|
+
function Le(...e) {
|
|
2600
|
+
for (const n of e) {
|
|
2601
|
+
const t = typeof n == "string" ? n.trim() : "";
|
|
2602
|
+
if (t) return t;
|
|
2603
|
+
}
|
|
2604
|
+
return "";
|
|
2605
|
+
}
|
|
2606
|
+
function Be(e, n) {
|
|
2607
|
+
return Le(e?.unitId?.value, n);
|
|
2608
|
+
}
|
|
2609
|
+
function qi(e) {
|
|
2610
|
+
const n = Be(e.authentication, e.unitId), t = Le(
|
|
2611
|
+
e.shopper?.activeContractId?.value,
|
|
2612
|
+
e.authentication?.customerId?.value,
|
|
2613
|
+
e.customerId
|
|
2614
|
+
);
|
|
2615
|
+
if (!n || !t)
|
|
2522
2616
|
return null;
|
|
2523
|
-
const
|
|
2617
|
+
const r = dn(e.shopper?.firstName), i = dn(e.shopper?.lastName);
|
|
2524
2618
|
return {
|
|
2525
2619
|
isRepresentative: !0,
|
|
2526
|
-
customerId:
|
|
2620
|
+
customerId: t,
|
|
2527
2621
|
unitName: e.authentication?.unitName?.value ?? "",
|
|
2528
|
-
unitId:
|
|
2529
|
-
firstName:
|
|
2530
|
-
lastName:
|
|
2531
|
-
userName: `${
|
|
2622
|
+
unitId: n,
|
|
2623
|
+
firstName: r,
|
|
2624
|
+
lastName: i,
|
|
2625
|
+
userName: `${r} ${i}`.trim(),
|
|
2532
2626
|
userEmail: e.authentication?.storeUserEmail?.value ?? "",
|
|
2533
2627
|
savedPostalCode: e.publicData?.postalCode?.value ?? "",
|
|
2534
|
-
contractName:
|
|
2628
|
+
contractName: Yn(e.contract, e.profile),
|
|
2535
2629
|
organizationManager: e.shopper?.organizationManager?.value ?? !1
|
|
2536
2630
|
};
|
|
2537
2631
|
}
|
|
2538
|
-
function
|
|
2632
|
+
function ji(e) {
|
|
2539
2633
|
return e?.id ? {
|
|
2540
2634
|
id: e.id?.value ?? "",
|
|
2541
2635
|
email: e.email?.value ?? "",
|
|
@@ -2543,14 +2637,14 @@ function Ri(e) {
|
|
|
2543
2637
|
familyName: e.lastName?.value ?? ""
|
|
2544
2638
|
} : null;
|
|
2545
2639
|
}
|
|
2546
|
-
const
|
|
2640
|
+
const Wi = (e) => e instanceof Q && (e.extensions.status === 401 || e.extensions.status === 403), Hi = (e) => e instanceof Error && /sales\s*channel/i.test(e.message), Gi = (e, n, t, r) => {
|
|
2547
2641
|
if (n !== "orderForm" || t !== r)
|
|
2548
2642
|
return !1;
|
|
2549
|
-
if (
|
|
2643
|
+
if (Hi(e))
|
|
2550
2644
|
return !0;
|
|
2551
2645
|
const i = `[validateSession] Session Manager rejected adopted sales channel ${t} with an unrecognized error; keeping the adoption.`, a = e instanceof Error ? e.message : e;
|
|
2552
|
-
return console.warn(i, a),
|
|
2553
|
-
},
|
|
2646
|
+
return console.warn(i, a), Ue("warn", "%s %o", i, a), !1;
|
|
2647
|
+
}, Xi = async (e, n, t, r) => {
|
|
2554
2648
|
const i = { salesChannelSource: t, rejectedSalesChannel: void 0 };
|
|
2555
2649
|
try {
|
|
2556
2650
|
return {
|
|
@@ -2558,9 +2652,9 @@ const Ti = (e) => e instanceof J && (e.extensions.status === 401 || e.extensions
|
|
|
2558
2652
|
sessionData: await e.commerce.session(n.toString())
|
|
2559
2653
|
};
|
|
2560
2654
|
} catch (a) {
|
|
2561
|
-
if (t === "url" || !
|
|
2655
|
+
if (t === "url" || !Wi(a))
|
|
2562
2656
|
return { ...i, sessionData: null };
|
|
2563
|
-
const o = n.get("sc") ?? void 0, s =
|
|
2657
|
+
const o = n.get("sc") ?? void 0, s = Gi(
|
|
2564
2658
|
a,
|
|
2565
2659
|
t,
|
|
2566
2660
|
o,
|
|
@@ -2574,77 +2668,77 @@ const Ti = (e) => e instanceof J && (e.extensions.status === 401 || e.extensions
|
|
|
2574
2668
|
rejectedSalesChannel: o
|
|
2575
2669
|
};
|
|
2576
2670
|
}
|
|
2577
|
-
},
|
|
2578
|
-
const c =
|
|
2579
|
-
localizationEnabled:
|
|
2671
|
+
}, Yi = async (e, { session: n, search: t }, { clients: r, headers: i, account: a, storage: o, discoveryConfig: s }) => {
|
|
2672
|
+
const c = oe.parse(n.channel ?? ""), d = Ln(n.channel, {
|
|
2673
|
+
localizationEnabled: Bn(s)
|
|
2580
2674
|
}), g = {
|
|
2581
2675
|
...c,
|
|
2582
|
-
salesChannel:
|
|
2676
|
+
salesChannel: ii(
|
|
2583
2677
|
c,
|
|
2584
2678
|
d,
|
|
2585
2679
|
o?.channel?.salesChannel ? String(o.channel.salesChannel) : void 0,
|
|
2586
2680
|
t
|
|
2587
2681
|
)
|
|
2588
|
-
},
|
|
2682
|
+
}, u = String(n.postalCode ?? ""), f = n.country ?? "";
|
|
2589
2683
|
let h = n.city ?? null, I = n.geoCoordinates ?? null;
|
|
2590
|
-
if ((!h || !I) &&
|
|
2591
|
-
const
|
|
2684
|
+
if ((!h || !I) && u !== "" && f !== "") {
|
|
2685
|
+
const M = await $i(
|
|
2592
2686
|
r,
|
|
2593
2687
|
f,
|
|
2594
|
-
|
|
2688
|
+
u
|
|
2595
2689
|
);
|
|
2596
|
-
h =
|
|
2690
|
+
h = M.city, I = M.geoCoordinates;
|
|
2597
2691
|
}
|
|
2598
|
-
const
|
|
2692
|
+
const p = Mi(
|
|
2599
2693
|
t,
|
|
2600
2694
|
g,
|
|
2601
|
-
|
|
2695
|
+
u,
|
|
2602
2696
|
f,
|
|
2603
2697
|
I,
|
|
2604
2698
|
n.locale
|
|
2605
|
-
), m =
|
|
2699
|
+
), m = zi(p, n.marketingData), { customerId: S, unitId: v } = await Vi(
|
|
2606
2700
|
r,
|
|
2607
2701
|
i?.cookie,
|
|
2608
2702
|
a
|
|
2609
|
-
), { sessionData:
|
|
2703
|
+
), { sessionData: O, salesChannelSource: C, rejectedSalesChannel: T } = await Xi(
|
|
2610
2704
|
r,
|
|
2611
|
-
|
|
2705
|
+
p,
|
|
2612
2706
|
d,
|
|
2613
2707
|
String(g.salesChannel ?? "")
|
|
2614
|
-
),
|
|
2615
|
-
let
|
|
2616
|
-
if (
|
|
2708
|
+
), w = O?.namespaces.profile ?? null, b = O?.namespaces.shopper ?? null, A = O?.namespaces.store ?? null, E = O?.namespaces.authentication ?? null, _ = O?.namespaces.checkout ?? null, D = O?.namespaces.public ?? null;
|
|
2709
|
+
let U = null;
|
|
2710
|
+
if (Be(E, v) && w?.id?.value)
|
|
2617
2711
|
try {
|
|
2618
|
-
|
|
2619
|
-
contractId:
|
|
2712
|
+
U = await r.commerce.masterData.getContractById({
|
|
2713
|
+
contractId: w.id.value
|
|
2620
2714
|
});
|
|
2621
2715
|
} catch {
|
|
2622
2716
|
console.error(
|
|
2623
|
-
`Error while getting contract data for profile ID (${
|
|
2717
|
+
`Error while getting contract data for profile ID (${w.id.value}).
|
|
2624
2718
|
`
|
|
2625
2719
|
);
|
|
2626
2720
|
}
|
|
2627
|
-
const
|
|
2721
|
+
const P = await xi(
|
|
2628
2722
|
r,
|
|
2629
2723
|
g,
|
|
2630
|
-
|
|
2724
|
+
u,
|
|
2631
2725
|
I,
|
|
2632
2726
|
f,
|
|
2633
|
-
|
|
2634
|
-
),
|
|
2727
|
+
p.get("sc") ?? A?.channel?.value ?? g.salesChannel
|
|
2728
|
+
), R = ji(w), $ = (n.person?.id ?? null) === (R?.id ?? null) ? $n(n.channel) : void 0, Z = {
|
|
2635
2729
|
...n,
|
|
2636
2730
|
currency: {
|
|
2637
|
-
code:
|
|
2638
|
-
symbol:
|
|
2731
|
+
code: A?.currencyCode?.value ?? n.currency.code,
|
|
2732
|
+
symbol: A?.currencySymbol?.value ?? n.currency.symbol
|
|
2639
2733
|
},
|
|
2640
|
-
country:
|
|
2641
|
-
channel:
|
|
2734
|
+
country: A?.countryCode?.value ?? f,
|
|
2735
|
+
channel: ri(
|
|
2642
2736
|
g,
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2737
|
+
A?.channel?.value,
|
|
2738
|
+
_?.regionId?.value,
|
|
2739
|
+
P,
|
|
2740
|
+
C,
|
|
2741
|
+
T ?? $
|
|
2648
2742
|
),
|
|
2649
2743
|
/**
|
|
2650
2744
|
* B2B data structure in Session:
|
|
@@ -2652,53 +2746,52 @@ const Ti = (e) => e instanceof J && (e.extensions.status === 401 || e.extensions
|
|
|
2652
2746
|
* - Unit data: `authentication` namespace
|
|
2653
2747
|
* - Contract data: `profile` namespace (those info will be available inside Faststore's Session `person` object)
|
|
2654
2748
|
*/
|
|
2655
|
-
b2b:
|
|
2656
|
-
isRepresentative: S,
|
|
2749
|
+
b2b: qi({
|
|
2657
2750
|
authentication: E,
|
|
2658
|
-
shopper:
|
|
2659
|
-
publicData:
|
|
2660
|
-
profile:
|
|
2661
|
-
contract:
|
|
2662
|
-
customerId:
|
|
2663
|
-
unitId:
|
|
2751
|
+
shopper: b,
|
|
2752
|
+
publicData: D,
|
|
2753
|
+
profile: w,
|
|
2754
|
+
contract: U,
|
|
2755
|
+
customerId: S,
|
|
2756
|
+
unitId: v
|
|
2664
2757
|
}),
|
|
2665
2758
|
marketingData: m,
|
|
2666
|
-
person:
|
|
2759
|
+
person: R,
|
|
2667
2760
|
geoCoordinates: I?.latitude && I?.longitude && I || null,
|
|
2668
2761
|
city: h
|
|
2669
2762
|
};
|
|
2670
|
-
return
|
|
2671
|
-
},
|
|
2672
|
-
validateCart:
|
|
2673
|
-
validateSession:
|
|
2674
|
-
subscribeToNewsletter:
|
|
2675
|
-
cancelOrder:
|
|
2676
|
-
processOrderAuthorization:
|
|
2677
|
-
uploadFileToOrderEntry:
|
|
2678
|
-
startOrderEntryOperation:
|
|
2679
|
-
startRecommendationSession:
|
|
2763
|
+
return Te(n, Z) ? null : Z;
|
|
2764
|
+
}, Ki = {
|
|
2765
|
+
validateCart: _i,
|
|
2766
|
+
validateSession: Yi,
|
|
2767
|
+
subscribeToNewsletter: Zr,
|
|
2768
|
+
cancelOrder: Hr,
|
|
2769
|
+
processOrderAuthorization: Xr,
|
|
2770
|
+
uploadFileToOrderEntry: ei,
|
|
2771
|
+
startOrderEntryOperation: Yr,
|
|
2772
|
+
startRecommendationSession: Kr
|
|
2680
2773
|
};
|
|
2681
|
-
var
|
|
2774
|
+
var Ee;
|
|
2682
2775
|
(function(e) {
|
|
2683
2776
|
e.NAME = "Name", e.DOCUMENT = "Document", e.OPERATION_DEFINITION = "OperationDefinition", e.VARIABLE_DEFINITION = "VariableDefinition", e.SELECTION_SET = "SelectionSet", e.FIELD = "Field", e.ARGUMENT = "Argument", e.FRAGMENT_SPREAD = "FragmentSpread", e.INLINE_FRAGMENT = "InlineFragment", e.FRAGMENT_DEFINITION = "FragmentDefinition", e.VARIABLE = "Variable", e.INT = "IntValue", e.FLOAT = "FloatValue", e.STRING = "StringValue", e.BOOLEAN = "BooleanValue", e.NULL = "NullValue", e.ENUM = "EnumValue", e.LIST = "ListValue", e.OBJECT = "ObjectValue", e.OBJECT_FIELD = "ObjectField", e.DIRECTIVE = "Directive", e.NAMED_TYPE = "NamedType", e.LIST_TYPE = "ListType", e.NON_NULL_TYPE = "NonNullType", e.SCHEMA_DEFINITION = "SchemaDefinition", e.OPERATION_TYPE_DEFINITION = "OperationTypeDefinition", e.SCALAR_TYPE_DEFINITION = "ScalarTypeDefinition", e.OBJECT_TYPE_DEFINITION = "ObjectTypeDefinition", e.FIELD_DEFINITION = "FieldDefinition", e.INPUT_VALUE_DEFINITION = "InputValueDefinition", e.INTERFACE_TYPE_DEFINITION = "InterfaceTypeDefinition", e.UNION_TYPE_DEFINITION = "UnionTypeDefinition", e.ENUM_TYPE_DEFINITION = "EnumTypeDefinition", e.ENUM_VALUE_DEFINITION = "EnumValueDefinition", e.INPUT_OBJECT_TYPE_DEFINITION = "InputObjectTypeDefinition", e.DIRECTIVE_DEFINITION = "DirectiveDefinition", e.SCHEMA_EXTENSION = "SchemaExtension", e.SCALAR_TYPE_EXTENSION = "ScalarTypeExtension", e.OBJECT_TYPE_EXTENSION = "ObjectTypeExtension", e.INTERFACE_TYPE_EXTENSION = "InterfaceTypeExtension", e.UNION_TYPE_EXTENSION = "UnionTypeExtension", e.ENUM_TYPE_EXTENSION = "EnumTypeExtension", e.INPUT_OBJECT_TYPE_EXTENSION = "InputObjectTypeExtension";
|
|
2684
|
-
})(
|
|
2685
|
-
const
|
|
2686
|
-
function
|
|
2777
|
+
})(Ee || (Ee = {}));
|
|
2778
|
+
const Ji = (e) => typeof e == "string" ? Kn(e) : null;
|
|
2779
|
+
function Kn(e) {
|
|
2687
2780
|
try {
|
|
2688
2781
|
return JSON.parse(e);
|
|
2689
2782
|
} catch {
|
|
2690
2783
|
return e;
|
|
2691
2784
|
}
|
|
2692
2785
|
}
|
|
2693
|
-
const
|
|
2786
|
+
const Qi = (e) => typeof e == "object" ? JSON.stringify(e) : typeof e == "string" ? e : null, Zi = new ot({
|
|
2694
2787
|
name: "ObjectOrString",
|
|
2695
2788
|
description: "A string or the string representation of an object (a stringified object).",
|
|
2696
|
-
parseValue:
|
|
2697
|
-
serialize:
|
|
2789
|
+
parseValue: Ji,
|
|
2790
|
+
serialize: Qi,
|
|
2698
2791
|
parseLiteral(e) {
|
|
2699
|
-
return e.kind ===
|
|
2792
|
+
return e.kind === Ee.STRING ? Kn(e.value) : null;
|
|
2700
2793
|
}
|
|
2701
|
-
}),
|
|
2794
|
+
}), N = (e) => "Price" in e && "seller" in e && "product" in e, F = (e) => "skuName" in e, ea = {
|
|
2702
2795
|
priceCurrency: async (e, n, t) => {
|
|
2703
2796
|
const {
|
|
2704
2797
|
loaders: { salesChannelLoader: r },
|
|
@@ -2706,36 +2799,36 @@ const zi = (e) => typeof e == "object" ? JSON.stringify(e) : typeof e == "string
|
|
|
2706
2799
|
} = t;
|
|
2707
2800
|
return (await r.load(i.salesChannel)).CurrencyCode ?? "";
|
|
2708
2801
|
},
|
|
2709
|
-
priceValidUntil: (e) =>
|
|
2802
|
+
priceValidUntil: (e) => N(e) ? e.PriceValidUntil ?? "" : F(e) ? e.priceValidUntil ?? "" : null,
|
|
2710
2803
|
itemCondition: () => "https://schema.org/NewCondition",
|
|
2711
|
-
availability: async (e) =>
|
|
2712
|
-
seller: (e, n, t) =>
|
|
2804
|
+
availability: async (e) => N(e) ? Ge(V(e)) : F(e) ? Ge(Tr(e.availability)) : null,
|
|
2805
|
+
seller: (e, n, t) => N(e) ? {
|
|
2713
2806
|
identifier: t.storage.channel?.seller || e.seller.sellerId || ""
|
|
2714
2807
|
} : F(e) ? {
|
|
2715
2808
|
identifier: e.seller
|
|
2716
2809
|
} : null,
|
|
2717
|
-
price: (e) =>
|
|
2718
|
-
priceWithTaxes: (e) =>
|
|
2810
|
+
price: (e) => N(e) ? J(e) : F(e) ? e.sellingPrice / 100 : null,
|
|
2811
|
+
priceWithTaxes: (e) => N(e) ? X(J(e), e?.Tax, e.product.unitMultiplier) : F(e) ? X(
|
|
2719
2812
|
e.sellingPrice / 100,
|
|
2720
2813
|
e.tax / 100,
|
|
2721
2814
|
e.unitMultiplier
|
|
2722
2815
|
) : null,
|
|
2723
|
-
sellingPrice: (e) =>
|
|
2724
|
-
listPrice: (e) =>
|
|
2725
|
-
listPriceWithTaxes: (e) =>
|
|
2816
|
+
sellingPrice: (e) => N(e) ? _r(e) : F(e) ? e.sellingPrice / 100 : null,
|
|
2817
|
+
listPrice: (e) => N(e) ? e.ListPrice ?? 0 : F(e) ? e.listPrice / 100 : null,
|
|
2818
|
+
listPriceWithTaxes: (e) => N(e) ? X(
|
|
2726
2819
|
e.ListPrice ?? 0,
|
|
2727
2820
|
e?.Tax,
|
|
2728
2821
|
e.product.unitMultiplier
|
|
2729
|
-
) : F(e) ?
|
|
2730
|
-
itemOffered: (e) =>
|
|
2822
|
+
) : F(e) ? X(e.listPrice / 100, e.tax / 100, e.unitMultiplier) : null,
|
|
2823
|
+
itemOffered: (e) => N(e) ? e.product : F(e) ? {
|
|
2731
2824
|
...e.product,
|
|
2732
2825
|
attachmentsValues: e.attachments,
|
|
2733
2826
|
servicesValues: e.bundleItems ?? []
|
|
2734
2827
|
} : null,
|
|
2735
|
-
quantity: (e) =>
|
|
2828
|
+
quantity: (e) => N(e) ? e.AvailableQuantity ?? 0 : F(e) ? e.quantity : null,
|
|
2736
2829
|
isGift: (e) => F(e) ? e.isGift ?? !1 : null,
|
|
2737
|
-
priceToken: (e) =>
|
|
2738
|
-
},
|
|
2830
|
+
priceToken: (e) => N(e) ? e.PriceToken ?? null : null
|
|
2831
|
+
}, na = ({ linkText: e }) => `/${e}/p`, ta = ({
|
|
2739
2832
|
offer: e,
|
|
2740
2833
|
seller: n,
|
|
2741
2834
|
product: t
|
|
@@ -2743,12 +2836,12 @@ const zi = (e) => typeof e == "object" ? JSON.stringify(e) : typeof e == "string
|
|
|
2743
2836
|
...e,
|
|
2744
2837
|
product: t,
|
|
2745
2838
|
seller: n
|
|
2746
|
-
}),
|
|
2839
|
+
}), ra = {
|
|
2747
2840
|
imageText: "image",
|
|
2748
2841
|
imageUrl: "https://storecomponents.vtexassets.com/assets/faststore/images/image___117a6d3e229a96ad0e0d0876352566e2.svg",
|
|
2749
2842
|
imageLabel: "label"
|
|
2750
|
-
}, ue = (e, n) => `${e}-${n}`,
|
|
2751
|
-
function
|
|
2843
|
+
}, ue = (e, n) => `${e}-${n}`, un = (e, n) => `/${ue(e, n)}/p`, ia = (e) => Array.isArray(e) && e.length > 0 ? e : null;
|
|
2844
|
+
function ke(e) {
|
|
2752
2845
|
return e.replace(/^\/+|\/+$/g, "");
|
|
2753
2846
|
}
|
|
2754
2847
|
async function pe(e, n, t) {
|
|
@@ -2776,10 +2869,10 @@ async function pe(e, n, t) {
|
|
|
2776
2869
|
})();
|
|
2777
2870
|
return i.set(r, o), o;
|
|
2778
2871
|
}
|
|
2779
|
-
const
|
|
2780
|
-
const t = e.findIndex((r) =>
|
|
2872
|
+
const aa = (e, n) => {
|
|
2873
|
+
const t = e.findIndex((r) => ke(r).split("/").at(-1) === n);
|
|
2781
2874
|
return t < 0 ? 0 : t;
|
|
2782
|
-
},
|
|
2875
|
+
}, oa = {
|
|
2783
2876
|
productID: ({ itemId: e }) => e,
|
|
2784
2877
|
name: ({ isVariantOf: e, name: n }) => n ?? e.productName,
|
|
2785
2878
|
slug: ({ isVariantOf: { linkText: e }, itemId: n }) => ue(e, n),
|
|
@@ -2787,7 +2880,7 @@ const Gi = (e, n) => {
|
|
|
2787
2880
|
seo: ({ isVariantOf: e }) => ({
|
|
2788
2881
|
title: e.productTitle || e.productName,
|
|
2789
2882
|
description: e.metaTagDescription || e.description,
|
|
2790
|
-
canonical:
|
|
2883
|
+
canonical: na(e)
|
|
2791
2884
|
}),
|
|
2792
2885
|
brand: ({ isVariantOf: { brand: e } }) => ({ name: e }),
|
|
2793
2886
|
unitMultiplier: ({ unitMultiplier: e }) => e,
|
|
@@ -2802,28 +2895,28 @@ const Gi = (e, n) => {
|
|
|
2802
2895
|
productId: c
|
|
2803
2896
|
},
|
|
2804
2897
|
itemId: d
|
|
2805
|
-
} = e, g =
|
|
2806
|
-
if (
|
|
2898
|
+
} = e, g = aa(s, o), u = r[g], f = ke(u).split("/"), h = t.storage.locale;
|
|
2899
|
+
if (K(t) && h) {
|
|
2807
2900
|
const I = await pe(t, c, h);
|
|
2808
2901
|
if (I) {
|
|
2809
2902
|
const l = new Set(
|
|
2810
|
-
|
|
2811
|
-
),
|
|
2903
|
+
ke(s[g]).split("/").filter(Boolean)
|
|
2904
|
+
), p = I.categories.filter((S) => l.has(S.id.toString())).sort(
|
|
2812
2905
|
(S, v) => S.fullPath.split("/").length - v.fullPath.split("/").length
|
|
2813
2906
|
);
|
|
2814
|
-
if (
|
|
2907
|
+
if (p.length === f.length)
|
|
2815
2908
|
return {
|
|
2816
2909
|
itemListElement: [
|
|
2817
2910
|
// Category items: both name and slug come from Catalog Dataplane, ensuring
|
|
2818
2911
|
// they are always consistent with each other for the requested locale.
|
|
2819
|
-
...
|
|
2912
|
+
...p.map((S, v) => ({
|
|
2820
2913
|
name: S.name,
|
|
2821
2914
|
item: `/${S.fullPathUriName}/`,
|
|
2822
2915
|
position: v + 1
|
|
2823
2916
|
})),
|
|
2824
2917
|
{
|
|
2825
2918
|
name: i,
|
|
2826
|
-
item:
|
|
2919
|
+
item: un(I.linkId, d),
|
|
2827
2920
|
position: f.length + 1
|
|
2828
2921
|
}
|
|
2829
2922
|
],
|
|
@@ -2834,16 +2927,16 @@ const Gi = (e, n) => {
|
|
|
2834
2927
|
return {
|
|
2835
2928
|
itemListElement: [
|
|
2836
2929
|
...f.map((I, l) => {
|
|
2837
|
-
const
|
|
2930
|
+
const p = `/${f.slice(0, l + 1).map(ge).join("/")}/`;
|
|
2838
2931
|
return {
|
|
2839
2932
|
name: I,
|
|
2840
|
-
item:
|
|
2933
|
+
item: p,
|
|
2841
2934
|
position: l + 1
|
|
2842
2935
|
};
|
|
2843
2936
|
}),
|
|
2844
2937
|
{
|
|
2845
2938
|
name: i,
|
|
2846
|
-
item:
|
|
2939
|
+
item: un(a, d),
|
|
2847
2940
|
position: f.length + 1
|
|
2848
2941
|
}
|
|
2849
2942
|
],
|
|
@@ -2851,7 +2944,7 @@ const Gi = (e, n) => {
|
|
|
2851
2944
|
};
|
|
2852
2945
|
},
|
|
2853
2946
|
image: ({ images: e }, n) => {
|
|
2854
|
-
const t = (
|
|
2947
|
+
const t = (ia(e) ?? [ra]).map(
|
|
2855
2948
|
({ imageUrl: s, imageText: c, imageLabel: d }) => ({
|
|
2856
2949
|
alternateName: c ?? "",
|
|
2857
2950
|
url: s.replace("vteximg.com.br", "vtexassets.com"),
|
|
@@ -2874,12 +2967,12 @@ const Gi = (e, n) => {
|
|
|
2874
2967
|
review: () => [],
|
|
2875
2968
|
aggregateRating: () => ({}),
|
|
2876
2969
|
offers: (e) => e.sellers.map(
|
|
2877
|
-
(n) =>
|
|
2970
|
+
(n) => ta({
|
|
2878
2971
|
offer: n.commertialOffer,
|
|
2879
2972
|
seller: n,
|
|
2880
2973
|
product: e
|
|
2881
2974
|
})
|
|
2882
|
-
).sort(
|
|
2975
|
+
).sort(Tn),
|
|
2883
2976
|
isVariantOf: (e) => e,
|
|
2884
2977
|
additionalProperty: ({
|
|
2885
2978
|
// Search uses the name variations for specifications
|
|
@@ -2892,11 +2985,11 @@ const Gi = (e, n) => {
|
|
|
2892
2985
|
({ name: c, values: d }) => d.map((g) => ({
|
|
2893
2986
|
name: c,
|
|
2894
2987
|
value: g,
|
|
2895
|
-
valueReference:
|
|
2988
|
+
valueReference: x.specification
|
|
2896
2989
|
}))
|
|
2897
2990
|
), a = n.map(
|
|
2898
|
-
|
|
2899
|
-
), o = t.map(
|
|
2991
|
+
Mn
|
|
2992
|
+
), o = t.map(ai), s = r.map(Fe);
|
|
2900
2993
|
return [
|
|
2901
2994
|
...i,
|
|
2902
2995
|
...a,
|
|
@@ -2914,8 +3007,8 @@ const Gi = (e, n) => {
|
|
|
2914
3007
|
advertisement: ({ isVariantOf: { advertisement: e } }) => e,
|
|
2915
3008
|
deliveryPromiseBadges: ({ isVariantOf: { deliveryPromisesBadges: e } }) => e,
|
|
2916
3009
|
otherLocales: async (e, n, t) => {
|
|
2917
|
-
if (!
|
|
2918
|
-
const r =
|
|
3010
|
+
if (!K(t)) return null;
|
|
3011
|
+
const r = Gt(t);
|
|
2919
3012
|
if (r.length === 0) return null;
|
|
2920
3013
|
const i = e.isVariantOf.productId, a = e.itemId, o = t.storage.locale, s = await pe(t, i, o);
|
|
2921
3014
|
if (!s?.availableLinkIds) return null;
|
|
@@ -2926,8 +3019,8 @@ const Gi = (e, n) => {
|
|
|
2926
3019
|
}).filter((d) => d !== null);
|
|
2927
3020
|
},
|
|
2928
3021
|
defaultLocaleSlug: async (e, n, t) => {
|
|
2929
|
-
if (!
|
|
2930
|
-
const r =
|
|
3022
|
+
if (!K(t)) return null;
|
|
3023
|
+
const r = Xt(t);
|
|
2931
3024
|
if (!r) return null;
|
|
2932
3025
|
const { productId: i, linkText: a } = e.isVariantOf, o = e.itemId, c = (await pe(
|
|
2933
3026
|
t,
|
|
@@ -2936,25 +3029,25 @@ const Gi = (e, n) => {
|
|
|
2936
3029
|
))?.availableLinkIds?.[r] ?? a;
|
|
2937
3030
|
return ue(c, o);
|
|
2938
3031
|
}
|
|
2939
|
-
},
|
|
3032
|
+
}, sa = /* @__PURE__ */ new Set(["allSpecifications"]), ca = {
|
|
2940
3033
|
hasVariant: (e) => e.isVariantOf.items.map((n) => L(n, e.isVariantOf)),
|
|
2941
3034
|
productGroupID: ({ isVariantOf: e }) => e.productId,
|
|
2942
3035
|
productClusters: ({ isVariantOf: e }) => e.productClusters ?? [],
|
|
2943
3036
|
name: (e) => e.isVariantOf.productName,
|
|
2944
3037
|
skuVariants: (e) => e,
|
|
2945
3038
|
additionalProperty: ({ isVariantOf: { specificationGroups: e } }) => e.filter(
|
|
2946
|
-
(n) => !
|
|
3039
|
+
(n) => !sa.has(n.name)
|
|
2947
3040
|
).flatMap(
|
|
2948
3041
|
({ specifications: n }) => n.flatMap(
|
|
2949
3042
|
({ name: t, values: r }) => r.map((i) => ({
|
|
2950
3043
|
name: t,
|
|
2951
3044
|
value: i,
|
|
2952
|
-
valueReference:
|
|
3045
|
+
valueReference: x.specification
|
|
2953
3046
|
}))
|
|
2954
3047
|
)
|
|
2955
3048
|
)
|
|
2956
|
-
},
|
|
2957
|
-
propertyID: (e) => e.propertyID ||
|
|
3049
|
+
}, la = {
|
|
3050
|
+
propertyID: (e) => e.propertyID || zn(e),
|
|
2958
3051
|
name: ({ name: e }) => e,
|
|
2959
3052
|
value: ({ value: e }) => e,
|
|
2960
3053
|
valueReference: ({ valueReference: e }) => e
|
|
@@ -2966,20 +3059,20 @@ const Gi = (e, n) => {
|
|
|
2966
3059
|
}))
|
|
2967
3060
|
), t = we(
|
|
2968
3061
|
n,
|
|
2969
|
-
({ offer: r }, { offer: i }) =>
|
|
3062
|
+
({ offer: r }, { offer: i }) => Tn(r, i)
|
|
2970
3063
|
);
|
|
2971
3064
|
return t ? t.sku : e[0];
|
|
2972
|
-
},
|
|
3065
|
+
}, Jn = (e) => e !== "" && !Number.isNaN(Number(e)), da = /^vrn:recommendations:[^:]+:[^:]+:[^:]+$/, ua = async (e, { campaignVrn: n, userId: t, products: r }, i) => {
|
|
2973
3066
|
const {
|
|
2974
3067
|
clients: { commerce: a }
|
|
2975
3068
|
} = i, { salesChannel: o } = i.storage.channel, s = n?.trim();
|
|
2976
|
-
if (!s || !
|
|
2977
|
-
throw new
|
|
3069
|
+
if (!s || !da.test(s))
|
|
3070
|
+
throw new k(`Invalid campaignVrn: "${n}"`);
|
|
2978
3071
|
const c = t?.trim();
|
|
2979
3072
|
if (t != null && !c)
|
|
2980
|
-
throw new
|
|
3073
|
+
throw new k("Invalid userId: must be a non-empty string");
|
|
2981
3074
|
if (r != null && (!Array.isArray(r) || r.some((h) => !h?.trim())))
|
|
2982
|
-
throw new
|
|
3075
|
+
throw new k(
|
|
2983
3076
|
"Invalid products: must be an array of non-empty strings"
|
|
2984
3077
|
);
|
|
2985
3078
|
const d = await a.recommendation.recommendations({
|
|
@@ -2988,16 +3081,43 @@ const Gi = (e, n) => {
|
|
|
2988
3081
|
products: r ?? [],
|
|
2989
3082
|
salesChannel: o ?? void 0,
|
|
2990
3083
|
locale: i.storage.locale
|
|
2991
|
-
}), { campaign: g, correlationId:
|
|
3084
|
+
}), { campaign: g, correlationId: u } = d;
|
|
2992
3085
|
return {
|
|
2993
3086
|
products: (d.products ?? []).map((h) => {
|
|
2994
3087
|
const I = he(h.items);
|
|
2995
3088
|
return I ? L(I, h) : null;
|
|
2996
3089
|
}).filter((h) => !!h),
|
|
2997
|
-
correlationId:
|
|
3090
|
+
correlationId: u,
|
|
2998
3091
|
campaign: g
|
|
2999
3092
|
};
|
|
3000
|
-
},
|
|
3093
|
+
}, pa = "productClusterIds", pn = "not:";
|
|
3094
|
+
function ga(e) {
|
|
3095
|
+
const n = /* @__PURE__ */ new Set(), t = /* @__PURE__ */ new Set();
|
|
3096
|
+
for (const { key: r, value: i } of rr(e))
|
|
3097
|
+
if (r === pa)
|
|
3098
|
+
for (const a of i.split(",")) {
|
|
3099
|
+
const o = a.trim();
|
|
3100
|
+
if (o.startsWith(pn)) {
|
|
3101
|
+
const s = o.slice(pn.length);
|
|
3102
|
+
s && t.add(s);
|
|
3103
|
+
} else o && n.add(o);
|
|
3104
|
+
}
|
|
3105
|
+
return n.size === 0 && t.size === 0 ? null : { allowed: n, excluded: t };
|
|
3106
|
+
}
|
|
3107
|
+
function ma(e, { allowed: n, excluded: t }) {
|
|
3108
|
+
const r = (e ?? []).map(({ id: i }) => String(i));
|
|
3109
|
+
return r.some((i) => t.has(i)) ? !1 : n.size === 0 || r.some((i) => n.has(i));
|
|
3110
|
+
}
|
|
3111
|
+
function ha(e, n) {
|
|
3112
|
+
const t = ga(
|
|
3113
|
+
Re(e.headers?.cookie)
|
|
3114
|
+
);
|
|
3115
|
+
if (t && !ma(n.isVariantOf.productClusters, t))
|
|
3116
|
+
throw new B(
|
|
3117
|
+
`Product ${n.isVariantOf.productId} is not in the shopper's assortment`
|
|
3118
|
+
);
|
|
3119
|
+
}
|
|
3120
|
+
const gn = {
|
|
3001
3121
|
price_desc: "price:desc",
|
|
3002
3122
|
price_asc: "price:asc",
|
|
3003
3123
|
orders_desc: "orders:desc",
|
|
@@ -3007,19 +3127,19 @@ const Gi = (e, n) => {
|
|
|
3007
3127
|
discount_desc: "discount:desc",
|
|
3008
3128
|
score_desc: ""
|
|
3009
3129
|
};
|
|
3010
|
-
function
|
|
3130
|
+
function fa(e, n) {
|
|
3011
3131
|
let t;
|
|
3012
|
-
if (Object.hasOwn(n, e) ? t = n[e] : Object.hasOwn(
|
|
3013
|
-
throw new
|
|
3132
|
+
if (Object.hasOwn(n, e) ? t = n[e] : Object.hasOwn(gn, e) && (t = gn[e]), t === void 0)
|
|
3133
|
+
throw new k(`Unknown sort value: ${e}`);
|
|
3014
3134
|
return t;
|
|
3015
3135
|
}
|
|
3016
|
-
const
|
|
3136
|
+
const Sa = async (e, { operationId: n }, { clients: { commerce: t } }) => {
|
|
3017
3137
|
if (!n)
|
|
3018
|
-
throw new
|
|
3138
|
+
throw new k("Missing operationId");
|
|
3019
3139
|
return t.orderEntry.getOperation({ operationId: n });
|
|
3020
|
-
},
|
|
3140
|
+
}, ya = async (e, { orderFormId: n }, { clients: { commerce: t } }) => {
|
|
3021
3141
|
if (!n)
|
|
3022
|
-
throw new
|
|
3142
|
+
throw new k("Missing orderFormId");
|
|
3023
3143
|
const { items: r } = await t.orderEntry.getOrderFormItems({ orderFormId: n });
|
|
3024
3144
|
return (r ?? []).map((i) => ({
|
|
3025
3145
|
id: i.id,
|
|
@@ -3033,50 +3153,52 @@ const na = async (e, { operationId: n }, { clients: { commerce: t } }) => {
|
|
|
3033
3153
|
unitMultiplier: i.unitMultiplier ?? 1
|
|
3034
3154
|
}));
|
|
3035
3155
|
};
|
|
3036
|
-
async function
|
|
3156
|
+
async function Ia(e, n, t, r) {
|
|
3037
3157
|
const i = n.slice(0, n.lastIndexOf("-"));
|
|
3038
3158
|
return (await pe(e, t, r))?.linkId === i;
|
|
3039
3159
|
}
|
|
3040
|
-
const
|
|
3041
|
-
async function
|
|
3160
|
+
const Qn = "Invalid SkuId", Zn = "Slug was set but the fetched sku does not satisfy the slug condition.", va = "UseAdHocCard", Oa = (e) => Y(e) || e instanceof Error && (e.message === Qn || e.message.startsWith(Zn));
|
|
3161
|
+
async function Ca(e, n, t, r) {
|
|
3042
3162
|
const { linkText: i, productId: a } = n.isVariantOf;
|
|
3043
|
-
if (!(!t || !i || t.startsWith(i) ||
|
|
3044
|
-
throw new Error(`${
|
|
3163
|
+
if (!(!t || !i || t.startsWith(i) || K(e) && r && Jn(t.split("-").pop() ?? "") && await Ia(e, t, a, r)))
|
|
3164
|
+
throw new Error(`${Zn} slug: ${t}, linkText: ${i}`);
|
|
3045
3165
|
}
|
|
3046
|
-
async function
|
|
3166
|
+
async function ba(e, n) {
|
|
3047
3167
|
if (n == null)
|
|
3048
|
-
throw new
|
|
3168
|
+
throw new k("Missing slug or id");
|
|
3049
3169
|
const {
|
|
3050
3170
|
clients: { commerce: t, search: r }
|
|
3051
3171
|
} = e, i = await t.catalog.portal.pagetype(`${n}/p`);
|
|
3052
3172
|
if (i.pageType !== "Product" || !i.id)
|
|
3053
|
-
throw new
|
|
3173
|
+
throw new B(`No product found for slug ${n}`);
|
|
3054
3174
|
const a = await r.fetchProduct({
|
|
3055
3175
|
field: "id",
|
|
3056
3176
|
value: String(i.id)
|
|
3057
3177
|
}).catch(() => null);
|
|
3058
3178
|
if (!a)
|
|
3059
|
-
throw new
|
|
3179
|
+
throw new B(`No product found for id ${i.id}`);
|
|
3060
3180
|
return L(he(a.items), a);
|
|
3061
3181
|
}
|
|
3062
|
-
const
|
|
3182
|
+
const wa = {
|
|
3063
3183
|
product: async (e, { locator: n }, t) => {
|
|
3064
|
-
const r =
|
|
3065
|
-
r &&
|
|
3184
|
+
const r = Ze(n), i = Qe(n), a = Vr(n), o = zr(n);
|
|
3185
|
+
r && te(t, r), i && Ae(t, i);
|
|
3066
3186
|
const {
|
|
3067
3187
|
loaders: { skuLoader: s }
|
|
3068
|
-
} = t
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
|
|
3073
|
-
|
|
3074
|
-
|
|
3075
|
-
|
|
3076
|
-
|
|
3077
|
-
|
|
3078
|
-
|
|
3079
|
-
|
|
3188
|
+
} = t, d = await (async () => {
|
|
3189
|
+
try {
|
|
3190
|
+
const g = a ?? o?.split("-").pop() ?? "";
|
|
3191
|
+
if (!Jn(g))
|
|
3192
|
+
throw new Error(Qn);
|
|
3193
|
+
const u = await s.load(g);
|
|
3194
|
+
return await Ca(t, u, o, i), u;
|
|
3195
|
+
} catch (g) {
|
|
3196
|
+
if (!Oa(g))
|
|
3197
|
+
throw g;
|
|
3198
|
+
return ba(t, o);
|
|
3199
|
+
}
|
|
3200
|
+
})();
|
|
3201
|
+
return ha(t, d), d;
|
|
3080
3202
|
},
|
|
3081
3203
|
collection: (e, { slug: n }, t) => {
|
|
3082
3204
|
const {
|
|
@@ -3084,7 +3206,7 @@ const ca = {
|
|
|
3084
3206
|
} = t;
|
|
3085
3207
|
return r.load({
|
|
3086
3208
|
slug: n,
|
|
3087
|
-
locale:
|
|
3209
|
+
locale: Pn(t)
|
|
3088
3210
|
});
|
|
3089
3211
|
},
|
|
3090
3212
|
search: async (e, {
|
|
@@ -3095,21 +3217,21 @@ const ca = {
|
|
|
3095
3217
|
selectedFacets: a,
|
|
3096
3218
|
sponsoredCount: o
|
|
3097
3219
|
}, s) => {
|
|
3098
|
-
const c =
|
|
3099
|
-
c &&
|
|
3100
|
-
const
|
|
3101
|
-
page: Math.ceil(
|
|
3220
|
+
const c = Ze(a), d = Qe(a), g = Mr(a);
|
|
3221
|
+
c && te(s, c), d && Ae(s, d);
|
|
3222
|
+
const u = t ? Number(t) : 0, f = {
|
|
3223
|
+
page: Math.ceil(u / n) || 0,
|
|
3102
3224
|
count: n,
|
|
3103
3225
|
query: i ?? void 0,
|
|
3104
|
-
sort:
|
|
3105
|
-
selectedFacets: a?.flatMap(
|
|
3226
|
+
sort: fa(r ?? "score_desc", s.storage.customSortMap),
|
|
3227
|
+
selectedFacets: a?.flatMap(Ke) ?? [],
|
|
3106
3228
|
sponsoredCount: o ?? void 0
|
|
3107
3229
|
};
|
|
3108
3230
|
if (g) {
|
|
3109
3231
|
const l = (await s.clients.commerce.catalog.products.crossselling({
|
|
3110
|
-
type:
|
|
3232
|
+
type: Rn[g.key],
|
|
3111
3233
|
productId: g.value
|
|
3112
|
-
})).map((m) => m.productId).slice(0, n),
|
|
3234
|
+
})).map((m) => m.productId).slice(0, n), p = s.clients.search.productsByIdentifier({ field: "id", values: l }).then((m) => ({
|
|
3113
3235
|
products: m,
|
|
3114
3236
|
recordsFiltered: m.length,
|
|
3115
3237
|
pagination: {
|
|
@@ -3132,7 +3254,7 @@ const ca = {
|
|
|
3132
3254
|
fuzzy: "0",
|
|
3133
3255
|
searchId: ""
|
|
3134
3256
|
}));
|
|
3135
|
-
return { searchArgs: f, productSearchPromise:
|
|
3257
|
+
return { searchArgs: f, productSearchPromise: p };
|
|
3136
3258
|
}
|
|
3137
3259
|
const h = s.clients.search.products(f);
|
|
3138
3260
|
return { searchArgs: f, productSearchPromise: h };
|
|
@@ -3207,7 +3329,7 @@ const ca = {
|
|
|
3207
3329
|
metaTagDescription: h.metaTagDescription,
|
|
3208
3330
|
availableLinkIds: null,
|
|
3209
3331
|
entityType: "brand"
|
|
3210
|
-
})), ...c].filter((h) => !!
|
|
3332
|
+
})), ...c].filter((h) => !!Un.slug(h, null, r, null));
|
|
3211
3333
|
return {
|
|
3212
3334
|
pageInfo: {
|
|
3213
3335
|
hasNextPage: f.length - a > n,
|
|
@@ -3242,7 +3364,7 @@ const ca = {
|
|
|
3242
3364
|
page: 1,
|
|
3243
3365
|
count: 1,
|
|
3244
3366
|
query: n ?? void 0,
|
|
3245
|
-
selectedFacets: t?.flatMap(
|
|
3367
|
+
selectedFacets: t?.flatMap(Ke) ?? [],
|
|
3246
3368
|
allowRedirect: !0
|
|
3247
3369
|
});
|
|
3248
3370
|
return {
|
|
@@ -3285,16 +3407,16 @@ const ca = {
|
|
|
3285
3407
|
userOrder: async (e, { orderId: n }, t) => {
|
|
3286
3408
|
try {
|
|
3287
3409
|
if (!n)
|
|
3288
|
-
throw new
|
|
3410
|
+
throw new k("Missing orderId");
|
|
3289
3411
|
const {
|
|
3290
3412
|
clients: { commerce: r }
|
|
3291
3413
|
} = t, i = await r.oms.userOrder({ orderId: n });
|
|
3292
3414
|
if (!i)
|
|
3293
|
-
throw new
|
|
3415
|
+
throw new B(`No order found for id ${n}`);
|
|
3294
3416
|
let a = null;
|
|
3295
3417
|
try {
|
|
3296
3418
|
const c = await r.oms.getCommercialAuthorizationsByOrderId({ orderId: n });
|
|
3297
|
-
a =
|
|
3419
|
+
a = Nn(c);
|
|
3298
3420
|
} catch {
|
|
3299
3421
|
}
|
|
3300
3422
|
const s = (await r.masterData.getShopperById({
|
|
@@ -3333,7 +3455,7 @@ const ca = {
|
|
|
3333
3455
|
a = { message: i };
|
|
3334
3456
|
}
|
|
3335
3457
|
const o = a?.message || i;
|
|
3336
|
-
throw
|
|
3458
|
+
throw Y(r) ? new B(`No order found for id ${n}. ${o}.`) : _t(r) ? new re(
|
|
3337
3459
|
`You are forbidden to interact with order with id ${n}. ${o}.`
|
|
3338
3460
|
) : r;
|
|
3339
3461
|
}
|
|
@@ -3381,10 +3503,10 @@ const ca = {
|
|
|
3381
3503
|
account: r,
|
|
3382
3504
|
headers: i,
|
|
3383
3505
|
clients: { commerce: a }
|
|
3384
|
-
} = t, s =
|
|
3506
|
+
} = t, s = G(z(i?.cookie ?? "", r))?.userId ?? "";
|
|
3385
3507
|
if (!s)
|
|
3386
3508
|
return !0;
|
|
3387
|
-
const c = await a.licenseManager.isResourceGranted({ userId: s, resourceKey:
|
|
3509
|
+
const c = await a.licenseManager.isResourceGranted({ userId: s, resourceKey: va }).catch(() => null);
|
|
3388
3510
|
return typeof c == "boolean" ? c : !0;
|
|
3389
3511
|
},
|
|
3390
3512
|
listUserQuotes: async (e, n, t) => {
|
|
@@ -3438,52 +3560,57 @@ const ca = {
|
|
|
3438
3560
|
account: r,
|
|
3439
3561
|
headers: i,
|
|
3440
3562
|
clients: { commerce: a }
|
|
3441
|
-
} = t, s =
|
|
3563
|
+
} = t, s = G(z(i?.cookie ?? "", r))?.userId ?? "", [c, d, g] = await Promise.all([
|
|
3442
3564
|
a.session("").catch(() => null),
|
|
3443
3565
|
s ? a.masterData.getShopperById({ userId: s }).catch(() => null) : Promise.resolve(null),
|
|
3444
3566
|
s ? a.licenseManager.getUserRoles({ userId: s }).catch(() => null) : Promise.resolve(null)
|
|
3445
|
-
]),
|
|
3567
|
+
]), u = d?.[0], f = c?.namespaces.authentication ?? null, h = `${(u?.firstName ?? "").trim()} ${(u?.lastName ?? "").trim()}`.trim();
|
|
3446
3568
|
return {
|
|
3447
3569
|
username: f?.storeUserEmail?.value ?? "",
|
|
3448
3570
|
name: h,
|
|
3449
3571
|
email: f?.storeUserEmail?.value ?? "",
|
|
3450
|
-
phone:
|
|
3572
|
+
phone: u?.phone ?? "",
|
|
3451
3573
|
role: g?.Roles?.map((I) => I.Name) ?? [],
|
|
3452
3574
|
orgUnit: f?.unitName?.value ?? ""
|
|
3453
3575
|
};
|
|
3454
3576
|
},
|
|
3455
|
-
//
|
|
3456
|
-
//
|
|
3577
|
+
// Buyers with an organizational unit and a contract get the contract
|
|
3578
|
+
// information. Everyone else gets the b2c user information.
|
|
3457
3579
|
accountProfile: async (e, n, t) => {
|
|
3458
3580
|
const {
|
|
3459
3581
|
account: r,
|
|
3460
3582
|
headers: i,
|
|
3461
3583
|
clients: { commerce: a }
|
|
3462
|
-
} = t, o =
|
|
3584
|
+
} = t, o = G(z(i?.cookie ?? "", r));
|
|
3463
3585
|
if (!o?.userId)
|
|
3464
3586
|
return null;
|
|
3465
|
-
if (o
|
|
3587
|
+
if (Be(null, o.unitId)) {
|
|
3466
3588
|
const c = await a.session("").catch(() => null);
|
|
3467
3589
|
if (!c)
|
|
3468
3590
|
return null;
|
|
3469
|
-
const d = c.namespaces.profile ?? null, g = c.namespaces.shopper ?? null,
|
|
3470
|
-
|
|
3471
|
-
|
|
3591
|
+
const d = c.namespaces.profile ?? null, g = c.namespaces.shopper ?? null, u = c.namespaces.authentication ?? null, f = Le(
|
|
3592
|
+
g?.activeContractId?.value,
|
|
3593
|
+
u?.customerId?.value,
|
|
3594
|
+
o.customerId
|
|
3595
|
+
);
|
|
3596
|
+
if (f) {
|
|
3597
|
+
let h = null;
|
|
3472
3598
|
try {
|
|
3473
3599
|
h = await a.masterData.getContractById({ contractId: f });
|
|
3474
|
-
} catch (
|
|
3600
|
+
} catch (p) {
|
|
3475
3601
|
console.error(
|
|
3476
3602
|
`Error while getting contract data for contract ID (${f}).`,
|
|
3477
|
-
|
|
3603
|
+
p
|
|
3478
3604
|
);
|
|
3479
3605
|
}
|
|
3480
|
-
|
|
3481
|
-
|
|
3482
|
-
|
|
3483
|
-
|
|
3484
|
-
|
|
3485
|
-
|
|
3486
|
-
|
|
3606
|
+
const I = `${(g?.firstName?.value ?? "").trim()} ${(g?.lastName?.value ?? "").trim()}`.trim();
|
|
3607
|
+
return {
|
|
3608
|
+
name: Yn(h, d) || I || "",
|
|
3609
|
+
email: d?.email?.value || u?.storeUserEmail?.value || "",
|
|
3610
|
+
id: d?.id?.value || f
|
|
3611
|
+
// createdAt: '',
|
|
3612
|
+
};
|
|
3613
|
+
}
|
|
3487
3614
|
}
|
|
3488
3615
|
const s = await a.licenseManager.getUserById({
|
|
3489
3616
|
userId: o?.userId
|
|
@@ -3499,32 +3626,32 @@ const ca = {
|
|
|
3499
3626
|
// Contract list from VTEX session `shopper.availableContracts`.
|
|
3500
3627
|
availableContracts: async (e, { orgUnitId: n }, t) => {
|
|
3501
3628
|
if (!n)
|
|
3502
|
-
throw new
|
|
3629
|
+
throw new k("Missing orgUnitId");
|
|
3503
3630
|
const {
|
|
3504
3631
|
account: r,
|
|
3505
3632
|
headers: i,
|
|
3506
3633
|
clients: { commerce: a }
|
|
3507
|
-
} = t, o = await a.session("").catch(() => null), s =
|
|
3634
|
+
} = t, o = await a.session("").catch(() => null), s = z(i?.cookie ?? "", r);
|
|
3508
3635
|
let c = null;
|
|
3509
3636
|
try {
|
|
3510
|
-
c = s ?
|
|
3637
|
+
c = s ? G(s) : null;
|
|
3511
3638
|
} catch {
|
|
3512
3639
|
c = null;
|
|
3513
3640
|
}
|
|
3514
3641
|
const d = o?.namespaces.authentication?.unitId?.value?.trim() ?? c?.unitId?.trim() ?? "";
|
|
3515
3642
|
if (!d || d !== n)
|
|
3516
|
-
throw new
|
|
3643
|
+
throw new re(
|
|
3517
3644
|
"You are not allowed to list contracts for this organization unit"
|
|
3518
3645
|
);
|
|
3519
|
-
const g =
|
|
3646
|
+
const g = Ri(
|
|
3520
3647
|
o?.namespaces.shopper
|
|
3521
|
-
),
|
|
3648
|
+
), u = Fi(o) || c?.customerId?.trim() || "", f = await a.storeFront.attachedContracts(n).catch((I) => (console.warn(
|
|
3522
3649
|
"availableContracts: default contract lookup failed",
|
|
3523
3650
|
I
|
|
3524
|
-
), null)), h =
|
|
3525
|
-
return
|
|
3651
|
+
), null)), h = Li(f?.contracts);
|
|
3652
|
+
return Bi(
|
|
3526
3653
|
g,
|
|
3527
|
-
|
|
3654
|
+
u,
|
|
3528
3655
|
h
|
|
3529
3656
|
);
|
|
3530
3657
|
},
|
|
@@ -3532,7 +3659,7 @@ const ca = {
|
|
|
3532
3659
|
const {
|
|
3533
3660
|
clients: { search: o }
|
|
3534
3661
|
} = a;
|
|
3535
|
-
i &&
|
|
3662
|
+
i && te(a, i);
|
|
3536
3663
|
const s = n?.longitude != null && n?.latitude != null ? `${n.longitude},${n.latitude}` : void 0;
|
|
3537
3664
|
return {
|
|
3538
3665
|
pickupPointDistances: (await o.pickupPointAvailability({
|
|
@@ -3543,10 +3670,10 @@ const ca = {
|
|
|
3543
3670
|
pickupPointsHash: null
|
|
3544
3671
|
};
|
|
3545
3672
|
},
|
|
3546
|
-
orderEntryOperation:
|
|
3547
|
-
orderFormItems:
|
|
3548
|
-
recommendations:
|
|
3549
|
-
},
|
|
3673
|
+
orderEntryOperation: Sa,
|
|
3674
|
+
orderFormItems: ya,
|
|
3675
|
+
recommendations: ua
|
|
3676
|
+
}, Aa = {
|
|
3550
3677
|
reviewRating: () => ({
|
|
3551
3678
|
ratingValue: 5,
|
|
3552
3679
|
bestRating: 5
|
|
@@ -3554,16 +3681,16 @@ const ca = {
|
|
|
3554
3681
|
author: () => ({
|
|
3555
3682
|
name: ""
|
|
3556
3683
|
})
|
|
3557
|
-
},
|
|
3684
|
+
}, Pa = (e, n, t) => n ? e.key === "category-1" : t ? e.key === "brand" : !1, Da = {
|
|
3558
3685
|
suggestions: async (e, n, t) => {
|
|
3559
3686
|
const {
|
|
3560
3687
|
clients: { search: r }
|
|
3561
3688
|
} = t, { searchArgs: i } = e;
|
|
3562
3689
|
if (!i.query)
|
|
3563
3690
|
return {
|
|
3564
|
-
terms: (await r.topSearches()).searches.map((
|
|
3565
|
-
value:
|
|
3566
|
-
count:
|
|
3691
|
+
terms: (await r.topSearches()).searches.map((u) => ({
|
|
3692
|
+
value: u.term,
|
|
3693
|
+
count: u.count
|
|
3567
3694
|
})),
|
|
3568
3695
|
products: []
|
|
3569
3696
|
};
|
|
@@ -3571,8 +3698,8 @@ const ca = {
|
|
|
3571
3698
|
r.suggestedTerms(i),
|
|
3572
3699
|
a
|
|
3573
3700
|
]), c = s.products.map((g) => {
|
|
3574
|
-
const
|
|
3575
|
-
return
|
|
3701
|
+
const u = he(g.items);
|
|
3702
|
+
return u && L(u, g);
|
|
3576
3703
|
}).filter((g) => !!g), { searches: d } = o;
|
|
3577
3704
|
return {
|
|
3578
3705
|
terms: d.map((g) => ({ value: g.term, count: g.count })),
|
|
@@ -3605,7 +3732,7 @@ const ca = {
|
|
|
3605
3732
|
t.storage.searchArgs = e;
|
|
3606
3733
|
const { facets: i = [] } = await r.facets(e), a = !e.query, o = e.selectedFacets?.length ? e.selectedFacets[0].key === "category-1" : !1, s = e.selectedFacets?.length ? e.selectedFacets[0].key === "brand" : !1;
|
|
3607
3734
|
return i.filter(
|
|
3608
|
-
(d) => !a || !
|
|
3735
|
+
(d) => !a || !Pa(d, o, s)
|
|
3609
3736
|
);
|
|
3610
3737
|
},
|
|
3611
3738
|
metadata: async ({ productSearchPromise: e }) => {
|
|
@@ -3617,12 +3744,12 @@ const ca = {
|
|
|
3617
3744
|
};
|
|
3618
3745
|
},
|
|
3619
3746
|
searchId: async ({ productSearchPromise: e }) => (await e).searchId
|
|
3620
|
-
},
|
|
3747
|
+
}, Ea = {
|
|
3621
3748
|
title: ({ title: e }) => e ?? "",
|
|
3622
3749
|
description: ({ description: e }) => e ?? "",
|
|
3623
3750
|
canonical: ({ canonical: e }) => e ?? "",
|
|
3624
3751
|
titleTemplate: () => ""
|
|
3625
|
-
},
|
|
3752
|
+
}, ka = ["bd", "d", "h", "m"], _a = (e) => ka.includes(e), Ta = {
|
|
3626
3753
|
bd: {
|
|
3627
3754
|
0: "Today",
|
|
3628
3755
|
1: "In 1 business day",
|
|
@@ -3643,29 +3770,29 @@ const ca = {
|
|
|
3643
3770
|
1: "In 1 minute",
|
|
3644
3771
|
other: "Up to # minutes"
|
|
3645
3772
|
}
|
|
3646
|
-
},
|
|
3647
|
-
const [n, t] = [e.split(/\D+/)[0], e.split(/[0-9]+/)[1]], r = n !== "" && !Number.isNaN(Number(n)), i =
|
|
3773
|
+
}, et = (e) => {
|
|
3774
|
+
const [n, t] = [e.split(/\D+/)[0], e.split(/[0-9]+/)[1]], r = n !== "" && !Number.isNaN(Number(n)), i = _a(t);
|
|
3648
3775
|
if (!r || !i)
|
|
3649
3776
|
return "";
|
|
3650
3777
|
const a = Number(n) < 2 ? Number(n) : "other";
|
|
3651
|
-
return
|
|
3652
|
-
},
|
|
3778
|
+
return Ta[t][a].replace("#", n) ?? "";
|
|
3779
|
+
}, Ua = {
|
|
3653
3780
|
carrier: (e) => e?.friendlyName ?? e?.name ?? "",
|
|
3654
3781
|
price: (e) => e?.price ? e.price / 100 : e?.price,
|
|
3655
|
-
localizedEstimates: (e) => e?.shippingEstimate ?
|
|
3656
|
-
},
|
|
3657
|
-
function
|
|
3658
|
-
const t = `${
|
|
3782
|
+
localizedEstimates: (e) => e?.shippingEstimate ? et(e.shippingEstimate) : ""
|
|
3783
|
+
}, mn = "skuvariation";
|
|
3784
|
+
function hn(e, n) {
|
|
3785
|
+
const t = `${mn}${n}`.toLowerCase(), r = e.find(
|
|
3659
3786
|
(a) => a.imageLabel === t
|
|
3660
3787
|
);
|
|
3661
3788
|
if (r)
|
|
3662
3789
|
return r;
|
|
3663
3790
|
const i = e.find(
|
|
3664
|
-
(a) => a.imageLabel ===
|
|
3791
|
+
(a) => a.imageLabel === mn
|
|
3665
3792
|
);
|
|
3666
3793
|
return i || e[0];
|
|
3667
3794
|
}
|
|
3668
|
-
function
|
|
3795
|
+
function Ra(e, n, t) {
|
|
3669
3796
|
const r = {};
|
|
3670
3797
|
return e.forEach((i) => {
|
|
3671
3798
|
const a = i.variations;
|
|
@@ -3677,30 +3804,30 @@ function Sa(e, n, t) {
|
|
|
3677
3804
|
r[s] = `${t}-${i.itemId}`;
|
|
3678
3805
|
}), r;
|
|
3679
3806
|
}
|
|
3680
|
-
function
|
|
3807
|
+
function fn(e) {
|
|
3681
3808
|
const n = {};
|
|
3682
3809
|
return e.forEach((t) => {
|
|
3683
3810
|
n[t.name] = t.values[0];
|
|
3684
3811
|
}), n;
|
|
3685
3812
|
}
|
|
3686
|
-
function
|
|
3813
|
+
function Na(e) {
|
|
3687
3814
|
const n = {};
|
|
3688
3815
|
return e?.forEach((t) => {
|
|
3689
3816
|
n[t.field.originalName ?? t.field.name] = t.values.map((r) => r.originalName ?? r.name);
|
|
3690
3817
|
}), n;
|
|
3691
3818
|
}
|
|
3692
|
-
function
|
|
3819
|
+
function Fa(e, n) {
|
|
3693
3820
|
return Number.isNaN(Number(e) - Number(n)) ? e < n ? -1 : e > n ? 1 : 0 : Number(e) - Number(n);
|
|
3694
3821
|
}
|
|
3695
|
-
function
|
|
3822
|
+
function La(e) {
|
|
3696
3823
|
const n = e;
|
|
3697
3824
|
for (const t in e)
|
|
3698
3825
|
e[t].every(
|
|
3699
3826
|
(i) => !Number.isNaN(Number(i.value))
|
|
3700
|
-
) && e[t].sort((i, a) =>
|
|
3827
|
+
) && e[t].sort((i, a) => Fa(i.value, a.value));
|
|
3701
3828
|
return n;
|
|
3702
3829
|
}
|
|
3703
|
-
function
|
|
3830
|
+
function Ba(e, n, t) {
|
|
3704
3831
|
const r = {}, i = /* @__PURE__ */ new Set();
|
|
3705
3832
|
return e.forEach((a) => {
|
|
3706
3833
|
if (a.variations.length === 0)
|
|
@@ -3713,7 +3840,7 @@ function Oa(e, n, t) {
|
|
|
3713
3840
|
if (!o || i.has(c))
|
|
3714
3841
|
return;
|
|
3715
3842
|
i.add(c);
|
|
3716
|
-
const d =
|
|
3843
|
+
const d = hn(
|
|
3717
3844
|
a.images,
|
|
3718
3845
|
n
|
|
3719
3846
|
), g = {
|
|
@@ -3730,69 +3857,69 @@ function Oa(e, n, t) {
|
|
|
3730
3857
|
if (i.has(d))
|
|
3731
3858
|
return;
|
|
3732
3859
|
i.add(d);
|
|
3733
|
-
const g =
|
|
3860
|
+
const g = hn(
|
|
3734
3861
|
a.images,
|
|
3735
3862
|
c.name
|
|
3736
|
-
),
|
|
3863
|
+
), u = {
|
|
3737
3864
|
src: g.imageUrl,
|
|
3738
3865
|
alt: g.imageText ?? "",
|
|
3739
3866
|
label: `${c.name}: ${c.values[0]}`,
|
|
3740
3867
|
value: c.values[0]
|
|
3741
3868
|
};
|
|
3742
|
-
r[c.name] ? r[c.name].push(
|
|
3869
|
+
r[c.name] ? r[c.name].push(u) : r[c.name] = [u];
|
|
3743
3870
|
});
|
|
3744
|
-
}),
|
|
3871
|
+
}), La(r);
|
|
3745
3872
|
}
|
|
3746
|
-
const
|
|
3747
|
-
activeVariations: (e) =>
|
|
3748
|
-
allVariantsByName: (e) =>
|
|
3749
|
-
slugsMap: (e, n) =>
|
|
3873
|
+
const $a = {
|
|
3874
|
+
activeVariations: (e) => fn(e.variations),
|
|
3875
|
+
allVariantsByName: (e) => Na(e.isVariantOf.skuSpecifications),
|
|
3876
|
+
slugsMap: (e, n) => Ra(
|
|
3750
3877
|
e.isVariantOf.items,
|
|
3751
3878
|
n.dominantVariantName ?? e.variations[0]?.name,
|
|
3752
3879
|
e.isVariantOf.linkText
|
|
3753
3880
|
),
|
|
3754
3881
|
availableVariations: (e, n) => {
|
|
3755
|
-
const t = n.dominantVariantName ?? e.variations[0]?.name, i =
|
|
3756
|
-
return
|
|
3882
|
+
const t = n.dominantVariantName ?? e.variations[0]?.name, i = fn(e.variations)[t];
|
|
3883
|
+
return Ba(
|
|
3757
3884
|
e.isVariantOf.items,
|
|
3758
3885
|
t,
|
|
3759
3886
|
i
|
|
3760
3887
|
);
|
|
3761
3888
|
},
|
|
3762
3889
|
allVariantProducts: (e) => e.isVariantOf.items.map((n) => L(n, e.isVariantOf))
|
|
3763
|
-
},
|
|
3890
|
+
}, Ma = {
|
|
3764
3891
|
"pickup-in-point": "Pickup",
|
|
3765
3892
|
delivery: "Delivery",
|
|
3766
3893
|
pickup: "Pickup",
|
|
3767
3894
|
"take-away": "Take away",
|
|
3768
3895
|
"": ""
|
|
3769
|
-
},
|
|
3896
|
+
}, za = {
|
|
3770
3897
|
deliveryOptionsData: (e) => {
|
|
3771
3898
|
const { shippingData: n, items: t } = e, r = n?.logisticsInfo || [], i = n?.selectedAddresses || n?.availableAddresses || [n?.address], a = r.reduce(
|
|
3772
3899
|
(d, g) => {
|
|
3773
|
-
const
|
|
3774
|
-
(
|
|
3775
|
-
),
|
|
3900
|
+
const u = g?.selectedSla || "", f = g?.selectedDeliveryChannel || g?.deliveryChannel || "", h = g?.deliveryCompany || "", I = g?.deliveryWindow, l = g?.pickupStoreInfo, p = g?.shippingEstimate || "", m = g?.shippingEstimate ? et(g?.shippingEstimate) : "", S = g?.shippingEstimateDate || "", v = g?.addressId || "", O = g?.itemIndex ?? 0, C = t?.[O], T = C?.seller || "", w = `${u}|${f}|${h}|${T}|${p}|${S}|${v}|${I?.startDateUtc}|${I?.endDateUtc}`, b = i?.find(
|
|
3901
|
+
(U) => U?.addressId === v
|
|
3902
|
+
), A = `${Ma[f] || ""} ${m} ${b?.neighborhood ? `to ${b?.neighborhood}` : ""}`.trim(), { taxPriceTagsTotal: E, taxPriceTags: _ } = Va(
|
|
3776
3903
|
C?.priceTags ?? []
|
|
3777
|
-
),
|
|
3778
|
-
return d[
|
|
3904
|
+
), D = (C?.sellingPrice ?? 0) * (C?.quantity ?? 0) + (C?.tax ?? 0) + (E ?? 0);
|
|
3905
|
+
return d[w] || (d[w] = {
|
|
3779
3906
|
// static fields
|
|
3780
|
-
selectedSla:
|
|
3907
|
+
selectedSla: u,
|
|
3781
3908
|
deliveryChannel: f,
|
|
3782
3909
|
deliveryCompany: h,
|
|
3783
3910
|
deliveryWindow: I,
|
|
3784
|
-
shippingEstimate:
|
|
3911
|
+
shippingEstimate: p,
|
|
3785
3912
|
shippingEstimateDate: S,
|
|
3786
|
-
seller:
|
|
3913
|
+
seller: T,
|
|
3787
3914
|
friendlyShippingEstimate: m,
|
|
3788
|
-
friendlyDeliveryOptionName:
|
|
3789
|
-
address:
|
|
3915
|
+
friendlyDeliveryOptionName: A,
|
|
3916
|
+
address: b,
|
|
3790
3917
|
pickupStoreInfo: l,
|
|
3791
3918
|
// dynamic fields
|
|
3792
3919
|
quantityOfDifferentItems: 0,
|
|
3793
3920
|
total: 0,
|
|
3794
3921
|
items: []
|
|
3795
|
-
}), d[
|
|
3922
|
+
}), d[w] && (d[w].items?.push({
|
|
3796
3923
|
id: C?.id || "",
|
|
3797
3924
|
uniqueId: C?.uniqueId || "",
|
|
3798
3925
|
name: C?.name || "",
|
|
@@ -3800,11 +3927,11 @@ const Ca = {
|
|
|
3800
3927
|
price: C?.price || 0,
|
|
3801
3928
|
sellingPrice: C?.sellingPrice || 0,
|
|
3802
3929
|
imageUrl: C?.imageUrl || "",
|
|
3803
|
-
taxPriceTags:
|
|
3804
|
-
taxPriceTagsTotal:
|
|
3930
|
+
taxPriceTags: _ ?? [],
|
|
3931
|
+
taxPriceTagsTotal: E ?? 0,
|
|
3805
3932
|
tax: C?.tax || 0,
|
|
3806
|
-
total:
|
|
3807
|
-
}), d[
|
|
3933
|
+
total: D
|
|
3934
|
+
}), d[w].quantityOfDifferentItems = (d[w].quantityOfDifferentItems ?? 0) + 1, d[w].total = (d[w].total ?? 0) + D), d;
|
|
3808
3935
|
},
|
|
3809
3936
|
{}
|
|
3810
3937
|
), o = Object.values(a), s = n?.contactInformation?.[0], c = {
|
|
@@ -3830,7 +3957,7 @@ const Ca = {
|
|
|
3830
3957
|
) || [];
|
|
3831
3958
|
}
|
|
3832
3959
|
};
|
|
3833
|
-
function
|
|
3960
|
+
function Va(e) {
|
|
3834
3961
|
const t = e.filter(
|
|
3835
3962
|
(i) => i?.name?.includes("TAX")
|
|
3836
3963
|
), r = t.reduce(
|
|
@@ -3842,28 +3969,28 @@ function Aa(e) {
|
|
|
3842
3969
|
taxPriceTagsTotal: r
|
|
3843
3970
|
};
|
|
3844
3971
|
}
|
|
3845
|
-
const
|
|
3846
|
-
StoreCollection:
|
|
3847
|
-
StoreAggregateOffer:
|
|
3848
|
-
StoreProduct:
|
|
3849
|
-
StoreSeo:
|
|
3850
|
-
StoreFacet:
|
|
3851
|
-
StoreFacetBoolean:
|
|
3852
|
-
StoreFacetRange:
|
|
3853
|
-
StoreFacetValueBoolean:
|
|
3854
|
-
StoreOffer:
|
|
3855
|
-
StoreAggregateRating:
|
|
3856
|
-
StoreReview:
|
|
3857
|
-
StoreProductGroup:
|
|
3858
|
-
StoreSearchResult:
|
|
3859
|
-
StorePropertyValue:
|
|
3860
|
-
SkuVariants:
|
|
3861
|
-
ShippingSLA:
|
|
3862
|
-
UserOrderResult:
|
|
3863
|
-
ObjectOrString:
|
|
3864
|
-
Query:
|
|
3865
|
-
Mutation:
|
|
3866
|
-
},
|
|
3972
|
+
const xa = {
|
|
3973
|
+
StoreCollection: Un,
|
|
3974
|
+
StoreAggregateOffer: Rr,
|
|
3975
|
+
StoreProduct: oa,
|
|
3976
|
+
StoreSeo: Ea,
|
|
3977
|
+
StoreFacet: xr,
|
|
3978
|
+
StoreFacetBoolean: qr,
|
|
3979
|
+
StoreFacetRange: jr,
|
|
3980
|
+
StoreFacetValueBoolean: Wr,
|
|
3981
|
+
StoreOffer: ea,
|
|
3982
|
+
StoreAggregateRating: Nr,
|
|
3983
|
+
StoreReview: Aa,
|
|
3984
|
+
StoreProductGroup: ca,
|
|
3985
|
+
StoreSearchResult: Da,
|
|
3986
|
+
StorePropertyValue: la,
|
|
3987
|
+
SkuVariants: $a,
|
|
3988
|
+
ShippingSLA: Ua,
|
|
3989
|
+
UserOrderResult: za,
|
|
3990
|
+
ObjectOrString: Zi,
|
|
3991
|
+
Query: wa,
|
|
3992
|
+
Mutation: Ki
|
|
3993
|
+
}, qa = () => xa, ja = `"""
|
|
3867
3994
|
Address information.
|
|
3868
3995
|
"""
|
|
3869
3996
|
type Address {
|
|
@@ -3908,7 +4035,7 @@ type Address {
|
|
|
3908
4035
|
"""
|
|
3909
4036
|
geoCoordinates: [Float]
|
|
3910
4037
|
}
|
|
3911
|
-
`,
|
|
4038
|
+
`, Wa = `"""
|
|
3912
4039
|
Advertisement information about a specific product in a campaign
|
|
3913
4040
|
"""
|
|
3914
4041
|
type Advertisement {
|
|
@@ -3933,7 +4060,7 @@ type Advertisement {
|
|
|
3933
4060
|
"""
|
|
3934
4061
|
adResponseId: String!
|
|
3935
4062
|
}
|
|
3936
|
-
`,
|
|
4063
|
+
`, Ha = `"""
|
|
3937
4064
|
Aggregate offer information, for a given SKU that is available to be fulfilled by multiple sellers.
|
|
3938
4065
|
"""
|
|
3939
4066
|
type StoreAggregateOffer {
|
|
@@ -3962,7 +4089,7 @@ type StoreAggregateOffer {
|
|
|
3962
4089
|
"""
|
|
3963
4090
|
offers: [StoreOffer!]!
|
|
3964
4091
|
}
|
|
3965
|
-
`,
|
|
4092
|
+
`, Ga = `"""
|
|
3966
4093
|
Average rating, based on multiple ratings or reviews.
|
|
3967
4094
|
"""
|
|
3968
4095
|
type StoreAggregateRating {
|
|
@@ -3975,7 +4102,7 @@ type StoreAggregateRating {
|
|
|
3975
4102
|
"""
|
|
3976
4103
|
reviewCount: Int!
|
|
3977
4104
|
}
|
|
3978
|
-
`,
|
|
4105
|
+
`, Xa = `"""
|
|
3979
4106
|
information about the author of a product review or rating.
|
|
3980
4107
|
"""
|
|
3981
4108
|
type StoreAuthor {
|
|
@@ -3984,7 +4111,7 @@ type StoreAuthor {
|
|
|
3984
4111
|
"""
|
|
3985
4112
|
name: String!
|
|
3986
4113
|
}
|
|
3987
|
-
`,
|
|
4114
|
+
`, Ya = `"""
|
|
3988
4115
|
Brand of a given product.
|
|
3989
4116
|
"""
|
|
3990
4117
|
type StoreBrand {
|
|
@@ -3993,7 +4120,7 @@ type StoreBrand {
|
|
|
3993
4120
|
"""
|
|
3994
4121
|
name: String!
|
|
3995
4122
|
}
|
|
3996
|
-
`,
|
|
4123
|
+
`, Ka = `"""
|
|
3997
4124
|
Item of a list.
|
|
3998
4125
|
"""
|
|
3999
4126
|
type StoreListItem {
|
|
@@ -4024,7 +4151,7 @@ type StoreBreadcrumbList {
|
|
|
4024
4151
|
"""
|
|
4025
4152
|
numberOfItems: Int!
|
|
4026
4153
|
}
|
|
4027
|
-
`,
|
|
4154
|
+
`, Ja = `"""
|
|
4028
4155
|
Shopping cart message.
|
|
4029
4156
|
"""
|
|
4030
4157
|
type StoreCartMessage {
|
|
@@ -4061,7 +4188,7 @@ input IStoreCart {
|
|
|
4061
4188
|
"""
|
|
4062
4189
|
order: IStoreOrder!
|
|
4063
4190
|
}
|
|
4064
|
-
`,
|
|
4191
|
+
`, Qa = `"""
|
|
4065
4192
|
Product collection type. Possible values are \`Department\`, \`Category\`, \`Brand\` or \`Collection\`.
|
|
4066
4193
|
|
|
4067
4194
|
\`SubCategory\` and \`Cluster\` are still declared for backward compatibility but are
|
|
@@ -4187,7 +4314,7 @@ type StoreCollectionLocale {
|
|
|
4187
4314
|
"""
|
|
4188
4315
|
slug: String!
|
|
4189
4316
|
}
|
|
4190
|
-
`,
|
|
4317
|
+
`, Za = `"""
|
|
4191
4318
|
Delivery Promise badge.
|
|
4192
4319
|
"""
|
|
4193
4320
|
type DeliveryPromiseBadge {
|
|
@@ -4196,7 +4323,7 @@ type DeliveryPromiseBadge {
|
|
|
4196
4323
|
"""
|
|
4197
4324
|
typeName: String
|
|
4198
4325
|
}
|
|
4199
|
-
`,
|
|
4326
|
+
`, eo = `union StoreFacet = StoreFacetRange | StoreFacetBoolean
|
|
4200
4327
|
|
|
4201
4328
|
"""
|
|
4202
4329
|
Search facet range information.
|
|
@@ -4273,7 +4400,7 @@ type StoreFacetValueBoolean {
|
|
|
4273
4400
|
"""
|
|
4274
4401
|
quantity: Int
|
|
4275
4402
|
}
|
|
4276
|
-
`,
|
|
4403
|
+
`, no = `"""
|
|
4277
4404
|
Image.
|
|
4278
4405
|
"""
|
|
4279
4406
|
type StoreImage {
|
|
@@ -4300,7 +4427,7 @@ input IStoreImage {
|
|
|
4300
4427
|
"""
|
|
4301
4428
|
alternateName: String!
|
|
4302
4429
|
}
|
|
4303
|
-
`,
|
|
4430
|
+
`, to = `type Mutation {
|
|
4304
4431
|
"""
|
|
4305
4432
|
Checks for changes between the cart presented in the UI and the cart stored in the ecommerce platform. If changes are detected, it returns the cart stored on the platform. Otherwise, it returns \`null\`.
|
|
4306
4433
|
"""
|
|
@@ -4342,7 +4469,7 @@ input IStoreImage {
|
|
|
4342
4469
|
"""
|
|
4343
4470
|
startRecommendationSession: Boolean!
|
|
4344
4471
|
}
|
|
4345
|
-
`,
|
|
4472
|
+
`, ro = `"""
|
|
4346
4473
|
Newsletter information.
|
|
4347
4474
|
"""
|
|
4348
4475
|
type PersonNewsletter {
|
|
@@ -4365,8 +4492,8 @@ input IPersonNewsletter {
|
|
|
4365
4492
|
"""
|
|
4366
4493
|
email: String!
|
|
4367
4494
|
}
|
|
4368
|
-
`,
|
|
4369
|
-
`,
|
|
4495
|
+
`, io = `scalar ObjectOrString
|
|
4496
|
+
`, ao = `"""
|
|
4370
4497
|
Offer information.
|
|
4371
4498
|
"""
|
|
4372
4499
|
type StoreOffer {
|
|
@@ -4459,7 +4586,7 @@ input IStoreOffer {
|
|
|
4459
4586
|
"""
|
|
4460
4587
|
priceToken: String
|
|
4461
4588
|
}
|
|
4462
|
-
`,
|
|
4589
|
+
`, oo = `"""
|
|
4463
4590
|
Information of a specific order.
|
|
4464
4591
|
"""
|
|
4465
4592
|
type StoreOrder {
|
|
@@ -4500,7 +4627,7 @@ input IStoreOrder {
|
|
|
4500
4627
|
"""
|
|
4501
4628
|
shouldSplitItem: Boolean
|
|
4502
4629
|
}
|
|
4503
|
-
`,
|
|
4630
|
+
`, so = `"""
|
|
4504
4631
|
Commercial Authorization response.
|
|
4505
4632
|
"""
|
|
4506
4633
|
type CommercialAuthorizationResponse {
|
|
@@ -4899,7 +5026,7 @@ type ProcessOrderAuthorizationRule {
|
|
|
4899
5026
|
"""
|
|
4900
5027
|
rule: CommercialAuthorizationRule!
|
|
4901
5028
|
}
|
|
4902
|
-
`,
|
|
5029
|
+
`, co = `"""
|
|
4903
5030
|
Input for uploading a file to the Order Entry Service.
|
|
4904
5031
|
The file is transmitted as a Base64-encoded string so it can travel
|
|
4905
5032
|
through the standard GraphQL JSON pipeline without multipart support.
|
|
@@ -4960,7 +5087,7 @@ type StoreOrderFormCartItem {
|
|
|
4960
5087
|
seller: String!
|
|
4961
5088
|
unitMultiplier: Float
|
|
4962
5089
|
}
|
|
4963
|
-
`,
|
|
5090
|
+
`, lo = `"""
|
|
4964
5091
|
Organization.
|
|
4965
5092
|
"""
|
|
4966
5093
|
type StoreOrganization {
|
|
@@ -5001,7 +5128,7 @@ type StoreContract {
|
|
|
5001
5128
|
"""
|
|
5002
5129
|
isDefault: Boolean!
|
|
5003
5130
|
}
|
|
5004
|
-
`,
|
|
5131
|
+
`, uo = `"""
|
|
5005
5132
|
Whenever you make a query that allows for pagination, such as \`allProducts\` or \`allCollections\`, you can check \`StorePageInfo\` to learn more about the complete set of items and use it to paginate your queries.
|
|
5006
5133
|
"""
|
|
5007
5134
|
type StorePageInfo {
|
|
@@ -5026,7 +5153,7 @@ type StorePageInfo {
|
|
|
5026
5153
|
"""
|
|
5027
5154
|
totalCount: Int!
|
|
5028
5155
|
}
|
|
5029
|
-
`,
|
|
5156
|
+
`, po = `"""
|
|
5030
5157
|
Input type for setting a new password.
|
|
5031
5158
|
"""
|
|
5032
5159
|
input ISetPassword {
|
|
@@ -5069,7 +5196,7 @@ type SetPasswordResponse {
|
|
|
5069
5196
|
"""
|
|
5070
5197
|
message: String
|
|
5071
5198
|
}
|
|
5072
|
-
`,
|
|
5199
|
+
`, go = `"""
|
|
5073
5200
|
Client profile data.
|
|
5074
5201
|
"""
|
|
5075
5202
|
type StorePerson {
|
|
@@ -5112,7 +5239,7 @@ input IStorePerson {
|
|
|
5112
5239
|
"""
|
|
5113
5240
|
familyName: String!
|
|
5114
5241
|
}
|
|
5115
|
-
`,
|
|
5242
|
+
`, mo = `type PickupPointAddress {
|
|
5116
5243
|
"""
|
|
5117
5244
|
Address city.
|
|
5118
5245
|
"""
|
|
@@ -5194,7 +5321,7 @@ type PickupPoints {
|
|
|
5194
5321
|
reason: "Not returned by Intelligent Search pickup-point-availability. Always null."
|
|
5195
5322
|
)
|
|
5196
5323
|
}
|
|
5197
|
-
`,
|
|
5324
|
+
`, ho = `"""
|
|
5198
5325
|
Product information. Products are variants within product groups, equivalent to VTEX [SKUs](https://help.vtex.com/en/tutorial/what-is-an-sku--1K75s4RXAQyOuGUYKMM68u#). For example, you may have a **Shirt** product group with associated products such as **Blue shirt size L**, **Green shirt size XL** and so on.
|
|
5199
5326
|
"""
|
|
5200
5327
|
type StoreProduct {
|
|
@@ -5370,7 +5497,7 @@ input IStoreProduct {
|
|
|
5370
5497
|
"""
|
|
5371
5498
|
additionalProperty: [IStorePropertyValue!]
|
|
5372
5499
|
}
|
|
5373
|
-
`,
|
|
5500
|
+
`, fo = `"""
|
|
5374
5501
|
Product group information. Product groups are catalog entities that may contain variants. They are equivalent to VTEX [Products](https://help.vtex.com/en/tutorial/what-is-a-product--2zrB2gFCHyQokCKKE8kuAw#), whereas each variant is equivalent to a VTEX [SKU](https://help.vtex.com/en/tutorial/what-is-an-sku--1K75s4RXAQyOuGUYKMM68u#). For example, you may have a **Shirt** product group with associated products such as **Blue shirt size L**, **Green shirt size XL** and so on.
|
|
5375
5502
|
"""
|
|
5376
5503
|
type StoreProductGroup {
|
|
@@ -5415,7 +5542,7 @@ type StoreProductCluster {
|
|
|
5415
5542
|
"""
|
|
5416
5543
|
name: String!
|
|
5417
5544
|
}
|
|
5418
|
-
`,
|
|
5545
|
+
`, So = `type Profile {
|
|
5419
5546
|
"""
|
|
5420
5547
|
Collection of user's address
|
|
5421
5548
|
"""
|
|
@@ -5476,7 +5603,7 @@ type ProfileAddress {
|
|
|
5476
5603
|
"""
|
|
5477
5604
|
geoCoordinate: [Float]
|
|
5478
5605
|
}
|
|
5479
|
-
`,
|
|
5606
|
+
`, yo = `"""
|
|
5480
5607
|
Properties that can be associated with products and products groups.
|
|
5481
5608
|
"""
|
|
5482
5609
|
type StorePropertyValue {
|
|
@@ -5516,7 +5643,7 @@ input IStorePropertyValue {
|
|
|
5516
5643
|
"""
|
|
5517
5644
|
valueReference: ObjectOrString!
|
|
5518
5645
|
}
|
|
5519
|
-
`,
|
|
5646
|
+
`, Io = `"""
|
|
5520
5647
|
Each product edge contains a \`node\`, with product information, and a \`cursor\`, that can be used as a reference for pagination.
|
|
5521
5648
|
"""
|
|
5522
5649
|
type StoreProductEdge {
|
|
@@ -6177,7 +6304,7 @@ type StoreAccountProfile {
|
|
|
6177
6304
|
email: String
|
|
6178
6305
|
id: String
|
|
6179
6306
|
}
|
|
6180
|
-
`,
|
|
6307
|
+
`, vo = `"""
|
|
6181
6308
|
Summary of a quote returned in list results.
|
|
6182
6309
|
"""
|
|
6183
6310
|
type UserQuoteSummary {
|
|
@@ -6242,7 +6369,7 @@ type UserQuoteListPaging {
|
|
|
6242
6369
|
"""
|
|
6243
6370
|
perPage: Int!
|
|
6244
6371
|
}
|
|
6245
|
-
`,
|
|
6372
|
+
`, Oo = `type RecommendationResponse {
|
|
6246
6373
|
products: [StoreProduct!]!
|
|
6247
6374
|
correlationId: String!
|
|
6248
6375
|
campaign: RecommendationCampaign!
|
|
@@ -6253,7 +6380,7 @@ type RecommendationCampaign {
|
|
|
6253
6380
|
title: String
|
|
6254
6381
|
type: String!
|
|
6255
6382
|
}
|
|
6256
|
-
`,
|
|
6383
|
+
`, Co = `"""
|
|
6257
6384
|
Information of a given review rating.
|
|
6258
6385
|
"""
|
|
6259
6386
|
type StoreReviewRating {
|
|
@@ -6280,7 +6407,7 @@ type StoreReview {
|
|
|
6280
6407
|
"""
|
|
6281
6408
|
author: StoreAuthor!
|
|
6282
6409
|
}
|
|
6283
|
-
`,
|
|
6410
|
+
`, bo = `"""
|
|
6284
6411
|
Whether a saved card is personally owned by the buyer or shared by their
|
|
6285
6412
|
Organization/Contract. Resolved server-side by the Saved-cards service from
|
|
6286
6413
|
the buyer's \`useAdHocCard\` role — never inferred client-side.
|
|
@@ -6344,7 +6471,7 @@ type SavedCardListResult {
|
|
|
6344
6471
|
"""
|
|
6345
6472
|
list: [SavedCard!]
|
|
6346
6473
|
}
|
|
6347
|
-
`,
|
|
6474
|
+
`, wo = `"""
|
|
6348
6475
|
Search Engine Optimization (SEO) tags data.
|
|
6349
6476
|
"""
|
|
6350
6477
|
type StoreSeo {
|
|
@@ -6365,7 +6492,7 @@ type StoreSeo {
|
|
|
6365
6492
|
"""
|
|
6366
6493
|
canonical: String!
|
|
6367
6494
|
}
|
|
6368
|
-
`,
|
|
6495
|
+
`, Ao = `"""
|
|
6369
6496
|
Currency information.
|
|
6370
6497
|
"""
|
|
6371
6498
|
type StoreCurrency {
|
|
@@ -6558,6 +6685,9 @@ type StoreSession {
|
|
|
6558
6685
|
type StoreB2B {
|
|
6559
6686
|
customerId: String!
|
|
6560
6687
|
isRepresentative: Boolean
|
|
6688
|
+
@deprecated(
|
|
6689
|
+
reason: "Always true when \`b2b\` is set: a B2B session is identified by \`unitId\` and \`customerId\`. Check that \`b2b\` is not null instead. Scheduled for removal in the next major."
|
|
6690
|
+
)
|
|
6561
6691
|
unitName: String
|
|
6562
6692
|
unitId: String
|
|
6563
6693
|
firstName: String
|
|
@@ -6640,7 +6770,7 @@ input IStoreSession {
|
|
|
6640
6770
|
"""
|
|
6641
6771
|
refreshAfter: String
|
|
6642
6772
|
}
|
|
6643
|
-
`,
|
|
6773
|
+
`, Po = `"""
|
|
6644
6774
|
Shipping Simulation item input.
|
|
6645
6775
|
"""
|
|
6646
6776
|
input IShippingItem {
|
|
@@ -6971,7 +7101,7 @@ type MessageFields {
|
|
|
6971
7101
|
"""
|
|
6972
7102
|
skuName: String
|
|
6973
7103
|
}
|
|
6974
|
-
`,
|
|
7104
|
+
`, Do = `type SkuVariants {
|
|
6975
7105
|
"""
|
|
6976
7106
|
SKU property values for the current SKU.
|
|
6977
7107
|
"""
|
|
@@ -7066,7 +7196,7 @@ Example:
|
|
|
7066
7196
|
\`\`\`
|
|
7067
7197
|
"""
|
|
7068
7198
|
scalar FormattedVariants
|
|
7069
|
-
`,
|
|
7199
|
+
`, Eo = `"""
|
|
7070
7200
|
Status used to indicate a message type. For instance, a shopping cart informative or error message.
|
|
7071
7201
|
"""
|
|
7072
7202
|
enum StoreStatus {
|
|
@@ -7074,7 +7204,7 @@ enum StoreStatus {
|
|
|
7074
7204
|
WARNING
|
|
7075
7205
|
ERROR
|
|
7076
7206
|
}
|
|
7077
|
-
`,
|
|
7207
|
+
`, ko = `scalar JSONObject
|
|
7078
7208
|
|
|
7079
7209
|
type UserOrder {
|
|
7080
7210
|
orderId: String
|
|
@@ -7898,99 +8028,99 @@ type UserOrderBudgetAllocationLinkedEntity {
|
|
|
7898
8028
|
type: String
|
|
7899
8029
|
id: String
|
|
7900
8030
|
}
|
|
7901
|
-
`,
|
|
7902
|
-
"./address.graphql":
|
|
7903
|
-
"./advertisement.graphql":
|
|
7904
|
-
"./aggregateOffer.graphql":
|
|
7905
|
-
"./aggregateRating.graphql":
|
|
7906
|
-
"./author.graphql":
|
|
7907
|
-
"./brand.graphql":
|
|
7908
|
-
"./breadcrumb.graphql":
|
|
7909
|
-
"./cart.graphql":
|
|
7910
|
-
"./collection.graphql":
|
|
7911
|
-
"./deliveryPromisesBadge.graphql":
|
|
7912
|
-
"./facet.graphql":
|
|
7913
|
-
"./image.graphql":
|
|
7914
|
-
"./mutation.graphql":
|
|
7915
|
-
"./newsletter.graphql":
|
|
7916
|
-
"./objectOrString.graphql":
|
|
7917
|
-
"./offer.graphql":
|
|
7918
|
-
"./order.graphql":
|
|
7919
|
-
"./orderCommercialAuthorizaton.graphql":
|
|
7920
|
-
"./orderEntry.graphql":
|
|
7921
|
-
"./organization.graphql":
|
|
7922
|
-
"./pageInfo.graphql":
|
|
7923
|
-
"./password.graphql":
|
|
7924
|
-
"./person.graphql":
|
|
7925
|
-
"./pickupPoints.graphql":
|
|
7926
|
-
"./product.graphql":
|
|
7927
|
-
"./productGroup.graphql":
|
|
7928
|
-
"./profile.graphql":
|
|
7929
|
-
"./propertyValue.graphql":
|
|
7930
|
-
"./query.graphql":
|
|
7931
|
-
"./quote.graphql":
|
|
7932
|
-
"./recommendation.graphql":
|
|
7933
|
-
"./review.graphql":
|
|
7934
|
-
"./savedCard.graphql":
|
|
7935
|
-
"./seo.graphql":
|
|
7936
|
-
"./session.graphql":
|
|
7937
|
-
"./shipping.graphql":
|
|
7938
|
-
"./skuVariants.graphql":
|
|
7939
|
-
"./status.graphql":
|
|
7940
|
-
"./userOrder.graphql":
|
|
7941
|
-
}),
|
|
7942
|
-
Object.values(
|
|
7943
|
-
(e, n) =>
|
|
8031
|
+
`, _o = /* @__PURE__ */ Object.assign({
|
|
8032
|
+
"./address.graphql": ja,
|
|
8033
|
+
"./advertisement.graphql": Wa,
|
|
8034
|
+
"./aggregateOffer.graphql": Ha,
|
|
8035
|
+
"./aggregateRating.graphql": Ga,
|
|
8036
|
+
"./author.graphql": Xa,
|
|
8037
|
+
"./brand.graphql": Ya,
|
|
8038
|
+
"./breadcrumb.graphql": Ka,
|
|
8039
|
+
"./cart.graphql": Ja,
|
|
8040
|
+
"./collection.graphql": Qa,
|
|
8041
|
+
"./deliveryPromisesBadge.graphql": Za,
|
|
8042
|
+
"./facet.graphql": eo,
|
|
8043
|
+
"./image.graphql": no,
|
|
8044
|
+
"./mutation.graphql": to,
|
|
8045
|
+
"./newsletter.graphql": ro,
|
|
8046
|
+
"./objectOrString.graphql": io,
|
|
8047
|
+
"./offer.graphql": ao,
|
|
8048
|
+
"./order.graphql": oo,
|
|
8049
|
+
"./orderCommercialAuthorizaton.graphql": so,
|
|
8050
|
+
"./orderEntry.graphql": co,
|
|
8051
|
+
"./organization.graphql": lo,
|
|
8052
|
+
"./pageInfo.graphql": uo,
|
|
8053
|
+
"./password.graphql": po,
|
|
8054
|
+
"./person.graphql": go,
|
|
8055
|
+
"./pickupPoints.graphql": mo,
|
|
8056
|
+
"./product.graphql": ho,
|
|
8057
|
+
"./productGroup.graphql": fo,
|
|
8058
|
+
"./profile.graphql": So,
|
|
8059
|
+
"./propertyValue.graphql": yo,
|
|
8060
|
+
"./query.graphql": Io,
|
|
8061
|
+
"./quote.graphql": vo,
|
|
8062
|
+
"./recommendation.graphql": Oo,
|
|
8063
|
+
"./review.graphql": Co,
|
|
8064
|
+
"./savedCard.graphql": bo,
|
|
8065
|
+
"./seo.graphql": wo,
|
|
8066
|
+
"./session.graphql": Ao,
|
|
8067
|
+
"./shipping.graphql": Po,
|
|
8068
|
+
"./skuVariants.graphql": Do,
|
|
8069
|
+
"./status.graphql": Eo,
|
|
8070
|
+
"./userOrder.graphql": ko
|
|
8071
|
+
}), To = st(
|
|
8072
|
+
Object.values(_o).map((e) => ct(e)).reduce(
|
|
8073
|
+
(e, n) => Sn([e, n], { sort: !0 })
|
|
7944
8074
|
)
|
|
7945
|
-
),
|
|
7946
|
-
channel:
|
|
8075
|
+
), Uo = To, Ko = async (e) => (n) => (n.storage = {
|
|
8076
|
+
channel: oe.parse(e.channel),
|
|
7947
8077
|
flags: e.flags ?? {},
|
|
7948
8078
|
locale: e.locale,
|
|
7949
8079
|
customSortMap: e.customSortMap ?? {},
|
|
7950
8080
|
cookies: /* @__PURE__ */ new Map()
|
|
7951
|
-
}, n.account = e.account, n.OTEL_ENABLED = e.OTEL_ENABLED, n.discoveryConfig = e.discoveryConfig, n.clients =
|
|
7952
|
-
function
|
|
7953
|
-
const e =
|
|
8081
|
+
}, n.account = e.account, n.OTEL_ENABLED = e.OTEL_ENABLED, n.discoveryConfig = e.discoveryConfig, n.clients = Ir(e, n), n.loaders = kr(e, n), n);
|
|
8082
|
+
function Ro() {
|
|
8083
|
+
const e = qa(), n = {};
|
|
7954
8084
|
for (const [t, r] of Object.entries(e))
|
|
7955
8085
|
n[t] = Object.fromEntries(
|
|
7956
|
-
Object.entries(r).map(([i, a]) => typeof a != "function" ? [i, a] : [i,
|
|
8086
|
+
Object.entries(r).map(([i, a]) => typeof a != "function" ? [i, a] : [i, kt(a, `${t}(${i})`)])
|
|
7957
8087
|
);
|
|
7958
8088
|
return n;
|
|
7959
8089
|
}
|
|
7960
|
-
function
|
|
7961
|
-
const t =
|
|
7962
|
-
|
|
7963
|
-
|
|
7964
|
-
])(
|
|
7965
|
-
return e &&
|
|
8090
|
+
function Jo(e) {
|
|
8091
|
+
const t = Et([
|
|
8092
|
+
Dt,
|
|
8093
|
+
wt
|
|
8094
|
+
])(Ro(), Uo);
|
|
8095
|
+
return e && lt(e) ? at({
|
|
7966
8096
|
schemas: [t, e]
|
|
7967
8097
|
}) : t;
|
|
7968
8098
|
}
|
|
7969
8099
|
export {
|
|
7970
|
-
|
|
7971
|
-
|
|
7972
|
-
|
|
7973
|
-
|
|
7974
|
-
|
|
7975
|
-
|
|
7976
|
-
|
|
7977
|
-
|
|
7978
|
-
|
|
7979
|
-
|
|
7980
|
-
|
|
7981
|
-
|
|
7982
|
-
|
|
7983
|
-
|
|
8100
|
+
wt as AuthDirective,
|
|
8101
|
+
k as BadRequestError,
|
|
8102
|
+
Dt as CacheControlDirective,
|
|
8103
|
+
mt as CardOrigin,
|
|
8104
|
+
ht as CommercialAuthorizationStatus,
|
|
8105
|
+
Q as FastStoreError,
|
|
8106
|
+
re as ForbiddenError,
|
|
8107
|
+
Ko as GraphqlVtexContextFactory,
|
|
8108
|
+
Jo as GraphqlVtexSchema,
|
|
8109
|
+
B as NotFoundError,
|
|
8110
|
+
ft as StoreCollectionType,
|
|
8111
|
+
St as StoreFacetType,
|
|
8112
|
+
yt as StoreSort,
|
|
8113
|
+
It as StoreStatus,
|
|
7984
8114
|
de as UnauthorizedError,
|
|
7985
|
-
|
|
7986
|
-
|
|
7987
|
-
|
|
7988
|
-
|
|
7989
|
-
|
|
7990
|
-
|
|
7991
|
-
|
|
7992
|
-
|
|
7993
|
-
|
|
7994
|
-
|
|
7995
|
-
|
|
8115
|
+
vt as UserOrderInvoiceType,
|
|
8116
|
+
z as getAuthCookie,
|
|
8117
|
+
Xo as isBadRequestError,
|
|
8118
|
+
Go as isFastStoreError,
|
|
8119
|
+
_t as isForbiddenError,
|
|
8120
|
+
Y as isNotFoundError,
|
|
8121
|
+
Yo as isUnauthorizedError,
|
|
8122
|
+
Ho as stringifyCacheControl,
|
|
8123
|
+
Uo as typeDefs,
|
|
8124
|
+
Ct as validateUserAuthentication,
|
|
8125
|
+
Et as withDirectives
|
|
7996
8126
|
};
|