@0xinsider/mcp 1.3.1 → 2.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.
Files changed (57) hide show
  1. package/README.md +98 -0
  2. package/dist/cli-lib.d.ts.map +1 -1
  3. package/dist/cli-lib.js +9 -5
  4. package/dist/cli-lib.js.map +1 -1
  5. package/dist/cli.js +6 -1
  6. package/dist/cli.js.map +1 -1
  7. package/dist/constants.d.ts +1 -1
  8. package/dist/constants.js +1 -1
  9. package/dist/product-cli/client.d.ts +9 -0
  10. package/dist/product-cli/client.d.ts.map +1 -0
  11. package/dist/product-cli/client.js +78 -0
  12. package/dist/product-cli/client.js.map +1 -0
  13. package/dist/product-cli/errors.d.ts +7 -0
  14. package/dist/product-cli/errors.d.ts.map +1 -0
  15. package/dist/product-cli/errors.js +13 -0
  16. package/dist/product-cli/errors.js.map +1 -0
  17. package/dist/product-cli/index.d.ts +4 -0
  18. package/dist/product-cli/index.d.ts.map +1 -0
  19. package/dist/product-cli/index.js +354 -0
  20. package/dist/product-cli/index.js.map +1 -0
  21. package/dist/product-cli/oauth.d.ts +10 -0
  22. package/dist/product-cli/oauth.d.ts.map +1 -0
  23. package/dist/product-cli/oauth.js +246 -0
  24. package/dist/product-cli/oauth.js.map +1 -0
  25. package/dist/product-cli/storage.d.ts +20 -0
  26. package/dist/product-cli/storage.d.ts.map +1 -0
  27. package/dist/product-cli/storage.js +158 -0
  28. package/dist/product-cli/storage.js.map +1 -0
  29. package/dist/sdk/client.d.ts +765 -0
  30. package/dist/sdk/client.d.ts.map +1 -0
  31. package/dist/sdk/client.js +974 -0
  32. package/dist/sdk/client.js.map +1 -0
  33. package/dist/sdk/errors.d.ts +313 -0
  34. package/dist/sdk/errors.d.ts.map +1 -0
  35. package/dist/sdk/errors.js +521 -0
  36. package/dist/sdk/errors.js.map +1 -0
  37. package/dist/sdk/index.d.ts +26 -0
  38. package/dist/sdk/index.d.ts.map +1 -0
  39. package/dist/sdk/index.js +25 -0
  40. package/dist/sdk/index.js.map +1 -0
  41. package/dist/sdk/pagination.d.ts +76 -0
  42. package/dist/sdk/pagination.d.ts.map +1 -0
  43. package/dist/sdk/pagination.js +106 -0
  44. package/dist/sdk/pagination.js.map +1 -0
  45. package/dist/sdk/schema.d.ts +2425 -0
  46. package/dist/sdk/schema.d.ts.map +1 -0
  47. package/dist/sdk/schema.js +7 -0
  48. package/dist/sdk/schema.js.map +1 -0
  49. package/dist/sdk/stream.d.ts +182 -0
  50. package/dist/sdk/stream.d.ts.map +1 -0
  51. package/dist/sdk/stream.js +391 -0
  52. package/dist/sdk/stream.js.map +1 -0
  53. package/dist/sdk/webhooks.d.ts +163 -0
  54. package/dist/sdk/webhooks.d.ts.map +1 -0
  55. package/dist/sdk/webhooks.js +122 -0
  56. package/dist/sdk/webhooks.js.map +1 -0
  57. package/package.json +6 -3
@@ -0,0 +1,521 @@
1
+ /**
2
+ * Typed error hierarchy for the 0xinsider API V1 error envelope.
3
+ *
4
+ * The V1 contract returns a stable error shape on every non-2xx response
5
+ * (`web/public/api/v1/openapi.json` -> components.schemas.ApiError):
6
+ *
7
+ * {
8
+ * "object": "error",
9
+ * "error": { "code": <ApiErrorCode>, "message": string, "doc_url"?, "param"? },
10
+ * "meta": { "request_id": string, "cached": boolean, "cost": number, ... }
11
+ * }
12
+ *
13
+ * Some upstream/proxy failures return a flat body `{ code, message }` without
14
+ * the `object: "error"` wrapper; both shapes are normalized here.
15
+ *
16
+ * The canonical `code` set is the `ApiError.error.code` enum in the OpenAPI
17
+ * spec. The client maps each error to the most specific subclass -- dispatching on `reason` first (it is strictly more specific), then `code` so callers can
18
+ * `instanceof` the specific failure, and falls back to the base
19
+ * `OxinsiderApiError` for unknown codes or non-JSON bodies.
20
+ */
21
+ /**
22
+ * Canonical error codes the API can return. Source of truth:
23
+ * `components.schemas.ApiError.properties.error.properties.code.enum`.
24
+ */
25
+ export const API_ERROR_CODES = [
26
+ "bad_request",
27
+ "invalid_api_key",
28
+ "subscription_required",
29
+ "forbidden",
30
+ "not_found",
31
+ "account_locked",
32
+ "rate_limited",
33
+ "rate_limit_unavailable",
34
+ "internal_error",
35
+ ];
36
+ /**
37
+ * The specific, actionable cause behind a `code`. Source of truth:
38
+ * `components.schemas.ApiError.properties.error.properties.reason.enum`.
39
+ *
40
+ * Additive (#7209): `code` keeps its published values, so this never changes what
41
+ * an existing `code` means. It tells you what to DO, where the code alone could
42
+ * not: `pick_not_released` is "not YET" (sleep until `retryAt`), not "does not
43
+ * exist"; `unknown_endpoint` is a wrong PATH (do not retry); `trader_not_tracked`
44
+ * is a wallet we do not capture (stop asking for it); `cursor_expired` means
45
+ * re-request page 1; `read_model_warming` is endpoint-local unavailability,
46
+ * not rate limiting. Retry only that route after the supplied interval; do not
47
+ * infer dependency health from the reason.
48
+ */
49
+ export const API_ERROR_REASONS = [
50
+ "cursor_expired",
51
+ "unknown_endpoint",
52
+ "pick_not_released",
53
+ "trader_not_tracked",
54
+ "read_model_warming",
55
+ "database_unavailable",
56
+ "request_accounting_unavailable",
57
+ // 409 conflict causes (code `bad_request` at HTTP 409): the same mutation is
58
+ // still running / a webhook endpoint is mid-delivery. Dispatched to
59
+ // IdempotencyInProgressError / WebhookDeliveryInProgressError below, both
60
+ // refining BadRequestError to match the wire code.
61
+ "idempotency_in_progress",
62
+ "webhook_delivery_in_progress",
63
+ // 401 `invalid_api_key` refinement (#13959): a sandbox key sent to the live
64
+ // API. Dispatched to SandboxApiKeyError below.
65
+ "sandbox_api_key",
66
+ // 401 `invalid_api_key` refinement (#14123): the key was sent as a `?token=`
67
+ // query parameter, which no route reads. Dispatched to ApiKeyInQueryError.
68
+ "api_key_in_query",
69
+ // 402 `subscription_required` refinement (#14283): the account's Pro
70
+ // subscription has lapsed. Permanent until a person reactivates; the
71
+ // message names the URL. Carried on SubscriptionRequiredError.reason.
72
+ "subscription_inactive",
73
+ ];
74
+ /**
75
+ * The request missed its deadline (`timeoutMs`) before any response arrived.
76
+ * Not an `OxinsiderApiError`: there is no status, body, or request id. Retry
77
+ * with backoff; a persistent timeout is a network or service problem, not a
78
+ * rejected request (#11115).
79
+ */
80
+ export class RequestTimeoutError extends Error {
81
+ operationId;
82
+ timeoutMs;
83
+ constructor(operationId, timeoutMs) {
84
+ super(`0xinsider API ${operationId} did not answer within ${String(timeoutMs)} ms`);
85
+ this.name = "RequestTimeoutError";
86
+ this.operationId = operationId;
87
+ this.timeoutMs = timeoutMs;
88
+ }
89
+ }
90
+ /**
91
+ * Base class for every error thrown by the SDK on a non-2xx API response.
92
+ * Subclasses below specialize by documented `code`.
93
+ */
94
+ export class OxinsiderApiError extends Error {
95
+ /** HTTP status code of the failing response. */
96
+ status;
97
+ /** Documented error code, when the body carried one. */
98
+ code;
99
+ /**
100
+ * The specific, actionable cause behind `code`, or `null` when the response carried
101
+ * no reason the SDK recognizes (#7209).
102
+ *
103
+ * Declared on the BASE class, not only on the five reason subclasses, so the thing an
104
+ * SDK user actually writes type-checks:
105
+ *
106
+ * catch (e) { if (e instanceof OxinsiderApiError && e.reason === "pick_not_released") ... }
107
+ *
108
+ * With `reason` living only on the subclasses, that read was a type error, and the only
109
+ * way to branch on the cause was an `instanceof` ladder over all five -- which defeats
110
+ * the point of shipping a reason at all. The subclasses narrow this to their own literal.
111
+ *
112
+ * The raw wire value always stays on `error.reason`, so a reason NEWER than this SDK is
113
+ * never destroyed -- it is simply not typed yet, and reads as `null` here.
114
+ */
115
+ reason = null;
116
+ /**
117
+ * When retrying can first succeed, or `null` when the error is terminal.
118
+ *
119
+ * On the BASE class for exactly the reason `reason` is, and the backend says so in its
120
+ * own contract (`ApiErrorBody::retry_at`): the field is "generic on purpose ... so
121
+ * clients key on ONE field across the whole API rather than a per-endpoint zoo". With
122
+ * `retryAt` living only on the three retryable subclasses,
123
+ *
124
+ * catch (e) { if (e instanceof OxinsiderApiError && e.retryAt) scheduleRetry(e.retryAt) }
125
+ *
126
+ * was a type error -- the same defect the `reason` hoist above exists to fix, left in
127
+ * place one field over.
128
+ *
129
+ * Parsed from the wire on every error, so it is present whenever the API sends it and
130
+ * `null` when it does not. A terminal error (`cursor_expired`, `trader_not_tracked`)
131
+ * has no `retry_at`, and `null` is the honest answer: do not retry this.
132
+ *
133
+ * DO NOT BLOCK A WORKER THREAD ON IT. On `pick_not_released` this can be 13-14 hours
134
+ * out (a full day on a skipped day). Schedule the retry; do not sleep.
135
+ */
136
+ retryAt;
137
+ /** Parsed `error` object (`{ code, message, doc_url?, param? }`), or null. */
138
+ error;
139
+ /** Response `meta` (`request_id`, `cost`, ...), or null. */
140
+ meta;
141
+ /** The `request_id` from `meta`, surfaced for support correlation. */
142
+ requestId;
143
+ /** Raw, unparsed body for debugging. */
144
+ body;
145
+ constructor(status, body) {
146
+ const error = extractApiErrorBody(body);
147
+ const meta = extractApiErrorMeta(body);
148
+ const message = error?.message ??
149
+ `0xinsider API request failed with status ${String(status)}`;
150
+ super(message);
151
+ this.name = "OxinsiderApiError";
152
+ this.status = status;
153
+ this.code = error?.code;
154
+ this.error = error;
155
+ this.meta = meta;
156
+ this.requestId = meta?.request_id;
157
+ this.body = body;
158
+ // Parsed once, here, for EVERY error. The retryable subclasses no longer parse it
159
+ // themselves -- two parsers for one wire field is how they drift.
160
+ this.retryAt = parseRetryAt(body);
161
+ }
162
+ }
163
+ /** 400 - the request was malformed; see `param` for the offending field. */
164
+ export class BadRequestError extends OxinsiderApiError {
165
+ code = "bad_request";
166
+ constructor(status, body) {
167
+ super(status, body);
168
+ this.name = "BadRequestError";
169
+ }
170
+ }
171
+ /** 401 - the `oxi_sk_*` API key is missing, malformed, or revoked. */
172
+ export class InvalidApiKeyError extends OxinsiderApiError {
173
+ code = "invalid_api_key";
174
+ constructor(status, body) {
175
+ super(status, body);
176
+ this.name = "InvalidApiKeyError";
177
+ }
178
+ }
179
+ /**
180
+ * 401 `reason: sandbox_api_key` - the credential is a sandbox key (`oxi_sk_test_`)
181
+ * from `POST /api/v1/agents/register` (#13959). Only the sandbox server accepts
182
+ * it: call `https://0xinsider.com/sandbox/api/v1` with it, or use a live key or
183
+ * OAuth access token. Retrying here will not help.
184
+ */
185
+ export class SandboxApiKeyError extends InvalidApiKeyError {
186
+ reason = "sandbox_api_key";
187
+ constructor(status, body) {
188
+ super(status, body);
189
+ this.name = "SandboxApiKeyError";
190
+ }
191
+ }
192
+ /**
193
+ * 401 `reason: api_key_in_query` - the key was sent as a `?token=` query
194
+ * parameter (#14123). No route reads a key from the URL, so the key itself was
195
+ * not checked: resend it as `Authorization: Bearer`. This client always sends
196
+ * the header, so seeing this means a URL was built by hand.
197
+ */
198
+ export class ApiKeyInQueryError extends InvalidApiKeyError {
199
+ reason = "api_key_in_query";
200
+ constructor(status, body) {
201
+ super(status, body);
202
+ this.name = "ApiKeyInQueryError";
203
+ }
204
+ }
205
+ /**
206
+ * 402 - the key is valid but the account has no active Pro subscription.
207
+ *
208
+ * Permanent until a person reactivates (`reason: subscription_inactive`,
209
+ * #14283): there is no `Retry-After`, and a retry on a schedule never clears
210
+ * it. Stop the loop and surface `reactivationUrl` to your own user. The key
211
+ * and its settings are unchanged and work again the moment Pro is active;
212
+ * the owner is emailed once per lapse.
213
+ */
214
+ export class SubscriptionRequiredError extends OxinsiderApiError {
215
+ code = "subscription_required";
216
+ /** Where the account reactivates Pro. */
217
+ reactivationUrl = "https://0xinsider.com/billing";
218
+ constructor(status, body) {
219
+ super(status, body);
220
+ this.name = "SubscriptionRequiredError";
221
+ }
222
+ }
223
+ /** 403 - the key is authenticated but not allowed to access this resource. */
224
+ export class ForbiddenError extends OxinsiderApiError {
225
+ code = "forbidden";
226
+ constructor(status, body) {
227
+ super(status, body);
228
+ this.name = "ForbiddenError";
229
+ }
230
+ }
231
+ /** 404 - the requested resource does not exist. */
232
+ export class NotFoundError extends OxinsiderApiError {
233
+ code = "not_found";
234
+ constructor(status, body) {
235
+ super(status, body);
236
+ this.name = "NotFoundError";
237
+ }
238
+ }
239
+ /** 403 - the account is locked; contact support. */
240
+ export class AccountLockedError extends OxinsiderApiError {
241
+ code = "account_locked";
242
+ constructor(status, body) {
243
+ super(status, body);
244
+ this.name = "AccountLockedError";
245
+ }
246
+ }
247
+ /**
248
+ * 429 - the per-key rate limit was exceeded. `retryAfterSeconds` is read from
249
+ * the standard `Retry-After` response header when present.
250
+ */
251
+ export class RateLimitedError extends OxinsiderApiError {
252
+ code = "rate_limited";
253
+ /** Seconds to wait before retrying, from the `Retry-After` header. */
254
+ retryAfterSeconds;
255
+ constructor(status, body, retryAfterSeconds) {
256
+ super(status, body);
257
+ this.name = "RateLimitedError";
258
+ this.retryAfterSeconds = retryAfterSeconds;
259
+ }
260
+ }
261
+ /** 503 - the rate-limit/admission backend was briefly unavailable; retry. */
262
+ export class RateLimitUnavailableError extends OxinsiderApiError {
263
+ code = "rate_limit_unavailable";
264
+ /** Seconds to wait before retrying, from the `Retry-After` header. */
265
+ retryAfterSeconds;
266
+ constructor(status, body, retryAfterSeconds) {
267
+ super(status, body);
268
+ this.name = "RateLimitUnavailableError";
269
+ this.retryAfterSeconds = retryAfterSeconds;
270
+ }
271
+ }
272
+ /**
273
+ * 404 `reason: pick_not_released` - no Pick of the Day is published for the
274
+ * current product day (#7209).
275
+ *
276
+ * This is NOT "the endpoint is broken" and NOT "the resource does not exist".
277
+ * Each selected pick releases about an hour before its own provider kickoff, inside
278
+ * the daily 11:00-23:00 UTC operating window (#7226, #7709) -- there is no fixed
279
+ * publish clock time. The product day rolls at midnight America/New_York, so the
280
+ * endpoint legitimately 404s from that roll until the day's release (a span that
281
+ * varies with the pick's kickoff), and for the full product day on a skipped day.
282
+ *
283
+ * DO NOT POLL. Sleep for `retryAfterSeconds` (or until `retryAt`) and request
284
+ * once. Blind polling through this window was 91.8% of all logged v1 API errors.
285
+ */
286
+ export class PickNotReleasedError extends NotFoundError {
287
+ reason = "pick_not_released";
288
+ /** Seconds to wait, from `Retry-After`. Prefer this: it is clock-skew immune. */
289
+ retryAfterSeconds;
290
+ constructor(status, body, retryAfterSeconds) {
291
+ super(status, body);
292
+ this.name = "PickNotReleasedError";
293
+ this.retryAfterSeconds = retryAfterSeconds;
294
+ }
295
+ }
296
+ /**
297
+ * 503 `reason: read_model_warming` - endpoint-local read-model unavailability (#7209).
298
+ *
299
+ * This is not rate limiting. Retry only this route after the supplied interval;
300
+ * the exact cause is endpoint-specific, so do not infer dependency health from
301
+ * this reason.
302
+ */
303
+ export class ReadModelWarmingError extends RateLimitUnavailableError {
304
+ reason = "read_model_warming";
305
+ constructor(status, body, retryAfterSeconds) {
306
+ super(status, body, retryAfterSeconds);
307
+ this.name = "ReadModelWarmingError";
308
+ }
309
+ }
310
+ /**
311
+ * 503 `reason: database_unavailable` - the API's database or its connection
312
+ * pool is temporarily unreachable (#10737). A connection-class failure, not a
313
+ * query fault, and not rate limiting: back off for `retryAfterSeconds`, then
314
+ * retry the same request.
315
+ */
316
+ export class DatabaseUnavailableError extends RateLimitUnavailableError {
317
+ reason = "database_unavailable";
318
+ constructor(status, body, retryAfterSeconds) {
319
+ super(status, body, retryAfterSeconds);
320
+ this.name = "DatabaseUnavailableError";
321
+ }
322
+ }
323
+ /** 503 - accounting capacity was unavailable before the handler ran. */
324
+ export class RequestAccountingUnavailableError extends RateLimitUnavailableError {
325
+ reason = "request_accounting_unavailable";
326
+ constructor(status, body, retryAfterSeconds) {
327
+ super(status, body, retryAfterSeconds);
328
+ this.name = "RequestAccountingUnavailableError";
329
+ }
330
+ }
331
+ /**
332
+ * 400 `reason: cursor_expired` - the pagination cursor was invalidated by an
333
+ * upstream data change (#7209). Recovery is mechanical: re-request the first page
334
+ * and continue. This is NOT a bad parameter -- do not stop retrying.
335
+ */
336
+ export class CursorExpiredError extends BadRequestError {
337
+ reason = "cursor_expired";
338
+ constructor(status, body) {
339
+ super(status, body);
340
+ this.name = "CursorExpiredError";
341
+ }
342
+ }
343
+ /**
344
+ * 409 `reason: idempotency_in_progress` - the same idempotent mutation is still
345
+ * running. Retain the exact `Idempotency-Key` and body and retry shortly; do NOT
346
+ * mint a new mutation. The wire carries code `bad_request` at HTTP 409, so this
347
+ * refines `BadRequestError` -- a consumer catching `BadRequestError` still matches.
348
+ */
349
+ export class IdempotencyInProgressError extends BadRequestError {
350
+ reason = "idempotency_in_progress";
351
+ constructor(status, body) {
352
+ super(status, body);
353
+ this.name = "IdempotencyInProgressError";
354
+ }
355
+ }
356
+ /**
357
+ * 409 `reason: webhook_delivery_in_progress` - a webhook endpoint's URL and
358
+ * signing secret are frozen while a delivery is in flight. Retry the
359
+ * configuration change after that delivery completes. The wire carries code
360
+ * `bad_request` at HTTP 409, so this refines `BadRequestError`.
361
+ */
362
+ export class WebhookDeliveryInProgressError extends BadRequestError {
363
+ reason = "webhook_delivery_in_progress";
364
+ constructor(status, body) {
365
+ super(status, body);
366
+ this.name = "WebhookDeliveryInProgressError";
367
+ }
368
+ }
369
+ /**
370
+ * 404 `reason: unknown_endpoint` - the PATH is not a route on this API (#7209).
371
+ * Read `GET /api/v1` for the route index. Retrying will not help.
372
+ */
373
+ export class UnknownEndpointError extends NotFoundError {
374
+ reason = "unknown_endpoint";
375
+ constructor(status, body) {
376
+ super(status, body);
377
+ this.name = "UnknownEndpointError";
378
+ }
379
+ }
380
+ /**
381
+ * 404 `reason: trader_not_tracked` - the wallet is real and the URL is right, but
382
+ * the trader is outside the HOT/WARM sync tiers so we do not capture this data
383
+ * for them (#7209). Stop asking for this wallet; do not hunt for a different URL.
384
+ */
385
+ export class TraderNotTrackedError extends NotFoundError {
386
+ reason = "trader_not_tracked";
387
+ constructor(status, body) {
388
+ super(status, body);
389
+ this.name = "TraderNotTrackedError";
390
+ }
391
+ }
392
+ /** Parse the RFC3339 `error.retry_at` off an error envelope, if present. */
393
+ function parseRetryAt(body) {
394
+ const raw = extractApiErrorBody(body)?.retry_at;
395
+ if (typeof raw !== "string")
396
+ return null;
397
+ const parsed = new Date(raw);
398
+ return Number.isNaN(parsed.getTime()) ? null : parsed;
399
+ }
400
+ /** 5xx - an unexpected server-side error; safe to retry with backoff. */
401
+ export class InternalServerError extends OxinsiderApiError {
402
+ code = "internal_error";
403
+ constructor(status, body) {
404
+ super(status, body);
405
+ this.name = "InternalServerError";
406
+ }
407
+ }
408
+ /**
409
+ * Construct the most specific `OxinsiderApiError` subclass for a failed
410
+ * response. Dispatch is by `error.reason` FIRST -- strictly more specific than the code,
411
+ * because the reason names the CAUSE where the code names only the class -- then by
412
+ * `error.code`, then a status-code heuristic, falling back to the base class for anything
413
+ * unrecognized so an unknown code is never silently dropped.
414
+ */
415
+ export function errorFromResponse(status, body, retryAfterSeconds = null) {
416
+ const parsed = extractApiErrorBody(body);
417
+ const code = parsed?.code;
418
+ // `reason` first: it is strictly more specific than `code` (#7209), and it is
419
+ // what carries the actionable distinction -- "not yet" vs "does not exist",
420
+ // "warming" vs "rate limiter down". Falling through to `code` here is what made
421
+ // the SDK re-assert the very lie the backend removed.
422
+ switch (parsed?.reason) {
423
+ case "pick_not_released":
424
+ return new PickNotReleasedError(status, body, retryAfterSeconds);
425
+ case "read_model_warming":
426
+ return new ReadModelWarmingError(status, body, retryAfterSeconds);
427
+ case "request_accounting_unavailable":
428
+ return new RequestAccountingUnavailableError(status, body, retryAfterSeconds);
429
+ case "database_unavailable":
430
+ return new DatabaseUnavailableError(status, body, retryAfterSeconds);
431
+ case "cursor_expired":
432
+ return new CursorExpiredError(status, body);
433
+ case "unknown_endpoint":
434
+ return new UnknownEndpointError(status, body);
435
+ case "trader_not_tracked":
436
+ return new TraderNotTrackedError(status, body);
437
+ case "idempotency_in_progress":
438
+ return new IdempotencyInProgressError(status, body);
439
+ case "webhook_delivery_in_progress":
440
+ return new WebhookDeliveryInProgressError(status, body);
441
+ case "sandbox_api_key":
442
+ return new SandboxApiKeyError(status, body);
443
+ case "api_key_in_query":
444
+ return new ApiKeyInQueryError(status, body);
445
+ default:
446
+ break;
447
+ }
448
+ switch (code) {
449
+ case "bad_request":
450
+ return new BadRequestError(status, body);
451
+ case "invalid_api_key":
452
+ return new InvalidApiKeyError(status, body);
453
+ case "subscription_required":
454
+ return new SubscriptionRequiredError(status, body);
455
+ case "forbidden":
456
+ return new ForbiddenError(status, body);
457
+ case "not_found":
458
+ return new NotFoundError(status, body);
459
+ case "account_locked":
460
+ return new AccountLockedError(status, body);
461
+ case "rate_limited":
462
+ return new RateLimitedError(status, body, retryAfterSeconds);
463
+ case "rate_limit_unavailable":
464
+ return new RateLimitUnavailableError(status, body, retryAfterSeconds);
465
+ case "internal_error":
466
+ return new InternalServerError(status, body);
467
+ default:
468
+ break;
469
+ }
470
+ // No (or unknown) error code: dispatch on the HTTP status so common
471
+ // failures still arrive as the expected subclass.
472
+ switch (status) {
473
+ case 400:
474
+ return new BadRequestError(status, body);
475
+ case 401:
476
+ return new InvalidApiKeyError(status, body);
477
+ case 402:
478
+ return new SubscriptionRequiredError(status, body);
479
+ case 404:
480
+ return new NotFoundError(status, body);
481
+ case 429:
482
+ return new RateLimitedError(status, body, retryAfterSeconds);
483
+ case 503:
484
+ return new RateLimitUnavailableError(status, body, retryAfterSeconds);
485
+ default:
486
+ if (status >= 500) {
487
+ return new InternalServerError(status, body);
488
+ }
489
+ return new OxinsiderApiError(status, body);
490
+ }
491
+ }
492
+ /** Pull the `error` object out of an envelope or a flat error body. */
493
+ export function extractApiErrorBody(body) {
494
+ if (!body || typeof body !== "object")
495
+ return null;
496
+ if ("object" in body &&
497
+ body.object === "error" &&
498
+ "error" in body &&
499
+ isApiErrorBody(body.error)) {
500
+ return body.error;
501
+ }
502
+ if (isApiErrorBody(body) && typeof body.code === "string") {
503
+ return body;
504
+ }
505
+ return null;
506
+ }
507
+ function extractApiErrorMeta(body) {
508
+ if (!body || typeof body !== "object")
509
+ return null;
510
+ if ("meta" in body) {
511
+ const meta = body.meta;
512
+ if (meta && typeof meta === "object") {
513
+ return meta;
514
+ }
515
+ }
516
+ return null;
517
+ }
518
+ function isApiErrorBody(body) {
519
+ return typeof body === "object" && body !== null;
520
+ }
521
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
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;QAC/C,IAAI,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;YACrC,OAAO,IAAoB,CAAC;QAC9B,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,cAAc,CAAC,IAAa;IACnC,OAAO,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI,CAAC;AACnD,CAAC"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * @0xinsider/sdk - official TypeScript SDK for the 0xinsider API.
3
+ *
4
+ * Analytics for Polymarket sports and esports markets: wallet grades, large
5
+ * trades, profitable-wallet flows, market intel/candles, the live SSE feed, and
6
+ * webhooks. Drift-tested
7
+ * against the public OpenAPI contract (`web/public/api/v1/openapi.json`).
8
+ *
9
+ * @example
10
+ * import { OxinsiderApiClient, paginate, streamFeed, verifySignature } from "@0xinsider/sdk";
11
+ *
12
+ * const client = new OxinsiderApiClient({ apiKey: process.env.OXINSIDER_API_KEY });
13
+ * const board = await client.listLeaderboard({ strategy: "swing_trader", limit: 100 });
14
+ */
15
+ export { API_CLIENT_OPERATIONS, DEFAULT_BASE_URL, DEFAULT_MAX_RETRIES, DEFAULT_TIMEOUT_MS, assertTrustedBaseUrl, composeSignals, GRADES, LEADERBOARD_STRATEGIES, OxinsiderApiClient, interpolatePath, isApiNotModifiedResponse, isListEnvelope, } from "./client.js";
16
+ export type { ApiClientMethod, ApiClientOperation, ApiClientOptions, ApiClientResponse, ApiEnvelope, ApiListEnvelope, ApiNotModifiedResponse, ApiOperationId, ApiQueryValue, ApiRequestOptions, AuthMode, CategorySkillStatus, CategorySkillStatusCounts, Grade, ListParams, PickQualifyingExpert, SportsEdgeSignalsParams, SportsEdgeObservationBoardUnavailableScope, SportsEdgeObservationBoardUpcomingStatus, SportsEdgeObservationCohort, SportsEdgeObservationDirectionalStatus, SportsEdgeObservationOutcomeIndex, SportsEdgeObservationProviderSource, SportsEdgeObservationSport, SportsEdgeObservationTopGrade, SportsEdgeObservationsParams, SportsEdgeObservationsResponse, TennisTour, WhaleTradeHistoryParams, LeaderboardListParams, LeaderboardStrategy, TrendingWalletsParams, WhaleTradeListParams, } from "./client.js";
17
+ export { API_ERROR_CODES, API_ERROR_REASONS, AccountLockedError, BadRequestError, CursorExpiredError, ForbiddenError, IdempotencyInProgressError, InternalServerError, InvalidApiKeyError, NotFoundError, OxinsiderApiError, PickNotReleasedError, RateLimitUnavailableError, RequestTimeoutError, RateLimitedError, ReadModelWarmingError, DatabaseUnavailableError, RequestAccountingUnavailableError, SandboxApiKeyError, ApiKeyInQueryError, SubscriptionRequiredError, TraderNotTrackedError, UnknownEndpointError, WebhookDeliveryInProgressError, errorFromResponse, extractApiErrorBody, } from "./errors.js";
18
+ export type { ApiErrorCode, ApiErrorMeta, ApiErrorReason, } from "./errors.js";
19
+ export { collect, paginate, paginatePages, paginationResumePoint, } from "./pagination.js";
20
+ export type { PaginateOptions, PaginationResumePoint } from "./pagination.js";
21
+ export { DEFAULT_MAX_STREAM_RECONNECTS, StreamReconnectsExhaustedError, consumeStream, parseSseFrame, streamFeed, streamFeedResilient, } from "./stream.js";
22
+ export type { FeedEnvelope, ResilientStreamOptions, ResyncMarker, StreamEvent, StreamFilters, StreamOptions, } from "./stream.js";
23
+ export { SIGNATURE_HEADER, SIGNATURE_TOLERANCE_SECONDS, TIMESTAMP_HEADER, WEBHOOK_EVENT_TYPES, computeSignature, parseWebhookEvent, verifySignature, } from "./webhooks.js";
24
+ export type { InsiderRadarFlagRaisedData, InsiderRadarFlagRaisedEvent, LargePositionsUpdatedData, LargePositionsUpdatedEvent, SmartMoneyFlowDetectedData, SmartMoneyFlowDetectedEvent, VerifySignatureInput, WalletGradeChangedData, WalletGradeChangedEvent, WebhookEvent, WebhookEventEnvelope, WhaleTradesInsertedData, WhaleTradesInsertedEvent, WhaleTraderSyncedData, WhaleTraderSyncedEvent, } from "./webhooks.js";
25
+ export type { AgentRegistration, ApiDiscovery, ApiError, BatchMarketIntelItem, BatchRateLimitMeta, BatchResponseMeta, BatchTraderItem, Candle, ContentSearchResult, CounterpartyAnalysis, CounterpartyExecution, CounterpartyMakerPage, CounterpartyMatchBreakdown, CounterpartyParticipant, CreateWebhookRequest, EventReplayEvent, EventReplayFreshness, EventReplayMeta, EventReplaySource, ExploreEntry, ExploreFacetValue, ExploreFacets, ExploreGroup, ExploreMarket, ExploreStandalone, ExportCompleteness, ExportCounts, ExportSourceRange, ExportVolumeReconciliation, LargeExportPolicy, LargePosition, LeaderboardEntry, MarketCandles, MarketIntel, MarketSearchResult, MarketSnapshot, MarketSnapshotFreshness, MarketSnapshotTopOfBook, MarketSnapshotTrust, McpJsonRpcError, OutcomeCandles, PickHolder, PickOfTheDay, PickOfTheDayArchive, PickOfTheDayArchiveDay, PickOfTheDayArchiveEntry, PickOfTheDayHitRate, PickSportsContext, PickSportsTeam, PickTrust, PlatformCapabilities, PlatformCapabilityStatus, Platforms, Position, PositionTimelineEvent, PotdEntryAuthorization, ProofPendingPickSlot, RadarFlag, ReportPayload, ReportReconciliation, ReportSnapshot, ReportSourceRange, ResponseMeta, ScheduledPickSlot, ScoreCell, ScoreFormat, SmartMoneyFlowMarket, SnapshotCompleteness, SnapshotState, SportsEdgeFunnelReport, SportsEdgeObservation, SportsEdgeObservationTerminalReason, SportsEdgeSignal, SportsEdgeSignalCategorySkill, SportsEdgeSportFunnelReport, Trader, TraderContext, TraderExportJob, TraderExportSnapshot, TraderPnl, TraderTrust, TrendingWallet, TrustCompleteness, TrustFreshness, TrustMetadata, TrustReconciliation, TrustSource, UpdateWebhookRequest, Usage, VerifyWebhookRequest, WebhookDelivery, WebhookEndpoint, WebhookEventDescriptor, WebhookRetryPolicy, WebhookStatus, WebhookVerification, WhaleTrade, WhaleTradeDetail, WhaleTradeHistoryMeta, OperationData, OperationQuery, } from "./schema.js";
26
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../sdk/src/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EACvB,uBAAuB,EACvB,mBAAmB,EACnB,eAAe,EACf,cAAc,EACd,UAAU,EACV,YAAY,EACZ,mBAAmB,EACnB,sBAAsB,EACtB,wBAAwB,EACxB,mBAAmB,EACnB,iBAAiB,EACjB,cAAc,EACd,SAAS,EACT,oBAAoB,EACpB,wBAAwB,EACxB,SAAS,EACT,QAAQ,EACR,qBAAqB,EACrB,sBAAsB,EACtB,oBAAoB,EACpB,SAAS,EACT,aAAa,EACb,oBAAoB,EACpB,cAAc,EACd,iBAAiB,EACjB,YAAY,EACZ,iBAAiB,EACjB,SAAS,EACT,WAAW,EACX,oBAAoB,EACpB,oBAAoB,EACpB,aAAa,EACb,sBAAsB,EACtB,qBAAqB,EACrB,mCAAmC,EACnC,gBAAgB,EAChB,6BAA6B,EAC7B,2BAA2B,EAC3B,MAAM,EACN,aAAa,EACb,eAAe,EACf,oBAAoB,EACpB,SAAS,EACT,WAAW,EACX,cAAc,EACd,iBAAiB,EACjB,cAAc,EACd,aAAa,EACb,mBAAmB,EACnB,WAAW,EACX,oBAAoB,EACpB,KAAK,EACL,oBAAoB,EACpB,eAAe,EACf,eAAe,EACf,sBAAsB,EACtB,kBAAkB,EAClB,aAAa,EACb,mBAAmB,EACnB,UAAU,EACV,gBAAgB,EAChB,qBAAqB,EACrB,aAAa,EACb,cAAc,GACf,MAAM,aAAa,CAAC"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * @0xinsider/sdk - official TypeScript SDK for the 0xinsider API.
3
+ *
4
+ * Analytics for Polymarket sports and esports markets: wallet grades, large
5
+ * trades, profitable-wallet flows, market intel/candles, the live SSE feed, and
6
+ * webhooks. Drift-tested
7
+ * against the public OpenAPI contract (`web/public/api/v1/openapi.json`).
8
+ *
9
+ * @example
10
+ * import { OxinsiderApiClient, paginate, streamFeed, verifySignature } from "@0xinsider/sdk";
11
+ *
12
+ * const client = new OxinsiderApiClient({ apiKey: process.env.OXINSIDER_API_KEY });
13
+ * const board = await client.listLeaderboard({ strategy: "swing_trader", limit: 100 });
14
+ */
15
+ // Client + core request/response types
16
+ export { API_CLIENT_OPERATIONS, DEFAULT_BASE_URL, DEFAULT_MAX_RETRIES, DEFAULT_TIMEOUT_MS, assertTrustedBaseUrl, composeSignals, GRADES, LEADERBOARD_STRATEGIES, OxinsiderApiClient, interpolatePath, isApiNotModifiedResponse, isListEnvelope, } from "./client.js";
17
+ // Error hierarchy
18
+ export { API_ERROR_CODES, API_ERROR_REASONS, AccountLockedError, BadRequestError, CursorExpiredError, ForbiddenError, IdempotencyInProgressError, InternalServerError, InvalidApiKeyError, NotFoundError, OxinsiderApiError, PickNotReleasedError, RateLimitUnavailableError, RequestTimeoutError, RateLimitedError, ReadModelWarmingError, DatabaseUnavailableError, RequestAccountingUnavailableError, SandboxApiKeyError, ApiKeyInQueryError, SubscriptionRequiredError, TraderNotTrackedError, UnknownEndpointError, WebhookDeliveryInProgressError, errorFromResponse, extractApiErrorBody, } from "./errors.js";
19
+ // Pagination
20
+ export { collect, paginate, paginatePages, paginationResumePoint, } from "./pagination.js";
21
+ // SSE stream
22
+ export { DEFAULT_MAX_STREAM_RECONNECTS, StreamReconnectsExhaustedError, consumeStream, parseSseFrame, streamFeed, streamFeedResilient, } from "./stream.js";
23
+ // Webhooks
24
+ export { SIGNATURE_HEADER, SIGNATURE_TOLERANCE_SECONDS, TIMESTAMP_HEADER, WEBHOOK_EVENT_TYPES, computeSignature, parseWebhookEvent, verifySignature, } from "./webhooks.js";
25
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../sdk/src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,uCAAuC;AACvC,OAAO,EACL,qBAAqB,EACrB,gBAAgB,EAChB,mBAAmB,EACnB,kBAAkB,EAClB,oBAAoB,EACpB,cAAc,EACd,MAAM,EACN,sBAAsB,EACtB,kBAAkB,EAClB,eAAe,EACf,wBAAwB,EACxB,cAAc,GACf,MAAM,aAAa,CAAC;AAqCrB,kBAAkB;AAClB,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,EACf,kBAAkB,EAClB,cAAc,EACd,0BAA0B,EAC1B,mBAAmB,EACnB,kBAAkB,EAClB,aAAa,EACb,iBAAiB,EACjB,oBAAoB,EACpB,yBAAyB,EACzB,mBAAmB,EACnB,gBAAgB,EAChB,qBAAqB,EACrB,wBAAwB,EACxB,iCAAiC,EACjC,kBAAkB,EAClB,kBAAkB,EAClB,yBAAyB,EACzB,qBAAqB,EACrB,oBAAoB,EACpB,8BAA8B,EAC9B,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,aAAa,CAAC;AAOrB,aAAa;AACb,OAAO,EACL,OAAO,EACP,QAAQ,EACR,aAAa,EACb,qBAAqB,GACtB,MAAM,iBAAiB,CAAC;AAGzB,aAAa;AACb,OAAO,EACL,6BAA6B,EAC7B,8BAA8B,EAC9B,aAAa,EACb,aAAa,EACb,UAAU,EACV,mBAAmB,GACpB,MAAM,aAAa,CAAC;AAUrB,WAAW;AACX,OAAO,EACL,gBAAgB,EAChB,2BAA2B,EAC3B,gBAAgB,EAChB,mBAAmB,EACnB,gBAAgB,EAChB,iBAAiB,EACjB,eAAe,GAChB,MAAM,eAAe,CAAC"}