@moonbase.sh/storefront-api 0.1.96 → 0.1.98

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
@@ -96,10 +96,10 @@ function quantifiable(itemSchema) {
96
96
  });
97
97
  }
98
98
 
99
- // src/products/schemas.ts
99
+ // src/inventory/products/schemas.ts
100
100
  var import_zod2 = require("zod");
101
101
 
102
- // src/products/models.ts
102
+ // src/inventory/products/models.ts
103
103
  var Platform = /* @__PURE__ */ ((Platform2) => {
104
104
  Platform2["Universal"] = "Universal";
105
105
  Platform2["Windows"] = "Windows";
@@ -108,7 +108,7 @@ var Platform = /* @__PURE__ */ ((Platform2) => {
108
108
  return Platform2;
109
109
  })(Platform || {});
110
110
 
111
- // src/products/schemas.ts
111
+ // src/inventory/products/schemas.ts
112
112
  var downloadSchema = import_zod2.z.object({
113
113
  name: import_zod2.z.string(),
114
114
  key: import_zod2.z.string(),
@@ -153,7 +153,7 @@ var storefrontBundleSchema = import_zod3.z.object({
153
153
  owned: import_zod3.z.boolean(),
154
154
  partial: import_zod3.z.boolean(),
155
155
  products: storefrontProductSchema.and(import_zod3.z.object({
156
- included: import_zod3.z.boolean()
156
+ included: import_zod3.z.boolean().optional()
157
157
  })).array(),
158
158
  defaultVariation: pricingVariationSchema.optional(),
159
159
  variations: pricingVariationSchema.array().optional(),
@@ -375,66 +375,8 @@ var IdentityEndpoints = class {
375
375
  }
376
376
  };
377
377
 
378
- // src/licenses/schemas.ts
379
- var import_zod8 = require("zod");
380
-
381
- // src/licenses/models.ts
382
- var LicenseStatus = /* @__PURE__ */ ((LicenseStatus2) => {
383
- LicenseStatus2["Active"] = "Active";
384
- LicenseStatus2["Revoked"] = "Revoked";
385
- return LicenseStatus2;
386
- })(LicenseStatus || {});
387
- var ActivationStatus = /* @__PURE__ */ ((ActivationStatus2) => {
388
- ActivationStatus2["Active"] = "Active";
389
- ActivationStatus2["Revoked"] = "Revoked";
390
- return ActivationStatus2;
391
- })(ActivationStatus || {});
392
- var ActivationMethod = /* @__PURE__ */ ((ActivationMethod2) => {
393
- ActivationMethod2["Online"] = "Online";
394
- ActivationMethod2["Offline"] = "Offline";
395
- return ActivationMethod2;
396
- })(ActivationMethod || {});
397
-
398
- // src/licenses/schemas.ts
399
- var licenseSchema = import_zod8.z.object({
400
- id: import_zod8.z.string(),
401
- status: import_zod8.z.nativeEnum(LicenseStatus),
402
- product: productSummarySchema.optional(),
403
- activeNumberOfActivations: import_zod8.z.number(),
404
- maxNumberOfActivations: import_zod8.z.number(),
405
- createdAt: import_zod8.z.coerce.date()
406
- });
407
- var activationSchema = import_zod8.z.object({
408
- id: import_zod8.z.string(),
409
- licenseId: import_zod8.z.string(),
410
- name: import_zod8.z.string(),
411
- status: import_zod8.z.nativeEnum(ActivationStatus),
412
- activationMethod: import_zod8.z.nativeEnum(ActivationMethod),
413
- lastValidatedAt: import_zod8.z.coerce.date().nullable()
414
- });
415
-
416
- // src/licenses/endpoints.ts
417
- var LicenseEndpoints = class {
418
- constructor(api) {
419
- this.api = api;
420
- }
421
- async get(nextUrl) {
422
- const response = await this.api.authenticatedFetch(nextUrl || "/api/customer/licenses");
423
- return paged(licenseSchema).parse(response.data);
424
- }
425
- async getActivations(licenseId, nextUrl) {
426
- const response = await this.api.authenticatedFetch(
427
- nextUrl || `/api/customer/licenses/${licenseId}/activations`
428
- );
429
- return paged(activationSchema).parse(response.data);
430
- }
431
- async revokeActivation(licenseId, activationId) {
432
- await this.api.authenticatedFetch(`/api/customer/licenses/${licenseId}/activations/${activationId}/revoke`, "POST");
433
- }
434
- };
435
-
436
378
  // src/orders/schemas.ts
437
- var import_zod9 = require("zod");
379
+ var import_zod8 = require("zod");
438
380
 
439
381
  // src/orders/models.ts
440
382
  var OrderStatus = /* @__PURE__ */ ((OrderStatus2) => {
@@ -448,65 +390,65 @@ var OrderStatus = /* @__PURE__ */ ((OrderStatus2) => {
448
390
  })(OrderStatus || {});
449
391
 
450
392
  // src/orders/schemas.ts
451
- var couponSchema = import_zod9.z.object({
452
- code: import_zod9.z.string(),
453
- name: import_zod9.z.string(),
454
- description: import_zod9.z.string()
393
+ var couponSchema = import_zod8.z.object({
394
+ code: import_zod8.z.string(),
395
+ name: import_zod8.z.string(),
396
+ description: import_zod8.z.string()
455
397
  });
456
- var percentageOffDiscountSchema2 = import_zod9.z.object({
457
- type: import_zod9.z.literal("PercentageOffDiscount"),
458
- name: import_zod9.z.string(),
459
- description: import_zod9.z.string().optional(),
460
- percentage: import_zod9.z.number(),
398
+ var percentageOffDiscountSchema2 = import_zod8.z.object({
399
+ type: import_zod8.z.literal("PercentageOffDiscount"),
400
+ name: import_zod8.z.string(),
401
+ description: import_zod8.z.string().optional(),
402
+ percentage: import_zod8.z.number(),
461
403
  total: priceCollectionSchema.optional(),
462
- isExclusive: import_zod9.z.boolean()
404
+ isExclusive: import_zod8.z.boolean()
463
405
  });
464
- var flatAmountOffDiscountSchema2 = import_zod9.z.object({
465
- type: import_zod9.z.literal("FlatAmountOffDiscount"),
466
- name: import_zod9.z.string(),
467
- description: import_zod9.z.string().optional(),
406
+ var flatAmountOffDiscountSchema2 = import_zod8.z.object({
407
+ type: import_zod8.z.literal("FlatAmountOffDiscount"),
408
+ name: import_zod8.z.string(),
409
+ description: import_zod8.z.string().optional(),
468
410
  total: priceCollectionSchema.optional(),
469
- isExclusive: import_zod9.z.boolean()
411
+ isExclusive: import_zod8.z.boolean()
470
412
  });
471
- var discountSchema2 = import_zod9.z.discriminatedUnion("type", [
413
+ var discountSchema2 = import_zod8.z.discriminatedUnion("type", [
472
414
  percentageOffDiscountSchema2,
473
415
  flatAmountOffDiscountSchema2
474
416
  ]);
475
- var openProductLineItem = import_zod9.z.object({
476
- id: import_zod9.z.string(),
477
- type: import_zod9.z.literal("Product"),
478
- productId: import_zod9.z.string(),
479
- quantity: import_zod9.z.number(),
480
- variationId: import_zod9.z.string(),
417
+ var openProductLineItem = import_zod8.z.object({
418
+ id: import_zod8.z.string(),
419
+ type: import_zod8.z.literal("Product"),
420
+ productId: import_zod8.z.string(),
421
+ quantity: import_zod8.z.number(),
422
+ variationId: import_zod8.z.string(),
481
423
  price: priceCollectionSchema.optional(),
482
424
  variation: pricingVariationSchema.optional(),
483
425
  product: storefrontProductSchema.optional(),
484
426
  appliedDiscount: discountSchema2.optional()
485
427
  });
486
- var openBundleLineItem = import_zod9.z.object({
487
- id: import_zod9.z.string(),
488
- type: import_zod9.z.literal("Bundle"),
489
- bundleId: import_zod9.z.string(),
490
- quantity: import_zod9.z.number(),
491
- variationId: import_zod9.z.string(),
428
+ var openBundleLineItem = import_zod8.z.object({
429
+ id: import_zod8.z.string(),
430
+ type: import_zod8.z.literal("Bundle"),
431
+ bundleId: import_zod8.z.string(),
432
+ quantity: import_zod8.z.number(),
433
+ variationId: import_zod8.z.string(),
492
434
  price: priceCollectionSchema.optional(),
493
435
  variation: pricingVariationSchema.optional(),
494
436
  bundle: storefrontBundleSchema.optional(),
495
437
  appliedDiscount: discountSchema2.optional()
496
438
  });
497
- var openOrderLineItem = import_zod9.z.discriminatedUnion("type", [
439
+ var openOrderLineItem = import_zod8.z.discriminatedUnion("type", [
498
440
  openProductLineItem,
499
441
  openBundleLineItem
500
442
  ]);
501
- var openOrderSchema = import_zod9.z.object({
502
- id: import_zod9.z.string(),
503
- status: import_zod9.z.literal("Open" /* Open */),
504
- currency: import_zod9.z.string(),
443
+ var openOrderSchema = import_zod8.z.object({
444
+ id: import_zod8.z.string(),
445
+ status: import_zod8.z.literal("Open" /* Open */),
446
+ currency: import_zod8.z.string(),
505
447
  items: openOrderLineItem.array(),
506
448
  couponsApplied: couponSchema.array(),
507
- checkoutUrl: import_zod9.z.string().optional()
449
+ checkoutUrl: import_zod8.z.string().optional()
508
450
  });
509
- var orderSchema = import_zod9.z.discriminatedUnion("status", [
451
+ var orderSchema = import_zod8.z.discriminatedUnion("status", [
510
452
  openOrderSchema
511
453
  ]);
512
454
 
@@ -539,33 +481,6 @@ var OrderEndpoints = class {
539
481
  }
540
482
  };
541
483
 
542
- // src/products/endpoints.ts
543
- var import_zod10 = require("zod");
544
- var ProductEndpoints = class {
545
- constructor(api) {
546
- this.api = api;
547
- }
548
- async getOwned(nextUrl) {
549
- const response = await this.api.authenticatedFetch(nextUrl || "/api/customer/products");
550
- return paged(productSummarySchema).parse(response.data);
551
- }
552
- async getLicenses(productId, nextUrl) {
553
- const response = await this.api.authenticatedFetch(nextUrl || `/api/customer/products/${productId}/licenses`);
554
- return paged(licenseSchema).parse(response.data);
555
- }
556
- async getActivations(productId, nextUrl) {
557
- const response = await this.api.authenticatedFetch(nextUrl || `/api/customer/products/${productId}/licenses/activations`);
558
- return paged(activationSchema).parse(response.data);
559
- }
560
- async activate(deviceToken, activationMethod) {
561
- const response = await this.api.authenticatedFetch(`/api/customer/products/activate?method=${activationMethod}`, "POST", deviceToken, "text/plain");
562
- return {
563
- license: licenseSchema.parse(response.data),
564
- url: import_zod10.z.string().parse(response.headers.get("location"))
565
- };
566
- }
567
- };
568
-
569
484
  // src/globalModels.ts
570
485
  function utmToObject(utm) {
571
486
  return Object.entries({
@@ -731,13 +646,13 @@ _TokenStore.storageKey = "moonbase_auth";
731
646
  var TokenStore = _TokenStore;
732
647
 
733
648
  // src/vouchers/schemas.ts
734
- var import_zod11 = require("zod");
735
- var voucherSchema = import_zod11.z.object({
736
- id: import_zod11.z.string(),
737
- name: import_zod11.z.string(),
738
- description: import_zod11.z.string(),
739
- code: import_zod11.z.string(),
740
- redeemed: import_zod11.z.boolean(),
649
+ var import_zod9 = require("zod");
650
+ var voucherSchema = import_zod9.z.object({
651
+ id: import_zod9.z.string(),
652
+ name: import_zod9.z.string(),
653
+ description: import_zod9.z.string(),
654
+ code: import_zod9.z.string(),
655
+ redeemed: import_zod9.z.boolean(),
741
656
  redeemsProducts: quantifiable(storefrontProductSchema).array(),
742
657
  redeemsBundles: quantifiable(storefrontBundleSchema).array()
743
658
  });
@@ -760,6 +675,119 @@ var VoucherEndpoints = class {
760
675
  }
761
676
  };
762
677
 
678
+ // src/inventory/activation/endpoints.ts
679
+ var import_zod11 = require("zod");
680
+
681
+ // src/inventory/licenses/schemas.ts
682
+ var import_zod10 = require("zod");
683
+
684
+ // src/inventory/licenses/models.ts
685
+ var LicenseStatus = /* @__PURE__ */ ((LicenseStatus2) => {
686
+ LicenseStatus2["Active"] = "Active";
687
+ LicenseStatus2["Revoked"] = "Revoked";
688
+ return LicenseStatus2;
689
+ })(LicenseStatus || {});
690
+ var ActivationStatus = /* @__PURE__ */ ((ActivationStatus2) => {
691
+ ActivationStatus2["Active"] = "Active";
692
+ ActivationStatus2["Revoked"] = "Revoked";
693
+ return ActivationStatus2;
694
+ })(ActivationStatus || {});
695
+ var ActivationMethod = /* @__PURE__ */ ((ActivationMethod2) => {
696
+ ActivationMethod2["Online"] = "Online";
697
+ ActivationMethod2["Offline"] = "Offline";
698
+ return ActivationMethod2;
699
+ })(ActivationMethod || {});
700
+
701
+ // src/inventory/licenses/schemas.ts
702
+ var licenseSchema = import_zod10.z.object({
703
+ id: import_zod10.z.string(),
704
+ status: import_zod10.z.nativeEnum(LicenseStatus),
705
+ product: productSummarySchema,
706
+ activeNumberOfActivations: import_zod10.z.number(),
707
+ maxNumberOfActivations: import_zod10.z.number(),
708
+ createdAt: import_zod10.z.coerce.date()
709
+ });
710
+ var activationSchema = import_zod10.z.object({
711
+ id: import_zod10.z.string(),
712
+ licenseId: import_zod10.z.string(),
713
+ name: import_zod10.z.string(),
714
+ status: import_zod10.z.nativeEnum(ActivationStatus),
715
+ activationMethod: import_zod10.z.nativeEnum(ActivationMethod),
716
+ lastValidatedAt: import_zod10.z.coerce.date().nullable()
717
+ });
718
+
719
+ // src/inventory/activation/endpoints.ts
720
+ var ActivationEndpoints = class {
721
+ constructor(api) {
722
+ this.api = api;
723
+ }
724
+ async activate(deviceToken, activationMethod) {
725
+ const response = await this.api.authenticatedFetch(`/api/customer/inventory/activate?method=${activationMethod}`, "POST", deviceToken, "text/plain");
726
+ return {
727
+ license: licenseSchema.parse(response.data),
728
+ url: import_zod11.z.string().parse(response.headers.get("location"))
729
+ };
730
+ }
731
+ };
732
+
733
+ // src/inventory/licenses/endpoints.ts
734
+ var LicenseEndpoints = class {
735
+ constructor(api) {
736
+ this.api = api;
737
+ }
738
+ async get(nextUrl) {
739
+ const response = await this.api.authenticatedFetch(nextUrl || "/api/customer/inventory/licenses");
740
+ return paged(licenseSchema).parse(response.data);
741
+ }
742
+ async getActivations(licenseId, nextUrl) {
743
+ const response = await this.api.authenticatedFetch(
744
+ nextUrl || `/api/customer/inventory/licenses/${licenseId}/activations`
745
+ );
746
+ return paged(activationSchema).parse(response.data);
747
+ }
748
+ async revokeActivation(licenseId, activationId) {
749
+ await this.api.authenticatedFetch(`/api/customer/inventory/licenses/${licenseId}/activations/${activationId}/revoke`, "POST");
750
+ }
751
+ };
752
+
753
+ // src/inventory/products/endpoints.ts
754
+ var import_zod12 = require("zod");
755
+ var ProductEndpoints = class {
756
+ constructor(api) {
757
+ this.api = api;
758
+ }
759
+ async getOwned(nextUrl) {
760
+ const response = await this.api.authenticatedFetch(nextUrl || "/api/customer/inventory/products");
761
+ return paged(productSummarySchema).parse(response.data);
762
+ }
763
+ async getLicenses(productId, nextUrl) {
764
+ const response = await this.api.authenticatedFetch(nextUrl || `/api/customer/inventory/products/${productId}/licenses`);
765
+ return paged(licenseSchema).parse(response.data);
766
+ }
767
+ async getActivations(productId, nextUrl) {
768
+ const response = await this.api.authenticatedFetch(nextUrl || `/api/customer/inventory/products/${productId}/licenses/activations`);
769
+ return paged(activationSchema).parse(response.data);
770
+ }
771
+ async getDownloadUrl(path) {
772
+ const url = new URL(path);
773
+ url.searchParams.append("redirect", "false");
774
+ const response = await this.api.authenticatedFetch(url.pathname + url.search);
775
+ const content = import_zod12.z.object({
776
+ location: import_zod12.z.string()
777
+ }).parse(response.data);
778
+ return content.location;
779
+ }
780
+ };
781
+
782
+ // src/inventory/index.ts
783
+ var InventoryEndpoints = class {
784
+ constructor(api) {
785
+ this.licenses = new LicenseEndpoints(api);
786
+ this.products = new ProductEndpoints(api);
787
+ this.activation = new ActivationEndpoints(api);
788
+ }
789
+ };
790
+
763
791
  // src/index.ts
764
792
  var MoonbaseClient = class {
765
793
  constructor(configuration) {
@@ -771,9 +799,8 @@ var MoonbaseClient = class {
771
799
  this.identity = new IdentityEndpoints(api, this.tokenStore);
772
800
  this.vouchers = new VoucherEndpoints(api);
773
801
  this.orders = new OrderEndpoints(api);
774
- this.licenses = new LicenseEndpoints(api);
802
+ this.inventory = new InventoryEndpoints(api);
775
803
  this.activationRequests = new ActivationRequestEndpoints(api);
776
- this.products = new ProductEndpoints(api);
777
804
  }
778
805
  };
779
806
  // Annotate the CommonJS export names for ESM import in node: