Support user and team preferences (#4081)
* feat: support user preferences * feat: support team preferences * fix: update snapshots * feat: update last visited url by user * fix: update snapshots * fix: use path instead of complete url * fix: do not expose preferences to other users with the exception of admin * feat: support defaultDocumentStatus as a team preference * feat: allow edit even when collaborative editing is enabled * Revert "feat: allow edit even when collaborative editing is enabled" This reverts commit a22a02a406d01eb418dab32249b8b846bf77c59b. * Revert "feat: support defaultDocumentStatus as a team preference" This reverts commit 4928cffe5c682952b1e469a3e50a1a34d05dcc58. * fix: keep preference as a boolean
This commit is contained in:
@@ -33,6 +33,21 @@ export const assertIn = (
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Asserts that an object contains no other keys than specified
|
||||
* by a type
|
||||
*
|
||||
* @param obj The object to check for assertion
|
||||
* @param type The type to check against
|
||||
* @throws {ValidationError}
|
||||
*/
|
||||
export function assertKeysIn(
|
||||
obj: Record<string, unknown>,
|
||||
type: { [key: string]: number | string }
|
||||
) {
|
||||
Object.keys(obj).forEach((key) => assertIn(key, Object.values(type)));
|
||||
}
|
||||
|
||||
export const assertSort = (
|
||||
value: string,
|
||||
model: any,
|
||||
@@ -78,6 +93,24 @@ export function assertUrl(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts that the passed value is a valid boolean
|
||||
*
|
||||
* @param value The value to check for assertion
|
||||
* @param [message] The error message to show
|
||||
* @throws {ValidationError}
|
||||
*/
|
||||
export function assertBoolean(
|
||||
value: IncomingValue,
|
||||
message?: string
|
||||
): asserts value {
|
||||
if (typeof value !== "boolean") {
|
||||
throw ValidationError(
|
||||
message ?? `${String(value)} is a ${typeof value}, not a boolean!`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export function assertUuid(
|
||||
value: IncomingValue,
|
||||
message?: string
|
||||
|
||||
Reference in New Issue
Block a user