@moonbase.sh/storefront-api 3.9.0 → 3.11.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
@@ -48,6 +48,7 @@ __export(index_exports, {
48
48
  OrderStatus: () => OrderStatus,
49
49
  PasswordSetupRequiredError: () => PasswordSetupRequiredError,
50
50
  Platform: () => Platform,
51
+ ReleaseNotCoveredError: () => ReleaseNotCoveredError,
51
52
  StoreClosedError: () => StoreClosedError,
52
53
  SubscriptionCancellationReason: () => SubscriptionCancellationReason,
53
54
  SubscriptionStatus: () => SubscriptionStatus,
@@ -85,6 +86,7 @@ __export(schemas_exports2, {
85
86
  offerConditionSchema: () => offerConditionSchema,
86
87
  offerScopeSchema: () => offerScopeSchema,
87
88
  storefrontBundleSchema: () => storefrontBundleSchema,
89
+ storefrontLicenseUpgradeSchema: () => storefrontLicenseUpgradeSchema,
88
90
  storefrontOfferSchema: () => storefrontOfferSchema,
89
91
  storefrontOfferTargetSchema: () => storefrontOfferTargetSchema,
90
92
  storefrontProductSchema: () => storefrontProductSchema,
@@ -219,6 +221,7 @@ var schemas_exports = {};
219
221
  __export(schemas_exports, {
220
222
  downloadSchema: () => downloadSchema,
221
223
  manifestSchema: () => manifestSchema,
224
+ productReleaseAccessSchema: () => productReleaseAccessSchema,
222
225
  productReleaseSchema: () => productReleaseSchema,
223
226
  productSummarySchema: () => productSummarySchema
224
227
  });
@@ -261,6 +264,21 @@ var downloadSchema = import_zod2.z.object({
261
264
  path: import_zod2.z.string().nullable(),
262
265
  manifest: manifestSchema.optional()
263
266
  });
267
+ var productReleaseAccessSchema = import_zod2.z.object({
268
+ // Releases published until then are covered, and every version while it has not passed.
269
+ updatesUntil: import_zod2.z.coerce.date().nullish().catch(void 0),
270
+ // Every version whose major is at most this is covered.
271
+ upToMajor: import_zod2.z.number().nullish().catch(void 0),
272
+ // Once updates have ended, the last version published before they did.
273
+ upToVersion: import_zod2.z.string().nullish().catch(void 0),
274
+ // Whether the release this was resolved for (the one shown) is covered. Read as covered when
275
+ // unreadable, so a garbled answer never locks a download the API would hand out.
276
+ coversRelease: import_zod2.z.boolean().catch(true),
277
+ // The newest published version the customer may download, when the shown one is not covered.
278
+ latestCoveredVersion: import_zod2.z.string().nullish().catch(void 0),
279
+ // Where to buy the upgrade or renewal, while the product sells one.
280
+ upgradeUrl: import_zod2.z.string().nullish().catch(void 0)
281
+ });
264
282
  var productSummarySchema = import_zod2.z.object({
265
283
  id: import_zod2.z.string(),
266
284
  name: import_zod2.z.string(),
@@ -284,7 +302,10 @@ var productSummarySchema = import_zod2.z.object({
284
302
  // Whether this caller clears every requirement above, including the group membership the client
285
303
  // can't see for itself. False with none of them set means the merchant closed the release to everyone.
286
304
  downloadsAllowed: import_zod2.z.boolean(),
287
- downloads: import_zod2.z.array(downloadSchema).optional()
305
+ downloads: import_zod2.z.array(downloadSchema).optional(),
306
+ // Set only when the customer's licenses do not cover every release. `downloadsAllowed` already
307
+ // accounts for it; this says why a download is locked and where to upgrade.
308
+ releaseAccess: productReleaseAccessSchema.nullish().catch(void 0)
288
309
  });
289
310
  var productReleaseSchema = import_zod2.z.object({
290
311
  version: import_zod2.z.string(),
@@ -294,10 +315,33 @@ var productReleaseSchema = import_zod2.z.object({
294
315
  // merchant can keep past releases to owners while the current one is open to anyone.
295
316
  downloadsAllowed: import_zod2.z.boolean(),
296
317
  downloads: import_zod2.z.array(downloadSchema),
297
- properties: import_zod2.z.record(rawPropertyValueSchema).nullish()
318
+ properties: import_zod2.z.record(rawPropertyValueSchema).nullish(),
319
+ // True when the caller owns the product but none of their licenses covers this release, so it
320
+ // takes an upgrade rather than a sign-in to unlock. Absent otherwise.
321
+ releaseNotCovered: import_zod2.z.boolean().nullish().catch(void 0)
298
322
  });
299
323
 
300
324
  // src/storefront/schemas.ts
325
+ var storefrontLicenseUpgradeSchema = import_zod3.z.object({
326
+ // The customer's licenses this entry prices. An entry without them is no use and is left out.
327
+ licenseIds: import_zod3.z.string().array(),
328
+ // What those licenses cover now, which is how a cart tells the customer which of their licenses an
329
+ // upgrade is for. Read leniently, field by field: a backend that predates it leaves it out, and one
330
+ // this version cannot read reads as absent rather than costing the entry.
331
+ releaseAccess: import_zod3.z.object({
332
+ // Releases published until then are covered, and every version while it has not passed.
333
+ updatesUntil: import_zod3.z.coerce.date().nullish().catch(void 0),
334
+ // Every version whose major is at most this is covered.
335
+ upToMajor: import_zod3.z.number().nullish().catch(void 0),
336
+ // Once updates have ended, the last version published before they did.
337
+ upToVersion: import_zod3.z.string().nullish().catch(void 0)
338
+ }).nullish().catch(void 0),
339
+ variations: pricingVariationSchema.array()
340
+ });
341
+ var storefrontLicenseUpgradesSchema = import_zod3.z.array(import_zod3.z.unknown()).transform((upgrades) => upgrades.flatMap((upgrade) => {
342
+ const parsed = storefrontLicenseUpgradeSchema.safeParse(upgrade);
343
+ return parsed.success ? [parsed.data] : [];
344
+ }));
301
345
  var storefrontProductSchema = import_zod3.z.object({
302
346
  id: import_zod3.z.string(),
303
347
  name: import_zod3.z.string(),
@@ -311,7 +355,13 @@ var storefrontProductSchema = import_zod3.z.object({
311
355
  defaultVariation: pricingVariationSchema.optional(),
312
356
  variations: pricingVariationSchema.array().optional(),
313
357
  properties: import_zod3.z.record(rawPropertyValueSchema).nullish(),
314
- type: import_zod3.z.string().optional().default("Product").pipe(import_zod3.z.literal("Product"))
358
+ type: import_zod3.z.string().optional().default("Product").pipe(import_zod3.z.literal("Product")),
359
+ // What upgrading or renewing the signed-in customer's licenses of the product that cover only
360
+ // some releases costs, one entry per group of licenses that cover the same, furthest behind first.
361
+ // Capped, so a customer with a great many licenses may find one in none of them. Absent for anyone
362
+ // else, and from a backend that predates per-license prices. A cart line naming one of these
363
+ // licenses (`targetLicenseId`) is priced from here: see `CartUtils.licenseUpgrade`.
364
+ licenseUpgrades: storefrontLicenseUpgradesSchema.nullish().catch(void 0)
315
365
  });
316
366
  var storefrontBundleSchema = import_zod3.z.object({
317
367
  id: import_zod3.z.string(),
@@ -485,7 +535,17 @@ var activationRequestSchema = import_zod4.z.object({
485
535
  endless: import_zod4.z.boolean().default(false)
486
536
  }).optional(),
487
537
  licenseEligibility: import_zod4.z.object({
488
- eligible: import_zod4.z.boolean()
538
+ eligible: import_zod4.z.boolean(),
539
+ // Set when the customer's licenses would take the device but none of them covers the version
540
+ // the app runs (`eligible` is then false), so the app's version needs an upgrade. Absent from
541
+ // a backend that predates release access, and read leniently so it can never fail the request.
542
+ releaseNotCovered: import_zod4.z.object({
543
+ appVersion: import_zod4.z.string().nullish().catch(void 0),
544
+ updatesUntil: import_zod4.z.coerce.date().nullish().catch(void 0),
545
+ upToMajor: import_zod4.z.number().nullish().catch(void 0),
546
+ upToVersion: import_zod4.z.string().nullish().catch(void 0),
547
+ upgradeUrl: import_zod4.z.string().nullish().catch(void 0)
548
+ }).nullish().catch(void 0)
489
549
  }).optional()
490
550
  });
491
551
 
@@ -564,7 +624,8 @@ var CommunicationsEndpoints = class {
564
624
  newsletter: (_b = input.newsletter) != null ? _b : true,
565
625
  productUpdates: (_c = input.productUpdates) != null ? _c : true,
566
626
  groupIds: normalizeGroupIds(input.groupIds)
567
- }
627
+ },
628
+ headers: input.captchaToken ? { "X-MB-CAPTCHA": input.captchaToken } : void 0
568
629
  });
569
630
  return response.data;
570
631
  }
@@ -644,6 +705,15 @@ var NotAuthorizedError = class extends Error {
644
705
  this.message = "Not allowed";
645
706
  }
646
707
  };
708
+ var ReleaseNotCoveredError = class extends NotAuthorizedError {
709
+ constructor(releaseAccess, upgradeUrl, detail) {
710
+ super();
711
+ this.releaseAccess = releaseAccess;
712
+ this.upgradeUrl = upgradeUrl;
713
+ this.name = "ReleaseNotCoveredError";
714
+ this.message = detail != null ? detail : "Your license doesn't cover this version";
715
+ }
716
+ };
647
717
  var NotAuthenticatedError = class extends Error {
648
718
  constructor() {
649
719
  super();
@@ -693,6 +763,9 @@ var PasswordSetupRequiredError = class extends MoonbaseError {
693
763
  }
694
764
  };
695
765
 
766
+ // src/utils/problemHandler.ts
767
+ var import_zod8 = require("zod");
768
+
696
769
  // src/utils/problemDetails.ts
697
770
  var import_zod7 = require("zod");
698
771
  var problemDetailsSchema = import_zod7.z.object({
@@ -706,6 +779,28 @@ var problemDetailsSchema = import_zod7.z.object({
706
779
  });
707
780
 
708
781
  // src/utils/problemHandler.ts
782
+ var releaseNotCoveredProblemSchema = import_zod8.z.object({
783
+ errorType: import_zod8.z.literal("ReleaseNotCovered"),
784
+ detail: import_zod8.z.string().nullish().catch(void 0),
785
+ releaseAccess: productReleaseAccessSchema.nullish().catch(void 0),
786
+ upgradeUrl: import_zod8.z.string().nullish().catch(void 0)
787
+ });
788
+ async function forbiddenError(response) {
789
+ var _a;
790
+ try {
791
+ const problem = releaseNotCoveredProblemSchema.safeParse(JSON.parse(await response.text()));
792
+ if (problem.success) {
793
+ const { releaseAccess, upgradeUrl, detail } = problem.data;
794
+ return new ReleaseNotCoveredError(
795
+ releaseAccess != null ? releaseAccess : void 0,
796
+ (_a = upgradeUrl != null ? upgradeUrl : releaseAccess == null ? void 0 : releaseAccess.upgradeUrl) != null ? _a : void 0,
797
+ detail != null ? detail : void 0
798
+ );
799
+ }
800
+ } catch (e) {
801
+ }
802
+ return new NotAuthorizedError();
803
+ }
709
804
  function camelCase(str) {
710
805
  return str.split(".").map((word, index) => {
711
806
  let [firstLetter, ...restOfLetters] = word;
@@ -722,7 +817,7 @@ async function handleResponseProblem(response, logger) {
722
817
  throw new NotAuthenticatedError();
723
818
  }
724
819
  if (response.status === 403) {
725
- throw new NotAuthorizedError();
820
+ throw await forbiddenError(response);
726
821
  }
727
822
  let problemDetails;
728
823
  const body = await response.text();
@@ -762,7 +857,7 @@ __export(schemas_exports5, {
762
857
  userAccountConfirmedStatusSchema: () => userAccountConfirmedStatusSchema,
763
858
  userSchema: () => userSchema
764
859
  });
765
- var import_zod8 = require("zod");
860
+ var import_zod9 = require("zod");
766
861
 
767
862
  // src/identity/models.ts
768
863
  var ConnectableAccountProvider = /* @__PURE__ */ ((ConnectableAccountProvider2) => {
@@ -771,69 +866,69 @@ var ConnectableAccountProvider = /* @__PURE__ */ ((ConnectableAccountProvider2)
771
866
  })(ConnectableAccountProvider || {});
772
867
 
773
868
  // src/identity/schemas.ts
774
- var addressSchema = import_zod8.z.object({
775
- countryCode: import_zod8.z.string(),
776
- streetAddress1: import_zod8.z.string(),
777
- streetAddress2: import_zod8.z.string().nullable(),
778
- locality: import_zod8.z.string().nullable(),
779
- region: import_zod8.z.string().nullable(),
780
- postCode: import_zod8.z.string().nullable()
781
- });
782
- var communicationPreferencesSchema = import_zod8.z.object({
783
- newsletterOptIn: import_zod8.z.boolean(),
869
+ var addressSchema = import_zod9.z.object({
870
+ countryCode: import_zod9.z.string(),
871
+ streetAddress1: import_zod9.z.string(),
872
+ streetAddress2: import_zod9.z.string().nullable(),
873
+ locality: import_zod9.z.string().nullable(),
874
+ region: import_zod9.z.string().nullable(),
875
+ postCode: import_zod9.z.string().nullable()
876
+ });
877
+ var communicationPreferencesSchema = import_zod9.z.object({
878
+ newsletterOptIn: import_zod9.z.boolean(),
784
879
  // Default keeps older persisted identities (pre productUpdatesOptIn) parseable
785
880
  // during boot. The server-side value is hydrated by updateUser() right after.
786
- productUpdatesOptIn: import_zod8.z.boolean().default(false)
881
+ productUpdatesOptIn: import_zod9.z.boolean().default(false)
787
882
  });
788
- var ilokConnectedAccountSchema = import_zod8.z.object({
789
- provider: import_zod8.z.literal("iLok" /* iLok */),
790
- isConnected: import_zod8.z.boolean(),
791
- pendingLicenseFulfillments: import_zod8.z.boolean(),
792
- accountId: import_zod8.z.string().nullish()
883
+ var ilokConnectedAccountSchema = import_zod9.z.object({
884
+ provider: import_zod9.z.literal("iLok" /* iLok */),
885
+ isConnected: import_zod9.z.boolean(),
886
+ pendingLicenseFulfillments: import_zod9.z.boolean(),
887
+ accountId: import_zod9.z.string().nullish()
793
888
  });
794
- var connectedAccountSchema = import_zod8.z.discriminatedUnion("provider", [
889
+ var connectedAccountSchema = import_zod9.z.discriminatedUnion("provider", [
795
890
  ilokConnectedAccountSchema
796
891
  ]);
797
- var connectionUrlSchema = import_zod8.z.object({
798
- url: import_zod8.z.string()
892
+ var connectionUrlSchema = import_zod9.z.object({
893
+ url: import_zod9.z.string()
799
894
  });
800
- var userSchema = import_zod8.z.object({
801
- id: import_zod8.z.string(),
802
- email: import_zod8.z.string(),
895
+ var userSchema = import_zod9.z.object({
896
+ id: import_zod9.z.string(),
897
+ email: import_zod9.z.string(),
803
898
  // Nullable: customers created via import may have no name.
804
- name: import_zod8.z.string().nullable(),
805
- tenantId: import_zod8.z.string(),
899
+ name: import_zod9.z.string().nullable(),
900
+ tenantId: import_zod9.z.string(),
806
901
  address: addressSchema.optional(),
807
- phone: import_zod8.z.string().optional(),
902
+ phone: import_zod9.z.string().optional(),
808
903
  communicationPreferences: communicationPreferencesSchema,
809
- ownedProducts: import_zod8.z.string().array().optional(),
810
- subscribedProducts: import_zod8.z.string().array().optional(),
811
- confirmedAccount: import_zod8.z.boolean().optional(),
812
- hasProducts: import_zod8.z.boolean().nullish(),
813
- hasSubscriptions: import_zod8.z.boolean().nullish(),
814
- connectedAccounts: import_zod8.z.array(connectedAccountSchema).default([])
815
- });
816
- var identitySchema = userSchema.and(import_zod8.z.object({
817
- accessToken: import_zod8.z.string(),
818
- refreshToken: import_zod8.z.string()
904
+ ownedProducts: import_zod9.z.string().array().optional(),
905
+ subscribedProducts: import_zod9.z.string().array().optional(),
906
+ confirmedAccount: import_zod9.z.boolean().optional(),
907
+ hasProducts: import_zod9.z.boolean().nullish(),
908
+ hasSubscriptions: import_zod9.z.boolean().nullish(),
909
+ connectedAccounts: import_zod9.z.array(connectedAccountSchema).default([])
910
+ });
911
+ var identitySchema = userSchema.and(import_zod9.z.object({
912
+ accessToken: import_zod9.z.string(),
913
+ refreshToken: import_zod9.z.string()
819
914
  }));
820
- var userAccountConfirmedStatusSchema = import_zod8.z.enum([
915
+ var userAccountConfirmedStatusSchema = import_zod9.z.enum([
821
916
  "PasswordSetupRequired",
822
917
  "SignedIn"
823
918
  ]);
824
- var userAccountConfirmedSchema = userSchema.and(import_zod8.z.object({
919
+ var userAccountConfirmedSchema = userSchema.and(import_zod9.z.object({
825
920
  status: userAccountConfirmedStatusSchema,
826
- resetPasswordToken: import_zod8.z.string().nullish(),
827
- accessToken: import_zod8.z.string().nullish(),
828
- refreshToken: import_zod8.z.string().nullish()
921
+ resetPasswordToken: import_zod9.z.string().nullish(),
922
+ accessToken: import_zod9.z.string().nullish(),
923
+ refreshToken: import_zod9.z.string().nullish()
829
924
  }));
830
- var pendingActivationSchema = import_zod8.z.object({
831
- status: import_zod8.z.literal("activation_pending"),
832
- email: import_zod8.z.string()
925
+ var pendingActivationSchema = import_zod9.z.object({
926
+ status: import_zod9.z.literal("activation_pending"),
927
+ email: import_zod9.z.string()
833
928
  });
834
- var pendingPasswordProblemSchema = import_zod8.z.object({
835
- errorType: import_zod8.z.literal("PasswordSetupRequired"),
836
- pendingPasswordToken: import_zod8.z.string()
929
+ var pendingPasswordProblemSchema = import_zod9.z.object({
930
+ errorType: import_zod9.z.literal("PasswordSetupRequired"),
931
+ pendingPasswordToken: import_zod9.z.string()
837
932
  });
838
933
 
839
934
  // src/identity/endpoints.ts
@@ -1029,16 +1124,17 @@ var IdentityEndpoints = class {
1029
1124
  };
1030
1125
 
1031
1126
  // src/inventory/activation/endpoints.ts
1032
- var import_zod10 = require("zod");
1127
+ var import_zod11 = require("zod");
1033
1128
 
1034
1129
  // src/inventory/licenses/schemas.ts
1035
1130
  var schemas_exports6 = {};
1036
1131
  __export(schemas_exports6, {
1037
1132
  activationSchema: () => activationSchema,
1038
1133
  externalLicenseContent: () => externalLicenseContent,
1134
+ licenseReleaseAccessSchema: () => licenseReleaseAccessSchema,
1039
1135
  licenseSchema: () => licenseSchema
1040
1136
  });
1041
- var import_zod9 = require("zod");
1137
+ var import_zod10 = require("zod");
1042
1138
 
1043
1139
  // src/inventory/licenses/models.ts
1044
1140
  var LicenseStatus = /* @__PURE__ */ ((LicenseStatus2) => {
@@ -1059,43 +1155,57 @@ var ActivationMethod = /* @__PURE__ */ ((ActivationMethod2) => {
1059
1155
  })(ActivationMethod || {});
1060
1156
 
1061
1157
  // src/inventory/licenses/schemas.ts
1062
- var externalLicenseFileContent = import_zod9.z.object({
1063
- type: import_zod9.z.literal("file"),
1064
- fileName: import_zod9.z.string(),
1065
- contentType: import_zod9.z.string(),
1066
- data: import_zod9.z.string()
1067
- });
1068
- var externalLicenseILokContent = import_zod9.z.object({
1069
- type: import_zod9.z.literal("iLok")
1070
- });
1071
- var externalLicenseContent = import_zod9.z.union([
1072
- import_zod9.z.string(),
1073
- import_zod9.z.discriminatedUnion("type", [
1158
+ var externalLicenseFileContent = import_zod10.z.object({
1159
+ type: import_zod10.z.literal("file"),
1160
+ fileName: import_zod10.z.string(),
1161
+ contentType: import_zod10.z.string(),
1162
+ data: import_zod10.z.string()
1163
+ });
1164
+ var externalLicenseILokContent = import_zod10.z.object({
1165
+ type: import_zod10.z.literal("iLok")
1166
+ });
1167
+ var externalLicenseContent = import_zod10.z.union([
1168
+ import_zod10.z.string(),
1169
+ import_zod10.z.discriminatedUnion("type", [
1074
1170
  externalLicenseFileContent,
1075
1171
  externalLicenseILokContent
1076
1172
  ])
1077
1173
  ]);
1078
- var licenseSchema = import_zod9.z.object({
1079
- id: import_zod9.z.string(),
1080
- status: import_zod9.z.nativeEnum(LicenseStatus),
1174
+ var licenseReleaseAccessSchema = import_zod10.z.object({
1175
+ // Releases published until then are covered, and every version while it has not passed.
1176
+ updatesUntil: import_zod10.z.coerce.date().nullish().catch(void 0),
1177
+ // Every version whose major is at most this is covered.
1178
+ upToMajor: import_zod10.z.number().nullish().catch(void 0),
1179
+ // Once updates have ended, the last version published before they did.
1180
+ upToVersion: import_zod10.z.string().nullish().catch(void 0),
1181
+ // Whether the product's current release is covered, so whether to offer an upgrade. Read as
1182
+ // covered when unreadable, so a garbled answer never pushes an upgrade nobody needs.
1183
+ coversCurrentRelease: import_zod10.z.boolean().catch(true),
1184
+ // Where to buy the upgrade or renewal for this license, while the product sells one.
1185
+ upgradeUrl: import_zod10.z.string().nullish().catch(void 0)
1186
+ });
1187
+ var licenseSchema = import_zod10.z.object({
1188
+ id: import_zod10.z.string(),
1189
+ status: import_zod10.z.nativeEnum(LicenseStatus),
1081
1190
  product: productSummarySchema,
1082
- activeNumberOfActivations: import_zod9.z.number(),
1083
- maxNumberOfActivations: import_zod9.z.number(),
1191
+ activeNumberOfActivations: import_zod10.z.number(),
1192
+ maxNumberOfActivations: import_zod10.z.number(),
1084
1193
  externalFulfillment: externalLicenseContent.optional(),
1085
- requiredConnectedAccount: import_zod9.z.nativeEnum(ConnectableAccountProvider).nullish(),
1086
- fulfillmentMessage: import_zod9.z.string().optional(),
1087
- properties: import_zod9.z.record(rawPropertyValueSchema).nullish(),
1088
- expiresAt: import_zod9.z.coerce.date().optional(),
1089
- createdAt: import_zod9.z.coerce.date()
1090
- });
1091
- var activationSchema = import_zod9.z.object({
1092
- id: import_zod9.z.string(),
1093
- licenseId: import_zod9.z.string(),
1094
- name: import_zod9.z.string(),
1095
- status: import_zod9.z.nativeEnum(ActivationStatus),
1096
- activationMethod: import_zod9.z.nativeEnum(ActivationMethod),
1097
- firstValidatedAt: import_zod9.z.coerce.date(),
1098
- lastValidatedAt: import_zod9.z.coerce.date().nullable()
1194
+ requiredConnectedAccount: import_zod10.z.nativeEnum(ConnectableAccountProvider).nullish(),
1195
+ fulfillmentMessage: import_zod10.z.string().optional(),
1196
+ properties: import_zod10.z.record(rawPropertyValueSchema).nullish(),
1197
+ expiresAt: import_zod10.z.coerce.date().optional(),
1198
+ createdAt: import_zod10.z.coerce.date(),
1199
+ releaseAccess: licenseReleaseAccessSchema.nullish().catch(void 0)
1200
+ });
1201
+ var activationSchema = import_zod10.z.object({
1202
+ id: import_zod10.z.string(),
1203
+ licenseId: import_zod10.z.string(),
1204
+ name: import_zod10.z.string(),
1205
+ status: import_zod10.z.nativeEnum(ActivationStatus),
1206
+ activationMethod: import_zod10.z.nativeEnum(ActivationMethod),
1207
+ firstValidatedAt: import_zod10.z.coerce.date(),
1208
+ lastValidatedAt: import_zod10.z.coerce.date().nullable()
1099
1209
  });
1100
1210
 
1101
1211
  // src/inventory/activation/endpoints.ts
@@ -1112,7 +1222,7 @@ var ActivationEndpoints = class {
1112
1222
  });
1113
1223
  return {
1114
1224
  license: response.data,
1115
- url: import_zod10.z.string().parse(response.headers.location)
1225
+ url: import_zod11.z.string().parse(response.headers.location)
1116
1226
  };
1117
1227
  }
1118
1228
  };
@@ -1140,7 +1250,7 @@ var LicenseEndpoints = class {
1140
1250
  };
1141
1251
 
1142
1252
  // src/inventory/products/endpoints.ts
1143
- var import_zod11 = require("zod");
1253
+ var import_zod12 = require("zod");
1144
1254
  var ProductEndpoints = class {
1145
1255
  constructor(api, configuration) {
1146
1256
  this.api = api;
@@ -1174,18 +1284,18 @@ var ProductEndpoints = class {
1174
1284
  async getDownloadUrl(path) {
1175
1285
  const url = new URL(path);
1176
1286
  url.searchParams.append("redirect", "false");
1177
- const response = await this.api.fetch(url.pathname + url.search, import_zod11.z.object({
1178
- location: import_zod11.z.string()
1287
+ const response = await this.api.fetch(url.pathname + url.search, import_zod12.z.object({
1288
+ location: import_zod12.z.string()
1179
1289
  }));
1180
1290
  return response.data.location;
1181
1291
  }
1182
1292
  };
1183
1293
 
1184
1294
  // src/inventory/subscriptions/endpoints.ts
1185
- var import_zod14 = require("zod");
1295
+ var import_zod15 = require("zod");
1186
1296
 
1187
1297
  // package.json
1188
- var version = "3.9.0";
1298
+ var version = "3.11.0";
1189
1299
 
1190
1300
  // src/utils/client.ts
1191
1301
  function buildClientHeader(sdk) {
@@ -1232,7 +1342,8 @@ var MoonbaseApi = class {
1232
1342
  ...accessToken ? { Authorization: `Bearer ${accessToken}` } : {},
1233
1343
  // Force CORS on all calls
1234
1344
  "x-mb-cors": "1",
1235
- "x-mb-client": this.clientHeader
1345
+ "x-mb-client": this.clientHeader,
1346
+ ...options == null ? void 0 : options.headers
1236
1347
  },
1237
1348
  body: (options == null ? void 0 : options.body) ? contentType !== "application/json" ? options.body : JSON.stringify(options.body) : void 0,
1238
1349
  signal: options == null ? void 0 : options.abort,
@@ -1340,9 +1451,13 @@ var MoonbaseApi = class {
1340
1451
  var schemas_exports8 = {};
1341
1452
  __export(schemas_exports8, {
1342
1453
  milestoneProgressSchema: () => milestoneProgressSchema,
1454
+ pendingPlanChangeSchema: () => pendingPlanChangeSchema,
1455
+ pricingOptionSchema: () => pricingOptionSchema,
1456
+ subscriptionPlanOptionSchema: () => subscriptionPlanOptionSchema,
1457
+ subscriptionPlanOptionsSchema: () => subscriptionPlanOptionsSchema,
1343
1458
  subscriptionSchema: () => subscriptionSchema
1344
1459
  });
1345
- var import_zod13 = require("zod");
1460
+ var import_zod14 = require("zod");
1346
1461
 
1347
1462
  // src/orders/schemas.ts
1348
1463
  var schemas_exports7 = {};
@@ -1356,7 +1471,7 @@ __export(schemas_exports7, {
1356
1471
  orderSchema: () => orderSchema,
1357
1472
  orderTotalSchema: () => orderTotalSchema
1358
1473
  });
1359
- var import_zod12 = require("zod");
1474
+ var import_zod13 = require("zod");
1360
1475
 
1361
1476
  // src/orders/models.ts
1362
1477
  var OrderStatus = /* @__PURE__ */ ((OrderStatus2) => {
@@ -1369,18 +1484,18 @@ var OrderStatus = /* @__PURE__ */ ((OrderStatus2) => {
1369
1484
  })(OrderStatus || {});
1370
1485
 
1371
1486
  // src/orders/schemas.ts
1372
- var couponSchema = import_zod12.z.object({
1373
- code: import_zod12.z.string(),
1374
- name: import_zod12.z.string(),
1375
- description: import_zod12.z.string()
1376
- });
1377
- var lineItemProductSchema = import_zod12.z.object({
1378
- id: import_zod12.z.string(),
1379
- name: import_zod12.z.string(),
1380
- tagline: import_zod12.z.string().nullish(),
1381
- iconUrl: import_zod12.z.string().nullable()
1382
- });
1383
- var lineItemTotalSchema = import_zod12.z.object({
1487
+ var couponSchema = import_zod13.z.object({
1488
+ code: import_zod13.z.string(),
1489
+ name: import_zod13.z.string(),
1490
+ description: import_zod13.z.string()
1491
+ });
1492
+ var lineItemProductSchema = import_zod13.z.object({
1493
+ id: import_zod13.z.string(),
1494
+ name: import_zod13.z.string(),
1495
+ tagline: import_zod13.z.string().nullish(),
1496
+ iconUrl: import_zod13.z.string().nullable()
1497
+ });
1498
+ var lineItemTotalSchema = import_zod13.z.object({
1384
1499
  original: moneySchema,
1385
1500
  discount: moneySchema,
1386
1501
  subtotal: moneySchema,
@@ -1389,52 +1504,59 @@ var lineItemTotalSchema = import_zod12.z.object({
1389
1504
  // for this item. Both are part of `discount`. Absent on orders priced before cart offers existed.
1390
1505
  cartOfferDiscount: moneySchema.optional()
1391
1506
  });
1392
- var openProductLineItem = import_zod12.z.object({
1393
- id: import_zod12.z.string(),
1394
- type: import_zod12.z.literal("Product"),
1395
- productId: import_zod12.z.string(),
1396
- quantity: import_zod12.z.number(),
1397
- variationId: import_zod12.z.string(),
1398
- offerId: import_zod12.z.string().optional(),
1399
- isDefaultVariation: import_zod12.z.boolean().nullish(),
1400
- isSubcriptionPayment: import_zod12.z.boolean().nullish(),
1507
+ var openProductLineItem = import_zod13.z.object({
1508
+ id: import_zod13.z.string(),
1509
+ type: import_zod13.z.literal("Product"),
1510
+ productId: import_zod13.z.string(),
1511
+ quantity: import_zod13.z.number(),
1512
+ variationId: import_zod13.z.string(),
1513
+ offerId: import_zod13.z.string().optional(),
1514
+ isDefaultVariation: import_zod13.z.boolean().nullish(),
1515
+ isSubcriptionPayment: import_zod13.z.boolean().nullish(),
1401
1516
  price: priceCollectionSchema.optional(),
1402
1517
  variation: pricingVariationSchema.optional(),
1403
1518
  total: lineItemTotalSchema.nullish(),
1404
1519
  product: lineItemProductSchema.optional(),
1405
- appliedDiscount: discountSchema.optional()
1406
- });
1407
- var lineItemBundleSchema = import_zod12.z.object({
1408
- id: import_zod12.z.string(),
1409
- name: import_zod12.z.string(),
1410
- tagline: import_zod12.z.string().nullish(),
1411
- iconUrl: import_zod12.z.string().nullable(),
1412
- products: lineItemProductSchema.and(import_zod12.z.object({
1413
- included: import_zod12.z.boolean().optional()
1520
+ appliedDiscount: discountSchema.optional(),
1521
+ // The customer's license this line upgrades or renews, as the cart named it. Such a line is one
1522
+ // license, so its quantity is always 1, and the line's `id` names the license too
1523
+ // (`p/<productId>/<variationId>/<licenseId>`): upgrading two licenses takes two lines. A line
1524
+ // without one issues new licenses. Part of the cart payload like `offerId`, so a push that leaves
1525
+ // it out forgets it. Echoed on completed orders too. Absent from a backend that predates release
1526
+ // access.
1527
+ targetLicenseId: import_zod13.z.string().nullish().catch(void 0)
1528
+ });
1529
+ var lineItemBundleSchema = import_zod13.z.object({
1530
+ id: import_zod13.z.string(),
1531
+ name: import_zod13.z.string(),
1532
+ tagline: import_zod13.z.string().nullish(),
1533
+ iconUrl: import_zod13.z.string().nullable(),
1534
+ products: lineItemProductSchema.and(import_zod13.z.object({
1535
+ included: import_zod13.z.boolean().optional()
1414
1536
  })).array()
1415
1537
  });
1416
- var openBundleLineItem = import_zod12.z.object({
1417
- id: import_zod12.z.string(),
1418
- type: import_zod12.z.literal("Bundle"),
1419
- bundleId: import_zod12.z.string(),
1420
- quantity: import_zod12.z.number(),
1421
- variationId: import_zod12.z.string(),
1422
- offerId: import_zod12.z.string().optional(),
1423
- partial: import_zod12.z.boolean().optional(),
1424
- replaced: import_zod12.z.string().array().optional(),
1425
- isDefaultVariation: import_zod12.z.boolean().nullish(),
1426
- isSubcriptionPayment: import_zod12.z.boolean().nullish(),
1538
+ var openBundleLineItem = import_zod13.z.object({
1539
+ id: import_zod13.z.string(),
1540
+ type: import_zod13.z.literal("Bundle"),
1541
+ bundleId: import_zod13.z.string(),
1542
+ quantity: import_zod13.z.number(),
1543
+ variationId: import_zod13.z.string(),
1544
+ offerId: import_zod13.z.string().optional(),
1545
+ partial: import_zod13.z.boolean().optional(),
1546
+ replaced: import_zod13.z.string().array().optional(),
1547
+ isDefaultVariation: import_zod13.z.boolean().nullish(),
1548
+ isSubcriptionPayment: import_zod13.z.boolean().nullish(),
1427
1549
  price: priceCollectionSchema.optional(),
1428
1550
  variation: pricingVariationSchema.optional(),
1429
1551
  total: lineItemTotalSchema.nullish(),
1430
1552
  bundle: lineItemBundleSchema.optional(),
1431
1553
  appliedDiscount: discountSchema.optional()
1432
1554
  });
1433
- var openOrderLineItem = import_zod12.z.discriminatedUnion("type", [
1555
+ var openOrderLineItem = import_zod13.z.discriminatedUnion("type", [
1434
1556
  openProductLineItem,
1435
1557
  openBundleLineItem
1436
1558
  ]);
1437
- var orderTotalSchema = import_zod12.z.object({
1559
+ var orderTotalSchema = import_zod13.z.object({
1438
1560
  original: moneySchema,
1439
1561
  discount: moneySchema,
1440
1562
  subtotal: moneySchema,
@@ -1444,52 +1566,52 @@ var orderTotalSchema = import_zod12.z.object({
1444
1566
  // rather than a share on every line. Absent when no cart offer applied.
1445
1567
  cartOfferDiscount: moneySchema.optional()
1446
1568
  });
1447
- var openOrderSchema = import_zod12.z.object({
1448
- id: import_zod12.z.string(),
1449
- currency: import_zod12.z.string(),
1569
+ var openOrderSchema = import_zod13.z.object({
1570
+ id: import_zod13.z.string(),
1571
+ currency: import_zod13.z.string(),
1450
1572
  total: orderTotalSchema.nullish(),
1451
1573
  items: openOrderLineItem.array(),
1452
1574
  couponsApplied: couponSchema.array(),
1453
1575
  // The cart offer on the order as a whole: the buyer's intent. It is part of the cart payload, so
1454
1576
  // a content push that leaves it out clears it. The API echoes it back even while the cart sits
1455
1577
  // below the offer's threshold.
1456
- offerId: import_zod12.z.string().optional(),
1578
+ offerId: import_zod13.z.string().optional(),
1457
1579
  // The cart offer as actually applied: the result. Absent while the offer's condition doesn't hold.
1458
1580
  appliedOffer: discountSchema.optional(),
1459
- checkoutUrl: import_zod12.z.string().optional(),
1460
- hostedCheckoutUrl: import_zod12.z.string().optional(),
1461
- embeddedCheckoutUrl: import_zod12.z.string().optional()
1462
- });
1463
- var customerSnapshotSchema = import_zod12.z.object({
1464
- name: import_zod12.z.string().nullable(),
1465
- businessName: import_zod12.z.string().nullable(),
1466
- taxId: import_zod12.z.string().nullable(),
1467
- email: import_zod12.z.string().nullable(),
1468
- phone: import_zod12.z.string().nullable(),
1581
+ checkoutUrl: import_zod13.z.string().optional(),
1582
+ hostedCheckoutUrl: import_zod13.z.string().optional(),
1583
+ embeddedCheckoutUrl: import_zod13.z.string().optional()
1584
+ });
1585
+ var customerSnapshotSchema = import_zod13.z.object({
1586
+ name: import_zod13.z.string().nullable(),
1587
+ businessName: import_zod13.z.string().nullable(),
1588
+ taxId: import_zod13.z.string().nullable(),
1589
+ email: import_zod13.z.string().nullable(),
1590
+ phone: import_zod13.z.string().nullable(),
1469
1591
  address: addressSchema.nullable()
1470
1592
  });
1471
- var completedOrderSchema = import_zod12.z.object({
1472
- id: import_zod12.z.string(),
1473
- status: import_zod12.z.literal("Completed" /* Completed */),
1474
- currency: import_zod12.z.string(),
1593
+ var completedOrderSchema = import_zod13.z.object({
1594
+ id: import_zod13.z.string(),
1595
+ status: import_zod13.z.literal("Completed" /* Completed */),
1596
+ currency: import_zod13.z.string(),
1475
1597
  customer: customerSnapshotSchema,
1476
1598
  total: orderTotalSchema,
1477
1599
  items: openOrderLineItem.array(),
1478
1600
  couponsApplied: couponSchema.array(),
1479
1601
  appliedOffer: discountSchema.optional()
1480
1602
  });
1481
- var orderSchema = import_zod12.z.discriminatedUnion("status", [
1603
+ var orderSchema = import_zod13.z.discriminatedUnion("status", [
1482
1604
  openOrderSchema.extend({
1483
- status: import_zod12.z.literal("Open" /* Open */)
1605
+ status: import_zod13.z.literal("Open" /* Open */)
1484
1606
  }),
1485
1607
  openOrderSchema.extend({
1486
- status: import_zod12.z.literal("PaymentProcessing" /* PaymentProcessing */)
1608
+ status: import_zod13.z.literal("PaymentProcessing" /* PaymentProcessing */)
1487
1609
  }),
1488
1610
  openOrderSchema.extend({
1489
- status: import_zod12.z.literal("Paid" /* Paid */)
1611
+ status: import_zod13.z.literal("Paid" /* Paid */)
1490
1612
  }),
1491
1613
  openOrderSchema.extend({
1492
- status: import_zod12.z.literal("Failed" /* Failed */)
1614
+ status: import_zod13.z.literal("Failed" /* Failed */)
1493
1615
  }),
1494
1616
  completedOrderSchema
1495
1617
  ]);
@@ -1513,58 +1635,89 @@ var SubscriptionCancellationReason = /* @__PURE__ */ ((SubscriptionCancellationR
1513
1635
  })(SubscriptionCancellationReason || {});
1514
1636
 
1515
1637
  // src/inventory/subscriptions/schemas.ts
1516
- var baseMilestoneProgressEventSchema = import_zod13.z.object({
1517
- milestoneId: import_zod13.z.string(),
1518
- fulfilled: import_zod13.z.boolean(),
1519
- afterCycleNumber: import_zod13.z.number(),
1520
- afterNormalizedCycleNumber: import_zod13.z.number(),
1521
- message: import_zod13.z.string().optional()
1522
- });
1523
- var milestoneProgressEventSchema = import_zod13.z.discriminatedUnion("type", [
1638
+ var baseMilestoneProgressEventSchema = import_zod14.z.object({
1639
+ milestoneId: import_zod14.z.string(),
1640
+ fulfilled: import_zod14.z.boolean(),
1641
+ afterCycleNumber: import_zod14.z.number(),
1642
+ afterNormalizedCycleNumber: import_zod14.z.number(),
1643
+ message: import_zod14.z.string().optional()
1644
+ });
1645
+ var milestoneProgressEventSchema = import_zod14.z.discriminatedUnion("type", [
1524
1646
  baseMilestoneProgressEventSchema.extend({
1525
- type: import_zod13.z.literal("CouponCodeMilestone"),
1526
- code: import_zod13.z.string().optional(),
1527
- redeemed: import_zod13.z.boolean().optional()
1647
+ type: import_zod14.z.literal("CouponCodeMilestone"),
1648
+ code: import_zod14.z.string().optional(),
1649
+ redeemed: import_zod14.z.boolean().optional()
1528
1650
  }),
1529
1651
  baseMilestoneProgressEventSchema.extend({
1530
- type: import_zod13.z.literal("PerpetualLicenseConversionMilestone")
1652
+ type: import_zod14.z.literal("PerpetualLicenseConversionMilestone")
1531
1653
  })
1532
1654
  ]);
1533
- var milestoneProgressSchema = import_zod13.z.object({
1534
- title: import_zod13.z.string(),
1535
- description: import_zod13.z.string().nullish(),
1536
- currentCycleNumber: import_zod13.z.number(),
1537
- currentNormalizedCycleNumber: import_zod13.z.number(),
1538
- currentCycleIsCompleted: import_zod13.z.boolean(),
1539
- fromCycleNumber: import_zod13.z.number(),
1540
- fromNormalizedCycleNumber: import_zod13.z.number(),
1541
- toCycleNumber: import_zod13.z.number(),
1542
- toNormalizedCycleNumber: import_zod13.z.number(),
1543
- events: import_zod13.z.record(import_zod13.z.coerce.number(), milestoneProgressEventSchema.array())
1544
- });
1545
- var subscriptionSchema = import_zod13.z.object({
1546
- id: import_zod13.z.string(),
1547
- status: import_zod13.z.nativeEnum(SubscriptionStatus),
1548
- hasPaymentMethod: import_zod13.z.boolean(),
1549
- cancellable: import_zod13.z.boolean(),
1550
- expiresAt: import_zod13.z.coerce.date(),
1551
- renewedAt: import_zod13.z.coerce.date().nullable(),
1552
- nextPaymentScheduledAt: import_zod13.z.coerce.date().nullable(),
1553
- startedAt: import_zod13.z.coerce.date(),
1655
+ var milestoneProgressSchema = import_zod14.z.object({
1656
+ title: import_zod14.z.string(),
1657
+ description: import_zod14.z.string().nullish(),
1658
+ currentCycleNumber: import_zod14.z.number(),
1659
+ currentNormalizedCycleNumber: import_zod14.z.number(),
1660
+ currentCycleIsCompleted: import_zod14.z.boolean(),
1661
+ fromCycleNumber: import_zod14.z.number(),
1662
+ fromNormalizedCycleNumber: import_zod14.z.number(),
1663
+ toCycleNumber: import_zod14.z.number(),
1664
+ toNormalizedCycleNumber: import_zod14.z.number(),
1665
+ events: import_zod14.z.record(import_zod14.z.coerce.number(), milestoneProgressEventSchema.array())
1666
+ });
1667
+ var pricingOptionSchema = import_zod14.z.object({
1668
+ id: import_zod14.z.string(),
1669
+ name: import_zod14.z.string(),
1670
+ cycleLength: import_zod14.z.nativeEnum(CycleLength)
1671
+ });
1672
+ var pendingPlanChangeSchema = import_zod14.z.object({
1673
+ option: pricingOptionSchema,
1674
+ // The renewal that starts the new plan and charges `nextTotal`.
1675
+ takesEffectAt: import_zod14.z.coerce.date(),
1676
+ nextTotal: orderTotalSchema,
1677
+ // Whether everything the subscription gets off now (discount, offer, coupons) still applies on the new plan.
1678
+ keepsDiscount: import_zod14.z.boolean(),
1679
+ scheduledAt: import_zod14.z.coerce.date()
1680
+ });
1681
+ var subscriptionPlanOptionSchema = import_zod14.z.object({
1682
+ option: pricingOptionSchema,
1683
+ // What the next renewal charges on this plan. For the plan it is on, its normal renewal.
1684
+ nextTotal: orderTotalSchema,
1685
+ takesEffectAt: import_zod14.z.coerce.date(),
1686
+ keepsDiscount: import_zod14.z.boolean(),
1687
+ current: import_zod14.z.boolean(),
1688
+ scheduled: import_zod14.z.boolean()
1689
+ });
1690
+ var subscriptionPlanOptionsSchema = import_zod14.z.object({
1691
+ unavailable: import_zod14.z.string().nullish(),
1692
+ plans: subscriptionPlanOptionSchema.array()
1693
+ });
1694
+ var subscriptionSchema = import_zod14.z.object({
1695
+ id: import_zod14.z.string(),
1696
+ status: import_zod14.z.nativeEnum(SubscriptionStatus),
1697
+ hasPaymentMethod: import_zod14.z.boolean(),
1698
+ cancellable: import_zod14.z.boolean(),
1699
+ expiresAt: import_zod14.z.coerce.date(),
1700
+ renewedAt: import_zod14.z.coerce.date().nullable(),
1701
+ nextPaymentScheduledAt: import_zod14.z.coerce.date().nullable(),
1702
+ startedAt: import_zod14.z.coerce.date(),
1554
1703
  total: orderTotalSchema,
1555
- cycleLength: import_zod13.z.nativeEnum(CycleLength),
1556
- paymentMethod: import_zod13.z.string().optional(),
1704
+ cycleLength: import_zod14.z.nativeEnum(CycleLength),
1705
+ paymentMethod: import_zod14.z.string().optional(),
1557
1706
  milestoneProgress: milestoneProgressSchema.nullish(),
1558
- embeddedUpdatePaymentUrl: import_zod13.z.string().optional(),
1559
- content: import_zod13.z.discriminatedUnion("type", [
1560
- import_zod13.z.object({
1561
- type: import_zod13.z.literal("Product"),
1562
- quantity: import_zod13.z.number(),
1707
+ embeddedUpdatePaymentUrl: import_zod14.z.string().optional(),
1708
+ // Older backends send neither, and one this version can't read is dropped rather than failing
1709
+ // the whole subscription.
1710
+ pricingOption: pricingOptionSchema.nullish().catch(void 0),
1711
+ pendingChange: pendingPlanChangeSchema.nullish().catch(void 0),
1712
+ content: import_zod14.z.discriminatedUnion("type", [
1713
+ import_zod14.z.object({
1714
+ type: import_zod14.z.literal("Product"),
1715
+ quantity: import_zod14.z.number(),
1563
1716
  product: storefrontProductSchema
1564
1717
  }),
1565
- import_zod13.z.object({
1566
- type: import_zod13.z.literal("Bundle"),
1567
- quantity: import_zod13.z.number(),
1718
+ import_zod14.z.object({
1719
+ type: import_zod14.z.literal("Bundle"),
1720
+ quantity: import_zod14.z.number(),
1568
1721
  bundle: storefrontBundleSchema
1569
1722
  })
1570
1723
  ])
@@ -1599,9 +1752,41 @@ var SubscriptionEndpoints = class {
1599
1752
  });
1600
1753
  return response.data;
1601
1754
  }
1755
+ /**
1756
+ * The plans the subscription can switch to when its current period ends, each with what the
1757
+ * next renewal would charge on it. The plan it is on comes first. When it can't switch,
1758
+ * `unavailable` says why, ready to show to the customer.
1759
+ */
1760
+ async getPlanOptions(subscriptionId) {
1761
+ const response = await this.api.authenticatedFetch(`/api/customer/inventory/subscriptions/${subscriptionId}/plan-options`, subscriptionPlanOptionsSchema);
1762
+ return response.data;
1763
+ }
1764
+ /**
1765
+ * Switches the subscription to another plan when its current period ends. Nothing is charged
1766
+ * now: the next renewal charges the new plan and starts its cycle. Until then the customer can
1767
+ * switch again, and passing the plan it is on keeps that plan. Returns the updated subscription,
1768
+ * with the switch in `pendingChange`.
1769
+ */
1770
+ async changePlan(subscriptionId, variationId) {
1771
+ const response = await this.api.authenticatedFetch(`/api/customer/inventory/subscriptions/${subscriptionId}/plan-change`, subscriptionSchema, {
1772
+ method: "POST",
1773
+ body: { variationId }
1774
+ });
1775
+ return response.data;
1776
+ }
1777
+ /**
1778
+ * Keeps the subscription on its current plan, dropping a switch scheduled with `changePlan`.
1779
+ * Returns the updated subscription.
1780
+ */
1781
+ async cancelPlanChange(subscriptionId) {
1782
+ const response = await this.api.authenticatedFetch(`/api/customer/inventory/subscriptions/${subscriptionId}/plan-change`, subscriptionSchema, {
1783
+ method: "DELETE"
1784
+ });
1785
+ return response.data;
1786
+ }
1602
1787
  async renew(subscriptionId, returnUrl, embedded) {
1603
- const response = await this.api.authenticatedFetch(`/api/customer/inventory/subscriptions/${subscriptionId}/renew?redirect=false&return=${returnUrl}&embedded=${embedded ? "true" : "false"}`, import_zod14.z.object({
1604
- location: import_zod14.z.string()
1788
+ const response = await this.api.authenticatedFetch(`/api/customer/inventory/subscriptions/${subscriptionId}/renew?redirect=false&return=${returnUrl}&embedded=${embedded ? "true" : "false"}`, import_zod15.z.object({
1789
+ location: import_zod15.z.string()
1605
1790
  }), { method: "POST" });
1606
1791
  return response.data;
1607
1792
  }
@@ -2170,21 +2355,21 @@ __export(schemas_exports9, {
2170
2355
  vendorFeaturesSchema: () => vendorFeaturesSchema,
2171
2356
  vendorSchema: () => vendorSchema
2172
2357
  });
2173
- var import_zod15 = require("zod");
2174
- var vendorCaptchaSchema = import_zod15.z.object({
2175
- url: import_zod15.z.string()
2358
+ var import_zod16 = require("zod");
2359
+ var vendorCaptchaSchema = import_zod16.z.object({
2360
+ url: import_zod16.z.string()
2176
2361
  });
2177
- var vendorFeaturesSchema = import_zod15.z.object({
2178
- customerPortal: import_zod15.z.boolean().optional(),
2179
- phoneNumber: import_zod15.z.boolean().optional(),
2180
- marketingConsent: import_zod15.z.nativeEnum(MarketingConsentType).optional().catch(void 0),
2362
+ var vendorFeaturesSchema = import_zod16.z.object({
2363
+ customerPortal: import_zod16.z.boolean().optional(),
2364
+ phoneNumber: import_zod16.z.boolean().optional(),
2365
+ marketingConsent: import_zod16.z.nativeEnum(MarketingConsentType).optional().catch(void 0),
2181
2366
  // Absent on backends from before captchas, which never ask for one.
2182
2367
  captcha: vendorCaptchaSchema.nullish()
2183
2368
  });
2184
- var vendorSchema = import_zod15.z.object({
2185
- id: import_zod15.z.string(),
2186
- name: import_zod15.z.string(),
2187
- logoUrl: import_zod15.z.string().nullable(),
2369
+ var vendorSchema = import_zod16.z.object({
2370
+ id: import_zod16.z.string(),
2371
+ name: import_zod16.z.string(),
2372
+ logoUrl: import_zod16.z.string().nullable(),
2188
2373
  features: vendorFeaturesSchema.optional()
2189
2374
  });
2190
2375
 
@@ -2204,16 +2389,16 @@ var schemas_exports10 = {};
2204
2389
  __export(schemas_exports10, {
2205
2390
  voucherSchema: () => voucherSchema
2206
2391
  });
2207
- var import_zod16 = require("zod");
2208
- var voucherSchema = import_zod16.z.object({
2209
- id: import_zod16.z.string(),
2210
- name: import_zod16.z.string(),
2211
- description: import_zod16.z.string(),
2212
- code: import_zod16.z.string(),
2213
- redeemed: import_zod16.z.boolean(),
2392
+ var import_zod17 = require("zod");
2393
+ var voucherSchema = import_zod17.z.object({
2394
+ id: import_zod17.z.string(),
2395
+ name: import_zod17.z.string(),
2396
+ description: import_zod17.z.string(),
2397
+ code: import_zod17.z.string(),
2398
+ redeemed: import_zod17.z.boolean(),
2214
2399
  redeemsProducts: quantifiable(storefrontProductSchema).array(),
2215
2400
  redeemsBundles: quantifiable(storefrontBundleSchema).array(),
2216
- properties: import_zod16.z.record(rawPropertyValueSchema).nullish()
2401
+ properties: import_zod17.z.record(rawPropertyValueSchema).nullish()
2217
2402
  });
2218
2403
 
2219
2404
  // src/vouchers/endpoints.ts
@@ -2414,11 +2599,48 @@ var OfferUtils = class _OfferUtils {
2414
2599
  // src/utils/cart.ts
2415
2600
  var _CartUtils = class _CartUtils {
2416
2601
  // The pricing variation a line item points at, falling back to the item's default variation when
2417
- // the variation id doesn't resolve, which is what the cart has always displayed.
2602
+ // the variation id doesn't resolve, which is what the cart has always displayed. A line upgrading
2603
+ // one of the customer's licenses is priced for that license, as the API prices it.
2418
2604
  static resolveVariation(catalog, item) {
2419
- var _a, _b;
2420
- const source = item.type === "Product" ? catalog.products.find((p) => p.id === item.productId) : catalog.bundles.find((b) => b.id === item.bundleId);
2421
- return (_b = (_a = source == null ? void 0 : source.variations) == null ? void 0 : _a.find((v) => v.id === item.variationId)) != null ? _b : source == null ? void 0 : source.defaultVariation;
2605
+ var _a, _b, _c;
2606
+ if (item.type === "Product") {
2607
+ const product = catalog.products.find((p) => p.id === item.productId);
2608
+ return (_a = _CartUtils.productLineVariation(product, item.variationId, item.targetLicenseId)) != null ? _a : product == null ? void 0 : product.defaultVariation;
2609
+ }
2610
+ const bundle = catalog.bundles.find((b) => b.id === item.bundleId);
2611
+ return (_c = (_b = bundle == null ? void 0 : bundle.variations) == null ? void 0 : _b.find((v) => v.id === item.variationId)) != null ? _c : bundle == null ? void 0 : bundle.defaultVariation;
2612
+ }
2613
+ /**
2614
+ * The storefront's entry for upgrading or renewing one of the signed-in customer's licenses of a
2615
+ * product: what it covers now, and the variations that would upgrade it, priced for it. Licenses
2616
+ * that cover the same share an entry. `undefined` when the storefront has none for it (the license
2617
+ * is not theirs, covers every release, is past the cap on entries, or the customer is not signed in).
2618
+ */
2619
+ static licenseUpgrade(product, licenseId) {
2620
+ var _a;
2621
+ if (!product || !licenseId)
2622
+ return void 0;
2623
+ const wanted = licenseId.toLowerCase();
2624
+ return (_a = product.licenseUpgrades) == null ? void 0 : _a.find((u) => u.licenseIds.some((id) => id.toLowerCase() === wanted));
2625
+ }
2626
+ /**
2627
+ * The variations that would upgrade or renew one of the signed-in customer's licenses of a
2628
+ * product, priced for that license, or `undefined` when the storefront has no price for it.
2629
+ */
2630
+ static licenseUpgradeVariations(product, licenseId) {
2631
+ var _a;
2632
+ return (_a = _CartUtils.licenseUpgrade(product, licenseId)) == null ? void 0 : _a.variations;
2633
+ }
2634
+ /**
2635
+ * The variation a product line is priced at. A line naming one of the customer's licenses
2636
+ * (`targetLicenseId`) upgrades that license, and an upgrade discount is judged per license, so its
2637
+ * price comes from the product's `licenseUpgrades` for that license. Every other line, and an
2638
+ * upgrade line the storefront has no price for, takes the product's own variation, which is what
2639
+ * a new license costs.
2640
+ */
2641
+ static productLineVariation(product, variationId, targetLicenseId) {
2642
+ var _a, _b, _c;
2643
+ return (_c = (_a = _CartUtils.licenseUpgradeVariations(product, targetLicenseId)) == null ? void 0 : _a.find((v) => v.id === variationId)) != null ? _c : (_b = product == null ? void 0 : product.variations) == null ? void 0 : _b.find((v) => v.id === variationId);
2422
2644
  }
2423
2645
  // A line's unit price after its product discount and any pricing tier, and *before* any offer.
2424
2646
  // This is the basis the API measures cart total conditions on, which is why it reads the catalog
@@ -2905,6 +3127,7 @@ var MoonbaseClient = class {
2905
3127
  OrderStatus,
2906
3128
  PasswordSetupRequiredError,
2907
3129
  Platform,
3130
+ ReleaseNotCoveredError,
2908
3131
  StoreClosedError,
2909
3132
  SubscriptionCancellationReason,
2910
3133
  SubscriptionStatus,