diff --git a/biblio-tools/v1/unpaywall/expand.ini b/biblio-tools/v1/unpaywall/expand.ini new file mode 100644 index 0000000..4ebfbf6 --- /dev/null +++ b/biblio-tools/v1/unpaywall/expand.ini @@ -0,0 +1,93 @@ +# OpenAPI Documentation - JSON format (dot notation) +post.responses.default.description = Return a JSON, composed of `id`, `value`, where value is a DOI +post.responses.default.content.application/json.schema.$ref = #/components/schemas/JSONStream +post.summary = Find openaccess data in unpaywall database +post.requestBody.required = true +post.requestBody.content.application/json.schema.$ref = #/components/schemas/JSONStream + +# Necessary plugins +[use] +plugin = basics +plugin = analytics +plugin = storage + +# Flow configuration +[JSONParse] +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, 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') + +# 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) + +[dump] +indent = env('indent')