aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-wallet-core/src/util/query.ts
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2023-08-29 20:35:49 +0200
committerFlorian Dold <florian@dold.me>2023-08-29 20:35:49 +0200
commit1ad2f4cbe9d231f7f2324b37ae0e0cc97fbb1216 (patch)
tree56805ba034ef49b5ce0eded277420020d13f6e4e /packages/taler-wallet-core/src/util/query.ts
parenta386de8a9c1aa3fff76b4cb37fb3287213981387 (diff)
downloadwallet-core-1ad2f4cbe9d231f7f2324b37ae0e0cc97fbb1216.tar.xz
wallet-core: do p2p coin selection based on coin availability records
Diffstat (limited to 'packages/taler-wallet-core/src/util/query.ts')
-rw-r--r--packages/taler-wallet-core/src/util/query.ts40
1 files changed, 40 insertions, 0 deletions
diff --git a/packages/taler-wallet-core/src/util/query.ts b/packages/taler-wallet-core/src/util/query.ts
index 527cbdf63..71f80f8aa 100644
--- a/packages/taler-wallet-core/src/util/query.ts
+++ b/packages/taler-wallet-core/src/util/query.ts
@@ -429,6 +429,46 @@ export type GetReadOnlyAccess<BoundStores> = {
: unknown;
};
+export type StoreNames<StoreMap> = StoreMap extends {
+ [P in keyof StoreMap]: StoreWithIndexes<infer SN1, infer SD1, infer IM1>;
+}
+ ? keyof StoreMap
+ : unknown;
+
+export type DbReadOnlyTransaction<
+ StoreMap,
+ Stores extends StoreNames<StoreMap> & string,
+> = StoreMap extends {
+ [P in Stores]: StoreWithIndexes<infer SN1, infer SD1, infer IM1>;
+}
+ ? {
+ [P in Stores]: StoreMap[P] extends StoreWithIndexes<
+ infer SN,
+ infer SD,
+ infer IM
+ >
+ ? StoreReadOnlyAccessor<GetRecordType<SD>, IM>
+ : unknown;
+ }
+ : unknown;
+
+export type DbReadWriteTransaction<
+ StoreMap,
+ Stores extends StoreNames<StoreMap> & string,
+> = StoreMap extends {
+ [P in Stores]: StoreWithIndexes<infer SN1, infer SD1, infer IM1>;
+}
+ ? {
+ [P in Stores]: StoreMap[P] extends StoreWithIndexes<
+ infer SN,
+ infer SD,
+ infer IM
+ >
+ ? StoreReadWriteAccessor<GetRecordType<SD>, IM>
+ : unknown;
+ }
+ : unknown;
+
export type GetReadWriteAccess<BoundStores> = {
[P in keyof BoundStores]: BoundStores[P] extends StoreWithIndexes<
infer SN,