diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ceeeb9b --- /dev/null +++ b/.gitignore @@ -0,0 +1,53 @@ +.env +# Logs +*.log +npm-debug.log* + +# Runtime data +pids +*.pid +*.seed +*.sw? + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (http://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules +jspm_packages + +# Optional npm cache directory +.npm + +# Optional REPL history +.node_repl_history +package-lock.json +build +typings +upload/ + +# Cypress +cypress/videos +cypress/screenshots + +# Webpack Bundle Analyzer +stats.json + +# Misc +examples/ +.idea diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000..dcfecd7 --- /dev/null +++ b/.npmignore @@ -0,0 +1,5 @@ +.env +coverage/ +bench/ +examples/ +test/ diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000..ebbd5db --- /dev/null +++ b/.npmrc @@ -0,0 +1,3 @@ +; see https://docs.npmjs.com/misc/config#save-exact +save-exact = true +registry = https://registry.npmjs.org/ diff --git a/loterre-resolver/v1/92D/9SD.xml.gz b/loterre-resolver/v1/92D/9SD.xml.gz new file mode 100644 index 0000000..be3828c --- /dev/null +++ b/loterre-resolver/v1/92D/9SD.xml.gz Binary files differ diff --git a/loterre-resolver/v1/92D/combine.ini b/loterre-resolver/v1/92D/combine.ini new file mode 100644 index 0000000..159501f --- /dev/null +++ b/loterre-resolver/v1/92D/combine.ini @@ -0,0 +1,29 @@ +# OpenAPI Documentation - JSON format (dot notation) +post.responses.default.description = Return all objects with enrich fields +post.responses.default.content.application/json.schema.$ref = #/components/schemas/JSONStream +post.summary = Fetch all enrichments +post.requestBody.required = true +post.requestBody.content.application/json.schema.$ref = #/components/schemas/JSONStream +post.parameters.0.in = query +post.parameters.0.name = path +post.parameters.0.schema.type = string +post.parameters.0.description = The path in each object to enrcih with a SKOS Cocnept +post.parameters.1.in = query +post.parameters.1.name = indent +post.parameters.1.schema.type = boolean +post.parameters.1.description = Indent or not the JSON Result + +[use] +plugin = analytics + +[exchange] +value = 9SD.xml.gz + +[files] + +[delegate] +file = ../combine.ini + +[dump] +indent = env('indent', false) + diff --git a/loterre-resolver/v1/92D/expand.ini b/loterre-resolver/v1/92D/expand.ini new file mode 100644 index 0000000..8de0651 --- /dev/null +++ b/loterre-resolver/v1/92D/expand.ini @@ -0,0 +1,21 @@ +# OpenAPI Documentation - JSON format (dot notation) +post.responses.default.description = Return all objects with enrich fields +post.responses.default.content.application/json.schema.$ref = #/components/schemas/JSONStream +post.summary = Enrich on field of each Object with a SKOS concept +post.requestBody.required = true +post.requestBody.content.application/json.schema.$ref = #/components/schemas/JSONStream +post.parameters.0.in = query +post.parameters.0.name = path +post.parameters.0.schema.type = string +post.parameters.0.description = The path in each object to enrcih with a SKOS Cocnept +post.parameters.1.in = query +post.parameters.1.name = indent +post.parameters.1.schema.type = boolean +post.parameters.1.description = Indent or not the JSON Result + +[env] +path = primer +value = ./9SD.xml.gz + +[delegate] +file = ../expand.ini diff --git a/loterre-resolver/v1/combine.ini b/loterre-resolver/v1/combine.ini new file mode 100644 index 0000000..23e5f42 --- /dev/null +++ b/loterre-resolver/v1/combine.ini @@ -0,0 +1,55 @@ +# Context input/output +append = dump?indent=true + +# OpenAPI Documentation - JSON format (dot notation) +post.responses.default.description = Return all objects from XML/SKOS file +post.responses.default.content.application/json.schema.type = array +post.responses.default.content.application/json.schema.items.type = object +post.responses.default.content.application/json.schema.items.properties.id.type = string +post.responses.default.content.application/json.schema.items.properties.value.$ref = #/components/schemas/anyValue +post.summary = Transform XML/SKOS file to array of JSON Objects +post.requestBody.required = true +post.requestBody.content.text/xml.schema.type = string +post.requestBody.content.text/xml.schema.format = binary + +# Necessary plugins +[use] +plugin = basics +plugin = loterre +plugin = analytics + +# Flow configuration +[TXTZip] +unzip = true + +[XMLParse] +separator = /rdf:RDF/skos:Concept + +[OBJFlatten] +safe = true + +[replace] +path = concept +value = self() + +# select all keys and remove duplicates to avoid ambiguities +path = keys +value = fix(_.get(self, 'skos$prefLabel'), _.get(self, 'skos$altLabel'), _.get(self, 'skos$hiddenLabel')). \ + flatten().\ + filter(o => _.has(o, '$t')).\ + map(o =>_.lowerCase(_.trim((o.$t)))).\ + reduce((accumulator, value, key, collection) => (_.indexOf(collection, value) >= 0 ? accumulator.concat(value) : accumulator), []) + + +[exploding] +id = concept +value = keys + +; invert id & value because of [exploding] which works only by value (not by id) +[replace] +path = id +value = get('value') + +path = value +value = get('id') + diff --git a/loterre-resolver/v1/expand.ini b/loterre-resolver/v1/expand.ini new file mode 100644 index 0000000..6935f91 --- /dev/null +++ b/loterre-resolver/v1/expand.ini @@ -0,0 +1,42 @@ +# OpenAPI Documentation - JSON format (dot notation) +post.responses.default.description = Return all objects with enrich fields +post.responses.default.content.application/json.schema.$ref = #/components/schemas/JSONStream +post.summary = Enrich on field of each Object with a SKOS concept +post.requestBody.required = true +post.requestBody.content.application/json.schema.$ref = #/components/schemas/JSONStream +post.parameters.0.in = query +post.parameters.0.name = path +post.parameters.0.schema.type = string +post.parameters.0.description = The path in each object to enrcih with a SKOS Cocnept +post.parameters.1.in = query +post.parameters.1.name = indent +post.parameters.1.schema.type = boolean +post.parameters.1.description = Indent or not the JSON Result + +# Necessary plugins +[use] +plugin = basics +plugin = analytics +plugin = storage + +# Flow configuration +[JSONParse] +separator = * + +[expand] +path = value +size = 1 +cacheName = env('primer') + +[expand/assign] +path = value +value = get('value').lowerCase() + +[expand/combine] +path = value +primer = env('primer') +prepend = files +file = ./combine.ini + +[dump] +indent = env('indent', false)