@cesto/sdk 0.0.1

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.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/core/errors.ts","../src/core/options.ts","../src/core/version.ts","../src/core/request.ts","../src/resources/resource.ts","../src/resources/positions.ts","../src/resources/products.ts","../src/client.ts","../src/types/products.ts"],"names":[],"mappings":";;;AAUO,IAAM,UAAA,GAAN,cAAyB,KAAA,CAAM;AAAA,EACpC,YAAY,OAAA,EAAiB;AAC3B,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,OAAO,GAAA,CAAA,MAAA,CAAW,IAAA;AAEvB,IAAA,MAAA,CAAO,cAAA,CAAe,IAAA,EAAM,GAAA,CAAA,MAAA,CAAW,SAAS,CAAA;AAAA,EAClD;AACF;AAWO,IAAM,QAAA,GAAN,cAAuB,UAAA,CAAW;AAAA;AAAA,EAE9B,MAAA;AAAA;AAAA,EAEA,IAAA;AAAA;AAAA,EAEA,SAAA;AAAA;AAAA,EAEA,OAAA;AAAA;AAAA,EAEA,OAAA;AAAA,EAET,WAAA,CACE,MAAA,EACA,OAAA,EACA,IAAA,GAAoF,EAAC,EACrF;AACA,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,MAAA,GAAS,MAAA;AACd,IAAA,IAAA,CAAK,OAAO,IAAA,CAAK,IAAA;AACjB,IAAA,IAAA,CAAK,YAAY,IAAA,CAAK,SAAA;AACtB,IAAA,IAAA,CAAK,UAAU,IAAA,CAAK,OAAA;AACpB,IAAA,IAAA,CAAK,UAAU,IAAA,CAAK,OAAA;AAAA,EACtB;AACF;AAEO,IAAM,eAAA,GAAN,cAA8B,QAAA,CAAS;AAAC;AACxC,IAAM,mBAAA,GAAN,cAAkC,QAAA,CAAS;AAAC;AAC5C,IAAM,qBAAA,GAAN,cAAoC,QAAA,CAAS;AAAC;AAC9C,IAAM,aAAA,GAAN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,EAC7B,OAAgB,QAAA,GAAW,QAAA;AAAA,EAC3B,OAAgB,eAAA,GAAkB,eAAA;AAAA,EAClC,OAAgB,mBAAA,GAAsB,mBAAA;AAAA,EACtC,OAAgB,qBAAA,GAAwB,qBAAA;AAAA,EACxC,OAAgB,aAAA,GAAgB,aAAA;AAAA,EAChC,OAAgB,aAAA,GAAgB,aAAA;AAAA,EAChC,OAAgB,wBAAA,GAA2B,wBAAA;AAAA,EAC3C,OAAgB,cAAA,GAAiB,cAAA;AAAA,EACjC,OAAgB,mBAAA,GAAsB,mBAAA;AAAA,EACtC,OAAgB,kBAAA,GAAqB,kBAAA;AAAA,EACrC,OAAgB,yBAAA,GAA4B,yBAAA;AAAA,EAC5C,OAAgB,iBAAA,GAAoB,iBAAA;AACtC;;;ACsJO,SAAS,wBACd,KAAA,EACgC;AAChC,EAAA,OAAQ,MAAgC,gBAAA,KAAqB,IAAA;AAC/D","file":"index.cjs","sourcesContent":["/**\n * Error hierarchy thrown by the SDK.\n *\n * Everything extends {@link CestoError}. Server (non-2xx) responses become an\n * {@link APIError} subclass built from the API's `{ code, message, details,\n * requestId }` envelope; transport problems become {@link APIConnectionError}\n * (or its timeout subclass); caller cancellation becomes {@link APIUserAbortError}.\n */\n\n/** Base class for every error the SDK throws. */\nexport class CestoError extends Error {\n constructor(message: string) {\n super(message);\n this.name = new.target.name;\n // Restore the prototype chain for `instanceof` across the transpile target.\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\n/** Parsed `{ code, message, details, requestId }` envelope from the API. */\nexport interface APIErrorEnvelope {\n code?: string;\n message?: string;\n details?: unknown;\n requestId?: string;\n}\n\n/** A non-2xx HTTP response. */\nexport class APIError extends CestoError {\n /** HTTP status code. */\n readonly status: number;\n /** Machine-readable error code from the API envelope (e.g. `RESOURCE_NOT_FOUND`). */\n readonly code?: string;\n /** Correlation id from the API envelope, useful when reporting issues. */\n readonly requestId?: string;\n /** Structured error details from the API envelope. */\n readonly details?: unknown;\n /** Response headers. */\n readonly headers?: Headers;\n\n constructor(\n status: number,\n message: string,\n opts: { code?: string; requestId?: string; details?: unknown; headers?: Headers } = {},\n ) {\n super(message);\n this.status = status;\n this.code = opts.code;\n this.requestId = opts.requestId;\n this.details = opts.details;\n this.headers = opts.headers;\n }\n}\n\nexport class BadRequestError extends APIError {}\nexport class AuthenticationError extends APIError {}\nexport class PermissionDeniedError extends APIError {}\nexport class NotFoundError extends APIError {}\nexport class ConflictError extends APIError {}\nexport class UnprocessableEntityError extends APIError {}\n\n/** HTTP 429. Carries `retryAfter` (ms) when the server sent a `Retry-After` header. */\nexport class RateLimitError extends APIError {\n /** Milliseconds to wait before retrying, derived from `Retry-After`. */\n readonly retryAfter?: number;\n\n constructor(\n status: number,\n message: string,\n opts: {\n code?: string;\n requestId?: string;\n details?: unknown;\n headers?: Headers;\n retryAfter?: number;\n } = {},\n ) {\n super(status, message, opts);\n this.retryAfter = opts.retryAfter;\n }\n}\n\nexport class InternalServerError extends APIError {}\n\n/** A network-level failure (DNS, connection reset, fetch threw). */\nexport class APIConnectionError extends CestoError {\n readonly cause?: unknown;\n constructor(message = 'Connection error', opts: { cause?: unknown } = {}) {\n super(message);\n this.cause = opts.cause;\n }\n}\n\n/** The request exceeded the configured timeout. */\nexport class APIConnectionTimeoutError extends APIConnectionError {\n constructor(message = 'Request timed out') {\n super(message);\n }\n}\n\n/** The caller's `AbortSignal` fired. */\nexport class APIUserAbortError extends CestoError {\n constructor(message = 'Request was aborted') {\n super(message);\n }\n}\n\n/** Build the right {@link APIError} subclass from a parsed error response. */\nexport function makeAPIError(\n status: number,\n envelope: APIErrorEnvelope,\n headers: Headers,\n retryAfter?: number,\n): APIError {\n const message = envelope.message || `HTTP ${status}`;\n const opts = {\n code: envelope.code,\n requestId: envelope.requestId,\n details: envelope.details,\n headers,\n };\n\n switch (status) {\n case 400:\n return new BadRequestError(status, message, opts);\n case 401:\n return new AuthenticationError(status, message, opts);\n case 403:\n return new PermissionDeniedError(status, message, opts);\n case 404:\n return new NotFoundError(status, message, opts);\n case 409:\n return new ConflictError(status, message, opts);\n case 422:\n return new UnprocessableEntityError(status, message, opts);\n case 429:\n return new RateLimitError(status, message, { ...opts, retryAfter });\n default:\n if (status >= 500) return new InternalServerError(status, message, opts);\n return new APIError(status, message, opts);\n }\n}\n","import { CestoError } from './errors.js';\n\nconst PROD_BASE_URL = 'https://backend.cesto.co';\nconst BETA_BASE_URL = 'https://dev.backend.cesto.co';\nconst DEFAULT_TIMEOUT_MS = 60_000;\nconst DEFAULT_MAX_RETRIES = 2;\n\n/** Which deployed Cesto backend to target. */\nexport type CestoEnvironment = 'PRODUCTION' | 'BETA';\n\n/** Options for constructing a {@link Cesto} client. */\nexport interface ClientOptions {\n /**\n * Secret API key (`cesto_sk_…`). Required — the constructor throws if omitted.\n * Read it from your environment yourself, e.g. `apiKey: process.env.CESTO_API_KEY`.\n */\n apiKey?: string;\n /**\n * Which backend to target in a deployed build (`NODE_ENV=production`):\n * `PRODUCTION` → backend.cesto.co, `BETA` → dev.backend.cesto.co. Default `PRODUCTION`.\n */\n environment?: CestoEnvironment;\n /** Per-request timeout in milliseconds. Default `60000`. */\n timeout?: number;\n /** Max automatic retries on transient failures. Default `2`. */\n maxRetries?: number;\n /** Custom fetch implementation (e.g. undici, a test mock). Default `globalThis.fetch`. */\n fetch?: typeof fetch;\n}\n\n/** Per-request overrides accepted by every resource method. */\nexport interface RequestOptions {\n /** Override the client timeout (ms) for this request. */\n timeout?: number;\n /** Override the client retry count for this request (e.g. `0` to disable). */\n maxRetries?: number;\n /** Caller cancellation; composed with the internal timeout signal. */\n signal?: AbortSignal;\n}\n\n/** Fully-resolved, validated client configuration. */\nexport interface ResolvedOptions {\n apiKey: string;\n /** Normalized base URL, no trailing slash. */\n baseURL: string;\n timeout: number;\n maxRetries: number;\n fetch: typeof fetch;\n}\n\nfunction isBrowser(): boolean {\n return typeof window !== 'undefined' && typeof window.document !== 'undefined';\n}\n\n/** Resolve the backend URL as per `environment`. */\nfunction resolveBaseURL(environment: CestoEnvironment): string {\n return environment === 'BETA' ? BETA_BASE_URL : PROD_BASE_URL;\n}\n\n/** Validate and normalize {@link ClientOptions} into {@link ResolvedOptions}. */\nexport function resolveOptions(options: ClientOptions): ResolvedOptions {\n if (isBrowser()) {\n throw new CestoError(\n 'The Cesto SDK is server-side only. It must not run in a browser — a secret key ' +\n '(cesto_sk_…) would be exposed to end users.',\n );\n }\n\n const apiKey = options.apiKey\n if (!apiKey) {\n throw new CestoError('Missing API key. Pass { apiKey } when constructing the client.');\n }\n\n const fetchImpl = options.fetch ?? globalThis.fetch;\n if (typeof fetchImpl !== 'function') {\n throw new CestoError(\n 'No fetch implementation found. Use Node 18+ or pass a custom { fetch } in ClientOptions.',\n );\n }\n\n const timeout = options.timeout ?? DEFAULT_TIMEOUT_MS;\n if (!Number.isFinite(timeout) || timeout < 0) {\n throw new CestoError('`timeout` must be a finite number >= 0.');\n }\n\n const maxRetries = options.maxRetries ?? DEFAULT_MAX_RETRIES;\n if (!Number.isInteger(maxRetries) || maxRetries < 0) {\n throw new CestoError('`maxRetries` must be an integer >= 0.');\n }\n\n const environment = options.environment ?? 'PRODUCTION';\n if (environment !== 'PRODUCTION' && environment !== 'BETA') {\n throw new CestoError(`Invalid environment: ${environment}. Use 'PRODUCTION' or 'BETA'.`);\n }\n\n return {\n apiKey,\n baseURL: resolveBaseURL(environment),\n timeout,\n maxRetries,\n fetch: options.fetch ?? fetchImpl.bind(globalThis),\n };\n}\n","/** SDK version. Keep in sync with package.json `version`. */\nexport const VERSION = '0.0.1';\n","import {\n APIConnectionError,\n APIConnectionTimeoutError,\n type APIError,\n type APIErrorEnvelope,\n APIUserAbortError,\n CestoError,\n makeAPIError,\n} from './errors.js';\nimport type { RequestOptions, ResolvedOptions } from './options.js';\nimport { VERSION } from './version.js';\n\n/** Query parameters; `undefined`/`null` values are skipped. */\nexport type QueryParams = Record<string, string | number | boolean | undefined | null>;\n\ninterface GetOptions extends RequestOptions {\n query?: QueryParams;\n}\n\nconst RETRY_BASE_MS = 500;\nconst RETRY_CAP_MS = 8_000;\n\n/** Internal transport: builds requests, applies auth, retries, and parses JSON. */\nexport class APIClientCore {\n constructor(private readonly opts: ResolvedOptions) {}\n\n get<T>(path: string, options: GetOptions = {}): Promise<T> {\n return this.request<T>('GET', path, options);\n }\n\n private async request<T>(method: string, path: string, options: GetOptions): Promise<T> {\n const url = this.buildURL(path, options.query);\n const timeout = options.timeout ?? this.opts.timeout;\n const maxRetries = options.maxRetries ?? this.opts.maxRetries;\n\n let attempt = 0;\n // Loop: returns on success/non-retryable error, retries transient failures.\n for (;;) {\n const timer = withTimeout(options.signal, timeout);\n let response: Response;\n\n try {\n response = await this.opts.fetch(url, {\n method,\n headers: buildHeaders(this.opts.apiKey, attempt),\n signal: timer.signal,\n });\n } catch (err) {\n timer.cleanup();\n const mapped = mapFetchError(err, timer, options.signal);\n // Never retry a user abort.\n if (mapped instanceof APIUserAbortError) throw mapped;\n if (attempt < maxRetries) {\n attempt += 1;\n await sleep(backoff(attempt));\n continue;\n }\n throw mapped;\n }\n\n timer.cleanup();\n\n if (response.ok) {\n return parseJSON<T>(response);\n }\n\n if (shouldRetryStatus(response.status) && attempt < maxRetries) {\n attempt += 1;\n await sleep(parseRetryAfter(response.headers) ?? backoff(attempt));\n continue;\n }\n\n throw await errorFromResponse(response);\n }\n }\n\n private buildURL(path: string, query?: QueryParams): string {\n const url = new URL(`${this.opts.baseURL}${path}`);\n if (query) {\n for (const [key, value] of Object.entries(query)) {\n if (value !== undefined && value !== null) url.searchParams.set(key, String(value));\n }\n }\n return url.toString();\n }\n}\n\nfunction buildHeaders(apiKey: string, attempt: number): Record<string, string> {\n const headers: Record<string, string> = {\n 'X-API-Key': apiKey,\n Accept: 'application/json',\n };\n const ua = userAgent();\n if (ua) headers['User-Agent'] = ua;\n if (attempt > 0) headers['x-cesto-retry-count'] = String(attempt);\n return headers;\n}\n\nfunction userAgent(): string {\n if (typeof process !== 'undefined' && process.versions?.node) {\n return `cesto-sdk/${VERSION} (node/${process.versions.node})`;\n }\n return `cesto-sdk/${VERSION}`;\n}\n\n/** AbortController that fires on either the caller's signal or the timeout. */\nfunction withTimeout(userSignal: AbortSignal | undefined, timeoutMs: number) {\n const controller = new AbortController();\n let timedOut = false;\n\n const timer = setTimeout(() => {\n timedOut = true;\n controller.abort(new Error('timeout'));\n }, timeoutMs);\n\n const onUserAbort = () => controller.abort(userSignal?.reason);\n if (userSignal) {\n if (userSignal.aborted) controller.abort(userSignal.reason);\n else userSignal.addEventListener('abort', onUserAbort, { once: true });\n }\n\n return {\n signal: controller.signal,\n didTimeout: () => timedOut,\n cleanup: () => {\n clearTimeout(timer);\n userSignal?.removeEventListener('abort', onUserAbort);\n },\n };\n}\n\nfunction mapFetchError(\n err: unknown,\n timer: { didTimeout: () => boolean },\n userSignal: AbortSignal | undefined,\n): CestoError {\n if (userSignal?.aborted) return new APIUserAbortError();\n if (timer.didTimeout()) return new APIConnectionTimeoutError();\n return new APIConnectionError('Connection error', { cause: err });\n}\n\nfunction shouldRetryStatus(status: number): boolean {\n return status === 408 || status === 409 || status === 429 || status >= 500;\n}\n\nasync function parseJSON<T>(response: Response): Promise<T> {\n const text = await response.text();\n if (!text) return undefined as T;\n try {\n return JSON.parse(text) as T;\n } catch {\n throw new CestoError('Failed to parse response body as JSON.');\n }\n}\n\nasync function errorFromResponse(response: Response): Promise<APIError> {\n let envelope: APIErrorEnvelope = {};\n try {\n const text = await response.text();\n if (text) {\n const parsed = JSON.parse(text) as unknown;\n if (parsed && typeof parsed === 'object') envelope = parsed as APIErrorEnvelope;\n }\n } catch {\n // Non-JSON error body — fall back to status-only error.\n }\n return makeAPIError(\n response.status,\n envelope,\n response.headers,\n parseRetryAfter(response.headers),\n );\n}\n\n/** Parse a `Retry-After` header (delta-seconds or HTTP-date) into milliseconds. */\nfunction parseRetryAfter(headers: Headers): number | undefined {\n const value = headers.get('retry-after');\n if (!value) return undefined;\n const seconds = Number(value);\n if (!Number.isNaN(seconds)) return Math.max(0, seconds * 1000);\n const dateMs = Date.parse(value);\n if (!Number.isNaN(dateMs)) return Math.max(0, dateMs - Date.now());\n return undefined;\n}\n\n/** Exponential backoff with full jitter, capped. */\nfunction backoff(attempt: number): number {\n const ceiling = Math.min(RETRY_CAP_MS, RETRY_BASE_MS * 2 ** (attempt - 1));\n return Math.random() * ceiling;\n}\n\nfunction sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n","import type { APIClientCore } from '../core/request.js';\n\n/** Base class for resource groups; holds a reference to the transport. */\nexport abstract class APIResource {\n constructor(protected readonly client: APIClientCore) {}\n}\n","import { CestoError } from '../core/errors.js';\nimport type { RequestOptions } from '../core/options.js';\nimport type { PositionsResult } from '../types/positions.js';\nimport { APIResource } from './resource.js';\n\nexport interface PositionsListParams {\n /** External Solana wallet address (Phantom/Solflare). Required. */\n wallet: string;\n}\n\nexport class Positions extends APIResource {\n /**\n * List a user's open/closing positions, resolved from their external Solana\n * wallet. A wallet with no Cesto account returns an empty result (not an error).\n */\n list(params: PositionsListParams, options?: RequestOptions): Promise<PositionsResult> {\n if (!params?.wallet) throw new CestoError('wallet is required');\n return this.client.get<PositionsResult>('/positions/by-wallet', {\n query: { wallet: params.wallet },\n ...options,\n });\n }\n}\n","import type { RequestOptions } from '../core/options.js';\nimport type {\n ProductBacktest,\n ProductBacktestChart,\n ProductListItem,\n ProductVersionResponse,\n ProductWithBacktest,\n ProductWithBacktestChart,\n} from '../types/products.js';\nimport type { ChartTimeRange } from '../types/shared.js';\nimport { APIResource } from './resource.js';\n\nexport interface ProductListParams {\n /** Filter by category. */\n category?: string;\n /**\n * Also fetch backtested performance (`GET /products/analytics`) and merge it\n * onto each product as `backtest`. Fails gracefully → `backtest: null`.\n */\n includeBacktest?: boolean;\n}\n\nexport interface ProductGetParams {\n /**\n * Also fetch the product's backtested value chart and attach it as `backtestChart`.\n * Fails gracefully → `backtestChart: null`.\n */\n includeBacktestChart?: boolean;\n /** Chart window when `includeBacktestChart` is true. Default `'1y'`. */\n chartTimeRange?: ChartTimeRange;\n}\n\nconst DEFAULT_CHART_TIME_RANGE: ChartTimeRange = '1y';\n\nexport class Products extends APIResource {\n /** List products. */\n list(): Promise<ProductListItem[]>;\n list(\n params: ProductListParams & { includeBacktest?: false },\n options?: RequestOptions,\n ): Promise<ProductListItem[]>;\n list(\n params: ProductListParams & { includeBacktest: true },\n options?: RequestOptions,\n ): Promise<ProductWithBacktest[]>;\n async list(\n params: ProductListParams = {},\n options?: RequestOptions,\n ): Promise<ProductListItem[] | ProductWithBacktest[]> {\n const query = params.category ? { category: params.category } : undefined;\n\n if (!params.includeBacktest) {\n return this.client.get<ProductListItem[]>('/products', { query, ...options });\n }\n\n const [items, backtests] = await Promise.all([\n this.client.get<ProductListItem[]>('/products', { query, ...options }),\n this.client\n .get<Record<string, ProductBacktest>>('/products/analytics', { query, ...options })\n // Graceful: a failed/slow analytics fetch never breaks the list.\n .catch(() => ({}) as Record<string, ProductBacktest>),\n ]);\n\n return items.map((item) => ({ ...item, backtest: backtests[item.id] ?? null }));\n }\n\n /** Get a product by slug. */\n get(slug: string): Promise<ProductVersionResponse>;\n get(\n slug: string,\n params: ProductGetParams & { includeBacktestChart?: false },\n options?: RequestOptions,\n ): Promise<ProductVersionResponse>;\n get(\n slug: string,\n params: ProductGetParams & { includeBacktestChart: true },\n options?: RequestOptions,\n ): Promise<ProductWithBacktestChart>;\n async get(\n slug: string,\n params: ProductGetParams = {},\n options?: RequestOptions,\n ): Promise<ProductVersionResponse | ProductWithBacktestChart> {\n const product = await this.client.get<ProductVersionResponse>(\n `/products/${encodeURIComponent(slug)}`,\n options,\n );\n\n if (!params.includeBacktestChart) return product;\n\n // Sequential: the chart is keyed by productId, which we only have after the\n // detail fetch resolves the slug. Graceful: a chart failure → null.\n const backtestChart = await this.client\n .get<ProductBacktestChart>(`/products/${encodeURIComponent(product.id)}/graph`, {\n query: { timeRange: params.chartTimeRange ?? DEFAULT_CHART_TIME_RANGE },\n ...options,\n })\n .catch(() => null);\n\n return { ...product, backtestChart };\n }\n}\n","import {\n APIConnectionError,\n APIConnectionTimeoutError,\n APIError,\n APIUserAbortError,\n AuthenticationError,\n BadRequestError,\n CestoError,\n ConflictError,\n InternalServerError,\n NotFoundError,\n PermissionDeniedError,\n RateLimitError,\n UnprocessableEntityError,\n} from './core/errors.js';\nimport { type ClientOptions, resolveOptions } from './core/options.js';\nimport { APIClientCore } from './core/request.js';\nimport { Positions } from './resources/positions.js';\nimport { Products } from './resources/products.js';\n\n/**\n * The Cesto SDK client.\n *\n * @example\n * ```ts\n * const cesto = new Cesto({ apiKey: process.env.CESTO_API_KEY! });\n * const products = await cesto.products.list({ includeBacktest: true });\n * ```\n */\nexport class Cesto {\n readonly products: Products;\n readonly positions: Positions;\n private readonly core: APIClientCore;\n\n constructor(options: ClientOptions = {}) {\n this.core = new APIClientCore(resolveOptions(options));\n this.products = new Products(this.core);\n this.positions = new Positions(this.core);\n }\n\n // Error classes re-exposed for ergonomic `instanceof` checks:\n // catch (e) { if (e instanceof Cesto.NotFoundError) … }\n static readonly CestoError = CestoError;\n static readonly APIError = APIError;\n static readonly BadRequestError = BadRequestError;\n static readonly AuthenticationError = AuthenticationError;\n static readonly PermissionDeniedError = PermissionDeniedError;\n static readonly NotFoundError = NotFoundError;\n static readonly ConflictError = ConflictError;\n static readonly UnprocessableEntityError = UnprocessableEntityError;\n static readonly RateLimitError = RateLimitError;\n static readonly InternalServerError = InternalServerError;\n static readonly APIConnectionError = APIConnectionError;\n static readonly APIConnectionTimeoutError = APIConnectionTimeoutError;\n static readonly APIUserAbortError = APIUserAbortError;\n}\n","import type {\n ChartTimeRange,\n GeoStatus,\n IncentiveOverlayCampaign,\n PredictionMarketState,\n TokenPerformance,\n} from './shared.js';\n\n/** An item in `products.list()` — `GET /products`. */\nexport interface ProductListItem {\n id: string;\n slug: string;\n name: string;\n description: string | null;\n logoUrl: string | null;\n category: string | null;\n tags: string[];\n isActive: boolean;\n isPublished: boolean;\n pointMultiplier: number;\n metadata: Record<string, unknown> | null;\n geoStatus: GeoStatus;\n /** Active incentive campaigns; `[]` when none. */\n incentives: IncentiveOverlayCampaign[];\n}\n\n/** Backtested performance for a product — `GET /products/analytics` (per product). */\nexport interface ProductBacktest {\n protocolsInvolved: string[];\n tokensInvolved: string[];\n tokenPerformance: TokenPerformance | null;\n tokenPerformance7d: TokenPerformance | null;\n tokenPerformance30d: TokenPerformance | null;\n priceChange24h: number | null;\n tokenPriceChanges: Record<\n string,\n { priceChange24h: number | null; priceChange24hPercent: number | null }\n >;\n}\n\n/** `products.list({ includeBacktest: true })` — list item with backtest merged in. */\nexport type ProductWithBacktest = ProductListItem & {\n backtest: ProductBacktest | null;\n};\n\nexport interface ProductCreator {\n id: string;\n username: string | null;\n email: string | null;\n solanaWalletAddress: string | null;\n embeddedWalletAddress: string | null;\n}\n\nexport interface OndoTradingStatus {\n allTradable: boolean;\n currentSession: string;\n hasOndoTokens: boolean;\n tokens: unknown[];\n untradableTokens: unknown[];\n nextFullyTradableAt: string | null;\n nextFullyTradableSession: string | null;\n}\n\n/** Full product detail — `GET /products/:slug`. */\nexport interface ProductVersionResponse {\n id: string;\n versionId: string;\n version: number;\n changelog: string | null;\n minimumInvestment: string;\n inputTokenMint: string;\n inputTokenDecimals: number;\n about: string | null;\n riskNotes: string | null;\n resources: string | null;\n name: string;\n slug: string;\n description: string | null;\n logoUrl: string | null;\n category: string | null;\n tags: string[];\n isActive: boolean;\n isPublished: boolean;\n metadata: Record<string, unknown> | null;\n pointMultiplier: number;\n createdBy: string;\n creator: ProductCreator | null;\n tokensInvolved: string[];\n protocolsInvolved: string[];\n tokenPerformance: TokenPerformance | null;\n tokenPerformance7d: TokenPerformance | null;\n tokenPerformance30d: TokenPerformance | null;\n predictionMarkets?: PredictionMarketState[];\n canInvest: boolean;\n /** Raw workflow definition. */\n definition: unknown;\n geoStatus: GeoStatus;\n ondoTradingStatus: OndoTradingStatus;\n incentives?: IncentiveOverlayCampaign[];\n}\n\nexport interface BacktestChartTimeSeriesPoint {\n timestamp: string;\n portfolioValue: number;\n sp500Value?: number;\n mag7Value?: number;\n btcValue?: number;\n solValue?: number;\n usdcValue?: number;\n isLiquidated?: boolean;\n liquidationThreshold?: number;\n}\n\nexport interface BacktestChartMetrics {\n totalReturn: number;\n cagr: number;\n volatility: number;\n maxDrawdown: number;\n sharpe: number;\n}\n\nexport interface PredictionMarketEvent {\n ticker: string;\n marketTicker: string;\n seriesTicker: string;\n title: string;\n closeTime: number;\n currentProbability?: number;\n currentPrice: number;\n daysToClose: number;\n timeSeries: Array<{\n market_ticker: string;\n event_ticker: string;\n raw_numerical_forecast: number;\n numerical_forecast: number;\n formatted_forecast: string;\n end_period_ts: number;\n period_interval: number;\n }>;\n}\n\n/** Token-portfolio backtest chart — `GET /products/:id/graph` (non-prediction). */\nexport interface BacktestChart {\n workflowId: string;\n name: string;\n timeRange?: ChartTimeRange;\n timeSeries: BacktestChartTimeSeriesPoint[];\n /** Computed only when `timeRange === '1y'`; null otherwise. */\n metrics: BacktestChartMetrics | null;\n assetPerformance: Array<{ token: string; mint: string; returnPct: number }>;\n contributions: Array<{ token: string; mint: string; contribution: number }>;\n assetSparklines: Array<{\n token: string;\n mint: string;\n points: Array<{ timestamp: string; value: number; price: number }>;\n }>;\n checkpoints?: Array<{\n timestamp: string;\n version: number;\n fromVersion: number | null;\n changelog: string | null;\n added: Array<{ token: string; mint: string; allocation: number }>;\n removed: Array<{ token: string; mint: string; allocation: number }>;\n reweighted: Array<{ token: string; mint: string; fromPct: number; toPct: number }>;\n }>;\n liquidationInfo?: {\n hasLiquidations: boolean;\n liquidationEvents: Array<{\n timestamp: string;\n asset: string;\n liquidationPrice: number;\n actualPrice: number;\n }>;\n liquidationThresholds: Array<{\n asset: string;\n mint: string;\n liquidationPrice: number;\n entryPrice: number;\n leverage: number;\n direction: 'LONG' | 'SHORT';\n }>;\n };\n hasPredictionMarkets?: boolean;\n predictionMarketEvents?: PredictionMarketEvent[];\n incentives?: IncentiveOverlayCampaign[];\n}\n\n/** Prediction-market backtest chart — `GET /products/:id/graph` (prediction). */\nexport interface PredictionMarketChart {\n workflowId: string;\n name: string;\n predictionMarket: boolean;\n markets: PredictionMarketEvent[];\n incentives?: IncentiveOverlayCampaign[];\n}\n\n/** Union returned by the graph endpoint. Discriminate with {@link isPredictionMarketChart}. */\nexport type ProductBacktestChart = BacktestChart | PredictionMarketChart;\n\n/** `products.get(slug, { includeBacktestChart: true })` — detail with chart merged in. */\nexport type ProductWithBacktestChart = ProductVersionResponse & {\n backtestChart: ProductBacktestChart | null;\n};\n\n/** Type guard: is this chart the prediction-market variant? */\nexport function isPredictionMarketChart(\n chart: ProductBacktestChart,\n): chart is PredictionMarketChart {\n return (chart as PredictionMarketChart).predictionMarket === true;\n}\n"]}
@@ -0,0 +1,573 @@
1
+ /**
2
+ * Error hierarchy thrown by the SDK.
3
+ *
4
+ * Everything extends {@link CestoError}. Server (non-2xx) responses become an
5
+ * {@link APIError} subclass built from the API's `{ code, message, details,
6
+ * requestId }` envelope; transport problems become {@link APIConnectionError}
7
+ * (or its timeout subclass); caller cancellation becomes {@link APIUserAbortError}.
8
+ */
9
+ /** Base class for every error the SDK throws. */
10
+ declare class CestoError extends Error {
11
+ constructor(message: string);
12
+ }
13
+ /** Parsed `{ code, message, details, requestId }` envelope from the API. */
14
+ interface APIErrorEnvelope {
15
+ code?: string;
16
+ message?: string;
17
+ details?: unknown;
18
+ requestId?: string;
19
+ }
20
+ /** A non-2xx HTTP response. */
21
+ declare class APIError extends CestoError {
22
+ /** HTTP status code. */
23
+ readonly status: number;
24
+ /** Machine-readable error code from the API envelope (e.g. `RESOURCE_NOT_FOUND`). */
25
+ readonly code?: string;
26
+ /** Correlation id from the API envelope, useful when reporting issues. */
27
+ readonly requestId?: string;
28
+ /** Structured error details from the API envelope. */
29
+ readonly details?: unknown;
30
+ /** Response headers. */
31
+ readonly headers?: Headers;
32
+ constructor(status: number, message: string, opts?: {
33
+ code?: string;
34
+ requestId?: string;
35
+ details?: unknown;
36
+ headers?: Headers;
37
+ });
38
+ }
39
+ declare class BadRequestError extends APIError {
40
+ }
41
+ declare class AuthenticationError extends APIError {
42
+ }
43
+ declare class PermissionDeniedError extends APIError {
44
+ }
45
+ declare class NotFoundError extends APIError {
46
+ }
47
+ declare class ConflictError extends APIError {
48
+ }
49
+ declare class UnprocessableEntityError extends APIError {
50
+ }
51
+ /** HTTP 429. Carries `retryAfter` (ms) when the server sent a `Retry-After` header. */
52
+ declare class RateLimitError extends APIError {
53
+ /** Milliseconds to wait before retrying, derived from `Retry-After`. */
54
+ readonly retryAfter?: number;
55
+ constructor(status: number, message: string, opts?: {
56
+ code?: string;
57
+ requestId?: string;
58
+ details?: unknown;
59
+ headers?: Headers;
60
+ retryAfter?: number;
61
+ });
62
+ }
63
+ declare class InternalServerError extends APIError {
64
+ }
65
+ /** A network-level failure (DNS, connection reset, fetch threw). */
66
+ declare class APIConnectionError extends CestoError {
67
+ readonly cause?: unknown;
68
+ constructor(message?: string, opts?: {
69
+ cause?: unknown;
70
+ });
71
+ }
72
+ /** The request exceeded the configured timeout. */
73
+ declare class APIConnectionTimeoutError extends APIConnectionError {
74
+ constructor(message?: string);
75
+ }
76
+ /** The caller's `AbortSignal` fired. */
77
+ declare class APIUserAbortError extends CestoError {
78
+ constructor(message?: string);
79
+ }
80
+
81
+ /** Which deployed Cesto backend to target. */
82
+ type CestoEnvironment = 'PRODUCTION' | 'BETA';
83
+ /** Options for constructing a {@link Cesto} client. */
84
+ interface ClientOptions {
85
+ /**
86
+ * Secret API key (`cesto_sk_…`). Required — the constructor throws if omitted.
87
+ * Read it from your environment yourself, e.g. `apiKey: process.env.CESTO_API_KEY`.
88
+ */
89
+ apiKey?: string;
90
+ /**
91
+ * Which backend to target in a deployed build (`NODE_ENV=production`):
92
+ * `PRODUCTION` → backend.cesto.co, `BETA` → dev.backend.cesto.co. Default `PRODUCTION`.
93
+ */
94
+ environment?: CestoEnvironment;
95
+ /** Per-request timeout in milliseconds. Default `60000`. */
96
+ timeout?: number;
97
+ /** Max automatic retries on transient failures. Default `2`. */
98
+ maxRetries?: number;
99
+ /** Custom fetch implementation (e.g. undici, a test mock). Default `globalThis.fetch`. */
100
+ fetch?: typeof fetch;
101
+ }
102
+ /** Per-request overrides accepted by every resource method. */
103
+ interface RequestOptions {
104
+ /** Override the client timeout (ms) for this request. */
105
+ timeout?: number;
106
+ /** Override the client retry count for this request (e.g. `0` to disable). */
107
+ maxRetries?: number;
108
+ /** Caller cancellation; composed with the internal timeout signal. */
109
+ signal?: AbortSignal;
110
+ }
111
+ /** Fully-resolved, validated client configuration. */
112
+ interface ResolvedOptions {
113
+ apiKey: string;
114
+ /** Normalized base URL, no trailing slash. */
115
+ baseURL: string;
116
+ timeout: number;
117
+ maxRetries: number;
118
+ fetch: typeof fetch;
119
+ }
120
+
121
+ /** Backtest chart window. Only `1y` carries full portfolio metrics. */
122
+ type ChartTimeRange = '7d' | '1m' | '3m' | '6m' | '1y' | 'all';
123
+ type PredictionProtocol = 'kalshi' | 'polymarket';
124
+ type PredictionSide = 'YES' | 'NO';
125
+ type MarketStatus = 'initialized' | 'active' | 'inactive' | 'closed' | 'determined' | 'finalized';
126
+ /** Whether the requester's region may view / invest in a product. */
127
+ interface GeoStatus {
128
+ canView: boolean;
129
+ canInvest: boolean;
130
+ }
131
+ /** One incentive campaign overlaid on a product. */
132
+ interface IncentiveOverlayCampaign {
133
+ campaignId: string;
134
+ slug: string;
135
+ partnerName: string;
136
+ rewardTokenSymbol: string;
137
+ rewardTokenMint: string;
138
+ /** Campaign APY in percent, or null when TVL is 0 / not yet computed. */
139
+ apy: number | null;
140
+ /** ISO timestamp. */
141
+ endsAt: string;
142
+ tvlUsd: string;
143
+ pointsMultiplier: string | null;
144
+ }
145
+ /** Prediction-market performance (present only for prediction-market products). */
146
+ interface PredictionPerformance {
147
+ roi: number;
148
+ impliedProbability: number;
149
+ daysToExpiration: number;
150
+ /** ISO timestamp. */
151
+ expirationDate: string;
152
+ }
153
+ /** Backtested token/basket performance over a window. */
154
+ interface TokenPerformance {
155
+ avgPercentChange?: number;
156
+ daysAvailable?: number;
157
+ startDate?: string;
158
+ endDate?: string;
159
+ annualizedReturn?: number;
160
+ return?: number;
161
+ netPnL?: number | null;
162
+ pricePnL?: number | null;
163
+ netAPY?: number | null;
164
+ priceAPY?: number | null;
165
+ yieldBreakdown?: {
166
+ pricePnL: number;
167
+ yieldPnL: number;
168
+ netPnL: number;
169
+ priceAPY: number;
170
+ netAPY: number;
171
+ annualizedReturn: number;
172
+ } | null;
173
+ predictionPerformance?: PredictionPerformance | null;
174
+ /** Incentive overlay (added per window when campaigns apply). */
175
+ incentiveAPY?: number;
176
+ totalAPY?: number;
177
+ }
178
+ /** Live state of a prediction market attached to a product. */
179
+ interface PredictionMarketState {
180
+ marketTicker: string;
181
+ protocol: PredictionProtocol;
182
+ side: PredictionSide;
183
+ title?: string;
184
+ /** Unix seconds. */
185
+ closeTime: number;
186
+ status: MarketStatus;
187
+ result?: 'yes' | 'no';
188
+ }
189
+
190
+ /** Product summary attached to a position. */
191
+ interface PositionProduct {
192
+ id: string;
193
+ name: string;
194
+ slug: string;
195
+ category: string | null;
196
+ logoUrl: string | null;
197
+ isActive: boolean;
198
+ }
199
+ /** The product version a position currently tracks. */
200
+ interface PositionVersion {
201
+ id: string;
202
+ version: number;
203
+ isDeprecated: boolean;
204
+ }
205
+ /** One underlying investment row within a position (transparency view). */
206
+ interface PositionInvestment {
207
+ id: string;
208
+ /** Invested amount in token base units. */
209
+ totalInvested: string;
210
+ totalInvestedUsd: string;
211
+ tokenMint: string;
212
+ tokenDecimals: number;
213
+ /** ISO timestamp. */
214
+ openedAt: string;
215
+ closedAt: string | null;
216
+ closedReason: string | null;
217
+ creationType: string | null;
218
+ executionStatus: string | null;
219
+ /** UI-facing status, e.g. `Active`, `Closing`, `Scheduled`. */
220
+ displayStatus: string;
221
+ partialReason: string | null;
222
+ openingExecutionId: string | null;
223
+ scheduledToOpenAt: string | null;
224
+ closingExecutionId: string | null;
225
+ closeExecutionStatus: string | null;
226
+ scheduledToCloseAt: string | null;
227
+ }
228
+ /**
229
+ * Aggregated valuation for a position (live + partial buckets).
230
+ *
231
+ * The bucket internals mirror the API's portfolio aggregation and are treated as
232
+ * loosely-typed until the `/v1` route formalizes them; `totalCurrentValueUsd` is
233
+ * the field most consumers read.
234
+ */
235
+ interface PositionValuation {
236
+ live?: Record<string, unknown>;
237
+ partial?: Record<string, unknown>;
238
+ calculatedAt?: string;
239
+ }
240
+ /** A live position — one entry per (user, product). */
241
+ interface Position {
242
+ productId: string;
243
+ product: PositionProduct;
244
+ currentVersion: PositionVersion | null;
245
+ aggregatedData: PositionValuation | null;
246
+ investments: PositionInvestment[];
247
+ incentives: {
248
+ campaigns: IncentiveOverlayCampaign[];
249
+ };
250
+ cacheMetadata: {
251
+ calculatedAt: string;
252
+ expiresAt: string;
253
+ } | null;
254
+ }
255
+ /** Result of `positions.list({ wallet })`. */
256
+ interface PositionsResult {
257
+ positions: Position[];
258
+ pendingClosePositions: Position[];
259
+ }
260
+
261
+ /** Query parameters; `undefined`/`null` values are skipped. */
262
+ type QueryParams = Record<string, string | number | boolean | undefined | null>;
263
+ interface GetOptions extends RequestOptions {
264
+ query?: QueryParams;
265
+ }
266
+ /** Internal transport: builds requests, applies auth, retries, and parses JSON. */
267
+ declare class APIClientCore {
268
+ private readonly opts;
269
+ constructor(opts: ResolvedOptions);
270
+ get<T>(path: string, options?: GetOptions): Promise<T>;
271
+ private request;
272
+ private buildURL;
273
+ }
274
+
275
+ /** Base class for resource groups; holds a reference to the transport. */
276
+ declare abstract class APIResource {
277
+ protected readonly client: APIClientCore;
278
+ constructor(client: APIClientCore);
279
+ }
280
+
281
+ interface PositionsListParams {
282
+ /** External Solana wallet address (Phantom/Solflare). Required. */
283
+ wallet: string;
284
+ }
285
+ declare class Positions extends APIResource {
286
+ /**
287
+ * List a user's open/closing positions, resolved from their external Solana
288
+ * wallet. A wallet with no Cesto account returns an empty result (not an error).
289
+ */
290
+ list(params: PositionsListParams, options?: RequestOptions): Promise<PositionsResult>;
291
+ }
292
+
293
+ /** An item in `products.list()` — `GET /products`. */
294
+ interface ProductListItem {
295
+ id: string;
296
+ slug: string;
297
+ name: string;
298
+ description: string | null;
299
+ logoUrl: string | null;
300
+ category: string | null;
301
+ tags: string[];
302
+ isActive: boolean;
303
+ isPublished: boolean;
304
+ pointMultiplier: number;
305
+ metadata: Record<string, unknown> | null;
306
+ geoStatus: GeoStatus;
307
+ /** Active incentive campaigns; `[]` when none. */
308
+ incentives: IncentiveOverlayCampaign[];
309
+ }
310
+ /** Backtested performance for a product — `GET /products/analytics` (per product). */
311
+ interface ProductBacktest {
312
+ protocolsInvolved: string[];
313
+ tokensInvolved: string[];
314
+ tokenPerformance: TokenPerformance | null;
315
+ tokenPerformance7d: TokenPerformance | null;
316
+ tokenPerformance30d: TokenPerformance | null;
317
+ priceChange24h: number | null;
318
+ tokenPriceChanges: Record<string, {
319
+ priceChange24h: number | null;
320
+ priceChange24hPercent: number | null;
321
+ }>;
322
+ }
323
+ /** `products.list({ includeBacktest: true })` — list item with backtest merged in. */
324
+ type ProductWithBacktest = ProductListItem & {
325
+ backtest: ProductBacktest | null;
326
+ };
327
+ interface ProductCreator {
328
+ id: string;
329
+ username: string | null;
330
+ email: string | null;
331
+ solanaWalletAddress: string | null;
332
+ embeddedWalletAddress: string | null;
333
+ }
334
+ interface OndoTradingStatus {
335
+ allTradable: boolean;
336
+ currentSession: string;
337
+ hasOndoTokens: boolean;
338
+ tokens: unknown[];
339
+ untradableTokens: unknown[];
340
+ nextFullyTradableAt: string | null;
341
+ nextFullyTradableSession: string | null;
342
+ }
343
+ /** Full product detail — `GET /products/:slug`. */
344
+ interface ProductVersionResponse {
345
+ id: string;
346
+ versionId: string;
347
+ version: number;
348
+ changelog: string | null;
349
+ minimumInvestment: string;
350
+ inputTokenMint: string;
351
+ inputTokenDecimals: number;
352
+ about: string | null;
353
+ riskNotes: string | null;
354
+ resources: string | null;
355
+ name: string;
356
+ slug: string;
357
+ description: string | null;
358
+ logoUrl: string | null;
359
+ category: string | null;
360
+ tags: string[];
361
+ isActive: boolean;
362
+ isPublished: boolean;
363
+ metadata: Record<string, unknown> | null;
364
+ pointMultiplier: number;
365
+ createdBy: string;
366
+ creator: ProductCreator | null;
367
+ tokensInvolved: string[];
368
+ protocolsInvolved: string[];
369
+ tokenPerformance: TokenPerformance | null;
370
+ tokenPerformance7d: TokenPerformance | null;
371
+ tokenPerformance30d: TokenPerformance | null;
372
+ predictionMarkets?: PredictionMarketState[];
373
+ canInvest: boolean;
374
+ /** Raw workflow definition. */
375
+ definition: unknown;
376
+ geoStatus: GeoStatus;
377
+ ondoTradingStatus: OndoTradingStatus;
378
+ incentives?: IncentiveOverlayCampaign[];
379
+ }
380
+ interface BacktestChartTimeSeriesPoint {
381
+ timestamp: string;
382
+ portfolioValue: number;
383
+ sp500Value?: number;
384
+ mag7Value?: number;
385
+ btcValue?: number;
386
+ solValue?: number;
387
+ usdcValue?: number;
388
+ isLiquidated?: boolean;
389
+ liquidationThreshold?: number;
390
+ }
391
+ interface BacktestChartMetrics {
392
+ totalReturn: number;
393
+ cagr: number;
394
+ volatility: number;
395
+ maxDrawdown: number;
396
+ sharpe: number;
397
+ }
398
+ interface PredictionMarketEvent {
399
+ ticker: string;
400
+ marketTicker: string;
401
+ seriesTicker: string;
402
+ title: string;
403
+ closeTime: number;
404
+ currentProbability?: number;
405
+ currentPrice: number;
406
+ daysToClose: number;
407
+ timeSeries: Array<{
408
+ market_ticker: string;
409
+ event_ticker: string;
410
+ raw_numerical_forecast: number;
411
+ numerical_forecast: number;
412
+ formatted_forecast: string;
413
+ end_period_ts: number;
414
+ period_interval: number;
415
+ }>;
416
+ }
417
+ /** Token-portfolio backtest chart — `GET /products/:id/graph` (non-prediction). */
418
+ interface BacktestChart {
419
+ workflowId: string;
420
+ name: string;
421
+ timeRange?: ChartTimeRange;
422
+ timeSeries: BacktestChartTimeSeriesPoint[];
423
+ /** Computed only when `timeRange === '1y'`; null otherwise. */
424
+ metrics: BacktestChartMetrics | null;
425
+ assetPerformance: Array<{
426
+ token: string;
427
+ mint: string;
428
+ returnPct: number;
429
+ }>;
430
+ contributions: Array<{
431
+ token: string;
432
+ mint: string;
433
+ contribution: number;
434
+ }>;
435
+ assetSparklines: Array<{
436
+ token: string;
437
+ mint: string;
438
+ points: Array<{
439
+ timestamp: string;
440
+ value: number;
441
+ price: number;
442
+ }>;
443
+ }>;
444
+ checkpoints?: Array<{
445
+ timestamp: string;
446
+ version: number;
447
+ fromVersion: number | null;
448
+ changelog: string | null;
449
+ added: Array<{
450
+ token: string;
451
+ mint: string;
452
+ allocation: number;
453
+ }>;
454
+ removed: Array<{
455
+ token: string;
456
+ mint: string;
457
+ allocation: number;
458
+ }>;
459
+ reweighted: Array<{
460
+ token: string;
461
+ mint: string;
462
+ fromPct: number;
463
+ toPct: number;
464
+ }>;
465
+ }>;
466
+ liquidationInfo?: {
467
+ hasLiquidations: boolean;
468
+ liquidationEvents: Array<{
469
+ timestamp: string;
470
+ asset: string;
471
+ liquidationPrice: number;
472
+ actualPrice: number;
473
+ }>;
474
+ liquidationThresholds: Array<{
475
+ asset: string;
476
+ mint: string;
477
+ liquidationPrice: number;
478
+ entryPrice: number;
479
+ leverage: number;
480
+ direction: 'LONG' | 'SHORT';
481
+ }>;
482
+ };
483
+ hasPredictionMarkets?: boolean;
484
+ predictionMarketEvents?: PredictionMarketEvent[];
485
+ incentives?: IncentiveOverlayCampaign[];
486
+ }
487
+ /** Prediction-market backtest chart — `GET /products/:id/graph` (prediction). */
488
+ interface PredictionMarketChart {
489
+ workflowId: string;
490
+ name: string;
491
+ predictionMarket: boolean;
492
+ markets: PredictionMarketEvent[];
493
+ incentives?: IncentiveOverlayCampaign[];
494
+ }
495
+ /** Union returned by the graph endpoint. Discriminate with {@link isPredictionMarketChart}. */
496
+ type ProductBacktestChart = BacktestChart | PredictionMarketChart;
497
+ /** `products.get(slug, { includeBacktestChart: true })` — detail with chart merged in. */
498
+ type ProductWithBacktestChart = ProductVersionResponse & {
499
+ backtestChart: ProductBacktestChart | null;
500
+ };
501
+ /** Type guard: is this chart the prediction-market variant? */
502
+ declare function isPredictionMarketChart(chart: ProductBacktestChart): chart is PredictionMarketChart;
503
+
504
+ interface ProductListParams {
505
+ /** Filter by category. */
506
+ category?: string;
507
+ /**
508
+ * Also fetch backtested performance (`GET /products/analytics`) and merge it
509
+ * onto each product as `backtest`. Fails gracefully → `backtest: null`.
510
+ */
511
+ includeBacktest?: boolean;
512
+ }
513
+ interface ProductGetParams {
514
+ /**
515
+ * Also fetch the product's backtested value chart and attach it as `backtestChart`.
516
+ * Fails gracefully → `backtestChart: null`.
517
+ */
518
+ includeBacktestChart?: boolean;
519
+ /** Chart window when `includeBacktestChart` is true. Default `'1y'`. */
520
+ chartTimeRange?: ChartTimeRange;
521
+ }
522
+ declare class Products extends APIResource {
523
+ /** List products. */
524
+ list(): Promise<ProductListItem[]>;
525
+ list(params: ProductListParams & {
526
+ includeBacktest?: false;
527
+ }, options?: RequestOptions): Promise<ProductListItem[]>;
528
+ list(params: ProductListParams & {
529
+ includeBacktest: true;
530
+ }, options?: RequestOptions): Promise<ProductWithBacktest[]>;
531
+ /** Get a product by slug. */
532
+ get(slug: string): Promise<ProductVersionResponse>;
533
+ get(slug: string, params: ProductGetParams & {
534
+ includeBacktestChart?: false;
535
+ }, options?: RequestOptions): Promise<ProductVersionResponse>;
536
+ get(slug: string, params: ProductGetParams & {
537
+ includeBacktestChart: true;
538
+ }, options?: RequestOptions): Promise<ProductWithBacktestChart>;
539
+ }
540
+
541
+ /**
542
+ * The Cesto SDK client.
543
+ *
544
+ * @example
545
+ * ```ts
546
+ * const cesto = new Cesto({ apiKey: process.env.CESTO_API_KEY! });
547
+ * const products = await cesto.products.list({ includeBacktest: true });
548
+ * ```
549
+ */
550
+ declare class Cesto {
551
+ readonly products: Products;
552
+ readonly positions: Positions;
553
+ private readonly core;
554
+ constructor(options?: ClientOptions);
555
+ static readonly CestoError: typeof CestoError;
556
+ static readonly APIError: typeof APIError;
557
+ static readonly BadRequestError: typeof BadRequestError;
558
+ static readonly AuthenticationError: typeof AuthenticationError;
559
+ static readonly PermissionDeniedError: typeof PermissionDeniedError;
560
+ static readonly NotFoundError: typeof NotFoundError;
561
+ static readonly ConflictError: typeof ConflictError;
562
+ static readonly UnprocessableEntityError: typeof UnprocessableEntityError;
563
+ static readonly RateLimitError: typeof RateLimitError;
564
+ static readonly InternalServerError: typeof InternalServerError;
565
+ static readonly APIConnectionError: typeof APIConnectionError;
566
+ static readonly APIConnectionTimeoutError: typeof APIConnectionTimeoutError;
567
+ static readonly APIUserAbortError: typeof APIUserAbortError;
568
+ }
569
+
570
+ /** SDK version. Keep in sync with package.json `version`. */
571
+ declare const VERSION = "0.0.1";
572
+
573
+ export { APIConnectionError, APIConnectionTimeoutError, APIError, type APIErrorEnvelope, APIUserAbortError, AuthenticationError, type BacktestChart, type BacktestChartMetrics, type BacktestChartTimeSeriesPoint, BadRequestError, Cesto, type CestoEnvironment, CestoError, type ChartTimeRange, type ClientOptions, ConflictError, type GeoStatus, type IncentiveOverlayCampaign, InternalServerError, type MarketStatus, NotFoundError, type OndoTradingStatus, PermissionDeniedError, type Position, type PositionInvestment, type PositionProduct, type PositionValuation, type PositionVersion, type PositionsListParams, type PositionsResult, type PredictionMarketChart, type PredictionMarketEvent, type PredictionMarketState, type PredictionPerformance, type PredictionProtocol, type PredictionSide, type ProductBacktest, type ProductBacktestChart, type ProductCreator, type ProductGetParams, type ProductListItem, type ProductListParams, type ProductVersionResponse, type ProductWithBacktest, type ProductWithBacktestChart, RateLimitError, type RequestOptions, type TokenPerformance, UnprocessableEntityError, VERSION, isPredictionMarketChart };