react-native-onyx 2.0.27 → 2.0.29

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/Onyx.js CHANGED
@@ -89,7 +89,8 @@ function init({ keys = {}, initialKeyStates = {}, safeEvictionKeys = [], maxCach
89
89
  * Note that it will not cause the component to have the loading prop set to true.
90
90
  * @returns an ID to use when calling disconnect
91
91
  */
92
- function connect(mapping) {
92
+ function connect(connectOptions) {
93
+ const mapping = connectOptions;
93
94
  const connectionID = lastConnectionID++;
94
95
  const callbackToStateMapping = OnyxUtils_1.default.getCallbackToStateMapping();
95
96
  callbackToStateMapping[connectionID] = mapping;
@@ -149,7 +150,7 @@ function connect(mapping) {
149
150
  }
150
151
  // If we have a withOnyxInstance that means a React component has subscribed via the withOnyx() HOC and we need to
151
152
  // group collection key member data into an object.
152
- if (mapping.withOnyxInstance) {
153
+ if ('withOnyxInstance' in mapping && mapping.withOnyxInstance) {
153
154
  if (OnyxUtils_1.default.isCollectionKey(mapping.key)) {
154
155
  OnyxUtils_1.default.getCollectionDataAndSendAsObject(matchingKeys, mapping);
155
156
  return;
@@ -192,22 +193,23 @@ function disconnect(connectionID, keyToRemoveFromEvictionBlocklist) {
192
193
  function set(key, value) {
193
194
  // If the value is null, we remove the key from storage
194
195
  const { value: valueAfterRemoving, wasRemoved } = OnyxUtils_1.default.removeNullValues(key, value);
196
+ const valueWithoutNullValues = valueAfterRemoving;
195
197
  if (OnyxUtils_1.default.hasPendingMergeForKey(key)) {
196
198
  delete OnyxUtils_1.default.getMergeQueue()[key];
197
199
  }
198
- const hasChanged = OnyxCache_1.default.hasValueChanged(key, valueAfterRemoving);
200
+ const hasChanged = OnyxCache_1.default.hasValueChanged(key, valueWithoutNullValues);
199
201
  // Logging properties only since values could be sensitive things we don't want to log
200
202
  Logger.logInfo(`set called for key: ${key}${underscore_1.default.isObject(value) ? ` properties: ${underscore_1.default.keys(value).join(',')}` : ''} hasChanged: ${hasChanged}`);
201
203
  // This approach prioritizes fast UI changes without waiting for data to be stored in device storage.
202
- const updatePromise = OnyxUtils_1.default.broadcastUpdate(key, valueAfterRemoving, hasChanged, wasRemoved);
204
+ const updatePromise = OnyxUtils_1.default.broadcastUpdate(key, valueWithoutNullValues, hasChanged, wasRemoved);
203
205
  // If the value has not changed or the key got removed, calling Storage.setItem() would be redundant and a waste of performance, so return early instead.
204
206
  if (!hasChanged || wasRemoved) {
205
207
  return updatePromise;
206
208
  }
207
- return storage_1.default.setItem(key, valueAfterRemoving)
208
- .catch((error) => OnyxUtils_1.default.evictStorageAndRetry(error, set, key, valueAfterRemoving))
209
+ return storage_1.default.setItem(key, valueWithoutNullValues)
210
+ .catch((error) => OnyxUtils_1.default.evictStorageAndRetry(error, set, key, valueWithoutNullValues))
209
211
  .then(() => {
210
- OnyxUtils_1.default.sendActionToDevTools(OnyxUtils_1.default.METHOD.SET, key, valueAfterRemoving);
212
+ OnyxUtils_1.default.sendActionToDevTools(OnyxUtils_1.default.METHOD.SET, key, valueWithoutNullValues);
211
213
  return updatePromise;
212
214
  });
213
215
  }
@@ -231,7 +233,8 @@ function multiSet(data) {
231
233
  .then(() => {
232
234
  OnyxUtils_1.default.sendActionToDevTools(OnyxUtils_1.default.METHOD.MULTI_SET, undefined, data);
233
235
  return Promise.all(updatePromises);
234
- });
236
+ })
237
+ .then(() => undefined);
235
238
  }
236
239
  /**
237
240
  * Merge a new value into an existing value at a key.
@@ -344,7 +347,8 @@ function mergeCollection(collectionKey, collection) {
344
347
  if (hasCollectionKeyCheckFailed) {
345
348
  return Promise.resolve();
346
349
  }
347
- return OnyxUtils_1.default.getAllKeys().then((persistedKeys) => {
350
+ return OnyxUtils_1.default.getAllKeys()
351
+ .then((persistedKeys) => {
348
352
  // Split to keys that exist in storage and keys that don't
349
353
  const keys = Object.keys(mergedCollection).filter((key) => {
350
354
  if (mergedCollection[key] === null) {
@@ -388,7 +392,8 @@ function mergeCollection(collectionKey, collection) {
388
392
  OnyxUtils_1.default.sendActionToDevTools(OnyxUtils_1.default.METHOD.MERGE_COLLECTION, undefined, mergedCollection);
389
393
  return promiseUpdate;
390
394
  });
391
- });
395
+ })
396
+ .then(() => undefined);
392
397
  }
393
398
  /**
394
399
  * Clear out all the data in the store
@@ -412,7 +417,8 @@ function mergeCollection(collectionKey, collection) {
412
417
  * @param keysToPreserve is a list of ONYXKEYS that should not be cleared with the rest of the data
413
418
  */
414
419
  function clear(keysToPreserve = []) {
415
- return OnyxUtils_1.default.getAllKeys().then((keys) => {
420
+ return OnyxUtils_1.default.getAllKeys()
421
+ .then((keys) => {
416
422
  const keysToBeClearedFromStorage = [];
417
423
  const keyValuesToResetAsCollection = {};
418
424
  const keyValuesToResetIndividually = {};
@@ -477,12 +483,13 @@ function clear(keysToPreserve = []) {
477
483
  DevTools_1.default.clearState(keysToPreserve);
478
484
  return Promise.all(updatePromises);
479
485
  });
480
- });
486
+ })
487
+ .then(() => undefined);
481
488
  }
482
489
  /**
483
490
  * Insert API responses and lifecycle data into Onyx
484
491
  *
485
- * @param data An array of objects with shape {onyxMethod: oneOf('set', 'merge', 'mergeCollection', 'multiSet', 'clear'), key: string, value: *}
492
+ * @param data An array of objects with update expressions
486
493
  * @returns resolves when all operations are complete
487
494
  */
488
495
  function update(data) {
@@ -525,7 +532,7 @@ function update(data) {
525
532
  break;
526
533
  }
527
534
  });
528
- return clearPromise.then(() => Promise.all(promises.map((p) => p())));
535
+ return clearPromise.then(() => Promise.all(promises.map((p) => p()))).then(() => undefined);
529
536
  }
530
537
  const Onyx = {
531
538
  METHOD: OnyxUtils_1.default.METHOD,
@@ -1,56 +1,30 @@
1
- import {Component} from 'react';
2
- import * as Logger from './Logger';
3
- import {CollectionKey, CollectionKeyBase, DeepRecord, KeyValueMapping, NullishDeep, OnyxCollection, OnyxEntry, OnyxKey, Selector} from './types';
4
-
1
+ import type { ValueOf } from 'type-fest';
2
+ import type { DeepRecord, Mapping, CollectionKey, CollectionKeyBase, NullableKeyValueMapping, OnyxKey, OnyxValue, OnyxCollection, WithOnyxConnectOptions, OnyxEntry, KeyValueMapping } from './types';
3
+ import type Onyx from './Onyx';
5
4
  declare const METHOD: {
6
- readonly SET: 'set';
7
- readonly MERGE: 'merge';
8
- readonly MERGE_COLLECTION: 'mergecollection';
9
- readonly MULTI_SET: 'multiset';
10
- readonly CLEAR: 'clear';
5
+ readonly SET: "set";
6
+ readonly MERGE: "merge";
7
+ readonly MERGE_COLLECTION: "mergecollection";
8
+ readonly MULTI_SET: "multiset";
9
+ readonly CLEAR: "clear";
11
10
  };
12
-
13
11
  type OnyxMethod = ValueOf<typeof METHOD>;
14
-
15
- // Key/value store of Onyx key and arrays of values to merge
16
- declare const mergeQueue: Record<OnyxKey, OnyxValue<OnyxKey>[]>;
17
- declare const mergeQueuePromise: Record<OnyxKey, Promise<void | void[]>>;
18
-
19
- // Holds a mapping of all the react components that want their state subscribed to a store key
20
- declare const callbackToStateMapping: Record<string, Mapping<OnyxKey>>;
21
-
22
- // Keeps a copy of the values of the onyx collection keys as a map for faster lookups
23
- declare let onyxCollectionKeyMap: Map<OnyxKey, OnyxValue<OnyxKey>>;
24
-
25
- // Holds a list of keys that have been directly subscribed to or recently modified from least to most recent
26
- declare let recentlyAccessedKeys: OnyxKey[];
27
-
28
- // Holds a list of keys that are safe to remove when we reach max storage. If a key does not match with
29
- // whatever appears in this list it will NEVER be a candidate for eviction.
30
- declare let evictionAllowList: OnyxKey[];
31
-
32
- // Holds a map of keys and connectionID arrays whose keys will never be automatically evicted as
33
- // long as we have at least one subscriber that returns false for the canEvict property.
34
- declare const evictionBlocklist: Record<OnyxKey, number[]>;
35
-
36
- // Optional user-provided key value states set when Onyx initializes or clears
37
- declare let defaultKeyStates: Record<OnyxKey, OnyxValue<OnyxKey>>;
38
-
39
- declare let batchUpdatesPromise: Promise<void> | null;
40
- declare let batchUpdatesQueue: Array<() => void>;
41
-
42
- /** Getter - returns the merge queue. */
43
- declare function getMergeQueue(): Record<string, OnyxValue<string>[]>;
44
-
45
- /** Getter - returns the merge queue promise. */
46
- declare function getMergeQueuePromise(): Record<string, Promise<void | void[]>>;
47
-
48
- /** Getter - returns the callback to state mapping. */
49
- declare function getCallbackToStateMapping(): Record<string, Mapping<string>>;
50
-
51
- /** Getter - returns the default key states. */
52
- declare function getDefaultKeyStates(): Record<string, OnyxValue<string>>;
53
-
12
+ /**
13
+ * Getter - returns the merge queue.
14
+ */
15
+ declare function getMergeQueue(): Record<OnyxKey, Array<OnyxValue<OnyxKey>>>;
16
+ /**
17
+ * Getter - returns the merge queue promise.
18
+ */
19
+ declare function getMergeQueuePromise(): Record<OnyxKey, Promise<void>>;
20
+ /**
21
+ * Getter - returns the callback to state mapping.
22
+ */
23
+ declare function getCallbackToStateMapping(): Record<string, Mapping<OnyxKey>>;
24
+ /**
25
+ * Getter - returns the default key states.
26
+ */
27
+ declare function getDefaultKeyStates(): Record<OnyxKey, OnyxValue<OnyxKey>>;
54
28
  /**
55
29
  * Sets the initial values for the Onyx store
56
30
  *
@@ -59,7 +33,6 @@ declare function getDefaultKeyStates(): Record<string, OnyxValue<string>>;
59
33
  * @param safeEvictionKeys - This is an array of keys (individual or collection patterns) that when provided to Onyx are flagged as "safe" for removal.
60
34
  */
61
35
  declare function initStoreValues(keys: DeepRecord<string, OnyxKey>, initialKeyStates: Partial<NullableKeyValueMapping>, safeEvictionKeys: OnyxKey[]): void;
62
-
63
36
  /**
64
37
  * Sends an action to DevTools extension
65
38
  *
@@ -68,9 +41,8 @@ declare function initStoreValues(keys: DeepRecord<string, OnyxKey>, initialKeySt
68
41
  * @param value - contains the change that was made by the method
69
42
  * @param mergedValue - (optional) value that was written in the storage after a merge method was executed.
70
43
  */
71
- declare function sendActionToDevTools(method: OnyxMethod, key: undefined, value: Record<OnyxKey, OnyxValue<OnyxKey>>, mergedValue?: OnyxValue<OnyxKey>): void;
72
- declare function sendActionToDevTools(method: OnyxMethod, key: OnyxKey, value: OnyxValue<OnyxKey>, mergedValue?: OnyxValue<OnyxKey>): void;
73
-
44
+ declare function sendActionToDevTools(method: typeof METHOD.MERGE_COLLECTION | typeof METHOD.MULTI_SET, key: undefined, value: OnyxCollection<KeyValueMapping[OnyxKey]>, mergedValue?: undefined): void;
45
+ declare function sendActionToDevTools(method: Exclude<OnyxMethod, typeof METHOD.MERGE_COLLECTION | typeof METHOD.MULTI_SET>, key: OnyxKey, value: OnyxEntry<KeyValueMapping[OnyxKey]>, mergedValue?: OnyxEntry<KeyValueMapping[OnyxKey]>): void;
74
46
  /**
75
47
  * We are batching together onyx updates. This helps with use cases where we schedule onyx updates after each other.
76
48
  * This happens for example in the Onyx.update function, where we process API responses that might contain a lot of
@@ -78,190 +50,132 @@ declare function sendActionToDevTools(method: OnyxMethod, key: OnyxKey, value: O
78
50
  * cause react to schedule the updates at once instead of after each other. This is mainly a performance optimization.
79
51
  */
80
52
  declare function maybeFlushBatchUpdates(): Promise<void>;
81
-
82
53
  declare function batchUpdates(updates: () => void): Promise<void>;
83
-
84
54
  /** Get some data from the store */
85
55
  declare function get(key: OnyxKey): Promise<OnyxValue<OnyxKey>>;
86
-
87
- /**
88
- * Returns current key names stored in persisted storage
89
- */
90
- declare function getAllKeys(): Promise<Set<string>>;
91
-
56
+ /** Returns current key names stored in persisted storage */
57
+ declare function getAllKeys(): Promise<Set<OnyxKey>>;
92
58
  /**
93
59
  * Checks to see if the a subscriber's supplied key
94
60
  * is associated with a collection of keys.
95
61
  */
96
62
  declare function isCollectionKey(key: OnyxKey): key is CollectionKeyBase;
97
-
98
63
  declare function isCollectionMemberKey<TCollectionKey extends CollectionKeyBase>(collectionKey: TCollectionKey, key: string): key is `${TCollectionKey}${string}`;
99
-
100
64
  /**
101
65
  * Splits a collection member key into the collection key part and the ID part.
102
66
  * @param key - The collection member key to split.
103
67
  * @returns A tuple where the first element is the collection part and the second element is the ID part.
104
68
  */
105
69
  declare function splitCollectionMemberKey<TKey extends CollectionKey>(key: TKey): [TKey extends `${infer Prefix}_${string}` ? `${Prefix}_` : never, string];
106
-
107
70
  /**
108
71
  * Checks to see if a provided key is the exact configured key of our connected subscriber
109
72
  * or if the provided key is a collection member key (in case our configured key is a "collection key")
110
73
  */
111
74
  declare function isKeyMatch(configKey: OnyxKey, key: OnyxKey): boolean;
112
-
113
- /**
114
- * Checks to see if this key has been flagged as
115
- * safe for removal.
116
- */
75
+ /** Checks to see if this key has been flagged as safe for removal. */
117
76
  declare function isSafeEvictionKey(testKey: OnyxKey): boolean;
118
-
119
77
  /**
120
78
  * Tries to get a value from the cache. If the value is not present in cache it will return the default value or undefined.
121
79
  * If the requested key is a collection, it will return an object with all the collection members.
122
80
  */
123
- declare function tryGetCachedValue<TKey extends OnyxKey>(key: TKey, mapping: Mapping<TKey>): OnyxValue<OnyxKey>;
124
-
125
- /** Remove a key from the recently accessed key list. */
81
+ declare function tryGetCachedValue<TKey extends OnyxKey>(key: TKey, mapping?: Partial<WithOnyxConnectOptions<TKey>>): OnyxValue<OnyxKey>;
82
+ /**
83
+ * Remove a key from the recently accessed key list.
84
+ */
126
85
  declare function removeLastAccessedKey(key: OnyxKey): void;
127
-
128
86
  /**
129
- * Add a key to the list of recently accessed keys.
130
- * The least recently accessed key should be at the head and the most recently accessed key at the tail.
87
+ * Add a key to the list of recently accessed keys. The least
88
+ * recently accessed key should be at the head and the most
89
+ * recently accessed key at the tail.
131
90
  */
132
91
  declare function addLastAccessedKey(key: OnyxKey): void;
133
-
134
92
  /**
135
93
  * Removes a key previously added to this list
136
94
  * which will enable it to be deleted again.
137
95
  */
138
96
  declare function removeFromEvictionBlockList(key: OnyxKey, connectionID: number): void;
139
-
140
- /**
141
- * Keys added to this list can never be deleted.
142
- */
97
+ /** Keys added to this list can never be deleted. */
143
98
  declare function addToEvictionBlockList(key: OnyxKey, connectionID: number): void;
144
-
145
99
  /**
146
100
  * Take all the keys that are safe to evict and add them to
147
101
  * the recently accessed list when initializing the app. This
148
- * enables keys that have not recently been accessed to be removed.
102
+ * enables keys that have not recently been accessed to be
103
+ * removed.
149
104
  */
150
105
  declare function addAllSafeEvictionKeysToRecentlyAccessedList(): Promise<void>;
151
-
152
- declare function getCachedCollection<TKey extends CollectionKeyBase>(collectionKey: TKey): Record<OnyxKey, OnyxValue<OnyxKey>>;
153
-
154
- /** When a collection of keys change, search for any callbacks matching the collection key and trigger those callbacks */
155
- declare function keysChanged<TKey extends CollectionKeyBase>(
156
- collectionKey: TKey,
157
- partialCollection: OnyxCollection<OnyxValue<OnyxKey>>,
158
- notifyRegularSubscibers?: boolean,
159
- notifyWithOnyxSubscibers?: boolean,
160
- ): void;
106
+ declare function getCachedCollection<TKey extends CollectionKeyBase>(collectionKey: TKey): NonNullable<OnyxCollection<KeyValueMapping[TKey]>>;
107
+ /**
108
+ * When a collection of keys change, search for any callbacks matching the collection key and trigger those callbacks
109
+ */
110
+ declare function keysChanged<TKey extends CollectionKeyBase>(collectionKey: TKey, partialCollection: OnyxCollection<KeyValueMapping[TKey]>, notifyRegularSubscibers?: boolean, notifyWithOnyxSubscibers?: boolean): void;
161
111
  /**
162
112
  * When a key change happens, search for any callbacks matching the key or collection key and trigger those callbacks
163
113
  *
164
114
  * @example
165
115
  * keyChanged(key, value, subscriber => subscriber.initWithStoredValues === false)
166
- *
167
- * @param [canUpdateSubscriber] only subscribers that pass this truth test will be updated
168
116
  */
169
- declare function keyChanged(
170
- key: OnyxKey,
171
- data: OnyxValue<OnyxKey>,
172
- prevData: OnyxValue<OnyxKey>,
173
- canUpdateSubscriber?: (_subscriber: Mapping<OnyxKey>) => boolean,
174
- notifyRegularSubscibers?: boolean,
175
- notifyWithOnyxSubscibers?: boolean,
176
- ): void;
177
-
117
+ declare function keyChanged<TKey extends OnyxKey>(key: TKey, data: OnyxValue<TKey>, prevData: OnyxValue<TKey>, canUpdateSubscriber?: (subscriber?: Mapping<OnyxKey>) => boolean, notifyRegularSubscibers?: boolean, notifyWithOnyxSubscibers?: boolean): void;
178
118
  /**
179
119
  * Sends the data obtained from the keys to the connection. It either:
180
120
  * - sets state on the withOnyxInstances
181
121
  * - triggers the callback function
182
122
  */
183
- declare function sendDataToConnection<TKey extends OnyxKey>(
184
- mapping: Mapping<TKey>,
185
- val: OnyxValue<OnyxKey> | Record<OnyxKey, OnyxValue<OnyxKey>>,
186
- matchedKey: TKey | undefined,
187
- isBatched: boolean,
188
- ): void;
189
-
123
+ declare function sendDataToConnection<TKey extends OnyxKey>(mapping: Mapping<TKey>, val: OnyxValue<TKey>, matchedKey: TKey | undefined, isBatched: boolean): void;
190
124
  /**
191
125
  * We check to see if this key is flagged as safe for eviction and add it to the recentlyAccessedKeys list so that when we
192
126
  * run out of storage the least recently accessed key can be removed.
193
127
  */
194
128
  declare function addKeyToRecentlyAccessedIfNeeded<TKey extends OnyxKey>(mapping: Mapping<TKey>): void;
195
-
196
129
  /**
197
130
  * Gets the data for a given an array of matching keys, combines them into an object, and sends the result back to the subscriber.
198
131
  */
199
132
  declare function getCollectionDataAndSendAsObject<TKey extends OnyxKey>(matchingKeys: CollectionKeyBase[], mapping: Mapping<TKey>): void;
200
-
201
133
  /**
202
134
  * Schedules an update that will be appended to the macro task queue (so it doesn't update the subscribers immediately).
203
135
  *
204
136
  * @example
205
137
  * scheduleSubscriberUpdate(key, value, subscriber => subscriber.initWithStoredValues === false)
206
138
  */
207
- declare function scheduleSubscriberUpdate<TKey extends OnyxKey>(
208
- key: TKey,
209
- value: KeyValueMapping[TKey],
210
- prevValue: KeyValueMapping[TKey],
211
- canUpdateSubscriber?: (_subscriber: Mapping<OnyxKey>) => boolean,
212
- ): Promise<void>;
213
-
139
+ declare function scheduleSubscriberUpdate<TKey extends OnyxKey>(key: TKey, value: OnyxValue<TKey>, prevValue: OnyxValue<TKey>, canUpdateSubscriber?: (subscriber?: Mapping<OnyxKey>) => boolean): Promise<void>;
214
140
  /**
215
141
  * This method is similar to notifySubscribersOnNextTick but it is built for working specifically with collections
216
142
  * so that keysChanged() is triggered for the collection and not keyChanged(). If this was not done, then the
217
143
  * subscriber callbacks receive the data in a different format than they normally expect and it breaks code.
218
144
  */
219
- declare function scheduleNotifyCollectionSubscribers(key: OnyxKey, value: OnyxCollection<OnyxValue<OnyxKey>>): Promise<void>;
220
-
145
+ declare function scheduleNotifyCollectionSubscribers<TKey extends OnyxKey>(key: TKey, value: OnyxCollection<KeyValueMapping[TKey]>): Promise<void>;
221
146
  /**
222
147
  * Remove a key from Onyx and update the subscribers
223
148
  */
224
149
  declare function remove<TKey extends OnyxKey>(key: TKey): Promise<void>;
225
-
226
150
  declare function reportStorageQuota(): Promise<void>;
227
-
228
151
  /**
229
152
  * If we fail to set or merge we must handle this by
230
153
  * evicting some data from Onyx and then retrying to do
231
154
  * whatever it is we attempted to do.
232
155
  */
233
- declare function evictStorageAndRetry<TMethod extends typeof Onyx.set | typeof Onyx.multiSet | typeof Onyx.mergeCollection>(
234
- error: Error,
235
- onyxMethod: TMethod,
236
- ...args: Parameters<TMethod>
237
- ): Promise<void>;
238
-
239
- /** Notifies subscribers and writes current value to cache */
240
- declare function broadcastUpdate<TKey extends OnyxKey>(key: TKey, value: KeyValueMapping[TKey], hasChanged: boolean, wasRemoved?: boolean): Promise<void[]>;
241
-
156
+ declare function evictStorageAndRetry<TMethod extends typeof Onyx.set | typeof Onyx.multiSet | typeof Onyx.mergeCollection>(error: Error, onyxMethod: TMethod, ...args: Parameters<TMethod>): Promise<void>;
242
157
  /**
243
- * @private
158
+ * Notifies subscribers and writes current value to cache
244
159
  */
160
+ declare function broadcastUpdate<TKey extends OnyxKey>(key: TKey, value: OnyxValue<TKey>, hasChanged?: boolean, wasRemoved?: boolean): Promise<void>;
245
161
  declare function hasPendingMergeForKey(key: OnyxKey): boolean;
246
-
162
+ type RemoveNullValuesOutput = {
163
+ value: Record<string, unknown> | unknown[] | null;
164
+ wasRemoved: boolean;
165
+ };
247
166
  /**
248
167
  * Removes a key from storage if the value is null.
249
168
  * Otherwise removes all nested null values in objects and returns the object
169
+ *
250
170
  * @returns The value without null values and a boolean "wasRemoved", which indicates if the key got removed completely
251
171
  */
252
- declare function removeNullValues<TKey extends OnyxKey>(
253
- key: TKey,
254
- value: OnyxValue<TKey>,
255
- ): {
256
- value: OnyxValue<TKey>;
257
- wasRemoved: boolean;
258
- };
172
+ declare function removeNullValues(key: OnyxKey, value: OnyxValue<OnyxKey>): RemoveNullValuesOutput;
259
173
  /**
260
174
  * Storage expects array like: [["@MyApp_user", value_1], ["@MyApp_key", value_2]]
261
175
  * This method transforms an object like {'@MyApp_user': myUserValue, '@MyApp_key': myKeyValue}
262
176
  * to an array of key-value pairs in the above format and removes key-value pairs that are being set to null
263
- *
264
- * @return an array of key - value pairs <[key, value]>
177
+
178
+ * @return an array of key - value pairs <[key, value]>
265
179
  */
266
180
  declare function prepareKeyValuePairsForStorage(data: Record<OnyxKey, OnyxValue<OnyxKey>>): Array<[OnyxKey, OnyxValue<OnyxKey>]>;
267
181
  /**
@@ -269,52 +183,56 @@ declare function prepareKeyValuePairsForStorage(data: Record<OnyxKey, OnyxValue<
269
183
  *
270
184
  * @param changes Array of changes that should be applied to the existing value
271
185
  */
272
- declare function applyMerge(existingValue: OnyxValue<OnyxKey>, changes: Array<OnyxValue<OnyxKey>>, shouldRemoveNullObjectValues: boolean): any;
186
+ declare function applyMerge(existingValue: OnyxValue<OnyxKey>, changes: Array<OnyxValue<OnyxKey>>, shouldRemoveNullObjectValues: boolean): OnyxValue<OnyxKey>;
273
187
  /**
274
188
  * Merge user provided default key value pairs.
275
189
  */
276
190
  declare function initializeWithDefaultKeyStates(): Promise<void>;
277
-
278
- const OnyxUtils = {
279
- METHOD,
280
- getMergeQueue,
281
- getMergeQueuePromise,
282
- getCallbackToStateMapping,
283
- getDefaultKeyStates,
284
- initStoreValues,
285
- sendActionToDevTools,
286
- maybeFlushBatchUpdates,
287
- batchUpdates,
288
- get,
289
- getAllKeys,
290
- isCollectionKey,
291
- isCollectionMemberKey,
292
- splitCollectionMemberKey,
293
- isKeyMatch,
294
- isSafeEvictionKey,
295
- tryGetCachedValue,
296
- removeLastAccessedKey,
297
- addLastAccessedKey,
298
- removeFromEvictionBlockList,
299
- addToEvictionBlockList,
300
- addAllSafeEvictionKeysToRecentlyAccessedList,
301
- getCachedCollection,
302
- keysChanged,
303
- keyChanged,
304
- sendDataToConnection,
305
- addKeyToRecentlyAccessedIfNeeded,
306
- getCollectionDataAndSendAsObject,
307
- scheduleSubscriberUpdate,
308
- scheduleNotifyCollectionSubscribers,
309
- remove,
310
- reportStorageQuota,
311
- evictStorageAndRetry,
312
- broadcastUpdate,
313
- hasPendingMergeForKey,
314
- removeNullValues,
315
- prepareKeyValuePairsForStorage,
316
- applyMerge,
317
- initializeWithDefaultKeyStates,
318
- } as const;
319
-
191
+ declare const OnyxUtils: {
192
+ METHOD: {
193
+ readonly SET: "set";
194
+ readonly MERGE: "merge";
195
+ readonly MERGE_COLLECTION: "mergecollection";
196
+ readonly MULTI_SET: "multiset";
197
+ readonly CLEAR: "clear";
198
+ };
199
+ getMergeQueue: typeof getMergeQueue;
200
+ getMergeQueuePromise: typeof getMergeQueuePromise;
201
+ getCallbackToStateMapping: typeof getCallbackToStateMapping;
202
+ getDefaultKeyStates: typeof getDefaultKeyStates;
203
+ initStoreValues: typeof initStoreValues;
204
+ sendActionToDevTools: typeof sendActionToDevTools;
205
+ maybeFlushBatchUpdates: typeof maybeFlushBatchUpdates;
206
+ batchUpdates: typeof batchUpdates;
207
+ get: typeof get;
208
+ getAllKeys: typeof getAllKeys;
209
+ isCollectionKey: typeof isCollectionKey;
210
+ isCollectionMemberKey: typeof isCollectionMemberKey;
211
+ splitCollectionMemberKey: typeof splitCollectionMemberKey;
212
+ isKeyMatch: typeof isKeyMatch;
213
+ isSafeEvictionKey: typeof isSafeEvictionKey;
214
+ tryGetCachedValue: typeof tryGetCachedValue;
215
+ removeLastAccessedKey: typeof removeLastAccessedKey;
216
+ addLastAccessedKey: typeof addLastAccessedKey;
217
+ removeFromEvictionBlockList: typeof removeFromEvictionBlockList;
218
+ addToEvictionBlockList: typeof addToEvictionBlockList;
219
+ addAllSafeEvictionKeysToRecentlyAccessedList: typeof addAllSafeEvictionKeysToRecentlyAccessedList;
220
+ getCachedCollection: typeof getCachedCollection;
221
+ keysChanged: typeof keysChanged;
222
+ keyChanged: typeof keyChanged;
223
+ sendDataToConnection: typeof sendDataToConnection;
224
+ addKeyToRecentlyAccessedIfNeeded: typeof addKeyToRecentlyAccessedIfNeeded;
225
+ getCollectionDataAndSendAsObject: typeof getCollectionDataAndSendAsObject;
226
+ scheduleSubscriberUpdate: typeof scheduleSubscriberUpdate;
227
+ scheduleNotifyCollectionSubscribers: typeof scheduleNotifyCollectionSubscribers;
228
+ remove: typeof remove;
229
+ reportStorageQuota: typeof reportStorageQuota;
230
+ evictStorageAndRetry: typeof evictStorageAndRetry;
231
+ broadcastUpdate: typeof broadcastUpdate;
232
+ hasPendingMergeForKey: typeof hasPendingMergeForKey;
233
+ removeNullValues: typeof removeNullValues;
234
+ prepareKeyValuePairsForStorage: typeof prepareKeyValuePairsForStorage;
235
+ applyMerge: typeof applyMerge;
236
+ initializeWithDefaultKeyStates: typeof initializeWithDefaultKeyStates;
237
+ };
320
238
  export default OnyxUtils;