tinacms
Version:
> The Fastest Way to Edit Next.js Content
184 lines (183 loc) • 5.56 kB
TypeScript
import { TokenObject } from '../auth/authenticate';
import { BranchData, EventBus } from '@tinacms/toolkit';
import { DocumentNode, GraphQLSchema } from 'graphql';
import gql from 'graphql-tag';
import { TinaSchema, Schema, AuthProvider } from '@tinacms/schema-tools';
import { TinaCloudProject } from './types';
import { SearchClient } from '@tinacms/search/dist/index-client';
export * from './authProvider';
export declare type OnLoginFunc = (args: {
token?: TokenObject;
}) => Promise<void>;
export declare type TinaIOConfig = {
assetsApiUrlOverride?: string;
frontendUrlOverride?: string;
identityApiUrlOverride?: string;
contentApiUrlOverride?: string;
};
interface ServerOptions {
schema?: Schema;
clientId: string;
branch: string;
tinaGraphQLVersion: string;
customContentApiUrl?: string;
getTokenFn?: () => Promise<TokenObject>;
tinaioConfig?: TinaIOConfig;
tokenStorage?: 'MEMORY' | 'LOCAL_STORAGE' | 'CUSTOM';
}
export declare class Client {
authProvider: AuthProvider;
onLogin?: OnLoginFunc;
onLogout?: () => Promise<void>;
frontendUrl: string;
contentApiUrl: string;
identityApiUrl: string;
assetsApiUrl: string;
gqlSchema: GraphQLSchema;
schema?: TinaSchema;
clientId: string;
contentApiBase: string;
tinaGraphQLVersion: string;
branch: string;
private options;
events: EventBus;
protectedBranches: string[];
usingEditorialWorkflow: boolean;
constructor({ tokenStorage, ...options }: ServerOptions);
get isLocalMode(): boolean;
get isCustomContentApi(): boolean;
setBranch(branchName: string): void;
getBranch(): string;
addPendingContent: (props: any) => Promise<any>;
getSchema: () => Promise<GraphQLSchema>;
/**
*
* Returns a version of the query with fragments inlined. Eg.
* ```graphql
* {
* getPostDocument(relativePath: "") {
* data {
* ...PostFragment
* }
* }
* }
*
* fragment PostFragment on Post {
* title
* }
* ```
* Turns into
* ```graphql
* {
* getPostDocument(relativePath: "") {
* data {
* title
* }
* }
* }
*/
getOptimizedQuery: (documentNode: DocumentNode) => Promise<DocumentNode>;
request<ReturnType>(query: ((gqlTag: typeof gql) => DocumentNode) | string, { variables }: {
variables: object;
}): Promise<ReturnType>;
get appDashboardLink(): string;
checkSyncStatus({ assetsSyncing, }: {
assetsSyncing: string[];
}): Promise<{
assetsSyncing: string[];
}>;
getProject(): Promise<TinaCloudProject>;
createPullRequest({ baseBranch, branch, title, }: {
baseBranch: string;
branch: string;
title: string;
}): Promise<any>;
fetchEvents(limit?: number, cursor?: string): Promise<{
events: {
message: string;
timestamp: number;
id: string;
isError: boolean;
isGlobal: boolean;
}[];
cursor?: string;
}>;
getBillingState(): Promise<{
clientId: string;
delinquencyDate: number;
billingState: 'current' | 'late' | 'delinquent';
}>;
waitForIndexStatus({ ref }: {
ref: string;
}): (Promise<any> | (() => void))[];
getIndexStatus({ ref }: {
ref: string;
}): Promise<{
status?: "unknown" | "complete" | "failed" | "inprogress";
timestamp?: number;
}>;
listBranches(args?: {
includeIndexStatus?: boolean;
}): Promise<[{
name?: string;
protected?: boolean;
githubPullRequestUrl?: string;
}, ...{
name?: string;
protected?: boolean;
githubPullRequestUrl?: string;
}[]] | {
indexStatus: {
status?: "unknown" | "complete" | "failed" | "inprogress";
timestamp?: number;
};
name?: string;
protected?: boolean;
githubPullRequestUrl?: string;
}[]>;
usingProtectedBranch(): boolean;
createBranch({ baseBranch, branchName }: BranchData): Promise<string>;
}
export declare const DEFAULT_LOCAL_TINA_GQL_SERVER_URL = "http://localhost:4001/graphql";
export declare class LocalClient extends Client {
constructor(props?: {
customContentApiUrl?: string;
schema?: Schema;
} & Omit<ServerOptions, 'clientId' | 'branch' | 'tinaGraphQLVersion'>);
get isLocalMode(): boolean;
}
export declare class TinaCMSSearchClient implements SearchClient {
private client;
private tinaSearchConfig?;
constructor(client: Client, tinaSearchConfig?: {
stopwordLanguages?: string[];
});
query(query: string, options?: {
limit?: number;
cursor?: string;
}): Promise<{
results: any[];
nextCursor: string | null;
total: number;
prevCursor: string | null;
}>;
del(ids: string[]): Promise<any>;
put(docs: any[]): Promise<any>;
supportsClientSideIndexing(): boolean;
}
export declare class LocalSearchClient implements SearchClient {
private client;
constructor(client: Client);
query(query: string, options?: {
limit?: number;
cursor?: string;
}): Promise<{
results: any[];
nextCursor: string | null;
total: number;
prevCursor: string | null;
}>;
del(ids: string[]): Promise<any>;
put(docs: any[]): Promise<any>;
supportsClientSideIndexing(): boolean;
}