@moonbase.sh/api 0.1.118 → 0.1.119
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 +56 -0
- package/dist/index.d.cts +236 -1
- package/dist/index.d.ts +236 -1
- package/dist/index.js +56 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -284,6 +284,12 @@ function paged(itemSchema) {
|
|
|
284
284
|
next: import_zod6.z.string().nullable()
|
|
285
285
|
});
|
|
286
286
|
}
|
|
287
|
+
function quantifiable(itemSchema) {
|
|
288
|
+
return import_zod6.z.object({
|
|
289
|
+
value: itemSchema,
|
|
290
|
+
quantity: import_zod6.z.number()
|
|
291
|
+
});
|
|
292
|
+
}
|
|
287
293
|
|
|
288
294
|
// src/utils/api.ts
|
|
289
295
|
var import_cross_fetch = __toESM(require("cross-fetch"), 1);
|
|
@@ -457,6 +463,55 @@ var TrialEndpoints = class {
|
|
|
457
463
|
}
|
|
458
464
|
};
|
|
459
465
|
|
|
466
|
+
// src/vouchers/schemas.ts
|
|
467
|
+
var import_zod9 = require("zod");
|
|
468
|
+
|
|
469
|
+
// src/bundles/schemas.ts
|
|
470
|
+
var import_zod8 = require("zod");
|
|
471
|
+
var bundleSchema = import_zod8.z.object({
|
|
472
|
+
id: import_zod8.z.string(),
|
|
473
|
+
name: import_zod8.z.string(),
|
|
474
|
+
tagline: import_zod8.z.string(),
|
|
475
|
+
description: import_zod8.z.string(),
|
|
476
|
+
iconUrl: import_zod8.z.string().nullable(),
|
|
477
|
+
purchasable: import_zod8.z.boolean(),
|
|
478
|
+
partialPurchaseEnabled: import_zod8.z.boolean()
|
|
479
|
+
});
|
|
480
|
+
|
|
481
|
+
// src/vouchers/schemas.ts
|
|
482
|
+
var voucherSchema = import_zod9.z.object({
|
|
483
|
+
id: import_zod9.z.string(),
|
|
484
|
+
description: import_zod9.z.string(),
|
|
485
|
+
numberOfCodes: import_zod9.z.number(),
|
|
486
|
+
numberOfRedemptions: import_zod9.z.number(),
|
|
487
|
+
redeemsProducts: quantifiable(productSchema).array(),
|
|
488
|
+
redeemsBundles: quantifiable(bundleSchema).array()
|
|
489
|
+
});
|
|
490
|
+
var createVoucherRequestSchema = import_zod9.z.object({
|
|
491
|
+
name: import_zod9.z.string(),
|
|
492
|
+
description: import_zod9.z.string(),
|
|
493
|
+
productEntitlements: import_zod9.z.record(import_zod9.z.string(), import_zod9.z.number()).optional(),
|
|
494
|
+
bundleEntitlements: import_zod9.z.record(import_zod9.z.string(), import_zod9.z.number()).optional()
|
|
495
|
+
});
|
|
496
|
+
|
|
497
|
+
// src/vouchers/endpoints.ts
|
|
498
|
+
var VoucherEndpoints = class {
|
|
499
|
+
constructor(api) {
|
|
500
|
+
this.api = api;
|
|
501
|
+
}
|
|
502
|
+
async create(voucher) {
|
|
503
|
+
const request = createVoucherRequestSchema.parse(voucher);
|
|
504
|
+
const response = await this.api.fetch(`/api/vouchers/create`, "POST", request);
|
|
505
|
+
return voucherSchema.parse(response.data);
|
|
506
|
+
}
|
|
507
|
+
async addCodes(voucherId, codes) {
|
|
508
|
+
await this.api.fetch(`/api/vouchers/${voucherId}/codes`, "PUT", codes);
|
|
509
|
+
}
|
|
510
|
+
async deleteCode(voucherId, code) {
|
|
511
|
+
await this.api.fetch(`/api/vouchers/${voucherId}/codes/${code}`, "DELETE");
|
|
512
|
+
}
|
|
513
|
+
};
|
|
514
|
+
|
|
460
515
|
// src/index.ts
|
|
461
516
|
var MoonbaseClient = class {
|
|
462
517
|
constructor(configuration) {
|
|
@@ -468,6 +523,7 @@ var MoonbaseClient = class {
|
|
|
468
523
|
this.licenses = new LicenseEndpoints(api);
|
|
469
524
|
this.products = new ProductEndpoints(api);
|
|
470
525
|
this.trials = new TrialEndpoints(api);
|
|
526
|
+
this.vouchers = new VoucherEndpoints(api);
|
|
471
527
|
}
|
|
472
528
|
};
|
|
473
529
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/index.d.cts
CHANGED
|
@@ -959,6 +959,240 @@ declare class TrialEndpoints {
|
|
|
959
959
|
import(trial: ImportTrialRequest): Promise<Trial>;
|
|
960
960
|
}
|
|
961
961
|
|
|
962
|
+
declare const voucherSchema: z.ZodObject<{
|
|
963
|
+
id: z.ZodString;
|
|
964
|
+
description: z.ZodString;
|
|
965
|
+
numberOfCodes: z.ZodNumber;
|
|
966
|
+
numberOfRedemptions: z.ZodNumber;
|
|
967
|
+
redeemsProducts: z.ZodArray<z.ZodObject<{
|
|
968
|
+
value: z.ZodObject<{
|
|
969
|
+
id: z.ZodString;
|
|
970
|
+
name: z.ZodString;
|
|
971
|
+
tagline: z.ZodString;
|
|
972
|
+
description: z.ZodString;
|
|
973
|
+
website: z.ZodNullable<z.ZodString>;
|
|
974
|
+
iconUrl: z.ZodNullable<z.ZodString>;
|
|
975
|
+
status: z.ZodNativeEnum<typeof ProductStatus>;
|
|
976
|
+
purchasable: z.ZodBoolean;
|
|
977
|
+
currentReleaseVersion: z.ZodNullable<z.ZodString>;
|
|
978
|
+
}, "strip", z.ZodTypeAny, {
|
|
979
|
+
status: ProductStatus;
|
|
980
|
+
id: string;
|
|
981
|
+
name: string;
|
|
982
|
+
tagline: string;
|
|
983
|
+
description: string;
|
|
984
|
+
website: string | null;
|
|
985
|
+
iconUrl: string | null;
|
|
986
|
+
purchasable: boolean;
|
|
987
|
+
currentReleaseVersion: string | null;
|
|
988
|
+
}, {
|
|
989
|
+
status: ProductStatus;
|
|
990
|
+
id: string;
|
|
991
|
+
name: string;
|
|
992
|
+
tagline: string;
|
|
993
|
+
description: string;
|
|
994
|
+
website: string | null;
|
|
995
|
+
iconUrl: string | null;
|
|
996
|
+
purchasable: boolean;
|
|
997
|
+
currentReleaseVersion: string | null;
|
|
998
|
+
}>;
|
|
999
|
+
quantity: z.ZodNumber;
|
|
1000
|
+
}, "strip", z.ZodTypeAny, {
|
|
1001
|
+
value: {
|
|
1002
|
+
status: ProductStatus;
|
|
1003
|
+
id: string;
|
|
1004
|
+
name: string;
|
|
1005
|
+
tagline: string;
|
|
1006
|
+
description: string;
|
|
1007
|
+
website: string | null;
|
|
1008
|
+
iconUrl: string | null;
|
|
1009
|
+
purchasable: boolean;
|
|
1010
|
+
currentReleaseVersion: string | null;
|
|
1011
|
+
};
|
|
1012
|
+
quantity: number;
|
|
1013
|
+
}, {
|
|
1014
|
+
value: {
|
|
1015
|
+
status: ProductStatus;
|
|
1016
|
+
id: string;
|
|
1017
|
+
name: string;
|
|
1018
|
+
tagline: string;
|
|
1019
|
+
description: string;
|
|
1020
|
+
website: string | null;
|
|
1021
|
+
iconUrl: string | null;
|
|
1022
|
+
purchasable: boolean;
|
|
1023
|
+
currentReleaseVersion: string | null;
|
|
1024
|
+
};
|
|
1025
|
+
quantity: number;
|
|
1026
|
+
}>, "many">;
|
|
1027
|
+
redeemsBundles: z.ZodArray<z.ZodObject<{
|
|
1028
|
+
value: z.ZodObject<{
|
|
1029
|
+
id: z.ZodString;
|
|
1030
|
+
name: z.ZodString;
|
|
1031
|
+
tagline: z.ZodString;
|
|
1032
|
+
description: z.ZodString;
|
|
1033
|
+
iconUrl: z.ZodNullable<z.ZodString>;
|
|
1034
|
+
purchasable: z.ZodBoolean;
|
|
1035
|
+
partialPurchaseEnabled: z.ZodBoolean;
|
|
1036
|
+
}, "strip", z.ZodTypeAny, {
|
|
1037
|
+
id: string;
|
|
1038
|
+
name: string;
|
|
1039
|
+
tagline: string;
|
|
1040
|
+
description: string;
|
|
1041
|
+
iconUrl: string | null;
|
|
1042
|
+
purchasable: boolean;
|
|
1043
|
+
partialPurchaseEnabled: boolean;
|
|
1044
|
+
}, {
|
|
1045
|
+
id: string;
|
|
1046
|
+
name: string;
|
|
1047
|
+
tagline: string;
|
|
1048
|
+
description: string;
|
|
1049
|
+
iconUrl: string | null;
|
|
1050
|
+
purchasable: boolean;
|
|
1051
|
+
partialPurchaseEnabled: boolean;
|
|
1052
|
+
}>;
|
|
1053
|
+
quantity: z.ZodNumber;
|
|
1054
|
+
}, "strip", z.ZodTypeAny, {
|
|
1055
|
+
value: {
|
|
1056
|
+
id: string;
|
|
1057
|
+
name: string;
|
|
1058
|
+
tagline: string;
|
|
1059
|
+
description: string;
|
|
1060
|
+
iconUrl: string | null;
|
|
1061
|
+
purchasable: boolean;
|
|
1062
|
+
partialPurchaseEnabled: boolean;
|
|
1063
|
+
};
|
|
1064
|
+
quantity: number;
|
|
1065
|
+
}, {
|
|
1066
|
+
value: {
|
|
1067
|
+
id: string;
|
|
1068
|
+
name: string;
|
|
1069
|
+
tagline: string;
|
|
1070
|
+
description: string;
|
|
1071
|
+
iconUrl: string | null;
|
|
1072
|
+
purchasable: boolean;
|
|
1073
|
+
partialPurchaseEnabled: boolean;
|
|
1074
|
+
};
|
|
1075
|
+
quantity: number;
|
|
1076
|
+
}>, "many">;
|
|
1077
|
+
}, "strip", z.ZodTypeAny, {
|
|
1078
|
+
id: string;
|
|
1079
|
+
description: string;
|
|
1080
|
+
numberOfCodes: number;
|
|
1081
|
+
numberOfRedemptions: number;
|
|
1082
|
+
redeemsProducts: {
|
|
1083
|
+
value: {
|
|
1084
|
+
status: ProductStatus;
|
|
1085
|
+
id: string;
|
|
1086
|
+
name: string;
|
|
1087
|
+
tagline: string;
|
|
1088
|
+
description: string;
|
|
1089
|
+
website: string | null;
|
|
1090
|
+
iconUrl: string | null;
|
|
1091
|
+
purchasable: boolean;
|
|
1092
|
+
currentReleaseVersion: string | null;
|
|
1093
|
+
};
|
|
1094
|
+
quantity: number;
|
|
1095
|
+
}[];
|
|
1096
|
+
redeemsBundles: {
|
|
1097
|
+
value: {
|
|
1098
|
+
id: string;
|
|
1099
|
+
name: string;
|
|
1100
|
+
tagline: string;
|
|
1101
|
+
description: string;
|
|
1102
|
+
iconUrl: string | null;
|
|
1103
|
+
purchasable: boolean;
|
|
1104
|
+
partialPurchaseEnabled: boolean;
|
|
1105
|
+
};
|
|
1106
|
+
quantity: number;
|
|
1107
|
+
}[];
|
|
1108
|
+
}, {
|
|
1109
|
+
id: string;
|
|
1110
|
+
description: string;
|
|
1111
|
+
numberOfCodes: number;
|
|
1112
|
+
numberOfRedemptions: number;
|
|
1113
|
+
redeemsProducts: {
|
|
1114
|
+
value: {
|
|
1115
|
+
status: ProductStatus;
|
|
1116
|
+
id: string;
|
|
1117
|
+
name: string;
|
|
1118
|
+
tagline: string;
|
|
1119
|
+
description: string;
|
|
1120
|
+
website: string | null;
|
|
1121
|
+
iconUrl: string | null;
|
|
1122
|
+
purchasable: boolean;
|
|
1123
|
+
currentReleaseVersion: string | null;
|
|
1124
|
+
};
|
|
1125
|
+
quantity: number;
|
|
1126
|
+
}[];
|
|
1127
|
+
redeemsBundles: {
|
|
1128
|
+
value: {
|
|
1129
|
+
id: string;
|
|
1130
|
+
name: string;
|
|
1131
|
+
tagline: string;
|
|
1132
|
+
description: string;
|
|
1133
|
+
iconUrl: string | null;
|
|
1134
|
+
purchasable: boolean;
|
|
1135
|
+
partialPurchaseEnabled: boolean;
|
|
1136
|
+
};
|
|
1137
|
+
quantity: number;
|
|
1138
|
+
}[];
|
|
1139
|
+
}>;
|
|
1140
|
+
declare const createVoucherRequestSchema: z.ZodObject<{
|
|
1141
|
+
name: z.ZodString;
|
|
1142
|
+
description: z.ZodString;
|
|
1143
|
+
productEntitlements: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
|
|
1144
|
+
bundleEntitlements: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
|
|
1145
|
+
}, "strip", z.ZodTypeAny, {
|
|
1146
|
+
name: string;
|
|
1147
|
+
description: string;
|
|
1148
|
+
productEntitlements?: Record<string, number> | undefined;
|
|
1149
|
+
bundleEntitlements?: Record<string, number> | undefined;
|
|
1150
|
+
}, {
|
|
1151
|
+
name: string;
|
|
1152
|
+
description: string;
|
|
1153
|
+
productEntitlements?: Record<string, number> | undefined;
|
|
1154
|
+
bundleEntitlements?: Record<string, number> | undefined;
|
|
1155
|
+
}>;
|
|
1156
|
+
|
|
1157
|
+
type Voucher = z.infer<typeof voucherSchema>;
|
|
1158
|
+
type CreateVoucherRequest = z.infer<typeof createVoucherRequestSchema>;
|
|
1159
|
+
|
|
1160
|
+
declare class VoucherEndpoints {
|
|
1161
|
+
private api;
|
|
1162
|
+
constructor(api: MoonbaseApi);
|
|
1163
|
+
create(voucher: CreateVoucherRequest): Promise<Voucher>;
|
|
1164
|
+
addCodes(voucherId: string, codes: string[]): Promise<void>;
|
|
1165
|
+
deleteCode(voucherId: string, code: string): Promise<void>;
|
|
1166
|
+
}
|
|
1167
|
+
|
|
1168
|
+
declare const bundleSchema: z.ZodObject<{
|
|
1169
|
+
id: z.ZodString;
|
|
1170
|
+
name: z.ZodString;
|
|
1171
|
+
tagline: z.ZodString;
|
|
1172
|
+
description: z.ZodString;
|
|
1173
|
+
iconUrl: z.ZodNullable<z.ZodString>;
|
|
1174
|
+
purchasable: z.ZodBoolean;
|
|
1175
|
+
partialPurchaseEnabled: z.ZodBoolean;
|
|
1176
|
+
}, "strip", z.ZodTypeAny, {
|
|
1177
|
+
id: string;
|
|
1178
|
+
name: string;
|
|
1179
|
+
tagline: string;
|
|
1180
|
+
description: string;
|
|
1181
|
+
iconUrl: string | null;
|
|
1182
|
+
purchasable: boolean;
|
|
1183
|
+
partialPurchaseEnabled: boolean;
|
|
1184
|
+
}, {
|
|
1185
|
+
id: string;
|
|
1186
|
+
name: string;
|
|
1187
|
+
tagline: string;
|
|
1188
|
+
description: string;
|
|
1189
|
+
iconUrl: string | null;
|
|
1190
|
+
purchasable: boolean;
|
|
1191
|
+
partialPurchaseEnabled: boolean;
|
|
1192
|
+
}>;
|
|
1193
|
+
|
|
1194
|
+
type Bundle = z.infer<typeof bundleSchema>;
|
|
1195
|
+
|
|
962
1196
|
declare const problemDetailsSchema: z.ZodObject<{
|
|
963
1197
|
type: z.ZodString;
|
|
964
1198
|
title: z.ZodString;
|
|
@@ -1013,6 +1247,7 @@ declare class MoonbaseClient {
|
|
|
1013
1247
|
licenses: LicenseEndpoints;
|
|
1014
1248
|
products: ProductEndpoints;
|
|
1015
1249
|
trials: TrialEndpoints;
|
|
1250
|
+
vouchers: VoucherEndpoints;
|
|
1016
1251
|
}
|
|
1017
1252
|
|
|
1018
|
-
export { ActivationMethod, type ActivationRequest, ActivationRequestStatus, ActivationStatus, ConflictError, type Customer, type ImportCustomerRequest, type ImportLicenseRequest, type ImportTrialRequest, type License, type LicenseActivation, LicenseStatus, MoonbaseClient, type MoonbaseConfiguration, MoonbaseError, NotAuthenticatedError, NotAuthorizedError, NotFoundError, type Page, type PricingVariation, type Product, ProductStatus, type Quantifiable, type Trial, TrialStatus };
|
|
1253
|
+
export { ActivationMethod, type ActivationRequest, ActivationRequestStatus, ActivationStatus, type Bundle, ConflictError, type CreateVoucherRequest, type Customer, type ImportCustomerRequest, type ImportLicenseRequest, type ImportTrialRequest, type License, type LicenseActivation, LicenseStatus, MoonbaseClient, type MoonbaseConfiguration, MoonbaseError, NotAuthenticatedError, NotAuthorizedError, NotFoundError, type Page, type PricingVariation, type Product, ProductStatus, type Quantifiable, type Trial, TrialStatus, type Voucher };
|
package/dist/index.d.ts
CHANGED
|
@@ -959,6 +959,240 @@ declare class TrialEndpoints {
|
|
|
959
959
|
import(trial: ImportTrialRequest): Promise<Trial>;
|
|
960
960
|
}
|
|
961
961
|
|
|
962
|
+
declare const voucherSchema: z.ZodObject<{
|
|
963
|
+
id: z.ZodString;
|
|
964
|
+
description: z.ZodString;
|
|
965
|
+
numberOfCodes: z.ZodNumber;
|
|
966
|
+
numberOfRedemptions: z.ZodNumber;
|
|
967
|
+
redeemsProducts: z.ZodArray<z.ZodObject<{
|
|
968
|
+
value: z.ZodObject<{
|
|
969
|
+
id: z.ZodString;
|
|
970
|
+
name: z.ZodString;
|
|
971
|
+
tagline: z.ZodString;
|
|
972
|
+
description: z.ZodString;
|
|
973
|
+
website: z.ZodNullable<z.ZodString>;
|
|
974
|
+
iconUrl: z.ZodNullable<z.ZodString>;
|
|
975
|
+
status: z.ZodNativeEnum<typeof ProductStatus>;
|
|
976
|
+
purchasable: z.ZodBoolean;
|
|
977
|
+
currentReleaseVersion: z.ZodNullable<z.ZodString>;
|
|
978
|
+
}, "strip", z.ZodTypeAny, {
|
|
979
|
+
status: ProductStatus;
|
|
980
|
+
id: string;
|
|
981
|
+
name: string;
|
|
982
|
+
tagline: string;
|
|
983
|
+
description: string;
|
|
984
|
+
website: string | null;
|
|
985
|
+
iconUrl: string | null;
|
|
986
|
+
purchasable: boolean;
|
|
987
|
+
currentReleaseVersion: string | null;
|
|
988
|
+
}, {
|
|
989
|
+
status: ProductStatus;
|
|
990
|
+
id: string;
|
|
991
|
+
name: string;
|
|
992
|
+
tagline: string;
|
|
993
|
+
description: string;
|
|
994
|
+
website: string | null;
|
|
995
|
+
iconUrl: string | null;
|
|
996
|
+
purchasable: boolean;
|
|
997
|
+
currentReleaseVersion: string | null;
|
|
998
|
+
}>;
|
|
999
|
+
quantity: z.ZodNumber;
|
|
1000
|
+
}, "strip", z.ZodTypeAny, {
|
|
1001
|
+
value: {
|
|
1002
|
+
status: ProductStatus;
|
|
1003
|
+
id: string;
|
|
1004
|
+
name: string;
|
|
1005
|
+
tagline: string;
|
|
1006
|
+
description: string;
|
|
1007
|
+
website: string | null;
|
|
1008
|
+
iconUrl: string | null;
|
|
1009
|
+
purchasable: boolean;
|
|
1010
|
+
currentReleaseVersion: string | null;
|
|
1011
|
+
};
|
|
1012
|
+
quantity: number;
|
|
1013
|
+
}, {
|
|
1014
|
+
value: {
|
|
1015
|
+
status: ProductStatus;
|
|
1016
|
+
id: string;
|
|
1017
|
+
name: string;
|
|
1018
|
+
tagline: string;
|
|
1019
|
+
description: string;
|
|
1020
|
+
website: string | null;
|
|
1021
|
+
iconUrl: string | null;
|
|
1022
|
+
purchasable: boolean;
|
|
1023
|
+
currentReleaseVersion: string | null;
|
|
1024
|
+
};
|
|
1025
|
+
quantity: number;
|
|
1026
|
+
}>, "many">;
|
|
1027
|
+
redeemsBundles: z.ZodArray<z.ZodObject<{
|
|
1028
|
+
value: z.ZodObject<{
|
|
1029
|
+
id: z.ZodString;
|
|
1030
|
+
name: z.ZodString;
|
|
1031
|
+
tagline: z.ZodString;
|
|
1032
|
+
description: z.ZodString;
|
|
1033
|
+
iconUrl: z.ZodNullable<z.ZodString>;
|
|
1034
|
+
purchasable: z.ZodBoolean;
|
|
1035
|
+
partialPurchaseEnabled: z.ZodBoolean;
|
|
1036
|
+
}, "strip", z.ZodTypeAny, {
|
|
1037
|
+
id: string;
|
|
1038
|
+
name: string;
|
|
1039
|
+
tagline: string;
|
|
1040
|
+
description: string;
|
|
1041
|
+
iconUrl: string | null;
|
|
1042
|
+
purchasable: boolean;
|
|
1043
|
+
partialPurchaseEnabled: boolean;
|
|
1044
|
+
}, {
|
|
1045
|
+
id: string;
|
|
1046
|
+
name: string;
|
|
1047
|
+
tagline: string;
|
|
1048
|
+
description: string;
|
|
1049
|
+
iconUrl: string | null;
|
|
1050
|
+
purchasable: boolean;
|
|
1051
|
+
partialPurchaseEnabled: boolean;
|
|
1052
|
+
}>;
|
|
1053
|
+
quantity: z.ZodNumber;
|
|
1054
|
+
}, "strip", z.ZodTypeAny, {
|
|
1055
|
+
value: {
|
|
1056
|
+
id: string;
|
|
1057
|
+
name: string;
|
|
1058
|
+
tagline: string;
|
|
1059
|
+
description: string;
|
|
1060
|
+
iconUrl: string | null;
|
|
1061
|
+
purchasable: boolean;
|
|
1062
|
+
partialPurchaseEnabled: boolean;
|
|
1063
|
+
};
|
|
1064
|
+
quantity: number;
|
|
1065
|
+
}, {
|
|
1066
|
+
value: {
|
|
1067
|
+
id: string;
|
|
1068
|
+
name: string;
|
|
1069
|
+
tagline: string;
|
|
1070
|
+
description: string;
|
|
1071
|
+
iconUrl: string | null;
|
|
1072
|
+
purchasable: boolean;
|
|
1073
|
+
partialPurchaseEnabled: boolean;
|
|
1074
|
+
};
|
|
1075
|
+
quantity: number;
|
|
1076
|
+
}>, "many">;
|
|
1077
|
+
}, "strip", z.ZodTypeAny, {
|
|
1078
|
+
id: string;
|
|
1079
|
+
description: string;
|
|
1080
|
+
numberOfCodes: number;
|
|
1081
|
+
numberOfRedemptions: number;
|
|
1082
|
+
redeemsProducts: {
|
|
1083
|
+
value: {
|
|
1084
|
+
status: ProductStatus;
|
|
1085
|
+
id: string;
|
|
1086
|
+
name: string;
|
|
1087
|
+
tagline: string;
|
|
1088
|
+
description: string;
|
|
1089
|
+
website: string | null;
|
|
1090
|
+
iconUrl: string | null;
|
|
1091
|
+
purchasable: boolean;
|
|
1092
|
+
currentReleaseVersion: string | null;
|
|
1093
|
+
};
|
|
1094
|
+
quantity: number;
|
|
1095
|
+
}[];
|
|
1096
|
+
redeemsBundles: {
|
|
1097
|
+
value: {
|
|
1098
|
+
id: string;
|
|
1099
|
+
name: string;
|
|
1100
|
+
tagline: string;
|
|
1101
|
+
description: string;
|
|
1102
|
+
iconUrl: string | null;
|
|
1103
|
+
purchasable: boolean;
|
|
1104
|
+
partialPurchaseEnabled: boolean;
|
|
1105
|
+
};
|
|
1106
|
+
quantity: number;
|
|
1107
|
+
}[];
|
|
1108
|
+
}, {
|
|
1109
|
+
id: string;
|
|
1110
|
+
description: string;
|
|
1111
|
+
numberOfCodes: number;
|
|
1112
|
+
numberOfRedemptions: number;
|
|
1113
|
+
redeemsProducts: {
|
|
1114
|
+
value: {
|
|
1115
|
+
status: ProductStatus;
|
|
1116
|
+
id: string;
|
|
1117
|
+
name: string;
|
|
1118
|
+
tagline: string;
|
|
1119
|
+
description: string;
|
|
1120
|
+
website: string | null;
|
|
1121
|
+
iconUrl: string | null;
|
|
1122
|
+
purchasable: boolean;
|
|
1123
|
+
currentReleaseVersion: string | null;
|
|
1124
|
+
};
|
|
1125
|
+
quantity: number;
|
|
1126
|
+
}[];
|
|
1127
|
+
redeemsBundles: {
|
|
1128
|
+
value: {
|
|
1129
|
+
id: string;
|
|
1130
|
+
name: string;
|
|
1131
|
+
tagline: string;
|
|
1132
|
+
description: string;
|
|
1133
|
+
iconUrl: string | null;
|
|
1134
|
+
purchasable: boolean;
|
|
1135
|
+
partialPurchaseEnabled: boolean;
|
|
1136
|
+
};
|
|
1137
|
+
quantity: number;
|
|
1138
|
+
}[];
|
|
1139
|
+
}>;
|
|
1140
|
+
declare const createVoucherRequestSchema: z.ZodObject<{
|
|
1141
|
+
name: z.ZodString;
|
|
1142
|
+
description: z.ZodString;
|
|
1143
|
+
productEntitlements: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
|
|
1144
|
+
bundleEntitlements: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
|
|
1145
|
+
}, "strip", z.ZodTypeAny, {
|
|
1146
|
+
name: string;
|
|
1147
|
+
description: string;
|
|
1148
|
+
productEntitlements?: Record<string, number> | undefined;
|
|
1149
|
+
bundleEntitlements?: Record<string, number> | undefined;
|
|
1150
|
+
}, {
|
|
1151
|
+
name: string;
|
|
1152
|
+
description: string;
|
|
1153
|
+
productEntitlements?: Record<string, number> | undefined;
|
|
1154
|
+
bundleEntitlements?: Record<string, number> | undefined;
|
|
1155
|
+
}>;
|
|
1156
|
+
|
|
1157
|
+
type Voucher = z.infer<typeof voucherSchema>;
|
|
1158
|
+
type CreateVoucherRequest = z.infer<typeof createVoucherRequestSchema>;
|
|
1159
|
+
|
|
1160
|
+
declare class VoucherEndpoints {
|
|
1161
|
+
private api;
|
|
1162
|
+
constructor(api: MoonbaseApi);
|
|
1163
|
+
create(voucher: CreateVoucherRequest): Promise<Voucher>;
|
|
1164
|
+
addCodes(voucherId: string, codes: string[]): Promise<void>;
|
|
1165
|
+
deleteCode(voucherId: string, code: string): Promise<void>;
|
|
1166
|
+
}
|
|
1167
|
+
|
|
1168
|
+
declare const bundleSchema: z.ZodObject<{
|
|
1169
|
+
id: z.ZodString;
|
|
1170
|
+
name: z.ZodString;
|
|
1171
|
+
tagline: z.ZodString;
|
|
1172
|
+
description: z.ZodString;
|
|
1173
|
+
iconUrl: z.ZodNullable<z.ZodString>;
|
|
1174
|
+
purchasable: z.ZodBoolean;
|
|
1175
|
+
partialPurchaseEnabled: z.ZodBoolean;
|
|
1176
|
+
}, "strip", z.ZodTypeAny, {
|
|
1177
|
+
id: string;
|
|
1178
|
+
name: string;
|
|
1179
|
+
tagline: string;
|
|
1180
|
+
description: string;
|
|
1181
|
+
iconUrl: string | null;
|
|
1182
|
+
purchasable: boolean;
|
|
1183
|
+
partialPurchaseEnabled: boolean;
|
|
1184
|
+
}, {
|
|
1185
|
+
id: string;
|
|
1186
|
+
name: string;
|
|
1187
|
+
tagline: string;
|
|
1188
|
+
description: string;
|
|
1189
|
+
iconUrl: string | null;
|
|
1190
|
+
purchasable: boolean;
|
|
1191
|
+
partialPurchaseEnabled: boolean;
|
|
1192
|
+
}>;
|
|
1193
|
+
|
|
1194
|
+
type Bundle = z.infer<typeof bundleSchema>;
|
|
1195
|
+
|
|
962
1196
|
declare const problemDetailsSchema: z.ZodObject<{
|
|
963
1197
|
type: z.ZodString;
|
|
964
1198
|
title: z.ZodString;
|
|
@@ -1013,6 +1247,7 @@ declare class MoonbaseClient {
|
|
|
1013
1247
|
licenses: LicenseEndpoints;
|
|
1014
1248
|
products: ProductEndpoints;
|
|
1015
1249
|
trials: TrialEndpoints;
|
|
1250
|
+
vouchers: VoucherEndpoints;
|
|
1016
1251
|
}
|
|
1017
1252
|
|
|
1018
|
-
export { ActivationMethod, type ActivationRequest, ActivationRequestStatus, ActivationStatus, ConflictError, type Customer, type ImportCustomerRequest, type ImportLicenseRequest, type ImportTrialRequest, type License, type LicenseActivation, LicenseStatus, MoonbaseClient, type MoonbaseConfiguration, MoonbaseError, NotAuthenticatedError, NotAuthorizedError, NotFoundError, type Page, type PricingVariation, type Product, ProductStatus, type Quantifiable, type Trial, TrialStatus };
|
|
1253
|
+
export { ActivationMethod, type ActivationRequest, ActivationRequestStatus, ActivationStatus, type Bundle, ConflictError, type CreateVoucherRequest, type Customer, type ImportCustomerRequest, type ImportLicenseRequest, type ImportTrialRequest, type License, type LicenseActivation, LicenseStatus, MoonbaseClient, type MoonbaseConfiguration, MoonbaseError, NotAuthenticatedError, NotAuthorizedError, NotFoundError, type Page, type PricingVariation, type Product, ProductStatus, type Quantifiable, type Trial, TrialStatus, type Voucher };
|
package/dist/index.js
CHANGED
|
@@ -237,6 +237,12 @@ function paged(itemSchema) {
|
|
|
237
237
|
next: z6.string().nullable()
|
|
238
238
|
});
|
|
239
239
|
}
|
|
240
|
+
function quantifiable(itemSchema) {
|
|
241
|
+
return z6.object({
|
|
242
|
+
value: itemSchema,
|
|
243
|
+
quantity: z6.number()
|
|
244
|
+
});
|
|
245
|
+
}
|
|
240
246
|
|
|
241
247
|
// src/utils/api.ts
|
|
242
248
|
import fetch from "cross-fetch";
|
|
@@ -410,6 +416,55 @@ var TrialEndpoints = class {
|
|
|
410
416
|
}
|
|
411
417
|
};
|
|
412
418
|
|
|
419
|
+
// src/vouchers/schemas.ts
|
|
420
|
+
import { z as z9 } from "zod";
|
|
421
|
+
|
|
422
|
+
// src/bundles/schemas.ts
|
|
423
|
+
import { z as z8 } from "zod";
|
|
424
|
+
var bundleSchema = z8.object({
|
|
425
|
+
id: z8.string(),
|
|
426
|
+
name: z8.string(),
|
|
427
|
+
tagline: z8.string(),
|
|
428
|
+
description: z8.string(),
|
|
429
|
+
iconUrl: z8.string().nullable(),
|
|
430
|
+
purchasable: z8.boolean(),
|
|
431
|
+
partialPurchaseEnabled: z8.boolean()
|
|
432
|
+
});
|
|
433
|
+
|
|
434
|
+
// src/vouchers/schemas.ts
|
|
435
|
+
var voucherSchema = z9.object({
|
|
436
|
+
id: z9.string(),
|
|
437
|
+
description: z9.string(),
|
|
438
|
+
numberOfCodes: z9.number(),
|
|
439
|
+
numberOfRedemptions: z9.number(),
|
|
440
|
+
redeemsProducts: quantifiable(productSchema).array(),
|
|
441
|
+
redeemsBundles: quantifiable(bundleSchema).array()
|
|
442
|
+
});
|
|
443
|
+
var createVoucherRequestSchema = z9.object({
|
|
444
|
+
name: z9.string(),
|
|
445
|
+
description: z9.string(),
|
|
446
|
+
productEntitlements: z9.record(z9.string(), z9.number()).optional(),
|
|
447
|
+
bundleEntitlements: z9.record(z9.string(), z9.number()).optional()
|
|
448
|
+
});
|
|
449
|
+
|
|
450
|
+
// src/vouchers/endpoints.ts
|
|
451
|
+
var VoucherEndpoints = class {
|
|
452
|
+
constructor(api) {
|
|
453
|
+
this.api = api;
|
|
454
|
+
}
|
|
455
|
+
async create(voucher) {
|
|
456
|
+
const request = createVoucherRequestSchema.parse(voucher);
|
|
457
|
+
const response = await this.api.fetch(`/api/vouchers/create`, "POST", request);
|
|
458
|
+
return voucherSchema.parse(response.data);
|
|
459
|
+
}
|
|
460
|
+
async addCodes(voucherId, codes) {
|
|
461
|
+
await this.api.fetch(`/api/vouchers/${voucherId}/codes`, "PUT", codes);
|
|
462
|
+
}
|
|
463
|
+
async deleteCode(voucherId, code) {
|
|
464
|
+
await this.api.fetch(`/api/vouchers/${voucherId}/codes/${code}`, "DELETE");
|
|
465
|
+
}
|
|
466
|
+
};
|
|
467
|
+
|
|
413
468
|
// src/index.ts
|
|
414
469
|
var MoonbaseClient = class {
|
|
415
470
|
constructor(configuration) {
|
|
@@ -421,6 +476,7 @@ var MoonbaseClient = class {
|
|
|
421
476
|
this.licenses = new LicenseEndpoints(api);
|
|
422
477
|
this.products = new ProductEndpoints(api);
|
|
423
478
|
this.trials = new TrialEndpoints(api);
|
|
479
|
+
this.vouchers = new VoucherEndpoints(api);
|
|
424
480
|
}
|
|
425
481
|
};
|
|
426
482
|
export {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moonbase.sh/api",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.119",
|
|
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",
|