message: Tweak NEdB datastore types
diff: @@ -171,7 +171,9 @@ export class NeDBDataStore implements DataStore {
  * $roomId => [{networkId: 'server #channel1', channel: '#channel2'} , ...]
  */
  public async getAllChannelMappings(): Promise<ChannelMappings> {
  - const entries = await this.roomStore.select<unknown, Entry>(
  + const entries = await this.roomStore.select<
  + unknown,
  + { remote: { domain: string; channel: string}; matrix_id: string}>(
  {
  matrix_id: {$exists: true},
  remote_id: {$exists: true},
  @@ -181,22 +183,17 @@ export class NeDBDataStore implements DataStore {
  const mappings: ChannelMappings = {};
  - entries.forEach((e) => {
  - const domain = e.remote?.get<string>("domain");
  - const channel = e.remote?.get<string>("channel");
  - const matrixId = e.matrix?.getId();
  - if (!domain || !channel || !matrixId) {
  - // Unexpected undefined value, do not process.
  - return;
  - }
  + entries.forEach(e => {
  + const domain = e.remote.domain;
  + const channel = e.remote.channel;
  // drop unknown irc networks in the database
  if (!this.serverMappings[domain]) {
  return;
  }
  - if (!mappings[matrixId]) {
  - mappings[matrixId] = [];
  + if (!mappings[e.matrix_id]) {
  + mappings[e.matrix_id] = [];
  }
  - mappings[matrixId].push({
  + mappings[e.matrix_id].push({
  networkId: this.serverMappings[domain].getNetworkId(),
  channel,
  });
  @@ -274,9 +271,9 @@ export class NeDBDataStore implements DataStore {
  // filter out rooms with unknown IRC servers and
  // map RemoteRooms to IrcRooms
  roomIdToRemoteRooms[roomId] = linkedRemoteRooms[roomId].filter((remoteRoom) => {
  - return Boolean(this.serverMappings[remoteRoom.get<string>("domain")]);
  + return Boolean(this.serverMappings[remoteRoom.get("domain") as string]);
  }).map((remoteRoom) => {
  - const server = this.serverMappings[remoteRoom.get<string>("domain")];
  + const server = this.serverMappings[remoteRoom.get("domain") as string];
  return IrcRoom.fromRemoteRoom(server, remoteRoom);
  });
  }
  @@ -489,10 +486,7 @@ export class NeDBDataStore implements DataStore {
  public async getAdminRoomByUserId(userId: string): Promise<MatrixRoom|null> {
  const entry = await this.roomStore.getEntryById(NeDBDataStore.createAdminId(userId));
  - if (!entry) {
  - return null;
  - }
  - return entry.matrix || null;
  + return entry?.matrix || null;
  }
  public async storeMatrixUser(matrixUser: MatrixUser): Promise<void> {
  @@ -632,19 +626,19 @@ export class NeDBDataStore implements DataStore {
  }
  public async getLastSeenTimeForUsers() {
  - const docs = await this.userStore.select<unknown, MatrixUser>({
  + const docs = await this.userStore.select<unknown, {id: string; data: { last_seen_ts: number }}>({
  type: "matrix",
  "data.last_seen_ts": {$exists: true},
  });
  return docs.map(doc => ({
  - user_id: doc.userId,
  - ts: doc.get<number>("last_seen_ts"),
  + user_id: doc.id,
  + ts: doc.data.last_seen_ts,
  }));
  }
  public async getAllUserIds() {
  - const docs = await this.userStore.select<unknown, MatrixUser>({ type: "matrix" });
  - return docs.map(e => e.userId);
  + const docs = await this.userStore.select<unknown, {id: string}>({ type: "matrix" });
  + return docs.map(e => e.id);
  }
  public async getRoomVisibility(roomId: string) {
  