@moonbase.sh/storefront-api 0.3.3 → 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 +119 -35
- package/dist/index.d.cts +3943 -904
- package/dist/index.d.ts +3943 -904
- package/dist/index.js +117 -35
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -43,7 +43,9 @@ __export(index_exports, {
|
|
|
43
43
|
NotFoundError: () => NotFoundError,
|
|
44
44
|
OrderStatus: () => OrderStatus,
|
|
45
45
|
Platform: () => Platform,
|
|
46
|
-
|
|
46
|
+
SubscriptionStatus: () => SubscriptionStatus,
|
|
47
|
+
TokenStore: () => TokenStore,
|
|
48
|
+
schemas: () => schemas_exports3,
|
|
47
49
|
utmToObject: () => utmToObject
|
|
48
50
|
});
|
|
49
51
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -100,6 +102,10 @@ var flatAmountOffDiscountSchema = import_zod.z.object({
|
|
|
100
102
|
total: priceCollectionSchema.optional(),
|
|
101
103
|
isExclusive: import_zod.z.boolean()
|
|
102
104
|
});
|
|
105
|
+
var moneySchema = import_zod.z.object({
|
|
106
|
+
currency: import_zod.z.string(),
|
|
107
|
+
amount: import_zod.z.number()
|
|
108
|
+
});
|
|
103
109
|
var discountSchema = import_zod.z.discriminatedUnion("type", [
|
|
104
110
|
percentageOffDiscountSchema,
|
|
105
111
|
flatAmountOffDiscountSchema
|
|
@@ -120,8 +126,7 @@ var pricingVariationSchema = import_zod.z.object({
|
|
|
120
126
|
price: priceCollectionSchema,
|
|
121
127
|
hasDiscount: import_zod.z.boolean(),
|
|
122
128
|
discount: discountSchema.optional(),
|
|
123
|
-
|
|
124
|
-
recurrence: recurrenceSchema.default({ type: "OneOff" }),
|
|
129
|
+
recurrence: recurrenceSchema,
|
|
125
130
|
pricingTiers: import_zod.z.array(pricingTierSchema).nullish()
|
|
126
131
|
});
|
|
127
132
|
function paged(itemSchema) {
|
|
@@ -178,6 +183,7 @@ var productSummarySchema = import_zod2.z.object({
|
|
|
178
183
|
currentActivations: import_zod2.z.number().optional(),
|
|
179
184
|
maxActivations: import_zod2.z.number().optional(),
|
|
180
185
|
externalLicenses: import_zod2.z.number().optional(),
|
|
186
|
+
subscriptionLicenses: import_zod2.z.number().optional(),
|
|
181
187
|
currentVersion: import_zod2.z.string().nullable(),
|
|
182
188
|
version: import_zod2.z.string().optional(),
|
|
183
189
|
prerelease: import_zod2.z.boolean().optional(),
|
|
@@ -364,6 +370,14 @@ async function handleResponseProblem(response) {
|
|
|
364
370
|
}
|
|
365
371
|
|
|
366
372
|
// src/identity/schemas.ts
|
|
373
|
+
var schemas_exports = {};
|
|
374
|
+
__export(schemas_exports, {
|
|
375
|
+
addressSchema: () => addressSchema,
|
|
376
|
+
communicationPreferencesSchema: () => communicationPreferencesSchema,
|
|
377
|
+
identityUserSchema: () => identityUserSchema,
|
|
378
|
+
userAccountConfirmedSchema: () => userAccountConfirmedSchema,
|
|
379
|
+
userSchema: () => userSchema
|
|
380
|
+
});
|
|
367
381
|
var import_zod7 = require("zod");
|
|
368
382
|
var addressSchema = import_zod7.z.object({
|
|
369
383
|
countryCode: import_zod7.z.string(),
|
|
@@ -384,7 +398,10 @@ var userSchema = import_zod7.z.object({
|
|
|
384
398
|
tenantId: import_zod7.z.string(),
|
|
385
399
|
address: addressSchema.optional(),
|
|
386
400
|
communicationPreferences: communicationPreferencesSchema,
|
|
387
|
-
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()
|
|
388
405
|
});
|
|
389
406
|
var identityUserSchema = userSchema.and(import_zod7.z.object({
|
|
390
407
|
accessToken: import_zod7.z.string(),
|
|
@@ -533,6 +550,7 @@ var licenseSchema = import_zod8.z.object({
|
|
|
533
550
|
activeNumberOfActivations: import_zod8.z.number(),
|
|
534
551
|
maxNumberOfActivations: import_zod8.z.number(),
|
|
535
552
|
externalFulfillment: import_zod8.z.string().optional(),
|
|
553
|
+
expiresAt: import_zod8.z.coerce.date().optional(),
|
|
536
554
|
createdAt: import_zod8.z.coerce.date()
|
|
537
555
|
});
|
|
538
556
|
var activationSchema = import_zod8.z.object({
|
|
@@ -619,24 +637,30 @@ var ProductEndpoints = class {
|
|
|
619
637
|
}
|
|
620
638
|
};
|
|
621
639
|
|
|
622
|
-
// src/inventory/
|
|
623
|
-
var
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
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 || {});
|
|
630
653
|
|
|
631
654
|
// src/orders/schemas.ts
|
|
632
|
-
var
|
|
633
|
-
__export(
|
|
655
|
+
var schemas_exports2 = {};
|
|
656
|
+
__export(schemas_exports2, {
|
|
634
657
|
completedOrderSchema: () => completedOrderSchema,
|
|
635
658
|
openBundleLineItem: () => openBundleLineItem,
|
|
636
659
|
openOrderLineItem: () => openOrderLineItem,
|
|
637
660
|
openOrderSchema: () => openOrderSchema,
|
|
638
661
|
openProductLineItem: () => openProductLineItem,
|
|
639
|
-
orderSchema: () => orderSchema
|
|
662
|
+
orderSchema: () => orderSchema,
|
|
663
|
+
orderTotalSchema: () => orderTotalSchema
|
|
640
664
|
});
|
|
641
665
|
var import_zod11 = require("zod");
|
|
642
666
|
|
|
@@ -710,10 +734,6 @@ var openOrderSchema = import_zod11.z.object({
|
|
|
710
734
|
checkoutUrl: import_zod11.z.string().optional(),
|
|
711
735
|
embeddedCheckoutUrl: import_zod11.z.string().optional()
|
|
712
736
|
});
|
|
713
|
-
var moneySchema = import_zod11.z.object({
|
|
714
|
-
currency: import_zod11.z.string(),
|
|
715
|
-
amount: import_zod11.z.number()
|
|
716
|
-
});
|
|
717
737
|
var orderTotalSchema = import_zod11.z.object({
|
|
718
738
|
original: moneySchema,
|
|
719
739
|
discount: moneySchema,
|
|
@@ -753,6 +773,66 @@ var orderSchema = import_zod11.z.discriminatedUnion("status", [
|
|
|
753
773
|
completedOrderSchema
|
|
754
774
|
]);
|
|
755
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
|
+
|
|
756
836
|
// src/orders/endpoints.ts
|
|
757
837
|
var OrderEndpoints = class {
|
|
758
838
|
constructor(api) {
|
|
@@ -835,7 +915,8 @@ var MoonbaseApi = class {
|
|
|
835
915
|
"x-mb-cors": "1"
|
|
836
916
|
},
|
|
837
917
|
body: (options == null ? void 0 : options.body) ? contentType !== "application/json" ? options.body : JSON.stringify(options.body) : void 0,
|
|
838
|
-
signal: options == null ? void 0 : options.abort
|
|
918
|
+
signal: options == null ? void 0 : options.abort,
|
|
919
|
+
redirect: "manual"
|
|
839
920
|
});
|
|
840
921
|
if (response.status >= 400)
|
|
841
922
|
await handleResponseProblem(response);
|
|
@@ -964,11 +1045,11 @@ _TokenStore.storageKey = "moonbase_auth";
|
|
|
964
1045
|
var TokenStore = _TokenStore;
|
|
965
1046
|
|
|
966
1047
|
// src/vendor/schemas.ts
|
|
967
|
-
var
|
|
968
|
-
var vendorSchema =
|
|
969
|
-
id:
|
|
970
|
-
name:
|
|
971
|
-
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()
|
|
972
1053
|
});
|
|
973
1054
|
|
|
974
1055
|
// src/vendor/endpoints.ts
|
|
@@ -983,13 +1064,13 @@ var VendorEndpoints = class {
|
|
|
983
1064
|
};
|
|
984
1065
|
|
|
985
1066
|
// src/vouchers/schemas.ts
|
|
986
|
-
var
|
|
987
|
-
var voucherSchema =
|
|
988
|
-
id:
|
|
989
|
-
name:
|
|
990
|
-
description:
|
|
991
|
-
code:
|
|
992
|
-
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(),
|
|
993
1074
|
redeemsProducts: quantifiable(storefrontProductSchema).array(),
|
|
994
1075
|
redeemsBundles: quantifiable(storefrontBundleSchema).array()
|
|
995
1076
|
});
|
|
@@ -1016,9 +1097,10 @@ var VoucherEndpoints = class {
|
|
|
1016
1097
|
};
|
|
1017
1098
|
|
|
1018
1099
|
// src/schemas.ts
|
|
1019
|
-
var
|
|
1020
|
-
__export(
|
|
1021
|
-
|
|
1100
|
+
var schemas_exports3 = {};
|
|
1101
|
+
__export(schemas_exports3, {
|
|
1102
|
+
identity: () => schemas_exports,
|
|
1103
|
+
orders: () => schemas_exports2
|
|
1022
1104
|
});
|
|
1023
1105
|
|
|
1024
1106
|
// src/index.ts
|
|
@@ -1052,6 +1134,8 @@ var MoonbaseClient = class {
|
|
|
1052
1134
|
NotFoundError,
|
|
1053
1135
|
OrderStatus,
|
|
1054
1136
|
Platform,
|
|
1137
|
+
SubscriptionStatus,
|
|
1138
|
+
TokenStore,
|
|
1055
1139
|
schemas,
|
|
1056
1140
|
utmToObject
|
|
1057
1141
|
});
|