@malawistore/store-sdk 0.1.1 → 0.1.3
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 +19 -0
- package/README.md +31 -3
- package/dist/index.cjs +108 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +74 -10
- package/dist/index.d.ts +74 -10
- package/dist/index.js +108 -12
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,25 @@ All notable changes to this project are documented here. The format follows
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [0.1.3] - 2026-10-29
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- `cart.getPage()` with line filters (`q`, `product_id`, `variant_id`), sorting,
|
|
14
|
+
and paging metadata; cart totals still cover every line.
|
|
15
|
+
- `orders.listPage()` with status/currency/date/total filters and sorting.
|
|
16
|
+
- `wishlist.listPage()` with product search, category filtering, and sorting.
|
|
17
|
+
- Review filters and paging through `reviews.summary(productId, params)`.
|
|
18
|
+
- `ListCartParams`, `ListOrdersParams`, `ListWishlistParams`,
|
|
19
|
+
`ListReviewsParams`, and `CartResponse` wire types.
|
|
20
|
+
|
|
21
|
+
### Changed
|
|
22
|
+
|
|
23
|
+
- Storefront and shopper lists default to 12 rows per page; the admin user
|
|
24
|
+
directory still defaults to 20. Every page remains capped at 100.
|
|
25
|
+
- Existing `list()`, `get()`, and `summary()` methods now accept the same
|
|
26
|
+
optional query parameters without changing their return shapes.
|
|
27
|
+
|
|
9
28
|
## [0.1.1] - 2026-10-28
|
|
10
29
|
|
|
11
30
|
### Added
|
package/README.md
CHANGED
|
@@ -120,7 +120,7 @@ several parallel queries does not rotate the token multiple times.
|
|
|
120
120
|
| `store.cart` | Get, add, update quantity, remove, clear |
|
|
121
121
|
| `store.inventory` | Stock lookup and admin set/reserve/release/confirm |
|
|
122
122
|
| `store.orders` | Checkout, list, get, cancel |
|
|
123
|
-
| `store.payments` | Stripe payment
|
|
123
|
+
| `store.payments` | Stripe payment intents and hosted Checkout sessions |
|
|
124
124
|
| `store.wishlist` | List, add, remove |
|
|
125
125
|
| `store.reviews` | Product summary, create, edit, delete, admin moderation |
|
|
126
126
|
|
|
@@ -183,8 +183,32 @@ page.meta; // page, limit, offset, total, total_pages, has_next, has_prev
|
|
|
183
183
|
|
|
184
184
|
Categories support `q`, `parent_id`, `root_only`, `has_products`, `sort`,
|
|
185
185
|
`page`, `limit` and `offset` through `categories.list()` or
|
|
186
|
-
`categories.listPage()`. `page` wins over `offset`;
|
|
187
|
-
|
|
186
|
+
`categories.listPage()`. `page` wins over `offset`; storefront and shopper
|
|
187
|
+
lists (products, carts, categories, orders, reviews and wishlists) default to
|
|
188
|
+
12 rows. Every page is capped at 100.
|
|
189
|
+
|
|
190
|
+
The shopper lists expose the same paging envelope:
|
|
191
|
+
|
|
192
|
+
```ts
|
|
193
|
+
const cart = await store.cart.getPage({ page: 1, sort: "newest" });
|
|
194
|
+
cart.data.items; // current page; subtotal still covers the whole cart
|
|
195
|
+
cart.meta; // line-level page counters
|
|
196
|
+
|
|
197
|
+
const orders = await store.orders.listPage({
|
|
198
|
+
status: "paid",
|
|
199
|
+
created_after: "2026-01-01",
|
|
200
|
+
sort: "total_desc",
|
|
201
|
+
});
|
|
202
|
+
const wishlist = await store.wishlist.listPage({ q: "oil", sort: "price_asc" });
|
|
203
|
+
|
|
204
|
+
const reviews = await store.reviews.summary(productId, {
|
|
205
|
+
rating: 5,
|
|
206
|
+
sort: "highest",
|
|
207
|
+
page: 1,
|
|
208
|
+
limit: 12,
|
|
209
|
+
});
|
|
210
|
+
reviews.meta; // filtered review page counters
|
|
211
|
+
```
|
|
188
212
|
|
|
189
213
|
Variant rows include `available` (on-hand minus reservations) and `in_stock`,
|
|
190
214
|
both in the product detail and `/products/:id/variants` responses.
|
|
@@ -210,6 +234,10 @@ const order = await store.orders.checkout();
|
|
|
210
234
|
// Create a Stripe intent and confirm it with Stripe.js
|
|
211
235
|
const payment = await store.payments.createIntent(order.id);
|
|
212
236
|
// stripe.confirmCardPayment(payment.client_secret, { … })
|
|
237
|
+
|
|
238
|
+
// Or send the customer to Stripe's hosted payment page
|
|
239
|
+
const checkout = await store.payments.createCheckoutSession(order.id);
|
|
240
|
+
window.location.assign(checkout.url);
|
|
213
241
|
```
|
|
214
242
|
|
|
215
243
|
### Orders
|
package/dist/index.cjs
CHANGED
|
@@ -444,9 +444,34 @@ var CartResource = class {
|
|
|
444
444
|
this.http = http;
|
|
445
445
|
}
|
|
446
446
|
http;
|
|
447
|
-
/** Active cart, created empty on first use. */
|
|
448
|
-
get() {
|
|
449
|
-
return this.http.request("GET", "/cart"
|
|
447
|
+
/** Active cart, created empty on first use (paging meta is dropped). */
|
|
448
|
+
get(params = {}) {
|
|
449
|
+
return this.http.request("GET", "/cart", {
|
|
450
|
+
query: {
|
|
451
|
+
q: params.q,
|
|
452
|
+
product_id: params.product_id,
|
|
453
|
+
variant_id: params.variant_id,
|
|
454
|
+
sort: params.sort,
|
|
455
|
+
page: params.page,
|
|
456
|
+
limit: params.limit,
|
|
457
|
+
offset: params.offset
|
|
458
|
+
}
|
|
459
|
+
});
|
|
460
|
+
}
|
|
461
|
+
/** Same as `get`, plus the `meta` paging counters. */
|
|
462
|
+
getPage(params = {}) {
|
|
463
|
+
return this.http.request("GET", "/cart", {
|
|
464
|
+
query: {
|
|
465
|
+
q: params.q,
|
|
466
|
+
product_id: params.product_id,
|
|
467
|
+
variant_id: params.variant_id,
|
|
468
|
+
sort: params.sort,
|
|
469
|
+
page: params.page,
|
|
470
|
+
limit: params.limit,
|
|
471
|
+
offset: params.offset
|
|
472
|
+
},
|
|
473
|
+
unwrap: false
|
|
474
|
+
});
|
|
450
475
|
}
|
|
451
476
|
/** Validates against the catalog and snapshots the current price. */
|
|
452
477
|
addItem(input) {
|
|
@@ -645,9 +670,40 @@ var OrdersResource = class {
|
|
|
645
670
|
retry: false
|
|
646
671
|
});
|
|
647
672
|
}
|
|
648
|
-
/** Newest first. */
|
|
649
|
-
list() {
|
|
650
|
-
return this.http.request("GET", "/orders"
|
|
673
|
+
/** Newest first (paging meta is dropped). */
|
|
674
|
+
list(params = {}) {
|
|
675
|
+
return this.http.request("GET", "/orders", {
|
|
676
|
+
query: {
|
|
677
|
+
status: params.status,
|
|
678
|
+
currency: params.currency,
|
|
679
|
+
created_after: params.created_after,
|
|
680
|
+
created_before: params.created_before,
|
|
681
|
+
min_total_cents: params.min_total_cents,
|
|
682
|
+
max_total_cents: params.max_total_cents,
|
|
683
|
+
sort: params.sort,
|
|
684
|
+
page: params.page,
|
|
685
|
+
limit: params.limit,
|
|
686
|
+
offset: params.offset
|
|
687
|
+
}
|
|
688
|
+
});
|
|
689
|
+
}
|
|
690
|
+
/** Same filters as `list`, plus the `meta` paging counters. */
|
|
691
|
+
listPage(params = {}) {
|
|
692
|
+
return this.http.request("GET", "/orders", {
|
|
693
|
+
query: {
|
|
694
|
+
status: params.status,
|
|
695
|
+
currency: params.currency,
|
|
696
|
+
created_after: params.created_after,
|
|
697
|
+
created_before: params.created_before,
|
|
698
|
+
min_total_cents: params.min_total_cents,
|
|
699
|
+
max_total_cents: params.max_total_cents,
|
|
700
|
+
sort: params.sort,
|
|
701
|
+
page: params.page,
|
|
702
|
+
limit: params.limit,
|
|
703
|
+
offset: params.offset
|
|
704
|
+
},
|
|
705
|
+
unwrap: false
|
|
706
|
+
});
|
|
651
707
|
}
|
|
652
708
|
get(id) {
|
|
653
709
|
return this.http.request("GET", `/orders/${segment(id)}`);
|
|
@@ -678,6 +734,13 @@ var PaymentsResource = class {
|
|
|
678
734
|
retry: false
|
|
679
735
|
});
|
|
680
736
|
}
|
|
737
|
+
/** Creates a Stripe-hosted Checkout page and returns its URL. */
|
|
738
|
+
createCheckoutSession(orderId) {
|
|
739
|
+
return this.http.request("POST", "/payments/checkout-sessions", {
|
|
740
|
+
body: { order_id: orderId },
|
|
741
|
+
retry: false
|
|
742
|
+
});
|
|
743
|
+
}
|
|
681
744
|
};
|
|
682
745
|
|
|
683
746
|
// src/resources/products.ts
|
|
@@ -790,12 +853,22 @@ var ReviewsResource = class {
|
|
|
790
853
|
this.http = http;
|
|
791
854
|
}
|
|
792
855
|
http;
|
|
793
|
-
/** Public aggregate plus
|
|
794
|
-
summary(productId) {
|
|
856
|
+
/** Public aggregate plus one filtered review page (`summary.meta`). */
|
|
857
|
+
summary(productId, params = {}) {
|
|
795
858
|
return this.http.request(
|
|
796
859
|
"GET",
|
|
797
860
|
`/products/${segment(productId)}/reviews`,
|
|
798
|
-
{
|
|
861
|
+
{
|
|
862
|
+
query: {
|
|
863
|
+
q: params.q,
|
|
864
|
+
rating: params.rating,
|
|
865
|
+
sort: params.sort,
|
|
866
|
+
page: params.page,
|
|
867
|
+
limit: params.limit,
|
|
868
|
+
offset: params.offset
|
|
869
|
+
},
|
|
870
|
+
skipAuth: true
|
|
871
|
+
}
|
|
799
872
|
);
|
|
800
873
|
}
|
|
801
874
|
/** One review per user per product. */
|
|
@@ -931,9 +1004,32 @@ var WishlistResource = class {
|
|
|
931
1004
|
this.http = http;
|
|
932
1005
|
}
|
|
933
1006
|
http;
|
|
934
|
-
/** Newest first. */
|
|
935
|
-
list() {
|
|
936
|
-
return this.http.request("GET", "/wishlist"
|
|
1007
|
+
/** Newest first (paging meta is dropped). */
|
|
1008
|
+
list(params = {}) {
|
|
1009
|
+
return this.http.request("GET", "/wishlist", {
|
|
1010
|
+
query: {
|
|
1011
|
+
q: params.q,
|
|
1012
|
+
category_id: params.category_id,
|
|
1013
|
+
sort: params.sort,
|
|
1014
|
+
page: params.page,
|
|
1015
|
+
limit: params.limit,
|
|
1016
|
+
offset: params.offset
|
|
1017
|
+
}
|
|
1018
|
+
});
|
|
1019
|
+
}
|
|
1020
|
+
/** Same filters as `list`, plus the `meta` paging counters. */
|
|
1021
|
+
listPage(params = {}) {
|
|
1022
|
+
return this.http.request("GET", "/wishlist", {
|
|
1023
|
+
query: {
|
|
1024
|
+
q: params.q,
|
|
1025
|
+
category_id: params.category_id,
|
|
1026
|
+
sort: params.sort,
|
|
1027
|
+
page: params.page,
|
|
1028
|
+
limit: params.limit,
|
|
1029
|
+
offset: params.offset
|
|
1030
|
+
},
|
|
1031
|
+
unwrap: false
|
|
1032
|
+
});
|
|
937
1033
|
}
|
|
938
1034
|
/** Idempotent: re-hearting succeeds silently. */
|
|
939
1035
|
add(productId) {
|