( offline: ReturnType<typeof createOfflineExecutor> | null, )
| 117 | } |
| 118 | |
| 119 | export async function clearLocalState( |
| 120 | offline: ReturnType<typeof createOfflineExecutor> | null, |
| 121 | ): Promise<void> { |
| 122 | if (offline) { |
| 123 | await offline.clearOutbox() |
| 124 | } else { |
| 125 | await offlineStorage.clear() |
| 126 | } |
| 127 | |
| 128 | const rows = extractRows( |
| 129 | await executeSql( |
| 130 | `SELECT name FROM sqlite_master WHERE type = 'table' AND name NOT LIKE 'sqlite_%'`, |
| 131 | ), |
| 132 | ) |
| 133 | |
| 134 | await executeSql(`PRAGMA foreign_keys = OFF`) |
| 135 | try { |
| 136 | for (const row of rows) { |
| 137 | const tableName = row.name |
| 138 | if (typeof tableName === `string`) { |
| 139 | await executeSql( |
| 140 | `DROP TABLE IF EXISTS "${tableName.replace(/"/g, `""`)}"`, |
| 141 | ) |
| 142 | } |
| 143 | } |
| 144 | } finally { |
| 145 | await executeSql(`PRAGMA foreign_keys = ON`) |
| 146 | } |
| 147 | } |
| 148 | |
| 149 | export const listsCollection = createCollection( |
| 150 | persistedCollectionOptions< |
no test coverage detected