@moonbase.sh/storefront-api 0.0.0-next-20260526085904

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 ADDED
@@ -0,0 +1,1723 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __export = (target, all) => {
3
+ for (var name in all)
4
+ __defProp(target, name, { get: all[name], enumerable: true });
5
+ };
6
+
7
+ // src/activationRequests/endpoints.ts
8
+ import { z as z5 } from "zod";
9
+
10
+ // src/activationRequests/schemas.ts
11
+ var schemas_exports3 = {};
12
+ __export(schemas_exports3, {
13
+ activationRequestSchema: () => activationRequestSchema
14
+ });
15
+ import { z as z4 } from "zod";
16
+
17
+ // src/storefront/schemas.ts
18
+ var schemas_exports2 = {};
19
+ __export(schemas_exports2, {
20
+ offerConditionSchema: () => offerConditionSchema,
21
+ storefrontBundleSchema: () => storefrontBundleSchema,
22
+ storefrontOfferSchema: () => storefrontOfferSchema,
23
+ storefrontProductSchema: () => storefrontProductSchema,
24
+ storefrontSchema: () => storefrontSchema,
25
+ taxEstimateSchema: () => taxEstimateSchema
26
+ });
27
+ import { z as z3 } from "zod";
28
+
29
+ // src/globalSchemas.ts
30
+ import { z } from "zod";
31
+
32
+ // src/globalModels.ts
33
+ var CycleLength = /* @__PURE__ */ ((CycleLength2) => {
34
+ CycleLength2["Daily"] = "Daily";
35
+ CycleLength2["Weekly"] = "Weekly";
36
+ CycleLength2["Monthly"] = "Monthly";
37
+ CycleLength2["Quarterly"] = "Quarterly";
38
+ CycleLength2["Yearly"] = "Yearly";
39
+ return CycleLength2;
40
+ })(CycleLength || {});
41
+ var MarketingConsentType = /* @__PURE__ */ ((MarketingConsentType2) => {
42
+ MarketingConsentType2["OptIn"] = "OptIn";
43
+ MarketingConsentType2["OptedInByDefault"] = "OptedInByDefault";
44
+ MarketingConsentType2["OptOut"] = "OptOut";
45
+ return MarketingConsentType2;
46
+ })(MarketingConsentType || {});
47
+ function utmToObject(utm) {
48
+ return Object.entries({
49
+ utm_source: utm == null ? void 0 : utm.source,
50
+ utm_medium: utm == null ? void 0 : utm.medium,
51
+ utm_campaign: utm == null ? void 0 : utm.campaign,
52
+ utm_term: utm == null ? void 0 : utm.term,
53
+ utm_content: utm == null ? void 0 : utm.content,
54
+ utm_referrer: utm == null ? void 0 : utm.referrer
55
+ }).filter(([_, value]) => value !== void 0).reduce((obj, [key, value]) => ({
56
+ ...obj,
57
+ [key]: value
58
+ }), {});
59
+ }
60
+
61
+ // src/globalSchemas.ts
62
+ var priceCollectionSchema = z.record(z.number());
63
+ var percentageOffDiscountSchema = z.object({
64
+ type: z.literal("PercentageOffDiscount"),
65
+ name: z.string(),
66
+ description: z.string().optional(),
67
+ percentage: z.number(),
68
+ total: priceCollectionSchema.optional(),
69
+ isExclusive: z.boolean(),
70
+ recurringPaymentUseCount: z.number().optional()
71
+ });
72
+ var flatAmountOffDiscountSchema = z.object({
73
+ type: z.literal("FlatAmountOffDiscount"),
74
+ name: z.string(),
75
+ description: z.string().optional(),
76
+ total: priceCollectionSchema.optional(),
77
+ isExclusive: z.boolean(),
78
+ recurringPaymentUseCount: z.number().optional()
79
+ });
80
+ var moneySchema = z.object({
81
+ currency: z.string(),
82
+ amount: z.number()
83
+ });
84
+ var discountSchema = z.discriminatedUnion("type", [
85
+ percentageOffDiscountSchema,
86
+ flatAmountOffDiscountSchema
87
+ ]);
88
+ var recurrenceSchema = z.discriminatedUnion("type", [
89
+ z.object({ type: z.literal("OneOff") }),
90
+ z.object({ type: z.literal("Recurring"), cycleLength: z.nativeEnum(CycleLength) })
91
+ ]);
92
+ var pricingTierSchema = z.object({
93
+ minQuantity: z.number(),
94
+ originalPrice: priceCollectionSchema,
95
+ price: priceCollectionSchema
96
+ });
97
+ var pricingVariationSchema = z.object({
98
+ id: z.string(),
99
+ name: z.string(),
100
+ originalPrice: priceCollectionSchema,
101
+ price: priceCollectionSchema,
102
+ hasDiscount: z.boolean(),
103
+ discount: discountSchema.optional(),
104
+ recurrence: recurrenceSchema,
105
+ pricingTiers: z.array(pricingTierSchema).nullish()
106
+ });
107
+ var rawPropertyValueSchema = z.lazy(
108
+ () => z.union([z.string(), z.number(), z.boolean(), z.record(rawPropertyValueSchema)])
109
+ );
110
+ function paged(itemSchema) {
111
+ return z.object({
112
+ items: z.array(itemSchema),
113
+ hasMore: z.boolean(),
114
+ next: z.string().nullable()
115
+ });
116
+ }
117
+ function quantifiable(itemSchema) {
118
+ return z.object({
119
+ value: itemSchema,
120
+ quantity: z.number()
121
+ });
122
+ }
123
+ function singleOrMultiple(schema) {
124
+ return z.union([schema, z.array(schema)]);
125
+ }
126
+
127
+ // src/inventory/products/schemas.ts
128
+ var schemas_exports = {};
129
+ __export(schemas_exports, {
130
+ downloadSchema: () => downloadSchema,
131
+ manifestSchema: () => manifestSchema,
132
+ productSummarySchema: () => productSummarySchema
133
+ });
134
+ import { z as z2 } from "zod";
135
+
136
+ // src/inventory/products/models.ts
137
+ var Platform = /* @__PURE__ */ ((Platform2) => {
138
+ Platform2["Universal"] = "Universal";
139
+ Platform2["Windows"] = "Windows";
140
+ Platform2["Linux"] = "Linux";
141
+ Platform2["Mac"] = "Mac";
142
+ Platform2["iOS"] = "iOS";
143
+ Platform2["Android"] = "Android";
144
+ return Platform2;
145
+ })(Platform || {});
146
+ var Architecture = /* @__PURE__ */ ((Architecture2) => {
147
+ Architecture2["Unknown"] = "Unknown";
148
+ Architecture2["Universal"] = "Universal";
149
+ Architecture2["X86"] = "X86";
150
+ Architecture2["X64"] = "X64";
151
+ Architecture2["Arm"] = "Arm";
152
+ Architecture2["Arm64"] = "Arm64";
153
+ return Architecture2;
154
+ })(Architecture || {});
155
+
156
+ // src/inventory/products/schemas.ts
157
+ var manifestSchema = z2.object({
158
+ files: z2.object({
159
+ name: z2.string(),
160
+ path: z2.string()
161
+ }).array(),
162
+ licensePath: z2.string().nullable()
163
+ });
164
+ var downloadSchema = z2.object({
165
+ name: z2.string(),
166
+ key: z2.string(),
167
+ platform: z2.nativeEnum(Platform),
168
+ arch: z2.nativeEnum(Architecture).nullish(),
169
+ size: z2.number(),
170
+ path: z2.string().nullable(),
171
+ manifest: manifestSchema.optional()
172
+ });
173
+ var productSummarySchema = z2.object({
174
+ id: z2.string(),
175
+ name: z2.string(),
176
+ tagline: z2.string(),
177
+ description: z2.string().nullish(),
178
+ website: z2.string().optional(),
179
+ iconUrl: z2.string().optional(),
180
+ numberOfLicenses: z2.number().optional(),
181
+ numberOfTrials: z2.number().optional(),
182
+ currentActivations: z2.number().optional(),
183
+ maxActivations: z2.number().optional(),
184
+ externalLicenses: z2.number().optional(),
185
+ subscriptionLicenses: z2.number().optional(),
186
+ currentVersion: z2.string().nullable(),
187
+ version: z2.string().optional(),
188
+ prerelease: z2.boolean().optional(),
189
+ releaseDescription: z2.string().optional(),
190
+ downloadsNeedsUser: z2.boolean(),
191
+ downloadsNeedsOwnership: z2.boolean(),
192
+ downloads: z2.array(downloadSchema).optional()
193
+ });
194
+
195
+ // src/storefront/schemas.ts
196
+ var storefrontProductSchema = z3.object({
197
+ id: z3.string(),
198
+ name: z3.string(),
199
+ tagline: z3.string(),
200
+ description: z3.string(),
201
+ iconUrl: z3.string().nullable(),
202
+ website: z3.string().nullish(),
203
+ owned: z3.boolean(),
204
+ currentVersion: z3.string().optional(),
205
+ downloads: downloadSchema.array().optional(),
206
+ defaultVariation: pricingVariationSchema.optional(),
207
+ variations: pricingVariationSchema.array().optional(),
208
+ properties: z3.record(rawPropertyValueSchema).nullish(),
209
+ type: z3.string().optional().default("Product").pipe(z3.literal("Product"))
210
+ });
211
+ var storefrontBundleSchema = z3.object({
212
+ id: z3.string(),
213
+ name: z3.string(),
214
+ tagline: z3.string(),
215
+ description: z3.string(),
216
+ iconUrl: z3.string().nullable(),
217
+ owned: z3.boolean(),
218
+ partial: z3.boolean(),
219
+ products: storefrontProductSchema.and(z3.object({
220
+ included: z3.boolean().optional()
221
+ })).array(),
222
+ defaultVariation: pricingVariationSchema.optional(),
223
+ variations: pricingVariationSchema.array().optional(),
224
+ properties: z3.record(rawPropertyValueSchema).nullish(),
225
+ type: z3.string().optional().default("Bundle").pipe(z3.literal("Bundle"))
226
+ });
227
+ var cartContainsItemsConditionSchema = z3.object({
228
+ type: z3.literal("CartContainsItems"),
229
+ minimumItems: z3.number(),
230
+ relevantItemVariations: z3.record(z3.string(), z3.string().array())
231
+ });
232
+ var offerConditionSchema = z3.discriminatedUnion("type", [cartContainsItemsConditionSchema]);
233
+ var storefrontOfferSchema = z3.object({
234
+ id: z3.string(),
235
+ target: singleOrMultiple(z3.union([storefrontProductSchema, storefrontBundleSchema])),
236
+ targetVariations: z3.string().array(),
237
+ condition: offerConditionSchema,
238
+ discount: discountSchema
239
+ });
240
+ var taxEstimateSchema = z3.object({
241
+ rate: z3.number(),
242
+ mode: z3.enum(["Exclusive", "Inclusive"]),
243
+ countryCode: z3.string(),
244
+ region: z3.string().optional()
245
+ });
246
+ var storefrontSchema = z3.object({
247
+ suggestedCurrency: z3.string(),
248
+ // Enabled currencies need to be optional since we may still have old, cached representations in browsers
249
+ enabledCurrencies: z3.string().array().optional(),
250
+ products: storefrontProductSchema.array(),
251
+ bundles: storefrontBundleSchema.array(),
252
+ // Offers need to be optional since we may still have old, cached representations in browsers
253
+ offers: storefrontOfferSchema.array().optional(),
254
+ // Depending on circumstances, we may have a tax estimate available
255
+ estimatedTax: taxEstimateSchema.optional()
256
+ });
257
+
258
+ // src/activationRequests/models.ts
259
+ var ActivationRequestFulfillmentType = /* @__PURE__ */ ((ActivationRequestFulfillmentType2) => {
260
+ ActivationRequestFulfillmentType2["License"] = "License";
261
+ ActivationRequestFulfillmentType2["Trial"] = "Trial";
262
+ return ActivationRequestFulfillmentType2;
263
+ })(ActivationRequestFulfillmentType || {});
264
+ var ActivationRequestStatus = /* @__PURE__ */ ((ActivationRequestStatus2) => {
265
+ ActivationRequestStatus2["Requested"] = "Requested";
266
+ ActivationRequestStatus2["Fulfilled"] = "Fulfilled";
267
+ ActivationRequestStatus2["Completed"] = "Completed";
268
+ ActivationRequestStatus2["Cancelled"] = "Cancelled";
269
+ return ActivationRequestStatus2;
270
+ })(ActivationRequestStatus || {});
271
+
272
+ // src/activationRequests/schemas.ts
273
+ var activationRequestSchema = z4.object({
274
+ id: z4.string(),
275
+ status: z4.nativeEnum(ActivationRequestStatus),
276
+ product: storefrontProductSchema,
277
+ fulfillmentType: z4.nativeEnum(ActivationRequestFulfillmentType).optional(),
278
+ trialEligibility: z4.object({
279
+ eligible: z4.boolean(),
280
+ existing: z4.boolean(),
281
+ requiresAccount: z4.boolean(),
282
+ requiresNewsletterOptIn: z4.boolean(),
283
+ numberOfDaysPerProduct: z4.number(),
284
+ numberOfDaysRemaining: z4.number()
285
+ }).optional(),
286
+ licenseEligibility: z4.object({
287
+ eligible: z4.boolean()
288
+ }).optional()
289
+ });
290
+
291
+ // src/activationRequests/endpoints.ts
292
+ var ActivationRequestEndpoints = class {
293
+ constructor(api) {
294
+ this.api = api;
295
+ }
296
+ async get(requestId) {
297
+ const response = await this.api.fetch(`/api/customer/activations/${requestId}`, activationRequestSchema);
298
+ return response.data;
299
+ }
300
+ async isCompleted(requestId) {
301
+ const response = await this.api.fetch(`/api/customer/activations/${requestId}/completed`, z5.boolean());
302
+ return z5.boolean().parse(response.data);
303
+ }
304
+ async fulfillLicense(requestId) {
305
+ const response = await this.api.authenticatedFetch(`/api/customer/activations/${requestId}/license`, activationRequestSchema, { method: "POST" });
306
+ return response.data;
307
+ }
308
+ async fulfillTrial(requestId) {
309
+ const response = await this.api.fetch(`/api/customer/activations/${requestId}/trial`, activationRequestSchema, { method: "POST" });
310
+ return response.data;
311
+ }
312
+ async cancel(requestId) {
313
+ const response = await this.api.fetch(`/api/customer/activations/${requestId}/cancel`, activationRequestSchema, { method: "POST" });
314
+ return response.data;
315
+ }
316
+ };
317
+
318
+ // src/communications/schemas.ts
319
+ var schemas_exports4 = {};
320
+ __export(schemas_exports4, {
321
+ communicationPreferencesViewSchema: () => communicationPreferencesViewSchema,
322
+ subscribeResponseSchema: () => subscribeResponseSchema
323
+ });
324
+ import { z as z6 } from "zod";
325
+ var subscribeResponseSchema = z6.object({
326
+ status: z6.enum(["subscribed", "confirmation_sent"])
327
+ });
328
+ var communicationPreferencesViewSchema = z6.object({
329
+ email: z6.string(),
330
+ name: z6.string().nullish(),
331
+ newsletter: z6.boolean(),
332
+ productUpdates: z6.boolean()
333
+ });
334
+
335
+ // src/communications/endpoints.ts
336
+ function encodeToken(token) {
337
+ return encodeURIComponent(token.replaceAll(" ", "+"));
338
+ }
339
+ var CommunicationsEndpoints = class {
340
+ constructor(api) {
341
+ this.api = api;
342
+ }
343
+ async subscribe(input) {
344
+ var _a, _b, _c;
345
+ const response = await this.api.fetch("/api/customer/communications/subscribe", subscribeResponseSchema, {
346
+ method: "POST",
347
+ body: {
348
+ email: input.email,
349
+ name: ((_a = input.name) == null ? void 0 : _a.trim()) || null,
350
+ newsletter: (_b = input.newsletter) != null ? _b : true,
351
+ productUpdates: (_c = input.productUpdates) != null ? _c : true
352
+ }
353
+ });
354
+ return response.data;
355
+ }
356
+ async confirm(email, token) {
357
+ await this.api.fetch(
358
+ `/api/customer/communications/confirm?email=${encodeURIComponent(email)}&token=${encodeToken(token)}`,
359
+ null,
360
+ { method: "POST" }
361
+ );
362
+ }
363
+ async getPreferences(email, token) {
364
+ const response = await this.api.fetch(
365
+ `/api/customer/communications/preferences?email=${encodeURIComponent(email)}&token=${encodeToken(token)}`,
366
+ communicationPreferencesViewSchema
367
+ );
368
+ return response.data;
369
+ }
370
+ async updatePreferences(email, token, preferences) {
371
+ const response = await this.api.fetch(
372
+ `/api/customer/communications/preferences?email=${encodeURIComponent(email)}&token=${encodeToken(token)}`,
373
+ communicationPreferencesViewSchema,
374
+ {
375
+ method: "POST",
376
+ body: {
377
+ newsletter: preferences.newsletter,
378
+ productUpdates: preferences.productUpdates
379
+ }
380
+ }
381
+ );
382
+ return response.data;
383
+ }
384
+ async unsubscribe(email, token) {
385
+ await this.api.fetch(
386
+ `/api/customer/communications/unsubscribe?email=${encodeURIComponent(email)}&token=${encodeToken(token)}`,
387
+ null,
388
+ { method: "POST" }
389
+ );
390
+ }
391
+ };
392
+
393
+ // src/utils/errors.ts
394
+ var NotAuthorizedError = class extends Error {
395
+ constructor() {
396
+ super();
397
+ this.name = "NotAuthorizedError";
398
+ this.message = "Not allowed";
399
+ }
400
+ };
401
+ var NotAuthenticatedError = class extends Error {
402
+ constructor() {
403
+ super();
404
+ this.name = "NotAuthenticatedError";
405
+ this.message = "Not authenticated";
406
+ }
407
+ };
408
+ var NotFoundError = class extends Error {
409
+ constructor(message) {
410
+ super();
411
+ this.name = "NotFoundError";
412
+ this.message = message != null ? message : "Not found";
413
+ }
414
+ };
415
+ var MoonbaseError = class extends Error {
416
+ constructor(title, detail, status, errors) {
417
+ super();
418
+ this.title = title;
419
+ this.detail = detail;
420
+ this.status = status;
421
+ this.errors = errors;
422
+ this.name = "MoonbaseError";
423
+ if (errors && Object.values(errors).length === 1) {
424
+ this.message = Object.values(errors)[0];
425
+ } else {
426
+ this.message = detail != null ? detail : title;
427
+ }
428
+ }
429
+ };
430
+
431
+ // src/utils/problemDetails.ts
432
+ import { z as z7 } from "zod";
433
+ var problemDetailsSchema = z7.object({
434
+ type: z7.string().optional(),
435
+ title: z7.string(),
436
+ detail: z7.string().optional(),
437
+ status: z7.number().optional(),
438
+ instance: z7.string().optional(),
439
+ errors: z7.record(z7.string(), z7.string().array()).optional()
440
+ });
441
+
442
+ // src/utils/problemHandler.ts
443
+ function camelCase(str) {
444
+ return str.split(".").map((word, index) => {
445
+ let [firstLetter, ...restOfLetters] = word;
446
+ firstLetter = index !== 0 ? firstLetter.toUpperCase() : firstLetter.toLowerCase();
447
+ restOfLetters = [restOfLetters.join("").toLowerCase()];
448
+ return firstLetter + restOfLetters[0];
449
+ }).join("");
450
+ }
451
+ async function handleResponseProblem(response, logger) {
452
+ if (response.status === 404)
453
+ throw new NotFoundError();
454
+ if (response.status === 401) {
455
+ throw new NotAuthenticatedError();
456
+ }
457
+ if (response.status === 403) {
458
+ throw new NotAuthorizedError();
459
+ }
460
+ let problemDetails;
461
+ try {
462
+ const json = await response.json();
463
+ problemDetails = problemDetailsSchema.parse(json);
464
+ } catch (err) {
465
+ logger.warn("Could not handle response", { response, err, content: await response.text() });
466
+ throw new Error("An unknown problem occurred");
467
+ }
468
+ logger.debug("The response indicates a problem", problemDetails);
469
+ throw new MoonbaseError(
470
+ problemDetails.title,
471
+ problemDetails.detail,
472
+ problemDetails.status,
473
+ problemDetails.errors ? Object.fromEntries(Object.entries(problemDetails.errors).map(([field, errors]) => [camelCase(field), errors.join(", ")])) : void 0
474
+ );
475
+ }
476
+
477
+ // src/identity/schemas.ts
478
+ var schemas_exports5 = {};
479
+ __export(schemas_exports5, {
480
+ addressSchema: () => addressSchema,
481
+ communicationPreferencesSchema: () => communicationPreferencesSchema,
482
+ connectedAccountSchema: () => connectedAccountSchema,
483
+ connectionUrlSchema: () => connectionUrlSchema,
484
+ identitySchema: () => identitySchema,
485
+ ilokConnectedAccountSchema: () => ilokConnectedAccountSchema,
486
+ pendingActivationSchema: () => pendingActivationSchema,
487
+ userAccountConfirmedSchema: () => userAccountConfirmedSchema,
488
+ userAccountConfirmedStatusSchema: () => userAccountConfirmedStatusSchema,
489
+ userSchema: () => userSchema
490
+ });
491
+ import { z as z8 } from "zod";
492
+
493
+ // src/identity/models.ts
494
+ var ConnectableAccountProvider = /* @__PURE__ */ ((ConnectableAccountProvider2) => {
495
+ ConnectableAccountProvider2["iLok"] = "iLok";
496
+ return ConnectableAccountProvider2;
497
+ })(ConnectableAccountProvider || {});
498
+
499
+ // src/identity/schemas.ts
500
+ var addressSchema = z8.object({
501
+ countryCode: z8.string(),
502
+ streetAddress1: z8.string(),
503
+ streetAddress2: z8.string().nullable(),
504
+ locality: z8.string().nullable(),
505
+ region: z8.string().nullable(),
506
+ postCode: z8.string().nullable()
507
+ });
508
+ var communicationPreferencesSchema = z8.object({
509
+ newsletterOptIn: z8.boolean(),
510
+ // Default keeps older persisted identities (pre productUpdatesOptIn) parseable
511
+ // during boot. The server-side value is hydrated by updateUser() right after.
512
+ productUpdatesOptIn: z8.boolean().default(false)
513
+ });
514
+ var ilokConnectedAccountSchema = z8.object({
515
+ provider: z8.literal("iLok" /* iLok */),
516
+ isConnected: z8.boolean(),
517
+ pendingLicenseFulfillments: z8.boolean(),
518
+ accountId: z8.string().nullish()
519
+ });
520
+ var connectedAccountSchema = z8.discriminatedUnion("provider", [
521
+ ilokConnectedAccountSchema
522
+ ]);
523
+ var connectionUrlSchema = z8.object({
524
+ url: z8.string()
525
+ });
526
+ var userSchema = z8.object({
527
+ id: z8.string(),
528
+ email: z8.string(),
529
+ name: z8.string(),
530
+ tenantId: z8.string(),
531
+ address: addressSchema.optional(),
532
+ phone: z8.string().optional(),
533
+ communicationPreferences: communicationPreferencesSchema,
534
+ ownedProducts: z8.string().array().optional(),
535
+ subscribedProducts: z8.string().array().optional(),
536
+ confirmedAccount: z8.boolean().optional(),
537
+ hasProducts: z8.boolean().nullish(),
538
+ hasSubscriptions: z8.boolean().nullish(),
539
+ connectedAccounts: z8.array(connectedAccountSchema).default([])
540
+ });
541
+ var identitySchema = userSchema.and(z8.object({
542
+ accessToken: z8.string(),
543
+ refreshToken: z8.string()
544
+ }));
545
+ var userAccountConfirmedStatusSchema = z8.enum([
546
+ "PasswordSetupRequired",
547
+ "SignedIn"
548
+ ]);
549
+ var userAccountConfirmedSchema = userSchema.and(z8.object({
550
+ status: userAccountConfirmedStatusSchema,
551
+ resetPasswordToken: z8.string().nullish(),
552
+ accessToken: z8.string().nullish(),
553
+ refreshToken: z8.string().nullish()
554
+ }));
555
+ var pendingActivationSchema = z8.object({
556
+ status: z8.literal("activation_pending"),
557
+ email: z8.string()
558
+ });
559
+
560
+ // src/identity/endpoints.ts
561
+ var IdentityEndpoints = class {
562
+ constructor(api, tokenStore, logger) {
563
+ this.api = api;
564
+ this.tokenStore = tokenStore;
565
+ this.logger = logger;
566
+ }
567
+ async get() {
568
+ const response = await this.api.authenticatedFetch("/api/customer/meta/user", userSchema);
569
+ return response.data;
570
+ }
571
+ async signIn(email, password) {
572
+ const response = await fetch(`${this.api.baseUrl}/api/customer/identity/sign-in?email=${encodeURIComponent(email)}&scheme=JWT`, {
573
+ method: "POST",
574
+ headers: {
575
+ "Accept": "application/json",
576
+ "Content-Type": "text/plain",
577
+ "x-mb-cors": "1"
578
+ },
579
+ body: password
580
+ });
581
+ if (response.status === 404)
582
+ throw new NotFoundError("User not found");
583
+ if (response.status >= 400)
584
+ await handleResponseProblem(response, this.logger);
585
+ try {
586
+ const data = await response.json();
587
+ const user = identitySchema.parse(data);
588
+ this.tokenStore.setUser(user);
589
+ return userSchema.parse(user);
590
+ } catch (err) {
591
+ this.logger.warn("Could not sign in user", { email, response, err });
592
+ throw new MoonbaseError("Bad response", "Could not sign in user", response.status);
593
+ }
594
+ }
595
+ async signUp(name, email, password, address, acceptedPrivacyPolicy, acceptedTermsAndConditions, communicationOptIn) {
596
+ const path = `/api/customer/identity/sign-up?scheme=JWT&communicationOptIn=${communicationOptIn ? "true" : "false"}`;
597
+ const response = await fetch(`${this.api.baseUrl}${path}`, {
598
+ method: "POST",
599
+ headers: {
600
+ "Accept": "application/json",
601
+ "Content-Type": "application/json",
602
+ "x-mb-cors": "1"
603
+ },
604
+ body: JSON.stringify({
605
+ name,
606
+ email,
607
+ password,
608
+ address,
609
+ acceptedPrivacyPolicy,
610
+ acceptedTermsAndConditions
611
+ })
612
+ });
613
+ if (response.status >= 400)
614
+ await handleResponseProblem(response, this.logger);
615
+ const data = await response.json();
616
+ if (response.status === 202) {
617
+ const parsed = pendingActivationSchema.parse(data);
618
+ return { status: "activation-pending", email: parsed.email };
619
+ }
620
+ try {
621
+ const identity = identitySchema.parse(data);
622
+ this.tokenStore.setUser(identity);
623
+ return { status: "signed-in", user: userSchema.parse(identity) };
624
+ } catch (err) {
625
+ this.logger.warn("Could not sign up user", { email, response, err });
626
+ throw new MoonbaseError("Bad response", "Could not sign up user", response.status);
627
+ }
628
+ }
629
+ async signOut() {
630
+ this.tokenStore.clear();
631
+ }
632
+ async update(name, email, emailConfirmationToken, communicationPreferences) {
633
+ const response = await this.api.authenticatedFetch("/api/customer/identity", userSchema, {
634
+ method: "PATCH",
635
+ body: {
636
+ name,
637
+ email,
638
+ emailConfirmationToken,
639
+ communicationPreferences
640
+ }
641
+ });
642
+ this.tokenStore.setUser(response.data);
643
+ return {
644
+ needsEmailConfirmationToken: response.status === 201,
645
+ user: response.data
646
+ };
647
+ }
648
+ async setPassword(currentPassword, newPassword) {
649
+ await this.api.authenticatedFetch(`/api/customer/identity/set-password`, null, {
650
+ method: "POST",
651
+ body: {
652
+ currentPassword,
653
+ newPassword
654
+ }
655
+ });
656
+ }
657
+ async forgotPassword(email) {
658
+ await this.api.fetch(`/api/customer/identity/forgot-password?email=${encodeURIComponent(email)}`, null, { method: "POST" });
659
+ }
660
+ async resetPassword(email, newPassword, code) {
661
+ const response = await fetch(`${this.api.baseUrl}/api/customer/identity/reset-password?email=${encodeURIComponent(email)}&code=${encodeURIComponent(code.replaceAll(" ", "+"))}`, {
662
+ method: "POST",
663
+ headers: {
664
+ "Accept": "application/json",
665
+ "Content-Type": "text/plain",
666
+ "x-mb-cors": "1"
667
+ },
668
+ body: newPassword
669
+ });
670
+ if (response.status >= 400)
671
+ await handleResponseProblem(response, this.logger);
672
+ }
673
+ async confirmAccount(email, code) {
674
+ const response = await this.api.fetch(`/api/customer/identity/confirm-account?email=${encodeURIComponent(email)}&code=${encodeURIComponent(code.replaceAll(" ", "+"))}&scheme=JWT`, userAccountConfirmedSchema, { method: "POST" });
675
+ const result = response.data;
676
+ if (result.status === "SignedIn") {
677
+ if (!result.accessToken || !result.refreshToken) {
678
+ this.logger.warn("Confirm-account returned SignedIn without tokens", { email });
679
+ throw new MoonbaseError(
680
+ "Bad response",
681
+ "Confirm-account succeeded but the server did not return auth tokens",
682
+ response.status
683
+ );
684
+ }
685
+ this.tokenStore.setUser({
686
+ ...result,
687
+ accessToken: result.accessToken,
688
+ refreshToken: result.refreshToken
689
+ });
690
+ }
691
+ return result;
692
+ }
693
+ async confirmEmail(email, code) {
694
+ await this.api.fetch(`/api/customer/identity/confirm-email?email=${encodeURIComponent(email)}&code=${encodeURIComponent(code.replaceAll(" ", "+"))}`, null, { method: "POST" });
695
+ }
696
+ async confirmEmailChange(email, code) {
697
+ await this.api.authenticatedFetch(`/api/customer/identity/confirm-email-change?email=${encodeURIComponent(email)}&code=${encodeURIComponent(code.replaceAll(" ", "+"))}`, null, { method: "POST" });
698
+ }
699
+ async getConnectionUrl(provider, redirectUri, loginId) {
700
+ const params = new URLSearchParams({ redirectUri });
701
+ if (loginId)
702
+ params.set("loginId", loginId);
703
+ const response = await this.api.authenticatedFetch(
704
+ `/api/customer/connect/${provider}/authorize?${params.toString()}`,
705
+ connectionUrlSchema
706
+ );
707
+ return response.data.url;
708
+ }
709
+ async disconnectAccount(provider) {
710
+ await this.api.authenticatedFetch(`/api/customer/connect/${provider}`, null, { method: "DELETE" });
711
+ }
712
+ };
713
+
714
+ // src/inventory/activation/endpoints.ts
715
+ import { z as z10 } from "zod";
716
+
717
+ // src/inventory/licenses/schemas.ts
718
+ var schemas_exports6 = {};
719
+ __export(schemas_exports6, {
720
+ activationSchema: () => activationSchema,
721
+ externalLicenseContent: () => externalLicenseContent,
722
+ licenseSchema: () => licenseSchema
723
+ });
724
+ import { z as z9 } from "zod";
725
+
726
+ // src/inventory/licenses/models.ts
727
+ var LicenseStatus = /* @__PURE__ */ ((LicenseStatus2) => {
728
+ LicenseStatus2["Active"] = "Active";
729
+ LicenseStatus2["Pending"] = "Pending";
730
+ LicenseStatus2["Revoked"] = "Revoked";
731
+ return LicenseStatus2;
732
+ })(LicenseStatus || {});
733
+ var ActivationStatus = /* @__PURE__ */ ((ActivationStatus2) => {
734
+ ActivationStatus2["Active"] = "Active";
735
+ ActivationStatus2["Revoked"] = "Revoked";
736
+ return ActivationStatus2;
737
+ })(ActivationStatus || {});
738
+ var ActivationMethod = /* @__PURE__ */ ((ActivationMethod2) => {
739
+ ActivationMethod2["Online"] = "Online";
740
+ ActivationMethod2["Offline"] = "Offline";
741
+ return ActivationMethod2;
742
+ })(ActivationMethod || {});
743
+
744
+ // src/inventory/licenses/schemas.ts
745
+ var externalLicenseFileContent = z9.object({
746
+ type: z9.literal("file"),
747
+ fileName: z9.string(),
748
+ contentType: z9.string(),
749
+ data: z9.string()
750
+ });
751
+ var externalLicenseILokContent = z9.object({
752
+ type: z9.literal("iLok")
753
+ });
754
+ var externalLicenseContent = z9.union([
755
+ z9.string(),
756
+ z9.discriminatedUnion("type", [
757
+ externalLicenseFileContent,
758
+ externalLicenseILokContent
759
+ ])
760
+ ]);
761
+ var licenseSchema = z9.object({
762
+ id: z9.string(),
763
+ status: z9.nativeEnum(LicenseStatus),
764
+ product: productSummarySchema,
765
+ activeNumberOfActivations: z9.number(),
766
+ maxNumberOfActivations: z9.number(),
767
+ externalFulfillment: externalLicenseContent.optional(),
768
+ requiredConnectedAccount: z9.nativeEnum(ConnectableAccountProvider).nullish(),
769
+ fulfillmentMessage: z9.string().optional(),
770
+ properties: z9.record(rawPropertyValueSchema).nullish(),
771
+ expiresAt: z9.coerce.date().optional(),
772
+ createdAt: z9.coerce.date()
773
+ });
774
+ var activationSchema = z9.object({
775
+ id: z9.string(),
776
+ licenseId: z9.string(),
777
+ name: z9.string(),
778
+ status: z9.nativeEnum(ActivationStatus),
779
+ activationMethod: z9.nativeEnum(ActivationMethod),
780
+ firstValidatedAt: z9.coerce.date(),
781
+ lastValidatedAt: z9.coerce.date().nullable()
782
+ });
783
+
784
+ // src/inventory/activation/endpoints.ts
785
+ var ActivationEndpoints = class {
786
+ constructor(api, configuration) {
787
+ this.api = api;
788
+ this.configuration = configuration;
789
+ }
790
+ async activate(deviceToken, activationMethod) {
791
+ const response = await this.api.authenticatedFetch(`/api/customer/inventory/activate?method=${activationMethod}${this.configuration.includeManifests ? "&includeManifests=true" : ""}`, licenseSchema, {
792
+ method: "POST",
793
+ body: deviceToken,
794
+ contentType: "text/plain"
795
+ });
796
+ return {
797
+ license: response.data,
798
+ url: z10.string().parse(response.headers.location)
799
+ };
800
+ }
801
+ };
802
+
803
+ // src/inventory/licenses/endpoints.ts
804
+ var LicenseEndpoints = class {
805
+ constructor(api, configuration) {
806
+ this.api = api;
807
+ this.configuration = configuration;
808
+ }
809
+ async get(nextUrl) {
810
+ const response = await this.api.authenticatedFetch(nextUrl || `/api/customer/inventory/licenses${this.configuration.includeManifests ? "?includeManifests=true" : ""}`, paged(licenseSchema));
811
+ return response.data;
812
+ }
813
+ async getActivations(licenseId, nextUrl) {
814
+ const response = await this.api.authenticatedFetch(
815
+ nextUrl || `/api/customer/inventory/licenses/${licenseId}/activations`,
816
+ paged(activationSchema)
817
+ );
818
+ return response.data;
819
+ }
820
+ async revokeActivation(licenseId, activationId) {
821
+ await this.api.authenticatedFetch(`/api/customer/inventory/licenses/${licenseId}/activations/${activationId}/revoke`, null, { method: "POST" });
822
+ }
823
+ };
824
+
825
+ // src/inventory/products/endpoints.ts
826
+ import { z as z11 } from "zod";
827
+ var ProductEndpoints = class {
828
+ constructor(api, configuration) {
829
+ this.api = api;
830
+ this.configuration = configuration;
831
+ }
832
+ async get(productId, version) {
833
+ const response = await this.api.fetch(`/api/customer/inventory/products/${productId}${version ? `?version=${version}${this.configuration.includeManifests ? "&includeManifests=true" : ""}` : this.configuration.includeManifests ? "?includeManifests=true" : ""}`, productSummarySchema);
834
+ return response.data;
835
+ }
836
+ async getOwned(nextUrl) {
837
+ const response = await this.api.authenticatedFetch(nextUrl || `/api/customer/inventory/products${this.configuration.includeManifests ? "?includeManifests=true" : ""}`, paged(productSummarySchema));
838
+ return response.data;
839
+ }
840
+ async getLicenses(productId, nextUrl) {
841
+ const response = await this.api.authenticatedFetch(nextUrl || `/api/customer/inventory/products/${productId}/licenses${this.configuration.includeManifests ? "?includeManifests=true" : ""}`, paged(licenseSchema));
842
+ return response.data;
843
+ }
844
+ async getActivations(productId, nextUrl) {
845
+ const response = await this.api.authenticatedFetch(nextUrl || `/api/customer/inventory/products/${productId}/licenses/activations`, paged(activationSchema));
846
+ return response.data;
847
+ }
848
+ async getDownloadUrl(path) {
849
+ const url = new URL(path);
850
+ url.searchParams.append("redirect", "false");
851
+ const response = await this.api.fetch(url.pathname + url.search, z11.object({
852
+ location: z11.string()
853
+ }));
854
+ return response.data.location;
855
+ }
856
+ };
857
+
858
+ // src/utils/api.ts
859
+ function objectToQuery(obj) {
860
+ return Object.entries(obj != null ? obj : {}).filter(([_, value]) => value !== void 0).map(([key, value]) => `${key}=${encodeURIComponent(value instanceof Date ? value.toISOString() : value)}`).join("&");
861
+ }
862
+ var MoonbaseApi = class {
863
+ constructor(baseUrl, tokenStore, logger) {
864
+ this.baseUrl = baseUrl;
865
+ this.tokenStore = tokenStore;
866
+ this.logger = logger;
867
+ }
868
+ async authenticatedFetch(path, schema, options) {
869
+ if (!this.tokenStore.user)
870
+ throw new NotAuthenticatedError();
871
+ return await this.fetch(path, schema, options);
872
+ }
873
+ async fetch(path, schema, options) {
874
+ var _a;
875
+ const accessToken = await this.tokenStore.getAccessToken();
876
+ const contentType = (_a = options == null ? void 0 : options.contentType) != null ? _a : "application/json";
877
+ this.logger.debug("Making request to Moonbase API...", {
878
+ path,
879
+ body: options == null ? void 0 : options.body
880
+ });
881
+ const startedAt = /* @__PURE__ */ new Date();
882
+ const request = {
883
+ method: (options == null ? void 0 : options.method) || "GET",
884
+ mode: "cors",
885
+ headers: {
886
+ "Accept": "application/json",
887
+ "Content-Type": contentType,
888
+ // While this fetch can be anonymous, we add the token if we have it
889
+ ...accessToken ? { Authorization: `Bearer ${accessToken}` } : {},
890
+ // Force CORS on all calls
891
+ "x-mb-cors": "1"
892
+ },
893
+ body: (options == null ? void 0 : options.body) ? contentType !== "application/json" ? options.body : JSON.stringify(options.body) : void 0,
894
+ signal: options == null ? void 0 : options.abort,
895
+ redirect: "manual"
896
+ };
897
+ const response = await fetch(this.baseUrl + path, request);
898
+ const finishedAt = /* @__PURE__ */ new Date();
899
+ this.logger.debug("Received response from Moonbase", {
900
+ path,
901
+ status: response.status,
902
+ duration: finishedAt.getTime() - startedAt.getTime()
903
+ });
904
+ if (response.status >= 400) {
905
+ try {
906
+ await handleResponseProblem(response, this.logger);
907
+ } catch (err) {
908
+ this.reportRequestProblem(path, request, response, err);
909
+ throw err;
910
+ }
911
+ }
912
+ let json;
913
+ try {
914
+ json = schema ? await response.json() : null;
915
+ return {
916
+ data: schema ? schema.parse(json) : null,
917
+ headers: Object.fromEntries(response.headers.entries()),
918
+ status: response.status
919
+ };
920
+ } catch (err) {
921
+ this.logger.warn("Could not parse response", {
922
+ status: response.status,
923
+ path,
924
+ content: json || (response.bodyUsed ? "unknown" : await response.text()),
925
+ headers: Object.fromEntries(response.headers.entries()),
926
+ userAgent: window && window.navigator && window.navigator.userAgent,
927
+ err
928
+ });
929
+ this.reportParsingProblem(path, err, json || (response.bodyUsed ? "unknown" : await response.text()));
930
+ throw new MoonbaseError("Bad response", "Could not parse server response", response.status);
931
+ }
932
+ }
933
+ async reportParsingProblem(path, err, body) {
934
+ try {
935
+ await fetch(`${this.baseUrl}/api/customer/insights/error`, {
936
+ mode: "cors",
937
+ method: "POST",
938
+ headers: {
939
+ "Accept": "application/json",
940
+ "Content-Type": "application/json"
941
+ },
942
+ body: JSON.stringify({
943
+ title: "Parse error",
944
+ detail: `Could not parse response body`,
945
+ path,
946
+ origin: window == null ? void 0 : window.location.href,
947
+ userAgent: window && window.navigator && window.navigator.userAgent,
948
+ err,
949
+ body
950
+ })
951
+ });
952
+ } catch (e) {
953
+ }
954
+ }
955
+ async reportRequestProblem(path, request, response, err) {
956
+ try {
957
+ await fetch(`${this.baseUrl}/api/customer/insights/warn`, {
958
+ mode: "cors",
959
+ method: "POST",
960
+ headers: {
961
+ "Accept": "application/json",
962
+ "Content-Type": "application/json"
963
+ },
964
+ body: JSON.stringify({
965
+ title: "Request error",
966
+ detail: `Request failed with status ${response.status}`,
967
+ status: response.status,
968
+ request: {
969
+ ...request,
970
+ headers: void 0,
971
+ body: void 0
972
+ },
973
+ error: err,
974
+ path,
975
+ origin: window == null ? void 0 : window.location.href
976
+ })
977
+ });
978
+ } catch (e) {
979
+ }
980
+ }
981
+ };
982
+
983
+ // src/inventory/subscriptions/endpoints.ts
984
+ import { z as z14 } from "zod";
985
+
986
+ // src/inventory/subscriptions/schemas.ts
987
+ var schemas_exports8 = {};
988
+ __export(schemas_exports8, {
989
+ milestoneProgressSchema: () => milestoneProgressSchema,
990
+ subscriptionSchema: () => subscriptionSchema
991
+ });
992
+ import { z as z13 } from "zod";
993
+
994
+ // src/inventory/subscriptions/models.ts
995
+ var SubscriptionStatus = /* @__PURE__ */ ((SubscriptionStatus2) => {
996
+ SubscriptionStatus2["Active"] = "Active";
997
+ SubscriptionStatus2["Expired"] = "Expired";
998
+ SubscriptionStatus2["Cancelled"] = "Cancelled";
999
+ SubscriptionStatus2["Completed"] = "Completed";
1000
+ return SubscriptionStatus2;
1001
+ })(SubscriptionStatus || {});
1002
+
1003
+ // src/orders/schemas.ts
1004
+ var schemas_exports7 = {};
1005
+ __export(schemas_exports7, {
1006
+ completedOrderSchema: () => completedOrderSchema,
1007
+ openBundleLineItem: () => openBundleLineItem,
1008
+ openOrderLineItem: () => openOrderLineItem,
1009
+ openOrderSchema: () => openOrderSchema,
1010
+ openProductLineItem: () => openProductLineItem,
1011
+ orderSchema: () => orderSchema,
1012
+ orderTotalSchema: () => orderTotalSchema
1013
+ });
1014
+ import { z as z12 } from "zod";
1015
+
1016
+ // src/orders/models.ts
1017
+ var OrderStatus = /* @__PURE__ */ ((OrderStatus2) => {
1018
+ OrderStatus2["Open"] = "Open";
1019
+ OrderStatus2["PaymentProcessing"] = "PaymentProcessing";
1020
+ OrderStatus2["Paid"] = "Paid";
1021
+ OrderStatus2["Completed"] = "Completed";
1022
+ OrderStatus2["Failed"] = "Failed";
1023
+ return OrderStatus2;
1024
+ })(OrderStatus || {});
1025
+
1026
+ // src/orders/schemas.ts
1027
+ var couponSchema = z12.object({
1028
+ code: z12.string(),
1029
+ name: z12.string(),
1030
+ description: z12.string()
1031
+ });
1032
+ var lineItemProductSchema = z12.object({
1033
+ id: z12.string(),
1034
+ name: z12.string(),
1035
+ tagline: z12.string(),
1036
+ iconUrl: z12.string().nullable()
1037
+ });
1038
+ var lineItemTotalSchema = z12.object({
1039
+ original: moneySchema,
1040
+ discount: moneySchema,
1041
+ subtotal: moneySchema,
1042
+ due: moneySchema
1043
+ });
1044
+ var openProductLineItem = z12.object({
1045
+ id: z12.string(),
1046
+ type: z12.literal("Product"),
1047
+ productId: z12.string(),
1048
+ quantity: z12.number(),
1049
+ variationId: z12.string(),
1050
+ offerId: z12.string().optional(),
1051
+ isDefaultVariation: z12.boolean().nullish(),
1052
+ isSubcriptionPayment: z12.boolean().nullish(),
1053
+ price: priceCollectionSchema.optional(),
1054
+ variation: pricingVariationSchema.optional(),
1055
+ total: lineItemTotalSchema.nullish(),
1056
+ product: lineItemProductSchema.optional(),
1057
+ appliedDiscount: discountSchema.optional()
1058
+ });
1059
+ var lineItemBundleSchema = z12.object({
1060
+ id: z12.string(),
1061
+ name: z12.string(),
1062
+ tagline: z12.string(),
1063
+ iconUrl: z12.string().nullable(),
1064
+ products: lineItemProductSchema.and(z12.object({
1065
+ included: z12.boolean().optional()
1066
+ })).array()
1067
+ });
1068
+ var openBundleLineItem = z12.object({
1069
+ id: z12.string(),
1070
+ type: z12.literal("Bundle"),
1071
+ bundleId: z12.string(),
1072
+ quantity: z12.number(),
1073
+ variationId: z12.string(),
1074
+ offerId: z12.string().optional(),
1075
+ partial: z12.boolean().optional(),
1076
+ replaced: z12.string().array().optional(),
1077
+ isDefaultVariation: z12.boolean().nullish(),
1078
+ isSubcriptionPayment: z12.boolean().nullish(),
1079
+ price: priceCollectionSchema.optional(),
1080
+ variation: pricingVariationSchema.optional(),
1081
+ total: lineItemTotalSchema.nullish(),
1082
+ bundle: lineItemBundleSchema.optional(),
1083
+ appliedDiscount: discountSchema.optional()
1084
+ });
1085
+ var openOrderLineItem = z12.discriminatedUnion("type", [
1086
+ openProductLineItem,
1087
+ openBundleLineItem
1088
+ ]);
1089
+ var orderTotalSchema = z12.object({
1090
+ original: moneySchema,
1091
+ discount: moneySchema,
1092
+ subtotal: moneySchema,
1093
+ taxes: moneySchema,
1094
+ due: moneySchema
1095
+ });
1096
+ var openOrderSchema = z12.object({
1097
+ id: z12.string(),
1098
+ currency: z12.string(),
1099
+ total: orderTotalSchema.nullish(),
1100
+ items: openOrderLineItem.array(),
1101
+ couponsApplied: couponSchema.array(),
1102
+ checkoutUrl: z12.string().optional(),
1103
+ hostedCheckoutUrl: z12.string().optional(),
1104
+ embeddedCheckoutUrl: z12.string().optional()
1105
+ });
1106
+ var customerSnapshotSchema = z12.object({
1107
+ name: z12.string().nullable(),
1108
+ businessName: z12.string().nullable(),
1109
+ taxId: z12.string().nullable(),
1110
+ email: z12.string().nullable(),
1111
+ phone: z12.string().nullable(),
1112
+ address: addressSchema.nullable()
1113
+ });
1114
+ var completedOrderSchema = z12.object({
1115
+ id: z12.string(),
1116
+ status: z12.literal("Completed" /* Completed */),
1117
+ currency: z12.string(),
1118
+ customer: customerSnapshotSchema,
1119
+ total: orderTotalSchema,
1120
+ items: openOrderLineItem.array(),
1121
+ couponsApplied: couponSchema.array()
1122
+ });
1123
+ var orderSchema = z12.discriminatedUnion("status", [
1124
+ openOrderSchema.extend({
1125
+ status: z12.literal("Open" /* Open */)
1126
+ }),
1127
+ openOrderSchema.extend({
1128
+ status: z12.literal("PaymentProcessing" /* PaymentProcessing */)
1129
+ }),
1130
+ openOrderSchema.extend({
1131
+ status: z12.literal("Paid" /* Paid */)
1132
+ }),
1133
+ openOrderSchema.extend({
1134
+ status: z12.literal("Failed" /* Failed */)
1135
+ }),
1136
+ completedOrderSchema
1137
+ ]);
1138
+
1139
+ // src/inventory/subscriptions/schemas.ts
1140
+ var baseMilestoneProgressEventSchema = z13.object({
1141
+ milestoneId: z13.string(),
1142
+ fulfilled: z13.boolean(),
1143
+ afterCycleNumber: z13.number(),
1144
+ afterNormalizedCycleNumber: z13.number(),
1145
+ message: z13.string().optional()
1146
+ });
1147
+ var milestoneProgressEventSchema = z13.discriminatedUnion("type", [
1148
+ baseMilestoneProgressEventSchema.extend({
1149
+ type: z13.literal("CouponCodeMilestone"),
1150
+ code: z13.string().optional(),
1151
+ redeemed: z13.boolean().optional()
1152
+ }),
1153
+ baseMilestoneProgressEventSchema.extend({
1154
+ type: z13.literal("PerpetualLicenseConversionMilestone")
1155
+ })
1156
+ ]);
1157
+ var milestoneProgressSchema = z13.object({
1158
+ title: z13.string(),
1159
+ description: z13.string().nullish(),
1160
+ currentCycleNumber: z13.number(),
1161
+ currentNormalizedCycleNumber: z13.number(),
1162
+ currentCycleIsCompleted: z13.boolean(),
1163
+ fromCycleNumber: z13.number(),
1164
+ fromNormalizedCycleNumber: z13.number(),
1165
+ toCycleNumber: z13.number(),
1166
+ toNormalizedCycleNumber: z13.number(),
1167
+ events: z13.record(z13.coerce.number(), milestoneProgressEventSchema.array())
1168
+ });
1169
+ var subscriptionSchema = z13.object({
1170
+ id: z13.string(),
1171
+ status: z13.nativeEnum(SubscriptionStatus),
1172
+ hasPaymentMethod: z13.boolean(),
1173
+ cancellable: z13.boolean(),
1174
+ expiresAt: z13.coerce.date(),
1175
+ renewedAt: z13.coerce.date().nullable(),
1176
+ nextPaymentScheduledAt: z13.coerce.date().nullable(),
1177
+ startedAt: z13.coerce.date(),
1178
+ total: orderTotalSchema,
1179
+ cycleLength: z13.nativeEnum(CycleLength),
1180
+ paymentMethod: z13.string().optional(),
1181
+ milestoneProgress: milestoneProgressSchema.nullish(),
1182
+ embeddedUpdatePaymentUrl: z13.string().optional(),
1183
+ content: z13.discriminatedUnion("type", [
1184
+ z13.object({
1185
+ type: z13.literal("Product"),
1186
+ quantity: z13.number(),
1187
+ product: storefrontProductSchema
1188
+ }),
1189
+ z13.object({
1190
+ type: z13.literal("Bundle"),
1191
+ quantity: z13.number(),
1192
+ bundle: storefrontBundleSchema
1193
+ })
1194
+ ])
1195
+ });
1196
+
1197
+ // src/inventory/subscriptions/endpoints.ts
1198
+ var SubscriptionEndpoints = class {
1199
+ constructor(api, configuration) {
1200
+ this.api = api;
1201
+ this.configuration = configuration;
1202
+ }
1203
+ async get(nextUrl) {
1204
+ const response = await this.api.authenticatedFetch(nextUrl || "/api/customer/inventory/subscriptions", paged(subscriptionSchema));
1205
+ return response.data;
1206
+ }
1207
+ async getById(subscriptionId, options) {
1208
+ const response = await this.api.authenticatedFetch(`/api/customer/inventory/subscriptions/${subscriptionId}?${objectToQuery(options)}`, subscriptionSchema);
1209
+ return response.data;
1210
+ }
1211
+ async cancel(subscriptionId) {
1212
+ const response = await this.api.authenticatedFetch(`/api/customer/inventory/subscriptions/${subscriptionId}/cancel`, subscriptionSchema, { method: "POST" });
1213
+ return response.data;
1214
+ }
1215
+ async renew(subscriptionId, returnUrl, embedded) {
1216
+ const response = await this.api.authenticatedFetch(`/api/customer/inventory/subscriptions/${subscriptionId}/renew?redirect=false&return=${returnUrl}&embedded=${embedded ? "true" : "false"}`, z14.object({
1217
+ location: z14.string()
1218
+ }), { method: "POST" });
1219
+ return response.data;
1220
+ }
1221
+ };
1222
+
1223
+ // src/inventory/index.ts
1224
+ var InventoryEndpoints = class {
1225
+ constructor(api, configuration) {
1226
+ this.licenses = new LicenseEndpoints(api, configuration);
1227
+ this.products = new ProductEndpoints(api, configuration);
1228
+ this.activation = new ActivationEndpoints(api, configuration);
1229
+ this.subscriptions = new SubscriptionEndpoints(api, configuration);
1230
+ }
1231
+ };
1232
+
1233
+ // src/orders/endpoints.ts
1234
+ var OrderEndpoints = class {
1235
+ constructor(api) {
1236
+ this.api = api;
1237
+ }
1238
+ async get(orderId, options) {
1239
+ const query = new URLSearchParams();
1240
+ if (options == null ? void 0 : options.finalize) {
1241
+ query.append("finalize", "true");
1242
+ }
1243
+ if (options == null ? void 0 : options.checkout) {
1244
+ query.append("checkout", "true");
1245
+ if (options.checkout.returnUrl) {
1246
+ query.append("returnUrl", options.checkout.returnUrl);
1247
+ }
1248
+ }
1249
+ const response = await this.api.fetch(`/api/customer/orders/${orderId}?${query.toString()}`, orderSchema, {
1250
+ abort: options == null ? void 0 : options.abort
1251
+ });
1252
+ return response.data;
1253
+ }
1254
+ async pushContent(order, checkout, utm) {
1255
+ const query = {
1256
+ ...utmToObject(utm)
1257
+ };
1258
+ if (checkout) {
1259
+ query.checkout = "true";
1260
+ if (checkout.returnUrl)
1261
+ query.returnUrl = checkout.returnUrl;
1262
+ }
1263
+ const response = await this.api.fetch(
1264
+ `/api/customer/orders/${order.id}?${new URLSearchParams(query).toString()}`,
1265
+ openOrderSchema,
1266
+ {
1267
+ method: "PATCH",
1268
+ body: {
1269
+ currency: order.currency || void 0,
1270
+ items: order.items
1271
+ }
1272
+ }
1273
+ );
1274
+ return response.data;
1275
+ }
1276
+ async addBillingDetails(orderId, details) {
1277
+ const response = await this.api.fetch(`/api/customer/orders/${orderId}/billing-details`, openOrderSchema, { method: "PATCH", body: details });
1278
+ return response.data;
1279
+ }
1280
+ async removeBillingDetails(orderId) {
1281
+ const response = await this.api.fetch(`/api/customer/orders/${orderId}/billing-details`, openOrderSchema, { method: "DELETE" });
1282
+ return response.data;
1283
+ }
1284
+ async addCouponCode(orderId, code) {
1285
+ const response = await this.api.fetch(`/api/customer/orders/${orderId}/coupon?code=${encodeURIComponent(code)}`, openOrderSchema, { method: "PATCH" });
1286
+ return response.data;
1287
+ }
1288
+ async removeCouponCode(orderId, code) {
1289
+ const response = await this.api.fetch(`/api/customer/orders/${orderId}/coupon?code=${encodeURIComponent(code)}`, openOrderSchema, { method: "DELETE" });
1290
+ return response.data;
1291
+ }
1292
+ async clearCouponCodes(orderId) {
1293
+ const response = await this.api.fetch(`/api/customer/orders/${orderId}/coupons`, openOrderSchema, { method: "DELETE" });
1294
+ return response.data;
1295
+ }
1296
+ };
1297
+
1298
+ // src/storefront/endpoints.ts
1299
+ var StorefrontEndpoints = class {
1300
+ constructor(api, configuration) {
1301
+ this.api = api;
1302
+ this.configuration = configuration;
1303
+ }
1304
+ async get(utm) {
1305
+ const query = new URLSearchParams(this.configuration.includeManifests ? {
1306
+ includeManifests: "true",
1307
+ ...utmToObject(utm)
1308
+ } : utmToObject(utm));
1309
+ const response = await this.api.fetch(`/api/customer/storefront?${query.toString()}`, storefrontSchema);
1310
+ return response.data;
1311
+ }
1312
+ };
1313
+
1314
+ // src/utils/store.ts
1315
+ var LocalStorageStore = class {
1316
+ get(key) {
1317
+ const item = localStorage.getItem(key);
1318
+ if (item) {
1319
+ return JSON.parse(item);
1320
+ }
1321
+ return null;
1322
+ }
1323
+ set(key, item) {
1324
+ localStorage.setItem(key, JSON.stringify(item));
1325
+ }
1326
+ remove(key) {
1327
+ localStorage.removeItem(key);
1328
+ }
1329
+ listen(key, callback) {
1330
+ if (typeof window !== "undefined") {
1331
+ window.addEventListener("storage", (event) => {
1332
+ if (event.key === key) {
1333
+ callback(event.newValue ? JSON.parse(event.newValue) : null);
1334
+ }
1335
+ });
1336
+ }
1337
+ }
1338
+ };
1339
+ var InMemoryStore = class {
1340
+ constructor() {
1341
+ this.store = {};
1342
+ this.listeners = {};
1343
+ }
1344
+ get(key) {
1345
+ var _a;
1346
+ return (_a = this.store[key]) != null ? _a : null;
1347
+ }
1348
+ set(key, item) {
1349
+ this.store[key] = item;
1350
+ for (const listener of this.listeners[key] || []) {
1351
+ listener(item);
1352
+ }
1353
+ }
1354
+ remove(key) {
1355
+ delete this.store[key];
1356
+ for (const listener of this.listeners[key] || []) {
1357
+ listener(null);
1358
+ }
1359
+ }
1360
+ listen(key, callback) {
1361
+ if (!this.listeners[key]) this.listeners[key] = [];
1362
+ this.listeners[key].push(callback);
1363
+ }
1364
+ };
1365
+
1366
+ // src/utils/tokenStore.ts
1367
+ var _TokenStore = class _TokenStore {
1368
+ constructor(configuration) {
1369
+ this.configuration = configuration;
1370
+ this.tokens = null;
1371
+ this.refreshTimeoutId = null;
1372
+ this.refreshPromise = null;
1373
+ var _a;
1374
+ this.store = (_a = configuration.store) != null ? _a : typeof window !== "undefined" && localStorage ? new LocalStorageStore() : new InMemoryStore();
1375
+ const storedToken = this.store.get(_TokenStore.storageKey);
1376
+ if (storedToken) {
1377
+ this.tokens = {
1378
+ ...storedToken,
1379
+ expiresAt: new Date(storedToken.expiresAt)
1380
+ };
1381
+ }
1382
+ this.store.listen(_TokenStore.storageKey, (updatedTokens) => this.handleStorageUpdate(updatedTokens));
1383
+ }
1384
+ get user() {
1385
+ if (this.tokens)
1386
+ return this.tokens;
1387
+ return null;
1388
+ }
1389
+ async getAccessToken() {
1390
+ var _a, _b, _c;
1391
+ if (this.isExpired) {
1392
+ if (this.refreshPromise) {
1393
+ const tokens2 = await this.refreshPromise;
1394
+ return (_a = tokens2 == null ? void 0 : tokens2.accessToken) != null ? _a : null;
1395
+ }
1396
+ this.refreshPromise = this.refreshTokens();
1397
+ const tokens = await this.refreshPromise;
1398
+ return (_b = tokens == null ? void 0 : tokens.accessToken) != null ? _b : null;
1399
+ }
1400
+ return ((_c = this.tokens) == null ? void 0 : _c.accessToken) || null;
1401
+ }
1402
+ setUser(user) {
1403
+ const identity = user;
1404
+ if (!identity.accessToken || !identity.refreshToken) {
1405
+ if (!this.tokens) return null;
1406
+ this.tokens = {
1407
+ ...user,
1408
+ accessToken: this.tokens.accessToken,
1409
+ refreshToken: this.tokens.refreshToken,
1410
+ expiresAt: this.tokens.expiresAt
1411
+ };
1412
+ } else {
1413
+ this.tokens = {
1414
+ ...identity,
1415
+ // Hardcoded 15 minutes now, might want to check the JWT tho
1416
+ expiresAt: new Date((/* @__PURE__ */ new Date()).getTime() + 15 * 60 * 1e3)
1417
+ };
1418
+ }
1419
+ this.store.set(_TokenStore.storageKey, this.tokens);
1420
+ if (typeof window !== "undefined") {
1421
+ if (this.refreshTimeoutId != null)
1422
+ window.clearTimeout(this.refreshTimeoutId);
1423
+ this.refreshTimeoutId = window.setTimeout(() => {
1424
+ this.refreshPromise = this.refreshTokens();
1425
+ }, 10 * 60 * 1e3);
1426
+ }
1427
+ return this.tokens;
1428
+ }
1429
+ clear() {
1430
+ this.tokens = null;
1431
+ this.store.remove(_TokenStore.storageKey);
1432
+ if (this.refreshTimeoutId != null && typeof window !== "undefined")
1433
+ window.clearTimeout(this.refreshTimeoutId);
1434
+ return null;
1435
+ }
1436
+ get isExpired() {
1437
+ return this.tokens != null && this.tokens.expiresAt < /* @__PURE__ */ new Date();
1438
+ }
1439
+ async refreshTokens() {
1440
+ if (!this.tokens)
1441
+ throw new Error("No tokens found to refresh");
1442
+ const response = await fetch(`${this.configuration.endpoint}/api/customer/identity/refresh?token=${this.tokens.refreshToken}`, {
1443
+ method: "POST",
1444
+ headers: {
1445
+ "Accept": "application/json",
1446
+ "Content-Type": "text/plain",
1447
+ "x-mb-cors": "1"
1448
+ },
1449
+ body: this.tokens.accessToken
1450
+ });
1451
+ if (response.status !== 200) {
1452
+ if (response.status === 403 || response.status === 404) {
1453
+ this.clear();
1454
+ return null;
1455
+ }
1456
+ throw new MoonbaseError("Unexpected result", `Could not refresh access token, status code ${response.status}`, response.status);
1457
+ }
1458
+ const result = identitySchema.parse(await response.json());
1459
+ this.setUser(result);
1460
+ return this.tokens;
1461
+ }
1462
+ handleStorageUpdate(updatedTokens) {
1463
+ this.tokens = updatedTokens;
1464
+ if (this.refreshTimeoutId != null)
1465
+ window.clearTimeout(this.refreshTimeoutId);
1466
+ if (this.tokens) {
1467
+ this.tokens.expiresAt = new Date(this.tokens.expiresAt);
1468
+ }
1469
+ }
1470
+ };
1471
+ _TokenStore.storageKey = "moonbase_auth";
1472
+ var TokenStore = _TokenStore;
1473
+
1474
+ // src/vendor/schemas.ts
1475
+ var schemas_exports9 = {};
1476
+ __export(schemas_exports9, {
1477
+ vendorSchema: () => vendorSchema
1478
+ });
1479
+ import { z as z15 } from "zod";
1480
+ var vendorSchema = z15.object({
1481
+ id: z15.string(),
1482
+ name: z15.string(),
1483
+ logoUrl: z15.string().nullable()
1484
+ });
1485
+
1486
+ // src/vendor/endpoints.ts
1487
+ var VendorEndpoints = class {
1488
+ constructor(api) {
1489
+ this.api = api;
1490
+ }
1491
+ async get() {
1492
+ const response = await this.api.fetch(`/api/public/vendors/current`, vendorSchema);
1493
+ return response.data;
1494
+ }
1495
+ };
1496
+
1497
+ // src/vouchers/schemas.ts
1498
+ var schemas_exports10 = {};
1499
+ __export(schemas_exports10, {
1500
+ voucherSchema: () => voucherSchema
1501
+ });
1502
+ import { z as z16 } from "zod";
1503
+ var voucherSchema = z16.object({
1504
+ id: z16.string(),
1505
+ name: z16.string(),
1506
+ description: z16.string(),
1507
+ code: z16.string(),
1508
+ redeemed: z16.boolean(),
1509
+ redeemsProducts: quantifiable(storefrontProductSchema).array(),
1510
+ redeemsBundles: quantifiable(storefrontBundleSchema).array(),
1511
+ properties: z16.record(rawPropertyValueSchema).nullish()
1512
+ });
1513
+
1514
+ // src/vouchers/endpoints.ts
1515
+ var VoucherEndpoints = class {
1516
+ constructor(api) {
1517
+ this.api = api;
1518
+ }
1519
+ async peek(code) {
1520
+ const response = await this.api.fetch(`/api/customer/vouchers?code=${encodeURIComponent(code)}`, voucherSchema);
1521
+ return response.data;
1522
+ }
1523
+ async redeem(code) {
1524
+ const response = await this.api.authenticatedFetch(
1525
+ `/api/customer/vouchers/redeem?code=${encodeURIComponent(code)}`,
1526
+ voucherSchema,
1527
+ {
1528
+ method: "POST"
1529
+ }
1530
+ );
1531
+ return response.data;
1532
+ }
1533
+ };
1534
+
1535
+ // src/utils/logger.ts
1536
+ var LogLevel = /* @__PURE__ */ ((LogLevel2) => {
1537
+ LogLevel2[LogLevel2["Debug"] = 0] = "Debug";
1538
+ LogLevel2[LogLevel2["Information"] = 1] = "Information";
1539
+ LogLevel2[LogLevel2["Warn"] = 2] = "Warn";
1540
+ LogLevel2[LogLevel2["Error"] = 3] = "Error";
1541
+ return LogLevel2;
1542
+ })(LogLevel || {});
1543
+ var ConsoleLogger = class {
1544
+ constructor(level = 2 /* Warn */) {
1545
+ this.level = level;
1546
+ }
1547
+ debug(message, ...optionalParams) {
1548
+ if (this.level <= 0 /* Debug */) console.debug(message, ...optionalParams);
1549
+ }
1550
+ log(message, ...optionalParams) {
1551
+ if (this.level <= 1 /* Information */) console.log(message, ...optionalParams);
1552
+ }
1553
+ warn(message, ...optionalParams) {
1554
+ if (this.level <= 2 /* Warn */) console.warn(message, ...optionalParams);
1555
+ }
1556
+ error(message, ...optionalParams) {
1557
+ if (this.level <= 3 /* Error */) console.error(message, ...optionalParams);
1558
+ }
1559
+ };
1560
+
1561
+ // src/schemas.ts
1562
+ var schemas_exports12 = {};
1563
+ __export(schemas_exports12, {
1564
+ activationRequests: () => schemas_exports3,
1565
+ communications: () => schemas_exports4,
1566
+ identity: () => schemas_exports5,
1567
+ inventory: () => schemas_exports11,
1568
+ orders: () => schemas_exports7,
1569
+ storefront: () => schemas_exports2,
1570
+ vendor: () => schemas_exports9,
1571
+ vouchers: () => schemas_exports10
1572
+ });
1573
+
1574
+ // src/inventory/schemas.ts
1575
+ var schemas_exports11 = {};
1576
+ __export(schemas_exports11, {
1577
+ licenses: () => schemas_exports6,
1578
+ products: () => schemas_exports,
1579
+ subscriptions: () => schemas_exports8
1580
+ });
1581
+
1582
+ // src/utils/discount.ts
1583
+ var DiscountUtils = class {
1584
+ static apply(discount, price) {
1585
+ switch (discount.type) {
1586
+ case "PercentageOffDiscount":
1587
+ return Object.fromEntries(Object.entries(price).map(([currency, amount]) => [currency, amount * discount.percentage]));
1588
+ case "FlatAmountOffDiscount":
1589
+ return Object.fromEntries(Object.entries(price).map(([currency, amount]) => {
1590
+ var _a, _b;
1591
+ return [currency, Math.min(amount, (_b = (_a = discount.total) == null ? void 0 : _a[currency]) != null ? _b : 0)];
1592
+ }));
1593
+ }
1594
+ }
1595
+ };
1596
+
1597
+ // src/utils/money.ts
1598
+ var MoneyCollectionUtils = class {
1599
+ static sum(a, b) {
1600
+ return Object.fromEntries(Object.entries(a).map(([currency, amount]) => [currency, amount + b[currency]]));
1601
+ }
1602
+ static subtract(a, b) {
1603
+ return Object.fromEntries(Object.entries(a).map(([currency, amount]) => [currency, amount - b[currency]]));
1604
+ }
1605
+ };
1606
+
1607
+ // src/utils/offer.ts
1608
+ var OfferUtils = class _OfferUtils {
1609
+ static eligible(offer, order) {
1610
+ switch (offer.condition.type) {
1611
+ case "CartContainsItems":
1612
+ const relevantItems = order.items.filter(
1613
+ (i) => i.type === "Product" && offer.condition.relevantItemVariations[`Product/${i.productId}`] && offer.condition.relevantItemVariations[`Product/${i.productId}`].includes(i.variationId) || i.type === "Bundle" && offer.condition.relevantItemVariations[`Bundle/${i.bundleId}`] && offer.condition.relevantItemVariations[`Bundle/${i.bundleId}`].includes(i.variationId)
1614
+ );
1615
+ const relevantReplacedItems = order.items.flatMap((i) => {
1616
+ var _a;
1617
+ return offer.id === i.offerId && i.type === "Bundle" && _OfferUtils.targetContainsBundle(offer, i.id) ? (_a = i.replaced) != null ? _a : [] : [];
1618
+ }).filter((ref) => {
1619
+ const [productId, variationId] = ref.split("/");
1620
+ return offer.condition.relevantItemVariations[`Product/${productId}`] && offer.condition.relevantItemVariations[`Product/${productId}`].includes(variationId);
1621
+ });
1622
+ return relevantItems.length + relevantReplacedItems.length >= offer.condition.minimumItems;
1623
+ }
1624
+ console.warn("Unsupported offer condition found:", offer.condition);
1625
+ return false;
1626
+ }
1627
+ // The relevant targets of an offer with more than a single target needs to:
1628
+ // a. Not be owned, or all targets need to be owned
1629
+ // b. Not already in the cart
1630
+ static relevantTargets(offer, cartItems) {
1631
+ if (Array.isArray(offer.target)) {
1632
+ const allOwned = offer.target.every((i) => i.owned);
1633
+ return offer.target.filter((i) => (allOwned || !i.owned) && !cartItems.some((l) => l.type === i.type && i.id === (l.type === "Product" ? l.productId : l.bundleId)));
1634
+ }
1635
+ return [offer.target];
1636
+ }
1637
+ static applyToVariation(offer, variation) {
1638
+ const discount = DiscountUtils.apply(offer.discount, variation.price);
1639
+ return {
1640
+ ...variation,
1641
+ price: MoneyCollectionUtils.subtract(variation.price, discount),
1642
+ hasDiscount: Object.values(discount).some((v) => v > 0) || variation.hasDiscount
1643
+ };
1644
+ }
1645
+ static targetContainsBundle(offer, bundleId) {
1646
+ if (Array.isArray(offer.target)) return offer.target.some((i) => i.type === "Bundle" && i.id === bundleId);
1647
+ }
1648
+ };
1649
+
1650
+ // src/utils/utm.ts
1651
+ function parseOffSiteReferrer(rawReferrer, currentOrigin) {
1652
+ if (!rawReferrer)
1653
+ return void 0;
1654
+ try {
1655
+ const referrerUrl = new URL(rawReferrer);
1656
+ if (referrerUrl.origin === currentOrigin)
1657
+ return void 0;
1658
+ return referrerUrl.host || void 0;
1659
+ } catch (e) {
1660
+ return void 0;
1661
+ }
1662
+ }
1663
+ function resolveUtm(cached, fresh) {
1664
+ const freshHasUtm = !!(fresh.source || fresh.medium || fresh.campaign || fresh.term || fresh.content);
1665
+ const freshIsExternalArrival = freshHasUtm || !!fresh.referrer;
1666
+ if (freshIsExternalArrival)
1667
+ return fresh;
1668
+ return cached != null ? cached : fresh;
1669
+ }
1670
+
1671
+ // src/index.ts
1672
+ var MoonbaseClient = class {
1673
+ constructor(configuration) {
1674
+ var _a;
1675
+ this.configuration = configuration;
1676
+ this.configuration.endpoint = this.configuration.endpoint.replace(/\/$/, "");
1677
+ this.logger = (_a = this.configuration.logger) != null ? _a : new ConsoleLogger();
1678
+ this.tokenStore = new TokenStore(configuration);
1679
+ this.api = new MoonbaseApi(this.configuration.endpoint, this.tokenStore, this.logger);
1680
+ this.storefront = new StorefrontEndpoints(this.api, this.configuration);
1681
+ this.identity = new IdentityEndpoints(this.api, this.tokenStore, this.logger);
1682
+ this.communications = new CommunicationsEndpoints(this.api);
1683
+ this.vouchers = new VoucherEndpoints(this.api);
1684
+ this.orders = new OrderEndpoints(this.api);
1685
+ this.inventory = new InventoryEndpoints(this.api, this.configuration);
1686
+ this.activationRequests = new ActivationRequestEndpoints(this.api);
1687
+ this.vendor = new VendorEndpoints(this.api);
1688
+ }
1689
+ };
1690
+ export {
1691
+ ActivationMethod,
1692
+ ActivationRequestFulfillmentType,
1693
+ ActivationRequestStatus,
1694
+ ActivationStatus,
1695
+ Architecture,
1696
+ ConnectableAccountProvider,
1697
+ ConsoleLogger,
1698
+ CycleLength,
1699
+ DiscountUtils,
1700
+ InMemoryStore,
1701
+ LicenseStatus,
1702
+ LocalStorageStore,
1703
+ LogLevel,
1704
+ MarketingConsentType,
1705
+ MoneyCollectionUtils,
1706
+ MoonbaseApi,
1707
+ MoonbaseClient,
1708
+ MoonbaseError,
1709
+ NotAuthenticatedError,
1710
+ NotAuthorizedError,
1711
+ NotFoundError,
1712
+ OfferUtils,
1713
+ OrderStatus,
1714
+ Platform,
1715
+ SubscriptionStatus,
1716
+ TokenStore,
1717
+ objectToQuery,
1718
+ parseOffSiteReferrer,
1719
+ problemDetailsSchema,
1720
+ resolveUtm,
1721
+ schemas_exports12 as schemas,
1722
+ utmToObject
1723
+ };