@faststore/api 4.5.0-dev.0 → 4.5.0-dev.1
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 +96 -42
- package/dist/cjs/index.js.map +1 -1
- package/dist/es/index.mjs +1267 -1091
- package/dist/es/index.mjs.map +1 -1
- package/dist/src/__generated__/schema.d.ts +40 -0
- package/dist/src/__generated__/schema.d.ts.map +1 -1
- package/dist/src/platforms/vtex/clients/commerce/Contract.d.ts +1 -0
- package/dist/src/platforms/vtex/clients/commerce/Contract.d.ts.map +1 -1
- package/dist/src/platforms/vtex/clients/commerce/index.d.ts +12 -0
- package/dist/src/platforms/vtex/clients/commerce/index.d.ts.map +1 -1
- package/dist/src/platforms/vtex/clients/commerce/types/RecommendationResult.d.ts +25 -0
- package/dist/src/platforms/vtex/clients/commerce/types/RecommendationResult.d.ts.map +1 -0
- package/dist/src/platforms/vtex/clients/commerce/types/Session.d.ts +10 -0
- package/dist/src/platforms/vtex/clients/commerce/types/Session.d.ts.map +1 -1
- package/dist/src/platforms/vtex/clients/index.d.ts +4 -0
- package/dist/src/platforms/vtex/clients/index.d.ts.map +1 -1
- package/dist/src/platforms/vtex/index.d.ts +7 -0
- package/dist/src/platforms/vtex/index.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 +7 -0
- package/dist/src/platforms/vtex/resolvers/index.d.ts.map +1 -1
- package/dist/src/platforms/vtex/resolvers/mutation.d.ts +1 -0
- package/dist/src/platforms/vtex/resolvers/mutation.d.ts.map +1 -1
- package/dist/src/platforms/vtex/resolvers/query.d.ts +7 -1
- package/dist/src/platforms/vtex/resolvers/query.d.ts.map +1 -1
- package/dist/src/platforms/vtex/resolvers/recommendations.d.ts +18 -0
- package/dist/src/platforms/vtex/resolvers/recommendations.d.ts.map +1 -0
- package/dist/src/platforms/vtex/resolvers/startRecommendationSession.d.ts +11 -0
- package/dist/src/platforms/vtex/resolvers/startRecommendationSession.d.ts.map +1 -0
- package/dist/src/platforms/vtex/resolvers/validateSession.d.ts.map +1 -1
- package/dist/src/platforms/vtex/utils/contract.d.ts +59 -0
- package/dist/src/platforms/vtex/utils/contract.d.ts.map +1 -0
- package/package.json +3 -3
- package/src/__generated__/schema.ts +47 -0
- package/src/platforms/vtex/clients/commerce/Contract.ts +1 -0
- package/src/platforms/vtex/clients/commerce/index.ts +88 -3
- package/src/platforms/vtex/clients/commerce/types/RecommendationResult.ts +27 -0
- package/src/platforms/vtex/clients/commerce/types/Session.ts +9 -0
- package/src/platforms/vtex/resolvers/mutation.ts +2 -0
- package/src/platforms/vtex/resolvers/query.ts +60 -3
- package/src/platforms/vtex/resolvers/recommendations.ts +80 -0
- package/src/platforms/vtex/resolvers/startRecommendationSession.ts +30 -0
- package/src/platforms/vtex/resolvers/validateSession.ts +2 -1
- package/src/platforms/vtex/typeDefs/mutation.graphql +4 -0
- package/src/platforms/vtex/typeDefs/organization.graphql +18 -0
- package/src/platforms/vtex/typeDefs/query.graphql +21 -0
- package/src/platforms/vtex/typeDefs/recommendation.graphql +11 -0
- package/src/platforms/vtex/utils/contract.ts +144 -0
package/dist/es/index.mjs
CHANGED
|
@@ -1,147 +1,147 @@
|
|
|
1
|
-
import { mergeTypeDefs as
|
|
2
|
-
import { makeExecutableSchema as
|
|
3
|
-
import { mapSchema as
|
|
4
|
-
import { OTELAPI as
|
|
5
|
-
import { GraphQLScalarType as
|
|
6
|
-
import { parse as
|
|
1
|
+
import { mergeTypeDefs as je } from "@graphql-tools/merge";
|
|
2
|
+
import { makeExecutableSchema as On, mergeSchemas as Cn } from "@graphql-tools/schema";
|
|
3
|
+
import { mapSchema as We, MapperKind as Ge, getDirective as He } from "@graphql-tools/utils";
|
|
4
|
+
import { OTELAPI as B } from "@faststore/diagnostics";
|
|
5
|
+
import { GraphQLScalarType as bn, print as wn, parse as Dn, isSchema as An } from "graphql";
|
|
6
|
+
import { parse as J } from "cookie";
|
|
7
7
|
import Pn from "isomorphic-unfetch";
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
var
|
|
14
|
-
const
|
|
8
|
+
import Ie from "p-limit";
|
|
9
|
+
import ie from "dataloader";
|
|
10
|
+
import Un from "sanitize-html";
|
|
11
|
+
import ve from "fast-deep-equal";
|
|
12
|
+
import En from "node:crypto";
|
|
13
|
+
var _n = /* @__PURE__ */ ((e) => (e.Accepted = "accepted", e.Denied = "denied", e.Pending = "pending", e))(_n || {}), Tn = /* @__PURE__ */ ((e) => (e.Brand = "Brand", e.Category = "Category", e.Cluster = "Cluster", e.Collection = "Collection", e.Department = "Department", e.SubCategory = "SubCategory", e))(Tn || {}), Rn = /* @__PURE__ */ ((e) => (e.Boolean = "BOOLEAN", e.Range = "RANGE", e))(Rn || {}), kn = /* @__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))(kn || {}), Fn = /* @__PURE__ */ ((e) => (e.Error = "ERROR", e.Info = "INFO", e.Warning = "WARNING", e))(Fn || {}), Nn = /* @__PURE__ */ ((e) => (e.Input = "Input", e.Output = "Output", e))(Nn || {});
|
|
14
|
+
const Bn = () => 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 Y("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
|
+
}, Ln = async (e) => {
|
|
24
24
|
const {
|
|
25
25
|
clients: { commerce: n }
|
|
26
26
|
} = e;
|
|
27
27
|
try {
|
|
28
28
|
if ((await n.vtexid.validate())?.authStatus?.toLowerCase() !== "success")
|
|
29
|
-
throw new
|
|
29
|
+
throw new Z("Authentication required");
|
|
30
30
|
} catch (t) {
|
|
31
31
|
const r = t.extensions?.status ?? t.status;
|
|
32
|
-
throw r === 401 ? new
|
|
32
|
+
throw r === 401 ? new Z("Authentication required") : r === 403 ? new Y("You are not allowed to access this resource") : new Z("Authentication required");
|
|
33
33
|
}
|
|
34
|
-
},
|
|
34
|
+
}, Mn = "auth", $n = {
|
|
35
35
|
typeDefs: "directive @auth on FIELD_DEFINITION",
|
|
36
|
-
transformer: (e) =>
|
|
37
|
-
[
|
|
38
|
-
if (
|
|
36
|
+
transformer: (e) => We(e, {
|
|
37
|
+
[Ge.OBJECT_FIELD]: (n) => {
|
|
38
|
+
if (He(e, n, Mn)?.[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 Ln(o), r?.(i, a, o, s));
|
|
41
41
|
}
|
|
42
42
|
return n;
|
|
43
43
|
}
|
|
44
44
|
})
|
|
45
|
-
},
|
|
45
|
+
}, zn = "cacheControl", va = (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
|
+
}, Ce = (e, n) => typeof e == "number" && typeof n == "number" ? e > n ? n : e : typeof e == "number" ? e : n, xn = (e, n) => typeof e == "string" && typeof n == "string" ? e === "public" && n === "public" ? "public" : "private" : e || n, Vn = {
|
|
53
53
|
typeDefs: "directive @cacheControl(sMaxAge: Int, staleWhileRevalidate: Int, scope: String) on FIELD_DEFINITION",
|
|
54
|
-
transformer: (e) =>
|
|
55
|
-
[
|
|
56
|
-
const t =
|
|
54
|
+
transformer: (e) => We(e, {
|
|
55
|
+
[Ge.OBJECT_FIELD]: (n) => {
|
|
56
|
+
const t = He(e, n, zn)?.[0];
|
|
57
57
|
if (t) {
|
|
58
58
|
const { sMaxAge: r, staleWhileRevalidate: i, scope: a } = t, o = n.resolve;
|
|
59
|
-
n.resolve = (s, c,
|
|
60
|
-
sMaxAge:
|
|
61
|
-
staleWhileRevalidate:
|
|
62
|
-
|
|
59
|
+
n.resolve = (s, c, l, p) => (l.cacheControl = {
|
|
60
|
+
sMaxAge: Ce(l.cacheControl?.sMaxAge, r),
|
|
61
|
+
staleWhileRevalidate: Ce(
|
|
62
|
+
l.cacheControl?.staleWhileRevalidate,
|
|
63
63
|
i
|
|
64
64
|
),
|
|
65
|
-
scope:
|
|
66
|
-
}, o?.(s, c,
|
|
65
|
+
scope: xn(l.cacheControl?.scope, a)
|
|
66
|
+
}, o?.(s, c, l, p));
|
|
67
67
|
}
|
|
68
68
|
return n;
|
|
69
69
|
}
|
|
70
70
|
})
|
|
71
|
-
},
|
|
72
|
-
const r =
|
|
71
|
+
}, qn = (e) => (n, t) => {
|
|
72
|
+
const r = je([
|
|
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
|
+
On({
|
|
79
79
|
typeDefs: r,
|
|
80
80
|
resolvers: n
|
|
81
81
|
})
|
|
82
82
|
);
|
|
83
|
-
},
|
|
84
|
-
name:
|
|
85
|
-
version:
|
|
86
|
-
},
|
|
83
|
+
}, se = "@faststore/api", ce = "4.5.0-dev.0", be = {
|
|
84
|
+
name: se,
|
|
85
|
+
version: ce
|
|
86
|
+
}, jn = (e, n) => (t, r, i, a) => {
|
|
87
87
|
if ((i?.OTEL?.enabled ?? !1) === !1)
|
|
88
88
|
return e(t, r, i, a);
|
|
89
|
-
const o =
|
|
90
|
-
|
|
89
|
+
const o = B.trace.getTracer(se, ce), s = B.propagation.extract(
|
|
90
|
+
B.context.active(),
|
|
91
91
|
i.OTEL
|
|
92
92
|
);
|
|
93
|
-
return
|
|
93
|
+
return B.context.with(s, () => {
|
|
94
94
|
const c = o.startSpan(n ?? "Unknown Graphql Resolver", {
|
|
95
95
|
startTime: Date.now(),
|
|
96
|
-
kind:
|
|
96
|
+
kind: B.SpanKind.INTERNAL,
|
|
97
97
|
attributes: {
|
|
98
98
|
timestamp: Date.now(),
|
|
99
|
-
"@faststore_version":
|
|
100
|
-
"@faststore_package_name":
|
|
99
|
+
"@faststore_version": ce,
|
|
100
|
+
"@faststore_package_name": se,
|
|
101
101
|
"@faststore_account_name": i.account,
|
|
102
102
|
"@faststore_environment": process.env.NODE_ENV
|
|
103
103
|
}
|
|
104
104
|
});
|
|
105
105
|
if (!c) return e(t, r, i, a);
|
|
106
106
|
try {
|
|
107
|
-
const
|
|
108
|
-
return
|
|
109
|
-
} catch (
|
|
110
|
-
throw c.end(), console.error(`Error when executing resolver: ${n}`,
|
|
107
|
+
const l = e(t, r, i, a);
|
|
108
|
+
return l instanceof Promise ? l.then((p) => (c.end(), p)) : (c.end(), l);
|
|
109
|
+
} catch (l) {
|
|
110
|
+
throw c.end(), console.error(`Error when executing resolver: ${n}`, l), l;
|
|
111
111
|
}
|
|
112
112
|
});
|
|
113
113
|
};
|
|
114
|
-
class
|
|
114
|
+
class Q extends Error {
|
|
115
115
|
constructor(n, t) {
|
|
116
116
|
super(t), this.extensions = n, this.name = "FastStoreError";
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
|
-
class
|
|
119
|
+
class T extends Q {
|
|
120
120
|
constructor(n) {
|
|
121
121
|
super({ status: 400, type: "BadRequestError" }, n);
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
|
-
class
|
|
124
|
+
class Z extends Q {
|
|
125
125
|
constructor(n) {
|
|
126
126
|
super({ status: 401, type: "UnauthorizedError" }, n);
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
|
-
class
|
|
129
|
+
class Y extends Q {
|
|
130
130
|
constructor(n) {
|
|
131
131
|
super({ status: 403, type: "ForbiddenError" }, n);
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
|
-
class L extends
|
|
134
|
+
class L extends Q {
|
|
135
135
|
constructor(n) {
|
|
136
136
|
super({ status: 404, type: "NotFoundError" }, n);
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
|
-
const
|
|
139
|
+
const Oa = (e) => e?.name === "FastStoreError", Ca = (e) => e?.extensions?.type === "BadRequestError", ba = (e) => e?.extensions?.type === "UnauthorizedError", Wn = (e) => e?.extensions?.type === "ForbiddenError", Xe = (e) => e?.extensions?.type === "NotFoundError", Gn = `${be.name}@${be.version}`, I = async (e, n, t) => {
|
|
140
140
|
const r = await Pn(e, {
|
|
141
141
|
...n,
|
|
142
142
|
headers: {
|
|
143
143
|
...n?.headers ?? {},
|
|
144
|
-
"User-Agent":
|
|
144
|
+
"User-Agent": Gn
|
|
145
145
|
}
|
|
146
146
|
});
|
|
147
147
|
if (r.ok)
|
|
@@ -151,21 +151,21 @@ const la = (e) => e?.name === "FastStoreError", da = (e) => e?.extensions?.type
|
|
|
151
151
|
if (typeof r?.status == "number")
|
|
152
152
|
switch (r.status) {
|
|
153
153
|
case 400:
|
|
154
|
-
throw new
|
|
154
|
+
throw new T(i);
|
|
155
155
|
case 401:
|
|
156
|
-
throw new
|
|
156
|
+
throw new Z(i);
|
|
157
157
|
case 403:
|
|
158
|
-
throw new
|
|
158
|
+
throw new Y(i);
|
|
159
159
|
case 404:
|
|
160
160
|
throw new L(i);
|
|
161
161
|
default:
|
|
162
|
-
throw new
|
|
162
|
+
throw new Q(
|
|
163
163
|
{ status: r.status, type: "UnknownError" },
|
|
164
164
|
i
|
|
165
165
|
);
|
|
166
166
|
}
|
|
167
167
|
throw new Error(i);
|
|
168
|
-
},
|
|
168
|
+
}, Ye = (e) => {
|
|
169
169
|
if (!e)
|
|
170
170
|
return e;
|
|
171
171
|
const n = /* @__PURE__ */ new Map(), t = e.split(";"), r = [];
|
|
@@ -179,8 +179,8 @@ const la = (e) => e?.name === "FastStoreError", da = (e) => e?.extensions?.type
|
|
|
179
179
|
}
|
|
180
180
|
}
|
|
181
181
|
}), r.map((i) => `${i}=${n.get(i)}`).join("; ");
|
|
182
|
-
},
|
|
183
|
-
const t = n.match(
|
|
182
|
+
}, Hn = /^([^=]+)=([^;]*)/, Xn = (e, n) => {
|
|
183
|
+
const t = n.match(Hn);
|
|
184
184
|
if (t) {
|
|
185
185
|
const r = t[1], i = t[2];
|
|
186
186
|
e.storage.cookies.set(r, {
|
|
@@ -188,16 +188,16 @@ const la = (e) => e?.name === "FastStoreError", da = (e) => e?.extensions?.type
|
|
|
188
188
|
setCookie: n
|
|
189
189
|
});
|
|
190
190
|
}
|
|
191
|
-
},
|
|
191
|
+
}, Yn = (e, n) => {
|
|
192
192
|
n.getSetCookie().forEach(
|
|
193
|
-
(t) =>
|
|
193
|
+
(t) => Xn(e, t)
|
|
194
194
|
);
|
|
195
|
-
},
|
|
195
|
+
}, Jn = (e) => (n) => Yn(e, n), le = (e) => {
|
|
196
196
|
if (!e.headers?.cookie)
|
|
197
197
|
return null;
|
|
198
|
-
const n =
|
|
198
|
+
const n = Ye(e.headers.cookie), t = Array.from(e.storage.cookies.entries());
|
|
199
199
|
return t.length === 0 ? n : t.reduce(
|
|
200
|
-
(r, [i, { value: a }]) =>
|
|
200
|
+
(r, [i, { value: a }]) => Qn(
|
|
201
201
|
r,
|
|
202
202
|
i,
|
|
203
203
|
a
|
|
@@ -205,30 +205,30 @@ const la = (e) => e?.name === "FastStoreError", da = (e) => e?.extensions?.type
|
|
|
205
205
|
n
|
|
206
206
|
);
|
|
207
207
|
}, Je = (e) => function(t) {
|
|
208
|
-
const r =
|
|
208
|
+
const r = le(e);
|
|
209
209
|
return r ? {
|
|
210
210
|
...t,
|
|
211
211
|
cookie: r
|
|
212
212
|
} : t;
|
|
213
|
-
},
|
|
214
|
-
const t =
|
|
215
|
-
return
|
|
216
|
-
},
|
|
213
|
+
}, z = (e, n) => {
|
|
214
|
+
const t = Ye(e);
|
|
215
|
+
return J(t)[`VtexIdclientAutCookie_${n}`] || "";
|
|
216
|
+
}, Qn = (e, n, t) => {
|
|
217
217
|
const r = new RegExp(`(${n})=([^;]*)`), i = e.match(r);
|
|
218
218
|
return i ? e.replace(
|
|
219
219
|
i[0],
|
|
220
220
|
`${i[1]}=${t}`
|
|
221
221
|
) : `${e};${n}=${t}`;
|
|
222
222
|
};
|
|
223
|
-
function
|
|
223
|
+
function X(e) {
|
|
224
224
|
return e ? JSON.parse(Buffer.from(e.split(".")[1], "base64").toString()) : null;
|
|
225
225
|
}
|
|
226
|
-
const
|
|
226
|
+
const Kn = "storefront/faststore.recommendation-shelf@v4", W = {
|
|
227
227
|
method: "POST",
|
|
228
228
|
headers: {
|
|
229
229
|
"content-type": "application/json"
|
|
230
230
|
}
|
|
231
|
-
},
|
|
231
|
+
}, Zn = /^\d{4}-\d{2}-\d{2}$/, et = /* @__PURE__ */ new Set([
|
|
232
232
|
"Draft",
|
|
233
233
|
"Requested",
|
|
234
234
|
"InReview",
|
|
@@ -239,7 +239,7 @@ const j = {
|
|
|
239
239
|
"ConvertedToCart",
|
|
240
240
|
"ConvertedToOrder"
|
|
241
241
|
]);
|
|
242
|
-
function
|
|
242
|
+
function nt({
|
|
243
243
|
page: e,
|
|
244
244
|
perPage: n,
|
|
245
245
|
status: t,
|
|
@@ -262,19 +262,19 @@ function Zn({
|
|
|
262
262
|
["expiresAtFrom", a],
|
|
263
263
|
["expiresAtTo", o]
|
|
264
264
|
])
|
|
265
|
-
if (c && !
|
|
265
|
+
if (c && !Zn.test(c))
|
|
266
266
|
throw new Error(
|
|
267
267
|
`listUserQuotes: invalid ${s} "${c}" — must be YYYY-MM-DD`
|
|
268
268
|
);
|
|
269
269
|
if (t && t.length > 0) {
|
|
270
|
-
const s = t.filter((c) => !
|
|
270
|
+
const s = t.filter((c) => !et.has(c));
|
|
271
271
|
if (s.length > 0)
|
|
272
272
|
throw new Error(
|
|
273
273
|
`listUserQuotes: invalid status values: ${s.join(", ")}`
|
|
274
274
|
);
|
|
275
275
|
}
|
|
276
276
|
}
|
|
277
|
-
function
|
|
277
|
+
function tt({
|
|
278
278
|
page: e,
|
|
279
279
|
perPage: n,
|
|
280
280
|
status: t,
|
|
@@ -285,48 +285,59 @@ function et({
|
|
|
285
285
|
label: s
|
|
286
286
|
}) {
|
|
287
287
|
const c = new URLSearchParams();
|
|
288
|
-
return e && c.append("pageNumber", e.toString()), n && c.append("pageSize", n.toString()), t?.forEach((
|
|
288
|
+
return e && c.append("pageNumber", e.toString()), n && c.append("pageSize", n.toString()), t?.forEach((l) => c.append("status", l)), 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;
|
|
289
289
|
}
|
|
290
|
-
const
|
|
291
|
-
const a = `https://${e}.${n}.com.br`, o =
|
|
290
|
+
const rt = ({ account: e, environment: n, incrementAddress: t, subDomainPrefix: r }, i) => {
|
|
291
|
+
const a = `https://${e}.${n}.com.br`, o = Jn(i), s = Je(i), c = Bn(), l = new Headers(i.headers).get("x-forwarded-host") ?? i.headers?.host ?? "", p = r && r.map((d) => d + ".").find((d) => l.includes(d)) || "", u = l.replace(p, ""), h = `${a}/api/recommend-bff/v2`, S = s({
|
|
292
|
+
accept: "application/json",
|
|
293
|
+
"content-type": "application/json",
|
|
294
|
+
"x-vtex-rec-origin": `${e}/${Kn}`
|
|
295
|
+
}), b = (d = {}) => {
|
|
296
|
+
const g = z(le(i) ?? "", e);
|
|
297
|
+
return s({
|
|
298
|
+
...d,
|
|
299
|
+
"X-FORWARDED-HOST": u,
|
|
300
|
+
...g ? { [`VtexIdclientAutCookie_${e}`]: g } : {}
|
|
301
|
+
});
|
|
302
|
+
};
|
|
292
303
|
return {
|
|
293
304
|
catalog: {
|
|
294
|
-
salesChannel: (
|
|
295
|
-
`${a}/api/catalog_system/pub/saleschannel/${
|
|
305
|
+
salesChannel: (d) => I(
|
|
306
|
+
`${a}/api/catalog_system/pub/saleschannel/${d}`,
|
|
296
307
|
void 0,
|
|
297
308
|
{ storeCookies: o }
|
|
298
309
|
),
|
|
299
310
|
brand: {
|
|
300
|
-
list: () =>
|
|
311
|
+
list: () => I(`${a}/api/catalog_system/pub/brand/list`, void 0, {
|
|
301
312
|
storeCookies: o
|
|
302
313
|
})
|
|
303
314
|
},
|
|
304
315
|
category: {
|
|
305
|
-
tree: (
|
|
306
|
-
`${a}/api/catalog_system/pub/category/tree/${
|
|
316
|
+
tree: (d = 3) => I(
|
|
317
|
+
`${a}/api/catalog_system/pub/category/tree/${d}`,
|
|
307
318
|
void 0,
|
|
308
319
|
{ storeCookies: o }
|
|
309
320
|
)
|
|
310
321
|
},
|
|
311
322
|
portal: {
|
|
312
|
-
pagetype: (
|
|
313
|
-
`${a}/api/catalog_system/pub/portal/pagetype/${
|
|
323
|
+
pagetype: (d) => I(
|
|
324
|
+
`${a}/api/catalog_system/pub/portal/pagetype/${d}`,
|
|
314
325
|
void 0,
|
|
315
326
|
{ storeCookies: o }
|
|
316
327
|
)
|
|
317
328
|
},
|
|
318
329
|
products: {
|
|
319
330
|
crossselling: ({
|
|
320
|
-
type:
|
|
321
|
-
productId:
|
|
331
|
+
type: d,
|
|
332
|
+
productId: g,
|
|
322
333
|
groupByProduct: m = !0
|
|
323
334
|
}) => {
|
|
324
335
|
const y = new URLSearchParams({
|
|
325
336
|
sc: i.storage.channel.salesChannel,
|
|
326
337
|
groupByProduct: m.toString()
|
|
327
338
|
});
|
|
328
|
-
return
|
|
329
|
-
`${a}/api/catalog_system/pub/products/crossselling/${
|
|
339
|
+
return I(
|
|
340
|
+
`${a}/api/catalog_system/pub/products/crossselling/${d}/${g}?${y}`,
|
|
330
341
|
void 0,
|
|
331
342
|
{ storeCookies: o }
|
|
332
343
|
);
|
|
@@ -334,147 +345,147 @@ const nt = ({ account: e, environment: n, incrementAddress: t, subDomainPrefix:
|
|
|
334
345
|
}
|
|
335
346
|
},
|
|
336
347
|
checkout: {
|
|
337
|
-
simulation: (
|
|
348
|
+
simulation: (d, { salesChannel: g } = i.storage.channel) => {
|
|
338
349
|
const m = new URLSearchParams({
|
|
339
|
-
sc:
|
|
350
|
+
sc: g
|
|
340
351
|
}), y = s({
|
|
341
352
|
"content-type": "application/json",
|
|
342
|
-
"X-FORWARDED-HOST":
|
|
353
|
+
"X-FORWARDED-HOST": u
|
|
343
354
|
});
|
|
344
|
-
return
|
|
355
|
+
return I(
|
|
345
356
|
`${a}/api/checkout/pub/orderForms/simulation?${m.toString()}`,
|
|
346
357
|
{
|
|
347
|
-
...
|
|
358
|
+
...W,
|
|
348
359
|
headers: y,
|
|
349
|
-
body: JSON.stringify(
|
|
360
|
+
body: JSON.stringify(d)
|
|
350
361
|
},
|
|
351
362
|
{ storeCookies: o }
|
|
352
363
|
);
|
|
353
364
|
},
|
|
354
365
|
shippingData: ({
|
|
355
|
-
id:
|
|
356
|
-
index:
|
|
366
|
+
id: d,
|
|
367
|
+
index: g,
|
|
357
368
|
deliveryMode: m,
|
|
358
369
|
selectedAddresses: y
|
|
359
|
-
},
|
|
360
|
-
const
|
|
370
|
+
}, C) => {
|
|
371
|
+
const w = C ? {
|
|
361
372
|
startDateUtc: m?.deliveryWindow?.startDate,
|
|
362
373
|
endDateUtc: m?.deliveryWindow?.endDate
|
|
363
|
-
} : null,
|
|
364
|
-
logisticsInfo: Array.from({ length:
|
|
365
|
-
itemIndex:
|
|
374
|
+
} : null, v = {
|
|
375
|
+
logisticsInfo: Array.from({ length: g }, (f, D) => ({
|
|
376
|
+
itemIndex: D,
|
|
366
377
|
selectedDeliveryChannel: m?.deliveryChannel || null,
|
|
367
378
|
selectedSla: m?.deliveryMethod || null,
|
|
368
|
-
deliveryWindow:
|
|
379
|
+
deliveryWindow: w
|
|
369
380
|
})),
|
|
370
381
|
selectedAddresses: y,
|
|
371
382
|
clearAddressIfPostalCodeNotFound: t
|
|
372
|
-
},
|
|
383
|
+
}, P = s({
|
|
373
384
|
"content-type": "application/json",
|
|
374
|
-
"X-FORWARDED-HOST":
|
|
385
|
+
"X-FORWARDED-HOST": u
|
|
375
386
|
});
|
|
376
|
-
return
|
|
377
|
-
`${a}/api/checkout/pub/orderForm/${
|
|
387
|
+
return I(
|
|
388
|
+
`${a}/api/checkout/pub/orderForm/${d}/attachments/shippingData`,
|
|
378
389
|
{
|
|
379
|
-
...
|
|
380
|
-
headers:
|
|
381
|
-
body: JSON.stringify(
|
|
390
|
+
...W,
|
|
391
|
+
headers: P,
|
|
392
|
+
body: JSON.stringify(v)
|
|
382
393
|
},
|
|
383
394
|
{ storeCookies: o }
|
|
384
395
|
);
|
|
385
396
|
},
|
|
386
397
|
marketingData: ({
|
|
387
|
-
id:
|
|
388
|
-
marketingData:
|
|
398
|
+
id: d,
|
|
399
|
+
marketingData: g
|
|
389
400
|
}) => {
|
|
390
401
|
const m = s({
|
|
391
402
|
"content-type": "application/json",
|
|
392
|
-
"X-FORWARDED-HOST":
|
|
403
|
+
"X-FORWARDED-HOST": u
|
|
393
404
|
});
|
|
394
|
-
return
|
|
395
|
-
`${a}/api/checkout/pub/orderForm/${
|
|
405
|
+
return I(
|
|
406
|
+
`${a}/api/checkout/pub/orderForm/${d}/attachments/marketingData`,
|
|
396
407
|
{
|
|
397
408
|
headers: m,
|
|
398
|
-
body: JSON.stringify(
|
|
409
|
+
body: JSON.stringify(g),
|
|
399
410
|
method: "POST"
|
|
400
411
|
},
|
|
401
412
|
{ storeCookies: o }
|
|
402
413
|
);
|
|
403
414
|
},
|
|
404
415
|
clientPreferencesData: ({
|
|
405
|
-
id:
|
|
406
|
-
clientPreferencesData:
|
|
416
|
+
id: d,
|
|
417
|
+
clientPreferencesData: g
|
|
407
418
|
}) => {
|
|
408
419
|
const m = s({
|
|
409
420
|
"content-type": "application/json",
|
|
410
|
-
"X-FORWARDED-HOST":
|
|
421
|
+
"X-FORWARDED-HOST": u
|
|
411
422
|
});
|
|
412
|
-
return
|
|
413
|
-
`${a}/api/checkout/pub/orderForm/${
|
|
423
|
+
return I(
|
|
424
|
+
`${a}/api/checkout/pub/orderForm/${d}/attachments/clientPreferencesData`,
|
|
414
425
|
{
|
|
415
426
|
headers: m,
|
|
416
|
-
body: JSON.stringify(
|
|
427
|
+
body: JSON.stringify(g),
|
|
417
428
|
method: "POST"
|
|
418
429
|
},
|
|
419
430
|
{ storeCookies: o }
|
|
420
431
|
);
|
|
421
432
|
},
|
|
422
433
|
orderForm: ({
|
|
423
|
-
id:
|
|
424
|
-
refreshOutdatedData:
|
|
434
|
+
id: d,
|
|
435
|
+
refreshOutdatedData: g = !0,
|
|
425
436
|
channel: m = i.storage.channel
|
|
426
437
|
}) => {
|
|
427
|
-
const { salesChannel: y } = m,
|
|
438
|
+
const { salesChannel: y } = m, C = s({
|
|
428
439
|
"content-type": "application/json",
|
|
429
|
-
"X-FORWARDED-HOST":
|
|
430
|
-
}),
|
|
431
|
-
|
|
432
|
-
const
|
|
433
|
-
return
|
|
434
|
-
|
|
440
|
+
"X-FORWARDED-HOST": u
|
|
441
|
+
}), w = new URLSearchParams({ sc: y });
|
|
442
|
+
d && w.set("refreshOutdatedData", g.toString());
|
|
443
|
+
const v = `${a}/api/checkout/pub/orderForm${d ? `/${d}` : ""}?${w.toString()}`;
|
|
444
|
+
return I(
|
|
445
|
+
v,
|
|
435
446
|
{
|
|
436
|
-
...
|
|
437
|
-
headers:
|
|
438
|
-
...
|
|
447
|
+
...W,
|
|
448
|
+
headers: C,
|
|
449
|
+
...d ? {} : { body: "{}" }
|
|
439
450
|
},
|
|
440
451
|
{ storeCookies: o }
|
|
441
452
|
);
|
|
442
453
|
},
|
|
443
|
-
clearOrderFormMessages: ({ id:
|
|
444
|
-
const
|
|
454
|
+
clearOrderFormMessages: ({ id: d }) => {
|
|
455
|
+
const g = s({
|
|
445
456
|
"content-type": "application/json",
|
|
446
|
-
"X-FORWARDED-HOST":
|
|
457
|
+
"X-FORWARDED-HOST": u
|
|
447
458
|
});
|
|
448
|
-
return
|
|
449
|
-
`${a}/api/checkout/pub/orderForm/${
|
|
459
|
+
return I(
|
|
460
|
+
`${a}/api/checkout/pub/orderForm/${d}/messages/clear`,
|
|
450
461
|
{
|
|
451
|
-
...
|
|
452
|
-
headers:
|
|
462
|
+
...W,
|
|
463
|
+
headers: g,
|
|
453
464
|
body: "{}"
|
|
454
465
|
}
|
|
455
466
|
);
|
|
456
467
|
},
|
|
457
468
|
updateOrderFormItems: ({
|
|
458
|
-
id:
|
|
459
|
-
orderItems:
|
|
469
|
+
id: d,
|
|
470
|
+
orderItems: g,
|
|
460
471
|
allowOutdatedData: m = "paymentData",
|
|
461
472
|
salesChannel: y = i.storage.channel.salesChannel,
|
|
462
|
-
shouldSplitItem:
|
|
473
|
+
shouldSplitItem: C = !0
|
|
463
474
|
}) => {
|
|
464
|
-
const
|
|
475
|
+
const w = new URLSearchParams({
|
|
465
476
|
allowOutdatedData: m,
|
|
466
477
|
sc: y
|
|
467
|
-
}),
|
|
478
|
+
}), v = s({
|
|
468
479
|
"content-type": "application/json",
|
|
469
|
-
"X-FORWARDED-HOST":
|
|
480
|
+
"X-FORWARDED-HOST": u
|
|
470
481
|
});
|
|
471
|
-
return
|
|
472
|
-
`${a}/api/checkout/pub/orderForm/${
|
|
482
|
+
return I(
|
|
483
|
+
`${a}/api/checkout/pub/orderForm/${d}/items?${w}`,
|
|
473
484
|
{
|
|
474
|
-
headers:
|
|
485
|
+
headers: v,
|
|
475
486
|
body: JSON.stringify({
|
|
476
|
-
orderItems:
|
|
477
|
-
noSplitItem: !
|
|
487
|
+
orderItems: g,
|
|
488
|
+
noSplitItem: !C
|
|
478
489
|
}),
|
|
479
490
|
method: "PATCH"
|
|
480
491
|
},
|
|
@@ -482,60 +493,60 @@ const nt = ({ account: e, environment: n, incrementAddress: t, subDomainPrefix:
|
|
|
482
493
|
);
|
|
483
494
|
},
|
|
484
495
|
setCustomData: ({
|
|
485
|
-
id:
|
|
486
|
-
appId:
|
|
496
|
+
id: d,
|
|
497
|
+
appId: g,
|
|
487
498
|
key: m,
|
|
488
499
|
value: y
|
|
489
500
|
}) => {
|
|
490
|
-
const
|
|
501
|
+
const C = s({
|
|
491
502
|
"content-type": "application/json",
|
|
492
|
-
"X-FORWARDED-HOST":
|
|
503
|
+
"X-FORWARDED-HOST": u
|
|
493
504
|
});
|
|
494
|
-
return
|
|
495
|
-
`${a}/api/checkout/pub/orderForm/${
|
|
505
|
+
return I(
|
|
506
|
+
`${a}/api/checkout/pub/orderForm/${d}/customData/${g}/${m}`,
|
|
496
507
|
{
|
|
497
|
-
headers:
|
|
508
|
+
headers: C,
|
|
498
509
|
body: JSON.stringify({ value: y }),
|
|
499
510
|
method: "PUT"
|
|
500
511
|
}
|
|
501
512
|
);
|
|
502
513
|
},
|
|
503
514
|
region: async ({
|
|
504
|
-
postalCode:
|
|
505
|
-
geoCoordinates:
|
|
515
|
+
postalCode: d,
|
|
516
|
+
geoCoordinates: g,
|
|
506
517
|
country: m,
|
|
507
518
|
salesChannel: y
|
|
508
519
|
}) => {
|
|
509
|
-
const
|
|
520
|
+
const C = new URLSearchParams({
|
|
510
521
|
country: m,
|
|
511
522
|
sc: y ?? ""
|
|
512
523
|
});
|
|
513
|
-
|
|
524
|
+
d ? C.append("postalCode", d) : C.append(
|
|
514
525
|
"geoCoordinates",
|
|
515
|
-
`${
|
|
526
|
+
`${g?.longitude};${g?.latitude}`
|
|
516
527
|
);
|
|
517
|
-
const
|
|
528
|
+
const w = `${a}/api/checkout/pub/regions/?${C.toString()}`, v = s({
|
|
518
529
|
"content-type": "application/json",
|
|
519
|
-
"X-FORWARDED-HOST":
|
|
530
|
+
"X-FORWARDED-HOST": u
|
|
520
531
|
});
|
|
521
|
-
return
|
|
522
|
-
|
|
532
|
+
return I(
|
|
533
|
+
w,
|
|
523
534
|
{
|
|
524
|
-
headers:
|
|
535
|
+
headers: v
|
|
525
536
|
},
|
|
526
537
|
{ storeCookies: o }
|
|
527
538
|
);
|
|
528
539
|
},
|
|
529
540
|
address: async ({
|
|
530
|
-
postalCode:
|
|
531
|
-
country:
|
|
541
|
+
postalCode: d,
|
|
542
|
+
country: g
|
|
532
543
|
}) => {
|
|
533
544
|
const m = s({
|
|
534
545
|
"content-type": "application/json",
|
|
535
|
-
"X-FORWARDED-HOST":
|
|
546
|
+
"X-FORWARDED-HOST": u
|
|
536
547
|
});
|
|
537
|
-
return
|
|
538
|
-
`${a}/api/checkout/pub/postal-code/${
|
|
548
|
+
return I(
|
|
549
|
+
`${a}/api/checkout/pub/postal-code/${g}/${d}`,
|
|
539
550
|
{
|
|
540
551
|
headers: m
|
|
541
552
|
},
|
|
@@ -543,21 +554,21 @@ const nt = ({ account: e, environment: n, incrementAddress: t, subDomainPrefix:
|
|
|
543
554
|
);
|
|
544
555
|
},
|
|
545
556
|
cancelOrder: ({
|
|
546
|
-
orderId:
|
|
547
|
-
customerEmail:
|
|
557
|
+
orderId: d,
|
|
558
|
+
customerEmail: g,
|
|
548
559
|
reason: m
|
|
549
560
|
}) => {
|
|
550
561
|
const y = s({
|
|
551
562
|
"content-type": "application/json",
|
|
552
|
-
"X-FORWARDED-HOST":
|
|
563
|
+
"X-FORWARDED-HOST": u
|
|
553
564
|
});
|
|
554
|
-
return
|
|
555
|
-
`${a}/api/checkout/pub/orders/${
|
|
565
|
+
return I(
|
|
566
|
+
`${a}/api/checkout/pub/orders/${d}/user-cancel-request`,
|
|
556
567
|
{
|
|
557
568
|
method: "POST",
|
|
558
569
|
headers: y,
|
|
559
570
|
body: JSON.stringify({
|
|
560
|
-
customerEmail:
|
|
571
|
+
customerEmail: g,
|
|
561
572
|
reason: m
|
|
562
573
|
})
|
|
563
574
|
},
|
|
@@ -565,38 +576,38 @@ const nt = ({ account: e, environment: n, incrementAddress: t, subDomainPrefix:
|
|
|
565
576
|
);
|
|
566
577
|
},
|
|
567
578
|
pickupPoints: ({
|
|
568
|
-
geoCoordinates:
|
|
579
|
+
geoCoordinates: d
|
|
569
580
|
}) => {
|
|
570
|
-
if (!
|
|
581
|
+
if (!d)
|
|
571
582
|
throw new Error(
|
|
572
583
|
"Missing required parameter for listing pickup points."
|
|
573
584
|
);
|
|
574
|
-
const
|
|
585
|
+
const g = s({
|
|
575
586
|
"content-type": "application/json",
|
|
576
|
-
"X-FORWARDED-HOST":
|
|
587
|
+
"X-FORWARDED-HOST": u
|
|
577
588
|
});
|
|
578
|
-
return
|
|
589
|
+
return I(
|
|
579
590
|
`${a}/api/logistics-shipping/pickuppoints/_search`,
|
|
580
591
|
{
|
|
581
592
|
method: "POST",
|
|
582
|
-
headers:
|
|
583
|
-
body: JSON.stringify({ coordinate:
|
|
593
|
+
headers: g,
|
|
594
|
+
body: JSON.stringify({ coordinate: d })
|
|
584
595
|
},
|
|
585
596
|
{ storeCookies: o }
|
|
586
597
|
);
|
|
587
598
|
}
|
|
588
599
|
},
|
|
589
|
-
session: (
|
|
590
|
-
const
|
|
591
|
-
|
|
600
|
+
session: (d) => {
|
|
601
|
+
const g = new URLSearchParams(d);
|
|
602
|
+
g.set(
|
|
592
603
|
"items",
|
|
593
|
-
"profile.id,profile.email,profile.firstName,profile.lastName,profile.phone,shopper.firstName,shopper.lastName,shopper.organizationManager,store.channel,store.countryCode,store.cultureInfo,store.currencyCode,store.currencySymbol,authentication.customerId,authentication.storeUserId,authentication.storeUserEmail,authentication.unitId,authentication.unitName,checkout.regionId,public.postalCode"
|
|
604
|
+
"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"
|
|
594
605
|
);
|
|
595
606
|
const m = s({
|
|
596
607
|
"content-type": "application/json"
|
|
597
|
-
}), y =
|
|
598
|
-
return
|
|
599
|
-
`${a}/api/sessions?${
|
|
608
|
+
}), y = J(i?.headers?.cookie ?? "")?.vtex_session;
|
|
609
|
+
return I(
|
|
610
|
+
`${a}/api/sessions?${g.toString()}`,
|
|
600
611
|
{
|
|
601
612
|
method: y ? "PATCH" : "POST",
|
|
602
613
|
headers: m,
|
|
@@ -605,127 +616,127 @@ const nt = ({ account: e, environment: n, incrementAddress: t, subDomainPrefix:
|
|
|
605
616
|
{ storeCookies: o }
|
|
606
617
|
);
|
|
607
618
|
},
|
|
608
|
-
subscribeToNewsletter: (
|
|
619
|
+
subscribeToNewsletter: (d) => I(
|
|
609
620
|
`${a}/api/dataentities/NL/documents/`,
|
|
610
621
|
{
|
|
611
|
-
...
|
|
612
|
-
body: JSON.stringify({ ...
|
|
622
|
+
...W,
|
|
623
|
+
body: JSON.stringify({ ...d, isNewsletterOptIn: !0 }),
|
|
613
624
|
method: "PATCH"
|
|
614
625
|
},
|
|
615
626
|
{ storeCookies: o }
|
|
616
627
|
),
|
|
617
628
|
profile: {
|
|
618
|
-
addresses: async (
|
|
619
|
-
const
|
|
629
|
+
addresses: async (d) => {
|
|
630
|
+
const g = s({
|
|
620
631
|
"content-type": "application/json",
|
|
621
|
-
"X-FORWARDED-HOST":
|
|
632
|
+
"X-FORWARDED-HOST": u
|
|
622
633
|
});
|
|
623
|
-
return
|
|
624
|
-
`${a}/api/profile-system/pvt/profiles/${
|
|
625
|
-
{ headers:
|
|
634
|
+
return I(
|
|
635
|
+
`${a}/api/profile-system/pvt/profiles/${d}/addresses`,
|
|
636
|
+
{ headers: g },
|
|
626
637
|
{ storeCookies: o }
|
|
627
638
|
);
|
|
628
639
|
}
|
|
629
640
|
},
|
|
630
641
|
oms: {
|
|
631
|
-
userOrder: ({ orderId:
|
|
632
|
-
const
|
|
642
|
+
userOrder: ({ orderId: d }) => {
|
|
643
|
+
const g = s({
|
|
633
644
|
"content-type": "application/json",
|
|
634
|
-
"X-FORWARDED-HOST":
|
|
645
|
+
"X-FORWARDED-HOST": u
|
|
635
646
|
});
|
|
636
|
-
return
|
|
637
|
-
`${a}/api/oms/user/orders/${
|
|
647
|
+
return I(
|
|
648
|
+
`${a}/api/oms/user/orders/${d}`,
|
|
638
649
|
{
|
|
639
650
|
method: "GET",
|
|
640
|
-
headers:
|
|
651
|
+
headers: g
|
|
641
652
|
},
|
|
642
653
|
{ storeCookies: o }
|
|
643
654
|
);
|
|
644
655
|
},
|
|
645
656
|
listUserOrders: ({
|
|
646
|
-
page:
|
|
647
|
-
status:
|
|
657
|
+
page: d,
|
|
658
|
+
status: g,
|
|
648
659
|
dateInitial: m,
|
|
649
660
|
dateFinal: y,
|
|
650
|
-
text:
|
|
651
|
-
clientEmail:
|
|
652
|
-
perPage:
|
|
653
|
-
pendingMyApproval:
|
|
661
|
+
text: C,
|
|
662
|
+
clientEmail: w,
|
|
663
|
+
perPage: v,
|
|
664
|
+
pendingMyApproval: P
|
|
654
665
|
}) => {
|
|
655
|
-
const
|
|
666
|
+
const f = new URLSearchParams();
|
|
656
667
|
if (m) {
|
|
657
|
-
const
|
|
668
|
+
const A = new Date(m).setHours(
|
|
658
669
|
0,
|
|
659
670
|
0,
|
|
660
671
|
0,
|
|
661
672
|
0
|
|
662
673
|
);
|
|
663
|
-
m = new Date(
|
|
674
|
+
m = new Date(A).toISOString();
|
|
664
675
|
}
|
|
665
676
|
if (y) {
|
|
666
|
-
const
|
|
677
|
+
const A = new Date(y).setHours(
|
|
667
678
|
23,
|
|
668
679
|
59,
|
|
669
680
|
59,
|
|
670
681
|
999
|
|
671
682
|
);
|
|
672
|
-
y = new Date(
|
|
683
|
+
y = new Date(A).toISOString();
|
|
673
684
|
}
|
|
674
|
-
|
|
685
|
+
C && f.append("text", C), g && g.length > 0 && f.append("status", g.filter(Boolean).join(",")), m && y ? f.append(
|
|
675
686
|
"creation_date",
|
|
676
687
|
`creationDate:[${m} TO ${y}]`
|
|
677
|
-
) : m ?
|
|
678
|
-
const
|
|
688
|
+
) : m ? f.append("creation_date", `creationDate:[${m} TO *]`) : y && f.append("creation_date", `creationDate:[* TO ${y}]`), w && f.append("clientEmail", w), d && f.append("page", d.toString()), v && f.append("per_page", v.toString()), P && f.append("my_pending_approvals", String(!0));
|
|
689
|
+
const D = s({
|
|
679
690
|
"content-type": "application/json",
|
|
680
|
-
"X-FORWARDED-HOST":
|
|
691
|
+
"X-FORWARDED-HOST": u
|
|
681
692
|
});
|
|
682
|
-
return
|
|
683
|
-
`${a}/api/oms/user/orders?${
|
|
693
|
+
return I(
|
|
694
|
+
`${a}/api/oms/user/orders?${f.toString()}`,
|
|
684
695
|
{
|
|
685
696
|
method: "GET",
|
|
686
|
-
headers:
|
|
697
|
+
headers: D
|
|
687
698
|
},
|
|
688
699
|
{ storeCookies: o }
|
|
689
700
|
);
|
|
690
701
|
},
|
|
691
702
|
getCommercialAuthorizationsByOrderId: ({
|
|
692
|
-
orderId:
|
|
703
|
+
orderId: d
|
|
693
704
|
}) => {
|
|
694
|
-
const
|
|
705
|
+
const g = s({
|
|
695
706
|
"content-type": "application/json",
|
|
696
|
-
"X-FORWARDED-HOST":
|
|
707
|
+
"X-FORWARDED-HOST": u
|
|
697
708
|
});
|
|
698
|
-
return
|
|
699
|
-
`${a}/${e}/commercial-authorizations/order/${
|
|
709
|
+
return I(
|
|
710
|
+
`${a}/${e}/commercial-authorizations/order/${d}`,
|
|
700
711
|
{
|
|
701
712
|
method: "GET",
|
|
702
|
-
headers:
|
|
713
|
+
headers: g
|
|
703
714
|
},
|
|
704
715
|
{ storeCookies: o }
|
|
705
716
|
);
|
|
706
717
|
},
|
|
707
718
|
processOrderAuthorization: async ({
|
|
708
|
-
orderAuthorizationId:
|
|
709
|
-
dimensionId:
|
|
719
|
+
orderAuthorizationId: d,
|
|
720
|
+
dimensionId: g,
|
|
710
721
|
ruleId: m,
|
|
711
722
|
approved: y
|
|
712
723
|
}) => {
|
|
713
|
-
const
|
|
724
|
+
const C = s({
|
|
714
725
|
"content-type": "application/json",
|
|
715
|
-
"X-FORWARDED-HOST":
|
|
716
|
-
}),
|
|
726
|
+
"X-FORWARDED-HOST": u
|
|
727
|
+
}), P = {
|
|
717
728
|
params: {
|
|
718
729
|
ruleId: m,
|
|
719
|
-
dimensionId:
|
|
730
|
+
dimensionId: g,
|
|
720
731
|
score: y ? 100 : 0
|
|
721
732
|
}
|
|
722
733
|
};
|
|
723
|
-
return
|
|
724
|
-
`${a}/${e}/commercial-authorizations/${
|
|
734
|
+
return I(
|
|
735
|
+
`${a}/${e}/commercial-authorizations/${d}/callback`,
|
|
725
736
|
{
|
|
726
737
|
method: "POST",
|
|
727
|
-
headers:
|
|
728
|
-
body: JSON.stringify(
|
|
738
|
+
headers: C,
|
|
739
|
+
body: JSON.stringify(P)
|
|
729
740
|
},
|
|
730
741
|
{ storeCookies: o }
|
|
731
742
|
);
|
|
@@ -733,49 +744,49 @@ const nt = ({ account: e, environment: n, incrementAddress: t, subDomainPrefix:
|
|
|
733
744
|
},
|
|
734
745
|
units: {
|
|
735
746
|
getUnitByUserId: ({
|
|
736
|
-
userId:
|
|
747
|
+
userId: d
|
|
737
748
|
}) => {
|
|
738
|
-
const
|
|
749
|
+
const g = s({
|
|
739
750
|
"content-type": "application/json",
|
|
740
|
-
"X-FORWARDED-HOST":
|
|
751
|
+
"X-FORWARDED-HOST": u
|
|
741
752
|
});
|
|
742
|
-
return
|
|
743
|
-
`${a}/api/units/v1/${
|
|
753
|
+
return I(
|
|
754
|
+
`${a}/api/units/v1/${d}/unit`,
|
|
744
755
|
{
|
|
745
756
|
method: "GET",
|
|
746
|
-
headers:
|
|
757
|
+
headers: g
|
|
747
758
|
},
|
|
748
759
|
{}
|
|
749
760
|
);
|
|
750
761
|
},
|
|
751
762
|
getOrgUnitById: ({
|
|
752
|
-
orgUnitId:
|
|
763
|
+
orgUnitId: d
|
|
753
764
|
}) => {
|
|
754
|
-
const
|
|
765
|
+
const g = s({
|
|
755
766
|
"content-type": "application/json",
|
|
756
|
-
"X-FORWARDED-HOST":
|
|
767
|
+
"X-FORWARDED-HOST": u
|
|
757
768
|
});
|
|
758
|
-
return
|
|
759
|
-
`${a}/api/units/v1/${
|
|
769
|
+
return I(
|
|
770
|
+
`${a}/api/units/v1/${d}`,
|
|
760
771
|
{
|
|
761
772
|
method: "GET",
|
|
762
|
-
headers:
|
|
773
|
+
headers: g
|
|
763
774
|
},
|
|
764
775
|
{}
|
|
765
776
|
);
|
|
766
777
|
},
|
|
767
778
|
getScopesByOrgUnit: ({
|
|
768
|
-
orgUnitId:
|
|
779
|
+
orgUnitId: d
|
|
769
780
|
}) => {
|
|
770
|
-
const
|
|
781
|
+
const g = s({
|
|
771
782
|
"content-type": "application/json",
|
|
772
|
-
"X-FORWARDED-HOST":
|
|
783
|
+
"X-FORWARDED-HOST": u
|
|
773
784
|
});
|
|
774
|
-
return
|
|
775
|
-
`${a}/api/units/v1/${
|
|
785
|
+
return I(
|
|
786
|
+
`${a}/api/units/v1/${d}/scopes`,
|
|
776
787
|
{
|
|
777
788
|
method: "GET",
|
|
778
|
-
headers:
|
|
789
|
+
headers: g
|
|
779
790
|
},
|
|
780
791
|
{}
|
|
781
792
|
);
|
|
@@ -783,49 +794,49 @@ const nt = ({ account: e, environment: n, incrementAddress: t, subDomainPrefix:
|
|
|
783
794
|
},
|
|
784
795
|
licenseManager: {
|
|
785
796
|
getUserById: ({
|
|
786
|
-
userId:
|
|
797
|
+
userId: d
|
|
787
798
|
}) => {
|
|
788
|
-
const
|
|
799
|
+
const g = s({
|
|
789
800
|
"content-type": "application/json",
|
|
790
|
-
"X-FORWARDED-HOST":
|
|
801
|
+
"X-FORWARDED-HOST": u
|
|
791
802
|
});
|
|
792
|
-
return
|
|
793
|
-
`${a}/api/license-manager/users/${
|
|
803
|
+
return I(
|
|
804
|
+
`${a}/api/license-manager/users/${d}`,
|
|
794
805
|
{
|
|
795
806
|
method: "GET",
|
|
796
|
-
headers:
|
|
807
|
+
headers: g
|
|
797
808
|
},
|
|
798
809
|
{}
|
|
799
810
|
);
|
|
800
811
|
},
|
|
801
812
|
getUserByEmail: ({
|
|
802
|
-
email:
|
|
813
|
+
email: d
|
|
803
814
|
}) => {
|
|
804
|
-
const
|
|
815
|
+
const g = s({
|
|
805
816
|
"content-type": "application/json",
|
|
806
|
-
"X-FORWARDED-HOST":
|
|
817
|
+
"X-FORWARDED-HOST": u
|
|
807
818
|
});
|
|
808
|
-
return
|
|
809
|
-
`${a}/api/license-manager/pvt/users/${
|
|
819
|
+
return I(
|
|
820
|
+
`${a}/api/license-manager/pvt/users/${d}`,
|
|
810
821
|
{
|
|
811
822
|
method: "GET",
|
|
812
|
-
headers:
|
|
823
|
+
headers: g
|
|
813
824
|
},
|
|
814
825
|
{}
|
|
815
826
|
);
|
|
816
827
|
},
|
|
817
828
|
getUserRoles: ({
|
|
818
|
-
userId:
|
|
829
|
+
userId: d
|
|
819
830
|
}) => {
|
|
820
|
-
const
|
|
831
|
+
const g = s({
|
|
821
832
|
"content-type": "application/json",
|
|
822
|
-
"X-FORWARDED-HOST":
|
|
833
|
+
"X-FORWARDED-HOST": u
|
|
823
834
|
});
|
|
824
|
-
return
|
|
825
|
-
`${a}/api/license-manager/storefront/users/${
|
|
835
|
+
return I(
|
|
836
|
+
`${a}/api/license-manager/storefront/users/${d}/roles`,
|
|
826
837
|
{
|
|
827
838
|
method: "GET",
|
|
828
|
-
headers:
|
|
839
|
+
headers: g
|
|
829
840
|
},
|
|
830
841
|
{}
|
|
831
842
|
);
|
|
@@ -833,53 +844,52 @@ const nt = ({ account: e, environment: n, incrementAddress: t, subDomainPrefix:
|
|
|
833
844
|
},
|
|
834
845
|
masterData: {
|
|
835
846
|
getContractById: ({
|
|
836
|
-
contractId:
|
|
847
|
+
contractId: d
|
|
837
848
|
}) => {
|
|
838
|
-
if (!
|
|
839
|
-
throw new
|
|
840
|
-
const
|
|
849
|
+
if (!d)
|
|
850
|
+
throw new T("Missing contractId to fetch CL fields.");
|
|
851
|
+
const g = b({
|
|
841
852
|
Accept: "application/json",
|
|
842
|
-
"content-type": "application/json"
|
|
843
|
-
"X-FORWARDED-HOST": p
|
|
853
|
+
"content-type": "application/json"
|
|
844
854
|
});
|
|
845
|
-
return
|
|
846
|
-
`${a}/api/dataentities/CL/documents/${
|
|
855
|
+
return I(
|
|
856
|
+
`${a}/api/dataentities/CL/documents/${d}?_fields=_all`,
|
|
847
857
|
{
|
|
848
858
|
method: "GET",
|
|
849
|
-
headers:
|
|
859
|
+
headers: g
|
|
850
860
|
},
|
|
851
861
|
{}
|
|
852
862
|
);
|
|
853
863
|
},
|
|
854
864
|
getShopperById: ({
|
|
855
|
-
userId:
|
|
865
|
+
userId: d
|
|
856
866
|
}) => {
|
|
857
|
-
if (!
|
|
858
|
-
throw new
|
|
859
|
-
const
|
|
867
|
+
if (!d)
|
|
868
|
+
throw new T("Missing userId to fetch shopper name.");
|
|
869
|
+
const g = c({
|
|
860
870
|
Accept: "application/json",
|
|
861
871
|
"content-type": "application/json",
|
|
862
|
-
"X-FORWARDED-HOST":
|
|
863
|
-
}), m =
|
|
864
|
-
return
|
|
865
|
-
`${a}/api/dataentities/shopper/search?_where=(userId=${m} OR userId=${
|
|
872
|
+
"X-FORWARDED-HOST": u
|
|
873
|
+
}), m = d.replace(/-/g, "");
|
|
874
|
+
return I(
|
|
875
|
+
`${a}/api/dataentities/shopper/search?_where=(userId=${m} OR userId=${d})&_fields=_all&_schema=v1`,
|
|
866
876
|
{
|
|
867
877
|
method: "GET",
|
|
868
|
-
headers:
|
|
878
|
+
headers: g
|
|
869
879
|
},
|
|
870
880
|
{}
|
|
871
881
|
);
|
|
872
882
|
}
|
|
873
883
|
},
|
|
874
884
|
quotes: {
|
|
875
|
-
listUserQuotes: (
|
|
876
|
-
|
|
877
|
-
const
|
|
885
|
+
listUserQuotes: (d) => {
|
|
886
|
+
nt(d);
|
|
887
|
+
const g = tt(d), m = s({
|
|
878
888
|
"content-type": "application/json",
|
|
879
|
-
"X-FORWARDED-HOST":
|
|
889
|
+
"X-FORWARDED-HOST": u
|
|
880
890
|
});
|
|
881
|
-
return
|
|
882
|
-
`${a}/api/quoting/quotes?${
|
|
891
|
+
return I(
|
|
892
|
+
`${a}/api/quoting/quotes?${g.toString()}`,
|
|
883
893
|
{
|
|
884
894
|
method: "GET",
|
|
885
895
|
headers: m
|
|
@@ -890,15 +900,15 @@ const nt = ({ account: e, environment: n, incrementAddress: t, subDomainPrefix:
|
|
|
890
900
|
},
|
|
891
901
|
vtexid: {
|
|
892
902
|
validate: () => {
|
|
893
|
-
const
|
|
903
|
+
const d = s({
|
|
894
904
|
"content-type": "application/json",
|
|
895
|
-
"X-FORWARDED-HOST":
|
|
896
|
-
}),
|
|
897
|
-
return
|
|
905
|
+
"X-FORWARDED-HOST": u
|
|
906
|
+
}), g = z(le(i) ?? "", e);
|
|
907
|
+
return I(
|
|
898
908
|
`${a}/api/vtexid/credential/validate`,
|
|
899
909
|
{
|
|
900
|
-
headers:
|
|
901
|
-
body: JSON.stringify({ token:
|
|
910
|
+
headers: d,
|
|
911
|
+
body: JSON.stringify({ token: g }),
|
|
902
912
|
method: "POST"
|
|
903
913
|
},
|
|
904
914
|
{ storeCookies: o }
|
|
@@ -907,131 +917,159 @@ const nt = ({ account: e, environment: n, incrementAddress: t, subDomainPrefix:
|
|
|
907
917
|
},
|
|
908
918
|
orderEntry: {
|
|
909
919
|
uploadFile: ({
|
|
910
|
-
fileBuffer:
|
|
911
|
-
fileName:
|
|
920
|
+
fileBuffer: d,
|
|
921
|
+
fileName: g,
|
|
912
922
|
mimeType: m
|
|
913
923
|
}) => {
|
|
914
924
|
const y = s({
|
|
915
925
|
"content-type": "application/json",
|
|
916
|
-
"X-FORWARDED-HOST":
|
|
917
|
-
}),
|
|
918
|
-
`,
|
|
919
|
-
`--${
|
|
920
|
-
`Content-Disposition: form-data; name="file"; filename="${
|
|
921
|
-
`Content-Type: ${
|
|
926
|
+
"X-FORWARDED-HOST": u
|
|
927
|
+
}), C = `----FastStoreUploadBoundary${Date.now()}`, w = `\r
|
|
928
|
+
`, P = /^[a-zA-Z0-9][a-zA-Z0-9!#$&\-.^_]*\/[a-zA-Z0-9][a-zA-Z0-9!#$&\-.^_+]*$/.test(m) ? m : "application/octet-stream", f = g.replaceAll(/[\r\n"]/g, "_"), D = [
|
|
929
|
+
`--${C}`,
|
|
930
|
+
`Content-Disposition: form-data; name="file"; filename="${f}"`,
|
|
931
|
+
`Content-Type: ${P}`,
|
|
922
932
|
"",
|
|
923
933
|
""
|
|
924
|
-
].join(
|
|
925
|
-
|
|
934
|
+
].join(w), A = `${w}--${C}--${w}`, U = Buffer.from(D), O = Buffer.from(A), E = new Uint8Array(
|
|
935
|
+
U.byteLength + d.byteLength + O.byteLength
|
|
926
936
|
);
|
|
927
|
-
let
|
|
928
|
-
return
|
|
937
|
+
let _ = 0;
|
|
938
|
+
return E.set(U, _), _ += U.byteLength, E.set(d, _), _ += d.byteLength, E.set(O, _), I(
|
|
929
939
|
`${a}/api/order-entry/upload?an=${e}`,
|
|
930
940
|
{
|
|
931
941
|
method: "POST",
|
|
932
942
|
headers: {
|
|
933
943
|
...y,
|
|
934
|
-
"content-type": `multipart/form-data; boundary=${
|
|
944
|
+
"content-type": `multipart/form-data; boundary=${C}`
|
|
935
945
|
},
|
|
936
|
-
body:
|
|
946
|
+
body: E.buffer
|
|
937
947
|
},
|
|
938
948
|
{}
|
|
939
949
|
);
|
|
940
950
|
},
|
|
941
951
|
startOperation: ({
|
|
942
|
-
objectKey:
|
|
943
|
-
orderFormId:
|
|
952
|
+
objectKey: d,
|
|
953
|
+
orderFormId: g,
|
|
944
954
|
sessionToken: m
|
|
945
955
|
}) => {
|
|
946
956
|
const y = s({
|
|
947
957
|
"content-type": "application/json",
|
|
948
|
-
"X-FORWARDED-HOST":
|
|
949
|
-
}),
|
|
950
|
-
objectKey:
|
|
951
|
-
orderFormId:
|
|
958
|
+
"X-FORWARDED-HOST": u
|
|
959
|
+
}), C = JSON.stringify({
|
|
960
|
+
objectKey: d,
|
|
961
|
+
orderFormId: g,
|
|
952
962
|
operation: "CreateCart",
|
|
953
963
|
...m ? { sessionToken: m } : {}
|
|
954
964
|
});
|
|
955
|
-
return
|
|
965
|
+
return I(
|
|
956
966
|
`${a}/api/order-entry/operation?an=${e}`,
|
|
957
967
|
{
|
|
958
968
|
method: "POST",
|
|
959
969
|
headers: y,
|
|
960
|
-
body:
|
|
970
|
+
body: C
|
|
961
971
|
},
|
|
962
972
|
{}
|
|
963
973
|
);
|
|
964
974
|
},
|
|
965
975
|
getOperation: ({
|
|
966
|
-
operationId:
|
|
976
|
+
operationId: d
|
|
967
977
|
}) => {
|
|
968
|
-
const
|
|
978
|
+
const g = s({
|
|
969
979
|
"content-type": "application/json",
|
|
970
|
-
"X-FORWARDED-HOST":
|
|
980
|
+
"X-FORWARDED-HOST": u
|
|
971
981
|
});
|
|
972
|
-
return
|
|
973
|
-
`${a}/api/order-entry/operation/${
|
|
982
|
+
return I(
|
|
983
|
+
`${a}/api/order-entry/operation/${d}?an=${e}`,
|
|
974
984
|
{
|
|
975
985
|
method: "GET",
|
|
976
|
-
headers:
|
|
986
|
+
headers: g
|
|
977
987
|
},
|
|
978
988
|
{}
|
|
979
989
|
);
|
|
980
990
|
},
|
|
981
991
|
createOrderForm: () => {
|
|
982
|
-
const
|
|
992
|
+
const d = s({
|
|
983
993
|
"content-type": "application/json",
|
|
984
|
-
"X-FORWARDED-HOST":
|
|
994
|
+
"X-FORWARDED-HOST": u
|
|
985
995
|
});
|
|
986
|
-
return
|
|
996
|
+
return I(
|
|
987
997
|
`${a}/api/checkout/pub/orderForm?sc=${i.storage.channel.salesChannel}`,
|
|
988
998
|
{
|
|
989
999
|
method: "POST",
|
|
990
|
-
headers:
|
|
1000
|
+
headers: d,
|
|
991
1001
|
body: "{}"
|
|
992
1002
|
},
|
|
993
1003
|
{}
|
|
994
1004
|
);
|
|
995
1005
|
},
|
|
996
1006
|
getOrderFormItems: ({
|
|
997
|
-
orderFormId:
|
|
1007
|
+
orderFormId: d
|
|
998
1008
|
}) => {
|
|
999
|
-
const
|
|
1009
|
+
const g = s({
|
|
1000
1010
|
"content-type": "application/json",
|
|
1001
|
-
"X-FORWARDED-HOST":
|
|
1011
|
+
"X-FORWARDED-HOST": u
|
|
1002
1012
|
});
|
|
1003
|
-
return
|
|
1004
|
-
`${a}/api/checkout/pub/orderForm/${
|
|
1013
|
+
return I(
|
|
1014
|
+
`${a}/api/checkout/pub/orderForm/${d}`,
|
|
1005
1015
|
{
|
|
1006
1016
|
method: "GET",
|
|
1007
|
-
headers:
|
|
1017
|
+
headers: g
|
|
1008
1018
|
},
|
|
1009
1019
|
{}
|
|
1010
1020
|
);
|
|
1011
1021
|
}
|
|
1022
|
+
},
|
|
1023
|
+
// Anonymous personalization / recommendations served by the VTEX
|
|
1024
|
+
// Recommendations BFF. The BFF replies with `vtex-rec-*` Set-Cookie headers
|
|
1025
|
+
// (forwarded to the browser via `ctx.storage.cookies`) and returns products
|
|
1026
|
+
// already hydrated in the Intelligent Search shape.
|
|
1027
|
+
recommendation: {
|
|
1028
|
+
recommendations: ({
|
|
1029
|
+
campaignVrn: d,
|
|
1030
|
+
userId: g,
|
|
1031
|
+
products: m = [],
|
|
1032
|
+
salesChannel: y,
|
|
1033
|
+
locale: C
|
|
1034
|
+
}) => {
|
|
1035
|
+
const w = new URLSearchParams({ an: e, campaignVrn: d });
|
|
1036
|
+
return g && w.append("userId", g), m.length > 0 && w.append("products", m.join(",")), y && w.append("salesChannel", y), C && w.append("locale", C), I(
|
|
1037
|
+
`${h}/recommendations?${w.toString()}`,
|
|
1038
|
+
{ headers: S },
|
|
1039
|
+
{ storeCookies: o }
|
|
1040
|
+
);
|
|
1041
|
+
},
|
|
1042
|
+
startRecommendationSession: () => {
|
|
1043
|
+
const d = new URLSearchParams({ an: e });
|
|
1044
|
+
return I(
|
|
1045
|
+
`${h}/users/start-session?${d.toString()}`,
|
|
1046
|
+
{ method: "POST", headers: S },
|
|
1047
|
+
{ storeCookies: o }
|
|
1048
|
+
);
|
|
1049
|
+
}
|
|
1012
1050
|
}
|
|
1013
1051
|
};
|
|
1014
|
-
},
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
]),
|
|
1052
|
+
}, de = "fuzzy", ue = "operator", pe = "pickupPoint", we = "shipping", De = "delivery-options", it = "in-stock", at = "trade-policy", ot = "region-id", st = /* @__PURE__ */ new Set([
|
|
1053
|
+
at,
|
|
1054
|
+
ot,
|
|
1055
|
+
de,
|
|
1056
|
+
ue,
|
|
1057
|
+
pe
|
|
1058
|
+
]), ct = /* @__PURE__ */ new Set([
|
|
1021
1059
|
"zip-code",
|
|
1022
1060
|
"pickupPoint",
|
|
1023
1061
|
"country",
|
|
1024
1062
|
"coordinates",
|
|
1025
1063
|
"deliveryZonesHash",
|
|
1026
1064
|
"pickupPointsHash"
|
|
1027
|
-
]),
|
|
1065
|
+
]), lt = /* @__PURE__ */ new Set(["productClusterIds"]), Ae = (e) => encodeURI(decodeURI(e)), dt = (e) => encodeURIComponent(
|
|
1028
1066
|
decodeURIComponent(e).normalize("NFD").replaceAll(/[\u0300-\u036f]/g, "")
|
|
1029
|
-
),
|
|
1067
|
+
), ut = /^pickup-in-point-(.+)$/;
|
|
1030
1068
|
function Qe(e) {
|
|
1031
1069
|
if (!e)
|
|
1032
1070
|
return {};
|
|
1033
1071
|
try {
|
|
1034
|
-
const t =
|
|
1072
|
+
const t = J(e).vtex_segment;
|
|
1035
1073
|
if (!t)
|
|
1036
1074
|
return {};
|
|
1037
1075
|
const r = Buffer.from(t, "base64").toString("utf-8");
|
|
@@ -1040,18 +1078,18 @@ function Qe(e) {
|
|
|
1040
1078
|
return {};
|
|
1041
1079
|
}
|
|
1042
1080
|
}
|
|
1043
|
-
function
|
|
1081
|
+
function pt(e) {
|
|
1044
1082
|
const n = {}, t = {}, r = [];
|
|
1045
1083
|
for (const i of e.split(";")) {
|
|
1046
1084
|
const a = i.indexOf("=");
|
|
1047
1085
|
if (a < 0) continue;
|
|
1048
1086
|
const o = i.slice(0, a), s = i.slice(a + 1);
|
|
1049
|
-
!o || !s || (
|
|
1087
|
+
!o || !s || (ct.has(o) ? n[o] = s : lt.has(o) ? t[o] = s : r.push({ key: o, value: s }));
|
|
1050
1088
|
}
|
|
1051
1089
|
return { shipping: n, queryParams: t, extraFacets: r };
|
|
1052
1090
|
}
|
|
1053
|
-
function
|
|
1054
|
-
const n = typeof e.facets == "string" ? e.facets : "", { shipping: t, queryParams: r, extraFacets: i } =
|
|
1091
|
+
function gt(e) {
|
|
1092
|
+
const n = typeof e.facets == "string" ? e.facets : "", { shipping: t, queryParams: r, extraFacets: i } = pt(n);
|
|
1055
1093
|
return {
|
|
1056
1094
|
segmentParams: {
|
|
1057
1095
|
sc: e.channel,
|
|
@@ -1095,9 +1133,9 @@ function Ke(e, n) {
|
|
|
1095
1133
|
i != null && i !== "" && e.append(r, String(i));
|
|
1096
1134
|
}
|
|
1097
1135
|
function Ze(e) {
|
|
1098
|
-
return
|
|
1136
|
+
return ut.exec(e)?.[1];
|
|
1099
1137
|
}
|
|
1100
|
-
function
|
|
1138
|
+
function mt(e) {
|
|
1101
1139
|
const n = e.find((r) => r.key === "shipping"), t = n ? Ze(n.value) : void 0;
|
|
1102
1140
|
if (t !== void 0)
|
|
1103
1141
|
try {
|
|
@@ -1106,8 +1144,8 @@ function pt(e) {
|
|
|
1106
1144
|
return t;
|
|
1107
1145
|
}
|
|
1108
1146
|
}
|
|
1109
|
-
function
|
|
1110
|
-
const t =
|
|
1147
|
+
function ht(e, n) {
|
|
1148
|
+
const t = mt(
|
|
1111
1149
|
n
|
|
1112
1150
|
);
|
|
1113
1151
|
return t === void 0 ? e : {
|
|
@@ -1115,25 +1153,25 @@ function gt(e, n) {
|
|
|
1115
1153
|
pickupPoint: t
|
|
1116
1154
|
};
|
|
1117
1155
|
}
|
|
1118
|
-
function
|
|
1156
|
+
function ft(e) {
|
|
1119
1157
|
return e.map((n) => n.key !== "shipping" || Ze(n.value) === void 0 ? n : { ...n, value: "pickup-in-point" });
|
|
1120
1158
|
}
|
|
1121
|
-
function
|
|
1159
|
+
function St(e, n) {
|
|
1122
1160
|
let t = [...e];
|
|
1123
1161
|
const r = t.some((i) => i.key === "shipping");
|
|
1124
1162
|
for (const i of n)
|
|
1125
1163
|
(!r || i.key !== "shipping") && t.push(i);
|
|
1126
|
-
return t.some((i) => i.key === "shipping" && i.value === "ignore") && (t = t.filter((i) => i.key !== "shipping")),
|
|
1164
|
+
return t.some((i) => i.key === "shipping" && i.value === "ignore") && (t = t.filter((i) => i.key !== "shipping")), ft(t);
|
|
1127
1165
|
}
|
|
1128
|
-
function
|
|
1166
|
+
function yt(e) {
|
|
1129
1167
|
return e.reduce((n, t) => {
|
|
1130
1168
|
let { key: r, value: i } = t;
|
|
1131
|
-
return r === "priceRange" && (r = "price", i = i.replace(" TO ", ":")), r === "ft" ? n : `${n}${
|
|
1169
|
+
return r === "priceRange" && (r = "price", i = i.replace(" TO ", ":")), r === "ft" ? n : `${n}${Ae(r)}/${dt(Ae(i)).replaceAll(/ |%20/g, "-")}/`;
|
|
1132
1170
|
}, "");
|
|
1133
1171
|
}
|
|
1134
|
-
const
|
|
1135
|
-
function
|
|
1136
|
-
const { segmentParams: t, extraFacets: r } =
|
|
1172
|
+
const It = (e) => e.key === "fuzzy" && (e.value === "0" || e.value === "1" || e.value === "auto"), vt = (e) => e.key === "operator" && (e.value === "and" || e.value === "or");
|
|
1173
|
+
function Ot(e, n) {
|
|
1174
|
+
const { segmentParams: t, extraFacets: r } = gt(e ?? {}), i = n?.salesChannel ?? t.sc, a = n?.regionId ?? t.regionId, o = n?.locale ?? t.locale ?? "";
|
|
1137
1175
|
return {
|
|
1138
1176
|
segmentParams: {
|
|
1139
1177
|
...t,
|
|
@@ -1144,21 +1182,21 @@ function It(e, n) {
|
|
|
1144
1182
|
extraFacets: r
|
|
1145
1183
|
};
|
|
1146
1184
|
}
|
|
1147
|
-
function
|
|
1148
|
-
const t = e.filter(({ key: c }) => !
|
|
1149
|
-
({ key: c, value:
|
|
1185
|
+
function Ct(e, n) {
|
|
1186
|
+
const t = e.filter(({ key: c }) => !st.has(c)), r = e.find(
|
|
1187
|
+
({ key: c, value: l }) => c === we && l !== "all-delivery-methods"
|
|
1150
1188
|
) ?? null, i = e.find(
|
|
1151
|
-
({ key: c, value:
|
|
1189
|
+
({ key: c, value: l }) => c === De && l !== "all-delivery-options"
|
|
1152
1190
|
) ?? null, a = [...t], o = a.some(
|
|
1153
|
-
({ key: c }) => c ===
|
|
1191
|
+
({ key: c }) => c === we
|
|
1154
1192
|
), s = a.some(
|
|
1155
1193
|
({ key: c }) => c === De
|
|
1156
1194
|
);
|
|
1157
|
-
return r !== null && !o && a.push(r), i !== null && !s && a.push(i),
|
|
1195
|
+
return r !== null && !o && a.push(r), i !== null && !s && a.push(i), St(a, n);
|
|
1158
1196
|
}
|
|
1159
|
-
function
|
|
1160
|
-
const t = e.find(({ key: a }) => a ===
|
|
1161
|
-
t &&
|
|
1197
|
+
function bt(e, n) {
|
|
1198
|
+
const t = e.find(({ key: a }) => a === de) ?? null, r = e.find(({ key: a }) => a === ue) ?? null, i = e.find(({ key: a }) => a === pe) ?? null;
|
|
1199
|
+
t && It(t) && n.append(de, t.value), r && vt(r) && n.append(ue, r.value), i && n.append(pe, i.value);
|
|
1162
1200
|
}
|
|
1163
1201
|
function Pe(e, n, t, r) {
|
|
1164
1202
|
const {
|
|
@@ -1167,38 +1205,38 @@ function Pe(e, n, t, r) {
|
|
|
1167
1205
|
count: o,
|
|
1168
1206
|
sort: s,
|
|
1169
1207
|
selectedFacets: c = [],
|
|
1170
|
-
showInvisibleItems:
|
|
1171
|
-
sponsoredCount:
|
|
1172
|
-
hideUnavailableItems:
|
|
1173
|
-
allowRedirect:
|
|
1174
|
-
} = e,
|
|
1208
|
+
showInvisibleItems: l,
|
|
1209
|
+
sponsoredCount: p,
|
|
1210
|
+
hideUnavailableItems: u,
|
|
1211
|
+
allowRedirect: h = !1
|
|
1212
|
+
} = e, S = new URLSearchParams();
|
|
1175
1213
|
if (r.includePagination && a !== void 0 && o !== void 0) {
|
|
1176
|
-
const
|
|
1177
|
-
|
|
1214
|
+
const g = a * o, m = o === 0 ? g : g + o - 1;
|
|
1215
|
+
S.append("from", g.toString()), S.append("to", m.toString());
|
|
1178
1216
|
}
|
|
1179
|
-
i &&
|
|
1180
|
-
const
|
|
1217
|
+
i && S.append("query", i), r.includeSort && s && S.append("sort", s);
|
|
1218
|
+
const b = ht(
|
|
1181
1219
|
t.segmentParams,
|
|
1182
1220
|
c
|
|
1183
1221
|
);
|
|
1184
|
-
if (Ke(
|
|
1185
|
-
const
|
|
1186
|
-
|
|
1222
|
+
if (Ke(S, b ?? t.segmentParams), bt(c, S), l && S.append("show-invisible-items", "true"), n?.hideUnavailableItems !== void 0) {
|
|
1223
|
+
const g = c.find(({ key: y }) => y === it), m = g ? g.value : u?.toString() ?? n.hideUnavailableItems.toString();
|
|
1224
|
+
S.append("hideUnavailableItems", m);
|
|
1187
1225
|
}
|
|
1188
|
-
n?.simulationBehavior !== void 0 &&
|
|
1189
|
-
const
|
|
1190
|
-
|
|
1226
|
+
n?.simulationBehavior !== void 0 && S.append("simulationBehavior", n.simulationBehavior.toString()), n?.showSponsored !== void 0 && S.append("showSponsored", n.showSponsored.toString()), p !== void 0 && S.append("sponsoredCount", p.toString()), h !== void 0 && S.append("allowRedirect", h.toString());
|
|
1227
|
+
const d = yt(
|
|
1228
|
+
Ct(c, t.extraFacets)
|
|
1191
1229
|
);
|
|
1192
|
-
return { params:
|
|
1230
|
+
return { params: S, path: d };
|
|
1193
1231
|
}
|
|
1194
|
-
function
|
|
1232
|
+
function wt(e, n) {
|
|
1195
1233
|
const { field: t, value: r, hideUnavailableItems: i, showInvisibleItems: a } = e, o = new URLSearchParams({
|
|
1196
1234
|
field: t ?? "",
|
|
1197
1235
|
value: r ?? ""
|
|
1198
1236
|
});
|
|
1199
1237
|
return Ke(o, n), i && o.append("hideUnavailableItems", "true"), a && o.append("show-invisible-items", "true"), o;
|
|
1200
1238
|
}
|
|
1201
|
-
function
|
|
1239
|
+
function G(e, n) {
|
|
1202
1240
|
return {
|
|
1203
1241
|
path: e,
|
|
1204
1242
|
params: n,
|
|
@@ -1208,8 +1246,8 @@ function W(e, n) {
|
|
|
1208
1246
|
}
|
|
1209
1247
|
};
|
|
1210
1248
|
}
|
|
1211
|
-
function
|
|
1212
|
-
const { endpoint: n, segment: t, defaults: r, args: i = {} } = e, a =
|
|
1249
|
+
function H(e) {
|
|
1250
|
+
const { endpoint: n, segment: t, defaults: r, args: i = {} } = e, a = Ot(t, r);
|
|
1213
1251
|
switch (n) {
|
|
1214
1252
|
case "product-search":
|
|
1215
1253
|
case "facets": {
|
|
@@ -1219,7 +1257,7 @@ function G(e) {
|
|
|
1219
1257
|
a,
|
|
1220
1258
|
{ includePagination: !0, includeSort: !0 }
|
|
1221
1259
|
);
|
|
1222
|
-
return
|
|
1260
|
+
return G(s, o);
|
|
1223
1261
|
}
|
|
1224
1262
|
case "catalog-count": {
|
|
1225
1263
|
const { params: o, path: s } = Pe(
|
|
@@ -1228,24 +1266,24 @@ function G(e) {
|
|
|
1228
1266
|
a,
|
|
1229
1267
|
{ includePagination: !1, includeSort: !1 }
|
|
1230
1268
|
);
|
|
1231
|
-
return
|
|
1269
|
+
return G(s, o);
|
|
1232
1270
|
}
|
|
1233
1271
|
case "products": {
|
|
1234
|
-
const o =
|
|
1235
|
-
return
|
|
1272
|
+
const o = wt(i, a.segmentParams);
|
|
1273
|
+
return G("", o);
|
|
1236
1274
|
}
|
|
1237
1275
|
case "search-suggestions": {
|
|
1238
1276
|
const o = new URLSearchParams({
|
|
1239
1277
|
query: i.query?.toString() ?? "",
|
|
1240
1278
|
locale: r?.locale ?? a.segmentParams.locale ?? ""
|
|
1241
1279
|
});
|
|
1242
|
-
return
|
|
1280
|
+
return G("", o);
|
|
1243
1281
|
}
|
|
1244
1282
|
case "top-searches": {
|
|
1245
1283
|
const o = new URLSearchParams({
|
|
1246
1284
|
locale: r?.locale ?? a.segmentParams.locale ?? ""
|
|
1247
1285
|
});
|
|
1248
|
-
return
|
|
1286
|
+
return G("", o);
|
|
1249
1287
|
}
|
|
1250
1288
|
default: {
|
|
1251
1289
|
const o = n;
|
|
@@ -1253,16 +1291,16 @@ function G(e) {
|
|
|
1253
1291
|
}
|
|
1254
1292
|
}
|
|
1255
1293
|
}
|
|
1256
|
-
const
|
|
1257
|
-
function
|
|
1294
|
+
const Dt = 10;
|
|
1295
|
+
function At(e) {
|
|
1258
1296
|
const { regionId: n, seller: t } = e.storage.channel;
|
|
1259
1297
|
return (t ? Buffer.from(`SW#${t}`).toString("base64") : void 0) ?? (n || void 0);
|
|
1260
1298
|
}
|
|
1261
|
-
function
|
|
1299
|
+
function Pt(e) {
|
|
1262
1300
|
const n = Qe(e.headers?.cookie);
|
|
1263
1301
|
return e.storage.locale || n.cultureInfo || "";
|
|
1264
1302
|
}
|
|
1265
|
-
const
|
|
1303
|
+
const Ut = ({
|
|
1266
1304
|
account: e,
|
|
1267
1305
|
environment: n,
|
|
1268
1306
|
hideUnavailableItems: t,
|
|
@@ -1270,69 +1308,69 @@ const Pt = ({
|
|
|
1270
1308
|
showSponsored: i,
|
|
1271
1309
|
subDomainPrefix: a
|
|
1272
1310
|
}, o) => {
|
|
1273
|
-
const s = `https://${e}.${n}.com.br`, c = Je(o),
|
|
1311
|
+
const s = `https://${e}.${n}.com.br`, c = Je(o), l = Qe(o.headers?.cookie), p = () => ({
|
|
1274
1312
|
salesChannel: o.storage.channel.salesChannel,
|
|
1275
|
-
regionId:
|
|
1276
|
-
locale:
|
|
1313
|
+
regionId: At(o),
|
|
1314
|
+
locale: Pt(o),
|
|
1277
1315
|
hideUnavailableItems: t,
|
|
1278
1316
|
simulationBehavior: r,
|
|
1279
1317
|
showSponsored: i
|
|
1280
|
-
}),
|
|
1318
|
+
}), u = new Headers(o.headers).get("x-forwarded-host") ?? o.headers?.host ?? "", h = a && a.map((f) => f + ".").find((f) => u.includes(f)) || "", S = u.replace(h, ""), b = c({
|
|
1281
1319
|
"content-type": "application/json",
|
|
1282
|
-
"X-FORWARDED-HOST":
|
|
1283
|
-
}),
|
|
1284
|
-
const
|
|
1285
|
-
endpoint:
|
|
1286
|
-
segment:
|
|
1287
|
-
defaults:
|
|
1288
|
-
args:
|
|
1320
|
+
"X-FORWARDED-HOST": S
|
|
1321
|
+
}), d = ({ type: f, ...D }) => {
|
|
1322
|
+
const A = f === "facets" ? "facets" : "product-search", U = H({
|
|
1323
|
+
endpoint: A,
|
|
1324
|
+
segment: l,
|
|
1325
|
+
defaults: p(),
|
|
1326
|
+
args: D
|
|
1289
1327
|
});
|
|
1290
|
-
return
|
|
1291
|
-
`${s}/api/intelligent-search/v1/${
|
|
1292
|
-
{ headers:
|
|
1328
|
+
return I(
|
|
1329
|
+
`${s}/api/intelligent-search/v1/${A}/${U.path}?${U.params.toString()}`,
|
|
1330
|
+
{ headers: b }
|
|
1293
1331
|
);
|
|
1294
|
-
},
|
|
1295
|
-
field:
|
|
1296
|
-
value:
|
|
1297
|
-
hideUnavailableItems:
|
|
1298
|
-
showInvisibleItems:
|
|
1332
|
+
}, g = (f) => d({ ...f, type: "product_search" }), m = ({
|
|
1333
|
+
field: f,
|
|
1334
|
+
value: D,
|
|
1335
|
+
hideUnavailableItems: A,
|
|
1336
|
+
showInvisibleItems: U
|
|
1299
1337
|
}) => {
|
|
1300
|
-
const
|
|
1338
|
+
const O = H({
|
|
1301
1339
|
endpoint: "products",
|
|
1302
|
-
segment:
|
|
1303
|
-
defaults:
|
|
1340
|
+
segment: l,
|
|
1341
|
+
defaults: p(),
|
|
1304
1342
|
args: {
|
|
1305
|
-
field:
|
|
1306
|
-
value:
|
|
1307
|
-
hideUnavailableItems:
|
|
1308
|
-
showInvisibleItems:
|
|
1343
|
+
field: f,
|
|
1344
|
+
value: D,
|
|
1345
|
+
hideUnavailableItems: A,
|
|
1346
|
+
showInvisibleItems: U
|
|
1309
1347
|
}
|
|
1310
1348
|
});
|
|
1311
|
-
return
|
|
1312
|
-
`${s}/api/intelligent-search/v1/products?${
|
|
1313
|
-
{ headers:
|
|
1349
|
+
return I(
|
|
1350
|
+
`${s}/api/intelligent-search/v1/products?${O.params.toString()}`,
|
|
1351
|
+
{ headers: b }
|
|
1314
1352
|
);
|
|
1315
1353
|
};
|
|
1316
1354
|
return {
|
|
1317
|
-
facets: (
|
|
1318
|
-
products:
|
|
1319
|
-
fetchProduct:
|
|
1355
|
+
facets: (f) => d({ ...f, type: "facets" }),
|
|
1356
|
+
products: g,
|
|
1357
|
+
fetchProduct: m,
|
|
1320
1358
|
productsByIdentifier: async ({
|
|
1321
|
-
field:
|
|
1322
|
-
values:
|
|
1323
|
-
showInvisibleItems:
|
|
1324
|
-
hideUnavailableItems:
|
|
1359
|
+
field: f,
|
|
1360
|
+
values: D,
|
|
1361
|
+
showInvisibleItems: A,
|
|
1362
|
+
hideUnavailableItems: U
|
|
1325
1363
|
}) => {
|
|
1326
|
-
const
|
|
1364
|
+
const O = Ie(Dt);
|
|
1327
1365
|
return (await Promise.all(
|
|
1328
|
-
|
|
1329
|
-
(
|
|
1366
|
+
D.map(
|
|
1367
|
+
(_) => O(async () => {
|
|
1330
1368
|
try {
|
|
1331
|
-
return await
|
|
1332
|
-
field:
|
|
1333
|
-
value:
|
|
1334
|
-
hideUnavailableItems:
|
|
1335
|
-
showInvisibleItems:
|
|
1369
|
+
return await m({
|
|
1370
|
+
field: f,
|
|
1371
|
+
value: _,
|
|
1372
|
+
hideUnavailableItems: U,
|
|
1373
|
+
showInvisibleItems: A
|
|
1336
1374
|
});
|
|
1337
1375
|
} catch {
|
|
1338
1376
|
return null;
|
|
@@ -1340,64 +1378,64 @@ const Pt = ({
|
|
|
1340
1378
|
})
|
|
1341
1379
|
)
|
|
1342
1380
|
)).filter(
|
|
1343
|
-
(
|
|
1381
|
+
(_) => _ !== null
|
|
1344
1382
|
);
|
|
1345
1383
|
},
|
|
1346
|
-
suggestedTerms: (
|
|
1347
|
-
const
|
|
1384
|
+
suggestedTerms: (f) => {
|
|
1385
|
+
const D = H({
|
|
1348
1386
|
endpoint: "search-suggestions",
|
|
1349
|
-
segment:
|
|
1350
|
-
defaults:
|
|
1351
|
-
args: { query:
|
|
1387
|
+
segment: l,
|
|
1388
|
+
defaults: p(),
|
|
1389
|
+
args: { query: f.query }
|
|
1352
1390
|
});
|
|
1353
|
-
return
|
|
1354
|
-
`${s}/api/intelligent-search/v1/search-suggestions?${
|
|
1355
|
-
{ headers:
|
|
1391
|
+
return I(
|
|
1392
|
+
`${s}/api/intelligent-search/v1/search-suggestions?${D.params.toString()}`,
|
|
1393
|
+
{ headers: b }
|
|
1356
1394
|
);
|
|
1357
1395
|
},
|
|
1358
1396
|
topSearches: () => {
|
|
1359
|
-
const
|
|
1397
|
+
const f = H({
|
|
1360
1398
|
endpoint: "top-searches",
|
|
1361
|
-
segment:
|
|
1362
|
-
defaults:
|
|
1399
|
+
segment: l,
|
|
1400
|
+
defaults: p()
|
|
1363
1401
|
});
|
|
1364
|
-
return
|
|
1365
|
-
`${s}/api/intelligent-search/v1/top-searches?${
|
|
1366
|
-
{ headers:
|
|
1402
|
+
return I(
|
|
1403
|
+
`${s}/api/intelligent-search/v1/top-searches?${f.params.toString()}`,
|
|
1404
|
+
{ headers: b }
|
|
1367
1405
|
);
|
|
1368
1406
|
},
|
|
1369
|
-
productCount: (
|
|
1370
|
-
const
|
|
1407
|
+
productCount: (f) => {
|
|
1408
|
+
const D = H({
|
|
1371
1409
|
endpoint: "catalog-count",
|
|
1372
|
-
segment:
|
|
1373
|
-
defaults:
|
|
1374
|
-
args:
|
|
1410
|
+
segment: l,
|
|
1411
|
+
defaults: p(),
|
|
1412
|
+
args: f
|
|
1375
1413
|
});
|
|
1376
|
-
return
|
|
1377
|
-
`${s}/api/intelligent-search/v1/catalog-count/${
|
|
1378
|
-
{ headers:
|
|
1414
|
+
return I(
|
|
1415
|
+
`${s}/api/intelligent-search/v1/catalog-count/${D.path}?${D.params.toString()}`,
|
|
1416
|
+
{ headers: b }
|
|
1379
1417
|
);
|
|
1380
1418
|
}
|
|
1381
1419
|
};
|
|
1382
|
-
},
|
|
1383
|
-
const t =
|
|
1420
|
+
}, Et = (e, n) => {
|
|
1421
|
+
const t = Ut(e, n), r = rt(e, n);
|
|
1384
1422
|
return {
|
|
1385
1423
|
search: t,
|
|
1386
1424
|
commerce: r
|
|
1387
1425
|
};
|
|
1388
|
-
},
|
|
1426
|
+
}, _t = 20, Tt = /* @__PURE__ */ new Set([
|
|
1389
1427
|
"brand",
|
|
1390
1428
|
"category",
|
|
1391
1429
|
"department",
|
|
1392
1430
|
"subcategory",
|
|
1393
1431
|
"collection",
|
|
1394
1432
|
"cluster"
|
|
1395
|
-
]),
|
|
1396
|
-
const t =
|
|
1433
|
+
]), x = (e) => typeof e.pageType == "string" && Tt.has(e.pageType.toLowerCase()), Rt = (e, n) => {
|
|
1434
|
+
const t = Ie(_t), r = async (i) => Promise.all(
|
|
1397
1435
|
i.map(
|
|
1398
1436
|
(a) => t(async () => {
|
|
1399
1437
|
const o = await n.commerce.catalog.portal.pagetype(a);
|
|
1400
|
-
if (
|
|
1438
|
+
if (x(o))
|
|
1401
1439
|
return o;
|
|
1402
1440
|
throw new L(
|
|
1403
1441
|
`Catalog returned ${o.pageType} for slug: ${a}. This usually happens when there is more than one category with the same name in the same category tree level.`
|
|
@@ -1405,51 +1443,51 @@ const Pt = ({
|
|
|
1405
1443
|
})
|
|
1406
1444
|
)
|
|
1407
1445
|
);
|
|
1408
|
-
return new
|
|
1446
|
+
return new ie(r, {
|
|
1409
1447
|
// DataLoader is being used to cache requests, not to batch them
|
|
1410
1448
|
batch: !1
|
|
1411
1449
|
});
|
|
1412
|
-
},
|
|
1450
|
+
}, kt = (e, n) => {
|
|
1413
1451
|
const t = async (r) => Promise.all(r.map((i) => n.commerce.catalog.salesChannel(i)));
|
|
1414
|
-
return new
|
|
1415
|
-
},
|
|
1416
|
-
const t =
|
|
1417
|
-
const o = a.reduce((
|
|
1452
|
+
return new ie(t);
|
|
1453
|
+
}, Ft = 1, Nt = (e, n) => {
|
|
1454
|
+
const t = Ie(Ft), r = async (a) => {
|
|
1455
|
+
const o = a.reduce((u, { items: h }) => [...u, h], []), s = [...o.flat()], c = await n.commerce.checkout.simulation({
|
|
1418
1456
|
country: a[0].country,
|
|
1419
1457
|
postalCode: a[0].postalCode,
|
|
1420
1458
|
items: s
|
|
1421
|
-
}),
|
|
1422
|
-
(
|
|
1423
|
-
const
|
|
1424
|
-
return typeof
|
|
1459
|
+
}), l = c.items.reduce(
|
|
1460
|
+
(u, h) => {
|
|
1461
|
+
const S = h.requestIndex;
|
|
1462
|
+
return typeof S == "number" && S < u.length && (u[S] = h), u;
|
|
1425
1463
|
},
|
|
1426
1464
|
Array(s.length).fill(null)
|
|
1427
|
-
),
|
|
1428
|
-
(
|
|
1465
|
+
), p = o.reduce(
|
|
1466
|
+
(u, h) => [...u, h.length + u[u.length - 1]],
|
|
1429
1467
|
[0]
|
|
1430
1468
|
);
|
|
1431
|
-
return o.map((
|
|
1469
|
+
return o.map((u, h) => ({
|
|
1432
1470
|
...c,
|
|
1433
|
-
items:
|
|
1471
|
+
items: l.slice(p[h], p[h + 1]).filter((S) => !!S)
|
|
1434
1472
|
}));
|
|
1435
1473
|
}, i = async (a) => t(r, a);
|
|
1436
|
-
return new
|
|
1474
|
+
return new ie(i, {
|
|
1437
1475
|
maxBatchSize: 50
|
|
1438
1476
|
});
|
|
1439
|
-
},
|
|
1440
|
-
function
|
|
1477
|
+
}, Bt = (e, n) => Un(e, n);
|
|
1478
|
+
function Lt(e) {
|
|
1441
1479
|
return {
|
|
1442
1480
|
...e,
|
|
1443
|
-
description: e.description ?
|
|
1481
|
+
description: e.description ? Bt(e.description) : e.description
|
|
1444
1482
|
};
|
|
1445
1483
|
}
|
|
1446
|
-
const
|
|
1484
|
+
const N = (e, n) => ({
|
|
1447
1485
|
...e,
|
|
1448
|
-
isVariantOf:
|
|
1449
|
-
}),
|
|
1486
|
+
isVariantOf: Lt(n)
|
|
1487
|
+
}), Mt = ({ flags: e }, n) => {
|
|
1450
1488
|
const t = async (r) => {
|
|
1451
|
-
const i = r.map((
|
|
1452
|
-
(
|
|
1489
|
+
const i = r.map((p) => p.split("-")[0]), a = r.some(
|
|
1490
|
+
(p) => p.split("-")[1] === "invisibleItems"
|
|
1453
1491
|
), s = (await n.search.productsByIdentifier({
|
|
1454
1492
|
field: "sku",
|
|
1455
1493
|
values: i,
|
|
@@ -1458,44 +1496,44 @@ const B = (e, n) => ({
|
|
|
1458
1496
|
hideUnavailableItems: !1
|
|
1459
1497
|
}
|
|
1460
1498
|
})).reduce(
|
|
1461
|
-
(
|
|
1462
|
-
for (const
|
|
1463
|
-
|
|
1464
|
-
return
|
|
1499
|
+
(p, u) => {
|
|
1500
|
+
for (const h of u.items)
|
|
1501
|
+
p[h.itemId] = N(h, u);
|
|
1502
|
+
return p;
|
|
1465
1503
|
},
|
|
1466
1504
|
{}
|
|
1467
|
-
), c = i.map((
|
|
1468
|
-
if (
|
|
1505
|
+
), c = i.map((p) => s[p]), l = i.filter((p) => !s[p]);
|
|
1506
|
+
if (l.length > 0)
|
|
1469
1507
|
throw new L(
|
|
1470
|
-
`Search API did not found the following skus: ${
|
|
1508
|
+
`Search API did not found the following skus: ${l.join(",")}`
|
|
1471
1509
|
);
|
|
1472
1510
|
return c;
|
|
1473
1511
|
};
|
|
1474
|
-
return new
|
|
1512
|
+
return new ie(t, {
|
|
1475
1513
|
maxBatchSize: 99
|
|
1476
1514
|
// Max allowed batch size of Search API
|
|
1477
1515
|
});
|
|
1478
|
-
},
|
|
1479
|
-
const t =
|
|
1516
|
+
}, $t = (e, { clients: n }) => {
|
|
1517
|
+
const t = Mt(e, n), r = Nt(e, n), i = Rt(e, n), a = kt(e, n);
|
|
1480
1518
|
return {
|
|
1481
1519
|
skuLoader: t,
|
|
1482
1520
|
simulationLoader: r,
|
|
1483
1521
|
collectionLoader: i,
|
|
1484
1522
|
salesChannelLoader: a
|
|
1485
1523
|
};
|
|
1486
|
-
}, M = (e) => e.AvailableQuantity > 0,
|
|
1524
|
+
}, M = (e) => e.AvailableQuantity > 0, V = (e) => e.spotPrice ?? 0, zt = (e) => e.Price ?? 0, Ue = (e) => e ? "https://schema.org/InStock" : "https://schema.org/OutOfStock", en = (e, n) => M(e) && !M(n) ? -1 : !M(e) && M(n) ? 1 : V(e) - V(n), xt = (e) => e === "available", $ = (e, n = 0, t = 1) => {
|
|
1487
1525
|
const r = n / t;
|
|
1488
1526
|
return Math.round((e + r) * 100) / 100;
|
|
1489
|
-
},
|
|
1490
|
-
const t = e.filter(M), r = t[t.length - 1], i = r ?
|
|
1527
|
+
}, Vt = (e, n = { includeTaxes: !1 }) => {
|
|
1528
|
+
const t = e.filter(M), r = t[t.length - 1], i = r ? V(r) : 0;
|
|
1491
1529
|
return n.includeTaxes ? $(i, r?.Tax, r?.product?.unitMultiplier) : i;
|
|
1492
|
-
},
|
|
1493
|
-
const [t] = e.filter(M), r = t ?
|
|
1530
|
+
}, Ee = (e, n = { includeTaxes: !1 }) => {
|
|
1531
|
+
const [t] = e.filter(M), r = t ? V(t) : 0;
|
|
1494
1532
|
return n.includeTaxes ? $(r, t?.Tax, t?.product?.unitMultiplier) : r;
|
|
1495
|
-
},
|
|
1496
|
-
highPrice: (e) =>
|
|
1497
|
-
lowPrice: (e) =>
|
|
1498
|
-
lowPriceWithTaxes: (e) =>
|
|
1533
|
+
}, qt = {
|
|
1534
|
+
highPrice: (e) => Vt(e),
|
|
1535
|
+
lowPrice: (e) => Ee(e),
|
|
1536
|
+
lowPriceWithTaxes: (e) => Ee(e, { includeTaxes: !0 }),
|
|
1499
1537
|
offerCount: (e) => e.length,
|
|
1500
1538
|
priceCurrency: async (e, n, t) => {
|
|
1501
1539
|
const {
|
|
@@ -1505,35 +1543,35 @@ const B = (e, n) => ({
|
|
|
1505
1543
|
return (await r.load(i.salesChannel)).CurrencyCode ?? "";
|
|
1506
1544
|
},
|
|
1507
1545
|
offers: (e) => e
|
|
1508
|
-
},
|
|
1546
|
+
}, jt = {
|
|
1509
1547
|
ratingValue: () => 5,
|
|
1510
1548
|
reviewCount: () => 0
|
|
1511
|
-
},
|
|
1549
|
+
}, _e = "ÁÄÂÀÃÅČÇĆĎÉĚËÈÊẼĔȆÍÌÎÏŇÑÓÖÒÔÕØŘŔŠŤÚŮÜÙÛÝŸŽáäâàãåčçćďéěëèêẽĕȇíìîïňñóöòôõøðřŕšťúůüùûýÿžþÞĐđ߯a", Wt = "AAAAAACCCDEEEEEEEEIIIINNOOOOOORRSTUUUUUYYZaaaaaacccdeeeeeeeeiiiinnooooooorrstuuuuuyyzbBDdBAa", Gt = (e) => {
|
|
1512
1550
|
let n = e.slice(0);
|
|
1513
|
-
for (let t = 0; t <
|
|
1514
|
-
n = n.replace(new RegExp(
|
|
1551
|
+
for (let t = 0; t < _e.length; t++)
|
|
1552
|
+
n = n.replace(new RegExp(_e.charAt(t), "g"), Wt.charAt(t));
|
|
1515
1553
|
return n;
|
|
1516
|
-
},
|
|
1554
|
+
}, Ht = (e) => e.replace(/[·/_,:]/, "-");
|
|
1517
1555
|
function nn(e) {
|
|
1518
1556
|
const t = e.replace(/,/g, "").replace(/[*+~.()'"!:@&\[\]`/ %$#?{}><=_^]/g, "-");
|
|
1519
|
-
return
|
|
1557
|
+
return Ht(Gt(t)).toLowerCase();
|
|
1520
1558
|
}
|
|
1521
|
-
const
|
|
1559
|
+
const ee = (e) => e.type === "brand" || x(e) && e.pageType.toLowerCase() === "brand", ge = (e) => x(e) && e.pageType.toLowerCase() === "collection", oe = (e) => ee(e) || ge(e) ? nn(e.name) : x(e) ? new URL(`https://${e.url}`).pathname.slice(1).toLowerCase() : new URL(e.url).pathname.slice(1).toLowerCase(), tn = {
|
|
1522
1560
|
id: ({ id: e }) => e.toString(),
|
|
1523
|
-
slug: (e) =>
|
|
1524
|
-
seo: (e) =>
|
|
1561
|
+
slug: (e) => oe(e),
|
|
1562
|
+
seo: (e) => ee(e) || x(e) ? {
|
|
1525
1563
|
title: e.title ?? e.name,
|
|
1526
1564
|
description: e.metaTagDescription
|
|
1527
1565
|
} : {
|
|
1528
1566
|
title: e.Title,
|
|
1529
1567
|
description: e.MetaTagDescription
|
|
1530
1568
|
},
|
|
1531
|
-
type: (e) =>
|
|
1569
|
+
type: (e) => ee(e) ? "Brand" : x(e) ? e.pageType : e.level === 0 ? "Department" : "Category",
|
|
1532
1570
|
meta: (e) => {
|
|
1533
|
-
const n =
|
|
1534
|
-
return
|
|
1571
|
+
const n = oe(e);
|
|
1572
|
+
return ee(e) ? {
|
|
1535
1573
|
selectedFacets: [{ key: "brand", value: n }]
|
|
1536
|
-
} :
|
|
1574
|
+
} : ge(e) ? {
|
|
1537
1575
|
selectedFacets: [{ key: "productclusterids", value: e.id }]
|
|
1538
1576
|
} : {
|
|
1539
1577
|
selectedFacets: n.split("/").map((t, r) => ({
|
|
@@ -1545,21 +1583,21 @@ const Q = (e) => e.type === "brand" || z(e) && e.pageType.toLowerCase() === "bra
|
|
|
1545
1583
|
breadcrumbList: async (e, n, t) => {
|
|
1546
1584
|
const {
|
|
1547
1585
|
loaders: { collectionLoader: r }
|
|
1548
|
-
} = t, a =
|
|
1549
|
-
(c,
|
|
1586
|
+
} = t, a = oe(e).split("/").filter((c) => !!c), o = a.map(
|
|
1587
|
+
(c, l) => a.slice(0, l + 1).join("/")
|
|
1550
1588
|
), s = await Promise.all(
|
|
1551
1589
|
o.map(async (c) => {
|
|
1552
|
-
const
|
|
1553
|
-
return { slug: c, ...
|
|
1590
|
+
const l = await r.load(c);
|
|
1591
|
+
return { slug: c, ...l };
|
|
1554
1592
|
})
|
|
1555
1593
|
);
|
|
1556
1594
|
return {
|
|
1557
|
-
itemListElement: s.map((c,
|
|
1558
|
-
item:
|
|
1595
|
+
itemListElement: s.map((c, l) => ({
|
|
1596
|
+
item: ge(c) ? `/${c.slug}` : new URL(
|
|
1559
1597
|
`https://${c.url}`
|
|
1560
1598
|
).pathname.toLowerCase(),
|
|
1561
1599
|
name: c.name,
|
|
1562
|
-
position:
|
|
1600
|
+
position: l + 1
|
|
1563
1601
|
})),
|
|
1564
1602
|
numberOfItems: s.length
|
|
1565
1603
|
};
|
|
@@ -1587,58 +1625,58 @@ const Q = (e) => e.type === "brand" || z(e) && e.pageType.toLowerCase() === "bra
|
|
|
1587
1625
|
default:
|
|
1588
1626
|
return { key: e, value: n };
|
|
1589
1627
|
}
|
|
1590
|
-
},
|
|
1628
|
+
}, Re = (e) => {
|
|
1591
1629
|
const n = e.split(":").map(Number);
|
|
1592
1630
|
return n.length !== 2 || Number.isNaN(n[0]) || Number.isNaN(n[1]) ? null : n;
|
|
1593
|
-
},
|
|
1631
|
+
}, Xt = (e) => typeof rn[e] == "string", Yt = (e) => {
|
|
1594
1632
|
const n = e?.filter(
|
|
1595
|
-
(t) =>
|
|
1633
|
+
(t) => Xt(t.key)
|
|
1596
1634
|
);
|
|
1597
1635
|
if (Array.isArray(n) && n.length > 1)
|
|
1598
|
-
throw new
|
|
1636
|
+
throw new T(
|
|
1599
1637
|
`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(",")}`
|
|
1600
1638
|
);
|
|
1601
1639
|
return n?.[0] ?? null;
|
|
1602
|
-
},
|
|
1640
|
+
}, Jt = (e) => e?.find((n) => n.key === "slug")?.value ?? null, Qt = (e) => e?.find((n) => n.key === "id")?.value ?? null, ke = (e) => e?.find((n) => n.key === "locale")?.value ?? null, Fe = (e) => e?.find((n) => n.key === "channel")?.value ?? null, me = (e, n) => {
|
|
1603
1641
|
let t = 0;
|
|
1604
1642
|
for (let r = 1; r < e.length; r++)
|
|
1605
1643
|
n(e[t], e[r]) > 0 && (t = r);
|
|
1606
1644
|
return e[t];
|
|
1607
|
-
},
|
|
1645
|
+
}, Kt = {
|
|
1608
1646
|
__resolveType: ({ type: e, values: n }) => e !== "TEXT" && e !== "DELIVERY" ? "StoreFacetRange" : !n || n.length === 0 ? "StoreFacetBoolean" : n.every((t) => t.range) ? "StoreFacetRange" : "StoreFacetBoolean"
|
|
1609
|
-
},
|
|
1647
|
+
}, Zt = {
|
|
1610
1648
|
key: ({ key: e }) => e,
|
|
1611
1649
|
label: ({ name: e }) => e,
|
|
1612
1650
|
values: ({ values: e }) => e.sort((n, t) => n.name.localeCompare(t.name))
|
|
1613
|
-
},
|
|
1651
|
+
}, er = {
|
|
1614
1652
|
key: ({ key: e }) => e,
|
|
1615
1653
|
label: ({ name: e }) => e,
|
|
1616
1654
|
min: ({ values: e, key: n }, t, { storage: { searchArgs: r } }) => {
|
|
1617
|
-
const i =
|
|
1655
|
+
const i = Re(
|
|
1618
1656
|
r?.selectedFacets?.find((s) => s.key === n)?.value ?? ""
|
|
1619
|
-
), o =
|
|
1657
|
+
), o = me(e, (s, c) => s.range.from - c.range.from)?.range?.from ?? 0;
|
|
1620
1658
|
return {
|
|
1621
1659
|
selected: i?.[0] ?? o,
|
|
1622
1660
|
absolute: o
|
|
1623
1661
|
};
|
|
1624
1662
|
},
|
|
1625
1663
|
max: ({ values: e, key: n }, t, { storage: { searchArgs: r } }) => {
|
|
1626
|
-
const i =
|
|
1664
|
+
const i = Re(
|
|
1627
1665
|
r?.selectedFacets?.find((s) => s.key === n)?.value ?? ""
|
|
1628
|
-
), o =
|
|
1666
|
+
), o = me(e, (s, c) => c.range.to - s.range.to)?.range?.to ?? 0;
|
|
1629
1667
|
return {
|
|
1630
1668
|
selected: i?.[1] ?? o,
|
|
1631
1669
|
absolute: o
|
|
1632
1670
|
};
|
|
1633
1671
|
}
|
|
1634
|
-
},
|
|
1672
|
+
}, nr = {
|
|
1635
1673
|
value: ({ value: e }) => e,
|
|
1636
1674
|
label: ({ name: e }) => e || "unknown",
|
|
1637
1675
|
selected: ({ selected: e }) => e,
|
|
1638
1676
|
quantity: ({ quantity: e }) => e
|
|
1639
|
-
},
|
|
1677
|
+
}, tr = async (e, { data: n }, { clients: { commerce: t } }) => {
|
|
1640
1678
|
if (!n?.orderId)
|
|
1641
|
-
throw new
|
|
1679
|
+
throw new T("Missing orderId");
|
|
1642
1680
|
return { data: (await t.checkout.cancelOrder(n))?.data };
|
|
1643
1681
|
};
|
|
1644
1682
|
function an(e) {
|
|
@@ -1659,47 +1697,53 @@ function an(e) {
|
|
|
1659
1697
|
}
|
|
1660
1698
|
return null;
|
|
1661
1699
|
}
|
|
1662
|
-
function
|
|
1700
|
+
function rr(e) {
|
|
1663
1701
|
if (!e || e.status !== "pending") return !1;
|
|
1664
1702
|
const n = e.dimensionStatus.filter((t) => t.status === "pending").flatMap((t) => t.ruleCollection).filter((t) => t.status === "pending");
|
|
1665
1703
|
return n.length === 0 ? !1 : n.every((t) => !t.isUserNextAuthorizer);
|
|
1666
1704
|
}
|
|
1667
|
-
const
|
|
1705
|
+
const ir = async (e, { data: n }, { clients: { commerce: t } }) => {
|
|
1668
1706
|
const r = await t.oms.processOrderAuthorization(n), i = an(r);
|
|
1669
1707
|
return {
|
|
1670
|
-
isPendingForOtherAuthorizer: !i &&
|
|
1708
|
+
isPendingForOtherAuthorizer: !i && rr(r),
|
|
1671
1709
|
ruleForAuthorization: i
|
|
1672
1710
|
};
|
|
1673
|
-
},
|
|
1711
|
+
}, ar = async (e, { data: n }, { clients: { commerce: t } }) => {
|
|
1674
1712
|
if (!n?.objectKey)
|
|
1675
|
-
throw new
|
|
1713
|
+
throw new T("Missing objectKey");
|
|
1676
1714
|
const r = n.orderFormId || (await t.orderEntry.createOrderForm()).orderFormId;
|
|
1677
1715
|
return t.orderEntry.startOperation({
|
|
1678
1716
|
objectKey: n.objectKey,
|
|
1679
1717
|
orderFormId: r,
|
|
1680
1718
|
sessionToken: n.sessionToken ?? void 0
|
|
1681
1719
|
});
|
|
1682
|
-
},
|
|
1720
|
+
}, or = async (e, n, t) => {
|
|
1721
|
+
if (!(await t.clients.commerce.recommendation.startRecommendationSession())?.recommendationsUserId)
|
|
1722
|
+
throw new Error(
|
|
1723
|
+
"Failed to start recommendation session: no session data returned"
|
|
1724
|
+
);
|
|
1725
|
+
return !0;
|
|
1726
|
+
}, sr = async (e, { data: n }, { clients: { commerce: t } }) => ({ id: (await t.subscribeToNewsletter(n))?.Id }), cr = async (e, { data: n }, { clients: { commerce: t } }) => {
|
|
1683
1727
|
const { fileContent: r, fileName: i, mimeType: a } = n;
|
|
1684
1728
|
if (!r || !i || !a)
|
|
1685
|
-
throw new
|
|
1729
|
+
throw new T(
|
|
1686
1730
|
"Missing required fields: fileContent, fileName, mimeType"
|
|
1687
1731
|
);
|
|
1688
1732
|
const o = r.replaceAll(/\s/g, ""), s = 5 * 1024 * 1024;
|
|
1689
1733
|
if (Math.floor(o.length * 3 / 4) > s)
|
|
1690
|
-
throw new
|
|
1734
|
+
throw new T("File exceeds maximum allowed size of 5MB");
|
|
1691
1735
|
if (!/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(
|
|
1692
1736
|
o
|
|
1693
1737
|
))
|
|
1694
|
-
throw new
|
|
1695
|
-
const
|
|
1738
|
+
throw new T("Invalid Base64 fileContent");
|
|
1739
|
+
const p = Buffer.from(o, "base64");
|
|
1696
1740
|
return await t.orderEntry.uploadFile({
|
|
1697
|
-
fileBuffer:
|
|
1741
|
+
fileBuffer: p,
|
|
1698
1742
|
fileName: i,
|
|
1699
1743
|
mimeType: a
|
|
1700
1744
|
});
|
|
1701
1745
|
};
|
|
1702
|
-
class
|
|
1746
|
+
class ne {
|
|
1703
1747
|
static parse(n) {
|
|
1704
1748
|
try {
|
|
1705
1749
|
const t = JSON.parse(n);
|
|
@@ -1717,11 +1761,11 @@ class ee {
|
|
|
1717
1761
|
return JSON.stringify(n);
|
|
1718
1762
|
}
|
|
1719
1763
|
}
|
|
1720
|
-
const
|
|
1721
|
-
e.storage.channel =
|
|
1722
|
-
},
|
|
1764
|
+
const he = (e, n) => {
|
|
1765
|
+
e.storage.channel = ne.parse(n);
|
|
1766
|
+
}, fe = (e, n) => {
|
|
1723
1767
|
e.storage.locale = n;
|
|
1724
|
-
}, on = (e) =>
|
|
1768
|
+
}, on = (e) => En.createHash("md5").update(e).digest("hex"), K = {
|
|
1725
1769
|
attachment: "ATTACHMENT",
|
|
1726
1770
|
specification: "SPECIFICATION",
|
|
1727
1771
|
attribute: "ATTRIBUTE"
|
|
@@ -1730,16 +1774,16 @@ function sn(e) {
|
|
|
1730
1774
|
return {
|
|
1731
1775
|
name: e.name,
|
|
1732
1776
|
value: e.content,
|
|
1733
|
-
valueReference:
|
|
1777
|
+
valueReference: K.attachment
|
|
1734
1778
|
};
|
|
1735
1779
|
}
|
|
1736
|
-
function
|
|
1780
|
+
function lr(e) {
|
|
1737
1781
|
return {
|
|
1738
1782
|
propertyID: e.id,
|
|
1739
1783
|
name: e.name,
|
|
1740
1784
|
value: e.value,
|
|
1741
1785
|
valueReference: {
|
|
1742
|
-
valueReference:
|
|
1786
|
+
valueReference: K.attribute,
|
|
1743
1787
|
visible: e.visible
|
|
1744
1788
|
}
|
|
1745
1789
|
};
|
|
@@ -1749,7 +1793,7 @@ function cn(e) {
|
|
|
1749
1793
|
`${e.name}:${JSON.stringify(e.value)}:${e.valueReference}`
|
|
1750
1794
|
);
|
|
1751
1795
|
}
|
|
1752
|
-
const
|
|
1796
|
+
const dr = (e) => {
|
|
1753
1797
|
const n = e.postalCode, t = e.geoCoordinates, r = {
|
|
1754
1798
|
addressType: e.addressType || null,
|
|
1755
1799
|
postalCode: n || null,
|
|
@@ -1768,7 +1812,7 @@ const sr = (e) => {
|
|
|
1768
1812
|
r.geoCoordinates = i !== null && a !== null ? [a, i] : [];
|
|
1769
1813
|
}
|
|
1770
1814
|
return [r];
|
|
1771
|
-
},
|
|
1815
|
+
}, ur = (e, n, t) => {
|
|
1772
1816
|
const r = n.postalCode, i = n.geoCoordinates, a = e?.shippingData?.availableAddresses ?? [], o = e?.shippingData?.selectedAddresses ?? [];
|
|
1773
1817
|
if (!t && o.length > 0)
|
|
1774
1818
|
return [o[0]];
|
|
@@ -1783,31 +1827,31 @@ const sr = (e) => {
|
|
|
1783
1827
|
}
|
|
1784
1828
|
return null;
|
|
1785
1829
|
}, ln = (e, n) => {
|
|
1786
|
-
if (!
|
|
1830
|
+
if (!pr(n))
|
|
1787
1831
|
return { updateShipping: !1, addressChanged: !1 };
|
|
1788
|
-
if (!
|
|
1832
|
+
if (!fr(e))
|
|
1789
1833
|
return { updateShipping: !1, addressChanged: !1 };
|
|
1790
1834
|
const [t] = e?.shippingData?.selectedAddresses ?? [];
|
|
1791
|
-
if (
|
|
1835
|
+
if (gr(t, n.postalCode) || mr(t, n.geoCoordinates) || hr(t, n.addressType))
|
|
1792
1836
|
return { updateShipping: !0, addressChanged: !0 };
|
|
1793
1837
|
const { logisticsInfo: r } = e.shippingData;
|
|
1794
|
-
return
|
|
1795
|
-
},
|
|
1838
|
+
return Sr(r, n) ? { updateShipping: !0, addressChanged: !1 } : { updateShipping: !1, addressChanged: !1 };
|
|
1839
|
+
}, pr = (e) => !!e.postalCode || e.geoCoordinates?.latitude && e.geoCoordinates?.longitude, gr = (e, n) => typeof n == "string" && e?.postalCode !== n, mr = (e, n) => typeof n?.latitude == "number" && typeof n?.longitude == "number" && (e?.geoCoordinates[0] !== n?.longitude || e?.geoCoordinates[1] !== n?.latitude), hr = (e, n) => typeof n == "string" && e?.addressType !== n, fr = (e) => e.items.length !== 0, Sr = (e, n) => {
|
|
1796
1840
|
const t = n?.deliveryMode?.deliveryChannel, r = n?.deliveryMode?.deliveryMethod, { startDate: i, endDate: a } = n?.deliveryMode?.deliveryWindow || {};
|
|
1797
1841
|
return e.some(
|
|
1798
1842
|
({ selectedDeliveryChannel: o, selectedSla: s, slas: c }) => {
|
|
1799
|
-
const
|
|
1800
|
-
return c?.some((
|
|
1801
|
-
(
|
|
1843
|
+
const l = t && o !== t, p = r && s !== r;
|
|
1844
|
+
return c?.some((u) => l && u.deliveryChannel === t || p && 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(
|
|
1845
|
+
(h) => h?.startDateUtc === i && h?.endDateUtc === a
|
|
1802
1846
|
));
|
|
1803
1847
|
}
|
|
1804
1848
|
);
|
|
1805
|
-
}, dn = (e) => e.valueReference ===
|
|
1849
|
+
}, dn = (e) => e.valueReference === K.attachment, Se = (e) => [
|
|
1806
1850
|
e.itemOffered.sku,
|
|
1807
1851
|
e.seller.identifier,
|
|
1808
1852
|
e.price < 0.01 ? "Gift" : void 0,
|
|
1809
1853
|
e.itemOffered.additionalProperty?.filter(dn).map(cn).join("-")
|
|
1810
|
-
].filter(Boolean).join("::"),
|
|
1854
|
+
].filter(Boolean).join("::"), te = (e, n) => ({
|
|
1811
1855
|
listPrice: e.listPrice / 100,
|
|
1812
1856
|
price: e.sellingPrice / 100,
|
|
1813
1857
|
quantity: e.quantity,
|
|
@@ -1819,7 +1863,7 @@ const sr = (e) => {
|
|
|
1819
1863
|
additionalProperty: e.attachments.map(sn)
|
|
1820
1864
|
},
|
|
1821
1865
|
index: n
|
|
1822
|
-
}),
|
|
1866
|
+
}), yr = (e) => ({
|
|
1823
1867
|
quantity: e.quantity,
|
|
1824
1868
|
seller: e.seller.identifier,
|
|
1825
1869
|
id: e.itemOffered.sku,
|
|
@@ -1828,17 +1872,17 @@ const sr = (e) => {
|
|
|
1828
1872
|
name: n.name,
|
|
1829
1873
|
content: n.value
|
|
1830
1874
|
}))
|
|
1831
|
-
}),
|
|
1832
|
-
const r =
|
|
1875
|
+
}), Ne = (e) => e.reduce((n, t) => {
|
|
1876
|
+
const r = Se(t);
|
|
1833
1877
|
return n.has(r) || n.set(r, []), n.get(r)?.push(t), n;
|
|
1834
|
-
}, /* @__PURE__ */ new Map()),
|
|
1878
|
+
}, /* @__PURE__ */ new Map()), Ir = (e, n) => {
|
|
1835
1879
|
const t = (s, c) => ({
|
|
1836
1880
|
...s,
|
|
1837
1881
|
itemOffered: {
|
|
1838
1882
|
sku: s.itemOffered.sku
|
|
1839
1883
|
},
|
|
1840
1884
|
index: c
|
|
1841
|
-
}), r = n.items.map(
|
|
1885
|
+
}), r = n.items.map(te).map(t), i = e.acceptedOffer.map(t), a = e.orderNumber === n.orderFormId, o = ve(r, i);
|
|
1842
1886
|
return a && o;
|
|
1843
1887
|
};
|
|
1844
1888
|
function un(e, n) {
|
|
@@ -1851,10 +1895,10 @@ function pn(e, n) {
|
|
|
1851
1895
|
(t) => t.id === n && t.parentItemIndex !== null
|
|
1852
1896
|
);
|
|
1853
1897
|
}
|
|
1854
|
-
const
|
|
1898
|
+
const Be = (e) => {
|
|
1855
1899
|
const n = e.items.reduce(
|
|
1856
1900
|
(t, r, i) => {
|
|
1857
|
-
const a = pn(e.items, r.id) || un(e.items, r.id) ? `${
|
|
1901
|
+
const a = pn(e.items, r.id) || un(e.items, r.id) ? `${Se(te(r))}::${i}` : Se(te(r));
|
|
1858
1902
|
return t[a] || (t[a] = []), t[a].push(r), t;
|
|
1859
1903
|
},
|
|
1860
1904
|
{}
|
|
@@ -1873,7 +1917,7 @@ const Ne = (e) => {
|
|
|
1873
1917
|
};
|
|
1874
1918
|
})
|
|
1875
1919
|
};
|
|
1876
|
-
},
|
|
1920
|
+
}, Le = async (e, n, t) => ({
|
|
1877
1921
|
order: {
|
|
1878
1922
|
orderNumber: e.orderFormId,
|
|
1879
1923
|
acceptedOffer: e.items.map(async (r) => ({
|
|
@@ -1897,7 +1941,7 @@ const Ne = (e) => {
|
|
|
1897
1941
|
return on(
|
|
1898
1942
|
JSON.stringify({ sessionId: n?.id ?? "", items: t })
|
|
1899
1943
|
);
|
|
1900
|
-
},
|
|
1944
|
+
}, Me = async (e, n, t) => {
|
|
1901
1945
|
try {
|
|
1902
1946
|
return await n.checkout.setCustomData({
|
|
1903
1947
|
id: e.orderFormId,
|
|
@@ -1913,14 +1957,14 @@ const Ne = (e) => {
|
|
|
1913
1957
|
More info at: https://developers.vtex.com/vtex-rest-api/docs/customizable-fields-with-checkout-api`
|
|
1914
1958
|
), r;
|
|
1915
1959
|
}
|
|
1916
|
-
},
|
|
1960
|
+
}, vr = (e, n) => {
|
|
1917
1961
|
const r = e.customData?.customApps.find(
|
|
1918
1962
|
(a) => a.id === "faststore"
|
|
1919
1963
|
)?.fields?.cartEtag;
|
|
1920
1964
|
return r == null ? !0 : gn(e, n) !== r;
|
|
1921
|
-
},
|
|
1965
|
+
}, Or = async (e, { clients: { commerce: n } }) => n.checkout.clearOrderFormMessages({
|
|
1922
1966
|
id: e
|
|
1923
|
-
}),
|
|
1967
|
+
}), $e = async (e, n, { clients: { commerce: t } }) => {
|
|
1924
1968
|
if (!n)
|
|
1925
1969
|
return e;
|
|
1926
1970
|
const { updateShipping: r, addressChanged: i } = ln(
|
|
@@ -1928,7 +1972,7 @@ const Ne = (e) => {
|
|
|
1928
1972
|
n
|
|
1929
1973
|
);
|
|
1930
1974
|
if (r) {
|
|
1931
|
-
const a =
|
|
1975
|
+
const a = ur(e, n, i), s = a || dr(n);
|
|
1932
1976
|
return !!n.deliveryMode?.deliveryWindow && await t.checkout.shippingData(
|
|
1933
1977
|
{
|
|
1934
1978
|
id: e.orderFormId,
|
|
@@ -1948,95 +1992,116 @@ const Ne = (e) => {
|
|
|
1948
1992
|
);
|
|
1949
1993
|
}
|
|
1950
1994
|
return e;
|
|
1951
|
-
},
|
|
1995
|
+
}, Cr = (e, n) => {
|
|
1952
1996
|
if (!e)
|
|
1953
1997
|
return "";
|
|
1954
|
-
const r =
|
|
1998
|
+
const r = J(e)[n];
|
|
1955
1999
|
return r ? r.split("=")[1] : "";
|
|
1956
|
-
},
|
|
1957
|
-
const i =
|
|
2000
|
+
}, br = async (e, { cart: { order: n }, session: t }, r) => {
|
|
2001
|
+
const i = Cr(
|
|
1958
2002
|
r.headers.cookie,
|
|
1959
2003
|
"checkout.vtex.com"
|
|
1960
2004
|
), {
|
|
1961
2005
|
clients: { commerce: a },
|
|
1962
2006
|
loaders: { skuLoader: o }
|
|
1963
2007
|
} = r, s = t?.channel, c = t?.locale;
|
|
1964
|
-
s &&
|
|
1965
|
-
const
|
|
2008
|
+
s && he(r, s), c && fe(r, c);
|
|
2009
|
+
const l = await a.checkout.orderForm({
|
|
1966
2010
|
id: i || void 0,
|
|
1967
2011
|
channel: r.storage.channel
|
|
1968
|
-
}),
|
|
1969
|
-
|
|
1970
|
-
const
|
|
1971
|
-
if (
|
|
1972
|
-
const
|
|
1973
|
-
|
|
2012
|
+
}), p = l.orderFormId;
|
|
2013
|
+
l.messages.length !== 0 && await Or(p, r);
|
|
2014
|
+
const u = J(r?.headers?.cookie ?? "")?.vtex_session, h = X(u), { acceptedOffer: S, shouldSplitItem: b } = n;
|
|
2015
|
+
if (vr(l, h)) {
|
|
2016
|
+
const O = await Me(
|
|
2017
|
+
l,
|
|
1974
2018
|
a,
|
|
1975
|
-
|
|
1976
|
-
).then(
|
|
1977
|
-
if (
|
|
1978
|
-
return
|
|
2019
|
+
h
|
|
2020
|
+
).then(Be);
|
|
2021
|
+
if (p)
|
|
2022
|
+
return Le(O, o, b);
|
|
1979
2023
|
}
|
|
1980
|
-
const
|
|
1981
|
-
(
|
|
1982
|
-
const
|
|
1983
|
-
if (!
|
|
1984
|
-
return
|
|
1985
|
-
const [
|
|
1986
|
-
if (pn(
|
|
1987
|
-
return
|
|
1988
|
-
const
|
|
1989
|
-
return
|
|
1990
|
-
...
|
|
1991
|
-
quantity:
|
|
1992
|
-
}),
|
|
2024
|
+
const g = Ne(S), m = Ne(l.items.map(te)), y = Array.from(m.entries()), C = Array.from(g.entries()), { itemsToAdd: w, itemsToUpdate: v } = C.reduce(
|
|
2025
|
+
(O, [E, _]) => {
|
|
2026
|
+
const q = m.get(E);
|
|
2027
|
+
if (!q)
|
|
2028
|
+
return _.forEach((j) => O.itemsToAdd.push(j)), O;
|
|
2029
|
+
const [R, ...Oe] = q;
|
|
2030
|
+
if (pn(l.items, R.itemOffered.sku) || un(l.items, R.itemOffered.sku))
|
|
2031
|
+
return O.itemsToUpdate.push(R), O;
|
|
2032
|
+
const ae = _.reduce((j, vn) => j + vn.quantity, 0);
|
|
2033
|
+
return O.itemsToUpdate.push({
|
|
2034
|
+
...R,
|
|
2035
|
+
quantity: ae
|
|
2036
|
+
}), Oe.forEach((j) => O.itemsToUpdate.push({ ...j, quantity: 0 })), O;
|
|
1993
2037
|
},
|
|
1994
2038
|
{
|
|
1995
2039
|
itemsToAdd: [],
|
|
1996
2040
|
itemsToUpdate: []
|
|
1997
2041
|
}
|
|
1998
|
-
), P =
|
|
1999
|
-
|
|
2000
|
-
), { updateShipping:
|
|
2001
|
-
if (
|
|
2042
|
+
), P = y.filter(([O]) => !g.has(O)).flatMap(([, O]) => O.map((E) => ({ ...E, quantity: 0 }))), f = [...w, ...v, ...P].map(
|
|
2043
|
+
yr
|
|
2044
|
+
), { updateShipping: D } = t ? ln(l, t) : { updateShipping: !1 };
|
|
2045
|
+
if (f.length === 0 && !D)
|
|
2002
2046
|
return null;
|
|
2003
|
-
let
|
|
2004
|
-
|
|
2005
|
-
id:
|
|
2006
|
-
orderItems:
|
|
2007
|
-
shouldSplitItem:
|
|
2047
|
+
let A;
|
|
2048
|
+
f.length > 0 ? A = await a.checkout.updateOrderFormItems({
|
|
2049
|
+
id: l.orderFormId,
|
|
2050
|
+
orderItems: f,
|
|
2051
|
+
shouldSplitItem: b
|
|
2008
2052
|
}).then(
|
|
2009
|
-
(
|
|
2010
|
-
) :
|
|
2011
|
-
|
|
2053
|
+
(O) => $e(O, t, r)
|
|
2054
|
+
) : A = await $e(
|
|
2055
|
+
l,
|
|
2012
2056
|
t,
|
|
2013
2057
|
r
|
|
2014
|
-
),
|
|
2058
|
+
), A = await Promise.resolve(A).then((O) => {
|
|
2015
2059
|
if (t?.marketingData) {
|
|
2016
|
-
const
|
|
2017
|
-
...
|
|
2060
|
+
const E = {
|
|
2061
|
+
...O.marketingData,
|
|
2018
2062
|
...t.marketingData
|
|
2019
2063
|
};
|
|
2020
2064
|
return a.checkout.marketingData({
|
|
2021
|
-
id:
|
|
2022
|
-
marketingData:
|
|
2065
|
+
id: l.orderFormId,
|
|
2066
|
+
marketingData: E
|
|
2023
2067
|
});
|
|
2024
2068
|
}
|
|
2025
|
-
return
|
|
2026
|
-
}).then((
|
|
2027
|
-
id:
|
|
2069
|
+
return O;
|
|
2070
|
+
}).then((O) => c && O.clientPreferencesData?.locale !== c ? a.checkout.clientPreferencesData({
|
|
2071
|
+
id: O.orderFormId,
|
|
2028
2072
|
clientPreferencesData: {
|
|
2029
|
-
...
|
|
2073
|
+
...O.clientPreferencesData,
|
|
2030
2074
|
locale: c
|
|
2031
2075
|
}
|
|
2032
|
-
}) :
|
|
2033
|
-
const
|
|
2034
|
-
|
|
2035
|
-
|
|
2076
|
+
}) : O).then((O) => Me(O, a, h)).then(Be);
|
|
2077
|
+
const U = ve(
|
|
2078
|
+
l.messages,
|
|
2079
|
+
A.messages
|
|
2036
2080
|
);
|
|
2037
|
-
return
|
|
2081
|
+
return Ir(n, A) && U ? null : Le(A, o, b);
|
|
2082
|
+
}, wr = (e) => {
|
|
2083
|
+
const n = (e?.corporateName ?? "").trim();
|
|
2084
|
+
return n || (e?.firstName ?? "").trim();
|
|
2085
|
+
}, Dr = (e) => {
|
|
2086
|
+
if (!e || typeof e != "object")
|
|
2087
|
+
return !1;
|
|
2088
|
+
const n = e;
|
|
2089
|
+
return typeof n.customerId == "string" && n.customerId.trim() !== "" && typeof n.contractName == "string" && typeof n.isActive == "boolean" && typeof n.isCurrent == "boolean";
|
|
2090
|
+
}, Ar = (e) => {
|
|
2091
|
+
const n = e?.availableContracts?.value;
|
|
2092
|
+
return Array.isArray(n) ? n.filter(Dr) : [];
|
|
2093
|
+
}, Pr = (e) => e?.customerId ? !!((e.contractName ?? "").trim() && e.isActive) : !1, Ur = (e) => e?.namespaces?.shopper?.activeContractId?.value?.trim() ?? e?.namespaces?.authentication?.customerId?.value?.trim() ?? e?.namespaces?.profile?.id?.value?.trim() ?? "", Er = (e, n = "") => {
|
|
2094
|
+
const t = n.trim();
|
|
2095
|
+
return e.filter(Pr).map((r) => ({
|
|
2096
|
+
id: r.customerId,
|
|
2097
|
+
corporateName: r.contractName.trim(),
|
|
2098
|
+
isActive: t ? r.customerId === t : r.isCurrent
|
|
2099
|
+
}));
|
|
2100
|
+
}, mn = (e, n) => {
|
|
2101
|
+
const t = wr(e);
|
|
2102
|
+
return t || (n?.firstName?.value ?? "").trim();
|
|
2038
2103
|
};
|
|
2039
|
-
async function
|
|
2104
|
+
async function _r(e, n, t) {
|
|
2040
2105
|
try {
|
|
2041
2106
|
const r = await e.commerce.checkout.address({
|
|
2042
2107
|
postalCode: t,
|
|
@@ -2053,45 +2118,45 @@ async function Or(e, n, t) {
|
|
|
2053
2118
|
), r;
|
|
2054
2119
|
}
|
|
2055
2120
|
}
|
|
2056
|
-
const
|
|
2057
|
-
const o =
|
|
2058
|
-
let
|
|
2059
|
-
if ((!
|
|
2060
|
-
const
|
|
2121
|
+
const Tr = async (e, { session: n, search: t }, { clients: r, headers: i, account: a }) => {
|
|
2122
|
+
const o = ne.parse(n.channel ?? ""), s = String(n.postalCode ?? ""), c = n.country ?? "";
|
|
2123
|
+
let l = n.city ?? null, p = n.geoCoordinates ?? null;
|
|
2124
|
+
if ((!l || !p) && s !== "" && c !== "") {
|
|
2125
|
+
const R = await _r(
|
|
2061
2126
|
r,
|
|
2062
2127
|
c,
|
|
2063
2128
|
s
|
|
2064
2129
|
);
|
|
2065
|
-
|
|
2130
|
+
l = R.city, p = R.geoCoordinates;
|
|
2066
2131
|
}
|
|
2067
|
-
const
|
|
2068
|
-
|
|
2069
|
-
const
|
|
2070
|
-
|
|
2132
|
+
const h = new URLSearchParams(t);
|
|
2133
|
+
h.has("facets") && h.delete("facets");
|
|
2134
|
+
const S = h.get("sc") ?? o.salesChannel;
|
|
2135
|
+
h.set("sc", S), s && h.set("postalCode", s), c && h.set("country", c), p && h.set(
|
|
2071
2136
|
"geoCoordinates",
|
|
2072
|
-
`${
|
|
2137
|
+
`${p.longitude},${p.latitude}`
|
|
2073
2138
|
// long,lat is the format expected
|
|
2074
|
-
),
|
|
2075
|
-
const { marketingData:
|
|
2076
|
-
utmCampaign:
|
|
2077
|
-
utmMedium:
|
|
2078
|
-
utmSource:
|
|
2079
|
-
utmiCampaign:
|
|
2080
|
-
utmiPage:
|
|
2081
|
-
utmiPart:
|
|
2082
|
-
},
|
|
2083
|
-
let
|
|
2084
|
-
if (
|
|
2139
|
+
), h.set("locale", n.locale);
|
|
2140
|
+
const { marketingData: b } = n, d = {
|
|
2141
|
+
utmCampaign: h.get("utm_campaign") ?? b?.utmCampaign ?? "",
|
|
2142
|
+
utmMedium: h.get("utm_medium") ?? b?.utmMedium ?? "",
|
|
2143
|
+
utmSource: h.get("utm_source") ?? b?.utmSource ?? "",
|
|
2144
|
+
utmiCampaign: h.get("utmi_cp") ?? b?.utmiCampaign ?? "",
|
|
2145
|
+
utmiPage: h.get("utmi_p") ?? b?.utmiPage ?? "",
|
|
2146
|
+
utmiPart: h.get("utmi_pc") ?? b?.utmiPart ?? ""
|
|
2147
|
+
}, g = X(z(i?.cookie ?? "", a));
|
|
2148
|
+
let m = !1;
|
|
2149
|
+
if (g)
|
|
2085
2150
|
try {
|
|
2086
|
-
|
|
2087
|
-
} catch (
|
|
2088
|
-
console.warn("JWT validation failed:",
|
|
2151
|
+
m = (await r.commerce.vtexid.validate())?.authStatus?.toLowerCase() === "success";
|
|
2152
|
+
} catch (R) {
|
|
2153
|
+
console.warn("JWT validation failed:", R), m = !1;
|
|
2089
2154
|
}
|
|
2090
|
-
const
|
|
2091
|
-
let
|
|
2092
|
-
if (
|
|
2155
|
+
const y = m ? g?.isRepresentative : !1, C = m ? g?.customerId : void 0, w = m ? g?.unitId : void 0, v = await r.commerce.session(h.toString()).catch(() => null), P = v?.namespaces.profile ?? null, f = v?.namespaces.shopper ?? null, D = v?.namespaces.store ?? null, A = v?.namespaces.authentication ?? null, U = v?.namespaces.checkout ?? null, O = v?.namespaces.public ?? null;
|
|
2156
|
+
let E = null;
|
|
2157
|
+
if (y && P?.id?.value)
|
|
2093
2158
|
try {
|
|
2094
|
-
|
|
2159
|
+
E = await r.commerce.masterData.getContractById({
|
|
2095
2160
|
contractId: P.id.value
|
|
2096
2161
|
});
|
|
2097
2162
|
} catch {
|
|
@@ -2100,25 +2165,25 @@ const Cr = async (e, { session: n, search: t }, { clients: r, headers: i, accoun
|
|
|
2100
2165
|
`
|
|
2101
2166
|
);
|
|
2102
2167
|
}
|
|
2103
|
-
let
|
|
2104
|
-
o.seller && (s ||
|
|
2168
|
+
let _;
|
|
2169
|
+
o.seller && (s || p) && (_ = (await r.commerce.checkout.region({
|
|
2105
2170
|
postalCode: s,
|
|
2106
|
-
geoCoordinates:
|
|
2171
|
+
geoCoordinates: p,
|
|
2107
2172
|
country: c,
|
|
2108
|
-
salesChannel:
|
|
2109
|
-
}))?.[0]?.sellers.find((
|
|
2110
|
-
const
|
|
2173
|
+
salesChannel: S
|
|
2174
|
+
}))?.[0]?.sellers.find((ae) => o.seller === ae.id));
|
|
2175
|
+
const q = {
|
|
2111
2176
|
...n,
|
|
2112
2177
|
currency: {
|
|
2113
|
-
code:
|
|
2114
|
-
symbol:
|
|
2178
|
+
code: D?.currencyCode?.value ?? n.currency.code,
|
|
2179
|
+
symbol: D?.currencySymbol?.value ?? n.currency.symbol
|
|
2115
2180
|
},
|
|
2116
|
-
country:
|
|
2117
|
-
channel:
|
|
2118
|
-
salesChannel:
|
|
2119
|
-
regionId:
|
|
2120
|
-
seller:
|
|
2121
|
-
hasOnlyDefaultSalesChannel: !
|
|
2181
|
+
country: D?.countryCode?.value ?? c,
|
|
2182
|
+
channel: ne.stringify({
|
|
2183
|
+
salesChannel: D?.channel?.value ?? o.salesChannel,
|
|
2184
|
+
regionId: U?.regionId?.value ?? o.regionId,
|
|
2185
|
+
seller: _?.id,
|
|
2186
|
+
hasOnlyDefaultSalesChannel: !D?.channel?.value
|
|
2122
2187
|
}),
|
|
2123
2188
|
/**
|
|
2124
2189
|
* B2B data structure in Session:
|
|
@@ -2126,60 +2191,61 @@ const Cr = async (e, { session: n, search: t }, { clients: r, headers: i, accoun
|
|
|
2126
2191
|
* - Unit data: `authentication` namespace
|
|
2127
2192
|
* - Contract data: `profile` namespace (those info will be available inside Faststore's Session `person` object)
|
|
2128
2193
|
*/
|
|
2129
|
-
b2b:
|
|
2130
|
-
isRepresentative:
|
|
2131
|
-
customerId:
|
|
2132
|
-
unitName:
|
|
2133
|
-
unitId:
|
|
2134
|
-
firstName: typeof
|
|
2135
|
-
lastName: typeof
|
|
2136
|
-
userName: `${typeof
|
|
2137
|
-
userEmail:
|
|
2138
|
-
savedPostalCode:
|
|
2139
|
-
contractName:
|
|
2140
|
-
organizationManager:
|
|
2194
|
+
b2b: y ? {
|
|
2195
|
+
isRepresentative: y ?? !1,
|
|
2196
|
+
customerId: A?.customerId?.value ?? C ?? "",
|
|
2197
|
+
unitName: A?.unitName?.value ?? "",
|
|
2198
|
+
unitId: A?.unitId?.value ?? w ?? "",
|
|
2199
|
+
firstName: typeof f?.firstName?.value == "string" ? f.firstName.value : "",
|
|
2200
|
+
lastName: typeof f?.lastName?.value == "string" ? f.lastName.value : "",
|
|
2201
|
+
userName: `${typeof f?.firstName?.value == "string" ? f.firstName.value : ""} ${typeof f?.lastName?.value == "string" ? f.lastName.value : ""}`.trim(),
|
|
2202
|
+
userEmail: A?.storeUserEmail.value ?? "",
|
|
2203
|
+
savedPostalCode: O?.postalCode?.value ?? "",
|
|
2204
|
+
contractName: mn(E, P),
|
|
2205
|
+
organizationManager: f?.organizationManager?.value ?? !1
|
|
2141
2206
|
} : null,
|
|
2142
|
-
marketingData:
|
|
2207
|
+
marketingData: d,
|
|
2143
2208
|
person: P?.id ? {
|
|
2144
2209
|
id: P.id?.value ?? "",
|
|
2145
2210
|
email: P.email?.value ?? "",
|
|
2146
2211
|
givenName: P.firstName?.value ?? "",
|
|
2147
2212
|
familyName: P.lastName?.value ?? ""
|
|
2148
2213
|
} : null,
|
|
2149
|
-
geoCoordinates:
|
|
2150
|
-
city:
|
|
2214
|
+
geoCoordinates: p?.latitude && p?.longitude && p || null,
|
|
2215
|
+
city: l
|
|
2151
2216
|
};
|
|
2152
|
-
return
|
|
2153
|
-
},
|
|
2154
|
-
validateCart:
|
|
2155
|
-
validateSession:
|
|
2156
|
-
subscribeToNewsletter:
|
|
2157
|
-
cancelOrder:
|
|
2158
|
-
processOrderAuthorization:
|
|
2159
|
-
uploadFileToOrderEntry:
|
|
2160
|
-
startOrderEntryOperation:
|
|
2217
|
+
return ve(n, q) ? null : q;
|
|
2218
|
+
}, Rr = {
|
|
2219
|
+
validateCart: br,
|
|
2220
|
+
validateSession: Tr,
|
|
2221
|
+
subscribeToNewsletter: sr,
|
|
2222
|
+
cancelOrder: tr,
|
|
2223
|
+
processOrderAuthorization: ir,
|
|
2224
|
+
uploadFileToOrderEntry: cr,
|
|
2225
|
+
startOrderEntryOperation: ar,
|
|
2226
|
+
startRecommendationSession: or
|
|
2161
2227
|
};
|
|
2162
|
-
var
|
|
2228
|
+
var ye;
|
|
2163
2229
|
(function(e) {
|
|
2164
2230
|
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";
|
|
2165
|
-
})(
|
|
2166
|
-
const
|
|
2167
|
-
function
|
|
2231
|
+
})(ye || (ye = {}));
|
|
2232
|
+
const kr = (e) => typeof e == "string" ? hn(e) : null;
|
|
2233
|
+
function hn(e) {
|
|
2168
2234
|
try {
|
|
2169
2235
|
return JSON.parse(e);
|
|
2170
2236
|
} catch {
|
|
2171
2237
|
return e;
|
|
2172
2238
|
}
|
|
2173
2239
|
}
|
|
2174
|
-
const
|
|
2240
|
+
const Fr = (e) => typeof e == "object" ? JSON.stringify(e) : typeof e == "string" ? e : null, Nr = new bn({
|
|
2175
2241
|
name: "ObjectOrString",
|
|
2176
2242
|
description: "A string or the string representation of an object (a stringified object).",
|
|
2177
|
-
parseValue:
|
|
2178
|
-
serialize:
|
|
2243
|
+
parseValue: kr,
|
|
2244
|
+
serialize: Fr,
|
|
2179
2245
|
parseLiteral(e) {
|
|
2180
|
-
return e.kind ===
|
|
2246
|
+
return e.kind === ye.STRING ? hn(e.value) : null;
|
|
2181
2247
|
}
|
|
2182
|
-
}),
|
|
2248
|
+
}), F = (e) => "Price" in e && "seller" in e && "product" in e, k = (e) => "skuName" in e, Br = {
|
|
2183
2249
|
priceCurrency: async (e, n, t) => {
|
|
2184
2250
|
const {
|
|
2185
2251
|
loaders: { salesChannelLoader: r },
|
|
@@ -2187,34 +2253,34 @@ const wr = (e) => typeof e == "object" ? JSON.stringify(e) : typeof e == "string
|
|
|
2187
2253
|
} = t;
|
|
2188
2254
|
return (await r.load(i.salesChannel)).CurrencyCode ?? "";
|
|
2189
2255
|
},
|
|
2190
|
-
priceValidUntil: (e) =>
|
|
2256
|
+
priceValidUntil: (e) => F(e) ? e.PriceValidUntil ?? "" : k(e) ? e.priceValidUntil ?? "" : null,
|
|
2191
2257
|
itemCondition: () => "https://schema.org/NewCondition",
|
|
2192
|
-
availability: async (e) =>
|
|
2193
|
-
seller: (e, n, t) =>
|
|
2258
|
+
availability: async (e) => F(e) ? Ue(M(e)) : k(e) ? Ue(xt(e.availability)) : null,
|
|
2259
|
+
seller: (e, n, t) => F(e) ? {
|
|
2194
2260
|
identifier: t.storage.channel?.seller || e.seller.sellerId || ""
|
|
2195
|
-
} :
|
|
2261
|
+
} : k(e) ? {
|
|
2196
2262
|
identifier: e.seller
|
|
2197
2263
|
} : null,
|
|
2198
|
-
price: (e) =>
|
|
2199
|
-
priceWithTaxes: (e) =>
|
|
2264
|
+
price: (e) => F(e) ? V(e) : k(e) ? e.sellingPrice / 100 : null,
|
|
2265
|
+
priceWithTaxes: (e) => F(e) ? $(V(e), e?.Tax, e.product.unitMultiplier) : k(e) ? $(
|
|
2200
2266
|
e.sellingPrice / 100,
|
|
2201
2267
|
e.tax / 100,
|
|
2202
2268
|
e.unitMultiplier
|
|
2203
2269
|
) : null,
|
|
2204
|
-
sellingPrice: (e) =>
|
|
2205
|
-
listPrice: (e) =>
|
|
2206
|
-
listPriceWithTaxes: (e) =>
|
|
2270
|
+
sellingPrice: (e) => F(e) ? zt(e) : k(e) ? e.sellingPrice / 100 : null,
|
|
2271
|
+
listPrice: (e) => F(e) ? e.ListPrice ?? 0 : k(e) ? e.listPrice / 100 : null,
|
|
2272
|
+
listPriceWithTaxes: (e) => F(e) ? $(
|
|
2207
2273
|
e.ListPrice ?? 0,
|
|
2208
2274
|
e?.Tax,
|
|
2209
2275
|
e.product.unitMultiplier
|
|
2210
|
-
) :
|
|
2211
|
-
itemOffered: (e) =>
|
|
2276
|
+
) : k(e) ? $(e.listPrice / 100, e.tax / 100, e.unitMultiplier) : null,
|
|
2277
|
+
itemOffered: (e) => F(e) ? e.product : k(e) ? {
|
|
2212
2278
|
...e.product,
|
|
2213
2279
|
attachmentsValues: e.attachments
|
|
2214
2280
|
} : null,
|
|
2215
|
-
quantity: (e) =>
|
|
2216
|
-
isGift: (e) =>
|
|
2217
|
-
},
|
|
2281
|
+
quantity: (e) => F(e) ? e.AvailableQuantity ?? 0 : k(e) ? e.quantity : null,
|
|
2282
|
+
isGift: (e) => k(e) ? e.isGift ?? !1 : null
|
|
2283
|
+
}, Lr = ({ linkText: e }) => `/${e}/p`, Mr = ({
|
|
2218
2284
|
offer: e,
|
|
2219
2285
|
seller: n,
|
|
2220
2286
|
product: t
|
|
@@ -2222,26 +2288,26 @@ const wr = (e) => typeof e == "object" ? JSON.stringify(e) : typeof e == "string
|
|
|
2222
2288
|
...e,
|
|
2223
2289
|
product: t,
|
|
2224
2290
|
seller: n
|
|
2225
|
-
}),
|
|
2291
|
+
}), $r = {
|
|
2226
2292
|
imageText: "image",
|
|
2227
2293
|
imageUrl: "https://storecomponents.vtexassets.com/assets/faststore/images/image___117a6d3e229a96ad0e0d0876352566e2.svg",
|
|
2228
2294
|
imageLabel: "label"
|
|
2229
|
-
},
|
|
2230
|
-
function
|
|
2295
|
+
}, fn = (e, n) => `${e}-${n}`, zr = (e, n) => `/${fn(e, n)}/p`, xr = (e) => Array.isArray(e) && e.length > 0 ? e : null;
|
|
2296
|
+
function Sn(e) {
|
|
2231
2297
|
return e.replace(/^\/+|\/+$/g, "");
|
|
2232
2298
|
}
|
|
2233
|
-
const
|
|
2234
|
-
const t = e.findIndex((r) =>
|
|
2299
|
+
const Vr = (e, n) => {
|
|
2300
|
+
const t = e.findIndex((r) => Sn(r).split("/").at(-1) === n);
|
|
2235
2301
|
return t < 0 ? 0 : t;
|
|
2236
|
-
},
|
|
2302
|
+
}, qr = {
|
|
2237
2303
|
productID: ({ itemId: e }) => e,
|
|
2238
2304
|
name: ({ isVariantOf: e, name: n }) => n ?? e.productName,
|
|
2239
|
-
slug: ({ isVariantOf: { linkText: e }, itemId: n }) =>
|
|
2305
|
+
slug: ({ isVariantOf: { linkText: e }, itemId: n }) => fn(e, n),
|
|
2240
2306
|
description: ({ isVariantOf: { description: e } }) => e,
|
|
2241
2307
|
seo: ({ isVariantOf: e }) => ({
|
|
2242
2308
|
title: e.productTitle || e.productName,
|
|
2243
2309
|
description: e.metaTagDescription || e.description,
|
|
2244
|
-
canonical:
|
|
2310
|
+
canonical: Lr(e)
|
|
2245
2311
|
}),
|
|
2246
2312
|
brand: ({ isVariantOf: { brand: e } }) => ({ name: e }),
|
|
2247
2313
|
unitMultiplier: ({ unitMultiplier: e }) => e,
|
|
@@ -2255,20 +2321,20 @@ const Fr = (e, n) => {
|
|
|
2255
2321
|
},
|
|
2256
2322
|
itemId: a
|
|
2257
2323
|
}) => {
|
|
2258
|
-
const o =
|
|
2324
|
+
const o = Vr(i, r), s = e[o], c = Sn(s).split("/");
|
|
2259
2325
|
return {
|
|
2260
2326
|
itemListElement: [
|
|
2261
|
-
...c.map((
|
|
2262
|
-
const
|
|
2327
|
+
...c.map((l, p) => {
|
|
2328
|
+
const u = `/${c.slice(0, p + 1).map(nn).join("/")}/`;
|
|
2263
2329
|
return {
|
|
2264
|
-
name:
|
|
2265
|
-
item:
|
|
2266
|
-
position:
|
|
2330
|
+
name: l,
|
|
2331
|
+
item: u,
|
|
2332
|
+
position: p + 1
|
|
2267
2333
|
};
|
|
2268
2334
|
}),
|
|
2269
2335
|
{
|
|
2270
2336
|
name: n,
|
|
2271
|
-
item:
|
|
2337
|
+
item: zr(t, a),
|
|
2272
2338
|
position: c.length + 1
|
|
2273
2339
|
}
|
|
2274
2340
|
],
|
|
@@ -2276,11 +2342,11 @@ const Fr = (e, n) => {
|
|
|
2276
2342
|
};
|
|
2277
2343
|
},
|
|
2278
2344
|
image: ({ images: e }, n) => {
|
|
2279
|
-
const t = (
|
|
2280
|
-
({ imageUrl: s, imageText: c, imageLabel:
|
|
2345
|
+
const t = (xr(e) ?? [$r]).map(
|
|
2346
|
+
({ imageUrl: s, imageText: c, imageLabel: l }) => ({
|
|
2281
2347
|
alternateName: c ?? "",
|
|
2282
2348
|
url: s.replace("vteximg.com.br", "vtexassets.com"),
|
|
2283
|
-
keywords:
|
|
2349
|
+
keywords: l
|
|
2284
2350
|
})
|
|
2285
2351
|
);
|
|
2286
2352
|
if (typeof n != "object")
|
|
@@ -2299,7 +2365,7 @@ const Fr = (e, n) => {
|
|
|
2299
2365
|
review: () => [],
|
|
2300
2366
|
aggregateRating: () => ({}),
|
|
2301
2367
|
offers: (e) => e.sellers.map(
|
|
2302
|
-
(n) =>
|
|
2368
|
+
(n) => Mr({
|
|
2303
2369
|
offer: n.commertialOffer,
|
|
2304
2370
|
seller: n,
|
|
2305
2371
|
product: e
|
|
@@ -2316,11 +2382,11 @@ const Fr = (e, n) => {
|
|
|
2316
2382
|
({ name: o, values: s }) => s.map((c) => ({
|
|
2317
2383
|
name: o,
|
|
2318
2384
|
value: c,
|
|
2319
|
-
valueReference:
|
|
2385
|
+
valueReference: K.specification
|
|
2320
2386
|
}))
|
|
2321
2387
|
), i = n.map(
|
|
2322
2388
|
sn
|
|
2323
|
-
), a = t.map(
|
|
2389
|
+
), a = t.map(lr);
|
|
2324
2390
|
return [
|
|
2325
2391
|
...r,
|
|
2326
2392
|
...i,
|
|
@@ -2333,34 +2399,34 @@ const Fr = (e, n) => {
|
|
|
2333
2399
|
releaseDate: ({ isVariantOf: { releaseDate: e } }) => e ?? "",
|
|
2334
2400
|
advertisement: ({ isVariantOf: { advertisement: e } }) => e,
|
|
2335
2401
|
deliveryPromiseBadges: ({ isVariantOf: { deliveryPromisesBadges: e } }) => e
|
|
2336
|
-
},
|
|
2337
|
-
hasVariant: (e) => e.isVariantOf.items.map((n) =>
|
|
2402
|
+
}, jr = /* @__PURE__ */ new Set(["allSpecifications"]), Wr = {
|
|
2403
|
+
hasVariant: (e) => e.isVariantOf.items.map((n) => N(n, e.isVariantOf)),
|
|
2338
2404
|
productGroupID: ({ isVariantOf: e }) => e.productId,
|
|
2339
2405
|
name: (e) => e.isVariantOf.productName,
|
|
2340
2406
|
skuVariants: (e) => e,
|
|
2341
2407
|
additionalProperty: ({ isVariantOf: { specificationGroups: e } }) => e.filter(
|
|
2342
|
-
(n) => !
|
|
2408
|
+
(n) => !jr.has(n.name)
|
|
2343
2409
|
).flatMap(
|
|
2344
2410
|
({ specifications: n }) => n.flatMap(
|
|
2345
2411
|
({ name: t, values: r }) => r.map((i) => ({
|
|
2346
2412
|
name: t,
|
|
2347
2413
|
value: i,
|
|
2348
|
-
valueReference:
|
|
2414
|
+
valueReference: K.specification
|
|
2349
2415
|
}))
|
|
2350
2416
|
)
|
|
2351
2417
|
)
|
|
2352
|
-
},
|
|
2418
|
+
}, Gr = {
|
|
2353
2419
|
propertyID: (e) => e.propertyID || cn(e),
|
|
2354
2420
|
name: ({ name: e }) => e,
|
|
2355
2421
|
value: ({ value: e }) => e,
|
|
2356
2422
|
valueReference: ({ valueReference: e }) => e
|
|
2357
|
-
},
|
|
2423
|
+
}, Hr = async (e, { operationId: n }, { clients: { commerce: t } }) => {
|
|
2358
2424
|
if (!n)
|
|
2359
|
-
throw new
|
|
2425
|
+
throw new T("Missing operationId");
|
|
2360
2426
|
return t.orderEntry.getOperation({ operationId: n });
|
|
2361
|
-
},
|
|
2427
|
+
}, Xr = async (e, { orderFormId: n }, { clients: { commerce: t } }) => {
|
|
2362
2428
|
if (!n)
|
|
2363
|
-
throw new
|
|
2429
|
+
throw new T("Missing orderFormId");
|
|
2364
2430
|
const { items: r } = await t.orderEntry.getOrderFormItems({ orderFormId: n });
|
|
2365
2431
|
return (r ?? []).map((i) => ({
|
|
2366
2432
|
id: i.id,
|
|
@@ -2373,18 +2439,46 @@ const Fr = (e, n) => {
|
|
|
2373
2439
|
seller: i.seller,
|
|
2374
2440
|
unitMultiplier: i.unitMultiplier ?? 1
|
|
2375
2441
|
}));
|
|
2376
|
-
},
|
|
2442
|
+
}, re = (e) => {
|
|
2377
2443
|
const n = e.flatMap(
|
|
2378
2444
|
(r) => r.sellers.map((i) => ({
|
|
2379
2445
|
offer: i.commertialOffer,
|
|
2380
2446
|
sku: r
|
|
2381
2447
|
}))
|
|
2382
|
-
), t =
|
|
2448
|
+
), t = me(
|
|
2383
2449
|
n,
|
|
2384
2450
|
({ offer: r }, { offer: i }) => en(r, i)
|
|
2385
2451
|
);
|
|
2386
2452
|
return t ? t.sku : e[0];
|
|
2387
|
-
},
|
|
2453
|
+
}, Yr = (e) => e !== "" && !Number.isNaN(Number(e)), Jr = /^vrn:recommendations:[^:]+:[^:]+:[^:]+$/, Qr = async (e, { campaignVrn: n, userId: t, products: r }, i) => {
|
|
2454
|
+
const {
|
|
2455
|
+
clients: { commerce: a }
|
|
2456
|
+
} = i, { salesChannel: o } = i.storage.channel, s = n?.trim();
|
|
2457
|
+
if (!s || !Jr.test(s))
|
|
2458
|
+
throw new T(`Invalid campaignVrn: "${n}"`);
|
|
2459
|
+
const c = t?.trim();
|
|
2460
|
+
if (t != null && !c)
|
|
2461
|
+
throw new T("Invalid userId: must be a non-empty string");
|
|
2462
|
+
if (r != null && (!Array.isArray(r) || r.some((S) => !S?.trim())))
|
|
2463
|
+
throw new T(
|
|
2464
|
+
"Invalid products: must be an array of non-empty strings"
|
|
2465
|
+
);
|
|
2466
|
+
const l = await a.recommendation.recommendations({
|
|
2467
|
+
campaignVrn: s,
|
|
2468
|
+
userId: c || void 0,
|
|
2469
|
+
products: r ?? [],
|
|
2470
|
+
salesChannel: o ?? void 0,
|
|
2471
|
+
locale: i.storage.locale
|
|
2472
|
+
}), { campaign: p, correlationId: u } = l;
|
|
2473
|
+
return {
|
|
2474
|
+
products: (l.products ?? []).map((S) => {
|
|
2475
|
+
const b = re(S.items);
|
|
2476
|
+
return b ? N(b, S) : null;
|
|
2477
|
+
}).filter((S) => !!S),
|
|
2478
|
+
correlationId: u,
|
|
2479
|
+
campaign: p
|
|
2480
|
+
};
|
|
2481
|
+
}, ze = {
|
|
2388
2482
|
price_desc: "price:desc",
|
|
2389
2483
|
price_asc: "price:asc",
|
|
2390
2484
|
orders_desc: "orders:desc",
|
|
@@ -2393,40 +2487,40 @@ const Fr = (e, n) => {
|
|
|
2393
2487
|
release_desc: "release:desc",
|
|
2394
2488
|
discount_desc: "discount:desc",
|
|
2395
2489
|
score_desc: ""
|
|
2396
|
-
},
|
|
2490
|
+
}, yn = "Invalid SkuId", Kr = "Slug was set but the fetched sku does not satisfy the slug condition.", Zr = (e) => Xe(e) || e instanceof Error && (e.message === yn || e.message.startsWith(Kr)), ei = {
|
|
2397
2491
|
product: async (e, { locator: n }, t) => {
|
|
2398
|
-
const r = Fe(n), i = ke(n), a =
|
|
2399
|
-
r &&
|
|
2492
|
+
const r = Fe(n), i = ke(n), a = Qt(n), o = Jt(n);
|
|
2493
|
+
r && he(t, r), i && fe(t, i);
|
|
2400
2494
|
const {
|
|
2401
2495
|
loaders: { skuLoader: s },
|
|
2402
|
-
clients: { commerce: c, search:
|
|
2496
|
+
clients: { commerce: c, search: l }
|
|
2403
2497
|
} = t;
|
|
2404
2498
|
try {
|
|
2405
|
-
const
|
|
2406
|
-
if (!
|
|
2407
|
-
throw new Error(
|
|
2408
|
-
const
|
|
2409
|
-
if (o &&
|
|
2499
|
+
const p = a ?? o?.split("-").pop() ?? "";
|
|
2500
|
+
if (!Yr(p))
|
|
2501
|
+
throw new Error(yn);
|
|
2502
|
+
const u = await s.load(p);
|
|
2503
|
+
if (o && u.isVariantOf.linkText && !o.startsWith(u.isVariantOf.linkText))
|
|
2410
2504
|
throw new Error(
|
|
2411
|
-
`Slug was set but the fetched sku does not satisfy the slug condition. slug: ${o}, linkText: ${
|
|
2505
|
+
`Slug was set but the fetched sku does not satisfy the slug condition. slug: ${o}, linkText: ${u.isVariantOf.linkText}`
|
|
2412
2506
|
);
|
|
2413
|
-
return
|
|
2414
|
-
} catch (
|
|
2415
|
-
if (!
|
|
2416
|
-
throw
|
|
2507
|
+
return u;
|
|
2508
|
+
} catch (p) {
|
|
2509
|
+
if (!Zr(p))
|
|
2510
|
+
throw p;
|
|
2417
2511
|
if (o == null)
|
|
2418
|
-
throw new
|
|
2419
|
-
const
|
|
2420
|
-
if (
|
|
2512
|
+
throw new T("Missing slug or id");
|
|
2513
|
+
const u = await c.catalog.portal.pagetype(`${o}/p`);
|
|
2514
|
+
if (u.pageType !== "Product" || !u.id)
|
|
2421
2515
|
throw new L(`No product found for slug ${o}`);
|
|
2422
|
-
const
|
|
2516
|
+
const h = await l.fetchProduct({
|
|
2423
2517
|
field: "id",
|
|
2424
|
-
value: String(
|
|
2518
|
+
value: String(u.id)
|
|
2425
2519
|
}).catch(() => null);
|
|
2426
|
-
if (!
|
|
2427
|
-
throw new L(`No product found for id ${
|
|
2428
|
-
const
|
|
2429
|
-
return
|
|
2520
|
+
if (!h)
|
|
2521
|
+
throw new L(`No product found for id ${u.id}`);
|
|
2522
|
+
const S = re(h.items);
|
|
2523
|
+
return N(S, h);
|
|
2430
2524
|
}
|
|
2431
2525
|
},
|
|
2432
2526
|
collection: (e, { slug: n }, t) => {
|
|
@@ -2443,25 +2537,25 @@ const Fr = (e, n) => {
|
|
|
2443
2537
|
selectedFacets: a,
|
|
2444
2538
|
sponsoredCount: o
|
|
2445
2539
|
}, s) => {
|
|
2446
|
-
const c = Fe(a),
|
|
2447
|
-
c &&
|
|
2448
|
-
const
|
|
2449
|
-
page: Math.ceil(
|
|
2540
|
+
const c = Fe(a), l = ke(a), p = Yt(a);
|
|
2541
|
+
c && he(s, c), l && fe(s, l);
|
|
2542
|
+
const u = t ? Number(t) : 0, h = {
|
|
2543
|
+
page: Math.ceil(u / n) || 0,
|
|
2450
2544
|
count: n,
|
|
2451
2545
|
query: i ?? void 0,
|
|
2452
|
-
sort:
|
|
2546
|
+
sort: ze[r ?? "score_desc"] ?? ze.score_desc,
|
|
2453
2547
|
selectedFacets: a?.flatMap(Te) ?? [],
|
|
2454
2548
|
sponsoredCount: o ?? void 0
|
|
2455
2549
|
};
|
|
2456
|
-
if (
|
|
2457
|
-
const
|
|
2458
|
-
type: rn[
|
|
2459
|
-
productId:
|
|
2460
|
-
})).map((
|
|
2461
|
-
products:
|
|
2462
|
-
recordsFiltered:
|
|
2550
|
+
if (p) {
|
|
2551
|
+
const d = (await s.clients.commerce.catalog.products.crossselling({
|
|
2552
|
+
type: rn[p.key],
|
|
2553
|
+
productId: p.value
|
|
2554
|
+
})).map((m) => m.productId).slice(0, n), g = s.clients.search.productsByIdentifier({ field: "id", values: d }).then((m) => ({
|
|
2555
|
+
products: m,
|
|
2556
|
+
recordsFiltered: m.length,
|
|
2463
2557
|
pagination: {
|
|
2464
|
-
count:
|
|
2558
|
+
count: m.length,
|
|
2465
2559
|
current: { index: 0, proxyURL: "" },
|
|
2466
2560
|
before: [],
|
|
2467
2561
|
after: [],
|
|
@@ -2480,10 +2574,10 @@ const Fr = (e, n) => {
|
|
|
2480
2574
|
fuzzy: "0",
|
|
2481
2575
|
searchId: ""
|
|
2482
2576
|
}));
|
|
2483
|
-
return { searchArgs:
|
|
2577
|
+
return { searchArgs: h, productSearchPromise: g };
|
|
2484
2578
|
}
|
|
2485
|
-
const
|
|
2486
|
-
return { searchArgs:
|
|
2579
|
+
const S = s.clients.search.products(h);
|
|
2580
|
+
return { searchArgs: h, productSearchPromise: S };
|
|
2487
2581
|
},
|
|
2488
2582
|
allProducts: async (e, { first: n, after: t }, r) => {
|
|
2489
2583
|
const {
|
|
@@ -2492,7 +2586,7 @@ const Fr = (e, n) => {
|
|
|
2492
2586
|
page: Math.ceil(a / n),
|
|
2493
2587
|
count: n
|
|
2494
2588
|
}), s = o.products.flatMap(
|
|
2495
|
-
(c) => c.items.map((
|
|
2589
|
+
(c) => c.items.map((l) => N(l, c))
|
|
2496
2590
|
).filter((c) => c.sellers.length > 0);
|
|
2497
2591
|
return {
|
|
2498
2592
|
pageInfo: {
|
|
@@ -2503,9 +2597,9 @@ const Fr = (e, n) => {
|
|
|
2503
2597
|
totalCount: o.recordsFiltered
|
|
2504
2598
|
},
|
|
2505
2599
|
// after + index is bigger than after+first itself because of the array flat() above
|
|
2506
|
-
edges: s.map((c,
|
|
2600
|
+
edges: s.map((c, l) => ({
|
|
2507
2601
|
node: c,
|
|
2508
|
-
cursor: (a +
|
|
2602
|
+
cursor: (a + l).toString()
|
|
2509
2603
|
}))
|
|
2510
2604
|
};
|
|
2511
2605
|
},
|
|
@@ -2517,7 +2611,7 @@ const Fr = (e, n) => {
|
|
|
2517
2611
|
field: "id",
|
|
2518
2612
|
values: n
|
|
2519
2613
|
})).flatMap(
|
|
2520
|
-
(a) => a.items.map((o) =>
|
|
2614
|
+
(a) => a.items.map((o) => N(o, a))
|
|
2521
2615
|
).filter(
|
|
2522
2616
|
(a) => n.includes(a.itemId) && a.sellers.length > 0
|
|
2523
2617
|
) : [];
|
|
@@ -2528,28 +2622,28 @@ const Fr = (e, n) => {
|
|
|
2528
2622
|
} = r, a = t ? Number(t) : 0, [o, s] = await Promise.all([
|
|
2529
2623
|
i.catalog.brand.list(),
|
|
2530
2624
|
i.catalog.category.tree()
|
|
2531
|
-
]), c = [],
|
|
2532
|
-
c.push({ ...
|
|
2533
|
-
for (const
|
|
2534
|
-
|
|
2625
|
+
]), c = [], l = (h, S) => {
|
|
2626
|
+
c.push({ ...h, level: S });
|
|
2627
|
+
for (const b of h.children)
|
|
2628
|
+
l(b, S + 1);
|
|
2535
2629
|
};
|
|
2536
|
-
for (const
|
|
2537
|
-
|
|
2538
|
-
const
|
|
2539
|
-
...o.filter((
|
|
2630
|
+
for (const h of s)
|
|
2631
|
+
l(h, 0);
|
|
2632
|
+
const u = [
|
|
2633
|
+
...o.filter((h) => h.isActive).map((h) => ({ ...h, type: "brand" })),
|
|
2540
2634
|
...c
|
|
2541
|
-
].filter((
|
|
2635
|
+
].filter((h) => !!tn.slug(h, null, r, null));
|
|
2542
2636
|
return {
|
|
2543
2637
|
pageInfo: {
|
|
2544
|
-
hasNextPage:
|
|
2638
|
+
hasNextPage: u.length - a > n,
|
|
2545
2639
|
hasPreviousPage: a > 0,
|
|
2546
2640
|
startCursor: "0",
|
|
2547
|
-
endCursor: (Math.min(n,
|
|
2548
|
-
totalCount:
|
|
2641
|
+
endCursor: (Math.min(n, u.length - a) - 1).toString(),
|
|
2642
|
+
totalCount: u.length
|
|
2549
2643
|
},
|
|
2550
|
-
edges:
|
|
2551
|
-
node:
|
|
2552
|
-
cursor: (a +
|
|
2644
|
+
edges: u.slice(a, a + n).map((h, S) => ({
|
|
2645
|
+
node: h,
|
|
2646
|
+
cursor: (a + S).toString()
|
|
2553
2647
|
}))
|
|
2554
2648
|
};
|
|
2555
2649
|
},
|
|
@@ -2588,10 +2682,10 @@ const Fr = (e, n) => {
|
|
|
2588
2682
|
geoCoordinates: t,
|
|
2589
2683
|
country: r,
|
|
2590
2684
|
salesChannel: i
|
|
2591
|
-
}))?.[0], { id:
|
|
2685
|
+
}))?.[0], { id: l, sellers: p } = c;
|
|
2592
2686
|
return {
|
|
2593
|
-
id:
|
|
2594
|
-
sellers:
|
|
2687
|
+
id: l,
|
|
2688
|
+
sellers: p
|
|
2595
2689
|
};
|
|
2596
2690
|
},
|
|
2597
2691
|
profile: async (e, { id: n }, t) => {
|
|
@@ -2616,7 +2710,7 @@ const Fr = (e, n) => {
|
|
|
2616
2710
|
userOrder: async (e, { orderId: n }, t) => {
|
|
2617
2711
|
try {
|
|
2618
2712
|
if (!n)
|
|
2619
|
-
throw new
|
|
2713
|
+
throw new T("Missing orderId");
|
|
2620
2714
|
const {
|
|
2621
2715
|
clients: { commerce: r }
|
|
2622
2716
|
} = t, i = await r.oms.userOrder({ orderId: n });
|
|
@@ -2664,7 +2758,7 @@ const Fr = (e, n) => {
|
|
|
2664
2758
|
a = { message: i };
|
|
2665
2759
|
}
|
|
2666
2760
|
const o = a?.message || i;
|
|
2667
|
-
throw
|
|
2761
|
+
throw Xe(r) ? new L(`No order found for id ${n}. ${o}.`) : Wn(r) ? new Y(
|
|
2668
2762
|
`You are forbidden to interact with order with id ${n}. ${o}.`
|
|
2669
2763
|
) : r;
|
|
2670
2764
|
}
|
|
@@ -2698,12 +2792,12 @@ const Fr = (e, n) => {
|
|
|
2698
2792
|
return await Promise.all(
|
|
2699
2793
|
a.map(async (c) => {
|
|
2700
2794
|
try {
|
|
2701
|
-
const [
|
|
2795
|
+
const [l] = await r.masterData.getShopperById({
|
|
2702
2796
|
userId: c
|
|
2703
2797
|
});
|
|
2704
|
-
if (
|
|
2705
|
-
const
|
|
2706
|
-
|
|
2798
|
+
if (l) {
|
|
2799
|
+
const p = [l.firstName, l.lastName].filter(Boolean).join(" ");
|
|
2800
|
+
p && o.set(c, p);
|
|
2707
2801
|
}
|
|
2708
2802
|
} catch {
|
|
2709
2803
|
}
|
|
@@ -2740,18 +2834,18 @@ const Fr = (e, n) => {
|
|
|
2740
2834
|
account: r,
|
|
2741
2835
|
headers: i,
|
|
2742
2836
|
clients: { commerce: a }
|
|
2743
|
-
} = t, s =
|
|
2837
|
+
} = t, s = X(z(i?.cookie ?? "", r))?.userId ?? "", [c, l, p] = await Promise.all([
|
|
2744
2838
|
a.session("").catch(() => null),
|
|
2745
2839
|
s ? a.masterData.getShopperById({ userId: s }).catch(() => null) : Promise.resolve(null),
|
|
2746
2840
|
s ? a.licenseManager.getUserRoles({ userId: s }).catch(() => null) : Promise.resolve(null)
|
|
2747
|
-
]),
|
|
2841
|
+
]), u = l?.[0], h = c?.namespaces.authentication ?? null, S = `${(u?.firstName ?? "").trim()} ${(u?.lastName ?? "").trim()}`.trim();
|
|
2748
2842
|
return {
|
|
2749
|
-
username:
|
|
2750
|
-
name:
|
|
2751
|
-
email:
|
|
2752
|
-
phone:
|
|
2753
|
-
role:
|
|
2754
|
-
orgUnit:
|
|
2843
|
+
username: h?.storeUserEmail?.value ?? "",
|
|
2844
|
+
name: S,
|
|
2845
|
+
email: h?.storeUserEmail?.value ?? "",
|
|
2846
|
+
phone: u?.phone ?? "",
|
|
2847
|
+
role: p?.Roles?.map((b) => b.Name) ?? [],
|
|
2848
|
+
orgUnit: h?.unitName?.value ?? ""
|
|
2755
2849
|
};
|
|
2756
2850
|
},
|
|
2757
2851
|
// If isRepresentative, return b2b information.
|
|
@@ -2761,20 +2855,20 @@ const Fr = (e, n) => {
|
|
|
2761
2855
|
account: r,
|
|
2762
2856
|
headers: i,
|
|
2763
2857
|
clients: { commerce: a }
|
|
2764
|
-
} = t, o =
|
|
2858
|
+
} = t, o = X(z(i?.cookie ?? "", r));
|
|
2765
2859
|
if (!o?.userId)
|
|
2766
2860
|
return null;
|
|
2767
2861
|
if (o?.isRepresentative) {
|
|
2768
2862
|
const c = await a.session("").catch(() => null);
|
|
2769
2863
|
if (!c)
|
|
2770
2864
|
return null;
|
|
2771
|
-
const
|
|
2865
|
+
const l = c.namespaces.profile ?? null, p = await a.masterData.getContractById({
|
|
2866
|
+
contractId: l?.id?.value ?? ""
|
|
2867
|
+
});
|
|
2772
2868
|
return {
|
|
2773
|
-
name: (
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
email: d?.email?.value || "",
|
|
2777
|
-
id: d?.id?.value || ""
|
|
2869
|
+
name: mn(p, l) || "",
|
|
2870
|
+
email: l?.email?.value || "",
|
|
2871
|
+
id: l?.id?.value || ""
|
|
2778
2872
|
// createdAt: '',
|
|
2779
2873
|
};
|
|
2780
2874
|
}
|
|
@@ -2788,6 +2882,32 @@ const Fr = (e, n) => {
|
|
|
2788
2882
|
// createdAt: '',
|
|
2789
2883
|
};
|
|
2790
2884
|
},
|
|
2885
|
+
// only b2b users
|
|
2886
|
+
// Contract list from VTEX session `shopper.availableContracts`.
|
|
2887
|
+
availableContracts: async (e, { orgUnitId: n }, t) => {
|
|
2888
|
+
if (!n)
|
|
2889
|
+
throw new T("Missing orgUnitId");
|
|
2890
|
+
const {
|
|
2891
|
+
account: r,
|
|
2892
|
+
headers: i,
|
|
2893
|
+
clients: { commerce: a }
|
|
2894
|
+
} = t, o = await a.session("").catch(() => null), s = z(i?.cookie ?? "", r);
|
|
2895
|
+
let c = null;
|
|
2896
|
+
try {
|
|
2897
|
+
c = s ? X(s) : null;
|
|
2898
|
+
} catch {
|
|
2899
|
+
c = null;
|
|
2900
|
+
}
|
|
2901
|
+
const l = o?.namespaces.authentication?.unitId?.value?.trim() ?? c?.unitId?.trim() ?? "";
|
|
2902
|
+
if (!l || l !== n)
|
|
2903
|
+
throw new Y(
|
|
2904
|
+
"You are not allowed to list contracts for this organization unit"
|
|
2905
|
+
);
|
|
2906
|
+
const p = Ar(
|
|
2907
|
+
o?.namespaces.shopper
|
|
2908
|
+
), u = Ur(o) || c?.customerId?.trim() || "";
|
|
2909
|
+
return Er(p, u);
|
|
2910
|
+
},
|
|
2791
2911
|
pickupPoints: async (e, { geoCoordinates: n }, t) => {
|
|
2792
2912
|
const {
|
|
2793
2913
|
clients: { commerce: r }
|
|
@@ -2796,9 +2916,10 @@ const Fr = (e, n) => {
|
|
|
2796
2916
|
geoCoordinates: n
|
|
2797
2917
|
});
|
|
2798
2918
|
},
|
|
2799
|
-
orderEntryOperation:
|
|
2800
|
-
orderFormItems:
|
|
2801
|
-
|
|
2919
|
+
orderEntryOperation: Hr,
|
|
2920
|
+
orderFormItems: Xr,
|
|
2921
|
+
recommendations: Qr
|
|
2922
|
+
}, ni = {
|
|
2802
2923
|
reviewRating: () => ({
|
|
2803
2924
|
ratingValue: 5,
|
|
2804
2925
|
bestRating: 5
|
|
@@ -2806,35 +2927,35 @@ const Fr = (e, n) => {
|
|
|
2806
2927
|
author: () => ({
|
|
2807
2928
|
name: ""
|
|
2808
2929
|
})
|
|
2809
|
-
},
|
|
2930
|
+
}, ti = (e, n, t) => n ? e.key === "category-1" : t ? e.key === "brand" : !1, ri = {
|
|
2810
2931
|
suggestions: async (e, n, t) => {
|
|
2811
2932
|
const {
|
|
2812
2933
|
clients: { search: r }
|
|
2813
2934
|
} = t, { searchArgs: i } = e;
|
|
2814
2935
|
if (!i.query)
|
|
2815
2936
|
return {
|
|
2816
|
-
terms: (await r.topSearches()).searches.map((
|
|
2817
|
-
value:
|
|
2818
|
-
count:
|
|
2937
|
+
terms: (await r.topSearches()).searches.map((u) => ({
|
|
2938
|
+
value: u.term,
|
|
2939
|
+
count: u.count
|
|
2819
2940
|
})),
|
|
2820
2941
|
products: []
|
|
2821
2942
|
};
|
|
2822
2943
|
const { productSearchPromise: a } = e, [o, s] = await Promise.all([
|
|
2823
2944
|
r.suggestedTerms(i),
|
|
2824
2945
|
a
|
|
2825
|
-
]), c = s.products.map((
|
|
2826
|
-
const
|
|
2827
|
-
return
|
|
2828
|
-
}).filter((
|
|
2946
|
+
]), c = s.products.map((p) => {
|
|
2947
|
+
const u = re(p.items);
|
|
2948
|
+
return u && N(u, p);
|
|
2949
|
+
}).filter((p) => !!p), { searches: l } = o;
|
|
2829
2950
|
return {
|
|
2830
|
-
terms:
|
|
2951
|
+
terms: l.map((p) => ({ value: p.term, count: p.count })),
|
|
2831
2952
|
products: c
|
|
2832
2953
|
};
|
|
2833
2954
|
},
|
|
2834
2955
|
products: async ({ productSearchPromise: e }) => {
|
|
2835
2956
|
const n = await e, t = n.products.map((r) => {
|
|
2836
|
-
const i =
|
|
2837
|
-
return i &&
|
|
2957
|
+
const i = re(r.items);
|
|
2958
|
+
return i && N(i, r);
|
|
2838
2959
|
}).filter((r) => !!r);
|
|
2839
2960
|
return {
|
|
2840
2961
|
pageInfo: {
|
|
@@ -2857,7 +2978,7 @@ const Fr = (e, n) => {
|
|
|
2857
2978
|
t.storage.searchArgs = e;
|
|
2858
2979
|
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;
|
|
2859
2980
|
return i.filter(
|
|
2860
|
-
(
|
|
2981
|
+
(l) => !a || !ti(l, o, s)
|
|
2861
2982
|
);
|
|
2862
2983
|
},
|
|
2863
2984
|
metadata: async ({ productSearchPromise: e }) => {
|
|
@@ -2869,12 +2990,12 @@ const Fr = (e, n) => {
|
|
|
2869
2990
|
};
|
|
2870
2991
|
},
|
|
2871
2992
|
searchId: async ({ productSearchPromise: e }) => (await e).searchId
|
|
2872
|
-
},
|
|
2993
|
+
}, ii = {
|
|
2873
2994
|
title: ({ title: e }) => e ?? "",
|
|
2874
2995
|
description: ({ description: e }) => e ?? "",
|
|
2875
2996
|
canonical: ({ canonical: e }) => e ?? "",
|
|
2876
2997
|
titleTemplate: () => ""
|
|
2877
|
-
},
|
|
2998
|
+
}, ai = ["bd", "d", "h", "m"], oi = (e) => ai.includes(e), si = {
|
|
2878
2999
|
bd: {
|
|
2879
3000
|
0: "Today",
|
|
2880
3001
|
1: "In 1 business day",
|
|
@@ -2895,29 +3016,29 @@ const Fr = (e, n) => {
|
|
|
2895
3016
|
1: "In 1 minute",
|
|
2896
3017
|
other: "Up to # minutes"
|
|
2897
3018
|
}
|
|
2898
|
-
},
|
|
2899
|
-
const [n, t] = [e.split(/\D+/)[0], e.split(/[0-9]+/)[1]], r = n !== "" && !Number.isNaN(Number(n)), i =
|
|
3019
|
+
}, In = (e) => {
|
|
3020
|
+
const [n, t] = [e.split(/\D+/)[0], e.split(/[0-9]+/)[1]], r = n !== "" && !Number.isNaN(Number(n)), i = oi(t);
|
|
2900
3021
|
if (!r || !i)
|
|
2901
3022
|
return "";
|
|
2902
3023
|
const a = Number(n) < 2 ? Number(n) : "other";
|
|
2903
|
-
return
|
|
2904
|
-
},
|
|
3024
|
+
return si[t][a].replace("#", n) ?? "";
|
|
3025
|
+
}, ci = {
|
|
2905
3026
|
carrier: (e) => e?.friendlyName ?? e?.name ?? "",
|
|
2906
3027
|
price: (e) => e?.price ? e.price / 100 : e?.price,
|
|
2907
|
-
localizedEstimates: (e) => e?.shippingEstimate ?
|
|
2908
|
-
},
|
|
2909
|
-
function
|
|
2910
|
-
const t = `${
|
|
3028
|
+
localizedEstimates: (e) => e?.shippingEstimate ? In(e.shippingEstimate) : ""
|
|
3029
|
+
}, xe = "skuvariation";
|
|
3030
|
+
function Ve(e, n) {
|
|
3031
|
+
const t = `${xe}${n}`.toLowerCase(), r = e.find(
|
|
2911
3032
|
(a) => a.imageLabel === t
|
|
2912
3033
|
);
|
|
2913
3034
|
if (r)
|
|
2914
3035
|
return r;
|
|
2915
3036
|
const i = e.find(
|
|
2916
|
-
(a) => a.imageLabel ===
|
|
3037
|
+
(a) => a.imageLabel === xe
|
|
2917
3038
|
);
|
|
2918
3039
|
return i || e[0];
|
|
2919
3040
|
}
|
|
2920
|
-
function
|
|
3041
|
+
function li(e, n, t) {
|
|
2921
3042
|
const r = {};
|
|
2922
3043
|
return e.forEach((i) => {
|
|
2923
3044
|
const a = i.variations;
|
|
@@ -2925,34 +3046,34 @@ function Kr(e, n, t) {
|
|
|
2925
3046
|
return;
|
|
2926
3047
|
const o = `${n}-${a.find(
|
|
2927
3048
|
(c) => c.name === n
|
|
2928
|
-
)?.values[0] ?? ""}`, s = a.reduce((c,
|
|
3049
|
+
)?.values[0] ?? ""}`, s = a.reduce((c, l) => l.name === n ? c : c + `-${l.name}-${l.values[0]}`, o);
|
|
2929
3050
|
r[s] = `${t}-${i.itemId}`;
|
|
2930
3051
|
}), r;
|
|
2931
3052
|
}
|
|
2932
|
-
function
|
|
3053
|
+
function qe(e) {
|
|
2933
3054
|
const n = {};
|
|
2934
3055
|
return e.forEach((t) => {
|
|
2935
3056
|
n[t.name] = t.values[0];
|
|
2936
3057
|
}), n;
|
|
2937
3058
|
}
|
|
2938
|
-
function
|
|
3059
|
+
function di(e) {
|
|
2939
3060
|
const n = {};
|
|
2940
3061
|
return e?.forEach((t) => {
|
|
2941
3062
|
n[t.field.originalName ?? t.field.name] = t.values.map((r) => r.originalName ?? r.name);
|
|
2942
3063
|
}), n;
|
|
2943
3064
|
}
|
|
2944
|
-
function
|
|
3065
|
+
function ui(e, n) {
|
|
2945
3066
|
return Number.isNaN(Number(e) - Number(n)) ? e < n ? -1 : e > n ? 1 : 0 : Number(e) - Number(n);
|
|
2946
3067
|
}
|
|
2947
|
-
function
|
|
3068
|
+
function pi(e) {
|
|
2948
3069
|
const n = e;
|
|
2949
3070
|
for (const t in e)
|
|
2950
3071
|
e[t].every(
|
|
2951
3072
|
(i) => !Number.isNaN(Number(i.value))
|
|
2952
|
-
) && e[t].sort((i, a) =>
|
|
3073
|
+
) && e[t].sort((i, a) => ui(i.value, a.value));
|
|
2953
3074
|
return n;
|
|
2954
3075
|
}
|
|
2955
|
-
function
|
|
3076
|
+
function gi(e, n, t) {
|
|
2956
3077
|
const r = {}, i = /* @__PURE__ */ new Set();
|
|
2957
3078
|
return e.forEach((a) => {
|
|
2958
3079
|
if (a.variations.length === 0)
|
|
@@ -2965,98 +3086,98 @@ function ti(e, n, t) {
|
|
|
2965
3086
|
if (!o || i.has(c))
|
|
2966
3087
|
return;
|
|
2967
3088
|
i.add(c);
|
|
2968
|
-
const
|
|
3089
|
+
const l = Ve(
|
|
2969
3090
|
a.images,
|
|
2970
3091
|
n
|
|
2971
|
-
),
|
|
2972
|
-
src:
|
|
2973
|
-
alt:
|
|
3092
|
+
), p = {
|
|
3093
|
+
src: l.imageUrl,
|
|
3094
|
+
alt: l.imageLabel ?? "",
|
|
2974
3095
|
label: `${n}: ${o.values[0]}`,
|
|
2975
3096
|
value: o.values[0]
|
|
2976
3097
|
};
|
|
2977
|
-
r[o.name] ? r[o.name].push(
|
|
3098
|
+
r[o.name] ? r[o.name].push(p) : r[o.name] = [p];
|
|
2978
3099
|
return;
|
|
2979
3100
|
}
|
|
2980
3101
|
a.variations.forEach((c) => {
|
|
2981
|
-
const
|
|
2982
|
-
if (i.has(
|
|
3102
|
+
const l = `${c.name}-${c.values[0]}`;
|
|
3103
|
+
if (i.has(l))
|
|
2983
3104
|
return;
|
|
2984
|
-
i.add(
|
|
2985
|
-
const
|
|
3105
|
+
i.add(l);
|
|
3106
|
+
const p = Ve(
|
|
2986
3107
|
a.images,
|
|
2987
3108
|
c.name
|
|
2988
|
-
),
|
|
2989
|
-
src:
|
|
2990
|
-
alt:
|
|
3109
|
+
), u = {
|
|
3110
|
+
src: p.imageUrl,
|
|
3111
|
+
alt: p.imageText ?? "",
|
|
2991
3112
|
label: `${c.name}: ${c.values[0]}`,
|
|
2992
3113
|
value: c.values[0]
|
|
2993
3114
|
};
|
|
2994
|
-
r[c.name] ? r[c.name].push(
|
|
3115
|
+
r[c.name] ? r[c.name].push(u) : r[c.name] = [u];
|
|
2995
3116
|
});
|
|
2996
|
-
}),
|
|
3117
|
+
}), pi(r);
|
|
2997
3118
|
}
|
|
2998
|
-
const
|
|
2999
|
-
activeVariations: (e) =>
|
|
3000
|
-
allVariantsByName: (e) =>
|
|
3001
|
-
slugsMap: (e, n) =>
|
|
3119
|
+
const mi = {
|
|
3120
|
+
activeVariations: (e) => qe(e.variations),
|
|
3121
|
+
allVariantsByName: (e) => di(e.isVariantOf.skuSpecifications),
|
|
3122
|
+
slugsMap: (e, n) => li(
|
|
3002
3123
|
e.isVariantOf.items,
|
|
3003
3124
|
n.dominantVariantName ?? e.variations[0]?.name,
|
|
3004
3125
|
e.isVariantOf.linkText
|
|
3005
3126
|
),
|
|
3006
3127
|
availableVariations: (e, n) => {
|
|
3007
|
-
const t = n.dominantVariantName ?? e.variations[0]?.name, i =
|
|
3008
|
-
return
|
|
3128
|
+
const t = n.dominantVariantName ?? e.variations[0]?.name, i = qe(e.variations)[t];
|
|
3129
|
+
return gi(
|
|
3009
3130
|
e.isVariantOf.items,
|
|
3010
3131
|
t,
|
|
3011
3132
|
i
|
|
3012
3133
|
);
|
|
3013
3134
|
},
|
|
3014
|
-
allVariantProducts: (e) => e.isVariantOf.items.map((n) =>
|
|
3015
|
-
},
|
|
3135
|
+
allVariantProducts: (e) => e.isVariantOf.items.map((n) => N(n, e.isVariantOf))
|
|
3136
|
+
}, hi = {
|
|
3016
3137
|
"pickup-in-point": "Pickup",
|
|
3017
3138
|
delivery: "Delivery",
|
|
3018
3139
|
pickup: "Pickup",
|
|
3019
3140
|
"take-away": "Take away",
|
|
3020
3141
|
"": ""
|
|
3021
|
-
},
|
|
3142
|
+
}, fi = {
|
|
3022
3143
|
deliveryOptionsData: (e) => {
|
|
3023
3144
|
const { shippingData: n, items: t } = e, r = n?.logisticsInfo || [], i = n?.selectedAddresses || n?.availableAddresses || [n?.address], a = r.reduce(
|
|
3024
|
-
(
|
|
3025
|
-
const
|
|
3026
|
-
(
|
|
3027
|
-
),
|
|
3028
|
-
|
|
3029
|
-
),
|
|
3030
|
-
return
|
|
3145
|
+
(l, p) => {
|
|
3146
|
+
const u = p?.selectedSla || "", h = p?.selectedDeliveryChannel || p?.deliveryChannel || "", S = p?.deliveryCompany || "", b = p?.deliveryWindow, d = p?.pickupStoreInfo, g = p?.shippingEstimate || "", m = p?.shippingEstimate ? In(p?.shippingEstimate) : "", y = p?.shippingEstimateDate || "", C = p?.addressId || "", w = p?.itemIndex ?? 0, v = t?.[w], P = v?.seller || "", f = `${u}|${h}|${S}|${P}|${g}|${y}|${C}|${b?.startDateUtc}|${b?.endDateUtc}`, D = i?.find(
|
|
3147
|
+
(_) => _?.addressId === C
|
|
3148
|
+
), A = `${hi[h] || ""} ${m} ${D?.neighborhood ? `to ${D?.neighborhood}` : ""}`.trim(), { taxPriceTagsTotal: U, taxPriceTags: O } = Si(
|
|
3149
|
+
v?.priceTags ?? []
|
|
3150
|
+
), E = (v?.sellingPrice ?? 0) * (v?.quantity ?? 0) + (v?.tax ?? 0) + (U ?? 0);
|
|
3151
|
+
return l[f] || (l[f] = {
|
|
3031
3152
|
// static fields
|
|
3032
|
-
selectedSla:
|
|
3033
|
-
deliveryChannel:
|
|
3034
|
-
deliveryCompany:
|
|
3035
|
-
deliveryWindow:
|
|
3036
|
-
shippingEstimate:
|
|
3037
|
-
shippingEstimateDate:
|
|
3153
|
+
selectedSla: u,
|
|
3154
|
+
deliveryChannel: h,
|
|
3155
|
+
deliveryCompany: S,
|
|
3156
|
+
deliveryWindow: b,
|
|
3157
|
+
shippingEstimate: g,
|
|
3158
|
+
shippingEstimateDate: y,
|
|
3038
3159
|
seller: P,
|
|
3039
|
-
friendlyShippingEstimate:
|
|
3040
|
-
friendlyDeliveryOptionName:
|
|
3041
|
-
address:
|
|
3042
|
-
pickupStoreInfo:
|
|
3160
|
+
friendlyShippingEstimate: m,
|
|
3161
|
+
friendlyDeliveryOptionName: A,
|
|
3162
|
+
address: D,
|
|
3163
|
+
pickupStoreInfo: d,
|
|
3043
3164
|
// dynamic fields
|
|
3044
3165
|
quantityOfDifferentItems: 0,
|
|
3045
3166
|
total: 0,
|
|
3046
3167
|
items: []
|
|
3047
|
-
}),
|
|
3048
|
-
id:
|
|
3049
|
-
uniqueId:
|
|
3050
|
-
name:
|
|
3051
|
-
quantity:
|
|
3052
|
-
price:
|
|
3053
|
-
sellingPrice:
|
|
3054
|
-
imageUrl:
|
|
3055
|
-
taxPriceTags:
|
|
3056
|
-
taxPriceTagsTotal:
|
|
3057
|
-
tax:
|
|
3058
|
-
total:
|
|
3059
|
-
}),
|
|
3168
|
+
}), l[f] && (l[f].items?.push({
|
|
3169
|
+
id: v?.id || "",
|
|
3170
|
+
uniqueId: v?.uniqueId || "",
|
|
3171
|
+
name: v?.name || "",
|
|
3172
|
+
quantity: v?.quantity || 0,
|
|
3173
|
+
price: v?.price || 0,
|
|
3174
|
+
sellingPrice: v?.sellingPrice || 0,
|
|
3175
|
+
imageUrl: v?.imageUrl || "",
|
|
3176
|
+
taxPriceTags: O ?? [],
|
|
3177
|
+
taxPriceTagsTotal: U ?? 0,
|
|
3178
|
+
tax: v?.tax || 0,
|
|
3179
|
+
total: E
|
|
3180
|
+
}), l[f].quantityOfDifferentItems = (l[f].quantityOfDifferentItems ?? 0) + 1, l[f].total = (l[f].total ?? 0) + E), l;
|
|
3060
3181
|
},
|
|
3061
3182
|
{}
|
|
3062
3183
|
), o = Object.values(a), s = n?.contactInformation?.[0], c = {
|
|
@@ -3082,7 +3203,7 @@ const ri = {
|
|
|
3082
3203
|
) || [];
|
|
3083
3204
|
}
|
|
3084
3205
|
};
|
|
3085
|
-
function
|
|
3206
|
+
function Si(e) {
|
|
3086
3207
|
const t = e.filter(
|
|
3087
3208
|
(i) => i?.name?.includes("TAX")
|
|
3088
3209
|
), r = t.reduce(
|
|
@@ -3094,28 +3215,28 @@ function oi(e) {
|
|
|
3094
3215
|
taxPriceTagsTotal: r
|
|
3095
3216
|
};
|
|
3096
3217
|
}
|
|
3097
|
-
const
|
|
3218
|
+
const yi = {
|
|
3098
3219
|
StoreCollection: tn,
|
|
3099
|
-
StoreAggregateOffer:
|
|
3100
|
-
StoreProduct:
|
|
3101
|
-
StoreSeo:
|
|
3102
|
-
StoreFacet:
|
|
3103
|
-
StoreFacetBoolean:
|
|
3104
|
-
StoreFacetRange:
|
|
3105
|
-
StoreFacetValueBoolean:
|
|
3106
|
-
StoreOffer:
|
|
3107
|
-
StoreAggregateRating:
|
|
3108
|
-
StoreReview:
|
|
3109
|
-
StoreProductGroup:
|
|
3110
|
-
StoreSearchResult:
|
|
3111
|
-
StorePropertyValue:
|
|
3112
|
-
SkuVariants:
|
|
3113
|
-
ShippingSLA:
|
|
3114
|
-
UserOrderResult:
|
|
3115
|
-
ObjectOrString:
|
|
3116
|
-
Query:
|
|
3117
|
-
Mutation:
|
|
3118
|
-
},
|
|
3220
|
+
StoreAggregateOffer: qt,
|
|
3221
|
+
StoreProduct: qr,
|
|
3222
|
+
StoreSeo: ii,
|
|
3223
|
+
StoreFacet: Kt,
|
|
3224
|
+
StoreFacetBoolean: Zt,
|
|
3225
|
+
StoreFacetRange: er,
|
|
3226
|
+
StoreFacetValueBoolean: nr,
|
|
3227
|
+
StoreOffer: Br,
|
|
3228
|
+
StoreAggregateRating: jt,
|
|
3229
|
+
StoreReview: ni,
|
|
3230
|
+
StoreProductGroup: Wr,
|
|
3231
|
+
StoreSearchResult: ri,
|
|
3232
|
+
StorePropertyValue: Gr,
|
|
3233
|
+
SkuVariants: mi,
|
|
3234
|
+
ShippingSLA: ci,
|
|
3235
|
+
UserOrderResult: fi,
|
|
3236
|
+
ObjectOrString: Nr,
|
|
3237
|
+
Query: ei,
|
|
3238
|
+
Mutation: Rr
|
|
3239
|
+
}, Ii = () => yi, vi = `"""
|
|
3119
3240
|
Address information.
|
|
3120
3241
|
"""
|
|
3121
3242
|
type Address {
|
|
@@ -3160,7 +3281,7 @@ type Address {
|
|
|
3160
3281
|
"""
|
|
3161
3282
|
geoCoordinates: [Float]
|
|
3162
3283
|
}
|
|
3163
|
-
`,
|
|
3284
|
+
`, Oi = `"""
|
|
3164
3285
|
Advertisement information about a specific product in a campaign
|
|
3165
3286
|
"""
|
|
3166
3287
|
type Advertisement {
|
|
@@ -3185,7 +3306,7 @@ type Advertisement {
|
|
|
3185
3306
|
"""
|
|
3186
3307
|
adResponseId: String!
|
|
3187
3308
|
}
|
|
3188
|
-
`,
|
|
3309
|
+
`, Ci = `"""
|
|
3189
3310
|
Aggregate offer information, for a given SKU that is available to be fulfilled by multiple sellers.
|
|
3190
3311
|
"""
|
|
3191
3312
|
type StoreAggregateOffer {
|
|
@@ -3214,7 +3335,7 @@ type StoreAggregateOffer {
|
|
|
3214
3335
|
"""
|
|
3215
3336
|
offers: [StoreOffer!]!
|
|
3216
3337
|
}
|
|
3217
|
-
`,
|
|
3338
|
+
`, bi = `"""
|
|
3218
3339
|
Average rating, based on multiple ratings or reviews.
|
|
3219
3340
|
"""
|
|
3220
3341
|
type StoreAggregateRating {
|
|
@@ -3227,7 +3348,7 @@ type StoreAggregateRating {
|
|
|
3227
3348
|
"""
|
|
3228
3349
|
reviewCount: Int!
|
|
3229
3350
|
}
|
|
3230
|
-
`,
|
|
3351
|
+
`, wi = `"""
|
|
3231
3352
|
information about the author of a product review or rating.
|
|
3232
3353
|
"""
|
|
3233
3354
|
type StoreAuthor {
|
|
@@ -3236,7 +3357,7 @@ type StoreAuthor {
|
|
|
3236
3357
|
"""
|
|
3237
3358
|
name: String!
|
|
3238
3359
|
}
|
|
3239
|
-
`,
|
|
3360
|
+
`, Di = `"""
|
|
3240
3361
|
Brand of a given product.
|
|
3241
3362
|
"""
|
|
3242
3363
|
type StoreBrand {
|
|
@@ -3245,7 +3366,7 @@ type StoreBrand {
|
|
|
3245
3366
|
"""
|
|
3246
3367
|
name: String!
|
|
3247
3368
|
}
|
|
3248
|
-
`,
|
|
3369
|
+
`, Ai = `"""
|
|
3249
3370
|
Item of a list.
|
|
3250
3371
|
"""
|
|
3251
3372
|
type StoreListItem {
|
|
@@ -3276,7 +3397,7 @@ type StoreBreadcrumbList {
|
|
|
3276
3397
|
"""
|
|
3277
3398
|
numberOfItems: Int!
|
|
3278
3399
|
}
|
|
3279
|
-
`,
|
|
3400
|
+
`, Pi = `"""
|
|
3280
3401
|
Shopping cart message.
|
|
3281
3402
|
"""
|
|
3282
3403
|
type StoreCartMessage {
|
|
@@ -3313,7 +3434,7 @@ input IStoreCart {
|
|
|
3313
3434
|
"""
|
|
3314
3435
|
order: IStoreOrder!
|
|
3315
3436
|
}
|
|
3316
|
-
`,
|
|
3437
|
+
`, Ui = `"""
|
|
3317
3438
|
Product collection type. Possible values are \`Department\`, \`Category\`, \`Brand\`, \`Cluster\`, \`SubCategory\` or \`Collection\`.
|
|
3318
3439
|
"""
|
|
3319
3440
|
enum StoreCollectionType {
|
|
@@ -3396,7 +3517,7 @@ type StoreCollection {
|
|
|
3396
3517
|
"""
|
|
3397
3518
|
type: StoreCollectionType!
|
|
3398
3519
|
}
|
|
3399
|
-
`,
|
|
3520
|
+
`, Ei = `"""
|
|
3400
3521
|
Delivery Promise badge.
|
|
3401
3522
|
"""
|
|
3402
3523
|
type DeliveryPromiseBadge {
|
|
@@ -3405,7 +3526,7 @@ type DeliveryPromiseBadge {
|
|
|
3405
3526
|
"""
|
|
3406
3527
|
typeName: String
|
|
3407
3528
|
}
|
|
3408
|
-
`,
|
|
3529
|
+
`, _i = `union StoreFacet = StoreFacetRange | StoreFacetBoolean
|
|
3409
3530
|
|
|
3410
3531
|
"""
|
|
3411
3532
|
Search facet range information.
|
|
@@ -3482,7 +3603,7 @@ type StoreFacetValueBoolean {
|
|
|
3482
3603
|
"""
|
|
3483
3604
|
quantity: Int
|
|
3484
3605
|
}
|
|
3485
|
-
`,
|
|
3606
|
+
`, Ti = `"""
|
|
3486
3607
|
Image.
|
|
3487
3608
|
"""
|
|
3488
3609
|
type StoreImage {
|
|
@@ -3509,7 +3630,7 @@ input IStoreImage {
|
|
|
3509
3630
|
"""
|
|
3510
3631
|
alternateName: String!
|
|
3511
3632
|
}
|
|
3512
|
-
`,
|
|
3633
|
+
`, Ri = `type Mutation {
|
|
3513
3634
|
"""
|
|
3514
3635
|
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\`.
|
|
3515
3636
|
"""
|
|
@@ -3546,8 +3667,12 @@ input IStoreImage {
|
|
|
3546
3667
|
startOrderEntryOperation(
|
|
3547
3668
|
data: IOrderEntryOperation!
|
|
3548
3669
|
): StoreOrderEntryOperationResult @auth
|
|
3670
|
+
"""
|
|
3671
|
+
Starts an anonymous personalization session for the current shopper.
|
|
3672
|
+
"""
|
|
3673
|
+
startRecommendationSession: Boolean!
|
|
3549
3674
|
}
|
|
3550
|
-
`,
|
|
3675
|
+
`, ki = `"""
|
|
3551
3676
|
Newsletter information.
|
|
3552
3677
|
"""
|
|
3553
3678
|
type PersonNewsletter {
|
|
@@ -3570,8 +3695,8 @@ input IPersonNewsletter {
|
|
|
3570
3695
|
"""
|
|
3571
3696
|
email: String!
|
|
3572
3697
|
}
|
|
3573
|
-
`,
|
|
3574
|
-
`,
|
|
3698
|
+
`, Fi = `scalar ObjectOrString
|
|
3699
|
+
`, Ni = `"""
|
|
3575
3700
|
Offer information.
|
|
3576
3701
|
"""
|
|
3577
3702
|
type StoreOffer {
|
|
@@ -3654,7 +3779,7 @@ input IStoreOffer {
|
|
|
3654
3779
|
"""
|
|
3655
3780
|
quantity: Int!
|
|
3656
3781
|
}
|
|
3657
|
-
`,
|
|
3782
|
+
`, Bi = `"""
|
|
3658
3783
|
Information of a specific order.
|
|
3659
3784
|
"""
|
|
3660
3785
|
type StoreOrder {
|
|
@@ -3689,7 +3814,7 @@ input IStoreOrder {
|
|
|
3689
3814
|
"""
|
|
3690
3815
|
shouldSplitItem: Boolean
|
|
3691
3816
|
}
|
|
3692
|
-
`,
|
|
3817
|
+
`, Li = `"""
|
|
3693
3818
|
Commercial Authorization response.
|
|
3694
3819
|
"""
|
|
3695
3820
|
type CommercialAuthorizationResponse {
|
|
@@ -4088,7 +4213,7 @@ type ProcessOrderAuthorizationRule {
|
|
|
4088
4213
|
"""
|
|
4089
4214
|
rule: CommercialAuthorizationRule!
|
|
4090
4215
|
}
|
|
4091
|
-
`,
|
|
4216
|
+
`, Mi = `"""
|
|
4092
4217
|
Input for uploading a file to the Order Entry Service.
|
|
4093
4218
|
The file is transmitted as a Base64-encoded string so it can travel
|
|
4094
4219
|
through the standard GraphQL JSON pipeline without multipart support.
|
|
@@ -4149,7 +4274,7 @@ type StoreOrderFormCartItem {
|
|
|
4149
4274
|
seller: String!
|
|
4150
4275
|
unitMultiplier: Float
|
|
4151
4276
|
}
|
|
4152
|
-
`,
|
|
4277
|
+
`, $i = `"""
|
|
4153
4278
|
Organization.
|
|
4154
4279
|
"""
|
|
4155
4280
|
type StoreOrganization {
|
|
@@ -4168,7 +4293,25 @@ input IStoreOrganization {
|
|
|
4168
4293
|
"""
|
|
4169
4294
|
identifier: String!
|
|
4170
4295
|
}
|
|
4171
|
-
|
|
4296
|
+
|
|
4297
|
+
"""
|
|
4298
|
+
A commercial contract available to a buyer's Organization Unit.
|
|
4299
|
+
"""
|
|
4300
|
+
type StoreContract {
|
|
4301
|
+
"""
|
|
4302
|
+
Contract identifier (the contract/scope ID associated with the Organization Unit).
|
|
4303
|
+
"""
|
|
4304
|
+
id: ID!
|
|
4305
|
+
"""
|
|
4306
|
+
Human-readable corporate name of the contract (resolved from MasterData).
|
|
4307
|
+
"""
|
|
4308
|
+
corporateName: String!
|
|
4309
|
+
"""
|
|
4310
|
+
Indicates whether this contract is the one currently active in the session.
|
|
4311
|
+
"""
|
|
4312
|
+
isActive: Boolean!
|
|
4313
|
+
}
|
|
4314
|
+
`, zi = `"""
|
|
4172
4315
|
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.
|
|
4173
4316
|
"""
|
|
4174
4317
|
type StorePageInfo {
|
|
@@ -4193,7 +4336,7 @@ type StorePageInfo {
|
|
|
4193
4336
|
"""
|
|
4194
4337
|
totalCount: Int!
|
|
4195
4338
|
}
|
|
4196
|
-
`,
|
|
4339
|
+
`, xi = `"""
|
|
4197
4340
|
Input type for setting a new password.
|
|
4198
4341
|
"""
|
|
4199
4342
|
input ISetPassword {
|
|
@@ -4236,7 +4379,7 @@ type SetPasswordResponse {
|
|
|
4236
4379
|
"""
|
|
4237
4380
|
message: String
|
|
4238
4381
|
}
|
|
4239
|
-
`,
|
|
4382
|
+
`, Vi = `"""
|
|
4240
4383
|
Client profile data.
|
|
4241
4384
|
"""
|
|
4242
4385
|
type StorePerson {
|
|
@@ -4279,7 +4422,7 @@ input IStorePerson {
|
|
|
4279
4422
|
"""
|
|
4280
4423
|
familyName: String!
|
|
4281
4424
|
}
|
|
4282
|
-
`,
|
|
4425
|
+
`, qi = `type PickupPointAddress {
|
|
4283
4426
|
"""
|
|
4284
4427
|
Address city.
|
|
4285
4428
|
"""
|
|
@@ -4358,7 +4501,7 @@ type PickupPoints {
|
|
|
4358
4501
|
"""
|
|
4359
4502
|
pickupPointsHash: String
|
|
4360
4503
|
}
|
|
4361
|
-
`,
|
|
4504
|
+
`, ji = `"""
|
|
4362
4505
|
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.
|
|
4363
4506
|
"""
|
|
4364
4507
|
type StoreProduct {
|
|
@@ -4507,7 +4650,7 @@ input IStoreProduct {
|
|
|
4507
4650
|
"""
|
|
4508
4651
|
additionalProperty: [IStorePropertyValue!]
|
|
4509
4652
|
}
|
|
4510
|
-
`,
|
|
4653
|
+
`, Wi = `"""
|
|
4511
4654
|
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.
|
|
4512
4655
|
"""
|
|
4513
4656
|
type StoreProductGroup {
|
|
@@ -4534,7 +4677,7 @@ type StoreProductGroup {
|
|
|
4534
4677
|
"""
|
|
4535
4678
|
skuVariants: SkuVariants
|
|
4536
4679
|
}
|
|
4537
|
-
`,
|
|
4680
|
+
`, Gi = `type Profile {
|
|
4538
4681
|
"""
|
|
4539
4682
|
Collection of user's address
|
|
4540
4683
|
"""
|
|
@@ -4595,7 +4738,7 @@ type ProfileAddress {
|
|
|
4595
4738
|
"""
|
|
4596
4739
|
geoCoordinate: [Float]
|
|
4597
4740
|
}
|
|
4598
|
-
`,
|
|
4741
|
+
`, Hi = `"""
|
|
4599
4742
|
Properties that can be associated with products and products groups.
|
|
4600
4743
|
"""
|
|
4601
4744
|
type StorePropertyValue {
|
|
@@ -4635,7 +4778,7 @@ input IStorePropertyValue {
|
|
|
4635
4778
|
"""
|
|
4636
4779
|
valueReference: ObjectOrString!
|
|
4637
4780
|
}
|
|
4638
|
-
`,
|
|
4781
|
+
`, Xi = `"""
|
|
4639
4782
|
Each product edge contains a \`node\`, with product information, and a \`cursor\`, that can be used as a reference for pagination.
|
|
4640
4783
|
"""
|
|
4641
4784
|
type StoreProductEdge {
|
|
@@ -5128,6 +5271,18 @@ type Query {
|
|
|
5128
5271
|
@auth
|
|
5129
5272
|
@cacheControl(scope: "private", sMaxAge: 300, staleWhileRevalidate: 3600)
|
|
5130
5273
|
|
|
5274
|
+
"""
|
|
5275
|
+
Lists the commercial contracts associated with the given Organization Unit,
|
|
5276
|
+
resolved to human-readable corporate names. Governed: only contracts associated
|
|
5277
|
+
with the authenticated buyer's Organization Unit are returned.
|
|
5278
|
+
"""
|
|
5279
|
+
availableContracts(
|
|
5280
|
+
"""
|
|
5281
|
+
The Organization Unit identifier whose contracts will be listed.
|
|
5282
|
+
"""
|
|
5283
|
+
orgUnitId: String!
|
|
5284
|
+
): [StoreContract!]! @auth @cacheControl(scope: "private", sMaxAge: 0)
|
|
5285
|
+
|
|
5131
5286
|
"""
|
|
5132
5287
|
Returns whether the current authenticated user belongs to a B2B organization unit.
|
|
5133
5288
|
"""
|
|
@@ -5154,6 +5309,15 @@ type Query {
|
|
|
5154
5309
|
Returns the items in an orderForm by its ID.
|
|
5155
5310
|
"""
|
|
5156
5311
|
orderFormItems(orderFormId: String!): [StoreOrderFormCartItem!]! @auth
|
|
5312
|
+
"""
|
|
5313
|
+
Returns personalized product recommendations for a given campaign.
|
|
5314
|
+
"""
|
|
5315
|
+
recommendations(
|
|
5316
|
+
campaignVrn: String!
|
|
5317
|
+
userId: String
|
|
5318
|
+
products: [String!]
|
|
5319
|
+
): RecommendationResponse!
|
|
5320
|
+
@cacheControl(scope: "private", sMaxAge: 120, staleWhileRevalidate: 3600)
|
|
5157
5321
|
}
|
|
5158
5322
|
|
|
5159
5323
|
type ValidateUserData {
|
|
@@ -5244,7 +5408,7 @@ type StoreAccountProfile {
|
|
|
5244
5408
|
email: String
|
|
5245
5409
|
id: String
|
|
5246
5410
|
}
|
|
5247
|
-
`,
|
|
5411
|
+
`, Yi = `"""
|
|
5248
5412
|
Summary of a quote returned in list results.
|
|
5249
5413
|
"""
|
|
5250
5414
|
type UserQuoteSummary {
|
|
@@ -5309,7 +5473,18 @@ type UserQuoteListPaging {
|
|
|
5309
5473
|
"""
|
|
5310
5474
|
perPage: Int!
|
|
5311
5475
|
}
|
|
5312
|
-
`,
|
|
5476
|
+
`, Ji = `type RecommendationResponse {
|
|
5477
|
+
products: [StoreProduct!]!
|
|
5478
|
+
correlationId: String!
|
|
5479
|
+
campaign: RecommendationCampaign!
|
|
5480
|
+
}
|
|
5481
|
+
|
|
5482
|
+
type RecommendationCampaign {
|
|
5483
|
+
id: String!
|
|
5484
|
+
title: String
|
|
5485
|
+
type: String!
|
|
5486
|
+
}
|
|
5487
|
+
`, Qi = `"""
|
|
5313
5488
|
Information of a given review rating.
|
|
5314
5489
|
"""
|
|
5315
5490
|
type StoreReviewRating {
|
|
@@ -5336,7 +5511,7 @@ type StoreReview {
|
|
|
5336
5511
|
"""
|
|
5337
5512
|
author: StoreAuthor!
|
|
5338
5513
|
}
|
|
5339
|
-
`,
|
|
5514
|
+
`, Ki = `"""
|
|
5340
5515
|
Search Engine Optimization (SEO) tags data.
|
|
5341
5516
|
"""
|
|
5342
5517
|
type StoreSeo {
|
|
@@ -5357,7 +5532,7 @@ type StoreSeo {
|
|
|
5357
5532
|
"""
|
|
5358
5533
|
canonical: String!
|
|
5359
5534
|
}
|
|
5360
|
-
`,
|
|
5535
|
+
`, Zi = `"""
|
|
5361
5536
|
Currency information.
|
|
5362
5537
|
"""
|
|
5363
5538
|
type StoreCurrency {
|
|
@@ -5632,7 +5807,7 @@ input IStoreSession {
|
|
|
5632
5807
|
"""
|
|
5633
5808
|
refreshAfter: String
|
|
5634
5809
|
}
|
|
5635
|
-
`,
|
|
5810
|
+
`, ea = `"""
|
|
5636
5811
|
Shipping Simulation item input.
|
|
5637
5812
|
"""
|
|
5638
5813
|
input IShippingItem {
|
|
@@ -5963,7 +6138,7 @@ type MessageFields {
|
|
|
5963
6138
|
"""
|
|
5964
6139
|
skuName: String
|
|
5965
6140
|
}
|
|
5966
|
-
`,
|
|
6141
|
+
`, na = `type SkuVariants {
|
|
5967
6142
|
"""
|
|
5968
6143
|
SKU property values for the current SKU.
|
|
5969
6144
|
"""
|
|
@@ -6058,7 +6233,7 @@ Example:
|
|
|
6058
6233
|
\`\`\`
|
|
6059
6234
|
"""
|
|
6060
6235
|
scalar FormattedVariants
|
|
6061
|
-
`,
|
|
6236
|
+
`, ta = `"""
|
|
6062
6237
|
Status used to indicate a message type. For instance, a shopping cart informative or error message.
|
|
6063
6238
|
"""
|
|
6064
6239
|
enum StoreStatus {
|
|
@@ -6066,7 +6241,7 @@ enum StoreStatus {
|
|
|
6066
6241
|
WARNING
|
|
6067
6242
|
ERROR
|
|
6068
6243
|
}
|
|
6069
|
-
`,
|
|
6244
|
+
`, ra = `scalar JSONObject
|
|
6070
6245
|
|
|
6071
6246
|
type UserOrder {
|
|
6072
6247
|
orderId: String
|
|
@@ -6890,96 +7065,97 @@ type UserOrderBudgetAllocationLinkedEntity {
|
|
|
6890
7065
|
type: String
|
|
6891
7066
|
id: String
|
|
6892
7067
|
}
|
|
6893
|
-
`,
|
|
6894
|
-
"./address.graphql":
|
|
6895
|
-
"./advertisement.graphql":
|
|
6896
|
-
"./aggregateOffer.graphql":
|
|
6897
|
-
"./aggregateRating.graphql":
|
|
6898
|
-
"./author.graphql":
|
|
6899
|
-
"./brand.graphql":
|
|
6900
|
-
"./breadcrumb.graphql":
|
|
6901
|
-
"./cart.graphql":
|
|
6902
|
-
"./collection.graphql":
|
|
6903
|
-
"./deliveryPromisesBadge.graphql":
|
|
6904
|
-
"./facet.graphql":
|
|
6905
|
-
"./image.graphql":
|
|
6906
|
-
"./mutation.graphql":
|
|
6907
|
-
"./newsletter.graphql":
|
|
6908
|
-
"./objectOrString.graphql":
|
|
6909
|
-
"./offer.graphql":
|
|
6910
|
-
"./order.graphql":
|
|
6911
|
-
"./orderCommercialAuthorizaton.graphql":
|
|
6912
|
-
"./orderEntry.graphql":
|
|
6913
|
-
"./organization.graphql":
|
|
6914
|
-
"./pageInfo.graphql":
|
|
6915
|
-
"./password.graphql":
|
|
6916
|
-
"./person.graphql":
|
|
6917
|
-
"./pickupPoints.graphql":
|
|
6918
|
-
"./product.graphql":
|
|
6919
|
-
"./productGroup.graphql":
|
|
6920
|
-
"./profile.graphql":
|
|
6921
|
-
"./propertyValue.graphql":
|
|
6922
|
-
"./query.graphql":
|
|
6923
|
-
"./quote.graphql":
|
|
6924
|
-
"./
|
|
6925
|
-
"./
|
|
6926
|
-
"./
|
|
6927
|
-
"./
|
|
6928
|
-
"./
|
|
6929
|
-
"./
|
|
6930
|
-
"./
|
|
6931
|
-
|
|
6932
|
-
|
|
6933
|
-
|
|
7068
|
+
`, ia = /* @__PURE__ */ Object.assign({
|
|
7069
|
+
"./address.graphql": vi,
|
|
7070
|
+
"./advertisement.graphql": Oi,
|
|
7071
|
+
"./aggregateOffer.graphql": Ci,
|
|
7072
|
+
"./aggregateRating.graphql": bi,
|
|
7073
|
+
"./author.graphql": wi,
|
|
7074
|
+
"./brand.graphql": Di,
|
|
7075
|
+
"./breadcrumb.graphql": Ai,
|
|
7076
|
+
"./cart.graphql": Pi,
|
|
7077
|
+
"./collection.graphql": Ui,
|
|
7078
|
+
"./deliveryPromisesBadge.graphql": Ei,
|
|
7079
|
+
"./facet.graphql": _i,
|
|
7080
|
+
"./image.graphql": Ti,
|
|
7081
|
+
"./mutation.graphql": Ri,
|
|
7082
|
+
"./newsletter.graphql": ki,
|
|
7083
|
+
"./objectOrString.graphql": Fi,
|
|
7084
|
+
"./offer.graphql": Ni,
|
|
7085
|
+
"./order.graphql": Bi,
|
|
7086
|
+
"./orderCommercialAuthorizaton.graphql": Li,
|
|
7087
|
+
"./orderEntry.graphql": Mi,
|
|
7088
|
+
"./organization.graphql": $i,
|
|
7089
|
+
"./pageInfo.graphql": zi,
|
|
7090
|
+
"./password.graphql": xi,
|
|
7091
|
+
"./person.graphql": Vi,
|
|
7092
|
+
"./pickupPoints.graphql": qi,
|
|
7093
|
+
"./product.graphql": ji,
|
|
7094
|
+
"./productGroup.graphql": Wi,
|
|
7095
|
+
"./profile.graphql": Gi,
|
|
7096
|
+
"./propertyValue.graphql": Hi,
|
|
7097
|
+
"./query.graphql": Xi,
|
|
7098
|
+
"./quote.graphql": Yi,
|
|
7099
|
+
"./recommendation.graphql": Ji,
|
|
7100
|
+
"./review.graphql": Qi,
|
|
7101
|
+
"./seo.graphql": Ki,
|
|
7102
|
+
"./session.graphql": Zi,
|
|
7103
|
+
"./shipping.graphql": ea,
|
|
7104
|
+
"./skuVariants.graphql": na,
|
|
7105
|
+
"./status.graphql": ta,
|
|
7106
|
+
"./userOrder.graphql": ra
|
|
7107
|
+
}), aa = wn(
|
|
7108
|
+
Object.values(ia).map((e) => Dn(e)).reduce(
|
|
7109
|
+
(e, n) => je([e, n], { sort: !0 })
|
|
6934
7110
|
)
|
|
6935
|
-
),
|
|
6936
|
-
|
|
7111
|
+
), oa = aa, wa = async (e) => B.context.with(
|
|
7112
|
+
B.propagation.extract(B.context.active(), e.OTEL),
|
|
6937
7113
|
() => (n) => (n.storage = {
|
|
6938
|
-
channel:
|
|
7114
|
+
channel: ne.parse(e.channel),
|
|
6939
7115
|
flags: e.flags ?? {},
|
|
6940
7116
|
locale: e.locale,
|
|
6941
7117
|
cookies: /* @__PURE__ */ new Map()
|
|
6942
|
-
}, n.clients =
|
|
7118
|
+
}, n.clients = Et(e, n), n.loaders = $t(e, n), n.account = e.account, n.OTEL = e.OTEL, n.discoveryConfig = e.discoveryConfig, n)
|
|
6943
7119
|
);
|
|
6944
|
-
function
|
|
6945
|
-
const e =
|
|
7120
|
+
function sa() {
|
|
7121
|
+
const e = Ii(), n = {};
|
|
6946
7122
|
for (const [t, r] of Object.entries(e))
|
|
6947
7123
|
n[t] = Object.fromEntries(
|
|
6948
|
-
Object.entries(r).map(([i, a]) => typeof a != "function" ? [i, a] : [i,
|
|
7124
|
+
Object.entries(r).map(([i, a]) => typeof a != "function" ? [i, a] : [i, jn(a, `${t}(${i})`)])
|
|
6949
7125
|
);
|
|
6950
7126
|
return n;
|
|
6951
7127
|
}
|
|
6952
|
-
function
|
|
6953
|
-
const t =
|
|
6954
|
-
|
|
6955
|
-
|
|
6956
|
-
])(
|
|
6957
|
-
return e &&
|
|
7128
|
+
function Da(e) {
|
|
7129
|
+
const t = qn([
|
|
7130
|
+
Vn,
|
|
7131
|
+
$n
|
|
7132
|
+
])(sa(), oa);
|
|
7133
|
+
return e && An(e) ? Cn({
|
|
6958
7134
|
schemas: [t, e]
|
|
6959
7135
|
}) : t;
|
|
6960
7136
|
}
|
|
6961
7137
|
export {
|
|
6962
|
-
|
|
6963
|
-
|
|
6964
|
-
|
|
6965
|
-
|
|
6966
|
-
|
|
6967
|
-
|
|
6968
|
-
|
|
6969
|
-
|
|
7138
|
+
$n as AuthDirective,
|
|
7139
|
+
T as BadRequestError,
|
|
7140
|
+
Vn as CacheControlDirective,
|
|
7141
|
+
_n as CommercialAuthorizationStatus,
|
|
7142
|
+
Q as FastStoreError,
|
|
7143
|
+
Y as ForbiddenError,
|
|
7144
|
+
wa as GraphqlVtexContextFactory,
|
|
7145
|
+
Da as GraphqlVtexSchema,
|
|
6970
7146
|
L as NotFoundError,
|
|
6971
7147
|
Tn as StoreCollectionType,
|
|
6972
|
-
|
|
7148
|
+
Rn as StoreFacetType,
|
|
6973
7149
|
kn as StoreSort,
|
|
6974
7150
|
Fn as StoreStatus,
|
|
6975
|
-
|
|
6976
|
-
|
|
6977
|
-
|
|
6978
|
-
|
|
6979
|
-
|
|
6980
|
-
|
|
6981
|
-
|
|
6982
|
-
|
|
6983
|
-
|
|
6984
|
-
|
|
7151
|
+
Z as UnauthorizedError,
|
|
7152
|
+
Nn as UserOrderInvoiceType,
|
|
7153
|
+
Ca as isBadRequestError,
|
|
7154
|
+
Oa as isFastStoreError,
|
|
7155
|
+
Wn as isForbiddenError,
|
|
7156
|
+
Xe as isNotFoundError,
|
|
7157
|
+
ba as isUnauthorizedError,
|
|
7158
|
+
va as stringifyCacheControl,
|
|
7159
|
+
oa as typeDefs,
|
|
7160
|
+
qn as withDirectives
|
|
6985
7161
|
};
|