@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.js CHANGED
@@ -20,6 +20,7 @@ __export(schemas_exports2, {
20
20
  offerConditionSchema: () => offerConditionSchema,
21
21
  offerScopeSchema: () => offerScopeSchema,
22
22
  storefrontBundleSchema: () => storefrontBundleSchema,
23
+ storefrontLicenseUpgradeSchema: () => storefrontLicenseUpgradeSchema,
23
24
  storefrontOfferSchema: () => storefrontOfferSchema,
24
25
  storefrontOfferTargetSchema: () => storefrontOfferTargetSchema,
25
26
  storefrontProductSchema: () => storefrontProductSchema,
@@ -154,6 +155,7 @@ var schemas_exports = {};
154
155
  __export(schemas_exports, {
155
156
  downloadSchema: () => downloadSchema,
156
157
  manifestSchema: () => manifestSchema,
158
+ productReleaseAccessSchema: () => productReleaseAccessSchema,
157
159
  productReleaseSchema: () => productReleaseSchema,
158
160
  productSummarySchema: () => productSummarySchema
159
161
  });
@@ -196,6 +198,21 @@ var downloadSchema = z2.object({
196
198
  path: z2.string().nullable(),
197
199
  manifest: manifestSchema.optional()
198
200
  });
201
+ var productReleaseAccessSchema = z2.object({
202
+ // Releases published until then are covered, and every version while it has not passed.
203
+ updatesUntil: z2.coerce.date().nullish().catch(void 0),
204
+ // Every version whose major is at most this is covered.
205
+ upToMajor: z2.number().nullish().catch(void 0),
206
+ // Once updates have ended, the last version published before they did.
207
+ upToVersion: z2.string().nullish().catch(void 0),
208
+ // Whether the release this was resolved for (the one shown) is covered. Read as covered when
209
+ // unreadable, so a garbled answer never locks a download the API would hand out.
210
+ coversRelease: z2.boolean().catch(true),
211
+ // The newest published version the customer may download, when the shown one is not covered.
212
+ latestCoveredVersion: z2.string().nullish().catch(void 0),
213
+ // Where to buy the upgrade or renewal, while the product sells one.
214
+ upgradeUrl: z2.string().nullish().catch(void 0)
215
+ });
199
216
  var productSummarySchema = z2.object({
200
217
  id: z2.string(),
201
218
  name: z2.string(),
@@ -219,7 +236,10 @@ var productSummarySchema = z2.object({
219
236
  // Whether this caller clears every requirement above, including the group membership the client
220
237
  // can't see for itself. False with none of them set means the merchant closed the release to everyone.
221
238
  downloadsAllowed: z2.boolean(),
222
- downloads: z2.array(downloadSchema).optional()
239
+ downloads: z2.array(downloadSchema).optional(),
240
+ // Set only when the customer's licenses do not cover every release. `downloadsAllowed` already
241
+ // accounts for it; this says why a download is locked and where to upgrade.
242
+ releaseAccess: productReleaseAccessSchema.nullish().catch(void 0)
223
243
  });
224
244
  var productReleaseSchema = z2.object({
225
245
  version: z2.string(),
@@ -229,10 +249,33 @@ var productReleaseSchema = z2.object({
229
249
  // merchant can keep past releases to owners while the current one is open to anyone.
230
250
  downloadsAllowed: z2.boolean(),
231
251
  downloads: z2.array(downloadSchema),
232
- properties: z2.record(rawPropertyValueSchema).nullish()
252
+ properties: z2.record(rawPropertyValueSchema).nullish(),
253
+ // True when the caller owns the product but none of their licenses covers this release, so it
254
+ // takes an upgrade rather than a sign-in to unlock. Absent otherwise.
255
+ releaseNotCovered: z2.boolean().nullish().catch(void 0)
233
256
  });
234
257
 
235
258
  // src/storefront/schemas.ts
259
+ var storefrontLicenseUpgradeSchema = z3.object({
260
+ // The customer's licenses this entry prices. An entry without them is no use and is left out.
261
+ licenseIds: z3.string().array(),
262
+ // What those licenses cover now, which is how a cart tells the customer which of their licenses an
263
+ // upgrade is for. Read leniently, field by field: a backend that predates it leaves it out, and one
264
+ // this version cannot read reads as absent rather than costing the entry.
265
+ releaseAccess: z3.object({
266
+ // Releases published until then are covered, and every version while it has not passed.
267
+ updatesUntil: z3.coerce.date().nullish().catch(void 0),
268
+ // Every version whose major is at most this is covered.
269
+ upToMajor: z3.number().nullish().catch(void 0),
270
+ // Once updates have ended, the last version published before they did.
271
+ upToVersion: z3.string().nullish().catch(void 0)
272
+ }).nullish().catch(void 0),
273
+ variations: pricingVariationSchema.array()
274
+ });
275
+ var storefrontLicenseUpgradesSchema = z3.array(z3.unknown()).transform((upgrades) => upgrades.flatMap((upgrade) => {
276
+ const parsed = storefrontLicenseUpgradeSchema.safeParse(upgrade);
277
+ return parsed.success ? [parsed.data] : [];
278
+ }));
236
279
  var storefrontProductSchema = z3.object({
237
280
  id: z3.string(),
238
281
  name: z3.string(),
@@ -246,7 +289,13 @@ var storefrontProductSchema = z3.object({
246
289
  defaultVariation: pricingVariationSchema.optional(),
247
290
  variations: pricingVariationSchema.array().optional(),
248
291
  properties: z3.record(rawPropertyValueSchema).nullish(),
249
- type: z3.string().optional().default("Product").pipe(z3.literal("Product"))
292
+ type: z3.string().optional().default("Product").pipe(z3.literal("Product")),
293
+ // What upgrading or renewing the signed-in customer's licenses of the product that cover only
294
+ // some releases costs, one entry per group of licenses that cover the same, furthest behind first.
295
+ // Capped, so a customer with a great many licenses may find one in none of them. Absent for anyone
296
+ // else, and from a backend that predates per-license prices. A cart line naming one of these
297
+ // licenses (`targetLicenseId`) is priced from here: see `CartUtils.licenseUpgrade`.
298
+ licenseUpgrades: storefrontLicenseUpgradesSchema.nullish().catch(void 0)
250
299
  });
251
300
  var storefrontBundleSchema = z3.object({
252
301
  id: z3.string(),
@@ -420,7 +469,17 @@ var activationRequestSchema = z4.object({
420
469
  endless: z4.boolean().default(false)
421
470
  }).optional(),
422
471
  licenseEligibility: z4.object({
423
- eligible: z4.boolean()
472
+ eligible: z4.boolean(),
473
+ // Set when the customer's licenses would take the device but none of them covers the version
474
+ // the app runs (`eligible` is then false), so the app's version needs an upgrade. Absent from
475
+ // a backend that predates release access, and read leniently so it can never fail the request.
476
+ releaseNotCovered: z4.object({
477
+ appVersion: z4.string().nullish().catch(void 0),
478
+ updatesUntil: z4.coerce.date().nullish().catch(void 0),
479
+ upToMajor: z4.number().nullish().catch(void 0),
480
+ upToVersion: z4.string().nullish().catch(void 0),
481
+ upgradeUrl: z4.string().nullish().catch(void 0)
482
+ }).nullish().catch(void 0)
424
483
  }).optional()
425
484
  });
426
485
 
@@ -499,7 +558,8 @@ var CommunicationsEndpoints = class {
499
558
  newsletter: (_b = input.newsletter) != null ? _b : true,
500
559
  productUpdates: (_c = input.productUpdates) != null ? _c : true,
501
560
  groupIds: normalizeGroupIds(input.groupIds)
502
- }
561
+ },
562
+ headers: input.captchaToken ? { "X-MB-CAPTCHA": input.captchaToken } : void 0
503
563
  });
504
564
  return response.data;
505
565
  }
@@ -579,6 +639,15 @@ var NotAuthorizedError = class extends Error {
579
639
  this.message = "Not allowed";
580
640
  }
581
641
  };
642
+ var ReleaseNotCoveredError = class extends NotAuthorizedError {
643
+ constructor(releaseAccess, upgradeUrl, detail) {
644
+ super();
645
+ this.releaseAccess = releaseAccess;
646
+ this.upgradeUrl = upgradeUrl;
647
+ this.name = "ReleaseNotCoveredError";
648
+ this.message = detail != null ? detail : "Your license doesn't cover this version";
649
+ }
650
+ };
582
651
  var NotAuthenticatedError = class extends Error {
583
652
  constructor() {
584
653
  super();
@@ -628,6 +697,9 @@ var PasswordSetupRequiredError = class extends MoonbaseError {
628
697
  }
629
698
  };
630
699
 
700
+ // src/utils/problemHandler.ts
701
+ import { z as z8 } from "zod";
702
+
631
703
  // src/utils/problemDetails.ts
632
704
  import { z as z7 } from "zod";
633
705
  var problemDetailsSchema = z7.object({
@@ -641,6 +713,28 @@ var problemDetailsSchema = z7.object({
641
713
  });
642
714
 
643
715
  // src/utils/problemHandler.ts
716
+ var releaseNotCoveredProblemSchema = z8.object({
717
+ errorType: z8.literal("ReleaseNotCovered"),
718
+ detail: z8.string().nullish().catch(void 0),
719
+ releaseAccess: productReleaseAccessSchema.nullish().catch(void 0),
720
+ upgradeUrl: z8.string().nullish().catch(void 0)
721
+ });
722
+ async function forbiddenError(response) {
723
+ var _a;
724
+ try {
725
+ const problem = releaseNotCoveredProblemSchema.safeParse(JSON.parse(await response.text()));
726
+ if (problem.success) {
727
+ const { releaseAccess, upgradeUrl, detail } = problem.data;
728
+ return new ReleaseNotCoveredError(
729
+ releaseAccess != null ? releaseAccess : void 0,
730
+ (_a = upgradeUrl != null ? upgradeUrl : releaseAccess == null ? void 0 : releaseAccess.upgradeUrl) != null ? _a : void 0,
731
+ detail != null ? detail : void 0
732
+ );
733
+ }
734
+ } catch (e) {
735
+ }
736
+ return new NotAuthorizedError();
737
+ }
644
738
  function camelCase(str) {
645
739
  return str.split(".").map((word, index) => {
646
740
  let [firstLetter, ...restOfLetters] = word;
@@ -657,7 +751,7 @@ async function handleResponseProblem(response, logger) {
657
751
  throw new NotAuthenticatedError();
658
752
  }
659
753
  if (response.status === 403) {
660
- throw new NotAuthorizedError();
754
+ throw await forbiddenError(response);
661
755
  }
662
756
  let problemDetails;
663
757
  const body = await response.text();
@@ -697,7 +791,7 @@ __export(schemas_exports5, {
697
791
  userAccountConfirmedStatusSchema: () => userAccountConfirmedStatusSchema,
698
792
  userSchema: () => userSchema
699
793
  });
700
- import { z as z8 } from "zod";
794
+ import { z as z9 } from "zod";
701
795
 
702
796
  // src/identity/models.ts
703
797
  var ConnectableAccountProvider = /* @__PURE__ */ ((ConnectableAccountProvider2) => {
@@ -706,69 +800,69 @@ var ConnectableAccountProvider = /* @__PURE__ */ ((ConnectableAccountProvider2)
706
800
  })(ConnectableAccountProvider || {});
707
801
 
708
802
  // src/identity/schemas.ts
709
- var addressSchema = z8.object({
710
- countryCode: z8.string(),
711
- streetAddress1: z8.string(),
712
- streetAddress2: z8.string().nullable(),
713
- locality: z8.string().nullable(),
714
- region: z8.string().nullable(),
715
- postCode: z8.string().nullable()
716
- });
717
- var communicationPreferencesSchema = z8.object({
718
- newsletterOptIn: z8.boolean(),
803
+ var addressSchema = z9.object({
804
+ countryCode: z9.string(),
805
+ streetAddress1: z9.string(),
806
+ streetAddress2: z9.string().nullable(),
807
+ locality: z9.string().nullable(),
808
+ region: z9.string().nullable(),
809
+ postCode: z9.string().nullable()
810
+ });
811
+ var communicationPreferencesSchema = z9.object({
812
+ newsletterOptIn: z9.boolean(),
719
813
  // Default keeps older persisted identities (pre productUpdatesOptIn) parseable
720
814
  // during boot. The server-side value is hydrated by updateUser() right after.
721
- productUpdatesOptIn: z8.boolean().default(false)
815
+ productUpdatesOptIn: z9.boolean().default(false)
722
816
  });
723
- var ilokConnectedAccountSchema = z8.object({
724
- provider: z8.literal("iLok" /* iLok */),
725
- isConnected: z8.boolean(),
726
- pendingLicenseFulfillments: z8.boolean(),
727
- accountId: z8.string().nullish()
817
+ var ilokConnectedAccountSchema = z9.object({
818
+ provider: z9.literal("iLok" /* iLok */),
819
+ isConnected: z9.boolean(),
820
+ pendingLicenseFulfillments: z9.boolean(),
821
+ accountId: z9.string().nullish()
728
822
  });
729
- var connectedAccountSchema = z8.discriminatedUnion("provider", [
823
+ var connectedAccountSchema = z9.discriminatedUnion("provider", [
730
824
  ilokConnectedAccountSchema
731
825
  ]);
732
- var connectionUrlSchema = z8.object({
733
- url: z8.string()
826
+ var connectionUrlSchema = z9.object({
827
+ url: z9.string()
734
828
  });
735
- var userSchema = z8.object({
736
- id: z8.string(),
737
- email: z8.string(),
829
+ var userSchema = z9.object({
830
+ id: z9.string(),
831
+ email: z9.string(),
738
832
  // Nullable: customers created via import may have no name.
739
- name: z8.string().nullable(),
740
- tenantId: z8.string(),
833
+ name: z9.string().nullable(),
834
+ tenantId: z9.string(),
741
835
  address: addressSchema.optional(),
742
- phone: z8.string().optional(),
836
+ phone: z9.string().optional(),
743
837
  communicationPreferences: communicationPreferencesSchema,
744
- ownedProducts: z8.string().array().optional(),
745
- subscribedProducts: z8.string().array().optional(),
746
- confirmedAccount: z8.boolean().optional(),
747
- hasProducts: z8.boolean().nullish(),
748
- hasSubscriptions: z8.boolean().nullish(),
749
- connectedAccounts: z8.array(connectedAccountSchema).default([])
750
- });
751
- var identitySchema = userSchema.and(z8.object({
752
- accessToken: z8.string(),
753
- refreshToken: z8.string()
838
+ ownedProducts: z9.string().array().optional(),
839
+ subscribedProducts: z9.string().array().optional(),
840
+ confirmedAccount: z9.boolean().optional(),
841
+ hasProducts: z9.boolean().nullish(),
842
+ hasSubscriptions: z9.boolean().nullish(),
843
+ connectedAccounts: z9.array(connectedAccountSchema).default([])
844
+ });
845
+ var identitySchema = userSchema.and(z9.object({
846
+ accessToken: z9.string(),
847
+ refreshToken: z9.string()
754
848
  }));
755
- var userAccountConfirmedStatusSchema = z8.enum([
849
+ var userAccountConfirmedStatusSchema = z9.enum([
756
850
  "PasswordSetupRequired",
757
851
  "SignedIn"
758
852
  ]);
759
- var userAccountConfirmedSchema = userSchema.and(z8.object({
853
+ var userAccountConfirmedSchema = userSchema.and(z9.object({
760
854
  status: userAccountConfirmedStatusSchema,
761
- resetPasswordToken: z8.string().nullish(),
762
- accessToken: z8.string().nullish(),
763
- refreshToken: z8.string().nullish()
855
+ resetPasswordToken: z9.string().nullish(),
856
+ accessToken: z9.string().nullish(),
857
+ refreshToken: z9.string().nullish()
764
858
  }));
765
- var pendingActivationSchema = z8.object({
766
- status: z8.literal("activation_pending"),
767
- email: z8.string()
859
+ var pendingActivationSchema = z9.object({
860
+ status: z9.literal("activation_pending"),
861
+ email: z9.string()
768
862
  });
769
- var pendingPasswordProblemSchema = z8.object({
770
- errorType: z8.literal("PasswordSetupRequired"),
771
- pendingPasswordToken: z8.string()
863
+ var pendingPasswordProblemSchema = z9.object({
864
+ errorType: z9.literal("PasswordSetupRequired"),
865
+ pendingPasswordToken: z9.string()
772
866
  });
773
867
 
774
868
  // src/identity/endpoints.ts
@@ -964,16 +1058,17 @@ var IdentityEndpoints = class {
964
1058
  };
965
1059
 
966
1060
  // src/inventory/activation/endpoints.ts
967
- import { z as z10 } from "zod";
1061
+ import { z as z11 } from "zod";
968
1062
 
969
1063
  // src/inventory/licenses/schemas.ts
970
1064
  var schemas_exports6 = {};
971
1065
  __export(schemas_exports6, {
972
1066
  activationSchema: () => activationSchema,
973
1067
  externalLicenseContent: () => externalLicenseContent,
1068
+ licenseReleaseAccessSchema: () => licenseReleaseAccessSchema,
974
1069
  licenseSchema: () => licenseSchema
975
1070
  });
976
- import { z as z9 } from "zod";
1071
+ import { z as z10 } from "zod";
977
1072
 
978
1073
  // src/inventory/licenses/models.ts
979
1074
  var LicenseStatus = /* @__PURE__ */ ((LicenseStatus2) => {
@@ -994,43 +1089,57 @@ var ActivationMethod = /* @__PURE__ */ ((ActivationMethod2) => {
994
1089
  })(ActivationMethod || {});
995
1090
 
996
1091
  // src/inventory/licenses/schemas.ts
997
- var externalLicenseFileContent = z9.object({
998
- type: z9.literal("file"),
999
- fileName: z9.string(),
1000
- contentType: z9.string(),
1001
- data: z9.string()
1002
- });
1003
- var externalLicenseILokContent = z9.object({
1004
- type: z9.literal("iLok")
1005
- });
1006
- var externalLicenseContent = z9.union([
1007
- z9.string(),
1008
- z9.discriminatedUnion("type", [
1092
+ var externalLicenseFileContent = z10.object({
1093
+ type: z10.literal("file"),
1094
+ fileName: z10.string(),
1095
+ contentType: z10.string(),
1096
+ data: z10.string()
1097
+ });
1098
+ var externalLicenseILokContent = z10.object({
1099
+ type: z10.literal("iLok")
1100
+ });
1101
+ var externalLicenseContent = z10.union([
1102
+ z10.string(),
1103
+ z10.discriminatedUnion("type", [
1009
1104
  externalLicenseFileContent,
1010
1105
  externalLicenseILokContent
1011
1106
  ])
1012
1107
  ]);
1013
- var licenseSchema = z9.object({
1014
- id: z9.string(),
1015
- status: z9.nativeEnum(LicenseStatus),
1108
+ var licenseReleaseAccessSchema = z10.object({
1109
+ // Releases published until then are covered, and every version while it has not passed.
1110
+ updatesUntil: z10.coerce.date().nullish().catch(void 0),
1111
+ // Every version whose major is at most this is covered.
1112
+ upToMajor: z10.number().nullish().catch(void 0),
1113
+ // Once updates have ended, the last version published before they did.
1114
+ upToVersion: z10.string().nullish().catch(void 0),
1115
+ // Whether the product's current release is covered, so whether to offer an upgrade. Read as
1116
+ // covered when unreadable, so a garbled answer never pushes an upgrade nobody needs.
1117
+ coversCurrentRelease: z10.boolean().catch(true),
1118
+ // Where to buy the upgrade or renewal for this license, while the product sells one.
1119
+ upgradeUrl: z10.string().nullish().catch(void 0)
1120
+ });
1121
+ var licenseSchema = z10.object({
1122
+ id: z10.string(),
1123
+ status: z10.nativeEnum(LicenseStatus),
1016
1124
  product: productSummarySchema,
1017
- activeNumberOfActivations: z9.number(),
1018
- maxNumberOfActivations: z9.number(),
1125
+ activeNumberOfActivations: z10.number(),
1126
+ maxNumberOfActivations: z10.number(),
1019
1127
  externalFulfillment: externalLicenseContent.optional(),
1020
- requiredConnectedAccount: z9.nativeEnum(ConnectableAccountProvider).nullish(),
1021
- fulfillmentMessage: z9.string().optional(),
1022
- properties: z9.record(rawPropertyValueSchema).nullish(),
1023
- expiresAt: z9.coerce.date().optional(),
1024
- createdAt: z9.coerce.date()
1128
+ requiredConnectedAccount: z10.nativeEnum(ConnectableAccountProvider).nullish(),
1129
+ fulfillmentMessage: z10.string().optional(),
1130
+ properties: z10.record(rawPropertyValueSchema).nullish(),
1131
+ expiresAt: z10.coerce.date().optional(),
1132
+ createdAt: z10.coerce.date(),
1133
+ releaseAccess: licenseReleaseAccessSchema.nullish().catch(void 0)
1025
1134
  });
1026
- var activationSchema = z9.object({
1027
- id: z9.string(),
1028
- licenseId: z9.string(),
1029
- name: z9.string(),
1030
- status: z9.nativeEnum(ActivationStatus),
1031
- activationMethod: z9.nativeEnum(ActivationMethod),
1032
- firstValidatedAt: z9.coerce.date(),
1033
- lastValidatedAt: z9.coerce.date().nullable()
1135
+ var activationSchema = z10.object({
1136
+ id: z10.string(),
1137
+ licenseId: z10.string(),
1138
+ name: z10.string(),
1139
+ status: z10.nativeEnum(ActivationStatus),
1140
+ activationMethod: z10.nativeEnum(ActivationMethod),
1141
+ firstValidatedAt: z10.coerce.date(),
1142
+ lastValidatedAt: z10.coerce.date().nullable()
1034
1143
  });
1035
1144
 
1036
1145
  // src/inventory/activation/endpoints.ts
@@ -1047,7 +1156,7 @@ var ActivationEndpoints = class {
1047
1156
  });
1048
1157
  return {
1049
1158
  license: response.data,
1050
- url: z10.string().parse(response.headers.location)
1159
+ url: z11.string().parse(response.headers.location)
1051
1160
  };
1052
1161
  }
1053
1162
  };
@@ -1075,7 +1184,7 @@ var LicenseEndpoints = class {
1075
1184
  };
1076
1185
 
1077
1186
  // src/inventory/products/endpoints.ts
1078
- import { z as z11 } from "zod";
1187
+ import { z as z12 } from "zod";
1079
1188
  var ProductEndpoints = class {
1080
1189
  constructor(api, configuration) {
1081
1190
  this.api = api;
@@ -1109,18 +1218,18 @@ var ProductEndpoints = class {
1109
1218
  async getDownloadUrl(path) {
1110
1219
  const url = new URL(path);
1111
1220
  url.searchParams.append("redirect", "false");
1112
- const response = await this.api.fetch(url.pathname + url.search, z11.object({
1113
- location: z11.string()
1221
+ const response = await this.api.fetch(url.pathname + url.search, z12.object({
1222
+ location: z12.string()
1114
1223
  }));
1115
1224
  return response.data.location;
1116
1225
  }
1117
1226
  };
1118
1227
 
1119
1228
  // src/inventory/subscriptions/endpoints.ts
1120
- import { z as z14 } from "zod";
1229
+ import { z as z15 } from "zod";
1121
1230
 
1122
1231
  // package.json
1123
- var version = "3.9.0";
1232
+ var version = "3.11.0";
1124
1233
 
1125
1234
  // src/utils/client.ts
1126
1235
  function buildClientHeader(sdk) {
@@ -1167,7 +1276,8 @@ var MoonbaseApi = class {
1167
1276
  ...accessToken ? { Authorization: `Bearer ${accessToken}` } : {},
1168
1277
  // Force CORS on all calls
1169
1278
  "x-mb-cors": "1",
1170
- "x-mb-client": this.clientHeader
1279
+ "x-mb-client": this.clientHeader,
1280
+ ...options == null ? void 0 : options.headers
1171
1281
  },
1172
1282
  body: (options == null ? void 0 : options.body) ? contentType !== "application/json" ? options.body : JSON.stringify(options.body) : void 0,
1173
1283
  signal: options == null ? void 0 : options.abort,
@@ -1275,9 +1385,13 @@ var MoonbaseApi = class {
1275
1385
  var schemas_exports8 = {};
1276
1386
  __export(schemas_exports8, {
1277
1387
  milestoneProgressSchema: () => milestoneProgressSchema,
1388
+ pendingPlanChangeSchema: () => pendingPlanChangeSchema,
1389
+ pricingOptionSchema: () => pricingOptionSchema,
1390
+ subscriptionPlanOptionSchema: () => subscriptionPlanOptionSchema,
1391
+ subscriptionPlanOptionsSchema: () => subscriptionPlanOptionsSchema,
1278
1392
  subscriptionSchema: () => subscriptionSchema
1279
1393
  });
1280
- import { z as z13 } from "zod";
1394
+ import { z as z14 } from "zod";
1281
1395
 
1282
1396
  // src/orders/schemas.ts
1283
1397
  var schemas_exports7 = {};
@@ -1291,7 +1405,7 @@ __export(schemas_exports7, {
1291
1405
  orderSchema: () => orderSchema,
1292
1406
  orderTotalSchema: () => orderTotalSchema
1293
1407
  });
1294
- import { z as z12 } from "zod";
1408
+ import { z as z13 } from "zod";
1295
1409
 
1296
1410
  // src/orders/models.ts
1297
1411
  var OrderStatus = /* @__PURE__ */ ((OrderStatus2) => {
@@ -1304,18 +1418,18 @@ var OrderStatus = /* @__PURE__ */ ((OrderStatus2) => {
1304
1418
  })(OrderStatus || {});
1305
1419
 
1306
1420
  // src/orders/schemas.ts
1307
- var couponSchema = z12.object({
1308
- code: z12.string(),
1309
- name: z12.string(),
1310
- description: z12.string()
1311
- });
1312
- var lineItemProductSchema = z12.object({
1313
- id: z12.string(),
1314
- name: z12.string(),
1315
- tagline: z12.string().nullish(),
1316
- iconUrl: z12.string().nullable()
1317
- });
1318
- var lineItemTotalSchema = z12.object({
1421
+ var couponSchema = z13.object({
1422
+ code: z13.string(),
1423
+ name: z13.string(),
1424
+ description: z13.string()
1425
+ });
1426
+ var lineItemProductSchema = z13.object({
1427
+ id: z13.string(),
1428
+ name: z13.string(),
1429
+ tagline: z13.string().nullish(),
1430
+ iconUrl: z13.string().nullable()
1431
+ });
1432
+ var lineItemTotalSchema = z13.object({
1319
1433
  original: moneySchema,
1320
1434
  discount: moneySchema,
1321
1435
  subtotal: moneySchema,
@@ -1324,52 +1438,59 @@ var lineItemTotalSchema = z12.object({
1324
1438
  // for this item. Both are part of `discount`. Absent on orders priced before cart offers existed.
1325
1439
  cartOfferDiscount: moneySchema.optional()
1326
1440
  });
1327
- var openProductLineItem = z12.object({
1328
- id: z12.string(),
1329
- type: z12.literal("Product"),
1330
- productId: z12.string(),
1331
- quantity: z12.number(),
1332
- variationId: z12.string(),
1333
- offerId: z12.string().optional(),
1334
- isDefaultVariation: z12.boolean().nullish(),
1335
- isSubcriptionPayment: z12.boolean().nullish(),
1441
+ var openProductLineItem = z13.object({
1442
+ id: z13.string(),
1443
+ type: z13.literal("Product"),
1444
+ productId: z13.string(),
1445
+ quantity: z13.number(),
1446
+ variationId: z13.string(),
1447
+ offerId: z13.string().optional(),
1448
+ isDefaultVariation: z13.boolean().nullish(),
1449
+ isSubcriptionPayment: z13.boolean().nullish(),
1336
1450
  price: priceCollectionSchema.optional(),
1337
1451
  variation: pricingVariationSchema.optional(),
1338
1452
  total: lineItemTotalSchema.nullish(),
1339
1453
  product: lineItemProductSchema.optional(),
1340
- appliedDiscount: discountSchema.optional()
1454
+ appliedDiscount: discountSchema.optional(),
1455
+ // The customer's license this line upgrades or renews, as the cart named it. Such a line is one
1456
+ // license, so its quantity is always 1, and the line's `id` names the license too
1457
+ // (`p/<productId>/<variationId>/<licenseId>`): upgrading two licenses takes two lines. A line
1458
+ // without one issues new licenses. Part of the cart payload like `offerId`, so a push that leaves
1459
+ // it out forgets it. Echoed on completed orders too. Absent from a backend that predates release
1460
+ // access.
1461
+ targetLicenseId: z13.string().nullish().catch(void 0)
1341
1462
  });
1342
- var lineItemBundleSchema = z12.object({
1343
- id: z12.string(),
1344
- name: z12.string(),
1345
- tagline: z12.string().nullish(),
1346
- iconUrl: z12.string().nullable(),
1347
- products: lineItemProductSchema.and(z12.object({
1348
- included: z12.boolean().optional()
1463
+ var lineItemBundleSchema = z13.object({
1464
+ id: z13.string(),
1465
+ name: z13.string(),
1466
+ tagline: z13.string().nullish(),
1467
+ iconUrl: z13.string().nullable(),
1468
+ products: lineItemProductSchema.and(z13.object({
1469
+ included: z13.boolean().optional()
1349
1470
  })).array()
1350
1471
  });
1351
- var openBundleLineItem = z12.object({
1352
- id: z12.string(),
1353
- type: z12.literal("Bundle"),
1354
- bundleId: z12.string(),
1355
- quantity: z12.number(),
1356
- variationId: z12.string(),
1357
- offerId: z12.string().optional(),
1358
- partial: z12.boolean().optional(),
1359
- replaced: z12.string().array().optional(),
1360
- isDefaultVariation: z12.boolean().nullish(),
1361
- isSubcriptionPayment: z12.boolean().nullish(),
1472
+ var openBundleLineItem = z13.object({
1473
+ id: z13.string(),
1474
+ type: z13.literal("Bundle"),
1475
+ bundleId: z13.string(),
1476
+ quantity: z13.number(),
1477
+ variationId: z13.string(),
1478
+ offerId: z13.string().optional(),
1479
+ partial: z13.boolean().optional(),
1480
+ replaced: z13.string().array().optional(),
1481
+ isDefaultVariation: z13.boolean().nullish(),
1482
+ isSubcriptionPayment: z13.boolean().nullish(),
1362
1483
  price: priceCollectionSchema.optional(),
1363
1484
  variation: pricingVariationSchema.optional(),
1364
1485
  total: lineItemTotalSchema.nullish(),
1365
1486
  bundle: lineItemBundleSchema.optional(),
1366
1487
  appliedDiscount: discountSchema.optional()
1367
1488
  });
1368
- var openOrderLineItem = z12.discriminatedUnion("type", [
1489
+ var openOrderLineItem = z13.discriminatedUnion("type", [
1369
1490
  openProductLineItem,
1370
1491
  openBundleLineItem
1371
1492
  ]);
1372
- var orderTotalSchema = z12.object({
1493
+ var orderTotalSchema = z13.object({
1373
1494
  original: moneySchema,
1374
1495
  discount: moneySchema,
1375
1496
  subtotal: moneySchema,
@@ -1379,52 +1500,52 @@ var orderTotalSchema = z12.object({
1379
1500
  // rather than a share on every line. Absent when no cart offer applied.
1380
1501
  cartOfferDiscount: moneySchema.optional()
1381
1502
  });
1382
- var openOrderSchema = z12.object({
1383
- id: z12.string(),
1384
- currency: z12.string(),
1503
+ var openOrderSchema = z13.object({
1504
+ id: z13.string(),
1505
+ currency: z13.string(),
1385
1506
  total: orderTotalSchema.nullish(),
1386
1507
  items: openOrderLineItem.array(),
1387
1508
  couponsApplied: couponSchema.array(),
1388
1509
  // The cart offer on the order as a whole: the buyer's intent. It is part of the cart payload, so
1389
1510
  // a content push that leaves it out clears it. The API echoes it back even while the cart sits
1390
1511
  // below the offer's threshold.
1391
- offerId: z12.string().optional(),
1512
+ offerId: z13.string().optional(),
1392
1513
  // The cart offer as actually applied: the result. Absent while the offer's condition doesn't hold.
1393
1514
  appliedOffer: discountSchema.optional(),
1394
- checkoutUrl: z12.string().optional(),
1395
- hostedCheckoutUrl: z12.string().optional(),
1396
- embeddedCheckoutUrl: z12.string().optional()
1397
- });
1398
- var customerSnapshotSchema = z12.object({
1399
- name: z12.string().nullable(),
1400
- businessName: z12.string().nullable(),
1401
- taxId: z12.string().nullable(),
1402
- email: z12.string().nullable(),
1403
- phone: z12.string().nullable(),
1515
+ checkoutUrl: z13.string().optional(),
1516
+ hostedCheckoutUrl: z13.string().optional(),
1517
+ embeddedCheckoutUrl: z13.string().optional()
1518
+ });
1519
+ var customerSnapshotSchema = z13.object({
1520
+ name: z13.string().nullable(),
1521
+ businessName: z13.string().nullable(),
1522
+ taxId: z13.string().nullable(),
1523
+ email: z13.string().nullable(),
1524
+ phone: z13.string().nullable(),
1404
1525
  address: addressSchema.nullable()
1405
1526
  });
1406
- var completedOrderSchema = z12.object({
1407
- id: z12.string(),
1408
- status: z12.literal("Completed" /* Completed */),
1409
- currency: z12.string(),
1527
+ var completedOrderSchema = z13.object({
1528
+ id: z13.string(),
1529
+ status: z13.literal("Completed" /* Completed */),
1530
+ currency: z13.string(),
1410
1531
  customer: customerSnapshotSchema,
1411
1532
  total: orderTotalSchema,
1412
1533
  items: openOrderLineItem.array(),
1413
1534
  couponsApplied: couponSchema.array(),
1414
1535
  appliedOffer: discountSchema.optional()
1415
1536
  });
1416
- var orderSchema = z12.discriminatedUnion("status", [
1537
+ var orderSchema = z13.discriminatedUnion("status", [
1417
1538
  openOrderSchema.extend({
1418
- status: z12.literal("Open" /* Open */)
1539
+ status: z13.literal("Open" /* Open */)
1419
1540
  }),
1420
1541
  openOrderSchema.extend({
1421
- status: z12.literal("PaymentProcessing" /* PaymentProcessing */)
1542
+ status: z13.literal("PaymentProcessing" /* PaymentProcessing */)
1422
1543
  }),
1423
1544
  openOrderSchema.extend({
1424
- status: z12.literal("Paid" /* Paid */)
1545
+ status: z13.literal("Paid" /* Paid */)
1425
1546
  }),
1426
1547
  openOrderSchema.extend({
1427
- status: z12.literal("Failed" /* Failed */)
1548
+ status: z13.literal("Failed" /* Failed */)
1428
1549
  }),
1429
1550
  completedOrderSchema
1430
1551
  ]);
@@ -1448,58 +1569,89 @@ var SubscriptionCancellationReason = /* @__PURE__ */ ((SubscriptionCancellationR
1448
1569
  })(SubscriptionCancellationReason || {});
1449
1570
 
1450
1571
  // src/inventory/subscriptions/schemas.ts
1451
- var baseMilestoneProgressEventSchema = z13.object({
1452
- milestoneId: z13.string(),
1453
- fulfilled: z13.boolean(),
1454
- afterCycleNumber: z13.number(),
1455
- afterNormalizedCycleNumber: z13.number(),
1456
- message: z13.string().optional()
1457
- });
1458
- var milestoneProgressEventSchema = z13.discriminatedUnion("type", [
1572
+ var baseMilestoneProgressEventSchema = z14.object({
1573
+ milestoneId: z14.string(),
1574
+ fulfilled: z14.boolean(),
1575
+ afterCycleNumber: z14.number(),
1576
+ afterNormalizedCycleNumber: z14.number(),
1577
+ message: z14.string().optional()
1578
+ });
1579
+ var milestoneProgressEventSchema = z14.discriminatedUnion("type", [
1459
1580
  baseMilestoneProgressEventSchema.extend({
1460
- type: z13.literal("CouponCodeMilestone"),
1461
- code: z13.string().optional(),
1462
- redeemed: z13.boolean().optional()
1581
+ type: z14.literal("CouponCodeMilestone"),
1582
+ code: z14.string().optional(),
1583
+ redeemed: z14.boolean().optional()
1463
1584
  }),
1464
1585
  baseMilestoneProgressEventSchema.extend({
1465
- type: z13.literal("PerpetualLicenseConversionMilestone")
1586
+ type: z14.literal("PerpetualLicenseConversionMilestone")
1466
1587
  })
1467
1588
  ]);
1468
- var milestoneProgressSchema = z13.object({
1469
- title: z13.string(),
1470
- description: z13.string().nullish(),
1471
- currentCycleNumber: z13.number(),
1472
- currentNormalizedCycleNumber: z13.number(),
1473
- currentCycleIsCompleted: z13.boolean(),
1474
- fromCycleNumber: z13.number(),
1475
- fromNormalizedCycleNumber: z13.number(),
1476
- toCycleNumber: z13.number(),
1477
- toNormalizedCycleNumber: z13.number(),
1478
- events: z13.record(z13.coerce.number(), milestoneProgressEventSchema.array())
1479
- });
1480
- var subscriptionSchema = z13.object({
1481
- id: z13.string(),
1482
- status: z13.nativeEnum(SubscriptionStatus),
1483
- hasPaymentMethod: z13.boolean(),
1484
- cancellable: z13.boolean(),
1485
- expiresAt: z13.coerce.date(),
1486
- renewedAt: z13.coerce.date().nullable(),
1487
- nextPaymentScheduledAt: z13.coerce.date().nullable(),
1488
- startedAt: z13.coerce.date(),
1589
+ var milestoneProgressSchema = z14.object({
1590
+ title: z14.string(),
1591
+ description: z14.string().nullish(),
1592
+ currentCycleNumber: z14.number(),
1593
+ currentNormalizedCycleNumber: z14.number(),
1594
+ currentCycleIsCompleted: z14.boolean(),
1595
+ fromCycleNumber: z14.number(),
1596
+ fromNormalizedCycleNumber: z14.number(),
1597
+ toCycleNumber: z14.number(),
1598
+ toNormalizedCycleNumber: z14.number(),
1599
+ events: z14.record(z14.coerce.number(), milestoneProgressEventSchema.array())
1600
+ });
1601
+ var pricingOptionSchema = z14.object({
1602
+ id: z14.string(),
1603
+ name: z14.string(),
1604
+ cycleLength: z14.nativeEnum(CycleLength)
1605
+ });
1606
+ var pendingPlanChangeSchema = z14.object({
1607
+ option: pricingOptionSchema,
1608
+ // The renewal that starts the new plan and charges `nextTotal`.
1609
+ takesEffectAt: z14.coerce.date(),
1610
+ nextTotal: orderTotalSchema,
1611
+ // Whether everything the subscription gets off now (discount, offer, coupons) still applies on the new plan.
1612
+ keepsDiscount: z14.boolean(),
1613
+ scheduledAt: z14.coerce.date()
1614
+ });
1615
+ var subscriptionPlanOptionSchema = z14.object({
1616
+ option: pricingOptionSchema,
1617
+ // What the next renewal charges on this plan. For the plan it is on, its normal renewal.
1618
+ nextTotal: orderTotalSchema,
1619
+ takesEffectAt: z14.coerce.date(),
1620
+ keepsDiscount: z14.boolean(),
1621
+ current: z14.boolean(),
1622
+ scheduled: z14.boolean()
1623
+ });
1624
+ var subscriptionPlanOptionsSchema = z14.object({
1625
+ unavailable: z14.string().nullish(),
1626
+ plans: subscriptionPlanOptionSchema.array()
1627
+ });
1628
+ var subscriptionSchema = z14.object({
1629
+ id: z14.string(),
1630
+ status: z14.nativeEnum(SubscriptionStatus),
1631
+ hasPaymentMethod: z14.boolean(),
1632
+ cancellable: z14.boolean(),
1633
+ expiresAt: z14.coerce.date(),
1634
+ renewedAt: z14.coerce.date().nullable(),
1635
+ nextPaymentScheduledAt: z14.coerce.date().nullable(),
1636
+ startedAt: z14.coerce.date(),
1489
1637
  total: orderTotalSchema,
1490
- cycleLength: z13.nativeEnum(CycleLength),
1491
- paymentMethod: z13.string().optional(),
1638
+ cycleLength: z14.nativeEnum(CycleLength),
1639
+ paymentMethod: z14.string().optional(),
1492
1640
  milestoneProgress: milestoneProgressSchema.nullish(),
1493
- embeddedUpdatePaymentUrl: z13.string().optional(),
1494
- content: z13.discriminatedUnion("type", [
1495
- z13.object({
1496
- type: z13.literal("Product"),
1497
- quantity: z13.number(),
1641
+ embeddedUpdatePaymentUrl: z14.string().optional(),
1642
+ // Older backends send neither, and one this version can't read is dropped rather than failing
1643
+ // the whole subscription.
1644
+ pricingOption: pricingOptionSchema.nullish().catch(void 0),
1645
+ pendingChange: pendingPlanChangeSchema.nullish().catch(void 0),
1646
+ content: z14.discriminatedUnion("type", [
1647
+ z14.object({
1648
+ type: z14.literal("Product"),
1649
+ quantity: z14.number(),
1498
1650
  product: storefrontProductSchema
1499
1651
  }),
1500
- z13.object({
1501
- type: z13.literal("Bundle"),
1502
- quantity: z13.number(),
1652
+ z14.object({
1653
+ type: z14.literal("Bundle"),
1654
+ quantity: z14.number(),
1503
1655
  bundle: storefrontBundleSchema
1504
1656
  })
1505
1657
  ])
@@ -1534,9 +1686,41 @@ var SubscriptionEndpoints = class {
1534
1686
  });
1535
1687
  return response.data;
1536
1688
  }
1689
+ /**
1690
+ * The plans the subscription can switch to when its current period ends, each with what the
1691
+ * next renewal would charge on it. The plan it is on comes first. When it can't switch,
1692
+ * `unavailable` says why, ready to show to the customer.
1693
+ */
1694
+ async getPlanOptions(subscriptionId) {
1695
+ const response = await this.api.authenticatedFetch(`/api/customer/inventory/subscriptions/${subscriptionId}/plan-options`, subscriptionPlanOptionsSchema);
1696
+ return response.data;
1697
+ }
1698
+ /**
1699
+ * Switches the subscription to another plan when its current period ends. Nothing is charged
1700
+ * now: the next renewal charges the new plan and starts its cycle. Until then the customer can
1701
+ * switch again, and passing the plan it is on keeps that plan. Returns the updated subscription,
1702
+ * with the switch in `pendingChange`.
1703
+ */
1704
+ async changePlan(subscriptionId, variationId) {
1705
+ const response = await this.api.authenticatedFetch(`/api/customer/inventory/subscriptions/${subscriptionId}/plan-change`, subscriptionSchema, {
1706
+ method: "POST",
1707
+ body: { variationId }
1708
+ });
1709
+ return response.data;
1710
+ }
1711
+ /**
1712
+ * Keeps the subscription on its current plan, dropping a switch scheduled with `changePlan`.
1713
+ * Returns the updated subscription.
1714
+ */
1715
+ async cancelPlanChange(subscriptionId) {
1716
+ const response = await this.api.authenticatedFetch(`/api/customer/inventory/subscriptions/${subscriptionId}/plan-change`, subscriptionSchema, {
1717
+ method: "DELETE"
1718
+ });
1719
+ return response.data;
1720
+ }
1537
1721
  async renew(subscriptionId, returnUrl, embedded) {
1538
- const response = await this.api.authenticatedFetch(`/api/customer/inventory/subscriptions/${subscriptionId}/renew?redirect=false&return=${returnUrl}&embedded=${embedded ? "true" : "false"}`, z14.object({
1539
- location: z14.string()
1722
+ const response = await this.api.authenticatedFetch(`/api/customer/inventory/subscriptions/${subscriptionId}/renew?redirect=false&return=${returnUrl}&embedded=${embedded ? "true" : "false"}`, z15.object({
1723
+ location: z15.string()
1540
1724
  }), { method: "POST" });
1541
1725
  return response.data;
1542
1726
  }
@@ -2105,21 +2289,21 @@ __export(schemas_exports9, {
2105
2289
  vendorFeaturesSchema: () => vendorFeaturesSchema,
2106
2290
  vendorSchema: () => vendorSchema
2107
2291
  });
2108
- import { z as z15 } from "zod";
2109
- var vendorCaptchaSchema = z15.object({
2110
- url: z15.string()
2292
+ import { z as z16 } from "zod";
2293
+ var vendorCaptchaSchema = z16.object({
2294
+ url: z16.string()
2111
2295
  });
2112
- var vendorFeaturesSchema = z15.object({
2113
- customerPortal: z15.boolean().optional(),
2114
- phoneNumber: z15.boolean().optional(),
2115
- marketingConsent: z15.nativeEnum(MarketingConsentType).optional().catch(void 0),
2296
+ var vendorFeaturesSchema = z16.object({
2297
+ customerPortal: z16.boolean().optional(),
2298
+ phoneNumber: z16.boolean().optional(),
2299
+ marketingConsent: z16.nativeEnum(MarketingConsentType).optional().catch(void 0),
2116
2300
  // Absent on backends from before captchas, which never ask for one.
2117
2301
  captcha: vendorCaptchaSchema.nullish()
2118
2302
  });
2119
- var vendorSchema = z15.object({
2120
- id: z15.string(),
2121
- name: z15.string(),
2122
- logoUrl: z15.string().nullable(),
2303
+ var vendorSchema = z16.object({
2304
+ id: z16.string(),
2305
+ name: z16.string(),
2306
+ logoUrl: z16.string().nullable(),
2123
2307
  features: vendorFeaturesSchema.optional()
2124
2308
  });
2125
2309
 
@@ -2139,16 +2323,16 @@ var schemas_exports10 = {};
2139
2323
  __export(schemas_exports10, {
2140
2324
  voucherSchema: () => voucherSchema
2141
2325
  });
2142
- import { z as z16 } from "zod";
2143
- var voucherSchema = z16.object({
2144
- id: z16.string(),
2145
- name: z16.string(),
2146
- description: z16.string(),
2147
- code: z16.string(),
2148
- redeemed: z16.boolean(),
2326
+ import { z as z17 } from "zod";
2327
+ var voucherSchema = z17.object({
2328
+ id: z17.string(),
2329
+ name: z17.string(),
2330
+ description: z17.string(),
2331
+ code: z17.string(),
2332
+ redeemed: z17.boolean(),
2149
2333
  redeemsProducts: quantifiable(storefrontProductSchema).array(),
2150
2334
  redeemsBundles: quantifiable(storefrontBundleSchema).array(),
2151
- properties: z16.record(rawPropertyValueSchema).nullish()
2335
+ properties: z17.record(rawPropertyValueSchema).nullish()
2152
2336
  });
2153
2337
 
2154
2338
  // src/vouchers/endpoints.ts
@@ -2349,11 +2533,48 @@ var OfferUtils = class _OfferUtils {
2349
2533
  // src/utils/cart.ts
2350
2534
  var _CartUtils = class _CartUtils {
2351
2535
  // The pricing variation a line item points at, falling back to the item's default variation when
2352
- // the variation id doesn't resolve, which is what the cart has always displayed.
2536
+ // the variation id doesn't resolve, which is what the cart has always displayed. A line upgrading
2537
+ // one of the customer's licenses is priced for that license, as the API prices it.
2353
2538
  static resolveVariation(catalog, item) {
2354
- var _a, _b;
2355
- const source = item.type === "Product" ? catalog.products.find((p) => p.id === item.productId) : catalog.bundles.find((b) => b.id === item.bundleId);
2356
- 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;
2539
+ var _a, _b, _c;
2540
+ if (item.type === "Product") {
2541
+ const product = catalog.products.find((p) => p.id === item.productId);
2542
+ return (_a = _CartUtils.productLineVariation(product, item.variationId, item.targetLicenseId)) != null ? _a : product == null ? void 0 : product.defaultVariation;
2543
+ }
2544
+ const bundle = catalog.bundles.find((b) => b.id === item.bundleId);
2545
+ 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;
2546
+ }
2547
+ /**
2548
+ * The storefront's entry for upgrading or renewing one of the signed-in customer's licenses of a
2549
+ * product: what it covers now, and the variations that would upgrade it, priced for it. Licenses
2550
+ * that cover the same share an entry. `undefined` when the storefront has none for it (the license
2551
+ * is not theirs, covers every release, is past the cap on entries, or the customer is not signed in).
2552
+ */
2553
+ static licenseUpgrade(product, licenseId) {
2554
+ var _a;
2555
+ if (!product || !licenseId)
2556
+ return void 0;
2557
+ const wanted = licenseId.toLowerCase();
2558
+ return (_a = product.licenseUpgrades) == null ? void 0 : _a.find((u) => u.licenseIds.some((id) => id.toLowerCase() === wanted));
2559
+ }
2560
+ /**
2561
+ * The variations that would upgrade or renew one of the signed-in customer's licenses of a
2562
+ * product, priced for that license, or `undefined` when the storefront has no price for it.
2563
+ */
2564
+ static licenseUpgradeVariations(product, licenseId) {
2565
+ var _a;
2566
+ return (_a = _CartUtils.licenseUpgrade(product, licenseId)) == null ? void 0 : _a.variations;
2567
+ }
2568
+ /**
2569
+ * The variation a product line is priced at. A line naming one of the customer's licenses
2570
+ * (`targetLicenseId`) upgrades that license, and an upgrade discount is judged per license, so its
2571
+ * price comes from the product's `licenseUpgrades` for that license. Every other line, and an
2572
+ * upgrade line the storefront has no price for, takes the product's own variation, which is what
2573
+ * a new license costs.
2574
+ */
2575
+ static productLineVariation(product, variationId, targetLicenseId) {
2576
+ var _a, _b, _c;
2577
+ 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);
2357
2578
  }
2358
2579
  // A line's unit price after its product discount and any pricing tier, and *before* any offer.
2359
2580
  // This is the basis the API measures cart total conditions on, which is why it reads the catalog
@@ -2839,6 +3060,7 @@ export {
2839
3060
  OrderStatus,
2840
3061
  PasswordSetupRequiredError,
2841
3062
  Platform,
3063
+ ReleaseNotCoveredError,
2842
3064
  StoreClosedError,
2843
3065
  SubscriptionCancellationReason,
2844
3066
  SubscriptionStatus,