react-native-onyx 3.0.87 → 3.0.88
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/CircuitBreaker/AbstractCircuitBreaker.d.ts +91 -0
- package/dist/CircuitBreaker/AbstractCircuitBreaker.js +166 -0
- package/dist/CircuitBreaker/types.d.ts +38 -0
- package/dist/CircuitBreaker/types.js +24 -0
- package/dist/OnyxUtils.d.ts +11 -5
- package/dist/OnyxUtils.js +87 -41
- package/dist/StateMachine.d.ts +45 -0
- package/dist/StateMachine.js +37 -0
- package/dist/StorageCircuitBreaker.d.ts +66 -0
- package/dist/StorageCircuitBreaker.js +177 -0
- package/dist/storage/__mocks__/index.d.ts +10 -0
- package/dist/storage/__mocks__/index.js +15 -0
- package/dist/storage/errors.d.ts +34 -0
- package/dist/storage/errors.js +41 -0
- package/dist/storage/index.js +5 -0
- package/dist/storage/providers/IDBKeyValProvider/classifyError.d.ts +9 -0
- package/dist/storage/providers/IDBKeyValProvider/classifyError.js +37 -0
- package/dist/storage/providers/IDBKeyValProvider/createStore.js +40 -57
- package/dist/storage/providers/IDBKeyValProvider/index.js +5 -0
- package/dist/storage/providers/MemoryOnlyProvider.js +5 -0
- package/dist/storage/providers/NoopProvider.js +5 -0
- package/dist/storage/providers/SQLiteProvider.js +5 -0
- package/dist/storage/providers/classifySQLiteError.d.ts +13 -0
- package/dist/storage/providers/classifySQLiteError.js +21 -0
- package/dist/storage/providers/types.d.ts +8 -0
- package/package.json +1 -1
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.setMockStore = exports.mockStore = exports.mockSet = void 0;
|
|
7
7
|
const underscore_1 = __importDefault(require("underscore"));
|
|
8
8
|
const utils_1 = __importDefault(require("../../utils"));
|
|
9
|
+
const errors_1 = require("../errors");
|
|
9
10
|
const storeInternal = {};
|
|
10
11
|
exports.mockStore = storeInternal;
|
|
11
12
|
const setInternal = (key, value) => {
|
|
@@ -21,6 +22,10 @@ const provider = {
|
|
|
21
22
|
* The name of the provider that can be printed to the logs
|
|
22
23
|
*/
|
|
23
24
|
name: 'MemoryOnlyProvider',
|
|
25
|
+
/**
|
|
26
|
+
* In-memory storage has no quota/connection failure modes, so nothing is classifiable.
|
|
27
|
+
*/
|
|
28
|
+
classifyError: () => errors_1.StorageErrorClass.UNKNOWN,
|
|
24
29
|
/**
|
|
25
30
|
* Initializes the storage provider
|
|
26
31
|
*/
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const errors_1 = require("../errors");
|
|
3
4
|
const provider = {
|
|
4
5
|
store: undefined,
|
|
5
6
|
/**
|
|
6
7
|
* The name of the provider that can be printed to the logs
|
|
7
8
|
*/
|
|
8
9
|
name: 'NoopProvider',
|
|
10
|
+
/**
|
|
11
|
+
* The noop provider never throws, so nothing is classifiable.
|
|
12
|
+
*/
|
|
13
|
+
classifyError: () => errors_1.StorageErrorClass.UNKNOWN,
|
|
9
14
|
/**
|
|
10
15
|
* Initializes the storage provider
|
|
11
16
|
*/
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const react_native_nitro_sqlite_1 = require("react-native-nitro-sqlite");
|
|
7
7
|
const react_native_device_info_1 = require("react-native-device-info");
|
|
8
8
|
const utils_1 = __importDefault(require("../../utils"));
|
|
9
|
+
const classifySQLiteError_1 = __importDefault(require("./classifySQLiteError"));
|
|
9
10
|
const DB_NAME = 'OnyxDB';
|
|
10
11
|
/**
|
|
11
12
|
* Prevents the stringifying of the object markers.
|
|
@@ -31,6 +32,10 @@ const provider = {
|
|
|
31
32
|
* The name of the provider that can be printed to the logs
|
|
32
33
|
*/
|
|
33
34
|
name: 'SQLiteProvider',
|
|
35
|
+
/**
|
|
36
|
+
* Classifies a SQLite write failure into the shared storage taxonomy.
|
|
37
|
+
*/
|
|
38
|
+
classifyError: classifySQLiteError_1.default,
|
|
34
39
|
/**
|
|
35
40
|
* Initializes the storage provider
|
|
36
41
|
*/
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ValueOf } from 'type-fest';
|
|
2
|
+
import { StorageErrorClass } from '../errors';
|
|
3
|
+
/**
|
|
4
|
+
* Classifies a SQLite write failure into the shared storage taxonomy (lib/storage/errors.ts).
|
|
5
|
+
* This is the SQLite engine's own dialect — it is NOT shared with other engines. It lives in a
|
|
6
|
+
* standalone module (no `react-native-nitro-sqlite` import) so it can be reused without pulling in
|
|
7
|
+
* native dependencies.
|
|
8
|
+
*
|
|
9
|
+
* SQLite surfaces fewer distinct write-failure shapes than IndexedDB. As telemetry from the UNKNOWN
|
|
10
|
+
* bucket (see OnyxUtils.retryOperation) reveals recurring native errors, add matchers here.
|
|
11
|
+
*/
|
|
12
|
+
declare function classifySQLiteError(error: unknown): ValueOf<typeof StorageErrorClass>;
|
|
13
|
+
export default classifySQLiteError;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const errors_1 = require("../errors");
|
|
4
|
+
/**
|
|
5
|
+
* Classifies a SQLite write failure into the shared storage taxonomy (lib/storage/errors.ts).
|
|
6
|
+
* This is the SQLite engine's own dialect — it is NOT shared with other engines. It lives in a
|
|
7
|
+
* standalone module (no `react-native-nitro-sqlite` import) so it can be reused without pulling in
|
|
8
|
+
* native dependencies.
|
|
9
|
+
*
|
|
10
|
+
* SQLite surfaces fewer distinct write-failure shapes than IndexedDB. As telemetry from the UNKNOWN
|
|
11
|
+
* bucket (see OnyxUtils.retryOperation) reveals recurring native errors, add matchers here.
|
|
12
|
+
*/
|
|
13
|
+
function classifySQLiteError(error) {
|
|
14
|
+
const { message } = (0, errors_1.getErrorParts)(error);
|
|
15
|
+
// Device disk full.
|
|
16
|
+
if (message.includes('database or disk is full')) {
|
|
17
|
+
return errors_1.StorageErrorClass.CAPACITY;
|
|
18
|
+
}
|
|
19
|
+
return errors_1.StorageErrorClass.UNKNOWN;
|
|
20
|
+
}
|
|
21
|
+
exports.default = classifySQLiteError;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import type { ValueOf } from 'type-fest';
|
|
1
2
|
import type { OnyxKey, OnyxValue } from '../../types';
|
|
2
3
|
import type { FastMergeReplaceNullPatch } from '../../utils';
|
|
4
|
+
import type { StorageErrorClass } from '../errors';
|
|
3
5
|
type StorageKeyValuePair = [key: OnyxKey, value: OnyxValue<OnyxKey>, replaceNullPatches?: FastMergeReplaceNullPatch[]];
|
|
4
6
|
type StorageKeyList = OnyxKey[];
|
|
5
7
|
type DatabaseSize = {
|
|
@@ -68,6 +70,12 @@ type StorageProvider<TStore> = {
|
|
|
68
70
|
* Gets the total bytes of the database file
|
|
69
71
|
*/
|
|
70
72
|
getDatabaseSize: () => Promise<DatabaseSize>;
|
|
73
|
+
/**
|
|
74
|
+
* Classifies a write error from THIS engine into the shared {@link StorageErrorClass} taxonomy.
|
|
75
|
+
* Each provider owns its own matchers (IndexedDB DOMExceptions, SQLite messages, …) so the central
|
|
76
|
+
* taxonomy stays engine-agnostic. Anything the provider doesn't recognize must return UNKNOWN.
|
|
77
|
+
*/
|
|
78
|
+
classifyError: (error: unknown) => ValueOf<typeof StorageErrorClass>;
|
|
71
79
|
/**
|
|
72
80
|
* @param onStorageKeyChanged Storage synchronization mechanism keeping all opened tabs in sync
|
|
73
81
|
*/
|