@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 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", import_zod8.z.null(), {
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`, import_zod8.z.null(), {
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)}`, import_zod8.z.null(), { method: "POST" });
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(" ", "+"))}`, import_zod8.z.null(), { method: "POST" });
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(" ", "+"))}`, import_zod8.z.null(), { method: "POST" });
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 import_zod9 = require("zod");
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 = import_zod9.z.object({
473
- code: import_zod9.z.string(),
474
- name: import_zod9.z.string(),
475
- description: import_zod9.z.string()
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 = import_zod9.z.object({
478
- id: import_zod9.z.string(),
479
- name: import_zod9.z.string(),
480
- tagline: import_zod9.z.string(),
481
- iconUrl: import_zod9.z.string().nullable()
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 = import_zod9.z.object({
484
- id: import_zod9.z.string(),
485
- type: import_zod9.z.literal("Product"),
486
- productId: import_zod9.z.string(),
487
- quantity: import_zod9.z.number(),
488
- variationId: import_zod9.z.string(),
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 = import_zod9.z.object({
495
- id: import_zod9.z.string(),
496
- name: import_zod9.z.string(),
497
- tagline: import_zod9.z.string(),
498
- iconUrl: import_zod9.z.string().nullable(),
499
- partial: import_zod9.z.boolean(),
500
- products: lineItemProductSchema.and(import_zod9.z.object({
501
- included: import_zod9.z.boolean().optional()
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 = import_zod9.z.object({
505
- id: import_zod9.z.string(),
506
- type: import_zod9.z.literal("Bundle"),
507
- bundleId: import_zod9.z.string(),
508
- quantity: import_zod9.z.number(),
509
- variationId: import_zod9.z.string(),
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 = import_zod9.z.discriminatedUnion("type", [
514
+ var openOrderLineItem = import_zod8.z.discriminatedUnion("type", [
516
515
  openProductLineItem,
517
516
  openBundleLineItem
518
517
  ]);
519
- var openOrderSchema = import_zod9.z.object({
520
- id: import_zod9.z.string(),
521
- status: import_zod9.z.literal("Open" /* Open */),
522
- currency: import_zod9.z.string(),
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: import_zod9.z.string().optional(),
526
- embeddedCheckoutUrl: import_zod9.z.string().optional()
524
+ checkoutUrl: import_zod8.z.string().optional(),
525
+ embeddedCheckoutUrl: import_zod8.z.string().optional()
527
526
  });
528
- var moneySchema = import_zod9.z.object({
529
- currency: import_zod9.z.string(),
530
- amount: import_zod9.z.number()
527
+ var moneySchema = import_zod8.z.object({
528
+ currency: import_zod8.z.string(),
529
+ amount: import_zod8.z.number()
531
530
  });
532
- var orderTotalSchema = import_zod9.z.object({
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 = import_zod9.z.object({
540
- name: import_zod9.z.string().nullable(),
541
- businessName: import_zod9.z.string().nullable(),
542
- taxId: import_zod9.z.string().nullable(),
543
- email: import_zod9.z.string().nullable(),
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 = import_zod9.z.object({
547
- id: import_zod9.z.string(),
548
- status: import_zod9.z.literal("Completed" /* Completed */),
549
- currency: import_zod9.z.string(),
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 = import_zod9.z.discriminatedUnion("status", [
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 instanceof import_zod10.ZodNull ? null : schema.parse(await response.json()),
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
- content: await response.text(),
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 import_zod11 = require("zod");
777
- var voucherSchema = import_zod11.z.object({
778
- id: import_zod11.z.string(),
779
- name: import_zod11.z.string(),
780
- description: import_zod11.z.string(),
781
- code: import_zod11.z.string(),
782
- redeemed: import_zod11.z.boolean(),
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 import_zod13 = require("zod");
810
+ var import_zod11 = require("zod");
810
811
 
811
812
  // src/inventory/licenses/schemas.ts
812
- var import_zod12 = require("zod");
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 = import_zod12.z.object({
833
- id: import_zod12.z.string(),
834
- status: import_zod12.z.nativeEnum(LicenseStatus),
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: import_zod12.z.number(),
837
- maxNumberOfActivations: import_zod12.z.number(),
838
- createdAt: import_zod12.z.coerce.date()
837
+ activeNumberOfActivations: import_zod10.z.number(),
838
+ maxNumberOfActivations: import_zod10.z.number(),
839
+ createdAt: import_zod10.z.coerce.date()
839
840
  });
840
- var activationSchema = import_zod12.z.object({
841
- id: import_zod12.z.string(),
842
- licenseId: import_zod12.z.string(),
843
- name: import_zod12.z.string(),
844
- status: import_zod12.z.nativeEnum(ActivationStatus),
845
- activationMethod: import_zod12.z.nativeEnum(ActivationMethod),
846
- lastValidatedAt: import_zod12.z.coerce.date().nullable()
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: import_zod13.z.string().parse(response.headers.location)
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`, import_zod14.z.null(), { method: "POST" });
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 import_zod15 = require("zod");
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, import_zod15.z.object({
915
- location: import_zod15.z.string()
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", z8.null(), {
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`, z8.null(), {
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)}`, z8.null(), { method: "POST" });
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(" ", "+"))}`, z8.null(), { method: "POST" });
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(" ", "+"))}`, z8.null(), { method: "POST" });
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 z9 } from "zod";
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 = z9.object({
431
- code: z9.string(),
432
- name: z9.string(),
433
- description: z9.string()
429
+ var couponSchema = z8.object({
430
+ code: z8.string(),
431
+ name: z8.string(),
432
+ description: z8.string()
434
433
  });
435
- var lineItemProductSchema = z9.object({
436
- id: z9.string(),
437
- name: z9.string(),
438
- tagline: z9.string(),
439
- iconUrl: z9.string().nullable()
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 = z9.object({
442
- id: z9.string(),
443
- type: z9.literal("Product"),
444
- productId: z9.string(),
445
- quantity: z9.number(),
446
- variationId: z9.string(),
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 = z9.object({
453
- id: z9.string(),
454
- name: z9.string(),
455
- tagline: z9.string(),
456
- iconUrl: z9.string().nullable(),
457
- partial: z9.boolean(),
458
- products: lineItemProductSchema.and(z9.object({
459
- included: z9.boolean().optional()
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 = z9.object({
463
- id: z9.string(),
464
- type: z9.literal("Bundle"),
465
- bundleId: z9.string(),
466
- quantity: z9.number(),
467
- variationId: z9.string(),
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 = z9.discriminatedUnion("type", [
472
+ var openOrderLineItem = z8.discriminatedUnion("type", [
474
473
  openProductLineItem,
475
474
  openBundleLineItem
476
475
  ]);
477
- var openOrderSchema = z9.object({
478
- id: z9.string(),
479
- status: z9.literal("Open" /* Open */),
480
- currency: z9.string(),
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: z9.string().optional(),
484
- embeddedCheckoutUrl: z9.string().optional()
482
+ checkoutUrl: z8.string().optional(),
483
+ embeddedCheckoutUrl: z8.string().optional()
485
484
  });
486
- var moneySchema = z9.object({
487
- currency: z9.string(),
488
- amount: z9.number()
485
+ var moneySchema = z8.object({
486
+ currency: z8.string(),
487
+ amount: z8.number()
489
488
  });
490
- var orderTotalSchema = z9.object({
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 = z9.object({
498
- name: z9.string().nullable(),
499
- businessName: z9.string().nullable(),
500
- taxId: z9.string().nullable(),
501
- email: z9.string().nullable(),
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 = z9.object({
505
- id: z9.string(),
506
- status: z9.literal("Completed" /* Completed */),
507
- currency: z9.string(),
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 = z9.discriminatedUnion("status", [
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 instanceof ZodNull ? null : schema.parse(await response.json()),
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
- content: await response.text(),
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 z10 } from "zod";
735
- var voucherSchema = z10.object({
736
- id: z10.string(),
737
- name: z10.string(),
738
- description: z10.string(),
739
- code: z10.string(),
740
- redeemed: z10.boolean(),
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 z12 } from "zod";
768
+ import { z as z11 } from "zod";
768
769
 
769
770
  // src/inventory/licenses/schemas.ts
770
- import { z as z11 } from "zod";
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 = z11.object({
791
- id: z11.string(),
792
- status: z11.nativeEnum(LicenseStatus),
791
+ var licenseSchema = z10.object({
792
+ id: z10.string(),
793
+ status: z10.nativeEnum(LicenseStatus),
793
794
  product: productSummarySchema,
794
- activeNumberOfActivations: z11.number(),
795
- maxNumberOfActivations: z11.number(),
796
- createdAt: z11.coerce.date()
795
+ activeNumberOfActivations: z10.number(),
796
+ maxNumberOfActivations: z10.number(),
797
+ createdAt: z10.coerce.date()
797
798
  });
798
- var activationSchema = z11.object({
799
- id: z11.string(),
800
- licenseId: z11.string(),
801
- name: z11.string(),
802
- status: z11.nativeEnum(ActivationStatus),
803
- activationMethod: z11.nativeEnum(ActivationMethod),
804
- lastValidatedAt: z11.coerce.date().nullable()
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: z12.string().parse(response.headers.location)
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`, z13.null(), { method: "POST" });
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 z14 } from "zod";
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, z14.object({
873
- location: z14.string()
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.40",
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",