supastash 0.2.0 → 0.2.1
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/README.md +20 -3
- package/dist/desktop/adapters/appstate.d.ts +2 -0
- package/dist/desktop/adapters/appstate.d.ts.map +1 -0
- package/dist/desktop/adapters/appstate.js +10 -0
- package/dist/desktop/adapters/crypto.d.ts +3 -0
- package/dist/desktop/adapters/crypto.d.ts.map +1 -0
- package/dist/desktop/adapters/crypto.js +16 -0
- package/dist/{core → desktop/core}/schemaManager/index.d.ts +1 -1
- package/dist/desktop/core/schemaManager/index.d.ts.map +1 -0
- package/dist/{core → desktop/core}/schemaManager/index.js +3 -3
- package/dist/{hooks/supastashData/index.d.ts → desktop/hooks/supastashData.d.ts} +2 -2
- package/dist/desktop/hooks/supastashData.d.ts.map +1 -0
- package/dist/desktop/hooks/supastashData.js +139 -0
- package/dist/{hooks → desktop/hooks}/supastashLogic.d.ts +1 -1
- package/dist/desktop/hooks/supastashLogic.d.ts.map +1 -0
- package/dist/{hooks → desktop/hooks}/supastashLogic.js +11 -12
- package/dist/{hooks/syncEngine/index.d.ts → desktop/hooks/syncEngine.d.ts} +1 -1
- package/dist/desktop/hooks/syncEngine.d.ts.map +1 -0
- package/dist/desktop/hooks/syncEngine.js +233 -0
- package/dist/desktop/index.d.ts +28 -0
- package/dist/desktop/index.d.ts.map +1 -0
- package/dist/desktop/index.js +21 -0
- package/dist/{hooks/supastashData → desktop/utils/fetchData}/eventQueues.d.ts +2 -2
- package/dist/desktop/utils/fetchData/eventQueues.d.ts.map +1 -0
- package/dist/{hooks/supastashData → desktop/utils/fetchData}/eventQueues.js +3 -3
- package/dist/{hooks/supastashData → desktop/utils/fetchData}/fetchCalls.d.ts +1 -1
- package/dist/desktop/utils/fetchData/fetchCalls.d.ts.map +1 -0
- package/dist/{hooks/supastashData → desktop/utils/fetchData}/fetchCalls.js +5 -5
- package/dist/{utils → desktop/utils}/fetchData/initialFetch.d.ts +1 -1
- package/dist/desktop/utils/fetchData/initialFetch.d.ts.map +1 -0
- package/dist/{utils → desktop/utils}/fetchData/initialFetch.js +2 -2
- package/dist/{utils → desktop/utils}/fetchData/receiveData.d.ts +1 -1
- package/dist/desktop/utils/fetchData/receiveData.d.ts.map +1 -0
- package/dist/{utils → desktop/utils}/fetchData/receiveData.js +6 -6
- package/dist/desktop/utils/query/index.d.ts +73 -0
- package/dist/desktop/utils/query/index.d.ts.map +1 -0
- package/dist/desktop/utils/query/index.js +139 -0
- package/dist/desktop/utils/schema/wipeTables.d.ts.map +1 -0
- package/dist/{utils → desktop/utils}/schema/wipeTables.js +4 -4
- package/dist/{utils → desktop/utils}/sync/pullFromRemote/fetchOlder.d.ts +2 -2
- package/dist/desktop/utils/sync/pullFromRemote/fetchOlder.d.ts.map +1 -0
- package/dist/{utils → desktop/utils}/sync/pullFromRemote/fetchOlder.js +2 -2
- package/dist/{utils → desktop/utils}/sync/pullFromRemote/fetchOlderHelpers.d.ts +3 -3
- package/dist/desktop/utils/sync/pullFromRemote/fetchOlderHelpers.d.ts.map +1 -0
- package/dist/{utils → desktop/utils}/sync/pullFromRemote/fetchOlderHelpers.js +8 -14
- package/dist/desktop/utils/sync/pullFromRemote/index.d.ts.map +1 -0
- package/dist/{hooks/syncEngine → desktop/utils/sync}/pullFromRemote/index.js +7 -7
- package/dist/{utils → desktop/utils}/sync/pullFromRemote/pullData.d.ts +2 -2
- package/dist/desktop/utils/sync/pullFromRemote/pullData.d.ts.map +1 -0
- package/dist/{utils → desktop/utils}/sync/pullFromRemote/pullData.js +6 -6
- package/dist/desktop/utils/sync/pullFromRemote/updateLocalDb.d.ts +46 -0
- package/dist/desktop/utils/sync/pullFromRemote/updateLocalDb.d.ts.map +1 -0
- package/dist/desktop/utils/sync/pullFromRemote/updateLocalDb.js +284 -0
- package/dist/desktop/utils/sync/pushLocal/index.d.ts.map +1 -0
- package/dist/{hooks/syncEngine → desktop/utils/sync}/pushLocal/index.js +7 -10
- package/dist/desktop/utils/sync/pushLocal/sendUnsyncedToSupabase.d.ts.map +1 -0
- package/dist/{utils → desktop/utils}/sync/pushLocal/sendUnsyncedToSupabase.js +5 -8
- package/dist/{utils → desktop/utils}/sync/pushLocal/uploadChunk.d.ts +1 -1
- package/dist/desktop/utils/sync/pushLocal/uploadChunk.d.ts.map +1 -0
- package/dist/{utils → desktop/utils}/sync/pushLocal/uploadChunk.js +8 -12
- package/dist/{utils → desktop/utils}/sync/pushLocal/uploadHelpers.d.ts +2 -2
- package/dist/desktop/utils/sync/pushLocal/uploadHelpers.d.ts.map +1 -0
- package/dist/{utils → desktop/utils}/sync/pushLocal/uploadHelpers.js +6 -6
- package/dist/{utils → desktop/utils}/sync/status/filterKey.d.ts +1 -1
- package/dist/desktop/utils/sync/status/filterKey.d.ts.map +1 -0
- package/dist/desktop/utils/sync/status/filterKey.js +48 -0
- package/dist/{utils → desktop/utils}/sync/status/repo.d.ts +3 -3
- package/dist/desktop/utils/sync/status/repo.d.ts.map +1 -0
- package/dist/{utils → desktop/utils}/sync/status/repo.js +3 -3
- package/dist/{utils → desktop/utils}/sync/status/services.d.ts +2 -2
- package/dist/desktop/utils/sync/status/services.d.ts.map +1 -0
- package/dist/{utils → desktop/utils}/sync/status/services.js +3 -3
- package/dist/{utils → desktop/utils}/sync/status/syncStatus.d.ts +2 -2
- package/dist/desktop/utils/sync/status/syncStatus.d.ts.map +1 -0
- package/dist/{utils → desktop/utils}/sync/status/syncStatus.js +4 -4
- package/dist/index.d.ts +18 -25
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -22
- package/dist/native/core/schemaManager/index.d.ts +40 -0
- package/dist/native/core/schemaManager/index.d.ts.map +1 -0
- package/dist/native/core/schemaManager/index.js +141 -0
- package/dist/native/hooks/supastashData.d.ts +67 -0
- package/dist/native/hooks/supastashData.d.ts.map +1 -0
- package/dist/{hooks/supastashData/index.js → native/hooks/supastashData.js} +12 -10
- package/dist/native/hooks/supastashLogic.d.ts +19 -0
- package/dist/native/hooks/supastashLogic.d.ts.map +1 -0
- package/dist/native/hooks/supastashLogic.js +101 -0
- package/dist/native/hooks/syncEngine.d.ts +28 -0
- package/dist/native/hooks/syncEngine.d.ts.map +1 -0
- package/dist/{hooks/syncEngine/index.js → native/hooks/syncEngine.js} +18 -18
- package/dist/native/index.d.ts +28 -0
- package/dist/native/index.d.ts.map +1 -0
- package/dist/native/index.js +21 -0
- package/dist/native/utils/fetchData/eventQueues.d.ts +5 -0
- package/dist/native/utils/fetchData/eventQueues.d.ts.map +1 -0
- package/dist/native/utils/fetchData/eventQueues.js +52 -0
- package/dist/native/utils/fetchData/fetchCalls.d.ts +9 -0
- package/dist/native/utils/fetchData/fetchCalls.d.ts.map +1 -0
- package/dist/native/utils/fetchData/fetchCalls.js +88 -0
- package/dist/native/utils/fetchData/initialFetch.d.ts +3 -0
- package/dist/native/utils/fetchData/initialFetch.d.ts.map +1 -0
- package/dist/native/utils/fetchData/initialFetch.js +21 -0
- package/dist/native/utils/fetchData/receiveData.d.ts +3 -0
- package/dist/native/utils/fetchData/receiveData.d.ts.map +1 -0
- package/dist/native/utils/fetchData/receiveData.js +39 -0
- package/dist/native/utils/query/index.d.ts +73 -0
- package/dist/native/utils/query/index.d.ts.map +1 -0
- package/dist/native/utils/query/index.js +139 -0
- package/dist/native/utils/schema/wipeTables.d.ts +98 -0
- package/dist/native/utils/schema/wipeTables.d.ts.map +1 -0
- package/dist/native/utils/schema/wipeTables.js +188 -0
- package/dist/native/utils/sync/pullFromRemote/fetchOlder.d.ts +44 -0
- package/dist/native/utils/sync/pullFromRemote/fetchOlder.d.ts.map +1 -0
- package/dist/native/utils/sync/pullFromRemote/fetchOlder.js +55 -0
- package/dist/native/utils/sync/pullFromRemote/fetchOlderHelpers.d.ts +33 -0
- package/dist/native/utils/sync/pullFromRemote/fetchOlderHelpers.d.ts.map +1 -0
- package/dist/native/utils/sync/pullFromRemote/fetchOlderHelpers.js +104 -0
- package/dist/native/utils/sync/pullFromRemote/index.d.ts +5 -0
- package/dist/native/utils/sync/pullFromRemote/index.d.ts.map +1 -0
- package/dist/native/utils/sync/pullFromRemote/index.js +73 -0
- package/dist/native/utils/sync/pullFromRemote/pullData.d.ts +21 -0
- package/dist/native/utils/sync/pullFromRemote/pullData.d.ts.map +1 -0
- package/dist/native/utils/sync/pullFromRemote/pullData.js +80 -0
- package/dist/native/utils/sync/pullFromRemote/updateLocalDb.d.ts +46 -0
- package/dist/native/utils/sync/pullFromRemote/updateLocalDb.d.ts.map +1 -0
- package/dist/{utils → native/utils}/sync/pullFromRemote/updateLocalDb.js +120 -47
- package/dist/native/utils/sync/pushLocal/index.d.ts +5 -0
- package/dist/native/utils/sync/pushLocal/index.d.ts.map +1 -0
- package/dist/native/utils/sync/pushLocal/index.js +101 -0
- package/dist/native/utils/sync/pushLocal/sendUnsyncedToSupabase.d.ts +6 -0
- package/dist/native/utils/sync/pushLocal/sendUnsyncedToSupabase.d.ts.map +1 -0
- package/dist/native/utils/sync/pushLocal/sendUnsyncedToSupabase.js +57 -0
- package/dist/native/utils/sync/pushLocal/uploadChunk.d.ts +8 -0
- package/dist/native/utils/sync/pushLocal/uploadChunk.d.ts.map +1 -0
- package/dist/native/utils/sync/pushLocal/uploadChunk.js +173 -0
- package/dist/native/utils/sync/pushLocal/uploadHelpers.d.ts +41 -0
- package/dist/native/utils/sync/pushLocal/uploadHelpers.d.ts.map +1 -0
- package/dist/native/utils/sync/pushLocal/uploadHelpers.js +243 -0
- package/dist/native/utils/sync/status/filterKey.d.ts +15 -0
- package/dist/native/utils/sync/status/filterKey.d.ts.map +1 -0
- package/dist/{utils → native/utils}/sync/status/filterKey.js +0 -14
- package/dist/native/utils/sync/status/repo.d.ts +10 -0
- package/dist/native/utils/sync/status/repo.d.ts.map +1 -0
- package/dist/native/utils/sync/status/repo.js +97 -0
- package/dist/native/utils/sync/status/services.d.ts +31 -0
- package/dist/native/utils/sync/status/services.d.ts.map +1 -0
- package/dist/native/utils/sync/status/services.js +107 -0
- package/dist/native/utils/sync/status/syncStatus.d.ts +109 -0
- package/dist/native/utils/sync/status/syncStatus.d.ts.map +1 -0
- package/dist/native/utils/sync/status/syncStatus.js +161 -0
- package/dist/shared/constants/syncDefaults.d.ts.map +1 -0
- package/dist/{core → shared/core}/config/index.d.ts +2 -0
- package/dist/shared/core/config/index.d.ts.map +1 -0
- package/dist/{core → shared/core}/config/index.js +4 -0
- package/dist/shared/core/platform/appState.d.ts +12 -0
- package/dist/shared/core/platform/appState.d.ts.map +1 -0
- package/dist/shared/core/platform/appState.js +11 -0
- package/dist/shared/db/adapters/expo_sqlite.d.ts +3 -0
- package/dist/shared/db/adapters/expo_sqlite.d.ts.map +1 -0
- package/dist/shared/db/adapters/expo_sqlite.js +72 -0
- package/dist/shared/db/adapters/rn_nitro.d.ts +3 -0
- package/dist/shared/db/adapters/rn_nitro.d.ts.map +1 -0
- package/dist/shared/db/adapters/rn_nitro.js +111 -0
- package/dist/shared/db/adapters/rn_sqlite_storage.d.ts +3 -0
- package/dist/shared/db/adapters/rn_sqlite_storage.d.ts.map +1 -0
- package/dist/{db → shared/db}/adapters/rn_sqlite_storage.js +41 -0
- package/dist/shared/db/adapters/tauri.d.ts +3 -0
- package/dist/shared/db/adapters/tauri.d.ts.map +1 -0
- package/dist/shared/db/adapters/tauri.js +100 -0
- package/dist/shared/db/dbErrorMsg.d.ts.map +1 -0
- package/dist/{db → shared/db}/dbErrorMsg.js +7 -0
- package/dist/{db → shared/db}/dbInitializer.d.ts +1 -1
- package/dist/shared/db/dbInitializer.d.ts.map +1 -0
- package/dist/{db → shared/db}/dbInitializer.js +28 -15
- package/dist/shared/db/normalizer.d.ts +6 -0
- package/dist/shared/db/normalizer.d.ts.map +1 -0
- package/dist/shared/db/normalizer.js +26 -0
- package/dist/{hooks → shared/hooks}/supastashFilters/index.d.ts +1 -1
- package/dist/shared/hooks/supastashFilters/index.d.ts.map +1 -0
- package/dist/{hooks → shared/hooks}/syncStatus/index.d.ts +1 -1
- package/dist/shared/hooks/syncStatus/index.d.ts.map +1 -0
- package/dist/shared/store/localCache.d.ts.map +1 -0
- package/dist/shared/store/sharedDb.d.ts +6 -0
- package/dist/shared/store/sharedDb.d.ts.map +1 -0
- package/dist/shared/store/sharedDb.js +17 -0
- package/dist/shared/store/syncCalls.d.ts.map +1 -0
- package/dist/{store → shared/store}/syncStatus.d.ts +1 -1
- package/dist/shared/store/syncStatus.d.ts.map +1 -0
- package/dist/shared/store/tableFilters.d.ts.map +1 -0
- package/dist/shared/store/tableSchemaData.d.ts.map +1 -0
- package/dist/shared/store/tx.d.ts.map +1 -0
- package/dist/shared/types/adapters.types.d.ts +8 -0
- package/dist/shared/types/index.d.ts.map +1 -0
- package/dist/{types → shared/types}/supastashConfig.types.d.ts +180 -2
- package/dist/shared/utils/connection.d.ts.map +1 -0
- package/dist/{utils → shared/utils}/connection.js +6 -6
- package/dist/shared/utils/errorHandler.d.ts.map +1 -0
- package/dist/shared/utils/events/eventBus.d.ts.map +1 -0
- package/dist/shared/utils/fetchData/addPayloadToUI.d.ts.map +1 -0
- package/dist/shared/utils/fetchData/createTable.d.ts.map +1 -0
- package/dist/shared/utils/fetchData/dataState.d.ts.map +1 -0
- package/dist/{hooks/supastashData → shared/utils/fetchData}/dataState.js +1 -1
- package/dist/shared/utils/fetchData/deleteData.d.ts.map +1 -0
- package/dist/{utils → shared/utils}/fetchData/deleteData.js +2 -2
- package/dist/shared/utils/fetchData/fetchLocalData.d.ts.map +1 -0
- package/dist/shared/utils/fetchData/getKeyType.d.ts.map +1 -0
- package/dist/shared/utils/fetchData/liteHelpers.d.ts.map +1 -0
- package/dist/shared/utils/fetchData/realTimeCall.d.ts.map +1 -0
- package/dist/shared/utils/fetchData/realTimeManager.d.ts.map +1 -0
- package/dist/shared/utils/fetchData/registerSub.d.ts.map +1 -0
- package/dist/{hooks/supastashData → shared/utils/fetchData}/registerSub.js +1 -1
- package/dist/shared/utils/fetchData/setDataInBatches.d.ts.map +1 -0
- package/dist/shared/utils/fetchData/snapShot.d.ts.map +1 -0
- package/dist/shared/utils/fetchData/validatePayload.d.ts.map +1 -0
- package/dist/shared/utils/genUUID.d.ts.map +1 -0
- package/dist/shared/utils/getSafeValues.d.ts.map +1 -0
- package/dist/shared/utils/getTableSchema.d.ts.map +1 -0
- package/dist/{utils → shared/utils}/logs.d.ts +1 -0
- package/dist/shared/utils/logs.d.ts.map +1 -0
- package/dist/{utils → shared/utils}/logs.js +6 -1
- package/dist/shared/utils/query/builder/crud.d.ts.map +1 -0
- package/dist/shared/utils/query/builder/filters.d.ts.map +1 -0
- package/dist/{utils → shared/utils}/query/builder/filters.js +1 -1
- package/dist/shared/utils/query/builder/index.d.ts.map +1 -0
- package/dist/shared/utils/query/builder/mainQuery.d.ts.map +1 -0
- package/dist/shared/utils/query/helpers/localDb/getLocalMethod.d.ts.map +1 -0
- package/dist/shared/utils/query/helpers/localDb/insertMany.d.ts.map +1 -0
- package/dist/shared/utils/query/helpers/localDb/localQueryBuilder.d.ts.map +1 -0
- package/dist/shared/utils/query/helpers/localDb/upsertMany.d.ts.map +1 -0
- package/dist/shared/utils/query/helpers/mainQueryHelpers.d.ts.map +1 -0
- package/dist/{utils → shared/utils}/query/helpers/mainQueryHelpers.js +1 -1
- package/dist/shared/utils/query/helpers/queryValidator.d.ts.map +1 -0
- package/dist/shared/utils/query/helpers/queueRemote.d.ts.map +1 -0
- package/dist/{utils → shared/utils}/query/helpers/queueRemote.js +4 -4
- package/dist/shared/utils/query/helpers/remoteDb/queryFilterBuilder.d.ts.map +1 -0
- package/dist/shared/utils/query/helpers/remoteDb/queryUtils.d.ts.map +1 -0
- package/dist/shared/utils/query/localDbQuery/delete.d.ts.map +1 -0
- package/dist/shared/utils/query/localDbQuery/index.d.ts.map +1 -0
- package/dist/shared/utils/query/localDbQuery/insert.d.ts.map +1 -0
- package/dist/shared/utils/query/localDbQuery/select.d.ts.map +1 -0
- package/dist/shared/utils/query/localDbQuery/update.d.ts.map +1 -0
- package/dist/{utils → shared/utils}/query/localDbQuery/update.js +2 -2
- package/dist/shared/utils/query/localDbQuery/upsert.d.ts.map +1 -0
- package/dist/shared/utils/query/remoteQuery/supabaseQuery.d.ts.map +1 -0
- package/dist/{utils → shared/utils}/query/remoteQuery/supabaseQuery.js +1 -1
- package/dist/shared/utils/refreshScreenCalls.d.ts.map +1 -0
- package/dist/shared/utils/reusedHelpers.d.ts.map +1 -0
- package/dist/shared/utils/schema/createSyncStatus.d.ts.map +1 -0
- package/dist/shared/utils/serializer.d.ts.map +1 -0
- package/dist/shared/utils/supabaseClientErr.d.ts.map +1 -0
- package/dist/shared/utils/supastashMode.d.ts.map +1 -0
- package/dist/shared/utils/sync/getAllTables.d.ts.map +1 -0
- package/dist/{utils → shared/utils}/sync/getAllTables.js +1 -1
- package/dist/shared/utils/sync/pullFromRemote/getLastCreatedInfo.d.ts.map +1 -0
- package/dist/shared/utils/sync/pullFromRemote/getLastDeletedInfo.d.ts.map +1 -0
- package/dist/shared/utils/sync/pullFromRemote/getLastPulledInfo.d.ts.map +1 -0
- package/dist/shared/utils/sync/pullFromRemote/helpers.d.ts.map +1 -0
- package/dist/shared/utils/sync/pullFromRemote/runLimitedConcurrency.d.ts.map +1 -0
- package/dist/{utils → shared/utils}/sync/pullFromRemote/runLimitedConcurrency.js +1 -1
- package/dist/shared/utils/sync/pullFromRemote/stringifyFields.d.ts.map +1 -0
- package/dist/shared/utils/sync/pullFromRemote/updateFilter.d.ts.map +1 -0
- package/dist/shared/utils/sync/pullFromRemote/validateFilters.d.ts.map +1 -0
- package/dist/shared/utils/sync/pushLocal/deleteChunks.d.ts.map +1 -0
- package/dist/shared/utils/sync/pushLocal/getAllUnsyncedData.d.ts.map +1 -0
- package/dist/{utils → shared/utils}/sync/pushLocal/getAllUnsyncedData.js +2 -2
- package/dist/shared/utils/sync/pushLocal/normalize.d.ts.map +1 -0
- package/dist/shared/utils/sync/pushLocal/parseFields.d.ts.map +1 -0
- package/dist/{utils → shared/utils}/sync/queryStatus.d.ts +1 -1
- package/dist/shared/utils/sync/queryStatus.d.ts.map +1 -0
- package/dist/shared/utils/sync/refreshTables.d.ts.map +1 -0
- package/dist/shared/utils/sync/registration/syncCalls.d.ts.map +1 -0
- package/dist/{utils → shared/utils}/sync/registration/syncCalls.js +1 -1
- package/dist/shared/utils/sync/status/remoteSchema.d.ts.map +1 -0
- package/dist/shared/utils/sync/status/syncUpdate.d.ts.map +1 -0
- package/dist/shared/utils/tableValidator.d.ts.map +1 -0
- package/package.json +28 -11
- package/dist/constants/syncDefaults.d.ts.map +0 -1
- package/dist/core/config/index.d.ts.map +0 -1
- package/dist/core/schemaManager/index.d.ts.map +0 -1
- package/dist/db/adapters/expo_sqlite.d.ts +0 -3
- package/dist/db/adapters/expo_sqlite.d.ts.map +0 -1
- package/dist/db/adapters/expo_sqlite.js +0 -35
- package/dist/db/adapters/rn_nitro.d.ts +0 -3
- package/dist/db/adapters/rn_nitro.d.ts.map +0 -1
- package/dist/db/adapters/rn_nitro.js +0 -54
- package/dist/db/adapters/rn_sqlite_storage.d.ts +0 -3
- package/dist/db/adapters/rn_sqlite_storage.d.ts.map +0 -1
- package/dist/db/dbErrorMsg.d.ts.map +0 -1
- package/dist/db/dbInitializer.d.ts.map +0 -1
- package/dist/hooks/supastashData/addPayloadToUI.d.ts.map +0 -1
- package/dist/hooks/supastashData/dataState.d.ts.map +0 -1
- package/dist/hooks/supastashData/eventQueues.d.ts.map +0 -1
- package/dist/hooks/supastashData/fetchCalls.d.ts.map +0 -1
- package/dist/hooks/supastashData/index.d.ts.map +0 -1
- package/dist/hooks/supastashData/realtimeSubscription.d.ts +0 -5
- package/dist/hooks/supastashData/realtimeSubscription.d.ts.map +0 -1
- package/dist/hooks/supastashData/realtimeSubscription.js +0 -96
- package/dist/hooks/supastashData/registerSub.d.ts.map +0 -1
- package/dist/hooks/supastashFilters/index.d.ts.map +0 -1
- package/dist/hooks/supastashLiteQuery/fetchCalls.d.ts +0 -1
- package/dist/hooks/supastashLiteQuery/fetchCalls.d.ts.map +0 -1
- package/dist/hooks/supastashLiteQuery/fetchCalls.js +0 -122
- package/dist/hooks/supastashLiteQuery/index.d.ts +0 -53
- package/dist/hooks/supastashLiteQuery/index.d.ts.map +0 -1
- package/dist/hooks/supastashLiteQuery/index.js +0 -127
- package/dist/hooks/supastashLiteQuery/loadCacheOnMount.d.ts +0 -1
- package/dist/hooks/supastashLiteQuery/loadCacheOnMount.d.ts.map +0 -1
- package/dist/hooks/supastashLiteQuery/loadCacheOnMount.js +0 -1
- package/dist/hooks/supastashLogic.d.ts.map +0 -1
- package/dist/hooks/syncEngine/index.d.ts.map +0 -1
- package/dist/hooks/syncEngine/pullFromRemote/index.d.ts.map +0 -1
- package/dist/hooks/syncEngine/pushLocal/index.d.ts.map +0 -1
- package/dist/hooks/syncStatus/index.d.ts.map +0 -1
- package/dist/store/localCache.d.ts.map +0 -1
- package/dist/store/syncCalls.d.ts.map +0 -1
- package/dist/store/syncStatus.d.ts.map +0 -1
- package/dist/store/tableFilters.d.ts.map +0 -1
- package/dist/store/tableSchemaData.d.ts.map +0 -1
- package/dist/store/tx.d.ts.map +0 -1
- package/dist/types/index.d.ts.map +0 -1
- package/dist/utils/connection.d.ts.map +0 -1
- package/dist/utils/createIndexes.d.ts +0 -9
- package/dist/utils/createIndexes.d.ts.map +0 -1
- package/dist/utils/createIndexes.js +0 -74
- package/dist/utils/errorHandler.d.ts.map +0 -1
- package/dist/utils/events/eventBus.d.ts.map +0 -1
- package/dist/utils/fetchData/buildFilter.d.ts +0 -8
- package/dist/utils/fetchData/buildFilter.d.ts.map +0 -1
- package/dist/utils/fetchData/buildFilter.js +0 -58
- package/dist/utils/fetchData/createTable.d.ts.map +0 -1
- package/dist/utils/fetchData/deleteData.d.ts.map +0 -1
- package/dist/utils/fetchData/fetchLocalData.d.ts.map +0 -1
- package/dist/utils/fetchData/getKeyType.d.ts.map +0 -1
- package/dist/utils/fetchData/initialFetch.d.ts.map +0 -1
- package/dist/utils/fetchData/liteHelpers.d.ts.map +0 -1
- package/dist/utils/fetchData/liteReducer.d.ts +0 -3
- package/dist/utils/fetchData/liteReducer.d.ts.map +0 -1
- package/dist/utils/fetchData/liteReducer.js +0 -103
- package/dist/utils/fetchData/realTimeCall.d.ts.map +0 -1
- package/dist/utils/fetchData/realTimeManager.d.ts.map +0 -1
- package/dist/utils/fetchData/receiveData.d.ts.map +0 -1
- package/dist/utils/fetchData/setDataInBatches.d.ts.map +0 -1
- package/dist/utils/fetchData/snapShot.d.ts.map +0 -1
- package/dist/utils/fetchData/validatePayload.d.ts.map +0 -1
- package/dist/utils/genUUID.d.ts.map +0 -1
- package/dist/utils/getSafeValues.d.ts.map +0 -1
- package/dist/utils/getTableSchema.d.ts.map +0 -1
- package/dist/utils/logs.d.ts.map +0 -1
- package/dist/utils/query/builder/crud.d.ts.map +0 -1
- package/dist/utils/query/builder/filters.d.ts.map +0 -1
- package/dist/utils/query/builder/index.d.ts.map +0 -1
- package/dist/utils/query/builder/mainQuery.d.ts.map +0 -1
- package/dist/utils/query/helpers/localDb/getLocalMethod.d.ts.map +0 -1
- package/dist/utils/query/helpers/localDb/insertMany.d.ts.map +0 -1
- package/dist/utils/query/helpers/localDb/localQueryBuilder.d.ts.map +0 -1
- package/dist/utils/query/helpers/localDb/upsertMany.d.ts.map +0 -1
- package/dist/utils/query/helpers/mainQueryHelpers.d.ts.map +0 -1
- package/dist/utils/query/helpers/queryValidator.d.ts.map +0 -1
- package/dist/utils/query/helpers/queueRemote.d.ts.map +0 -1
- package/dist/utils/query/helpers/remoteDb/queryFilterBuilder.d.ts.map +0 -1
- package/dist/utils/query/helpers/remoteDb/queryUtils.d.ts.map +0 -1
- package/dist/utils/query/localDbQuery/delete.d.ts.map +0 -1
- package/dist/utils/query/localDbQuery/index.d.ts.map +0 -1
- package/dist/utils/query/localDbQuery/insert.d.ts.map +0 -1
- package/dist/utils/query/localDbQuery/select.d.ts.map +0 -1
- package/dist/utils/query/localDbQuery/update.d.ts.map +0 -1
- package/dist/utils/query/localDbQuery/upsert.d.ts.map +0 -1
- package/dist/utils/query/remoteQuery/supabaseQuery.d.ts.map +0 -1
- package/dist/utils/refreshScreenCalls.d.ts.map +0 -1
- package/dist/utils/reusedHelpers.d.ts.map +0 -1
- package/dist/utils/schema/createSyncStatus.d.ts.map +0 -1
- package/dist/utils/schema/wipeTables.d.ts.map +0 -1
- package/dist/utils/serializer.d.ts.map +0 -1
- package/dist/utils/supabaseClientErr.d.ts.map +0 -1
- package/dist/utils/supastashMode.d.ts.map +0 -1
- package/dist/utils/sync/getAllTables.d.ts.map +0 -1
- package/dist/utils/sync/pullFromRemote/fetchOlder.d.ts.map +0 -1
- package/dist/utils/sync/pullFromRemote/fetchOlderHelpers.d.ts.map +0 -1
- package/dist/utils/sync/pullFromRemote/getLastCreatedInfo.d.ts.map +0 -1
- package/dist/utils/sync/pullFromRemote/getLastDeletedInfo.d.ts.map +0 -1
- package/dist/utils/sync/pullFromRemote/getLastPulledInfo.d.ts.map +0 -1
- package/dist/utils/sync/pullFromRemote/helpers.d.ts.map +0 -1
- package/dist/utils/sync/pullFromRemote/pullData.d.ts.map +0 -1
- package/dist/utils/sync/pullFromRemote/pullDeletedData.d.ts +0 -15
- package/dist/utils/sync/pullFromRemote/pullDeletedData.d.ts.map +0 -1
- package/dist/utils/sync/pullFromRemote/pullDeletedData.js +0 -51
- package/dist/utils/sync/pullFromRemote/runLimitedConcurrency.d.ts.map +0 -1
- package/dist/utils/sync/pullFromRemote/stringifyFields.d.ts.map +0 -1
- package/dist/utils/sync/pullFromRemote/updateFilter.d.ts.map +0 -1
- package/dist/utils/sync/pullFromRemote/updateLocalDb.d.ts +0 -15
- package/dist/utils/sync/pullFromRemote/updateLocalDb.d.ts.map +0 -1
- package/dist/utils/sync/pullFromRemote/validateFilters.d.ts.map +0 -1
- package/dist/utils/sync/pushLocal/deleteChunks.d.ts.map +0 -1
- package/dist/utils/sync/pushLocal/getAllUnsyncedData.d.ts.map +0 -1
- package/dist/utils/sync/pushLocal/normalize.d.ts.map +0 -1
- package/dist/utils/sync/pushLocal/parseFields.d.ts.map +0 -1
- package/dist/utils/sync/pushLocal/sendUnsyncedToSupabase.d.ts.map +0 -1
- package/dist/utils/sync/pushLocal/uploadChunk.d.ts.map +0 -1
- package/dist/utils/sync/pushLocal/uploadHelpers.d.ts.map +0 -1
- package/dist/utils/sync/queryStatus.d.ts.map +0 -1
- package/dist/utils/sync/refreshTables.d.ts.map +0 -1
- package/dist/utils/sync/registration/syncCalls.d.ts.map +0 -1
- package/dist/utils/sync/status/filterKey.d.ts.map +0 -1
- package/dist/utils/sync/status/remoteSchema.d.ts.map +0 -1
- package/dist/utils/sync/status/repo.d.ts.map +0 -1
- package/dist/utils/sync/status/services.d.ts.map +0 -1
- package/dist/utils/sync/status/syncStatus.d.ts.map +0 -1
- package/dist/utils/sync/status/syncUpdate.d.ts.map +0 -1
- package/dist/utils/syncStatus.d.ts +0 -69
- package/dist/utils/syncStatus.d.ts.map +0 -1
- package/dist/utils/syncStatus.js +0 -129
- package/dist/utils/syncUpdate.d.ts +0 -7
- package/dist/utils/syncUpdate.d.ts.map +0 -1
- package/dist/utils/syncUpdate.js +0 -18
- package/dist/utils/tableValidator.d.ts.map +0 -1
- package/dist/utils/toggleSupastashMode.d.ts +0 -28
- package/dist/utils/toggleSupastashMode.d.ts.map +0 -1
- package/dist/utils/toggleSupastashMode.js +0 -46
- /package/dist/{utils → desktop/utils}/schema/wipeTables.d.ts +0 -0
- /package/dist/{hooks/syncEngine → desktop/utils/sync}/pullFromRemote/index.d.ts +0 -0
- /package/dist/{hooks/syncEngine → desktop/utils/sync}/pushLocal/index.d.ts +0 -0
- /package/dist/{utils → desktop/utils}/sync/pushLocal/sendUnsyncedToSupabase.d.ts +0 -0
- /package/dist/{constants → shared/constants}/syncDefaults.d.ts +0 -0
- /package/dist/{constants → shared/constants}/syncDefaults.js +0 -0
- /package/dist/{db → shared/db}/dbErrorMsg.d.ts +0 -0
- /package/dist/{hooks → shared/hooks}/supastashFilters/index.js +0 -0
- /package/dist/{hooks → shared/hooks}/syncStatus/index.js +0 -0
- /package/dist/{store → shared/store}/localCache.d.ts +0 -0
- /package/dist/{store → shared/store}/localCache.js +0 -0
- /package/dist/{store → shared/store}/syncCalls.d.ts +0 -0
- /package/dist/{store → shared/store}/syncCalls.js +0 -0
- /package/dist/{store → shared/store}/syncStatus.js +0 -0
- /package/dist/{store → shared/store}/tableFilters.d.ts +0 -0
- /package/dist/{store → shared/store}/tableFilters.js +0 -0
- /package/dist/{store → shared/store}/tableSchemaData.d.ts +0 -0
- /package/dist/{store → shared/store}/tableSchemaData.js +0 -0
- /package/dist/{store → shared/store}/tx.d.ts +0 -0
- /package/dist/{store → shared/store}/tx.js +0 -0
- /package/dist/{types → shared/types}/expoSqlite.types.d.ts +0 -0
- /package/dist/{types → shared/types}/index.d.ts +0 -0
- /package/dist/{types → shared/types}/index.js +0 -0
- /package/dist/{types → shared/types}/liteQuery.types.d.ts +0 -0
- /package/dist/{types → shared/types}/query.types.d.ts +0 -0
- /package/dist/{types → shared/types}/realtimeData.types.d.ts +0 -0
- /package/dist/{types → shared/types}/rnNitroSqlite.types.d.ts +0 -0
- /package/dist/{types → shared/types}/rnSqliteStorage.types.d.ts +0 -0
- /package/dist/{types → shared/types}/schemaManager.types.d.ts +0 -0
- /package/dist/{types → shared/types}/syncEngine.types.d.ts +0 -0
- /package/dist/{utils → shared/utils}/connection.d.ts +0 -0
- /package/dist/{utils → shared/utils}/errorHandler.d.ts +0 -0
- /package/dist/{utils → shared/utils}/errorHandler.js +0 -0
- /package/dist/{utils → shared/utils}/events/eventBus.d.ts +0 -0
- /package/dist/{utils → shared/utils}/events/eventBus.js +0 -0
- /package/dist/{hooks/supastashData → shared/utils/fetchData}/addPayloadToUI.d.ts +0 -0
- /package/dist/{hooks/supastashData → shared/utils/fetchData}/addPayloadToUI.js +0 -0
- /package/dist/{utils → shared/utils}/fetchData/createTable.d.ts +0 -0
- /package/dist/{utils → shared/utils}/fetchData/createTable.js +0 -0
- /package/dist/{hooks/supastashData → shared/utils/fetchData}/dataState.d.ts +0 -0
- /package/dist/{utils → shared/utils}/fetchData/deleteData.d.ts +0 -0
- /package/dist/{utils → shared/utils}/fetchData/fetchLocalData.d.ts +0 -0
- /package/dist/{utils → shared/utils}/fetchData/fetchLocalData.js +0 -0
- /package/dist/{utils → shared/utils}/fetchData/getKeyType.d.ts +0 -0
- /package/dist/{utils → shared/utils}/fetchData/getKeyType.js +0 -0
- /package/dist/{utils → shared/utils}/fetchData/liteHelpers.d.ts +0 -0
- /package/dist/{utils → shared/utils}/fetchData/liteHelpers.js +0 -0
- /package/dist/{utils → shared/utils}/fetchData/realTimeCall.d.ts +0 -0
- /package/dist/{utils → shared/utils}/fetchData/realTimeCall.js +0 -0
- /package/dist/{utils → shared/utils}/fetchData/realTimeManager.d.ts +0 -0
- /package/dist/{utils → shared/utils}/fetchData/realTimeManager.js +0 -0
- /package/dist/{hooks/supastashData → shared/utils/fetchData}/registerSub.d.ts +0 -0
- /package/dist/{utils → shared/utils}/fetchData/setDataInBatches.d.ts +0 -0
- /package/dist/{utils → shared/utils}/fetchData/setDataInBatches.js +0 -0
- /package/dist/{utils → shared/utils}/fetchData/snapShot.d.ts +0 -0
- /package/dist/{utils → shared/utils}/fetchData/snapShot.js +0 -0
- /package/dist/{utils → shared/utils}/fetchData/validatePayload.d.ts +0 -0
- /package/dist/{utils → shared/utils}/fetchData/validatePayload.js +0 -0
- /package/dist/{utils → shared/utils}/genUUID.d.ts +0 -0
- /package/dist/{utils → shared/utils}/genUUID.js +0 -0
- /package/dist/{utils → shared/utils}/getSafeValues.d.ts +0 -0
- /package/dist/{utils → shared/utils}/getSafeValues.js +0 -0
- /package/dist/{utils → shared/utils}/getTableSchema.d.ts +0 -0
- /package/dist/{utils → shared/utils}/getTableSchema.js +0 -0
- /package/dist/{utils → shared/utils}/query/builder/crud.d.ts +0 -0
- /package/dist/{utils → shared/utils}/query/builder/crud.js +0 -0
- /package/dist/{utils → shared/utils}/query/builder/filters.d.ts +0 -0
- /package/dist/{utils → shared/utils}/query/builder/index.d.ts +0 -0
- /package/dist/{utils → shared/utils}/query/builder/index.js +0 -0
- /package/dist/{utils → shared/utils}/query/builder/mainQuery.d.ts +0 -0
- /package/dist/{utils → shared/utils}/query/builder/mainQuery.js +0 -0
- /package/dist/{utils → shared/utils}/query/helpers/localDb/getLocalMethod.d.ts +0 -0
- /package/dist/{utils → shared/utils}/query/helpers/localDb/getLocalMethod.js +0 -0
- /package/dist/{utils → shared/utils}/query/helpers/localDb/insertMany.d.ts +0 -0
- /package/dist/{utils → shared/utils}/query/helpers/localDb/insertMany.js +0 -0
- /package/dist/{utils → shared/utils}/query/helpers/localDb/localQueryBuilder.d.ts +0 -0
- /package/dist/{utils → shared/utils}/query/helpers/localDb/localQueryBuilder.js +0 -0
- /package/dist/{utils → shared/utils}/query/helpers/localDb/upsertMany.d.ts +0 -0
- /package/dist/{utils → shared/utils}/query/helpers/localDb/upsertMany.js +0 -0
- /package/dist/{utils → shared/utils}/query/helpers/mainQueryHelpers.d.ts +0 -0
- /package/dist/{utils → shared/utils}/query/helpers/queryValidator.d.ts +0 -0
- /package/dist/{utils → shared/utils}/query/helpers/queryValidator.js +0 -0
- /package/dist/{utils → shared/utils}/query/helpers/queueRemote.d.ts +0 -0
- /package/dist/{utils → shared/utils}/query/helpers/remoteDb/queryFilterBuilder.d.ts +0 -0
- /package/dist/{utils → shared/utils}/query/helpers/remoteDb/queryFilterBuilder.js +0 -0
- /package/dist/{utils → shared/utils}/query/helpers/remoteDb/queryUtils.d.ts +0 -0
- /package/dist/{utils → shared/utils}/query/helpers/remoteDb/queryUtils.js +0 -0
- /package/dist/{utils → shared/utils}/query/localDbQuery/delete.d.ts +0 -0
- /package/dist/{utils → shared/utils}/query/localDbQuery/delete.js +0 -0
- /package/dist/{utils → shared/utils}/query/localDbQuery/index.d.ts +0 -0
- /package/dist/{utils → shared/utils}/query/localDbQuery/index.js +0 -0
- /package/dist/{utils → shared/utils}/query/localDbQuery/insert.d.ts +0 -0
- /package/dist/{utils → shared/utils}/query/localDbQuery/insert.js +0 -0
- /package/dist/{utils → shared/utils}/query/localDbQuery/select.d.ts +0 -0
- /package/dist/{utils → shared/utils}/query/localDbQuery/select.js +0 -0
- /package/dist/{utils → shared/utils}/query/localDbQuery/update.d.ts +0 -0
- /package/dist/{utils → shared/utils}/query/localDbQuery/upsert.d.ts +0 -0
- /package/dist/{utils → shared/utils}/query/localDbQuery/upsert.js +0 -0
- /package/dist/{utils → shared/utils}/query/remoteQuery/supabaseQuery.d.ts +0 -0
- /package/dist/{utils → shared/utils}/refreshScreenCalls.d.ts +0 -0
- /package/dist/{utils → shared/utils}/refreshScreenCalls.js +0 -0
- /package/dist/{utils → shared/utils}/reusedHelpers.d.ts +0 -0
- /package/dist/{utils → shared/utils}/reusedHelpers.js +0 -0
- /package/dist/{utils → shared/utils}/schema/createSyncStatus.d.ts +0 -0
- /package/dist/{utils → shared/utils}/schema/createSyncStatus.js +0 -0
- /package/dist/{utils → shared/utils}/serializer.d.ts +0 -0
- /package/dist/{utils → shared/utils}/serializer.js +0 -0
- /package/dist/{utils → shared/utils}/supabaseClientErr.d.ts +0 -0
- /package/dist/{utils → shared/utils}/supabaseClientErr.js +0 -0
- /package/dist/{utils → shared/utils}/supastashMode.d.ts +0 -0
- /package/dist/{utils → shared/utils}/supastashMode.js +0 -0
- /package/dist/{utils → shared/utils}/sync/getAllTables.d.ts +0 -0
- /package/dist/{utils → shared/utils}/sync/pullFromRemote/getLastCreatedInfo.d.ts +0 -0
- /package/dist/{utils → shared/utils}/sync/pullFromRemote/getLastCreatedInfo.js +0 -0
- /package/dist/{utils → shared/utils}/sync/pullFromRemote/getLastDeletedInfo.d.ts +0 -0
- /package/dist/{utils → shared/utils}/sync/pullFromRemote/getLastDeletedInfo.js +0 -0
- /package/dist/{utils → shared/utils}/sync/pullFromRemote/getLastPulledInfo.d.ts +0 -0
- /package/dist/{utils → shared/utils}/sync/pullFromRemote/getLastPulledInfo.js +0 -0
- /package/dist/{utils → shared/utils}/sync/pullFromRemote/helpers.d.ts +0 -0
- /package/dist/{utils → shared/utils}/sync/pullFromRemote/helpers.js +0 -0
- /package/dist/{utils → shared/utils}/sync/pullFromRemote/runLimitedConcurrency.d.ts +0 -0
- /package/dist/{utils → shared/utils}/sync/pullFromRemote/stringifyFields.d.ts +0 -0
- /package/dist/{utils → shared/utils}/sync/pullFromRemote/stringifyFields.js +0 -0
- /package/dist/{utils → shared/utils}/sync/pullFromRemote/updateFilter.d.ts +0 -0
- /package/dist/{utils → shared/utils}/sync/pullFromRemote/updateFilter.js +0 -0
- /package/dist/{utils → shared/utils}/sync/pullFromRemote/validateFilters.d.ts +0 -0
- /package/dist/{utils → shared/utils}/sync/pullFromRemote/validateFilters.js +0 -0
- /package/dist/{utils → shared/utils}/sync/pushLocal/deleteChunks.d.ts +0 -0
- /package/dist/{utils → shared/utils}/sync/pushLocal/deleteChunks.js +0 -0
- /package/dist/{utils → shared/utils}/sync/pushLocal/getAllUnsyncedData.d.ts +0 -0
- /package/dist/{utils → shared/utils}/sync/pushLocal/normalize.d.ts +0 -0
- /package/dist/{utils → shared/utils}/sync/pushLocal/normalize.js +0 -0
- /package/dist/{utils → shared/utils}/sync/pushLocal/parseFields.d.ts +0 -0
- /package/dist/{utils → shared/utils}/sync/pushLocal/parseFields.js +0 -0
- /package/dist/{utils → shared/utils}/sync/queryStatus.js +0 -0
- /package/dist/{utils → shared/utils}/sync/refreshTables.d.ts +0 -0
- /package/dist/{utils → shared/utils}/sync/refreshTables.js +0 -0
- /package/dist/{utils → shared/utils}/sync/registration/syncCalls.d.ts +0 -0
- /package/dist/{utils → shared/utils}/sync/status/remoteSchema.d.ts +0 -0
- /package/dist/{utils → shared/utils}/sync/status/remoteSchema.js +0 -0
- /package/dist/{utils → shared/utils}/sync/status/syncUpdate.d.ts +0 -0
- /package/dist/{utils → shared/utils}/sync/status/syncUpdate.js +0 -0
- /package/dist/{utils → shared/utils}/tableValidator.d.ts +0 -0
- /package/dist/{utils → shared/utils}/tableValidator.js +0 -0
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { getSupastashConfig } from "../../../../shared/core/config";
|
|
2
|
+
import { getSupastashDb } from "../../../../shared/db/dbInitializer";
|
|
3
|
+
import { logError } from "../../../../shared/utils/logs";
|
|
4
|
+
import { createSyncStatusTable } from "../../../../shared/utils/schema/createSyncStatus";
|
|
5
|
+
import { clearSupastashSyncStatus, getSupastashSyncStatus, resetSupastashSyncStatus, setSupastashSyncStatus, } from "./services";
|
|
6
|
+
const SYNC_STATUS_TABLE = "supastash_sync_marks";
|
|
7
|
+
const SERVER_SYNC_STATUS_TABLE = "supastash_server_sync_marks";
|
|
8
|
+
const getSyncStatusTable = () => {
|
|
9
|
+
const cfg = getSupastashConfig();
|
|
10
|
+
return cfg.replicationMode === "server-side"
|
|
11
|
+
? SERVER_SYNC_STATUS_TABLE
|
|
12
|
+
: SYNC_STATUS_TABLE;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Clears the sync log for a specific table.
|
|
16
|
+
*
|
|
17
|
+
* Removes all stored sync checkpoints (created / updated / deleted)
|
|
18
|
+
* for the given table and filter key (if any).
|
|
19
|
+
*
|
|
20
|
+
* @param tableName - Name of the table whose sync status should be cleared.
|
|
21
|
+
* @example
|
|
22
|
+
* await clearLocalSyncLog("users");
|
|
23
|
+
*/
|
|
24
|
+
export async function clearLocalSyncLog(tableName) {
|
|
25
|
+
await clearSupastashSyncStatus(tableName);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Clears the sync log for every local table.
|
|
29
|
+
*
|
|
30
|
+
* Drops the `supastash_sync_marks` table and recreates it.
|
|
31
|
+
* Use with caution — this wipes all sync history.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* await clearAllLocalSyncLog();
|
|
35
|
+
*/
|
|
36
|
+
export async function clearAllLocalSyncLog() {
|
|
37
|
+
const db = await getSupastashDb();
|
|
38
|
+
const syncStatusTable = getSyncStatusTable();
|
|
39
|
+
await db.runAsync(`DROP TABLE IF EXISTS ${syncStatusTable}`);
|
|
40
|
+
await createSyncStatusTable();
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
*
|
|
44
|
+
* Returns the stored timestamps and filter info, or `null` if
|
|
45
|
+
* there is no entry for the table.
|
|
46
|
+
* @param tableName - The name of the table to get the sync log for
|
|
47
|
+
* @example
|
|
48
|
+
* const syncLog = await getSyncLog("users");
|
|
49
|
+
* console.log(syncLog);
|
|
50
|
+
* return {
|
|
51
|
+
* table_name: "users",
|
|
52
|
+
* last_synced_at: "2021-01-01T00:00:00.000Z",
|
|
53
|
+
* last_deleted_at: "2021-01-01T00:00:00.000Z",
|
|
54
|
+
* filter_key: "1234567890",
|
|
55
|
+
* filter_json: "[...]",
|
|
56
|
+
* updated_at: "2021-01-01T00:00:00.000Z"
|
|
57
|
+
* }
|
|
58
|
+
*/
|
|
59
|
+
export async function getSyncLog(tableName) {
|
|
60
|
+
try {
|
|
61
|
+
const syncStatus = await getSupastashSyncStatus(tableName);
|
|
62
|
+
return syncStatus;
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
logError(error);
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Writes or updates the sync log for a table.
|
|
71
|
+
*
|
|
72
|
+
* Stores the latest `updated_at` and `updated_at_pk`
|
|
73
|
+
* timestamps for a table + filter combination.
|
|
74
|
+
*
|
|
75
|
+
* @param table - Table name to update.
|
|
76
|
+
* @param filters - Optional realtime filters to scope the log.
|
|
77
|
+
* @param opts - Timestamp fields to set.
|
|
78
|
+
* @example
|
|
79
|
+
* await setSyncLog("users", undefined, {
|
|
80
|
+
* lastSyncedAt: new Date().toISOString(),
|
|
81
|
+
* lastSyncedAtPk: "00000000-0000-0000-0000-000000000000",
|
|
82
|
+
* });
|
|
83
|
+
*/
|
|
84
|
+
export async function setSyncLog(table, filters, opts) {
|
|
85
|
+
try {
|
|
86
|
+
await setSupastashSyncStatus(table, filters, opts);
|
|
87
|
+
}
|
|
88
|
+
catch (e) {
|
|
89
|
+
logError(`[Supastash] setMarks(${table}) failed`, e);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Resets one or more timestamps in the sync log for a table.
|
|
94
|
+
*
|
|
95
|
+
* @param table - Table to reset.
|
|
96
|
+
* @param filters - Optional filters for a scoped reset.
|
|
97
|
+
* @param scope - Field(s) to reset: "all" (default),
|
|
98
|
+
* "last_synced_at", or "last_deleted_at".
|
|
99
|
+
* @example
|
|
100
|
+
* await resetSyncLog("users", undefined, "all");
|
|
101
|
+
*/
|
|
102
|
+
export async function resetSyncLog(table, filters, scope = "all") {
|
|
103
|
+
try {
|
|
104
|
+
await resetSupastashSyncStatus(table, filters, scope);
|
|
105
|
+
}
|
|
106
|
+
catch (e) {
|
|
107
|
+
logError(`[Supastash] resetMarks(${table}, ${scope}) failed`, e);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Deletes the sync log entry for a table (and optional filter key).
|
|
112
|
+
*
|
|
113
|
+
* @param table - Table name.
|
|
114
|
+
* @param filters - Optional filters to target a specific row.
|
|
115
|
+
* @example
|
|
116
|
+
* await clearSyncLog("users");
|
|
117
|
+
*/
|
|
118
|
+
export async function clearSyncLog(table, filters) {
|
|
119
|
+
try {
|
|
120
|
+
await clearSupastashSyncStatus(table, filters);
|
|
121
|
+
}
|
|
122
|
+
catch (e) {
|
|
123
|
+
logError(`[Supastash] clearMarks(${table}) failed`, e);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
/** ------------------- DEPRECATED 🗑 Local Sync & Delete Log ------------------- */
|
|
127
|
+
/**
|
|
128
|
+
* @deprecated Use `setSyncLog` instead.
|
|
129
|
+
* Sets the sync timestamp for a given table.
|
|
130
|
+
*/
|
|
131
|
+
export async function setLocalSyncLog(tableName, lastSyncedAt, lastCreatedAt) {
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* @deprecated Use `clearSyncLog` instead.
|
|
136
|
+
* Clears the delete log for a given table.
|
|
137
|
+
*/
|
|
138
|
+
export async function clearLocalDeleteLog(tableName) {
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* @deprecated Use `clearSyncLog` instead.
|
|
143
|
+
* Clears the delete status for all local tables.
|
|
144
|
+
*/
|
|
145
|
+
export async function clearAllLocalDeleteLog() {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* @deprecated Use `getSyncLog` instead.
|
|
150
|
+
* Gets the delete log for a given table.
|
|
151
|
+
*/
|
|
152
|
+
export async function getLocalDeleteLog(tableName) {
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* @deprecated Use `setSyncLog` instead.
|
|
157
|
+
* Sets the delete log for a given table.
|
|
158
|
+
*/
|
|
159
|
+
export async function setLocalDeleteLog(tableName, lastDeletedAt) {
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"syncDefaults.d.ts","sourceRoot":"","sources":["../../../src/shared/constants/syncDefaults.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,mBAAmB,EACpB,MAAM,gCAAgC,CAAC;AAExC,eAAO,MAAM,cAAc,EAAE,mBAU5B,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,gBAO5B,CAAC;AAEF,eAAO,MAAM,kBAAkB,MAAM,CAAC"}
|
|
@@ -19,6 +19,7 @@ import { SupastashConfig, SupastashSQLiteClientTypes } from "../../types/supasta
|
|
|
19
19
|
* supabaseClient: supabase,
|
|
20
20
|
* sqliteClient: { openDatabaseAsync },
|
|
21
21
|
* sqliteClientType: "expo",
|
|
22
|
+
* platform: "native",
|
|
22
23
|
* onSchemaInit: () => {
|
|
23
24
|
* defineLocalSchema("users", {
|
|
24
25
|
* id: "TEXT PRIMARY KEY",
|
|
@@ -35,6 +36,7 @@ import { SupastashConfig, SupastashSQLiteClientTypes } from "../../types/supasta
|
|
|
35
36
|
* @param config.supabaseClient - Supabase client instance (**required**)
|
|
36
37
|
* @param config.sqliteClient - SQLite client adapter (**required**)
|
|
37
38
|
* @param config.sqliteClientType - SQLite engine: `"expo" | "rn-storage" | "rn-nitro"` (**required**)
|
|
39
|
+
* @param config.platform - Runtime platform: `"native" | "desktop"` (default: `"native"`)
|
|
38
40
|
* @param config.onSchemaInit - Optional callback to define local table schemas
|
|
39
41
|
* @param config.debugMode - Enables debug logging (default: `false`)
|
|
40
42
|
* @param config.listeners - Max number of active Realtime subscriptions (default: `250`)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/shared/core/config/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,eAAe,EACf,0BAA0B,EAC3B,MAAM,mCAAmC,CAAC;AAmC3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AAEH,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,0BAA0B,EACrE,MAAM,EAAE,eAAe,CAAC,CAAC,CAAC,GAAG;IAAE,gBAAgB,EAAE,CAAC,CAAA;CAAE,QAwCrD;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,kBAAkB,CAChC,CAAC,SAAS,0BAA0B,KACjC,eAAe,CAAC,CAAC,CAAC,CAEtB;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,qBAAqB,CACnC,CAAC,SAAS,0BAA0B,EACpC,MAAM,EAAE;IACR,SAAS,EAAE,eAAe,CAAC,CAAC,CAAC,GAAG;QAC9B,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;KAC3B,CAAC;CACH,QAEA"}
|
|
@@ -14,7 +14,9 @@ let _config = {
|
|
|
14
14
|
pull: true,
|
|
15
15
|
useFiltersFromStore: true,
|
|
16
16
|
},
|
|
17
|
+
platform: "native",
|
|
17
18
|
replicationMode: "client-side",
|
|
19
|
+
hasEnabledSimpleNullHandling: false,
|
|
18
20
|
maxSyncLookbackDays: 365,
|
|
19
21
|
perTableSyncLookbackDays: undefined,
|
|
20
22
|
fullSyncTables: [],
|
|
@@ -48,6 +50,7 @@ let _configured = false;
|
|
|
48
50
|
* supabaseClient: supabase,
|
|
49
51
|
* sqliteClient: { openDatabaseAsync },
|
|
50
52
|
* sqliteClientType: "expo",
|
|
53
|
+
* platform: "native",
|
|
51
54
|
* onSchemaInit: () => {
|
|
52
55
|
* defineLocalSchema("users", {
|
|
53
56
|
* id: "TEXT PRIMARY KEY",
|
|
@@ -64,6 +67,7 @@ let _configured = false;
|
|
|
64
67
|
* @param config.supabaseClient - Supabase client instance (**required**)
|
|
65
68
|
* @param config.sqliteClient - SQLite client adapter (**required**)
|
|
66
69
|
* @param config.sqliteClientType - SQLite engine: `"expo" | "rn-storage" | "rn-nitro"` (**required**)
|
|
70
|
+
* @param config.platform - Runtime platform: `"native" | "desktop"` (default: `"native"`)
|
|
67
71
|
* @param config.onSchemaInit - Optional callback to define local table schemas
|
|
68
72
|
* @param config.debugMode - Enables debug logging (default: `false`)
|
|
69
73
|
* @param config.listeners - Max number of active Realtime subscriptions (default: `250`)
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type AppStateStatus = "active" | "background";
|
|
2
|
+
type Callback = (state: AppStateStatus) => void;
|
|
3
|
+
export interface AppStateAdapter {
|
|
4
|
+
subscribe(cb: Callback): () => void;
|
|
5
|
+
}
|
|
6
|
+
export declare class AppStateService {
|
|
7
|
+
private adapter;
|
|
8
|
+
constructor(adapter: AppStateAdapter);
|
|
9
|
+
onActive(cb: () => void): () => void;
|
|
10
|
+
}
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=appState.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"appState.d.ts","sourceRoot":"","sources":["../../../../src/shared/core/platform/appState.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,YAAY,CAAC;AAErD,KAAK,QAAQ,GAAG,CAAC,KAAK,EAAE,cAAc,KAAK,IAAI,CAAC;AAEhD,MAAM,WAAW,eAAe;IAC9B,SAAS,CAAC,EAAE,EAAE,QAAQ,GAAG,MAAM,IAAI,CAAC;CACrC;AAED,qBAAa,eAAe;IAC1B,OAAO,CAAC,OAAO,CAAkB;gBAErB,OAAO,EAAE,eAAe;IAIpC,QAAQ,CAAC,EAAE,EAAE,MAAM,IAAI,SAVQ,IAAI;CAepC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"expo_sqlite.d.ts","sourceRoot":"","sources":["../../../../src/shared/db/adapters/expo_sqlite.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,sBAAsB,EAGvB,MAAM,mCAAmC,CAAC;AAG3C,eAAO,MAAM,iBAAiB,EAAE,sBAAsB,CAAC,gBAAgB,CA6GtE,CAAC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { namedToPositional } from "../normalizer";
|
|
2
|
+
export const SQLiteAdapterExpo = {
|
|
3
|
+
async openDatabaseAsync(name, sqliteClient) {
|
|
4
|
+
const db = await sqliteClient.openDatabaseAsync(name);
|
|
5
|
+
return {
|
|
6
|
+
runAsync: async (sql, params) => {
|
|
7
|
+
await db.runAsync(sql, params ?? []);
|
|
8
|
+
},
|
|
9
|
+
execAsync: async (statement) => {
|
|
10
|
+
await db.execAsync(statement);
|
|
11
|
+
},
|
|
12
|
+
getAllAsync: async (sql, params) => {
|
|
13
|
+
const result = await db.getAllAsync(sql, params ?? []);
|
|
14
|
+
return result ?? [];
|
|
15
|
+
},
|
|
16
|
+
getFirstAsync: async (sql, params) => {
|
|
17
|
+
const result = await db.getFirstAsync(sql, params ?? []);
|
|
18
|
+
return result ?? null;
|
|
19
|
+
},
|
|
20
|
+
query: async (sql, params) => {
|
|
21
|
+
const { sql: q, params: p } = params
|
|
22
|
+
? namedToPositional(sql, params)
|
|
23
|
+
: { sql, params: [] };
|
|
24
|
+
return await db.getAllAsync(q, p);
|
|
25
|
+
},
|
|
26
|
+
queryOne: async (sql, params) => {
|
|
27
|
+
const { sql: q, params: p } = params
|
|
28
|
+
? namedToPositional(sql, params)
|
|
29
|
+
: { sql, params: [] };
|
|
30
|
+
return await db.getFirstAsync(q, p);
|
|
31
|
+
},
|
|
32
|
+
execute: async (sql, params) => {
|
|
33
|
+
const { sql: q, params: p } = params
|
|
34
|
+
? namedToPositional(sql, params)
|
|
35
|
+
: { sql, params: [] };
|
|
36
|
+
return await db.runAsync(q, p);
|
|
37
|
+
},
|
|
38
|
+
closeAsync: async () => {
|
|
39
|
+
await db.closeAsync?.();
|
|
40
|
+
},
|
|
41
|
+
withTransaction: async (fn) => {
|
|
42
|
+
return await db.withTransactionAsync(async () => {
|
|
43
|
+
const txExecutor = {
|
|
44
|
+
runAsync: async (sql, params) => await db.runAsync(sql, params ?? []),
|
|
45
|
+
execAsync: async (statement) => await db.execAsync(statement),
|
|
46
|
+
getAllAsync: async (sql, params) => await db.getAllAsync(sql, params ?? []),
|
|
47
|
+
getFirstAsync: async (sql, params) => await db.getFirstAsync(sql, params ?? []),
|
|
48
|
+
query: async (sql, params) => {
|
|
49
|
+
const { sql: q, params: p } = params
|
|
50
|
+
? namedToPositional(sql, params)
|
|
51
|
+
: { sql, params: [] };
|
|
52
|
+
return await db.getAllAsync(q, p);
|
|
53
|
+
},
|
|
54
|
+
queryOne: async (sql, params) => {
|
|
55
|
+
const { sql: q, params: p } = params
|
|
56
|
+
? namedToPositional(sql, params)
|
|
57
|
+
: { sql, params: [] };
|
|
58
|
+
return await db.getFirstAsync(q, p);
|
|
59
|
+
},
|
|
60
|
+
execute: async (sql, params) => {
|
|
61
|
+
const { sql: q, params: p } = params
|
|
62
|
+
? namedToPositional(sql, params)
|
|
63
|
+
: { sql, params: [] };
|
|
64
|
+
return await db.runAsync(q, p);
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
return await fn(txExecutor);
|
|
68
|
+
});
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
},
|
|
72
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rn_nitro.d.ts","sourceRoot":"","sources":["../../../../src/shared/db/adapters/rn_nitro.ts"],"names":[],"mappings":"AACA,OAAO,EACL,mBAAmB,EACnB,sBAAsB,EAGvB,MAAM,mCAAmC,CAAC;AAI3C,eAAO,MAAM,kBAAkB,EAAE,sBAAsB,CAAC,mBAAmB,CAyJ1E,CAAC"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { getSupastashConfig } from "../../core/config";
|
|
2
|
+
import { isDebugMode } from "../../utils/logs";
|
|
3
|
+
import { namedToPositional } from "../normalizer";
|
|
4
|
+
export const SQLiteAdapterNitro = {
|
|
5
|
+
async openDatabaseAsync(name, sqliteClient) {
|
|
6
|
+
//Enable simple null handling for Nitro SQLite
|
|
7
|
+
const config = getSupastashConfig();
|
|
8
|
+
if (!config.hasEnabledSimpleNullHandling && isDebugMode()) {
|
|
9
|
+
console.warn("[Supastash] Nitro SQLite detected. Call `enableSimpleNullHandling()` at the top of your app to ensure correct null behavior (see: https://libraries.io/npm/@vertexmd%2Freact-native-nitro-sqlite#simplified-null-handling). If already enabled, set `hasEnabledSimpleNullHandling: true` in Supastash config to silence this warning.");
|
|
10
|
+
}
|
|
11
|
+
const db = await sqliteClient.open({ name, location: "default" });
|
|
12
|
+
return {
|
|
13
|
+
runAsync: async (sql, params) => {
|
|
14
|
+
await db.executeAsync(sql, params ?? []);
|
|
15
|
+
},
|
|
16
|
+
execAsync: async (statement) => {
|
|
17
|
+
await db.executeAsync(statement);
|
|
18
|
+
},
|
|
19
|
+
getAllAsync: async (sql, params) => {
|
|
20
|
+
const result = await db.executeAsync(sql, params ?? []);
|
|
21
|
+
const mainResult = result.rows?._array ?? [];
|
|
22
|
+
return mainResult;
|
|
23
|
+
},
|
|
24
|
+
getFirstAsync: async (sql, params) => {
|
|
25
|
+
const result = await db.executeAsync(sql, params ?? []);
|
|
26
|
+
return result.rows?._array?.[0] ?? null;
|
|
27
|
+
},
|
|
28
|
+
query: async (sql, params) => {
|
|
29
|
+
const { sql: q, params: p } = params
|
|
30
|
+
? namedToPositional(sql, params)
|
|
31
|
+
: { sql, params: [] };
|
|
32
|
+
const result = await db.executeAsync(q, p ?? []);
|
|
33
|
+
const mainResult = result.rows?._array ?? [];
|
|
34
|
+
return mainResult;
|
|
35
|
+
},
|
|
36
|
+
queryOne: async (sql, params) => {
|
|
37
|
+
const { sql: q, params: p } = params
|
|
38
|
+
? namedToPositional(sql, params)
|
|
39
|
+
: { sql, params: [] };
|
|
40
|
+
const result = await db.executeAsync(q, p ?? []);
|
|
41
|
+
return result.rows?._array?.[0] ?? null;
|
|
42
|
+
},
|
|
43
|
+
execute: async (sql, params) => {
|
|
44
|
+
const { sql: q, params: p } = params
|
|
45
|
+
? namedToPositional(sql, params)
|
|
46
|
+
: { sql, params: [] };
|
|
47
|
+
return await db.executeAsync(q, p ?? []);
|
|
48
|
+
},
|
|
49
|
+
closeAsync: async () => {
|
|
50
|
+
await db.close?.();
|
|
51
|
+
},
|
|
52
|
+
withTransaction: async (fn) => {
|
|
53
|
+
const statements = [];
|
|
54
|
+
const enqueue = (sql, params) => {
|
|
55
|
+
statements.push({ sql, params });
|
|
56
|
+
};
|
|
57
|
+
const txExecutor = {
|
|
58
|
+
runAsync: async (sql, params) => {
|
|
59
|
+
enqueue(sql, params ?? []);
|
|
60
|
+
},
|
|
61
|
+
execAsync: async (statement) => {
|
|
62
|
+
enqueue(statement, []);
|
|
63
|
+
},
|
|
64
|
+
getAllAsync: async (sql, params) => {
|
|
65
|
+
const result = await db.executeAsync(sql, params ?? []);
|
|
66
|
+
return result.rows?._array ?? [];
|
|
67
|
+
},
|
|
68
|
+
getFirstAsync: async (sql, params) => {
|
|
69
|
+
const result = await db.executeAsync(sql, params ?? []);
|
|
70
|
+
return result.rows?._array?.[0] ?? null;
|
|
71
|
+
},
|
|
72
|
+
query: async (sql, params) => {
|
|
73
|
+
const { sql: q, params: p } = params
|
|
74
|
+
? namedToPositional(sql, params)
|
|
75
|
+
: { sql, params: [] };
|
|
76
|
+
const result = await db.executeAsync(q, p ?? []);
|
|
77
|
+
return result.rows?._array ?? [];
|
|
78
|
+
},
|
|
79
|
+
queryOne: async (sql, params) => {
|
|
80
|
+
const { sql: q, params: p } = params
|
|
81
|
+
? namedToPositional(sql, params)
|
|
82
|
+
: { sql, params: [] };
|
|
83
|
+
const result = await db.executeAsync(q, p ?? []);
|
|
84
|
+
return result.rows?._array?.[0] ?? null;
|
|
85
|
+
},
|
|
86
|
+
execute: async (sql, params) => {
|
|
87
|
+
const { sql: q, params: p } = params
|
|
88
|
+
? namedToPositional(sql, params)
|
|
89
|
+
: { sql, params: [] };
|
|
90
|
+
enqueue(q, p ?? []);
|
|
91
|
+
return {};
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
await fn(txExecutor);
|
|
95
|
+
if (statements.length === 0)
|
|
96
|
+
return;
|
|
97
|
+
await db.executeAsync("BEGIN");
|
|
98
|
+
try {
|
|
99
|
+
for (const { sql, params } of statements) {
|
|
100
|
+
await db.executeAsync(sql, params);
|
|
101
|
+
}
|
|
102
|
+
await db.executeAsync("COMMIT");
|
|
103
|
+
}
|
|
104
|
+
catch (err) {
|
|
105
|
+
await db.executeAsync("ROLLBACK").catch(() => { });
|
|
106
|
+
throw err;
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
};
|
|
110
|
+
},
|
|
111
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rn_sqlite_storage.d.ts","sourceRoot":"","sources":["../../../../src/shared/db/adapters/rn_sqlite_storage.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EAGvB,MAAM,mCAAmC,CAAC;AAG3C,eAAO,MAAM,oBAAoB,EAAE,sBAAsB,CAAC,qBAAqB,CAgJ5E,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { namedToPositional } from "../normalizer";
|
|
1
2
|
export const SQLiteAdapterStorage = {
|
|
2
3
|
async openDatabaseAsync(name, sqliteClient) {
|
|
3
4
|
const db = await sqliteClient.openDatabase({ name });
|
|
@@ -17,6 +18,26 @@ export const SQLiteAdapterStorage = {
|
|
|
17
18
|
const result = await db.executeSql(sql, params ?? []);
|
|
18
19
|
return result[0].rows.item(0) ?? null;
|
|
19
20
|
},
|
|
21
|
+
query: async (sql, params) => {
|
|
22
|
+
const { sql: q, params: p } = params
|
|
23
|
+
? namedToPositional(sql, params)
|
|
24
|
+
: { sql, params: [] };
|
|
25
|
+
const result = await db.executeSql(q, p ?? []);
|
|
26
|
+
return result.map((r, index) => r.rows.item(index));
|
|
27
|
+
},
|
|
28
|
+
queryOne: async (sql, params) => {
|
|
29
|
+
const { sql: q, params: p } = params
|
|
30
|
+
? namedToPositional(sql, params)
|
|
31
|
+
: { sql, params: [] };
|
|
32
|
+
const result = await db.executeSql(q, p ?? []);
|
|
33
|
+
return result[0].rows.item(0) ?? null;
|
|
34
|
+
},
|
|
35
|
+
execute: async (sql, params) => {
|
|
36
|
+
const { sql: q, params: p } = params
|
|
37
|
+
? namedToPositional(sql, params)
|
|
38
|
+
: { sql, params: [] };
|
|
39
|
+
await db.executeSql(q, p ?? []);
|
|
40
|
+
},
|
|
20
41
|
closeAsync: async () => {
|
|
21
42
|
await db.close?.();
|
|
22
43
|
},
|
|
@@ -43,6 +64,26 @@ export const SQLiteAdapterStorage = {
|
|
|
43
64
|
return null;
|
|
44
65
|
return resultSet.rows.item(0);
|
|
45
66
|
},
|
|
67
|
+
query: async (sql, params) => {
|
|
68
|
+
const { sql: q, params: p } = params
|
|
69
|
+
? namedToPositional(sql, params)
|
|
70
|
+
: { sql, params: [] };
|
|
71
|
+
const result = await db.executeSql(q, p ?? []);
|
|
72
|
+
return result.map((r, index) => r.rows.item(index));
|
|
73
|
+
},
|
|
74
|
+
queryOne: async (sql, params) => {
|
|
75
|
+
const { sql: q, params: p } = params
|
|
76
|
+
? namedToPositional(sql, params)
|
|
77
|
+
: { sql, params: [] };
|
|
78
|
+
const result = await db.executeSql(q, p ?? []);
|
|
79
|
+
return result[0].rows.item(0) ?? null;
|
|
80
|
+
},
|
|
81
|
+
execute: async (sql, params) => {
|
|
82
|
+
const { sql: q, params: p } = params
|
|
83
|
+
? namedToPositional(sql, params)
|
|
84
|
+
: { sql, params: [] };
|
|
85
|
+
await db.executeSql(q, p ?? []);
|
|
86
|
+
},
|
|
46
87
|
};
|
|
47
88
|
return await fn(txExecutor);
|
|
48
89
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tauri.d.ts","sourceRoot":"","sources":["../../../../src/shared/db/adapters/tauri.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EAEtB,iBAAiB,EAClB,MAAM,mCAAmC,CAAC;AAG3C,eAAO,MAAM,kBAAkB,EAAE,sBAAsB,CAAC,iBAAiB,CAiJxE,CAAC"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { interpolate, namedToPositional } from "../normalizer";
|
|
2
|
+
export const SQLiteAdapterTauri = {
|
|
3
|
+
async openDatabaseAsync(name, sqliteClient) {
|
|
4
|
+
const db = await sqliteClient.load(`sqlite:${name}`);
|
|
5
|
+
const normalizeParams = (params) => {
|
|
6
|
+
return (params ?? []).map((v) => typeof v === "boolean" ? (v ? 1 : 0) : v);
|
|
7
|
+
};
|
|
8
|
+
return {
|
|
9
|
+
runAsync: async (sql, params) => {
|
|
10
|
+
const normalized = normalizeParams(params);
|
|
11
|
+
await db.execute(sql, normalized ?? []);
|
|
12
|
+
},
|
|
13
|
+
execAsync: async (statement) => {
|
|
14
|
+
await db.execute(statement);
|
|
15
|
+
},
|
|
16
|
+
getAllAsync: async (sql, params) => {
|
|
17
|
+
const normalized = normalizeParams(params);
|
|
18
|
+
const rows = await db.select(sql, normalized ?? []);
|
|
19
|
+
return rows ?? [];
|
|
20
|
+
},
|
|
21
|
+
getFirstAsync: async (sql, params) => {
|
|
22
|
+
const normalized = normalizeParams(params);
|
|
23
|
+
const rows = (await db.select(sql, normalized ?? []));
|
|
24
|
+
return rows?.[0] ?? null;
|
|
25
|
+
},
|
|
26
|
+
query: async (sql, params) => {
|
|
27
|
+
const { sql: q, params: p } = params
|
|
28
|
+
? namedToPositional(sql, params)
|
|
29
|
+
: { sql, params: [] };
|
|
30
|
+
const normalized = normalizeParams(p);
|
|
31
|
+
return (await db.select(q, normalized));
|
|
32
|
+
},
|
|
33
|
+
queryOne: async (sql, params) => {
|
|
34
|
+
const { sql: q, params: p } = params
|
|
35
|
+
? namedToPositional(sql, params)
|
|
36
|
+
: { sql, params: [] };
|
|
37
|
+
const normalized = normalizeParams(p);
|
|
38
|
+
const rows = (await db.select(q, normalized));
|
|
39
|
+
return rows?.[0] ?? null;
|
|
40
|
+
},
|
|
41
|
+
execute: async (sql, params) => {
|
|
42
|
+
const { sql: q, params: p } = params
|
|
43
|
+
? namedToPositional(sql, params)
|
|
44
|
+
: { sql, params: [] };
|
|
45
|
+
return (await db.execute(q, p));
|
|
46
|
+
},
|
|
47
|
+
closeAsync: async () => {
|
|
48
|
+
if (typeof db.close === "function") {
|
|
49
|
+
await db.close();
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
withTransaction: async (fn) => {
|
|
53
|
+
const statements = [];
|
|
54
|
+
const enqueue = (sql, params) => {
|
|
55
|
+
statements.push(interpolate(sql, params));
|
|
56
|
+
};
|
|
57
|
+
const txExecutor = {
|
|
58
|
+
runAsync: async (sql, params) => {
|
|
59
|
+
enqueue(sql, params ?? []);
|
|
60
|
+
},
|
|
61
|
+
execAsync: async (statement) => {
|
|
62
|
+
statements.push(statement);
|
|
63
|
+
},
|
|
64
|
+
getAllAsync: async (sql, params) => (await db.select(sql, params ?? [])) ?? [],
|
|
65
|
+
getFirstAsync: async (sql, params) => (await db.select(sql, params ?? []))?.[0] ?? null,
|
|
66
|
+
query: async (sql, params) => {
|
|
67
|
+
const { sql: q, params: p } = params
|
|
68
|
+
? namedToPositional(sql, params)
|
|
69
|
+
: { sql, params: [] };
|
|
70
|
+
return (await db.select(q, p));
|
|
71
|
+
},
|
|
72
|
+
queryOne: async (sql, params) => {
|
|
73
|
+
const { sql: q, params: p } = params
|
|
74
|
+
? namedToPositional(sql, params)
|
|
75
|
+
: { sql, params: [] };
|
|
76
|
+
return (await db.select(q, p))?.[0] ?? null;
|
|
77
|
+
},
|
|
78
|
+
execute: async (sql, params) => {
|
|
79
|
+
const { sql: q, params: p } = params
|
|
80
|
+
? namedToPositional(sql, params)
|
|
81
|
+
: { sql, params: [] };
|
|
82
|
+
enqueue(q, p);
|
|
83
|
+
return {};
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
await fn(txExecutor);
|
|
87
|
+
if (statements.length === 0)
|
|
88
|
+
return;
|
|
89
|
+
const batch = `BEGIN; ${statements.join("; ")}; COMMIT;`;
|
|
90
|
+
try {
|
|
91
|
+
await db.execute(batch, []);
|
|
92
|
+
}
|
|
93
|
+
catch (err) {
|
|
94
|
+
await db.execute("ROLLBACK;", []).catch(() => { });
|
|
95
|
+
throw err;
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
};
|
|
99
|
+
},
|
|
100
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dbErrorMsg.d.ts","sourceRoot":"","sources":["../../../src/shared/db/dbErrorMsg.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,mBAAmB,QAmCxB,CAAC"}
|
|
@@ -25,4 +25,11 @@ export const supastashDbErrorMsg = "SQLite client not found. Please provide a SQ
|
|
|
25
25
|
" sqliteClient: { openDatabaseAsync }, \n" +
|
|
26
26
|
" sqliteClientType: 'rn-storage', \n" +
|
|
27
27
|
"});" +
|
|
28
|
+
"\n\n" +
|
|
29
|
+
"or \n" +
|
|
30
|
+
"import Database from '@tauri-apps/plugin-sql';\n" +
|
|
31
|
+
"configureSupastash({ \n" +
|
|
32
|
+
" sqliteClient: Database, \n" +
|
|
33
|
+
" sqliteClientType: 'tauri', \n" +
|
|
34
|
+
"});" +
|
|
28
35
|
"\n\n";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { SupastashSQLiteDatabase } from "../types/supastashConfig.types";
|
|
2
|
+
export declare function closeSupastashDb(): Promise<void>;
|
|
2
3
|
/**
|
|
3
4
|
* Gets the supastash database
|
|
4
5
|
* @returns The supastash database
|
|
5
6
|
*/
|
|
6
7
|
export declare function getSupastashDb(): Promise<SupastashSQLiteDatabase>;
|
|
7
|
-
export declare function closeSupastashDb(): Promise<void>;
|
|
8
8
|
//# sourceMappingURL=dbInitializer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dbInitializer.d.ts","sourceRoot":"","sources":["../../../src/shared/db/dbInitializer.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,uBAAuB,EAExB,MAAM,gCAAgC,CAAC;AAMxC,wBAAsB,gBAAgB,kBAOrC;AAED;;;GAGG;AACH,wBAAsB,cAAc,IAAI,OAAO,CAAC,uBAAuB,CAAC,CAyEvE"}
|