Login page design
This commit is contained in:
67
packages/common/src/db.ts
Normal file
67
packages/common/src/db.ts
Normal file
@@ -0,0 +1,67 @@
|
||||
import { Schema as S } from "@effect/schema";
|
||||
import { AttachmentId, BooleanFromNumber, PieceId, RequestId, SessionId, Sha256, UserId } from "common";
|
||||
import { Brand as B, pipe } from "effect";
|
||||
|
||||
export const SystemInformation = S.Struct({
|
||||
createdBy: S.Union(UserId, S.Null),
|
||||
createdAt: S.DateTimeUtc,
|
||||
modifiedBy: S.Union(UserId, S.Null),
|
||||
modifiedAt: S.DateTimeUtc,
|
||||
});
|
||||
|
||||
export type SystemInformation = typeof SystemInformation.Type;
|
||||
|
||||
// --- TABLES ------------------------------------------------------------------
|
||||
|
||||
export const AccessLog = S.Struct({
|
||||
timestamp: S.DateTimeUtc,
|
||||
requestId: RequestId,
|
||||
method: S.NonEmptyString,
|
||||
pathname: S.NonEmptyString,
|
||||
query: S.parseJson(S.Record({
|
||||
key: S.String,
|
||||
value: S.String,
|
||||
})),
|
||||
ip: S.Union(S.NonEmptyString, S.Null),
|
||||
});
|
||||
|
||||
export const Attachment = pipe(
|
||||
S.Struct({
|
||||
attachmentId: AttachmentId,
|
||||
pieceId: PieceId,
|
||||
sha256: Sha256,
|
||||
filename: S.NonEmptyString,
|
||||
mediaType: S.NonEmptyString,
|
||||
}),
|
||||
S.extend(SystemInformation),
|
||||
);
|
||||
|
||||
export const Piece = pipe(
|
||||
S.Struct({
|
||||
pieceId: PieceId,
|
||||
name: S.NonEmptyString,
|
||||
composer: S.Union(S.NonEmptyString, S.Null),
|
||||
lyricist: S.Union(S.NonEmptyString, S.Null),
|
||||
arranger: S.Union(S.NonEmptyString, S.Null),
|
||||
}),
|
||||
S.extend(SystemInformation),
|
||||
);
|
||||
|
||||
export const Session = S.Struct({
|
||||
sessionId: SessionId,
|
||||
userId: UserId,
|
||||
expiresAt: S.DateTimeUtc,
|
||||
});
|
||||
|
||||
export const User = S.Struct({
|
||||
userId: UserId,
|
||||
username: S.NonEmptyString,
|
||||
password: S.NonEmptyString,
|
||||
admin: BooleanFromNumber,
|
||||
});
|
||||
|
||||
export type AccessLog = typeof AccessLog.Type;
|
||||
export type Attachment = typeof Attachment.Type;
|
||||
export type Piece = typeof Piece.Type;
|
||||
export type Session = typeof Session.Type;
|
||||
export type User = typeof User.Type;
|
||||
Reference in New Issue
Block a user