supastash 0.1.62 → 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 +37 -8
- 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/desktop/utils/fetchData/initialFetch.d.ts +3 -0
- 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 +7 -7
- 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/desktop/utils/sync/pullFromRemote/fetchOlder.d.ts +44 -0
- package/dist/desktop/utils/sync/pullFromRemote/fetchOlder.d.ts.map +1 -0
- package/dist/desktop/utils/sync/pullFromRemote/fetchOlder.js +55 -0
- package/dist/desktop/utils/sync/pullFromRemote/fetchOlderHelpers.d.ts +33 -0
- package/dist/desktop/utils/sync/pullFromRemote/fetchOlderHelpers.d.ts.map +1 -0
- package/dist/desktop/utils/sync/pullFromRemote/fetchOlderHelpers.js +104 -0
- 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 +3 -4
- package/dist/desktop/utils/sync/pullFromRemote/pullData.d.ts.map +1 -0
- package/dist/{utils → desktop/utils}/sync/pullFromRemote/pullData.js +10 -15
- 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 +8 -11
- 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 +7 -7
- package/dist/{utils → desktop/utils}/sync/status/filterKey.d.ts +3 -3
- package/dist/desktop/utils/sync/status/filterKey.d.ts.map +1 -0
- package/dist/desktop/utils/sync/status/filterKey.js +48 -0
- package/dist/desktop/utils/sync/status/repo.d.ts +10 -0
- package/dist/desktop/utils/sync/status/repo.d.ts.map +1 -0
- package/dist/{utils → desktop/utils}/sync/status/repo.js +31 -25
- package/dist/{utils → desktop/utils}/sync/status/services.d.ts +6 -7
- package/dist/desktop/utils/sync/status/services.d.ts.map +1 -0
- package/dist/{utils → desktop/utils}/sync/status/services.js +4 -9
- package/dist/{utils → desktop/utils}/sync/status/syncStatus.d.ts +6 -8
- package/dist/desktop/utils/sync/status/syncStatus.d.ts.map +1 -0
- package/dist/{utils → desktop/utils}/sync/status/syncStatus.js +14 -6
- package/dist/index.d.ts +18 -23
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -21
- 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} +23 -13
- 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/native/utils/sync/pullFromRemote/updateLocalDb.js +278 -0
- 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 +5 -16
- 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 +9 -1
- 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/shared/db/adapters/rn_sqlite_storage.js +93 -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 +3 -3
- package/dist/shared/hooks/supastashFilters/index.d.ts.map +1 -0
- package/dist/{hooks → shared/hooks}/supastashFilters/index.js +6 -4
- 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 +5 -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 +3 -0
- package/dist/shared/store/tx.d.ts.map +1 -0
- package/dist/shared/store/tx.js +1 -0
- package/dist/shared/types/adapters.types.d.ts +8 -0
- package/dist/{types → shared/types}/expoSqlite.types.d.ts +3 -13
- package/dist/{types → shared/types}/index.d.ts +1 -1
- package/dist/shared/types/index.d.ts.map +1 -0
- package/dist/{types → shared/types}/liteQuery.types.d.ts +2 -2
- package/dist/{types → shared/types}/query.types.d.ts +24 -1
- package/dist/{types → shared/types}/realtimeData.types.d.ts +8 -4
- package/dist/{types → shared/types}/supastashConfig.types.d.ts +263 -8
- package/dist/{types → shared/types}/syncEngine.types.d.ts +49 -7
- 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 +6 -0
- package/dist/shared/utils/errorHandler.d.ts.map +1 -0
- package/dist/shared/utils/errorHandler.js +8 -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/createTable.js +38 -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 +8 -5
- package/dist/{utils → shared/utils}/fetchData/fetchLocalData.d.ts +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 +6 -0
- package/dist/shared/utils/fetchData/liteHelpers.d.ts.map +1 -0
- package/dist/shared/utils/fetchData/liteHelpers.js +92 -0
- package/dist/shared/utils/fetchData/realTimeCall.d.ts.map +1 -0
- package/dist/{utils → shared/utils}/fetchData/realTimeCall.js +2 -2
- package/dist/shared/utils/fetchData/realTimeManager.d.ts.map +1 -0
- package/dist/shared/utils/fetchData/registerSub.d.ts +4 -0
- package/dist/shared/utils/fetchData/registerSub.d.ts.map +1 -0
- package/dist/{hooks/supastashData → shared/utils/fetchData}/registerSub.js +3 -3
- 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/{utils → shared/utils}/query/builder/crud.d.ts +5 -5
- package/dist/shared/utils/query/builder/crud.d.ts.map +1 -0
- package/dist/{utils → shared/utils}/query/builder/filters.d.ts +36 -12
- package/dist/shared/utils/query/builder/filters.d.ts.map +1 -0
- package/dist/{utils → shared/utils}/query/builder/filters.js +33 -1
- package/dist/{utils → shared/utils}/query/builder/index.d.ts +29 -1
- package/dist/shared/utils/query/builder/index.d.ts.map +1 -0
- package/dist/shared/utils/query/builder/index.js +138 -0
- package/dist/shared/utils/query/builder/mainQuery.d.ts.map +1 -0
- package/dist/{utils → shared/utils}/query/builder/mainQuery.js +17 -2
- package/dist/shared/utils/query/helpers/localDb/getLocalMethod.d.ts +15 -0
- package/dist/shared/utils/query/helpers/localDb/getLocalMethod.d.ts.map +1 -0
- package/dist/{utils → shared/utils}/query/helpers/localDb/getLocalMethod.js +7 -6
- package/dist/{utils → shared/utils}/query/helpers/localDb/insertMany.d.ts +3 -0
- package/dist/shared/utils/query/helpers/localDb/insertMany.d.ts.map +1 -0
- package/dist/{utils → shared/utils}/query/helpers/localDb/insertMany.js +10 -3
- package/dist/shared/utils/query/helpers/localDb/localQueryBuilder.d.ts +34 -0
- package/dist/shared/utils/query/helpers/localDb/localQueryBuilder.d.ts.map +1 -0
- package/dist/{utils → shared/utils}/query/helpers/localDb/localQueryBuilder.js +17 -10
- package/dist/{utils → shared/utils}/query/helpers/localDb/upsertMany.d.ts +3 -0
- package/dist/shared/utils/query/helpers/localDb/upsertMany.d.ts.map +1 -0
- package/dist/{utils → shared/utils}/query/helpers/localDb/upsertMany.js +9 -2
- package/dist/shared/utils/query/helpers/mainQueryHelpers.d.ts.map +1 -0
- package/dist/{utils → shared/utils}/query/helpers/mainQueryHelpers.js +39 -9
- 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 +36 -27
- 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 +22 -0
- package/dist/shared/utils/query/localDbQuery/delete.d.ts.map +1 -0
- package/dist/{utils → shared/utils}/query/localDbQuery/delete.js +16 -5
- package/dist/shared/utils/query/localDbQuery/index.d.ts.map +1 -0
- package/dist/shared/utils/query/localDbQuery/index.js +15 -0
- package/dist/shared/utils/query/localDbQuery/insert.d.ts +10 -0
- package/dist/shared/utils/query/localDbQuery/insert.d.ts.map +1 -0
- package/dist/{utils → shared/utils}/query/localDbQuery/insert.js +8 -5
- package/dist/{utils → shared/utils}/query/localDbQuery/select.d.ts +2 -2
- package/dist/shared/utils/query/localDbQuery/select.d.ts.map +1 -0
- package/dist/{utils → shared/utils}/query/localDbQuery/select.js +5 -2
- package/dist/shared/utils/query/localDbQuery/update.d.ts +11 -0
- package/dist/shared/utils/query/localDbQuery/update.d.ts.map +1 -0
- package/dist/{utils → shared/utils}/query/localDbQuery/update.js +7 -4
- package/dist/shared/utils/query/localDbQuery/upsert.d.ts +9 -0
- package/dist/shared/utils/query/localDbQuery/upsert.d.ts.map +1 -0
- package/dist/{utils → shared/utils}/query/localDbQuery/upsert.js +8 -3
- package/dist/shared/utils/query/remoteQuery/supabaseQuery.d.ts.map +1 -0
- package/dist/{utils → shared/utils}/query/remoteQuery/supabaseQuery.js +5 -2
- package/dist/shared/utils/refreshScreenCalls.d.ts.map +1 -0
- package/dist/shared/utils/reusedHelpers.d.ts +8 -0
- package/dist/shared/utils/reusedHelpers.d.ts.map +1 -0
- package/dist/shared/utils/reusedHelpers.js +162 -0
- package/dist/shared/utils/schema/createSyncStatus.d.ts +19 -0
- package/dist/shared/utils/schema/createSyncStatus.d.ts.map +1 -0
- package/dist/{utils → shared/utils}/schema/createSyncStatus.js +30 -3
- 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/{utils → shared/utils}/sync/pullFromRemote/helpers.d.ts +10 -7
- package/dist/shared/utils/sync/pullFromRemote/helpers.d.ts.map +1 -0
- package/dist/{utils → shared/utils}/sync/pullFromRemote/helpers.js +20 -14
- 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/{utils → shared/utils}/sync/pullFromRemote/updateFilter.d.ts +1 -1
- package/dist/shared/utils/sync/pullFromRemote/updateFilter.d.ts.map +1 -0
- package/dist/{utils → shared/utils}/sync/pullFromRemote/updateFilter.js +5 -3
- package/dist/shared/utils/sync/pullFromRemote/validateFilters.d.ts +3 -0
- package/dist/shared/utils/sync/pullFromRemote/validateFilters.d.ts.map +1 -0
- package/dist/shared/utils/sync/pullFromRemote/validateFilters.js +49 -0
- package/dist/shared/utils/sync/pushLocal/deleteChunks.d.ts.map +1 -0
- package/dist/{utils → shared/utils}/sync/pushLocal/deleteChunks.js +7 -5
- package/dist/shared/utils/sync/pushLocal/getAllUnsyncedData.d.ts.map +1 -0
- package/dist/shared/utils/sync/pushLocal/getAllUnsyncedData.js +53 -0
- 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 +4 -0
- package/dist/shared/utils/sync/status/remoteSchema.d.ts.map +1 -0
- package/dist/shared/utils/sync/status/remoteSchema.js +140 -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 +29 -12
- 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 -24
- 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 -34
- 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/adapters/rn_sqlite_storage.js +0 -25
- 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 +0 -4
- 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 -117
- 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 +0 -5
- package/dist/store/tableFilters.d.ts.map +0 -1
- package/dist/store/tableSchemaData.d.ts.map +0 -1
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/supastashFilters.types.d.ts +0 -3
- 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/events/eventBus.d.ts.map +0 -1
- package/dist/utils/fetchData/buildFilter.d.ts +0 -4
- 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/createTable.js +0 -81
- 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 +0 -3
- package/dist/utils/fetchData/initialFetch.d.ts.map +0 -1
- package/dist/utils/fetchData/liteHelpers.d.ts +0 -6
- package/dist/utils/fetchData/liteHelpers.d.ts.map +0 -1
- package/dist/utils/fetchData/liteHelpers.js +0 -197
- 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/index.js +0 -62
- package/dist/utils/query/builder/mainQuery.d.ts.map +0 -1
- package/dist/utils/query/helpers/localDb/getLocalMethod.d.ts +0 -15
- 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 +0 -34
- 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 +0 -16
- 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/index.js +0 -15
- package/dist/utils/query/localDbQuery/insert.d.ts +0 -10
- 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 +0 -11
- package/dist/utils/query/localDbQuery/update.d.ts.map +0 -1
- package/dist/utils/query/localDbQuery/upsert.d.ts +0 -9
- 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/schema/createSyncStatus.d.ts +0 -17
- 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/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 -12
- 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 -14
- package/dist/utils/sync/pullFromRemote/updateLocalDb.d.ts.map +0 -1
- package/dist/utils/sync/pullFromRemote/updateLocalDb.js +0 -200
- package/dist/utils/sync/pullFromRemote/validateFilters.d.ts +0 -5
- package/dist/utils/sync/pullFromRemote/validateFilters.d.ts.map +0 -1
- package/dist/utils/sync/pullFromRemote/validateFilters.js +0 -103
- 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/getAllUnsyncedData.js +0 -85
- 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/repo.d.ts +0 -10
- 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}/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.js +0 -0
- /package/dist/{store → shared/store}/tableSchemaData.d.ts +0 -0
- /package/dist/{store → shared/store}/tableSchemaData.js +0 -0
- /package/dist/{types → shared/types}/index.js +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/{utils → shared/utils}/connection.d.ts +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/{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.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/realTimeCall.d.ts +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/{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.js +0 -0
- /package/dist/{utils → shared/utils}/query/builder/mainQuery.d.ts +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/index.d.ts +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}/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/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/pushLocal/deleteChunks.d.ts +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/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,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"}
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
import { getSupastashConfig } from "../../../../shared/core/config";
|
|
2
|
+
import { getSupastashDb } from "../../../../shared/db/dbInitializer";
|
|
3
|
+
import { supastashEventBus } from "../../../../shared/utils/events/eventBus";
|
|
4
|
+
import log, { logWarn } from "../../../../shared/utils/logs";
|
|
5
|
+
import { setQueryStatus } from "../../../../shared/utils/sync/queryStatus";
|
|
6
|
+
import { updateLocalSyncedAt } from "../../../../shared/utils/sync/status/syncUpdate";
|
|
7
|
+
import { upsertData } from "../pullFromRemote/updateLocalDb";
|
|
8
|
+
export function classifyFailure(cfg, code) {
|
|
9
|
+
const p = cfg.syncPolicy ?? {};
|
|
10
|
+
const n = Number(code);
|
|
11
|
+
if (n === 409 || n === 412)
|
|
12
|
+
return "HTTP";
|
|
13
|
+
if (code == null)
|
|
14
|
+
return "UNKNOWN";
|
|
15
|
+
const s = String(code);
|
|
16
|
+
if (p.nonRetryableCodes?.has?.(s))
|
|
17
|
+
return "NON_RETRYABLE";
|
|
18
|
+
if (s === (p.fkCode ?? "23503"))
|
|
19
|
+
return "FK_BLOCK";
|
|
20
|
+
if (p.retryableCodes?.has?.(s))
|
|
21
|
+
return "RETRYABLE";
|
|
22
|
+
return "UNKNOWN";
|
|
23
|
+
}
|
|
24
|
+
async function batchUpsert(table, rows, supabase) {
|
|
25
|
+
return await supabase.from(table).upsert(rows);
|
|
26
|
+
}
|
|
27
|
+
async function singleUpsert(table, row, supabase) {
|
|
28
|
+
return await supabase.from(table).upsert(row).select("id").maybeSingle();
|
|
29
|
+
}
|
|
30
|
+
async function backoff(attempts) {
|
|
31
|
+
const config = getSupastashConfig();
|
|
32
|
+
const schedule = config.syncPolicy?.backoffDelaysMs ?? [
|
|
33
|
+
10000, 30000, 120000, 300000, 600000,
|
|
34
|
+
];
|
|
35
|
+
const delay = schedule[Math.min(attempts - 1, schedule.length - 1)];
|
|
36
|
+
await new Promise((r) => setTimeout(r, delay));
|
|
37
|
+
}
|
|
38
|
+
async function fetchServerRowById(table, id, supabase) {
|
|
39
|
+
const { data } = await supabase
|
|
40
|
+
.from(table)
|
|
41
|
+
.select("*")
|
|
42
|
+
.eq("id", id)
|
|
43
|
+
.maybeSingle();
|
|
44
|
+
return data ?? null;
|
|
45
|
+
}
|
|
46
|
+
/* ────────────────────────────────────────────────────────────────────────── *
|
|
47
|
+
* RPC Upsert
|
|
48
|
+
* ────────────────────────────────────────────────────────────────────────── */
|
|
49
|
+
function setPending(table, rows) {
|
|
50
|
+
for (const row of rows) {
|
|
51
|
+
setQueryStatus(row.id, table, "pending");
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
async function rpcUpsert({ table, rows, supabase, }) {
|
|
55
|
+
const cfg = getSupastashConfig();
|
|
56
|
+
if (!cfg.pushRPCPath) {
|
|
57
|
+
throw new Error("pushRPCPath is not configured. Please configure it in the Supastash config. You can find more information in the Supastash docs: https://0xzekea.github.io/supastash/docs/sync-calls#%EF%B8%8F-pushrpcpath-custom-batch-sync-rpc");
|
|
58
|
+
}
|
|
59
|
+
setPending(table, rows);
|
|
60
|
+
const columns = Object.keys(rows[0]);
|
|
61
|
+
const { data, error } = await supabase.rpc(cfg.pushRPCPath, {
|
|
62
|
+
target_table: table,
|
|
63
|
+
payload: rows,
|
|
64
|
+
columns,
|
|
65
|
+
});
|
|
66
|
+
const mappedRows = new Map();
|
|
67
|
+
for (const row of rows) {
|
|
68
|
+
mappedRows.set(row.id, row);
|
|
69
|
+
}
|
|
70
|
+
const skipped = [];
|
|
71
|
+
const completed = [];
|
|
72
|
+
const existsMap = new Map();
|
|
73
|
+
for (const row of data ?? []) {
|
|
74
|
+
if (row.action === "skipped") {
|
|
75
|
+
if (row.reason === "stale_remote") {
|
|
76
|
+
void acceptServerAndStopRetrying(table, row.id);
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
const localRow = mappedRows.get(row.id);
|
|
80
|
+
if (localRow) {
|
|
81
|
+
skipped.push(localRow);
|
|
82
|
+
existsMap.set(localRow.id, !!row.record_exists);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
completed.push(row);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return {
|
|
90
|
+
data: {
|
|
91
|
+
completed,
|
|
92
|
+
skipped,
|
|
93
|
+
existsMap,
|
|
94
|
+
},
|
|
95
|
+
error: error ?? null,
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
async function rpcUpsertSingle({ table, row, supabase, existsMap, }) {
|
|
99
|
+
const rowExist = existsMap.get(row.id) ?? false;
|
|
100
|
+
const { data, error } = rowExist
|
|
101
|
+
? await supabase
|
|
102
|
+
.from(table)
|
|
103
|
+
.update(row)
|
|
104
|
+
.eq("id", row.id)
|
|
105
|
+
.select("id")
|
|
106
|
+
.maybeSingle()
|
|
107
|
+
: await supabase.from(table).insert(row).select("id").maybeSingle();
|
|
108
|
+
if (error)
|
|
109
|
+
return { data: null, error };
|
|
110
|
+
return { data, error: null };
|
|
111
|
+
}
|
|
112
|
+
/* ────────────────────────────────────────────────────────────────────────── *
|
|
113
|
+
* Local side-effects (shared)
|
|
114
|
+
* ────────────────────────────────────────────────────────────────────────── */
|
|
115
|
+
async function markSynced(table, ids) {
|
|
116
|
+
await updateLocalSyncedAt(table, ids);
|
|
117
|
+
for (const id of ids)
|
|
118
|
+
setQueryStatus(id, table, "success");
|
|
119
|
+
supastashEventBus.emit("updateSyncStatus");
|
|
120
|
+
}
|
|
121
|
+
async function acceptServerAndStopRetrying(table, id) {
|
|
122
|
+
await updateLocalSyncedAt(table, [id]);
|
|
123
|
+
setQueryStatus(id, table, "success");
|
|
124
|
+
}
|
|
125
|
+
/* ────────────────────────────────────────────────────────────────────────── *
|
|
126
|
+
* Pre-filter: decide which local rows are worth pushing (server-wins on time)
|
|
127
|
+
* ────────────────────────────────────────────────────────────────────────── */
|
|
128
|
+
function filterRowsByUpdatedAt(table, chunk, remoteHeads) {
|
|
129
|
+
const toPush = [];
|
|
130
|
+
const cfg = getSupastashConfig();
|
|
131
|
+
const defaultDate = cfg.fieldEnforcement?.autoFillDefaultISO ?? "1970-01-01T00:00:00Z";
|
|
132
|
+
for (const row of chunk) {
|
|
133
|
+
const id = row?.id;
|
|
134
|
+
const updatedAt = row?.updated_at ?? defaultDate;
|
|
135
|
+
if (!id || !updatedAt) {
|
|
136
|
+
// Skip bad input silently but mark visible status for debugging.
|
|
137
|
+
setQueryStatus(id ?? "UNKNOWN", table, "error");
|
|
138
|
+
continue;
|
|
139
|
+
}
|
|
140
|
+
const remoteUpdatedAt = remoteHeads.get(id) ?? defaultDate;
|
|
141
|
+
const localTs = new Date(updatedAt);
|
|
142
|
+
const remoteTs = new Date(remoteUpdatedAt);
|
|
143
|
+
if (remoteTs > localTs) {
|
|
144
|
+
// Server newer -> accept server; stop retrying this row
|
|
145
|
+
void acceptServerAndStopRetrying(table, id);
|
|
146
|
+
continue;
|
|
147
|
+
}
|
|
148
|
+
setQueryStatus(id, table, "pending");
|
|
149
|
+
toPush.push(row);
|
|
150
|
+
}
|
|
151
|
+
return toPush;
|
|
152
|
+
}
|
|
153
|
+
/* ────────────────────────────────────────────────────────────────────────── *
|
|
154
|
+
* Per-row conflict handling
|
|
155
|
+
* ────────────────────────────────────────────────────────────────────────── */
|
|
156
|
+
async function handleRowFailure(cfg, table, row, err, supabase) {
|
|
157
|
+
const code = (err?.code ?? err?.status);
|
|
158
|
+
const klass = classifyFailure(cfg, code);
|
|
159
|
+
if (klass === "NON_RETRYABLE") {
|
|
160
|
+
const action = cfg.syncPolicy?.onNonRetryable ?? "accept-server";
|
|
161
|
+
if (action === "delete-local" || cfg.deleteConflictedRows) {
|
|
162
|
+
logWarn(`Row ${row.id} on ${table} hit NON_RETRYABLE conflict → deleting local`, JSON.stringify(err));
|
|
163
|
+
await deleteLocalRow(table, row.id, supabase);
|
|
164
|
+
return "DROP";
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
logWarn(`Row ${row.id} on ${table} hit NON_RETRYABLE conflict → accepting server`, JSON.stringify(err));
|
|
168
|
+
await deleteLocalRow(table, row.id, supabase);
|
|
169
|
+
cfg.syncPolicy?.onRowAcceptedServer?.(table, row.id);
|
|
170
|
+
return "DROP";
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
if (klass === "FK_BLOCK") {
|
|
174
|
+
// Parent missing (23503) -> KEEP for later;
|
|
175
|
+
log(`Row ${row.id} on ${table} blocked by missing parent (FK) → will retry`, JSON.stringify(err));
|
|
176
|
+
setQueryStatus(row.id, table, "error");
|
|
177
|
+
return "KEEP";
|
|
178
|
+
}
|
|
179
|
+
if (klass === "HTTP" || klass === "RETRYABLE" || klass === "UNKNOWN") {
|
|
180
|
+
log(`Row ${row.id} on ${table} transient/HTTP error → scheduling retry`, JSON.stringify(err));
|
|
181
|
+
if (klass === "HTTP") {
|
|
182
|
+
await deleteLocalRow(table, row.id, supabase);
|
|
183
|
+
return "REPLACED";
|
|
184
|
+
}
|
|
185
|
+
setQueryStatus(row.id, table, "error");
|
|
186
|
+
return "KEEP";
|
|
187
|
+
}
|
|
188
|
+
setQueryStatus(row.id, table, "error");
|
|
189
|
+
return "KEEP";
|
|
190
|
+
}
|
|
191
|
+
function quoteIdent(name) {
|
|
192
|
+
if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(name)) {
|
|
193
|
+
throw new Error(`[Supastash] Invalid table identifier: ${name}`);
|
|
194
|
+
}
|
|
195
|
+
return `"${name.replace(/"/g, '""')}"`;
|
|
196
|
+
}
|
|
197
|
+
async function deleteLocalRow(table, id, supabase) {
|
|
198
|
+
await rewindAndDropLocal(table, id, supabase);
|
|
199
|
+
setQueryStatus(id, table, "success");
|
|
200
|
+
supastashEventBus.emit("updateSyncStatus");
|
|
201
|
+
}
|
|
202
|
+
export { backoff, batchUpsert, filterRowsByUpdatedAt, handleRowFailure, markSynced, rpcUpsert, rpcUpsertSingle, singleUpsert, };
|
|
203
|
+
/**
|
|
204
|
+
* Deletes local row and rewinds table watermark so normal pull will fetch server copy.
|
|
205
|
+
* No server read needed.
|
|
206
|
+
*/
|
|
207
|
+
export async function rewindAndDropLocal(table, rowId, supabase) {
|
|
208
|
+
const server = await fetchServerRowById(table, rowId, supabase);
|
|
209
|
+
if (server) {
|
|
210
|
+
await replaceLocalWithServer(table, server);
|
|
211
|
+
}
|
|
212
|
+
else {
|
|
213
|
+
const db = await getSupastashDb();
|
|
214
|
+
// 1) Delete local copy
|
|
215
|
+
await db.runAsync(`DELETE FROM ${quoteIdent(table)} WHERE id = ?`, [rowId]);
|
|
216
|
+
const cfg = getSupastashConfig();
|
|
217
|
+
cfg.syncPolicy?.onRowDroppedLocal?.(table, rowId);
|
|
218
|
+
logWarn(`[Supastash] REPLACED: dropped local ${table}:${rowId}
|
|
219
|
+
`);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
async function replaceLocalWithServer(table, serverRow) {
|
|
223
|
+
await upsertData({ table, record: serverRow });
|
|
224
|
+
await updateLocalSyncedAt(table, [serverRow.id]);
|
|
225
|
+
setQueryStatus(serverRow.id, table, "success");
|
|
226
|
+
supastashEventBus.emit("updateSyncStatus");
|
|
227
|
+
}
|
|
228
|
+
export async function fetchRemoteHeadsChunked(table, ids, supabase) {
|
|
229
|
+
const CHUNK = 1000;
|
|
230
|
+
const map = new Map();
|
|
231
|
+
for (let i = 0; i < ids.length; i += CHUNK) {
|
|
232
|
+
const slice = ids.slice(i, i + CHUNK);
|
|
233
|
+
const { data, error } = await supabase
|
|
234
|
+
.from(table)
|
|
235
|
+
.select("id,updated_at")
|
|
236
|
+
.in("id", slice);
|
|
237
|
+
if (error)
|
|
238
|
+
throw error;
|
|
239
|
+
for (const r of data ?? [])
|
|
240
|
+
map.set(r.id, r.updated_at);
|
|
241
|
+
}
|
|
242
|
+
return map;
|
|
243
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { SupastashFilter } from "../../../../shared/types/realtimeData.types";
|
|
2
|
+
/**
|
|
3
|
+
* Canonicalizes a set of filters
|
|
4
|
+
* @param filters - The filters to canonicalize
|
|
5
|
+
* @returns The canonicalized filters
|
|
6
|
+
*/
|
|
7
|
+
export declare function canonicalizeFilters(filters?: SupastashFilter[] | null): string;
|
|
8
|
+
/**
|
|
9
|
+
* Computes the filter key for a given set of filters
|
|
10
|
+
* @param filters - The filters to compute the key for
|
|
11
|
+
* @param ns - The namespace to use for the key
|
|
12
|
+
* @returns The computed filter key
|
|
13
|
+
*/
|
|
14
|
+
export declare function computeFilterKey(filters?: SupastashFilter[] | null, ns?: string): Promise<string>;
|
|
15
|
+
//# sourceMappingURL=filterKey.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filterKey.d.ts","sourceRoot":"","sources":["../../../../../src/native/utils/sync/status/filterKey.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,6CAA6C,CAAC;AAa9E;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,CAAC,EAAE,eAAe,EAAE,GAAG,IAAI,GACjC,MAAM,CAuBR;AAED;;;;;GAKG;AACH,wBAAsB,gBAAgB,CACpC,OAAO,CAAC,EAAE,eAAe,EAAE,GAAG,IAAI,EAClC,EAAE,SAAW,mBAQd"}
|
|
@@ -1,18 +1,4 @@
|
|
|
1
1
|
import * as ExpoCrypto from "expo-crypto";
|
|
2
|
-
// let sha256: (s: string) => Promise<string>;
|
|
3
|
-
// try {
|
|
4
|
-
// const crypto = require("react-native-quick-crypto");
|
|
5
|
-
// if (crypto.createHash) {
|
|
6
|
-
// sha256 = async (msg) =>
|
|
7
|
-
// crypto.createHash("sha256").update(msg).digest("hex");
|
|
8
|
-
// } else {
|
|
9
|
-
// throw new Error("createHash not available");
|
|
10
|
-
// }
|
|
11
|
-
// } catch {
|
|
12
|
-
// const ExpoCrypto = require("expo-crypto");
|
|
13
|
-
// sha256 = (msg) =>
|
|
14
|
-
// ExpoCrypto.digestStringAsync(ExpoCrypto.CryptoDigestAlgorithm.SHA256, msg);
|
|
15
|
-
// }
|
|
16
2
|
/**
|
|
17
3
|
* Normalizes a value
|
|
18
4
|
* @param v - The value to normalize
|
|
@@ -31,7 +17,9 @@ function normVal(v) {
|
|
|
31
17
|
* @returns The canonicalized filters
|
|
32
18
|
*/
|
|
33
19
|
export function canonicalizeFilters(filters) {
|
|
34
|
-
const list = (filters ?? [])
|
|
20
|
+
const list = (filters ?? [])
|
|
21
|
+
.filter((f) => !!f && typeof f === "object" && "column" in f && "operator" in f)
|
|
22
|
+
.map((f) => ({
|
|
35
23
|
column: String(f.column),
|
|
36
24
|
operator: f.operator,
|
|
37
25
|
value: normVal(f.value),
|
|
@@ -41,7 +29,8 @@ export function canonicalizeFilters(filters) {
|
|
|
41
29
|
return a.column < b.column ? -1 : 1;
|
|
42
30
|
if (a.operator !== b.operator)
|
|
43
31
|
return a.operator < b.operator ? -1 : 1;
|
|
44
|
-
const av = JSON.stringify(a.value)
|
|
32
|
+
const av = JSON.stringify(a.value);
|
|
33
|
+
const bv = JSON.stringify(b.value);
|
|
45
34
|
return av < bv ? -1 : av > bv ? 1 : 0;
|
|
46
35
|
});
|
|
47
36
|
return JSON.stringify(list);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { SupastashFilter } from "../../../../shared/types/realtimeData.types";
|
|
2
|
+
import { SupastashSQLiteDatabase } from "../../../../shared/types/supastashConfig.types";
|
|
3
|
+
import { SupastashSyncStatus } from "../../../../shared/types/syncEngine.types";
|
|
4
|
+
export declare function ensureSyncMarksTable(): Promise<void>;
|
|
5
|
+
export declare function selectMarks(db: SupastashSQLiteDatabase, table: string, filterKey: string): Promise<SupastashSyncStatus | null>;
|
|
6
|
+
export declare function selectSyncStatus(db: SupastashSQLiteDatabase, table: string, tableFilters?: SupastashFilter[]): Promise<SupastashSyncStatus>;
|
|
7
|
+
export declare function upsertMarks(db: SupastashSQLiteDatabase, row: Partial<SupastashSyncStatus>): Promise<any>;
|
|
8
|
+
export declare function resetColumn(db: SupastashSQLiteDatabase, table: string, filterKey: string, col: "last_synced_at" | "last_deleted_at", value: string, filterJson: string): Promise<any>;
|
|
9
|
+
export declare function deleteMarks(db: SupastashSQLiteDatabase, table: string, filterKey?: string): Promise<any>;
|
|
10
|
+
//# sourceMappingURL=repo.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"repo.d.ts","sourceRoot":"","sources":["../../../../../src/native/utils/sync/status/repo.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,6CAA6C,CAAC;AAC9E,OAAO,EAAE,uBAAuB,EAAE,MAAM,gDAAgD,CAAC;AACzF,OAAO,EAAE,mBAAmB,EAAE,MAAM,2CAA2C,CAAC;AAuDhF,wBAAsB,oBAAoB,kBAEzC;AAED,wBAAsB,WAAW,CAC/B,EAAE,EAAE,uBAAuB,EAC3B,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,MAAM,uCAOlB;AAED,wBAAsB,gBAAgB,CACpC,EAAE,EAAE,uBAAuB,EAC3B,KAAK,EAAE,MAAM,EACb,YAAY,CAAC,EAAE,eAAe,EAAE,GAC/B,OAAO,CAAC,mBAAmB,CAAC,CAoB9B;AAED,wBAAsB,WAAW,CAC/B,EAAE,EAAE,uBAAuB,EAC3B,GAAG,EAAE,OAAO,CAAC,mBAAmB,CAAC,gBA8BlC;AAED,wBAAsB,WAAW,CAC/B,EAAE,EAAE,uBAAuB,EAC3B,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,MAAM,EACjB,GAAG,EAAE,gBAAgB,GAAG,iBAAiB,EACzC,KAAK,EAAE,MAAM,EACb,UAAU,EAAE,MAAM,gBAYnB;AAED,wBAAsB,WAAW,CAC/B,EAAE,EAAE,uBAAuB,EAC3B,KAAK,EAAE,MAAM,EACb,SAAS,CAAC,EAAE,MAAM,gBASnB"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { getSupastashConfig } from "../../../../shared/core/config";
|
|
2
|
+
import { logWarn } from "../../../../shared/utils/logs";
|
|
3
|
+
import { createSyncStatusTable } from "../../../../shared/utils/schema/createSyncStatus";
|
|
4
|
+
import { computeFilterKey } from "./filterKey";
|
|
5
|
+
const OLD_DATE = "2000-01-01T00:00:00Z";
|
|
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
|
+
const cleanDate = ({ date, table, column, }) => {
|
|
15
|
+
const original = date || OLD_DATE;
|
|
16
|
+
const d = new Date(original);
|
|
17
|
+
if (Number.isNaN(d?.getTime?.())) {
|
|
18
|
+
logWarn(`[Supastash] Invalid date string found on the ${column} column for ${table}: ${original}`);
|
|
19
|
+
return original;
|
|
20
|
+
}
|
|
21
|
+
return original;
|
|
22
|
+
};
|
|
23
|
+
const cleanSyncStatus = (syncStatus) => {
|
|
24
|
+
const cfg = getSupastashConfig();
|
|
25
|
+
const lastSyncedAtColumn = cfg.replicationMode === "server-side" ? "arrived_at" : "updated_at";
|
|
26
|
+
return {
|
|
27
|
+
...syncStatus,
|
|
28
|
+
last_synced_at: cleanDate({
|
|
29
|
+
date: syncStatus.last_synced_at,
|
|
30
|
+
table: syncStatus.table_name,
|
|
31
|
+
column: lastSyncedAtColumn,
|
|
32
|
+
}),
|
|
33
|
+
last_deleted_at: cleanDate({
|
|
34
|
+
date: syncStatus.last_deleted_at || OLD_DATE,
|
|
35
|
+
table: syncStatus.table_name,
|
|
36
|
+
column: "deleted_at",
|
|
37
|
+
}),
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
export async function ensureSyncMarksTable() {
|
|
41
|
+
await createSyncStatusTable();
|
|
42
|
+
}
|
|
43
|
+
export async function selectMarks(db, table, filterKey) {
|
|
44
|
+
const syncStatusTable = getSyncStatusTable();
|
|
45
|
+
return db.getFirstAsync(`SELECT * FROM ${syncStatusTable} WHERE table_name=? AND filter_key=?`, [table, filterKey]);
|
|
46
|
+
}
|
|
47
|
+
export async function selectSyncStatus(db, table, tableFilters) {
|
|
48
|
+
const filterKey = await computeFilterKey(tableFilters ?? []);
|
|
49
|
+
const syncStatusTable = getSyncStatusTable();
|
|
50
|
+
const result = await db.getFirstAsync(`SELECT * FROM ${syncStatusTable} WHERE table_name=? AND filter_key=?`, [table, filterKey]);
|
|
51
|
+
if (result) {
|
|
52
|
+
return cleanSyncStatus(result);
|
|
53
|
+
}
|
|
54
|
+
return {
|
|
55
|
+
table_name: table,
|
|
56
|
+
filter_key: filterKey,
|
|
57
|
+
filter_json: "{}",
|
|
58
|
+
last_synced_at: OLD_DATE,
|
|
59
|
+
last_synced_at_pk: null,
|
|
60
|
+
last_deleted_at: OLD_DATE,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
export async function upsertMarks(db, row) {
|
|
64
|
+
const { table_name, filter_key, filter_json = null, last_synced_at = null, last_deleted_at = null, last_synced_at_pk = null, } = row;
|
|
65
|
+
const syncStatusTable = getSyncStatusTable();
|
|
66
|
+
return db.runAsync(`INSERT INTO ${syncStatusTable}
|
|
67
|
+
(table_name, filter_key, filter_json, last_synced_at, last_deleted_at, updated_at, last_synced_at_pk)
|
|
68
|
+
VALUES (?,?,?,?,?,datetime('now'),?)
|
|
69
|
+
ON CONFLICT(table_name, filter_key) DO UPDATE SET
|
|
70
|
+
filter_json = excluded.filter_json,
|
|
71
|
+
last_synced_at = COALESCE(excluded.last_synced_at, ${syncStatusTable}.last_synced_at),
|
|
72
|
+
last_deleted_at = COALESCE(excluded.last_deleted_at, ${syncStatusTable}.last_deleted_at),
|
|
73
|
+
updated_at = datetime('now'),
|
|
74
|
+
last_synced_at_pk = COALESCE(excluded.last_synced_at_pk, ${syncStatusTable}.last_synced_at_pk)`, [
|
|
75
|
+
table_name,
|
|
76
|
+
filter_key,
|
|
77
|
+
filter_json,
|
|
78
|
+
last_synced_at,
|
|
79
|
+
last_deleted_at,
|
|
80
|
+
last_synced_at_pk,
|
|
81
|
+
]);
|
|
82
|
+
}
|
|
83
|
+
export async function resetColumn(db, table, filterKey, col, value, filterJson) {
|
|
84
|
+
const syncStatusTable = getSyncStatusTable();
|
|
85
|
+
return db.runAsync(`INSERT INTO ${syncStatusTable} (table_name, filter_key, filter_json, ${col}, updated_at)
|
|
86
|
+
VALUES (?,?,?,?,datetime('now'))
|
|
87
|
+
ON CONFLICT(table_name, filter_key) DO UPDATE SET
|
|
88
|
+
filter_json = excluded.filter_json,
|
|
89
|
+
${col} = excluded.${col},
|
|
90
|
+
updated_at = datetime('now')`, [table, filterKey, filterJson, value]);
|
|
91
|
+
}
|
|
92
|
+
export async function deleteMarks(db, table, filterKey) {
|
|
93
|
+
const syncStatusTable = getSyncStatusTable();
|
|
94
|
+
return filterKey
|
|
95
|
+
? db.runAsync(`DELETE FROM ${syncStatusTable} WHERE table_name=? AND filter_key=?`, [table, filterKey])
|
|
96
|
+
: db.runAsync(`DELETE FROM ${syncStatusTable} WHERE table_name=?`, [table]);
|
|
97
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { SupastashFilter } from "../../../../shared/types/realtimeData.types";
|
|
2
|
+
import { PublicScope, SupastashSyncStatus } from "../../../../shared/types/syncEngine.types";
|
|
3
|
+
/**
|
|
4
|
+
* Gets the supastash sync status for a given table and filters
|
|
5
|
+
* @param table - The name of the table to get the sync status for
|
|
6
|
+
* @param filters - The filters to apply to the sync status
|
|
7
|
+
* @returns The supastash sync status
|
|
8
|
+
*/
|
|
9
|
+
export declare function getSupastashSyncStatus(table: string, filters?: SupastashFilter[]): Promise<SupastashSyncStatus | null>;
|
|
10
|
+
export declare function setSupastashSyncStatus(table: string, filters: SupastashFilter[] | undefined, opts: {
|
|
11
|
+
lastSyncedAt?: string | null;
|
|
12
|
+
lastDeletedAt?: string | null;
|
|
13
|
+
lastSyncedAtPk?: string | null;
|
|
14
|
+
filterNamespace?: string;
|
|
15
|
+
}): Promise<void>;
|
|
16
|
+
/**
|
|
17
|
+
* Resets the supastash sync status for a given table and filters
|
|
18
|
+
* @param table - The name of the table to reset the sync status for
|
|
19
|
+
* @param filters - The filters to apply to the sync status
|
|
20
|
+
* @param scope - The scope to reset the sync status for
|
|
21
|
+
* @returns The supastash sync status
|
|
22
|
+
*/
|
|
23
|
+
export declare function resetSupastashSyncStatus(table: string, filters: SupastashFilter[] | undefined, scope?: PublicScope): Promise<void>;
|
|
24
|
+
/**
|
|
25
|
+
* Clears the supastash sync status for a given table and filters
|
|
26
|
+
* @param table - The name of the table to clear the sync status for
|
|
27
|
+
* @param filters - The filters to apply to the sync status
|
|
28
|
+
* @returns The supastash sync status
|
|
29
|
+
*/
|
|
30
|
+
export declare function clearSupastashSyncStatus(table: string, filters?: SupastashFilter[]): Promise<void>;
|
|
31
|
+
//# sourceMappingURL=services.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"services.d.ts","sourceRoot":"","sources":["../../../../../src/native/utils/sync/status/services.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,6CAA6C,CAAC;AAC9E,OAAO,EACL,WAAW,EACX,mBAAmB,EACpB,MAAM,2CAA2C,CAAC;AAmBnD;;;;;GAKG;AACH,wBAAsB,sBAAsB,CAC1C,KAAK,EAAE,MAAM,EACb,OAAO,CAAC,EAAE,eAAe,EAAE,GAC1B,OAAO,CAAC,mBAAmB,GAAG,IAAI,CAAC,CAWrC;AAED,wBAAsB,sBAAsB,CAC1C,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,eAAe,EAAE,GAAG,SAAS,EACtC,IAAI,EAAE;IACJ,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,iBAyCF;AAED;;;;;;GAMG;AACH,wBAAsB,wBAAwB,CAC5C,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,eAAe,EAAE,GAAG,SAAS,EACtC,KAAK,GAAE,WAAmB,iBAmB3B;AAED;;;;;GAKG;AACH,wBAAsB,wBAAwB,CAC5C,KAAK,EAAE,MAAM,EACb,OAAO,CAAC,EAAE,eAAe,EAAE,iBAY5B"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { getSupastashDb } from "../../../../shared/db/dbInitializer";
|
|
2
|
+
import { tableFilters } from "../../../../shared/store/tableFilters";
|
|
3
|
+
import { logError, logWarn } from "../../../../shared/utils/logs";
|
|
4
|
+
import { canonicalizeFilters, computeFilterKey } from "./filterKey";
|
|
5
|
+
import { deleteMarks, ensureSyncMarksTable, resetColumn, selectMarks, upsertMarks, } from "./repo";
|
|
6
|
+
const maxIso = (a, b) => {
|
|
7
|
+
if (!a)
|
|
8
|
+
return b ?? null;
|
|
9
|
+
if (!b)
|
|
10
|
+
return a ?? null;
|
|
11
|
+
return Date.parse(b) > Date.parse(a) ? b : a;
|
|
12
|
+
};
|
|
13
|
+
const OLD_DATE = "2000-01-01T00:00:00Z";
|
|
14
|
+
/**
|
|
15
|
+
* Gets the supastash sync status for a given table and filters
|
|
16
|
+
* @param table - The name of the table to get the sync status for
|
|
17
|
+
* @param filters - The filters to apply to the sync status
|
|
18
|
+
* @returns The supastash sync status
|
|
19
|
+
*/
|
|
20
|
+
export async function getSupastashSyncStatus(table, filters) {
|
|
21
|
+
try {
|
|
22
|
+
const filterToUse = filters ?? tableFilters.get(table) ?? [];
|
|
23
|
+
const db = await getSupastashDb();
|
|
24
|
+
await ensureSyncMarksTable();
|
|
25
|
+
const fk = await computeFilterKey(filterToUse);
|
|
26
|
+
return await selectMarks(db, table, fk);
|
|
27
|
+
}
|
|
28
|
+
catch (e) {
|
|
29
|
+
logError(`[Supastash] getMarks(${table}) failed`, e);
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
export async function setSupastashSyncStatus(table, filters, opts) {
|
|
34
|
+
try {
|
|
35
|
+
const db = await getSupastashDb();
|
|
36
|
+
await ensureSyncMarksTable();
|
|
37
|
+
const filterToUse = filters ?? tableFilters.get(table) ?? [];
|
|
38
|
+
const ns = opts.filterNamespace ?? "global";
|
|
39
|
+
const fk = await computeFilterKey(filterToUse, ns);
|
|
40
|
+
const filterJson = canonicalizeFilters(filterToUse);
|
|
41
|
+
const existing = await selectMarks(db, table, fk);
|
|
42
|
+
const nextLastSynced = opts.lastSyncedAt !== undefined
|
|
43
|
+
? maxIso(opts.lastSyncedAt, existing?.last_synced_at ?? null)
|
|
44
|
+
: existing?.last_synced_at ?? null;
|
|
45
|
+
const nextLastDeleted = opts.lastDeletedAt !== undefined
|
|
46
|
+
? maxIso(opts.lastDeletedAt, existing?.last_deleted_at ?? null)
|
|
47
|
+
: existing?.last_deleted_at ?? null;
|
|
48
|
+
await upsertMarks(db, {
|
|
49
|
+
table_name: table,
|
|
50
|
+
filter_key: fk,
|
|
51
|
+
filter_json: filterJson,
|
|
52
|
+
last_synced_at_pk: opts.lastSyncedAtPk ?? undefined,
|
|
53
|
+
last_synced_at: nextLastSynced ?? undefined,
|
|
54
|
+
last_deleted_at: nextLastDeleted ?? undefined,
|
|
55
|
+
});
|
|
56
|
+
if (!opts.lastSyncedAt && !opts.lastDeletedAt) {
|
|
57
|
+
logWarn(`[Supastash] setSupastashSyncStatus(${table}): no fields provided`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
catch (e) {
|
|
61
|
+
logError(`[Supastash] setSupastashSyncStatus(${table}) failed`, e);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Resets the supastash sync status for a given table and filters
|
|
66
|
+
* @param table - The name of the table to reset the sync status for
|
|
67
|
+
* @param filters - The filters to apply to the sync status
|
|
68
|
+
* @param scope - The scope to reset the sync status for
|
|
69
|
+
* @returns The supastash sync status
|
|
70
|
+
*/
|
|
71
|
+
export async function resetSupastashSyncStatus(table, filters, scope = "all") {
|
|
72
|
+
try {
|
|
73
|
+
const db = await getSupastashDb();
|
|
74
|
+
await ensureSyncMarksTable();
|
|
75
|
+
const filterToUse = filters ?? tableFilters.get(table) ?? [];
|
|
76
|
+
const fk = await computeFilterKey(filterToUse);
|
|
77
|
+
const filterJson = canonicalizeFilters(filterToUse);
|
|
78
|
+
if (scope === "all") {
|
|
79
|
+
await resetColumn(db, table, fk, "last_synced_at", OLD_DATE, filterJson);
|
|
80
|
+
await resetColumn(db, table, fk, "last_deleted_at", OLD_DATE, filterJson);
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
await resetColumn(db, table, fk, scope, OLD_DATE, filterJson);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
catch (e) {
|
|
87
|
+
logError(`[Supastash] resetMarks(${table}, ${scope}) failed`, e);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Clears the supastash sync status for a given table and filters
|
|
92
|
+
* @param table - The name of the table to clear the sync status for
|
|
93
|
+
* @param filters - The filters to apply to the sync status
|
|
94
|
+
* @returns The supastash sync status
|
|
95
|
+
*/
|
|
96
|
+
export async function clearSupastashSyncStatus(table, filters) {
|
|
97
|
+
try {
|
|
98
|
+
const filterToUse = filters ?? tableFilters.get(table) ?? [];
|
|
99
|
+
const db = await getSupastashDb();
|
|
100
|
+
await ensureSyncMarksTable();
|
|
101
|
+
const fk = filterToUse ? await computeFilterKey(filterToUse) : undefined;
|
|
102
|
+
await deleteMarks(db, table, fk);
|
|
103
|
+
}
|
|
104
|
+
catch (e) {
|
|
105
|
+
logError(`[Supastash] clearMarks(${table}) failed`, e);
|
|
106
|
+
}
|
|
107
|
+
}
|