// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { AbstractPage, Response, APIClient, FinalRequestOptions, PageInfo } from './core'; export interface DatastoresPageResponse { datastores: Array; next_cursor: string; } export interface DatastoresPageParams { cursor?: string; limit?: number; } export class DatastoresPage extends AbstractPage implements DatastoresPageResponse { datastores: Array; next_cursor: string; constructor( client: APIClient, response: Response, body: DatastoresPageResponse, options: FinalRequestOptions, ) { super(client, response, body, options); this.datastores = body.datastores || []; this.next_cursor = body.next_cursor || ''; } getPaginatedItems(): Item[] { return this.datastores ?? []; } // @deprecated Please use `nextPageInfo()` instead nextPageParams(): Partial | null { const info = this.nextPageInfo(); if (!info) return null; if ('params' in info) return info.params; const params = Object.fromEntries(info.url.searchParams); if (!Object.keys(params).length) return null; return params; } nextPageInfo(): PageInfo | null { const cursor = this.next_cursor; if (!cursor) { return null; } return { params: { cursor, }, }; } } export interface DocumentsPageResponse { documents: Array; next_cursor: string; } export interface DocumentsPageParams { cursor?: string; limit?: number; } export class DocumentsPage extends AbstractPage implements DocumentsPageResponse { documents: Array; next_cursor: string; constructor( client: APIClient, response: Response, body: DocumentsPageResponse, options: FinalRequestOptions, ) { super(client, response, body, options); this.documents = body.documents || []; this.next_cursor = body.next_cursor || ''; } getPaginatedItems(): Item[] { return this.documents ?? []; } // @deprecated Please use `nextPageInfo()` instead nextPageParams(): Partial | null { const info = this.nextPageInfo(); if (!info) return null; if ('params' in info) return info.params; const params = Object.fromEntries(info.url.searchParams); if (!Object.keys(params).length) return null; return params; } nextPageInfo(): PageInfo | null { const cursor = this.next_cursor; if (!cursor) { return null; } return { params: { cursor, }, }; } } export interface UsersPageResponse { users: Array; next_cursor: string; } export interface UsersPageParams { cursor?: string; limit?: number; } export class UsersPage extends AbstractPage implements UsersPageResponse { users: Array; next_cursor: string; constructor( client: APIClient, response: Response, body: UsersPageResponse, options: FinalRequestOptions, ) { super(client, response, body, options); this.users = body.users || []; this.next_cursor = body.next_cursor || ''; } getPaginatedItems(): Item[] { return this.users ?? []; } // @deprecated Please use `nextPageInfo()` instead nextPageParams(): Partial | null { const info = this.nextPageInfo(); if (!info) return null; if ('params' in info) return info.params; const params = Object.fromEntries(info.url.searchParams); if (!Object.keys(params).length) return null; return params; } nextPageInfo(): PageInfo | null { const cursor = this.next_cursor; if (!cursor) { return null; } return { params: { cursor, }, }; } } export interface PageResponse { agents: Array; next_cursor: string; } export interface PageParams { cursor?: string; limit?: number; } export class Page extends AbstractPage implements PageResponse { agents: Array; next_cursor: string; constructor(client: APIClient, response: Response, body: PageResponse, options: FinalRequestOptions) { super(client, response, body, options); this.agents = body.agents || []; this.next_cursor = body.next_cursor || ''; } getPaginatedItems(): Item[] { return this.agents ?? []; } // @deprecated Please use `nextPageInfo()` instead nextPageParams(): Partial | null { const info = this.nextPageInfo(); if (!info) return null; if ('params' in info) return info.params; const params = Object.fromEntries(info.url.searchParams); if (!Object.keys(params).length) return null; return params; } nextPageInfo(): PageInfo | null { const cursor = this.next_cursor; if (!cursor) { return null; } return { params: { cursor, }, }; } } export interface ContentsPageResponse { data: Array; } export interface ContentsPageParams { limit?: number; offset?: number; } export class ContentsPage extends AbstractPage implements ContentsPageResponse { data: Array; constructor( client: APIClient, response: Response, body: ContentsPageResponse, options: FinalRequestOptions, ) { super(client, response, body, options); this.data = body.data || []; } getPaginatedItems(): Item[] { return this.data ?? []; } // @deprecated Please use `nextPageInfo()` instead nextPageParams(): Partial | null { const info = this.nextPageInfo(); if (!info) return null; if ('params' in info) return info.params; const params = Object.fromEntries(info.url.searchParams); if (!Object.keys(params).length) return null; return params; } nextPageInfo(): PageInfo | null { const offset = (this.options.query as ContentsPageParams).offset ?? 0; const length = this.getPaginatedItems().length; const currentCount = offset + length; return { params: { offset: currentCount } }; } }