@ancon/wildcat-utils 1.40.26 → 1.40.28

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.
@@ -54,13 +54,14 @@ declare enum CheckoutPaymentErrorTranslationKey {
54
54
  PaymentPenguinInvalidTimeSlot = "paymentPenguinInvalidTimeSlot",
55
55
  PaymentPenguinNotEnoughLockers = "paymentPenguinNotEnoughLockers",
56
56
  PaymentPenguinTooManyItems = "paymentPenguinTooManyItems",
57
- PaymentPenguinProductInvalidUnits = "paymentPenguinProductInvalidUnits"
57
+ PaymentPenguinProductInvalidUnits = "paymentPenguinProductInvalidUnits",
58
+ PaymentCheckoutServiceTimeInPast = "paymentCheckoutServiceTimeInPast"
58
59
  }
59
60
  declare type CheckoutPaymentErrorTranslation = {
60
61
  title: string;
61
62
  message: string;
62
63
  };
63
- declare type TranslationsWithMeta = Record<CheckoutPaymentErrorTranslationKey.PaymentRefusalReferral | CheckoutPaymentErrorTranslationKey.PaymentRefusalAcquirer | CheckoutPaymentErrorTranslationKey.PaymentRefusalSubmmissionAdyen | CheckoutPaymentErrorTranslationKey.PaymentRefusalDoNotHonor | CheckoutPaymentErrorTranslationKey.PaymentResultError | CheckoutPaymentErrorTranslationKey.PaymentAuthorizeDataNotValid | CheckoutPaymentErrorTranslationKey.PaymentAuthorizeErrorUnknownReason | CheckoutPaymentErrorTranslationKey.PaymentAuthorizeCheckoutCaptured | CheckoutPaymentErrorTranslationKey.PaymentAuthorizeCheckoutAuthorized | CheckoutPaymentErrorTranslationKey.PaymentAuthorizeCaptureFailure | CheckoutPaymentErrorTranslationKey.PaymentActionErrorUnknownReason | CheckoutPaymentErrorTranslationKey.PaymentActionInvalidData | CheckoutPaymentErrorTranslationKey.PaymentActionCaptureFailure | CheckoutPaymentErrorTranslationKey.PaymentPaymentCheckoutCreated | CheckoutPaymentErrorTranslationKey.PaymentCheckoutPaymentFailure | CheckoutPaymentErrorTranslationKey.PaymentAuthorizeNoItems | CheckoutPaymentErrorTranslationKey.PaymentAuthorizeInvalidCustomer | CheckoutPaymentErrorTranslationKey.PaymentAuthorizeInvalidDelivery | CheckoutPaymentErrorTranslationKey.PaymentPenguinProductInvalidUnits, ({ meta, }: {
64
+ declare type TranslationsWithMeta = Record<CheckoutPaymentErrorTranslationKey.PaymentRefusalReferral | CheckoutPaymentErrorTranslationKey.PaymentRefusalAcquirer | CheckoutPaymentErrorTranslationKey.PaymentRefusalSubmmissionAdyen | CheckoutPaymentErrorTranslationKey.PaymentRefusalDoNotHonor | CheckoutPaymentErrorTranslationKey.PaymentResultError | CheckoutPaymentErrorTranslationKey.PaymentAuthorizeDataNotValid | CheckoutPaymentErrorTranslationKey.PaymentAuthorizeErrorUnknownReason | CheckoutPaymentErrorTranslationKey.PaymentAuthorizeCheckoutCaptured | CheckoutPaymentErrorTranslationKey.PaymentAuthorizeCheckoutAuthorized | CheckoutPaymentErrorTranslationKey.PaymentAuthorizeCaptureFailure | CheckoutPaymentErrorTranslationKey.PaymentActionErrorUnknownReason | CheckoutPaymentErrorTranslationKey.PaymentActionInvalidData | CheckoutPaymentErrorTranslationKey.PaymentActionCaptureFailure | CheckoutPaymentErrorTranslationKey.PaymentPaymentCheckoutCreated | CheckoutPaymentErrorTranslationKey.PaymentCheckoutPaymentFailure | CheckoutPaymentErrorTranslationKey.PaymentAuthorizeNoItems | CheckoutPaymentErrorTranslationKey.PaymentAuthorizeInvalidCustomer | CheckoutPaymentErrorTranslationKey.PaymentAuthorizeInvalidDelivery | CheckoutPaymentErrorTranslationKey.PaymentPenguinProductInvalidUnits | CheckoutPaymentErrorTranslationKey.PaymentCheckoutServiceTimeInPast, ({ meta, }: {
64
65
  key: CheckoutPaymentErrorTranslationKey;
65
66
  meta: {
66
67
  checkoutId: string;
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("@ancon/wildcat-types");require("axios");const l=require("../error/isSerializedAPIError.js");var s=(e=>(e.PaymentRefusalGeneral="paymentRefusalGeneral",e.PaymentRefusalTransactionRefused="paymentRefusalTransactionRefused",e.PaymentRefusalReferral="paymentRefusalReferral",e.PaymentRefusalAcquirer="paymentRefusalAcquirer",e.PaymentRefusalBlockedCard="paymentRefusalBlockedCard",e.PaymentRefusalExpiredCard="paymentRefusalExpiredCard",e.PaymentRefusalInvalidAmount="paymentRefusalInvalidAmount",e.PaymentRefusalInvalidCardnumber="paymentRefusalInvalidCardnumber",e.PaymentRefusalIssuerUnavailable="paymentRefusalIssuerUnavailable",e.PaymentRefusalBankNotSupported="paymentRefusalBankNotSupported",e.PaymentRefusal3dsecureAuthFailed="paymentRefusal3dsecureAuthFailed",e.PaymentRefusalNoEnoughBalance="paymentRefusalNoEnoughBalance",e.PaymentRefusalFraudDetected="paymentRefusalFraudDetected",e.PaymentRefusalCancelled="paymentRefusalCancelled",e.PaymentRefusalInvalidPin="paymentRefusalInvalidPin",e.PaymentRefusalPinRetryExceeded="paymentRefusalPinRetryExceeded",e.PaymentRefusalUnableValidatePin="paymentRefusalUnableValidatePin",e.PaymentRefusalSubmmissionAdyen="paymentRefusalSubmmissionAdyen",e.PaymentRefusalCvcDeclined="paymentRefusalCvcDeclined",e.PaymentRefusalRestrictedCard="paymentRefusalRestrictedCard",e.PaymentRefusalDoNotHonor="paymentRefusalDoNotHonor",e.PaymentRefusalWdrwAmountExceeded="paymentRefusalWdrwAmountExceeded",e.PaymentRefusalWdrwCountExceeded="paymentRefusalWdrwCountExceeded",e.PaymentRefusalAvsDeclined="paymentRefusalAvsDeclined",e.PaymentRefusalCardOnlinePin="paymentRefusalCardOnlinePin",e.PaymentRefusalNoAcctAtchdCard="paymentRefusalNoAcctAtchdCard",e.PaymentRefusalMobilePin="paymentRefusalMobilePin",e.PaymentRefusalContactlessFallback="paymentRefusalContactlessFallback",e.PaymentRefusalAuthRequired="paymentRefusalAuthRequired",e.PaymentResultCancelled="paymentResultCancelled",e.PaymentResultError="paymentResultError",e.PaymentResultRefused="paymentResultRefused",e.PaymentAuthorizeDataNotValid="paymentAuthorizeDataNotValid",e.PaymentAuthorizeErrorUnknownReason="paymentAuthorizeErrorUnknownReason",e.PaymentAuthorizeCheckoutCaptured="paymentAuthorizeCheckoutCaptured",e.PaymentAuthorizeCheckoutAuthorized="paymentAuthorizeCheckoutAuthorized",e.PaymentAuthorizeCaptureFailure="paymentAuthorizeCaptureFailure",e.PaymentAuthorizeCancelOrRefund="paymentAuthorizeCancelOrRefund",e.PaymentActionErrorUnknownReason="paymentActionErrorUnknownReason",e.PaymentActionInvalidData="paymentActionInvalidData",e.PaymentActionCaptureFailure="paymentActionCaptureFailure",e.PaymentActionCancelOrRefund="paymentActionCancelOrRefund",e.PaymentPaymentAppNotFound="paymentPaymentAppNotFound",e.PaymentPaymentCheckoutCreated="paymentPaymentCheckoutCreated",e.PaymentCheckoutPaymentFailure="paymentCheckoutPaymentFailure",e.PaymentDetailsNotSupported="paymentDetailsNotSupported",e.PaymentAuthorizeNoItems="paymentAuthorizeNoItems",e.PaymentAuthorizeInvalidCustomer="paymentAuthorizeInvalidCustomer",e.PaymentAuthorizeInvalidDelivery="paymentAuthorizeInvalidDelivery",e.PaymentPenguinInvalidStation="paymentPenguinInvalidStation",e.PaymentPenguinInvalidTimeSlot="paymentPenguinInvalidTimeSlot",e.PaymentPenguinNotEnoughLockers="paymentPenguinNotEnoughLockers",e.PaymentPenguinTooManyItems="paymentPenguinTooManyItems",e.PaymentPenguinProductInvalidUnits="paymentPenguinProductInvalidUnits",e))(s||{});const d={paymentRefusalGeneral:()=>({title:"Payment failure",message:"The transaction was refused."}),paymentRefusalTransactionRefused:()=>({title:"Payment failure",message:"The transaction was refused."}),paymentRefusalReferral:({meta:e})=>({title:"Payment failure",message:`A referral error occurred. (${e.checkoutId})`}),paymentRefusalAcquirer:({meta:e})=>({title:"Payment failure",message:`An acquirer error occurred. (${e.checkoutId})`}),paymentRefusalBlockedCard:()=>({title:"Payment failure",message:"The provided card is blocked."}),paymentRefusalExpiredCard:()=>({title:"Payment failure",message:"The provided card is expired."}),paymentRefusalInvalidAmount:()=>({title:"Payment failure",message:"An invalid payment amount was provided."}),paymentRefusalInvalidCardnumber:()=>({title:"Payment failure",message:"An invalid card number was provided."}),paymentRefusalIssuerUnavailable:()=>({title:"Payment failure",message:"Card issuer not available."}),paymentRefusalBankNotSupported:()=>({title:"Payment failure",message:"CVC declined."}),paymentRefusal3dsecureAuthFailed:()=>({title:"Payment failure",message:"3D Secure was not authenticated."}),paymentRefusalNoEnoughBalance:()=>({title:"Payment failure",message:"Not enough balance."}),paymentRefusalFraudDetected:()=>({title:"Payment failure",message:"The provided card is not allowed."}),paymentRefusalCancelled:()=>({title:"Payment cancelled",message:"The payment was cancelled."}),paymentRefusalInvalidPin:()=>({title:"Payment failure",message:"Invalid PIN."}),paymentRefusalPinRetryExceeded:()=>({title:"Payment failure",message:"PIN tries exceeded."}),paymentRefusalUnableValidatePin:()=>({title:"Payment failure",message:"PIN validation was not possible."}),paymentRefusalSubmmissionAdyen:({meta:e})=>({title:"Payment failure",message:`Submission error. (${e.checkoutId})`}),paymentRefusalCvcDeclined:()=>({title:"Payment failure",message:"CVC declined."}),paymentRefusalRestrictedCard:()=>({title:"Payment failure",message:"Restricted card."}),paymentRefusalDoNotHonor:({meta:e})=>({title:"Payment failure",message:`The transaction was refused (do not honor). (${e.checkoutId})`}),paymentRefusalWdrwAmountExceeded:()=>({title:"Payment failure",message:"Withdrawal amount exceeded."}),paymentRefusalWdrwCountExceeded:()=>({title:"Payment failure",message:"Withdrawal count exceeded."}),paymentRefusalAvsDeclined:()=>({title:"Payment failure",message:"AVS declined."}),paymentRefusalCardOnlinePin:()=>({title:"Payment failure",message:"The provided card requires online PIN."}),paymentRefusalNoAcctAtchdCard:()=>({title:"Payment failure",message:"No account attached to the provided card."}),paymentRefusalMobilePin:()=>({title:"Payment failure",message:"Mobile PIN required."}),paymentRefusalContactlessFallback:()=>({title:"Payment failure",message:"Contactless fallback."}),paymentRefusalAuthRequired:()=>({title:"Payment failure",message:"Authentication required"}),paymentResultCancelled:()=>({title:"Payment cancelled",message:"The payment was cancelled."}),paymentResultError:({meta:e})=>({title:"Payment error",message:`There was an error processing your payment. (${e.checkoutId})`}),paymentResultRefused:()=>({title:"Payment refused",message:"The payment was refused."}),paymentAuthorizeDataNotValid:({meta:e})=>({title:"Authorization failed",message:`The provided data was invalid. (${e.checkoutId})`}),paymentAuthorizeErrorUnknownReason:({meta:e})=>({title:"Authorization failed",message:`Authorization failed because of an unknown error. (${e.checkoutId})`}),paymentAuthorizeCheckoutCaptured:({meta:e})=>({title:"Authorization failed",message:`The checkout has already been captured. (${e.checkoutId})`}),paymentAuthorizeCheckoutAuthorized:({meta:e})=>({title:"Authorization failed",message:`The checkout has already been authorized. (${e.checkoutId})`}),paymentAuthorizeCaptureFailure:({meta:e})=>({title:"Authorization failed",message:`Failed to capture checkout. (${e.checkoutId})`}),paymentAuthorizeCancelOrRefund:()=>({title:"Authorization failed",message:"The checkout has already been cancelled or refunded."}),paymentActionErrorUnknownReason:({meta:e})=>({title:"Action failed",message:`The action failed because of an unknown error. (${e.checkoutId})`}),paymentActionInvalidData:({meta:e})=>({title:"Action failed",message:`The provided data was invalid. (${e.checkoutId})`}),paymentActionCaptureFailure:({meta:e})=>({title:"Action failed",message:`Failed to capture checkout. (${e.checkoutId})`}),paymentActionCancelOrRefund:()=>({title:"Action failed",message:"The checkout has already been cancelled or refunded."}),paymentPaymentAppNotFound:()=>({title:"Payment failure",message:"The chosen payment method requires an app which is not installed."}),paymentPaymentCheckoutCreated:({meta:e})=>({title:"Payment failure",message:`The checkout is created, cannot make payment, make sure the customer is connected to this checkout. (${e.checkoutId})`}),paymentCheckoutPaymentFailure:({meta:e})=>({title:"Payment failure",message:`Unfortunately an error has occurred and your payment cannot be processed. (${e.checkoutId})`}),paymentDetailsNotSupported:()=>({title:"Payment failure",message:"The payment provider is not supported by this outlet."}),paymentAuthorizeNoItems:({meta:e})=>({title:"Payment failure",message:`The current checkout does not contain any products. (${e.checkoutId})`}),paymentAuthorizeInvalidCustomer:({meta:e})=>({title:"Payment failure",message:`Could not resolve the customer from database. (${e.checkoutId})`}),paymentAuthorizeInvalidDelivery:({meta:e})=>({title:"Payment failure",message:`Missing delivery information. (${e.checkoutId})`}),paymentPenguinInvalidStation:()=>({title:"Payment failure",message:"Invalid station."}),paymentPenguinInvalidTimeSlot:()=>({title:"Payment failure",message:"Invalid time slot."}),paymentPenguinNotEnoughLockers:()=>({title:"Payment failure",message:"Not enough lockers."}),paymentPenguinTooManyItems:()=>({title:"Payment failure",message:"The current checkout has too many items."}),paymentPenguinProductInvalidUnits:({meta:e})=>({title:"Payment failure",message:`The current checkout does not contain valid product storage configurations. (${e.checkoutId})`})};function m(e){switch(e){case"0":return"paymentRefusalGeneral";case"2":case"23":return"paymentRefusalTransactionRefused";case"3":return"paymentRefusalReferral";case"4":return"paymentRefusalAcquirer";case"5":return"paymentRefusalBlockedCard";case"6":return"paymentRefusalExpiredCard";case"7":return"paymentRefusalInvalidAmount";case"8":return"paymentRefusalInvalidCardnumber";case"9":return"paymentRefusalIssuerUnavailable";case"10":return"paymentRefusalBankNotSupported";case"11":return"paymentRefusal3dsecureAuthFailed";case"12":return"paymentRefusalNoEnoughBalance";case"14":case"20":case"31":return"paymentRefusalFraudDetected";case"15":case"16":return"paymentRefusalCancelled";case"17":return"paymentRefusalInvalidPin";case"18":return"paymentRefusalPinRetryExceeded";case"19":return"paymentRefusalUnableValidatePin";case"21":return"paymentRefusalSubmmissionAdyen";case"24":return"paymentRefusalCvcDeclined";case"25":return"paymentRefusalRestrictedCard";case"27":return"paymentRefusalDoNotHonor";case"28":return"paymentRefusalWdrwAmountExceeded";case"29":return"paymentRefusalWdrwCountExceeded";case"32":return"paymentRefusalAvsDeclined";case"33":return"paymentRefusalCardOnlinePin";case"34":case"35":return"paymentRefusalNoAcctAtchdCard";case"36":return"paymentRefusalMobilePin";case"37":return"paymentRefusalContactlessFallback";case"38":return"paymentRefusalAuthRequired";default:return null}}function o(e){switch(e){case"Cancelled":return"paymentResultCancelled";case"Error":return"paymentResultError";case"Refused":return"paymentResultRefused";default:return null}}function c(e,a){if(l(e))switch(e.response.data.errorCode){case t.ErrorCode.AuthorizeDataNotValid:return["paymentAuthorizeDataNotValid",{checkoutId:a}];case t.ErrorCode.AuthorizeErrorUnknownReason:return["paymentAuthorizeErrorUnknownReason",{checkoutId:a}];case t.ErrorCode.AuthorizeCheckoutCaptured:return["paymentAuthorizeCheckoutCaptured",{checkoutId:a}];case t.ErrorCode.AuthorizeCheckoutAuthorized:return["paymentAuthorizeCheckoutAuthorized",{checkoutId:a}];case t.ErrorCode.AuthorizeCaptureFailure:return["paymentAuthorizeCaptureFailure",{checkoutId:a}];case t.ErrorCode.AuthorizeCancelOrRefund:return["paymentAuthorizeCancelOrRefund",{checkoutId:a}];case t.ErrorCode.ActionErrorUnknownReason:return["paymentActionErrorUnknownReason",{checkoutId:a}];case t.ErrorCode.ActionInvalidData:return["paymentActionInvalidData",{checkoutId:a}];case t.ErrorCode.ActionCaptureFailure:return["paymentActionCaptureFailure",{checkoutId:a}];case t.ErrorCode.ActionCancelOrRefund:return["paymentActionCancelOrRefund",{checkoutId:a}];case t.ErrorCode.AppNotFound:return["paymentPaymentAppNotFound",{checkoutId:a}];case t.ErrorCode.PaymentCheckoutCreated:return["paymentPaymentCheckoutCreated",{checkoutId:a}];case t.ErrorCode.PaymentAuthorizeNoItems:return["paymentAuthorizeNoItems",{checkoutId:a}];case t.ErrorCode.PaymentAuthorizeInvalidCustomer:return["paymentAuthorizeInvalidCustomer",{checkoutId:a}];case t.ErrorCode.PaymentAuthorizeInvalidDelivery:return["paymentAuthorizeInvalidDelivery",{checkoutId:a}];case t.ErrorCode.CheckoutPenguinInvalidStation:return["paymentCheckoutPaymentFailure",{checkoutId:a}];case t.ErrorCode.CheckoutPenguinInvalidTimeSlot:return["paymentPenguinInvalidTimeSlot",{checkoutId:a}];case t.ErrorCode.CheckoutPenguinNotEnoughLockers:return["paymentPenguinNotEnoughLockers",{checkoutId:a}];case t.ErrorCode.CheckoutPenguinTooManyItems:return["paymentPenguinTooManyItems",{checkoutId:a}];case t.ErrorCode.CheckoutPenguinProductInvalidUnits:return["paymentPenguinProductInvalidUnits",{checkoutId:a}]}else{const u=m(e==null?void 0:e.refusalReasonCode);if(u)return[u,{checkoutId:a}];const n=o(e==null?void 0:e.resultCode);if(n)return[n,{checkoutId:a}]}return["paymentCheckoutPaymentFailure",{checkoutId:a}]}function p(e,a,u=d){const[n,r]=c(e,a),i=u[n]({key:n,meta:r});if(!i)throw new Error("Could not resolve translation in getCheckoutPaymentErrorTexts()");return[i,n]}exports.CheckoutPaymentErrorTranslationKey=s;exports.default=p;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("@ancon/wildcat-types");require("axios");const l=require("../error/isSerializedAPIError.js");var s=(e=>(e.PaymentRefusalGeneral="paymentRefusalGeneral",e.PaymentRefusalTransactionRefused="paymentRefusalTransactionRefused",e.PaymentRefusalReferral="paymentRefusalReferral",e.PaymentRefusalAcquirer="paymentRefusalAcquirer",e.PaymentRefusalBlockedCard="paymentRefusalBlockedCard",e.PaymentRefusalExpiredCard="paymentRefusalExpiredCard",e.PaymentRefusalInvalidAmount="paymentRefusalInvalidAmount",e.PaymentRefusalInvalidCardnumber="paymentRefusalInvalidCardnumber",e.PaymentRefusalIssuerUnavailable="paymentRefusalIssuerUnavailable",e.PaymentRefusalBankNotSupported="paymentRefusalBankNotSupported",e.PaymentRefusal3dsecureAuthFailed="paymentRefusal3dsecureAuthFailed",e.PaymentRefusalNoEnoughBalance="paymentRefusalNoEnoughBalance",e.PaymentRefusalFraudDetected="paymentRefusalFraudDetected",e.PaymentRefusalCancelled="paymentRefusalCancelled",e.PaymentRefusalInvalidPin="paymentRefusalInvalidPin",e.PaymentRefusalPinRetryExceeded="paymentRefusalPinRetryExceeded",e.PaymentRefusalUnableValidatePin="paymentRefusalUnableValidatePin",e.PaymentRefusalSubmmissionAdyen="paymentRefusalSubmmissionAdyen",e.PaymentRefusalCvcDeclined="paymentRefusalCvcDeclined",e.PaymentRefusalRestrictedCard="paymentRefusalRestrictedCard",e.PaymentRefusalDoNotHonor="paymentRefusalDoNotHonor",e.PaymentRefusalWdrwAmountExceeded="paymentRefusalWdrwAmountExceeded",e.PaymentRefusalWdrwCountExceeded="paymentRefusalWdrwCountExceeded",e.PaymentRefusalAvsDeclined="paymentRefusalAvsDeclined",e.PaymentRefusalCardOnlinePin="paymentRefusalCardOnlinePin",e.PaymentRefusalNoAcctAtchdCard="paymentRefusalNoAcctAtchdCard",e.PaymentRefusalMobilePin="paymentRefusalMobilePin",e.PaymentRefusalContactlessFallback="paymentRefusalContactlessFallback",e.PaymentRefusalAuthRequired="paymentRefusalAuthRequired",e.PaymentResultCancelled="paymentResultCancelled",e.PaymentResultError="paymentResultError",e.PaymentResultRefused="paymentResultRefused",e.PaymentAuthorizeDataNotValid="paymentAuthorizeDataNotValid",e.PaymentAuthorizeErrorUnknownReason="paymentAuthorizeErrorUnknownReason",e.PaymentAuthorizeCheckoutCaptured="paymentAuthorizeCheckoutCaptured",e.PaymentAuthorizeCheckoutAuthorized="paymentAuthorizeCheckoutAuthorized",e.PaymentAuthorizeCaptureFailure="paymentAuthorizeCaptureFailure",e.PaymentAuthorizeCancelOrRefund="paymentAuthorizeCancelOrRefund",e.PaymentActionErrorUnknownReason="paymentActionErrorUnknownReason",e.PaymentActionInvalidData="paymentActionInvalidData",e.PaymentActionCaptureFailure="paymentActionCaptureFailure",e.PaymentActionCancelOrRefund="paymentActionCancelOrRefund",e.PaymentPaymentAppNotFound="paymentPaymentAppNotFound",e.PaymentPaymentCheckoutCreated="paymentPaymentCheckoutCreated",e.PaymentCheckoutPaymentFailure="paymentCheckoutPaymentFailure",e.PaymentDetailsNotSupported="paymentDetailsNotSupported",e.PaymentAuthorizeNoItems="paymentAuthorizeNoItems",e.PaymentAuthorizeInvalidCustomer="paymentAuthorizeInvalidCustomer",e.PaymentAuthorizeInvalidDelivery="paymentAuthorizeInvalidDelivery",e.PaymentPenguinInvalidStation="paymentPenguinInvalidStation",e.PaymentPenguinInvalidTimeSlot="paymentPenguinInvalidTimeSlot",e.PaymentPenguinNotEnoughLockers="paymentPenguinNotEnoughLockers",e.PaymentPenguinTooManyItems="paymentPenguinTooManyItems",e.PaymentPenguinProductInvalidUnits="paymentPenguinProductInvalidUnits",e.PaymentCheckoutServiceTimeInPast="paymentCheckoutServiceTimeInPast",e))(s||{});const d={paymentRefusalGeneral:()=>({title:"Payment failure",message:"The transaction was refused."}),paymentRefusalTransactionRefused:()=>({title:"Payment failure",message:"The transaction was refused."}),paymentRefusalReferral:({meta:e})=>({title:"Payment failure",message:`A referral error occurred. (${e.checkoutId})`}),paymentRefusalAcquirer:({meta:e})=>({title:"Payment failure",message:`An acquirer error occurred. (${e.checkoutId})`}),paymentRefusalBlockedCard:()=>({title:"Payment failure",message:"The provided card is blocked."}),paymentRefusalExpiredCard:()=>({title:"Payment failure",message:"The provided card is expired."}),paymentRefusalInvalidAmount:()=>({title:"Payment failure",message:"An invalid payment amount was provided."}),paymentRefusalInvalidCardnumber:()=>({title:"Payment failure",message:"An invalid card number was provided."}),paymentRefusalIssuerUnavailable:()=>({title:"Payment failure",message:"Card issuer not available."}),paymentRefusalBankNotSupported:()=>({title:"Payment failure",message:"CVC declined."}),paymentRefusal3dsecureAuthFailed:()=>({title:"Payment failure",message:"3D Secure was not authenticated."}),paymentRefusalNoEnoughBalance:()=>({title:"Payment failure",message:"Not enough balance."}),paymentRefusalFraudDetected:()=>({title:"Payment failure",message:"The provided card is not allowed."}),paymentRefusalCancelled:()=>({title:"Payment cancelled",message:"The payment was cancelled."}),paymentRefusalInvalidPin:()=>({title:"Payment failure",message:"Invalid PIN."}),paymentRefusalPinRetryExceeded:()=>({title:"Payment failure",message:"PIN tries exceeded."}),paymentRefusalUnableValidatePin:()=>({title:"Payment failure",message:"PIN validation was not possible."}),paymentRefusalSubmmissionAdyen:({meta:e})=>({title:"Payment failure",message:`Submission error. (${e.checkoutId})`}),paymentRefusalCvcDeclined:()=>({title:"Payment failure",message:"CVC declined."}),paymentRefusalRestrictedCard:()=>({title:"Payment failure",message:"Restricted card."}),paymentRefusalDoNotHonor:({meta:e})=>({title:"Payment failure",message:`The transaction was refused (do not honor). (${e.checkoutId})`}),paymentRefusalWdrwAmountExceeded:()=>({title:"Payment failure",message:"Withdrawal amount exceeded."}),paymentRefusalWdrwCountExceeded:()=>({title:"Payment failure",message:"Withdrawal count exceeded."}),paymentRefusalAvsDeclined:()=>({title:"Payment failure",message:"AVS declined."}),paymentRefusalCardOnlinePin:()=>({title:"Payment failure",message:"The provided card requires online PIN."}),paymentRefusalNoAcctAtchdCard:()=>({title:"Payment failure",message:"No account attached to the provided card."}),paymentRefusalMobilePin:()=>({title:"Payment failure",message:"Mobile PIN required."}),paymentRefusalContactlessFallback:()=>({title:"Payment failure",message:"Contactless fallback."}),paymentRefusalAuthRequired:()=>({title:"Payment failure",message:"Authentication required"}),paymentResultCancelled:()=>({title:"Payment cancelled",message:"The payment was cancelled."}),paymentResultError:({meta:e})=>({title:"Payment error",message:`There was an error processing your payment. (${e.checkoutId})`}),paymentResultRefused:()=>({title:"Payment refused",message:"The payment was refused."}),paymentAuthorizeDataNotValid:({meta:e})=>({title:"Authorization failed",message:`The provided data was invalid. (${e.checkoutId})`}),paymentAuthorizeErrorUnknownReason:({meta:e})=>({title:"Authorization failed",message:`Authorization failed because of an unknown error. (${e.checkoutId})`}),paymentAuthorizeCheckoutCaptured:({meta:e})=>({title:"Authorization failed",message:`The checkout has already been captured. (${e.checkoutId})`}),paymentAuthorizeCheckoutAuthorized:({meta:e})=>({title:"Authorization failed",message:`The checkout has already been authorized. (${e.checkoutId})`}),paymentAuthorizeCaptureFailure:({meta:e})=>({title:"Authorization failed",message:`Failed to capture checkout. (${e.checkoutId})`}),paymentAuthorizeCancelOrRefund:()=>({title:"Authorization failed",message:"The checkout has already been cancelled or refunded."}),paymentActionErrorUnknownReason:({meta:e})=>({title:"Action failed",message:`The action failed because of an unknown error. (${e.checkoutId})`}),paymentActionInvalidData:({meta:e})=>({title:"Action failed",message:`The provided data was invalid. (${e.checkoutId})`}),paymentActionCaptureFailure:({meta:e})=>({title:"Action failed",message:`Failed to capture checkout. (${e.checkoutId})`}),paymentActionCancelOrRefund:()=>({title:"Action failed",message:"The checkout has already been cancelled or refunded."}),paymentPaymentAppNotFound:()=>({title:"Payment failure",message:"The chosen payment method requires an app which is not installed."}),paymentPaymentCheckoutCreated:({meta:e})=>({title:"Payment failure",message:`The checkout is created, cannot make payment, make sure the customer is connected to this checkout. (${e.checkoutId})`}),paymentCheckoutPaymentFailure:({meta:e})=>({title:"Payment failure",message:`Unfortunately an error has occurred and your payment cannot be processed. (${e.checkoutId})`}),paymentDetailsNotSupported:()=>({title:"Payment failure",message:"The payment provider is not supported by this outlet."}),paymentAuthorizeNoItems:({meta:e})=>({title:"Payment failure",message:`The current checkout does not contain any products. (${e.checkoutId})`}),paymentAuthorizeInvalidCustomer:({meta:e})=>({title:"Payment failure",message:`Could not resolve the customer from database. (${e.checkoutId})`}),paymentAuthorizeInvalidDelivery:({meta:e})=>({title:"Payment failure",message:`Missing delivery information. (${e.checkoutId})`}),paymentPenguinInvalidStation:()=>({title:"Payment failure",message:"Invalid station."}),paymentPenguinInvalidTimeSlot:()=>({title:"Payment failure",message:"Invalid time slot."}),paymentPenguinNotEnoughLockers:()=>({title:"Payment failure",message:"Not enough lockers."}),paymentPenguinTooManyItems:()=>({title:"Payment failure",message:"The current checkout has too many items."}),paymentPenguinProductInvalidUnits:({meta:e})=>({title:"Payment failure",message:`The current checkout does not contain valid product storage configurations. (${e.checkoutId})`}),paymentCheckoutServiceTimeInPast:({meta:e})=>({title:"Payment failure",message:`The order time cannot be in the past. (${e.checkoutId})`})};function m(e){switch(e){case"0":return"paymentRefusalGeneral";case"2":case"23":return"paymentRefusalTransactionRefused";case"3":return"paymentRefusalReferral";case"4":return"paymentRefusalAcquirer";case"5":return"paymentRefusalBlockedCard";case"6":return"paymentRefusalExpiredCard";case"7":return"paymentRefusalInvalidAmount";case"8":return"paymentRefusalInvalidCardnumber";case"9":return"paymentRefusalIssuerUnavailable";case"10":return"paymentRefusalBankNotSupported";case"11":return"paymentRefusal3dsecureAuthFailed";case"12":return"paymentRefusalNoEnoughBalance";case"14":case"20":case"31":return"paymentRefusalFraudDetected";case"15":case"16":return"paymentRefusalCancelled";case"17":return"paymentRefusalInvalidPin";case"18":return"paymentRefusalPinRetryExceeded";case"19":return"paymentRefusalUnableValidatePin";case"21":return"paymentRefusalSubmmissionAdyen";case"24":return"paymentRefusalCvcDeclined";case"25":return"paymentRefusalRestrictedCard";case"27":return"paymentRefusalDoNotHonor";case"28":return"paymentRefusalWdrwAmountExceeded";case"29":return"paymentRefusalWdrwCountExceeded";case"32":return"paymentRefusalAvsDeclined";case"33":return"paymentRefusalCardOnlinePin";case"34":case"35":return"paymentRefusalNoAcctAtchdCard";case"36":return"paymentRefusalMobilePin";case"37":return"paymentRefusalContactlessFallback";case"38":return"paymentRefusalAuthRequired";default:return null}}function o(e){switch(e){case"Cancelled":return"paymentResultCancelled";case"Error":return"paymentResultError";case"Refused":return"paymentResultRefused";default:return null}}function c(e,a){if(l(e))switch(e.response.data.errorCode){case t.ErrorCode.AuthorizeDataNotValid:return["paymentAuthorizeDataNotValid",{checkoutId:a}];case t.ErrorCode.AuthorizeErrorUnknownReason:return["paymentAuthorizeErrorUnknownReason",{checkoutId:a}];case t.ErrorCode.AuthorizeCheckoutCaptured:return["paymentAuthorizeCheckoutCaptured",{checkoutId:a}];case t.ErrorCode.AuthorizeCheckoutAuthorized:return["paymentAuthorizeCheckoutAuthorized",{checkoutId:a}];case t.ErrorCode.AuthorizeCaptureFailure:return["paymentAuthorizeCaptureFailure",{checkoutId:a}];case t.ErrorCode.AuthorizeCancelOrRefund:return["paymentAuthorizeCancelOrRefund",{checkoutId:a}];case t.ErrorCode.ActionErrorUnknownReason:return["paymentActionErrorUnknownReason",{checkoutId:a}];case t.ErrorCode.ActionInvalidData:return["paymentActionInvalidData",{checkoutId:a}];case t.ErrorCode.ActionCaptureFailure:return["paymentActionCaptureFailure",{checkoutId:a}];case t.ErrorCode.ActionCancelOrRefund:return["paymentActionCancelOrRefund",{checkoutId:a}];case t.ErrorCode.AppNotFound:return["paymentPaymentAppNotFound",{checkoutId:a}];case t.ErrorCode.PaymentCheckoutCreated:return["paymentPaymentCheckoutCreated",{checkoutId:a}];case t.ErrorCode.PaymentAuthorizeNoItems:return["paymentAuthorizeNoItems",{checkoutId:a}];case t.ErrorCode.PaymentAuthorizeInvalidCustomer:return["paymentAuthorizeInvalidCustomer",{checkoutId:a}];case t.ErrorCode.PaymentAuthorizeInvalidDelivery:return["paymentAuthorizeInvalidDelivery",{checkoutId:a}];case t.ErrorCode.CheckoutPenguinInvalidStation:return["paymentCheckoutPaymentFailure",{checkoutId:a}];case t.ErrorCode.CheckoutPenguinInvalidTimeSlot:return["paymentPenguinInvalidTimeSlot",{checkoutId:a}];case t.ErrorCode.CheckoutPenguinNotEnoughLockers:return["paymentPenguinNotEnoughLockers",{checkoutId:a}];case t.ErrorCode.CheckoutPenguinTooManyItems:return["paymentPenguinTooManyItems",{checkoutId:a}];case t.ErrorCode.CheckoutPenguinProductInvalidUnits:return["paymentPenguinProductInvalidUnits",{checkoutId:a}];case t.ErrorCode.ServiceTimeInThePast:return["paymentCheckoutServiceTimeInPast",{checkoutId:a}]}else{const u=m(e==null?void 0:e.refusalReasonCode);if(u)return[u,{checkoutId:a}];const n=o(e==null?void 0:e.resultCode);if(n)return[n,{checkoutId:a}]}return["paymentCheckoutPaymentFailure",{checkoutId:a}]}function p(e,a,u=d){const[n,r]=c(e,a),i=u[n]({key:n,meta:r});if(!i)throw new Error("Could not resolve translation in getCheckoutPaymentErrorTexts()");return[i,n]}exports.CheckoutPaymentErrorTranslationKey=s;exports.default=p;
@@ -1,7 +1,7 @@
1
1
  import { ErrorCode as t } from "@ancon/wildcat-types";
2
2
  import "axios";
3
3
  import l from "../error/isSerializedAPIError.mjs";
4
- var r = /* @__PURE__ */ ((e) => (e.PaymentRefusalGeneral = "paymentRefusalGeneral", e.PaymentRefusalTransactionRefused = "paymentRefusalTransactionRefused", e.PaymentRefusalReferral = "paymentRefusalReferral", e.PaymentRefusalAcquirer = "paymentRefusalAcquirer", e.PaymentRefusalBlockedCard = "paymentRefusalBlockedCard", e.PaymentRefusalExpiredCard = "paymentRefusalExpiredCard", e.PaymentRefusalInvalidAmount = "paymentRefusalInvalidAmount", e.PaymentRefusalInvalidCardnumber = "paymentRefusalInvalidCardnumber", e.PaymentRefusalIssuerUnavailable = "paymentRefusalIssuerUnavailable", e.PaymentRefusalBankNotSupported = "paymentRefusalBankNotSupported", e.PaymentRefusal3dsecureAuthFailed = "paymentRefusal3dsecureAuthFailed", e.PaymentRefusalNoEnoughBalance = "paymentRefusalNoEnoughBalance", e.PaymentRefusalFraudDetected = "paymentRefusalFraudDetected", e.PaymentRefusalCancelled = "paymentRefusalCancelled", e.PaymentRefusalInvalidPin = "paymentRefusalInvalidPin", e.PaymentRefusalPinRetryExceeded = "paymentRefusalPinRetryExceeded", e.PaymentRefusalUnableValidatePin = "paymentRefusalUnableValidatePin", e.PaymentRefusalSubmmissionAdyen = "paymentRefusalSubmmissionAdyen", e.PaymentRefusalCvcDeclined = "paymentRefusalCvcDeclined", e.PaymentRefusalRestrictedCard = "paymentRefusalRestrictedCard", e.PaymentRefusalDoNotHonor = "paymentRefusalDoNotHonor", e.PaymentRefusalWdrwAmountExceeded = "paymentRefusalWdrwAmountExceeded", e.PaymentRefusalWdrwCountExceeded = "paymentRefusalWdrwCountExceeded", e.PaymentRefusalAvsDeclined = "paymentRefusalAvsDeclined", e.PaymentRefusalCardOnlinePin = "paymentRefusalCardOnlinePin", e.PaymentRefusalNoAcctAtchdCard = "paymentRefusalNoAcctAtchdCard", e.PaymentRefusalMobilePin = "paymentRefusalMobilePin", e.PaymentRefusalContactlessFallback = "paymentRefusalContactlessFallback", e.PaymentRefusalAuthRequired = "paymentRefusalAuthRequired", e.PaymentResultCancelled = "paymentResultCancelled", e.PaymentResultError = "paymentResultError", e.PaymentResultRefused = "paymentResultRefused", e.PaymentAuthorizeDataNotValid = "paymentAuthorizeDataNotValid", e.PaymentAuthorizeErrorUnknownReason = "paymentAuthorizeErrorUnknownReason", e.PaymentAuthorizeCheckoutCaptured = "paymentAuthorizeCheckoutCaptured", e.PaymentAuthorizeCheckoutAuthorized = "paymentAuthorizeCheckoutAuthorized", e.PaymentAuthorizeCaptureFailure = "paymentAuthorizeCaptureFailure", e.PaymentAuthorizeCancelOrRefund = "paymentAuthorizeCancelOrRefund", e.PaymentActionErrorUnknownReason = "paymentActionErrorUnknownReason", e.PaymentActionInvalidData = "paymentActionInvalidData", e.PaymentActionCaptureFailure = "paymentActionCaptureFailure", e.PaymentActionCancelOrRefund = "paymentActionCancelOrRefund", e.PaymentPaymentAppNotFound = "paymentPaymentAppNotFound", e.PaymentPaymentCheckoutCreated = "paymentPaymentCheckoutCreated", e.PaymentCheckoutPaymentFailure = "paymentCheckoutPaymentFailure", e.PaymentDetailsNotSupported = "paymentDetailsNotSupported", e.PaymentAuthorizeNoItems = "paymentAuthorizeNoItems", e.PaymentAuthorizeInvalidCustomer = "paymentAuthorizeInvalidCustomer", e.PaymentAuthorizeInvalidDelivery = "paymentAuthorizeInvalidDelivery", e.PaymentPenguinInvalidStation = "paymentPenguinInvalidStation", e.PaymentPenguinInvalidTimeSlot = "paymentPenguinInvalidTimeSlot", e.PaymentPenguinNotEnoughLockers = "paymentPenguinNotEnoughLockers", e.PaymentPenguinTooManyItems = "paymentPenguinTooManyItems", e.PaymentPenguinProductInvalidUnits = "paymentPenguinProductInvalidUnits", e))(r || {});
4
+ var r = /* @__PURE__ */ ((e) => (e.PaymentRefusalGeneral = "paymentRefusalGeneral", e.PaymentRefusalTransactionRefused = "paymentRefusalTransactionRefused", e.PaymentRefusalReferral = "paymentRefusalReferral", e.PaymentRefusalAcquirer = "paymentRefusalAcquirer", e.PaymentRefusalBlockedCard = "paymentRefusalBlockedCard", e.PaymentRefusalExpiredCard = "paymentRefusalExpiredCard", e.PaymentRefusalInvalidAmount = "paymentRefusalInvalidAmount", e.PaymentRefusalInvalidCardnumber = "paymentRefusalInvalidCardnumber", e.PaymentRefusalIssuerUnavailable = "paymentRefusalIssuerUnavailable", e.PaymentRefusalBankNotSupported = "paymentRefusalBankNotSupported", e.PaymentRefusal3dsecureAuthFailed = "paymentRefusal3dsecureAuthFailed", e.PaymentRefusalNoEnoughBalance = "paymentRefusalNoEnoughBalance", e.PaymentRefusalFraudDetected = "paymentRefusalFraudDetected", e.PaymentRefusalCancelled = "paymentRefusalCancelled", e.PaymentRefusalInvalidPin = "paymentRefusalInvalidPin", e.PaymentRefusalPinRetryExceeded = "paymentRefusalPinRetryExceeded", e.PaymentRefusalUnableValidatePin = "paymentRefusalUnableValidatePin", e.PaymentRefusalSubmmissionAdyen = "paymentRefusalSubmmissionAdyen", e.PaymentRefusalCvcDeclined = "paymentRefusalCvcDeclined", e.PaymentRefusalRestrictedCard = "paymentRefusalRestrictedCard", e.PaymentRefusalDoNotHonor = "paymentRefusalDoNotHonor", e.PaymentRefusalWdrwAmountExceeded = "paymentRefusalWdrwAmountExceeded", e.PaymentRefusalWdrwCountExceeded = "paymentRefusalWdrwCountExceeded", e.PaymentRefusalAvsDeclined = "paymentRefusalAvsDeclined", e.PaymentRefusalCardOnlinePin = "paymentRefusalCardOnlinePin", e.PaymentRefusalNoAcctAtchdCard = "paymentRefusalNoAcctAtchdCard", e.PaymentRefusalMobilePin = "paymentRefusalMobilePin", e.PaymentRefusalContactlessFallback = "paymentRefusalContactlessFallback", e.PaymentRefusalAuthRequired = "paymentRefusalAuthRequired", e.PaymentResultCancelled = "paymentResultCancelled", e.PaymentResultError = "paymentResultError", e.PaymentResultRefused = "paymentResultRefused", e.PaymentAuthorizeDataNotValid = "paymentAuthorizeDataNotValid", e.PaymentAuthorizeErrorUnknownReason = "paymentAuthorizeErrorUnknownReason", e.PaymentAuthorizeCheckoutCaptured = "paymentAuthorizeCheckoutCaptured", e.PaymentAuthorizeCheckoutAuthorized = "paymentAuthorizeCheckoutAuthorized", e.PaymentAuthorizeCaptureFailure = "paymentAuthorizeCaptureFailure", e.PaymentAuthorizeCancelOrRefund = "paymentAuthorizeCancelOrRefund", e.PaymentActionErrorUnknownReason = "paymentActionErrorUnknownReason", e.PaymentActionInvalidData = "paymentActionInvalidData", e.PaymentActionCaptureFailure = "paymentActionCaptureFailure", e.PaymentActionCancelOrRefund = "paymentActionCancelOrRefund", e.PaymentPaymentAppNotFound = "paymentPaymentAppNotFound", e.PaymentPaymentCheckoutCreated = "paymentPaymentCheckoutCreated", e.PaymentCheckoutPaymentFailure = "paymentCheckoutPaymentFailure", e.PaymentDetailsNotSupported = "paymentDetailsNotSupported", e.PaymentAuthorizeNoItems = "paymentAuthorizeNoItems", e.PaymentAuthorizeInvalidCustomer = "paymentAuthorizeInvalidCustomer", e.PaymentAuthorizeInvalidDelivery = "paymentAuthorizeInvalidDelivery", e.PaymentPenguinInvalidStation = "paymentPenguinInvalidStation", e.PaymentPenguinInvalidTimeSlot = "paymentPenguinInvalidTimeSlot", e.PaymentPenguinNotEnoughLockers = "paymentPenguinNotEnoughLockers", e.PaymentPenguinTooManyItems = "paymentPenguinTooManyItems", e.PaymentPenguinProductInvalidUnits = "paymentPenguinProductInvalidUnits", e.PaymentCheckoutServiceTimeInPast = "paymentCheckoutServiceTimeInPast", e))(r || {});
5
5
  const m = {
6
6
  paymentRefusalGeneral: () => ({
7
7
  title: "Payment failure",
@@ -218,6 +218,10 @@ const m = {
218
218
  paymentPenguinProductInvalidUnits: ({ meta: e }) => ({
219
219
  title: "Payment failure",
220
220
  message: `The current checkout does not contain valid product storage configurations. (${e.checkoutId})`
221
+ }),
222
+ paymentCheckoutServiceTimeInPast: ({ meta: e }) => ({
223
+ title: "Payment failure",
224
+ message: `The order time cannot be in the past. (${e.checkoutId})`
221
225
  })
222
226
  };
223
227
  function d(e) {
@@ -404,6 +408,11 @@ function c(e, a) {
404
408
  "paymentPenguinProductInvalidUnits",
405
409
  { checkoutId: a }
406
410
  ];
411
+ case t.ServiceTimeInThePast:
412
+ return [
413
+ "paymentCheckoutServiceTimeInPast",
414
+ { checkoutId: a }
415
+ ];
407
416
  }
408
417
  else {
409
418
  const u = d(
@@ -28,6 +28,7 @@ declare class HangfirePoller {
28
28
  constructor(options?: Partial<HangfirePollerConfig>);
29
29
  private stopTimer;
30
30
  private startTimer;
31
+ private waitForNetworkOnline;
31
32
  private executeWorkerRequest;
32
33
  private deleteWorker;
33
34
  createWorker(groupId: string, { workerId, url, headers, }: {
@@ -1 +1 @@
1
- "use strict";var f=Object.defineProperty;var p=(i,e,r)=>e in i?f(i,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):i[e]=r;var o=(i,e,r)=>(p(i,typeof e!="symbol"?e+"":e,r),r);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const b=require("axios"),n=require("@ancon/wildcat-types"),u=require("../error/createCodedError.js"),m=require("../api/isNoContentResponse.js");class g{constructor(e){o(this,"busyWorkers",new Set);o(this,"enabledGroups",new Set);o(this,"groups",new Map);o(this,"workerByIdMap",new Map);o(this,"timer",null);o(this,"config",{maxGroupsSize:50,maxWorkersSize:20,getIsNetworkOnline(){return!0},async getRequestHeaders(){return{}},debug(...e){console.log(...e)}});this.config={...this.config,...e??null}}stopTimer(){this.timer!=null&&(this.config.debug("*stop timer*"),clearInterval(this.timer),this.timer=null)}startTimer(){if(this.timer!=null)throw u(new Error("Timer already started"),n.ErrorCode.GenericUnexpectedHangfireError);this.config.debug("*start timer*"),this.timer=setInterval(()=>{this.config.debug("*tick*",{busyWorkers:this.busyWorkers.size,enabledGroups:this.enabledGroups.size,groups:this.groups}),this.enabledGroups.forEach(e=>{const r=this.groups.get(e);r&&r.forEach(s=>this.executeWorkerRequest(s))}),this.groups.size<1&&this.stopTimer()},5e3)}async executeWorkerRequest(e,r=!1){const s=this.config.getIsNetworkOnline();!(r!==!0&&this.busyWorkers.has(e.workerId))&&s&&(this.busyWorkers.add(e.workerId),b({url:e.url,method:"get",headers:{...await this.config.getRequestHeaders(),...e.headers}}).then(t=>{t&&!m(t)?(e.resolve(t),this.deleteWorker(e.groupId,e.workerId)):this.busyWorkers.delete(e.workerId)}).catch(t=>{e.reject(t),this.deleteWorker(e.groupId,e.workerId)}))}deleteWorker(e,r){const s=this.groups.get(e);s&&(this.config.debug("*delete worker*",s.size,s),s.delete(r),this.workerByIdMap.delete(r),this.busyWorkers.delete(r),s.size<1&&(this.groups.delete(e),this.enabledGroups.delete(e),this.enabledGroups.size<1&&this.stopTimer()))}createWorker(e,{workerId:r,url:s,headers:h}){if(!this.groups.has(e)){if(this.groups.size>=this.config.maxGroupsSize){const a=u(new Error("Max number of Hangfire groups exceeded"),n.ErrorCode.GenericUnexpectedHangfireError,{count:this.groups.size});throw this.destroy(),a}this.groups.set(e,new Map)}const t=this.groups.get(e);return new Promise((a,l)=>{if(t.has(r))throw u(new Error("Duplicate Hangfire worker ID"),n.ErrorCode.GenericUnexpectedHangfireError);if(t.size>=this.config.maxWorkersSize){const c=u(new Error("Max number of Hangfire workers in group exceeded"),n.ErrorCode.GenericUnexpectedHangfireError,{groupId:e,count:t.size});throw l(c),this.destroy(),c}const d={workerId:r,groupId:e,url:s,resolve:a,reject:l,headers:h};t.set(r,d),this.workerByIdMap.set(r,d),this.enabledGroups.has(e)||this.enabledGroups.add(e),this.timer==null&&this.enabledGroups.size>0&&this.startTimer()})}triggerWorker(e){this.config.debug("*triggerWorker*");const r=this.workerByIdMap.get(e);r&&this.executeWorkerRequest(r,!0)}enableWorkers(e){this.config.debug("*enable*",e),this.enabledGroups.add(e),this.groups.has(e)&&this.timer==null&&this.startTimer()}disableWorkers(e){this.config.debug("*disable*",e),this.enabledGroups.delete(e),this.enabledGroups.size<1&&this.stopTimer()}destroy(){this.config.debug("*destroy*"),this.groups.clear(),this.stopTimer()}}function k(i){return new g(i)}exports.HangfirePoller=g;exports.default=k;
1
+ "use strict";var f=Object.defineProperty;var p=(s,e,r)=>e in s?f(s,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):s[e]=r;var o=(s,e,r)=>(p(s,typeof e!="symbol"?e+"":e,r),r);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const b=require("axios"),u=require("@ancon/wildcat-types"),a=require("../error/createCodedError.js"),k=require("../api/isNoContentResponse.js"),w=require("../shared/wait.js");class g{constructor(e){o(this,"busyWorkers",new Set);o(this,"enabledGroups",new Set);o(this,"groups",new Map);o(this,"workerByIdMap",new Map);o(this,"timer",null);o(this,"config",{maxGroupsSize:50,maxWorkersSize:20,getIsNetworkOnline(){return!0},async getRequestHeaders(){return{}},debug(...e){console.log(...e)}});this.config={...this.config,...e??null}}stopTimer(){this.timer!=null&&(this.config.debug("*stop timer*"),clearInterval(this.timer),this.timer=null)}startTimer(){if(this.timer!=null)throw a(new Error("Timer already started"),u.ErrorCode.GenericUnexpectedHangfireError);this.config.debug("*start timer*"),this.timer=setInterval(()=>{this.config.debug("*tick*",{busyWorkers:this.busyWorkers.size,enabledGroups:this.enabledGroups.size,groups:this.groups}),this.enabledGroups.forEach(e=>{const r=this.groups.get(e);r&&r.forEach(t=>this.executeWorkerRequest(t))}),this.groups.size<1&&this.stopTimer()},5e3)}async waitForNetworkOnline(e=5){let r=0;for(;!this.config.getIsNetworkOnline()&&r<e+1;)r+=1,await w(1e3)}async executeWorkerRequest(e,r=!1){const t=r!==!0&&this.busyWorkers.has(e.workerId);this.config.debug("*executeWorkerRequest*",{workerId:e.workerId,isBusy:t,force:r}),t?this.config.debug("*executeWorkerRequest* worker is busy",e.workerId):(this.busyWorkers.add(e.workerId),await this.waitForNetworkOnline(),this.config.debug("*executeWorkerRequest* request",{isNetworkOnline:this.config.getIsNetworkOnline()}),b({url:e.url,method:"get",headers:{...await this.config.getRequestHeaders(),...e.headers}}).then(i=>{i&&!k(i)?(e.resolve(i),this.deleteWorker(e.groupId,e.workerId)):this.busyWorkers.delete(e.workerId)}).catch(i=>{e.reject(i),this.deleteWorker(e.groupId,e.workerId)}))}deleteWorker(e,r){const t=this.groups.get(e);t&&(this.config.debug("*delete worker*",t.size,t),t.delete(r),this.workerByIdMap.delete(r),this.busyWorkers.delete(r),t.size<1&&(this.groups.delete(e),this.enabledGroups.delete(e),this.enabledGroups.size<1&&this.stopTimer()))}createWorker(e,{workerId:r,url:t,headers:i}){if(!this.groups.has(e)){if(this.groups.size>=this.config.maxGroupsSize){const h=a(new Error("Max number of Hangfire groups exceeded"),u.ErrorCode.GenericUnexpectedHangfireError,{count:this.groups.size});throw this.destroy(),h}this.groups.set(e,new Map)}const n=this.groups.get(e);return new Promise((h,l)=>{if(n.has(r))throw a(new Error("Duplicate Hangfire worker ID"),u.ErrorCode.GenericUnexpectedHangfireError);if(n.size>=this.config.maxWorkersSize){const c=a(new Error("Max number of Hangfire workers in group exceeded"),u.ErrorCode.GenericUnexpectedHangfireError,{groupId:e,count:n.size});throw l(c),this.destroy(),c}const d={workerId:r,groupId:e,url:t,resolve:h,reject:l,headers:i};n.set(r,d),this.workerByIdMap.set(r,d),this.enabledGroups.has(e)||this.enabledGroups.add(e),this.timer==null&&this.enabledGroups.size>0&&this.startTimer()})}triggerWorker(e){this.config.debug("*triggerWorker*");const r=this.workerByIdMap.get(e);r?this.executeWorkerRequest(r,!0):this.config.debug("*triggerWorker* worker not found",e)}enableWorkers(e){this.config.debug("*enable*",e),this.enabledGroups.add(e),this.groups.has(e)&&this.timer==null&&this.startTimer()}disableWorkers(e){this.config.debug("*disable*",e),this.enabledGroups.delete(e),this.enabledGroups.size<1&&this.stopTimer()}destroy(){this.config.debug("*destroy*"),this.groups.clear(),this.stopTimer()}}function m(s){return new g(s)}exports.HangfirePoller=g;exports.default=m;
@@ -1,11 +1,12 @@
1
- var g = Object.defineProperty;
2
- var f = (i, e, r) => e in i ? g(i, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : i[e] = r;
3
- var o = (i, e, r) => (f(i, typeof e != "symbol" ? e + "" : e, r), r);
1
+ var c = Object.defineProperty;
2
+ var f = (s, e, r) => e in s ? c(s, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : s[e] = r;
3
+ var o = (s, e, r) => (f(s, typeof e != "symbol" ? e + "" : e, r), r);
4
4
  import p from "axios";
5
- import { ErrorCode as n } from "@ancon/wildcat-types";
5
+ import { ErrorCode as a } from "@ancon/wildcat-types";
6
6
  import h from "../error/createCodedError.mjs";
7
- import m from "../api/isNoContentResponse.mjs";
8
- class b {
7
+ import b from "../api/isNoContentResponse.mjs";
8
+ import m from "../shared/wait.mjs";
9
+ class k {
9
10
  constructor(e) {
10
11
  /** Workers currently executing a request */
11
12
  o(this, "busyWorkers", /* @__PURE__ */ new Set());
@@ -41,7 +42,7 @@ class b {
41
42
  if (this.timer != null)
42
43
  throw h(
43
44
  new Error("Timer already started"),
44
- n.GenericUnexpectedHangfireError
45
+ a.GenericUnexpectedHangfireError
45
46
  );
46
47
  this.config.debug("*start timer*"), this.timer = setInterval(() => {
47
48
  this.config.debug("*tick*", {
@@ -50,76 +51,90 @@ class b {
50
51
  groups: this.groups
51
52
  }), this.enabledGroups.forEach((e) => {
52
53
  const r = this.groups.get(e);
53
- r && r.forEach((s) => this.executeWorkerRequest(s));
54
+ r && r.forEach((t) => this.executeWorkerRequest(t));
54
55
  }), this.groups.size < 1 && this.stopTimer();
55
56
  }, 5e3);
56
57
  }
58
+ async waitForNetworkOnline(e = 5) {
59
+ let r = 0;
60
+ for (; !this.config.getIsNetworkOnline() && r < e + 1; )
61
+ r += 1, await m(1e3);
62
+ }
57
63
  async executeWorkerRequest(e, r = !1) {
58
- const s = this.config.getIsNetworkOnline();
59
- !(r !== !0 && this.busyWorkers.has(e.workerId)) && s && (this.busyWorkers.add(e.workerId), p({
64
+ const t = r !== !0 && this.busyWorkers.has(e.workerId);
65
+ this.config.debug("*executeWorkerRequest*", {
66
+ workerId: e.workerId,
67
+ isBusy: t,
68
+ force: r
69
+ }), t ? this.config.debug(
70
+ "*executeWorkerRequest* worker is busy",
71
+ e.workerId
72
+ ) : (this.busyWorkers.add(e.workerId), await this.waitForNetworkOnline(), this.config.debug("*executeWorkerRequest* request", {
73
+ isNetworkOnline: this.config.getIsNetworkOnline()
74
+ }), p({
60
75
  url: e.url,
61
76
  method: "get",
62
77
  headers: {
63
78
  ...await this.config.getRequestHeaders(),
64
79
  ...e.headers
65
80
  }
66
- }).then((t) => {
67
- t && !m(t) ? (e.resolve(t), this.deleteWorker(e.groupId, e.workerId)) : this.busyWorkers.delete(e.workerId);
68
- }).catch((t) => {
69
- e.reject(t), this.deleteWorker(e.groupId, e.workerId);
81
+ }).then((i) => {
82
+ i && !b(i) ? (e.resolve(i), this.deleteWorker(e.groupId, e.workerId)) : this.busyWorkers.delete(e.workerId);
83
+ }).catch((i) => {
84
+ e.reject(i), this.deleteWorker(e.groupId, e.workerId);
70
85
  }));
71
86
  }
72
87
  deleteWorker(e, r) {
73
- const s = this.groups.get(e);
74
- s && (this.config.debug("*delete worker*", s.size, s), s.delete(r), this.workerByIdMap.delete(r), this.busyWorkers.delete(r), s.size < 1 && (this.groups.delete(e), this.enabledGroups.delete(e), this.enabledGroups.size < 1 && this.stopTimer()));
88
+ const t = this.groups.get(e);
89
+ t && (this.config.debug("*delete worker*", t.size, t), t.delete(r), this.workerByIdMap.delete(r), this.busyWorkers.delete(r), t.size < 1 && (this.groups.delete(e), this.enabledGroups.delete(e), this.enabledGroups.size < 1 && this.stopTimer()));
75
90
  }
76
91
  createWorker(e, {
77
92
  workerId: r,
78
- url: s,
79
- headers: u
93
+ url: t,
94
+ headers: i
80
95
  }) {
81
96
  if (!this.groups.has(e)) {
82
97
  if (this.groups.size >= this.config.maxGroupsSize) {
83
- const a = h(
98
+ const u = h(
84
99
  new Error("Max number of Hangfire groups exceeded"),
85
- n.GenericUnexpectedHangfireError,
100
+ a.GenericUnexpectedHangfireError,
86
101
  { count: this.groups.size }
87
102
  );
88
- throw this.destroy(), a;
103
+ throw this.destroy(), u;
89
104
  }
90
105
  this.groups.set(e, /* @__PURE__ */ new Map());
91
106
  }
92
- const t = this.groups.get(e);
93
- return new Promise((a, l) => {
94
- if (t.has(r))
107
+ const n = this.groups.get(e);
108
+ return new Promise((u, l) => {
109
+ if (n.has(r))
95
110
  throw h(
96
111
  new Error("Duplicate Hangfire worker ID"),
97
- n.GenericUnexpectedHangfireError
112
+ a.GenericUnexpectedHangfireError
98
113
  );
99
- if (t.size >= this.config.maxWorkersSize) {
100
- const c = h(
114
+ if (n.size >= this.config.maxWorkersSize) {
115
+ const d = h(
101
116
  new Error("Max number of Hangfire workers in group exceeded"),
102
- n.GenericUnexpectedHangfireError,
103
- { groupId: e, count: t.size }
117
+ a.GenericUnexpectedHangfireError,
118
+ { groupId: e, count: n.size }
104
119
  );
105
- throw l(c), this.destroy(), c;
120
+ throw l(d), this.destroy(), d;
106
121
  }
107
- const d = {
122
+ const g = {
108
123
  workerId: r,
109
124
  groupId: e,
110
- url: s,
111
- resolve: a,
125
+ url: t,
126
+ resolve: u,
112
127
  reject: l,
113
- headers: u
128
+ headers: i
114
129
  };
115
- t.set(r, d), this.workerByIdMap.set(r, d), this.enabledGroups.has(e) || this.enabledGroups.add(e), this.timer == null && this.enabledGroups.size > 0 && this.startTimer();
130
+ n.set(r, g), this.workerByIdMap.set(r, g), this.enabledGroups.has(e) || this.enabledGroups.add(e), this.timer == null && this.enabledGroups.size > 0 && this.startTimer();
116
131
  });
117
132
  }
118
133
  /** Trigger a worker to execute immediately, ignoring busy state */
119
134
  triggerWorker(e) {
120
135
  this.config.debug("*triggerWorker*");
121
136
  const r = this.workerByIdMap.get(e);
122
- r && this.executeWorkerRequest(r, !0);
137
+ r ? this.executeWorkerRequest(r, !0) : this.config.debug("*triggerWorker* worker not found", e);
123
138
  }
124
139
  /** May be called either before or after `createWorker()` */
125
140
  enableWorkers(e) {
@@ -132,10 +147,10 @@ class b {
132
147
  this.config.debug("*destroy*"), this.groups.clear(), this.stopTimer();
133
148
  }
134
149
  }
135
- function x(i) {
136
- return new b(i);
150
+ function E(s) {
151
+ return new k(s);
137
152
  }
138
153
  export {
139
- b as HangfirePoller,
140
- x as default
154
+ k as HangfirePoller,
155
+ E as default
141
156
  };
package/hangfire/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./isHangfireResponse.js"),r=require("./createHangfirePoller.js"),i=require("./createMakeHangfireRequest.js");require("../api/isAcceptedResponse.js");require("axios");require("@ancon/wildcat-types");require("../error/createCodedError.js");require("../api/isNoContentResponse.js");exports.isHangfireResponse=e;exports.createHangfirePoller=r.default;exports.createMakeHangfireRequest=i;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./isHangfireResponse.js"),r=require("./createHangfirePoller.js"),i=require("./createMakeHangfireRequest.js");require("../api/isAcceptedResponse.js");require("axios");require("@ancon/wildcat-types");require("../error/createCodedError.js");require("../api/isNoContentResponse.js");require("../shared/wait.js");exports.isHangfireResponse=e;exports.createHangfirePoller=r.default;exports.createMakeHangfireRequest=i;
@@ -1,13 +1,14 @@
1
- import { default as p } from "./isHangfireResponse.mjs";
2
- import { default as s } from "./createHangfirePoller.mjs";
3
- import { default as n } from "./createMakeHangfireRequest.mjs";
1
+ import { default as m } from "./isHangfireResponse.mjs";
2
+ import { default as l } from "./createHangfirePoller.mjs";
3
+ import { default as u } from "./createMakeHangfireRequest.mjs";
4
4
  import "../api/isAcceptedResponse.mjs";
5
5
  import "axios";
6
6
  import "@ancon/wildcat-types";
7
7
  import "../error/createCodedError.mjs";
8
8
  import "../api/isNoContentResponse.mjs";
9
+ import "../shared/wait.mjs";
9
10
  export {
10
- s as createHangfirePoller,
11
- n as createMakeHangfireRequest,
12
- p as isHangfireResponse
11
+ l as createHangfirePoller,
12
+ u as createMakeHangfireRequest,
13
+ m as isHangfireResponse
13
14
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ancon/wildcat-utils",
3
- "version": "1.40.26",
3
+ "version": "1.40.28",
4
4
  "private": false,
5
5
  "main": "index.js",
6
6
  "module": "index.mjs",