Skip to content

Latest commit

 

History

History
726 lines (527 loc) · 36.6 KB

API.md

File metadata and controls

726 lines (527 loc) · 36.6 KB

Classes

NodeSwordInterface

This is the main class of node-sword-interface and it provides a set of static functions that wrap SWORD library functionality.

Typedefs

VerseObject : Object

An object representation of a Bible verse.

ModuleObject : Object

An object representation of a SWORD module.

StrongsReference : Object

An object representation of a Strongs reference

StrongsEntry : Object

An object representation of a Strong's entry.

NodeSwordInterface

This is the main class of node-sword-interface and it provides a set of static functions that wrap SWORD library functionality.

Kind: global class

nodeSwordInterface.repositoryConfigExisting() ⇒ Boolean

Checks whether a repository configuration is already existing locally.

Kind: instance method of NodeSwordInterface

nodeSwordInterface.updateRepositoryConfig(progressCB) ⇒ Promise

Creates or updates the repository configuration and stores the information persistently. The repository configuration contains information about all SWORD repositories and the available modules. After this operation the local cached repository configuration will contain the latest master repository list and updated lists of SWORD modules available from each repository.

This function must be called initially before using any other repository-related functions. Once the repository configuration has been initialized, the use of this function is optional. However, the cached repository configuration may not contain the latest information if this function is not called.

This function works asynchronously and returns a Promise object. The Promise delivers a detailed status object which contains one entry for each of the repositories of the master repo list as well as one result entry.

Kind: instance method of NodeSwordInterface

Param Type Description
progressCB function Optional callback function that is called on progress events.

nodeSwordInterface.getRepoNames() ⇒ Array.<String>

Returns the names of all available SWORD repositories.

Kind: instance method of NodeSwordInterface
Returns: Array.<String> - An array of strings with the names of the available SWORD repositories.

nodeSwordInterface.getRepoLanguages(repositoryName, moduleType) ⇒ Array.<String>

Returns the available languages for the modules from a given repository (default: Bible modules). Note that the languages are returned as language codes.

Kind: instance method of NodeSwordInterface
Returns: Array.<String> - An array of strings with the languages codes for the Bible modules from the given repository.

Param Type Default Description
repositoryName String The name of the given repository.
moduleType String BIBLE A filter parameter that defines the moduleType (Options: BIBLE, DICT, COMMENTARY)

nodeSwordInterface.getAllRepoModules(repositoryName, moduleType) ⇒ Array.<ModuleObject>

Returns all modules for the given repository (default: Bible modules).

Kind: instance method of NodeSwordInterface
Returns: Array.<ModuleObject> - An array of strings with the module codes for the Bible modules of the given repository.

Param Type Default Description
repositoryName String The name of the given repository.
moduleType String BIBLE A filter parameter that defines the moduleType (Options: BIBLE, DICT, COMMENTARY)

nodeSwordInterface.getRepoModulesByLang(repositoryName, language, moduleType, headersFilter, strongsFilter, hebrewStrongsKeys, greekStrongsKeys) ⇒ Array.<ModuleObject>

Returns all Bible modules for the given repository and language

Kind: instance method of NodeSwordInterface
Returns: Array.<ModuleObject> - An array of module objects.

Param Type Default Description
repositoryName String The name of the given repository.
language String The language code that shall be used as a filter.
moduleType String BIBLE A filter parameter that defines the moduleType (Options: BIBLE, DICT, COMMENTARY)
headersFilter Boolean false Whether only modules with Headers shall be returned.
strongsFilter Boolean false Whether only modules with Strong's shall be returned.
hebrewStrongsKeys Boolean false Whether only modules with Hebrew Strong's keys shall be returned (only applies to dictionaries).
greekStrongsKeys Boolean false Whether only modules with Greek Strong's keys shall be returned (only applies to dictionaries).

nodeSwordInterface.getUpdatedRepoModules(repositoryName, includeBeta) ⇒ Array.<ModuleObject>

Returns all updated modules from all repositories or one specific repository.

Kind: instance method of NodeSwordInterface
Returns: Array.<ModuleObject> - An array of module objects.

Param Type Default Description
repositoryName String all The name of the repository from which updates shall retrieved. Default: 'all'
includeBeta Boolean false Whether modules from the CrossWire Beta repository should also be included.

nodeSwordInterface.getRepoModule(moduleCode) ⇒ ModuleObject

Returns an object representation of a SWORD module from a repository.

Kind: instance method of NodeSwordInterface

Param Type Description
moduleCode String The module code of the SWORD module.

nodeSwordInterface.getAllLocalModules(moduleType) ⇒ Array.<ModuleObject>

Returns all modules installed locally (default: Bible modules).

Kind: instance method of NodeSwordInterface
Returns: Array.<ModuleObject> - An array of ModuleObjects which represents the locally installed Bible modules.

Param Type Default Description
moduleType String BIBLE A filter parameter that defines the moduleType (Options: BIBLE, DICT, COMMENTARY)

nodeSwordInterface.getRepoModuleCount(repositoryName, moduleType) ⇒ Number

Returns the number of modules for a given repository (default: Bible modules).

Kind: instance method of NodeSwordInterface
Returns: Number - The number of Bible modules for the given repository and module type.

Param Type Default Description
repositoryName String The name of the given repository.
moduleType String BIBLE A filter parameter that defines the moduleType (Options: BIBLE, DICT, COMMENTARY)

nodeSwordInterface.getRepoLanguageModuleCount(repositoryName, language, moduleType) ⇒ Number

Returns the number of modules for a given repository and language (default: Bible modules).

Kind: instance method of NodeSwordInterface
Returns: Number - The number of Bible modules for the given repository, language and module type.

Param Type Default Description
repositoryName String The name of the given repository.
language String The language code that shall be used as a filter.
moduleType String BIBLE A filter parameter that defines the moduleType (Options: BIBLE, DICT, COMMENTARY)

nodeSwordInterface.installModule(moduleCode, progressCB) ⇒ Promise

Installs a module. The repository is automatically determined. The module is downloaded from the corresponding repository and then installed in the local SWORD directory. This operation may take some time depending on the available bandwidth and geographical distance to the SWORD repository server.

This function works asynchronously and returns a Promise object.

If the installation fails, the Promise will be rejected with the following status codes (based on SWORD): -1: General installation issue -9: Installation cancelled by user or internet connection suddenly interrupted

Kind: instance method of NodeSwordInterface

Param Type Description
moduleCode String The module code of the SWORD module that shall be installed.
progressCB function Callback function that is called on progress events.

nodeSwordInterface.cancelInstallation()

Cancels an ongoing module installation.

Kind: instance method of NodeSwordInterface

nodeSwordInterface.uninstallModule(moduleCode) ⇒ Promise

Uninstalls a module.

This function works asynchronously and returns a Promise object.

Kind: instance method of NodeSwordInterface

Param Type Description
moduleCode String The module code of the SWORD module that shall be uninstalled.

nodeSwordInterface.refreshLocalModules()

Refresh the local module database. This function is purely for testing. It will usually be called after changing the SWORD module database outside of the actual application.

Kind: instance method of NodeSwordInterface

nodeSwordInterface.saveModuleUnlockKey(moduleCode, key)

Persistently saves the unlock key of the corresponding module in the module's .conf file (in ~/.sword/mods.d/.conf)

Kind: instance method of NodeSwordInterface

Param Type Description
moduleCode String The module code of the SWORD module.
key String The unlock key.

nodeSwordInterface.isModuleReadable(moduleCode) ⇒ Boolean

Checks whether the module is readable.

Kind: instance method of NodeSwordInterface

Param Type Description
moduleCode String The module code of the SWORD module.

nodeSwordInterface.getModuleDescription(moduleCode) ⇒ String

Returns the description of a module.

Kind: instance method of NodeSwordInterface
Returns: String - The description of the respective module.

Param Type Description
moduleCode String The module code of the SWORD module.

nodeSwordInterface.enableMarkup()

Enables available markup (like Strongs, foot notes, etc.) This influences the output for getChapterText, getBookText and getBibleText.

Kind: instance method of NodeSwordInterface

nodeSwordInterface.getRawModuleEntry(moduleCode, key) ⇒ String

Returns the raw text of an entry for the given module and key. If no entry exists for the given key the return value is undefined.

Kind: instance method of NodeSwordInterface

Param Type Description
moduleCode String The module code of the SWORD module.
key String The key of the entry.

nodeSwordInterface.getReferenceText(moduleCode, key) ⇒ VerseObject

Returns the text of an entry for the given module and key. If no entry exists for the given key the return value is a verse with empty content.

Kind: instance method of NodeSwordInterface

Param Type Description
moduleCode String The module code of the SWORD module.
key String The key of the entry.

nodeSwordInterface.getChapterText(moduleCode, bookCode, chapter) ⇒ Array.<VerseObject>

Returns the text of a chapter for the given module.

Kind: instance method of NodeSwordInterface
Returns: Array.<VerseObject> - An array of verse objects.

Param Type Description
moduleCode String The module code of the SWORD module.
bookCode String The book code of the SWORD module.
chapter Number The chapter that shall be returned.

nodeSwordInterface.getBookText(moduleCode, bookCode, startVerseNr, verseCount) ⇒ Array.<VerseObject>

Returns the text of a book for the given module.

Kind: instance method of NodeSwordInterface
Returns: Array.<VerseObject> - An array of verse objects.

Param Type Description
moduleCode String The module code of the SWORD module.
bookCode String The book code of the SWORD module.
startVerseNr Number The start verse number (absolute) where we start reading (Optional)
verseCount Number The number of verses that shall be returned (Optional)

nodeSwordInterface.getVersesFromReferences(moduleCode, references) ⇒ Array.<VerseObject>

Returns an array of verses based on the given array of verse references

Kind: instance method of NodeSwordInterface
Returns: Array.<VerseObject> - An array of verse objects.

Param Type Description
moduleCode String The module code of the SWORD module.
references Array A list of OSIS references. (like ['Gal.5.1', '1Cor.2.4'])

nodeSwordInterface.getReferencesFromReferenceRange(referenceRange) ⇒ Array.<String>

Returns an array of individual verse references based on an OSIS reference range expression.

Kind: instance method of NodeSwordInterface
Returns: Array.<String> - An array of OSIS references.

Param Type Description
referenceRange String An OSIS reference range expression. (like 'Gal.1.15-Gal.1.16')

nodeSwordInterface.getBookList(moduleCode) ⇒ Array.<String>

Returns the list of books available in the given module. By default the book codes will be in OSIS format.

Kind: instance method of NodeSwordInterface
Returns: Array.<String> - An array of book codes.

Param Type Description
moduleCode String The module code of the SWORD module.

nodeSwordInterface.getBookHeaderList(moduleCode, bookCode, startVerseNumber, verseCount) ⇒ Array.<VerseObject>

Returns the list of headers available in the given book. The headers are returned as an array of VerseObjects.

Kind: instance method of NodeSwordInterface

Param Type
moduleCode String
bookCode String
startVerseNumber Number
verseCount Number

nodeSwordInterface.getBookChapterCount(moduleCode, bookCode)

Returns the chapter count of the given book.

Kind: instance method of NodeSwordInterface

Param Type Description
moduleCode String The module code of the SWORD module.
bookCode String The book code of the SWORD module.

nodeSwordInterface.getChapterVerseCount(moduleCode, bookCode, chapter)

Returns the number of verses in the given chapter.

Kind: instance method of NodeSwordInterface

Param Type Description
moduleCode String The module code of the SWORD module.
bookCode String The book code of the SWORD module.
chapter Number The chapter of the book.

nodeSwordInterface.getAllChapterVerseCounts(moduleCode, bookCode) ⇒ Number

Returns an array with the chapter verse counts of all chapters of a given book.

Kind: instance method of NodeSwordInterface
Returns: Number - chapterVerseCounts

Param Type
moduleCode String
bookCode String

nodeSwordInterface.getBookVerseCount(moduleCode, bookCode) ⇒ Number

Returns the number verses in the given book.

Kind: instance method of NodeSwordInterface
Returns: Number - The verse count of the book.

Param Type Description
moduleCode String The module code of the SWORD module.
bookCode String The book code of the SWORD module.

nodeSwordInterface.getBibleText(moduleCode) ⇒ Array.<VerseObject>

Returns the Bible text of a module.

Kind: instance method of NodeSwordInterface
Returns: Array.<VerseObject> - An array of verse objects.

Param Type Description
moduleCode String The module code of the SWORD module.

nodeSwordInterface.getBookIntroduction(moduleCode, bookCode) ⇒ String

Returns the introduction of the given book.

Kind: instance method of NodeSwordInterface

Param Type Description
moduleCode String The module code of the SWORD module.
bookCode String The book code of the SWORD module.

nodeSwordInterface.moduleHasBook(moduleCode, bookCode) ⇒ Boolean

Checks whether a module has a certain book.

Kind: instance method of NodeSwordInterface

Param Type
moduleCode String
bookCode String

nodeSwordInterface.getDictModuleKeys(moduleCode) ⇒ Array.<String>

Returns the keys of a dictionary module.

Kind: instance method of NodeSwordInterface

Param Type
moduleCode String

nodeSwordInterface.getModuleSearchResults(moduleCode, searchTerm, progressCB, searchType, searchScope, isCaseSensitive, useExtendedVerseBoundaries) ⇒ Promise

Returns the results of a module search.

Kind: instance method of NodeSwordInterface

Param Type Default Description
moduleCode String The module code of the SWORD module.
searchTerm String The term to search for.
progressCB function Optional callback function that is called on progress events.
searchType String phrase Options: phrase, multiWord, strongsNumber
searchScope String BIBLE Options: BIBLE, OT, NT
isCaseSensitive Boolean false Whether the search is case sensitive
useExtendedVerseBoundaries Boolean false Whether the search should use extended verse boundaries (Two verses instead of one) in case of a multi word search.

nodeSwordInterface.terminateModuleSearch()

Terminates the currently ongoing module search.

Kind: instance method of NodeSwordInterface

nodeSwordInterface.hebrewStrongsAvailable() ⇒ Boolean

Checks whether Hebrew Strong's definitions are available.

Kind: instance method of NodeSwordInterface

nodeSwordInterface.greekStrongsAvailable() ⇒ Boolean

Checks whether Greek Strong's definitions are available.

Kind: instance method of NodeSwordInterface

nodeSwordInterface.strongsAvailable() ⇒ Boolean

Checks whether Strongs definitions are available

Kind: instance method of NodeSwordInterface

nodeSwordInterface.getStrongsEntry(strongsKey) ⇒ StrongsEntry

Returns the Strong's entry for a given key.

Kind: instance method of NodeSwordInterface
Returns: StrongsEntry - A StrongsEntry object.

Param Type Description
strongsKey String The Strong's key for the requested entry.

nodeSwordInterface.getLocalModule(moduleCode) ⇒ ModuleObject

Returns an object representation of a locally installed SWORD module. If the requested moduleCode is not available undefined will be returned.

Kind: instance method of NodeSwordInterface

Param Type Description
moduleCode String The module code of the SWORD module.

nodeSwordInterface.isModuleInUserDir(moduleCode) ⇒ Boolean

Checks whether the module resides in the user directory.

Kind: instance method of NodeSwordInterface

Param Type Description
moduleCode String The module code of the SWORD module.

nodeSwordInterface.isModuleAvailableInRepo(moduleCode) ⇒ Boolean

Checks whether the module is available in any repository.

Kind: instance method of NodeSwordInterface

Param Type Description
moduleCode String The module code of the SWORD module.

nodeSwordInterface.getSwordTranslation(originalString, localeCode)

Uses the Sword LocaleMgr to translate a string. This can be used to translate book names for example.

Kind: instance method of NodeSwordInterface

Param Type
originalString String
localeCode String

nodeSwordInterface.getBookAbbreviation(moduleName, bookCode, localeCode)

Uses the Sword LocaleMgr to translate a book abbreviation.

Kind: instance method of NodeSwordInterface

Param Type
moduleName String
bookCode String
localeCode String

nodeSwordInterface.getSwordVersion() ⇒ String

Returns the version of the SWORD library

Kind: instance method of NodeSwordInterface
Returns: String - SWORD library version.

nodeSwordInterface.getSwordPath() ⇒ String

Returns the platform-specific path where SWORD accesses and stores its modules.

Kind: instance method of NodeSwordInterface
Returns: String - Platform-specific SWORD path.

VerseObject : Object

An object representation of a Bible verse.

Kind: global typedef
Properties

Name Type Description
moduleCode String The name/code of the SWORD module
bibleBookShortTitle String The short title of the verses's Bible book
chapter String The chapter number
verseNr String The verse number
absoluteVerseNr Number The absolute number of the verse within the book (independent of chapters, starting from 1)
content String The verse content

ModuleObject : Object

An object representation of a SWORD module.

Kind: global typedef
Properties

Name Type Description
name String The name/code of the SWORD module
type String The type of the SWORD module (Currently the following types are supported: Biblical Texts, Lexicons / Dictionaries, Commentaries)
description String The description of the SWORD module
language String The language code of the SWORD module
distributionLicense String The distribution license of the SWORD module
shortCopyright String The short copyright information of the SWORD module
version String The version of the SWORD module
lastUpdate String The date of the last version update of the SWORD module
category String The category of the SWORD module
repository String The repository of the SWORD module
about String Extended description of the SWORD module
abbreviation String The abbreviation of the SWORD module
size Number The file size of the SWORD module (in KB)
location String The filesystem location where the module is stored
unlockInfo String Information about how to retrieve an unlock key (in case the module is locked)
inUserDir Boolean Information on whether the module is located in the user's directory
locked Boolean Information on whether the module is locked
hasStrongs Boolean Information on whether the module has Strong's numbers
hasGreekStrongsKeys Boolean Information on whether the module has Strong's based keys (Greek)
hasHebrewStrongsKeys Boolean Information on whether the module has Strong's based keys (Hebrew)
hasFootnotes Boolean Information on whether the module has footnotes
hasHeadings Boolean Information on whether the module has headings
hasRedLetterWords Boolean Information on whether the module has red letter words
hasCrossReferences Boolean Information on whether the module has cross references
isRightToLeft Boolean Information on whether the module has right to left text direction

StrongsReference : Object

An object representation of a Strongs reference

Kind: global typedef
Properties

Name Type Description
text String The full text of the reference
key String The reference key

StrongsEntry : Object

An object representation of a Strong's entry.

Kind: global typedef
Properties

Name Type Description
rawEntry String The full raw entry from the SWORD Strong's module
key String The key of the Strong's entry
transcription String The transcription of the Strong's entry
phoneticTranscription String The phonetic transcription of the Strong's entry
definition String The Strong's definition
references Array.<StrongsReference> The "see also" references of the Strong's entry