cozy-pouch-link 57.5.0 → 57.6.1
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.
- package/dist/CozyPouchLink.js +234 -470
- package/dist/CozyPouchLink.spec.js +6 -147
- package/dist/PouchManager.js +43 -8
- package/dist/PouchManager.spec.js +21 -12
- package/dist/__mocks__/@op-engineering/op-sqlite.js +11 -0
- package/dist/db/dbInterface.js +190 -0
- package/dist/db/helpers.js +128 -0
- package/dist/db/pouchdb/getDocs.js +157 -0
- package/dist/db/pouchdb/getDocs.spec.js +63 -0
- package/dist/db/pouchdb/pouchdb.js +264 -0
- package/dist/db/pouchdb/pouchdb.spec.js +151 -0
- package/dist/db/sqlite/sql.js +422 -0
- package/dist/db/sqlite/sql.spec.js +419 -0
- package/dist/db/sqlite/sqliteDb.js +41 -0
- package/dist/db/sqlite/sqliteDb.native.js +317 -0
- package/dist/errors.js +17 -2
- package/dist/helpers.js +21 -147
- package/dist/helpers.spec.js +1 -98
- package/dist/index.js +9 -1
- package/dist/jsonapi.js +57 -21
- package/dist/jsonapi.spec.js +105 -32
- package/dist/mango.js +146 -3
- package/dist/migrations/pouchdb.js +32 -0
- package/dist/replicateOnce.js +25 -23
- package/dist/types.js +5 -0
- package/dist/utils.js +33 -3
- package/package.json +5 -3
- package/types/CozyPouchLink.d.ts +6 -63
- package/types/PouchManager.d.ts +6 -1
- package/types/__mocks__/@op-engineering/op-sqlite.d.ts +1 -0
- package/types/db/dbInterface.d.ts +117 -0
- package/types/db/helpers.d.ts +4 -0
- package/types/db/pouchdb/getDocs.d.ts +18 -0
- package/types/db/pouchdb/pouchdb.d.ts +8 -0
- package/types/db/sqlite/sql.d.ts +45 -0
- package/types/db/sqlite/sqliteDb.d.ts +4 -0
- package/types/db/sqlite/sqliteDb.native.d.ts +7 -0
- package/types/errors.d.ts +2 -0
- package/types/helpers.d.ts +1 -4
- package/types/index.d.ts +1 -0
- package/types/jsonapi.d.ts +4 -2
- package/types/mango.d.ts +19 -1
- package/types/migrations/pouchdb.d.ts +1 -0
- package/types/types.d.ts +2 -0
- package/types/utils.d.ts +3 -0
package/dist/utils.js
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.allSettled = exports.formatAggregatedError = exports.getPrefix = exports.getDatabaseName = void 0;
|
|
7
|
-
|
|
6
|
+
exports.allSettled = exports.formatAggregatedError = exports.getPrefix = exports.getDoctypeFromDatabaseName = exports.getOldDatabaseName = exports.getDatabaseName = exports.DATABASE_NAME_SEPARATOR = void 0;
|
|
7
|
+
var DATABASE_NAME_SEPARATOR = '__doctype__';
|
|
8
8
|
/**
|
|
9
9
|
* Get the database name based on prefix and doctype
|
|
10
10
|
*
|
|
@@ -13,9 +13,39 @@ exports.allSettled = exports.formatAggregatedError = exports.getPrefix = exports
|
|
|
13
13
|
*
|
|
14
14
|
* @returns {string} The database name
|
|
15
15
|
*/
|
|
16
|
+
|
|
17
|
+
exports.DATABASE_NAME_SEPARATOR = DATABASE_NAME_SEPARATOR;
|
|
18
|
+
|
|
16
19
|
var getDatabaseName = function getDatabaseName(prefix, doctype) {
|
|
20
|
+
return "".concat(prefix).concat(DATABASE_NAME_SEPARATOR).concat(doctype);
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Get the old database name, based on prefix and doctype
|
|
24
|
+
* Used for migration purposes
|
|
25
|
+
*
|
|
26
|
+
* @param {string} prefix - The URL prefix
|
|
27
|
+
* @param {string} doctype - The database doctype
|
|
28
|
+
*
|
|
29
|
+
* @returns {string} The database name
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
exports.getDatabaseName = getDatabaseName;
|
|
34
|
+
|
|
35
|
+
var getOldDatabaseName = function getOldDatabaseName(prefix, doctype) {
|
|
17
36
|
return "".concat(prefix, "_").concat(doctype);
|
|
18
37
|
};
|
|
38
|
+
|
|
39
|
+
exports.getOldDatabaseName = getOldDatabaseName;
|
|
40
|
+
|
|
41
|
+
var getDoctypeFromDatabaseName = function getDoctypeFromDatabaseName(dbName) {
|
|
42
|
+
if (!dbName) {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
var tokens = dbName.split(DATABASE_NAME_SEPARATOR);
|
|
47
|
+
return tokens[tokens.length - 1];
|
|
48
|
+
};
|
|
19
49
|
/**
|
|
20
50
|
* Get the URI prefix
|
|
21
51
|
*
|
|
@@ -24,7 +54,7 @@ var getDatabaseName = function getDatabaseName(prefix, doctype) {
|
|
|
24
54
|
*/
|
|
25
55
|
|
|
26
56
|
|
|
27
|
-
exports.
|
|
57
|
+
exports.getDoctypeFromDatabaseName = getDoctypeFromDatabaseName;
|
|
28
58
|
|
|
29
59
|
var getPrefix = function getPrefix(uri) {
|
|
30
60
|
return uri.replace(/^https?:\/\//, '');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cozy-pouch-link",
|
|
3
|
-
"version": "57.
|
|
3
|
+
"version": "57.6.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "types/index.d.ts",
|
|
@@ -13,13 +13,14 @@
|
|
|
13
13
|
"url": "git+https://github.com/cozy/cozy-client.git"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"cozy-client": "^57.
|
|
16
|
+
"cozy-client": "^57.6.0",
|
|
17
17
|
"pouchdb-browser": "^7.2.2",
|
|
18
18
|
"pouchdb-find": "^7.2.2"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"@babel/cli": "7.12.8",
|
|
22
22
|
"@cozy/minilog": "1.0.0",
|
|
23
|
+
"@op-engineering/op-sqlite": "^11.4.8",
|
|
23
24
|
"cozy-device-helper": "2.7.0",
|
|
24
25
|
"jest-localstorage-mock": "2.4.19",
|
|
25
26
|
"parcel": "2.13.3",
|
|
@@ -30,6 +31,7 @@
|
|
|
30
31
|
},
|
|
31
32
|
"peerDependencies": {
|
|
32
33
|
"@cozy/minilog": "1.0.0",
|
|
34
|
+
"@op-engineering/op-sqlite": "*",
|
|
33
35
|
"cozy-device-helper": ">=2.1.0"
|
|
34
36
|
},
|
|
35
37
|
"scripts": {
|
|
@@ -39,5 +41,5 @@
|
|
|
39
41
|
"typecheck": "tsc -p tsconfig.json"
|
|
40
42
|
},
|
|
41
43
|
"sideEffects": false,
|
|
42
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "c8b0e04cccbdb92b0a846a7d25ac1c8f990fe3ce"
|
|
43
45
|
}
|
package/types/CozyPouchLink.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export function getReplicationURL(uri: any, token: any, doctype: any): string;
|
|
2
2
|
export default PouchLink;
|
|
3
|
-
export type
|
|
3
|
+
export type CozyPouchDocument = any;
|
|
4
4
|
export type ReplicationStatus = "idle" | "replicating";
|
|
5
5
|
export type PouchLinkOptions = {
|
|
6
6
|
/**
|
|
@@ -41,8 +41,7 @@ export type PouchLinkOptions = {
|
|
|
41
41
|
performanceApi?: any;
|
|
42
42
|
};
|
|
43
43
|
/**
|
|
44
|
-
* @typedef {import('cozy-client/src/types').CozyClientDocument}
|
|
45
|
-
*
|
|
44
|
+
* @typedef {import('cozy-client/src/types').CozyClientDocument & { cozyPouchData: any }} CozyPouchDocument *
|
|
46
45
|
* @typedef {"idle"|"replicating"} ReplicationStatus
|
|
47
46
|
*/
|
|
48
47
|
/**
|
|
@@ -125,6 +124,7 @@ declare class PouchLink extends CozyLink {
|
|
|
125
124
|
plugins?: Array<object>;
|
|
126
125
|
}): Promise<void>;
|
|
127
126
|
onLogin(): Promise<void>;
|
|
127
|
+
queryEngine: import("./db/dbInterface").default | typeof PouchDBQueryEngine;
|
|
128
128
|
pouches: PouchManager;
|
|
129
129
|
/**
|
|
130
130
|
* Receives PouchDB updates (documents grouped by doctype).
|
|
@@ -180,6 +180,7 @@ declare class PouchLink extends CozyLink {
|
|
|
180
180
|
public stopReplication(): void;
|
|
181
181
|
onSyncError(error: any): Promise<void>;
|
|
182
182
|
getSyncInfo(doctype: any): import("./types").SyncInfo;
|
|
183
|
+
getQueryEngineFromDoctype(doctype: any): any;
|
|
183
184
|
getPouch(doctype: any): any;
|
|
184
185
|
supportsOperation(operation: any): boolean;
|
|
185
186
|
/**
|
|
@@ -199,17 +200,6 @@ declare class PouchLink extends CozyLink {
|
|
|
199
200
|
* @returns {Promise<import('./types').PouchDBInfo>} The db info
|
|
200
201
|
*/
|
|
201
202
|
getDbInfo(doctype: string): Promise<import('./types').PouchDBInfo>;
|
|
202
|
-
sanitizeJsonApi(data: any): Pick<Pick<any, string | number | symbol>, string | number | symbol>;
|
|
203
|
-
/**
|
|
204
|
-
* Retrieve the existing document from Pouch
|
|
205
|
-
*
|
|
206
|
-
* @private
|
|
207
|
-
* @param {*} id - ID of the document to retrieve
|
|
208
|
-
* @param {*} type - Doctype of the document to retrieve
|
|
209
|
-
* @param {*} throwIfNotFound - If true the method will throw when the document is not found. Otherwise it will return null
|
|
210
|
-
* @returns {Promise<CozyClientDocument | null>}
|
|
211
|
-
*/
|
|
212
|
-
private getExistingDocument;
|
|
213
203
|
/**
|
|
214
204
|
*
|
|
215
205
|
* Check if there is warmup queries for this doctype
|
|
@@ -220,45 +210,6 @@ declare class PouchLink extends CozyLink {
|
|
|
220
210
|
*/
|
|
221
211
|
needsToWaitWarmup(doctype: string): Promise<boolean>;
|
|
222
212
|
hasIndex(name: any): boolean;
|
|
223
|
-
/**
|
|
224
|
-
* Create the PouchDB index if not existing
|
|
225
|
-
*
|
|
226
|
-
* @param {Array} fields - Fields to index
|
|
227
|
-
* @param {object} indexOption - Options for the index
|
|
228
|
-
* @param {object} [indexOption.partialFilter] - partialFilter
|
|
229
|
-
* @param {string} [indexOption.indexName] - indexName
|
|
230
|
-
* @param {string} [indexOption.doctype] - doctype
|
|
231
|
-
* @returns {Promise<import('./types').PouchDbIndex>}
|
|
232
|
-
*/
|
|
233
|
-
createIndex(fields: any[], { partialFilter, indexName, doctype }?: {
|
|
234
|
-
partialFilter: object;
|
|
235
|
-
indexName: string;
|
|
236
|
-
doctype: string;
|
|
237
|
-
}): Promise<import('./types').PouchDbIndex>;
|
|
238
|
-
/**
|
|
239
|
-
* Retrieve the PouchDB index if exist, undefined otherwise
|
|
240
|
-
*
|
|
241
|
-
* @param {string} doctype - The query's doctype
|
|
242
|
-
* @param {import('./types').MangoQueryOptions} options - The find options
|
|
243
|
-
* @param {string} indexName - The index name
|
|
244
|
-
* @returns {import('./types').PouchDbIndex | undefined}
|
|
245
|
-
*/
|
|
246
|
-
findExistingIndex(doctype: string, options: import('./types').MangoQueryOptions, indexName: string): import('./types').PouchDbIndex | undefined;
|
|
247
|
-
/**
|
|
248
|
-
* Handle index creation if it is missing.
|
|
249
|
-
*
|
|
250
|
-
* When an index is missing, we first check if there is one with a different
|
|
251
|
-
* name but the same definition. If there is none, we create the new index.
|
|
252
|
-
*
|
|
253
|
-
* /!\ Warning: this method is similar to DocumentCollection.handleMissingIndex()
|
|
254
|
-
* If you edit this method, please check if the change is also needed in DocumentCollection
|
|
255
|
-
*
|
|
256
|
-
* @param {string} doctype The mango selector
|
|
257
|
-
* @param {import('./types').MangoQueryOptions} options The find options
|
|
258
|
-
* @returns {Promise<import('./types').PouchDbIndex>} index
|
|
259
|
-
* @private
|
|
260
|
-
*/
|
|
261
|
-
private ensureIndex;
|
|
262
213
|
executeQuery({ doctype, selector, sort, fields, limit, id, ids, skip, indexedFields, partialFilter }: {
|
|
263
214
|
doctype: any;
|
|
264
215
|
selector: any;
|
|
@@ -270,16 +221,7 @@ declare class PouchLink extends CozyLink {
|
|
|
270
221
|
skip: any;
|
|
271
222
|
indexedFields: any;
|
|
272
223
|
partialFilter: any;
|
|
273
|
-
}): Promise<
|
|
274
|
-
data: any;
|
|
275
|
-
meta: {
|
|
276
|
-
count: any;
|
|
277
|
-
};
|
|
278
|
-
skip: any;
|
|
279
|
-
next: boolean;
|
|
280
|
-
} | {
|
|
281
|
-
data: any;
|
|
282
|
-
}>;
|
|
224
|
+
}): Promise<any>;
|
|
283
225
|
executeMutation(mutation: any, options: any, result: any, forward: any): Promise<any>;
|
|
284
226
|
createDocument(mutation: any): Promise<any>;
|
|
285
227
|
updateDocument(mutation: any): Promise<any>;
|
|
@@ -291,4 +233,5 @@ declare class PouchLink extends CozyLink {
|
|
|
291
233
|
}
|
|
292
234
|
import { CozyLink } from "cozy-client";
|
|
293
235
|
import { PouchLocalStorage } from "./localStorage";
|
|
236
|
+
import PouchDBQueryEngine from "./db/pouchdb/pouchdb";
|
|
294
237
|
import PouchManager from "./PouchManager";
|
package/types/PouchManager.d.ts
CHANGED
|
@@ -10,9 +10,12 @@ declare class PouchManager {
|
|
|
10
10
|
options: any;
|
|
11
11
|
doctypes: any;
|
|
12
12
|
storage: PouchLocalStorage;
|
|
13
|
+
queryEngine: any;
|
|
14
|
+
client: any;
|
|
13
15
|
PouchDB: any;
|
|
14
16
|
isOnline: any;
|
|
15
17
|
events: any;
|
|
18
|
+
dbQueryEngines: Map<any, any>;
|
|
16
19
|
init(): Promise<void>;
|
|
17
20
|
pouches: import("lodash").Dictionary<any>;
|
|
18
21
|
/** @type {Record<string, import('./types').SyncInfo>} - Stores synchronization info per doctype */
|
|
@@ -62,7 +65,9 @@ declare class PouchManager {
|
|
|
62
65
|
handleReplicationError(err: any): void;
|
|
63
66
|
cancelCurrentReplications(): void;
|
|
64
67
|
waitForCurrentReplications(): Promise<void> | Promise<(import("./utils").FulfilledPromise | import("./utils").RejectedPromise)[]>;
|
|
65
|
-
getPouch(
|
|
68
|
+
getPouch(dbName: any): any;
|
|
69
|
+
setQueryEngine(name: any, doctype: any): any;
|
|
70
|
+
getQueryEngine(name: any, doctype: any): any;
|
|
66
71
|
/**
|
|
67
72
|
* Update the Sync info for the specifed doctype
|
|
68
73
|
*
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function open(): void;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
export default DatabaseQueryEngine;
|
|
2
|
+
export type FindParams = {
|
|
3
|
+
/**
|
|
4
|
+
* - The mango selector
|
|
5
|
+
*/
|
|
6
|
+
selector: object;
|
|
7
|
+
/**
|
|
8
|
+
* - Following the mango selector syntax, used to filter out documents at indexing time
|
|
9
|
+
*/
|
|
10
|
+
partialFilter: object;
|
|
11
|
+
/**
|
|
12
|
+
* - The mango sort
|
|
13
|
+
*/
|
|
14
|
+
sort: any[];
|
|
15
|
+
/**
|
|
16
|
+
* - The doctype
|
|
17
|
+
*/
|
|
18
|
+
doctype: string;
|
|
19
|
+
/**
|
|
20
|
+
* - Array of indexed field name
|
|
21
|
+
*/
|
|
22
|
+
indexedFields: Array<string>;
|
|
23
|
+
/**
|
|
24
|
+
* - Maximum number of documents to return
|
|
25
|
+
*/
|
|
26
|
+
limit: number;
|
|
27
|
+
/**
|
|
28
|
+
* - Number of documents to skip
|
|
29
|
+
*/
|
|
30
|
+
skip: number;
|
|
31
|
+
/**
|
|
32
|
+
* - Whether or not an existing index should be recreated
|
|
33
|
+
*/
|
|
34
|
+
recreateIndex: boolean;
|
|
35
|
+
};
|
|
36
|
+
export type AllDocsParams = {
|
|
37
|
+
/**
|
|
38
|
+
* - Maximum number of documents to return
|
|
39
|
+
*/
|
|
40
|
+
limit: number;
|
|
41
|
+
/**
|
|
42
|
+
* - Number of documents to skip
|
|
43
|
+
*/
|
|
44
|
+
skip: number;
|
|
45
|
+
};
|
|
46
|
+
export type QueryResponse = {
|
|
47
|
+
/**
|
|
48
|
+
* - The documents retrieved by the query
|
|
49
|
+
*/
|
|
50
|
+
data: Array<object>;
|
|
51
|
+
};
|
|
52
|
+
export type QueryResponseSingleDoc = {
|
|
53
|
+
/**
|
|
54
|
+
* - The document retrieved by the query
|
|
55
|
+
*/
|
|
56
|
+
data: object;
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* @typedef {object} FindParams
|
|
60
|
+
* @property {object} selector - The mango selector
|
|
61
|
+
* @property {object} partialFilter - Following the mango selector syntax, used to filter out documents at indexing time
|
|
62
|
+
* @property {Array} sort - The mango sort
|
|
63
|
+
* @property {string} doctype - The doctype
|
|
64
|
+
* @property {Array<string>} indexedFields - Array of indexed field name
|
|
65
|
+
* @property {number} limit - Maximum number of documents to return
|
|
66
|
+
* @property {number} skip - Number of documents to skip
|
|
67
|
+
* @property {boolean} recreateIndex - Whether or not an existing index should be recreated
|
|
68
|
+
*/
|
|
69
|
+
/**
|
|
70
|
+
* @typedef {object} AllDocsParams
|
|
71
|
+
* @property {number} limit - Maximum number of documents to return
|
|
72
|
+
* @property {number} skip - Number of documents to skip
|
|
73
|
+
*/
|
|
74
|
+
/**
|
|
75
|
+
* @typedef {object} QueryResponse
|
|
76
|
+
* @property {Array<object>} data - The documents retrieved by the query
|
|
77
|
+
*/
|
|
78
|
+
/**
|
|
79
|
+
* @typedef {object} QueryResponseSingleDoc
|
|
80
|
+
* @property {object} data - The document retrieved by the query
|
|
81
|
+
*/
|
|
82
|
+
declare class DatabaseQueryEngine {
|
|
83
|
+
/**
|
|
84
|
+
* Open the database
|
|
85
|
+
*
|
|
86
|
+
* @param {string} dbName - The database name
|
|
87
|
+
*/
|
|
88
|
+
openDB(dbName: string): void;
|
|
89
|
+
/**
|
|
90
|
+
* Find docs with filtered query
|
|
91
|
+
*
|
|
92
|
+
* @param {FindParams} options - The find options
|
|
93
|
+
* @returns {Promise<QueryResponse>} The found docs
|
|
94
|
+
*/
|
|
95
|
+
find(options: FindParams): Promise<QueryResponse>;
|
|
96
|
+
/**
|
|
97
|
+
* Get all docs
|
|
98
|
+
*
|
|
99
|
+
* @param {AllDocsParams} options - The all docs options
|
|
100
|
+
* @returns {Promise<QueryResponse>} The found docs
|
|
101
|
+
*/
|
|
102
|
+
allDocs(options: AllDocsParams): Promise<QueryResponse>;
|
|
103
|
+
/**
|
|
104
|
+
* Get a single doc by its id
|
|
105
|
+
*
|
|
106
|
+
* @param {string} id - id of the document to get
|
|
107
|
+
* @returns {Promise<QueryResponseSingleDoc>} The found docs
|
|
108
|
+
*/
|
|
109
|
+
getById(id: string): Promise<QueryResponseSingleDoc>;
|
|
110
|
+
/**
|
|
111
|
+
* Get several docs by their ids
|
|
112
|
+
*
|
|
113
|
+
* @param {Array<string>} ids - ids of the documents to get
|
|
114
|
+
* @returns {Promise<QueryResponse>} The found docs
|
|
115
|
+
*/
|
|
116
|
+
getByIds(ids: Array<string>): Promise<QueryResponse>;
|
|
117
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export function getExistingDocument(queryEngine: DatabaseQueryEngine, id: string, throwIfNotFound?: boolean): Promise<import('./dbInterface').QueryResponseSingleDoc>;
|
|
2
|
+
export function areDocsEqual(oldDoc: any, newDoc: any): Promise<boolean>;
|
|
3
|
+
export function getCozyPouchData(doc: import('../CozyPouchLink').CozyPouchDocument): Array<import('cozy-client/types/types').CozyClientDocument>;
|
|
4
|
+
import DatabaseQueryEngine from "./dbInterface";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export function getDocsAndNormalize({ client, doctype, db, queryFunc, queryParams, withRows }: {
|
|
2
|
+
client: any;
|
|
3
|
+
doctype: any;
|
|
4
|
+
db: any;
|
|
5
|
+
queryFunc: any;
|
|
6
|
+
queryParams?: {};
|
|
7
|
+
withRows?: boolean;
|
|
8
|
+
}): Promise<{
|
|
9
|
+
data: any;
|
|
10
|
+
meta: {
|
|
11
|
+
count: any;
|
|
12
|
+
};
|
|
13
|
+
skip: any;
|
|
14
|
+
next: boolean;
|
|
15
|
+
} | {
|
|
16
|
+
data: any;
|
|
17
|
+
}>;
|
|
18
|
+
export function getDocs(db: any, fct: any, queryParams?: {}): any;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export function keepDocWitHighestRev(docs: any): any;
|
|
2
|
+
export function parseResults(client: any, result: any, doctype: any, { isSingleDoc, skip, limit }?: {
|
|
3
|
+
isSingleDoc?: boolean;
|
|
4
|
+
skip?: number;
|
|
5
|
+
limit?: number;
|
|
6
|
+
}): {
|
|
7
|
+
data: any;
|
|
8
|
+
meta?: undefined;
|
|
9
|
+
skip?: undefined;
|
|
10
|
+
next?: undefined;
|
|
11
|
+
} | {
|
|
12
|
+
data: any[];
|
|
13
|
+
meta: {
|
|
14
|
+
count: number;
|
|
15
|
+
};
|
|
16
|
+
skip: number;
|
|
17
|
+
next: boolean;
|
|
18
|
+
};
|
|
19
|
+
export function mangoSelectorToSQL(selector: any): string;
|
|
20
|
+
export function makeWhereClause(selector: any): string;
|
|
21
|
+
export function makeSortClause(mangoSortBy: any): string;
|
|
22
|
+
export function makeSQLQueryFromMango({ selector, sort, indexName, limit, skip }: {
|
|
23
|
+
selector: any;
|
|
24
|
+
sort: any;
|
|
25
|
+
indexName: any;
|
|
26
|
+
limit?: number;
|
|
27
|
+
skip?: number;
|
|
28
|
+
}): string;
|
|
29
|
+
export function makeSQLQueryForId(id: any): string;
|
|
30
|
+
export function makeSQLQueryForIds(ids: any): string;
|
|
31
|
+
export function makeSQLQueryAll({ limit, skip }?: {
|
|
32
|
+
limit?: number;
|
|
33
|
+
skip?: number;
|
|
34
|
+
}): string;
|
|
35
|
+
export function makeSQLDropIndex(indexName: any): string;
|
|
36
|
+
export function makeSQLCreateMangoIndex(indexName: any, fieldsToIndex: any, { partialFilter }: {
|
|
37
|
+
partialFilter: any;
|
|
38
|
+
}): string;
|
|
39
|
+
export function makeSQLCreateDocIDIndex(): string;
|
|
40
|
+
export function makeSQLCreateDeletedIndex(): string;
|
|
41
|
+
export function createMangoIndex(db: any, indexName: any, fieldsToIndex: any, { partialFilter }: {
|
|
42
|
+
partialFilter: any;
|
|
43
|
+
}): Promise<any>;
|
|
44
|
+
export function deleteIndex(db: any, indexName: any): Promise<void>;
|
|
45
|
+
export function executeSQL(db: any, sql: any): Promise<any>;
|
package/types/errors.d.ts
CHANGED
package/types/helpers.d.ts
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
+
export const LIMIT_BUG: 999;
|
|
1
2
|
export default helpers;
|
|
2
3
|
declare namespace helpers {
|
|
3
4
|
function isAdapterBugged(adapterName: any): boolean;
|
|
4
|
-
function withoutDesignDocuments(res: any): any;
|
|
5
|
-
function getDocs(db: any, fct: any, options?: {}): any;
|
|
6
|
-
function allDocs(db: any, options?: {}): Promise<any>;
|
|
7
|
-
function find(db: any, options?: {}): Promise<any>;
|
|
8
5
|
function isDesignDocument(doc: any): boolean;
|
|
9
6
|
function isDeletedDocument(doc: any): any;
|
|
10
7
|
function insertBulkDocs(db: any, docs: any): Promise<any>;
|
package/types/index.d.ts
CHANGED
package/types/jsonapi.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export function normalizeDocs(client: CozyClient, doctype: string, docs: Array<import('./CozyPouchLink').
|
|
2
|
-
export function normalizeDoc(client: CozyClient, doctype: string, doc:
|
|
1
|
+
export function normalizeDocs(client: CozyClient, doctype: string, docs: Array<import('./CozyPouchLink').CozyPouchDocument>): void;
|
|
2
|
+
export function normalizeDoc(client: CozyClient, doctype: string, doc: import('./CozyPouchLink').CozyPouchDocument): void;
|
|
3
3
|
export function fromPouchResult({ res, withRows, doctype, client }: {
|
|
4
4
|
res: any;
|
|
5
5
|
withRows: any;
|
|
@@ -15,4 +15,6 @@ export function fromPouchResult({ res, withRows, doctype, client }: {
|
|
|
15
15
|
} | {
|
|
16
16
|
data: any;
|
|
17
17
|
};
|
|
18
|
+
export function sanitized(doc: any): Pick<any, string | number | symbol>;
|
|
19
|
+
export function sanitizeJsonApi(doc: any): Pick<Pick<any, string | number | symbol>, string | number | symbol>;
|
|
18
20
|
import CozyClient from "cozy-client";
|
package/types/mango.d.ts
CHANGED
|
@@ -1,3 +1,21 @@
|
|
|
1
1
|
export function makeKeyFromPartialFilter(condition: object): string;
|
|
2
2
|
export function getIndexNameFromFields(fields: Array<string>, partialFilter?: object): string;
|
|
3
|
-
export function
|
|
3
|
+
export function getIndexFieldsFromFind({ selector, sort, partialFilter }: import('./types').MangoQueryOptions): string[];
|
|
4
|
+
export function createIndex(db: object, fields: any[], { partialFilter, indexName, doctype }?: {
|
|
5
|
+
partialFilter: object;
|
|
6
|
+
indexName: string;
|
|
7
|
+
doctype: string;
|
|
8
|
+
}): Promise<import('./types').PouchDbIndex>;
|
|
9
|
+
export function findExistingIndex(doctype: string, options: import('./types').MangoQueryOptions, indexName: string): import('./types').PouchDbIndex | undefined;
|
|
10
|
+
export function getIndexFields({ selector, sort, partialFilter, indexedFields }: {
|
|
11
|
+
selector: any;
|
|
12
|
+
sort: any;
|
|
13
|
+
partialFilter: any;
|
|
14
|
+
indexedFields: any;
|
|
15
|
+
}): any;
|
|
16
|
+
export function getIndexName({ selector, sort, indexedFields, partialFilter }: {
|
|
17
|
+
selector: any;
|
|
18
|
+
sort: any;
|
|
19
|
+
indexedFields: any;
|
|
20
|
+
partialFilter: any;
|
|
21
|
+
}): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function destroyOldDatabases(PouchDB: any, doctypes: any, prefix: any): void;
|
package/types/types.d.ts
CHANGED
|
@@ -33,6 +33,7 @@ export type LinkPlatform = {
|
|
|
33
33
|
* PouchDB class (can be pouchdb-core or pouchdb-browser)
|
|
34
34
|
*/
|
|
35
35
|
pouchAdapter: any;
|
|
36
|
+
queryEngine: DatabaseQueryEngine;
|
|
36
37
|
/**
|
|
37
38
|
* Method that check if the app is connected to internet
|
|
38
39
|
*/
|
|
@@ -144,3 +145,4 @@ export type PouchDBChanges = {
|
|
|
144
145
|
*/
|
|
145
146
|
doc: object;
|
|
146
147
|
};
|
|
148
|
+
import DatabaseQueryEngine from "./db/dbInterface";
|
package/types/utils.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
export const DATABASE_NAME_SEPARATOR: "__doctype__";
|
|
1
2
|
export function getDatabaseName(prefix: string, doctype: string): string;
|
|
3
|
+
export function getOldDatabaseName(prefix: string, doctype: string): string;
|
|
4
|
+
export function getDoctypeFromDatabaseName(dbName: any): any;
|
|
2
5
|
export function getPrefix(uri: string): string;
|
|
3
6
|
export function formatAggregatedError(aggregatedError: any): any;
|
|
4
7
|
export function allSettled(promises: Promise<any>[]): Promise<(FulfilledPromise | RejectedPromise)[]>;
|