@moonbase.sh/storefront-api 3.3.1 → 3.4.0

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
@@ -46,6 +46,7 @@ __export(index_exports, {
46
46
  OfferUtils: () => OfferUtils,
47
47
  OrderStatus: () => OrderStatus,
48
48
  Platform: () => Platform,
49
+ SubscriptionCancellationReason: () => SubscriptionCancellationReason,
49
50
  SubscriptionStatus: () => SubscriptionStatus,
50
51
  TokenStore: () => TokenStore,
51
52
  imageWidths: () => imageWidths,
@@ -1382,6 +1383,15 @@ var SubscriptionStatus = /* @__PURE__ */ ((SubscriptionStatus2) => {
1382
1383
  SubscriptionStatus2["Completed"] = "Completed";
1383
1384
  return SubscriptionStatus2;
1384
1385
  })(SubscriptionStatus || {});
1386
+ var SubscriptionCancellationReason = /* @__PURE__ */ ((SubscriptionCancellationReason2) => {
1387
+ SubscriptionCancellationReason2["TooExpensive"] = "TooExpensive";
1388
+ SubscriptionCancellationReason2["Unused"] = "Unused";
1389
+ SubscriptionCancellationReason2["MissingFeatures"] = "MissingFeatures";
1390
+ SubscriptionCancellationReason2["TechnicalIssues"] = "TechnicalIssues";
1391
+ SubscriptionCancellationReason2["SwitchedService"] = "SwitchedService";
1392
+ SubscriptionCancellationReason2["Other"] = "Other";
1393
+ return SubscriptionCancellationReason2;
1394
+ })(SubscriptionCancellationReason || {});
1385
1395
 
1386
1396
  // src/inventory/subscriptions/schemas.ts
1387
1397
  var baseMilestoneProgressEventSchema = import_zod13.z.object({
@@ -1455,8 +1465,19 @@ var SubscriptionEndpoints = class {
1455
1465
  const response = await this.api.authenticatedFetch(`/api/customer/inventory/subscriptions/${subscriptionId}?${objectToQuery(options)}`, subscriptionSchema);
1456
1466
  return response.data;
1457
1467
  }
1458
- async cancel(subscriptionId) {
1459
- const response = await this.api.authenticatedFetch(`/api/customer/inventory/subscriptions/${subscriptionId}/cancel`, subscriptionSchema, { method: "POST" });
1468
+ /**
1469
+ * Turns off auto-renew. The customer keeps access until the subscription's current
1470
+ * period ends. Pass `feedback` to record why they are cancelling.
1471
+ */
1472
+ async cancel(subscriptionId, feedback) {
1473
+ var _a, _b;
1474
+ const response = await this.api.authenticatedFetch(`/api/customer/inventory/subscriptions/${subscriptionId}/cancel`, subscriptionSchema, {
1475
+ method: "POST",
1476
+ body: {
1477
+ reason: (_a = feedback == null ? void 0 : feedback.reason) != null ? _a : void 0,
1478
+ comment: ((_b = feedback == null ? void 0 : feedback.comment) == null ? void 0 : _b.trim()) || void 0
1479
+ }
1480
+ });
1460
1481
  return response.data;
1461
1482
  }
1462
1483
  async renew(subscriptionId, returnUrl, embedded) {
@@ -2586,6 +2607,7 @@ var MoonbaseClient = class {
2586
2607
  OfferUtils,
2587
2608
  OrderStatus,
2588
2609
  Platform,
2610
+ SubscriptionCancellationReason,
2589
2611
  SubscriptionStatus,
2590
2612
  TokenStore,
2591
2613
  imageWidths,
package/dist/index.d.cts CHANGED
@@ -6539,6 +6539,27 @@ declare enum SubscriptionStatus {
6539
6539
  Cancelled = "Cancelled",
6540
6540
  Completed = "Completed"
6541
6541
  }
6542
+ /**
6543
+ * Why a customer is cancelling a subscription, as they would pick it from a list. The
6544
+ * merchant has two further reasons of its own that a customer cannot give.
6545
+ */
6546
+ declare enum SubscriptionCancellationReason {
6547
+ TooExpensive = "TooExpensive",
6548
+ Unused = "Unused",
6549
+ MissingFeatures = "MissingFeatures",
6550
+ TechnicalIssues = "TechnicalIssues",
6551
+ SwitchedService = "SwitchedService",
6552
+ Other = "Other"
6553
+ }
6554
+ /**
6555
+ * What a customer said about why they are cancelling. Both parts are optional, and
6556
+ * the merchant sees them alongside the cancellation.
6557
+ */
6558
+ interface SubscriptionCancellationFeedback {
6559
+ reason?: SubscriptionCancellationReason | null;
6560
+ /** Free text, at most 1000 characters. */
6561
+ comment?: string | null;
6562
+ }
6542
6563
  type Subscription = z.infer<typeof subscriptionSchema>;
6543
6564
  type MilestoneProgress = z.infer<typeof milestoneProgressSchema>;
6544
6565
 
@@ -6551,7 +6572,11 @@ declare class SubscriptionEndpoints {
6551
6572
  toUpdatePaymentMethod?: boolean;
6552
6573
  returnUrl?: string;
6553
6574
  }): Promise<Subscription>;
6554
- cancel(subscriptionId: string): Promise<Subscription>;
6575
+ /**
6576
+ * Turns off auto-renew. The customer keeps access until the subscription's current
6577
+ * period ends. Pass `feedback` to record why they are cancelling.
6578
+ */
6579
+ cancel(subscriptionId: string, feedback?: SubscriptionCancellationFeedback): Promise<Subscription>;
6555
6580
  renew(subscriptionId: string, returnUrl: string, embedded: boolean): Promise<{
6556
6581
  location: string;
6557
6582
  }>;
@@ -47157,4 +47182,4 @@ declare class MoonbaseClient {
47157
47182
  orders: OrderEndpoints;
47158
47183
  }
47159
47184
 
47160
- export { type Activation, ActivationMethod, type ActivationRequest, ActivationRequestFulfillmentType, ActivationRequestStatus, ActivationStatus, type Address, Architecture, type BundleLineItem, type CartCatalog, type CartOrder, type CartTotal, type CartTotalCondition, CartUtils, type CommunicationPreferences, type CommunicationPreferencesInput, type CommunicationPreferencesView, type CompletedOrder, ConnectableAccountProvider, type ConnectedAccount, ConsoleLogger, CycleLength, type Discount, DiscountUtils, type Download, type DownloadManifest, type ILogger, type IRecurrence, type IStore, type ITokenStore, type Identity, type ImageFit, type ImageFormat, type ImageTransform, ImageUtils, InMemoryStore, type License, LicenseStatus, type LineItem, type LineItemTotal, LocalStorageStore, LogLevel, MarketingConsentType, type MilestoneProgress, type Money, type MoneyCollection, MoneyCollectionUtils, MoonbaseApi, MoonbaseClient, type MoonbaseConfiguration, MoonbaseError, NotAuthenticatedError, NotAuthorizedError, NotFoundError, type OfferCondition, type OfferConditionContext, type OfferProgress, type OfferScope, OfferUtils, type OpenOrder, type Order, OrderStatus, type OrderTotal, type OwnedProduct, type Page, Platform, type PricingTier, type PricingVariation, type ProblemDetails, type ProductLineItem, type PromotionDisplay, type Quantifiable, type RawPropertyArray, type RawPropertyObject, type RawPropertyValue, type SignUpOptions, type SignUpResult, type SingleOrMultiple, type Storefront, type StorefrontBundle, type StorefrontOffer, type StorefrontOfferTarget, type StorefrontProduct, type StorefrontPromotion, type StorefrontPromotionCta, type StorefrontPromotionTarget, type SubscribeInput, type SubscribeResponse, type Subscription, SubscriptionStatus, type TaxEstimate, TokenStore, type UrchinTrackingModule, type User, type UserAccountConfirmed, type UserAccountConfirmedStatus, type Vendor, type Voucher, imageWidths, isLocalStorageAvailable, isPromotionDisplay, isTransformableImageUrl, maxImageDimension, normalizeGroupIds, objectToQuery, parseOffSiteReferrer, problemDetailsSchema, promotionDisplays, resolveUtm, schemas, utmToObject };
47185
+ export { type Activation, ActivationMethod, type ActivationRequest, ActivationRequestFulfillmentType, ActivationRequestStatus, ActivationStatus, type Address, Architecture, type BundleLineItem, type CartCatalog, type CartOrder, type CartTotal, type CartTotalCondition, CartUtils, type CommunicationPreferences, type CommunicationPreferencesInput, type CommunicationPreferencesView, type CompletedOrder, ConnectableAccountProvider, type ConnectedAccount, ConsoleLogger, CycleLength, type Discount, DiscountUtils, type Download, type DownloadManifest, type ILogger, type IRecurrence, type IStore, type ITokenStore, type Identity, type ImageFit, type ImageFormat, type ImageTransform, ImageUtils, InMemoryStore, type License, LicenseStatus, type LineItem, type LineItemTotal, LocalStorageStore, LogLevel, MarketingConsentType, type MilestoneProgress, type Money, type MoneyCollection, MoneyCollectionUtils, MoonbaseApi, MoonbaseClient, type MoonbaseConfiguration, MoonbaseError, NotAuthenticatedError, NotAuthorizedError, NotFoundError, type OfferCondition, type OfferConditionContext, type OfferProgress, type OfferScope, OfferUtils, type OpenOrder, type Order, OrderStatus, type OrderTotal, type OwnedProduct, type Page, Platform, type PricingTier, type PricingVariation, type ProblemDetails, type ProductLineItem, type PromotionDisplay, type Quantifiable, type RawPropertyArray, type RawPropertyObject, type RawPropertyValue, type SignUpOptions, type SignUpResult, type SingleOrMultiple, type Storefront, type StorefrontBundle, type StorefrontOffer, type StorefrontOfferTarget, type StorefrontProduct, type StorefrontPromotion, type StorefrontPromotionCta, type StorefrontPromotionTarget, type SubscribeInput, type SubscribeResponse, type Subscription, type SubscriptionCancellationFeedback, SubscriptionCancellationReason, SubscriptionStatus, type TaxEstimate, TokenStore, type UrchinTrackingModule, type User, type UserAccountConfirmed, type UserAccountConfirmedStatus, type Vendor, type Voucher, imageWidths, isLocalStorageAvailable, isPromotionDisplay, isTransformableImageUrl, maxImageDimension, normalizeGroupIds, objectToQuery, parseOffSiteReferrer, problemDetailsSchema, promotionDisplays, resolveUtm, schemas, utmToObject };
package/dist/index.d.ts CHANGED
@@ -6539,6 +6539,27 @@ declare enum SubscriptionStatus {
6539
6539
  Cancelled = "Cancelled",
6540
6540
  Completed = "Completed"
6541
6541
  }
6542
+ /**
6543
+ * Why a customer is cancelling a subscription, as they would pick it from a list. The
6544
+ * merchant has two further reasons of its own that a customer cannot give.
6545
+ */
6546
+ declare enum SubscriptionCancellationReason {
6547
+ TooExpensive = "TooExpensive",
6548
+ Unused = "Unused",
6549
+ MissingFeatures = "MissingFeatures",
6550
+ TechnicalIssues = "TechnicalIssues",
6551
+ SwitchedService = "SwitchedService",
6552
+ Other = "Other"
6553
+ }
6554
+ /**
6555
+ * What a customer said about why they are cancelling. Both parts are optional, and
6556
+ * the merchant sees them alongside the cancellation.
6557
+ */
6558
+ interface SubscriptionCancellationFeedback {
6559
+ reason?: SubscriptionCancellationReason | null;
6560
+ /** Free text, at most 1000 characters. */
6561
+ comment?: string | null;
6562
+ }
6542
6563
  type Subscription = z.infer<typeof subscriptionSchema>;
6543
6564
  type MilestoneProgress = z.infer<typeof milestoneProgressSchema>;
6544
6565
 
@@ -6551,7 +6572,11 @@ declare class SubscriptionEndpoints {
6551
6572
  toUpdatePaymentMethod?: boolean;
6552
6573
  returnUrl?: string;
6553
6574
  }): Promise<Subscription>;
6554
- cancel(subscriptionId: string): Promise<Subscription>;
6575
+ /**
6576
+ * Turns off auto-renew. The customer keeps access until the subscription's current
6577
+ * period ends. Pass `feedback` to record why they are cancelling.
6578
+ */
6579
+ cancel(subscriptionId: string, feedback?: SubscriptionCancellationFeedback): Promise<Subscription>;
6555
6580
  renew(subscriptionId: string, returnUrl: string, embedded: boolean): Promise<{
6556
6581
  location: string;
6557
6582
  }>;
@@ -47157,4 +47182,4 @@ declare class MoonbaseClient {
47157
47182
  orders: OrderEndpoints;
47158
47183
  }
47159
47184
 
47160
- export { type Activation, ActivationMethod, type ActivationRequest, ActivationRequestFulfillmentType, ActivationRequestStatus, ActivationStatus, type Address, Architecture, type BundleLineItem, type CartCatalog, type CartOrder, type CartTotal, type CartTotalCondition, CartUtils, type CommunicationPreferences, type CommunicationPreferencesInput, type CommunicationPreferencesView, type CompletedOrder, ConnectableAccountProvider, type ConnectedAccount, ConsoleLogger, CycleLength, type Discount, DiscountUtils, type Download, type DownloadManifest, type ILogger, type IRecurrence, type IStore, type ITokenStore, type Identity, type ImageFit, type ImageFormat, type ImageTransform, ImageUtils, InMemoryStore, type License, LicenseStatus, type LineItem, type LineItemTotal, LocalStorageStore, LogLevel, MarketingConsentType, type MilestoneProgress, type Money, type MoneyCollection, MoneyCollectionUtils, MoonbaseApi, MoonbaseClient, type MoonbaseConfiguration, MoonbaseError, NotAuthenticatedError, NotAuthorizedError, NotFoundError, type OfferCondition, type OfferConditionContext, type OfferProgress, type OfferScope, OfferUtils, type OpenOrder, type Order, OrderStatus, type OrderTotal, type OwnedProduct, type Page, Platform, type PricingTier, type PricingVariation, type ProblemDetails, type ProductLineItem, type PromotionDisplay, type Quantifiable, type RawPropertyArray, type RawPropertyObject, type RawPropertyValue, type SignUpOptions, type SignUpResult, type SingleOrMultiple, type Storefront, type StorefrontBundle, type StorefrontOffer, type StorefrontOfferTarget, type StorefrontProduct, type StorefrontPromotion, type StorefrontPromotionCta, type StorefrontPromotionTarget, type SubscribeInput, type SubscribeResponse, type Subscription, SubscriptionStatus, type TaxEstimate, TokenStore, type UrchinTrackingModule, type User, type UserAccountConfirmed, type UserAccountConfirmedStatus, type Vendor, type Voucher, imageWidths, isLocalStorageAvailable, isPromotionDisplay, isTransformableImageUrl, maxImageDimension, normalizeGroupIds, objectToQuery, parseOffSiteReferrer, problemDetailsSchema, promotionDisplays, resolveUtm, schemas, utmToObject };
47185
+ export { type Activation, ActivationMethod, type ActivationRequest, ActivationRequestFulfillmentType, ActivationRequestStatus, ActivationStatus, type Address, Architecture, type BundleLineItem, type CartCatalog, type CartOrder, type CartTotal, type CartTotalCondition, CartUtils, type CommunicationPreferences, type CommunicationPreferencesInput, type CommunicationPreferencesView, type CompletedOrder, ConnectableAccountProvider, type ConnectedAccount, ConsoleLogger, CycleLength, type Discount, DiscountUtils, type Download, type DownloadManifest, type ILogger, type IRecurrence, type IStore, type ITokenStore, type Identity, type ImageFit, type ImageFormat, type ImageTransform, ImageUtils, InMemoryStore, type License, LicenseStatus, type LineItem, type LineItemTotal, LocalStorageStore, LogLevel, MarketingConsentType, type MilestoneProgress, type Money, type MoneyCollection, MoneyCollectionUtils, MoonbaseApi, MoonbaseClient, type MoonbaseConfiguration, MoonbaseError, NotAuthenticatedError, NotAuthorizedError, NotFoundError, type OfferCondition, type OfferConditionContext, type OfferProgress, type OfferScope, OfferUtils, type OpenOrder, type Order, OrderStatus, type OrderTotal, type OwnedProduct, type Page, Platform, type PricingTier, type PricingVariation, type ProblemDetails, type ProductLineItem, type PromotionDisplay, type Quantifiable, type RawPropertyArray, type RawPropertyObject, type RawPropertyValue, type SignUpOptions, type SignUpResult, type SingleOrMultiple, type Storefront, type StorefrontBundle, type StorefrontOffer, type StorefrontOfferTarget, type StorefrontProduct, type StorefrontPromotion, type StorefrontPromotionCta, type StorefrontPromotionTarget, type SubscribeInput, type SubscribeResponse, type Subscription, type SubscriptionCancellationFeedback, SubscriptionCancellationReason, SubscriptionStatus, type TaxEstimate, TokenStore, type UrchinTrackingModule, type User, type UserAccountConfirmed, type UserAccountConfirmedStatus, type Vendor, type Voucher, imageWidths, isLocalStorageAvailable, isPromotionDisplay, isTransformableImageUrl, maxImageDimension, normalizeGroupIds, objectToQuery, parseOffSiteReferrer, problemDetailsSchema, promotionDisplays, resolveUtm, schemas, utmToObject };
package/dist/index.js CHANGED
@@ -1322,6 +1322,15 @@ var SubscriptionStatus = /* @__PURE__ */ ((SubscriptionStatus2) => {
1322
1322
  SubscriptionStatus2["Completed"] = "Completed";
1323
1323
  return SubscriptionStatus2;
1324
1324
  })(SubscriptionStatus || {});
1325
+ var SubscriptionCancellationReason = /* @__PURE__ */ ((SubscriptionCancellationReason2) => {
1326
+ SubscriptionCancellationReason2["TooExpensive"] = "TooExpensive";
1327
+ SubscriptionCancellationReason2["Unused"] = "Unused";
1328
+ SubscriptionCancellationReason2["MissingFeatures"] = "MissingFeatures";
1329
+ SubscriptionCancellationReason2["TechnicalIssues"] = "TechnicalIssues";
1330
+ SubscriptionCancellationReason2["SwitchedService"] = "SwitchedService";
1331
+ SubscriptionCancellationReason2["Other"] = "Other";
1332
+ return SubscriptionCancellationReason2;
1333
+ })(SubscriptionCancellationReason || {});
1325
1334
 
1326
1335
  // src/inventory/subscriptions/schemas.ts
1327
1336
  var baseMilestoneProgressEventSchema = z13.object({
@@ -1395,8 +1404,19 @@ var SubscriptionEndpoints = class {
1395
1404
  const response = await this.api.authenticatedFetch(`/api/customer/inventory/subscriptions/${subscriptionId}?${objectToQuery(options)}`, subscriptionSchema);
1396
1405
  return response.data;
1397
1406
  }
1398
- async cancel(subscriptionId) {
1399
- const response = await this.api.authenticatedFetch(`/api/customer/inventory/subscriptions/${subscriptionId}/cancel`, subscriptionSchema, { method: "POST" });
1407
+ /**
1408
+ * Turns off auto-renew. The customer keeps access until the subscription's current
1409
+ * period ends. Pass `feedback` to record why they are cancelling.
1410
+ */
1411
+ async cancel(subscriptionId, feedback) {
1412
+ var _a, _b;
1413
+ const response = await this.api.authenticatedFetch(`/api/customer/inventory/subscriptions/${subscriptionId}/cancel`, subscriptionSchema, {
1414
+ method: "POST",
1415
+ body: {
1416
+ reason: (_a = feedback == null ? void 0 : feedback.reason) != null ? _a : void 0,
1417
+ comment: ((_b = feedback == null ? void 0 : feedback.comment) == null ? void 0 : _b.trim()) || void 0
1418
+ }
1419
+ });
1400
1420
  return response.data;
1401
1421
  }
1402
1422
  async renew(subscriptionId, returnUrl, embedded) {
@@ -2525,6 +2545,7 @@ export {
2525
2545
  OfferUtils,
2526
2546
  OrderStatus,
2527
2547
  Platform,
2548
+ SubscriptionCancellationReason,
2528
2549
  SubscriptionStatus,
2529
2550
  TokenStore,
2530
2551
  imageWidths,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@moonbase.sh/storefront-api",
3
3
  "type": "module",
4
- "version": "3.3.1",
4
+ "version": "3.4.0",
5
5
  "description": "Package to let you build storefronts with Moonbase.sh as payment and delivery provider",
6
6
  "author": "Tobias Lønnerød Madsen <m@dsen.tv>",
7
7
  "license": "MIT",
@@ -27,6 +27,8 @@
27
27
  "dev": "tsup src/index.ts --format esm,cjs --watch --dts",
28
28
  "version": "npm version",
29
29
  "type-check": "tsc --noEmit -p tsconfig.typecheck.json",
30
+ "lint": "eslint . --cache --cache-location node_modules/.cache/eslint/ --cache-strategy content",
31
+ "lint:fix": "eslint . --cache --cache-location node_modules/.cache/eslint/ --cache-strategy content --fix",
30
32
  "test": "vitest run",
31
33
  "test:watch": "vitest",
32
34
  "test:integration": "TEST_INTEGRATION=true vitest run"