@@ -11,6 +11,8 @@ import {
11
11
import { HookContext } from '@feathersjs/feathers'
12
12
import { ImpressoApplication } from '../../types'
13
13
import { Image } from '../../models/generated/schemas'
14
+ import { protobuf } from 'impresso-jscommons'
15
+ import { BadRequest } from '@feathersjs/errors'
14
16
15
17
// const { authenticate } = require('@feathersjs/authentication').hooks;
16
18
const {
@@ -63,7 +65,6 @@ const updateIiifUrls = (context: HookContext<ImpressoApplication>) => {
63
65
} )
64
66
} )
65
67
} )
66
- console . log ( context . result . data )
67
68
}
68
69
}
69
70
@@ -111,17 +112,36 @@ const convertItemToNewImageFormat = (context: HookContext<ImpressoApplication>)
111
112
context . result = newResult
112
113
}
113
114
115
+ const deserializeFilters = ( serializedFilters : string ) => {
116
+ if ( serializedFilters == null ) return [ ]
117
+ try {
118
+ return protobuf . searchQuery . deserialize ( serializedFilters ) . filters || [ ]
119
+ } catch ( error ) {
120
+ throw new BadRequest ( `Could not deserialize filters: ${ ( error as Error ) . message } ` )
121
+ }
122
+ }
123
+
124
+ // parse filters
125
+ const parseFiltersHook = ( context : HookContext < ImpressoApplication > ) => {
126
+ const { filters } = context . params ?. query ?? { }
127
+ context . params . query . filters = deserializeFilters ( filters )
128
+ console . log ( 'ooo' , context . params . query . filters )
129
+ }
130
+
131
+ const parseQ = ( context : HookContext < ImpressoApplication > ) => {
132
+ if ( context ?. params ?. query ?. term ) {
133
+ context . params . query . q = context . params . query . term
134
+ }
135
+ }
136
+
114
137
export default {
115
138
before : {
116
139
all : [
117
140
// authenticate('jwt')
118
141
] ,
119
142
find : [
120
- ( context : HookContext < ImpressoApplication > ) => {
121
- if ( context ?. params ?. query ?. term ) {
122
- context . params . query . q = context . params . query . term
123
- }
124
- } ,
143
+ parseFiltersHook ,
144
+ parseQ ,
125
145
validate ( {
126
146
order_by : utils . orderBy ( {
127
147
values : {
0 commit comments