@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 +58 -1
- package/dist/index.d.cts +568 -1
- package/dist/index.d.ts +568 -1
- package/dist/index.js +58 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -78,7 +78,8 @@ var licenseActivationSchema = z2.object({
|
|
|
78
78
|
status: z2.nativeEnum(ActivationStatus),
|
|
79
79
|
activationMethod: z2.nativeEnum(ActivationMethod),
|
|
80
80
|
lastValidatedAt: z2.coerce.date(),
|
|
81
|
-
license: licenseSchema
|
|
81
|
+
license: licenseSchema,
|
|
82
|
+
customer: customerSchema.optional()
|
|
82
83
|
});
|
|
83
84
|
var importLicenseRequestSchema = z2.object({
|
|
84
85
|
ownerId: z2.string(),
|
|
@@ -237,6 +238,12 @@ function paged(itemSchema) {
|
|
|
237
238
|
next: z6.string().nullable()
|
|
238
239
|
});
|
|
239
240
|
}
|
|
241
|
+
function quantifiable(itemSchema) {
|
|
242
|
+
return z6.object({
|
|
243
|
+
value: itemSchema,
|
|
244
|
+
quantity: z6.number()
|
|
245
|
+
});
|
|
246
|
+
}
|
|
240
247
|
|
|
241
248
|
// src/utils/api.ts
|
|
242
249
|
import fetch from "cross-fetch";
|
|
@@ -410,6 +417,55 @@ var TrialEndpoints = class {
|
|
|
410
417
|
}
|
|
411
418
|
};
|
|
412
419
|
|
|
420
|
+
// src/vouchers/schemas.ts
|
|
421
|
+
import { z as z9 } from "zod";
|
|
422
|
+
|
|
423
|
+
// src/bundles/schemas.ts
|
|
424
|
+
import { z as z8 } from "zod";
|
|
425
|
+
var bundleSchema = z8.object({
|
|
426
|
+
id: z8.string(),
|
|
427
|
+
name: z8.string(),
|
|
428
|
+
tagline: z8.string(),
|
|
429
|
+
description: z8.string(),
|
|
430
|
+
iconUrl: z8.string().nullable(),
|
|
431
|
+
purchasable: z8.boolean(),
|
|
432
|
+
partialPurchaseEnabled: z8.boolean()
|
|
433
|
+
});
|
|
434
|
+
|
|
435
|
+
// src/vouchers/schemas.ts
|
|
436
|
+
var voucherSchema = z9.object({
|
|
437
|
+
id: z9.string(),
|
|
438
|
+
description: z9.string(),
|
|
439
|
+
numberOfCodes: z9.number(),
|
|
440
|
+
numberOfRedemptions: z9.number(),
|
|
441
|
+
redeemsProducts: quantifiable(productSchema).array(),
|
|
442
|
+
redeemsBundles: quantifiable(bundleSchema).array()
|
|
443
|
+
});
|
|
444
|
+
var createVoucherRequestSchema = z9.object({
|
|
445
|
+
name: z9.string(),
|
|
446
|
+
description: z9.string(),
|
|
447
|
+
productEntitlements: z9.record(z9.string(), z9.number()).optional(),
|
|
448
|
+
bundleEntitlements: z9.record(z9.string(), z9.number()).optional()
|
|
449
|
+
});
|
|
450
|
+
|
|
451
|
+
// src/vouchers/endpoints.ts
|
|
452
|
+
var VoucherEndpoints = class {
|
|
453
|
+
constructor(api) {
|
|
454
|
+
this.api = api;
|
|
455
|
+
}
|
|
456
|
+
async create(voucher) {
|
|
457
|
+
const request = createVoucherRequestSchema.parse(voucher);
|
|
458
|
+
const response = await this.api.fetch(`/api/vouchers/create`, "POST", request);
|
|
459
|
+
return voucherSchema.parse(response.data);
|
|
460
|
+
}
|
|
461
|
+
async addCodes(voucherId, codes) {
|
|
462
|
+
await this.api.fetch(`/api/vouchers/${voucherId}/codes`, "PUT", codes);
|
|
463
|
+
}
|
|
464
|
+
async deleteCode(voucherId, code) {
|
|
465
|
+
await this.api.fetch(`/api/vouchers/${voucherId}/codes/${code}`, "DELETE");
|
|
466
|
+
}
|
|
467
|
+
};
|
|
468
|
+
|
|
413
469
|
// src/index.ts
|
|
414
470
|
var MoonbaseClient = class {
|
|
415
471
|
constructor(configuration) {
|
|
@@ -421,6 +477,7 @@ var MoonbaseClient = class {
|
|
|
421
477
|
this.licenses = new LicenseEndpoints(api);
|
|
422
478
|
this.products = new ProductEndpoints(api);
|
|
423
479
|
this.trials = new TrialEndpoints(api);
|
|
480
|
+
this.vouchers = new VoucherEndpoints(api);
|
|
424
481
|
}
|
|
425
482
|
};
|
|
426
483
|
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.120",
|
|
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",
|