Add api source

This commit is contained in:
Geomitron
2024-05-04 03:20:54 -05:00
parent d57d8bcc9f
commit 3f72d21470
3 changed files with 6 additions and 0 deletions

View File

@@ -205,6 +205,7 @@ export class SearchBarComponent implements OnInit, AfterViewInit {
this.searchService.advancedSearch({
instrument: this.instrument,
difficulty: this.difficulty,
source: 'bridge' as const,
...this.advancedSearchForm.getRawValue(),
}).subscribe()
}

View File

@@ -86,6 +86,7 @@ export class SearchService {
page: this.currentPage,
instrument: this.instrument.value,
difficulty: this.difficulty.value,
source: 'bridge',
}).pipe(
catchError((err, caught) => {
if (err.status === 400 || retries-- <= 0) {

View File

@@ -3,11 +3,14 @@ import { z } from 'zod'
import { difficulties, instruments, Overwrite } from '../UtilFunctions'
export const sources = ['website', 'bridge'] as const
export const GeneralSearchSchema = z.object({
search: z.string(),
page: z.number().positive(),
instrument: z.enum(instruments).nullable(),
difficulty: z.enum(difficulties).nullable(),
source: z.enum(sources).optional(),
})
export type GeneralSearch = z.infer<typeof GeneralSearchSchema>
@@ -22,6 +25,7 @@ export const AdvancedSearchSchema = z.object({
return true
}, { message: 'Invalid instrument list' }).nullable(),
difficulty: z.enum(difficulties).nullable(),
source: z.enum(sources).optional(),
name: z.object({ value: z.string(), exact: z.boolean(), exclude: z.boolean() }),
artist: z.object({ value: z.string(), exact: z.boolean(), exclude: z.boolean() }),
album: z.object({ value: z.string(), exact: z.boolean(), exclude: z.boolean() }),