react-native-onyx 2.0.43 → 2.0.44
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.d.ts +5 -5
- package/dist/OnyxUtils.d.ts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/types.d.ts +31 -9
- package/dist/withOnyx/types.d.ts +2 -2
- package/package.json +1 -1
package/dist/Onyx.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as Logger from './Logger';
|
|
2
|
-
import type {
|
|
2
|
+
import type { CollectionKeyBase, ConnectOptions, InitOptions, Mapping, OnyxKey, OnyxMergeCollectionInput, OnyxMergeInput, OnyxMultiSetInput, OnyxSetInput, OnyxUpdate } from './types';
|
|
3
3
|
/** Initialize the store with actions and listening for storage events */
|
|
4
4
|
declare function init({ keys, initialKeyStates, safeEvictionKeys, maxCachedKeysCount, shouldSyncMultipleInstances, debugSetState, }: InitOptions): void;
|
|
5
5
|
/**
|
|
@@ -45,7 +45,7 @@ declare function disconnect(connectionID: number, keyToRemoveFromEvictionBlockli
|
|
|
45
45
|
* @param key ONYXKEY to set
|
|
46
46
|
* @param value value to store
|
|
47
47
|
*/
|
|
48
|
-
declare function set<TKey extends OnyxKey>(key: TKey, value:
|
|
48
|
+
declare function set<TKey extends OnyxKey>(key: TKey, value: OnyxSetInput<TKey>): Promise<void>;
|
|
49
49
|
/**
|
|
50
50
|
* Sets multiple keys and values
|
|
51
51
|
*
|
|
@@ -53,7 +53,7 @@ declare function set<TKey extends OnyxKey>(key: TKey, value: NonUndefined<OnyxEn
|
|
|
53
53
|
*
|
|
54
54
|
* @param data object keyed by ONYXKEYS and the values to set
|
|
55
55
|
*/
|
|
56
|
-
declare function multiSet(data:
|
|
56
|
+
declare function multiSet(data: OnyxMultiSetInput): Promise<void>;
|
|
57
57
|
/**
|
|
58
58
|
* Merge a new value into an existing value at a key.
|
|
59
59
|
*
|
|
@@ -70,7 +70,7 @@ declare function multiSet(data: Partial<NullableKeyValueMapping>): Promise<void>
|
|
|
70
70
|
* Onyx.merge(ONYXKEYS.POLICY, {id: 1}); // -> {id: 1}
|
|
71
71
|
* Onyx.merge(ONYXKEYS.POLICY, {name: 'My Workspace'}); // -> {id: 1, name: 'My Workspace'}
|
|
72
72
|
*/
|
|
73
|
-
declare function merge<TKey extends OnyxKey>(key: TKey, changes:
|
|
73
|
+
declare function merge<TKey extends OnyxKey>(key: TKey, changes: OnyxMergeInput<TKey>): Promise<void>;
|
|
74
74
|
/**
|
|
75
75
|
* Merges a collection based on their keys
|
|
76
76
|
*
|
|
@@ -84,7 +84,7 @@ declare function merge<TKey extends OnyxKey>(key: TKey, changes: NonUndefined<On
|
|
|
84
84
|
* @param collectionKey e.g. `ONYXKEYS.COLLECTION.REPORT`
|
|
85
85
|
* @param collection Object collection keyed by individual collection member keys and values
|
|
86
86
|
*/
|
|
87
|
-
declare function mergeCollection<TKey extends CollectionKeyBase, TMap>(collectionKey: TKey, collection:
|
|
87
|
+
declare function mergeCollection<TKey extends CollectionKeyBase, TMap>(collectionKey: TKey, collection: OnyxMergeCollectionInput<TKey, TMap>): Promise<void>;
|
|
88
88
|
/**
|
|
89
89
|
* Clear out all the data in the store
|
|
90
90
|
*
|
package/dist/OnyxUtils.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ValueOf } from 'type-fest';
|
|
2
2
|
import type Onyx from './Onyx';
|
|
3
|
-
import type { CollectionKey, CollectionKeyBase, DeepRecord, KeyValueMapping, Mapping,
|
|
3
|
+
import type { CollectionKey, CollectionKeyBase, DeepRecord, KeyValueMapping, Mapping, OnyxCollection, OnyxEntry, OnyxKey, OnyxValue, WithOnyxConnectOptions } from './types';
|
|
4
4
|
declare const METHOD: {
|
|
5
5
|
readonly SET: "set";
|
|
6
6
|
readonly MERGE: "merge";
|
|
@@ -32,7 +32,7 @@ declare function getDefaultKeyStates(): Record<OnyxKey, OnyxValue<OnyxKey>>;
|
|
|
32
32
|
* @param initialKeyStates - initial data to set when `init()` and `clear()` are called
|
|
33
33
|
* @param safeEvictionKeys - This is an array of keys (individual or collection patterns) that when provided to Onyx are flagged as "safe" for removal.
|
|
34
34
|
*/
|
|
35
|
-
declare function initStoreValues(keys: DeepRecord<string, OnyxKey>, initialKeyStates: Partial<
|
|
35
|
+
declare function initStoreValues(keys: DeepRecord<string, OnyxKey>, initialKeyStates: Partial<KeyValueMapping>, safeEvictionKeys: OnyxKey[]): void;
|
|
36
36
|
/**
|
|
37
37
|
* Sends an action to DevTools extension
|
|
38
38
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { ConnectOptions, OnyxUpdate } from './Onyx';
|
|
2
2
|
import Onyx from './Onyx';
|
|
3
|
-
import type { CustomTypeOptions, KeyValueMapping, NullishDeep, OnyxCollection, OnyxEntry, OnyxKey, OnyxValue, Selector } from './types';
|
|
3
|
+
import type { CustomTypeOptions, KeyValueMapping, NullishDeep, OnyxCollection, OnyxEntry, OnyxInput, OnyxKey, OnyxValue, Selector, OnyxSetInput, OnyxMultiSetInput, OnyxMergeInput, OnyxMergeCollectionInput } from './types';
|
|
4
4
|
import type { FetchStatus, ResultMetadata, UseOnyxResult } from './useOnyx';
|
|
5
5
|
import useOnyx from './useOnyx';
|
|
6
6
|
import withOnyx from './withOnyx';
|
|
7
7
|
import type { WithOnyxState } from './withOnyx/types';
|
|
8
8
|
export default Onyx;
|
|
9
9
|
export { useOnyx, withOnyx };
|
|
10
|
-
export type { ConnectOptions, CustomTypeOptions, FetchStatus, KeyValueMapping, NullishDeep, OnyxCollection, OnyxEntry, OnyxKey, OnyxUpdate, OnyxValue, ResultMetadata, Selector, UseOnyxResult, WithOnyxState, };
|
|
10
|
+
export type { ConnectOptions, CustomTypeOptions, FetchStatus, KeyValueMapping, NullishDeep, OnyxCollection, OnyxEntry, OnyxInput, OnyxKey, OnyxSetInput, OnyxMultiSetInput, OnyxMergeInput, OnyxMergeCollectionInput, OnyxUpdate, OnyxValue, ResultMetadata, Selector, UseOnyxResult, WithOnyxState, };
|
package/dist/types.d.ts
CHANGED
|
@@ -121,7 +121,7 @@ type KeyValueMapping = {
|
|
|
121
121
|
* It's very similar to `KeyValueMapping` but this type accepts using `null` as well.
|
|
122
122
|
*/
|
|
123
123
|
type NullableKeyValueMapping = {
|
|
124
|
-
[TKey in OnyxKey]: OnyxValue<TKey
|
|
124
|
+
[TKey in OnyxKey]: NonUndefined<OnyxValue<TKey>> | null;
|
|
125
125
|
};
|
|
126
126
|
/**
|
|
127
127
|
* Represents a selector function type which operates based on the provided `TKey` and `ReturnType`.
|
|
@@ -162,6 +162,12 @@ type Selector<TKey extends OnyxKey, TOnyxProps, TReturnType> = (value: OnyxEntry
|
|
|
162
162
|
* ```
|
|
163
163
|
*/
|
|
164
164
|
type OnyxEntry<TOnyxValue> = TOnyxValue | undefined;
|
|
165
|
+
/**
|
|
166
|
+
* Represents an input value that can be passed to Onyx methods, that can be either `TOnyxValue` or `null`.
|
|
167
|
+
* Setting a key to `null` will remove the key from the store.
|
|
168
|
+
* `undefined` is not allowed for setting values, because it will have no effect on the data.
|
|
169
|
+
*/
|
|
170
|
+
type OnyxInput<TOnyxValue> = TOnyxValue | null;
|
|
165
171
|
/**
|
|
166
172
|
* Represents an Onyx collection of entries, that can be either a record of `TOnyxValue`s or `null` / `undefined` if it is empty or doesn't exist.
|
|
167
173
|
*
|
|
@@ -229,7 +235,7 @@ type NullishObjectDeep<ObjectType extends object> = {
|
|
|
229
235
|
* Also, the `TMap` type is inferred automatically in `mergeCollection()` method and represents
|
|
230
236
|
* the object of collection keys/values specified in the second parameter of the method.
|
|
231
237
|
*/
|
|
232
|
-
type Collection<TKey extends CollectionKeyBase,
|
|
238
|
+
type Collection<TKey extends CollectionKeyBase, TValue, TMap = never> = {
|
|
233
239
|
[MapK in keyof TMap]: MapK extends `${TKey}${string}` ? MapK extends `${TKey}` ? never : TValue : never;
|
|
234
240
|
};
|
|
235
241
|
/** Represents the base options used in `Onyx.connect()` method. */
|
|
@@ -276,6 +282,22 @@ type ConnectOptions<TKey extends OnyxKey> = (CollectionConnectOptions<TKey> | De
|
|
|
276
282
|
type Mapping<TKey extends OnyxKey> = ConnectOptions<TKey> & {
|
|
277
283
|
connectionID: number;
|
|
278
284
|
};
|
|
285
|
+
/**
|
|
286
|
+
* This represents the value that can be passed to `Onyx.set` and to `Onyx.update` with the method "SET"
|
|
287
|
+
*/
|
|
288
|
+
type OnyxSetInput<TKey extends OnyxKey> = OnyxInput<KeyValueMapping[TKey]>;
|
|
289
|
+
/**
|
|
290
|
+
* This represents the value that can be passed to `Onyx.multiSet` and to `Onyx.update` with the method "MULTI_SET"
|
|
291
|
+
*/
|
|
292
|
+
type OnyxMultiSetInput = Partial<NullableKeyValueMapping>;
|
|
293
|
+
/**
|
|
294
|
+
* This represents the value that can be passed to `Onyx.merge` and to `Onyx.update` with the method "MERGE"
|
|
295
|
+
*/
|
|
296
|
+
type OnyxMergeInput<TKey extends OnyxKey> = OnyxInput<NullishDeep<KeyValueMapping[TKey]>>;
|
|
297
|
+
/**
|
|
298
|
+
* This represents the value that can be passed to `Onyx.merge` and to `Onyx.update` with the method "MERGE"
|
|
299
|
+
*/
|
|
300
|
+
type OnyxMergeCollectionInput<TKey extends OnyxKey, TMap = object> = Collection<TKey, NullishDeep<KeyValueMapping[TKey]>, TMap>;
|
|
279
301
|
/**
|
|
280
302
|
* Represents different kinds of updates that can be passed to `Onyx.update()` method. It is a discriminated union of
|
|
281
303
|
* different update methods (`SET`, `MERGE`, `MERGE_COLLECTION`), each with their own key and value structure.
|
|
@@ -284,15 +306,15 @@ type OnyxUpdate = {
|
|
|
284
306
|
[TKey in OnyxKey]: {
|
|
285
307
|
onyxMethod: typeof OnyxUtils.METHOD.SET;
|
|
286
308
|
key: TKey;
|
|
287
|
-
value:
|
|
309
|
+
value: OnyxSetInput<TKey>;
|
|
288
310
|
} | {
|
|
289
|
-
onyxMethod: typeof OnyxUtils.METHOD.
|
|
311
|
+
onyxMethod: typeof OnyxUtils.METHOD.MULTI_SET;
|
|
290
312
|
key: TKey;
|
|
291
|
-
value:
|
|
313
|
+
value: OnyxMultiSetInput;
|
|
292
314
|
} | {
|
|
293
|
-
onyxMethod: typeof OnyxUtils.METHOD.
|
|
315
|
+
onyxMethod: typeof OnyxUtils.METHOD.MERGE;
|
|
294
316
|
key: TKey;
|
|
295
|
-
value:
|
|
317
|
+
value: OnyxMergeInput<TKey>;
|
|
296
318
|
} | {
|
|
297
319
|
onyxMethod: typeof OnyxUtils.METHOD.CLEAR;
|
|
298
320
|
key: TKey;
|
|
@@ -302,7 +324,7 @@ type OnyxUpdate = {
|
|
|
302
324
|
[TKey in CollectionKeyBase]: {
|
|
303
325
|
onyxMethod: typeof OnyxUtils.METHOD.MERGE_COLLECTION;
|
|
304
326
|
key: TKey;
|
|
305
|
-
value:
|
|
327
|
+
value: OnyxMergeCollectionInput<TKey>;
|
|
306
328
|
};
|
|
307
329
|
}[CollectionKeyBase];
|
|
308
330
|
/**
|
|
@@ -333,4 +355,4 @@ type InitOptions = {
|
|
|
333
355
|
debugSetState?: boolean;
|
|
334
356
|
};
|
|
335
357
|
type GenericFunction = (...args: any[]) => any;
|
|
336
|
-
export type { BaseConnectOptions, Collection, CollectionConnectCallback, CollectionConnectOptions, CollectionKey, CollectionKeyBase, ConnectOptions, CustomTypeOptions, DeepRecord, DefaultConnectCallback, DefaultConnectOptions, ExtractOnyxCollectionValue, GenericFunction, InitOptions, Key, KeyValueMapping, Mapping, NonNull, NonUndefined, NullableKeyValueMapping, NullishDeep, OnyxCollection, OnyxEntry, OnyxKey, OnyxUpdate, OnyxValue, Selector, WithOnyxConnectOptions, };
|
|
358
|
+
export type { BaseConnectOptions, Collection, CollectionConnectCallback, CollectionConnectOptions, CollectionKey, CollectionKeyBase, ConnectOptions, CustomTypeOptions, DeepRecord, DefaultConnectCallback, DefaultConnectOptions, ExtractOnyxCollectionValue, GenericFunction, InitOptions, Key, KeyValueMapping, Mapping, NonNull, NonUndefined, NullableKeyValueMapping, NullishDeep, OnyxCollection, OnyxEntry, OnyxInput, OnyxKey, OnyxSetInput, OnyxMultiSetInput, OnyxMergeInput, OnyxMergeCollectionInput, OnyxUpdate, OnyxValue, Selector, WithOnyxConnectOptions, };
|
package/dist/withOnyx/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ForwardedRef } from 'react';
|
|
2
2
|
import type { IsEqual } from 'type-fest';
|
|
3
|
-
import type { CollectionKeyBase, ExtractOnyxCollectionValue, KeyValueMapping,
|
|
3
|
+
import type { CollectionKeyBase, ExtractOnyxCollectionValue, KeyValueMapping, OnyxCollection, OnyxEntry, OnyxKey, OnyxValue, Selector } from '../types';
|
|
4
4
|
/**
|
|
5
5
|
* Represents the base mapping options between an Onyx key and the component's prop.
|
|
6
6
|
*/
|
|
@@ -134,7 +134,7 @@ type WithOnyxState<TOnyxProps> = TOnyxProps & {
|
|
|
134
134
|
/**
|
|
135
135
|
* Represents the `withOnyx` internal component instance.
|
|
136
136
|
*/
|
|
137
|
-
type WithOnyxInstance = React.Component<unknown, WithOnyxState<
|
|
137
|
+
type WithOnyxInstance = React.Component<unknown, WithOnyxState<KeyValueMapping>> & {
|
|
138
138
|
setStateProxy: (modifier: Record<string, OnyxCollection<KeyValueMapping[OnyxKey]>> | ((state: Record<string, OnyxCollection<KeyValueMapping[OnyxKey]>>) => OnyxValue<OnyxKey>)) => void;
|
|
139
139
|
setWithOnyxState: (statePropertyName: OnyxKey, value: OnyxValue<OnyxKey>) => void;
|
|
140
140
|
};
|