proskomma-tools
v0.0.5
Published
Helpers to use when building projects around Proskomma
Downloads
367
Readme
proskomma-tools
Helpers to use when building projects around Proskomma
Setup
npm install proskomma-tools
cd proskomma-tools
npm install
Usage
proskomma-tools
currently exposes 3 objects as an interface to different utility functions for querying Proskomma
.
queries
: functions to generate a query string to be passed to aProskomma
instancepreQueries
: functions to pre-process data being passed into a query function (most are already called from within the query functions)postQueries
: functions to filter the results of a querycatalogQuery
:parseChapterVerseMapInDocSets
passageQuery
:parsePassageResponse
andparseScopeLabels
searchForBookCodesQuery
:searchForBookCodesFilter
searchForPassagesQuery
:searchForBlocksFilter
andsearchForVersesFilter
Example
This example assumes you already have a Proskomma
instance that has been populated with scripture data.
//import statements
import { queries, preQueries, postQueries } from 'proskomma-tools';
//separate "JHN 3:16" into a bookCode and chapter/chapterVerses
const reference = preQueries.parseReferenceString("JHN 3:16");
//string to pass to Proskomma.gqlQuery()
const queryString = queries.passageQuery({
bookCode: reference.bookCode,
chapterVerses: reference.chapterVerses
/*
passageQuery can take 3 different combinations of parameters:
1. bookCode and chapter
2. bookCode and chapterVerses
3. reference
In option 3, passageQuery internally calls preQueries.parseReferenceString
to separate reference out into a bookCode and chapter/chapterVerses.
*/
});
/*
call gqlQuery method on Proskomma instance that for the purposes of the example
is located elsewhere and has been pre-populated with scripture
*/
const result = pk.gqlQuerySync(queryString);
//an array of objects with properties docSetId, reference, and text.
const passages = postQueries.parsePassageResponse({
bookCode: reference.bookCode,
data: result.data
});
//print to console [optional]
console.log(JSON.stringify(passages, null, 2));