@polyester/sdk 0.27.3 → 0.28.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/CHANGELOG.md +6 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/services/lifecycle/lifecycle.schemas.d.ts +42 -42
- package/dist/services/orders/orders-output.schemas.d.ts +6 -6
- package/dist/services/trades/trades.schemas.d.ts +1 -1
- package/dist/services/triggers/trigger-input.schemas.d.ts +1 -1
- package/dist/services/triggers/triggers-output.schemas.d.ts +15 -15
- package/dist/shared/connect-error-mapping.d.ts.map +1 -1
- package/dist/shared/connect-error-mapping.js +7 -1
- package/dist/shared/connect-error-mapping.js.map +1 -1
- package/dist/shared/errors.d.ts +9 -3
- package/dist/shared/errors.d.ts.map +1 -1
- package/dist/shared/errors.js +12 -1
- package/dist/shared/errors.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @polyester/sdk
|
|
2
2
|
|
|
3
|
+
## 0.28.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Map HTTP 501 and Connect `unimplemented` to the new `NotImplementedError` instead of `InternalServerError`. Bare HTTP error responses without a Connect body now map by their status code instead of collapsing to `InternalServerError`. ([#171](https://github.com/Fabric-Labs/polyester-sdk-typescript/pull/171))
|
|
8
|
+
|
|
3
9
|
## 0.27.3
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { AssetConfig, DepositWithdrawConfig, PairConfig, PairStatus, SpotConfig,
|
|
|
6
6
|
import { OrderErrorCode, OrderErrorDetail } from "./services/orders/order-errors.schemas.js";
|
|
7
7
|
import { PolyesterErrorDetail } from "./shared/error-detail.js";
|
|
8
8
|
import { RateLimitDetail, RateLimitFailureReason, RateLimitPolicyClass, RateLimitRefillModel, RateLimitScope } from "./shared/rate-limit.schemas.js";
|
|
9
|
-
import { AlreadyExistsError, AuthenticationError, ConfigurationError, InternalServerError, MfaEnrollmentRequiredError, MfaLastFactorRequiredError, MfaRequiredError, MfaVerificationError, MfaVerificationFailureReason, NetworkError, PermissionError, PolicyInUseError, PolicyLockedError, PolicyScopeMismatchError, PolyesterError, PolyesterErrorCode, PolyesterErrorOptions, PreconditionFailedError, RateLimitError, RateLimitErrorOptions, RequestError, ResourceNotFoundError, RevisionConflictError, ServiceUnavailableError, SessionElevationRequiredError, StaleQuoteError, StepUpRequiredError, SubaccountChallengeInvalidError, TimeoutError, TransientError, ValidationError, errorFromHttpStatus, isAbortError, normalizeErrorMessage } from "./shared/errors.js";
|
|
9
|
+
import { AlreadyExistsError, AuthenticationError, ConfigurationError, InternalServerError, MfaEnrollmentRequiredError, MfaLastFactorRequiredError, MfaRequiredError, MfaVerificationError, MfaVerificationFailureReason, NetworkError, NotImplementedError, PermissionError, PolicyInUseError, PolicyLockedError, PolicyScopeMismatchError, PolyesterError, PolyesterErrorCode, PolyesterErrorOptions, PreconditionFailedError, RateLimitError, RateLimitErrorOptions, RequestError, ResourceNotFoundError, RevisionConflictError, ServiceUnavailableError, SessionElevationRequiredError, StaleQuoteError, StepUpRequiredError, SubaccountChallengeInvalidError, TimeoutError, TransientError, ValidationError, errorFromHttpStatus, isAbortError, normalizeErrorMessage } from "./shared/errors.js";
|
|
10
10
|
import { ApiKeyEd25519AuthProvider, JwtAuthProvider, Transports } from "./shared/transports.js";
|
|
11
11
|
import { PolyesterMutationOptions, PolyesterRequestOptions } from "./shared/request-options.js";
|
|
12
12
|
import { ResolveAccountInput, ResolvedAccount } from "./services/accounts/accounts.schemas.js";
|
|
@@ -110,4 +110,4 @@ import "./services/triggers/triggers.types.js";
|
|
|
110
110
|
import "./services/vip/vip.types.js";
|
|
111
111
|
import "./services/whiteboard/whiteboard.types.js";
|
|
112
112
|
import "./services/zipper/zipper.types.js";
|
|
113
|
-
export { type AccountCodeValue, type AccountIdentity, type AccountScope, type AccountScopedInput, type AccountSigner, type AccountSignerAuthEvents, type AccountSignerConfig, type CreateSubaccountResult as AccountSignerCreateSubaccountResult, type AccountSignerFactory, type ActiveAccountInfo, type AddressBook, type AddressBookEntries, type AddressBookEntriesView, type AddressBookEntry, type AddressBookRecentDestinationsView, type AddressBookTag, type AddressBookTagSummary, type AddressBookView, type AddressBookViewInvalidated, AlreadyExistsError, type ApiKey, type ApiKeyEd25519AuthProvider, type ApiKeyIdInput, type ApiKeyPolicy, type ApiKeyPolicyApplyInput, type ApiKeyPolicyCreateInput, type ApiKeyPolicyUpdateInput, type ApiKeyStatus, type ApiKeysCreateInput, type ApiKeysListInput, type ApiKeysUpdateInput, type ArchiveWhiteboardBoardInput, type ArchiveWhiteboardBoardResult, type AssetConfig, type AuthCookieLocation, type AuthHydrationData, type AuthLoginMethod, type AuthState, type AuthTokenStorage, type AuthTokenStorageSetOptions, AuthenticationError, type BalanceHistoryInput, type BalanceHistoryResponse, type BalanceRange, type BatchCancelOrderInput, type BatchCancelOrderResult, type BatchCancelOrdersInput, type BatchCancelOrdersResult, type BatchCreateOrderResult, type BatchCreateOrdersInput, type BatchCreateOrdersResult, type BatchGuardApprovals, type BatchReplaceAdmissionItem, type BatchReplaceOrdersInput, type BatchReplaceOrdersResult, type BatchSignProtectedActionInput, type BeginMfaChallengeInput, type BeginMfaChallengeResult, type BeginPasskeyEnrollmentInput, type BeginPasskeyEnrollmentResult, type BeginTotpEnrollmentInput, type BeginTotpEnrollmentResult, type CancelAllAfterInput, type CancelAllAfterResult, type CancelAllOrdersInput, type CancelAllOrdersResponse, type CancelOrderInput, type CancelOrderResult, type CancelTriggerInput, type CancelTriggerResult, type Candle, type CandleColumnar, type CandleColumnarInt, type CandleInt, type ChainAnalyticsRange, type ClaimCampaign, type ClaimDailyRewardResult, type ClaimFreshStepUpInput, type ClaimFreshStepUpResult, type ClaimGeneratedUsernameInput, type ClaimPolicy, type ColumnarTimeWindow, type CompleteMfaChallengeResult, ConfigurationError, type ConnectChannelParams, type ConsumeFreshStepUpInput, type CookieAuthTokenStorageOptions, type CopyAddressBookEntryInput, type CreateAddressBookEntryInput, type CreateAddressBookTagInput, type CreateDepositAddressInput, type CreateGuardSignerWalletResult, type CreateInternalTransferInput, type CreateInternalTransferResult, type CreateOrderResult, type CreateOrderbookSubscriptionInput, type CreatePolyesterAccountSignerParams, type CreatePolyesterEnvironmentParams, type CreateServerClientFromCookiesParams, type CreateServerClientFromRequestParams, type CreateSubaccountChallengeInput, type CreateSubaccountInput, type CreateSubaccountParams, type CreateSubaccountResult$1 as CreateSubaccountResult, type CreateSubaccountResult$1 as CreateSubaccountServiceResult, type CreateTradingWithdrawResult, type CreateTradingWithdrawToExternalChainInput, type CreateTradingWithdrawToExternalChainServiceInput, type CreateTradingWithdrawToFundingInput, type CreateTradingWithdrawToFundingServiceInput, type CreateTriggerInput, type CreateTriggerResult, type CreateWalletChallengeInput, type CreateWhiteboardBoardInput, type CreateWhiteboardBoardResult, type CurrencyConversionConfig, type CurrencyConversionRates, type CurrencyMetadata, type DailyClaimReward, type DailyClaimState, type DailyClaimStatus, type DailyClaimTransfer, type DeleteAddressBookEntryInput, type DeleteAddressBookTagInput, type DeleteMfaFactorInput, type DepositAddress, type DepositWithdrawConfig, type EffectiveSubaccountPermissions, type EquityGroupBy, type EquityHistoryInput, type EquityHistoryResponse, type EquitySeries, type EquitySeriesGrouping, type EvmHex, type ExportGuardSignerWalletResult, type FiatConversionRate, type FiatConversionSnapshot, type FinishPasskeyChallengeInput, type FinishPasskeyEnrollmentInput, type FinishPasskeyEnrollmentResult, type FinishTotpEnrollmentInput, type FinishTotpEnrollmentResult, type GeneratedUsernameOffer, type GetAddressBookViewInput, type GetBatchReplaceStatusInput, type GetBatchReplaceStatusResult, type GetCandlesColumnsInput, type GetCandlesInput, type GetLifecycleFlowInput, type GetLifecycleFlowOutput, type GetMarketTradesInput, type GetOrderDetailsInput, type GetOrderbookHeatmapInput, type GetOrderbookInput, type GetSpotFeeRatesInput, type GetTriggerInput, type GetUnifiedAssetBalancesInput, type GetUserTradesInput, type GetVerificationResponse, type GetWhiteboardBoardInput, type GetWhiteboardBoardResult, type GetZippedAssetSupplyGroupInput, type GetZippedAssetSupplyInput, type GuardApproval, type GuardSignerScopedInput, type GuardSignerStatus, type HeatmapDepthValue, type HeatmapIntervalValue, type HeatmapQuantityModeValue, type HexAddress, InternalServerError, type InternalTransferDestination, type InternalTransferWhitelistEntries, type InternalTransferWhitelistEntry, type InviteSubaccountMemberInput, type JwtAuthProvider, type LadderDetailsOutput, type LedgerBalance, type LedgerTransfer, type LedgerTransferSide, type LifecycleAssetIds, type LifecycleFlowDetail, type LifecycleFlowState, type LifecycleFlowStep, type LifecycleFlowStepActivity, type LifecycleFlowSummary, type LifecycleFlowSummaryProgress, type LifecycleFlowTimelineItem, type LifecycleFlowTxMatch, type LifecycleListOrderBy, type LifecycleListScope, type LifecycleReason, type LifecycleRequestFee, type LifecycleRequestFeeStatus, type LifecycleSort, type LifecycleTxLookupKind, type LifecycleZipperReason, type ListAddressBookEntriesInput, type ListApiKeyPoliciesResponse, type ListDepositAddressesInput, type ListInternalTransferWhitelistEntriesInput, type ListLifecycleFlowsByTxInput, type ListLifecycleFlowsByTxOutput, type ListLifecycleFlowsInput, type ListLifecycleFlowsOutput, type ListMarketOverviewInput, type ListMfaFactorsResult, type ListSubaccountInvitesInput, type ListTransferCounterpartiesInput, type ListTransferDestinationsInput, type ListTransfersInput, type ListTriggerEventsInput, type ListTriggerEventsResult, type ListTriggersInput, type ListTriggersResult, type ListWhiteboardBoardsInput, type ListWhiteboardBoardsResult, type LoginOptions, type LoginResult, type LoginWithWalletInput, type LoginWithWalletResponse, type MarketOverview, type MarketOverviewOrderBy, type MarketOverviewSort, type MarketOverviewSparkline, type MarketTrade, type Me, MfaEnrollmentRequiredError, type MfaFactor, MfaLastFactorRequiredError, MfaRequiredError, type MfaSessionInfo, MfaVerificationError, type MfaVerificationFailureReason, type MintWhiteboardJoinTokenInput, type MirroredWithdrawWhitelistEntry, type ModifyOrderInput, type ModifyOrderResult, type ModifyTriggerInput, type ModifyTriggerResult, NetworkError, type NewOrderInput, type NextVipTierThresholds, type OpenOrdersInput, type Order, type OrderDetails, type OrderErrorCode, type OrderErrorDetail, type OrderHistoryInput, type OrderIntentInput, type OrderLineage, type OrderTransfer, type OrderbookData, type OrderbookHeatmapDeltaBucket, type OrderbookHeatmapDeltaChain, type OrderbookHeatmapDeltaLevels, type OrderbookHeatmapKeyframe, type OrderbookHeatmapLevels, type OrderbookHeatmapLiveBucket, type OrderbookHeatmapResponse, type OrderbookLevel, type OrderbookStreamHandlers, type OrderbookSubscription, POLYESTER_AUTH_TOKEN_COOKIE_NAME, POLYESTER_DEVNET_ENVIRONMENT, POLYESTER_SESSION_COOKIE_NAME, POLYESTER_TESTNET_ENVIRONMENT, type PairConfig, type PairStatus, type PauseTriggerInput, type PauseTriggerResult, PermissionError, type PolicyAction, PolicyInUseError, PolicyLockedError, type PolicyMarketScope, PolicyScopeMismatchError, type PolyesterAccountAbstractionEnvironment, PolyesterBrowserClient, type PolyesterBrowserClientConfig, PolyesterClient, type PolyesterClientBaseConfig, type PolyesterClientConfig, type PolyesterContractsEnvironment, type PolyesterEntryPointConfig, type PolyesterEnvironment, PolyesterError, type PolyesterErrorCode, type PolyesterErrorDetail, type PolyesterErrorOptions, type PolyesterMutationOptions, type PolyesterRealtime, type PolyesterRealtimeAuthConfig, type PolyesterRequestOptions, type PolyesterSafeDeploymentConfig, PolyesterServerClient, type PolyesterServerClientConfig, type PortfolioEquityHistoryInput, type PortfolioEquityHistoryResponse, type PortfolioEquitySeries, type PortfolioEquitySeriesGrouping, type PortfolioEquitySnapshotResponse, PreconditionFailedError, type PreparedTradingWithdraw, type PreviewOrderResult, type Profile, type RateLimitConfig, type RateLimitDetail, RateLimitError, type RateLimitErrorOptions, type RateLimitFailureReason, type RateLimitPolicyClass, type RateLimitRefillModel, type RateLimitScope, type RegenerateRecoveryCodesInput, type RegenerateRecoveryCodesResult, type ReleaseFreshStepUpInput, type RemoveSubaccountMemberInput, RequestError, type ResolveAccountInput, type ResolvedAccount, type ResolvedInternalTransferDestination, ResourceNotFoundError, type RespondSubaccountInviteInput, type ResumeTriggerInput, type ResumeTriggerResult, RevisionConflictError, type RiskPolicyInput, type RotateGuardSignerWalletResult, type SdkSubscriptionErrorContext, type ServerSessionCookieOptions, type ServerSessionSnapshot, ServiceUnavailableError, type SessionData, SessionElevationRequiredError, type SetSubaccountMemberMfaRequirementInput, type SignProtectedActionInput, type SocialProvider, type SocialProviderInput, type SocialVerification, type SocialVerificationMethod, type SocialVerificationStatus, type SparklineIntervalName, type SpotConfig, type SpotFeeRate, type SpotPairVolumeSeries, type SpotVolumeHistoryInput, type SpotVolumeHistoryResponse, type StablecoinConversionRate, StaleQuoteError, type StartVerificationInput, type StartVerificationResponse, StepUpRequiredError, type StopDetailsOutput, type StopLossInput, type Subaccount, type SubaccountActivityInput, type SubaccountChallenge, SubaccountChallengeInvalidError, type SubaccountEvent, type SubaccountIdInput, type SubaccountInvite, type SubaccountInviteStatus, type SubaccountMember, type SubaccountPermission, type SubaccountPermissionDefinition, type SubaccountPolicy, type SubaccountPolicyApplyInput, type SubaccountPolicyCreateInput, type SubaccountPolicyUpdateInput, type SubaccountRole, type SubaccountRoleCatalog, type SubaccountRoleDefinition, type SubaccountScopedInput, type SubaccountStatus, type SubscribeHandlers, type SubscribeZippedAssetSupplyInput, type TakeProfitInput, type Timeframe, TimeoutError, type Trade, type TradingRateLimitClass, type TradingRateLimitRule, type TradingRateLimits, type TradingWithdrawSigningConfig, type TradingWithdrawWalletSigner, type TrailingDetailsOutput, type TrailingStopInput, type TransferCodeValue, type TransferCounterparties, type TransferCounterparty, type TransferDestination, type TransferDestinations, type TransferSideKind, TransientError, type Transports, type Trigger, type TriggerDetailsOutput, type TriggerEvent, type TwapDetailsOutput, type UnifiedAssetBalancesResponse, type UpdateAddressBookEntryInput, type UpdateAddressBookTagInput, type UpdateMfaFactorInput, type UpdateMfaFactorResult, type UpdateProfileInput, type UpdateSubaccountInput, type UpdateSubaccountMemberRoleInput, type UpdateWhiteboardBoardAclInput, type UpdateWhiteboardBoardAclResult, type UpdateWhiteboardBoardInput, type UpdateWhiteboardBoardResult, type UsernameHistoryEntry, type ValidateWithdrawDestinationInput, type ValidateWithdrawDestinationResult, ValidationError, type VerificationReadyResponse, type VerifyRecoveryCodeChallengeInput, type VerifyTotpChallengeInput, type VipStatus, type VipTier, type VipTierCatalog, type WalletChallenge, type WhiteboardAccess, type WhiteboardAclEntry, type WhiteboardAclEntryInput, type WhiteboardAclSubjectType, type WhiteboardAudience, type WhiteboardBoard, type WhiteboardBoardDetails, type WhiteboardBoardListItem, type WhiteboardJoinTokenResult, type WhiteboardPermissions, type WhiteboardPresencePayload, type WhiteboardResolvedRole, type WhiteboardSnapshot, type WhiteboardWritableRole, type WithdrawWhitelistView, type ZippedAssetSupplyBatch, type ZippedAssetSupplyGroupResponse, type ZippedAssetSupplyResponse, type ZippedAssetSupplySeries, type ZippedAssetSupplyUpdate, type ZipperAssetChainVariant, type ZipperAssetConfig, type ZipperChainConfig, type ZipperChainContractConfig, checksumEvmAddress, columnarTimestampSecAt, compareUnsignedIntegerStrings, connectErrorToPolyesterError, createCookieAuthTokenStorage, createErrorMappingInterceptor, createMemoryAuthTokenStorage, createPolyesterEnvironment, createPolyesterServerClientFromCookies, createPolyesterServerClientFromRequest, errorFromHttpStatus, evmHexToBytes, evmUtf8ToBytes, evmUtf8ToHex, expandColumnarTimestampsSec, formatConnectError, formatUserFacingError, isAbortError, isEvmAddress, isEvmAddressStrict, isFreshStepUpRequiredError, isMfaEnrollmentRequiredError, isMfaLastFactorRequiredError, isPolicyInUseError, isPolicyLockedError, isPolicyScopeMismatchError, isResourceNotFoundError, isRetryableError, isRevisionConflictError, isSessionElevationRequiredError, keccak256Hex, mergeLedgerBalances, normalizeErrorMessage, resolveAuthCookieName, shouldApplyReconciliationUpdate, tsObjToNsString as timestampToNanoseconds, toPolyesterError, validateCreateAddressBookEntryInput };
|
|
113
|
+
export { type AccountCodeValue, type AccountIdentity, type AccountScope, type AccountScopedInput, type AccountSigner, type AccountSignerAuthEvents, type AccountSignerConfig, type CreateSubaccountResult as AccountSignerCreateSubaccountResult, type AccountSignerFactory, type ActiveAccountInfo, type AddressBook, type AddressBookEntries, type AddressBookEntriesView, type AddressBookEntry, type AddressBookRecentDestinationsView, type AddressBookTag, type AddressBookTagSummary, type AddressBookView, type AddressBookViewInvalidated, AlreadyExistsError, type ApiKey, type ApiKeyEd25519AuthProvider, type ApiKeyIdInput, type ApiKeyPolicy, type ApiKeyPolicyApplyInput, type ApiKeyPolicyCreateInput, type ApiKeyPolicyUpdateInput, type ApiKeyStatus, type ApiKeysCreateInput, type ApiKeysListInput, type ApiKeysUpdateInput, type ArchiveWhiteboardBoardInput, type ArchiveWhiteboardBoardResult, type AssetConfig, type AuthCookieLocation, type AuthHydrationData, type AuthLoginMethod, type AuthState, type AuthTokenStorage, type AuthTokenStorageSetOptions, AuthenticationError, type BalanceHistoryInput, type BalanceHistoryResponse, type BalanceRange, type BatchCancelOrderInput, type BatchCancelOrderResult, type BatchCancelOrdersInput, type BatchCancelOrdersResult, type BatchCreateOrderResult, type BatchCreateOrdersInput, type BatchCreateOrdersResult, type BatchGuardApprovals, type BatchReplaceAdmissionItem, type BatchReplaceOrdersInput, type BatchReplaceOrdersResult, type BatchSignProtectedActionInput, type BeginMfaChallengeInput, type BeginMfaChallengeResult, type BeginPasskeyEnrollmentInput, type BeginPasskeyEnrollmentResult, type BeginTotpEnrollmentInput, type BeginTotpEnrollmentResult, type CancelAllAfterInput, type CancelAllAfterResult, type CancelAllOrdersInput, type CancelAllOrdersResponse, type CancelOrderInput, type CancelOrderResult, type CancelTriggerInput, type CancelTriggerResult, type Candle, type CandleColumnar, type CandleColumnarInt, type CandleInt, type ChainAnalyticsRange, type ClaimCampaign, type ClaimDailyRewardResult, type ClaimFreshStepUpInput, type ClaimFreshStepUpResult, type ClaimGeneratedUsernameInput, type ClaimPolicy, type ColumnarTimeWindow, type CompleteMfaChallengeResult, ConfigurationError, type ConnectChannelParams, type ConsumeFreshStepUpInput, type CookieAuthTokenStorageOptions, type CopyAddressBookEntryInput, type CreateAddressBookEntryInput, type CreateAddressBookTagInput, type CreateDepositAddressInput, type CreateGuardSignerWalletResult, type CreateInternalTransferInput, type CreateInternalTransferResult, type CreateOrderResult, type CreateOrderbookSubscriptionInput, type CreatePolyesterAccountSignerParams, type CreatePolyesterEnvironmentParams, type CreateServerClientFromCookiesParams, type CreateServerClientFromRequestParams, type CreateSubaccountChallengeInput, type CreateSubaccountInput, type CreateSubaccountParams, type CreateSubaccountResult$1 as CreateSubaccountResult, type CreateSubaccountResult$1 as CreateSubaccountServiceResult, type CreateTradingWithdrawResult, type CreateTradingWithdrawToExternalChainInput, type CreateTradingWithdrawToExternalChainServiceInput, type CreateTradingWithdrawToFundingInput, type CreateTradingWithdrawToFundingServiceInput, type CreateTriggerInput, type CreateTriggerResult, type CreateWalletChallengeInput, type CreateWhiteboardBoardInput, type CreateWhiteboardBoardResult, type CurrencyConversionConfig, type CurrencyConversionRates, type CurrencyMetadata, type DailyClaimReward, type DailyClaimState, type DailyClaimStatus, type DailyClaimTransfer, type DeleteAddressBookEntryInput, type DeleteAddressBookTagInput, type DeleteMfaFactorInput, type DepositAddress, type DepositWithdrawConfig, type EffectiveSubaccountPermissions, type EquityGroupBy, type EquityHistoryInput, type EquityHistoryResponse, type EquitySeries, type EquitySeriesGrouping, type EvmHex, type ExportGuardSignerWalletResult, type FiatConversionRate, type FiatConversionSnapshot, type FinishPasskeyChallengeInput, type FinishPasskeyEnrollmentInput, type FinishPasskeyEnrollmentResult, type FinishTotpEnrollmentInput, type FinishTotpEnrollmentResult, type GeneratedUsernameOffer, type GetAddressBookViewInput, type GetBatchReplaceStatusInput, type GetBatchReplaceStatusResult, type GetCandlesColumnsInput, type GetCandlesInput, type GetLifecycleFlowInput, type GetLifecycleFlowOutput, type GetMarketTradesInput, type GetOrderDetailsInput, type GetOrderbookHeatmapInput, type GetOrderbookInput, type GetSpotFeeRatesInput, type GetTriggerInput, type GetUnifiedAssetBalancesInput, type GetUserTradesInput, type GetVerificationResponse, type GetWhiteboardBoardInput, type GetWhiteboardBoardResult, type GetZippedAssetSupplyGroupInput, type GetZippedAssetSupplyInput, type GuardApproval, type GuardSignerScopedInput, type GuardSignerStatus, type HeatmapDepthValue, type HeatmapIntervalValue, type HeatmapQuantityModeValue, type HexAddress, InternalServerError, type InternalTransferDestination, type InternalTransferWhitelistEntries, type InternalTransferWhitelistEntry, type InviteSubaccountMemberInput, type JwtAuthProvider, type LadderDetailsOutput, type LedgerBalance, type LedgerTransfer, type LedgerTransferSide, type LifecycleAssetIds, type LifecycleFlowDetail, type LifecycleFlowState, type LifecycleFlowStep, type LifecycleFlowStepActivity, type LifecycleFlowSummary, type LifecycleFlowSummaryProgress, type LifecycleFlowTimelineItem, type LifecycleFlowTxMatch, type LifecycleListOrderBy, type LifecycleListScope, type LifecycleReason, type LifecycleRequestFee, type LifecycleRequestFeeStatus, type LifecycleSort, type LifecycleTxLookupKind, type LifecycleZipperReason, type ListAddressBookEntriesInput, type ListApiKeyPoliciesResponse, type ListDepositAddressesInput, type ListInternalTransferWhitelistEntriesInput, type ListLifecycleFlowsByTxInput, type ListLifecycleFlowsByTxOutput, type ListLifecycleFlowsInput, type ListLifecycleFlowsOutput, type ListMarketOverviewInput, type ListMfaFactorsResult, type ListSubaccountInvitesInput, type ListTransferCounterpartiesInput, type ListTransferDestinationsInput, type ListTransfersInput, type ListTriggerEventsInput, type ListTriggerEventsResult, type ListTriggersInput, type ListTriggersResult, type ListWhiteboardBoardsInput, type ListWhiteboardBoardsResult, type LoginOptions, type LoginResult, type LoginWithWalletInput, type LoginWithWalletResponse, type MarketOverview, type MarketOverviewOrderBy, type MarketOverviewSort, type MarketOverviewSparkline, type MarketTrade, type Me, MfaEnrollmentRequiredError, type MfaFactor, MfaLastFactorRequiredError, MfaRequiredError, type MfaSessionInfo, MfaVerificationError, type MfaVerificationFailureReason, type MintWhiteboardJoinTokenInput, type MirroredWithdrawWhitelistEntry, type ModifyOrderInput, type ModifyOrderResult, type ModifyTriggerInput, type ModifyTriggerResult, NetworkError, type NewOrderInput, type NextVipTierThresholds, NotImplementedError, type OpenOrdersInput, type Order, type OrderDetails, type OrderErrorCode, type OrderErrorDetail, type OrderHistoryInput, type OrderIntentInput, type OrderLineage, type OrderTransfer, type OrderbookData, type OrderbookHeatmapDeltaBucket, type OrderbookHeatmapDeltaChain, type OrderbookHeatmapDeltaLevels, type OrderbookHeatmapKeyframe, type OrderbookHeatmapLevels, type OrderbookHeatmapLiveBucket, type OrderbookHeatmapResponse, type OrderbookLevel, type OrderbookStreamHandlers, type OrderbookSubscription, POLYESTER_AUTH_TOKEN_COOKIE_NAME, POLYESTER_DEVNET_ENVIRONMENT, POLYESTER_SESSION_COOKIE_NAME, POLYESTER_TESTNET_ENVIRONMENT, type PairConfig, type PairStatus, type PauseTriggerInput, type PauseTriggerResult, PermissionError, type PolicyAction, PolicyInUseError, PolicyLockedError, type PolicyMarketScope, PolicyScopeMismatchError, type PolyesterAccountAbstractionEnvironment, PolyesterBrowserClient, type PolyesterBrowserClientConfig, PolyesterClient, type PolyesterClientBaseConfig, type PolyesterClientConfig, type PolyesterContractsEnvironment, type PolyesterEntryPointConfig, type PolyesterEnvironment, PolyesterError, type PolyesterErrorCode, type PolyesterErrorDetail, type PolyesterErrorOptions, type PolyesterMutationOptions, type PolyesterRealtime, type PolyesterRealtimeAuthConfig, type PolyesterRequestOptions, type PolyesterSafeDeploymentConfig, PolyesterServerClient, type PolyesterServerClientConfig, type PortfolioEquityHistoryInput, type PortfolioEquityHistoryResponse, type PortfolioEquitySeries, type PortfolioEquitySeriesGrouping, type PortfolioEquitySnapshotResponse, PreconditionFailedError, type PreparedTradingWithdraw, type PreviewOrderResult, type Profile, type RateLimitConfig, type RateLimitDetail, RateLimitError, type RateLimitErrorOptions, type RateLimitFailureReason, type RateLimitPolicyClass, type RateLimitRefillModel, type RateLimitScope, type RegenerateRecoveryCodesInput, type RegenerateRecoveryCodesResult, type ReleaseFreshStepUpInput, type RemoveSubaccountMemberInput, RequestError, type ResolveAccountInput, type ResolvedAccount, type ResolvedInternalTransferDestination, ResourceNotFoundError, type RespondSubaccountInviteInput, type ResumeTriggerInput, type ResumeTriggerResult, RevisionConflictError, type RiskPolicyInput, type RotateGuardSignerWalletResult, type SdkSubscriptionErrorContext, type ServerSessionCookieOptions, type ServerSessionSnapshot, ServiceUnavailableError, type SessionData, SessionElevationRequiredError, type SetSubaccountMemberMfaRequirementInput, type SignProtectedActionInput, type SocialProvider, type SocialProviderInput, type SocialVerification, type SocialVerificationMethod, type SocialVerificationStatus, type SparklineIntervalName, type SpotConfig, type SpotFeeRate, type SpotPairVolumeSeries, type SpotVolumeHistoryInput, type SpotVolumeHistoryResponse, type StablecoinConversionRate, StaleQuoteError, type StartVerificationInput, type StartVerificationResponse, StepUpRequiredError, type StopDetailsOutput, type StopLossInput, type Subaccount, type SubaccountActivityInput, type SubaccountChallenge, SubaccountChallengeInvalidError, type SubaccountEvent, type SubaccountIdInput, type SubaccountInvite, type SubaccountInviteStatus, type SubaccountMember, type SubaccountPermission, type SubaccountPermissionDefinition, type SubaccountPolicy, type SubaccountPolicyApplyInput, type SubaccountPolicyCreateInput, type SubaccountPolicyUpdateInput, type SubaccountRole, type SubaccountRoleCatalog, type SubaccountRoleDefinition, type SubaccountScopedInput, type SubaccountStatus, type SubscribeHandlers, type SubscribeZippedAssetSupplyInput, type TakeProfitInput, type Timeframe, TimeoutError, type Trade, type TradingRateLimitClass, type TradingRateLimitRule, type TradingRateLimits, type TradingWithdrawSigningConfig, type TradingWithdrawWalletSigner, type TrailingDetailsOutput, type TrailingStopInput, type TransferCodeValue, type TransferCounterparties, type TransferCounterparty, type TransferDestination, type TransferDestinations, type TransferSideKind, TransientError, type Transports, type Trigger, type TriggerDetailsOutput, type TriggerEvent, type TwapDetailsOutput, type UnifiedAssetBalancesResponse, type UpdateAddressBookEntryInput, type UpdateAddressBookTagInput, type UpdateMfaFactorInput, type UpdateMfaFactorResult, type UpdateProfileInput, type UpdateSubaccountInput, type UpdateSubaccountMemberRoleInput, type UpdateWhiteboardBoardAclInput, type UpdateWhiteboardBoardAclResult, type UpdateWhiteboardBoardInput, type UpdateWhiteboardBoardResult, type UsernameHistoryEntry, type ValidateWithdrawDestinationInput, type ValidateWithdrawDestinationResult, ValidationError, type VerificationReadyResponse, type VerifyRecoveryCodeChallengeInput, type VerifyTotpChallengeInput, type VipStatus, type VipTier, type VipTierCatalog, type WalletChallenge, type WhiteboardAccess, type WhiteboardAclEntry, type WhiteboardAclEntryInput, type WhiteboardAclSubjectType, type WhiteboardAudience, type WhiteboardBoard, type WhiteboardBoardDetails, type WhiteboardBoardListItem, type WhiteboardJoinTokenResult, type WhiteboardPermissions, type WhiteboardPresencePayload, type WhiteboardResolvedRole, type WhiteboardSnapshot, type WhiteboardWritableRole, type WithdrawWhitelistView, type ZippedAssetSupplyBatch, type ZippedAssetSupplyGroupResponse, type ZippedAssetSupplyResponse, type ZippedAssetSupplySeries, type ZippedAssetSupplyUpdate, type ZipperAssetChainVariant, type ZipperAssetConfig, type ZipperChainConfig, type ZipperChainContractConfig, checksumEvmAddress, columnarTimestampSecAt, compareUnsignedIntegerStrings, connectErrorToPolyesterError, createCookieAuthTokenStorage, createErrorMappingInterceptor, createMemoryAuthTokenStorage, createPolyesterEnvironment, createPolyesterServerClientFromCookies, createPolyesterServerClientFromRequest, errorFromHttpStatus, evmHexToBytes, evmUtf8ToBytes, evmUtf8ToHex, expandColumnarTimestampsSec, formatConnectError, formatUserFacingError, isAbortError, isEvmAddress, isEvmAddressStrict, isFreshStepUpRequiredError, isMfaEnrollmentRequiredError, isMfaLastFactorRequiredError, isPolicyInUseError, isPolicyLockedError, isPolicyScopeMismatchError, isResourceNotFoundError, isRetryableError, isRevisionConflictError, isSessionElevationRequiredError, keccak256Hex, mergeLedgerBalances, normalizeErrorMessage, resolveAuthCookieName, shouldApplyReconciliationUpdate, tsObjToNsString as timestampToNanoseconds, toPolyesterError, validateCreateAddressBookEntryInput };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AlreadyExistsError, AuthenticationError, ConfigurationError, InternalServerError, MfaEnrollmentRequiredError, MfaLastFactorRequiredError, MfaRequiredError, MfaVerificationError, NetworkError, PermissionError, PolicyInUseError, PolicyLockedError, PolicyScopeMismatchError, PolyesterError, PreconditionFailedError, RateLimitError, RequestError, ResourceNotFoundError, RevisionConflictError, ServiceUnavailableError, SessionElevationRequiredError, StaleQuoteError, StepUpRequiredError, SubaccountChallengeInvalidError, TimeoutError, TransientError, ValidationError, errorFromHttpStatus, isAbortError, normalizeErrorMessage } from "./shared/errors.js";
|
|
1
|
+
import { AlreadyExistsError, AuthenticationError, ConfigurationError, InternalServerError, MfaEnrollmentRequiredError, MfaLastFactorRequiredError, MfaRequiredError, MfaVerificationError, NetworkError, NotImplementedError, PermissionError, PolicyInUseError, PolicyLockedError, PolicyScopeMismatchError, PolyesterError, PreconditionFailedError, RateLimitError, RequestError, ResourceNotFoundError, RevisionConflictError, ServiceUnavailableError, SessionElevationRequiredError, StaleQuoteError, StepUpRequiredError, SubaccountChallengeInvalidError, TimeoutError, TransientError, ValidationError, errorFromHttpStatus, isAbortError, normalizeErrorMessage } from "./shared/errors.js";
|
|
2
2
|
import { tsObjToNsString } from "./utils/time.js";
|
|
3
3
|
import { connectErrorToPolyesterError, createErrorMappingInterceptor, toPolyesterError } from "./shared/connect-error-mapping.js";
|
|
4
4
|
import { checksumEvmAddress, evmHexToBytes, evmUtf8ToBytes, evmUtf8ToHex, isEvmAddress, isEvmAddressStrict, keccak256Hex } from "./utils/evm.js";
|
|
@@ -14,4 +14,4 @@ import { PolyesterBrowserClient } from "./browser-client.js";
|
|
|
14
14
|
import { PolyesterServerClient, createPolyesterServerClientFromCookies, createPolyesterServerClientFromRequest } from "./server-client.js";
|
|
15
15
|
import { isFreshStepUpRequiredError, isMfaEnrollmentRequiredError, isMfaLastFactorRequiredError, isSessionElevationRequiredError } from "./utils/connect-mfa-errors.js";
|
|
16
16
|
import { columnarTimestampSecAt, expandColumnarTimestampsSec } from "./utils/columnar-time.js";
|
|
17
|
-
export { AlreadyExistsError, AuthenticationError, ConfigurationError, InternalServerError, MfaEnrollmentRequiredError, MfaLastFactorRequiredError, MfaRequiredError, MfaVerificationError, NetworkError, POLYESTER_AUTH_TOKEN_COOKIE_NAME, POLYESTER_DEVNET_ENVIRONMENT, POLYESTER_SESSION_COOKIE_NAME, POLYESTER_TESTNET_ENVIRONMENT, PermissionError, PolicyInUseError, PolicyLockedError, PolicyScopeMismatchError, PolyesterBrowserClient, PolyesterClient, PolyesterError, PolyesterServerClient, PreconditionFailedError, RateLimitError, RequestError, ResourceNotFoundError, RevisionConflictError, ServiceUnavailableError, SessionElevationRequiredError, StaleQuoteError, StepUpRequiredError, SubaccountChallengeInvalidError, TimeoutError, TransientError, ValidationError, checksumEvmAddress, columnarTimestampSecAt, compareUnsignedIntegerStrings, connectErrorToPolyesterError, createCookieAuthTokenStorage, createErrorMappingInterceptor, createMemoryAuthTokenStorage, createPolyesterEnvironment, createPolyesterServerClientFromCookies, createPolyesterServerClientFromRequest, errorFromHttpStatus, evmHexToBytes, evmUtf8ToBytes, evmUtf8ToHex, expandColumnarTimestampsSec, formatConnectError, formatUserFacingError, isAbortError, isEvmAddress, isEvmAddressStrict, isFreshStepUpRequiredError, isMfaEnrollmentRequiredError, isMfaLastFactorRequiredError, isPolicyInUseError, isPolicyLockedError, isPolicyScopeMismatchError, isResourceNotFoundError, isRetryableError, isRevisionConflictError, isSessionElevationRequiredError, keccak256Hex, mergeLedgerBalances, normalizeErrorMessage, resolveAuthCookieName, shouldApplyReconciliationUpdate, tsObjToNsString as timestampToNanoseconds, toPolyesterError, validateCreateAddressBookEntryInput };
|
|
17
|
+
export { AlreadyExistsError, AuthenticationError, ConfigurationError, InternalServerError, MfaEnrollmentRequiredError, MfaLastFactorRequiredError, MfaRequiredError, MfaVerificationError, NetworkError, NotImplementedError, POLYESTER_AUTH_TOKEN_COOKIE_NAME, POLYESTER_DEVNET_ENVIRONMENT, POLYESTER_SESSION_COOKIE_NAME, POLYESTER_TESTNET_ENVIRONMENT, PermissionError, PolicyInUseError, PolicyLockedError, PolicyScopeMismatchError, PolyesterBrowserClient, PolyesterClient, PolyesterError, PolyesterServerClient, PreconditionFailedError, RateLimitError, RequestError, ResourceNotFoundError, RevisionConflictError, ServiceUnavailableError, SessionElevationRequiredError, StaleQuoteError, StepUpRequiredError, SubaccountChallengeInvalidError, TimeoutError, TransientError, ValidationError, checksumEvmAddress, columnarTimestampSecAt, compareUnsignedIntegerStrings, connectErrorToPolyesterError, createCookieAuthTokenStorage, createErrorMappingInterceptor, createMemoryAuthTokenStorage, createPolyesterEnvironment, createPolyesterServerClientFromCookies, createPolyesterServerClientFromRequest, errorFromHttpStatus, evmHexToBytes, evmUtf8ToBytes, evmUtf8ToHex, expandColumnarTimestampsSec, formatConnectError, formatUserFacingError, isAbortError, isEvmAddress, isEvmAddressStrict, isFreshStepUpRequiredError, isMfaEnrollmentRequiredError, isMfaLastFactorRequiredError, isPolicyInUseError, isPolicyLockedError, isPolicyScopeMismatchError, isResourceNotFoundError, isRetryableError, isRevisionConflictError, isSessionElevationRequiredError, keccak256Hex, mergeLedgerBalances, normalizeErrorMessage, resolveAuthCookieName, shouldApplyReconciliationUpdate, tsObjToNsString as timestampToNanoseconds, toPolyesterError, validateCreateAddressBookEntryInput };
|
|
@@ -7,7 +7,7 @@ declare const LifecycleAssetIdsSchema: v.ObjectSchema<{
|
|
|
7
7
|
readonly zippedAssetId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
8
8
|
readonly unifiedAssetId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
9
9
|
}, undefined>;
|
|
10
|
-
declare const LifecycleFlowStateEnumSchema: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "
|
|
10
|
+
declare const LifecycleFlowStateEnumSchema: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "failed" | "pending_source" | "pending_polyester_chain" | "pending_ledger" | "completed" | "dropped" | "refunded">]>;
|
|
11
11
|
declare const LifecycleZipperReasonSchema: v.ObjectSchema<{
|
|
12
12
|
readonly code: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
13
13
|
readonly reasonId: v.StringSchema<undefined>;
|
|
@@ -17,7 +17,7 @@ declare const ListLifecycleFlowsInputSchema: v.SchemaWithPipe<readonly [v.Strict
|
|
|
17
17
|
readonly limit: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>, v.MaxValueAction<number, 500, undefined>]>, 100>;
|
|
18
18
|
readonly sort: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<readonly ["newest", "oldest"], undefined>, "newest">, v.TransformAction<"newest" | "oldest", Sort.NEWEST | Sort.OLDEST>]>;
|
|
19
19
|
readonly flowKind: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<readonly ["deposit", "withdraw", "transfer"], undefined>, undefined>, v.TransformAction<"deposit" | "withdraw" | "transfer" | undefined, FlowKind>]>;
|
|
20
|
-
readonly flowState: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<readonly ["pending_source", "pending_polyester_chain", "pending_ledger", "completed", "failed", "dropped", "refunded"], undefined>, undefined>, v.TransformAction<"
|
|
20
|
+
readonly flowState: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<readonly ["pending_source", "pending_polyester_chain", "pending_ledger", "completed", "failed", "dropped", "refunded"], undefined>, undefined>, v.TransformAction<"failed" | "pending_source" | "pending_polyester_chain" | "pending_ledger" | "completed" | "dropped" | "refunded" | undefined, FlowState>]>;
|
|
21
21
|
readonly txRef: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, "txHash is required.">, v.CheckAction<string, "txHash must be a valid EVM hash or chain-native transaction id.">, v.TransformAction<string, string>]>, undefined>;
|
|
22
22
|
readonly scope: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<readonly ["all", "open", "terminal"], undefined>, "all">, v.TransformAction<"open" | "all" | "terminal", ListScope.LIST_ALL | ListScope.LIST_OPEN_ONLY | ListScope.LIST_TERMINAL_ONLY>]>;
|
|
23
23
|
readonly accountSelector: v.OptionalSchema<v.SchemaWithPipe<readonly [v.VariantSchema<"kind", [v.StrictObjectSchema<{
|
|
@@ -209,7 +209,7 @@ declare const LifecycleFlowStepActivitySchema: v.SchemaWithPipe<readonly [v.Obje
|
|
|
209
209
|
}>]>;
|
|
210
210
|
declare const LifecycleFlowStepSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
211
211
|
readonly sequence: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
212
|
-
readonly step: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "validation" | "unspecified" | "source" | "request" | "
|
|
212
|
+
readonly step: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "validation" | "unspecified" | "source" | "request" | "failed" | "transfer" | "dropped" | "refunded" | "execution" | "bridge_fulfillment" | "fulfilling" | "settlement">]>;
|
|
213
213
|
readonly assetIds: v.OptionalSchema<v.ObjectSchema<{
|
|
214
214
|
readonly zippedAssetId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
215
215
|
readonly unifiedAssetId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
@@ -346,7 +346,7 @@ declare const LifecycleFlowStepSchema: v.SchemaWithPipe<readonly [v.ObjectSchema
|
|
|
346
346
|
}>]>, undefined>, readonly []>;
|
|
347
347
|
}, undefined>, v.TransformAction<{
|
|
348
348
|
sequence: number;
|
|
349
|
-
step: "validation" | "unspecified" | "source" | "request" | "
|
|
349
|
+
step: "validation" | "unspecified" | "source" | "request" | "failed" | "transfer" | "dropped" | "refunded" | "execution" | "bridge_fulfillment" | "fulfilling" | "settlement";
|
|
350
350
|
assetIds?: {
|
|
351
351
|
zippedAssetId: number;
|
|
352
352
|
unifiedAssetId: number;
|
|
@@ -407,7 +407,7 @@ declare const LifecycleFlowStepSchema: v.SchemaWithPipe<readonly [v.ObjectSchema
|
|
|
407
407
|
})[];
|
|
408
408
|
}, Omit<{
|
|
409
409
|
sequence: number;
|
|
410
|
-
step: "validation" | "unspecified" | "source" | "request" | "
|
|
410
|
+
step: "validation" | "unspecified" | "source" | "request" | "failed" | "transfer" | "dropped" | "refunded" | "execution" | "bridge_fulfillment" | "fulfilling" | "settlement";
|
|
411
411
|
assetIds?: {
|
|
412
412
|
zippedAssetId: number;
|
|
413
413
|
unifiedAssetId: number;
|
|
@@ -471,7 +471,7 @@ declare const LifecycleFlowStepSchema: v.SchemaWithPipe<readonly [v.ObjectSchema
|
|
|
471
471
|
}>]>;
|
|
472
472
|
declare const LifecycleFlowTimelineItemSchema: v.ObjectSchema<{
|
|
473
473
|
readonly sequence: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
474
|
-
readonly step: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "validation" | "unspecified" | "source" | "request" | "
|
|
474
|
+
readonly step: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "validation" | "unspecified" | "source" | "request" | "failed" | "transfer" | "dropped" | "refunded" | "execution" | "bridge_fulfillment" | "fulfilling" | "settlement">]>;
|
|
475
475
|
readonly status: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "completed" | "current" | "planned">]>;
|
|
476
476
|
readonly expectedDurationMs: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, number>]>;
|
|
477
477
|
}, undefined>;
|
|
@@ -491,7 +491,7 @@ declare const LifecycleFlowSummarySchema: v.SchemaWithPipe<readonly [v.ObjectSch
|
|
|
491
491
|
readonly smartAccountAddress: v.StringSchema<undefined>;
|
|
492
492
|
readonly flowId: v.StringSchema<undefined>;
|
|
493
493
|
readonly flowKind: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "deposit" | "withdraw" | "transfer">]>;
|
|
494
|
-
readonly currentStep: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "validation" | "unspecified" | "source" | "request" | "
|
|
494
|
+
readonly currentStep: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "validation" | "unspecified" | "source" | "request" | "failed" | "transfer" | "dropped" | "refunded" | "execution" | "bridge_fulfillment" | "fulfilling" | "settlement">]>;
|
|
495
495
|
readonly assetIds: v.OptionalSchema<v.ObjectSchema<{
|
|
496
496
|
readonly zippedAssetId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
497
497
|
readonly unifiedAssetId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
@@ -571,7 +571,7 @@ declare const LifecycleFlowSummarySchema: v.SchemaWithPipe<readonly [v.ObjectSch
|
|
|
571
571
|
}, undefined>, undefined>;
|
|
572
572
|
readonly progressTimeline: v.OptionalSchema<v.ArraySchema<v.ObjectSchema<{
|
|
573
573
|
readonly sequence: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
574
|
-
readonly step: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "validation" | "unspecified" | "source" | "request" | "
|
|
574
|
+
readonly step: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "validation" | "unspecified" | "source" | "request" | "failed" | "transfer" | "dropped" | "refunded" | "execution" | "bridge_fulfillment" | "fulfilling" | "settlement">]>;
|
|
575
575
|
readonly status: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "completed" | "current" | "planned">]>;
|
|
576
576
|
readonly expectedDurationMs: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, number>]>;
|
|
577
577
|
}, undefined>, undefined>, readonly []>;
|
|
@@ -581,7 +581,7 @@ declare const LifecycleFlowSummarySchema: v.SchemaWithPipe<readonly [v.ObjectSch
|
|
|
581
581
|
smartAccountAddress: string;
|
|
582
582
|
flowId: string;
|
|
583
583
|
flowKind: "unspecified" | "deposit" | "withdraw" | "transfer";
|
|
584
|
-
currentStep: "validation" | "unspecified" | "source" | "request" | "
|
|
584
|
+
currentStep: "validation" | "unspecified" | "source" | "request" | "failed" | "transfer" | "dropped" | "refunded" | "execution" | "bridge_fulfillment" | "fulfilling" | "settlement";
|
|
585
585
|
assetIds?: {
|
|
586
586
|
zippedAssetId: number;
|
|
587
587
|
unifiedAssetId: number;
|
|
@@ -633,7 +633,7 @@ declare const LifecycleFlowSummarySchema: v.SchemaWithPipe<readonly [v.ObjectSch
|
|
|
633
633
|
} | undefined;
|
|
634
634
|
progressTimeline: {
|
|
635
635
|
sequence: number;
|
|
636
|
-
step: "validation" | "unspecified" | "source" | "request" | "
|
|
636
|
+
step: "validation" | "unspecified" | "source" | "request" | "failed" | "transfer" | "dropped" | "refunded" | "execution" | "bridge_fulfillment" | "fulfilling" | "settlement";
|
|
637
637
|
status: "unspecified" | "completed" | "current" | "planned";
|
|
638
638
|
expectedDurationMs: number;
|
|
639
639
|
}[];
|
|
@@ -643,7 +643,7 @@ declare const LifecycleFlowSummarySchema: v.SchemaWithPipe<readonly [v.ObjectSch
|
|
|
643
643
|
smartAccountAddress: string;
|
|
644
644
|
flowId: string;
|
|
645
645
|
flowKind: "unspecified" | "deposit" | "withdraw" | "transfer";
|
|
646
|
-
currentStep: "validation" | "unspecified" | "source" | "request" | "
|
|
646
|
+
currentStep: "validation" | "unspecified" | "source" | "request" | "failed" | "transfer" | "dropped" | "refunded" | "execution" | "bridge_fulfillment" | "fulfilling" | "settlement";
|
|
647
647
|
assetIds?: {
|
|
648
648
|
zippedAssetId: number;
|
|
649
649
|
unifiedAssetId: number;
|
|
@@ -695,7 +695,7 @@ declare const LifecycleFlowSummarySchema: v.SchemaWithPipe<readonly [v.ObjectSch
|
|
|
695
695
|
} | undefined;
|
|
696
696
|
progressTimeline: {
|
|
697
697
|
sequence: number;
|
|
698
|
-
step: "validation" | "unspecified" | "source" | "request" | "
|
|
698
|
+
step: "validation" | "unspecified" | "source" | "request" | "failed" | "transfer" | "dropped" | "refunded" | "execution" | "bridge_fulfillment" | "fulfilling" | "settlement";
|
|
699
699
|
status: "unspecified" | "completed" | "current" | "planned";
|
|
700
700
|
expectedDurationMs: number;
|
|
701
701
|
}[];
|
|
@@ -709,7 +709,7 @@ declare const LifecycleFlowDetailSchema: v.ObjectSchema<{
|
|
|
709
709
|
readonly smartAccountAddress: v.StringSchema<undefined>;
|
|
710
710
|
readonly flowId: v.StringSchema<undefined>;
|
|
711
711
|
readonly flowKind: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "deposit" | "withdraw" | "transfer">]>;
|
|
712
|
-
readonly currentStep: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "validation" | "unspecified" | "source" | "request" | "
|
|
712
|
+
readonly currentStep: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "validation" | "unspecified" | "source" | "request" | "failed" | "transfer" | "dropped" | "refunded" | "execution" | "bridge_fulfillment" | "fulfilling" | "settlement">]>;
|
|
713
713
|
readonly assetIds: v.OptionalSchema<v.ObjectSchema<{
|
|
714
714
|
readonly zippedAssetId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
715
715
|
readonly unifiedAssetId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
@@ -789,7 +789,7 @@ declare const LifecycleFlowDetailSchema: v.ObjectSchema<{
|
|
|
789
789
|
}, undefined>, undefined>;
|
|
790
790
|
readonly progressTimeline: v.OptionalSchema<v.ArraySchema<v.ObjectSchema<{
|
|
791
791
|
readonly sequence: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
792
|
-
readonly step: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "validation" | "unspecified" | "source" | "request" | "
|
|
792
|
+
readonly step: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "validation" | "unspecified" | "source" | "request" | "failed" | "transfer" | "dropped" | "refunded" | "execution" | "bridge_fulfillment" | "fulfilling" | "settlement">]>;
|
|
793
793
|
readonly status: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "completed" | "current" | "planned">]>;
|
|
794
794
|
readonly expectedDurationMs: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, number>]>;
|
|
795
795
|
}, undefined>, undefined>, readonly []>;
|
|
@@ -799,7 +799,7 @@ declare const LifecycleFlowDetailSchema: v.ObjectSchema<{
|
|
|
799
799
|
smartAccountAddress: string;
|
|
800
800
|
flowId: string;
|
|
801
801
|
flowKind: "unspecified" | "deposit" | "withdraw" | "transfer";
|
|
802
|
-
currentStep: "validation" | "unspecified" | "source" | "request" | "
|
|
802
|
+
currentStep: "validation" | "unspecified" | "source" | "request" | "failed" | "transfer" | "dropped" | "refunded" | "execution" | "bridge_fulfillment" | "fulfilling" | "settlement";
|
|
803
803
|
assetIds?: {
|
|
804
804
|
zippedAssetId: number;
|
|
805
805
|
unifiedAssetId: number;
|
|
@@ -851,7 +851,7 @@ declare const LifecycleFlowDetailSchema: v.ObjectSchema<{
|
|
|
851
851
|
} | undefined;
|
|
852
852
|
progressTimeline: {
|
|
853
853
|
sequence: number;
|
|
854
|
-
step: "validation" | "unspecified" | "source" | "request" | "
|
|
854
|
+
step: "validation" | "unspecified" | "source" | "request" | "failed" | "transfer" | "dropped" | "refunded" | "execution" | "bridge_fulfillment" | "fulfilling" | "settlement";
|
|
855
855
|
status: "unspecified" | "completed" | "current" | "planned";
|
|
856
856
|
expectedDurationMs: number;
|
|
857
857
|
}[];
|
|
@@ -861,7 +861,7 @@ declare const LifecycleFlowDetailSchema: v.ObjectSchema<{
|
|
|
861
861
|
smartAccountAddress: string;
|
|
862
862
|
flowId: string;
|
|
863
863
|
flowKind: "unspecified" | "deposit" | "withdraw" | "transfer";
|
|
864
|
-
currentStep: "validation" | "unspecified" | "source" | "request" | "
|
|
864
|
+
currentStep: "validation" | "unspecified" | "source" | "request" | "failed" | "transfer" | "dropped" | "refunded" | "execution" | "bridge_fulfillment" | "fulfilling" | "settlement";
|
|
865
865
|
assetIds?: {
|
|
866
866
|
zippedAssetId: number;
|
|
867
867
|
unifiedAssetId: number;
|
|
@@ -913,7 +913,7 @@ declare const LifecycleFlowDetailSchema: v.ObjectSchema<{
|
|
|
913
913
|
} | undefined;
|
|
914
914
|
progressTimeline: {
|
|
915
915
|
sequence: number;
|
|
916
|
-
step: "validation" | "unspecified" | "source" | "request" | "
|
|
916
|
+
step: "validation" | "unspecified" | "source" | "request" | "failed" | "transfer" | "dropped" | "refunded" | "execution" | "bridge_fulfillment" | "fulfilling" | "settlement";
|
|
917
917
|
status: "unspecified" | "completed" | "current" | "planned";
|
|
918
918
|
expectedDurationMs: number;
|
|
919
919
|
}[];
|
|
@@ -923,7 +923,7 @@ declare const LifecycleFlowDetailSchema: v.ObjectSchema<{
|
|
|
923
923
|
}>]>, undefined>;
|
|
924
924
|
readonly observedSteps: v.OptionalSchema<v.ArraySchema<v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
925
925
|
readonly sequence: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
926
|
-
readonly step: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "validation" | "unspecified" | "source" | "request" | "
|
|
926
|
+
readonly step: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "validation" | "unspecified" | "source" | "request" | "failed" | "transfer" | "dropped" | "refunded" | "execution" | "bridge_fulfillment" | "fulfilling" | "settlement">]>;
|
|
927
927
|
readonly assetIds: v.OptionalSchema<v.ObjectSchema<{
|
|
928
928
|
readonly zippedAssetId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
929
929
|
readonly unifiedAssetId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
@@ -1060,7 +1060,7 @@ declare const LifecycleFlowDetailSchema: v.ObjectSchema<{
|
|
|
1060
1060
|
}>]>, undefined>, readonly []>;
|
|
1061
1061
|
}, undefined>, v.TransformAction<{
|
|
1062
1062
|
sequence: number;
|
|
1063
|
-
step: "validation" | "unspecified" | "source" | "request" | "
|
|
1063
|
+
step: "validation" | "unspecified" | "source" | "request" | "failed" | "transfer" | "dropped" | "refunded" | "execution" | "bridge_fulfillment" | "fulfilling" | "settlement";
|
|
1064
1064
|
assetIds?: {
|
|
1065
1065
|
zippedAssetId: number;
|
|
1066
1066
|
unifiedAssetId: number;
|
|
@@ -1121,7 +1121,7 @@ declare const LifecycleFlowDetailSchema: v.ObjectSchema<{
|
|
|
1121
1121
|
})[];
|
|
1122
1122
|
}, Omit<{
|
|
1123
1123
|
sequence: number;
|
|
1124
|
-
step: "validation" | "unspecified" | "source" | "request" | "
|
|
1124
|
+
step: "validation" | "unspecified" | "source" | "request" | "failed" | "transfer" | "dropped" | "refunded" | "execution" | "bridge_fulfillment" | "fulfilling" | "settlement";
|
|
1125
1125
|
assetIds?: {
|
|
1126
1126
|
zippedAssetId: number;
|
|
1127
1127
|
unifiedAssetId: number;
|
|
@@ -1191,7 +1191,7 @@ declare const ListLifecycleFlowsOutputSchema: v.ObjectSchema<{
|
|
|
1191
1191
|
readonly smartAccountAddress: v.StringSchema<undefined>;
|
|
1192
1192
|
readonly flowId: v.StringSchema<undefined>;
|
|
1193
1193
|
readonly flowKind: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "deposit" | "withdraw" | "transfer">]>;
|
|
1194
|
-
readonly currentStep: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "validation" | "unspecified" | "source" | "request" | "
|
|
1194
|
+
readonly currentStep: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "validation" | "unspecified" | "source" | "request" | "failed" | "transfer" | "dropped" | "refunded" | "execution" | "bridge_fulfillment" | "fulfilling" | "settlement">]>;
|
|
1195
1195
|
readonly assetIds: v.OptionalSchema<v.ObjectSchema<{
|
|
1196
1196
|
readonly zippedAssetId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
1197
1197
|
readonly unifiedAssetId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
@@ -1271,7 +1271,7 @@ declare const ListLifecycleFlowsOutputSchema: v.ObjectSchema<{
|
|
|
1271
1271
|
}, undefined>, undefined>;
|
|
1272
1272
|
readonly progressTimeline: v.OptionalSchema<v.ArraySchema<v.ObjectSchema<{
|
|
1273
1273
|
readonly sequence: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
1274
|
-
readonly step: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "validation" | "unspecified" | "source" | "request" | "
|
|
1274
|
+
readonly step: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "validation" | "unspecified" | "source" | "request" | "failed" | "transfer" | "dropped" | "refunded" | "execution" | "bridge_fulfillment" | "fulfilling" | "settlement">]>;
|
|
1275
1275
|
readonly status: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "completed" | "current" | "planned">]>;
|
|
1276
1276
|
readonly expectedDurationMs: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, number>]>;
|
|
1277
1277
|
}, undefined>, undefined>, readonly []>;
|
|
@@ -1281,7 +1281,7 @@ declare const ListLifecycleFlowsOutputSchema: v.ObjectSchema<{
|
|
|
1281
1281
|
smartAccountAddress: string;
|
|
1282
1282
|
flowId: string;
|
|
1283
1283
|
flowKind: "unspecified" | "deposit" | "withdraw" | "transfer";
|
|
1284
|
-
currentStep: "validation" | "unspecified" | "source" | "request" | "
|
|
1284
|
+
currentStep: "validation" | "unspecified" | "source" | "request" | "failed" | "transfer" | "dropped" | "refunded" | "execution" | "bridge_fulfillment" | "fulfilling" | "settlement";
|
|
1285
1285
|
assetIds?: {
|
|
1286
1286
|
zippedAssetId: number;
|
|
1287
1287
|
unifiedAssetId: number;
|
|
@@ -1333,7 +1333,7 @@ declare const ListLifecycleFlowsOutputSchema: v.ObjectSchema<{
|
|
|
1333
1333
|
} | undefined;
|
|
1334
1334
|
progressTimeline: {
|
|
1335
1335
|
sequence: number;
|
|
1336
|
-
step: "validation" | "unspecified" | "source" | "request" | "
|
|
1336
|
+
step: "validation" | "unspecified" | "source" | "request" | "failed" | "transfer" | "dropped" | "refunded" | "execution" | "bridge_fulfillment" | "fulfilling" | "settlement";
|
|
1337
1337
|
status: "unspecified" | "completed" | "current" | "planned";
|
|
1338
1338
|
expectedDurationMs: number;
|
|
1339
1339
|
}[];
|
|
@@ -1343,7 +1343,7 @@ declare const ListLifecycleFlowsOutputSchema: v.ObjectSchema<{
|
|
|
1343
1343
|
smartAccountAddress: string;
|
|
1344
1344
|
flowId: string;
|
|
1345
1345
|
flowKind: "unspecified" | "deposit" | "withdraw" | "transfer";
|
|
1346
|
-
currentStep: "validation" | "unspecified" | "source" | "request" | "
|
|
1346
|
+
currentStep: "validation" | "unspecified" | "source" | "request" | "failed" | "transfer" | "dropped" | "refunded" | "execution" | "bridge_fulfillment" | "fulfilling" | "settlement";
|
|
1347
1347
|
assetIds?: {
|
|
1348
1348
|
zippedAssetId: number;
|
|
1349
1349
|
unifiedAssetId: number;
|
|
@@ -1395,7 +1395,7 @@ declare const ListLifecycleFlowsOutputSchema: v.ObjectSchema<{
|
|
|
1395
1395
|
} | undefined;
|
|
1396
1396
|
progressTimeline: {
|
|
1397
1397
|
sequence: number;
|
|
1398
|
-
step: "validation" | "unspecified" | "source" | "request" | "
|
|
1398
|
+
step: "validation" | "unspecified" | "source" | "request" | "failed" | "transfer" | "dropped" | "refunded" | "execution" | "bridge_fulfillment" | "fulfilling" | "settlement";
|
|
1399
1399
|
status: "unspecified" | "completed" | "current" | "planned";
|
|
1400
1400
|
expectedDurationMs: number;
|
|
1401
1401
|
}[];
|
|
@@ -1412,7 +1412,7 @@ declare const GetLifecycleFlowOutputSchema: v.ObjectSchema<{
|
|
|
1412
1412
|
readonly smartAccountAddress: v.StringSchema<undefined>;
|
|
1413
1413
|
readonly flowId: v.StringSchema<undefined>;
|
|
1414
1414
|
readonly flowKind: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "deposit" | "withdraw" | "transfer">]>;
|
|
1415
|
-
readonly currentStep: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "validation" | "unspecified" | "source" | "request" | "
|
|
1415
|
+
readonly currentStep: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "validation" | "unspecified" | "source" | "request" | "failed" | "transfer" | "dropped" | "refunded" | "execution" | "bridge_fulfillment" | "fulfilling" | "settlement">]>;
|
|
1416
1416
|
readonly assetIds: v.OptionalSchema<v.ObjectSchema<{
|
|
1417
1417
|
readonly zippedAssetId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
1418
1418
|
readonly unifiedAssetId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
@@ -1492,7 +1492,7 @@ declare const GetLifecycleFlowOutputSchema: v.ObjectSchema<{
|
|
|
1492
1492
|
}, undefined>, undefined>;
|
|
1493
1493
|
readonly progressTimeline: v.OptionalSchema<v.ArraySchema<v.ObjectSchema<{
|
|
1494
1494
|
readonly sequence: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
1495
|
-
readonly step: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "validation" | "unspecified" | "source" | "request" | "
|
|
1495
|
+
readonly step: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "validation" | "unspecified" | "source" | "request" | "failed" | "transfer" | "dropped" | "refunded" | "execution" | "bridge_fulfillment" | "fulfilling" | "settlement">]>;
|
|
1496
1496
|
readonly status: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "completed" | "current" | "planned">]>;
|
|
1497
1497
|
readonly expectedDurationMs: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, number>]>;
|
|
1498
1498
|
}, undefined>, undefined>, readonly []>;
|
|
@@ -1502,7 +1502,7 @@ declare const GetLifecycleFlowOutputSchema: v.ObjectSchema<{
|
|
|
1502
1502
|
smartAccountAddress: string;
|
|
1503
1503
|
flowId: string;
|
|
1504
1504
|
flowKind: "unspecified" | "deposit" | "withdraw" | "transfer";
|
|
1505
|
-
currentStep: "validation" | "unspecified" | "source" | "request" | "
|
|
1505
|
+
currentStep: "validation" | "unspecified" | "source" | "request" | "failed" | "transfer" | "dropped" | "refunded" | "execution" | "bridge_fulfillment" | "fulfilling" | "settlement";
|
|
1506
1506
|
assetIds?: {
|
|
1507
1507
|
zippedAssetId: number;
|
|
1508
1508
|
unifiedAssetId: number;
|
|
@@ -1554,7 +1554,7 @@ declare const GetLifecycleFlowOutputSchema: v.ObjectSchema<{
|
|
|
1554
1554
|
} | undefined;
|
|
1555
1555
|
progressTimeline: {
|
|
1556
1556
|
sequence: number;
|
|
1557
|
-
step: "validation" | "unspecified" | "source" | "request" | "
|
|
1557
|
+
step: "validation" | "unspecified" | "source" | "request" | "failed" | "transfer" | "dropped" | "refunded" | "execution" | "bridge_fulfillment" | "fulfilling" | "settlement";
|
|
1558
1558
|
status: "unspecified" | "completed" | "current" | "planned";
|
|
1559
1559
|
expectedDurationMs: number;
|
|
1560
1560
|
}[];
|
|
@@ -1564,7 +1564,7 @@ declare const GetLifecycleFlowOutputSchema: v.ObjectSchema<{
|
|
|
1564
1564
|
smartAccountAddress: string;
|
|
1565
1565
|
flowId: string;
|
|
1566
1566
|
flowKind: "unspecified" | "deposit" | "withdraw" | "transfer";
|
|
1567
|
-
currentStep: "validation" | "unspecified" | "source" | "request" | "
|
|
1567
|
+
currentStep: "validation" | "unspecified" | "source" | "request" | "failed" | "transfer" | "dropped" | "refunded" | "execution" | "bridge_fulfillment" | "fulfilling" | "settlement";
|
|
1568
1568
|
assetIds?: {
|
|
1569
1569
|
zippedAssetId: number;
|
|
1570
1570
|
unifiedAssetId: number;
|
|
@@ -1616,7 +1616,7 @@ declare const GetLifecycleFlowOutputSchema: v.ObjectSchema<{
|
|
|
1616
1616
|
} | undefined;
|
|
1617
1617
|
progressTimeline: {
|
|
1618
1618
|
sequence: number;
|
|
1619
|
-
step: "validation" | "unspecified" | "source" | "request" | "
|
|
1619
|
+
step: "validation" | "unspecified" | "source" | "request" | "failed" | "transfer" | "dropped" | "refunded" | "execution" | "bridge_fulfillment" | "fulfilling" | "settlement";
|
|
1620
1620
|
status: "unspecified" | "completed" | "current" | "planned";
|
|
1621
1621
|
expectedDurationMs: number;
|
|
1622
1622
|
}[];
|
|
@@ -1626,7 +1626,7 @@ declare const GetLifecycleFlowOutputSchema: v.ObjectSchema<{
|
|
|
1626
1626
|
}>]>, undefined>;
|
|
1627
1627
|
readonly observedSteps: v.OptionalSchema<v.ArraySchema<v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
1628
1628
|
readonly sequence: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
1629
|
-
readonly step: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "validation" | "unspecified" | "source" | "request" | "
|
|
1629
|
+
readonly step: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "validation" | "unspecified" | "source" | "request" | "failed" | "transfer" | "dropped" | "refunded" | "execution" | "bridge_fulfillment" | "fulfilling" | "settlement">]>;
|
|
1630
1630
|
readonly assetIds: v.OptionalSchema<v.ObjectSchema<{
|
|
1631
1631
|
readonly zippedAssetId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
1632
1632
|
readonly unifiedAssetId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
@@ -1763,7 +1763,7 @@ declare const GetLifecycleFlowOutputSchema: v.ObjectSchema<{
|
|
|
1763
1763
|
}>]>, undefined>, readonly []>;
|
|
1764
1764
|
}, undefined>, v.TransformAction<{
|
|
1765
1765
|
sequence: number;
|
|
1766
|
-
step: "validation" | "unspecified" | "source" | "request" | "
|
|
1766
|
+
step: "validation" | "unspecified" | "source" | "request" | "failed" | "transfer" | "dropped" | "refunded" | "execution" | "bridge_fulfillment" | "fulfilling" | "settlement";
|
|
1767
1767
|
assetIds?: {
|
|
1768
1768
|
zippedAssetId: number;
|
|
1769
1769
|
unifiedAssetId: number;
|
|
@@ -1824,7 +1824,7 @@ declare const GetLifecycleFlowOutputSchema: v.ObjectSchema<{
|
|
|
1824
1824
|
})[];
|
|
1825
1825
|
}, Omit<{
|
|
1826
1826
|
sequence: number;
|
|
1827
|
-
step: "validation" | "unspecified" | "source" | "request" | "
|
|
1827
|
+
step: "validation" | "unspecified" | "source" | "request" | "failed" | "transfer" | "dropped" | "refunded" | "execution" | "bridge_fulfillment" | "fulfilling" | "settlement";
|
|
1828
1828
|
assetIds?: {
|
|
1829
1829
|
zippedAssetId: number;
|
|
1830
1830
|
unifiedAssetId: number;
|
|
@@ -1899,7 +1899,7 @@ declare const LifecycleFlowTxMatchSchema: v.SchemaWithPipe<readonly [v.ObjectSch
|
|
|
1899
1899
|
readonly txOccurrenceIndex: v.SchemaWithPipe<readonly [v.OptionalSchema<v.BigintSchema<undefined>, undefined>, v.TransformAction<bigint | undefined, number>]>;
|
|
1900
1900
|
readonly sourceDomain: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "funding" | "trading" | "external_chain" | "zipper" | "lending">]>;
|
|
1901
1901
|
readonly destinationDomain: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "funding" | "trading" | "external_chain" | "zipper" | "lending">]>;
|
|
1902
|
-
readonly currentStep: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "validation" | "unspecified" | "source" | "request" | "
|
|
1902
|
+
readonly currentStep: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "validation" | "unspecified" | "source" | "request" | "failed" | "transfer" | "dropped" | "refunded" | "execution" | "bridge_fulfillment" | "fulfilling" | "settlement">]>;
|
|
1903
1903
|
readonly isOpen: v.BooleanSchema<undefined>;
|
|
1904
1904
|
readonly isTerminal: v.BooleanSchema<undefined>;
|
|
1905
1905
|
readonly assetIds: v.OptionalSchema<v.ObjectSchema<{
|
|
@@ -1933,7 +1933,7 @@ declare const LifecycleFlowTxMatchSchema: v.SchemaWithPipe<readonly [v.ObjectSch
|
|
|
1933
1933
|
txOccurrenceIndex?: number | undefined;
|
|
1934
1934
|
sourceDomain: "unspecified" | "funding" | "trading" | "external_chain" | "zipper" | "lending";
|
|
1935
1935
|
destinationDomain: "unspecified" | "funding" | "trading" | "external_chain" | "zipper" | "lending";
|
|
1936
|
-
currentStep: "validation" | "unspecified" | "source" | "request" | "
|
|
1936
|
+
currentStep: "validation" | "unspecified" | "source" | "request" | "failed" | "transfer" | "dropped" | "refunded" | "execution" | "bridge_fulfillment" | "fulfilling" | "settlement";
|
|
1937
1937
|
isOpen: boolean;
|
|
1938
1938
|
isTerminal: boolean;
|
|
1939
1939
|
assetIds?: {
|
|
@@ -1961,7 +1961,7 @@ declare const LifecycleFlowTxMatchSchema: v.SchemaWithPipe<readonly [v.ObjectSch
|
|
|
1961
1961
|
txOccurrenceIndex?: number | undefined;
|
|
1962
1962
|
sourceDomain: "unspecified" | "funding" | "trading" | "external_chain" | "zipper" | "lending";
|
|
1963
1963
|
destinationDomain: "unspecified" | "funding" | "trading" | "external_chain" | "zipper" | "lending";
|
|
1964
|
-
currentStep: "validation" | "unspecified" | "source" | "request" | "
|
|
1964
|
+
currentStep: "validation" | "unspecified" | "source" | "request" | "failed" | "transfer" | "dropped" | "refunded" | "execution" | "bridge_fulfillment" | "fulfilling" | "settlement";
|
|
1965
1965
|
isOpen: boolean;
|
|
1966
1966
|
isTerminal: boolean;
|
|
1967
1967
|
assetIds?: {
|
|
@@ -1994,7 +1994,7 @@ declare const ListLifecycleFlowsByTxOutputSchema: v.ObjectSchema<{
|
|
|
1994
1994
|
readonly txOccurrenceIndex: v.SchemaWithPipe<readonly [v.OptionalSchema<v.BigintSchema<undefined>, undefined>, v.TransformAction<bigint | undefined, number>]>;
|
|
1995
1995
|
readonly sourceDomain: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "funding" | "trading" | "external_chain" | "zipper" | "lending">]>;
|
|
1996
1996
|
readonly destinationDomain: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "funding" | "trading" | "external_chain" | "zipper" | "lending">]>;
|
|
1997
|
-
readonly currentStep: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "validation" | "unspecified" | "source" | "request" | "
|
|
1997
|
+
readonly currentStep: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "validation" | "unspecified" | "source" | "request" | "failed" | "transfer" | "dropped" | "refunded" | "execution" | "bridge_fulfillment" | "fulfilling" | "settlement">]>;
|
|
1998
1998
|
readonly isOpen: v.BooleanSchema<undefined>;
|
|
1999
1999
|
readonly isTerminal: v.BooleanSchema<undefined>;
|
|
2000
2000
|
readonly assetIds: v.OptionalSchema<v.ObjectSchema<{
|
|
@@ -2028,7 +2028,7 @@ declare const ListLifecycleFlowsByTxOutputSchema: v.ObjectSchema<{
|
|
|
2028
2028
|
txOccurrenceIndex?: number | undefined;
|
|
2029
2029
|
sourceDomain: "unspecified" | "funding" | "trading" | "external_chain" | "zipper" | "lending";
|
|
2030
2030
|
destinationDomain: "unspecified" | "funding" | "trading" | "external_chain" | "zipper" | "lending";
|
|
2031
|
-
currentStep: "validation" | "unspecified" | "source" | "request" | "
|
|
2031
|
+
currentStep: "validation" | "unspecified" | "source" | "request" | "failed" | "transfer" | "dropped" | "refunded" | "execution" | "bridge_fulfillment" | "fulfilling" | "settlement";
|
|
2032
2032
|
isOpen: boolean;
|
|
2033
2033
|
isTerminal: boolean;
|
|
2034
2034
|
assetIds?: {
|
|
@@ -2056,7 +2056,7 @@ declare const ListLifecycleFlowsByTxOutputSchema: v.ObjectSchema<{
|
|
|
2056
2056
|
txOccurrenceIndex?: number | undefined;
|
|
2057
2057
|
sourceDomain: "unspecified" | "funding" | "trading" | "external_chain" | "zipper" | "lending";
|
|
2058
2058
|
destinationDomain: "unspecified" | "funding" | "trading" | "external_chain" | "zipper" | "lending";
|
|
2059
|
-
currentStep: "validation" | "unspecified" | "source" | "request" | "
|
|
2059
|
+
currentStep: "validation" | "unspecified" | "source" | "request" | "failed" | "transfer" | "dropped" | "refunded" | "execution" | "bridge_fulfillment" | "fulfilling" | "settlement";
|
|
2060
2060
|
isOpen: boolean;
|
|
2061
2061
|
isTerminal: boolean;
|
|
2062
2062
|
assetIds?: {
|
|
@@ -260,7 +260,7 @@ declare function createOrderSchema(scales: SdkScales): v.SchemaWithPipe<readonly
|
|
|
260
260
|
attachedRisk: {
|
|
261
261
|
takeProfit: {
|
|
262
262
|
state: {
|
|
263
|
-
status: "unspecified" | "
|
|
263
|
+
status: "unspecified" | "failed" | "completed" | "created" | "canceled" | "not_configured" | "armed" | "running" | "paused";
|
|
264
264
|
armedTs: number | undefined;
|
|
265
265
|
armedTsNs: string | undefined;
|
|
266
266
|
terminalTs: number | undefined;
|
|
@@ -279,7 +279,7 @@ declare function createOrderSchema(scales: SdkScales): v.SchemaWithPipe<readonly
|
|
|
279
279
|
} | undefined;
|
|
280
280
|
stopLoss: {
|
|
281
281
|
state: {
|
|
282
|
-
status: "unspecified" | "
|
|
282
|
+
status: "unspecified" | "failed" | "completed" | "created" | "canceled" | "not_configured" | "armed" | "running" | "paused";
|
|
283
283
|
armedTs: number | undefined;
|
|
284
284
|
armedTsNs: string | undefined;
|
|
285
285
|
terminalTs: number | undefined;
|
|
@@ -298,7 +298,7 @@ declare function createOrderSchema(scales: SdkScales): v.SchemaWithPipe<readonly
|
|
|
298
298
|
} | undefined;
|
|
299
299
|
trailingStop: {
|
|
300
300
|
state: {
|
|
301
|
-
status: "unspecified" | "
|
|
301
|
+
status: "unspecified" | "failed" | "completed" | "created" | "canceled" | "not_configured" | "armed" | "running" | "paused";
|
|
302
302
|
armedTs: number | undefined;
|
|
303
303
|
armedTsNs: string | undefined;
|
|
304
304
|
terminalTs: number | undefined;
|
|
@@ -631,7 +631,7 @@ declare function createOrderDetailsSchema(scales: SdkScales): v.ObjectSchema<{
|
|
|
631
631
|
attachedRisk: {
|
|
632
632
|
takeProfit: {
|
|
633
633
|
state: {
|
|
634
|
-
status: "unspecified" | "
|
|
634
|
+
status: "unspecified" | "failed" | "completed" | "created" | "canceled" | "not_configured" | "armed" | "running" | "paused";
|
|
635
635
|
armedTs: number | undefined;
|
|
636
636
|
armedTsNs: string | undefined;
|
|
637
637
|
terminalTs: number | undefined;
|
|
@@ -650,7 +650,7 @@ declare function createOrderDetailsSchema(scales: SdkScales): v.ObjectSchema<{
|
|
|
650
650
|
} | undefined;
|
|
651
651
|
stopLoss: {
|
|
652
652
|
state: {
|
|
653
|
-
status: "unspecified" | "
|
|
653
|
+
status: "unspecified" | "failed" | "completed" | "created" | "canceled" | "not_configured" | "armed" | "running" | "paused";
|
|
654
654
|
armedTs: number | undefined;
|
|
655
655
|
armedTsNs: string | undefined;
|
|
656
656
|
terminalTs: number | undefined;
|
|
@@ -669,7 +669,7 @@ declare function createOrderDetailsSchema(scales: SdkScales): v.ObjectSchema<{
|
|
|
669
669
|
} | undefined;
|
|
670
670
|
trailingStop: {
|
|
671
671
|
state: {
|
|
672
|
-
status: "unspecified" | "
|
|
672
|
+
status: "unspecified" | "failed" | "completed" | "created" | "canceled" | "not_configured" | "armed" | "running" | "paused";
|
|
673
673
|
armedTs: number | undefined;
|
|
674
674
|
armedTsNs: string | undefined;
|
|
675
675
|
terminalTs: number | undefined;
|
|
@@ -168,7 +168,7 @@ declare const GetUserTradesInputSchema: v.SchemaWithPipe<readonly [v.UnionSchema
|
|
|
168
168
|
readonly orderId: v.OptionalSchema<v.NeverSchema<undefined>, undefined>;
|
|
169
169
|
readonly lineageId: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>, v.TransformAction<string, bigint>]>, v.CheckAction<bigint, `${string} must be greater than zero`>]>;
|
|
170
170
|
readonly throughGeneration: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 1, undefined>, v.MaxValueAction<number, 4294967295, undefined>]>, undefined>;
|
|
171
|
-
}, undefined>], undefined>], ({ input }: v.UnionIssue<v.NumberIssue | v.StringIssue | v.PicklistIssue | v.StrictObjectIssue | v.MinLengthIssue<string, 1> | v.UnionIssue<v.StringIssue | v.PicklistIssue | v.StrictObjectIssue | v.MinLengthIssue<string, 1>> | v.IntegerIssue<number> | v.MaxValueIssue<number, 4294967295> | v.CheckIssue<bigint> | v.BooleanIssue | v.NeverIssue | v.
|
|
171
|
+
}, undefined>], undefined>], ({ input }: v.UnionIssue<v.NumberIssue | v.StringIssue | v.PicklistIssue | v.StrictObjectIssue | v.MinLengthIssue<string, 1> | v.UnionIssue<v.StringIssue | v.PicklistIssue | v.StrictObjectIssue | v.MinLengthIssue<string, 1>> | v.IntegerIssue<number> | v.MaxValueIssue<number, 4294967295> | v.CheckIssue<bigint> | v.BooleanIssue | v.NeverIssue | v.MaxValueIssue<number, 1000> | v.MinValueIssue<number, 1> | v.UnionIssue<v.NumberIssue | v.StringIssue | v.PicklistIssue | v.StrictObjectIssue | v.MinLengthIssue<string, 1> | v.UnionIssue<v.StringIssue | v.PicklistIssue | v.StrictObjectIssue | v.MinLengthIssue<string, 1>> | v.IntegerIssue<number> | v.MaxValueIssue<number, 4294967295> | v.CheckIssue<bigint> | v.BooleanIssue | v.NeverIssue | v.MaxValueIssue<number, 1000> | v.MinValueIssue<number, 1>> | v.CheckIssue<number> | v.UnionIssue<v.NumberIssue | v.StringIssue | v.PicklistIssue | v.StrictObjectIssue | v.MinLengthIssue<string, 1> | v.UnionIssue<v.StringIssue | v.PicklistIssue | v.StrictObjectIssue | v.MinLengthIssue<string, 1>> | v.IntegerIssue<number> | v.MaxValueIssue<number, 4294967295> | v.CheckIssue<bigint> | v.BooleanIssue | v.NeverIssue | v.MaxValueIssue<number, 1000> | v.MinValueIssue<number, 1> | v.CheckIssue<number>>>) => "symbolId is required when afterMatchId is set" | "Provide at most one of orderId or lineageId">, v.TransformAction<{
|
|
172
172
|
symbolId?: number | undefined;
|
|
173
173
|
afterMatchId?: undefined;
|
|
174
174
|
side?: Side.BUY | Side.SELL | undefined;
|
|
@@ -845,7 +845,7 @@ type CreateTriggerInput = v.InferInput<ReturnType<typeof createCreateTriggerInpu
|
|
|
845
845
|
declare const ListTriggersInputSchema: v.SchemaWithPipe<readonly [v.StrictObjectSchema<{
|
|
846
846
|
readonly parentOrderId: v.SchemaWithPipe<readonly [v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction]>, undefined>, v.TransformAction<string | undefined, bigint | undefined>]>;
|
|
847
847
|
readonly symbolId: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>, v.MaxValueAction<number, 4294967295, undefined>]>, undefined>;
|
|
848
|
-
readonly status: v.SchemaWithPipe<readonly [v.OptionalSchema<v.ArraySchema<v.PicklistSchema<readonly ["created", "armed", "running", "completed", "cancelled", "failed", "paused"], undefined>, undefined>, undefined>, v.TransformAction<("
|
|
848
|
+
readonly status: v.SchemaWithPipe<readonly [v.OptionalSchema<v.ArraySchema<v.PicklistSchema<readonly ["created", "armed", "running", "completed", "cancelled", "failed", "paused"], undefined>, undefined>, undefined>, v.TransformAction<("failed" | "cancelled" | "completed" | "created" | "armed" | "running" | "paused")[] | undefined, (TriggerStatus.STATUS_CREATED | TriggerStatus.STATUS_ARMED | TriggerStatus.STATUS_RUNNING | TriggerStatus.STATUS_COMPLETED | TriggerStatus.STATUS_CANCELED | TriggerStatus.STATUS_FAILED | TriggerStatus.STATUS_PAUSED)[]>]>;
|
|
849
849
|
readonly triggerType: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<readonly ["stop_loss", "take_profit", "trailing_stop", "twap", "ladder"], undefined>, undefined>, v.TransformAction<"stop_loss" | "take_profit" | "trailing_stop" | "twap" | "ladder" | undefined, TriggerType>]>;
|
|
850
850
|
readonly limit: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>, v.MaxValueAction<number, 1000, undefined>]>, 50>;
|
|
851
851
|
readonly pageToken: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction]>, "">;
|
|
@@ -29,62 +29,62 @@ declare const CreateTriggerResultSchema: v.SchemaWithPipe<readonly [v.ObjectSche
|
|
|
29
29
|
type CreateTriggerResult = v.InferOutput<typeof CreateTriggerResultSchema>;
|
|
30
30
|
declare const CancelTriggerResultSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
31
31
|
readonly triggerId: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, string>]>;
|
|
32
|
-
readonly status: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "
|
|
32
|
+
readonly status: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "failed" | "cancelled" | "completed" | "created" | "armed" | "running" | "paused">]>;
|
|
33
33
|
readonly tsNs: v.BigintSchema<undefined>;
|
|
34
34
|
}, undefined>, v.TransformAction<{
|
|
35
35
|
triggerId: string;
|
|
36
|
-
status: "unspecified" | "
|
|
36
|
+
status: "unspecified" | "failed" | "cancelled" | "completed" | "created" | "armed" | "running" | "paused";
|
|
37
37
|
tsNs: bigint;
|
|
38
38
|
}, {
|
|
39
39
|
ts: number;
|
|
40
40
|
tsNs: string;
|
|
41
41
|
triggerId: string;
|
|
42
|
-
status: "unspecified" | "
|
|
42
|
+
status: "unspecified" | "failed" | "cancelled" | "completed" | "created" | "armed" | "running" | "paused";
|
|
43
43
|
}>]>;
|
|
44
44
|
type CancelTriggerResult = v.InferOutput<typeof CancelTriggerResultSchema>;
|
|
45
45
|
declare const ModifyTriggerResultSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
46
46
|
readonly triggerId: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, string>]>;
|
|
47
|
-
readonly status: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "
|
|
47
|
+
readonly status: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "failed" | "cancelled" | "completed" | "created" | "armed" | "running" | "paused">]>;
|
|
48
48
|
readonly tsNs: v.BigintSchema<undefined>;
|
|
49
49
|
}, undefined>, v.TransformAction<{
|
|
50
50
|
triggerId: string;
|
|
51
|
-
status: "unspecified" | "
|
|
51
|
+
status: "unspecified" | "failed" | "cancelled" | "completed" | "created" | "armed" | "running" | "paused";
|
|
52
52
|
tsNs: bigint;
|
|
53
53
|
}, {
|
|
54
54
|
ts: number;
|
|
55
55
|
tsNs: string;
|
|
56
56
|
triggerId: string;
|
|
57
|
-
status: "unspecified" | "
|
|
57
|
+
status: "unspecified" | "failed" | "cancelled" | "completed" | "created" | "armed" | "running" | "paused";
|
|
58
58
|
}>]>;
|
|
59
59
|
type ModifyTriggerResult = v.InferOutput<typeof ModifyTriggerResultSchema>;
|
|
60
60
|
declare const PauseTriggerResultSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
61
61
|
readonly triggerId: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, string>]>;
|
|
62
|
-
readonly status: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "
|
|
62
|
+
readonly status: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "failed" | "cancelled" | "completed" | "created" | "armed" | "running" | "paused">]>;
|
|
63
63
|
readonly tsNs: v.BigintSchema<undefined>;
|
|
64
64
|
}, undefined>, v.TransformAction<{
|
|
65
65
|
triggerId: string;
|
|
66
|
-
status: "unspecified" | "
|
|
66
|
+
status: "unspecified" | "failed" | "cancelled" | "completed" | "created" | "armed" | "running" | "paused";
|
|
67
67
|
tsNs: bigint;
|
|
68
68
|
}, {
|
|
69
69
|
ts: number;
|
|
70
70
|
tsNs: string;
|
|
71
71
|
triggerId: string;
|
|
72
|
-
status: "unspecified" | "
|
|
72
|
+
status: "unspecified" | "failed" | "cancelled" | "completed" | "created" | "armed" | "running" | "paused";
|
|
73
73
|
}>]>;
|
|
74
74
|
type PauseTriggerResult = v.InferOutput<typeof PauseTriggerResultSchema>;
|
|
75
75
|
declare const ResumeTriggerResultSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
76
76
|
readonly triggerId: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, string>]>;
|
|
77
|
-
readonly status: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "
|
|
77
|
+
readonly status: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "failed" | "cancelled" | "completed" | "created" | "armed" | "running" | "paused">]>;
|
|
78
78
|
readonly tsNs: v.BigintSchema<undefined>;
|
|
79
79
|
}, undefined>, v.TransformAction<{
|
|
80
80
|
triggerId: string;
|
|
81
|
-
status: "unspecified" | "
|
|
81
|
+
status: "unspecified" | "failed" | "cancelled" | "completed" | "created" | "armed" | "running" | "paused";
|
|
82
82
|
tsNs: bigint;
|
|
83
83
|
}, {
|
|
84
84
|
ts: number;
|
|
85
85
|
tsNs: string;
|
|
86
86
|
triggerId: string;
|
|
87
|
-
status: "unspecified" | "
|
|
87
|
+
status: "unspecified" | "failed" | "cancelled" | "completed" | "created" | "armed" | "running" | "paused";
|
|
88
88
|
}>]>;
|
|
89
89
|
type ResumeTriggerResult = v.InferOutput<typeof ResumeTriggerResultSchema>;
|
|
90
90
|
type StopDetailsOutput = {
|
|
@@ -560,7 +560,7 @@ declare function createTriggerSchema(scales: SdkScales): v.SchemaWithPipe<readon
|
|
|
560
560
|
triggerId: string;
|
|
561
561
|
subaccountId: string;
|
|
562
562
|
symbolId: number;
|
|
563
|
-
status: "unspecified" | "
|
|
563
|
+
status: "unspecified" | "failed" | "cancelled" | "completed" | "created" | "armed" | "running" | "paused";
|
|
564
564
|
parentOrderId: string | undefined;
|
|
565
565
|
qty: string;
|
|
566
566
|
feeAsset: "unspecified" | "quote" | "base";
|
|
@@ -716,7 +716,7 @@ declare function createTriggerSchema(scales: SdkScales): v.SchemaWithPipe<readon
|
|
|
716
716
|
triggerId: string;
|
|
717
717
|
subaccountId: string;
|
|
718
718
|
symbolId: number;
|
|
719
|
-
status: "unspecified" | "
|
|
719
|
+
status: "unspecified" | "failed" | "cancelled" | "completed" | "created" | "armed" | "running" | "paused";
|
|
720
720
|
parentOrderId: string | undefined;
|
|
721
721
|
qty: string;
|
|
722
722
|
feeAsset: "unspecified" | "quote" | "base";
|
|
@@ -872,7 +872,7 @@ declare function createTriggerSchema(scales: SdkScales): v.SchemaWithPipe<readon
|
|
|
872
872
|
triggerId: string;
|
|
873
873
|
subaccountId: string;
|
|
874
874
|
symbolId: number;
|
|
875
|
-
status: "unspecified" | "
|
|
875
|
+
status: "unspecified" | "failed" | "cancelled" | "completed" | "created" | "armed" | "running" | "paused";
|
|
876
876
|
parentOrderId: string | undefined;
|
|
877
877
|
qty: string;
|
|
878
878
|
feeAsset: "unspecified" | "quote" | "base";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connect-error-mapping.d.ts","names":[],"sources":["../../src/shared/connect-error-mapping.ts"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"connect-error-mapping.d.ts","names":[],"sources":["../../src/shared/connect-error-mapping.ts"],"mappings":";;;;;;;iBAqIgB,6BAA6B,IAAI,eAAe;;;;;;iBA0KhD,iBAAiB;;;;;;iBA0CjB,iCAAiC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AlreadyExistsError, AuthenticationError, InternalServerError, MfaEnrollmentRequiredError, MfaLastFactorRequiredError, MfaVerificationError, PermissionError, PolicyInUseError, PolicyLockedError, PolicyScopeMismatchError, PolyesterError, PreconditionFailedError, RateLimitError, ResourceNotFoundError, RevisionConflictError, ServiceUnavailableError, SessionElevationRequiredError, StaleQuoteError, StepUpRequiredError, SubaccountChallengeInvalidError, TimeoutError, TransientError, ValidationError, isAbortError, normalizeErrorMessage } from "./errors.js";
|
|
1
|
+
import { AlreadyExistsError, AuthenticationError, InternalServerError, MfaEnrollmentRequiredError, MfaLastFactorRequiredError, MfaVerificationError, NotImplementedError, PermissionError, PolicyInUseError, PolicyLockedError, PolicyScopeMismatchError, PolyesterError, PreconditionFailedError, RateLimitError, ResourceNotFoundError, RevisionConflictError, ServiceUnavailableError, SessionElevationRequiredError, StaleQuoteError, StepUpRequiredError, SubaccountChallengeInvalidError, TimeoutError, TransientError, ValidationError, errorFromHttpStatus, isAbortError, normalizeErrorMessage } from "./errors.js";
|
|
2
2
|
import { parseConnectErrorDetail } from "./error-detail.js";
|
|
3
3
|
import { Code, ConnectError } from "@connectrpc/connect";
|
|
4
4
|
//#region src/shared/connect-error-mapping.ts
|
|
@@ -76,6 +76,11 @@ function connectErrorToPolyesterError(ce) {
|
|
|
76
76
|
detail
|
|
77
77
|
};
|
|
78
78
|
const withFallback = (fallback) => message || fallback;
|
|
79
|
+
const httpStatus = /^HTTP (\d{3})$/u.exec(ce.rawMessage)?.[1];
|
|
80
|
+
if (!detail && httpStatus && httpStatus !== "404") return errorFromHttpStatus(Number(httpStatus), message, {
|
|
81
|
+
...options,
|
|
82
|
+
retryAfterMs: parseRetryAfterMs(ce)
|
|
83
|
+
});
|
|
79
84
|
if (detail?.service === "auth" && detail.code === "AUTH_RESOURCE_NOT_FOUND") return new ResourceNotFoundError(withFallback("Resource not found."), options);
|
|
80
85
|
if (detail?.service === "auth" && detail.code === "AUTH_REVISION_CONFLICT") return new RevisionConflictError(withFallback("Resource changed since it was last read."), options);
|
|
81
86
|
if (detail?.service === "auth" && detail.code === "AUTH_SUBACCOUNT_CHALLENGE_INVALID") return new SubaccountChallengeInvalidError(withFallback("Subaccount challenge is expired, replaced, or invalid."), options);
|
|
@@ -110,6 +115,7 @@ function connectErrorToPolyesterError(ce) {
|
|
|
110
115
|
});
|
|
111
116
|
case Code.DeadlineExceeded: return new TimeoutError(withFallback("Request timed out."), options);
|
|
112
117
|
case Code.Unavailable: return new ServiceUnavailableError(withFallback("Service unavailable."), options);
|
|
118
|
+
case Code.Unimplemented: return new NotImplementedError(withFallback("Operation not implemented."), options);
|
|
113
119
|
case Code.Aborted: return new TransientError(withFallback("Operation aborted by the backend."), options);
|
|
114
120
|
default:
|
|
115
121
|
if (/service temporarily unavailable/i.test(message)) return new ServiceUnavailableError(withFallback("Service unavailable."), options);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connect-error-mapping.js","names":[],"sources":["../../src/shared/connect-error-mapping.ts"],"sourcesContent":["import { Code, ConnectError, type Interceptor, type Transport } from \"@connectrpc/connect\";\nimport { parseConnectErrorDetail, type PolyesterErrorDetail } from \"./error-detail.js\";\nimport {\n AlreadyExistsError,\n AuthenticationError,\n InternalServerError,\n isAbortError,\n MfaEnrollmentRequiredError,\n MfaLastFactorRequiredError,\n MfaVerificationError,\n type MfaVerificationFailureReason,\n normalizeErrorMessage,\n PermissionError,\n PolicyInUseError,\n PolicyLockedError,\n PolicyScopeMismatchError,\n PolyesterError,\n type PolyesterErrorOptions,\n PreconditionFailedError,\n RateLimitError,\n ResourceNotFoundError,\n RevisionConflictError,\n ServiceUnavailableError,\n SessionElevationRequiredError,\n StaleQuoteError,\n SubaccountChallengeInvalidError,\n StepUpRequiredError,\n TimeoutError,\n TransientError,\n ValidationError,\n} from \"./errors.js\";\nimport type { RateLimitDetail } from \"./rate-limit.schemas.js\";\n\nfunction hasTransientServiceError(detail: PolyesterErrorDetail | undefined): boolean {\n if (detail?.service === \"withdraw\") {\n return [\n \"SERVICE_UNAVAILABLE\",\n \"SOURCE_SMART_ACCOUNT_UNAVAILABLE\",\n \"CAPITAL_VIEW_UNAVAILABLE\",\n \"CHAIN_METADATA_UNAVAILABLE\",\n \"FEE_UNAVAILABLE\",\n \"SUPPLY_UNAVAILABLE\",\n \"STEP_UP_UNAVAILABLE\",\n \"DESTINATION_VALIDATION_UNAVAILABLE\",\n \"ACCOUNT_SHARD_UNAVAILABLE\",\n ].includes(detail.code);\n }\n if (detail?.service === \"internal_transfer\") {\n return [\n \"SERVICE_UNAVAILABLE\",\n \"SMART_ACCOUNT_UNAVAILABLE\",\n \"STEP_UP_UNAVAILABLE\",\n \"CAPITAL_VIEW_UNAVAILABLE\",\n \"ACCOUNT_SHARD_UNAVAILABLE\",\n ].includes(detail.code);\n }\n if (detail?.service === \"claims\") {\n return [\"SERVICE_UNAVAILABLE\", \"CLAIM_TEMPORARILY_UNAVAILABLE\"].includes(detail.code);\n }\n return false;\n}\n\nfunction safeRetryAfterMs(rateLimit: RateLimitDetail | undefined): number | undefined {\n if (rateLimit?.retryAfterMs === undefined) return undefined;\n const value = BigInt(rateLimit.retryAfterMs);\n return value <= BigInt(Number.MAX_SAFE_INTEGER) ? Number(value) : undefined;\n}\n\nconst HTTP_WEEKDAY = \"(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun)\";\nconst HTTP_WEEKDAY_LONG = \"(?:Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday)\";\nconst HTTP_MONTH = \"(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\";\nconst HTTP_DATE_RE = new RegExp(\n `^(?:${HTTP_WEEKDAY}, \\\\d{2} ${HTTP_MONTH} \\\\d{4} \\\\d{2}:\\\\d{2}:\\\\d{2} GMT|${HTTP_WEEKDAY_LONG}, \\\\d{2}-${HTTP_MONTH}-\\\\d{2} \\\\d{2}:\\\\d{2}:\\\\d{2} GMT|${HTTP_WEEKDAY} ${HTTP_MONTH} {1,2}\\\\d{1,2} \\\\d{2}:\\\\d{2}:\\\\d{2} \\\\d{4})$`,\n \"u\",\n);\n\n/**\n * Returns the error message without the leading \"[code] \" prefix that\n * `ConnectError` prepends, e.g. \"[invalid_argument] Insufficient funds.\"\n * becomes \"Insufficient funds.\".\n */\nexport function getNormalizedConnectMessage(err: unknown): string {\n const ce = ConnectError.from(err);\n const raw = ce.message ?? \"\";\n return normalizeErrorMessage(raw);\n}\n\nexport type MfaErrorKind = \"session-elevation\" | \"enrollment\" | \"step-up\";\n\n/**\n * Classifies an error as one of the MFA flows the backend can demand.\n * Classification is based only on stable structured auth error details.\n */\nexport function detectMfaErrorKind(err: unknown): MfaErrorKind | null {\n const mapped = toPolyesterError(err);\n return mfaErrorKind(mapped instanceof PolyesterError ? mapped.detail : undefined);\n}\n\nfunction mfaErrorKind(detail: PolyesterErrorDetail | undefined): MfaErrorKind | null {\n if (detail?.service === \"auth\" && detail.code === \"AUTH_MFA_ELEVATION_REQUIRED\") {\n return \"session-elevation\";\n }\n if (detail?.service === \"auth\" && detail.code === \"AUTH_STEP_UP_REQUIRED\") return \"step-up\";\n if (detail?.service === \"auth\" && detail.code === \"AUTH_MFA_NOT_ENROLLED\") return \"enrollment\";\n return null;\n}\n\nfunction parseRetryAfterMs(ce: ConnectError): number | undefined {\n const value = ce.metadata.get(\"retry-after\");\n if (!value) return undefined;\n if (/^\\d+$/u.test(value)) {\n const seconds = BigInt(value);\n const maxSafeSeconds = BigInt(Math.floor(Number.MAX_SAFE_INTEGER / 1000));\n return seconds <= maxSafeSeconds ? Number(seconds) * 1000 : undefined;\n }\n if (!HTTP_DATE_RE.test(value)) return undefined;\n const date = Date.parse(value);\n if (!Number.isNaN(date)) return Math.max(0, date - Date.now());\n return undefined;\n}\n\nconst MFA_ERROR_CLASSES = {\n \"session-elevation\": SessionElevationRequiredError,\n enrollment: MfaEnrollmentRequiredError,\n \"step-up\": StepUpRequiredError,\n} as const;\n\n/**\n * Maps a `ConnectError` from the Polyester backend onto the typed\n * {@link PolyesterError} tree. The original error is preserved as `cause`.\n */\nexport function connectErrorToPolyesterError(ce: ConnectError): PolyesterError {\n const message = getNormalizedConnectMessage(ce);\n const detail = parseConnectErrorDetail(ce);\n const options: PolyesterErrorOptions = { cause: ce, detail };\n const withFallback = (fallback: string) => message || fallback;\n\n if (detail?.service === \"auth\" && detail.code === \"AUTH_RESOURCE_NOT_FOUND\") {\n return new ResourceNotFoundError(withFallback(\"Resource not found.\"), options);\n }\n\n if (detail?.service === \"auth\" && detail.code === \"AUTH_REVISION_CONFLICT\") {\n return new RevisionConflictError(\n withFallback(\"Resource changed since it was last read.\"),\n options,\n );\n }\n\n if (detail?.service === \"auth\" && detail.code === \"AUTH_SUBACCOUNT_CHALLENGE_INVALID\") {\n return new SubaccountChallengeInvalidError(\n withFallback(\"Subaccount challenge is expired, replaced, or invalid.\"),\n options,\n );\n }\n if (detail?.service === \"auth\" && detail.code === \"AUTH_POLICY_IN_USE\") {\n return new PolicyInUseError(withFallback(\"Policy is still in use.\"), options);\n }\n if (detail?.service === \"auth\" && detail.code === \"AUTH_POLICY_LOCKED\") {\n return new PolicyLockedError(withFallback(\"Policy is locked.\"), options);\n }\n if (detail?.service === \"auth\" && detail.code === \"AUTH_POLICY_SCOPE_MISMATCH\") {\n return new PolicyScopeMismatchError(\n withFallback(\"Policy does not belong to the target account scope.\"),\n options,\n );\n }\n if (detail?.service === \"auth\" && detail.code === \"AUTH_MFA_LAST_FACTOR_REQUIRED\") {\n return new MfaLastFactorRequiredError(\n withFallback(\"At least one active MFA factor must remain enrolled.\"),\n options,\n );\n }\n if (detail?.service === \"auth\" && detail.code === \"AUTH_INTERNAL_ERROR\") {\n return new InternalServerError(withFallback(\"Internal server error.\"), options);\n }\n\n const mfaVerificationReason = getMfaVerificationFailureReason(detail);\n if (mfaVerificationReason) {\n return new MfaVerificationError(\n withFallback(\"MFA verification failed.\"),\n mfaVerificationReason,\n options,\n );\n }\n\n const mfaKind = mfaErrorKind(detail);\n if (mfaKind) {\n return new MFA_ERROR_CLASSES[mfaKind](\n withFallback(\"Multi-factor authentication required.\"),\n options,\n );\n }\n\n if (detail?.service === \"orders\" && detail.code === \"STALE_QUOTE\") {\n return new StaleQuoteError(withFallback(\"The submitted market quote is stale.\"), options);\n }\n\n const rateLimit = detail?.service === \"orders\" ? detail.rateLimit : undefined;\n if (\n rateLimit ||\n ((detail?.service === \"orders\" ||\n detail?.service === \"withdraw\" ||\n detail?.service === \"internal_transfer\" ||\n detail?.service === \"claims\") &&\n detail.code === \"RATE_LIMIT_EXCEEDED\")\n ) {\n return new RateLimitError(withFallback(\"Rate limit exceeded.\"), {\n ...options,\n rateLimit,\n retryAfterMs: safeRetryAfterMs(rateLimit) ?? parseRetryAfterMs(ce),\n });\n }\n\n if (hasTransientServiceError(detail)) {\n return new ServiceUnavailableError(withFallback(\"Service unavailable.\"), options);\n }\n\n switch (ce.code) {\n case Code.InvalidArgument:\n case Code.OutOfRange:\n return new ValidationError(withFallback(\"Invalid request.\"), options);\n case Code.NotFound:\n return new ResourceNotFoundError(withFallback(\"Resource not found.\"), options);\n case Code.AlreadyExists:\n return new AlreadyExistsError(withFallback(\"Resource already exists.\"), options);\n case Code.PermissionDenied:\n return new PermissionError(withFallback(\"Permission denied.\"), options);\n case Code.Unauthenticated:\n return new AuthenticationError(withFallback(\"Authentication required.\"), options);\n case Code.FailedPrecondition:\n return new PreconditionFailedError(withFallback(\"Precondition failed.\"), options);\n case Code.ResourceExhausted:\n return new RateLimitError(withFallback(\"Rate limit exceeded.\"), {\n ...options,\n retryAfterMs: parseRetryAfterMs(ce),\n });\n case Code.DeadlineExceeded:\n return new TimeoutError(withFallback(\"Request timed out.\"), options);\n case Code.Unavailable:\n return new ServiceUnavailableError(withFallback(\"Service unavailable.\"), options);\n case Code.Aborted:\n return new TransientError(withFallback(\"Operation aborted by the backend.\"), options);\n default:\n // Gateways sometimes surface outages as Unknown with this stock phrase.\n if (/service temporarily unavailable/i.test(message)) {\n return new ServiceUnavailableError(withFallback(\"Service unavailable.\"), options);\n }\n return new InternalServerError(withFallback(\"Internal server error.\"), options);\n }\n}\n\nfunction getMfaVerificationFailureReason(\n detail: PolyesterErrorDetail | undefined,\n): MfaVerificationFailureReason | null {\n if (detail?.service === \"auth\" && detail.code === \"AUTH_MFA_CHALLENGE_INVALID\") {\n return \"challenge-invalid\";\n }\n if (detail?.service === \"auth\" && detail.code === \"AUTH_MFA_CHALLENGE_LOCKED\") {\n return \"challenge-locked\";\n }\n if (detail?.service === \"auth\" && detail.code === \"AUTH_MFA_OTP_INVALID\") return \"otp-invalid\";\n if (detail?.service === \"auth\" && detail.code === \"AUTH_MFA_RECOVERY_INVALID\") {\n return \"recovery-code-invalid\";\n }\n if (\n (detail?.service === \"auth\" && detail.code === \"AUTH_MFA_PASSKEY_CREDENTIAL_INVALID\") ||\n (detail?.service === \"auth\" && detail.code === \"AUTH_MFA_PASSKEY_VERIFY_FAILED\")\n ) {\n return \"passkey-invalid\";\n }\n\n return null;\n}\n\nfunction findPolyesterErrorInCauseChain(err: unknown): PolyesterError | null {\n let current: unknown = err;\n for (let depth = 0; depth < 5 && current instanceof Error; depth++) {\n current = current.cause;\n if (current instanceof PolyesterError) return current;\n }\n return null;\n}\n\n/**\n * Converts any RPC-layer failure into its typed SDK error. Abort errors and\n * caller-cancelled requests pass through unchanged, as do errors that are\n * already typed (e.g. a `NetworkError` from the SDK fetch wrapper).\n */\nexport function toPolyesterError(err: unknown): unknown {\n if (err instanceof PolyesterError) return err;\n if (isAbortError(err)) return err;\n if (err instanceof ConnectError) {\n if (err.code === Code.Canceled) return err;\n const wrapped = findPolyesterErrorInCauseChain(err);\n if (wrapped) return wrapped;\n return connectErrorToPolyesterError(err);\n }\n return err;\n}\n\nfunction callerAbortError(signal: AbortSignal): DOMException {\n const reason: unknown = signal.reason;\n return reason instanceof DOMException && reason.name === \"AbortError\"\n ? reason\n : new DOMException(\"Request canceled.\", \"AbortError\");\n}\n\nfunction toTransportError(err: unknown, signal?: AbortSignal): unknown {\n if (signal?.aborted && err instanceof ConnectError && err.code === Code.Canceled) {\n return callerAbortError(signal);\n }\n return toPolyesterError(err);\n}\n\nasync function* mapStreamErrors<T>(\n source: AsyncIterable<T>,\n signal?: AbortSignal,\n): AsyncIterable<T> {\n try {\n yield* source;\n } catch (err) {\n throw toTransportError(err, signal);\n }\n}\n\n/**\n * Interceptor that converts every RPC failure (unary and streaming) into the\n * typed {@link PolyesterError} hierarchy. Installed outermost by\n * `createTransports`, so callers of SDK services always see typed errors.\n */\nexport function createErrorMappingInterceptor(): Interceptor {\n return (next) => async (req) => {\n try {\n const res = await next(req);\n if (res.stream) {\n return { ...res, message: mapStreamErrors(res.message) };\n }\n return res;\n } catch (err) {\n throw toPolyesterError(err);\n }\n };\n}\n\n/**\n * Wraps a Connect transport so errors are translated after Connect's call\n * runner has applied its own error normalization.\n */\nexport function createErrorMappingTransport(transport: Transport): Transport {\n return {\n async unary(method, signal, timeoutMs, header, input, contextValues) {\n if (signal?.aborted) throw callerAbortError(signal);\n try {\n return await transport.unary(\n method,\n signal,\n timeoutMs,\n header,\n input,\n contextValues,\n );\n } catch (error) {\n throw toTransportError(error, signal);\n }\n },\n async stream(method, signal, timeoutMs, header, input, contextValues) {\n if (signal?.aborted) throw callerAbortError(signal);\n try {\n const response = await transport.stream(\n method,\n signal,\n timeoutMs,\n header,\n input,\n contextValues,\n );\n return { ...response, message: mapStreamErrors(response.message, signal) };\n } catch (error) {\n throw toTransportError(error, signal);\n }\n },\n };\n}\n"],"mappings":";;;;AAiCA,SAAS,yBAAyB,QAAmD;CACjF,IAAI,QAAQ,YAAY,YACpB,OAAO;EACH;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACJ,CAAC,CAAC,SAAS,OAAO,IAAI;CAE1B,IAAI,QAAQ,YAAY,qBACpB,OAAO;EACH;EACA;EACA;EACA;EACA;CACJ,CAAC,CAAC,SAAS,OAAO,IAAI;CAE1B,IAAI,QAAQ,YAAY,UACpB,OAAO,CAAC,uBAAuB,+BAA+B,CAAC,CAAC,SAAS,OAAO,IAAI;CAExF,OAAO;AACX;AAEA,SAAS,iBAAiB,WAA4D;CAClF,IAAI,WAAW,iBAAiB,KAAA,GAAW,OAAO,KAAA;CAClD,MAAM,QAAQ,OAAO,UAAU,YAAY;CAC3C,OAAO,SAAS,OAAO,OAAO,gBAAgB,IAAI,OAAO,KAAK,IAAI,KAAA;AACtE;AAEA,MAAM,eAAe;AACrB,MAAM,oBAAoB;AAC1B,MAAM,aAAa;AACnB,MAAM,eAAe,IAAI,OACrB,OAAO,aAAa,WAAW,WAAW,mCAAmC,kBAAkB,WAAW,WAAW,mCAAmC,aAAa,GAAG,WAAW,+CACnL,GACJ;;;;;;AAOA,SAAgB,4BAA4B,KAAsB;CAE9D,MAAM,MADK,aAAa,KAAK,GAChB,CAAC,CAAC,WAAW;CAC1B,OAAO,sBAAsB,GAAG;AACpC;AAaA,SAAS,aAAa,QAA+D;CACjF,IAAI,QAAQ,YAAY,UAAU,OAAO,SAAS,+BAC9C,OAAO;CAEX,IAAI,QAAQ,YAAY,UAAU,OAAO,SAAS,yBAAyB,OAAO;CAClF,IAAI,QAAQ,YAAY,UAAU,OAAO,SAAS,yBAAyB,OAAO;CAClF,OA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AQ,QAAQ,WAAW,QAAQ,OAAO,eAAe;GAClE,IAAI,QAAQ,SAAS,MAAM,iBAAiB,MAAM;GAClD,IAAI;IACA,MAAM,WAAW,MAAM,UAAU,OAC7B,QACA,QACA,WACA,QACA,OACA,aACJ;IACA,OAAO;KAAE,GAAG;KAAU,SAAS,gBAAgB,SAAS,SAAS,MAAM;IAAE;GAC7E,SAAS,OAAO;IACZ,MAAM,iBAAiB,OAAO,MAAM;GACxC;EACJ;CACJ;AACJ"}
|
|
1
|
+
{"version":3,"file":"connect-error-mapping.js","names":[],"sources":["../../src/shared/connect-error-mapping.ts"],"sourcesContent":["import { Code, ConnectError, type Interceptor, type Transport } from \"@connectrpc/connect\";\nimport { parseConnectErrorDetail, type PolyesterErrorDetail } from \"./error-detail.js\";\nimport {\n AlreadyExistsError,\n AuthenticationError,\n errorFromHttpStatus,\n InternalServerError,\n NotImplementedError,\n isAbortError,\n MfaEnrollmentRequiredError,\n MfaLastFactorRequiredError,\n MfaVerificationError,\n type MfaVerificationFailureReason,\n normalizeErrorMessage,\n PermissionError,\n PolicyInUseError,\n PolicyLockedError,\n PolicyScopeMismatchError,\n PolyesterError,\n type PolyesterErrorOptions,\n PreconditionFailedError,\n RateLimitError,\n ResourceNotFoundError,\n RevisionConflictError,\n ServiceUnavailableError,\n SessionElevationRequiredError,\n StaleQuoteError,\n SubaccountChallengeInvalidError,\n StepUpRequiredError,\n TimeoutError,\n TransientError,\n ValidationError,\n} from \"./errors.js\";\nimport type { RateLimitDetail } from \"./rate-limit.schemas.js\";\n\nfunction hasTransientServiceError(detail: PolyesterErrorDetail | undefined): boolean {\n if (detail?.service === \"withdraw\") {\n return [\n \"SERVICE_UNAVAILABLE\",\n \"SOURCE_SMART_ACCOUNT_UNAVAILABLE\",\n \"CAPITAL_VIEW_UNAVAILABLE\",\n \"CHAIN_METADATA_UNAVAILABLE\",\n \"FEE_UNAVAILABLE\",\n \"SUPPLY_UNAVAILABLE\",\n \"STEP_UP_UNAVAILABLE\",\n \"DESTINATION_VALIDATION_UNAVAILABLE\",\n \"ACCOUNT_SHARD_UNAVAILABLE\",\n ].includes(detail.code);\n }\n if (detail?.service === \"internal_transfer\") {\n return [\n \"SERVICE_UNAVAILABLE\",\n \"SMART_ACCOUNT_UNAVAILABLE\",\n \"STEP_UP_UNAVAILABLE\",\n \"CAPITAL_VIEW_UNAVAILABLE\",\n \"ACCOUNT_SHARD_UNAVAILABLE\",\n ].includes(detail.code);\n }\n if (detail?.service === \"claims\") {\n return [\"SERVICE_UNAVAILABLE\", \"CLAIM_TEMPORARILY_UNAVAILABLE\"].includes(detail.code);\n }\n return false;\n}\n\nfunction safeRetryAfterMs(rateLimit: RateLimitDetail | undefined): number | undefined {\n if (rateLimit?.retryAfterMs === undefined) return undefined;\n const value = BigInt(rateLimit.retryAfterMs);\n return value <= BigInt(Number.MAX_SAFE_INTEGER) ? Number(value) : undefined;\n}\n\nconst HTTP_WEEKDAY = \"(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun)\";\nconst HTTP_WEEKDAY_LONG = \"(?:Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday)\";\nconst HTTP_MONTH = \"(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\";\nconst HTTP_DATE_RE = new RegExp(\n `^(?:${HTTP_WEEKDAY}, \\\\d{2} ${HTTP_MONTH} \\\\d{4} \\\\d{2}:\\\\d{2}:\\\\d{2} GMT|${HTTP_WEEKDAY_LONG}, \\\\d{2}-${HTTP_MONTH}-\\\\d{2} \\\\d{2}:\\\\d{2}:\\\\d{2} GMT|${HTTP_WEEKDAY} ${HTTP_MONTH} {1,2}\\\\d{1,2} \\\\d{2}:\\\\d{2}:\\\\d{2} \\\\d{4})$`,\n \"u\",\n);\n\n/**\n * Returns the error message without the leading \"[code] \" prefix that\n * `ConnectError` prepends, e.g. \"[invalid_argument] Insufficient funds.\"\n * becomes \"Insufficient funds.\".\n */\nexport function getNormalizedConnectMessage(err: unknown): string {\n const ce = ConnectError.from(err);\n const raw = ce.message ?? \"\";\n return normalizeErrorMessage(raw);\n}\n\nexport type MfaErrorKind = \"session-elevation\" | \"enrollment\" | \"step-up\";\n\n/**\n * Classifies an error as one of the MFA flows the backend can demand.\n * Classification is based only on stable structured auth error details.\n */\nexport function detectMfaErrorKind(err: unknown): MfaErrorKind | null {\n const mapped = toPolyesterError(err);\n return mfaErrorKind(mapped instanceof PolyesterError ? mapped.detail : undefined);\n}\n\nfunction mfaErrorKind(detail: PolyesterErrorDetail | undefined): MfaErrorKind | null {\n if (detail?.service === \"auth\" && detail.code === \"AUTH_MFA_ELEVATION_REQUIRED\") {\n return \"session-elevation\";\n }\n if (detail?.service === \"auth\" && detail.code === \"AUTH_STEP_UP_REQUIRED\") return \"step-up\";\n if (detail?.service === \"auth\" && detail.code === \"AUTH_MFA_NOT_ENROLLED\") return \"enrollment\";\n return null;\n}\n\nfunction parseRetryAfterMs(ce: ConnectError): number | undefined {\n const value = ce.metadata.get(\"retry-after\");\n if (!value) return undefined;\n if (/^\\d+$/u.test(value)) {\n const seconds = BigInt(value);\n const maxSafeSeconds = BigInt(Math.floor(Number.MAX_SAFE_INTEGER / 1000));\n return seconds <= maxSafeSeconds ? Number(seconds) * 1000 : undefined;\n }\n if (!HTTP_DATE_RE.test(value)) return undefined;\n const date = Date.parse(value);\n if (!Number.isNaN(date)) return Math.max(0, date - Date.now());\n return undefined;\n}\n\nconst MFA_ERROR_CLASSES = {\n \"session-elevation\": SessionElevationRequiredError,\n enrollment: MfaEnrollmentRequiredError,\n \"step-up\": StepUpRequiredError,\n} as const;\n\n/**\n * Maps a `ConnectError` from the Polyester backend onto the typed\n * {@link PolyesterError} tree. The original error is preserved as `cause`.\n */\nexport function connectErrorToPolyesterError(ce: ConnectError): PolyesterError {\n const message = getNormalizedConnectMessage(ce);\n const detail = parseConnectErrorDetail(ce);\n const options: PolyesterErrorOptions = { cause: ce, detail };\n const withFallback = (fallback: string) => message || fallback;\n\n // Connect reports non-Connect HTTP error bodies as \"HTTP <status>\" with a lossy\n // code (e.g. 501 → Unknown), so map the real status. Bare 404 keeps Connect's\n // Unimplemented: it means the route is missing, not the resource.\n const httpStatus = /^HTTP (\\d{3})$/u.exec(ce.rawMessage)?.[1];\n if (!detail && httpStatus && httpStatus !== \"404\") {\n return errorFromHttpStatus(Number(httpStatus), message, {\n ...options,\n retryAfterMs: parseRetryAfterMs(ce),\n });\n }\n\n if (detail?.service === \"auth\" && detail.code === \"AUTH_RESOURCE_NOT_FOUND\") {\n return new ResourceNotFoundError(withFallback(\"Resource not found.\"), options);\n }\n\n if (detail?.service === \"auth\" && detail.code === \"AUTH_REVISION_CONFLICT\") {\n return new RevisionConflictError(\n withFallback(\"Resource changed since it was last read.\"),\n options,\n );\n }\n\n if (detail?.service === \"auth\" && detail.code === \"AUTH_SUBACCOUNT_CHALLENGE_INVALID\") {\n return new SubaccountChallengeInvalidError(\n withFallback(\"Subaccount challenge is expired, replaced, or invalid.\"),\n options,\n );\n }\n if (detail?.service === \"auth\" && detail.code === \"AUTH_POLICY_IN_USE\") {\n return new PolicyInUseError(withFallback(\"Policy is still in use.\"), options);\n }\n if (detail?.service === \"auth\" && detail.code === \"AUTH_POLICY_LOCKED\") {\n return new PolicyLockedError(withFallback(\"Policy is locked.\"), options);\n }\n if (detail?.service === \"auth\" && detail.code === \"AUTH_POLICY_SCOPE_MISMATCH\") {\n return new PolicyScopeMismatchError(\n withFallback(\"Policy does not belong to the target account scope.\"),\n options,\n );\n }\n if (detail?.service === \"auth\" && detail.code === \"AUTH_MFA_LAST_FACTOR_REQUIRED\") {\n return new MfaLastFactorRequiredError(\n withFallback(\"At least one active MFA factor must remain enrolled.\"),\n options,\n );\n }\n if (detail?.service === \"auth\" && detail.code === \"AUTH_INTERNAL_ERROR\") {\n return new InternalServerError(withFallback(\"Internal server error.\"), options);\n }\n\n const mfaVerificationReason = getMfaVerificationFailureReason(detail);\n if (mfaVerificationReason) {\n return new MfaVerificationError(\n withFallback(\"MFA verification failed.\"),\n mfaVerificationReason,\n options,\n );\n }\n\n const mfaKind = mfaErrorKind(detail);\n if (mfaKind) {\n return new MFA_ERROR_CLASSES[mfaKind](\n withFallback(\"Multi-factor authentication required.\"),\n options,\n );\n }\n\n if (detail?.service === \"orders\" && detail.code === \"STALE_QUOTE\") {\n return new StaleQuoteError(withFallback(\"The submitted market quote is stale.\"), options);\n }\n\n const rateLimit = detail?.service === \"orders\" ? detail.rateLimit : undefined;\n if (\n rateLimit ||\n ((detail?.service === \"orders\" ||\n detail?.service === \"withdraw\" ||\n detail?.service === \"internal_transfer\" ||\n detail?.service === \"claims\") &&\n detail.code === \"RATE_LIMIT_EXCEEDED\")\n ) {\n return new RateLimitError(withFallback(\"Rate limit exceeded.\"), {\n ...options,\n rateLimit,\n retryAfterMs: safeRetryAfterMs(rateLimit) ?? parseRetryAfterMs(ce),\n });\n }\n\n if (hasTransientServiceError(detail)) {\n return new ServiceUnavailableError(withFallback(\"Service unavailable.\"), options);\n }\n\n switch (ce.code) {\n case Code.InvalidArgument:\n case Code.OutOfRange:\n return new ValidationError(withFallback(\"Invalid request.\"), options);\n case Code.NotFound:\n return new ResourceNotFoundError(withFallback(\"Resource not found.\"), options);\n case Code.AlreadyExists:\n return new AlreadyExistsError(withFallback(\"Resource already exists.\"), options);\n case Code.PermissionDenied:\n return new PermissionError(withFallback(\"Permission denied.\"), options);\n case Code.Unauthenticated:\n return new AuthenticationError(withFallback(\"Authentication required.\"), options);\n case Code.FailedPrecondition:\n return new PreconditionFailedError(withFallback(\"Precondition failed.\"), options);\n case Code.ResourceExhausted:\n return new RateLimitError(withFallback(\"Rate limit exceeded.\"), {\n ...options,\n retryAfterMs: parseRetryAfterMs(ce),\n });\n case Code.DeadlineExceeded:\n return new TimeoutError(withFallback(\"Request timed out.\"), options);\n case Code.Unavailable:\n return new ServiceUnavailableError(withFallback(\"Service unavailable.\"), options);\n case Code.Unimplemented:\n return new NotImplementedError(withFallback(\"Operation not implemented.\"), options);\n case Code.Aborted:\n return new TransientError(withFallback(\"Operation aborted by the backend.\"), options);\n default:\n // Gateways sometimes surface outages as Unknown with this stock phrase.\n if (/service temporarily unavailable/i.test(message)) {\n return new ServiceUnavailableError(withFallback(\"Service unavailable.\"), options);\n }\n return new InternalServerError(withFallback(\"Internal server error.\"), options);\n }\n}\n\nfunction getMfaVerificationFailureReason(\n detail: PolyesterErrorDetail | undefined,\n): MfaVerificationFailureReason | null {\n if (detail?.service === \"auth\" && detail.code === \"AUTH_MFA_CHALLENGE_INVALID\") {\n return \"challenge-invalid\";\n }\n if (detail?.service === \"auth\" && detail.code === \"AUTH_MFA_CHALLENGE_LOCKED\") {\n return \"challenge-locked\";\n }\n if (detail?.service === \"auth\" && detail.code === \"AUTH_MFA_OTP_INVALID\") return \"otp-invalid\";\n if (detail?.service === \"auth\" && detail.code === \"AUTH_MFA_RECOVERY_INVALID\") {\n return \"recovery-code-invalid\";\n }\n if (\n (detail?.service === \"auth\" && detail.code === \"AUTH_MFA_PASSKEY_CREDENTIAL_INVALID\") ||\n (detail?.service === \"auth\" && detail.code === \"AUTH_MFA_PASSKEY_VERIFY_FAILED\")\n ) {\n return \"passkey-invalid\";\n }\n\n return null;\n}\n\nfunction findPolyesterErrorInCauseChain(err: unknown): PolyesterError | null {\n let current: unknown = err;\n for (let depth = 0; depth < 5 && current instanceof Error; depth++) {\n current = current.cause;\n if (current instanceof PolyesterError) return current;\n }\n return null;\n}\n\n/**\n * Converts any RPC-layer failure into its typed SDK error. Abort errors and\n * caller-cancelled requests pass through unchanged, as do errors that are\n * already typed (e.g. a `NetworkError` from the SDK fetch wrapper).\n */\nexport function toPolyesterError(err: unknown): unknown {\n if (err instanceof PolyesterError) return err;\n if (isAbortError(err)) return err;\n if (err instanceof ConnectError) {\n if (err.code === Code.Canceled) return err;\n const wrapped = findPolyesterErrorInCauseChain(err);\n if (wrapped) return wrapped;\n return connectErrorToPolyesterError(err);\n }\n return err;\n}\n\nfunction callerAbortError(signal: AbortSignal): DOMException {\n const reason: unknown = signal.reason;\n return reason instanceof DOMException && reason.name === \"AbortError\"\n ? reason\n : new DOMException(\"Request canceled.\", \"AbortError\");\n}\n\nfunction toTransportError(err: unknown, signal?: AbortSignal): unknown {\n if (signal?.aborted && err instanceof ConnectError && err.code === Code.Canceled) {\n return callerAbortError(signal);\n }\n return toPolyesterError(err);\n}\n\nasync function* mapStreamErrors<T>(\n source: AsyncIterable<T>,\n signal?: AbortSignal,\n): AsyncIterable<T> {\n try {\n yield* source;\n } catch (err) {\n throw toTransportError(err, signal);\n }\n}\n\n/**\n * Interceptor that converts every RPC failure (unary and streaming) into the\n * typed {@link PolyesterError} hierarchy. Installed outermost by\n * `createTransports`, so callers of SDK services always see typed errors.\n */\nexport function createErrorMappingInterceptor(): Interceptor {\n return (next) => async (req) => {\n try {\n const res = await next(req);\n if (res.stream) {\n return { ...res, message: mapStreamErrors(res.message) };\n }\n return res;\n } catch (err) {\n throw toPolyesterError(err);\n }\n };\n}\n\n/**\n * Wraps a Connect transport so errors are translated after Connect's call\n * runner has applied its own error normalization.\n */\nexport function createErrorMappingTransport(transport: Transport): Transport {\n return {\n async unary(method, signal, timeoutMs, header, input, contextValues) {\n if (signal?.aborted) throw callerAbortError(signal);\n try {\n return await transport.unary(\n method,\n signal,\n timeoutMs,\n header,\n input,\n contextValues,\n );\n } catch (error) {\n throw toTransportError(error, signal);\n }\n },\n async stream(method, signal, timeoutMs, header, input, contextValues) {\n if (signal?.aborted) throw callerAbortError(signal);\n try {\n const response = await transport.stream(\n method,\n signal,\n timeoutMs,\n header,\n input,\n contextValues,\n );\n return { ...response, message: mapStreamErrors(response.message, signal) };\n } catch (error) {\n throw toTransportError(error, signal);\n }\n },\n };\n}\n"],"mappings":";;;;AAmCA,SAAS,yBAAyB,QAAmD;CACjF,IAAI,QAAQ,YAAY,YACpB,OAAO;EACH;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACJ,CAAC,CAAC,SAAS,OAAO,IAAI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AAM,iBAAiB,MAAM;GAClD,IAAI;IACA,MAAM,WAAW,MAAM,UAAU,OAC7B,QACA,QACA,WACA,QACA,OACA,aACJ;IACA,OAAO;KAAE,GAAG;KAAU,SAAS,gBAAgB,SAAS,SAAS,MAAM;IAAE;GAC7E,SAAS,OAAO;IACZ,MAAM,iBAAiB,OAAO,MAAM;GACxC;EACJ;CACJ;AACJ"}
|
package/dist/shared/errors.d.ts
CHANGED
|
@@ -20,6 +20,7 @@ import { RateLimitDetail } from "./rate-limit.schemas.js";
|
|
|
20
20
|
* │ │ ├── StaleQuoteError STALE_QUOTE
|
|
21
21
|
* │ │ └── PolicyScopeMismatchError POLICY_SCOPE_MISMATCH
|
|
22
22
|
* │ ├── ResourceNotFoundError RESOURCE_NOT_FOUND false
|
|
23
|
+
* │ ├── NotImplementedError NOT_IMPLEMENTED false
|
|
23
24
|
* │ ├── AlreadyExistsError ALREADY_EXISTS false
|
|
24
25
|
* │ ├── PermissionError PERMISSION_DENIED false
|
|
25
26
|
* │ ├── AuthenticationError UNAUTHENTICATED false
|
|
@@ -56,7 +57,7 @@ import { RateLimitDetail } from "./rate-limit.schemas.js";
|
|
|
56
57
|
* ```
|
|
57
58
|
*/
|
|
58
59
|
/** Stable machine-readable codes carried by built-in SDK errors. */
|
|
59
|
-
type PolyesterErrorCode = "TRANSIENT_FAILURE" | "NETWORK_ERROR" | "TIMEOUT" | "RATE_LIMITED" | "SERVICE_UNAVAILABLE" | "REQUEST_FAILED" | "VALIDATION_FAILED" | "STALE_QUOTE" | "RESOURCE_NOT_FOUND" | "ALREADY_EXISTS" | "PERMISSION_DENIED" | "UNAUTHENTICATED" | "PRECONDITION_FAILED" | "REVISION_CONFLICT" | "POLICY_IN_USE" | "POLICY_LOCKED" | "POLICY_SCOPE_MISMATCH" | "INVALID_CONFIGURATION" | "MFA_REQUIRED" | "MFA_ENROLLMENT_REQUIRED" | "STEP_UP_REQUIRED" | "SESSION_ELEVATION_REQUIRED" | "MFA_LAST_FACTOR_REQUIRED" | "MFA_VERIFICATION_FAILED" | "INTERNAL_SERVER_ERROR" | "CATALOG_LOOKUP_MISS" | "CATALOG_NOT_READY" | "CATALOG_CONVERSION_INVALID" | "CATALOG_VALIDATION_FAILED";
|
|
60
|
+
type PolyesterErrorCode = "TRANSIENT_FAILURE" | "NETWORK_ERROR" | "TIMEOUT" | "RATE_LIMITED" | "SERVICE_UNAVAILABLE" | "REQUEST_FAILED" | "VALIDATION_FAILED" | "STALE_QUOTE" | "RESOURCE_NOT_FOUND" | "NOT_IMPLEMENTED" | "ALREADY_EXISTS" | "PERMISSION_DENIED" | "UNAUTHENTICATED" | "PRECONDITION_FAILED" | "REVISION_CONFLICT" | "POLICY_IN_USE" | "POLICY_LOCKED" | "POLICY_SCOPE_MISMATCH" | "INVALID_CONFIGURATION" | "MFA_REQUIRED" | "MFA_ENROLLMENT_REQUIRED" | "STEP_UP_REQUIRED" | "SESSION_ELEVATION_REQUIRED" | "MFA_LAST_FACTOR_REQUIRED" | "MFA_VERIFICATION_FAILED" | "INTERNAL_SERVER_ERROR" | "CATALOG_LOOKUP_MISS" | "CATALOG_NOT_READY" | "CATALOG_CONVERSION_INVALID" | "CATALOG_VALIDATION_FAILED";
|
|
60
61
|
interface PolyesterErrorOptions {
|
|
61
62
|
/** Underlying error, typically the original `ConnectError` for RPC failures. */
|
|
62
63
|
cause?: unknown;
|
|
@@ -144,6 +145,11 @@ declare class ResourceNotFoundError extends RequestError {
|
|
|
144
145
|
readonly code: string;
|
|
145
146
|
constructor(message: string, options?: PolyesterErrorOptions);
|
|
146
147
|
}
|
|
148
|
+
/** The backend does not implement the requested operation (HTTP 501 / Connect `unimplemented`). */
|
|
149
|
+
declare class NotImplementedError extends RequestError {
|
|
150
|
+
readonly code: string;
|
|
151
|
+
constructor(message: string, options?: PolyesterErrorOptions);
|
|
152
|
+
}
|
|
147
153
|
/** The resource already exists (e.g. a duplicate `clientOrderId`). */
|
|
148
154
|
declare class AlreadyExistsError extends RequestError {
|
|
149
155
|
readonly code: string;
|
|
@@ -256,7 +262,7 @@ declare class InternalServerError extends PolyesterError {
|
|
|
256
262
|
*/
|
|
257
263
|
declare function isAbortError(err: unknown): boolean;
|
|
258
264
|
/** Maps a plain HTTP status code onto the SDK error tree. */
|
|
259
|
-
declare function errorFromHttpStatus(status: number, message: string, options?:
|
|
265
|
+
declare function errorFromHttpStatus(status: number, message: string, options?: RateLimitErrorOptions): PolyesterError;
|
|
260
266
|
//#endregion
|
|
261
|
-
export { AlreadyExistsError, AuthenticationError, ConfigurationError, InternalServerError, MfaEnrollmentRequiredError, MfaLastFactorRequiredError, MfaRequiredError, MfaVerificationError, MfaVerificationFailureReason, NetworkError, PermissionError, PolicyInUseError, PolicyLockedError, PolicyScopeMismatchError, PolyesterError, PolyesterErrorCode, type PolyesterErrorDetail, PolyesterErrorOptions, PreconditionFailedError, RateLimitError, RateLimitErrorOptions, RequestError, ResourceNotFoundError, RevisionConflictError, ServiceUnavailableError, SessionElevationRequiredError, StaleQuoteError, StepUpRequiredError, SubaccountChallengeInvalidError, TimeoutError, TransientError, ValidationError, errorFromHttpStatus, isAbortError, normalizeErrorMessage };
|
|
267
|
+
export { AlreadyExistsError, AuthenticationError, ConfigurationError, InternalServerError, MfaEnrollmentRequiredError, MfaLastFactorRequiredError, MfaRequiredError, MfaVerificationError, MfaVerificationFailureReason, NetworkError, NotImplementedError, PermissionError, PolicyInUseError, PolicyLockedError, PolicyScopeMismatchError, PolyesterError, PolyesterErrorCode, type PolyesterErrorDetail, PolyesterErrorOptions, PreconditionFailedError, RateLimitError, RateLimitErrorOptions, RequestError, ResourceNotFoundError, RevisionConflictError, ServiceUnavailableError, SessionElevationRequiredError, StaleQuoteError, StepUpRequiredError, SubaccountChallengeInvalidError, TimeoutError, TransientError, ValidationError, errorFromHttpStatus, isAbortError, normalizeErrorMessage };
|
|
262
268
|
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","names":[],"sources":["../../src/shared/errors.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"errors.d.ts","names":[],"sources":["../../src/shared/errors.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA6DY;UAgCK;;EAEb;;EAEA,SAAS;;iBAKG,sBAAsB;;;;;;;;uBAWhB,uBAAuB;;oBAEvB;;oBAEA;WACT,QAAQ;EAEL,YAAA,iBAAiB,UAAU;;;;;;;;cAe9B,uBAAuB;WACvB;WACA;EAEG,YAAA,iBAAiB,UAAU;;;cAO9B,qBAAqB;WACZ;EAEN,YAAA,iBAAiB,UAAU;;;cAO9B,qBAAqB;WACZ;EAEN,YAAA,iBAAiB,UAAU;;UAM1B,8BAA8B;;EAE3C;;EAEA,YAAY;;;cAIH,uBAAuB;WACd;;WAET;;WAEA,YAAY;EAET,YAAA,iBAAiB,UAAU;;;cAS9B,gCAAgC;WACvB;EAEN,YAAA,iBAAiB,UAAU;;;;;;cAU9B,qBAAqB;WACrB;WACA;EAEG,YAAA,iBAAiB,UAAU;;;cAO9B,wBAAwB;WACf;EAEN,YAAA,iBAAiB,UAAU;;;cAO9B,wBAAwB;WACf;EAEN,YAAA,iBAAiB,UAAU;;;cAO9B,8BAA8B;WACrB;EAEN,YAAA,iBAAiB,UAAU;;;cAO9B,4BAA4B;WACnB;EAEN,YAAA,iBAAiB,UAAU;;;cAO9B,2BAA2B;WAClB;EAEN,YAAA,iBAAiB,UAAU;;;cAO9B,wBAAwB;WACf;EAEN,YAAA,iBAAiB,UAAU;;;cAO9B,4BAA4B;WACnB;EAEN,YAAA,iBAAiB,UAAU;;;cAO9B,gCAAgC;WACvB;EAEN,YAAA,iBAAiB,UAAU;;;;;;cAU9B,8BAA8B;WACrB;EAEN,YAAA,iBAAiB,UAAU;;;;;;cAU9B,wCAAwC;WAC/B;EAEN,YAAA,iBAAiB,UAAU;;;cAO9B,yBAAyB;WAChB;EAEN,YAAA,iBAAiB,UAAU;;;cAO9B,0BAA0B;WACjB;EAEN,YAAA,iBAAiB,UAAU;;;cAO9B,iCAAiC;WACxB;EAEN,YAAA,iBAAiB,UAAU;;;cAO9B,2BAA2B;WAClB;EAEN,YAAA,iBAAiB,UAAU;;;;;;cAU9B,yBAAyB;WAChB;EAEN,YAAA,iBAAiB,UAAU;;;cAO9B,mCAAmC;WAC1B;EAEN,YAAA,iBAAiB,UAAU;;;cAO9B,4BAA4B;WACnB;EAEN,YAAA,iBAAiB,UAAU;;;cAO9B,sCAAsC;WAC7B;EAEN,YAAA,iBAAiB,UAAU;;;cAO9B,mCAAmC;WAC1B;EAEN,YAAA,iBAAiB,UAAU;;;KAO/B;;;;;cAWC,6BAA6B;WAKzB,QAAQ;WAJH;EAGd,YAAA,iBACS,QAAQ,8BACjB,UAAU;;;;;;;cAYL,4BAA4B;WAC5B;WACA;EAEG,YAAA,iBAAiB,UAAU;;;;;;;iBAW3B,aAAa;;iBAKb,oBACZ,gBACA,iBACA,UAAU,wBACX"}
|
package/dist/shared/errors.js
CHANGED
|
@@ -106,6 +106,14 @@ var ResourceNotFoundError = class extends RequestError {
|
|
|
106
106
|
this.name = "ResourceNotFoundError";
|
|
107
107
|
}
|
|
108
108
|
};
|
|
109
|
+
/** The backend does not implement the requested operation (HTTP 501 / Connect `unimplemented`). */
|
|
110
|
+
var NotImplementedError = class extends RequestError {
|
|
111
|
+
code = "NOT_IMPLEMENTED";
|
|
112
|
+
constructor(message, options) {
|
|
113
|
+
super(message, options);
|
|
114
|
+
this.name = "NotImplementedError";
|
|
115
|
+
}
|
|
116
|
+
};
|
|
109
117
|
/** The resource already exists (e.g. a duplicate `clientOrderId`). */
|
|
110
118
|
var AlreadyExistsError = class extends RequestError {
|
|
111
119
|
code = "ALREADY_EXISTS";
|
|
@@ -271,18 +279,21 @@ function isAbortError(err) {
|
|
|
271
279
|
}
|
|
272
280
|
/** Maps a plain HTTP status code onto the SDK error tree. */
|
|
273
281
|
function errorFromHttpStatus(status, message, options) {
|
|
282
|
+
if (status === 400 || status === 422) return new ValidationError(message, options);
|
|
274
283
|
if (status === 401) return new AuthenticationError(message, options);
|
|
275
284
|
if (status === 403) return new PermissionError(message, options);
|
|
276
285
|
if (status === 404) return new ResourceNotFoundError(message, options);
|
|
277
286
|
if (status === 408) return new TimeoutError(message, options);
|
|
278
287
|
if (status === 409) return new AlreadyExistsError(message, options);
|
|
288
|
+
if (status === 412) return new PreconditionFailedError(message, options);
|
|
279
289
|
if (status === 429) return new RateLimitError(message, options);
|
|
290
|
+
if (status === 501) return new NotImplementedError(message, options);
|
|
280
291
|
if (status === 502 || status === 503 || status === 504) return new ServiceUnavailableError(message, options);
|
|
281
292
|
if (status >= 500) return new InternalServerError(message, options);
|
|
282
293
|
if (status >= 400) return new RequestError(message, options);
|
|
283
294
|
return new NetworkError(message, options);
|
|
284
295
|
}
|
|
285
296
|
//#endregion
|
|
286
|
-
export { AlreadyExistsError, AuthenticationError, ConfigurationError, InternalServerError, MfaEnrollmentRequiredError, MfaLastFactorRequiredError, MfaRequiredError, MfaVerificationError, NetworkError, PermissionError, PolicyInUseError, PolicyLockedError, PolicyScopeMismatchError, PolyesterError, PreconditionFailedError, RateLimitError, RequestError, ResourceNotFoundError, RevisionConflictError, ServiceUnavailableError, SessionElevationRequiredError, StaleQuoteError, StepUpRequiredError, SubaccountChallengeInvalidError, TimeoutError, TransientError, ValidationError, errorFromHttpStatus, isAbortError, normalizeErrorMessage };
|
|
297
|
+
export { AlreadyExistsError, AuthenticationError, ConfigurationError, InternalServerError, MfaEnrollmentRequiredError, MfaLastFactorRequiredError, MfaRequiredError, MfaVerificationError, NetworkError, NotImplementedError, PermissionError, PolicyInUseError, PolicyLockedError, PolicyScopeMismatchError, PolyesterError, PreconditionFailedError, RateLimitError, RequestError, ResourceNotFoundError, RevisionConflictError, ServiceUnavailableError, SessionElevationRequiredError, StaleQuoteError, StepUpRequiredError, SubaccountChallengeInvalidError, TimeoutError, TransientError, ValidationError, errorFromHttpStatus, isAbortError, normalizeErrorMessage };
|
|
287
298
|
|
|
288
299
|
//# sourceMappingURL=errors.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","names":[],"sources":["../../src/shared/errors.ts"],"sourcesContent":["import type { PolyesterErrorDetail } from \"./error-detail.js\";\nexport type { PolyesterErrorDetail } from \"./error-detail.js\";\nimport type { RateLimitDetail } from \"./rate-limit.schemas.js\";\n\n/**\n * Typed error hierarchy for the Polyester SDK.\n *\n * Every error raised by the SDK extends {@link PolyesterError}, which carries a\n * stable machine-readable `code` and a `retryable` flag. The tree splits on\n * retryability so callers can triage with a single `instanceof` check:\n *\n * ```\n * PolyesterError code retryable\n * ├── TransientError TRANSIENT_FAILURE true\n * │ ├── NetworkError NETWORK_ERROR true\n * │ ├── TimeoutError TIMEOUT true\n * │ ├── RateLimitError RATE_LIMITED true\n * │ └── ServiceUnavailableError SERVICE_UNAVAILABLE true\n * ├── RequestError REQUEST_FAILED false\n * │ ├── ValidationError VALIDATION_FAILED false\n * │ │ ├── StaleQuoteError STALE_QUOTE\n * │ │ └── PolicyScopeMismatchError POLICY_SCOPE_MISMATCH\n * │ ├── ResourceNotFoundError RESOURCE_NOT_FOUND false\n * │ ├── AlreadyExistsError ALREADY_EXISTS false\n * │ ├── PermissionError PERMISSION_DENIED false\n * │ ├── AuthenticationError UNAUTHENTICATED false\n * │ ├── PreconditionFailedError PRECONDITION_FAILED false\n * │ │ ├── RevisionConflictError REVISION_CONFLICT\n * │ │ ├── PolicyInUseError POLICY_IN_USE\n * │ │ ├── PolicyLockedError POLICY_LOCKED\n * │ │ ├── SubaccountChallengeInvalidError SUBACCOUNT_CHALLENGE_INVALID\n * │ │ └── MfaLastFactorRequiredError MFA_LAST_FACTOR_REQUIRED\n * │ ├── ConfigurationError INVALID_CONFIGURATION false\n * │ ├── MfaRequiredError MFA_REQUIRED false\n * │ │ ├── MfaEnrollmentRequiredError MFA_ENROLLMENT_REQUIRED\n * │ │ ├── StepUpRequiredError STEP_UP_REQUIRED\n * │ │ └── SessionElevationRequiredError SESSION_ELEVATION_REQUIRED\n * │ └── MfaVerificationError MFA_VERIFICATION_FAILED false\n * └── InternalServerError INTERNAL_SERVER_ERROR false\n * ```\n *\n * Catalog errors (`CatalogLookupError`, `CatalogConversionError`, …) plug into\n * the same tree under `RequestError`/`ValidationError`.\n *\n * Errors mapped from RPC failures keep the original `ConnectError` as `cause`.\n *\n * @example\n * ```ts\n * try {\n * await client.orders.createSpotOrder(input);\n * } catch (err) {\n * if (err instanceof RateLimitError) await sleep(err.retryAfterMs ?? 1000);\n * else if (err instanceof TransientError) retry();\n * else if (err instanceof StepUpRequiredError) promptForMfa();\n * else throw err;\n * }\n * ```\n */\n\n/** Stable machine-readable codes carried by built-in SDK errors. */\nexport type PolyesterErrorCode =\n | \"TRANSIENT_FAILURE\"\n | \"NETWORK_ERROR\"\n | \"TIMEOUT\"\n | \"RATE_LIMITED\"\n | \"SERVICE_UNAVAILABLE\"\n | \"REQUEST_FAILED\"\n | \"VALIDATION_FAILED\"\n | \"STALE_QUOTE\"\n | \"RESOURCE_NOT_FOUND\"\n | \"ALREADY_EXISTS\"\n | \"PERMISSION_DENIED\"\n | \"UNAUTHENTICATED\"\n | \"PRECONDITION_FAILED\"\n | \"REVISION_CONFLICT\"\n | \"POLICY_IN_USE\"\n | \"POLICY_LOCKED\"\n | \"POLICY_SCOPE_MISMATCH\"\n | \"INVALID_CONFIGURATION\"\n | \"MFA_REQUIRED\"\n | \"MFA_ENROLLMENT_REQUIRED\"\n | \"STEP_UP_REQUIRED\"\n | \"SESSION_ELEVATION_REQUIRED\"\n | \"MFA_LAST_FACTOR_REQUIRED\"\n | \"MFA_VERIFICATION_FAILED\"\n | \"INTERNAL_SERVER_ERROR\"\n | \"CATALOG_LOOKUP_MISS\"\n | \"CATALOG_NOT_READY\"\n | \"CATALOG_CONVERSION_INVALID\"\n | \"CATALOG_VALIDATION_FAILED\";\n\nexport interface PolyesterErrorOptions {\n /** Underlying error, typically the original `ConnectError` for RPC failures. */\n cause?: unknown;\n /** Recognized structured backend rejection, decoded at the RPC boundary. */\n detail?: PolyesterErrorDetail;\n}\n\nconst CONNECT_ERROR_PREFIX_RE = /^(?:\\[[a-z][a-z0-9_-]*]\\s*)+/i;\n\nexport function normalizeErrorMessage(message: string): string {\n return message.replace(CONNECT_ERROR_PREFIX_RE, \"\").trim();\n}\n\n/**\n * Base class for every error raised by the Polyester SDK.\n *\n * Check `retryable` (or `instanceof TransientError`) to decide whether the\n * same call can be safely retried, and switch on `code` for exhaustive,\n * minification-safe handling.\n */\nexport abstract class PolyesterError extends Error {\n /** Stable machine-readable error code, e.g. `\"RATE_LIMITED\"`. */\n abstract readonly code: string;\n /** Whether retrying the same operation may succeed. */\n abstract readonly retryable: boolean;\n readonly detail: PolyesterErrorDetail | undefined;\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(normalizeErrorMessage(message), options);\n this.name = \"PolyesterError\";\n this.detail =\n options?.detail ??\n (options?.cause instanceof PolyesterError ? options.cause.detail : undefined);\n }\n}\n\n/**\n * A transient failure — the request may never have reached the backend or the\n * backend was temporarily unable to serve it. Follow the operation's retry\n * contract: reuse requestId for idempotent mutations. For single-order creation,\n * reconcile by clientOrderId; reusing it returns a conflict rather than replay.\n */\nexport class TransientError extends PolyesterError {\n readonly code: string = \"TRANSIENT_FAILURE\";\n readonly retryable = true;\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"TransientError\";\n }\n}\n\n/** The request could not be sent or the connection failed mid-flight. */\nexport class NetworkError extends TransientError {\n override readonly code: string = \"NETWORK_ERROR\";\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"NetworkError\";\n }\n}\n\n/** The request timed out before the backend produced a response. */\nexport class TimeoutError extends TransientError {\n override readonly code: string = \"TIMEOUT\";\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"TimeoutError\";\n }\n}\n\nexport interface RateLimitErrorOptions extends PolyesterErrorOptions {\n /** Suggested wait before retrying, when the backend provided one. */\n retryAfterMs?: number;\n /** Structured quota state attached to the rejection, when provided. */\n rateLimit?: RateLimitDetail;\n}\n\n/** The backend rejected the request due to rate limiting. */\nexport class RateLimitError extends TransientError {\n override readonly code: string = \"RATE_LIMITED\";\n /** Suggested wait before retrying, in milliseconds, when known. */\n readonly retryAfterMs?: number;\n /** Structured quota state attached to the rejection, when provided. */\n readonly rateLimit?: RateLimitDetail;\n\n constructor(message: string, options?: RateLimitErrorOptions) {\n super(message, options);\n this.name = \"RateLimitError\";\n this.retryAfterMs = options?.retryAfterMs;\n this.rateLimit = options?.rateLimit;\n }\n}\n\n/** The backend is temporarily unavailable (e.g. overloaded or restarting). */\nexport class ServiceUnavailableError extends TransientError {\n override readonly code: string = \"SERVICE_UNAVAILABLE\";\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"ServiceUnavailableError\";\n }\n}\n\n/**\n * The request itself was rejected — retrying the identical call will fail the\n * same way. Fix the input, authentication, or permissions first.\n */\nexport class RequestError extends PolyesterError {\n readonly code: string = \"REQUEST_FAILED\";\n readonly retryable = false;\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"RequestError\";\n }\n}\n\n/** The request input failed validation (client- or server-side). */\nexport class ValidationError extends RequestError {\n override readonly code: string = \"VALIDATION_FAILED\";\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"ValidationError\";\n }\n}\n\n/** The submitted client reference quote exceeded the market's configured drift limit. */\nexport class StaleQuoteError extends ValidationError {\n override readonly code = \"STALE_QUOTE\" as const;\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"StaleQuoteError\";\n }\n}\n\n/** The requested resource does not exist (or is not visible to the caller). */\nexport class ResourceNotFoundError extends RequestError {\n override readonly code: string = \"RESOURCE_NOT_FOUND\";\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"ResourceNotFoundError\";\n }\n}\n\n/** The resource already exists (e.g. a duplicate `clientOrderId`). */\nexport class AlreadyExistsError extends RequestError {\n override readonly code: string = \"ALREADY_EXISTS\";\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"AlreadyExistsError\";\n }\n}\n\n/** The caller is authenticated but not allowed to perform this operation. */\nexport class PermissionError extends RequestError {\n override readonly code: string = \"PERMISSION_DENIED\";\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"PermissionError\";\n }\n}\n\n/** The caller is not authenticated (missing, expired, or invalid credentials). */\nexport class AuthenticationError extends RequestError {\n override readonly code: string = \"UNAUTHENTICATED\";\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"AuthenticationError\";\n }\n}\n\n/** The system is not in a state that allows this operation (e.g. insufficient balance). */\nexport class PreconditionFailedError extends RequestError {\n override readonly code: string = \"PRECONDITION_FAILED\";\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"PreconditionFailedError\";\n }\n}\n\n/**\n * The resource changed after it was read, so the submitted expected revision\n * is stale. Refetch and let the caller reconcile; do not blindly retry.\n */\nexport class RevisionConflictError extends PreconditionFailedError {\n override readonly code: string = \"REVISION_CONFLICT\";\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"RevisionConflictError\";\n }\n}\n\n/**\n * The subaccount authorization is expired, replaced by a newer challenge, replayed,\n * or otherwise invalid. Request a fresh challenge via `subaccounts.createChallenge`.\n */\nexport class SubaccountChallengeInvalidError extends PreconditionFailedError {\n override readonly code: string = \"SUBACCOUNT_CHALLENGE_INVALID\";\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"SubaccountChallengeInvalidError\";\n }\n}\n\n/** The policy cannot be removed while accounts or API keys still use it. */\nexport class PolicyInUseError extends PreconditionFailedError {\n override readonly code: string = \"POLICY_IN_USE\";\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"PolicyInUseError\";\n }\n}\n\n/** The policy is locked against the requested mutation. */\nexport class PolicyLockedError extends PreconditionFailedError {\n override readonly code: string = \"POLICY_LOCKED\";\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"PolicyLockedError\";\n }\n}\n\n/** The policy does not belong to the account scope targeted by the request. */\nexport class PolicyScopeMismatchError extends ValidationError {\n override readonly code: string = \"POLICY_SCOPE_MISMATCH\";\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"PolicyScopeMismatchError\";\n }\n}\n\n/** The SDK was configured incorrectly (bad environment, missing credentials, …). */\nexport class ConfigurationError extends RequestError {\n override readonly code: string = \"INVALID_CONFIGURATION\";\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"ConfigurationError\";\n }\n}\n\n/**\n * The operation requires additional multi-factor authentication. Catch this\n * class to handle all MFA flows, or the subclasses to branch per flow.\n */\nexport class MfaRequiredError extends RequestError {\n override readonly code: string = \"MFA_REQUIRED\";\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"MfaRequiredError\";\n }\n}\n\n/** The user must enroll in MFA before this operation can proceed. */\nexport class MfaEnrollmentRequiredError extends MfaRequiredError {\n override readonly code: string = \"MFA_ENROLLMENT_REQUIRED\";\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"MfaEnrollmentRequiredError\";\n }\n}\n\n/** The operation requires a fresh MFA step-up proof (retry with `X-Auth-Step-Up`). */\nexport class StepUpRequiredError extends MfaRequiredError {\n override readonly code: string = \"STEP_UP_REQUIRED\";\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"StepUpRequiredError\";\n }\n}\n\n/** The operation requires a recent MFA-elevated session, not a one-use step-up proof. */\nexport class SessionElevationRequiredError extends MfaRequiredError {\n override readonly code: string = \"SESSION_ELEVATION_REQUIRED\";\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"SessionElevationRequiredError\";\n }\n}\n\n/** The requested deletion would leave the account without an active MFA factor. */\nexport class MfaLastFactorRequiredError extends PreconditionFailedError {\n override readonly code: string = \"MFA_LAST_FACTOR_REQUIRED\";\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"MfaLastFactorRequiredError\";\n }\n}\n\n/** The reason an MFA challenge could not be completed. */\nexport type MfaVerificationFailureReason =\n | \"challenge-invalid\"\n | \"challenge-locked\"\n | \"otp-invalid\"\n | \"recovery-code-invalid\"\n | \"passkey-invalid\";\n\n/**\n * An expected MFA verification rejection. Callers should select their own\n * user-facing copy from `reason` instead of displaying the backend message.\n */\nexport class MfaVerificationError extends RequestError {\n override readonly code: string = \"MFA_VERIFICATION_FAILED\";\n\n constructor(\n message: string,\n readonly reason: MfaVerificationFailureReason,\n options?: PolyesterErrorOptions,\n ) {\n super(message, options);\n this.name = \"MfaVerificationError\";\n }\n}\n\n/**\n * The backend failed unexpectedly or returned a malformed response. Not\n * automatically retryable — the failure may recur and mutations may have\n * partially applied.\n */\nexport class InternalServerError extends PolyesterError {\n readonly code: string = \"INTERNAL_SERVER_ERROR\";\n readonly retryable = false;\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"InternalServerError\";\n }\n}\n\n/**\n * Checks whether an error represents an aborted request (caller-initiated via\n * `AbortSignal`). Aborts are intentionally NOT part of the {@link PolyesterError}\n * tree and are never retryable.\n */\nexport function isAbortError(err: unknown): boolean {\n return err instanceof DOMException && err.name === \"AbortError\";\n}\n\n/** Maps a plain HTTP status code onto the SDK error tree. */\nexport function errorFromHttpStatus(\n status: number,\n message: string,\n options?: PolyesterErrorOptions,\n): PolyesterError {\n if (status === 401) return new AuthenticationError(message, options);\n if (status === 403) return new PermissionError(message, options);\n if (status === 404) return new ResourceNotFoundError(message, options);\n if (status === 408) return new TimeoutError(message, options);\n if (status === 409) return new AlreadyExistsError(message, options);\n if (status === 429) return new RateLimitError(message, options);\n if (status === 502 || status === 503 || status === 504) {\n return new ServiceUnavailableError(message, options);\n }\n if (status >= 500) return new InternalServerError(message, options);\n if (status >= 400) return new RequestError(message, options);\n return new NetworkError(message, options);\n}\n"],"mappings":";AAkGA,MAAM,0BAA0B;AAEhC,SAAgB,sBAAsB,SAAyB;CAC3D,OAAO,QAAQ,QAAQ,yBAAyB,EAAE,CAAC,CAAC,KAAK;AAC7D;;;;;;;;AASA,IAAsB,iBAAtB,MAAsB,uBAAuB,MAAM;CAK/C;CAEA,YAAY,SAAiB,SAAiC;EAC1D,MAAM,sBAAsB,OAAO,GAAG,OAAO;EAC7C,KAAK,OAAO;EACZ,KAAK,SACD,SAAS,WACR,SAAS,iBAAiB,iBAAiB,QAAQ,MAAM,SAAS,KAAA;CAC3E;AACJ;;;;;;;AAQA,IAAa,iBAAb,cAAoC,eAAe;CAC/C,OAAwB;CACxB,YAAqB;CAErB,YAAY,SAAiB,SAAiC;EAC1D,MAAM,SAAS,OAAO;EACtB,KAAK,OAAO;CAChB;AACJ;;AAGA,IAAa,eAAb,cAAkC,eAAe;CAC7C,OAAiC;CAEjC,YAAY,SAAiB,SAAiC;EAC1D,MAAM,SAAS,OAAO;EACtB,KAAK,OAAO;CAChB;AACJ;;AAGA,IAAa,eAAb,cAAkC,eAAe;CAC7C,OAAiC;CAEjC,YAAY,SAAiB,SAAiC;EAC1D,MAAM,SAAS,OAAO;EACtB,KAAK,OAAO;CAChB;AACJ;;AAUA,IAAa,iBAAb,cAAoC,eAAe;CAC/C,OAAiC;;CAEjC;;CAEA;CAEA,YAAY,SAAiB,SAAiC;EAC1D,MAAM,SAAS,OAAO;EACtB,KAAK,OAAO;EACZ,KAAK,eAAe,SAAS;EAC7B,KAAK,YAAY,SAAS;CAC9B;AACJ;;AAGA,IAAa,0BAAb,cAA6C,eAAe;CACxD,OAAiC;CAEjC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ChB;AACJ;;AAGA,IAAa,6BAAb,cAAgD,wBAAwB;CACpE,OAAiC;CAEjC,YAAY,SAAiB,SAAiC;EAC1D,MAAM,SAAS,OAAO;EACtB,KAAK,OAAO;CAChB;AACJ;;;;;AAcA,IAAa,uBAAb,cAA0C,aAAa;CAKtC;CAJb,OAAiC;CAEjC,YACI,SACA,QACA,SACF;EACE,MAAM,SAAS,OAAO;EAHb,KAAA,SAAA;EAIT,KAAK,OAAO;CAChB;AACJ;;;;;;AAOA,IAAa,sBAAb,cAAyC,eAAe;CACpD,OAAwB;CACxB,YAAqB;CAErB,YAAY,SAAiB,SAAiC;EAC1D,MAAM,SAAS,OAAO;EACtB,KAAK,OAAO;CAChB;AACJ;;;;;;AAOA,SAAgB,aAAa,KAAuB;CAChD,OAAO,eAAe,gBAAgB,IAAI,SAAS;AACvD;;AAGA,SAAgB,oBACZ,QACA,SACA,SACc;CACd,IAAI,WAAW,KAAK,OAAO,IAAI,oBAAoB,SAAS,OAAO;CACnE,IAAI,WAAW,KAAK,OAAO,IAAI,gBAAgB,SAAS,OAAO;CAC/D,IAAI,WAAW,KAAK,OAAO,IAAI,sBAAsB,SAAS,OAAO;CACrE,IAAI,WAAW,KAAK,OAAO,IAAI,aAAa,SAAS,OAAO;CAC5D,IAAI,WAAW,KAAK,OAAO,IAAI,mBAAmB,SAAS,OAAO;CAClE,IAAI,WAAW,KAAK,OAAO,IAAI,eAAe,SAAS,OAAO;CAC9D,IAAI,WAAW,OAAO,WAAW,OAAO,WAAW,KAC/C,OAAO,IAAI,wBAAwB,SAAS,OAAO;CAEvD,IAAI,UAAU,KAAK,OAAO,IAAI,oBAAoB,SAAS,OAAO;CAClE,IAAI,UAAU,KAAK,OAAO,IAAI,aAAa,SAAS,OAAO;CAC3D,OAAO,IAAI,aAAa,SAAS,OAAO;AAC5C"}
|
|
1
|
+
{"version":3,"file":"errors.js","names":[],"sources":["../../src/shared/errors.ts"],"sourcesContent":["import type { PolyesterErrorDetail } from \"./error-detail.js\";\nexport type { PolyesterErrorDetail } from \"./error-detail.js\";\nimport type { RateLimitDetail } from \"./rate-limit.schemas.js\";\n\n/**\n * Typed error hierarchy for the Polyester SDK.\n *\n * Every error raised by the SDK extends {@link PolyesterError}, which carries a\n * stable machine-readable `code` and a `retryable` flag. The tree splits on\n * retryability so callers can triage with a single `instanceof` check:\n *\n * ```\n * PolyesterError code retryable\n * ├── TransientError TRANSIENT_FAILURE true\n * │ ├── NetworkError NETWORK_ERROR true\n * │ ├── TimeoutError TIMEOUT true\n * │ ├── RateLimitError RATE_LIMITED true\n * │ └── ServiceUnavailableError SERVICE_UNAVAILABLE true\n * ├── RequestError REQUEST_FAILED false\n * │ ├── ValidationError VALIDATION_FAILED false\n * │ │ ├── StaleQuoteError STALE_QUOTE\n * │ │ └── PolicyScopeMismatchError POLICY_SCOPE_MISMATCH\n * │ ├── ResourceNotFoundError RESOURCE_NOT_FOUND false\n * │ ├── NotImplementedError NOT_IMPLEMENTED false\n * │ ├── AlreadyExistsError ALREADY_EXISTS false\n * │ ├── PermissionError PERMISSION_DENIED false\n * │ ├── AuthenticationError UNAUTHENTICATED false\n * │ ├── PreconditionFailedError PRECONDITION_FAILED false\n * │ │ ├── RevisionConflictError REVISION_CONFLICT\n * │ │ ├── PolicyInUseError POLICY_IN_USE\n * │ │ ├── PolicyLockedError POLICY_LOCKED\n * │ │ ├── SubaccountChallengeInvalidError SUBACCOUNT_CHALLENGE_INVALID\n * │ │ └── MfaLastFactorRequiredError MFA_LAST_FACTOR_REQUIRED\n * │ ├── ConfigurationError INVALID_CONFIGURATION false\n * │ ├── MfaRequiredError MFA_REQUIRED false\n * │ │ ├── MfaEnrollmentRequiredError MFA_ENROLLMENT_REQUIRED\n * │ │ ├── StepUpRequiredError STEP_UP_REQUIRED\n * │ │ └── SessionElevationRequiredError SESSION_ELEVATION_REQUIRED\n * │ └── MfaVerificationError MFA_VERIFICATION_FAILED false\n * └── InternalServerError INTERNAL_SERVER_ERROR false\n * ```\n *\n * Catalog errors (`CatalogLookupError`, `CatalogConversionError`, …) plug into\n * the same tree under `RequestError`/`ValidationError`.\n *\n * Errors mapped from RPC failures keep the original `ConnectError` as `cause`.\n *\n * @example\n * ```ts\n * try {\n * await client.orders.createSpotOrder(input);\n * } catch (err) {\n * if (err instanceof RateLimitError) await sleep(err.retryAfterMs ?? 1000);\n * else if (err instanceof TransientError) retry();\n * else if (err instanceof StepUpRequiredError) promptForMfa();\n * else throw err;\n * }\n * ```\n */\n\n/** Stable machine-readable codes carried by built-in SDK errors. */\nexport type PolyesterErrorCode =\n | \"TRANSIENT_FAILURE\"\n | \"NETWORK_ERROR\"\n | \"TIMEOUT\"\n | \"RATE_LIMITED\"\n | \"SERVICE_UNAVAILABLE\"\n | \"REQUEST_FAILED\"\n | \"VALIDATION_FAILED\"\n | \"STALE_QUOTE\"\n | \"RESOURCE_NOT_FOUND\"\n | \"NOT_IMPLEMENTED\"\n | \"ALREADY_EXISTS\"\n | \"PERMISSION_DENIED\"\n | \"UNAUTHENTICATED\"\n | \"PRECONDITION_FAILED\"\n | \"REVISION_CONFLICT\"\n | \"POLICY_IN_USE\"\n | \"POLICY_LOCKED\"\n | \"POLICY_SCOPE_MISMATCH\"\n | \"INVALID_CONFIGURATION\"\n | \"MFA_REQUIRED\"\n | \"MFA_ENROLLMENT_REQUIRED\"\n | \"STEP_UP_REQUIRED\"\n | \"SESSION_ELEVATION_REQUIRED\"\n | \"MFA_LAST_FACTOR_REQUIRED\"\n | \"MFA_VERIFICATION_FAILED\"\n | \"INTERNAL_SERVER_ERROR\"\n | \"CATALOG_LOOKUP_MISS\"\n | \"CATALOG_NOT_READY\"\n | \"CATALOG_CONVERSION_INVALID\"\n | \"CATALOG_VALIDATION_FAILED\";\n\nexport interface PolyesterErrorOptions {\n /** Underlying error, typically the original `ConnectError` for RPC failures. */\n cause?: unknown;\n /** Recognized structured backend rejection, decoded at the RPC boundary. */\n detail?: PolyesterErrorDetail;\n}\n\nconst CONNECT_ERROR_PREFIX_RE = /^(?:\\[[a-z][a-z0-9_-]*]\\s*)+/i;\n\nexport function normalizeErrorMessage(message: string): string {\n return message.replace(CONNECT_ERROR_PREFIX_RE, \"\").trim();\n}\n\n/**\n * Base class for every error raised by the Polyester SDK.\n *\n * Check `retryable` (or `instanceof TransientError`) to decide whether the\n * same call can be safely retried, and switch on `code` for exhaustive,\n * minification-safe handling.\n */\nexport abstract class PolyesterError extends Error {\n /** Stable machine-readable error code, e.g. `\"RATE_LIMITED\"`. */\n abstract readonly code: string;\n /** Whether retrying the same operation may succeed. */\n abstract readonly retryable: boolean;\n readonly detail: PolyesterErrorDetail | undefined;\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(normalizeErrorMessage(message), options);\n this.name = \"PolyesterError\";\n this.detail =\n options?.detail ??\n (options?.cause instanceof PolyesterError ? options.cause.detail : undefined);\n }\n}\n\n/**\n * A transient failure — the request may never have reached the backend or the\n * backend was temporarily unable to serve it. Follow the operation's retry\n * contract: reuse requestId for idempotent mutations. For single-order creation,\n * reconcile by clientOrderId; reusing it returns a conflict rather than replay.\n */\nexport class TransientError extends PolyesterError {\n readonly code: string = \"TRANSIENT_FAILURE\";\n readonly retryable = true;\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"TransientError\";\n }\n}\n\n/** The request could not be sent or the connection failed mid-flight. */\nexport class NetworkError extends TransientError {\n override readonly code: string = \"NETWORK_ERROR\";\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"NetworkError\";\n }\n}\n\n/** The request timed out before the backend produced a response. */\nexport class TimeoutError extends TransientError {\n override readonly code: string = \"TIMEOUT\";\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"TimeoutError\";\n }\n}\n\nexport interface RateLimitErrorOptions extends PolyesterErrorOptions {\n /** Suggested wait before retrying, when the backend provided one. */\n retryAfterMs?: number;\n /** Structured quota state attached to the rejection, when provided. */\n rateLimit?: RateLimitDetail;\n}\n\n/** The backend rejected the request due to rate limiting. */\nexport class RateLimitError extends TransientError {\n override readonly code: string = \"RATE_LIMITED\";\n /** Suggested wait before retrying, in milliseconds, when known. */\n readonly retryAfterMs?: number;\n /** Structured quota state attached to the rejection, when provided. */\n readonly rateLimit?: RateLimitDetail;\n\n constructor(message: string, options?: RateLimitErrorOptions) {\n super(message, options);\n this.name = \"RateLimitError\";\n this.retryAfterMs = options?.retryAfterMs;\n this.rateLimit = options?.rateLimit;\n }\n}\n\n/** The backend is temporarily unavailable (e.g. overloaded or restarting). */\nexport class ServiceUnavailableError extends TransientError {\n override readonly code: string = \"SERVICE_UNAVAILABLE\";\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"ServiceUnavailableError\";\n }\n}\n\n/**\n * The request itself was rejected — retrying the identical call will fail the\n * same way. Fix the input, authentication, or permissions first.\n */\nexport class RequestError extends PolyesterError {\n readonly code: string = \"REQUEST_FAILED\";\n readonly retryable = false;\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"RequestError\";\n }\n}\n\n/** The request input failed validation (client- or server-side). */\nexport class ValidationError extends RequestError {\n override readonly code: string = \"VALIDATION_FAILED\";\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"ValidationError\";\n }\n}\n\n/** The submitted client reference quote exceeded the market's configured drift limit. */\nexport class StaleQuoteError extends ValidationError {\n override readonly code = \"STALE_QUOTE\" as const;\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"StaleQuoteError\";\n }\n}\n\n/** The requested resource does not exist (or is not visible to the caller). */\nexport class ResourceNotFoundError extends RequestError {\n override readonly code: string = \"RESOURCE_NOT_FOUND\";\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"ResourceNotFoundError\";\n }\n}\n\n/** The backend does not implement the requested operation (HTTP 501 / Connect `unimplemented`). */\nexport class NotImplementedError extends RequestError {\n override readonly code: string = \"NOT_IMPLEMENTED\";\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"NotImplementedError\";\n }\n}\n\n/** The resource already exists (e.g. a duplicate `clientOrderId`). */\nexport class AlreadyExistsError extends RequestError {\n override readonly code: string = \"ALREADY_EXISTS\";\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"AlreadyExistsError\";\n }\n}\n\n/** The caller is authenticated but not allowed to perform this operation. */\nexport class PermissionError extends RequestError {\n override readonly code: string = \"PERMISSION_DENIED\";\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"PermissionError\";\n }\n}\n\n/** The caller is not authenticated (missing, expired, or invalid credentials). */\nexport class AuthenticationError extends RequestError {\n override readonly code: string = \"UNAUTHENTICATED\";\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"AuthenticationError\";\n }\n}\n\n/** The system is not in a state that allows this operation (e.g. insufficient balance). */\nexport class PreconditionFailedError extends RequestError {\n override readonly code: string = \"PRECONDITION_FAILED\";\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"PreconditionFailedError\";\n }\n}\n\n/**\n * The resource changed after it was read, so the submitted expected revision\n * is stale. Refetch and let the caller reconcile; do not blindly retry.\n */\nexport class RevisionConflictError extends PreconditionFailedError {\n override readonly code: string = \"REVISION_CONFLICT\";\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"RevisionConflictError\";\n }\n}\n\n/**\n * The subaccount authorization is expired, replaced by a newer challenge, replayed,\n * or otherwise invalid. Request a fresh challenge via `subaccounts.createChallenge`.\n */\nexport class SubaccountChallengeInvalidError extends PreconditionFailedError {\n override readonly code: string = \"SUBACCOUNT_CHALLENGE_INVALID\";\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"SubaccountChallengeInvalidError\";\n }\n}\n\n/** The policy cannot be removed while accounts or API keys still use it. */\nexport class PolicyInUseError extends PreconditionFailedError {\n override readonly code: string = \"POLICY_IN_USE\";\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"PolicyInUseError\";\n }\n}\n\n/** The policy is locked against the requested mutation. */\nexport class PolicyLockedError extends PreconditionFailedError {\n override readonly code: string = \"POLICY_LOCKED\";\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"PolicyLockedError\";\n }\n}\n\n/** The policy does not belong to the account scope targeted by the request. */\nexport class PolicyScopeMismatchError extends ValidationError {\n override readonly code: string = \"POLICY_SCOPE_MISMATCH\";\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"PolicyScopeMismatchError\";\n }\n}\n\n/** The SDK was configured incorrectly (bad environment, missing credentials, …). */\nexport class ConfigurationError extends RequestError {\n override readonly code: string = \"INVALID_CONFIGURATION\";\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"ConfigurationError\";\n }\n}\n\n/**\n * The operation requires additional multi-factor authentication. Catch this\n * class to handle all MFA flows, or the subclasses to branch per flow.\n */\nexport class MfaRequiredError extends RequestError {\n override readonly code: string = \"MFA_REQUIRED\";\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"MfaRequiredError\";\n }\n}\n\n/** The user must enroll in MFA before this operation can proceed. */\nexport class MfaEnrollmentRequiredError extends MfaRequiredError {\n override readonly code: string = \"MFA_ENROLLMENT_REQUIRED\";\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"MfaEnrollmentRequiredError\";\n }\n}\n\n/** The operation requires a fresh MFA step-up proof (retry with `X-Auth-Step-Up`). */\nexport class StepUpRequiredError extends MfaRequiredError {\n override readonly code: string = \"STEP_UP_REQUIRED\";\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"StepUpRequiredError\";\n }\n}\n\n/** The operation requires a recent MFA-elevated session, not a one-use step-up proof. */\nexport class SessionElevationRequiredError extends MfaRequiredError {\n override readonly code: string = \"SESSION_ELEVATION_REQUIRED\";\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"SessionElevationRequiredError\";\n }\n}\n\n/** The requested deletion would leave the account without an active MFA factor. */\nexport class MfaLastFactorRequiredError extends PreconditionFailedError {\n override readonly code: string = \"MFA_LAST_FACTOR_REQUIRED\";\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"MfaLastFactorRequiredError\";\n }\n}\n\n/** The reason an MFA challenge could not be completed. */\nexport type MfaVerificationFailureReason =\n | \"challenge-invalid\"\n | \"challenge-locked\"\n | \"otp-invalid\"\n | \"recovery-code-invalid\"\n | \"passkey-invalid\";\n\n/**\n * An expected MFA verification rejection. Callers should select their own\n * user-facing copy from `reason` instead of displaying the backend message.\n */\nexport class MfaVerificationError extends RequestError {\n override readonly code: string = \"MFA_VERIFICATION_FAILED\";\n\n constructor(\n message: string,\n readonly reason: MfaVerificationFailureReason,\n options?: PolyesterErrorOptions,\n ) {\n super(message, options);\n this.name = \"MfaVerificationError\";\n }\n}\n\n/**\n * The backend failed unexpectedly or returned a malformed response. Not\n * automatically retryable — the failure may recur and mutations may have\n * partially applied.\n */\nexport class InternalServerError extends PolyesterError {\n readonly code: string = \"INTERNAL_SERVER_ERROR\";\n readonly retryable = false;\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"InternalServerError\";\n }\n}\n\n/**\n * Checks whether an error represents an aborted request (caller-initiated via\n * `AbortSignal`). Aborts are intentionally NOT part of the {@link PolyesterError}\n * tree and are never retryable.\n */\nexport function isAbortError(err: unknown): boolean {\n return err instanceof DOMException && err.name === \"AbortError\";\n}\n\n/** Maps a plain HTTP status code onto the SDK error tree. */\nexport function errorFromHttpStatus(\n status: number,\n message: string,\n options?: RateLimitErrorOptions,\n): PolyesterError {\n if (status === 400 || status === 422) return new ValidationError(message, options);\n if (status === 401) return new AuthenticationError(message, options);\n if (status === 403) return new PermissionError(message, options);\n if (status === 404) return new ResourceNotFoundError(message, options);\n if (status === 408) return new TimeoutError(message, options);\n if (status === 409) return new AlreadyExistsError(message, options);\n if (status === 412) return new PreconditionFailedError(message, options);\n if (status === 429) return new RateLimitError(message, options);\n if (status === 501) return new NotImplementedError(message, options);\n if (status === 502 || status === 503 || status === 504) {\n return new ServiceUnavailableError(message, options);\n }\n if (status >= 500) return new InternalServerError(message, options);\n if (status >= 400) return new RequestError(message, options);\n return new NetworkError(message, options);\n}\n"],"mappings":";AAoGA,MAAM,0BAA0B;AAEhC,SAAgB,sBAAsB,SAAyB;CAC3D,OAAO,QAAQ,QAAQ,yBAAyB,EAAE,CAAC,CAAC,KAAK;AAC7D;;;;;;;;AASA,IAAsB,iBAAtB,MAAsB,uBAAuB,MAAM;CAK/C;CAEA,YAAY,SAAiB,SAAiC;EAC1D,MAAM,sBAAsB,OAAO,GAAG,OAAO;EAC7C,KAAK,OAAO;EACZ,KAAK,SACD,SAAS,WACR,SAAS,iBAAiB,iBAAiB,QAAQ,MAAM,SAAS,KAAA;CAC3E;AACJ;;;;;;;AAQA,IAAa,iBAAb,cAAoC,eAAe;CAC/C,OAAwB;CACxB,YAAqB;CAErB,YAAY,SAAiB,SAAiC;EAC1D,MAAM,SAAS,OAAO;EACtB,KAAK,OAAO;CAChB;AACJ;;AAGA,IAAa,eAAb,cAAkC,eAAe;CAC7C,OAAiC;CAEjC,YAAY,SAAiB,SAAiC;EAC1D,MAAM,SAAS,OAAO;EACtB,KAAK,OAAO;CAChB;AACJ;;AAGA,IAAa,eAAb,cAAkC,eAAe;CAC7C,OAAiC;CAEjC,YAAY,SAAiB,SAAiC;EAC1D,MAAM,SAAS,OAAO;EACtB,KAAK,OAAO;CAChB;AACJ;;AAUA,IAAa,iBAAb,cAAoC,eAAe;CAC/C,OAAiC;;CAEjC;;CAEA;CAEA,YAAY,SAAiB,SAAiC;EAC1D,MAAM,SAAS,OAAO;EACtB,KA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