@moonbase.sh/api 0.1.118 → 0.1.120

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
@@ -125,7 +125,8 @@ var licenseActivationSchema = import_zod2.z.object({
125
125
  status: import_zod2.z.nativeEnum(ActivationStatus),
126
126
  activationMethod: import_zod2.z.nativeEnum(ActivationMethod),
127
127
  lastValidatedAt: import_zod2.z.coerce.date(),
128
- license: licenseSchema
128
+ license: licenseSchema,
129
+ customer: customerSchema.optional()
129
130
  });
130
131
  var importLicenseRequestSchema = import_zod2.z.object({
131
132
  ownerId: import_zod2.z.string(),
@@ -284,6 +285,12 @@ function paged(itemSchema) {
284
285
  next: import_zod6.z.string().nullable()
285
286
  });
286
287
  }
288
+ function quantifiable(itemSchema) {
289
+ return import_zod6.z.object({
290
+ value: itemSchema,
291
+ quantity: import_zod6.z.number()
292
+ });
293
+ }
287
294
 
288
295
  // src/utils/api.ts
289
296
  var import_cross_fetch = __toESM(require("cross-fetch"), 1);
@@ -457,6 +464,55 @@ var TrialEndpoints = class {
457
464
  }
458
465
  };
459
466
 
467
+ // src/vouchers/schemas.ts
468
+ var import_zod9 = require("zod");
469
+
470
+ // src/bundles/schemas.ts
471
+ var import_zod8 = require("zod");
472
+ var bundleSchema = import_zod8.z.object({
473
+ id: import_zod8.z.string(),
474
+ name: import_zod8.z.string(),
475
+ tagline: import_zod8.z.string(),
476
+ description: import_zod8.z.string(),
477
+ iconUrl: import_zod8.z.string().nullable(),
478
+ purchasable: import_zod8.z.boolean(),
479
+ partialPurchaseEnabled: import_zod8.z.boolean()
480
+ });
481
+
482
+ // src/vouchers/schemas.ts
483
+ var voucherSchema = import_zod9.z.object({
484
+ id: import_zod9.z.string(),
485
+ description: import_zod9.z.string(),
486
+ numberOfCodes: import_zod9.z.number(),
487
+ numberOfRedemptions: import_zod9.z.number(),
488
+ redeemsProducts: quantifiable(productSchema).array(),
489
+ redeemsBundles: quantifiable(bundleSchema).array()
490
+ });
491
+ var createVoucherRequestSchema = import_zod9.z.object({
492
+ name: import_zod9.z.string(),
493
+ description: import_zod9.z.string(),
494
+ productEntitlements: import_zod9.z.record(import_zod9.z.string(), import_zod9.z.number()).optional(),
495
+ bundleEntitlements: import_zod9.z.record(import_zod9.z.string(), import_zod9.z.number()).optional()
496
+ });
497
+
498
+ // src/vouchers/endpoints.ts
499
+ var VoucherEndpoints = class {
500
+ constructor(api) {
501
+ this.api = api;
502
+ }
503
+ async create(voucher) {
504
+ const request = createVoucherRequestSchema.parse(voucher);
505
+ const response = await this.api.fetch(`/api/vouchers/create`, "POST", request);
506
+ return voucherSchema.parse(response.data);
507
+ }
508
+ async addCodes(voucherId, codes) {
509
+ await this.api.fetch(`/api/vouchers/${voucherId}/codes`, "PUT", codes);
510
+ }
511
+ async deleteCode(voucherId, code) {
512
+ await this.api.fetch(`/api/vouchers/${voucherId}/codes/${code}`, "DELETE");
513
+ }
514
+ };
515
+
460
516
  // src/index.ts
461
517
  var MoonbaseClient = class {
462
518
  constructor(configuration) {
@@ -468,6 +524,7 @@ var MoonbaseClient = class {
468
524
  this.licenses = new LicenseEndpoints(api);
469
525
  this.products = new ProductEndpoints(api);
470
526
  this.trials = new TrialEndpoints(api);
527
+ this.vouchers = new VoucherEndpoints(api);
471
528
  }
472
529
  };
473
530
  // Annotate the CommonJS export names for ESM import in node: