@alphabite/medusa-sdk 0.3.1 → 0.3.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/README.md +233 -0
- package/dist/index.d.mts +40 -31
- package/dist/index.d.ts +40 -31
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
# ⚙️ Alphabite Medusa Client
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@alphabite/medusa-client)
|
|
4
|
+
[](https://www.npmjs.com/package/@alphabite/medusa-client)
|
|
5
|
+

|
|
6
|
+

|
|
7
|
+
|
|
8
|
+
> Drop-in replacement for `@medusajs/js-sdk` with plugin support for Wishlists, PayPal, Reviews, and more.
|
|
9
|
+
|
|
10
|
+
The **Alphabite Medusa Client** wraps the Medusa JS SDK and adds support for rich frontend integrations via plugin architecture.
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## 📚 Table of Contents
|
|
15
|
+
|
|
16
|
+
- [📦 Installation](#-installation)
|
|
17
|
+
- [🚀 Usage](#-usage)
|
|
18
|
+
- [🔁 Drop-in Replacement](#-drop-in-replacement)
|
|
19
|
+
- [🔌 Plugin Injection](#-plugin-injection)
|
|
20
|
+
- [🔐 Auth Handling](#-auth-handling)
|
|
21
|
+
- [✅ Example: Wishlist Usage](#-example-wishlist-usage)
|
|
22
|
+
- [🧩 Plugins Included](#-plugins-included)
|
|
23
|
+
- [🧪 TypeScript Support](#-typescript-support)
|
|
24
|
+
- [📁 Folder Structure Tip](#-folder-structure-tip)
|
|
25
|
+
- [🤝 Contributing](#-contributing)
|
|
26
|
+
- [📝 License](#-license)
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## 📦 Installation
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
npm install @alphabite/medusa-client
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## 🚀 Usage
|
|
39
|
+
|
|
40
|
+
```ts
|
|
41
|
+
import {
|
|
42
|
+
AlphabiteMedusaClient,
|
|
43
|
+
wishlistPlugin,
|
|
44
|
+
paypalPlugin,
|
|
45
|
+
reviewsPlugin,
|
|
46
|
+
} from '@alphabite/medusa-client'
|
|
47
|
+
|
|
48
|
+
const sdk = new AlphabiteMedusaClient(
|
|
49
|
+
{
|
|
50
|
+
baseUrl: process.env.NEXT_PUBLIC_API_URL || 'http://localhost:8000/api',
|
|
51
|
+
debug: process.env.NODE_ENV === 'development',
|
|
52
|
+
publishableKey: process.env.NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY,
|
|
53
|
+
},
|
|
54
|
+
[wishlistPlugin, paypalPlugin, reviewsPlugin],
|
|
55
|
+
|
|
56
|
+
// Optional options config to add a global getAuthHeader function for all endpoints
|
|
57
|
+
{
|
|
58
|
+
// supports async functions, for example a server action that fetches the token from headers
|
|
59
|
+
getAuthHeader: async () => {
|
|
60
|
+
const token = await getToken(); // your own function that returns the auth token
|
|
61
|
+
|
|
62
|
+
return {
|
|
63
|
+
authorization: `Bearer ${token}`,
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
}
|
|
67
|
+
)
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## 🔁 Drop-in Replacement
|
|
73
|
+
|
|
74
|
+
To migrate from the default Medusa SDK:
|
|
75
|
+
|
|
76
|
+
```ts
|
|
77
|
+
// BEFORE
|
|
78
|
+
import Medusa from '@medusajs/js-sdk'
|
|
79
|
+
const sdk = new Medusa({
|
|
80
|
+
baseUrl: process.env.NEXT_PUBLIC_API_URL || 'http://localhost:8000/api',
|
|
81
|
+
debug: process.env.NODE_ENV === 'development',
|
|
82
|
+
publishableKey: process.env.NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY,
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
// AFTER
|
|
86
|
+
import { AlphabiteMedusaClient, wishlistPlugin } from '@alphabite/medusa-client'
|
|
87
|
+
|
|
88
|
+
const sdk = new AlphabiteMedusaClient({
|
|
89
|
+
baseUrl: process.env.NEXT_PUBLIC_API_URL || 'http://localhost:8000/api',
|
|
90
|
+
debug: process.env.NODE_ENV === 'development',
|
|
91
|
+
publishableKey: process.env.NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY,
|
|
92
|
+
},
|
|
93
|
+
[wishlistPlugin], {
|
|
94
|
+
// supports async functions, for example a server action that fetches the token from headers
|
|
95
|
+
getAuthHeader: async () => {
|
|
96
|
+
const token = await getToken(); // your own function that returns the auth token
|
|
97
|
+
|
|
98
|
+
return {
|
|
99
|
+
authorization: `Bearer ${token}`,
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
}
|
|
103
|
+
)
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
---
|
|
107
|
+
|
|
108
|
+
## 🔌 Plugin Injection
|
|
109
|
+
|
|
110
|
+
Pass an array of plugins as the second argument:
|
|
111
|
+
|
|
112
|
+
```ts
|
|
113
|
+
[wishlistPlugin]
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Each plugin registers a namespace like:
|
|
117
|
+
|
|
118
|
+
```ts
|
|
119
|
+
sdk.alphabite.wishlist
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
---
|
|
123
|
+
|
|
124
|
+
## 🔐 Auth Handling
|
|
125
|
+
|
|
126
|
+
### 1. Global headers with `getAuthHeader`
|
|
127
|
+
|
|
128
|
+
```ts
|
|
129
|
+
const sdk = new AlphabiteMedusaClient(
|
|
130
|
+
{ baseUrl },
|
|
131
|
+
[wishlistPlugin],
|
|
132
|
+
{
|
|
133
|
+
// supports async function, for example a server action that fetches the token from headers
|
|
134
|
+
getAuthHeader: async () => {
|
|
135
|
+
const token = await getToken(); // your own function that returns the auth token
|
|
136
|
+
|
|
137
|
+
return {
|
|
138
|
+
authorization: `Bearer ${token}`,
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
}
|
|
142
|
+
)
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### 2. Per-request headers
|
|
146
|
+
|
|
147
|
+
```ts
|
|
148
|
+
await sdk.alphabite.wishlist.create({ name: 'Favorites' }, {
|
|
149
|
+
'x-request-id': 'abc',
|
|
150
|
+
})
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
## ✅ Example: Wishlist Usage
|
|
156
|
+
|
|
157
|
+
```ts
|
|
158
|
+
await sdk.alphabite.wishlist.create({ name: 'My Sneakers' })
|
|
159
|
+
|
|
160
|
+
await sdk.alphabite.wishlist.addItem({
|
|
161
|
+
id: 'wishlist_id',
|
|
162
|
+
product_id: 'variant_id',
|
|
163
|
+
})
|
|
164
|
+
|
|
165
|
+
const { data: items } = await sdk.alphabite.wishlist.listItems({
|
|
166
|
+
id: 'wishlist_id',
|
|
167
|
+
})
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
---
|
|
171
|
+
|
|
172
|
+
## 🧩 Plugins Included
|
|
173
|
+
|
|
174
|
+
| Plugin | Namespace | Description |
|
|
175
|
+
|---------------|-------------------|-------------------------------------|
|
|
176
|
+
| `wishlist` | `sdk.alphabite.wishlist` | Multi-wishlist system |
|
|
177
|
+
|
|
178
|
+
---
|
|
179
|
+
|
|
180
|
+
## 🧪 TypeScript Support
|
|
181
|
+
|
|
182
|
+
Includes full types for every plugin endpoint:
|
|
183
|
+
- `Wishlist`, `WishlistItem`, `AddItemToWishlistInput`, etc.
|
|
184
|
+
- Fully typed SDK, request bodies, and responses
|
|
185
|
+
|
|
186
|
+
---
|
|
187
|
+
|
|
188
|
+
## 📁 Folder Structure Tip
|
|
189
|
+
|
|
190
|
+
Create a central instance:
|
|
191
|
+
|
|
192
|
+
```ts
|
|
193
|
+
// lib/sdk.ts
|
|
194
|
+
import {
|
|
195
|
+
AlphabiteMedusaClient,
|
|
196
|
+
wishlistPlugin,
|
|
197
|
+
} from '@alphabite/medusa-client'
|
|
198
|
+
|
|
199
|
+
export const sdk = new AlphabiteMedusaClient(
|
|
200
|
+
{ baseUrl: process.env.NEXT_PUBLIC_API_URL! },
|
|
201
|
+
[wishlistPlugin],
|
|
202
|
+
{
|
|
203
|
+
// supports async function, for example a server action that fetches the token from headers
|
|
204
|
+
getAuthHeader: async () => {
|
|
205
|
+
const token = await getToken(); // your own function that returns the auth token
|
|
206
|
+
|
|
207
|
+
return {
|
|
208
|
+
authorization: `Bearer ${token}`,
|
|
209
|
+
}
|
|
210
|
+
},
|
|
211
|
+
}
|
|
212
|
+
)
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
Use across your app:
|
|
216
|
+
|
|
217
|
+
```ts
|
|
218
|
+
import { sdk } from '@/lib/sdk'
|
|
219
|
+
|
|
220
|
+
await sdk.alphabite.wishlist.list({ limit: 10 })
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
---
|
|
224
|
+
|
|
225
|
+
## 🤝 Contributing
|
|
226
|
+
|
|
227
|
+
Want to build plugins or extend core support? PRs are welcome!
|
|
228
|
+
|
|
229
|
+
---
|
|
230
|
+
|
|
231
|
+
## 📝 License
|
|
232
|
+
|
|
233
|
+
MIT © Alphabite — extend and use freely.
|
package/dist/index.d.mts
CHANGED
|
@@ -42,12 +42,6 @@ interface CreateWishlistInput {
|
|
|
42
42
|
}
|
|
43
43
|
interface CreateWishlistOutput extends Wishlist {
|
|
44
44
|
}
|
|
45
|
-
interface AddItemToWishlistInput {
|
|
46
|
-
product_variant_id: string;
|
|
47
|
-
id: string;
|
|
48
|
-
}
|
|
49
|
-
interface AddItemToWishlistOutput extends WishlistItem {
|
|
50
|
-
}
|
|
51
45
|
interface ListWishlistsInput extends PaginatedInput {
|
|
52
46
|
items_fields?: string[];
|
|
53
47
|
}
|
|
@@ -59,10 +53,17 @@ interface RetrieveWishlistInput {
|
|
|
59
53
|
}
|
|
60
54
|
interface RetrieveWishlistOutput extends Wishlist {
|
|
61
55
|
}
|
|
62
|
-
interface
|
|
56
|
+
interface UpdateWishlistInput {
|
|
63
57
|
id: string;
|
|
58
|
+
name?: string;
|
|
64
59
|
}
|
|
65
|
-
interface
|
|
60
|
+
interface UpdateWishlistOutput extends Omit<Wishlist, 'items'> {
|
|
61
|
+
}
|
|
62
|
+
interface DeleteWishlistInput {
|
|
63
|
+
id: string;
|
|
64
|
+
}
|
|
65
|
+
interface DeleteWishlistOutput {
|
|
66
|
+
id: string;
|
|
66
67
|
}
|
|
67
68
|
interface TotalItemsCountInput {
|
|
68
69
|
wishlist_id?: string;
|
|
@@ -76,36 +77,48 @@ interface TransferWishlistInput {
|
|
|
76
77
|
interface TransferWishlistOutput {
|
|
77
78
|
id: string;
|
|
78
79
|
}
|
|
79
|
-
interface
|
|
80
|
+
interface ShareWishlistInput {
|
|
80
81
|
id: string;
|
|
81
|
-
name?: string;
|
|
82
82
|
}
|
|
83
|
-
interface
|
|
83
|
+
interface ShareWishlistOutput {
|
|
84
|
+
share_token: string;
|
|
84
85
|
}
|
|
85
|
-
interface
|
|
86
|
-
|
|
86
|
+
interface ImportWishlistInput {
|
|
87
|
+
share_token: string;
|
|
88
|
+
}
|
|
89
|
+
interface ImportWishlistOutput extends Wishlist {
|
|
90
|
+
}
|
|
91
|
+
interface AddItemToWishlistInput {
|
|
92
|
+
product_variant_id: string;
|
|
87
93
|
id: string;
|
|
88
94
|
}
|
|
89
|
-
interface
|
|
95
|
+
interface AddItemToWishlistOutput extends WishlistItem {
|
|
96
|
+
}
|
|
97
|
+
interface ListItemsInput extends PaginatedInput {
|
|
90
98
|
id: string;
|
|
91
99
|
}
|
|
92
|
-
interface
|
|
100
|
+
interface ListItemsOutput extends PaginatedOutput<WishlistItem> {
|
|
101
|
+
}
|
|
102
|
+
interface RemoveItemFromWishlistInput {
|
|
103
|
+
wishlist_item_id: string;
|
|
93
104
|
id: string;
|
|
94
105
|
}
|
|
95
|
-
interface
|
|
106
|
+
interface RemoveItemFromWishlistOutput {
|
|
96
107
|
id: string;
|
|
97
108
|
}
|
|
98
109
|
type WishlistEndpoints = {
|
|
99
110
|
create: (input: CreateWishlistInput, headers?: ClientHeaders) => Promise<CreateWishlistOutput>;
|
|
100
|
-
addItem: (input: AddItemToWishlistInput, headers?: ClientHeaders) => Promise<AddItemToWishlistOutput>;
|
|
101
111
|
list: (input: ListWishlistsInput, headers?: ClientHeaders) => Promise<ListWishlistsOutput>;
|
|
102
|
-
listItems: (input: ListItemsInput, headers?: ClientHeaders) => Promise<ListItemsOutput>;
|
|
103
112
|
retrieve: (input: RetrieveWishlistInput, headers?: ClientHeaders) => Promise<RetrieveWishlistOutput>;
|
|
104
|
-
transfer: (input: TransferWishlistInput, headers?: ClientHeaders) => Promise<TransferWishlistOutput>;
|
|
105
113
|
update: (input: UpdateWishlistInput, headers?: ClientHeaders) => Promise<UpdateWishlistOutput>;
|
|
106
114
|
delete: (input: DeleteWishlistInput, headers?: ClientHeaders) => Promise<DeleteWishlistOutput>;
|
|
107
|
-
|
|
115
|
+
transfer: (input: TransferWishlistInput, headers?: ClientHeaders) => Promise<TransferWishlistOutput>;
|
|
116
|
+
share: (input: ShareWishlistInput, headers?: ClientHeaders) => Promise<ShareWishlistOutput>;
|
|
117
|
+
import: (input: ImportWishlistInput, headers?: ClientHeaders) => Promise<ImportWishlistOutput>;
|
|
108
118
|
totalItemsCount: (input: TotalItemsCountInput, headers?: ClientHeaders) => Promise<TotalItemsCountOutput>;
|
|
119
|
+
addItem: (input: AddItemToWishlistInput, headers?: ClientHeaders) => Promise<AddItemToWishlistOutput>;
|
|
120
|
+
listItems: (input: ListItemsInput, headers?: ClientHeaders) => Promise<ListItemsOutput>;
|
|
121
|
+
removeItem: (input: RemoveItemFromWishlistInput, headers?: ClientHeaders) => Promise<RemoveItemFromWishlistOutput>;
|
|
109
122
|
};
|
|
110
123
|
declare const wishlistPlugin: Plugin<'wishlist', WishlistEndpoints>;
|
|
111
124
|
|
|
@@ -123,7 +136,7 @@ interface AggregateCounts {
|
|
|
123
136
|
rating: number;
|
|
124
137
|
count: number;
|
|
125
138
|
}[];
|
|
126
|
-
product_id
|
|
139
|
+
product_id?: string;
|
|
127
140
|
total_count: number;
|
|
128
141
|
}
|
|
129
142
|
interface Review {
|
|
@@ -142,7 +155,7 @@ interface CreateReviewInput {
|
|
|
142
155
|
content: string;
|
|
143
156
|
rating: number;
|
|
144
157
|
product_id: string;
|
|
145
|
-
|
|
158
|
+
image_urls: string[];
|
|
146
159
|
title?: string;
|
|
147
160
|
}
|
|
148
161
|
interface CreateReviewOutput extends Review {
|
|
@@ -153,19 +166,15 @@ interface ListReviewsInput extends PaginatedInput {
|
|
|
153
166
|
verified_purchase_only?: boolean;
|
|
154
167
|
rating?: number;
|
|
155
168
|
include_product?: boolean;
|
|
169
|
+
sort_by?: 'created_at' | 'rating';
|
|
170
|
+
order?: 'asc' | 'desc';
|
|
156
171
|
}
|
|
157
172
|
interface ListReviewsOutput extends PaginatedOutput<Review> {
|
|
158
173
|
}
|
|
159
|
-
interface ListProductReviewsInput extends
|
|
174
|
+
interface ListProductReviewsInput extends Omit<ListReviewsInput, 'product_ids'> {
|
|
160
175
|
product_id: string;
|
|
161
|
-
my_reviews_only?: boolean;
|
|
162
|
-
verified_purchase_only?: boolean;
|
|
163
|
-
sort?: 'created_at' | 'rating';
|
|
164
|
-
order?: 'asc' | 'desc';
|
|
165
|
-
rating?: number;
|
|
166
|
-
include_product?: boolean;
|
|
167
176
|
}
|
|
168
|
-
interface ListProductReviewsOutput extends PaginatedOutput<Review
|
|
177
|
+
interface ListProductReviewsOutput extends PaginatedOutput<Omit<Review, 'product'>>, AggregateCounts {
|
|
169
178
|
}
|
|
170
179
|
interface DeleteReviewInput {
|
|
171
180
|
id: string;
|
|
@@ -204,4 +213,4 @@ declare class AlphabiteMedusaSdk<TPlugins extends readonly Plugin<any, any>[], T
|
|
|
204
213
|
constructor(medusaOptions: ConstructorParameters<typeof Medusa>[0], plugins: TPlugins, options?: TOptions);
|
|
205
214
|
}
|
|
206
215
|
|
|
207
|
-
export { type AddItemToWishlistInput, type AddItemToWishlistOutput, type AggregateCounts, type AggregateCountsInput, type AggregateCountsOutput, type AlphabiteClientOptions, AlphabiteMedusaSdk, type CreateClientTokenOutput, type CreateReviewInput, type CreateReviewOutput, type CreateWishlistInput, type CreateWishlistOutput, type DeleteReviewInput, type DeleteReviewOutput, type DeleteWishlistInput, type DeleteWishlistOutput, type ListItemsInput, type ListItemsOutput, type ListProductReviewsInput, type ListProductReviewsOutput, type ListReviewsInput, type ListReviewsOutput, type ListWishlistsInput, type ListWishlistsOutput, type Plugin, type PluginsToAlphabite, type RemoveItemFromWishlistInput, type RemoveItemFromWishlistOutput, type RetrieveWishlistInput, type RetrieveWishlistOutput, type Review, type TotalItemsCountInput, type TotalItemsCountOutput, type TransferWishlistInput, type TransferWishlistOutput, type UpdateWishlistInput, type UpdateWishlistOutput, type Wishlist, type WishlistItem, paypalPlugin, reviewsPlugin, wishlistPlugin };
|
|
216
|
+
export { type AddItemToWishlistInput, type AddItemToWishlistOutput, type AggregateCounts, type AggregateCountsInput, type AggregateCountsOutput, type AlphabiteClientOptions, AlphabiteMedusaSdk, type CreateClientTokenOutput, type CreateReviewInput, type CreateReviewOutput, type CreateWishlistInput, type CreateWishlistOutput, type DeleteReviewInput, type DeleteReviewOutput, type DeleteWishlistInput, type DeleteWishlistOutput, type ImportWishlistInput, type ImportWishlistOutput, type ListItemsInput, type ListItemsOutput, type ListProductReviewsInput, type ListProductReviewsOutput, type ListReviewsInput, type ListReviewsOutput, type ListWishlistsInput, type ListWishlistsOutput, type Plugin, type PluginsToAlphabite, type RemoveItemFromWishlistInput, type RemoveItemFromWishlistOutput, type RetrieveWishlistInput, type RetrieveWishlistOutput, type Review, type ShareWishlistInput, type ShareWishlistOutput, type TotalItemsCountInput, type TotalItemsCountOutput, type TransferWishlistInput, type TransferWishlistOutput, type UpdateWishlistInput, type UpdateWishlistOutput, type Wishlist, type WishlistItem, paypalPlugin, reviewsPlugin, wishlistPlugin };
|
package/dist/index.d.ts
CHANGED
|
@@ -42,12 +42,6 @@ interface CreateWishlistInput {
|
|
|
42
42
|
}
|
|
43
43
|
interface CreateWishlistOutput extends Wishlist {
|
|
44
44
|
}
|
|
45
|
-
interface AddItemToWishlistInput {
|
|
46
|
-
product_variant_id: string;
|
|
47
|
-
id: string;
|
|
48
|
-
}
|
|
49
|
-
interface AddItemToWishlistOutput extends WishlistItem {
|
|
50
|
-
}
|
|
51
45
|
interface ListWishlistsInput extends PaginatedInput {
|
|
52
46
|
items_fields?: string[];
|
|
53
47
|
}
|
|
@@ -59,10 +53,17 @@ interface RetrieveWishlistInput {
|
|
|
59
53
|
}
|
|
60
54
|
interface RetrieveWishlistOutput extends Wishlist {
|
|
61
55
|
}
|
|
62
|
-
interface
|
|
56
|
+
interface UpdateWishlistInput {
|
|
63
57
|
id: string;
|
|
58
|
+
name?: string;
|
|
64
59
|
}
|
|
65
|
-
interface
|
|
60
|
+
interface UpdateWishlistOutput extends Omit<Wishlist, 'items'> {
|
|
61
|
+
}
|
|
62
|
+
interface DeleteWishlistInput {
|
|
63
|
+
id: string;
|
|
64
|
+
}
|
|
65
|
+
interface DeleteWishlistOutput {
|
|
66
|
+
id: string;
|
|
66
67
|
}
|
|
67
68
|
interface TotalItemsCountInput {
|
|
68
69
|
wishlist_id?: string;
|
|
@@ -76,36 +77,48 @@ interface TransferWishlistInput {
|
|
|
76
77
|
interface TransferWishlistOutput {
|
|
77
78
|
id: string;
|
|
78
79
|
}
|
|
79
|
-
interface
|
|
80
|
+
interface ShareWishlistInput {
|
|
80
81
|
id: string;
|
|
81
|
-
name?: string;
|
|
82
82
|
}
|
|
83
|
-
interface
|
|
83
|
+
interface ShareWishlistOutput {
|
|
84
|
+
share_token: string;
|
|
84
85
|
}
|
|
85
|
-
interface
|
|
86
|
-
|
|
86
|
+
interface ImportWishlistInput {
|
|
87
|
+
share_token: string;
|
|
88
|
+
}
|
|
89
|
+
interface ImportWishlistOutput extends Wishlist {
|
|
90
|
+
}
|
|
91
|
+
interface AddItemToWishlistInput {
|
|
92
|
+
product_variant_id: string;
|
|
87
93
|
id: string;
|
|
88
94
|
}
|
|
89
|
-
interface
|
|
95
|
+
interface AddItemToWishlistOutput extends WishlistItem {
|
|
96
|
+
}
|
|
97
|
+
interface ListItemsInput extends PaginatedInput {
|
|
90
98
|
id: string;
|
|
91
99
|
}
|
|
92
|
-
interface
|
|
100
|
+
interface ListItemsOutput extends PaginatedOutput<WishlistItem> {
|
|
101
|
+
}
|
|
102
|
+
interface RemoveItemFromWishlistInput {
|
|
103
|
+
wishlist_item_id: string;
|
|
93
104
|
id: string;
|
|
94
105
|
}
|
|
95
|
-
interface
|
|
106
|
+
interface RemoveItemFromWishlistOutput {
|
|
96
107
|
id: string;
|
|
97
108
|
}
|
|
98
109
|
type WishlistEndpoints = {
|
|
99
110
|
create: (input: CreateWishlistInput, headers?: ClientHeaders) => Promise<CreateWishlistOutput>;
|
|
100
|
-
addItem: (input: AddItemToWishlistInput, headers?: ClientHeaders) => Promise<AddItemToWishlistOutput>;
|
|
101
111
|
list: (input: ListWishlistsInput, headers?: ClientHeaders) => Promise<ListWishlistsOutput>;
|
|
102
|
-
listItems: (input: ListItemsInput, headers?: ClientHeaders) => Promise<ListItemsOutput>;
|
|
103
112
|
retrieve: (input: RetrieveWishlistInput, headers?: ClientHeaders) => Promise<RetrieveWishlistOutput>;
|
|
104
|
-
transfer: (input: TransferWishlistInput, headers?: ClientHeaders) => Promise<TransferWishlistOutput>;
|
|
105
113
|
update: (input: UpdateWishlistInput, headers?: ClientHeaders) => Promise<UpdateWishlistOutput>;
|
|
106
114
|
delete: (input: DeleteWishlistInput, headers?: ClientHeaders) => Promise<DeleteWishlistOutput>;
|
|
107
|
-
|
|
115
|
+
transfer: (input: TransferWishlistInput, headers?: ClientHeaders) => Promise<TransferWishlistOutput>;
|
|
116
|
+
share: (input: ShareWishlistInput, headers?: ClientHeaders) => Promise<ShareWishlistOutput>;
|
|
117
|
+
import: (input: ImportWishlistInput, headers?: ClientHeaders) => Promise<ImportWishlistOutput>;
|
|
108
118
|
totalItemsCount: (input: TotalItemsCountInput, headers?: ClientHeaders) => Promise<TotalItemsCountOutput>;
|
|
119
|
+
addItem: (input: AddItemToWishlistInput, headers?: ClientHeaders) => Promise<AddItemToWishlistOutput>;
|
|
120
|
+
listItems: (input: ListItemsInput, headers?: ClientHeaders) => Promise<ListItemsOutput>;
|
|
121
|
+
removeItem: (input: RemoveItemFromWishlistInput, headers?: ClientHeaders) => Promise<RemoveItemFromWishlistOutput>;
|
|
109
122
|
};
|
|
110
123
|
declare const wishlistPlugin: Plugin<'wishlist', WishlistEndpoints>;
|
|
111
124
|
|
|
@@ -123,7 +136,7 @@ interface AggregateCounts {
|
|
|
123
136
|
rating: number;
|
|
124
137
|
count: number;
|
|
125
138
|
}[];
|
|
126
|
-
product_id
|
|
139
|
+
product_id?: string;
|
|
127
140
|
total_count: number;
|
|
128
141
|
}
|
|
129
142
|
interface Review {
|
|
@@ -142,7 +155,7 @@ interface CreateReviewInput {
|
|
|
142
155
|
content: string;
|
|
143
156
|
rating: number;
|
|
144
157
|
product_id: string;
|
|
145
|
-
|
|
158
|
+
image_urls: string[];
|
|
146
159
|
title?: string;
|
|
147
160
|
}
|
|
148
161
|
interface CreateReviewOutput extends Review {
|
|
@@ -153,19 +166,15 @@ interface ListReviewsInput extends PaginatedInput {
|
|
|
153
166
|
verified_purchase_only?: boolean;
|
|
154
167
|
rating?: number;
|
|
155
168
|
include_product?: boolean;
|
|
169
|
+
sort_by?: 'created_at' | 'rating';
|
|
170
|
+
order?: 'asc' | 'desc';
|
|
156
171
|
}
|
|
157
172
|
interface ListReviewsOutput extends PaginatedOutput<Review> {
|
|
158
173
|
}
|
|
159
|
-
interface ListProductReviewsInput extends
|
|
174
|
+
interface ListProductReviewsInput extends Omit<ListReviewsInput, 'product_ids'> {
|
|
160
175
|
product_id: string;
|
|
161
|
-
my_reviews_only?: boolean;
|
|
162
|
-
verified_purchase_only?: boolean;
|
|
163
|
-
sort?: 'created_at' | 'rating';
|
|
164
|
-
order?: 'asc' | 'desc';
|
|
165
|
-
rating?: number;
|
|
166
|
-
include_product?: boolean;
|
|
167
176
|
}
|
|
168
|
-
interface ListProductReviewsOutput extends PaginatedOutput<Review
|
|
177
|
+
interface ListProductReviewsOutput extends PaginatedOutput<Omit<Review, 'product'>>, AggregateCounts {
|
|
169
178
|
}
|
|
170
179
|
interface DeleteReviewInput {
|
|
171
180
|
id: string;
|
|
@@ -204,4 +213,4 @@ declare class AlphabiteMedusaSdk<TPlugins extends readonly Plugin<any, any>[], T
|
|
|
204
213
|
constructor(medusaOptions: ConstructorParameters<typeof Medusa>[0], plugins: TPlugins, options?: TOptions);
|
|
205
214
|
}
|
|
206
215
|
|
|
207
|
-
export { type AddItemToWishlistInput, type AddItemToWishlistOutput, type AggregateCounts, type AggregateCountsInput, type AggregateCountsOutput, type AlphabiteClientOptions, AlphabiteMedusaSdk, type CreateClientTokenOutput, type CreateReviewInput, type CreateReviewOutput, type CreateWishlistInput, type CreateWishlistOutput, type DeleteReviewInput, type DeleteReviewOutput, type DeleteWishlistInput, type DeleteWishlistOutput, type ListItemsInput, type ListItemsOutput, type ListProductReviewsInput, type ListProductReviewsOutput, type ListReviewsInput, type ListReviewsOutput, type ListWishlistsInput, type ListWishlistsOutput, type Plugin, type PluginsToAlphabite, type RemoveItemFromWishlistInput, type RemoveItemFromWishlistOutput, type RetrieveWishlistInput, type RetrieveWishlistOutput, type Review, type TotalItemsCountInput, type TotalItemsCountOutput, type TransferWishlistInput, type TransferWishlistOutput, type UpdateWishlistInput, type UpdateWishlistOutput, type Wishlist, type WishlistItem, paypalPlugin, reviewsPlugin, wishlistPlugin };
|
|
216
|
+
export { type AddItemToWishlistInput, type AddItemToWishlistOutput, type AggregateCounts, type AggregateCountsInput, type AggregateCountsOutput, type AlphabiteClientOptions, AlphabiteMedusaSdk, type CreateClientTokenOutput, type CreateReviewInput, type CreateReviewOutput, type CreateWishlistInput, type CreateWishlistOutput, type DeleteReviewInput, type DeleteReviewOutput, type DeleteWishlistInput, type DeleteWishlistOutput, type ImportWishlistInput, type ImportWishlistOutput, type ListItemsInput, type ListItemsOutput, type ListProductReviewsInput, type ListProductReviewsOutput, type ListReviewsInput, type ListReviewsOutput, type ListWishlistsInput, type ListWishlistsOutput, type Plugin, type PluginsToAlphabite, type RemoveItemFromWishlistInput, type RemoveItemFromWishlistOutput, type RetrieveWishlistInput, type RetrieveWishlistOutput, type Review, type ShareWishlistInput, type ShareWishlistOutput, type TotalItemsCountInput, type TotalItemsCountOutput, type TransferWishlistInput, type TransferWishlistOutput, type UpdateWishlistInput, type UpdateWishlistOutput, type Wishlist, type WishlistItem, paypalPlugin, reviewsPlugin, wishlistPlugin };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var o=require('@medusajs/js-sdk');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var o__default=/*#__PURE__*/_interopDefault(o);var d={name:"wishlist",endpoints:(s,i)=>({create:async({...e},t)=>s.client.fetch("/store/wishlists",{method:"POST",body:e,headers:{...await i?.getAuthHeader?.(),...t}}),list:async({limit:e=10,offset:t=0,...r},n)=>s.client.fetch("/store/wishlists",{method:"GET",headers:{...await i?.getAuthHeader?.(),...n},query:{limit:e,offset:t,...r}}),retrieve:async({id:e,...t},r)=>s.client.fetch(`/store/wishlists/${e}`,{method:"GET",headers:{...await i?.getAuthHeader?.(),...r},query:t}),update:async({id:e,...t},r)=>s.client.fetch(`/store/wishlists/${e}`,{method:"PUT",body:t,headers:{...await i?.getAuthHeader?.(),...r}}),delete:async({id:e},t)=>s.client.fetch(`/store/wishlists/${e}`,{method:"DELETE",headers:{...await i?.getAuthHeader?.(),...t}}),totalItemsCount:async({wishlist_id:e},t)=>s.client.fetch("store/wishlists/total-items-count",{method:"GET",headers:{...await i?.getAuthHeader?.(),...t},query:{wishlist_id:e}}),transfer:async({id:e},t)=>s.client.fetch(`/store/wishlists/${e}/transfer`,{method:"POST",headers:{...await i?.getAuthHeader?.(),...t}}),share:async({id:e},t)=>s.client.fetch(`/store/wishlists/${e}/share`,{method:"POST",headers:{...await i?.getAuthHeader?.(),...t}}),import:async(e,t)=>s.client.fetch("/store/wishlists/import",{method:"POST",body:e,headers:{...await i?.getAuthHeader?.(),...t}}),addItem:async({id:e,...t},r)=>s.client.fetch(`/store/wishlists/${e}/add-item`,{method:"POST",body:t,headers:{...await i?.getAuthHeader?.(),...r}}),listItems:async({id:e,limit:t=10,offset:r=0,...n},u)=>s.client.fetch(`/store/wishlists/${e}/items`,{method:"GET",headers:{...await i?.getAuthHeader?.(),...u},query:{limit:t,offset:r,...n}}),removeItem:async({wishlist_item_id:e,id:t},r)=>s.client.fetch(`/store/wishlists/${t}/items/${e}`,{method:"DELETE",headers:{...await i?.getAuthHeader?.(),...r}})})};var l={name:"paypal",endpoints:(s,i)=>({createClientToken:async e=>s.client.fetch("/store/paypal/client-token",{method:"POST",headers:{...await i?.getAuthHeader?.(),...e}})})};var c={name:"reviews",endpoints:(s,i)=>({create:async(e,t)=>s.client.fetch("/store/reviews",{method:"POST",body:e,headers:{...await i?.getAuthHeader?.(),...t}}),list:async({...e},t)=>s.client.fetch("/store/products/reviews",{method:"GET",headers:{...await i?.getAuthHeader?.(),...t},query:e}),listProductReviews:async({product_id:e,...t},r)=>s.client.fetch(`store/reviews/product/${e}`,{method:"GET",query:t,headers:{...await i?.getAuthHeader?.(),...r}}),aggregateCounts:async({product_id:e,...t},r)=>s.client.fetch(`/store/reviews/product/${e}/aggregate-counts`,{method:"GET",query:t,headers:{...await i?.getAuthHeader?.(),...r}}),delete:async({id:e},t)=>s.client.fetch(`/store/reviews/${e}`,{method:"DELETE",headers:{...await i?.getAuthHeader?.(),...t}})})};var a=class extends o__default.default{constructor(i,e,t){super(i),this.options=t;let r={};e.forEach(n=>{r[n.name]=n.endpoints(this,this.options);}),this.alphabite=r;}};exports.AlphabiteMedusaSdk=a;exports.paypalPlugin=l;exports.reviewsPlugin=c;exports.wishlistPlugin=d;
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import o from'@medusajs/js-sdk';var d={name:"wishlist",endpoints:(s,i)=>({create:async({...e},t)=>s.client.fetch("/store/wishlists",{method:"POST",body:e,headers:{...await i?.getAuthHeader?.(),...t}}),list:async({limit:e=10,offset:t=0,...r},n)=>s.client.fetch("/store/wishlists",{method:"GET",headers:{...await i?.getAuthHeader?.(),...n},query:{limit:e,offset:t,...r}}),retrieve:async({id:e,...t},r)=>s.client.fetch(`/store/wishlists/${e}`,{method:"GET",headers:{...await i?.getAuthHeader?.(),...r},query:t}),update:async({id:e,...t},r)=>s.client.fetch(`/store/wishlists/${e}`,{method:"PUT",body:t,headers:{...await i?.getAuthHeader?.(),...r}}),delete:async({id:e},t)=>s.client.fetch(`/store/wishlists/${e}`,{method:"DELETE",headers:{...await i?.getAuthHeader?.(),...t}}),totalItemsCount:async({wishlist_id:e},t)=>s.client.fetch("store/wishlists/total-items-count",{method:"GET",headers:{...await i?.getAuthHeader?.(),...t},query:{wishlist_id:e}}),transfer:async({id:e},t)=>s.client.fetch(`/store/wishlists/${e}/transfer`,{method:"POST",headers:{...await i?.getAuthHeader?.(),...t}}),share:async({id:e},t)=>s.client.fetch(`/store/wishlists/${e}/share`,{method:"POST",headers:{...await i?.getAuthHeader?.(),...t}}),import:async(e,t)=>s.client.fetch("/store/wishlists/import",{method:"POST",body:e,headers:{...await i?.getAuthHeader?.(),...t}}),addItem:async({id:e,...t},r)=>s.client.fetch(`/store/wishlists/${e}/add-item`,{method:"POST",body:t,headers:{...await i?.getAuthHeader?.(),...r}}),listItems:async({id:e,limit:t=10,offset:r=0,...n},u)=>s.client.fetch(`/store/wishlists/${e}/items`,{method:"GET",headers:{...await i?.getAuthHeader?.(),...u},query:{limit:t,offset:r,...n}}),removeItem:async({wishlist_item_id:e,id:t},r)=>s.client.fetch(`/store/wishlists/${t}/items/${e}`,{method:"DELETE",headers:{...await i?.getAuthHeader?.(),...r}})})};var l={name:"paypal",endpoints:(s,i)=>({createClientToken:async e=>s.client.fetch("/store/paypal/client-token",{method:"POST",headers:{...await i?.getAuthHeader?.(),...e}})})};var c={name:"reviews",endpoints:(s,i)=>({create:async(e,t)=>s.client.fetch("/store/reviews",{method:"POST",body:e,headers:{...await i?.getAuthHeader?.(),...t}}),list:async({...e},t)=>s.client.fetch("/store/products/reviews",{method:"GET",headers:{...await i?.getAuthHeader?.(),...t},query:e}),listProductReviews:async({product_id:e,...t},r)=>s.client.fetch(`store/reviews/product/${e}`,{method:"GET",query:t,headers:{...await i?.getAuthHeader?.(),...r}}),aggregateCounts:async({product_id:e,...t},r)=>s.client.fetch(`/store/reviews/product/${e}/aggregate-counts`,{method:"GET",query:t,headers:{...await i?.getAuthHeader?.(),...r}}),delete:async({id:e},t)=>s.client.fetch(`/store/reviews/${e}`,{method:"DELETE",headers:{...await i?.getAuthHeader?.(),...t}})})};var a=class extends o{constructor(i,e,t){super(i),this.options=t;let r={};e.forEach(n=>{r[n.name]=n.endpoints(this,this.options);}),this.alphabite=r;}};export{a as AlphabiteMedusaSdk,l as paypalPlugin,c as reviewsPlugin,d as wishlistPlugin};
|