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,71 @@
|
|
|
1
|
+
const test = require('tape');
|
|
2
|
+
|
|
3
|
+
const { Proskomma } = require('../../../src/index.cjs');
|
|
4
|
+
const {
|
|
5
|
+
pkWithDoc,
|
|
6
|
+
customPkWithDoc,
|
|
7
|
+
} = require('../../lib/load.js');
|
|
8
|
+
|
|
9
|
+
const testGroup = 'Empty Blocks';
|
|
10
|
+
|
|
11
|
+
const pk = pkWithDoc('../test_data/usfm/en_ust_psa_1.usfm', {
|
|
12
|
+
lang: 'fra',
|
|
13
|
+
abbr: 'hello',
|
|
14
|
+
})[0];
|
|
15
|
+
|
|
16
|
+
const customProskomma = class extends Proskomma {
|
|
17
|
+
constructor() {
|
|
18
|
+
super();
|
|
19
|
+
this.filters = {};
|
|
20
|
+
this.customTags = {
|
|
21
|
+
heading: [],
|
|
22
|
+
paragraph: [],
|
|
23
|
+
char: [],
|
|
24
|
+
word: [],
|
|
25
|
+
intro: [],
|
|
26
|
+
introHeading: [],
|
|
27
|
+
};
|
|
28
|
+
this.emptyBlocks = ['blockTag/s5', 'blockTag/m'];
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const customPk = customPkWithDoc(customProskomma, '../test_data/usfm/en_ust_psa_1.usfm', {
|
|
33
|
+
lang: 'fra',
|
|
34
|
+
abbr: 'hello',
|
|
35
|
+
}, {})[0];
|
|
36
|
+
|
|
37
|
+
const query = `{ documents { sequences { type blocks { bg { subType payload } bs { payload } text } } } }`;
|
|
38
|
+
|
|
39
|
+
test(
|
|
40
|
+
`Without Custom (${testGroup})`,
|
|
41
|
+
async function (t) {
|
|
42
|
+
try {
|
|
43
|
+
t.plan(2);
|
|
44
|
+
const result = await pk.gqlQuery(query);
|
|
45
|
+
t.equal(result.errors, undefined);
|
|
46
|
+
const sequences = result.data.documents[0].sequences;
|
|
47
|
+
// t.equal(sequences.filter(s => s.type === 'heading').length, 0);
|
|
48
|
+
// BEHAVIOUR CHANGED WITH SUCCINCT FILTER. s5 sequences are empty but not deleted
|
|
49
|
+
t.equal(sequences.filter(s => s.type === 'main')[0].blocks[0].bs.payload, 'blockTag/q');
|
|
50
|
+
} catch (err) {
|
|
51
|
+
console.log(err);
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
test(
|
|
57
|
+
`With Custom (${testGroup})`,
|
|
58
|
+
async function (t) {
|
|
59
|
+
try {
|
|
60
|
+
t.plan(4);
|
|
61
|
+
const result = await customPk.gqlQuery(query);
|
|
62
|
+
t.equal(result.errors, undefined);
|
|
63
|
+
const sequences = result.data.documents[0].sequences;
|
|
64
|
+
t.equal(sequences.filter(s => s.type === 'heading').length, 3);
|
|
65
|
+
t.equal(sequences.filter(s => s.type === 'heading' && s.blocks[0].bs.payload === 'blockTag/s5').length, 3);
|
|
66
|
+
t.equal(sequences.filter(s => s.type === 'main')[0].blocks[0].bs.payload, 'blockTag/m');
|
|
67
|
+
} catch (err) {
|
|
68
|
+
console.log(err);
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
);
|
|
@@ -0,0 +1,402 @@
|
|
|
1
|
+
/* eslint-disable no-return-assign */
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const fse = require('fs-extra');
|
|
4
|
+
const test = require('tape');
|
|
5
|
+
|
|
6
|
+
const { Validator } = require('proskomma-json-tools');
|
|
7
|
+
const { pkWithDoc } = require('../../lib/load.js');
|
|
8
|
+
|
|
9
|
+
const { blocksSpec2Query } = require('../../../src/util/scriptlike/blocksSpec.cjs');
|
|
10
|
+
|
|
11
|
+
const [pk, pkDoc] = pkWithDoc('../test_data/usfm/66-JUD-ust.usfm', {
|
|
12
|
+
lang: 'eng',
|
|
13
|
+
abbr: 'ust',
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
const cleanKV = entry => {
|
|
17
|
+
const fields = {};
|
|
18
|
+
entry.itemGroups.forEach(ig => fields[ig.scopeLabels[0].split('/')[1]] = ig.text);
|
|
19
|
+
const secondaryKeys = {};
|
|
20
|
+
entry.secondaryKeys.forEach(k => secondaryKeys[k.key] = k.value);
|
|
21
|
+
return {
|
|
22
|
+
key: entry.key,
|
|
23
|
+
secondaryKeys,
|
|
24
|
+
fields,
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const testGroup = 'Entries';
|
|
29
|
+
|
|
30
|
+
test(
|
|
31
|
+
`kv mutation (${testGroup})`,
|
|
32
|
+
async function (t) {
|
|
33
|
+
try {
|
|
34
|
+
t.plan(2);
|
|
35
|
+
const kvQuery = blocksSpec2Query(
|
|
36
|
+
fse.readJSONSync(path.resolve(__dirname, '../../test_data/inputBlockSpec/kv.json')),
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
let query = `mutation { newSequence(` +
|
|
40
|
+
` documentId: "${pkDoc.id}"` +
|
|
41
|
+
` type: "kv"` +
|
|
42
|
+
` blocksSpec: ${kvQuery}` +
|
|
43
|
+
` graftToMain: true) }`;
|
|
44
|
+
|
|
45
|
+
let result = await pk.gqlQuery(query);
|
|
46
|
+
t.equal(result.errors, undefined);
|
|
47
|
+
const newSeqId = result.data.newSequence;
|
|
48
|
+
query = `mutation { addSequenceTags(docSetId: "eng_ust", documentId: "${pkDoc.id}", sequenceId: "${newSeqId}", tags: ["kv"]) }`;
|
|
49
|
+
result = await pk.gqlQuery(query);
|
|
50
|
+
t.equal(result.errors, undefined);
|
|
51
|
+
} catch (err) {
|
|
52
|
+
console.log(err);
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
test(
|
|
58
|
+
`Without args (${testGroup})`,
|
|
59
|
+
async function (t) {
|
|
60
|
+
try {
|
|
61
|
+
t.plan(8);
|
|
62
|
+
|
|
63
|
+
const query = `{
|
|
64
|
+
docSets {
|
|
65
|
+
document(bookCode:"JUD") {
|
|
66
|
+
kvSequences(withTags:"kv") {
|
|
67
|
+
nEntries
|
|
68
|
+
entries {
|
|
69
|
+
key
|
|
70
|
+
secondaryKeys { key value }
|
|
71
|
+
itemGroups {
|
|
72
|
+
scopeLabels(startsWith:"kvField")
|
|
73
|
+
text
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}`;
|
|
80
|
+
const result = await pk.gqlQuery(query);
|
|
81
|
+
t.equal(result.errors, undefined);
|
|
82
|
+
const document = result.data.docSets[0].document;
|
|
83
|
+
const kv = document.kvSequences[0].entries.map(kv => cleanKV(kv));
|
|
84
|
+
t.equal(document.kvSequences[0].nEntries, 3);
|
|
85
|
+
t.equal(kv.length, 3);
|
|
86
|
+
t.equal(kv[0].key, 'a');
|
|
87
|
+
t.equal(Object.keys(kv[0].secondaryKeys).length, 2);
|
|
88
|
+
t.equal(kv[0].secondaryKeys['service'], 'dessert');
|
|
89
|
+
t.equal(Object.keys(kv[0].fields).length, 2);
|
|
90
|
+
t.equal(kv[0].fields['name'], 'apple');
|
|
91
|
+
} catch (err) {
|
|
92
|
+
console.log(err);
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
test(
|
|
98
|
+
`keyEquals (${testGroup})`,
|
|
99
|
+
async function (t) {
|
|
100
|
+
try {
|
|
101
|
+
t.plan(4);
|
|
102
|
+
|
|
103
|
+
const query = `{
|
|
104
|
+
docSets {
|
|
105
|
+
document(bookCode:"JUD") {
|
|
106
|
+
kvSequences(withTags:"kv") {
|
|
107
|
+
entries(keyEquals: ["a", "c"]) {
|
|
108
|
+
key
|
|
109
|
+
secondaryKeys { key value }
|
|
110
|
+
itemGroups {
|
|
111
|
+
scopeLabels(startsWith:"kvField")
|
|
112
|
+
text
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}`;
|
|
119
|
+
const result = await pk.gqlQuery(query);
|
|
120
|
+
t.equal(result.errors, undefined);
|
|
121
|
+
const document = result.data.docSets[0].document;
|
|
122
|
+
const kv = document.kvSequences[0].entries.map(kv => cleanKV(kv));
|
|
123
|
+
t.equal(kv.length, 2);
|
|
124
|
+
t.equal(kv[0].key, 'a');
|
|
125
|
+
t.equal(kv[1].key, 'c');
|
|
126
|
+
} catch (err) {
|
|
127
|
+
console.log(err);
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
);
|
|
131
|
+
|
|
132
|
+
test(
|
|
133
|
+
`keyMatches (${testGroup})`,
|
|
134
|
+
async function (t) {
|
|
135
|
+
try {
|
|
136
|
+
t.plan(4);
|
|
137
|
+
|
|
138
|
+
const query = `{
|
|
139
|
+
docSets {
|
|
140
|
+
document(bookCode:"JUD") {
|
|
141
|
+
kvSequences(withTags:"kv") {
|
|
142
|
+
entries(keyMatches: "[ab]") {
|
|
143
|
+
key
|
|
144
|
+
secondaryKeys { key value }
|
|
145
|
+
itemGroups {
|
|
146
|
+
scopeLabels(startsWith:"kvField")
|
|
147
|
+
text
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}`;
|
|
154
|
+
const result = await pk.gqlQuery(query);
|
|
155
|
+
t.equal(result.errors, undefined);
|
|
156
|
+
const document = result.data.docSets[0].document;
|
|
157
|
+
const kv = document.kvSequences[0].entries.map(kv => cleanKV(kv));
|
|
158
|
+
t.equal(kv.length, 2);
|
|
159
|
+
t.equal(kv[0].key, 'a');
|
|
160
|
+
t.equal(kv[1].key, 'b');
|
|
161
|
+
} catch (err) {
|
|
162
|
+
console.log(err);
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
);
|
|
166
|
+
|
|
167
|
+
test(
|
|
168
|
+
`secondaryEquals (${testGroup})`,
|
|
169
|
+
async function (t) {
|
|
170
|
+
try {
|
|
171
|
+
t.plan(3);
|
|
172
|
+
|
|
173
|
+
const query = `{
|
|
174
|
+
docSets {
|
|
175
|
+
document(bookCode:"JUD") {
|
|
176
|
+
kvSequences(withTags:"kv") {
|
|
177
|
+
entries(secondaryEquals: [{key: "color", values: "green"}, {key: "service", values: "starter"}]) {
|
|
178
|
+
key
|
|
179
|
+
secondaryKeys { key value }
|
|
180
|
+
itemGroups {
|
|
181
|
+
scopeLabels(startsWith:"kvField")
|
|
182
|
+
text
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}`;
|
|
189
|
+
const result = await pk.gqlQuery(query);
|
|
190
|
+
t.equal(result.errors, undefined);
|
|
191
|
+
const document = result.data.docSets[0].document;
|
|
192
|
+
const kv = document.kvSequences[0].entries.map(kv => cleanKV(kv));
|
|
193
|
+
t.equal(kv.length, 1);
|
|
194
|
+
t.equal(kv[0].key, 'c');
|
|
195
|
+
} catch (err) {
|
|
196
|
+
console.log(err);
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
);
|
|
200
|
+
|
|
201
|
+
test(
|
|
202
|
+
`secondaryMatches (${testGroup})`,
|
|
203
|
+
async function (t) {
|
|
204
|
+
try {
|
|
205
|
+
t.plan(3);
|
|
206
|
+
|
|
207
|
+
const query = `{
|
|
208
|
+
docSets {
|
|
209
|
+
document(bookCode:"JUD") {
|
|
210
|
+
kvSequences(withTags:"kv") {
|
|
211
|
+
entries(secondaryMatches: [{key: "color", matches: "ree"}, {key: "service", matches: "tar"}]) {
|
|
212
|
+
key
|
|
213
|
+
secondaryKeys { key value }
|
|
214
|
+
itemGroups {
|
|
215
|
+
scopeLabels(startsWith:"kvField")
|
|
216
|
+
text
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}`;
|
|
223
|
+
const result = await pk.gqlQuery(query);
|
|
224
|
+
t.equal(result.errors, undefined);
|
|
225
|
+
const document = result.data.docSets[0].document;
|
|
226
|
+
const kv = document.kvSequences[0].entries.map(kv => cleanKV(kv));
|
|
227
|
+
t.equal(kv.length, 1);
|
|
228
|
+
t.equal(kv[0].key, 'c');
|
|
229
|
+
} catch (err) {
|
|
230
|
+
console.log(err);
|
|
231
|
+
}
|
|
232
|
+
},
|
|
233
|
+
);
|
|
234
|
+
|
|
235
|
+
test(
|
|
236
|
+
`contentMatches (${testGroup})`,
|
|
237
|
+
async function (t) {
|
|
238
|
+
try {
|
|
239
|
+
t.plan(3);
|
|
240
|
+
|
|
241
|
+
const query = `{
|
|
242
|
+
docSets {
|
|
243
|
+
document(bookCode:"JUD") {
|
|
244
|
+
kvSequences(withTags:"kv") {
|
|
245
|
+
entries(contentMatches: [{key: "name", matches: "pl|na"}, {key: "definition", matches: "obj"}]) {
|
|
246
|
+
key
|
|
247
|
+
secondaryKeys { key value }
|
|
248
|
+
itemGroups {
|
|
249
|
+
scopeLabels(startsWith:"kvField")
|
|
250
|
+
text
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}`;
|
|
257
|
+
const result = await pk.gqlQuery(query);
|
|
258
|
+
t.equal(result.errors, undefined);
|
|
259
|
+
const document = result.data.docSets[0].document;
|
|
260
|
+
const kv = document.kvSequences[0].entries.map(kv => cleanKV(kv));
|
|
261
|
+
t.equal(kv.length, 1);
|
|
262
|
+
t.equal(kv[0].key, 'b');
|
|
263
|
+
} catch (err) {
|
|
264
|
+
console.log(err);
|
|
265
|
+
}
|
|
266
|
+
},
|
|
267
|
+
);
|
|
268
|
+
|
|
269
|
+
test(
|
|
270
|
+
`contentEquals (${testGroup})`,
|
|
271
|
+
async function (t) {
|
|
272
|
+
try {
|
|
273
|
+
t.plan(3);
|
|
274
|
+
|
|
275
|
+
const query = `{
|
|
276
|
+
docSets {
|
|
277
|
+
document(bookCode:"JUD") {
|
|
278
|
+
kvSequences(withTags:"kv") {
|
|
279
|
+
entries(contentEquals: [{key: "name", values: "apple"}, {key: "definition", values: "A tasty snack"}]) {
|
|
280
|
+
key
|
|
281
|
+
secondaryKeys { key value }
|
|
282
|
+
itemGroups {
|
|
283
|
+
scopeLabels(startsWith:"kvField")
|
|
284
|
+
text
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
}`;
|
|
291
|
+
const result = await pk.gqlQuery(query);
|
|
292
|
+
t.equal(result.errors, undefined);
|
|
293
|
+
const document = result.data.docSets[0].document;
|
|
294
|
+
const kv = document.kvSequences[0].entries.map(kv => cleanKV(kv));
|
|
295
|
+
t.equal(kv.length, 1);
|
|
296
|
+
t.equal(kv[0].key, 'a');
|
|
297
|
+
} catch (err) {
|
|
298
|
+
console.log(err);
|
|
299
|
+
}
|
|
300
|
+
},
|
|
301
|
+
);
|
|
302
|
+
|
|
303
|
+
test(
|
|
304
|
+
`Dodson lexicon mutation (${testGroup})`,
|
|
305
|
+
async function (t) {
|
|
306
|
+
try {
|
|
307
|
+
t.plan(2);
|
|
308
|
+
const dodsonQuery = blocksSpec2Query(
|
|
309
|
+
fse.readJSONSync(path.resolve(__dirname, '../../test_data/inputBlockSpec/dodson.json')),
|
|
310
|
+
);
|
|
311
|
+
|
|
312
|
+
let query = `mutation { newSequence(` +
|
|
313
|
+
` documentId: "${pkDoc.id}"` +
|
|
314
|
+
` type: "kv"` +
|
|
315
|
+
` blocksSpec: ${dodsonQuery}` +
|
|
316
|
+
` graftToMain: true) }`;
|
|
317
|
+
|
|
318
|
+
let result = await pk.gqlQuery(query);
|
|
319
|
+
t.equal(result.errors, undefined);
|
|
320
|
+
const newSeqId = result.data.newSequence;
|
|
321
|
+
query = `mutation { addSequenceTags(docSetId: "eng_ust", documentId: "${pkDoc.id}", sequenceId: "${newSeqId}", tags: ["dodson"]) }`;
|
|
322
|
+
result = await pk.gqlQuery(query);
|
|
323
|
+
t.equal(result.errors, undefined);
|
|
324
|
+
} catch (err) {
|
|
325
|
+
console.log(err);
|
|
326
|
+
}
|
|
327
|
+
},
|
|
328
|
+
);
|
|
329
|
+
|
|
330
|
+
test(
|
|
331
|
+
`Dodson queries (${testGroup})`,
|
|
332
|
+
async function (t) {
|
|
333
|
+
try {
|
|
334
|
+
t.plan(13);
|
|
335
|
+
|
|
336
|
+
const query = `{
|
|
337
|
+
docSets {
|
|
338
|
+
document(bookCode:"JUD") {
|
|
339
|
+
kvSequences(withTags:"dodson") {
|
|
340
|
+
nEntries
|
|
341
|
+
allEntries: entries {
|
|
342
|
+
key
|
|
343
|
+
secondaryKeys { key value }
|
|
344
|
+
itemGroups {
|
|
345
|
+
scopeLabels(startsWith:"kvField")
|
|
346
|
+
text
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
byLemma: entries(keyEquals: ["ἀβαρής"]) { key }
|
|
350
|
+
byStrong: entries(secondaryEquals: [{key: "strong", values: "0007"}]) { key }
|
|
351
|
+
byContent: entries(contentMatches: [{key: "fullDef", matches: "son.+Amram"}]) { key itemGroups { text } }
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
}`;
|
|
356
|
+
const result = await pk.gqlQuery(query);
|
|
357
|
+
t.equal(result.errors, undefined);
|
|
358
|
+
const document = result.data.docSets[0].document;
|
|
359
|
+
const allEntries = document.kvSequences[0].allEntries.map(kv => cleanKV(kv));
|
|
360
|
+
t.equal(document.kvSequences[0].nEntries, 9);
|
|
361
|
+
t.equal(allEntries.length, 9);
|
|
362
|
+
t.equal(allEntries[0].key, 'ἄλφα');
|
|
363
|
+
t.equal(Object.keys(allEntries[0].secondaryKeys).length, 1);
|
|
364
|
+
t.equal(allEntries[0].secondaryKeys['strong'], '0001');
|
|
365
|
+
t.equal(Object.keys(allEntries[0].fields).length, 2);
|
|
366
|
+
t.ok(allEntries[0].fields['briefDef'].startsWith('the first letter'));
|
|
367
|
+
const lemmaEntries = document.kvSequences[0].byLemma;
|
|
368
|
+
t.equal(lemmaEntries.length, 1);
|
|
369
|
+
t.equal(lemmaEntries[0].key, 'ἀβαρής');
|
|
370
|
+
const strongEntries = document.kvSequences[0].byStrong;
|
|
371
|
+
t.equal(strongEntries.length, 1);
|
|
372
|
+
t.equal(strongEntries[0].key, 'Ἀβιά');
|
|
373
|
+
const sonEntries = document.kvSequences[0].byContent;
|
|
374
|
+
t.equal(sonEntries.length, 1);
|
|
375
|
+
} catch (err) {
|
|
376
|
+
console.log(err);
|
|
377
|
+
}
|
|
378
|
+
},
|
|
379
|
+
);
|
|
380
|
+
|
|
381
|
+
test(
|
|
382
|
+
`Serialize (${testGroup})`,
|
|
383
|
+
async function (t) {
|
|
384
|
+
try {
|
|
385
|
+
t.plan(3);
|
|
386
|
+
const query = '{ docSets { id } }';
|
|
387
|
+
const result = await pk.gqlQuery(query);
|
|
388
|
+
const docSetId = result.data.docSets[0].id;
|
|
389
|
+
const serialized = pk.serializeSuccinct(docSetId);
|
|
390
|
+
t.ok(serialized);
|
|
391
|
+
const validationReport = new Validator().validate('proskomma',
|
|
392
|
+
'succinct',
|
|
393
|
+
'0.2.0',
|
|
394
|
+
serialized
|
|
395
|
+
);
|
|
396
|
+
t.ok(validationReport.isValid);
|
|
397
|
+
t.equal(validationReport.errors, null);
|
|
398
|
+
} catch (err) {
|
|
399
|
+
console.log(err);
|
|
400
|
+
}
|
|
401
|
+
},
|
|
402
|
+
);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const test = require('tape');
|
|
2
|
+
|
|
3
|
+
const pkExports = require('../../../src/index.cjs');
|
|
4
|
+
|
|
5
|
+
const testGroup = 'Export lexingRegexes';
|
|
6
|
+
|
|
7
|
+
test(
|
|
8
|
+
`Smoke (${testGroup})`,
|
|
9
|
+
function (t) {
|
|
10
|
+
try {
|
|
11
|
+
t.plan(3);
|
|
12
|
+
t.ok('Proskomma' in pkExports);
|
|
13
|
+
t.ok('lexingRegexes' in pkExports);
|
|
14
|
+
t.equal(pkExports.lexingRegexes.filter(r => r[0] === 'chapter').length, 1);
|
|
15
|
+
} catch (err) {
|
|
16
|
+
console.log(err);
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
);
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
const test = require('tape');
|
|
2
|
+
|
|
3
|
+
const { pkWithDoc } = require('../../lib/load.js');
|
|
4
|
+
|
|
5
|
+
const testGroup = 'Fig';
|
|
6
|
+
|
|
7
|
+
const pk = pkWithDoc('../test_data/usfm/fig.usfm', {
|
|
8
|
+
lang: 'fra',
|
|
9
|
+
abbr: 'hello',
|
|
10
|
+
})[0];
|
|
11
|
+
const pk2 = pkWithDoc('../test_data/usx/fig.usx', {
|
|
12
|
+
lang: 'fra',
|
|
13
|
+
abbr: 'hello',
|
|
14
|
+
})[0];
|
|
15
|
+
|
|
16
|
+
const query =
|
|
17
|
+
'{ documents { sequences { id type blocks { scopeLabels text items { type subType payload } } } } }';
|
|
18
|
+
|
|
19
|
+
const checkResult = (t, result) => {
|
|
20
|
+
const sequences = result.data.documents[0].sequences;
|
|
21
|
+
t.equal(sequences.length, 2);
|
|
22
|
+
const figSequence = sequences.filter(s => s.type === 'fig')[0];
|
|
23
|
+
const firstFigItem = figSequence.blocks[0].items[0];
|
|
24
|
+
t.equal(firstFigItem.subType, 'start');
|
|
25
|
+
t.equal(firstFigItem.payload, 'spanWithAtts/fig');
|
|
26
|
+
const lastFigItem = figSequence.blocks[0].items[figSequence.blocks[0].items.length - 1];
|
|
27
|
+
t.equal(lastFigItem.subType, 'end');
|
|
28
|
+
t.equal(lastFigItem.payload, 'spanWithAtts/fig');
|
|
29
|
+
const attributeTypes = figSequence.blocks[0].scopeLabels.filter(sl => sl.startsWith('attribute')).map(sl => sl.split('/')[3]);
|
|
30
|
+
|
|
31
|
+
for (const att of ['src', 'size', 'ref']) {
|
|
32
|
+
t.ok(attributeTypes.includes(att));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const mainSequence = sequences.filter(s => s.type === 'main')[0];
|
|
36
|
+
const lastMainItem = mainSequence.blocks[0].items[mainSequence.blocks[0].items.length - 1];
|
|
37
|
+
t.equal(lastMainItem.type, 'graft');
|
|
38
|
+
t.equal(lastMainItem.subType, 'fig');
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
test(
|
|
42
|
+
`USFM (${testGroup})`,
|
|
43
|
+
async function (t) {
|
|
44
|
+
try {
|
|
45
|
+
t.plan(11);
|
|
46
|
+
const result = await pk.gqlQuery(query);
|
|
47
|
+
t.equal(result.errors, undefined);
|
|
48
|
+
checkResult(t, result);
|
|
49
|
+
} catch (err) {
|
|
50
|
+
console.log(err);
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
test(
|
|
56
|
+
`USX (${testGroup})`,
|
|
57
|
+
async function (t) {
|
|
58
|
+
try {
|
|
59
|
+
t.plan(11);
|
|
60
|
+
const result = await pk2.gqlQuery(query);
|
|
61
|
+
t.equal(result.errors, undefined);
|
|
62
|
+
checkResult(t, result);
|
|
63
|
+
} catch (err) {
|
|
64
|
+
console.log(err);
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
);
|