cozy-pouch-link 48.25.0 → 49.0.0

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.
Files changed (41) hide show
  1. package/dist/CozyPouchLink.js +593 -237
  2. package/dist/CozyPouchLink.spec.js +67 -42
  3. package/dist/PouchManager.js +317 -254
  4. package/dist/PouchManager.spec.js +91 -58
  5. package/dist/helpers.js +79 -0
  6. package/dist/helpers.spec.js +85 -1
  7. package/dist/jsonapi.js +54 -7
  8. package/dist/jsonapi.spec.js +57 -14
  9. package/dist/localStorage.js +646 -207
  10. package/dist/localStorage.spec.js +48 -0
  11. package/dist/mango.js +72 -20
  12. package/dist/mango.spec.js +1 -1
  13. package/dist/migrations/adapter.js +1 -1
  14. package/dist/platformWeb.js +120 -0
  15. package/dist/remote.js +39 -5
  16. package/dist/remote.spec.js +214 -0
  17. package/dist/replicateOnce.js +337 -0
  18. package/dist/startReplication.js +70 -45
  19. package/dist/startReplication.spec.js +374 -39
  20. package/dist/types.js +80 -0
  21. package/dist/utils.js +11 -2
  22. package/package.json +9 -5
  23. package/types/AccessToken.d.ts +16 -0
  24. package/types/CozyPouchLink.d.ts +228 -0
  25. package/types/PouchManager.d.ts +86 -0
  26. package/types/__tests__/fixtures.d.ts +48 -0
  27. package/types/__tests__/mocks.d.ts +4 -0
  28. package/types/helpers.d.ts +17 -0
  29. package/types/index.d.ts +1 -0
  30. package/types/jsonapi.d.ts +19 -0
  31. package/types/localStorage.d.ts +124 -0
  32. package/types/logger.d.ts +2 -0
  33. package/types/loop.d.ts +60 -0
  34. package/types/mango.d.ts +3 -0
  35. package/types/migrations/adapter.d.ts +18 -0
  36. package/types/platformWeb.d.ts +17 -0
  37. package/types/remote.d.ts +6 -0
  38. package/types/replicateOnce.d.ts +29 -0
  39. package/types/startReplication.d.ts +12 -0
  40. package/types/types.d.ts +104 -0
  41. package/types/utils.d.ts +3 -0
@@ -0,0 +1,12 @@
1
+ export function startReplication(pouch: object, replicationOptions: {
2
+ strategy: string;
3
+ initialReplication: boolean;
4
+ doctype: string;
5
+ warmupQueries: import('cozy-client/types/types').Query[];
6
+ }, getReplicationURL: Function, storage: import('./localStorage').PouchLocalStorage): import('./types').CancelablePromise;
7
+ export function replicateAllDocs({ db, baseUrl, doctype, storage }: {
8
+ db: object;
9
+ baseUrl: string;
10
+ doctype: string;
11
+ storage: import('./localStorage').PouchLocalStorage;
12
+ }): Promise<any[]>;
@@ -0,0 +1,104 @@
1
+ declare var _default: {};
2
+ export default _default;
3
+ export type Cancelable = {
4
+ /**
5
+ * - Cancel the promise
6
+ */
7
+ cancel?: Function;
8
+ };
9
+ export type CancelablePromise = Promise<any> & Cancelable;
10
+ export type CancelablePromises = CancelablePromise[] & Cancelable;
11
+ export type SyncStatus = "synced" | "not_synced" | "not_complete";
12
+ export type SyncInfo = {
13
+ /**
14
+ * - The date of the last synchronization
15
+ */
16
+ date: string;
17
+ /**
18
+ * - The current synchronization status
19
+ */
20
+ status: SyncStatus;
21
+ };
22
+ export type LocalStorage = {
23
+ getItem: (arg0: string) => Promise<string | null>;
24
+ setItem: (arg0: string, arg1: string) => Promise<void>;
25
+ removeItem: (arg0: string) => Promise<void>;
26
+ };
27
+ export type LinkPlatform = {
28
+ /**
29
+ * Methods to access local storage
30
+ */
31
+ storage: LocalStorage;
32
+ /**
33
+ * PouchDB class (can be pouchdb-core or pouchdb-browser)
34
+ */
35
+ pouchAdapter: any;
36
+ /**
37
+ * Method that check if the app is connected to internet
38
+ */
39
+ isOnline: () => Promise<boolean>;
40
+ };
41
+ export type MangoPartialFilter = any;
42
+ export type MangoSelector = any;
43
+ export type MangoSort = any[];
44
+ export type MangoQueryOptions = {
45
+ /**
46
+ * Selector
47
+ */
48
+ selector?: MangoSelector;
49
+ /**
50
+ * The sorting parameters
51
+ */
52
+ sort?: MangoSort;
53
+ /**
54
+ * The fields to return
55
+ */
56
+ fields?: Array<string>;
57
+ /**
58
+ * The partial filter fields
59
+ */
60
+ partialFilterFields?: Array<string>;
61
+ /**
62
+ * For pagination, the number of results to return
63
+ */
64
+ limit?: number | null;
65
+ /**
66
+ * For skip-based pagination, the number of referenced files to skip
67
+ */
68
+ skip?: number | null;
69
+ /**
70
+ * The _id of the CouchDB index to use for this request
71
+ */
72
+ indexId?: string | null;
73
+ /**
74
+ * For bookmark-based pagination, the document _id to start from
75
+ */
76
+ bookmark?: string | null;
77
+ indexedFields?: Array<string>;
78
+ /**
79
+ * Name of the index to use
80
+ */
81
+ use_index?: string;
82
+ /**
83
+ * If true, we request the stats from Couch
84
+ */
85
+ execution_stats?: boolean;
86
+ /**
87
+ * An optional partial filter
88
+ */
89
+ partialFilter?: MangoPartialFilter | null;
90
+ };
91
+ export type PouchDbIndex = {
92
+ /**
93
+ * - The ddoc's id
94
+ */
95
+ id: string;
96
+ /**
97
+ * - The ddoc's name
98
+ */
99
+ name: string;
100
+ /**
101
+ * - If the index has been created or if it already exists
102
+ */
103
+ result: 'exists' | 'created';
104
+ };
@@ -0,0 +1,3 @@
1
+ export function getDatabaseName(prefix: string, doctype: string): string;
2
+ export function getPrefix(uri: string): string;
3
+ export function formatAggregatedError(aggregatedError: any): any;