@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.cjs
CHANGED
|
@@ -34,6 +34,7 @@ __export(index_exports, {
|
|
|
34
34
|
ActivationRequestStatus: () => ActivationRequestStatus,
|
|
35
35
|
ActivationStatus: () => ActivationStatus,
|
|
36
36
|
ConflictError: () => ConflictError,
|
|
37
|
+
CycleLength: () => CycleLength,
|
|
37
38
|
LicenseStatus: () => LicenseStatus,
|
|
38
39
|
MoonbaseApi: () => MoonbaseApi,
|
|
39
40
|
MoonbaseClient: () => MoonbaseClient,
|
|
@@ -44,6 +45,7 @@ __export(index_exports, {
|
|
|
44
45
|
OrderStatus: () => OrderStatus,
|
|
45
46
|
Platform: () => Platform,
|
|
46
47
|
ProductStatus: () => ProductStatus,
|
|
48
|
+
SubscriptionStatus: () => SubscriptionStatus,
|
|
47
49
|
TrialStatus: () => TrialStatus,
|
|
48
50
|
objectToQuery: () => objectToQuery
|
|
49
51
|
});
|
|
@@ -233,6 +235,7 @@ var importLicenseRequestSchema = import_zod3.z.object({
|
|
|
233
235
|
productId: import_zod3.z.string(),
|
|
234
236
|
externalId: import_zod3.z.string().optional(),
|
|
235
237
|
createdAt: import_zod3.z.date().optional(),
|
|
238
|
+
expiresAt: import_zod3.z.date().optional(),
|
|
236
239
|
maxNumberOfActivations: import_zod3.z.number().optional(),
|
|
237
240
|
offlineActivationsAllowed: import_zod3.z.boolean().optional(),
|
|
238
241
|
activations: import_zod3.z.object({
|
|
@@ -735,6 +738,116 @@ var ProductEndpoints = class {
|
|
|
735
738
|
}
|
|
736
739
|
};
|
|
737
740
|
|
|
741
|
+
// src/subscriptions/schemas.ts
|
|
742
|
+
var import_zod9 = require("zod");
|
|
743
|
+
|
|
744
|
+
// src/subscriptions/models.ts
|
|
745
|
+
var SubscriptionStatus = /* @__PURE__ */ ((SubscriptionStatus2) => {
|
|
746
|
+
SubscriptionStatus2["Active"] = "Active";
|
|
747
|
+
SubscriptionStatus2["Expired"] = "Expired";
|
|
748
|
+
SubscriptionStatus2["Cancelled"] = "Cancelled";
|
|
749
|
+
return SubscriptionStatus2;
|
|
750
|
+
})(SubscriptionStatus || {});
|
|
751
|
+
var CycleLength = /* @__PURE__ */ ((CycleLength2) => {
|
|
752
|
+
CycleLength2["Daily"] = "Daily";
|
|
753
|
+
CycleLength2["Weekly"] = "Weekly";
|
|
754
|
+
CycleLength2["Monthly"] = "Monthly";
|
|
755
|
+
CycleLength2["Quarterly"] = "Quarterly";
|
|
756
|
+
CycleLength2["Yearly"] = "Yearly";
|
|
757
|
+
return CycleLength2;
|
|
758
|
+
})(CycleLength || {});
|
|
759
|
+
|
|
760
|
+
// src/subscriptions/schemas.ts
|
|
761
|
+
var subscriptionContentSchema = import_zod9.z.discriminatedUnion("type", [
|
|
762
|
+
import_zod9.z.object({
|
|
763
|
+
type: import_zod9.z.literal("Product"),
|
|
764
|
+
productId: import_zod9.z.string(),
|
|
765
|
+
quantity: import_zod9.z.number(),
|
|
766
|
+
fulfillment: lineItemFulfillmentSchema
|
|
767
|
+
}),
|
|
768
|
+
import_zod9.z.object({
|
|
769
|
+
type: import_zod9.z.literal("Bundle"),
|
|
770
|
+
bundleId: import_zod9.z.string(),
|
|
771
|
+
quantity: import_zod9.z.number(),
|
|
772
|
+
fulfillment: lineItemFulfillmentSchema
|
|
773
|
+
})
|
|
774
|
+
]);
|
|
775
|
+
var subscriptionSchema = import_zod9.z.object({
|
|
776
|
+
id: import_zod9.z.string(),
|
|
777
|
+
externalId: import_zod9.z.string().optional(),
|
|
778
|
+
ownerId: import_zod9.z.string(),
|
|
779
|
+
status: import_zod9.z.nativeEnum(SubscriptionStatus),
|
|
780
|
+
expiresAt: import_zod9.z.coerce.date(),
|
|
781
|
+
startedAt: import_zod9.z.coerce.date(),
|
|
782
|
+
licenseExpiry: import_zod9.z.coerce.date(),
|
|
783
|
+
renewedAt: import_zod9.z.coerce.date().nullable(),
|
|
784
|
+
nextPaymentScheduledAt: import_zod9.z.coerce.date().nullable(),
|
|
785
|
+
total: orderTotalSchema,
|
|
786
|
+
currency: import_zod9.z.string(),
|
|
787
|
+
cycleLength: import_zod9.z.nativeEnum(CycleLength),
|
|
788
|
+
currentCycle: import_zod9.z.number(),
|
|
789
|
+
content: subscriptionContentSchema,
|
|
790
|
+
pricingVariation: pricingVariationSchema,
|
|
791
|
+
lastUpdated: entityChangeSchema,
|
|
792
|
+
created: entityChangeSchema
|
|
793
|
+
});
|
|
794
|
+
var importSubscriptionLicenseSchema = import_zod9.z.object({
|
|
795
|
+
externalId: import_zod9.z.string().optional(),
|
|
796
|
+
createdAt: import_zod9.z.date().optional(),
|
|
797
|
+
maxNumberOfActivations: import_zod9.z.number().optional(),
|
|
798
|
+
offlineActivationsAllowed: import_zod9.z.boolean().optional(),
|
|
799
|
+
activations: import_zod9.z.object({
|
|
800
|
+
activationMethod: import_zod9.z.nativeEnum(ActivationMethod),
|
|
801
|
+
deviceName: import_zod9.z.string(),
|
|
802
|
+
deviceSignature: import_zod9.z.string(),
|
|
803
|
+
lastValidation: import_zod9.z.date().optional()
|
|
804
|
+
}).array().optional()
|
|
805
|
+
});
|
|
806
|
+
var importSubscriptionContentSchema = import_zod9.z.discriminatedUnion("type", [
|
|
807
|
+
import_zod9.z.object({
|
|
808
|
+
type: import_zod9.z.literal("Product"),
|
|
809
|
+
productId: import_zod9.z.string(),
|
|
810
|
+
variationId: import_zod9.z.string().optional(),
|
|
811
|
+
license: importSubscriptionLicenseSchema
|
|
812
|
+
}),
|
|
813
|
+
import_zod9.z.object({
|
|
814
|
+
type: import_zod9.z.literal("Bundle"),
|
|
815
|
+
bundleId: import_zod9.z.string(),
|
|
816
|
+
variationId: import_zod9.z.string().optional(),
|
|
817
|
+
licenses: import_zod9.z.record(import_zod9.z.string(), importSubscriptionLicenseSchema).optional()
|
|
818
|
+
})
|
|
819
|
+
]);
|
|
820
|
+
var importSubscriptionRequestSchema = import_zod9.z.object({
|
|
821
|
+
ownerId: import_zod9.z.string(),
|
|
822
|
+
externalId: import_zod9.z.string().optional(),
|
|
823
|
+
status: import_zod9.z.nativeEnum(SubscriptionStatus),
|
|
824
|
+
startedAt: import_zod9.z.date(),
|
|
825
|
+
expiresAt: import_zod9.z.date(),
|
|
826
|
+
currentCycle: import_zod9.z.number().optional(),
|
|
827
|
+
currency: import_zod9.z.string().optional(),
|
|
828
|
+
content: importSubscriptionContentSchema
|
|
829
|
+
});
|
|
830
|
+
|
|
831
|
+
// src/subscriptions/endpoints.ts
|
|
832
|
+
var SubscriptionEndpoints = class {
|
|
833
|
+
constructor(api) {
|
|
834
|
+
this.api = api;
|
|
835
|
+
}
|
|
836
|
+
async query(opts) {
|
|
837
|
+
const response = await this.api.fetch(`/api/subscriptions?${objectToQuery(opts)}`);
|
|
838
|
+
return paged(subscriptionSchema, this.api).parse(response.data);
|
|
839
|
+
}
|
|
840
|
+
async get(subscriptionId) {
|
|
841
|
+
const response = await this.api.fetch(`/api/subscriptions/${subscriptionId}`);
|
|
842
|
+
return subscriptionSchema.parse(response.data);
|
|
843
|
+
}
|
|
844
|
+
async import(subscription) {
|
|
845
|
+
const request = importSubscriptionRequestSchema.parse(subscription);
|
|
846
|
+
const response = await this.api.fetch(`/api/subscriptions/import`, "POST", request);
|
|
847
|
+
return subscriptionSchema.parse(response.data);
|
|
848
|
+
}
|
|
849
|
+
};
|
|
850
|
+
|
|
738
851
|
// src/trials/endpoints.ts
|
|
739
852
|
var TrialEndpoints = class {
|
|
740
853
|
constructor(api) {
|
|
@@ -760,43 +873,43 @@ var TrialEndpoints = class {
|
|
|
760
873
|
};
|
|
761
874
|
|
|
762
875
|
// src/vouchers/schemas.ts
|
|
763
|
-
var
|
|
876
|
+
var import_zod11 = require("zod");
|
|
764
877
|
|
|
765
878
|
// src/bundles/schemas.ts
|
|
766
|
-
var
|
|
767
|
-
var bundleSchema =
|
|
768
|
-
id:
|
|
769
|
-
name:
|
|
770
|
-
tagline:
|
|
771
|
-
description:
|
|
772
|
-
iconUrl:
|
|
773
|
-
purchasable:
|
|
774
|
-
partialPurchaseEnabled:
|
|
879
|
+
var import_zod10 = require("zod");
|
|
880
|
+
var bundleSchema = import_zod10.z.object({
|
|
881
|
+
id: import_zod10.z.string(),
|
|
882
|
+
name: import_zod10.z.string(),
|
|
883
|
+
tagline: import_zod10.z.string(),
|
|
884
|
+
description: import_zod10.z.string(),
|
|
885
|
+
iconUrl: import_zod10.z.string().nullable(),
|
|
886
|
+
purchasable: import_zod10.z.boolean(),
|
|
887
|
+
partialPurchaseEnabled: import_zod10.z.boolean()
|
|
775
888
|
});
|
|
776
889
|
|
|
777
890
|
// src/vouchers/schemas.ts
|
|
778
|
-
var voucherSchema =
|
|
779
|
-
id:
|
|
780
|
-
description:
|
|
781
|
-
numberOfCodes:
|
|
782
|
-
numberOfRedemptions:
|
|
891
|
+
var voucherSchema = import_zod11.z.object({
|
|
892
|
+
id: import_zod11.z.string(),
|
|
893
|
+
description: import_zod11.z.string(),
|
|
894
|
+
numberOfCodes: import_zod11.z.number(),
|
|
895
|
+
numberOfRedemptions: import_zod11.z.number(),
|
|
783
896
|
redeemsProducts: quantifiable(productSchema).array(),
|
|
784
897
|
redeemsBundles: quantifiable(bundleSchema).array(),
|
|
785
898
|
lastUpdated: entityChangeSchema,
|
|
786
899
|
created: entityChangeSchema
|
|
787
900
|
});
|
|
788
|
-
var createVoucherRequestSchema =
|
|
789
|
-
name:
|
|
790
|
-
description:
|
|
791
|
-
productEntitlements:
|
|
792
|
-
bundleEntitlements:
|
|
901
|
+
var createVoucherRequestSchema = import_zod11.z.object({
|
|
902
|
+
name: import_zod11.z.string(),
|
|
903
|
+
description: import_zod11.z.string(),
|
|
904
|
+
productEntitlements: import_zod11.z.record(import_zod11.z.string(), import_zod11.z.number()).optional(),
|
|
905
|
+
bundleEntitlements: import_zod11.z.record(import_zod11.z.string(), import_zod11.z.number()).optional()
|
|
793
906
|
});
|
|
794
|
-
var voucherCodeSchema =
|
|
795
|
-
voucherId:
|
|
796
|
-
code:
|
|
797
|
-
isRedeemed:
|
|
798
|
-
redeemedAt:
|
|
799
|
-
redeemedBy:
|
|
907
|
+
var voucherCodeSchema = import_zod11.z.object({
|
|
908
|
+
voucherId: import_zod11.z.string(),
|
|
909
|
+
code: import_zod11.z.string(),
|
|
910
|
+
isRedeemed: import_zod11.z.boolean(),
|
|
911
|
+
redeemedAt: import_zod11.z.coerce.date().nullable(),
|
|
912
|
+
redeemedBy: import_zod11.z.string().nullable()
|
|
800
913
|
});
|
|
801
914
|
|
|
802
915
|
// src/vouchers/endpoints.ts
|
|
@@ -838,6 +951,7 @@ var MoonbaseClient = class {
|
|
|
838
951
|
this.activationRequests = new ActivationRequestEndpoints(this.api);
|
|
839
952
|
this.customers = new CustomerEndpoints(this.api);
|
|
840
953
|
this.licenses = new LicenseEndpoints(this.api);
|
|
954
|
+
this.subscriptions = new SubscriptionEndpoints(this.api);
|
|
841
955
|
this.products = new ProductEndpoints(this.api);
|
|
842
956
|
this.trials = new TrialEndpoints(this.api);
|
|
843
957
|
this.vouchers = new VoucherEndpoints(this.api);
|
|
@@ -850,6 +964,7 @@ var MoonbaseClient = class {
|
|
|
850
964
|
ActivationRequestStatus,
|
|
851
965
|
ActivationStatus,
|
|
852
966
|
ConflictError,
|
|
967
|
+
CycleLength,
|
|
853
968
|
LicenseStatus,
|
|
854
969
|
MoonbaseApi,
|
|
855
970
|
MoonbaseClient,
|
|
@@ -860,6 +975,7 @@ var MoonbaseClient = class {
|
|
|
860
975
|
OrderStatus,
|
|
861
976
|
Platform,
|
|
862
977
|
ProductStatus,
|
|
978
|
+
SubscriptionStatus,
|
|
863
979
|
TrialStatus,
|
|
864
980
|
objectToQuery
|
|
865
981
|
});
|