import { WriteStream } from 'node:fs'; import { Component, ContentType, PagedList, PagedSearchList, Project, Query as QueryType, ZenqlQuery as ZenqlQueryType } from 'contensis-core-api'; import { Client as DeliveryApiClient, Entry as DeliveryEntry } from 'contensis-delivery-api'; import { Entry, EntryListOptions, ICreateTag, ICreateTagGroup, IUpdateTag, IUpdateTagGroup, Node, Role, Tag, TagGetByLabelOptions, TagGroup, TagGroupListOptions, TagListOptions, Workflow } from 'contensis-management-api'; import { ApiKey, Block, BlockActionType, BlockVersion, CreateApiKeyParams, CreateProxyParams, EntryWithPublishSchedule, GetBlockLogsParams, Proxy, PushBlockParams, Renderer, WebhookSubscription } from '../models/Contensis'; import { SearchQuery } from '../models/SearchQuery'; import { MigrateStatus } from '../services'; import { CachedFetch } from '../util/lru-cache'; export type ContensisManagementApiCtor = { clientId?: string; clientSecret?: string; username?: string; password?: string; refreshToken?: string; projectId: string; rootUrl: string; }; export type GetNodeOptions = Parameters[0]; export type SearchResult = PagedList; declare class ContensisManagementApi { private assetClient; private client; deliveryClient: DeliveryApiClient; cache: CachedFetch; private contensisVersion; private ensureDeliveryApiClient; get alias(): string; get deliveryApi(): Promise; constructor({ clientId, clientSecret, username, password, refreshToken, projectId, rootUrl, }: ContensisManagementApiCtor); ContensisVersion: () => string; BearerToken: () => Promise; SecurityToken: () => Promise; GetApiKeys: () => Promise<[Error | null, ApiKey[] | undefined, Response | undefined]>; CreateApiKey: (apiKeyParams: CreateApiKeyParams) => Promise<[Error | null, ApiKey | undefined, Response | undefined]>; UpdateApiKey: (apiKey: Partial) => Promise<[Error | null, ApiKey | undefined, Response | undefined]>; DeleteApiKey: (clientId: string) => Promise<[Error | null, any, Response | undefined]>; GetBlocks: (blockId?: string) => Promise<[Error | null, T | undefined, Response | undefined]>; GetBlockVersions: (blockId: string, branchId?: string, // TODO: change this to "default" version?: string) => Promise<[Error | null, BlockVersion | PagedList | undefined, Response | undefined]>; GetBlockLogs: ({ blockId, branchId, dataCenter, includeTimestamps, lines, previous, sinceSeconds, version, }: GetBlockLogsParams) => Promise<[Error | null, string | undefined, Response | undefined]>; PushBlock: ({ release, makeLive, ...payload }: PushBlockParams) => Promise<[Error | null, BlockVersion | undefined, Response | undefined]>; BlockAction: (blockId: string, actionType: BlockActionType, version: string) => Promise<[Error | null, BlockVersion | undefined, Response | undefined]>; GetRenderers: (rendererId?: string) => Promise<[Error | null, T | undefined, Response | undefined]>; CreateRenderer: (payload: Renderer) => Promise<[Error | null, Renderer | undefined, Response | undefined]>; UpdateRenderer: (payload: Partial) => Promise<[Error | null, Renderer | undefined, Response | undefined]>; DeleteRenderer: (rendererId: string) => Promise<[Error | null, any, Response | undefined]>; GetProxies: (proxyId?: string) => Promise<[Error | null, PagedList | undefined, Response | undefined]>; CreateProxy: (payload: CreateProxyParams) => Promise<[Error | null, Renderer | undefined, Response | undefined]>; UpdateProxy: (payload: CreateProxyParams) => Promise<[Error | null, WebhookSubscription | undefined, Response | undefined]>; PublishProxy: (proxyId: string, version: string) => Promise<[Error | null, Proxy | undefined, Response | undefined]>; DeleteProxy: (proxyId: string) => Promise<[Error | null, any, Response | undefined]>; GetRoles: () => Promise<[Error, undefined] | [null, PagedList]>; CreateRole: (role: Role) => Promise<[Error, undefined] | [null, Role]>; UpdateRole: (role: Role) => Promise<[Error, undefined] | [null, Role]>; DeleteRole: (roleId: string) => Promise<[Error, undefined] | [null, void]>; GetWorkflows: () => Promise<[Error | null, PagedList | undefined, Response | undefined]>; GetWebhooks: (subscriptionId?: string) => Promise<[Error | null, WebhookSubscription[] | undefined, Response | undefined]>; CreateWebhook: (payload: WebhookSubscription) => Promise<[Error | null, WebhookSubscription | undefined, Response | undefined]>; UpdateWebhook: (payload: Partial) => Promise<[Error | null, WebhookSubscription | undefined, Response | undefined]>; DeleteWebhook: (subscriptionId: string) => Promise<[Error | null, any, Response | undefined]>; UpdateOrCreateWebhook: (existing: WebhookSubscription | undefined, webhook: WebhookSubscription) => Promise<[AppError | null, WebhookSubscription | undefined, MigrateStatus]>; ProjectId: () => string; RootUrl: () => string; GetProjects: () => Promise; GetProject: (projectId?: string) => Promise; CreateProject: (project: Project) => Promise; UpdateProject: (project: Project) => Promise; DeleteProject: (projectId: string) => Promise; DeliverySearchEntries: (query: QueryType | ZenqlQueryType, linkDepth?: number) => Promise>; DeliveryGetNodes: (options: GetNodeOptions) => Promise>; DeliveryGetNodeAncestors: (id: string) => Promise[]>; DeliveryGetRootNode: (value?: number) => Promise>; CacheRequest: (id: string, fn: () => Promise, noCache?: boolean) => Promise; GenerateCacheKey: (id: string) => string; HttpFetch: (uri: string, init?: RequestInit) => Promise<[Error | null, T | undefined, Response | undefined]>; HttpFetchAsset: (localFilePath: string, uri: string, init?: RequestInit) => Promise<[Error | null, WriteStream | undefined, Response | undefined]>; ShouldPublish: (existing: T | undefined, posted: T | undefined) => boolean; ShouldPublishEntry: (existing: T | undefined, posted: T | undefined) => boolean; ShouldScheduleEntry: (entry: T | undefined) => boolean; IsEntryScheduled: (entry: T | undefined) => boolean; GetContentTypes: () => Promise; GetContentType: (contentTypeId: string, version?: string) => Promise; UpsertContentType: (existing: ContentType | false | undefined, contentType: ContentType) => Promise<[Error | null, ContentType | undefined, MigrateStatus]>; UpdateOrCreateContentType: (existing: ContentType | undefined, contentType: ContentType) => Promise<[Error | null, ContentType | undefined, MigrateStatus]>; PublishContentType: (object: T | undefined, event?: string) => Promise; DeleteContentType: (contentTypeId: string) => Promise<[Error, undefined] | [null, void]>; GetComponents: () => Promise; GetComponent: (componentId: string, version?: string) => void; UpsertComponent: (existing: Component | false | undefined, component: Component) => Promise<[Error | null, Component | undefined, MigrateStatus]>; UpdateOrCreateComponent: (existing: Component | undefined, component: Component) => Promise<[Error | null, Component | undefined, MigrateStatus]>; DeleteComponent: (componentId: string) => Promise<[Error, undefined] | [null, void]>; GetEntryById: (entryId: string) => Promise; GetEntry: (entry: Entry) => Promise; GetEntries: (options: EntryListOptions) => Promise>; SearchEntries: (query: QueryType | ZenqlQueryType) => Promise>; CreateEntry: (entry: Entry) => Promise; UpdateEntry: (entry: Entry) => Promise; DeleteEntry: (entryId: string, recycle?: boolean) => Promise; PublishEntry: (entry: Entry, publishEvent?: string, message?: any) => Promise; CreateEntryPublishSchedule: (entry: EntryWithPublishSchedule) => Promise<[Error | null, any, Response | undefined]> | (Error | undefined)[]; ScheduleEntryPublish: (entry: EntryWithPublishSchedule) => Promise<(Error | undefined)[] | (Entry | undefined)[]>; DeleteEntryPublishSchedule: (entry: Entry) => Promise<[Error | null, any, Response | undefined]>; UnscheduleEntryPublish: (entry: Entry) => Promise; UpsertEntry: (entry: Entry, existing: Entry | undefined, publishEntry: boolean) => Promise<[AppError | null, Entry | undefined]>; UpdateOrCreateEntry: (existing: Entry | undefined, entry: Entry) => Promise<[AppError | null, Entry | undefined]>; DownloadContentAsset: (localFilePath: string, uri: string, init?: RequestInit) => Promise<[Error | null, WriteStream | undefined, Response | undefined]>; UpsertContentAsset: (existing: Entry | false | undefined, asset: Entry, assetFilePath: string, parentNodePath: string) => Promise<[AppError | null, Entry | undefined, boolean, boolean]>; UpdateOrCreateAsset: (existing: Entry | undefined, asset: Entry, assetFilePath: string, parentNodePath: string) => Promise<[AppError | null, Entry | undefined]>; CreateAsset: (asset: Entry, assetFilePath: string, parentNodePath: string) => Promise; CreateNode: (node: Node) => Promise; UpdateNode: (node: Node) => Promise; GetRootNode: () => Promise; GetNodeById: (nodeId: string) => Promise; GetNodeByPath: (path: string) => Promise; GetNodesByEntryId: (entryId: string) => Promise; GetNodeChildren: (nodeId: string) => Promise; UpdateOrCreateNode: (existing: Node, node: Node) => Promise<[AppError | null, Node | undefined]>; DeleteNode: (id: string) => Promise<[Error, undefined] | [null, void]>; GetTag: (idOrOptions: string | TagGetByLabelOptions) => Promise<[Error, undefined] | [null, Tag]>; GetTags: (options?: TagListOptions) => Promise<[Error, undefined] | [null, PagedList]>; CreateTag: (tag: ICreateTag) => Promise<[Error, undefined] | [null, Tag]>; UpdateTag: (tag: IUpdateTag) => Promise<[Error, undefined] | [null, Tag]>; DeleteTag: (id: string) => Promise<[Error, undefined] | [null, void]>; DeleteTagsInGroup: (groupId: string, ids: string[]) => Promise<[Error, undefined] | [null, import("contensis-management-api").IBulkDeletedTags]>; UpdateOrCreateTag: (tag: IUpdateTag, existing?: Tag) => Promise<[AppError | null, Tag | undefined]>; GetTagGroup: (id: string) => Promise<[Error, undefined] | [null, TagGroup]>; GetTagGroups: (options?: TagGroupListOptions) => Promise<[Error, undefined] | [null, PagedList]>; CreateTagGroup: (tagGroup: ICreateTagGroup) => Promise<[Error, undefined] | [null, TagGroup]>; UpdateTagGroup: (tagGroup: IUpdateTagGroup) => Promise<[Error, undefined] | [null, TagGroup]>; DeleteTagGroup: (id: string) => Promise<[Error, undefined] | [null, void]>; UpdateOrCreateTagGroup: (tagGroup: IUpdateTagGroup, existing?: TagGroup) => Promise<[AppError, undefined] | [null, TagGroup]>; } export declare const searchQuery: SearchQuery; export default ContensisManagementApi;