@01.software/sdk 0.36.0 → 0.37.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +71 -6
- package/dist/analytics/react.cjs +33 -9
- package/dist/analytics/react.cjs.map +1 -1
- package/dist/analytics/react.d.cts +1 -1
- package/dist/analytics/react.d.ts +1 -1
- package/dist/analytics/react.js +33 -9
- package/dist/analytics/react.js.map +1 -1
- package/dist/analytics.cjs +30 -8
- package/dist/analytics.cjs.map +1 -1
- package/dist/analytics.d.cts +6 -0
- package/dist/analytics.d.ts +6 -0
- package/dist/analytics.js +30 -8
- package/dist/analytics.js.map +1 -1
- package/dist/client.cjs +94 -114
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +6 -6
- package/dist/client.d.ts +6 -6
- package/dist/client.js +94 -114
- package/dist/client.js.map +1 -1
- package/dist/{collection-client-Bq5Zd7p7.d.ts → collection-client-DyELGUcL.d.ts} +3 -3
- package/dist/{collection-client-Cv0D2w1Q.d.cts → collection-client-zOmnxwdA.d.cts} +3 -3
- package/dist/{const-DVcM7Ac_.d.cts → const-CK_FPaIn.d.cts} +3 -3
- package/dist/{const-BDUKFP9w.d.ts → const-Dqz05oaG.d.ts} +3 -3
- package/dist/{image-BDz2-AaO.d.cts → image-BDjHp03R.d.cts} +13 -9
- package/dist/{image-BDz2-AaO.d.ts → image-BDjHp03R.d.ts} +13 -9
- package/dist/{index-DTSXUYkr.d.ts → index-DRJs7QIh.d.cts} +9 -6
- package/dist/{index-BHDKJ6B3.d.cts → index-DTqoUZk_.d.ts} +9 -6
- package/dist/index.cjs +172 -132
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -9
- package/dist/index.d.ts +10 -9
- package/dist/index.js +172 -132
- package/dist/index.js.map +1 -1
- package/dist/metadata.cjs +5 -3
- package/dist/metadata.cjs.map +1 -1
- package/dist/metadata.js +5 -3
- package/dist/metadata.js.map +1 -1
- package/dist/{payload-types-BCui2Oml.d.cts → payload-types-CREOjFNT.d.cts} +281 -108
- package/dist/{payload-types-BCui2Oml.d.ts → payload-types-CREOjFNT.d.ts} +281 -108
- package/dist/query.cjs +5 -3
- package/dist/query.cjs.map +1 -1
- package/dist/query.d.cts +5 -5
- package/dist/query.d.ts +5 -5
- package/dist/query.js +5 -3
- package/dist/query.js.map +1 -1
- package/dist/realtime.d.cts +2 -2
- package/dist/realtime.d.ts +2 -2
- package/dist/server.cjs +84 -69
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.cts +7 -7
- package/dist/server.d.ts +7 -7
- package/dist/server.js +84 -69
- package/dist/server.js.map +1 -1
- package/dist/{types-Dib-zdK6.d.cts → types-BWMUr3Zw.d.cts} +195 -71
- package/dist/{types-CEzLf3PX.d.cts → types-BkZNhuBh.d.cts} +1 -1
- package/dist/{types-3qV6sY7T.d.ts → types-CxzWHspI.d.ts} +1 -1
- package/dist/{types-DK9EnLwJ.d.ts → types-DMvVHdb1.d.ts} +195 -71
- package/dist/ui/canvas.cjs +15 -5
- package/dist/ui/canvas.cjs.map +1 -1
- package/dist/ui/canvas.d.cts +1 -1
- package/dist/ui/canvas.d.ts +1 -1
- package/dist/ui/canvas.js +15 -5
- package/dist/ui/canvas.js.map +1 -1
- package/dist/ui/form.d.cts +1 -1
- package/dist/ui/form.d.ts +1 -1
- package/dist/ui/image.cjs +15 -5
- package/dist/ui/image.cjs.map +1 -1
- package/dist/ui/image.d.cts +1 -1
- package/dist/ui/image.d.ts +1 -1
- package/dist/ui/image.js +15 -5
- package/dist/ui/image.js.map +1 -1
- package/dist/ui/video.d.cts +1 -1
- package/dist/ui/video.d.ts +1 -1
- package/dist/webhook.cjs +5 -1
- package/dist/webhook.cjs.map +1 -1
- package/dist/webhook.d.cts +4 -4
- package/dist/webhook.d.ts +4 -4
- package/dist/webhook.js +5 -1
- package/dist/webhook.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -44,6 +44,7 @@ __export(src_exports, {
|
|
|
44
44
|
NotFoundError: () => NotFoundError,
|
|
45
45
|
ORDER_CHANGED_EVENT_TYPE: () => ORDER_CHANGED_EVENT_TYPE,
|
|
46
46
|
OrderApi: () => OrderApi,
|
|
47
|
+
PRODUCT_PLP_FIND_OPTIONS: () => PRODUCT_PLP_FIND_OPTIONS,
|
|
47
48
|
PRODUCT_UPSERT_READONLY_FIELD_REASON: () => PRODUCT_UPSERT_READONLY_FIELD_REASON,
|
|
48
49
|
PRODUCT_UPSERT_UNKNOWN_FIELD_REASON: () => PRODUCT_UPSERT_UNKNOWN_FIELD_REASON,
|
|
49
50
|
PermissionError: () => PermissionError,
|
|
@@ -69,6 +70,7 @@ __export(src_exports, {
|
|
|
69
70
|
createAuthError: () => createAuthError,
|
|
70
71
|
createClient: () => createClient2,
|
|
71
72
|
createCommerceEmailWebhookHandler: () => createCommerceEmailWebhookHandler,
|
|
73
|
+
createCommerceNotificationWebhookHandler: () => createCommerceNotificationWebhookHandler,
|
|
72
74
|
createConflictError: () => createConflictError,
|
|
73
75
|
createCustomerAuthWebhookHandler: () => createCustomerAuthWebhookHandler,
|
|
74
76
|
createNotFoundError: () => createNotFoundError,
|
|
@@ -945,13 +947,15 @@ var HttpClient = class {
|
|
|
945
947
|
};
|
|
946
948
|
|
|
947
949
|
// src/utils/types.ts
|
|
948
|
-
|
|
950
|
+
function resolveRelation(ref) {
|
|
949
951
|
if (typeof ref === "string" || typeof ref === "number" || ref === null || ref === void 0)
|
|
950
952
|
return null;
|
|
951
953
|
return ref;
|
|
952
|
-
}
|
|
954
|
+
}
|
|
953
955
|
|
|
954
956
|
// src/core/metadata/index.ts
|
|
957
|
+
var OPEN_GRAPH_IMAGE_SIZE = "1200";
|
|
958
|
+
var LEGACY_OPEN_GRAPH_IMAGE_SIZE = "1536";
|
|
955
959
|
function extractSeo(doc) {
|
|
956
960
|
const seo = doc.seo ?? {};
|
|
957
961
|
const og = seo.openGraph ?? {};
|
|
@@ -995,7 +999,7 @@ function generateMetadata(input, options) {
|
|
|
995
999
|
function resolveMetaImage(ref) {
|
|
996
1000
|
const image = resolveRelation(ref);
|
|
997
1001
|
if (!image) return null;
|
|
998
|
-
const sized = image.sizes?.[
|
|
1002
|
+
const sized = image.sizes?.[OPEN_GRAPH_IMAGE_SIZE] ?? image.sizes?.[LEGACY_OPEN_GRAPH_IMAGE_SIZE];
|
|
999
1003
|
const url = sized?.url || image.url;
|
|
1000
1004
|
if (!url) return null;
|
|
1001
1005
|
const width = sized?.url ? sized.width : image.width;
|
|
@@ -1127,13 +1131,16 @@ async function parseApiResponse(response, endpoint) {
|
|
|
1127
1131
|
return data;
|
|
1128
1132
|
}
|
|
1129
1133
|
|
|
1130
|
-
// src/core/
|
|
1131
|
-
var
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1134
|
+
// src/core/api/customer-scoped-api.ts
|
|
1135
|
+
var CustomerScopedApi = class {
|
|
1136
|
+
constructor(apiName, options) {
|
|
1137
|
+
if (options.requiresCredential !== false && !options.secretKey && !options.customerToken) {
|
|
1138
|
+
throw createConfigError(
|
|
1139
|
+
`Either secretKey or customerToken is required for ${apiName}.`
|
|
1140
|
+
);
|
|
1141
|
+
}
|
|
1135
1142
|
this.publishableKey = requirePublishableKeyForSecret(
|
|
1136
|
-
|
|
1143
|
+
apiName,
|
|
1137
1144
|
options.publishableKey,
|
|
1138
1145
|
options.secretKey
|
|
1139
1146
|
);
|
|
@@ -1143,6 +1150,44 @@ var CommunityClient = class {
|
|
|
1143
1150
|
this.onUnauthorized = options.onUnauthorized;
|
|
1144
1151
|
this.onRequestId = options.onRequestId;
|
|
1145
1152
|
}
|
|
1153
|
+
async request(endpoint, options) {
|
|
1154
|
+
const token = typeof this.customerToken === "function" ? this.customerToken() : this.customerToken;
|
|
1155
|
+
try {
|
|
1156
|
+
const response = await httpFetch(endpoint, {
|
|
1157
|
+
method: options.method,
|
|
1158
|
+
apiUrl: this.apiUrl,
|
|
1159
|
+
publishableKey: this.publishableKey,
|
|
1160
|
+
secretKey: this.secretKey,
|
|
1161
|
+
customerToken: token ?? void 0,
|
|
1162
|
+
...token && this.onUnauthorized && { onUnauthorized: this.onUnauthorized },
|
|
1163
|
+
...options.body !== void 0 && {
|
|
1164
|
+
body: JSON.stringify(options.body)
|
|
1165
|
+
},
|
|
1166
|
+
...options.headers && { headers: options.headers }
|
|
1167
|
+
});
|
|
1168
|
+
this.onRequestId?.(response.headers.get("x-request-id") ?? null);
|
|
1169
|
+
return parseApiResponse(response, endpoint);
|
|
1170
|
+
} catch (err) {
|
|
1171
|
+
const id = err instanceof SDKError ? err.requestId ?? null : null;
|
|
1172
|
+
this.onRequestId?.(id);
|
|
1173
|
+
throw err;
|
|
1174
|
+
}
|
|
1175
|
+
}
|
|
1176
|
+
};
|
|
1177
|
+
|
|
1178
|
+
// src/core/community/community-client.ts
|
|
1179
|
+
var DEFAULT_POST_LIST_SORT = "-lastActivityAt";
|
|
1180
|
+
var DEFAULT_COMMENT_LIST_SORT = "-createdAt";
|
|
1181
|
+
function unwrapPayloadDoc(value) {
|
|
1182
|
+
if (value && typeof value === "object" && "doc" in value) {
|
|
1183
|
+
return value.doc;
|
|
1184
|
+
}
|
|
1185
|
+
return value;
|
|
1186
|
+
}
|
|
1187
|
+
var CommunityClient = class extends CustomerScopedApi {
|
|
1188
|
+
constructor(options) {
|
|
1189
|
+
super("CommunityClient", { ...options, requiresCredential: false });
|
|
1190
|
+
}
|
|
1146
1191
|
buildQuery(params) {
|
|
1147
1192
|
if (!params) return "";
|
|
1148
1193
|
const entries = Object.entries(params).filter((e) => e[1] !== void 0).map(([k, v]) => [k, String(v)]);
|
|
@@ -1183,27 +1228,14 @@ var CommunityClient = class {
|
|
|
1183
1228
|
return `/api/comments?${urlParams.toString()}`;
|
|
1184
1229
|
}
|
|
1185
1230
|
async execute(endpoint, method, body) {
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
publishableKey: this.publishableKey,
|
|
1192
|
-
secretKey: this.secretKey,
|
|
1193
|
-
customerToken: token ?? void 0,
|
|
1194
|
-
...token && this.onUnauthorized && { onUnauthorized: this.onUnauthorized },
|
|
1195
|
-
...body !== void 0 && { body: JSON.stringify(body) }
|
|
1196
|
-
});
|
|
1197
|
-
this.onRequestId?.(response.headers.get("x-request-id") ?? null);
|
|
1198
|
-
return parseApiResponse(response, endpoint);
|
|
1199
|
-
} catch (err) {
|
|
1200
|
-
const id = err instanceof SDKError ? err.requestId ?? null : null;
|
|
1201
|
-
this.onRequestId?.(id);
|
|
1202
|
-
throw err;
|
|
1203
|
-
}
|
|
1231
|
+
return this.request(endpoint, { method, body });
|
|
1232
|
+
}
|
|
1233
|
+
async executeDoc(endpoint, method, body) {
|
|
1234
|
+
const response = await this.execute(endpoint, method, body);
|
|
1235
|
+
return unwrapPayloadDoc(response);
|
|
1204
1236
|
}
|
|
1205
1237
|
createPost(params) {
|
|
1206
|
-
return this.
|
|
1238
|
+
return this.executeDoc("/api/posts", "POST", params);
|
|
1207
1239
|
}
|
|
1208
1240
|
/**
|
|
1209
1241
|
* Public post feed. Server applies the same visibility contract as
|
|
@@ -1260,7 +1292,7 @@ var CommunityClient = class {
|
|
|
1260
1292
|
if (parentId !== void 0) {
|
|
1261
1293
|
body.parent = parentId;
|
|
1262
1294
|
}
|
|
1263
|
-
return this.
|
|
1295
|
+
return this.executeDoc("/api/comments", "POST", body);
|
|
1264
1296
|
}
|
|
1265
1297
|
/**
|
|
1266
1298
|
* List comments for a post.
|
|
@@ -1298,7 +1330,7 @@ var CommunityClient = class {
|
|
|
1298
1330
|
}
|
|
1299
1331
|
updateComment(params) {
|
|
1300
1332
|
const { commentId, body } = params;
|
|
1301
|
-
return this.
|
|
1333
|
+
return this.executeDoc(
|
|
1302
1334
|
`/api/comments/${commentId}`,
|
|
1303
1335
|
"PATCH",
|
|
1304
1336
|
{ body }
|
|
@@ -1329,7 +1361,7 @@ var CommunityClient = class {
|
|
|
1329
1361
|
400
|
|
1330
1362
|
);
|
|
1331
1363
|
}
|
|
1332
|
-
return this.
|
|
1364
|
+
return this.executeDoc("/api/reactions", "POST", {
|
|
1333
1365
|
post: postId,
|
|
1334
1366
|
type: reactionType
|
|
1335
1367
|
});
|
|
@@ -1351,7 +1383,7 @@ var CommunityClient = class {
|
|
|
1351
1383
|
400
|
|
1352
1384
|
);
|
|
1353
1385
|
}
|
|
1354
|
-
return this.
|
|
1386
|
+
return this.executeDoc("/api/reactions", "POST", {
|
|
1355
1387
|
comment: commentId,
|
|
1356
1388
|
type: reactionType
|
|
1357
1389
|
});
|
|
@@ -1383,7 +1415,7 @@ var CommunityClient = class {
|
|
|
1383
1415
|
}
|
|
1384
1416
|
// Bookmarks
|
|
1385
1417
|
addBookmark(params) {
|
|
1386
|
-
return this.
|
|
1418
|
+
return this.executeDoc("/api/bookmarks", "POST", {
|
|
1387
1419
|
post: params.postId
|
|
1388
1420
|
});
|
|
1389
1421
|
}
|
|
@@ -1634,43 +1666,12 @@ var CustomerNamespace = class {
|
|
|
1634
1666
|
};
|
|
1635
1667
|
|
|
1636
1668
|
// src/core/api/cart-api.ts
|
|
1637
|
-
var CartApi = class {
|
|
1669
|
+
var CartApi = class extends CustomerScopedApi {
|
|
1638
1670
|
constructor(options) {
|
|
1639
|
-
|
|
1640
|
-
throw createConfigError(
|
|
1641
|
-
"Either secretKey or customerToken is required for CartApi."
|
|
1642
|
-
);
|
|
1643
|
-
}
|
|
1644
|
-
this.publishableKey = requirePublishableKeyForSecret(
|
|
1645
|
-
"CartApi",
|
|
1646
|
-
options.publishableKey,
|
|
1647
|
-
options.secretKey
|
|
1648
|
-
);
|
|
1649
|
-
this.secretKey = options.secretKey;
|
|
1650
|
-
this.apiUrl = options.apiUrl;
|
|
1651
|
-
this.customerToken = options.customerToken;
|
|
1652
|
-
this.onUnauthorized = options.onUnauthorized;
|
|
1653
|
-
this.onRequestId = options.onRequestId;
|
|
1671
|
+
super("CartApi", options);
|
|
1654
1672
|
}
|
|
1655
1673
|
async execute(endpoint, method, body) {
|
|
1656
|
-
|
|
1657
|
-
try {
|
|
1658
|
-
const response = await httpFetch(endpoint, {
|
|
1659
|
-
method,
|
|
1660
|
-
apiUrl: this.apiUrl,
|
|
1661
|
-
publishableKey: this.publishableKey,
|
|
1662
|
-
secretKey: this.secretKey,
|
|
1663
|
-
customerToken: token ?? void 0,
|
|
1664
|
-
...token && this.onUnauthorized && { onUnauthorized: this.onUnauthorized },
|
|
1665
|
-
...body !== void 0 && { body: JSON.stringify(body) }
|
|
1666
|
-
});
|
|
1667
|
-
this.onRequestId?.(response.headers.get("x-request-id") ?? null);
|
|
1668
|
-
return parseApiResponse(response, endpoint);
|
|
1669
|
-
} catch (err) {
|
|
1670
|
-
const id = err instanceof SDKError ? err.requestId ?? null : null;
|
|
1671
|
-
this.onRequestId?.(id);
|
|
1672
|
-
throw err;
|
|
1673
|
-
}
|
|
1674
|
+
return this.request(endpoint, { method, body });
|
|
1674
1675
|
}
|
|
1675
1676
|
getCart(cartId) {
|
|
1676
1677
|
return this.execute(`/api/carts/${cartId}`, "GET");
|
|
@@ -1894,15 +1895,24 @@ function splitIdempotencyKey(params) {
|
|
|
1894
1895
|
const { idempotencyKey, ...body } = params;
|
|
1895
1896
|
return { body, idempotencyKey };
|
|
1896
1897
|
}
|
|
1898
|
+
function normalizeCreateOrderBody(params) {
|
|
1899
|
+
if (params.items !== void 0) {
|
|
1900
|
+
const { idempotencyKey: _idempotencyKey2, items, ...rest } = params;
|
|
1901
|
+
return { ...rest, orderItems: items };
|
|
1902
|
+
}
|
|
1903
|
+
const { idempotencyKey: _idempotencyKey, ...body } = params;
|
|
1904
|
+
return body;
|
|
1905
|
+
}
|
|
1897
1906
|
var OrderApi = class extends BaseApi {
|
|
1898
1907
|
constructor(options) {
|
|
1899
1908
|
super("OrderApi", options);
|
|
1900
1909
|
}
|
|
1901
1910
|
createOrder(params) {
|
|
1902
|
-
const {
|
|
1911
|
+
const { idempotencyKey } = params;
|
|
1912
|
+
const normalizedBody = normalizeCreateOrderBody(params);
|
|
1903
1913
|
return this.request(
|
|
1904
1914
|
"/api/orders/create",
|
|
1905
|
-
|
|
1915
|
+
normalizedBody,
|
|
1906
1916
|
idempotencyRequestOptions(idempotencyKey)
|
|
1907
1917
|
);
|
|
1908
1918
|
}
|
|
@@ -1964,6 +1974,12 @@ var OrderApi = class extends BaseApi {
|
|
|
1964
1974
|
idempotencyRequestOptions(idempotencyKey)
|
|
1965
1975
|
);
|
|
1966
1976
|
}
|
|
1977
|
+
prepareFulfillmentOrder(params) {
|
|
1978
|
+
return this.request(
|
|
1979
|
+
"/api/fulfillment-orders/prepare-fulfillment-order",
|
|
1980
|
+
params
|
|
1981
|
+
);
|
|
1982
|
+
}
|
|
1967
1983
|
updateFulfillment(params) {
|
|
1968
1984
|
return this.request("/api/orders/update-fulfillment", params);
|
|
1969
1985
|
}
|
|
@@ -1995,6 +2011,18 @@ var OrderApi = class extends BaseApi {
|
|
|
1995
2011
|
};
|
|
1996
2012
|
|
|
1997
2013
|
// src/core/commerce/commerce-client.ts
|
|
2014
|
+
var BrowserCommerceApi = class extends CustomerScopedApi {
|
|
2015
|
+
post(endpoint, body, requestOptions) {
|
|
2016
|
+
return this.request(endpoint, {
|
|
2017
|
+
method: "POST",
|
|
2018
|
+
body,
|
|
2019
|
+
headers: requestOptions?.headers
|
|
2020
|
+
});
|
|
2021
|
+
}
|
|
2022
|
+
get(endpoint) {
|
|
2023
|
+
return this.request(endpoint, { method: "GET" });
|
|
2024
|
+
}
|
|
2025
|
+
};
|
|
1998
2026
|
var CommerceClient = class {
|
|
1999
2027
|
constructor(options) {
|
|
2000
2028
|
const cartApi = new CartApi({
|
|
@@ -2004,52 +2032,21 @@ var CommerceClient = class {
|
|
|
2004
2032
|
onUnauthorized: options.onUnauthorized,
|
|
2005
2033
|
onRequestId: options.onRequestId
|
|
2006
2034
|
});
|
|
2007
|
-
const
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
customerToken: token ?? void 0,
|
|
2015
|
-
...token && options.onUnauthorized && { onUnauthorized: options.onUnauthorized },
|
|
2016
|
-
body: JSON.stringify(body),
|
|
2017
|
-
...requestOptions?.headers && { headers: requestOptions.headers }
|
|
2018
|
-
});
|
|
2019
|
-
options.onRequestId?.(response.headers.get("x-request-id") ?? null);
|
|
2020
|
-
return parseApiResponse(response, endpoint);
|
|
2021
|
-
} catch (err) {
|
|
2022
|
-
const id = err instanceof SDKError ? err.requestId ?? null : null;
|
|
2023
|
-
options.onRequestId?.(id);
|
|
2024
|
-
throw err;
|
|
2025
|
-
}
|
|
2026
|
-
};
|
|
2027
|
-
const executeGet = async (endpoint) => {
|
|
2028
|
-
const token = options.customerToken();
|
|
2029
|
-
try {
|
|
2030
|
-
const response = await httpFetch(endpoint, {
|
|
2031
|
-
method: "GET",
|
|
2032
|
-
apiUrl: options.apiUrl,
|
|
2033
|
-
publishableKey: options.publishableKey,
|
|
2034
|
-
customerToken: token ?? void 0,
|
|
2035
|
-
...token && options.onUnauthorized && { onUnauthorized: options.onUnauthorized }
|
|
2036
|
-
});
|
|
2037
|
-
options.onRequestId?.(response.headers.get("x-request-id") ?? null);
|
|
2038
|
-
return parseApiResponse(response, endpoint);
|
|
2039
|
-
} catch (err) {
|
|
2040
|
-
const id = err instanceof SDKError ? err.requestId ?? null : null;
|
|
2041
|
-
options.onRequestId?.(id);
|
|
2042
|
-
throw err;
|
|
2043
|
-
}
|
|
2044
|
-
};
|
|
2035
|
+
const api = new BrowserCommerceApi("CommerceClient", {
|
|
2036
|
+
publishableKey: options.publishableKey,
|
|
2037
|
+
apiUrl: options.apiUrl,
|
|
2038
|
+
customerToken: options.customerToken,
|
|
2039
|
+
onUnauthorized: options.onUnauthorized,
|
|
2040
|
+
onRequestId: options.onRequestId
|
|
2041
|
+
});
|
|
2045
2042
|
this.product = {
|
|
2046
|
-
stockCheck: (params) =>
|
|
2047
|
-
stockSnapshot: (params) =>
|
|
2048
|
-
listingGroups: (params) =>
|
|
2049
|
-
listingGroupsCatalog: (params) =>
|
|
2043
|
+
stockCheck: (params) => api.post("/api/products/stock-check", params),
|
|
2044
|
+
stockSnapshot: (params) => api.get(stockSnapshotQuery(params)),
|
|
2045
|
+
listingGroups: (params) => api.get(listingGroupsQuery(params)),
|
|
2046
|
+
listingGroupsCatalog: (params) => api.get(listingGroupsCatalogQuery(params)),
|
|
2050
2047
|
detail: async (params) => {
|
|
2051
2048
|
try {
|
|
2052
|
-
const product = await
|
|
2049
|
+
const product = await api.get(productDetailQuery(params));
|
|
2053
2050
|
return { found: true, product };
|
|
2054
2051
|
} catch (err) {
|
|
2055
2052
|
const notFoundResult = productDetailResultFromError(err);
|
|
@@ -2059,7 +2056,7 @@ var CommerceClient = class {
|
|
|
2059
2056
|
},
|
|
2060
2057
|
detailCatalog: async (params) => {
|
|
2061
2058
|
try {
|
|
2062
|
-
const product = await
|
|
2059
|
+
const product = await api.get(
|
|
2063
2060
|
productDetailCatalogQuery(params)
|
|
2064
2061
|
);
|
|
2065
2062
|
return { found: true, product };
|
|
@@ -2082,7 +2079,7 @@ var CommerceClient = class {
|
|
|
2082
2079
|
this.orders = {
|
|
2083
2080
|
checkout: (params) => {
|
|
2084
2081
|
const { body, idempotencyKey } = splitIdempotencyKey(params);
|
|
2085
|
-
return
|
|
2082
|
+
return api.post(
|
|
2086
2083
|
"/api/orders/checkout",
|
|
2087
2084
|
body,
|
|
2088
2085
|
idempotencyRequestOptions(idempotencyKey)
|
|
@@ -2091,10 +2088,10 @@ var CommerceClient = class {
|
|
|
2091
2088
|
listMine: (params) => options.customerAuth.getMyOrders(params)
|
|
2092
2089
|
};
|
|
2093
2090
|
this.discounts = {
|
|
2094
|
-
validate: (params) =>
|
|
2091
|
+
validate: (params) => api.post("/api/discounts/validate", params)
|
|
2095
2092
|
};
|
|
2096
2093
|
this.shipping = {
|
|
2097
|
-
calculate: (params) =>
|
|
2094
|
+
calculate: (params) => api.post("/api/shipping-policies/calculate", params)
|
|
2098
2095
|
};
|
|
2099
2096
|
}
|
|
2100
2097
|
};
|
|
@@ -2450,7 +2447,7 @@ function getCommerceNotificationIdempotencyKey(event) {
|
|
|
2450
2447
|
function defineCommerceEmailConfig(config) {
|
|
2451
2448
|
return config;
|
|
2452
2449
|
}
|
|
2453
|
-
function
|
|
2450
|
+
function createCommerceNotificationWebhookHandler(handlers) {
|
|
2454
2451
|
return async (event) => {
|
|
2455
2452
|
if (!isCommerceNotificationWebhookEvent(event)) {
|
|
2456
2453
|
await handlers.unhandled?.(event);
|
|
@@ -2467,6 +2464,9 @@ function createCommerceEmailWebhookHandler(handlers) {
|
|
|
2467
2464
|
});
|
|
2468
2465
|
};
|
|
2469
2466
|
}
|
|
2467
|
+
function createCommerceEmailWebhookHandler(handlers) {
|
|
2468
|
+
return createCommerceNotificationWebhookHandler(handlers);
|
|
2469
|
+
}
|
|
2470
2470
|
function isWebhookCollection(event, collection) {
|
|
2471
2471
|
return isValidWebhookEvent(event) && event.collection === collection;
|
|
2472
2472
|
}
|
|
@@ -2636,6 +2636,8 @@ var COLLECTIONS = [
|
|
|
2636
2636
|
"order-items",
|
|
2637
2637
|
"returns",
|
|
2638
2638
|
"return-items",
|
|
2639
|
+
"fulfillment-orders",
|
|
2640
|
+
"fulfillment-order-items",
|
|
2639
2641
|
"fulfillments",
|
|
2640
2642
|
"fulfillment-items",
|
|
2641
2643
|
"transactions",
|
|
@@ -4554,6 +4556,12 @@ function maxOfNullable(values) {
|
|
|
4554
4556
|
const numbers = values.filter((v) => v !== null);
|
|
4555
4557
|
return numbers.length === 0 ? null : Math.max(...numbers);
|
|
4556
4558
|
}
|
|
4559
|
+
var PRODUCT_PLP_FIND_OPTIONS = {
|
|
4560
|
+
joins: {
|
|
4561
|
+
variants: { limit: 200, sort: "_order" },
|
|
4562
|
+
options: { limit: 50, sort: "_order" }
|
|
4563
|
+
}
|
|
4564
|
+
};
|
|
4557
4565
|
function buildProductListingGroupsByOption(args) {
|
|
4558
4566
|
const primaryOptionId = args.primaryOptionId ?? void 0;
|
|
4559
4567
|
if (!primaryOptionId) return [];
|
|
@@ -4768,14 +4776,22 @@ function resolveProductGallery(input) {
|
|
|
4768
4776
|
}
|
|
4769
4777
|
|
|
4770
4778
|
// src/utils/image.ts
|
|
4771
|
-
var IMAGE_SIZES = [
|
|
4779
|
+
var IMAGE_SIZES = [200, 400, 800, 1200, 1600];
|
|
4780
|
+
function imageSizeCandidates(sizes) {
|
|
4781
|
+
const keys = new Set(IMAGE_SIZES);
|
|
4782
|
+
for (const key of Object.keys(sizes)) {
|
|
4783
|
+
const value = Number(key);
|
|
4784
|
+
if (Number.isFinite(value) && value > 0) keys.add(value);
|
|
4785
|
+
}
|
|
4786
|
+
return [...keys].sort((a, b) => a - b);
|
|
4787
|
+
}
|
|
4772
4788
|
function getImageUrl(image, displayWidth, dpr = 1) {
|
|
4773
4789
|
const target = displayWidth * dpr;
|
|
4774
4790
|
const sizes = image.sizes;
|
|
4775
4791
|
if (sizes) {
|
|
4776
|
-
for (const size of
|
|
4792
|
+
for (const size of imageSizeCandidates(sizes)) {
|
|
4777
4793
|
if (size >= target) {
|
|
4778
|
-
const entry = sizes[
|
|
4794
|
+
const entry = sizes[`${size}`];
|
|
4779
4795
|
if (entry?.url) return entry.url;
|
|
4780
4796
|
}
|
|
4781
4797
|
}
|
|
@@ -4784,16 +4800,18 @@ function getImageUrl(image, displayWidth, dpr = 1) {
|
|
|
4784
4800
|
}
|
|
4785
4801
|
function getImageSrcSet(image) {
|
|
4786
4802
|
const parts = [];
|
|
4803
|
+
const emittedWidths = /* @__PURE__ */ new Set();
|
|
4787
4804
|
const sizes = image.sizes;
|
|
4788
4805
|
if (sizes) {
|
|
4789
|
-
for (const size of
|
|
4790
|
-
const entry = sizes[
|
|
4791
|
-
if (entry?.url && entry.width) {
|
|
4806
|
+
for (const size of imageSizeCandidates(sizes)) {
|
|
4807
|
+
const entry = sizes[`${size}`];
|
|
4808
|
+
if (entry?.url && entry.width && !emittedWidths.has(entry.width)) {
|
|
4809
|
+
emittedWidths.add(entry.width);
|
|
4792
4810
|
parts.push(`${entry.url} ${entry.width}w`);
|
|
4793
4811
|
}
|
|
4794
4812
|
}
|
|
4795
4813
|
}
|
|
4796
|
-
if (image.url && image.width) {
|
|
4814
|
+
if (image.url && image.width && !emittedWidths.has(image.width)) {
|
|
4797
4815
|
parts.push(`${image.url} ${image.width}w`);
|
|
4798
4816
|
}
|
|
4799
4817
|
return parts.join(", ");
|
|
@@ -4895,6 +4913,27 @@ function createAnalytics(config) {
|
|
|
4895
4913
|
const nav = navigator;
|
|
4896
4914
|
return nav.doNotTrack === "1" || nav.globalPrivacyControl === true;
|
|
4897
4915
|
}
|
|
4916
|
+
const isLocalHost = (() => {
|
|
4917
|
+
try {
|
|
4918
|
+
const h = location.hostname;
|
|
4919
|
+
return h === "localhost" || h === "127.0.0.1" || h.endsWith(".local");
|
|
4920
|
+
} catch {
|
|
4921
|
+
return false;
|
|
4922
|
+
}
|
|
4923
|
+
})();
|
|
4924
|
+
const mode = config.mode ?? "auto";
|
|
4925
|
+
const sendSuppressed = mode === "development" || mode === "auto" && isLocalHost;
|
|
4926
|
+
let suppressNoticeShown = false;
|
|
4927
|
+
function devSuppressNotice() {
|
|
4928
|
+
if (suppressNoticeShown) return;
|
|
4929
|
+
suppressNoticeShown = true;
|
|
4930
|
+
try {
|
|
4931
|
+
console.info(
|
|
4932
|
+
`[01 analytics] events disabled on local host (mode: '${mode}'). Pass mode: 'production' to send while developing.`
|
|
4933
|
+
);
|
|
4934
|
+
} catch {
|
|
4935
|
+
}
|
|
4936
|
+
}
|
|
4898
4937
|
let lastPath = null;
|
|
4899
4938
|
let lastAt = 0;
|
|
4900
4939
|
const autoTrack = config.autoTrack !== false;
|
|
@@ -4925,6 +4964,10 @@ function createAnalytics(config) {
|
|
|
4925
4964
|
if (isDntActive()) return;
|
|
4926
4965
|
const doc = document;
|
|
4927
4966
|
if (doc.prerendering === true || document.visibilityState === "prerender") return;
|
|
4967
|
+
if (sendSuppressed) {
|
|
4968
|
+
devSuppressNotice();
|
|
4969
|
+
return;
|
|
4970
|
+
}
|
|
4928
4971
|
const now = Date.now();
|
|
4929
4972
|
if (pathname === lastPath && now - lastAt < 500) return;
|
|
4930
4973
|
lastPath = pathname;
|
|
@@ -4960,14 +5003,7 @@ function createAnalytics(config) {
|
|
|
4960
5003
|
window.addEventListener("load", trackCurrentPath, { once: true });
|
|
4961
5004
|
}
|
|
4962
5005
|
}
|
|
4963
|
-
const isProduction =
|
|
4964
|
-
try {
|
|
4965
|
-
const hostname = location.hostname;
|
|
4966
|
-
return hostname !== "localhost" && hostname !== "127.0.0.1" && !hostname.endsWith(".local");
|
|
4967
|
-
} catch {
|
|
4968
|
-
return true;
|
|
4969
|
-
}
|
|
4970
|
-
})();
|
|
5006
|
+
const isProduction = !isLocalHost;
|
|
4971
5007
|
const warnedReasons = /* @__PURE__ */ new Set();
|
|
4972
5008
|
function devWarn(name, reason) {
|
|
4973
5009
|
if (isProduction) return;
|
|
@@ -5027,6 +5063,10 @@ function createAnalytics(config) {
|
|
|
5027
5063
|
return;
|
|
5028
5064
|
}
|
|
5029
5065
|
}
|
|
5066
|
+
if (sendSuppressed) {
|
|
5067
|
+
devSuppressNotice();
|
|
5068
|
+
return;
|
|
5069
|
+
}
|
|
5030
5070
|
const body = JSON.stringify({
|
|
5031
5071
|
publishableKey: config.publishableKey,
|
|
5032
5072
|
pathname: location.pathname,
|