Merge branch 'main' into issue/160-chats-de-ia-en-segundo-plano-para-asignaturas

This commit is contained in:
2026-03-11 22:07:19 +00:00
4 changed files with 1427 additions and 676 deletions
+20 -7
View File
@@ -42,8 +42,19 @@ const EDGE = {
export type BuscarBibliografiaRequest = {
searchTerms: {
q: string
maxResults: number
}
google: {
orderBy?: 'newest' | 'relevance'
langRestrict?: string
startIndex?: number
[k: string]: unknown
}
openLibrary: {
language?: string
page?: number
sort?: string
[k: string]: unknown
}
}
@@ -82,20 +93,22 @@ export type GoogleBooksVolume = {
[k: string]: unknown
}
export type OpenLibraryDoc = Record<string, unknown>
export type EndpointResult =
| { endpoint: 'google'; item: GoogleBooksVolume }
| { endpoint: 'open_library'; item: OpenLibraryDoc }
export async function buscar_bibliografia(
input: BuscarBibliografiaRequest,
): Promise<Array<GoogleBooksVolume>> {
): Promise<Array<EndpointResult>> {
const q = input.searchTerms.q
const maxResults = input.searchTerms.maxResults
if (typeof q !== 'string' || q.trim().length < 1) {
throw new Error('q es requerido')
}
if (!Number.isInteger(maxResults) || maxResults < 0 || maxResults > 40) {
throw new Error('maxResults debe ser entero entre 0 y 40')
}
return await invokeEdge<Array<GoogleBooksVolume>>(
return await invokeEdge<Array<EndpointResult>>(
EDGE.buscar_bibliografia,
input,
{ headers: { 'Content-Type': 'application/json' } },