@moonbase.sh/storefront-api 0.3.10 → 0.3.11
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/index.cjs +78 -15
- package/dist/index.d.cts +28 -1
- package/dist/index.d.ts +28 -1
- package/dist/index.js +76 -15
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -36,6 +36,7 @@ __export(index_exports, {
|
|
|
36
36
|
ActivationStatus: () => ActivationStatus,
|
|
37
37
|
CycleLength: () => CycleLength,
|
|
38
38
|
LicenseStatus: () => LicenseStatus,
|
|
39
|
+
MoonbaseApi: () => MoonbaseApi,
|
|
39
40
|
MoonbaseClient: () => MoonbaseClient,
|
|
40
41
|
MoonbaseError: () => MoonbaseError,
|
|
41
42
|
NotAuthenticatedError: () => NotAuthenticatedError,
|
|
@@ -45,6 +46,7 @@ __export(index_exports, {
|
|
|
45
46
|
Platform: () => Platform,
|
|
46
47
|
SubscriptionStatus: () => SubscriptionStatus,
|
|
47
48
|
TokenStore: () => TokenStore,
|
|
49
|
+
problemDetailsSchema: () => problemDetailsSchema,
|
|
48
50
|
schemas: () => schemas_exports3,
|
|
49
51
|
utmToObject: () => utmToObject
|
|
50
52
|
});
|
|
@@ -329,15 +331,18 @@ var MoonbaseError = class extends Error {
|
|
|
329
331
|
}
|
|
330
332
|
};
|
|
331
333
|
|
|
332
|
-
// src/utils/
|
|
334
|
+
// src/utils/problemDetails.ts
|
|
333
335
|
var import_zod6 = require("zod");
|
|
334
336
|
var problemDetailsSchema = import_zod6.z.object({
|
|
335
|
-
type: import_zod6.z.string(),
|
|
337
|
+
type: import_zod6.z.string().optional(),
|
|
336
338
|
title: import_zod6.z.string(),
|
|
337
339
|
detail: import_zod6.z.string().optional(),
|
|
338
|
-
status: import_zod6.z.number(),
|
|
340
|
+
status: import_zod6.z.number().optional(),
|
|
341
|
+
instance: import_zod6.z.string().optional(),
|
|
339
342
|
errors: import_zod6.z.record(import_zod6.z.string(), import_zod6.z.string().array()).optional()
|
|
340
343
|
});
|
|
344
|
+
|
|
345
|
+
// src/utils/problemHandler.ts
|
|
341
346
|
function camelCase(str) {
|
|
342
347
|
return str.split(".").map((word, index) => {
|
|
343
348
|
let [firstLetter, ...restOfLetters] = word;
|
|
@@ -903,7 +908,7 @@ var MoonbaseApi = class {
|
|
|
903
908
|
var _a;
|
|
904
909
|
const accessToken = await this.tokenStore.getAccessToken();
|
|
905
910
|
const contentType = (_a = options == null ? void 0 : options.contentType) != null ? _a : "application/json";
|
|
906
|
-
const
|
|
911
|
+
const request = {
|
|
907
912
|
method: (options == null ? void 0 : options.method) || "GET",
|
|
908
913
|
mode: "cors",
|
|
909
914
|
headers: {
|
|
@@ -917,9 +922,16 @@ var MoonbaseApi = class {
|
|
|
917
922
|
body: (options == null ? void 0 : options.body) ? contentType !== "application/json" ? options.body : JSON.stringify(options.body) : void 0,
|
|
918
923
|
signal: options == null ? void 0 : options.abort,
|
|
919
924
|
redirect: "manual"
|
|
920
|
-
}
|
|
921
|
-
|
|
922
|
-
|
|
925
|
+
};
|
|
926
|
+
const response = await (0, import_cross_fetch2.default)(this.baseUrl + path, request);
|
|
927
|
+
if (response.status >= 400) {
|
|
928
|
+
try {
|
|
929
|
+
await handleResponseProblem(response);
|
|
930
|
+
} catch (err) {
|
|
931
|
+
this.reportRequestProblem(path, request, response, err);
|
|
932
|
+
throw err;
|
|
933
|
+
}
|
|
934
|
+
}
|
|
923
935
|
let json;
|
|
924
936
|
try {
|
|
925
937
|
json = schema ? await response.json() : null;
|
|
@@ -937,9 +949,58 @@ var MoonbaseApi = class {
|
|
|
937
949
|
userAgent: window && window.navigator && window.navigator.userAgent,
|
|
938
950
|
err
|
|
939
951
|
});
|
|
952
|
+
this.reportParsingProblem(path, err, json || (response.bodyUsed ? "unknown" : await response.text()));
|
|
940
953
|
throw new MoonbaseError("Bad response", "Could not parse server response", response.status);
|
|
941
954
|
}
|
|
942
955
|
}
|
|
956
|
+
async reportParsingProblem(path, err, body) {
|
|
957
|
+
try {
|
|
958
|
+
await (0, import_cross_fetch2.default)(this.baseUrl + "/api/customer/insights/error", {
|
|
959
|
+
mode: "cors",
|
|
960
|
+
method: "POST",
|
|
961
|
+
headers: {
|
|
962
|
+
"Accept": "application/json",
|
|
963
|
+
"Content-Type": "application/json"
|
|
964
|
+
},
|
|
965
|
+
body: JSON.stringify({
|
|
966
|
+
title: "Parse error",
|
|
967
|
+
detail: `Could not parse response body`,
|
|
968
|
+
path,
|
|
969
|
+
origin: window == null ? void 0 : window.location.href,
|
|
970
|
+
userAgent: window && window.navigator && window.navigator.userAgent,
|
|
971
|
+
err,
|
|
972
|
+
body
|
|
973
|
+
})
|
|
974
|
+
});
|
|
975
|
+
} catch (e) {
|
|
976
|
+
}
|
|
977
|
+
}
|
|
978
|
+
async reportRequestProblem(path, request, response, err) {
|
|
979
|
+
try {
|
|
980
|
+
await (0, import_cross_fetch2.default)(this.baseUrl + "/api/customer/insights/warn", {
|
|
981
|
+
mode: "cors",
|
|
982
|
+
method: "POST",
|
|
983
|
+
headers: {
|
|
984
|
+
"Accept": "application/json",
|
|
985
|
+
"Content-Type": "application/json"
|
|
986
|
+
},
|
|
987
|
+
body: JSON.stringify({
|
|
988
|
+
title: "Request error",
|
|
989
|
+
detail: `Request failed with status ${response.status}`,
|
|
990
|
+
status: response.status,
|
|
991
|
+
request: {
|
|
992
|
+
...request,
|
|
993
|
+
headers: void 0,
|
|
994
|
+
body: void 0
|
|
995
|
+
},
|
|
996
|
+
error: err,
|
|
997
|
+
path,
|
|
998
|
+
origin: window == null ? void 0 : window.location.href
|
|
999
|
+
})
|
|
1000
|
+
});
|
|
1001
|
+
} catch (e) {
|
|
1002
|
+
}
|
|
1003
|
+
}
|
|
943
1004
|
};
|
|
944
1005
|
|
|
945
1006
|
// src/utils/tokenStore.ts
|
|
@@ -1109,14 +1170,14 @@ var MoonbaseClient = class {
|
|
|
1109
1170
|
this.configuration = configuration;
|
|
1110
1171
|
this.configuration.endpoint = this.configuration.endpoint.replace(/\/$/, "");
|
|
1111
1172
|
this.tokenStore = new TokenStore(configuration);
|
|
1112
|
-
|
|
1113
|
-
this.storefront = new StorefrontEndpoints(api, this.configuration);
|
|
1114
|
-
this.identity = new IdentityEndpoints(api, this.tokenStore);
|
|
1115
|
-
this.vouchers = new VoucherEndpoints(api);
|
|
1116
|
-
this.orders = new OrderEndpoints(api);
|
|
1117
|
-
this.inventory = new InventoryEndpoints(api, this.configuration);
|
|
1118
|
-
this.activationRequests = new ActivationRequestEndpoints(api);
|
|
1119
|
-
this.vendor = new VendorEndpoints(api);
|
|
1173
|
+
this.api = new MoonbaseApi(this.configuration.endpoint, this.tokenStore);
|
|
1174
|
+
this.storefront = new StorefrontEndpoints(this.api, this.configuration);
|
|
1175
|
+
this.identity = new IdentityEndpoints(this.api, this.tokenStore);
|
|
1176
|
+
this.vouchers = new VoucherEndpoints(this.api);
|
|
1177
|
+
this.orders = new OrderEndpoints(this.api);
|
|
1178
|
+
this.inventory = new InventoryEndpoints(this.api, this.configuration);
|
|
1179
|
+
this.activationRequests = new ActivationRequestEndpoints(this.api);
|
|
1180
|
+
this.vendor = new VendorEndpoints(this.api);
|
|
1120
1181
|
}
|
|
1121
1182
|
};
|
|
1122
1183
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -1127,6 +1188,7 @@ var MoonbaseClient = class {
|
|
|
1127
1188
|
ActivationStatus,
|
|
1128
1189
|
CycleLength,
|
|
1129
1190
|
LicenseStatus,
|
|
1191
|
+
MoonbaseApi,
|
|
1130
1192
|
MoonbaseClient,
|
|
1131
1193
|
MoonbaseError,
|
|
1132
1194
|
NotAuthenticatedError,
|
|
@@ -1136,6 +1198,7 @@ var MoonbaseClient = class {
|
|
|
1136
1198
|
Platform,
|
|
1137
1199
|
SubscriptionStatus,
|
|
1138
1200
|
TokenStore,
|
|
1201
|
+
problemDetailsSchema,
|
|
1139
1202
|
schemas,
|
|
1140
1203
|
utmToObject
|
|
1141
1204
|
});
|
package/dist/index.d.cts
CHANGED
|
@@ -260,6 +260,8 @@ declare class MoonbaseApi {
|
|
|
260
260
|
constructor(baseUrl: string, tokenStore: TokenStore);
|
|
261
261
|
authenticatedFetch<T extends ZodTypeAny>(path: string, schema: T | null, options?: FetchOptions): Promise<Response<z.infer<T>>>;
|
|
262
262
|
fetch<T extends ZodTypeAny>(path: string, schema: T | null, options?: FetchOptions): Promise<Response<z.infer<T>>>;
|
|
263
|
+
private reportParsingProblem;
|
|
264
|
+
private reportRequestProblem;
|
|
263
265
|
}
|
|
264
266
|
|
|
265
267
|
declare const activationRequestSchema: z.ZodObject<{
|
|
@@ -21469,6 +21471,30 @@ declare class MoonbaseError extends Error {
|
|
|
21469
21471
|
constructor(title: string, detail: string | undefined, status?: number | undefined, errors?: Record<string, string> | undefined);
|
|
21470
21472
|
}
|
|
21471
21473
|
|
|
21474
|
+
declare const problemDetailsSchema: z.ZodObject<{
|
|
21475
|
+
type: z.ZodOptional<z.ZodString>;
|
|
21476
|
+
title: z.ZodString;
|
|
21477
|
+
detail: z.ZodOptional<z.ZodString>;
|
|
21478
|
+
status: z.ZodOptional<z.ZodNumber>;
|
|
21479
|
+
instance: z.ZodOptional<z.ZodString>;
|
|
21480
|
+
errors: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString, "many">>>;
|
|
21481
|
+
}, "strip", z.ZodTypeAny, {
|
|
21482
|
+
title: string;
|
|
21483
|
+
type?: string | undefined;
|
|
21484
|
+
status?: number | undefined;
|
|
21485
|
+
detail?: string | undefined;
|
|
21486
|
+
instance?: string | undefined;
|
|
21487
|
+
errors?: Record<string, string[]> | undefined;
|
|
21488
|
+
}, {
|
|
21489
|
+
title: string;
|
|
21490
|
+
type?: string | undefined;
|
|
21491
|
+
status?: number | undefined;
|
|
21492
|
+
detail?: string | undefined;
|
|
21493
|
+
instance?: string | undefined;
|
|
21494
|
+
errors?: Record<string, string[]> | undefined;
|
|
21495
|
+
}>;
|
|
21496
|
+
type ProblemDetails = z.infer<typeof problemDetailsSchema>;
|
|
21497
|
+
|
|
21472
21498
|
interface MoonbaseConfiguration {
|
|
21473
21499
|
endpoint: string;
|
|
21474
21500
|
persistUtm?: boolean;
|
|
@@ -21478,6 +21504,7 @@ declare class MoonbaseClient {
|
|
|
21478
21504
|
private readonly configuration;
|
|
21479
21505
|
readonly tokenStore: TokenStore;
|
|
21480
21506
|
constructor(configuration: MoonbaseConfiguration);
|
|
21507
|
+
api: MoonbaseApi;
|
|
21481
21508
|
storefront: StorefrontEndpoints;
|
|
21482
21509
|
identity: IdentityEndpoints;
|
|
21483
21510
|
vouchers: VoucherEndpoints;
|
|
@@ -21487,4 +21514,4 @@ declare class MoonbaseClient {
|
|
|
21487
21514
|
orders: OrderEndpoints;
|
|
21488
21515
|
}
|
|
21489
21516
|
|
|
21490
|
-
export { type Activation, ActivationMethod, type ActivationRequest, ActivationRequestFulfillmentType, ActivationRequestStatus, ActivationStatus, type Address, type BundleLineItem, type CommunicationPreferences, type CompletedOrder, CycleLength, type Discount, type Download, type DownloadManifest, type IRecurrence, type License, LicenseStatus, type LineItem, type Money, MoonbaseClient, type MoonbaseConfiguration, MoonbaseError, NotAuthenticatedError, NotAuthorizedError, NotFoundError, type OpenOrder, type Order, OrderStatus, type OwnedProduct, type Page, Platform, type PricingTier, type PricingVariation, type ProductLineItem, type Quantifiable, type Storefront, type StorefrontBundle, type StorefrontProduct, type Subscription, SubscriptionStatus, TokenStore, type UrchinTrackingModule, type User, type UserAccountConfirmed, type Vendor, type Voucher, schemas, utmToObject };
|
|
21517
|
+
export { type Activation, ActivationMethod, type ActivationRequest, ActivationRequestFulfillmentType, ActivationRequestStatus, ActivationStatus, type Address, type BundleLineItem, type CommunicationPreferences, type CompletedOrder, CycleLength, type Discount, type Download, type DownloadManifest, type IRecurrence, type License, LicenseStatus, type LineItem, type Money, MoonbaseApi, MoonbaseClient, type MoonbaseConfiguration, MoonbaseError, NotAuthenticatedError, NotAuthorizedError, NotFoundError, type OpenOrder, type Order, OrderStatus, type OwnedProduct, type Page, Platform, type PricingTier, type PricingVariation, type ProblemDetails, type ProductLineItem, type Quantifiable, type Storefront, type StorefrontBundle, type StorefrontProduct, type Subscription, SubscriptionStatus, TokenStore, type UrchinTrackingModule, type User, type UserAccountConfirmed, type Vendor, type Voucher, problemDetailsSchema, schemas, utmToObject };
|
package/dist/index.d.ts
CHANGED
|
@@ -260,6 +260,8 @@ declare class MoonbaseApi {
|
|
|
260
260
|
constructor(baseUrl: string, tokenStore: TokenStore);
|
|
261
261
|
authenticatedFetch<T extends ZodTypeAny>(path: string, schema: T | null, options?: FetchOptions): Promise<Response<z.infer<T>>>;
|
|
262
262
|
fetch<T extends ZodTypeAny>(path: string, schema: T | null, options?: FetchOptions): Promise<Response<z.infer<T>>>;
|
|
263
|
+
private reportParsingProblem;
|
|
264
|
+
private reportRequestProblem;
|
|
263
265
|
}
|
|
264
266
|
|
|
265
267
|
declare const activationRequestSchema: z.ZodObject<{
|
|
@@ -21469,6 +21471,30 @@ declare class MoonbaseError extends Error {
|
|
|
21469
21471
|
constructor(title: string, detail: string | undefined, status?: number | undefined, errors?: Record<string, string> | undefined);
|
|
21470
21472
|
}
|
|
21471
21473
|
|
|
21474
|
+
declare const problemDetailsSchema: z.ZodObject<{
|
|
21475
|
+
type: z.ZodOptional<z.ZodString>;
|
|
21476
|
+
title: z.ZodString;
|
|
21477
|
+
detail: z.ZodOptional<z.ZodString>;
|
|
21478
|
+
status: z.ZodOptional<z.ZodNumber>;
|
|
21479
|
+
instance: z.ZodOptional<z.ZodString>;
|
|
21480
|
+
errors: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString, "many">>>;
|
|
21481
|
+
}, "strip", z.ZodTypeAny, {
|
|
21482
|
+
title: string;
|
|
21483
|
+
type?: string | undefined;
|
|
21484
|
+
status?: number | undefined;
|
|
21485
|
+
detail?: string | undefined;
|
|
21486
|
+
instance?: string | undefined;
|
|
21487
|
+
errors?: Record<string, string[]> | undefined;
|
|
21488
|
+
}, {
|
|
21489
|
+
title: string;
|
|
21490
|
+
type?: string | undefined;
|
|
21491
|
+
status?: number | undefined;
|
|
21492
|
+
detail?: string | undefined;
|
|
21493
|
+
instance?: string | undefined;
|
|
21494
|
+
errors?: Record<string, string[]> | undefined;
|
|
21495
|
+
}>;
|
|
21496
|
+
type ProblemDetails = z.infer<typeof problemDetailsSchema>;
|
|
21497
|
+
|
|
21472
21498
|
interface MoonbaseConfiguration {
|
|
21473
21499
|
endpoint: string;
|
|
21474
21500
|
persistUtm?: boolean;
|
|
@@ -21478,6 +21504,7 @@ declare class MoonbaseClient {
|
|
|
21478
21504
|
private readonly configuration;
|
|
21479
21505
|
readonly tokenStore: TokenStore;
|
|
21480
21506
|
constructor(configuration: MoonbaseConfiguration);
|
|
21507
|
+
api: MoonbaseApi;
|
|
21481
21508
|
storefront: StorefrontEndpoints;
|
|
21482
21509
|
identity: IdentityEndpoints;
|
|
21483
21510
|
vouchers: VoucherEndpoints;
|
|
@@ -21487,4 +21514,4 @@ declare class MoonbaseClient {
|
|
|
21487
21514
|
orders: OrderEndpoints;
|
|
21488
21515
|
}
|
|
21489
21516
|
|
|
21490
|
-
export { type Activation, ActivationMethod, type ActivationRequest, ActivationRequestFulfillmentType, ActivationRequestStatus, ActivationStatus, type Address, type BundleLineItem, type CommunicationPreferences, type CompletedOrder, CycleLength, type Discount, type Download, type DownloadManifest, type IRecurrence, type License, LicenseStatus, type LineItem, type Money, MoonbaseClient, type MoonbaseConfiguration, MoonbaseError, NotAuthenticatedError, NotAuthorizedError, NotFoundError, type OpenOrder, type Order, OrderStatus, type OwnedProduct, type Page, Platform, type PricingTier, type PricingVariation, type ProductLineItem, type Quantifiable, type Storefront, type StorefrontBundle, type StorefrontProduct, type Subscription, SubscriptionStatus, TokenStore, type UrchinTrackingModule, type User, type UserAccountConfirmed, type Vendor, type Voucher, schemas, utmToObject };
|
|
21517
|
+
export { type Activation, ActivationMethod, type ActivationRequest, ActivationRequestFulfillmentType, ActivationRequestStatus, ActivationStatus, type Address, type BundleLineItem, type CommunicationPreferences, type CompletedOrder, CycleLength, type Discount, type Download, type DownloadManifest, type IRecurrence, type License, LicenseStatus, type LineItem, type Money, MoonbaseApi, MoonbaseClient, type MoonbaseConfiguration, MoonbaseError, NotAuthenticatedError, NotAuthorizedError, NotFoundError, type OpenOrder, type Order, OrderStatus, type OwnedProduct, type Page, Platform, type PricingTier, type PricingVariation, type ProblemDetails, type ProductLineItem, type Quantifiable, type Storefront, type StorefrontBundle, type StorefrontProduct, type Subscription, SubscriptionStatus, TokenStore, type UrchinTrackingModule, type User, type UserAccountConfirmed, type Vendor, type Voucher, problemDetailsSchema, schemas, utmToObject };
|
package/dist/index.js
CHANGED
|
@@ -283,15 +283,18 @@ var MoonbaseError = class extends Error {
|
|
|
283
283
|
}
|
|
284
284
|
};
|
|
285
285
|
|
|
286
|
-
// src/utils/
|
|
286
|
+
// src/utils/problemDetails.ts
|
|
287
287
|
import { z as z6 } from "zod";
|
|
288
288
|
var problemDetailsSchema = z6.object({
|
|
289
|
-
type: z6.string(),
|
|
289
|
+
type: z6.string().optional(),
|
|
290
290
|
title: z6.string(),
|
|
291
291
|
detail: z6.string().optional(),
|
|
292
|
-
status: z6.number(),
|
|
292
|
+
status: z6.number().optional(),
|
|
293
|
+
instance: z6.string().optional(),
|
|
293
294
|
errors: z6.record(z6.string(), z6.string().array()).optional()
|
|
294
295
|
});
|
|
296
|
+
|
|
297
|
+
// src/utils/problemHandler.ts
|
|
295
298
|
function camelCase(str) {
|
|
296
299
|
return str.split(".").map((word, index) => {
|
|
297
300
|
let [firstLetter, ...restOfLetters] = word;
|
|
@@ -857,7 +860,7 @@ var MoonbaseApi = class {
|
|
|
857
860
|
var _a;
|
|
858
861
|
const accessToken = await this.tokenStore.getAccessToken();
|
|
859
862
|
const contentType = (_a = options == null ? void 0 : options.contentType) != null ? _a : "application/json";
|
|
860
|
-
const
|
|
863
|
+
const request = {
|
|
861
864
|
method: (options == null ? void 0 : options.method) || "GET",
|
|
862
865
|
mode: "cors",
|
|
863
866
|
headers: {
|
|
@@ -871,9 +874,16 @@ var MoonbaseApi = class {
|
|
|
871
874
|
body: (options == null ? void 0 : options.body) ? contentType !== "application/json" ? options.body : JSON.stringify(options.body) : void 0,
|
|
872
875
|
signal: options == null ? void 0 : options.abort,
|
|
873
876
|
redirect: "manual"
|
|
874
|
-
}
|
|
875
|
-
|
|
876
|
-
|
|
877
|
+
};
|
|
878
|
+
const response = await fetch2(this.baseUrl + path, request);
|
|
879
|
+
if (response.status >= 400) {
|
|
880
|
+
try {
|
|
881
|
+
await handleResponseProblem(response);
|
|
882
|
+
} catch (err) {
|
|
883
|
+
this.reportRequestProblem(path, request, response, err);
|
|
884
|
+
throw err;
|
|
885
|
+
}
|
|
886
|
+
}
|
|
877
887
|
let json;
|
|
878
888
|
try {
|
|
879
889
|
json = schema ? await response.json() : null;
|
|
@@ -891,9 +901,58 @@ var MoonbaseApi = class {
|
|
|
891
901
|
userAgent: window && window.navigator && window.navigator.userAgent,
|
|
892
902
|
err
|
|
893
903
|
});
|
|
904
|
+
this.reportParsingProblem(path, err, json || (response.bodyUsed ? "unknown" : await response.text()));
|
|
894
905
|
throw new MoonbaseError("Bad response", "Could not parse server response", response.status);
|
|
895
906
|
}
|
|
896
907
|
}
|
|
908
|
+
async reportParsingProblem(path, err, body) {
|
|
909
|
+
try {
|
|
910
|
+
await fetch2(this.baseUrl + "/api/customer/insights/error", {
|
|
911
|
+
mode: "cors",
|
|
912
|
+
method: "POST",
|
|
913
|
+
headers: {
|
|
914
|
+
"Accept": "application/json",
|
|
915
|
+
"Content-Type": "application/json"
|
|
916
|
+
},
|
|
917
|
+
body: JSON.stringify({
|
|
918
|
+
title: "Parse error",
|
|
919
|
+
detail: `Could not parse response body`,
|
|
920
|
+
path,
|
|
921
|
+
origin: window == null ? void 0 : window.location.href,
|
|
922
|
+
userAgent: window && window.navigator && window.navigator.userAgent,
|
|
923
|
+
err,
|
|
924
|
+
body
|
|
925
|
+
})
|
|
926
|
+
});
|
|
927
|
+
} catch (e) {
|
|
928
|
+
}
|
|
929
|
+
}
|
|
930
|
+
async reportRequestProblem(path, request, response, err) {
|
|
931
|
+
try {
|
|
932
|
+
await fetch2(this.baseUrl + "/api/customer/insights/warn", {
|
|
933
|
+
mode: "cors",
|
|
934
|
+
method: "POST",
|
|
935
|
+
headers: {
|
|
936
|
+
"Accept": "application/json",
|
|
937
|
+
"Content-Type": "application/json"
|
|
938
|
+
},
|
|
939
|
+
body: JSON.stringify({
|
|
940
|
+
title: "Request error",
|
|
941
|
+
detail: `Request failed with status ${response.status}`,
|
|
942
|
+
status: response.status,
|
|
943
|
+
request: {
|
|
944
|
+
...request,
|
|
945
|
+
headers: void 0,
|
|
946
|
+
body: void 0
|
|
947
|
+
},
|
|
948
|
+
error: err,
|
|
949
|
+
path,
|
|
950
|
+
origin: window == null ? void 0 : window.location.href
|
|
951
|
+
})
|
|
952
|
+
});
|
|
953
|
+
} catch (e) {
|
|
954
|
+
}
|
|
955
|
+
}
|
|
897
956
|
};
|
|
898
957
|
|
|
899
958
|
// src/utils/tokenStore.ts
|
|
@@ -1063,14 +1122,14 @@ var MoonbaseClient = class {
|
|
|
1063
1122
|
this.configuration = configuration;
|
|
1064
1123
|
this.configuration.endpoint = this.configuration.endpoint.replace(/\/$/, "");
|
|
1065
1124
|
this.tokenStore = new TokenStore(configuration);
|
|
1066
|
-
|
|
1067
|
-
this.storefront = new StorefrontEndpoints(api, this.configuration);
|
|
1068
|
-
this.identity = new IdentityEndpoints(api, this.tokenStore);
|
|
1069
|
-
this.vouchers = new VoucherEndpoints(api);
|
|
1070
|
-
this.orders = new OrderEndpoints(api);
|
|
1071
|
-
this.inventory = new InventoryEndpoints(api, this.configuration);
|
|
1072
|
-
this.activationRequests = new ActivationRequestEndpoints(api);
|
|
1073
|
-
this.vendor = new VendorEndpoints(api);
|
|
1125
|
+
this.api = new MoonbaseApi(this.configuration.endpoint, this.tokenStore);
|
|
1126
|
+
this.storefront = new StorefrontEndpoints(this.api, this.configuration);
|
|
1127
|
+
this.identity = new IdentityEndpoints(this.api, this.tokenStore);
|
|
1128
|
+
this.vouchers = new VoucherEndpoints(this.api);
|
|
1129
|
+
this.orders = new OrderEndpoints(this.api);
|
|
1130
|
+
this.inventory = new InventoryEndpoints(this.api, this.configuration);
|
|
1131
|
+
this.activationRequests = new ActivationRequestEndpoints(this.api);
|
|
1132
|
+
this.vendor = new VendorEndpoints(this.api);
|
|
1074
1133
|
}
|
|
1075
1134
|
};
|
|
1076
1135
|
export {
|
|
@@ -1080,6 +1139,7 @@ export {
|
|
|
1080
1139
|
ActivationStatus,
|
|
1081
1140
|
CycleLength,
|
|
1082
1141
|
LicenseStatus,
|
|
1142
|
+
MoonbaseApi,
|
|
1083
1143
|
MoonbaseClient,
|
|
1084
1144
|
MoonbaseError,
|
|
1085
1145
|
NotAuthenticatedError,
|
|
@@ -1089,6 +1149,7 @@ export {
|
|
|
1089
1149
|
Platform,
|
|
1090
1150
|
SubscriptionStatus,
|
|
1091
1151
|
TokenStore,
|
|
1152
|
+
problemDetailsSchema,
|
|
1092
1153
|
schemas_exports3 as schemas,
|
|
1093
1154
|
utmToObject
|
|
1094
1155
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moonbase.sh/storefront-api",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.11",
|
|
5
5
|
"description": "Package to let you build storefronts with Moonbase.sh as payment and delivery provider",
|
|
6
6
|
"author": "Tobias Lønnerød Madsen <m@dsen.tv>",
|
|
7
7
|
"license": "MIT",
|