@routier/pouchdb-plugin 0.0.1-alpha.2 → 0.0.1-alpha.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,68 @@
1
+ import { PropertyInfo } from '@routier/core/schema';
2
+ import { DbPluginBulkPersistEvent, DbPluginEvent, DbPluginQueryEvent, IDbPlugin, IQuery } from '@routier/core/plugins';
3
+ import { PluginEventCallbackPartialResult, PluginEventCallbackResult } from '@routier/core/results';
4
+ import { Expression } from '@routier/core/expressions';
5
+ import { BulkPersistResult, SchemaCollection } from '@routier/core';
6
+ type PouchDBPluginOptions = PouchDB.Configuration.DatabaseConfiguration & {
7
+ queryType?: "default" | "memory-optimized" | "experimental";
8
+ sync?: PouchDB.Replication.SyncOptions & {
9
+ remoteDb: string;
10
+ onChange?: (schemas: SchemaCollection, event: PouchDB.Replication.SyncResult<{}>) => void;
11
+ onError?: (schemas: SchemaCollection, error?: any) => void;
12
+ onComplete?: (schemas: SchemaCollection, event: PouchDB.Replication.SyncResultComplete<{}>) => void;
13
+ onPaused?: (schemas: SchemaCollection, event?: any) => void;
14
+ onActive?: (schemas: SchemaCollection) => void;
15
+ onDenied?: (schemas: SchemaCollection, event?: any) => void;
16
+ auth?: {
17
+ username: string;
18
+ password: string;
19
+ };
20
+ headers?: {
21
+ [key: string]: string;
22
+ };
23
+ };
24
+ };
25
+ export type PouchDbDesignDoc = {
26
+ _id: string;
27
+ language?: string;
28
+ views?: {
29
+ [viewName: string]: {
30
+ map: string | Function;
31
+ reduce?: string | Function;
32
+ };
33
+ };
34
+ filters?: {
35
+ [filterName: string]: string | Function;
36
+ };
37
+ validate_doc_update?: string | Function;
38
+ options?: Record<string, any>;
39
+ [key: string]: any;
40
+ };
41
+ export declare class PouchDbPlugin implements IDbPlugin {
42
+ private readonly _name;
43
+ private readonly _options?;
44
+ constructor(name: string, options?: PouchDBPluginOptions);
45
+ sync(schemas: SchemaCollection): PouchDB.Replication.Sync<{}>;
46
+ private _identityBulkOperations;
47
+ private _defaultBulkOperations;
48
+ private _prepareProperties;
49
+ private resolveIndexes;
50
+ private _bulkGetAdditions;
51
+ private _validateSchemas;
52
+ private _bulkPersist;
53
+ private _doWork;
54
+ destroy(_event: DbPluginEvent, done: (error?: any) => void): void;
55
+ bulkPersist(event: DbPluginBulkPersistEvent, done: PluginEventCallbackPartialResult<BulkPersistResult>): void;
56
+ query<TRoot extends {}, TShape extends any = TRoot>(event: DbPluginQueryEvent<TRoot, TShape>, done: PluginEventCallbackResult<TShape>): void;
57
+ protected onGetIndex<TEntity extends {}, TShape extends unknown = TEntity>(_: IQuery<TEntity, TShape>, __: PouchDB.Find.FindRequest<unknown>, done: (result: null | string | [string, string]) => void): void;
58
+ extractEqualityValueForProperty(expression: Expression, prop: PropertyInfo<any>): any | undefined;
59
+ private _findMatchingIndex;
60
+ private _queryIndex;
61
+ private _queryNoIndex;
62
+ private _queryWithNoFilters;
63
+ private _queryWithFilters;
64
+ private _query;
65
+ private _getExpressionFromQuery;
66
+ private findMatchingIndexForMap;
67
+ }
68
+ export {};