@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.
Files changed (82) hide show
  1. package/README.md +142 -55
  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 +150 -207
  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 +150 -207
  19. package/dist/client.js.map +1 -1
  20. package/dist/{collection-client-Cv0D2w1Q.d.cts → collection-client-B0J9wMNE.d.cts} +5 -5
  21. package/dist/{collection-client-Bq5Zd7p7.d.ts → collection-client-BroIWHY1.d.ts} +5 -5
  22. package/dist/const-6XHz_jej.d.ts +32 -0
  23. package/dist/const-B5KT72c7.d.cts +32 -0
  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-DTSXUYkr.d.ts → index-BOLQxveo.d.cts} +9 -6
  27. package/dist/{index-BHDKJ6B3.d.cts → index-CSwR2HSg.d.ts} +9 -6
  28. package/dist/index.cjs +256 -244
  29. package/dist/index.cjs.map +1 -1
  30. package/dist/index.d.cts +12 -11
  31. package/dist/index.d.ts +12 -11
  32. package/dist/index.js +256 -244
  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-BCui2Oml.d.cts → payload-types-m3jjhxk9.d.cts} +669 -184
  39. package/dist/{payload-types-BCui2Oml.d.ts → payload-types-m3jjhxk9.d.ts} +669 -184
  40. package/dist/query.cjs +3 -1033
  41. package/dist/query.cjs.map +1 -1
  42. package/dist/query.d.cts +13 -13
  43. package/dist/query.d.ts +13 -13
  44. package/dist/query.js +3 -1033
  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 +121 -85
  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 +121 -85
  53. package/dist/server.js.map +1 -1
  54. package/dist/{types-Dib-zdK6.d.cts → types-CIGscmus.d.cts} +1471 -1100
  55. package/dist/{types-3qV6sY7T.d.ts → types-Cmrd1ezc.d.ts} +1 -15
  56. package/dist/{types-CEzLf3PX.d.cts → types-D0ubzQw0.d.cts} +1 -15
  57. package/dist/{types-DK9EnLwJ.d.ts → types-D2xYdz4P.d.ts} +1471 -1100
  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
  81. package/dist/const-BDUKFP9w.d.ts +0 -32
  82. package/dist/const-DVcM7Ac_.d.cts +0 -32
package/dist/server.d.cts CHANGED
@@ -1,11 +1,11 @@
1
- import { S as ServerCollectionClient } from './collection-client-Cv0D2w1Q.cjs';
2
- export { C as CollectionClient } from './collection-client-Cv0D2w1Q.cjs';
3
- import { B as BaseApi, l as ServerApiOptions, m as ServerCommerceClient, T as TenantIntrospectionClient, a as CommunityClient, n as BanCustomerParams, o as CommunityBan, U as UnbanCustomerParams, c as ClientState, p as ClientServerConfig, E as EventsClient, q as RootServerClientWithEvents } from './types-Dib-zdK6.cjs';
4
- export { r as CollectionFieldSchema, s as CollectionSchemaResponse, t as EventGuestCancelParams, u as EventGuestRegistration, v as EventGuestRegistrationResponse, w as EventRegistrationAnswerInput, x as EventRegistrationAttendeeInput, y as EventRegistrationPublic, z as EventRegistrationRegisterParams, F as EventRegistrationRegisterResponse, G as EventsCalendarItem, H as EventsClientOptions, I as EventsDateParam, J as EventsExternalSource, K as EventsLocation, L as EventsOccurrenceLocation, M as EventsRangeEvent, N as EventsRangeOccurrence, O as EventsRangeParams, Q as EventsRangeResponse, V as EventsTaxonomyItem, X as ModerationApi, Y as RootServerClient, Z as TenantFeatureProgressEvidenceValue, _ as TenantFeatureProgressFeature, $ as TenantFeatureProgressGroup, a0 as TenantFeatureProgressInput, a1 as TenantFeatureProgressItem, a2 as TenantFeatureProgressItemState, a3 as TenantFeatureProgressResponse, a4 as TenantFeatureProgressSeverity, a5 as TenantFeatureProgressStatus, a6 as TenantIntrospectionApi, a7 as TenantIntrospectionApiOptions } from './types-Dib-zdK6.cjs';
5
- import './payload-types-BCui2Oml.cjs';
1
+ import { S as ServerCollectionClient } from './collection-client-B0J9wMNE.cjs';
2
+ export { C as CollectionClient } from './collection-client-B0J9wMNE.cjs';
3
+ import { B as BaseApi, z as ServerApiOptions, F as ServerCommerceClient, T as TenantIntrospectionClient, a as CommunityClient, G as BanCustomerParams, H as CommunityBan, I as UnbanCustomerParams, c as ClientState, J as ClientServerConfig, E as EventsClient, K as RootServerClientWithEvents } from './types-CIGscmus.cjs';
4
+ export { A as AddItemParams, f as ApplyDiscountParams, g as CheckoutParams, h as ClearCartParams, L as CollectionFieldSchema, M as CollectionSchemaResponse, N as EventGuestCancelParams, O as EventGuestRegistration, Q as EventGuestRegistrationResponse, V as EventRegistrationAnswerInput, X as EventRegistrationAttendeeInput, Y as EventRegistrationPublic, Z as EventRegistrationRegisterParams, _ as EventRegistrationRegisterResponse, $ as EventsCalendarItem, a0 as EventsClientOptions, a1 as EventsDateParam, a2 as EventsExternalSource, a3 as EventsLocation, a4 as EventsOccurrenceLocation, a5 as EventsRangeEvent, a6 as EventsRangeOccurrence, a7 as EventsRangeParams, a8 as EventsRangeResponse, a9 as EventsTaxonomyItem, aa as ModerationApi, m as PublicCart, n as PublicCartItem, o as PublicCartReference, p as PublicMediaAsset, q as PublicMediaSize, r as PublicOrder, s as PublicOrderItem, t as PublicOrderReference, R as RemoveDiscountParams, u as RemoveItemParams, ab as RootServerClient, ac as TenantFeatureProgressEvidenceValue, ad as TenantFeatureProgressFeature, ae as TenantFeatureProgressGroup, af as TenantFeatureProgressInput, ag as TenantFeatureProgressItem, ah as TenantFeatureProgressItemState, ai as TenantFeatureProgressResponse, aj as TenantFeatureProgressSeverity, ak as TenantFeatureProgressStatus, al as TenantIntrospectionApi, am as TenantIntrospectionApiOptions, U as UpdateItemParams } from './types-CIGscmus.cjs';
5
+ import './payload-types-m3jjhxk9.cjs';
6
6
  import './metadata.cjs';
7
- import './const-DVcM7Ac_.cjs';
8
- import './types-CEzLf3PX.cjs';
7
+ import './const-B5KT72c7.cjs';
8
+ import './types-D0ubzQw0.cjs';
9
9
 
10
10
  type PreviewDetailParams = {
11
11
  collection: string;
package/dist/server.d.ts CHANGED
@@ -1,11 +1,11 @@
1
- import { S as ServerCollectionClient } from './collection-client-Bq5Zd7p7.js';
2
- export { C as CollectionClient } from './collection-client-Bq5Zd7p7.js';
3
- import { B as BaseApi, l as ServerApiOptions, m as ServerCommerceClient, T as TenantIntrospectionClient, a as CommunityClient, n as BanCustomerParams, o as CommunityBan, U as UnbanCustomerParams, c as ClientState, p as ClientServerConfig, E as EventsClient, q as RootServerClientWithEvents } from './types-DK9EnLwJ.js';
4
- export { r as CollectionFieldSchema, s as CollectionSchemaResponse, t as EventGuestCancelParams, u as EventGuestRegistration, v as EventGuestRegistrationResponse, w as EventRegistrationAnswerInput, x as EventRegistrationAttendeeInput, y as EventRegistrationPublic, z as EventRegistrationRegisterParams, F as EventRegistrationRegisterResponse, G as EventsCalendarItem, H as EventsClientOptions, I as EventsDateParam, J as EventsExternalSource, K as EventsLocation, L as EventsOccurrenceLocation, M as EventsRangeEvent, N as EventsRangeOccurrence, O as EventsRangeParams, Q as EventsRangeResponse, V as EventsTaxonomyItem, X as ModerationApi, Y as RootServerClient, Z as TenantFeatureProgressEvidenceValue, _ as TenantFeatureProgressFeature, $ as TenantFeatureProgressGroup, a0 as TenantFeatureProgressInput, a1 as TenantFeatureProgressItem, a2 as TenantFeatureProgressItemState, a3 as TenantFeatureProgressResponse, a4 as TenantFeatureProgressSeverity, a5 as TenantFeatureProgressStatus, a6 as TenantIntrospectionApi, a7 as TenantIntrospectionApiOptions } from './types-DK9EnLwJ.js';
5
- import './payload-types-BCui2Oml.js';
1
+ import { S as ServerCollectionClient } from './collection-client-BroIWHY1.js';
2
+ export { C as CollectionClient } from './collection-client-BroIWHY1.js';
3
+ import { B as BaseApi, z as ServerApiOptions, F as ServerCommerceClient, T as TenantIntrospectionClient, a as CommunityClient, G as BanCustomerParams, H as CommunityBan, I as UnbanCustomerParams, c as ClientState, J as ClientServerConfig, E as EventsClient, K as RootServerClientWithEvents } from './types-D2xYdz4P.js';
4
+ export { A as AddItemParams, f as ApplyDiscountParams, g as CheckoutParams, h as ClearCartParams, L as CollectionFieldSchema, M as CollectionSchemaResponse, N as EventGuestCancelParams, O as EventGuestRegistration, Q as EventGuestRegistrationResponse, V as EventRegistrationAnswerInput, X as EventRegistrationAttendeeInput, Y as EventRegistrationPublic, Z as EventRegistrationRegisterParams, _ as EventRegistrationRegisterResponse, $ as EventsCalendarItem, a0 as EventsClientOptions, a1 as EventsDateParam, a2 as EventsExternalSource, a3 as EventsLocation, a4 as EventsOccurrenceLocation, a5 as EventsRangeEvent, a6 as EventsRangeOccurrence, a7 as EventsRangeParams, a8 as EventsRangeResponse, a9 as EventsTaxonomyItem, aa as ModerationApi, m as PublicCart, n as PublicCartItem, o as PublicCartReference, p as PublicMediaAsset, q as PublicMediaSize, r as PublicOrder, s as PublicOrderItem, t as PublicOrderReference, R as RemoveDiscountParams, u as RemoveItemParams, ab as RootServerClient, ac as TenantFeatureProgressEvidenceValue, ad as TenantFeatureProgressFeature, ae as TenantFeatureProgressGroup, af as TenantFeatureProgressInput, ag as TenantFeatureProgressItem, ah as TenantFeatureProgressItemState, ai as TenantFeatureProgressResponse, aj as TenantFeatureProgressSeverity, ak as TenantFeatureProgressStatus, al as TenantIntrospectionApi, am as TenantIntrospectionApiOptions, U as UpdateItemParams } from './types-D2xYdz4P.js';
5
+ import './payload-types-m3jjhxk9.js';
6
6
  import './metadata.js';
7
- import './const-BDUKFP9w.js';
8
- import './types-3qV6sY7T.js';
7
+ import './const-6XHz_jej.js';
8
+ import './types-Cmrd1ezc.js';
9
9
 
10
10
  type PreviewDetailParams = {
11
11
  collection: string;
package/dist/server.js CHANGED
@@ -745,13 +745,15 @@ var HttpClient = class {
745
745
  };
746
746
 
747
747
  // src/utils/types.ts
748
- var resolveRelation = (ref) => {
748
+ function resolveRelation(ref) {
749
749
  if (typeof ref === "string" || typeof ref === "number" || ref === null || ref === void 0)
750
750
  return null;
751
751
  return ref;
752
- };
752
+ }
753
753
 
754
754
  // src/core/metadata/index.ts
755
+ var OPEN_GRAPH_IMAGE_SIZE = "1200";
756
+ var LEGACY_OPEN_GRAPH_IMAGE_SIZE = "1536";
755
757
  function extractSeo(doc) {
756
758
  const seo = doc.seo ?? {};
757
759
  const og = seo.openGraph ?? {};
@@ -795,7 +797,7 @@ function generateMetadata(input, options) {
795
797
  function resolveMetaImage(ref) {
796
798
  const image = resolveRelation(ref);
797
799
  if (!image) return null;
798
- const sized = image.sizes?.["1536"];
800
+ const sized = image.sizes?.[OPEN_GRAPH_IMAGE_SIZE] ?? image.sizes?.[LEGACY_OPEN_GRAPH_IMAGE_SIZE];
799
801
  const url = sized?.url || image.url;
800
802
  if (!url) return null;
801
803
  const width = sized?.url ? sized.width : image.width;
@@ -1153,13 +1155,16 @@ async function parseApiResponse(response, endpoint) {
1153
1155
  return data;
1154
1156
  }
1155
1157
 
1156
- // src/core/community/community-client.ts
1157
- var DEFAULT_POST_LIST_SORT = "-lastActivityAt";
1158
- var DEFAULT_COMMENT_LIST_SORT = "-createdAt";
1159
- var CommunityClient = class {
1160
- constructor(options) {
1158
+ // src/core/api/customer-scoped-api.ts
1159
+ var CustomerScopedApi = class {
1160
+ constructor(apiName, options) {
1161
+ if (options.requiresCredential !== false && !options.secretKey && !options.customerToken) {
1162
+ throw createConfigError(
1163
+ `Either secretKey or customerToken is required for ${apiName}.`
1164
+ );
1165
+ }
1161
1166
  this.publishableKey = requirePublishableKeyForSecret(
1162
- "CommunityClient",
1167
+ apiName,
1163
1168
  options.publishableKey,
1164
1169
  options.secretKey
1165
1170
  );
@@ -1169,6 +1174,44 @@ var CommunityClient = class {
1169
1174
  this.onUnauthorized = options.onUnauthorized;
1170
1175
  this.onRequestId = options.onRequestId;
1171
1176
  }
1177
+ async request(endpoint, options) {
1178
+ const token = typeof this.customerToken === "function" ? this.customerToken() : this.customerToken;
1179
+ try {
1180
+ const response = await httpFetch(endpoint, {
1181
+ method: options.method,
1182
+ apiUrl: this.apiUrl,
1183
+ publishableKey: this.publishableKey,
1184
+ secretKey: this.secretKey,
1185
+ customerToken: token ?? void 0,
1186
+ ...token && this.onUnauthorized && { onUnauthorized: this.onUnauthorized },
1187
+ ...options.body !== void 0 && {
1188
+ body: JSON.stringify(options.body)
1189
+ },
1190
+ ...options.headers && { headers: options.headers }
1191
+ });
1192
+ this.onRequestId?.(response.headers.get("x-request-id") ?? null);
1193
+ return parseApiResponse(response, endpoint);
1194
+ } catch (err) {
1195
+ const id = err instanceof SDKError ? err.requestId ?? null : null;
1196
+ this.onRequestId?.(id);
1197
+ throw err;
1198
+ }
1199
+ }
1200
+ };
1201
+
1202
+ // src/core/community/community-client.ts
1203
+ var DEFAULT_POST_LIST_SORT = "-lastActivityAt";
1204
+ var DEFAULT_COMMENT_LIST_SORT = "-createdAt";
1205
+ function unwrapPayloadDoc(value) {
1206
+ if (value && typeof value === "object" && "doc" in value) {
1207
+ return value.doc;
1208
+ }
1209
+ return value;
1210
+ }
1211
+ var CommunityClient = class extends CustomerScopedApi {
1212
+ constructor(options) {
1213
+ super("CommunityClient", { ...options, requiresCredential: false });
1214
+ }
1172
1215
  buildQuery(params) {
1173
1216
  if (!params) return "";
1174
1217
  const entries = Object.entries(params).filter((e) => e[1] !== void 0).map(([k, v]) => [k, String(v)]);
@@ -1178,7 +1221,8 @@ var CommunityClient = class {
1178
1221
  const urlParams = new URLSearchParams();
1179
1222
  const sort = params?.sort ?? DEFAULT_POST_LIST_SORT;
1180
1223
  urlParams.set("sort", sort);
1181
- if (params?.limit !== void 0) urlParams.set("limit", String(params.limit));
1224
+ if (params?.limit !== void 0)
1225
+ urlParams.set("limit", String(params.limit));
1182
1226
  if (params?.page !== void 0) urlParams.set("page", String(params.page));
1183
1227
  if (params?.categoryId !== void 0) {
1184
1228
  urlParams.set("where[categories][in]", params.categoryId);
@@ -1186,7 +1230,7 @@ var CommunityClient = class {
1186
1230
  if (params?.tagId !== void 0) {
1187
1231
  urlParams.set("where[tags][in]", params.tagId);
1188
1232
  }
1189
- return `/api/posts?${urlParams.toString()}`;
1233
+ return `/api/posts/public?${urlParams.toString()}`;
1190
1234
  }
1191
1235
  buildCommentsListQuery(params) {
1192
1236
  const urlParams = new URLSearchParams();
@@ -1206,30 +1250,21 @@ var CommunityClient = class {
1206
1250
  }
1207
1251
  if (params.limit !== void 0) urlParams.set("limit", String(params.limit));
1208
1252
  if (params.page !== void 0) urlParams.set("page", String(params.page));
1209
- return `/api/comments?${urlParams.toString()}`;
1253
+ return `/api/comments/public?${urlParams.toString()}`;
1210
1254
  }
1211
1255
  async execute(endpoint, method, body) {
1212
- const token = typeof this.customerToken === "function" ? this.customerToken() : this.customerToken;
1213
- try {
1214
- const response = await httpFetch(endpoint, {
1215
- method,
1216
- apiUrl: this.apiUrl,
1217
- publishableKey: this.publishableKey,
1218
- secretKey: this.secretKey,
1219
- customerToken: token ?? void 0,
1220
- ...token && this.onUnauthorized && { onUnauthorized: this.onUnauthorized },
1221
- ...body !== void 0 && { body: JSON.stringify(body) }
1222
- });
1223
- this.onRequestId?.(response.headers.get("x-request-id") ?? null);
1224
- return parseApiResponse(response, endpoint);
1225
- } catch (err) {
1226
- const id = err instanceof SDKError ? err.requestId ?? null : null;
1227
- this.onRequestId?.(id);
1228
- throw err;
1229
- }
1256
+ return this.request(endpoint, { method, body });
1257
+ }
1258
+ async executeDoc(endpoint, method, body) {
1259
+ const response = await this.execute(endpoint, method, body);
1260
+ return unwrapPayloadDoc(response);
1230
1261
  }
1231
1262
  createPost(params) {
1232
- return this.execute("/api/posts", "POST", params);
1263
+ return this.executeDoc(
1264
+ "/api/posts",
1265
+ "POST",
1266
+ params
1267
+ );
1233
1268
  }
1234
1269
  /**
1235
1270
  * Public post feed. Server applies the same visibility contract as
@@ -1286,7 +1321,11 @@ var CommunityClient = class {
1286
1321
  if (parentId !== void 0) {
1287
1322
  body.parent = parentId;
1288
1323
  }
1289
- return this.execute("/api/comments", "POST", body);
1324
+ return this.executeDoc(
1325
+ "/api/comments",
1326
+ "POST",
1327
+ body
1328
+ );
1290
1329
  }
1291
1330
  /**
1292
1331
  * List comments for a post.
@@ -1324,7 +1363,7 @@ var CommunityClient = class {
1324
1363
  }
1325
1364
  updateComment(params) {
1326
1365
  const { commentId, body } = params;
1327
- return this.execute(
1366
+ return this.executeDoc(
1328
1367
  `/api/comments/${commentId}`,
1329
1368
  "PATCH",
1330
1369
  { body }
@@ -1355,10 +1394,14 @@ var CommunityClient = class {
1355
1394
  400
1356
1395
  );
1357
1396
  }
1358
- return this.execute("/api/reactions", "POST", {
1359
- post: postId,
1360
- type: reactionType
1361
- });
1397
+ return this.executeDoc(
1398
+ "/api/reactions",
1399
+ "POST",
1400
+ {
1401
+ post: postId,
1402
+ type: reactionType
1403
+ }
1404
+ );
1362
1405
  }
1363
1406
  removeReaction(params) {
1364
1407
  const { postId, type } = params;
@@ -1377,10 +1420,14 @@ var CommunityClient = class {
1377
1420
  400
1378
1421
  );
1379
1422
  }
1380
- return this.execute("/api/reactions", "POST", {
1381
- comment: commentId,
1382
- type: reactionType
1383
- });
1423
+ return this.executeDoc(
1424
+ "/api/reactions",
1425
+ "POST",
1426
+ {
1427
+ comment: commentId,
1428
+ type: reactionType
1429
+ }
1430
+ );
1384
1431
  }
1385
1432
  removeCommentReaction(params) {
1386
1433
  const { commentId, type } = params;
@@ -1409,9 +1456,13 @@ var CommunityClient = class {
1409
1456
  }
1410
1457
  // Bookmarks
1411
1458
  addBookmark(params) {
1412
- return this.execute("/api/bookmarks", "POST", {
1413
- post: params.postId
1414
- });
1459
+ return this.executeDoc(
1460
+ "/api/bookmarks",
1461
+ "POST",
1462
+ {
1463
+ post: params.postId
1464
+ }
1465
+ );
1415
1466
  }
1416
1467
  removeBookmark(params) {
1417
1468
  return this.execute(
@@ -1427,10 +1478,7 @@ var CommunityClient = class {
1427
1478
  }
1428
1479
  // Profiles
1429
1480
  listProfileLists(params) {
1430
- return this.execute(
1431
- `/api/customer-profile-lists${this.buildQuery(params)}`,
1432
- "GET"
1433
- );
1481
+ return this.execute(`/api/customer-profile-lists${this.buildQuery(params)}`, "GET");
1434
1482
  }
1435
1483
  async getProfileList(params) {
1436
1484
  const query = "slug" in params ? `?where[slug][equals]=${encodeURIComponent(params.slug)}&limit=1` : `?where[id][equals]=${encodeURIComponent(params.id)}&limit=1`;
@@ -1504,46 +1552,18 @@ var ModerationApi = class extends BaseApi {
1504
1552
  };
1505
1553
 
1506
1554
  // src/core/api/cart-api.ts
1507
- var CartApi = class {
1555
+ var CartApi = class extends CustomerScopedApi {
1508
1556
  constructor(options) {
1509
- if (!options.secretKey && !options.customerToken) {
1510
- throw createConfigError(
1511
- "Either secretKey or customerToken is required for CartApi."
1512
- );
1513
- }
1514
- this.publishableKey = requirePublishableKeyForSecret(
1515
- "CartApi",
1516
- options.publishableKey,
1517
- options.secretKey
1518
- );
1519
- this.secretKey = options.secretKey;
1520
- this.apiUrl = options.apiUrl;
1521
- this.customerToken = options.customerToken;
1522
- this.onUnauthorized = options.onUnauthorized;
1523
- this.onRequestId = options.onRequestId;
1557
+ super("CartApi", options);
1524
1558
  }
1525
1559
  async execute(endpoint, method, body) {
1526
- const token = typeof this.customerToken === "function" ? this.customerToken() : this.customerToken;
1527
- try {
1528
- const response = await httpFetch(endpoint, {
1529
- method,
1530
- apiUrl: this.apiUrl,
1531
- publishableKey: this.publishableKey,
1532
- secretKey: this.secretKey,
1533
- customerToken: token ?? void 0,
1534
- ...token && this.onUnauthorized && { onUnauthorized: this.onUnauthorized },
1535
- ...body !== void 0 && { body: JSON.stringify(body) }
1536
- });
1537
- this.onRequestId?.(response.headers.get("x-request-id") ?? null);
1538
- return parseApiResponse(response, endpoint);
1539
- } catch (err) {
1540
- const id = err instanceof SDKError ? err.requestId ?? null : null;
1541
- this.onRequestId?.(id);
1542
- throw err;
1543
- }
1560
+ return this.request(endpoint, { method, body });
1544
1561
  }
1545
1562
  getCart(cartId) {
1546
- return this.execute(`/api/carts/${cartId}`, "GET");
1563
+ return this.execute(
1564
+ `/api/carts/${cartId}?depth=0&joins=false`,
1565
+ "GET"
1566
+ );
1547
1567
  }
1548
1568
  addItem(params) {
1549
1569
  return this.execute("/api/carts/add-item", "POST", params);
@@ -1740,15 +1760,24 @@ function splitIdempotencyKey(params) {
1740
1760
  const { idempotencyKey, ...body } = params;
1741
1761
  return { body, idempotencyKey };
1742
1762
  }
1763
+ function normalizeCreateOrderBody(params) {
1764
+ if (params.items !== void 0) {
1765
+ const { idempotencyKey: _idempotencyKey2, items, ...rest } = params;
1766
+ return { ...rest, orderItems: items };
1767
+ }
1768
+ const { idempotencyKey: _idempotencyKey, ...body } = params;
1769
+ return body;
1770
+ }
1743
1771
  var OrderApi = class extends BaseApi {
1744
1772
  constructor(options) {
1745
1773
  super("OrderApi", options);
1746
1774
  }
1747
1775
  createOrder(params) {
1748
- const { body, idempotencyKey } = splitIdempotencyKey(params);
1776
+ const { idempotencyKey } = params;
1777
+ const normalizedBody = normalizeCreateOrderBody(params);
1749
1778
  return this.request(
1750
1779
  "/api/orders/create",
1751
- body,
1780
+ normalizedBody,
1752
1781
  idempotencyRequestOptions(idempotencyKey)
1753
1782
  );
1754
1783
  }
@@ -1810,6 +1839,12 @@ var OrderApi = class extends BaseApi {
1810
1839
  idempotencyRequestOptions(idempotencyKey)
1811
1840
  );
1812
1841
  }
1842
+ prepareFulfillmentOrder(params) {
1843
+ return this.request(
1844
+ "/api/fulfillment-orders/prepare-fulfillment-order",
1845
+ params
1846
+ );
1847
+ }
1813
1848
  updateFulfillment(params) {
1814
1849
  return this.request("/api/orders/update-fulfillment", params);
1815
1850
  }
@@ -1938,6 +1973,7 @@ var ServerCommerceClient = class {
1938
1973
  cancelOrder: orderApi.cancelOrder.bind(orderApi),
1939
1974
  resolveCancelRefund: orderApi.resolveCancelRefund.bind(orderApi),
1940
1975
  createFulfillment: orderApi.createFulfillment.bind(orderApi),
1976
+ prepareFulfillmentOrder: orderApi.prepareFulfillmentOrder.bind(orderApi),
1941
1977
  updateFulfillment: orderApi.updateFulfillment.bind(orderApi),
1942
1978
  bulkImportFulfillments: orderApi.bulkImportFulfillments.bind(orderApi),
1943
1979
  createReturn: orderApi.createReturn.bind(orderApi),