@medusajs/js-sdk 3.0.0-preview-20250211091350 → 3.0.0-preview-20250406164537
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/campaign.d.ts +9 -0
- package/dist/admin/campaign.d.ts.map +1 -1
- package/dist/admin/campaign.js +9 -0
- package/dist/admin/campaign.js.map +1 -1
- package/dist/admin/customer.d.ts +95 -0
- package/dist/admin/customer.d.ts.map +1 -1
- package/dist/admin/customer.js +120 -0
- package/dist/admin/customer.js.map +1 -1
- package/dist/admin/draft-order.d.ts +427 -0
- package/dist/admin/draft-order.d.ts.map +1 -0
- package/dist/admin/draft-order.js +534 -0
- package/dist/admin/draft-order.js.map +1 -0
- package/dist/admin/fulfillment-provider.d.ts +7 -1
- package/dist/admin/fulfillment-provider.d.ts.map +1 -1
- package/dist/admin/fulfillment-provider.js +7 -1
- package/dist/admin/fulfillment-provider.js.map +1 -1
- package/dist/admin/fulfillment.js +1 -1
- package/dist/admin/fulfillment.js.map +1 -1
- package/dist/admin/index.d.ts +10 -0
- package/dist/admin/index.d.ts.map +1 -1
- package/dist/admin/index.js +4 -0
- package/dist/admin/index.js.map +1 -1
- package/dist/admin/order.d.ts +2 -1
- package/dist/admin/order.d.ts.map +1 -1
- package/dist/admin/order.js +8 -0
- package/dist/admin/order.js.map +1 -1
- package/dist/admin/plugin.d.ts +9 -0
- package/dist/admin/plugin.d.ts.map +1 -0
- package/dist/admin/plugin.js +16 -0
- package/dist/admin/plugin.js.map +1 -0
- package/dist/admin/product-collection.d.ts +1 -1
- package/dist/admin/product-collection.js +1 -1
- package/dist/admin/product.d.ts +3 -2
- package/dist/admin/product.d.ts.map +1 -1
- package/dist/admin/product.js +3 -2
- package/dist/admin/product.js.map +1 -1
- package/dist/admin/promotion.d.ts +285 -1
- package/dist/admin/promotion.d.ts.map +1 -1
- package/dist/admin/promotion.js +284 -0
- package/dist/admin/promotion.js.map +1 -1
- package/dist/admin/refund-reasons.d.ts +48 -0
- package/dist/admin/refund-reasons.d.ts.map +1 -1
- package/dist/admin/refund-reasons.js +48 -0
- package/dist/admin/refund-reasons.js.map +1 -1
- package/dist/admin/region.d.ts +137 -12
- package/dist/admin/region.d.ts.map +1 -1
- package/dist/admin/region.js +133 -0
- package/dist/admin/region.js.map +1 -1
- package/dist/admin/reservation.d.ts +134 -0
- package/dist/admin/reservation.d.ts.map +1 -1
- package/dist/admin/reservation.js +134 -0
- package/dist/admin/reservation.js.map +1 -1
- package/dist/admin/return-reason.d.ts +135 -0
- package/dist/admin/return-reason.d.ts.map +1 -1
- package/dist/admin/return-reason.js +135 -0
- package/dist/admin/return-reason.js.map +1 -1
- package/dist/admin/return.d.ts +523 -1
- package/dist/admin/return.d.ts.map +1 -1
- package/dist/admin/return.js +522 -0
- package/dist/admin/return.js.map +1 -1
- package/dist/admin/sales-channel.d.ts +176 -1
- package/dist/admin/sales-channel.d.ts.map +1 -1
- package/dist/admin/sales-channel.js +175 -0
- package/dist/admin/sales-channel.js.map +1 -1
- package/dist/admin/shipping-option.d.ts +151 -0
- package/dist/admin/shipping-option.d.ts.map +1 -1
- package/dist/admin/shipping-option.js +151 -0
- package/dist/admin/shipping-option.js.map +1 -1
- package/dist/admin/shipping-profile.d.ts +132 -0
- package/dist/admin/shipping-profile.d.ts.map +1 -1
- package/dist/admin/shipping-profile.js +132 -0
- package/dist/admin/shipping-profile.js.map +1 -1
- package/dist/admin/stock-location.d.ts +190 -0
- package/dist/admin/stock-location.d.ts.map +1 -1
- package/dist/admin/stock-location.js +190 -0
- package/dist/admin/stock-location.js.map +1 -1
- package/dist/admin/store.d.ts +99 -0
- package/dist/admin/store.d.ts.map +1 -1
- package/dist/admin/store.js +99 -0
- package/dist/admin/store.js.map +1 -1
- package/dist/admin/tax-rate.d.ts +136 -0
- package/dist/admin/tax-rate.d.ts.map +1 -1
- package/dist/admin/tax-rate.js +136 -0
- package/dist/admin/tax-rate.js.map +1 -1
- package/dist/admin/tax-region.d.ts +125 -0
- package/dist/admin/tax-region.d.ts.map +1 -1
- package/dist/admin/tax-region.js +125 -1
- package/dist/admin/tax-region.js.map +1 -1
- package/dist/admin/upload.d.ts +65 -6
- package/dist/admin/upload.d.ts.map +1 -1
- package/dist/admin/upload.js +63 -1
- package/dist/admin/upload.js.map +1 -1
- package/dist/admin/user.d.ts +147 -0
- package/dist/admin/user.d.ts.map +1 -1
- package/dist/admin/user.js +147 -0
- package/dist/admin/user.js.map +1 -1
- package/dist/admin/workflow-execution.d.ts +62 -0
- package/dist/admin/workflow-execution.d.ts.map +1 -1
- package/dist/admin/workflow-execution.js +62 -0
- package/dist/admin/workflow-execution.js.map +1 -1
- package/dist/auth/index.d.ts +88 -24
- package/dist/auth/index.d.ts.map +1 -1
- package/dist/auth/index.js +89 -24
- package/dist/auth/index.js.map +1 -1
- package/dist/client.d.ts +9 -8
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +67 -48
- package/dist/client.js.map +1 -1
- package/dist/esm/admin/campaign.d.ts +9 -0
- package/dist/esm/admin/campaign.d.ts.map +1 -1
- package/dist/esm/admin/campaign.js +9 -0
- package/dist/esm/admin/campaign.js.map +1 -1
- package/dist/esm/admin/customer.d.ts +95 -0
- package/dist/esm/admin/customer.d.ts.map +1 -1
- package/dist/esm/admin/customer.js +130 -0
- package/dist/esm/admin/customer.js.map +1 -1
- package/dist/esm/admin/draft-order.d.ts +427 -0
- package/dist/esm/admin/draft-order.d.ts.map +1 -0
- package/dist/esm/admin/draft-order.js +577 -0
- package/dist/esm/admin/draft-order.js.map +1 -0
- package/dist/esm/admin/fulfillment-provider.d.ts +7 -1
- package/dist/esm/admin/fulfillment-provider.d.ts.map +1 -1
- package/dist/esm/admin/fulfillment-provider.js +7 -1
- package/dist/esm/admin/fulfillment-provider.js.map +1 -1
- package/dist/esm/admin/fulfillment.js +1 -1
- package/dist/esm/admin/fulfillment.js.map +1 -1
- package/dist/esm/admin/index.d.ts +10 -0
- package/dist/esm/admin/index.d.ts.map +1 -1
- package/dist/esm/admin/index.js +4 -0
- package/dist/esm/admin/index.js.map +1 -1
- package/dist/esm/admin/order.d.ts +2 -1
- package/dist/esm/admin/order.d.ts.map +1 -1
- package/dist/esm/admin/order.js +10 -0
- package/dist/esm/admin/order.js.map +1 -1
- package/dist/esm/admin/plugin.d.ts +9 -0
- package/dist/esm/admin/plugin.d.ts.map +1 -0
- package/dist/esm/admin/plugin.js +23 -0
- package/dist/esm/admin/plugin.js.map +1 -0
- package/dist/esm/admin/product-collection.d.ts +1 -1
- package/dist/esm/admin/product-collection.js +1 -1
- package/dist/esm/admin/product.d.ts +3 -2
- package/dist/esm/admin/product.d.ts.map +1 -1
- package/dist/esm/admin/product.js +3 -2
- package/dist/esm/admin/product.js.map +1 -1
- package/dist/esm/admin/promotion.d.ts +285 -1
- package/dist/esm/admin/promotion.d.ts.map +1 -1
- package/dist/esm/admin/promotion.js +284 -0
- package/dist/esm/admin/promotion.js.map +1 -1
- package/dist/esm/admin/refund-reasons.d.ts +48 -0
- package/dist/esm/admin/refund-reasons.d.ts.map +1 -1
- package/dist/esm/admin/refund-reasons.js +48 -0
- package/dist/esm/admin/refund-reasons.js.map +1 -1
- package/dist/esm/admin/region.d.ts +137 -12
- package/dist/esm/admin/region.d.ts.map +1 -1
- package/dist/esm/admin/region.js +133 -0
- package/dist/esm/admin/region.js.map +1 -1
- package/dist/esm/admin/reservation.d.ts +134 -0
- package/dist/esm/admin/reservation.d.ts.map +1 -1
- package/dist/esm/admin/reservation.js +134 -0
- package/dist/esm/admin/reservation.js.map +1 -1
- package/dist/esm/admin/return-reason.d.ts +135 -0
- package/dist/esm/admin/return-reason.d.ts.map +1 -1
- package/dist/esm/admin/return-reason.js +135 -0
- package/dist/esm/admin/return-reason.js.map +1 -1
- package/dist/esm/admin/return.d.ts +523 -1
- package/dist/esm/admin/return.d.ts.map +1 -1
- package/dist/esm/admin/return.js +522 -0
- package/dist/esm/admin/return.js.map +1 -1
- package/dist/esm/admin/sales-channel.d.ts +176 -1
- package/dist/esm/admin/sales-channel.d.ts.map +1 -1
- package/dist/esm/admin/sales-channel.js +175 -0
- package/dist/esm/admin/sales-channel.js.map +1 -1
- package/dist/esm/admin/shipping-option.d.ts +151 -0
- package/dist/esm/admin/shipping-option.d.ts.map +1 -1
- package/dist/esm/admin/shipping-option.js +151 -0
- package/dist/esm/admin/shipping-option.js.map +1 -1
- package/dist/esm/admin/shipping-profile.d.ts +132 -0
- package/dist/esm/admin/shipping-profile.d.ts.map +1 -1
- package/dist/esm/admin/shipping-profile.js +132 -0
- package/dist/esm/admin/shipping-profile.js.map +1 -1
- package/dist/esm/admin/stock-location.d.ts +190 -0
- package/dist/esm/admin/stock-location.d.ts.map +1 -1
- package/dist/esm/admin/stock-location.js +190 -0
- package/dist/esm/admin/stock-location.js.map +1 -1
- package/dist/esm/admin/store.d.ts +99 -0
- package/dist/esm/admin/store.d.ts.map +1 -1
- package/dist/esm/admin/store.js +99 -0
- package/dist/esm/admin/store.js.map +1 -1
- package/dist/esm/admin/tax-rate.d.ts +136 -0
- package/dist/esm/admin/tax-rate.d.ts.map +1 -1
- package/dist/esm/admin/tax-rate.js +136 -0
- package/dist/esm/admin/tax-rate.js.map +1 -1
- package/dist/esm/admin/tax-region.d.ts +125 -0
- package/dist/esm/admin/tax-region.d.ts.map +1 -1
- package/dist/esm/admin/tax-region.js +125 -1
- package/dist/esm/admin/tax-region.js.map +1 -1
- package/dist/esm/admin/upload.d.ts +65 -6
- package/dist/esm/admin/upload.d.ts.map +1 -1
- package/dist/esm/admin/upload.js +63 -1
- package/dist/esm/admin/upload.js.map +1 -1
- package/dist/esm/admin/user.d.ts +147 -0
- package/dist/esm/admin/user.d.ts.map +1 -1
- package/dist/esm/admin/user.js +147 -0
- package/dist/esm/admin/user.js.map +1 -1
- package/dist/esm/admin/workflow-execution.d.ts +62 -0
- package/dist/esm/admin/workflow-execution.d.ts.map +1 -1
- package/dist/esm/admin/workflow-execution.js +62 -0
- package/dist/esm/admin/workflow-execution.js.map +1 -1
- package/dist/esm/auth/index.d.ts +88 -24
- package/dist/esm/auth/index.d.ts.map +1 -1
- package/dist/esm/auth/index.js +89 -24
- package/dist/esm/auth/index.js.map +1 -1
- package/dist/esm/client.d.ts +9 -8
- package/dist/esm/client.d.ts.map +1 -1
- package/dist/esm/client.js +97 -63
- package/dist/esm/client.js.map +1 -1
- package/dist/esm/store/index.d.ts +19 -0
- package/dist/esm/store/index.d.ts.map +1 -1
- package/dist/esm/store/index.js +19 -0
- package/dist/esm/store/index.js.map +1 -1
- package/dist/esm/types.d.ts +8 -1
- package/dist/esm/types.d.ts.map +1 -1
- package/dist/store/index.d.ts +19 -0
- package/dist/store/index.d.ts.map +1 -1
- package/dist/store/index.js +19 -0
- package/dist/store/index.js.map +1 -1
- package/dist/types.d.ts +8 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +3 -3
package/dist/admin/user.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"user.js","sourceRoot":"","sources":["../../src/admin/user.ts"],"names":[],"mappings":";;;AAIA,MAAa,IAAI;IAKf;;OAEG;IACH,YAAY,MAAc;QACxB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;IACtB,CAAC;IAED,KAAK,CAAC,MAAM,CACV,EAAU,EACV,IAA+B,EAC/B,KAAiC,EACjC,OAAuB;QAEvB,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CACtB,gBAAgB,EAAE,EAAE,EACpB;YACE,MAAM,EAAE,MAAM;YACd,OAAO;YACP,IAAI;YACJ,KAAK;SACN,CACF,CAAA;IACH,CAAC;IAED,KAAK,CAAC,IAAI,CACR,WAA2C,EAC3C,OAAuB;QAEvB,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAkC,cAAc,EAAE;YACxE,OAAO;YACP,KAAK,EAAE,WAAW;SACnB,CAAC,CAAA;IACJ,CAAC;IAED,KAAK,CAAC,QAAQ,CACZ,EAAU,EACV,KAAiC,EACjC,OAAuB;QAEv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,CACZ,EAAU,EACV,KAAiC,EACjC,OAAuB;QAEvB,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CACtB,gBAAgB,EAAE,EAAE,EACpB;YACE,KAAK;YACL,OAAO;SACR,CACF,CAAA;IACH,CAAC;IAED;;;;;;;;;;;;;;OAcG;IACH,KAAK,CAAC,MAAM,CAAC,EAAU,EAAE,OAAuB;QAC9C,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CACtB,gBAAgB,EAAE,EAAE,EACpB;YACE,MAAM,EAAE,QAAQ;YAChB,OAAO;SACR,CACF,CAAA;IACH,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA+BG;IACH,KAAK,CAAC,EAAE,CAAC,KAAiC,EAAE,OAAuB;QACjE,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAA8B,iBAAiB,EAAE;YACvE,KAAK;YACL,OAAO;SACR,CAAC,CAAA;IACJ,CAAC;CACF;AAxND,oBAwNC"}
|
@@ -10,7 +10,69 @@ export declare class WorkflowExecution {
|
|
10
10
|
* @ignore
|
11
11
|
*/
|
12
12
|
constructor(client: Client);
|
13
|
+
/**
|
14
|
+
* This method retrieves a list of workflow executions. It sends a request to the
|
15
|
+
* [List Workflow Executions](https://docs.medusajs.com/api/admin#workflows-executions_getworkflowsexecutions)
|
16
|
+
* API route.
|
17
|
+
*
|
18
|
+
* @param queryParams - Filters and pagination configurations.
|
19
|
+
* @param headers - Headers to pass in the request.
|
20
|
+
* @returns The list of workflow executions.
|
21
|
+
*
|
22
|
+
* @example
|
23
|
+
* To retrieve the list of workflow executions:
|
24
|
+
*
|
25
|
+
* ```ts
|
26
|
+
* sdk.admin.workflowExecution.list()
|
27
|
+
* .then(({ workflow_executions, count, limit, offset }) => {
|
28
|
+
* console.log(workflow_executions)
|
29
|
+
* })
|
30
|
+
* ```
|
31
|
+
*
|
32
|
+
* To configure the pagination, pass the `limit` and `offset` query parameters.
|
33
|
+
*
|
34
|
+
* For example, to retrieve only 10 items and skip 10 items:
|
35
|
+
*
|
36
|
+
* ```ts
|
37
|
+
* sdk.admin.workflowExecution.list({
|
38
|
+
* limit: 10,
|
39
|
+
* offset: 10
|
40
|
+
* })
|
41
|
+
* .then(({ workflow_executions, count, limit, offset }) => {
|
42
|
+
* console.log(workflow_executions)
|
43
|
+
* })
|
44
|
+
* ```
|
45
|
+
*
|
46
|
+
* Using the `fields` query parameter, you can specify the fields and relations to retrieve
|
47
|
+
* in each workflow execution:
|
48
|
+
*
|
49
|
+
* ```ts
|
50
|
+
* sdk.admin.workflowExecution.list({
|
51
|
+
* fields: "id,name"
|
52
|
+
* })
|
53
|
+
* .then(({ workflow_executions, count, limit, offset }) => {
|
54
|
+
* console.log(workflow_executions)
|
55
|
+
* })
|
56
|
+
* ```
|
57
|
+
*
|
58
|
+
* Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/api/admin#select-fields-and-relations).
|
59
|
+
*/
|
13
60
|
list(queryParams?: HttpTypes.AdminGetWorkflowExecutionsParams, headers?: ClientHeaders): Promise<HttpTypes.AdminWorkflowExecutionListResponse>;
|
61
|
+
/**
|
62
|
+
* This method retrieves a workflow execution by its ID. It sends a request to the
|
63
|
+
* [Get Workflow Execution](https://docs.medusajs.com/api/admin#workflows-executions_getworkflowsexecutionsworkflow_idtransaction_id)
|
64
|
+
* API route.
|
65
|
+
*
|
66
|
+
* @param id - The ID of the workflow execution to retrieve.
|
67
|
+
* @param headers - Headers to pass in the request.
|
68
|
+
* @returns The workflow execution's details.
|
69
|
+
*
|
70
|
+
* @example
|
71
|
+
* sdk.admin.workflowExecution.retrieve("wrk_123")
|
72
|
+
* .then(({ workflow_execution }) => {
|
73
|
+
* console.log(workflow_execution)
|
74
|
+
* })
|
75
|
+
*/
|
14
76
|
retrieve(id: string, headers?: ClientHeaders): Promise<HttpTypes.AdminWorkflowExecutionResponse>;
|
15
77
|
}
|
16
78
|
//# sourceMappingURL=workflow-execution.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"workflow-execution.d.ts","sourceRoot":"","sources":["../../src/admin/workflow-execution.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAExC,qBAAa,iBAAiB;IAC5B;;OAEG;IACH,OAAO,CAAC,MAAM,CAAQ;IACtB;;OAEG;gBACS,MAAM,EAAE,MAAM;
|
1
|
+
{"version":3,"file":"workflow-execution.d.ts","sourceRoot":"","sources":["../../src/admin/workflow-execution.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAExC,qBAAa,iBAAiB;IAC5B;;OAEG;IACH,OAAO,CAAC,MAAM,CAAQ;IACtB;;OAEG;gBACS,MAAM,EAAE,MAAM;IAI1B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8CG;IACG,IAAI,CACR,WAAW,CAAC,EAAE,SAAS,CAAC,gCAAgC,EACxD,OAAO,CAAC,EAAE,aAAa;IAWzB;;;;;;;;;;;;;;OAcG;IACG,QAAQ,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa;CAQnD"}
|
@@ -8,12 +8,74 @@ class WorkflowExecution {
|
|
8
8
|
constructor(client) {
|
9
9
|
this.client = client;
|
10
10
|
}
|
11
|
+
/**
|
12
|
+
* This method retrieves a list of workflow executions. It sends a request to the
|
13
|
+
* [List Workflow Executions](https://docs.medusajs.com/api/admin#workflows-executions_getworkflowsexecutions)
|
14
|
+
* API route.
|
15
|
+
*
|
16
|
+
* @param queryParams - Filters and pagination configurations.
|
17
|
+
* @param headers - Headers to pass in the request.
|
18
|
+
* @returns The list of workflow executions.
|
19
|
+
*
|
20
|
+
* @example
|
21
|
+
* To retrieve the list of workflow executions:
|
22
|
+
*
|
23
|
+
* ```ts
|
24
|
+
* sdk.admin.workflowExecution.list()
|
25
|
+
* .then(({ workflow_executions, count, limit, offset }) => {
|
26
|
+
* console.log(workflow_executions)
|
27
|
+
* })
|
28
|
+
* ```
|
29
|
+
*
|
30
|
+
* To configure the pagination, pass the `limit` and `offset` query parameters.
|
31
|
+
*
|
32
|
+
* For example, to retrieve only 10 items and skip 10 items:
|
33
|
+
*
|
34
|
+
* ```ts
|
35
|
+
* sdk.admin.workflowExecution.list({
|
36
|
+
* limit: 10,
|
37
|
+
* offset: 10
|
38
|
+
* })
|
39
|
+
* .then(({ workflow_executions, count, limit, offset }) => {
|
40
|
+
* console.log(workflow_executions)
|
41
|
+
* })
|
42
|
+
* ```
|
43
|
+
*
|
44
|
+
* Using the `fields` query parameter, you can specify the fields and relations to retrieve
|
45
|
+
* in each workflow execution:
|
46
|
+
*
|
47
|
+
* ```ts
|
48
|
+
* sdk.admin.workflowExecution.list({
|
49
|
+
* fields: "id,name"
|
50
|
+
* })
|
51
|
+
* .then(({ workflow_executions, count, limit, offset }) => {
|
52
|
+
* console.log(workflow_executions)
|
53
|
+
* })
|
54
|
+
* ```
|
55
|
+
*
|
56
|
+
* Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/api/admin#select-fields-and-relations).
|
57
|
+
*/
|
11
58
|
async list(queryParams, headers) {
|
12
59
|
return await this.client.fetch(`/admin/workflows-executions`, {
|
13
60
|
query: queryParams,
|
14
61
|
headers,
|
15
62
|
});
|
16
63
|
}
|
64
|
+
/**
|
65
|
+
* This method retrieves a workflow execution by its ID. It sends a request to the
|
66
|
+
* [Get Workflow Execution](https://docs.medusajs.com/api/admin#workflows-executions_getworkflowsexecutionsworkflow_idtransaction_id)
|
67
|
+
* API route.
|
68
|
+
*
|
69
|
+
* @param id - The ID of the workflow execution to retrieve.
|
70
|
+
* @param headers - Headers to pass in the request.
|
71
|
+
* @returns The workflow execution's details.
|
72
|
+
*
|
73
|
+
* @example
|
74
|
+
* sdk.admin.workflowExecution.retrieve("wrk_123")
|
75
|
+
* .then(({ workflow_execution }) => {
|
76
|
+
* console.log(workflow_execution)
|
77
|
+
* })
|
78
|
+
*/
|
17
79
|
async retrieve(id, headers) {
|
18
80
|
return await this.client.fetch(`/admin/workflows-executions/${id}`, {
|
19
81
|
headers,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"workflow-execution.js","sourceRoot":"","sources":["../../src/admin/workflow-execution.ts"],"names":[],"mappings":";;;AAIA,MAAa,iBAAiB;IAK5B;;OAEG;IACH,YAAY,MAAc;QACxB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;IACtB,CAAC;IAED,KAAK,CAAC,IAAI,CACR,WAAwD,EACxD,OAAuB;QAEvB,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,CAC5B,6BAA6B,EAC7B;YACE,KAAK,EAAE,WAAW;YAClB,OAAO;SACR,CACF,CAAA;IACH,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,EAAU,EAAE,OAAuB;QAChD,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,CAC5B,+BAA+B,EAAE,EAAE,EACnC;YACE,OAAO;SACR,CACF,CAAA;IACH,CAAC;CACF;
|
1
|
+
{"version":3,"file":"workflow-execution.js","sourceRoot":"","sources":["../../src/admin/workflow-execution.ts"],"names":[],"mappings":";;;AAIA,MAAa,iBAAiB;IAK5B;;OAEG;IACH,YAAY,MAAc;QACxB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;IACtB,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8CG;IACH,KAAK,CAAC,IAAI,CACR,WAAwD,EACxD,OAAuB;QAEvB,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,CAC5B,6BAA6B,EAC7B;YACE,KAAK,EAAE,WAAW;YAClB,OAAO;SACR,CACF,CAAA;IACH,CAAC;IAED;;;;;;;;;;;;;;OAcG;IACH,KAAK,CAAC,QAAQ,CAAC,EAAU,EAAE,OAAuB;QAChD,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,CAC5B,+BAA+B,EAAE,EAAE,EACnC;YACE,OAAO;SACR,CACF,CAAA;IACH,CAAC;CACF;AA/FD,8CA+FC"}
|
package/dist/auth/index.d.ts
CHANGED
@@ -9,6 +9,12 @@ export declare class Auth {
|
|
9
9
|
* This method is used to retrieve a registration JWT token for a user, customer, or custom actor type. It sends a request to the
|
10
10
|
* [Retrieve Registration Token API route](https://docs.medusajs.com/api/store#auth_postactor_typeauth_provider_register).
|
11
11
|
*
|
12
|
+
* Then, it stores the returned token and passes it in the header of subsequent requests. So, you can call the
|
13
|
+
* [store.customer.create](https://docs.medusajs.com/resources/references/js-sdk/store/customer#create) method,
|
14
|
+
* for example, after calling this method.
|
15
|
+
*
|
16
|
+
* Learn more in the [JS SDK Authentication](https://docs.medusajs.com/resources/js-sdk/auth/overview) guide.
|
17
|
+
*
|
12
18
|
* @param actor - The actor type. For example, `user` for admin user, or `customer` for customer.
|
13
19
|
* @param method - The authentication provider to use. For example, `emailpass` or `google`.
|
14
20
|
* @param payload - The data to pass in the request's body for authentication. When using the `emailpass` provider,
|
@@ -18,15 +24,19 @@ export declare class Auth {
|
|
18
24
|
* @tags auth
|
19
25
|
*
|
20
26
|
* @example
|
21
|
-
* sdk.auth.register(
|
27
|
+
* await sdk.auth.register(
|
22
28
|
* "customer",
|
23
29
|
* "emailpass",
|
24
30
|
* {
|
25
31
|
* email: "customer@gmail.com",
|
26
32
|
* password: "supersecret"
|
27
33
|
* }
|
28
|
-
* )
|
29
|
-
*
|
34
|
+
* )
|
35
|
+
*
|
36
|
+
* // all subsequent requests will use the token in the header
|
37
|
+
* const { customer } = await sdk.store.customer.create({
|
38
|
+
* email: "customer@gmail.com",
|
39
|
+
* password: "supersecret"
|
30
40
|
* })
|
31
41
|
*/
|
32
42
|
register: (actor: string, method: string, payload: HttpTypes.AdminSignUpWithEmailPassword) => Promise<string>;
|
@@ -34,11 +44,32 @@ export declare class Auth {
|
|
34
44
|
* This method retrieves the JWT authenticated token for an admin user, customer, or custom
|
35
45
|
* actor type. It sends a request to the [Authenticate API Route](https://docs.medusajs.com/api/admin#auth_postactor_typeauth_provider).
|
36
46
|
*
|
47
|
+
* ### Third-Party Authentication
|
48
|
+
*
|
49
|
+
* If the API route returns a `location` property, it means that the authentication requires additional steps,
|
50
|
+
* typically in a third-party service. The `location` property is returned so that you
|
51
|
+
* can redirect the user to the appropriate page.
|
52
|
+
*
|
53
|
+
* :::note
|
54
|
+
*
|
55
|
+
* For an example of implementing third-party authentication, refer to the
|
56
|
+
* [Third-Party Login in Storefront](https://docs.medusajs.com/resources/storefront-development/customers/third-party-login) guide.
|
57
|
+
*
|
58
|
+
* :::
|
59
|
+
*
|
60
|
+
* ### Session Authentication
|
61
|
+
*
|
37
62
|
* If the `auth.type` of the SDK is set to `session`, this method will also send a request to the
|
38
63
|
* [Set Authentication Session API route](https://docs.medusajs.com/api/admin#auth_postsession).
|
39
64
|
*
|
40
|
-
*
|
41
|
-
*
|
65
|
+
* Learn more in the [JS SDK Authentication](https://docs.medusajs.com/resources/js-sdk/auth/overview) guide.
|
66
|
+
*
|
67
|
+
* ### Automatic Authentication
|
68
|
+
*
|
69
|
+
* If the authentication was successful, subsequent requests using the SDK will automatically have the necessary authentication headers / session
|
70
|
+
* set, based on your JS SDK authentication configurations.
|
71
|
+
*
|
72
|
+
* Learn more in the [JS SDK Authentication](https://docs.medusajs.com/resources/js-sdk/auth/overview) guide.
|
42
73
|
*
|
43
74
|
* @param actor - The actor type. For example, `user` for admin user, or `customer` for customer.
|
44
75
|
* @param method - The authentication provider to use. For example, `emailpass` or `google`.
|
@@ -49,16 +80,25 @@ export declare class Auth {
|
|
49
80
|
* @tags auth
|
50
81
|
*
|
51
82
|
* @example
|
52
|
-
* sdk.auth.login(
|
83
|
+
* const result = await sdk.auth.login(
|
53
84
|
* "customer",
|
54
85
|
* "emailpass",
|
55
86
|
* {
|
56
87
|
* email: "customer@gmail.com",
|
57
88
|
* password: "supersecret"
|
58
89
|
* }
|
59
|
-
* )
|
60
|
-
*
|
61
|
-
*
|
90
|
+
* )
|
91
|
+
*
|
92
|
+
* if (typeof result !== "string") {
|
93
|
+
* alert("Authentication requires additional steps")
|
94
|
+
* // replace with the redirect logic of your application
|
95
|
+
* window.location.href = result.location
|
96
|
+
* return
|
97
|
+
* }
|
98
|
+
*
|
99
|
+
* // customer is now authenticated
|
100
|
+
* // all subsequent requests will use the token in the header
|
101
|
+
* const { customer } = await sdk.store.customer.retrieve()
|
62
102
|
*/
|
63
103
|
login: (actor: string, method: string, payload: HttpTypes.AdminSignInWithEmailPassword | Record<string, unknown>) => Promise<string | {
|
64
104
|
location: string;
|
@@ -67,6 +107,12 @@ export declare class Auth {
|
|
67
107
|
* 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.
|
68
108
|
* It sends a request to the [Validate Authentication Callback](https://docs.medusajs.com/api/admin#auth_postactor_typeauth_providercallback).
|
69
109
|
*
|
110
|
+
* The method stores the returned token and passes it in the header of subsequent requests. So, you can call the
|
111
|
+
* [store.customer.create](https://docs.medusajs.com/resources/references/js-sdk/store/customer#create) or {@link refresh} methods,
|
112
|
+
* for example, after calling this method.
|
113
|
+
*
|
114
|
+
* Learn more in the [JS SDK Authentication](https://docs.medusajs.com/resources/js-sdk/auth/overview) guide.
|
115
|
+
*
|
70
116
|
* @param actor - The actor type. For example, `user` for admin user, or `customer` for customer.
|
71
117
|
* @param method - The authentication provider to use. For example, `google`.
|
72
118
|
* @param query - The query parameters from the Oauth callback, which should be passed to the API route. This includes query parameters like
|
@@ -76,17 +122,20 @@ export declare class Auth {
|
|
76
122
|
* @tags auth
|
77
123
|
*
|
78
124
|
* @example
|
79
|
-
* sdk.auth.callback(
|
125
|
+
* await sdk.auth.callback(
|
80
126
|
* "customer",
|
81
127
|
* "google",
|
82
128
|
* {
|
83
129
|
* code: "123",
|
84
130
|
* state: "456"
|
85
131
|
* }
|
86
|
-
* )
|
87
|
-
* console.log(token)
|
88
|
-
* })
|
132
|
+
* )
|
89
133
|
*
|
134
|
+
* // all subsequent requests will use the token in the header
|
135
|
+
* const { customer } = await sdk.store.customer.create({
|
136
|
+
* email: "customer@gmail.com",
|
137
|
+
* password: "supersecret"
|
138
|
+
* })
|
90
139
|
*
|
91
140
|
* @privateRemarks
|
92
141
|
* The callback expects all query parameters from the Oauth callback to be passed to
|
@@ -97,28 +146,43 @@ export declare class Auth {
|
|
97
146
|
* This method refreshes a JWT authentication token, which is useful after validating the Oauth callback
|
98
147
|
* with {@link callback}. It sends a request to the [Refresh Authentication Token API route](https://docs.medusajs.com/api/admin#auth_postadminauthtokenrefresh).
|
99
148
|
*
|
149
|
+
* The method stores the returned token and passes it in the header of subsequent requests. So, you can call other
|
150
|
+
* methods that require authentication after calling this method.
|
151
|
+
*
|
152
|
+
* Learn more in the [JS SDK Authentication](https://docs.medusajs.com/resources/js-sdk/auth/overview) guide.
|
153
|
+
*
|
154
|
+
* For an example of implementing third-party authentication, refer to the
|
155
|
+
* [Third-Party Login in Storefront](https://docs.medusajs.com/resources/storefront-development/customers/third-party-login) guide.
|
156
|
+
*
|
157
|
+
*
|
100
158
|
* @returns The refreshed JWT authentication token.
|
101
159
|
*
|
102
160
|
* @tags auth
|
103
161
|
*
|
104
162
|
* @example
|
105
|
-
* sdk.auth.refresh()
|
106
|
-
*
|
107
|
-
*
|
108
|
-
* })
|
163
|
+
* const token = await sdk.auth.refresh()
|
164
|
+
*
|
165
|
+
* // all subsequent requests will use the token in the header
|
166
|
+
* const { customer } = await sdk.store.customer.retrieve()
|
109
167
|
*/
|
110
168
|
refresh: () => Promise<string>;
|
111
169
|
/**
|
112
|
-
* This method
|
113
|
-
*
|
170
|
+
* This method logs out the currently authenticated user based on your JS SDK authentication configurations.
|
171
|
+
*
|
172
|
+
* If the `auth.type` of the SDK is set to `session`, this method will also send a request to the
|
173
|
+
* [Delete Authentication Session API route](https://docs.medusajs.com/api/admin#auth_deletesession).
|
174
|
+
*
|
175
|
+
* The method also clears any stored tokens or sessions, based on your JS SDK authentication configurations.
|
176
|
+
*
|
177
|
+
* Learn more in the [JS SDK Authentication](https://docs.medusajs.com/resources/js-sdk/auth/overview) guide.
|
114
178
|
*
|
115
179
|
* @tags auth
|
116
180
|
*
|
117
181
|
* @example
|
118
|
-
* sdk.auth.logout()
|
119
|
-
*
|
120
|
-
*
|
121
|
-
*
|
182
|
+
* await sdk.auth.logout()
|
183
|
+
*
|
184
|
+
* // user is now logged out
|
185
|
+
* // you can't send any requests that require authentication
|
122
186
|
*/
|
123
187
|
logout: () => Promise<void>;
|
124
188
|
/**
|
@@ -184,7 +248,7 @@ export declare class Auth {
|
|
184
248
|
* // password updated
|
185
249
|
* })
|
186
250
|
*/
|
187
|
-
updateProvider: (actor: string, provider: string, body:
|
251
|
+
updateProvider: (actor: string, provider: string, body: HttpTypes.AdminUpdateProvider, token: string) => Promise<void>;
|
188
252
|
/**
|
189
253
|
* @ignore
|
190
254
|
*/
|
package/dist/auth/index.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/auth/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAClC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAEjC,qBAAa,IAAI;IACf,OAAO,CAAC,MAAM,CAAQ;IACtB,OAAO,CAAC,MAAM,CAAQ;gBAEV,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAK1C
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/auth/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAClC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAEjC,qBAAa,IAAI;IACf,OAAO,CAAC,MAAM,CAAQ;IACtB,OAAO,CAAC,MAAM,CAAQ;gBAEV,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAK1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAiCG;IACH,QAAQ,UACC,MAAM,UACL,MAAM,WACL,SAAS,CAAC,4BAA4B,qBAahD;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2DG;IACH,KAAK,UACI,MAAM,UACL,MAAM,WACL,SAAS,CAAC,4BAA4B,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;;OAmB1E;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAqCG;IACH,QAAQ,UACC,MAAM,UACL,MAAM,UACN,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,qBAYhC;IAED;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,OAAO,wBAYN;IAED;;;;;;;;;;;;;;;;;OAiBG;IACH,MAAM,sBAQL;IAED;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,aAAa,UACJ,MAAM,YACH,MAAM,QACV;QACJ;;;WAGG;QACH,UAAU,EAAE,MAAM,CAAA;KACnB,mBAOF;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6BG;IACH,cAAc,UACL,MAAM,YACH,MAAM,QACV,SAAS,CAAC,mBAAmB,SAC5B,MAAM,mBAOd;IAED;;OAEG;IACH,OAAO,CAAC,SAAS,CAUhB;CACF"}
|
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") {
|
@@ -223,9 +287,10 @@ class Auth {
|
|
223
287
|
* })
|
224
288
|
*/
|
225
289
|
this.updateProvider = async (actor, provider, body, token) => {
|
226
|
-
await this.client.fetch(`/auth/${actor}/${provider}/update
|
290
|
+
await this.client.fetch(`/auth/${actor}/${provider}/update`, {
|
227
291
|
method: "POST",
|
228
292
|
body,
|
293
|
+
headers: { Authorization: `Bearer ${token}` },
|
229
294
|
});
|
230
295
|
};
|
231
296
|
/**
|
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;IAIf,YAAY,MAAc,EAAE,MAAc;QAK1C
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/auth/index.ts"],"names":[],"mappings":";;;AAIA,MAAa,IAAI;IAIf,YAAY,MAAc,EAAE,MAAc;QAK1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;WAiCG;QACH,aAAQ,GAAG,KAAK,EACd,KAAa,EACb,MAAc,EACd,OAA+C,EAC/C,EAAE;YACF,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,CACvC,SAAS,KAAK,IAAI,MAAM,WAAW,EACnC;gBACE,MAAM,EAAE,MAAM;gBACd,IAAI,EAAE,OAAO;aACd,CACF,CAAA;YAED,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;YAE3B,OAAO,KAAK,CAAA;QACd,CAAC,CAAA;QAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;WA2DG;QACH,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O,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"}
|
package/dist/client.d.ts
CHANGED
@@ -36,9 +36,9 @@ export declare class Client {
|
|
36
36
|
* @returns FetchStreamResponse
|
37
37
|
*/
|
38
38
|
fetchStream(input: FetchInput, init?: FetchArgs): Promise<FetchStreamResponse>;
|
39
|
-
setToken(token: string): void
|
40
|
-
clearToken(): void
|
41
|
-
protected clearToken_(): void
|
39
|
+
setToken(token: string): Promise<void>;
|
40
|
+
clearToken(): Promise<void>;
|
41
|
+
protected clearToken_(): Promise<void>;
|
42
42
|
protected initClient(): ClientFetch;
|
43
43
|
protected getApiKeyHeader_: () => {
|
44
44
|
Authorization: string;
|
@@ -46,14 +46,15 @@ export declare class Client {
|
|
46
46
|
protected getPublishableKeyHeader_: () => {
|
47
47
|
[PUBLISHABLE_KEY_HEADER]: string;
|
48
48
|
} | {};
|
49
|
-
protected getJwtHeader_
|
49
|
+
protected getJwtHeader_(): Promise<{
|
50
50
|
Authorization: string;
|
51
|
-
} | {}
|
52
|
-
protected setToken_
|
53
|
-
protected getToken_
|
51
|
+
} | {}>;
|
52
|
+
protected setToken_(token: string): Promise<void>;
|
53
|
+
protected getToken_(): Promise<string | null | undefined>;
|
54
54
|
protected getTokenStorageInfo_: () => {
|
55
|
-
storageMethod: "session" | "local" | "memory" | "nostore";
|
55
|
+
storageMethod: "session" | "local" | "memory" | "custom" | "nostore";
|
56
56
|
storageKey: string;
|
57
57
|
};
|
58
|
+
protected throwError_(message: string): void;
|
58
59
|
}
|
59
60
|
//# sourceMappingURL=client.d.ts.map
|
package/dist/client.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,WAAW,EACX,MAAM,EACN,SAAS,EACT,UAAU,EACV,mBAAmB,EAEpB,MAAM,SAAS,CAAA;AAEhB,eAAO,MAAM,sBAAsB,0BAA0B,CAAA;AAoF7D,qBAAa,UAAW,SAAQ,KAAK;IACnC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAA;IAC1B,UAAU,EAAE,MAAM,GAAG,SAAS,CAAA;gBAElB,OAAO,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM;CAKlE;AAED,qBAAa,MAAM;IACV,MAAM,EAAE,WAAW,CAAA;IAC1B,OAAO,CAAC,MAAM,CAAQ;IACtB,OAAO,CAAC,MAAM,CAAQ;IAEtB,OAAO,CAAC,uBAAuB,CAAsB;IACrD,OAAO,CAAC,KAAK,CAAK;gBAEN,MAAM,EAAE,MAAM;IAiB1B;;;;;;;;;;;OAWG;IACH,KAAK,CAAC,CAAC,SAAS,GAAG,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC,CAAC,CAAC;IAIrE;;;;;;;;;OASG;IACG,WAAW,CACf,KAAK,EAAE,UAAU,EACjB,IAAI,CAAC,EAAE,SAAS,GACf,OAAO,CAAC,mBAAmB,CAAC;
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,WAAW,EACX,MAAM,EACN,SAAS,EACT,UAAU,EACV,mBAAmB,EAEpB,MAAM,SAAS,CAAA;AAEhB,eAAO,MAAM,sBAAsB,0BAA0B,CAAA;AAoF7D,qBAAa,UAAW,SAAQ,KAAK;IACnC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAA;IAC1B,UAAU,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