proskomma-core 0.9.12 → 0.9.13
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/esm/wrapper.mjs +1 -1
- package/{index.js → index.cjs} +1 -1
- package/package.json +2 -2
- package/babel.config.js +0 -18
- package/test/code/main/bad.cjs +0 -79
- package/test/code/main/basics.cjs +0 -534
- package/test/code/main/block.cjs +0 -586
- package/test/code/main/block_scope_numbers.cjs +0 -31
- package/test/code/main/blocks_with_atts.cjs +0 -150
- package/test/code/main/blocks_with_cv.cjs +0 -250
- package/test/code/main/break.cjs +0 -73
- package/test/code/main/checksum.cjs +0 -36
- package/test/code/main/cl_global.cjs +0 -35
- package/test/code/main/class_for_fragment.cjs +0 -18
- package/test/code/main/clean_usfm.cjs +0 -46
- package/test/code/main/cp_vp.cjs +0 -158
- package/test/code/main/custom.cjs +0 -124
- package/test/code/main/cv.cjs +0 -249
- package/test/code/main/cvMatching.cjs +0 -155
- package/test/code/main/cv_indexes.cjs +0 -189
- package/test/code/main/cv_navigation.cjs +0 -124
- package/test/code/main/document.cjs +0 -382
- package/test/code/main/empty_blocks.cjs +0 -71
- package/test/code/main/entries.cjs +0 -402
- package/test/code/main/export_lexing_regexes.cjs +0 -19
- package/test/code/main/fig.cjs +0 -67
- package/test/code/main/filter.cjs +0 -222
- package/test/code/main/glossary.cjs +0 -36
- package/test/code/main/graft_headings.cjs +0 -36
- package/test/code/main/graft_introduction.cjs +0 -96
- package/test/code/main/graft_note.cjs +0 -104
- package/test/code/main/graft_rems.cjs +0 -34
- package/test/code/main/graft_sidebars.cjs +0 -62
- package/test/code/main/graft_title.cjs +0 -36
- package/test/code/main/hello.cjs +0 -105
- package/test/code/main/import_document.cjs +0 -22
- package/test/code/main/import_usfm_int.cjs +0 -48
- package/test/code/main/item_groups.cjs +0 -133
- package/test/code/main/items_with_cv.cjs +0 -311
- package/test/code/main/milestone_attributes.cjs +0 -163
- package/test/code/main/mixed_sequence_documents.cjs +0 -137
- package/test/code/main/mixed_sequences.cjs +0 -217
- package/test/code/main/modify_sequence.cjs +0 -29
- package/test/code/main/multiple_chapters.cjs +0 -58
- package/test/code/main/multiple_content.cjs +0 -105
- package/test/code/main/mutate_add.cjs +0 -180
- package/test/code/main/mutate_delete.cjs +0 -236
- package/test/code/main/mutate_rehash.cjs +0 -68
- package/test/code/main/mutate_tags.cjs +0 -90
- package/test/code/main/mutate_update.cjs +0 -538
- package/test/code/main/selectors.cjs +0 -289
- package/test/code/main/sequence.cjs +0 -361
- package/test/code/main/serialize.cjs +0 -104
- package/test/code/main/spans.cjs +0 -51
- package/test/code/main/split_long_tokens.cjs +0 -30
- package/test/code/main/standard_vrs.cjs +0 -76
- package/test/code/main/subclass.cjs +0 -25
- package/test/code/main/table.cjs +0 -119
- package/test/code/main/tags.cjs +0 -248
- package/test/code/main/token_alignment.cjs +0 -84
- package/test/code/main/trees.cjs +0 -211
- package/test/code/main/tribos.cjs +0 -865
- package/test/code/main/tsv.cjs +0 -385
- package/test/code/main/usx_ref.cjs +0 -65
- package/test/code/main/verse_mapping.cjs +0 -252
- package/test/code/main/verse_range.cjs +0 -31
- package/test/code/main/word_likes.cjs +0 -41
- package/test/code/utils/byte_array.cjs +0 -271
- package/test/code/utils/canons.cjs +0 -20
- package/test/code/utils/generate_id.cjs +0 -17
- package/test/code/utils/graft_defs.cjs +0 -16
- package/test/code/utils/inspect.cjs +0 -130
- package/test/code/utils/items.cjs +0 -56
- package/test/code/utils/push_succinct.cjs +0 -69
- package/test/code/utils/scope_defs.cjs +0 -79
- package/test/code/utils/serialize.cjs +0 -28
- package/test/code/utils/splice.cjs +0 -67
- package/test/code/utils/tags.cjs +0 -69
- package/test/code/utils/versification.cjs +0 -249
- package/test/lib/load.js +0 -110
- package/test/skipped_code/diff.js +0 -53
- package/test/test_data/inputBlockSpec/dodson.json +0 -1654
- package/test/test_data/inputBlockSpec/kv.json +0 -326
- package/test/test_data/inputBlockSpec/mk1.json +0 -1019
- package/test/test_data/inputBlockSpec/table.json +0 -170
- package/test/test_data/tree/genealogy.json +0 -55
- package/test/test_data/tree/jude.json +0 -15965
- package/test/test_data/tsv/en_tn_66-JUD.tsv +0 -75
- package/test/test_data/tsv/twl_JUD.tsv +0 -144
- package/test/test_data/usfm/1pe_webbe.usfm +0 -13
- package/test/test_data/usfm/66-JUD-ust.usfm +0 -1089
- package/test/test_data/usfm/78-GALspavbl.usfm +0 -10
- package/test/test_data/usfm/add_test.usfm +0 -15
- package/test/test_data/usfm/backslash.usfm +0 -4
- package/test/test_data/usfm/cl.usfm +0 -14
- package/test/test_data/usfm/cp_vp.usfm +0 -8
- package/test/test_data/usfm/custom.usfm +0 -13
- package/test/test_data/usfm/en_ust_oba.usfm +0 -875
- package/test/test_data/usfm/en_ust_psa_1.usfm +0 -20
- package/test/test_data/usfm/fig.usfm +0 -3
- package/test/test_data/usfm/filter.usfm +0 -7
- package/test/test_data/usfm/footnote.usfm +0 -11
- package/test/test_data/usfm/frt.usfm +0 -4
- package/test/test_data/usfm/headings.usfm +0 -7
- package/test/test_data/usfm/hello.usfm +0 -8
- package/test/test_data/usfm/int.usfm +0 -7
- package/test/test_data/usfm/milestone_attributes.usfm +0 -7
- package/test/test_data/usfm/milestone_attributes_default.usfm +0 -7
- package/test/test_data/usfm/no_break_space.usfm +0 -4
- package/test/test_data/usfm/no_mt.usfm +0 -6
- package/test/test_data/usfm/rems.usfm +0 -6
- package/test/test_data/usfm/section_intros.usfm +0 -26
- package/test/test_data/usfm/sidebars.usfm +0 -25
- package/test/test_data/usfm/slash_in_att.usfm +0 -6
- package/test/test_data/usfm/soft_line_break.usfm +0 -4
- package/test/test_data/usfm/spans.usfm +0 -5
- package/test/test_data/usfm/split_long_tokens.usfm +0 -6
- package/test/test_data/usfm/table.usfm +0 -18
- package/test/test_data/usfm/table_at_end.usfm +0 -11
- package/test/test_data/usfm/table_in_intro.usfm +0 -22
- package/test/test_data/usfm/table_no_end_cells.usfm +0 -18
- package/test/test_data/usfm/tit_kitchen_sink.usfm +0 -73
- package/test/test_data/usfm/titus_template.usfm +0 -58
- package/test/test_data/usfm/ugnt_3jn.usfm +0 -265
- package/test/test_data/usfm/ult_3jn.usfm +0 -335
- package/test/test_data/usfm/unknown.usfm +0 -5
- package/test/test_data/usfm/ust_psa.usfm +0 -29
- package/test/test_data/usfm/ust_psa_verse_ranges.usfm +0 -24
- package/test/test_data/usfm/ust_psa_with_ts.usfm +0 -29
- package/test/test_data/usfm/verse_breaks_in_blocks.usfm +0 -20
- package/test/test_data/usfm/verse_range.usfm +0 -7
- package/test/test_data/usfm/web_ecc.usfm +0 -391
- package/test/test_data/usfm/web_psa51.usfm +0 -71
- package/test/test_data/usfm/whitespace.usfm +0 -12
- package/test/test_data/usfm/xref.usfm +0 -11
- package/test/test_data/usx/bad_element.usx +0 -2
- package/test/test_data/usx/cp_vp.usx +0 -12
- package/test/test_data/usx/diff1.usx +0 -59
- package/test/test_data/usx/diff2.usx +0 -74
- package/test/test_data/usx/douay_rheims_ecc.usx +0 -58
- package/test/test_data/usx/douay_rheims_psa.usx +0 -5366
- package/test/test_data/usx/douay_rheims_psa_40_60.usx +0 -666
- package/test/test_data/usx/douay_rheims_rut.usx +0 -26
- package/test/test_data/usx/esg3.usx +0 -47
- package/test/test_data/usx/fig.usx +0 -6
- package/test/test_data/usx/milestone_attributes.usx +0 -11
- package/test/test_data/usx/not_nfc18_glo.usx +0 -9
- package/test/test_data/usx/not_nfc18_phm.usx +0 -24
- package/test/test_data/usx/opt_break.usx +0 -10
- package/test/test_data/usx/sidebars.usx +0 -29
- package/test/test_data/usx/table.usx +0 -23
- package/test/test_data/usx/web_psa.usx +0 -8489
- package/test/test_data/usx/web_psa150.usx +0 -33
- package/test/test_data/usx/web_psa_40_60.usx +0 -1079
- package/test/test_data/usx/web_rut.usx +0 -95
- package/test/test_data/usx/web_rut_1.usx +0 -17
- package/test/test_data/utils/douay_rheims.vrs +0 -520
- package/test/test_data/utils/douay_rheims_PSA.usx +0 -5366
- package/test/test_data/utils/serialize_example.json +0 -91
- package/test/test_data/utils/truncated_versification.vrs +0 -29
- package/test/test_data/utils/web_rut_items.json +0 -2977
- package/test/test_data/utils/webbe.vrs +0 -395
- package/test/test_data/utils/webbe_PSA.usx +0 -8489
- package/test/test_data/vrs/douay_rheims.vrs +0 -520
- package/test/test_data/vrs/truncated_versification.vrs +0 -27
- package/test/test_data/vrs/webbe.vrs +0 -397
- package/webpack.prod.js +0 -50
|
@@ -1,252 +0,0 @@
|
|
|
1
|
-
const path = require('path');
|
|
2
|
-
const fse = require('fs-extra');
|
|
3
|
-
const test = require('tape');
|
|
4
|
-
const deepCopy = require('deep-copy-all');
|
|
5
|
-
|
|
6
|
-
const { pkWithDoc, pkWithDocs } = require('../../lib/load.js');
|
|
7
|
-
|
|
8
|
-
const testGroup = 'Verse Mapping';
|
|
9
|
-
|
|
10
|
-
const cleanPk = pkWithDoc('../test_data/usx/web_psa_40_60.usx', {
|
|
11
|
-
lang: 'eng',
|
|
12
|
-
abbr: 'web',
|
|
13
|
-
})[0];
|
|
14
|
-
|
|
15
|
-
const cleanPk2 = pkWithDocs([
|
|
16
|
-
['../test_data/usx/web_psa.usx', {
|
|
17
|
-
lang: 'eng',
|
|
18
|
-
abbr: 'webbe',
|
|
19
|
-
}],
|
|
20
|
-
['../test_data/usx/douay_rheims_psa.usx', {
|
|
21
|
-
lang: 'eng',
|
|
22
|
-
abbr: 'drh',
|
|
23
|
-
}],
|
|
24
|
-
]);
|
|
25
|
-
|
|
26
|
-
const pk3 = pkWithDocs([
|
|
27
|
-
['../test_data/usx/web_rut.usx', {
|
|
28
|
-
lang: 'eng',
|
|
29
|
-
abbr: 'webbe',
|
|
30
|
-
}],
|
|
31
|
-
['../test_data/usx/douay_rheims_rut.usx', {
|
|
32
|
-
lang: 'eng',
|
|
33
|
-
abbr: 'drh',
|
|
34
|
-
}],
|
|
35
|
-
]);
|
|
36
|
-
|
|
37
|
-
const pk4 = pkWithDocs([
|
|
38
|
-
['../test_data/usfm/web_ecc.usfm', {
|
|
39
|
-
lang: 'eng',
|
|
40
|
-
abbr: 'webbe',
|
|
41
|
-
}],
|
|
42
|
-
['../test_data/usx/douay_rheims_ecc.usx', {
|
|
43
|
-
lang: 'eng',
|
|
44
|
-
abbr: 'drh',
|
|
45
|
-
}],
|
|
46
|
-
]);
|
|
47
|
-
|
|
48
|
-
const addPk2Vrs = async () => {
|
|
49
|
-
let vrs = fse.readFileSync(path.resolve(__dirname, '../../test_data/vrs/webbe.vrs'))
|
|
50
|
-
.toString();
|
|
51
|
-
let mutationQuery = `mutation { setVerseMapping(docSetId: "eng_webbe" vrsSource: """${vrs}""")}`;
|
|
52
|
-
await cleanPk2.gqlQuery(mutationQuery);
|
|
53
|
-
vrs = fse.readFileSync(path.resolve(__dirname, '../../test_data/vrs/douay_rheims.vrs'))
|
|
54
|
-
.toString();
|
|
55
|
-
mutationQuery = `mutation { setVerseMapping(docSetId: "eng_drh" vrsSource: """${vrs}""")}`;
|
|
56
|
-
await cleanPk2.gqlQuery(mutationQuery);
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
const addPk3Vrs = async () => {
|
|
60
|
-
let vrs = fse.readFileSync(path.resolve(__dirname, '../test_data/vrs/webbe.vrs'))
|
|
61
|
-
.toString();
|
|
62
|
-
let mutationQuery = `mutation { setVerseMapping(docSetId: "eng_webbe" vrsSource: """${vrs}""")}`;
|
|
63
|
-
await pk3.gqlQuery(mutationQuery);
|
|
64
|
-
vrs = fse.readFileSync(path.resolve(__dirname, '../test_data/vrs/douay_rheims.vrs'))
|
|
65
|
-
.toString();
|
|
66
|
-
mutationQuery = `mutation { setVerseMapping(docSetId: "eng_drh" vrsSource: """${vrs}""")}`;
|
|
67
|
-
await pk3.gqlQuery(mutationQuery);
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
const addPk4Vrs = async () => {
|
|
71
|
-
let vrs = fse.readFileSync(path.resolve(__dirname, '../../test_data/vrs/webbe.vrs'))
|
|
72
|
-
.toString();
|
|
73
|
-
let mutationQuery = `mutation { setVerseMapping(docSetId: "eng_webbe" vrsSource: """${vrs}""")}`;
|
|
74
|
-
await pk4.gqlQuery(mutationQuery);
|
|
75
|
-
vrs = fse.readFileSync(path.resolve(__dirname, '../../test_data/vrs/douay_rheims.vrs'))
|
|
76
|
-
.toString();
|
|
77
|
-
mutationQuery = `mutation { setVerseMapping(docSetId: "eng_drh" vrsSource: """${vrs}""")}`;
|
|
78
|
-
await pk4.gqlQuery(mutationQuery);
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
Promise.all([addPk2Vrs(), addPk3Vrs, addPk4Vrs()]).then();
|
|
83
|
-
|
|
84
|
-
test(
|
|
85
|
-
`hasMapping (${testGroup})`,
|
|
86
|
-
async function (t) {
|
|
87
|
-
try {
|
|
88
|
-
t.plan(4);
|
|
89
|
-
const pk = deepCopy(cleanPk);
|
|
90
|
-
const query =
|
|
91
|
-
'{ docSets { id hasMapping } }';
|
|
92
|
-
let result = await pk.gqlQuery(query);
|
|
93
|
-
t.equal(result.errors, undefined);
|
|
94
|
-
t.equal(result.data.docSets[0].hasMapping, false);
|
|
95
|
-
const docSet = pk.docSetById(result.data.docSets[0].id);
|
|
96
|
-
docSet.tags.add('hasMapping');
|
|
97
|
-
result = await pk.gqlQuery(query);
|
|
98
|
-
t.equal(result.errors, undefined);
|
|
99
|
-
t.equal(result.data.docSets[0].hasMapping, true);
|
|
100
|
-
} catch (err) {
|
|
101
|
-
console.log(err);
|
|
102
|
-
}
|
|
103
|
-
},
|
|
104
|
-
);
|
|
105
|
-
|
|
106
|
-
test(
|
|
107
|
-
`setVerseMapping/unsetVerseMapping (${testGroup})`,
|
|
108
|
-
async function (t) {
|
|
109
|
-
try {
|
|
110
|
-
t.plan(15);
|
|
111
|
-
const pk = deepCopy(cleanPk);
|
|
112
|
-
let docSetQuery =
|
|
113
|
-
'{ docSets { id hasMapping } }';
|
|
114
|
-
let result = await pk.gqlQuery(docSetQuery);
|
|
115
|
-
t.equal(result.errors, undefined);
|
|
116
|
-
t.equal(result.data.docSets[0].hasMapping, false);
|
|
117
|
-
const docSetId = result.data.docSets[0].id;
|
|
118
|
-
const vrs = fse.readFileSync(path.resolve(__dirname, '../../test_data/vrs/webbe.vrs'))
|
|
119
|
-
.toString();
|
|
120
|
-
let mutationQuery = `mutation { setVerseMapping(docSetId: "${docSetId}" vrsSource: """${vrs}""")}`;
|
|
121
|
-
result = await pk.gqlQuery(mutationQuery);
|
|
122
|
-
t.equal(result.errors, undefined);
|
|
123
|
-
docSetQuery =
|
|
124
|
-
'{ docSets { id hasMapping documents { cvIndex(chapter: 51) { chapter verseNumbers { number orig { book cvs { chapter verse } } } } } } }';
|
|
125
|
-
result = await pk.gqlQuery(docSetQuery);
|
|
126
|
-
t.equal(result.errors, undefined);
|
|
127
|
-
t.equal(result.data.docSets[0].hasMapping, true);
|
|
128
|
-
let v0 = result.data.docSets[0].documents[0].cvIndex.verseNumbers[0];
|
|
129
|
-
t.equal(v0.number, 0);
|
|
130
|
-
t.equal(v0.orig.cvs.length, 2);
|
|
131
|
-
t.equal(v0.orig.cvs[0].verse, 1);
|
|
132
|
-
t.equal(v0.orig.cvs[1].verse, 2);
|
|
133
|
-
mutationQuery = `mutation { unsetVerseMapping(docSetId: "${docSetId}")}`;
|
|
134
|
-
result = await pk.gqlQuery(mutationQuery);
|
|
135
|
-
t.equal(result.errors, undefined);
|
|
136
|
-
result = await pk.gqlQuery(docSetQuery);
|
|
137
|
-
t.equal(result.errors, undefined);
|
|
138
|
-
v0 = result.data.docSets[0].documents[0].cvIndex.verseNumbers[0];
|
|
139
|
-
t.equal(result.data.docSets[0].hasMapping, false);
|
|
140
|
-
t.equal(v0.number, 0);
|
|
141
|
-
t.equal(v0.orig.cvs.length, 1);
|
|
142
|
-
t.equal(v0.orig.cvs[0].verse, 0);
|
|
143
|
-
} catch (err) {
|
|
144
|
-
console.log(err);
|
|
145
|
-
}
|
|
146
|
-
},
|
|
147
|
-
);
|
|
148
|
-
|
|
149
|
-
test(
|
|
150
|
-
`mappedCv between docSets (${testGroup})`,
|
|
151
|
-
async function (t) {
|
|
152
|
-
try {
|
|
153
|
-
t.plan(40);
|
|
154
|
-
const pk = deepCopy(cleanPk2);
|
|
155
|
-
let docSetQuery =
|
|
156
|
-
'{ docSet(id: "eng_webbe") { documents { web: cv(chapter: "48" verses: ["1"]) { text } drh: mappedCv(chapter: "48" verses: ["1"], mappedDocSetId: "eng_drh") { text } } } }';
|
|
157
|
-
let result = await pk.gqlQuery(docSetQuery);
|
|
158
|
-
t.equal(result.errors, undefined);
|
|
159
|
-
t.ok(result.data.docSet.documents[0].web[0].text.startsWith('Great is'));
|
|
160
|
-
t.ok(result.data.docSet.documents[0].drh[0].text.startsWith('Great is'));
|
|
161
|
-
t.ok(result.data.docSet.documents[0].web[0].text.endsWith('mountain.'));
|
|
162
|
-
t.ok(result.data.docSet.documents[0].drh[0].text.endsWith('mountain.'));
|
|
163
|
-
docSetQuery =
|
|
164
|
-
'{ docSet(id: "eng_webbe") { documents { web: cv(chapter: "1" verses: ["1"]) { text } drh: mappedCv(chapter: "1" verses: ["1"], mappedDocSetId: "eng_drh") { text } } } }';
|
|
165
|
-
result = await pk.gqlQuery(docSetQuery);
|
|
166
|
-
t.equal(result.errors, undefined);
|
|
167
|
-
t.ok(result.data.docSet.documents[0].web[0].text.startsWith('Blessed is the man who does'));
|
|
168
|
-
t.ok(result.data.docSet.documents[0].drh[0].text.startsWith('Blessed is the man who hath'));
|
|
169
|
-
t.ok(result.data.docSet.documents[0].web[0].text.endsWith('scoffers;'));
|
|
170
|
-
t.ok(result.data.docSet.documents[0].drh[0].text.endsWith('pestilence.'));
|
|
171
|
-
docSetQuery =
|
|
172
|
-
'{ docSet(id: "eng_webbe") { documents { web: cv(chapter: "10" verses: ["1"]) { text } drh: mappedCv(chapter: "10" verses: ["1"], mappedDocSetId: "eng_drh") { text } } } }';
|
|
173
|
-
result = await pk.gqlQuery(docSetQuery);
|
|
174
|
-
t.equal(result.errors, undefined);
|
|
175
|
-
t.ok(result.data.docSet.documents[0].web[0].text.startsWith('Why do you stand far off'));
|
|
176
|
-
t.ok(result.data.docSet.documents[0].drh[0].text.startsWith('Why, O Lord,'));
|
|
177
|
-
t.ok(result.data.docSet.documents[0].web[0].text.endsWith('times of trouble?'));
|
|
178
|
-
t.ok(result.data.docSet.documents[0].drh[0].text.endsWith('the time of trouble?'));
|
|
179
|
-
docSetQuery =
|
|
180
|
-
'{ docSet(id: "eng_webbe") { documents { web: cv(chapter: "11" verses: ["1"]) { text } drh: mappedCv(chapter: "11" verses: ["1"], mappedDocSetId: "eng_drh") { text } } } }';
|
|
181
|
-
result = await pk.gqlQuery(docSetQuery);
|
|
182
|
-
t.equal(result.errors, undefined);
|
|
183
|
-
t.ok(result.data.docSet.documents[0].web[0].text.startsWith('In the LORD, I take refuge'));
|
|
184
|
-
t.ok(result.data.docSet.documents[0].drh[0].text.startsWith('In the Lord'));
|
|
185
|
-
t.ok(result.data.docSet.documents[0].web[0].text.endsWith('to your mountain”?'));
|
|
186
|
-
t.ok(result.data.docSet.documents[0].drh[0].text.endsWith('like a sparrow?'));
|
|
187
|
-
docSetQuery =
|
|
188
|
-
'{ docSet(id: "eng_webbe") { documents { web: cv(chapter: "11" verses: ["1"]) { text } drh: mappedCv(chapter: "11" verses: ["1"], mappedDocSetId: "eng_drh") { text } } } }';
|
|
189
|
-
result = await pk.gqlQuery(docSetQuery);
|
|
190
|
-
t.equal(result.errors, undefined);
|
|
191
|
-
t.ok(result.data.docSet.documents[0].web[0].text.startsWith('In the LORD, I take refuge'));
|
|
192
|
-
t.ok(result.data.docSet.documents[0].drh[0].text.startsWith('In the Lord'));
|
|
193
|
-
t.ok(result.data.docSet.documents[0].web[0].text.endsWith('to your mountain”?'));
|
|
194
|
-
t.ok(result.data.docSet.documents[0].drh[0].text.endsWith('like a sparrow?'));
|
|
195
|
-
let results = [];
|
|
196
|
-
|
|
197
|
-
for (const docSetId of ['eng_webbe', 'eng_drh']) {
|
|
198
|
-
let mutationQuery = `mutation { unsetVerseMapping(docSetId: "${docSetId}")}`;
|
|
199
|
-
results.push(pk.gqlQuery(mutationQuery));
|
|
200
|
-
}
|
|
201
|
-
results = Promise.all(results);
|
|
202
|
-
docSetQuery =
|
|
203
|
-
'{ docSet(id: "eng_webbe") { documents { web: cv(chapter: "1" verses: ["1"]) { text } drh: mappedCv(chapter: "1" verses: ["1"], mappedDocSetId: "eng_drh") { text } } } }';
|
|
204
|
-
result = await pk.gqlQuery(docSetQuery);
|
|
205
|
-
t.equal(result.errors, undefined);
|
|
206
|
-
t.ok(result.data.docSet.documents[0].web[0].text.startsWith('Blessed is the man who does'));
|
|
207
|
-
t.ok(result.data.docSet.documents[0].drh[0].text.startsWith('Blessed is the man who hath'));
|
|
208
|
-
t.ok(result.data.docSet.documents[0].web[0].text.endsWith('scoffers;'));
|
|
209
|
-
t.ok(result.data.docSet.documents[0].drh[0].text.endsWith('pestilence.'));
|
|
210
|
-
docSetQuery =
|
|
211
|
-
'{ docSet(id: "eng_webbe") { documents { web: cv(chapter: "1" verses: ["1"]) { text } drh: mappedCv(chapter: "1" verses: ["1"], mappedDocSetId: "eng_drh") { text } } } }';
|
|
212
|
-
result = await pk3.gqlQuery(docSetQuery);
|
|
213
|
-
t.equal(result.errors, undefined);
|
|
214
|
-
t.ok(result.data.docSet.documents[0].web[0].text.startsWith('In the days when the judges judged'));
|
|
215
|
-
t.ok(result.data.docSet.documents[0].drh[0].text.startsWith('In the days of one of the judges'));
|
|
216
|
-
t.ok(result.data.docSet.documents[0].web[0].text.endsWith('his two sons. '));
|
|
217
|
-
t.ok(result.data.docSet.documents[0].drh[0].text.endsWith('his two sons. '));
|
|
218
|
-
docSetQuery =
|
|
219
|
-
'{ docSet(id: "eng_webbe") { documents { web: cv(chapter: "1" verses: ["1"]) { text } drh: mappedCv(chapter: "1" verses: ["1"], mappedDocSetId: "eng_drh") { text } } } }';
|
|
220
|
-
result = await pk4.gqlQuery(docSetQuery);
|
|
221
|
-
t.equal(result.errors, undefined);
|
|
222
|
-
t.ok(result.data.docSet.documents[0].web[0].text.startsWith('The words of the Preacher'));
|
|
223
|
-
t.ok(result.data.docSet.documents[0].drh[0].text.startsWith('The words of Ecclesiastes'));
|
|
224
|
-
t.ok(result.data.docSet.documents[0].web[0].text.endsWith('king in Jerusalem:'));
|
|
225
|
-
t.ok(result.data.docSet.documents[0].drh[0].text.endsWith('king of Jerusalem. '));
|
|
226
|
-
} catch (err) {
|
|
227
|
-
console.log(err);
|
|
228
|
-
}
|
|
229
|
-
},
|
|
230
|
-
);
|
|
231
|
-
|
|
232
|
-
test(
|
|
233
|
-
`mappedCvs between docSets (${testGroup})`,
|
|
234
|
-
async function (t) {
|
|
235
|
-
try {
|
|
236
|
-
t.plan(6);
|
|
237
|
-
const pk = deepCopy(cleanPk2);
|
|
238
|
-
let docSetQuery =
|
|
239
|
-
'{ docSet(id: "eng_webbe") { documents { mappedCvs(chapter: "65", mappedDocSetId: "eng_drh") { scopeLabels text } } } }';
|
|
240
|
-
let result = await pk.gqlQuery(docSetQuery);
|
|
241
|
-
t.equal(result.errors, undefined);
|
|
242
|
-
const mappedCVs = result.data.docSet.documents[0].mappedCvs[0][0];
|
|
243
|
-
t.ok(mappedCVs.text.endsWith('began to go out.'));
|
|
244
|
-
t.ok(mappedCVs.scopeLabels.includes('fromChapter/65'));
|
|
245
|
-
t.ok(mappedCVs.scopeLabels.includes('fromVerse/0'));
|
|
246
|
-
t.ok(mappedCVs.scopeLabels.includes('chapter/64'));
|
|
247
|
-
t.ok(mappedCVs.scopeLabels.includes('verse/1'));
|
|
248
|
-
} catch (err) {
|
|
249
|
-
console.log(err);
|
|
250
|
-
}
|
|
251
|
-
},
|
|
252
|
-
);
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
const test = require('tape');
|
|
2
|
-
|
|
3
|
-
const { pkWithDoc } = require('../../lib/load.js');
|
|
4
|
-
|
|
5
|
-
const testGroup = 'Verse Range';
|
|
6
|
-
|
|
7
|
-
const pk = pkWithDoc('../test_data/usfm/verse_range.usfm', {
|
|
8
|
-
lang: 'fra',
|
|
9
|
-
abbr: 'hello',
|
|
10
|
-
})[0];
|
|
11
|
-
|
|
12
|
-
test(
|
|
13
|
-
`Verse and Verses Scopes (${testGroup})`,
|
|
14
|
-
async function (t) {
|
|
15
|
-
try {
|
|
16
|
-
t.plan(6);
|
|
17
|
-
const query =
|
|
18
|
-
'{ documents { mainSequence { blocks { is { payload } } } } }';
|
|
19
|
-
const result = await pk.gqlQuery(query);
|
|
20
|
-
t.equal(result.errors, undefined);
|
|
21
|
-
const block = result.data.documents[0].mainSequence.blocks[0];
|
|
22
|
-
t.equal(block.is.length, 4);
|
|
23
|
-
t.equal(block.is[0].payload, 'chapter/1');
|
|
24
|
-
t.equal(block.is[1].payload, 'verse/1');
|
|
25
|
-
t.equal(block.is[2].payload, 'verse/2');
|
|
26
|
-
t.equal(block.is[3].payload, 'verses/1-2');
|
|
27
|
-
} catch (err) {
|
|
28
|
-
console.log(err);
|
|
29
|
-
}
|
|
30
|
-
},
|
|
31
|
-
);
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
const test = require('tape');
|
|
2
|
-
|
|
3
|
-
const { pkWithDoc } = require('../../lib/load.js');
|
|
4
|
-
|
|
5
|
-
const testGroup = 'wordLikes';
|
|
6
|
-
|
|
7
|
-
const pk = pkWithDoc('../test_data/usfm/cp_vp.usfm', {
|
|
8
|
-
lang: 'eng',
|
|
9
|
-
abbr: 'hello',
|
|
10
|
-
})[0];
|
|
11
|
-
|
|
12
|
-
test(
|
|
13
|
-
`DocSet (${testGroup})`,
|
|
14
|
-
async function (t) {
|
|
15
|
-
try {
|
|
16
|
-
t.plan(8);
|
|
17
|
-
let query =
|
|
18
|
-
'{ docSets { wordLikes } }';
|
|
19
|
-
let result = await pk.gqlQuery(query);
|
|
20
|
-
t.equal(result.errors, undefined);
|
|
21
|
-
let wordLikes = result.data.docSets[0].wordLikes;
|
|
22
|
-
t.ok(wordLikes.includes('Here'));
|
|
23
|
-
t.false(wordLikes.includes('here'));
|
|
24
|
-
query =
|
|
25
|
-
'{ docSets { wordLikes(coerceCase:"toLower") } }';
|
|
26
|
-
result = await pk.gqlQuery(query);
|
|
27
|
-
t.equal(result.errors, undefined);
|
|
28
|
-
wordLikes = result.data.docSets[0].wordLikes;
|
|
29
|
-
t.ok(wordLikes.includes('here'));
|
|
30
|
-
t.false(wordLikes.includes('Here'));
|
|
31
|
-
query =
|
|
32
|
-
'{ docSets { wordLikes(coerceCase:"toUpper") } }';
|
|
33
|
-
result = await pk.gqlQuery(query);
|
|
34
|
-
t.equal(result.errors, undefined);
|
|
35
|
-
wordLikes = result.data.docSets[0].wordLikes;
|
|
36
|
-
t.ok(wordLikes.includes('HERE'));
|
|
37
|
-
} catch (err) {
|
|
38
|
-
console.log(err);
|
|
39
|
-
}
|
|
40
|
-
},
|
|
41
|
-
);
|
|
@@ -1,271 +0,0 @@
|
|
|
1
|
-
const test = require('tape');
|
|
2
|
-
const { utils } = require('../../../src/index.cjs');
|
|
3
|
-
const ByteArray = utils.ByteArray;
|
|
4
|
-
|
|
5
|
-
const testGroup = 'Byte Array';
|
|
6
|
-
|
|
7
|
-
test(
|
|
8
|
-
`Construct (${testGroup})`,
|
|
9
|
-
function (t) {
|
|
10
|
-
try {
|
|
11
|
-
t.plan(2);
|
|
12
|
-
t.doesNotThrow(() => new ByteArray());
|
|
13
|
-
t.doesNotThrow(() => new ByteArray(10));
|
|
14
|
-
} catch (err) {
|
|
15
|
-
console.log(err);
|
|
16
|
-
}
|
|
17
|
-
},
|
|
18
|
-
);
|
|
19
|
-
|
|
20
|
-
test(
|
|
21
|
-
`Push, Read Byte (${testGroup})`,
|
|
22
|
-
function (t) {
|
|
23
|
-
try {
|
|
24
|
-
t.plan(2);
|
|
25
|
-
const ba = new ByteArray(1);
|
|
26
|
-
t.throws(() => ba.byte(0));
|
|
27
|
-
ba.pushByte(99);
|
|
28
|
-
t.equal(ba.byte(0), 99);
|
|
29
|
-
} catch (err) {
|
|
30
|
-
console.log(err);
|
|
31
|
-
}
|
|
32
|
-
},
|
|
33
|
-
);
|
|
34
|
-
|
|
35
|
-
test(
|
|
36
|
-
`Write Byte (${testGroup})`,
|
|
37
|
-
function (t) {
|
|
38
|
-
try {
|
|
39
|
-
t.plan(4);
|
|
40
|
-
const ba = new ByteArray(1);
|
|
41
|
-
ba.pushByte(93);
|
|
42
|
-
t.equal(ba.byte(0), 93);
|
|
43
|
-
t.throws(() => ba.setByte(99, 3));
|
|
44
|
-
ba.setByte(0, 27);
|
|
45
|
-
t.equal(ba.byte(0), 27);
|
|
46
|
-
t.throws(() => ba.setByte(0, 500));
|
|
47
|
-
} catch (err) {
|
|
48
|
-
console.log(err);
|
|
49
|
-
}
|
|
50
|
-
},
|
|
51
|
-
);
|
|
52
|
-
|
|
53
|
-
test(
|
|
54
|
-
`Push, Read Bytes (${testGroup})`,
|
|
55
|
-
function (t) {
|
|
56
|
-
try {
|
|
57
|
-
t.plan(5);
|
|
58
|
-
const ba = new ByteArray(10);
|
|
59
|
-
t.throws(() => ba.pushBytes('banana'));
|
|
60
|
-
ba.pushBytes([2, 4, 6, 8]);
|
|
61
|
-
t.equal(ba.byte(0), 2);
|
|
62
|
-
t.equal(ba.byte(2), 6);
|
|
63
|
-
t.equal(ba.bytes(1, 3)[2], 8);
|
|
64
|
-
t.throws(() => ba.bytes(1, 99));
|
|
65
|
-
} catch (err) {
|
|
66
|
-
console.log(err);
|
|
67
|
-
}
|
|
68
|
-
},
|
|
69
|
-
);
|
|
70
|
-
|
|
71
|
-
test(
|
|
72
|
-
`Write Bytes (${testGroup})`,
|
|
73
|
-
function (t) {
|
|
74
|
-
try {
|
|
75
|
-
t.plan(3);
|
|
76
|
-
const ba = new ByteArray(5);
|
|
77
|
-
ba.pushBytes([2, 4, 6, 8]);
|
|
78
|
-
t.equal(ba.byte(0), 2);
|
|
79
|
-
ba.setBytes(1, [3, 5, 7]);
|
|
80
|
-
t.throws(() => ba.setBytes(99, [1, 2]));
|
|
81
|
-
t.equal(ba.byte(2), 5);
|
|
82
|
-
} catch (err) {
|
|
83
|
-
console.log(err);
|
|
84
|
-
}
|
|
85
|
-
},
|
|
86
|
-
);
|
|
87
|
-
|
|
88
|
-
test(
|
|
89
|
-
`Grow (${testGroup})`,
|
|
90
|
-
function (t) {
|
|
91
|
-
try {
|
|
92
|
-
t.plan(6);
|
|
93
|
-
const ba = new ByteArray(5);
|
|
94
|
-
ba.pushBytes([2, 4, 6, 8, 10]);
|
|
95
|
-
t.equal(ba.length, 5);
|
|
96
|
-
t.equal(ba.byteArray.length, 5);
|
|
97
|
-
ba.pushByte(12);
|
|
98
|
-
t.equal(ba.byteArray.length, 21);
|
|
99
|
-
t.equal(ba.length, 6);
|
|
100
|
-
t.equal(ba.byte(0), 2);
|
|
101
|
-
t.equal(ba.byte(5), 12);
|
|
102
|
-
} catch (err) {
|
|
103
|
-
console.log(err);
|
|
104
|
-
}
|
|
105
|
-
},
|
|
106
|
-
);
|
|
107
|
-
|
|
108
|
-
test(
|
|
109
|
-
`NByte (${testGroup})`,
|
|
110
|
-
function (t) {
|
|
111
|
-
try {
|
|
112
|
-
t.plan(7);
|
|
113
|
-
const ba = new ByteArray();
|
|
114
|
-
ba.pushNByte(127);
|
|
115
|
-
t.equal(ba.byte(0), 127 + 128);
|
|
116
|
-
t.equal(ba.nByte(0), 127);
|
|
117
|
-
ba.pushNByte(130);
|
|
118
|
-
t.equal(ba.byte(1), 2);
|
|
119
|
-
t.equal(ba.byte(2), 1 + 128);
|
|
120
|
-
t.equal(ba.nByte(1), 130);
|
|
121
|
-
t.throws(() => ba.pushNByte('banana'));
|
|
122
|
-
t.throws(() => ba.nByte(99));
|
|
123
|
-
} catch (err) {
|
|
124
|
-
console.log(err);
|
|
125
|
-
}
|
|
126
|
-
},
|
|
127
|
-
);
|
|
128
|
-
|
|
129
|
-
test(
|
|
130
|
-
`NBytes (${testGroup})`,
|
|
131
|
-
function (t) {
|
|
132
|
-
try {
|
|
133
|
-
t.plan(6);
|
|
134
|
-
const ba = new ByteArray();
|
|
135
|
-
ba.pushNByte(127);
|
|
136
|
-
ba.pushNByte(17000);
|
|
137
|
-
ba.pushNByte(130);
|
|
138
|
-
const nBytes = ba.nBytes(0, 3);
|
|
139
|
-
t.equal(nBytes.length, 3);
|
|
140
|
-
t.equal(nBytes[0], 127);
|
|
141
|
-
t.equal(nBytes[1], 17000);
|
|
142
|
-
t.equal(nBytes[2], 130);
|
|
143
|
-
t.equal(ba.nBytes(0, 0).length, 0);
|
|
144
|
-
t.throws(() => ba.nBytes(0, 4));
|
|
145
|
-
} catch (err) {
|
|
146
|
-
console.log(err);
|
|
147
|
-
}
|
|
148
|
-
},
|
|
149
|
-
);
|
|
150
|
-
|
|
151
|
-
test(
|
|
152
|
-
`pushNBytes (${testGroup})`,
|
|
153
|
-
function (t) {
|
|
154
|
-
try {
|
|
155
|
-
t.plan(5);
|
|
156
|
-
const ba = new ByteArray();
|
|
157
|
-
ba.pushNBytes([127, 17000, 130]);
|
|
158
|
-
const nBytes = ba.nBytes(0, 3);
|
|
159
|
-
t.equal(nBytes.length, 3);
|
|
160
|
-
t.equal(nBytes[0], 127);
|
|
161
|
-
t.equal(nBytes[1], 17000);
|
|
162
|
-
t.equal(nBytes[2], 130);
|
|
163
|
-
t.throws(() => ba.pushNBytes([1, '2', 3]));
|
|
164
|
-
} catch (err) {
|
|
165
|
-
console.log(err);
|
|
166
|
-
}
|
|
167
|
-
},
|
|
168
|
-
);
|
|
169
|
-
|
|
170
|
-
test(
|
|
171
|
-
`Counted String (${testGroup})`,
|
|
172
|
-
function (t) {
|
|
173
|
-
try {
|
|
174
|
-
t.plan(9);
|
|
175
|
-
let ba = new ByteArray();
|
|
176
|
-
ba.pushCountedString('abc');
|
|
177
|
-
t.equal(ba.byte(0), 3);
|
|
178
|
-
t.equal(ba.byte(1), 'a'.charCodeAt(0));
|
|
179
|
-
t.equal(ba.countedString(0), 'abc');
|
|
180
|
-
ba = new ByteArray();
|
|
181
|
-
ba.pushCountedString('égale');
|
|
182
|
-
t.equal(ba.byte(0), 6);
|
|
183
|
-
t.equal(ba.byte(3), 'g'.charCodeAt(0));
|
|
184
|
-
t.equal(ba.countedString(0), 'égale');
|
|
185
|
-
ba = new ByteArray();
|
|
186
|
-
const musicalChar = String.fromCodePoint(0x1D11E);
|
|
187
|
-
ba.pushCountedString(musicalChar);
|
|
188
|
-
t.equal(ba.byte(0), 4);
|
|
189
|
-
t.equal(ba.countedString(0), musicalChar);
|
|
190
|
-
ba = new ByteArray();
|
|
191
|
-
const hebrew = 'וּבְדֶ֣רֶך';
|
|
192
|
-
ba.pushCountedString(hebrew);
|
|
193
|
-
t.equal(ba.countedString(0), hebrew);
|
|
194
|
-
} catch (err) {
|
|
195
|
-
console.log(err);
|
|
196
|
-
}
|
|
197
|
-
},
|
|
198
|
-
);
|
|
199
|
-
|
|
200
|
-
test(
|
|
201
|
-
`Clear (${testGroup})`,
|
|
202
|
-
function (t) {
|
|
203
|
-
try {
|
|
204
|
-
t.plan(3);
|
|
205
|
-
let ba = new ByteArray();
|
|
206
|
-
ba.pushCountedString('abc');
|
|
207
|
-
t.equal(ba.countedString(0), 'abc');
|
|
208
|
-
ba.clear();
|
|
209
|
-
t.equal(ba.byteArray[0], 0);
|
|
210
|
-
t.equal(ba.length, 0);
|
|
211
|
-
} catch (err) {
|
|
212
|
-
console.log(err);
|
|
213
|
-
}
|
|
214
|
-
},
|
|
215
|
-
);
|
|
216
|
-
|
|
217
|
-
test(
|
|
218
|
-
`nByteLength (${testGroup})`,
|
|
219
|
-
function (t) {
|
|
220
|
-
try {
|
|
221
|
-
t.plan(5);
|
|
222
|
-
let ba = new ByteArray();
|
|
223
|
-
ba.pushNByte((2 ** 7) - 1);
|
|
224
|
-
ba.pushNByte(2 ** 7);
|
|
225
|
-
ba.pushNByte(2 ** 14);
|
|
226
|
-
ba.pushNByte(2 ** 21);
|
|
227
|
-
t.equal(ba.nByteLength(ba.nByte(0)), 1);
|
|
228
|
-
t.equal(ba.nByteLength(ba.nByte(1)), 2);
|
|
229
|
-
t.equal(ba.nByteLength(ba.nByte(3)), 3);
|
|
230
|
-
t.equal(ba.nByteLength(ba.nByte(6)), 4);
|
|
231
|
-
t.throws(() => ba.nByteLength(128 ** 4));
|
|
232
|
-
} catch (err) {
|
|
233
|
-
console.log(err);
|
|
234
|
-
}
|
|
235
|
-
},
|
|
236
|
-
);
|
|
237
|
-
|
|
238
|
-
test(
|
|
239
|
-
`Trim (${testGroup})`,
|
|
240
|
-
function (t) {
|
|
241
|
-
try {
|
|
242
|
-
t.plan(2);
|
|
243
|
-
let ba = new ByteArray(256);
|
|
244
|
-
ba.pushCountedString('abc');
|
|
245
|
-
t.equal(ba.byteArray.length, 256);
|
|
246
|
-
ba.trim();
|
|
247
|
-
t.equal(ba.byteArray.length, 4);
|
|
248
|
-
} catch (err) {
|
|
249
|
-
console.log(err);
|
|
250
|
-
}
|
|
251
|
-
},
|
|
252
|
-
);
|
|
253
|
-
|
|
254
|
-
test(
|
|
255
|
-
`Base64 (${testGroup})`,
|
|
256
|
-
function (t) {
|
|
257
|
-
try {
|
|
258
|
-
t.plan(3);
|
|
259
|
-
let ba = new ByteArray();
|
|
260
|
-
ba.pushCountedString('abc');
|
|
261
|
-
ba.trim();
|
|
262
|
-
let ba2 = new ByteArray();
|
|
263
|
-
ba2.fromBase64(ba.base64());
|
|
264
|
-
t.equal(ba2.byteArray.length, 4);
|
|
265
|
-
t.equal(ba2.length, 4);
|
|
266
|
-
t.equal(ba2.countedString(0), 'abc');
|
|
267
|
-
} catch (err) {
|
|
268
|
-
console.log(err);
|
|
269
|
-
}
|
|
270
|
-
},
|
|
271
|
-
);
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
const test = require('tape');
|
|
2
|
-
const { utils } = require('../../../src/index.cjs');
|
|
3
|
-
|
|
4
|
-
const testGroup = 'Generate ID';
|
|
5
|
-
|
|
6
|
-
test(
|
|
7
|
-
`Get an Id (${testGroup})`,
|
|
8
|
-
function (t) {
|
|
9
|
-
try {
|
|
10
|
-
t.plan(utils.canons.ptBookArray.length * 2);
|
|
11
|
-
|
|
12
|
-
for (const ptBook of utils.canons.ptBookArray) {
|
|
13
|
-
t.ok(ptBook.code in utils.canons.ptBooks);
|
|
14
|
-
t.equal(ptBook.code, utils.canons.ptBooks[ptBook.code].code);
|
|
15
|
-
}
|
|
16
|
-
} catch (err) {
|
|
17
|
-
console.log(err);
|
|
18
|
-
}
|
|
19
|
-
},
|
|
20
|
-
);
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
const test = require('tape');
|
|
2
|
-
const { utils } = require('../../../src/index.cjs');
|
|
3
|
-
|
|
4
|
-
const testGroup = 'Generate ID';
|
|
5
|
-
|
|
6
|
-
test(
|
|
7
|
-
`Get an Id (${testGroup})`,
|
|
8
|
-
function (t) {
|
|
9
|
-
try {
|
|
10
|
-
t.plan(1);
|
|
11
|
-
const id = utils.generateId();
|
|
12
|
-
t.equal(id.length, 12);
|
|
13
|
-
} catch (err) {
|
|
14
|
-
console.log(err);
|
|
15
|
-
}
|
|
16
|
-
},
|
|
17
|
-
);
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
const test = require('tape');
|
|
2
|
-
const { utils } = require('../../../src/index.cjs');
|
|
3
|
-
|
|
4
|
-
const testGroup = 'Graft Defs';
|
|
5
|
-
|
|
6
|
-
test(
|
|
7
|
-
`Get an Id (${testGroup})`,
|
|
8
|
-
function (t) {
|
|
9
|
-
try {
|
|
10
|
-
t.plan(1);
|
|
11
|
-
t.equal(utils.graftDefs.graftLocation['footnote'], 'inline');
|
|
12
|
-
} catch (err) {
|
|
13
|
-
console.log(err);
|
|
14
|
-
}
|
|
15
|
-
},
|
|
16
|
-
);
|