@01.software/sdk 0.36.0 → 0.38.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 +142 -55
- 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 +150 -207
- 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 +150 -207
- package/dist/client.js.map +1 -1
- package/dist/{collection-client-Cv0D2w1Q.d.cts → collection-client-B0J9wMNE.d.cts} +5 -5
- package/dist/{collection-client-Bq5Zd7p7.d.ts → collection-client-BroIWHY1.d.ts} +5 -5
- package/dist/const-6XHz_jej.d.ts +32 -0
- package/dist/const-B5KT72c7.d.cts +32 -0
- 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-BOLQxveo.d.cts} +9 -6
- package/dist/{index-BHDKJ6B3.d.cts → index-CSwR2HSg.d.ts} +9 -6
- package/dist/index.cjs +256 -244
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -11
- package/dist/index.d.ts +12 -11
- package/dist/index.js +256 -244
- 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-m3jjhxk9.d.cts} +669 -184
- package/dist/{payload-types-BCui2Oml.d.ts → payload-types-m3jjhxk9.d.ts} +669 -184
- package/dist/query.cjs +3 -1033
- package/dist/query.cjs.map +1 -1
- package/dist/query.d.cts +13 -13
- package/dist/query.d.ts +13 -13
- package/dist/query.js +3 -1033
- 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 +121 -85
- 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 +121 -85
- package/dist/server.js.map +1 -1
- package/dist/{types-Dib-zdK6.d.cts → types-CIGscmus.d.cts} +1471 -1100
- package/dist/{types-3qV6sY7T.d.ts → types-Cmrd1ezc.d.ts} +1 -15
- package/dist/{types-CEzLf3PX.d.cts → types-D0ubzQw0.d.cts} +1 -15
- package/dist/{types-DK9EnLwJ.d.ts → types-D2xYdz4P.d.ts} +1471 -1100
- 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/const-BDUKFP9w.d.ts +0 -32
- package/dist/const-DVcM7Ac_.d.cts +0 -32
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,70 +947,20 @@ 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
|
-
};
|
|
953
|
-
|
|
954
|
-
// src/core/metadata/index.ts
|
|
955
|
-
function extractSeo(doc) {
|
|
956
|
-
const seo = doc.seo ?? {};
|
|
957
|
-
const og = seo.openGraph ?? {};
|
|
958
|
-
return {
|
|
959
|
-
title: seo.title ?? doc.title ?? null,
|
|
960
|
-
description: seo.description ?? null,
|
|
961
|
-
noIndex: seo.noIndex ?? null,
|
|
962
|
-
canonical: seo.canonical ?? null,
|
|
963
|
-
openGraph: {
|
|
964
|
-
title: og.title ?? null,
|
|
965
|
-
description: og.description ?? null,
|
|
966
|
-
image: og.image ?? null
|
|
967
|
-
}
|
|
968
|
-
};
|
|
969
|
-
}
|
|
970
|
-
function generateMetadata(input, options) {
|
|
971
|
-
const title = input.title ?? void 0;
|
|
972
|
-
const description = input.description ?? void 0;
|
|
973
|
-
const ogTitle = input.openGraph?.title ?? title;
|
|
974
|
-
const ogDescription = input.openGraph?.description ?? description;
|
|
975
|
-
const image = resolveMetaImage(input.openGraph?.image);
|
|
976
|
-
return {
|
|
977
|
-
title,
|
|
978
|
-
description,
|
|
979
|
-
...input.noIndex && { robots: { index: false, follow: false } },
|
|
980
|
-
...input.canonical && { alternates: { canonical: input.canonical } },
|
|
981
|
-
openGraph: {
|
|
982
|
-
...ogTitle && { title: ogTitle },
|
|
983
|
-
...ogDescription && { description: ogDescription },
|
|
984
|
-
...options?.siteName && { siteName: options.siteName },
|
|
985
|
-
...image && { images: [image] }
|
|
986
|
-
},
|
|
987
|
-
twitter: {
|
|
988
|
-
card: image ? "summary_large_image" : "summary",
|
|
989
|
-
...ogTitle && { title: ogTitle },
|
|
990
|
-
...ogDescription && { description: ogDescription },
|
|
991
|
-
...image && { images: [image.url] }
|
|
992
|
-
}
|
|
993
|
-
};
|
|
994
954
|
}
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
const sized = image.sizes?.["1536"];
|
|
999
|
-
const url = sized?.url || image.url;
|
|
1000
|
-
if (!url) return null;
|
|
1001
|
-
const width = sized?.url ? sized.width : image.width;
|
|
1002
|
-
const height = sized?.url ? sized.height : image.height;
|
|
955
|
+
|
|
956
|
+
// src/core/collection/query-builder.ts
|
|
957
|
+
function withDefaultPublicReadOptions(options) {
|
|
1003
958
|
return {
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
...image.alt && { alt: image.alt }
|
|
959
|
+
...options,
|
|
960
|
+
depth: options?.depth ?? 0,
|
|
961
|
+
joins: options?.joins ?? false
|
|
1008
962
|
};
|
|
1009
963
|
}
|
|
1010
|
-
|
|
1011
|
-
// src/core/collection/query-builder.ts
|
|
1012
964
|
var ReadOnlyCollectionQueryBuilder = class {
|
|
1013
965
|
constructor(api, collection) {
|
|
1014
966
|
this.api = api;
|
|
@@ -1017,13 +969,13 @@ var ReadOnlyCollectionQueryBuilder = class {
|
|
|
1017
969
|
async find(options) {
|
|
1018
970
|
return this.api.requestFind(
|
|
1019
971
|
`/api/${String(this.collection)}`,
|
|
1020
|
-
options
|
|
972
|
+
withDefaultPublicReadOptions(options)
|
|
1021
973
|
);
|
|
1022
974
|
}
|
|
1023
975
|
async findById(id, options) {
|
|
1024
976
|
return this.api.requestFindById(
|
|
1025
977
|
`/api/${String(this.collection)}/${String(id)}`,
|
|
1026
|
-
options
|
|
978
|
+
withDefaultPublicReadOptions(options)
|
|
1027
979
|
);
|
|
1028
980
|
}
|
|
1029
981
|
async count(options) {
|
|
@@ -1032,22 +984,6 @@ var ReadOnlyCollectionQueryBuilder = class {
|
|
|
1032
984
|
options
|
|
1033
985
|
);
|
|
1034
986
|
}
|
|
1035
|
-
async findMetadata(options, metadataOptions) {
|
|
1036
|
-
const { docs } = await this.find({ ...options, limit: 1, depth: 1 });
|
|
1037
|
-
const doc = docs[0];
|
|
1038
|
-
if (!doc) return null;
|
|
1039
|
-
return generateMetadata(
|
|
1040
|
-
extractSeo(doc),
|
|
1041
|
-
metadataOptions
|
|
1042
|
-
);
|
|
1043
|
-
}
|
|
1044
|
-
async findMetadataById(id, metadataOptions) {
|
|
1045
|
-
const doc = await this.findById(id, { depth: 1 });
|
|
1046
|
-
return generateMetadata(
|
|
1047
|
-
extractSeo(doc),
|
|
1048
|
-
metadataOptions
|
|
1049
|
-
);
|
|
1050
|
-
}
|
|
1051
987
|
};
|
|
1052
988
|
|
|
1053
989
|
// src/core/collection/collection-client.ts
|
|
@@ -1063,6 +999,21 @@ var ReadOnlyCollectionClient = class extends HttpClient {
|
|
|
1063
999
|
});
|
|
1064
1000
|
return this.parseFindResponse(response);
|
|
1065
1001
|
}
|
|
1002
|
+
async requestFindEndpoint(endpoint, data) {
|
|
1003
|
+
const response = await this.fetchWithTracking(endpoint, {
|
|
1004
|
+
...this.defaultOptions,
|
|
1005
|
+
method: "POST",
|
|
1006
|
+
body: data ? JSON.stringify(data) : void 0
|
|
1007
|
+
});
|
|
1008
|
+
return this.parseFindResponse(response);
|
|
1009
|
+
}
|
|
1010
|
+
async requestFindEndpointGet(endpoint) {
|
|
1011
|
+
const response = await this.fetchWithTracking(endpoint, {
|
|
1012
|
+
...this.defaultOptions,
|
|
1013
|
+
method: "GET"
|
|
1014
|
+
});
|
|
1015
|
+
return this.parseFindResponse(response);
|
|
1016
|
+
}
|
|
1066
1017
|
async requestFindById(endpoint, options) {
|
|
1067
1018
|
const url = this.buildUrl(endpoint, options);
|
|
1068
1019
|
const response = await this.fetchWithTracking(url, {
|
|
@@ -1127,13 +1078,16 @@ async function parseApiResponse(response, endpoint) {
|
|
|
1127
1078
|
return data;
|
|
1128
1079
|
}
|
|
1129
1080
|
|
|
1130
|
-
// src/core/
|
|
1131
|
-
var
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1081
|
+
// src/core/api/customer-scoped-api.ts
|
|
1082
|
+
var CustomerScopedApi = class {
|
|
1083
|
+
constructor(apiName, options) {
|
|
1084
|
+
if (options.requiresCredential !== false && !options.secretKey && !options.customerToken) {
|
|
1085
|
+
throw createConfigError(
|
|
1086
|
+
`Either secretKey or customerToken is required for ${apiName}.`
|
|
1087
|
+
);
|
|
1088
|
+
}
|
|
1135
1089
|
this.publishableKey = requirePublishableKeyForSecret(
|
|
1136
|
-
|
|
1090
|
+
apiName,
|
|
1137
1091
|
options.publishableKey,
|
|
1138
1092
|
options.secretKey
|
|
1139
1093
|
);
|
|
@@ -1143,6 +1097,44 @@ var CommunityClient = class {
|
|
|
1143
1097
|
this.onUnauthorized = options.onUnauthorized;
|
|
1144
1098
|
this.onRequestId = options.onRequestId;
|
|
1145
1099
|
}
|
|
1100
|
+
async request(endpoint, options) {
|
|
1101
|
+
const token = typeof this.customerToken === "function" ? this.customerToken() : this.customerToken;
|
|
1102
|
+
try {
|
|
1103
|
+
const response = await httpFetch(endpoint, {
|
|
1104
|
+
method: options.method,
|
|
1105
|
+
apiUrl: this.apiUrl,
|
|
1106
|
+
publishableKey: this.publishableKey,
|
|
1107
|
+
secretKey: this.secretKey,
|
|
1108
|
+
customerToken: token ?? void 0,
|
|
1109
|
+
...token && this.onUnauthorized && { onUnauthorized: this.onUnauthorized },
|
|
1110
|
+
...options.body !== void 0 && {
|
|
1111
|
+
body: JSON.stringify(options.body)
|
|
1112
|
+
},
|
|
1113
|
+
...options.headers && { headers: options.headers }
|
|
1114
|
+
});
|
|
1115
|
+
this.onRequestId?.(response.headers.get("x-request-id") ?? null);
|
|
1116
|
+
return parseApiResponse(response, endpoint);
|
|
1117
|
+
} catch (err) {
|
|
1118
|
+
const id = err instanceof SDKError ? err.requestId ?? null : null;
|
|
1119
|
+
this.onRequestId?.(id);
|
|
1120
|
+
throw err;
|
|
1121
|
+
}
|
|
1122
|
+
}
|
|
1123
|
+
};
|
|
1124
|
+
|
|
1125
|
+
// src/core/community/community-client.ts
|
|
1126
|
+
var DEFAULT_POST_LIST_SORT = "-lastActivityAt";
|
|
1127
|
+
var DEFAULT_COMMENT_LIST_SORT = "-createdAt";
|
|
1128
|
+
function unwrapPayloadDoc(value) {
|
|
1129
|
+
if (value && typeof value === "object" && "doc" in value) {
|
|
1130
|
+
return value.doc;
|
|
1131
|
+
}
|
|
1132
|
+
return value;
|
|
1133
|
+
}
|
|
1134
|
+
var CommunityClient = class extends CustomerScopedApi {
|
|
1135
|
+
constructor(options) {
|
|
1136
|
+
super("CommunityClient", { ...options, requiresCredential: false });
|
|
1137
|
+
}
|
|
1146
1138
|
buildQuery(params) {
|
|
1147
1139
|
if (!params) return "";
|
|
1148
1140
|
const entries = Object.entries(params).filter((e) => e[1] !== void 0).map(([k, v]) => [k, String(v)]);
|
|
@@ -1152,7 +1144,8 @@ var CommunityClient = class {
|
|
|
1152
1144
|
const urlParams = new URLSearchParams();
|
|
1153
1145
|
const sort = params?.sort ?? DEFAULT_POST_LIST_SORT;
|
|
1154
1146
|
urlParams.set("sort", sort);
|
|
1155
|
-
if (params?.limit !== void 0)
|
|
1147
|
+
if (params?.limit !== void 0)
|
|
1148
|
+
urlParams.set("limit", String(params.limit));
|
|
1156
1149
|
if (params?.page !== void 0) urlParams.set("page", String(params.page));
|
|
1157
1150
|
if (params?.categoryId !== void 0) {
|
|
1158
1151
|
urlParams.set("where[categories][in]", params.categoryId);
|
|
@@ -1160,7 +1153,7 @@ var CommunityClient = class {
|
|
|
1160
1153
|
if (params?.tagId !== void 0) {
|
|
1161
1154
|
urlParams.set("where[tags][in]", params.tagId);
|
|
1162
1155
|
}
|
|
1163
|
-
return `/api/posts?${urlParams.toString()}`;
|
|
1156
|
+
return `/api/posts/public?${urlParams.toString()}`;
|
|
1164
1157
|
}
|
|
1165
1158
|
buildCommentsListQuery(params) {
|
|
1166
1159
|
const urlParams = new URLSearchParams();
|
|
@@ -1180,30 +1173,21 @@ var CommunityClient = class {
|
|
|
1180
1173
|
}
|
|
1181
1174
|
if (params.limit !== void 0) urlParams.set("limit", String(params.limit));
|
|
1182
1175
|
if (params.page !== void 0) urlParams.set("page", String(params.page));
|
|
1183
|
-
return `/api/comments?${urlParams.toString()}`;
|
|
1176
|
+
return `/api/comments/public?${urlParams.toString()}`;
|
|
1184
1177
|
}
|
|
1185
1178
|
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
|
-
}
|
|
1179
|
+
return this.request(endpoint, { method, body });
|
|
1180
|
+
}
|
|
1181
|
+
async executeDoc(endpoint, method, body) {
|
|
1182
|
+
const response = await this.execute(endpoint, method, body);
|
|
1183
|
+
return unwrapPayloadDoc(response);
|
|
1204
1184
|
}
|
|
1205
1185
|
createPost(params) {
|
|
1206
|
-
return this.
|
|
1186
|
+
return this.executeDoc(
|
|
1187
|
+
"/api/posts",
|
|
1188
|
+
"POST",
|
|
1189
|
+
params
|
|
1190
|
+
);
|
|
1207
1191
|
}
|
|
1208
1192
|
/**
|
|
1209
1193
|
* Public post feed. Server applies the same visibility contract as
|
|
@@ -1260,7 +1244,11 @@ var CommunityClient = class {
|
|
|
1260
1244
|
if (parentId !== void 0) {
|
|
1261
1245
|
body.parent = parentId;
|
|
1262
1246
|
}
|
|
1263
|
-
return this.
|
|
1247
|
+
return this.executeDoc(
|
|
1248
|
+
"/api/comments",
|
|
1249
|
+
"POST",
|
|
1250
|
+
body
|
|
1251
|
+
);
|
|
1264
1252
|
}
|
|
1265
1253
|
/**
|
|
1266
1254
|
* List comments for a post.
|
|
@@ -1298,7 +1286,7 @@ var CommunityClient = class {
|
|
|
1298
1286
|
}
|
|
1299
1287
|
updateComment(params) {
|
|
1300
1288
|
const { commentId, body } = params;
|
|
1301
|
-
return this.
|
|
1289
|
+
return this.executeDoc(
|
|
1302
1290
|
`/api/comments/${commentId}`,
|
|
1303
1291
|
"PATCH",
|
|
1304
1292
|
{ body }
|
|
@@ -1329,10 +1317,14 @@ var CommunityClient = class {
|
|
|
1329
1317
|
400
|
|
1330
1318
|
);
|
|
1331
1319
|
}
|
|
1332
|
-
return this.
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1320
|
+
return this.executeDoc(
|
|
1321
|
+
"/api/reactions",
|
|
1322
|
+
"POST",
|
|
1323
|
+
{
|
|
1324
|
+
post: postId,
|
|
1325
|
+
type: reactionType
|
|
1326
|
+
}
|
|
1327
|
+
);
|
|
1336
1328
|
}
|
|
1337
1329
|
removeReaction(params) {
|
|
1338
1330
|
const { postId, type } = params;
|
|
@@ -1351,10 +1343,14 @@ var CommunityClient = class {
|
|
|
1351
1343
|
400
|
|
1352
1344
|
);
|
|
1353
1345
|
}
|
|
1354
|
-
return this.
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1346
|
+
return this.executeDoc(
|
|
1347
|
+
"/api/reactions",
|
|
1348
|
+
"POST",
|
|
1349
|
+
{
|
|
1350
|
+
comment: commentId,
|
|
1351
|
+
type: reactionType
|
|
1352
|
+
}
|
|
1353
|
+
);
|
|
1358
1354
|
}
|
|
1359
1355
|
removeCommentReaction(params) {
|
|
1360
1356
|
const { commentId, type } = params;
|
|
@@ -1383,9 +1379,13 @@ var CommunityClient = class {
|
|
|
1383
1379
|
}
|
|
1384
1380
|
// Bookmarks
|
|
1385
1381
|
addBookmark(params) {
|
|
1386
|
-
return this.
|
|
1387
|
-
|
|
1388
|
-
|
|
1382
|
+
return this.executeDoc(
|
|
1383
|
+
"/api/bookmarks",
|
|
1384
|
+
"POST",
|
|
1385
|
+
{
|
|
1386
|
+
post: params.postId
|
|
1387
|
+
}
|
|
1388
|
+
);
|
|
1389
1389
|
}
|
|
1390
1390
|
removeBookmark(params) {
|
|
1391
1391
|
return this.execute(
|
|
@@ -1401,10 +1401,7 @@ var CommunityClient = class {
|
|
|
1401
1401
|
}
|
|
1402
1402
|
// Profiles
|
|
1403
1403
|
listProfileLists(params) {
|
|
1404
|
-
return this.execute(
|
|
1405
|
-
`/api/customer-profile-lists${this.buildQuery(params)}`,
|
|
1406
|
-
"GET"
|
|
1407
|
-
);
|
|
1404
|
+
return this.execute(`/api/customer-profile-lists${this.buildQuery(params)}`, "GET");
|
|
1408
1405
|
}
|
|
1409
1406
|
async getProfileList(params) {
|
|
1410
1407
|
const query = "slug" in params ? `?where[slug][equals]=${encodeURIComponent(params.slug)}&limit=1` : `?where[id][equals]=${encodeURIComponent(params.id)}&limit=1`;
|
|
@@ -1634,46 +1631,18 @@ var CustomerNamespace = class {
|
|
|
1634
1631
|
};
|
|
1635
1632
|
|
|
1636
1633
|
// src/core/api/cart-api.ts
|
|
1637
|
-
var CartApi = class {
|
|
1634
|
+
var CartApi = class extends CustomerScopedApi {
|
|
1638
1635
|
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;
|
|
1636
|
+
super("CartApi", options);
|
|
1654
1637
|
}
|
|
1655
1638
|
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
|
-
}
|
|
1639
|
+
return this.request(endpoint, { method, body });
|
|
1674
1640
|
}
|
|
1675
1641
|
getCart(cartId) {
|
|
1676
|
-
return this.execute(
|
|
1642
|
+
return this.execute(
|
|
1643
|
+
`/api/carts/${cartId}?depth=0&joins=false`,
|
|
1644
|
+
"GET"
|
|
1645
|
+
);
|
|
1677
1646
|
}
|
|
1678
1647
|
addItem(params) {
|
|
1679
1648
|
return this.execute("/api/carts/add-item", "POST", params);
|
|
@@ -1894,15 +1863,24 @@ function splitIdempotencyKey(params) {
|
|
|
1894
1863
|
const { idempotencyKey, ...body } = params;
|
|
1895
1864
|
return { body, idempotencyKey };
|
|
1896
1865
|
}
|
|
1866
|
+
function normalizeCreateOrderBody(params) {
|
|
1867
|
+
if (params.items !== void 0) {
|
|
1868
|
+
const { idempotencyKey: _idempotencyKey2, items, ...rest } = params;
|
|
1869
|
+
return { ...rest, orderItems: items };
|
|
1870
|
+
}
|
|
1871
|
+
const { idempotencyKey: _idempotencyKey, ...body } = params;
|
|
1872
|
+
return body;
|
|
1873
|
+
}
|
|
1897
1874
|
var OrderApi = class extends BaseApi {
|
|
1898
1875
|
constructor(options) {
|
|
1899
1876
|
super("OrderApi", options);
|
|
1900
1877
|
}
|
|
1901
1878
|
createOrder(params) {
|
|
1902
|
-
const {
|
|
1879
|
+
const { idempotencyKey } = params;
|
|
1880
|
+
const normalizedBody = normalizeCreateOrderBody(params);
|
|
1903
1881
|
return this.request(
|
|
1904
1882
|
"/api/orders/create",
|
|
1905
|
-
|
|
1883
|
+
normalizedBody,
|
|
1906
1884
|
idempotencyRequestOptions(idempotencyKey)
|
|
1907
1885
|
);
|
|
1908
1886
|
}
|
|
@@ -1964,6 +1942,12 @@ var OrderApi = class extends BaseApi {
|
|
|
1964
1942
|
idempotencyRequestOptions(idempotencyKey)
|
|
1965
1943
|
);
|
|
1966
1944
|
}
|
|
1945
|
+
prepareFulfillmentOrder(params) {
|
|
1946
|
+
return this.request(
|
|
1947
|
+
"/api/fulfillment-orders/prepare-fulfillment-order",
|
|
1948
|
+
params
|
|
1949
|
+
);
|
|
1950
|
+
}
|
|
1967
1951
|
updateFulfillment(params) {
|
|
1968
1952
|
return this.request("/api/orders/update-fulfillment", params);
|
|
1969
1953
|
}
|
|
@@ -1995,6 +1979,18 @@ var OrderApi = class extends BaseApi {
|
|
|
1995
1979
|
};
|
|
1996
1980
|
|
|
1997
1981
|
// src/core/commerce/commerce-client.ts
|
|
1982
|
+
var BrowserCommerceApi = class extends CustomerScopedApi {
|
|
1983
|
+
post(endpoint, body, requestOptions) {
|
|
1984
|
+
return this.request(endpoint, {
|
|
1985
|
+
method: "POST",
|
|
1986
|
+
body,
|
|
1987
|
+
headers: requestOptions?.headers
|
|
1988
|
+
});
|
|
1989
|
+
}
|
|
1990
|
+
get(endpoint) {
|
|
1991
|
+
return this.request(endpoint, { method: "GET" });
|
|
1992
|
+
}
|
|
1993
|
+
};
|
|
1998
1994
|
var CommerceClient = class {
|
|
1999
1995
|
constructor(options) {
|
|
2000
1996
|
const cartApi = new CartApi({
|
|
@@ -2004,52 +2000,23 @@ var CommerceClient = class {
|
|
|
2004
2000
|
onUnauthorized: options.onUnauthorized,
|
|
2005
2001
|
onRequestId: options.onRequestId
|
|
2006
2002
|
});
|
|
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
|
-
};
|
|
2003
|
+
const api = new BrowserCommerceApi("CommerceClient", {
|
|
2004
|
+
publishableKey: options.publishableKey,
|
|
2005
|
+
apiUrl: options.apiUrl,
|
|
2006
|
+
customerToken: options.customerToken,
|
|
2007
|
+
onUnauthorized: options.onUnauthorized,
|
|
2008
|
+
onRequestId: options.onRequestId
|
|
2009
|
+
});
|
|
2045
2010
|
this.product = {
|
|
2046
|
-
stockCheck: (params) =>
|
|
2047
|
-
stockSnapshot: (params) =>
|
|
2048
|
-
listingGroups: (params) =>
|
|
2049
|
-
listingGroupsCatalog: (params) =>
|
|
2011
|
+
stockCheck: (params) => api.post("/api/products/stock-check", params),
|
|
2012
|
+
stockSnapshot: (params) => api.get(stockSnapshotQuery(params)),
|
|
2013
|
+
listingGroups: (params) => api.get(listingGroupsQuery(params)),
|
|
2014
|
+
listingGroupsCatalog: (params) => api.get(
|
|
2015
|
+
listingGroupsCatalogQuery(params)
|
|
2016
|
+
),
|
|
2050
2017
|
detail: async (params) => {
|
|
2051
2018
|
try {
|
|
2052
|
-
const product = await
|
|
2019
|
+
const product = await api.get(productDetailQuery(params));
|
|
2053
2020
|
return { found: true, product };
|
|
2054
2021
|
} catch (err) {
|
|
2055
2022
|
const notFoundResult = productDetailResultFromError(err);
|
|
@@ -2059,7 +2026,7 @@ var CommerceClient = class {
|
|
|
2059
2026
|
},
|
|
2060
2027
|
detailCatalog: async (params) => {
|
|
2061
2028
|
try {
|
|
2062
|
-
const product = await
|
|
2029
|
+
const product = await api.get(
|
|
2063
2030
|
productDetailCatalogQuery(params)
|
|
2064
2031
|
);
|
|
2065
2032
|
return { found: true, product };
|
|
@@ -2082,7 +2049,7 @@ var CommerceClient = class {
|
|
|
2082
2049
|
this.orders = {
|
|
2083
2050
|
checkout: (params) => {
|
|
2084
2051
|
const { body, idempotencyKey } = splitIdempotencyKey(params);
|
|
2085
|
-
return
|
|
2052
|
+
return api.post(
|
|
2086
2053
|
"/api/orders/checkout",
|
|
2087
2054
|
body,
|
|
2088
2055
|
idempotencyRequestOptions(idempotencyKey)
|
|
@@ -2091,10 +2058,10 @@ var CommerceClient = class {
|
|
|
2091
2058
|
listMine: (params) => options.customerAuth.getMyOrders(params)
|
|
2092
2059
|
};
|
|
2093
2060
|
this.discounts = {
|
|
2094
|
-
validate: (params) =>
|
|
2061
|
+
validate: (params) => api.post("/api/discounts/validate", params)
|
|
2095
2062
|
};
|
|
2096
2063
|
this.shipping = {
|
|
2097
|
-
calculate: (params) =>
|
|
2064
|
+
calculate: (params) => api.post("/api/shipping-policies/calculate", params)
|
|
2098
2065
|
};
|
|
2099
2066
|
}
|
|
2100
2067
|
};
|
|
@@ -2450,7 +2417,7 @@ function getCommerceNotificationIdempotencyKey(event) {
|
|
|
2450
2417
|
function defineCommerceEmailConfig(config) {
|
|
2451
2418
|
return config;
|
|
2452
2419
|
}
|
|
2453
|
-
function
|
|
2420
|
+
function createCommerceNotificationWebhookHandler(handlers) {
|
|
2454
2421
|
return async (event) => {
|
|
2455
2422
|
if (!isCommerceNotificationWebhookEvent(event)) {
|
|
2456
2423
|
await handlers.unhandled?.(event);
|
|
@@ -2467,6 +2434,9 @@ function createCommerceEmailWebhookHandler(handlers) {
|
|
|
2467
2434
|
});
|
|
2468
2435
|
};
|
|
2469
2436
|
}
|
|
2437
|
+
function createCommerceEmailWebhookHandler(handlers) {
|
|
2438
|
+
return createCommerceNotificationWebhookHandler(handlers);
|
|
2439
|
+
}
|
|
2470
2440
|
function isWebhookCollection(event, collection) {
|
|
2471
2441
|
return isValidWebhookEvent(event) && event.collection === collection;
|
|
2472
2442
|
}
|
|
@@ -2604,6 +2574,7 @@ var INTERNAL_COLLECTIONS = [
|
|
|
2604
2574
|
"subscriptions",
|
|
2605
2575
|
"billing-history",
|
|
2606
2576
|
"inventory-reservations",
|
|
2577
|
+
"inventory-adjustments",
|
|
2607
2578
|
"commerce-notification-intents",
|
|
2608
2579
|
"product-collection-items",
|
|
2609
2580
|
"order-status-logs",
|
|
@@ -2622,7 +2593,6 @@ var INTERNAL_COLLECTIONS = [
|
|
|
2622
2593
|
var COLLECTIONS = [
|
|
2623
2594
|
"tenants",
|
|
2624
2595
|
"tenant-metadata",
|
|
2625
|
-
"tenant-logos",
|
|
2626
2596
|
"products",
|
|
2627
2597
|
"product-variants",
|
|
2628
2598
|
"product-options",
|
|
@@ -2631,19 +2601,7 @@ var COLLECTIONS = [
|
|
|
2631
2601
|
"product-tags",
|
|
2632
2602
|
"product-collections",
|
|
2633
2603
|
"brands",
|
|
2634
|
-
"brand-logos",
|
|
2635
|
-
"orders",
|
|
2636
|
-
"order-items",
|
|
2637
|
-
"returns",
|
|
2638
|
-
"return-items",
|
|
2639
|
-
"fulfillments",
|
|
2640
|
-
"fulfillment-items",
|
|
2641
|
-
"transactions",
|
|
2642
|
-
"customers",
|
|
2643
2604
|
"customer-profiles",
|
|
2644
|
-
"customer-addresses",
|
|
2645
|
-
"carts",
|
|
2646
|
-
"cart-items",
|
|
2647
2605
|
"discounts",
|
|
2648
2606
|
"shipping-policies",
|
|
2649
2607
|
"shipping-zones",
|
|
@@ -2674,19 +2632,11 @@ var COLLECTIONS = [
|
|
|
2674
2632
|
"canvas-tags",
|
|
2675
2633
|
"canvas-nodes",
|
|
2676
2634
|
"canvas-edges",
|
|
2677
|
-
"videos",
|
|
2678
2635
|
"video-categories",
|
|
2679
2636
|
"video-tags",
|
|
2680
|
-
"live-streams",
|
|
2681
|
-
"images",
|
|
2682
2637
|
"forms",
|
|
2683
|
-
"form-submissions",
|
|
2684
2638
|
// Community
|
|
2685
|
-
"posts",
|
|
2686
|
-
"comments",
|
|
2687
|
-
"reactions",
|
|
2688
2639
|
"reaction-types",
|
|
2689
|
-
"bookmarks",
|
|
2690
2640
|
"post-categories",
|
|
2691
2641
|
"post-tags",
|
|
2692
2642
|
"customer-profile-lists",
|
|
@@ -2698,9 +2648,33 @@ var COLLECTIONS = [
|
|
|
2698
2648
|
"event-tags"
|
|
2699
2649
|
];
|
|
2700
2650
|
var SERVER_ONLY_COLLECTIONS = [
|
|
2651
|
+
"tenant-logos",
|
|
2652
|
+
"brand-logos",
|
|
2653
|
+
"images",
|
|
2654
|
+
"videos",
|
|
2655
|
+
"orders",
|
|
2656
|
+
"order-items",
|
|
2657
|
+
"returns",
|
|
2658
|
+
"return-items",
|
|
2659
|
+
"fulfillment-orders",
|
|
2660
|
+
"fulfillment-order-items",
|
|
2661
|
+
"fulfillments",
|
|
2662
|
+
"fulfillment-items",
|
|
2663
|
+
"transactions",
|
|
2664
|
+
"customers",
|
|
2665
|
+
"customer-addresses",
|
|
2666
|
+
"form-submissions",
|
|
2667
|
+
"carts",
|
|
2668
|
+
"cart-items",
|
|
2669
|
+
"posts",
|
|
2670
|
+
"comments",
|
|
2671
|
+
"reactions",
|
|
2672
|
+
"bookmarks",
|
|
2673
|
+
"live-streams",
|
|
2701
2674
|
"customer-groups",
|
|
2702
2675
|
"reports",
|
|
2703
|
-
"community-bans"
|
|
2676
|
+
"community-bans",
|
|
2677
|
+
"order-export-profiles"
|
|
2704
2678
|
];
|
|
2705
2679
|
var SERVER_COLLECTIONS = [
|
|
2706
2680
|
...COLLECTIONS,
|
|
@@ -4554,6 +4528,12 @@ function maxOfNullable(values) {
|
|
|
4554
4528
|
const numbers = values.filter((v) => v !== null);
|
|
4555
4529
|
return numbers.length === 0 ? null : Math.max(...numbers);
|
|
4556
4530
|
}
|
|
4531
|
+
var PRODUCT_PLP_FIND_OPTIONS = {
|
|
4532
|
+
joins: {
|
|
4533
|
+
variants: { limit: 200, sort: "_order" },
|
|
4534
|
+
options: { limit: 50, sort: "_order" }
|
|
4535
|
+
}
|
|
4536
|
+
};
|
|
4557
4537
|
function buildProductListingGroupsByOption(args) {
|
|
4558
4538
|
const primaryOptionId = args.primaryOptionId ?? void 0;
|
|
4559
4539
|
if (!primaryOptionId) return [];
|
|
@@ -4747,8 +4727,6 @@ function resolveLegacyMediaSet(input) {
|
|
|
4747
4727
|
};
|
|
4748
4728
|
}
|
|
4749
4729
|
function resolveProductGallery(input) {
|
|
4750
|
-
const legacyResolved = resolveLegacyMediaSet(input);
|
|
4751
|
-
if (legacyResolved && legacyResolved.source !== "none") return legacyResolved;
|
|
4752
4730
|
const selectedVariantId = mediaId(input.selectedVariantId);
|
|
4753
4731
|
const selectedOptionValueIds = relationshipIds(input.selectedOptionValueIds);
|
|
4754
4732
|
const selection = resolveProductSelectionMedia({
|
|
@@ -4760,6 +4738,8 @@ function resolveProductGallery(input) {
|
|
|
4760
4738
|
if (selection.source !== "none") {
|
|
4761
4739
|
return selection;
|
|
4762
4740
|
}
|
|
4741
|
+
const legacyResolved = resolveLegacyMediaSet(input);
|
|
4742
|
+
if (legacyResolved && legacyResolved.source !== "none") return legacyResolved;
|
|
4763
4743
|
return resolveProductDisplayMedia({
|
|
4764
4744
|
productMediaPool: input.productMediaPool ?? input.pool ?? null,
|
|
4765
4745
|
productPrimaryMediaItemId: input.productPrimaryMediaItemId,
|
|
@@ -4768,14 +4748,22 @@ function resolveProductGallery(input) {
|
|
|
4768
4748
|
}
|
|
4769
4749
|
|
|
4770
4750
|
// src/utils/image.ts
|
|
4771
|
-
var IMAGE_SIZES = [
|
|
4751
|
+
var IMAGE_SIZES = [200, 400, 800, 1200, 1600];
|
|
4752
|
+
function imageSizeCandidates(sizes) {
|
|
4753
|
+
const keys = new Set(IMAGE_SIZES);
|
|
4754
|
+
for (const key of Object.keys(sizes)) {
|
|
4755
|
+
const value = Number(key);
|
|
4756
|
+
if (Number.isFinite(value) && value > 0) keys.add(value);
|
|
4757
|
+
}
|
|
4758
|
+
return [...keys].sort((a, b) => a - b);
|
|
4759
|
+
}
|
|
4772
4760
|
function getImageUrl(image, displayWidth, dpr = 1) {
|
|
4773
4761
|
const target = displayWidth * dpr;
|
|
4774
4762
|
const sizes = image.sizes;
|
|
4775
4763
|
if (sizes) {
|
|
4776
|
-
for (const size of
|
|
4764
|
+
for (const size of imageSizeCandidates(sizes)) {
|
|
4777
4765
|
if (size >= target) {
|
|
4778
|
-
const entry = sizes[
|
|
4766
|
+
const entry = sizes[`${size}`];
|
|
4779
4767
|
if (entry?.url) return entry.url;
|
|
4780
4768
|
}
|
|
4781
4769
|
}
|
|
@@ -4784,16 +4772,18 @@ function getImageUrl(image, displayWidth, dpr = 1) {
|
|
|
4784
4772
|
}
|
|
4785
4773
|
function getImageSrcSet(image) {
|
|
4786
4774
|
const parts = [];
|
|
4775
|
+
const emittedWidths = /* @__PURE__ */ new Set();
|
|
4787
4776
|
const sizes = image.sizes;
|
|
4788
4777
|
if (sizes) {
|
|
4789
|
-
for (const size of
|
|
4790
|
-
const entry = sizes[
|
|
4791
|
-
if (entry?.url && entry.width) {
|
|
4778
|
+
for (const size of imageSizeCandidates(sizes)) {
|
|
4779
|
+
const entry = sizes[`${size}`];
|
|
4780
|
+
if (entry?.url && entry.width && !emittedWidths.has(entry.width)) {
|
|
4781
|
+
emittedWidths.add(entry.width);
|
|
4792
4782
|
parts.push(`${entry.url} ${entry.width}w`);
|
|
4793
4783
|
}
|
|
4794
4784
|
}
|
|
4795
4785
|
}
|
|
4796
|
-
if (image.url && image.width) {
|
|
4786
|
+
if (image.url && image.width && !emittedWidths.has(image.width)) {
|
|
4797
4787
|
parts.push(`${image.url} ${image.width}w`);
|
|
4798
4788
|
}
|
|
4799
4789
|
return parts.join(", ");
|
|
@@ -4895,6 +4885,27 @@ function createAnalytics(config) {
|
|
|
4895
4885
|
const nav = navigator;
|
|
4896
4886
|
return nav.doNotTrack === "1" || nav.globalPrivacyControl === true;
|
|
4897
4887
|
}
|
|
4888
|
+
const isLocalHost = (() => {
|
|
4889
|
+
try {
|
|
4890
|
+
const h = location.hostname;
|
|
4891
|
+
return h === "localhost" || h === "127.0.0.1" || h.endsWith(".local");
|
|
4892
|
+
} catch {
|
|
4893
|
+
return false;
|
|
4894
|
+
}
|
|
4895
|
+
})();
|
|
4896
|
+
const mode = config.mode ?? "auto";
|
|
4897
|
+
const sendSuppressed = mode === "development" || mode === "auto" && isLocalHost;
|
|
4898
|
+
let suppressNoticeShown = false;
|
|
4899
|
+
function devSuppressNotice() {
|
|
4900
|
+
if (suppressNoticeShown) return;
|
|
4901
|
+
suppressNoticeShown = true;
|
|
4902
|
+
try {
|
|
4903
|
+
console.info(
|
|
4904
|
+
`[01 analytics] events disabled on local host (mode: '${mode}'). Pass mode: 'production' to send while developing.`
|
|
4905
|
+
);
|
|
4906
|
+
} catch {
|
|
4907
|
+
}
|
|
4908
|
+
}
|
|
4898
4909
|
let lastPath = null;
|
|
4899
4910
|
let lastAt = 0;
|
|
4900
4911
|
const autoTrack = config.autoTrack !== false;
|
|
@@ -4925,6 +4936,10 @@ function createAnalytics(config) {
|
|
|
4925
4936
|
if (isDntActive()) return;
|
|
4926
4937
|
const doc = document;
|
|
4927
4938
|
if (doc.prerendering === true || document.visibilityState === "prerender") return;
|
|
4939
|
+
if (sendSuppressed) {
|
|
4940
|
+
devSuppressNotice();
|
|
4941
|
+
return;
|
|
4942
|
+
}
|
|
4928
4943
|
const now = Date.now();
|
|
4929
4944
|
if (pathname === lastPath && now - lastAt < 500) return;
|
|
4930
4945
|
lastPath = pathname;
|
|
@@ -4960,14 +4975,7 @@ function createAnalytics(config) {
|
|
|
4960
4975
|
window.addEventListener("load", trackCurrentPath, { once: true });
|
|
4961
4976
|
}
|
|
4962
4977
|
}
|
|
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
|
-
})();
|
|
4978
|
+
const isProduction = !isLocalHost;
|
|
4971
4979
|
const warnedReasons = /* @__PURE__ */ new Set();
|
|
4972
4980
|
function devWarn(name, reason) {
|
|
4973
4981
|
if (isProduction) return;
|
|
@@ -5027,6 +5035,10 @@ function createAnalytics(config) {
|
|
|
5027
5035
|
return;
|
|
5028
5036
|
}
|
|
5029
5037
|
}
|
|
5038
|
+
if (sendSuppressed) {
|
|
5039
|
+
devSuppressNotice();
|
|
5040
|
+
return;
|
|
5041
|
+
}
|
|
5030
5042
|
const body = JSON.stringify({
|
|
5031
5043
|
publishableKey: config.publishableKey,
|
|
5032
5044
|
pathname: location.pathname,
|