@polyester/sdk 0.34.1-devnet-20261106033258 → 0.35.0-devnet-20261108030630

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.
Files changed (75) hide show
  1. package/CHANGELOG.md +21 -1
  2. package/README.md +12 -0
  3. package/dist/gen/auth/v1/auth_pb.d.ts +9 -1
  4. package/dist/gen/auth/v1/auth_pb.d.ts.map +1 -1
  5. package/dist/gen/auth/v1/auth_pb.js +9 -1
  6. package/dist/gen/auth/v1/auth_pb.js.map +1 -1
  7. package/dist/gen/changelog/v1/changelog_pb.d.ts +28 -9
  8. package/dist/gen/changelog/v1/changelog_pb.d.ts.map +1 -1
  9. package/dist/gen/changelog/v1/changelog_pb.js +1 -1
  10. package/dist/gen/changelog/v1/changelog_pb.js.map +1 -1
  11. package/dist/gen/marketoverview/v1/marketoverview_pb.d.ts +2 -1
  12. package/dist/gen/marketoverview/v1/marketoverview_pb.d.ts.map +1 -1
  13. package/dist/gen/marketoverview/v1/marketoverview_pb.js.map +1 -1
  14. package/dist/gen/orders/v1/orders_pb.d.ts +2 -0
  15. package/dist/gen/orders/v1/orders_pb.d.ts.map +1 -1
  16. package/dist/gen/orders/v1/orders_pb.js.map +1 -1
  17. package/dist/gen/orders/v1/orders_read_pb.d.ts +23 -7
  18. package/dist/gen/orders/v1/orders_read_pb.d.ts.map +1 -1
  19. package/dist/gen/orders/v1/orders_read_pb.js.map +1 -1
  20. package/dist/gen/triggers/v1/triggers_pb.d.ts +1 -1
  21. package/dist/gen/triggers/v1/triggers_pb.js.map +1 -1
  22. package/dist/index.d.ts +4 -4
  23. package/dist/index.js +2 -2
  24. package/dist/realtime/client.d.ts.map +1 -1
  25. package/dist/realtime/client.js +178 -29
  26. package/dist/realtime/client.js.map +1 -1
  27. package/dist/realtime/index.d.ts +2 -2
  28. package/dist/realtime/types.d.ts +21 -2
  29. package/dist/realtime/types.d.ts.map +1 -1
  30. package/dist/services/auto-withdraw/auto-withdraw.schemas.d.ts +19 -19
  31. package/dist/services/candles/candles.schemas.d.ts +10 -10
  32. package/dist/services/changelog/changelog.d.ts +6 -3
  33. package/dist/services/changelog/changelog.d.ts.map +1 -1
  34. package/dist/services/changelog/changelog.js +6 -3
  35. package/dist/services/changelog/changelog.js.map +1 -1
  36. package/dist/services/changelog/changelog.schemas.d.ts +37 -3
  37. package/dist/services/changelog/changelog.schemas.d.ts.map +1 -1
  38. package/dist/services/changelog/changelog.schemas.js +10 -2
  39. package/dist/services/changelog/changelog.schemas.js.map +1 -1
  40. package/dist/services/heatmap/heatmap.schemas.d.ts +4 -4
  41. package/dist/services/lifecycle/lifecycle.schemas.d.ts +42 -42
  42. package/dist/services/orderbook/orderbook.d.ts +1 -1
  43. package/dist/services/orderbook/orderbook.js +1 -1
  44. package/dist/services/orderbook/orderbook.js.map +1 -1
  45. package/dist/services/orderbook/orderbook.schemas.d.ts +1 -1
  46. package/dist/services/orders/order-errors.schemas.d.ts +1 -1
  47. package/dist/services/orders/orders-batch.schemas.d.ts +39 -39
  48. package/dist/services/orders/orders-input.schemas.d.ts +3 -3
  49. package/dist/services/orders/orders-output.schemas.d.ts +14 -14
  50. package/dist/services/orders/orders.d.ts +9 -1
  51. package/dist/services/orders/orders.d.ts.map +1 -1
  52. package/dist/services/orders/orders.js +9 -1
  53. package/dist/services/orders/orders.js.map +1 -1
  54. package/dist/services/rewards/rewards.schemas.d.ts +3 -3
  55. package/dist/services/subaccounts/subaccounts.schemas.d.ts +5 -5
  56. package/dist/services/trades/trades.schemas.d.ts +1 -1
  57. package/dist/services/triggers/trigger-input.schemas.d.ts +2 -2
  58. package/dist/services/triggers/triggers-output.schemas.d.ts +18 -18
  59. package/dist/shared/connect-error-mapping.d.ts.map +1 -1
  60. package/dist/shared/connect-error-mapping.js +7 -3
  61. package/dist/shared/connect-error-mapping.js.map +1 -1
  62. package/dist/shared/error-detail.d.ts +7 -0
  63. package/dist/shared/error-detail.d.ts.map +1 -1
  64. package/dist/shared/error-detail.js +2 -1
  65. package/dist/shared/error-detail.js.map +1 -1
  66. package/dist/shared/error-details/rate-limit.js +18 -0
  67. package/dist/shared/error-details/rate-limit.js.map +1 -0
  68. package/dist/shared/errors.d.ts +12 -3
  69. package/dist/shared/errors.d.ts.map +1 -1
  70. package/dist/shared/errors.js +13 -1
  71. package/dist/shared/errors.js.map +1 -1
  72. package/dist/shared/subscription-errors.d.ts +2 -0
  73. package/dist/shared/subscription-errors.d.ts.map +1 -1
  74. package/dist/shared/subscription-errors.js.map +1 -1
  75. package/package.json +1 -1
@@ -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 * │ ├── TimestampSkewError TIMESTAMP_SKEW true\n * │ └── ServiceUnavailableError SERVICE_UNAVAILABLE true\n * ├── RequestError REQUEST_FAILED false\n * │ ├── ValidationError VALIDATION_FAILED false\n * │ │ ├── StaleQuoteError STALE_QUOTE\n * │ │ ├── WithdrawDeadlineExpiredError WITHDRAW_DEADLINE_EXPIRED\n * │ │ └── PolicyScopeMismatchError POLICY_SCOPE_MISMATCH\n * │ ├── ResourceNotFoundError RESOURCE_NOT_FOUND false\n * │ ├── NotImplementedError NOT_IMPLEMENTED false\n * │ ├── AlreadyExistsError ALREADY_EXISTS false\n * │ │ └── UserOperationAlreadyKnownError USER_OPERATION_ALREADY_KNOWN\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 * │ ├── UserOperationSendTimeoutError USER_OPERATION_SEND_TIMEOUT false\n * │ ├── OutcomeUnknownError OUTCOME_UNKNOWN false\n * │ └── UserOperationNotExecutedError USER_OPERATION_NOT_EXECUTED false\n * ├── InternalServerError INTERNAL_SERVER_ERROR false\n * └── RealtimeError REALTIME_ERROR varies\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 * and carry the response's `status` when available.\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 | \"TIMESTAMP_SKEW\"\n | \"SERVICE_UNAVAILABLE\"\n | \"REQUEST_FAILED\"\n | \"VALIDATION_FAILED\"\n | \"STALE_QUOTE\"\n | \"WITHDRAW_DEADLINE_EXPIRED\"\n | \"RESOURCE_NOT_FOUND\"\n | \"NOT_IMPLEMENTED\"\n | \"ALREADY_EXISTS\"\n | \"USER_OPERATION_ALREADY_KNOWN\"\n | \"USER_OPERATION_SEND_TIMEOUT\"\n | \"OUTCOME_UNKNOWN\"\n | \"USER_OPERATION_NOT_EXECUTED\"\n | \"PERMISSION_DENIED\"\n | \"UNAUTHENTICATED\"\n | \"PRECONDITION_FAILED\"\n | \"REVISION_CONFLICT\"\n | \"SUBACCOUNT_CHALLENGE_INVALID\"\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 | \"REALTIME_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 /** HTTP status of the failed response. */\n status?: number;\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 * HTTP status of the failed response. For Connect errors that carry no raw\n * HTTP status, the Connect protocol's status for the error code.\n */\n readonly status: number | undefined;\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(normalizeErrorMessage(message), options);\n this.name = \"PolyesterError\";\n const inherited = options?.cause instanceof PolyesterError ? options.cause : undefined;\n this.detail = options?.detail ?? inherited?.detail;\n this.status = options?.status ?? inherited?.status;\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/**\n * The API-key signature timestamp fell outside the backend's skew window, e.g.\n * because the request waited too long in the runtime's fetch queue during a\n * large concurrent burst, or the local clock drifted. Retrying the call signs\n * it again with a fresh timestamp; bound concurrency if it recurs.\n */\nexport class TimestampSkewError extends TransientError {\n override readonly code: string = \"TIMESTAMP_SKEW\";\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"TimestampSkewError\";\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/**\n * The prepared withdraw's signed deadline has passed, so the backend would\n * reject it. Prepare (and sign) the withdraw again.\n *\n * Thrown by `submit` before sending once the deadline has passed, and when the\n * backend rejects the deadline as expired: one that lapsed in flight, or one\n * signed from a device clock running behind the server's.\n */\nexport class WithdrawDeadlineExpiredError extends ValidationError {\n override readonly code: string = \"WITHDRAW_DEADLINE_EXPIRED\";\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"WithdrawDeadlineExpiredError\";\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/**\n * The bundler already holds this exact UserOperation (it answered \"Already\n * known\"), so the earlier submission is still pending. Wait on `userOpHash`\n * instead of signing again; a new operation would execute a second time.\n */\nexport class UserOperationAlreadyKnownError extends AlreadyExistsError {\n override readonly code: string = \"USER_OPERATION_ALREADY_KNOWN\";\n readonly userOpHash: `0x${string}`;\n\n constructor(message: string, userOpHash: `0x${string}`, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"UserOperationAlreadyKnownError\";\n this.userOpHash = userOpHash;\n }\n}\n\n/**\n * `eth_sendUserOperation` timed out after the UserOperation was signed. The\n * bundler may still have accepted it, so the outcome is unknown rather than\n * rejected. Wait on `userOpHash` instead of signing again; a new operation\n * could execute a second time. Not retryable for the same reason.\n */\nexport class UserOperationSendTimeoutError extends RequestError {\n override readonly code: string = \"USER_OPERATION_SEND_TIMEOUT\";\n readonly userOpHash: `0x${string}`;\n\n constructor(message: string, userOpHash: `0x${string}`, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"UserOperationSendTimeoutError\";\n this.userOpHash = userOpHash;\n }\n}\n\n/**\n * An order or trigger change was sent but not confirmed in time, so it may\n * still apply. Not retryable: read the order by its client order ID, or list\n * triggers by client trigger ID, before sending it again. `detail.code` names\n * the operation, e.g. `ORDER_CREATE_OUTCOME_UNKNOWN`.\n */\nexport class OutcomeUnknownError extends RequestError {\n override readonly code: string = \"OUTCOME_UNKNOWN\";\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"OutcomeUnknownError\";\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, already\n * consumed, or has an invalid signature. Request a fresh challenge via\n * `subaccounts.createChallenge`. Temporary verification failures surface as\n * `ServiceUnavailableError` instead; retry those with the same signed challenge.\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\nexport interface RealtimeErrorOptions extends PolyesterErrorOptions {\n /** Centrifugo protocol, disconnect, or unsubscribe code; 0 when none applies. */\n realtimeCode?: number;\n /** True when the realtime client is already retrying on its own. */\n retryable?: boolean;\n}\n\n/**\n * A realtime subscription failure reported by the server or the websocket\n * client. `retryable` errors (e.g. code 109, token expired) are being retried\n * automatically; only non-retryable ones end the subscription.\n */\nexport class RealtimeError extends PolyesterError {\n readonly code = \"REALTIME_ERROR\" as const;\n readonly retryable: boolean;\n readonly realtimeCode: number;\n\n constructor(message: string, options?: RealtimeErrorOptions) {\n super(message, options);\n this.name = \"RealtimeError\";\n this.realtimeCode = options?.realtimeCode ?? 0;\n this.retryable = options?.retryable ?? false;\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/** Checks whether an error is the `TimeoutError` raised by `AbortSignal.timeout()`. */\nexport function isTimeoutAbortError(err: unknown): boolean {\n return err instanceof DOMException && err.name === \"TimeoutError\";\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\n/**\n * The bundler reported a UserOperation as definitively not executed, so nothing\n * moved on chain: `rejected` (dropped by the bundler, often for a fee below the\n * current price) or `failed` (its bundle transaction reverted). Submitting a\n * fresh operation is safe.\n */\nexport class UserOperationNotExecutedError extends RequestError {\n override readonly code: string = \"USER_OPERATION_NOT_EXECUTED\";\n readonly userOpHash: `0x${string}`;\n /** The bundler's `pimlico_getUserOperationStatus` result. */\n readonly bundlerStatus: \"rejected\" | \"failed\";\n\n constructor(\n message: string,\n userOpHash: `0x${string}`,\n bundlerStatus: \"rejected\" | \"failed\",\n options?: PolyesterErrorOptions,\n ) {\n super(message, options);\n this.name = \"UserOperationNotExecutedError\";\n this.userOpHash = userOpHash;\n this.bundlerStatus = bundlerStatus;\n }\n}\n"],"mappings":";AAsHA,MAAM,0BAA0B;AAEhC,SAAgB,sBAAsB,SAAyB;CAC3D,OAAO,QAAQ,QAAQ,yBAAyB,EAAE,CAAC,CAAC,KAAK;AAC7D;;;;;;;;AASA,IAAsB,iBAAtB,MAAsB,uBAAuB,MAAM;CAK/C;;;;;CAKA;CAEA,YAAY,SAAiB,SAAiC;EAC1D,MAAM,sBAAsB,OAAO,GAAG,OAAO;EAC7C,KAAK,OAAO;EACZ,MAAM,YAAY,SAAS,iBAAiB,iBAAiB,QAAQ,QAAQ,KAAA;EAC7E,KAAK,SAAS,SAAS,UAAU,WAAW;EAC5C,KAAK,SAAS,SAAS,UAAU,WAAW;CAChD;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,KAA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AAW,KAAK,OAAO,IAAI,oBAAoB,SAAS,OAAO;CACnE,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;;;;;;;AAQA,IAAa,gCAAb,cAAmD,aAAa;CAC5D,OAAiC;CACjC;;CAEA;CAEA,YACI,SACA,YACA,eACA,SACF;EACE,MAAM,SAAS,OAAO;EACtB,KAAK,OAAO;EACZ,KAAK,aAAa;EAClB,KAAK,gBAAgB;CACzB;AACJ"}
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 * │ ├── TimestampSkewError TIMESTAMP_SKEW true\n * │ └── ServiceUnavailableError SERVICE_UNAVAILABLE true\n * ├── RequestError REQUEST_FAILED false\n * │ ├── ValidationError VALIDATION_FAILED false\n * │ │ ├── StaleQuoteError STALE_QUOTE\n * │ │ ├── WithdrawDeadlineExpiredError WITHDRAW_DEADLINE_EXPIRED\n * │ │ └── PolicyScopeMismatchError POLICY_SCOPE_MISMATCH\n * │ ├── ResourceNotFoundError RESOURCE_NOT_FOUND false\n * │ ├── RequestTooLargeError REQUEST_TOO_LARGE false\n * │ ├── NotImplementedError NOT_IMPLEMENTED false\n * │ ├── AlreadyExistsError ALREADY_EXISTS false\n * │ │ └── UserOperationAlreadyKnownError USER_OPERATION_ALREADY_KNOWN\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 * │ ├── UserOperationSendTimeoutError USER_OPERATION_SEND_TIMEOUT false\n * │ ├── OutcomeUnknownError OUTCOME_UNKNOWN false\n * │ └── UserOperationNotExecutedError USER_OPERATION_NOT_EXECUTED false\n * ├── InternalServerError INTERNAL_SERVER_ERROR false\n * └── RealtimeError REALTIME_ERROR varies\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 * and carry the response's `status` when available.\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 | \"TIMESTAMP_SKEW\"\n | \"SERVICE_UNAVAILABLE\"\n | \"REQUEST_FAILED\"\n | \"VALIDATION_FAILED\"\n | \"STALE_QUOTE\"\n | \"WITHDRAW_DEADLINE_EXPIRED\"\n | \"RESOURCE_NOT_FOUND\"\n | \"REQUEST_TOO_LARGE\"\n | \"NOT_IMPLEMENTED\"\n | \"ALREADY_EXISTS\"\n | \"USER_OPERATION_ALREADY_KNOWN\"\n | \"USER_OPERATION_SEND_TIMEOUT\"\n | \"OUTCOME_UNKNOWN\"\n | \"USER_OPERATION_NOT_EXECUTED\"\n | \"PERMISSION_DENIED\"\n | \"UNAUTHENTICATED\"\n | \"PRECONDITION_FAILED\"\n | \"REVISION_CONFLICT\"\n | \"SUBACCOUNT_CHALLENGE_INVALID\"\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 | \"REALTIME_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 /** HTTP status of the failed response. */\n status?: number;\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 * HTTP status of the failed response. For Connect errors that carry no raw\n * HTTP status, the Connect protocol's status for the error code.\n */\n readonly status: number | undefined;\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(normalizeErrorMessage(message), options);\n this.name = \"PolyesterError\";\n const inherited = options?.cause instanceof PolyesterError ? options.cause : undefined;\n this.detail = options?.detail ?? inherited?.detail;\n this.status = options?.status ?? inherited?.status;\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/**\n * The API-key signature timestamp fell outside the backend's skew window, e.g.\n * because the request waited too long in the runtime's fetch queue during a\n * large concurrent burst, or the local clock drifted. Retrying the call signs\n * it again with a fresh timestamp; bound concurrency if it recurs.\n */\nexport class TimestampSkewError extends TransientError {\n override readonly code: string = \"TIMESTAMP_SKEW\";\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"TimestampSkewError\";\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/**\n * The prepared withdraw's signed deadline has passed, so the backend would\n * reject it. Prepare (and sign) the withdraw again.\n *\n * Thrown by `submit` before sending once the deadline has passed, and when the\n * backend rejects the deadline as expired: one that lapsed in flight, or one\n * signed from a device clock running behind the server's.\n */\nexport class WithdrawDeadlineExpiredError extends ValidationError {\n override readonly code: string = \"WITHDRAW_DEADLINE_EXPIRED\";\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"WithdrawDeadlineExpiredError\";\n }\n}\n\n/**\n * The request body was over the endpoint's size limit (HTTP 413). The limit is\n * fixed per endpoint, so the same request fails again; send a smaller one.\n */\nexport class RequestTooLargeError extends RequestError {\n override readonly code: string = \"REQUEST_TOO_LARGE\";\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"RequestTooLargeError\";\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/**\n * The bundler already holds this exact UserOperation (it answered \"Already\n * known\"), so the earlier submission is still pending. Wait on `userOpHash`\n * instead of signing again; a new operation would execute a second time.\n */\nexport class UserOperationAlreadyKnownError extends AlreadyExistsError {\n override readonly code: string = \"USER_OPERATION_ALREADY_KNOWN\";\n readonly userOpHash: `0x${string}`;\n\n constructor(message: string, userOpHash: `0x${string}`, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"UserOperationAlreadyKnownError\";\n this.userOpHash = userOpHash;\n }\n}\n\n/**\n * `eth_sendUserOperation` timed out after the UserOperation was signed. The\n * bundler may still have accepted it, so the outcome is unknown rather than\n * rejected. Wait on `userOpHash` instead of signing again; a new operation\n * could execute a second time. Not retryable for the same reason.\n */\nexport class UserOperationSendTimeoutError extends RequestError {\n override readonly code: string = \"USER_OPERATION_SEND_TIMEOUT\";\n readonly userOpHash: `0x${string}`;\n\n constructor(message: string, userOpHash: `0x${string}`, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"UserOperationSendTimeoutError\";\n this.userOpHash = userOpHash;\n }\n}\n\n/**\n * An order or trigger change was sent but not confirmed in time, so it may\n * still apply. Not retryable: read the order by its client order ID, or list\n * triggers by client trigger ID, before sending it again. `detail.code` names\n * the operation, e.g. `ORDER_CREATE_OUTCOME_UNKNOWN`.\n */\nexport class OutcomeUnknownError extends RequestError {\n override readonly code: string = \"OUTCOME_UNKNOWN\";\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"OutcomeUnknownError\";\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, already\n * consumed, or has an invalid signature. Request a fresh challenge via\n * `subaccounts.createChallenge`. Temporary verification failures surface as\n * `ServiceUnavailableError` instead; retry those with the same signed challenge.\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\nexport interface RealtimeErrorOptions extends PolyesterErrorOptions {\n /** Centrifugo protocol, disconnect, or unsubscribe code; 0 when none applies. */\n realtimeCode?: number;\n /** True when the realtime client is already retrying on its own. */\n retryable?: boolean;\n}\n\n/**\n * A realtime subscription failure reported by the server or the websocket\n * client. `retryable` errors (e.g. code 109, token expired) are being retried\n * automatically; only non-retryable ones end the subscription.\n */\nexport class RealtimeError extends PolyesterError {\n readonly code = \"REALTIME_ERROR\" as const;\n readonly retryable: boolean;\n readonly realtimeCode: number;\n\n constructor(message: string, options?: RealtimeErrorOptions) {\n super(message, options);\n this.name = \"RealtimeError\";\n this.realtimeCode = options?.realtimeCode ?? 0;\n this.retryable = options?.retryable ?? false;\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/** Checks whether an error is the `TimeoutError` raised by `AbortSignal.timeout()`. */\nexport function isTimeoutAbortError(err: unknown): boolean {\n return err instanceof DOMException && err.name === \"TimeoutError\";\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 === 413) return new RequestTooLargeError(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\n/**\n * The bundler reported a UserOperation as definitively not executed, so nothing\n * moved on chain: `rejected` (dropped by the bundler, often for a fee below the\n * current price) or `failed` (its bundle transaction reverted). Submitting a\n * fresh operation is safe.\n */\nexport class UserOperationNotExecutedError extends RequestError {\n override readonly code: string = \"USER_OPERATION_NOT_EXECUTED\";\n readonly userOpHash: `0x${string}`;\n /** The bundler's `pimlico_getUserOperationStatus` result. */\n readonly bundlerStatus: \"rejected\" | \"failed\";\n\n constructor(\n message: string,\n userOpHash: `0x${string}`,\n bundlerStatus: \"rejected\" | \"failed\",\n options?: PolyesterErrorOptions,\n ) {\n super(message, options);\n this.name = \"UserOperationNotExecutedError\";\n this.userOpHash = userOpHash;\n this.bundlerStatus = bundlerStatus;\n }\n}\n"],"mappings":";AAwHA,MAAM,0BAA0B;AAEhC,SAAgB,sBAAsB,SAAyB;CAC3D,OAAO,QAAQ,QAAQ,yBAAyB,EAAE,CAAC,CAAC,KAAK;AAC7D;;;;;;;;AASA,IAAsB,iBAAtB,MAAsB,uBAAuB,MAAM;CAK/C;;;;;CAKA;CAEA,YAAY,SAAiB,SAAiC;EAC1D,MAAM,sBAAsB,OAAO,GAAG,OAAO;EAC7C,KAAK,OAAO;EACZ,MAAM,YAAY,SAAS,iBAAiB,iBAAiB,QAAQ,QAAQ,KAAA;EAC7E,KAAK,SAAS,SAAS,UAAU,WAAW;EAC5C,KAAK,SAA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ACvD,OAAO,eAAe,gBAAgB,IAAI,SAAS;AACvD;;AAGA,SAAgB,oBACZ,QACA,SACA,SACc;CACd,IAAI,WAAW,OAAO,WAAW,KAAK,OAAO,IAAI,gBAAgB,SAAS,OAAO;CACjF,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,wBAAwB,SAAS,OAAO;CACvE,IAAI,WAAW,KAAK,OAAO,IAAI,qBAAqB,SAAS,OAAO;CACpE,IAAI,WAAW,KAAK,OAAO,IAAI,eAAe,SAAS,OAAO;CAC9D,IAAI,WAAW,KAAK,OAAO,IAAI,oBAAoB,SAAS,OAAO;CACnE,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;;;;;;;AAQA,IAAa,gCAAb,cAAmD,aAAa;CAC5D,OAAiC;CACjC;;CAEA;CAEA,YACI,SACA,YACA,eACA,SACF;EACE,MAAM,SAAS,OAAO;EACtB,KAAK,OAAO;EACZ,KAAK,aAAa;EAClB,KAAK,gBAAgB;CACzB;AACJ"}
@@ -6,6 +6,8 @@ type SdkSubscriptionErrorContext = {
6
6
  /**
7
7
  * Always an `Error`. Server and websocket failures arrive as {@link RealtimeError};
8
8
  * skip reporting when `retryable` is true, the realtime client is already retrying.
9
+ * A `"transport"` error is retryable too, but the channel gets no data until the socket
10
+ * recovers, so show it rather than ignore it.
9
11
  */
10
12
  error: Error;
11
13
  };
@@ -1 +1 @@
1
- {"version":3,"file":"subscription-errors.d.ts","names":[],"sources":["../../src/shared/subscription-errors.ts"],"mappings":";;KAGY;EACR;EACA;;;;;EAKA,OAAO"}
1
+ {"version":3,"file":"subscription-errors.d.ts","names":[],"sources":["../../src/shared/subscription-errors.ts"],"mappings":";;KAGY;EACR;EACA;;;;;;;EAOA,OAAO"}
@@ -1 +1 @@
1
- {"version":3,"file":"subscription-errors.js","names":[],"sources":["../../src/shared/subscription-errors.ts"],"sourcesContent":["import type { SubscriptionErrorContext as CentrifugeSubscriptionErrorContext } from \"centrifuge/build/protobuf\";\nimport { RealtimeError } from \"./errors.js\";\n\nexport type SdkSubscriptionErrorContext = {\n channel: string;\n type: string;\n /**\n * Always an `Error`. Server and websocket failures arrive as {@link RealtimeError};\n * skip reporting when `retryable` is true, the realtime client is already retrying.\n */\n error: Error;\n};\n\nfunction toRealtimeError(error: unknown, retryable: boolean): Error {\n if (error instanceof Error) return error;\n if (typeof error === \"string\") return new RealtimeError(error, { retryable });\n if (typeof error === \"object\" && error !== null) {\n const { code, message } = error as { code?: unknown; message?: unknown };\n return new RealtimeError(\n typeof message === \"string\" && message\n ? message\n : \"Unknown realtime subscription error\",\n { realtimeCode: typeof code === \"number\" ? code : 0, retryable },\n );\n }\n return new RealtimeError(\"Unknown realtime subscription error\", { retryable });\n}\n\nexport function createSdkSubscriptionErrorContext(\n channel: string,\n type: string,\n error: unknown,\n): SdkSubscriptionErrorContext {\n return { channel, type, error: toRealtimeError(error, false) };\n}\n\nexport function publicationHandlerErrorContext(\n channel: string,\n error: unknown,\n): SdkSubscriptionErrorContext {\n return createSdkSubscriptionErrorContext(channel, \"publication_handler\", error);\n}\n\n/**\n * Delivers every event of one batch publication in order. A failing event is\n * reported on its own, so it does not drop the rest of the batch.\n */\nexport function deliverBatch<T>(\n channel: string,\n events: readonly T[],\n deliver: (event: T) => void,\n onError: ((error: SdkSubscriptionErrorContext) => void) | undefined,\n): void {\n for (const event of events) {\n try {\n deliver(event);\n } catch (error) {\n onError?.(publicationHandlerErrorContext(channel, error));\n }\n }\n}\n\n/**\n * Centrifuge emits plain `{ code, message, temporary }` objects despite its types, and\n * only emits subscription `error` events for failures it retries itself; fatal ones\n * arrive as `unsubscribed`.\n */\nexport function fromCentrifugeSubscriptionError(\n ctx: CentrifugeSubscriptionErrorContext,\n): SdkSubscriptionErrorContext {\n return { channel: ctx.channel, type: ctx.type, error: toRealtimeError(ctx.error, true) };\n}\n"],"mappings":";;AAaA,SAAS,gBAAgB,OAAgB,WAA2B;CAChE,IAAI,iBAAiB,OAAO,OAAO;CACnC,IAAI,OAAO,UAAU,UAAU,OAAO,IAAI,cAAc,OAAO,EAAE,UAAU,CAAC;CAC5E,IAAI,OAAO,UAAU,YAAY,UAAU,MAAM;EAC7C,MAAM,EAAE,MAAM,YAAY;EAC1B,OAAO,IAAI,cACP,OAAO,YAAY,YAAY,UACzB,UACA,uCACN;GAAE,cAAc,OAAO,SAAS,WAAW,OAAO;GAAG;EAAU,CACnE;CACJ;CACA,OAAO,IAAI,cAAc,uCAAuC,EAAE,UAAU,CAAC;AACjF;AAEA,SAAgB,kCACZ,SACA,MACA,OAC2B;CAC3B,OAAO;EAAE;EAAS;EAAM,OAAO,gBAAgB,OAAO,KAAK;CAAE;AACjE;AAEA,SAAgB,+BACZ,SACA,OAC2B;CAC3B,OAAO,kCAAkC,SAAS,uBAAuB,KAAK;AAClF;;;;;AAMA,SAAgB,aACZ,SACA,QACA,SACA,SACI;CACJ,KAAK,MAAM,SAAS,QAChB,IAAI;EACA,QAAQ,KAAK;CACjB,SAAS,OAAO;EACZ,UAAU,+BAA+B,SAAS,KAAK,CAAC;CAC5D;AAER;;;;;;AAOA,SAAgB,gCACZ,KAC2B;CAC3B,OAAO;EAAE,SAAS,IAAI;EAAS,MAAM,IAAI;EAAM,OAAO,gBAAgB,IAAI,OAAO,IAAI;CAAE;AAC3F"}
1
+ {"version":3,"file":"subscription-errors.js","names":[],"sources":["../../src/shared/subscription-errors.ts"],"sourcesContent":["import type { SubscriptionErrorContext as CentrifugeSubscriptionErrorContext } from \"centrifuge/build/protobuf\";\nimport { RealtimeError } from \"./errors.js\";\n\nexport type SdkSubscriptionErrorContext = {\n channel: string;\n type: string;\n /**\n * Always an `Error`. Server and websocket failures arrive as {@link RealtimeError};\n * skip reporting when `retryable` is true, the realtime client is already retrying.\n * A `\"transport\"` error is retryable too, but the channel gets no data until the socket\n * recovers, so show it rather than ignore it.\n */\n error: Error;\n};\n\nfunction toRealtimeError(error: unknown, retryable: boolean): Error {\n if (error instanceof Error) return error;\n if (typeof error === \"string\") return new RealtimeError(error, { retryable });\n if (typeof error === \"object\" && error !== null) {\n const { code, message } = error as { code?: unknown; message?: unknown };\n return new RealtimeError(\n typeof message === \"string\" && message\n ? message\n : \"Unknown realtime subscription error\",\n { realtimeCode: typeof code === \"number\" ? code : 0, retryable },\n );\n }\n return new RealtimeError(\"Unknown realtime subscription error\", { retryable });\n}\n\nexport function createSdkSubscriptionErrorContext(\n channel: string,\n type: string,\n error: unknown,\n): SdkSubscriptionErrorContext {\n return { channel, type, error: toRealtimeError(error, false) };\n}\n\nexport function publicationHandlerErrorContext(\n channel: string,\n error: unknown,\n): SdkSubscriptionErrorContext {\n return createSdkSubscriptionErrorContext(channel, \"publication_handler\", error);\n}\n\n/**\n * Delivers every event of one batch publication in order. A failing event is\n * reported on its own, so it does not drop the rest of the batch.\n */\nexport function deliverBatch<T>(\n channel: string,\n events: readonly T[],\n deliver: (event: T) => void,\n onError: ((error: SdkSubscriptionErrorContext) => void) | undefined,\n): void {\n for (const event of events) {\n try {\n deliver(event);\n } catch (error) {\n onError?.(publicationHandlerErrorContext(channel, error));\n }\n }\n}\n\n/**\n * Centrifuge emits plain `{ code, message, temporary }` objects despite its types, and\n * only emits subscription `error` events for failures it retries itself; fatal ones\n * arrive as `unsubscribed`.\n */\nexport function fromCentrifugeSubscriptionError(\n ctx: CentrifugeSubscriptionErrorContext,\n): SdkSubscriptionErrorContext {\n return { channel: ctx.channel, type: ctx.type, error: toRealtimeError(ctx.error, true) };\n}\n"],"mappings":";;AAeA,SAAS,gBAAgB,OAAgB,WAA2B;CAChE,IAAI,iBAAiB,OAAO,OAAO;CACnC,IAAI,OAAO,UAAU,UAAU,OAAO,IAAI,cAAc,OAAO,EAAE,UAAU,CAAC;CAC5E,IAAI,OAAO,UAAU,YAAY,UAAU,MAAM;EAC7C,MAAM,EAAE,MAAM,YAAY;EAC1B,OAAO,IAAI,cACP,OAAO,YAAY,YAAY,UACzB,UACA,uCACN;GAAE,cAAc,OAAO,SAAS,WAAW,OAAO;GAAG;EAAU,CACnE;CACJ;CACA,OAAO,IAAI,cAAc,uCAAuC,EAAE,UAAU,CAAC;AACjF;AAEA,SAAgB,kCACZ,SACA,MACA,OAC2B;CAC3B,OAAO;EAAE;EAAS;EAAM,OAAO,gBAAgB,OAAO,KAAK;CAAE;AACjE;AAEA,SAAgB,+BACZ,SACA,OAC2B;CAC3B,OAAO,kCAAkC,SAAS,uBAAuB,KAAK;AAClF;;;;;AAMA,SAAgB,aACZ,SACA,QACA,SACA,SACI;CACJ,KAAK,MAAM,SAAS,QAChB,IAAI;EACA,QAAQ,KAAK;CACjB,SAAS,OAAO;EACZ,UAAU,+BAA+B,SAAS,KAAK,CAAC;CAC5D;AAER;;;;;;AAOA,SAAgB,gCACZ,KAC2B;CAC3B,OAAO;EAAE,SAAS,IAAI;EAAS,MAAM,IAAI;EAAM,OAAO,gBAAgB,IAAI,OAAO,IAAI;CAAE;AAC3F"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@polyester/sdk",
3
- "version": "0.34.1-devnet-20261106033258",
3
+ "version": "0.35.0-devnet-20261108030630",
4
4
  "private": false,
5
5
  "description": "TypeScript SDK providing access to APIs on Polyester Exchange.",
6
6
  "homepage": "https://github.com/Fabric-Labs/polyester-sdk-typescript#readme",