gbv / cocoda-sdk

SDK for Cocoda and coli-conc services
https://gbv.github.io/cocoda-sdk/
MIT License
5 stars 1 forks source link

ReconciliationApi: make fromScheme optional #11

Closed nichtich closed 4 years ago

nichtich commented 4 years ago

At https://github.com/gbv/cocoda-sdk/blob/6f48fce4b4c174b4f6355d55ae50c97c21e8f2cc/providers/reconciliation-api-provider.js#L55 we could remove testing from fromScheme. Setting from.inScheme to [ {} ] works anyway, so there is no reason to have fromSchem except for copying it into the result mappings.

We could further make to.inScheme optional and set it to schemes[0] if the registry has exactely one scheme, so this should work:

const registry = cdk.initializeRegistry({
  provider: "ReconciliationApi",
  reconcile: "...",
  schemes: [ theScheme ]
})
registry.getMappings({ from: { prefLabel: { en: "label" } } })
stefandesu commented 4 years ago

toScheme will already fall back to schemes[0]. I can remove the check completely, but if someone did something like you described, the resulting mappings would basically be invalid (no fromScheme).

I will also take a closer look at the code, I'm not sure whether it needs to be as complicated as it is.