@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.
- 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-DkREjhQ9.d.ts → collection-client-DyELGUcL.d.ts} +3 -3
- package/dist/{collection-client-CR2B8c1v.d.cts → collection-client-zOmnxwdA.d.cts} +3 -3
- package/dist/{const-CdqCauHQ.d.ts → const-CK_FPaIn.d.cts} +3 -3
- package/dist/{const-BTvdrXtY.d.cts → 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-DK8_NXkh.d.ts → index-DRJs7QIh.d.cts} +9 -6
- package/dist/{index-CjA3U6X3.d.cts → index-DTqoUZk_.d.ts} +9 -6
- package/dist/index.cjs +229 -136
- 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 +229 -136
- 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-C7tb7Xbs.d.cts → payload-types-CREOjFNT.d.cts} +281 -128
- package/dist/{payload-types-C7tb7Xbs.d.ts → payload-types-CREOjFNT.d.ts} +281 -128
- 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 +99 -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 +99 -69
- package/dist/server.js.map +1 -1
- package/dist/{types-DDhtZI6E.d.cts → types-BWMUr3Zw.d.cts} +274 -84
- package/dist/{types-Bx558PU6.d.cts → types-BkZNhuBh.d.cts} +1 -1
- package/dist/{types-1ylMrCuW.d.ts → types-CxzWHspI.d.ts} +1 -1
- package/dist/{types-Byo_Rty4.d.ts → types-DMvVHdb1.d.ts} +274 -84
- 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 +3 -3
package/dist/index.js
CHANGED
|
@@ -807,13 +807,15 @@ var HttpClient = class {
|
|
|
807
807
|
};
|
|
808
808
|
|
|
809
809
|
// src/utils/types.ts
|
|
810
|
-
|
|
810
|
+
function resolveRelation(ref) {
|
|
811
811
|
if (typeof ref === "string" || typeof ref === "number" || ref === null || ref === void 0)
|
|
812
812
|
return null;
|
|
813
813
|
return ref;
|
|
814
|
-
}
|
|
814
|
+
}
|
|
815
815
|
|
|
816
816
|
// src/core/metadata/index.ts
|
|
817
|
+
var OPEN_GRAPH_IMAGE_SIZE = "1200";
|
|
818
|
+
var LEGACY_OPEN_GRAPH_IMAGE_SIZE = "1536";
|
|
817
819
|
function extractSeo(doc) {
|
|
818
820
|
const seo = doc.seo ?? {};
|
|
819
821
|
const og = seo.openGraph ?? {};
|
|
@@ -857,7 +859,7 @@ function generateMetadata(input, options) {
|
|
|
857
859
|
function resolveMetaImage(ref) {
|
|
858
860
|
const image = resolveRelation(ref);
|
|
859
861
|
if (!image) return null;
|
|
860
|
-
const sized = image.sizes?.[
|
|
862
|
+
const sized = image.sizes?.[OPEN_GRAPH_IMAGE_SIZE] ?? image.sizes?.[LEGACY_OPEN_GRAPH_IMAGE_SIZE];
|
|
861
863
|
const url = sized?.url || image.url;
|
|
862
864
|
if (!url) return null;
|
|
863
865
|
const width = sized?.url ? sized.width : image.width;
|
|
@@ -989,13 +991,16 @@ async function parseApiResponse(response, endpoint) {
|
|
|
989
991
|
return data;
|
|
990
992
|
}
|
|
991
993
|
|
|
992
|
-
// src/core/
|
|
993
|
-
var
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
994
|
+
// src/core/api/customer-scoped-api.ts
|
|
995
|
+
var CustomerScopedApi = class {
|
|
996
|
+
constructor(apiName, options) {
|
|
997
|
+
if (options.requiresCredential !== false && !options.secretKey && !options.customerToken) {
|
|
998
|
+
throw createConfigError(
|
|
999
|
+
`Either secretKey or customerToken is required for ${apiName}.`
|
|
1000
|
+
);
|
|
1001
|
+
}
|
|
997
1002
|
this.publishableKey = requirePublishableKeyForSecret(
|
|
998
|
-
|
|
1003
|
+
apiName,
|
|
999
1004
|
options.publishableKey,
|
|
1000
1005
|
options.secretKey
|
|
1001
1006
|
);
|
|
@@ -1005,6 +1010,44 @@ var CommunityClient = class {
|
|
|
1005
1010
|
this.onUnauthorized = options.onUnauthorized;
|
|
1006
1011
|
this.onRequestId = options.onRequestId;
|
|
1007
1012
|
}
|
|
1013
|
+
async request(endpoint, options) {
|
|
1014
|
+
const token = typeof this.customerToken === "function" ? this.customerToken() : this.customerToken;
|
|
1015
|
+
try {
|
|
1016
|
+
const response = await httpFetch(endpoint, {
|
|
1017
|
+
method: options.method,
|
|
1018
|
+
apiUrl: this.apiUrl,
|
|
1019
|
+
publishableKey: this.publishableKey,
|
|
1020
|
+
secretKey: this.secretKey,
|
|
1021
|
+
customerToken: token ?? void 0,
|
|
1022
|
+
...token && this.onUnauthorized && { onUnauthorized: this.onUnauthorized },
|
|
1023
|
+
...options.body !== void 0 && {
|
|
1024
|
+
body: JSON.stringify(options.body)
|
|
1025
|
+
},
|
|
1026
|
+
...options.headers && { headers: options.headers }
|
|
1027
|
+
});
|
|
1028
|
+
this.onRequestId?.(response.headers.get("x-request-id") ?? null);
|
|
1029
|
+
return parseApiResponse(response, endpoint);
|
|
1030
|
+
} catch (err) {
|
|
1031
|
+
const id = err instanceof SDKError ? err.requestId ?? null : null;
|
|
1032
|
+
this.onRequestId?.(id);
|
|
1033
|
+
throw err;
|
|
1034
|
+
}
|
|
1035
|
+
}
|
|
1036
|
+
};
|
|
1037
|
+
|
|
1038
|
+
// src/core/community/community-client.ts
|
|
1039
|
+
var DEFAULT_POST_LIST_SORT = "-lastActivityAt";
|
|
1040
|
+
var DEFAULT_COMMENT_LIST_SORT = "-createdAt";
|
|
1041
|
+
function unwrapPayloadDoc(value) {
|
|
1042
|
+
if (value && typeof value === "object" && "doc" in value) {
|
|
1043
|
+
return value.doc;
|
|
1044
|
+
}
|
|
1045
|
+
return value;
|
|
1046
|
+
}
|
|
1047
|
+
var CommunityClient = class extends CustomerScopedApi {
|
|
1048
|
+
constructor(options) {
|
|
1049
|
+
super("CommunityClient", { ...options, requiresCredential: false });
|
|
1050
|
+
}
|
|
1008
1051
|
buildQuery(params) {
|
|
1009
1052
|
if (!params) return "";
|
|
1010
1053
|
const entries = Object.entries(params).filter((e) => e[1] !== void 0).map(([k, v]) => [k, String(v)]);
|
|
@@ -1045,27 +1088,14 @@ var CommunityClient = class {
|
|
|
1045
1088
|
return `/api/comments?${urlParams.toString()}`;
|
|
1046
1089
|
}
|
|
1047
1090
|
async execute(endpoint, method, body) {
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
publishableKey: this.publishableKey,
|
|
1054
|
-
secretKey: this.secretKey,
|
|
1055
|
-
customerToken: token ?? void 0,
|
|
1056
|
-
...token && this.onUnauthorized && { onUnauthorized: this.onUnauthorized },
|
|
1057
|
-
...body !== void 0 && { body: JSON.stringify(body) }
|
|
1058
|
-
});
|
|
1059
|
-
this.onRequestId?.(response.headers.get("x-request-id") ?? null);
|
|
1060
|
-
return parseApiResponse(response, endpoint);
|
|
1061
|
-
} catch (err) {
|
|
1062
|
-
const id = err instanceof SDKError ? err.requestId ?? null : null;
|
|
1063
|
-
this.onRequestId?.(id);
|
|
1064
|
-
throw err;
|
|
1065
|
-
}
|
|
1091
|
+
return this.request(endpoint, { method, body });
|
|
1092
|
+
}
|
|
1093
|
+
async executeDoc(endpoint, method, body) {
|
|
1094
|
+
const response = await this.execute(endpoint, method, body);
|
|
1095
|
+
return unwrapPayloadDoc(response);
|
|
1066
1096
|
}
|
|
1067
1097
|
createPost(params) {
|
|
1068
|
-
return this.
|
|
1098
|
+
return this.executeDoc("/api/posts", "POST", params);
|
|
1069
1099
|
}
|
|
1070
1100
|
/**
|
|
1071
1101
|
* Public post feed. Server applies the same visibility contract as
|
|
@@ -1122,7 +1152,7 @@ var CommunityClient = class {
|
|
|
1122
1152
|
if (parentId !== void 0) {
|
|
1123
1153
|
body.parent = parentId;
|
|
1124
1154
|
}
|
|
1125
|
-
return this.
|
|
1155
|
+
return this.executeDoc("/api/comments", "POST", body);
|
|
1126
1156
|
}
|
|
1127
1157
|
/**
|
|
1128
1158
|
* List comments for a post.
|
|
@@ -1160,7 +1190,7 @@ var CommunityClient = class {
|
|
|
1160
1190
|
}
|
|
1161
1191
|
updateComment(params) {
|
|
1162
1192
|
const { commentId, body } = params;
|
|
1163
|
-
return this.
|
|
1193
|
+
return this.executeDoc(
|
|
1164
1194
|
`/api/comments/${commentId}`,
|
|
1165
1195
|
"PATCH",
|
|
1166
1196
|
{ body }
|
|
@@ -1191,7 +1221,7 @@ var CommunityClient = class {
|
|
|
1191
1221
|
400
|
|
1192
1222
|
);
|
|
1193
1223
|
}
|
|
1194
|
-
return this.
|
|
1224
|
+
return this.executeDoc("/api/reactions", "POST", {
|
|
1195
1225
|
post: postId,
|
|
1196
1226
|
type: reactionType
|
|
1197
1227
|
});
|
|
@@ -1213,7 +1243,7 @@ var CommunityClient = class {
|
|
|
1213
1243
|
400
|
|
1214
1244
|
);
|
|
1215
1245
|
}
|
|
1216
|
-
return this.
|
|
1246
|
+
return this.executeDoc("/api/reactions", "POST", {
|
|
1217
1247
|
comment: commentId,
|
|
1218
1248
|
type: reactionType
|
|
1219
1249
|
});
|
|
@@ -1245,7 +1275,7 @@ var CommunityClient = class {
|
|
|
1245
1275
|
}
|
|
1246
1276
|
// Bookmarks
|
|
1247
1277
|
addBookmark(params) {
|
|
1248
|
-
return this.
|
|
1278
|
+
return this.executeDoc("/api/bookmarks", "POST", {
|
|
1249
1279
|
post: params.postId
|
|
1250
1280
|
});
|
|
1251
1281
|
}
|
|
@@ -1496,43 +1526,12 @@ var CustomerNamespace = class {
|
|
|
1496
1526
|
};
|
|
1497
1527
|
|
|
1498
1528
|
// src/core/api/cart-api.ts
|
|
1499
|
-
var CartApi = class {
|
|
1529
|
+
var CartApi = class extends CustomerScopedApi {
|
|
1500
1530
|
constructor(options) {
|
|
1501
|
-
|
|
1502
|
-
throw createConfigError(
|
|
1503
|
-
"Either secretKey or customerToken is required for CartApi."
|
|
1504
|
-
);
|
|
1505
|
-
}
|
|
1506
|
-
this.publishableKey = requirePublishableKeyForSecret(
|
|
1507
|
-
"CartApi",
|
|
1508
|
-
options.publishableKey,
|
|
1509
|
-
options.secretKey
|
|
1510
|
-
);
|
|
1511
|
-
this.secretKey = options.secretKey;
|
|
1512
|
-
this.apiUrl = options.apiUrl;
|
|
1513
|
-
this.customerToken = options.customerToken;
|
|
1514
|
-
this.onUnauthorized = options.onUnauthorized;
|
|
1515
|
-
this.onRequestId = options.onRequestId;
|
|
1531
|
+
super("CartApi", options);
|
|
1516
1532
|
}
|
|
1517
1533
|
async execute(endpoint, method, body) {
|
|
1518
|
-
|
|
1519
|
-
try {
|
|
1520
|
-
const response = await httpFetch(endpoint, {
|
|
1521
|
-
method,
|
|
1522
|
-
apiUrl: this.apiUrl,
|
|
1523
|
-
publishableKey: this.publishableKey,
|
|
1524
|
-
secretKey: this.secretKey,
|
|
1525
|
-
customerToken: token ?? void 0,
|
|
1526
|
-
...token && this.onUnauthorized && { onUnauthorized: this.onUnauthorized },
|
|
1527
|
-
...body !== void 0 && { body: JSON.stringify(body) }
|
|
1528
|
-
});
|
|
1529
|
-
this.onRequestId?.(response.headers.get("x-request-id") ?? null);
|
|
1530
|
-
return parseApiResponse(response, endpoint);
|
|
1531
|
-
} catch (err) {
|
|
1532
|
-
const id = err instanceof SDKError ? err.requestId ?? null : null;
|
|
1533
|
-
this.onRequestId?.(id);
|
|
1534
|
-
throw err;
|
|
1535
|
-
}
|
|
1534
|
+
return this.request(endpoint, { method, body });
|
|
1536
1535
|
}
|
|
1537
1536
|
getCart(cartId) {
|
|
1538
1537
|
return this.execute(`/api/carts/${cartId}`, "GET");
|
|
@@ -1756,15 +1755,24 @@ function splitIdempotencyKey(params) {
|
|
|
1756
1755
|
const { idempotencyKey, ...body } = params;
|
|
1757
1756
|
return { body, idempotencyKey };
|
|
1758
1757
|
}
|
|
1758
|
+
function normalizeCreateOrderBody(params) {
|
|
1759
|
+
if (params.items !== void 0) {
|
|
1760
|
+
const { idempotencyKey: _idempotencyKey2, items, ...rest } = params;
|
|
1761
|
+
return { ...rest, orderItems: items };
|
|
1762
|
+
}
|
|
1763
|
+
const { idempotencyKey: _idempotencyKey, ...body } = params;
|
|
1764
|
+
return body;
|
|
1765
|
+
}
|
|
1759
1766
|
var OrderApi = class extends BaseApi {
|
|
1760
1767
|
constructor(options) {
|
|
1761
1768
|
super("OrderApi", options);
|
|
1762
1769
|
}
|
|
1763
1770
|
createOrder(params) {
|
|
1764
|
-
const {
|
|
1771
|
+
const { idempotencyKey } = params;
|
|
1772
|
+
const normalizedBody = normalizeCreateOrderBody(params);
|
|
1765
1773
|
return this.request(
|
|
1766
1774
|
"/api/orders/create",
|
|
1767
|
-
|
|
1775
|
+
normalizedBody,
|
|
1768
1776
|
idempotencyRequestOptions(idempotencyKey)
|
|
1769
1777
|
);
|
|
1770
1778
|
}
|
|
@@ -1796,6 +1804,20 @@ var OrderApi = class extends BaseApi {
|
|
|
1796
1804
|
idempotencyKey ? { headers: { "X-Idempotency-Key": idempotencyKey } } : void 0
|
|
1797
1805
|
);
|
|
1798
1806
|
}
|
|
1807
|
+
resolveCancelRefund(params) {
|
|
1808
|
+
return this.request(
|
|
1809
|
+
"/api/orders/resolve-cancel-refund",
|
|
1810
|
+
{
|
|
1811
|
+
orderNumber: params.orderNumber,
|
|
1812
|
+
idempotencyKey: params.idempotencyKey,
|
|
1813
|
+
outcome: params.outcome,
|
|
1814
|
+
refundedAmount: params.refundedAmount,
|
|
1815
|
+
pgProvider: params.pgProvider,
|
|
1816
|
+
...params.pgRefundId ? { pgRefundId: params.pgRefundId } : {}
|
|
1817
|
+
},
|
|
1818
|
+
idempotencyRequestOptions(params.idempotencyKey)
|
|
1819
|
+
);
|
|
1820
|
+
}
|
|
1799
1821
|
checkout(params) {
|
|
1800
1822
|
const { body, idempotencyKey } = splitIdempotencyKey(params);
|
|
1801
1823
|
return this.request(
|
|
@@ -1812,6 +1834,12 @@ var OrderApi = class extends BaseApi {
|
|
|
1812
1834
|
idempotencyRequestOptions(idempotencyKey)
|
|
1813
1835
|
);
|
|
1814
1836
|
}
|
|
1837
|
+
prepareFulfillmentOrder(params) {
|
|
1838
|
+
return this.request(
|
|
1839
|
+
"/api/fulfillment-orders/prepare-fulfillment-order",
|
|
1840
|
+
params
|
|
1841
|
+
);
|
|
1842
|
+
}
|
|
1815
1843
|
updateFulfillment(params) {
|
|
1816
1844
|
return this.request("/api/orders/update-fulfillment", params);
|
|
1817
1845
|
}
|
|
@@ -1843,6 +1871,18 @@ var OrderApi = class extends BaseApi {
|
|
|
1843
1871
|
};
|
|
1844
1872
|
|
|
1845
1873
|
// src/core/commerce/commerce-client.ts
|
|
1874
|
+
var BrowserCommerceApi = class extends CustomerScopedApi {
|
|
1875
|
+
post(endpoint, body, requestOptions) {
|
|
1876
|
+
return this.request(endpoint, {
|
|
1877
|
+
method: "POST",
|
|
1878
|
+
body,
|
|
1879
|
+
headers: requestOptions?.headers
|
|
1880
|
+
});
|
|
1881
|
+
}
|
|
1882
|
+
get(endpoint) {
|
|
1883
|
+
return this.request(endpoint, { method: "GET" });
|
|
1884
|
+
}
|
|
1885
|
+
};
|
|
1846
1886
|
var CommerceClient = class {
|
|
1847
1887
|
constructor(options) {
|
|
1848
1888
|
const cartApi = new CartApi({
|
|
@@ -1852,52 +1892,21 @@ var CommerceClient = class {
|
|
|
1852
1892
|
onUnauthorized: options.onUnauthorized,
|
|
1853
1893
|
onRequestId: options.onRequestId
|
|
1854
1894
|
});
|
|
1855
|
-
const
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
customerToken: token ?? void 0,
|
|
1863
|
-
...token && options.onUnauthorized && { onUnauthorized: options.onUnauthorized },
|
|
1864
|
-
body: JSON.stringify(body),
|
|
1865
|
-
...requestOptions?.headers && { headers: requestOptions.headers }
|
|
1866
|
-
});
|
|
1867
|
-
options.onRequestId?.(response.headers.get("x-request-id") ?? null);
|
|
1868
|
-
return parseApiResponse(response, endpoint);
|
|
1869
|
-
} catch (err) {
|
|
1870
|
-
const id = err instanceof SDKError ? err.requestId ?? null : null;
|
|
1871
|
-
options.onRequestId?.(id);
|
|
1872
|
-
throw err;
|
|
1873
|
-
}
|
|
1874
|
-
};
|
|
1875
|
-
const executeGet = async (endpoint) => {
|
|
1876
|
-
const token = options.customerToken();
|
|
1877
|
-
try {
|
|
1878
|
-
const response = await httpFetch(endpoint, {
|
|
1879
|
-
method: "GET",
|
|
1880
|
-
apiUrl: options.apiUrl,
|
|
1881
|
-
publishableKey: options.publishableKey,
|
|
1882
|
-
customerToken: token ?? void 0,
|
|
1883
|
-
...token && options.onUnauthorized && { onUnauthorized: options.onUnauthorized }
|
|
1884
|
-
});
|
|
1885
|
-
options.onRequestId?.(response.headers.get("x-request-id") ?? null);
|
|
1886
|
-
return parseApiResponse(response, endpoint);
|
|
1887
|
-
} catch (err) {
|
|
1888
|
-
const id = err instanceof SDKError ? err.requestId ?? null : null;
|
|
1889
|
-
options.onRequestId?.(id);
|
|
1890
|
-
throw err;
|
|
1891
|
-
}
|
|
1892
|
-
};
|
|
1895
|
+
const api = new BrowserCommerceApi("CommerceClient", {
|
|
1896
|
+
publishableKey: options.publishableKey,
|
|
1897
|
+
apiUrl: options.apiUrl,
|
|
1898
|
+
customerToken: options.customerToken,
|
|
1899
|
+
onUnauthorized: options.onUnauthorized,
|
|
1900
|
+
onRequestId: options.onRequestId
|
|
1901
|
+
});
|
|
1893
1902
|
this.product = {
|
|
1894
|
-
stockCheck: (params) =>
|
|
1895
|
-
stockSnapshot: (params) =>
|
|
1896
|
-
listingGroups: (params) =>
|
|
1897
|
-
listingGroupsCatalog: (params) =>
|
|
1903
|
+
stockCheck: (params) => api.post("/api/products/stock-check", params),
|
|
1904
|
+
stockSnapshot: (params) => api.get(stockSnapshotQuery(params)),
|
|
1905
|
+
listingGroups: (params) => api.get(listingGroupsQuery(params)),
|
|
1906
|
+
listingGroupsCatalog: (params) => api.get(listingGroupsCatalogQuery(params)),
|
|
1898
1907
|
detail: async (params) => {
|
|
1899
1908
|
try {
|
|
1900
|
-
const product = await
|
|
1909
|
+
const product = await api.get(productDetailQuery(params));
|
|
1901
1910
|
return { found: true, product };
|
|
1902
1911
|
} catch (err) {
|
|
1903
1912
|
const notFoundResult = productDetailResultFromError(err);
|
|
@@ -1907,7 +1916,7 @@ var CommerceClient = class {
|
|
|
1907
1916
|
},
|
|
1908
1917
|
detailCatalog: async (params) => {
|
|
1909
1918
|
try {
|
|
1910
|
-
const product = await
|
|
1919
|
+
const product = await api.get(
|
|
1911
1920
|
productDetailCatalogQuery(params)
|
|
1912
1921
|
);
|
|
1913
1922
|
return { found: true, product };
|
|
@@ -1930,7 +1939,7 @@ var CommerceClient = class {
|
|
|
1930
1939
|
this.orders = {
|
|
1931
1940
|
checkout: (params) => {
|
|
1932
1941
|
const { body, idempotencyKey } = splitIdempotencyKey(params);
|
|
1933
|
-
return
|
|
1942
|
+
return api.post(
|
|
1934
1943
|
"/api/orders/checkout",
|
|
1935
1944
|
body,
|
|
1936
1945
|
idempotencyRequestOptions(idempotencyKey)
|
|
@@ -1939,10 +1948,10 @@ var CommerceClient = class {
|
|
|
1939
1948
|
listMine: (params) => options.customerAuth.getMyOrders(params)
|
|
1940
1949
|
};
|
|
1941
1950
|
this.discounts = {
|
|
1942
|
-
validate: (params) =>
|
|
1951
|
+
validate: (params) => api.post("/api/discounts/validate", params)
|
|
1943
1952
|
};
|
|
1944
1953
|
this.shipping = {
|
|
1945
|
-
calculate: (params) =>
|
|
1954
|
+
calculate: (params) => api.post("/api/shipping-policies/calculate", params)
|
|
1946
1955
|
};
|
|
1947
1956
|
}
|
|
1948
1957
|
};
|
|
@@ -2298,7 +2307,7 @@ function getCommerceNotificationIdempotencyKey(event) {
|
|
|
2298
2307
|
function defineCommerceEmailConfig(config) {
|
|
2299
2308
|
return config;
|
|
2300
2309
|
}
|
|
2301
|
-
function
|
|
2310
|
+
function createCommerceNotificationWebhookHandler(handlers) {
|
|
2302
2311
|
return async (event) => {
|
|
2303
2312
|
if (!isCommerceNotificationWebhookEvent(event)) {
|
|
2304
2313
|
await handlers.unhandled?.(event);
|
|
@@ -2315,6 +2324,9 @@ function createCommerceEmailWebhookHandler(handlers) {
|
|
|
2315
2324
|
});
|
|
2316
2325
|
};
|
|
2317
2326
|
}
|
|
2327
|
+
function createCommerceEmailWebhookHandler(handlers) {
|
|
2328
|
+
return createCommerceNotificationWebhookHandler(handlers);
|
|
2329
|
+
}
|
|
2318
2330
|
function isWebhookCollection(event, collection) {
|
|
2319
2331
|
return isValidWebhookEvent(event) && event.collection === collection;
|
|
2320
2332
|
}
|
|
@@ -2484,6 +2496,8 @@ var COLLECTIONS = [
|
|
|
2484
2496
|
"order-items",
|
|
2485
2497
|
"returns",
|
|
2486
2498
|
"return-items",
|
|
2499
|
+
"fulfillment-orders",
|
|
2500
|
+
"fulfillment-order-items",
|
|
2487
2501
|
"fulfillments",
|
|
2488
2502
|
"fulfillment-items",
|
|
2489
2503
|
"transactions",
|
|
@@ -4275,10 +4289,12 @@ function buildProductListingCard(item, options = {}) {
|
|
|
4275
4289
|
const listingPrimaryMedia = listingPrimaryPointer ? productMediaPool.find(
|
|
4276
4290
|
(item2) => getRelationID(item2) === listingPrimaryPointer
|
|
4277
4291
|
) ?? resolvedPrimaryMedia.primaryImage ?? null : null;
|
|
4278
|
-
const priceRange =
|
|
4279
|
-
|
|
4280
|
-
|
|
4292
|
+
const priceRange = resolveListingCardPriceRange(
|
|
4293
|
+
product,
|
|
4294
|
+
projectedListing,
|
|
4295
|
+
groups
|
|
4281
4296
|
);
|
|
4297
|
+
const availableForSale = product.listing?.availableForSale != null ? product.listing.availableForSale : groups.length > 0 ? groups.some((group) => group.listing.availableForSale) : projectedListing.availableForSale;
|
|
4282
4298
|
const swatches = groups.length > 1 ? groups.map((group) => buildListingSwatch(product, group, options)) : [];
|
|
4283
4299
|
return {
|
|
4284
4300
|
id: String(product.id),
|
|
@@ -4318,6 +4334,42 @@ function findListingCardRepresentativeVariant(variants, representativeVariantId)
|
|
|
4318
4334
|
(variant) => getRelationID(variant.id) === representativeVariantId
|
|
4319
4335
|
) ?? null;
|
|
4320
4336
|
}
|
|
4337
|
+
function toShopifyPriceRangeV2(listing) {
|
|
4338
|
+
return {
|
|
4339
|
+
minVariantPrice: { amount: listing.minPrice ?? null },
|
|
4340
|
+
maxVariantPrice: { amount: listing.maxPrice ?? null }
|
|
4341
|
+
};
|
|
4342
|
+
}
|
|
4343
|
+
function hasCompleteListingPriceProjection(listing) {
|
|
4344
|
+
return listing?.minPrice != null && listing?.maxPrice != null;
|
|
4345
|
+
}
|
|
4346
|
+
function listingDefinesCompareAtProjection(listing) {
|
|
4347
|
+
return "minCompareAtPrice" in listing || "maxCompareAtPrice" in listing;
|
|
4348
|
+
}
|
|
4349
|
+
function resolveListingCardPriceRange(product, projectedListing, groups) {
|
|
4350
|
+
const listing = product.listing;
|
|
4351
|
+
if (hasCompleteListingPriceProjection(listing)) {
|
|
4352
|
+
const groupRange = groups.length > 0 ? aggregateListingPriceRange(groups) : null;
|
|
4353
|
+
const definesCompareAt = listingDefinesCompareAtProjection(listing);
|
|
4354
|
+
return {
|
|
4355
|
+
minPrice: listing.minPrice,
|
|
4356
|
+
maxPrice: listing.maxPrice,
|
|
4357
|
+
minCompareAtPrice: definesCompareAt ? listing.minCompareAtPrice ?? null : groupRange?.minCompareAtPrice ?? projectedListing.minCompareAtPrice,
|
|
4358
|
+
maxCompareAtPrice: definesCompareAt ? listing.maxCompareAtPrice ?? null : groupRange?.maxCompareAtPrice ?? projectedListing.maxCompareAtPrice,
|
|
4359
|
+
isPriceRange: listing.isPriceRange ?? listing.minPrice !== listing.maxPrice
|
|
4360
|
+
};
|
|
4361
|
+
}
|
|
4362
|
+
if (groups.length > 0) {
|
|
4363
|
+
return aggregateListingPriceRange(groups);
|
|
4364
|
+
}
|
|
4365
|
+
return {
|
|
4366
|
+
minPrice: projectedListing.minPrice,
|
|
4367
|
+
maxPrice: projectedListing.maxPrice,
|
|
4368
|
+
minCompareAtPrice: projectedListing.minCompareAtPrice,
|
|
4369
|
+
maxCompareAtPrice: projectedListing.maxCompareAtPrice,
|
|
4370
|
+
isPriceRange: projectedListing.isPriceRange
|
|
4371
|
+
};
|
|
4372
|
+
}
|
|
4321
4373
|
function aggregateListingPriceRange(groups) {
|
|
4322
4374
|
const minPrice = minOfNullable(groups.map((g) => g.listing.minPrice));
|
|
4323
4375
|
const maxPrice = maxOfNullable(groups.map((g) => g.listing.maxPrice));
|
|
@@ -4364,6 +4416,12 @@ function maxOfNullable(values) {
|
|
|
4364
4416
|
const numbers = values.filter((v) => v !== null);
|
|
4365
4417
|
return numbers.length === 0 ? null : Math.max(...numbers);
|
|
4366
4418
|
}
|
|
4419
|
+
var PRODUCT_PLP_FIND_OPTIONS = {
|
|
4420
|
+
joins: {
|
|
4421
|
+
variants: { limit: 200, sort: "_order" },
|
|
4422
|
+
options: { limit: 50, sort: "_order" }
|
|
4423
|
+
}
|
|
4424
|
+
};
|
|
4367
4425
|
function buildProductListingGroupsByOption(args) {
|
|
4368
4426
|
const primaryOptionId = args.primaryOptionId ?? void 0;
|
|
4369
4427
|
if (!primaryOptionId) return [];
|
|
@@ -4578,14 +4636,22 @@ function resolveProductGallery(input) {
|
|
|
4578
4636
|
}
|
|
4579
4637
|
|
|
4580
4638
|
// src/utils/image.ts
|
|
4581
|
-
var IMAGE_SIZES = [
|
|
4639
|
+
var IMAGE_SIZES = [200, 400, 800, 1200, 1600];
|
|
4640
|
+
function imageSizeCandidates(sizes) {
|
|
4641
|
+
const keys = new Set(IMAGE_SIZES);
|
|
4642
|
+
for (const key of Object.keys(sizes)) {
|
|
4643
|
+
const value = Number(key);
|
|
4644
|
+
if (Number.isFinite(value) && value > 0) keys.add(value);
|
|
4645
|
+
}
|
|
4646
|
+
return [...keys].sort((a, b) => a - b);
|
|
4647
|
+
}
|
|
4582
4648
|
function getImageUrl(image, displayWidth, dpr = 1) {
|
|
4583
4649
|
const target = displayWidth * dpr;
|
|
4584
4650
|
const sizes = image.sizes;
|
|
4585
4651
|
if (sizes) {
|
|
4586
|
-
for (const size of
|
|
4652
|
+
for (const size of imageSizeCandidates(sizes)) {
|
|
4587
4653
|
if (size >= target) {
|
|
4588
|
-
const entry = sizes[
|
|
4654
|
+
const entry = sizes[`${size}`];
|
|
4589
4655
|
if (entry?.url) return entry.url;
|
|
4590
4656
|
}
|
|
4591
4657
|
}
|
|
@@ -4594,16 +4660,18 @@ function getImageUrl(image, displayWidth, dpr = 1) {
|
|
|
4594
4660
|
}
|
|
4595
4661
|
function getImageSrcSet(image) {
|
|
4596
4662
|
const parts = [];
|
|
4663
|
+
const emittedWidths = /* @__PURE__ */ new Set();
|
|
4597
4664
|
const sizes = image.sizes;
|
|
4598
4665
|
if (sizes) {
|
|
4599
|
-
for (const size of
|
|
4600
|
-
const entry = sizes[
|
|
4601
|
-
if (entry?.url && entry.width) {
|
|
4666
|
+
for (const size of imageSizeCandidates(sizes)) {
|
|
4667
|
+
const entry = sizes[`${size}`];
|
|
4668
|
+
if (entry?.url && entry.width && !emittedWidths.has(entry.width)) {
|
|
4669
|
+
emittedWidths.add(entry.width);
|
|
4602
4670
|
parts.push(`${entry.url} ${entry.width}w`);
|
|
4603
4671
|
}
|
|
4604
4672
|
}
|
|
4605
4673
|
}
|
|
4606
|
-
if (image.url && image.width) {
|
|
4674
|
+
if (image.url && image.width && !emittedWidths.has(image.width)) {
|
|
4607
4675
|
parts.push(`${image.url} ${image.width}w`);
|
|
4608
4676
|
}
|
|
4609
4677
|
return parts.join(", ");
|
|
@@ -4705,6 +4773,27 @@ function createAnalytics(config) {
|
|
|
4705
4773
|
const nav = navigator;
|
|
4706
4774
|
return nav.doNotTrack === "1" || nav.globalPrivacyControl === true;
|
|
4707
4775
|
}
|
|
4776
|
+
const isLocalHost = (() => {
|
|
4777
|
+
try {
|
|
4778
|
+
const h = location.hostname;
|
|
4779
|
+
return h === "localhost" || h === "127.0.0.1" || h.endsWith(".local");
|
|
4780
|
+
} catch {
|
|
4781
|
+
return false;
|
|
4782
|
+
}
|
|
4783
|
+
})();
|
|
4784
|
+
const mode = config.mode ?? "auto";
|
|
4785
|
+
const sendSuppressed = mode === "development" || mode === "auto" && isLocalHost;
|
|
4786
|
+
let suppressNoticeShown = false;
|
|
4787
|
+
function devSuppressNotice() {
|
|
4788
|
+
if (suppressNoticeShown) return;
|
|
4789
|
+
suppressNoticeShown = true;
|
|
4790
|
+
try {
|
|
4791
|
+
console.info(
|
|
4792
|
+
`[01 analytics] events disabled on local host (mode: '${mode}'). Pass mode: 'production' to send while developing.`
|
|
4793
|
+
);
|
|
4794
|
+
} catch {
|
|
4795
|
+
}
|
|
4796
|
+
}
|
|
4708
4797
|
let lastPath = null;
|
|
4709
4798
|
let lastAt = 0;
|
|
4710
4799
|
const autoTrack = config.autoTrack !== false;
|
|
@@ -4735,6 +4824,10 @@ function createAnalytics(config) {
|
|
|
4735
4824
|
if (isDntActive()) return;
|
|
4736
4825
|
const doc = document;
|
|
4737
4826
|
if (doc.prerendering === true || document.visibilityState === "prerender") return;
|
|
4827
|
+
if (sendSuppressed) {
|
|
4828
|
+
devSuppressNotice();
|
|
4829
|
+
return;
|
|
4830
|
+
}
|
|
4738
4831
|
const now = Date.now();
|
|
4739
4832
|
if (pathname === lastPath && now - lastAt < 500) return;
|
|
4740
4833
|
lastPath = pathname;
|
|
@@ -4770,14 +4863,7 @@ function createAnalytics(config) {
|
|
|
4770
4863
|
window.addEventListener("load", trackCurrentPath, { once: true });
|
|
4771
4864
|
}
|
|
4772
4865
|
}
|
|
4773
|
-
const isProduction =
|
|
4774
|
-
try {
|
|
4775
|
-
const hostname = location.hostname;
|
|
4776
|
-
return hostname !== "localhost" && hostname !== "127.0.0.1" && !hostname.endsWith(".local");
|
|
4777
|
-
} catch {
|
|
4778
|
-
return true;
|
|
4779
|
-
}
|
|
4780
|
-
})();
|
|
4866
|
+
const isProduction = !isLocalHost;
|
|
4781
4867
|
const warnedReasons = /* @__PURE__ */ new Set();
|
|
4782
4868
|
function devWarn(name, reason) {
|
|
4783
4869
|
if (isProduction) return;
|
|
@@ -4837,6 +4923,10 @@ function createAnalytics(config) {
|
|
|
4837
4923
|
return;
|
|
4838
4924
|
}
|
|
4839
4925
|
}
|
|
4926
|
+
if (sendSuppressed) {
|
|
4927
|
+
devSuppressNotice();
|
|
4928
|
+
return;
|
|
4929
|
+
}
|
|
4840
4930
|
const body = JSON.stringify({
|
|
4841
4931
|
publishableKey: config.publishableKey,
|
|
4842
4932
|
pathname: location.pathname,
|
|
@@ -4891,6 +4981,7 @@ export {
|
|
|
4891
4981
|
NotFoundError,
|
|
4892
4982
|
ORDER_CHANGED_EVENT_TYPE,
|
|
4893
4983
|
OrderApi,
|
|
4984
|
+
PRODUCT_PLP_FIND_OPTIONS,
|
|
4894
4985
|
PRODUCT_UPSERT_READONLY_FIELD_REASON,
|
|
4895
4986
|
PRODUCT_UPSERT_UNKNOWN_FIELD_REASON,
|
|
4896
4987
|
PermissionError,
|
|
@@ -4916,6 +5007,7 @@ export {
|
|
|
4916
5007
|
createAuthError,
|
|
4917
5008
|
createClient2 as createClient,
|
|
4918
5009
|
createCommerceEmailWebhookHandler,
|
|
5010
|
+
createCommerceNotificationWebhookHandler,
|
|
4919
5011
|
createConflictError,
|
|
4920
5012
|
createCustomerAuthWebhookHandler,
|
|
4921
5013
|
createNotFoundError,
|
|
@@ -4978,6 +5070,7 @@ export {
|
|
|
4978
5070
|
resolveVariantForSelection,
|
|
4979
5071
|
selectNext,
|
|
4980
5072
|
selectedSwatchMediaItemId,
|
|
4981
|
-
stringifyProductSelection
|
|
5073
|
+
stringifyProductSelection,
|
|
5074
|
+
toShopifyPriceRangeV2
|
|
4982
5075
|
};
|
|
4983
5076
|
//# sourceMappingURL=index.js.map
|