@moonbase.sh/storefront-api 0.1.91 → 0.1.93
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 +42 -29
- package/dist/index.d.cts +11 -2
- package/dist/index.d.ts +11 -2
- package/dist/index.js +42 -29
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -195,19 +195,19 @@ var ActivationRequestEndpoints = class {
|
|
|
195
195
|
}
|
|
196
196
|
async get(requestId) {
|
|
197
197
|
const response = await this.api.fetch(`/api/customer/activations/${requestId}`);
|
|
198
|
-
return activationRequestSchema.parse(response);
|
|
198
|
+
return activationRequestSchema.parse(response.data);
|
|
199
199
|
}
|
|
200
200
|
async isCompleted(requestId) {
|
|
201
201
|
const response = await this.api.fetch(`/api/customer/activations/${requestId}/completed`);
|
|
202
|
-
return import_zod5.z.boolean().parse(response);
|
|
202
|
+
return import_zod5.z.boolean().parse(response.data);
|
|
203
203
|
}
|
|
204
204
|
async fulfillLicense(requestId) {
|
|
205
205
|
const response = await this.api.authenticatedFetch(`/api/customer/activations/${requestId}/license`, "POST");
|
|
206
|
-
return activationRequestSchema.parse(response);
|
|
206
|
+
return activationRequestSchema.parse(response.data);
|
|
207
207
|
}
|
|
208
208
|
async fulfillTrial(requestId) {
|
|
209
209
|
const response = await this.api.fetch(`/api/customer/activations/${requestId}/trial`, "POST");
|
|
210
|
-
return activationRequestSchema.parse(response);
|
|
210
|
+
return activationRequestSchema.parse(response.data);
|
|
211
211
|
}
|
|
212
212
|
};
|
|
213
213
|
|
|
@@ -300,7 +300,7 @@ var IdentityEndpoints = class {
|
|
|
300
300
|
}
|
|
301
301
|
async get() {
|
|
302
302
|
const response = await this.api.authenticatedFetch("/api/customer/meta/user");
|
|
303
|
-
return userSchema.parse(response);
|
|
303
|
+
return userSchema.parse(response.data);
|
|
304
304
|
}
|
|
305
305
|
async signIn(email, password) {
|
|
306
306
|
const response = await (0, import_cross_fetch.default)(`${this.api.baseUrl}/api/customer/identity/sign-in?email=${email}&scheme=JWT`, {
|
|
@@ -328,7 +328,7 @@ var IdentityEndpoints = class {
|
|
|
328
328
|
acceptedPrivacyPolicy,
|
|
329
329
|
acceptedTermsAndConditions
|
|
330
330
|
});
|
|
331
|
-
const user = identityUserSchema.parse(response);
|
|
331
|
+
const user = identityUserSchema.parse(response.data);
|
|
332
332
|
this.tokenStore.setUser(user);
|
|
333
333
|
return user;
|
|
334
334
|
}
|
|
@@ -412,13 +412,13 @@ var LicenseEndpoints = class {
|
|
|
412
412
|
}
|
|
413
413
|
async get(nextUrl) {
|
|
414
414
|
const response = await this.api.authenticatedFetch(nextUrl || "/api/customer/licenses");
|
|
415
|
-
return paged(licenseSchema).parse(response);
|
|
415
|
+
return paged(licenseSchema).parse(response.data);
|
|
416
416
|
}
|
|
417
417
|
async getActivations(licenseId, nextUrl) {
|
|
418
418
|
const response = await this.api.authenticatedFetch(
|
|
419
419
|
nextUrl || `/api/customer/licenses/${licenseId}/activations`
|
|
420
420
|
);
|
|
421
|
-
return paged(activationSchema).parse(response);
|
|
421
|
+
return paged(activationSchema).parse(response.data);
|
|
422
422
|
}
|
|
423
423
|
async revokeActivation(licenseId, activationId) {
|
|
424
424
|
await this.api.authenticatedFetch(`/api/customer/licenses/${licenseId}/activations/${activationId}/revoke`, "POST");
|
|
@@ -509,7 +509,7 @@ var OrderEndpoints = class {
|
|
|
509
509
|
}
|
|
510
510
|
async get(orderId) {
|
|
511
511
|
const response = await this.api.fetch(`/api/customer/orders/${orderId}`);
|
|
512
|
-
return orderSchema.parse(response);
|
|
512
|
+
return orderSchema.parse(response.data);
|
|
513
513
|
}
|
|
514
514
|
async pushContent(order, checkout) {
|
|
515
515
|
const response = await this.api.fetch(
|
|
@@ -520,26 +520,34 @@ var OrderEndpoints = class {
|
|
|
520
520
|
items: order.items
|
|
521
521
|
}
|
|
522
522
|
);
|
|
523
|
-
return openOrderSchema.parse(response);
|
|
523
|
+
return openOrderSchema.parse(response.data);
|
|
524
524
|
}
|
|
525
525
|
};
|
|
526
526
|
|
|
527
527
|
// src/products/endpoints.ts
|
|
528
|
+
var import_zod10 = require("zod");
|
|
528
529
|
var ProductEndpoints = class {
|
|
529
530
|
constructor(api) {
|
|
530
531
|
this.api = api;
|
|
531
532
|
}
|
|
532
533
|
async getOwned(nextUrl) {
|
|
533
534
|
const response = await this.api.authenticatedFetch(nextUrl || "/api/customer/products");
|
|
534
|
-
return paged(productSummarySchema).parse(response);
|
|
535
|
+
return paged(productSummarySchema).parse(response.data);
|
|
535
536
|
}
|
|
536
537
|
async getLicenses(productId, nextUrl) {
|
|
537
538
|
const response = await this.api.authenticatedFetch(nextUrl || `/api/customer/products/${productId}/licenses`);
|
|
538
|
-
return paged(licenseSchema).parse(response);
|
|
539
|
+
return paged(licenseSchema).parse(response.data);
|
|
539
540
|
}
|
|
540
541
|
async getActivations(productId, nextUrl) {
|
|
541
542
|
const response = await this.api.authenticatedFetch(nextUrl || `/api/customer/products/${productId}/licenses/activations`);
|
|
542
|
-
return paged(activationSchema).parse(response);
|
|
543
|
+
return paged(activationSchema).parse(response.data);
|
|
544
|
+
}
|
|
545
|
+
async activate(deviceToken, activationMethod) {
|
|
546
|
+
const response = await this.api.authenticatedFetch(`/api/customer/products/activate?method=${activationMethod}`, "POST", deviceToken, "text/plain");
|
|
547
|
+
return {
|
|
548
|
+
license: licenseSchema.parse(response.data),
|
|
549
|
+
url: import_zod10.z.string().parse(response.headers.get("location"))
|
|
550
|
+
};
|
|
543
551
|
}
|
|
544
552
|
};
|
|
545
553
|
|
|
@@ -550,7 +558,7 @@ var StorefrontEndpoints = class {
|
|
|
550
558
|
}
|
|
551
559
|
async get() {
|
|
552
560
|
const response = await this.api.fetch("/api/customer/storefront");
|
|
553
|
-
return storefrontSchema.parse(response);
|
|
561
|
+
return storefrontSchema.parse(response.data);
|
|
554
562
|
}
|
|
555
563
|
};
|
|
556
564
|
|
|
@@ -561,30 +569,35 @@ var MoonbaseApi = class {
|
|
|
561
569
|
this.baseUrl = baseUrl;
|
|
562
570
|
this.tokenStore = tokenStore;
|
|
563
571
|
}
|
|
564
|
-
async authenticatedFetch(path, method, body) {
|
|
572
|
+
async authenticatedFetch(path, method, body, contentType) {
|
|
565
573
|
if (!this.tokenStore.hasAccessToken)
|
|
566
574
|
throw new NotAuthenticatedError();
|
|
567
|
-
return await this.fetch(path, method, body);
|
|
575
|
+
return await this.fetch(path, method, body, contentType);
|
|
568
576
|
}
|
|
569
|
-
async fetch(path, method, body) {
|
|
577
|
+
async fetch(path, method, body, contentType) {
|
|
570
578
|
const accessToken = await this.tokenStore.getAccessToken();
|
|
579
|
+
contentType != null ? contentType : contentType = "application/json";
|
|
571
580
|
const response = await (0, import_cross_fetch2.default)(this.baseUrl + path, {
|
|
572
581
|
method: method || "GET",
|
|
573
582
|
mode: "cors",
|
|
574
583
|
headers: {
|
|
575
584
|
"Accept": "application/json",
|
|
576
|
-
"Content-Type":
|
|
585
|
+
"Content-Type": contentType,
|
|
577
586
|
// While this fetch can be anonymous, we add the token if we have it
|
|
578
587
|
...accessToken ? { Authorization: `Bearer ${accessToken}` } : {},
|
|
579
588
|
// Force CORS on all calls
|
|
580
589
|
"x-mb-cors": "1"
|
|
581
590
|
},
|
|
582
|
-
body: body ? JSON.stringify(body) : void 0
|
|
591
|
+
body: body ? contentType !== "application/json" ? body : JSON.stringify(body) : void 0
|
|
583
592
|
});
|
|
584
593
|
if (response.status >= 400)
|
|
585
594
|
await handleResponseProblem(response);
|
|
586
595
|
const contentLength = Number(response.headers.get("Content-Length")) || 0;
|
|
587
|
-
return
|
|
596
|
+
return {
|
|
597
|
+
data: contentLength > 0 ? await response.json() : null,
|
|
598
|
+
headers: response.headers,
|
|
599
|
+
status: response.status
|
|
600
|
+
};
|
|
588
601
|
}
|
|
589
602
|
};
|
|
590
603
|
|
|
@@ -687,13 +700,13 @@ _TokenStore.storageKey = "moonbase_auth";
|
|
|
687
700
|
var TokenStore = _TokenStore;
|
|
688
701
|
|
|
689
702
|
// src/vouchers/schemas.ts
|
|
690
|
-
var
|
|
691
|
-
var voucherSchema =
|
|
692
|
-
id:
|
|
693
|
-
name:
|
|
694
|
-
description:
|
|
695
|
-
code:
|
|
696
|
-
redeemed:
|
|
703
|
+
var import_zod11 = require("zod");
|
|
704
|
+
var voucherSchema = import_zod11.z.object({
|
|
705
|
+
id: import_zod11.z.string(),
|
|
706
|
+
name: import_zod11.z.string(),
|
|
707
|
+
description: import_zod11.z.string(),
|
|
708
|
+
code: import_zod11.z.string(),
|
|
709
|
+
redeemed: import_zod11.z.boolean(),
|
|
697
710
|
redeemsProducts: quantifiable(storefrontProductSchema).array(),
|
|
698
711
|
redeemsBundles: quantifiable(storefrontBundleSchema).array()
|
|
699
712
|
});
|
|
@@ -705,14 +718,14 @@ var VoucherEndpoints = class {
|
|
|
705
718
|
}
|
|
706
719
|
async peek(code) {
|
|
707
720
|
const response = await this.api.fetch(`/api/customer/vouchers?code=${encodeURIComponent(code)}`);
|
|
708
|
-
return voucherSchema.parse(response);
|
|
721
|
+
return voucherSchema.parse(response.data);
|
|
709
722
|
}
|
|
710
723
|
async redeem(code) {
|
|
711
724
|
const response = await this.api.authenticatedFetch(
|
|
712
725
|
`/api/customer/vouchers/redeem?code=${encodeURIComponent(code)}`,
|
|
713
726
|
"POST"
|
|
714
727
|
);
|
|
715
|
-
return voucherSchema.parse(response);
|
|
728
|
+
return voucherSchema.parse(response.data);
|
|
716
729
|
}
|
|
717
730
|
};
|
|
718
731
|
|
package/dist/index.d.cts
CHANGED
|
@@ -194,12 +194,17 @@ declare class TokenStore {
|
|
|
194
194
|
}
|
|
195
195
|
|
|
196
196
|
type HttpMethods = 'GET' | 'POST' | 'PATCH' | 'PUT' | 'DELETE';
|
|
197
|
+
interface Response {
|
|
198
|
+
data: unknown;
|
|
199
|
+
headers: Headers;
|
|
200
|
+
status: number;
|
|
201
|
+
}
|
|
197
202
|
declare class MoonbaseApi {
|
|
198
203
|
baseUrl: string;
|
|
199
204
|
private tokenStore;
|
|
200
205
|
constructor(baseUrl: string, tokenStore: TokenStore);
|
|
201
|
-
authenticatedFetch(path: string, method?: HttpMethods, body?: any): Promise<
|
|
202
|
-
fetch(path: string, method?: HttpMethods, body?: any): Promise<
|
|
206
|
+
authenticatedFetch(path: string, method?: HttpMethods, body?: any, contentType?: string): Promise<Response>;
|
|
207
|
+
fetch(path: string, method?: HttpMethods, body?: any, contentType?: string): Promise<Response>;
|
|
203
208
|
}
|
|
204
209
|
|
|
205
210
|
declare const activationRequestSchema: z.ZodObject<{
|
|
@@ -9058,6 +9063,10 @@ declare class ProductEndpoints {
|
|
|
9058
9063
|
getOwned(nextUrl?: string): Promise<Page<OwnedProduct>>;
|
|
9059
9064
|
getLicenses(productId: string, nextUrl?: string): Promise<Page<License>>;
|
|
9060
9065
|
getActivations(productId: string, nextUrl?: string): Promise<Page<Activation>>;
|
|
9066
|
+
activate(deviceToken: string, activationMethod: ActivationMethod): Promise<{
|
|
9067
|
+
license: License;
|
|
9068
|
+
url: string;
|
|
9069
|
+
}>;
|
|
9061
9070
|
}
|
|
9062
9071
|
|
|
9063
9072
|
declare class StorefrontEndpoints {
|
package/dist/index.d.ts
CHANGED
|
@@ -194,12 +194,17 @@ declare class TokenStore {
|
|
|
194
194
|
}
|
|
195
195
|
|
|
196
196
|
type HttpMethods = 'GET' | 'POST' | 'PATCH' | 'PUT' | 'DELETE';
|
|
197
|
+
interface Response {
|
|
198
|
+
data: unknown;
|
|
199
|
+
headers: Headers;
|
|
200
|
+
status: number;
|
|
201
|
+
}
|
|
197
202
|
declare class MoonbaseApi {
|
|
198
203
|
baseUrl: string;
|
|
199
204
|
private tokenStore;
|
|
200
205
|
constructor(baseUrl: string, tokenStore: TokenStore);
|
|
201
|
-
authenticatedFetch(path: string, method?: HttpMethods, body?: any): Promise<
|
|
202
|
-
fetch(path: string, method?: HttpMethods, body?: any): Promise<
|
|
206
|
+
authenticatedFetch(path: string, method?: HttpMethods, body?: any, contentType?: string): Promise<Response>;
|
|
207
|
+
fetch(path: string, method?: HttpMethods, body?: any, contentType?: string): Promise<Response>;
|
|
203
208
|
}
|
|
204
209
|
|
|
205
210
|
declare const activationRequestSchema: z.ZodObject<{
|
|
@@ -9058,6 +9063,10 @@ declare class ProductEndpoints {
|
|
|
9058
9063
|
getOwned(nextUrl?: string): Promise<Page<OwnedProduct>>;
|
|
9059
9064
|
getLicenses(productId: string, nextUrl?: string): Promise<Page<License>>;
|
|
9060
9065
|
getActivations(productId: string, nextUrl?: string): Promise<Page<Activation>>;
|
|
9066
|
+
activate(deviceToken: string, activationMethod: ActivationMethod): Promise<{
|
|
9067
|
+
license: License;
|
|
9068
|
+
url: string;
|
|
9069
|
+
}>;
|
|
9061
9070
|
}
|
|
9062
9071
|
|
|
9063
9072
|
declare class StorefrontEndpoints {
|
package/dist/index.js
CHANGED
|
@@ -150,19 +150,19 @@ var ActivationRequestEndpoints = class {
|
|
|
150
150
|
}
|
|
151
151
|
async get(requestId) {
|
|
152
152
|
const response = await this.api.fetch(`/api/customer/activations/${requestId}`);
|
|
153
|
-
return activationRequestSchema.parse(response);
|
|
153
|
+
return activationRequestSchema.parse(response.data);
|
|
154
154
|
}
|
|
155
155
|
async isCompleted(requestId) {
|
|
156
156
|
const response = await this.api.fetch(`/api/customer/activations/${requestId}/completed`);
|
|
157
|
-
return z5.boolean().parse(response);
|
|
157
|
+
return z5.boolean().parse(response.data);
|
|
158
158
|
}
|
|
159
159
|
async fulfillLicense(requestId) {
|
|
160
160
|
const response = await this.api.authenticatedFetch(`/api/customer/activations/${requestId}/license`, "POST");
|
|
161
|
-
return activationRequestSchema.parse(response);
|
|
161
|
+
return activationRequestSchema.parse(response.data);
|
|
162
162
|
}
|
|
163
163
|
async fulfillTrial(requestId) {
|
|
164
164
|
const response = await this.api.fetch(`/api/customer/activations/${requestId}/trial`, "POST");
|
|
165
|
-
return activationRequestSchema.parse(response);
|
|
165
|
+
return activationRequestSchema.parse(response.data);
|
|
166
166
|
}
|
|
167
167
|
};
|
|
168
168
|
|
|
@@ -255,7 +255,7 @@ var IdentityEndpoints = class {
|
|
|
255
255
|
}
|
|
256
256
|
async get() {
|
|
257
257
|
const response = await this.api.authenticatedFetch("/api/customer/meta/user");
|
|
258
|
-
return userSchema.parse(response);
|
|
258
|
+
return userSchema.parse(response.data);
|
|
259
259
|
}
|
|
260
260
|
async signIn(email, password) {
|
|
261
261
|
const response = await fetch(`${this.api.baseUrl}/api/customer/identity/sign-in?email=${email}&scheme=JWT`, {
|
|
@@ -283,7 +283,7 @@ var IdentityEndpoints = class {
|
|
|
283
283
|
acceptedPrivacyPolicy,
|
|
284
284
|
acceptedTermsAndConditions
|
|
285
285
|
});
|
|
286
|
-
const user = identityUserSchema.parse(response);
|
|
286
|
+
const user = identityUserSchema.parse(response.data);
|
|
287
287
|
this.tokenStore.setUser(user);
|
|
288
288
|
return user;
|
|
289
289
|
}
|
|
@@ -367,13 +367,13 @@ var LicenseEndpoints = class {
|
|
|
367
367
|
}
|
|
368
368
|
async get(nextUrl) {
|
|
369
369
|
const response = await this.api.authenticatedFetch(nextUrl || "/api/customer/licenses");
|
|
370
|
-
return paged(licenseSchema).parse(response);
|
|
370
|
+
return paged(licenseSchema).parse(response.data);
|
|
371
371
|
}
|
|
372
372
|
async getActivations(licenseId, nextUrl) {
|
|
373
373
|
const response = await this.api.authenticatedFetch(
|
|
374
374
|
nextUrl || `/api/customer/licenses/${licenseId}/activations`
|
|
375
375
|
);
|
|
376
|
-
return paged(activationSchema).parse(response);
|
|
376
|
+
return paged(activationSchema).parse(response.data);
|
|
377
377
|
}
|
|
378
378
|
async revokeActivation(licenseId, activationId) {
|
|
379
379
|
await this.api.authenticatedFetch(`/api/customer/licenses/${licenseId}/activations/${activationId}/revoke`, "POST");
|
|
@@ -464,7 +464,7 @@ var OrderEndpoints = class {
|
|
|
464
464
|
}
|
|
465
465
|
async get(orderId) {
|
|
466
466
|
const response = await this.api.fetch(`/api/customer/orders/${orderId}`);
|
|
467
|
-
return orderSchema.parse(response);
|
|
467
|
+
return orderSchema.parse(response.data);
|
|
468
468
|
}
|
|
469
469
|
async pushContent(order, checkout) {
|
|
470
470
|
const response = await this.api.fetch(
|
|
@@ -475,26 +475,34 @@ var OrderEndpoints = class {
|
|
|
475
475
|
items: order.items
|
|
476
476
|
}
|
|
477
477
|
);
|
|
478
|
-
return openOrderSchema.parse(response);
|
|
478
|
+
return openOrderSchema.parse(response.data);
|
|
479
479
|
}
|
|
480
480
|
};
|
|
481
481
|
|
|
482
482
|
// src/products/endpoints.ts
|
|
483
|
+
import { z as z10 } from "zod";
|
|
483
484
|
var ProductEndpoints = class {
|
|
484
485
|
constructor(api) {
|
|
485
486
|
this.api = api;
|
|
486
487
|
}
|
|
487
488
|
async getOwned(nextUrl) {
|
|
488
489
|
const response = await this.api.authenticatedFetch(nextUrl || "/api/customer/products");
|
|
489
|
-
return paged(productSummarySchema).parse(response);
|
|
490
|
+
return paged(productSummarySchema).parse(response.data);
|
|
490
491
|
}
|
|
491
492
|
async getLicenses(productId, nextUrl) {
|
|
492
493
|
const response = await this.api.authenticatedFetch(nextUrl || `/api/customer/products/${productId}/licenses`);
|
|
493
|
-
return paged(licenseSchema).parse(response);
|
|
494
|
+
return paged(licenseSchema).parse(response.data);
|
|
494
495
|
}
|
|
495
496
|
async getActivations(productId, nextUrl) {
|
|
496
497
|
const response = await this.api.authenticatedFetch(nextUrl || `/api/customer/products/${productId}/licenses/activations`);
|
|
497
|
-
return paged(activationSchema).parse(response);
|
|
498
|
+
return paged(activationSchema).parse(response.data);
|
|
499
|
+
}
|
|
500
|
+
async activate(deviceToken, activationMethod) {
|
|
501
|
+
const response = await this.api.authenticatedFetch(`/api/customer/products/activate?method=${activationMethod}`, "POST", deviceToken, "text/plain");
|
|
502
|
+
return {
|
|
503
|
+
license: licenseSchema.parse(response.data),
|
|
504
|
+
url: z10.string().parse(response.headers.get("location"))
|
|
505
|
+
};
|
|
498
506
|
}
|
|
499
507
|
};
|
|
500
508
|
|
|
@@ -505,7 +513,7 @@ var StorefrontEndpoints = class {
|
|
|
505
513
|
}
|
|
506
514
|
async get() {
|
|
507
515
|
const response = await this.api.fetch("/api/customer/storefront");
|
|
508
|
-
return storefrontSchema.parse(response);
|
|
516
|
+
return storefrontSchema.parse(response.data);
|
|
509
517
|
}
|
|
510
518
|
};
|
|
511
519
|
|
|
@@ -516,30 +524,35 @@ var MoonbaseApi = class {
|
|
|
516
524
|
this.baseUrl = baseUrl;
|
|
517
525
|
this.tokenStore = tokenStore;
|
|
518
526
|
}
|
|
519
|
-
async authenticatedFetch(path, method, body) {
|
|
527
|
+
async authenticatedFetch(path, method, body, contentType) {
|
|
520
528
|
if (!this.tokenStore.hasAccessToken)
|
|
521
529
|
throw new NotAuthenticatedError();
|
|
522
|
-
return await this.fetch(path, method, body);
|
|
530
|
+
return await this.fetch(path, method, body, contentType);
|
|
523
531
|
}
|
|
524
|
-
async fetch(path, method, body) {
|
|
532
|
+
async fetch(path, method, body, contentType) {
|
|
525
533
|
const accessToken = await this.tokenStore.getAccessToken();
|
|
534
|
+
contentType != null ? contentType : contentType = "application/json";
|
|
526
535
|
const response = await fetch2(this.baseUrl + path, {
|
|
527
536
|
method: method || "GET",
|
|
528
537
|
mode: "cors",
|
|
529
538
|
headers: {
|
|
530
539
|
"Accept": "application/json",
|
|
531
|
-
"Content-Type":
|
|
540
|
+
"Content-Type": contentType,
|
|
532
541
|
// While this fetch can be anonymous, we add the token if we have it
|
|
533
542
|
...accessToken ? { Authorization: `Bearer ${accessToken}` } : {},
|
|
534
543
|
// Force CORS on all calls
|
|
535
544
|
"x-mb-cors": "1"
|
|
536
545
|
},
|
|
537
|
-
body: body ? JSON.stringify(body) : void 0
|
|
546
|
+
body: body ? contentType !== "application/json" ? body : JSON.stringify(body) : void 0
|
|
538
547
|
});
|
|
539
548
|
if (response.status >= 400)
|
|
540
549
|
await handleResponseProblem(response);
|
|
541
550
|
const contentLength = Number(response.headers.get("Content-Length")) || 0;
|
|
542
|
-
return
|
|
551
|
+
return {
|
|
552
|
+
data: contentLength > 0 ? await response.json() : null,
|
|
553
|
+
headers: response.headers,
|
|
554
|
+
status: response.status
|
|
555
|
+
};
|
|
543
556
|
}
|
|
544
557
|
};
|
|
545
558
|
|
|
@@ -642,13 +655,13 @@ _TokenStore.storageKey = "moonbase_auth";
|
|
|
642
655
|
var TokenStore = _TokenStore;
|
|
643
656
|
|
|
644
657
|
// src/vouchers/schemas.ts
|
|
645
|
-
import { z as
|
|
646
|
-
var voucherSchema =
|
|
647
|
-
id:
|
|
648
|
-
name:
|
|
649
|
-
description:
|
|
650
|
-
code:
|
|
651
|
-
redeemed:
|
|
658
|
+
import { z as z11 } from "zod";
|
|
659
|
+
var voucherSchema = z11.object({
|
|
660
|
+
id: z11.string(),
|
|
661
|
+
name: z11.string(),
|
|
662
|
+
description: z11.string(),
|
|
663
|
+
code: z11.string(),
|
|
664
|
+
redeemed: z11.boolean(),
|
|
652
665
|
redeemsProducts: quantifiable(storefrontProductSchema).array(),
|
|
653
666
|
redeemsBundles: quantifiable(storefrontBundleSchema).array()
|
|
654
667
|
});
|
|
@@ -660,14 +673,14 @@ var VoucherEndpoints = class {
|
|
|
660
673
|
}
|
|
661
674
|
async peek(code) {
|
|
662
675
|
const response = await this.api.fetch(`/api/customer/vouchers?code=${encodeURIComponent(code)}`);
|
|
663
|
-
return voucherSchema.parse(response);
|
|
676
|
+
return voucherSchema.parse(response.data);
|
|
664
677
|
}
|
|
665
678
|
async redeem(code) {
|
|
666
679
|
const response = await this.api.authenticatedFetch(
|
|
667
680
|
`/api/customer/vouchers/redeem?code=${encodeURIComponent(code)}`,
|
|
668
681
|
"POST"
|
|
669
682
|
);
|
|
670
|
-
return voucherSchema.parse(response);
|
|
683
|
+
return voucherSchema.parse(response.data);
|
|
671
684
|
}
|
|
672
685
|
};
|
|
673
686
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moonbase.sh/storefront-api",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.93",
|
|
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",
|