UNPKG

cozy-dataproxy-lib

Version:

Library meant to be by Cozy Cloud's DataProxy apps for data manipulation

44 lines (43 loc) 1.67 kB
import FlexSearch from 'flexsearch'; import { IOCozyFile, IOCozyContact, IOCozyApp } from 'cozy-client/types/types'; import { SearchedDoctype } from './consts'; export type CozyDoc = IOCozyFile | IOCozyContact | IOCozyApp; export declare const isIOCozyFile: (doc: CozyDoc) => doc is IOCozyFile; export declare const isIOCozySharedDriveFile: (doc: CozyDoc) => doc is IOCozyFile; export declare const isIOCozyContact: (doc: CozyDoc) => doc is IOCozyContact; export declare const isIOCozyApp: (doc: CozyDoc) => doc is IOCozyApp; export declare const isSearchedDoctype: (doctype: string | undefined) => doctype is SearchedDoctype; export declare const isTrashedSharedDrive: (doc: IOCozyFile, sharedDriveId: string | undefined) => boolean; export declare const isInSharedDrivesDir: (doc: IOCozyFile) => boolean; export interface SearchOptions { doctypes: string[]; excludeFilters?: Record<string, unknown>; } export interface RawSearchResult { fields: string[]; doctype: SearchedDoctype; id: string; } export interface EnrichedSearchResult extends RawSearchResult { doc: CozyDoc; } export interface SearchResult { doc: IOCozyFile | IOCozyApp | IOCozyContact; slug: string | null; title: string | null; subTitle: string | null; url: string | null; secondaryUrl: string | null; } export interface SearchIndex { index: FlexSearch.Document<CozyDoc, false>; lastSeq: number | null; lastUpdated: string | null; } export type SearchIndexes = { [key: string]: SearchIndex; }; export interface StorageInterface { storeData(key: string, value: unknown): Promise<void>; getData<T>(key: string): Promise<T | null>; }