mirror of
https://github.com/gristlabs/grist-core.git
synced 2024-10-27 20:44:07 +00:00
16ebc32611
Context HomeDBManager lacks of direct tests, which makes hard to make rework or refactorations. Proposed solution Specifically here, I introduce tests which call exposed UsersManager methods directly and check their result. Also: I removed updateUserName which seems to me useless (updateUser does the same work) Taking a look at the getUserByLogin methods, it appears that Typescirpt infers it returns a Promise<User|null> while in no case it may resolve a nullish value, therefore I have forced to return a Promise<User> and have changed the call sites to reflect the change. Related issues I make this change for then working on #870
41 lines
1.2 KiB
TypeScript
41 lines
1.2 KiB
TypeScript
import { UserProfile } from "app/common/LoginSessionAPI";
|
|
import { UserOptions } from "app/common/UserAPI";
|
|
import * as roles from 'app/common/roles';
|
|
import { Document } from "app/gen-server/entity/Document";
|
|
import { Group } from "app/gen-server/entity/Group";
|
|
import { Organization } from "app/gen-server/entity/Organization";
|
|
import { Workspace } from "app/gen-server/entity/Workspace";
|
|
|
|
import { EntityManager } from "typeorm";
|
|
|
|
export interface QueryResult<T> {
|
|
status: number;
|
|
data?: T;
|
|
errMessage?: string;
|
|
}
|
|
|
|
export interface GetUserOptions {
|
|
manager?: EntityManager;
|
|
profile?: UserProfile;
|
|
userOptions?: UserOptions;
|
|
}
|
|
|
|
export interface UserProfileChange {
|
|
name?: string;
|
|
isFirstTimeUser?: boolean;
|
|
}
|
|
|
|
// A specification of the users available during a request. This can be a single
|
|
// user, identified by a user id, or a collection of profiles (typically drawn from
|
|
// the session).
|
|
export type AvailableUsers = number | UserProfile[];
|
|
|
|
export type NonGuestGroup = Group & { name: roles.NonGuestRole };
|
|
|
|
export type Resource = Organization|Workspace|Document;
|
|
|
|
export type RunInTransaction = <T>(
|
|
transaction: EntityManager|undefined,
|
|
op: ((manager: EntityManager) => Promise<T>)
|
|
) => Promise<T>;
|