diff --git a/rollup.config.mjs b/rollup.config.mjs index 80bf4e5..1a13bc7 100644 --- a/rollup.config.mjs +++ b/rollup.config.mjs @@ -13,6 +13,9 @@ export default defineConfig( }).map(([name, entry]) => ({ logLevel: 'debug', input: entry, + watch: { + include: 'src/**/*.ts', + }, plugins: [ ...definePlugins({ esm: true, diff --git a/src/acum-work-import/acum.ts b/src/acum-work-import/acum.ts index dbe9c7a..84a7f86 100644 --- a/src/acum-work-import/acum.ts +++ b/src/acum-work-import/acum.ts @@ -14,8 +14,17 @@ type CreatorBase = Bean & { export type Creator = CreatorBase<'org.acum.site.searchdb.dto.bean.CreatorBean'>; +export enum RoleCode { + Composer = 'C', + Author = 'A', + Arranger = 'AR', + Translator = 'AT', + ComposerAndAuthor = 'CA', +} + export type CreatorFull = CreatorBase<'org.acum.site.searchdb.dto.bean.CreatorFullBean'> & { number: string; + roleCode: RoleCode; }; export type Creators = ReadonlyArray; @@ -44,10 +53,11 @@ type AlbumInfoResponse = Response<{ export type WorkVersion = WorkBean & { versionNumber: string; creators: Creators; - authors: ReadonlyArray; - composers: ReadonlyArray; - arrangers: ReadonlyArray | undefined; - translators: ReadonlyArray | undefined; + authors?: ReadonlyArray; + composers?: ReadonlyArray; + arrangers?: ReadonlyArray; + translators?: ReadonlyArray; + composersAndAuthors?: ReadonlyArray; versionIswcNumber: string; versionEssenceType: string; albumTrackNumber: string; diff --git a/src/acum-work-import/artists.ts b/src/acum-work-import/artists.ts index ab1d5b5..6b7059d 100644 --- a/src/acum-work-import/artists.ts +++ b/src/acum-work-import/artists.ts @@ -1,6 +1,6 @@ import {filter, from, lastValueFrom, mergeMap, tap} from 'rxjs'; import {tryFetchJSON} from 'src/common/musicbrainz/fetch'; -import {Creator, CreatorFull, Creators, IPBaseNumber} from './acum'; +import {Creator, CreatorFull, Creators, IPBaseNumber, RoleCode} from './acum'; import {AddWarning} from './ui/warnings'; function nameMatch(creator: CreatorFull, artist: ArtistSearchResultsT['artists'][number]): boolean { @@ -17,6 +17,20 @@ async function findArtist( ): Promise { const artistMBID = await (async () => { const creator = creators.find(creator => creator.creatorIpBaseNumber === ipBaseNumber)!; + const role = (() => { + switch (creator.roleCode) { + case RoleCode.Composer: + return 'composer'; + case RoleCode.Author: + return 'lyricist'; + case RoleCode.Arranger: + return 'arranger'; + case RoleCode.Translator: + return 'translator'; + case RoleCode.ComposerAndAuthor: + return 'composer and lyricist'; + } + })(); const byIpi = await tryFetchJSON(`/ws/2/artist?query=ipi:${creator.number}&limit=1&fmt=json`); if (byIpi && byIpi.artists.length > 0) { return byIpi.artists[0].id; @@ -26,11 +40,11 @@ async function findArtist( `/ws/2/artist?query=name:(${creator.creatorHebName} OR ${creator.creatorEngName})&limit=1&fmt=json` ); if (byName && byName.artists.length > 0 && nameMatch(creator, byName.artists[0])) { - addWarning(`artist ${byName.artists[0].name} found by name search, please verify (IPI = ${creator.number})`); + addWarning(`${role} ${byName.artists[0].name} found by name search, please verify (IPI = ${creator.number})`); return byName.artists[0].id; } - addWarning(`failed to find ${creator.creatorHebName || creator.creatorEngName}, IPI ${creator.number}`); + addWarning(`failed to find ${role} ${creator.creatorHebName || creator.creatorEngName}, IPI ${creator.number}`); return null; })(); diff --git a/src/acum-work-import/import-album.ts b/src/acum-work-import/import-album.ts index 7ca363b..6ddb08d 100644 --- a/src/acum-work-import/import-album.ts +++ b/src/acum-work-import/import-album.ts @@ -49,7 +49,8 @@ export async function importAlbum( work: WorkT, writers: ReadonlyArray | undefined, creators: Creators, - linkTypeId: number + linkTypeId: number, + addWarning: AddWarning ) => { await linkArtists( artistCache, @@ -63,7 +64,8 @@ export async function importAlbum( const linkArrangers = async ( recording: RecordingT, arrangers: ReadonlyArray | undefined, - creators: Creators + creators: Creators, + addWarning: AddWarning ) => { await linkArtists( artistCache, @@ -96,10 +98,11 @@ export async function importAlbum( WorkStateWithEditDataT, ]): Promise => { const work = workState.work; - await linkWriters(work, track.authors, track.creators, LYRICIST_LINK_TYPE_ID); - await linkWriters(work, track.composers, track.creators, COMPOSER_LINK_TYPE_ID); - await linkWriters(work, track.translators, track.creators, TRANSLATOR_LINK_TYPE_ID); - await linkArrangers(recording, track.arrangers, track.creators); + const addWarning = addTrackWarning(track); + await linkWriters(work, track.authors, track.creators, LYRICIST_LINK_TYPE_ID, addWarning); + await linkWriters(work, track.composers, track.creators, COMPOSER_LINK_TYPE_ID, addWarning); + await linkWriters(work, track.translators, track.creators, TRANSLATOR_LINK_TYPE_ID, addWarning); + await linkArrangers(recording, track.arrangers, track.creators, addWarning); return workState; }; @@ -128,7 +131,7 @@ export async function importAlbum( tap(([track, recordingState, addWarning]) => { const recording = recordingState.recording; if (track[searchName(recording.name)] != recording.name) { - addWarning(`Work name of ${recording.name} is different than recording name, please verify`); + addWarning(`Work name of ${recording.name} is different from recording name, please verify`); } }), mergeMap( diff --git a/tsconfig.json b/tsconfig.json index 07794b0..aff47a1 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -28,5 +28,8 @@ }, "include": [ "src/**/*" + ], + "exclude": [ + "src/*/dist/*" ] }