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