PerspectPerspectDocs
Go to Admin
View as Markdown

perspectapi-ts-sdk

Classes

  • ContentV2Client

Class: ContentV2Client

Extends

  • BaseV2Client

Constructors

Constructor

new ContentV2Client(http, basePath, cache?): ContentV2Client

Parameters

http

HttpClient

basePath

string

cache?

CacheManager

Returns

ContentV2Client

Inherited from

BaseV2Client.constructor

Properties

basePath

protected basePath: string

Inherited from

BaseV2Client.basePath

cache?

protected optional cache?: CacheManager

Inherited from

BaseV2Client.cache

http

protected http: HttpClient

Inherited from

BaseV2Client.http

Methods

buildPath()

protected buildPath(endpoint): string

Parameters

endpoint

string

Returns

string

Inherited from

BaseV2Client.buildPath

create()

create(siteName, data): Promise<V2Content>

Parameters

siteName

string

data

V2ContentCreateParams

Returns

Promise<V2Content>

del()

del(siteName, id): Promise<V2Deleted>

Parameters

siteName

string

id

string

Returns

Promise<V2Deleted>

deleteOne()

protected deleteOne(path): Promise<V2Deleted>

DELETE a resource.

Parameters

path

string

Returns

Promise<V2Deleted>

Inherited from

BaseV2Client.deleteOne

get()

get(siteName, idOrSlug, cachePolicy?): Promise<V2Content>

Parameters

siteName

string

idOrSlug

string

cachePolicy?

CachePolicy

Returns

Promise<V2Content>

getList()

protected getList<T>(path, params?, cachePolicy?): Promise<V2List<T>>

GET a list of resources with cursor pagination, with optional caching.

Type Parameters

T

T

Parameters

path

string

params?

object

cachePolicy?

CachePolicy

Returns

Promise<V2List<T>>

Inherited from

BaseV2Client.getList

getOne()

protected getOne<T>(path, params?, cachePolicy?): Promise<T>

GET a single resource, with optional caching.

Type Parameters

T

T

Parameters

path

string

params?

object

cachePolicy?

CachePolicy

Returns

Promise<T>

Inherited from

BaseV2Client.getOne

invalidateCache()

protected invalidateCache(options): Promise<void>

Invalidate cache entries by keys or tags.

Parameters

options

CacheInvalidateOptions

Returns

Promise<void>

Inherited from

BaseV2Client.invalidateCache

list()

list(siteName, params?, cachePolicy?): Promise<V2List<V2Content>>

Parameters

siteName

string

params?

V2ContentListParams

cachePolicy?

CachePolicy

Returns

Promise<V2List<V2Content>>

listAutoPaginate()

protected listAutoPaginate<T>(path, params?): AsyncGenerator<T, void, unknown>

Auto-paginating async generator. Yields every item across all pages.

Usage: for await (const item of client.listAutoPaginate(path, params)) { ... }

Type Parameters

T

T extends object

Parameters

path

string

params?

object

Returns

AsyncGenerator<T, void, unknown>

Inherited from

BaseV2Client.listAutoPaginate

listAutoPaginated()

listAutoPaginated(siteName, params?, cachePolicy?): AsyncGenerator<V2Content, void, unknown>

Parameters

siteName

string

params?

Omit<V2ContentListParams, "starting_after" | "ending_before">

cachePolicy?

CachePolicy

Returns

AsyncGenerator<V2Content, void, unknown>

patchOne()

protected patchOne<T>(path, body?): Promise<T>

PATCH to update a resource.

Type Parameters

T

T

Parameters

path

string

body?

unknown

Returns

Promise<T>

Inherited from

BaseV2Client.patchOne

post()

protected post<T>(path, body?): Promise<T>

POST to create a resource.

Type Parameters

T

T

Parameters

path

string

body?

unknown

Returns

Promise<T>

Inherited from

BaseV2Client.post

publish()

publish(siteName, id): Promise<V2Content>

Parameters

siteName

string

id

string

Returns

Promise<V2Content>

putOne()

protected putOne<T>(path, body?): Promise<T>

PUT to upsert a resource.

Type Parameters

T

T

Parameters

path

string

body?

unknown

Returns

Promise<T>

Inherited from

BaseV2Client.putOne

sitePath()

protected sitePath(siteName, resource, suffix?): string

Parameters

siteName

string

resource

string

suffix?

string = ''

Returns

string

Inherited from

BaseV2Client.sitePath

unpublish()

unpublish(siteName, id): Promise<V2Content>

Parameters

siteName

string

id

string

Returns

Promise<V2Content>

update()

update(siteName, id, data): Promise<V2Content>

Parameters

siteName

string

id

string

data

V2ContentUpdateParams

Returns

Promise<V2Content>