@moonbase.sh/api 0.4.44 → 0.4.46

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
@@ -47,19 +47,54 @@ __export(index_exports, {
47
47
  ProductStatus: () => ProductStatus,
48
48
  SubscriptionStatus: () => SubscriptionStatus,
49
49
  TrialStatus: () => TrialStatus,
50
- objectToQuery: () => objectToQuery
50
+ objectToQuery: () => objectToQuery,
51
+ schemas: () => schemas_exports11
51
52
  });
52
53
  module.exports = __toCommonJS(index_exports);
53
54
 
54
55
  // src/activationRequests/schemas.ts
56
+ var schemas_exports5 = {};
57
+ __export(schemas_exports5, {
58
+ activationRequestSchema: () => activationRequestSchema
59
+ });
55
60
  var import_zod6 = require("zod");
56
61
 
57
62
  // src/licenses/schemas.ts
63
+ var schemas_exports2 = {};
64
+ __export(schemas_exports2, {
65
+ importLicenseRequestSchema: () => importLicenseRequestSchema,
66
+ licenseActivationSchema: () => licenseActivationSchema,
67
+ licenseSchema: () => licenseSchema,
68
+ provisionLicensesRequestSchema: () => provisionLicensesRequestSchema
69
+ });
58
70
  var import_zod3 = require("zod");
59
71
 
60
72
  // src/customers/schemas.ts
73
+ var schemas_exports = {};
74
+ __export(schemas_exports, {
75
+ addressSchema: () => addressSchema,
76
+ communicationPreferencesSchema: () => communicationPreferencesSchema,
77
+ customerSchema: () => customerSchema,
78
+ importCustomerRequestSchema: () => importCustomerRequestSchema
79
+ });
61
80
  var import_zod2 = require("zod");
62
81
 
82
+ // src/subscriptions/models.ts
83
+ var SubscriptionStatus = /* @__PURE__ */ ((SubscriptionStatus2) => {
84
+ SubscriptionStatus2["Active"] = "Active";
85
+ SubscriptionStatus2["Expired"] = "Expired";
86
+ SubscriptionStatus2["Cancelled"] = "Cancelled";
87
+ return SubscriptionStatus2;
88
+ })(SubscriptionStatus || {});
89
+ var CycleLength = /* @__PURE__ */ ((CycleLength2) => {
90
+ CycleLength2["Daily"] = "Daily";
91
+ CycleLength2["Weekly"] = "Weekly";
92
+ CycleLength2["Monthly"] = "Monthly";
93
+ CycleLength2["Quarterly"] = "Quarterly";
94
+ CycleLength2["Yearly"] = "Yearly";
95
+ return CycleLength2;
96
+ })(CycleLength || {});
97
+
63
98
  // src/globalSchemas.ts
64
99
  var import_zod = require("zod");
65
100
  var userSchema = import_zod.z.object({
@@ -75,7 +110,7 @@ var moneySchema = import_zod.z.object({
75
110
  currency: import_zod.z.string(),
76
111
  amount: import_zod.z.number()
77
112
  });
78
- var priceCollectionSchema = import_zod.z.record(import_zod.z.number());
113
+ var priceCollectionSchema = import_zod.z.record(import_zod.z.number()).describe("Mapping of currency code to amount");
79
114
  var percentageOffDiscountSchema = import_zod.z.object({
80
115
  type: import_zod.z.literal("PercentageOffDiscount"),
81
116
  percentage: import_zod.z.number()
@@ -92,17 +127,62 @@ var dateTimeSpanSchema = import_zod.z.object({
92
127
  from: import_zod.z.coerce.date().nullable(),
93
128
  to: import_zod.z.coerce.date().nullable()
94
129
  });
130
+ var exclusivitySchema = import_zod.z.discriminatedUnion("type", [
131
+ import_zod.z.object({ type: import_zod.z.literal("Everyone") }),
132
+ import_zod.z.object({ type: import_zod.z.literal("None") }),
133
+ import_zod.z.object({ type: import_zod.z.literal("OwnsAllOf"), productIds: import_zod.z.string().array(), includeSubscriptions: import_zod.z.boolean() }),
134
+ import_zod.z.object({ type: import_zod.z.literal("OwnsSomeOf"), productIds: import_zod.z.string().array(), includeSubscriptions: import_zod.z.boolean() }),
135
+ import_zod.z.object({ type: import_zod.z.literal("CustomerGroup"), groupId: import_zod.z.string() }),
136
+ import_zod.z.object({
137
+ type: import_zod.z.literal("AtLeastNumberOfProducts"),
138
+ minNumberOfProducts: import_zod.z.number(),
139
+ includeSubscriptions: import_zod.z.boolean(),
140
+ including: import_zod.z.string().array(),
141
+ excluding: import_zod.z.string().array()
142
+ }),
143
+ import_zod.z.object({
144
+ type: import_zod.z.literal("UTMSegment"),
145
+ source: import_zod.z.string().nullable(),
146
+ medium: import_zod.z.string().nullable(),
147
+ campaign: import_zod.z.string().nullable(),
148
+ term: import_zod.z.string().nullable(),
149
+ content: import_zod.z.string().nullable()
150
+ })
151
+ ]);
95
152
  var pricingDiscountSchema = import_zod.z.object({
96
153
  name: import_zod.z.string(),
97
- description: import_zod.z.string().nullable(),
154
+ description: import_zod.z.string().nullish(),
98
155
  discount: discountSchema,
99
- applicableVariationIds: import_zod.z.string().array().nullable(),
100
- validity: dateTimeSpanSchema.nullable()
156
+ exclusivity: exclusivitySchema.nullish(),
157
+ applicableVariationIds: import_zod.z.string().array().nullish(),
158
+ validity: dateTimeSpanSchema.nullish(),
159
+ recurringPaymentUseCount: import_zod.z.number().nullish()
101
160
  });
161
+ var entitlementSchema = import_zod.z.discriminatedUnion("type", [
162
+ import_zod.z.object({
163
+ type: import_zod.z.literal("PerpetualLicense")
164
+ }),
165
+ import_zod.z.object({
166
+ type: import_zod.z.literal("SubscriptionLicense")
167
+ })
168
+ ]);
169
+ var recurrenceSchema = import_zod.z.discriminatedUnion("type", [
170
+ import_zod.z.object({
171
+ type: import_zod.z.literal("OneOff")
172
+ }),
173
+ import_zod.z.object({
174
+ type: import_zod.z.literal("Recurring"),
175
+ cycleLength: import_zod.z.nativeEnum(CycleLength),
176
+ renewalPrice: priceCollectionSchema.nullish()
177
+ })
178
+ ]);
102
179
  var pricingVariationSchema = import_zod.z.object({
103
180
  id: import_zod.z.string(),
104
181
  name: import_zod.z.string(),
105
- price: priceCollectionSchema
182
+ price: priceCollectionSchema,
183
+ entitlement: entitlementSchema,
184
+ recurrence: recurrenceSchema,
185
+ requireCommunicationsOptInOnLeadGeneration: import_zod.z.boolean().optional()
106
186
  });
107
187
  function paged(itemSchema, api) {
108
188
  return import_zod.z.object({
@@ -265,6 +345,11 @@ var provisionLicensesRequestSchema = import_zod3.z.union([
265
345
  ]);
266
346
 
267
347
  // src/products/schemas.ts
348
+ var schemas_exports3 = {};
349
+ __export(schemas_exports3, {
350
+ productReleaseSchema: () => productReleaseSchema,
351
+ productSchema: () => productSchema
352
+ });
268
353
  var import_zod4 = require("zod");
269
354
 
270
355
  // src/products/models.ts
@@ -313,6 +398,11 @@ var productReleaseSchema = import_zod4.z.object({
313
398
  });
314
399
 
315
400
  // src/trials/schemas.ts
401
+ var schemas_exports4 = {};
402
+ __export(schemas_exports4, {
403
+ importTrialRequestSchema: () => importTrialRequestSchema,
404
+ trialSchema: () => trialSchema
405
+ });
316
406
  var import_zod5 = require("zod");
317
407
 
318
408
  // src/trials/models.ts
@@ -388,11 +478,11 @@ var import_cross_fetch = __toESM(require("cross-fetch"), 1);
388
478
  // src/utils/errors.ts
389
479
  var MoonbaseError = class extends Error {
390
480
  constructor(problemDetails) {
391
- var _a, _b;
481
+ var _a;
392
482
  super();
393
483
  this.problemDetails = problemDetails;
394
484
  this.name = "MoonbaseError";
395
- this.message = (_b = (_a = problemDetails == null ? void 0 : problemDetails.detail) != null ? _a : problemDetails == null ? void 0 : problemDetails.title) != null ? _b : "An unknown error occurred";
485
+ this.message = problemDetails ? ((_a = problemDetails.detail) != null ? _a : problemDetails.title) + "\n" + JSON.stringify(problemDetails, void 0, 2) : "An unknown error occurred";
396
486
  }
397
487
  };
398
488
  var NotAuthorizedError = class extends MoonbaseError {
@@ -564,6 +654,20 @@ var LicenseEndpoints = class {
564
654
  };
565
655
 
566
656
  // src/orders/schemas.ts
657
+ var schemas_exports6 = {};
658
+ __export(schemas_exports6, {
659
+ bundleLineItemFulfillmentSchema: () => bundleLineItemFulfillmentSchema,
660
+ bundleLineItemSchema: () => bundleLineItemSchema,
661
+ couponSnapshotSchema: () => couponSnapshotSchema,
662
+ customerSnapshotSchema: () => customerSnapshotSchema,
663
+ licenseLineItemFulfillmentSchema: () => licenseLineItemFulfillmentSchema,
664
+ lineItemFulfillmentSchema: () => lineItemFulfillmentSchema,
665
+ orderLineItemSchema: () => orderLineItemSchema,
666
+ orderSchema: () => orderSchema,
667
+ orderTotalSchema: () => orderTotalSchema,
668
+ productLineItemSchema: () => productLineItemSchema,
669
+ utmSchema: () => utmSchema
670
+ });
567
671
  var import_zod8 = require("zod");
568
672
 
569
673
  // src/orders/models.ts
@@ -576,10 +680,16 @@ var OrderStatus = /* @__PURE__ */ ((OrderStatus2) => {
576
680
  })(OrderStatus || {});
577
681
 
578
682
  // src/orders/schemas.ts
579
- var couponSchema = import_zod8.z.object({
683
+ var couponSnapshotSchema = import_zod8.z.object({
684
+ id: import_zod8.z.string(),
580
685
  code: import_zod8.z.string(),
581
686
  name: import_zod8.z.string(),
582
- description: import_zod8.z.string()
687
+ description: import_zod8.z.string(),
688
+ combinable: import_zod8.z.boolean(),
689
+ discount: discountSchema,
690
+ applicableProductIds: import_zod8.z.string().array().describe("List of product IDs the coupon can be applied to, empty or missing means all products are applicable"),
691
+ applicableBundleIds: import_zod8.z.string().array().describe("List of bundle IDs the coupon can be applied to, empty or missing means all bundles are applicable"),
692
+ recurringPaymentUseCount: import_zod8.z.number().nullish()
583
693
  });
584
694
  var licenseLineItemFulfillmentSchema = import_zod8.z.object({
585
695
  type: import_zod8.z.literal("License"),
@@ -670,11 +780,11 @@ var orderPayoutSchema = import_zod8.z.object({
670
780
  feeBreakdown: import_zod8.z.string().array()
671
781
  });
672
782
  var customerSnapshotSchema = import_zod8.z.object({
673
- name: import_zod8.z.string().nullable(),
674
- businessName: import_zod8.z.string().nullable(),
675
- taxId: import_zod8.z.string().nullable(),
676
- email: import_zod8.z.string().nullable(),
677
- address: addressSchema.nullable()
783
+ name: import_zod8.z.string().nullish(),
784
+ businessName: import_zod8.z.string().nullish(),
785
+ taxId: import_zod8.z.string().nullish(),
786
+ email: import_zod8.z.string().nullish(),
787
+ address: addressSchema.nullish()
678
788
  });
679
789
  var utmSchema = import_zod8.z.object({
680
790
  referrer: import_zod8.z.string().optional(),
@@ -699,10 +809,12 @@ var orderSchema = import_zod8.z.object({
699
809
  initialUTM: utmSchema.optional(),
700
810
  currentUTM: utmSchema.optional(),
701
811
  customer: customerSnapshotSchema.optional(),
702
- couponsApplied: couponSchema.array(),
812
+ couponsApplied: couponSnapshotSchema.array(),
703
813
  items: orderLineItemSchema.array(),
704
814
  lastUpdated: entityChangeSchema,
705
- created: entityChangeSchema
815
+ created: entityChangeSchema,
816
+ checkoutUrl: import_zod8.z.string().optional(),
817
+ embeddedCheckoutUrl: import_zod8.z.string().optional()
706
818
  });
707
819
 
708
820
  // src/orders/endpoints.ts
@@ -718,6 +830,10 @@ var OrderEndpoints = class {
718
830
  const response = await this.api.fetch(`/api/orders/${id}`);
719
831
  return orderSchema.parse(response.data);
720
832
  }
833
+ async prepare(request, returnUrl) {
834
+ const response = await this.api.fetch("/api/orders/prepare" + (returnUrl ? `?returnUrl=${encodeURIComponent(returnUrl)}` : ""), "POST", request);
835
+ return orderSchema.parse(response.data);
836
+ }
721
837
  };
722
838
 
723
839
  // src/products/endpoints.ts
@@ -740,25 +856,12 @@ var ProductEndpoints = class {
740
856
  };
741
857
 
742
858
  // src/subscriptions/schemas.ts
859
+ var schemas_exports7 = {};
860
+ __export(schemas_exports7, {
861
+ importSubscriptionRequestSchema: () => importSubscriptionRequestSchema,
862
+ subscriptionSchema: () => subscriptionSchema
863
+ });
743
864
  var import_zod9 = require("zod");
744
-
745
- // src/subscriptions/models.ts
746
- var SubscriptionStatus = /* @__PURE__ */ ((SubscriptionStatus2) => {
747
- SubscriptionStatus2["Active"] = "Active";
748
- SubscriptionStatus2["Expired"] = "Expired";
749
- SubscriptionStatus2["Cancelled"] = "Cancelled";
750
- return SubscriptionStatus2;
751
- })(SubscriptionStatus || {});
752
- var CycleLength = /* @__PURE__ */ ((CycleLength2) => {
753
- CycleLength2["Daily"] = "Daily";
754
- CycleLength2["Weekly"] = "Weekly";
755
- CycleLength2["Monthly"] = "Monthly";
756
- CycleLength2["Quarterly"] = "Quarterly";
757
- CycleLength2["Yearly"] = "Yearly";
758
- return CycleLength2;
759
- })(CycleLength || {});
760
-
761
- // src/subscriptions/schemas.ts
762
865
  var subscriptionContentSchema = import_zod9.z.discriminatedUnion("type", [
763
866
  import_zod9.z.object({
764
867
  type: import_zod9.z.literal("Product"),
@@ -873,9 +976,19 @@ var TrialEndpoints = class {
873
976
  };
874
977
 
875
978
  // src/vouchers/schemas.ts
979
+ var schemas_exports9 = {};
980
+ __export(schemas_exports9, {
981
+ createVoucherRequestSchema: () => createVoucherRequestSchema,
982
+ voucherCodeSchema: () => voucherCodeSchema,
983
+ voucherSchema: () => voucherSchema
984
+ });
876
985
  var import_zod11 = require("zod");
877
986
 
878
987
  // src/bundles/schemas.ts
988
+ var schemas_exports8 = {};
989
+ __export(schemas_exports8, {
990
+ bundleSchema: () => bundleSchema
991
+ });
879
992
  var import_zod10 = require("zod");
880
993
  var bundleSchema = import_zod10.z.object({
881
994
  id: import_zod10.z.string(),
@@ -942,6 +1055,67 @@ var VoucherEndpoints = class {
942
1055
  }
943
1056
  };
944
1057
 
1058
+ // src/schemas.ts
1059
+ var schemas_exports11 = {};
1060
+ __export(schemas_exports11, {
1061
+ activationRequests: () => schemas_exports5,
1062
+ bundles: () => schemas_exports8,
1063
+ coupons: () => schemas_exports10,
1064
+ customers: () => schemas_exports,
1065
+ dateTimeSpanSchema: () => dateTimeSpanSchema,
1066
+ discountSchema: () => discountSchema,
1067
+ entityChangeSchema: () => entityChangeSchema,
1068
+ licenses: () => schemas_exports2,
1069
+ moneySchema: () => moneySchema,
1070
+ orders: () => schemas_exports6,
1071
+ paged: () => paged,
1072
+ priceCollectionSchema: () => priceCollectionSchema,
1073
+ pricingDiscountSchema: () => pricingDiscountSchema,
1074
+ pricingVariationSchema: () => pricingVariationSchema,
1075
+ products: () => schemas_exports3,
1076
+ quantifiable: () => quantifiable,
1077
+ subscriptions: () => schemas_exports7,
1078
+ trials: () => schemas_exports4,
1079
+ userSchema: () => userSchema,
1080
+ vouchers: () => schemas_exports9
1081
+ });
1082
+
1083
+ // src/coupons/schemas.ts
1084
+ var schemas_exports10 = {};
1085
+ __export(schemas_exports10, {
1086
+ couponCodeSchema: () => couponCodeSchema,
1087
+ couponSchema: () => couponSchema,
1088
+ createCouponRequestSchema: () => createCouponRequestSchema
1089
+ });
1090
+ var import_zod12 = require("zod");
1091
+ var couponSchema = import_zod12.z.object({
1092
+ id: import_zod12.z.string(),
1093
+ name: import_zod12.z.string(),
1094
+ description: import_zod12.z.string(),
1095
+ numberOfCodes: import_zod12.z.number(),
1096
+ numberOfRedemptions: import_zod12.z.number(),
1097
+ combinable: import_zod12.z.boolean(),
1098
+ recurringPaymentUseCount: import_zod12.z.number().nullable(),
1099
+ discount: discountSchema,
1100
+ applicableProducts: productSchema.array(),
1101
+ applicableBundles: bundleSchema.array(),
1102
+ applicableProductVariations: import_zod12.z.record(import_zod12.z.string(), import_zod12.z.string().array()),
1103
+ applicableBundleVariations: import_zod12.z.record(import_zod12.z.string(), import_zod12.z.string().array()),
1104
+ isDeleted: import_zod12.z.boolean(),
1105
+ lastUpdated: entityChangeSchema,
1106
+ created: entityChangeSchema
1107
+ });
1108
+ var createCouponRequestSchema = import_zod12.z.object({
1109
+ name: import_zod12.z.string(),
1110
+ description: import_zod12.z.string(),
1111
+ applicableProducts: import_zod12.z.record(import_zod12.z.string(), import_zod12.z.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."),
1112
+ applicableBundles: import_zod12.z.record(import_zod12.z.string(), import_zod12.z.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.")
1113
+ });
1114
+ var couponCodeSchema = import_zod12.z.object({
1115
+ code: import_zod12.z.string(),
1116
+ numberOfRedemptions: import_zod12.z.number()
1117
+ });
1118
+
945
1119
  // src/index.ts
946
1120
  var MoonbaseClient = class {
947
1121
  constructor(configuration) {
@@ -977,5 +1151,6 @@ var MoonbaseClient = class {
977
1151
  ProductStatus,
978
1152
  SubscriptionStatus,
979
1153
  TrialStatus,
980
- objectToQuery
1154
+ objectToQuery,
1155
+ schemas
981
1156
  });