@moonbase.sh/storefront-api 0.2.41 → 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 +86 -88
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +86 -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;
|
|
@@ -650,15 +648,16 @@ var MoonbaseApi = class {
|
|
|
650
648
|
await handleResponseProblem(response);
|
|
651
649
|
let json;
|
|
652
650
|
try {
|
|
653
|
-
json = await response.json();
|
|
651
|
+
json = schema ? await response.json() : null;
|
|
654
652
|
return {
|
|
655
|
-
data: schema
|
|
653
|
+
data: schema ? schema.parse(json) : null,
|
|
656
654
|
headers: Object.fromEntries(response.headers.entries()),
|
|
657
655
|
status: response.status
|
|
658
656
|
};
|
|
659
657
|
} catch (err) {
|
|
660
658
|
console.warn("Could not parse response", {
|
|
661
659
|
status: response.status,
|
|
660
|
+
path,
|
|
662
661
|
content: json || (response.bodyUsed ? "unknown" : await response.text()),
|
|
663
662
|
headers: Object.fromEntries(response.headers.entries()),
|
|
664
663
|
userAgent: window && window.navigator && window.navigator.userAgent,
|
|
@@ -775,13 +774,13 @@ _TokenStore.storageKey = "moonbase_auth";
|
|
|
775
774
|
var TokenStore = _TokenStore;
|
|
776
775
|
|
|
777
776
|
// src/vouchers/schemas.ts
|
|
778
|
-
var
|
|
779
|
-
var voucherSchema =
|
|
780
|
-
id:
|
|
781
|
-
name:
|
|
782
|
-
description:
|
|
783
|
-
code:
|
|
784
|
-
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(),
|
|
785
784
|
redeemsProducts: quantifiable(storefrontProductSchema).array(),
|
|
786
785
|
redeemsBundles: quantifiable(storefrontBundleSchema).array()
|
|
787
786
|
});
|
|
@@ -808,10 +807,10 @@ var VoucherEndpoints = class {
|
|
|
808
807
|
};
|
|
809
808
|
|
|
810
809
|
// src/inventory/activation/endpoints.ts
|
|
811
|
-
var
|
|
810
|
+
var import_zod11 = require("zod");
|
|
812
811
|
|
|
813
812
|
// src/inventory/licenses/schemas.ts
|
|
814
|
-
var
|
|
813
|
+
var import_zod10 = require("zod");
|
|
815
814
|
|
|
816
815
|
// src/inventory/licenses/models.ts
|
|
817
816
|
var LicenseStatus = /* @__PURE__ */ ((LicenseStatus2) => {
|
|
@@ -831,21 +830,21 @@ var ActivationMethod = /* @__PURE__ */ ((ActivationMethod2) => {
|
|
|
831
830
|
})(ActivationMethod || {});
|
|
832
831
|
|
|
833
832
|
// src/inventory/licenses/schemas.ts
|
|
834
|
-
var licenseSchema =
|
|
835
|
-
id:
|
|
836
|
-
status:
|
|
833
|
+
var licenseSchema = import_zod10.z.object({
|
|
834
|
+
id: import_zod10.z.string(),
|
|
835
|
+
status: import_zod10.z.nativeEnum(LicenseStatus),
|
|
837
836
|
product: productSummarySchema,
|
|
838
|
-
activeNumberOfActivations:
|
|
839
|
-
maxNumberOfActivations:
|
|
840
|
-
createdAt:
|
|
837
|
+
activeNumberOfActivations: import_zod10.z.number(),
|
|
838
|
+
maxNumberOfActivations: import_zod10.z.number(),
|
|
839
|
+
createdAt: import_zod10.z.coerce.date()
|
|
841
840
|
});
|
|
842
|
-
var activationSchema =
|
|
843
|
-
id:
|
|
844
|
-
licenseId:
|
|
845
|
-
name:
|
|
846
|
-
status:
|
|
847
|
-
activationMethod:
|
|
848
|
-
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()
|
|
849
848
|
});
|
|
850
849
|
|
|
851
850
|
// src/inventory/activation/endpoints.ts
|
|
@@ -861,13 +860,12 @@ var ActivationEndpoints = class {
|
|
|
861
860
|
});
|
|
862
861
|
return {
|
|
863
862
|
license: response.data,
|
|
864
|
-
url:
|
|
863
|
+
url: import_zod11.z.string().parse(response.headers.location)
|
|
865
864
|
};
|
|
866
865
|
}
|
|
867
866
|
};
|
|
868
867
|
|
|
869
868
|
// src/inventory/licenses/endpoints.ts
|
|
870
|
-
var import_zod14 = require("zod");
|
|
871
869
|
var LicenseEndpoints = class {
|
|
872
870
|
constructor(api) {
|
|
873
871
|
this.api = api;
|
|
@@ -884,12 +882,12 @@ var LicenseEndpoints = class {
|
|
|
884
882
|
return response.data;
|
|
885
883
|
}
|
|
886
884
|
async revokeActivation(licenseId, activationId) {
|
|
887
|
-
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" });
|
|
888
886
|
}
|
|
889
887
|
};
|
|
890
888
|
|
|
891
889
|
// src/inventory/products/endpoints.ts
|
|
892
|
-
var
|
|
890
|
+
var import_zod12 = require("zod");
|
|
893
891
|
var ProductEndpoints = class {
|
|
894
892
|
constructor(api) {
|
|
895
893
|
this.api = api;
|
|
@@ -913,8 +911,8 @@ var ProductEndpoints = class {
|
|
|
913
911
|
async getDownloadUrl(path) {
|
|
914
912
|
const url = new URL(path);
|
|
915
913
|
url.searchParams.append("redirect", "false");
|
|
916
|
-
const response = await this.api.fetch(url.pathname + url.search,
|
|
917
|
-
location:
|
|
914
|
+
const response = await this.api.fetch(url.pathname + url.search, import_zod12.z.object({
|
|
915
|
+
location: import_zod12.z.string()
|
|
918
916
|
}));
|
|
919
917
|
return response.data.location;
|
|
920
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;
|
|
@@ -608,15 +606,16 @@ var MoonbaseApi = class {
|
|
|
608
606
|
await handleResponseProblem(response);
|
|
609
607
|
let json;
|
|
610
608
|
try {
|
|
611
|
-
json = await response.json();
|
|
609
|
+
json = schema ? await response.json() : null;
|
|
612
610
|
return {
|
|
613
|
-
data: schema
|
|
611
|
+
data: schema ? schema.parse(json) : null,
|
|
614
612
|
headers: Object.fromEntries(response.headers.entries()),
|
|
615
613
|
status: response.status
|
|
616
614
|
};
|
|
617
615
|
} catch (err) {
|
|
618
616
|
console.warn("Could not parse response", {
|
|
619
617
|
status: response.status,
|
|
618
|
+
path,
|
|
620
619
|
content: json || (response.bodyUsed ? "unknown" : await response.text()),
|
|
621
620
|
headers: Object.fromEntries(response.headers.entries()),
|
|
622
621
|
userAgent: window && window.navigator && window.navigator.userAgent,
|
|
@@ -733,13 +732,13 @@ _TokenStore.storageKey = "moonbase_auth";
|
|
|
733
732
|
var TokenStore = _TokenStore;
|
|
734
733
|
|
|
735
734
|
// src/vouchers/schemas.ts
|
|
736
|
-
import { z as
|
|
737
|
-
var voucherSchema =
|
|
738
|
-
id:
|
|
739
|
-
name:
|
|
740
|
-
description:
|
|
741
|
-
code:
|
|
742
|
-
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(),
|
|
743
742
|
redeemsProducts: quantifiable(storefrontProductSchema).array(),
|
|
744
743
|
redeemsBundles: quantifiable(storefrontBundleSchema).array()
|
|
745
744
|
});
|
|
@@ -766,10 +765,10 @@ var VoucherEndpoints = class {
|
|
|
766
765
|
};
|
|
767
766
|
|
|
768
767
|
// src/inventory/activation/endpoints.ts
|
|
769
|
-
import { z as
|
|
768
|
+
import { z as z11 } from "zod";
|
|
770
769
|
|
|
771
770
|
// src/inventory/licenses/schemas.ts
|
|
772
|
-
import { z as
|
|
771
|
+
import { z as z10 } from "zod";
|
|
773
772
|
|
|
774
773
|
// src/inventory/licenses/models.ts
|
|
775
774
|
var LicenseStatus = /* @__PURE__ */ ((LicenseStatus2) => {
|
|
@@ -789,21 +788,21 @@ var ActivationMethod = /* @__PURE__ */ ((ActivationMethod2) => {
|
|
|
789
788
|
})(ActivationMethod || {});
|
|
790
789
|
|
|
791
790
|
// src/inventory/licenses/schemas.ts
|
|
792
|
-
var licenseSchema =
|
|
793
|
-
id:
|
|
794
|
-
status:
|
|
791
|
+
var licenseSchema = z10.object({
|
|
792
|
+
id: z10.string(),
|
|
793
|
+
status: z10.nativeEnum(LicenseStatus),
|
|
795
794
|
product: productSummarySchema,
|
|
796
|
-
activeNumberOfActivations:
|
|
797
|
-
maxNumberOfActivations:
|
|
798
|
-
createdAt:
|
|
795
|
+
activeNumberOfActivations: z10.number(),
|
|
796
|
+
maxNumberOfActivations: z10.number(),
|
|
797
|
+
createdAt: z10.coerce.date()
|
|
799
798
|
});
|
|
800
|
-
var activationSchema =
|
|
801
|
-
id:
|
|
802
|
-
licenseId:
|
|
803
|
-
name:
|
|
804
|
-
status:
|
|
805
|
-
activationMethod:
|
|
806
|
-
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()
|
|
807
806
|
});
|
|
808
807
|
|
|
809
808
|
// src/inventory/activation/endpoints.ts
|
|
@@ -819,13 +818,12 @@ var ActivationEndpoints = class {
|
|
|
819
818
|
});
|
|
820
819
|
return {
|
|
821
820
|
license: response.data,
|
|
822
|
-
url:
|
|
821
|
+
url: z11.string().parse(response.headers.location)
|
|
823
822
|
};
|
|
824
823
|
}
|
|
825
824
|
};
|
|
826
825
|
|
|
827
826
|
// src/inventory/licenses/endpoints.ts
|
|
828
|
-
import { z as z13 } from "zod";
|
|
829
827
|
var LicenseEndpoints = class {
|
|
830
828
|
constructor(api) {
|
|
831
829
|
this.api = api;
|
|
@@ -842,12 +840,12 @@ var LicenseEndpoints = class {
|
|
|
842
840
|
return response.data;
|
|
843
841
|
}
|
|
844
842
|
async revokeActivation(licenseId, activationId) {
|
|
845
|
-
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" });
|
|
846
844
|
}
|
|
847
845
|
};
|
|
848
846
|
|
|
849
847
|
// src/inventory/products/endpoints.ts
|
|
850
|
-
import { z as
|
|
848
|
+
import { z as z12 } from "zod";
|
|
851
849
|
var ProductEndpoints = class {
|
|
852
850
|
constructor(api) {
|
|
853
851
|
this.api = api;
|
|
@@ -871,8 +869,8 @@ var ProductEndpoints = class {
|
|
|
871
869
|
async getDownloadUrl(path) {
|
|
872
870
|
const url = new URL(path);
|
|
873
871
|
url.searchParams.append("redirect", "false");
|
|
874
|
-
const response = await this.api.fetch(url.pathname + url.search,
|
|
875
|
-
location:
|
|
872
|
+
const response = await this.api.fetch(url.pathname + url.search, z12.object({
|
|
873
|
+
location: z12.string()
|
|
876
874
|
}));
|
|
877
875
|
return response.data.location;
|
|
878
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",
|