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
|
@@ -1,21 +1,20 @@
|
|
|
1
|
-
import { getSupastashConfig } from "
|
|
2
|
-
import { getSupastashDb } from "
|
|
3
|
-
import { DEFAULT_RECEIVED_DATA_COMPLETED, RECEIVED_DATA_COMPLETED_MAP, } from "
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
1
|
+
import { getSupastashConfig } from "../../../../shared/core/config";
|
|
2
|
+
import { getSupastashDb } from "../../../../shared/db/dbInitializer";
|
|
3
|
+
import { DEFAULT_RECEIVED_DATA_COMPLETED, RECEIVED_DATA_COMPLETED_MAP, } from "../../../../shared/store/syncStatus";
|
|
4
|
+
import { generateUUIDv4 } from "../../../../shared/utils/genUUID";
|
|
5
|
+
import { getTableSchema } from "../../../../shared/utils/getTableSchema";
|
|
6
|
+
import log, { logError, logWarn } from "../../../../shared/utils/logs";
|
|
7
|
+
import { refreshScreen } from "../../../../shared/utils/refreshScreenCalls";
|
|
8
|
+
import { deleteReceivedDataCompleted } from "../../../../shared/utils/sync/pullFromRemote/helpers";
|
|
9
|
+
import { stringifyValue } from "../../../../shared/utils/sync/pullFromRemote/stringifyFields";
|
|
10
|
+
import { SyncInfoUpdater } from "../../../../shared/utils/sync/queryStatus";
|
|
11
|
+
import { updateLocalSyncedAt } from "../../../../shared/utils/sync/status/syncUpdate";
|
|
10
12
|
import { setSupastashSyncStatus } from "../status/services";
|
|
11
|
-
import { updateLocalSyncedAt } from "../status/syncUpdate";
|
|
12
|
-
import { deleteReceivedDataCompleted } from "./helpers";
|
|
13
13
|
import { pullData } from "./pullData";
|
|
14
|
-
import { stringifyValue } from "./stringifyFields";
|
|
15
14
|
let isInSync = new Map();
|
|
16
15
|
const DEFAULT_DATE = "1970-01-01T00:00:00Z";
|
|
17
16
|
const BATCH_SIZE = 500;
|
|
18
|
-
const
|
|
17
|
+
const CHUNK_SIZE = 999;
|
|
19
18
|
/**
|
|
20
19
|
* Updates the local database with the remote changes
|
|
21
20
|
* @param table - The table to update
|
|
@@ -26,8 +25,6 @@ export async function updateLocalDb(table, filters, onReceiveData) {
|
|
|
26
25
|
const cfg = getSupastashConfig();
|
|
27
26
|
if (cfg.supastashMode === "ghost")
|
|
28
27
|
return;
|
|
29
|
-
if (!(await isOnline()))
|
|
30
|
-
return;
|
|
31
28
|
isInSync.set(table, true);
|
|
32
29
|
const batchId = generateUUIDv4();
|
|
33
30
|
try {
|
|
@@ -61,8 +58,8 @@ export async function updateLocalDb(table, filters, onReceiveData) {
|
|
|
61
58
|
await db.withTransaction(async (tx) => {
|
|
62
59
|
if (deletedIds && deletedIds.length > 0) {
|
|
63
60
|
const ids = deletedIds;
|
|
64
|
-
for (let i = 0; i < ids.length; i +=
|
|
65
|
-
const slice = ids.slice(i, i +
|
|
61
|
+
for (let i = 0; i < ids.length; i += CHUNK_SIZE) {
|
|
62
|
+
const slice = ids.slice(i, i + CHUNK_SIZE);
|
|
66
63
|
const placeholders = slice.map(() => "?").join(", ");
|
|
67
64
|
await tx.runAsync(`DELETE FROM ${table} WHERE id IN (${placeholders})`, slice);
|
|
68
65
|
}
|
|
@@ -71,8 +68,8 @@ export async function updateLocalDb(table, filters, onReceiveData) {
|
|
|
71
68
|
let localStamp = new Map();
|
|
72
69
|
if (data?.length) {
|
|
73
70
|
const ids = data.map((r) => r.id).filter(Boolean);
|
|
74
|
-
for (let i = 0; i < ids.length; i +=
|
|
75
|
-
const slice = ids.slice(i, i +
|
|
71
|
+
for (let i = 0; i < ids.length; i += CHUNK_SIZE) {
|
|
72
|
+
const slice = ids.slice(i, i + CHUNK_SIZE);
|
|
76
73
|
const placeholders = slice.map(() => "?").join(", ");
|
|
77
74
|
const rows = await db.getAllAsync(`SELECT id, updated_at FROM ${table} WHERE id IN (${placeholders})`, slice);
|
|
78
75
|
for (const row of rows ?? []) {
|
|
@@ -82,33 +79,11 @@ export async function updateLocalDb(table, filters, onReceiveData) {
|
|
|
82
79
|
}
|
|
83
80
|
// Update local database with remote changes
|
|
84
81
|
if (data?.length) {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
continue;
|
|
91
|
-
const localUpdated = localStamp.get(record.id) ?? DEFAULT_DATE;
|
|
92
|
-
const remoteUpdated = record.updated_at ?? DEFAULT_DATE;
|
|
93
|
-
if (new Date(localUpdated) >= new Date(remoteUpdated)) {
|
|
94
|
-
// local is newer or same — skip
|
|
95
|
-
continue;
|
|
96
|
-
}
|
|
97
|
-
if (onReceiveData) {
|
|
98
|
-
await onReceiveData(record);
|
|
99
|
-
}
|
|
100
|
-
else {
|
|
101
|
-
await upsertData({
|
|
102
|
-
tx,
|
|
103
|
-
table,
|
|
104
|
-
record,
|
|
105
|
-
doesExist: localStamp.has(record.id),
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
if ((i + 1) % BATCH_SIZE === 0) {
|
|
109
|
-
await new Promise((res) => setTimeout(res, 0));
|
|
110
|
-
}
|
|
111
|
-
}
|
|
82
|
+
await upsertChunkData({
|
|
83
|
+
tx,
|
|
84
|
+
table,
|
|
85
|
+
records: data,
|
|
86
|
+
});
|
|
112
87
|
}
|
|
113
88
|
});
|
|
114
89
|
if (timestamps) {
|
|
@@ -161,7 +136,7 @@ export async function upsertData({ tx, table, record, doesExist, }) {
|
|
|
161
136
|
...record,
|
|
162
137
|
synced_at: new Date().toISOString(),
|
|
163
138
|
};
|
|
164
|
-
if (
|
|
139
|
+
if (getSupastashConfig().debugMode) {
|
|
165
140
|
const unknownKeys = Object.keys(record).filter((key) => !columns.includes(key));
|
|
166
141
|
if (unknownKeys.length > 0 && !warned.get(table)) {
|
|
167
142
|
warned.set(table, true);
|
|
@@ -190,6 +165,104 @@ export async function upsertData({ tx, table, record, doesExist, }) {
|
|
|
190
165
|
logError(`[Supastash] Error upserting data for ${table}`, error);
|
|
191
166
|
}
|
|
192
167
|
}
|
|
168
|
+
/**
|
|
169
|
+
• Bulk upserts records into a local SQLite table using a batched, conflict-aware strategy.
|
|
170
|
+
•
|
|
171
|
+
• This function:
|
|
172
|
+
• • Fetches existing id and updated_at values in bulk to avoid per-row queries
|
|
173
|
+
• • Filters incoming records to only include new or more recent entries
|
|
174
|
+
• • Performs batched INSERT ... ON CONFLICT(id) DO UPDATE operations
|
|
175
|
+
• while respecting SQLite parameter limits
|
|
176
|
+
• • Updates synced_at for successfully written records
|
|
177
|
+
•
|
|
178
|
+
• Designed for high-performance sync scenarios in offline-first apps.
|
|
179
|
+
•
|
|
180
|
+
• Key guarantees:
|
|
181
|
+
• • Avoids N+1 query patterns (no per-row existence checks)
|
|
182
|
+
• • Minimizes disk I/O pressure via batching
|
|
183
|
+
• • Safe for large datasets when used with chunking
|
|
184
|
+
•
|
|
185
|
+
• Notes:
|
|
186
|
+
• • Assumes id is the primary or unique key
|
|
187
|
+
• • Requires updated_at for conflict resolution (falls back if missing)
|
|
188
|
+
• • Respects SQLite parameter limit (~999 variables per query)
|
|
189
|
+
•
|
|
190
|
+
• @param tx Optional transaction instance. If not provided, a connection is used directly.
|
|
191
|
+
• @param table Target table name
|
|
192
|
+
• @param records Array of records to upsert
|
|
193
|
+
*/
|
|
194
|
+
export async function upsertChunkData({ tx, table, records, }) {
|
|
195
|
+
if (!records?.length)
|
|
196
|
+
return;
|
|
197
|
+
const cfg = getSupastashConfig();
|
|
198
|
+
if (cfg.supastashMode === "ghost")
|
|
199
|
+
return;
|
|
200
|
+
const db = tx ?? (await getSupastashDb());
|
|
201
|
+
const columns = await getTableSchema(table);
|
|
202
|
+
const syncedAt = new Date().toISOString();
|
|
203
|
+
if (cfg.debugMode) {
|
|
204
|
+
const unknownKeys = Object.keys(records[0]).filter((key) => !columns.includes(key));
|
|
205
|
+
if (unknownKeys.length > 0 && !warned.get(table)) {
|
|
206
|
+
warned.set(table, true);
|
|
207
|
+
logWarn(`⚠️ [Supastash] '${table}' payload contains keys not in local schema: ${unknownKeys.join(", ")}. ` + `They will be ignored locally.`);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
// Step 1: Fetch existing id + updated_at for all incoming ids in bulk
|
|
211
|
+
const incomingIds = records.map((r) => r.id).filter(Boolean);
|
|
212
|
+
const localStamp = new Map();
|
|
213
|
+
for (let i = 0; i < incomingIds.length; i += CHUNK_SIZE) {
|
|
214
|
+
const slice = incomingIds.slice(i, i + CHUNK_SIZE);
|
|
215
|
+
const placeholders = slice.map(() => "?").join(", ");
|
|
216
|
+
const rows = await db.getAllAsync(`SELECT id, updated_at FROM ${table} WHERE id IN (${placeholders})`, slice);
|
|
217
|
+
for (const row of rows ?? []) {
|
|
218
|
+
localStamp.set(row.id, row.updated_at ?? null);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
// Step 2: Keep only records that are new or have a newer remote updated_at
|
|
222
|
+
const toUpsert = records.filter((record) => {
|
|
223
|
+
if (!record?.id)
|
|
224
|
+
return false;
|
|
225
|
+
const localUpdated = localStamp.get(record.id) ?? DEFAULT_DATE;
|
|
226
|
+
const remoteUpdated = record.updated_at ?? DEFAULT_DATE;
|
|
227
|
+
return new Date(remoteUpdated) > new Date(localUpdated);
|
|
228
|
+
});
|
|
229
|
+
if (!toUpsert.length)
|
|
230
|
+
return;
|
|
231
|
+
// Step 3: Build INSERT … ON CONFLICT(id) DO UPDATE in param-limit-safe chunks
|
|
232
|
+
const colList = columns.join(", ");
|
|
233
|
+
const updateSet = columns
|
|
234
|
+
.filter((key) => key !== "id")
|
|
235
|
+
.map((key) => `${key} = excluded.${key}`)
|
|
236
|
+
.join(", ");
|
|
237
|
+
const paramsPerRow = columns.length;
|
|
238
|
+
const rowsPerChunk = Math.max(1, Math.floor(999 / paramsPerRow));
|
|
239
|
+
const successfulIds = [];
|
|
240
|
+
for (let i = 0; i < toUpsert.length; i += rowsPerChunk) {
|
|
241
|
+
const chunk = toUpsert.slice(i, i + rowsPerChunk);
|
|
242
|
+
const rowPlaceholders = chunk
|
|
243
|
+
.map(() => `(${columns.map(() => "?").join(", ")})`)
|
|
244
|
+
.join(", ");
|
|
245
|
+
const values = [];
|
|
246
|
+
for (const record of chunk) {
|
|
247
|
+
const recordToSave = { ...record, synced_at: syncedAt };
|
|
248
|
+
for (const col of columns) {
|
|
249
|
+
values.push(stringifyValue(recordToSave[col]));
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
try {
|
|
253
|
+
await db.runAsync(`INSERT INTO ${table} (${colList}) VALUES ${rowPlaceholders} ON CONFLICT(id) DO UPDATE SET ${updateSet}`, values);
|
|
254
|
+
for (const record of chunk) {
|
|
255
|
+
successfulIds.push(record.id);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
catch (error) {
|
|
259
|
+
logError(`[Supastash] Error upserting chunk for ${table}`, error);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
if (successfulIds.length) {
|
|
263
|
+
await updateLocalSyncedAt(table, successfulIds);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
193
266
|
async function checkIfRecordExistsAndIsNewer(table, item) {
|
|
194
267
|
if (!item?.id)
|
|
195
268
|
return { doesExist: false, newer: false };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/native/utils/sync/pushLocal/index.ts"],"names":[],"mappings":"AAaA;;GAEG;AACH,wBAAsB,aAAa,kBAiGlC"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { getSupastashConfig } from "../../../../shared/core/config";
|
|
2
|
+
import { syncCalls } from "../../../../shared/store/syncCalls";
|
|
3
|
+
import log from "../../../../shared/utils/logs";
|
|
4
|
+
import { getAllTables } from "../../../../shared/utils/sync/getAllTables";
|
|
5
|
+
import { runLimitedConcurrency } from "../../../../shared/utils/sync/pullFromRemote/runLimitedConcurrency";
|
|
6
|
+
import { SyncInfoUpdater } from "../../../../shared/utils/sync/queryStatus";
|
|
7
|
+
import { pushLocalDataToRemote } from "./sendUnsyncedToSupabase";
|
|
8
|
+
let emptyPassCount = 0;
|
|
9
|
+
let lastEmptyPassAt = 0;
|
|
10
|
+
const tablePushLock = new Map();
|
|
11
|
+
/**
|
|
12
|
+
* Pushes the local data to the remote database
|
|
13
|
+
*/
|
|
14
|
+
export async function pushLocalData() {
|
|
15
|
+
let tablesCompleted = 0;
|
|
16
|
+
let numberOfTables = 0;
|
|
17
|
+
try {
|
|
18
|
+
const tables = await getAllTables();
|
|
19
|
+
if (!tables) {
|
|
20
|
+
log("[Supastash] No tables found");
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
const excludeTables = getSupastashConfig()?.excludeTables?.push || [];
|
|
24
|
+
const tablesToPush = tables.filter((table) => !excludeTables?.includes(table));
|
|
25
|
+
numberOfTables = tablesToPush.length;
|
|
26
|
+
SyncInfoUpdater.setInProgress({
|
|
27
|
+
action: "start",
|
|
28
|
+
type: "push",
|
|
29
|
+
});
|
|
30
|
+
SyncInfoUpdater.setNumberOfTables({
|
|
31
|
+
amount: numberOfTables,
|
|
32
|
+
type: "push",
|
|
33
|
+
});
|
|
34
|
+
const results = [];
|
|
35
|
+
const jobs = tablesToPush.map((table) => async () => {
|
|
36
|
+
SyncInfoUpdater.setCurrentTable({
|
|
37
|
+
table,
|
|
38
|
+
type: "push",
|
|
39
|
+
});
|
|
40
|
+
if (tablePushLock.get(table)) {
|
|
41
|
+
results.push({ table, hadWork: false });
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
tablePushLock.set(table, true);
|
|
45
|
+
try {
|
|
46
|
+
const onPush = syncCalls.get(table)?.push;
|
|
47
|
+
SyncInfoUpdater.markLogStart({
|
|
48
|
+
type: "push",
|
|
49
|
+
table,
|
|
50
|
+
});
|
|
51
|
+
const hadWork = await pushLocalDataToRemote(table, onPush);
|
|
52
|
+
results.push({ table, hadWork: !!hadWork });
|
|
53
|
+
SyncInfoUpdater.markLogSuccess({
|
|
54
|
+
type: "push",
|
|
55
|
+
table,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
catch (e) {
|
|
59
|
+
const msg = e?.message ?? e?.code ?? e?.name ?? String(e);
|
|
60
|
+
SyncInfoUpdater.markLogError({
|
|
61
|
+
type: "push",
|
|
62
|
+
table,
|
|
63
|
+
lastError: e,
|
|
64
|
+
errorCount: 1,
|
|
65
|
+
});
|
|
66
|
+
results.push({ table, hadWork: false, error: msg });
|
|
67
|
+
log(`[Supastash] Push table failed: ${table} — ${msg}`);
|
|
68
|
+
}
|
|
69
|
+
finally {
|
|
70
|
+
tablesCompleted++;
|
|
71
|
+
SyncInfoUpdater.setTablesCompleted({
|
|
72
|
+
amount: tablesCompleted,
|
|
73
|
+
type: "push",
|
|
74
|
+
});
|
|
75
|
+
tablePushLock.set(table, false);
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
await runLimitedConcurrency(jobs, 3);
|
|
79
|
+
const hadAnyWork = results.some((r) => r.hadWork);
|
|
80
|
+
if (!hadAnyWork) {
|
|
81
|
+
emptyPassCount += 1;
|
|
82
|
+
if (emptyPassCount % 150 === 0) {
|
|
83
|
+
const now = Date.now();
|
|
84
|
+
const gap = lastEmptyPassAt ? now - lastEmptyPassAt : 0;
|
|
85
|
+
lastEmptyPassAt = now;
|
|
86
|
+
const noSyncTables = results.map((r) => r.table).join(", ");
|
|
87
|
+
log(`[Supastash] No pushable data for: ${noSyncTables} (empty passes: ${emptyPassCount})${gap ? ` in the last ${gap}ms` : ""}`);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
emptyPassCount = 0;
|
|
92
|
+
lastEmptyPassAt = Date.now();
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
catch (error) {
|
|
96
|
+
log(`[Supastash] Error pushing local data to remote database: ${error}`);
|
|
97
|
+
}
|
|
98
|
+
finally {
|
|
99
|
+
SyncInfoUpdater.reset({ type: "push" });
|
|
100
|
+
}
|
|
101
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sends unsynced data to the remote database for a given table.
|
|
3
|
+
* Returns true if it pushed anything (creates/updates OR deletes), else false.
|
|
4
|
+
*/
|
|
5
|
+
export declare function pushLocalDataToRemote(table: string, onPushToRemote?: (payload: any[]) => Promise<boolean>, noSync?: string[]): Promise<boolean | undefined>;
|
|
6
|
+
//# sourceMappingURL=sendUnsyncedToSupabase.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sendUnsyncedToSupabase.d.ts","sourceRoot":"","sources":["../../../../../src/native/utils/sync/pushLocal/sendUnsyncedToSupabase.ts"],"names":[],"mappings":"AAYA;;;GAGG;AACH,wBAAsB,qBAAqB,CACzC,KAAK,EAAE,MAAM,EACb,cAAc,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,OAAO,CAAC,EACrD,MAAM,CAAC,EAAE,MAAM,EAAE,gCA+ClB"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { getSupastashConfig } from "../../../../shared/core/config";
|
|
2
|
+
import { refreshScreen } from "../../../../shared/utils/refreshScreenCalls";
|
|
3
|
+
import { deleteData } from "../../../../shared/utils/sync/pushLocal/deleteChunks";
|
|
4
|
+
import { getAllDeletedData, getAllUnsyncedData, } from "../../../../shared/utils/sync/pushLocal/getAllUnsyncedData";
|
|
5
|
+
import { SyncInfoUpdater } from "../../../../shared/utils/sync/queryStatus";
|
|
6
|
+
import { uploadData } from "./uploadChunk";
|
|
7
|
+
let isInSync = new Map();
|
|
8
|
+
/**
|
|
9
|
+
* Sends unsynced data to the remote database for a given table.
|
|
10
|
+
* Returns true if it pushed anything (creates/updates OR deletes), else false.
|
|
11
|
+
*/
|
|
12
|
+
export async function pushLocalDataToRemote(table, onPushToRemote, noSync) {
|
|
13
|
+
if (isInSync.get(table))
|
|
14
|
+
return;
|
|
15
|
+
const cfg = getSupastashConfig();
|
|
16
|
+
if (cfg.supastashMode === "ghost")
|
|
17
|
+
return false;
|
|
18
|
+
isInSync.set(table, true);
|
|
19
|
+
try {
|
|
20
|
+
const data = await getAllUnsyncedData(table);
|
|
21
|
+
const deletedData = await getAllDeletedData(table);
|
|
22
|
+
SyncInfoUpdater.setUnsyncedDataCount({
|
|
23
|
+
amount: data?.length ?? 0,
|
|
24
|
+
type: "push",
|
|
25
|
+
table,
|
|
26
|
+
});
|
|
27
|
+
SyncInfoUpdater.setUnsyncedDeletedCount({
|
|
28
|
+
amount: deletedData?.length ?? 0,
|
|
29
|
+
type: "push",
|
|
30
|
+
table,
|
|
31
|
+
});
|
|
32
|
+
const hasData = !!data?.length;
|
|
33
|
+
const hasDeletes = !!deletedData?.length;
|
|
34
|
+
if (!hasData && !hasDeletes) {
|
|
35
|
+
noSync?.push?.(table);
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
let didWork = false;
|
|
39
|
+
if (hasData) {
|
|
40
|
+
await uploadData(table, data, onPushToRemote);
|
|
41
|
+
didWork = true;
|
|
42
|
+
}
|
|
43
|
+
if (hasDeletes) {
|
|
44
|
+
await deleteData(table, deletedData);
|
|
45
|
+
didWork = true;
|
|
46
|
+
}
|
|
47
|
+
if (didWork)
|
|
48
|
+
refreshScreen(table);
|
|
49
|
+
return didWork;
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
throw error;
|
|
53
|
+
}
|
|
54
|
+
finally {
|
|
55
|
+
isInSync.delete(table);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { PayloadData } from "../../../../shared/types/query.types";
|
|
2
|
+
/**
|
|
3
|
+
* Uploads a chunk of data to the remote database
|
|
4
|
+
* @param table - The table to upload to
|
|
5
|
+
* @param unsyncedRecords - The unsynced records to upload
|
|
6
|
+
*/
|
|
7
|
+
export declare function uploadData(table: string, unsyncedRecords: PayloadData[], onPushToRemote?: (payload: any[]) => Promise<boolean>): Promise<void>;
|
|
8
|
+
//# sourceMappingURL=uploadChunk.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uploadChunk.d.ts","sourceRoot":"","sources":["../../../../../src/native/utils/sync/pushLocal/uploadChunk.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AAmMnE;;;;GAIG;AACH,wBAAsB,UAAU,CAC9B,KAAK,EAAE,MAAM,EACb,eAAe,EAAE,WAAW,EAAE,EAC9B,cAAc,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,OAAO,CAAC,iBAetD"}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { DEFAULT_CHUNK_SIZE } from "../../../../shared/constants/syncDefaults";
|
|
2
|
+
import { getSupastashConfig } from "../../../../shared/core/config";
|
|
3
|
+
import { isOnline } from "../../../../shared/utils/connection";
|
|
4
|
+
import { normalizeForSupabase } from "../../../../shared/utils/getSafeValues";
|
|
5
|
+
import log from "../../../../shared/utils/logs";
|
|
6
|
+
import { supabaseClientErr } from "../../../../shared/utils/supabaseClientErr";
|
|
7
|
+
import { enforceTimestamps } from "../../../../shared/utils/sync/pushLocal/normalize";
|
|
8
|
+
import { setQueryStatus, SyncInfoUpdater, } from "../../../../shared/utils/sync/queryStatus";
|
|
9
|
+
import { backoff, batchUpsert, fetchRemoteHeadsChunked, filterRowsByUpdatedAt, handleRowFailure, markSynced, rpcUpsert, rpcUpsertSingle, singleUpsert, } from "./uploadHelpers";
|
|
10
|
+
/**
|
|
11
|
+
* Uploads a chunk of data to the remote database
|
|
12
|
+
*
|
|
13
|
+
* It will check if the data in the remote database is more recent than the data in the local database.
|
|
14
|
+
* If it is, it will skip it.
|
|
15
|
+
* If it is not, it will upsert it.
|
|
16
|
+
*
|
|
17
|
+
* @param table - The table to upload to
|
|
18
|
+
* @param chunk - The chunk of data to upload
|
|
19
|
+
*/
|
|
20
|
+
async function uploadChunk(table, chunk, onPushToRemote) {
|
|
21
|
+
const config = getSupastashConfig();
|
|
22
|
+
const supabase = config.supabaseClient;
|
|
23
|
+
if (!supabase) {
|
|
24
|
+
throw new Error(supabaseClientErr);
|
|
25
|
+
}
|
|
26
|
+
const online = await isOnline();
|
|
27
|
+
if (!online)
|
|
28
|
+
return;
|
|
29
|
+
let errorCount = 0;
|
|
30
|
+
let lastError = null;
|
|
31
|
+
let pending = [];
|
|
32
|
+
const hasRPCPath = !!config.pushRPCPath;
|
|
33
|
+
const ids = chunk.map((row) => row.id);
|
|
34
|
+
const toPush = [];
|
|
35
|
+
// If we have a RPC path, we can push the whole chunk. Server validates freshness.
|
|
36
|
+
if (hasRPCPath) {
|
|
37
|
+
toPush.push(...chunk);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
// Fetch remote data for the current chunk
|
|
41
|
+
const remoteIds = await fetchRemoteHeadsChunked(table, ids, supabase);
|
|
42
|
+
// Loop through the initial chunk and check if the id is in the remote data
|
|
43
|
+
const filtered = filterRowsByUpdatedAt(table, chunk, remoteIds);
|
|
44
|
+
toPush.push(...filtered);
|
|
45
|
+
}
|
|
46
|
+
if (toPush.length === 0)
|
|
47
|
+
return;
|
|
48
|
+
const preflightOK = [];
|
|
49
|
+
if (config.syncPolicy?.ensureParents) {
|
|
50
|
+
for (const r of toPush) {
|
|
51
|
+
try {
|
|
52
|
+
const status = await config.syncPolicy.ensureParents(table, r);
|
|
53
|
+
if (status === "blocked") {
|
|
54
|
+
setQueryStatus(r.id, table, "error");
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
preflightOK.push(r);
|
|
58
|
+
}
|
|
59
|
+
catch (e) {
|
|
60
|
+
setQueryStatus(r.id, table, "error");
|
|
61
|
+
log(`[Supastash] ensureParents failed for ${table}:${r.id}`, e);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
preflightOK.push(...toPush);
|
|
67
|
+
}
|
|
68
|
+
if (preflightOK.length === 0)
|
|
69
|
+
return;
|
|
70
|
+
pending.push(...preflightOK);
|
|
71
|
+
const maxBatchAttempts = config.syncPolicy?.maxBatchAttempts ?? 5;
|
|
72
|
+
let attempts = 0;
|
|
73
|
+
while (attempts < maxBatchAttempts && pending.length > 0) {
|
|
74
|
+
let batchOk = false;
|
|
75
|
+
// RPC return values
|
|
76
|
+
let completed = [];
|
|
77
|
+
let existsMap = new Map();
|
|
78
|
+
if (onPushToRemote) {
|
|
79
|
+
const ok = await onPushToRemote(pending);
|
|
80
|
+
if (ok)
|
|
81
|
+
batchOk = true;
|
|
82
|
+
}
|
|
83
|
+
else if (hasRPCPath) {
|
|
84
|
+
const res = await rpcUpsert({ table, rows: pending, supabase });
|
|
85
|
+
completed = res.data.completed;
|
|
86
|
+
pending = [...res.data.skipped];
|
|
87
|
+
existsMap = res.data.existsMap;
|
|
88
|
+
batchOk = res.error == null && pending.length === 0;
|
|
89
|
+
// If there was an RPC error, we need to retry the main function
|
|
90
|
+
if (res.error) {
|
|
91
|
+
attempts++;
|
|
92
|
+
await backoff(attempts);
|
|
93
|
+
pending = [...preflightOK];
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
const { error } = await batchUpsert(table, pending, supabase);
|
|
99
|
+
if (!error)
|
|
100
|
+
batchOk = true;
|
|
101
|
+
}
|
|
102
|
+
if (batchOk) {
|
|
103
|
+
await markSynced(table, pending.map((r) => r.id));
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
if (completed.length > 0) {
|
|
107
|
+
await markSynced(table, completed.map((r) => r.id));
|
|
108
|
+
}
|
|
109
|
+
//Batch failed -> isolate per-row offenders
|
|
110
|
+
const keep = [];
|
|
111
|
+
const syncedNow = [];
|
|
112
|
+
for (const row of pending) {
|
|
113
|
+
let res = null;
|
|
114
|
+
if (onPushToRemote) {
|
|
115
|
+
const ok = await onPushToRemote([row]);
|
|
116
|
+
res = { error: ok ? null : { code: "ROW_FAILED" } };
|
|
117
|
+
}
|
|
118
|
+
else if (hasRPCPath) {
|
|
119
|
+
res = await rpcUpsertSingle({ table, row, supabase, existsMap });
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
res = await singleUpsert(table, row, supabase);
|
|
123
|
+
}
|
|
124
|
+
if (!res.error) {
|
|
125
|
+
syncedNow.push(row.id);
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
errorCount++;
|
|
129
|
+
lastError = res.error;
|
|
130
|
+
const decision = await handleRowFailure(config, table, row, res.error, supabase);
|
|
131
|
+
if (decision === "DROP" || decision === "REPLACED") {
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
134
|
+
keep.push(row); // retry later
|
|
135
|
+
}
|
|
136
|
+
if (syncedNow.length)
|
|
137
|
+
await markSynced(table, syncedNow);
|
|
138
|
+
if (keep.length === 0)
|
|
139
|
+
return;
|
|
140
|
+
// Backoff before next batch round (exponential, bounded by policy)
|
|
141
|
+
attempts++;
|
|
142
|
+
await backoff(attempts);
|
|
143
|
+
pending = keep;
|
|
144
|
+
}
|
|
145
|
+
if (pending.length > 0) {
|
|
146
|
+
SyncInfoUpdater.markLogError({
|
|
147
|
+
type: "push",
|
|
148
|
+
table,
|
|
149
|
+
lastError: lastError ?? new Error("Unknown error"),
|
|
150
|
+
errorCount: errorCount ?? 0,
|
|
151
|
+
rowsFailed: pending.length,
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
// Gave up this pass — rows left in `pending` will be retried by outer scheduler
|
|
155
|
+
for (const r of pending)
|
|
156
|
+
setQueryStatus(r.id, table, "error");
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Uploads a chunk of data to the remote database
|
|
160
|
+
* @param table - The table to upload to
|
|
161
|
+
* @param unsyncedRecords - The unsynced records to upload
|
|
162
|
+
*/
|
|
163
|
+
export async function uploadData(table, unsyncedRecords, onPushToRemote) {
|
|
164
|
+
const cfg = getSupastashConfig();
|
|
165
|
+
const supabase = cfg.supabaseClient;
|
|
166
|
+
if (!supabase)
|
|
167
|
+
throw new Error("[Supastash] Supabase client not configured");
|
|
168
|
+
const cleaned = unsyncedRecords.map(({ synced_at, deleted_at, arrived_at, ...rest }) => enforceTimestamps(normalizeForSupabase(rest)));
|
|
169
|
+
for (let i = 0; i < cleaned.length; i += DEFAULT_CHUNK_SIZE) {
|
|
170
|
+
const chunk = cleaned.slice(i, i + DEFAULT_CHUNK_SIZE);
|
|
171
|
+
await uploadChunk(table, chunk, onPushToRemote);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { SupastashConfig } from "../../../../shared/types/supastashConfig.types";
|
|
2
|
+
import { RowLike } from "../../../../shared/types/syncEngine.types";
|
|
3
|
+
export declare function classifyFailure(cfg: SupastashConfig<any>, code?: string | number): "HTTP" | "UNKNOWN" | "NON_RETRYABLE" | "FK_BLOCK" | "RETRYABLE";
|
|
4
|
+
declare function batchUpsert(table: string, rows: RowLike[], supabase: any): Promise<any>;
|
|
5
|
+
declare function singleUpsert(table: string, row: RowLike, supabase: any): Promise<any>;
|
|
6
|
+
declare function backoff(attempts: number): Promise<void>;
|
|
7
|
+
declare function rpcUpsert({ table, rows, supabase, }: {
|
|
8
|
+
table: string;
|
|
9
|
+
rows: RowLike[];
|
|
10
|
+
supabase: any;
|
|
11
|
+
}): Promise<{
|
|
12
|
+
data: {
|
|
13
|
+
completed: RowLike[];
|
|
14
|
+
skipped: RowLike[];
|
|
15
|
+
existsMap: Map<string, boolean>;
|
|
16
|
+
};
|
|
17
|
+
error: any;
|
|
18
|
+
}>;
|
|
19
|
+
declare function rpcUpsertSingle({ table, row, supabase, existsMap, }: {
|
|
20
|
+
table: string;
|
|
21
|
+
row: RowLike;
|
|
22
|
+
supabase: any;
|
|
23
|
+
existsMap: Map<string, boolean>;
|
|
24
|
+
}): Promise<{
|
|
25
|
+
data: null;
|
|
26
|
+
error: any;
|
|
27
|
+
} | {
|
|
28
|
+
data: any;
|
|
29
|
+
error: null;
|
|
30
|
+
}>;
|
|
31
|
+
declare function markSynced(table: string, ids: string[]): Promise<void>;
|
|
32
|
+
declare function filterRowsByUpdatedAt(table: string, chunk: RowLike[], remoteHeads: Map<string, string>): RowLike[];
|
|
33
|
+
declare function handleRowFailure(cfg: SupastashConfig<any>, table: string, row: RowLike, err: any, supabase: any): Promise<"DROP" | "KEEP" | "REPLACED">;
|
|
34
|
+
export { backoff, batchUpsert, filterRowsByUpdatedAt, handleRowFailure, markSynced, rpcUpsert, rpcUpsertSingle, singleUpsert, };
|
|
35
|
+
/**
|
|
36
|
+
* Deletes local row and rewinds table watermark so normal pull will fetch server copy.
|
|
37
|
+
* No server read needed.
|
|
38
|
+
*/
|
|
39
|
+
export declare function rewindAndDropLocal(table: string, rowId: string, supabase: any): Promise<void>;
|
|
40
|
+
export declare function fetchRemoteHeadsChunked(table: string, ids: string[], supabase: any): Promise<Map<string, string>>;
|
|
41
|
+
//# sourceMappingURL=uploadHelpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uploadHelpers.d.ts","sourceRoot":"","sources":["../../../../../src/native/utils/sync/pushLocal/uploadHelpers.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,gDAAgD,CAAC;AACjF,OAAO,EAAE,OAAO,EAAE,MAAM,2CAA2C,CAAC;AAOpE,wBAAgB,eAAe,CAC7B,GAAG,EAAE,eAAe,CAAC,GAAG,CAAC,EACzB,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,mEAWvB;AAED,iBAAe,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,QAAQ,EAAE,GAAG,gBAEvE;AAED,iBAAe,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,gBAErE;AAED,iBAAe,OAAO,CAAC,QAAQ,EAAE,MAAM,iBAOtC;AAmBD,iBAAe,SAAS,CAAC,EACvB,KAAK,EACL,IAAI,EACJ,QAAQ,GACT,EAAE;IACD,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,OAAO,EAAE,CAAC;IAChB,QAAQ,EAAE,GAAG,CAAC;CACf;;;;;;;GA+CA;AAED,iBAAe,eAAe,CAAC,EAC7B,KAAK,EACL,GAAG,EACH,QAAQ,EACR,SAAS,GACV,EAAE;IACD,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,OAAO,CAAC;IACb,QAAQ,EAAE,GAAG,CAAC;IACd,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjC;;;;;;GAaA;AAMD,iBAAe,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,iBAIrD;AAWD,iBAAS,qBAAqB,CAC5B,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,OAAO,EAAE,EAChB,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,aAiCjC;AAMD,iBAAe,gBAAgB,CAC7B,GAAG,EAAE,eAAe,CAAC,GAAG,CAAC,EACzB,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,OAAO,EACZ,GAAG,EAAE,GAAG,EACR,QAAQ,EAAE,GAAG,GACZ,OAAO,CAAC,MAAM,GAAG,MAAM,GAAG,UAAU,CAAC,CAkDvC;AAgBD,OAAO,EACL,OAAO,EACP,WAAW,EACX,qBAAqB,EACrB,gBAAgB,EAChB,UAAU,EACV,SAAS,EACT,eAAe,EACf,YAAY,GACb,CAAC;AAEF;;;GAGG;AACH,wBAAsB,kBAAkB,CACtC,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,GAAG,iBAkBd;AASD,wBAAsB,uBAAuB,CAC3C,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,EAAE,EACb,QAAQ,EAAE,GAAG,gCAcd"}
|