@stackd-solutions/medusa-sdk 0.1.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/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [2026] [StackD Solutions]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,179 @@
1
+ <!--suppress HtmlDeprecatedAttribute -->
2
+ <h1 align="center">
3
+ <br>
4
+ <a href="https://www.stackd-solutions.io"><img src="https://raw.githubusercontent.com/StackD-Solutions/medusa-sdk/main/docs/logo.svg" alt="StackD Solutions" width="250"></a>
5
+ <br>Medusa SDK
6
+ <br>
7
+ </h1>
8
+
9
+ <p align="center">
10
+ <a href="https://www.npmjs.com/package/@stackd-solutions/medusa-sdk"><img src="https://img.shields.io/npm/v/@stackd-solutions/medusa-sdk" alt="npm version"></a>
11
+ <a href="https://www.npmjs.com/package/@stackd-solutions/medusa-sdk"><img src="https://img.shields.io/npm/dm/@stackd-solutions/medusa-sdk" alt="npm downloads"></a>
12
+ <img src="https://img.shields.io/npm/l/@stackd-solutions/medusa-sdk" alt="Apache License">
13
+ <img src="https://img.shields.io/npm/types/@stackd-solutions/medusa-sdk" alt="Types Included">
14
+ </p>
15
+
16
+ An extended [Medusa v2](https://medusajs.com/) SDK client with typed endpoints for StackD Solutions plugins. It extends `@medusajs/js-sdk` with a plugin system that adds fully typed methods for each plugin's API.
17
+
18
+ ## Installation
19
+
20
+ ```bash
21
+ yarn add @stackd-solutions/medusa-sdk @medusajs/js-sdk
22
+ ```
23
+
24
+ ## Usage
25
+
26
+ ```typescript
27
+ import {StackdMedusaSdk, emailVerificationPlugin, wishlistPlugin} from '@stackd-solutions/medusa-sdk'
28
+
29
+ const sdk = new StackdMedusaSdk(
30
+ {
31
+ baseUrl: 'http://localhost:9000',
32
+ auth: {type: 'session', jwtTokenStorageKey: 'medusa_auth_token'}
33
+ },
34
+ [emailVerificationPlugin, wishlistPlugin] as const,
35
+ {
36
+ getAuthHeader: async () => ({
37
+ Authorization: `Bearer ${localStorage.getItem('medusa_auth_token')}`
38
+ })
39
+ }
40
+ )
41
+
42
+ // All plugin endpoints are available under sdk.stackd
43
+ const status = await sdk.stackd.emailVerification.getVerificationStatus()
44
+ ```
45
+
46
+ ## Available Plugins
47
+
48
+ | Plugin | Namespace | Description |
49
+ | ------------------ | ------------------------------ | --------------------------------------------------- |
50
+ | Email Verification | `sdk.stackd.emailVerification` | Send, verify, and check customer email verification |
51
+ | Wishlist | `sdk.stackd.wishlist` | Create, manage, and share product wishlists |
52
+
53
+ ### Email Verification
54
+
55
+ Companion SDK for the [`@stackd-solutions/medusa-email-verification`](https://www.npmjs.com/package/@stackd-solutions/medusa-email-verification) plugin. Provides typed methods for the email verification store API.
56
+
57
+ ```typescript
58
+ import {emailVerificationPlugin} from '@stackd-solutions/medusa-sdk'
59
+ ```
60
+
61
+ **Endpoints:**
62
+
63
+ | Method | HTTP | Description |
64
+ | ----------------------- | -------------------------------- | --------------------------------------------------------- |
65
+ | `sendVerificationEmail` | `POST /store/email/verify/send` | Send a verification email to the authenticated customer |
66
+ | `verifyToken` | `POST /store/email/verify` | Verify an email token |
67
+ | `getVerificationStatus` | `GET /store/email/verify/status` | Get the verification status of the authenticated customer |
68
+
69
+ **Example:**
70
+
71
+ ```typescript
72
+ // Send verification email
73
+ await sdk.stackd.emailVerification.sendVerificationEmail({
74
+ callback_url: 'https://mystore.com/email/verify'
75
+ })
76
+
77
+ // Verify token from email link
78
+ const result = await sdk.stackd.emailVerification.verifyToken({
79
+ token: 'abc123'
80
+ })
81
+
82
+ // Check verification status
83
+ const {verified} = await sdk.stackd.emailVerification.getVerificationStatus()
84
+ ```
85
+
86
+ ### Wishlist
87
+
88
+ Companion SDK for the [`@stackd-solutions/medusa-wishlist`](https://www.npmjs.com/package/@stackd-solutions/medusa-wishlist) plugin. Provides typed methods for the wishlist store API.
89
+
90
+ ```typescript
91
+ import {wishlistPlugin} from '@stackd-solutions/medusa-sdk'
92
+ ```
93
+
94
+ **Endpoints:**
95
+
96
+ | Method | HTTP | Description |
97
+ | -------------------- | -------------------------------------------- | --------------------------------------- |
98
+ | `list` | `GET /store/wishlists` | List wishlists for the current customer |
99
+ | `create` | `POST /store/wishlists` | Create a new wishlist |
100
+ | `retrieve` | `GET /store/wishlists/:id` | Retrieve a wishlist by ID |
101
+ | `update` | `PUT /store/wishlists/:id` | Update wishlist metadata |
102
+ | `delete` | `DELETE /store/wishlists/:id` | Delete a wishlist |
103
+ | `listItems` | `GET /store/wishlists/:id/items` | List items in a wishlist |
104
+ | `addItem` | `POST /store/wishlists/:id/items` | Add a product variant to a wishlist |
105
+ | `removeItem` | `DELETE /store/wishlists/:id/items/:item_id` | Remove an item from a wishlist |
106
+ | `generateShareToken` | `POST /store/wishlists/:id/share` | Generate a share token for a wishlist |
107
+ | `transfer` | `POST /store/wishlists/:id/transfer` | Transfer a guest wishlist to a customer |
108
+ | `import` | `POST /store/wishlists/import` | Import a shared wishlist via token |
109
+ | `getTotalItemsCount` | `GET /store/wishlists/total-items-count` | Get total items count across wishlists |
110
+
111
+ **Example:**
112
+
113
+ ```typescript
114
+ // Create a wishlist
115
+ const wishlist = await sdk.stackd.wishlist.create({
116
+ name: 'My Favorites',
117
+ sales_channel_id: 'sc_123'
118
+ })
119
+
120
+ // Add an item
121
+ await sdk.stackd.wishlist.addItem(wishlist.id, {
122
+ product_variant_id: 'variant_123'
123
+ })
124
+
125
+ // List wishlists
126
+ const {data} = await sdk.stackd.wishlist.list({limit: 10, offset: 0})
127
+
128
+ // Share a wishlist
129
+ const {share_token} = await sdk.stackd.wishlist.generateShareToken(wishlist.id)
130
+ ```
131
+
132
+ ## Plugin System
133
+
134
+ The SDK uses a generic plugin system. Each plugin registers a set of typed endpoints under a named key:
135
+
136
+ ```typescript
137
+ import {Plugin, StackdMedusaSdk} from '@stackd-solutions/medusa-sdk'
138
+
139
+ const myPlugin: Plugin<'myPlugin', MyEndpoints> = {
140
+ name: 'myPlugin' as const,
141
+ endpoints: (sdk, options, medusaConfig) => ({
142
+ // your typed endpoint methods
143
+ })
144
+ }
145
+
146
+ const sdk = new StackdMedusaSdk(medusaOptions, [myPlugin] as const)
147
+ sdk.stackd.myPlugin // fully typed
148
+ ```
149
+
150
+ ## Types
151
+
152
+ The SDK exports the following types:
153
+
154
+ ```typescript
155
+ import type {StackdClientOptions, StackdMedusaConfig, Plugin, PluginsToStackd} from '@stackd-solutions/medusa-sdk'
156
+ ```
157
+
158
+ | Type | Description |
159
+ | --------------------- | ------------------------------------------------------------ |
160
+ | `StackdClientOptions` | Options passed to plugins (e.g. `getAuthHeader`) |
161
+ | `StackdMedusaConfig` | Constructor parameters for the underlying `@medusajs/js-sdk` |
162
+ | `Plugin` | Plugin definition with a name and endpoint factory |
163
+ | `PluginsToStackd` | Utility type that maps a plugin tuple to its endpoint types |
164
+
165
+ ## Build
166
+
167
+ ```bash
168
+ yarn build
169
+ ```
170
+
171
+ ## Development
172
+
173
+ ```bash
174
+ yarn dev
175
+ ```
176
+
177
+ ## License
178
+
179
+ Apache 2.0
@@ -0,0 +1,52 @@
1
+ import Medusa, { ClientHeaders } from '@medusajs/js-sdk';
2
+ import { SendVerificationEmailRequest, SendVerificationEmailResponse, VerifyEmailTokenRequest, VerifyEmailTokenResponse, EmailVerificationStatusResponse } from '@stackd-solutions/medusa-email-verification';
3
+ export { EmailVerificationStatusResponse, SendVerificationEmailRequest, SendVerificationEmailResponse, VerifyEmailTokenRequest, VerifyEmailTokenResponse } from '@stackd-solutions/medusa-email-verification';
4
+ import { ListWishlistsQuery, PaginatedWishlistResponse, CreateWishlistRequest, Wishlist, RetrieveWishlistQuery, UpdateWishlistRequest, DeleteResponse, PaginatedWishlistItemResponse, AddItemToWishlistRequest, WishlistItem, ShareTokenResponse, ImportWishlistRequest, TotalItemsCountQuery, TotalItemsCountResponse } from '@stackd-solutions/medusa-wishlist';
5
+ export { AddItemToWishlistRequest, CreateWishlistRequest, DeleteResponse, ImportWishlistRequest, ListWishlistsQuery, PaginatedWishlistItemResponse, PaginatedWishlistResponse, RetrieveWishlistQuery, ShareTokenResponse, TotalItemsCountQuery, TotalItemsCountResponse, UpdateWishlistRequest, Wishlist, WishlistItem } from '@stackd-solutions/medusa-wishlist';
6
+
7
+ type EmailVerificationEndpoints = {
8
+ sendVerificationEmail: (input: SendVerificationEmailRequest, headers?: ClientHeaders) => Promise<SendVerificationEmailResponse>;
9
+ verifyToken: (input: VerifyEmailTokenRequest, headers?: ClientHeaders) => Promise<VerifyEmailTokenResponse>;
10
+ getVerificationStatus: (headers?: ClientHeaders) => Promise<EmailVerificationStatusResponse>;
11
+ };
12
+ declare const emailVerificationPlugin: Plugin<'emailVerification', EmailVerificationEndpoints>;
13
+
14
+ type ListItemsQuery = {
15
+ limit?: number;
16
+ offset?: number;
17
+ };
18
+ type WishlistEndpoints = {
19
+ list: (query?: ListWishlistsQuery, headers?: ClientHeaders) => Promise<PaginatedWishlistResponse>;
20
+ create: (input: CreateWishlistRequest, headers?: ClientHeaders) => Promise<Wishlist>;
21
+ retrieve: (id: string, query?: RetrieveWishlistQuery, headers?: ClientHeaders) => Promise<Wishlist>;
22
+ update: (id: string, input: UpdateWishlistRequest, headers?: ClientHeaders) => Promise<Wishlist>;
23
+ delete: (id: string, headers?: ClientHeaders) => Promise<DeleteResponse>;
24
+ listItems: (id: string, query?: ListItemsQuery, headers?: ClientHeaders) => Promise<PaginatedWishlistItemResponse>;
25
+ addItem: (id: string, input: AddItemToWishlistRequest, headers?: ClientHeaders) => Promise<WishlistItem>;
26
+ removeItem: (id: string, itemId: string, headers?: ClientHeaders) => Promise<DeleteResponse>;
27
+ generateShareToken: (id: string, headers?: ClientHeaders) => Promise<ShareTokenResponse>;
28
+ transfer: (id: string, headers?: ClientHeaders) => Promise<Wishlist>;
29
+ import: (input: ImportWishlistRequest, headers?: ClientHeaders) => Promise<Wishlist>;
30
+ getTotalItemsCount: (query?: TotalItemsCountQuery, headers?: ClientHeaders) => Promise<TotalItemsCountResponse>;
31
+ };
32
+ declare const wishlistPlugin: Plugin<'wishlist', WishlistEndpoints>;
33
+
34
+ type StackdClientOptions = {
35
+ getAuthHeader?: () => Promise<Record<string, string>> | Record<string, string>;
36
+ };
37
+ type StackdMedusaConfig = ConstructorParameters<typeof Medusa>[0];
38
+ type Plugin<Name extends string, Endpoints> = {
39
+ name: Name;
40
+ endpoints: (client: Medusa, options?: StackdClientOptions, medusaConfig?: StackdMedusaConfig) => Endpoints;
41
+ };
42
+ type PluginsToStackd<T extends readonly Plugin<any, any>[]> = {
43
+ [K in T[number] as K['name']]: ReturnType<K['endpoints']>;
44
+ };
45
+ declare class StackdMedusaSdk<TPlugins extends readonly Plugin<any, any>[]> extends Medusa {
46
+ stackd: PluginsToStackd<TPlugins>;
47
+ protected options?: StackdClientOptions;
48
+ protected medusaConfig: StackdMedusaConfig;
49
+ constructor(medusaOptions: StackdMedusaConfig, plugins: TPlugins, options?: StackdClientOptions);
50
+ }
51
+
52
+ export { type ListItemsQuery, type Plugin, type PluginsToStackd, type StackdClientOptions, type StackdMedusaConfig, StackdMedusaSdk, emailVerificationPlugin, wishlistPlugin };
@@ -0,0 +1,52 @@
1
+ import Medusa, { ClientHeaders } from '@medusajs/js-sdk';
2
+ import { SendVerificationEmailRequest, SendVerificationEmailResponse, VerifyEmailTokenRequest, VerifyEmailTokenResponse, EmailVerificationStatusResponse } from '@stackd-solutions/medusa-email-verification';
3
+ export { EmailVerificationStatusResponse, SendVerificationEmailRequest, SendVerificationEmailResponse, VerifyEmailTokenRequest, VerifyEmailTokenResponse } from '@stackd-solutions/medusa-email-verification';
4
+ import { ListWishlistsQuery, PaginatedWishlistResponse, CreateWishlistRequest, Wishlist, RetrieveWishlistQuery, UpdateWishlistRequest, DeleteResponse, PaginatedWishlistItemResponse, AddItemToWishlistRequest, WishlistItem, ShareTokenResponse, ImportWishlistRequest, TotalItemsCountQuery, TotalItemsCountResponse } from '@stackd-solutions/medusa-wishlist';
5
+ export { AddItemToWishlistRequest, CreateWishlistRequest, DeleteResponse, ImportWishlistRequest, ListWishlistsQuery, PaginatedWishlistItemResponse, PaginatedWishlistResponse, RetrieveWishlistQuery, ShareTokenResponse, TotalItemsCountQuery, TotalItemsCountResponse, UpdateWishlistRequest, Wishlist, WishlistItem } from '@stackd-solutions/medusa-wishlist';
6
+
7
+ type EmailVerificationEndpoints = {
8
+ sendVerificationEmail: (input: SendVerificationEmailRequest, headers?: ClientHeaders) => Promise<SendVerificationEmailResponse>;
9
+ verifyToken: (input: VerifyEmailTokenRequest, headers?: ClientHeaders) => Promise<VerifyEmailTokenResponse>;
10
+ getVerificationStatus: (headers?: ClientHeaders) => Promise<EmailVerificationStatusResponse>;
11
+ };
12
+ declare const emailVerificationPlugin: Plugin<'emailVerification', EmailVerificationEndpoints>;
13
+
14
+ type ListItemsQuery = {
15
+ limit?: number;
16
+ offset?: number;
17
+ };
18
+ type WishlistEndpoints = {
19
+ list: (query?: ListWishlistsQuery, headers?: ClientHeaders) => Promise<PaginatedWishlistResponse>;
20
+ create: (input: CreateWishlistRequest, headers?: ClientHeaders) => Promise<Wishlist>;
21
+ retrieve: (id: string, query?: RetrieveWishlistQuery, headers?: ClientHeaders) => Promise<Wishlist>;
22
+ update: (id: string, input: UpdateWishlistRequest, headers?: ClientHeaders) => Promise<Wishlist>;
23
+ delete: (id: string, headers?: ClientHeaders) => Promise<DeleteResponse>;
24
+ listItems: (id: string, query?: ListItemsQuery, headers?: ClientHeaders) => Promise<PaginatedWishlistItemResponse>;
25
+ addItem: (id: string, input: AddItemToWishlistRequest, headers?: ClientHeaders) => Promise<WishlistItem>;
26
+ removeItem: (id: string, itemId: string, headers?: ClientHeaders) => Promise<DeleteResponse>;
27
+ generateShareToken: (id: string, headers?: ClientHeaders) => Promise<ShareTokenResponse>;
28
+ transfer: (id: string, headers?: ClientHeaders) => Promise<Wishlist>;
29
+ import: (input: ImportWishlistRequest, headers?: ClientHeaders) => Promise<Wishlist>;
30
+ getTotalItemsCount: (query?: TotalItemsCountQuery, headers?: ClientHeaders) => Promise<TotalItemsCountResponse>;
31
+ };
32
+ declare const wishlistPlugin: Plugin<'wishlist', WishlistEndpoints>;
33
+
34
+ type StackdClientOptions = {
35
+ getAuthHeader?: () => Promise<Record<string, string>> | Record<string, string>;
36
+ };
37
+ type StackdMedusaConfig = ConstructorParameters<typeof Medusa>[0];
38
+ type Plugin<Name extends string, Endpoints> = {
39
+ name: Name;
40
+ endpoints: (client: Medusa, options?: StackdClientOptions, medusaConfig?: StackdMedusaConfig) => Endpoints;
41
+ };
42
+ type PluginsToStackd<T extends readonly Plugin<any, any>[]> = {
43
+ [K in T[number] as K['name']]: ReturnType<K['endpoints']>;
44
+ };
45
+ declare class StackdMedusaSdk<TPlugins extends readonly Plugin<any, any>[]> extends Medusa {
46
+ stackd: PluginsToStackd<TPlugins>;
47
+ protected options?: StackdClientOptions;
48
+ protected medusaConfig: StackdMedusaConfig;
49
+ constructor(medusaOptions: StackdMedusaConfig, plugins: TPlugins, options?: StackdClientOptions);
50
+ }
51
+
52
+ export { type ListItemsQuery, type Plugin, type PluginsToStackd, type StackdClientOptions, type StackdMedusaConfig, StackdMedusaSdk, emailVerificationPlugin, wishlistPlugin };
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ 'use strict';var l=require('@medusajs/js-sdk');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var l__default=/*#__PURE__*/_interopDefault(l);var a=(o,n)=>async(s,e)=>{let{method:t,headers:i}=e;return o.client.fetch(s,{method:t,..."body"in e&&{body:e.body},headers:{...await n?.getAuthHeader?.(),...i}})},r=o=>{if(!o)return "";let n=Object.entries(o).filter(([,e])=>e!=null);if(n.length===0)return "";let s=new URLSearchParams;return n.forEach(([e,t])=>{Array.isArray(t)?t.forEach(i=>s.append(e,String(i))):s.append(e,String(t));}),`?${s.toString()}`};var p={name:"emailVerification",endpoints:(o,n)=>{let s=a(o,n);return {sendVerificationEmail:async(e,t)=>s("/store/email/verify/send",{method:"POST",body:e,headers:t}),verifyToken:async(e,t)=>s("/store/email/verify",{method:"POST",body:e,headers:t}),getVerificationStatus:async e=>s("/store/email/verify/status",{method:"GET",headers:e})}}};var y={name:"wishlist",endpoints:(o,n)=>{let s=a(o,n);return {list:async(e,t)=>s(`/store/wishlists${r(e)}`,{method:"GET",headers:t}),create:async(e,t)=>s("/store/wishlists",{method:"POST",body:e,headers:t}),retrieve:async(e,t,i)=>s(`/store/wishlists/${e}${r(t)}`,{method:"GET",headers:i}),update:async(e,t,i)=>s(`/store/wishlists/${e}`,{method:"PUT",body:t,headers:i}),delete:async(e,t)=>s(`/store/wishlists/${e}`,{method:"DELETE",headers:t}),listItems:async(e,t,i)=>s(`/store/wishlists/${e}/items${r(t)}`,{method:"GET",headers:i}),addItem:async(e,t,i)=>s(`/store/wishlists/${e}/items`,{method:"POST",body:t,headers:i}),removeItem:async(e,t,i)=>s(`/store/wishlists/${e}/items/${t}`,{method:"DELETE",headers:i}),generateShareToken:async(e,t)=>s(`/store/wishlists/${e}/share`,{method:"POST",headers:t}),transfer:async(e,t)=>s(`/store/wishlists/${e}/transfer`,{method:"POST",headers:t}),import:async(e,t)=>s("/store/wishlists/import",{method:"POST",body:e,headers:t}),getTotalItemsCount:async(e,t)=>s(`/store/wishlists/total-items-count${r(e)}`,{method:"GET",headers:t})}}};var d=class extends l__default.default{constructor(n,s,e){super(n),this.options=e,this.medusaConfig=n;let t={};s.forEach(i=>{t[i.name]=i.endpoints(this,this.options,this.medusaConfig);}),this.stackd=t;}};exports.StackdMedusaSdk=d;exports.emailVerificationPlugin=p;exports.wishlistPlugin=y;//# sourceMappingURL=index.js.map
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/utils/http.ts","../src/plugins/email-verification/plugin.ts","../src/plugins/wishlist/plugin.ts","../src/index.ts"],"names":["createFetch","sdk","options","path","opts","method","headers","toQueryString","params","entries","v","searchParams","k","item","emailVerificationPlugin","fetch","input","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CH'\r\n\tbody?: Record<string, any>\r\n\theaders?: ClientHeaders\r\n}\r\n\r\ntype StackdFetchWithoutBody = {\r\n\tmethod: 'GET' | 'DELETE'\r\n\theaders?: ClientHeaders\r\n}\r\n\r\ntype StackdFetchOptions = StackdFetchWithBody | StackdFetchWithoutBody\r\n\r\ntype StackdFetch = <T>(path: string, options: StackdFetchOptions) => Promise<T>\r\n\r\nexport const createFetch =\r\n\t(sdk: Medusa, options?: StackdClientOptions): StackdFetch =>\r\n\tasync <T>(path: string, opts: StackdFetchOptions): Promise<T> => {\r\n\t\tconst {method, headers} = opts\r\n\t\treturn sdk.client.fetch<T>(path, {\r\n\t\t\tmethod,\r\n\t\t\t...('body' in opts && {body: opts.body}),\r\n\t\t\theaders: {\r\n\t\t\t\t...(await options?.getAuthHeader?.()),\r\n\t\t\t\t...headers\r\n\t\t\t}\r\n\t\t})\r\n\t}\r\n\r\nexport const toQueryString = (params?: Record<string, unknown>): string => {\r\n\tif (!params) {\r\n\t\treturn ''\r\n\t}\r\n\tconst entries = Object.entries(params).filter(([, v]) => v !== undefined && v !== null)\r\n\tif (entries.length === 0) {\r\n\t\treturn ''\r\n\t}\r\n\tconst searchParams = new URLSearchParams()\r\n\tentries.forEach(([k, v]) => {\r\n\t\tif (Array.isArray(v)) {\r\n\t\t\tv.forEach(item => searchParams.append(k, String(item)))\r\n\t\t} else {\r\n\t\t\tsearchParams.append(k, String(v))\r\n\t\t}\r\n\t})\r\n\treturn `?${searchParams.toString()}`\r\n}\r\n","import Medusa, {ClientHeaders} from '@medusajs/js-sdk'\r\nimport type {\r\n\tSendVerificationEmailRequest,\r\n\tSendVerificationEmailResponse,\r\n\tVerifyEmailTokenRequest,\r\n\tVerifyEmailTokenResponse,\r\n\tEmailVerificationStatusResponse\r\n} from '@stackd-solutions/medusa-email-verification'\r\nimport {StackdClientOptions, Plugin} from '../..'\r\nimport {createFetch} from '../../utils/http'\r\n\r\nexport type {\r\n\tSendVerificationEmailRequest,\r\n\tSendVerificationEmailResponse,\r\n\tVerifyEmailTokenRequest,\r\n\tVerifyEmailTokenResponse,\r\n\tEmailVerificationStatusResponse\r\n}\r\n\r\ntype EmailVerificationEndpoints = {\r\n\tsendVerificationEmail: (input: SendVerificationEmailRequest, headers?: ClientHeaders) => Promise<SendVerificationEmailResponse>\r\n\tverifyToken: (input: VerifyEmailTokenRequest, headers?: ClientHeaders) => Promise<VerifyEmailTokenResponse>\r\n\tgetVerificationStatus: (headers?: ClientHeaders) => Promise<EmailVerificationStatusResponse>\r\n}\r\n\r\nexport const emailVerificationPlugin: Plugin<'emailVerification', EmailVerificationEndpoints> = {\r\n\tname: 'emailVerification' as const,\r\n\tendpoints: (sdk: Medusa, options?: StackdClientOptions) => {\r\n\t\tconst fetch = createFetch(sdk, options)\r\n\r\n\t\treturn {\r\n\t\t\tsendVerificationEmail: async (input, headers) => fetch('/store/email/verify/send', {method: 'POST', body: input, headers}),\r\n\t\t\tverifyToken: async (input, headers) => fetch('/store/email/verify', {method: 'POST', body: input, headers}),\r\n\t\t\tgetVerificationStatus: async headers => fetch('/store/email/verify/status', {method: 'GET', headers})\r\n\t\t}\r\n\t}\r\n}\r\n","import Medusa, {ClientHeaders} from '@medusajs/js-sdk'\r\nimport type {\r\n\tWishlist,\r\n\tWishlistItem,\r\n\tPaginatedWishlistResponse,\r\n\tPaginatedWishlistItemResponse,\r\n\tCreateWishlistRequest,\r\n\tUpdateWishlistRequest,\r\n\tAddItemToWishlistRequest,\r\n\tImportWishlistRequest,\r\n\tShareTokenResponse,\r\n\tDeleteResponse,\r\n\tTotalItemsCountResponse,\r\n\tListWishlistsQuery,\r\n\tRetrieveWishlistQuery,\r\n\tTotalItemsCountQuery\r\n} from '@stackd-solutions/medusa-wishlist'\r\nimport {StackdClientOptions, Plugin} from '../..'\r\nimport {createFetch, toQueryString} from '../../utils/http'\r\n\r\nexport type {\r\n\tWishlist,\r\n\tWishlistItem,\r\n\tPaginatedWishlistResponse,\r\n\tPaginatedWishlistItemResponse,\r\n\tCreateWishlistRequest,\r\n\tUpdateWishlistRequest,\r\n\tAddItemToWishlistRequest,\r\n\tImportWishlistRequest,\r\n\tShareTokenResponse,\r\n\tDeleteResponse,\r\n\tTotalItemsCountResponse,\r\n\tListWishlistsQuery,\r\n\tRetrieveWishlistQuery,\r\n\tTotalItemsCountQuery\r\n}\r\n\r\nexport type ListItemsQuery = {\r\n\tlimit?: number\r\n\toffset?: number\r\n}\r\n\r\ntype WishlistEndpoints = {\r\n\tlist: (query?: ListWishlistsQuery, headers?: ClientHeaders) => Promise<PaginatedWishlistResponse>\r\n\tcreate: (input: CreateWishlistRequest, headers?: ClientHeaders) => Promise<Wishlist>\r\n\tretrieve: (id: string, query?: RetrieveWishlistQuery, headers?: ClientHeaders) => Promise<Wishlist>\r\n\tupdate: (id: string, input: UpdateWishlistRequest, headers?: ClientHeaders) => Promise<Wishlist>\r\n\tdelete: (id: string, headers?: ClientHeaders) => Promise<DeleteResponse>\r\n\tlistItems: (id: string, query?: ListItemsQuery, headers?: ClientHeaders) => Promise<PaginatedWishlistItemResponse>\r\n\taddItem: (id: string, input: AddItemToWishlistRequest, headers?: ClientHeaders) => Promise<WishlistItem>\r\n\tremoveItem: (id: string, itemId: string, headers?: ClientHeaders) => Promise<DeleteResponse>\r\n\tgenerateShareToken: (id: string, headers?: ClientHeaders) => Promise<ShareTokenResponse>\r\n\ttransfer: (id: string, headers?: ClientHeaders) => Promise<Wishlist>\r\n\timport: (input: ImportWishlistRequest, headers?: ClientHeaders) => Promise<Wishlist>\r\n\tgetTotalItemsCount: (query?: TotalItemsCountQuery, headers?: ClientHeaders) => Promise<TotalItemsCountResponse>\r\n}\r\n\r\nexport const wishlistPlugin: Plugin<'wishlist', WishlistEndpoints> = {\r\n\tname: 'wishlist' as const,\r\n\tendpoints: (sdk: Medusa, options?: StackdClientOptions) => {\r\n\t\tconst fetch = createFetch(sdk, options)\r\n\r\n\t\treturn {\r\n\t\t\tlist: async (query, headers) => fetch(`/store/wishlists${toQueryString(query)}`, {method: 'GET', headers}),\r\n\t\t\tcreate: async (input, headers) => fetch('/store/wishlists', {method: 'POST', body: input, headers}),\r\n\t\t\tretrieve: async (id, query, headers) => fetch(`/store/wishlists/${id}${toQueryString(query)}`, {method: 'GET', headers}),\r\n\t\t\tupdate: async (id, input, headers) => fetch(`/store/wishlists/${id}`, {method: 'PUT', body: input, headers}),\r\n\t\t\tdelete: async (id, headers) => fetch(`/store/wishlists/${id}`, {method: 'DELETE', headers}),\r\n\t\t\tlistItems: async (id, query, headers) => fetch(`/store/wishlists/${id}/items${toQueryString(query)}`, {method: 'GET', headers}),\r\n\t\t\taddItem: async (id, input, headers) => fetch(`/store/wishlists/${id}/items`, {method: 'POST', body: input, headers}),\r\n\t\t\tremoveItem: async (id, itemId, headers) => fetch(`/store/wishlists/${id}/items/${itemId}`, {method: 'DELETE', headers}),\r\n\t\t\tgenerateShareToken: async (id, headers) => fetch(`/store/wishlists/${id}/share`, {method: 'POST', headers}),\r\n\t\t\ttransfer: async (id, headers) => fetch(`/store/wishlists/${id}/transfer`, {method: 'POST', headers}),\r\n\t\t\timport: async (input, headers) => fetch('/store/wishlists/import', {method: 'POST', body: input, headers}),\r\n\t\t\tgetTotalItemsCount: async (query, headers) => fetch(`/store/wishlists/total-items-count${toQueryString(query)}`, {method: 'GET', headers})\r\n\t\t}\r\n\t}\r\n}\r\n","import Medusa from '@medusajs/js-sdk'\r\nexport * from './plugins'\r\n\r\nexport type StackdClientOptions = {\r\n\tgetAuthHeader?: () => Promise<Record<string, string>> | Record<string, string>\r\n}\r\n\r\nexport type StackdMedusaConfig = ConstructorParameters<typeof Medusa>[0]\r\n\r\nexport type Plugin<Name extends string, Endpoints> = {\r\n\tname: Name\r\n\tendpoints: (client: Medusa, options?: StackdClientOptions, medusaConfig?: StackdMedusaConfig) => Endpoints\r\n}\r\n\r\nexport type PluginsToStackd<T extends readonly Plugin<any, any>[]> = {\r\n\t[K in T[number] as K['name']]: ReturnType<K['endpoints']>\r\n}\r\n\r\nexport class StackdMedusaSdk<TPlugins extends readonly Plugin<any, any>[]> extends Medusa {\r\n\tpublic stackd: PluginsToStackd<TPlugins>\r\n\tprotected options?: StackdClientOptions\r\n\tprotected medusaConfig: StackdMedusaConfig\r\n\r\n\tconstructor(medusaOptions: StackdMedusaConfig, plugins: TPlugins, options?: StackdClientOptions) {\r\n\t\tsuper(medusaOptions)\r\n\t\tthis.options = options\r\n\t\tthis.medusaConfig = medusaOptions\r\n\r\n\t\tconst endpoints: Record<string, any> = {}\r\n\t\tplugins.forEach(plugin => {\r\n\t\t\tendpoints[plugin.name] = plugin.endpoints(this, this.options, this.medusaConfig)\r\n\t\t})\r\n\t\tthis.stackd = endpoints as PluginsToStackd<TPlugins>\r\n\t}\r\n}\r\n"]}
package/dist/index.mjs ADDED
@@ -0,0 +1,2 @@
1
+ import l from'@medusajs/js-sdk';var a=(o,n)=>async(s,e)=>{let{method:t,headers:i}=e;return o.client.fetch(s,{method:t,..."body"in e&&{body:e.body},headers:{...await n?.getAuthHeader?.(),...i}})},r=o=>{if(!o)return "";let n=Object.entries(o).filter(([,e])=>e!=null);if(n.length===0)return "";let s=new URLSearchParams;return n.forEach(([e,t])=>{Array.isArray(t)?t.forEach(i=>s.append(e,String(i))):s.append(e,String(t));}),`?${s.toString()}`};var p={name:"emailVerification",endpoints:(o,n)=>{let s=a(o,n);return {sendVerificationEmail:async(e,t)=>s("/store/email/verify/send",{method:"POST",body:e,headers:t}),verifyToken:async(e,t)=>s("/store/email/verify",{method:"POST",body:e,headers:t}),getVerificationStatus:async e=>s("/store/email/verify/status",{method:"GET",headers:e})}}};var y={name:"wishlist",endpoints:(o,n)=>{let s=a(o,n);return {list:async(e,t)=>s(`/store/wishlists${r(e)}`,{method:"GET",headers:t}),create:async(e,t)=>s("/store/wishlists",{method:"POST",body:e,headers:t}),retrieve:async(e,t,i)=>s(`/store/wishlists/${e}${r(t)}`,{method:"GET",headers:i}),update:async(e,t,i)=>s(`/store/wishlists/${e}`,{method:"PUT",body:t,headers:i}),delete:async(e,t)=>s(`/store/wishlists/${e}`,{method:"DELETE",headers:t}),listItems:async(e,t,i)=>s(`/store/wishlists/${e}/items${r(t)}`,{method:"GET",headers:i}),addItem:async(e,t,i)=>s(`/store/wishlists/${e}/items`,{method:"POST",body:t,headers:i}),removeItem:async(e,t,i)=>s(`/store/wishlists/${e}/items/${t}`,{method:"DELETE",headers:i}),generateShareToken:async(e,t)=>s(`/store/wishlists/${e}/share`,{method:"POST",headers:t}),transfer:async(e,t)=>s(`/store/wishlists/${e}/transfer`,{method:"POST",headers:t}),import:async(e,t)=>s("/store/wishlists/import",{method:"POST",body:e,headers:t}),getTotalItemsCount:async(e,t)=>s(`/store/wishlists/total-items-count${r(e)}`,{method:"GET",headers:t})}}};var d=class extends l{constructor(n,s,e){super(n),this.options=e,this.medusaConfig=n;let t={};s.forEach(i=>{t[i.name]=i.endpoints(this,this.options,this.medusaConfig);}),this.stackd=t;}};export{d as StackdMedusaSdk,p as emailVerificationPlugin,y as wishlistPlugin};//# sourceMappingURL=index.mjs.map
2
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/utils/http.ts","../src/plugins/email-verification/plugin.ts","../src/plugins/wishlist/plugin.ts","../src/index.ts"],"names":["createFetch","sdk","options","path","opts","method","headers","toQueryString","params","entries","v","searchParams","k","item","emailVerificationPlugin","fetch","input","wishlistPlugin","query","id","itemId","StackdMedusaSdk","Medusa","medusaOptions","plugins","endpoints","plugin"],"mappings":"gCAkBO,IAAMA,CAAAA,CACZ,CAACC,EAAaC,CAAAA,GACd,MAAUC,CAAAA,CAAcC,CAAAA,GAAyC,CAChE,GAAM,CAAC,MAAA,CAAAC,CAAAA,CAAQ,OAAA,CAAAC,CAAO,CAAA,CAAIF,CAAAA,CAC1B,OAAOH,CAAAA,CAAI,MAAA,CAAO,KAAA,CAASE,CAAAA,CAAM,CAChC,MAAA,CAAAE,EACA,GAAI,MAAA,GAAUD,CAAA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,MAAA,CAAQ,KAAMC,CAAAA,CAAO,OAAA,CAAAV,CAAO,CAAC,CAAA,CACzG,kBAAA,CAAoB,MAAOY,CAAAA,CAAOZ,CAAAA,GAAYS,CAAAA,CAAM,CAAA,kCAAA,EAAqCR,CAAAA,CAAcW,CAAK,CAAC,GAAI,CAAC,MAAA,CAAQ,KAAA,CAAO,OAAA,CAAAZ,CAAO,CAAC,CAC1I,CACD,CACD,EC3DO,IAAMe,CAAAA,CAAN,cAA4EC,CAAO,CAKzF,WAAA,CAAYC,CAAAA,CAAmCC,CAAAA,CAAmBtB,CAAAA,CAA+B,CAChG,MAAMqB,CAAa,CAAA,CACnB,IAAA,CAAK,OAAA,CAAUrB,CAAAA,CACf,IAAA,CAAK,aAAeqB,CAAAA,CAEpB,IAAME,CAAAA,CAAiC,EAAC,CACxCD,CAAAA,CAAQ,QAAQE,CAAAA,EAAU,CACzBD,CAAAA,CAAUC,CAAAA,CAAO,IAAI,CAAA,CAAIA,EAAO,SAAA,CAAU,IAAA,CAAM,IAAA,CAAK,OAAA,CAAS,IAAA,CAAK,YAAY,EAChF,CAAC,CAAA,CACD,IAAA,CAAK,MAAA,CAASD,EACf,CACD","file":"index.mjs","sourcesContent":["import Medusa, {ClientHeaders} from '@medusajs/js-sdk'\r\nimport type {StackdClientOptions} from '..'\r\n\r\ntype StackdFetchWithBody = {\r\n\tmethod: 'POST' | 'PUT' | 'PATCH'\r\n\tbody?: Record<string, any>\r\n\theaders?: ClientHeaders\r\n}\r\n\r\ntype StackdFetchWithoutBody = {\r\n\tmethod: 'GET' | 'DELETE'\r\n\theaders?: ClientHeaders\r\n}\r\n\r\ntype StackdFetchOptions = StackdFetchWithBody | StackdFetchWithoutBody\r\n\r\ntype StackdFetch = <T>(path: string, options: StackdFetchOptions) => Promise<T>\r\n\r\nexport const createFetch =\r\n\t(sdk: Medusa, options?: StackdClientOptions): StackdFetch =>\r\n\tasync <T>(path: string, opts: StackdFetchOptions): Promise<T> => {\r\n\t\tconst {method, headers} = opts\r\n\t\treturn sdk.client.fetch<T>(path, {\r\n\t\t\tmethod,\r\n\t\t\t...('body' in opts && {body: opts.body}),\r\n\t\t\theaders: {\r\n\t\t\t\t...(await options?.getAuthHeader?.()),\r\n\t\t\t\t...headers\r\n\t\t\t}\r\n\t\t})\r\n\t}\r\n\r\nexport const toQueryString = (params?: Record<string, unknown>): string => {\r\n\tif (!params) {\r\n\t\treturn ''\r\n\t}\r\n\tconst entries = Object.entries(params).filter(([, v]) => v !== undefined && v !== null)\r\n\tif (entries.length === 0) {\r\n\t\treturn ''\r\n\t}\r\n\tconst searchParams = new URLSearchParams()\r\n\tentries.forEach(([k, v]) => {\r\n\t\tif (Array.isArray(v)) {\r\n\t\t\tv.forEach(item => searchParams.append(k, String(item)))\r\n\t\t} else {\r\n\t\t\tsearchParams.append(k, String(v))\r\n\t\t}\r\n\t})\r\n\treturn `?${searchParams.toString()}`\r\n}\r\n","import Medusa, {ClientHeaders} from '@medusajs/js-sdk'\r\nimport type {\r\n\tSendVerificationEmailRequest,\r\n\tSendVerificationEmailResponse,\r\n\tVerifyEmailTokenRequest,\r\n\tVerifyEmailTokenResponse,\r\n\tEmailVerificationStatusResponse\r\n} from '@stackd-solutions/medusa-email-verification'\r\nimport {StackdClientOptions, Plugin} from '../..'\r\nimport {createFetch} from '../../utils/http'\r\n\r\nexport type {\r\n\tSendVerificationEmailRequest,\r\n\tSendVerificationEmailResponse,\r\n\tVerifyEmailTokenRequest,\r\n\tVerifyEmailTokenResponse,\r\n\tEmailVerificationStatusResponse\r\n}\r\n\r\ntype EmailVerificationEndpoints = {\r\n\tsendVerificationEmail: (input: SendVerificationEmailRequest, headers?: ClientHeaders) => Promise<SendVerificationEmailResponse>\r\n\tverifyToken: (input: VerifyEmailTokenRequest, headers?: ClientHeaders) => Promise<VerifyEmailTokenResponse>\r\n\tgetVerificationStatus: (headers?: ClientHeaders) => Promise<EmailVerificationStatusResponse>\r\n}\r\n\r\nexport const emailVerificationPlugin: Plugin<'emailVerification', EmailVerificationEndpoints> = {\r\n\tname: 'emailVerification' as const,\r\n\tendpoints: (sdk: Medusa, options?: StackdClientOptions) => {\r\n\t\tconst fetch = createFetch(sdk, options)\r\n\r\n\t\treturn {\r\n\t\t\tsendVerificationEmail: async (input, headers) => fetch('/store/email/verify/send', {method: 'POST', body: input, headers}),\r\n\t\t\tverifyToken: async (input, headers) => fetch('/store/email/verify', {method: 'POST', body: input, headers}),\r\n\t\t\tgetVerificationStatus: async headers => fetch('/store/email/verify/status', {method: 'GET', headers})\r\n\t\t}\r\n\t}\r\n}\r\n","import Medusa, {ClientHeaders} from '@medusajs/js-sdk'\r\nimport type {\r\n\tWishlist,\r\n\tWishlistItem,\r\n\tPaginatedWishlistResponse,\r\n\tPaginatedWishlistItemResponse,\r\n\tCreateWishlistRequest,\r\n\tUpdateWishlistRequest,\r\n\tAddItemToWishlistRequest,\r\n\tImportWishlistRequest,\r\n\tShareTokenResponse,\r\n\tDeleteResponse,\r\n\tTotalItemsCountResponse,\r\n\tListWishlistsQuery,\r\n\tRetrieveWishlistQuery,\r\n\tTotalItemsCountQuery\r\n} from '@stackd-solutions/medusa-wishlist'\r\nimport {StackdClientOptions, Plugin} from '../..'\r\nimport {createFetch, toQueryString} from '../../utils/http'\r\n\r\nexport type {\r\n\tWishlist,\r\n\tWishlistItem,\r\n\tPaginatedWishlistResponse,\r\n\tPaginatedWishlistItemResponse,\r\n\tCreateWishlistRequest,\r\n\tUpdateWishlistRequest,\r\n\tAddItemToWishlistRequest,\r\n\tImportWishlistRequest,\r\n\tShareTokenResponse,\r\n\tDeleteResponse,\r\n\tTotalItemsCountResponse,\r\n\tListWishlistsQuery,\r\n\tRetrieveWishlistQuery,\r\n\tTotalItemsCountQuery\r\n}\r\n\r\nexport type ListItemsQuery = {\r\n\tlimit?: number\r\n\toffset?: number\r\n}\r\n\r\ntype WishlistEndpoints = {\r\n\tlist: (query?: ListWishlistsQuery, headers?: ClientHeaders) => Promise<PaginatedWishlistResponse>\r\n\tcreate: (input: CreateWishlistRequest, headers?: ClientHeaders) => Promise<Wishlist>\r\n\tretrieve: (id: string, query?: RetrieveWishlistQuery, headers?: ClientHeaders) => Promise<Wishlist>\r\n\tupdate: (id: string, input: UpdateWishlistRequest, headers?: ClientHeaders) => Promise<Wishlist>\r\n\tdelete: (id: string, headers?: ClientHeaders) => Promise<DeleteResponse>\r\n\tlistItems: (id: string, query?: ListItemsQuery, headers?: ClientHeaders) => Promise<PaginatedWishlistItemResponse>\r\n\taddItem: (id: string, input: AddItemToWishlistRequest, headers?: ClientHeaders) => Promise<WishlistItem>\r\n\tremoveItem: (id: string, itemId: string, headers?: ClientHeaders) => Promise<DeleteResponse>\r\n\tgenerateShareToken: (id: string, headers?: ClientHeaders) => Promise<ShareTokenResponse>\r\n\ttransfer: (id: string, headers?: ClientHeaders) => Promise<Wishlist>\r\n\timport: (input: ImportWishlistRequest, headers?: ClientHeaders) => Promise<Wishlist>\r\n\tgetTotalItemsCount: (query?: TotalItemsCountQuery, headers?: ClientHeaders) => Promise<TotalItemsCountResponse>\r\n}\r\n\r\nexport const wishlistPlugin: Plugin<'wishlist', WishlistEndpoints> = {\r\n\tname: 'wishlist' as const,\r\n\tendpoints: (sdk: Medusa, options?: StackdClientOptions) => {\r\n\t\tconst fetch = createFetch(sdk, options)\r\n\r\n\t\treturn {\r\n\t\t\tlist: async (query, headers) => fetch(`/store/wishlists${toQueryString(query)}`, {method: 'GET', headers}),\r\n\t\t\tcreate: async (input, headers) => fetch('/store/wishlists', {method: 'POST', body: input, headers}),\r\n\t\t\tretrieve: async (id, query, headers) => fetch(`/store/wishlists/${id}${toQueryString(query)}`, {method: 'GET', headers}),\r\n\t\t\tupdate: async (id, input, headers) => fetch(`/store/wishlists/${id}`, {method: 'PUT', body: input, headers}),\r\n\t\t\tdelete: async (id, headers) => fetch(`/store/wishlists/${id}`, {method: 'DELETE', headers}),\r\n\t\t\tlistItems: async (id, query, headers) => fetch(`/store/wishlists/${id}/items${toQueryString(query)}`, {method: 'GET', headers}),\r\n\t\t\taddItem: async (id, input, headers) => fetch(`/store/wishlists/${id}/items`, {method: 'POST', body: input, headers}),\r\n\t\t\tremoveItem: async (id, itemId, headers) => fetch(`/store/wishlists/${id}/items/${itemId}`, {method: 'DELETE', headers}),\r\n\t\t\tgenerateShareToken: async (id, headers) => fetch(`/store/wishlists/${id}/share`, {method: 'POST', headers}),\r\n\t\t\ttransfer: async (id, headers) => fetch(`/store/wishlists/${id}/transfer`, {method: 'POST', headers}),\r\n\t\t\timport: async (input, headers) => fetch('/store/wishlists/import', {method: 'POST', body: input, headers}),\r\n\t\t\tgetTotalItemsCount: async (query, headers) => fetch(`/store/wishlists/total-items-count${toQueryString(query)}`, {method: 'GET', headers})\r\n\t\t}\r\n\t}\r\n}\r\n","import Medusa from '@medusajs/js-sdk'\r\nexport * from './plugins'\r\n\r\nexport type StackdClientOptions = {\r\n\tgetAuthHeader?: () => Promise<Record<string, string>> | Record<string, string>\r\n}\r\n\r\nexport type StackdMedusaConfig = ConstructorParameters<typeof Medusa>[0]\r\n\r\nexport type Plugin<Name extends string, Endpoints> = {\r\n\tname: Name\r\n\tendpoints: (client: Medusa, options?: StackdClientOptions, medusaConfig?: StackdMedusaConfig) => Endpoints\r\n}\r\n\r\nexport type PluginsToStackd<T extends readonly Plugin<any, any>[]> = {\r\n\t[K in T[number] as K['name']]: ReturnType<K['endpoints']>\r\n}\r\n\r\nexport class StackdMedusaSdk<TPlugins extends readonly Plugin<any, any>[]> extends Medusa {\r\n\tpublic stackd: PluginsToStackd<TPlugins>\r\n\tprotected options?: StackdClientOptions\r\n\tprotected medusaConfig: StackdMedusaConfig\r\n\r\n\tconstructor(medusaOptions: StackdMedusaConfig, plugins: TPlugins, options?: StackdClientOptions) {\r\n\t\tsuper(medusaOptions)\r\n\t\tthis.options = options\r\n\t\tthis.medusaConfig = medusaOptions\r\n\r\n\t\tconst endpoints: Record<string, any> = {}\r\n\t\tplugins.forEach(plugin => {\r\n\t\t\tendpoints[plugin.name] = plugin.endpoints(this, this.options, this.medusaConfig)\r\n\t\t})\r\n\t\tthis.stackd = endpoints as PluginsToStackd<TPlugins>\r\n\t}\r\n}\r\n"]}
package/package.json ADDED
@@ -0,0 +1,64 @@
1
+ {
2
+ "name": "@stackd-solutions/medusa-sdk",
3
+ "version": "0.1.0",
4
+ "description": "Extended Medusa SDK client",
5
+ "author": "StackD Solutions (https://stackd-solutions.io)",
6
+ "license": "Apache-2.0",
7
+ "main": "dist/index.js",
8
+ "module": "dist/index.mjs",
9
+ "types": "dist/index.d.ts",
10
+ "files": [
11
+ "dist"
12
+ ],
13
+ "exports": {
14
+ ".": {
15
+ "types": "./dist/index.d.ts",
16
+ "import": "./dist/index.mjs",
17
+ "require": "./dist/index.js",
18
+ "default": "./dist/index.js"
19
+ },
20
+ "./package.json": "./package.json"
21
+ },
22
+ "repository": {
23
+ "type": "git",
24
+ "url": "git+ssh://git@github.com/StackD-Solutions/medusa-sdk.git"
25
+ },
26
+ "keywords": [
27
+ "medusa",
28
+ "medusa-sdk",
29
+ "ecommerce",
30
+ "email-verification",
31
+ "wishlist"
32
+ ],
33
+ "scripts": {
34
+ "build": "tsup",
35
+ "dev": "tsup --watch",
36
+ "lint": "eslint src --ext .ts",
37
+ "fix:prettier": "prettier --write .",
38
+ "test": "jest",
39
+ "test:coverage": "jest --coverage"
40
+ },
41
+ "peerDependencies": {
42
+ "@medusajs/js-sdk": "^2.13.5"
43
+ },
44
+ "devDependencies": {
45
+ "@medusajs/js-sdk": "2.13.5",
46
+ "@stackd-solutions/medusa-email-verification": "^0.1.3",
47
+ "@stackd-solutions/medusa-wishlist": "^0.1.1",
48
+ "@swc/core": "^1.15.24",
49
+ "@swc/jest": "^0.2.39",
50
+ "@types/jest": "^30.0.0",
51
+ "eslint": "^10.1.0",
52
+ "jest": "^30.3.0",
53
+ "prettier": "^3",
54
+ "ts-node": "^10.9.2",
55
+ "tsup": "^8.0.0",
56
+ "typescript": "^5.6.2"
57
+ },
58
+ "engines": {
59
+ "node": ">=20"
60
+ },
61
+ "publishConfig": {
62
+ "access": "public"
63
+ }
64
+ }