@moonbase.sh/api 0.4.35 → 0.4.39
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 +142 -26
- package/dist/index.d.cts +1179 -191
- package/dist/index.d.ts +1179 -191
- package/dist/index.js +140 -26
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -182,6 +182,7 @@ var importLicenseRequestSchema = z3.object({
|
|
|
182
182
|
productId: z3.string(),
|
|
183
183
|
externalId: z3.string().optional(),
|
|
184
184
|
createdAt: z3.date().optional(),
|
|
185
|
+
expiresAt: z3.date().optional(),
|
|
185
186
|
maxNumberOfActivations: z3.number().optional(),
|
|
186
187
|
offlineActivationsAllowed: z3.boolean().optional(),
|
|
187
188
|
activations: z3.object({
|
|
@@ -684,6 +685,116 @@ var ProductEndpoints = class {
|
|
|
684
685
|
}
|
|
685
686
|
};
|
|
686
687
|
|
|
688
|
+
// src/subscriptions/schemas.ts
|
|
689
|
+
import { z as z9 } from "zod";
|
|
690
|
+
|
|
691
|
+
// src/subscriptions/models.ts
|
|
692
|
+
var SubscriptionStatus = /* @__PURE__ */ ((SubscriptionStatus2) => {
|
|
693
|
+
SubscriptionStatus2["Active"] = "Active";
|
|
694
|
+
SubscriptionStatus2["Expired"] = "Expired";
|
|
695
|
+
SubscriptionStatus2["Cancelled"] = "Cancelled";
|
|
696
|
+
return SubscriptionStatus2;
|
|
697
|
+
})(SubscriptionStatus || {});
|
|
698
|
+
var CycleLength = /* @__PURE__ */ ((CycleLength2) => {
|
|
699
|
+
CycleLength2["Daily"] = "Daily";
|
|
700
|
+
CycleLength2["Weekly"] = "Weekly";
|
|
701
|
+
CycleLength2["Monthly"] = "Monthly";
|
|
702
|
+
CycleLength2["Quarterly"] = "Quarterly";
|
|
703
|
+
CycleLength2["Yearly"] = "Yearly";
|
|
704
|
+
return CycleLength2;
|
|
705
|
+
})(CycleLength || {});
|
|
706
|
+
|
|
707
|
+
// src/subscriptions/schemas.ts
|
|
708
|
+
var subscriptionContentSchema = z9.discriminatedUnion("type", [
|
|
709
|
+
z9.object({
|
|
710
|
+
type: z9.literal("Product"),
|
|
711
|
+
productId: z9.string(),
|
|
712
|
+
quantity: z9.number(),
|
|
713
|
+
fulfillment: lineItemFulfillmentSchema
|
|
714
|
+
}),
|
|
715
|
+
z9.object({
|
|
716
|
+
type: z9.literal("Bundle"),
|
|
717
|
+
bundleId: z9.string(),
|
|
718
|
+
quantity: z9.number(),
|
|
719
|
+
fulfillment: lineItemFulfillmentSchema
|
|
720
|
+
})
|
|
721
|
+
]);
|
|
722
|
+
var subscriptionSchema = z9.object({
|
|
723
|
+
id: z9.string(),
|
|
724
|
+
externalId: z9.string().optional(),
|
|
725
|
+
ownerId: z9.string(),
|
|
726
|
+
status: z9.nativeEnum(SubscriptionStatus),
|
|
727
|
+
expiresAt: z9.coerce.date(),
|
|
728
|
+
startedAt: z9.coerce.date(),
|
|
729
|
+
licenseExpiry: z9.coerce.date(),
|
|
730
|
+
renewedAt: z9.coerce.date().nullable(),
|
|
731
|
+
nextPaymentScheduledAt: z9.coerce.date().nullable(),
|
|
732
|
+
total: orderTotalSchema,
|
|
733
|
+
currency: z9.string(),
|
|
734
|
+
cycleLength: z9.nativeEnum(CycleLength),
|
|
735
|
+
currentCycle: z9.number(),
|
|
736
|
+
content: subscriptionContentSchema,
|
|
737
|
+
pricingVariation: pricingVariationSchema,
|
|
738
|
+
lastUpdated: entityChangeSchema,
|
|
739
|
+
created: entityChangeSchema
|
|
740
|
+
});
|
|
741
|
+
var importSubscriptionLicenseSchema = z9.object({
|
|
742
|
+
externalId: z9.string().optional(),
|
|
743
|
+
createdAt: z9.date().optional(),
|
|
744
|
+
maxNumberOfActivations: z9.number().optional(),
|
|
745
|
+
offlineActivationsAllowed: z9.boolean().optional(),
|
|
746
|
+
activations: z9.object({
|
|
747
|
+
activationMethod: z9.nativeEnum(ActivationMethod),
|
|
748
|
+
deviceName: z9.string(),
|
|
749
|
+
deviceSignature: z9.string(),
|
|
750
|
+
lastValidation: z9.date().optional()
|
|
751
|
+
}).array().optional()
|
|
752
|
+
});
|
|
753
|
+
var importSubscriptionContentSchema = z9.discriminatedUnion("type", [
|
|
754
|
+
z9.object({
|
|
755
|
+
type: z9.literal("Product"),
|
|
756
|
+
productId: z9.string(),
|
|
757
|
+
variationId: z9.string().optional(),
|
|
758
|
+
license: importSubscriptionLicenseSchema
|
|
759
|
+
}),
|
|
760
|
+
z9.object({
|
|
761
|
+
type: z9.literal("Bundle"),
|
|
762
|
+
bundleId: z9.string(),
|
|
763
|
+
variationId: z9.string().optional(),
|
|
764
|
+
licenses: z9.record(z9.string(), importSubscriptionLicenseSchema).optional()
|
|
765
|
+
})
|
|
766
|
+
]);
|
|
767
|
+
var importSubscriptionRequestSchema = z9.object({
|
|
768
|
+
ownerId: z9.string(),
|
|
769
|
+
externalId: z9.string().optional(),
|
|
770
|
+
status: z9.nativeEnum(SubscriptionStatus),
|
|
771
|
+
startedAt: z9.date(),
|
|
772
|
+
expiresAt: z9.date(),
|
|
773
|
+
currentCycle: z9.number().optional(),
|
|
774
|
+
currency: z9.string().optional(),
|
|
775
|
+
content: importSubscriptionContentSchema
|
|
776
|
+
});
|
|
777
|
+
|
|
778
|
+
// src/subscriptions/endpoints.ts
|
|
779
|
+
var SubscriptionEndpoints = class {
|
|
780
|
+
constructor(api) {
|
|
781
|
+
this.api = api;
|
|
782
|
+
}
|
|
783
|
+
async query(opts) {
|
|
784
|
+
const response = await this.api.fetch(`/api/subscriptions?${objectToQuery(opts)}`);
|
|
785
|
+
return paged(subscriptionSchema, this.api).parse(response.data);
|
|
786
|
+
}
|
|
787
|
+
async get(subscriptionId) {
|
|
788
|
+
const response = await this.api.fetch(`/api/subscriptions/${subscriptionId}`);
|
|
789
|
+
return subscriptionSchema.parse(response.data);
|
|
790
|
+
}
|
|
791
|
+
async import(subscription) {
|
|
792
|
+
const request = importSubscriptionRequestSchema.parse(subscription);
|
|
793
|
+
const response = await this.api.fetch(`/api/subscriptions/import`, "POST", request);
|
|
794
|
+
return subscriptionSchema.parse(response.data);
|
|
795
|
+
}
|
|
796
|
+
};
|
|
797
|
+
|
|
687
798
|
// src/trials/endpoints.ts
|
|
688
799
|
var TrialEndpoints = class {
|
|
689
800
|
constructor(api) {
|
|
@@ -709,43 +820,43 @@ var TrialEndpoints = class {
|
|
|
709
820
|
};
|
|
710
821
|
|
|
711
822
|
// src/vouchers/schemas.ts
|
|
712
|
-
import { z as
|
|
823
|
+
import { z as z11 } from "zod";
|
|
713
824
|
|
|
714
825
|
// src/bundles/schemas.ts
|
|
715
|
-
import { z as
|
|
716
|
-
var bundleSchema =
|
|
717
|
-
id:
|
|
718
|
-
name:
|
|
719
|
-
tagline:
|
|
720
|
-
description:
|
|
721
|
-
iconUrl:
|
|
722
|
-
purchasable:
|
|
723
|
-
partialPurchaseEnabled:
|
|
826
|
+
import { z as z10 } from "zod";
|
|
827
|
+
var bundleSchema = z10.object({
|
|
828
|
+
id: z10.string(),
|
|
829
|
+
name: z10.string(),
|
|
830
|
+
tagline: z10.string(),
|
|
831
|
+
description: z10.string(),
|
|
832
|
+
iconUrl: z10.string().nullable(),
|
|
833
|
+
purchasable: z10.boolean(),
|
|
834
|
+
partialPurchaseEnabled: z10.boolean()
|
|
724
835
|
});
|
|
725
836
|
|
|
726
837
|
// src/vouchers/schemas.ts
|
|
727
|
-
var voucherSchema =
|
|
728
|
-
id:
|
|
729
|
-
description:
|
|
730
|
-
numberOfCodes:
|
|
731
|
-
numberOfRedemptions:
|
|
838
|
+
var voucherSchema = z11.object({
|
|
839
|
+
id: z11.string(),
|
|
840
|
+
description: z11.string(),
|
|
841
|
+
numberOfCodes: z11.number(),
|
|
842
|
+
numberOfRedemptions: z11.number(),
|
|
732
843
|
redeemsProducts: quantifiable(productSchema).array(),
|
|
733
844
|
redeemsBundles: quantifiable(bundleSchema).array(),
|
|
734
845
|
lastUpdated: entityChangeSchema,
|
|
735
846
|
created: entityChangeSchema
|
|
736
847
|
});
|
|
737
|
-
var createVoucherRequestSchema =
|
|
738
|
-
name:
|
|
739
|
-
description:
|
|
740
|
-
productEntitlements:
|
|
741
|
-
bundleEntitlements:
|
|
848
|
+
var createVoucherRequestSchema = z11.object({
|
|
849
|
+
name: z11.string(),
|
|
850
|
+
description: z11.string(),
|
|
851
|
+
productEntitlements: z11.record(z11.string(), z11.number()).optional(),
|
|
852
|
+
bundleEntitlements: z11.record(z11.string(), z11.number()).optional()
|
|
742
853
|
});
|
|
743
|
-
var voucherCodeSchema =
|
|
744
|
-
voucherId:
|
|
745
|
-
code:
|
|
746
|
-
isRedeemed:
|
|
747
|
-
redeemedAt:
|
|
748
|
-
redeemedBy:
|
|
854
|
+
var voucherCodeSchema = z11.object({
|
|
855
|
+
voucherId: z11.string(),
|
|
856
|
+
code: z11.string(),
|
|
857
|
+
isRedeemed: z11.boolean(),
|
|
858
|
+
redeemedAt: z11.coerce.date().nullable(),
|
|
859
|
+
redeemedBy: z11.string().nullable()
|
|
749
860
|
});
|
|
750
861
|
|
|
751
862
|
// src/vouchers/endpoints.ts
|
|
@@ -787,6 +898,7 @@ var MoonbaseClient = class {
|
|
|
787
898
|
this.activationRequests = new ActivationRequestEndpoints(this.api);
|
|
788
899
|
this.customers = new CustomerEndpoints(this.api);
|
|
789
900
|
this.licenses = new LicenseEndpoints(this.api);
|
|
901
|
+
this.subscriptions = new SubscriptionEndpoints(this.api);
|
|
790
902
|
this.products = new ProductEndpoints(this.api);
|
|
791
903
|
this.trials = new TrialEndpoints(this.api);
|
|
792
904
|
this.vouchers = new VoucherEndpoints(this.api);
|
|
@@ -798,6 +910,7 @@ export {
|
|
|
798
910
|
ActivationRequestStatus,
|
|
799
911
|
ActivationStatus,
|
|
800
912
|
ConflictError,
|
|
913
|
+
CycleLength,
|
|
801
914
|
LicenseStatus,
|
|
802
915
|
MoonbaseApi,
|
|
803
916
|
MoonbaseClient,
|
|
@@ -808,6 +921,7 @@ export {
|
|
|
808
921
|
OrderStatus,
|
|
809
922
|
Platform,
|
|
810
923
|
ProductStatus,
|
|
924
|
+
SubscriptionStatus,
|
|
811
925
|
TrialStatus,
|
|
812
926
|
objectToQuery
|
|
813
927
|
};
|
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.39",
|
|
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",
|