@moonbase.sh/storefront-api 0.2.115 → 0.2.117

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -463,6 +463,130 @@ var IdentityEndpoints = class {
463
463
  }
464
464
  };
465
465
 
466
+ // src/inventory/activation/endpoints.ts
467
+ var import_zod9 = require("zod");
468
+
469
+ // src/inventory/licenses/schemas.ts
470
+ var import_zod8 = require("zod");
471
+
472
+ // src/inventory/licenses/models.ts
473
+ var LicenseStatus = /* @__PURE__ */ ((LicenseStatus2) => {
474
+ LicenseStatus2["Active"] = "Active";
475
+ LicenseStatus2["Revoked"] = "Revoked";
476
+ return LicenseStatus2;
477
+ })(LicenseStatus || {});
478
+ var ActivationStatus = /* @__PURE__ */ ((ActivationStatus2) => {
479
+ ActivationStatus2["Active"] = "Active";
480
+ ActivationStatus2["Revoked"] = "Revoked";
481
+ return ActivationStatus2;
482
+ })(ActivationStatus || {});
483
+ var ActivationMethod = /* @__PURE__ */ ((ActivationMethod2) => {
484
+ ActivationMethod2["Online"] = "Online";
485
+ ActivationMethod2["Offline"] = "Offline";
486
+ return ActivationMethod2;
487
+ })(ActivationMethod || {});
488
+
489
+ // src/inventory/licenses/schemas.ts
490
+ var licenseSchema = import_zod8.z.object({
491
+ id: import_zod8.z.string(),
492
+ status: import_zod8.z.nativeEnum(LicenseStatus),
493
+ product: productSummarySchema,
494
+ activeNumberOfActivations: import_zod8.z.number(),
495
+ maxNumberOfActivations: import_zod8.z.number(),
496
+ createdAt: import_zod8.z.coerce.date()
497
+ });
498
+ var activationSchema = import_zod8.z.object({
499
+ id: import_zod8.z.string(),
500
+ licenseId: import_zod8.z.string(),
501
+ name: import_zod8.z.string(),
502
+ status: import_zod8.z.nativeEnum(ActivationStatus),
503
+ activationMethod: import_zod8.z.nativeEnum(ActivationMethod),
504
+ lastValidatedAt: import_zod8.z.coerce.date().nullable()
505
+ });
506
+
507
+ // src/inventory/activation/endpoints.ts
508
+ var ActivationEndpoints = class {
509
+ constructor(api, configuration) {
510
+ this.api = api;
511
+ this.configuration = configuration;
512
+ }
513
+ async activate(deviceToken, activationMethod) {
514
+ const response = await this.api.authenticatedFetch(`/api/customer/inventory/activate?method=${activationMethod}${this.configuration.includeManifests ? "&includeManifests=true" : ""}`, licenseSchema, {
515
+ method: "POST",
516
+ body: deviceToken,
517
+ contentType: "text/plain"
518
+ });
519
+ return {
520
+ license: response.data,
521
+ url: import_zod9.z.string().parse(response.headers.location)
522
+ };
523
+ }
524
+ };
525
+
526
+ // src/inventory/licenses/endpoints.ts
527
+ var LicenseEndpoints = class {
528
+ constructor(api, configuration) {
529
+ this.api = api;
530
+ this.configuration = configuration;
531
+ }
532
+ async get(nextUrl) {
533
+ const response = await this.api.authenticatedFetch(nextUrl || `/api/customer/inventory/licenses${this.configuration.includeManifests ? "?includeManifests=true" : ""}`, paged(licenseSchema));
534
+ return response.data;
535
+ }
536
+ async getActivations(licenseId, nextUrl) {
537
+ const response = await this.api.authenticatedFetch(
538
+ nextUrl || `/api/customer/inventory/licenses/${licenseId}/activations`,
539
+ paged(activationSchema)
540
+ );
541
+ return response.data;
542
+ }
543
+ async revokeActivation(licenseId, activationId) {
544
+ await this.api.authenticatedFetch(`/api/customer/inventory/licenses/${licenseId}/activations/${activationId}/revoke`, null, { method: "POST" });
545
+ }
546
+ };
547
+
548
+ // src/inventory/products/endpoints.ts
549
+ var import_zod10 = require("zod");
550
+ var ProductEndpoints = class {
551
+ constructor(api, configuration) {
552
+ this.api = api;
553
+ this.configuration = configuration;
554
+ }
555
+ async get(productId, version) {
556
+ 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);
557
+ return response.data;
558
+ }
559
+ async getOwned(nextUrl) {
560
+ const response = await this.api.authenticatedFetch(nextUrl || `/api/customer/inventory/products${this.configuration.includeManifests ? "?includeManifests=true" : ""}`, paged(productSummarySchema));
561
+ return response.data;
562
+ }
563
+ async getLicenses(productId, nextUrl) {
564
+ const response = await this.api.authenticatedFetch(nextUrl || `/api/customer/inventory/products/${productId}/licenses${this.configuration.includeManifests ? "?includeManifests=true" : ""}`, paged(licenseSchema));
565
+ return response.data;
566
+ }
567
+ async getActivations(productId, nextUrl) {
568
+ const response = await this.api.authenticatedFetch(nextUrl || `/api/customer/inventory/products/${productId}/licenses/activations`, paged(activationSchema));
569
+ return response.data;
570
+ }
571
+ async getDownloadUrl(path) {
572
+ const url = new URL(path);
573
+ url.searchParams.append("redirect", "false");
574
+ const response = await this.api.fetch(url.pathname + url.search, import_zod10.z.object({
575
+ location: import_zod10.z.string()
576
+ }));
577
+ return response.data.location;
578
+ }
579
+ };
580
+
581
+ // src/inventory/index.ts
582
+ var InventoryEndpoints = class {
583
+ constructor(api, configuration) {
584
+ this.licenses = new LicenseEndpoints(api, configuration);
585
+ this.products = new ProductEndpoints(api, configuration);
586
+ this.activation = new ActivationEndpoints(api, configuration);
587
+ }
588
+ };
589
+
466
590
  // src/orders/schemas.ts
467
591
  var schemas_exports = {};
468
592
  __export(schemas_exports, {
@@ -473,7 +597,7 @@ __export(schemas_exports, {
473
597
  openProductLineItem: () => openProductLineItem,
474
598
  orderSchema: () => orderSchema
475
599
  });
476
- var import_zod8 = require("zod");
600
+ var import_zod11 = require("zod");
477
601
 
478
602
  // src/orders/models.ts
479
603
  var OrderStatus = /* @__PURE__ */ ((OrderStatus2) => {
@@ -485,90 +609,90 @@ var OrderStatus = /* @__PURE__ */ ((OrderStatus2) => {
485
609
  })(OrderStatus || {});
486
610
 
487
611
  // src/orders/schemas.ts
488
- var couponSchema = import_zod8.z.object({
489
- code: import_zod8.z.string(),
490
- name: import_zod8.z.string(),
491
- description: import_zod8.z.string()
492
- });
493
- var lineItemProductSchema = import_zod8.z.object({
494
- id: import_zod8.z.string(),
495
- name: import_zod8.z.string(),
496
- tagline: import_zod8.z.string(),
497
- iconUrl: import_zod8.z.string().nullable()
498
- });
499
- var openProductLineItem = import_zod8.z.object({
500
- id: import_zod8.z.string(),
501
- type: import_zod8.z.literal("Product"),
502
- productId: import_zod8.z.string(),
503
- quantity: import_zod8.z.number(),
504
- variationId: import_zod8.z.string(),
612
+ var couponSchema = import_zod11.z.object({
613
+ code: import_zod11.z.string(),
614
+ name: import_zod11.z.string(),
615
+ description: import_zod11.z.string()
616
+ });
617
+ var lineItemProductSchema = import_zod11.z.object({
618
+ id: import_zod11.z.string(),
619
+ name: import_zod11.z.string(),
620
+ tagline: import_zod11.z.string(),
621
+ iconUrl: import_zod11.z.string().nullable()
622
+ });
623
+ var openProductLineItem = import_zod11.z.object({
624
+ id: import_zod11.z.string(),
625
+ type: import_zod11.z.literal("Product"),
626
+ productId: import_zod11.z.string(),
627
+ quantity: import_zod11.z.number(),
628
+ variationId: import_zod11.z.string(),
505
629
  price: priceCollectionSchema.optional(),
506
630
  variation: pricingVariationSchema.optional(),
507
631
  product: lineItemProductSchema.optional(),
508
632
  appliedDiscount: discountSchema.optional()
509
633
  });
510
- var lineItemBundleSchema = import_zod8.z.object({
511
- id: import_zod8.z.string(),
512
- name: import_zod8.z.string(),
513
- tagline: import_zod8.z.string(),
514
- iconUrl: import_zod8.z.string().nullable(),
515
- products: lineItemProductSchema.and(import_zod8.z.object({
516
- included: import_zod8.z.boolean().optional()
634
+ var lineItemBundleSchema = import_zod11.z.object({
635
+ id: import_zod11.z.string(),
636
+ name: import_zod11.z.string(),
637
+ tagline: import_zod11.z.string(),
638
+ iconUrl: import_zod11.z.string().nullable(),
639
+ products: lineItemProductSchema.and(import_zod11.z.object({
640
+ included: import_zod11.z.boolean().optional()
517
641
  })).array()
518
642
  });
519
- var openBundleLineItem = import_zod8.z.object({
520
- id: import_zod8.z.string(),
521
- type: import_zod8.z.literal("Bundle"),
522
- bundleId: import_zod8.z.string(),
523
- quantity: import_zod8.z.number(),
524
- variationId: import_zod8.z.string(),
525
- partial: import_zod8.z.boolean().optional(),
643
+ var openBundleLineItem = import_zod11.z.object({
644
+ id: import_zod11.z.string(),
645
+ type: import_zod11.z.literal("Bundle"),
646
+ bundleId: import_zod11.z.string(),
647
+ quantity: import_zod11.z.number(),
648
+ variationId: import_zod11.z.string(),
649
+ partial: import_zod11.z.boolean().optional(),
526
650
  price: priceCollectionSchema.optional(),
527
651
  variation: pricingVariationSchema.optional(),
528
652
  bundle: lineItemBundleSchema.optional(),
529
653
  appliedDiscount: discountSchema.optional()
530
654
  });
531
- var openOrderLineItem = import_zod8.z.discriminatedUnion("type", [
655
+ var openOrderLineItem = import_zod11.z.discriminatedUnion("type", [
532
656
  openProductLineItem,
533
657
  openBundleLineItem
534
658
  ]);
535
- var openOrderSchema = import_zod8.z.object({
536
- id: import_zod8.z.string(),
537
- status: import_zod8.z.literal("Open" /* Open */),
538
- currency: import_zod8.z.string(),
659
+ var openOrderSchema = import_zod11.z.object({
660
+ id: import_zod11.z.string(),
661
+ status: import_zod11.z.literal("Open" /* Open */),
662
+ currency: import_zod11.z.string(),
539
663
  items: openOrderLineItem.array(),
540
664
  couponsApplied: couponSchema.array(),
541
- checkoutUrl: import_zod8.z.string().optional(),
542
- embeddedCheckoutUrl: import_zod8.z.string().optional()
665
+ checkoutUrl: import_zod11.z.string().optional(),
666
+ embeddedCheckoutUrl: import_zod11.z.string().optional()
543
667
  });
544
- var moneySchema = import_zod8.z.object({
545
- currency: import_zod8.z.string(),
546
- amount: import_zod8.z.number()
668
+ var moneySchema = import_zod11.z.object({
669
+ currency: import_zod11.z.string(),
670
+ amount: import_zod11.z.number()
547
671
  });
548
- var orderTotalSchema = import_zod8.z.object({
672
+ var orderTotalSchema = import_zod11.z.object({
549
673
  original: moneySchema,
550
674
  discount: moneySchema,
551
675
  subtotal: moneySchema,
552
676
  taxes: moneySchema,
553
677
  due: moneySchema
554
678
  });
555
- var customerSnapshotSchema = import_zod8.z.object({
556
- name: import_zod8.z.string().nullable(),
557
- businessName: import_zod8.z.string().nullable(),
558
- taxId: import_zod8.z.string().nullable(),
559
- email: import_zod8.z.string().nullable(),
679
+ var customerSnapshotSchema = import_zod11.z.object({
680
+ name: import_zod11.z.string().nullable(),
681
+ businessName: import_zod11.z.string().nullable(),
682
+ taxId: import_zod11.z.string().nullable(),
683
+ email: import_zod11.z.string().nullable(),
560
684
  address: addressSchema.nullable()
561
685
  });
562
- var completedOrderSchema = import_zod8.z.object({
563
- id: import_zod8.z.string(),
564
- status: import_zod8.z.literal("Completed" /* Completed */),
565
- currency: import_zod8.z.string(),
686
+ var completedOrderSchema = import_zod11.z.object({
687
+ id: import_zod11.z.string(),
688
+ status: import_zod11.z.literal("Completed" /* Completed */),
689
+ currency: import_zod11.z.string(),
566
690
  customer: customerSnapshotSchema,
567
691
  total: orderTotalSchema,
568
692
  items: openOrderLineItem.array(),
569
693
  couponsApplied: couponSchema.array()
570
694
  });
571
- var orderSchema = import_zod8.z.discriminatedUnion("status", [
695
+ var orderSchema = import_zod11.z.discriminatedUnion("status", [
572
696
  openOrderSchema,
573
697
  completedOrderSchema
574
698
  ]);
@@ -578,8 +702,10 @@ var OrderEndpoints = class {
578
702
  constructor(api) {
579
703
  this.api = api;
580
704
  }
581
- async get(orderId) {
582
- const response = await this.api.fetch(`/api/customer/orders/${orderId}`, orderSchema);
705
+ async get(orderId, abort) {
706
+ const response = await this.api.fetch(`/api/customer/orders/${orderId}`, orderSchema, {
707
+ abort
708
+ });
583
709
  return response.data;
584
710
  }
585
711
  async pushContent(order, checkout, utm) {
@@ -667,7 +793,8 @@ var MoonbaseApi = class {
667
793
  // Force CORS on all calls
668
794
  "x-mb-cors": "1"
669
795
  },
670
- body: (options == null ? void 0 : options.body) ? contentType !== "application/json" ? options.body : JSON.stringify(options.body) : void 0
796
+ body: (options == null ? void 0 : options.body) ? contentType !== "application/json" ? options.body : JSON.stringify(options.body) : void 0,
797
+ signal: options == null ? void 0 : options.abort
671
798
  });
672
799
  if (response.status >= 400)
673
800
  await handleResponseProblem(response);
@@ -795,14 +922,33 @@ var _TokenStore = class _TokenStore {
795
922
  _TokenStore.storageKey = "moonbase_auth";
796
923
  var TokenStore = _TokenStore;
797
924
 
925
+ // src/vendor/schemas.ts
926
+ var import_zod12 = require("zod");
927
+ var vendorSchema = import_zod12.z.object({
928
+ id: import_zod12.z.string(),
929
+ name: import_zod12.z.string(),
930
+ logoUrl: import_zod12.z.string().nullable()
931
+ });
932
+
933
+ // src/vendor/endpoints.ts
934
+ var VendorEndpoints = class {
935
+ constructor(api) {
936
+ this.api = api;
937
+ }
938
+ async get() {
939
+ const response = await this.api.fetch(`/api/public/vendors/current`, vendorSchema);
940
+ return response.data;
941
+ }
942
+ };
943
+
798
944
  // src/vouchers/schemas.ts
799
- var import_zod9 = require("zod");
800
- var voucherSchema = import_zod9.z.object({
801
- id: import_zod9.z.string(),
802
- name: import_zod9.z.string(),
803
- description: import_zod9.z.string(),
804
- code: import_zod9.z.string(),
805
- redeemed: import_zod9.z.boolean(),
945
+ var import_zod13 = require("zod");
946
+ var voucherSchema = import_zod13.z.object({
947
+ id: import_zod13.z.string(),
948
+ name: import_zod13.z.string(),
949
+ description: import_zod13.z.string(),
950
+ code: import_zod13.z.string(),
951
+ redeemed: import_zod13.z.boolean(),
806
952
  redeemsProducts: quantifiable(storefrontProductSchema).array(),
807
953
  redeemsBundles: quantifiable(storefrontBundleSchema).array()
808
954
  });
@@ -828,149 +974,6 @@ var VoucherEndpoints = class {
828
974
  }
829
975
  };
830
976
 
831
- // src/inventory/activation/endpoints.ts
832
- var import_zod11 = require("zod");
833
-
834
- // src/inventory/licenses/schemas.ts
835
- var import_zod10 = require("zod");
836
-
837
- // src/inventory/licenses/models.ts
838
- var LicenseStatus = /* @__PURE__ */ ((LicenseStatus2) => {
839
- LicenseStatus2["Active"] = "Active";
840
- LicenseStatus2["Revoked"] = "Revoked";
841
- return LicenseStatus2;
842
- })(LicenseStatus || {});
843
- var ActivationStatus = /* @__PURE__ */ ((ActivationStatus2) => {
844
- ActivationStatus2["Active"] = "Active";
845
- ActivationStatus2["Revoked"] = "Revoked";
846
- return ActivationStatus2;
847
- })(ActivationStatus || {});
848
- var ActivationMethod = /* @__PURE__ */ ((ActivationMethod2) => {
849
- ActivationMethod2["Online"] = "Online";
850
- ActivationMethod2["Offline"] = "Offline";
851
- return ActivationMethod2;
852
- })(ActivationMethod || {});
853
-
854
- // src/inventory/licenses/schemas.ts
855
- var licenseSchema = import_zod10.z.object({
856
- id: import_zod10.z.string(),
857
- status: import_zod10.z.nativeEnum(LicenseStatus),
858
- product: productSummarySchema,
859
- activeNumberOfActivations: import_zod10.z.number(),
860
- maxNumberOfActivations: import_zod10.z.number(),
861
- createdAt: import_zod10.z.coerce.date()
862
- });
863
- var activationSchema = import_zod10.z.object({
864
- id: import_zod10.z.string(),
865
- licenseId: import_zod10.z.string(),
866
- name: import_zod10.z.string(),
867
- status: import_zod10.z.nativeEnum(ActivationStatus),
868
- activationMethod: import_zod10.z.nativeEnum(ActivationMethod),
869
- lastValidatedAt: import_zod10.z.coerce.date().nullable()
870
- });
871
-
872
- // src/inventory/activation/endpoints.ts
873
- var ActivationEndpoints = class {
874
- constructor(api, configuration) {
875
- this.api = api;
876
- this.configuration = configuration;
877
- }
878
- async activate(deviceToken, activationMethod) {
879
- const response = await this.api.authenticatedFetch(`/api/customer/inventory/activate?method=${activationMethod}${this.configuration.includeManifests ? "&includeManifests=true" : ""}`, licenseSchema, {
880
- method: "POST",
881
- body: deviceToken,
882
- contentType: "text/plain"
883
- });
884
- return {
885
- license: response.data,
886
- url: import_zod11.z.string().parse(response.headers.location)
887
- };
888
- }
889
- };
890
-
891
- // src/inventory/licenses/endpoints.ts
892
- var LicenseEndpoints = class {
893
- constructor(api, configuration) {
894
- this.api = api;
895
- this.configuration = configuration;
896
- }
897
- async get(nextUrl) {
898
- const response = await this.api.authenticatedFetch(nextUrl || `/api/customer/inventory/licenses${this.configuration.includeManifests ? "?includeManifests=true" : ""}`, paged(licenseSchema));
899
- return response.data;
900
- }
901
- async getActivations(licenseId, nextUrl) {
902
- const response = await this.api.authenticatedFetch(
903
- nextUrl || `/api/customer/inventory/licenses/${licenseId}/activations`,
904
- paged(activationSchema)
905
- );
906
- return response.data;
907
- }
908
- async revokeActivation(licenseId, activationId) {
909
- await this.api.authenticatedFetch(`/api/customer/inventory/licenses/${licenseId}/activations/${activationId}/revoke`, null, { method: "POST" });
910
- }
911
- };
912
-
913
- // src/inventory/products/endpoints.ts
914
- var import_zod12 = require("zod");
915
- var ProductEndpoints = class {
916
- constructor(api, configuration) {
917
- this.api = api;
918
- this.configuration = configuration;
919
- }
920
- async get(productId, version) {
921
- 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);
922
- return response.data;
923
- }
924
- async getOwned(nextUrl) {
925
- const response = await this.api.authenticatedFetch(nextUrl || `/api/customer/inventory/products${this.configuration.includeManifests ? "?includeManifests=true" : ""}`, paged(productSummarySchema));
926
- return response.data;
927
- }
928
- async getLicenses(productId, nextUrl) {
929
- const response = await this.api.authenticatedFetch(nextUrl || `/api/customer/inventory/products/${productId}/licenses${this.configuration.includeManifests ? "?includeManifests=true" : ""}`, paged(licenseSchema));
930
- return response.data;
931
- }
932
- async getActivations(productId, nextUrl) {
933
- const response = await this.api.authenticatedFetch(nextUrl || `/api/customer/inventory/products/${productId}/licenses/activations`, paged(activationSchema));
934
- return response.data;
935
- }
936
- async getDownloadUrl(path) {
937
- const url = new URL(path);
938
- url.searchParams.append("redirect", "false");
939
- const response = await this.api.fetch(url.pathname + url.search, import_zod12.z.object({
940
- location: import_zod12.z.string()
941
- }));
942
- return response.data.location;
943
- }
944
- };
945
-
946
- // src/inventory/index.ts
947
- var InventoryEndpoints = class {
948
- constructor(api, configuration) {
949
- this.licenses = new LicenseEndpoints(api, configuration);
950
- this.products = new ProductEndpoints(api, configuration);
951
- this.activation = new ActivationEndpoints(api, configuration);
952
- }
953
- };
954
-
955
- // src/vendor/schemas.ts
956
- var import_zod13 = require("zod");
957
- var vendorSchema = import_zod13.z.object({
958
- id: import_zod13.z.string(),
959
- name: import_zod13.z.string(),
960
- logoUrl: import_zod13.z.string().nullable()
961
- });
962
-
963
- // src/vendor/endpoints.ts
964
- var VendorEndpoints = class {
965
- constructor(api) {
966
- this.api = api;
967
- }
968
- async get() {
969
- const response = await this.api.fetch(`/api/public/vendors/current`, vendorSchema);
970
- return response.data;
971
- }
972
- };
973
-
974
977
  // src/schemas.ts
975
978
  var schemas_exports2 = {};
976
979
  __export(schemas_exports2, {