@moonbase.sh/storefront-api 3.9.0 → 3.10.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/README.md +10 -3
- package/dist/index.cjs +385 -229
- package/dist/index.d.cts +5632 -1544
- package/dist/index.d.ts +5632 -1544
- package/dist/index.js +382 -227
- package/package.json +1 -1
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
|
|
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
|
|
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 =
|
|
710
|
-
countryCode:
|
|
711
|
-
streetAddress1:
|
|
712
|
-
streetAddress2:
|
|
713
|
-
locality:
|
|
714
|
-
region:
|
|
715
|
-
postCode:
|
|
716
|
-
});
|
|
717
|
-
var communicationPreferencesSchema =
|
|
718
|
-
newsletterOptIn:
|
|
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:
|
|
815
|
+
productUpdatesOptIn: z9.boolean().default(false)
|
|
722
816
|
});
|
|
723
|
-
var ilokConnectedAccountSchema =
|
|
724
|
-
provider:
|
|
725
|
-
isConnected:
|
|
726
|
-
pendingLicenseFulfillments:
|
|
727
|
-
accountId:
|
|
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 =
|
|
823
|
+
var connectedAccountSchema = z9.discriminatedUnion("provider", [
|
|
730
824
|
ilokConnectedAccountSchema
|
|
731
825
|
]);
|
|
732
|
-
var connectionUrlSchema =
|
|
733
|
-
url:
|
|
826
|
+
var connectionUrlSchema = z9.object({
|
|
827
|
+
url: z9.string()
|
|
734
828
|
});
|
|
735
|
-
var userSchema =
|
|
736
|
-
id:
|
|
737
|
-
email:
|
|
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:
|
|
740
|
-
tenantId:
|
|
833
|
+
name: z9.string().nullable(),
|
|
834
|
+
tenantId: z9.string(),
|
|
741
835
|
address: addressSchema.optional(),
|
|
742
|
-
phone:
|
|
836
|
+
phone: z9.string().optional(),
|
|
743
837
|
communicationPreferences: communicationPreferencesSchema,
|
|
744
|
-
ownedProducts:
|
|
745
|
-
subscribedProducts:
|
|
746
|
-
confirmedAccount:
|
|
747
|
-
hasProducts:
|
|
748
|
-
hasSubscriptions:
|
|
749
|
-
connectedAccounts:
|
|
750
|
-
});
|
|
751
|
-
var identitySchema = userSchema.and(
|
|
752
|
-
accessToken:
|
|
753
|
-
refreshToken:
|
|
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 =
|
|
849
|
+
var userAccountConfirmedStatusSchema = z9.enum([
|
|
756
850
|
"PasswordSetupRequired",
|
|
757
851
|
"SignedIn"
|
|
758
852
|
]);
|
|
759
|
-
var userAccountConfirmedSchema = userSchema.and(
|
|
853
|
+
var userAccountConfirmedSchema = userSchema.and(z9.object({
|
|
760
854
|
status: userAccountConfirmedStatusSchema,
|
|
761
|
-
resetPasswordToken:
|
|
762
|
-
accessToken:
|
|
763
|
-
refreshToken:
|
|
855
|
+
resetPasswordToken: z9.string().nullish(),
|
|
856
|
+
accessToken: z9.string().nullish(),
|
|
857
|
+
refreshToken: z9.string().nullish()
|
|
764
858
|
}));
|
|
765
|
-
var pendingActivationSchema =
|
|
766
|
-
status:
|
|
767
|
-
email:
|
|
859
|
+
var pendingActivationSchema = z9.object({
|
|
860
|
+
status: z9.literal("activation_pending"),
|
|
861
|
+
email: z9.string()
|
|
768
862
|
});
|
|
769
|
-
var pendingPasswordProblemSchema =
|
|
770
|
-
errorType:
|
|
771
|
-
pendingPasswordToken:
|
|
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
|
|
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
|
|
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 =
|
|
998
|
-
type:
|
|
999
|
-
fileName:
|
|
1000
|
-
contentType:
|
|
1001
|
-
data:
|
|
1002
|
-
});
|
|
1003
|
-
var externalLicenseILokContent =
|
|
1004
|
-
type:
|
|
1005
|
-
});
|
|
1006
|
-
var externalLicenseContent =
|
|
1007
|
-
|
|
1008
|
-
|
|
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
|
|
1014
|
-
|
|
1015
|
-
|
|
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:
|
|
1018
|
-
maxNumberOfActivations:
|
|
1125
|
+
activeNumberOfActivations: z10.number(),
|
|
1126
|
+
maxNumberOfActivations: z10.number(),
|
|
1019
1127
|
externalFulfillment: externalLicenseContent.optional(),
|
|
1020
|
-
requiredConnectedAccount:
|
|
1021
|
-
fulfillmentMessage:
|
|
1022
|
-
properties:
|
|
1023
|
-
expiresAt:
|
|
1024
|
-
createdAt:
|
|
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 =
|
|
1027
|
-
id:
|
|
1028
|
-
licenseId:
|
|
1029
|
-
name:
|
|
1030
|
-
status:
|
|
1031
|
-
activationMethod:
|
|
1032
|
-
firstValidatedAt:
|
|
1033
|
-
lastValidatedAt:
|
|
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:
|
|
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
|
|
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,
|
|
1113
|
-
location:
|
|
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
|
|
1229
|
+
import { z as z15 } from "zod";
|
|
1121
1230
|
|
|
1122
1231
|
// package.json
|
|
1123
|
-
var version = "3.
|
|
1232
|
+
var version = "3.10.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,
|
|
@@ -1277,7 +1387,7 @@ __export(schemas_exports8, {
|
|
|
1277
1387
|
milestoneProgressSchema: () => milestoneProgressSchema,
|
|
1278
1388
|
subscriptionSchema: () => subscriptionSchema
|
|
1279
1389
|
});
|
|
1280
|
-
import { z as
|
|
1390
|
+
import { z as z14 } from "zod";
|
|
1281
1391
|
|
|
1282
1392
|
// src/orders/schemas.ts
|
|
1283
1393
|
var schemas_exports7 = {};
|
|
@@ -1291,7 +1401,7 @@ __export(schemas_exports7, {
|
|
|
1291
1401
|
orderSchema: () => orderSchema,
|
|
1292
1402
|
orderTotalSchema: () => orderTotalSchema
|
|
1293
1403
|
});
|
|
1294
|
-
import { z as
|
|
1404
|
+
import { z as z13 } from "zod";
|
|
1295
1405
|
|
|
1296
1406
|
// src/orders/models.ts
|
|
1297
1407
|
var OrderStatus = /* @__PURE__ */ ((OrderStatus2) => {
|
|
@@ -1304,18 +1414,18 @@ var OrderStatus = /* @__PURE__ */ ((OrderStatus2) => {
|
|
|
1304
1414
|
})(OrderStatus || {});
|
|
1305
1415
|
|
|
1306
1416
|
// src/orders/schemas.ts
|
|
1307
|
-
var couponSchema =
|
|
1308
|
-
code:
|
|
1309
|
-
name:
|
|
1310
|
-
description:
|
|
1311
|
-
});
|
|
1312
|
-
var lineItemProductSchema =
|
|
1313
|
-
id:
|
|
1314
|
-
name:
|
|
1315
|
-
tagline:
|
|
1316
|
-
iconUrl:
|
|
1317
|
-
});
|
|
1318
|
-
var lineItemTotalSchema =
|
|
1417
|
+
var couponSchema = z13.object({
|
|
1418
|
+
code: z13.string(),
|
|
1419
|
+
name: z13.string(),
|
|
1420
|
+
description: z13.string()
|
|
1421
|
+
});
|
|
1422
|
+
var lineItemProductSchema = z13.object({
|
|
1423
|
+
id: z13.string(),
|
|
1424
|
+
name: z13.string(),
|
|
1425
|
+
tagline: z13.string().nullish(),
|
|
1426
|
+
iconUrl: z13.string().nullable()
|
|
1427
|
+
});
|
|
1428
|
+
var lineItemTotalSchema = z13.object({
|
|
1319
1429
|
original: moneySchema,
|
|
1320
1430
|
discount: moneySchema,
|
|
1321
1431
|
subtotal: moneySchema,
|
|
@@ -1324,52 +1434,59 @@ var lineItemTotalSchema = z12.object({
|
|
|
1324
1434
|
// for this item. Both are part of `discount`. Absent on orders priced before cart offers existed.
|
|
1325
1435
|
cartOfferDiscount: moneySchema.optional()
|
|
1326
1436
|
});
|
|
1327
|
-
var openProductLineItem =
|
|
1328
|
-
id:
|
|
1329
|
-
type:
|
|
1330
|
-
productId:
|
|
1331
|
-
quantity:
|
|
1332
|
-
variationId:
|
|
1333
|
-
offerId:
|
|
1334
|
-
isDefaultVariation:
|
|
1335
|
-
isSubcriptionPayment:
|
|
1437
|
+
var openProductLineItem = z13.object({
|
|
1438
|
+
id: z13.string(),
|
|
1439
|
+
type: z13.literal("Product"),
|
|
1440
|
+
productId: z13.string(),
|
|
1441
|
+
quantity: z13.number(),
|
|
1442
|
+
variationId: z13.string(),
|
|
1443
|
+
offerId: z13.string().optional(),
|
|
1444
|
+
isDefaultVariation: z13.boolean().nullish(),
|
|
1445
|
+
isSubcriptionPayment: z13.boolean().nullish(),
|
|
1336
1446
|
price: priceCollectionSchema.optional(),
|
|
1337
1447
|
variation: pricingVariationSchema.optional(),
|
|
1338
1448
|
total: lineItemTotalSchema.nullish(),
|
|
1339
1449
|
product: lineItemProductSchema.optional(),
|
|
1340
|
-
appliedDiscount: discountSchema.optional()
|
|
1450
|
+
appliedDiscount: discountSchema.optional(),
|
|
1451
|
+
// The customer's license this line upgrades or renews, as the cart named it. Such a line is one
|
|
1452
|
+
// license, so its quantity is always 1, and the line's `id` names the license too
|
|
1453
|
+
// (`p/<productId>/<variationId>/<licenseId>`): upgrading two licenses takes two lines. A line
|
|
1454
|
+
// without one issues new licenses. Part of the cart payload like `offerId`, so a push that leaves
|
|
1455
|
+
// it out forgets it. Echoed on completed orders too. Absent from a backend that predates release
|
|
1456
|
+
// access.
|
|
1457
|
+
targetLicenseId: z13.string().nullish().catch(void 0)
|
|
1341
1458
|
});
|
|
1342
|
-
var lineItemBundleSchema =
|
|
1343
|
-
id:
|
|
1344
|
-
name:
|
|
1345
|
-
tagline:
|
|
1346
|
-
iconUrl:
|
|
1347
|
-
products: lineItemProductSchema.and(
|
|
1348
|
-
included:
|
|
1459
|
+
var lineItemBundleSchema = z13.object({
|
|
1460
|
+
id: z13.string(),
|
|
1461
|
+
name: z13.string(),
|
|
1462
|
+
tagline: z13.string().nullish(),
|
|
1463
|
+
iconUrl: z13.string().nullable(),
|
|
1464
|
+
products: lineItemProductSchema.and(z13.object({
|
|
1465
|
+
included: z13.boolean().optional()
|
|
1349
1466
|
})).array()
|
|
1350
1467
|
});
|
|
1351
|
-
var openBundleLineItem =
|
|
1352
|
-
id:
|
|
1353
|
-
type:
|
|
1354
|
-
bundleId:
|
|
1355
|
-
quantity:
|
|
1356
|
-
variationId:
|
|
1357
|
-
offerId:
|
|
1358
|
-
partial:
|
|
1359
|
-
replaced:
|
|
1360
|
-
isDefaultVariation:
|
|
1361
|
-
isSubcriptionPayment:
|
|
1468
|
+
var openBundleLineItem = z13.object({
|
|
1469
|
+
id: z13.string(),
|
|
1470
|
+
type: z13.literal("Bundle"),
|
|
1471
|
+
bundleId: z13.string(),
|
|
1472
|
+
quantity: z13.number(),
|
|
1473
|
+
variationId: z13.string(),
|
|
1474
|
+
offerId: z13.string().optional(),
|
|
1475
|
+
partial: z13.boolean().optional(),
|
|
1476
|
+
replaced: z13.string().array().optional(),
|
|
1477
|
+
isDefaultVariation: z13.boolean().nullish(),
|
|
1478
|
+
isSubcriptionPayment: z13.boolean().nullish(),
|
|
1362
1479
|
price: priceCollectionSchema.optional(),
|
|
1363
1480
|
variation: pricingVariationSchema.optional(),
|
|
1364
1481
|
total: lineItemTotalSchema.nullish(),
|
|
1365
1482
|
bundle: lineItemBundleSchema.optional(),
|
|
1366
1483
|
appliedDiscount: discountSchema.optional()
|
|
1367
1484
|
});
|
|
1368
|
-
var openOrderLineItem =
|
|
1485
|
+
var openOrderLineItem = z13.discriminatedUnion("type", [
|
|
1369
1486
|
openProductLineItem,
|
|
1370
1487
|
openBundleLineItem
|
|
1371
1488
|
]);
|
|
1372
|
-
var orderTotalSchema =
|
|
1489
|
+
var orderTotalSchema = z13.object({
|
|
1373
1490
|
original: moneySchema,
|
|
1374
1491
|
discount: moneySchema,
|
|
1375
1492
|
subtotal: moneySchema,
|
|
@@ -1379,52 +1496,52 @@ var orderTotalSchema = z12.object({
|
|
|
1379
1496
|
// rather than a share on every line. Absent when no cart offer applied.
|
|
1380
1497
|
cartOfferDiscount: moneySchema.optional()
|
|
1381
1498
|
});
|
|
1382
|
-
var openOrderSchema =
|
|
1383
|
-
id:
|
|
1384
|
-
currency:
|
|
1499
|
+
var openOrderSchema = z13.object({
|
|
1500
|
+
id: z13.string(),
|
|
1501
|
+
currency: z13.string(),
|
|
1385
1502
|
total: orderTotalSchema.nullish(),
|
|
1386
1503
|
items: openOrderLineItem.array(),
|
|
1387
1504
|
couponsApplied: couponSchema.array(),
|
|
1388
1505
|
// The cart offer on the order as a whole: the buyer's intent. It is part of the cart payload, so
|
|
1389
1506
|
// a content push that leaves it out clears it. The API echoes it back even while the cart sits
|
|
1390
1507
|
// below the offer's threshold.
|
|
1391
|
-
offerId:
|
|
1508
|
+
offerId: z13.string().optional(),
|
|
1392
1509
|
// The cart offer as actually applied: the result. Absent while the offer's condition doesn't hold.
|
|
1393
1510
|
appliedOffer: discountSchema.optional(),
|
|
1394
|
-
checkoutUrl:
|
|
1395
|
-
hostedCheckoutUrl:
|
|
1396
|
-
embeddedCheckoutUrl:
|
|
1397
|
-
});
|
|
1398
|
-
var customerSnapshotSchema =
|
|
1399
|
-
name:
|
|
1400
|
-
businessName:
|
|
1401
|
-
taxId:
|
|
1402
|
-
email:
|
|
1403
|
-
phone:
|
|
1511
|
+
checkoutUrl: z13.string().optional(),
|
|
1512
|
+
hostedCheckoutUrl: z13.string().optional(),
|
|
1513
|
+
embeddedCheckoutUrl: z13.string().optional()
|
|
1514
|
+
});
|
|
1515
|
+
var customerSnapshotSchema = z13.object({
|
|
1516
|
+
name: z13.string().nullable(),
|
|
1517
|
+
businessName: z13.string().nullable(),
|
|
1518
|
+
taxId: z13.string().nullable(),
|
|
1519
|
+
email: z13.string().nullable(),
|
|
1520
|
+
phone: z13.string().nullable(),
|
|
1404
1521
|
address: addressSchema.nullable()
|
|
1405
1522
|
});
|
|
1406
|
-
var completedOrderSchema =
|
|
1407
|
-
id:
|
|
1408
|
-
status:
|
|
1409
|
-
currency:
|
|
1523
|
+
var completedOrderSchema = z13.object({
|
|
1524
|
+
id: z13.string(),
|
|
1525
|
+
status: z13.literal("Completed" /* Completed */),
|
|
1526
|
+
currency: z13.string(),
|
|
1410
1527
|
customer: customerSnapshotSchema,
|
|
1411
1528
|
total: orderTotalSchema,
|
|
1412
1529
|
items: openOrderLineItem.array(),
|
|
1413
1530
|
couponsApplied: couponSchema.array(),
|
|
1414
1531
|
appliedOffer: discountSchema.optional()
|
|
1415
1532
|
});
|
|
1416
|
-
var orderSchema =
|
|
1533
|
+
var orderSchema = z13.discriminatedUnion("status", [
|
|
1417
1534
|
openOrderSchema.extend({
|
|
1418
|
-
status:
|
|
1535
|
+
status: z13.literal("Open" /* Open */)
|
|
1419
1536
|
}),
|
|
1420
1537
|
openOrderSchema.extend({
|
|
1421
|
-
status:
|
|
1538
|
+
status: z13.literal("PaymentProcessing" /* PaymentProcessing */)
|
|
1422
1539
|
}),
|
|
1423
1540
|
openOrderSchema.extend({
|
|
1424
|
-
status:
|
|
1541
|
+
status: z13.literal("Paid" /* Paid */)
|
|
1425
1542
|
}),
|
|
1426
1543
|
openOrderSchema.extend({
|
|
1427
|
-
status:
|
|
1544
|
+
status: z13.literal("Failed" /* Failed */)
|
|
1428
1545
|
}),
|
|
1429
1546
|
completedOrderSchema
|
|
1430
1547
|
]);
|
|
@@ -1448,58 +1565,58 @@ var SubscriptionCancellationReason = /* @__PURE__ */ ((SubscriptionCancellationR
|
|
|
1448
1565
|
})(SubscriptionCancellationReason || {});
|
|
1449
1566
|
|
|
1450
1567
|
// src/inventory/subscriptions/schemas.ts
|
|
1451
|
-
var baseMilestoneProgressEventSchema =
|
|
1452
|
-
milestoneId:
|
|
1453
|
-
fulfilled:
|
|
1454
|
-
afterCycleNumber:
|
|
1455
|
-
afterNormalizedCycleNumber:
|
|
1456
|
-
message:
|
|
1457
|
-
});
|
|
1458
|
-
var milestoneProgressEventSchema =
|
|
1568
|
+
var baseMilestoneProgressEventSchema = z14.object({
|
|
1569
|
+
milestoneId: z14.string(),
|
|
1570
|
+
fulfilled: z14.boolean(),
|
|
1571
|
+
afterCycleNumber: z14.number(),
|
|
1572
|
+
afterNormalizedCycleNumber: z14.number(),
|
|
1573
|
+
message: z14.string().optional()
|
|
1574
|
+
});
|
|
1575
|
+
var milestoneProgressEventSchema = z14.discriminatedUnion("type", [
|
|
1459
1576
|
baseMilestoneProgressEventSchema.extend({
|
|
1460
|
-
type:
|
|
1461
|
-
code:
|
|
1462
|
-
redeemed:
|
|
1577
|
+
type: z14.literal("CouponCodeMilestone"),
|
|
1578
|
+
code: z14.string().optional(),
|
|
1579
|
+
redeemed: z14.boolean().optional()
|
|
1463
1580
|
}),
|
|
1464
1581
|
baseMilestoneProgressEventSchema.extend({
|
|
1465
|
-
type:
|
|
1582
|
+
type: z14.literal("PerpetualLicenseConversionMilestone")
|
|
1466
1583
|
})
|
|
1467
1584
|
]);
|
|
1468
|
-
var milestoneProgressSchema =
|
|
1469
|
-
title:
|
|
1470
|
-
description:
|
|
1471
|
-
currentCycleNumber:
|
|
1472
|
-
currentNormalizedCycleNumber:
|
|
1473
|
-
currentCycleIsCompleted:
|
|
1474
|
-
fromCycleNumber:
|
|
1475
|
-
fromNormalizedCycleNumber:
|
|
1476
|
-
toCycleNumber:
|
|
1477
|
-
toNormalizedCycleNumber:
|
|
1478
|
-
events:
|
|
1479
|
-
});
|
|
1480
|
-
var subscriptionSchema =
|
|
1481
|
-
id:
|
|
1482
|
-
status:
|
|
1483
|
-
hasPaymentMethod:
|
|
1484
|
-
cancellable:
|
|
1485
|
-
expiresAt:
|
|
1486
|
-
renewedAt:
|
|
1487
|
-
nextPaymentScheduledAt:
|
|
1488
|
-
startedAt:
|
|
1585
|
+
var milestoneProgressSchema = z14.object({
|
|
1586
|
+
title: z14.string(),
|
|
1587
|
+
description: z14.string().nullish(),
|
|
1588
|
+
currentCycleNumber: z14.number(),
|
|
1589
|
+
currentNormalizedCycleNumber: z14.number(),
|
|
1590
|
+
currentCycleIsCompleted: z14.boolean(),
|
|
1591
|
+
fromCycleNumber: z14.number(),
|
|
1592
|
+
fromNormalizedCycleNumber: z14.number(),
|
|
1593
|
+
toCycleNumber: z14.number(),
|
|
1594
|
+
toNormalizedCycleNumber: z14.number(),
|
|
1595
|
+
events: z14.record(z14.coerce.number(), milestoneProgressEventSchema.array())
|
|
1596
|
+
});
|
|
1597
|
+
var subscriptionSchema = z14.object({
|
|
1598
|
+
id: z14.string(),
|
|
1599
|
+
status: z14.nativeEnum(SubscriptionStatus),
|
|
1600
|
+
hasPaymentMethod: z14.boolean(),
|
|
1601
|
+
cancellable: z14.boolean(),
|
|
1602
|
+
expiresAt: z14.coerce.date(),
|
|
1603
|
+
renewedAt: z14.coerce.date().nullable(),
|
|
1604
|
+
nextPaymentScheduledAt: z14.coerce.date().nullable(),
|
|
1605
|
+
startedAt: z14.coerce.date(),
|
|
1489
1606
|
total: orderTotalSchema,
|
|
1490
|
-
cycleLength:
|
|
1491
|
-
paymentMethod:
|
|
1607
|
+
cycleLength: z14.nativeEnum(CycleLength),
|
|
1608
|
+
paymentMethod: z14.string().optional(),
|
|
1492
1609
|
milestoneProgress: milestoneProgressSchema.nullish(),
|
|
1493
|
-
embeddedUpdatePaymentUrl:
|
|
1494
|
-
content:
|
|
1495
|
-
|
|
1496
|
-
type:
|
|
1497
|
-
quantity:
|
|
1610
|
+
embeddedUpdatePaymentUrl: z14.string().optional(),
|
|
1611
|
+
content: z14.discriminatedUnion("type", [
|
|
1612
|
+
z14.object({
|
|
1613
|
+
type: z14.literal("Product"),
|
|
1614
|
+
quantity: z14.number(),
|
|
1498
1615
|
product: storefrontProductSchema
|
|
1499
1616
|
}),
|
|
1500
|
-
|
|
1501
|
-
type:
|
|
1502
|
-
quantity:
|
|
1617
|
+
z14.object({
|
|
1618
|
+
type: z14.literal("Bundle"),
|
|
1619
|
+
quantity: z14.number(),
|
|
1503
1620
|
bundle: storefrontBundleSchema
|
|
1504
1621
|
})
|
|
1505
1622
|
])
|
|
@@ -1535,8 +1652,8 @@ var SubscriptionEndpoints = class {
|
|
|
1535
1652
|
return response.data;
|
|
1536
1653
|
}
|
|
1537
1654
|
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"}`,
|
|
1539
|
-
location:
|
|
1655
|
+
const response = await this.api.authenticatedFetch(`/api/customer/inventory/subscriptions/${subscriptionId}/renew?redirect=false&return=${returnUrl}&embedded=${embedded ? "true" : "false"}`, z15.object({
|
|
1656
|
+
location: z15.string()
|
|
1540
1657
|
}), { method: "POST" });
|
|
1541
1658
|
return response.data;
|
|
1542
1659
|
}
|
|
@@ -2105,21 +2222,21 @@ __export(schemas_exports9, {
|
|
|
2105
2222
|
vendorFeaturesSchema: () => vendorFeaturesSchema,
|
|
2106
2223
|
vendorSchema: () => vendorSchema
|
|
2107
2224
|
});
|
|
2108
|
-
import { z as
|
|
2109
|
-
var vendorCaptchaSchema =
|
|
2110
|
-
url:
|
|
2225
|
+
import { z as z16 } from "zod";
|
|
2226
|
+
var vendorCaptchaSchema = z16.object({
|
|
2227
|
+
url: z16.string()
|
|
2111
2228
|
});
|
|
2112
|
-
var vendorFeaturesSchema =
|
|
2113
|
-
customerPortal:
|
|
2114
|
-
phoneNumber:
|
|
2115
|
-
marketingConsent:
|
|
2229
|
+
var vendorFeaturesSchema = z16.object({
|
|
2230
|
+
customerPortal: z16.boolean().optional(),
|
|
2231
|
+
phoneNumber: z16.boolean().optional(),
|
|
2232
|
+
marketingConsent: z16.nativeEnum(MarketingConsentType).optional().catch(void 0),
|
|
2116
2233
|
// Absent on backends from before captchas, which never ask for one.
|
|
2117
2234
|
captcha: vendorCaptchaSchema.nullish()
|
|
2118
2235
|
});
|
|
2119
|
-
var vendorSchema =
|
|
2120
|
-
id:
|
|
2121
|
-
name:
|
|
2122
|
-
logoUrl:
|
|
2236
|
+
var vendorSchema = z16.object({
|
|
2237
|
+
id: z16.string(),
|
|
2238
|
+
name: z16.string(),
|
|
2239
|
+
logoUrl: z16.string().nullable(),
|
|
2123
2240
|
features: vendorFeaturesSchema.optional()
|
|
2124
2241
|
});
|
|
2125
2242
|
|
|
@@ -2139,16 +2256,16 @@ var schemas_exports10 = {};
|
|
|
2139
2256
|
__export(schemas_exports10, {
|
|
2140
2257
|
voucherSchema: () => voucherSchema
|
|
2141
2258
|
});
|
|
2142
|
-
import { z as
|
|
2143
|
-
var voucherSchema =
|
|
2144
|
-
id:
|
|
2145
|
-
name:
|
|
2146
|
-
description:
|
|
2147
|
-
code:
|
|
2148
|
-
redeemed:
|
|
2259
|
+
import { z as z17 } from "zod";
|
|
2260
|
+
var voucherSchema = z17.object({
|
|
2261
|
+
id: z17.string(),
|
|
2262
|
+
name: z17.string(),
|
|
2263
|
+
description: z17.string(),
|
|
2264
|
+
code: z17.string(),
|
|
2265
|
+
redeemed: z17.boolean(),
|
|
2149
2266
|
redeemsProducts: quantifiable(storefrontProductSchema).array(),
|
|
2150
2267
|
redeemsBundles: quantifiable(storefrontBundleSchema).array(),
|
|
2151
|
-
properties:
|
|
2268
|
+
properties: z17.record(rawPropertyValueSchema).nullish()
|
|
2152
2269
|
});
|
|
2153
2270
|
|
|
2154
2271
|
// src/vouchers/endpoints.ts
|
|
@@ -2349,11 +2466,48 @@ var OfferUtils = class _OfferUtils {
|
|
|
2349
2466
|
// src/utils/cart.ts
|
|
2350
2467
|
var _CartUtils = class _CartUtils {
|
|
2351
2468
|
// 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.
|
|
2469
|
+
// the variation id doesn't resolve, which is what the cart has always displayed. A line upgrading
|
|
2470
|
+
// one of the customer's licenses is priced for that license, as the API prices it.
|
|
2353
2471
|
static resolveVariation(catalog, item) {
|
|
2354
|
-
var _a, _b;
|
|
2355
|
-
|
|
2356
|
-
|
|
2472
|
+
var _a, _b, _c;
|
|
2473
|
+
if (item.type === "Product") {
|
|
2474
|
+
const product = catalog.products.find((p) => p.id === item.productId);
|
|
2475
|
+
return (_a = _CartUtils.productLineVariation(product, item.variationId, item.targetLicenseId)) != null ? _a : product == null ? void 0 : product.defaultVariation;
|
|
2476
|
+
}
|
|
2477
|
+
const bundle = catalog.bundles.find((b) => b.id === item.bundleId);
|
|
2478
|
+
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;
|
|
2479
|
+
}
|
|
2480
|
+
/**
|
|
2481
|
+
* The storefront's entry for upgrading or renewing one of the signed-in customer's licenses of a
|
|
2482
|
+
* product: what it covers now, and the variations that would upgrade it, priced for it. Licenses
|
|
2483
|
+
* that cover the same share an entry. `undefined` when the storefront has none for it (the license
|
|
2484
|
+
* is not theirs, covers every release, is past the cap on entries, or the customer is not signed in).
|
|
2485
|
+
*/
|
|
2486
|
+
static licenseUpgrade(product, licenseId) {
|
|
2487
|
+
var _a;
|
|
2488
|
+
if (!product || !licenseId)
|
|
2489
|
+
return void 0;
|
|
2490
|
+
const wanted = licenseId.toLowerCase();
|
|
2491
|
+
return (_a = product.licenseUpgrades) == null ? void 0 : _a.find((u) => u.licenseIds.some((id) => id.toLowerCase() === wanted));
|
|
2492
|
+
}
|
|
2493
|
+
/**
|
|
2494
|
+
* The variations that would upgrade or renew one of the signed-in customer's licenses of a
|
|
2495
|
+
* product, priced for that license, or `undefined` when the storefront has no price for it.
|
|
2496
|
+
*/
|
|
2497
|
+
static licenseUpgradeVariations(product, licenseId) {
|
|
2498
|
+
var _a;
|
|
2499
|
+
return (_a = _CartUtils.licenseUpgrade(product, licenseId)) == null ? void 0 : _a.variations;
|
|
2500
|
+
}
|
|
2501
|
+
/**
|
|
2502
|
+
* The variation a product line is priced at. A line naming one of the customer's licenses
|
|
2503
|
+
* (`targetLicenseId`) upgrades that license, and an upgrade discount is judged per license, so its
|
|
2504
|
+
* price comes from the product's `licenseUpgrades` for that license. Every other line, and an
|
|
2505
|
+
* upgrade line the storefront has no price for, takes the product's own variation, which is what
|
|
2506
|
+
* a new license costs.
|
|
2507
|
+
*/
|
|
2508
|
+
static productLineVariation(product, variationId, targetLicenseId) {
|
|
2509
|
+
var _a, _b, _c;
|
|
2510
|
+
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
2511
|
}
|
|
2358
2512
|
// A line's unit price after its product discount and any pricing tier, and *before* any offer.
|
|
2359
2513
|
// This is the basis the API measures cart total conditions on, which is why it reads the catalog
|
|
@@ -2839,6 +2993,7 @@ export {
|
|
|
2839
2993
|
OrderStatus,
|
|
2840
2994
|
PasswordSetupRequiredError,
|
|
2841
2995
|
Platform,
|
|
2996
|
+
ReleaseNotCoveredError,
|
|
2842
2997
|
StoreClosedError,
|
|
2843
2998
|
SubscriptionCancellationReason,
|
|
2844
2999
|
SubscriptionStatus,
|