diff --git a/biblio-tools/examples.http b/biblio-tools/examples.http index f25a107..b8c8dc7 100644 --- a/biblio-tools/examples.http +++ b/biblio-tools/examples.http @@ -104,3 +104,16 @@ { "value": "unknown"} ] ### + +# istex/works/expand +POST https://biblio-tools.services.inist.fr/v1/istex/works/expand?indent=true HTTP/1.1 +Content-Type: application/json + +[ + { "value": "10.1016/S0047-6374(98)00099-2"}, + { "value": "10.1016/S0167-4943(01)00186-8"}, + { "value": "10.1093/ageing/afm016"}, + { "value": ""} +] +### + diff --git a/biblio-tools/v1/istex/works/expand.ini b/biblio-tools/v1/istex/works/expand.ini new file mode 100644 index 0000000..71a06e6 --- /dev/null +++ b/biblio-tools/v1/istex/works/expand.ini @@ -0,0 +1,108 @@ +# OpenAPI Documentation - JSON format (dot notation) +mimeType = application/json + +post.operationId = post-v1-crossref-works-expand +post.description = Récupération des métadonnées associées à un DOI dans ISTEX +post.summary = Récupération à partir d'un tableau d'objets avec à minima un champ value contenant le DOI +post.tags.0 = biblio-tools +post.requestBody.content.application/json.example.0.id = 1 +post.requestBody.content.application/json.example.0.value = 10.1093/ageing/afm016 +post.requestBody.content.application/json.schema.$ref = #/components/schemas/JSONStream +post.requestBody.required = true +post.responses.default.content.application/json.example.0.id = 1 +post.responses.default.content.application/json.example.0.value = { ... } +post.responses.default.content.application/json.schema.$ref = #/components/schemas/JSONStream +post.responses.default.description = Les prefixes DOI en version textuel +post.parameters.0.description = Indenter le JSON résultant +post.parameters.0.in = query +post.parameters.0.name = indent +post.parameters.0.schema.type = boolean + + +# Necessary plugins +[use] +plugin = basics +plugin = analytics +plugin = storage + +# Flow configuration +[JSONParse] +legacy = false +separator = $ + +[bufferize] + +[combine] +path = env('path', 'value') +primer = get('bufferID') +prepend = buffers +append = transit +persistent = true + +[combine/exchange] +value = get('value') + +[combine/group] +size = 2 + +[combine/replace] +path = size +value = fix(self.length) + +path = q +value = self().map(doi => `"${doi}"`).join(' ').prepend('doi.raw:(').append(')') + +path = rankBy +value = qualityOverRelevance + +path = sid +value = bibilo-tools + +path = total +value = 0 + +path = queryType +value = querywithARK + +path = output +value = * + +[combine/URLStream] +url = https://api.istex.fr/document/ +path = .hits.* +timeout = 30000 +noerrors = true + +; Simplification de la structure à postriori (le faire à priori était également possible) +[combine/exchange] +value = self().omit(['refBibs', 'enrichments', 'metadata', 'fulltext', 'annexes', 'covers']) + + +[combine/OBJFlatten] + +[combine/replace] +path = id +value = get('doi.0') +path = value +value = self().omit('refBibs') + +# On nettoie l'objet en supprimant les champs temporaires +[exchange] +value = self().omit('bufferID') + +[assign] +path = value +value = get('value.value', 'n/a') + + +# On marque les réponses qui n'ont pas abouties +[swing] +test = has('value.doi') +reverse = true + +[swing/assign] +path = value +value = fix('n/a') + +[dump] +indent = env('indent', false) diff --git a/biblio-tools/v1/unpaywall/expand.ini b/biblio-tools/v1/unpaywall/expand.ini deleted file mode 100644 index 66efff0..0000000 --- a/biblio-tools/v1/unpaywall/expand.ini +++ /dev/null @@ -1,120 +0,0 @@ -# OpenAPI Documentation - JSON format (dot notation) -mimeType = application/json - -post.operationId = post-v1-unpaywall-expand -post.description = Récupération des métadonnées associées à DOI dans la base Unpaywall -post.summary = Récupération à partir d'un tableau d'objets avec à minima un champ value contenant le DOI -post.tags.0 = biblio-tools -post.requestBody.content.application/json.example.0.id = 1 -post.requestBody.content.application/json.example.0.value = 10.4000/edc.9014 -post.requestBody.content.application/json.schema.$ref = #/components/schemas/JSONStream -post.requestBody.required = true -post.responses.default.content.application/json.example.0.id = 1 -post.responses.default.content.application/json.example.0.value = { ... } -post.responses.default.content.application/json.schema.$ref = #/components/schemas/JSONStream -post.responses.default.description = une réponse sous forme d'un objet ou n/a pour chaque DOI -post.parameters.0.description = Indenter le JSON résultant -post.parameters.0.in = query -post.parameters.0.name = indent -post.parameters.0.schema.type = boolean - -# Necessary plugins -[use] -plugin = basics -plugin = analytics -plugin = storage - -# Flow configuration -[JSONParse] -legacy = false -separator = $ - -[env] -path = size -value = 10 - -path = indent -value = true - -path = token -value = env('UNPAYWALL_API_KEY') - - -# Pour traiter par lot on groupe puis on utilise spawn qui crée un buffer par lot -[group] -size = env('size') - -[spawn] -[spawn/ungroup] -[spawn/bufferize] - -# On réalise un mapping dynamique sur le champ value (et on sauvegarde les correspondances trouvées) -[spawn/combine] -path = value -default = n/a -primer = get('bufferID') -prepend = buffers -append = transit -persistent = true - -[spawn/combine/group] -size = env('size') - -[spawn/combine/replace] -path = dois -value = self().map('value').map(x => JSON.stringify(x)).join(',') - -# On crée un objet contenant tous les valeurs nécessaire pour créer une requete -[spawn/combine/replace] -path = query -value = fix('{GetByDOI(dois:[', self.dois, ']){doi, is_oa, oa_status, has_repository_copy, best_oa_location { host_type }}}').join('') - -[spawn/combine/URLStream] -url = https://unpaywall.inist.fr/api/graphql -header = env('token').prepend('x-api-key:') -path = data.GetByDOI.* -timeout = 5000 -noerror = false - -# On supprime les réponses qui n'ont pas abouties ( -[spawn/combine/drop] -path = is_oa - -# On créé l'object attendu par combine { id, value } pour faire le mapping -[spawn/combine/replace] -path = id -value = get('doi') - -path = value.is_oa -value = get('is_oa') - -path = value.oa_status -value = get('oa_status') - -path = value.host_type -value = get('best_oa_location.host_type', 'n/a') - -path = value.has_repository_copy -value = get('has_repository_copy', 'n/a') - - -# On nettoie l'objet en supprimant les champs temporaires -[spawn/exchange] -value = self().omit('bufferID') - -# On simplifie la structure -[assign] -path = value -value = get('value.value', self.value) - -# On marque les réponses qui n'ont pas abouties -[swing] -test = has('value.is_oa') -reverse = true - -[swing/assign] -path = value -value = fix('n/a') - -[dump] -indent = env('indent') diff --git a/biblio-tools/v1/unpaywall/works/expand.ini b/biblio-tools/v1/unpaywall/works/expand.ini new file mode 100644 index 0000000..66efff0 --- /dev/null +++ b/biblio-tools/v1/unpaywall/works/expand.ini @@ -0,0 +1,120 @@ +# OpenAPI Documentation - JSON format (dot notation) +mimeType = application/json + +post.operationId = post-v1-unpaywall-expand +post.description = Récupération des métadonnées associées à DOI dans la base Unpaywall +post.summary = Récupération à partir d'un tableau d'objets avec à minima un champ value contenant le DOI +post.tags.0 = biblio-tools +post.requestBody.content.application/json.example.0.id = 1 +post.requestBody.content.application/json.example.0.value = 10.4000/edc.9014 +post.requestBody.content.application/json.schema.$ref = #/components/schemas/JSONStream +post.requestBody.required = true +post.responses.default.content.application/json.example.0.id = 1 +post.responses.default.content.application/json.example.0.value = { ... } +post.responses.default.content.application/json.schema.$ref = #/components/schemas/JSONStream +post.responses.default.description = une réponse sous forme d'un objet ou n/a pour chaque DOI +post.parameters.0.description = Indenter le JSON résultant +post.parameters.0.in = query +post.parameters.0.name = indent +post.parameters.0.schema.type = boolean + +# Necessary plugins +[use] +plugin = basics +plugin = analytics +plugin = storage + +# Flow configuration +[JSONParse] +legacy = false +separator = $ + +[env] +path = size +value = 10 + +path = indent +value = true + +path = token +value = env('UNPAYWALL_API_KEY') + + +# Pour traiter par lot on groupe puis on utilise spawn qui crée un buffer par lot +[group] +size = env('size') + +[spawn] +[spawn/ungroup] +[spawn/bufferize] + +# On réalise un mapping dynamique sur le champ value (et on sauvegarde les correspondances trouvées) +[spawn/combine] +path = value +default = n/a +primer = get('bufferID') +prepend = buffers +append = transit +persistent = true + +[spawn/combine/group] +size = env('size') + +[spawn/combine/replace] +path = dois +value = self().map('value').map(x => JSON.stringify(x)).join(',') + +# On crée un objet contenant tous les valeurs nécessaire pour créer une requete +[spawn/combine/replace] +path = query +value = fix('{GetByDOI(dois:[', self.dois, ']){doi, is_oa, oa_status, has_repository_copy, best_oa_location { host_type }}}').join('') + +[spawn/combine/URLStream] +url = https://unpaywall.inist.fr/api/graphql +header = env('token').prepend('x-api-key:') +path = data.GetByDOI.* +timeout = 5000 +noerror = false + +# On supprime les réponses qui n'ont pas abouties ( +[spawn/combine/drop] +path = is_oa + +# On créé l'object attendu par combine { id, value } pour faire le mapping +[spawn/combine/replace] +path = id +value = get('doi') + +path = value.is_oa +value = get('is_oa') + +path = value.oa_status +value = get('oa_status') + +path = value.host_type +value = get('best_oa_location.host_type', 'n/a') + +path = value.has_repository_copy +value = get('has_repository_copy', 'n/a') + + +# On nettoie l'objet en supprimant les champs temporaires +[spawn/exchange] +value = self().omit('bufferID') + +# On simplifie la structure +[assign] +path = value +value = get('value.value', self.value) + +# On marque les réponses qui n'ont pas abouties +[swing] +test = has('value.is_oa') +reverse = true + +[swing/assign] +path = value +value = fix('n/a') + +[dump] +indent = env('indent')