@01.software/sdk 0.42.0 → 0.43.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 (51) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/README.md +10 -4
  3. package/dist/client.cjs +99 -57
  4. package/dist/client.cjs.map +1 -1
  5. package/dist/client.d.cts +9 -6
  6. package/dist/client.d.ts +9 -6
  7. package/dist/client.js +99 -57
  8. package/dist/client.js.map +1 -1
  9. package/dist/{collection-client-B-qVIBnJ.d.cts → collection-client-U70KizLf.d.cts} +3 -3
  10. package/dist/{collection-client-BhCMwIus.d.ts → collection-client-gWsA7BVP.d.ts} +3 -3
  11. package/dist/{const-pmHlwm3E.d.ts → const-BBynifk0.d.cts} +5 -5
  12. package/dist/{const-BiDujixF.d.cts → const-_WWHU-gX.d.ts} +5 -5
  13. package/dist/{index-B1UBDaKz.d.ts → index-DPi5NWU8.d.ts} +4 -4
  14. package/dist/{index-D78ki6Ij.d.cts → index-Dg4Y6Aq7.d.cts} +4 -4
  15. package/dist/index.cjs +111 -61
  16. package/dist/index.cjs.map +1 -1
  17. package/dist/index.d.cts +41 -8
  18. package/dist/index.d.ts +41 -8
  19. package/dist/index.js +111 -61
  20. package/dist/index.js.map +1 -1
  21. package/dist/{payload-types-C7Ul4ElL.d.cts → payload-types-DLxkB7Mv.d.cts} +399 -27
  22. package/dist/{payload-types-C7Ul4ElL.d.ts → payload-types-DLxkB7Mv.d.ts} +399 -27
  23. package/dist/query.cjs +59 -7
  24. package/dist/query.cjs.map +1 -1
  25. package/dist/query.d.cts +5 -5
  26. package/dist/query.d.ts +5 -5
  27. package/dist/query.js +59 -7
  28. package/dist/query.js.map +1 -1
  29. package/dist/realtime.d.cts +2 -2
  30. package/dist/realtime.d.ts +2 -2
  31. package/dist/server.cjs +130 -57
  32. package/dist/server.cjs.map +1 -1
  33. package/dist/server.d.cts +12 -7
  34. package/dist/server.d.ts +12 -7
  35. package/dist/server.js +130 -57
  36. package/dist/server.js.map +1 -1
  37. package/dist/{types-ChV1t4ei.d.cts → types-B1ngKbWI.d.cts} +1 -1
  38. package/dist/{types-BL7M-EUV.d.cts → types-B9lGhZlB.d.ts} +95 -6
  39. package/dist/{types-Bf2iCjy8.d.ts → types-BiKNBwRA.d.ts} +1 -1
  40. package/dist/{types-D5dSNIGs.d.ts → types-Bpx5sYKo.d.cts} +95 -6
  41. package/dist/ui/form.d.cts +1 -1
  42. package/dist/ui/form.d.ts +1 -1
  43. package/dist/ui/video.d.cts +1 -1
  44. package/dist/ui/video.d.ts +1 -1
  45. package/dist/webhook.cjs +3 -1
  46. package/dist/webhook.cjs.map +1 -1
  47. package/dist/webhook.d.cts +4 -4
  48. package/dist/webhook.d.ts +4 -4
  49. package/dist/webhook.js +3 -1
  50. package/dist/webhook.js.map +1 -1
  51. package/package.json +1 -1
package/dist/client.d.cts CHANGED
@@ -1,10 +1,10 @@
1
- import { R as ReadOnlyCollectionClient } from './collection-client-B-qVIBnJ.cjs';
2
- import { C as CommerceClient, a as CommunityClient, b as ContentClient, E as EventsClient, c as CustomerNamespace, d as ClientState, e as ClientConfig } from './types-BL7M-EUV.cjs';
3
- export { A as AddItemParams, f as ApiQueryOptions, g as ApplyDiscountParams, h as CheckoutParams, i as ClearCartParams, j as ClientMetadata, k as ContentClientOptions, D as DebugConfig, l as DeepPartial, m as ExtractArrayType, P as PayloadFindResponse, n as PayloadMutationResponse, o as PublicCart, p as PublicCartItem, q as PublicCartReference, r as PublicMediaAsset, s as PublicMediaSize, t as PublicOrder, u as PublicOrderItem, v as PublicOrderReference, R as RemoveDiscountParams, w as RemoveItemParams, x as RetryConfig, y as RootClient, y as RootClientType, z as RootCollectionClient, B as RootReadOnlyQueryBuilder, S as Sort, F as StorefrontContentListOptions, G as StorefrontContentReference, H as StorefrontGalleryItem, I as StorefrontGalleryItemsListOptions, J as StorefrontGalleryItemsSort, K as StorefrontLink, L as StorefrontLinksListOptions, M as StorefrontLinksSort, U as UpdateItemParams, W as Where } from './types-BL7M-EUV.cjs';
4
- import './payload-types-C7Ul4ElL.cjs';
5
- export { C as Collection, P as PublicCollection } from './const-BiDujixF.cjs';
1
+ import { R as ReadOnlyCollectionClient } from './collection-client-U70KizLf.cjs';
2
+ import { C as CommerceClient, a as CommunityClient, b as ContentClient, E as EventsClient, c as CustomerNamespace, d as CustomerMembershipView, e as ClientState, f as ClientConfig } from './types-Bpx5sYKo.cjs';
3
+ export { A as AddItemParams, g as ApiQueryOptions, h as ApplyDiscountParams, i as CheckoutParams, j as ClearCartParams, k as ClientMetadata, l as ContentClientOptions, D as DebugConfig, m as DeepPartial, n as ExtractArrayType, P as PayloadFindResponse, o as PayloadMutationResponse, p as PublicCart, q as PublicCartItem, r as PublicCartReference, s as PublicMediaAsset, t as PublicMediaSize, u as PublicOrder, v as PublicOrderItem, w as PublicOrderReference, R as RemoveDiscountParams, x as RemoveItemParams, y as RetryConfig, z as RootClient, z as RootClientType, B as RootCollectionClient, F as RootReadOnlyQueryBuilder, S as Sort, G as StorefrontContentListOptions, H as StorefrontContentReference, I as StorefrontGalleryItem, J as StorefrontGalleryItemsListOptions, K as StorefrontGalleryItemsSort, L as StorefrontLink, M as StorefrontLinksListOptions, N as StorefrontLinksSort, U as UpdateItemParams, W as Where } from './types-Bpx5sYKo.cjs';
4
+ import './payload-types-DLxkB7Mv.cjs';
5
+ export { C as Collection, P as PublicCollection } from './const-BBynifk0.cjs';
6
6
  import './metadata.cjs';
7
- import './types-ChV1t4ei.cjs';
7
+ import './types-B1ngKbWI.cjs';
8
8
 
9
9
  declare class Client {
10
10
  commerce: CommerceClient;
@@ -13,6 +13,9 @@ declare class Client {
13
13
  events: EventsClient;
14
14
  customer: CustomerNamespace;
15
15
  collections: ReadOnlyCollectionClient;
16
+ memberships: {
17
+ me: () => Promise<CustomerMembershipView | null>;
18
+ };
16
19
  lastRequestId: string | null;
17
20
  protected state: ClientState;
18
21
  protected config: ClientConfig;
package/dist/client.d.ts CHANGED
@@ -1,10 +1,10 @@
1
- import { R as ReadOnlyCollectionClient } from './collection-client-BhCMwIus.js';
2
- import { C as CommerceClient, a as CommunityClient, b as ContentClient, E as EventsClient, c as CustomerNamespace, d as ClientState, e as ClientConfig } from './types-D5dSNIGs.js';
3
- export { A as AddItemParams, f as ApiQueryOptions, g as ApplyDiscountParams, h as CheckoutParams, i as ClearCartParams, j as ClientMetadata, k as ContentClientOptions, D as DebugConfig, l as DeepPartial, m as ExtractArrayType, P as PayloadFindResponse, n as PayloadMutationResponse, o as PublicCart, p as PublicCartItem, q as PublicCartReference, r as PublicMediaAsset, s as PublicMediaSize, t as PublicOrder, u as PublicOrderItem, v as PublicOrderReference, R as RemoveDiscountParams, w as RemoveItemParams, x as RetryConfig, y as RootClient, y as RootClientType, z as RootCollectionClient, B as RootReadOnlyQueryBuilder, S as Sort, F as StorefrontContentListOptions, G as StorefrontContentReference, H as StorefrontGalleryItem, I as StorefrontGalleryItemsListOptions, J as StorefrontGalleryItemsSort, K as StorefrontLink, L as StorefrontLinksListOptions, M as StorefrontLinksSort, U as UpdateItemParams, W as Where } from './types-D5dSNIGs.js';
4
- import './payload-types-C7Ul4ElL.js';
5
- export { C as Collection, P as PublicCollection } from './const-pmHlwm3E.js';
1
+ import { R as ReadOnlyCollectionClient } from './collection-client-gWsA7BVP.js';
2
+ import { C as CommerceClient, a as CommunityClient, b as ContentClient, E as EventsClient, c as CustomerNamespace, d as CustomerMembershipView, e as ClientState, f as ClientConfig } from './types-B9lGhZlB.js';
3
+ export { A as AddItemParams, g as ApiQueryOptions, h as ApplyDiscountParams, i as CheckoutParams, j as ClearCartParams, k as ClientMetadata, l as ContentClientOptions, D as DebugConfig, m as DeepPartial, n as ExtractArrayType, P as PayloadFindResponse, o as PayloadMutationResponse, p as PublicCart, q as PublicCartItem, r as PublicCartReference, s as PublicMediaAsset, t as PublicMediaSize, u as PublicOrder, v as PublicOrderItem, w as PublicOrderReference, R as RemoveDiscountParams, x as RemoveItemParams, y as RetryConfig, z as RootClient, z as RootClientType, B as RootCollectionClient, F as RootReadOnlyQueryBuilder, S as Sort, G as StorefrontContentListOptions, H as StorefrontContentReference, I as StorefrontGalleryItem, J as StorefrontGalleryItemsListOptions, K as StorefrontGalleryItemsSort, L as StorefrontLink, M as StorefrontLinksListOptions, N as StorefrontLinksSort, U as UpdateItemParams, W as Where } from './types-B9lGhZlB.js';
4
+ import './payload-types-DLxkB7Mv.js';
5
+ export { C as Collection, P as PublicCollection } from './const-_WWHU-gX.js';
6
6
  import './metadata.js';
7
- import './types-Bf2iCjy8.js';
7
+ import './types-BiKNBwRA.js';
8
8
 
9
9
  declare class Client {
10
10
  commerce: CommerceClient;
@@ -13,6 +13,9 @@ declare class Client {
13
13
  events: EventsClient;
14
14
  customer: CustomerNamespace;
15
15
  collections: ReadOnlyCollectionClient;
16
+ memberships: {
17
+ me: () => Promise<CustomerMembershipView | null>;
18
+ };
16
19
  lastRequestId: string | null;
17
20
  protected state: ClientState;
18
21
  protected config: ClientConfig;
package/dist/client.js CHANGED
@@ -640,6 +640,64 @@ async function httpFetch(url, options) {
640
640
  throw lastError ?? new NetworkError("Request failed after retries");
641
641
  }
642
642
 
643
+ // src/core/api/endpoints.ts
644
+ var COMMERCE_ENDPOINTS = {
645
+ orders: {
646
+ create: "/api/orders/create",
647
+ update: "/api/orders/update",
648
+ confirmPayment: "/api/orders/confirm-payment",
649
+ byPayment: "/api/orders/by-payment",
650
+ cancel: "/api/orders/cancel",
651
+ resolveCancelRefund: "/api/orders/resolve-cancel-refund",
652
+ checkout: "/api/orders/checkout",
653
+ createFulfillment: "/api/orders/create-fulfillment",
654
+ updateFulfillment: "/api/orders/update-fulfillment"
655
+ },
656
+ transactions: {
657
+ update: "/api/transactions/update"
658
+ },
659
+ returns: {
660
+ create: "/api/returns/create",
661
+ update: "/api/returns/update",
662
+ returnRefund: "/api/returns/return-refund"
663
+ },
664
+ fulfillmentOrders: {
665
+ prepare: "/api/fulfillment-orders/prepare-fulfillment-order"
666
+ },
667
+ fulfillments: {
668
+ bulkImport: "/api/fulfillments/bulk-import"
669
+ },
670
+ carts: {
671
+ mine: "/api/carts/mine",
672
+ merge: "/api/carts/merge",
673
+ addItem: "/api/carts/add-item",
674
+ updateItem: "/api/carts/update-item",
675
+ removeItem: "/api/carts/remove-item",
676
+ applyDiscount: "/api/carts/apply-discount",
677
+ removeDiscount: "/api/carts/remove-discount",
678
+ clear: "/api/carts/clear"
679
+ },
680
+ products: {
681
+ stockCheck: "/api/products/stock-check",
682
+ stockSnapshot: "/api/products/stock",
683
+ listingGroups: "/api/products/listing-groups",
684
+ listingGroupsCatalog: "/api/products/listing-groups/catalog",
685
+ listingGroupsQuery: "/api/products/listing-groups/query",
686
+ listingGroupsQueryCatalog: "/api/products/listing-groups/query/catalog",
687
+ detail: "/api/products/detail",
688
+ detailCatalog: "/api/products/detail/catalog",
689
+ upsert: "/api/products/upsert"
690
+ }
691
+ };
692
+ var COMMERCE_ENDPOINT_PATHS = Object.values(
693
+ COMMERCE_ENDPOINTS
694
+ ).flatMap((group) => Object.values(group));
695
+ var MEMBERSHIP_ENDPOINTS = {
696
+ subscribe: "/api/memberships/subscribe",
697
+ cancel: (id) => `/api/memberships/${id}/cancel`,
698
+ me: "/api/memberships/me"
699
+ };
700
+
643
701
  // src/core/internal/utils/query-string.ts
644
702
  function productDetailQuery(params) {
645
703
  const search = new URLSearchParams();
@@ -648,7 +706,7 @@ function productDetailQuery(params) {
648
706
  } else {
649
707
  search.set("id", params.id);
650
708
  }
651
- return `/api/products/detail?${search}`;
709
+ return `${COMMERCE_ENDPOINTS.products.detail}?${search}`;
652
710
  }
653
711
  function productDetailCatalogQuery(params) {
654
712
  const search = new URLSearchParams();
@@ -657,20 +715,17 @@ function productDetailCatalogQuery(params) {
657
715
  } else {
658
716
  search.set("id", params.id);
659
717
  }
660
- return `/api/products/detail/catalog?${search}`;
718
+ return `${COMMERCE_ENDPOINTS.products.detailCatalog}?${search}`;
661
719
  }
662
720
  function listingGroupsCatalogQuery(params) {
663
- return `/api/products/listing-groups/catalog?ids=${params.productIds.map(encodeURIComponent).join(",")}`;
721
+ return `${COMMERCE_ENDPOINTS.products.listingGroupsCatalog}?ids=${params.productIds.map(encodeURIComponent).join(",")}`;
664
722
  }
665
723
  function appendListingGroupsQuerySearchParams(search, options) {
666
724
  if (options?.page != null) search.set("page", String(options.page));
667
725
  if (options?.limit != null) search.set("limit", String(options.limit));
668
726
  if (options?.sort != null) {
669
727
  const sort = options.sort;
670
- search.set(
671
- "sort",
672
- Array.isArray(sort) ? sort.join(",") : sort
673
- );
728
+ search.set("sort", Array.isArray(sort) ? sort.join(",") : sort);
674
729
  }
675
730
  if (options?.where != null) {
676
731
  search.set("whereJson", JSON.stringify(options.where));
@@ -680,16 +735,16 @@ function listingGroupsQueryUrl(options) {
680
735
  const search = new URLSearchParams();
681
736
  appendListingGroupsQuerySearchParams(search, options);
682
737
  const query = search.toString();
683
- return `/api/products/listing-groups/query${query ? `?${query}` : ""}`;
738
+ return `${COMMERCE_ENDPOINTS.products.listingGroupsQuery}${query ? `?${query}` : ""}`;
684
739
  }
685
740
  function listingGroupsQueryCatalogUrl(options) {
686
741
  const search = new URLSearchParams();
687
742
  appendListingGroupsQuerySearchParams(search, options);
688
743
  const query = search.toString();
689
- return `/api/products/listing-groups/query/catalog${query ? `?${query}` : ""}`;
744
+ return `${COMMERCE_ENDPOINTS.products.listingGroupsQueryCatalog}${query ? `?${query}` : ""}`;
690
745
  }
691
746
  function stockSnapshotQuery(params) {
692
- return `/api/products/stock?variantIds=${params.variantIds.map(encodeURIComponent).join(",")}`;
747
+ return `${COMMERCE_ENDPOINTS.products.stockSnapshot}?variantIds=${params.variantIds.map(encodeURIComponent).join(",")}`;
693
748
  }
694
749
 
695
750
  // src/core/collection/http-client.ts
@@ -1578,48 +1633,6 @@ var CustomerNamespace = class {
1578
1633
  }
1579
1634
  };
1580
1635
 
1581
- // src/core/api/endpoints.ts
1582
- var COMMERCE_ENDPOINTS = {
1583
- orders: {
1584
- create: "/api/orders/create",
1585
- update: "/api/orders/update",
1586
- confirmPayment: "/api/orders/confirm-payment",
1587
- byPayment: "/api/orders/by-payment",
1588
- cancel: "/api/orders/cancel",
1589
- resolveCancelRefund: "/api/orders/resolve-cancel-refund",
1590
- checkout: "/api/orders/checkout",
1591
- createFulfillment: "/api/orders/create-fulfillment",
1592
- updateFulfillment: "/api/orders/update-fulfillment"
1593
- },
1594
- transactions: {
1595
- update: "/api/transactions/update"
1596
- },
1597
- returns: {
1598
- create: "/api/returns/create",
1599
- update: "/api/returns/update",
1600
- returnRefund: "/api/returns/return-refund"
1601
- },
1602
- fulfillmentOrders: {
1603
- prepare: "/api/fulfillment-orders/prepare-fulfillment-order"
1604
- },
1605
- fulfillments: {
1606
- bulkImport: "/api/fulfillments/bulk-import"
1607
- },
1608
- carts: {
1609
- mine: "/api/carts/mine",
1610
- merge: "/api/carts/merge",
1611
- addItem: "/api/carts/add-item",
1612
- updateItem: "/api/carts/update-item",
1613
- removeItem: "/api/carts/remove-item",
1614
- applyDiscount: "/api/carts/apply-discount",
1615
- removeDiscount: "/api/carts/remove-discount",
1616
- clear: "/api/carts/clear"
1617
- }
1618
- };
1619
- var COMMERCE_ENDPOINT_PATHS = Object.values(
1620
- COMMERCE_ENDPOINTS
1621
- ).flatMap((group) => Object.values(group));
1622
-
1623
1636
  // src/core/api/cart-api.ts
1624
1637
  var CartApi = class extends CustomerScopedApi {
1625
1638
  constructor(options) {
@@ -2843,7 +2856,10 @@ var CommerceClient = class {
2843
2856
  onRequestId: options.onRequestId
2844
2857
  });
2845
2858
  this.product = {
2846
- stockCheck: (params) => api.post("/api/products/stock-check", params),
2859
+ stockCheck: (params) => api.post(
2860
+ COMMERCE_ENDPOINTS.products.stockCheck,
2861
+ params
2862
+ ),
2847
2863
  stockSnapshot: (params) => api.get(stockSnapshotQuery(params)),
2848
2864
  listingGroups: (params) => api.get(
2849
2865
  listingGroupsCatalogQuery(params)
@@ -2861,7 +2877,9 @@ var CommerceClient = class {
2861
2877
  },
2862
2878
  detail: async (params) => {
2863
2879
  try {
2864
- const product = await api.get(productDetailQuery(params));
2880
+ const product = await api.get(
2881
+ productDetailQuery(params)
2882
+ );
2865
2883
  return { found: true, product };
2866
2884
  } catch (err) {
2867
2885
  const notFoundResult = productDetailResultFromError(err);
@@ -2909,7 +2927,10 @@ var CommerceClient = class {
2909
2927
  validate: (params) => api.post("/api/discounts/validate", params)
2910
2928
  };
2911
2929
  this.shipping = {
2912
- calculate: (params) => api.post("/api/shipping-policies/calculate", params)
2930
+ calculate: (params) => api.post(
2931
+ "/api/shipping-policies/calculate",
2932
+ params
2933
+ )
2913
2934
  };
2914
2935
  }
2915
2936
  };
@@ -2998,8 +3019,12 @@ function buildGuestCancelRequestBody(token, params) {
2998
3019
  }
2999
3020
  function buildRangeEndpoint(params) {
3000
3021
  const urlParams = new URLSearchParams();
3001
- urlParams.set("start", formatDateParam(params.start));
3002
- urlParams.set("end", formatDateParam(params.end));
3022
+ if (params.start !== void 0) {
3023
+ urlParams.set("start", formatDateParam(params.start));
3024
+ }
3025
+ if (params.end !== void 0) {
3026
+ urlParams.set("end", formatDateParam(params.end));
3027
+ }
3003
3028
  if (params.limit !== void 0) urlParams.set("limit", String(params.limit));
3004
3029
  if (params.page !== void 0) urlParams.set("page", String(params.page));
3005
3030
  appendValues(urlParams, "calendar", params.calendar);
@@ -3022,6 +3047,13 @@ function appendValues(params, key, value) {
3022
3047
  }
3023
3048
 
3024
3049
  // src/core/client/client.ts
3050
+ var BrowserMembershipApi = class extends CustomerScopedApi {
3051
+ me() {
3052
+ return this.request(MEMBERSHIP_ENDPOINTS.me, {
3053
+ method: "GET"
3054
+ });
3055
+ }
3056
+ };
3025
3057
  var Client = class {
3026
3058
  constructor(options) {
3027
3059
  this.lastRequestId = null;
@@ -3086,6 +3118,16 @@ var Client = class {
3086
3118
  onRequestId,
3087
3119
  this.config.apiUrl
3088
3120
  );
3121
+ const membershipApi = new BrowserMembershipApi("MembershipApi", {
3122
+ publishableKey: this.config.publishableKey,
3123
+ apiUrl: this.config.apiUrl,
3124
+ customerToken: () => this.customer.auth.getToken(),
3125
+ onUnauthorized,
3126
+ onRequestId
3127
+ });
3128
+ this.memberships = {
3129
+ me: membershipApi.me.bind(membershipApi)
3130
+ };
3089
3131
  }
3090
3132
  getState() {
3091
3133
  return { ...this.state };