From a38e1028a788ecf2b6419983c46657dc19c916ff Mon Sep 17 00:00:00 2001 From: Blazej Kustra Date: Fri, 12 Apr 2024 12:09:53 +0200 Subject: [PATCH] Fix build:docs script --- API-INTERNAL.md | 399 ++++++++++++++++++++++++++++++++++++++++++++ API.md | 412 ++++++++++------------------------------------ buildDocs.js | 8 - buildDocs.ts | 14 ++ lib/Onyx.ts | 2 +- package-lock.json | 264 +++++++++++++++++++++++++++++ package.json | 5 +- 7 files changed, 767 insertions(+), 337 deletions(-) create mode 100644 API-INTERNAL.md delete mode 100644 buildDocs.js create mode 100644 buildDocs.ts diff --git a/API-INTERNAL.md b/API-INTERNAL.md new file mode 100644 index 00000000..aae82ccc --- /dev/null +++ b/API-INTERNAL.md @@ -0,0 +1,399 @@ + + +# Internal API Reference + +## Functions + +
+
getMergeQueue()
+

Getter - returns the merge queue.

+
+
getMergeQueuePromise()
+

Getter - returns the merge queue promise.

+
+
getCallbackToStateMapping()
+

Getter - returns the callback to state mapping.

+
+
getDefaultKeyStates()
+

Getter - returns the default key states.

+
+
initStoreValues(keys, initialKeyStates, safeEvictionKeys)
+

Sets the initial values for the Onyx store

+
+
maybeFlushBatchUpdates()
+

We are batching together onyx updates. This helps with use cases where we schedule onyx updates after each other. +This happens for example in the Onyx.update function, where we process API responses that might contain a lot of +update operations. Instead of calling the subscribers for each update operation, we batch them together which will +cause react to schedule the updates at once instead of after each other. This is mainly a performance optimization.

+
+
reduceCollectionWithSelector()
+

Takes a collection of items (eg. {testKey_1:{a:'a'}, testKey_2:{b:'b'}}) +and runs it through a reducer function to return a subset of the data according to a selector. +The resulting collection will only contain items that are returned by the selector.

+
+
get()
+

Get some data from the store

+
+
getAllKeys()
+

Returns current key names stored in persisted storage

+
+
isCollectionKey()
+

Checks to see if the a subscriber's supplied key +is associated with a collection of keys.

+
+
splitCollectionMemberKey(key)
+

Splits a collection member key into the collection key part and the ID part.

+
+
isKeyMatch()
+

Checks to see if a provided key is the exact configured key of our connected subscriber +or if the provided key is a collection member key (in case our configured key is a "collection key")

+
+
isSafeEvictionKey()
+

Checks to see if this key has been flagged as safe for removal.

+
+
tryGetCachedValue()
+

Tries to get a value from the cache. If the value is not present in cache it will return the default value or undefined. +If the requested key is a collection, it will return an object with all the collection members.

+
+
removeLastAccessedKey()
+

Remove a key from the recently accessed key list.

+
+
addLastAccessedKey()
+

Add a key to the list of recently accessed keys. The least +recently accessed key should be at the head and the most +recently accessed key at the tail.

+
+
removeFromEvictionBlockList()
+

Removes a key previously added to this list +which will enable it to be deleted again.

+
+
addToEvictionBlockList()
+

Keys added to this list can never be deleted.

+
+
addAllSafeEvictionKeysToRecentlyAccessedList()
+

Take all the keys that are safe to evict and add them to +the recently accessed list when initializing the app. This +enables keys that have not recently been accessed to be +removed.

+
+
keysChanged()
+

When a collection of keys change, search for any callbacks matching the collection key and trigger those callbacks

+
+
keyChanged()
+

When a key change happens, search for any callbacks matching the key or collection key and trigger those callbacks

+
+
sendDataToConnection()
+

Sends the data obtained from the keys to the connection. It either: + - sets state on the withOnyxInstances + - triggers the callback function

+
+
addKeyToRecentlyAccessedIfNeeded()
+

We check to see if this key is flagged as safe for eviction and add it to the recentlyAccessedKeys list so that when we +run out of storage the least recently accessed key can be removed.

+
+
getCollectionDataAndSendAsObject()
+

Gets the data for a given an array of matching keys, combines them into an object, and sends the result back to the subscriber.

+
+
scheduleSubscriberUpdate()
+

Schedules an update that will be appended to the macro task queue (so it doesn't update the subscribers immediately).

+
+
scheduleNotifyCollectionSubscribers()
+

This method is similar to notifySubscribersOnNextTick but it is built for working specifically with collections +so that keysChanged() is triggered for the collection and not keyChanged(). If this was not done, then the +subscriber callbacks receive the data in a different format than they normally expect and it breaks code.

+
+
remove()
+

Remove a key from Onyx and update the subscribers

+
+
evictStorageAndRetry()
+

If we fail to set or merge we must handle this by +evicting some data from Onyx and then retrying to do +whatever it is we attempted to do.

+
+
broadcastUpdate()
+

Notifies subscribers and writes current value to cache

+
+
removeNullValues()
+

Removes a key from storage if the value is null. +Otherwise removes all nested null values in objects and returns the object

+
+
prepareKeyValuePairsForStorage()
+

Storage expects array like: [["@MyApp_user", value_1], ["@MyApp_key", value_2]] +This method transforms an object like {'@MyApp_user': myUserValue, '@MyApp_key': myKeyValue} +to an array of key-value pairs in the above format and removes key-value pairs that are being set to null

+
+
applyMerge(changes)
+

Merges an array of changes with an existing value

+
+
initializeWithDefaultKeyStates()
+

Merge user provided default key value pairs.

+
+
+ + + +## getMergeQueue() +Getter - returns the merge queue. + +**Kind**: global function + + +## getMergeQueuePromise() +Getter - returns the merge queue promise. + +**Kind**: global function + + +## getCallbackToStateMapping() +Getter - returns the callback to state mapping. + +**Kind**: global function + + +## getDefaultKeyStates() +Getter - returns the default key states. + +**Kind**: global function + + +## initStoreValues(keys, initialKeyStates, safeEvictionKeys) +Sets the initial values for the Onyx store + +**Kind**: global function + +| Param | Description | +| --- | --- | +| keys | `ONYXKEYS` constants object from Onyx.init() | +| initialKeyStates | initial data to set when `init()` and `clear()` are called | +| safeEvictionKeys | This is an array of keys (individual or collection patterns) that when provided to Onyx are flagged as "safe" for removal. | + + + +## maybeFlushBatchUpdates() +We are batching together onyx updates. This helps with use cases where we schedule onyx updates after each other. +This happens for example in the Onyx.update function, where we process API responses that might contain a lot of +update operations. Instead of calling the subscribers for each update operation, we batch them together which will +cause react to schedule the updates at once instead of after each other. This is mainly a performance optimization. + +**Kind**: global function + + +## reduceCollectionWithSelector() +Takes a collection of items (eg. {testKey_1:{a:'a'}, testKey_2:{b:'b'}}) +and runs it through a reducer function to return a subset of the data according to a selector. +The resulting collection will only contain items that are returned by the selector. + +**Kind**: global function + + +## get() +Get some data from the store + +**Kind**: global function + + +## getAllKeys() +Returns current key names stored in persisted storage + +**Kind**: global function + + +## isCollectionKey() +Checks to see if the a subscriber's supplied key +is associated with a collection of keys. + +**Kind**: global function + + +## splitCollectionMemberKey(key) ⇒ +Splits a collection member key into the collection key part and the ID part. + +**Kind**: global function +**Returns**: A tuple where the first element is the collection part and the second element is the ID part. + +| Param | Description | +| --- | --- | +| key | The collection member key to split. | + + + +## isKeyMatch() +Checks to see if a provided key is the exact configured key of our connected subscriber +or if the provided key is a collection member key (in case our configured key is a "collection key") + +**Kind**: global function + + +## isSafeEvictionKey() +Checks to see if this key has been flagged as safe for removal. + +**Kind**: global function + + +## tryGetCachedValue() +Tries to get a value from the cache. If the value is not present in cache it will return the default value or undefined. +If the requested key is a collection, it will return an object with all the collection members. + +**Kind**: global function + + +## removeLastAccessedKey() +Remove a key from the recently accessed key list. + +**Kind**: global function + + +## addLastAccessedKey() +Add a key to the list of recently accessed keys. The least +recently accessed key should be at the head and the most +recently accessed key at the tail. + +**Kind**: global function + + +## removeFromEvictionBlockList() +Removes a key previously added to this list +which will enable it to be deleted again. + +**Kind**: global function + + +## addToEvictionBlockList() +Keys added to this list can never be deleted. + +**Kind**: global function + + +## addAllSafeEvictionKeysToRecentlyAccessedList() +Take all the keys that are safe to evict and add them to +the recently accessed list when initializing the app. This +enables keys that have not recently been accessed to be +removed. + +**Kind**: global function + + +## keysChanged() +When a collection of keys change, search for any callbacks matching the collection key and trigger those callbacks + +**Kind**: global function + +* [keysChanged()](#keysChanged) + * [~isSubscribedToCollectionKey](#keysChanged..isSubscribedToCollectionKey) + * [~isSubscribedToCollectionMemberKey](#keysChanged..isSubscribedToCollectionMemberKey) + + + +### keysChanged~isSubscribedToCollectionKey +e.g. Onyx.connect({key: ONYXKEYS.COLLECTION.REPORT, callback: ...}); + +**Kind**: inner constant of [keysChanged](#keysChanged) + + +### keysChanged~isSubscribedToCollectionMemberKey +e.g. Onyx.connect({key: `${ONYXKEYS.COLLECTION.REPORT}{reportID}`, callback: ...}); + +**Kind**: inner constant of [keysChanged](#keysChanged) + + +## keyChanged() +When a key change happens, search for any callbacks matching the key or collection key and trigger those callbacks + +**Kind**: global function +**Example** +```js +keyChanged(key, value, subscriber => subscriber.initWithStoredValues === false) +``` + + +## sendDataToConnection() +Sends the data obtained from the keys to the connection. It either: + - sets state on the withOnyxInstances + - triggers the callback function + +**Kind**: global function + + +## addKeyToRecentlyAccessedIfNeeded() +We check to see if this key is flagged as safe for eviction and add it to the recentlyAccessedKeys list so that when we +run out of storage the least recently accessed key can be removed. + +**Kind**: global function + + +## getCollectionDataAndSendAsObject() +Gets the data for a given an array of matching keys, combines them into an object, and sends the result back to the subscriber. + +**Kind**: global function + + +## scheduleSubscriberUpdate() +Schedules an update that will be appended to the macro task queue (so it doesn't update the subscribers immediately). + +**Kind**: global function +**Example** +```js +scheduleSubscriberUpdate(key, value, subscriber => subscriber.initWithStoredValues === false) +``` + + +## scheduleNotifyCollectionSubscribers() +This method is similar to notifySubscribersOnNextTick but it is built for working specifically with collections +so that keysChanged() is triggered for the collection and not keyChanged(). If this was not done, then the +subscriber callbacks receive the data in a different format than they normally expect and it breaks code. + +**Kind**: global function + + +## remove() +Remove a key from Onyx and update the subscribers + +**Kind**: global function + + +## evictStorageAndRetry() +If we fail to set or merge we must handle this by +evicting some data from Onyx and then retrying to do +whatever it is we attempted to do. + +**Kind**: global function + + +## broadcastUpdate() +Notifies subscribers and writes current value to cache + +**Kind**: global function + + +## removeNullValues() ⇒ +Removes a key from storage if the value is null. +Otherwise removes all nested null values in objects and returns the object + +**Kind**: global function +**Returns**: The value without null values and a boolean "wasRemoved", which indicates if the key got removed completely + + +## prepareKeyValuePairsForStorage() ⇒ +Storage expects array like: [["@MyApp_user", value_1], ["@MyApp_key", value_2]] +This method transforms an object like {'@MyApp_user': myUserValue, '@MyApp_key': myKeyValue} +to an array of key-value pairs in the above format and removes key-value pairs that are being set to null + +**Kind**: global function +**Returns**: an array of key - value pairs <[key, value]> + + +## applyMerge(changes) +Merges an array of changes with an existing value + +**Kind**: global function + +| Param | Description | +| --- | --- | +| changes | Array of changes that should be applied to the existing value | + + + +## initializeWithDefaultKeyStates() +Merge user provided default key value pairs. + +**Kind**: global function diff --git a/API.md b/API.md index cbd98288..59e76ce7 100644 --- a/API.md +++ b/API.md @@ -1,70 +1,26 @@ - + # API Reference ## Functions
-
sendActionToDevTools(method, key, value, mergedValue)
-

Sends an action to DevTools extension

-
-
maybeFlushBatchUpdates()Promise
-

We are batching together onyx updates. This helps with use cases where we schedule onyx updates after each other. -This happens for example in the Onyx.update function, where we process API responses that might contain a lot of -update operations. Instead of calling the subscribers for each update operation, we batch them together which will -cause react to schedule the updates at once instead of after each other. This is mainly a performance optimization.

-
-
getSubsetOfData(sourceData, selector, [withOnyxInstanceState])Mixed
-

Uses a selector function to return a simplified version of sourceData

-
-
reduceCollectionWithSelector(collection, selector, [withOnyxInstanceState])Object
-

Takes a collection of items (eg. {testKey_1:{a:'a'}, testKey_2:{b:'b'}}) -and runs it through a reducer function to return a subset of the data according to a selector. -The resulting collection will only contain items that are returned by the selector.

-
-
isCollectionKey(key)Boolean
-

Checks to see if the a subscriber's supplied key -is associated with a collection of keys.

-
-
isCollectionMemberKey(collectionKey, key)Boolean
-
-
splitCollectionMemberKey(key)Array.<String>
-

Splits a collection member key into the collection key part and the ID part.

-
-
tryGetCachedValue(key, mapping)Mixed
-

Tries to get a value from the cache. If the value is not present in cache it will return the default value or undefined. -If the requested key is a collection, it will return an object with all the collection members.

+
init()
+

Initialize the store with actions and listening for storage events

-
connect(mapping)Number
+
connect(mapping)

Subscribes a react component's state directly to a store key

-
disconnect(connectionID, [keyToRemoveFromEvictionBlocklist])
+
disconnect(connectionID)

Remove the listener for a react component

-
scheduleSubscriberUpdate(key, value, prevValue, [canUpdateSubscriber])Promise
-

Schedules an update that will be appended to the macro task queue (so it doesn't update the subscribers immediately).

-
-
scheduleNotifyCollectionSubscribers(key, value)Promise
-

This method is similar to notifySubscribersOnNextTick but it is built for working specifically with collections -so that keysChanged() is triggered for the collection and not keyChanged(). If this was not done, then the -subscriber callbacks receive the data in a different format than they normally expect and it breaks code.

-
-
broadcastUpdate(key, value, hasChanged, wasRemoved)Promise
-

Notifys subscribers and writes current value to cache

-
-
hasPendingMergeForKey(key)Boolean
-
-
removeNullValues(key, value)Mixed
-

Removes a key from storage if the value is null. -Otherwise removes all nested null values in objects and returns the object

-
-
set(key, value)Promise
+
set(key, value)

Write a value to our store with the given key

-
multiSet(data)Promise
+
multiSet(data)

Sets multiple keys and values

-
merge(key, changes)Promise
+
merge()

Merge a new value into an existing value at a key.

The types of values that can be merged are Object and Array. To set another type of value use Onyx.set(). Values of type Object get merged with the old value, whilst for Array's we simply replace the current value with the new one.

@@ -72,7 +28,10 @@ Values of type Object get merged with the old value, whilst for Onyx.set() calls do not work this way so use caution when mixing Onyx.merge() and Onyx.set().

-
clear(keysToPreserve)Promise.<void>
+
mergeCollection(collectionKey, collection)
+

Merges a collection based on their keys

+
+
clear(keysToPreserve)

Clear out all the data in the store

Note that calling Onyx.clear() and then Onyx.set() on a key with a default key state may store an unexpected value in Storage.

@@ -88,136 +47,38 @@ Onyx.get(key) before calling Storage.setItem() via Onyx.set(). Storage.setItem() from Onyx.clear() will have already finished and the merged value will be saved to storage after the default value.

-
mergeCollection(collectionKey, collection)Promise
-

Merges a collection based on their keys

-
-
update(data)Promise
+
update(data)

Insert API responses and lifecycle data into Onyx

-
init([options])
-

Initialize the store with actions and listening for storage events

-
- - -## sendActionToDevTools(method, key, value, mergedValue) -Sends an action to DevTools extension - -**Kind**: global function - -| Param | Type | Description | -| --- | --- | --- | -| method | string | Onyx method from METHOD | -| key | string | Onyx key that was changed | -| value | any | contains the change that was made by the method | -| mergedValue | any | (optional) value that was written in the storage after a merge method was executed. | - - - -## maybeFlushBatchUpdates() ⇒ Promise -We are batching together onyx updates. This helps with use cases where we schedule onyx updates after each other. -This happens for example in the Onyx.update function, where we process API responses that might contain a lot of -update operations. Instead of calling the subscribers for each update operation, we batch them together which will -cause react to schedule the updates at once instead of after each other. This is mainly a performance optimization. - -**Kind**: global function - - -## getSubsetOfData(sourceData, selector, [withOnyxInstanceState]) ⇒ Mixed -Uses a selector function to return a simplified version of sourceData - -**Kind**: global function - -| Param | Type | Description | -| --- | --- | --- | -| sourceData | Mixed | | -| selector | function | Function that takes sourceData and returns a simplified version of it | -| [withOnyxInstanceState] | Object | | - - - -## reduceCollectionWithSelector(collection, selector, [withOnyxInstanceState]) ⇒ Object -Takes a collection of items (eg. {testKey_1:{a:'a'}, testKey_2:{b:'b'}}) -and runs it through a reducer function to return a subset of the data according to a selector. -The resulting collection will only contain items that are returned by the selector. - -**Kind**: global function - -| Param | Type | Description | -| --- | --- | --- | -| collection | Object | | -| selector | String \| function | (see method docs for getSubsetOfData() for full details) | -| [withOnyxInstanceState] | Object | | - - - -## isCollectionKey(key) ⇒ Boolean -Checks to see if the a subscriber's supplied key -is associated with a collection of keys. - -**Kind**: global function - -| Param | Type | -| --- | --- | -| key | String | - - - -## isCollectionMemberKey(collectionKey, key) ⇒ Boolean -**Kind**: global function - -| Param | Type | -| --- | --- | -| collectionKey | String | -| key | String | - - - -## splitCollectionMemberKey(key) ⇒ Array.<String> -Splits a collection member key into the collection key part and the ID part. - -**Kind**: global function -**Returns**: Array.<String> - A tuple where the first element is the collection part and the second element is the ID part. - -| Param | Type | Description | -| --- | --- | --- | -| key | String | The collection member key to split. | - - - -## tryGetCachedValue(key, mapping) ⇒ Mixed -Tries to get a value from the cache. If the value is not present in cache it will return the default value or undefined. -If the requested key is a collection, it will return an object with all the collection members. - -**Kind**: global function + -| Param | Type | -| --- | --- | -| key | String | -| mapping | Object | +## init() +Initialize the store with actions and listening for storage events +**Kind**: global function -## connect(mapping) ⇒ Number +## connect(mapping) ⇒ Subscribes a react component's state directly to a store key -**Kind**: global function -**Returns**: Number - an ID to use when calling disconnect - -| Param | Type | Description | -| --- | --- | --- | -| mapping | Object | the mapping information to connect Onyx to the components state | -| mapping.key | String | ONYXKEY to subscribe to | -| [mapping.statePropertyName] | String | the name of the property in the state to connect the data to | -| [mapping.withOnyxInstance] | Object | whose setState() method will be called with any changed data This is used by React components to connect to Onyx | -| [mapping.callback] | function | a method that will be called with changed data This is used by any non-React code to connect to Onyx | -| [mapping.initWithStoredValues] | Boolean | If set to false, then no data will be prefilled into the component | -| [mapping.waitForCollectionCallback] | Boolean | If set to true, it will return the entire collection to the callback as a single object | -| [mapping.selector] | function | THIS PARAM IS ONLY USED WITH withOnyx(). If included, this will be used to subscribe to a subset of an Onyx key's data. The sourceData and withOnyx state are passed to the selector and should return the simplified data. Using this setting on `withOnyx` can have very positive performance benefits because the component will only re-render when the subset of data changes. Otherwise, any change of data on any property would normally cause the component to re-render (and that can be expensive from a performance standpoint). | -| [mapping.initialValue] | String \| Number \| Boolean \| Object | THIS PARAM IS ONLY USED WITH withOnyx(). If included, this will be passed to the component so that something can be rendered while data is being fetched from the DB. Note that it will not cause the component to have the loading prop set to true. | | - -**Example** +**Kind**: global function +**Returns**: an ID to use when calling disconnect + +| Param | Description | +| --- | --- | +| mapping | the mapping information to connect Onyx to the components state | +| mapping.key | ONYXKEY to subscribe to | +| [mapping.statePropertyName] | the name of the property in the state to connect the data to | +| [mapping.withOnyxInstance] | whose setState() method will be called with any changed data This is used by React components to connect to Onyx | +| [mapping.callback] | a method that will be called with changed data This is used by any non-React code to connect to Onyx | +| [mapping.initWithStoredValues] | If set to false, then no data will be prefilled into the component | +| [mapping.waitForCollectionCallback] | If set to true, it will return the entire collection to the callback as a single object | +| [mapping.selector] | THIS PARAM IS ONLY USED WITH withOnyx(). If included, this will be used to subscribe to a subset of an Onyx key's data. The sourceData and withOnyx state are passed to the selector and should return the simplified data. Using this setting on `withOnyx` can have very positive performance benefits because the component will only re-render when the subset of data changes. Otherwise, any change of data on any property would normally cause the component to re-render (and that can be expensive from a performance standpoint). | +| [mapping.initialValue] | THIS PARAM IS ONLY USED WITH withOnyx(). If included, this will be passed to the component so that something can be rendered while data is being fetched from the DB. Note that it will not cause the component to have the loading prop set to true. | + +**Example** ```js const connectionID = Onyx.connect({ key: ONYXKEYS.SESSION, @@ -226,119 +87,49 @@ const connectionID = Onyx.connect({ ``` -## disconnect(connectionID, [keyToRemoveFromEvictionBlocklist]) +## disconnect(connectionID) Remove the listener for a react component -**Kind**: global function +**Kind**: global function -| Param | Type | Description | -| --- | --- | --- | -| connectionID | Number | unique id returned by call to Onyx.connect() | -| [keyToRemoveFromEvictionBlocklist] | String | | +| Param | Description | +| --- | --- | +| connectionID | unique id returned by call to Onyx.connect() | -**Example** +**Example** ```js Onyx.disconnect(connectionID); ``` - - -## scheduleSubscriberUpdate(key, value, prevValue, [canUpdateSubscriber]) ⇒ Promise -Schedules an update that will be appended to the macro task queue (so it doesn't update the subscribers immediately). - -**Kind**: global function - -| Param | Type | Description | -| --- | --- | --- | -| key | String | | -| value | \* | | -| prevValue | \* | | -| [canUpdateSubscriber] | function | only subscribers that pass this truth test will be updated | - -**Example** -```js -scheduleSubscriberUpdate(key, value, subscriber => subscriber.initWithStoredValues === false) -``` - - -## scheduleNotifyCollectionSubscribers(key, value) ⇒ Promise -This method is similar to notifySubscribersOnNextTick but it is built for working specifically with collections -so that keysChanged() is triggered for the collection and not keyChanged(). If this was not done, then the -subscriber callbacks receive the data in a different format than they normally expect and it breaks code. - -**Kind**: global function - -| Param | Type | -| --- | --- | -| key | String | -| value | \* | - - - -## broadcastUpdate(key, value, hasChanged, wasRemoved) ⇒ Promise -Notifys subscribers and writes current value to cache - -**Kind**: global function - -| Param | Type | Default | -| --- | --- | --- | -| key | String | | -| value | \* | | -| hasChanged | Boolean | | -| wasRemoved | Boolean | false | - - - -## hasPendingMergeForKey(key) ⇒ Boolean -**Kind**: global function - -| Param | Type | -| --- | --- | -| key | String | - - - -## removeNullValues(key, value) ⇒ Mixed -Removes a key from storage if the value is null. -Otherwise removes all nested null values in objects and returns the object - -**Kind**: global function -**Returns**: Mixed - The value without null values and a boolean "wasRemoved", which indicates if the key got removed completely - -| Param | Type | -| --- | --- | -| key | String | -| value | Mixed | - -## set(key, value) ⇒ Promise +## set(key, value) Write a value to our store with the given key -**Kind**: global function +**Kind**: global function -| Param | Type | Description | -| --- | --- | --- | -| key | String | ONYXKEY to set | -| value | \* | value to store | +| Param | Description | +| --- | --- | +| key | ONYXKEY to set | +| value | value to store | -## multiSet(data) ⇒ Promise +## multiSet(data) Sets multiple keys and values -**Kind**: global function +**Kind**: global function -| Param | Type | Description | -| --- | --- | --- | -| data | Object | object keyed by ONYXKEYS and the values to set | +| Param | Description | +| --- | --- | +| data | object keyed by ONYXKEYS and the values to set | -**Example** +**Example** ```js Onyx.multiSet({'key1': 'a', 'key2': 'b'}); ``` -## merge(key, changes) ⇒ Promise +## merge() Merge a new value into an existing value at a key. The types of values that can be merged are `Object` and `Array`. To set another type of value use `Onyx.set()`. @@ -348,23 +139,36 @@ Calls to `Onyx.merge()` are batched so that any calls performed in a single tick applied in the order they were called. Note: `Onyx.set()` calls do not work this way so use caution when mixing `Onyx.merge()` and `Onyx.set()`. -**Kind**: global function - -| Param | Type | Description | -| --- | --- | --- | -| key | String | ONYXKEYS key | -| changes | Object \| Array | Object or Array value to merge | - -**Example** +**Kind**: global function +**Example** ```js Onyx.merge(ONYXKEYS.EMPLOYEE_LIST, ['Joe']); // -> ['Joe'] Onyx.merge(ONYXKEYS.EMPLOYEE_LIST, ['Jack']); // -> ['Joe', 'Jack'] Onyx.merge(ONYXKEYS.POLICY, {id: 1}); // -> {id: 1} Onyx.merge(ONYXKEYS.POLICY, {name: 'My Workspace'}); // -> {id: 1, name: 'My Workspace'} ``` + + +## mergeCollection(collectionKey, collection) +Merges a collection based on their keys + +**Kind**: global function + +| Param | Description | +| --- | --- | +| collectionKey | e.g. `ONYXKEYS.COLLECTION.REPORT` | +| collection | Object collection keyed by individual collection member keys and values | + +**Example** +```js +Onyx.mergeCollection(ONYXKEYS.COLLECTION.REPORT, { + [`${ONYXKEYS.COLLECTION.REPORT}1`]: report1, + [`${ONYXKEYS.COLLECTION.REPORT}2`]: report2, +}); +``` -## clear(keysToPreserve) ⇒ Promise.<void> +## clear(keysToPreserve) Clear out all the data in the store Note that calling Onyx.clear() and then Onyx.set() on a key with a default @@ -383,67 +187,21 @@ Onyx.get(key) before calling Storage.setItem() via Onyx.set(). Storage.setItem() from Onyx.clear() will have already finished and the merged value will be saved to storage after the default value. -**Kind**: global function +**Kind**: global function -| Param | Type | Description | -| --- | --- | --- | -| keysToPreserve | Array | is a list of ONYXKEYS that should not be cleared with the rest of the data | - - - -## mergeCollection(collectionKey, collection) ⇒ Promise -Merges a collection based on their keys - -**Kind**: global function - -| Param | Type | Description | -| --- | --- | --- | -| collectionKey | String | e.g. `ONYXKEYS.COLLECTION.REPORT` | -| collection | Object | Object collection keyed by individual collection member keys and values | +| Param | Description | +| --- | --- | +| keysToPreserve | is a list of ONYXKEYS that should not be cleared with the rest of the data | -**Example** -```js -Onyx.mergeCollection(ONYXKEYS.COLLECTION.REPORT, { - [`${ONYXKEYS.COLLECTION.REPORT}1`]: report1, - [`${ONYXKEYS.COLLECTION.REPORT}2`]: report2, -}); -``` -## update(data) ⇒ Promise +## update(data) ⇒ Insert API responses and lifecycle data into Onyx -**Kind**: global function -**Returns**: Promise - resolves when all operations are complete - -| Param | Type | Description | -| --- | --- | --- | -| data | Array | An array of objects with shape {onyxMethod: oneOf('set', 'merge', 'mergeCollection', 'multiSet', 'clear'), key: string, value: *} | - - - -## init([options]) -Initialize the store with actions and listening for storage events - -**Kind**: global function +**Kind**: global function +**Returns**: resolves when all operations are complete -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| [options] | Object | {} | config object | -| [options.keys] | Object | {} | `ONYXKEYS` constants object | -| [options.initialKeyStates] | Object | {} | initial data to set when `init()` and `clear()` is called | -| [options.safeEvictionKeys] | Array.<String> | [] | This is an array of keys (individual or collection patterns) that when provided to Onyx are flagged as "safe" for removal. Any components subscribing to these keys must also implement a canEvict option. See the README for more info. | -| [options.maxCachedKeysCount] | Number | 55 | Sets how many recent keys should we try to keep in cache Setting this to 0 would practically mean no cache We try to free cache when we connect to a safe eviction key | -| [options.captureMetrics] | Boolean | | Enables Onyx benchmarking and exposes the get/print/reset functions | -| [options.shouldSyncMultipleInstances] | Boolean | | Auto synchronize storage events between multiple instances of Onyx running in different tabs/windows. Defaults to true for platforms that support local storage (web/desktop) | -| [options.debugSetState] | Boolean | | Enables debugging setState() calls to connected components. | +| Param | Description | +| --- | --- | +| data | An array of objects with update expressions | -**Example** -```js -Onyx.init({ - keys: ONYXKEYS, - initialKeyStates: { - [ONYXKEYS.SESSION]: {loading: false}, - }, -}); -``` diff --git a/buildDocs.js b/buildDocs.js deleted file mode 100644 index 2b45a96d..00000000 --- a/buildDocs.js +++ /dev/null @@ -1,8 +0,0 @@ -const fs = require('fs'); -const jsdoc2md = require('jsdoc-to-markdown'); - -jsdoc2md.render({files: 'lib/Onyx.js'}).then((docs) => { - let heading = '\n\n# API Reference\n\n'; - heading += docs; - fs.writeFileSync('API.md', heading); -}); diff --git a/buildDocs.ts b/buildDocs.ts new file mode 100644 index 00000000..c3066142 --- /dev/null +++ b/buildDocs.ts @@ -0,0 +1,14 @@ +import fs from 'fs'; +import jsdoc2md from 'jsdoc-to-markdown'; + +jsdoc2md.render({files: 'dist/Onyx.js'}).then((docs) => { + let heading = '\n\n# API Reference\n\n'; + heading += docs; + fs.writeFileSync('API.md', heading); +}); + +jsdoc2md.render({files: 'dist/OnyxUtils.js'}).then((docs) => { + let heading = '\n\n# Internal API Reference\n\n'; + heading += docs; + fs.writeFileSync('API-INTERNAL.md', heading); +}); diff --git a/lib/Onyx.ts b/lib/Onyx.ts index 95d056c9..ee039a91 100644 --- a/lib/Onyx.ts +++ b/lib/Onyx.ts @@ -554,7 +554,7 @@ function clear(keysToPreserve: OnyxKey[] = []): Promise { /** * Insert API responses and lifecycle data into Onyx * - * @param data An array of objects with shape {onyxMethod: oneOf('set', 'merge', 'mergeCollection', 'multiSet', 'clear'), key: string, value: *} + * @param data An array of objects with update expressions * @returns resolves when all operations are complete */ function update(data: OnyxUpdate[]): Promise { diff --git a/package-lock.json b/package-lock.json index 66d1ed11..e24b1925 100644 --- a/package-lock.json +++ b/package-lock.json @@ -20,6 +20,7 @@ "@testing-library/jest-native": "^3.4.2", "@testing-library/react-native": "^10.0.0", "@types/jest": "^28.1.8", + "@types/jsdoc-to-markdown": "^7.0.6", "@types/lodash": "^4.14.202", "@types/node": "^20.11.5", "@types/react": "^18.2.14", @@ -49,6 +50,7 @@ "react-native-performance": "^2.0.0", "react-native-quick-sqlite": "^8.0.6", "react-test-renderer": "18.1.0", + "ts-node": "^10.9.2", "type-fest": "^3.12.0", "typescript": "^5.3.3" }, @@ -2178,6 +2180,28 @@ "node": ">=0.1.95" } }, + "node_modules/@cspotcode/source-map-support": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", + "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", + "dev": true, + "dependencies": { + "@jridgewell/trace-mapping": "0.3.9" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/@cspotcode/source-map-support/node_modules/@jridgewell/trace-mapping": { + "version": "0.3.9", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", + "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", + "dev": true, + "dependencies": { + "@jridgewell/resolve-uri": "^3.0.3", + "@jridgewell/sourcemap-codec": "^1.4.10" + } + }, "node_modules/@eslint-community/eslint-utils": { "version": "4.4.0", "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz", @@ -3796,6 +3820,30 @@ "node": ">= 6" } }, + "node_modules/@tsconfig/node10": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.11.tgz", + "integrity": "sha512-DcRjDCujK/kCk/cUe8Xz8ZSpm8mS3mNNpta+jGCA6USEDfktlNvm1+IuZ9eTcDbNk41BHwpHHeW+N1lKCz4zOw==", + "dev": true + }, + "node_modules/@tsconfig/node12": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.11.tgz", + "integrity": "sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==", + "dev": true + }, + "node_modules/@tsconfig/node14": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.3.tgz", + "integrity": "sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==", + "dev": true + }, + "node_modules/@tsconfig/node16": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.4.tgz", + "integrity": "sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==", + "dev": true + }, "node_modules/@types/babel__core": { "version": "7.1.20", "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.1.20.tgz", @@ -4073,6 +4121,12 @@ "integrity": "sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w==", "dev": true }, + "node_modules/@types/jsdoc-to-markdown": { + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/@types/jsdoc-to-markdown/-/jsdoc-to-markdown-7.0.6.tgz", + "integrity": "sha512-FB/oOam8P4WoGbkfLu6ciektQhqlVuL4VsbrGJp3/YDAlRGcoiOhXDnnPL73TtHYMsDZ7NHYhCGJn4hu0TZdHg==", + "dev": true + }, "node_modules/@types/json-schema": { "version": "7.0.15", "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz", @@ -4685,6 +4739,12 @@ "integrity": "sha512-Quji6+8kLBC3NnBeo14nPDq0+2jUs5s3/xEye+udFHumHhRk4M7aAMXp/PBJqkKYGuuyR9M/6Dq7d2AViiGmhw==", "dev": true }, + "node_modules/arg": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", + "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==", + "dev": true + }, "node_modules/argparse": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", @@ -6154,6 +6214,12 @@ "node": ">=4" } }, + "node_modules/create-require": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", + "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==", + "dev": true + }, "node_modules/cross-spawn": { "version": "7.0.3", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", @@ -6481,6 +6547,15 @@ "node": ">=8" } }, + "node_modules/diff": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", + "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", + "dev": true, + "engines": { + "node": ">=0.3.1" + } + }, "node_modules/diff-sequences": { "version": "24.9.0", "resolved": "https://registry.npmjs.org/diff-sequences/-/diff-sequences-24.9.0.tgz", @@ -11963,6 +12038,12 @@ "semver": "bin/semver.js" } }, + "node_modules/make-error": { + "version": "1.3.6", + "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", + "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==", + "dev": true + }, "node_modules/makeerror": { "version": "1.0.12", "resolved": "https://registry.npmjs.org/makeerror/-/makeerror-1.0.12.tgz", @@ -16846,6 +16927,58 @@ "typescript": ">=4.2.0" } }, + "node_modules/ts-node": { + "version": "10.9.2", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.2.tgz", + "integrity": "sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ==", + "dev": true, + "dependencies": { + "@cspotcode/source-map-support": "^0.8.0", + "@tsconfig/node10": "^1.0.7", + "@tsconfig/node12": "^1.0.7", + "@tsconfig/node14": "^1.0.0", + "@tsconfig/node16": "^1.0.2", + "acorn": "^8.4.1", + "acorn-walk": "^8.1.1", + "arg": "^4.1.0", + "create-require": "^1.1.0", + "diff": "^4.0.1", + "make-error": "^1.1.1", + "v8-compile-cache-lib": "^3.0.1", + "yn": "3.1.1" + }, + "bin": { + "ts-node": "dist/bin.js", + "ts-node-cwd": "dist/bin-cwd.js", + "ts-node-esm": "dist/bin-esm.js", + "ts-node-script": "dist/bin-script.js", + "ts-node-transpile-only": "dist/bin-transpile.js", + "ts-script": "dist/bin-script-deprecated.js" + }, + "peerDependencies": { + "@swc/core": ">=1.2.50", + "@swc/wasm": ">=1.2.50", + "@types/node": "*", + "typescript": ">=2.7" + }, + "peerDependenciesMeta": { + "@swc/core": { + "optional": true + }, + "@swc/wasm": { + "optional": true + } + } + }, + "node_modules/ts-node/node_modules/acorn-walk": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.3.2.tgz", + "integrity": "sha512-cjkyv4OtNCIeqhHrfS81QWXoCBPExR/J62oyEqepVw8WaQeSqpW2uhuLPh1m9eWhDuOo/jUXVTlifvesOWp/4A==", + "dev": true, + "engines": { + "node": ">=0.4.0" + } + }, "node_modules/tsconfig-paths": { "version": "3.15.0", "resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.15.0.tgz", @@ -17300,6 +17433,12 @@ "integrity": "sha512-ocyWc3bAHBB/guyqJQVI5o4BZkPhznPYUG2ea80Gond/BgNWpap8TOmLSeeQG7bnh2KMISxskdADG59j7zruhw==", "dev": true }, + "node_modules/v8-compile-cache-lib": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", + "integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==", + "dev": true + }, "node_modules/v8-to-istanbul": { "version": "7.1.2", "resolved": "https://registry.npmjs.org/v8-to-istanbul/-/v8-to-istanbul-7.1.2.tgz", @@ -17795,6 +17934,15 @@ "node": ">=8" } }, + "node_modules/yn": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", + "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==", + "dev": true, + "engines": { + "node": ">=6" + } + }, "node_modules/yocto-queue": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", @@ -19300,6 +19448,27 @@ "minimist": "^1.2.0" } }, + "@cspotcode/source-map-support": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", + "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", + "dev": true, + "requires": { + "@jridgewell/trace-mapping": "0.3.9" + }, + "dependencies": { + "@jridgewell/trace-mapping": { + "version": "0.3.9", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", + "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", + "dev": true, + "requires": { + "@jridgewell/resolve-uri": "^3.0.3", + "@jridgewell/sourcemap-codec": "^1.4.10" + } + } + } + }, "@eslint-community/eslint-utils": { "version": "4.4.0", "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz", @@ -20551,6 +20720,30 @@ "integrity": "sha512-RbzJvlNzmRq5c3O09UipeuXno4tA1FE6ikOjxZK0tuxVv3412l64l5t1W5pj4+rJq9vpkm/kwiR07aZXnsKPxw==", "dev": true }, + "@tsconfig/node10": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.11.tgz", + "integrity": "sha512-DcRjDCujK/kCk/cUe8Xz8ZSpm8mS3mNNpta+jGCA6USEDfktlNvm1+IuZ9eTcDbNk41BHwpHHeW+N1lKCz4zOw==", + "dev": true + }, + "@tsconfig/node12": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.11.tgz", + "integrity": "sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==", + "dev": true + }, + "@tsconfig/node14": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.3.tgz", + "integrity": "sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==", + "dev": true + }, + "@tsconfig/node16": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.4.tgz", + "integrity": "sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==", + "dev": true + }, "@types/babel__core": { "version": "7.1.20", "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.1.20.tgz", @@ -20785,6 +20978,12 @@ } } }, + "@types/jsdoc-to-markdown": { + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/@types/jsdoc-to-markdown/-/jsdoc-to-markdown-7.0.6.tgz", + "integrity": "sha512-FB/oOam8P4WoGbkfLu6ciektQhqlVuL4VsbrGJp3/YDAlRGcoiOhXDnnPL73TtHYMsDZ7NHYhCGJn4hu0TZdHg==", + "dev": true + }, "@types/json-schema": { "version": "7.0.15", "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz", @@ -21241,6 +21440,12 @@ "integrity": "sha512-Quji6+8kLBC3NnBeo14nPDq0+2jUs5s3/xEye+udFHumHhRk4M7aAMXp/PBJqkKYGuuyR9M/6Dq7d2AViiGmhw==", "dev": true }, + "arg": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", + "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==", + "dev": true + }, "argparse": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", @@ -22383,6 +22588,12 @@ } } }, + "create-require": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", + "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==", + "dev": true + }, "cross-spawn": { "version": "7.0.3", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", @@ -22638,6 +22849,12 @@ "integrity": "sha512-TLz+x/vEXm/Y7P7wn1EJFNLxYpUD4TgMosxY6fAVJUnJMbupHBOncxyWUG9OpTaH9EBD7uFI5LfEgmMOc54DsA==", "dev": true }, + "diff": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", + "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", + "dev": true + }, "diff-sequences": { "version": "24.9.0", "resolved": "https://registry.npmjs.org/diff-sequences/-/diff-sequences-24.9.0.tgz", @@ -26882,6 +27099,12 @@ } } }, + "make-error": { + "version": "1.3.6", + "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", + "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==", + "dev": true + }, "makeerror": { "version": "1.0.12", "resolved": "https://registry.npmjs.org/makeerror/-/makeerror-1.0.12.tgz", @@ -30795,6 +31018,35 @@ "dev": true, "requires": {} }, + "ts-node": { + "version": "10.9.2", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.2.tgz", + "integrity": "sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ==", + "dev": true, + "requires": { + "@cspotcode/source-map-support": "^0.8.0", + "@tsconfig/node10": "^1.0.7", + "@tsconfig/node12": "^1.0.7", + "@tsconfig/node14": "^1.0.0", + "@tsconfig/node16": "^1.0.2", + "acorn": "^8.4.1", + "acorn-walk": "^8.1.1", + "arg": "^4.1.0", + "create-require": "^1.1.0", + "diff": "^4.0.1", + "make-error": "^1.1.1", + "v8-compile-cache-lib": "^3.0.1", + "yn": "3.1.1" + }, + "dependencies": { + "acorn-walk": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.3.2.tgz", + "integrity": "sha512-cjkyv4OtNCIeqhHrfS81QWXoCBPExR/J62oyEqepVw8WaQeSqpW2uhuLPh1m9eWhDuOo/jUXVTlifvesOWp/4A==", + "dev": true + } + } + }, "tsconfig-paths": { "version": "3.15.0", "resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.15.0.tgz", @@ -31140,6 +31392,12 @@ "integrity": "sha512-ocyWc3bAHBB/guyqJQVI5o4BZkPhznPYUG2ea80Gond/BgNWpap8TOmLSeeQG7bnh2KMISxskdADG59j7zruhw==", "dev": true }, + "v8-compile-cache-lib": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", + "integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==", + "dev": true + }, "v8-to-istanbul": { "version": "7.1.2", "resolved": "https://registry.npmjs.org/v8-to-istanbul/-/v8-to-istanbul-7.1.2.tgz", @@ -31541,6 +31799,12 @@ "decamelize": "^1.2.0" } }, + "yn": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", + "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==", + "dev": true + }, "yocto-queue": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", diff --git a/package.json b/package.json index 2ebeb4bc..245204fe 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,8 @@ "test": "jest", "build": "tsc -p tsconfig.build.json && cp ./lib/*.d.ts ./dist", "build:watch": "nodemon --watch lib --ext js,json,ts,tsx --exec \"npm run build && npm pack\"", - "build:docs": "node buildDocs.js", + "prebuild:docs": "npm run build", + "build:docs": "ts-node buildDocs.ts", "lint-tests": "eslint tests/**", "prettier": "prettier --write ." }, @@ -49,6 +50,7 @@ "@testing-library/jest-native": "^3.4.2", "@testing-library/react-native": "^10.0.0", "@types/jest": "^28.1.8", + "@types/jsdoc-to-markdown": "^7.0.6", "@types/lodash": "^4.14.202", "@types/node": "^20.11.5", "@types/react": "^18.2.14", @@ -78,6 +80,7 @@ "react-native-performance": "^2.0.0", "react-native-quick-sqlite": "^8.0.6", "react-test-renderer": "18.1.0", + "ts-node": "^10.9.2", "type-fest": "^3.12.0", "typescript": "^5.3.3" },