Skip to content

@ralphschuler.ai function caller.index.<internal>.PagePromise

github-actions edited this page Nov 26, 2023 · 1 revision

Class: PagePromise<PageClass, Item>

index.<internal>.PagePromise

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) }

Type parameters

Name Type
PageClass extends AbstractPage<Item>
Item ReturnType<PageClass["getPaginatedItems"]>[number]

Hierarchy

Implements

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new PagePromise<PageClass, Item>(client, request, Page): PagePromise<PageClass, Item>

Type parameters

Name Type
PageClass extends AbstractPage<Item>
Item ReturnType<PageClass["getPaginatedItems"]>[number]

Parameters

Name Type
client APIClient
request Promise<APIResponseProps>
Page (...args: [client: APIClient, response: Response, body: unknown, options: FinalRequestOptions<Readable | Record<string, unknown>>]) => PageClass

Returns

PagePromise<PageClass, Item>

Overrides

APIPromise.constructor

Defined in

node_modules/openai/core.d.ts:161

Properties

[toStringTag]

Readonly [toStringTag]: string

Inherited from

APIPromise.[toStringTag]

Defined in

node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts:176


[species]

Static Readonly [species]: PromiseConstructor

Inherited from

APIPromise.[species]

Defined in

node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts:180

Methods

[asyncIterator]

[asyncIterator](): AsyncGenerator<Awaited<Item>, void, unknown>

Allow auto-paginating iteration on an unawaited list call, eg:

for await (const item of client.items.list()) { console.log(item) }

Returns

AsyncGenerator<Awaited<Item>, void, unknown>

Implementation of

AsyncIterable.[asyncIterator]

Defined in

node_modules/openai/core.d.ts:169


_thenUnwrap

_thenUnwrap<U>(transform): APIPromise<U>

Type parameters

Name
U

Parameters

Name Type
transform (data: PageClass) => U

Returns

APIPromise<U>

Inherited from

APIPromise._thenUnwrap

Defined in

node_modules/openai/core.d.ts:24


asResponse

asResponse(): Promise<Response>

Gets the raw Response instance instead of parsing the response data.

If you want to parse the response body but still get the Response instance, you can use ().

👋 Getting the wrong TypeScript type for Response? Try setting "moduleResolution": "NodeNext" if you can, or add one of these imports before your first import … from 'openai':

  • import 'openai/shims/node' (if you're running on Node)
  • import 'openai/shims/web' (otherwise)

Returns

Promise<Response>

Inherited from

APIPromise.asResponse

Defined in

node_modules/openai/core.d.ts:38


catch

catch<TResult>(onrejected?): Promise<PageClass | TResult>

Type parameters

Name Type
TResult never

Parameters

Name Type
onrejected? null | (reason: any) => TResult | PromiseLike<TResult>

Returns

Promise<PageClass | TResult>

Inherited from

APIPromise.catch

Defined in

node_modules/openai/core.d.ts:58


finally

finally(onfinally?): Promise<PageClass>

Parameters

Name Type
onfinally? null | () => void

Returns

Promise<PageClass>

Inherited from

APIPromise.finally

Defined in

node_modules/openai/core.d.ts:59


then

then<TResult1, TResult2>(onfulfilled?, onrejected?): Promise<TResult1 | TResult2>

Type parameters

Name Type
TResult1 PageClass
TResult2 never

Parameters

Name Type
onfulfilled? null | (value: PageClass) => TResult1 | PromiseLike<TResult1>
onrejected? null | (reason: any) => TResult2 | PromiseLike<TResult2>

Returns

Promise<TResult1 | TResult2>

Inherited from

APIPromise.then

Defined in

node_modules/openai/core.d.ts:57


withResponse

withResponse(): Promise<{ data: PageClass ; response: Response }>

Gets the parsed response data and the raw Response instance.

If you just want to get the raw Response instance without parsing it, you can use ().

👋 Getting the wrong TypeScript type for Response? Try setting "moduleResolution": "NodeNext" if you can, or add one of these imports before your first import … from 'openai':

  • import 'openai/shims/node' (if you're running on Node)
  • import 'openai/shims/web' (otherwise)

Returns

Promise<{ data: PageClass ; response: Response }>

Inherited from

APIPromise.withResponse

Defined in

node_modules/openai/core.d.ts:52


all

all<T>(values): Promise<Awaited<T>[]>

Creates a Promise that is resolved with an array of results when all of the provided Promises resolve, or rejected when any Promise is rejected.

Type parameters

Name
T

Parameters

Name Type Description
values Iterable<T | PromiseLike<T>> An iterable of Promises.

Returns

Promise<Awaited<T>[]>

A new Promise.

Inherited from

APIPromise.all

Defined in

node_modules/typescript/lib/lib.es2015.iterable.d.ts:225

all<T>(values): Promise<{ -readonly [P in string | number | symbol]: Awaited<T[P]> }>

Creates a Promise that is resolved with an array of results when all of the provided Promises resolve, or rejected when any Promise is rejected.

Type parameters

Name Type
T extends [] | readonly unknown[]

Parameters

Name Type Description
values T An array of Promises.

Returns

Promise<{ -readonly [P in string | number | symbol]: Awaited<T[P]> }>

A new Promise.

Inherited from

APIPromise.all

Defined in

node_modules/typescript/lib/lib.es2015.promise.d.ts:39


allSettled

allSettled<T>(values): Promise<{ -readonly [P in string | number | symbol]: PromiseSettledResult<Awaited<T[P]>> }>

Creates a Promise that is resolved with an array of results when all of the provided Promises resolve or reject.

Type parameters

Name Type
T extends [] | readonly unknown[]

Parameters

Name Type Description
values T An array of Promises.

Returns

Promise<{ -readonly [P in string | number | symbol]: PromiseSettledResult<Awaited<T[P]>> }>

A new Promise.

Inherited from

APIPromise.allSettled

Defined in

node_modules/typescript/lib/lib.es2020.promise.d.ts:38

allSettled<T>(values): Promise<PromiseSettledResult<Awaited<T>>[]>

Creates a Promise that is resolved with an array of results when all of the provided Promises resolve or reject.

Type parameters

Name
T

Parameters

Name Type Description
values Iterable<T | PromiseLike<T>> An array of Promises.

Returns

Promise<PromiseSettledResult<Awaited<T>>[]>

A new Promise.

Inherited from

APIPromise.allSettled

Defined in

node_modules/typescript/lib/lib.es2020.promise.d.ts:46


any

any<T>(values): Promise<Awaited<T[number]>>

The any function returns a promise that is fulfilled by the first given promise to be fulfilled, or rejected with an AggregateError containing an array of rejection reasons if all of the given promises are rejected. It resolves all elements of the passed iterable to promises as it runs this algorithm.

Type parameters

Name Type
T extends [] | readonly unknown[]

Parameters

Name Type Description
values T An array or iterable of Promises.

Returns

Promise<Awaited<T[number]>>

A new Promise.

Inherited from

APIPromise.any

Defined in

node_modules/typescript/lib/lib.es2021.promise.d.ts:40

any<T>(values): Promise<Awaited<T>>

The any function returns a promise that is fulfilled by the first given promise to be fulfilled, or rejected with an AggregateError containing an array of rejection reasons if all of the given promises are rejected. It resolves all elements of the passed iterable to promises as it runs this algorithm.

Type parameters

Name
T

Parameters

Name Type Description
values Iterable<T | PromiseLike<T>> An array or iterable of Promises.

Returns

Promise<Awaited<T>>

A new Promise.

Inherited from

APIPromise.any

Defined in

node_modules/typescript/lib/lib.es2021.promise.d.ts:47


race

race<T>(values): Promise<Awaited<T>>

Creates a Promise that is resolved or rejected when any of the provided Promises are resolved or rejected.

Type parameters

Name
T

Parameters

Name Type Description
values Iterable<T | PromiseLike<T>> An iterable of Promises.

Returns

Promise<Awaited<T>>

A new Promise.

Inherited from

APIPromise.race

Defined in

node_modules/typescript/lib/lib.es2015.iterable.d.ts:233

race<T>(values): Promise<Awaited<T[number]>>

Creates a Promise that is resolved or rejected when any of the provided Promises are resolved or rejected.

Type parameters

Name Type
T extends [] | readonly unknown[]

Parameters

Name Type Description
values T An array of Promises.

Returns

Promise<Awaited<T[number]>>

A new Promise.

Inherited from

APIPromise.race

Defined in

node_modules/typescript/lib/lib.es2015.promise.d.ts:50


reject

reject<T>(reason?): Promise<T>

Creates a new rejected promise for the provided reason.

Type parameters

Name Type
T never

Parameters

Name Type Description
reason? any The reason the promise was rejected.

Returns

Promise<T>

A new rejected Promise.

Inherited from

APIPromise.reject

Defined in

node_modules/typescript/lib/lib.es2015.promise.d.ts:60


resolve

resolve(): Promise<void>

Creates a new resolved promise.

Returns

Promise<void>

A resolved promise.

Inherited from

APIPromise.resolve

Defined in

node_modules/typescript/lib/lib.es2015.promise.d.ts:66

resolve<T>(value): Promise<Awaited<T>>

Creates a new resolved promise for the provided value.

Type parameters

Name
T

Parameters

Name Type Description
value T A promise.

Returns

Promise<Awaited<T>>

A promise whose internal state matches the provided promise.

Inherited from

APIPromise.resolve

Defined in

node_modules/typescript/lib/lib.es2015.promise.d.ts:72

resolve<T>(value): Promise<Awaited<T>>

Creates a new resolved promise for the provided value.

Type parameters

Name
T

Parameters

Name Type Description
value T | PromiseLike<T> A promise.

Returns

Promise<Awaited<T>>

A promise whose internal state matches the provided promise.

Inherited from

APIPromise.resolve

Defined in

node_modules/typescript/lib/lib.es2015.promise.d.ts:78

Typescript Libraries

Modules

Namespaces

Clone this wiki locally