@arkisto/describo-data-packs
v0.6.2
Published
A set of data packs for describo to load content from.
Downloads
3
Readme
A repository to host data packs for use in Describo. A data pack is simply a pre-defined array of JSON-LD objects that can be used as the value of a property.
For users
Install the package
npm install --save @arkisto/describo-data-packs
Loading the data packs into elastic search
For development you can start a local elastic search service with:
docker compose up -d ; docker compose logs -f ; docker compose stop ; docker compose rm -f
Then in your application you can trigger a load of all of the data packs:
const { IndexDataPacks } = require('@arkisto/describo-data-packs')
const index = new IndexDataPacks({ elasticUrl: "http://localhost:9200" });
await index.load();
Or to do it once somewhere outside of your app with something like the script
./bin/index-data-packs.js
Working with the package
const { DataPack } = require('@arkisto/describo-data-packs')
let datapack = new DataPack({ dataPacks: ['Austlang', 'Glottolog'], indexFields: ['@id', 'name']})
await datapack.load()
let language = datapack.get({
field: "name",
value: "Nyaki Nyaki / Njaki Njaki",
});
Returns a JSON-LD snippet if a match is found.
For Developers
Working on the package - writing tests
- start elastic search docker container:
docker compose up
- Run the tests in watch mode:
npm run test:watch
Updating the JSDoc documentation
- npm run generate-docs
- Then commit the docs and push to github
Adding a data pack to this repository
- add a folder in the
data-packs
top level folder named as your data pack. - create an update script inside that folder named like:
create-data-pack.js
.- Your script should be self contained and retrieve the data it needs. That is, don't check a datasource into this repo if you can avoid it. Get it from the web so that the data pack is updated from the main version online. Whatever, and wherever, that is.
- add a reference to that script in
update-all-packages.sh
so that your data pack is updated when the others are. - document the data structure by adding a file in your data pack folder called:
datapack-entry-format.js
. Follow the example inlanguages/datapack-entry-format.js
.
Building and publishing an update
bash ./update_all_packages.sh
npm run generate-docs
- Commit all of the changes
- Bump the version:
npm version minor
- Publish
npm publish