@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.
- package/CHANGELOG.md +38 -0
- package/README.md +10 -4
- package/dist/client.cjs +99 -57
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +9 -6
- package/dist/client.d.ts +9 -6
- package/dist/client.js +99 -57
- package/dist/client.js.map +1 -1
- package/dist/{collection-client-B-qVIBnJ.d.cts → collection-client-U70KizLf.d.cts} +3 -3
- package/dist/{collection-client-BhCMwIus.d.ts → collection-client-gWsA7BVP.d.ts} +3 -3
- package/dist/{const-pmHlwm3E.d.ts → const-BBynifk0.d.cts} +5 -5
- package/dist/{const-BiDujixF.d.cts → const-_WWHU-gX.d.ts} +5 -5
- package/dist/{index-B1UBDaKz.d.ts → index-DPi5NWU8.d.ts} +4 -4
- package/dist/{index-D78ki6Ij.d.cts → index-Dg4Y6Aq7.d.cts} +4 -4
- package/dist/index.cjs +111 -61
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +41 -8
- package/dist/index.d.ts +41 -8
- package/dist/index.js +111 -61
- package/dist/index.js.map +1 -1
- package/dist/{payload-types-C7Ul4ElL.d.cts → payload-types-DLxkB7Mv.d.cts} +399 -27
- package/dist/{payload-types-C7Ul4ElL.d.ts → payload-types-DLxkB7Mv.d.ts} +399 -27
- package/dist/query.cjs +59 -7
- 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 +59 -7
- 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 +130 -57
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.cts +12 -7
- package/dist/server.d.ts +12 -7
- package/dist/server.js +130 -57
- package/dist/server.js.map +1 -1
- package/dist/{types-ChV1t4ei.d.cts → types-B1ngKbWI.d.cts} +1 -1
- package/dist/{types-BL7M-EUV.d.cts → types-B9lGhZlB.d.ts} +95 -6
- package/dist/{types-Bf2iCjy8.d.ts → types-BiKNBwRA.d.ts} +1 -1
- package/dist/{types-D5dSNIGs.d.ts → types-Bpx5sYKo.d.cts} +95 -6
- package/dist/ui/form.d.cts +1 -1
- package/dist/ui/form.d.ts +1 -1
- package/dist/ui/video.d.cts +1 -1
- package/dist/ui/video.d.ts +1 -1
- package/dist/webhook.cjs +3 -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 +3 -1
- package/dist/webhook.js.map +1 -1
- package/package.json +1 -1
package/dist/client.d.cts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { R as ReadOnlyCollectionClient } from './collection-client-
|
|
2
|
-
import { C as CommerceClient, a as CommunityClient, b as ContentClient, E as EventsClient, c as CustomerNamespace, d as
|
|
3
|
-
export { A as AddItemParams,
|
|
4
|
-
import './payload-types-
|
|
5
|
-
export { C as Collection, P as PublicCollection } from './const-
|
|
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-
|
|
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-
|
|
2
|
-
import { C as CommerceClient, a as CommunityClient, b as ContentClient, E as EventsClient, c as CustomerNamespace, d as
|
|
3
|
-
export { A as AddItemParams,
|
|
4
|
-
import './payload-types-
|
|
5
|
-
export { C as Collection, P as PublicCollection } from './const-
|
|
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-
|
|
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
|
|
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
|
|
718
|
+
return `${COMMERCE_ENDPOINTS.products.detailCatalog}?${search}`;
|
|
661
719
|
}
|
|
662
720
|
function listingGroupsCatalogQuery(params) {
|
|
663
|
-
return
|
|
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
|
|
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
|
|
744
|
+
return `${COMMERCE_ENDPOINTS.products.listingGroupsQueryCatalog}${query ? `?${query}` : ""}`;
|
|
690
745
|
}
|
|
691
746
|
function stockSnapshotQuery(params) {
|
|
692
|
-
return
|
|
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(
|
|
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(
|
|
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(
|
|
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
|
-
|
|
3002
|
-
|
|
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 };
|