Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ContentfulClient

Hierarchy

  • ContentfulClient

Index

Constructors

constructor

Properties

allowedOrigins

allowedOrigins: string[] = ...

environment

environment: string

rateLimit

rateLimit: number

sdks

sdks: ContentfulApiService

Methods

archiveAsset

  • archiveAsset(assetId: string): Promise<boolean>

archiveEntry

  • archiveEntry(entryId: string): Promise<boolean>

authenticate

  • authenticate(popup?: Window): Promise<boolean>

createAsset

  • createAsset(upload: ContentfulUpload, options: { locale: string }): Promise<Asset>
  • Creates a new asset from a file upload, usually from the Media Manager

    Parameters

    • upload: ContentfulUpload

      A valid contentful upload datastructure, including the contents of the file as a string, ArrayBuffer, or ReadStream

    • options: { locale: string }
      • locale: string

        The locale string for the locale to run the create for

    Returns Promise<Asset>

createEntry

  • createEntry<EntryShape>(contentTypeId: string, fields: EntryShape, options: { entryId?: string; locale: string; references?: boolean }): Promise<Entry<any>>
  • Creates a single entry

    Type parameters

    • EntryShape = any

    Parameters

    • contentTypeId: string

      The content type id of the entry you are creating

    • fields: EntryShape

      The field data for the entry you are creating

    • options: { entryId?: string; locale: string; references?: boolean }
      • Optional entryId?: string

        A pre-created entry ID to use instead of autogenerating one

      • locale: string

        The locale string for the locale to run the update for

      • Optional references?: boolean

        Whether or not nested references should be created/updated

    Returns Promise<Entry<any>>

deleteAsset

  • deleteAsset(assetId: string): Promise<boolean>

deleteEntry

  • deleteEntry(entryId: string): Promise<void>

getAsset

  • getAsset(assetId: string, options?: { preview?: boolean; query?: any }): Promise<Asset>

getAssetCollection

  • getAssetCollection(query?: any, options?: { preview: boolean }): Promise<AssetCollection>

getAssets

  • getAssets(query?: any, options?: { preview?: boolean }): Promise<Asset[]>

getContentType

  • getContentType<ContentTypeShape>(contentTypeId: string, options?: { preview?: boolean }): Promise<ContentTypeShape>
  • Fetches a content type definition by ID

    Type parameters

    • ContentTypeShape: ContentType

    Parameters

    • contentTypeId: string
    • Optional options: { preview?: boolean }
      • Optional preview?: boolean

        If true, get the latest unpublished revision

    Returns Promise<ContentTypeShape>

getEntries

  • getEntries<EntryShape, Mode>(query?: any, options?: Pick<getEntryOptions<"delivery">, "locale" | "preview" | "mode">): Promise<Entry<EntryShape>[]>
  • getEntries<EntryShape, Mode>(query?: any, options?: Pick<getEntryOptions<"management">, "locale" | "preview" | "mode">): Promise<Entry[]>
  • getEntries<EntryShape, Mode>(query?: any, options?: Pick<getEntryOptions<Mode>, "locale" | "preview" | "mode">): Promise<Entry<EntryShape>[]>

getEntry

  • getEntry<EntryShape, Mode>(entryId: string, options?: getEntryOptions<"delivery">): Promise<Entry<any>>
  • getEntry<EntryShape, Mode>(entryId: string, options?: getEntryOptions<"management">): Promise<Entry>
  • getEntry<EntryShape, Mode>(entryId: string, options?: getEntryOptions<Mode>): Promise<Entry<any>>

getManagementClient

  • getManagementClient(): Promise<{ client: { createPersonalAccessToken: (data: Pick<PersonalAccessToken, "name" | "scopes">) => Promise<PersonalAccessToken>; createSpace: (spaceData: Pick<SpaceProps, "name">, organizationId: string) => Promise<Space>; getCurrentUser: <T>(params?: QueryParams) => Promise<T>; getOrganization: (id: string) => Promise<Organization>; getOrganizationUsage: (organizationId: string, query?: QueryOptions) => Promise<Collection<Usage, UsageProps>>; getOrganizations: () => Promise<Collection<Organization, OrganizationProp>>; getPersonalAccessToken: (tokenId: string) => Promise<PersonalAccessToken>; getPersonalAccessTokens: () => Promise<Collection<PersonalAccessToken, PersonalAccessTokenProp>>; getSpace: (spaceId: string) => Promise<Space>; getSpaceUsage: (organizationId: string, query?: UsageQuery) => Promise<Collection<Usage, UsageProps>>; getSpaces: (query?: QueryOptions) => Promise<Collection<Space, SpaceProps>>; rawRequest: (__namedParameters: AxiosRequestConfig & { url: string }) => Promise<any> }; env: Environment; space: Space }>
  • Returns Promise<{ client: { createPersonalAccessToken: (data: Pick<PersonalAccessToken, "name" | "scopes">) => Promise<PersonalAccessToken>; createSpace: (spaceData: Pick<SpaceProps, "name">, organizationId: string) => Promise<Space>; getCurrentUser: <T>(params?: QueryParams) => Promise<T>; getOrganization: (id: string) => Promise<Organization>; getOrganizationUsage: (organizationId: string, query?: QueryOptions) => Promise<Collection<Usage, UsageProps>>; getOrganizations: () => Promise<Collection<Organization, OrganizationProp>>; getPersonalAccessToken: (tokenId: string) => Promise<PersonalAccessToken>; getPersonalAccessTokens: () => Promise<Collection<PersonalAccessToken, PersonalAccessTokenProp>>; getSpace: (spaceId: string) => Promise<Space>; getSpaceUsage: (organizationId: string, query?: UsageQuery) => Promise<Collection<Usage, UsageProps>>; getSpaces: (query?: QueryOptions) => Promise<Collection<Space, SpaceProps>>; rawRequest: (__namedParameters: AxiosRequestConfig & { url: string }) => Promise<any> }; env: Environment; space: Space }>

publishEntry

  • publishEntry(entryId: string): Promise<boolean>

setEnvironment

  • setEnvironment(environmentId: string): Promise<void>

sync

  • sync(query: any, options?: { preview: boolean }): Promise<SyncCollection>

unpublishEntry

  • unpublishEntry(entryId: string): Promise<boolean>

updateAsset

  • updateAsset(assetId: string, update: Asset, options: { locale: string; query?: any }): Promise<Asset>
  • Updates an asset

    Parameters

    • assetId: string

      the ID of the asset to update_results

    • update: Asset
    • options: { locale: string; query?: any }
      • locale: string

        The locale string for the locale to run the create for

      • Optional query?: any

    Returns Promise<Asset>

updateEntries

  • updateEntries<EntryShape>(updates: Entry<EntryShape>[], options: { force?: boolean; initial?: Entry<EntryShape>[]; locale: string }): Promise<Entry<any>[]>
  • Updates an array of entries, resolving when all updates are complete

    Type parameters

    • EntryShape: unknown

    Parameters

    • updates: Entry<EntryShape>[]

      The updated entries

    • options: { force?: boolean; initial?: Entry<EntryShape>[]; locale: string }
      • Optional force?: boolean

        Whether or not to force updates even if versions mismatch

      • Optional initial?: Entry<EntryShape>[]

        The initial state of the entries, used for doing recursive updates to nested entries

      • locale: string

        The locale string for the locale to run the update for

    Returns Promise<Entry<any>[]>

updateEntry

  • updateEntry<EntryShape>(entryId: string, update: Entry<EntryShape>, options: { force?: boolean; initial?: Entry<EntryShape>; locale: string }): Promise<Entry<any>>
  • Updates a single entry

    Type parameters

    • EntryShape: unknown

    Parameters

    • entryId: string
    • update: Entry<EntryShape>

      The updated entry

    • options: { force?: boolean; initial?: Entry<EntryShape>; locale: string }
      • Optional force?: boolean

        Whether or not to force updates even if versions mismatch

      • Optional initial?: Entry<EntryShape>

        The initial state of the entry, used for doing recursive updates to nested entries

      • locale: string

        The locale string for the locale to run the update for

    Returns Promise<Entry<any>>

Generated using TypeDoc