@moonbase.sh/storefront-api 0.3.4 → 0.3.5
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 +102 -29
- package/dist/index.d.cts +3935 -905
- package/dist/index.d.ts +3935 -905
- package/dist/index.js +101 -29
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -43,6 +43,7 @@ __export(index_exports, {
|
|
|
43
43
|
NotFoundError: () => NotFoundError,
|
|
44
44
|
OrderStatus: () => OrderStatus,
|
|
45
45
|
Platform: () => Platform,
|
|
46
|
+
SubscriptionStatus: () => SubscriptionStatus,
|
|
46
47
|
TokenStore: () => TokenStore,
|
|
47
48
|
schemas: () => schemas_exports3,
|
|
48
49
|
utmToObject: () => utmToObject
|
|
@@ -101,6 +102,10 @@ var flatAmountOffDiscountSchema = import_zod.z.object({
|
|
|
101
102
|
total: priceCollectionSchema.optional(),
|
|
102
103
|
isExclusive: import_zod.z.boolean()
|
|
103
104
|
});
|
|
105
|
+
var moneySchema = import_zod.z.object({
|
|
106
|
+
currency: import_zod.z.string(),
|
|
107
|
+
amount: import_zod.z.number()
|
|
108
|
+
});
|
|
104
109
|
var discountSchema = import_zod.z.discriminatedUnion("type", [
|
|
105
110
|
percentageOffDiscountSchema,
|
|
106
111
|
flatAmountOffDiscountSchema
|
|
@@ -121,8 +126,7 @@ var pricingVariationSchema = import_zod.z.object({
|
|
|
121
126
|
price: priceCollectionSchema,
|
|
122
127
|
hasDiscount: import_zod.z.boolean(),
|
|
123
128
|
discount: discountSchema.optional(),
|
|
124
|
-
|
|
125
|
-
recurrence: recurrenceSchema.default({ type: "OneOff" }),
|
|
129
|
+
recurrence: recurrenceSchema,
|
|
126
130
|
pricingTiers: import_zod.z.array(pricingTierSchema).nullish()
|
|
127
131
|
});
|
|
128
132
|
function paged(itemSchema) {
|
|
@@ -179,6 +183,7 @@ var productSummarySchema = import_zod2.z.object({
|
|
|
179
183
|
currentActivations: import_zod2.z.number().optional(),
|
|
180
184
|
maxActivations: import_zod2.z.number().optional(),
|
|
181
185
|
externalLicenses: import_zod2.z.number().optional(),
|
|
186
|
+
subscriptionLicenses: import_zod2.z.number().optional(),
|
|
182
187
|
currentVersion: import_zod2.z.string().nullable(),
|
|
183
188
|
version: import_zod2.z.string().optional(),
|
|
184
189
|
prerelease: import_zod2.z.boolean().optional(),
|
|
@@ -393,7 +398,10 @@ var userSchema = import_zod7.z.object({
|
|
|
393
398
|
tenantId: import_zod7.z.string(),
|
|
394
399
|
address: addressSchema.optional(),
|
|
395
400
|
communicationPreferences: communicationPreferencesSchema,
|
|
396
|
-
ownedProducts: import_zod7.z.string().array().optional()
|
|
401
|
+
ownedProducts: import_zod7.z.string().array().optional(),
|
|
402
|
+
subscribedProducts: import_zod7.z.string().array().optional(),
|
|
403
|
+
hasProducts: import_zod7.z.boolean().nullish(),
|
|
404
|
+
hasSubscriptions: import_zod7.z.boolean().nullish()
|
|
397
405
|
});
|
|
398
406
|
var identityUserSchema = userSchema.and(import_zod7.z.object({
|
|
399
407
|
accessToken: import_zod7.z.string(),
|
|
@@ -542,6 +550,7 @@ var licenseSchema = import_zod8.z.object({
|
|
|
542
550
|
activeNumberOfActivations: import_zod8.z.number(),
|
|
543
551
|
maxNumberOfActivations: import_zod8.z.number(),
|
|
544
552
|
externalFulfillment: import_zod8.z.string().optional(),
|
|
553
|
+
expiresAt: import_zod8.z.coerce.date().optional(),
|
|
545
554
|
createdAt: import_zod8.z.coerce.date()
|
|
546
555
|
});
|
|
547
556
|
var activationSchema = import_zod8.z.object({
|
|
@@ -628,14 +637,19 @@ var ProductEndpoints = class {
|
|
|
628
637
|
}
|
|
629
638
|
};
|
|
630
639
|
|
|
631
|
-
// src/inventory/
|
|
632
|
-
var
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
640
|
+
// src/inventory/subscriptions/endpoints.ts
|
|
641
|
+
var import_zod13 = require("zod");
|
|
642
|
+
|
|
643
|
+
// src/inventory/subscriptions/schemas.ts
|
|
644
|
+
var import_zod12 = require("zod");
|
|
645
|
+
|
|
646
|
+
// src/inventory/subscriptions/models.ts
|
|
647
|
+
var SubscriptionStatus = /* @__PURE__ */ ((SubscriptionStatus2) => {
|
|
648
|
+
SubscriptionStatus2["Active"] = "Active";
|
|
649
|
+
SubscriptionStatus2["Expired"] = "Expired";
|
|
650
|
+
SubscriptionStatus2["Cancelled"] = "Cancelled";
|
|
651
|
+
return SubscriptionStatus2;
|
|
652
|
+
})(SubscriptionStatus || {});
|
|
639
653
|
|
|
640
654
|
// src/orders/schemas.ts
|
|
641
655
|
var schemas_exports2 = {};
|
|
@@ -645,7 +659,8 @@ __export(schemas_exports2, {
|
|
|
645
659
|
openOrderLineItem: () => openOrderLineItem,
|
|
646
660
|
openOrderSchema: () => openOrderSchema,
|
|
647
661
|
openProductLineItem: () => openProductLineItem,
|
|
648
|
-
orderSchema: () => orderSchema
|
|
662
|
+
orderSchema: () => orderSchema,
|
|
663
|
+
orderTotalSchema: () => orderTotalSchema
|
|
649
664
|
});
|
|
650
665
|
var import_zod11 = require("zod");
|
|
651
666
|
|
|
@@ -719,10 +734,6 @@ var openOrderSchema = import_zod11.z.object({
|
|
|
719
734
|
checkoutUrl: import_zod11.z.string().optional(),
|
|
720
735
|
embeddedCheckoutUrl: import_zod11.z.string().optional()
|
|
721
736
|
});
|
|
722
|
-
var moneySchema = import_zod11.z.object({
|
|
723
|
-
currency: import_zod11.z.string(),
|
|
724
|
-
amount: import_zod11.z.number()
|
|
725
|
-
});
|
|
726
737
|
var orderTotalSchema = import_zod11.z.object({
|
|
727
738
|
original: moneySchema,
|
|
728
739
|
discount: moneySchema,
|
|
@@ -762,6 +773,66 @@ var orderSchema = import_zod11.z.discriminatedUnion("status", [
|
|
|
762
773
|
completedOrderSchema
|
|
763
774
|
]);
|
|
764
775
|
|
|
776
|
+
// src/inventory/subscriptions/schemas.ts
|
|
777
|
+
var subscriptionSchema = import_zod12.z.object({
|
|
778
|
+
id: import_zod12.z.string(),
|
|
779
|
+
status: import_zod12.z.nativeEnum(SubscriptionStatus),
|
|
780
|
+
hasPaymentMethod: import_zod12.z.boolean(),
|
|
781
|
+
expiresAt: import_zod12.z.coerce.date(),
|
|
782
|
+
renewedAt: import_zod12.z.coerce.date().nullable(),
|
|
783
|
+
startedAt: import_zod12.z.coerce.date(),
|
|
784
|
+
total: orderTotalSchema,
|
|
785
|
+
cycleLength: import_zod12.z.nativeEnum(CycleLength),
|
|
786
|
+
content: import_zod12.z.discriminatedUnion("type", [
|
|
787
|
+
import_zod12.z.object({
|
|
788
|
+
type: import_zod12.z.literal("Product"),
|
|
789
|
+
quantity: import_zod12.z.number(),
|
|
790
|
+
product: storefrontProductSchema
|
|
791
|
+
}),
|
|
792
|
+
import_zod12.z.object({
|
|
793
|
+
type: import_zod12.z.literal("Bundle"),
|
|
794
|
+
quantity: import_zod12.z.number(),
|
|
795
|
+
bundle: storefrontBundleSchema
|
|
796
|
+
})
|
|
797
|
+
])
|
|
798
|
+
});
|
|
799
|
+
|
|
800
|
+
// src/inventory/subscriptions/endpoints.ts
|
|
801
|
+
var SubscriptionEndpoints = class {
|
|
802
|
+
constructor(api, configuration) {
|
|
803
|
+
this.api = api;
|
|
804
|
+
this.configuration = configuration;
|
|
805
|
+
}
|
|
806
|
+
async get(nextUrl) {
|
|
807
|
+
const response = await this.api.authenticatedFetch(nextUrl || "/api/customer/inventory/subscriptions", paged(subscriptionSchema));
|
|
808
|
+
return response.data;
|
|
809
|
+
}
|
|
810
|
+
async getById(subscriptionId) {
|
|
811
|
+
const response = await this.api.authenticatedFetch(`/api/customer/inventory/subscriptions/${subscriptionId}`, subscriptionSchema);
|
|
812
|
+
return response.data;
|
|
813
|
+
}
|
|
814
|
+
async cancel(subscriptionId) {
|
|
815
|
+
const response = await this.api.authenticatedFetch(`/api/customer/inventory/subscriptions/${subscriptionId}/cancel`, subscriptionSchema, { method: "POST" });
|
|
816
|
+
return response.data;
|
|
817
|
+
}
|
|
818
|
+
async renew(subscriptionId, returnUrl, embedded) {
|
|
819
|
+
const response = await this.api.authenticatedFetch(`/api/customer/inventory/subscriptions/${subscriptionId}/renew?redirect=false&return=${returnUrl}&embedded=${embedded ? "true" : "false"}`, import_zod13.z.object({
|
|
820
|
+
location: import_zod13.z.string()
|
|
821
|
+
}), { method: "POST" });
|
|
822
|
+
return response.data;
|
|
823
|
+
}
|
|
824
|
+
};
|
|
825
|
+
|
|
826
|
+
// src/inventory/index.ts
|
|
827
|
+
var InventoryEndpoints = class {
|
|
828
|
+
constructor(api, configuration) {
|
|
829
|
+
this.licenses = new LicenseEndpoints(api, configuration);
|
|
830
|
+
this.products = new ProductEndpoints(api, configuration);
|
|
831
|
+
this.activation = new ActivationEndpoints(api, configuration);
|
|
832
|
+
this.subscriptions = new SubscriptionEndpoints(api, configuration);
|
|
833
|
+
}
|
|
834
|
+
};
|
|
835
|
+
|
|
765
836
|
// src/orders/endpoints.ts
|
|
766
837
|
var OrderEndpoints = class {
|
|
767
838
|
constructor(api) {
|
|
@@ -844,7 +915,8 @@ var MoonbaseApi = class {
|
|
|
844
915
|
"x-mb-cors": "1"
|
|
845
916
|
},
|
|
846
917
|
body: (options == null ? void 0 : options.body) ? contentType !== "application/json" ? options.body : JSON.stringify(options.body) : void 0,
|
|
847
|
-
signal: options == null ? void 0 : options.abort
|
|
918
|
+
signal: options == null ? void 0 : options.abort,
|
|
919
|
+
redirect: "manual"
|
|
848
920
|
});
|
|
849
921
|
if (response.status >= 400)
|
|
850
922
|
await handleResponseProblem(response);
|
|
@@ -973,11 +1045,11 @@ _TokenStore.storageKey = "moonbase_auth";
|
|
|
973
1045
|
var TokenStore = _TokenStore;
|
|
974
1046
|
|
|
975
1047
|
// src/vendor/schemas.ts
|
|
976
|
-
var
|
|
977
|
-
var vendorSchema =
|
|
978
|
-
id:
|
|
979
|
-
name:
|
|
980
|
-
logoUrl:
|
|
1048
|
+
var import_zod14 = require("zod");
|
|
1049
|
+
var vendorSchema = import_zod14.z.object({
|
|
1050
|
+
id: import_zod14.z.string(),
|
|
1051
|
+
name: import_zod14.z.string(),
|
|
1052
|
+
logoUrl: import_zod14.z.string().nullable()
|
|
981
1053
|
});
|
|
982
1054
|
|
|
983
1055
|
// src/vendor/endpoints.ts
|
|
@@ -992,13 +1064,13 @@ var VendorEndpoints = class {
|
|
|
992
1064
|
};
|
|
993
1065
|
|
|
994
1066
|
// src/vouchers/schemas.ts
|
|
995
|
-
var
|
|
996
|
-
var voucherSchema =
|
|
997
|
-
id:
|
|
998
|
-
name:
|
|
999
|
-
description:
|
|
1000
|
-
code:
|
|
1001
|
-
redeemed:
|
|
1067
|
+
var import_zod15 = require("zod");
|
|
1068
|
+
var voucherSchema = import_zod15.z.object({
|
|
1069
|
+
id: import_zod15.z.string(),
|
|
1070
|
+
name: import_zod15.z.string(),
|
|
1071
|
+
description: import_zod15.z.string(),
|
|
1072
|
+
code: import_zod15.z.string(),
|
|
1073
|
+
redeemed: import_zod15.z.boolean(),
|
|
1002
1074
|
redeemsProducts: quantifiable(storefrontProductSchema).array(),
|
|
1003
1075
|
redeemsBundles: quantifiable(storefrontBundleSchema).array()
|
|
1004
1076
|
});
|
|
@@ -1062,6 +1134,7 @@ var MoonbaseClient = class {
|
|
|
1062
1134
|
NotFoundError,
|
|
1063
1135
|
OrderStatus,
|
|
1064
1136
|
Platform,
|
|
1137
|
+
SubscriptionStatus,
|
|
1065
1138
|
TokenStore,
|
|
1066
1139
|
schemas,
|
|
1067
1140
|
utmToObject
|