/opt/canhelp/node_modules/@anthropic-ai/sdk/core
NameSizeModeActions
api-promise.d.mts24260644editdlrm
api-promise.d.mts.map15040644editdlrm
api-promise.d.ts24220644editdlrm
api-promise.d.ts.map15030644editdlrm
api-promise.js31890644editdlrm
api-promise.js.map17160644editdlrm
api-promise.mjs30800644editdlrm
api-promise.mjs.map17200644editdlrm
error.d.mts20400644editdlrm
error.d.mts.map16980644editdlrm
error.d.ts20390644editdlrm
error.d.ts.map16970644editdlrm
error.js43770644editdlrm
error.js.map32860644editdlrm
error.mjs34010644editdlrm
error.mjs.map31880644editdlrm
pagination.d.mts39140644editdlrm
pagination.d.mts.map31810644editdlrm
pagination.d.ts39090644editdlrm
pagination.d.ts.map31800644editdlrm
pagination.js58350644editdlrm
pagination.js.map45840644editdlrm
pagination.mjs54770644editdlrm
pagination.mjs.map45450644editdlrm
resource.d.mts2100644editdlrm
resource.d.mts.map2170644editdlrm
resource.d.ts2080644editdlrm
resource.d.ts.map2160644editdlrm
resource.js3500644editdlrm
resource.js.map2240644editdlrm
resource.mjs2160644editdlrm
resource.mjs.map2160644editdlrm
streaming.d.mts14860644editdlrm
streaming.d.mts.map10500644editdlrm
streaming.d.ts14830644editdlrm
streaming.d.ts.map10490644editdlrm
streaming.js106310644editdlrm
streaming.js.map83300644editdlrm
streaming.mjs103860644editdlrm
streaming.mjs.map83390644editdlrm
uploads.d.mts1650644editdlrm
uploads.d.mts.map1740644editdlrm
uploads.d.ts1620644editdlrm
uploads.d.ts.map1730644editdlrm
uploads.js2990644editdlrm
uploads.js.map1470644editdlrm
uploads.mjs860644editdlrm
uploads.mjs.map1320644editdlrm
Edit: /opt/canhelp/node_modules/@anthropic-ai/sdk/core/pagination.js (5835B)
"use strict"; // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. var _AbstractPage_client; Object.defineProperty(exports, "__esModule", { value: true }); exports.PageCursor = exports.TokenPage = exports.Page = exports.PagePromise = exports.AbstractPage = void 0; const tslib_1 = require("../internal/tslib.js"); const error_1 = require("./error.js"); const parse_1 = require("../internal/parse.js"); const api_promise_1 = require("./api-promise.js"); const values_1 = require("../internal/utils/values.js"); class AbstractPage { constructor(client, response, body, options) { _AbstractPage_client.set(this, void 0); tslib_1.__classPrivateFieldSet(this, _AbstractPage_client, client, "f"); this.options = options; this.response = response; this.body = body; } hasNextPage() { const items = this.getPaginatedItems(); if (!items.length) return false; return this.nextPageRequestOptions() != null; } async getNextPage() { const nextOptions = this.nextPageRequestOptions(); if (!nextOptions) { throw new error_1.AnthropicError('No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`.'); } return await tslib_1.__classPrivateFieldGet(this, _AbstractPage_client, "f").requestAPIList(this.constructor, nextOptions); } async *iterPages() { let page = this; yield page; while (page.hasNextPage()) { page = await page.getNextPage(); yield page; } } async *[(_AbstractPage_client = new WeakMap(), Symbol.asyncIterator)]() { for await (const page of this.iterPages()) { for (const item of page.getPaginatedItems()) { yield item; } } } } exports.AbstractPage = AbstractPage; /** * This subclass of Promise will resolve to an instantiated Page once the request completes. * * It also implements AsyncIterable to allow auto-paginating iteration on an unawaited list call, eg: * * for await (const item of client.items.list()) { * console.log(item) * } */ class PagePromise extends api_promise_1.APIPromise { constructor(client, request, Page) { super(client, request, async (client, props) => new Page(client, props.response, await (0, parse_1.defaultParseResponse)(client, props), props.options)); } /** * Allow auto-paginating iteration on an unawaited list call, eg: * * for await (const item of client.items.list()) { * console.log(item) * } */ async *[Symbol.asyncIterator]() { const page = await this; for await (const item of page) { yield item; } } } exports.PagePromise = PagePromise; class Page extends AbstractPage { constructor(client, response, body, options) { super(client, response, body, options); this.data = body.data || []; this.has_more = body.has_more || false; this.first_id = body.first_id || null; this.last_id = body.last_id || null; } getPaginatedItems() { return this.data ?? []; } hasNextPage() { if (this.has_more === false) { return false; } return super.hasNextPage(); } nextPageRequestOptions() { if (this.options.query?.['before_id']) { // in reverse const first_id = this.first_id; if (!first_id) { return null; } return { ...this.options, query: { ...(0, values_1.maybeObj)(this.options.query), before_id: first_id, }, }; } const cursor = this.last_id; if (!cursor) { return null; } return { ...this.options, query: { ...(0, values_1.maybeObj)(this.options.query), after_id: cursor, }, }; } } exports.Page = Page; class TokenPage extends AbstractPage { constructor(client, response, body, options) { super(client, response, body, options); this.data = body.data || []; this.has_more = body.has_more || false; this.next_page = body.next_page || null; } getPaginatedItems() { return this.data ?? []; } hasNextPage() { if (this.has_more === false) { return false; } return super.hasNextPage(); } nextPageRequestOptions() { const cursor = this.next_page; if (!cursor) { return null; } return { ...this.options, query: { ...(0, values_1.maybeObj)(this.options.query), page_token: cursor, }, }; } } exports.TokenPage = TokenPage; class PageCursor extends AbstractPage { constructor(client, response, body, options) { super(client, response, body, options); this.data = body.data || []; this.has_more = body.has_more || false; this.next_page = body.next_page || null; } getPaginatedItems() { return this.data ?? []; } hasNextPage() { if (this.has_more === false) { return false; } return super.hasNextPage(); } nextPageRequestOptions() { const cursor = this.next_page; if (!cursor) { return null; } return { ...this.options, query: { ...(0, values_1.maybeObj)(this.options.query), page: cursor, }, }; } } exports.PageCursor = PageCursor; //# sourceMappingURL=pagination.js.map