@moonbase.sh/api 0.1.117 → 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 +58 -1
- package/dist/index.d.cts +239 -1
- package/dist/index.d.ts +239 -1
- package/dist/index.js +58 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -83,7 +83,8 @@ var importCustomerRequestSchema = import_zod.z.object({
|
|
|
83
83
|
email: import_zod.z.string(),
|
|
84
84
|
externalId: import_zod.z.string().optional(),
|
|
85
85
|
password: import_zod.z.string().optional(),
|
|
86
|
-
address: addressSchema.optional()
|
|
86
|
+
address: addressSchema.optional(),
|
|
87
|
+
createdAt: import_zod.z.date().optional()
|
|
87
88
|
});
|
|
88
89
|
|
|
89
90
|
// src/licenses/schemas.ts
|
|
@@ -283,6 +284,12 @@ function paged(itemSchema) {
|
|
|
283
284
|
next: import_zod6.z.string().nullable()
|
|
284
285
|
});
|
|
285
286
|
}
|
|
287
|
+
function quantifiable(itemSchema) {
|
|
288
|
+
return import_zod6.z.object({
|
|
289
|
+
value: itemSchema,
|
|
290
|
+
quantity: import_zod6.z.number()
|
|
291
|
+
});
|
|
292
|
+
}
|
|
286
293
|
|
|
287
294
|
// src/utils/api.ts
|
|
288
295
|
var import_cross_fetch = __toESM(require("cross-fetch"), 1);
|
|
@@ -456,6 +463,55 @@ var TrialEndpoints = class {
|
|
|
456
463
|
}
|
|
457
464
|
};
|
|
458
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
|
+
|
|
459
515
|
// src/index.ts
|
|
460
516
|
var MoonbaseClient = class {
|
|
461
517
|
constructor(configuration) {
|
|
@@ -467,6 +523,7 @@ var MoonbaseClient = class {
|
|
|
467
523
|
this.licenses = new LicenseEndpoints(api);
|
|
468
524
|
this.products = new ProductEndpoints(api);
|
|
469
525
|
this.trials = new TrialEndpoints(api);
|
|
526
|
+
this.vouchers = new VoucherEndpoints(api);
|
|
470
527
|
}
|
|
471
528
|
};
|
|
472
529
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/index.d.cts
CHANGED
|
@@ -518,6 +518,7 @@ declare const importCustomerRequestSchema: z.ZodObject<{
|
|
|
518
518
|
region: string | null;
|
|
519
519
|
postCode: string;
|
|
520
520
|
}>>;
|
|
521
|
+
createdAt: z.ZodOptional<z.ZodDate>;
|
|
521
522
|
}, "strip", z.ZodTypeAny, {
|
|
522
523
|
name: string;
|
|
523
524
|
email: string;
|
|
@@ -531,6 +532,7 @@ declare const importCustomerRequestSchema: z.ZodObject<{
|
|
|
531
532
|
region: string | null;
|
|
532
533
|
postCode: string;
|
|
533
534
|
} | undefined;
|
|
535
|
+
createdAt?: Date | undefined;
|
|
534
536
|
}, {
|
|
535
537
|
name: string;
|
|
536
538
|
email: string;
|
|
@@ -544,6 +546,7 @@ declare const importCustomerRequestSchema: z.ZodObject<{
|
|
|
544
546
|
region: string | null;
|
|
545
547
|
postCode: string;
|
|
546
548
|
} | undefined;
|
|
549
|
+
createdAt?: Date | undefined;
|
|
547
550
|
}>;
|
|
548
551
|
|
|
549
552
|
type Customer = z.infer<typeof customerSchema>;
|
|
@@ -956,6 +959,240 @@ declare class TrialEndpoints {
|
|
|
956
959
|
import(trial: ImportTrialRequest): Promise<Trial>;
|
|
957
960
|
}
|
|
958
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
|
+
|
|
959
1196
|
declare const problemDetailsSchema: z.ZodObject<{
|
|
960
1197
|
type: z.ZodString;
|
|
961
1198
|
title: z.ZodString;
|
|
@@ -1010,6 +1247,7 @@ declare class MoonbaseClient {
|
|
|
1010
1247
|
licenses: LicenseEndpoints;
|
|
1011
1248
|
products: ProductEndpoints;
|
|
1012
1249
|
trials: TrialEndpoints;
|
|
1250
|
+
vouchers: VoucherEndpoints;
|
|
1013
1251
|
}
|
|
1014
1252
|
|
|
1015
|
-
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
|
@@ -518,6 +518,7 @@ declare const importCustomerRequestSchema: z.ZodObject<{
|
|
|
518
518
|
region: string | null;
|
|
519
519
|
postCode: string;
|
|
520
520
|
}>>;
|
|
521
|
+
createdAt: z.ZodOptional<z.ZodDate>;
|
|
521
522
|
}, "strip", z.ZodTypeAny, {
|
|
522
523
|
name: string;
|
|
523
524
|
email: string;
|
|
@@ -531,6 +532,7 @@ declare const importCustomerRequestSchema: z.ZodObject<{
|
|
|
531
532
|
region: string | null;
|
|
532
533
|
postCode: string;
|
|
533
534
|
} | undefined;
|
|
535
|
+
createdAt?: Date | undefined;
|
|
534
536
|
}, {
|
|
535
537
|
name: string;
|
|
536
538
|
email: string;
|
|
@@ -544,6 +546,7 @@ declare const importCustomerRequestSchema: z.ZodObject<{
|
|
|
544
546
|
region: string | null;
|
|
545
547
|
postCode: string;
|
|
546
548
|
} | undefined;
|
|
549
|
+
createdAt?: Date | undefined;
|
|
547
550
|
}>;
|
|
548
551
|
|
|
549
552
|
type Customer = z.infer<typeof customerSchema>;
|
|
@@ -956,6 +959,240 @@ declare class TrialEndpoints {
|
|
|
956
959
|
import(trial: ImportTrialRequest): Promise<Trial>;
|
|
957
960
|
}
|
|
958
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
|
+
|
|
959
1196
|
declare const problemDetailsSchema: z.ZodObject<{
|
|
960
1197
|
type: z.ZodString;
|
|
961
1198
|
title: z.ZodString;
|
|
@@ -1010,6 +1247,7 @@ declare class MoonbaseClient {
|
|
|
1010
1247
|
licenses: LicenseEndpoints;
|
|
1011
1248
|
products: ProductEndpoints;
|
|
1012
1249
|
trials: TrialEndpoints;
|
|
1250
|
+
vouchers: VoucherEndpoints;
|
|
1013
1251
|
}
|
|
1014
1252
|
|
|
1015
|
-
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
|
@@ -36,7 +36,8 @@ var importCustomerRequestSchema = z.object({
|
|
|
36
36
|
email: z.string(),
|
|
37
37
|
externalId: z.string().optional(),
|
|
38
38
|
password: z.string().optional(),
|
|
39
|
-
address: addressSchema.optional()
|
|
39
|
+
address: addressSchema.optional(),
|
|
40
|
+
createdAt: z.date().optional()
|
|
40
41
|
});
|
|
41
42
|
|
|
42
43
|
// src/licenses/schemas.ts
|
|
@@ -236,6 +237,12 @@ function paged(itemSchema) {
|
|
|
236
237
|
next: z6.string().nullable()
|
|
237
238
|
});
|
|
238
239
|
}
|
|
240
|
+
function quantifiable(itemSchema) {
|
|
241
|
+
return z6.object({
|
|
242
|
+
value: itemSchema,
|
|
243
|
+
quantity: z6.number()
|
|
244
|
+
});
|
|
245
|
+
}
|
|
239
246
|
|
|
240
247
|
// src/utils/api.ts
|
|
241
248
|
import fetch from "cross-fetch";
|
|
@@ -409,6 +416,55 @@ var TrialEndpoints = class {
|
|
|
409
416
|
}
|
|
410
417
|
};
|
|
411
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
|
+
|
|
412
468
|
// src/index.ts
|
|
413
469
|
var MoonbaseClient = class {
|
|
414
470
|
constructor(configuration) {
|
|
@@ -420,6 +476,7 @@ var MoonbaseClient = class {
|
|
|
420
476
|
this.licenses = new LicenseEndpoints(api);
|
|
421
477
|
this.products = new ProductEndpoints(api);
|
|
422
478
|
this.trials = new TrialEndpoints(api);
|
|
479
|
+
this.vouchers = new VoucherEndpoints(api);
|
|
423
480
|
}
|
|
424
481
|
};
|
|
425
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",
|