@moonbase.sh/api 0.4.12 → 0.4.14

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
@@ -744,6 +744,13 @@ var createVoucherRequestSchema = import_zod10.z.object({
744
744
  productEntitlements: import_zod10.z.record(import_zod10.z.string(), import_zod10.z.number()).optional(),
745
745
  bundleEntitlements: import_zod10.z.record(import_zod10.z.string(), import_zod10.z.number()).optional()
746
746
  });
747
+ var voucherCodeSchema = import_zod10.z.object({
748
+ voucherId: import_zod10.z.string(),
749
+ code: import_zod10.z.string(),
750
+ isRedeemed: import_zod10.z.boolean(),
751
+ redeemedAt: import_zod10.z.coerce.date().nullable(),
752
+ redeemedBy: import_zod10.z.string().nullable()
753
+ });
747
754
 
748
755
  // src/vouchers/endpoints.ts
749
756
  var VoucherEndpoints = class {
@@ -755,6 +762,18 @@ var VoucherEndpoints = class {
755
762
  const response = await this.api.fetch(`/api/vouchers/create`, "POST", request);
756
763
  return voucherSchema.parse(response.data);
757
764
  }
765
+ async query(opts) {
766
+ const response = await this.api.fetch(`/api/vouchers?${objectToQuery(opts)}`);
767
+ return paged(voucherSchema, this.api).parse(response.data);
768
+ }
769
+ async get(voucherId) {
770
+ const response = await this.api.fetch(`/api/vouchers/${voucherId}`);
771
+ return voucherSchema.parse(response.data);
772
+ }
773
+ async queryCodes(voucherId, opts) {
774
+ const response = await this.api.fetch(`/api/vouchers/${voucherId}/codes?${objectToQuery(opts)}`);
775
+ return paged(voucherCodeSchema, this.api).parse(response.data);
776
+ }
758
777
  async addCodes(voucherId, codes) {
759
778
  await this.api.fetch(`/api/vouchers/${voucherId}/codes`, "PUT", codes);
760
779
  }
package/dist/index.d.cts CHANGED
@@ -3858,14 +3858,45 @@ declare const createVoucherRequestSchema: z.ZodObject<{
3858
3858
  productEntitlements?: Record<string, number> | undefined;
3859
3859
  bundleEntitlements?: Record<string, number> | undefined;
3860
3860
  }>;
3861
+ declare const voucherCodeSchema: z.ZodObject<{
3862
+ voucherId: z.ZodString;
3863
+ code: z.ZodString;
3864
+ isRedeemed: z.ZodBoolean;
3865
+ redeemedAt: z.ZodNullable<z.ZodDate>;
3866
+ redeemedBy: z.ZodNullable<z.ZodString>;
3867
+ }, "strip", z.ZodTypeAny, {
3868
+ code: string;
3869
+ voucherId: string;
3870
+ isRedeemed: boolean;
3871
+ redeemedAt: Date | null;
3872
+ redeemedBy: string | null;
3873
+ }, {
3874
+ code: string;
3875
+ voucherId: string;
3876
+ isRedeemed: boolean;
3877
+ redeemedAt: Date | null;
3878
+ redeemedBy: string | null;
3879
+ }>;
3861
3880
 
3862
3881
  type Voucher = z.infer<typeof voucherSchema>;
3882
+ type VoucherCode = z.infer<typeof voucherCodeSchema>;
3863
3883
  type CreateVoucherRequest = z.infer<typeof createVoucherRequestSchema>;
3864
3884
 
3865
3885
  declare class VoucherEndpoints {
3866
3886
  private api;
3867
3887
  constructor(api: MoonbaseApi);
3868
3888
  create(voucher: CreateVoucherRequest): Promise<Voucher>;
3889
+ query(opts?: {
3890
+ paginationToken?: string;
3891
+ pageSize?: number;
3892
+ }): Promise<Page<Voucher>>;
3893
+ get(voucherId: string): Promise<Voucher>;
3894
+ queryCodes(voucherId: string, opts?: {
3895
+ paginationToken?: string;
3896
+ redeemedAfter?: Date;
3897
+ redeemedBefore?: Date;
3898
+ pageSize?: number;
3899
+ }): Promise<Page<VoucherCode>>;
3869
3900
  addCodes(voucherId: string, codes: string[]): Promise<void>;
3870
3901
  deleteCode(voucherId: string, code: string): Promise<void>;
3871
3902
  }
@@ -3957,4 +3988,4 @@ declare class MoonbaseClient {
3957
3988
  orders: OrderEndpoints;
3958
3989
  }
3959
3990
 
3960
- export { ActivationMethod, type ActivationRequest, ActivationRequestStatus, ActivationStatus, type Bundle, ConflictError, type CreateVoucherRequest, type Customer, type ImportCustomerRequest, type ImportLicenseRequest, type ImportTrialRequest, type License, type LicenseActivation, LicenseStatus, MoonbaseApi, MoonbaseClient, type MoonbaseConfiguration, MoonbaseError, NotAuthenticatedError, NotAuthorizedError, NotFoundError, type Order, OrderStatus, type Page, Platform, type PricingVariation, type Product, type ProductRelease, ProductStatus, type ProvisionLicensesRequest, type Quantifiable, type Trial, TrialStatus, type Voucher, objectToQuery };
3991
+ export { ActivationMethod, type ActivationRequest, ActivationRequestStatus, ActivationStatus, type Bundle, ConflictError, type CreateVoucherRequest, type Customer, type ImportCustomerRequest, type ImportLicenseRequest, type ImportTrialRequest, type License, type LicenseActivation, LicenseStatus, MoonbaseApi, MoonbaseClient, type MoonbaseConfiguration, MoonbaseError, NotAuthenticatedError, NotAuthorizedError, NotFoundError, type Order, OrderStatus, type Page, Platform, type PricingVariation, type Product, type ProductRelease, ProductStatus, type ProvisionLicensesRequest, type Quantifiable, type Trial, TrialStatus, type Voucher, type VoucherCode, objectToQuery };
package/dist/index.d.ts CHANGED
@@ -3858,14 +3858,45 @@ declare const createVoucherRequestSchema: z.ZodObject<{
3858
3858
  productEntitlements?: Record<string, number> | undefined;
3859
3859
  bundleEntitlements?: Record<string, number> | undefined;
3860
3860
  }>;
3861
+ declare const voucherCodeSchema: z.ZodObject<{
3862
+ voucherId: z.ZodString;
3863
+ code: z.ZodString;
3864
+ isRedeemed: z.ZodBoolean;
3865
+ redeemedAt: z.ZodNullable<z.ZodDate>;
3866
+ redeemedBy: z.ZodNullable<z.ZodString>;
3867
+ }, "strip", z.ZodTypeAny, {
3868
+ code: string;
3869
+ voucherId: string;
3870
+ isRedeemed: boolean;
3871
+ redeemedAt: Date | null;
3872
+ redeemedBy: string | null;
3873
+ }, {
3874
+ code: string;
3875
+ voucherId: string;
3876
+ isRedeemed: boolean;
3877
+ redeemedAt: Date | null;
3878
+ redeemedBy: string | null;
3879
+ }>;
3861
3880
 
3862
3881
  type Voucher = z.infer<typeof voucherSchema>;
3882
+ type VoucherCode = z.infer<typeof voucherCodeSchema>;
3863
3883
  type CreateVoucherRequest = z.infer<typeof createVoucherRequestSchema>;
3864
3884
 
3865
3885
  declare class VoucherEndpoints {
3866
3886
  private api;
3867
3887
  constructor(api: MoonbaseApi);
3868
3888
  create(voucher: CreateVoucherRequest): Promise<Voucher>;
3889
+ query(opts?: {
3890
+ paginationToken?: string;
3891
+ pageSize?: number;
3892
+ }): Promise<Page<Voucher>>;
3893
+ get(voucherId: string): Promise<Voucher>;
3894
+ queryCodes(voucherId: string, opts?: {
3895
+ paginationToken?: string;
3896
+ redeemedAfter?: Date;
3897
+ redeemedBefore?: Date;
3898
+ pageSize?: number;
3899
+ }): Promise<Page<VoucherCode>>;
3869
3900
  addCodes(voucherId: string, codes: string[]): Promise<void>;
3870
3901
  deleteCode(voucherId: string, code: string): Promise<void>;
3871
3902
  }
@@ -3957,4 +3988,4 @@ declare class MoonbaseClient {
3957
3988
  orders: OrderEndpoints;
3958
3989
  }
3959
3990
 
3960
- export { ActivationMethod, type ActivationRequest, ActivationRequestStatus, ActivationStatus, type Bundle, ConflictError, type CreateVoucherRequest, type Customer, type ImportCustomerRequest, type ImportLicenseRequest, type ImportTrialRequest, type License, type LicenseActivation, LicenseStatus, MoonbaseApi, MoonbaseClient, type MoonbaseConfiguration, MoonbaseError, NotAuthenticatedError, NotAuthorizedError, NotFoundError, type Order, OrderStatus, type Page, Platform, type PricingVariation, type Product, type ProductRelease, ProductStatus, type ProvisionLicensesRequest, type Quantifiable, type Trial, TrialStatus, type Voucher, objectToQuery };
3991
+ export { ActivationMethod, type ActivationRequest, ActivationRequestStatus, ActivationStatus, type Bundle, ConflictError, type CreateVoucherRequest, type Customer, type ImportCustomerRequest, type ImportLicenseRequest, type ImportTrialRequest, type License, type LicenseActivation, LicenseStatus, MoonbaseApi, MoonbaseClient, type MoonbaseConfiguration, MoonbaseError, NotAuthenticatedError, NotAuthorizedError, NotFoundError, type Order, OrderStatus, type Page, Platform, type PricingVariation, type Product, type ProductRelease, ProductStatus, type ProvisionLicensesRequest, type Quantifiable, type Trial, TrialStatus, type Voucher, type VoucherCode, objectToQuery };
package/dist/index.js CHANGED
@@ -693,6 +693,13 @@ var createVoucherRequestSchema = z10.object({
693
693
  productEntitlements: z10.record(z10.string(), z10.number()).optional(),
694
694
  bundleEntitlements: z10.record(z10.string(), z10.number()).optional()
695
695
  });
696
+ var voucherCodeSchema = z10.object({
697
+ voucherId: z10.string(),
698
+ code: z10.string(),
699
+ isRedeemed: z10.boolean(),
700
+ redeemedAt: z10.coerce.date().nullable(),
701
+ redeemedBy: z10.string().nullable()
702
+ });
696
703
 
697
704
  // src/vouchers/endpoints.ts
698
705
  var VoucherEndpoints = class {
@@ -704,6 +711,18 @@ var VoucherEndpoints = class {
704
711
  const response = await this.api.fetch(`/api/vouchers/create`, "POST", request);
705
712
  return voucherSchema.parse(response.data);
706
713
  }
714
+ async query(opts) {
715
+ const response = await this.api.fetch(`/api/vouchers?${objectToQuery(opts)}`);
716
+ return paged(voucherSchema, this.api).parse(response.data);
717
+ }
718
+ async get(voucherId) {
719
+ const response = await this.api.fetch(`/api/vouchers/${voucherId}`);
720
+ return voucherSchema.parse(response.data);
721
+ }
722
+ async queryCodes(voucherId, opts) {
723
+ const response = await this.api.fetch(`/api/vouchers/${voucherId}/codes?${objectToQuery(opts)}`);
724
+ return paged(voucherCodeSchema, this.api).parse(response.data);
725
+ }
707
726
  async addCodes(voucherId, codes) {
708
727
  await this.api.fetch(`/api/vouchers/${voucherId}/codes`, "PUT", codes);
709
728
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@moonbase.sh/api",
3
3
  "type": "module",
4
- "version": "0.4.12",
4
+ "version": "0.4.14",
5
5
  "description": "Package to let you integrate backends with Moonbase.sh as payment and delivery provider",
6
6
  "author": "Tobias Lønnerød Madsen <m@dsen.tv>",
7
7
  "license": "MIT",