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
package/esm/wrapper.mjs
CHANGED
package/{index.js → index.cjs}
RENAMED
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "proskomma-core",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.13",
|
|
4
4
|
"description": "A Scripture Runtime Engine",
|
|
5
5
|
"main": "esm/wrapper.mjs",
|
|
6
6
|
"exports": {
|
|
7
|
-
"require": "./index.
|
|
7
|
+
"require": "./index.cjs",
|
|
8
8
|
"import": "./esm/wrapper.mjs"
|
|
9
9
|
},
|
|
10
10
|
"scripts": {
|
package/babel.config.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
'assumptions': {
|
|
3
|
-
'noDocumentAll': true,
|
|
4
|
-
'pureGetters': true,
|
|
5
|
-
'iterableIsArray': true,
|
|
6
|
-
'ignoreToPrimitiveHint': true,
|
|
7
|
-
},
|
|
8
|
-
'presets': [
|
|
9
|
-
[
|
|
10
|
-
'@babel/preset-env',
|
|
11
|
-
{
|
|
12
|
-
'targets': { 'esmodules': true },
|
|
13
|
-
'useBuiltIns': 'entry',
|
|
14
|
-
'corejs': '3.25.1',
|
|
15
|
-
},
|
|
16
|
-
],
|
|
17
|
-
],
|
|
18
|
-
};
|
package/test/code/main/bad.cjs
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
/* eslint-disable require-await */
|
|
2
|
-
const test = require('tape');
|
|
3
|
-
|
|
4
|
-
const { pkWithDoc } = require('../../lib/load.js');
|
|
5
|
-
|
|
6
|
-
const testGroup = 'Lexing Badness';
|
|
7
|
-
|
|
8
|
-
const pk = pkWithDoc('../test_data/usfm/backslash.usfm', {
|
|
9
|
-
lang: 'fra',
|
|
10
|
-
abbr: 'hello',
|
|
11
|
-
})[0];
|
|
12
|
-
const pk2 = pkWithDoc('../test_data/usfm/unknown.usfm', {
|
|
13
|
-
lang: 'fra',
|
|
14
|
-
abbr: 'hello',
|
|
15
|
-
})[0];
|
|
16
|
-
|
|
17
|
-
test(
|
|
18
|
-
`Bare Backslash (${testGroup})`,
|
|
19
|
-
async function (t) {
|
|
20
|
-
try {
|
|
21
|
-
t.plan(2);
|
|
22
|
-
const query = `{ documents { mainSequence { blocks { items { type subType payload } } } } }`;
|
|
23
|
-
const result = await pk.gqlQuery(query);
|
|
24
|
-
t.equal(result.errors, undefined);
|
|
25
|
-
const firstItem = result.data.documents[0].mainSequence.blocks[0].items[0];
|
|
26
|
-
t.equal(firstItem.subType, 'bareSlash');
|
|
27
|
-
} catch (err) {
|
|
28
|
-
console.log(err);
|
|
29
|
-
}
|
|
30
|
-
},
|
|
31
|
-
);
|
|
32
|
-
|
|
33
|
-
test(
|
|
34
|
-
`Handle exotic symbols (not really ${testGroup})`,
|
|
35
|
-
async function (t) {
|
|
36
|
-
try {
|
|
37
|
-
t.plan(3);
|
|
38
|
-
const query = `{ documents { mainSequence { blocks { items { type subType payload } } } } }`;
|
|
39
|
-
const result = await pk2.gqlQuery(query);
|
|
40
|
-
t.equal(result.errors, undefined);
|
|
41
|
-
const firstItem = result.data.documents[0].mainSequence.blocks[0].items[0];
|
|
42
|
-
t.equal(firstItem.subType, 'punctuation');
|
|
43
|
-
const secondItem = result.data.documents[0].mainSequence.blocks[0].items[1];
|
|
44
|
-
t.equal(secondItem.subType, 'punctuation');
|
|
45
|
-
} catch (err) {
|
|
46
|
-
console.log(err);
|
|
47
|
-
}
|
|
48
|
-
},
|
|
49
|
-
);
|
|
50
|
-
|
|
51
|
-
test(
|
|
52
|
-
`Bad Element in USX (${testGroup})`,
|
|
53
|
-
async function (t) {
|
|
54
|
-
try {
|
|
55
|
-
t.plan(1);
|
|
56
|
-
t.throws(() => pkWithDoc('../test_data/usx/bad_element.usx', {
|
|
57
|
-
lang: 'fra',
|
|
58
|
-
abbr: 'hello',
|
|
59
|
-
}), /Unexpected .+bananas/);
|
|
60
|
-
} catch (err) {
|
|
61
|
-
console.log(err);
|
|
62
|
-
}
|
|
63
|
-
},
|
|
64
|
-
);
|
|
65
|
-
|
|
66
|
-
test(
|
|
67
|
-
`No mt (${testGroup})`,
|
|
68
|
-
async function (t) {
|
|
69
|
-
try {
|
|
70
|
-
t.plan(1);
|
|
71
|
-
t.throws(() => pkWithDoc('../test_data/usfm/no_mt.usfm', {
|
|
72
|
-
lang: 'fra',
|
|
73
|
-
abbr: 'hello',
|
|
74
|
-
}), /wordLike content/);
|
|
75
|
-
} catch (err) {
|
|
76
|
-
console.log(err);
|
|
77
|
-
}
|
|
78
|
-
},
|
|
79
|
-
);
|
|
@@ -1,534 +0,0 @@
|
|
|
1
|
-
const test = require('tape');
|
|
2
|
-
|
|
3
|
-
const { Proskomma } = require('../../../src/index.cjs');
|
|
4
|
-
const {
|
|
5
|
-
pkWithDoc,
|
|
6
|
-
pkWithDocs,
|
|
7
|
-
} = require('../../lib/load.js');
|
|
8
|
-
|
|
9
|
-
const testGroup = 'Graph Basics';
|
|
10
|
-
|
|
11
|
-
const [pk, pkDoc] = pkWithDoc('../test_data/usx/web_rut.usx', {
|
|
12
|
-
lang: 'eng',
|
|
13
|
-
abbr: 'web',
|
|
14
|
-
});
|
|
15
|
-
const pk2 = pkWithDocs([
|
|
16
|
-
['../test_data/usx/web_psa150.usx', {
|
|
17
|
-
lang: 'eng',
|
|
18
|
-
abbr: 'webbe',
|
|
19
|
-
}],
|
|
20
|
-
['../test_data/usx/web_rut.usx', {
|
|
21
|
-
lang: 'eng',
|
|
22
|
-
abbr: 'webbe',
|
|
23
|
-
}],
|
|
24
|
-
['../test_data/usfm/ust_psa.usfm', {
|
|
25
|
-
lang: 'eng',
|
|
26
|
-
abbr: 'ust',
|
|
27
|
-
}],
|
|
28
|
-
['../test_data/usx/not_nfc18_phm.usx', {
|
|
29
|
-
lang: 'eng',
|
|
30
|
-
abbr: 'nnfc18',
|
|
31
|
-
}],
|
|
32
|
-
]);
|
|
33
|
-
|
|
34
|
-
const pk3 = pkWithDocs([
|
|
35
|
-
['../test_data/usx/web_rut.usx', {
|
|
36
|
-
lang: 'eng',
|
|
37
|
-
abbr: 'webbe',
|
|
38
|
-
}],
|
|
39
|
-
['../test_data/usfm/web_ecc.usfm', {
|
|
40
|
-
lang: 'eng',
|
|
41
|
-
abbr: 'webbe',
|
|
42
|
-
}],
|
|
43
|
-
['../test_data/usx/web_psa150.usx', {
|
|
44
|
-
lang: 'eng',
|
|
45
|
-
abbr: 'webbe',
|
|
46
|
-
}],
|
|
47
|
-
]);
|
|
48
|
-
|
|
49
|
-
test(
|
|
50
|
-
`Scalar Root Fields (${testGroup})`,
|
|
51
|
-
async function (t) {
|
|
52
|
-
try {
|
|
53
|
-
t.plan(9);
|
|
54
|
-
const query = '{ id processor packageVersion nDocSets nDocuments }';
|
|
55
|
-
const pk = new Proskomma();
|
|
56
|
-
const result = await pk.gqlQuery(query);
|
|
57
|
-
t.equal(result.errors, undefined);
|
|
58
|
-
t.ok('id' in result.data);
|
|
59
|
-
t.ok('processor' in result.data);
|
|
60
|
-
t.ok('packageVersion' in result.data);
|
|
61
|
-
t.equal(result.data.packageVersion, pk.packageVersion());
|
|
62
|
-
t.ok('nDocSets' in result.data);
|
|
63
|
-
t.equal(result.data.nDocSets, 0);
|
|
64
|
-
t.ok('nDocuments' in result.data);
|
|
65
|
-
t.equal(result.data.nDocuments, 0);
|
|
66
|
-
} catch (err) {
|
|
67
|
-
console.log(err);
|
|
68
|
-
}
|
|
69
|
-
},
|
|
70
|
-
);
|
|
71
|
-
|
|
72
|
-
test(
|
|
73
|
-
`Sync query (${testGroup})`,
|
|
74
|
-
function (t) {
|
|
75
|
-
try {
|
|
76
|
-
t.plan(2);
|
|
77
|
-
const query = '{ id }';
|
|
78
|
-
const pk = new Proskomma();
|
|
79
|
-
const result = pk.gqlQuerySync(query);
|
|
80
|
-
t.equal(result.errors, undefined);
|
|
81
|
-
t.ok('id' in result.data);
|
|
82
|
-
} catch (err) {
|
|
83
|
-
console.log(err);
|
|
84
|
-
}
|
|
85
|
-
},
|
|
86
|
-
);
|
|
87
|
-
|
|
88
|
-
test(
|
|
89
|
-
`DocSets (${testGroup})`,
|
|
90
|
-
async function (t) {
|
|
91
|
-
try {
|
|
92
|
-
t.plan(4);
|
|
93
|
-
const query = '{ docSets { id lang: selector(id:"lang") abbr: selector(id:"abbr") } }';
|
|
94
|
-
const result = await pk.gqlQuery(query);
|
|
95
|
-
t.equal(result.errors, undefined);
|
|
96
|
-
t.ok('id' in result.data.docSets[0]);
|
|
97
|
-
t.equal(result.data.docSets[0].lang, 'eng');
|
|
98
|
-
t.equal(result.data.docSets[0].abbr, 'web');
|
|
99
|
-
} catch (err) {
|
|
100
|
-
console.log(err);
|
|
101
|
-
}
|
|
102
|
-
},
|
|
103
|
-
);
|
|
104
|
-
|
|
105
|
-
test(
|
|
106
|
-
`Sort DocSet Documents (${testGroup})`,
|
|
107
|
-
async function (t) {
|
|
108
|
-
try {
|
|
109
|
-
t.plan(8);
|
|
110
|
-
let query = '{ docSets { documents(sortedBy:"paratext") { bookCode: header(id:"bookCode") } } }';
|
|
111
|
-
let result = await pk3.gqlQuery(query);
|
|
112
|
-
t.equal(result.errors, undefined);
|
|
113
|
-
t.equal(result.data.docSets[0].documents[0].bookCode, 'RUT');
|
|
114
|
-
t.equal(result.data.docSets[0].documents[2].bookCode, 'ECC');
|
|
115
|
-
query = '{ docSets { documents(sortedBy:"alpha") { bookCode: header(id:"bookCode") } } }';
|
|
116
|
-
result = await pk3.gqlQuery(query);
|
|
117
|
-
t.equal(result.errors, undefined);
|
|
118
|
-
t.equal(result.data.docSets[0].documents[0].bookCode, 'ECC');
|
|
119
|
-
t.equal(result.data.docSets[0].documents[2].bookCode, 'RUT');
|
|
120
|
-
query = '{ docSets { documents(sortedBy:"banana") { bookCode: header(id:"bookCode") } } }';
|
|
121
|
-
result = await pk3.gqlQuery(query);
|
|
122
|
-
t.equal(result.errors.length, 1);
|
|
123
|
-
t.ok(result.errors[0].message.includes('banana'));
|
|
124
|
-
} catch (err) {
|
|
125
|
-
console.log(err);
|
|
126
|
-
}
|
|
127
|
-
},
|
|
128
|
-
);
|
|
129
|
-
|
|
130
|
-
test(
|
|
131
|
-
`nDocuments in docSet (${testGroup})`,
|
|
132
|
-
async function (t) {
|
|
133
|
-
try {
|
|
134
|
-
t.plan(3);
|
|
135
|
-
const query = '{ docSets { nDocuments } }';
|
|
136
|
-
const result = await pk.gqlQuery(query);
|
|
137
|
-
t.equal(result.errors, undefined);
|
|
138
|
-
t.ok('nDocuments' in result.data.docSets[0]);
|
|
139
|
-
t.equal(result.data.docSets[0].nDocuments, 1);
|
|
140
|
-
} catch (err) {
|
|
141
|
-
console.log(err);
|
|
142
|
-
}
|
|
143
|
-
},
|
|
144
|
-
);
|
|
145
|
-
|
|
146
|
-
test(
|
|
147
|
-
`DocSet (${testGroup})`,
|
|
148
|
-
async function (t) {
|
|
149
|
-
try {
|
|
150
|
-
t.plan(5);
|
|
151
|
-
const query = `{ docSet(id: "${pkDoc.docSetId}") { id lang: selector(id:"lang") abbr: selector(id:"abbr") documents { id } } }`;
|
|
152
|
-
const result = await pk.gqlQuery(query);
|
|
153
|
-
t.equal(result.errors, undefined);
|
|
154
|
-
t.ok('id' in result.data.docSet);
|
|
155
|
-
t.equal(result.data.docSet.lang, 'eng');
|
|
156
|
-
t.equal(result.data.docSet.abbr, 'web');
|
|
157
|
-
t.ok('id' in result.data.docSet.documents[0]);
|
|
158
|
-
} catch (err) {
|
|
159
|
-
console.log(err);
|
|
160
|
-
}
|
|
161
|
-
},
|
|
162
|
-
);
|
|
163
|
-
|
|
164
|
-
test(
|
|
165
|
-
`Filter docSets by IDs (${testGroup})`,
|
|
166
|
-
async function (t) {
|
|
167
|
-
try {
|
|
168
|
-
t.plan(5);
|
|
169
|
-
const query = `{ docSets(ids: ["${pkDoc.docSetId}"]) { id lang: selector(id:"lang") abbr: selector(id:"abbr") documents { id } } }`;
|
|
170
|
-
const result = await pk.gqlQuery(query);
|
|
171
|
-
t.equal(result.errors, undefined);
|
|
172
|
-
t.ok('id' in result.data.docSets[0]);
|
|
173
|
-
t.equal(result.data.docSets[0].lang, 'eng');
|
|
174
|
-
t.equal(result.data.docSets[0].abbr, 'web');
|
|
175
|
-
t.ok('id' in result.data.docSets[0].documents[0]);
|
|
176
|
-
} catch (err) {
|
|
177
|
-
console.log(err);
|
|
178
|
-
}
|
|
179
|
-
},
|
|
180
|
-
);
|
|
181
|
-
|
|
182
|
-
test(
|
|
183
|
-
`Filter docSets by withBooks (${testGroup})`,
|
|
184
|
-
async function (t) {
|
|
185
|
-
try {
|
|
186
|
-
t.plan(4);
|
|
187
|
-
const query = `{ docSets(withBook: "PSA") { id lang: selector(id:"lang") selector(id:"abbr") document(bookCode: "PSA") { id header(id:"bookCode")} } }`;
|
|
188
|
-
const result = await pk2.gqlQuery(query);
|
|
189
|
-
t.equal(result.errors, undefined);
|
|
190
|
-
t.equal(result.data.docSets.length, 2);
|
|
191
|
-
t.equal(result.data.docSets[0].document.header, 'PSA');
|
|
192
|
-
t.equal(result.data.docSets[1].document.header, 'PSA');
|
|
193
|
-
} catch (err) {
|
|
194
|
-
console.log(err);
|
|
195
|
-
}
|
|
196
|
-
},
|
|
197
|
-
);
|
|
198
|
-
|
|
199
|
-
test(
|
|
200
|
-
`Filter docSets documents by withChars (${testGroup})`,
|
|
201
|
-
async function (t) {
|
|
202
|
-
try {
|
|
203
|
-
const docSetDocuments = ds => ds
|
|
204
|
-
.map(ds => ds.documents)
|
|
205
|
-
.reduce((a, b) => a.concat(b));
|
|
206
|
-
t.plan(5);
|
|
207
|
-
let query = `{ docSets { documents(withChars: ["Boaz" "banana"]) { id header(id:"bookCode")} } }`;
|
|
208
|
-
let result = await pk2.gqlQuery(query);
|
|
209
|
-
t.equal(result.errors, undefined);
|
|
210
|
-
let documents = docSetDocuments(result.data.docSets);
|
|
211
|
-
t.equal(documents.length, 1);
|
|
212
|
-
t.equal(documents[0].header, 'RUT');
|
|
213
|
-
query = `{ docSets { documents(withChars: ["Boaz" "banana"] allChars: true) { id header(id:"bookCode")} } }`;
|
|
214
|
-
result = await pk2.gqlQuery(query);
|
|
215
|
-
t.equal(result.errors, undefined);
|
|
216
|
-
documents = docSetDocuments(result.data.docSets);
|
|
217
|
-
t.equal(documents.length, 0);
|
|
218
|
-
} catch (err) {
|
|
219
|
-
console.log(err);
|
|
220
|
-
}
|
|
221
|
-
},
|
|
222
|
-
);
|
|
223
|
-
|
|
224
|
-
test(
|
|
225
|
-
`Filter docSets documents by withMatchingChars (${testGroup})`,
|
|
226
|
-
async function (t) {
|
|
227
|
-
try {
|
|
228
|
-
const docSetDocuments = ds => ds
|
|
229
|
-
.map(ds => ds.documents)
|
|
230
|
-
.reduce((a, b) => a.concat(b));
|
|
231
|
-
t.plan(5);
|
|
232
|
-
let query = `{ docSets { documents(withMatchingChars: ["boaz" "banana"]) { id header(id:"bookCode")} } }`;
|
|
233
|
-
let result = await pk2.gqlQuery(query);
|
|
234
|
-
t.equal(result.errors, undefined);
|
|
235
|
-
let documents = docSetDocuments(result.data.docSets);
|
|
236
|
-
t.equal(documents.length, 1);
|
|
237
|
-
t.equal(documents[0].header, 'RUT');
|
|
238
|
-
query = `{ docSets { documents(withMatchingChars: ["boaz" "banana"] allChars: true) { id header(id:"bookCode")} } }`;
|
|
239
|
-
result = await pk2.gqlQuery(query);
|
|
240
|
-
t.equal(result.errors, undefined);
|
|
241
|
-
documents = docSetDocuments(result.data.docSets);
|
|
242
|
-
t.equal(documents.length, 0);
|
|
243
|
-
} catch (err) {
|
|
244
|
-
console.log(err);
|
|
245
|
-
}
|
|
246
|
-
},
|
|
247
|
-
);
|
|
248
|
-
|
|
249
|
-
test(
|
|
250
|
-
`Filter docSets documents by withScopes (${testGroup})`,
|
|
251
|
-
async function (t) {
|
|
252
|
-
try {
|
|
253
|
-
const docSetDocuments = ds => ds
|
|
254
|
-
.map(ds => ds.documents)
|
|
255
|
-
.reduce((a, b) => a.concat(b));
|
|
256
|
-
t.plan(4);
|
|
257
|
-
let query = `{ docSets { documents(withScopes: ["blockTag/p" "blockTag/q" "blockTag/q2"]) { id header(id:"bookCode")} } }`;
|
|
258
|
-
let result = await pk2.gqlQuery(query);
|
|
259
|
-
t.equal(result.errors, undefined);
|
|
260
|
-
let documents = docSetDocuments(result.data.docSets);
|
|
261
|
-
t.equal(documents.length, 4);
|
|
262
|
-
query = `{ docSets { documents(withScopes: ["blockTag/q" "blockTag/q2"] allScopes:true) { id header(id:"bookCode")} } }`;
|
|
263
|
-
result = await pk2.gqlQuery(query);
|
|
264
|
-
t.equal(result.errors, undefined);
|
|
265
|
-
documents = docSetDocuments(result.data.docSets);
|
|
266
|
-
t.equal(documents.length, 2);
|
|
267
|
-
} catch (err) {
|
|
268
|
-
console.log(err);
|
|
269
|
-
}
|
|
270
|
-
},
|
|
271
|
-
);
|
|
272
|
-
|
|
273
|
-
test(
|
|
274
|
-
`Filter docSets documents by withHeaderValues (${testGroup})`,
|
|
275
|
-
async function (t) {
|
|
276
|
-
try {
|
|
277
|
-
const docSetDocuments = ds => ds
|
|
278
|
-
.map(ds => ds.documents)
|
|
279
|
-
.reduce((a, b) => a.concat(b));
|
|
280
|
-
t.plan(8);
|
|
281
|
-
let query = `{ docSets { documents(withHeaderValues: { key: "bookCode" value: "PSA" }) { id } } }`;
|
|
282
|
-
let result = await pk2.gqlQuery(query);
|
|
283
|
-
t.equal(result.errors, undefined);
|
|
284
|
-
let documents = docSetDocuments(result.data.docSets);
|
|
285
|
-
t.equal(documents.length, 2);
|
|
286
|
-
query = `{ docSets { documents(withHeaderValues: { key: "ide" value: "UTF-8" }) { id } } }`;
|
|
287
|
-
result = await pk2.gqlQuery(query);
|
|
288
|
-
t.equal(result.errors, undefined);
|
|
289
|
-
documents = docSetDocuments(result.data.docSets);
|
|
290
|
-
t.equal(documents.length, 3);
|
|
291
|
-
query = `{ docSets { documents(withHeaderValues: { key: "ide" value: "EDBIC" }) { id } } }`;
|
|
292
|
-
result = await pk2.gqlQuery(query);
|
|
293
|
-
t.equal(result.errors, undefined);
|
|
294
|
-
documents = docSetDocuments(result.data.docSets);
|
|
295
|
-
t.equal(documents.length, 0);
|
|
296
|
-
query = `{ docSets { documents(withHeaderValues: { key: "banana" value: "split" }) { id } } }`;
|
|
297
|
-
result = await pk2.gqlQuery(query);
|
|
298
|
-
t.equal(result.errors, undefined);
|
|
299
|
-
documents = docSetDocuments(result.data.docSets);
|
|
300
|
-
t.equal(documents.length, 0);
|
|
301
|
-
} catch (err) {
|
|
302
|
-
console.log(err);
|
|
303
|
-
}
|
|
304
|
-
},
|
|
305
|
-
);
|
|
306
|
-
|
|
307
|
-
test(
|
|
308
|
-
`Documents (${testGroup})`,
|
|
309
|
-
async function (t) {
|
|
310
|
-
try {
|
|
311
|
-
t.plan(2);
|
|
312
|
-
const query = '{ documents { id } }';
|
|
313
|
-
const result = await pk.gqlQuery(query);
|
|
314
|
-
t.equal(result.errors, undefined);
|
|
315
|
-
t.ok('id' in result.data.documents[0]);
|
|
316
|
-
} catch (err) {
|
|
317
|
-
console.log(err);
|
|
318
|
-
}
|
|
319
|
-
},
|
|
320
|
-
);
|
|
321
|
-
|
|
322
|
-
test(
|
|
323
|
-
`Sort Documents (${testGroup})`,
|
|
324
|
-
async function (t) {
|
|
325
|
-
try {
|
|
326
|
-
t.plan(5);
|
|
327
|
-
let query = '{ documents(sortedBy:"paratext") { bookCode: header(id:"bookCode") } }';
|
|
328
|
-
let result = await pk2.gqlQuery(query);
|
|
329
|
-
t.equal(result.errors, undefined);
|
|
330
|
-
t.equal(result.data.documents[0].bookCode, 'RUT');
|
|
331
|
-
t.equal(result.data.documents[3].bookCode, 'PHM');
|
|
332
|
-
query = '{ documents(sortedBy:"banana") { bookCode: header(id:"bookCode") } }';
|
|
333
|
-
result = await pk2.gqlQuery(query);
|
|
334
|
-
t.equal(result.errors.length, 1);
|
|
335
|
-
t.ok(result.errors[0].message.includes('banana'));
|
|
336
|
-
} catch (err) {
|
|
337
|
-
console.log(err);
|
|
338
|
-
}
|
|
339
|
-
},
|
|
340
|
-
);
|
|
341
|
-
|
|
342
|
-
test(
|
|
343
|
-
`Document (${testGroup})`,
|
|
344
|
-
async function (t) {
|
|
345
|
-
try {
|
|
346
|
-
t.plan(8);
|
|
347
|
-
let query = `{ document(id: "${pkDoc.id}") { id } }`;
|
|
348
|
-
let result = await pk.gqlQuery(query);
|
|
349
|
-
t.equal(result.errors, undefined);
|
|
350
|
-
t.ok('id' in result.data.document);
|
|
351
|
-
query = `{ document(withBook: "RUT" docSetId: "${pkDoc.docSetId}") { id } }`;
|
|
352
|
-
result = await pk.gqlQuery(query);
|
|
353
|
-
t.equal(result.errors, undefined);
|
|
354
|
-
t.ok('id' in result.data.document);
|
|
355
|
-
query = `{ document(withBook: "XYZ" docSetId: "${pkDoc.docSetId}") { id } }`;
|
|
356
|
-
result = await pk.gqlQuery(query);
|
|
357
|
-
t.equal(result.errors, undefined);
|
|
358
|
-
t.ok(!result.data.document);
|
|
359
|
-
query = `{ document(withBook: "RUT") { id } }`;
|
|
360
|
-
result = await pk.gqlQuery(query);
|
|
361
|
-
t.equal(result.errors.length, 1);
|
|
362
|
-
t.ok(result.errors[0].message.includes('but not all three'));
|
|
363
|
-
} catch (err) {
|
|
364
|
-
console.log(err);
|
|
365
|
-
}
|
|
366
|
-
},
|
|
367
|
-
);
|
|
368
|
-
|
|
369
|
-
test(
|
|
370
|
-
`Filter documents by id (${testGroup})`,
|
|
371
|
-
async function (t) {
|
|
372
|
-
try {
|
|
373
|
-
t.plan(3);
|
|
374
|
-
const query = `{ documents(ids: ["${pkDoc.id}"]) { id } noDocs: documents(ids: ["abc"]) { id }}`;
|
|
375
|
-
const result = await pk.gqlQuery(query);
|
|
376
|
-
t.equal(result.errors, undefined);
|
|
377
|
-
t.ok('id' in result.data.documents[0]);
|
|
378
|
-
t.equal(result.data.noDocs.length, 0);
|
|
379
|
-
} catch (err) {
|
|
380
|
-
console.log(err);
|
|
381
|
-
}
|
|
382
|
-
},
|
|
383
|
-
);
|
|
384
|
-
|
|
385
|
-
test(
|
|
386
|
-
`Filter docSet documents by id (${testGroup})`,
|
|
387
|
-
async function (t) {
|
|
388
|
-
try {
|
|
389
|
-
t.plan(3);
|
|
390
|
-
const query = `{ docSet(id: "${pkDoc.docSetId}") { documents(ids: ["${pkDoc.id}"]) { id } noDocs: documents(ids: ["abc"]) { id } } }`;
|
|
391
|
-
const result = await pk.gqlQuery(query);
|
|
392
|
-
t.equal(result.errors, undefined);
|
|
393
|
-
t.ok('id' in result.data.docSet.documents[0]);
|
|
394
|
-
t.equal(result.data.docSet.noDocs.length, 0);
|
|
395
|
-
} catch (err) {
|
|
396
|
-
console.log(err);
|
|
397
|
-
}
|
|
398
|
-
},
|
|
399
|
-
);
|
|
400
|
-
|
|
401
|
-
test(
|
|
402
|
-
`Filter documents by withBook (${testGroup})`,
|
|
403
|
-
async function (t) {
|
|
404
|
-
try {
|
|
405
|
-
t.plan(4);
|
|
406
|
-
const query = `{ documents(withBook:"PSA") { id header(id:"bookCode") } }`;
|
|
407
|
-
const result = await pk2.gqlQuery(query);
|
|
408
|
-
t.equal(result.errors, undefined);
|
|
409
|
-
t.equal(result.data.documents.length, 2);
|
|
410
|
-
t.equal(result.data.documents[0].header, 'PSA');
|
|
411
|
-
t.equal(result.data.documents[1].header, 'PSA');
|
|
412
|
-
} catch (err) {
|
|
413
|
-
console.log(err);
|
|
414
|
-
}
|
|
415
|
-
},
|
|
416
|
-
);
|
|
417
|
-
|
|
418
|
-
test(
|
|
419
|
-
`Filter documents by withHeaderValues (${testGroup})`,
|
|
420
|
-
async function (t) {
|
|
421
|
-
try {
|
|
422
|
-
t.plan(10);
|
|
423
|
-
let query = `{ documents(withHeaderValues:{key: "bookCode" value: "PSA" }) { id } }`;
|
|
424
|
-
let result = await pk2.gqlQuery(query);
|
|
425
|
-
t.equal(result.errors, undefined);
|
|
426
|
-
t.equal(result.data.documents.length, 2);
|
|
427
|
-
query = `{ documents(withHeaderValues:{key: "bookCode" value: "RUT" }) { id } }`;
|
|
428
|
-
result = await pk2.gqlQuery(query);
|
|
429
|
-
t.equal(result.errors, undefined);
|
|
430
|
-
t.equal(result.data.documents.length, 1);
|
|
431
|
-
query = `{ documents(withHeaderValues:{key: "ide" value: "UTF-8" }) { id } }`;
|
|
432
|
-
result = await pk2.gqlQuery(query);
|
|
433
|
-
t.equal(result.errors, undefined);
|
|
434
|
-
t.equal(result.data.documents.length, 3);
|
|
435
|
-
query = `{ documents(withHeaderValues:{key: "ide" value: "EDBIC" }) { id } }`;
|
|
436
|
-
result = await pk2.gqlQuery(query);
|
|
437
|
-
t.equal(result.errors, undefined);
|
|
438
|
-
t.equal(result.data.documents.length, 0);
|
|
439
|
-
query = `{ documents(withHeaderValues:{key: "banana" value: "split" }) { id } }`;
|
|
440
|
-
result = await pk2.gqlQuery(query);
|
|
441
|
-
t.equal(result.errors, undefined);
|
|
442
|
-
t.equal(result.data.documents.length, 0);
|
|
443
|
-
} catch (err) {
|
|
444
|
-
console.log(err);
|
|
445
|
-
}
|
|
446
|
-
},
|
|
447
|
-
);
|
|
448
|
-
|
|
449
|
-
test(
|
|
450
|
-
`Enum index for string (${testGroup})`,
|
|
451
|
-
async function (t) {
|
|
452
|
-
try {
|
|
453
|
-
t.plan(3);
|
|
454
|
-
const query =
|
|
455
|
-
'{' +
|
|
456
|
-
' docSets {' +
|
|
457
|
-
' boaz: enumIndexForString(enumType:"wordLike" searchString:"Boaz")' +
|
|
458
|
-
' banana: enumIndexForString(enumType:"wordLike" searchString:"Banana")' +
|
|
459
|
-
' }' +
|
|
460
|
-
'}';
|
|
461
|
-
const result = await pk.gqlQuery(query);
|
|
462
|
-
t.equal(result.errors, undefined);
|
|
463
|
-
t.ok(result.data.docSets[0].boaz > 0);
|
|
464
|
-
t.equal(result.data.docSets[0].banana, -1);
|
|
465
|
-
} catch (err) {
|
|
466
|
-
console.log(err);
|
|
467
|
-
}
|
|
468
|
-
},
|
|
469
|
-
);
|
|
470
|
-
|
|
471
|
-
test(
|
|
472
|
-
`Enum regex indexes for string (${testGroup})`,
|
|
473
|
-
async function (t) {
|
|
474
|
-
try {
|
|
475
|
-
t.plan(3);
|
|
476
|
-
const query =
|
|
477
|
-
'{' +
|
|
478
|
-
' docSets {' +
|
|
479
|
-
' kin: enumRegexIndexesForString(enumType:"wordLike" searchRegex:"kinsm[ae]n") { index matched }' +
|
|
480
|
-
' banana: enumRegexIndexesForString(enumType:"wordLike" searchRegex:"Banana") { index matched }' +
|
|
481
|
-
' }' +
|
|
482
|
-
'}';
|
|
483
|
-
const result = await pk.gqlQuery(query);
|
|
484
|
-
t.equal(result.errors, undefined);
|
|
485
|
-
t.equal(result.data.docSets[0].kin.length, 2);
|
|
486
|
-
t.equal(result.data.docSets[0].banana.length, 0);
|
|
487
|
-
// console.log(JSON.stringify(result.data, null, 2));
|
|
488
|
-
} catch (err) {
|
|
489
|
-
console.log(err);
|
|
490
|
-
}
|
|
491
|
-
},
|
|
492
|
-
);
|
|
493
|
-
|
|
494
|
-
test(
|
|
495
|
-
`Unique Chars (${testGroup})`,
|
|
496
|
-
async function (t) {
|
|
497
|
-
try {
|
|
498
|
-
t.plan(7);
|
|
499
|
-
const query = '{ docSets { uniqueChars } }';
|
|
500
|
-
const result = await pk.gqlQuery(query);
|
|
501
|
-
t.equal(result.errors, undefined);
|
|
502
|
-
// console.log(JSON.stringify(result.data, null, 2));
|
|
503
|
-
t.ok(result.data.docSets[0].uniqueChars.length > 0);
|
|
504
|
-
t.ok(result.data.docSets[0].uniqueChars.includes(' '));
|
|
505
|
-
t.ok(result.data.docSets[0].uniqueChars.includes('!'));
|
|
506
|
-
t.ok(result.data.docSets[0].uniqueChars.includes('A'));
|
|
507
|
-
t.ok(result.data.docSets[0].uniqueChars.includes('1'));
|
|
508
|
-
t.ok(result.data.docSets[0].uniqueChars.includes('א'));
|
|
509
|
-
} catch (err) {
|
|
510
|
-
console.log(err);
|
|
511
|
-
}
|
|
512
|
-
},
|
|
513
|
-
);
|
|
514
|
-
|
|
515
|
-
test(
|
|
516
|
-
`Unique Chars String (${testGroup})`,
|
|
517
|
-
async function (t) {
|
|
518
|
-
try {
|
|
519
|
-
t.plan(7);
|
|
520
|
-
const query = '{ docSets { uniqueCharsString } }';
|
|
521
|
-
const result = await pk.gqlQuery(query);
|
|
522
|
-
t.equal(result.errors, undefined);
|
|
523
|
-
// console.log(JSON.stringify(result.data, null, 2));
|
|
524
|
-
t.ok(result.data.docSets[0].uniqueCharsString.length > 0);
|
|
525
|
-
t.ok(result.data.docSets[0].uniqueCharsString.includes(' '));
|
|
526
|
-
t.ok(result.data.docSets[0].uniqueCharsString.includes('!'));
|
|
527
|
-
t.ok(result.data.docSets[0].uniqueCharsString.includes('A'));
|
|
528
|
-
t.ok(result.data.docSets[0].uniqueCharsString.includes('1'));
|
|
529
|
-
t.ok(result.data.docSets[0].uniqueCharsString.includes('א'));
|
|
530
|
-
} catch (err) {
|
|
531
|
-
console.log(err);
|
|
532
|
-
}
|
|
533
|
-
},
|
|
534
|
-
);
|