|
1 | 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. |
2 | 2 |
|
3 | 3 | import { AbstractPage, Response, APIClient, FinalRequestOptions, PageInfo } from './core'; |
4 | | -import * as StainlessPageResourceAPI from './resources/stainless-page-resource'; |
5 | 4 |
|
6 | 5 | export interface V4PagePaginationResponse<Item> { |
7 | 6 | result: V4PagePaginationResponse.Result<Item>; |
@@ -195,78 +194,6 @@ export class CursorPagination<Item> extends AbstractPage<Item> implements Cursor |
195 | 194 | } |
196 | 195 | } |
197 | 196 |
|
198 | | -export interface CursorPaginationAfterResponse<Item> { |
199 | | - result: Array<Item>; |
200 | | - |
201 | | - result_info: CursorPaginationAfterResponse.ResultInfo; |
202 | | -} |
203 | | - |
204 | | -export namespace CursorPaginationAfterResponse { |
205 | | - export interface ResultInfo { |
206 | | - cursors?: StainlessPageResourceAPI.ResultInfo.Cursors; |
207 | | - } |
208 | | - |
209 | | - export namespace ResultInfo { |
210 | | - export interface Cursors { |
211 | | - after?: string; |
212 | | - } |
213 | | - } |
214 | | -} |
215 | | - |
216 | | -export interface CursorPaginationAfterParams { |
217 | | - cursor?: string; |
218 | | - |
219 | | - per_page?: number; |
220 | | -} |
221 | | - |
222 | | -export class CursorPaginationAfter<Item> |
223 | | - extends AbstractPage<Item> |
224 | | - implements CursorPaginationAfterResponse<Item> |
225 | | -{ |
226 | | - result: Array<Item>; |
227 | | - |
228 | | - result_info: CursorPaginationAfterResponse.ResultInfo; |
229 | | - |
230 | | - constructor( |
231 | | - client: APIClient, |
232 | | - response: Response, |
233 | | - body: CursorPaginationAfterResponse<Item>, |
234 | | - options: FinalRequestOptions, |
235 | | - ) { |
236 | | - super(client, response, body, options); |
237 | | - |
238 | | - this.result = body.result || []; |
239 | | - this.result_info = body.result_info || {}; |
240 | | - } |
241 | | - |
242 | | - getPaginatedItems(): Item[] { |
243 | | - return this.result ?? []; |
244 | | - } |
245 | | - |
246 | | - // @deprecated Please use `nextPageInfo()` instead |
247 | | - nextPageParams(): Partial<CursorPaginationAfterParams> | null { |
248 | | - const info = this.nextPageInfo(); |
249 | | - if (!info) return null; |
250 | | - if ('params' in info) return info.params; |
251 | | - const params = Object.fromEntries(info.url.searchParams); |
252 | | - if (!Object.keys(params).length) return null; |
253 | | - return params; |
254 | | - } |
255 | | - |
256 | | - nextPageInfo(): PageInfo | null { |
257 | | - const cursor = this.result_info?.cursors?.after; |
258 | | - if (!cursor) { |
259 | | - return null; |
260 | | - } |
261 | | - |
262 | | - return { |
263 | | - params: { |
264 | | - cursor, |
265 | | - }, |
266 | | - }; |
267 | | - } |
268 | | -} |
269 | | - |
270 | 197 | export interface CursorLimitPaginationResponse<Item> { |
271 | 198 | result: Array<Item>; |
272 | 199 |
|
|
0 commit comments