react-native-mosquito-transport 0.0.21 → 0.0.23

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.
@@ -1,21 +1,32 @@
1
- import AsyncStorage from "@react-native-async-storage/async-storage";
2
1
  import { ServerReachableListener, StoreReadyListener } from "./listeners";
3
- import { CACHE_PROTOCOL, CACHE_STORAGE_PATH, DEFAULT_CACHE_PASSWORD, LOCAL_STORAGE_PATH } from "./values";
4
2
  import { CacheStore, Scoped } from "./variables";
5
- import { decryptString, encryptString, niceTry, serializeE2E } from "./peripherals";
3
+ import { serializeE2E } from "./peripherals";
6
4
  import { deserializeBSON, serializeToBase64 } from "../products/database/bson";
7
5
  import { trySendPendingWrite } from "../products/database";
8
6
  import { deserialize } from "entity-serializer";
7
+ import { openDB, SQLITE_COMMANDS, SQLITE_PATH } from "./sqlite_manager";
8
+ import { purgeRedundantRecords } from "./purger";
9
+ import { getStoreID, handleBigData, parseBigData } from "./fs_manager";
9
10
 
10
- export const updateCacheStore = (timer = 300) => {
11
- const { cachePassword = DEFAULT_CACHE_PASSWORD, cacheProtocol = CACHE_PROTOCOL.ASYNC_STORAGE, io, promoteCache } = Scoped.ReleaseCacheData;
11
+ const { FILE_NAME, TABLE_NAME } = SQLITE_PATH;
12
12
 
13
- clearTimeout(Scoped.cacheStorageReducer);
14
- Scoped.cacheStorageReducer = setTimeout(() => {
15
- const { AuthStore, EmulatedAuth, PendingAuthPurge, DatabaseStore, PendingWrites, ...restStore } = CacheStore;
13
+ const CacheKeys = Object.keys(CacheStore);
14
+
15
+ export const updateCacheStore = (timer = 300, node) => {
16
+ const { io, promoteCache } = Scoped.ReleaseCacheData;
17
+
18
+ const doUpdate = async () => {
19
+ const {
20
+ AuthStore,
21
+ EmulatedAuth,
22
+ PendingAuthPurge,
23
+ DatabaseStore,
24
+ PendingWrites,
25
+ ...restStore
26
+ } = CacheStore;
16
27
 
17
- const txt = encryptString(
18
- JSON.stringify({
28
+ if (io) {
29
+ const txt = JSON.stringify({
19
30
  AuthStore,
20
31
  EmulatedAuth,
21
32
  PendingAuthPurge,
@@ -24,51 +35,75 @@ export const updateCacheStore = (timer = 300) => {
24
35
  PendingWrites: serializeToBase64(PendingWrites)
25
36
  } : {},
26
37
  ...promoteCache ? restStore : {}
27
- }),
28
- cachePassword,
29
- cachePassword
30
- );
38
+ });
31
39
 
32
- if (io) {
33
- io.output(txt);
34
- } else if (cacheProtocol === CACHE_PROTOCOL.ASYNC_STORAGE) {
35
- AsyncStorage.setItem(CACHE_STORAGE_PATH, txt);
36
- } else if (cacheProtocol === CACHE_PROTOCOL.SQLITE) {
37
- console.error('unsupported protocol "sqlite"');
40
+ io.output(txt, node);
38
41
  } else {
39
- const fs = require('react-native-fs');
40
- fs.writeFile(LOCAL_STORAGE_PATH(), txt, 'utf8');
42
+ // use sqlite
43
+ const exclusion = ['DatabaseStore', 'DatabaseCountResult', 'FetchedStore'];
44
+ const updationKey = (node ? Array.isArray(node) ? node : [node] : CacheKeys).filter(v => !exclusion.includes(v));
45
+
46
+ if (!updationKey.length) return;
47
+ const sqlite = await openDB(FILE_NAME);
48
+ await Promise.all(
49
+ updationKey
50
+ .map(v => [v, v === 'PendingWrites' ? serializeToBase64(CacheStore[v]) : CacheStore[v]])
51
+ .map(async ([ref, value]) => {
52
+ const blobData = await handleBigData(getStoreID(FILE_NAME, TABLE_NAME, ref), value);
53
+ return sqlite.executeSql(SQLITE_COMMANDS.MERGE(TABLE_NAME, ['ref', 'value']), [ref, blobData]);
54
+ })
55
+ ).catch(err => {
56
+ console.error('updateCacheStore err:', err);
57
+ }).finally(() => {
58
+ sqlite.close();
59
+ });
41
60
  }
42
- }, timer);
61
+ };
62
+
63
+ clearTimeout(Scoped.cacheStorageReducer);
64
+ if (timer) {
65
+ Scoped.cacheStorageReducer = setTimeout(doUpdate, timer);
66
+ } else doUpdate();
43
67
  };
44
68
 
45
69
  export const releaseCacheStore = async (builder) => {
46
- const { cachePassword = DEFAULT_CACHE_PASSWORD, cacheProtocol = CACHE_PROTOCOL.ASYNC_STORAGE, io } = builder;
70
+ const { io } = builder;
47
71
 
48
- let txt;
72
+ let data = {};
49
73
 
50
- if (io) {
51
- txt = await io.input();
52
- } else if (cacheProtocol === CACHE_PROTOCOL.ASYNC_STORAGE) {
53
- txt = await niceTry(() => AsyncStorage.getItem(CACHE_STORAGE_PATH));
54
- } else {
55
- const fs = require('react-native-fs');
56
- txt = await niceTry(() => fs.readFile(LOCAL_STORAGE_PATH(), 'utf8'));
74
+ try {
75
+ if (io) {
76
+ data = JSON.parse((await io.input()) || '{}');
77
+ } else {
78
+ const sqlite = await openDB(FILE_NAME);
79
+ await sqlite.executeSql(`CREATE TABLE IF NOT EXISTS ${TABLE_NAME} ( ref TEXT PRIMARY KEY, value BLOB )`).catch(() => null);
80
+ try {
81
+ const [query] = await sqlite.executeSql(`SELECT * FROM ${TABLE_NAME}`);
82
+ data = Object.fromEntries(
83
+ await Promise.all(query.rows.raw().map(async v =>
84
+ [v.ref, await parseBigData(v.value)]
85
+ ))
86
+ );
87
+ } catch (error) {
88
+ console.error('initializeCache sqlite data release err:', error);
89
+ } finally {
90
+ sqlite.close();
91
+ }
92
+ }
93
+ await purgeRedundantRecords(data, builder);
94
+ } catch (e) {
95
+ console.error('initializeCache data err:', e);
57
96
  }
58
97
 
59
- const j = JSON.parse(decryptString(txt || '', cachePassword, cachePassword) || '{}');
60
- const projectList = new Set([]);
61
-
62
- Object.entries(j).forEach(([k, v]) => {
98
+ Object.entries(data).forEach(([k, v]) => {
63
99
  if (['DatabaseStore', 'PendingWrites'].includes(k)) {
64
100
  CacheStore[k] = deserializeBSON(v);
65
101
  } else CacheStore[k] = v;
66
- projectList.add(k);
67
102
  });
68
103
  Object.entries(CacheStore.AuthStore).forEach(([key, value]) => {
69
104
  Scoped.AuthJWTToken[key] = value?.token;
70
105
  });
71
- projectList.forEach(projectUrl => {
106
+ Object.keys(CacheStore.PendingWrites).forEach(projectUrl => {
72
107
  if (Scoped.IS_CONNECTED[projectUrl])
73
108
  trySendPendingWrite(projectUrl);
74
109
  });
@@ -117,18 +152,17 @@ export const getReachableServer = (projectUrl) => new Promise(resolve => {
117
152
  }, true);
118
153
  });
119
154
 
120
- export const buildFetchInterface = async ({ body, accessKey, authToken, method, uglify, serverE2E_PublicKey, extraHeaders }) => {
155
+ export const buildFetchInterface = async ({ body, authToken, method, uglify, serverE2E_PublicKey, extraHeaders }) => {
121
156
  if (!uglify) body = JSON.stringify({ ...body });
122
157
  const [plate, keyPair] = uglify ? await serializeE2E(body, authToken, serverE2E_PublicKey) : [undefined, []];
123
158
 
124
159
  return [{
125
160
  body: uglify ? plate : body,
126
- cache: 'no-cache',
161
+ // cache: 'no-cache',
127
162
  headers: {
163
+ ...extraHeaders,
128
164
  'Content-type': uglify ? 'request/buffer' : 'application/json',
129
- 'Authorization': accessKey,
130
- ...(authToken && !uglify) ? { 'Mosquito-Token': authToken } : {},
131
- ...extraHeaders
165
+ ...(authToken && !uglify) ? { 'Mosquito-Token': authToken } : {}
132
166
  },
133
167
  method: method || 'POST'
134
168
  }, keyPair];
@@ -1,24 +1,10 @@
1
- import { Platform } from 'react-native';
2
- import { encodeBinary } from './peripherals';
3
-
4
- export const CACHE_STORAGE_PATH = encodeBinary('MOSQUITO_TRANSPORT_FREEZER'),
5
- DEFAULT_CACHE_PASSWORD = encodeBinary('MOSQUITO_TRANSPORT_CACHE_PASSWORD'),
6
- LOCAL_STORAGE_PATH = () => {
7
- const fs = require('react-native-fs');
8
- return `${Platform.OS === 'android' ? fs.ExternalCachesDirectoryPath : fs.CachesDirectoryPath}/${encodeBinary('MOSQUITO_TRANSPORT_STORAGE')}`;
9
- };
10
-
11
- export const CACHE_PROTOCOL = {
12
- ASYNC_STORAGE: 'async-storage',
13
- REACT_NATIVE_FS: 'reat-native-fs',
14
- SQLITE: 'sqlite' // TODO:
15
- };
16
1
 
17
2
  export const RETRIEVAL = {
18
3
  STICKY: 'sticky',
19
4
  STICKY_NO_AWAIT: 'sticky-no-await',
20
5
  STICKY_RELOAD: 'sticky-reload',
21
6
  DEFAULT: 'default',
7
+ CACHE_AWAIT: 'cache-await',
22
8
  CACHE_NO_AWAIT: 'cache-no-await',
23
9
  NO_CACHE_NO_AWAIT: 'no-cache-no-await',
24
10
  NO_CACHE_AWAIT: 'no-cache-await'
@@ -26,11 +12,10 @@ export const RETRIEVAL = {
26
12
 
27
13
  export const DELIVERY = {
28
14
  DEFAULT: 'default',
29
- NO_CACHE: 'no-cache',
30
- NO_AWAIT: 'no-await',
31
- NO_AWAIT_NO_CACHE: 'no-await-no-cache',
32
- AWAIT_NO_CACHE: 'await-no-cache',
33
- CACHE_NO_AWAIT: 'cache-no-await'
15
+ CACHE_AWAIT: 'cache-await',
16
+ CACHE_NO_AWAIT: 'cache-no-await',
17
+ NO_CACHE_NO_AWAIT: 'no-cache-no-await',
18
+ NO_CACHE_AWAIT: 'no-cache-await'
34
19
  };
35
20
 
36
21
  export const AUTH_PROVIDER_ID = {
@@ -14,26 +14,52 @@ export const Scoped = {
14
14
  LastTokenRefreshRef: {},
15
15
  StorageProcessID: 0,
16
16
  InitiatedForcedToken: {},
17
- PendingFetchCollective: {
18
- pendingProcess: {},
19
- pendingResolution: {}
20
- },
21
- PendingDbReadCollective: {
22
- pendingProcess: {},
23
- pendingResolution: {}
24
- },
17
+ PendingFetchCollective: {},
18
+ PendingDbReadCollective: {},
25
19
  ActiveDatabaseListeners: {},
26
20
  OutgoingWrites: {},
27
21
  /**
28
22
  * @type {Promise<any> | undefined}
29
23
  */
30
- dispatchingWritesPromise: undefined
24
+ dispatchingWritesPromise: undefined,
25
+ linearSqliteProcess: {
26
+ database: {},
27
+ dbQueryCount: {},
28
+ httpFetch: {}
29
+ },
30
+ initedSqliteInstances: {
31
+ httpFetch: {},
32
+ dbQueryCount: {},
33
+ database: {}
34
+ }
35
+ };
36
+
37
+ export const SqliteCollective = {
38
+ openedDb: {},
39
+ openedDbProcess: {},
40
+ closeDbPromises: {},
41
+ openedDbReducerTimer: {}
31
42
  };
32
43
 
33
44
  export const CacheStore = {
34
45
  DatabaseStore: {},
35
46
  DatabaseCountResult: {},
36
- DatabaseStats: {},
47
+ DatabaseStats: {
48
+ /**
49
+ * @type {{[projectUrl: string]: {[dbUrl: string]: {[dbName: string]: {[path: string]: number}}}}}
50
+ */
51
+ database: {},
52
+ /**
53
+ * @type {{[projectUrl: string]: {[dbUrl: string]: {[dbName: string]: {[path: string]: boolean}}}}}
54
+ */
55
+ counters: {},
56
+ /**
57
+ * @type {{[projectUrl: string]: number}}
58
+ */
59
+ fetchers: {},
60
+ _db_size: 0,
61
+ _fetcher_size: 0
62
+ },
37
63
  AuthStore: {},
38
64
  PendingAuthPurge: {},
39
65
  EmulatedAuth: {},
package/src/index.d.ts CHANGED
@@ -2,10 +2,16 @@ interface RNMTConfig {
2
2
  dbName?: string;
3
3
  dbUrl?: string;
4
4
  projectUrl: string;
5
+ /**
6
+ * disable caching for database and fetchHttp in this instance.
7
+ *
8
+ * defaults to `false` but `true` in scenerio where an invoked fetchHttp does have a request body and disableCache is undefined
9
+ */
5
10
  disableCache?: boolean;
6
- accessKey: string;
7
11
  /**
8
- * maximum numbers of attempts to retry sending a request
12
+ * maximum numbers of attempts to retry sending a failed request
13
+ *
14
+ * @default 3
9
15
  */
10
16
  maxRetries?: number;
11
17
  /**
@@ -37,6 +43,7 @@ interface GetDatabase {
37
43
  interface mtimestamp { $timestamp: 'now' }
38
44
 
39
45
  export const TIMESTAMP: mtimestamp;
46
+ export function TIMESTAMP_OFFSET(offset: number): { $timestamp_offset: number };
40
47
  export function DOCUMENT_EXTRACTION(path: string): { $dynamicValue: string };
41
48
 
42
49
  type longitude = number;
@@ -64,6 +71,7 @@ export const AUTH_PROVIDER_ID: auth_provider_id;
64
71
  * useful for avoiding encrypting data and extra overhead
65
72
  */
66
73
  export class DoNotEncrypt {
74
+ constructor(value: any);
67
75
  value: any;
68
76
  }
69
77
 
@@ -84,40 +92,45 @@ type auth_provider_id_values = auth_provider_id['GOOGLE'] |
84
92
  auth_provider_id['APPLE'];
85
93
 
86
94
  interface ReleaseCacheOption_IO {
95
+ }
96
+
97
+ interface ReleaseCacheOption {
87
98
  /**
88
- * This password will be used to encrypt data stored locally
99
+ * This key will be used to encrypt sqlite data stored locally
100
+ */
101
+ sqliteKey?: string;
102
+ /**
103
+ * sqlite is used as the default caching mechanism
104
+ *
105
+ * providing `io` means you want to override this behaviour and handle caching yourself in the system's memory
89
106
  */
90
- cachePassword?: string;
91
107
  io: {
92
108
  /**
93
- * feeds mosquito-transport data
109
+ * you should handle retrieval of mosquito-transport data here by returning it
94
110
  */
95
- input: () => string;
111
+ input: () => string | Promise<string>;
96
112
  /**
97
- * emits mosquito-transport internal data
113
+ * you should handle storage of mosquito-transport data here by caching the emitted string
98
114
  */
99
115
  output: (data: string) => void;
100
- };
101
- }
102
-
103
- interface ReleaseCacheOption {
104
- /**
105
- * This password will be used to encrypt data stored locally
106
- */
107
- cachePassword?: string;
116
+ },
108
117
  /**
109
- * select the mechanism for storing data locally
110
- * - async-storage: uses [@react-native-async-storage/async-storage](https://github.com/react-native-async-storage/async-storage) for storing data, make sure you have this package installed before setting this as the value
111
- * - reat-native-fs: uses [reat-native-fs](https://github.com/itinance/react-native-fs) for storing data, make sure you have this package installed before setting this as the value
118
+ * the maximum size allocated to local database
119
+ *
120
+ * when local database size exceed this value, redundant database documents will be purge retaining only recently used ones
121
+ *
122
+ * @default 10485760 - 'which is 10 megabytes'
112
123
  */
113
- cacheProtocol?: 'async-storage' | 'reat-native-fs';
124
+ maxLocalDatabaseSize?: number;
114
125
  /**
115
- * the maximum database size
126
+ * the maximum size allocated to local database for storing {@link RNMT.fetchHttp}
127
+ *
128
+ * @default 10485760 - 'which is 10 megabytes'
116
129
  */
117
- heapMemory?: number;
130
+ maxLocalFetchHttpSize?: number;
118
131
  /**
119
132
  * true to cache database and {@link RNMT.fetchHttp} data.
120
- * the value only applies to in-memory storage protocol such as `io`, `async-storage` and `reat-native-fs`
133
+ * the value only applies to in-memory storage protocol such as `io`
121
134
  *
122
135
  * @default false
123
136
  */
@@ -146,16 +159,28 @@ interface BatchWriteConfig extends WriteConfig {
146
159
  stepping?: boolean;
147
160
  }
148
161
 
162
+ interface CountConfig {
163
+ disableAuth?: boolean;
164
+ }
165
+
166
+ interface FetchHttpResponse extends Response {
167
+ /**
168
+ * true if this response was from local cache
169
+ */
170
+ fromCache?: boolean | undefined;
171
+ }
172
+
149
173
  export default class RNMT {
150
174
  constructor(config: RNMTConfig);
151
- static initializeCache(option?: ReleaseCacheOption | ReleaseCacheOption_IO): void;
175
+ static initializeCache(option?: ReleaseCacheOption): void;
152
176
  getDatabase(dbName?: string, dbUrl?: string): GetDatabase;
153
177
  collection(path: string): RNMTCollection;
154
178
  auth(): RNMTAuth;
155
179
  storage(): RNMTStorage;
156
- fetchHttp(endpoint: string, init?: RequestInit, config?: FetchHttpConfig): Promise<Response>;
180
+ fetchHttp(endpoint: string, init?: RequestInit, config?: FetchHttpConfig): Promise<FetchHttpResponse>;
157
181
  listenReachableServer(callback: (reachable: boolean) => void): () => void;
158
182
  getSocket(options: { disableAuth?: boolean; authHandshake?: Object }): RNMTSocket;
183
+ onConnect: () => CollectionIO;
159
184
  batchWrite(map: BatchWriteValue[], config?: BatchWriteConfig): Promise<DocumentWriteResult[] | undefined>;
160
185
  }
161
186
 
@@ -163,7 +188,7 @@ interface RNMTCollection {
163
188
  find: (find?: DocumentFind) => ({
164
189
  get: (config?: GetConfig) => Promise<DocumentResult[]>;
165
190
  listen: (callback: (snapshot?: DocumentResult[]) => void, onError?: (error?: DocumentError) => void, config?: GetConfig) => void;
166
- count: () => Promise<number>;
191
+ count: (config?: CountConfig) => Promise<number>;
167
192
  limit: (limit: number) => ({
168
193
  random: (config?: GetConfig) => Promise<DocumentResult[]>;
169
194
  get: (config?: GetConfig) => Promise<DocumentResult[]>;
@@ -199,25 +224,13 @@ interface RNMTCollection {
199
224
  listen: (callback: (snapshot?: DocumentResult[]) => void, onError?: (error?: DocumentError) => void, config?: GetConfig) => void;
200
225
  })
201
226
  });
202
- count: () => Promise<number>;
227
+ count: (config?: CountConfig) => Promise<number>;
203
228
  get: (config?: GetConfig) => Promise<DocumentResult[]>;
204
229
  listen: (callback: (snapshot?: DocumentResult[]) => void, onError?: (error?: DocumentError) => void, config?: GetConfig) => void;
205
230
  findOne: (findOne?: DocumentFind) => ({
206
231
  get: (config?: GetConfig) => Promise<DocumentResult>;
207
232
  listen: (callback: (snapshot?: DocumentResult) => void, onError?: (error?: DocumentError) => void, config?: GetConfig) => void;
208
233
  });
209
- onDisconnect: () => ({
210
- setOne: (value: DocumentWriteValue) => () => void;
211
- setMany: (value: DocumentWriteValue[]) => () => void;
212
- updateOne: (find: DocumentFind, value: DocumentWriteValue) => () => void;
213
- updateMany: (find: DocumentFind, value: DocumentWriteValue) => () => void;
214
- mergeOne: (find: DocumentFind, value: DocumentWriteValue) => () => void;
215
- mergeMany: (find: DocumentFind, value: DocumentWriteValue) => () => void;
216
- replaceOne: (find: DocumentFind, value: DocumentWriteValue) => () => void;
217
- putOne: (find: DocumentFind, value: DocumentWriteValue) => () => void;
218
- deleteOne: (find: DocumentFind) => () => void;
219
- deleteMany: (find?: DocumentFind) => () => void;
220
- })
221
234
 
222
235
  setOne: (value: DocumentWriteValue, config?: WriteConfig) => Promise<DocumentWriteResult>;
223
236
 
@@ -240,8 +253,24 @@ interface RNMTCollection {
240
253
  deleteMany: (find?: DocumentFind, config?: WriteConfig) => Promise<DocumentWriteResult>;
241
254
  }
242
255
 
243
- interface DocumentResult {
244
- _id: any
256
+ interface CollectionTaskIO<T> {
257
+ batchWrite(map: BatchWriteValue[], config?: BatchWriteConfig): T;
258
+ }
259
+
260
+ interface StartStop {
261
+ start: () => () => void;
262
+ }
263
+
264
+ interface OnConnectChain extends StartStop {
265
+ onDisconnect: () => CollectionTaskIO<StartStop>;
266
+ }
267
+
268
+ interface CollectionIO extends CollectionTaskIO<OnConnectChain> {
269
+ onDisconnect: () => CollectionTaskIO<StartStop>;
270
+ }
271
+
272
+ interface DocumentResult extends Document {
273
+ _foreign_doc?: Document | Document[] | Document[][]
245
274
  }
246
275
 
247
276
  interface DocumentError extends ErrorResponse {
@@ -263,15 +292,21 @@ interface WriteConfig {
263
292
  */
264
293
  disableAuth?: boolean;
265
294
 
295
+ DEFAULT: 'default',
296
+ CACHE_AWAIT: 'cache-await',
297
+ CACHE_NO_AWAIT: 'cache-no-await',
298
+ NO_CACHE_NO_AWAIT: 'no-cache-no-await',
299
+ NO_CACHE_AWAIT: 'no-cache-await'
300
+
266
301
  /**
267
- * This property defines how the write will be committed and sent
302
+ * This property determines how the write will be dispatch to the remote server
303
+ * TODO:
268
304
  *
269
- * - default:
270
- * - no-cache:
271
- * - no-await:
272
- * - no-await-no-cache:
273
- * - await-no-cache:
274
- * - cache-no-await:
305
+ * `default`:
306
+ * `cache-await`:
307
+ * `cache-no-await`:
308
+ * `no-cache-no-await`:
309
+ * `no-cache-await`:
275
310
  */
276
311
  delivery?: Delievery;
277
312
  }
@@ -283,23 +318,28 @@ interface GetConfig {
283
318
  returnOnly?: string | string[];
284
319
  extraction?: GetConfigExtraction | GetConfigExtraction[];
285
320
  /**
286
- * This property determines how requested data is being access and handled
321
+ * This property determines how requested data should be accessed and handled
287
322
  *
288
- * - default: will try getting fresh data from server if server is reachable, else we check if local data exists and return it, if no local data exist we await for client->server connectivity, then try getting the data, return it and cache it for future need. ⚠️ This respect disableCache value
323
+ * `default`: will try getting fresh data from the server if the server is reachable then cache the result for future use. In scenerio where the server is unreachable, we check if local data exists and return it, if no local data exist we wait for reachable a server to complete the task.
324
+ * ⚠️ This respect `disableCache` value therefore if disableCache is true, no local cache read/write will be made for the request.
289
325
  *
290
- * - sticky: if local data exists for the specified query, such data is returned and no-ops afterwards. If no local data is found, we await for client->server connectivity and try to get fresh data from serve, return the data and cache it for future need. ⚠️ This does not respect disableCache value
326
+ * `sticky`: if local data exists for the specified query, such data is returned and no-ops afterwards. If no local data is found, we await for client->server connectivity and try to get fresh data from serve, return the data and cache it for future need. ⚠️ This overrides `disableCache` value
291
327
  *
292
- * - sticky-no-await: if local data exists for the specified query, such data is returned and no-ops afterwards. If no local data is found, will try to get fresh data from serve, we throw an error if server is not reachable else if server returns requested data, we return such data and cache it for future need. ⚠️ This does not respect disableCache value
328
+ * `sticky-no-await`: if local data exists for the specified query, such data is returned and no operation is performed afterwards. If no local data is found, will try to get fresh data from serve, we throw an error if server is unreachable else if server returns requested data, we return such data and cache it for future need. ⚠️ This overrides `disableCache` value
293
329
  *
294
- * - sticky-reload: if local data exists for the specified query, such data is returned, then will try getting fresh data from the server and caching it for future need. If no local data is found, we await for client->server connectivity and try to get fresh data from serve, return the data and cache it for future need
330
+ * `sticky-reload`: if local data exists for the specified query, such data is returned, then will try getting fresh data from the server and caching it for future need. If no local data is found, we await for a reachable server and try to get fresh data from the serve, return the data and cache it for future need. ⚠️ This overrides `disableCache` value
295
331
  *
296
- * - cache-no-await: will try getting fresh data from server if server is reachable, else we check if local data exists and return it, if no local data exist we throw an error
332
+ * `cache-await`: will try getting fresh data from the server if the server is reachable then cache the result for future use. In scenerio where the server is unreachable, then we check if local data exists and return it, if no local data exist we wait for a reachable server to complete the task. ⚠️ This overrides `disableCache` value
297
333
  *
298
- * - no-cache-no-await: will try getting fresh data from server if server is reachable, else we throw an error
334
+ * `cache-no-await`: will try getting fresh data from the server if the server is reachable then cache the result for future use. In scenerio where the server is unreachable, then we check if local data exists and return it, if no local data exist an error is thrown instead. ⚠️ This overrides `disableCache` value
299
335
  *
300
- * - no-cache-await: will try getting fresh data from server when server is reachable and the result won't be cache
336
+ * `no-cache-no-await`: will try getting fresh data from the server and the result won't be cached. In scenerio where the server is unreachable, an error will be thrown. ⚠️ This overrides `disableCache` value
337
+ *
338
+ * `no-cache-await`: will wait for a reachable server then try getting fresh data from that server and the result won't be cache. ⚠️ This overrides `disableCache` value
301
339
  *
302
340
  * To learn and see more examples on this, Please visit https://brainbehindx.com/mosquito-transport/docs/reading_data/retrieval
341
+ *
342
+ * @default 'default'
303
343
  */
304
344
  retrieval?: Retrieval;
305
345
  /**
@@ -324,7 +364,7 @@ interface GetConfig {
324
364
  *
325
365
  * ```js
326
366
  *
327
- * const mserver = new RNMT({ projectUrl: 'http..', accessKey: '..'});
367
+ * const mserver = new RNMT({ projectUrl: 'http://..' });
328
368
  *
329
369
  * // operation will be reduced to only one request
330
370
  *
@@ -375,6 +415,7 @@ interface DocumentFind {
375
415
  }
376
416
 
377
417
  declare interface Document {
418
+ _id: any;
378
419
  [key: string]: any;
379
420
  }
380
421