import type { DocumentNode } from 'graphql'; import type { Collection, CollectionTemplateable, Schema, TinaSchema } from '@tinacms/schema-tools'; import type { Bridge } from './bridge'; import { type BinaryFilter, type IndexDefinition, type TernaryFilter } from './datalayer'; import { type Level } from './level'; type IndexStatusEvent = { status: 'inprogress' | 'complete' | 'failed'; error?: Error; }; type IndexStatusCallback = (event: IndexStatusEvent) => Promise; export type OnPutCallback = (key: string, value: any) => Promise; export type OnDeleteCallback = (key: string) => Promise; export interface DatabaseArgs { bridge?: Bridge; level: Level; onPut?: (key: string, value: any) => Promise; onDelete?: (key: string) => Promise; tinaDirectory?: string; indexStatusCallback?: IndexStatusCallback; version?: boolean; namespace?: string; levelBatchSize?: number; } export interface GitProvider { onPut: (key: string, value: string) => Promise; onDelete: (key: string) => Promise; } export type CreateDatabase = Omit & { databaseAdapter: Level; gitProvider: GitProvider; /** * @deprecated Use databaseAdapter instead */ level?: Level; /** * @deprecated Use gitProvider instead */ onPut?: OnPutCallback; /** * @deprecated Use gitProvider instead */ onDelete?: OnDeleteCallback; }; export type CreateLocalDatabaseArgs = Omit & { port?: number; rootPath?: string; }; export declare const createLocalDatabase: (config?: CreateLocalDatabaseArgs) => Database; export declare const createDatabase: (config: CreateDatabase) => Database; export declare const createDatabaseInternal: (config: DatabaseArgs) => Database; /** Options for {@link Database.query} **/ export type QueryOptions = { fileExtension?: string; collection: string; filterChain?: (BinaryFilter | TernaryFilter)[]; sort?: string; first?: number; last?: number; after?: string; before?: string; folder?: string; }; export declare class Database { config: DatabaseArgs; bridge?: Bridge; rootLevel: Level; appLevel: Level | undefined; contentLevel: Level | undefined; tinaDirectory: string; indexStatusCallback: IndexStatusCallback | undefined; private readonly onPut; private readonly onDelete; private readonly levelBatchSize; private tinaSchema; private contentNamespace; private collectionIndexDefinitions; private collectionReferences; private _lookup; constructor(config: DatabaseArgs); private collectionForPath; private getGeneratedFolder; private updateDatabaseVersion; private getDatabaseVersion; private initLevel; getMetadata: (key: string) => Promise; setMetadata: (key: string, value: string) => Promise; get: (filepath: string) => Promise; addPendingDocument: (filepath: string, data: { [key: string]: unknown; }) => Promise; put: (filepath: string, data: { [key: string]: unknown; }, collectionName?: string) => Promise; getTemplateDetailsForFile(collection: Collection, data: { [key: string]: unknown; }): Promise<{ template: { label?: string | boolean; name: string; nameOverride?: string; ui?: { itemProps?(item: Record): { key?: string; label?: string | boolean; }; defaultItem?: import("@tinacms/schema-tools").DefaultItem>; previewSrc?: string; }; fields: ((import("@tinacms/schema-tools").StringField | import("@tinacms/schema-tools").NumberField | import("@tinacms/schema-tools").BooleanField | import("@tinacms/schema-tools").DateTimeField | import("@tinacms/schema-tools").ImageField | import("@tinacms/schema-tools").ReferenceField | import("@tinacms/schema-tools").PasswordField | import("@tinacms/schema-tools").DisplayOnlyField | import("@tinacms/schema-tools").RichTextField | import("@tinacms/schema-tools").ObjectField) & {})[]; }; info: CollectionTemplateable; }>; formatBodyOnPayload: (filepath: string, data: { [key: string]: unknown; }) => Promise<{ [key: string]: unknown; }>; stringifyFile: (filepath: string, payload: { [key: string]: unknown; }, collection: Collection) => Promise; /** * Clears the internal cache of the tinaSchema and the lookup file. This allows the state to be reset */ clearCache(): void; flush: (filepath: string) => Promise; getLookup: (returnType?: string) => Promise>; getGraphQLSchema: () => Promise; getGraphQLSchemaFromBridge: () => Promise; getTinaSchema: (level?: Level) => Promise; getSchema: (level?: Level, existingSchema?: Schema) => Promise; getCollectionReferences: (level?: Level) => Promise>>; getIndexDefinitions: (level?: Level) => Promise>>; documentExists: (fullpath: unknown) => Promise; query: (queryOptions: QueryOptions, hydrator: any) => Promise<{ edges: { node: any; cursor: string; }[]; pageInfo: { hasPreviousPage: boolean; hasNextPage: boolean; startCursor: string; endCursor: string; }; }>; private indexStatusCallbackWrapper; indexContent: ({ graphQLSchema, tinaSchema, lookup: lookupFromLockFile, }: { graphQLSchema: DocumentNode; tinaSchema: TinaSchema; lookup?: object; }) => Promise<{ warnings: string[]; }>; deleteContentByPaths: (documentPaths: string[]) => Promise; indexContentByPaths: (documentPaths: string[]) => Promise; delete: (filepath: string) => Promise; _indexAllContent: (level: Level, schema?: Schema) => Promise<{ warnings: string[]; }>; } export type LookupMapType = GlobalDocumentLookup | CollectionDocumentLookup | CollectionFolderLookup | MultiCollectionDocumentLookup | MultiCollectionDocumentListLookup | CollectionDocumentListLookup | UnionDataLookup | NodeDocument; type NodeDocument = { type: string; resolveType: 'nodeDocument'; }; type GlobalDocumentLookup = { type: string; resolveType: 'globalDocument'; collection: string; }; type CollectionDocumentLookup = { type: string; resolveType: 'collectionDocument'; collection: string; }; type CollectionFolderLookup = { type: string; resolveType: 'collectionFolder'; collection: string; }; type MultiCollectionDocumentLookup = { type: string; resolveType: 'multiCollectionDocument'; createDocument: 'create'; updateDocument: 'update'; }; type MultiCollectionDocumentListLookup = { type: string; resolveType: 'multiCollectionDocumentList'; collections: string[]; }; export type CollectionDocumentListLookup = { type: string; resolveType: 'collectionDocumentList'; collection: string; }; type UnionDataLookup = { type: string; resolveType: 'unionData'; collection?: string; typeMap: { [templateName: string]: string; }; }; export {};