123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360 |
- declare namespace PouchDB {
- namespace Core {
- interface Error {
- }
- interface Callback<E, R> {
- (error: E | void, result: R | void): void;
- }
- type AnyCallback = Callback<any, any>;
- type DocumentId = string;
- type DocumentKey = string;
- type RevisionId = string;
- type Availability = 'available' | 'compacted' | 'not compacted' | 'missing';
- type Attachment = string | ArrayBuffer;
- type Encodable = { [propertyName: string]: any };
- interface Options {
- ajax?: Configuration.RemoteRequesterConfiguration;
- }
- interface BasicResponse {
-
- ok: boolean;
- }
- interface Response extends BasicResponse {
-
- id: DocumentId;
-
- rev: RevisionId;
- }
- interface DatabaseInfo {
- }
- interface Revision<Content> {
- ok: Document<Content> & RevisionIdMeta;
- }
- interface RevisionInfo {
- rev: RevisionId;
- status: Availability;
- }
- interface IdMeta {
- _id: DocumentId;
- }
- interface RevisionIdMeta {
- _rev: RevisionId;
- }
- interface GetMeta {
-
- _conflicts?: RevisionId[];
- _rev?: RevisionId;
-
- _revs_info?: RevisionInfo[];
-
- _revisions?: {
- ids: RevisionId[];
- start: number;
- }
- }
- type NewDocument<Content extends Encodable> = Content;
- type Document<Content extends Encodable> = Content & IdMeta;
- type ExistingDocument<Content extends Encodable> =
- Document<Content> & RevisionIdMeta;
- interface AllDocsOptions extends Options {
-
- attachments?: boolean;
-
- binary?: boolean;
-
- conflicts?: boolean;
-
- descending?: boolean;
-
- include_docs?: boolean;
-
- limit?: number;
-
- skip?: number;
- }
- interface AllDocsWithKeyOptions extends AllDocsOptions {
-
- key: DocumentKey;
- }
- interface AllDocsWithKeysOptions extends AllDocsOptions {
-
- keys: DocumentId[];
- }
- interface AllDocsWithinRangeOptions extends AllDocsOptions {
-
- startkey: DocumentKey;
-
- endkey: DocumentKey;
-
- inclusive_end?: boolean;
- }
- interface AllDocsMeta {
- _attachments?: {
- [attachmentId: string]: Attachment;
- };
- }
- interface AllDocsResponse<Content extends Core.Encodable> {
-
- offset: number;
- total_rows: number;
- rows: {
-
- doc?: Document<Content & AllDocsMeta>;
- id: DocumentId;
- key: DocumentKey;
- value: {
- rev: RevisionId;
- }
- }[];
- }
- interface DestroyOptions extends Options {
- }
- interface GetOptions extends Options {
-
- conflicts?: boolean;
-
- rev?: RevisionId;
-
- revs?: boolean;
-
- revs_info?: boolean;
- }
- interface GetOpenRevisions extends Options {
-
- open_revs: 'all' | Core.RevisionId[];
- }
-
- interface PutOptions extends Options {
- }
- interface PostOptions extends PutOptions {
- }
- interface CompactOptions extends Core.Options {
- interval?: number;
- }
- interface InfoOptions extends Options {
- }
- }
-
- export type Plugin = 'This should be passed to PouchDB.plugin()';
- namespace Configuration {
- interface CommonDatabaseConfiguration {
-
- name?: string;
-
- adapter?: string;
- }
- interface LocalDatabaseConfiguration extends CommonDatabaseConfiguration {
-
- auto_compaction?: boolean;
-
- revs_limit?: number;
- }
- interface RemoteRequesterConfiguration {
-
- timeout?: number;
-
- cache?: boolean;
-
- headers?: {
- [name: string]: string;
- }
- username?: string;
- password?: string;
-
- withCredentials?: boolean;
-
- skip_setup?: boolean;
- }
- interface RemoteDatabaseConfiguration extends CommonDatabaseConfiguration {
- ajax?: RemoteRequesterConfiguration;
- }
- type DatabaseConfiguration = LocalDatabaseConfiguration |
- RemoteDatabaseConfiguration;
- }
- interface Static {
- plugin(plugin: Plugin): Static;
- new<Content extends Core.Encodable>(name?: string,
- options?: Configuration.DatabaseConfiguration): Database<Content>;
- }
- interface Database<Content extends Core.Encodable> {
-
- allDocs(options: Core.AllDocsWithKeyOptions):
- Promise<Core.AllDocsResponse<Content>>;
-
- allDocs(options: Core.AllDocsWithKeysOptions):
- Promise<Core.AllDocsResponse<Content>>;
-
- allDocs(options: Core.AllDocsWithinRangeOptions):
- Promise<Core.AllDocsResponse<Content>>;
-
- allDocs(options?: Core.AllDocsOptions):
- Promise<Core.AllDocsResponse<Content>>;
- bulkDocs(docs: Core.Document<Content>[],
- options: Core.PutOptions | void,
- callback: Core.Callback<Core.Error, Core.Response[]>): void;
- bulkDocs(docs: Core.Document<Content>[],
- options?: Core.PutOptions): Promise<Core.Response[]>;
-
- compact(options?: Core.CompactOptions): Promise<Core.Response>;
- compact(options: Core.CompactOptions,
- callback: Core.Callback<Core.Error, Core.Response>): void;
-
- destroy(options: Core.DestroyOptions | void,
- callback: Core.AnyCallback): void;
- destroy(options?: Core.DestroyOptions | void): Promise<void>;
-
- get(docId: Core.DocumentId,
- options: Core.GetOpenRevisions): Promise<Core.Revision<Content>[]>;
- get(docId: Core.DocumentId,
- options: Core.GetOpenRevisions,
- callback: Core.Callback<any,
- Core.Revision<Content>[]>): void;
- get(docId: Core.DocumentId,
- options: Core.GetOptions
- ): Promise<Core.Document<Content> & Core.GetMeta>;
- get(docId: Core.DocumentId,
- options: Core.GetOptions,
- callback: Core.Callback<any, Core.Document<Content> & Core.GetMeta>
- ): void;
- get(docId: Core.DocumentId,
- options: void,
- callback: Core.Callback<any, Core.Document<Content>>): void;
- get(docId: Core.DocumentId): Promise<Core.Document<Content>>;
-
- post(doc: Core.NewDocument<Content>,
- options: Core.PostOptions | void,
- callback: Core.Callback<Core.Error, Core.Response>): void;
- post(doc: Core.NewDocument<Content>,
- options?: Core.PostOptions): Promise<Core.Response>;
-
- put(doc: Core.Document<Content>,
- id: Core.DocumentId | void,
- revision: Core.RevisionId | void,
- options: Core.PutOptions | void,
- callback: Core.Callback<Core.Error, Core.Response>): void;
- put(doc: Core.Document<Content>,
- id?: Core.DocumentId,
- revision?: Core.RevisionId,
- options?: Core.PutOptions): Promise<Core.Response>;
-
- remove(doc: Core.Document<Content>,
- options: Core.Options,
- callback: Core.Callback<Core.Error, Core.Response>): void;
- remove(docId: Core.DocumentId,
- revision: Core.RevisionId,
- options: Core.Options,
- callback: Core.Callback<Core.Error, Core.Response>): void;
- remove(doc: Core.Document<Content>,
- options?: Core.Options): Promise<Core.Response>;
- remove(docId: Core.DocumentId,
- revision: Core.RevisionId,
- options?: Core.Options): Promise<Core.Response>;
-
- info(options: Core.InfoOptions | void,
- callback: Core.Callback<any, Core.DatabaseInfo>): void;
- info(options?: Core.InfoOptions): Promise<Core.DatabaseInfo>;
- }
- }
- declare module 'pouchdb-core' {
- const PouchDb: PouchDB.Static;
- export = PouchDb;
- }
- declare var PouchDB: PouchDB.Static;
|