@polymarket/client 0.9.0 → 0.11.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.
@@ -1,2 +0,0 @@
1
- import {PolymarketError}from'@polymarket/types';var n=class s extends PolymarketError{name="TransportError";constructor(r,t={}){super(r,t);}static fromError(r){return new s(r instanceof Error?r.message:"Request failed",{cause:r})}};var a=class extends PolymarketError{name="TimeoutError";constructor(r,t={}){super(r,t);}},o=class extends PolymarketError{name="TransactionFailedError";constructor(r,t={}){super(r,t);}},i=class s extends PolymarketError{name="CancelledSigningError";constructor(r,t={}){super(r,t);}static fromError(r){return new s(r.message,{cause:r})}};var p=class s extends PolymarketError{name="SigningError";constructor(r,t={}){super(r,t);}static fromError(r,t){let c=t??(r instanceof Error?r.message:"Signing failed");return new s(c,{cause:r})}};export{n as a,a as b,o as c,i as d,p as e};//# sourceMappingURL=chunk-ZH5ERGHG.js.map
2
- //# sourceMappingURL=chunk-ZH5ERGHG.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/errors.ts"],"names":["TransportError","_TransportError","PolymarketError","message","options","error","TimeoutError","TransactionFailedError","CancelledSigningError","_CancelledSigningError","SigningError","_SigningError","msg"],"mappings":"gDAoDO,IAAMA,EAAN,MAAMC,CAAAA,SAAuBC,eAAgB,CACzC,KAAO,gBAAA,CAEhB,WAAA,CAAYC,CAAAA,CAAiBC,CAAAA,CAAwB,EAAC,CAAG,CACvD,KAAA,CAAMD,CAAAA,CAASC,CAAO,EACxB,CAEA,OAAO,SAAA,CAAUC,EAAgC,CAC/C,OAAO,IAAIJ,CAAAA,CACTI,aAAiB,KAAA,CAAQA,CAAAA,CAAM,OAAA,CAAU,gBAAA,CACzC,CACE,KAAA,CAAOA,CACT,CACF,CACF,CACF,EAwKO,IAAMC,CAAAA,CAAN,cAA2BJ,eAAgB,CACvC,IAAA,CAAO,cAAA,CAEhB,YAAYC,CAAAA,CAAiBC,CAAAA,CAAwB,EAAC,CAAG,CACvD,KAAA,CAAMD,CAAAA,CAASC,CAAO,EACxB,CACF,CAAA,CAKaG,CAAAA,CAAN,cAAqCL,eAAgB,CACjD,IAAA,CAAO,wBAAA,CAEhB,WAAA,CAAYC,CAAAA,CAAiBC,EAAwB,EAAC,CAAG,CACvD,KAAA,CAAMD,EAASC,CAAO,EACxB,CACF,CAAA,CAKaI,CAAAA,CAAN,MAAMC,CAAAA,SAA8BP,eAAgB,CAChD,IAAA,CAAO,uBAAA,CAEhB,WAAA,CAAYC,CAAAA,CAAiBC,EAAwB,EAAC,CAAG,CACvD,KAAA,CAAMD,EAASC,CAAO,EACxB,CAEA,OAAO,UAAUC,CAAAA,CAAqC,CACpD,OAAO,IAAII,EAAsBJ,CAAAA,CAAM,OAAA,CAAS,CAC9C,KAAA,CAAOA,CACT,CAAC,CACH,CACF,MAkCaK,CAAAA,CAAN,MAAMC,CAAAA,SAAqBT,eAAgB,CACvC,IAAA,CAAO,cAAA,CAEhB,WAAA,CAAYC,CAAAA,CAAiBC,EAAwB,EAAC,CAAG,CACvD,KAAA,CAAMD,EAASC,CAAO,EACxB,CAEA,OAAO,UAAUC,CAAAA,CAAgBF,CAAAA,CAAgC,CAC/D,IAAMS,EACJT,CAAAA,GAAYE,CAAAA,YAAiB,KAAA,CAAQA,CAAAA,CAAM,QAAU,gBAAA,CAAA,CACvD,OAAO,IAAIM,CAAAA,CAAaC,EAAK,CAAE,KAAA,CAAOP,CAAM,CAAC,CAC/C,CACF","file":"chunk-ZH5ERGHG.js","sourcesContent":["import { PolymarketError } from '@polymarket/types';\nimport type { ZodError } from 'zod';\nimport type { RateLimitUpdate } from './rate-limit';\nimport {\n formatInputZodError,\n formatResponseZodError,\n type ResponseValidationContext,\n} from './validation';\n\n/**\n * Error thrown when an action input fails SDK validation before a request is\n * sent.\n */\nexport class UserInputError extends PolymarketError {\n override name = 'UserInputError' as const;\n\n constructor(message: string, options: ErrorOptions = {}) {\n super(message, options);\n }\n\n static fromZodError(error: ZodError): UserInputError {\n return new UserInputError(formatInputZodError(error), {\n cause: error,\n });\n }\n}\n\n/**\n * Error thrown when a service response does not match the action's expected\n * response shape.\n */\nexport class UnexpectedResponseError extends PolymarketError {\n override name = 'UnexpectedResponseError' as const;\n\n constructor(message: string, options: ErrorOptions = {}) {\n super(message, options);\n }\n\n static fromZodError(\n error: ZodError,\n context: ResponseValidationContext,\n ): UnexpectedResponseError {\n return new UnexpectedResponseError(formatResponseZodError(error, context), {\n cause: error,\n });\n }\n}\n\n/**\n * Error thrown when the SDK cannot complete a request because of a network or\n * runtime transport failure.\n */\nexport class TransportError extends PolymarketError {\n override name = 'TransportError' as const;\n\n constructor(message: string, options: ErrorOptions = {}) {\n super(message, options);\n }\n\n static fromError(error: unknown): TransportError {\n return new TransportError(\n error instanceof Error ? error.message : 'Request failed',\n {\n cause: error,\n },\n );\n }\n}\n\n/**\n * WebSocket close codes defined by RFC 6455 and the IANA WebSocket Close Code\n * Number registry. Codes 4000-4999 are reserved for application use and are\n * intentionally not modeled here.\n */\nexport enum WebSocketKnownCloseCode {\n NormalClosure = 1000,\n GoingAway = 1001,\n ProtocolError = 1002,\n UnsupportedData = 1003,\n /** Synthesized locally when the peer closed without a status code. */\n NoStatusReceived = 1005,\n /** Synthesized locally when the connection dropped without a close frame. */\n AbnormalClosure = 1006,\n InvalidFramePayload = 1007,\n PolicyViolation = 1008,\n MessageTooBig = 1009,\n InternalError = 1011,\n ServiceRestart = 1012,\n TryAgainLater = 1013,\n}\n\n/**\n * A WebSocket close code. Codes enumerated in\n * {@link WebSocketKnownCloseCode} are defined by RFC 6455; other values, such\n * as application-defined 4000-4999 codes, flow through as plain numbers.\n */\nexport type WebSocketCloseCode = WebSocketKnownCloseCode | (number & {});\n\nexport type ConnectionLostErrorOptions = {\n /** WebSocket close code reported for the lost connection. */\n code: WebSocketCloseCode;\n /** Close reason provided by the peer. Empty when none was sent. */\n reason: string;\n};\n\n/**\n * Error thrown when a live connection ends without the SDK requesting it.\n */\nexport class ConnectionLostError extends PolymarketError {\n override name = 'ConnectionLostError' as const;\n\n readonly code: WebSocketCloseCode;\n readonly reason: string;\n\n constructor(\n message: string,\n options: ErrorOptions & ConnectionLostErrorOptions,\n ) {\n super(message, options);\n this.code = options.code;\n this.reason = options.reason;\n }\n}\n\n/**\n * Trading restriction reported by the venue while orders cannot be placed\n * normally. The SDK does not retry automatically; callers decide how to\n * react, honoring {@link RequestRejectedError.retryAfter} when provided.\n */\nexport enum TradingRestriction {\n /** The matching engine is restarting and rejects order requests until it is back. */\n RESTARTING = 'restarting',\n /** Cancels and post-only orders are accepted; other orders are rejected. */\n POST_ONLY = 'post_only',\n}\n\nexport type RequestRejectedErrorOptions = {\n status: number;\n /**\n * Machine-readable error code from the response body, when the service\n * provided one.\n */\n code?: string;\n /**\n * Server-requested delay in seconds before retrying, when the response\n * provided one.\n */\n retryAfter?: number;\n /**\n * Trading restriction that caused the rejection, when the response\n * identified one.\n */\n restriction?: TradingRestriction;\n};\n\n/**\n * Error thrown when a service responds with a non-success status other than\n * rate limiting.\n */\nexport class RequestRejectedError extends PolymarketError {\n override name = 'RequestRejectedError' as const;\n\n readonly status: number;\n /**\n * Machine-readable error code from the response body, when the service\n * provided one.\n */\n readonly code?: string;\n /**\n * Server-requested delay in seconds before retrying, when the response\n * provided one.\n */\n readonly retryAfter?: number;\n /**\n * Trading restriction that caused the rejection, when the response\n * identified one.\n */\n readonly restriction?: TradingRestriction;\n\n constructor(\n message: string,\n options: ErrorOptions & RequestRejectedErrorOptions,\n ) {\n super(message, options);\n this.status = options.status;\n this.code = options.code;\n this.retryAfter = options.retryAfter;\n this.restriction = options.restriction;\n }\n}\n\nexport type RateLimitErrorOptions = {\n /**\n * Server-requested delay in seconds before retrying, when the response\n * provided one.\n */\n retryAfter?: number;\n /**\n * Rate-limit state reported with the rejection, when the response provided\n * it.\n */\n rateLimit?: RateLimitUpdate;\n};\n\n/**\n * Error thrown when the service rejects a request because the rate limit has\n * been exceeded.\n */\nexport class RateLimitError extends PolymarketError {\n override name = 'RateLimitError' as const;\n\n /**\n * Server-requested delay in seconds before retrying, when the response\n * provided one.\n */\n readonly retryAfter?: number;\n /**\n * Rate-limit state reported with the rejection, when the response provided\n * it.\n */\n readonly rateLimit?: RateLimitUpdate;\n\n constructor(\n message: string,\n options: ErrorOptions & RateLimitErrorOptions = {},\n ) {\n super(message, options);\n this.retryAfter = options.retryAfter;\n this.rateLimit = options.rateLimit;\n }\n}\n\n/**\n * Error thrown when an async wait operation exceeds its allotted polling time.\n */\nexport class TimeoutError extends PolymarketError {\n override name = 'TimeoutError' as const;\n\n constructor(message: string, options: ErrorOptions = {}) {\n super(message, options);\n }\n}\n\n/**\n * Error thrown when a submitted transaction reaches a terminal failure state.\n */\nexport class TransactionFailedError extends PolymarketError {\n override name = 'TransactionFailedError' as const;\n\n constructor(message: string, options: ErrorOptions = {}) {\n super(message, options);\n }\n}\n\n/**\n * Error thrown when the user cancels a required wallet signing action.\n */\nexport class CancelledSigningError extends PolymarketError {\n override name = 'CancelledSigningError' as const;\n\n constructor(message: string, options: ErrorOptions = {}) {\n super(message, options);\n }\n\n static fromError(error: Error): CancelledSigningError {\n return new CancelledSigningError(error.message, {\n cause: error,\n });\n }\n}\n\n/**\n * Error thrown when there is not enough resting market liquidity to satisfy the\n * requested execution semantics.\n */\nexport class InsufficientLiquidityError extends PolymarketError {\n override name = 'InsufficientLiquidityError' as const;\n\n constructor(message: string, options: ErrorOptions = {}) {\n super(message, options);\n }\n}\n\n/**\n * Error thrown when arming auto-cancel is rejected because the account has\n * reached its daily auto-cancel trigger limit. Arming is rejected until the\n * daily counter resets at the next UTC midnight; clearing an existing\n * schedule is always allowed.\n *\n * @experimental This API may change in a breaking way in any release, including patch releases.\n */\nexport class AutoCancelDailyLimitError extends PolymarketError {\n override name = 'AutoCancelDailyLimitError' as const;\n\n constructor(message: string, options: ErrorOptions = {}) {\n super(message, options);\n }\n}\n\n/**\n * Error thrown when the SDK cannot produce a required signature or\n * authentication payload.\n */\nexport class SigningError extends PolymarketError {\n override name = 'SigningError' as const;\n\n constructor(message: string, options: ErrorOptions = {}) {\n super(message, options);\n }\n\n static fromError(error: unknown, message?: string): SigningError {\n const msg =\n message ?? (error instanceof Error ? error.message : 'Signing failed');\n return new SigningError(msg, { cause: error });\n }\n}\n\nexport function makeErrorGuard<\n // biome-ignore lint/suspicious/noExplicitAny: constructor rest args require any[]\n TClasses extends ReadonlyArray<new (...args: any[]) => unknown>,\n>(\n ...classes: TClasses\n): { isError(error: unknown): error is InstanceType<TClasses[number]> } {\n return {\n isError(error: unknown): error is InstanceType<TClasses[number]> {\n return classes.some((c) => error instanceof c);\n },\n };\n}\n"]}