@spree/sdk 0.8.0 → 0.8.2
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/README.md +29 -28
- package/dist/{index-CM4b4ZtS.d.cts → index-F-7S7yjO.d.cts} +43 -52
- package/dist/{index-CM4b4ZtS.d.ts → index-F-7S7yjO.d.ts} +43 -52
- package/dist/index.cjs +21 -28
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +18 -26
- package/dist/index.d.ts +18 -26
- package/dist/index.js +21 -28
- package/dist/index.js.map +1 -1
- package/dist/types/index.d.cts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/zod/index.cjs +36 -47
- package/dist/zod/index.cjs.map +1 -1
- package/dist/zod/index.d.cts +5 -24
- package/dist/zod/index.d.ts +5 -24
- package/dist/zod/index.js +36 -46
- package/dist/zod/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -150,7 +150,7 @@ const products = await client.products.list({
|
|
|
150
150
|
limit: 25,
|
|
151
151
|
name_cont: 'shirt',
|
|
152
152
|
sort: 'price asc',
|
|
153
|
-
expand: ['variants', 'images', '
|
|
153
|
+
expand: ['variants', 'images', 'categories'],
|
|
154
154
|
});
|
|
155
155
|
|
|
156
156
|
// Get single product by ID or slug
|
|
@@ -158,38 +158,27 @@ const product = await client.products.get('spree-tote', {
|
|
|
158
158
|
expand: ['variants', 'images'],
|
|
159
159
|
});
|
|
160
160
|
|
|
161
|
-
// Get available filters (price range, availability, options,
|
|
161
|
+
// Get available filters (price range, availability, options, categories)
|
|
162
162
|
const filters = await client.products.filters({
|
|
163
|
-
|
|
163
|
+
category_id: 'ctg_abc123', // Optional: scope filters to a category
|
|
164
164
|
});
|
|
165
165
|
```
|
|
166
166
|
|
|
167
|
-
### Categories
|
|
167
|
+
### Categories
|
|
168
168
|
|
|
169
169
|
```typescript
|
|
170
|
-
// List
|
|
171
|
-
const
|
|
172
|
-
expand: ['taxons'],
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
// Get taxonomy with taxons
|
|
176
|
-
const categories = await client.taxonomies.get('tax_123', {
|
|
177
|
-
expand: ['root', 'taxons'],
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
// List taxons with filtering
|
|
181
|
-
const taxons = await client.taxons.list({
|
|
170
|
+
// List categories with filtering
|
|
171
|
+
const categories = await client.categories.list({
|
|
182
172
|
depth_eq: 1, // Top-level categories only
|
|
183
|
-
taxonomy_id_eq: '123', // Filter by taxonomy
|
|
184
173
|
});
|
|
185
174
|
|
|
186
|
-
// Get single
|
|
187
|
-
const
|
|
175
|
+
// Get single category by ID or permalink
|
|
176
|
+
const category = await client.categories.get('clothing/shirts', {
|
|
188
177
|
expand: ['ancestors', 'children'], // For breadcrumbs and subcategories
|
|
189
178
|
});
|
|
190
179
|
|
|
191
180
|
// List products in a category
|
|
192
|
-
const categoryProducts = await client.
|
|
181
|
+
const categoryProducts = await client.categories.products.list('clothing/shirts', {
|
|
193
182
|
page: 1,
|
|
194
183
|
limit: 12,
|
|
195
184
|
expand: ['images', 'default_variant'],
|
|
@@ -318,12 +307,25 @@ const options = { orderToken: cart.token };
|
|
|
318
307
|
|
|
319
308
|
// Get available payment methods for an order
|
|
320
309
|
const methods = await client.orders.paymentMethods.list(cart.id, options);
|
|
310
|
+
// Each method includes `session_required` flag:
|
|
311
|
+
// - true → use paymentSessions (Stripe, Adyen, PayPal, etc.)
|
|
312
|
+
// - false → use payments.create (Check, Cash on Delivery, Bank Transfer, etc.)
|
|
321
313
|
|
|
322
314
|
// List payments on an order
|
|
323
315
|
const payments = await client.orders.payments.list(cart.id, options);
|
|
324
316
|
|
|
325
317
|
// Get a specific payment
|
|
326
318
|
const payment = await client.orders.payments.get(cart.id, paymentId, options);
|
|
319
|
+
|
|
320
|
+
// Create a payment for a non-session payment method
|
|
321
|
+
// (e.g. Check, Cash on Delivery, Bank Transfer, Purchase Order)
|
|
322
|
+
const payment = await client.orders.payments.create(cart.id, {
|
|
323
|
+
payment_method_id: 'pm_xxx',
|
|
324
|
+
amount: '99.99', // Optional, defaults to order total minus store credits
|
|
325
|
+
metadata: { // Optional, write-only metadata
|
|
326
|
+
purchase_order_number: 'PO-12345',
|
|
327
|
+
},
|
|
328
|
+
}, options);
|
|
327
329
|
```
|
|
328
330
|
|
|
329
331
|
### Payment Sessions
|
|
@@ -516,7 +518,7 @@ The SDK uses a resource builder pattern for nested resources:
|
|
|
516
518
|
| Parent Resource | Nested Resource | Available Methods |
|
|
517
519
|
|-----------------|-----------------|-------------------|
|
|
518
520
|
| `orders` | `lineItems` | `create`, `update`, `delete` |
|
|
519
|
-
| `orders` | `payments` | `list`, `get` |
|
|
521
|
+
| `orders` | `payments` | `list`, `get`, `create` |
|
|
520
522
|
| `orders` | `paymentMethods` | `list` |
|
|
521
523
|
| `orders` | `paymentSessions` | `create`, `get`, `update`, `complete` |
|
|
522
524
|
| `orders` | `shipments` | `list`, `update` |
|
|
@@ -525,7 +527,7 @@ The SDK uses a resource builder pattern for nested resources:
|
|
|
525
527
|
| `customer` | `creditCards` | `list`, `get`, `delete` |
|
|
526
528
|
| `customer` | `giftCards` | `list`, `get` |
|
|
527
529
|
| `markets` | `countries` | `list`, `get` |
|
|
528
|
-
| `
|
|
530
|
+
| `categories` | `products` | `list` |
|
|
529
531
|
| `wishlists` | `items` | `create`, `update`, `delete` |
|
|
530
532
|
|
|
531
533
|
Example:
|
|
@@ -536,7 +538,7 @@ await client.orders.payments.list(orderId, options);
|
|
|
536
538
|
await client.orders.shipments.update(orderId, shipmentId, params, options);
|
|
537
539
|
await client.customer.addresses.list({}, options);
|
|
538
540
|
await client.markets.countries.list(marketId);
|
|
539
|
-
await client.
|
|
541
|
+
await client.categories.products.list(categoryId, params, options);
|
|
540
542
|
await client.wishlists.items.create(wishlistId, params, options);
|
|
541
543
|
```
|
|
542
544
|
|
|
@@ -605,8 +607,7 @@ import type {
|
|
|
605
607
|
StoreProduct,
|
|
606
608
|
StoreOrder,
|
|
607
609
|
StoreVariant,
|
|
608
|
-
|
|
609
|
-
StoreTaxonomy,
|
|
610
|
+
StoreCategory,
|
|
610
611
|
StoreLineItem,
|
|
611
612
|
StoreAddress,
|
|
612
613
|
StoreCustomer,
|
|
@@ -615,7 +616,7 @@ import type {
|
|
|
615
616
|
|
|
616
617
|
// All responses are fully typed
|
|
617
618
|
const products: PaginatedResponse<StoreProduct> = await client.products.list();
|
|
618
|
-
const
|
|
619
|
+
const category: StoreCategory = await client.categories.get('clothing');
|
|
619
620
|
```
|
|
620
621
|
|
|
621
622
|
## Available Types
|
|
@@ -627,8 +628,7 @@ The SDK exports all Store API types:
|
|
|
627
628
|
- `StoreVariant` - Variant data
|
|
628
629
|
- `StoreOrder` - Order/cart data
|
|
629
630
|
- `StoreLineItem` - Line item in cart
|
|
630
|
-
- `
|
|
631
|
-
- `StoreTaxon` - Individual category
|
|
631
|
+
- `StoreCategory` - Category
|
|
632
632
|
- `StoreCountry` - Country with states
|
|
633
633
|
- `StoreState` - State/province
|
|
634
634
|
- `StoreAddress` - Customer address
|
|
@@ -668,6 +668,7 @@ The SDK exports all Store API types:
|
|
|
668
668
|
- `PaginatedResponse<T>` - Paginated API response
|
|
669
669
|
- `AuthTokens` - JWT tokens from login
|
|
670
670
|
- `AddressParams` - Address input parameters
|
|
671
|
+
- `CreatePaymentParams` - Direct payment creation parameters (for non-session payment methods)
|
|
671
672
|
- `CreatePaymentSessionParams` - Payment session creation parameters
|
|
672
673
|
- `UpdatePaymentSessionParams` - Payment session update parameters
|
|
673
674
|
- `CompletePaymentSessionParams` - Payment session completion parameters
|
|
@@ -130,6 +130,32 @@ type Base = {
|
|
|
130
130
|
id: string;
|
|
131
131
|
};
|
|
132
132
|
|
|
133
|
+
type Category = {
|
|
134
|
+
id: string;
|
|
135
|
+
name: string;
|
|
136
|
+
permalink: string;
|
|
137
|
+
position: number;
|
|
138
|
+
depth: number;
|
|
139
|
+
meta_title: string | null;
|
|
140
|
+
meta_description: string | null;
|
|
141
|
+
meta_keywords: string | null;
|
|
142
|
+
children_count: number;
|
|
143
|
+
created_at: string;
|
|
144
|
+
updated_at: string;
|
|
145
|
+
parent_id: string | null;
|
|
146
|
+
description: string;
|
|
147
|
+
description_html: string;
|
|
148
|
+
image_url: string | null;
|
|
149
|
+
square_image_url: string | null;
|
|
150
|
+
is_root: boolean;
|
|
151
|
+
is_child: boolean;
|
|
152
|
+
is_leaf: boolean;
|
|
153
|
+
parent?: Category;
|
|
154
|
+
children?: Array<Category>;
|
|
155
|
+
ancestors?: Array<Category>;
|
|
156
|
+
metafields?: Array<Metafield>;
|
|
157
|
+
};
|
|
158
|
+
|
|
133
159
|
type Country = {
|
|
134
160
|
iso: string;
|
|
135
161
|
iso3: string;
|
|
@@ -535,7 +561,7 @@ type Product = {
|
|
|
535
561
|
default_variant?: Variant;
|
|
536
562
|
master_variant?: Variant;
|
|
537
563
|
option_types?: Array<OptionType>;
|
|
538
|
-
|
|
564
|
+
categories?: Array<Category>;
|
|
539
565
|
metafields?: Array<Metafield>;
|
|
540
566
|
};
|
|
541
567
|
|
|
@@ -722,45 +748,6 @@ type TaxCategory = {
|
|
|
722
748
|
name: string;
|
|
723
749
|
};
|
|
724
750
|
|
|
725
|
-
type Taxon = {
|
|
726
|
-
id: string;
|
|
727
|
-
name: string;
|
|
728
|
-
permalink: string;
|
|
729
|
-
position: number;
|
|
730
|
-
depth: number;
|
|
731
|
-
meta_title: string | null;
|
|
732
|
-
meta_description: string | null;
|
|
733
|
-
meta_keywords: string | null;
|
|
734
|
-
children_count: number;
|
|
735
|
-
created_at: string;
|
|
736
|
-
updated_at: string;
|
|
737
|
-
parent_id: string | null;
|
|
738
|
-
taxonomy_id: string;
|
|
739
|
-
description: string;
|
|
740
|
-
description_html: string;
|
|
741
|
-
image_url: string | null;
|
|
742
|
-
square_image_url: string | null;
|
|
743
|
-
is_root: boolean;
|
|
744
|
-
is_child: boolean;
|
|
745
|
-
is_leaf: boolean;
|
|
746
|
-
parent?: Taxon;
|
|
747
|
-
children?: Array<Taxon>;
|
|
748
|
-
ancestors?: Array<Taxon>;
|
|
749
|
-
metafields?: Array<Metafield>;
|
|
750
|
-
};
|
|
751
|
-
|
|
752
|
-
type Taxonomy = {
|
|
753
|
-
id: string;
|
|
754
|
-
name: string;
|
|
755
|
-
position: number;
|
|
756
|
-
created_at: string;
|
|
757
|
-
updated_at: string;
|
|
758
|
-
root_id: string | null;
|
|
759
|
-
root?: Taxon;
|
|
760
|
-
taxons?: Array<Taxon>;
|
|
761
|
-
metafields?: Array<Metafield>;
|
|
762
|
-
};
|
|
763
|
-
|
|
764
751
|
type Variant = {
|
|
765
752
|
id: string;
|
|
766
753
|
product_id: string;
|
|
@@ -848,17 +835,16 @@ interface ProductListParams extends ListParams {
|
|
|
848
835
|
in_stock?: boolean;
|
|
849
836
|
/** Filter: only out-of-stock products */
|
|
850
837
|
out_of_stock?: boolean;
|
|
851
|
-
/** Filter: products in
|
|
852
|
-
|
|
838
|
+
/** Filter: products in category */
|
|
839
|
+
categories_id_eq?: string;
|
|
853
840
|
/** Any additional Ransack predicate */
|
|
854
841
|
[key: string]: string | number | boolean | (string | number)[] | undefined;
|
|
855
842
|
}
|
|
856
|
-
interface
|
|
843
|
+
interface CategoryListParams extends ListParams {
|
|
857
844
|
/** Sort order, e.g. 'name', '-created_at' */
|
|
858
845
|
sort?: string;
|
|
859
846
|
/** Filter: name contains */
|
|
860
847
|
name_cont?: string;
|
|
861
|
-
taxonomy_id_eq?: string | number;
|
|
862
848
|
parent_id_eq?: string | number;
|
|
863
849
|
depth_eq?: number;
|
|
864
850
|
/** Any additional Ransack predicate */
|
|
@@ -918,6 +904,11 @@ interface UpdateOrderParams {
|
|
|
918
904
|
/** Line items to upsert (sets quantity for existing, creates new) */
|
|
919
905
|
line_items?: LineItemInput[];
|
|
920
906
|
}
|
|
907
|
+
interface CreatePaymentParams {
|
|
908
|
+
payment_method_id: string;
|
|
909
|
+
amount?: string;
|
|
910
|
+
metadata?: Record<string, unknown>;
|
|
911
|
+
}
|
|
921
912
|
interface CreatePaymentSessionParams {
|
|
922
913
|
payment_method_id: string;
|
|
923
914
|
amount?: string;
|
|
@@ -947,7 +938,7 @@ interface OptionFilterOption extends FilterOption {
|
|
|
947
938
|
presentation: string;
|
|
948
939
|
position: number;
|
|
949
940
|
}
|
|
950
|
-
interface
|
|
941
|
+
interface CategoryFilterOption {
|
|
951
942
|
id: string;
|
|
952
943
|
name: string;
|
|
953
944
|
permalink: string;
|
|
@@ -972,12 +963,12 @@ interface OptionFilter {
|
|
|
972
963
|
presentation: string;
|
|
973
964
|
options: OptionFilterOption[];
|
|
974
965
|
}
|
|
975
|
-
interface
|
|
976
|
-
id: '
|
|
977
|
-
type: '
|
|
978
|
-
options:
|
|
966
|
+
interface CategoryFilter {
|
|
967
|
+
id: 'categories';
|
|
968
|
+
type: 'category';
|
|
969
|
+
options: CategoryFilterOption[];
|
|
979
970
|
}
|
|
980
|
-
type ProductFilter = PriceRangeFilter | AvailabilityFilter | OptionFilter |
|
|
971
|
+
type ProductFilter = PriceRangeFilter | AvailabilityFilter | OptionFilter | CategoryFilter;
|
|
981
972
|
interface SortOption {
|
|
982
973
|
id: string;
|
|
983
974
|
}
|
|
@@ -988,8 +979,8 @@ interface ProductFiltersResponse {
|
|
|
988
979
|
total_count: number;
|
|
989
980
|
}
|
|
990
981
|
interface ProductFiltersParams {
|
|
991
|
-
|
|
982
|
+
category_id?: string;
|
|
992
983
|
q?: Record<string, unknown>;
|
|
993
984
|
}
|
|
994
985
|
|
|
995
|
-
export { type
|
|
986
|
+
export { type FilterOption as $, type AuthTokens as A, type OrderListParams as B, type CategoryListParams as C, type CreatePaymentSetupSessionParams as D, type PaymentSetupSession as E, type CompletePaymentSetupSessionParams as F, type GiftCard as G, type WishedItem as H, type RetryConfig as I, type Asset as J, type AvailabilityFilter as K, type LoginCredentials as L, type Market as M, type Base as N, type Order as O, type ProductListParams as P, type CategoryFilter as Q, type RequestFn as R, type Shipment as S, type CategoryFilterOption as T, type UpdateOrderParams as U, type CustomerReturn as V, type Wishlist as W, type Digital as X, type DigitalLink as Y, type ErrorResponse as Z, type Export as _, type RequestOptions as a, type GiftCardBatch as a0, type Image as a1, type Import as a2, type ImportRow as a3, type Invitation as a4, type LineItem as a5, type LineItemInput as a6, type LocaleDefaults as a7, type Metafield as a8, type NewsletterSubscriber as a9, type StoreCredit as aA, type TaxCategory as aB, type Variant as aC, type OptionFilter as aa, type OptionFilterOption as ab, type OptionType as ac, type OptionValue as ad, type OrderPromotion as ae, type PaginationMeta as af, type PaymentSource as ag, type Price as ah, type PriceRangeFilter as ai, type ProductFilter as aj, type Promotion as ak, type Refund as al, type Reimbursement as am, type Report as an, type ReturnAuthorization as ao, type ReturnItem as ap, type ShippingCategory as aq, type ShippingMethod as ar, type ShippingRate as as, type SortOption as at, SpreeError as au, type State as av, type StockItem as aw, type StockLocation as ax, type StockMovement as ay, type StockTransfer as az, type PaginatedResponse as b, type Product as c, type ProductFiltersParams as d, type ProductFiltersResponse as e, type Category as f, type ListResponse as g, type Country as h, type Currency as i, type Locale as j, type CreateCartParams as k, type AddLineItemParams as l, type UpdateLineItemParams as m, type Payment as n, type CreatePaymentParams as o, type PaymentMethod as p, type CreatePaymentSessionParams as q, type PaymentSession as r, type UpdatePaymentSessionParams as s, type CompletePaymentSessionParams as t, type RegisterParams as u, type Customer as v, type ListParams as w, type Address as x, type AddressParams as y, type CreditCard as z };
|
|
@@ -130,6 +130,32 @@ type Base = {
|
|
|
130
130
|
id: string;
|
|
131
131
|
};
|
|
132
132
|
|
|
133
|
+
type Category = {
|
|
134
|
+
id: string;
|
|
135
|
+
name: string;
|
|
136
|
+
permalink: string;
|
|
137
|
+
position: number;
|
|
138
|
+
depth: number;
|
|
139
|
+
meta_title: string | null;
|
|
140
|
+
meta_description: string | null;
|
|
141
|
+
meta_keywords: string | null;
|
|
142
|
+
children_count: number;
|
|
143
|
+
created_at: string;
|
|
144
|
+
updated_at: string;
|
|
145
|
+
parent_id: string | null;
|
|
146
|
+
description: string;
|
|
147
|
+
description_html: string;
|
|
148
|
+
image_url: string | null;
|
|
149
|
+
square_image_url: string | null;
|
|
150
|
+
is_root: boolean;
|
|
151
|
+
is_child: boolean;
|
|
152
|
+
is_leaf: boolean;
|
|
153
|
+
parent?: Category;
|
|
154
|
+
children?: Array<Category>;
|
|
155
|
+
ancestors?: Array<Category>;
|
|
156
|
+
metafields?: Array<Metafield>;
|
|
157
|
+
};
|
|
158
|
+
|
|
133
159
|
type Country = {
|
|
134
160
|
iso: string;
|
|
135
161
|
iso3: string;
|
|
@@ -535,7 +561,7 @@ type Product = {
|
|
|
535
561
|
default_variant?: Variant;
|
|
536
562
|
master_variant?: Variant;
|
|
537
563
|
option_types?: Array<OptionType>;
|
|
538
|
-
|
|
564
|
+
categories?: Array<Category>;
|
|
539
565
|
metafields?: Array<Metafield>;
|
|
540
566
|
};
|
|
541
567
|
|
|
@@ -722,45 +748,6 @@ type TaxCategory = {
|
|
|
722
748
|
name: string;
|
|
723
749
|
};
|
|
724
750
|
|
|
725
|
-
type Taxon = {
|
|
726
|
-
id: string;
|
|
727
|
-
name: string;
|
|
728
|
-
permalink: string;
|
|
729
|
-
position: number;
|
|
730
|
-
depth: number;
|
|
731
|
-
meta_title: string | null;
|
|
732
|
-
meta_description: string | null;
|
|
733
|
-
meta_keywords: string | null;
|
|
734
|
-
children_count: number;
|
|
735
|
-
created_at: string;
|
|
736
|
-
updated_at: string;
|
|
737
|
-
parent_id: string | null;
|
|
738
|
-
taxonomy_id: string;
|
|
739
|
-
description: string;
|
|
740
|
-
description_html: string;
|
|
741
|
-
image_url: string | null;
|
|
742
|
-
square_image_url: string | null;
|
|
743
|
-
is_root: boolean;
|
|
744
|
-
is_child: boolean;
|
|
745
|
-
is_leaf: boolean;
|
|
746
|
-
parent?: Taxon;
|
|
747
|
-
children?: Array<Taxon>;
|
|
748
|
-
ancestors?: Array<Taxon>;
|
|
749
|
-
metafields?: Array<Metafield>;
|
|
750
|
-
};
|
|
751
|
-
|
|
752
|
-
type Taxonomy = {
|
|
753
|
-
id: string;
|
|
754
|
-
name: string;
|
|
755
|
-
position: number;
|
|
756
|
-
created_at: string;
|
|
757
|
-
updated_at: string;
|
|
758
|
-
root_id: string | null;
|
|
759
|
-
root?: Taxon;
|
|
760
|
-
taxons?: Array<Taxon>;
|
|
761
|
-
metafields?: Array<Metafield>;
|
|
762
|
-
};
|
|
763
|
-
|
|
764
751
|
type Variant = {
|
|
765
752
|
id: string;
|
|
766
753
|
product_id: string;
|
|
@@ -848,17 +835,16 @@ interface ProductListParams extends ListParams {
|
|
|
848
835
|
in_stock?: boolean;
|
|
849
836
|
/** Filter: only out-of-stock products */
|
|
850
837
|
out_of_stock?: boolean;
|
|
851
|
-
/** Filter: products in
|
|
852
|
-
|
|
838
|
+
/** Filter: products in category */
|
|
839
|
+
categories_id_eq?: string;
|
|
853
840
|
/** Any additional Ransack predicate */
|
|
854
841
|
[key: string]: string | number | boolean | (string | number)[] | undefined;
|
|
855
842
|
}
|
|
856
|
-
interface
|
|
843
|
+
interface CategoryListParams extends ListParams {
|
|
857
844
|
/** Sort order, e.g. 'name', '-created_at' */
|
|
858
845
|
sort?: string;
|
|
859
846
|
/** Filter: name contains */
|
|
860
847
|
name_cont?: string;
|
|
861
|
-
taxonomy_id_eq?: string | number;
|
|
862
848
|
parent_id_eq?: string | number;
|
|
863
849
|
depth_eq?: number;
|
|
864
850
|
/** Any additional Ransack predicate */
|
|
@@ -918,6 +904,11 @@ interface UpdateOrderParams {
|
|
|
918
904
|
/** Line items to upsert (sets quantity for existing, creates new) */
|
|
919
905
|
line_items?: LineItemInput[];
|
|
920
906
|
}
|
|
907
|
+
interface CreatePaymentParams {
|
|
908
|
+
payment_method_id: string;
|
|
909
|
+
amount?: string;
|
|
910
|
+
metadata?: Record<string, unknown>;
|
|
911
|
+
}
|
|
921
912
|
interface CreatePaymentSessionParams {
|
|
922
913
|
payment_method_id: string;
|
|
923
914
|
amount?: string;
|
|
@@ -947,7 +938,7 @@ interface OptionFilterOption extends FilterOption {
|
|
|
947
938
|
presentation: string;
|
|
948
939
|
position: number;
|
|
949
940
|
}
|
|
950
|
-
interface
|
|
941
|
+
interface CategoryFilterOption {
|
|
951
942
|
id: string;
|
|
952
943
|
name: string;
|
|
953
944
|
permalink: string;
|
|
@@ -972,12 +963,12 @@ interface OptionFilter {
|
|
|
972
963
|
presentation: string;
|
|
973
964
|
options: OptionFilterOption[];
|
|
974
965
|
}
|
|
975
|
-
interface
|
|
976
|
-
id: '
|
|
977
|
-
type: '
|
|
978
|
-
options:
|
|
966
|
+
interface CategoryFilter {
|
|
967
|
+
id: 'categories';
|
|
968
|
+
type: 'category';
|
|
969
|
+
options: CategoryFilterOption[];
|
|
979
970
|
}
|
|
980
|
-
type ProductFilter = PriceRangeFilter | AvailabilityFilter | OptionFilter |
|
|
971
|
+
type ProductFilter = PriceRangeFilter | AvailabilityFilter | OptionFilter | CategoryFilter;
|
|
981
972
|
interface SortOption {
|
|
982
973
|
id: string;
|
|
983
974
|
}
|
|
@@ -988,8 +979,8 @@ interface ProductFiltersResponse {
|
|
|
988
979
|
total_count: number;
|
|
989
980
|
}
|
|
990
981
|
interface ProductFiltersParams {
|
|
991
|
-
|
|
982
|
+
category_id?: string;
|
|
992
983
|
q?: Record<string, unknown>;
|
|
993
984
|
}
|
|
994
985
|
|
|
995
|
-
export { type
|
|
986
|
+
export { type FilterOption as $, type AuthTokens as A, type OrderListParams as B, type CategoryListParams as C, type CreatePaymentSetupSessionParams as D, type PaymentSetupSession as E, type CompletePaymentSetupSessionParams as F, type GiftCard as G, type WishedItem as H, type RetryConfig as I, type Asset as J, type AvailabilityFilter as K, type LoginCredentials as L, type Market as M, type Base as N, type Order as O, type ProductListParams as P, type CategoryFilter as Q, type RequestFn as R, type Shipment as S, type CategoryFilterOption as T, type UpdateOrderParams as U, type CustomerReturn as V, type Wishlist as W, type Digital as X, type DigitalLink as Y, type ErrorResponse as Z, type Export as _, type RequestOptions as a, type GiftCardBatch as a0, type Image as a1, type Import as a2, type ImportRow as a3, type Invitation as a4, type LineItem as a5, type LineItemInput as a6, type LocaleDefaults as a7, type Metafield as a8, type NewsletterSubscriber as a9, type StoreCredit as aA, type TaxCategory as aB, type Variant as aC, type OptionFilter as aa, type OptionFilterOption as ab, type OptionType as ac, type OptionValue as ad, type OrderPromotion as ae, type PaginationMeta as af, type PaymentSource as ag, type Price as ah, type PriceRangeFilter as ai, type ProductFilter as aj, type Promotion as ak, type Refund as al, type Reimbursement as am, type Report as an, type ReturnAuthorization as ao, type ReturnItem as ap, type ShippingCategory as aq, type ShippingMethod as ar, type ShippingRate as as, type SortOption as at, SpreeError as au, type State as av, type StockItem as aw, type StockLocation as ax, type StockMovement as ay, type StockTransfer as az, type PaginatedResponse as b, type Product as c, type ProductFiltersParams as d, type ProductFiltersResponse as e, type Category as f, type ListResponse as g, type Country as h, type Currency as i, type Locale as j, type CreateCartParams as k, type AddLineItemParams as l, type UpdateLineItemParams as m, type Payment as n, type CreatePaymentParams as o, type PaymentMethod as p, type CreatePaymentSessionParams as q, type PaymentSession as r, type UpdatePaymentSessionParams as s, type CompletePaymentSessionParams as t, type RegisterParams as u, type Customer as v, type ListParams as w, type Address as x, type AddressParams as y, type CreditCard as z };
|
package/dist/index.cjs
CHANGED
|
@@ -199,7 +199,7 @@ var StoreClient = class {
|
|
|
199
199
|
}),
|
|
200
200
|
/**
|
|
201
201
|
* Get available filters for products
|
|
202
|
-
* Returns filter options (price range, availability, option types,
|
|
202
|
+
* Returns filter options (price range, availability, option types, categories) with counts
|
|
203
203
|
*/
|
|
204
204
|
filters: (params, options) => this.request("GET", "/products/filters", {
|
|
205
205
|
...options,
|
|
@@ -207,50 +207,34 @@ var StoreClient = class {
|
|
|
207
207
|
})
|
|
208
208
|
};
|
|
209
209
|
// ============================================
|
|
210
|
-
//
|
|
210
|
+
// Categories
|
|
211
211
|
// ============================================
|
|
212
|
-
|
|
212
|
+
categories = {
|
|
213
213
|
/**
|
|
214
|
-
* List
|
|
214
|
+
* List categories
|
|
215
215
|
*/
|
|
216
|
-
list: (params, options) => this.request("GET", "/
|
|
216
|
+
list: (params, options) => this.request("GET", "/categories", {
|
|
217
217
|
...options,
|
|
218
218
|
params: transformListParams({ ...params })
|
|
219
219
|
}),
|
|
220
220
|
/**
|
|
221
|
-
* Get a
|
|
221
|
+
* Get a category by ID or permalink
|
|
222
222
|
*/
|
|
223
|
-
get: (
|
|
224
|
-
...options,
|
|
225
|
-
params: getParams(params)
|
|
226
|
-
})
|
|
227
|
-
};
|
|
228
|
-
taxons = {
|
|
229
|
-
/**
|
|
230
|
-
* List taxons
|
|
231
|
-
*/
|
|
232
|
-
list: (params, options) => this.request("GET", "/taxons", {
|
|
233
|
-
...options,
|
|
234
|
-
params: transformListParams({ ...params })
|
|
235
|
-
}),
|
|
236
|
-
/**
|
|
237
|
-
* Get a taxon by ID or permalink
|
|
238
|
-
*/
|
|
239
|
-
get: (idOrPermalink, params, options) => this.request("GET", `/taxons/${idOrPermalink}`, {
|
|
223
|
+
get: (idOrPermalink, params, options) => this.request("GET", `/categories/${idOrPermalink}`, {
|
|
240
224
|
...options,
|
|
241
225
|
params: getParams(params)
|
|
242
226
|
}),
|
|
243
227
|
/**
|
|
244
|
-
* Nested resource: Products in a
|
|
228
|
+
* Nested resource: Products in a category
|
|
245
229
|
*/
|
|
246
230
|
products: {
|
|
247
231
|
/**
|
|
248
|
-
* List products in a
|
|
249
|
-
* @param
|
|
232
|
+
* List products in a category
|
|
233
|
+
* @param categoryId - Category ID (prefix_id) or permalink
|
|
250
234
|
*/
|
|
251
|
-
list: (
|
|
235
|
+
list: (categoryId, params, options) => this.request(
|
|
252
236
|
"GET",
|
|
253
|
-
`/
|
|
237
|
+
`/categories/${categoryId}/products`,
|
|
254
238
|
{
|
|
255
239
|
...options,
|
|
256
240
|
params: transformListParams({ ...params })
|
|
@@ -462,6 +446,15 @@ var StoreClient = class {
|
|
|
462
446
|
"GET",
|
|
463
447
|
`/orders/${orderId}/payments/${paymentId}`,
|
|
464
448
|
options
|
|
449
|
+
),
|
|
450
|
+
/**
|
|
451
|
+
* Create a payment for a non-session payment method (e.g. Check, Cash on Delivery, Bank Transfer)
|
|
452
|
+
* For session-based payment methods (e.g. Stripe, PayPal), use paymentSessions.create() instead
|
|
453
|
+
*/
|
|
454
|
+
create: (orderId, params, options) => this.request(
|
|
455
|
+
"POST",
|
|
456
|
+
`/orders/${orderId}/payments`,
|
|
457
|
+
{ ...options, body: params }
|
|
465
458
|
)
|
|
466
459
|
},
|
|
467
460
|
/**
|