cozy-dataproxy-lib
Version:
Library meant to be by Cozy Cloud's DataProxy apps for data manipulation
40 lines (39 loc) • 1.37 kB
TypeScript
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 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 interface SearchOptions {
doctypes: string[];
}
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 in SearchedDoctype]: SearchIndex;
};
export interface StorageInterface {
storeData(key: string, value: unknown): Promise<void>;
getData<T>(key: string): Promise<T | null>;
}