@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 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;
@@ -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 instanceof import_zod10.ZodNull ? null : schema.parse(json),
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 import_zod11 = require("zod");
779
- var voucherSchema = import_zod11.z.object({
780
- id: import_zod11.z.string(),
781
- name: import_zod11.z.string(),
782
- description: import_zod11.z.string(),
783
- code: import_zod11.z.string(),
784
- 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(),
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 import_zod13 = require("zod");
810
+ var import_zod11 = require("zod");
812
811
 
813
812
  // src/inventory/licenses/schemas.ts
814
- var import_zod12 = require("zod");
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 = import_zod12.z.object({
835
- id: import_zod12.z.string(),
836
- 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),
837
836
  product: productSummarySchema,
838
- activeNumberOfActivations: import_zod12.z.number(),
839
- maxNumberOfActivations: import_zod12.z.number(),
840
- 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()
841
840
  });
842
- var activationSchema = import_zod12.z.object({
843
- id: import_zod12.z.string(),
844
- licenseId: import_zod12.z.string(),
845
- name: import_zod12.z.string(),
846
- status: import_zod12.z.nativeEnum(ActivationStatus),
847
- activationMethod: import_zod12.z.nativeEnum(ActivationMethod),
848
- 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()
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: import_zod13.z.string().parse(response.headers.location)
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`, import_zod14.z.null(), { method: "POST" });
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 import_zod15 = require("zod");
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, import_zod15.z.object({
917
- 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()
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", 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;
@@ -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 instanceof ZodNull ? null : schema.parse(json),
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 z10 } from "zod";
737
- var voucherSchema = z10.object({
738
- id: z10.string(),
739
- name: z10.string(),
740
- description: z10.string(),
741
- code: z10.string(),
742
- 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(),
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 z12 } from "zod";
768
+ import { z as z11 } from "zod";
770
769
 
771
770
  // src/inventory/licenses/schemas.ts
772
- import { z as z11 } from "zod";
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 = z11.object({
793
- id: z11.string(),
794
- status: z11.nativeEnum(LicenseStatus),
791
+ var licenseSchema = z10.object({
792
+ id: z10.string(),
793
+ status: z10.nativeEnum(LicenseStatus),
795
794
  product: productSummarySchema,
796
- activeNumberOfActivations: z11.number(),
797
- maxNumberOfActivations: z11.number(),
798
- createdAt: z11.coerce.date()
795
+ activeNumberOfActivations: z10.number(),
796
+ maxNumberOfActivations: z10.number(),
797
+ createdAt: z10.coerce.date()
799
798
  });
800
- var activationSchema = z11.object({
801
- id: z11.string(),
802
- licenseId: z11.string(),
803
- name: z11.string(),
804
- status: z11.nativeEnum(ActivationStatus),
805
- activationMethod: z11.nativeEnum(ActivationMethod),
806
- 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()
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: z12.string().parse(response.headers.location)
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`, z13.null(), { method: "POST" });
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 z14 } from "zod";
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, z14.object({
875
- location: z14.string()
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.41",
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",