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,71 +0,0 @@
|
|
|
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
|
-
);
|
|
@@ -1,402 +0,0 @@
|
|
|
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
|
-
);
|
|
@@ -1,19 +0,0 @@
|
|
|
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
|
-
);
|
package/test/code/main/fig.cjs
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
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
|
-
);
|