@medusajs/js-sdk 2.6.2-snapshot-20250328151043 → 2.7.0-preview-20250411080918
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/dist/admin/draft-order.d.ts +285 -4
- package/dist/admin/draft-order.d.ts.map +1 -1
- package/dist/admin/draft-order.js +369 -4
- package/dist/admin/draft-order.js.map +1 -1
- package/dist/admin/plugin.d.ts +18 -0
- package/dist/admin/plugin.d.ts.map +1 -1
- package/dist/admin/plugin.js +15 -0
- package/dist/admin/plugin.js.map +1 -1
- package/dist/auth/index.d.ts +87 -23
- package/dist/auth/index.d.ts.map +1 -1
- package/dist/auth/index.js +87 -23
- package/dist/auth/index.js.map +1 -1
- package/dist/esm/admin/draft-order.d.ts +285 -4
- package/dist/esm/admin/draft-order.d.ts.map +1 -1
- package/dist/esm/admin/draft-order.js +399 -4
- package/dist/esm/admin/draft-order.js.map +1 -1
- package/dist/esm/admin/plugin.d.ts +18 -0
- package/dist/esm/admin/plugin.d.ts.map +1 -1
- package/dist/esm/admin/plugin.js +15 -0
- package/dist/esm/admin/plugin.js.map +1 -1
- package/dist/esm/auth/index.d.ts +87 -23
- package/dist/esm/auth/index.d.ts.map +1 -1
- package/dist/esm/auth/index.js +87 -23
- package/dist/esm/auth/index.js.map +1 -1
- package/package.json +2 -2
package/dist/auth/index.js
CHANGED
@@ -7,6 +7,12 @@ class Auth {
|
|
7
7
|
* This method is used to retrieve a registration JWT token for a user, customer, or custom actor type. It sends a request to the
|
8
8
|
* [Retrieve Registration Token API route](https://docs.medusajs.com/api/store#auth_postactor_typeauth_provider_register).
|
9
9
|
*
|
10
|
+
* Then, it stores the returned token and passes it in the header of subsequent requests. So, you can call the
|
11
|
+
* [store.customer.create](https://docs.medusajs.com/resources/references/js-sdk/store/customer#create) method,
|
12
|
+
* for example, after calling this method.
|
13
|
+
*
|
14
|
+
* Learn more in the [JS SDK Authentication](https://docs.medusajs.com/resources/js-sdk/auth/overview) guide.
|
15
|
+
*
|
10
16
|
* @param actor - The actor type. For example, `user` for admin user, or `customer` for customer.
|
11
17
|
* @param method - The authentication provider to use. For example, `emailpass` or `google`.
|
12
18
|
* @param payload - The data to pass in the request's body for authentication. When using the `emailpass` provider,
|
@@ -16,15 +22,19 @@ class Auth {
|
|
16
22
|
* @tags auth
|
17
23
|
*
|
18
24
|
* @example
|
19
|
-
* sdk.auth.register(
|
25
|
+
* await sdk.auth.register(
|
20
26
|
* "customer",
|
21
27
|
* "emailpass",
|
22
28
|
* {
|
23
29
|
* email: "customer@gmail.com",
|
24
30
|
* password: "supersecret"
|
25
31
|
* }
|
26
|
-
* )
|
27
|
-
*
|
32
|
+
* )
|
33
|
+
*
|
34
|
+
* // all subsequent requests will use the token in the header
|
35
|
+
* const { customer } = await sdk.store.customer.create({
|
36
|
+
* email: "customer@gmail.com",
|
37
|
+
* password: "supersecret"
|
28
38
|
* })
|
29
39
|
*/
|
30
40
|
this.register = async (actor, method, payload) => {
|
@@ -39,11 +49,32 @@ class Auth {
|
|
39
49
|
* This method retrieves the JWT authenticated token for an admin user, customer, or custom
|
40
50
|
* actor type. It sends a request to the [Authenticate API Route](https://docs.medusajs.com/api/admin#auth_postactor_typeauth_provider).
|
41
51
|
*
|
52
|
+
* ### Third-Party Authentication
|
53
|
+
*
|
54
|
+
* If the API route returns a `location` property, it means that the authentication requires additional steps,
|
55
|
+
* typically in a third-party service. The `location` property is returned so that you
|
56
|
+
* can redirect the user to the appropriate page.
|
57
|
+
*
|
58
|
+
* :::note
|
59
|
+
*
|
60
|
+
* For an example of implementing third-party authentication, refer to the
|
61
|
+
* [Third-Party Login in Storefront](https://docs.medusajs.com/resources/storefront-development/customers/third-party-login) guide.
|
62
|
+
*
|
63
|
+
* :::
|
64
|
+
*
|
65
|
+
* ### Session Authentication
|
66
|
+
*
|
42
67
|
* If the `auth.type` of the SDK is set to `session`, this method will also send a request to the
|
43
68
|
* [Set Authentication Session API route](https://docs.medusajs.com/api/admin#auth_postsession).
|
44
69
|
*
|
45
|
-
*
|
46
|
-
*
|
70
|
+
* Learn more in the [JS SDK Authentication](https://docs.medusajs.com/resources/js-sdk/auth/overview) guide.
|
71
|
+
*
|
72
|
+
* ### Automatic Authentication
|
73
|
+
*
|
74
|
+
* If the authentication was successful, subsequent requests using the SDK will automatically have the necessary authentication headers / session
|
75
|
+
* set, based on your JS SDK authentication configurations.
|
76
|
+
*
|
77
|
+
* Learn more in the [JS SDK Authentication](https://docs.medusajs.com/resources/js-sdk/auth/overview) guide.
|
47
78
|
*
|
48
79
|
* @param actor - The actor type. For example, `user` for admin user, or `customer` for customer.
|
49
80
|
* @param method - The authentication provider to use. For example, `emailpass` or `google`.
|
@@ -54,16 +85,25 @@ class Auth {
|
|
54
85
|
* @tags auth
|
55
86
|
*
|
56
87
|
* @example
|
57
|
-
* sdk.auth.login(
|
88
|
+
* const result = await sdk.auth.login(
|
58
89
|
* "customer",
|
59
90
|
* "emailpass",
|
60
91
|
* {
|
61
92
|
* email: "customer@gmail.com",
|
62
93
|
* password: "supersecret"
|
63
94
|
* }
|
64
|
-
* )
|
65
|
-
*
|
66
|
-
*
|
95
|
+
* )
|
96
|
+
*
|
97
|
+
* if (typeof result !== "string") {
|
98
|
+
* alert("Authentication requires additional steps")
|
99
|
+
* // replace with the redirect logic of your application
|
100
|
+
* window.location.href = result.location
|
101
|
+
* return
|
102
|
+
* }
|
103
|
+
*
|
104
|
+
* // customer is now authenticated
|
105
|
+
* // all subsequent requests will use the token in the header
|
106
|
+
* const { customer } = await sdk.store.customer.retrieve()
|
67
107
|
*/
|
68
108
|
this.login = async (actor, method, payload) => {
|
69
109
|
// There will either be token or location returned from the backend.
|
@@ -83,6 +123,12 @@ class Auth {
|
|
83
123
|
* This method is used to validate an Oauth callback from a third-party service, such as Google, for an admin user, customer, or custom actor types.
|
84
124
|
* It sends a request to the [Validate Authentication Callback](https://docs.medusajs.com/api/admin#auth_postactor_typeauth_providercallback).
|
85
125
|
*
|
126
|
+
* The method stores the returned token and passes it in the header of subsequent requests. So, you can call the
|
127
|
+
* [store.customer.create](https://docs.medusajs.com/resources/references/js-sdk/store/customer#create) or {@link refresh} methods,
|
128
|
+
* for example, after calling this method.
|
129
|
+
*
|
130
|
+
* Learn more in the [JS SDK Authentication](https://docs.medusajs.com/resources/js-sdk/auth/overview) guide.
|
131
|
+
*
|
86
132
|
* @param actor - The actor type. For example, `user` for admin user, or `customer` for customer.
|
87
133
|
* @param method - The authentication provider to use. For example, `google`.
|
88
134
|
* @param query - The query parameters from the Oauth callback, which should be passed to the API route. This includes query parameters like
|
@@ -92,17 +138,20 @@ class Auth {
|
|
92
138
|
* @tags auth
|
93
139
|
*
|
94
140
|
* @example
|
95
|
-
* sdk.auth.callback(
|
141
|
+
* await sdk.auth.callback(
|
96
142
|
* "customer",
|
97
143
|
* "google",
|
98
144
|
* {
|
99
145
|
* code: "123",
|
100
146
|
* state: "456"
|
101
147
|
* }
|
102
|
-
* )
|
103
|
-
* console.log(token)
|
104
|
-
* })
|
148
|
+
* )
|
105
149
|
*
|
150
|
+
* // all subsequent requests will use the token in the header
|
151
|
+
* const { customer } = await sdk.store.customer.create({
|
152
|
+
* email: "customer@gmail.com",
|
153
|
+
* password: "supersecret"
|
154
|
+
* })
|
106
155
|
*
|
107
156
|
* @privateRemarks
|
108
157
|
* The callback expects all query parameters from the Oauth callback to be passed to
|
@@ -120,15 +169,24 @@ class Auth {
|
|
120
169
|
* This method refreshes a JWT authentication token, which is useful after validating the Oauth callback
|
121
170
|
* with {@link callback}. It sends a request to the [Refresh Authentication Token API route](https://docs.medusajs.com/api/admin#auth_postadminauthtokenrefresh).
|
122
171
|
*
|
172
|
+
* The method stores the returned token and passes it in the header of subsequent requests. So, you can call other
|
173
|
+
* methods that require authentication after calling this method.
|
174
|
+
*
|
175
|
+
* Learn more in the [JS SDK Authentication](https://docs.medusajs.com/resources/js-sdk/auth/overview) guide.
|
176
|
+
*
|
177
|
+
* For an example of implementing third-party authentication, refer to the
|
178
|
+
* [Third-Party Login in Storefront](https://docs.medusajs.com/resources/storefront-development/customers/third-party-login) guide.
|
179
|
+
*
|
180
|
+
*
|
123
181
|
* @returns The refreshed JWT authentication token.
|
124
182
|
*
|
125
183
|
* @tags auth
|
126
184
|
*
|
127
185
|
* @example
|
128
|
-
* sdk.auth.refresh()
|
129
|
-
*
|
130
|
-
*
|
131
|
-
* })
|
186
|
+
* const token = await sdk.auth.refresh()
|
187
|
+
*
|
188
|
+
* // all subsequent requests will use the token in the header
|
189
|
+
* const { customer } = await sdk.store.customer.retrieve()
|
132
190
|
*/
|
133
191
|
this.refresh = async () => {
|
134
192
|
const { token } = await this.client.fetch("/auth/token/refresh", {
|
@@ -140,16 +198,22 @@ class Auth {
|
|
140
198
|
return token;
|
141
199
|
};
|
142
200
|
/**
|
143
|
-
* This method
|
144
|
-
*
|
201
|
+
* This method logs out the currently authenticated user based on your JS SDK authentication configurations.
|
202
|
+
*
|
203
|
+
* If the `auth.type` of the SDK is set to `session`, this method will also send a request to the
|
204
|
+
* [Delete Authentication Session API route](https://docs.medusajs.com/api/admin#auth_deletesession).
|
205
|
+
*
|
206
|
+
* The method also clears any stored tokens or sessions, based on your JS SDK authentication configurations.
|
207
|
+
*
|
208
|
+
* Learn more in the [JS SDK Authentication](https://docs.medusajs.com/resources/js-sdk/auth/overview) guide.
|
145
209
|
*
|
146
210
|
* @tags auth
|
147
211
|
*
|
148
212
|
* @example
|
149
|
-
* sdk.auth.logout()
|
150
|
-
*
|
151
|
-
*
|
152
|
-
*
|
213
|
+
* await sdk.auth.logout()
|
214
|
+
*
|
215
|
+
* // user is now logged out
|
216
|
+
* // you can't send any requests that require authentication
|
153
217
|
*/
|
154
218
|
this.logout = async () => {
|
155
219
|
if (this.config?.auth?.type === "session") {
|
package/dist/auth/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/auth/index.ts"],"names":[],"mappings":";;;AAIA,MAAa,IAAI;IA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BAAuB;aAC3D,CAAC,CAAA;QACJ,CAAC,CAAA;QAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;WA6BG;QACH,mBAAc,GAAG,KAAK,EACpB,KAAa,EACb,QAAgB,EAChB,IAAmC,EACnC,KAAa,EACb,EAAE;YACF,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,KAAK,IAAI,QAAQ,SAAS,EAAE;gBAC3D,MAAM,EAAE,MAAM;gBACd,IAAI;gBACJ,OAAO,EAAE,EAAE,aAAa,EAAE,UAAU,KAAK,EAAE,EAAE;aAC9C,CAAC,CAAA;QACJ,CAAC,CAAA;QAED;;WAEG;QACK,cAAS,GAAG,KAAK,EAAE,KAAa,EAAE,EAAE;YAC1C,wIAAwI;YACxI,IAAI,IAAI,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,KAAK,SAAS,EAAE,CAAC;gBAC1C,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,eAAe,EAAE;oBACvC,MAAM,EAAE,MAAM;oBACd,OAAO,EAAE,EAAE,aAAa,EAAE,UAAU,KAAK,EAAE,EAAE;iBAC9C,CAAC,CAAA;YACJ,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;YAC7B,CAAC;QACH,CAAC,CAAA;QAxWC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;IACtB,CAAC;CAuWF;AA9WD,oBA8WC"}
|
@@ -24,7 +24,7 @@ export declare class DraftOrder {
|
|
24
24
|
* To retrieve a draft order by its ID:
|
25
25
|
*
|
26
26
|
* ```ts
|
27
|
-
* sdk.admin.draftOrder.retrieve("
|
27
|
+
* sdk.admin.draftOrder.retrieve("order_123")
|
28
28
|
* .then(({ draft_order }) => {
|
29
29
|
* console.log(draft_order)
|
30
30
|
* })
|
@@ -33,7 +33,7 @@ export declare class DraftOrder {
|
|
33
33
|
* To specify the fields and relations to retrieve:
|
34
34
|
*
|
35
35
|
* ```ts
|
36
|
-
* sdk.admin.draftOrder.retrieve("
|
36
|
+
* sdk.admin.draftOrder.retrieve("order_123", {
|
37
37
|
* fields: "id,*items"
|
38
38
|
* })
|
39
39
|
* .then(({ draft_order }) => {
|
@@ -112,7 +112,7 @@ export declare class DraftOrder {
|
|
112
112
|
* },
|
113
113
|
* ],
|
114
114
|
* region_id: "region_123",
|
115
|
-
* sales_channel_id: "
|
115
|
+
* sales_channel_id: "sc_123",
|
116
116
|
* })
|
117
117
|
* .then(({ draft_order }) => {
|
118
118
|
* console.log(draft_order)
|
@@ -133,7 +133,7 @@ export declare class DraftOrder {
|
|
133
133
|
* To update a draft order:
|
134
134
|
*
|
135
135
|
* ```ts
|
136
|
-
* sdk.admin.draftOrder.update("
|
136
|
+
* sdk.admin.draftOrder.update("order_123", {
|
137
137
|
* email: "test@test.com",
|
138
138
|
* })
|
139
139
|
* .then(({ draft_order }) => {
|
@@ -142,5 +142,286 @@ export declare class DraftOrder {
|
|
142
142
|
* ```
|
143
143
|
*/
|
144
144
|
update(id: string, body: HttpTypes.AdminUpdateDraftOrder, query?: HttpTypes.AdminDraftOrderParams, headers?: ClientHeaders): Promise<HttpTypes.AdminDraftOrderResponse>;
|
145
|
+
/**
|
146
|
+
* This method converts a draft order to an order. It sends a request to the
|
147
|
+
* [Convert Draft Order to Order](https://docs.medusajs.com/api/admin#draft-orders_postdraftordersidconvert-to-order) API route.
|
148
|
+
*
|
149
|
+
* @param id - The draft order's ID.
|
150
|
+
* @param query - Configure the fields to retrieve in the order.
|
151
|
+
* @param headers - Headers to pass in the request.
|
152
|
+
*
|
153
|
+
* @example
|
154
|
+
* To convert a draft order to an order:
|
155
|
+
*
|
156
|
+
* ```ts
|
157
|
+
* sdk.admin.draftOrder.convertToOrder("order_123")
|
158
|
+
* .then(({ order }) => {
|
159
|
+
* console.log(order)
|
160
|
+
* })
|
161
|
+
*/
|
162
|
+
convertToOrder(id: string, query?: HttpTypes.AdminDraftOrderParams, headers?: ClientHeaders): Promise<HttpTypes.AdminOrderResponse>;
|
163
|
+
/**
|
164
|
+
* This method adds items to a draft order. It sends a request to the
|
165
|
+
* [Add Draft Order Items](https://docs.medusajs.com/api/admin#draft-orders_postordereditsiditems) API route.
|
166
|
+
*
|
167
|
+
* @param id - The draft order's ID.
|
168
|
+
* @param body - The data to add the items to the draft order.
|
169
|
+
* @param headers - Headers to pass in the request.
|
170
|
+
*
|
171
|
+
* @example
|
172
|
+
* To add items to a draft order:
|
173
|
+
*
|
174
|
+
* ```ts
|
175
|
+
* sdk.admin.draftOrder.addItems("order_123", {
|
176
|
+
* items: [
|
177
|
+
* {
|
178
|
+
* variant_id: "variant_123",
|
179
|
+
* quantity: 1,
|
180
|
+
* },
|
181
|
+
* ],
|
182
|
+
* })
|
183
|
+
* .then(({ draft_order_preview }) => {
|
184
|
+
* console.log(draft_order_preview)
|
185
|
+
* })
|
186
|
+
* ```
|
187
|
+
*/
|
188
|
+
addItems(id: string, body: HttpTypes.AdminAddDraftOrderItems, headers?: ClientHeaders): Promise<HttpTypes.AdminDraftOrderPreviewResponse>;
|
189
|
+
/**
|
190
|
+
* This method updates an item that is part of an action in a draft order. It sends a request to the
|
191
|
+
* [Update Draft Order Item](https://docs.medusajs.com/api/admin#draft-orders_postordereditsiditemsaction_id) API route.
|
192
|
+
*
|
193
|
+
* @param id - The draft order's ID.
|
194
|
+
* @param actionId - The action ID.
|
195
|
+
* @param body - The data to update the item.
|
196
|
+
* @param headers - Headers to pass in the request.
|
197
|
+
*
|
198
|
+
* @example
|
199
|
+
* To update an item that is part of an action in a draft order:
|
200
|
+
*
|
201
|
+
* ```ts
|
202
|
+
* sdk.admin.draftOrder.updateActionItem("order_123", "action_123", {
|
203
|
+
* quantity: 2,
|
204
|
+
* })
|
205
|
+
* .then(({ draft_order_preview }) => {
|
206
|
+
* console.log(draft_order_preview)
|
207
|
+
* })
|
208
|
+
* ```
|
209
|
+
*/
|
210
|
+
updateActionItem(id: string, actionId: string, body: HttpTypes.AdminUpdateDraftOrderItem, headers?: ClientHeaders): Promise<HttpTypes.AdminDraftOrderPreviewResponse>;
|
211
|
+
/**
|
212
|
+
* This method removes an item that is part of an action in a draft order. It sends a request to the
|
213
|
+
* [Remove Draft Order Item](https://docs.medusajs.com/api/admin#draft-orders_deleteordereditsiditemsaction_id) API route.
|
214
|
+
*
|
215
|
+
* @param id - The draft order's ID.
|
216
|
+
* @param actionId - The action ID.
|
217
|
+
* @param headers - Headers to pass in the request.
|
218
|
+
*
|
219
|
+
* @example
|
220
|
+
* To remove an item that is part of an action in a draft order:
|
221
|
+
*
|
222
|
+
* ```ts
|
223
|
+
* sdk.admin.draftOrder.removeActionItem("order_123", "action_123")
|
224
|
+
* .then(({ draft_order_preview }) => {
|
225
|
+
* console.log(draft_order_preview)
|
226
|
+
* })
|
227
|
+
* ```
|
228
|
+
*/
|
229
|
+
removeActionItem(id: string, actionId: string, headers?: ClientHeaders): Promise<HttpTypes.AdminDraftOrderPreviewResponse>;
|
230
|
+
/**
|
231
|
+
* This method updates an item in a draft order. It sends a request to the
|
232
|
+
* [Update Draft Order Item](https://docs.medusajs.com/api/admin#draft-orders_postordereditsiditemsitem_id) API route.
|
233
|
+
*
|
234
|
+
* @param id - The draft order's ID.
|
235
|
+
* @param itemId - The item ID.
|
236
|
+
* @param body - The data to update the item.
|
237
|
+
* @param headers - Headers to pass in the request.
|
238
|
+
*
|
239
|
+
* @example
|
240
|
+
* To update an item in a draft order:
|
241
|
+
*
|
242
|
+
* ```ts
|
243
|
+
* sdk.admin.draftOrder.updateItem("order_123", "item_123", {
|
244
|
+
* quantity: 2,
|
245
|
+
* })
|
246
|
+
* .then(({ draft_order_preview }) => {
|
247
|
+
* console.log(draft_order_preview)
|
248
|
+
* })
|
249
|
+
* ```
|
250
|
+
*/
|
251
|
+
updateItem(id: string, itemId: string, body: HttpTypes.AdminUpdateDraftOrderItem, headers?: ClientHeaders): Promise<HttpTypes.AdminDraftOrderPreviewResponse>;
|
252
|
+
/**
|
253
|
+
* This method adds promotions to a draft order. It sends a request to the
|
254
|
+
* [Add Draft Order Promotions](https://docs.medusajs.com/api/admin#draft-orders_postordereditsidpromotions) API route.
|
255
|
+
*
|
256
|
+
* @param id - The draft order's ID.
|
257
|
+
* @param body - The data to add the promotions to the draft order.
|
258
|
+
* @param headers - Headers to pass in the request.
|
259
|
+
*
|
260
|
+
* @example
|
261
|
+
* To add promotions to a draft order:
|
262
|
+
*
|
263
|
+
* ```ts
|
264
|
+
* sdk.admin.draftOrder.addPromotions("order_123", {
|
265
|
+
* promo_codes: ["PROMO_CODE_1", "PROMO_CODE_2"],
|
266
|
+
* })
|
267
|
+
* .then(({ draft_order_preview }) => {
|
268
|
+
* console.log(draft_order_preview)
|
269
|
+
* })
|
270
|
+
* ```
|
271
|
+
*/
|
272
|
+
addPromotions(id: string, body: HttpTypes.AdminAddDraftOrderPromotions, headers?: ClientHeaders): Promise<HttpTypes.AdminDraftOrderPreviewResponse>;
|
273
|
+
/**
|
274
|
+
* This method removes promotions from a draft order. It sends a request to the
|
275
|
+
* [Remove Draft Order Promotions](https://docs.medusajs.com/api/admin#draft-orders_deleteordereditsidpromotions) API route.
|
276
|
+
*
|
277
|
+
* @param id - The draft order's ID.
|
278
|
+
* @param body - The data to remove the promotions from the draft order.
|
279
|
+
* @param headers - Headers to pass in the request.
|
280
|
+
*
|
281
|
+
* @example
|
282
|
+
* To remove promotions from a draft order:
|
283
|
+
*
|
284
|
+
* ```ts
|
285
|
+
* sdk.admin.draftOrder.removePromotions("order_123", {
|
286
|
+
* promo_codes: ["PROMO_CODE_1", "PROMO_CODE_2"],
|
287
|
+
* })
|
288
|
+
* ```
|
289
|
+
*/
|
290
|
+
removePromotions(id: string, body: HttpTypes.AdminRemoveDraftOrderPromotions, headers?: ClientHeaders): Promise<HttpTypes.AdminDraftOrderPreviewResponse>;
|
291
|
+
/**
|
292
|
+
* This method adds a shipping method to a draft order. It sends a request to the
|
293
|
+
* [Add Draft Order Shipping Method](https://docs.medusajs.com/api/admin#draft-orders_postordereditsidshipping-methods) API route.
|
294
|
+
*
|
295
|
+
* @param id - The draft order's ID.
|
296
|
+
* @param body - The data to add the shipping method to the draft order.
|
297
|
+
* @param headers - Headers to pass in the request.
|
298
|
+
*
|
299
|
+
* @example
|
300
|
+
* To add a shipping method to a draft order:
|
301
|
+
*
|
302
|
+
* ```ts
|
303
|
+
* sdk.admin.draftOrder.addShippingMethod("order_123", {
|
304
|
+
* shipping_option_id: "shipping_option_123",
|
305
|
+
* })
|
306
|
+
* .then(({ draft_order_preview }) => {
|
307
|
+
* console.log(draft_order_preview)
|
308
|
+
* })
|
309
|
+
* ```
|
310
|
+
*/
|
311
|
+
addShippingMethod(id: string, body: HttpTypes.AdminAddDraftOrderShippingMethod, headers?: ClientHeaders): Promise<HttpTypes.AdminDraftOrderPreviewResponse>;
|
312
|
+
/**
|
313
|
+
* This method updates a shipping method in a draft order. It sends a request to the
|
314
|
+
* [Update Draft Order Shipping Method](https://docs.medusajs.com/api/admin#draft-orders_postordereditsidshipping-methodsaction_id) API route.
|
315
|
+
*
|
316
|
+
* @param id - The draft order's ID.
|
317
|
+
* @param actionId - The action ID.
|
318
|
+
* @param body - The data to update the shipping method.
|
319
|
+
* @param headers - Headers to pass in the request.
|
320
|
+
*
|
321
|
+
* @example
|
322
|
+
* To update a shipping method in a draft order:
|
323
|
+
*
|
324
|
+
* ```ts
|
325
|
+
* sdk.admin.draftOrder.updateShippingMethod("order_123", "action_123", {
|
326
|
+
* shipping_option_id: "shipping_option_123",
|
327
|
+
* })
|
328
|
+
* .then(({ draft_order_preview }) => {
|
329
|
+
* console.log(draft_order_preview)
|
330
|
+
* })
|
331
|
+
* ```
|
332
|
+
*/
|
333
|
+
updateActionShippingMethod(id: string, actionId: string, body: HttpTypes.AdminUpdateDraftOrderActionShippingMethod, headers?: ClientHeaders): Promise<HttpTypes.AdminDraftOrderPreviewResponse>;
|
334
|
+
/**
|
335
|
+
* This method removes a shipping method from a draft order. It sends a request to the
|
336
|
+
* [Remove Draft Order Shipping Method](https://docs.medusajs.com/api/admin#draft-orders_deleteordereditsidshipping-methodsaction_id) API route.
|
337
|
+
*
|
338
|
+
* @param id - The draft order's ID.
|
339
|
+
* @param actionId - The action ID.
|
340
|
+
* @param headers - Headers to pass in the request.
|
341
|
+
*
|
342
|
+
* @example
|
343
|
+
* To remove a shipping method from a draft order:
|
344
|
+
*
|
345
|
+
* ```ts
|
346
|
+
* sdk.admin.draftOrder.removeShippingMethod("order_123", "action_123")
|
347
|
+
* .then(({ draft_order_preview }) => {
|
348
|
+
* console.log(draft_order_preview)
|
349
|
+
* })
|
350
|
+
* ```
|
351
|
+
*/
|
352
|
+
removeActionShippingMethod(id: string, actionId: string, headers?: ClientHeaders): Promise<HttpTypes.AdminDraftOrderPreviewResponse>;
|
353
|
+
updateShippingMethod(id: string, methodId: string, body: HttpTypes.AdminUpdateDraftOrderShippingMethod, headers?: ClientHeaders): Promise<HttpTypes.AdminDraftOrderPreviewResponse>;
|
354
|
+
/**
|
355
|
+
* This method begins an edit to a draft order. It sends a request to the
|
356
|
+
* [Begin Draft Order Edit](https://docs.medusajs.com/api/admin#draft-orders_postordereditsid) API route.
|
357
|
+
*
|
358
|
+
* @param id - The draft order's ID.
|
359
|
+
* @param headers - Headers to pass in the request.
|
360
|
+
*
|
361
|
+
* @example
|
362
|
+
* To begin an edit to a draft order:
|
363
|
+
*
|
364
|
+
* ```ts
|
365
|
+
* sdk.admin.draftOrder.beginEdit("order_123")
|
366
|
+
* .then(({ draft_order_preview }) => {
|
367
|
+
* console.log(draft_order_preview)
|
368
|
+
* })
|
369
|
+
* ```
|
370
|
+
*/
|
371
|
+
beginEdit(id: string, headers?: ClientHeaders): Promise<HttpTypes.AdminDraftOrderPreviewResponse>;
|
372
|
+
/**
|
373
|
+
* This method cancels an edit to a draft order. It sends a request to the
|
374
|
+
* [Cancel Draft Order Edit](https://docs.medusajs.com/api/admin#draft-orders_deleteordereditsid) API route.
|
375
|
+
*
|
376
|
+
* @param id - The draft order's ID.
|
377
|
+
* @param headers - Headers to pass in the request.
|
378
|
+
*
|
379
|
+
* @example
|
380
|
+
* To cancel an edit to a draft order:
|
381
|
+
*
|
382
|
+
* ```ts
|
383
|
+
* sdk.admin.draftOrder.cancelEdit("order_123")
|
384
|
+
* .then(({ id, object, deleted }) => {
|
385
|
+
* console.log(id, object, deleted)
|
386
|
+
* })
|
387
|
+
* ```
|
388
|
+
*/
|
389
|
+
cancelEdit(id: string, headers?: ClientHeaders): Promise<HttpTypes.DeleteResponse<"draft-order-edit">>;
|
390
|
+
/**
|
391
|
+
* This method requests an edit to a draft order. It sends a request to the
|
392
|
+
* [Request Draft Order Edit](https://docs.medusajs.com/api/admin#draft-orders_postordereditsidrequest) API route.
|
393
|
+
*
|
394
|
+
* @param id - The draft order's ID.
|
395
|
+
* @param headers - Headers to pass in the request.
|
396
|
+
*
|
397
|
+
* @example
|
398
|
+
* To request an edit to a draft order:
|
399
|
+
*
|
400
|
+
* ```ts
|
401
|
+
* sdk.admin.draftOrder.requestEdit("order_123")
|
402
|
+
* .then(({ draft_order_preview }) => {
|
403
|
+
* console.log(draft_order_preview)
|
404
|
+
* })
|
405
|
+
* ```
|
406
|
+
*/
|
407
|
+
requestEdit(id: string, headers?: ClientHeaders): Promise<HttpTypes.AdminDraftOrderPreviewResponse>;
|
408
|
+
/**
|
409
|
+
* This method confirms an edit to a draft order. It sends a request to the
|
410
|
+
* [Confirm Draft Order Edit](https://docs.medusajs.com/api/admin#draft-orders_postordereditsidconfirm) API route.
|
411
|
+
*
|
412
|
+
* @param id - The draft order's ID.
|
413
|
+
* @param headers - Headers to pass in the request.
|
414
|
+
*
|
415
|
+
* @example
|
416
|
+
* To confirm an edit to a draft order:
|
417
|
+
*
|
418
|
+
* ```ts
|
419
|
+
* sdk.admin.draftOrder.confirmEdit("order_123")
|
420
|
+
* .then(({ draft_order_preview }) => {
|
421
|
+
* console.log(draft_order_preview)
|
422
|
+
* })
|
423
|
+
* ```
|
424
|
+
*/
|
425
|
+
confirmEdit(id: string, headers?: ClientHeaders): Promise<HttpTypes.AdminDraftOrderPreviewResponse>;
|
145
426
|
}
|
146
427
|
//# sourceMappingURL=draft-order.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"draft-order.d.ts","sourceRoot":"","sources":["../../../src/admin/draft-order.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAE3C,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAExC,qBAAa,UAAU;IACrB;;OAEG;IACH,OAAO,CAAC,MAAM,CAAQ;IACtB;;OAEG;gBACS,MAAM,EAAE,MAAM;IAI1B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgCG;IACG,QAAQ,CACZ,EAAE,EAAE,MAAM,EACV,KAAK,CAAC,EAAE,SAAS,CAAC,qBAAqB,EACvC,OAAO,CAAC,EAAE,aAAa;IAWzB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6CG;IACG,IAAI,CACR,WAAW,CAAC,EAAE,SAAS,CAAC,yBAAyB,EACjD,OAAO,CAAC,EAAE,aAAa;IAWzB;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IACG,MAAM,CACV,IAAI,EAAE,SAAS,CAAC,qBAAqB,EACrC,KAAK,CAAC,EAAE,SAAS,CAAC,qBAAqB,EACvC,OAAO,CAAC,EAAE,aAAa;IAazB;;;;;;;;;;;;;;;;;;;;OAoBG;IACG,MAAM,CACV,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,SAAS,CAAC,qBAAqB,EACrC,KAAK,CAAC,EAAE,SAAS,CAAC,qBAAqB,EACvC,OAAO,CAAC,EAAE,aAAa;
|
1
|
+
{"version":3,"file":"draft-order.d.ts","sourceRoot":"","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