proskomma-core 0.9.7 → 0.9.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.json +79 -0
- package/.gitattributes +2 -0
- package/babel.config.js +18 -0
- package/docs/_config.yml +1 -0
- package/docs/index.md +3 -0
- package/docs/pk_edit_0_9.odt +0 -0
- package/docs/pk_edit_0_9.pdf +0 -0
- package/docs/proskomma_101_slideshow.odp +0 -0
- package/docs/proskomma_101_slideshow.pdf +0 -0
- package/docs/proskomma_edit_html.png +0 -0
- package/docs/proskomma_edit_html.svg +451 -0
- package/docs/proskomma_edit_reference.png +0 -0
- package/docs/proskomma_edit_reference.svg +349 -0
- package/docs/repo_logo.png +0 -0
- package/esm/package.json +3 -0
- package/esm/wrapper.mjs +5 -0
- package/index.js +6 -0
- package/package.json +19 -17
- package/src/graph/index.cjs +201 -0
- package/src/graph/lib/do_cv.cjs +249 -0
- package/src/graph/lib/dump.cjs +40 -0
- package/src/graph/lib/remake_blocks.cjs +57 -0
- package/src/graph/lib/sequence_chars.cjs +84 -0
- package/src/graph/lib/sort.cjs +39 -0
- package/src/graph/lib/tribos.cjs +97 -0
- package/src/graph/lib/tribos_expression.cjs +556 -0
- package/src/graph/lib/tribos_ohm_UNUSED.cjs +37 -0
- package/src/graph/lib/tribos_step.cjs +434 -0
- package/src/graph/mutations/add.cjs +91 -0
- package/src/graph/mutations/delete.cjs +61 -0
- package/src/graph/mutations/index.cjs +54 -0
- package/src/graph/mutations/rehash.cjs +17 -0
- package/src/graph/mutations/tags.cjs +120 -0
- package/src/graph/mutations/update.cjs +210 -0
- package/src/graph/mutations/versification.cjs +96 -0
- package/src/graph/queries/block.cjs +228 -0
- package/src/graph/queries/cIndex.cjs +87 -0
- package/src/graph/queries/cell.cjs +42 -0
- package/src/graph/queries/cv.cjs +19 -0
- package/src/graph/queries/cvBook.cjs +16 -0
- package/src/graph/queries/cvChapter.cjs +16 -0
- package/src/graph/queries/cvIndex.cjs +47 -0
- package/src/graph/queries/cvNavigation.cjs +116 -0
- package/src/graph/queries/cvVerseElement.cjs +84 -0
- package/src/graph/queries/cvVerses.cjs +14 -0
- package/src/graph/queries/doc_set.cjs +220 -0
- package/src/graph/queries/document.cjs +555 -0
- package/src/graph/queries/idParts.cjs +30 -0
- package/src/graph/queries/index.cjs +151 -0
- package/src/graph/queries/inputBlockSpec.cjs +17 -0
- package/src/graph/queries/inputItemObject.cjs +12 -0
- package/src/graph/queries/input_att_spec.cjs +14 -0
- package/src/graph/queries/input_key_matches.cjs +11 -0
- package/src/graph/queries/input_key_value.cjs +11 -0
- package/src/graph/queries/input_key_values.cjs +11 -0
- package/src/graph/queries/input_selector_spec.cjs +19 -0
- package/src/graph/queries/item.cjs +71 -0
- package/src/graph/queries/itemGroup.cjs +75 -0
- package/src/graph/queries/key_value.cjs +18 -0
- package/src/graph/queries/kv_entry.cjs +21 -0
- package/src/graph/queries/kv_sequence.cjs +151 -0
- package/src/graph/queries/node.cjs +44 -0
- package/src/graph/queries/orig.cjs +11 -0
- package/src/graph/queries/regex_index.cjs +18 -0
- package/src/graph/queries/row_equals_spec.cjs +11 -0
- package/src/graph/queries/row_match_spec.cjs +11 -0
- package/src/graph/queries/selector_spec.cjs +29 -0
- package/src/graph/queries/sequence.cjs +314 -0
- package/src/graph/queries/table_sequence.cjs +192 -0
- package/src/graph/queries/tree_sequence.cjs +58 -0
- package/src/graph/queries/verseNumber.cjs +44 -0
- package/src/graph/queries/verseRange.cjs +11 -0
- package/src/graph/queries/versification.cjs +25 -0
- package/src/index.cjs +583 -0
- package/src/model/doc_set.cjs +389 -0
- package/src/model/doc_set_helpers/block.cjs +232 -0
- package/src/model/doc_set_helpers/enum.cjs +87 -0
- package/src/model/doc_set_helpers/item.cjs +198 -0
- package/src/model/doc_set_helpers/rehash.cjs +53 -0
- package/src/model/doc_set_helpers/selectors.cjs +58 -0
- package/src/model/doc_set_helpers/serialize.cjs +22 -0
- package/src/model/doc_set_helpers/unsuccinctify.cjs +288 -0
- package/src/model/doc_set_helpers/update.cjs +290 -0
- package/src/model/document.cjs +369 -0
- package/src/model/document_helpers/blocks.cjs +135 -0
- package/src/model/document_helpers/chapter_verse.cjs +291 -0
- package/src/model/document_helpers/pre_enums.cjs +67 -0
- package/src/model/document_helpers/sequences.cjs +205 -0
- package/src/model/document_helpers/serialize_succinct.cjs +55 -0
- package/src/model/document_helpers/succinct_filter.cjs +102 -0
- package/src/model/versifications/eng_vrs.cjs +455 -0
- package/src/model/versifications/index.cjs +38 -0
- package/src/model/versifications/lxx_vrs.cjs +950 -0
- package/src/model/versifications/org_vrs.cjs +155 -0
- package/src/model/versifications/rsc_vrs.cjs +342 -0
- package/src/model/versifications/rso_vrs.cjs +541 -0
- package/src/model/versifications/vul_vrs.cjs +835 -0
- package/src/parser/index.cjs +506 -0
- package/src/parser/lexers/index.cjs +11 -0
- package/src/parser/lexers/lexingRegexes.cjs +45 -0
- package/src/parser/lexers/nodes.cjs +123 -0
- package/src/parser/lexers/object_for_fragment.cjs +123 -0
- package/src/parser/lexers/tsv.cjs +45 -0
- package/src/parser/lexers/usfm.cjs +17 -0
- package/src/parser/lexers/usx/index.cjs +7 -0
- package/src/parser/lexers/usx/usx_lexer.cjs +321 -0
- package/src/parser/lib/tokenize.cjs +37 -0
- package/src/parser/model/index.cjs +637 -0
- package/src/parser/parser_specs.cjs +781 -0
- package/src/pipelines/perf2x/index.cjs +7 -0
- package/src/pipelines/perf2x/perf2PkJsonPipeline.json +41 -0
- package/src/pipelines/perf2x/perf2usfmPipeline.json +65 -0
- package/src/transforms/calculateUsfmChapterPositions.cjs +106 -0
- package/src/transforms/index.cjs +9 -0
- package/src/transforms/perf2PkJson.cjs +534 -0
- package/src/transforms/perf2usfm.cjs +294 -0
- package/src/util/byteArray.cjs +251 -0
- package/src/util/canons.cjs +117 -0
- package/src/util/enums.cjs +41 -0
- package/src/util/generateId.cjs +6 -0
- package/src/util/graftDefs.cjs +15 -0
- package/src/util/index.cjs +29 -0
- package/src/util/inspectSuccinct.cjs +59 -0
- package/src/util/itemDefs.cjs +33 -0
- package/src/util/parserConstantDefs.cjs +30 -0
- package/src/util/scopeDefs.cjs +173 -0
- package/src/util/scriptlike/blocksSpec.cjs +192 -0
- package/src/util/scriptlike/dodson_lexicon.xsl +19 -0
- package/src/util/scriptlike/dodson_lexicon_to_entries.cjs +85 -0
- package/src/util/scriptlike/open_scriptures_hebrew_lexicon.xsl +28 -0
- package/src/util/scriptlike/open_scriptures_hebrew_lexicon_to_entries.cjs +85 -0
- package/src/util/succinct.cjs +159 -0
- package/src/util/tags.cjs +28 -0
- package/src/util/tokenDefs.cjs +27 -0
- package/src/util/versification.cjs +364 -0
- package/test/code/main/bad.cjs +79 -0
- package/test/code/main/basics.cjs +534 -0
- package/test/code/main/block.cjs +586 -0
- package/test/code/main/block_scope_numbers.cjs +31 -0
- package/test/code/main/blocks_with_atts.cjs +150 -0
- package/test/code/main/blocks_with_cv.cjs +250 -0
- package/test/code/main/break.cjs +73 -0
- package/test/code/main/checksum.cjs +36 -0
- package/test/code/main/cl_global.cjs +35 -0
- package/test/code/main/class_for_fragment.cjs +18 -0
- package/test/code/main/clean_usfm.cjs +46 -0
- package/test/code/main/cp_vp.cjs +158 -0
- package/test/code/main/custom.cjs +124 -0
- package/test/code/main/cv.cjs +249 -0
- package/test/code/main/cvMatching.cjs +155 -0
- package/test/code/main/cv_indexes.cjs +189 -0
- package/test/code/main/cv_navigation.cjs +124 -0
- package/test/code/main/document.cjs +382 -0
- package/test/code/main/empty_blocks.cjs +71 -0
- package/test/code/main/entries.cjs +402 -0
- package/test/code/main/export_lexing_regexes.cjs +19 -0
- package/test/code/main/fig.cjs +67 -0
- package/test/code/main/filter.cjs +222 -0
- package/test/code/main/glossary.cjs +36 -0
- package/test/code/main/graft_headings.cjs +36 -0
- package/test/code/main/graft_introduction.cjs +96 -0
- package/test/code/main/graft_note.cjs +104 -0
- package/test/code/main/graft_rems.cjs +34 -0
- package/test/code/main/graft_sidebars.cjs +62 -0
- package/test/code/main/graft_title.cjs +36 -0
- package/test/code/main/hello.cjs +105 -0
- package/test/code/main/import_document.cjs +22 -0
- package/test/code/main/import_usfm_int.cjs +48 -0
- package/test/code/main/item_groups.cjs +133 -0
- package/test/code/main/items_with_cv.cjs +311 -0
- package/test/code/main/milestone_attributes.cjs +163 -0
- package/test/code/main/mixed_sequence_documents.cjs +137 -0
- package/test/code/main/mixed_sequences.cjs +217 -0
- package/test/code/main/modify_sequence.cjs +29 -0
- package/test/code/main/multiple_chapters.cjs +58 -0
- package/test/code/main/multiple_content.cjs +105 -0
- package/test/code/main/mutate_add.cjs +180 -0
- package/test/code/main/mutate_delete.cjs +236 -0
- package/test/code/main/mutate_rehash.cjs +68 -0
- package/test/code/main/mutate_tags.cjs +90 -0
- package/test/code/main/mutate_update.cjs +538 -0
- package/test/code/main/selectors.cjs +289 -0
- package/test/code/main/sequence.cjs +361 -0
- package/test/code/main/serialize.cjs +104 -0
- package/test/code/main/spans.cjs +51 -0
- package/test/code/main/split_long_tokens.cjs +30 -0
- package/test/code/main/standard_vrs.cjs +76 -0
- package/test/code/main/subclass.cjs +25 -0
- package/test/code/main/table.cjs +119 -0
- package/test/code/main/tags.cjs +248 -0
- package/test/code/main/token_alignment.cjs +84 -0
- package/test/code/main/trees.cjs +211 -0
- package/test/code/main/tribos.cjs +865 -0
- package/test/code/main/tsv.cjs +385 -0
- package/test/code/main/usx_ref.cjs +65 -0
- package/test/code/main/verse_mapping.cjs +252 -0
- package/test/code/main/verse_range.cjs +31 -0
- package/test/code/main/word_likes.cjs +41 -0
- package/test/code/utils/byte_array.cjs +271 -0
- package/test/code/utils/canons.cjs +20 -0
- package/test/code/utils/generate_id.cjs +17 -0
- package/test/code/utils/graft_defs.cjs +16 -0
- package/test/code/utils/inspect.cjs +130 -0
- package/test/code/utils/items.cjs +56 -0
- package/test/code/utils/push_succinct.cjs +69 -0
- package/test/code/utils/scope_defs.cjs +79 -0
- package/test/code/utils/serialize.cjs +28 -0
- package/test/code/utils/splice.cjs +67 -0
- package/test/code/utils/tags.cjs +69 -0
- package/test/code/utils/versification.cjs +249 -0
- package/test/lib/load.js +110 -0
- package/test/skipped_code/diff.js +53 -0
- package/test/test_data/inputBlockSpec/dodson.json +1654 -0
- package/test/test_data/inputBlockSpec/kv.json +326 -0
- package/test/test_data/inputBlockSpec/mk1.json +1019 -0
- package/test/test_data/inputBlockSpec/table.json +170 -0
- package/test/test_data/tree/genealogy.json +55 -0
- package/test/test_data/tree/jude.json +15965 -0
- package/test/test_data/tsv/en_tn_66-JUD.tsv +75 -0
- package/test/test_data/tsv/twl_JUD.tsv +144 -0
- package/test/test_data/usfm/1pe_webbe.usfm +13 -0
- package/test/test_data/usfm/66-JUD-ust.usfm +1089 -0
- package/test/test_data/usfm/78-GALspavbl.usfm +10 -0
- package/test/test_data/usfm/add_test.usfm +15 -0
- package/test/test_data/usfm/backslash.usfm +4 -0
- package/test/test_data/usfm/cl.usfm +14 -0
- package/test/test_data/usfm/cp_vp.usfm +8 -0
- package/test/test_data/usfm/custom.usfm +13 -0
- package/test/test_data/usfm/en_ust_oba.usfm +875 -0
- package/test/test_data/usfm/en_ust_psa_1.usfm +20 -0
- package/test/test_data/usfm/fig.usfm +3 -0
- package/test/test_data/usfm/filter.usfm +7 -0
- package/test/test_data/usfm/footnote.usfm +11 -0
- package/test/test_data/usfm/frt.usfm +4 -0
- package/test/test_data/usfm/headings.usfm +7 -0
- package/test/test_data/usfm/hello.usfm +8 -0
- package/test/test_data/usfm/int.usfm +7 -0
- package/test/test_data/usfm/milestone_attributes.usfm +7 -0
- package/test/test_data/usfm/milestone_attributes_default.usfm +7 -0
- package/test/test_data/usfm/no_break_space.usfm +4 -0
- package/test/test_data/usfm/no_mt.usfm +6 -0
- package/test/test_data/usfm/rems.usfm +6 -0
- package/test/test_data/usfm/section_intros.usfm +26 -0
- package/test/test_data/usfm/sidebars.usfm +25 -0
- package/test/test_data/usfm/slash_in_att.usfm +6 -0
- package/test/test_data/usfm/soft_line_break.usfm +4 -0
- package/test/test_data/usfm/spans.usfm +5 -0
- package/test/test_data/usfm/split_long_tokens.usfm +6 -0
- package/test/test_data/usfm/table.usfm +18 -0
- package/test/test_data/usfm/table_at_end.usfm +11 -0
- package/test/test_data/usfm/table_in_intro.usfm +22 -0
- package/test/test_data/usfm/table_no_end_cells.usfm +18 -0
- package/test/test_data/usfm/tit_kitchen_sink.usfm +73 -0
- package/test/test_data/usfm/titus_template.usfm +58 -0
- package/test/test_data/usfm/ugnt_3jn.usfm +265 -0
- package/test/test_data/usfm/ult_3jn.usfm +335 -0
- package/test/test_data/usfm/unknown.usfm +5 -0
- package/test/test_data/usfm/ust_psa.usfm +29 -0
- package/test/test_data/usfm/ust_psa_verse_ranges.usfm +24 -0
- package/test/test_data/usfm/ust_psa_with_ts.usfm +29 -0
- package/test/test_data/usfm/verse_breaks_in_blocks.usfm +20 -0
- package/test/test_data/usfm/verse_range.usfm +7 -0
- package/test/test_data/usfm/web_ecc.usfm +391 -0
- package/test/test_data/usfm/web_psa51.usfm +71 -0
- package/test/test_data/usfm/whitespace.usfm +12 -0
- package/test/test_data/usfm/xref.usfm +11 -0
- package/test/test_data/usx/bad_element.usx +2 -0
- package/test/test_data/usx/cp_vp.usx +12 -0
- package/test/test_data/usx/diff1.usx +59 -0
- package/test/test_data/usx/diff2.usx +74 -0
- package/test/test_data/usx/douay_rheims_ecc.usx +58 -0
- package/test/test_data/usx/douay_rheims_psa.usx +5366 -0
- package/test/test_data/usx/douay_rheims_psa_40_60.usx +666 -0
- package/test/test_data/usx/douay_rheims_rut.usx +26 -0
- package/test/test_data/usx/esg3.usx +47 -0
- package/test/test_data/usx/fig.usx +6 -0
- package/test/test_data/usx/milestone_attributes.usx +11 -0
- package/test/test_data/usx/not_nfc18_glo.usx +9 -0
- package/test/test_data/usx/not_nfc18_phm.usx +24 -0
- package/test/test_data/usx/opt_break.usx +10 -0
- package/test/test_data/usx/sidebars.usx +29 -0
- package/test/test_data/usx/table.usx +23 -0
- package/test/test_data/usx/web_psa.usx +8489 -0
- package/test/test_data/usx/web_psa150.usx +33 -0
- package/test/test_data/usx/web_psa_40_60.usx +1079 -0
- package/test/test_data/usx/web_rut.usx +95 -0
- package/test/test_data/usx/web_rut_1.usx +17 -0
- package/test/test_data/utils/douay_rheims.vrs +520 -0
- package/test/test_data/utils/douay_rheims_PSA.usx +5366 -0
- package/test/test_data/utils/serialize_example.json +91 -0
- package/test/test_data/utils/truncated_versification.vrs +29 -0
- package/test/test_data/utils/web_rut_items.json +2977 -0
- package/test/test_data/utils/webbe.vrs +395 -0
- package/test/test_data/utils/webbe_PSA.usx +8489 -0
- package/test/test_data/vrs/douay_rheims.vrs +520 -0
- package/test/test_data/vrs/truncated_versification.vrs +27 -0
- package/test/test_data/vrs/webbe.vrs +397 -0
- package/webpack.prod.js +50 -0
- package/dist/index.js +0 -8
- package/dist/index.js.LICENSE.txt +0 -23
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
const test = require('tape');
|
|
2
|
+
|
|
3
|
+
const { pkWithDoc } = require('../../lib/load.js');
|
|
4
|
+
|
|
5
|
+
const testGroup = 'CV Indexes';
|
|
6
|
+
|
|
7
|
+
const pk = pkWithDoc('../test_data/usx/web_rut.usx', {
|
|
8
|
+
lang: 'eng',
|
|
9
|
+
abbr: 'web',
|
|
10
|
+
})[0];
|
|
11
|
+
|
|
12
|
+
const pk2 = pkWithDoc('../test_data/usfm/web_psa51.usfm', {
|
|
13
|
+
lang: 'eng',
|
|
14
|
+
abbr: 'web',
|
|
15
|
+
})[0];
|
|
16
|
+
|
|
17
|
+
const pk3 = pkWithDoc('../test_data/usfm/verse_range.usfm', {
|
|
18
|
+
lang: 'eng',
|
|
19
|
+
abbr: 'web',
|
|
20
|
+
})[0];
|
|
21
|
+
|
|
22
|
+
const rangeQuery = 'startBlock startItem endBlock endItem nextToken ' +
|
|
23
|
+
'items { type subType payload } ' +
|
|
24
|
+
'tokens { type subType payload } ' +
|
|
25
|
+
'wordLikes: tokens(withSubTypes:"wordLike") { type subType payload } ' +
|
|
26
|
+
'text normalized: text(normalizeSpace:true) dumpItems';
|
|
27
|
+
const cvQuery = `{ chapter verseNumbers { number range } verseRanges { range numbers } verses { verse { ${rangeQuery} verseRange } } }`;
|
|
28
|
+
const cQuery = `{ chapter ${rangeQuery} }`;
|
|
29
|
+
const cvCharsQuery = `{ chapter verses { verse { tokens(includeContext:true withChars:["Ruth", "Boaz", "Naomi"]) { payload position} text } } }`;
|
|
30
|
+
|
|
31
|
+
const checkIndexFields = (t, index) => {
|
|
32
|
+
t.ok('startBlock' in index);
|
|
33
|
+
t.ok('endBlock' in index);
|
|
34
|
+
t.ok('startItem' in index);
|
|
35
|
+
t.ok('endItem' in index);
|
|
36
|
+
t.ok('nextToken' in index);
|
|
37
|
+
t.ok(index.text.length > 0);
|
|
38
|
+
t.ok(index.items.length > 0);
|
|
39
|
+
t.ok(index.tokens.length > 0);
|
|
40
|
+
t.ok(index.wordLikes.length > 0);
|
|
41
|
+
t.ok(index.dumpItems.length > 0);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
test(
|
|
45
|
+
`cvIndexes (${testGroup})`,
|
|
46
|
+
async function (t) {
|
|
47
|
+
try {
|
|
48
|
+
t.plan(1 + 10);
|
|
49
|
+
const query =
|
|
50
|
+
`{ documents { cvIndexes ${cvQuery} } }`;
|
|
51
|
+
const result = await pk.gqlQuery(query);
|
|
52
|
+
t.equal(result.errors, undefined);
|
|
53
|
+
const index = result.data.documents[0].cvIndexes[0];
|
|
54
|
+
checkIndexFields(t, index.verses[1].verse[0]);
|
|
55
|
+
} catch (err) {
|
|
56
|
+
console.log(err);
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
test(
|
|
62
|
+
`cIndexes (${testGroup})`,
|
|
63
|
+
async function (t) {
|
|
64
|
+
try {
|
|
65
|
+
t.plan(1 + 10);
|
|
66
|
+
const query =
|
|
67
|
+
`{ documents { cIndexes ${cQuery} } }`;
|
|
68
|
+
const result = await pk.gqlQuery(query);
|
|
69
|
+
t.equal(result.errors, undefined);
|
|
70
|
+
const index = result.data.documents[0].cIndexes[0];
|
|
71
|
+
checkIndexFields(t, index);
|
|
72
|
+
// console.log(JSON.stringify(result.data.documents[0].cIndexes, null, 2));
|
|
73
|
+
} catch (err) {
|
|
74
|
+
console.log(err);
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
test(
|
|
80
|
+
`cvIndex (${testGroup})`,
|
|
81
|
+
async function (t) {
|
|
82
|
+
try {
|
|
83
|
+
t.plan(2 + 10 + 6);
|
|
84
|
+
let query =
|
|
85
|
+
`{ documents { cvIndex(chapter:3) ${cvQuery} } }`;
|
|
86
|
+
let result = await pk.gqlQuery(query);
|
|
87
|
+
t.equal(result.errors, undefined);
|
|
88
|
+
let index = result.data.documents[0].cvIndex;
|
|
89
|
+
t.equal(index.chapter, 3);
|
|
90
|
+
checkIndexFields(t, index.verses[1].verse[0]);
|
|
91
|
+
const verseNumbers = result.data.documents[0].cvIndex.verseNumbers;
|
|
92
|
+
t.equal(verseNumbers.length, 18);
|
|
93
|
+
t.equal(Math.max(...verseNumbers.map(n => n.number)), 18);
|
|
94
|
+
t.equal(Math.min(...verseNumbers.map(n => n.number)), 1);
|
|
95
|
+
query =
|
|
96
|
+
`{ documents { cvIndex(chapter:9) ${cvQuery} } }`;
|
|
97
|
+
result = await pk.gqlQuery(query);
|
|
98
|
+
t.equal(result.errors, undefined);
|
|
99
|
+
index = result.data.documents[0].cvIndex;
|
|
100
|
+
t.equal(index.chapter, 9);
|
|
101
|
+
t.equal(index.verses.length, 0);
|
|
102
|
+
} catch (err) {
|
|
103
|
+
console.log(err);
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
test(
|
|
109
|
+
`cvIndex v0 (${testGroup})`,
|
|
110
|
+
async function (t) {
|
|
111
|
+
try {
|
|
112
|
+
t.plan(4);
|
|
113
|
+
let query =
|
|
114
|
+
`{ documents { cvIndex(chapter:51) ${cvQuery} } }`;
|
|
115
|
+
let result = await pk2.gqlQuery(query);
|
|
116
|
+
t.equal(result.errors, undefined);
|
|
117
|
+
const verseNumbers = result.data.documents[0].cvIndex.verseNumbers;
|
|
118
|
+
t.equal(verseNumbers.length, 20);
|
|
119
|
+
t.equal(Math.max(...verseNumbers.map(n => n.number)), 19);
|
|
120
|
+
t.equal(Math.min(...verseNumbers.map(n => n.number)), 0);
|
|
121
|
+
// console.log(JSON.stringify(result.data.documents[0].cvIndex.verses.map(v => v.verse[0].dumpItems), null, 2));
|
|
122
|
+
} catch (err) {
|
|
123
|
+
console.log(err);
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
);
|
|
127
|
+
|
|
128
|
+
test(
|
|
129
|
+
`cvIndex verseRanges (${testGroup})`,
|
|
130
|
+
async function (t) {
|
|
131
|
+
try {
|
|
132
|
+
t.plan(6);
|
|
133
|
+
let query =
|
|
134
|
+
`{ documents { cvIndex(chapter:1) ${cvQuery} } }`;
|
|
135
|
+
let result = await pk3.gqlQuery(query);
|
|
136
|
+
t.equal(result.errors, undefined);
|
|
137
|
+
// console.log(JSON.stringify(result.data.documents[0].cvIndex.verseRanges, null, 2));
|
|
138
|
+
const verseRanges = result.data.documents[0].cvIndex.verseRanges;
|
|
139
|
+
t.equal(verseRanges.length, 1);
|
|
140
|
+
t.equal(verseRanges[0].range, '1-2');
|
|
141
|
+
t.equal(verseRanges[0].numbers.length, 2);
|
|
142
|
+
t.equal(verseRanges[0].numbers[0], 1);
|
|
143
|
+
t.equal(verseRanges[0].numbers[1], 2);
|
|
144
|
+
} catch (err) {
|
|
145
|
+
console.log(err);
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
);
|
|
149
|
+
|
|
150
|
+
test(
|
|
151
|
+
`cIndex (${testGroup})`,
|
|
152
|
+
async function (t) {
|
|
153
|
+
try {
|
|
154
|
+
t.plan(2 + 10 + 3);
|
|
155
|
+
let query =
|
|
156
|
+
`{ documents { cIndex(chapter:3) ${cQuery} } }`;
|
|
157
|
+
let result = await pk.gqlQuery(query);
|
|
158
|
+
t.equal(result.errors, undefined);
|
|
159
|
+
let index = result.data.documents[0].cIndex;
|
|
160
|
+
t.equal(index.chapter, 3);
|
|
161
|
+
checkIndexFields(t, index);
|
|
162
|
+
query =
|
|
163
|
+
`{ documents { cIndex(chapter:9) ${cQuery} } }`;
|
|
164
|
+
result = await pk.gqlQuery(query);
|
|
165
|
+
t.equal(result.errors, undefined);
|
|
166
|
+
index = result.data.documents[0].cIndex;
|
|
167
|
+
t.equal(index.chapter, 9);
|
|
168
|
+
t.equal(index.startBlock, null);
|
|
169
|
+
} catch (err) {
|
|
170
|
+
console.log(err);
|
|
171
|
+
}
|
|
172
|
+
},
|
|
173
|
+
);
|
|
174
|
+
|
|
175
|
+
test(
|
|
176
|
+
`cvIndexes withChars (${testGroup})`,
|
|
177
|
+
async function (t) {
|
|
178
|
+
try {
|
|
179
|
+
t.plan(1);
|
|
180
|
+
let query =
|
|
181
|
+
`{ documents { cvIndexes ${cvCharsQuery} } }`;
|
|
182
|
+
let result = await pk.gqlQuery(query);
|
|
183
|
+
t.equal(result.errors, undefined);
|
|
184
|
+
// console.log(JSON.stringify(result.data, null, 2));
|
|
185
|
+
} catch (err) {
|
|
186
|
+
console.log(err);
|
|
187
|
+
}
|
|
188
|
+
},
|
|
189
|
+
);
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/* eslint-disable no-await-in-loop */
|
|
2
|
+
const test = require('tape');
|
|
3
|
+
|
|
4
|
+
const { pkWithDoc } = require('../../lib/load.js');
|
|
5
|
+
|
|
6
|
+
const testGroup = 'cv Navigation';
|
|
7
|
+
|
|
8
|
+
const pk = pkWithDoc('../test_data/usx/web_rut.usx', {
|
|
9
|
+
lang: 'eng',
|
|
10
|
+
abbr: 'web',
|
|
11
|
+
})[0];
|
|
12
|
+
|
|
13
|
+
const pk2 = pkWithDoc('../test_data/usx/web_psa_40_60.usx', {
|
|
14
|
+
lang: 'eng',
|
|
15
|
+
abbr: 'web',
|
|
16
|
+
})[0];
|
|
17
|
+
|
|
18
|
+
const pk3 = pkWithDoc('../test_data/usfm/ust_psa_verse_ranges.usfm', {
|
|
19
|
+
lang: 'eng',
|
|
20
|
+
abbr: 'ust',
|
|
21
|
+
})[0];
|
|
22
|
+
|
|
23
|
+
test(
|
|
24
|
+
`Next/Previous Chapter (${testGroup})`,
|
|
25
|
+
async function (t) {
|
|
26
|
+
try {
|
|
27
|
+
const expected = [
|
|
28
|
+
['2', '1', '3'],
|
|
29
|
+
['1', null, '2'],
|
|
30
|
+
['4', '3', null],
|
|
31
|
+
['5', null, null],
|
|
32
|
+
];
|
|
33
|
+
t.plan(3 * expected.length);
|
|
34
|
+
|
|
35
|
+
for (const [chap, prev, next] of expected) {
|
|
36
|
+
const query =
|
|
37
|
+
'{ documents { nav: cvNavigation(chapter:"%c%" verse:"3") { previousChapter nextChapter } } }'
|
|
38
|
+
.replace('%c%', chap);
|
|
39
|
+
const result = await pk.gqlQuery(query);
|
|
40
|
+
t.equal(result.errors, undefined);
|
|
41
|
+
const nav = result.data.documents[0].nav;
|
|
42
|
+
t.equal(nav.previousChapter, prev);
|
|
43
|
+
t.equal(nav.nextChapter, next);
|
|
44
|
+
}
|
|
45
|
+
} catch (err) {
|
|
46
|
+
console.log(err);
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
test(
|
|
52
|
+
`Next/Previous Verse (${testGroup})`,
|
|
53
|
+
async function (t) {
|
|
54
|
+
try {
|
|
55
|
+
const expected = [
|
|
56
|
+
[pk, 2, 3, 2, 2, 2, 4],
|
|
57
|
+
[pk, 1, 22, 1, 21, 2, 1],
|
|
58
|
+
[pk, 2, 1, 1, 22, 2, 2],
|
|
59
|
+
[pk, 1, 1, null, null, 1, 2],
|
|
60
|
+
[pk, 5, 1, null, null, null, null],
|
|
61
|
+
[pk, 1, 0, null, null, null, null],
|
|
62
|
+
[pk, 1, 50, null, null, null, null],
|
|
63
|
+
[pk2, 50, 23, 50, 22, 51, 0],
|
|
64
|
+
[pk2, 51, 1, 51, 0, 51, 2],
|
|
65
|
+
[pk2, 51, 0, 50, 23, 51, 1],
|
|
66
|
+
];
|
|
67
|
+
t.plan(5 * expected.length);
|
|
68
|
+
|
|
69
|
+
for (const [pros, chap, verse, prevChap, prevVerse, nextChap, nextVerse] of expected) {
|
|
70
|
+
const query =
|
|
71
|
+
'{ documents { nav: cvNavigation(chapter:"%c%" verse:"%v%") { previousVerse { chapter verse } nextVerse { chapter verse } } } }'
|
|
72
|
+
.replace('%c%', chap)
|
|
73
|
+
.replace('%v%', verse);
|
|
74
|
+
const result = await pros.gqlQuery(query);
|
|
75
|
+
t.equal(result.errors, undefined);
|
|
76
|
+
const nav = result.data.documents[0].nav;
|
|
77
|
+
t.equal(nav.nextVerse && nav.nextVerse.chapter, nextChap);
|
|
78
|
+
t.equal(nav.nextVerse && nav.nextVerse.verse, nextVerse);
|
|
79
|
+
t.equal(nav.previousVerse && nav.previousVerse.chapter, prevChap);
|
|
80
|
+
t.equal(nav.previousVerse && nav.previousVerse.verse, prevVerse);
|
|
81
|
+
}
|
|
82
|
+
} catch (err) {
|
|
83
|
+
console.log(err);
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
test(
|
|
89
|
+
`Next/Previous VerseRangeVerse (${testGroup})`,
|
|
90
|
+
async function (t) {
|
|
91
|
+
try {
|
|
92
|
+
const expected = [
|
|
93
|
+
[pk, 2, 3, 2, 2, 2, 4],
|
|
94
|
+
[pk, 1, 22, 1, 21, 2, 1],
|
|
95
|
+
[pk, 2, 1, 1, 22, 2, 2],
|
|
96
|
+
[pk, 1, 1, null, null, 1, 2],
|
|
97
|
+
[pk, 5, 1, null, null, null, null],
|
|
98
|
+
[pk, 1, 0, null, null, null, null],
|
|
99
|
+
[pk, 1, 50, null, null, null, null],
|
|
100
|
+
[pk2, 50, 23, 50, 22, 51, 0],
|
|
101
|
+
[pk2, 51, 1, 51, 0, 51, 2],
|
|
102
|
+
[pk2, 51, 0, 50, 23, 51, 1],
|
|
103
|
+
[pk3, 150, 4, 150, 2, 150, 6],
|
|
104
|
+
];
|
|
105
|
+
t.plan(5 * expected.length);
|
|
106
|
+
|
|
107
|
+
for (const [pros, chap, verse, prevChap, prevVerse, nextChap, nextVerse] of expected) {
|
|
108
|
+
const query =
|
|
109
|
+
'{ documents { nav: cvNavigation(chapter:"%c%" verse:"%v%") { previousVerseRangeVerse { chapter verse } nextVerseRangeVerse { chapter verse } } } }'
|
|
110
|
+
.replace('%c%', chap)
|
|
111
|
+
.replace('%v%', verse);
|
|
112
|
+
const result = await pros.gqlQuery(query);
|
|
113
|
+
t.equal(result.errors, undefined);
|
|
114
|
+
const nav = result.data.documents[0].nav;
|
|
115
|
+
t.equal(nav.nextVerseRangeVerse && nav.nextVerseRangeVerse.chapter, nextChap);
|
|
116
|
+
t.equal(nav.nextVerseRangeVerse && nav.nextVerseRangeVerse.verse, nextVerse);
|
|
117
|
+
t.equal(nav.previousVerseRangeVerse && nav.previousVerseRangeVerse.chapter, prevChap);
|
|
118
|
+
t.equal(nav.previousVerseRangeVerse && nav.previousVerseRangeVerse.verse, prevVerse);
|
|
119
|
+
}
|
|
120
|
+
} catch (err) {
|
|
121
|
+
console.log(err);
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
);
|
|
@@ -0,0 +1,382 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const test = require('tape');
|
|
3
|
+
const fse = require('fs-extra');
|
|
4
|
+
const deepEqual = require('deep-equal');
|
|
5
|
+
|
|
6
|
+
const { Proskomma } = require('../../../src/index.cjs');
|
|
7
|
+
|
|
8
|
+
const { pkWithDoc } = require('../../lib/load.js');
|
|
9
|
+
|
|
10
|
+
const testGroup = 'Graph Document';
|
|
11
|
+
|
|
12
|
+
const pk = pkWithDoc('../test_data/usx/web_rut.usx', {
|
|
13
|
+
lang: 'eng',
|
|
14
|
+
abbr: 'web',
|
|
15
|
+
})[0];
|
|
16
|
+
|
|
17
|
+
const pk2 = new Proskomma();
|
|
18
|
+
const fp = '../../test_data/usfm/int.usfm';
|
|
19
|
+
const content = fse.readFileSync(path.resolve(__dirname, fp));
|
|
20
|
+
|
|
21
|
+
pk2.importUsfmPeriph(
|
|
22
|
+
{ lang: 'eng', abbr: 'abc' },
|
|
23
|
+
content,
|
|
24
|
+
{},
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
const pk3 = pkWithDoc('../test_data/usfm/78-GALspavbl.usfm', {
|
|
28
|
+
lang: 'spa',
|
|
29
|
+
abbr: 'vbl',
|
|
30
|
+
})[0];
|
|
31
|
+
|
|
32
|
+
test(
|
|
33
|
+
`DocSetId (${testGroup})`,
|
|
34
|
+
async function (t) {
|
|
35
|
+
try {
|
|
36
|
+
t.plan(3);
|
|
37
|
+
const query = '{ documents { docSetId } }';
|
|
38
|
+
const result = await pk.gqlQuery(query);
|
|
39
|
+
t.equal(result.errors, undefined);
|
|
40
|
+
t.ok('documents' in result.data);
|
|
41
|
+
t.ok('docSetId' in result.data.documents[0]);
|
|
42
|
+
} catch
|
|
43
|
+
(err) {
|
|
44
|
+
console.log(err);
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
test(
|
|
50
|
+
`Headers (${testGroup})`,
|
|
51
|
+
async function (t) {
|
|
52
|
+
try {
|
|
53
|
+
t.plan(6);
|
|
54
|
+
const query = '{ documents { headers { key value } toc: header(id:"toc") } }';
|
|
55
|
+
const result = await pk.gqlQuery(query);
|
|
56
|
+
t.equal(result.errors, undefined);
|
|
57
|
+
t.ok('documents' in result.data);
|
|
58
|
+
t.ok('headers' in result.data.documents[0]);
|
|
59
|
+
t.equal(result.data.documents[0].headers.length, 7);
|
|
60
|
+
t.equal(result.data.documents[0].headers.filter(h => h.key === 'toc')[0].value, 'The Book of Ruth');
|
|
61
|
+
t.equal(result.data.documents[0].toc, 'The Book of Ruth');
|
|
62
|
+
} catch
|
|
63
|
+
(err) {
|
|
64
|
+
console.log(err);
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
test(
|
|
70
|
+
`Headers with accents (${testGroup})`,
|
|
71
|
+
async function (t) {
|
|
72
|
+
try {
|
|
73
|
+
t.plan(6);
|
|
74
|
+
const query = '{ documents { headers { key value } toc: header(id:"toc") } }';
|
|
75
|
+
const result = await pk3.gqlQuery(query);
|
|
76
|
+
t.equal(result.errors, undefined);
|
|
77
|
+
t.ok('documents' in result.data);
|
|
78
|
+
t.ok('headers' in result.data.documents[0]);
|
|
79
|
+
t.equal(result.data.documents[0].headers.length, 5);
|
|
80
|
+
t.equal(result.data.documents[0].headers.filter(h => h.key === 'toc')[0].value, 'Gálatas');
|
|
81
|
+
t.equal(result.data.documents[0].toc, 'Gálatas');
|
|
82
|
+
} catch (err) {
|
|
83
|
+
console.log(err);
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
test(
|
|
89
|
+
`ID Parts (${testGroup})`,
|
|
90
|
+
async function (t) {
|
|
91
|
+
try {
|
|
92
|
+
t.plan(14);
|
|
93
|
+
const query = '{ documents { idParts { type parts part(index:0) nullPart: part(index:9) } } }';
|
|
94
|
+
let result = await pk.gqlQuery(query);
|
|
95
|
+
t.equal(result.errors, undefined);
|
|
96
|
+
let idParts = result.data.documents[0].idParts;
|
|
97
|
+
t.equal(idParts.type, 'book');
|
|
98
|
+
t.equal(idParts.parts.length, 2);
|
|
99
|
+
t.equal(idParts.parts[0], 'RUT');
|
|
100
|
+
t.equal(idParts.part, 'RUT');
|
|
101
|
+
t.ok(!idParts.nullPart);
|
|
102
|
+
result = await pk2.gqlQuery(query);
|
|
103
|
+
t.equal(result.errors, undefined);
|
|
104
|
+
idParts = result.data.documents[0].idParts;
|
|
105
|
+
t.equal(idParts.type, 'periph');
|
|
106
|
+
t.equal(idParts.parts.length, 4);
|
|
107
|
+
t.equal(idParts.parts[0], 'P00');
|
|
108
|
+
t.equal(idParts.parts[1], 'INT');
|
|
109
|
+
t.equal(idParts.parts[2], 'intbible');
|
|
110
|
+
t.equal(idParts.part, 'P00');
|
|
111
|
+
t.ok(!idParts.nullPart);
|
|
112
|
+
} catch (err) {
|
|
113
|
+
console.log(err);
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
);
|
|
117
|
+
|
|
118
|
+
test(
|
|
119
|
+
`mainSequence (${testGroup})`,
|
|
120
|
+
async function (t) {
|
|
121
|
+
try {
|
|
122
|
+
t.plan(4);
|
|
123
|
+
const query = '{ documents { mainSequence { id } } }';
|
|
124
|
+
const result = await pk.gqlQuery(query);
|
|
125
|
+
t.equal(result.errors, undefined);
|
|
126
|
+
t.ok('documents' in result.data);
|
|
127
|
+
t.ok('mainSequence' in result.data.documents[0]);
|
|
128
|
+
t.ok('id' in result.data.documents[0].mainSequence);
|
|
129
|
+
} catch
|
|
130
|
+
(err) {
|
|
131
|
+
console.log(err);
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
);
|
|
135
|
+
|
|
136
|
+
test(
|
|
137
|
+
`Sequences (${testGroup})`,
|
|
138
|
+
async function (t) {
|
|
139
|
+
try {
|
|
140
|
+
t.plan(4);
|
|
141
|
+
const query = '{ documents { sequences { id } } }';
|
|
142
|
+
const result = await pk.gqlQuery(query);
|
|
143
|
+
t.equal(result.errors, undefined);
|
|
144
|
+
t.ok('documents' in result.data);
|
|
145
|
+
t.ok('sequences' in result.data.documents[0]);
|
|
146
|
+
t.ok('id' in result.data.documents[0].sequences[0]);
|
|
147
|
+
} catch (err) {
|
|
148
|
+
console.log(err);
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
);
|
|
152
|
+
|
|
153
|
+
test(
|
|
154
|
+
`Sequences by type and ids (${testGroup})`,
|
|
155
|
+
async function (t) {
|
|
156
|
+
try {
|
|
157
|
+
t.plan(11);
|
|
158
|
+
let query = '{ documents { sequences(types:"main") { id type } } }';
|
|
159
|
+
let result = await pk.gqlQuery(query);
|
|
160
|
+
t.equal(result.errors, undefined);
|
|
161
|
+
t.ok('documents' in result.data);
|
|
162
|
+
t.ok('sequences' in result.data.documents[0]);
|
|
163
|
+
t.equal(result.data.documents[0].sequences.length, 1);
|
|
164
|
+
const mainSequence = result.data.documents[0].sequences[0];
|
|
165
|
+
t.equal(mainSequence.type, 'main');
|
|
166
|
+
const mainId = mainSequence.id;
|
|
167
|
+
query = `{ documents { sequences(ids:"${mainId}") { id type } } }`;
|
|
168
|
+
result = await pk.gqlQuery(query);
|
|
169
|
+
t.equal(result.errors, undefined);
|
|
170
|
+
t.ok('documents' in result.data);
|
|
171
|
+
t.ok('sequences' in result.data.documents[0]);
|
|
172
|
+
t.equal(result.data.documents[0].sequences.length, 1);
|
|
173
|
+
const foundSequence = result.data.documents[0].sequences[0];
|
|
174
|
+
t.equal(foundSequence.id, mainId);
|
|
175
|
+
t.equal(foundSequence.type, 'main');
|
|
176
|
+
} catch (err) {
|
|
177
|
+
console.log(err);
|
|
178
|
+
}
|
|
179
|
+
},
|
|
180
|
+
);
|
|
181
|
+
|
|
182
|
+
test(
|
|
183
|
+
`Sequence (${testGroup})`,
|
|
184
|
+
async function (t) {
|
|
185
|
+
try {
|
|
186
|
+
t.plan(10);
|
|
187
|
+
let query = '{ documents { mainSequence { id } } }';
|
|
188
|
+
let result = await pk.gqlQuery(query);
|
|
189
|
+
t.equal(result.errors, undefined);
|
|
190
|
+
const mainId = result.data.documents[0].mainSequence.id;
|
|
191
|
+
query = `{ documents { sequence(id:"${mainId}") { id type } } }`;
|
|
192
|
+
result = await pk.gqlQuery(query);
|
|
193
|
+
t.equal(result.errors, undefined);
|
|
194
|
+
t.ok('documents' in result.data);
|
|
195
|
+
t.ok('sequence' in result.data.documents[0]);
|
|
196
|
+
const foundSequence = result.data.documents[0].sequence;
|
|
197
|
+
t.equal(foundSequence.id, mainId);
|
|
198
|
+
t.equal(foundSequence.type, 'main');
|
|
199
|
+
query = `{ documents { sequence(id:"banana") { id type } } }`;
|
|
200
|
+
result = await pk.gqlQuery(query);
|
|
201
|
+
t.equal(result.errors, undefined);
|
|
202
|
+
t.ok('documents' in result.data);
|
|
203
|
+
t.ok('sequence' in result.data.documents[0]);
|
|
204
|
+
t.equal(result.data.documents[0].sequence, null);
|
|
205
|
+
} catch (err) {
|
|
206
|
+
console.log(err);
|
|
207
|
+
}
|
|
208
|
+
},
|
|
209
|
+
);
|
|
210
|
+
|
|
211
|
+
test(
|
|
212
|
+
`mainBlocks (${testGroup})`,
|
|
213
|
+
async function (t) {
|
|
214
|
+
try {
|
|
215
|
+
t.plan(4);
|
|
216
|
+
const query = '{ documents { mainBlocks { text } } }';
|
|
217
|
+
const result = await pk.gqlQuery(query);
|
|
218
|
+
t.equal(result.errors, undefined);
|
|
219
|
+
t.ok('documents' in result.data);
|
|
220
|
+
t.ok('mainBlocks' in result.data.documents[0]);
|
|
221
|
+
t.ok(result.data.documents[0].mainBlocks[0].text.startsWith('In the days when'));
|
|
222
|
+
} catch (err) {
|
|
223
|
+
console.log(err);
|
|
224
|
+
}
|
|
225
|
+
},
|
|
226
|
+
);
|
|
227
|
+
|
|
228
|
+
test(
|
|
229
|
+
`mainBlocksText (${testGroup})`,
|
|
230
|
+
async function (t) {
|
|
231
|
+
try {
|
|
232
|
+
t.plan(5);
|
|
233
|
+
const query = '{ documents { mainBlocksText normalized: mainBlocksText(normalizeSpace:true) } }';
|
|
234
|
+
const result = await pk.gqlQuery(query);
|
|
235
|
+
t.equal(result.errors, undefined);
|
|
236
|
+
t.ok('documents' in result.data);
|
|
237
|
+
t.ok('mainBlocksText' in result.data.documents[0]);
|
|
238
|
+
t.ok(result.data.documents[0].mainBlocksText[0].startsWith('In the days when'));
|
|
239
|
+
t.ok(result.data.documents[0].normalized[0].startsWith('In the days when'));
|
|
240
|
+
} catch (err) {
|
|
241
|
+
console.log(err);
|
|
242
|
+
}
|
|
243
|
+
},
|
|
244
|
+
);
|
|
245
|
+
|
|
246
|
+
test(
|
|
247
|
+
`mainBlocksItems (${testGroup})`,
|
|
248
|
+
async function (t) {
|
|
249
|
+
try {
|
|
250
|
+
t.plan(7);
|
|
251
|
+
const query = '{ documents { mainBlocksItems { type subType payload } } }';
|
|
252
|
+
const result = await pk.gqlQuery(query);
|
|
253
|
+
t.equal(result.errors, undefined);
|
|
254
|
+
t.ok('documents' in result.data);
|
|
255
|
+
t.ok('mainBlocksItems' in result.data.documents[0]);
|
|
256
|
+
t.equal(result.data.documents[0].mainBlocksItems[0][0].payload, 'chapter/1');
|
|
257
|
+
t.equal(result.data.documents[0].mainBlocksItems[0][1].payload, 'verse/1');
|
|
258
|
+
t.equal(result.data.documents[0].mainBlocksItems[0][2].payload, 'verses/1');
|
|
259
|
+
t.equal(result.data.documents[0].mainBlocksItems[0][3].payload, 'In');
|
|
260
|
+
} catch (err) {
|
|
261
|
+
console.log(err);
|
|
262
|
+
}
|
|
263
|
+
},
|
|
264
|
+
);
|
|
265
|
+
|
|
266
|
+
test(
|
|
267
|
+
`mainBlocksTokens (${testGroup})`,
|
|
268
|
+
async function (t) {
|
|
269
|
+
try {
|
|
270
|
+
t.plan(4);
|
|
271
|
+
const query = '{ documents { mainBlocksTokens { type subType payload } } }';
|
|
272
|
+
const result = await pk.gqlQuery(query);
|
|
273
|
+
t.equal(result.errors, undefined);
|
|
274
|
+
t.ok('documents' in result.data);
|
|
275
|
+
t.ok('mainBlocksTokens' in result.data.documents[0]);
|
|
276
|
+
t.equal(result.data.documents[0].mainBlocksTokens[0][0].payload, 'In');
|
|
277
|
+
} catch (err) {
|
|
278
|
+
console.log(err);
|
|
279
|
+
}
|
|
280
|
+
},
|
|
281
|
+
);
|
|
282
|
+
|
|
283
|
+
test(
|
|
284
|
+
`mainText (${testGroup})`,
|
|
285
|
+
async function (t) {
|
|
286
|
+
try {
|
|
287
|
+
t.plan(5);
|
|
288
|
+
const query = '{ documents { mainText normalized: mainText(normalizeSpace:true) } }';
|
|
289
|
+
const result = await pk.gqlQuery(query);
|
|
290
|
+
t.equal(result.errors, undefined);
|
|
291
|
+
t.ok('documents' in result.data);
|
|
292
|
+
t.ok('mainText' in result.data.documents[0]);
|
|
293
|
+
t.ok(result.data.documents[0].mainText.startsWith('In the days when'));
|
|
294
|
+
t.ok(result.data.documents[0].normalized.startsWith('In the days when'));
|
|
295
|
+
} catch (err) {
|
|
296
|
+
console.log(err);
|
|
297
|
+
}
|
|
298
|
+
},
|
|
299
|
+
);
|
|
300
|
+
|
|
301
|
+
test(
|
|
302
|
+
`perf (${testGroup})`,
|
|
303
|
+
async function (t) {
|
|
304
|
+
try {
|
|
305
|
+
t.plan(9);
|
|
306
|
+
let query = '{ documents { perf } }';
|
|
307
|
+
let result = await pk.gqlQuery(query);
|
|
308
|
+
t.equal(result.errors, undefined);
|
|
309
|
+
t.ok('documents' in result.data);
|
|
310
|
+
t.ok('perf' in result.data.documents[0]);
|
|
311
|
+
let perfJSON;
|
|
312
|
+
t.doesNotThrow(() => perfJSON = JSON.parse(result.data.documents[0].perf));
|
|
313
|
+
query = '{ documents { perf(indent:2) } }';
|
|
314
|
+
result = await pk.gqlQuery(query);
|
|
315
|
+
t.equal(result.errors, undefined);
|
|
316
|
+
t.ok('documents' in result.data);
|
|
317
|
+
t.ok('perf' in result.data.documents[0]);
|
|
318
|
+
let perfJSON2;
|
|
319
|
+
t.doesNotThrow(() => perfJSON2 = JSON.parse(result.data.documents[0].perf));
|
|
320
|
+
t.ok(deepEqual(perfJSON, perfJSON2));
|
|
321
|
+
} catch (err) {
|
|
322
|
+
console.log(err);
|
|
323
|
+
}
|
|
324
|
+
},
|
|
325
|
+
);
|
|
326
|
+
|
|
327
|
+
test(
|
|
328
|
+
`sofria (${testGroup})`,
|
|
329
|
+
async function (t) {
|
|
330
|
+
try {
|
|
331
|
+
t.plan(9);
|
|
332
|
+
let query = '{ documents { sofria } }';
|
|
333
|
+
let result = await pk3.gqlQuery(query);
|
|
334
|
+
t.equal(result.errors, undefined);
|
|
335
|
+
t.ok('documents' in result.data);
|
|
336
|
+
t.ok('sofria' in result.data.documents[0]);
|
|
337
|
+
let sofriaJSON;
|
|
338
|
+
t.doesNotThrow(() => sofriaJSON = JSON.parse(result.data.documents[0].sofria));
|
|
339
|
+
query = '{ documents { sofria(indent:2) } }';
|
|
340
|
+
result = await pk3.gqlQuery(query);
|
|
341
|
+
t.equal(result.errors, undefined);
|
|
342
|
+
t.ok('documents' in result.data);
|
|
343
|
+
t.ok('sofria' in result.data.documents[0]);
|
|
344
|
+
let sofriaJSON2;
|
|
345
|
+
t.doesNotThrow(() => sofriaJSON2 = JSON.parse(result.data.documents[0].sofria));
|
|
346
|
+
t.ok(deepEqual(sofriaJSON, sofriaJSON2));
|
|
347
|
+
} catch (err) {
|
|
348
|
+
console.log(err);
|
|
349
|
+
}
|
|
350
|
+
},
|
|
351
|
+
);
|
|
352
|
+
|
|
353
|
+
test(
|
|
354
|
+
`usfm (${testGroup})`,
|
|
355
|
+
async function (t) {
|
|
356
|
+
try {
|
|
357
|
+
t.plan(4);
|
|
358
|
+
let query = '{ documents { usfm } }';
|
|
359
|
+
let result = await pk3.gqlQuery(query);
|
|
360
|
+
t.equal(result.errors, undefined);
|
|
361
|
+
t.ok('documents' in result.data);
|
|
362
|
+
t.ok('usfm' in result.data.documents[0]);
|
|
363
|
+
|
|
364
|
+
let rawUsfm = fse.readFileSync(path.resolve(__dirname, '../../test_data/usfm/78-GALspavbl.usfm')).toString();
|
|
365
|
+
let tabRawUsfm = rawUsfm.split(/(\\[a-z]+[\d\*]?|\n)/g).filter((e) => e !== '' && e !== ' ' && e !== '\n');
|
|
366
|
+
|
|
367
|
+
let outputUsfm = result.data.documents[0].usfm;
|
|
368
|
+
let tabOutputUsfm = outputUsfm.split(/(\\[a-z]+[\d\*]?|\n)/g).filter((e) => e !== '' && e !== ' ' && e !== '\n');
|
|
369
|
+
|
|
370
|
+
let diff = [];
|
|
371
|
+
|
|
372
|
+
tabRawUsfm.forEach((elem, i) => {
|
|
373
|
+
if (!tabOutputUsfm[i] || elem.trim() !== tabOutputUsfm[i].trim()) {
|
|
374
|
+
diff.push([tabOutputUsfm[i], elem]);
|
|
375
|
+
}
|
|
376
|
+
});
|
|
377
|
+
t.equal(diff.join(''), '');
|
|
378
|
+
} catch (err) {
|
|
379
|
+
console.log(err);
|
|
380
|
+
}
|
|
381
|
+
},
|
|
382
|
+
);
|