@moonbase.sh/storefront-api 1.0.36 → 2.0.0

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
@@ -47,7 +47,7 @@ __export(index_exports, {
47
47
  TokenStore: () => TokenStore,
48
48
  objectToQuery: () => objectToQuery,
49
49
  problemDetailsSchema: () => problemDetailsSchema,
50
- schemas: () => schemas_exports11,
50
+ schemas: () => schemas_exports12,
51
51
  utmToObject: () => utmToObject
52
52
  });
53
53
  module.exports = __toCommonJS(index_exports);
@@ -353,6 +353,81 @@ var ActivationRequestEndpoints = class {
353
353
  }
354
354
  };
355
355
 
356
+ // src/communications/schemas.ts
357
+ var schemas_exports4 = {};
358
+ __export(schemas_exports4, {
359
+ communicationPreferencesViewSchema: () => communicationPreferencesViewSchema,
360
+ subscribeResponseSchema: () => subscribeResponseSchema
361
+ });
362
+ var import_zod6 = require("zod");
363
+ var subscribeResponseSchema = import_zod6.z.object({
364
+ status: import_zod6.z.enum(["subscribed", "confirmation_sent"])
365
+ });
366
+ var communicationPreferencesViewSchema = import_zod6.z.object({
367
+ email: import_zod6.z.string(),
368
+ name: import_zod6.z.string().nullish(),
369
+ newsletter: import_zod6.z.boolean(),
370
+ productUpdates: import_zod6.z.boolean()
371
+ });
372
+
373
+ // src/communications/endpoints.ts
374
+ function encodeToken(token) {
375
+ return encodeURIComponent(token.replaceAll(" ", "+"));
376
+ }
377
+ var CommunicationsEndpoints = class {
378
+ constructor(api) {
379
+ this.api = api;
380
+ }
381
+ async subscribe(input) {
382
+ var _a, _b, _c;
383
+ const response = await this.api.fetch("/api/customer/communications/subscribe", subscribeResponseSchema, {
384
+ method: "POST",
385
+ body: {
386
+ email: input.email,
387
+ name: ((_a = input.name) == null ? void 0 : _a.trim()) || null,
388
+ newsletter: (_b = input.newsletter) != null ? _b : true,
389
+ productUpdates: (_c = input.productUpdates) != null ? _c : true
390
+ }
391
+ });
392
+ return response.data;
393
+ }
394
+ async confirm(email, token) {
395
+ await this.api.fetch(
396
+ `/api/customer/communications/confirm?email=${encodeURIComponent(email)}&token=${encodeToken(token)}`,
397
+ null,
398
+ { method: "POST" }
399
+ );
400
+ }
401
+ async getPreferences(email, token) {
402
+ const response = await this.api.fetch(
403
+ `/api/customer/communications/preferences?email=${encodeURIComponent(email)}&token=${encodeToken(token)}`,
404
+ communicationPreferencesViewSchema
405
+ );
406
+ return response.data;
407
+ }
408
+ async updatePreferences(email, token, preferences) {
409
+ const response = await this.api.fetch(
410
+ `/api/customer/communications/preferences?email=${encodeURIComponent(email)}&token=${encodeToken(token)}`,
411
+ communicationPreferencesViewSchema,
412
+ {
413
+ method: "POST",
414
+ body: {
415
+ newsletter: preferences.newsletter,
416
+ productUpdates: preferences.productUpdates
417
+ }
418
+ }
419
+ );
420
+ return response.data;
421
+ }
422
+ async unsubscribe(email, token) {
423
+ await this.api.fetch(
424
+ `/api/customer/communications/unsubscribe?email=${encodeURIComponent(email)}&token=${encodeToken(token)}`,
425
+ null,
426
+ { method: "POST" }
427
+ );
428
+ }
429
+ };
430
+
356
431
  // src/utils/errors.ts
357
432
  var NotAuthorizedError = class extends Error {
358
433
  constructor() {
@@ -392,14 +467,14 @@ var MoonbaseError = class extends Error {
392
467
  };
393
468
 
394
469
  // src/utils/problemDetails.ts
395
- var import_zod6 = require("zod");
396
- var problemDetailsSchema = import_zod6.z.object({
397
- type: import_zod6.z.string().optional(),
398
- title: import_zod6.z.string(),
399
- detail: import_zod6.z.string().optional(),
400
- status: import_zod6.z.number().optional(),
401
- instance: import_zod6.z.string().optional(),
402
- errors: import_zod6.z.record(import_zod6.z.string(), import_zod6.z.string().array()).optional()
470
+ var import_zod7 = require("zod");
471
+ var problemDetailsSchema = import_zod7.z.object({
472
+ type: import_zod7.z.string().optional(),
473
+ title: import_zod7.z.string(),
474
+ detail: import_zod7.z.string().optional(),
475
+ status: import_zod7.z.number().optional(),
476
+ instance: import_zod7.z.string().optional(),
477
+ errors: import_zod7.z.record(import_zod7.z.string(), import_zod7.z.string().array()).optional()
403
478
  });
404
479
 
405
480
  // src/utils/problemHandler.ts
@@ -438,18 +513,20 @@ async function handleResponseProblem(response, logger) {
438
513
  }
439
514
 
440
515
  // src/identity/schemas.ts
441
- var schemas_exports4 = {};
442
- __export(schemas_exports4, {
516
+ var schemas_exports5 = {};
517
+ __export(schemas_exports5, {
443
518
  addressSchema: () => addressSchema,
444
519
  communicationPreferencesSchema: () => communicationPreferencesSchema,
445
520
  connectedAccountSchema: () => connectedAccountSchema,
446
521
  connectionUrlSchema: () => connectionUrlSchema,
447
522
  identitySchema: () => identitySchema,
448
523
  ilokConnectedAccountSchema: () => ilokConnectedAccountSchema,
524
+ pendingActivationSchema: () => pendingActivationSchema,
449
525
  userAccountConfirmedSchema: () => userAccountConfirmedSchema,
526
+ userAccountConfirmedStatusSchema: () => userAccountConfirmedStatusSchema,
450
527
  userSchema: () => userSchema
451
528
  });
452
- var import_zod7 = require("zod");
529
+ var import_zod8 = require("zod");
453
530
 
454
531
  // src/identity/models.ts
455
532
  var ConnectableAccountProvider = /* @__PURE__ */ ((ConnectableAccountProvider2) => {
@@ -458,54 +535,64 @@ var ConnectableAccountProvider = /* @__PURE__ */ ((ConnectableAccountProvider2)
458
535
  })(ConnectableAccountProvider || {});
459
536
 
460
537
  // src/identity/schemas.ts
461
- var addressSchema = import_zod7.z.object({
462
- countryCode: import_zod7.z.string(),
463
- streetAddress1: import_zod7.z.string(),
464
- streetAddress2: import_zod7.z.string().nullable(),
465
- locality: import_zod7.z.string().nullable(),
466
- region: import_zod7.z.string().nullable(),
467
- postCode: import_zod7.z.string().nullable()
538
+ var addressSchema = import_zod8.z.object({
539
+ countryCode: import_zod8.z.string(),
540
+ streetAddress1: import_zod8.z.string(),
541
+ streetAddress2: import_zod8.z.string().nullable(),
542
+ locality: import_zod8.z.string().nullable(),
543
+ region: import_zod8.z.string().nullable(),
544
+ postCode: import_zod8.z.string().nullable()
468
545
  });
469
- var communicationPreferencesSchema = import_zod7.z.object({
470
- newsletterOptIn: import_zod7.z.boolean()
471
- // productUpdatesOptIn: z.boolean(), // TODO: Enable when relevant
546
+ var communicationPreferencesSchema = import_zod8.z.object({
547
+ newsletterOptIn: import_zod8.z.boolean(),
548
+ // Default keeps older persisted identities (pre productUpdatesOptIn) parseable
549
+ // during boot. The server-side value is hydrated by updateUser() right after.
550
+ productUpdatesOptIn: import_zod8.z.boolean().default(false)
472
551
  });
473
- var ilokConnectedAccountSchema = import_zod7.z.object({
474
- provider: import_zod7.z.literal("iLok" /* iLok */),
475
- isConnected: import_zod7.z.boolean(),
476
- pendingLicenseFulfillments: import_zod7.z.boolean(),
477
- accountId: import_zod7.z.string().nullish()
552
+ var ilokConnectedAccountSchema = import_zod8.z.object({
553
+ provider: import_zod8.z.literal("iLok" /* iLok */),
554
+ isConnected: import_zod8.z.boolean(),
555
+ pendingLicenseFulfillments: import_zod8.z.boolean(),
556
+ accountId: import_zod8.z.string().nullish()
478
557
  });
479
- var connectedAccountSchema = import_zod7.z.discriminatedUnion("provider", [
558
+ var connectedAccountSchema = import_zod8.z.discriminatedUnion("provider", [
480
559
  ilokConnectedAccountSchema
481
560
  ]);
482
- var connectionUrlSchema = import_zod7.z.object({
483
- url: import_zod7.z.string()
561
+ var connectionUrlSchema = import_zod8.z.object({
562
+ url: import_zod8.z.string()
484
563
  });
485
- var userSchema = import_zod7.z.object({
486
- id: import_zod7.z.string(),
487
- email: import_zod7.z.string(),
488
- name: import_zod7.z.string(),
489
- tenantId: import_zod7.z.string(),
564
+ var userSchema = import_zod8.z.object({
565
+ id: import_zod8.z.string(),
566
+ email: import_zod8.z.string(),
567
+ name: import_zod8.z.string(),
568
+ tenantId: import_zod8.z.string(),
490
569
  address: addressSchema.optional(),
491
- phone: import_zod7.z.string().optional(),
570
+ phone: import_zod8.z.string().optional(),
492
571
  communicationPreferences: communicationPreferencesSchema,
493
- ownedProducts: import_zod7.z.string().array().optional(),
494
- subscribedProducts: import_zod7.z.string().array().optional(),
495
- confirmedAccount: import_zod7.z.boolean().optional(),
496
- hasProducts: import_zod7.z.boolean().nullish(),
497
- hasSubscriptions: import_zod7.z.boolean().nullish(),
498
- connectedAccounts: import_zod7.z.array(connectedAccountSchema).default([])
572
+ ownedProducts: import_zod8.z.string().array().optional(),
573
+ subscribedProducts: import_zod8.z.string().array().optional(),
574
+ confirmedAccount: import_zod8.z.boolean().optional(),
575
+ hasProducts: import_zod8.z.boolean().nullish(),
576
+ hasSubscriptions: import_zod8.z.boolean().nullish(),
577
+ connectedAccounts: import_zod8.z.array(connectedAccountSchema).default([])
499
578
  });
500
- var identitySchema = userSchema.and(import_zod7.z.object({
501
- accessToken: import_zod7.z.string(),
502
- refreshToken: import_zod7.z.string()
579
+ var identitySchema = userSchema.and(import_zod8.z.object({
580
+ accessToken: import_zod8.z.string(),
581
+ refreshToken: import_zod8.z.string()
582
+ }));
583
+ var userAccountConfirmedStatusSchema = import_zod8.z.enum([
584
+ "PasswordSetupRequired",
585
+ "SignedIn"
586
+ ]);
587
+ var userAccountConfirmedSchema = userSchema.and(import_zod8.z.object({
588
+ status: userAccountConfirmedStatusSchema,
589
+ resetPasswordToken: import_zod8.z.string().nullish(),
590
+ accessToken: import_zod8.z.string().nullish(),
591
+ refreshToken: import_zod8.z.string().nullish()
503
592
  }));
504
- var userAccountConfirmedSchema = import_zod7.z.object({
505
- id: import_zod7.z.string(),
506
- name: import_zod7.z.string(),
507
- email: import_zod7.z.string(),
508
- resetPasswordToken: import_zod7.z.string().nullable()
593
+ var pendingActivationSchema = import_zod8.z.object({
594
+ status: import_zod8.z.literal("activation_pending"),
595
+ email: import_zod8.z.string()
509
596
  });
510
597
 
511
598
  // src/identity/endpoints.ts
@@ -544,19 +631,38 @@ var IdentityEndpoints = class {
544
631
  }
545
632
  }
546
633
  async signUp(name, email, password, address, acceptedPrivacyPolicy, acceptedTermsAndConditions, communicationOptIn) {
547
- const response = await this.api.fetch(`/api/customer/identity/sign-up?scheme=JWT&communicationOptIn=${communicationOptIn ? "true" : "false"}`, identitySchema, {
634
+ const path = `/api/customer/identity/sign-up?scheme=JWT&communicationOptIn=${communicationOptIn ? "true" : "false"}`;
635
+ const response = await fetch(`${this.api.baseUrl}${path}`, {
548
636
  method: "POST",
549
- body: {
637
+ headers: {
638
+ "Accept": "application/json",
639
+ "Content-Type": "application/json",
640
+ "x-mb-cors": "1"
641
+ },
642
+ body: JSON.stringify({
550
643
  name,
551
644
  email,
552
645
  password,
553
646
  address,
554
647
  acceptedPrivacyPolicy,
555
648
  acceptedTermsAndConditions
556
- }
649
+ })
557
650
  });
558
- this.tokenStore.setUser(response.data);
559
- return userSchema.parse(response.data);
651
+ if (response.status >= 400)
652
+ await handleResponseProblem(response, this.logger);
653
+ const data = await response.json();
654
+ if (response.status === 202) {
655
+ const parsed = pendingActivationSchema.parse(data);
656
+ return { status: "activation-pending", email: parsed.email };
657
+ }
658
+ try {
659
+ const identity = identitySchema.parse(data);
660
+ this.tokenStore.setUser(identity);
661
+ return { status: "signed-in", user: userSchema.parse(identity) };
662
+ } catch (err) {
663
+ this.logger.warn("Could not sign up user", { email, response, err });
664
+ throw new MoonbaseError("Bad response", "Could not sign up user", response.status);
665
+ }
560
666
  }
561
667
  async signOut() {
562
668
  this.tokenStore.clear();
@@ -603,13 +709,24 @@ var IdentityEndpoints = class {
603
709
  await handleResponseProblem(response, this.logger);
604
710
  }
605
711
  async confirmAccount(email, code) {
606
- const response = await this.api.fetch(`/api/customer/identity/confirm-account?email=${encodeURIComponent(email)}&code=${encodeURIComponent(code.replaceAll(" ", "+"))}`, userAccountConfirmedSchema, { method: "POST" });
607
- try {
608
- return userAccountConfirmedSchema.parse(response.data);
609
- } catch (err) {
610
- this.logger.warn("Could not confirm user account", { email, code, response, err });
611
- throw new MoonbaseError("Bad response", "Could not confirm user account", response.status);
712
+ const response = await this.api.fetch(`/api/customer/identity/confirm-account?email=${encodeURIComponent(email)}&code=${encodeURIComponent(code.replaceAll(" ", "+"))}&scheme=JWT`, userAccountConfirmedSchema, { method: "POST" });
713
+ const result = response.data;
714
+ if (result.status === "SignedIn") {
715
+ if (!result.accessToken || !result.refreshToken) {
716
+ this.logger.warn("Confirm-account returned SignedIn without tokens", { email });
717
+ throw new MoonbaseError(
718
+ "Bad response",
719
+ "Confirm-account succeeded but the server did not return auth tokens",
720
+ response.status
721
+ );
722
+ }
723
+ this.tokenStore.setUser({
724
+ ...result,
725
+ accessToken: result.accessToken,
726
+ refreshToken: result.refreshToken
727
+ });
612
728
  }
729
+ return result;
613
730
  }
614
731
  async confirmEmail(email, code) {
615
732
  await this.api.fetch(`/api/customer/identity/confirm-email?email=${encodeURIComponent(email)}&code=${encodeURIComponent(code.replaceAll(" ", "+"))}`, null, { method: "POST" });
@@ -633,16 +750,16 @@ var IdentityEndpoints = class {
633
750
  };
634
751
 
635
752
  // src/inventory/activation/endpoints.ts
636
- var import_zod9 = require("zod");
753
+ var import_zod10 = require("zod");
637
754
 
638
755
  // src/inventory/licenses/schemas.ts
639
- var schemas_exports5 = {};
640
- __export(schemas_exports5, {
756
+ var schemas_exports6 = {};
757
+ __export(schemas_exports6, {
641
758
  activationSchema: () => activationSchema,
642
759
  externalLicenseContent: () => externalLicenseContent,
643
760
  licenseSchema: () => licenseSchema
644
761
  });
645
- var import_zod8 = require("zod");
762
+ var import_zod9 = require("zod");
646
763
 
647
764
  // src/inventory/licenses/models.ts
648
765
  var LicenseStatus = /* @__PURE__ */ ((LicenseStatus2) => {
@@ -663,43 +780,43 @@ var ActivationMethod = /* @__PURE__ */ ((ActivationMethod2) => {
663
780
  })(ActivationMethod || {});
664
781
 
665
782
  // src/inventory/licenses/schemas.ts
666
- var externalLicenseFileContent = import_zod8.z.object({
667
- type: import_zod8.z.literal("file"),
668
- fileName: import_zod8.z.string(),
669
- contentType: import_zod8.z.string(),
670
- data: import_zod8.z.string()
783
+ var externalLicenseFileContent = import_zod9.z.object({
784
+ type: import_zod9.z.literal("file"),
785
+ fileName: import_zod9.z.string(),
786
+ contentType: import_zod9.z.string(),
787
+ data: import_zod9.z.string()
671
788
  });
672
- var externalLicenseILokContent = import_zod8.z.object({
673
- type: import_zod8.z.literal("iLok")
789
+ var externalLicenseILokContent = import_zod9.z.object({
790
+ type: import_zod9.z.literal("iLok")
674
791
  });
675
- var externalLicenseContent = import_zod8.z.union([
676
- import_zod8.z.string(),
677
- import_zod8.z.discriminatedUnion("type", [
792
+ var externalLicenseContent = import_zod9.z.union([
793
+ import_zod9.z.string(),
794
+ import_zod9.z.discriminatedUnion("type", [
678
795
  externalLicenseFileContent,
679
796
  externalLicenseILokContent
680
797
  ])
681
798
  ]);
682
- var licenseSchema = import_zod8.z.object({
683
- id: import_zod8.z.string(),
684
- status: import_zod8.z.nativeEnum(LicenseStatus),
799
+ var licenseSchema = import_zod9.z.object({
800
+ id: import_zod9.z.string(),
801
+ status: import_zod9.z.nativeEnum(LicenseStatus),
685
802
  product: productSummarySchema,
686
- activeNumberOfActivations: import_zod8.z.number(),
687
- maxNumberOfActivations: import_zod8.z.number(),
803
+ activeNumberOfActivations: import_zod9.z.number(),
804
+ maxNumberOfActivations: import_zod9.z.number(),
688
805
  externalFulfillment: externalLicenseContent.optional(),
689
- requiredConnectedAccount: import_zod8.z.nativeEnum(ConnectableAccountProvider).nullish(),
690
- fulfillmentMessage: import_zod8.z.string().optional(),
691
- properties: import_zod8.z.record(rawPropertyValueSchema).nullish(),
692
- expiresAt: import_zod8.z.coerce.date().optional(),
693
- createdAt: import_zod8.z.coerce.date()
806
+ requiredConnectedAccount: import_zod9.z.nativeEnum(ConnectableAccountProvider).nullish(),
807
+ fulfillmentMessage: import_zod9.z.string().optional(),
808
+ properties: import_zod9.z.record(rawPropertyValueSchema).nullish(),
809
+ expiresAt: import_zod9.z.coerce.date().optional(),
810
+ createdAt: import_zod9.z.coerce.date()
694
811
  });
695
- var activationSchema = import_zod8.z.object({
696
- id: import_zod8.z.string(),
697
- licenseId: import_zod8.z.string(),
698
- name: import_zod8.z.string(),
699
- status: import_zod8.z.nativeEnum(ActivationStatus),
700
- activationMethod: import_zod8.z.nativeEnum(ActivationMethod),
701
- firstValidatedAt: import_zod8.z.coerce.date(),
702
- lastValidatedAt: import_zod8.z.coerce.date().nullable()
812
+ var activationSchema = import_zod9.z.object({
813
+ id: import_zod9.z.string(),
814
+ licenseId: import_zod9.z.string(),
815
+ name: import_zod9.z.string(),
816
+ status: import_zod9.z.nativeEnum(ActivationStatus),
817
+ activationMethod: import_zod9.z.nativeEnum(ActivationMethod),
818
+ firstValidatedAt: import_zod9.z.coerce.date(),
819
+ lastValidatedAt: import_zod9.z.coerce.date().nullable()
703
820
  });
704
821
 
705
822
  // src/inventory/activation/endpoints.ts
@@ -716,7 +833,7 @@ var ActivationEndpoints = class {
716
833
  });
717
834
  return {
718
835
  license: response.data,
719
- url: import_zod9.z.string().parse(response.headers.location)
836
+ url: import_zod10.z.string().parse(response.headers.location)
720
837
  };
721
838
  }
722
839
  };
@@ -744,7 +861,7 @@ var LicenseEndpoints = class {
744
861
  };
745
862
 
746
863
  // src/inventory/products/endpoints.ts
747
- var import_zod10 = require("zod");
864
+ var import_zod11 = require("zod");
748
865
  var ProductEndpoints = class {
749
866
  constructor(api, configuration) {
750
867
  this.api = api;
@@ -769,8 +886,8 @@ var ProductEndpoints = class {
769
886
  async getDownloadUrl(path) {
770
887
  const url = new URL(path);
771
888
  url.searchParams.append("redirect", "false");
772
- const response = await this.api.fetch(url.pathname + url.search, import_zod10.z.object({
773
- location: import_zod10.z.string()
889
+ const response = await this.api.fetch(url.pathname + url.search, import_zod11.z.object({
890
+ location: import_zod11.z.string()
774
891
  }));
775
892
  return response.data.location;
776
893
  }
@@ -902,15 +1019,15 @@ var MoonbaseApi = class {
902
1019
  };
903
1020
 
904
1021
  // src/inventory/subscriptions/endpoints.ts
905
- var import_zod13 = require("zod");
1022
+ var import_zod14 = require("zod");
906
1023
 
907
1024
  // src/inventory/subscriptions/schemas.ts
908
- var schemas_exports7 = {};
909
- __export(schemas_exports7, {
1025
+ var schemas_exports8 = {};
1026
+ __export(schemas_exports8, {
910
1027
  milestoneProgressSchema: () => milestoneProgressSchema,
911
1028
  subscriptionSchema: () => subscriptionSchema
912
1029
  });
913
- var import_zod12 = require("zod");
1030
+ var import_zod13 = require("zod");
914
1031
 
915
1032
  // src/inventory/subscriptions/models.ts
916
1033
  var SubscriptionStatus = /* @__PURE__ */ ((SubscriptionStatus2) => {
@@ -922,8 +1039,8 @@ var SubscriptionStatus = /* @__PURE__ */ ((SubscriptionStatus2) => {
922
1039
  })(SubscriptionStatus || {});
923
1040
 
924
1041
  // src/orders/schemas.ts
925
- var schemas_exports6 = {};
926
- __export(schemas_exports6, {
1042
+ var schemas_exports7 = {};
1043
+ __export(schemas_exports7, {
927
1044
  completedOrderSchema: () => completedOrderSchema,
928
1045
  openBundleLineItem: () => openBundleLineItem,
929
1046
  openOrderLineItem: () => openOrderLineItem,
@@ -932,7 +1049,7 @@ __export(schemas_exports6, {
932
1049
  orderSchema: () => orderSchema,
933
1050
  orderTotalSchema: () => orderTotalSchema
934
1051
  });
935
- var import_zod11 = require("zod");
1052
+ var import_zod12 = require("zod");
936
1053
 
937
1054
  // src/orders/models.ts
938
1055
  var OrderStatus = /* @__PURE__ */ ((OrderStatus2) => {
@@ -945,171 +1062,171 @@ var OrderStatus = /* @__PURE__ */ ((OrderStatus2) => {
945
1062
  })(OrderStatus || {});
946
1063
 
947
1064
  // src/orders/schemas.ts
948
- var couponSchema = import_zod11.z.object({
949
- code: import_zod11.z.string(),
950
- name: import_zod11.z.string(),
951
- description: import_zod11.z.string()
1065
+ var couponSchema = import_zod12.z.object({
1066
+ code: import_zod12.z.string(),
1067
+ name: import_zod12.z.string(),
1068
+ description: import_zod12.z.string()
952
1069
  });
953
- var lineItemProductSchema = import_zod11.z.object({
954
- id: import_zod11.z.string(),
955
- name: import_zod11.z.string(),
956
- tagline: import_zod11.z.string(),
957
- iconUrl: import_zod11.z.string().nullable()
1070
+ var lineItemProductSchema = import_zod12.z.object({
1071
+ id: import_zod12.z.string(),
1072
+ name: import_zod12.z.string(),
1073
+ tagline: import_zod12.z.string(),
1074
+ iconUrl: import_zod12.z.string().nullable()
958
1075
  });
959
- var lineItemTotalSchema = import_zod11.z.object({
1076
+ var lineItemTotalSchema = import_zod12.z.object({
960
1077
  original: moneySchema,
961
1078
  discount: moneySchema,
962
1079
  subtotal: moneySchema,
963
1080
  due: moneySchema
964
1081
  });
965
- var openProductLineItem = import_zod11.z.object({
966
- id: import_zod11.z.string(),
967
- type: import_zod11.z.literal("Product"),
968
- productId: import_zod11.z.string(),
969
- quantity: import_zod11.z.number(),
970
- variationId: import_zod11.z.string(),
971
- offerId: import_zod11.z.string().optional(),
972
- isDefaultVariation: import_zod11.z.boolean().nullish(),
973
- isSubcriptionPayment: import_zod11.z.boolean().nullish(),
1082
+ var openProductLineItem = import_zod12.z.object({
1083
+ id: import_zod12.z.string(),
1084
+ type: import_zod12.z.literal("Product"),
1085
+ productId: import_zod12.z.string(),
1086
+ quantity: import_zod12.z.number(),
1087
+ variationId: import_zod12.z.string(),
1088
+ offerId: import_zod12.z.string().optional(),
1089
+ isDefaultVariation: import_zod12.z.boolean().nullish(),
1090
+ isSubcriptionPayment: import_zod12.z.boolean().nullish(),
974
1091
  price: priceCollectionSchema.optional(),
975
1092
  variation: pricingVariationSchema.optional(),
976
1093
  total: lineItemTotalSchema.nullish(),
977
1094
  product: lineItemProductSchema.optional(),
978
1095
  appliedDiscount: discountSchema.optional()
979
1096
  });
980
- var lineItemBundleSchema = import_zod11.z.object({
981
- id: import_zod11.z.string(),
982
- name: import_zod11.z.string(),
983
- tagline: import_zod11.z.string(),
984
- iconUrl: import_zod11.z.string().nullable(),
985
- products: lineItemProductSchema.and(import_zod11.z.object({
986
- included: import_zod11.z.boolean().optional()
1097
+ var lineItemBundleSchema = import_zod12.z.object({
1098
+ id: import_zod12.z.string(),
1099
+ name: import_zod12.z.string(),
1100
+ tagline: import_zod12.z.string(),
1101
+ iconUrl: import_zod12.z.string().nullable(),
1102
+ products: lineItemProductSchema.and(import_zod12.z.object({
1103
+ included: import_zod12.z.boolean().optional()
987
1104
  })).array()
988
1105
  });
989
- var openBundleLineItem = import_zod11.z.object({
990
- id: import_zod11.z.string(),
991
- type: import_zod11.z.literal("Bundle"),
992
- bundleId: import_zod11.z.string(),
993
- quantity: import_zod11.z.number(),
994
- variationId: import_zod11.z.string(),
995
- offerId: import_zod11.z.string().optional(),
996
- partial: import_zod11.z.boolean().optional(),
997
- replaced: import_zod11.z.string().array().optional(),
998
- isDefaultVariation: import_zod11.z.boolean().nullish(),
999
- isSubcriptionPayment: import_zod11.z.boolean().nullish(),
1106
+ var openBundleLineItem = import_zod12.z.object({
1107
+ id: import_zod12.z.string(),
1108
+ type: import_zod12.z.literal("Bundle"),
1109
+ bundleId: import_zod12.z.string(),
1110
+ quantity: import_zod12.z.number(),
1111
+ variationId: import_zod12.z.string(),
1112
+ offerId: import_zod12.z.string().optional(),
1113
+ partial: import_zod12.z.boolean().optional(),
1114
+ replaced: import_zod12.z.string().array().optional(),
1115
+ isDefaultVariation: import_zod12.z.boolean().nullish(),
1116
+ isSubcriptionPayment: import_zod12.z.boolean().nullish(),
1000
1117
  price: priceCollectionSchema.optional(),
1001
1118
  variation: pricingVariationSchema.optional(),
1002
1119
  total: lineItemTotalSchema.nullish(),
1003
1120
  bundle: lineItemBundleSchema.optional(),
1004
1121
  appliedDiscount: discountSchema.optional()
1005
1122
  });
1006
- var openOrderLineItem = import_zod11.z.discriminatedUnion("type", [
1123
+ var openOrderLineItem = import_zod12.z.discriminatedUnion("type", [
1007
1124
  openProductLineItem,
1008
1125
  openBundleLineItem
1009
1126
  ]);
1010
- var orderTotalSchema = import_zod11.z.object({
1127
+ var orderTotalSchema = import_zod12.z.object({
1011
1128
  original: moneySchema,
1012
1129
  discount: moneySchema,
1013
1130
  subtotal: moneySchema,
1014
1131
  taxes: moneySchema,
1015
1132
  due: moneySchema
1016
1133
  });
1017
- var openOrderSchema = import_zod11.z.object({
1018
- id: import_zod11.z.string(),
1019
- currency: import_zod11.z.string(),
1134
+ var openOrderSchema = import_zod12.z.object({
1135
+ id: import_zod12.z.string(),
1136
+ currency: import_zod12.z.string(),
1020
1137
  total: orderTotalSchema.nullish(),
1021
1138
  items: openOrderLineItem.array(),
1022
1139
  couponsApplied: couponSchema.array(),
1023
- checkoutUrl: import_zod11.z.string().optional(),
1024
- hostedCheckoutUrl: import_zod11.z.string().optional(),
1025
- embeddedCheckoutUrl: import_zod11.z.string().optional()
1140
+ checkoutUrl: import_zod12.z.string().optional(),
1141
+ hostedCheckoutUrl: import_zod12.z.string().optional(),
1142
+ embeddedCheckoutUrl: import_zod12.z.string().optional()
1026
1143
  });
1027
- var customerSnapshotSchema = import_zod11.z.object({
1028
- name: import_zod11.z.string().nullable(),
1029
- businessName: import_zod11.z.string().nullable(),
1030
- taxId: import_zod11.z.string().nullable(),
1031
- email: import_zod11.z.string().nullable(),
1032
- phone: import_zod11.z.string().nullable(),
1144
+ var customerSnapshotSchema = import_zod12.z.object({
1145
+ name: import_zod12.z.string().nullable(),
1146
+ businessName: import_zod12.z.string().nullable(),
1147
+ taxId: import_zod12.z.string().nullable(),
1148
+ email: import_zod12.z.string().nullable(),
1149
+ phone: import_zod12.z.string().nullable(),
1033
1150
  address: addressSchema.nullable()
1034
1151
  });
1035
- var completedOrderSchema = import_zod11.z.object({
1036
- id: import_zod11.z.string(),
1037
- status: import_zod11.z.literal("Completed" /* Completed */),
1038
- currency: import_zod11.z.string(),
1152
+ var completedOrderSchema = import_zod12.z.object({
1153
+ id: import_zod12.z.string(),
1154
+ status: import_zod12.z.literal("Completed" /* Completed */),
1155
+ currency: import_zod12.z.string(),
1039
1156
  customer: customerSnapshotSchema,
1040
1157
  total: orderTotalSchema,
1041
1158
  items: openOrderLineItem.array(),
1042
1159
  couponsApplied: couponSchema.array()
1043
1160
  });
1044
- var orderSchema = import_zod11.z.discriminatedUnion("status", [
1161
+ var orderSchema = import_zod12.z.discriminatedUnion("status", [
1045
1162
  openOrderSchema.extend({
1046
- status: import_zod11.z.literal("Open" /* Open */)
1163
+ status: import_zod12.z.literal("Open" /* Open */)
1047
1164
  }),
1048
1165
  openOrderSchema.extend({
1049
- status: import_zod11.z.literal("PaymentProcessing" /* PaymentProcessing */)
1166
+ status: import_zod12.z.literal("PaymentProcessing" /* PaymentProcessing */)
1050
1167
  }),
1051
1168
  openOrderSchema.extend({
1052
- status: import_zod11.z.literal("Paid" /* Paid */)
1169
+ status: import_zod12.z.literal("Paid" /* Paid */)
1053
1170
  }),
1054
1171
  openOrderSchema.extend({
1055
- status: import_zod11.z.literal("Failed" /* Failed */)
1172
+ status: import_zod12.z.literal("Failed" /* Failed */)
1056
1173
  }),
1057
1174
  completedOrderSchema
1058
1175
  ]);
1059
1176
 
1060
1177
  // src/inventory/subscriptions/schemas.ts
1061
- var baseMilestoneProgressEventSchema = import_zod12.z.object({
1062
- milestoneId: import_zod12.z.string(),
1063
- fulfilled: import_zod12.z.boolean(),
1064
- afterCycleNumber: import_zod12.z.number(),
1065
- afterNormalizedCycleNumber: import_zod12.z.number(),
1066
- message: import_zod12.z.string().optional()
1178
+ var baseMilestoneProgressEventSchema = import_zod13.z.object({
1179
+ milestoneId: import_zod13.z.string(),
1180
+ fulfilled: import_zod13.z.boolean(),
1181
+ afterCycleNumber: import_zod13.z.number(),
1182
+ afterNormalizedCycleNumber: import_zod13.z.number(),
1183
+ message: import_zod13.z.string().optional()
1067
1184
  });
1068
- var milestoneProgressEventSchema = import_zod12.z.discriminatedUnion("type", [
1185
+ var milestoneProgressEventSchema = import_zod13.z.discriminatedUnion("type", [
1069
1186
  baseMilestoneProgressEventSchema.extend({
1070
- type: import_zod12.z.literal("CouponCodeMilestone"),
1071
- code: import_zod12.z.string().optional(),
1072
- redeemed: import_zod12.z.boolean().optional()
1187
+ type: import_zod13.z.literal("CouponCodeMilestone"),
1188
+ code: import_zod13.z.string().optional(),
1189
+ redeemed: import_zod13.z.boolean().optional()
1073
1190
  }),
1074
1191
  baseMilestoneProgressEventSchema.extend({
1075
- type: import_zod12.z.literal("PerpetualLicenseConversionMilestone")
1192
+ type: import_zod13.z.literal("PerpetualLicenseConversionMilestone")
1076
1193
  })
1077
1194
  ]);
1078
- var milestoneProgressSchema = import_zod12.z.object({
1079
- title: import_zod12.z.string(),
1080
- description: import_zod12.z.string().nullish(),
1081
- currentCycleNumber: import_zod12.z.number(),
1082
- currentNormalizedCycleNumber: import_zod12.z.number(),
1083
- currentCycleIsCompleted: import_zod12.z.boolean(),
1084
- fromCycleNumber: import_zod12.z.number(),
1085
- fromNormalizedCycleNumber: import_zod12.z.number(),
1086
- toCycleNumber: import_zod12.z.number(),
1087
- toNormalizedCycleNumber: import_zod12.z.number(),
1088
- events: import_zod12.z.record(import_zod12.z.coerce.number(), milestoneProgressEventSchema.array())
1195
+ var milestoneProgressSchema = import_zod13.z.object({
1196
+ title: import_zod13.z.string(),
1197
+ description: import_zod13.z.string().nullish(),
1198
+ currentCycleNumber: import_zod13.z.number(),
1199
+ currentNormalizedCycleNumber: import_zod13.z.number(),
1200
+ currentCycleIsCompleted: import_zod13.z.boolean(),
1201
+ fromCycleNumber: import_zod13.z.number(),
1202
+ fromNormalizedCycleNumber: import_zod13.z.number(),
1203
+ toCycleNumber: import_zod13.z.number(),
1204
+ toNormalizedCycleNumber: import_zod13.z.number(),
1205
+ events: import_zod13.z.record(import_zod13.z.coerce.number(), milestoneProgressEventSchema.array())
1089
1206
  });
1090
- var subscriptionSchema = import_zod12.z.object({
1091
- id: import_zod12.z.string(),
1092
- status: import_zod12.z.nativeEnum(SubscriptionStatus),
1093
- hasPaymentMethod: import_zod12.z.boolean(),
1094
- cancellable: import_zod12.z.boolean(),
1095
- expiresAt: import_zod12.z.coerce.date(),
1096
- renewedAt: import_zod12.z.coerce.date().nullable(),
1097
- nextPaymentScheduledAt: import_zod12.z.coerce.date().nullable(),
1098
- startedAt: import_zod12.z.coerce.date(),
1207
+ var subscriptionSchema = import_zod13.z.object({
1208
+ id: import_zod13.z.string(),
1209
+ status: import_zod13.z.nativeEnum(SubscriptionStatus),
1210
+ hasPaymentMethod: import_zod13.z.boolean(),
1211
+ cancellable: import_zod13.z.boolean(),
1212
+ expiresAt: import_zod13.z.coerce.date(),
1213
+ renewedAt: import_zod13.z.coerce.date().nullable(),
1214
+ nextPaymentScheduledAt: import_zod13.z.coerce.date().nullable(),
1215
+ startedAt: import_zod13.z.coerce.date(),
1099
1216
  total: orderTotalSchema,
1100
- cycleLength: import_zod12.z.nativeEnum(CycleLength),
1101
- paymentMethod: import_zod12.z.string().optional(),
1217
+ cycleLength: import_zod13.z.nativeEnum(CycleLength),
1218
+ paymentMethod: import_zod13.z.string().optional(),
1102
1219
  milestoneProgress: milestoneProgressSchema.nullish(),
1103
- embeddedUpdatePaymentUrl: import_zod12.z.string().optional(),
1104
- content: import_zod12.z.discriminatedUnion("type", [
1105
- import_zod12.z.object({
1106
- type: import_zod12.z.literal("Product"),
1107
- quantity: import_zod12.z.number(),
1220
+ embeddedUpdatePaymentUrl: import_zod13.z.string().optional(),
1221
+ content: import_zod13.z.discriminatedUnion("type", [
1222
+ import_zod13.z.object({
1223
+ type: import_zod13.z.literal("Product"),
1224
+ quantity: import_zod13.z.number(),
1108
1225
  product: storefrontProductSchema
1109
1226
  }),
1110
- import_zod12.z.object({
1111
- type: import_zod12.z.literal("Bundle"),
1112
- quantity: import_zod12.z.number(),
1227
+ import_zod13.z.object({
1228
+ type: import_zod13.z.literal("Bundle"),
1229
+ quantity: import_zod13.z.number(),
1113
1230
  bundle: storefrontBundleSchema
1114
1231
  })
1115
1232
  ])
@@ -1134,8 +1251,8 @@ var SubscriptionEndpoints = class {
1134
1251
  return response.data;
1135
1252
  }
1136
1253
  async renew(subscriptionId, returnUrl, embedded) {
1137
- const response = await this.api.authenticatedFetch(`/api/customer/inventory/subscriptions/${subscriptionId}/renew?redirect=false&return=${returnUrl}&embedded=${embedded ? "true" : "false"}`, import_zod13.z.object({
1138
- location: import_zod13.z.string()
1254
+ const response = await this.api.authenticatedFetch(`/api/customer/inventory/subscriptions/${subscriptionId}/renew?redirect=false&return=${returnUrl}&embedded=${embedded ? "true" : "false"}`, import_zod14.z.object({
1255
+ location: import_zod14.z.string()
1139
1256
  }), { method: "POST" });
1140
1257
  return response.data;
1141
1258
  }
@@ -1393,15 +1510,15 @@ _TokenStore.storageKey = "moonbase_auth";
1393
1510
  var TokenStore = _TokenStore;
1394
1511
 
1395
1512
  // src/vendor/schemas.ts
1396
- var schemas_exports8 = {};
1397
- __export(schemas_exports8, {
1513
+ var schemas_exports9 = {};
1514
+ __export(schemas_exports9, {
1398
1515
  vendorSchema: () => vendorSchema
1399
1516
  });
1400
- var import_zod14 = require("zod");
1401
- var vendorSchema = import_zod14.z.object({
1402
- id: import_zod14.z.string(),
1403
- name: import_zod14.z.string(),
1404
- logoUrl: import_zod14.z.string().nullable()
1517
+ var import_zod15 = require("zod");
1518
+ var vendorSchema = import_zod15.z.object({
1519
+ id: import_zod15.z.string(),
1520
+ name: import_zod15.z.string(),
1521
+ logoUrl: import_zod15.z.string().nullable()
1405
1522
  });
1406
1523
 
1407
1524
  // src/vendor/endpoints.ts
@@ -1416,20 +1533,20 @@ var VendorEndpoints = class {
1416
1533
  };
1417
1534
 
1418
1535
  // src/vouchers/schemas.ts
1419
- var schemas_exports9 = {};
1420
- __export(schemas_exports9, {
1536
+ var schemas_exports10 = {};
1537
+ __export(schemas_exports10, {
1421
1538
  voucherSchema: () => voucherSchema
1422
1539
  });
1423
- var import_zod15 = require("zod");
1424
- var voucherSchema = import_zod15.z.object({
1425
- id: import_zod15.z.string(),
1426
- name: import_zod15.z.string(),
1427
- description: import_zod15.z.string(),
1428
- code: import_zod15.z.string(),
1429
- redeemed: import_zod15.z.boolean(),
1540
+ var import_zod16 = require("zod");
1541
+ var voucherSchema = import_zod16.z.object({
1542
+ id: import_zod16.z.string(),
1543
+ name: import_zod16.z.string(),
1544
+ description: import_zod16.z.string(),
1545
+ code: import_zod16.z.string(),
1546
+ redeemed: import_zod16.z.boolean(),
1430
1547
  redeemsProducts: quantifiable(storefrontProductSchema).array(),
1431
1548
  redeemsBundles: quantifiable(storefrontBundleSchema).array(),
1432
- properties: import_zod15.z.record(rawPropertyValueSchema).nullish()
1549
+ properties: import_zod16.z.record(rawPropertyValueSchema).nullish()
1433
1550
  });
1434
1551
 
1435
1552
  // src/vouchers/endpoints.ts
@@ -1480,23 +1597,24 @@ var ConsoleLogger = class {
1480
1597
  };
1481
1598
 
1482
1599
  // src/schemas.ts
1483
- var schemas_exports11 = {};
1484
- __export(schemas_exports11, {
1600
+ var schemas_exports12 = {};
1601
+ __export(schemas_exports12, {
1485
1602
  activationRequests: () => schemas_exports3,
1486
- identity: () => schemas_exports4,
1487
- inventory: () => schemas_exports10,
1488
- orders: () => schemas_exports6,
1603
+ communications: () => schemas_exports4,
1604
+ identity: () => schemas_exports5,
1605
+ inventory: () => schemas_exports11,
1606
+ orders: () => schemas_exports7,
1489
1607
  storefront: () => schemas_exports2,
1490
- vendor: () => schemas_exports8,
1491
- vouchers: () => schemas_exports9
1608
+ vendor: () => schemas_exports9,
1609
+ vouchers: () => schemas_exports10
1492
1610
  });
1493
1611
 
1494
1612
  // src/inventory/schemas.ts
1495
- var schemas_exports10 = {};
1496
- __export(schemas_exports10, {
1497
- licenses: () => schemas_exports5,
1613
+ var schemas_exports11 = {};
1614
+ __export(schemas_exports11, {
1615
+ licenses: () => schemas_exports6,
1498
1616
  products: () => schemas_exports,
1499
- subscriptions: () => schemas_exports7
1617
+ subscriptions: () => schemas_exports8
1500
1618
  });
1501
1619
 
1502
1620
  // src/utils/discount.ts
@@ -1578,6 +1696,7 @@ var MoonbaseClient = class {
1578
1696
  this.api = new MoonbaseApi(this.configuration.endpoint, this.tokenStore, this.logger);
1579
1697
  this.storefront = new StorefrontEndpoints(this.api, this.configuration);
1580
1698
  this.identity = new IdentityEndpoints(this.api, this.tokenStore, this.logger);
1699
+ this.communications = new CommunicationsEndpoints(this.api);
1581
1700
  this.vouchers = new VoucherEndpoints(this.api);
1582
1701
  this.orders = new OrderEndpoints(this.api);
1583
1702
  this.inventory = new InventoryEndpoints(this.api, this.configuration);