@moonbase.sh/api 0.4.43 → 0.4.45
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 +211 -36
- package/dist/index.d.cts +7787 -2301
- package/dist/index.d.ts +7787 -2301
- package/dist/index.js +215 -35
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,12 +1,52 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __export = (target, all) => {
|
|
3
|
+
for (var name in all)
|
|
4
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
5
|
+
};
|
|
6
|
+
|
|
1
7
|
// src/activationRequests/schemas.ts
|
|
8
|
+
var schemas_exports5 = {};
|
|
9
|
+
__export(schemas_exports5, {
|
|
10
|
+
activationRequestSchema: () => activationRequestSchema
|
|
11
|
+
});
|
|
2
12
|
import { z as z6 } from "zod";
|
|
3
13
|
|
|
4
14
|
// src/licenses/schemas.ts
|
|
15
|
+
var schemas_exports2 = {};
|
|
16
|
+
__export(schemas_exports2, {
|
|
17
|
+
importLicenseRequestSchema: () => importLicenseRequestSchema,
|
|
18
|
+
licenseActivationSchema: () => licenseActivationSchema,
|
|
19
|
+
licenseSchema: () => licenseSchema,
|
|
20
|
+
provisionLicensesRequestSchema: () => provisionLicensesRequestSchema
|
|
21
|
+
});
|
|
5
22
|
import { z as z3 } from "zod";
|
|
6
23
|
|
|
7
24
|
// src/customers/schemas.ts
|
|
25
|
+
var schemas_exports = {};
|
|
26
|
+
__export(schemas_exports, {
|
|
27
|
+
addressSchema: () => addressSchema,
|
|
28
|
+
communicationPreferencesSchema: () => communicationPreferencesSchema,
|
|
29
|
+
customerSchema: () => customerSchema,
|
|
30
|
+
importCustomerRequestSchema: () => importCustomerRequestSchema
|
|
31
|
+
});
|
|
8
32
|
import { z as z2 } from "zod";
|
|
9
33
|
|
|
34
|
+
// src/subscriptions/models.ts
|
|
35
|
+
var SubscriptionStatus = /* @__PURE__ */ ((SubscriptionStatus2) => {
|
|
36
|
+
SubscriptionStatus2["Active"] = "Active";
|
|
37
|
+
SubscriptionStatus2["Expired"] = "Expired";
|
|
38
|
+
SubscriptionStatus2["Cancelled"] = "Cancelled";
|
|
39
|
+
return SubscriptionStatus2;
|
|
40
|
+
})(SubscriptionStatus || {});
|
|
41
|
+
var CycleLength = /* @__PURE__ */ ((CycleLength2) => {
|
|
42
|
+
CycleLength2["Daily"] = "Daily";
|
|
43
|
+
CycleLength2["Weekly"] = "Weekly";
|
|
44
|
+
CycleLength2["Monthly"] = "Monthly";
|
|
45
|
+
CycleLength2["Quarterly"] = "Quarterly";
|
|
46
|
+
CycleLength2["Yearly"] = "Yearly";
|
|
47
|
+
return CycleLength2;
|
|
48
|
+
})(CycleLength || {});
|
|
49
|
+
|
|
10
50
|
// src/globalSchemas.ts
|
|
11
51
|
import { z } from "zod";
|
|
12
52
|
var userSchema = z.object({
|
|
@@ -22,7 +62,7 @@ var moneySchema = z.object({
|
|
|
22
62
|
currency: z.string(),
|
|
23
63
|
amount: z.number()
|
|
24
64
|
});
|
|
25
|
-
var priceCollectionSchema = z.record(z.number());
|
|
65
|
+
var priceCollectionSchema = z.record(z.number()).describe("Mapping of currency code to amount");
|
|
26
66
|
var percentageOffDiscountSchema = z.object({
|
|
27
67
|
type: z.literal("PercentageOffDiscount"),
|
|
28
68
|
percentage: z.number()
|
|
@@ -39,17 +79,62 @@ var dateTimeSpanSchema = z.object({
|
|
|
39
79
|
from: z.coerce.date().nullable(),
|
|
40
80
|
to: z.coerce.date().nullable()
|
|
41
81
|
});
|
|
82
|
+
var exclusivitySchema = z.discriminatedUnion("type", [
|
|
83
|
+
z.object({ type: z.literal("Everyone") }),
|
|
84
|
+
z.object({ type: z.literal("None") }),
|
|
85
|
+
z.object({ type: z.literal("OwnsAllOf"), productIds: z.string().array(), includeSubscriptions: z.boolean() }),
|
|
86
|
+
z.object({ type: z.literal("OwnsSomeOf"), productIds: z.string().array(), includeSubscriptions: z.boolean() }),
|
|
87
|
+
z.object({ type: z.literal("CustomerGroup"), groupId: z.string() }),
|
|
88
|
+
z.object({
|
|
89
|
+
type: z.literal("AtLeastNumberOfProducts"),
|
|
90
|
+
minNumberOfProducts: z.number(),
|
|
91
|
+
includeSubscriptions: z.boolean(),
|
|
92
|
+
including: z.string().array(),
|
|
93
|
+
excluding: z.string().array()
|
|
94
|
+
}),
|
|
95
|
+
z.object({
|
|
96
|
+
type: z.literal("UTMSegment"),
|
|
97
|
+
source: z.string().nullable(),
|
|
98
|
+
medium: z.string().nullable(),
|
|
99
|
+
campaign: z.string().nullable(),
|
|
100
|
+
term: z.string().nullable(),
|
|
101
|
+
content: z.string().nullable()
|
|
102
|
+
})
|
|
103
|
+
]);
|
|
42
104
|
var pricingDiscountSchema = z.object({
|
|
43
105
|
name: z.string(),
|
|
44
|
-
description: z.string().
|
|
106
|
+
description: z.string().nullish(),
|
|
45
107
|
discount: discountSchema,
|
|
46
|
-
|
|
47
|
-
|
|
108
|
+
exclusivity: exclusivitySchema.nullish(),
|
|
109
|
+
applicableVariationIds: z.string().array().nullish(),
|
|
110
|
+
validity: dateTimeSpanSchema.nullish(),
|
|
111
|
+
recurringPaymentUseCount: z.number().nullish()
|
|
48
112
|
});
|
|
113
|
+
var entitlementSchema = z.discriminatedUnion("type", [
|
|
114
|
+
z.object({
|
|
115
|
+
type: z.literal("PerpetualLicense")
|
|
116
|
+
}),
|
|
117
|
+
z.object({
|
|
118
|
+
type: z.literal("SubscriptionLicense")
|
|
119
|
+
})
|
|
120
|
+
]);
|
|
121
|
+
var recurrenceSchema = z.discriminatedUnion("type", [
|
|
122
|
+
z.object({
|
|
123
|
+
type: z.literal("OneOff")
|
|
124
|
+
}),
|
|
125
|
+
z.object({
|
|
126
|
+
type: z.literal("Recurring"),
|
|
127
|
+
cycleLength: z.nativeEnum(CycleLength),
|
|
128
|
+
renewalPrice: priceCollectionSchema.nullish()
|
|
129
|
+
})
|
|
130
|
+
]);
|
|
49
131
|
var pricingVariationSchema = z.object({
|
|
50
132
|
id: z.string(),
|
|
51
133
|
name: z.string(),
|
|
52
|
-
price: priceCollectionSchema
|
|
134
|
+
price: priceCollectionSchema,
|
|
135
|
+
entitlement: entitlementSchema,
|
|
136
|
+
recurrence: recurrenceSchema,
|
|
137
|
+
requireCommunicationsOptInOnLeadGeneration: z.boolean().optional()
|
|
53
138
|
});
|
|
54
139
|
function paged(itemSchema, api) {
|
|
55
140
|
return z.object({
|
|
@@ -212,6 +297,11 @@ var provisionLicensesRequestSchema = z3.union([
|
|
|
212
297
|
]);
|
|
213
298
|
|
|
214
299
|
// src/products/schemas.ts
|
|
300
|
+
var schemas_exports3 = {};
|
|
301
|
+
__export(schemas_exports3, {
|
|
302
|
+
productReleaseSchema: () => productReleaseSchema,
|
|
303
|
+
productSchema: () => productSchema
|
|
304
|
+
});
|
|
215
305
|
import { z as z4 } from "zod";
|
|
216
306
|
|
|
217
307
|
// src/products/models.ts
|
|
@@ -260,6 +350,11 @@ var productReleaseSchema = z4.object({
|
|
|
260
350
|
});
|
|
261
351
|
|
|
262
352
|
// src/trials/schemas.ts
|
|
353
|
+
var schemas_exports4 = {};
|
|
354
|
+
__export(schemas_exports4, {
|
|
355
|
+
importTrialRequestSchema: () => importTrialRequestSchema,
|
|
356
|
+
trialSchema: () => trialSchema
|
|
357
|
+
});
|
|
263
358
|
import { z as z5 } from "zod";
|
|
264
359
|
|
|
265
360
|
// src/trials/models.ts
|
|
@@ -335,11 +430,11 @@ import fetch from "cross-fetch";
|
|
|
335
430
|
// src/utils/errors.ts
|
|
336
431
|
var MoonbaseError = class extends Error {
|
|
337
432
|
constructor(problemDetails) {
|
|
338
|
-
var _a
|
|
433
|
+
var _a;
|
|
339
434
|
super();
|
|
340
435
|
this.problemDetails = problemDetails;
|
|
341
436
|
this.name = "MoonbaseError";
|
|
342
|
-
this.message =
|
|
437
|
+
this.message = problemDetails ? ((_a = problemDetails.detail) != null ? _a : problemDetails.title) + "\n" + JSON.stringify(problemDetails, void 0, 2) : "An unknown error occurred";
|
|
343
438
|
}
|
|
344
439
|
};
|
|
345
440
|
var NotAuthorizedError = class extends MoonbaseError {
|
|
@@ -511,6 +606,20 @@ var LicenseEndpoints = class {
|
|
|
511
606
|
};
|
|
512
607
|
|
|
513
608
|
// src/orders/schemas.ts
|
|
609
|
+
var schemas_exports6 = {};
|
|
610
|
+
__export(schemas_exports6, {
|
|
611
|
+
bundleLineItemFulfillmentSchema: () => bundleLineItemFulfillmentSchema,
|
|
612
|
+
bundleLineItemSchema: () => bundleLineItemSchema,
|
|
613
|
+
couponSnapshotSchema: () => couponSnapshotSchema,
|
|
614
|
+
customerSnapshotSchema: () => customerSnapshotSchema,
|
|
615
|
+
licenseLineItemFulfillmentSchema: () => licenseLineItemFulfillmentSchema,
|
|
616
|
+
lineItemFulfillmentSchema: () => lineItemFulfillmentSchema,
|
|
617
|
+
orderLineItemSchema: () => orderLineItemSchema,
|
|
618
|
+
orderSchema: () => orderSchema,
|
|
619
|
+
orderTotalSchema: () => orderTotalSchema,
|
|
620
|
+
productLineItemSchema: () => productLineItemSchema,
|
|
621
|
+
utmSchema: () => utmSchema
|
|
622
|
+
});
|
|
514
623
|
import { z as z8 } from "zod";
|
|
515
624
|
|
|
516
625
|
// src/orders/models.ts
|
|
@@ -523,10 +632,16 @@ var OrderStatus = /* @__PURE__ */ ((OrderStatus2) => {
|
|
|
523
632
|
})(OrderStatus || {});
|
|
524
633
|
|
|
525
634
|
// src/orders/schemas.ts
|
|
526
|
-
var
|
|
635
|
+
var couponSnapshotSchema = z8.object({
|
|
636
|
+
id: z8.string(),
|
|
527
637
|
code: z8.string(),
|
|
528
638
|
name: z8.string(),
|
|
529
|
-
description: z8.string()
|
|
639
|
+
description: z8.string(),
|
|
640
|
+
combinable: z8.boolean(),
|
|
641
|
+
discount: discountSchema,
|
|
642
|
+
applicableProductIds: z8.string().array().describe("List of product IDs the coupon can be applied to, empty or missing means all products are applicable"),
|
|
643
|
+
applicableBundleIds: z8.string().array().describe("List of bundle IDs the coupon can be applied to, empty or missing means all bundles are applicable"),
|
|
644
|
+
recurringPaymentUseCount: z8.number().nullish()
|
|
530
645
|
});
|
|
531
646
|
var licenseLineItemFulfillmentSchema = z8.object({
|
|
532
647
|
type: z8.literal("License"),
|
|
@@ -617,11 +732,11 @@ var orderPayoutSchema = z8.object({
|
|
|
617
732
|
feeBreakdown: z8.string().array()
|
|
618
733
|
});
|
|
619
734
|
var customerSnapshotSchema = z8.object({
|
|
620
|
-
name: z8.string().
|
|
621
|
-
businessName: z8.string().
|
|
622
|
-
taxId: z8.string().
|
|
623
|
-
email: z8.string().
|
|
624
|
-
address: addressSchema.
|
|
735
|
+
name: z8.string().nullish(),
|
|
736
|
+
businessName: z8.string().nullish(),
|
|
737
|
+
taxId: z8.string().nullish(),
|
|
738
|
+
email: z8.string().nullish(),
|
|
739
|
+
address: addressSchema.nullish()
|
|
625
740
|
});
|
|
626
741
|
var utmSchema = z8.object({
|
|
627
742
|
referrer: z8.string().optional(),
|
|
@@ -646,10 +761,12 @@ var orderSchema = z8.object({
|
|
|
646
761
|
initialUTM: utmSchema.optional(),
|
|
647
762
|
currentUTM: utmSchema.optional(),
|
|
648
763
|
customer: customerSnapshotSchema.optional(),
|
|
649
|
-
couponsApplied:
|
|
764
|
+
couponsApplied: couponSnapshotSchema.array(),
|
|
650
765
|
items: orderLineItemSchema.array(),
|
|
651
766
|
lastUpdated: entityChangeSchema,
|
|
652
|
-
created: entityChangeSchema
|
|
767
|
+
created: entityChangeSchema,
|
|
768
|
+
checkoutUrl: z8.string().optional(),
|
|
769
|
+
embeddedCheckoutUrl: z8.string().optional()
|
|
653
770
|
});
|
|
654
771
|
|
|
655
772
|
// src/orders/endpoints.ts
|
|
@@ -665,6 +782,10 @@ var OrderEndpoints = class {
|
|
|
665
782
|
const response = await this.api.fetch(`/api/orders/${id}`);
|
|
666
783
|
return orderSchema.parse(response.data);
|
|
667
784
|
}
|
|
785
|
+
async prepare(request, returnUrl) {
|
|
786
|
+
const response = await this.api.fetch("/api/orders/prepare" + (returnUrl ? `?returnUrl=${encodeURIComponent(returnUrl)}` : ""), "POST", request);
|
|
787
|
+
return orderSchema.parse(response.data);
|
|
788
|
+
}
|
|
668
789
|
};
|
|
669
790
|
|
|
670
791
|
// src/products/endpoints.ts
|
|
@@ -687,25 +808,12 @@ var ProductEndpoints = class {
|
|
|
687
808
|
};
|
|
688
809
|
|
|
689
810
|
// src/subscriptions/schemas.ts
|
|
811
|
+
var schemas_exports7 = {};
|
|
812
|
+
__export(schemas_exports7, {
|
|
813
|
+
importSubscriptionRequestSchema: () => importSubscriptionRequestSchema,
|
|
814
|
+
subscriptionSchema: () => subscriptionSchema
|
|
815
|
+
});
|
|
690
816
|
import { z as z9 } from "zod";
|
|
691
|
-
|
|
692
|
-
// src/subscriptions/models.ts
|
|
693
|
-
var SubscriptionStatus = /* @__PURE__ */ ((SubscriptionStatus2) => {
|
|
694
|
-
SubscriptionStatus2["Active"] = "Active";
|
|
695
|
-
SubscriptionStatus2["Expired"] = "Expired";
|
|
696
|
-
SubscriptionStatus2["Cancelled"] = "Cancelled";
|
|
697
|
-
return SubscriptionStatus2;
|
|
698
|
-
})(SubscriptionStatus || {});
|
|
699
|
-
var CycleLength = /* @__PURE__ */ ((CycleLength2) => {
|
|
700
|
-
CycleLength2["Daily"] = "Daily";
|
|
701
|
-
CycleLength2["Weekly"] = "Weekly";
|
|
702
|
-
CycleLength2["Monthly"] = "Monthly";
|
|
703
|
-
CycleLength2["Quarterly"] = "Quarterly";
|
|
704
|
-
CycleLength2["Yearly"] = "Yearly";
|
|
705
|
-
return CycleLength2;
|
|
706
|
-
})(CycleLength || {});
|
|
707
|
-
|
|
708
|
-
// src/subscriptions/schemas.ts
|
|
709
817
|
var subscriptionContentSchema = z9.discriminatedUnion("type", [
|
|
710
818
|
z9.object({
|
|
711
819
|
type: z9.literal("Product"),
|
|
@@ -820,9 +928,19 @@ var TrialEndpoints = class {
|
|
|
820
928
|
};
|
|
821
929
|
|
|
822
930
|
// src/vouchers/schemas.ts
|
|
931
|
+
var schemas_exports9 = {};
|
|
932
|
+
__export(schemas_exports9, {
|
|
933
|
+
createVoucherRequestSchema: () => createVoucherRequestSchema,
|
|
934
|
+
voucherCodeSchema: () => voucherCodeSchema,
|
|
935
|
+
voucherSchema: () => voucherSchema
|
|
936
|
+
});
|
|
823
937
|
import { z as z11 } from "zod";
|
|
824
938
|
|
|
825
939
|
// src/bundles/schemas.ts
|
|
940
|
+
var schemas_exports8 = {};
|
|
941
|
+
__export(schemas_exports8, {
|
|
942
|
+
bundleSchema: () => bundleSchema
|
|
943
|
+
});
|
|
826
944
|
import { z as z10 } from "zod";
|
|
827
945
|
var bundleSchema = z10.object({
|
|
828
946
|
id: z10.string(),
|
|
@@ -889,6 +1007,67 @@ var VoucherEndpoints = class {
|
|
|
889
1007
|
}
|
|
890
1008
|
};
|
|
891
1009
|
|
|
1010
|
+
// src/schemas.ts
|
|
1011
|
+
var schemas_exports11 = {};
|
|
1012
|
+
__export(schemas_exports11, {
|
|
1013
|
+
activationRequests: () => schemas_exports5,
|
|
1014
|
+
bundles: () => schemas_exports8,
|
|
1015
|
+
coupons: () => schemas_exports10,
|
|
1016
|
+
customers: () => schemas_exports,
|
|
1017
|
+
dateTimeSpanSchema: () => dateTimeSpanSchema,
|
|
1018
|
+
discountSchema: () => discountSchema,
|
|
1019
|
+
entityChangeSchema: () => entityChangeSchema,
|
|
1020
|
+
licenses: () => schemas_exports2,
|
|
1021
|
+
moneySchema: () => moneySchema,
|
|
1022
|
+
orders: () => schemas_exports6,
|
|
1023
|
+
paged: () => paged,
|
|
1024
|
+
priceCollectionSchema: () => priceCollectionSchema,
|
|
1025
|
+
pricingDiscountSchema: () => pricingDiscountSchema,
|
|
1026
|
+
pricingVariationSchema: () => pricingVariationSchema,
|
|
1027
|
+
products: () => schemas_exports3,
|
|
1028
|
+
quantifiable: () => quantifiable,
|
|
1029
|
+
subscriptions: () => schemas_exports7,
|
|
1030
|
+
trials: () => schemas_exports4,
|
|
1031
|
+
userSchema: () => userSchema,
|
|
1032
|
+
vouchers: () => schemas_exports9
|
|
1033
|
+
});
|
|
1034
|
+
|
|
1035
|
+
// src/coupons/schemas.ts
|
|
1036
|
+
var schemas_exports10 = {};
|
|
1037
|
+
__export(schemas_exports10, {
|
|
1038
|
+
couponCodeSchema: () => couponCodeSchema,
|
|
1039
|
+
couponSchema: () => couponSchema,
|
|
1040
|
+
createCouponRequestSchema: () => createCouponRequestSchema
|
|
1041
|
+
});
|
|
1042
|
+
import { z as z12 } from "zod";
|
|
1043
|
+
var couponSchema = z12.object({
|
|
1044
|
+
id: z12.string(),
|
|
1045
|
+
name: z12.string(),
|
|
1046
|
+
description: z12.string(),
|
|
1047
|
+
numberOfCodes: z12.number(),
|
|
1048
|
+
numberOfRedemptions: z12.number(),
|
|
1049
|
+
combinable: z12.boolean(),
|
|
1050
|
+
recurringPaymentUseCount: z12.number().nullable(),
|
|
1051
|
+
discount: discountSchema,
|
|
1052
|
+
applicableProducts: productSchema.array(),
|
|
1053
|
+
applicableBundles: bundleSchema.array(),
|
|
1054
|
+
applicableProductVariations: z12.record(z12.string(), z12.string().array()),
|
|
1055
|
+
applicableBundleVariations: z12.record(z12.string(), z12.string().array()),
|
|
1056
|
+
isDeleted: z12.boolean(),
|
|
1057
|
+
lastUpdated: entityChangeSchema,
|
|
1058
|
+
created: entityChangeSchema
|
|
1059
|
+
});
|
|
1060
|
+
var createCouponRequestSchema = z12.object({
|
|
1061
|
+
name: z12.string(),
|
|
1062
|
+
description: z12.string(),
|
|
1063
|
+
applicableProducts: z12.record(z12.string(), z12.string().array()).optional().describe("Restricts the coupon to specific products, needs to be a map of product ID to array of applicable pricing variations, empty array if any variation is applicable."),
|
|
1064
|
+
applicableBundles: z12.record(z12.string(), z12.string().array()).optional().describe("Restricts the coupon to specific bundles, needs to be a map of bundle ID to array of applicable pricing variations, empty array if any variation is applicable.")
|
|
1065
|
+
});
|
|
1066
|
+
var couponCodeSchema = z12.object({
|
|
1067
|
+
code: z12.string(),
|
|
1068
|
+
numberOfRedemptions: z12.number()
|
|
1069
|
+
});
|
|
1070
|
+
|
|
892
1071
|
// src/index.ts
|
|
893
1072
|
var MoonbaseClient = class {
|
|
894
1073
|
constructor(configuration) {
|
|
@@ -923,5 +1102,6 @@ export {
|
|
|
923
1102
|
ProductStatus,
|
|
924
1103
|
SubscriptionStatus,
|
|
925
1104
|
TrialStatus,
|
|
926
|
-
objectToQuery
|
|
1105
|
+
objectToQuery,
|
|
1106
|
+
schemas_exports11 as schemas
|
|
927
1107
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moonbase.sh/api",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.4.
|
|
4
|
+
"version": "0.4.45",
|
|
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",
|