aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-wallet-core/src/util/query.ts
diff options
context:
space:
mode:
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,