cojson-storage-sqlite
Advanced tools
Comparing version
# cojson-storage-sqlite | ||
## 0.13.32 | ||
### Patch Changes | ||
- Updated dependencies [2bf9743] | ||
- cojson-storage@0.13.32 | ||
## 0.13.31 | ||
@@ -4,0 +11,0 @@ |
@@ -24,3 +24,3 @@ import type { Database as DatabaseT } from "better-sqlite3"; | ||
getSingleCoValueSession(coValueRowId: number, sessionID: SessionID): StoredSessionRow | undefined; | ||
getNewTransactionInSession(sessionRowId: number, firstNewTxIdx: number): TransactionRow[]; | ||
getNewTransactionInSession(sessionRowId: number, fromIdx: number, toIdx: number): TransactionRow[]; | ||
getSignatures(sessionRowId: number, firstNewTxIdx: number): SignatureAfterRow[]; | ||
@@ -27,0 +27,0 @@ addCoValue(msg: CojsonInternalTypes.NewContentMessage): number; |
@@ -43,6 +43,6 @@ import { logger, } from "cojson"; | ||
} | ||
getNewTransactionInSession(sessionRowId, firstNewTxIdx) { | ||
getNewTransactionInSession(sessionRowId, fromIdx, toIdx) { | ||
const txs = this.db | ||
.prepare("SELECT * FROM transactions WHERE ses = ? AND idx >= ?") | ||
.all(sessionRowId, firstNewTxIdx); | ||
.prepare("SELECT * FROM transactions WHERE ses = ? AND idx >= ? AND idx <= ?") | ||
.all(sessionRowId, fromIdx, toIdx); | ||
try { | ||
@@ -49,0 +49,0 @@ return txs.map((transactionRow) => ({ |
@@ -9,2 +9,3 @@ import type { LocalNode, SyncMessage } from "cojson"; | ||
}; | ||
export declare function waitFor(callback: () => boolean | undefined | Promise<boolean | undefined>): Promise<void>; | ||
//# sourceMappingURL=testUtils.d.ts.map |
@@ -33,2 +33,26 @@ import { StorageManagerSync } from "cojson-storage"; | ||
} | ||
export function waitFor(callback) { | ||
return new Promise((resolve, reject) => { | ||
const checkPassed = async () => { | ||
try { | ||
return { ok: await callback(), error: null }; | ||
} | ||
catch (error) { | ||
return { ok: false, error }; | ||
} | ||
}; | ||
let retries = 0; | ||
const interval = setInterval(async () => { | ||
const { ok, error } = await checkPassed(); | ||
if (ok !== false) { | ||
clearInterval(interval); | ||
resolve(); | ||
} | ||
if (++retries > 10) { | ||
clearInterval(interval); | ||
reject(error); | ||
} | ||
}, 100); | ||
}); | ||
} | ||
//# sourceMappingURL=testUtils.js.map |
{ | ||
"name": "cojson-storage-sqlite", | ||
"type": "module", | ||
"version": "0.13.31", | ||
"version": "0.13.32", | ||
"main": "dist/index.js", | ||
@@ -11,3 +11,3 @@ "types": "dist/index.d.ts", | ||
"cojson": "0.13.31", | ||
"cojson-storage": "0.13.31" | ||
"cojson-storage": "0.13.32" | ||
}, | ||
@@ -14,0 +14,0 @@ "devDependencies": { |
@@ -89,9 +89,10 @@ import type { Database as DatabaseT } from "better-sqlite3"; | ||
sessionRowId: number, | ||
firstNewTxIdx: number, | ||
fromIdx: number, | ||
toIdx: number, | ||
): TransactionRow[] { | ||
const txs = this.db | ||
.prepare<[number, number]>( | ||
"SELECT * FROM transactions WHERE ses = ? AND idx >= ?", | ||
.prepare<[number, number, number]>( | ||
"SELECT * FROM transactions WHERE ses = ? AND idx >= ? AND idx <= ?", | ||
) | ||
.all(sessionRowId, firstNewTxIdx) as RawTransactionRow[]; | ||
.all(sessionRowId, fromIdx, toIdx) as RawTransactionRow[]; | ||
@@ -98,0 +99,0 @@ try { |
@@ -45,1 +45,30 @@ import type { LocalNode, SyncMessage } from "cojson"; | ||
} | ||
export function waitFor( | ||
callback: () => boolean | undefined | Promise<boolean | undefined>, | ||
) { | ||
return new Promise<void>((resolve, reject) => { | ||
const checkPassed = async () => { | ||
try { | ||
return { ok: await callback(), error: null }; | ||
} catch (error) { | ||
return { ok: false, error }; | ||
} | ||
}; | ||
let retries = 0; | ||
const interval = setInterval(async () => { | ||
const { ok, error } = await checkPassed(); | ||
if (ok !== false) { | ||
clearInterval(interval); | ||
resolve(); | ||
} | ||
if (++retries > 10) { | ||
clearInterval(interval); | ||
reject(error); | ||
} | ||
}, 100); | ||
}); | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
113033
18.83%1785
23.79%1
Infinity%175
-1.13%14
-12.5%34
-5.56%3
-25%123
-1.6%+ Added
- Removed
Updated