@moonbase.sh/storefront-api 1.0.37 → 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.js CHANGED
@@ -305,6 +305,81 @@ var ActivationRequestEndpoints = class {
305
305
  }
306
306
  };
307
307
 
308
+ // src/communications/schemas.ts
309
+ var schemas_exports4 = {};
310
+ __export(schemas_exports4, {
311
+ communicationPreferencesViewSchema: () => communicationPreferencesViewSchema,
312
+ subscribeResponseSchema: () => subscribeResponseSchema
313
+ });
314
+ import { z as z6 } from "zod";
315
+ var subscribeResponseSchema = z6.object({
316
+ status: z6.enum(["subscribed", "confirmation_sent"])
317
+ });
318
+ var communicationPreferencesViewSchema = z6.object({
319
+ email: z6.string(),
320
+ name: z6.string().nullish(),
321
+ newsletter: z6.boolean(),
322
+ productUpdates: z6.boolean()
323
+ });
324
+
325
+ // src/communications/endpoints.ts
326
+ function encodeToken(token) {
327
+ return encodeURIComponent(token.replaceAll(" ", "+"));
328
+ }
329
+ var CommunicationsEndpoints = class {
330
+ constructor(api) {
331
+ this.api = api;
332
+ }
333
+ async subscribe(input) {
334
+ var _a, _b, _c;
335
+ const response = await this.api.fetch("/api/customer/communications/subscribe", subscribeResponseSchema, {
336
+ method: "POST",
337
+ body: {
338
+ email: input.email,
339
+ name: ((_a = input.name) == null ? void 0 : _a.trim()) || null,
340
+ newsletter: (_b = input.newsletter) != null ? _b : true,
341
+ productUpdates: (_c = input.productUpdates) != null ? _c : true
342
+ }
343
+ });
344
+ return response.data;
345
+ }
346
+ async confirm(email, token) {
347
+ await this.api.fetch(
348
+ `/api/customer/communications/confirm?email=${encodeURIComponent(email)}&token=${encodeToken(token)}`,
349
+ null,
350
+ { method: "POST" }
351
+ );
352
+ }
353
+ async getPreferences(email, token) {
354
+ const response = await this.api.fetch(
355
+ `/api/customer/communications/preferences?email=${encodeURIComponent(email)}&token=${encodeToken(token)}`,
356
+ communicationPreferencesViewSchema
357
+ );
358
+ return response.data;
359
+ }
360
+ async updatePreferences(email, token, preferences) {
361
+ const response = await this.api.fetch(
362
+ `/api/customer/communications/preferences?email=${encodeURIComponent(email)}&token=${encodeToken(token)}`,
363
+ communicationPreferencesViewSchema,
364
+ {
365
+ method: "POST",
366
+ body: {
367
+ newsletter: preferences.newsletter,
368
+ productUpdates: preferences.productUpdates
369
+ }
370
+ }
371
+ );
372
+ return response.data;
373
+ }
374
+ async unsubscribe(email, token) {
375
+ await this.api.fetch(
376
+ `/api/customer/communications/unsubscribe?email=${encodeURIComponent(email)}&token=${encodeToken(token)}`,
377
+ null,
378
+ { method: "POST" }
379
+ );
380
+ }
381
+ };
382
+
308
383
  // src/utils/errors.ts
309
384
  var NotAuthorizedError = class extends Error {
310
385
  constructor() {
@@ -344,14 +419,14 @@ var MoonbaseError = class extends Error {
344
419
  };
345
420
 
346
421
  // src/utils/problemDetails.ts
347
- import { z as z6 } from "zod";
348
- var problemDetailsSchema = z6.object({
349
- type: z6.string().optional(),
350
- title: z6.string(),
351
- detail: z6.string().optional(),
352
- status: z6.number().optional(),
353
- instance: z6.string().optional(),
354
- errors: z6.record(z6.string(), z6.string().array()).optional()
422
+ import { z as z7 } from "zod";
423
+ var problemDetailsSchema = z7.object({
424
+ type: z7.string().optional(),
425
+ title: z7.string(),
426
+ detail: z7.string().optional(),
427
+ status: z7.number().optional(),
428
+ instance: z7.string().optional(),
429
+ errors: z7.record(z7.string(), z7.string().array()).optional()
355
430
  });
356
431
 
357
432
  // src/utils/problemHandler.ts
@@ -390,18 +465,20 @@ async function handleResponseProblem(response, logger) {
390
465
  }
391
466
 
392
467
  // src/identity/schemas.ts
393
- var schemas_exports4 = {};
394
- __export(schemas_exports4, {
468
+ var schemas_exports5 = {};
469
+ __export(schemas_exports5, {
395
470
  addressSchema: () => addressSchema,
396
471
  communicationPreferencesSchema: () => communicationPreferencesSchema,
397
472
  connectedAccountSchema: () => connectedAccountSchema,
398
473
  connectionUrlSchema: () => connectionUrlSchema,
399
474
  identitySchema: () => identitySchema,
400
475
  ilokConnectedAccountSchema: () => ilokConnectedAccountSchema,
476
+ pendingActivationSchema: () => pendingActivationSchema,
401
477
  userAccountConfirmedSchema: () => userAccountConfirmedSchema,
478
+ userAccountConfirmedStatusSchema: () => userAccountConfirmedStatusSchema,
402
479
  userSchema: () => userSchema
403
480
  });
404
- import { z as z7 } from "zod";
481
+ import { z as z8 } from "zod";
405
482
 
406
483
  // src/identity/models.ts
407
484
  var ConnectableAccountProvider = /* @__PURE__ */ ((ConnectableAccountProvider2) => {
@@ -410,54 +487,64 @@ var ConnectableAccountProvider = /* @__PURE__ */ ((ConnectableAccountProvider2)
410
487
  })(ConnectableAccountProvider || {});
411
488
 
412
489
  // src/identity/schemas.ts
413
- var addressSchema = z7.object({
414
- countryCode: z7.string(),
415
- streetAddress1: z7.string(),
416
- streetAddress2: z7.string().nullable(),
417
- locality: z7.string().nullable(),
418
- region: z7.string().nullable(),
419
- postCode: z7.string().nullable()
490
+ var addressSchema = z8.object({
491
+ countryCode: z8.string(),
492
+ streetAddress1: z8.string(),
493
+ streetAddress2: z8.string().nullable(),
494
+ locality: z8.string().nullable(),
495
+ region: z8.string().nullable(),
496
+ postCode: z8.string().nullable()
420
497
  });
421
- var communicationPreferencesSchema = z7.object({
422
- newsletterOptIn: z7.boolean()
423
- // productUpdatesOptIn: z.boolean(), // TODO: Enable when relevant
498
+ var communicationPreferencesSchema = z8.object({
499
+ newsletterOptIn: z8.boolean(),
500
+ // Default keeps older persisted identities (pre productUpdatesOptIn) parseable
501
+ // during boot. The server-side value is hydrated by updateUser() right after.
502
+ productUpdatesOptIn: z8.boolean().default(false)
424
503
  });
425
- var ilokConnectedAccountSchema = z7.object({
426
- provider: z7.literal("iLok" /* iLok */),
427
- isConnected: z7.boolean(),
428
- pendingLicenseFulfillments: z7.boolean(),
429
- accountId: z7.string().nullish()
504
+ var ilokConnectedAccountSchema = z8.object({
505
+ provider: z8.literal("iLok" /* iLok */),
506
+ isConnected: z8.boolean(),
507
+ pendingLicenseFulfillments: z8.boolean(),
508
+ accountId: z8.string().nullish()
430
509
  });
431
- var connectedAccountSchema = z7.discriminatedUnion("provider", [
510
+ var connectedAccountSchema = z8.discriminatedUnion("provider", [
432
511
  ilokConnectedAccountSchema
433
512
  ]);
434
- var connectionUrlSchema = z7.object({
435
- url: z7.string()
513
+ var connectionUrlSchema = z8.object({
514
+ url: z8.string()
436
515
  });
437
- var userSchema = z7.object({
438
- id: z7.string(),
439
- email: z7.string(),
440
- name: z7.string(),
441
- tenantId: z7.string(),
516
+ var userSchema = z8.object({
517
+ id: z8.string(),
518
+ email: z8.string(),
519
+ name: z8.string(),
520
+ tenantId: z8.string(),
442
521
  address: addressSchema.optional(),
443
- phone: z7.string().optional(),
522
+ phone: z8.string().optional(),
444
523
  communicationPreferences: communicationPreferencesSchema,
445
- ownedProducts: z7.string().array().optional(),
446
- subscribedProducts: z7.string().array().optional(),
447
- confirmedAccount: z7.boolean().optional(),
448
- hasProducts: z7.boolean().nullish(),
449
- hasSubscriptions: z7.boolean().nullish(),
450
- connectedAccounts: z7.array(connectedAccountSchema).default([])
524
+ ownedProducts: z8.string().array().optional(),
525
+ subscribedProducts: z8.string().array().optional(),
526
+ confirmedAccount: z8.boolean().optional(),
527
+ hasProducts: z8.boolean().nullish(),
528
+ hasSubscriptions: z8.boolean().nullish(),
529
+ connectedAccounts: z8.array(connectedAccountSchema).default([])
451
530
  });
452
- var identitySchema = userSchema.and(z7.object({
453
- accessToken: z7.string(),
454
- refreshToken: z7.string()
531
+ var identitySchema = userSchema.and(z8.object({
532
+ accessToken: z8.string(),
533
+ refreshToken: z8.string()
534
+ }));
535
+ var userAccountConfirmedStatusSchema = z8.enum([
536
+ "PasswordSetupRequired",
537
+ "SignedIn"
538
+ ]);
539
+ var userAccountConfirmedSchema = userSchema.and(z8.object({
540
+ status: userAccountConfirmedStatusSchema,
541
+ resetPasswordToken: z8.string().nullish(),
542
+ accessToken: z8.string().nullish(),
543
+ refreshToken: z8.string().nullish()
455
544
  }));
456
- var userAccountConfirmedSchema = z7.object({
457
- id: z7.string(),
458
- name: z7.string(),
459
- email: z7.string(),
460
- resetPasswordToken: z7.string().nullable()
545
+ var pendingActivationSchema = z8.object({
546
+ status: z8.literal("activation_pending"),
547
+ email: z8.string()
461
548
  });
462
549
 
463
550
  // src/identity/endpoints.ts
@@ -496,19 +583,38 @@ var IdentityEndpoints = class {
496
583
  }
497
584
  }
498
585
  async signUp(name, email, password, address, acceptedPrivacyPolicy, acceptedTermsAndConditions, communicationOptIn) {
499
- const response = await this.api.fetch(`/api/customer/identity/sign-up?scheme=JWT&communicationOptIn=${communicationOptIn ? "true" : "false"}`, identitySchema, {
586
+ const path = `/api/customer/identity/sign-up?scheme=JWT&communicationOptIn=${communicationOptIn ? "true" : "false"}`;
587
+ const response = await fetch(`${this.api.baseUrl}${path}`, {
500
588
  method: "POST",
501
- body: {
589
+ headers: {
590
+ "Accept": "application/json",
591
+ "Content-Type": "application/json",
592
+ "x-mb-cors": "1"
593
+ },
594
+ body: JSON.stringify({
502
595
  name,
503
596
  email,
504
597
  password,
505
598
  address,
506
599
  acceptedPrivacyPolicy,
507
600
  acceptedTermsAndConditions
508
- }
601
+ })
509
602
  });
510
- this.tokenStore.setUser(response.data);
511
- return userSchema.parse(response.data);
603
+ if (response.status >= 400)
604
+ await handleResponseProblem(response, this.logger);
605
+ const data = await response.json();
606
+ if (response.status === 202) {
607
+ const parsed = pendingActivationSchema.parse(data);
608
+ return { status: "activation-pending", email: parsed.email };
609
+ }
610
+ try {
611
+ const identity = identitySchema.parse(data);
612
+ this.tokenStore.setUser(identity);
613
+ return { status: "signed-in", user: userSchema.parse(identity) };
614
+ } catch (err) {
615
+ this.logger.warn("Could not sign up user", { email, response, err });
616
+ throw new MoonbaseError("Bad response", "Could not sign up user", response.status);
617
+ }
512
618
  }
513
619
  async signOut() {
514
620
  this.tokenStore.clear();
@@ -555,13 +661,24 @@ var IdentityEndpoints = class {
555
661
  await handleResponseProblem(response, this.logger);
556
662
  }
557
663
  async confirmAccount(email, code) {
558
- const response = await this.api.fetch(`/api/customer/identity/confirm-account?email=${encodeURIComponent(email)}&code=${encodeURIComponent(code.replaceAll(" ", "+"))}`, userAccountConfirmedSchema, { method: "POST" });
559
- try {
560
- return userAccountConfirmedSchema.parse(response.data);
561
- } catch (err) {
562
- this.logger.warn("Could not confirm user account", { email, code, response, err });
563
- throw new MoonbaseError("Bad response", "Could not confirm user account", response.status);
664
+ const response = await this.api.fetch(`/api/customer/identity/confirm-account?email=${encodeURIComponent(email)}&code=${encodeURIComponent(code.replaceAll(" ", "+"))}&scheme=JWT`, userAccountConfirmedSchema, { method: "POST" });
665
+ const result = response.data;
666
+ if (result.status === "SignedIn") {
667
+ if (!result.accessToken || !result.refreshToken) {
668
+ this.logger.warn("Confirm-account returned SignedIn without tokens", { email });
669
+ throw new MoonbaseError(
670
+ "Bad response",
671
+ "Confirm-account succeeded but the server did not return auth tokens",
672
+ response.status
673
+ );
674
+ }
675
+ this.tokenStore.setUser({
676
+ ...result,
677
+ accessToken: result.accessToken,
678
+ refreshToken: result.refreshToken
679
+ });
564
680
  }
681
+ return result;
565
682
  }
566
683
  async confirmEmail(email, code) {
567
684
  await this.api.fetch(`/api/customer/identity/confirm-email?email=${encodeURIComponent(email)}&code=${encodeURIComponent(code.replaceAll(" ", "+"))}`, null, { method: "POST" });
@@ -585,16 +702,16 @@ var IdentityEndpoints = class {
585
702
  };
586
703
 
587
704
  // src/inventory/activation/endpoints.ts
588
- import { z as z9 } from "zod";
705
+ import { z as z10 } from "zod";
589
706
 
590
707
  // src/inventory/licenses/schemas.ts
591
- var schemas_exports5 = {};
592
- __export(schemas_exports5, {
708
+ var schemas_exports6 = {};
709
+ __export(schemas_exports6, {
593
710
  activationSchema: () => activationSchema,
594
711
  externalLicenseContent: () => externalLicenseContent,
595
712
  licenseSchema: () => licenseSchema
596
713
  });
597
- import { z as z8 } from "zod";
714
+ import { z as z9 } from "zod";
598
715
 
599
716
  // src/inventory/licenses/models.ts
600
717
  var LicenseStatus = /* @__PURE__ */ ((LicenseStatus2) => {
@@ -615,43 +732,43 @@ var ActivationMethod = /* @__PURE__ */ ((ActivationMethod2) => {
615
732
  })(ActivationMethod || {});
616
733
 
617
734
  // src/inventory/licenses/schemas.ts
618
- var externalLicenseFileContent = z8.object({
619
- type: z8.literal("file"),
620
- fileName: z8.string(),
621
- contentType: z8.string(),
622
- data: z8.string()
735
+ var externalLicenseFileContent = z9.object({
736
+ type: z9.literal("file"),
737
+ fileName: z9.string(),
738
+ contentType: z9.string(),
739
+ data: z9.string()
623
740
  });
624
- var externalLicenseILokContent = z8.object({
625
- type: z8.literal("iLok")
741
+ var externalLicenseILokContent = z9.object({
742
+ type: z9.literal("iLok")
626
743
  });
627
- var externalLicenseContent = z8.union([
628
- z8.string(),
629
- z8.discriminatedUnion("type", [
744
+ var externalLicenseContent = z9.union([
745
+ z9.string(),
746
+ z9.discriminatedUnion("type", [
630
747
  externalLicenseFileContent,
631
748
  externalLicenseILokContent
632
749
  ])
633
750
  ]);
634
- var licenseSchema = z8.object({
635
- id: z8.string(),
636
- status: z8.nativeEnum(LicenseStatus),
751
+ var licenseSchema = z9.object({
752
+ id: z9.string(),
753
+ status: z9.nativeEnum(LicenseStatus),
637
754
  product: productSummarySchema,
638
- activeNumberOfActivations: z8.number(),
639
- maxNumberOfActivations: z8.number(),
755
+ activeNumberOfActivations: z9.number(),
756
+ maxNumberOfActivations: z9.number(),
640
757
  externalFulfillment: externalLicenseContent.optional(),
641
- requiredConnectedAccount: z8.nativeEnum(ConnectableAccountProvider).nullish(),
642
- fulfillmentMessage: z8.string().optional(),
643
- properties: z8.record(rawPropertyValueSchema).nullish(),
644
- expiresAt: z8.coerce.date().optional(),
645
- createdAt: z8.coerce.date()
758
+ requiredConnectedAccount: z9.nativeEnum(ConnectableAccountProvider).nullish(),
759
+ fulfillmentMessage: z9.string().optional(),
760
+ properties: z9.record(rawPropertyValueSchema).nullish(),
761
+ expiresAt: z9.coerce.date().optional(),
762
+ createdAt: z9.coerce.date()
646
763
  });
647
- var activationSchema = z8.object({
648
- id: z8.string(),
649
- licenseId: z8.string(),
650
- name: z8.string(),
651
- status: z8.nativeEnum(ActivationStatus),
652
- activationMethod: z8.nativeEnum(ActivationMethod),
653
- firstValidatedAt: z8.coerce.date(),
654
- lastValidatedAt: z8.coerce.date().nullable()
764
+ var activationSchema = z9.object({
765
+ id: z9.string(),
766
+ licenseId: z9.string(),
767
+ name: z9.string(),
768
+ status: z9.nativeEnum(ActivationStatus),
769
+ activationMethod: z9.nativeEnum(ActivationMethod),
770
+ firstValidatedAt: z9.coerce.date(),
771
+ lastValidatedAt: z9.coerce.date().nullable()
655
772
  });
656
773
 
657
774
  // src/inventory/activation/endpoints.ts
@@ -668,7 +785,7 @@ var ActivationEndpoints = class {
668
785
  });
669
786
  return {
670
787
  license: response.data,
671
- url: z9.string().parse(response.headers.location)
788
+ url: z10.string().parse(response.headers.location)
672
789
  };
673
790
  }
674
791
  };
@@ -696,7 +813,7 @@ var LicenseEndpoints = class {
696
813
  };
697
814
 
698
815
  // src/inventory/products/endpoints.ts
699
- import { z as z10 } from "zod";
816
+ import { z as z11 } from "zod";
700
817
  var ProductEndpoints = class {
701
818
  constructor(api, configuration) {
702
819
  this.api = api;
@@ -721,8 +838,8 @@ var ProductEndpoints = class {
721
838
  async getDownloadUrl(path) {
722
839
  const url = new URL(path);
723
840
  url.searchParams.append("redirect", "false");
724
- const response = await this.api.fetch(url.pathname + url.search, z10.object({
725
- location: z10.string()
841
+ const response = await this.api.fetch(url.pathname + url.search, z11.object({
842
+ location: z11.string()
726
843
  }));
727
844
  return response.data.location;
728
845
  }
@@ -854,15 +971,15 @@ var MoonbaseApi = class {
854
971
  };
855
972
 
856
973
  // src/inventory/subscriptions/endpoints.ts
857
- import { z as z13 } from "zod";
974
+ import { z as z14 } from "zod";
858
975
 
859
976
  // src/inventory/subscriptions/schemas.ts
860
- var schemas_exports7 = {};
861
- __export(schemas_exports7, {
977
+ var schemas_exports8 = {};
978
+ __export(schemas_exports8, {
862
979
  milestoneProgressSchema: () => milestoneProgressSchema,
863
980
  subscriptionSchema: () => subscriptionSchema
864
981
  });
865
- import { z as z12 } from "zod";
982
+ import { z as z13 } from "zod";
866
983
 
867
984
  // src/inventory/subscriptions/models.ts
868
985
  var SubscriptionStatus = /* @__PURE__ */ ((SubscriptionStatus2) => {
@@ -874,8 +991,8 @@ var SubscriptionStatus = /* @__PURE__ */ ((SubscriptionStatus2) => {
874
991
  })(SubscriptionStatus || {});
875
992
 
876
993
  // src/orders/schemas.ts
877
- var schemas_exports6 = {};
878
- __export(schemas_exports6, {
994
+ var schemas_exports7 = {};
995
+ __export(schemas_exports7, {
879
996
  completedOrderSchema: () => completedOrderSchema,
880
997
  openBundleLineItem: () => openBundleLineItem,
881
998
  openOrderLineItem: () => openOrderLineItem,
@@ -884,7 +1001,7 @@ __export(schemas_exports6, {
884
1001
  orderSchema: () => orderSchema,
885
1002
  orderTotalSchema: () => orderTotalSchema
886
1003
  });
887
- import { z as z11 } from "zod";
1004
+ import { z as z12 } from "zod";
888
1005
 
889
1006
  // src/orders/models.ts
890
1007
  var OrderStatus = /* @__PURE__ */ ((OrderStatus2) => {
@@ -897,171 +1014,171 @@ var OrderStatus = /* @__PURE__ */ ((OrderStatus2) => {
897
1014
  })(OrderStatus || {});
898
1015
 
899
1016
  // src/orders/schemas.ts
900
- var couponSchema = z11.object({
901
- code: z11.string(),
902
- name: z11.string(),
903
- description: z11.string()
1017
+ var couponSchema = z12.object({
1018
+ code: z12.string(),
1019
+ name: z12.string(),
1020
+ description: z12.string()
904
1021
  });
905
- var lineItemProductSchema = z11.object({
906
- id: z11.string(),
907
- name: z11.string(),
908
- tagline: z11.string(),
909
- iconUrl: z11.string().nullable()
1022
+ var lineItemProductSchema = z12.object({
1023
+ id: z12.string(),
1024
+ name: z12.string(),
1025
+ tagline: z12.string(),
1026
+ iconUrl: z12.string().nullable()
910
1027
  });
911
- var lineItemTotalSchema = z11.object({
1028
+ var lineItemTotalSchema = z12.object({
912
1029
  original: moneySchema,
913
1030
  discount: moneySchema,
914
1031
  subtotal: moneySchema,
915
1032
  due: moneySchema
916
1033
  });
917
- var openProductLineItem = z11.object({
918
- id: z11.string(),
919
- type: z11.literal("Product"),
920
- productId: z11.string(),
921
- quantity: z11.number(),
922
- variationId: z11.string(),
923
- offerId: z11.string().optional(),
924
- isDefaultVariation: z11.boolean().nullish(),
925
- isSubcriptionPayment: z11.boolean().nullish(),
1034
+ var openProductLineItem = z12.object({
1035
+ id: z12.string(),
1036
+ type: z12.literal("Product"),
1037
+ productId: z12.string(),
1038
+ quantity: z12.number(),
1039
+ variationId: z12.string(),
1040
+ offerId: z12.string().optional(),
1041
+ isDefaultVariation: z12.boolean().nullish(),
1042
+ isSubcriptionPayment: z12.boolean().nullish(),
926
1043
  price: priceCollectionSchema.optional(),
927
1044
  variation: pricingVariationSchema.optional(),
928
1045
  total: lineItemTotalSchema.nullish(),
929
1046
  product: lineItemProductSchema.optional(),
930
1047
  appliedDiscount: discountSchema.optional()
931
1048
  });
932
- var lineItemBundleSchema = z11.object({
933
- id: z11.string(),
934
- name: z11.string(),
935
- tagline: z11.string(),
936
- iconUrl: z11.string().nullable(),
937
- products: lineItemProductSchema.and(z11.object({
938
- included: z11.boolean().optional()
1049
+ var lineItemBundleSchema = z12.object({
1050
+ id: z12.string(),
1051
+ name: z12.string(),
1052
+ tagline: z12.string(),
1053
+ iconUrl: z12.string().nullable(),
1054
+ products: lineItemProductSchema.and(z12.object({
1055
+ included: z12.boolean().optional()
939
1056
  })).array()
940
1057
  });
941
- var openBundleLineItem = z11.object({
942
- id: z11.string(),
943
- type: z11.literal("Bundle"),
944
- bundleId: z11.string(),
945
- quantity: z11.number(),
946
- variationId: z11.string(),
947
- offerId: z11.string().optional(),
948
- partial: z11.boolean().optional(),
949
- replaced: z11.string().array().optional(),
950
- isDefaultVariation: z11.boolean().nullish(),
951
- isSubcriptionPayment: z11.boolean().nullish(),
1058
+ var openBundleLineItem = z12.object({
1059
+ id: z12.string(),
1060
+ type: z12.literal("Bundle"),
1061
+ bundleId: z12.string(),
1062
+ quantity: z12.number(),
1063
+ variationId: z12.string(),
1064
+ offerId: z12.string().optional(),
1065
+ partial: z12.boolean().optional(),
1066
+ replaced: z12.string().array().optional(),
1067
+ isDefaultVariation: z12.boolean().nullish(),
1068
+ isSubcriptionPayment: z12.boolean().nullish(),
952
1069
  price: priceCollectionSchema.optional(),
953
1070
  variation: pricingVariationSchema.optional(),
954
1071
  total: lineItemTotalSchema.nullish(),
955
1072
  bundle: lineItemBundleSchema.optional(),
956
1073
  appliedDiscount: discountSchema.optional()
957
1074
  });
958
- var openOrderLineItem = z11.discriminatedUnion("type", [
1075
+ var openOrderLineItem = z12.discriminatedUnion("type", [
959
1076
  openProductLineItem,
960
1077
  openBundleLineItem
961
1078
  ]);
962
- var orderTotalSchema = z11.object({
1079
+ var orderTotalSchema = z12.object({
963
1080
  original: moneySchema,
964
1081
  discount: moneySchema,
965
1082
  subtotal: moneySchema,
966
1083
  taxes: moneySchema,
967
1084
  due: moneySchema
968
1085
  });
969
- var openOrderSchema = z11.object({
970
- id: z11.string(),
971
- currency: z11.string(),
1086
+ var openOrderSchema = z12.object({
1087
+ id: z12.string(),
1088
+ currency: z12.string(),
972
1089
  total: orderTotalSchema.nullish(),
973
1090
  items: openOrderLineItem.array(),
974
1091
  couponsApplied: couponSchema.array(),
975
- checkoutUrl: z11.string().optional(),
976
- hostedCheckoutUrl: z11.string().optional(),
977
- embeddedCheckoutUrl: z11.string().optional()
1092
+ checkoutUrl: z12.string().optional(),
1093
+ hostedCheckoutUrl: z12.string().optional(),
1094
+ embeddedCheckoutUrl: z12.string().optional()
978
1095
  });
979
- var customerSnapshotSchema = z11.object({
980
- name: z11.string().nullable(),
981
- businessName: z11.string().nullable(),
982
- taxId: z11.string().nullable(),
983
- email: z11.string().nullable(),
984
- phone: z11.string().nullable(),
1096
+ var customerSnapshotSchema = z12.object({
1097
+ name: z12.string().nullable(),
1098
+ businessName: z12.string().nullable(),
1099
+ taxId: z12.string().nullable(),
1100
+ email: z12.string().nullable(),
1101
+ phone: z12.string().nullable(),
985
1102
  address: addressSchema.nullable()
986
1103
  });
987
- var completedOrderSchema = z11.object({
988
- id: z11.string(),
989
- status: z11.literal("Completed" /* Completed */),
990
- currency: z11.string(),
1104
+ var completedOrderSchema = z12.object({
1105
+ id: z12.string(),
1106
+ status: z12.literal("Completed" /* Completed */),
1107
+ currency: z12.string(),
991
1108
  customer: customerSnapshotSchema,
992
1109
  total: orderTotalSchema,
993
1110
  items: openOrderLineItem.array(),
994
1111
  couponsApplied: couponSchema.array()
995
1112
  });
996
- var orderSchema = z11.discriminatedUnion("status", [
1113
+ var orderSchema = z12.discriminatedUnion("status", [
997
1114
  openOrderSchema.extend({
998
- status: z11.literal("Open" /* Open */)
1115
+ status: z12.literal("Open" /* Open */)
999
1116
  }),
1000
1117
  openOrderSchema.extend({
1001
- status: z11.literal("PaymentProcessing" /* PaymentProcessing */)
1118
+ status: z12.literal("PaymentProcessing" /* PaymentProcessing */)
1002
1119
  }),
1003
1120
  openOrderSchema.extend({
1004
- status: z11.literal("Paid" /* Paid */)
1121
+ status: z12.literal("Paid" /* Paid */)
1005
1122
  }),
1006
1123
  openOrderSchema.extend({
1007
- status: z11.literal("Failed" /* Failed */)
1124
+ status: z12.literal("Failed" /* Failed */)
1008
1125
  }),
1009
1126
  completedOrderSchema
1010
1127
  ]);
1011
1128
 
1012
1129
  // src/inventory/subscriptions/schemas.ts
1013
- var baseMilestoneProgressEventSchema = z12.object({
1014
- milestoneId: z12.string(),
1015
- fulfilled: z12.boolean(),
1016
- afterCycleNumber: z12.number(),
1017
- afterNormalizedCycleNumber: z12.number(),
1018
- message: z12.string().optional()
1130
+ var baseMilestoneProgressEventSchema = z13.object({
1131
+ milestoneId: z13.string(),
1132
+ fulfilled: z13.boolean(),
1133
+ afterCycleNumber: z13.number(),
1134
+ afterNormalizedCycleNumber: z13.number(),
1135
+ message: z13.string().optional()
1019
1136
  });
1020
- var milestoneProgressEventSchema = z12.discriminatedUnion("type", [
1137
+ var milestoneProgressEventSchema = z13.discriminatedUnion("type", [
1021
1138
  baseMilestoneProgressEventSchema.extend({
1022
- type: z12.literal("CouponCodeMilestone"),
1023
- code: z12.string().optional(),
1024
- redeemed: z12.boolean().optional()
1139
+ type: z13.literal("CouponCodeMilestone"),
1140
+ code: z13.string().optional(),
1141
+ redeemed: z13.boolean().optional()
1025
1142
  }),
1026
1143
  baseMilestoneProgressEventSchema.extend({
1027
- type: z12.literal("PerpetualLicenseConversionMilestone")
1144
+ type: z13.literal("PerpetualLicenseConversionMilestone")
1028
1145
  })
1029
1146
  ]);
1030
- var milestoneProgressSchema = z12.object({
1031
- title: z12.string(),
1032
- description: z12.string().nullish(),
1033
- currentCycleNumber: z12.number(),
1034
- currentNormalizedCycleNumber: z12.number(),
1035
- currentCycleIsCompleted: z12.boolean(),
1036
- fromCycleNumber: z12.number(),
1037
- fromNormalizedCycleNumber: z12.number(),
1038
- toCycleNumber: z12.number(),
1039
- toNormalizedCycleNumber: z12.number(),
1040
- events: z12.record(z12.coerce.number(), milestoneProgressEventSchema.array())
1147
+ var milestoneProgressSchema = z13.object({
1148
+ title: z13.string(),
1149
+ description: z13.string().nullish(),
1150
+ currentCycleNumber: z13.number(),
1151
+ currentNormalizedCycleNumber: z13.number(),
1152
+ currentCycleIsCompleted: z13.boolean(),
1153
+ fromCycleNumber: z13.number(),
1154
+ fromNormalizedCycleNumber: z13.number(),
1155
+ toCycleNumber: z13.number(),
1156
+ toNormalizedCycleNumber: z13.number(),
1157
+ events: z13.record(z13.coerce.number(), milestoneProgressEventSchema.array())
1041
1158
  });
1042
- var subscriptionSchema = z12.object({
1043
- id: z12.string(),
1044
- status: z12.nativeEnum(SubscriptionStatus),
1045
- hasPaymentMethod: z12.boolean(),
1046
- cancellable: z12.boolean(),
1047
- expiresAt: z12.coerce.date(),
1048
- renewedAt: z12.coerce.date().nullable(),
1049
- nextPaymentScheduledAt: z12.coerce.date().nullable(),
1050
- startedAt: z12.coerce.date(),
1159
+ var subscriptionSchema = z13.object({
1160
+ id: z13.string(),
1161
+ status: z13.nativeEnum(SubscriptionStatus),
1162
+ hasPaymentMethod: z13.boolean(),
1163
+ cancellable: z13.boolean(),
1164
+ expiresAt: z13.coerce.date(),
1165
+ renewedAt: z13.coerce.date().nullable(),
1166
+ nextPaymentScheduledAt: z13.coerce.date().nullable(),
1167
+ startedAt: z13.coerce.date(),
1051
1168
  total: orderTotalSchema,
1052
- cycleLength: z12.nativeEnum(CycleLength),
1053
- paymentMethod: z12.string().optional(),
1169
+ cycleLength: z13.nativeEnum(CycleLength),
1170
+ paymentMethod: z13.string().optional(),
1054
1171
  milestoneProgress: milestoneProgressSchema.nullish(),
1055
- embeddedUpdatePaymentUrl: z12.string().optional(),
1056
- content: z12.discriminatedUnion("type", [
1057
- z12.object({
1058
- type: z12.literal("Product"),
1059
- quantity: z12.number(),
1172
+ embeddedUpdatePaymentUrl: z13.string().optional(),
1173
+ content: z13.discriminatedUnion("type", [
1174
+ z13.object({
1175
+ type: z13.literal("Product"),
1176
+ quantity: z13.number(),
1060
1177
  product: storefrontProductSchema
1061
1178
  }),
1062
- z12.object({
1063
- type: z12.literal("Bundle"),
1064
- quantity: z12.number(),
1179
+ z13.object({
1180
+ type: z13.literal("Bundle"),
1181
+ quantity: z13.number(),
1065
1182
  bundle: storefrontBundleSchema
1066
1183
  })
1067
1184
  ])
@@ -1086,8 +1203,8 @@ var SubscriptionEndpoints = class {
1086
1203
  return response.data;
1087
1204
  }
1088
1205
  async renew(subscriptionId, returnUrl, embedded) {
1089
- const response = await this.api.authenticatedFetch(`/api/customer/inventory/subscriptions/${subscriptionId}/renew?redirect=false&return=${returnUrl}&embedded=${embedded ? "true" : "false"}`, z13.object({
1090
- location: z13.string()
1206
+ const response = await this.api.authenticatedFetch(`/api/customer/inventory/subscriptions/${subscriptionId}/renew?redirect=false&return=${returnUrl}&embedded=${embedded ? "true" : "false"}`, z14.object({
1207
+ location: z14.string()
1091
1208
  }), { method: "POST" });
1092
1209
  return response.data;
1093
1210
  }
@@ -1345,15 +1462,15 @@ _TokenStore.storageKey = "moonbase_auth";
1345
1462
  var TokenStore = _TokenStore;
1346
1463
 
1347
1464
  // src/vendor/schemas.ts
1348
- var schemas_exports8 = {};
1349
- __export(schemas_exports8, {
1465
+ var schemas_exports9 = {};
1466
+ __export(schemas_exports9, {
1350
1467
  vendorSchema: () => vendorSchema
1351
1468
  });
1352
- import { z as z14 } from "zod";
1353
- var vendorSchema = z14.object({
1354
- id: z14.string(),
1355
- name: z14.string(),
1356
- logoUrl: z14.string().nullable()
1469
+ import { z as z15 } from "zod";
1470
+ var vendorSchema = z15.object({
1471
+ id: z15.string(),
1472
+ name: z15.string(),
1473
+ logoUrl: z15.string().nullable()
1357
1474
  });
1358
1475
 
1359
1476
  // src/vendor/endpoints.ts
@@ -1368,20 +1485,20 @@ var VendorEndpoints = class {
1368
1485
  };
1369
1486
 
1370
1487
  // src/vouchers/schemas.ts
1371
- var schemas_exports9 = {};
1372
- __export(schemas_exports9, {
1488
+ var schemas_exports10 = {};
1489
+ __export(schemas_exports10, {
1373
1490
  voucherSchema: () => voucherSchema
1374
1491
  });
1375
- import { z as z15 } from "zod";
1376
- var voucherSchema = z15.object({
1377
- id: z15.string(),
1378
- name: z15.string(),
1379
- description: z15.string(),
1380
- code: z15.string(),
1381
- redeemed: z15.boolean(),
1492
+ import { z as z16 } from "zod";
1493
+ var voucherSchema = z16.object({
1494
+ id: z16.string(),
1495
+ name: z16.string(),
1496
+ description: z16.string(),
1497
+ code: z16.string(),
1498
+ redeemed: z16.boolean(),
1382
1499
  redeemsProducts: quantifiable(storefrontProductSchema).array(),
1383
1500
  redeemsBundles: quantifiable(storefrontBundleSchema).array(),
1384
- properties: z15.record(rawPropertyValueSchema).nullish()
1501
+ properties: z16.record(rawPropertyValueSchema).nullish()
1385
1502
  });
1386
1503
 
1387
1504
  // src/vouchers/endpoints.ts
@@ -1432,23 +1549,24 @@ var ConsoleLogger = class {
1432
1549
  };
1433
1550
 
1434
1551
  // src/schemas.ts
1435
- var schemas_exports11 = {};
1436
- __export(schemas_exports11, {
1552
+ var schemas_exports12 = {};
1553
+ __export(schemas_exports12, {
1437
1554
  activationRequests: () => schemas_exports3,
1438
- identity: () => schemas_exports4,
1439
- inventory: () => schemas_exports10,
1440
- orders: () => schemas_exports6,
1555
+ communications: () => schemas_exports4,
1556
+ identity: () => schemas_exports5,
1557
+ inventory: () => schemas_exports11,
1558
+ orders: () => schemas_exports7,
1441
1559
  storefront: () => schemas_exports2,
1442
- vendor: () => schemas_exports8,
1443
- vouchers: () => schemas_exports9
1560
+ vendor: () => schemas_exports9,
1561
+ vouchers: () => schemas_exports10
1444
1562
  });
1445
1563
 
1446
1564
  // src/inventory/schemas.ts
1447
- var schemas_exports10 = {};
1448
- __export(schemas_exports10, {
1449
- licenses: () => schemas_exports5,
1565
+ var schemas_exports11 = {};
1566
+ __export(schemas_exports11, {
1567
+ licenses: () => schemas_exports6,
1450
1568
  products: () => schemas_exports,
1451
- subscriptions: () => schemas_exports7
1569
+ subscriptions: () => schemas_exports8
1452
1570
  });
1453
1571
 
1454
1572
  // src/utils/discount.ts
@@ -1530,6 +1648,7 @@ var MoonbaseClient = class {
1530
1648
  this.api = new MoonbaseApi(this.configuration.endpoint, this.tokenStore, this.logger);
1531
1649
  this.storefront = new StorefrontEndpoints(this.api, this.configuration);
1532
1650
  this.identity = new IdentityEndpoints(this.api, this.tokenStore, this.logger);
1651
+ this.communications = new CommunicationsEndpoints(this.api);
1533
1652
  this.vouchers = new VoucherEndpoints(this.api);
1534
1653
  this.orders = new OrderEndpoints(this.api);
1535
1654
  this.inventory = new InventoryEndpoints(this.api, this.configuration);
@@ -1565,6 +1684,6 @@ export {
1565
1684
  TokenStore,
1566
1685
  objectToQuery,
1567
1686
  problemDetailsSchema,
1568
- schemas_exports11 as schemas,
1687
+ schemas_exports12 as schemas,
1569
1688
  utmToObject
1570
1689
  };