@medusajs/js-sdk 0.0.2-snapshot-20240925105124 → 0.0.2-snapshot-20240926160837
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/esm/admin/api-key.d.ts +15 -0
- package/dist/esm/admin/api-key.d.ts.map +1 -0
- package/dist/esm/admin/api-key.js +75 -0
- package/dist/esm/admin/api-key.js.map +1 -0
- package/dist/esm/admin/campaign.d.ts +14 -0
- package/dist/esm/admin/campaign.d.ts.map +1 -0
- package/dist/esm/admin/campaign.js +66 -0
- package/dist/esm/admin/campaign.js.map +1 -0
- package/dist/esm/admin/claim.d.ts +30 -0
- package/dist/esm/admin/claim.d.ts.map +1 -0
- package/dist/esm/admin/claim.js +223 -0
- package/dist/esm/admin/claim.js.map +1 -0
- package/dist/esm/admin/currency.d.ts +10 -0
- package/dist/esm/admin/currency.d.ts.map +1 -0
- package/dist/esm/admin/currency.js +31 -0
- package/dist/esm/admin/currency.js.map +1 -0
- package/dist/esm/admin/customer-group.d.ts +14 -0
- package/dist/esm/admin/customer-group.d.ts.map +1 -0
- package/dist/esm/admin/customer-group.js +70 -0
- package/dist/esm/admin/customer-group.js.map +1 -0
- package/dist/esm/admin/customer.d.ts +21 -0
- package/dist/esm/admin/customer.d.ts.map +1 -0
- package/dist/esm/admin/customer.js +59 -0
- package/dist/esm/admin/customer.js.map +1 -0
- package/dist/esm/admin/exchange.d.ts +30 -0
- package/dist/esm/admin/exchange.d.ts.map +1 -0
- package/dist/esm/admin/exchange.js +223 -0
- package/dist/esm/admin/exchange.js.map +1 -0
- package/dist/esm/admin/fulfillment-provider.d.ts +9 -0
- package/dist/esm/admin/fulfillment-provider.d.ts.map +1 -0
- package/dist/esm/admin/fulfillment-provider.js +24 -0
- package/dist/esm/admin/fulfillment-provider.js.map +1 -0
- package/dist/esm/admin/fulfillment-set.d.ts +13 -0
- package/dist/esm/admin/fulfillment-set.d.ts.map +1 -0
- package/dist/esm/admin/fulfillment-set.js +60 -0
- package/dist/esm/admin/fulfillment-set.js.map +1 -0
- package/dist/esm/admin/fulfillment.d.ts +11 -0
- package/dist/esm/admin/fulfillment.d.ts.map +1 -0
- package/dist/esm/admin/fulfillment.js +44 -0
- package/dist/esm/admin/fulfillment.js.map +1 -0
- package/dist/esm/admin/index.d.ts +87 -0
- package/dist/esm/admin/index.d.ts.map +1 -0
- package/dist/esm/admin/index.js +87 -0
- package/dist/esm/admin/index.js.map +1 -0
- package/dist/esm/admin/inventory-item.d.ts +17 -0
- package/dist/esm/admin/inventory-item.d.ts.map +1 -0
- package/dist/esm/admin/inventory-item.js +95 -0
- package/dist/esm/admin/inventory-item.js.map +1 -0
- package/dist/esm/admin/invite.d.ts +26 -0
- package/dist/esm/admin/invite.d.ts.map +1 -0
- package/dist/esm/admin/invite.js +79 -0
- package/dist/esm/admin/invite.js.map +1 -0
- package/dist/esm/admin/notification.d.ts +10 -0
- package/dist/esm/admin/notification.d.ts.map +1 -0
- package/dist/esm/admin/notification.js +33 -0
- package/dist/esm/admin/notification.js.map +1 -0
- package/dist/esm/admin/order-edit.d.ts +16 -0
- package/dist/esm/admin/order-edit.d.ts.map +1 -0
- package/dist/esm/admin/order-edit.js +91 -0
- package/dist/esm/admin/order-edit.js.map +1 -0
- package/dist/esm/admin/order.d.ts +32 -0
- package/dist/esm/admin/order.d.ts.map +1 -0
- package/dist/esm/admin/order.js +94 -0
- package/dist/esm/admin/order.js.map +1 -0
- package/dist/esm/admin/payment-collection.d.ts +13 -0
- package/dist/esm/admin/payment-collection.d.ts.map +1 -0
- package/dist/esm/admin/payment-collection.js +59 -0
- package/dist/esm/admin/payment-collection.js.map +1 -0
- package/dist/esm/admin/payment.d.ts +13 -0
- package/dist/esm/admin/payment.d.ts.map +1 -0
- package/dist/esm/admin/payment.js +59 -0
- package/dist/esm/admin/payment.js.map +1 -0
- package/dist/esm/admin/price-list.d.ts +15 -0
- package/dist/esm/admin/price-list.d.ts.map +1 -0
- package/dist/esm/admin/price-list.js +81 -0
- package/dist/esm/admin/price-list.js.map +1 -0
- package/dist/esm/admin/price-preference.d.ts +13 -0
- package/dist/esm/admin/price-preference.d.ts.map +1 -0
- package/dist/esm/admin/price-preference.js +61 -0
- package/dist/esm/admin/price-preference.js.map +1 -0
- package/dist/esm/admin/product-category.d.ts +14 -0
- package/dist/esm/admin/product-category.d.ts.map +1 -0
- package/dist/esm/admin/product-category.js +69 -0
- package/dist/esm/admin/product-category.js.map +1 -0
- package/dist/esm/admin/product-collection.d.ts +14 -0
- package/dist/esm/admin/product-collection.d.ts.map +1 -0
- package/dist/esm/admin/product-collection.js +68 -0
- package/dist/esm/admin/product-collection.js.map +1 -0
- package/dist/esm/admin/product-tag.d.ts +13 -0
- package/dist/esm/admin/product-tag.d.ts.map +1 -0
- package/dist/esm/admin/product-tag.js +59 -0
- package/dist/esm/admin/product-tag.js.map +1 -0
- package/dist/esm/admin/product-type.d.ts +13 -0
- package/dist/esm/admin/product-type.d.ts.map +1 -0
- package/dist/esm/admin/product-type.js +59 -0
- package/dist/esm/admin/product-type.js.map +1 -0
- package/dist/esm/admin/product-variant.d.ts +9 -0
- package/dist/esm/admin/product-variant.d.ts.map +1 -0
- package/dist/esm/admin/product-variant.js +23 -0
- package/dist/esm/admin/product-variant.js.map +1 -0
- package/dist/esm/admin/product.d.ts +29 -0
- package/dist/esm/admin/product.d.ts.map +1 -0
- package/dist/esm/admin/product.js +211 -0
- package/dist/esm/admin/product.js.map +1 -0
- package/dist/esm/admin/promotion.d.ts +19 -0
- package/dist/esm/admin/promotion.d.ts.map +1 -0
- package/dist/esm/admin/promotion.js +110 -0
- package/dist/esm/admin/promotion.js.map +1 -0
- package/dist/esm/admin/refund-reasons.d.ts +9 -0
- package/dist/esm/admin/refund-reasons.d.ts.map +1 -0
- package/dist/esm/admin/refund-reasons.js +23 -0
- package/dist/esm/admin/refund-reasons.js.map +1 -0
- package/dist/esm/admin/region.d.ts +21 -0
- package/dist/esm/admin/region.d.ts.map +1 -0
- package/dist/esm/admin/region.js +59 -0
- package/dist/esm/admin/region.js.map +1 -0
- package/dist/esm/admin/reservation.d.ts +14 -0
- package/dist/esm/admin/reservation.d.ts.map +1 -0
- package/dist/esm/admin/reservation.js +62 -0
- package/dist/esm/admin/reservation.js.map +1 -0
- package/dist/esm/admin/return-reason.d.ts +13 -0
- package/dist/esm/admin/return-reason.d.ts.map +1 -0
- package/dist/esm/admin/return-reason.js +60 -0
- package/dist/esm/admin/return-reason.js.map +1 -0
- package/dist/esm/admin/return.d.ts +30 -0
- package/dist/esm/admin/return.d.ts.map +1 -0
- package/dist/esm/admin/return.js +224 -0
- package/dist/esm/admin/return.js.map +1 -0
- package/dist/esm/admin/sales-channel.d.ts +15 -0
- package/dist/esm/admin/sales-channel.d.ts.map +1 -0
- package/dist/esm/admin/sales-channel.js +79 -0
- package/dist/esm/admin/sales-channel.js.map +1 -0
- package/dist/esm/admin/shipping-option.d.ts +13 -0
- package/dist/esm/admin/shipping-option.d.ts.map +1 -0
- package/dist/esm/admin/shipping-option.js +61 -0
- package/dist/esm/admin/shipping-option.js.map +1 -0
- package/dist/esm/admin/shipping-profile.d.ts +13 -0
- package/dist/esm/admin/shipping-profile.d.ts.map +1 -0
- package/dist/esm/admin/shipping-profile.js +61 -0
- package/dist/esm/admin/shipping-profile.js.map +1 -0
- package/dist/esm/admin/stock-location.d.ts +16 -0
- package/dist/esm/admin/stock-location.d.ts.map +1 -0
- package/dist/esm/admin/stock-location.js +88 -0
- package/dist/esm/admin/stock-location.js.map +1 -0
- package/dist/esm/admin/store.d.ts +11 -0
- package/dist/esm/admin/store.d.ts.map +1 -0
- package/dist/esm/admin/store.js +43 -0
- package/dist/esm/admin/store.js.map +1 -0
- package/dist/esm/admin/tax-rate.d.ts +13 -0
- package/dist/esm/admin/tax-rate.d.ts.map +1 -0
- package/dist/esm/admin/tax-rate.js +62 -0
- package/dist/esm/admin/tax-rate.js.map +1 -0
- package/dist/esm/admin/tax-region.d.ts +12 -0
- package/dist/esm/admin/tax-region.d.ts.map +1 -0
- package/dist/esm/admin/tax-region.js +53 -0
- package/dist/esm/admin/tax-region.js.map +1 -0
- package/dist/esm/admin/upload.d.ts +15 -0
- package/dist/esm/admin/upload.d.ts.map +1 -0
- package/dist/esm/admin/upload.js +59 -0
- package/dist/esm/admin/upload.js.map +1 -0
- package/dist/esm/admin/user.d.ts +14 -0
- package/dist/esm/admin/user.d.ts.map +1 -0
- package/dist/esm/admin/user.js +67 -0
- package/dist/esm/admin/user.js.map +1 -0
- package/dist/esm/admin/workflow-execution.d.ts +10 -0
- package/dist/esm/admin/workflow-execution.d.ts.map +1 -0
- package/dist/esm/admin/workflow-execution.js +30 -0
- package/dist/esm/admin/workflow-execution.js.map +1 -0
- package/dist/esm/auth/index.d.ts +17 -0
- package/dist/esm/auth/index.d.ts.map +1 -0
- package/dist/esm/auth/index.js +78 -0
- package/dist/esm/auth/index.js.map +1 -0
- package/dist/esm/client.d.ts +59 -0
- package/dist/esm/client.d.ts.map +1 -0
- package/dist/esm/client.js +229 -0
- package/dist/esm/client.js.map +1 -0
- package/dist/esm/index.d.ts +15 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +15 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/store/index.d.ts +116 -0
- package/dist/esm/store/index.d.ts.map +1 -0
- package/dist/esm/store/index.js +240 -0
- package/dist/esm/store/index.js.map +1 -0
- package/dist/esm/types.d.ts +47 -0
- package/dist/esm/types.d.ts.map +1 -0
- package/dist/esm/types.js +2 -0
- package/dist/esm/types.js.map +1 -0
- package/package.json +7 -4
@@ -0,0 +1,67 @@
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
8
|
+
});
|
9
|
+
};
|
10
|
+
export class User {
|
11
|
+
constructor(client) {
|
12
|
+
this.client = client;
|
13
|
+
}
|
14
|
+
create(body, query, headers) {
|
15
|
+
return __awaiter(this, void 0, void 0, function* () {
|
16
|
+
return this.client.fetch(`/admin/users`, {
|
17
|
+
method: "POST",
|
18
|
+
headers,
|
19
|
+
body,
|
20
|
+
query,
|
21
|
+
});
|
22
|
+
});
|
23
|
+
}
|
24
|
+
update(id, body, query, headers) {
|
25
|
+
return __awaiter(this, void 0, void 0, function* () {
|
26
|
+
return this.client.fetch(`/admin/users/${id}`, {
|
27
|
+
method: "POST",
|
28
|
+
headers,
|
29
|
+
body,
|
30
|
+
query,
|
31
|
+
});
|
32
|
+
});
|
33
|
+
}
|
34
|
+
list(queryParams, headers) {
|
35
|
+
return __awaiter(this, void 0, void 0, function* () {
|
36
|
+
return this.client.fetch(`/admin/users`, {
|
37
|
+
headers,
|
38
|
+
query: queryParams,
|
39
|
+
});
|
40
|
+
});
|
41
|
+
}
|
42
|
+
retrieve(id, query, headers) {
|
43
|
+
return __awaiter(this, void 0, void 0, function* () {
|
44
|
+
return this.client.fetch(`/admin/users/${id}`, {
|
45
|
+
query,
|
46
|
+
headers,
|
47
|
+
});
|
48
|
+
});
|
49
|
+
}
|
50
|
+
delete(id, headers) {
|
51
|
+
return __awaiter(this, void 0, void 0, function* () {
|
52
|
+
return this.client.fetch(`/admin/users/${id}`, {
|
53
|
+
method: "DELETE",
|
54
|
+
headers,
|
55
|
+
});
|
56
|
+
});
|
57
|
+
}
|
58
|
+
me(query, headers) {
|
59
|
+
return __awaiter(this, void 0, void 0, function* () {
|
60
|
+
return this.client.fetch(`/admin/users/me`, {
|
61
|
+
query,
|
62
|
+
headers,
|
63
|
+
});
|
64
|
+
});
|
65
|
+
}
|
66
|
+
}
|
67
|
+
//# sourceMappingURL=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AuB;;YACjE,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAA8B,iBAAiB,EAAE;gBACvE,KAAK;gBACL,OAAO;aACR,CAAC,CAAA;QACJ,CAAC;KAAA;CACF"}
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import { HttpTypes } from "@medusajs/types";
|
2
|
+
import { Client } from "../client";
|
3
|
+
import { ClientHeaders } from "../types";
|
4
|
+
export declare class WorkflowExecution {
|
5
|
+
private client;
|
6
|
+
constructor(client: Client);
|
7
|
+
list(queryParams?: HttpTypes.AdminGetWorkflowExecutionsParams, headers?: ClientHeaders): Promise<HttpTypes.AdminWorkflowExecutionListResponse>;
|
8
|
+
retrieve(id: string, headers?: ClientHeaders): Promise<HttpTypes.AdminWorkflowExecutionResponse>;
|
9
|
+
}
|
10
|
+
//# sourceMappingURL=workflow-execution.d.ts.map
|
@@ -0,0 +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,OAAO,CAAC,MAAM,CAAQ;gBACV,MAAM,EAAE,MAAM;IAIpB,IAAI,CACR,WAAW,CAAC,EAAE,SAAS,CAAC,gCAAgC,EACxD,OAAO,CAAC,EAAE,aAAa;IAWnB,QAAQ,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa;CAQnD"}
|
@@ -0,0 +1,30 @@
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
8
|
+
});
|
9
|
+
};
|
10
|
+
export class WorkflowExecution {
|
11
|
+
constructor(client) {
|
12
|
+
this.client = client;
|
13
|
+
}
|
14
|
+
list(queryParams, headers) {
|
15
|
+
return __awaiter(this, void 0, void 0, function* () {
|
16
|
+
return yield this.client.fetch(`/admin/workflows-executions`, {
|
17
|
+
query: queryParams,
|
18
|
+
headers,
|
19
|
+
});
|
20
|
+
});
|
21
|
+
}
|
22
|
+
retrieve(id, headers) {
|
23
|
+
return __awaiter(this, void 0, void 0, function* () {
|
24
|
+
return yield this.client.fetch(`/admin/workflows-executions/${id}`, {
|
25
|
+
headers,
|
26
|
+
});
|
27
|
+
});
|
28
|
+
}
|
29
|
+
}
|
30
|
+
//# sourceMappingURL=workflow-execution.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"workflow-execution.js","sourceRoot":"","sources":["../../../src/admin/workflow-execution.ts"],"names":[],"mappings":";;;;;;;;;AAIA,MAAM,OAAO,iBAAiB;IAE5B,YAAY,MAAc;QACxB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;IACtB,CAAC;IAEK,IAAI,CACR,WAAwD,EACxD,OAAuB;;YAEvB,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,CAC5B,6BAA6B,EAC7B;gBACE,KAAK,EAAE,WAAW;gBAClB,OAAO;aACR,CACF,CAAA;QACH,CAAC;KAAA;IAEK,QAAQ,CAAC,EAAU,EAAE,OAAuB;;YAChD,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,CAC5B,+BAA+B,EAAE,EAAE,EACnC;gBACE,OAAO;aACR,CACF,CAAA;QACH,CAAC;KAAA;CACF"}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import { HttpTypes } from "@medusajs/types";
|
2
|
+
import { Client } from "../client";
|
3
|
+
import { Config } from "../types";
|
4
|
+
export declare class Auth {
|
5
|
+
private client;
|
6
|
+
private config;
|
7
|
+
constructor(client: Client, config: Config);
|
8
|
+
register: (actor: string, method: string, payload: HttpTypes.AdminSignUpWithEmailPassword) => Promise<string>;
|
9
|
+
login: (actor: string, method: string, payload: HttpTypes.AdminSignInWithEmailPassword | Record<string, unknown>) => Promise<string | {
|
10
|
+
location: string;
|
11
|
+
}>;
|
12
|
+
callback: (actor: string, method: string, query?: Record<string, unknown>) => Promise<string>;
|
13
|
+
refresh: () => Promise<string>;
|
14
|
+
logout: () => Promise<void>;
|
15
|
+
private setToken_;
|
16
|
+
}
|
17
|
+
//# sourceMappingURL=index.d.ts.map
|
@@ -0,0 +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,QAAQ,UACC,MAAM,UACL,MAAM,WACL,SAAS,CAAC,4BAA4B,qBAahD;IAED,KAAK,UACI,MAAM,UACL,MAAM,WACL,SAAS,CAAC,4BAA4B,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;;OAmB1E;IAGD,QAAQ,UACC,MAAM,UACL,MAAM,UACN,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,qBAYhC;IAED,OAAO,wBAYN;IAED,MAAM,sBAQL;IAED,OAAO,CAAC,SAAS,CAUhB;CACF"}
|
@@ -0,0 +1,78 @@
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
8
|
+
});
|
9
|
+
};
|
10
|
+
export class Auth {
|
11
|
+
constructor(client, config) {
|
12
|
+
this.register = (actor, method, payload) => __awaiter(this, void 0, void 0, function* () {
|
13
|
+
const { token } = yield this.client.fetch(`/auth/${actor}/${method}/register`, {
|
14
|
+
method: "POST",
|
15
|
+
body: payload,
|
16
|
+
});
|
17
|
+
this.client.setToken(token);
|
18
|
+
return token;
|
19
|
+
});
|
20
|
+
this.login = (actor, method, payload) => __awaiter(this, void 0, void 0, function* () {
|
21
|
+
// There will either be token or location returned from the backend.
|
22
|
+
const { token, location } = yield this.client.fetch(`/auth/${actor}/${method}`, {
|
23
|
+
method: "POST",
|
24
|
+
body: payload,
|
25
|
+
});
|
26
|
+
// In the case of an oauth login, we return the redirect location to the caller.
|
27
|
+
// They can decide if they do an immediate redirect or put it in an <a> tag.
|
28
|
+
if (location) {
|
29
|
+
return { location };
|
30
|
+
}
|
31
|
+
yield this.setToken_(token);
|
32
|
+
return token;
|
33
|
+
});
|
34
|
+
// The callback expects all query parameters from the Oauth callback to be passed to the backend, and the provider is in charge of parsing and validating them
|
35
|
+
this.callback = (actor, method, query) => __awaiter(this, void 0, void 0, function* () {
|
36
|
+
const { token } = yield this.client.fetch(`/auth/${actor}/${method}/callback`, {
|
37
|
+
method: "GET",
|
38
|
+
query,
|
39
|
+
});
|
40
|
+
yield this.setToken_(token);
|
41
|
+
return token;
|
42
|
+
});
|
43
|
+
this.refresh = () => __awaiter(this, void 0, void 0, function* () {
|
44
|
+
const { token } = yield this.client.fetch("/auth/token/refresh", {
|
45
|
+
method: "POST",
|
46
|
+
});
|
47
|
+
// Putting the token in session after refreshing is only useful when the new token has updated info (eg. actor_id).
|
48
|
+
// Ideally we don't use the full JWT in session as key, but just store a pseudorandom key that keeps the rest of the auth context as value.
|
49
|
+
yield this.setToken_(token);
|
50
|
+
return token;
|
51
|
+
});
|
52
|
+
this.logout = () => __awaiter(this, void 0, void 0, function* () {
|
53
|
+
var _a, _b;
|
54
|
+
if (((_b = (_a = this.config) === null || _a === void 0 ? void 0 : _a.auth) === null || _b === void 0 ? void 0 : _b.type) === "session") {
|
55
|
+
yield this.client.fetch("/auth/session", {
|
56
|
+
method: "DELETE",
|
57
|
+
});
|
58
|
+
}
|
59
|
+
this.client.clearToken();
|
60
|
+
});
|
61
|
+
this.setToken_ = (token) => __awaiter(this, void 0, void 0, function* () {
|
62
|
+
var _a, _b;
|
63
|
+
// By default we just set the token in the configured storage, if configured to use sessions we convert it into session storage instead.
|
64
|
+
if (((_b = (_a = this.config) === null || _a === void 0 ? void 0 : _a.auth) === null || _b === void 0 ? void 0 : _b.type) === "session") {
|
65
|
+
yield this.client.fetch("/auth/session", {
|
66
|
+
method: "POST",
|
67
|
+
headers: { Authorization: `Bearer ${token}` },
|
68
|
+
});
|
69
|
+
}
|
70
|
+
else {
|
71
|
+
this.client.setToken(token);
|
72
|
+
}
|
73
|
+
});
|
74
|
+
this.client = client;
|
75
|
+
this.config = config;
|
76
|
+
}
|
77
|
+
}
|
78
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/auth/index.ts"],"names":[],"mappings":";;;;;;;;;AAIA,MAAM,OAAO,IAAI;IAIf,YAAY,MAAc,EAAE,MAAc;QAK1C,aAAQ,GAAG,CACT,KAAa,EACb,MA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,CAAC,KAAK,CACvC,qBAAqB,EACrB;gBACE,MAAM,EAAE,MAAM;aACf,CACF,CAAA;YAED,mHAAmH;YACnH,2IAA2I;YAC3I,MAAM,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAA;YAC3B,OAAO,KAAK,CAAA;QACd,CAAC,CAAA,CAAA;QAED,WAAM,GAAG,GAAS,EAAE;;YAClB,IAAI,CAAA,MAAA,MAAA,IAAI,CAAC,MAAM,0CAAE,IAAI,0CAAE,IAAI,MAAK,SAAS,EAAE,CAAC;gBAC1C,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,eAAe,EAAE;oBACvC,MAAM,EAAE,QAAQ;iBACjB,CAAC,CAAA;YACJ,CAAC;YAED,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,CAAA;QAC1B,CAAC,CAAA,CAAA;QAEO,cAAS,GAAG,CAAO,KAAa,EAAE,EAAE;;YAC1C,wIAAwI;YACxI,IAAI,CAAA,MAAA,MAAA,IAAI,CAAC,MAAM,0CAAE,IAAI,0CAAE,IAAI,MAAK,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,CAAA;QAlGC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;IACtB,CAAC;CAiGF"}
|
@@ -0,0 +1,59 @@
|
|
1
|
+
import { ClientFetch, Config, FetchArgs, FetchInput, FetchStreamResponse } from "./types";
|
2
|
+
export declare const PUBLISHABLE_KEY_HEADER = "x-publishable-api-key";
|
3
|
+
export declare class FetchError extends Error {
|
4
|
+
status: number | undefined;
|
5
|
+
statusText: string | undefined;
|
6
|
+
constructor(message: string, statusText?: string, status?: number);
|
7
|
+
}
|
8
|
+
export declare class Client {
|
9
|
+
fetch_: ClientFetch;
|
10
|
+
private config;
|
11
|
+
private logger;
|
12
|
+
private DEFAULT_JWT_STORAGE_KEY;
|
13
|
+
private token;
|
14
|
+
constructor(config: Config);
|
15
|
+
/**
|
16
|
+
* `fetch` closely follows (and uses under the hood) the native `fetch` API. There are, however, few key differences:
|
17
|
+
* - Non 2xx statuses throw a `FetchError` with the status code as the `status` property, rather than resolving the promise
|
18
|
+
* - You can pass `body` and `query` as objects, and they will be encoded and stringified.
|
19
|
+
* - The response gets parsed as JSON if the `accept` header is set to `application/json`, otherwise the raw Response object is returned
|
20
|
+
*
|
21
|
+
* Since the response is dynamically determined, we cannot know if it is JSON or not. Therefore, it is important to pass `Response` as the return type
|
22
|
+
*
|
23
|
+
* @param input: FetchInput
|
24
|
+
* @param init: FetchArgs
|
25
|
+
* @returns Promise<T>
|
26
|
+
*/
|
27
|
+
fetch<T extends any>(input: FetchInput, init?: FetchArgs): Promise<T>;
|
28
|
+
/**
|
29
|
+
* `fetchStream` is a helper method to deal with server-sent events. It returns an object with a stream and an abort function.
|
30
|
+
* It follows a very similar interface to `fetch`, with the return value being an async generator.
|
31
|
+
* The stream is an async generator that yields `ServerSentEventMessage` objects, which contains the event name, stringified data, and few other properties.
|
32
|
+
* The caller is responsible for handling `disconnect` events and aborting the stream. The caller is also responsible for parsing the data field.
|
33
|
+
*
|
34
|
+
* @param input: FetchInput
|
35
|
+
* @param init: FetchArgs
|
36
|
+
* @returns FetchStreamResponse
|
37
|
+
*/
|
38
|
+
fetchStream(input: FetchInput, init?: FetchArgs): Promise<FetchStreamResponse>;
|
39
|
+
setToken(token: string): void;
|
40
|
+
clearToken(): void;
|
41
|
+
protected clearToken_(): void;
|
42
|
+
protected initClient(): ClientFetch;
|
43
|
+
protected getApiKeyHeader_: () => {
|
44
|
+
Authorization: string;
|
45
|
+
} | {};
|
46
|
+
protected getPublishableKeyHeader_: () => {
|
47
|
+
[PUBLISHABLE_KEY_HEADER]: string;
|
48
|
+
} | {};
|
49
|
+
protected getJwtHeader_: () => {
|
50
|
+
Authorization: string;
|
51
|
+
} | {};
|
52
|
+
protected setToken_: (token: string) => void;
|
53
|
+
protected getToken_: () => string | null | undefined;
|
54
|
+
protected getTokenStorageInfo_: () => {
|
55
|
+
storageMethod: "session" | "local" | "memory";
|
56
|
+
storageKey: string;
|
57
|
+
};
|
58
|
+
}
|
59
|
+
//# sourceMappingURL=client.d.ts.map
|
@@ -0,0 +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;AA6D7D,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;IAgB/B,QAAQ,CAAC,KAAK,EAAE,MAAM;IAItB,UAAU;IAIV,SAAS,CAAC,WAAW;IAkBrB,SAAS,CAAC,UAAU,IAAI,WAAW;IA2DnC,SAAS,CAAC,gBAAgB,QAAO;QAAE,aAAa,EAAE,MAAM,CAAA;KAAE,GAAG,EAAE,CAI9D;IAED,SAAS,CAAC,wBAAwB,QAC9B;QAAE,CAAC,sBAAsB,CAAC,EAAE,MAAM,CAAA;KAAE,GACpC,EAAE,CAIL;IAED,SAAS,CAAC,aAAa,QAAO;QAAE,aAAa,EAAE,MAAM,CAAA;KAAE,GAAG,EAAE,CAQ3D;IAED,SAAS,CAAC,SAAS,UAAW,MAAM,UAgBnC;IAED,SAAS,CAAC,SAAS,kCAelB;IAED,SAAS,CAAC,oBAAoB;;;MAoB7B;CACF"}
|
@@ -0,0 +1,229 @@
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
8
|
+
});
|
9
|
+
};
|
10
|
+
import qs from "qs";
|
11
|
+
import { events } from "fetch-event-stream";
|
12
|
+
export const PUBLISHABLE_KEY_HEADER = "x-publishable-api-key";
|
13
|
+
const hasStorage = (storage) => {
|
14
|
+
if (typeof window !== "undefined") {
|
15
|
+
return storage in window;
|
16
|
+
}
|
17
|
+
return false;
|
18
|
+
};
|
19
|
+
const toBase64 = (str) => {
|
20
|
+
if (typeof window !== "undefined") {
|
21
|
+
return window.btoa(str);
|
22
|
+
}
|
23
|
+
return Buffer.from(str).toString("base64");
|
24
|
+
};
|
25
|
+
const sanitizeHeaders = (headers) => {
|
26
|
+
return Object.assign(Object.assign({}, Object.fromEntries(headers.entries())), { authorization: "<REDACTED>" });
|
27
|
+
};
|
28
|
+
const normalizeRequest = (init, headers, config) => {
|
29
|
+
var _a, _b;
|
30
|
+
let body = init === null || init === void 0 ? void 0 : init.body;
|
31
|
+
if (body && ((_a = headers.get("content-type")) === null || _a === void 0 ? void 0 : _a.includes("application/json"))) {
|
32
|
+
body = JSON.stringify(body);
|
33
|
+
}
|
34
|
+
return Object.assign(Object.assign(Object.assign({}, init), { headers,
|
35
|
+
// TODO: Setting this to "include" poses some security risks, as it will send cookies to any domain. We should consider making this configurable.
|
36
|
+
credentials: ((_b = config.auth) === null || _b === void 0 ? void 0 : _b.type) === "session" ? "include" : "omit" }), (body ? { body: body } : {}));
|
37
|
+
};
|
38
|
+
const normalizeResponse = (resp, reqHeaders) => __awaiter(void 0, void 0, void 0, function* () {
|
39
|
+
var _a, _b;
|
40
|
+
if (resp.status >= 300) {
|
41
|
+
const jsonError = (yield resp.json().catch(() => ({})));
|
42
|
+
throw new FetchError((_a = jsonError.message) !== null && _a !== void 0 ? _a : resp.statusText, resp.statusText, resp.status);
|
43
|
+
}
|
44
|
+
// If we requested JSON, we try to parse the response. Otherwise, we return the raw response.
|
45
|
+
const isJsonRequest = (_b = reqHeaders.get("accept")) === null || _b === void 0 ? void 0 : _b.includes("application/json");
|
46
|
+
return isJsonRequest ? yield resp.json() : resp;
|
47
|
+
});
|
48
|
+
export class FetchError extends Error {
|
49
|
+
constructor(message, statusText, status) {
|
50
|
+
super(message);
|
51
|
+
this.statusText = statusText;
|
52
|
+
this.status = status;
|
53
|
+
}
|
54
|
+
}
|
55
|
+
export class Client {
|
56
|
+
constructor(config) {
|
57
|
+
this.DEFAULT_JWT_STORAGE_KEY = "medusa_auth_token";
|
58
|
+
this.token = "";
|
59
|
+
this.getApiKeyHeader_ = () => {
|
60
|
+
return this.config.apiKey
|
61
|
+
? { Authorization: "Basic " + toBase64(this.config.apiKey + ":") }
|
62
|
+
: {};
|
63
|
+
};
|
64
|
+
this.getPublishableKeyHeader_ = () => {
|
65
|
+
return this.config.publishableKey
|
66
|
+
? { [PUBLISHABLE_KEY_HEADER]: this.config.publishableKey }
|
67
|
+
: {};
|
68
|
+
};
|
69
|
+
this.getJwtHeader_ = () => {
|
70
|
+
var _a;
|
71
|
+
// If the user has requested for session storage, we don't want to send the JWT token in the header.
|
72
|
+
if (((_a = this.config.auth) === null || _a === void 0 ? void 0 : _a.type) === "session") {
|
73
|
+
return {};
|
74
|
+
}
|
75
|
+
const token = this.getToken_();
|
76
|
+
return token ? { Authorization: `Bearer ${token}` } : {};
|
77
|
+
};
|
78
|
+
this.setToken_ = (token) => {
|
79
|
+
const { storageMethod, storageKey } = this.getTokenStorageInfo_();
|
80
|
+
switch (storageMethod) {
|
81
|
+
case "local": {
|
82
|
+
window.localStorage.setItem(storageKey, token);
|
83
|
+
break;
|
84
|
+
}
|
85
|
+
case "session": {
|
86
|
+
window.sessionStorage.setItem(storageKey, token);
|
87
|
+
break;
|
88
|
+
}
|
89
|
+
case "memory": {
|
90
|
+
this.token = token;
|
91
|
+
break;
|
92
|
+
}
|
93
|
+
}
|
94
|
+
};
|
95
|
+
this.getToken_ = () => {
|
96
|
+
const { storageMethod, storageKey } = this.getTokenStorageInfo_();
|
97
|
+
switch (storageMethod) {
|
98
|
+
case "local": {
|
99
|
+
return window.localStorage.getItem(storageKey);
|
100
|
+
}
|
101
|
+
case "session": {
|
102
|
+
return window.sessionStorage.getItem(storageKey);
|
103
|
+
}
|
104
|
+
case "memory": {
|
105
|
+
return this.token;
|
106
|
+
}
|
107
|
+
}
|
108
|
+
return;
|
109
|
+
};
|
110
|
+
this.getTokenStorageInfo_ = () => {
|
111
|
+
var _a, _b;
|
112
|
+
const hasLocal = hasStorage("localStorage");
|
113
|
+
const hasSession = hasStorage("sessionStorage");
|
114
|
+
const storageMethod = ((_a = this.config.auth) === null || _a === void 0 ? void 0 : _a.jwtTokenStorageMethod) || (hasLocal ? "local" : "memory");
|
115
|
+
const storageKey = ((_b = this.config.auth) === null || _b === void 0 ? void 0 : _b.jwtTokenStorageKey) || this.DEFAULT_JWT_STORAGE_KEY;
|
116
|
+
if (!hasLocal && storageMethod === "local") {
|
117
|
+
throw new Error("Local JWT storage is only available in the browser");
|
118
|
+
}
|
119
|
+
if (!hasSession && storageMethod === "session") {
|
120
|
+
throw new Error("Session JWT storage is only available in the browser");
|
121
|
+
}
|
122
|
+
return {
|
123
|
+
storageMethod,
|
124
|
+
storageKey,
|
125
|
+
};
|
126
|
+
};
|
127
|
+
this.config = config;
|
128
|
+
const logger = config.logger || {
|
129
|
+
error: console.error,
|
130
|
+
warn: console.warn,
|
131
|
+
info: console.info,
|
132
|
+
debug: console.debug,
|
133
|
+
};
|
134
|
+
this.logger = Object.assign(Object.assign({}, logger), { debug: config.debug ? logger.debug : () => { } });
|
135
|
+
this.fetch_ = this.initClient();
|
136
|
+
}
|
137
|
+
/**
|
138
|
+
* `fetch` closely follows (and uses under the hood) the native `fetch` API. There are, however, few key differences:
|
139
|
+
* - Non 2xx statuses throw a `FetchError` with the status code as the `status` property, rather than resolving the promise
|
140
|
+
* - You can pass `body` and `query` as objects, and they will be encoded and stringified.
|
141
|
+
* - The response gets parsed as JSON if the `accept` header is set to `application/json`, otherwise the raw Response object is returned
|
142
|
+
*
|
143
|
+
* Since the response is dynamically determined, we cannot know if it is JSON or not. Therefore, it is important to pass `Response` as the return type
|
144
|
+
*
|
145
|
+
* @param input: FetchInput
|
146
|
+
* @param init: FetchArgs
|
147
|
+
* @returns Promise<T>
|
148
|
+
*/
|
149
|
+
fetch(input, init) {
|
150
|
+
return this.fetch_(input, init);
|
151
|
+
}
|
152
|
+
/**
|
153
|
+
* `fetchStream` is a helper method to deal with server-sent events. It returns an object with a stream and an abort function.
|
154
|
+
* It follows a very similar interface to `fetch`, with the return value being an async generator.
|
155
|
+
* The stream is an async generator that yields `ServerSentEventMessage` objects, which contains the event name, stringified data, and few other properties.
|
156
|
+
* The caller is responsible for handling `disconnect` events and aborting the stream. The caller is also responsible for parsing the data field.
|
157
|
+
*
|
158
|
+
* @param input: FetchInput
|
159
|
+
* @param init: FetchArgs
|
160
|
+
* @returns FetchStreamResponse
|
161
|
+
*/
|
162
|
+
fetchStream(input, init) {
|
163
|
+
return __awaiter(this, void 0, void 0, function* () {
|
164
|
+
let abort = new AbortController();
|
165
|
+
let res = yield this.fetch_(input, Object.assign(Object.assign({}, init), { signal: abort.signal, headers: Object.assign(Object.assign({}, init === null || init === void 0 ? void 0 : init.headers), { accept: "text/event-stream" }) }));
|
166
|
+
if (res.ok) {
|
167
|
+
return { stream: events(res, abort.signal), abort: abort.abort };
|
168
|
+
}
|
169
|
+
return { stream: null, abort: abort.abort };
|
170
|
+
});
|
171
|
+
}
|
172
|
+
setToken(token) {
|
173
|
+
this.setToken_(token);
|
174
|
+
}
|
175
|
+
clearToken() {
|
176
|
+
this.clearToken_();
|
177
|
+
}
|
178
|
+
clearToken_() {
|
179
|
+
const { storageMethod, storageKey } = this.getTokenStorageInfo_();
|
180
|
+
switch (storageMethod) {
|
181
|
+
case "local": {
|
182
|
+
window.localStorage.removeItem(storageKey);
|
183
|
+
break;
|
184
|
+
}
|
185
|
+
case "session": {
|
186
|
+
window.sessionStorage.removeItem(storageKey);
|
187
|
+
break;
|
188
|
+
}
|
189
|
+
case "memory": {
|
190
|
+
this.token = "";
|
191
|
+
break;
|
192
|
+
}
|
193
|
+
}
|
194
|
+
}
|
195
|
+
initClient() {
|
196
|
+
const defaultHeaders = new Headers(Object.assign(Object.assign({ "content-type": "application/json", accept: "application/json" }, this.getApiKeyHeader_()), this.getPublishableKeyHeader_()));
|
197
|
+
this.logger.debug("Initiating Medusa client with default headers:\n", `${JSON.stringify(sanitizeHeaders(defaultHeaders), null, 2)}\n`);
|
198
|
+
return (input, init) => __awaiter(this, void 0, void 0, function* () {
|
199
|
+
// We always want to fetch the up-to-date JWT token before firing off a request.
|
200
|
+
const headers = new Headers(defaultHeaders);
|
201
|
+
const customHeaders = Object.assign(Object.assign(Object.assign({}, this.config.globalHeaders), this.getJwtHeader_()), init === null || init === void 0 ? void 0 : init.headers);
|
202
|
+
// We use `headers.set` in order to ensure headers are overwritten in a case-insensitive manner.
|
203
|
+
Object.entries(customHeaders).forEach(([key, value]) => {
|
204
|
+
if (value === null) {
|
205
|
+
headers.delete(key);
|
206
|
+
}
|
207
|
+
else {
|
208
|
+
headers.set(key, value);
|
209
|
+
}
|
210
|
+
});
|
211
|
+
let normalizedInput = input;
|
212
|
+
if (input instanceof URL || typeof input === "string") {
|
213
|
+
normalizedInput = new URL(input, this.config.baseUrl);
|
214
|
+
if (init === null || init === void 0 ? void 0 : init.query) {
|
215
|
+
const params = Object.fromEntries(normalizedInput.searchParams.entries());
|
216
|
+
const stringifiedQuery = qs.stringify(Object.assign(Object.assign({}, params), init.query));
|
217
|
+
normalizedInput.search = stringifiedQuery;
|
218
|
+
}
|
219
|
+
}
|
220
|
+
this.logger.debug("Performing request to:\n", `URL: ${normalizedInput.toString()}\n`, `Headers: ${JSON.stringify(sanitizeHeaders(headers), null, 2)}\n`);
|
221
|
+
// Any non-request errors (eg. invalid JSON in the response) will be thrown as-is.
|
222
|
+
return yield fetch(normalizedInput, normalizeRequest(init, headers, this.config)).then((resp) => {
|
223
|
+
this.logger.debug(`Received response with status ${resp.status}\n`);
|
224
|
+
return normalizeResponse(resp, headers);
|
225
|
+
});
|
226
|
+
});
|
227
|
+
}
|
228
|
+
}
|
229
|
+
//# sourceMappingURL=client.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,MAAM,IAAI,CAAA;AACnB,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAo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,MAAM,CAAC,KAAK,CAAC,iCAAiC,IAAI,CAAC,MAAM,IAAI,CAAC,CAAA;gBACnE,OAAO,iBAAiB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;YACzC,CAAC,CAAC,CAAA;QACJ,CAAC,CAAA,CAAA;IACH,CAAC;CAkFF"}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
import { Admin } from "./admin";
|
2
|
+
import { Auth } from "./auth";
|
3
|
+
import { Client } from "./client";
|
4
|
+
import { Store } from "./store";
|
5
|
+
import { Config } from "./types";
|
6
|
+
declare class Medusa {
|
7
|
+
client: Client;
|
8
|
+
admin: Admin;
|
9
|
+
store: Store;
|
10
|
+
auth: Auth;
|
11
|
+
constructor(config: Config);
|
12
|
+
}
|
13
|
+
export default Medusa;
|
14
|
+
export { FetchError } from "./client";
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAC/B,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAC7B,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACjC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAC/B,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAEhC,cAAM,MAAM;IACH,MAAM,EAAE,MAAM,CAAA;IAEd,KAAK,EAAE,KAAK,CAAA;IACZ,KAAK,EAAE,KAAK,CAAA;IACZ,IAAI,EAAE,IAAI,CAAA;gBAEL,MAAM,EAAE,MAAM;CAO3B;AAED,eAAe,MAAM,CAAA;AACrB,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA"}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
import { Admin } from "./admin";
|
2
|
+
import { Auth } from "./auth";
|
3
|
+
import { Client } from "./client";
|
4
|
+
import { Store } from "./store";
|
5
|
+
class Medusa {
|
6
|
+
constructor(config) {
|
7
|
+
this.client = new Client(config);
|
8
|
+
this.admin = new Admin(this.client);
|
9
|
+
this.store = new Store(this.client);
|
10
|
+
this.auth = new Auth(this.client, config);
|
11
|
+
}
|
12
|
+
}
|
13
|
+
export default Medusa;
|
14
|
+
export { FetchError } from "./client";
|
15
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAC/B,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAC7B,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACjC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAG/B,MAAM,MAAM;IAOV,YAAY,MAAc;QACxB,IAAI,CAAC,MAAM,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,CAAA;QAEhC,IAAI,CAAC,KAAK,GAAG,IAAI,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;QACnC,IAAI,CAAC,KAAK,GAAG,IAAI,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;QACnC,IAAI,CAAC,IAAI,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC3C,CAAC;CACF;AAED,eAAe,MAAM,CAAA;AACrB,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA"}
|