@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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,43 @@
|
|
|
1
1
|
# @01.software/sdk
|
|
2
2
|
|
|
3
|
+
## 0.43.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 81ef105: Expose cart item `requiresShipping` snapshots through the public cart item
|
|
8
|
+
types, and update the ecommerce starter so non-shipping-only carts skip shipping
|
|
9
|
+
address collection while legacy or mixed carts remain shippable by default.
|
|
10
|
+
- 5d7b26f: Expose the new `markets` collection slug through the browser-safe `COLLECTIONS`
|
|
11
|
+
constant so storefront and integration code can address tenant-scoped market
|
|
12
|
+
records without local collection-name mirrors.
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- 9789528: Add checkout shipping context fields to the SDK contract and update the
|
|
17
|
+
ecommerce starter to pass checkout context through the order API instead of
|
|
18
|
+
mutating carts through the customer-scoped SDK client.
|
|
19
|
+
- 9b7afab: Expose membership plan and customer membership collection slugs in the public collection surface.
|
|
20
|
+
- db8bd4b: Add optional `seo` (title/description) to product upsert `ProductFieldsInput` for CSV import parity.
|
|
21
|
+
- b95f6ac: Expose stable storefront discount validation reason codes in the SDK.
|
|
22
|
+
`ValidateDiscountResult.reasonCode` now carries the machine-readable discount
|
|
23
|
+
reason union returned by `/api/discounts/validate`, so storefronts can branch and
|
|
24
|
+
localize without parsing human-readable `reason` text.
|
|
25
|
+
- c60ec7f: fix(sdk): remove stale event calendar order field
|
|
26
|
+
|
|
27
|
+
`EventCalendar` and its select type no longer expose the stale `_order` field
|
|
28
|
+
because tenant-global event calendars are not operator-orderable.
|
|
29
|
+
|
|
30
|
+
- 6c71a71: chore(sdk): sync event occurrence timezone generated type docs
|
|
31
|
+
|
|
32
|
+
The generated Payload types now include the Event Occurrence timezone field
|
|
33
|
+
description used by Console's read-only occurrence identity timezone contract.
|
|
34
|
+
Type-only change; no SDK runtime or request shape changed.
|
|
35
|
+
|
|
36
|
+
- 3aa6239: Allow `events.getRange()` to omit `start` and `end` so the public events range endpoint can use the tenant calendar's public listing defaults.
|
|
37
|
+
- 294b7d1: Keep membership contract-parity type tests within the SDK export guard's explicit test-only private-contract allowlist.
|
|
38
|
+
- f87fe09: Add return approval and rejection commerce notification webhook events.
|
|
39
|
+
- 4362b14: Expose tenant commerce `fulfillmentMode` in tenant feature progress responses.
|
|
40
|
+
|
|
3
41
|
## 0.42.0
|
|
4
42
|
|
|
5
43
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -118,7 +118,10 @@ typo detection) and pass it as the generic. Mistyped names and out-of-enum
|
|
|
118
118
|
values then fail to compile:
|
|
119
119
|
|
|
120
120
|
```typescript
|
|
121
|
-
import {
|
|
121
|
+
import {
|
|
122
|
+
createAnalytics,
|
|
123
|
+
defineAnalyticsEvents,
|
|
124
|
+
} from '@01.software/sdk/analytics'
|
|
122
125
|
|
|
123
126
|
type ShopEvents = {
|
|
124
127
|
signup: { plan: 'free' | 'pro'; trial: boolean }
|
|
@@ -128,7 +131,7 @@ type ShopEvents = {
|
|
|
128
131
|
|
|
129
132
|
const analytics = createAnalytics<ShopEvents>({ publishableKey: 'pk_xxx' })
|
|
130
133
|
analytics.track('signup', { plan: 'pro', trial: false }) // ✅
|
|
131
|
-
analytics.track('checkout_start')
|
|
134
|
+
analytics.track('checkout_start') // ✅ no props
|
|
132
135
|
// analytics.track('signpu', { plan: 'pro', trial: false }) // ❌ unknown event
|
|
133
136
|
// analytics.track('signup', { plan: 'team', trial: false }) // ❌ enum violation
|
|
134
137
|
|
|
@@ -144,7 +147,10 @@ instance for its subtree:
|
|
|
144
147
|
Reusing the `ShopEvents` type from above:
|
|
145
148
|
|
|
146
149
|
```tsx
|
|
147
|
-
import {
|
|
150
|
+
import {
|
|
151
|
+
AnalyticsProvider,
|
|
152
|
+
useAnalytics,
|
|
153
|
+
} from '@01.software/sdk/analytics/react'
|
|
148
154
|
|
|
149
155
|
function Root() {
|
|
150
156
|
return (
|
|
@@ -1411,7 +1417,7 @@ Source of truth: `packages/sdk/src/core/collection/const.ts` (`COLLECTIONS`).
|
|
|
1411
1417
|
| Category | Browser-public generic collections |
|
|
1412
1418
|
| ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
1413
1419
|
| Tenant | `tenants`, `tenant-metadata` |
|
|
1414
|
-
| Products | `products`, `product-variants`, `product-options`, `product-option-values`, `product-categories`, `product-tags`, `product-collections`, `brands`
|
|
1420
|
+
| Products | `products`, `product-variants`, `product-options`, `product-option-values`, `product-categories`, `product-tags`, `product-collections`, `markets`, `brands` |
|
|
1415
1421
|
| Customers | `customer-profiles` |
|
|
1416
1422
|
| Commerce | `discounts`, `shipping-policies`, `shipping-zones` |
|
|
1417
1423
|
| Content | `documents`, `document-categories`, `document-types`, `articles`, `article-authors`, `article-categories`, `article-tags`, `links`, `link-categories`, `link-tags` |
|
package/dist/client.cjs
CHANGED
|
@@ -668,6 +668,64 @@ async function httpFetch(url, options) {
|
|
|
668
668
|
throw lastError ?? new NetworkError("Request failed after retries");
|
|
669
669
|
}
|
|
670
670
|
|
|
671
|
+
// src/core/api/endpoints.ts
|
|
672
|
+
var COMMERCE_ENDPOINTS = {
|
|
673
|
+
orders: {
|
|
674
|
+
create: "/api/orders/create",
|
|
675
|
+
update: "/api/orders/update",
|
|
676
|
+
confirmPayment: "/api/orders/confirm-payment",
|
|
677
|
+
byPayment: "/api/orders/by-payment",
|
|
678
|
+
cancel: "/api/orders/cancel",
|
|
679
|
+
resolveCancelRefund: "/api/orders/resolve-cancel-refund",
|
|
680
|
+
checkout: "/api/orders/checkout",
|
|
681
|
+
createFulfillment: "/api/orders/create-fulfillment",
|
|
682
|
+
updateFulfillment: "/api/orders/update-fulfillment"
|
|
683
|
+
},
|
|
684
|
+
transactions: {
|
|
685
|
+
update: "/api/transactions/update"
|
|
686
|
+
},
|
|
687
|
+
returns: {
|
|
688
|
+
create: "/api/returns/create",
|
|
689
|
+
update: "/api/returns/update",
|
|
690
|
+
returnRefund: "/api/returns/return-refund"
|
|
691
|
+
},
|
|
692
|
+
fulfillmentOrders: {
|
|
693
|
+
prepare: "/api/fulfillment-orders/prepare-fulfillment-order"
|
|
694
|
+
},
|
|
695
|
+
fulfillments: {
|
|
696
|
+
bulkImport: "/api/fulfillments/bulk-import"
|
|
697
|
+
},
|
|
698
|
+
carts: {
|
|
699
|
+
mine: "/api/carts/mine",
|
|
700
|
+
merge: "/api/carts/merge",
|
|
701
|
+
addItem: "/api/carts/add-item",
|
|
702
|
+
updateItem: "/api/carts/update-item",
|
|
703
|
+
removeItem: "/api/carts/remove-item",
|
|
704
|
+
applyDiscount: "/api/carts/apply-discount",
|
|
705
|
+
removeDiscount: "/api/carts/remove-discount",
|
|
706
|
+
clear: "/api/carts/clear"
|
|
707
|
+
},
|
|
708
|
+
products: {
|
|
709
|
+
stockCheck: "/api/products/stock-check",
|
|
710
|
+
stockSnapshot: "/api/products/stock",
|
|
711
|
+
listingGroups: "/api/products/listing-groups",
|
|
712
|
+
listingGroupsCatalog: "/api/products/listing-groups/catalog",
|
|
713
|
+
listingGroupsQuery: "/api/products/listing-groups/query",
|
|
714
|
+
listingGroupsQueryCatalog: "/api/products/listing-groups/query/catalog",
|
|
715
|
+
detail: "/api/products/detail",
|
|
716
|
+
detailCatalog: "/api/products/detail/catalog",
|
|
717
|
+
upsert: "/api/products/upsert"
|
|
718
|
+
}
|
|
719
|
+
};
|
|
720
|
+
var COMMERCE_ENDPOINT_PATHS = Object.values(
|
|
721
|
+
COMMERCE_ENDPOINTS
|
|
722
|
+
).flatMap((group) => Object.values(group));
|
|
723
|
+
var MEMBERSHIP_ENDPOINTS = {
|
|
724
|
+
subscribe: "/api/memberships/subscribe",
|
|
725
|
+
cancel: (id) => `/api/memberships/${id}/cancel`,
|
|
726
|
+
me: "/api/memberships/me"
|
|
727
|
+
};
|
|
728
|
+
|
|
671
729
|
// src/core/internal/utils/query-string.ts
|
|
672
730
|
function productDetailQuery(params) {
|
|
673
731
|
const search = new URLSearchParams();
|
|
@@ -676,7 +734,7 @@ function productDetailQuery(params) {
|
|
|
676
734
|
} else {
|
|
677
735
|
search.set("id", params.id);
|
|
678
736
|
}
|
|
679
|
-
return
|
|
737
|
+
return `${COMMERCE_ENDPOINTS.products.detail}?${search}`;
|
|
680
738
|
}
|
|
681
739
|
function productDetailCatalogQuery(params) {
|
|
682
740
|
const search = new URLSearchParams();
|
|
@@ -685,20 +743,17 @@ function productDetailCatalogQuery(params) {
|
|
|
685
743
|
} else {
|
|
686
744
|
search.set("id", params.id);
|
|
687
745
|
}
|
|
688
|
-
return
|
|
746
|
+
return `${COMMERCE_ENDPOINTS.products.detailCatalog}?${search}`;
|
|
689
747
|
}
|
|
690
748
|
function listingGroupsCatalogQuery(params) {
|
|
691
|
-
return
|
|
749
|
+
return `${COMMERCE_ENDPOINTS.products.listingGroupsCatalog}?ids=${params.productIds.map(encodeURIComponent).join(",")}`;
|
|
692
750
|
}
|
|
693
751
|
function appendListingGroupsQuerySearchParams(search, options) {
|
|
694
752
|
if (options?.page != null) search.set("page", String(options.page));
|
|
695
753
|
if (options?.limit != null) search.set("limit", String(options.limit));
|
|
696
754
|
if (options?.sort != null) {
|
|
697
755
|
const sort = options.sort;
|
|
698
|
-
search.set(
|
|
699
|
-
"sort",
|
|
700
|
-
Array.isArray(sort) ? sort.join(",") : sort
|
|
701
|
-
);
|
|
756
|
+
search.set("sort", Array.isArray(sort) ? sort.join(",") : sort);
|
|
702
757
|
}
|
|
703
758
|
if (options?.where != null) {
|
|
704
759
|
search.set("whereJson", JSON.stringify(options.where));
|
|
@@ -708,16 +763,16 @@ function listingGroupsQueryUrl(options) {
|
|
|
708
763
|
const search = new URLSearchParams();
|
|
709
764
|
appendListingGroupsQuerySearchParams(search, options);
|
|
710
765
|
const query = search.toString();
|
|
711
|
-
return
|
|
766
|
+
return `${COMMERCE_ENDPOINTS.products.listingGroupsQuery}${query ? `?${query}` : ""}`;
|
|
712
767
|
}
|
|
713
768
|
function listingGroupsQueryCatalogUrl(options) {
|
|
714
769
|
const search = new URLSearchParams();
|
|
715
770
|
appendListingGroupsQuerySearchParams(search, options);
|
|
716
771
|
const query = search.toString();
|
|
717
|
-
return
|
|
772
|
+
return `${COMMERCE_ENDPOINTS.products.listingGroupsQueryCatalog}${query ? `?${query}` : ""}`;
|
|
718
773
|
}
|
|
719
774
|
function stockSnapshotQuery(params) {
|
|
720
|
-
return
|
|
775
|
+
return `${COMMERCE_ENDPOINTS.products.stockSnapshot}?variantIds=${params.variantIds.map(encodeURIComponent).join(",")}`;
|
|
721
776
|
}
|
|
722
777
|
|
|
723
778
|
// src/core/collection/http-client.ts
|
|
@@ -1606,48 +1661,6 @@ var CustomerNamespace = class {
|
|
|
1606
1661
|
}
|
|
1607
1662
|
};
|
|
1608
1663
|
|
|
1609
|
-
// src/core/api/endpoints.ts
|
|
1610
|
-
var COMMERCE_ENDPOINTS = {
|
|
1611
|
-
orders: {
|
|
1612
|
-
create: "/api/orders/create",
|
|
1613
|
-
update: "/api/orders/update",
|
|
1614
|
-
confirmPayment: "/api/orders/confirm-payment",
|
|
1615
|
-
byPayment: "/api/orders/by-payment",
|
|
1616
|
-
cancel: "/api/orders/cancel",
|
|
1617
|
-
resolveCancelRefund: "/api/orders/resolve-cancel-refund",
|
|
1618
|
-
checkout: "/api/orders/checkout",
|
|
1619
|
-
createFulfillment: "/api/orders/create-fulfillment",
|
|
1620
|
-
updateFulfillment: "/api/orders/update-fulfillment"
|
|
1621
|
-
},
|
|
1622
|
-
transactions: {
|
|
1623
|
-
update: "/api/transactions/update"
|
|
1624
|
-
},
|
|
1625
|
-
returns: {
|
|
1626
|
-
create: "/api/returns/create",
|
|
1627
|
-
update: "/api/returns/update",
|
|
1628
|
-
returnRefund: "/api/returns/return-refund"
|
|
1629
|
-
},
|
|
1630
|
-
fulfillmentOrders: {
|
|
1631
|
-
prepare: "/api/fulfillment-orders/prepare-fulfillment-order"
|
|
1632
|
-
},
|
|
1633
|
-
fulfillments: {
|
|
1634
|
-
bulkImport: "/api/fulfillments/bulk-import"
|
|
1635
|
-
},
|
|
1636
|
-
carts: {
|
|
1637
|
-
mine: "/api/carts/mine",
|
|
1638
|
-
merge: "/api/carts/merge",
|
|
1639
|
-
addItem: "/api/carts/add-item",
|
|
1640
|
-
updateItem: "/api/carts/update-item",
|
|
1641
|
-
removeItem: "/api/carts/remove-item",
|
|
1642
|
-
applyDiscount: "/api/carts/apply-discount",
|
|
1643
|
-
removeDiscount: "/api/carts/remove-discount",
|
|
1644
|
-
clear: "/api/carts/clear"
|
|
1645
|
-
}
|
|
1646
|
-
};
|
|
1647
|
-
var COMMERCE_ENDPOINT_PATHS = Object.values(
|
|
1648
|
-
COMMERCE_ENDPOINTS
|
|
1649
|
-
).flatMap((group) => Object.values(group));
|
|
1650
|
-
|
|
1651
1664
|
// src/core/api/cart-api.ts
|
|
1652
1665
|
var CartApi = class extends CustomerScopedApi {
|
|
1653
1666
|
constructor(options) {
|
|
@@ -2871,7 +2884,10 @@ var CommerceClient = class {
|
|
|
2871
2884
|
onRequestId: options.onRequestId
|
|
2872
2885
|
});
|
|
2873
2886
|
this.product = {
|
|
2874
|
-
stockCheck: (params) => api.post(
|
|
2887
|
+
stockCheck: (params) => api.post(
|
|
2888
|
+
COMMERCE_ENDPOINTS.products.stockCheck,
|
|
2889
|
+
params
|
|
2890
|
+
),
|
|
2875
2891
|
stockSnapshot: (params) => api.get(stockSnapshotQuery(params)),
|
|
2876
2892
|
listingGroups: (params) => api.get(
|
|
2877
2893
|
listingGroupsCatalogQuery(params)
|
|
@@ -2889,7 +2905,9 @@ var CommerceClient = class {
|
|
|
2889
2905
|
},
|
|
2890
2906
|
detail: async (params) => {
|
|
2891
2907
|
try {
|
|
2892
|
-
const product = await api.get(
|
|
2908
|
+
const product = await api.get(
|
|
2909
|
+
productDetailQuery(params)
|
|
2910
|
+
);
|
|
2893
2911
|
return { found: true, product };
|
|
2894
2912
|
} catch (err) {
|
|
2895
2913
|
const notFoundResult = productDetailResultFromError(err);
|
|
@@ -2937,7 +2955,10 @@ var CommerceClient = class {
|
|
|
2937
2955
|
validate: (params) => api.post("/api/discounts/validate", params)
|
|
2938
2956
|
};
|
|
2939
2957
|
this.shipping = {
|
|
2940
|
-
calculate: (params) => api.post(
|
|
2958
|
+
calculate: (params) => api.post(
|
|
2959
|
+
"/api/shipping-policies/calculate",
|
|
2960
|
+
params
|
|
2961
|
+
)
|
|
2941
2962
|
};
|
|
2942
2963
|
}
|
|
2943
2964
|
};
|
|
@@ -3026,8 +3047,12 @@ function buildGuestCancelRequestBody(token, params) {
|
|
|
3026
3047
|
}
|
|
3027
3048
|
function buildRangeEndpoint(params) {
|
|
3028
3049
|
const urlParams = new URLSearchParams();
|
|
3029
|
-
|
|
3030
|
-
|
|
3050
|
+
if (params.start !== void 0) {
|
|
3051
|
+
urlParams.set("start", formatDateParam(params.start));
|
|
3052
|
+
}
|
|
3053
|
+
if (params.end !== void 0) {
|
|
3054
|
+
urlParams.set("end", formatDateParam(params.end));
|
|
3055
|
+
}
|
|
3031
3056
|
if (params.limit !== void 0) urlParams.set("limit", String(params.limit));
|
|
3032
3057
|
if (params.page !== void 0) urlParams.set("page", String(params.page));
|
|
3033
3058
|
appendValues(urlParams, "calendar", params.calendar);
|
|
@@ -3050,6 +3075,13 @@ function appendValues(params, key, value) {
|
|
|
3050
3075
|
}
|
|
3051
3076
|
|
|
3052
3077
|
// src/core/client/client.ts
|
|
3078
|
+
var BrowserMembershipApi = class extends CustomerScopedApi {
|
|
3079
|
+
me() {
|
|
3080
|
+
return this.request(MEMBERSHIP_ENDPOINTS.me, {
|
|
3081
|
+
method: "GET"
|
|
3082
|
+
});
|
|
3083
|
+
}
|
|
3084
|
+
};
|
|
3053
3085
|
var Client = class {
|
|
3054
3086
|
constructor(options) {
|
|
3055
3087
|
this.lastRequestId = null;
|
|
@@ -3114,6 +3146,16 @@ var Client = class {
|
|
|
3114
3146
|
onRequestId,
|
|
3115
3147
|
this.config.apiUrl
|
|
3116
3148
|
);
|
|
3149
|
+
const membershipApi = new BrowserMembershipApi("MembershipApi", {
|
|
3150
|
+
publishableKey: this.config.publishableKey,
|
|
3151
|
+
apiUrl: this.config.apiUrl,
|
|
3152
|
+
customerToken: () => this.customer.auth.getToken(),
|
|
3153
|
+
onUnauthorized,
|
|
3154
|
+
onRequestId
|
|
3155
|
+
});
|
|
3156
|
+
this.memberships = {
|
|
3157
|
+
me: membershipApi.me.bind(membershipApi)
|
|
3158
|
+
};
|
|
3117
3159
|
}
|
|
3118
3160
|
getState() {
|
|
3119
3161
|
return { ...this.state };
|