Switch to internally managed roles, adapt frontend
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { pipe, Schema } from "effect";
|
||||
import * as Api from "./Api";
|
||||
import { AttachmentId, PieceId, RepertoireId, Sha256, UserId } from "common";
|
||||
import { pipe, Schema } from "effect";
|
||||
import { constant } from "effect/Function";
|
||||
import * as Api from "./Api";
|
||||
|
||||
// --- MARK: COMMON TYPES ------------------------------------------------------
|
||||
|
||||
@@ -27,17 +27,6 @@ export type Pagination = typeof Pagination.Type;
|
||||
|
||||
// --- MARK: RESPONSE TYPES ----------------------------------------------------
|
||||
|
||||
export const Me = Schema.Struct({
|
||||
userId: UserId,
|
||||
displayName: Schema.NonEmptyString,
|
||||
roles: Schema.HashSet(Schema.Enums(Role)),
|
||||
});
|
||||
|
||||
export const Other = Schema.Struct({
|
||||
userId: UserId,
|
||||
displayName: Schema.NonEmptyString,
|
||||
});
|
||||
|
||||
export const Attachment = Schema.Struct({
|
||||
attachmentId: AttachmentId,
|
||||
pieceId: PieceId,
|
||||
@@ -82,14 +71,20 @@ export const Repertoire_Query = Schema.Struct({
|
||||
name: pipe(Schema.NonEmptyString, Schema.optionalWith({ as: "Option", exact: true })),
|
||||
}).pipe(Schema.extend(Pagination));
|
||||
|
||||
export type Me = typeof Me.Type;
|
||||
export type Other = typeof Other.Type;
|
||||
export const User = Schema.Struct({
|
||||
userId: UserId,
|
||||
displayName: pipe(Schema.NonEmptyString, Schema.optionalWith({ as: "Option", exact: true })),
|
||||
avatarUrl: pipe(Schema.NonEmptyString, Schema.optionalWith({ as: "Option", exact: true })),
|
||||
roles: Schema.HashSet(Schema.Enums(Role)),
|
||||
});
|
||||
|
||||
export type Attachment = typeof Attachment.Type;
|
||||
export type Piece = typeof Piece.Type;
|
||||
export type Piece_Create = typeof Piece_Create.Type;
|
||||
export type Piece_Query = typeof Piece_Query.Type;
|
||||
export type Repertoire = typeof Repertoire.Type;
|
||||
export type Repertoire_Query = typeof Repertoire_Query.Type;
|
||||
export type User = typeof User.Type;
|
||||
|
||||
// --- MARK: ERROR TYPES -------------------------------------------------------
|
||||
|
||||
@@ -105,11 +100,11 @@ export default Api.bundle({
|
||||
|
||||
// --- Authentication ---
|
||||
|
||||
me: Api.make(Schema.Void, Me, Unauthenticated),
|
||||
me: Api.make(Schema.Void, User, Unauthenticated),
|
||||
logout: Api.make(Schema.Void, Schema.Void),
|
||||
getUser: Api.make(
|
||||
UserId,
|
||||
Other,
|
||||
User,
|
||||
Schema.Union(Unauthenticated, NotFound),
|
||||
),
|
||||
|
||||
|
||||
Reference in New Issue
Block a user