@moonbase.sh/storefront-api 0.2.40 → 0.2.42
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 +88 -88
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +88 -88
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -226,7 +226,6 @@ var ActivationRequestEndpoints = class {
|
|
|
226
226
|
|
|
227
227
|
// src/identity/endpoints.ts
|
|
228
228
|
var import_cross_fetch = __toESM(require("cross-fetch"), 1);
|
|
229
|
-
var import_zod8 = require("zod");
|
|
230
229
|
|
|
231
230
|
// src/utils/problemHandler.ts
|
|
232
231
|
var import_zod6 = require("zod");
|
|
@@ -392,7 +391,7 @@ var IdentityEndpoints = class {
|
|
|
392
391
|
return response.data;
|
|
393
392
|
}
|
|
394
393
|
async update(name, email, emailConfirmationToken, communicationPreferences) {
|
|
395
|
-
const response = await this.api.authenticatedFetch("/api/customer/identity",
|
|
394
|
+
const response = await this.api.authenticatedFetch("/api/customer/identity", null, {
|
|
396
395
|
method: "PATCH",
|
|
397
396
|
body: {
|
|
398
397
|
name,
|
|
@@ -406,7 +405,7 @@ var IdentityEndpoints = class {
|
|
|
406
405
|
};
|
|
407
406
|
}
|
|
408
407
|
async setPassword(currentPassword, newPassword) {
|
|
409
|
-
await this.api.authenticatedFetch(`/api/customer/identity/set-password`,
|
|
408
|
+
await this.api.authenticatedFetch(`/api/customer/identity/set-password`, null, {
|
|
410
409
|
method: "POST",
|
|
411
410
|
body: {
|
|
412
411
|
currentPassword,
|
|
@@ -415,7 +414,7 @@ var IdentityEndpoints = class {
|
|
|
415
414
|
});
|
|
416
415
|
}
|
|
417
416
|
async forgotPassword(email) {
|
|
418
|
-
await this.api.fetch(`/api/customer/identity/forgot-password?email=${encodeURIComponent(email)}`,
|
|
417
|
+
await this.api.fetch(`/api/customer/identity/forgot-password?email=${encodeURIComponent(email)}`, null, { method: "POST" });
|
|
419
418
|
}
|
|
420
419
|
async resetPassword(email, newPassword, code) {
|
|
421
420
|
const response = await (0, import_cross_fetch.default)(`${this.api.baseUrl}/api/customer/identity/reset-password?email=${encodeURIComponent(email)}&code=${encodeURIComponent(code.replaceAll(" ", "+"))}`, {
|
|
@@ -440,10 +439,10 @@ var IdentityEndpoints = class {
|
|
|
440
439
|
}
|
|
441
440
|
}
|
|
442
441
|
async confirmEmail(email, code) {
|
|
443
|
-
await this.api.fetch(`/api/customer/identity/confirm-email?email=${encodeURIComponent(email)}&code=${encodeURIComponent(code.replaceAll(" ", "+"))}`,
|
|
442
|
+
await this.api.fetch(`/api/customer/identity/confirm-email?email=${encodeURIComponent(email)}&code=${encodeURIComponent(code.replaceAll(" ", "+"))}`, null, { method: "POST" });
|
|
444
443
|
}
|
|
445
444
|
async confirmEmailChange(email, code) {
|
|
446
|
-
await this.api.authenticatedFetch(`/api/customer/identity/confirm-email-change?email=${encodeURIComponent(email)}&code=${encodeURIComponent(code.replaceAll(" ", "+"))}`,
|
|
445
|
+
await this.api.authenticatedFetch(`/api/customer/identity/confirm-email-change?email=${encodeURIComponent(email)}&code=${encodeURIComponent(code.replaceAll(" ", "+"))}`, null, { method: "POST" });
|
|
447
446
|
}
|
|
448
447
|
};
|
|
449
448
|
|
|
@@ -457,7 +456,7 @@ __export(schemas_exports, {
|
|
|
457
456
|
openProductLineItem: () => openProductLineItem,
|
|
458
457
|
orderSchema: () => orderSchema
|
|
459
458
|
});
|
|
460
|
-
var
|
|
459
|
+
var import_zod8 = require("zod");
|
|
461
460
|
|
|
462
461
|
// src/orders/models.ts
|
|
463
462
|
var OrderStatus = /* @__PURE__ */ ((OrderStatus2) => {
|
|
@@ -469,90 +468,90 @@ var OrderStatus = /* @__PURE__ */ ((OrderStatus2) => {
|
|
|
469
468
|
})(OrderStatus || {});
|
|
470
469
|
|
|
471
470
|
// src/orders/schemas.ts
|
|
472
|
-
var couponSchema =
|
|
473
|
-
code:
|
|
474
|
-
name:
|
|
475
|
-
description:
|
|
471
|
+
var couponSchema = import_zod8.z.object({
|
|
472
|
+
code: import_zod8.z.string(),
|
|
473
|
+
name: import_zod8.z.string(),
|
|
474
|
+
description: import_zod8.z.string()
|
|
476
475
|
});
|
|
477
|
-
var lineItemProductSchema =
|
|
478
|
-
id:
|
|
479
|
-
name:
|
|
480
|
-
tagline:
|
|
481
|
-
iconUrl:
|
|
476
|
+
var lineItemProductSchema = import_zod8.z.object({
|
|
477
|
+
id: import_zod8.z.string(),
|
|
478
|
+
name: import_zod8.z.string(),
|
|
479
|
+
tagline: import_zod8.z.string(),
|
|
480
|
+
iconUrl: import_zod8.z.string().nullable()
|
|
482
481
|
});
|
|
483
|
-
var openProductLineItem =
|
|
484
|
-
id:
|
|
485
|
-
type:
|
|
486
|
-
productId:
|
|
487
|
-
quantity:
|
|
488
|
-
variationId:
|
|
482
|
+
var openProductLineItem = import_zod8.z.object({
|
|
483
|
+
id: import_zod8.z.string(),
|
|
484
|
+
type: import_zod8.z.literal("Product"),
|
|
485
|
+
productId: import_zod8.z.string(),
|
|
486
|
+
quantity: import_zod8.z.number(),
|
|
487
|
+
variationId: import_zod8.z.string(),
|
|
489
488
|
price: priceCollectionSchema.optional(),
|
|
490
489
|
variation: pricingVariationSchema.optional(),
|
|
491
490
|
product: lineItemProductSchema.optional(),
|
|
492
491
|
appliedDiscount: discountSchema.optional()
|
|
493
492
|
});
|
|
494
|
-
var lineItemBundleSchema =
|
|
495
|
-
id:
|
|
496
|
-
name:
|
|
497
|
-
tagline:
|
|
498
|
-
iconUrl:
|
|
499
|
-
partial:
|
|
500
|
-
products: lineItemProductSchema.and(
|
|
501
|
-
included:
|
|
493
|
+
var lineItemBundleSchema = import_zod8.z.object({
|
|
494
|
+
id: import_zod8.z.string(),
|
|
495
|
+
name: import_zod8.z.string(),
|
|
496
|
+
tagline: import_zod8.z.string(),
|
|
497
|
+
iconUrl: import_zod8.z.string().nullable(),
|
|
498
|
+
partial: import_zod8.z.boolean(),
|
|
499
|
+
products: lineItemProductSchema.and(import_zod8.z.object({
|
|
500
|
+
included: import_zod8.z.boolean().optional()
|
|
502
501
|
})).array()
|
|
503
502
|
});
|
|
504
|
-
var openBundleLineItem =
|
|
505
|
-
id:
|
|
506
|
-
type:
|
|
507
|
-
bundleId:
|
|
508
|
-
quantity:
|
|
509
|
-
variationId:
|
|
503
|
+
var openBundleLineItem = import_zod8.z.object({
|
|
504
|
+
id: import_zod8.z.string(),
|
|
505
|
+
type: import_zod8.z.literal("Bundle"),
|
|
506
|
+
bundleId: import_zod8.z.string(),
|
|
507
|
+
quantity: import_zod8.z.number(),
|
|
508
|
+
variationId: import_zod8.z.string(),
|
|
510
509
|
price: priceCollectionSchema.optional(),
|
|
511
510
|
variation: pricingVariationSchema.optional(),
|
|
512
511
|
bundle: lineItemBundleSchema.optional(),
|
|
513
512
|
appliedDiscount: discountSchema.optional()
|
|
514
513
|
});
|
|
515
|
-
var openOrderLineItem =
|
|
514
|
+
var openOrderLineItem = import_zod8.z.discriminatedUnion("type", [
|
|
516
515
|
openProductLineItem,
|
|
517
516
|
openBundleLineItem
|
|
518
517
|
]);
|
|
519
|
-
var openOrderSchema =
|
|
520
|
-
id:
|
|
521
|
-
status:
|
|
522
|
-
currency:
|
|
518
|
+
var openOrderSchema = import_zod8.z.object({
|
|
519
|
+
id: import_zod8.z.string(),
|
|
520
|
+
status: import_zod8.z.literal("Open" /* Open */),
|
|
521
|
+
currency: import_zod8.z.string(),
|
|
523
522
|
items: openOrderLineItem.array(),
|
|
524
523
|
couponsApplied: couponSchema.array(),
|
|
525
|
-
checkoutUrl:
|
|
526
|
-
embeddedCheckoutUrl:
|
|
524
|
+
checkoutUrl: import_zod8.z.string().optional(),
|
|
525
|
+
embeddedCheckoutUrl: import_zod8.z.string().optional()
|
|
527
526
|
});
|
|
528
|
-
var moneySchema =
|
|
529
|
-
currency:
|
|
530
|
-
amount:
|
|
527
|
+
var moneySchema = import_zod8.z.object({
|
|
528
|
+
currency: import_zod8.z.string(),
|
|
529
|
+
amount: import_zod8.z.number()
|
|
531
530
|
});
|
|
532
|
-
var orderTotalSchema =
|
|
531
|
+
var orderTotalSchema = import_zod8.z.object({
|
|
533
532
|
original: moneySchema,
|
|
534
533
|
discount: moneySchema,
|
|
535
534
|
subtotal: moneySchema,
|
|
536
535
|
taxes: moneySchema,
|
|
537
536
|
due: moneySchema
|
|
538
537
|
});
|
|
539
|
-
var customerSnapshotSchema =
|
|
540
|
-
name:
|
|
541
|
-
businessName:
|
|
542
|
-
taxId:
|
|
543
|
-
email:
|
|
538
|
+
var customerSnapshotSchema = import_zod8.z.object({
|
|
539
|
+
name: import_zod8.z.string().nullable(),
|
|
540
|
+
businessName: import_zod8.z.string().nullable(),
|
|
541
|
+
taxId: import_zod8.z.string().nullable(),
|
|
542
|
+
email: import_zod8.z.string().nullable(),
|
|
544
543
|
address: addressSchema.nullable()
|
|
545
544
|
});
|
|
546
|
-
var completedOrderSchema =
|
|
547
|
-
id:
|
|
548
|
-
status:
|
|
549
|
-
currency:
|
|
545
|
+
var completedOrderSchema = import_zod8.z.object({
|
|
546
|
+
id: import_zod8.z.string(),
|
|
547
|
+
status: import_zod8.z.literal("Completed" /* Completed */),
|
|
548
|
+
currency: import_zod8.z.string(),
|
|
550
549
|
customer: customerSnapshotSchema,
|
|
551
550
|
total: orderTotalSchema,
|
|
552
551
|
items: openOrderLineItem.array(),
|
|
553
552
|
couponsApplied: couponSchema.array()
|
|
554
553
|
});
|
|
555
|
-
var orderSchema =
|
|
554
|
+
var orderSchema = import_zod8.z.discriminatedUnion("status", [
|
|
556
555
|
openOrderSchema,
|
|
557
556
|
completedOrderSchema
|
|
558
557
|
]);
|
|
@@ -618,7 +617,6 @@ var StorefrontEndpoints = class {
|
|
|
618
617
|
|
|
619
618
|
// src/utils/api.ts
|
|
620
619
|
var import_cross_fetch2 = __toESM(require("cross-fetch"), 1);
|
|
621
|
-
var import_zod10 = require("zod");
|
|
622
620
|
var MoonbaseApi = class {
|
|
623
621
|
constructor(baseUrl, tokenStore) {
|
|
624
622
|
this.baseUrl = baseUrl;
|
|
@@ -648,16 +646,19 @@ var MoonbaseApi = class {
|
|
|
648
646
|
});
|
|
649
647
|
if (response.status >= 400)
|
|
650
648
|
await handleResponseProblem(response);
|
|
649
|
+
let json;
|
|
651
650
|
try {
|
|
651
|
+
json = schema ? await response.json() : null;
|
|
652
652
|
return {
|
|
653
|
-
data: schema
|
|
653
|
+
data: schema ? schema.parse(json) : null,
|
|
654
654
|
headers: Object.fromEntries(response.headers.entries()),
|
|
655
655
|
status: response.status
|
|
656
656
|
};
|
|
657
657
|
} catch (err) {
|
|
658
658
|
console.warn("Could not parse response", {
|
|
659
659
|
status: response.status,
|
|
660
|
-
|
|
660
|
+
path,
|
|
661
|
+
content: json || (response.bodyUsed ? "unknown" : await response.text()),
|
|
661
662
|
headers: Object.fromEntries(response.headers.entries()),
|
|
662
663
|
userAgent: window && window.navigator && window.navigator.userAgent,
|
|
663
664
|
err
|
|
@@ -773,13 +774,13 @@ _TokenStore.storageKey = "moonbase_auth";
|
|
|
773
774
|
var TokenStore = _TokenStore;
|
|
774
775
|
|
|
775
776
|
// src/vouchers/schemas.ts
|
|
776
|
-
var
|
|
777
|
-
var voucherSchema =
|
|
778
|
-
id:
|
|
779
|
-
name:
|
|
780
|
-
description:
|
|
781
|
-
code:
|
|
782
|
-
redeemed:
|
|
777
|
+
var import_zod9 = require("zod");
|
|
778
|
+
var voucherSchema = import_zod9.z.object({
|
|
779
|
+
id: import_zod9.z.string(),
|
|
780
|
+
name: import_zod9.z.string(),
|
|
781
|
+
description: import_zod9.z.string(),
|
|
782
|
+
code: import_zod9.z.string(),
|
|
783
|
+
redeemed: import_zod9.z.boolean(),
|
|
783
784
|
redeemsProducts: quantifiable(storefrontProductSchema).array(),
|
|
784
785
|
redeemsBundles: quantifiable(storefrontBundleSchema).array()
|
|
785
786
|
});
|
|
@@ -806,10 +807,10 @@ var VoucherEndpoints = class {
|
|
|
806
807
|
};
|
|
807
808
|
|
|
808
809
|
// src/inventory/activation/endpoints.ts
|
|
809
|
-
var
|
|
810
|
+
var import_zod11 = require("zod");
|
|
810
811
|
|
|
811
812
|
// src/inventory/licenses/schemas.ts
|
|
812
|
-
var
|
|
813
|
+
var import_zod10 = require("zod");
|
|
813
814
|
|
|
814
815
|
// src/inventory/licenses/models.ts
|
|
815
816
|
var LicenseStatus = /* @__PURE__ */ ((LicenseStatus2) => {
|
|
@@ -829,21 +830,21 @@ var ActivationMethod = /* @__PURE__ */ ((ActivationMethod2) => {
|
|
|
829
830
|
})(ActivationMethod || {});
|
|
830
831
|
|
|
831
832
|
// src/inventory/licenses/schemas.ts
|
|
832
|
-
var licenseSchema =
|
|
833
|
-
id:
|
|
834
|
-
status:
|
|
833
|
+
var licenseSchema = import_zod10.z.object({
|
|
834
|
+
id: import_zod10.z.string(),
|
|
835
|
+
status: import_zod10.z.nativeEnum(LicenseStatus),
|
|
835
836
|
product: productSummarySchema,
|
|
836
|
-
activeNumberOfActivations:
|
|
837
|
-
maxNumberOfActivations:
|
|
838
|
-
createdAt:
|
|
837
|
+
activeNumberOfActivations: import_zod10.z.number(),
|
|
838
|
+
maxNumberOfActivations: import_zod10.z.number(),
|
|
839
|
+
createdAt: import_zod10.z.coerce.date()
|
|
839
840
|
});
|
|
840
|
-
var activationSchema =
|
|
841
|
-
id:
|
|
842
|
-
licenseId:
|
|
843
|
-
name:
|
|
844
|
-
status:
|
|
845
|
-
activationMethod:
|
|
846
|
-
lastValidatedAt:
|
|
841
|
+
var activationSchema = import_zod10.z.object({
|
|
842
|
+
id: import_zod10.z.string(),
|
|
843
|
+
licenseId: import_zod10.z.string(),
|
|
844
|
+
name: import_zod10.z.string(),
|
|
845
|
+
status: import_zod10.z.nativeEnum(ActivationStatus),
|
|
846
|
+
activationMethod: import_zod10.z.nativeEnum(ActivationMethod),
|
|
847
|
+
lastValidatedAt: import_zod10.z.coerce.date().nullable()
|
|
847
848
|
});
|
|
848
849
|
|
|
849
850
|
// src/inventory/activation/endpoints.ts
|
|
@@ -859,13 +860,12 @@ var ActivationEndpoints = class {
|
|
|
859
860
|
});
|
|
860
861
|
return {
|
|
861
862
|
license: response.data,
|
|
862
|
-
url:
|
|
863
|
+
url: import_zod11.z.string().parse(response.headers.location)
|
|
863
864
|
};
|
|
864
865
|
}
|
|
865
866
|
};
|
|
866
867
|
|
|
867
868
|
// src/inventory/licenses/endpoints.ts
|
|
868
|
-
var import_zod14 = require("zod");
|
|
869
869
|
var LicenseEndpoints = class {
|
|
870
870
|
constructor(api) {
|
|
871
871
|
this.api = api;
|
|
@@ -882,12 +882,12 @@ var LicenseEndpoints = class {
|
|
|
882
882
|
return response.data;
|
|
883
883
|
}
|
|
884
884
|
async revokeActivation(licenseId, activationId) {
|
|
885
|
-
await this.api.authenticatedFetch(`/api/customer/inventory/licenses/${licenseId}/activations/${activationId}/revoke`,
|
|
885
|
+
await this.api.authenticatedFetch(`/api/customer/inventory/licenses/${licenseId}/activations/${activationId}/revoke`, null, { method: "POST" });
|
|
886
886
|
}
|
|
887
887
|
};
|
|
888
888
|
|
|
889
889
|
// src/inventory/products/endpoints.ts
|
|
890
|
-
var
|
|
890
|
+
var import_zod12 = require("zod");
|
|
891
891
|
var ProductEndpoints = class {
|
|
892
892
|
constructor(api) {
|
|
893
893
|
this.api = api;
|
|
@@ -911,8 +911,8 @@ var ProductEndpoints = class {
|
|
|
911
911
|
async getDownloadUrl(path) {
|
|
912
912
|
const url = new URL(path);
|
|
913
913
|
url.searchParams.append("redirect", "false");
|
|
914
|
-
const response = await this.api.fetch(url.pathname + url.search,
|
|
915
|
-
location:
|
|
914
|
+
const response = await this.api.fetch(url.pathname + url.search, import_zod12.z.object({
|
|
915
|
+
location: import_zod12.z.string()
|
|
916
916
|
}));
|
|
917
917
|
return response.data.location;
|
|
918
918
|
}
|
package/dist/index.d.cts
CHANGED
|
@@ -230,8 +230,8 @@ declare class MoonbaseApi {
|
|
|
230
230
|
baseUrl: string;
|
|
231
231
|
private tokenStore;
|
|
232
232
|
constructor(baseUrl: string, tokenStore: TokenStore);
|
|
233
|
-
authenticatedFetch<T extends ZodTypeAny>(path: string, schema: T, options?: FetchOptions): Promise<Response<z.infer<T>>>;
|
|
234
|
-
fetch<T extends ZodTypeAny>(path: string, schema: T, options?: FetchOptions): Promise<Response<z.infer<T>>>;
|
|
233
|
+
authenticatedFetch<T extends ZodTypeAny>(path: string, schema: T | null, options?: FetchOptions): Promise<Response<z.infer<T>>>;
|
|
234
|
+
fetch<T extends ZodTypeAny>(path: string, schema: T | null, options?: FetchOptions): Promise<Response<z.infer<T>>>;
|
|
235
235
|
}
|
|
236
236
|
|
|
237
237
|
declare const activationRequestSchema: z.ZodObject<{
|
package/dist/index.d.ts
CHANGED
|
@@ -230,8 +230,8 @@ declare class MoonbaseApi {
|
|
|
230
230
|
baseUrl: string;
|
|
231
231
|
private tokenStore;
|
|
232
232
|
constructor(baseUrl: string, tokenStore: TokenStore);
|
|
233
|
-
authenticatedFetch<T extends ZodTypeAny>(path: string, schema: T, options?: FetchOptions): Promise<Response<z.infer<T>>>;
|
|
234
|
-
fetch<T extends ZodTypeAny>(path: string, schema: T, options?: FetchOptions): Promise<Response<z.infer<T>>>;
|
|
233
|
+
authenticatedFetch<T extends ZodTypeAny>(path: string, schema: T | null, options?: FetchOptions): Promise<Response<z.infer<T>>>;
|
|
234
|
+
fetch<T extends ZodTypeAny>(path: string, schema: T | null, options?: FetchOptions): Promise<Response<z.infer<T>>>;
|
|
235
235
|
}
|
|
236
236
|
|
|
237
237
|
declare const activationRequestSchema: z.ZodObject<{
|
package/dist/index.js
CHANGED
|
@@ -184,7 +184,6 @@ var ActivationRequestEndpoints = class {
|
|
|
184
184
|
|
|
185
185
|
// src/identity/endpoints.ts
|
|
186
186
|
import fetch from "cross-fetch";
|
|
187
|
-
import { z as z8 } from "zod";
|
|
188
187
|
|
|
189
188
|
// src/utils/problemHandler.ts
|
|
190
189
|
import { z as z6 } from "zod";
|
|
@@ -350,7 +349,7 @@ var IdentityEndpoints = class {
|
|
|
350
349
|
return response.data;
|
|
351
350
|
}
|
|
352
351
|
async update(name, email, emailConfirmationToken, communicationPreferences) {
|
|
353
|
-
const response = await this.api.authenticatedFetch("/api/customer/identity",
|
|
352
|
+
const response = await this.api.authenticatedFetch("/api/customer/identity", null, {
|
|
354
353
|
method: "PATCH",
|
|
355
354
|
body: {
|
|
356
355
|
name,
|
|
@@ -364,7 +363,7 @@ var IdentityEndpoints = class {
|
|
|
364
363
|
};
|
|
365
364
|
}
|
|
366
365
|
async setPassword(currentPassword, newPassword) {
|
|
367
|
-
await this.api.authenticatedFetch(`/api/customer/identity/set-password`,
|
|
366
|
+
await this.api.authenticatedFetch(`/api/customer/identity/set-password`, null, {
|
|
368
367
|
method: "POST",
|
|
369
368
|
body: {
|
|
370
369
|
currentPassword,
|
|
@@ -373,7 +372,7 @@ var IdentityEndpoints = class {
|
|
|
373
372
|
});
|
|
374
373
|
}
|
|
375
374
|
async forgotPassword(email) {
|
|
376
|
-
await this.api.fetch(`/api/customer/identity/forgot-password?email=${encodeURIComponent(email)}`,
|
|
375
|
+
await this.api.fetch(`/api/customer/identity/forgot-password?email=${encodeURIComponent(email)}`, null, { method: "POST" });
|
|
377
376
|
}
|
|
378
377
|
async resetPassword(email, newPassword, code) {
|
|
379
378
|
const response = await fetch(`${this.api.baseUrl}/api/customer/identity/reset-password?email=${encodeURIComponent(email)}&code=${encodeURIComponent(code.replaceAll(" ", "+"))}`, {
|
|
@@ -398,10 +397,10 @@ var IdentityEndpoints = class {
|
|
|
398
397
|
}
|
|
399
398
|
}
|
|
400
399
|
async confirmEmail(email, code) {
|
|
401
|
-
await this.api.fetch(`/api/customer/identity/confirm-email?email=${encodeURIComponent(email)}&code=${encodeURIComponent(code.replaceAll(" ", "+"))}`,
|
|
400
|
+
await this.api.fetch(`/api/customer/identity/confirm-email?email=${encodeURIComponent(email)}&code=${encodeURIComponent(code.replaceAll(" ", "+"))}`, null, { method: "POST" });
|
|
402
401
|
}
|
|
403
402
|
async confirmEmailChange(email, code) {
|
|
404
|
-
await this.api.authenticatedFetch(`/api/customer/identity/confirm-email-change?email=${encodeURIComponent(email)}&code=${encodeURIComponent(code.replaceAll(" ", "+"))}`,
|
|
403
|
+
await this.api.authenticatedFetch(`/api/customer/identity/confirm-email-change?email=${encodeURIComponent(email)}&code=${encodeURIComponent(code.replaceAll(" ", "+"))}`, null, { method: "POST" });
|
|
405
404
|
}
|
|
406
405
|
};
|
|
407
406
|
|
|
@@ -415,7 +414,7 @@ __export(schemas_exports, {
|
|
|
415
414
|
openProductLineItem: () => openProductLineItem,
|
|
416
415
|
orderSchema: () => orderSchema
|
|
417
416
|
});
|
|
418
|
-
import { z as
|
|
417
|
+
import { z as z8 } from "zod";
|
|
419
418
|
|
|
420
419
|
// src/orders/models.ts
|
|
421
420
|
var OrderStatus = /* @__PURE__ */ ((OrderStatus2) => {
|
|
@@ -427,90 +426,90 @@ var OrderStatus = /* @__PURE__ */ ((OrderStatus2) => {
|
|
|
427
426
|
})(OrderStatus || {});
|
|
428
427
|
|
|
429
428
|
// src/orders/schemas.ts
|
|
430
|
-
var couponSchema =
|
|
431
|
-
code:
|
|
432
|
-
name:
|
|
433
|
-
description:
|
|
429
|
+
var couponSchema = z8.object({
|
|
430
|
+
code: z8.string(),
|
|
431
|
+
name: z8.string(),
|
|
432
|
+
description: z8.string()
|
|
434
433
|
});
|
|
435
|
-
var lineItemProductSchema =
|
|
436
|
-
id:
|
|
437
|
-
name:
|
|
438
|
-
tagline:
|
|
439
|
-
iconUrl:
|
|
434
|
+
var lineItemProductSchema = z8.object({
|
|
435
|
+
id: z8.string(),
|
|
436
|
+
name: z8.string(),
|
|
437
|
+
tagline: z8.string(),
|
|
438
|
+
iconUrl: z8.string().nullable()
|
|
440
439
|
});
|
|
441
|
-
var openProductLineItem =
|
|
442
|
-
id:
|
|
443
|
-
type:
|
|
444
|
-
productId:
|
|
445
|
-
quantity:
|
|
446
|
-
variationId:
|
|
440
|
+
var openProductLineItem = z8.object({
|
|
441
|
+
id: z8.string(),
|
|
442
|
+
type: z8.literal("Product"),
|
|
443
|
+
productId: z8.string(),
|
|
444
|
+
quantity: z8.number(),
|
|
445
|
+
variationId: z8.string(),
|
|
447
446
|
price: priceCollectionSchema.optional(),
|
|
448
447
|
variation: pricingVariationSchema.optional(),
|
|
449
448
|
product: lineItemProductSchema.optional(),
|
|
450
449
|
appliedDiscount: discountSchema.optional()
|
|
451
450
|
});
|
|
452
|
-
var lineItemBundleSchema =
|
|
453
|
-
id:
|
|
454
|
-
name:
|
|
455
|
-
tagline:
|
|
456
|
-
iconUrl:
|
|
457
|
-
partial:
|
|
458
|
-
products: lineItemProductSchema.and(
|
|
459
|
-
included:
|
|
451
|
+
var lineItemBundleSchema = z8.object({
|
|
452
|
+
id: z8.string(),
|
|
453
|
+
name: z8.string(),
|
|
454
|
+
tagline: z8.string(),
|
|
455
|
+
iconUrl: z8.string().nullable(),
|
|
456
|
+
partial: z8.boolean(),
|
|
457
|
+
products: lineItemProductSchema.and(z8.object({
|
|
458
|
+
included: z8.boolean().optional()
|
|
460
459
|
})).array()
|
|
461
460
|
});
|
|
462
|
-
var openBundleLineItem =
|
|
463
|
-
id:
|
|
464
|
-
type:
|
|
465
|
-
bundleId:
|
|
466
|
-
quantity:
|
|
467
|
-
variationId:
|
|
461
|
+
var openBundleLineItem = z8.object({
|
|
462
|
+
id: z8.string(),
|
|
463
|
+
type: z8.literal("Bundle"),
|
|
464
|
+
bundleId: z8.string(),
|
|
465
|
+
quantity: z8.number(),
|
|
466
|
+
variationId: z8.string(),
|
|
468
467
|
price: priceCollectionSchema.optional(),
|
|
469
468
|
variation: pricingVariationSchema.optional(),
|
|
470
469
|
bundle: lineItemBundleSchema.optional(),
|
|
471
470
|
appliedDiscount: discountSchema.optional()
|
|
472
471
|
});
|
|
473
|
-
var openOrderLineItem =
|
|
472
|
+
var openOrderLineItem = z8.discriminatedUnion("type", [
|
|
474
473
|
openProductLineItem,
|
|
475
474
|
openBundleLineItem
|
|
476
475
|
]);
|
|
477
|
-
var openOrderSchema =
|
|
478
|
-
id:
|
|
479
|
-
status:
|
|
480
|
-
currency:
|
|
476
|
+
var openOrderSchema = z8.object({
|
|
477
|
+
id: z8.string(),
|
|
478
|
+
status: z8.literal("Open" /* Open */),
|
|
479
|
+
currency: z8.string(),
|
|
481
480
|
items: openOrderLineItem.array(),
|
|
482
481
|
couponsApplied: couponSchema.array(),
|
|
483
|
-
checkoutUrl:
|
|
484
|
-
embeddedCheckoutUrl:
|
|
482
|
+
checkoutUrl: z8.string().optional(),
|
|
483
|
+
embeddedCheckoutUrl: z8.string().optional()
|
|
485
484
|
});
|
|
486
|
-
var moneySchema =
|
|
487
|
-
currency:
|
|
488
|
-
amount:
|
|
485
|
+
var moneySchema = z8.object({
|
|
486
|
+
currency: z8.string(),
|
|
487
|
+
amount: z8.number()
|
|
489
488
|
});
|
|
490
|
-
var orderTotalSchema =
|
|
489
|
+
var orderTotalSchema = z8.object({
|
|
491
490
|
original: moneySchema,
|
|
492
491
|
discount: moneySchema,
|
|
493
492
|
subtotal: moneySchema,
|
|
494
493
|
taxes: moneySchema,
|
|
495
494
|
due: moneySchema
|
|
496
495
|
});
|
|
497
|
-
var customerSnapshotSchema =
|
|
498
|
-
name:
|
|
499
|
-
businessName:
|
|
500
|
-
taxId:
|
|
501
|
-
email:
|
|
496
|
+
var customerSnapshotSchema = z8.object({
|
|
497
|
+
name: z8.string().nullable(),
|
|
498
|
+
businessName: z8.string().nullable(),
|
|
499
|
+
taxId: z8.string().nullable(),
|
|
500
|
+
email: z8.string().nullable(),
|
|
502
501
|
address: addressSchema.nullable()
|
|
503
502
|
});
|
|
504
|
-
var completedOrderSchema =
|
|
505
|
-
id:
|
|
506
|
-
status:
|
|
507
|
-
currency:
|
|
503
|
+
var completedOrderSchema = z8.object({
|
|
504
|
+
id: z8.string(),
|
|
505
|
+
status: z8.literal("Completed" /* Completed */),
|
|
506
|
+
currency: z8.string(),
|
|
508
507
|
customer: customerSnapshotSchema,
|
|
509
508
|
total: orderTotalSchema,
|
|
510
509
|
items: openOrderLineItem.array(),
|
|
511
510
|
couponsApplied: couponSchema.array()
|
|
512
511
|
});
|
|
513
|
-
var orderSchema =
|
|
512
|
+
var orderSchema = z8.discriminatedUnion("status", [
|
|
514
513
|
openOrderSchema,
|
|
515
514
|
completedOrderSchema
|
|
516
515
|
]);
|
|
@@ -576,7 +575,6 @@ var StorefrontEndpoints = class {
|
|
|
576
575
|
|
|
577
576
|
// src/utils/api.ts
|
|
578
577
|
import fetch2 from "cross-fetch";
|
|
579
|
-
import { ZodNull } from "zod";
|
|
580
578
|
var MoonbaseApi = class {
|
|
581
579
|
constructor(baseUrl, tokenStore) {
|
|
582
580
|
this.baseUrl = baseUrl;
|
|
@@ -606,16 +604,19 @@ var MoonbaseApi = class {
|
|
|
606
604
|
});
|
|
607
605
|
if (response.status >= 400)
|
|
608
606
|
await handleResponseProblem(response);
|
|
607
|
+
let json;
|
|
609
608
|
try {
|
|
609
|
+
json = schema ? await response.json() : null;
|
|
610
610
|
return {
|
|
611
|
-
data: schema
|
|
611
|
+
data: schema ? schema.parse(json) : null,
|
|
612
612
|
headers: Object.fromEntries(response.headers.entries()),
|
|
613
613
|
status: response.status
|
|
614
614
|
};
|
|
615
615
|
} catch (err) {
|
|
616
616
|
console.warn("Could not parse response", {
|
|
617
617
|
status: response.status,
|
|
618
|
-
|
|
618
|
+
path,
|
|
619
|
+
content: json || (response.bodyUsed ? "unknown" : await response.text()),
|
|
619
620
|
headers: Object.fromEntries(response.headers.entries()),
|
|
620
621
|
userAgent: window && window.navigator && window.navigator.userAgent,
|
|
621
622
|
err
|
|
@@ -731,13 +732,13 @@ _TokenStore.storageKey = "moonbase_auth";
|
|
|
731
732
|
var TokenStore = _TokenStore;
|
|
732
733
|
|
|
733
734
|
// src/vouchers/schemas.ts
|
|
734
|
-
import { z as
|
|
735
|
-
var voucherSchema =
|
|
736
|
-
id:
|
|
737
|
-
name:
|
|
738
|
-
description:
|
|
739
|
-
code:
|
|
740
|
-
redeemed:
|
|
735
|
+
import { z as z9 } from "zod";
|
|
736
|
+
var voucherSchema = z9.object({
|
|
737
|
+
id: z9.string(),
|
|
738
|
+
name: z9.string(),
|
|
739
|
+
description: z9.string(),
|
|
740
|
+
code: z9.string(),
|
|
741
|
+
redeemed: z9.boolean(),
|
|
741
742
|
redeemsProducts: quantifiable(storefrontProductSchema).array(),
|
|
742
743
|
redeemsBundles: quantifiable(storefrontBundleSchema).array()
|
|
743
744
|
});
|
|
@@ -764,10 +765,10 @@ var VoucherEndpoints = class {
|
|
|
764
765
|
};
|
|
765
766
|
|
|
766
767
|
// src/inventory/activation/endpoints.ts
|
|
767
|
-
import { z as
|
|
768
|
+
import { z as z11 } from "zod";
|
|
768
769
|
|
|
769
770
|
// src/inventory/licenses/schemas.ts
|
|
770
|
-
import { z as
|
|
771
|
+
import { z as z10 } from "zod";
|
|
771
772
|
|
|
772
773
|
// src/inventory/licenses/models.ts
|
|
773
774
|
var LicenseStatus = /* @__PURE__ */ ((LicenseStatus2) => {
|
|
@@ -787,21 +788,21 @@ var ActivationMethod = /* @__PURE__ */ ((ActivationMethod2) => {
|
|
|
787
788
|
})(ActivationMethod || {});
|
|
788
789
|
|
|
789
790
|
// src/inventory/licenses/schemas.ts
|
|
790
|
-
var licenseSchema =
|
|
791
|
-
id:
|
|
792
|
-
status:
|
|
791
|
+
var licenseSchema = z10.object({
|
|
792
|
+
id: z10.string(),
|
|
793
|
+
status: z10.nativeEnum(LicenseStatus),
|
|
793
794
|
product: productSummarySchema,
|
|
794
|
-
activeNumberOfActivations:
|
|
795
|
-
maxNumberOfActivations:
|
|
796
|
-
createdAt:
|
|
795
|
+
activeNumberOfActivations: z10.number(),
|
|
796
|
+
maxNumberOfActivations: z10.number(),
|
|
797
|
+
createdAt: z10.coerce.date()
|
|
797
798
|
});
|
|
798
|
-
var activationSchema =
|
|
799
|
-
id:
|
|
800
|
-
licenseId:
|
|
801
|
-
name:
|
|
802
|
-
status:
|
|
803
|
-
activationMethod:
|
|
804
|
-
lastValidatedAt:
|
|
799
|
+
var activationSchema = z10.object({
|
|
800
|
+
id: z10.string(),
|
|
801
|
+
licenseId: z10.string(),
|
|
802
|
+
name: z10.string(),
|
|
803
|
+
status: z10.nativeEnum(ActivationStatus),
|
|
804
|
+
activationMethod: z10.nativeEnum(ActivationMethod),
|
|
805
|
+
lastValidatedAt: z10.coerce.date().nullable()
|
|
805
806
|
});
|
|
806
807
|
|
|
807
808
|
// src/inventory/activation/endpoints.ts
|
|
@@ -817,13 +818,12 @@ var ActivationEndpoints = class {
|
|
|
817
818
|
});
|
|
818
819
|
return {
|
|
819
820
|
license: response.data,
|
|
820
|
-
url:
|
|
821
|
+
url: z11.string().parse(response.headers.location)
|
|
821
822
|
};
|
|
822
823
|
}
|
|
823
824
|
};
|
|
824
825
|
|
|
825
826
|
// src/inventory/licenses/endpoints.ts
|
|
826
|
-
import { z as z13 } from "zod";
|
|
827
827
|
var LicenseEndpoints = class {
|
|
828
828
|
constructor(api) {
|
|
829
829
|
this.api = api;
|
|
@@ -840,12 +840,12 @@ var LicenseEndpoints = class {
|
|
|
840
840
|
return response.data;
|
|
841
841
|
}
|
|
842
842
|
async revokeActivation(licenseId, activationId) {
|
|
843
|
-
await this.api.authenticatedFetch(`/api/customer/inventory/licenses/${licenseId}/activations/${activationId}/revoke`,
|
|
843
|
+
await this.api.authenticatedFetch(`/api/customer/inventory/licenses/${licenseId}/activations/${activationId}/revoke`, null, { method: "POST" });
|
|
844
844
|
}
|
|
845
845
|
};
|
|
846
846
|
|
|
847
847
|
// src/inventory/products/endpoints.ts
|
|
848
|
-
import { z as
|
|
848
|
+
import { z as z12 } from "zod";
|
|
849
849
|
var ProductEndpoints = class {
|
|
850
850
|
constructor(api) {
|
|
851
851
|
this.api = api;
|
|
@@ -869,8 +869,8 @@ var ProductEndpoints = class {
|
|
|
869
869
|
async getDownloadUrl(path) {
|
|
870
870
|
const url = new URL(path);
|
|
871
871
|
url.searchParams.append("redirect", "false");
|
|
872
|
-
const response = await this.api.fetch(url.pathname + url.search,
|
|
873
|
-
location:
|
|
872
|
+
const response = await this.api.fetch(url.pathname + url.search, z12.object({
|
|
873
|
+
location: z12.string()
|
|
874
874
|
}));
|
|
875
875
|
return response.data.location;
|
|
876
876
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moonbase.sh/storefront-api",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.42",
|
|
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",
|