@01.software/sdk 0.35.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.
Files changed (80) hide show
  1. package/README.md +71 -6
  2. package/dist/analytics/react.cjs +33 -9
  3. package/dist/analytics/react.cjs.map +1 -1
  4. package/dist/analytics/react.d.cts +1 -1
  5. package/dist/analytics/react.d.ts +1 -1
  6. package/dist/analytics/react.js +33 -9
  7. package/dist/analytics/react.js.map +1 -1
  8. package/dist/analytics.cjs +30 -8
  9. package/dist/analytics.cjs.map +1 -1
  10. package/dist/analytics.d.cts +6 -0
  11. package/dist/analytics.d.ts +6 -0
  12. package/dist/analytics.js +30 -8
  13. package/dist/analytics.js.map +1 -1
  14. package/dist/client.cjs +94 -114
  15. package/dist/client.cjs.map +1 -1
  16. package/dist/client.d.cts +6 -6
  17. package/dist/client.d.ts +6 -6
  18. package/dist/client.js +94 -114
  19. package/dist/client.js.map +1 -1
  20. package/dist/{collection-client-DkREjhQ9.d.ts → collection-client-DyELGUcL.d.ts} +3 -3
  21. package/dist/{collection-client-CR2B8c1v.d.cts → collection-client-zOmnxwdA.d.cts} +3 -3
  22. package/dist/{const-CdqCauHQ.d.ts → const-CK_FPaIn.d.cts} +3 -3
  23. package/dist/{const-BTvdrXtY.d.cts → const-Dqz05oaG.d.ts} +3 -3
  24. package/dist/{image-BDz2-AaO.d.cts → image-BDjHp03R.d.cts} +13 -9
  25. package/dist/{image-BDz2-AaO.d.ts → image-BDjHp03R.d.ts} +13 -9
  26. package/dist/{index-DK8_NXkh.d.ts → index-DRJs7QIh.d.cts} +9 -6
  27. package/dist/{index-CjA3U6X3.d.cts → index-DTqoUZk_.d.ts} +9 -6
  28. package/dist/index.cjs +229 -136
  29. package/dist/index.cjs.map +1 -1
  30. package/dist/index.d.cts +10 -9
  31. package/dist/index.d.ts +10 -9
  32. package/dist/index.js +229 -136
  33. package/dist/index.js.map +1 -1
  34. package/dist/metadata.cjs +5 -3
  35. package/dist/metadata.cjs.map +1 -1
  36. package/dist/metadata.js +5 -3
  37. package/dist/metadata.js.map +1 -1
  38. package/dist/{payload-types-C7tb7Xbs.d.cts → payload-types-CREOjFNT.d.cts} +281 -128
  39. package/dist/{payload-types-C7tb7Xbs.d.ts → payload-types-CREOjFNT.d.ts} +281 -128
  40. package/dist/query.cjs +5 -3
  41. package/dist/query.cjs.map +1 -1
  42. package/dist/query.d.cts +5 -5
  43. package/dist/query.d.ts +5 -5
  44. package/dist/query.js +5 -3
  45. package/dist/query.js.map +1 -1
  46. package/dist/realtime.d.cts +2 -2
  47. package/dist/realtime.d.ts +2 -2
  48. package/dist/server.cjs +99 -69
  49. package/dist/server.cjs.map +1 -1
  50. package/dist/server.d.cts +7 -7
  51. package/dist/server.d.ts +7 -7
  52. package/dist/server.js +99 -69
  53. package/dist/server.js.map +1 -1
  54. package/dist/{types-DDhtZI6E.d.cts → types-BWMUr3Zw.d.cts} +274 -84
  55. package/dist/{types-Bx558PU6.d.cts → types-BkZNhuBh.d.cts} +1 -1
  56. package/dist/{types-1ylMrCuW.d.ts → types-CxzWHspI.d.ts} +1 -1
  57. package/dist/{types-Byo_Rty4.d.ts → types-DMvVHdb1.d.ts} +274 -84
  58. package/dist/ui/canvas.cjs +15 -5
  59. package/dist/ui/canvas.cjs.map +1 -1
  60. package/dist/ui/canvas.d.cts +1 -1
  61. package/dist/ui/canvas.d.ts +1 -1
  62. package/dist/ui/canvas.js +15 -5
  63. package/dist/ui/canvas.js.map +1 -1
  64. package/dist/ui/form.d.cts +1 -1
  65. package/dist/ui/form.d.ts +1 -1
  66. package/dist/ui/image.cjs +15 -5
  67. package/dist/ui/image.cjs.map +1 -1
  68. package/dist/ui/image.d.cts +1 -1
  69. package/dist/ui/image.d.ts +1 -1
  70. package/dist/ui/image.js +15 -5
  71. package/dist/ui/image.js.map +1 -1
  72. package/dist/ui/video.d.cts +1 -1
  73. package/dist/ui/video.d.ts +1 -1
  74. package/dist/webhook.cjs +5 -1
  75. package/dist/webhook.cjs.map +1 -1
  76. package/dist/webhook.d.cts +4 -4
  77. package/dist/webhook.d.ts +4 -4
  78. package/dist/webhook.js +5 -1
  79. package/dist/webhook.js.map +1 -1
  80. package/package.json +3 -3
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,
@@ -131,7 +133,8 @@ __export(src_exports, {
131
133
  resolveVariantForSelection: () => resolveVariantForSelection,
132
134
  selectNext: () => selectNext,
133
135
  selectedSwatchMediaItemId: () => selectedSwatchMediaItemId,
134
- stringifyProductSelection: () => stringifyProductSelection
136
+ stringifyProductSelection: () => stringifyProductSelection,
137
+ toShopifyPriceRangeV2: () => toShopifyPriceRangeV2
135
138
  });
136
139
  module.exports = __toCommonJS(src_exports);
137
140
 
@@ -944,13 +947,15 @@ var HttpClient = class {
944
947
  };
945
948
 
946
949
  // src/utils/types.ts
947
- var resolveRelation = (ref) => {
950
+ function resolveRelation(ref) {
948
951
  if (typeof ref === "string" || typeof ref === "number" || ref === null || ref === void 0)
949
952
  return null;
950
953
  return ref;
951
- };
954
+ }
952
955
 
953
956
  // src/core/metadata/index.ts
957
+ var OPEN_GRAPH_IMAGE_SIZE = "1200";
958
+ var LEGACY_OPEN_GRAPH_IMAGE_SIZE = "1536";
954
959
  function extractSeo(doc) {
955
960
  const seo = doc.seo ?? {};
956
961
  const og = seo.openGraph ?? {};
@@ -994,7 +999,7 @@ function generateMetadata(input, options) {
994
999
  function resolveMetaImage(ref) {
995
1000
  const image = resolveRelation(ref);
996
1001
  if (!image) return null;
997
- const sized = image.sizes?.["1536"];
1002
+ const sized = image.sizes?.[OPEN_GRAPH_IMAGE_SIZE] ?? image.sizes?.[LEGACY_OPEN_GRAPH_IMAGE_SIZE];
998
1003
  const url = sized?.url || image.url;
999
1004
  if (!url) return null;
1000
1005
  const width = sized?.url ? sized.width : image.width;
@@ -1126,13 +1131,16 @@ async function parseApiResponse(response, endpoint) {
1126
1131
  return data;
1127
1132
  }
1128
1133
 
1129
- // src/core/community/community-client.ts
1130
- var DEFAULT_POST_LIST_SORT = "-lastActivityAt";
1131
- var DEFAULT_COMMENT_LIST_SORT = "-createdAt";
1132
- var CommunityClient = class {
1133
- constructor(options) {
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
+ }
1134
1142
  this.publishableKey = requirePublishableKeyForSecret(
1135
- "CommunityClient",
1143
+ apiName,
1136
1144
  options.publishableKey,
1137
1145
  options.secretKey
1138
1146
  );
@@ -1142,6 +1150,44 @@ var CommunityClient = class {
1142
1150
  this.onUnauthorized = options.onUnauthorized;
1143
1151
  this.onRequestId = options.onRequestId;
1144
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
+ }
1145
1191
  buildQuery(params) {
1146
1192
  if (!params) return "";
1147
1193
  const entries = Object.entries(params).filter((e) => e[1] !== void 0).map(([k, v]) => [k, String(v)]);
@@ -1182,27 +1228,14 @@ var CommunityClient = class {
1182
1228
  return `/api/comments?${urlParams.toString()}`;
1183
1229
  }
1184
1230
  async execute(endpoint, method, body) {
1185
- const token = typeof this.customerToken === "function" ? this.customerToken() : this.customerToken;
1186
- try {
1187
- const response = await httpFetch(endpoint, {
1188
- method,
1189
- apiUrl: this.apiUrl,
1190
- publishableKey: this.publishableKey,
1191
- secretKey: this.secretKey,
1192
- customerToken: token ?? void 0,
1193
- ...token && this.onUnauthorized && { onUnauthorized: this.onUnauthorized },
1194
- ...body !== void 0 && { body: JSON.stringify(body) }
1195
- });
1196
- this.onRequestId?.(response.headers.get("x-request-id") ?? null);
1197
- return parseApiResponse(response, endpoint);
1198
- } catch (err) {
1199
- const id = err instanceof SDKError ? err.requestId ?? null : null;
1200
- this.onRequestId?.(id);
1201
- throw err;
1202
- }
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);
1203
1236
  }
1204
1237
  createPost(params) {
1205
- return this.execute("/api/posts", "POST", params);
1238
+ return this.executeDoc("/api/posts", "POST", params);
1206
1239
  }
1207
1240
  /**
1208
1241
  * Public post feed. Server applies the same visibility contract as
@@ -1259,7 +1292,7 @@ var CommunityClient = class {
1259
1292
  if (parentId !== void 0) {
1260
1293
  body.parent = parentId;
1261
1294
  }
1262
- return this.execute("/api/comments", "POST", body);
1295
+ return this.executeDoc("/api/comments", "POST", body);
1263
1296
  }
1264
1297
  /**
1265
1298
  * List comments for a post.
@@ -1297,7 +1330,7 @@ var CommunityClient = class {
1297
1330
  }
1298
1331
  updateComment(params) {
1299
1332
  const { commentId, body } = params;
1300
- return this.execute(
1333
+ return this.executeDoc(
1301
1334
  `/api/comments/${commentId}`,
1302
1335
  "PATCH",
1303
1336
  { body }
@@ -1328,7 +1361,7 @@ var CommunityClient = class {
1328
1361
  400
1329
1362
  );
1330
1363
  }
1331
- return this.execute("/api/reactions", "POST", {
1364
+ return this.executeDoc("/api/reactions", "POST", {
1332
1365
  post: postId,
1333
1366
  type: reactionType
1334
1367
  });
@@ -1350,7 +1383,7 @@ var CommunityClient = class {
1350
1383
  400
1351
1384
  );
1352
1385
  }
1353
- return this.execute("/api/reactions", "POST", {
1386
+ return this.executeDoc("/api/reactions", "POST", {
1354
1387
  comment: commentId,
1355
1388
  type: reactionType
1356
1389
  });
@@ -1382,7 +1415,7 @@ var CommunityClient = class {
1382
1415
  }
1383
1416
  // Bookmarks
1384
1417
  addBookmark(params) {
1385
- return this.execute("/api/bookmarks", "POST", {
1418
+ return this.executeDoc("/api/bookmarks", "POST", {
1386
1419
  post: params.postId
1387
1420
  });
1388
1421
  }
@@ -1633,43 +1666,12 @@ var CustomerNamespace = class {
1633
1666
  };
1634
1667
 
1635
1668
  // src/core/api/cart-api.ts
1636
- var CartApi = class {
1669
+ var CartApi = class extends CustomerScopedApi {
1637
1670
  constructor(options) {
1638
- if (!options.secretKey && !options.customerToken) {
1639
- throw createConfigError(
1640
- "Either secretKey or customerToken is required for CartApi."
1641
- );
1642
- }
1643
- this.publishableKey = requirePublishableKeyForSecret(
1644
- "CartApi",
1645
- options.publishableKey,
1646
- options.secretKey
1647
- );
1648
- this.secretKey = options.secretKey;
1649
- this.apiUrl = options.apiUrl;
1650
- this.customerToken = options.customerToken;
1651
- this.onUnauthorized = options.onUnauthorized;
1652
- this.onRequestId = options.onRequestId;
1671
+ super("CartApi", options);
1653
1672
  }
1654
1673
  async execute(endpoint, method, body) {
1655
- const token = typeof this.customerToken === "function" ? this.customerToken() : this.customerToken;
1656
- try {
1657
- const response = await httpFetch(endpoint, {
1658
- method,
1659
- apiUrl: this.apiUrl,
1660
- publishableKey: this.publishableKey,
1661
- secretKey: this.secretKey,
1662
- customerToken: token ?? void 0,
1663
- ...token && this.onUnauthorized && { onUnauthorized: this.onUnauthorized },
1664
- ...body !== void 0 && { body: JSON.stringify(body) }
1665
- });
1666
- this.onRequestId?.(response.headers.get("x-request-id") ?? null);
1667
- return parseApiResponse(response, endpoint);
1668
- } catch (err) {
1669
- const id = err instanceof SDKError ? err.requestId ?? null : null;
1670
- this.onRequestId?.(id);
1671
- throw err;
1672
- }
1674
+ return this.request(endpoint, { method, body });
1673
1675
  }
1674
1676
  getCart(cartId) {
1675
1677
  return this.execute(`/api/carts/${cartId}`, "GET");
@@ -1893,15 +1895,24 @@ function splitIdempotencyKey(params) {
1893
1895
  const { idempotencyKey, ...body } = params;
1894
1896
  return { body, idempotencyKey };
1895
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
+ }
1896
1906
  var OrderApi = class extends BaseApi {
1897
1907
  constructor(options) {
1898
1908
  super("OrderApi", options);
1899
1909
  }
1900
1910
  createOrder(params) {
1901
- const { body, idempotencyKey } = splitIdempotencyKey(params);
1911
+ const { idempotencyKey } = params;
1912
+ const normalizedBody = normalizeCreateOrderBody(params);
1902
1913
  return this.request(
1903
1914
  "/api/orders/create",
1904
- body,
1915
+ normalizedBody,
1905
1916
  idempotencyRequestOptions(idempotencyKey)
1906
1917
  );
1907
1918
  }
@@ -1933,6 +1944,20 @@ var OrderApi = class extends BaseApi {
1933
1944
  idempotencyKey ? { headers: { "X-Idempotency-Key": idempotencyKey } } : void 0
1934
1945
  );
1935
1946
  }
1947
+ resolveCancelRefund(params) {
1948
+ return this.request(
1949
+ "/api/orders/resolve-cancel-refund",
1950
+ {
1951
+ orderNumber: params.orderNumber,
1952
+ idempotencyKey: params.idempotencyKey,
1953
+ outcome: params.outcome,
1954
+ refundedAmount: params.refundedAmount,
1955
+ pgProvider: params.pgProvider,
1956
+ ...params.pgRefundId ? { pgRefundId: params.pgRefundId } : {}
1957
+ },
1958
+ idempotencyRequestOptions(params.idempotencyKey)
1959
+ );
1960
+ }
1936
1961
  checkout(params) {
1937
1962
  const { body, idempotencyKey } = splitIdempotencyKey(params);
1938
1963
  return this.request(
@@ -1949,6 +1974,12 @@ var OrderApi = class extends BaseApi {
1949
1974
  idempotencyRequestOptions(idempotencyKey)
1950
1975
  );
1951
1976
  }
1977
+ prepareFulfillmentOrder(params) {
1978
+ return this.request(
1979
+ "/api/fulfillment-orders/prepare-fulfillment-order",
1980
+ params
1981
+ );
1982
+ }
1952
1983
  updateFulfillment(params) {
1953
1984
  return this.request("/api/orders/update-fulfillment", params);
1954
1985
  }
@@ -1980,6 +2011,18 @@ var OrderApi = class extends BaseApi {
1980
2011
  };
1981
2012
 
1982
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
+ };
1983
2026
  var CommerceClient = class {
1984
2027
  constructor(options) {
1985
2028
  const cartApi = new CartApi({
@@ -1989,52 +2032,21 @@ var CommerceClient = class {
1989
2032
  onUnauthorized: options.onUnauthorized,
1990
2033
  onRequestId: options.onRequestId
1991
2034
  });
1992
- const execute = async (endpoint, body, requestOptions) => {
1993
- const token = options.customerToken();
1994
- try {
1995
- const response = await httpFetch(endpoint, {
1996
- method: "POST",
1997
- apiUrl: options.apiUrl,
1998
- publishableKey: options.publishableKey,
1999
- customerToken: token ?? void 0,
2000
- ...token && options.onUnauthorized && { onUnauthorized: options.onUnauthorized },
2001
- body: JSON.stringify(body),
2002
- ...requestOptions?.headers && { headers: requestOptions.headers }
2003
- });
2004
- options.onRequestId?.(response.headers.get("x-request-id") ?? null);
2005
- return parseApiResponse(response, endpoint);
2006
- } catch (err) {
2007
- const id = err instanceof SDKError ? err.requestId ?? null : null;
2008
- options.onRequestId?.(id);
2009
- throw err;
2010
- }
2011
- };
2012
- const executeGet = async (endpoint) => {
2013
- const token = options.customerToken();
2014
- try {
2015
- const response = await httpFetch(endpoint, {
2016
- method: "GET",
2017
- apiUrl: options.apiUrl,
2018
- publishableKey: options.publishableKey,
2019
- customerToken: token ?? void 0,
2020
- ...token && options.onUnauthorized && { onUnauthorized: options.onUnauthorized }
2021
- });
2022
- options.onRequestId?.(response.headers.get("x-request-id") ?? null);
2023
- return parseApiResponse(response, endpoint);
2024
- } catch (err) {
2025
- const id = err instanceof SDKError ? err.requestId ?? null : null;
2026
- options.onRequestId?.(id);
2027
- throw err;
2028
- }
2029
- };
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
+ });
2030
2042
  this.product = {
2031
- stockCheck: (params) => execute("/api/products/stock-check", params),
2032
- stockSnapshot: (params) => executeGet(stockSnapshotQuery(params)),
2033
- listingGroups: (params) => executeGet(listingGroupsQuery(params)),
2034
- listingGroupsCatalog: (params) => executeGet(listingGroupsCatalogQuery(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)),
2035
2047
  detail: async (params) => {
2036
2048
  try {
2037
- const product = await executeGet(productDetailQuery(params));
2049
+ const product = await api.get(productDetailQuery(params));
2038
2050
  return { found: true, product };
2039
2051
  } catch (err) {
2040
2052
  const notFoundResult = productDetailResultFromError(err);
@@ -2044,7 +2056,7 @@ var CommerceClient = class {
2044
2056
  },
2045
2057
  detailCatalog: async (params) => {
2046
2058
  try {
2047
- const product = await executeGet(
2059
+ const product = await api.get(
2048
2060
  productDetailCatalogQuery(params)
2049
2061
  );
2050
2062
  return { found: true, product };
@@ -2067,7 +2079,7 @@ var CommerceClient = class {
2067
2079
  this.orders = {
2068
2080
  checkout: (params) => {
2069
2081
  const { body, idempotencyKey } = splitIdempotencyKey(params);
2070
- return execute(
2082
+ return api.post(
2071
2083
  "/api/orders/checkout",
2072
2084
  body,
2073
2085
  idempotencyRequestOptions(idempotencyKey)
@@ -2076,10 +2088,10 @@ var CommerceClient = class {
2076
2088
  listMine: (params) => options.customerAuth.getMyOrders(params)
2077
2089
  };
2078
2090
  this.discounts = {
2079
- validate: (params) => execute("/api/discounts/validate", params)
2091
+ validate: (params) => api.post("/api/discounts/validate", params)
2080
2092
  };
2081
2093
  this.shipping = {
2082
- calculate: (params) => execute("/api/shipping-policies/calculate", params)
2094
+ calculate: (params) => api.post("/api/shipping-policies/calculate", params)
2083
2095
  };
2084
2096
  }
2085
2097
  };
@@ -2435,7 +2447,7 @@ function getCommerceNotificationIdempotencyKey(event) {
2435
2447
  function defineCommerceEmailConfig(config) {
2436
2448
  return config;
2437
2449
  }
2438
- function createCommerceEmailWebhookHandler(handlers) {
2450
+ function createCommerceNotificationWebhookHandler(handlers) {
2439
2451
  return async (event) => {
2440
2452
  if (!isCommerceNotificationWebhookEvent(event)) {
2441
2453
  await handlers.unhandled?.(event);
@@ -2452,6 +2464,9 @@ function createCommerceEmailWebhookHandler(handlers) {
2452
2464
  });
2453
2465
  };
2454
2466
  }
2467
+ function createCommerceEmailWebhookHandler(handlers) {
2468
+ return createCommerceNotificationWebhookHandler(handlers);
2469
+ }
2455
2470
  function isWebhookCollection(event, collection) {
2456
2471
  return isValidWebhookEvent(event) && event.collection === collection;
2457
2472
  }
@@ -2621,6 +2636,8 @@ var COLLECTIONS = [
2621
2636
  "order-items",
2622
2637
  "returns",
2623
2638
  "return-items",
2639
+ "fulfillment-orders",
2640
+ "fulfillment-order-items",
2624
2641
  "fulfillments",
2625
2642
  "fulfillment-items",
2626
2643
  "transactions",
@@ -4412,10 +4429,12 @@ function buildProductListingCard(item, options = {}) {
4412
4429
  const listingPrimaryMedia = listingPrimaryPointer ? productMediaPool.find(
4413
4430
  (item2) => getRelationID(item2) === listingPrimaryPointer
4414
4431
  ) ?? resolvedPrimaryMedia.primaryImage ?? null : null;
4415
- const priceRange = aggregateListingPriceRange(groups);
4416
- const availableForSale = groups.some(
4417
- (group) => group.listing.availableForSale
4432
+ const priceRange = resolveListingCardPriceRange(
4433
+ product,
4434
+ projectedListing,
4435
+ groups
4418
4436
  );
4437
+ const availableForSale = product.listing?.availableForSale != null ? product.listing.availableForSale : groups.length > 0 ? groups.some((group) => group.listing.availableForSale) : projectedListing.availableForSale;
4419
4438
  const swatches = groups.length > 1 ? groups.map((group) => buildListingSwatch(product, group, options)) : [];
4420
4439
  return {
4421
4440
  id: String(product.id),
@@ -4455,6 +4474,42 @@ function findListingCardRepresentativeVariant(variants, representativeVariantId)
4455
4474
  (variant) => getRelationID(variant.id) === representativeVariantId
4456
4475
  ) ?? null;
4457
4476
  }
4477
+ function toShopifyPriceRangeV2(listing) {
4478
+ return {
4479
+ minVariantPrice: { amount: listing.minPrice ?? null },
4480
+ maxVariantPrice: { amount: listing.maxPrice ?? null }
4481
+ };
4482
+ }
4483
+ function hasCompleteListingPriceProjection(listing) {
4484
+ return listing?.minPrice != null && listing?.maxPrice != null;
4485
+ }
4486
+ function listingDefinesCompareAtProjection(listing) {
4487
+ return "minCompareAtPrice" in listing || "maxCompareAtPrice" in listing;
4488
+ }
4489
+ function resolveListingCardPriceRange(product, projectedListing, groups) {
4490
+ const listing = product.listing;
4491
+ if (hasCompleteListingPriceProjection(listing)) {
4492
+ const groupRange = groups.length > 0 ? aggregateListingPriceRange(groups) : null;
4493
+ const definesCompareAt = listingDefinesCompareAtProjection(listing);
4494
+ return {
4495
+ minPrice: listing.minPrice,
4496
+ maxPrice: listing.maxPrice,
4497
+ minCompareAtPrice: definesCompareAt ? listing.minCompareAtPrice ?? null : groupRange?.minCompareAtPrice ?? projectedListing.minCompareAtPrice,
4498
+ maxCompareAtPrice: definesCompareAt ? listing.maxCompareAtPrice ?? null : groupRange?.maxCompareAtPrice ?? projectedListing.maxCompareAtPrice,
4499
+ isPriceRange: listing.isPriceRange ?? listing.minPrice !== listing.maxPrice
4500
+ };
4501
+ }
4502
+ if (groups.length > 0) {
4503
+ return aggregateListingPriceRange(groups);
4504
+ }
4505
+ return {
4506
+ minPrice: projectedListing.minPrice,
4507
+ maxPrice: projectedListing.maxPrice,
4508
+ minCompareAtPrice: projectedListing.minCompareAtPrice,
4509
+ maxCompareAtPrice: projectedListing.maxCompareAtPrice,
4510
+ isPriceRange: projectedListing.isPriceRange
4511
+ };
4512
+ }
4458
4513
  function aggregateListingPriceRange(groups) {
4459
4514
  const minPrice = minOfNullable(groups.map((g) => g.listing.minPrice));
4460
4515
  const maxPrice = maxOfNullable(groups.map((g) => g.listing.maxPrice));
@@ -4501,6 +4556,12 @@ function maxOfNullable(values) {
4501
4556
  const numbers = values.filter((v) => v !== null);
4502
4557
  return numbers.length === 0 ? null : Math.max(...numbers);
4503
4558
  }
4559
+ var PRODUCT_PLP_FIND_OPTIONS = {
4560
+ joins: {
4561
+ variants: { limit: 200, sort: "_order" },
4562
+ options: { limit: 50, sort: "_order" }
4563
+ }
4564
+ };
4504
4565
  function buildProductListingGroupsByOption(args) {
4505
4566
  const primaryOptionId = args.primaryOptionId ?? void 0;
4506
4567
  if (!primaryOptionId) return [];
@@ -4715,14 +4776,22 @@ function resolveProductGallery(input) {
4715
4776
  }
4716
4777
 
4717
4778
  // src/utils/image.ts
4718
- var IMAGE_SIZES = [384, 768, 1536];
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
+ }
4719
4788
  function getImageUrl(image, displayWidth, dpr = 1) {
4720
4789
  const target = displayWidth * dpr;
4721
4790
  const sizes = image.sizes;
4722
4791
  if (sizes) {
4723
- for (const size of IMAGE_SIZES) {
4792
+ for (const size of imageSizeCandidates(sizes)) {
4724
4793
  if (size >= target) {
4725
- const entry = sizes[String(size)];
4794
+ const entry = sizes[`${size}`];
4726
4795
  if (entry?.url) return entry.url;
4727
4796
  }
4728
4797
  }
@@ -4731,16 +4800,18 @@ function getImageUrl(image, displayWidth, dpr = 1) {
4731
4800
  }
4732
4801
  function getImageSrcSet(image) {
4733
4802
  const parts = [];
4803
+ const emittedWidths = /* @__PURE__ */ new Set();
4734
4804
  const sizes = image.sizes;
4735
4805
  if (sizes) {
4736
- for (const size of IMAGE_SIZES) {
4737
- const entry = sizes[String(size)];
4738
- 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);
4739
4810
  parts.push(`${entry.url} ${entry.width}w`);
4740
4811
  }
4741
4812
  }
4742
4813
  }
4743
- if (image.url && image.width) {
4814
+ if (image.url && image.width && !emittedWidths.has(image.width)) {
4744
4815
  parts.push(`${image.url} ${image.width}w`);
4745
4816
  }
4746
4817
  return parts.join(", ");
@@ -4842,6 +4913,27 @@ function createAnalytics(config) {
4842
4913
  const nav = navigator;
4843
4914
  return nav.doNotTrack === "1" || nav.globalPrivacyControl === true;
4844
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
+ }
4845
4937
  let lastPath = null;
4846
4938
  let lastAt = 0;
4847
4939
  const autoTrack = config.autoTrack !== false;
@@ -4872,6 +4964,10 @@ function createAnalytics(config) {
4872
4964
  if (isDntActive()) return;
4873
4965
  const doc = document;
4874
4966
  if (doc.prerendering === true || document.visibilityState === "prerender") return;
4967
+ if (sendSuppressed) {
4968
+ devSuppressNotice();
4969
+ return;
4970
+ }
4875
4971
  const now = Date.now();
4876
4972
  if (pathname === lastPath && now - lastAt < 500) return;
4877
4973
  lastPath = pathname;
@@ -4907,14 +5003,7 @@ function createAnalytics(config) {
4907
5003
  window.addEventListener("load", trackCurrentPath, { once: true });
4908
5004
  }
4909
5005
  }
4910
- const isProduction = (() => {
4911
- try {
4912
- const hostname = location.hostname;
4913
- return hostname !== "localhost" && hostname !== "127.0.0.1" && !hostname.endsWith(".local");
4914
- } catch {
4915
- return true;
4916
- }
4917
- })();
5006
+ const isProduction = !isLocalHost;
4918
5007
  const warnedReasons = /* @__PURE__ */ new Set();
4919
5008
  function devWarn(name, reason) {
4920
5009
  if (isProduction) return;
@@ -4974,6 +5063,10 @@ function createAnalytics(config) {
4974
5063
  return;
4975
5064
  }
4976
5065
  }
5066
+ if (sendSuppressed) {
5067
+ devSuppressNotice();
5068
+ return;
5069
+ }
4977
5070
  const body = JSON.stringify({
4978
5071
  publishableKey: config.publishableKey,
4979
5072
  pathname: location.pathname,