Skip to content

Commit

Permalink
fix: fix build failure for next.js minify
Browse files Browse the repository at this point in the history
  • Loading branch information
blueset committed Nov 3, 2023
1 parent 5be469f commit 48b890d
Show file tree
Hide file tree
Showing 23 changed files with 211 additions and 105 deletions.
2 changes: 1 addition & 1 deletion packages/common/src/models/Album.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { Artist } from "./Artist";
import _ from "lodash";

@ObjectType()
@Table
@Table({ modelName: "Album" })
export class Album extends Model<Album, Partial<Album>> {
@Field((type) => Int)
@PrimaryKey
Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/models/Artist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import { GraphQLJSONObject } from "graphql-type-json";
import { SongInAlbum } from "./SongInAlbum";

@ObjectType()
@Table
@Table({ modelName: "Artist" })
export class Artist extends Model<Artist, Partial<Artist>> {
@Field(() => Int)
@PrimaryKey
Expand Down
51 changes: 32 additions & 19 deletions packages/common/src/models/ArtistOfAlbum.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@

import type {
VDBArtistRoleType,
VDBArtistCategoryType,
ArtistForSongContract,
ArtistForAlbumForApiContract
ArtistForAlbumForApiContract,
} from "../types/vocadb";
import { Artist } from "./Artist";
import { Album } from "./Album";
import { Table, Column, PrimaryKey, AutoIncrement, Default, ForeignKey, BelongsTo, CreatedAt, UpdatedAt, DeletedAt, Model } from "sequelize-typescript";
import {
Table,
Column,
PrimaryKey,
AutoIncrement,
Default,
ForeignKey,
BelongsTo,
CreatedAt,
UpdatedAt,
DeletedAt,
Model,
} from "sequelize-typescript";
import { SIMPLE_ENUM_ARRAY } from "../utils/sequelizeAdditions";
import { DataTypes } from "sequelize";
import { Field, Int, ObjectType } from "type-graphql";
Expand All @@ -29,7 +40,7 @@ const ROLES = [
"Mixer",
"Chorus",
"Encoder",
"VocalDataProvider"
"VocalDataProvider",
];
const CATEGORIES = [
"Nothing",
Expand All @@ -41,52 +52,52 @@ const CATEGORIES = [
"Other",
"Band",
"Illustrator",
"Subject"
"Subject",
];

@ObjectType()
@Table
@Table({ modelName: "ArtistOfAlbum" })
export class ArtistOfAlbum extends Model<ArtistOfAlbum> {
@Field(type => Int)
@Field((type) => Int)
@AutoIncrement
@PrimaryKey
@Column({ type: new DataTypes.INTEGER })
@Column({ type: new DataTypes.INTEGER() })
artistOfAlbumId: number;

@Field(type => [String])
@Field((type) => [String])
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
@Column({
type: new SIMPLE_ENUM_ARRAY(ROLES)
type: new SIMPLE_ENUM_ARRAY(ROLES),
})
roles: VDBArtistRoleType[];

@Field(type => [String])
@Field((type) => [String])
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
@Column({
type: new SIMPLE_ENUM_ARRAY(ROLES)
type: new SIMPLE_ENUM_ARRAY(ROLES),
})
effectiveRoles: VDBArtistRoleType[];

@Field(type => String)
@Field((type) => String)
@Default("Nothing")
@Column({
type: DataTypes.ENUM(...CATEGORIES)
type: DataTypes.ENUM(...CATEGORIES),
})
categories: VDBArtistCategoryType;

@BelongsTo(type => Album)
@BelongsTo((type) => Album)
album: Album;

@ForeignKey(type => Album)
@ForeignKey((type) => Album)
@Column
albumId: number;

@BelongsTo(type => Artist)
@BelongsTo((type) => Artist)
artist: Artist;

@ForeignKey(type => Artist)
@ForeignKey((type) => Artist)
@Column
artistId: number;

Expand All @@ -97,7 +108,9 @@ export class ArtistOfAlbum extends Model<ArtistOfAlbum> {
updatedOn: Date;

/** Incomplete build. */
static async artistFromVocaDB(entity: ArtistForAlbumForApiContract): Promise<Artist> {
static async artistFromVocaDB(
entity: ArtistForAlbumForApiContract
): Promise<Artist> {
const artist = await Artist.fromVocaDBArtistContract(entity.artist);
const artistOfAlbumAttrs = {
effectiveRoles: entity.effectiveRoles.split(", ") as VDBArtistRoleType[],
Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/models/ArtistOfSong.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { SIMPLE_ENUM_ARRAY_INVOCABLE } from "../utils/sequelizeAdditions";
import { Field, Int, ObjectType } from "type-graphql";

@ObjectType()
@Table
@Table({ modelName: "ArtistOfSong" })
export class ArtistOfSong extends Model<ArtistOfSong> {
@Field((type) => Int)
@AutoIncrement
Expand Down
12 changes: 3 additions & 9 deletions packages/common/src/models/Entry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { Pulse } from "./Pulse";
import { ObjectType, Field, ID } from "type-graphql";

@ObjectType({ description: "A Lyricova entry." })
@Table
@Table({ modelName: "Entry" })
export class Entry extends Model<Entry> {
@Field()
@AutoIncrement
Expand All @@ -45,10 +45,7 @@ export class Entry extends Model<Entry> {
@Column({ type: new DataTypes.STRING(1024) })
vocalistsName: string;

@BelongsToMany(
() => Song,
() => SongOfEntry
)
@BelongsToMany(() => Song, () => SongOfEntry)
songs: Array<Song & { SongOfEntry: SongOfEntry }>;

@Field()
Expand All @@ -65,10 +62,7 @@ export class Entry extends Model<Entry> {
@Column({ type: "text" })
comment: string;

@BelongsToMany(
() => Tag,
() => TagOfEntry
)
@BelongsToMany(() => Tag, () => TagOfEntry)
tags: Array<Tag & { TagOfEntry: TagOfEntry }>;

@HasMany((type) => Verse)
Expand Down
23 changes: 15 additions & 8 deletions packages/common/src/models/FileInPlaylist.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
import { MusicFile } from "./MusicFile";
import { DataTypes } from "sequelize";
import { Model, CreatedAt, UpdatedAt, Column, Table, PrimaryKey, ForeignKey, AutoIncrement } from "sequelize-typescript";
import {
Model,
CreatedAt,
UpdatedAt,
Column,
Table,
PrimaryKey,
ForeignKey,
AutoIncrement,
} from "sequelize-typescript";
import { Playlist } from "./Playlist";
import { Field, Int, ObjectType } from "type-graphql";

@ObjectType()
@Table
@Table({ modelName: "FileInPlaylist" })
export class FileInPlaylist extends Model<FileInPlaylist> {

@Field(type => Int)
@Field((type) => Int)
@AutoIncrement
@PrimaryKey
@Column({ type: new DataTypes.INTEGER })
@Column({ type: new DataTypes.INTEGER() })
public id!: number;

@ForeignKey(() => MusicFile)
Expand All @@ -22,8 +30,8 @@ export class FileInPlaylist extends Model<FileInPlaylist> {
@Column
playlistId: number;

@Field(type => Int)
@Column({ type: new DataTypes.INTEGER, defaultValue: 0 })
@Field((type) => Int)
@Column({ type: new DataTypes.INTEGER(), defaultValue: 0 })
sortOrder: number;

@Field()
Expand All @@ -33,5 +41,4 @@ export class FileInPlaylist extends Model<FileInPlaylist> {
@Field()
@UpdatedAt
updatedOn: Date;

}
2 changes: 1 addition & 1 deletion packages/common/src/models/FuriganaMapping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
import { Field, ObjectType } from "type-graphql";

@ObjectType()
@Table({ updatedAt: false, createdAt: false })
@Table({ updatedAt: false, createdAt: false, modelName: "FuriganaMapping" })
export class FuriganaMapping extends Model<FuriganaMapping> {
@Field()
@Column({ type: new DataType.STRING(128), primaryKey: true })
Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/models/MusicFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const SONG_ID_TAG = "LyricovaSongID",
export const ID3_LYRICS_LANGUAGE = "eng";

@ObjectType({ description: "A music file in the jukebox." })
@Table
@Table({ modelName: "MusicFile" })
export class MusicFile extends Model<MusicFile, Partial<MusicFile>> {
@Field((type) => Int, { description: "File ID in database." })
@AutoIncrement
Expand Down
17 changes: 10 additions & 7 deletions packages/common/src/models/Playlist.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
import { MusicFile } from "./MusicFile";
import { Table, Model, PrimaryKey, Column, BelongsToMany } from "sequelize-typescript";
import {
Table,
Model,
PrimaryKey,
Column,
BelongsToMany,
} from "sequelize-typescript";
import { DataTypes } from "sequelize";
import { FileInPlaylist } from "./FileInPlaylist";
import { ObjectType, Field, ID } from "type-graphql";

@ObjectType({ description: "A playlist of music files." })
@Table
@Table({ modelName: "Playlist" })
export class Playlist extends Model<Playlist, Partial<Playlist>> {
@Field(type => ID, { description: "Slug of the playlist." })
@Field((type) => ID, { description: "Slug of the playlist." })
@PrimaryKey
@Column({ type: new DataTypes.STRING(512) })
slug: string;
Expand All @@ -16,10 +22,7 @@ export class Playlist extends Model<Playlist, Partial<Playlist>> {
@Column({ type: new DataTypes.STRING(1024) })
name: string;

@BelongsToMany(
type => MusicFile,
intermediate => FileInPlaylist
)
@BelongsToMany((type) => MusicFile, (intermediate) => FileInPlaylist)
files: MusicFile[];

// virtual field in GraphQL
Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/models/Pulse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { Entry } from "./Entry";
import { Field, Int, ObjectType } from "type-graphql";

@ObjectType()
@Table({ updatedAt: false })
@Table({ updatedAt: false, modelName: "Pulse" })
export class Pulse extends Model<Pulse> {
@Field((type) => Int)
@AutoIncrement
Expand Down
3 changes: 1 addition & 2 deletions packages/common/src/models/SiteMeta.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { Table, Model, Column, PrimaryKey } from "sequelize-typescript";
import { DataTypes } from "sequelize";


@Table
@Table({ modelName: "SiteMeta" })
export class SiteMeta extends Model<SiteMeta> {
@PrimaryKey
@Column({ type: new DataTypes.STRING(768) })
Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/models/Song.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { GraphQLJSONObject } from "graphql-type-json";
import _ from "lodash";

@ObjectType()
@Table
@Table({ modelName: "Song" })
export class Song extends Model<Song, Partial<Song>> {
@Field(() => Int)
@PrimaryKey
Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/models/SongInAlbum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { DataTypes } from "sequelize";
import { Field, Int, ObjectType } from "type-graphql";

@ObjectType()
@Table
@Table({ modelName: "SongInAlbum" })
export class SongInAlbum extends Model<SongInAlbum> {
@AutoIncrement
@PrimaryKey
Expand Down
18 changes: 13 additions & 5 deletions packages/common/src/models/SongOfEntry.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
import { DataTypes } from "sequelize";
import { Model, CreatedAt, UpdatedAt, DeletedAt, Column, Table, PrimaryKey, ForeignKey, AutoIncrement } from "sequelize-typescript";
import {
Model,
CreatedAt,
UpdatedAt,
DeletedAt,
Column,
Table,
PrimaryKey,
ForeignKey,
AutoIncrement,
} from "sequelize-typescript";
import { Song } from "./Song";
import { Entry } from "./Entry";

@Table
@Table({ modelName: "SongOfEntry" })
export class SongOfEntry extends Model<SongOfEntry> {

@AutoIncrement
@PrimaryKey
@Column({ type: new DataTypes.INTEGER })
@Column({ type: new DataTypes.INTEGER() })
public id!: number;

@ForeignKey(() => Song)
Expand All @@ -24,5 +33,4 @@ export class SongOfEntry extends Model<SongOfEntry> {

@UpdatedAt
updatedOn: Date;

}
7 changes: 2 additions & 5 deletions packages/common/src/models/Tag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { TagOfEntry } from "./TagOfEntry";
import { Field, ID, ObjectType } from "type-graphql";

@ObjectType()
@Table
@Table({ modelName: "Tag" })
export class Tag extends Model<Tag> {
@Field((type) => ID)
@PrimaryKey
Expand All @@ -26,9 +26,6 @@ export class Tag extends Model<Tag> {
@Column({ type: new DataTypes.STRING(16) })
color: string;

@BelongsToMany(
() => Entry,
() => TagOfEntry
)
@BelongsToMany(() => Entry, () => TagOfEntry)
entries: Entry[];
}
2 changes: 1 addition & 1 deletion packages/common/src/models/TagOfEntry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { Tag } from "./Tag";
import { Field, ID, ObjectType } from "type-graphql";

@ObjectType()
@Table
@Table({ modelName: "TagOfEntry" })
export class TagOfEntry extends Model<TagOfEntry> {
@Field((type) => ID)
@AutoIncrement
Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/models/User.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import crypto from "crypto";
import { ObjectType, Field, Int } from "type-graphql";

@ObjectType()
@Table
@Table({ modelName: "User" })
export class User extends Model<User> {
@Field((type) => Int)
@AutoIncrement
Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/models/UserPublicKeyCredential.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { User } from "./User";
import { ObjectType, Field, Int } from "type-graphql";

@ObjectType()
@Table
@Table({ modelName: "UserPublicKeyCredential" })
export class UserPublicKeyCredential extends Model<UserPublicKeyCredential> {
@Field()
@AutoIncrement
Expand Down
Loading

0 comments on commit 48b890d

Please sign in to comment.