@moonbase.sh/storefront-api 3.4.0 → 3.5.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
+ StoreClosedError: () => StoreClosedError,
49
50
  SubscriptionCancellationReason: () => SubscriptionCancellationReason,
50
51
  SubscriptionStatus: () => SubscriptionStatus,
51
52
  TokenStore: () => TokenStore,
@@ -634,6 +635,13 @@ var NotFoundError = class extends Error {
634
635
  this.message = message != null ? message : "Not found";
635
636
  }
636
637
  };
638
+ var StoreClosedError = class extends Error {
639
+ constructor(message) {
640
+ super();
641
+ this.name = "StoreClosedError";
642
+ this.message = message != null ? message : "This store has closed";
643
+ }
644
+ };
637
645
  var MoonbaseError = class extends Error {
638
646
  constructor(title, detail, status, errors) {
639
647
  super();
@@ -658,7 +666,8 @@ var problemDetailsSchema = import_zod7.z.object({
658
666
  detail: import_zod7.z.string().optional(),
659
667
  status: import_zod7.z.number().optional(),
660
668
  instance: import_zod7.z.string().optional(),
661
- errors: import_zod7.z.record(import_zod7.z.string(), import_zod7.z.string().array()).optional()
669
+ errors: import_zod7.z.record(import_zod7.z.string(), import_zod7.z.string().array()).optional(),
670
+ errorType: import_zod7.z.string().optional()
662
671
  });
663
672
 
664
673
  // src/utils/problemHandler.ts
@@ -688,6 +697,8 @@ async function handleResponseProblem(response, logger) {
688
697
  throw new Error("An unknown problem occurred");
689
698
  }
690
699
  logger.debug("The response indicates a problem", problemDetails);
700
+ if (problemDetails.errorType === "StoreClosed")
701
+ throw new StoreClosedError(problemDetails.detail);
691
702
  throw new MoonbaseError(
692
703
  problemDetails.title,
693
704
  problemDetails.detail,
@@ -1142,7 +1153,8 @@ var MoonbaseApi = class {
1142
1153
  try {
1143
1154
  await handleResponseProblem(response, this.logger);
1144
1155
  } catch (err) {
1145
- this.reportRequestProblem(path, request, response, err);
1156
+ if (!(err instanceof StoreClosedError))
1157
+ this.reportRequestProblem(path, request, response, err);
1146
1158
  throw err;
1147
1159
  }
1148
1160
  }
@@ -2607,6 +2619,7 @@ var MoonbaseClient = class {
2607
2619
  OfferUtils,
2608
2620
  OrderStatus,
2609
2621
  Platform,
2622
+ StoreClosedError,
2610
2623
  SubscriptionCancellationReason,
2611
2624
  SubscriptionStatus,
2612
2625
  TokenStore,
package/dist/index.d.cts CHANGED
@@ -47006,6 +47006,13 @@ declare class NotAuthenticatedError extends Error {
47006
47006
  declare class NotFoundError extends Error {
47007
47007
  constructor(message?: string);
47008
47008
  }
47009
+ /**
47010
+ * The store has closed its Moonbase account, so it answers nothing: no catalog, no cart, no
47011
+ * checkout and no sign-in. Not transient, so there is nothing to retry.
47012
+ */
47013
+ declare class StoreClosedError extends Error {
47014
+ constructor(message?: string);
47015
+ }
47009
47016
  declare class MoonbaseError extends Error {
47010
47017
  readonly title: string;
47011
47018
  readonly detail: string | undefined;
@@ -47115,6 +47122,7 @@ declare const problemDetailsSchema: z.ZodObject<{
47115
47122
  status: z.ZodOptional<z.ZodNumber>;
47116
47123
  instance: z.ZodOptional<z.ZodString>;
47117
47124
  errors: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString, "many">>>;
47125
+ errorType: z.ZodOptional<z.ZodString>;
47118
47126
  }, "strip", z.ZodTypeAny, {
47119
47127
  title: string;
47120
47128
  type?: string | undefined;
@@ -47122,6 +47130,7 @@ declare const problemDetailsSchema: z.ZodObject<{
47122
47130
  detail?: string | undefined;
47123
47131
  instance?: string | undefined;
47124
47132
  errors?: Record<string, string[]> | undefined;
47133
+ errorType?: string | undefined;
47125
47134
  }, {
47126
47135
  title: string;
47127
47136
  type?: string | undefined;
@@ -47129,6 +47138,7 @@ declare const problemDetailsSchema: z.ZodObject<{
47129
47138
  detail?: string | undefined;
47130
47139
  instance?: string | undefined;
47131
47140
  errors?: Record<string, string[]> | undefined;
47141
+ errorType?: string | undefined;
47132
47142
  }>;
47133
47143
  type ProblemDetails = z.infer<typeof problemDetailsSchema>;
47134
47144
 
@@ -47182,4 +47192,4 @@ declare class MoonbaseClient {
47182
47192
  orders: OrderEndpoints;
47183
47193
  }
47184
47194
 
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 };
47195
+ 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, StoreClosedError, 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
@@ -47006,6 +47006,13 @@ declare class NotAuthenticatedError extends Error {
47006
47006
  declare class NotFoundError extends Error {
47007
47007
  constructor(message?: string);
47008
47008
  }
47009
+ /**
47010
+ * The store has closed its Moonbase account, so it answers nothing: no catalog, no cart, no
47011
+ * checkout and no sign-in. Not transient, so there is nothing to retry.
47012
+ */
47013
+ declare class StoreClosedError extends Error {
47014
+ constructor(message?: string);
47015
+ }
47009
47016
  declare class MoonbaseError extends Error {
47010
47017
  readonly title: string;
47011
47018
  readonly detail: string | undefined;
@@ -47115,6 +47122,7 @@ declare const problemDetailsSchema: z.ZodObject<{
47115
47122
  status: z.ZodOptional<z.ZodNumber>;
47116
47123
  instance: z.ZodOptional<z.ZodString>;
47117
47124
  errors: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString, "many">>>;
47125
+ errorType: z.ZodOptional<z.ZodString>;
47118
47126
  }, "strip", z.ZodTypeAny, {
47119
47127
  title: string;
47120
47128
  type?: string | undefined;
@@ -47122,6 +47130,7 @@ declare const problemDetailsSchema: z.ZodObject<{
47122
47130
  detail?: string | undefined;
47123
47131
  instance?: string | undefined;
47124
47132
  errors?: Record<string, string[]> | undefined;
47133
+ errorType?: string | undefined;
47125
47134
  }, {
47126
47135
  title: string;
47127
47136
  type?: string | undefined;
@@ -47129,6 +47138,7 @@ declare const problemDetailsSchema: z.ZodObject<{
47129
47138
  detail?: string | undefined;
47130
47139
  instance?: string | undefined;
47131
47140
  errors?: Record<string, string[]> | undefined;
47141
+ errorType?: string | undefined;
47132
47142
  }>;
47133
47143
  type ProblemDetails = z.infer<typeof problemDetailsSchema>;
47134
47144
 
@@ -47182,4 +47192,4 @@ declare class MoonbaseClient {
47182
47192
  orders: OrderEndpoints;
47183
47193
  }
47184
47194
 
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 };
47195
+ 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, StoreClosedError, 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
@@ -573,6 +573,13 @@ var NotFoundError = class extends Error {
573
573
  this.message = message != null ? message : "Not found";
574
574
  }
575
575
  };
576
+ var StoreClosedError = class extends Error {
577
+ constructor(message) {
578
+ super();
579
+ this.name = "StoreClosedError";
580
+ this.message = message != null ? message : "This store has closed";
581
+ }
582
+ };
576
583
  var MoonbaseError = class extends Error {
577
584
  constructor(title, detail, status, errors) {
578
585
  super();
@@ -597,7 +604,8 @@ var problemDetailsSchema = z7.object({
597
604
  detail: z7.string().optional(),
598
605
  status: z7.number().optional(),
599
606
  instance: z7.string().optional(),
600
- errors: z7.record(z7.string(), z7.string().array()).optional()
607
+ errors: z7.record(z7.string(), z7.string().array()).optional(),
608
+ errorType: z7.string().optional()
601
609
  });
602
610
 
603
611
  // src/utils/problemHandler.ts
@@ -627,6 +635,8 @@ async function handleResponseProblem(response, logger) {
627
635
  throw new Error("An unknown problem occurred");
628
636
  }
629
637
  logger.debug("The response indicates a problem", problemDetails);
638
+ if (problemDetails.errorType === "StoreClosed")
639
+ throw new StoreClosedError(problemDetails.detail);
630
640
  throw new MoonbaseError(
631
641
  problemDetails.title,
632
642
  problemDetails.detail,
@@ -1081,7 +1091,8 @@ var MoonbaseApi = class {
1081
1091
  try {
1082
1092
  await handleResponseProblem(response, this.logger);
1083
1093
  } catch (err) {
1084
- this.reportRequestProblem(path, request, response, err);
1094
+ if (!(err instanceof StoreClosedError))
1095
+ this.reportRequestProblem(path, request, response, err);
1085
1096
  throw err;
1086
1097
  }
1087
1098
  }
@@ -2545,6 +2556,7 @@ export {
2545
2556
  OfferUtils,
2546
2557
  OrderStatus,
2547
2558
  Platform,
2559
+ StoreClosedError,
2548
2560
  SubscriptionCancellationReason,
2549
2561
  SubscriptionStatus,
2550
2562
  TokenStore,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@moonbase.sh/storefront-api",
3
3
  "type": "module",
4
- "version": "3.4.0",
4
+ "version": "3.5.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",