@@ -5,20 +5,37 @@ import { FastifySchema } from 'fastify';
55
66import { ItemType , TagCategory } from '@graasp/sdk' ;
77
8- import { customType } from '../../../../../../../plugins/typebox' ;
8+ import { customType , registerSchemaAsRef } from '../../../../../../../plugins/typebox' ;
99import { errorSchemaRef } from '../../../../../../../schemas/global' ;
1010import {
1111 GET_MOST_LIKED_ITEMS_MAXIMUM ,
1212 GET_MOST_RECENT_ITEMS_MAXIMUM ,
1313} from '../../../../../../../utils/config' ;
1414
15- const meilisearchSearchResponseSchema = customType . StrictObject ( {
16- totalHits : Type . Optional ( Type . Number ( ) ) ,
17- estimatedTotalHits : Type . Optional ( Type . Number ( ) ) ,
18- processingTimeMs : Type . Number ( ) ,
19- query : Type . String ( ) ,
20- hits : Type . Array (
21- customType . StrictObject ( {
15+ const meilisearchHitRef = registerSchemaAsRef (
16+ 'searchHit' ,
17+ 'Search Hit' ,
18+ customType . StrictObject ( {
19+ name : Type . String ( ) ,
20+ description : Type . String ( ) ,
21+ content : Type . String ( ) ,
22+ creator : customType . StrictObject ( {
23+ id : customType . UUID ( ) ,
24+ name : Type . String ( ) ,
25+ } ) ,
26+ level : Type . Array ( Type . String ( ) ) ,
27+ discipline : Type . Array ( Type . String ( ) ) ,
28+ 'resource-type' : Type . Array ( Type . String ( ) ) ,
29+ id : customType . UUID ( ) ,
30+ type : Type . Enum ( ItemType ) ,
31+ isPublishedRoot : Type . Boolean ( ) ,
32+ isHidden : Type . Boolean ( ) ,
33+ createdAt : customType . DateTime ( ) ,
34+ updatedAt : customType . DateTime ( ) ,
35+ publicationUpdatedAt : customType . DateTime ( ) ,
36+ lang : Type . String ( ) ,
37+ likes : Type . Number ( ) ,
38+ _formatted : customType . StrictObject ( {
2239 name : Type . String ( ) ,
2340 description : Type . String ( ) ,
2441 content : Type . String ( ) ,
@@ -30,37 +47,24 @@ const meilisearchSearchResponseSchema = customType.StrictObject({
3047 discipline : Type . Array ( Type . String ( ) ) ,
3148 'resource-type' : Type . Array ( Type . String ( ) ) ,
3249 id : customType . UUID ( ) ,
33- type : Type . Enum ( ItemType ) ,
50+ type : Type . String ( ) ,
3451 isPublishedRoot : Type . Boolean ( ) ,
52+ publicationUpdatedAt : customType . DateTime ( ) ,
3553 isHidden : Type . Boolean ( ) ,
3654 createdAt : customType . DateTime ( ) ,
3755 updatedAt : customType . DateTime ( ) ,
38- publicationUpdatedAt : customType . DateTime ( ) ,
3956 lang : Type . String ( ) ,
4057 likes : Type . Number ( ) ,
41- _formatted : customType . StrictObject ( {
42- name : Type . String ( ) ,
43- description : Type . String ( ) ,
44- content : Type . String ( ) ,
45- creator : customType . StrictObject ( {
46- id : customType . UUID ( ) ,
47- name : Type . String ( ) ,
48- } ) ,
49- level : Type . Array ( Type . String ( ) ) ,
50- discipline : Type . Array ( Type . String ( ) ) ,
51- 'resource-type' : Type . Array ( Type . String ( ) ) ,
52- id : customType . UUID ( ) ,
53- type : Type . String ( ) ,
54- isPublishedRoot : Type . Boolean ( ) ,
55- publicationUpdatedAt : customType . DateTime ( ) ,
56- isHidden : Type . Boolean ( ) ,
57- createdAt : customType . DateTime ( ) ,
58- updatedAt : customType . DateTime ( ) ,
59- lang : Type . String ( ) ,
60- likes : Type . Number ( ) ,
61- } ) ,
6258 } ) ,
63- ) ,
59+ } ) ,
60+ ) ;
61+
62+ const meilisearchSearchResponseSchema = customType . StrictObject ( {
63+ totalHits : Type . Optional ( Type . Number ( ) ) ,
64+ estimatedTotalHits : Type . Optional ( Type . Number ( ) ) ,
65+ processingTimeMs : Type . Number ( ) ,
66+ query : Type . String ( ) ,
67+ hits : Type . Array ( meilisearchHitRef ) ,
6468} ) ;
6569
6670export const search = {
0 commit comments