@0xinsider/mcp 1.2.3 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +93 -1
- package/dist/catalog.generated.d.ts +4 -0
- package/dist/catalog.generated.d.ts.map +1 -1
- package/dist/catalog.generated.js +5 -0
- package/dist/catalog.generated.js.map +1 -1
- package/dist/cli-lib.d.ts.map +1 -1
- package/dist/cli-lib.js +9 -5
- package/dist/cli-lib.js.map +1 -1
- package/dist/cli.js +6 -1
- package/dist/cli.js.map +1 -1
- package/dist/constants.d.ts +1 -1
- package/dist/constants.js +1 -1
- package/dist/product-cli/errors.d.ts +7 -0
- package/dist/product-cli/errors.d.ts.map +1 -0
- package/dist/product-cli/errors.js +13 -0
- package/dist/product-cli/errors.js.map +1 -0
- package/dist/product-cli/index.d.ts +4 -0
- package/dist/product-cli/index.d.ts.map +1 -0
- package/dist/product-cli/index.js +372 -0
- package/dist/product-cli/index.js.map +1 -0
- package/dist/product-cli/oauth.d.ts +10 -0
- package/dist/product-cli/oauth.d.ts.map +1 -0
- package/dist/product-cli/oauth.js +245 -0
- package/dist/product-cli/oauth.js.map +1 -0
- package/dist/product-cli/storage.d.ts +20 -0
- package/dist/product-cli/storage.d.ts.map +1 -0
- package/dist/product-cli/storage.js +149 -0
- package/dist/product-cli/storage.js.map +1 -0
- package/dist/sdk/client.d.ts +765 -0
- package/dist/sdk/client.d.ts.map +1 -0
- package/dist/sdk/client.js +974 -0
- package/dist/sdk/client.js.map +1 -0
- package/dist/sdk/errors.d.ts +313 -0
- package/dist/sdk/errors.d.ts.map +1 -0
- package/dist/sdk/errors.js +521 -0
- package/dist/sdk/errors.js.map +1 -0
- package/dist/sdk/index.d.ts +26 -0
- package/dist/sdk/index.d.ts.map +1 -0
- package/dist/sdk/index.js +25 -0
- package/dist/sdk/index.js.map +1 -0
- package/dist/sdk/pagination.d.ts +76 -0
- package/dist/sdk/pagination.d.ts.map +1 -0
- package/dist/sdk/pagination.js +106 -0
- package/dist/sdk/pagination.js.map +1 -0
- package/dist/sdk/schema.d.ts +2372 -0
- package/dist/sdk/schema.d.ts.map +1 -0
- package/dist/sdk/schema.js +7 -0
- package/dist/sdk/schema.js.map +1 -0
- package/dist/sdk/stream.d.ts +182 -0
- package/dist/sdk/stream.d.ts.map +1 -0
- package/dist/sdk/stream.js +391 -0
- package/dist/sdk/stream.js.map +1 -0
- package/dist/sdk/webhooks.d.ts +163 -0
- package/dist/sdk/webhooks.d.ts.map +1 -0
- package/dist/sdk/webhooks.js +122 -0
- package/dist/sdk/webhooks.js.map +1 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +2 -1
- package/dist/server.js.map +1 -1
- package/dist/tools/get-trending-wallets.js +4 -4
- package/dist/tools/get-trending-wallets.js.map +1 -1
- package/dist/tools/read-parity.d.ts +1 -0
- package/dist/tools/read-parity.d.ts.map +1 -1
- package/dist/tools/read-parity.js +27 -0
- package/dist/tools/read-parity.js.map +1 -1
- package/package.json +6 -3
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cursor pagination over the Stripe-style V1 list envelope.
|
|
3
|
+
*
|
|
4
|
+
* Every list endpoint returns `{ object: "list", data, has_more, next_cursor }`.
|
|
5
|
+
* `paginate()` yields each `data[]` item across pages, following `next_cursor`
|
|
6
|
+
* while `has_more` is true. `paginatePages()` yields whole pages when you need
|
|
7
|
+
* the envelope (e.g. to read `meta.cost` or `total`).
|
|
8
|
+
*
|
|
9
|
+
* The loop stops on the first page where `has_more` is false OR `next_cursor`
|
|
10
|
+
* is null/absent, so a buggy server that returns `has_more: true` with no
|
|
11
|
+
* cursor cannot spin forever.
|
|
12
|
+
*/
|
|
13
|
+
import type { ApiListEnvelope, ApiOperationId, ApiRequestOptions, ListParams, OxinsiderApiClient } from "./client.js";
|
|
14
|
+
export interface PaginateOptions {
|
|
15
|
+
/** Path parameters for templated list paths (e.g. `{ id }` for deliveries). */
|
|
16
|
+
path?: ApiRequestOptions["path"];
|
|
17
|
+
/** Initial query params (filters, `limit`, an initial `cursor`, ...). */
|
|
18
|
+
query?: ListParams;
|
|
19
|
+
/** Forwarded to each request for cooperative cancellation. */
|
|
20
|
+
signal?: AbortSignal;
|
|
21
|
+
/** Hard cap on pages fetched; defaults to unbounded. */
|
|
22
|
+
maxPages?: number;
|
|
23
|
+
}
|
|
24
|
+
/** Where an interrupted walk can pick up again; see `paginationResumePoint`. */
|
|
25
|
+
export interface PaginationResumePoint {
|
|
26
|
+
/**
|
|
27
|
+
* The cursor of the page that failed. Pass it back as `query.cursor` to
|
|
28
|
+
* refetch that page and continue. `undefined` means the first page failed,
|
|
29
|
+
* so start the walk again without a cursor.
|
|
30
|
+
*/
|
|
31
|
+
cursor: string | undefined;
|
|
32
|
+
/** Pages already yielded before the failure. */
|
|
33
|
+
pagesFetched: number;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The resume point of an error thrown out of `paginatePages`, `paginate` or
|
|
37
|
+
* `collect`, or `undefined` for any other error (#14281).
|
|
38
|
+
*
|
|
39
|
+
* Each page request already retries a 429 or 5xx (`maxRetries`). When those
|
|
40
|
+
* retries are exhausted the ORIGINAL error is rethrown unchanged, so an
|
|
41
|
+
* `instanceof RateLimitedError` check keeps working, and this function recovers
|
|
42
|
+
* the cursor that the throw would otherwise have destroyed with the generator.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* try {
|
|
46
|
+
* for await (const trade of paginate(client, "listWhaleTrades", { query })) handle(trade);
|
|
47
|
+
* } catch (err) {
|
|
48
|
+
* const resume = paginationResumePoint(err);
|
|
49
|
+
* if (resume) later(() => paginate(client, "listWhaleTrades", { query: { ...query, cursor: resume.cursor } }));
|
|
50
|
+
* }
|
|
51
|
+
*/
|
|
52
|
+
export declare function paginationResumePoint(error: unknown): PaginationResumePoint | undefined;
|
|
53
|
+
/**
|
|
54
|
+
* Async-iterate whole list pages, following `next_cursor` until exhausted.
|
|
55
|
+
* Yields the full envelope so callers can read `meta`/`total`/`has_more`.
|
|
56
|
+
* A failed page throws its original error; `paginationResumePoint(error)`
|
|
57
|
+
* returns the cursor to continue from.
|
|
58
|
+
*/
|
|
59
|
+
export declare function paginatePages<T>(client: OxinsiderApiClient, operationId: ApiOperationId, options?: PaginateOptions): AsyncGenerator<ApiListEnvelope<T>, void, undefined>;
|
|
60
|
+
/**
|
|
61
|
+
* Async-iterate individual `data[]` items across all pages.
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* for await (const trade of paginate<WhaleTrade>(client, "listWhaleTrades", {
|
|
65
|
+
* query: { min_grade: "S", limit: 100 },
|
|
66
|
+
* })) {
|
|
67
|
+
* handle(trade);
|
|
68
|
+
* }
|
|
69
|
+
*/
|
|
70
|
+
export declare function paginate<T>(client: OxinsiderApiClient, operationId: ApiOperationId, options?: PaginateOptions): AsyncGenerator<T, void, undefined>;
|
|
71
|
+
/**
|
|
72
|
+
* Collect every item across all pages into one array. Convenience over
|
|
73
|
+
* `paginate()` for small result sets; prefer the iterator for large ones.
|
|
74
|
+
*/
|
|
75
|
+
export declare function collect<T>(client: OxinsiderApiClient, operationId: ApiOperationId, options?: PaginateOptions): Promise<T[]>;
|
|
76
|
+
//# sourceMappingURL=pagination.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pagination.d.ts","sourceRoot":"","sources":["../../../sdk/src/pagination.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EACV,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,UAAU,EACV,kBAAkB,EACnB,MAAM,aAAa,CAAC;AAErB,MAAM,WAAW,eAAe;IAC9B,+EAA+E;IAC/E,IAAI,CAAC,EAAE,iBAAiB,CAAC,MAAM,CAAC,CAAC;IACjC,yEAAyE;IACzE,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,8DAA8D;IAC9D,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,wDAAwD;IACxD,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,gFAAgF;AAChF,MAAM,WAAW,qBAAqB;IACpC;;;;OAIG;IACH,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,gDAAgD;IAChD,YAAY,EAAE,MAAM,CAAC;CACtB;AAID;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,OAAO,GACb,qBAAqB,GAAG,SAAS,CAInC;AAED;;;;;GAKG;AACH,wBAAuB,aAAa,CAAC,CAAC,EACpC,MAAM,EAAE,kBAAkB,EAC1B,WAAW,EAAE,cAAc,EAC3B,OAAO,GAAE,eAAoB,GAC5B,cAAc,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,CAAC,CAsCrD;AAED;;;;;;;;;GASG;AACH,wBAAuB,QAAQ,CAAC,CAAC,EAC/B,MAAM,EAAE,kBAAkB,EAC1B,WAAW,EAAE,cAAc,EAC3B,OAAO,GAAE,eAAoB,GAC5B,cAAc,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,CAAC,CAMpC;AAED;;;GAGG;AACH,wBAAsB,OAAO,CAAC,CAAC,EAC7B,MAAM,EAAE,kBAAkB,EAC1B,WAAW,EAAE,cAAc,EAC3B,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,CAAC,EAAE,CAAC,CAMd"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cursor pagination over the Stripe-style V1 list envelope.
|
|
3
|
+
*
|
|
4
|
+
* Every list endpoint returns `{ object: "list", data, has_more, next_cursor }`.
|
|
5
|
+
* `paginate()` yields each `data[]` item across pages, following `next_cursor`
|
|
6
|
+
* while `has_more` is true. `paginatePages()` yields whole pages when you need
|
|
7
|
+
* the envelope (e.g. to read `meta.cost` or `total`).
|
|
8
|
+
*
|
|
9
|
+
* The loop stops on the first page where `has_more` is false OR `next_cursor`
|
|
10
|
+
* is null/absent, so a buggy server that returns `has_more: true` with no
|
|
11
|
+
* cursor cannot spin forever.
|
|
12
|
+
*/
|
|
13
|
+
const resumePoints = new WeakMap();
|
|
14
|
+
/**
|
|
15
|
+
* The resume point of an error thrown out of `paginatePages`, `paginate` or
|
|
16
|
+
* `collect`, or `undefined` for any other error (#14281).
|
|
17
|
+
*
|
|
18
|
+
* Each page request already retries a 429 or 5xx (`maxRetries`). When those
|
|
19
|
+
* retries are exhausted the ORIGINAL error is rethrown unchanged, so an
|
|
20
|
+
* `instanceof RateLimitedError` check keeps working, and this function recovers
|
|
21
|
+
* the cursor that the throw would otherwise have destroyed with the generator.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* try {
|
|
25
|
+
* for await (const trade of paginate(client, "listWhaleTrades", { query })) handle(trade);
|
|
26
|
+
* } catch (err) {
|
|
27
|
+
* const resume = paginationResumePoint(err);
|
|
28
|
+
* if (resume) later(() => paginate(client, "listWhaleTrades", { query: { ...query, cursor: resume.cursor } }));
|
|
29
|
+
* }
|
|
30
|
+
*/
|
|
31
|
+
export function paginationResumePoint(error) {
|
|
32
|
+
return typeof error === "object" && error !== null
|
|
33
|
+
? resumePoints.get(error)
|
|
34
|
+
: undefined;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Async-iterate whole list pages, following `next_cursor` until exhausted.
|
|
38
|
+
* Yields the full envelope so callers can read `meta`/`total`/`has_more`.
|
|
39
|
+
* A failed page throws its original error; `paginationResumePoint(error)`
|
|
40
|
+
* returns the cursor to continue from.
|
|
41
|
+
*/
|
|
42
|
+
export async function* paginatePages(client, operationId, options = {}) {
|
|
43
|
+
const { path, query, signal, maxPages } = options;
|
|
44
|
+
let cursor = query?.cursor;
|
|
45
|
+
let pages = 0;
|
|
46
|
+
for (;;) {
|
|
47
|
+
if (signal?.aborted) {
|
|
48
|
+
throw signal.reason instanceof Error
|
|
49
|
+
? signal.reason
|
|
50
|
+
: new DOMException("The pagination was aborted", "AbortError");
|
|
51
|
+
}
|
|
52
|
+
let page;
|
|
53
|
+
try {
|
|
54
|
+
page = await client.list(operationId, {
|
|
55
|
+
path,
|
|
56
|
+
query: { ...query, ...(cursor === undefined ? {} : { cursor }) },
|
|
57
|
+
signal,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
if (typeof error === "object" && error !== null && !resumePoints.has(error)) {
|
|
62
|
+
resumePoints.set(error, { cursor, pagesFetched: pages });
|
|
63
|
+
}
|
|
64
|
+
throw error;
|
|
65
|
+
}
|
|
66
|
+
yield page;
|
|
67
|
+
pages += 1;
|
|
68
|
+
const next = page.next_cursor;
|
|
69
|
+
if (!page.has_more || next === null || next === undefined || next === "") {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
if (maxPages !== undefined && pages >= maxPages) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
cursor = next;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Async-iterate individual `data[]` items across all pages.
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* for await (const trade of paginate<WhaleTrade>(client, "listWhaleTrades", {
|
|
83
|
+
* query: { min_grade: "S", limit: 100 },
|
|
84
|
+
* })) {
|
|
85
|
+
* handle(trade);
|
|
86
|
+
* }
|
|
87
|
+
*/
|
|
88
|
+
export async function* paginate(client, operationId, options = {}) {
|
|
89
|
+
for await (const page of paginatePages(client, operationId, options)) {
|
|
90
|
+
for (const item of page.data) {
|
|
91
|
+
yield item;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Collect every item across all pages into one array. Convenience over
|
|
97
|
+
* `paginate()` for small result sets; prefer the iterator for large ones.
|
|
98
|
+
*/
|
|
99
|
+
export async function collect(client, operationId, options = {}) {
|
|
100
|
+
const items = [];
|
|
101
|
+
for await (const item of paginate(client, operationId, options)) {
|
|
102
|
+
items.push(item);
|
|
103
|
+
}
|
|
104
|
+
return items;
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=pagination.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pagination.js","sourceRoot":"","sources":["../../../sdk/src/pagination.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAiCH,MAAM,YAAY,GAAG,IAAI,OAAO,EAAiC,CAAC;AAElE;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,qBAAqB,CACnC,KAAc;IAEd,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI;QAChD,CAAC,CAAC,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC;QACzB,CAAC,CAAC,SAAS,CAAC;AAChB,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,SAAS,CAAC,CAAC,aAAa,CAClC,MAA0B,EAC1B,WAA2B,EAC3B,OAAO,GAAoB,EAAE;IAE7B,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;IAClD,IAAI,MAAM,GAAuB,KAAK,EAAE,MAAM,CAAC;IAC/C,IAAI,KAAK,GAAG,CAAC,CAAC;IAEd,SAAS,CAAC;QACR,IAAI,MAAM,EAAE,OAAO,EAAE,CAAC;YACpB,MAAM,MAAM,CAAC,MAAM,YAAY,KAAK;gBAClC,CAAC,CAAC,MAAM,CAAC,MAAM;gBACf,CAAC,CAAC,IAAI,YAAY,CAAC,4BAA4B,EAAE,YAAY,CAAC,CAAC;QACnE,CAAC;QAED,IAAI,IAAwB,CAAC;QAC7B,IAAI,CAAC;YACH,IAAI,GAAG,MAAM,MAAM,CAAC,IAAI,CAAI,WAAW,EAAE;gBACvC,IAAI;gBACJ,KAAK,EAAE,EAAE,GAAG,KAAK,EAAE,GAAG,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,E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