Skip to content

Commit

Permalink
Revert "add artistdb & songdb"
Browse files Browse the repository at this point in the history
This reverts commit 6a74354.
  • Loading branch information
Schlauer-Hax committed Apr 28, 2024
1 parent 6a74354 commit 20e06ac
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 34 deletions.
10 changes: 5 additions & 5 deletions pages/_legacy/helper.ts
Expand Up @@ -2,7 +2,7 @@ import { API, fileCache, Permission, stupidErrorAlert, Table2 } from "shared/mod
import { asState, Box, Button, Cache, CenterV, Component, Custom, DropDownInput, Horizontal, IconButton, Image, Label, MIcon, SheetDialog, SheetsStack, Spacer, StateHandler, Style, SupportedThemes, TextInput, Vertical } from "webgen/mod.ts";
import { templateArtwork } from "../../assets/imports.ts";
import { loginRequired } from "../../components/pages.ts";
import { ArtistRef, ArtistTypes, Drop } from "../../spec/music.ts";
import { Artist, ArtistTypes, Drop } from "../../spec/music.ts";

export const allowedAudioFormats = ["audio/flac", "audio/wav", "audio/mp3"];
export const allowedImageFormats = ["image/png", "image/jpeg"];
Expand Down Expand Up @@ -185,27 +185,27 @@ export function saveBlob(blob: Blob, fileName: string) {
}

const ARTIST_ARRAY = <ArtistTypes[]> ["PRIMARY", "FEATURING", "PRODUCER", "SONGWRITER"];
export const EditArtistsDialog = (state: StateHandler<{ artists: ArtistRef[] }>) => {
export const EditArtistsDialog = (state: StateHandler<{ artists: Artist[] }>) => {
const dialog = SheetDialog(
sheetStack,
"Manage your Artists",
Vertical(
new Table2(state.$artists)
.addClass("artist-table")
.setColumnTemplate("10rem auto min-content")
.addColumn("Type", (artist: ArtistRef) =>
.addColumn("Type", (artist: Artist) =>
DropDownInput("Type", ARTIST_ARRAY)
.setValue(artist[2])
.onChange((data) => artist[2] = <ArtistTypes> data))
.addColumn("Name", (artist: ArtistRef) =>
.addColumn("Name", (artist: Artist) =>
TextInput("text", "Name", "blur")
.setValue(artist[0])
.onChange((data) => artist[0] = data ?? ""))
.addColumn("", (data) => IconButton(MIcon("delete"), "Delete").onClick(() => state.artists = state.artists.filter((_, i) => i != state.artists.indexOf(data)) as typeof state.artists)),
Horizontal(
Spacer(),
Button("Add Artist")
.onClick(() => state.artists = asState([...state.artists, ["", "", ArtistTypes.Primary]] as ArtistRef[])),
.onClick(() => state.artists = asState([...state.artists, ["", "", ArtistTypes.Primary]] as Artist[])),
).setPadding("0 0 3rem 0"),
Horizontal(
Spacer(),
Expand Down
4 changes: 2 additions & 2 deletions pages/_legacy/music/changeDrop.ts
Expand Up @@ -5,7 +5,7 @@ import { zod } from "webgen/zod.ts";
import { templateArtwork } from "../../../assets/imports.ts";
import genres from "../../../data/genres.json" with { type: "json" };
import language from "../../../data/language.json" with { type: "json" };
import { artistref, DATE_PATTERN, Drop, song, userString } from "../../../spec/music.ts";
import { artist, DATE_PATTERN, Drop, song, userString } from "../../../spec/music.ts";
import { allowedImageFormats, EditArtistsDialog, getSecondary } from "../helper.ts";
import { uploadArtwork } from "./data.ts";

Expand All @@ -20,7 +20,7 @@ export function ChangeDrop(drop: Drop) {
asState(drop),
zod.object({
title: userString,
artists: artistref.array().refine((x) => x.some(({type}) => type == "PRIMARY"), { message: "At least one primary artist is required" }),
artists: artist.array().refine((x) => x.some(([, , type]) => type == "PRIMARY"), { message: "At least one primary artist is required" }),
release: zod.string().regex(DATE_PATTERN, { message: "Not a date" }),
language: zod.string(),
primaryGenre: zod.string(),
Expand Down
4 changes: 2 additions & 2 deletions pages/_legacy/music/data.ts
@@ -1,9 +1,9 @@
import { API, StreamingUploadHandler } from "shared/mod.ts";
import { delay } from "std/async/delay.ts";
import { AdvancedImage, asState, Reference, StateHandler } from "webgen/mod.ts";
import { ArtistRef, Song } from "../../../spec/music.ts";
import { Artist, Song } from "../../../spec/music.ts";

export function uploadSongToDrop(state: StateHandler<{ songs: Song[]; artists: ArtistRef[]; language: string | undefined; primaryGenre: string | undefined; secondaryGenre: string | undefined; _id: string }>, uploadingSongs: Reference<string[]>, file: File) {
export function uploadSongToDrop(state: StateHandler<{ songs: Song[]; artists: Artist[]; language: string | undefined; primaryGenre: string | undefined; secondaryGenre: string | undefined; _id: string }>, uploadingSongs: Reference<string[]>, file: File) {
const uploadId = crypto.randomUUID();
uploadingSongs.addItem(uploadId);

Expand Down
4 changes: 2 additions & 2 deletions pages/_legacy/music/table.ts
Expand Up @@ -2,7 +2,7 @@ import { Progress, Table2 } from "shared/mod.ts";
import { Box, ButtonStyle, Checkbox, Color, DropDownInput, IconButton, Image, InlineTextInput, Label, MIcon, StateHandler } from "webgen/mod.ts";
import genres from "../../../data/genres.json" with { type: "json" };
import language from "../../../data/language.json" with { type: "json" };
import { ArtistRef, Song } from "../../../spec/music.ts";
import { Artist, Song } from "../../../spec/music.ts";
import { EditArtistsDialog, getSecondary, getYearList, ProfilePicture } from "../helper.ts";
import "./table.css";

Expand All @@ -12,7 +12,7 @@ export function ManageSongs(state: StateHandler<{ songs: Song[]; primaryGenre: s
.addColumn("Title", (song) => song.progress !== undefined ? Progress(song.progress) : InlineTextInput("text", "blur").addClass("low-level").sync(song, "title"))
.addColumn("Artists", (song) =>
song.$artists.map((artists) =>
Box(...artists.map(([name, url, _type]: ArtistRef) => ProfilePicture(url ? Image(url, "A profile picture") : Label(""), name)), IconButton(MIcon("add"), "add"))
Box(...artists.map(([name, url, _type]: Artist) => ProfilePicture(url ? Image(url, "A profile picture") : Label(""), name)), IconButton(MIcon("add"), "add"))
.addClass("artists-list")
.onClick(() => EditArtistsDialog(song).open())
).asRefComponent())
Expand Down
4 changes: 2 additions & 2 deletions pages/music/state.ts
@@ -1,6 +1,6 @@
import { AdvancedImage, asState } from "webgen/mod.ts";
import { zod } from "webgen/zod.ts";
import { ArtistRef, Drop, Payout, Song } from "../../spec/music.ts";
import { Artist, Drop, Payout, Song } from "../../spec/music.ts";

export const state = asState({
published: <Drop[] | "loading"> "loading",
Expand All @@ -16,7 +16,7 @@ export const creationState = asState({
title: <string | undefined> undefined,
release: <string | undefined> undefined,
language: <string | undefined> undefined,
artists: <ArtistRef[]> [],
artists: <Artist[]> [],
primaryGenre: <string | undefined> undefined,
secondaryGenre: <string | undefined> undefined,
compositionCopyright: <string | undefined> undefined,
Expand Down
35 changes: 14 additions & 21 deletions spec/music.ts
Expand Up @@ -43,25 +43,17 @@ export enum ReviewResponse {
DeclineMaliciousActivity = "DECLINE_MALICIOUS_ACTIVITY",
}

export const artist = zod.object({
_id: zod.string(),
name: userString,
users: zod.string().array(),
avatar: zod.string().optional(),
});

export const artistref = zod.object({
_id: zod.string(),
type: zod.nativeEnum(ArtistTypes),
});
export const artist = zod.tuple([
userString,
zod.string(),
zod.nativeEnum(ArtistTypes),
]);

export const song = zod.object({
_id: zod.string(),
user: zod.string(),
id: zod.string(),
isrc: zod.string().optional(),
title: userString,
artists: artistref.array().refine((x) => x.some(({ type }) => type == "PRIMARY"), { message: "At least one primary artist is required" }),
primaryGenre: zod.string(),
artists: artist.array().refine((x) => x.some(([, , type]) => type == "PRIMARY"), { message: "At least one primary artist is required" }),
secondaryGenre: zod.string(),
year: zod.number(),
country: zod.string(),
Expand All @@ -70,7 +62,9 @@ export const song = zod.object({
explicit: zod.boolean(),
instrumental: zod.boolean(),
file: zod.string({ required_error: "a Song is missing its file." }),
});
progress: zod.number().optional().transform((x) => <typeof x> undefined),
})
.refine(({ instrumental, explicit }) => !(instrumental && explicit), "Can't have an explicit instrumental song");

export const pureDrop = zod.object({
upc: zod.string().trim().max(0).nullable().or(
Expand All @@ -84,15 +78,15 @@ export const pureDrop = zod.object({
}),
),
title: userString,
artists: artistref.array().refine((x) => x.some(({ type }) => type == "PRIMARY"), { message: "At least one primary artist is required" }),
artists: artist.array().refine((x) => x.some(([, , type]) => type == "PRIMARY"), { message: "At least one primary artist is required" }),
release: zod.string().regex(DATE_PATTERN, { message: "Not a date" }),
language: zod.string(),
primaryGenre: zod.string(),
secondaryGenre: zod.string(),
compositionCopyright: userString,
soundRecordingCopyright: userString,
artwork: zod.string(),
songs: zod.string().array().min(1),
songs: song.array().min(1),
comments: userString.optional(),
});

Expand All @@ -116,7 +110,7 @@ const pageOne = zod.object({

const pageTwo = zod.object({
title: userString,
artists: artistref.array().refine((x) => x.some(({ type }) => type == "PRIMARY"), { message: "At least one primary artist is required" }),
artists: artist.array().refine((x) => x.some(([, , type]) => type == "PRIMARY"), { message: "At least one primary artist is required" }),
release: zod.string().regex(DATE_PATTERN, { message: "Not a date" }),
language: zod.string(),
primaryGenre: zod.string(),
Expand All @@ -134,7 +128,7 @@ const pageFour = zod.object({
});

const pageFive = zod.object({
songs: song.array().min(1, { message: "At least one song is required" }).refine((songs) => songs.every(({ instrumental, explicit }) => !(instrumental && explicit)), "Can't have an explicit instrumental song"),
songs: song.array().min(1, { message: "At least one song is required" }),
uploadingSongs: zod.array(zod.string()).max(0, { message: "Some uploads are still in progress" }),
});

Expand Down Expand Up @@ -619,7 +613,6 @@ export type RequestPayoutResponse = zod.infer<typeof requestPayoutResponse>;
export type SidecarResponse = zod.infer<typeof sidecarResponse>;
export type Addon = zod.infer<typeof addon>;
export type SidecarRequest = zod.infer<typeof sidecarRequest>;
export type ArtistRef = zod.infer<typeof artistref>;
export type Artist = zod.infer<typeof artist>;
export type BugReport = zod.infer<typeof bugReport>;
export type Drop = zod.infer<typeof drop>;
Expand Down

0 comments on commit 20e06ac

Please sign in to comment.